aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2015-09-06 18:46:46 +0000
committerDimitry Andric <dim@FreeBSD.org>2015-09-06 18:46:46 +0000
commit61b9a7258a7693d7f3674a5a1daf7b036ff1d382 (patch)
treeec41ed70ffca97240e76f9a78bb2dedba28f310c /test
parentf857581820d15e410e9945d2fcd5f7163be25a96 (diff)
downloadsrc-61b9a7258a7693d7f3674a5a1daf7b036ff1d382.tar.gz
src-61b9a7258a7693d7f3674a5a1daf7b036ff1d382.zip
Notes
Diffstat (limited to 'test')
-rw-r--r--test/CMakeLists.txt89
-rw-r--r--test/libcxx/__init__.py0
-rw-r--r--test/libcxx/compiler.py152
-rw-r--r--test/libcxx/containers/unord/unord.set/insert_dup_alloc.pass.cpp48
-rw-r--r--test/libcxx/double_include.sh.cpp114
-rw-r--r--test/libcxx/experimental/algorithms/header.algorithm.synop/includes.pass.cpp20
-rw-r--r--test/libcxx/experimental/algorithms/version.pass.cpp20
-rw-r--r--test/libcxx/experimental/containers/sequences/dynarray/dynarray.cons/alloc.pass.cpp86
-rw-r--r--test/libcxx/experimental/containers/sequences/dynarray/dynarray.cons/default.pass.cpp95
-rw-r--r--test/libcxx/experimental/containers/sequences/dynarray/dynarray.data/default.pass.cpp67
-rw-r--r--test/libcxx/experimental/containers/sequences/dynarray/dynarray.mutate/default.pass.cpp48
-rw-r--r--test/libcxx/experimental/containers/sequences/dynarray/dynarray.overview/at.pass.cpp94
-rw-r--r--test/libcxx/experimental/containers/sequences/dynarray/dynarray.overview/begin_end.pass.cpp108
-rw-r--r--test/libcxx/experimental/containers/sequences/dynarray/dynarray.overview/capacity.pass.cpp57
-rw-r--r--test/libcxx/experimental/containers/sequences/dynarray/dynarray.overview/front_back.pass.cpp68
-rw-r--r--test/libcxx/experimental/containers/sequences/dynarray/dynarray.overview/indexing.pass.cpp71
-rw-r--r--test/libcxx/experimental/containers/sequences/dynarray/dynarray.traits/default.pass.cpp31
-rw-r--r--test/libcxx/experimental/containers/sequences/dynarray/dynarray.zero/default.pass.cpp50
-rw-r--r--test/libcxx/experimental/containers/sequences/dynarray/nothing_to_do.pass.cpp12
-rw-r--r--test/libcxx/experimental/utilities/ratio/header.ratio.synop/includes.pass.cpp24
-rw-r--r--test/libcxx/experimental/utilities/ratio/version.pass.cpp20
-rw-r--r--test/libcxx/experimental/utilities/syserror/header.system_error.synop/includes.pass.cpp22
-rw-r--r--test/libcxx/experimental/utilities/syserror/version.pass.cpp20
-rw-r--r--test/libcxx/experimental/utilities/time/header.chrono.synop/includes.pass.cpp22
-rw-r--r--test/libcxx/experimental/utilities/time/version.pass.cpp20
-rw-r--r--test/libcxx/experimental/utilities/tuple/header.tuple.synop/includes.pass.cpp21
-rw-r--r--test/libcxx/experimental/utilities/tuple/version.pass.cpp20
-rw-r--r--test/libcxx/selftest/not_test.sh.cpp17
-rw-r--r--test/libcxx/selftest/test.fail.cpp11
-rw-r--r--test/libcxx/selftest/test.pass.cpp13
-rw-r--r--test/libcxx/selftest/test.sh.cpp16
-rw-r--r--test/libcxx/selftest/test_macros.pass.cpp58
-rw-r--r--test/libcxx/test/__init__.py0
-rw-r--r--test/libcxx/test/config.py709
-rw-r--r--test/libcxx/test/executor.py191
-rw-r--r--test/libcxx/test/format.py163
-rw-r--r--test/libcxx/test/target_info.py55
-rw-r--r--test/libcxx/test/tracing.py34
-rw-r--r--test/libcxx/type_traits/convert_to_integral.pass.cpp94
-rw-r--r--test/libcxx/util.py46
-rw-r--r--test/libcxx/utilities/memory/util.smartptr/race_condition.pass.cpp94
-rw-r--r--test/lit.cfg51
-rw-r--r--test/lit.site.cfg.in30
-rw-r--r--test/nothing_to_do.pass.cpp13
-rw-r--r--test/std/algorithms/alg.c.library/tested_elsewhere.pass.cpp12
-rw-r--r--test/std/algorithms/alg.modifying.operations/alg.copy/copy.pass.cpp73
-rw-r--r--test/std/algorithms/alg.modifying.operations/alg.copy/copy_backward.pass.cpp51
-rw-r--r--test/std/algorithms/alg.modifying.operations/alg.copy/copy_if.pass.cpp80
-rw-r--r--test/std/algorithms/alg.modifying.operations/alg.copy/copy_n.pass.cpp76
-rw-r--r--test/std/algorithms/alg.modifying.operations/alg.fill/fill.pass.cpp59
-rw-r--r--test/std/algorithms/alg.modifying.operations/alg.fill/fill_n.pass.cpp156
-rw-r--r--test/std/algorithms/alg.modifying.operations/alg.generate/generate.pass.cpp47
-rw-r--r--test/std/algorithms/alg.modifying.operations/alg.generate/generate_n.pass.cpp50
-rw-r--r--test/std/algorithms/alg.modifying.operations/alg.move/move.pass.cpp134
-rw-r--r--test/std/algorithms/alg.modifying.operations/alg.move/move_backward.pass.cpp88
-rw-r--r--test/std/algorithms/alg.modifying.operations/alg.partitions/is_partitioned.pass.cpp77
-rw-r--r--test/std/algorithms/alg.modifying.operations/alg.partitions/partition.pass.cpp104
-rw-r--r--test/std/algorithms/alg.modifying.operations/alg.partitions/partition_copy.pass.cpp50
-rw-r--r--test/std/algorithms/alg.modifying.operations/alg.partitions/partition_point.pass.cpp76
-rw-r--r--test/std/algorithms/alg.modifying.operations/alg.partitions/stable_partition.pass.cpp314
-rw-r--r--test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp30
-rw-r--r--test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_rand.pass.cpp37
-rw-r--r--test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_urng.pass.cpp31
-rw-r--r--test/std/algorithms/alg.modifying.operations/alg.remove/remove.pass.cpp83
-rw-r--r--test/std/algorithms/alg.modifying.operations/alg.remove/remove_copy.pass.cpp70
-rw-r--r--test/std/algorithms/alg.modifying.operations/alg.remove/remove_copy_if.pass.cpp73
-rw-r--r--test/std/algorithms/alg.modifying.operations/alg.remove/remove_if.pass.cpp98
-rw-r--r--test/std/algorithms/alg.modifying.operations/alg.replace/replace.pass.cpp44
-rw-r--r--test/std/algorithms/alg.modifying.operations/alg.replace/replace_copy.pass.cpp72
-rw-r--r--test/std/algorithms/alg.modifying.operations/alg.replace/replace_copy_if.pass.cpp74
-rw-r--r--test/std/algorithms/alg.modifying.operations/alg.replace/replace_if.pass.cpp45
-rw-r--r--test/std/algorithms/alg.modifying.operations/alg.reverse/reverse.pass.cpp60
-rw-r--r--test/std/algorithms/alg.modifying.operations/alg.reverse/reverse_copy.pass.cpp81
-rw-r--r--test/std/algorithms/alg.modifying.operations/alg.rotate/rotate.pass.cpp439
-rw-r--r--test/std/algorithms/alg.modifying.operations/alg.rotate/rotate_copy.pass.cpp134
-rw-r--r--test/std/algorithms/alg.modifying.operations/alg.swap/iter_swap.pass.cpp27
-rw-r--r--test/std/algorithms/alg.modifying.operations/alg.swap/swap_ranges.pass.cpp159
-rw-r--r--test/std/algorithms/alg.modifying.operations/alg.transform/binary_transform.pass.cpp217
-rw-r--r--test/std/algorithms/alg.modifying.operations/alg.transform/unary_transform.pass.cpp77
-rw-r--r--test/std/algorithms/alg.modifying.operations/alg.unique/unique.pass.cpp189
-rw-r--r--test/std/algorithms/alg.modifying.operations/alg.unique/unique_copy.pass.cpp125
-rw-r--r--test/std/algorithms/alg.modifying.operations/alg.unique/unique_copy_pred.pass.cpp152
-rw-r--r--test/std/algorithms/alg.modifying.operations/alg.unique/unique_pred.pass.cpp231
-rw-r--r--test/std/algorithms/alg.modifying.operations/nothing_to_do.pass.cpp12
-rw-r--r--test/std/algorithms/alg.nonmodifying/alg.adjacent.find/adjacent_find.pass.cpp35
-rw-r--r--test/std/algorithms/alg.nonmodifying/alg.adjacent.find/adjacent_find_pred.pass.cpp39
-rw-r--r--test/std/algorithms/alg.nonmodifying/alg.all_of/all_of.pass.cpp47
-rw-r--r--test/std/algorithms/alg.nonmodifying/alg.any_of/any_of.pass.cpp55
-rw-r--r--test/std/algorithms/alg.nonmodifying/alg.count/count.pass.cpp32
-rw-r--r--test/std/algorithms/alg.nonmodifying/alg.count/count_if.pass.cpp36
-rw-r--r--test/std/algorithms/alg.nonmodifying/alg.equal/equal.pass.cpp66
-rw-r--r--test/std/algorithms/alg.nonmodifying/alg.equal/equal_pred.pass.cpp87
-rw-r--r--test/std/algorithms/alg.nonmodifying/alg.find.end/find_end.pass.cpp57
-rw-r--r--test/std/algorithms/alg.nonmodifying/alg.find.end/find_end_pred.pass.cpp86
-rw-r--r--test/std/algorithms/alg.nonmodifying/alg.find.first.of/find_first_of.pass.cpp49
-rw-r--r--test/std/algorithms/alg.nonmodifying/alg.find.first.of/find_first_of_pred.pass.cpp55
-rw-r--r--test/std/algorithms/alg.nonmodifying/alg.find/find.pass.cpp31
-rw-r--r--test/std/algorithms/alg.nonmodifying/alg.find/find_if.pass.cpp35
-rw-r--r--test/std/algorithms/alg.nonmodifying/alg.find/find_if_not.pass.cpp35
-rw-r--r--test/std/algorithms/alg.nonmodifying/alg.foreach/test.pass.cpp39
-rw-r--r--test/std/algorithms/alg.nonmodifying/alg.is_permutation/is_permutation.pass.cpp605
-rw-r--r--test/std/algorithms/alg.nonmodifying/alg.is_permutation/is_permutation_pred.pass.cpp729
-rw-r--r--test/std/algorithms/alg.nonmodifying/alg.none_of/none_of.pass.cpp55
-rw-r--r--test/std/algorithms/alg.nonmodifying/alg.search/search.pass.cpp72
-rw-r--r--test/std/algorithms/alg.nonmodifying/alg.search/search_n.pass.cpp77
-rw-r--r--test/std/algorithms/alg.nonmodifying/alg.search/search_n_pred.pass.cpp154
-rw-r--r--test/std/algorithms/alg.nonmodifying/alg.search/search_pred.pass.cpp111
-rw-r--r--test/std/algorithms/alg.nonmodifying/mismatch/mismatch.pass.cpp53
-rw-r--r--test/std/algorithms/alg.nonmodifying/mismatch/mismatch_pred.pass.cpp71
-rw-r--r--test/std/algorithms/alg.nonmodifying/nothing_to_do.pass.cpp12
-rw-r--r--test/std/algorithms/alg.sorting/alg.binary.search/binary.search/binary_search.pass.cpp63
-rw-r--r--test/std/algorithms/alg.sorting/alg.binary.search/binary.search/binary_search_comp.pass.cpp64
-rw-r--r--test/std/algorithms/alg.sorting/alg.binary.search/equal.range/equal_range.pass.cpp69
-rw-r--r--test/std/algorithms/alg.sorting/alg.binary.search/equal.range/equal_range_comp.pass.cpp70
-rw-r--r--test/std/algorithms/alg.sorting/alg.binary.search/lower.bound/lower_bound.pass.cpp64
-rw-r--r--test/std/algorithms/alg.sorting/alg.binary.search/lower.bound/lower_bound_comp.pass.cpp65
-rw-r--r--test/std/algorithms/alg.sorting/alg.binary.search/nothing_to_do.pass.cpp12
-rw-r--r--test/std/algorithms/alg.sorting/alg.binary.search/upper.bound/upper_bound.pass.cpp64
-rw-r--r--test/std/algorithms/alg.sorting/alg.binary.search/upper.bound/upper_bound_comp.pass.cpp65
-rw-r--r--test/std/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap.pass.cpp521
-rw-r--r--test/std/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap_comp.pass.cpp522
-rw-r--r--test/std/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap_until.pass.cpp521
-rw-r--r--test/std/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap_until_comp.pass.cpp522
-rw-r--r--test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap.pass.cpp39
-rw-r--r--test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap_comp.pass.cpp101
-rw-r--r--test/std/algorithms/alg.sorting/alg.heap.operations/nothing_to_do.pass.cpp12
-rw-r--r--test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap.pass.cpp39
-rw-r--r--test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap_comp.pass.cpp68
-rw-r--r--test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap.pass.cpp38
-rw-r--r--test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap_comp.pass.cpp66
-rw-r--r--test/std/algorithms/alg.sorting/alg.heap.operations/sort.heap/sort_heap.pass.cpp40
-rw-r--r--test/std/algorithms/alg.sorting/alg.heap.operations/sort.heap/sort_heap_comp.pass.cpp66
-rw-r--r--test/std/algorithms/alg.sorting/alg.lex.comparison/lexicographical_compare.pass.cpp69
-rw-r--r--test/std/algorithms/alg.sorting/alg.lex.comparison/lexicographical_compare_comp.pass.cpp73
-rw-r--r--test/std/algorithms/alg.sorting/alg.merge/inplace_merge.pass.cpp108
-rw-r--r--test/std/algorithms/alg.sorting/alg.merge/inplace_merge_comp.pass.cpp146
-rw-r--r--test/std/algorithms/alg.sorting/alg.merge/merge.pass.cpp224
-rw-r--r--test/std/algorithms/alg.sorting/alg.merge/merge_comp.pass.cpp234
-rw-r--r--test/std/algorithms/alg.sorting/alg.min.max/max.pass.cpp54
-rw-r--r--test/std/algorithms/alg.sorting/alg.min.max/max_comp.pass.cpp56
-rw-r--r--test/std/algorithms/alg.sorting/alg.min.max/max_element.pass.cpp80
-rw-r--r--test/std/algorithms/alg.sorting/alg.min.max/max_element_comp.pass.cpp100
-rw-r--r--test/std/algorithms/alg.sorting/alg.min.max/max_init_list.pass.cpp42
-rw-r--r--test/std/algorithms/alg.sorting/alg.min.max/max_init_list_comp.pass.cpp43
-rw-r--r--test/std/algorithms/alg.sorting/alg.min.max/min.pass.cpp54
-rw-r--r--test/std/algorithms/alg.sorting/alg.min.max/min_comp.pass.cpp56
-rw-r--r--test/std/algorithms/alg.sorting/alg.min.max/min_element.pass.cpp80
-rw-r--r--test/std/algorithms/alg.sorting/alg.min.max/min_element_comp.pass.cpp100
-rw-r--r--test/std/algorithms/alg.sorting/alg.min.max/min_init_list.pass.cpp42
-rw-r--r--test/std/algorithms/alg.sorting/alg.min.max/min_init_list_comp.pass.cpp43
-rw-r--r--test/std/algorithms/alg.sorting/alg.min.max/minmax.pass.cpp62
-rw-r--r--test/std/algorithms/alg.sorting/alg.min.max/minmax_comp.pass.cpp65
-rw-r--r--test/std/algorithms/alg.sorting/alg.min.max/minmax_element.pass.cpp98
-rw-r--r--test/std/algorithms/alg.sorting/alg.min.max/minmax_element_comp.pass.cpp104
-rw-r--r--test/std/algorithms/alg.sorting/alg.min.max/minmax_init_list.pass.cpp39
-rw-r--r--test/std/algorithms/alg.sorting/alg.min.max/minmax_init_list_comp.pass.cpp77
-rw-r--r--test/std/algorithms/alg.sorting/alg.nth.element/nth_element.pass.cpp63
-rw-r--r--test/std/algorithms/alg.sorting/alg.nth.element/nth_element_comp.pass.cpp86
-rw-r--r--test/std/algorithms/alg.sorting/alg.permutation.generators/next_permutation.pass.cpp66
-rw-r--r--test/std/algorithms/alg.sorting/alg.permutation.generators/next_permutation_comp.pass.cpp68
-rw-r--r--test/std/algorithms/alg.sorting/alg.permutation.generators/prev_permutation.pass.cpp66
-rw-r--r--test/std/algorithms/alg.sorting/alg.permutation.generators/prev_permutation_comp.pass.cpp68
-rw-r--r--test/std/algorithms/alg.sorting/alg.set.operations/includes/includes.pass.cpp84
-rw-r--r--test/std/algorithms/alg.sorting/alg.set.operations/includes/includes_comp.pass.cpp85
-rw-r--r--test/std/algorithms/alg.sorting/alg.set.operations/nothing_to_do.pass.cpp12
-rw-r--r--test/std/algorithms/alg.sorting/alg.set.operations/set.difference/set_difference.pass.cpp200
-rw-r--r--test/std/algorithms/alg.sorting/alg.set.operations/set.difference/set_difference_comp.pass.cpp202
-rw-r--r--test/std/algorithms/alg.sorting/alg.set.operations/set.intersection/set_intersection.pass.cpp198
-rw-r--r--test/std/algorithms/alg.sorting/alg.set.operations/set.intersection/set_intersection_comp.pass.cpp200
-rw-r--r--test/std/algorithms/alg.sorting/alg.set.operations/set.symmetric.difference/set_symmetric_difference.pass.cpp199
-rw-r--r--test/std/algorithms/alg.sorting/alg.set.operations/set.symmetric.difference/set_symmetric_difference_comp.pass.cpp203
-rw-r--r--test/std/algorithms/alg.sorting/alg.set.operations/set.union/set_union.pass.cpp198
-rw-r--r--test/std/algorithms/alg.sorting/alg.set.operations/set.union/set_union_comp.pass.cpp200
-rw-r--r--test/std/algorithms/alg.sorting/alg.sort/is.sorted/is_sorted.pass.cpp183
-rw-r--r--test/std/algorithms/alg.sorting/alg.sort/is.sorted/is_sorted_comp.pass.cpp184
-rw-r--r--test/std/algorithms/alg.sorting/alg.sort/is.sorted/is_sorted_until.pass.cpp183
-rw-r--r--test/std/algorithms/alg.sorting/alg.sort/is.sorted/is_sorted_until_comp.pass.cpp184
-rw-r--r--test/std/algorithms/alg.sorting/alg.sort/nothing_to_do.pass.cpp12
-rw-r--r--test/std/algorithms/alg.sorting/alg.sort/partial.sort.copy/partial_sort_copy.pass.cpp86
-rw-r--r--test/std/algorithms/alg.sorting/alg.sort/partial.sort.copy/partial_sort_copy_comp.pass.cpp90
-rw-r--r--test/std/algorithms/alg.sorting/alg.sort/partial.sort/partial_sort.pass.cpp63
-rw-r--r--test/std/algorithms/alg.sorting/alg.sort/partial.sort/partial_sort_comp.pass.cpp87
-rw-r--r--test/std/algorithms/alg.sorting/alg.sort/sort/sort.pass.cpp150
-rw-r--r--test/std/algorithms/alg.sorting/alg.sort/sort/sort_comp.pass.cpp57
-rw-r--r--test/std/algorithms/alg.sorting/alg.sort/stable.sort/stable_sort.pass.cpp150
-rw-r--r--test/std/algorithms/alg.sorting/alg.sort/stable.sort/stable_sort_comp.pass.cpp83
-rw-r--r--test/std/algorithms/alg.sorting/nothing_to_do.pass.cpp12
-rw-r--r--test/std/algorithms/algorithms.general/nothing_to_do.pass.cpp12
-rw-r--r--test/std/algorithms/version.pass.cpp20
-rw-r--r--test/std/atomics/atomics.fences/atomic_signal_fence.pass.cpp21
-rw-r--r--test/std/atomics/atomics.fences/atomic_thread_fence.pass.cpp21
-rw-r--r--test/std/atomics/atomics.flag/atomic_flag_clear.pass.cpp36
-rw-r--r--test/std/atomics/atomics.flag/atomic_flag_clear_explicit.pass.cpp60
-rw-r--r--test/std/atomics/atomics.flag/atomic_flag_test_and_set.pass.cpp36
-rw-r--r--test/std/atomics/atomics.flag/atomic_flag_test_and_set_explicit.pass.cpp96
-rw-r--r--test/std/atomics/atomics.flag/clear.pass.cpp72
-rw-r--r--test/std/atomics/atomics.flag/copy_assign.fail.cpp24
-rw-r--r--test/std/atomics/atomics.flag/copy_ctor.fail.cpp23
-rw-r--r--test/std/atomics/atomics.flag/copy_volatile_assign.fail.cpp24
-rw-r--r--test/std/atomics/atomics.flag/default.pass.cpp33
-rw-r--r--test/std/atomics/atomics.flag/init.pass.cpp25
-rw-r--r--test/std/atomics/atomics.flag/test_and_set.pass.cpp108
-rw-r--r--test/std/atomics/atomics.general/nothing_to_do.pass.cpp13
-rw-r--r--test/std/atomics/atomics.general/replace_failure_order.pass.cpp43
-rw-r--r--test/std/atomics/atomics.lockfree/lockfree.pass.cpp52
-rw-r--r--test/std/atomics/atomics.order/kill_dependency.pass.cpp23
-rw-r--r--test/std/atomics/atomics.order/memory_order.pass.cpp33
-rw-r--r--test/std/atomics/atomics.syn/nothing_to_do.pass.cpp13
-rw-r--r--test/std/atomics/atomics.types.generic/address.pass.cpp140
-rw-r--r--test/std/atomics/atomics.types.generic/bool.pass.cpp237
-rw-r--r--test/std/atomics/atomics.types.generic/cstdint_typedefs.pass.cpp69
-rw-r--r--test/std/atomics/atomics.types.generic/integral.pass.cpp203
-rw-r--r--test/std/atomics/atomics.types.generic/integral_typedefs.pass.cpp50
-rw-r--r--test/std/atomics/atomics.types.generic/trivially_copyable.fail.cpp70
-rw-r--r--test/std/atomics/atomics.types.generic/trivially_copyable.pass.cpp77
-rw-r--r--test/std/atomics/atomics.types.operations/atomics.types.operations.arith/nothing_to_do.pass.cpp13
-rw-r--r--test/std/atomics/atomics.types.operations/atomics.types.operations.general/nothing_to_do.pass.cpp13
-rw-r--r--test/std/atomics/atomics.types.operations/atomics.types.operations.pointer/nothing_to_do.pass.cpp13
-rw-r--r--test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_strong.pass.cpp88
-rw-r--r--test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_strong_explicit.pass.cpp95
-rw-r--r--test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_weak.pass.cpp90
-rw-r--r--test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_weak_explicit.pass.cpp97
-rw-r--r--test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_exchange.pass.cpp73
-rw-r--r--test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_exchange_explicit.pass.cpp75
-rw-r--r--test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_add.pass.cpp111
-rw-r--r--test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_add_explicit.pass.cpp115
-rw-r--r--test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_and.pass.cpp64
-rw-r--r--test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_and_explicit.pass.cpp66
-rw-r--r--test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_or.pass.cpp64
-rw-r--r--test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_or_explicit.pass.cpp66
-rw-r--r--test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_sub.pass.cpp111
-rw-r--r--test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_sub_explicit.pass.cpp116
-rw-r--r--test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_xor.pass.cpp64
-rw-r--r--test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_xor_explicit.pass.cpp66
-rw-r--r--test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_init.pass.cpp71
-rw-r--r--test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_is_lock_free.pass.cpp61
-rw-r--r--test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_load.pass.cpp71
-rw-r--r--test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_load_explicit.pass.cpp71
-rw-r--r--test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_store.pass.cpp71
-rw-r--r--test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_store_explicit.pass.cpp71
-rw-r--r--test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_var_init.pass.cpp24
-rw-r--r--test/std/atomics/atomics.types.operations/atomics.types.operations.req/ctor.pass.cpp56
-rw-r--r--test/std/atomics/atomics.types.operations/atomics.types.operations.templ/nothing_to_do.pass.cpp13
-rw-r--r--test/std/atomics/atomics.types.operations/nothing_to_do.pass.cpp13
-rw-r--r--test/std/atomics/libcpp-has-no-threads.fail.cpp23
-rw-r--r--test/std/atomics/libcpp-has-no-threads.pass.cpp18
-rw-r--r--test/std/atomics/version.pass.cpp22
-rw-r--r--test/std/containers/Copyable.h18
-rw-r--r--test/std/containers/Emplaceable.h54
-rw-r--r--test/std/containers/NotConstructible.h39
-rw-r--r--test/std/containers/associative/map/compare.pass.cpp32
-rw-r--r--test/std/containers/associative/map/map.access/at.pass.cpp154
-rw-r--r--test/std/containers/associative/map/map.access/empty.pass.cpp43
-rw-r--r--test/std/containers/associative/map/map.access/index_key.pass.cpp105
-rw-r--r--test/std/containers/associative/map/map.access/index_rv_key.pass.cpp58
-rw-r--r--test/std/containers/associative/map/map.access/index_tuple.pass.cpp33
-rw-r--r--test/std/containers/associative/map/map.access/iterator.pass.cpp227
-rw-r--r--test/std/containers/associative/map/map.access/max_size.pass.cpp35
-rw-r--r--test/std/containers/associative/map/map.access/size.pass.cpp59
-rw-r--r--test/std/containers/associative/map/map.cons/alloc.pass.cpp42
-rw-r--r--test/std/containers/associative/map/map.cons/assign_initializer_list.pass.cpp75
-rw-r--r--test/std/containers/associative/map/map.cons/compare.pass.cpp40
-rw-r--r--test/std/containers/associative/map/map.cons/compare_alloc.pass.cpp45
-rw-r--r--test/std/containers/associative/map/map.cons/copy.pass.cpp131
-rw-r--r--test/std/containers/associative/map/map.cons/copy_alloc.pass.cpp95
-rw-r--r--test/std/containers/associative/map/map.cons/copy_assign.pass.cpp182
-rw-r--r--test/std/containers/associative/map/map.cons/default.pass.cpp40
-rw-r--r--test/std/containers/associative/map/map.cons/default_noexcept.pass.cpp53
-rw-r--r--test/std/containers/associative/map/map.cons/default_recursive.pass.cpp29
-rw-r--r--test/std/containers/associative/map/map.cons/dtor_noexcept.pass.cpp51
-rw-r--r--test/std/containers/associative/map/map.cons/initializer_list.pass.cpp67
-rw-r--r--test/std/containers/associative/map/map.cons/initializer_list_compare.pass.cpp69
-rw-r--r--test/std/containers/associative/map/map.cons/initializer_list_compare_alloc.pass.cpp100
-rw-r--r--test/std/containers/associative/map/map.cons/iter_iter.pass.cpp68
-rw-r--r--test/std/containers/associative/map/map.cons/iter_iter_comp.pass.cpp73
-rw-r--r--test/std/containers/associative/map/map.cons/iter_iter_comp_alloc.pass.cpp108
-rw-r--r--test/std/containers/associative/map/map.cons/move.pass.cpp120
-rw-r--r--test/std/containers/associative/map/map.cons/move_alloc.pass.cpp234
-rw-r--r--test/std/containers/associative/map/map.cons/move_assign.pass.cpp190
-rw-r--r--test/std/containers/associative/map/map.cons/move_assign_noexcept.pass.cpp53
-rw-r--r--test/std/containers/associative/map/map.cons/move_noexcept.pass.cpp51
-rw-r--r--test/std/containers/associative/map/map.modifiers/clear.pass.cpp63
-rw-r--r--test/std/containers/associative/map/map.modifiers/emplace.pass.cpp165
-rw-r--r--test/std/containers/associative/map/map.modifiers/emplace_hint.pass.cpp160
-rw-r--r--test/std/containers/associative/map/map.modifiers/erase_iter.pass.cpp259
-rw-r--r--test/std/containers/associative/map/map.modifiers/erase_iter_iter.pass.cpp157
-rw-r--r--test/std/containers/associative/map/map.modifiers/erase_key.pass.cpp275
-rw-r--r--test/std/containers/associative/map/map.modifiers/insert_cv.pass.cpp89
-rw-r--r--test/std/containers/associative/map/map.modifiers/insert_initializer_list.pass.cpp71
-rw-r--r--test/std/containers/associative/map/map.modifiers/insert_iter_cv.pass.cpp81
-rw-r--r--test/std/containers/associative/map/map.modifiers/insert_iter_iter.pass.cpp77
-rw-r--r--test/std/containers/associative/map/map.modifiers/insert_iter_rv.pass.cpp87
-rw-r--r--test/std/containers/associative/map/map.modifiers/insert_or_assign.pass.cpp192
-rw-r--r--test/std/containers/associative/map/map.modifiers/insert_rv.pass.cpp93
-rw-r--r--test/std/containers/associative/map/map.modifiers/try.emplace.pass.cpp189
-rw-r--r--test/std/containers/associative/map/map.ops/count.pass.cpp193
-rw-r--r--test/std/containers/associative/map/map.ops/count0.pass.cpp34
-rw-r--r--test/std/containers/associative/map/map.ops/count1.fail.cpp39
-rw-r--r--test/std/containers/associative/map/map.ops/count2.fail.cpp39
-rw-r--r--test/std/containers/associative/map/map.ops/count3.fail.cpp39
-rw-r--r--test/std/containers/associative/map/map.ops/equal_range.pass.cpp490
-rw-r--r--test/std/containers/associative/map/map.ops/equal_range0.pass.cpp34
-rw-r--r--test/std/containers/associative/map/map.ops/equal_range1.fail.cpp39
-rw-r--r--test/std/containers/associative/map/map.ops/equal_range2.fail.cpp39
-rw-r--r--test/std/containers/associative/map/map.ops/equal_range3.fail.cpp39
-rw-r--r--test/std/containers/associative/map/map.ops/find.pass.cpp260
-rw-r--r--test/std/containers/associative/map/map.ops/find0.pass.cpp34
-rw-r--r--test/std/containers/associative/map/map.ops/find1.fail.cpp39
-rw-r--r--test/std/containers/associative/map/map.ops/find2.fail.cpp39
-rw-r--r--test/std/containers/associative/map/map.ops/find3.fail.cpp39
-rw-r--r--test/std/containers/associative/map/map.ops/lower_bound.pass.cpp372
-rw-r--r--test/std/containers/associative/map/map.ops/lower_bound0.pass.cpp34
-rw-r--r--test/std/containers/associative/map/map.ops/lower_bound1.fail.cpp39
-rw-r--r--test/std/containers/associative/map/map.ops/lower_bound2.fail.cpp39
-rw-r--r--test/std/containers/associative/map/map.ops/lower_bound3.fail.cpp39
-rw-r--r--test/std/containers/associative/map/map.ops/upper_bound.pass.cpp335
-rw-r--r--test/std/containers/associative/map/map.ops/upper_bound0.pass.cpp34
-rw-r--r--test/std/containers/associative/map/map.ops/upper_bound1.fail.cpp39
-rw-r--r--test/std/containers/associative/map/map.ops/upper_bound2.fail.cpp39
-rw-r--r--test/std/containers/associative/map/map.ops/upper_bound3.fail.cpp39
-rw-r--r--test/std/containers/associative/map/map.special/member_swap.pass.cpp176
-rw-r--r--test/std/containers/associative/map/map.special/non_member_swap.pass.cpp281
-rw-r--r--test/std/containers/associative/map/map.special/swap_noexcept.pass.cpp148
-rw-r--r--test/std/containers/associative/map/types.pass.cpp70
-rw-r--r--test/std/containers/associative/map/version.pass.cpp20
-rw-r--r--test/std/containers/associative/multimap/empty.pass.cpp43
-rw-r--r--test/std/containers/associative/multimap/iterator.pass.cpp231
-rw-r--r--test/std/containers/associative/multimap/max_size.pass.cpp35
-rw-r--r--test/std/containers/associative/multimap/multimap.cons/alloc.pass.cpp42
-rw-r--r--test/std/containers/associative/multimap/multimap.cons/assign_initializer_list.pass.cpp85
-rw-r--r--test/std/containers/associative/multimap/multimap.cons/compare.pass.cpp40
-rw-r--r--test/std/containers/associative/multimap/multimap.cons/compare_alloc.pass.cpp45
-rw-r--r--test/std/containers/associative/multimap/multimap.cons/copy.pass.cpp104
-rw-r--r--test/std/containers/associative/multimap/multimap.cons/copy_alloc.pass.cpp77
-rw-r--r--test/std/containers/associative/multimap/multimap.cons/copy_assign.pass.cpp125
-rw-r--r--test/std/containers/associative/multimap/multimap.cons/default.pass.cpp40
-rw-r--r--test/std/containers/associative/multimap/multimap.cons/default_noexcept.pass.cpp53
-rw-r--r--test/std/containers/associative/multimap/multimap.cons/default_recursive.pass.cpp29
-rw-r--r--test/std/containers/associative/multimap/multimap.cons/dtor_noexcept.pass.cpp51
-rw-r--r--test/std/containers/associative/multimap/multimap.cons/initializer_list.pass.cpp83
-rw-r--r--test/std/containers/associative/multimap/multimap.cons/initializer_list_compare.pass.cpp91
-rw-r--r--test/std/containers/associative/multimap/multimap.cons/initializer_list_compare_alloc.pass.cpp129
-rw-r--r--test/std/containers/associative/multimap/multimap.cons/iter_iter.pass.cpp112
-rw-r--r--test/std/containers/associative/multimap/multimap.cons/iter_iter_comp.pass.cpp86
-rw-r--r--test/std/containers/associative/multimap/multimap.cons/iter_iter_comp_alloc.pass.cpp91
-rw-r--r--test/std/containers/associative/multimap/multimap.cons/move.pass.cpp132
-rw-r--r--test/std/containers/associative/multimap/multimap.cons/move_alloc.pass.cpp234
-rw-r--r--test/std/containers/associative/multimap/multimap.cons/move_assign.pass.cpp190
-rw-r--r--test/std/containers/associative/multimap/multimap.cons/move_assign_noexcept.pass.cpp53
-rw-r--r--test/std/containers/associative/multimap/multimap.cons/move_noexcept.pass.cpp51
-rw-r--r--test/std/containers/associative/multimap/multimap.modifiers/clear.pass.cpp63
-rw-r--r--test/std/containers/associative/multimap/multimap.modifiers/emplace.pass.cpp150
-rw-r--r--test/std/containers/associative/multimap/multimap.modifiers/emplace_hint.pass.cpp160
-rw-r--r--test/std/containers/associative/multimap/multimap.modifiers/erase_iter.pass.cpp301
-rw-r--r--test/std/containers/associative/multimap/multimap.modifiers/erase_iter_iter.pass.cpp157
-rw-r--r--test/std/containers/associative/multimap/multimap.modifiers/erase_key.pass.cpp153
-rw-r--r--test/std/containers/associative/multimap/multimap.modifiers/insert_cv.pass.cpp81
-rw-r--r--test/std/containers/associative/multimap/multimap.modifiers/insert_initializer_list.pass.cpp91
-rw-r--r--test/std/containers/associative/multimap/multimap.modifiers/insert_iter_cv.pass.cpp81
-rw-r--r--test/std/containers/associative/multimap/multimap.modifiers/insert_iter_iter.pass.cpp101
-rw-r--r--test/std/containers/associative/multimap/multimap.modifiers/insert_iter_rv.pass.cpp87
-rw-r--r--test/std/containers/associative/multimap/multimap.modifiers/insert_rv.pass.cpp85
-rw-r--r--test/std/containers/associative/multimap/multimap.ops/count.pass.cpp175
-rw-r--r--test/std/containers/associative/multimap/multimap.ops/count0.pass.cpp34
-rw-r--r--test/std/containers/associative/multimap/multimap.ops/count1.fail.cpp37
-rw-r--r--test/std/containers/associative/multimap/multimap.ops/count2.fail.cpp37
-rw-r--r--test/std/containers/associative/multimap/multimap.ops/count3.fail.cpp37
-rw-r--r--test/std/containers/associative/multimap/multimap.ops/equal_range.pass.cpp287
-rw-r--r--test/std/containers/associative/multimap/multimap.ops/equal_range0.pass.cpp34
-rw-r--r--test/std/containers/associative/multimap/multimap.ops/equal_range1.fail.cpp37
-rw-r--r--test/std/containers/associative/multimap/multimap.ops/equal_range2.fail.cpp39
-rw-r--r--test/std/containers/associative/multimap/multimap.ops/equal_range3.fail.cpp39
-rw-r--r--test/std/containers/associative/multimap/multimap.ops/find.pass.cpp223
-rw-r--r--test/std/containers/associative/multimap/multimap.ops/find0.pass.cpp34
-rw-r--r--test/std/containers/associative/multimap/multimap.ops/find1.fail.cpp39
-rw-r--r--test/std/containers/associative/multimap/multimap.ops/find2.fail.cpp39
-rw-r--r--test/std/containers/associative/multimap/multimap.ops/find3.fail.cpp39
-rw-r--r--test/std/containers/associative/multimap/multimap.ops/lower_bound.pass.cpp237
-rw-r--r--test/std/containers/associative/multimap/multimap.ops/lower_bound0.pass.cpp34
-rw-r--r--test/std/containers/associative/multimap/multimap.ops/lower_bound1.fail.cpp39
-rw-r--r--test/std/containers/associative/multimap/multimap.ops/lower_bound2.fail.cpp39
-rw-r--r--test/std/containers/associative/multimap/multimap.ops/lower_bound3.fail.cpp39
-rw-r--r--test/std/containers/associative/multimap/multimap.ops/upper_bound.pass.cpp236
-rw-r--r--test/std/containers/associative/multimap/multimap.ops/upper_bound0.pass.cpp34
-rw-r--r--test/std/containers/associative/multimap/multimap.ops/upper_bound1.fail.cpp39
-rw-r--r--test/std/containers/associative/multimap/multimap.ops/upper_bound2.fail.cpp39
-rw-r--r--test/std/containers/associative/multimap/multimap.ops/upper_bound3.fail.cpp39
-rw-r--r--test/std/containers/associative/multimap/multimap.special/member_swap.pass.cpp176
-rw-r--r--test/std/containers/associative/multimap/multimap.special/non_member_swap.pass.cpp281
-rw-r--r--test/std/containers/associative/multimap/multimap.special/swap_noexcept.pass.cpp148
-rw-r--r--test/std/containers/associative/multimap/scary.pass.cpp24
-rw-r--r--test/std/containers/associative/multimap/size.pass.cpp59
-rw-r--r--test/std/containers/associative/multimap/types.pass.cpp70
-rw-r--r--test/std/containers/associative/multiset/clear.pass.cpp63
-rw-r--r--test/std/containers/associative/multiset/count.pass.cpp160
-rw-r--r--test/std/containers/associative/multiset/emplace.pass.cpp83
-rw-r--r--test/std/containers/associative/multiset/emplace_hint.pass.cpp83
-rw-r--r--test/std/containers/associative/multiset/empty.pass.cpp43
-rw-r--r--test/std/containers/associative/multiset/equal_range.pass.cpp263
-rw-r--r--test/std/containers/associative/multiset/erase_iter.pass.cpp203
-rw-r--r--test/std/containers/associative/multiset/erase_iter_iter.pass.cpp141
-rw-r--r--test/std/containers/associative/multiset/erase_key.pass.cpp129
-rw-r--r--test/std/containers/associative/multiset/find.pass.cpp240
-rw-r--r--test/std/containers/associative/multiset/insert_cv.pass.cpp73
-rw-r--r--test/std/containers/associative/multiset/insert_initializer_list.pass.cpp61
-rw-r--r--test/std/containers/associative/multiset/insert_iter_cv.pass.cpp73
-rw-r--r--test/std/containers/associative/multiset/insert_iter_iter.pass.cpp85
-rw-r--r--test/std/containers/associative/multiset/insert_iter_rv.pass.cpp76
-rw-r--r--test/std/containers/associative/multiset/insert_rv.pass.cpp76
-rw-r--r--test/std/containers/associative/multiset/iterator.pass.cpp215
-rw-r--r--test/std/containers/associative/multiset/lower_bound.pass.cpp223
-rw-r--r--test/std/containers/associative/multiset/max_size.pass.cpp35
-rw-r--r--test/std/containers/associative/multiset/multiset.cons/alloc.pass.cpp29
-rw-r--r--test/std/containers/associative/multiset/multiset.cons/assign_initializer_list.pass.cpp57
-rw-r--r--test/std/containers/associative/multiset/multiset.cons/compare.pass.cpp28
-rw-r--r--test/std/containers/associative/multiset/multiset.cons/compare_alloc.pass.cpp31
-rw-r--r--test/std/containers/associative/multiset/multiset.cons/copy.pass.cpp118
-rw-r--r--test/std/containers/associative/multiset/multiset.cons/copy_alloc.pass.cpp68
-rw-r--r--test/std/containers/associative/multiset/multiset.cons/copy_assign.pass.cpp138
-rw-r--r--test/std/containers/associative/multiset/multiset.cons/default.pass.cpp40
-rw-r--r--test/std/containers/associative/multiset/multiset.cons/default_noexcept.pass.cpp53
-rw-r--r--test/std/containers/associative/multiset/multiset.cons/dtor_noexcept.pass.cpp51
-rw-r--r--test/std/containers/associative/multiset/multiset.cons/initializer_list.pass.cpp73
-rw-r--r--test/std/containers/associative/multiset/multiset.cons/initializer_list_compare.pass.cpp38
-rw-r--r--test/std/containers/associative/multiset/multiset.cons/initializer_list_compare_alloc.pass.cpp41
-rw-r--r--test/std/containers/associative/multiset/multiset.cons/iter_iter.pass.cpp83
-rw-r--r--test/std/containers/associative/multiset/multiset.cons/iter_iter_alloc.pass.cpp92
-rw-r--r--test/std/containers/associative/multiset/multiset.cons/iter_iter_comp.pass.cpp53
-rw-r--r--test/std/containers/associative/multiset/multiset.cons/move.pass.cpp119
-rw-r--r--test/std/containers/associative/multiset/multiset.cons/move_alloc.pass.cpp187
-rw-r--r--test/std/containers/associative/multiset/multiset.cons/move_assign.pass.cpp186
-rw-r--r--test/std/containers/associative/multiset/multiset.cons/move_assign_noexcept.pass.cpp53
-rw-r--r--test/std/containers/associative/multiset/multiset.cons/move_noexcept.pass.cpp51
-rw-r--r--test/std/containers/associative/multiset/multiset.special/member_swap.pass.cpp177
-rw-r--r--test/std/containers/associative/multiset/multiset.special/non_member_swap.pass.cpp165
-rw-r--r--test/std/containers/associative/multiset/multiset.special/swap_noexcept.pass.cpp148
-rw-r--r--test/std/containers/associative/multiset/scary.pass.cpp24
-rw-r--r--test/std/containers/associative/multiset/size.pass.cpp59
-rw-r--r--test/std/containers/associative/multiset/types.pass.cpp70
-rw-r--r--test/std/containers/associative/multiset/upper_bound.pass.cpp222
-rw-r--r--test/std/containers/associative/set/clear.pass.cpp63
-rw-r--r--test/std/containers/associative/set/count.pass.cpp168
-rw-r--r--test/std/containers/associative/set/emplace.pass.cpp90
-rw-r--r--test/std/containers/associative/set/emplace_hint.pass.cpp83
-rw-r--r--test/std/containers/associative/set/empty.pass.cpp43
-rw-r--r--test/std/containers/associative/set/equal_range.pass.cpp370
-rw-r--r--test/std/containers/associative/set/erase_iter.pass.cpp203
-rw-r--r--test/std/containers/associative/set/erase_iter_iter.pass.cpp141
-rw-r--r--test/std/containers/associative/set/erase_key.pass.cpp203
-rw-r--r--test/std/containers/associative/set/find.pass.cpp240
-rw-r--r--test/std/containers/associative/set/insert_cv.pass.cpp81
-rw-r--r--test/std/containers/associative/set/insert_initializer_list.pass.cpp61
-rw-r--r--test/std/containers/associative/set/insert_iter_cv.pass.cpp73
-rw-r--r--test/std/containers/associative/set/insert_iter_iter.pass.cpp73
-rw-r--r--test/std/containers/associative/set/insert_iter_rv.pass.cpp76
-rw-r--r--test/std/containers/associative/set/insert_rv.pass.cpp84
-rw-r--r--test/std/containers/associative/set/iterator.pass.cpp211
-rw-r--r--test/std/containers/associative/set/lower_bound.pass.cpp337
-rw-r--r--test/std/containers/associative/set/max_size.pass.cpp35
-rw-r--r--test/std/containers/associative/set/set.cons/alloc.pass.cpp29
-rw-r--r--test/std/containers/associative/set/set.cons/assign_initializer_list.pass.cpp57
-rw-r--r--test/std/containers/associative/set/set.cons/compare.pass.cpp28
-rw-r--r--test/std/containers/associative/set/set.cons/compare_alloc.pass.cpp31
-rw-r--r--test/std/containers/associative/set/set.cons/copy.pass.cpp94
-rw-r--r--test/std/containers/associative/set/set.cons/copy_alloc.pass.cpp56
-rw-r--r--test/std/containers/associative/set/set.cons/copy_assign.pass.cpp109
-rw-r--r--test/std/containers/associative/set/set.cons/default.pass.cpp40
-rw-r--r--test/std/containers/associative/set/set.cons/default_noexcept.pass.cpp53
-rw-r--r--test/std/containers/associative/set/set.cons/dtor_noexcept.pass.cpp51
-rw-r--r--test/std/containers/associative/set/set.cons/initializer_list.pass.cpp55
-rw-r--r--test/std/containers/associative/set/set.cons/initializer_list_compare.pass.cpp38
-rw-r--r--test/std/containers/associative/set/set.cons/initializer_list_compare_alloc.pass.cpp63
-rw-r--r--test/std/containers/associative/set/set.cons/iter_iter.pass.cpp71
-rw-r--r--test/std/containers/associative/set/set.cons/iter_iter_alloc.pass.cpp84
-rw-r--r--test/std/containers/associative/set/set.cons/iter_iter_comp.pass.cpp47
-rw-r--r--test/std/containers/associative/set/set.cons/move.pass.cpp107
-rw-r--r--test/std/containers/associative/set/set.cons/move_alloc.pass.cpp188
-rw-r--r--test/std/containers/associative/set/set.cons/move_assign.pass.cpp186
-rw-r--r--test/std/containers/associative/set/set.cons/move_assign_noexcept.pass.cpp53
-rw-r--r--test/std/containers/associative/set/set.cons/move_noexcept.pass.cpp51
-rw-r--r--test/std/containers/associative/set/set.special/member_swap.pass.cpp177
-rw-r--r--test/std/containers/associative/set/set.special/non_member_swap.pass.cpp165
-rw-r--r--test/std/containers/associative/set/set.special/swap_noexcept.pass.cpp148
-rw-r--r--test/std/containers/associative/set/size.pass.cpp59
-rw-r--r--test/std/containers/associative/set/types.pass.cpp70
-rw-r--r--test/std/containers/associative/set/upper_bound.pass.cpp336
-rw-r--r--test/std/containers/associative/set/version.pass.cpp20
-rw-r--r--test/std/containers/associative/tree_balance_after_insert.pass.cpp1616
-rw-r--r--test/std/containers/associative/tree_left_rotate.pass.cpp98
-rw-r--r--test/std/containers/associative/tree_remove.pass.cpp1648
-rw-r--r--test/std/containers/associative/tree_right_rotate.pass.cpp98
-rw-r--r--test/std/containers/container.adaptors/nothing_to_do.pass.cpp12
-rw-r--r--test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_alloc.pass.cpp48
-rw-r--r--test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_comp_alloc.pass.cpp48
-rw-r--r--test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_comp_cont_alloc.pass.cpp62
-rw-r--r--test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_comp_rcont_alloc.pass.cpp61
-rw-r--r--test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_copy_alloc.pass.cpp58
-rw-r--r--test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_move_alloc.pass.cpp68
-rw-r--r--test/std/containers/container.adaptors/priority.queue/priqueue.cons/assign_copy.pass.cpp36
-rw-r--r--test/std/containers/container.adaptors/priority.queue/priqueue.cons/assign_move.pass.cpp42
-rw-r--r--test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_comp.pass.cpp27
-rw-r--r--test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_comp_container.pass.cpp34
-rw-r--r--test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_comp_rcontainer.pass.cpp40
-rw-r--r--test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_copy.pass.cpp35
-rw-r--r--test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_default.pass.cpp27
-rw-r--r--test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_iter_iter.pass.cpp25
-rw-r--r--test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_iter_iter_comp.pass.cpp27
-rw-r--r--test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_iter_iter_comp_cont.pass.cpp27
-rw-r--r--test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_iter_iter_comp_rcont.pass.cpp32
-rw-r--r--test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_move.pass.cpp41
-rw-r--r--test/std/containers/container.adaptors/priority.queue/priqueue.cons/default_noexcept.pass.cpp31
-rw-r--r--test/std/containers/container.adaptors/priority.queue/priqueue.cons/dtor_noexcept.pass.cpp27
-rw-r--r--test/std/containers/container.adaptors/priority.queue/priqueue.cons/move_assign_noexcept.pass.cpp31
-rw-r--r--test/std/containers/container.adaptors/priority.queue/priqueue.cons/move_noexcept.pass.cpp31
-rw-r--r--test/std/containers/container.adaptors/priority.queue/priqueue.members/emplace.pass.cpp32
-rw-r--r--test/std/containers/container.adaptors/priority.queue/priqueue.members/empty.pass.cpp27
-rw-r--r--test/std/containers/container.adaptors/priority.queue/priqueue.members/pop.pass.cpp34
-rw-r--r--test/std/containers/container.adaptors/priority.queue/priqueue.members/push.pass.cpp28
-rw-r--r--test/std/containers/container.adaptors/priority.queue/priqueue.members/push_rvalue.pass.cpp32
-rw-r--r--test/std/containers/container.adaptors/priority.queue/priqueue.members/size.pass.cpp27
-rw-r--r--test/std/containers/container.adaptors/priority.queue/priqueue.members/swap.pass.cpp30
-rw-r--r--test/std/containers/container.adaptors/priority.queue/priqueue.members/top.pass.cpp28
-rw-r--r--test/std/containers/container.adaptors/priority.queue/priqueue.special/swap.pass.cpp32
-rw-r--r--test/std/containers/container.adaptors/priority.queue/priqueue.special/swap_noexcept.pass.cpp32
-rw-r--r--test/std/containers/container.adaptors/priority.queue/types.pass.cpp60
-rw-r--r--test/std/containers/container.adaptors/queue/queue.cons.alloc/ctor_alloc.pass.cpp38
-rw-r--r--test/std/containers/container.adaptors/queue/queue.cons.alloc/ctor_container_alloc.pass.cpp57
-rw-r--r--test/std/containers/container.adaptors/queue/queue.cons.alloc/ctor_queue_alloc.pass.cpp52
-rw-r--r--test/std/containers/container.adaptors/queue/queue.cons.alloc/ctor_rcontainer_alloc.pass.cpp59
-rw-r--r--test/std/containers/container.adaptors/queue/queue.cons.alloc/ctor_rqueue_alloc.pass.cpp60
-rw-r--r--test/std/containers/container.adaptors/queue/queue.cons/ctor_container.pass.cpp37
-rw-r--r--test/std/containers/container.adaptors/queue/queue.cons/ctor_copy.pass.cpp32
-rw-r--r--test/std/containers/container.adaptors/queue/queue.cons/ctor_default.pass.cpp28
-rw-r--r--test/std/containers/container.adaptors/queue/queue.cons/ctor_move.pass.cpp41
-rw-r--r--test/std/containers/container.adaptors/queue/queue.cons/ctor_rcontainer.pass.cpp39
-rw-r--r--test/std/containers/container.adaptors/queue/queue.cons/default_noexcept.pass.cpp30
-rw-r--r--test/std/containers/container.adaptors/queue/queue.cons/dtor_noexcept.pass.cpp27
-rw-r--r--test/std/containers/container.adaptors/queue/queue.cons/move_assign_noexcept.pass.cpp30
-rw-r--r--test/std/containers/container.adaptors/queue/queue.cons/move_noexcept.pass.cpp30
-rw-r--r--test/std/containers/container.adaptors/queue/queue.defn/assign_copy.pass.cpp33
-rw-r--r--test/std/containers/container.adaptors/queue/queue.defn/assign_move.pass.cpp42
-rw-r--r--test/std/containers/container.adaptors/queue/queue.defn/back.pass.cpp26
-rw-r--r--test/std/containers/container.adaptors/queue/queue.defn/back_const.pass.cpp27
-rw-r--r--test/std/containers/container.adaptors/queue/queue.defn/emplace.pass.cpp30
-rw-r--r--test/std/containers/container.adaptors/queue/queue.defn/empty.pass.cpp25
-rw-r--r--test/std/containers/container.adaptors/queue/queue.defn/front.pass.cpp26
-rw-r--r--test/std/containers/container.adaptors/queue/queue.defn/front_const.pass.cpp27
-rw-r--r--test/std/containers/container.adaptors/queue/queue.defn/pop.pass.cpp37
-rw-r--r--test/std/containers/container.adaptors/queue/queue.defn/push.pass.cpp32
-rw-r--r--test/std/containers/container.adaptors/queue/queue.defn/push_rv.pass.cpp36
-rw-r--r--test/std/containers/container.adaptors/queue/queue.defn/size.pass.cpp23
-rw-r--r--test/std/containers/container.adaptors/queue/queue.defn/swap.pass.cpp36
-rw-r--r--test/std/containers/container.adaptors/queue/queue.defn/types.pass.cpp58
-rw-r--r--test/std/containers/container.adaptors/queue/queue.ops/eq.pass.cpp40
-rw-r--r--test/std/containers/container.adaptors/queue/queue.ops/lt.pass.cpp45
-rw-r--r--test/std/containers/container.adaptors/queue/queue.special/swap.pass.cpp37
-rw-r--r--test/std/containers/container.adaptors/queue/queue.special/swap_noexcept.pass.cpp31
-rw-r--r--test/std/containers/container.adaptors/queue/version.pass.cpp20
-rw-r--r--test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_alloc.pass.cpp38
-rw-r--r--test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_container_alloc.pass.cpp57
-rw-r--r--test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_copy_alloc.pass.cpp52
-rw-r--r--test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_rcontainer_alloc.pass.cpp59
-rw-r--r--test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_rqueue_alloc.pass.cpp60
-rw-r--r--test/std/containers/container.adaptors/stack/stack.cons/ctor_container.pass.cpp37
-rw-r--r--test/std/containers/container.adaptors/stack/stack.cons/ctor_copy.pass.cpp32
-rw-r--r--test/std/containers/container.adaptors/stack/stack.cons/ctor_default.pass.cpp28
-rw-r--r--test/std/containers/container.adaptors/stack/stack.cons/ctor_move.pass.cpp41
-rw-r--r--test/std/containers/container.adaptors/stack/stack.cons/ctor_rcontainer.pass.cpp39
-rw-r--r--test/std/containers/container.adaptors/stack/stack.cons/default_noexcept.pass.cpp30
-rw-r--r--test/std/containers/container.adaptors/stack/stack.cons/dtor_noexcept.pass.cpp27
-rw-r--r--test/std/containers/container.adaptors/stack/stack.cons/move_assign_noexcept.pass.cpp30
-rw-r--r--test/std/containers/container.adaptors/stack/stack.cons/move_noexcept.pass.cpp30
-rw-r--r--test/std/containers/container.adaptors/stack/stack.defn/assign_copy.pass.cpp33
-rw-r--r--test/std/containers/container.adaptors/stack/stack.defn/assign_move.pass.cpp42
-rw-r--r--test/std/containers/container.adaptors/stack/stack.defn/emplace.pass.cpp29
-rw-r--r--test/std/containers/container.adaptors/stack/stack.defn/empty.pass.cpp25
-rw-r--r--test/std/containers/container.adaptors/stack/stack.defn/pop.pass.cpp34
-rw-r--r--test/std/containers/container.adaptors/stack/stack.defn/push.pass.cpp29
-rw-r--r--test/std/containers/container.adaptors/stack/stack.defn/push_rv.pass.cpp33
-rw-r--r--test/std/containers/container.adaptors/stack/stack.defn/size.pass.cpp23
-rw-r--r--test/std/containers/container.adaptors/stack/stack.defn/swap.pass.cpp36
-rw-r--r--test/std/containers/container.adaptors/stack/stack.defn/top.pass.cpp26
-rw-r--r--test/std/containers/container.adaptors/stack/stack.defn/top_const.pass.cpp27
-rw-r--r--test/std/containers/container.adaptors/stack/stack.defn/types.pass.cpp59
-rw-r--r--test/std/containers/container.adaptors/stack/stack.ops/eq.pass.cpp40
-rw-r--r--test/std/containers/container.adaptors/stack/stack.ops/lt.pass.cpp45
-rw-r--r--test/std/containers/container.adaptors/stack/stack.special/swap.pass.cpp37
-rw-r--r--test/std/containers/container.adaptors/stack/stack.special/swap_noexcept.pass.cpp31
-rw-r--r--test/std/containers/container.adaptors/stack/version.pass.cpp20
-rw-r--r--test/std/containers/container.requirements/associative.reqmts/associative.reqmts.except/nothing_to_do.pass.cpp12
-rw-r--r--test/std/containers/container.requirements/associative.reqmts/nothing_to_do.pass.cpp12
-rw-r--r--test/std/containers/container.requirements/container.requirements.dataraces/nothing_to_do.pass.cpp12
-rw-r--r--test/std/containers/container.requirements/container.requirements.general/nothing_to_do.pass.cpp12
-rw-r--r--test/std/containers/container.requirements/nothing_to_do.pass.cpp12
-rw-r--r--test/std/containers/container.requirements/sequence.reqmts/nothing_to_do.pass.cpp12
-rw-r--r--test/std/containers/container.requirements/unord.req/nothing_to_do.pass.cpp12
-rw-r--r--test/std/containers/container.requirements/unord.req/unord.req.except/nothing_to_do.pass.cpp12
-rw-r--r--test/std/containers/containers.general/nothing_to_do.pass.cpp12
-rw-r--r--test/std/containers/nothing_to_do.pass.cpp12
-rw-r--r--test/std/containers/sequences/array/array.cons/default.pass.cpp31
-rw-r--r--test/std/containers/sequences/array/array.cons/initializer_list.pass.cpp34
-rw-r--r--test/std/containers/sequences/array/array.data/data.pass.cpp35
-rw-r--r--test/std/containers/sequences/array/array.data/data_const.pass.cpp35
-rw-r--r--test/std/containers/sequences/array/array.fill/fill.pass.cpp36
-rw-r--r--test/std/containers/sequences/array/array.size/size.pass.cpp53
-rw-r--r--test/std/containers/sequences/array/array.special/swap.pass.cpp43
-rw-r--r--test/std/containers/sequences/array/array.swap/swap.pass.cpp43
-rw-r--r--test/std/containers/sequences/array/array.tuple/get.fail.cpp25
-rw-r--r--test/std/containers/sequences/array/array.tuple/get.pass.cpp52
-rw-r--r--test/std/containers/sequences/array/array.tuple/get_const.pass.cpp37
-rw-r--r--test/std/containers/sequences/array/array.tuple/get_rv.pass.cpp30
-rw-r--r--test/std/containers/sequences/array/array.tuple/tuple_element.pass.cpp54
-rw-r--r--test/std/containers/sequences/array/array.tuple/tuple_size.pass.cpp42
-rw-r--r--test/std/containers/sequences/array/array.zero/tested_elsewhere.pass.cpp18
-rw-r--r--test/std/containers/sequences/array/at.pass.cpp67
-rw-r--r--test/std/containers/sequences/array/begin.pass.cpp32
-rw-r--r--test/std/containers/sequences/array/contiguous.pass.cpp31
-rw-r--r--test/std/containers/sequences/array/front_back.pass.cpp62
-rw-r--r--test/std/containers/sequences/array/indexing.pass.cpp60
-rw-r--r--test/std/containers/sequences/array/iterators.pass.cpp110
-rw-r--r--test/std/containers/sequences/array/types.pass.cpp62
-rw-r--r--test/std/containers/sequences/array/version.pass.cpp20
-rw-r--r--test/std/containers/sequences/deque/deque.capacity/access.pass.cpp91
-rw-r--r--test/std/containers/sequences/deque/deque.capacity/resize_size.pass.cpp86
-rw-r--r--test/std/containers/sequences/deque/deque.capacity/resize_size_value.pass.cpp86
-rw-r--r--test/std/containers/sequences/deque/deque.capacity/shrink_to_fit.pass.cpp77
-rw-r--r--test/std/containers/sequences/deque/deque.cons/alloc.pass.cpp38
-rw-r--r--test/std/containers/sequences/deque/deque.cons/assign_initializer_list.pass.cpp43
-rw-r--r--test/std/containers/sequences/deque/deque.cons/assign_iter_iter.pass.cpp109
-rw-r--r--test/std/containers/sequences/deque/deque.cons/assign_size_value.pass.cpp85
-rw-r--r--test/std/containers/sequences/deque/deque.cons/copy.pass.cpp61
-rw-r--r--test/std/containers/sequences/deque/deque.cons/copy_alloc.pass.cpp51
-rw-r--r--test/std/containers/sequences/deque/deque.cons/default.pass.cpp41
-rw-r--r--test/std/containers/sequences/deque/deque.cons/default_noexcept.pass.cpp50
-rw-r--r--test/std/containers/sequences/deque/deque.cons/dtor_noexcept.pass.cpp52
-rw-r--r--test/std/containers/sequences/deque/deque.cons/initializer_list.pass.cpp41
-rw-r--r--test/std/containers/sequences/deque/deque.cons/initializer_list_alloc.pass.cpp44
-rw-r--r--test/std/containers/sequences/deque/deque.cons/iter_iter.pass.cpp62
-rw-r--r--test/std/containers/sequences/deque/deque.cons/iter_iter_alloc.pass.cpp51
-rw-r--r--test/std/containers/sequences/deque/deque.cons/move.pass.cpp72
-rw-r--r--test/std/containers/sequences/deque/deque.cons/move_alloc.pass.cpp87
-rw-r--r--test/std/containers/sequences/deque/deque.cons/move_assign.pass.cpp91
-rw-r--r--test/std/containers/sequences/deque/deque.cons/move_assign_noexcept.pass.cpp52
-rw-r--r--test/std/containers/sequences/deque/deque.cons/move_noexcept.pass.cpp50
-rw-r--r--test/std/containers/sequences/deque/deque.cons/op_equal.pass.cpp63
-rw-r--r--test/std/containers/sequences/deque/deque.cons/op_equal_initializer_list.pass.cpp43
-rw-r--r--test/std/containers/sequences/deque/deque.cons/size.pass.cpp113
-rw-r--r--test/std/containers/sequences/deque/deque.cons/size_value.pass.cpp51
-rw-r--r--test/std/containers/sequences/deque/deque.cons/size_value_alloc.pass.cpp67
-rw-r--r--test/std/containers/sequences/deque/deque.modifiers/emplace.pass.cpp112
-rw-r--r--test/std/containers/sequences/deque/deque.modifiers/emplace_back.pass.cpp87
-rw-r--r--test/std/containers/sequences/deque/deque.modifiers/emplace_front.pass.cpp87
-rw-r--r--test/std/containers/sequences/deque/deque.modifiers/erase_iter.invalidation.pass.cpp70
-rw-r--r--test/std/containers/sequences/deque/deque.modifiers/erase_iter.pass.cpp90
-rw-r--r--test/std/containers/sequences/deque/deque.modifiers/erase_iter_iter.invalidation.pass.cpp78
-rw-r--r--test/std/containers/sequences/deque/deque.modifiers/erase_iter_iter.pass.cpp96
-rw-r--r--test/std/containers/sequences/deque/deque.modifiers/insert_iter_initializer_list.pass.cpp63
-rw-r--r--test/std/containers/sequences/deque/deque.modifiers/insert_iter_iter.pass.cpp295
-rw-r--r--test/std/containers/sequences/deque/deque.modifiers/insert_rvalue.pass.cpp118
-rw-r--r--test/std/containers/sequences/deque/deque.modifiers/insert_size_value.pass.cpp159
-rw-r--r--test/std/containers/sequences/deque/deque.modifiers/insert_value.pass.cpp139
-rw-r--r--test/std/containers/sequences/deque/deque.modifiers/pop_back.invalidation.pass.cpp49
-rw-r--r--test/std/containers/sequences/deque/deque.modifiers/pop_back.pass.cpp84
-rw-r--r--test/std/containers/sequences/deque/deque.modifiers/pop_front.invalidation.pass.cpp49
-rw-r--r--test/std/containers/sequences/deque/deque.modifiers/pop_front.pass.cpp84
-rw-r--r--test/std/containers/sequences/deque/deque.modifiers/push_back.pass.cpp73
-rw-r--r--test/std/containers/sequences/deque/deque.modifiers/push_back_exception_safety.pass.cpp101
-rw-r--r--test/std/containers/sequences/deque/deque.modifiers/push_back_rvalue.pass.cpp80
-rw-r--r--test/std/containers/sequences/deque/deque.modifiers/push_front.pass.cpp83
-rw-r--r--test/std/containers/sequences/deque/deque.modifiers/push_front_exception_safety.pass.cpp101
-rw-r--r--test/std/containers/sequences/deque/deque.modifiers/push_front_rvalue.pass.cpp90
-rw-r--r--test/std/containers/sequences/deque/deque.special/copy.pass.cpp88
-rw-r--r--test/std/containers/sequences/deque/deque.special/copy_backward.pass.cpp87
-rw-r--r--test/std/containers/sequences/deque/deque.special/move.pass.cpp87
-rw-r--r--test/std/containers/sequences/deque/deque.special/move_backward.pass.cpp87
-rw-r--r--test/std/containers/sequences/deque/deque.special/swap.pass.cpp110
-rw-r--r--test/std/containers/sequences/deque/deque.special/swap_noexcept.pass.cpp90
-rw-r--r--test/std/containers/sequences/deque/iterators.pass.cpp79
-rw-r--r--test/std/containers/sequences/deque/types.pass.cpp90
-rw-r--r--test/std/containers/sequences/deque/version.pass.cpp20
-rw-r--r--test/std/containers/sequences/forwardlist/forwardlist.access/front.pass.cpp61
-rw-r--r--test/std/containers/sequences/forwardlist/forwardlist.cons/alloc.fail.cpp30
-rw-r--r--test/std/containers/sequences/forwardlist/forwardlist.cons/alloc.pass.cpp41
-rw-r--r--test/std/containers/sequences/forwardlist/forwardlist.cons/assign_copy.pass.cpp146
-rw-r--r--test/std/containers/sequences/forwardlist/forwardlist.cons/assign_init.pass.cpp70
-rw-r--r--test/std/containers/sequences/forwardlist/forwardlist.cons/assign_move.pass.cpp199
-rw-r--r--test/std/containers/sequences/forwardlist/forwardlist.cons/assign_op_init.pass.cpp70
-rw-r--r--test/std/containers/sequences/forwardlist/forwardlist.cons/assign_range.pass.cpp78
-rw-r--r--test/std/containers/sequences/forwardlist/forwardlist.cons/assign_size_value.pass.cpp68
-rw-r--r--test/std/containers/sequences/forwardlist/forwardlist.cons/copy.pass.cpp69
-rw-r--r--test/std/containers/sequences/forwardlist/forwardlist.cons/copy_alloc.pass.cpp67
-rw-r--r--test/std/containers/sequences/forwardlist/forwardlist.cons/default.pass.cpp41
-rw-r--r--test/std/containers/sequences/forwardlist/forwardlist.cons/default_noexcept.pass.cpp50
-rw-r--r--test/std/containers/sequences/forwardlist/forwardlist.cons/default_recursive.pass.cpp25
-rw-r--r--test/std/containers/sequences/forwardlist/forwardlist.cons/dtor_noexcept.pass.cpp52
-rw-r--r--test/std/containers/sequences/forwardlist/forwardlist.cons/init.pass.cpp43
-rw-r--r--test/std/containers/sequences/forwardlist/forwardlist.cons/init_alloc.pass.cpp48
-rw-r--r--test/std/containers/sequences/forwardlist/forwardlist.cons/move.pass.cpp73
-rw-r--r--test/std/containers/sequences/forwardlist/forwardlist.cons/move_alloc.pass.cpp73
-rw-r--r--test/std/containers/sequences/forwardlist/forwardlist.cons/move_assign_noexcept.pass.cpp52
-rw-r--r--test/std/containers/sequences/forwardlist/forwardlist.cons/move_noexcept.pass.cpp50
-rw-r--r--test/std/containers/sequences/forwardlist/forwardlist.cons/range.pass.cpp48
-rw-r--r--test/std/containers/sequences/forwardlist/forwardlist.cons/range_alloc.pass.cpp54
-rw-r--r--test/std/containers/sequences/forwardlist/forwardlist.cons/size.fail.cpp35
-rw-r--r--test/std/containers/sequences/forwardlist/forwardlist.cons/size.pass.cpp66
-rw-r--r--test/std/containers/sequences/forwardlist/forwardlist.cons/size_value.pass.cpp45
-rw-r--r--test/std/containers/sequences/forwardlist/forwardlist.cons/size_value_alloc.pass.cpp50
-rw-r--r--test/std/containers/sequences/forwardlist/forwardlist.iter/before_begin.pass.cpp104
-rw-r--r--test/std/containers/sequences/forwardlist/forwardlist.iter/iterators.pass.cpp145
-rw-r--r--test/std/containers/sequences/forwardlist/forwardlist.modifiers/clear.pass.cpp62
-rw-r--r--test/std/containers/sequences/forwardlist/forwardlist.modifiers/emplace_after.pass.cpp89
-rw-r--r--test/std/containers/sequences/forwardlist/forwardlist.modifiers/emplace_front.pass.cpp50
-rw-r--r--test/std/containers/sequences/forwardlist/forwardlist.modifiers/erase_after_many.pass.cpp155
-rw-r--r--test/std/containers/sequences/forwardlist/forwardlist.modifiers/erase_after_one.pass.cpp97
-rw-r--r--test/std/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_const.pass.cpp87
-rw-r--r--test/std/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_init.pass.cpp75
-rw-r--r--test/std/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_range.pass.cpp80
-rw-r--r--test/std/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_rv.pass.cpp90
-rw-r--r--test/std/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_size_value.pass.cpp73
-rw-r--r--test/std/containers/sequences/forwardlist/forwardlist.modifiers/pop_front.pass.cpp78
-rw-r--r--test/std/containers/sequences/forwardlist/forwardlist.modifiers/push_front_const.pass.cpp47
-rw-r--r--test/std/containers/sequences/forwardlist/forwardlist.modifiers/push_front_exception_safety.pass.cpp73
-rw-r--r--test/std/containers/sequences/forwardlist/forwardlist.modifiers/push_front_rv.pass.cpp50
-rw-r--r--test/std/containers/sequences/forwardlist/forwardlist.modifiers/resize_size.pass.cpp114
-rw-r--r--test/std/containers/sequences/forwardlist/forwardlist.modifiers/resize_size_value.pass.cpp84
-rw-r--r--test/std/containers/sequences/forwardlist/forwardlist.ops/merge.pass.cpp48
-rw-r--r--test/std/containers/sequences/forwardlist/forwardlist.ops/merge_pred.pass.cpp49
-rw-r--r--test/std/containers/sequences/forwardlist/forwardlist.ops/remove.pass.cpp155
-rw-r--r--test/std/containers/sequences/forwardlist/forwardlist.ops/remove_if.pass.cpp155
-rw-r--r--test/std/containers/sequences/forwardlist/forwardlist.ops/reverse.pass.cpp42
-rw-r--r--test/std/containers/sequences/forwardlist/forwardlist.ops/sort.pass.cpp47
-rw-r--r--test/std/containers/sequences/forwardlist/forwardlist.ops/sort_pred.pass.cpp48
-rw-r--r--test/std/containers/sequences/forwardlist/forwardlist.ops/splice_after_flist.pass.cpp75
-rw-r--r--test/std/containers/sequences/forwardlist/forwardlist.ops/splice_after_one.pass.cpp140
-rw-r--r--test/std/containers/sequences/forwardlist/forwardlist.ops/splice_after_range.pass.cpp169
-rw-r--r--test/std/containers/sequences/forwardlist/forwardlist.ops/unique.pass.cpp120
-rw-r--r--test/std/containers/sequences/forwardlist/forwardlist.ops/unique_pred.pass.cpp125
-rw-r--r--test/std/containers/sequences/forwardlist/forwardlist.spec/equal.pass.cpp60
-rw-r--r--test/std/containers/sequences/forwardlist/forwardlist.spec/member_swap.pass.cpp259
-rw-r--r--test/std/containers/sequences/forwardlist/forwardlist.spec/non_member_swap.pass.cpp260
-rw-r--r--test/std/containers/sequences/forwardlist/forwardlist.spec/relational.pass.cpp65
-rw-r--r--test/std/containers/sequences/forwardlist/forwardlist.spec/swap_noexcept.pass.cpp90
-rw-r--r--test/std/containers/sequences/forwardlist/max_size.pass.cpp35
-rw-r--r--test/std/containers/sequences/forwardlist/types.pass.cpp62
-rw-r--r--test/std/containers/sequences/forwardlist/version.pass.cpp20
-rw-r--r--test/std/containers/sequences/list/db_back.pass.cpp56
-rw-r--r--test/std/containers/sequences/list/db_cback.pass.cpp52
-rw-r--r--test/std/containers/sequences/list/db_cfront.pass.cpp52
-rw-r--r--test/std/containers/sequences/list/db_front.pass.cpp56
-rw-r--r--test/std/containers/sequences/list/db_iterators_6.pass.cpp58
-rw-r--r--test/std/containers/sequences/list/db_iterators_7.pass.cpp58
-rw-r--r--test/std/containers/sequences/list/db_iterators_8.pass.cpp54
-rw-r--r--test/std/containers/sequences/list/db_iterators_9.pass.cpp67
-rw-r--r--test/std/containers/sequences/list/iterators.pass.cpp159
-rw-r--r--test/std/containers/sequences/list/list.capacity/resize_size.pass.cpp81
-rw-r--r--test/std/containers/sequences/list/list.capacity/resize_size_value.pass.cpp53
-rw-r--r--test/std/containers/sequences/list/list.cons/assign_copy.pass.cpp44
-rw-r--r--test/std/containers/sequences/list/list.cons/assign_initializer_list.pass.cpp45
-rw-r--r--test/std/containers/sequences/list/list.cons/assign_move.pass.cpp82
-rw-r--r--test/std/containers/sequences/list/list.cons/copy.pass.cpp54
-rw-r--r--test/std/containers/sequences/list/list.cons/copy_alloc.pass.cpp42
-rw-r--r--test/std/containers/sequences/list/list.cons/default.pass.cpp58
-rw-r--r--test/std/containers/sequences/list/list.cons/default_noexcept.pass.cpp50
-rw-r--r--test/std/containers/sequences/list/list.cons/default_stack_alloc.pass.cpp48
-rw-r--r--test/std/containers/sequences/list/list.cons/dtor_noexcept.pass.cpp52
-rw-r--r--test/std/containers/sequences/list/list.cons/initializer_list.pass.cpp43
-rw-r--r--test/std/containers/sequences/list/list.cons/initializer_list_alloc.pass.cpp46
-rw-r--r--test/std/containers/sequences/list/list.cons/input_iterator.pass.cpp77
-rw-r--r--test/std/containers/sequences/list/list.cons/move.pass.cpp74
-rw-r--r--test/std/containers/sequences/list/list.cons/move_alloc.pass.cpp78
-rw-r--r--test/std/containers/sequences/list/list.cons/move_assign_noexcept.pass.cpp52
-rw-r--r--test/std/containers/sequences/list/list.cons/move_noexcept.pass.cpp50
-rw-r--r--test/std/containers/sequences/list/list.cons/op_equal_initializer_list.pass.cpp44
-rw-r--r--test/std/containers/sequences/list/list.cons/size_type.pass.cpp103
-rw-r--r--test/std/containers/sequences/list/list.cons/size_value_alloc.pass.cpp79
-rw-r--r--test/std/containers/sequences/list/list.modifiers/clear.pass.cpp35
-rw-r--r--test/std/containers/sequences/list/list.modifiers/emplace.pass.cpp88
-rw-r--r--test/std/containers/sequences/list/list.modifiers/emplace_back.pass.cpp66
-rw-r--r--test/std/containers/sequences/list/list.modifiers/emplace_front.pass.cpp66
-rw-r--r--test/std/containers/sequences/list/list.modifiers/erase_iter.pass.cpp65
-rw-r--r--test/std/containers/sequences/list/list.modifiers/erase_iter_db1.pass.cpp51
-rw-r--r--test/std/containers/sequences/list/list.modifiers/erase_iter_db2.pass.cpp53
-rw-r--r--test/std/containers/sequences/list/list.modifiers/erase_iter_iter.pass.cpp84
-rw-r--r--test/std/containers/sequences/list/list.modifiers/erase_iter_iter_db1.pass.cpp51
-rw-r--r--test/std/containers/sequences/list/list.modifiers/erase_iter_iter_db2.pass.cpp51
-rw-r--r--test/std/containers/sequences/list/list.modifiers/erase_iter_iter_db3.pass.cpp51
-rw-r--r--test/std/containers/sequences/list/list.modifiers/erase_iter_iter_db4.pass.cpp49
-rw-r--r--test/std/containers/sequences/list/list.modifiers/insert_iter_initializer_list.pass.cpp67
-rw-r--r--test/std/containers/sequences/list/list.modifiers/insert_iter_iter_iter.pass.cpp185
-rw-r--r--test/std/containers/sequences/list/list.modifiers/insert_iter_rvalue.pass.cpp68
-rw-r--r--test/std/containers/sequences/list/list.modifiers/insert_iter_size_value.pass.cpp106
-rw-r--r--test/std/containers/sequences/list/list.modifiers/insert_iter_value.pass.cpp112
-rw-r--r--test/std/containers/sequences/list/list.modifiers/pop_back.pass.cpp55
-rw-r--r--test/std/containers/sequences/list/list.modifiers/pop_front.pass.cpp43
-rw-r--r--test/std/containers/sequences/list/list.modifiers/push_back.pass.cpp37
-rw-r--r--test/std/containers/sequences/list/list.modifiers/push_back_exception_safety.pass.cpp73
-rw-r--r--test/std/containers/sequences/list/list.modifiers/push_back_rvalue.pass.cpp46
-rw-r--r--test/std/containers/sequences/list/list.modifiers/push_front.pass.cpp37
-rw-r--r--test/std/containers/sequences/list/list.modifiers/push_front_exception_safety.pass.cpp73
-rw-r--r--test/std/containers/sequences/list/list.modifiers/push_front_rvalue.pass.cpp46
-rw-r--r--test/std/containers/sequences/list/list.ops/merge.pass.cpp41
-rw-r--r--test/std/containers/sequences/list/list.ops/merge_comp.pass.cpp42
-rw-r--r--test/std/containers/sequences/list/list.ops/remove.pass.cpp69
-rw-r--r--test/std/containers/sequences/list/list.ops/remove_if.pass.cpp64
-rw-r--r--test/std/containers/sequences/list/list.ops/reverse.pass.cpp37
-rw-r--r--test/std/containers/sequences/list/list.ops/sort.pass.cpp37
-rw-r--r--test/std/containers/sequences/list/list.ops/sort_comp.pass.cpp38
-rw-r--r--test/std/containers/sequences/list/list.ops/splice_pos_list.pass.cpp803
-rw-r--r--test/std/containers/sequences/list/list.ops/splice_pos_list_iter.pass.cpp357
-rw-r--r--test/std/containers/sequences/list/list.ops/splice_pos_list_iter_iter.pass.cpp237
-rw-r--r--test/std/containers/sequences/list/list.ops/unique.pass.cpp37
-rw-r--r--test/std/containers/sequences/list/list.ops/unique_pred.pass.cpp42
-rw-r--r--test/std/containers/sequences/list/list.special/db_swap_1.pass.cpp59
-rw-r--r--test/std/containers/sequences/list/list.special/swap.pass.cpp146
-rw-r--r--test/std/containers/sequences/list/list.special/swap_noexcept.pass.cpp90
-rw-r--r--test/std/containers/sequences/list/types.pass.cpp48
-rw-r--r--test/std/containers/sequences/list/version.pass.cpp20
-rw-r--r--test/std/containers/sequences/nothing_to_do.pass.cpp12
-rw-r--r--test/std/containers/sequences/vector.bool/assign_copy.pass.cpp44
-rw-r--r--test/std/containers/sequences/vector.bool/assign_initializer_list.pass.cpp43
-rw-r--r--test/std/containers/sequences/vector.bool/assign_move.pass.cpp81
-rw-r--r--test/std/containers/sequences/vector.bool/capacity.pass.cpp44
-rw-r--r--test/std/containers/sequences/vector.bool/construct_default.pass.cpp70
-rw-r--r--test/std/containers/sequences/vector.bool/construct_iter_iter.pass.cpp48
-rw-r--r--test/std/containers/sequences/vector.bool/construct_iter_iter_alloc.pass.cpp55
-rw-r--r--test/std/containers/sequences/vector.bool/construct_size.pass.cpp64
-rw-r--r--test/std/containers/sequences/vector.bool/construct_size_value.pass.cpp37
-rw-r--r--test/std/containers/sequences/vector.bool/construct_size_value_alloc.pass.cpp39
-rw-r--r--test/std/containers/sequences/vector.bool/copy.pass.cpp65
-rw-r--r--test/std/containers/sequences/vector.bool/copy_alloc.pass.cpp62
-rw-r--r--test/std/containers/sequences/vector.bool/default_noexcept.pass.cpp49
-rw-r--r--test/std/containers/sequences/vector.bool/dtor_noexcept.pass.cpp51
-rw-r--r--test/std/containers/sequences/vector.bool/emplace.pass.cpp68
-rw-r--r--test/std/containers/sequences/vector.bool/emplace_back.pass.cpp57
-rw-r--r--test/std/containers/sequences/vector.bool/erase_iter.pass.cpp65
-rw-r--r--test/std/containers/sequences/vector.bool/erase_iter_iter.pass.cpp85
-rw-r--r--test/std/containers/sequences/vector.bool/find.pass.cpp40
-rw-r--r--test/std/containers/sequences/vector.bool/initializer_list.pass.cpp41
-rw-r--r--test/std/containers/sequences/vector.bool/initializer_list_alloc.pass.cpp44
-rw-r--r--test/std/containers/sequences/vector.bool/insert_iter_initializer_list.pass.cpp65
-rw-r--r--test/std/containers/sequences/vector.bool/insert_iter_iter_iter.pass.cpp126
-rw-r--r--test/std/containers/sequences/vector.bool/insert_iter_size_value.pass.cpp81
-rw-r--r--test/std/containers/sequences/vector.bool/insert_iter_value.pass.cpp77
-rw-r--r--test/std/containers/sequences/vector.bool/iterators.pass.cpp123
-rw-r--r--test/std/containers/sequences/vector.bool/move.pass.cpp64
-rw-r--r--test/std/containers/sequences/vector.bool/move_alloc.pass.cpp77
-rw-r--r--test/std/containers/sequences/vector.bool/move_assign_noexcept.pass.cpp51
-rw-r--r--test/std/containers/sequences/vector.bool/move_noexcept.pass.cpp54
-rw-r--r--test/std/containers/sequences/vector.bool/op_equal_initializer_list.pass.cpp43
-rw-r--r--test/std/containers/sequences/vector.bool/push_back.pass.cpp48
-rw-r--r--test/std/containers/sequences/vector.bool/reserve.pass.cpp54
-rw-r--r--test/std/containers/sequences/vector.bool/resize_size.pass.cpp50
-rw-r--r--test/std/containers/sequences/vector.bool/resize_size_value.pass.cpp52
-rw-r--r--test/std/containers/sequences/vector.bool/shrink_to_fit.pass.cpp38
-rw-r--r--test/std/containers/sequences/vector.bool/swap.pass.cpp98
-rw-r--r--test/std/containers/sequences/vector.bool/swap_noexcept.pass.cpp90
-rw-r--r--test/std/containers/sequences/vector.bool/types.pass.cpp72
-rw-r--r--test/std/containers/sequences/vector.bool/vector_bool.pass.cpp52
-rw-r--r--test/std/containers/sequences/vector/asan.pass.cpp52
-rw-r--r--test/std/containers/sequences/vector/asan_throw.pass.cpp232
-rw-r--r--test/std/containers/sequences/vector/const_value_type.pass.cpp22
-rw-r--r--test/std/containers/sequences/vector/contiguous.pass.cpp52
-rw-r--r--test/std/containers/sequences/vector/db_back.pass.cpp56
-rw-r--r--test/std/containers/sequences/vector/db_cback.pass.cpp52
-rw-r--r--test/std/containers/sequences/vector/db_cfront.pass.cpp52
-rw-r--r--test/std/containers/sequences/vector/db_cindex.pass.cpp54
-rw-r--r--test/std/containers/sequences/vector/db_front.pass.cpp56
-rw-r--r--test/std/containers/sequences/vector/db_index.pass.cpp56
-rw-r--r--test/std/containers/sequences/vector/db_iterators_2.pass.cpp54
-rw-r--r--test/std/containers/sequences/vector/db_iterators_3.pass.cpp54
-rw-r--r--test/std/containers/sequences/vector/db_iterators_4.pass.cpp56
-rw-r--r--test/std/containers/sequences/vector/db_iterators_5.pass.cpp60
-rw-r--r--test/std/containers/sequences/vector/db_iterators_6.pass.cpp58
-rw-r--r--test/std/containers/sequences/vector/db_iterators_7.pass.cpp58
-rw-r--r--test/std/containers/sequences/vector/db_iterators_8.pass.cpp54
-rw-r--r--test/std/containers/sequences/vector/iterators.pass.cpp165
-rw-r--r--test/std/containers/sequences/vector/types.pass.cpp86
-rw-r--r--test/std/containers/sequences/vector/vector.capacity/capacity.pass.cpp48
-rw-r--r--test/std/containers/sequences/vector/vector.capacity/reserve.pass.cpp69
-rw-r--r--test/std/containers/sequences/vector/vector.capacity/resize_size.pass.cpp83
-rw-r--r--test/std/containers/sequences/vector/vector.capacity/resize_size_value.pass.cpp76
-rw-r--r--test/std/containers/sequences/vector/vector.capacity/shrink_to_fit.pass.cpp62
-rw-r--r--test/std/containers/sequences/vector/vector.capacity/swap.pass.cpp50
-rw-r--r--test/std/containers/sequences/vector/vector.cons/assign_copy.pass.cpp44
-rw-r--r--test/std/containers/sequences/vector/vector.cons/assign_initializer_list.pass.cpp55
-rw-r--r--test/std/containers/sequences/vector/vector.cons/assign_move.pass.cpp101
-rw-r--r--test/std/containers/sequences/vector/vector.cons/assign_size_value.pass.cpp54
-rw-r--r--test/std/containers/sequences/vector/vector.cons/construct_default.pass.cpp90
-rw-r--r--test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp56
-rw-r--r--test/std/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp71
-rw-r--r--test/std/containers/sequences/vector/vector.cons/construct_size.pass.cpp73
-rw-r--r--test/std/containers/sequences/vector/vector.cons/construct_size_value.pass.cpp40
-rw-r--r--test/std/containers/sequences/vector/vector.cons/construct_size_value_alloc.pass.cpp39
-rw-r--r--test/std/containers/sequences/vector/vector.cons/copy.pass.cpp78
-rw-r--r--test/std/containers/sequences/vector/vector.cons/copy_alloc.pass.cpp64
-rw-r--r--test/std/containers/sequences/vector/vector.cons/default.recursive.pass.cpp23
-rw-r--r--test/std/containers/sequences/vector/vector.cons/default_noexcept.pass.cpp51
-rw-r--r--test/std/containers/sequences/vector/vector.cons/dtor_noexcept.pass.cpp52
-rw-r--r--test/std/containers/sequences/vector/vector.cons/initializer_list.pass.cpp43
-rw-r--r--test/std/containers/sequences/vector/vector.cons/initializer_list_alloc.pass.cpp47
-rw-r--r--test/std/containers/sequences/vector/vector.cons/move.pass.cpp103
-rw-r--r--test/std/containers/sequences/vector/vector.cons/move_alloc.pass.cpp99
-rw-r--r--test/std/containers/sequences/vector/vector.cons/move_assign_noexcept.pass.cpp52
-rw-r--r--test/std/containers/sequences/vector/vector.cons/move_noexcept.pass.cpp55
-rw-r--r--test/std/containers/sequences/vector/vector.cons/op_equal_initializer_list.pass.cpp46
-rw-r--r--test/std/containers/sequences/vector/vector.data/data.pass.cpp44
-rw-r--r--test/std/containers/sequences/vector/vector.data/data_const.pass.cpp44
-rw-r--r--test/std/containers/sequences/vector/vector.modifiers/emplace.pass.cpp160
-rw-r--r--test/std/containers/sequences/vector/vector.modifiers/emplace_back.pass.cpp107
-rw-r--r--test/std/containers/sequences/vector/vector.modifiers/emplace_extra.pass.cpp62
-rw-r--r--test/std/containers/sequences/vector/vector.modifiers/erase_iter.pass.cpp75
-rw-r--r--test/std/containers/sequences/vector/vector.modifiers/erase_iter_db1.pass.cpp51
-rw-r--r--test/std/containers/sequences/vector/vector.modifiers/erase_iter_db2.pass.cpp53
-rw-r--r--test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter.pass.cpp128
-rw-r--r--test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db1.pass.cpp51
-rw-r--r--test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db2.pass.cpp51
-rw-r--r--test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db3.pass.cpp51
-rw-r--r--test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db4.pass.cpp49
-rw-r--r--test/std/containers/sequences/vector/vector.modifiers/insert_iter_initializer_list.pass.cpp68
-rw-r--r--test/std/containers/sequences/vector/vector.modifiers/insert_iter_iter_iter.pass.cpp190
-rw-r--r--test/std/containers/sequences/vector/vector.modifiers/insert_iter_rvalue.pass.cpp86
-rw-r--r--test/std/containers/sequences/vector/vector.modifiers/insert_iter_size_value.pass.cpp132
-rw-r--r--test/std/containers/sequences/vector/vector.modifiers/insert_iter_value.pass.cpp116
-rw-r--r--test/std/containers/sequences/vector/vector.modifiers/pop_back.pass.cpp55
-rw-r--r--test/std/containers/sequences/vector/vector.modifiers/push_back.pass.cpp108
-rw-r--r--test/std/containers/sequences/vector/vector.modifiers/push_back_exception_safety.pass.cpp86
-rw-r--r--test/std/containers/sequences/vector/vector.modifiers/push_back_rvalue.pass.cpp111
-rw-r--r--test/std/containers/sequences/vector/vector.special/db_swap_1.pass.cpp56
-rw-r--r--test/std/containers/sequences/vector/vector.special/swap.pass.cpp188
-rw-r--r--test/std/containers/sequences/vector/vector.special/swap_noexcept.pass.cpp91
-rw-r--r--test/std/containers/sequences/vector/version.pass.cpp20
-rw-r--r--test/std/containers/stack_allocator.h66
-rw-r--r--test/std/containers/test_compare.h36
-rw-r--r--test/std/containers/test_hash.h32
-rw-r--r--test/std/containers/unord/next_prime.pass.cpp51
-rw-r--r--test/std/containers/unord/unord.map/bucket.pass.cpp77
-rw-r--r--test/std/containers/unord/unord.map/bucket_count.pass.cpp80
-rw-r--r--test/std/containers/unord/unord.map/bucket_size.pass.cpp81
-rw-r--r--test/std/containers/unord/unord.map/compare.pass.cpp42
-rw-r--r--test/std/containers/unord/unord.map/count.pass.cpp65
-rw-r--r--test/std/containers/unord/unord.map/db_iterators_7.pass.cpp60
-rw-r--r--test/std/containers/unord/unord.map/db_iterators_8.pass.cpp56
-rw-r--r--test/std/containers/unord/unord.map/db_local_iterators_7.pass.cpp57
-rw-r--r--test/std/containers/unord/unord.map/db_local_iterators_8.pass.cpp54
-rw-r--r--test/std/containers/unord/unord.map/eq.pass.cpp163
-rw-r--r--test/std/containers/unord/unord.map/equal_range_const.pass.cpp75
-rw-r--r--test/std/containers/unord/unord.map/equal_range_non_const.pass.cpp75
-rw-r--r--test/std/containers/unord/unord.map/find_const.pass.cpp71
-rw-r--r--test/std/containers/unord/unord.map/find_non_const.pass.cpp71
-rw-r--r--test/std/containers/unord/unord.map/iterators.pass.cpp128
-rw-r--r--test/std/containers/unord/unord.map/load_factor.pass.cpp77
-rw-r--r--test/std/containers/unord/unord.map/local_iterators.pass.cpp421
-rw-r--r--test/std/containers/unord/unord.map/max_bucket_count.pass.cpp43
-rw-r--r--test/std/containers/unord/unord.map/max_load_factor.pass.cpp71
-rw-r--r--test/std/containers/unord/unord.map/max_size.pass.cpp36
-rw-r--r--test/std/containers/unord/unord.map/rehash.pass.cpp91
-rw-r--r--test/std/containers/unord/unord.map/reserve.pass.cpp91
-rw-r--r--test/std/containers/unord/unord.map/swap_member.pass.cpp572
-rw-r--r--test/std/containers/unord/unord.map/types.pass.cpp72
-rw-r--r--test/std/containers/unord/unord.map/unord.map.cnstr/allocator.pass.cpp111
-rw-r--r--test/std/containers/unord/unord.map/unord.map.cnstr/assign_copy.pass.cpp185
-rw-r--r--test/std/containers/unord/unord.map/unord.map.cnstr/assign_init.pass.cpp97
-rw-r--r--test/std/containers/unord/unord.map/unord.map.cnstr/assign_move.pass.cpp229
-rw-r--r--test/std/containers/unord/unord.map/unord.map.cnstr/copy.pass.cpp151
-rw-r--r--test/std/containers/unord/unord.map/unord.map.cnstr/copy_alloc.pass.cpp110
-rw-r--r--test/std/containers/unord/unord.map/unord.map.cnstr/default.pass.cpp78
-rw-r--r--test/std/containers/unord/unord.map/unord.map.cnstr/default_noexcept.pass.cpp70
-rw-r--r--test/std/containers/unord/unord.map/unord.map.cnstr/dtor_noexcept.pass.cpp67
-rw-r--r--test/std/containers/unord/unord.map/unord.map.cnstr/init.pass.cpp162
-rw-r--r--test/std/containers/unord/unord.map/unord.map.cnstr/init_size.pass.cpp100
-rw-r--r--test/std/containers/unord/unord.map/unord.map.cnstr/init_size_hash.pass.cpp102
-rw-r--r--test/std/containers/unord/unord.map/unord.map.cnstr/init_size_hash_equal.pass.cpp105
-rw-r--r--test/std/containers/unord/unord.map/unord.map.cnstr/init_size_hash_equal_allocator.pass.cpp107
-rw-r--r--test/std/containers/unord/unord.map/unord.map.cnstr/move.pass.cpp199
-rw-r--r--test/std/containers/unord/unord.map/unord.map.cnstr/move_alloc.pass.cpp157
-rw-r--r--test/std/containers/unord/unord.map/unord.map.cnstr/move_assign_noexcept.pass.cpp69
-rw-r--r--test/std/containers/unord/unord.map/unord.map.cnstr/move_noexcept.pass.cpp66
-rw-r--r--test/std/containers/unord/unord.map/unord.map.cnstr/range.pass.cpp170
-rw-r--r--test/std/containers/unord/unord.map/unord.map.cnstr/range_size.pass.cpp105
-rw-r--r--test/std/containers/unord/unord.map/unord.map.cnstr/range_size_hash.pass.cpp108
-rw-r--r--test/std/containers/unord/unord.map/unord.map.cnstr/range_size_hash_equal.pass.cpp110
-rw-r--r--test/std/containers/unord/unord.map/unord.map.cnstr/range_size_hash_equal_allocator.pass.cpp113
-rw-r--r--test/std/containers/unord/unord.map/unord.map.cnstr/size.fail.cpp69
-rw-r--r--test/std/containers/unord/unord.map/unord.map.cnstr/size.pass.cpp69
-rw-r--r--test/std/containers/unord/unord.map/unord.map.cnstr/size_hash.pass.cpp73
-rw-r--r--test/std/containers/unord/unord.map/unord.map.cnstr/size_hash_equal.pass.cpp75
-rw-r--r--test/std/containers/unord/unord.map/unord.map.cnstr/size_hash_equal_allocator.pass.cpp77
-rw-r--r--test/std/containers/unord/unord.map/unord.map.elem/at.pass.cpp134
-rw-r--r--test/std/containers/unord/unord.map/unord.map.elem/index.pass.cpp115
-rw-r--r--test/std/containers/unord/unord.map/unord.map.elem/index_tuple.pass.cpp41
-rw-r--r--test/std/containers/unord/unord.map/unord.map.swap/db_swap_1.pass.cpp44
-rw-r--r--test/std/containers/unord/unord.map/unord.map.swap/swap_noexcept.pass.cpp199
-rw-r--r--test/std/containers/unord/unord.map/unord.map.swap/swap_non_member.pass.cpp572
-rw-r--r--test/std/containers/unord/unord.map/unorder.map.modifiers/clear.pass.cpp61
-rw-r--r--test/std/containers/unord/unord.map/unorder.map.modifiers/emplace.pass.cpp80
-rw-r--r--test/std/containers/unord/unord.map/unorder.map.modifiers/emplace_hint.pass.cpp93
-rw-r--r--test/std/containers/unord/unord.map/unorder.map.modifiers/erase_const_iter.pass.cpp92
-rw-r--r--test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_db1.pass.cpp39
-rw-r--r--test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_db2.pass.cpp42
-rw-r--r--test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db1.pass.cpp41
-rw-r--r--test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db2.pass.cpp41
-rw-r--r--test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db3.pass.cpp41
-rw-r--r--test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db4.pass.cpp40
-rw-r--r--test/std/containers/unord/unord.map/unorder.map.modifiers/erase_key.pass.cpp177
-rw-r--r--test/std/containers/unord/unord.map/unorder.map.modifiers/erase_range.pass.cpp99
-rw-r--r--test/std/containers/unord/unord.map/unorder.map.modifiers/insert_const_lvalue.pass.cpp86
-rw-r--r--test/std/containers/unord/unord.map/unorder.map.modifiers/insert_hint_const_lvalue.pass.cpp97
-rw-r--r--test/std/containers/unord/unord.map/unorder.map.modifiers/insert_hint_rvalue.pass.cpp156
-rw-r--r--test/std/containers/unord/unord.map/unorder.map.modifiers/insert_init.pass.cpp72
-rw-r--r--test/std/containers/unord/unord.map/unorder.map.modifiers/insert_or_assign.pass.cpp198
-rw-r--r--test/std/containers/unord/unord.map/unorder.map.modifiers/insert_range.pass.cpp71
-rw-r--r--test/std/containers/unord/unord.map/unorder.map.modifiers/insert_rvalue.pass.cpp152
-rw-r--r--test/std/containers/unord/unord.map/unorder.map.modifiers/try.emplace.pass.cpp195
-rw-r--r--test/std/containers/unord/unord.map/version.pass.cpp20
-rw-r--r--test/std/containers/unord/unord.multimap/bucket.pass.cpp77
-rw-r--r--test/std/containers/unord/unord.multimap/bucket_count.pass.cpp49
-rw-r--r--test/std/containers/unord/unord.multimap/bucket_size.pass.cpp85
-rw-r--r--test/std/containers/unord/unord.multimap/count.pass.cpp71
-rw-r--r--test/std/containers/unord/unord.multimap/db_iterators_7.pass.cpp60
-rw-r--r--test/std/containers/unord/unord.multimap/db_iterators_8.pass.cpp56
-rw-r--r--test/std/containers/unord/unord.multimap/db_local_iterators_7.pass.cpp57
-rw-r--r--test/std/containers/unord/unord.multimap/db_local_iterators_8.pass.cpp54
-rw-r--r--test/std/containers/unord/unord.multimap/eq.pass.cpp181
-rw-r--r--test/std/containers/unord/unord.multimap/equal_range_const.pass.cpp97
-rw-r--r--test/std/containers/unord/unord.multimap/equal_range_non_const.pass.cpp97
-rw-r--r--test/std/containers/unord/unord.multimap/find_const.pass.cpp71
-rw-r--r--test/std/containers/unord/unord.multimap/find_non_const.pass.cpp71
-rw-r--r--test/std/containers/unord/unord.multimap/iterators.fail.cpp69
-rw-r--r--test/std/containers/unord/unord.multimap/iterators.pass.cpp134
-rw-r--r--test/std/containers/unord/unord.multimap/load_factor.pass.cpp77
-rw-r--r--test/std/containers/unord/unord.multimap/local_iterators.fail.cpp286
-rw-r--r--test/std/containers/unord/unord.multimap/local_iterators.pass.cpp549
-rw-r--r--test/std/containers/unord/unord.multimap/max_bucket_count.pass.cpp43
-rw-r--r--test/std/containers/unord/unord.multimap/max_load_factor.pass.cpp71
-rw-r--r--test/std/containers/unord/unord.multimap/max_size.pass.cpp36
-rw-r--r--test/std/containers/unord/unord.multimap/rehash.pass.cpp119
-rw-r--r--test/std/containers/unord/unord.multimap/reserve.pass.cpp93
-rw-r--r--test/std/containers/unord/unord.multimap/scary.pass.cpp24
-rw-r--r--test/std/containers/unord/unord.multimap/swap_member.pass.cpp585
-rw-r--r--test/std/containers/unord/unord.multimap/types.pass.cpp72
-rw-r--r--test/std/containers/unord/unord.multimap/unord.multimap.cnstr/allocator.pass.cpp111
-rw-r--r--test/std/containers/unord/unord.multimap/unord.multimap.cnstr/assign_copy.pass.cpp227
-rw-r--r--test/std/containers/unord/unord.multimap/unord.multimap.cnstr/assign_init.pass.cpp146
-rw-r--r--test/std/containers/unord/unord.multimap/unord.multimap.cnstr/assign_move.pass.cpp306
-rw-r--r--test/std/containers/unord/unord.multimap/unord.multimap.cnstr/copy.pass.cpp193
-rw-r--r--test/std/containers/unord/unord.multimap/unord.multimap.cnstr/copy_alloc.pass.cpp138
-rw-r--r--test/std/containers/unord/unord.multimap/unord.multimap.cnstr/default.pass.cpp78
-rw-r--r--test/std/containers/unord/unord.multimap/unord.multimap.cnstr/default_noexcept.pass.cpp70
-rw-r--r--test/std/containers/unord/unord.multimap/unord.multimap.cnstr/dtor_noexcept.pass.cpp67
-rw-r--r--test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init.pass.cpp254
-rw-r--r--test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size.pass.cpp144
-rw-r--r--test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash.pass.cpp146
-rw-r--r--test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash_equal.pass.cpp149
-rw-r--r--test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash_equal_allocator.pass.cpp151
-rw-r--r--test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move.pass.cpp243
-rw-r--r--test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_alloc.pass.cpp228
-rw-r--r--test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_assign_noexcept.pass.cpp69
-rw-r--r--test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_noexcept.pass.cpp66
-rw-r--r--test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range.pass.cpp263
-rw-r--r--test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size.pass.cpp149
-rw-r--r--test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash.pass.cpp152
-rw-r--r--test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash_equal.pass.cpp154
-rw-r--r--test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash_equal_allocator.pass.cpp157
-rw-r--r--test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size.fail.cpp69
-rw-r--r--test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size.pass.cpp69
-rw-r--r--test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash.pass.cpp73
-rw-r--r--test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash_equal.pass.cpp75
-rw-r--r--test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash_equal_allocator.pass.cpp77
-rw-r--r--test/std/containers/unord/unord.multimap/unord.multimap.modifiers/clear.pass.cpp61
-rw-r--r--test/std/containers/unord/unord.multimap/unord.multimap.modifiers/emplace.pass.cpp74
-rw-r--r--test/std/containers/unord/unord.multimap/unord.multimap.modifiers/emplace_hint.pass.cpp109
-rw-r--r--test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_const_iter.pass.cpp140
-rw-r--r--test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_db1.pass.cpp39
-rw-r--r--test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_db2.pass.cpp42
-rw-r--r--test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db1.pass.cpp41
-rw-r--r--test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db2.pass.cpp41
-rw-r--r--test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db3.pass.cpp41
-rw-r--r--test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db4.pass.cpp40
-rw-r--r--test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_key.pass.cpp388
-rw-r--r--test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_range.pass.cpp179
-rw-r--r--test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_const_lvalue.pass.cpp78
-rw-r--r--test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_const_lvalue.pass.cpp97
-rw-r--r--test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_rvalue.pass.cpp156
-rw-r--r--test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_init.pass.cpp122
-rw-r--r--test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_range.pass.cpp121
-rw-r--r--test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_rvalue.pass.cpp136
-rw-r--r--test/std/containers/unord/unord.multimap/unord.multimap.swap/db_swap_1.pass.cpp44
-rw-r--r--test/std/containers/unord/unord.multimap/unord.multimap.swap/swap_noexcept.pass.cpp198
-rw-r--r--test/std/containers/unord/unord.multimap/unord.multimap.swap/swap_non_member.pass.cpp584
-rw-r--r--test/std/containers/unord/unord.multiset/bucket.pass.cpp76
-rw-r--r--test/std/containers/unord/unord.multiset/bucket_count.pass.cpp79
-rw-r--r--test/std/containers/unord/unord.multiset/bucket_size.pass.cpp84
-rw-r--r--test/std/containers/unord/unord.multiset/clear.pass.cpp60
-rw-r--r--test/std/containers/unord/unord.multiset/count.pass.cpp70
-rw-r--r--test/std/containers/unord/unord.multiset/db_iterators_7.pass.cpp58
-rw-r--r--test/std/containers/unord/unord.multiset/db_iterators_8.pass.cpp54
-rw-r--r--test/std/containers/unord/unord.multiset/db_local_iterators_7.pass.cpp57
-rw-r--r--test/std/containers/unord/unord.multiset/db_local_iterators_8.pass.cpp54
-rw-r--r--test/std/containers/unord/unord.multiset/emplace.pass.cpp64
-rw-r--r--test/std/containers/unord/unord.multiset/emplace_hint.pass.cpp80
-rw-r--r--test/std/containers/unord/unord.multiset/eq.pass.cpp180
-rw-r--r--test/std/containers/unord/unord.multiset/equal_range_const.pass.cpp90
-rw-r--r--test/std/containers/unord/unord.multiset/equal_range_non_const.pass.cpp90
-rw-r--r--test/std/containers/unord/unord.multiset/erase_const_iter.pass.cpp93
-rw-r--r--test/std/containers/unord/unord.multiset/erase_iter_db1.pass.cpp38
-rw-r--r--test/std/containers/unord/unord.multiset/erase_iter_db2.pass.cpp41
-rw-r--r--test/std/containers/unord/unord.multiset/erase_iter_iter_db1.pass.cpp40
-rw-r--r--test/std/containers/unord/unord.multiset/erase_iter_iter_db2.pass.cpp40
-rw-r--r--test/std/containers/unord/unord.multiset/erase_iter_iter_db3.pass.cpp40
-rw-r--r--test/std/containers/unord/unord.multiset/erase_iter_iter_db4.pass.cpp39
-rw-r--r--test/std/containers/unord/unord.multiset/erase_key.pass.cpp176
-rw-r--r--test/std/containers/unord/unord.multiset/erase_range.pass.cpp94
-rw-r--r--test/std/containers/unord/unord.multiset/find_const.pass.cpp68
-rw-r--r--test/std/containers/unord/unord.multiset/find_non_const.pass.cpp68
-rw-r--r--test/std/containers/unord/unord.multiset/insert_const_lvalue.pass.cpp70
-rw-r--r--test/std/containers/unord/unord.multiset/insert_hint_const_lvalue.pass.cpp89
-rw-r--r--test/std/containers/unord/unord.multiset/insert_hint_rvalue.pass.cpp138
-rw-r--r--test/std/containers/unord/unord.multiset/insert_init.pass.cpp71
-rw-r--r--test/std/containers/unord/unord.multiset/insert_range.pass.cpp70
-rw-r--r--test/std/containers/unord/unord.multiset/insert_rvalue.pass.cpp118
-rw-r--r--test/std/containers/unord/unord.multiset/iterators.fail.cpp67
-rw-r--r--test/std/containers/unord/unord.multiset/iterators.pass.cpp127
-rw-r--r--test/std/containers/unord/unord.multiset/load_factor.pass.cpp76
-rw-r--r--test/std/containers/unord/unord.multiset/local_iterators.fail.cpp261
-rw-r--r--test/std/containers/unord/unord.multiset/local_iterators.pass.cpp500
-rw-r--r--test/std/containers/unord/unord.multiset/max_bucket_count.pass.cpp38
-rw-r--r--test/std/containers/unord/unord.multiset/max_load_factor.pass.cpp70
-rw-r--r--test/std/containers/unord/unord.multiset/max_size.pass.cpp36
-rw-r--r--test/std/containers/unord/unord.multiset/rehash.pass.cpp90
-rw-r--r--test/std/containers/unord/unord.multiset/reserve.pass.cpp90
-rw-r--r--test/std/containers/unord/unord.multiset/scary.pass.cpp24
-rw-r--r--test/std/containers/unord/unord.multiset/swap_member.pass.cpp571
-rw-r--r--test/std/containers/unord/unord.multiset/types.pass.cpp69
-rw-r--r--test/std/containers/unord/unord.multiset/unord.multiset.cnstr/allocator.pass.cpp109
-rw-r--r--test/std/containers/unord/unord.multiset/unord.multiset.cnstr/assign_copy.pass.cpp209
-rw-r--r--test/std/containers/unord/unord.multiset/unord.multiset.cnstr/assign_init.pass.cpp97
-rw-r--r--test/std/containers/unord/unord.multiset/unord.multiset.cnstr/assign_move.pass.cpp286
-rw-r--r--test/std/containers/unord/unord.multiset/unord.multiset.cnstr/copy.pass.cpp171
-rw-r--r--test/std/containers/unord/unord.multiset/unord.multiset.cnstr/copy_alloc.pass.cpp123
-rw-r--r--test/std/containers/unord/unord.multiset/unord.multiset.cnstr/default.pass.cpp74
-rw-r--r--test/std/containers/unord/unord.multiset/unord.multiset.cnstr/default_noexcept.pass.cpp70
-rw-r--r--test/std/containers/unord/unord.multiset/unord.multiset.cnstr/dtor_noexcept.pass.cpp67
-rw-r--r--test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init.pass.cpp163
-rw-r--r--test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init_size.pass.cpp97
-rw-r--r--test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash.pass.cpp100
-rw-r--r--test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash_equal.pass.cpp102
-rw-r--r--test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash_equal_allocator.pass.cpp104
-rw-r--r--test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move.pass.cpp194
-rw-r--r--test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move_alloc.pass.cpp213
-rw-r--r--test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move_assign_noexcept.pass.cpp69
-rw-r--r--test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move_noexcept.pass.cpp66
-rw-r--r--test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range.pass.cpp167
-rw-r--r--test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range_size.pass.cpp101
-rw-r--r--test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash.pass.cpp104
-rw-r--r--test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash_equal.pass.cpp106
-rw-r--r--test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash_equal_allocator.pass.cpp109
-rw-r--r--test/std/containers/unord/unord.multiset/unord.multiset.cnstr/size.fail.cpp65
-rw-r--r--test/std/containers/unord/unord.multiset/unord.multiset.cnstr/size.pass.cpp65
-rw-r--r--test/std/containers/unord/unord.multiset/unord.multiset.cnstr/size_hash.pass.cpp69
-rw-r--r--test/std/containers/unord/unord.multiset/unord.multiset.cnstr/size_hash_equal.pass.cpp71
-rw-r--r--test/std/containers/unord/unord.multiset/unord.multiset.cnstr/size_hash_equal_allocator.pass.cpp73
-rw-r--r--test/std/containers/unord/unord.multiset/unord.multiset.swap/db_swap_1.pass.cpp43
-rw-r--r--test/std/containers/unord/unord.multiset/unord.multiset.swap/swap_noexcept.pass.cpp198
-rw-r--r--test/std/containers/unord/unord.multiset/unord.multiset.swap/swap_non_member.pass.cpp571
-rw-r--r--test/std/containers/unord/unord.set/bucket.pass.cpp75
-rw-r--r--test/std/containers/unord/unord.set/bucket_count.pass.cpp77
-rw-r--r--test/std/containers/unord/unord.set/bucket_size.pass.cpp79
-rw-r--r--test/std/containers/unord/unord.set/clear.pass.cpp59
-rw-r--r--test/std/containers/unord/unord.set/count.pass.cpp69
-rw-r--r--test/std/containers/unord/unord.set/db_iterators_7.pass.cpp58
-rw-r--r--test/std/containers/unord/unord.set/db_iterators_8.pass.cpp54
-rw-r--r--test/std/containers/unord/unord.set/db_local_iterators_7.pass.cpp57
-rw-r--r--test/std/containers/unord/unord.set/db_local_iterators_8.pass.cpp54
-rw-r--r--test/std/containers/unord/unord.set/emplace.pass.cpp70
-rw-r--r--test/std/containers/unord/unord.set/emplace_hint.pass.cpp80
-rw-r--r--test/std/containers/unord/unord.set/eq.pass.cpp159
-rw-r--r--test/std/containers/unord/unord.set/equal_range_const.pass.cpp81
-rw-r--r--test/std/containers/unord/unord.set/equal_range_non_const.pass.cpp81
-rw-r--r--test/std/containers/unord/unord.set/erase_const_iter.pass.cpp90
-rw-r--r--test/std/containers/unord/unord.set/erase_iter_db1.pass.cpp38
-rw-r--r--test/std/containers/unord/unord.set/erase_iter_db2.pass.cpp41
-rw-r--r--test/std/containers/unord/unord.set/erase_iter_iter_db1.pass.cpp40
-rw-r--r--test/std/containers/unord/unord.set/erase_iter_iter_db2.pass.cpp40
-rw-r--r--test/std/containers/unord/unord.set/erase_iter_iter_db3.pass.cpp40
-rw-r--r--test/std/containers/unord/unord.set/erase_iter_iter_db4.pass.cpp39
-rw-r--r--test/std/containers/unord/unord.set/erase_key.pass.cpp175
-rw-r--r--test/std/containers/unord/unord.set/erase_range.pass.cpp93
-rw-r--r--test/std/containers/unord/unord.set/find_const.pass.cpp67
-rw-r--r--test/std/containers/unord/unord.set/find_non_const.pass.cpp67
-rw-r--r--test/std/containers/unord/unord.set/insert_const_lvalue.pass.cpp78
-rw-r--r--test/std/containers/unord/unord.set/insert_hint_const_lvalue.pass.cpp89
-rw-r--r--test/std/containers/unord/unord.set/insert_hint_rvalue.pass.cpp138
-rw-r--r--test/std/containers/unord/unord.set/insert_init.pass.cpp71
-rw-r--r--test/std/containers/unord/unord.set/insert_range.pass.cpp70
-rw-r--r--test/std/containers/unord/unord.set/insert_rvalue.pass.cpp134
-rw-r--r--test/std/containers/unord/unord.set/iterators.fail.cpp67
-rw-r--r--test/std/containers/unord/unord.set/iterators.pass.cpp127
-rw-r--r--test/std/containers/unord/unord.set/load_factor.pass.cpp76
-rw-r--r--test/std/containers/unord/unord.set/local_iterators.fail.cpp261
-rw-r--r--test/std/containers/unord/unord.set/local_iterators.pass.cpp388
-rw-r--r--test/std/containers/unord/unord.set/max_bucket_count.pass.cpp38
-rw-r--r--test/std/containers/unord/unord.set/max_load_factor.pass.cpp70
-rw-r--r--test/std/containers/unord/unord.set/max_size.pass.cpp36
-rw-r--r--test/std/containers/unord/unord.set/rehash.pass.cpp90
-rw-r--r--test/std/containers/unord/unord.set/reserve.pass.cpp90
-rw-r--r--test/std/containers/unord/unord.set/swap_member.pass.cpp571
-rw-r--r--test/std/containers/unord/unord.set/types.pass.cpp69
-rw-r--r--test/std/containers/unord/unord.set/unord.set.cnstr/allocator.pass.cpp109
-rw-r--r--test/std/containers/unord/unord.set/unord.set.cnstr/assign_copy.pass.cpp184
-rw-r--r--test/std/containers/unord/unord.set/unord.set.cnstr/assign_init.pass.cpp97
-rw-r--r--test/std/containers/unord/unord.set/unord.set.cnstr/assign_move.pass.cpp225
-rw-r--r--test/std/containers/unord/unord.set/unord.set.cnstr/copy.pass.cpp147
-rw-r--r--test/std/containers/unord/unord.set/unord.set.cnstr/copy_alloc.pass.cpp107
-rw-r--r--test/std/containers/unord/unord.set/unord.set.cnstr/default.pass.cpp74
-rw-r--r--test/std/containers/unord/unord.set/unord.set.cnstr/default_noexcept.pass.cpp70
-rw-r--r--test/std/containers/unord/unord.set/unord.set.cnstr/dtor_noexcept.pass.cpp67
-rw-r--r--test/std/containers/unord/unord.set/unord.set.cnstr/init.pass.cpp163
-rw-r--r--test/std/containers/unord/unord.set/unord.set.cnstr/init_size.pass.cpp97
-rw-r--r--test/std/containers/unord/unord.set/unord.set.cnstr/init_size_hash.pass.cpp100
-rw-r--r--test/std/containers/unord/unord.set/unord.set.cnstr/init_size_hash_equal.pass.cpp102
-rw-r--r--test/std/containers/unord/unord.set/unord.set.cnstr/init_size_hash_equal_allocator.pass.cpp104
-rw-r--r--test/std/containers/unord/unord.set/unord.set.cnstr/move.pass.cpp194
-rw-r--r--test/std/containers/unord/unord.set/unord.set.cnstr/move_alloc.pass.cpp156
-rw-r--r--test/std/containers/unord/unord.set/unord.set.cnstr/move_assign_noexcept.pass.cpp69
-rw-r--r--test/std/containers/unord/unord.set/unord.set.cnstr/move_noexcept.pass.cpp66
-rw-r--r--test/std/containers/unord/unord.set/unord.set.cnstr/range.pass.cpp168
-rw-r--r--test/std/containers/unord/unord.set/unord.set.cnstr/range_size.pass.cpp101
-rw-r--r--test/std/containers/unord/unord.set/unord.set.cnstr/range_size_hash.pass.cpp104
-rw-r--r--test/std/containers/unord/unord.set/unord.set.cnstr/range_size_hash_equal.pass.cpp106
-rw-r--r--test/std/containers/unord/unord.set/unord.set.cnstr/range_size_hash_equal_allocator.pass.cpp109
-rw-r--r--test/std/containers/unord/unord.set/unord.set.cnstr/size.fail.cpp45
-rw-r--r--test/std/containers/unord/unord.set/unord.set.cnstr/size.pass.cpp65
-rw-r--r--test/std/containers/unord/unord.set/unord.set.cnstr/size_hash.pass.cpp69
-rw-r--r--test/std/containers/unord/unord.set/unord.set.cnstr/size_hash_equal.pass.cpp71
-rw-r--r--test/std/containers/unord/unord.set/unord.set.cnstr/size_hash_equal_allocator.pass.cpp73
-rw-r--r--test/std/containers/unord/unord.set/unord.set.swap/db_swap_1.pass.cpp43
-rw-r--r--test/std/containers/unord/unord.set/unord.set.swap/swap_noexcept.pass.cpp198
-rw-r--r--test/std/containers/unord/unord.set/unord.set.swap/swap_non_member.pass.cpp571
-rw-r--r--test/std/containers/unord/unord.set/version.pass.cpp20
-rw-r--r--test/std/depr/depr.auto.ptr/auto.ptr/A.h30
-rw-r--r--test/std/depr/depr.auto.ptr/auto.ptr/AB.h41
-rw-r--r--test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/assignment.fail.cpp44
-rw-r--r--test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/assignment.pass.cpp44
-rw-r--r--test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert.fail.cpp40
-rw-r--r--test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert.pass.cpp40
-rw-r--r--test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert_assignment.fail.cpp47
-rw-r--r--test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert_assignment.pass.cpp47
-rw-r--r--test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/copy.fail.cpp38
-rw-r--r--test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/copy.pass.cpp38
-rw-r--r--test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/explicit.fail.cpp40
-rw-r--r--test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/pointer.pass.cpp40
-rw-r--r--test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/assign_from_auto_ptr_ref.pass.cpp40
-rw-r--r--test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_from_auto_ptr_ref.pass.cpp39
-rw-r--r--test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_to_auto_ptr.pass.cpp36
-rw-r--r--test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_to_auto_ptr_ref.pass.cpp33
-rw-r--r--test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/arrow.pass.cpp37
-rw-r--r--test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/deref.pass.cpp37
-rw-r--r--test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/release.pass.cpp38
-rw-r--r--test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/reset.pass.cpp54
-rw-r--r--test/std/depr/depr.auto.ptr/auto.ptr/element_type.pass.cpp36
-rw-r--r--test/std/depr/depr.auto.ptr/nothing_to_do.pass.cpp12
-rw-r--r--test/std/depr/depr.c.headers/assert_h.pass.cpp20
-rw-r--r--test/std/depr/depr.c.headers/ciso646.pass.cpp20
-rw-r--r--test/std/depr/depr.c.headers/complex.h.pass.cpp21
-rw-r--r--test/std/depr/depr.c.headers/ctype_h.pass.cpp103
-rw-r--r--test/std/depr/depr.c.headers/errno_h.pass.cpp33
-rw-r--r--test/std/depr/depr.c.headers/fenv_h.pass.cpp76
-rw-r--r--test/std/depr/depr.c.headers/float_h.pass.cpp140
-rw-r--r--test/std/depr/depr.c.headers/inttypes_h.pass.cpp643
-rw-r--r--test/std/depr/depr.c.headers/iso646_h.pass.cpp17
-rw-r--r--test/std/depr/depr.c.headers/limits_h.pass.cpp92
-rw-r--r--test/std/depr/depr.c.headers/locale_h.pass.cpp48
-rw-r--r--test/std/depr/depr.c.headers/math_h.pass.cpp683
-rw-r--r--test/std/depr/depr.c.headers/setjmp_h.pass.cpp20
-rw-r--r--test/std/depr/depr.c.headers/signal_h.pass.cpp57
-rw-r--r--test/std/depr/depr.c.headers/stdarg_h.pass.cpp35
-rw-r--r--test/std/depr/depr.c.headers/stdbool_h.pass.cpp32
-rw-r--r--test/std/depr/depr.c.headers/stddef_h.pass.cpp37
-rw-r--r--test/std/depr/depr.c.headers/stdint_h.pass.cpp291
-rw-r--r--test/std/depr/depr.c.headers/stdio_h.pass.cpp138
-rw-r--r--test/std/depr/depr.c.headers/stdlib_h.pass.cpp84
-rw-r--r--test/std/depr/depr.c.headers/string_h.pass.cpp50
-rw-r--r--test/std/depr/depr.c.headers/tgmath_h.pass.cpp23
-rw-r--r--test/std/depr/depr.c.headers/time_h.pass.cpp40
-rw-r--r--test/std/depr/depr.c.headers/uchar_h.pass.cpp19
-rw-r--r--test/std/depr/depr.c.headers/wchar_h.pass.cpp104
-rw-r--r--test/std/depr/depr.c.headers/wctype_h.pass.cpp114
-rw-r--r--test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/pointer_to_binary_function.pass.cpp26
-rw-r--r--test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/pointer_to_unary_function.pass.cpp26
-rw-r--r--test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/ptr_fun1.pass.cpp25
-rw-r--r--test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/ptr_fun2.pass.cpp25
-rw-r--r--test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun.pass.cpp31
-rw-r--r--test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1.pass.cpp31
-rw-r--r--test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1_ref_t.pass.cpp33
-rw-r--r--test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1_t.pass.cpp33
-rw-r--r--test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref.pass.cpp31
-rw-r--r--test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref1.pass.cpp31
-rw-r--r--test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref_t.pass.cpp33
-rw-r--r--test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_t.pass.cpp33
-rw-r--r--test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun.pass.cpp31
-rw-r--r--test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1.pass.cpp31
-rw-r--r--test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1_ref_t.pass.cpp33
-rw-r--r--test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1_t.pass.cpp33
-rw-r--r--test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref.pass.cpp31
-rw-r--r--test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref1.pass.cpp31
-rw-r--r--test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref_t.pass.cpp33
-rw-r--r--test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_t.pass.cpp33
-rw-r--r--test/std/depr/depr.function.objects/depr.adaptors/nothing_to_do.pass.cpp12
-rw-r--r--test/std/depr/depr.function.objects/depr.base/binary_function.pass.cpp28
-rw-r--r--test/std/depr/depr.function.objects/depr.base/unary_function.pass.cpp26
-rw-r--r--test/std/depr/depr.function.objects/nothing_to_do.pass.cpp12
-rw-r--r--test/std/depr/depr.ios.members/io_state.pass.cpp25
-rw-r--r--test/std/depr/depr.ios.members/open_mode.pass.cpp25
-rw-r--r--test/std/depr/depr.ios.members/seek_dir.pass.cpp25
-rw-r--r--test/std/depr/depr.ios.members/streamoff.pass.cpp25
-rw-r--r--test/std/depr/depr.ios.members/streampos.pass.cpp24
-rw-r--r--test/std/depr/depr.lib.binders/depr.lib.bind.1st/bind1st.pass.cpp24
-rw-r--r--test/std/depr/depr.lib.binders/depr.lib.bind.2nd/bind2nd.pass.cpp24
-rw-r--r--test/std/depr/depr.lib.binders/depr.lib.binder.1st/binder1st.pass.cpp58
-rw-r--r--test/std/depr/depr.lib.binders/depr.lib.binder.2nd/binder2nd.pass.cpp58
-rw-r--r--test/std/depr/depr.lib.binders/nothing_to_do.pass.cpp12
-rw-r--r--test/std/depr/depr.lib.binders/test_func.h33
-rw-r--r--test/std/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/ccp.pass.cpp43
-rw-r--r--test/std/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/ccp_size.pass.cpp43
-rw-r--r--test/std/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/cp.pass.cpp43
-rw-r--r--test/std/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/cp_size.pass.cpp43
-rw-r--r--test/std/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.members/rdbuf.pass.cpp27
-rw-r--r--test/std/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.members/str.pass.cpp26
-rw-r--r--test/std/depr/depr.str.strstreams/depr.istrstream/types.pass.cpp23
-rw-r--r--test/std/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.cons/cp_size_mode.pass.cpp41
-rw-r--r--test/std/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.cons/default.pass.cpp28
-rw-r--r--test/std/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.members/freeze.pass.cpp34
-rw-r--r--test/std/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.members/pcount.pass.cpp27
-rw-r--r--test/std/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.members/rdbuf.pass.cpp28
-rw-r--r--test/std/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.members/str.pass.cpp27
-rw-r--r--test/std/depr/depr.str.strstreams/depr.ostrstream/types.pass.cpp23
-rw-r--r--test/std/depr/depr.str.strstreams/depr.strstream/depr.strstream.cons/cp_size_mode.pass.cpp59
-rw-r--r--test/std/depr/depr.str.strstreams/depr.strstream/depr.strstream.cons/default.pass.cpp35
-rw-r--r--test/std/depr/depr.str.strstreams/depr.strstream/depr.strstream.dest/rdbuf.pass.cpp28
-rw-r--r--test/std/depr/depr.str.strstreams/depr.strstream/depr.strstream.oper/freeze.pass.cpp34
-rw-r--r--test/std/depr/depr.str.strstreams/depr.strstream/depr.strstream.oper/pcount.pass.cpp27
-rw-r--r--test/std/depr/depr.str.strstreams/depr.strstream/depr.strstream.oper/str.pass.cpp27
-rw-r--r--test/std/depr/depr.str.strstreams/depr.strstream/types.pass.cpp32
-rw-r--r--test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/ccp_size.pass.cpp40
-rw-r--r--test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/cp_size_cp.pass.cpp96
-rw-r--r--test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/cscp_size.pass.cpp40
-rw-r--r--test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/cucp_size.pass.cpp40
-rw-r--r--test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/custom_alloc.pass.cpp51
-rw-r--r--test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/default.pass.cpp31
-rw-r--r--test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/scp_size_scp.pass.cpp96
-rw-r--r--test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/ucp_size_ucp.pass.cpp96
-rw-r--r--test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.members/freeze.pass.cpp28
-rw-r--r--test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.members/pcount.pass.cpp32
-rw-r--r--test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.members/str.pass.cpp28
-rw-r--r--test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/overflow.pass.cpp47
-rw-r--r--test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/pbackfail.pass.cpp62
-rw-r--r--test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/seekoff.pass.cpp57
-rw-r--r--test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/seekpos.pass.cpp39
-rw-r--r--test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/setbuf.pass.cpp27
-rw-r--r--test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/underflow.pass.cpp51
-rw-r--r--test/std/depr/depr.str.strstreams/depr.strstreambuf/types.pass.cpp21
-rw-r--r--test/std/depr/depr.str.strstreams/version.pass.cpp20
-rw-r--r--test/std/depr/exception.unexpected/nothing_to_do.pass.cpp12
-rw-r--r--test/std/depr/exception.unexpected/set.unexpected/get_unexpected.pass.cpp39
-rw-r--r--test/std/depr/exception.unexpected/set.unexpected/set_unexpected.pass.cpp35
-rw-r--r--test/std/depr/exception.unexpected/unexpected.handler/unexpected_handler.pass.cpp19
-rw-r--r--test/std/depr/exception.unexpected/unexpected/unexpected.pass.cpp26
-rw-r--r--test/std/depr/nothing_to_do.pass.cpp12
-rw-r--r--test/std/diagnostics/assertions/cassert.pass.cpp24
-rw-r--r--test/std/diagnostics/diagnostics.general/nothing_to_do.pass.cpp12
-rw-r--r--test/std/diagnostics/errno/cerrno.pass.cpp349
-rw-r--r--test/std/diagnostics/nothing_to_do.pass.cpp12
-rw-r--r--test/std/diagnostics/std.exceptions/domain.error/domain_error.pass.cpp42
-rw-r--r--test/std/diagnostics/std.exceptions/invalid.argument/invalid_argument.pass.cpp42
-rw-r--r--test/std/diagnostics/std.exceptions/length.error/length_error.pass.cpp42
-rw-r--r--test/std/diagnostics/std.exceptions/logic.error/logic_error.pass.cpp42
-rw-r--r--test/std/diagnostics/std.exceptions/out.of.range/out_of_range.pass.cpp42
-rw-r--r--test/std/diagnostics/std.exceptions/overflow.error/overflow_error.pass.cpp42
-rw-r--r--test/std/diagnostics/std.exceptions/range.error/range_error.pass.cpp42
-rw-r--r--test/std/diagnostics/std.exceptions/runtime.error/runtime_error.pass.cpp42
-rw-r--r--test/std/diagnostics/std.exceptions/underflow.error/underflow_error.pass.cpp42
-rw-r--r--test/std/diagnostics/std.exceptions/version.pass.cpp20
-rw-r--r--test/std/diagnostics/syserr/errc.pass.cpp104
-rw-r--r--test/std/diagnostics/syserr/syserr.compare/eq_error_code_error_code.pass.cpp106
-rw-r--r--test/std/diagnostics/syserr/syserr.errcat/nothing_to_do.pass.cpp12
-rw-r--r--test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.derived/message.pass.cpp34
-rw-r--r--test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.nonvirtuals/default_ctor.pass.cpp40
-rw-r--r--test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.nonvirtuals/eq.pass.cpp26
-rw-r--r--test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.nonvirtuals/lt.pass.cpp26
-rw-r--r--test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.nonvirtuals/neq.pass.cpp26
-rw-r--r--test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/generic_category.pass.cpp25
-rw-r--r--test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/system_category.pass.cpp29
-rw-r--r--test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.overview/error_category.pass.cpp19
-rw-r--r--test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.virtuals/default_error_condition.pass.cpp25
-rw-r--r--test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.virtuals/equivalent_error_code_int.pass.cpp24
-rw-r--r--test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.virtuals/equivalent_int_error_condition.pass.cpp25
-rw-r--r--test/std/diagnostics/syserr/syserr.errcode/nothing_to_do.pass.cpp12
-rw-r--r--test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.constructors/ErrorCodeEnum.pass.cpp44
-rw-r--r--test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.constructors/default.pass.cpp24
-rw-r--r--test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.constructors/int_error_category.pass.cpp31
-rw-r--r--test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.modifiers/ErrorCodeEnum.pass.cpp45
-rw-r--r--test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.modifiers/assign.pass.cpp33
-rw-r--r--test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.modifiers/clear.pass.cpp30
-rw-r--r--test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.nonmembers/lt.pass.cpp27
-rw-r--r--test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.nonmembers/make_error_code.pass.cpp26
-rw-r--r--test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.nonmembers/stream_inserter.pass.cpp27
-rw-r--r--test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/bool.pass.cpp30
-rw-r--r--test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/category.pass.cpp23
-rw-r--r--test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/default_error_condition.pass.cpp31
-rw-r--r--test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/message.pass.cpp24
-rw-r--r--test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/value.pass.cpp23
-rw-r--r--test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.overview/nothing_to_do.pass.cpp12
-rw-r--r--test/std/diagnostics/syserr/syserr.errcondition/nothing_to_do.pass.cpp12
-rw-r--r--test/std/diagnostics/syserr/syserr.errcondition/syserr.errcondition.constructors/ErrorConditionEnum.pass.cpp26
-rw-r--r--test/std/diagnostics/syserr/syserr.errcondition/syserr.errcondition.constructors/default.pass.cpp24
-rw-r--r--test/std/diagnostics/syserr/syserr.errcondition/syserr.errcondition.constructors/int_error_category.pass.cpp31
-rw-r--r--test/std/diagnostics/syserr/syserr.errcondition/syserr.errcondition.modifiers/ErrorConditionEnum.pass.cpp27
-rw-r--r--test/std/diagnostics/syserr/syserr.errcondition/syserr.errcondition.modifiers/assign.pass.cpp33
-rw-r--r--test/std/diagnostics/syserr/syserr.errcondition/syserr.errcondition.modifiers/clear.pass.cpp30
-rw-r--r--test/std/diagnostics/syserr/syserr.errcondition/syserr.errcondition.nonmembers/lt.pass.cpp27
-rw-r--r--test/std/diagnostics/syserr/syserr.errcondition/syserr.errcondition.nonmembers/make_error_condition.pass.cpp26
-rw-r--r--test/std/diagnostics/syserr/syserr.errcondition/syserr.errcondition.observers/bool.pass.cpp30
-rw-r--r--test/std/diagnostics/syserr/syserr.errcondition/syserr.errcondition.observers/category.pass.cpp23
-rw-r--r--test/std/diagnostics/syserr/syserr.errcondition/syserr.errcondition.observers/message.pass.cpp24
-rw-r--r--test/std/diagnostics/syserr/syserr.errcondition/syserr.errcondition.observers/value.pass.cpp23
-rw-r--r--test/std/diagnostics/syserr/syserr.errcondition/syserr.errcondition.overview/nothing_to_do.pass.cpp12
-rw-r--r--test/std/diagnostics/syserr/syserr.hash/error_code.pass.cpp42
-rw-r--r--test/std/diagnostics/syserr/syserr.syserr/nothing_to_do.pass.cpp12
-rw-r--r--test/std/diagnostics/syserr/syserr.syserr/syserr.syserr.members/ctor_error_code.pass.cpp29
-rw-r--r--test/std/diagnostics/syserr/syserr.syserr/syserr.syserr.members/ctor_error_code_const_char_pointer.pass.cpp30
-rw-r--r--test/std/diagnostics/syserr/syserr.syserr/syserr.syserr.members/ctor_error_code_string.pass.cpp30
-rw-r--r--test/std/diagnostics/syserr/syserr.syserr/syserr.syserr.members/ctor_int_error_category.pass.cpp29
-rw-r--r--test/std/diagnostics/syserr/syserr.syserr/syserr.syserr.members/ctor_int_error_category_const_char_pointer.pass.cpp31
-rw-r--r--test/std/diagnostics/syserr/syserr.syserr/syserr.syserr.members/ctor_int_error_category_string.pass.cpp31
-rw-r--r--test/std/diagnostics/syserr/syserr.syserr/syserr.syserr.overview/nothing_to_do.pass.cpp12
-rw-r--r--test/std/diagnostics/syserr/version.pass.cpp20
-rw-r--r--test/std/experimental/algorithms/alg.random.sample/sample.fail.cpp36
-rw-r--r--test/std/experimental/algorithms/alg.random.sample/sample.pass.cpp146
-rw-r--r--test/std/experimental/algorithms/alg.random.sample/sample.stable.pass.cpp53
-rw-r--r--test/std/experimental/nothing_to_do.pass.cpp12
-rw-r--r--test/std/experimental/optional/optional.bad_optional_access/default.pass.cpp23
-rw-r--r--test/std/experimental/optional/optional.bad_optional_access/derive.pass.cpp25
-rw-r--r--test/std/experimental/optional/optional.comp_with_t/equal.pass.cpp58
-rw-r--r--test/std/experimental/optional/optional.comp_with_t/greater.pass.cpp61
-rw-r--r--test/std/experimental/optional/optional.comp_with_t/greater_equal.pass.cpp61
-rw-r--r--test/std/experimental/optional/optional.comp_with_t/less_equal.pass.cpp61
-rw-r--r--test/std/experimental/optional/optional.comp_with_t/less_than.pass.cpp61
-rw-r--r--test/std/experimental/optional/optional.comp_with_t/not_equal.pass.cpp58
-rw-r--r--test/std/experimental/optional/optional.defs/tested_elsewhere.pass.cpp12
-rw-r--r--test/std/experimental/optional/optional.general/nothing_to_do.pass.cpp12
-rw-r--r--test/std/experimental/optional/optional.hash/hash.pass.cpp47
-rw-r--r--test/std/experimental/optional/optional.inplace/in_place_t.pass.cpp42
-rw-r--r--test/std/experimental/optional/optional.nullops/equal.pass.cpp41
-rw-r--r--test/std/experimental/optional/optional.nullops/greater.pass.cpp41
-rw-r--r--test/std/experimental/optional/optional.nullops/greater_equal.pass.cpp41
-rw-r--r--test/std/experimental/optional/optional.nullops/less_equal.pass.cpp41
-rw-r--r--test/std/experimental/optional/optional.nullops/less_than.pass.cpp41
-rw-r--r--test/std/experimental/optional/optional.nullops/not_equal.pass.cpp41
-rw-r--r--test/std/experimental/optional/optional.nullopt/nullopt_t.pass.cpp43
-rw-r--r--test/std/experimental/optional/optional.object/optional.object.assign/assign_value.pass.cpp72
-rw-r--r--test/std/experimental/optional/optional.object/optional.object.assign/copy.pass.cpp90
-rw-r--r--test/std/experimental/optional/optional.object/optional.object.assign/emplace.pass.cpp148
-rw-r--r--test/std/experimental/optional/optional.object/optional.object.assign/emplace_initializer_list.pass.cpp116
-rw-r--r--test/std/experimental/optional/optional.object/optional.object.assign/move.pass.cpp103
-rw-r--r--test/std/experimental/optional/optional.object/optional.object.assign/nullopt_t.pass.cpp67
-rw-r--r--test/std/experimental/optional/optional.object/optional.object.ctor/const_T.pass.cpp117
-rw-r--r--test/std/experimental/optional/optional.object/optional.object.ctor/copy.pass.cpp124
-rw-r--r--test/std/experimental/optional/optional.object/optional.object.ctor/default.pass.cpp67
-rw-r--r--test/std/experimental/optional/optional.object/optional.object.ctor/in_place_t.pass.cpp145
-rw-r--r--test/std/experimental/optional/optional.object/optional.object.ctor/initializer_list.pass.cpp126
-rw-r--r--test/std/experimental/optional/optional.object/optional.object.ctor/move.pass.cpp124
-rw-r--r--test/std/experimental/optional/optional.object/optional.object.ctor/nullopt_t.pass.cpp68
-rw-r--r--test/std/experimental/optional/optional.object/optional.object.ctor/rvalue_T.pass.cpp110
-rw-r--r--test/std/experimental/optional/optional.object/optional.object.dtor/dtor.pass.cpp59
-rw-r--r--test/std/experimental/optional/optional.object/optional.object.observe/bool.pass.cpp32
-rw-r--r--test/std/experimental/optional/optional.object/optional.object.observe/dereference.pass.cpp49
-rw-r--r--test/std/experimental/optional/optional.object/optional.object.observe/dereference_const.pass.cpp57
-rw-r--r--test/std/experimental/optional/optional.object/optional.object.observe/op_arrow.pass.cpp48
-rw-r--r--test/std/experimental/optional/optional.object/optional.object.observe/op_arrow_const.pass.cpp67
-rw-r--r--test/std/experimental/optional/optional.object/optional.object.observe/value.pass.cpp53
-rw-r--r--test/std/experimental/optional/optional.object/optional.object.observe/value_const.fail.cpp40
-rw-r--r--test/std/experimental/optional/optional.object/optional.object.observe/value_const.pass.cpp58
-rw-r--r--test/std/experimental/optional/optional.object/optional.object.observe/value_or.pass.cpp71
-rw-r--r--test/std/experimental/optional/optional.object/optional.object.observe/value_or_const.pass.cpp82
-rw-r--r--test/std/experimental/optional/optional.object/optional.object.swap/swap.pass.cpp306
-rw-r--r--test/std/experimental/optional/optional.object/optional_const_void.fail.cpp25
-rw-r--r--test/std/experimental/optional/optional.object/optional_not_destructible.fail.cpp35
-rw-r--r--test/std/experimental/optional/optional.object/optional_not_noexcept_destructible.fail.cpp34
-rw-r--r--test/std/experimental/optional/optional.object/optional_void.fail.cpp25
-rw-r--r--test/std/experimental/optional/optional.object/types.pass.cpp43
-rw-r--r--test/std/experimental/optional/optional.relops/equal.pass.cpp79
-rw-r--r--test/std/experimental/optional/optional.relops/greater_equal.pass.cpp75
-rw-r--r--test/std/experimental/optional/optional.relops/greater_than.pass.cpp75
-rw-r--r--test/std/experimental/optional/optional.relops/less_equal.pass.cpp75
-rw-r--r--test/std/experimental/optional/optional.relops/less_than.pass.cpp75
-rw-r--r--test/std/experimental/optional/optional.relops/not_equal.pass.cpp79
-rw-r--r--test/std/experimental/optional/optional.specalg/make_optional.pass.cpp50
-rw-r--r--test/std/experimental/optional/optional.specalg/swap.pass.cpp305
-rw-r--r--test/std/experimental/optional/optional.syn/optional_const_in_place_t.fail.cpp28
-rw-r--r--test/std/experimental/optional/optional.syn/optional_const_lvalue_ref.fail.cpp26
-rw-r--r--test/std/experimental/optional/optional.syn/optional_const_nullopt_t.fail.cpp28
-rw-r--r--test/std/experimental/optional/optional.syn/optional_in_place_t.fail.cpp28
-rw-r--r--test/std/experimental/optional/optional.syn/optional_includes_initializer_list.pass.cpp23
-rw-r--r--test/std/experimental/optional/optional.syn/optional_lvalue_ref.fail.cpp26
-rw-r--r--test/std/experimental/optional/optional.syn/optional_nullopt_t.fail.cpp28
-rw-r--r--test/std/experimental/optional/optional.syn/optional_rvalue_ref.fail.cpp26
-rw-r--r--test/std/experimental/optional/version.pass.cpp20
-rw-r--r--test/std/experimental/string.view/nothing_to_do.pass.cpp12
-rw-r--r--test/std/experimental/string.view/string.view.access/at.pass.cpp57
-rw-r--r--test/std/experimental/string.view/string.view.access/back.pass.cpp48
-rw-r--r--test/std/experimental/string.view/string.view.access/data.pass.cpp48
-rw-r--r--test/std/experimental/string.view/string.view.access/front.pass.cpp48
-rw-r--r--test/std/experimental/string.view/string.view.access/index.pass.cpp51
-rw-r--r--test/std/experimental/string.view/string.view.capacity/capacity.pass.cpp87
-rw-r--r--test/std/experimental/string.view/string.view.comparison/opeq.string_view.pointer.pass.cpp68
-rw-r--r--test/std/experimental/string.view/string.view.comparison/opeq.string_view.string.pass.cpp54
-rw-r--r--test/std/experimental/string.view/string.view.comparison/opeq.string_view.string_view.pass.cpp61
-rw-r--r--test/std/experimental/string.view/string.view.comparison/opge.string_view.pointer.pass.cpp71
-rw-r--r--test/std/experimental/string.view/string.view.comparison/opge.string_view.string.pass.cpp50
-rw-r--r--test/std/experimental/string.view/string.view.comparison/opge.string_view.string_view.pass.cpp64
-rw-r--r--test/std/experimental/string.view/string.view.comparison/opgt.string_view.pointer.pass.cpp71
-rw-r--r--test/std/experimental/string.view/string.view.comparison/opgt.string_view.string.pass.cpp50
-rw-r--r--test/std/experimental/string.view/string.view.comparison/opgt.string_view.string_view.pass.cpp64
-rw-r--r--test/std/experimental/string.view/string.view.comparison/ople.string_view.pointer.pass.cpp71
-rw-r--r--test/std/experimental/string.view/string.view.comparison/ople.string_view.string.pass.cpp50
-rw-r--r--test/std/experimental/string.view/string.view.comparison/ople.string_view.string_view.pass.cpp64
-rw-r--r--test/std/experimental/string.view/string.view.comparison/oplt.string_view.pointer.pass.cpp71
-rw-r--r--test/std/experimental/string.view/string.view.comparison/oplt.string_view.string.pass.cpp50
-rw-r--r--test/std/experimental/string.view/string.view.comparison/oplt.string_view.string_view.pass.cpp64
-rw-r--r--test/std/experimental/string.view/string.view.comparison/opne.string_view.pointer.pass.cpp69
-rw-r--r--test/std/experimental/string.view/string.view.comparison/opne.string_view.string.pass.cpp49
-rw-r--r--test/std/experimental/string.view/string.view.comparison/opne.string_view.string_view.pass.cpp61
-rw-r--r--test/std/experimental/string.view/string.view.cons/default.pass.cpp46
-rw-r--r--test/std/experimental/string.view/string.view.cons/from_literal.pass.cpp64
-rw-r--r--test/std/experimental/string.view/string.view.cons/from_ptr_len.pass.cpp81
-rw-r--r--test/std/experimental/string.view/string.view.cons/from_string.pass.cpp54
-rw-r--r--test/std/experimental/string.view/string.view.cons/from_string1.fail.cpp32
-rw-r--r--test/std/experimental/string.view/string.view.cons/from_string2.fail.cpp32
-rw-r--r--test/std/experimental/string.view/string.view.find/find_char_size.pass.cpp84
-rw-r--r--test/std/experimental/string.view/string.view.find/find_first_not_of_char_size.pass.cpp84
-rw-r--r--test/std/experimental/string.view/string.view.find/find_first_not_of_pointer_size.pass.cpp165
-rw-r--r--test/std/experimental/string.view/string.view.find/find_first_not_of_pointer_size_size.pass.cpp392
-rw-r--r--test/std/experimental/string.view/string.view.find/find_first_not_of_string_view_size.pass.cpp148
-rw-r--r--test/std/experimental/string.view/string.view.find/find_first_of_char_size.pass.cpp82
-rw-r--r--test/std/experimental/string.view/string.view.find/find_first_of_pointer_size.pass.cpp165
-rw-r--r--test/std/experimental/string.view/string.view.find/find_first_of_pointer_size_size.pass.cpp392
-rw-r--r--test/std/experimental/string.view/string.view.find/find_first_of_string_view_size.pass.cpp148
-rw-r--r--test/std/experimental/string.view/string.view.find/find_last_not_of_char_size.pass.cpp82
-rw-r--r--test/std/experimental/string.view/string.view.find/find_last_not_of_pointer_size.pass.cpp165
-rw-r--r--test/std/experimental/string.view/string.view.find/find_last_not_of_pointer_size_size.pass.cpp392
-rw-r--r--test/std/experimental/string.view/string.view.find/find_last_not_of_string_view_size.pass.cpp148
-rw-r--r--test/std/experimental/string.view/string.view.find/find_last_of_char_size.pass.cpp82
-rw-r--r--test/std/experimental/string.view/string.view.find/find_last_of_pointer_size.pass.cpp165
-rw-r--r--test/std/experimental/string.view/string.view.find/find_last_of_pointer_size_size.pass.cpp392
-rw-r--r--test/std/experimental/string.view/string.view.find/find_last_of_string_view_size.pass.cpp148
-rw-r--r--test/std/experimental/string.view/string.view.find/find_pointer_size.pass.cpp171
-rw-r--r--test/std/experimental/string.view/string.view.find/find_pointer_size_size.pass.cpp393
-rw-r--r--test/std/experimental/string.view/string.view.find/find_string_view_size.pass.cpp164
-rw-r--r--test/std/experimental/string.view/string.view.find/rfind_char_size.pass.cpp83
-rw-r--r--test/std/experimental/string.view/string.view.find/rfind_pointer_size.pass.cpp171
-rw-r--r--test/std/experimental/string.view/string.view.find/rfind_pointer_size_size.pass.cpp392
-rw-r--r--test/std/experimental/string.view/string.view.find/rfind_string_view_size.pass.cpp164
-rw-r--r--test/std/experimental/string.view/string.view.hash/string_view.pass.cpp55
-rw-r--r--test/std/experimental/string.view/string.view.io/stream_insert.pass.cpp58
-rw-r--r--test/std/experimental/string.view/string.view.iterators/begin.pass.cpp77
-rw-r--r--test/std/experimental/string.view/string.view.iterators/end.pass.cpp85
-rw-r--r--test/std/experimental/string.view/string.view.iterators/rbegin.pass.cpp59
-rw-r--r--test/std/experimental/string.view/string.view.iterators/rend.pass.cpp66
-rw-r--r--test/std/experimental/string.view/string.view.modifiers/clear.pass.cpp65
-rw-r--r--test/std/experimental/string.view/string.view.modifiers/remove_prefix.pass.cpp76
-rw-r--r--test/std/experimental/string.view/string.view.modifiers/remove_suffix.pass.cpp76
-rw-r--r--test/std/experimental/string.view/string.view.modifiers/swap.pass.cpp74
-rw-r--r--test/std/experimental/string.view/string.view.nonmem/quoted.pass.cpp212
-rw-r--r--test/std/experimental/string.view/string.view.ops/basic_string.pass.cpp63
-rw-r--r--test/std/experimental/string.view/string.view.ops/compare.pointer.pass.cpp126
-rw-r--r--test/std/experimental/string.view/string.view.ops/compare.pointer_size.pass.cpp444
-rw-r--r--test/std/experimental/string.view/string.view.ops/compare.size_size_sv.pass.cpp397
-rw-r--r--test/std/experimental/string.view/string.view.ops/compare.size_size_sv_pointer_size.pass.cpp1349
-rw-r--r--test/std/experimental/string.view/string.view.ops/compare.size_size_sv_size_size.pass.cpp5843
-rw-r--r--test/std/experimental/string.view/string.view.ops/compare.sv.pass.cpp121
-rw-r--r--test/std/experimental/string.view/string.view.ops/copy.pass.cpp92
-rw-r--r--test/std/experimental/string.view/string.view.ops/substr.pass.cpp107
-rw-r--r--test/std/experimental/string.view/string.view.ops/to_string.pass.cpp76
-rw-r--r--test/std/experimental/string.view/string.view.synop/nothing_to_do.pass.cpp12
-rw-r--r--test/std/experimental/string.view/string.view.template/nothing_to_do.pass.cpp12
-rw-r--r--test/std/experimental/utilities/meta/meta.type.synop/includes.pass.cpp22
-rw-r--r--test/std/experimental/utilities/meta/meta.type.synop/meta.rel.pass.cpp65
-rw-r--r--test/std/experimental/utilities/meta/meta.type.synop/meta.unary.cat.pass.cpp181
-rw-r--r--test/std/experimental/utilities/meta/meta.type.synop/meta.unary.comp.pass.cpp102
-rw-r--r--test/std/experimental/utilities/meta/meta.type.synop/meta.unary.prop.pass.cpp489
-rw-r--r--test/std/experimental/utilities/meta/meta.type.synop/meta.unary.prop.query.pass.cpp66
-rw-r--r--test/std/experimental/utilities/meta/version.pass.cpp20
-rw-r--r--test/std/experimental/utilities/nothing_to_do.pass.cpp13
-rw-r--r--test/std/experimental/utilities/ratio/header.ratio.synop/includes.pass.cpp21
-rw-r--r--test/std/experimental/utilities/ratio/header.ratio.synop/ratio_equal_v.pass.cpp47
-rw-r--r--test/std/experimental/utilities/ratio/header.ratio.synop/ratio_greater_equal_v.pass.cpp61
-rw-r--r--test/std/experimental/utilities/ratio/header.ratio.synop/ratio_greater_v.pass.cpp57
-rw-r--r--test/std/experimental/utilities/ratio/header.ratio.synop/ratio_less_equal_v.pass.cpp57
-rw-r--r--test/std/experimental/utilities/ratio/header.ratio.synop/ratio_less_v.pass.cpp57
-rw-r--r--test/std/experimental/utilities/ratio/header.ratio.synop/ratio_not_equal_v.pass.cpp47
-rw-r--r--test/std/experimental/utilities/ratio/nothing_to_do.pass.cpp13
-rw-r--r--test/std/experimental/utilities/syserror/header.system_error.synop/includes.pass.cpp21
-rw-r--r--test/std/experimental/utilities/syserror/header.system_error.synop/is_error_code_enum_v.pass.cpp37
-rw-r--r--test/std/experimental/utilities/syserror/header.system_error.synop/is_error_condition_enum.pass.cpp38
-rw-r--r--test/std/experimental/utilities/time/header.chrono.synop/includes.pass.cpp19
-rw-r--r--test/std/experimental/utilities/time/header.chrono.synop/treat_as_floating_point_v.pass.cpp49
-rw-r--r--test/std/experimental/utilities/tuple/header.tuple.synop/includes.pass.cpp19
-rw-r--r--test/std/experimental/utilities/tuple/tuple.apply/arg_type.pass.cpp182
-rw-r--r--test/std/experimental/utilities/tuple/tuple.apply/constexpr_types.pass.cpp123
-rw-r--r--test/std/experimental/utilities/tuple/tuple.apply/extended_types.pass.cpp423
-rw-r--r--test/std/experimental/utilities/tuple/tuple.apply/large_arity.pass.cpp146
-rw-r--r--test/std/experimental/utilities/tuple/tuple.apply/ref_qualifiers.pass.cpp53
-rw-r--r--test/std/experimental/utilities/tuple/tuple.apply/return_type.pass.cpp76
-rw-r--r--test/std/experimental/utilities/tuple/tuple.apply/types.pass.cpp427
-rw-r--r--test/std/experimental/utilities/tuple/tuple_size_v.fail.cpp25
-rw-r--r--test/std/experimental/utilities/tuple/tuple_size_v.pass.cpp45
-rw-r--r--test/std/experimental/utilities/tuple/tuple_size_v_2.fail.cpp25
-rw-r--r--test/std/experimental/utilities/tuple/tuple_size_v_3.fail.cpp25
-rw-r--r--test/std/experimental/utilities/utility/utility.erased.type/erased_type.pass.cpp17
-rw-r--r--test/std/experimental/utilities/utility/utility.synop/includes.pass.cpp20
-rw-r--r--test/std/experimental/utilities/utility/version.pass.cpp20
-rw-r--r--test/std/extensions/hash/specializations.fail.cpp17
-rw-r--r--test/std/extensions/hash/specializations.pass.cpp31
-rw-r--r--test/std/extensions/hash_map/const_iterator.fail.cpp18
-rw-r--r--test/std/extensions/nothing_to_do.pass.cpp12
-rw-r--r--test/std/input.output/file.streams/c.files/cinttypes.pass.cpp929
-rw-r--r--test/std/input.output/file.streams/c.files/cstdio.pass.cpp148
-rw-r--r--test/std/input.output/file.streams/c.files/gets.fail.cpp23
-rw-r--r--test/std/input.output/file.streams/c.files/no.global.filesystem.namespace/fopen.fail.cpp15
-rw-r--r--test/std/input.output/file.streams/c.files/no.global.filesystem.namespace/lit.local.cfg2
-rw-r--r--test/std/input.output/file.streams/c.files/no.global.filesystem.namespace/rename.fail.cpp15
-rw-r--r--test/std/input.output/file.streams/c.files/version_ccstdio.pass.cpp20
-rw-r--r--test/std/input.output/file.streams/c.files/version_cinttypes.pass.cpp20
-rw-r--r--test/std/input.output/file.streams/fstreams/filebuf.assign/member_swap.pass.cpp54
-rw-r--r--test/std/input.output/file.streams/fstreams/filebuf.assign/move_assign.pass.cpp56
-rw-r--r--test/std/input.output/file.streams/fstreams/filebuf.assign/nonmember_swap.pass.cpp56
-rw-r--r--test/std/input.output/file.streams/fstreams/filebuf.cons/default.pass.cpp30
-rw-r--r--test/std/input.output/file.streams/fstreams/filebuf.cons/move.pass.cpp54
-rw-r--r--test/std/input.output/file.streams/fstreams/filebuf.members/open_pointer.pass.cpp51
-rw-r--r--test/std/input.output/file.streams/fstreams/filebuf.virtuals/overflow.pass.cpp142
-rw-r--r--test/std/input.output/file.streams/fstreams/filebuf.virtuals/pbackfail.pass.cpp56
-rw-r--r--test/std/input.output/file.streams/fstreams/filebuf.virtuals/seekoff.pass.cpp66
-rw-r--r--test/std/input.output/file.streams/fstreams/filebuf.virtuals/underflow.dat1
-rw-r--r--test/std/input.output/file.streams/fstreams/filebuf.virtuals/underflow.pass.cpp121
-rw-r--r--test/std/input.output/file.streams/fstreams/filebuf.virtuals/underflow_utf8.dat1
-rw-r--r--test/std/input.output/file.streams/fstreams/filebuf/types.pass.cpp34
-rw-r--r--test/std/input.output/file.streams/fstreams/fstream.assign/member_swap.pass.cpp71
-rw-r--r--test/std/input.output/file.streams/fstreams/fstream.assign/move_assign.pass.cpp50
-rw-r--r--test/std/input.output/file.streams/fstreams/fstream.assign/nonmember_swap.pass.cpp72
-rw-r--r--test/std/input.output/file.streams/fstreams/fstream.cons/default.pass.cpp28
-rw-r--r--test/std/input.output/file.streams/fstreams/fstream.cons/move.pass.cpp48
-rw-r--r--test/std/input.output/file.streams/fstreams/fstream.cons/pointer.pass.cpp44
-rw-r--r--test/std/input.output/file.streams/fstreams/fstream.cons/string.pass.cpp46
-rw-r--r--test/std/input.output/file.streams/fstreams/fstream.members/close.pass.cpp42
-rw-r--r--test/std/input.output/file.streams/fstreams/fstream.members/open_pointer.pass.cpp50
-rw-r--r--test/std/input.output/file.streams/fstreams/fstream.members/open_string.pass.cpp50
-rw-r--r--test/std/input.output/file.streams/fstreams/fstream.members/rdbuf.pass.cpp30
-rw-r--r--test/std/input.output/file.streams/fstreams/fstream/types.pass.cpp34
-rw-r--r--test/std/input.output/file.streams/fstreams/ifstream.assign/member_swap.pass.cpp42
-rw-r--r--test/std/input.output/file.streams/fstreams/ifstream.assign/move_assign.pass.cpp40
-rw-r--r--test/std/input.output/file.streams/fstreams/ifstream.assign/nonmember_swap.pass.cpp43
-rw-r--r--test/std/input.output/file.streams/fstreams/ifstream.assign/test.dat1
-rw-r--r--test/std/input.output/file.streams/fstreams/ifstream.assign/test2.dat1
-rw-r--r--test/std/input.output/file.streams/fstreams/ifstream.cons/default.pass.cpp28
-rw-r--r--test/std/input.output/file.streams/fstreams/ifstream.cons/move.pass.cpp38
-rw-r--r--test/std/input.output/file.streams/fstreams/ifstream.cons/pointer.pass.cpp46
-rw-r--r--test/std/input.output/file.streams/fstreams/ifstream.cons/string.pass.cpp46
-rw-r--r--test/std/input.output/file.streams/fstreams/ifstream.cons/test.dat1
-rw-r--r--test/std/input.output/file.streams/fstreams/ifstream.members/close.pass.cpp38
-rw-r--r--test/std/input.output/file.streams/fstreams/ifstream.members/open_pointer.pass.cpp46
-rw-r--r--test/std/input.output/file.streams/fstreams/ifstream.members/open_string.pass.cpp46
-rw-r--r--test/std/input.output/file.streams/fstreams/ifstream.members/rdbuf.pass.cpp32
-rw-r--r--test/std/input.output/file.streams/fstreams/ifstream.members/test.dat1
-rw-r--r--test/std/input.output/file.streams/fstreams/ifstream/types.pass.cpp34
-rw-r--r--test/std/input.output/file.streams/fstreams/lit.local.cfg2
-rw-r--r--test/std/input.output/file.streams/fstreams/ofstream.assign/member_swap.pass.cpp79
-rw-r--r--test/std/input.output/file.streams/fstreams/ofstream.assign/move_assign.pass.cpp52
-rw-r--r--test/std/input.output/file.streams/fstreams/ofstream.assign/nonmember_swap.pass.cpp80
-rw-r--r--test/std/input.output/file.streams/fstreams/ofstream.cons/default.pass.cpp28
-rw-r--r--test/std/input.output/file.streams/fstreams/ofstream.cons/move.pass.cpp50
-rw-r--r--test/std/input.output/file.streams/fstreams/ofstream.cons/pointer.pass.cpp46
-rw-r--r--test/std/input.output/file.streams/fstreams/ofstream.cons/string.pass.cpp46
-rw-r--r--test/std/input.output/file.streams/fstreams/ofstream.members/close.pass.cpp42
-rw-r--r--test/std/input.output/file.streams/fstreams/ofstream.members/open_pointer.pass.cpp58
-rw-r--r--test/std/input.output/file.streams/fstreams/ofstream.members/open_string.pass.cpp58
-rw-r--r--test/std/input.output/file.streams/fstreams/ofstream.members/rdbuf.pass.cpp36
-rw-r--r--test/std/input.output/file.streams/fstreams/ofstream/types.pass.cpp34
-rw-r--r--test/std/input.output/file.streams/fstreams/version.pass.cpp20
-rw-r--r--test/std/input.output/file.streams/nothing_to_do.pass.cpp12
-rw-r--r--test/std/input.output/input.output.general/nothing_to_do.pass.cpp12
-rw-r--r--test/std/input.output/iostream.format/ext.manip/get_money.pass.cpp75
-rw-r--r--test/std/input.output/iostream.format/ext.manip/get_time.pass.cpp73
-rw-r--r--test/std/input.output/iostream.format/ext.manip/put_money.pass.cpp91
-rw-r--r--test/std/input.output/iostream.format/ext.manip/put_time.pass.cpp84
-rw-r--r--test/std/input.output/iostream.format/input.streams/iostreamclass/iostream.assign/member_swap.pass.cpp85
-rw-r--r--test/std/input.output/iostream.format/input.streams/iostreamclass/iostream.assign/move_assign.pass.cpp92
-rw-r--r--test/std/input.output/iostream.format/input.streams/iostreamclass/iostream.cons/move.pass.cpp78
-rw-r--r--test/std/input.output/iostream.format/input.streams/iostreamclass/iostream.cons/streambuf.pass.cpp55
-rw-r--r--test/std/input.output/iostream.format/input.streams/iostreamclass/iostream.dest/nothing_to_do.pass.cpp12
-rw-r--r--test/std/input.output/iostream.format/input.streams/iostreamclass/types.pass.cpp37
-rw-r--r--test/std/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/bool.pass.cpp79
-rw-r--r--test/std/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/double.pass.cpp79
-rw-r--r--test/std/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/float.pass.cpp79
-rw-r--r--test/std/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/int.pass.cpp79
-rw-r--r--test/std/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/long.pass.cpp79
-rw-r--r--test/std/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/long_double.pass.cpp79
-rw-r--r--test/std/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/long_long.pass.cpp79
-rw-r--r--test/std/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/pointer.pass.cpp97
-rw-r--r--test/std/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/short.pass.cpp79
-rw-r--r--test/std/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/unsigned_int.pass.cpp79
-rw-r--r--test/std/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/unsigned_long.pass.cpp79
-rw-r--r--test/std/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/unsigned_long_long.pass.cpp79
-rw-r--r--test/std/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/unsigned_short.pass.cpp79
-rw-r--r--test/std/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.reqmts/tested_elsewhere.pass.cpp12
-rw-r--r--test/std/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/basic_ios.pass.cpp38
-rw-r--r--test/std/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/chart.pass.cpp87
-rw-r--r--test/std/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/ios_base.pass.cpp36
-rw-r--r--test/std/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/istream.pass.cpp38
-rw-r--r--test/std/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/signed_char.pass.cpp70
-rw-r--r--test/std/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/signed_char_pointer.pass.cpp85
-rw-r--r--test/std/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/streambuf.pass.cpp69
-rw-r--r--test/std/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/unsigned_char.pass.cpp70
-rw-r--r--test/std/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/unsigned_char_pointer.pass.cpp85
-rw-r--r--test/std/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/wchar_t_pointer.pass.cpp85
-rw-r--r--test/std/input.output/iostream.format/input.streams/istream.formatted/nothing_to_do.pass.cpp12
-rw-r--r--test/std/input.output/iostream.format/input.streams/istream.manip/ws.pass.cpp79
-rw-r--r--test/std/input.output/iostream.format/input.streams/istream.rvalue/rvalue.pass.cpp63
-rw-r--r--test/std/input.output/iostream.format/input.streams/istream.unformatted/get.pass.cpp100
-rw-r--r--test/std/input.output/iostream.format/input.streams/istream.unformatted/get_chart.pass.cpp103
-rw-r--r--test/std/input.output/iostream.format/input.streams/istream.unformatted/get_pointer_size.pass.cpp99
-rw-r--r--test/std/input.output/iostream.format/input.streams/istream.unformatted/get_pointer_size_chart.pass.cpp99
-rw-r--r--test/std/input.output/iostream.format/input.streams/istream.unformatted/get_streambuf.pass.cpp88
-rw-r--r--test/std/input.output/iostream.format/input.streams/istream.unformatted/get_streambuf_chart.pass.cpp89
-rw-r--r--test/std/input.output/iostream.format/input.streams/istream.unformatted/getline_pointer_size.pass.cpp83
-rw-r--r--test/std/input.output/iostream.format/input.streams/istream.unformatted/getline_pointer_size_chart.pass.cpp83
-rw-r--r--test/std/input.output/iostream.format/input.streams/istream.unformatted/ignore.pass.cpp76
-rw-r--r--test/std/input.output/iostream.format/input.streams/istream.unformatted/ignore_0xff.pass.cpp34
-rw-r--r--test/std/input.output/iostream.format/input.streams/istream.unformatted/peek.pass.cpp69
-rw-r--r--test/std/input.output/iostream.format/input.streams/istream.unformatted/putback.pass.cpp89
-rw-r--r--test/std/input.output/iostream.format/input.streams/istream.unformatted/read.pass.cpp81
-rw-r--r--test/std/input.output/iostream.format/input.streams/istream.unformatted/readsome.pass.cpp85
-rw-r--r--test/std/input.output/iostream.format/input.streams/istream.unformatted/seekg.pass.cpp66
-rw-r--r--test/std/input.output/iostream.format/input.streams/istream.unformatted/seekg_off.pass.cpp74
-rw-r--r--test/std/input.output/iostream.format/input.streams/istream.unformatted/sync.pass.cpp64
-rw-r--r--test/std/input.output/iostream.format/input.streams/istream.unformatted/tellg.pass.cpp63
-rw-r--r--test/std/input.output/iostream.format/input.streams/istream.unformatted/unget.pass.cpp81
-rw-r--r--test/std/input.output/iostream.format/input.streams/istream/istream.assign/member_swap.pass.cpp85
-rw-r--r--test/std/input.output/iostream.format/input.streams/istream/istream.assign/move_assign.pass.cpp92
-rw-r--r--test/std/input.output/iostream.format/input.streams/istream/istream.cons/move.pass.cpp78
-rw-r--r--test/std/input.output/iostream.format/input.streams/istream/istream.cons/streambuf.pass.cpp55
-rw-r--r--test/std/input.output/iostream.format/input.streams/istream/istream_sentry/ctor.pass.cpp128
-rw-r--r--test/std/input.output/iostream.format/input.streams/istream/types.pass.cpp35
-rw-r--r--test/std/input.output/iostream.format/input.streams/version.pass.cpp20
-rw-r--r--test/std/input.output/iostream.format/nothing_to_do.pass.cpp12
-rw-r--r--test/std/input.output/iostream.format/output.streams/ostream.assign/member_swap.pass.cpp85
-rw-r--r--test/std/input.output/iostream.format/output.streams/ostream.assign/move_assign.pass.cpp92
-rw-r--r--test/std/input.output/iostream.format/output.streams/ostream.cons/move.pass.cpp74
-rw-r--r--test/std/input.output/iostream.format/output.streams/ostream.cons/streambuf.pass.cpp53
-rw-r--r--test/std/input.output/iostream.format/output.streams/ostream.formatted/nothing_to_do.pass.cpp12
-rw-r--r--test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.formatted.reqmts/tested_elsewhere.pass.cpp12
-rw-r--r--test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/bool.pass.cpp91
-rw-r--r--test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/double.pass.cpp83
-rw-r--r--test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/float.pass.cpp83
-rw-r--r--test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/int.pass.cpp83
-rw-r--r--test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/long.pass.cpp83
-rw-r--r--test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/long_double.pass.cpp83
-rw-r--r--test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/long_long.pass.cpp83
-rw-r--r--test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/minus1.pass84
-rw-r--r--test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/pointer.pass.cpp91
-rw-r--r--test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/short.pass.cpp83
-rw-r--r--test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/unsigned_int.pass.cpp83
-rw-r--r--test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/unsigned_long.pass.cpp83
-rw-r--r--test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/unsigned_long_long.pass.cpp83
-rw-r--r--test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/unsigned_short.pass.cpp83
-rw-r--r--test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/CharT.pass.cpp88
-rw-r--r--test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/CharT_pointer.pass.cpp88
-rw-r--r--test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/char.pass.cpp88
-rw-r--r--test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/char_pointer.pass.cpp88
-rw-r--r--test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/char_to_wide.pass.cpp88
-rw-r--r--test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/char_to_wide_pointer.pass.cpp88
-rw-r--r--test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/signed_char.pass.cpp88
-rw-r--r--test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/signed_char_pointer.pass.cpp88
-rw-r--r--test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/unsigned_char.pass.cpp88
-rw-r--r--test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/unsigned_char_pointer.pass.cpp88
-rw-r--r--test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/basic_ios.pass.cpp70
-rw-r--r--test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/ios_base.pass.cpp61
-rw-r--r--test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/ostream.pass.cpp69
-rw-r--r--test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/streambuf.pass.cpp69
-rw-r--r--test/std/input.output/iostream.format/output.streams/ostream.manip/endl.pass.cpp80
-rw-r--r--test/std/input.output/iostream.format/output.streams/ostream.manip/ends.pass.cpp71
-rw-r--r--test/std/input.output/iostream.format/output.streams/ostream.manip/flush.pass.cpp58
-rw-r--r--test/std/input.output/iostream.format/output.streams/ostream.rvalue/CharT_pointer.pass.cpp72
-rw-r--r--test/std/input.output/iostream.format/output.streams/ostream.seeks/seekp.pass.cpp68
-rw-r--r--test/std/input.output/iostream.format/output.streams/ostream.seeks/seekp2.pass.cpp70
-rw-r--r--test/std/input.output/iostream.format/output.streams/ostream.seeks/tellp.pass.cpp54
-rw-r--r--test/std/input.output/iostream.format/output.streams/ostream.unformatted/flush.pass.cpp54
-rw-r--r--test/std/input.output/iostream.format/output.streams/ostream.unformatted/put.pass.cpp76
-rw-r--r--test/std/input.output/iostream.format/output.streams/ostream.unformatted/write.pass.cpp76
-rw-r--r--test/std/input.output/iostream.format/output.streams/ostream/types.pass.cpp35
-rw-r--r--test/std/input.output/iostream.format/output.streams/ostream_sentry/construct.pass.cpp61
-rw-r--r--test/std/input.output/iostream.format/output.streams/ostream_sentry/destruct.pass.cpp75
-rw-r--r--test/std/input.output/iostream.format/output.streams/version.pass.cpp20
-rw-r--r--test/std/input.output/iostream.format/quoted.manip/quoted.pass.cpp219
-rw-r--r--test/std/input.output/iostream.format/quoted.manip/quoted_char.fail.cpp36
-rw-r--r--test/std/input.output/iostream.format/quoted.manip/quoted_traits.fail.cpp42
-rw-r--r--test/std/input.output/iostream.format/std.manip/resetiosflags.pass.cpp54
-rw-r--r--test/std/input.output/iostream.format/std.manip/setbase.pass.cpp74
-rw-r--r--test/std/input.output/iostream.format/std.manip/setfill.pass.cpp38
-rw-r--r--test/std/input.output/iostream.format/std.manip/setiosflags.pass.cpp54
-rw-r--r--test/std/input.output/iostream.format/std.manip/setprecision.pass.cpp50
-rw-r--r--test/std/input.output/iostream.format/std.manip/setw.pass.cpp50
-rw-r--r--test/std/input.output/iostream.format/std.manip/version.pass.cpp20
-rw-r--r--test/std/input.output/iostream.forward/iosfwd.pass.cpp142
-rw-r--r--test/std/input.output/iostream.forward/version.pass.cpp20
-rw-r--r--test/std/input.output/iostream.objects/narrow.stream.objects/cerr.pass.cpp29
-rw-r--r--test/std/input.output/iostream.objects/narrow.stream.objects/cin.pass.cpp34
-rw-r--r--test/std/input.output/iostream.objects/narrow.stream.objects/clog.pass.cpp23
-rw-r--r--test/std/input.output/iostream.objects/narrow.stream.objects/cout.pass.cpp29
-rw-r--r--test/std/input.output/iostream.objects/version.pass.cpp20
-rw-r--r--test/std/input.output/iostream.objects/wide.stream.objects/wcerr.pass.cpp29
-rw-r--r--test/std/input.output/iostream.objects/wide.stream.objects/wcin.pass.cpp34
-rw-r--r--test/std/input.output/iostream.objects/wide.stream.objects/wclog.pass.cpp23
-rw-r--r--test/std/input.output/iostream.objects/wide.stream.objects/wcout.pass.cpp25
-rw-r--r--test/std/input.output/iostreams.base/fpos/fpos.members/state.pass.cpp24
-rw-r--r--test/std/input.output/iostreams.base/fpos/fpos.operations/addition.pass.cpp28
-rw-r--r--test/std/input.output/iostreams.base/fpos/fpos.operations/ctor_int.pass.cpp24
-rw-r--r--test/std/input.output/iostreams.base/fpos/fpos.operations/difference.pass.cpp26
-rw-r--r--test/std/input.output/iostreams.base/fpos/fpos.operations/eq_int.pass.cpp26
-rw-r--r--test/std/input.output/iostreams.base/fpos/fpos.operations/offset.pass.cpp25
-rw-r--r--test/std/input.output/iostreams.base/fpos/fpos.operations/streamsize.pass.cpp24
-rw-r--r--test/std/input.output/iostreams.base/fpos/fpos.operations/subtraction.pass.cpp28
-rw-r--r--test/std/input.output/iostreams.base/fpos/nothing_to_do.pass.cpp12
-rw-r--r--test/std/input.output/iostreams.base/ios.base/fmtflags.state/flags.pass.cpp33
-rw-r--r--test/std/input.output/iostreams.base/ios.base/fmtflags.state/flags_fmtflags.pass.cpp36
-rw-r--r--test/std/input.output/iostreams.base/ios.base/fmtflags.state/precision.pass.cpp33
-rw-r--r--test/std/input.output/iostreams.base/ios.base/fmtflags.state/precision_streamsize.pass.cpp36
-rw-r--r--test/std/input.output/iostreams.base/ios.base/fmtflags.state/setf_fmtflags.pass.cpp36
-rw-r--r--test/std/input.output/iostreams.base/ios.base/fmtflags.state/setf_fmtflags_mask.pass.cpp36
-rw-r--r--test/std/input.output/iostreams.base/ios.base/fmtflags.state/unsetf_mask.pass.cpp35
-rw-r--r--test/std/input.output/iostreams.base/ios.base/fmtflags.state/width.pass.cpp33
-rw-r--r--test/std/input.output/iostreams.base/ios.base/fmtflags.state/width_streamsize.pass.cpp36
-rw-r--r--test/std/input.output/iostreams.base/ios.base/ios.base.callback/register_callback.pass.cpp54
-rw-r--r--test/std/input.output/iostreams.base/ios.base/ios.base.cons/dtor.pass.cpp86
-rw-r--r--test/std/input.output/iostreams.base/ios.base/ios.base.locales/getloc.pass.cpp34
-rw-r--r--test/std/input.output/iostreams.base/ios.base/ios.base.locales/imbue.pass.cpp89
-rw-r--r--test/std/input.output/iostreams.base/ios.base/ios.base.storage/iword.pass.cpp42
-rw-r--r--test/std/input.output/iostreams.base/ios.base/ios.base.storage/pword.pass.cpp43
-rw-r--r--test/std/input.output/iostreams.base/ios.base/ios.base.storage/xalloc.pass.cpp26
-rw-r--r--test/std/input.output/iostreams.base/ios.base/ios.members.static/sync_with_stdio.pass.cpp27
-rw-r--r--test/std/input.output/iostreams.base/ios.base/ios.types/ios_Init/tested_elsewhere.pass.cpp12
-rw-r--r--test/std/input.output/iostreams.base/ios.base/ios.types/ios_failure/ctor_char_pointer_error_code.pass.cpp39
-rw-r--r--test/std/input.output/iostreams.base/ios.base/ios.types/ios_failure/ctor_string_error_code.pass.cpp39
-rw-r--r--test/std/input.output/iostreams.base/ios.base/ios.types/ios_fmtflags/fmtflags.pass.cpp81
-rw-r--r--test/std/input.output/iostreams.base/ios.base/ios.types/ios_iostate/iostate.pass.cpp36
-rw-r--r--test/std/input.output/iostreams.base/ios.base/ios.types/ios_openmode/openmode.pass.cpp42
-rw-r--r--test/std/input.output/iostreams.base/ios.base/ios.types/ios_seekdir/seekdir.pass.cpp26
-rw-r--r--test/std/input.output/iostreams.base/ios.base/ios.types/nothing_to_do.pass.cpp12
-rw-r--r--test/std/input.output/iostreams.base/ios.base/nothing_to_do.pass.cpp16
-rw-r--r--test/std/input.output/iostreams.base/ios/basic.ios.cons/ctor_streambuf.pass.cpp48
-rw-r--r--test/std/input.output/iostreams.base/ios/basic.ios.members/copyfmt.pass.cpp190
-rw-r--r--test/std/input.output/iostreams.base/ios/basic.ios.members/fill.pass.cpp23
-rw-r--r--test/std/input.output/iostreams.base/ios/basic.ios.members/fill_char_type.pass.cpp26
-rw-r--r--test/std/input.output/iostreams.base/ios/basic.ios.members/imbue.pass.cpp101
-rw-r--r--test/std/input.output/iostreams.base/ios/basic.ios.members/move.pass.cpp140
-rw-r--r--test/std/input.output/iostreams.base/ios/basic.ios.members/narow.pass.cpp24
-rw-r--r--test/std/input.output/iostreams.base/ios/basic.ios.members/rdbuf.pass.cpp31
-rw-r--r--test/std/input.output/iostreams.base/ios/basic.ios.members/rdbuf_streambuf.pass.cpp34
-rw-r--r--test/std/input.output/iostreams.base/ios/basic.ios.members/set_rdbuf.pass.cpp57
-rw-r--r--test/std/input.output/iostreams.base/ios/basic.ios.members/swap.pass.cpp168
-rw-r--r--test/std/input.output/iostreams.base/ios/basic.ios.members/tie.pass.cpp23
-rw-r--r--test/std/input.output/iostreams.base/ios/basic.ios.members/tie_ostream.pass.cpp26
-rw-r--r--test/std/input.output/iostreams.base/ios/basic.ios.members/widen.pass.cpp23
-rw-r--r--test/std/input.output/iostreams.base/ios/iostate.flags/bad.pass.cpp41
-rw-r--r--test/std/input.output/iostreams.base/ios/iostate.flags/bool.pass.cpp25
-rw-r--r--test/std/input.output/iostreams.base/ios/iostate.flags/clear.pass.cpp65
-rw-r--r--test/std/input.output/iostreams.base/ios/iostate.flags/eof.pass.cpp37
-rw-r--r--test/std/input.output/iostreams.base/ios/iostate.flags/exceptions.pass.cpp33
-rw-r--r--test/std/input.output/iostreams.base/ios/iostate.flags/exceptions_iostate.pass.cpp48
-rw-r--r--test/std/input.output/iostreams.base/ios/iostate.flags/fail.pass.cpp41
-rw-r--r--test/std/input.output/iostreams.base/ios/iostate.flags/good.pass.cpp35
-rw-r--r--test/std/input.output/iostreams.base/ios/iostate.flags/not.pass.cpp25
-rw-r--r--test/std/input.output/iostreams.base/ios/iostate.flags/rdstate.pass.cpp25
-rw-r--r--test/std/input.output/iostreams.base/ios/iostate.flags/setstate.pass.cpp64
-rw-r--r--test/std/input.output/iostreams.base/ios/types.pass.cpp33
-rw-r--r--test/std/input.output/iostreams.base/std.ios.manip/adjustfield.manip/internal.pass.cpp29
-rw-r--r--test/std/input.output/iostreams.base/std.ios.manip/adjustfield.manip/left.pass.cpp29
-rw-r--r--test/std/input.output/iostreams.base/std.ios.manip/adjustfield.manip/right.pass.cpp29
-rw-r--r--test/std/input.output/iostreams.base/std.ios.manip/basefield.manip/dec.pass.cpp29
-rw-r--r--test/std/input.output/iostreams.base/std.ios.manip/basefield.manip/hex.pass.cpp29
-rw-r--r--test/std/input.output/iostreams.base/std.ios.manip/basefield.manip/oct.pass.cpp29
-rw-r--r--test/std/input.output/iostreams.base/std.ios.manip/error.reporting/iostream_category.pass.cpp23
-rw-r--r--test/std/input.output/iostreams.base/std.ios.manip/error.reporting/make_error_code.pass.cpp24
-rw-r--r--test/std/input.output/iostreams.base/std.ios.manip/error.reporting/make_error_condition.pass.cpp24
-rw-r--r--test/std/input.output/iostreams.base/std.ios.manip/floatfield.manip/defaultfloat.pass.cpp30
-rw-r--r--test/std/input.output/iostreams.base/std.ios.manip/floatfield.manip/fixed.pass.cpp29
-rw-r--r--test/std/input.output/iostreams.base/std.ios.manip/floatfield.manip/hexfloat.pass.cpp30
-rw-r--r--test/std/input.output/iostreams.base/std.ios.manip/floatfield.manip/scientific.pass.cpp29
-rw-r--r--test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/boolalpha.pass.cpp29
-rw-r--r--test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noboolalpha.pass.cpp30
-rw-r--r--test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noshowbase.pass.cpp30
-rw-r--r--test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noshowpoint.pass.cpp30
-rw-r--r--test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noshowpos.pass.cpp30
-rw-r--r--test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noskipws.pass.cpp30
-rw-r--r--test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/nounitbuf.pass.cpp30
-rw-r--r--test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/nouppercase.pass.cpp30
-rw-r--r--test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/showbase.pass.cpp29
-rw-r--r--test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/showpoint.pass.cpp29
-rw-r--r--test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/showpos.pass.cpp29
-rw-r--r--test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/skipws.pass.cpp29
-rw-r--r--test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/unitbuf.pass.cpp29
-rw-r--r--test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/uppercase.pass.cpp29
-rw-r--r--test/std/input.output/iostreams.base/std.ios.manip/nothing_to_do.pass.cpp12
-rw-r--r--test/std/input.output/iostreams.base/stream.types/streamoff.pass.cpp21
-rw-r--r--test/std/input.output/iostreams.base/stream.types/streamsize.pass.cpp21
-rw-r--r--test/std/input.output/iostreams.base/version.pass.cpp20
-rw-r--r--test/std/input.output/iostreams.requirements/iostream.limits.imbue/tested_elsewhere.pass.cpp12
-rw-r--r--test/std/input.output/iostreams.requirements/iostreams.limits.pos/nothing_to_do.pass.cpp12
-rw-r--r--test/std/input.output/iostreams.requirements/iostreams.threadsafety/nothing_to_do.pass.cpp12
-rw-r--r--test/std/input.output/iostreams.requirements/nothing_to_do.pass.cpp12
-rw-r--r--test/std/input.output/nothing_to_do.pass.cpp12
-rw-r--r--test/std/input.output/stream.buffers/streambuf.reqts/tested_elsewhere.pass.cpp12
-rw-r--r--test/std/input.output/stream.buffers/streambuf/streambuf.cons/copy.fail.cpp25
-rw-r--r--test/std/input.output/stream.buffers/streambuf/streambuf.cons/copy.pass.cpp84
-rw-r--r--test/std/input.output/stream.buffers/streambuf/streambuf.cons/default.fail.cpp22
-rw-r--r--test/std/input.output/stream.buffers/streambuf/streambuf.cons/default.pass.cpp56
-rw-r--r--test/std/input.output/stream.buffers/streambuf/streambuf.members/nothing_to_do.pass.cpp12
-rw-r--r--test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.buffer/pubseekoff.pass.cpp35
-rw-r--r--test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.buffer/pubseekpos.pass.cpp34
-rw-r--r--test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.buffer/pubsetbuf.pass.cpp33
-rw-r--r--test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.buffer/pubsync.pass.cpp33
-rw-r--r--test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.locales/locales.pass.cpp52
-rw-r--r--test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/in_avail.pass.cpp52
-rw-r--r--test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/sbumpc.pass.cpp56
-rw-r--r--test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/sgetc.pass.cpp56
-rw-r--r--test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/sgetn.pass.cpp41
-rw-r--r--test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/snextc.pass.cpp56
-rw-r--r--test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.pback/sputbackc.pass.cpp56
-rw-r--r--test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.pback/sungetc.pass.cpp56
-rw-r--r--test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.put/sputc.pass.cpp63
-rw-r--r--test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.put/sputn.pass.cpp41
-rw-r--r--test/std/input.output/stream.buffers/streambuf/streambuf.protected/nothing_to_do.pass.cpp12
-rw-r--r--test/std/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.assign/assign.pass.cpp91
-rw-r--r--test/std/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.assign/swap.pass.cpp101
-rw-r--r--test/std/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.get.area/gbump.pass.cpp59
-rw-r--r--test/std/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.get.area/setg.pass.cpp49
-rw-r--r--test/std/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.put.area/pbump.pass.cpp61
-rw-r--r--test/std/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.put.area/setp.pass.cpp49
-rw-r--r--test/std/input.output/stream.buffers/streambuf/streambuf.virtuals/nothing_to_do.pass.cpp12
-rw-r--r--test/std/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.buffer/tested_elsewhere.pass.cpp12
-rw-r--r--test/std/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.get/showmanyc.pass.cpp33
-rw-r--r--test/std/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.get/uflow.pass.cpp33
-rw-r--r--test/std/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.get/underflow.pass.cpp30
-rw-r--r--test/std/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.get/xsgetn.pass.cpp41
-rw-r--r--test/std/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.locales/nothing_to_do.pass.cpp12
-rw-r--r--test/std/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.pback/pbackfail.pass.cpp32
-rw-r--r--test/std/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.put/overflow.pass.cpp30
-rw-r--r--test/std/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.put/xsputn.pass.cpp44
-rw-r--r--test/std/input.output/stream.buffers/streambuf/types.pass.cpp39
-rw-r--r--test/std/input.output/stream.buffers/version.pass.cpp20
-rw-r--r--test/std/input.output/string.streams/istringstream/istringstream.assign/member_swap.pass.cpp56
-rw-r--r--test/std/input.output/string.streams/istringstream/istringstream.assign/move.pass.cpp86
-rw-r--r--test/std/input.output/string.streams/istringstream/istringstream.assign/nonmember_swap.pass.cpp59
-rw-r--r--test/std/input.output/string.streams/istringstream/istringstream.cons/default.pass.cpp46
-rw-r--r--test/std/input.output/string.streams/istringstream/istringstream.cons/move.pass.cpp48
-rw-r--r--test/std/input.output/string.streams/istringstream/istringstream.cons/string.pass.cpp67
-rw-r--r--test/std/input.output/string.streams/istringstream/istringstream.members/str.pass.cpp56
-rw-r--r--test/std/input.output/string.streams/istringstream/types.pass.cpp36
-rw-r--r--test/std/input.output/string.streams/ostringstream/ostringstream.assign/member_swap.pass.cpp48
-rw-r--r--test/std/input.output/string.streams/ostringstream/ostringstream.assign/move.pass.cpp46
-rw-r--r--test/std/input.output/string.streams/ostringstream/ostringstream.assign/nonmember_swap.pass.cpp48
-rw-r--r--test/std/input.output/string.streams/ostringstream/ostringstream.cons/default.pass.cpp46
-rw-r--r--test/std/input.output/string.streams/ostringstream/ostringstream.cons/move.pass.cpp44
-rw-r--r--test/std/input.output/string.streams/ostringstream/ostringstream.cons/string.pass.cpp59
-rw-r--r--test/std/input.output/string.streams/ostringstream/ostringstream.members/str.pass.cpp52
-rw-r--r--test/std/input.output/string.streams/ostringstream/types.pass.cpp36
-rw-r--r--test/std/input.output/string.streams/stringbuf/stringbuf.assign/member_swap.pass.cpp64
-rw-r--r--test/std/input.output/string.streams/stringbuf/stringbuf.assign/move.pass.cpp58
-rw-r--r--test/std/input.output/string.streams/stringbuf/stringbuf.assign/nonmember_swap.pass.cpp66
-rw-r--r--test/std/input.output/string.streams/stringbuf/stringbuf.cons/default.pass.cpp30
-rw-r--r--test/std/input.output/string.streams/stringbuf/stringbuf.cons/move.pass.cpp52
-rw-r--r--test/std/input.output/string.streams/stringbuf/stringbuf.cons/string.pass.cpp47
-rw-r--r--test/std/input.output/string.streams/stringbuf/stringbuf.members/str.pass.cpp34
-rw-r--r--test/std/input.output/string.streams/stringbuf/stringbuf.virtuals/overflow.pass.cpp97
-rw-r--r--test/std/input.output/string.streams/stringbuf/stringbuf.virtuals/pbackfail.pass.cpp92
-rw-r--r--test/std/input.output/string.streams/stringbuf/stringbuf.virtuals/seekoff.pass.cpp143
-rw-r--r--test/std/input.output/string.streams/stringbuf/stringbuf.virtuals/seekpos.pass.cpp77
-rw-r--r--test/std/input.output/string.streams/stringbuf/stringbuf.virtuals/setbuf.pass.cpp32
-rw-r--r--test/std/input.output/string.streams/stringbuf/stringbuf.virtuals/underflow.pass.cpp70
-rw-r--r--test/std/input.output/string.streams/stringbuf/types.pass.cpp36
-rw-r--r--test/std/input.output/string.streams/stringstream.cons/default.pass.cpp46
-rw-r--r--test/std/input.output/string.streams/stringstream.cons/move.pass.cpp52
-rw-r--r--test/std/input.output/string.streams/stringstream.cons/move2.pass.cpp37
-rw-r--r--test/std/input.output/string.streams/stringstream.cons/string.pass.cpp49
-rw-r--r--test/std/input.output/string.streams/stringstream.cons/stringstream.assign/member_swap.pass.cpp56
-rw-r--r--test/std/input.output/string.streams/stringstream.cons/stringstream.assign/move.pass.cpp54
-rw-r--r--test/std/input.output/string.streams/stringstream.cons/stringstream.assign/nonmember_swap.pass.cpp59
-rw-r--r--test/std/input.output/string.streams/stringstream.members/str.pass.cpp62
-rw-r--r--test/std/input.output/string.streams/stringstream/types.pass.cpp36
-rw-r--r--test/std/input.output/string.streams/version.pass.cpp20
-rw-r--r--test/std/iterators/iterator.container/data.pass.cpp74
-rw-r--r--test/std/iterators/iterator.container/empty.pass.cpp77
-rw-r--r--test/std/iterators/iterator.container/size.pass.cpp76
-rw-r--r--test/std/iterators/iterator.primitives/iterator.basic/iterator.pass.cpp82
-rw-r--r--test/std/iterators/iterator.primitives/iterator.operations/advance.pass.cpp45
-rw-r--r--test/std/iterators/iterator.primitives/iterator.operations/distance.pass.cpp40
-rw-r--r--test/std/iterators/iterator.primitives/iterator.operations/next.pass.cpp46
-rw-r--r--test/std/iterators/iterator.primitives/iterator.operations/prev.pass.cpp44
-rw-r--r--test/std/iterators/iterator.primitives/iterator.traits/const_pointer.pass.cpp35
-rw-r--r--test/std/iterators/iterator.primitives/iterator.traits/empty.pass.cpp38
-rw-r--r--test/std/iterators/iterator.primitives/iterator.traits/iterator.pass.cpp43
-rw-r--r--test/std/iterators/iterator.primitives/iterator.traits/pointer.pass.cpp35
-rw-r--r--test/std/iterators/iterator.primitives/nothing_to_do.pass.cpp12
-rw-r--r--test/std/iterators/iterator.primitives/std.iterator.tags/bidirectional_iterator_tag.pass.cpp24
-rw-r--r--test/std/iterators/iterator.primitives/std.iterator.tags/forward_iterator_tag.pass.cpp24
-rw-r--r--test/std/iterators/iterator.primitives/std.iterator.tags/input_iterator_tag.pass.cpp22
-rw-r--r--test/std/iterators/iterator.primitives/std.iterator.tags/output_iterator_tag.pass.cpp22
-rw-r--r--test/std/iterators/iterator.primitives/std.iterator.tags/random_access_iterator_tag.pass.cpp24
-rw-r--r--test/std/iterators/iterator.range/begin-end.pass.cpp146
-rw-r--r--test/std/iterators/iterator.requirements/bidirectional.iterators/nothing_to_do.pass.cpp12
-rw-r--r--test/std/iterators/iterator.requirements/forward.iterators/nothing_to_do.pass.cpp12
-rw-r--r--test/std/iterators/iterator.requirements/input.iterators/nothing_to_do.pass.cpp12
-rw-r--r--test/std/iterators/iterator.requirements/iterator.iterators/nothing_to_do.pass.cpp12
-rw-r--r--test/std/iterators/iterator.requirements/iterator.requirements.general/nothing_to_do.pass.cpp12
-rw-r--r--test/std/iterators/iterator.requirements/nothing_to_do.pass.cpp12
-rw-r--r--test/std/iterators/iterator.requirements/output.iterators/nothing_to_do.pass.cpp12
-rw-r--r--test/std/iterators/iterator.requirements/random.access.iterators/nothing_to_do.pass.cpp12
-rw-r--r--test/std/iterators/iterator.synopsis/nothing_to_do.pass.cpp12
-rw-r--r--test/std/iterators/iterators.general/gcc_workaround.pass.cpp20
-rw-r--r--test/std/iterators/iterators.general/nothing_to_do.pass.cpp12
-rw-r--r--test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.cons/container.fail.cpp24
-rw-r--r--test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.cons/container.pass.cpp31
-rw-r--r--test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op++/post.pass.cpp36
-rw-r--r--test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op++/pre.pass.cpp34
-rw-r--r--test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op=/lv_value.pass.cpp46
-rw-r--r--test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op=/rv_value.pass.cpp42
-rw-r--r--test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op_astrk/test.pass.cpp34
-rw-r--r--test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.inserter/test.pass.cpp35
-rw-r--r--test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/nothing_to_do.pass.cpp12
-rw-r--r--test/std/iterators/predef.iterators/insert.iterators/back.insert.iterator/types.pass.cpp59
-rw-r--r--test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.cons/container.fail.cpp24
-rw-r--r--test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.cons/container.pass.cpp31
-rw-r--r--test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op++/post.pass.cpp36
-rw-r--r--test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op++/pre.pass.cpp34
-rw-r--r--test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op=/lv_value.pass.cpp47
-rw-r--r--test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op=/rv_value.pass.cpp41
-rw-r--r--test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op_astrk/test.pass.cpp34
-rw-r--r--test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.inserter/test.pass.cpp35
-rw-r--r--test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/nothing_to_do.pass.cpp12
-rw-r--r--test/std/iterators/predef.iterators/insert.iterators/front.insert.iterator/types.pass.cpp60
-rw-r--r--test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.cons/test.pass.cpp31
-rw-r--r--test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op++/post.pass.cpp36
-rw-r--r--test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op++/pre.pass.cpp34
-rw-r--r--test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op=/lv_value.pass.cpp85
-rw-r--r--test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op=/rv_value.pass.cpp98
-rw-r--r--test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op_astrk/test.pass.cpp34
-rw-r--r--test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/inserter/test.pass.cpp35
-rw-r--r--test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/nothing_to_do.pass.cpp12
-rw-r--r--test/std/iterators/predef.iterators/insert.iterators/insert.iterator/types.pass.cpp64
-rw-r--r--test/std/iterators/predef.iterators/insert.iterators/nothing_to_do.pass.cpp12
-rw-r--r--test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.nonmember/make_move_iterator.pass.cpp46
-rw-r--r--test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.nonmember/minus.pass.cpp39
-rw-r--r--test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.nonmember/plus.pass.cpp37
-rw-r--r--test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.+/difference_type.pass.cpp36
-rw-r--r--test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.+=/difference_type.pass.cpp37
-rw-r--r--test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.-/difference_type.pass.cpp36
-rw-r--r--test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.-=/difference_type.pass.cpp37
-rw-r--r--test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_eq.pass.cpp46
-rw-r--r--test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_gt.pass.cpp42
-rw-r--r--test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_gte.pass.cpp42
-rw-r--r--test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_lt.pass.cpp42
-rw-r--r--test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_lte.pass.cpp42
-rw-r--r--test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_neq.pass.cpp46
-rw-r--r--test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/convert.fail.cpp38
-rw-r--r--test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/convert.pass.cpp44
-rw-r--r--test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/default.pass.cpp34
-rw-r--r--test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/iter.fail.cpp31
-rw-r--r--test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/iter.pass.cpp37
-rw-r--r--test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.conv/tested_elsewhere.pass.cpp12
-rw-r--r--test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.decr/post.pass.cpp37
-rw-r--r--test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.decr/pre.pass.cpp37
-rw-r--r--test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.incr/post.pass.cpp39
-rw-r--r--test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.incr/pre.pass.cpp39
-rw-r--r--test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.index/difference_type.pass.cpp58
-rw-r--r--test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.ref/op_arrow.pass.cpp31
-rw-r--r--test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.star/op_star.pass.cpp61
-rw-r--r--test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op=/move_iterator.fail.cpp39
-rw-r--r--test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op=/move_iterator.pass.cpp47
-rw-r--r--test/std/iterators/predef.iterators/move.iterators/move.iter.ops/nothing_to_do.pass.cpp12
-rw-r--r--test/std/iterators/predef.iterators/move.iterators/move.iter.requirements/nothing_to_do.pass.cpp12
-rw-r--r--test/std/iterators/predef.iterators/move.iterators/move.iterator/types.pass.cpp56
-rw-r--r--test/std/iterators/predef.iterators/move.iterators/nothing_to_do.pass.cpp12
-rw-r--r--test/std/iterators/predef.iterators/nothing_to_do.pass.cpp12
-rw-r--r--test/std/iterators/predef.iterators/reverse.iterators/nothing_to_do.pass.cpp12
-rw-r--r--test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/nothing_to_do.pass.cpp12
-rw-r--r--test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/default.pass.cpp33
-rw-r--r--test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/iter.fail.cpp31
-rw-r--r--test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/iter.pass.cpp35
-rw-r--r--test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/reverse_iterator.fail.cpp38
-rw-r--r--test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/reverse_iterator.pass.cpp42
-rw-r--r--test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.conv/tested_elsewhere.pass.cpp12
-rw-r--r--test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.make/make_reverse_iterator.pass.cpp42
-rw-r--r--test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op!=/test.pass.cpp42
-rw-r--r--test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op++/post.pass.cpp37
-rw-r--r--test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op++/pre.pass.cpp37
-rw-r--r--test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op+/difference_type.pass.cpp36
-rw-r--r--test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op+=/difference_type.pass.cpp37
-rw-r--r--test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op--/post.pass.cpp37
-rw-r--r--test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op--/pre.pass.cpp37
-rw-r--r--test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op-/difference_type.pass.cpp36
-rw-r--r--test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op-=/difference_type.pass.cpp37
-rw-r--r--test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op.star/op_star.pass.cpp47
-rw-r--r--test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op=/reverse_iterator.fail.cpp39
-rw-r--r--test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op=/reverse_iterator.pass.cpp45
-rw-r--r--test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op==/test.pass.cpp42
-rw-r--r--test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opdiff/test.pass.cpp43
-rw-r--r--test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opgt/test.pass.cpp42
-rw-r--r--test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opgt=/test.pass.cpp42
-rw-r--r--test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opindex/difference_type.pass.cpp38
-rw-r--r--test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.oplt/test.pass.cpp42
-rw-r--r--test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.oplt=/test.pass.cpp42
-rw-r--r--test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opref/op_arrow.pass.cpp89
-rw-r--r--test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opsum/difference_type.pass.cpp37
-rw-r--r--test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.requirements/nothing_to_do.pass.cpp12
-rw-r--r--test/std/iterators/predef.iterators/reverse.iterators/reverse.iterator/types.pass.cpp61
-rw-r--r--test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/copy.pass.cpp36
-rw-r--r--test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/default.fail.cpp30
-rw-r--r--test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/default.pass.cpp30
-rw-r--r--test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/istream.pass.cpp30
-rw-r--r--test/std/iterators/stream.iterators/istream.iterator/istream.iterator.ops/arrow.pass.cpp37
-rw-r--r--test/std/iterators/stream.iterators/istream.iterator/istream.iterator.ops/dereference.pass.cpp34
-rw-r--r--test/std/iterators/stream.iterators/istream.iterator/istream.iterator.ops/equal.pass.cpp52
-rw-r--r--test/std/iterators/stream.iterators/istream.iterator/istream.iterator.ops/post_increment.pass.cpp32
-rw-r--r--test/std/iterators/stream.iterators/istream.iterator/istream.iterator.ops/pre_increment.pass.cpp29
-rw-r--r--test/std/iterators/stream.iterators/istream.iterator/types.pass.cpp56
-rw-r--r--test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator.cons/default.pass.cpp41
-rw-r--r--test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator.cons/istream.pass.cpp42
-rw-r--r--test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator.cons/proxy.pass.cpp36
-rw-r--r--test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator.cons/streambuf.pass.cpp50
-rw-r--r--test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_equal/equal.pass.cpp78
-rw-r--r--test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op!=/not_equal.pass.cpp80
-rw-r--r--test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op++/dereference.pass.cpp40
-rw-r--r--test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op==/equal.pass.cpp80
-rw-r--r--test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op_astrk/arrow.pass.cpp28
-rw-r--r--test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op_astrk/post_increment.pass.cpp38
-rw-r--r--test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op_astrk/pre_increment.pass.cpp39
-rw-r--r--test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_proxy/proxy.pass.cpp44
-rw-r--r--test/std/iterators/stream.iterators/istreambuf.iterator/types.pass.cpp60
-rw-r--r--test/std/iterators/stream.iterators/iterator.range/begin_array.pass.cpp24
-rw-r--r--test/std/iterators/stream.iterators/iterator.range/begin_const.pass.cpp23
-rw-r--r--test/std/iterators/stream.iterators/iterator.range/begin_non_const.pass.cpp25
-rw-r--r--test/std/iterators/stream.iterators/iterator.range/end_array.pass.cpp24
-rw-r--r--test/std/iterators/stream.iterators/iterator.range/end_const.pass.cpp23
-rw-r--r--test/std/iterators/stream.iterators/iterator.range/end_non_const.pass.cpp23
-rw-r--r--test/std/iterators/stream.iterators/nothing_to_do.pass.cpp12
-rw-r--r--test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.cons.des/copy.pass.cpp26
-rw-r--r--test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.cons.des/ostream.pass.cpp25
-rw-r--r--test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.cons.des/ostream_delem.pass.cpp32
-rw-r--r--test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.ops/assign_t.pass.cpp46
-rw-r--r--test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.ops/dereference.pass.cpp26
-rw-r--r--test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.ops/increment.pass.cpp29
-rw-r--r--test/std/iterators/stream.iterators/ostream.iterator/types.pass.cpp40
-rw-r--r--test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.cons/ostream.pass.cpp32
-rw-r--r--test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.cons/streambuf.pass.cpp32
-rw-r--r--test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/assign_c.pass.cpp39
-rw-r--r--test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/deref.pass.cpp34
-rw-r--r--test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/failed.pass.cpp30
-rw-r--r--test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/increment.pass.cpp39
-rw-r--r--test/std/iterators/stream.iterators/ostreambuf.iterator/types.pass.cpp44
-rw-r--r--test/std/iterators/version.pass.cpp20
-rw-r--r--test/std/language.support/cstdint/cstdint.syn/cstdint.pass.cpp292
-rw-r--r--test/std/language.support/cstdint/version.pass.cpp20
-rw-r--r--test/std/language.support/nothing_to_do.pass.cpp12
-rw-r--r--test/std/language.support/support.dynamic/alloc.errors/bad.alloc/bad_alloc.pass.cpp27
-rw-r--r--test/std/language.support/support.dynamic/alloc.errors/new.badlength/bad_array_length.pass.cpp29
-rw-r--r--test/std/language.support/support.dynamic/alloc.errors/new.badlength/bad_array_new_length.pass.cpp27
-rw-r--r--test/std/language.support/support.dynamic/alloc.errors/new.handler/new_handler.pass.cpp19
-rw-r--r--test/std/language.support/support.dynamic/alloc.errors/nothing_to_do.pass.cpp12
-rw-r--r--test/std/language.support/support.dynamic/alloc.errors/set.new.handler/get_new_handler.pass.cpp25
-rw-r--r--test/std/language.support/support.dynamic/alloc.errors/set.new.handler/set_new_handler.pass.cpp22
-rw-r--r--test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array.pass.cpp57
-rw-r--r--test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow.pass.cpp54
-rw-r--r--test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow_replace.pass.cpp51
-rw-r--r--test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_replace.pass.cpp51
-rw-r--r--test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array11.pass.cpp68
-rw-r--r--test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array14.pass.cpp73
-rw-r--r--test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array_calls_unsized_delete_array.pass.cpp56
-rw-r--r--test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array_fsizeddeallocation.sh.cpp80
-rw-r--r--test/std/language.support/support.dynamic/new.delete/new.delete.dataraces/not_testable.pass.cpp12
-rw-r--r--test/std/language.support/support.dynamic/new.delete/new.delete.placement/new.pass.cpp30
-rw-r--r--test/std/language.support/support.dynamic/new.delete/new.delete.placement/new_array.pass.cpp30
-rw-r--r--test/std/language.support/support.dynamic/new.delete/new.delete.single/new.pass.cpp57
-rw-r--r--test/std/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow.pass.cpp54
-rw-r--r--test/std/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow_replace.pass.cpp51
-rw-r--r--test/std/language.support/support.dynamic/new.delete/new.delete.single/new_replace.pass.cpp51
-rw-r--r--test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete11.pass.cpp56
-rw-r--r--test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete14.pass.cpp62
-rw-r--r--test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete_calls_unsized_delete.pass.cpp45
-rw-r--r--test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete_fsizeddeallocation.sh.cpp69
-rw-r--r--test/std/language.support/support.dynamic/new.delete/nothing_to_do.pass.cpp12
-rw-r--r--test/std/language.support/support.dynamic/version.pass.cpp20
-rw-r--r--test/std/language.support/support.exception/bad.exception/bad_exception.pass.cpp27
-rw-r--r--test/std/language.support/support.exception/except.nested/assign.pass.cpp59
-rw-r--r--test/std/language.support/support.exception/except.nested/ctor_copy.pass.cpp57
-rw-r--r--test/std/language.support/support.exception/except.nested/ctor_default.pass.cpp55
-rw-r--r--test/std/language.support/support.exception/except.nested/rethrow_if_nested.pass.cpp89
-rw-r--r--test/std/language.support/support.exception/except.nested/rethrow_nested.pass.cpp70
-rw-r--r--test/std/language.support/support.exception/except.nested/throw_with_nested.pass.cpp119
-rw-r--r--test/std/language.support/support.exception/exception.terminate/nothing_to_do.pass.cpp12
-rw-r--r--test/std/language.support/support.exception/exception.terminate/set.terminate/get_terminate.pass.cpp25
-rw-r--r--test/std/language.support/support.exception/exception.terminate/set.terminate/set_terminate.pass.cpp23
-rw-r--r--test/std/language.support/support.exception/exception.terminate/terminate.handler/terminate_handler.pass.cpp19
-rw-r--r--test/std/language.support/support.exception/exception.terminate/terminate/terminate.pass.cpp26
-rw-r--r--test/std/language.support/support.exception/exception/exception.pass.cpp25
-rw-r--r--test/std/language.support/support.exception/propagation/current_exception.pass.cpp269
-rw-r--r--test/std/language.support/support.exception/propagation/exception_ptr.pass.cpp34
-rw-r--r--test/std/language.support/support.exception/propagation/make_exception_ptr.pass.cpp49
-rw-r--r--test/std/language.support/support.exception/propagation/rethrow_exception.pass.cpp57
-rw-r--r--test/std/language.support/support.exception/uncaught/uncaught_exception.pass.cpp45
-rw-r--r--test/std/language.support/support.exception/uncaught/uncaught_exceptions.pass.cpp45
-rw-r--r--test/std/language.support/support.exception/version.pass.cpp20
-rw-r--r--test/std/language.support/support.general/nothing_to_do.pass.cpp12
-rw-r--r--test/std/language.support/support.initlist/support.initlist.access/access.pass.cpp62
-rw-r--r--test/std/language.support/support.initlist/support.initlist.cons/default.pass.cpp29
-rw-r--r--test/std/language.support/support.initlist/support.initlist.range/begin_end.pass.cpp59
-rw-r--r--test/std/language.support/support.initlist/types.pass.cpp37
-rw-r--r--test/std/language.support/support.initlist/version.pass.cpp20
-rw-r--r--test/std/language.support/support.limits/c.limits/cfloat.pass.cpp140
-rw-r--r--test/std/language.support/support.limits/c.limits/climits.pass.cpp92
-rw-r--r--test/std/language.support/support.limits/c.limits/version_cfloat.pass.cpp20
-rw-r--r--test/std/language.support/support.limits/c.limits/version_climits.pass.cpp20
-rw-r--r--test/std/language.support/support.limits/limits/denorm.style/check_values.pass.cpp38
-rw-r--r--test/std/language.support/support.limits/limits/is_specialized.pass.cpp71
-rw-r--r--test/std/language.support/support.limits/limits/numeric.limits.members/const_data_members.pass.cpp199
-rw-r--r--test/std/language.support/support.limits/limits/numeric.limits.members/denorm_min.pass.cpp53
-rw-r--r--test/std/language.support/support.limits/limits/numeric.limits.members/digits.pass.cpp53
-rw-r--r--test/std/language.support/support.limits/limits/numeric.limits.members/digits10.pass.cpp57
-rw-r--r--test/std/language.support/support.limits/limits/numeric.limits.members/epsilon.pass.cpp54
-rw-r--r--test/std/language.support/support.limits/limits/numeric.limits.members/has_denorm.pass.cpp52
-rw-r--r--test/std/language.support/support.limits/limits/numeric.limits.members/has_denorm_loss.pass.cpp52
-rw-r--r--test/std/language.support/support.limits/limits/numeric.limits.members/has_infinity.pass.cpp52
-rw-r--r--test/std/language.support/support.limits/limits/numeric.limits.members/has_quiet_NaN.pass.cpp52
-rw-r--r--test/std/language.support/support.limits/limits/numeric.limits.members/has_signaling_NaN.pass.cpp52
-rw-r--r--test/std/language.support/support.limits/limits/numeric.limits.members/infinity.pass.cpp58
-rw-r--r--test/std/language.support/support.limits/limits/numeric.limits.members/is_bounded.pass.cpp52
-rw-r--r--test/std/language.support/support.limits/limits/numeric.limits.members/is_exact.pass.cpp52
-rw-r--r--test/std/language.support/support.limits/limits/numeric.limits.members/is_iec559.pass.cpp56
-rw-r--r--test/std/language.support/support.limits/limits/numeric.limits.members/is_integer.pass.cpp52
-rw-r--r--test/std/language.support/support.limits/limits/numeric.limits.members/is_modulo.pass.cpp52
-rw-r--r--test/std/language.support/support.limits/limits/numeric.limits.members/is_signed.pass.cpp52
-rw-r--r--test/std/language.support/support.limits/limits/numeric.limits.members/lowest.pass.cpp60
-rw-r--r--test/std/language.support/support.limits/limits/numeric.limits.members/max.pass.cpp60
-rw-r--r--test/std/language.support/support.limits/limits/numeric.limits.members/max_digits10.pass.cpp53
-rw-r--r--test/std/language.support/support.limits/limits/numeric.limits.members/max_exponent.pass.cpp53
-rw-r--r--test/std/language.support/support.limits/limits/numeric.limits.members/max_exponent10.pass.cpp53
-rw-r--r--test/std/language.support/support.limits/limits/numeric.limits.members/min.pass.cpp60
-rw-r--r--test/std/language.support/support.limits/limits/numeric.limits.members/min_exponent.pass.cpp53
-rw-r--r--test/std/language.support/support.limits/limits/numeric.limits.members/min_exponent10.pass.cpp53
-rw-r--r--test/std/language.support/support.limits/limits/numeric.limits.members/quiet_NaN.pass.cpp73
-rw-r--r--test/std/language.support/support.limits/limits/numeric.limits.members/radix.pass.cpp53
-rw-r--r--test/std/language.support/support.limits/limits/numeric.limits.members/round_error.pass.cpp54
-rw-r--r--test/std/language.support/support.limits/limits/numeric.limits.members/round_style.pass.cpp52
-rw-r--r--test/std/language.support/support.limits/limits/numeric.limits.members/signaling_NaN.pass.cpp73
-rw-r--r--test/std/language.support/support.limits/limits/numeric.limits.members/tinyness_before.pass.cpp52
-rw-r--r--test/std/language.support/support.limits/limits/numeric.limits.members/traps.pass.cpp58
-rw-r--r--test/std/language.support/support.limits/limits/numeric.limits/default.pass.cpp83
-rw-r--r--test/std/language.support/support.limits/limits/numeric.special/nothing_to_do.pass.cpp12
-rw-r--r--test/std/language.support/support.limits/limits/round.style/check_values.pass.cpp34
-rw-r--r--test/std/language.support/support.limits/limits/version.pass.cpp20
-rw-r--r--test/std/language.support/support.limits/nothing_to_do.pass.cpp12
-rw-r--r--test/std/language.support/support.rtti/bad.cast/bad_cast.pass.cpp27
-rw-r--r--test/std/language.support/support.rtti/bad.typeid/bad_typeid.pass.cpp27
-rw-r--r--test/std/language.support/support.rtti/type.info/type_info.pass.cpp26
-rw-r--r--test/std/language.support/support.rtti/type.info/type_info_hash.pass.cpp23
-rw-r--r--test/std/language.support/support.rtti/version.pass.cpp20
-rw-r--r--test/std/language.support/support.runtime/csetjmp.pass.cpp24
-rw-r--r--test/std/language.support/support.runtime/csignal.pass.cpp57
-rw-r--r--test/std/language.support/support.runtime/cstdarg.pass.cpp35
-rw-r--r--test/std/language.support/support.runtime/cstdbool.pass.cpp32
-rw-r--r--test/std/language.support/support.runtime/cstdlib.pass.cpp88
-rw-r--r--test/std/language.support/support.runtime/ctime.pass.cpp42
-rw-r--r--test/std/language.support/support.runtime/version_csetjmp.pass.cpp20
-rw-r--r--test/std/language.support/support.runtime/version_csignal.pass.cpp20
-rw-r--r--test/std/language.support/support.runtime/version_cstdarg.pass.cpp20
-rw-r--r--test/std/language.support/support.runtime/version_cstdbool.pass.cpp20
-rw-r--r--test/std/language.support/support.runtime/version_cstdlib.pass.cpp20
-rw-r--r--test/std/language.support/support.runtime/version_ctime.pass.cpp20
-rw-r--r--test/std/language.support/support.start.term/quick_exit.pass.cpp23
-rw-r--r--test/std/language.support/support.start.term/quick_exit_check1.fail.cpp25
-rw-r--r--test/std/language.support/support.start.term/quick_exit_check2.fail.cpp25
-rw-r--r--test/std/language.support/support.types/max_align_t.pass.cpp34
-rw-r--r--test/std/language.support/support.types/null.pass.cpp18
-rw-r--r--test/std/language.support/support.types/nullptr_t.pass.cpp79
-rw-r--r--test/std/language.support/support.types/nullptr_t_integral_cast.fail.cpp17
-rw-r--r--test/std/language.support/support.types/nullptr_t_integral_cast.pass.cpp24
-rw-r--r--test/std/language.support/support.types/offsetof.pass.cpp26
-rw-r--r--test/std/language.support/support.types/ptrdiff_t.pass.cpp27
-rw-r--r--test/std/language.support/support.types/size_t.pass.cpp27
-rw-r--r--test/std/language.support/support.types/version.pass.cpp20
-rw-r--r--test/std/localization/c.locales/clocale.pass.cpp54
-rw-r--r--test/std/localization/c.locales/version.pass.cpp20
-rw-r--r--test/std/localization/locale.categories/__scan_keyword.pass.cpp118
-rw-r--r--test/std/localization/locale.categories/category.collate/locale.collate.byname/compare.pass.cpp87
-rw-r--r--test/std/localization/locale.categories/category.collate/locale.collate.byname/hash.pass.cpp41
-rw-r--r--test/std/localization/locale.categories/category.collate/locale.collate.byname/transform.pass.cpp69
-rw-r--r--test/std/localization/locale.categories/category.collate/locale.collate.byname/types.pass.cpp45
-rw-r--r--test/std/localization/locale.categories/category.collate/locale.collate/ctor.pass.cpp67
-rw-r--r--test/std/localization/locale.categories/category.collate/locale.collate/locale.collate.members/compare.pass.cpp49
-rw-r--r--test/std/localization/locale.categories/category.collate/locale.collate/locale.collate.members/hash.pass.cpp39
-rw-r--r--test/std/localization/locale.categories/category.collate/locale.collate/locale.collate.members/transform.pass.cpp33
-rw-r--r--test/std/localization/locale.categories/category.collate/locale.collate/locale.collate.virtuals/tested_elsewhere.pass.cpp12
-rw-r--r--test/std/localization/locale.categories/category.collate/locale.collate/types.pass.cpp49
-rw-r--r--test/std/localization/locale.categories/category.collate/nothing_to_do.pass.cpp12
-rw-r--r--test/std/localization/locale.categories/category.ctype/ctype_base.pass.cpp78
-rw-r--r--test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.dtor/dtor.pass.cpp40
-rw-r--r--test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/ctor.pass.cpp50
-rw-r--r--test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/is_1.pass.cpp59
-rw-r--r--test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/is_many.pass.cpp118
-rw-r--r--test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/narrow_1.pass.cpp33
-rw-r--r--test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/narrow_many.pass.cpp38
-rw-r--r--test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/scan_is.pass.cpp44
-rw-r--r--test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/scan_not.pass.cpp44
-rw-r--r--test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/table.pass.cpp33
-rw-r--r--test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/tolower_1.pass.cpp33
-rw-r--r--test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/tolower_many.pass.cpp36
-rw-r--r--test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/toupper_1.pass.cpp33
-rw-r--r--test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/toupper_many.pass.cpp36
-rw-r--r--test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/widen_1.pass.cpp33
-rw-r--r--test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/widen_many.pass.cpp38
-rw-r--r--test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.statics/classic_table.pass.cpp59
-rw-r--r--test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.virtuals/tested_elsewhere.pass.cpp12
-rw-r--r--test/std/localization/locale.categories/category.ctype/facet.ctype.special/types.pass.cpp38
-rw-r--r--test/std/localization/locale.categories/category.ctype/locale.codecvt.byname/ctor_char.pass.cpp70
-rw-r--r--test/std/localization/locale.categories/category.ctype/locale.codecvt.byname/ctor_char16_t.pass.cpp70
-rw-r--r--test/std/localization/locale.categories/category.ctype/locale.codecvt.byname/ctor_char32_t.pass.cpp70
-rw-r--r--test/std/localization/locale.categories/category.ctype/locale.codecvt.byname/ctor_wchar_t.pass.cpp72
-rw-r--r--test/std/localization/locale.categories/category.ctype/locale.codecvt/codecvt_base.pass.cpp27
-rw-r--r--test/std/localization/locale.categories/category.ctype/locale.codecvt/ctor_char.pass.cpp52
-rw-r--r--test/std/localization/locale.categories/category.ctype/locale.codecvt/ctor_char16_t.pass.cpp58
-rw-r--r--test/std/localization/locale.categories/category.ctype/locale.codecvt/ctor_char32_t.pass.cpp58
-rw-r--r--test/std/localization/locale.categories/category.ctype/locale.codecvt/ctor_wchar_t.pass.cpp52
-rw-r--r--test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_always_noconv.pass.cpp26
-rw-r--r--test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_encoding.pass.cpp26
-rw-r--r--test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_in.pass.cpp40
-rw-r--r--test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_length.pass.cpp32
-rw-r--r--test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_max_length.pass.cpp26
-rw-r--r--test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_out.pass.cpp45
-rw-r--r--test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_unshift.pass.cpp33
-rw-r--r--test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_always_noconv.pass.cpp26
-rw-r--r--test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_encoding.pass.cpp26
-rw-r--r--test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_in.pass.cpp40
-rw-r--r--test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_length.pass.cpp32
-rw-r--r--test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_max_length.pass.cpp26
-rw-r--r--test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_out.pass.cpp45
-rw-r--r--test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_unshift.pass.cpp33
-rw-r--r--test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_always_noconv.pass.cpp26
-rw-r--r--test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_encoding.pass.cpp26
-rw-r--r--test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_in.pass.cpp38
-rw-r--r--test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_length.pass.cpp32
-rw-r--r--test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_max_length.pass.cpp26
-rw-r--r--test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_out.pass.cpp38
-rw-r--r--test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_unshift.pass.cpp33
-rw-r--r--test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/utf_sanity_check.pass.cpp127
-rw-r--r--test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_always_noconv.pass.cpp26
-rw-r--r--test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_encoding.pass.cpp26
-rw-r--r--test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_in.pass.cpp42
-rw-r--r--test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_length.pass.cpp32
-rw-r--r--test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_max_length.pass.cpp26
-rw-r--r--test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_out.pass.cpp69
-rw-r--r--test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_unshift.pass.cpp35
-rw-r--r--test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.virtuals/tested_elsewhere.pass.cpp12
-rw-r--r--test/std/localization/locale.categories/category.ctype/locale.codecvt/types_char.pass.cpp40
-rw-r--r--test/std/localization/locale.categories/category.ctype/locale.codecvt/types_char16_t.pass.cpp42
-rw-r--r--test/std/localization/locale.categories/category.ctype/locale.codecvt/types_char32_t.pass.cpp42
-rw-r--r--test/std/localization/locale.categories/category.ctype/locale.codecvt/types_wchar_t.pass.cpp40
-rw-r--r--test/std/localization/locale.categories/category.ctype/locale.ctype.byname/is_1.pass.cpp112
-rw-r--r--test/std/localization/locale.categories/category.ctype/locale.ctype.byname/is_many.pass.cpp247
-rw-r--r--test/std/localization/locale.categories/category.ctype/locale.ctype.byname/mask.pass.cpp53
-rw-r--r--test/std/localization/locale.categories/category.ctype/locale.ctype.byname/narrow_1.pass.cpp56
-rw-r--r--test/std/localization/locale.categories/category.ctype/locale.ctype.byname/narrow_many.pass.cpp64
-rw-r--r--test/std/localization/locale.categories/category.ctype/locale.ctype.byname/scan_is.pass.cpp71
-rw-r--r--test/std/localization/locale.categories/category.ctype/locale.ctype.byname/scan_not.pass.cpp71
-rw-r--r--test/std/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_1.pass.cpp91
-rw-r--r--test/std/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_many.pass.cpp96
-rw-r--r--test/std/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_1.pass.cpp91
-rw-r--r--test/std/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_many.pass.cpp96
-rw-r--r--test/std/localization/locale.categories/category.ctype/locale.ctype.byname/types.pass.cpp71
-rw-r--r--test/std/localization/locale.categories/category.ctype/locale.ctype.byname/widen_1.pass.cpp58
-rw-r--r--test/std/localization/locale.categories/category.ctype/locale.ctype.byname/widen_many.pass.cpp65
-rw-r--r--test/std/localization/locale.categories/category.ctype/locale.ctype/ctor.pass.cpp51
-rw-r--r--test/std/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/is_1.pass.cpp59
-rw-r--r--test/std/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/is_many.pass.cpp118
-rw-r--r--test/std/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/narrow_1.pass.cpp33
-rw-r--r--test/std/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/narrow_many.pass.cpp38
-rw-r--r--test/std/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/scan_is.pass.cpp44
-rw-r--r--test/std/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/scan_not.pass.cpp44
-rw-r--r--test/std/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/tolower_1.pass.cpp33
-rw-r--r--test/std/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/tolower_many.pass.cpp36
-rw-r--r--test/std/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/toupper_1.pass.cpp33
-rw-r--r--test/std/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/toupper_many.pass.cpp36
-rw-r--r--test/std/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/widen_1.pass.cpp33
-rw-r--r--test/std/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/widen_many.pass.cpp38
-rw-r--r--test/std/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.virtuals/tested_elsewhere.pass.cpp12
-rw-r--r--test/std/localization/locale.categories/category.ctype/locale.ctype/types.pass.cpp38
-rw-r--r--test/std/localization/locale.categories/category.messages/locale.messages.byname/nothing_to_do.pass.cpp12
-rw-r--r--test/std/localization/locale.categories/category.messages/locale.messages/ctor.pass.cpp52
-rw-r--r--test/std/localization/locale.categories/category.messages/locale.messages/locale.messages.members/not_testable.pass.cpp34
-rw-r--r--test/std/localization/locale.categories/category.messages/locale.messages/locale.messages.virtuals/tested_elsewhere.pass.cpp12
-rw-r--r--test/std/localization/locale.categories/category.messages/locale.messages/messages_base.pass.cpp24
-rw-r--r--test/std/localization/locale.categories/category.messages/locale.messages/types.pass.cpp34
-rw-r--r--test/std/localization/locale.categories/category.messages/nothing_to_do.pass.cpp12
-rw-r--r--test/std/localization/locale.categories/category.monetary/locale.money.get/ctor.pass.cpp52
-rw-r--r--test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_en_US.pass.cpp723
-rw-r--r--test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_fr_FR.pass.cpp726
-rw-r--r--test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_ru_RU.pass.cpp735
-rw-r--r--test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_zh_CN.pass.cpp726
-rw-r--r--test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_string_en_US.pass.cpp731
-rw-r--r--test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.virtuals/tested_elsewhere.pass.cpp12
-rw-r--r--test/std/localization/locale.categories/category.monetary/locale.money.get/types.pass.cpp34
-rw-r--r--test/std/localization/locale.categories/category.monetary/locale.money.put/ctor.pass.cpp52
-rw-r--r--test/std/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_en_US.pass.cpp494
-rw-r--r--test/std/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_fr_FR.pass.cpp495
-rw-r--r--test/std/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_ru_RU.pass.cpp501
-rw-r--r--test/std/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_zh_CN.pass.cpp496
-rw-r--r--test/std/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_string_en_US.pass.cpp494
-rw-r--r--test/std/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.virtuals/tested_elsewhere.pass.cpp12
-rw-r--r--test/std/localization/locale.categories/category.monetary/locale.money.put/types.pass.cpp34
-rw-r--r--test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/curr_symbol.pass.cpp147
-rw-r--r--test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/decimal_point.pass.cpp148
-rw-r--r--test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/frac_digits.pass.cpp145
-rw-r--r--test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/grouping.pass.cpp150
-rw-r--r--test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/neg_format.pass.cpp227
-rw-r--r--test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/negative_sign.pass.cpp145
-rw-r--r--test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/pos_format.pass.cpp227
-rw-r--r--test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/positive_sign.pass.cpp145
-rw-r--r--test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/thousands_sep.pass.cpp151
-rw-r--r--test/std/localization/locale.categories/category.monetary/locale.moneypunct/ctor.pass.cpp52
-rw-r--r--test/std/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/curr_symbol.pass.cpp75
-rw-r--r--test/std/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/decimal_point.pass.cpp75
-rw-r--r--test/std/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/frac_digits.pass.cpp75
-rw-r--r--test/std/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/grouping.pass.cpp75
-rw-r--r--test/std/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/neg_format.pass.cpp88
-rw-r--r--test/std/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/negative_sign.pass.cpp76
-rw-r--r--test/std/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/pos_format.pass.cpp88
-rw-r--r--test/std/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/positive_sign.pass.cpp75
-rw-r--r--test/std/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/thousands_sep.pass.cpp75
-rw-r--r--test/std/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.virtuals/tested_elsewhere.pass.cpp12
-rw-r--r--test/std/localization/locale.categories/category.monetary/locale.moneypunct/money_base.pass.cpp33
-rw-r--r--test/std/localization/locale.categories/category.monetary/locale.moneypunct/types.pass.cpp48
-rw-r--r--test/std/localization/locale.categories/category.monetary/nothing_to_do.pass.cpp12
-rw-r--r--test/std/localization/locale.categories/category.numeric/locale.nm.put/ctor.pass.cpp52
-rw-r--r--test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_bool.pass.cpp100
-rw-r--r--test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_double.pass.cpp17887
-rw-r--r--test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long.pass.cpp371
-rw-r--r--test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long_double.pass.cpp26248
-rw-r--r--test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long_long.pass.cpp344
-rw-r--r--test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_pointer.pass.cpp43
-rw-r--r--test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_unsigned_long.pass.cpp374
-rw-r--r--test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_unsigned_long_long.pass.cpp344
-rw-r--r--test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.virtuals/tested_elsewhere.pass.cpp12
-rw-r--r--test/std/localization/locale.categories/category.numeric/locale.nm.put/types.pass.cpp32
-rw-r--r--test/std/localization/locale.categories/category.numeric/locale.num.get/ctor.pass.cpp52
-rw-r--r--test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_bool.pass.cpp230
-rw-r--r--test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_double.pass.cpp256
-rw-r--r--test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_float.pass.cpp171
-rw-r--r--test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_long.pass.cpp519
-rw-r--r--test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_long_double.pass.cpp231
-rw-r--r--test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_long_long.pass.cpp105
-rw-r--r--test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_pointer.pass.cpp61
-rw-r--r--test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_unsigned_int.pass.cpp83
-rw-r--r--test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_unsigned_long.pass.cpp83
-rw-r--r--test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_unsigned_long_long.pass.cpp83
-rw-r--r--test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_unsigned_short.pass.cpp83
-rw-r--r--test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/test_min_max.pass.cpp62
-rw-r--r--test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.virtuals/tested_elsewhere.pass.cpp12
-rw-r--r--test/std/localization/locale.categories/category.numeric/locale.num.get/types.pass.cpp32
-rw-r--r--test/std/localization/locale.categories/category.numeric/nothing_to_do.pass.cpp12
-rw-r--r--test/std/localization/locale.categories/category.time/locale.time.get.byname/date_order.pass.cpp55
-rw-r--r--test/std/localization/locale.categories/category.time/locale.time.get.byname/date_order_wide.pass.cpp55
-rw-r--r--test/std/localization/locale.categories/category.time/locale.time.get.byname/get_date.pass.cpp99
-rw-r--r--test/std/localization/locale.categories/category.time/locale.time.get.byname/get_date_wide.pass.cpp98
-rw-r--r--test/std/localization/locale.categories/category.time/locale.time.get.byname/get_monthname.pass.cpp92
-rw-r--r--test/std/localization/locale.categories/category.time/locale.time.get.byname/get_monthname_wide.pass.cpp101
-rw-r--r--test/std/localization/locale.categories/category.time/locale.time.get.byname/get_one.pass.cpp168
-rw-r--r--test/std/localization/locale.categories/category.time/locale.time.get.byname/get_one_wide.pass.cpp170
-rw-r--r--test/std/localization/locale.categories/category.time/locale.time.get.byname/get_time.pass.cpp94
-rw-r--r--test/std/localization/locale.categories/category.time/locale.time.get.byname/get_time_wide.pass.cpp94
-rw-r--r--test/std/localization/locale.categories/category.time/locale.time.get.byname/get_weekday.pass.cpp91
-rw-r--r--test/std/localization/locale.categories/category.time/locale.time.get.byname/get_weekday_wide.pass.cpp89
-rw-r--r--test/std/localization/locale.categories/category.time/locale.time.get.byname/get_year.pass.cpp85
-rw-r--r--test/std/localization/locale.categories/category.time/locale.time.get.byname/get_year_wide.pass.cpp85
-rw-r--r--test/std/localization/locale.categories/category.time/locale.time.get/ctor.pass.cpp52
-rw-r--r--test/std/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/date_order.pass.cpp34
-rw-r--r--test/std/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_date.pass.cpp51
-rw-r--r--test/std/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_date_wide.pass.cpp51
-rw-r--r--test/std/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_many.pass.cpp68
-rw-r--r--test/std/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_monthname.pass.cpp265
-rw-r--r--test/std/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_monthname_wide.pass.cpp265
-rw-r--r--test/std/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_one.pass.cpp305
-rw-r--r--test/std/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_time.pass.cpp117
-rw-r--r--test/std/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_time_wide.pass.cpp117
-rw-r--r--test/std/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_weekday.pass.cpp220
-rw-r--r--test/std/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_weekday_wide.pass.cpp220
-rw-r--r--test/std/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_year.pass.cpp138
-rw-r--r--test/std/localization/locale.categories/category.time/locale.time.get/locale.time.get.virtuals/tested_elsewhere.pass.cpp12
-rw-r--r--test/std/localization/locale.categories/category.time/locale.time.get/time_base.pass.cpp29
-rw-r--r--test/std/localization/locale.categories/category.time/locale.time.get/types.pass.cpp41
-rw-r--r--test/std/localization/locale.categories/category.time/locale.time.put.byname/put1.pass.cpp78
-rw-r--r--test/std/localization/locale.categories/category.time/locale.time.put/ctor.pass.cpp52
-rw-r--r--test/std/localization/locale.categories/category.time/locale.time.put/locale.time.put.members/put1.pass.cpp61
-rw-r--r--test/std/localization/locale.categories/category.time/locale.time.put/locale.time.put.members/put2.pass.cpp332
-rw-r--r--test/std/localization/locale.categories/category.time/locale.time.put/locale.time.put.virtuals/tested_elsewhere.pass.cpp12
-rw-r--r--test/std/localization/locale.categories/category.time/locale.time.put/types.pass.cpp32
-rw-r--r--test/std/localization/locale.categories/category.time/nothing_to_do.pass.cpp12
-rw-r--r--test/std/localization/locale.categories/facet.numpunct/locale.numpunct.byname/decimal_point.pass.cpp65
-rw-r--r--test/std/localization/locale.categories/facet.numpunct/locale.numpunct.byname/grouping.pass.cpp68
-rw-r--r--test/std/localization/locale.categories/facet.numpunct/locale.numpunct.byname/thousands_sep.pass.cpp68
-rw-r--r--test/std/localization/locale.categories/facet.numpunct/locale.numpunct/ctor.pass.cpp66
-rw-r--r--test/std/localization/locale.categories/facet.numpunct/locale.numpunct/facet.numpunct.members/decimal_point.pass.cpp32
-rw-r--r--test/std/localization/locale.categories/facet.numpunct/locale.numpunct/facet.numpunct.members/falsename.pass.cpp32
-rw-r--r--test/std/localization/locale.categories/facet.numpunct/locale.numpunct/facet.numpunct.members/grouping.pass.cpp32
-rw-r--r--test/std/localization/locale.categories/facet.numpunct/locale.numpunct/facet.numpunct.members/thousands_sep.pass.cpp32
-rw-r--r--test/std/localization/locale.categories/facet.numpunct/locale.numpunct/facet.numpunct.members/truename.pass.cpp32
-rw-r--r--test/std/localization/locale.categories/facet.numpunct/locale.numpunct/facet.numpunct.virtuals/tested_elsewhere.pass.cpp12
-rw-r--r--test/std/localization/locale.categories/facet.numpunct/locale.numpunct/types.pass.cpp48
-rw-r--r--test/std/localization/locale.categories/facet.numpunct/nothing_to_do.pass.cpp12
-rw-r--r--test/std/localization/locale.categories/facets.examples/nothing_to_do.pass.cpp12
-rw-r--r--test/std/localization/locale.stdcvt/codecvt_mode.pass.cpp29
-rw-r--r--test/std/localization/locale.stdcvt/codecvt_utf16.pass.cpp42
-rw-r--r--test/std/localization/locale.stdcvt/codecvt_utf16_always_noconv.pass.cpp45
-rw-r--r--test/std/localization/locale.stdcvt/codecvt_utf16_encoding.pass.cpp45
-rw-r--r--test/std/localization/locale.stdcvt/codecvt_utf16_in.pass.cpp739
-rw-r--r--test/std/localization/locale.stdcvt/codecvt_utf16_length.pass.cpp449
-rw-r--r--test/std/localization/locale.stdcvt/codecvt_utf16_max_length.pass.cpp63
-rw-r--r--test/std/localization/locale.stdcvt/codecvt_utf16_out.pass.cpp331
-rw-r--r--test/std/localization/locale.stdcvt/codecvt_utf16_unshift.pass.cpp56
-rw-r--r--test/std/localization/locale.stdcvt/codecvt_utf8.pass.cpp42
-rw-r--r--test/std/localization/locale.stdcvt/codecvt_utf8_always_noconv.pass.cpp45
-rw-r--r--test/std/localization/locale.stdcvt/codecvt_utf8_encoding.pass.cpp45
-rw-r--r--test/std/localization/locale.stdcvt/codecvt_utf8_in.pass.cpp360
-rw-r--r--test/std/localization/locale.stdcvt/codecvt_utf8_length.pass.cpp244
-rw-r--r--test/std/localization/locale.stdcvt/codecvt_utf8_max_length.pass.cpp63
-rw-r--r--test/std/localization/locale.stdcvt/codecvt_utf8_out.pass.cpp456
-rw-r--r--test/std/localization/locale.stdcvt/codecvt_utf8_unshift.pass.cpp56
-rw-r--r--test/std/localization/locale.stdcvt/codecvt_utf8_utf16_always_noconv.pass.cpp45
-rw-r--r--test/std/localization/locale.stdcvt/codecvt_utf8_utf16_encoding.pass.cpp45
-rw-r--r--test/std/localization/locale.stdcvt/codecvt_utf8_utf16_in.pass.cpp372
-rw-r--r--test/std/localization/locale.stdcvt/codecvt_utf8_utf16_length.pass.cpp235
-rw-r--r--test/std/localization/locale.stdcvt/codecvt_utf8_utf16_max_length.pass.cpp63
-rw-r--r--test/std/localization/locale.stdcvt/codecvt_utf8_utf16_out.pass.cpp415
-rw-r--r--test/std/localization/locale.stdcvt/codecvt_utf8_utf16_unshift.pass.cpp56
-rw-r--r--test/std/localization/locale.stdcvt/version.pass.cpp20
-rw-r--r--test/std/localization/locale.syn/nothing_to_do.pass.cpp12
-rw-r--r--test/std/localization/locales/locale.convenience/classification/isalnum.pass.cpp31
-rw-r--r--test/std/localization/locales/locale.convenience/classification/isalpha.pass.cpp31
-rw-r--r--test/std/localization/locales/locale.convenience/classification/iscntrl.pass.cpp31
-rw-r--r--test/std/localization/locales/locale.convenience/classification/isdigit.pass.cpp31
-rw-r--r--test/std/localization/locales/locale.convenience/classification/isgraph.pass.cpp31
-rw-r--r--test/std/localization/locales/locale.convenience/classification/islower.pass.cpp31
-rw-r--r--test/std/localization/locales/locale.convenience/classification/isprint.pass.cpp31
-rw-r--r--test/std/localization/locales/locale.convenience/classification/ispunct.pass.cpp31
-rw-r--r--test/std/localization/locales/locale.convenience/classification/isspace.pass.cpp31
-rw-r--r--test/std/localization/locales/locale.convenience/classification/isupper.pass.cpp31
-rw-r--r--test/std/localization/locales/locale.convenience/classification/isxdigit.pass.cpp31
-rw-r--r--test/std/localization/locales/locale.convenience/conversions/conversions.buffer/ctor.pass.cpp58
-rw-r--r--test/std/localization/locales/locale.convenience/conversions/conversions.buffer/lit.local.cfg2
-rw-r--r--test/std/localization/locales/locale.convenience/conversions/conversions.buffer/overflow.pass.cpp100
-rw-r--r--test/std/localization/locales/locale.convenience/conversions/conversions.buffer/pbackfail.pass.cpp59
-rw-r--r--test/std/localization/locales/locale.convenience/conversions/conversions.buffer/rdbuf.pass.cpp31
-rw-r--r--test/std/localization/locales/locale.convenience/conversions/conversions.buffer/seekoff.pass.cpp58
-rw-r--r--test/std/localization/locales/locale.convenience/conversions/conversions.buffer/state.pass.cpp28
-rw-r--r--test/std/localization/locales/locale.convenience/conversions/conversions.buffer/test.pass.cpp36
-rw-r--r--test/std/localization/locales/locale.convenience/conversions/conversions.buffer/underflow.dat1
-rw-r--r--test/std/localization/locales/locale.convenience/conversions/conversions.buffer/underflow.pass.cpp84
-rw-r--r--test/std/localization/locales/locale.convenience/conversions/conversions.buffer/underflow_utf8.dat1
-rw-r--r--test/std/localization/locales/locale.convenience/conversions/conversions.character/tolower.pass.cpp31
-rw-r--r--test/std/localization/locales/locale.convenience/conversions/conversions.character/toupper.pass.cpp31
-rw-r--r--test/std/localization/locales/locale.convenience/conversions/conversions.string/converted.pass.cpp32
-rw-r--r--test/std/localization/locales/locale.convenience/conversions/conversions.string/ctor_codecvt.pass.cpp38
-rw-r--r--test/std/localization/locales/locale.convenience/conversions/conversions.string/ctor_codecvt_state.pass.cpp28
-rw-r--r--test/std/localization/locales/locale.convenience/conversions/conversions.string/ctor_err_string.pass.cpp68
-rw-r--r--test/std/localization/locales/locale.convenience/conversions/conversions.string/from_bytes.pass.cpp39
-rw-r--r--test/std/localization/locales/locale.convenience/conversions/conversions.string/state.pass.cpp25
-rw-r--r--test/std/localization/locales/locale.convenience/conversions/conversions.string/to_bytes.pass.cpp39
-rw-r--r--test/std/localization/locales/locale.convenience/conversions/conversions.string/types.pass.cpp35
-rw-r--r--test/std/localization/locales/locale.convenience/conversions/nothing_to_do.pass.cpp12
-rw-r--r--test/std/localization/locales/locale.convenience/nothing_to_do.pass.cpp12
-rw-r--r--test/std/localization/locales/locale.global.templates/has_facet.pass.cpp32
-rw-r--r--test/std/localization/locales/locale.global.templates/use_facet.pass.cpp52
-rw-r--r--test/std/localization/locales/locale/locale.cons/assign.pass.cpp83
-rw-r--r--test/std/localization/locales/locale/locale.cons/char_pointer.pass.cpp104
-rw-r--r--test/std/localization/locales/locale/locale.cons/copy.pass.cpp82
-rw-r--r--test/std/localization/locales/locale/locale.cons/default.pass.cpp75
-rw-r--r--test/std/localization/locales/locale/locale.cons/locale_char_pointer_cat.pass.cpp82
-rw-r--r--test/std/localization/locales/locale/locale.cons/locale_facetptr.pass.cpp106
-rw-r--r--test/std/localization/locales/locale/locale.cons/locale_locale_cat.pass.cpp82
-rw-r--r--test/std/localization/locales/locale/locale.cons/locale_string_cat.pass.cpp81
-rw-r--r--test/std/localization/locales/locale/locale.cons/string.pass.cpp87
-rw-r--r--test/std/localization/locales/locale/locale.members/combine.pass.cpp94
-rw-r--r--test/std/localization/locales/locale/locale.members/name.pass.cpp29
-rw-r--r--test/std/localization/locales/locale/locale.operators/compare.pass.cpp34
-rw-r--r--test/std/localization/locales/locale/locale.operators/eq.pass.cpp84
-rw-r--r--test/std/localization/locales/locale/locale.statics/classic.pass.cpp59
-rw-r--r--test/std/localization/locales/locale/locale.statics/global.pass.cpp63
-rw-r--r--test/std/localization/locales/locale/locale.types/locale.category/category.pass.cpp59
-rw-r--r--test/std/localization/locales/locale/locale.types/locale.facet/facet.pass.cpp53
-rw-r--r--test/std/localization/locales/locale/locale.types/locale.id/id.pass.cpp50
-rw-r--r--test/std/localization/locales/locale/locale.types/nothing_to_do.pass.cpp12
-rw-r--r--test/std/localization/locales/locale/nothing_to_do.pass.cpp12
-rw-r--r--test/std/localization/locales/nothing_to_do.pass.cpp12
-rw-r--r--test/std/localization/localization.general/nothing_to_do.pass.cpp12
-rw-r--r--test/std/localization/version.pass.cpp20
-rw-r--r--test/std/nothing_to_do.pass.cpp13
-rw-r--r--test/std/numerics/c.math/cmath.pass.cpp1485
-rw-r--r--test/std/numerics/c.math/cmath_isinf.pass.cpp30
-rw-r--r--test/std/numerics/c.math/cmath_isnan.pass.cpp30
-rw-r--r--test/std/numerics/c.math/ctgmath.pass.cpp22
-rw-r--r--test/std/numerics/c.math/tgmath_h.pass.cpp20
-rw-r--r--test/std/numerics/c.math/version_cmath.pass.cpp20
-rw-r--r--test/std/numerics/cfenv/cfenv.syn/cfenv.pass.cpp76
-rw-r--r--test/std/numerics/cfenv/version.pass.cpp22
-rw-r--r--test/std/numerics/complex.number/cases.h230
-rw-r--r--test/std/numerics/complex.number/ccmplx/ccomplex.pass.cpp21
-rw-r--r--test/std/numerics/complex.number/cmplx.over/arg.pass.cpp55
-rw-r--r--test/std/numerics/complex.number/cmplx.over/conj.pass.cpp66
-rw-r--r--test/std/numerics/complex.number/cmplx.over/imag.pass.cpp67
-rw-r--r--test/std/numerics/complex.number/cmplx.over/norm.pass.cpp55
-rw-r--r--test/std/numerics/complex.number/cmplx.over/pow.pass.cpp104
-rw-r--r--test/std/numerics/complex.number/cmplx.over/proj.pass.cpp66
-rw-r--r--test/std/numerics/complex.number/cmplx.over/real.pass.cpp67
-rw-r--r--test/std/numerics/complex.number/complex.literals/literals.pass.cpp51
-rw-r--r--test/std/numerics/complex.number/complex.literals/literals1.fail.cpp20
-rw-r--r--test/std/numerics/complex.number/complex.literals/literals1.pass.cpp43
-rw-r--r--test/std/numerics/complex.number/complex.literals/literals2.pass.cpp43
-rw-r--r--test/std/numerics/complex.number/complex.member.ops/assignment_complex.pass.cpp48
-rw-r--r--test/std/numerics/complex.number/complex.member.ops/assignment_scalar.pass.cpp37
-rw-r--r--test/std/numerics/complex.number/complex.member.ops/divide_equal_complex.pass.cpp53
-rw-r--r--test/std/numerics/complex.number/complex.member.ops/divide_equal_scalar.pass.cpp44
-rw-r--r--test/std/numerics/complex.number/complex.member.ops/minus_equal_complex.pass.cpp52
-rw-r--r--test/std/numerics/complex.number/complex.member.ops/minus_equal_scalar.pass.cpp40
-rw-r--r--test/std/numerics/complex.number/complex.member.ops/plus_equal_complex.pass.cpp52
-rw-r--r--test/std/numerics/complex.number/complex.member.ops/plus_equal_scalar.pass.cpp40
-rw-r--r--test/std/numerics/complex.number/complex.member.ops/times_equal_complex.pass.cpp52
-rw-r--r--test/std/numerics/complex.number/complex.member.ops/times_equal_scalar.pass.cpp44
-rw-r--r--test/std/numerics/complex.number/complex.members/construct.pass.cpp70
-rw-r--r--test/std/numerics/complex.number/complex.members/real_imag.pass.cpp64
-rw-r--r--test/std/numerics/complex.number/complex.ops/complex_divide_complex.pass.cpp159
-rw-r--r--test/std/numerics/complex.number/complex.ops/complex_divide_scalar.pass.cpp41
-rw-r--r--test/std/numerics/complex.number/complex.ops/complex_equals_complex.pass.cpp60
-rw-r--r--test/std/numerics/complex.number/complex.ops/complex_equals_scalar.pass.cpp81
-rw-r--r--test/std/numerics/complex.number/complex.ops/complex_minus_complex.pass.cpp49
-rw-r--r--test/std/numerics/complex.number/complex.ops/complex_minus_scalar.pass.cpp49
-rw-r--r--test/std/numerics/complex.number/complex.ops/complex_not_equals_complex.pass.cpp62
-rw-r--r--test/std/numerics/complex.number/complex.ops/complex_not_equals_scalar.pass.cpp81
-rw-r--r--test/std/numerics/complex.number/complex.ops/complex_plus_complex.pass.cpp49
-rw-r--r--test/std/numerics/complex.number/complex.ops/complex_plus_scalar.pass.cpp49
-rw-r--r--test/std/numerics/complex.number/complex.ops/complex_times_complex.pass.cpp161
-rw-r--r--test/std/numerics/complex.number/complex.ops/complex_times_scalar.pass.cpp41
-rw-r--r--test/std/numerics/complex.number/complex.ops/scalar_divide_complex.pass.cpp41
-rw-r--r--test/std/numerics/complex.number/complex.ops/scalar_equals_complex.pass.cpp81
-rw-r--r--test/std/numerics/complex.number/complex.ops/scalar_minus_complex.pass.cpp49
-rw-r--r--test/std/numerics/complex.number/complex.ops/scalar_not_equals_complex.pass.cpp81
-rw-r--r--test/std/numerics/complex.number/complex.ops/scalar_plus_complex.pass.cpp49
-rw-r--r--test/std/numerics/complex.number/complex.ops/scalar_times_complex.pass.cpp41
-rw-r--r--test/std/numerics/complex.number/complex.ops/stream_input.pass.cpp99
-rw-r--r--test/std/numerics/complex.number/complex.ops/stream_output.pass.cpp26
-rw-r--r--test/std/numerics/complex.number/complex.ops/unary_minus.pass.cpp36
-rw-r--r--test/std/numerics/complex.number/complex.ops/unary_plus.pass.cpp36
-rw-r--r--test/std/numerics/complex.number/complex.special/double_float_explicit.pass.cpp37
-rw-r--r--test/std/numerics/complex.number/complex.special/double_float_implicit.pass.cpp37
-rw-r--r--test/std/numerics/complex.number/complex.special/double_long_double_explicit.pass.cpp37
-rw-r--r--test/std/numerics/complex.number/complex.special/double_long_double_implicit.fail.cpp27
-rw-r--r--test/std/numerics/complex.number/complex.special/float_double_explicit.pass.cpp37
-rw-r--r--test/std/numerics/complex.number/complex.special/float_double_implicit.fail.cpp27
-rw-r--r--test/std/numerics/complex.number/complex.special/float_long_double_explicit.pass.cpp37
-rw-r--r--test/std/numerics/complex.number/complex.special/float_long_double_implicit.fail.cpp27
-rw-r--r--test/std/numerics/complex.number/complex.special/long_double_double_explicit.pass.cpp37
-rw-r--r--test/std/numerics/complex.number/complex.special/long_double_double_implicit.pass.cpp37
-rw-r--r--test/std/numerics/complex.number/complex.special/long_double_float_explicit.pass.cpp37
-rw-r--r--test/std/numerics/complex.number/complex.special/long_double_float_implicit.pass.cpp37
-rw-r--r--test/std/numerics/complex.number/complex.synopsis/nothing_to_do.pass.cpp12
-rw-r--r--test/std/numerics/complex.number/complex.transcendentals/acos.pass.cpp140
-rw-r--r--test/std/numerics/complex.number/complex.transcendentals/acosh.pass.cpp142
-rw-r--r--test/std/numerics/complex.number/complex.transcendentals/asin.pass.cpp120
-rw-r--r--test/std/numerics/complex.number/complex.transcendentals/asinh.pass.cpp119
-rw-r--r--test/std/numerics/complex.number/complex.transcendentals/atan.pass.cpp68
-rw-r--r--test/std/numerics/complex.number/complex.transcendentals/atanh.pass.cpp132
-rw-r--r--test/std/numerics/complex.number/complex.transcendentals/cos.pass.cpp68
-rw-r--r--test/std/numerics/complex.number/complex.transcendentals/cosh.pass.cpp118
-rw-r--r--test/std/numerics/complex.number/complex.transcendentals/exp.pass.cpp114
-rw-r--r--test/std/numerics/complex.number/complex.transcendentals/log.pass.cpp131
-rw-r--r--test/std/numerics/complex.number/complex.transcendentals/log10.pass.cpp66
-rw-r--r--test/std/numerics/complex.number/complex.transcendentals/pow_complex_complex.pass.cpp71
-rw-r--r--test/std/numerics/complex.number/complex.transcendentals/pow_complex_scalar.pass.cpp69
-rw-r--r--test/std/numerics/complex.number/complex.transcendentals/pow_scalar_complex.pass.cpp69
-rw-r--r--test/std/numerics/complex.number/complex.transcendentals/sin.pass.cpp69
-rw-r--r--test/std/numerics/complex.number/complex.transcendentals/sinh.pass.cpp119
-rw-r--r--test/std/numerics/complex.number/complex.transcendentals/sqrt.pass.cpp109
-rw-r--r--test/std/numerics/complex.number/complex.transcendentals/tan.pass.cpp70
-rw-r--r--test/std/numerics/complex.number/complex.transcendentals/tanh.pass.cpp101
-rw-r--r--test/std/numerics/complex.number/complex.value.ops/abs.pass.cpp63
-rw-r--r--test/std/numerics/complex.number/complex.value.ops/arg.pass.cpp135
-rw-r--r--test/std/numerics/complex.number/complex.value.ops/conj.pass.cpp41
-rw-r--r--test/std/numerics/complex.number/complex.value.ops/imag.pass.cpp32
-rw-r--r--test/std/numerics/complex.number/complex.value.ops/norm.pass.cpp63
-rw-r--r--test/std/numerics/complex.number/complex.value.ops/polar.pass.cpp112
-rw-r--r--test/std/numerics/complex.number/complex.value.ops/proj.pass.cpp71
-rw-r--r--test/std/numerics/complex.number/complex.value.ops/real.pass.cpp32
-rw-r--r--test/std/numerics/complex.number/complex/types.pass.cpp36
-rw-r--r--test/std/numerics/complex.number/layout.pass.cpp36
-rw-r--r--test/std/numerics/complex.number/version.pass.cpp20
-rw-r--r--test/std/numerics/nothing_to_do.pass.cpp12
-rw-r--r--test/std/numerics/numarray/class.gslice/gslice.access/tested_elsewhere.pass.cpp12
-rw-r--r--test/std/numerics/numarray/class.gslice/gslice.cons/default.pass.cpp25
-rw-r--r--test/std/numerics/numarray/class.gslice/gslice.cons/start_size_stride.pass.cpp38
-rw-r--r--test/std/numerics/numarray/class.gslice/nothing_to_do.pass.cpp12
-rw-r--r--test/std/numerics/numarray/class.slice/cons.slice/default.pass.cpp25
-rw-r--r--test/std/numerics/numarray/class.slice/cons.slice/start_size_stride.pass.cpp25
-rw-r--r--test/std/numerics/numarray/class.slice/nothing_to_do.pass.cpp12
-rw-r--r--test/std/numerics/numarray/class.slice/slice.access/tested_elsewhere.pass.cpp12
-rw-r--r--test/std/numerics/numarray/template.gslice.array/default.fail.cpp22
-rw-r--r--test/std/numerics/numarray/template.gslice.array/gslice.array.assign/gslice_array.pass.cpp81
-rw-r--r--test/std/numerics/numarray/template.gslice.array/gslice.array.assign/valarray.pass.cpp77
-rw-r--r--test/std/numerics/numarray/template.gslice.array/gslice.array.comp.assign/addition.pass.cpp77
-rw-r--r--test/std/numerics/numarray/template.gslice.array/gslice.array.comp.assign/and.pass.cpp77
-rw-r--r--test/std/numerics/numarray/template.gslice.array/gslice.array.comp.assign/divide.pass.cpp77
-rw-r--r--test/std/numerics/numarray/template.gslice.array/gslice.array.comp.assign/modulo.pass.cpp77
-rw-r--r--test/std/numerics/numarray/template.gslice.array/gslice.array.comp.assign/multiply.pass.cpp77
-rw-r--r--test/std/numerics/numarray/template.gslice.array/gslice.array.comp.assign/or.pass.cpp77
-rw-r--r--test/std/numerics/numarray/template.gslice.array/gslice.array.comp.assign/shift_left.pass.cpp77
-rw-r--r--test/std/numerics/numarray/template.gslice.array/gslice.array.comp.assign/shift_right.pass.cpp77
-rw-r--r--test/std/numerics/numarray/template.gslice.array/gslice.array.comp.assign/subtraction.pass.cpp77
-rw-r--r--test/std/numerics/numarray/template.gslice.array/gslice.array.comp.assign/xor.pass.cpp77
-rw-r--r--test/std/numerics/numarray/template.gslice.array/gslice.array.fill/assign_value.pass.cpp74
-rw-r--r--test/std/numerics/numarray/template.gslice.array/types.pass.cpp24
-rw-r--r--test/std/numerics/numarray/template.indirect.array/default.fail.cpp22
-rw-r--r--test/std/numerics/numarray/template.indirect.array/indirect.array.assign/indirect_array.pass.cpp80
-rw-r--r--test/std/numerics/numarray/template.indirect.array/indirect.array.assign/valarray.pass.cpp77
-rw-r--r--test/std/numerics/numarray/template.indirect.array/indirect.array.comp.assign/addition.pass.cpp77
-rw-r--r--test/std/numerics/numarray/template.indirect.array/indirect.array.comp.assign/and.pass.cpp77
-rw-r--r--test/std/numerics/numarray/template.indirect.array/indirect.array.comp.assign/divide.pass.cpp77
-rw-r--r--test/std/numerics/numarray/template.indirect.array/indirect.array.comp.assign/modulo.pass.cpp77
-rw-r--r--test/std/numerics/numarray/template.indirect.array/indirect.array.comp.assign/multiply.pass.cpp77
-rw-r--r--test/std/numerics/numarray/template.indirect.array/indirect.array.comp.assign/or.pass.cpp77
-rw-r--r--test/std/numerics/numarray/template.indirect.array/indirect.array.comp.assign/shift_left.pass.cpp77
-rw-r--r--test/std/numerics/numarray/template.indirect.array/indirect.array.comp.assign/shift_right.pass.cpp77
-rw-r--r--test/std/numerics/numarray/template.indirect.array/indirect.array.comp.assign/subtraction.pass.cpp77
-rw-r--r--test/std/numerics/numarray/template.indirect.array/indirect.array.comp.assign/xor.pass.cpp77
-rw-r--r--test/std/numerics/numarray/template.indirect.array/indirect.array.fill/assign_value.pass.cpp74
-rw-r--r--test/std/numerics/numarray/template.indirect.array/types.pass.cpp24
-rw-r--r--test/std/numerics/numarray/template.mask.array/default.fail.cpp22
-rw-r--r--test/std/numerics/numarray/template.mask.array/mask.array.assign/mask_array.pass.cpp66
-rw-r--r--test/std/numerics/numarray/template.mask.array/mask.array.assign/valarray.pass.cpp49
-rw-r--r--test/std/numerics/numarray/template.mask.array/mask.array.comp.assign/addition.pass.cpp49
-rw-r--r--test/std/numerics/numarray/template.mask.array/mask.array.comp.assign/and.pass.cpp49
-rw-r--r--test/std/numerics/numarray/template.mask.array/mask.array.comp.assign/divide.pass.cpp49
-rw-r--r--test/std/numerics/numarray/template.mask.array/mask.array.comp.assign/modulo.pass.cpp49
-rw-r--r--test/std/numerics/numarray/template.mask.array/mask.array.comp.assign/multiply.pass.cpp49
-rw-r--r--test/std/numerics/numarray/template.mask.array/mask.array.comp.assign/or.pass.cpp49
-rw-r--r--test/std/numerics/numarray/template.mask.array/mask.array.comp.assign/shift_left.pass.cpp49
-rw-r--r--test/std/numerics/numarray/template.mask.array/mask.array.comp.assign/shift_right.pass.cpp49
-rw-r--r--test/std/numerics/numarray/template.mask.array/mask.array.comp.assign/subtraction.pass.cpp49
-rw-r--r--test/std/numerics/numarray/template.mask.array/mask.array.comp.assign/xor.pass.cpp49
-rw-r--r--test/std/numerics/numarray/template.mask.array/mask.array.fill/assign_value.pass.cpp45
-rw-r--r--test/std/numerics/numarray/template.mask.array/types.pass.cpp24
-rw-r--r--test/std/numerics/numarray/template.slice.array/default.fail.cpp22
-rw-r--r--test/std/numerics/numarray/template.slice.array/slice.arr.assign/slice_array.pass.cpp55
-rw-r--r--test/std/numerics/numarray/template.slice.array/slice.arr.assign/valarray.pass.cpp43
-rw-r--r--test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/addition.pass.cpp43
-rw-r--r--test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/and.pass.cpp43
-rw-r--r--test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/divide.pass.cpp43
-rw-r--r--test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/modulo.pass.cpp43
-rw-r--r--test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/multiply.pass.cpp43
-rw-r--r--test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/or.pass.cpp43
-rw-r--r--test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/shift_left.pass.cpp43
-rw-r--r--test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/shift_right.pass.cpp43
-rw-r--r--test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/subtraction.pass.cpp43
-rw-r--r--test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/xor.pass.cpp43
-rw-r--r--test/std/numerics/numarray/template.slice.array/slice.arr.fill/assign_value.pass.cpp41
-rw-r--r--test/std/numerics/numarray/template.slice.array/types.pass.cpp24
-rw-r--r--test/std/numerics/numarray/template.valarray/types.pass.cpp26
-rw-r--r--test/std/numerics/numarray/template.valarray/valarray.access/access.pass.cpp33
-rw-r--r--test/std/numerics/numarray/template.valarray/valarray.access/const_access.pass.cpp31
-rw-r--r--test/std/numerics/numarray/template.valarray/valarray.assign/copy_assign.pass.cpp58
-rw-r--r--test/std/numerics/numarray/template.valarray/valarray.assign/gslice_array_assign.pass.cpp58
-rw-r--r--test/std/numerics/numarray/template.valarray/valarray.assign/indirect_array_assign.pass.cpp58
-rw-r--r--test/std/numerics/numarray/template.valarray/valarray.assign/initializer_list_assign.pass.cpp57
-rw-r--r--test/std/numerics/numarray/template.valarray/valarray.assign/mask_array_assign.pass.cpp35
-rw-r--r--test/std/numerics/numarray/template.valarray/valarray.assign/move_assign.pass.cpp63
-rw-r--r--test/std/numerics/numarray/template.valarray/valarray.assign/slice_array_assign.pass.cpp31
-rw-r--r--test/std/numerics/numarray/template.valarray/valarray.assign/value_assign.pass.cpp31
-rw-r--r--test/std/numerics/numarray/template.valarray/valarray.cassign/and_valarray.pass.cpp36
-rw-r--r--test/std/numerics/numarray/template.valarray/valarray.cassign/and_value.pass.cpp33
-rw-r--r--test/std/numerics/numarray/template.valarray/valarray.cassign/divide_valarray.pass.cpp36
-rw-r--r--test/std/numerics/numarray/template.valarray/valarray.cassign/divide_value.pass.cpp33
-rw-r--r--test/std/numerics/numarray/template.valarray/valarray.cassign/minus_valarray.pass.cpp36
-rw-r--r--test/std/numerics/numarray/template.valarray/valarray.cassign/minus_value.pass.cpp33
-rw-r--r--test/std/numerics/numarray/template.valarray/valarray.cassign/modulo_valarray.pass.cpp36
-rw-r--r--test/std/numerics/numarray/template.valarray/valarray.cassign/modulo_value.pass.cpp33
-rw-r--r--test/std/numerics/numarray/template.valarray/valarray.cassign/or_valarray.pass.cpp36
-rw-r--r--test/std/numerics/numarray/template.valarray/valarray.cassign/or_value.pass.cpp33
-rw-r--r--test/std/numerics/numarray/template.valarray/valarray.cassign/plus_valarray.pass.cpp36
-rw-r--r--test/std/numerics/numarray/template.valarray/valarray.cassign/plus_value.pass.cpp33
-rw-r--r--test/std/numerics/numarray/template.valarray/valarray.cassign/shift_left_valarray.pass.cpp36
-rw-r--r--test/std/numerics/numarray/template.valarray/valarray.cassign/shift_left_value.pass.cpp33
-rw-r--r--test/std/numerics/numarray/template.valarray/valarray.cassign/shift_right_valarray.pass.cpp36
-rw-r--r--test/std/numerics/numarray/template.valarray/valarray.cassign/shift_right_value.pass.cpp33
-rw-r--r--test/std/numerics/numarray/template.valarray/valarray.cassign/times_valarray.pass.cpp36
-rw-r--r--test/std/numerics/numarray/template.valarray/valarray.cassign/times_value.pass.cpp33
-rw-r--r--test/std/numerics/numarray/template.valarray/valarray.cassign/xor_valarray.pass.cpp36
-rw-r--r--test/std/numerics/numarray/template.valarray/valarray.cassign/xor_value.pass.cpp33
-rw-r--r--test/std/numerics/numarray/template.valarray/valarray.cons/copy.pass.cpp55
-rw-r--r--test/std/numerics/numarray/template.valarray/valarray.cons/default.pass.cpp37
-rw-r--r--test/std/numerics/numarray/template.valarray/valarray.cons/gslice_array.pass.cpp57
-rw-r--r--test/std/numerics/numarray/template.valarray/valarray.cons/indirect_array.pass.cpp57
-rw-r--r--test/std/numerics/numarray/template.valarray/valarray.cons/initializer_list.pass.cpp41
-rw-r--r--test/std/numerics/numarray/template.valarray/valarray.cons/mask_array.pass.cpp34
-rw-r--r--test/std/numerics/numarray/template.valarray/valarray.cons/move.pass.cpp61
-rw-r--r--test/std/numerics/numarray/template.valarray/valarray.cons/pointer_size.pass.cpp52
-rw-r--r--test/std/numerics/numarray/template.valarray/valarray.cons/size.pass.cpp39
-rw-r--r--test/std/numerics/numarray/template.valarray/valarray.cons/slice_array.pass.cpp30
-rw-r--r--test/std/numerics/numarray/template.valarray/valarray.cons/value_size.pass.cpp39
-rw-r--r--test/std/numerics/numarray/template.valarray/valarray.members/apply_cref.pass.cpp51
-rw-r--r--test/std/numerics/numarray/template.valarray/valarray.members/apply_value.pass.cpp51
-rw-r--r--test/std/numerics/numarray/template.valarray/valarray.members/cshift.pass.cpp127
-rw-r--r--test/std/numerics/numarray/template.valarray/valarray.members/max.pass.cpp40
-rw-r--r--test/std/numerics/numarray/template.valarray/valarray.members/min.pass.cpp40
-rw-r--r--test/std/numerics/numarray/template.valarray/valarray.members/resize.pass.cpp41
-rw-r--r--test/std/numerics/numarray/template.valarray/valarray.members/shift.pass.cpp127
-rw-r--r--test/std/numerics/numarray/template.valarray/valarray.members/size.pass.cpp41
-rw-r--r--test/std/numerics/numarray/template.valarray/valarray.members/sum.pass.cpp28
-rw-r--r--test/std/numerics/numarray/template.valarray/valarray.members/swap.pass.cpp89
-rw-r--r--test/std/numerics/numarray/template.valarray/valarray.sub/gslice_const.pass.cpp77
-rw-r--r--test/std/numerics/numarray/template.valarray/valarray.sub/gslice_non_const.pass.cpp57
-rw-r--r--test/std/numerics/numarray/template.valarray/valarray.sub/indirect_array_const.pass.cpp57
-rw-r--r--test/std/numerics/numarray/template.valarray/valarray.sub/indirect_array_non_const.pass.cpp58
-rw-r--r--test/std/numerics/numarray/template.valarray/valarray.sub/slice_const.pass.cpp30
-rw-r--r--test/std/numerics/numarray/template.valarray/valarray.sub/slice_non_const.pass.cpp43
-rw-r--r--test/std/numerics/numarray/template.valarray/valarray.sub/valarray_bool_const.pass.cpp34
-rw-r--r--test/std/numerics/numarray/template.valarray/valarray.sub/valarray_bool_non_const.pass.cpp35
-rw-r--r--test/std/numerics/numarray/template.valarray/valarray.unary/bit_not.pass.cpp55
-rw-r--r--test/std/numerics/numarray/template.valarray/valarray.unary/negate.pass.cpp65
-rw-r--r--test/std/numerics/numarray/template.valarray/valarray.unary/not.pass.cpp41
-rw-r--r--test/std/numerics/numarray/template.valarray/valarray.unary/plus.pass.cpp65
-rw-r--r--test/std/numerics/numarray/valarray.nonmembers/nothing_to_do.pass.cpp12
-rw-r--r--test/std/numerics/numarray/valarray.nonmembers/valarray.binary/and_valarray_valarray.pass.cpp35
-rw-r--r--test/std/numerics/numarray/valarray.nonmembers/valarray.binary/and_valarray_value.pass.cpp32
-rw-r--r--test/std/numerics/numarray/valarray.nonmembers/valarray.binary/and_value_valarray.pass.cpp32
-rw-r--r--test/std/numerics/numarray/valarray.nonmembers/valarray.binary/divide_valarray_valarray.pass.cpp35
-rw-r--r--test/std/numerics/numarray/valarray.nonmembers/valarray.binary/divide_valarray_value.pass.cpp32
-rw-r--r--test/std/numerics/numarray/valarray.nonmembers/valarray.binary/divide_value_valarray.pass.cpp32
-rw-r--r--test/std/numerics/numarray/valarray.nonmembers/valarray.binary/minus_valarray_valarray.pass.cpp35
-rw-r--r--test/std/numerics/numarray/valarray.nonmembers/valarray.binary/minus_valarray_value.pass.cpp32
-rw-r--r--test/std/numerics/numarray/valarray.nonmembers/valarray.binary/minus_value_valarray.pass.cpp32
-rw-r--r--test/std/numerics/numarray/valarray.nonmembers/valarray.binary/modulo_valarray_valarray.pass.cpp35
-rw-r--r--test/std/numerics/numarray/valarray.nonmembers/valarray.binary/modulo_valarray_value.pass.cpp32
-rw-r--r--test/std/numerics/numarray/valarray.nonmembers/valarray.binary/modulo_value_valarray.pass.cpp32
-rw-r--r--test/std/numerics/numarray/valarray.nonmembers/valarray.binary/or_valarray_valarray.pass.cpp35
-rw-r--r--test/std/numerics/numarray/valarray.nonmembers/valarray.binary/or_valarray_value.pass.cpp32
-rw-r--r--test/std/numerics/numarray/valarray.nonmembers/valarray.binary/or_value_valarray.pass.cpp32
-rw-r--r--test/std/numerics/numarray/valarray.nonmembers/valarray.binary/plus_valarray_valarray.pass.cpp35
-rw-r--r--test/std/numerics/numarray/valarray.nonmembers/valarray.binary/plus_valarray_value.pass.cpp32
-rw-r--r--test/std/numerics/numarray/valarray.nonmembers/valarray.binary/plus_value_valarray.pass.cpp32
-rw-r--r--test/std/numerics/numarray/valarray.nonmembers/valarray.binary/shift_left_valarray_valarray.pass.cpp35
-rw-r--r--test/std/numerics/numarray/valarray.nonmembers/valarray.binary/shift_left_valarray_value.pass.cpp32
-rw-r--r--test/std/numerics/numarray/valarray.nonmembers/valarray.binary/shift_left_value_valarray.pass.cpp32
-rw-r--r--test/std/numerics/numarray/valarray.nonmembers/valarray.binary/shift_right_valarray_valarray.pass.cpp35
-rw-r--r--test/std/numerics/numarray/valarray.nonmembers/valarray.binary/shift_right_valarray_value.pass.cpp32
-rw-r--r--test/std/numerics/numarray/valarray.nonmembers/valarray.binary/shift_right_value_valarray.pass.cpp32
-rw-r--r--test/std/numerics/numarray/valarray.nonmembers/valarray.binary/times_valarray_valarray.pass.cpp35
-rw-r--r--test/std/numerics/numarray/valarray.nonmembers/valarray.binary/times_valarray_value.pass.cpp32
-rw-r--r--test/std/numerics/numarray/valarray.nonmembers/valarray.binary/times_value_valarray.pass.cpp32
-rw-r--r--test/std/numerics/numarray/valarray.nonmembers/valarray.binary/xor_valarray_valarray.pass.cpp35
-rw-r--r--test/std/numerics/numarray/valarray.nonmembers/valarray.binary/xor_valarray_value.pass.cpp32
-rw-r--r--test/std/numerics/numarray/valarray.nonmembers/valarray.binary/xor_value_valarray.pass.cpp32
-rw-r--r--test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/and_valarray_valarray.pass.cpp37
-rw-r--r--test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/and_valarray_value.pass.cpp45
-rw-r--r--test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/and_value_valarray.pass.cpp45
-rw-r--r--test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/equal_valarray_valarray.pass.cpp37
-rw-r--r--test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/equal_valarray_value.pass.cpp34
-rw-r--r--test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/equal_value_valarray.pass.cpp34
-rw-r--r--test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_equal_valarray_valarray.pass.cpp37
-rw-r--r--test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_equal_valarray_value.pass.cpp34
-rw-r--r--test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_equal_value_valarray.pass.cpp34
-rw-r--r--test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_valarray_valarray.pass.cpp37
-rw-r--r--test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_valarray_value.pass.cpp34
-rw-r--r--test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_value_valarray.pass.cpp34
-rw-r--r--test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/less_equal_valarray_valarray.pass.cpp37
-rw-r--r--test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/less_equal_valarray_value.pass.cpp34
-rw-r--r--test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/less_equal_value_valarray.pass.cpp34
-rw-r--r--test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/less_valarray_valarray.pass.cpp37
-rw-r--r--test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/less_valarray_value.pass.cpp34
-rw-r--r--test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/less_value_valarray.pass.cpp34
-rw-r--r--test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/not_equal_valarray_valarray.pass.cpp37
-rw-r--r--test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/not_equal_valarray_value.pass.cpp34
-rw-r--r--test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/not_equal_value_valarray.pass.cpp34
-rw-r--r--test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/or_valarray_valarray.pass.cpp37
-rw-r--r--test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/or_valarray_value.pass.cpp45
-rw-r--r--test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/or_value_valarray.pass.cpp45
-rw-r--r--test/std/numerics/numarray/valarray.nonmembers/valarray.special/swap.pass.cpp91
-rw-r--r--test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/abs_valarray.pass.cpp34
-rw-r--r--test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/acos_valarray.pass.cpp51
-rw-r--r--test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/asin_valarray.pass.cpp51
-rw-r--r--test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/atan2_valarray_valarray.pass.cpp53
-rw-r--r--test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/atan2_valarray_value.pass.cpp51
-rw-r--r--test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/atan2_value_valarray.pass.cpp51
-rw-r--r--test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/atan_valarray.pass.cpp51
-rw-r--r--test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/cos_valarray.pass.cpp51
-rw-r--r--test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/cosh_valarray.pass.cpp51
-rw-r--r--test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/exp_valarray.pass.cpp51
-rw-r--r--test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/log10_valarray.pass.cpp51
-rw-r--r--test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/log_valarray.pass.cpp51
-rw-r--r--test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/pow_valarray_valarray.pass.cpp53
-rw-r--r--test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/pow_valarray_value.pass.cpp51
-rw-r--r--test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/pow_value_valarray.pass.cpp51
-rw-r--r--test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/sin_valarray.pass.cpp51
-rw-r--r--test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/sinh_valarray.pass.cpp51
-rw-r--r--test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/sqrt_valarray.pass.cpp51
-rw-r--r--test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/tan_valarray.pass.cpp51
-rw-r--r--test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/tanh_valarray.pass.cpp51
-rw-r--r--test/std/numerics/numarray/valarray.range/begin_const.pass.cpp30
-rw-r--r--test/std/numerics/numarray/valarray.range/begin_non_const.pass.cpp31
-rw-r--r--test/std/numerics/numarray/valarray.range/end_const.pass.cpp31
-rw-r--r--test/std/numerics/numarray/valarray.range/end_non_const.pass.cpp32
-rw-r--r--test/std/numerics/numarray/valarray.syn/nothing_to_do.pass.cpp12
-rw-r--r--test/std/numerics/numarray/version.pass.cpp20
-rw-r--r--test/std/numerics/numeric.ops/accumulate/accumulate.pass.cpp53
-rw-r--r--test/std/numerics/numeric.ops/accumulate/accumulate_op.pass.cpp55
-rw-r--r--test/std/numerics/numeric.ops/adjacent.difference/adjacent_difference.pass.cpp115
-rw-r--r--test/std/numerics/numeric.ops/adjacent.difference/adjacent_difference_op.pass.cpp118
-rw-r--r--test/std/numerics/numeric.ops/inner.product/inner_product.pass.cpp82
-rw-r--r--test/std/numerics/numeric.ops/inner.product/inner_product_comp.pass.cpp85
-rw-r--r--test/std/numerics/numeric.ops/numeric.iota/iota.pass.cpp38
-rw-r--r--test/std/numerics/numeric.ops/partial.sum/partial_sum.pass.cpp70
-rw-r--r--test/std/numerics/numeric.ops/partial.sum/partial_sum_op.pass.cpp72
-rw-r--r--test/std/numerics/numeric.ops/version.pass.cpp20
-rw-r--r--test/std/numerics/numeric.requirements/nothing_to_do.pass.cpp12
-rw-r--r--test/std/numerics/numerics.general/nothing_to_do.pass.cpp12
-rw-r--r--test/std/numerics/rand/nothing_to_do.pass.cpp12
-rw-r--r--test/std/numerics/rand/rand.adapt/nothing_to_do.pass.cpp12
-rw-r--r--test/std/numerics/rand/rand.adapt/rand.adapt.disc/assign.pass.cpp56
-rw-r--r--test/std/numerics/rand/rand.adapt/rand.adapt.disc/copy.pass.cpp54
-rw-r--r--test/std/numerics/rand/rand.adapt/rand.adapt.disc/ctor_engine_copy.pass.cpp29
-rw-r--r--test/std/numerics/rand/rand.adapt/rand.adapt.disc/ctor_engine_move.pass.cpp30
-rw-r--r--test/std/numerics/rand/rand.adapt/rand.adapt.disc/ctor_result_type.pass.cpp51
-rw-r--r--test/std/numerics/rand/rand.adapt/rand.adapt.disc/ctor_sseq.pass.cpp55
-rw-r--r--test/std/numerics/rand/rand.adapt/rand.adapt.disc/default.pass.cpp42
-rw-r--r--test/std/numerics/rand/rand.adapt/rand.adapt.disc/discard.pass.cpp52
-rw-r--r--test/std/numerics/rand/rand.adapt/rand.adapt.disc/eval.pass.cpp42
-rw-r--r--test/std/numerics/rand/rand.adapt/rand.adapt.disc/io.pass.cpp63
-rw-r--r--test/std/numerics/rand/rand.adapt/rand.adapt.disc/result_type.pass.cpp42
-rw-r--r--test/std/numerics/rand/rand.adapt/rand.adapt.disc/seed_result_type.pass.cpp50
-rw-r--r--test/std/numerics/rand/rand.adapt/rand.adapt.disc/seed_sseq.pass.cpp48
-rw-r--r--test/std/numerics/rand/rand.adapt/rand.adapt.disc/values.pass.cpp60
-rw-r--r--test/std/numerics/rand/rand.adapt/rand.adapt.ibits/assign.pass.cpp56
-rw-r--r--test/std/numerics/rand/rand.adapt/rand.adapt.ibits/copy.pass.cpp54
-rw-r--r--test/std/numerics/rand/rand.adapt/rand.adapt.ibits/ctor_engine_copy.pass.cpp29
-rw-r--r--test/std/numerics/rand/rand.adapt/rand.adapt.ibits/ctor_engine_move.pass.cpp30
-rw-r--r--test/std/numerics/rand/rand.adapt/rand.adapt.ibits/ctor_result_type.pass.cpp51
-rw-r--r--test/std/numerics/rand/rand.adapt/rand.adapt.ibits/ctor_sseq.pass.cpp55
-rw-r--r--test/std/numerics/rand/rand.adapt/rand.adapt.ibits/default.pass.cpp42
-rw-r--r--test/std/numerics/rand/rand.adapt/rand.adapt.ibits/discard.pass.cpp52
-rw-r--r--test/std/numerics/rand/rand.adapt/rand.adapt.ibits/eval.pass.cpp141
-rw-r--r--test/std/numerics/rand/rand.adapt/rand.adapt.ibits/io.pass.cpp63
-rw-r--r--test/std/numerics/rand/rand.adapt/rand.adapt.ibits/result_type.pass.cpp83
-rw-r--r--test/std/numerics/rand/rand.adapt/rand.adapt.ibits/seed_result_type.pass.cpp50
-rw-r--r--test/std/numerics/rand/rand.adapt/rand.adapt.ibits/seed_sseq.pass.cpp48
-rw-r--r--test/std/numerics/rand/rand.adapt/rand.adapt.ibits/values.pass.cpp47
-rw-r--r--test/std/numerics/rand/rand.adapt/rand.adapt.shuf/assign.pass.cpp39
-rw-r--r--test/std/numerics/rand/rand.adapt/rand.adapt.shuf/copy.pass.cpp38
-rw-r--r--test/std/numerics/rand/rand.adapt/rand.adapt.shuf/ctor_engine_copy.pass.cpp31
-rw-r--r--test/std/numerics/rand/rand.adapt/rand.adapt.shuf/ctor_engine_move.pass.cpp32
-rw-r--r--test/std/numerics/rand/rand.adapt/rand.adapt.shuf/ctor_result_type.pass.cpp76
-rw-r--r--test/std/numerics/rand/rand.adapt/rand.adapt.shuf/ctor_sseq.pass.cpp79
-rw-r--r--test/std/numerics/rand/rand.adapt/rand.adapt.shuf/default.pass.cpp32
-rw-r--r--test/std/numerics/rand/rand.adapt/rand.adapt.shuf/discard.pass.cpp37
-rw-r--r--test/std/numerics/rand/rand.adapt/rand.adapt.shuf/eval.pass.cpp93
-rw-r--r--test/std/numerics/rand/rand.adapt/rand.adapt.shuf/io.pass.cpp48
-rw-r--r--test/std/numerics/rand/rand.adapt/rand.adapt.shuf/result_type.pass.cpp83
-rw-r--r--test/std/numerics/rand/rand.adapt/rand.adapt.shuf/seed_result_type.pass.cpp36
-rw-r--r--test/std/numerics/rand/rand.adapt/rand.adapt.shuf/seed_sseq.pass.cpp35
-rw-r--r--test/std/numerics/rand/rand.adapt/rand.adapt.shuf/values.pass.cpp44
-rw-r--r--test/std/numerics/rand/rand.device/ctor.pass.cpp83
-rw-r--r--test/std/numerics/rand/rand.device/entropy.pass.cpp23
-rw-r--r--test/std/numerics/rand/rand.device/eval.pass.cpp35
-rw-r--r--test/std/numerics/rand/rand.dis/nothing_to_do.pass.cpp12
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.bern/nothing_to_do.pass.cpp12
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/assign.pass.cpp33
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/copy.pass.cpp31
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/ctor_double.pass.cpp36
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/ctor_param.pass.cpp28
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/eq.pass.cpp36
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/eval.pass.cpp103
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/eval_param.pass.cpp107
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/get_param.pass.cpp28
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/io.pass.cpp40
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/max.pass.cpp26
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/min.pass.cpp26
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/param_assign.pass.cpp30
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/param_copy.pass.cpp29
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/param_ctor.pass.cpp34
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/param_eq.pass.cpp36
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/param_types.pass.cpp27
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/set_param.pass.cpp29
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/types.pass.cpp26
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/assign.pass.cpp34
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/copy.pass.cpp32
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/ctor_int_double.pass.cpp40
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/ctor_param.pass.cpp30
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/eq.pass.cpp43
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/eval.pass.cpp475
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/eval_param.pass.cpp160
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/get_param.pass.cpp29
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/io.pass.cpp41
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/max.pass.cpp27
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/min.pass.cpp27
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/param_assign.pass.cpp32
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/param_copy.pass.cpp31
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/param_ctor.pass.cpp44
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/param_eq.pass.cpp37
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/param_types.pass.cpp28
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/set_param.pass.cpp30
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/types.pass.cpp32
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/assign.pass.cpp34
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/copy.pass.cpp32
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/ctor_double.pass.cpp32
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/ctor_param.pass.cpp29
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/eq.pass.cpp37
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/eval.pass.cpp274
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/eval_param.pass.cpp160
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/get_param.pass.cpp29
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/io.pass.cpp41
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/max.pass.cpp27
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/min.pass.cpp27
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/param_assign.pass.cpp31
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/param_copy.pass.cpp30
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/param_ctor.pass.cpp35
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/param_eq.pass.cpp37
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/param_types.pass.cpp28
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/set_param.pass.cpp30
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/types.pass.cpp32
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/assign.pass.cpp34
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/copy.pass.cpp32
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/ctor_int_double.pass.cpp40
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/ctor_param.pass.cpp30
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/eq.pass.cpp43
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/eval.pass.cpp272
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/eval_param.pass.cpp160
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/get_param.pass.cpp29
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/io.pass.cpp41
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/max.pass.cpp27
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/min.pass.cpp27
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_assign.pass.cpp32
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_copy.pass.cpp31
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_ctor.pass.cpp44
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_eq.pass.cpp37
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_types.pass.cpp28
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/set_param.pass.cpp30
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/types.pass.cpp32
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/nothing_to_do.pass.cpp12
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/assign.pass.cpp34
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/copy.pass.cpp32
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/ctor_double_double.pass.cpp40
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/ctor_param.pass.cpp30
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/eq.pass.cpp37
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/eval.pass.cpp80
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/eval_param.pass.cpp83
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/get_param.pass.cpp29
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/io.pass.cpp41
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/max.pass.cpp28
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/min.pass.cpp27
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/param_assign.pass.cpp32
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/param_copy.pass.cpp31
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/param_ctor.pass.cpp44
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/param_eq.pass.cpp37
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/param_types.pass.cpp28
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/set_param.pass.cpp30
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/types.pass.cpp34
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/assign.pass.cpp34
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/copy.pass.cpp32
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/ctor_double.pass.cpp32
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/ctor_param.pass.cpp29
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/eq.pass.cpp37
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/eval.pass.cpp154
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/eval_param.pass.cpp157
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/get_param.pass.cpp29
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/io.pass.cpp41
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/max.pass.cpp28
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/min.pass.cpp27
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/param_assign.pass.cpp31
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/param_copy.pass.cpp30
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/param_ctor.pass.cpp35
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/param_eq.pass.cpp37
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/param_types.pass.cpp28
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/set_param.pass.cpp30
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/types.pass.cpp34
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/assign.pass.cpp34
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/copy.pass.cpp32
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/ctor_double_double.pass.cpp40
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/ctor_param.pass.cpp30
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/eq.pass.cpp37
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/eval.pass.cpp106
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/eval_param.pass.cpp109
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/get_param.pass.cpp29
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/io.pass.cpp41
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/max.pass.cpp28
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/min.pass.cpp27
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/param_assign.pass.cpp32
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/param_copy.pass.cpp31
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/param_ctor.pass.cpp44
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/param_eq.pass.cpp37
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/param_types.pass.cpp28
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/set_param.pass.cpp30
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/types.pass.cpp34
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/assign.pass.cpp34
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/copy.pass.cpp32
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/ctor_double_double.pass.cpp40
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/ctor_param.pass.cpp30
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/eq.pass.cpp37
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/eval.pass.cpp244
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/eval_param.pass.cpp250
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/get_param.pass.cpp29
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/io.pass.cpp41
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/max.pass.cpp28
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/min.pass.cpp27
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_assign.pass.cpp32
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_copy.pass.cpp31
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_ctor.pass.cpp44
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_eq.pass.cpp37
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_types.pass.cpp28
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/set_param.pass.cpp30
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/types.pass.cpp34
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/assign.pass.cpp34
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/copy.pass.cpp32
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/ctor_double_double.pass.cpp40
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/ctor_param.pass.cpp30
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/eq.pass.cpp37
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/eval.pass.cpp70
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/eval_param.pass.cpp71
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/get_param.pass.cpp29
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/io.pass.cpp41
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/max.pass.cpp28
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/min.pass.cpp27
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/param_assign.pass.cpp32
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/param_copy.pass.cpp31
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/param_ctor.pass.cpp44
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/param_eq.pass.cpp37
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/param_types.pass.cpp28
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/set_param.pass.cpp30
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/types.pass.cpp34
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/assign.pass.cpp34
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/copy.pass.cpp32
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/ctor_double.pass.cpp32
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/ctor_param.pass.cpp29
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/eq.pass.cpp37
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/eval.pass.cpp142
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/eval_param.pass.cpp145
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/get_param.pass.cpp29
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/io.pass.cpp41
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/max.pass.cpp28
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/min.pass.cpp27
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/param_assign.pass.cpp31
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/param_copy.pass.cpp30
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/param_ctor.pass.cpp35
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/param_eq.pass.cpp37
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/param_types.pass.cpp28
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/set_param.pass.cpp30
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/types.pass.cpp34
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/nothing_to_do.pass.cpp12
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/assign.pass.cpp34
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/copy.pass.cpp32
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/ctor_double.pass.cpp32
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/ctor_param.pass.cpp29
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/eq.pass.cpp37
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/eval.pass.cpp154
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/eval_param.pass.cpp75
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/get_param.pass.cpp29
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/io.pass.cpp41
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/max.pass.cpp28
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/min.pass.cpp27
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/param_assign.pass.cpp31
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/param_copy.pass.cpp30
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/param_ctor.pass.cpp35
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/param_eq.pass.cpp37
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/param_types.pass.cpp28
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/set_param.pass.cpp30
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/types.pass.cpp34
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/assign.pass.cpp34
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/copy.pass.cpp32
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/ctor_double_double.pass.cpp40
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/ctor_param.pass.cpp30
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/eq.pass.cpp37
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/eval.pass.cpp190
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/eval_param.pass.cpp194
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/get_param.pass.cpp29
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/io.pass.cpp41
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/max.pass.cpp28
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/min.pass.cpp27
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/param_assign.pass.cpp32
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/param_copy.pass.cpp31
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/param_ctor.pass.cpp44
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/param_eq.pass.cpp37
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/param_types.pass.cpp28
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/set_param.pass.cpp30
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/types.pass.cpp34
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/assign.pass.cpp34
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/copy.pass.cpp32
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/ctor_double_double.pass.cpp40
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/ctor_param.pass.cpp30
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/eq.pass.cpp37
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/eval.pass.cpp154
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/eval_param.pass.cpp157
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/get_param.pass.cpp29
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/io.pass.cpp41
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/max.pass.cpp28
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/min.pass.cpp27
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/param_assign.pass.cpp32
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/param_copy.pass.cpp31
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/param_ctor.pass.cpp44
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/param_eq.pass.cpp37
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/param_types.pass.cpp28
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/set_param.pass.cpp30
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/types.pass.cpp34
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/assign.pass.cpp34
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/copy.pass.cpp32
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/ctor_double.pass.cpp32
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/ctor_param.pass.cpp29
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/eq.pass.cpp37
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/eval.pass.cpp151
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/eval_param.pass.cpp157
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/get_param.pass.cpp29
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/io.pass.cpp41
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/max.pass.cpp28
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/min.pass.cpp27
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/param_assign.pass.cpp31
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/param_copy.pass.cpp30
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/param_ctor.pass.cpp35
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/param_eq.pass.cpp37
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/param_types.pass.cpp28
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/set_param.pass.cpp30
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/types.pass.cpp34
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/assign.pass.cpp34
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/copy.pass.cpp32
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/ctor_double_double.pass.cpp40
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/ctor_param.pass.cpp30
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/eq.pass.cpp37
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/eval.pass.cpp166
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/eval_param.pass.cpp169
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/get_param.pass.cpp29
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/io.pass.cpp41
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/max.pass.cpp28
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/min.pass.cpp27
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/param_assign.pass.cpp32
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/param_copy.pass.cpp31
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/param_ctor.pass.cpp44
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/param_eq.pass.cpp37
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/param_types.pass.cpp28
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/set_param.pass.cpp30
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/types.pass.cpp34
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.samp/nothing_to_do.pass.cpp12
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/assign.pass.cpp35
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/copy.pass.cpp33
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/ctor_default.pass.cpp29
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/ctor_func.pass.cpp60
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/ctor_init.pass.cpp81
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/ctor_iterator.pass.cpp87
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/ctor_param.pass.cpp33
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/eq.pass.cpp45
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/eval.pass.cpp279
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/eval_param.pass.cpp45
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/get_param.pass.cpp30
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/io.pass.cpp42
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/max.pass.cpp34
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/min.pass.cpp28
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_assign.pass.cpp32
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_copy.pass.cpp31
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_ctor_default.pass.cpp32
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_ctor_func.pass.cpp64
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_ctor_init.pass.cpp88
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_ctor_iterator.pass.cpp94
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_eq.pass.cpp39
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_types.pass.cpp28
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/set_param.pass.cpp31
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/types.pass.cpp32
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/assign.pass.cpp36
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/copy.pass.cpp34
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_default.pass.cpp35
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_func.pass.cpp64
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_init_func.pass.cpp78
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_iterator.pass.cpp96
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_param.pass.cpp41
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/eq.pass.cpp47
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/eval.pass.cpp695
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/eval_param.pass.cpp97
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/get_param.pass.cpp32
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/io.pass.cpp44
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/max.pass.cpp30
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/min.pass.cpp30
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_assign.pass.cpp34
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_copy.pass.cpp33
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_ctor_default.pass.cpp34
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_ctor_func.pass.cpp67
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_ctor_init_func.pass.cpp79
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_ctor_iterator.pass.cpp100
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_eq.pass.cpp41
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_types.pass.cpp28
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/set_param.pass.cpp32
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/types.pass.cpp32
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/assign.pass.cpp36
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/copy.pass.cpp34
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/ctor_default.pass.cpp36
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/ctor_func.pass.cpp69
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/ctor_init_func.pass.cpp82
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/ctor_iterator.pass.cpp101
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/ctor_param.pass.cpp42
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/eq.pass.cpp47
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/eval.pass.cpp343
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/eval_param.pass.cpp92
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/get_param.pass.cpp32
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/io.pass.cpp44
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/max.pass.cpp30
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/min.pass.cpp30
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_assign.pass.cpp34
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_copy.pass.cpp33
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_ctor_default.pass.cpp35
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_ctor_func.pass.cpp70
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_ctor_init_func.pass.cpp83
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_ctor_iterator.pass.cpp105
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_eq.pass.cpp41
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_types.pass.cpp28
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/set_param.pass.cpp32
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/types.pass.cpp32
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.uni/nothing_to_do.pass.cpp12
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/assign.pass.cpp34
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/copy.pass.cpp32
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/ctor_int_int.pass.cpp41
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/ctor_param.pass.cpp30
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/eq.pass.cpp37
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/eval.pass.cpp455
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/eval_param.pass.cpp75
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/get_param.pass.cpp29
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/io.pass.cpp41
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/max.pass.cpp27
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/min.pass.cpp27
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_assign.pass.cpp32
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_copy.pass.cpp31
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_ctor.pass.cpp44
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_eq.pass.cpp37
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_types.pass.cpp28
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/set_param.pass.cpp30
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/types.pass.cpp27
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/assign.pass.cpp34
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/copy.pass.cpp32
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/ctor_int_int.pass.cpp41
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/ctor_param.pass.cpp30
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/eq.pass.cpp37
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/eval.pass.cpp474
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/eval_param.pass.cpp74
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/get_param.pass.cpp29
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/io.pass.cpp41
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/max.pass.cpp27
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/min.pass.cpp27
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/param_assign.pass.cpp32
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/param_copy.pass.cpp31
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/param_ctor.pass.cpp44
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/param_eq.pass.cpp37
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/param_types.pass.cpp28
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/set_param.pass.cpp30
-rw-r--r--test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/types.pass.cpp27
-rw-r--r--test/std/numerics/rand/rand.eng/nothing_to_do.pass.cpp12
-rw-r--r--test/std/numerics/rand/rand.eng/rand.eng.lcong/assign.pass.cpp58
-rw-r--r--test/std/numerics/rand/rand.eng/rand.eng.lcong/copy.pass.cpp58
-rw-r--r--test/std/numerics/rand/rand.eng/rand.eng.lcong/ctor_result_type.pass.cpp154
-rw-r--r--test/std/numerics/rand/rand.eng/rand.eng.lcong/ctor_sseq.pass.cpp29
-rw-r--r--test/std/numerics/rand/rand.eng/rand.eng.lcong/default.pass.cpp57
-rw-r--r--test/std/numerics/rand/rand.eng/rand.eng.lcong/discard.pass.cpp73
-rw-r--r--test/std/numerics/rand/rand.eng/rand.eng.lcong/eval.pass.cpp87
-rw-r--r--test/std/numerics/rand/rand.eng/rand.eng.lcong/io.pass.cpp44
-rw-r--r--test/std/numerics/rand/rand.eng/rand.eng.lcong/result_type.pass.cpp37
-rw-r--r--test/std/numerics/rand/rand.eng/rand.eng.lcong/seed_result_type.pass.cpp40
-rw-r--r--test/std/numerics/rand/rand.eng/rand.eng.lcong/seed_sseq.pass.cpp39
-rw-r--r--test/std/numerics/rand/rand.eng/rand.eng.lcong/values.pass.cpp74
-rw-r--r--test/std/numerics/rand/rand.eng/rand.eng.mers/assign.pass.cpp58
-rw-r--r--test/std/numerics/rand/rand.eng/rand.eng.mers/copy.pass.cpp56
-rw-r--r--test/std/numerics/rand/rand.eng/rand.eng.mers/ctor_result_type.pass.cpp245
-rw-r--r--test/std/numerics/rand/rand.eng/rand.eng.mers/ctor_sseq.pass.cpp309
-rw-r--r--test/std/numerics/rand/rand.eng/rand.eng.mers/default.pass.cpp45
-rw-r--r--test/std/numerics/rand/rand.eng/rand.eng.mers/discard.pass.cpp55
-rw-r--r--test/std/numerics/rand/rand.eng/rand.eng.mers/eval.pass.cpp45
-rw-r--r--test/std/numerics/rand/rand.eng/rand.eng.mers/io.pass.cpp69
-rw-r--r--test/std/numerics/rand/rand.eng/rand.eng.mers/result_type.pass.cpp44
-rw-r--r--test/std/numerics/rand/rand.eng/rand.eng.mers/seed_result_type.pass.cpp52
-rw-r--r--test/std/numerics/rand/rand.eng/rand.eng.mers/seed_sseq.pass.cpp50
-rw-r--r--test/std/numerics/rand/rand.eng/rand.eng.mers/values.pass.cpp122
-rw-r--r--test/std/numerics/rand/rand.eng/rand.eng.sub/assign.pass.cpp56
-rw-r--r--test/std/numerics/rand/rand.eng/rand.eng.sub/copy.pass.cpp54
-rw-r--r--test/std/numerics/rand/rand.eng/rand.eng.sub/ctor_result_type.pass.cpp51
-rw-r--r--test/std/numerics/rand/rand.eng/rand.eng.sub/ctor_sseq.pass.cpp55
-rw-r--r--test/std/numerics/rand/rand.eng/rand.eng.sub/default.pass.cpp42
-rw-r--r--test/std/numerics/rand/rand.eng/rand.eng.sub/discard.pass.cpp52
-rw-r--r--test/std/numerics/rand/rand.eng/rand.eng.sub/eval.pass.cpp42
-rw-r--r--test/std/numerics/rand/rand.eng/rand.eng.sub/io.pass.cpp63
-rw-r--r--test/std/numerics/rand/rand.eng/rand.eng.sub/result_type.pass.cpp42
-rw-r--r--test/std/numerics/rand/rand.eng/rand.eng.sub/seed_result_type.pass.cpp50
-rw-r--r--test/std/numerics/rand/rand.eng/rand.eng.sub/seed_sseq.pass.cpp48
-rw-r--r--test/std/numerics/rand/rand.eng/rand.eng.sub/values.pass.cpp70
-rw-r--r--test/std/numerics/rand/rand.predef/default_random_engine.pass.cpp22
-rw-r--r--test/std/numerics/rand/rand.predef/knuth_b.pass.cpp22
-rw-r--r--test/std/numerics/rand/rand.predef/minstd_rand.pass.cpp23
-rw-r--r--test/std/numerics/rand/rand.predef/minstd_rand0.pass.cpp23
-rw-r--r--test/std/numerics/rand/rand.predef/mt19937.pass.cpp27
-rw-r--r--test/std/numerics/rand/rand.predef/mt19937_64.pass.cpp27
-rw-r--r--test/std/numerics/rand/rand.predef/ranlux24.pass.cpp22
-rw-r--r--test/std/numerics/rand/rand.predef/ranlux24_base.pass.cpp22
-rw-r--r--test/std/numerics/rand/rand.predef/ranlux48.pass.cpp22
-rw-r--r--test/std/numerics/rand/rand.predef/ranlux48_base.pass.cpp22
-rw-r--r--test/std/numerics/rand/rand.req/nothing_to_do.pass.cpp12
-rw-r--r--test/std/numerics/rand/rand.req/rand.req.adapt/nothing_to_do.pass.cpp12
-rw-r--r--test/std/numerics/rand/rand.req/rand.req.dst/nothing_to_do.pass.cpp12
-rw-r--r--test/std/numerics/rand/rand.req/rand.req.eng/nothing_to_do.pass.cpp12
-rw-r--r--test/std/numerics/rand/rand.req/rand.req.genl/nothing_to_do.pass.cpp12
-rw-r--r--test/std/numerics/rand/rand.req/rand.req.seedseq/nothing_to_do.pass.cpp12
-rw-r--r--test/std/numerics/rand/rand.req/rand.req.urng/nothing_to_do.pass.cpp12
-rw-r--r--test/std/numerics/rand/rand.synopsis/version.pass.cpp20
-rw-r--r--test/std/numerics/rand/rand.util/nothing_to_do.pass.cpp12
-rw-r--r--test/std/numerics/rand/rand.util/rand.util.canonical/generate_canonical.pass.cpp100
-rw-r--r--test/std/numerics/rand/rand.util/rand.util.seedseq/assign.fail.cpp23
-rw-r--r--test/std/numerics/rand/rand.util/rand.util.seedseq/copy.fail.cpp22
-rw-r--r--test/std/numerics/rand/rand.util/rand.util.seedseq/default.pass.cpp23
-rw-r--r--test/std/numerics/rand/rand.util/rand.util.seedseq/generate.pass.cpp805
-rw-r--r--test/std/numerics/rand/rand.util/rand.util.seedseq/initializer_list.pass.cpp33
-rw-r--r--test/std/numerics/rand/rand.util/rand.util.seedseq/iterator.pass.cpp32
-rw-r--r--test/std/numerics/rand/rand.util/rand.util.seedseq/types.pass.cpp24
-rw-r--r--test/std/re/nothing_to_do.pass.cpp12
-rw-r--r--test/std/re/re.alg/nothing_to_do.pass.cpp12
-rw-r--r--test/std/re/re.alg/re.alg.match/awk.pass.cpp1390
-rw-r--r--test/std/re/re.alg/re.alg.match/basic.fail.cpp36
-rw-r--r--test/std/re/re.alg/re.alg.match/basic.pass.cpp1367
-rw-r--r--test/std/re/re.alg/re.alg.match/ecma.pass.cpp1349
-rw-r--r--test/std/re/re.alg/re.alg.match/egrep.pass.cpp81
-rw-r--r--test/std/re/re.alg/re.alg.match/extended.pass.cpp1363
-rw-r--r--test/std/re/re.alg/re.alg.match/grep.pass.cpp49
-rw-r--r--test/std/re/re.alg/re.alg.match/lookahead_capture.pass.cpp98
-rw-r--r--test/std/re/re.alg/re.alg.match/parse_curly_brackets.pass.cpp72
-rw-r--r--test/std/re/re.alg/re.alg.replace/test1.pass.cpp107
-rw-r--r--test/std/re/re.alg/re.alg.replace/test2.pass.cpp107
-rw-r--r--test/std/re/re.alg/re.alg.replace/test3.pass.cpp73
-rw-r--r--test/std/re/re.alg/re.alg.replace/test4.pass.cpp72
-rw-r--r--test/std/re/re.alg/re.alg.replace/test5.pass.cpp73
-rw-r--r--test/std/re/re.alg/re.alg.replace/test6.pass.cpp73
-rw-r--r--test/std/re/re.alg/re.alg.search/awk.pass.cpp1574
-rw-r--r--test/std/re/re.alg/re.alg.search/backup.pass.cpp63
-rw-r--r--test/std/re/re.alg/re.alg.search/basic.fail.cpp36
-rw-r--r--test/std/re/re.alg/re.alg.search/basic.pass.cpp1547
-rw-r--r--test/std/re/re.alg/re.alg.search/ecma.pass.cpp1589
-rw-r--r--test/std/re/re.alg/re.alg.search/egrep.pass.cpp90
-rw-r--r--test/std/re/re.alg/re.alg.search/extended.pass.cpp1543
-rw-r--r--test/std/re/re.alg/re.alg.search/grep.pass.cpp58
-rw-r--r--test/std/re/re.alg/re.alg.search/lookahead.pass.cpp28
-rw-r--r--test/std/re/re.alg/re.alg.search/no_update_pos.pass.cpp38
-rw-r--r--test/std/re/re.alg/re.except/nothing_to_do.pass.cpp12
-rw-r--r--test/std/re/re.badexp/regex_error.pass.cpp96
-rw-r--r--test/std/re/re.const/nothing_to_do.pass.cpp13
-rw-r--r--test/std/re/re.const/re.err/error_type.pass.cpp143
-rw-r--r--test/std/re/re.const/re.matchflag/match_flag_type.pass.cpp128
-rw-r--r--test/std/re/re.const/re.matchflag/match_not_bol.pass.cpp50
-rw-r--r--test/std/re/re.const/re.matchflag/match_not_eol.pass.cpp50
-rw-r--r--test/std/re/re.const/re.synopt/syntax_option_type.pass.cpp114
-rw-r--r--test/std/re/re.def/defns.regex.collating.element/nothing_to_do.pass.cpp13
-rw-r--r--test/std/re/re.def/defns.regex.finite.state.machine/nothing_to_do.pass.cpp13
-rw-r--r--test/std/re/re.def/defns.regex.format.specifier/nothing_to_do.pass.cpp13
-rw-r--r--test/std/re/re.def/defns.regex.matched/nothing_to_do.pass.cpp13
-rw-r--r--test/std/re/re.def/defns.regex.primary.equivalence.class/nothing_to_do.pass.cpp13
-rw-r--r--test/std/re/re.def/defns.regex.regular.expression/nothing_to_do.pass.cpp13
-rw-r--r--test/std/re/re.def/defns.regex.subexpression/nothing_to_do.pass.cpp13
-rw-r--r--test/std/re/re.def/nothing_to_do.pass.cpp13
-rw-r--r--test/std/re/re.general/nothing_to_do.pass.cpp13
-rw-r--r--test/std/re/re.grammar/nothing_to_do.pass.cpp12
-rw-r--r--test/std/re/re.iter/nothing_to_do.pass.cpp12
-rw-r--r--test/std/re/re.iter/re.regiter/re.regiter.cnstr/cnstr.fail.cpp36
-rw-r--r--test/std/re/re.iter/re.regiter/re.regiter.cnstr/cnstr.pass.cpp44
-rw-r--r--test/std/re/re.iter/re.regiter/re.regiter.cnstr/default.pass.cpp32
-rw-r--r--test/std/re/re.iter/re.regiter/re.regiter.comp/tested_elsewhere.pass.cpp19
-rw-r--r--test/std/re/re.iter/re.regiter/re.regiter.deref/deref.pass.cpp42
-rw-r--r--test/std/re/re.iter/re.regiter/re.regiter.incr/post.pass.cpp97
-rw-r--r--test/std/re/re.iter/re.regiter/types.pass.cpp45
-rw-r--r--test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/array.fail.cpp39
-rw-r--r--test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/array.pass.cpp64
-rw-r--r--test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/default.pass.cpp32
-rw-r--r--test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/init.fail.cpp36
-rw-r--r--test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/init.pass.cpp64
-rw-r--r--test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/int.fail.cpp35
-rw-r--r--test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/int.pass.cpp75
-rw-r--r--test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/vector.fail.cpp40
-rw-r--r--test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/vector.pass.cpp128
-rw-r--r--test/std/re/re.iter/re.tokiter/re.tokiter.comp/equal.pass.cpp36
-rw-r--r--test/std/re/re.iter/re.tokiter/re.tokiter.deref/deref.pass.cpp72
-rw-r--r--test/std/re/re.iter/re.tokiter/re.tokiter.incr/post.pass.cpp135
-rw-r--r--test/std/re/re.iter/re.tokiter/types.pass.cpp45
-rw-r--r--test/std/re/re.regex/re.regex.assign/assign.il.pass.cpp33
-rw-r--r--test/std/re/re.regex/re.regex.assign/assign.pass.cpp35
-rw-r--r--test/std/re/re.regex/re.regex.assign/assign_iter_iter_flag.pass.cpp46
-rw-r--r--test/std/re/re.regex/re.regex.assign/assign_ptr_flag.pass.cpp29
-rw-r--r--test/std/re/re.regex/re.regex.assign/assign_ptr_size_flag.pass.cpp25
-rw-r--r--test/std/re/re.regex/re.regex.assign/assign_string_flag.pass.cpp31
-rw-r--r--test/std/re/re.regex/re.regex.assign/copy.pass.cpp26
-rw-r--r--test/std/re/re.regex/re.regex.assign/il.pass.cpp27
-rw-r--r--test/std/re/re.regex/re.regex.assign/ptr.pass.cpp25
-rw-r--r--test/std/re/re.regex/re.regex.assign/string.pass.cpp26
-rw-r--r--test/std/re/re.regex/re.regex.const/constants.pass.cpp65
-rw-r--r--test/std/re/re.regex/re.regex.construct/awk_oct.pass.cpp28
-rw-r--r--test/std/re/re.regex/re.regex.construct/bad_escape.pass.cpp45
-rw-r--r--test/std/re/re.regex/re.regex.construct/copy.pass.cpp25
-rw-r--r--test/std/re/re.regex/re.regex.construct/default.pass.cpp32
-rw-r--r--test/std/re/re.regex/re.regex.construct/il_flg.pass.cpp70
-rw-r--r--test/std/re/re.regex/re.regex.construct/iter_iter.pass.cpp43
-rw-r--r--test/std/re/re.regex/re.regex.construct/iter_iter_flg.pass.cpp69
-rw-r--r--test/std/re/re.regex/re.regex.construct/ptr.pass.cpp34
-rw-r--r--test/std/re/re.regex/re.regex.construct/ptr_flg.pass.cpp59
-rw-r--r--test/std/re/re.regex/re.regex.construct/ptr_size_flg.pass.cpp60
-rw-r--r--test/std/re/re.regex/re.regex.construct/string.pass.cpp35
-rw-r--r--test/std/re/re.regex/re.regex.construct/string_flg.pass.cpp61
-rw-r--r--test/std/re/re.regex/re.regex.locale/imbue.pass.cpp31
-rw-r--r--test/std/re/re.regex/re.regex.nonmemb/nothing_to_do.pass.cpp12
-rw-r--r--test/std/re/re.regex/re.regex.nonmemb/re.regex.nmswap/swap.pass.cpp29
-rw-r--r--test/std/re/re.regex/re.regex.operations/tested_elsewhere.pass.cpp12
-rw-r--r--test/std/re/re.regex/re.regex.swap/swap.pass.cpp28
-rw-r--r--test/std/re/re.regex/types.pass.cpp35
-rw-r--r--test/std/re/re.req/nothing_to_do.pass.cpp13
-rw-r--r--test/std/re/re.results/re.results.acc/begin_end.pass.cpp38
-rw-r--r--test/std/re/re.results/re.results.acc/cbegin_cend.pass.cpp38
-rw-r--r--test/std/re/re.results/re.results.acc/index.pass.cpp53
-rw-r--r--test/std/re/re.results/re.results.acc/length.pass.cpp36
-rw-r--r--test/std/re/re.results/re.results.acc/position.pass.cpp36
-rw-r--r--test/std/re/re.results/re.results.acc/prefix.pass.cpp34
-rw-r--r--test/std/re/re.results/re.results.acc/str.pass.cpp36
-rw-r--r--test/std/re/re.results/re.results.acc/suffix.pass.cpp34
-rw-r--r--test/std/re/re.results/re.results.all/get_allocator.pass.cpp35
-rw-r--r--test/std/re/re.results/re.results.const/allocator.pass.cpp35
-rw-r--r--test/std/re/re.results/re.results.const/default.pass.cpp33
-rw-r--r--test/std/re/re.results/re.results.form/form1.pass.cpp103
-rw-r--r--test/std/re/re.results/re.results.form/form2.pass.cpp102
-rw-r--r--test/std/re/re.results/re.results.form/form3.pass.cpp85
-rw-r--r--test/std/re/re.results/re.results.form/form4.pass.cpp80
-rw-r--r--test/std/re/re.results/re.results.nonmember/equal.pass.cpp46
-rw-r--r--test/std/re/re.results/re.results.size/empty.pass.cpp36
-rw-r--r--test/std/re/re.results/re.results.size/max_size.pass.cpp31
-rw-r--r--test/std/re/re.results/re.results.state/ready.pass.cpp43
-rw-r--r--test/std/re/re.results/re.results.swap/member_swap.pass.cpp39
-rw-r--r--test/std/re/re.results/re.results.swap/non_member_swap.pass.cpp41
-rw-r--r--test/std/re/re.results/types.pass.cpp51
-rw-r--r--test/std/re/re.submatch/re.submatch.members/compare_string_type.pass.cpp49
-rw-r--r--test/std/re/re.submatch/re.submatch.members/compare_sub_match.pass.cpp53
-rw-r--r--test/std/re/re.submatch/re.submatch.members/compare_value_type_ptr.pass.cpp47
-rw-r--r--test/std/re/re.submatch/re.submatch.members/default.pass.cpp33
-rw-r--r--test/std/re/re.submatch/re.submatch.members/length.pass.cpp43
-rw-r--r--test/std/re/re.submatch/re.submatch.members/operator_string.pass.cpp47
-rw-r--r--test/std/re/re.submatch/re.submatch.members/str.pass.cpp47
-rw-r--r--test/std/re/re.submatch/re.submatch.op/compare.pass.cpp287
-rw-r--r--test/std/re/re.submatch/re.submatch.op/stream.pass.cpp42
-rw-r--r--test/std/re/re.submatch/types.pass.cpp64
-rw-r--r--test/std/re/re.syn/cmatch.pass.cpp20
-rw-r--r--test/std/re/re.syn/cregex_iterator.pass.cpp20
-rw-r--r--test/std/re/re.syn/cregex_token_iterator.pass.cpp20
-rw-r--r--test/std/re/re.syn/csub_match.pass.cpp20
-rw-r--r--test/std/re/re.syn/regex.pass.cpp20
-rw-r--r--test/std/re/re.syn/smatch.pass.cpp20
-rw-r--r--test/std/re/re.syn/sregex_iterator.pass.cpp20
-rw-r--r--test/std/re/re.syn/sregex_token_iterator.pass.cpp20
-rw-r--r--test/std/re/re.syn/ssub_match.pass.cpp20
-rw-r--r--test/std/re/re.syn/wcmatch.pass.cpp20
-rw-r--r--test/std/re/re.syn/wcregex_iterator.pass.cpp20
-rw-r--r--test/std/re/re.syn/wcregex_token_iterator.pass.cpp20
-rw-r--r--test/std/re/re.syn/wcsub_match.pass.cpp20
-rw-r--r--test/std/re/re.syn/wregex.pass.cpp20
-rw-r--r--test/std/re/re.syn/wsmatch.pass.cpp20
-rw-r--r--test/std/re/re.syn/wsregex_iterator.pass.cpp20
-rw-r--r--test/std/re/re.syn/wsregex_token_iterator.pass.cpp20
-rw-r--r--test/std/re/re.syn/wssub_match.pass.cpp20
-rw-r--r--test/std/re/re.traits/default.pass.cpp37
-rw-r--r--test/std/re/re.traits/getloc.pass.cpp36
-rw-r--r--test/std/re/re.traits/imbue.pass.cpp30
-rw-r--r--test/std/re/re.traits/isctype.pass.cpp279
-rw-r--r--test/std/re/re.traits/length.pass.cpp31
-rw-r--r--test/std/re/re.traits/lookup_classname.pass.cpp211
-rw-r--r--test/std/re/re.traits/lookup_collatename.pass.cpp192
-rw-r--r--test/std/re/re.traits/transform.pass.cpp46
-rw-r--r--test/std/re/re.traits/transform_primary.pass.cpp51
-rw-r--r--test/std/re/re.traits/translate.pass.cpp34
-rw-r--r--test/std/re/re.traits/translate_nocase.pass.cpp72
-rw-r--r--test/std/re/re.traits/types.pass.cpp32
-rw-r--r--test/std/re/re.traits/value.pass.cpp125
-rw-r--r--test/std/strings/basic.string.hash/strings.pass.cpp48
-rw-r--r--test/std/strings/basic.string.literals/literal.pass.cpp47
-rw-r--r--test/std/strings/basic.string.literals/literal1.fail.cpp22
-rw-r--r--test/std/strings/basic.string.literals/literal1.pass.cpp20
-rw-r--r--test/std/strings/basic.string.literals/literal2.fail.cpp20
-rw-r--r--test/std/strings/basic.string.literals/literal2.pass.cpp20
-rw-r--r--test/std/strings/basic.string.literals/literal3.pass.cpp20
-rw-r--r--test/std/strings/basic.string/input_iterator.h41
-rw-r--r--test/std/strings/basic.string/string.access/at.pass.cpp58
-rw-r--r--test/std/strings/basic.string/string.access/back.pass.cpp56
-rw-r--r--test/std/strings/basic.string/string.access/db_back.pass.cpp54
-rw-r--r--test/std/strings/basic.string/string.access/db_cback.pass.cpp50
-rw-r--r--test/std/strings/basic.string/string.access/db_cfront.pass.cpp50
-rw-r--r--test/std/strings/basic.string/string.access/db_cindex.pass.cpp52
-rw-r--r--test/std/strings/basic.string/string.access/db_front.pass.cpp54
-rw-r--r--test/std/strings/basic.string/string.access/db_index.pass.cpp52
-rw-r--r--test/std/strings/basic.string/string.access/front.pass.cpp56
-rw-r--r--test/std/strings/basic.string/string.access/index.pass.cpp63
-rw-r--r--test/std/strings/basic.string/string.capacity/capacity.pass.cpp58
-rw-r--r--test/std/strings/basic.string/string.capacity/clear.pass.cpp57
-rw-r--r--test/std/strings/basic.string/string.capacity/empty.pass.cpp42
-rw-r--r--test/std/strings/basic.string/string.capacity/length.pass.cpp42
-rw-r--r--test/std/strings/basic.string/string.capacity/max_size.pass.cpp73
-rw-r--r--test/std/strings/basic.string/string.capacity/over_max_size.pass.cpp47
-rw-r--r--test/std/strings/basic.string/string.capacity/reserve.pass.cpp117
-rw-r--r--test/std/strings/basic.string/string.capacity/resize_size.pass.cpp79
-rw-r--r--test/std/strings/basic.string/string.capacity/resize_size_char.pass.cpp79
-rw-r--r--test/std/strings/basic.string/string.capacity/shrink_to_fit.pass.cpp62
-rw-r--r--test/std/strings/basic.string/string.capacity/size.pass.cpp42
-rw-r--r--test/std/strings/basic.string/string.cons/alloc.pass.cpp95
-rw-r--r--test/std/strings/basic.string/string.cons/char_assignment.pass.cpp49
-rw-r--r--test/std/strings/basic.string/string.cons/copy.pass.cpp49
-rw-r--r--test/std/strings/basic.string/string.cons/copy_alloc.pass.cpp49
-rw-r--r--test/std/strings/basic.string/string.cons/copy_assignment.pass.cpp70
-rw-r--r--test/std/strings/basic.string/string.cons/default_noexcept.pass.cpp46
-rw-r--r--test/std/strings/basic.string/string.cons/dtor_noexcept.pass.cpp47
-rw-r--r--test/std/strings/basic.string/string.cons/initializer_list.pass.cpp46
-rw-r--r--test/std/strings/basic.string/string.cons/initializer_list_assignment.pass.cpp36
-rw-r--r--test/std/strings/basic.string/string.cons/iter_alloc.pass.cpp119
-rw-r--r--test/std/strings/basic.string/string.cons/move.pass.cpp57
-rw-r--r--test/std/strings/basic.string/string.cons/move_alloc.pass.cpp89
-rw-r--r--test/std/strings/basic.string/string.cons/move_assign_noexcept.pass.cpp47
-rw-r--r--test/std/strings/basic.string/string.cons/move_assignment.pass.cpp79
-rw-r--r--test/std/strings/basic.string/string.cons/move_noexcept.pass.cpp50
-rw-r--r--test/std/strings/basic.string/string.cons/pointer_alloc.pass.cpp89
-rw-r--r--test/std/strings/basic.string/string.cons/pointer_assignment.pass.cpp72
-rw-r--r--test/std/strings/basic.string/string.cons/pointer_size_alloc.pass.cpp87
-rw-r--r--test/std/strings/basic.string/string.cons/size_char_alloc.pass.cpp128
-rw-r--r--test/std/strings/basic.string/string.cons/substr.pass.cpp173
-rw-r--r--test/std/strings/basic.string/string.iterators/begin.pass.cpp48
-rw-r--r--test/std/strings/basic.string/string.iterators/cbegin.pass.cpp45
-rw-r--r--test/std/strings/basic.string/string.iterators/cend.pass.cpp41
-rw-r--r--test/std/strings/basic.string/string.iterators/crbegin.pass.cpp45
-rw-r--r--test/std/strings/basic.string/string.iterators/crend.pass.cpp41
-rw-r--r--test/std/strings/basic.string/string.iterators/db_iterators_2.pass.cpp52
-rw-r--r--test/std/strings/basic.string/string.iterators/db_iterators_3.pass.cpp52
-rw-r--r--test/std/strings/basic.string/string.iterators/db_iterators_4.pass.cpp54
-rw-r--r--test/std/strings/basic.string/string.iterators/db_iterators_5.pass.cpp58
-rw-r--r--test/std/strings/basic.string/string.iterators/db_iterators_6.pass.cpp56
-rw-r--r--test/std/strings/basic.string/string.iterators/db_iterators_7.pass.cpp56
-rw-r--r--test/std/strings/basic.string/string.iterators/db_iterators_8.pass.cpp52
-rw-r--r--test/std/strings/basic.string/string.iterators/end.pass.cpp50
-rw-r--r--test/std/strings/basic.string/string.iterators/iterators.pass.cpp73
-rw-r--r--test/std/strings/basic.string/string.iterators/rbegin.pass.cpp48
-rw-r--r--test/std/strings/basic.string/string.iterators/rend.pass.cpp50
-rw-r--r--test/std/strings/basic.string/string.modifiers/nothing_to_do.pass.cpp12
-rw-r--r--test/std/strings/basic.string/string.modifiers/string_append/initializer_list.pass.cpp36
-rw-r--r--test/std/strings/basic.string/string.modifiers/string_append/iterator.pass.cpp150
-rw-r--r--test/std/strings/basic.string/string.modifiers/string_append/pointer.pass.cpp63
-rw-r--r--test/std/strings/basic.string/string.modifiers/string_append/pointer_size.pass.cpp72
-rw-r--r--test/std/strings/basic.string/string.modifiers/string_append/push_back.pass.cpp44
-rw-r--r--test/std/strings/basic.string/string.modifiers/string_append/size_char.pass.cpp63
-rw-r--r--test/std/strings/basic.string/string.modifiers/string_append/string.pass.cpp79
-rw-r--r--test/std/strings/basic.string/string.modifiers/string_append/string_size_size.pass.cpp118
-rw-r--r--test/std/strings/basic.string/string.modifiers/string_assign/initializer_list.pass.cpp36
-rw-r--r--test/std/strings/basic.string/string.modifiers/string_assign/iterator.pass.cpp150
-rw-r--r--test/std/strings/basic.string/string.modifiers/string_assign/pointer.pass.cpp63
-rw-r--r--test/std/strings/basic.string/string.modifiers/string_assign/pointer_size.pass.cpp72
-rw-r--r--test/std/strings/basic.string/string.modifiers/string_assign/rv_string.pass.cpp80
-rw-r--r--test/std/strings/basic.string/string.modifiers/string_assign/size_char.pass.cpp63
-rw-r--r--test/std/strings/basic.string/string.modifiers/string_assign/string.pass.cpp79
-rw-r--r--test/std/strings/basic.string/string.modifiers/string_assign/string_size_size.pass.cpp118
-rw-r--r--test/std/strings/basic.string/string.modifiers/string_copy/copy.pass.cpp170
-rw-r--r--test/std/strings/basic.string/string.modifiers/string_erase/erase_iter_db1.pass.cpp50
-rw-r--r--test/std/strings/basic.string/string.modifiers/string_erase/erase_iter_db2.pass.cpp52
-rw-r--r--test/std/strings/basic.string/string.modifiers/string_erase/erase_iter_iter_db1.pass.cpp50
-rw-r--r--test/std/strings/basic.string/string.modifiers/string_erase/erase_iter_iter_db2.pass.cpp50
-rw-r--r--test/std/strings/basic.string/string.modifiers/string_erase/erase_iter_iter_db3.pass.cpp50
-rw-r--r--test/std/strings/basic.string/string.modifiers/string_erase/erase_iter_iter_db4.pass.cpp48
-rw-r--r--test/std/strings/basic.string/string.modifiers/string_erase/iter.pass.cpp64
-rw-r--r--test/std/strings/basic.string/string.modifiers/string_erase/iter_iter.pass.cpp149
-rw-r--r--test/std/strings/basic.string/string.modifiers/string_erase/pop_back.pass.cpp55
-rw-r--r--test/std/strings/basic.string/string.modifiers/string_erase/size_size.pass.cpp280
-rw-r--r--test/std/strings/basic.string/string.modifiers/string_insert/iter_char.pass.cpp88
-rw-r--r--test/std/strings/basic.string/string.modifiers/string_insert/iter_initializer_list.pass.cpp50
-rw-r--r--test/std/strings/basic.string/string.modifiers/string_insert/iter_iter_iter.pass.cpp140
-rw-r--r--test/std/strings/basic.string/string.modifiers/string_insert/iter_size_char.pass.cpp181
-rw-r--r--test/std/strings/basic.string/string.modifiers/string_insert/size_pointer.pass.cpp211
-rw-r--r--test/std/strings/basic.string/string.modifiers/string_insert/size_pointer_size.pass.cpp692
-rw-r--r--test/std/strings/basic.string/string.modifiers/string_insert/size_size_char.pass.cpp212
-rw-r--r--test/std/strings/basic.string/string.modifiers/string_insert/size_string.pass.cpp211
-rw-r--r--test/std/strings/basic.string/string.modifiers/string_insert/size_string_size_size.pass.cpp1784
-rw-r--r--test/std/strings/basic.string/string.modifiers/string_op_plus_equal/char.pass.cpp46
-rw-r--r--test/std/strings/basic.string/string.modifiers/string_op_plus_equal/initializer_list.pass.cpp36
-rw-r--r--test/std/strings/basic.string/string.modifiers/string_op_plus_equal/pointer.pass.cpp78
-rw-r--r--test/std/strings/basic.string/string.modifiers/string_op_plus_equal/string.pass.cpp79
-rw-r--r--test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_initializer_list.pass.cpp36
-rw-r--r--test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_iter_iter.pass.cpp976
-rw-r--r--test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_pointer.pass.cpp285
-rw-r--r--test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_pointer_size.pass.cpp976
-rw-r--r--test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_size_char.pass.cpp286
-rw-r--r--test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_string.pass.cpp285
-rw-r--r--test/std/strings/basic.string/string.modifiers/string_replace/size_size_pointer.pass.cpp375
-rw-r--r--test/std/strings/basic.string/string.modifiers/string_replace/size_size_pointer_size.pass.cpp1327
-rw-r--r--test/std/strings/basic.string/string.modifiers/string_replace/size_size_size_char.pass.cpp374
-rw-r--r--test/std/strings/basic.string/string.modifiers/string_replace/size_size_string.pass.cpp372
-rw-r--r--test/std/strings/basic.string/string.modifiers/string_replace/size_size_string_size_size.pass.cpp5966
-rw-r--r--test/std/strings/basic.string/string.modifiers/string_swap/swap.pass.cpp76
-rw-r--r--test/std/strings/basic.string/string.nonmembers/nothing_to_do.pass.cpp12
-rw-r--r--test/std/strings/basic.string/string.nonmembers/string.io/get_line.pass.cpp81
-rw-r--r--test/std/strings/basic.string/string.nonmembers/string.io/get_line_delim.pass.cpp93
-rw-r--r--test/std/strings/basic.string/string.nonmembers/string.io/get_line_delim_rv.pass.cpp51
-rw-r--r--test/std/strings/basic.string/string.nonmembers/string.io/get_line_rv.pass.cpp51
-rw-r--r--test/std/strings/basic.string/string.nonmembers/string.io/stream_extract.pass.cpp117
-rw-r--r--test/std/strings/basic.string/string.nonmembers/string.io/stream_insert.pass.cpp91
-rw-r--r--test/std/strings/basic.string/string.nonmembers/string.special/swap.pass.cpp78
-rw-r--r--test/std/strings/basic.string/string.nonmembers/string.special/swap_noexcept.pass.cpp85
-rw-r--r--test/std/strings/basic.string/string.nonmembers/string_op!=/pointer_string.pass.cpp69
-rw-r--r--test/std/strings/basic.string/string.nonmembers/string_op!=/string_pointer.pass.cpp69
-rw-r--r--test/std/strings/basic.string/string.nonmembers/string_op!=/string_string.pass.cpp70
-rw-r--r--test/std/strings/basic.string/string.nonmembers/string_op+/char_string.pass.cpp80
-rw-r--r--test/std/strings/basic.string/string.nonmembers/string_op+/pointer_string.pass.cpp128
-rw-r--r--test/std/strings/basic.string/string.nonmembers/string_op+/string_char.pass.cpp80
-rw-r--r--test/std/strings/basic.string/string.nonmembers/string_op+/string_pointer.pass.cpp128
-rw-r--r--test/std/strings/basic.string/string.nonmembers/string_op+/string_string.pass.cpp222
-rw-r--r--test/std/strings/basic.string/string.nonmembers/string_operator==/pointer_string.pass.cpp69
-rw-r--r--test/std/strings/basic.string/string.nonmembers/string_operator==/string_pointer.pass.cpp69
-rw-r--r--test/std/strings/basic.string/string.nonmembers/string_operator==/string_string.pass.cpp70
-rw-r--r--test/std/strings/basic.string/string.nonmembers/string_opgt/pointer_string.pass.cpp69
-rw-r--r--test/std/strings/basic.string/string.nonmembers/string_opgt/string_pointer.pass.cpp69
-rw-r--r--test/std/strings/basic.string/string.nonmembers/string_opgt/string_string.pass.cpp70
-rw-r--r--test/std/strings/basic.string/string.nonmembers/string_opgt=/pointer_string.pass.cpp69
-rw-r--r--test/std/strings/basic.string/string.nonmembers/string_opgt=/string_pointer.pass.cpp69
-rw-r--r--test/std/strings/basic.string/string.nonmembers/string_opgt=/string_string.pass.cpp70
-rw-r--r--test/std/strings/basic.string/string.nonmembers/string_oplt/pointer_string.pass.cpp69
-rw-r--r--test/std/strings/basic.string/string.nonmembers/string_oplt/string_pointer.pass.cpp69
-rw-r--r--test/std/strings/basic.string/string.nonmembers/string_oplt/string_string.pass.cpp70
-rw-r--r--test/std/strings/basic.string/string.nonmembers/string_oplt=/pointer_string.pass.cpp69
-rw-r--r--test/std/strings/basic.string/string.nonmembers/string_oplt=/string_pointer.pass.cpp69
-rw-r--r--test/std/strings/basic.string/string.nonmembers/string_oplt=/string_string.pass.cpp70
-rw-r--r--test/std/strings/basic.string/string.ops/nothing_to_do.pass.cpp12
-rw-r--r--test/std/strings/basic.string/string.ops/string.accessors/c_str.pass.cpp52
-rw-r--r--test/std/strings/basic.string/string.ops/string.accessors/data.pass.cpp52
-rw-r--r--test/std/strings/basic.string/string.ops/string.accessors/get_allocator.pass.cpp47
-rw-r--r--test/std/strings/basic.string/string.ops/string_compare/pointer.pass.cpp77
-rw-r--r--test/std/strings/basic.string/string.ops/string_compare/size_size_pointer.pass.cpp372
-rw-r--r--test/std/strings/basic.string/string.ops/string_compare/size_size_pointer_size.pass.cpp1323
-rw-r--r--test/std/strings/basic.string/string.ops/string_compare/size_size_string.pass.cpp372
-rw-r--r--test/std/strings/basic.string/string.ops/string_compare/size_size_string_size_size.pass.cpp5948
-rw-r--r--test/std/strings/basic.string/string.ops/string_compare/string.pass.cpp77
-rw-r--r--test/std/strings/basic.string/string.ops/string_find.first.not.of/char_size.pass.cpp102
-rw-r--r--test/std/strings/basic.string/string.ops/string_find.first.not.of/pointer_size.pass.cpp158
-rw-r--r--test/std/strings/basic.string/string.ops/string_find.first.not.of/pointer_size_size.pass.cpp387
-rw-r--r--test/std/strings/basic.string/string.ops/string_find.first.not.of/string_size.pass.cpp157
-rw-r--r--test/std/strings/basic.string/string.ops/string_find.first.of/char_size.pass.cpp98
-rw-r--r--test/std/strings/basic.string/string.ops/string_find.first.of/pointer_size.pass.cpp158
-rw-r--r--test/std/strings/basic.string/string.ops/string_find.first.of/pointer_size_size.pass.cpp387
-rw-r--r--test/std/strings/basic.string/string.ops/string_find.first.of/string_size.pass.cpp157
-rw-r--r--test/std/strings/basic.string/string.ops/string_find.last.not.of/char_size.pass.cpp98
-rw-r--r--test/std/strings/basic.string/string.ops/string_find.last.not.of/pointer_size.pass.cpp158
-rw-r--r--test/std/strings/basic.string/string.ops/string_find.last.not.of/pointer_size_size.pass.cpp387
-rw-r--r--test/std/strings/basic.string/string.ops/string_find.last.not.of/string_size.pass.cpp157
-rw-r--r--test/std/strings/basic.string/string.ops/string_find.last.of/char_size.pass.cpp98
-rw-r--r--test/std/strings/basic.string/string.ops/string_find.last.of/pointer_size.pass.cpp158
-rw-r--r--test/std/strings/basic.string/string.ops/string_find.last.of/pointer_size_size.pass.cpp387
-rw-r--r--test/std/strings/basic.string/string.ops/string_find.last.of/string_size.pass.cpp157
-rw-r--r--test/std/strings/basic.string/string.ops/string_find/char_size.pass.cpp98
-rw-r--r--test/std/strings/basic.string/string.ops/string_find/pointer_size.pass.cpp164
-rw-r--r--test/std/strings/basic.string/string.ops/string_find/pointer_size_size.pass.cpp387
-rw-r--r--test/std/strings/basic.string/string.ops/string_find/string_size.pass.cpp157
-rw-r--r--test/std/strings/basic.string/string.ops/string_rfind/char_size.pass.cpp98
-rw-r--r--test/std/strings/basic.string/string.ops/string_rfind/pointer_size.pass.cpp165
-rw-r--r--test/std/strings/basic.string/string.ops/string_rfind/pointer_size_size.pass.cpp387
-rw-r--r--test/std/strings/basic.string/string.ops/string_rfind/string_size.pass.cpp157
-rw-r--r--test/std/strings/basic.string/string.ops/string_substr/substr.pass.cpp166
-rw-r--r--test/std/strings/basic.string/string.require/contiguous.pass.cpp53
-rw-r--r--test/std/strings/basic.string/test_traits.h19
-rw-r--r--test/std/strings/basic.string/types.pass.cpp85
-rw-r--r--test/std/strings/c.strings/cctype.pass.cpp103
-rw-r--r--test/std/strings/c.strings/cstring.pass.cpp55
-rw-r--r--test/std/strings/c.strings/cuchar.pass.cpp18
-rw-r--r--test/std/strings/c.strings/cwchar.pass.cpp115
-rw-r--r--test/std/strings/c.strings/cwctype.pass.cpp114
-rw-r--r--test/std/strings/c.strings/version_cctype.pass.cpp20
-rw-r--r--test/std/strings/c.strings/version_cstring.pass.cpp20
-rw-r--r--test/std/strings/c.strings/version_cuchar.pass.cpp22
-rw-r--r--test/std/strings/c.strings/version_cwchar.pass.cpp20
-rw-r--r--test/std/strings/c.strings/version_cwctype.pass.cpp20
-rw-r--r--test/std/strings/char.traits/char.traits.require/nothing_to_do.pass.cpp12
-rw-r--r--test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/assign2.pass.cpp24
-rw-r--r--test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/assign3.pass.cpp28
-rw-r--r--test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/compare.pass.cpp41
-rw-r--r--test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/copy.pass.cpp29
-rw-r--r--test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/eof.pass.cpp22
-rw-r--r--test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/eq.pass.cpp24
-rw-r--r--test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/eq_int_type.pass.cpp26
-rw-r--r--test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/find.pass.cpp28
-rw-r--r--test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/length.pass.cpp26
-rw-r--r--test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/lt.pass.cpp28
-rw-r--r--test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/move.pass.cpp33
-rw-r--r--test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/not_eof.pass.cpp26
-rw-r--r--test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/to_char_type.pass.cpp24
-rw-r--r--test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/to_int_type.pass.cpp24
-rw-r--r--test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/types.pass.cpp30
-rw-r--r--test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/assign2.pass.cpp28
-rw-r--r--test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/assign3.pass.cpp30
-rw-r--r--test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/compare.pass.cpp45
-rw-r--r--test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/copy.pass.cpp31
-rw-r--r--test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/eof.pass.cpp24
-rw-r--r--test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/eq.pass.cpp28
-rw-r--r--test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/eq_int_type.pass.cpp30
-rw-r--r--test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/find.pass.cpp30
-rw-r--r--test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/length.pass.cpp30
-rw-r--r--test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/lt.pass.cpp28
-rw-r--r--test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/move.pass.cpp35
-rw-r--r--test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/not_eof.pass.cpp30
-rw-r--r--test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/to_char_type.pass.cpp28
-rw-r--r--test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/to_int_type.pass.cpp28
-rw-r--r--test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/types.pass.cpp33
-rw-r--r--test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/assign2.pass.cpp28
-rw-r--r--test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/assign3.pass.cpp30
-rw-r--r--test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/compare.pass.cpp45
-rw-r--r--test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/copy.pass.cpp31
-rw-r--r--test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/eof.pass.cpp24
-rw-r--r--test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/eq.pass.cpp28
-rw-r--r--test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/eq_int_type.pass.cpp30
-rw-r--r--test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/find.pass.cpp30
-rw-r--r--test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/length.pass.cpp30
-rw-r--r--test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/lt.pass.cpp28
-rw-r--r--test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/move.pass.cpp35
-rw-r--r--test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/not_eof.pass.cpp30
-rw-r--r--test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/to_char_type.pass.cpp28
-rw-r--r--test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/to_int_type.pass.cpp28
-rw-r--r--test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/types.pass.cpp33
-rw-r--r--test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/assign2.pass.cpp24
-rw-r--r--test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/assign3.pass.cpp28
-rw-r--r--test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/compare.pass.cpp41
-rw-r--r--test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/copy.pass.cpp29
-rw-r--r--test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/eof.pass.cpp22
-rw-r--r--test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/eq.pass.cpp24
-rw-r--r--test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/eq_int_type.pass.cpp26
-rw-r--r--test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/find.pass.cpp28
-rw-r--r--test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/length.pass.cpp26
-rw-r--r--test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/lt.pass.cpp24
-rw-r--r--test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/move.pass.cpp33
-rw-r--r--test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/not_eof.pass.cpp26
-rw-r--r--test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/to_char_type.pass.cpp24
-rw-r--r--test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/to_int_type.pass.cpp24
-rw-r--r--test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/types.pass.cpp30
-rw-r--r--test/std/strings/char.traits/char.traits.specializations/nothing_to_do.pass.cpp12
-rw-r--r--test/std/strings/char.traits/char.traits.typedefs/nothing_to_do.pass.cpp12
-rw-r--r--test/std/strings/char.traits/nothing_to_do.pass.cpp12
-rw-r--r--test/std/strings/string.classes/typedefs.pass.cpp30
-rw-r--r--test/std/strings/string.conversions/stod.pass.cpp166
-rw-r--r--test/std/strings/string.conversions/stof.pass.cpp170
-rw-r--r--test/std/strings/string.conversions/stoi.pass.cpp108
-rw-r--r--test/std/strings/string.conversions/stol.pass.cpp111
-rw-r--r--test/std/strings/string.conversions/stold.pass.cpp168
-rw-r--r--test/std/strings/string.conversions/stoll.pass.cpp110
-rw-r--r--test/std/strings/string.conversions/stoul.pass.cpp109
-rw-r--r--test/std/strings/string.conversions/stoull.pass.cpp110
-rw-r--r--test/std/strings/string.conversions/to_string.pass.cpp126
-rw-r--r--test/std/strings/string.conversions/to_wstring.pass.cpp126
-rw-r--r--test/std/strings/strings.general/nothing_to_do.pass.cpp13
-rw-r--r--test/std/strings/version.pass.cpp20
-rw-r--r--test/std/thread/futures/futures.async/async.pass.cpp198
-rw-r--r--test/std/thread/futures/futures.async/async_race.pass.cpp67
-rw-r--r--test/std/thread/futures/futures.errors/default_error_condition.pass.cpp27
-rw-r--r--test/std/thread/futures/futures.errors/equivalent_error_code_int.pass.cpp26
-rw-r--r--test/std/thread/futures/futures.errors/equivalent_int_error_condition.pass.cpp27
-rw-r--r--test/std/thread/futures/futures.errors/future_category.pass.cpp24
-rw-r--r--test/std/thread/futures/futures.errors/make_error_code.pass.cpp28
-rw-r--r--test/std/thread/futures/futures.errors/make_error_condition.pass.cpp30
-rw-r--r--test/std/thread/futures/futures.future_error/code.pass.cpp43
-rw-r--r--test/std/thread/futures/futures.future_error/types.pass.cpp23
-rw-r--r--test/std/thread/futures/futures.future_error/what.pass.cpp50
-rw-r--r--test/std/thread/futures/futures.overview/future_errc.pass.cpp30
-rw-r--r--test/std/thread/futures/futures.overview/future_status.pass.cpp28
-rw-r--r--test/std/thread/futures/futures.overview/is_error_code_enum_future_errc.pass.cpp21
-rw-r--r--test/std/thread/futures/futures.overview/launch.pass.cpp45
-rw-r--r--test/std/thread/futures/futures.promise/alloc_ctor.pass.cpp84
-rw-r--r--test/std/thread/futures/futures.promise/copy_assign.fail.cpp87
-rw-r--r--test/std/thread/futures/futures.promise/copy_ctor.fail.cpp81
-rw-r--r--test/std/thread/futures/futures.promise/default.pass.cpp38
-rw-r--r--test/std/thread/futures/futures.promise/dtor.pass.cpp116
-rw-r--r--test/std/thread/futures/futures.promise/get_future.pass.cpp55
-rw-r--r--test/std/thread/futures/futures.promise/move_assign.pass.cpp91
-rw-r--r--test/std/thread/futures/futures.promise/move_ctor.pass.cpp85
-rw-r--r--test/std/thread/futures/futures.promise/set_exception.pass.cpp47
-rw-r--r--test/std/thread/futures/futures.promise/set_exception_at_thread_exit.pass.cpp44
-rw-r--r--test/std/thread/futures/futures.promise/set_lvalue.pass.cpp43
-rw-r--r--test/std/thread/futures/futures.promise/set_lvalue_at_thread_exit.pass.cpp38
-rw-r--r--test/std/thread/futures/futures.promise/set_rvalue.pass.cpp69
-rw-r--r--test/std/thread/futures/futures.promise/set_rvalue_at_thread_exit.pass.cpp41
-rw-r--r--test/std/thread/futures/futures.promise/set_value_at_thread_exit_const.pass.cpp35
-rw-r--r--test/std/thread/futures/futures.promise/set_value_at_thread_exit_void.pass.cpp39
-rw-r--r--test/std/thread/futures/futures.promise/set_value_const.pass.cpp63
-rw-r--r--test/std/thread/futures/futures.promise/set_value_void.pass.cpp39
-rw-r--r--test/std/thread/futures/futures.promise/swap.pass.cpp84
-rw-r--r--test/std/thread/futures/futures.promise/uses_allocator.pass.cpp28
-rw-r--r--test/std/thread/futures/futures.shared_future/copy_assign.pass.cpp76
-rw-r--r--test/std/thread/futures/futures.shared_future/copy_ctor.pass.cpp68
-rw-r--r--test/std/thread/futures/futures.shared_future/ctor_future.pass.cpp68
-rw-r--r--test/std/thread/futures/futures.shared_future/default.pass.cpp35
-rw-r--r--test/std/thread/futures/futures.shared_future/dtor.pass.cpp68
-rw-r--r--test/std/thread/futures/futures.shared_future/get.pass.cpp145
-rw-r--r--test/std/thread/futures/futures.shared_future/move_assign.pass.cpp76
-rw-r--r--test/std/thread/futures/futures.shared_future/move_ctor.pass.cpp68
-rw-r--r--test/std/thread/futures/futures.shared_future/wait.pass.cpp88
-rw-r--r--test/std/thread/futures/futures.shared_future/wait_for.pass.cpp97
-rw-r--r--test/std/thread/futures/futures.shared_future/wait_until.pass.cpp129
-rw-r--r--test/std/thread/futures/futures.state/nothing_to_do.pass.cpp13
-rw-r--r--test/std/thread/futures/futures.tas/futures.task.members/assign_copy.fail.cpp48
-rw-r--r--test/std/thread/futures/futures.tas/futures.task.members/assign_move.pass.cpp50
-rw-r--r--test/std/thread/futures/futures.tas/futures.task.members/ctor1.fail.cpp29
-rw-r--r--test/std/thread/futures/futures.tas/futures.task.members/ctor2.fail.cpp30
-rw-r--r--test/std/thread/futures/futures.tas/futures.task.members/ctor_copy.fail.cpp46
-rw-r--r--test/std/thread/futures/futures.tas/futures.task.members/ctor_default.pass.cpp27
-rw-r--r--test/std/thread/futures/futures.tas/futures.task.members/ctor_func.pass.cpp79
-rw-r--r--test/std/thread/futures/futures.tas/futures.task.members/ctor_func_alloc.pass.cpp124
-rw-r--r--test/std/thread/futures/futures.tas/futures.task.members/ctor_move.pass.cpp48
-rw-r--r--test/std/thread/futures/futures.tas/futures.task.members/dtor.pass.cpp62
-rw-r--r--test/std/thread/futures/futures.tas/futures.task.members/get_future.pass.cpp64
-rw-r--r--test/std/thread/futures/futures.tas/futures.task.members/make_ready_at_thread_exit.pass.cpp106
-rw-r--r--test/std/thread/futures/futures.tas/futures.task.members/operator.pass.cpp107
-rw-r--r--test/std/thread/futures/futures.tas/futures.task.members/reset.pass.cpp60
-rw-r--r--test/std/thread/futures/futures.tas/futures.task.members/swap.pass.cpp50
-rw-r--r--test/std/thread/futures/futures.tas/futures.task.nonmembers/swap.pass.cpp52
-rw-r--r--test/std/thread/futures/futures.tas/futures.task.nonmembers/uses_allocator.pass.cpp26
-rw-r--r--test/std/thread/futures/futures.tas/types.pass.cpp28
-rw-r--r--test/std/thread/futures/futures.unique_future/copy_assign.fail.cpp74
-rw-r--r--test/std/thread/futures/futures.unique_future/copy_ctor.fail.cpp66
-rw-r--r--test/std/thread/futures/futures.unique_future/default.pass.cpp35
-rw-r--r--test/std/thread/futures/futures.unique_future/dtor.pass.cpp68
-rw-r--r--test/std/thread/futures/futures.unique_future/get.pass.cpp145
-rw-r--r--test/std/thread/futures/futures.unique_future/move_assign.pass.cpp76
-rw-r--r--test/std/thread/futures/futures.unique_future/move_ctor.pass.cpp70
-rw-r--r--test/std/thread/futures/futures.unique_future/share.pass.cpp68
-rw-r--r--test/std/thread/futures/futures.unique_future/wait.pass.cpp88
-rw-r--r--test/std/thread/futures/futures.unique_future/wait_for.pass.cpp97
-rw-r--r--test/std/thread/futures/futures.unique_future/wait_until.pass.cpp129
-rw-r--r--test/std/thread/futures/test_allocator.h158
-rw-r--r--test/std/thread/futures/version.pass.cpp22
-rw-r--r--test/std/thread/macro.pass.cpp23
-rw-r--r--test/std/thread/thread.condition/cv_status.pass.cpp23
-rw-r--r--test/std/thread/thread.condition/notify_all_at_thread_exit.pass.cpp44
-rw-r--r--test/std/thread/thread.condition/thread.condition.condvar/assign.fail.cpp24
-rw-r--r--test/std/thread/thread.condition/thread.condition.condvar/copy.fail.cpp23
-rw-r--r--test/std/thread/thread.condition/thread.condition.condvar/default.pass.cpp24
-rw-r--r--test/std/thread/thread.condition/thread.condition.condvar/destructor.pass.cpp58
-rw-r--r--test/std/thread/thread.condition/thread.condition.condvar/native_handle.pass.cpp29
-rw-r--r--test/std/thread/thread.condition/thread.condition.condvar/notify_all.pass.cpp69
-rw-r--r--test/std/thread/thread.condition/thread.condition.condvar/notify_one.pass.cpp94
-rw-r--r--test/std/thread/thread.condition/thread.condition.condvar/wait.pass.cpp52
-rw-r--r--test/std/thread/thread.condition/thread.condition.condvar/wait_for.pass.cpp87
-rw-r--r--test/std/thread/thread.condition/thread.condition.condvar/wait_for_pred.pass.cpp95
-rw-r--r--test/std/thread/thread.condition/thread.condition.condvar/wait_pred.pass.cpp62
-rw-r--r--test/std/thread/thread.condition/thread.condition.condvar/wait_until.pass.cpp102
-rw-r--r--test/std/thread/thread.condition/thread.condition.condvar/wait_until_pred.pass.cpp113
-rw-r--r--test/std/thread/thread.condition/thread.condition.condvarany/assign.fail.cpp24
-rw-r--r--test/std/thread/thread.condition/thread.condition.condvarany/copy.fail.cpp23
-rw-r--r--test/std/thread/thread.condition/thread.condition.condvarany/default.pass.cpp24
-rw-r--r--test/std/thread/thread.condition/thread.condition.condvarany/destructor.pass.cpp59
-rw-r--r--test/std/thread/thread.condition/thread.condition.condvarany/notify_all.pass.cpp73
-rw-r--r--test/std/thread/thread.condition/thread.condition.condvarany/notify_one.pass.cpp98
-rw-r--r--test/std/thread/thread.condition/thread.condition.condvarany/wait.exception.pass.cpp63
-rw-r--r--test/std/thread/thread.condition/thread.condition.condvarany/wait.pass.cpp57
-rw-r--r--test/std/thread/thread.condition/thread.condition.condvarany/wait_for.exception.pass.cpp63
-rw-r--r--test/std/thread/thread.condition/thread.condition.condvarany/wait_for.pass.cpp90
-rw-r--r--test/std/thread/thread.condition/thread.condition.condvarany/wait_for_pred.pass.cpp98
-rw-r--r--test/std/thread/thread.condition/thread.condition.condvarany/wait_pred.pass.cpp66
-rw-r--r--test/std/thread/thread.condition/thread.condition.condvarany/wait_until.pass.cpp105
-rw-r--r--test/std/thread/thread.condition/thread.condition.condvarany/wait_until_pred.pass.cpp117
-rw-r--r--test/std/thread/thread.condition/version.pass.cpp22
-rw-r--r--test/std/thread/thread.general/nothing_to_do.pass.cpp12
-rw-r--r--test/std/thread/thread.mutex/thread.lock.algorithm/lock.pass.cpp507
-rw-r--r--test/std/thread/thread.mutex/thread.lock.algorithm/try_lock.pass.cpp516
-rw-r--r--test/std/thread/thread.mutex/thread.lock/thread.lock.guard/adopt_lock.pass.cpp51
-rw-r--r--test/std/thread/thread.mutex/thread.lock/thread.lock.guard/assign.fail.cpp25
-rw-r--r--test/std/thread/thread.mutex/thread.lock/thread.lock.guard/copy.fail.cpp23
-rw-r--r--test/std/thread/thread.mutex/thread.lock/thread.lock.guard/mutex.fail.cpp48
-rw-r--r--test/std/thread/thread.mutex/thread.lock/thread.lock.guard/mutex.pass.cpp50
-rw-r--r--test/std/thread/thread.mutex/thread.lock/thread.lock.guard/types.pass.cpp29
-rw-r--r--test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/copy_assign.fail.cpp34
-rw-r--r--test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/copy_ctor.fail.cpp30
-rw-r--r--test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/default.pass.cpp28
-rw-r--r--test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/move_assign.pass.cpp39
-rw-r--r--test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/move_ctor.pass.cpp35
-rw-r--r--test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex.pass.cpp81
-rw-r--r--test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_adopt_lock.pass.cpp30
-rw-r--r--test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_defer_lock.pass.cpp29
-rw-r--r--test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_duration.pass.cpp81
-rw-r--r--test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_time_point.pass.cpp81
-rw-r--r--test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_try_to_lock.pass.cpp74
-rw-r--r--test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/lock.pass.cpp79
-rw-r--r--test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock.pass.cpp70
-rw-r--r--test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock_for.pass.cpp75
-rw-r--r--test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock_until.pass.cpp75
-rw-r--r--test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/unlock.pass.cpp62
-rw-r--r--test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.mod/member_swap.pass.cpp45
-rw-r--r--test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.mod/nonmember_swap.pass.cpp46
-rw-r--r--test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.mod/release.pass.cpp53
-rw-r--r--test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.obs/mutex.pass.cpp38
-rw-r--r--test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.obs/op_bool.pass.cpp38
-rw-r--r--test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.obs/owns_lock.pass.cpp38
-rw-r--r--test/std/thread/thread.mutex/thread.lock/thread.lock.shared/types.pass.cpp31
-rw-r--r--test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/copy_assign.fail.cpp31
-rw-r--r--test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/copy_ctor.fail.cpp29
-rw-r--r--test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/default.pass.cpp26
-rw-r--r--test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/move_assign.pass.cpp35
-rw-r--r--test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/move_ctor.pass.cpp33
-rw-r--r--test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex.pass.cpp50
-rw-r--r--test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_adopt_lock.pass.cpp28
-rw-r--r--test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_defer_lock.pass.cpp27
-rw-r--r--test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_duration.pass.cpp68
-rw-r--r--test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_time_point.pass.cpp68
-rw-r--r--test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_try_to_lock.pass.cpp64
-rw-r--r--test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/lock.pass.cpp69
-rw-r--r--test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock.pass.cpp64
-rw-r--r--test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock_for.pass.cpp69
-rw-r--r--test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock_until.pass.cpp69
-rw-r--r--test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/unlock.pass.cpp56
-rw-r--r--test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.mod/member_swap.pass.cpp38
-rw-r--r--test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.mod/nonmember_swap.pass.cpp39
-rw-r--r--test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.mod/release.pass.cpp46
-rw-r--r--test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.obs/mutex.pass.cpp31
-rw-r--r--test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.obs/op_bool.pass.cpp31
-rw-r--r--test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.obs/owns_lock.pass.cpp31
-rw-r--r--test/std/thread/thread.mutex/thread.lock/thread.lock.unique/types.pass.cpp29
-rw-r--r--test/std/thread/thread.mutex/thread.lock/types.pass.cpp34
-rw-r--r--test/std/thread/thread.mutex/thread.mutex.requirements/nothing_to_do.pass.cpp12
-rw-r--r--test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.general/nothing_to_do.pass.cpp12
-rw-r--r--test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/nothing_to_do.pass.cpp12
-rw-r--r--test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/assign.fail.cpp23
-rw-r--r--test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/copy.fail.cpp22
-rw-r--r--test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/default.pass.cpp23
-rw-r--r--test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/lock.pass.cpp50
-rw-r--r--test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/native_handle.pass.cpp27
-rw-r--r--test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/try_lock.pass.cpp52
-rw-r--r--test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/assign.fail.cpp23
-rw-r--r--test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/copy.fail.cpp22
-rw-r--r--test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/default.pass.cpp23
-rw-r--r--test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/lock.pass.cpp52
-rw-r--r--test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/native_handle.pass.cpp27
-rw-r--r--test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/try_lock.pass.cpp54
-rw-r--r--test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/nothing_to_do.pass.cpp12
-rw-r--r--test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/assign.fail.cpp29
-rw-r--r--test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/copy.fail.cpp28
-rw-r--r--test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/default.pass.cpp24
-rw-r--r--test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/lock.pass.cpp50
-rw-r--r--test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/lock_shared.pass.cpp73
-rw-r--r--test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/try_lock.pass.cpp53
-rw-r--r--test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/try_lock_shared.pass.cpp58
-rw-r--r--test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/nothing_to_do.pass.cpp12
-rw-r--r--test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/assign.fail.cpp27
-rw-r--r--test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/copy.fail.cpp26
-rw-r--r--test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/default.pass.cpp24
-rw-r--r--test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/lock.pass.cpp49
-rw-r--r--test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/lock_shared.pass.cpp73
-rw-r--r--test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock.pass.cpp53
-rw-r--r--test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_for.pass.cpp68
-rw-r--r--test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_shared.pass.cpp57
-rw-r--r--test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_shared_for.pass.cpp75
-rw-r--r--test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_shared_until.pass.cpp75
-rw-r--r--test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_until.pass.cpp70
-rw-r--r--test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_until_deadlock_bug.pass.cpp70
-rw-r--r--test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/nothing_to_do.pass.cpp12
-rw-r--r--test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/assign.fail.cpp23
-rw-r--r--test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/copy.fail.cpp22
-rw-r--r--test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/default.pass.cpp23
-rw-r--r--test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/lock.pass.cpp50
-rw-r--r--test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/try_lock.pass.cpp52
-rw-r--r--test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/try_lock_for.pass.cpp67
-rw-r--r--test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/try_lock_until.pass.cpp67
-rw-r--r--test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/assign.fail.cpp23
-rw-r--r--test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/copy.fail.cpp22
-rw-r--r--test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/default.pass.cpp23
-rw-r--r--test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/lock.pass.cpp52
-rw-r--r--test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/try_lock.pass.cpp54
-rw-r--r--test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/try_lock_for.pass.cpp69
-rw-r--r--test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/try_lock_until.pass.cpp69
-rw-r--r--test/std/thread/thread.mutex/thread.once/nothing_to_do.pass.cpp12
-rw-r--r--test/std/thread/thread.mutex/thread.once/thread.once.callonce/call_once.pass.cpp254
-rw-r--r--test/std/thread/thread.mutex/thread.once/thread.once.onceflag/assign.fail.cpp23
-rw-r--r--test/std/thread/thread.mutex/thread.once/thread.once.onceflag/copy.fail.cpp22
-rw-r--r--test/std/thread/thread.mutex/thread.once/thread.once.onceflag/default.pass.cpp28
-rw-r--r--test/std/thread/thread.mutex/version.pass.cpp20
-rw-r--r--test/std/thread/thread.req/nothing_to_do.pass.cpp12
-rw-r--r--test/std/thread/thread.req/thread.req.exception/nothing_to_do.pass.cpp12
-rw-r--r--test/std/thread/thread.req/thread.req.lockable/nothing_to_do.pass.cpp12
-rw-r--r--test/std/thread/thread.req/thread.req.lockable/thread.req.lockable.basic/nothing_to_do.pass.cpp12
-rw-r--r--test/std/thread/thread.req/thread.req.lockable/thread.req.lockable.general/nothing_to_do.pass.cpp12
-rw-r--r--test/std/thread/thread.req/thread.req.lockable/thread.req.lockable.req/nothing_to_do.pass.cpp12
-rw-r--r--test/std/thread/thread.req/thread.req.lockable/thread.req.lockable.timed/nothing_to_do.pass.cpp12
-rw-r--r--test/std/thread/thread.req/thread.req.native/nothing_to_do.pass.cpp12
-rw-r--r--test/std/thread/thread.req/thread.req.paramname/nothing_to_do.pass.cpp12
-rw-r--r--test/std/thread/thread.req/thread.req.timing/nothing_to_do.pass.cpp12
-rw-r--r--test/std/thread/thread.threads/thread.thread.class/thread.thread.algorithm/swap.pass.cpp58
-rw-r--r--test/std/thread/thread.threads/thread.thread.class/thread.thread.assign/copy.fail.cpp51
-rw-r--r--test/std/thread/thread.threads/thread.thread.class/thread.thread.assign/move.pass.cpp65
-rw-r--r--test/std/thread/thread.threads/thread.thread.class/thread.thread.assign/move2.pass.cpp77
-rw-r--r--test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp154
-rw-r--r--test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/constr.fail.cpp26
-rw-r--r--test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/copy.fail.cpp66
-rw-r--r--test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/default.pass.cpp25
-rw-r--r--test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/move.pass.cpp72
-rw-r--r--test/std/thread/thread.threads/thread.thread.class/thread.thread.destr/dtor.pass.cpp66
-rw-r--r--test/std/thread/thread.threads/thread.thread.class/thread.thread.id/assign.pass.cpp29
-rw-r--r--test/std/thread/thread.threads/thread.thread.class/thread.thread.id/copy.pass.cpp26
-rw-r--r--test/std/thread/thread.threads/thread.thread.class/thread.thread.id/default.pass.cpp25
-rw-r--r--test/std/thread/thread.threads/thread.thread.class/thread.thread.id/eq.pass.cpp32
-rw-r--r--test/std/thread/thread.threads/thread.thread.class/thread.thread.id/lt.pass.cpp43
-rw-r--r--test/std/thread/thread.threads/thread.thread.class/thread.thread.id/stream.pass.cpp29
-rw-r--r--test/std/thread/thread.threads/thread.thread.class/thread.thread.id/thread_id.pass.cpp35
-rw-r--r--test/std/thread/thread.threads/thread.thread.class/thread.thread.member/detach.pass.cpp73
-rw-r--r--test/std/thread/thread.threads/thread.thread.class/thread.thread.member/get_id.pass.cpp57
-rw-r--r--test/std/thread/thread.threads/thread.thread.class/thread.thread.member/join.pass.cpp54
-rw-r--r--test/std/thread/thread.threads/thread.thread.class/thread.thread.member/joinable.pass.cpp54
-rw-r--r--test/std/thread/thread.threads/thread.thread.class/thread.thread.member/native_handle.pass.cpp54
-rw-r--r--test/std/thread/thread.threads/thread.thread.class/thread.thread.member/swap.pass.cpp58
-rw-r--r--test/std/thread/thread.threads/thread.thread.class/thread.thread.static/hardware_concurrency.pass.cpp24
-rw-r--r--test/std/thread/thread.threads/thread.thread.class/types.pass.cpp27
-rw-r--r--test/std/thread/thread.threads/thread.thread.this/get_id.pass.cpp23
-rw-r--r--test/std/thread/thread.threads/thread.thread.this/sleep_for.pass.cpp57
-rw-r--r--test/std/thread/thread.threads/thread.thread.this/sleep_until.pass.cpp34
-rw-r--r--test/std/thread/thread.threads/thread.thread.this/yield.pass.cpp22
-rw-r--r--test/std/thread/thread.threads/version.pass.cpp22
-rw-r--r--test/std/utilities/allocator.adaptor/allocator.adaptor.cnstr/allocs.pass.cpp112
-rw-r--r--test/std/utilities/allocator.adaptor/allocator.adaptor.cnstr/converting_copy.pass.cpp69
-rw-r--r--test/std/utilities/allocator.adaptor/allocator.adaptor.cnstr/converting_move.pass.cpp75
-rw-r--r--test/std/utilities/allocator.adaptor/allocator.adaptor.cnstr/copy.pass.cpp70
-rw-r--r--test/std/utilities/allocator.adaptor/allocator.adaptor.cnstr/default.pass.cpp58
-rw-r--r--test/std/utilities/allocator.adaptor/allocator.adaptor.members/allocate_size.pass.cpp49
-rw-r--r--test/std/utilities/allocator.adaptor/allocator.adaptor.members/allocate_size_hint.pass.cpp70
-rw-r--r--test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct.pass.cpp193
-rw-r--r--test/std/utilities/allocator.adaptor/allocator.adaptor.members/deallocate.pass.cpp46
-rw-r--r--test/std/utilities/allocator.adaptor/allocator.adaptor.members/destroy.pass.cpp70
-rw-r--r--test/std/utilities/allocator.adaptor/allocator.adaptor.members/inner_allocator.pass.cpp45
-rw-r--r--test/std/utilities/allocator.adaptor/allocator.adaptor.members/max_size.pass.cpp43
-rw-r--r--test/std/utilities/allocator.adaptor/allocator.adaptor.members/outer_allocator.pass.cpp44
-rw-r--r--test/std/utilities/allocator.adaptor/allocator.adaptor.members/select_on_container_copy_construction.pass.cpp55
-rw-r--r--test/std/utilities/allocator.adaptor/allocator.adaptor.types/allocator_pointers.pass.cpp117
-rw-r--r--test/std/utilities/allocator.adaptor/allocator.adaptor.types/inner_allocator_type.pass.cpp39
-rw-r--r--test/std/utilities/allocator.adaptor/allocator.adaptor.types/is_always_equal.pass.cpp75
-rw-r--r--test/std/utilities/allocator.adaptor/allocator.adaptor.types/propagate_on_container_copy_assignment.pass.cpp39
-rw-r--r--test/std/utilities/allocator.adaptor/allocator.adaptor.types/propagate_on_container_move_assignment.pass.cpp39
-rw-r--r--test/std/utilities/allocator.adaptor/allocator.adaptor.types/propagate_on_container_swap.pass.cpp39
-rw-r--r--test/std/utilities/allocator.adaptor/scoped.adaptor.operators/eq.pass.cpp64
-rw-r--r--test/std/utilities/allocator.adaptor/types.pass.cpp102
-rw-r--r--test/std/utilities/date.time/asctime.thread-unsafe.fail.cpp18
-rw-r--r--test/std/utilities/date.time/ctime.thread-unsafe.fail.cpp18
-rw-r--r--test/std/utilities/date.time/gmtime.thread-unsafe.fail.cpp18
-rw-r--r--test/std/utilities/date.time/localtime.thread-unsafe.fail.cpp18
-rw-r--r--test/std/utilities/date.time/tested_elsewhere.pass.cpp38
-rw-r--r--test/std/utilities/function.objects/arithmetic.operations/divides.pass.cpp39
-rw-r--r--test/std/utilities/function.objects/arithmetic.operations/minus.pass.cpp39
-rw-r--r--test/std/utilities/function.objects/arithmetic.operations/modulus.pass.cpp39
-rw-r--r--test/std/utilities/function.objects/arithmetic.operations/multiplies.pass.cpp39
-rw-r--r--test/std/utilities/function.objects/arithmetic.operations/negate.pass.cpp38
-rw-r--r--test/std/utilities/function.objects/arithmetic.operations/plus.pass.cpp39
-rw-r--r--test/std/utilities/function.objects/arithmetic.operations/transparent.pass.cpp61
-rw-r--r--test/std/utilities/function.objects/bind/func.bind/func.bind.bind/copy.pass.cpp35
-rw-r--r--test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_function_object.pass.cpp49
-rw-r--r--test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_int_0.pass.cpp53
-rw-r--r--test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_lvalue.pass.cpp287
-rw-r--r--test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_rvalue.pass.cpp266
-rw-r--r--test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_void_0.pass.cpp72
-rw-r--r--test/std/utilities/function.objects/bind/func.bind/func.bind.bind/nested.pass.cpp51
-rw-r--r--test/std/utilities/function.objects/bind/func.bind/func.bind.isbind/is_bind_expression.pass.cpp32
-rw-r--r--test/std/utilities/function.objects/bind/func.bind/func.bind.isbind/is_placeholder.pass.cpp41
-rw-r--r--test/std/utilities/function.objects/bind/func.bind/func.bind.place/placeholders.pass.cpp43
-rw-r--r--test/std/utilities/function.objects/bind/func.bind/nothing_to_do.pass.cpp12
-rw-r--r--test/std/utilities/function.objects/bind/nothing_to_do.pass.cpp12
-rw-r--r--test/std/utilities/function.objects/bitwise.operations/bit_and.pass.cpp59
-rw-r--r--test/std/utilities/function.objects/bitwise.operations/bit_not.pass.cpp47
-rw-r--r--test/std/utilities/function.objects/bitwise.operations/bit_or.pass.cpp59
-rw-r--r--test/std/utilities/function.objects/bitwise.operations/bit_xor.pass.cpp63
-rw-r--r--test/std/utilities/function.objects/bitwise.operations/transparent.pass.cpp51
-rw-r--r--test/std/utilities/function.objects/comparisons/equal_to.pass.cpp41
-rw-r--r--test/std/utilities/function.objects/comparisons/greater.pass.cpp45
-rw-r--r--test/std/utilities/function.objects/comparisons/greater_equal.pass.cpp45
-rw-r--r--test/std/utilities/function.objects/comparisons/less.pass.cpp45
-rw-r--r--test/std/utilities/function.objects/comparisons/less_equal.pass.cpp45
-rw-r--r--test/std/utilities/function.objects/comparisons/not_equal_to.pass.cpp43
-rw-r--r--test/std/utilities/function.objects/comparisons/transparent.pass.cpp61
-rw-r--r--test/std/utilities/function.objects/func.def/nothing_to_do.pass.cpp12
-rw-r--r--test/std/utilities/function.objects/func.invoke/invoke.pass.cpp268
-rw-r--r--test/std/utilities/function.objects/func.memfn/member_data.fail.cpp42
-rw-r--r--test/std/utilities/function.objects/func.memfn/member_data.pass.cpp43
-rw-r--r--test/std/utilities/function.objects/func.memfn/member_function.pass.cpp72
-rw-r--r--test/std/utilities/function.objects/func.memfn/member_function_const.pass.cpp78
-rw-r--r--test/std/utilities/function.objects/func.memfn/member_function_const_volatile.pass.cpp78
-rw-r--r--test/std/utilities/function.objects/func.memfn/member_function_volatile.pass.cpp78
-rw-r--r--test/std/utilities/function.objects/func.require/binary_function.pass.cpp23
-rw-r--r--test/std/utilities/function.objects/func.require/invoke.pass.cpp50
-rw-r--r--test/std/utilities/function.objects/func.require/unary_function.pass.cpp22
-rw-r--r--test/std/utilities/function.objects/func.wrap/func.wrap.badcall/bad_function_call.pass.cpp26
-rw-r--r--test/std/utilities/function.objects/func.wrap/func.wrap.badcall/func.wrap.badcall.const/bad_function_call_ctor.pass.cpp20
-rw-r--r--test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.alg/swap.pass.cpp123
-rw-r--r--test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.cap/operator_bool.pass.cpp29
-rw-r--r--test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F.pass.cpp90
-rw-r--r--test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_assign.pass.cpp98
-rw-r--r--test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_incomplete.pass.cpp29
-rw-r--r--test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc.pass.cpp27
-rw-r--r--test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_F.pass.cpp106
-rw-r--r--test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_function.pass.cpp124
-rw-r--r--test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_nullptr.pass.cpp25
-rw-r--r--test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_rfunction.pass.cpp68
-rw-r--r--test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy.pass.cpp118
-rw-r--r--test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy_assign.pass.cpp109
-rw-r--r--test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/default.pass.cpp23
-rw-r--r--test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/no-variadics.pass.cpp24
-rw-r--r--test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/nullptr_t.pass.cpp23
-rw-r--r--test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/nullptr_t_assign.pass.cpp72
-rw-r--r--test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke.fail.cpp46
-rw-r--r--test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke.pass.cpp335
-rw-r--r--test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke_int_0.pass.cpp58
-rw-r--r--test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke_no_variadics.pass.cpp60
-rw-r--r--test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke_void_0.pass.cpp67
-rw-r--r--test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.mod/assign_F_alloc.pass.cpp60
-rw-r--r--test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.mod/swap.pass.cpp120
-rw-r--r--test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.nullptr/operator_==.pass.cpp41
-rw-r--r--test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.targ/target.pass.cpp89
-rw-r--r--test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.targ/target_type.pass.cpp61
-rw-r--r--test/std/utilities/function.objects/func.wrap/func.wrap.func/function_types.h57
-rw-r--r--test/std/utilities/function.objects/func.wrap/func.wrap.func/types.pass.cpp108
-rw-r--r--test/std/utilities/function.objects/func.wrap/nothing_to_do.pass.cpp12
-rw-r--r--test/std/utilities/function.objects/logical.operations/logical_and.pass.cpp50
-rw-r--r--test/std/utilities/function.objects/logical.operations/logical_not.pass.cpp40
-rw-r--r--test/std/utilities/function.objects/logical.operations/logical_or.pass.cpp49
-rw-r--r--test/std/utilities/function.objects/logical.operations/transparent.pass.cpp46
-rw-r--r--test/std/utilities/function.objects/negators/binary_negate.pass.cpp29
-rw-r--r--test/std/utilities/function.objects/negators/not1.pass.cpp22
-rw-r--r--test/std/utilities/function.objects/negators/not2.pass.cpp24
-rw-r--r--test/std/utilities/function.objects/negators/unary_negate.pass.cpp26
-rw-r--r--test/std/utilities/function.objects/refwrap/binary.pass.cpp80
-rw-r--r--test/std/utilities/function.objects/refwrap/refwrap.access/conversion.pass.cpp46
-rw-r--r--test/std/utilities/function.objects/refwrap/refwrap.assign/copy_assign.pass.cpp58
-rw-r--r--test/std/utilities/function.objects/refwrap/refwrap.const/copy_ctor.pass.cpp46
-rw-r--r--test/std/utilities/function.objects/refwrap/refwrap.const/type_ctor.fail.cpp22
-rw-r--r--test/std/utilities/function.objects/refwrap/refwrap.const/type_ctor.pass.cpp45
-rw-r--r--test/std/utilities/function.objects/refwrap/refwrap.helpers/cref_1.pass.cpp24
-rw-r--r--test/std/utilities/function.objects/refwrap/refwrap.helpers/cref_2.pass.cpp25
-rw-r--r--test/std/utilities/function.objects/refwrap/refwrap.helpers/ref_1.fail.cpp27
-rw-r--r--test/std/utilities/function.objects/refwrap/refwrap.helpers/ref_1.pass.cpp24
-rw-r--r--test/std/utilities/function.objects/refwrap/refwrap.helpers/ref_2.pass.cpp43
-rw-r--r--test/std/utilities/function.objects/refwrap/refwrap.invoke/invoke.fail.cpp52
-rw-r--r--test/std/utilities/function.objects/refwrap/refwrap.invoke/invoke.pass.cpp329
-rw-r--r--test/std/utilities/function.objects/refwrap/refwrap.invoke/invoke_int_0.pass.cpp76
-rw-r--r--test/std/utilities/function.objects/refwrap/refwrap.invoke/invoke_void_0.pass.cpp68
-rw-r--r--test/std/utilities/function.objects/refwrap/type.pass.cpp37
-rw-r--r--test/std/utilities/function.objects/refwrap/type_properties.pass.cpp58
-rw-r--r--test/std/utilities/function.objects/refwrap/unary.pass.cpp78
-rw-r--r--test/std/utilities/function.objects/refwrap/weak_result.pass.cpp82
-rw-r--r--test/std/utilities/function.objects/unord.hash/enum.fail.cpp24
-rw-r--r--test/std/utilities/function.objects/unord.hash/enum.pass.cpp62
-rw-r--r--test/std/utilities/function.objects/unord.hash/floating.pass.cpp70
-rw-r--r--test/std/utilities/function.objects/unord.hash/integral.pass.cpp60
-rw-r--r--test/std/utilities/function.objects/unord.hash/pointer.pass.cpp44
-rw-r--r--test/std/utilities/function.objects/version.pass.cpp20
-rw-r--r--test/std/utilities/intseq/intseq.general/integer_seq.pass.cpp86
-rw-r--r--test/std/utilities/intseq/intseq.intseq/integer_seq.fail.cpp38
-rw-r--r--test/std/utilities/intseq/intseq.intseq/integer_seq.pass.cpp48
-rw-r--r--test/std/utilities/intseq/intseq.make/make_integer_seq.fail.cpp30
-rw-r--r--test/std/utilities/intseq/intseq.make/make_integer_seq.pass.cpp34
-rw-r--r--test/std/utilities/intseq/nothing_to_do.pass.cpp12
-rw-r--r--test/std/utilities/memory/allocator.tag/allocator_arg.pass.cpp22
-rw-r--r--test/std/utilities/memory/allocator.traits/allocator.traits.members/allocate.pass.cpp38
-rw-r--r--test/std/utilities/memory/allocator.traits/allocator.traits.members/allocate_hint.pass.cpp60
-rw-r--r--test/std/utilities/memory/allocator.traits/allocator.traits.members/construct.pass.cpp143
-rw-r--r--test/std/utilities/memory/allocator.traits/allocator.traits.members/deallocate.pass.cpp42
-rw-r--r--test/std/utilities/memory/allocator.traits/allocator.traits.members/destroy.pass.cpp80
-rw-r--r--test/std/utilities/memory/allocator.traits/allocator.traits.members/max_size.pass.cpp70
-rw-r--r--test/std/utilities/memory/allocator.traits/allocator.traits.members/select_on_container_copy_construction.pass.cpp68
-rw-r--r--test/std/utilities/memory/allocator.traits/allocator.traits.types/const_pointer.pass.cpp55
-rw-r--r--test/std/utilities/memory/allocator.traits/allocator.traits.types/const_void_pointer.pass.cpp55
-rw-r--r--test/std/utilities/memory/allocator.traits/allocator.traits.types/difference_type.pass.cpp62
-rw-r--r--test/std/utilities/memory/allocator.traits/allocator.traits.types/is_always_equal.pass.cpp52
-rw-r--r--test/std/utilities/memory/allocator.traits/allocator.traits.types/pointer.pass.cpp42
-rw-r--r--test/std/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_copy_assignment.pass.cpp40
-rw-r--r--test/std/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_move_assignment.pass.cpp40
-rw-r--r--test/std/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_swap.pass.cpp40
-rw-r--r--test/std/utilities/memory/allocator.traits/allocator.traits.types/rebind_alloc.pass.cpp79
-rw-r--r--test/std/utilities/memory/allocator.traits/allocator.traits.types/size_type.pass.cpp63
-rw-r--r--test/std/utilities/memory/allocator.traits/allocator.traits.types/void_pointer.pass.cpp55
-rw-r--r--test/std/utilities/memory/allocator.traits/allocator_type.pass.cpp31
-rw-r--r--test/std/utilities/memory/allocator.traits/rebind_traits.pass.cpp79
-rw-r--r--test/std/utilities/memory/allocator.traits/value_type.pass.cpp31
-rw-r--r--test/std/utilities/memory/allocator.uses/allocator.uses.construction/tested_elsewhere.pass.cpp12
-rw-r--r--test/std/utilities/memory/allocator.uses/allocator.uses.trait/uses_allocator.pass.cpp33
-rw-r--r--test/std/utilities/memory/allocator.uses/nothing_to_do.pass.cpp12
-rw-r--r--test/std/utilities/memory/c.malloc/nothing_to_do.pass.cpp14
-rw-r--r--test/std/utilities/memory/default.allocator/allocator.globals/eq.pass.cpp31
-rw-r--r--test/std/utilities/memory/default.allocator/allocator.members/address.pass.cpp39
-rw-r--r--test/std/utilities/memory/default.allocator/allocator.members/allocate.pass.cpp52
-rw-r--r--test/std/utilities/memory/default.allocator/allocator.members/construct.pass.cpp142
-rw-r--r--test/std/utilities/memory/default.allocator/allocator.members/max_size.pass.cpp27
-rw-r--r--test/std/utilities/memory/default.allocator/allocator_pointers.pass.cpp116
-rw-r--r--test/std/utilities/memory/default.allocator/allocator_types.pass.cpp55
-rw-r--r--test/std/utilities/memory/default.allocator/allocator_void.pass.cpp36
-rw-r--r--test/std/utilities/memory/pointer.traits/difference_type.pass.cpp25
-rw-r--r--test/std/utilities/memory/pointer.traits/element_type.pass.cpp25
-rw-r--r--test/std/utilities/memory/pointer.traits/pointer.pass.cpp32
-rw-r--r--test/std/utilities/memory/pointer.traits/pointer.traits.functions/pointer_to.pass.cpp48
-rw-r--r--test/std/utilities/memory/pointer.traits/pointer.traits.types/difference_type.pass.cpp48
-rw-r--r--test/std/utilities/memory/pointer.traits/pointer.traits.types/element_type.pass.cpp49
-rw-r--r--test/std/utilities/memory/pointer.traits/pointer.traits.types/rebind.pass.cpp69
-rw-r--r--test/std/utilities/memory/pointer.traits/pointer_to.pass.cpp32
-rw-r--r--test/std/utilities/memory/pointer.traits/rebind.pass.cpp29
-rw-r--r--test/std/utilities/memory/ptr.align/align.pass.cpp84
-rw-r--r--test/std/utilities/memory/specialized.algorithms/nothing_to_do.pass.cpp12
-rw-r--r--test/std/utilities/memory/specialized.algorithms/specialized.addressof/addressof.pass.cpp51
-rw-r--r--test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy.pass.cpp75
-rw-r--r--test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy_n.pass.cpp74
-rw-r--r--test/std/utilities/memory/specialized.algorithms/uninitialized.fill.n/uninitialized_fill_n.pass.cpp75
-rw-r--r--test/std/utilities/memory/specialized.algorithms/uninitialized.fill/uninitialized_fill.pass.cpp72
-rw-r--r--test/std/utilities/memory/storage.iterator/raw_storag_iterator.base.pass.cpp48
-rw-r--r--test/std/utilities/memory/storage.iterator/raw_storag_iterator.pass.cpp44
-rw-r--r--test/std/utilities/memory/temporary.buffer/temporary_buffer.pass.cpp29
-rw-r--r--test/std/utilities/memory/unique.ptr/deleter.h182
-rw-r--r--test/std/utilities/memory/unique.ptr/nothing_to_do.pass.cpp12
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array.pass.cpp45
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array1.fail.cpp17
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array2.fail.cpp17
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array3.fail.cpp17
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array4.fail.cpp17
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.single.pass.cpp33
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.dltr/nothing_to_do.pass.cpp12
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/convert_ctor.pass.cpp48
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/default.pass.cpp34
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/incomplete.fail.cpp26
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/void.fail.cpp24
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/convert_ctor.fail.cpp32
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/default.pass.cpp36
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/incomplete.fail.cpp26
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.general/nothing_to_do.pass.cpp12
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move01.fail.cpp39
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move01.pass.cpp79
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move02.fail.cpp39
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move03.fail.cpp57
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move04.fail.cpp57
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert01.fail.cpp57
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert02.fail.cpp61
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert03.fail.cpp62
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert04.fail.cpp57
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert05.fail.cpp61
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert06.fail.cpp62
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert07.fail.cpp56
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert08.fail.cpp60
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert09.fail.cpp62
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/null_asgn.pass.cpp41
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/null_ctor.pass.cpp44
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/nullptr_asgn.pass.cpp41
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/pointer_type.pass.cpp34
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.fail.cpp38
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.pass.cpp47
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default02.fail.cpp30
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default02.pass.cpp87
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default03.fail.cpp23
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move01.fail.cpp42
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move01.pass.cpp86
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move02.fail.cpp42
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move02.pass.cpp87
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move03.fail.cpp55
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move04.fail.cpp55
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert01.fail.cpp57
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert02.fail.cpp61
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert03.fail.cpp78
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert04.fail.cpp57
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert05.fail.cpp61
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert06.fail.cpp78
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert07.fail.cpp57
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert08.fail.cpp61
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert09.fail.cpp78
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert10.fail.cpp57
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert11.fail.cpp61
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert12.fail.cpp78
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert13.fail.cpp57
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert14.fail.cpp61
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert15.fail.cpp78
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert16.fail.cpp57
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert17.fail.cpp61
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert18.fail.cpp78
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/nullptr.pass.cpp46
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer01.fail.cpp36
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer01.pass.cpp63
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer02.fail.cpp29
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer02.pass.cpp95
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer03.fail.cpp23
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer04.fail.cpp67
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter01.pass.cpp43
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter02.pass.cpp58
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter03.pass.cpp60
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter04.fail.cpp55
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter04.pass.cpp58
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter05.fail.cpp58
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/release.pass.cpp27
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/reset1.pass.cpp50
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/reset2.fail.cpp64
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/swap.pass.cpp56
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/dereference.fail.cpp23
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/explicit_bool.pass.cpp39
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/get.pass.cpp24
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/get_deleter.pass.cpp37
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/index.pass.cpp47
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/op_arrow.fail.cpp30
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/pointer_type.pass.cpp34
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move01.fail.cpp38
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move01.pass.cpp75
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move02.fail.cpp38
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move03.fail.cpp56
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move04.fail.cpp56
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert01.fail.cpp57
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert01.pass.cpp56
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert02.fail.cpp61
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert02.pass.cpp60
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert03.fail.cpp62
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert03.pass.cpp63
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert04.fail.cpp57
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert05.fail.cpp61
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert06.fail.cpp62
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert13.fail.cpp36
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/null.pass.cpp41
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/nullptr.pass.cpp41
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer.pass.cpp68
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer01.fail.cpp67
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer02.fail.cpp61
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default01.fail.cpp35
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default01.pass.cpp46
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default02.fail.cpp29
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default02.pass.cpp84
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default03.fail.cpp23
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move01.fail.cpp42
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move01.pass.cpp142
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move02.fail.cpp42
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move02.pass.cpp143
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move03.fail.cpp55
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move04.fail.cpp55
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert01.fail.cpp56
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert01.pass.cpp58
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert02.fail.cpp62
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert02.pass.cpp62
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert03.fail.cpp79
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert03.pass.cpp79
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert04.fail.cpp58
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert04.pass.cpp58
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert05.fail.cpp51
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert05.pass.cpp62
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert06.fail.cpp79
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert06.pass.cpp79
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert07.fail.cpp58
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert07.pass.cpp63
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert08.fail.cpp118
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert09.fail.cpp79
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert10.fail.cpp58
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert11.fail.cpp118
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert12.fail.cpp79
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert13.fail.cpp35
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/nullptr.pass.cpp46
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer01.fail.cpp35
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer01.pass.cpp63
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer02.fail.cpp29
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer02.pass.cpp95
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer03.fail.cpp23
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer03.pass.cpp78
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter01.pass.cpp99
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter02.pass.cpp58
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter03.pass.cpp60
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter04.fail.cpp55
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter04.pass.cpp58
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter05.pass.cpp66
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter06.pass.cpp39
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.dtor/null.pass.cpp44
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/release.pass.cpp27
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset1.pass.cpp50
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset2.pass.cpp66
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset_self.pass.cpp29
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/swap.pass.cpp59
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/dereference.pass.cpp23
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/explicit_bool.pass.cpp39
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/get.pass.cpp24
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/get_deleter.pass.cpp37
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/index.fail.cpp47
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/op_arrow.pass.cpp30
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.special/cmp_nullptr.pass.cpp69
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.special/eq.pass.cpp86
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.special/rel.pass.cpp100
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.special/swap.pass.cpp77
-rw-r--r--test/std/utilities/memory/util.dynamic.safety/declare_no_pointers.pass.cpp23
-rw-r--r--test/std/utilities/memory/util.dynamic.safety/declare_reachable.pass.cpp24
-rw-r--r--test/std/utilities/memory/util.dynamic.safety/get_pointer_safety.pass.cpp23
-rw-r--r--test/std/utilities/memory/util.smartptr/nothing_to_do.pass.cpp12
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.enab/enable_shared_from_this.pass.cpp53
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.hash/hash_shared_ptr.pass.cpp30
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.hash/hash_unique_ptr.pass.cpp30
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_strong.pass.cpp53
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_strong_explicit.pass.cpp58
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_weak.pass.cpp53
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_weak_explicit.pass.cpp58
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_exchange.pass.cpp39
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_exchange_explicit.pass.cpp39
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_is_lock_free.pass.cpp31
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_load.pass.cpp37
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_load_explicit.pass.cpp37
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_store.pass.cpp38
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_store_explicit.pass.cpp38
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/test_deleter.h68
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/types.pass.cpp26
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.getdeleter/get_deleter.pass.cpp67
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/auto_ptr_Y.pass.cpp113
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr.pass.cpp121
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr_Y.pass.cpp121
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr_Y_rv.pass.cpp123
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr_rv.pass.cpp123
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/unique_ptr_Y.pass.cpp113
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cast/const_pointer_cast.pass.cpp57
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cast/dynamic_pointer_cast.pass.cpp57
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cast/static_pointer_cast.pass.cpp69
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cmp/cmp_nullptr.pass.cpp69
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cmp/eq.pass.cpp31
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cmp/lt.pass.cpp30
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/auto_ptr.pass.cpp104
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/default.pass.cpp22
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t.pass.cpp22
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter.pass.cpp47
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator.pass.cpp85
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator_throw.pass.cpp46
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_throw.pass.cpp63
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer.pass.cpp46
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter.pass.cpp48
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator.pass.cpp89
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator_throw.pass.cpp47
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_throw.pass.cpp64
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_throw.pass.cpp62
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr.pass.cpp62
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_Y.pass.cpp97
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_Y_rv.pass.cpp109
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_pointer.pass.cpp61
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_rv.pass.cpp73
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/unique_ptr.pass.cpp115
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/weak_ptr.pass.cpp79
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared.pass.cpp78
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared_no_variadics.pass.cpp118
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.pass.cpp80
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.volatile.pass.cpp61
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.dest/tested_elsewhere.pass.cpp12
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.io/io.pass.cpp29
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset.pass.cpp62
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer.pass.cpp64
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer_deleter.pass.cpp79
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer_deleter_allocator.pass.cpp88
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/swap.pass.cpp104
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/arrow.pass.cpp29
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/dereference.pass.cpp25
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/op_bool.pass.cpp29
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/owner_before_shared_ptr.pass.cpp28
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/owner_before_weak_ptr.pass.cpp31
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/unique.pass.cpp28
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.spec/swap.pass.cpp104
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.weak/types.pass.cpp26
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.ownerless/owner_less.pass.cpp82
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.assign/shared_ptr_Y.pass.cpp61
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.assign/weak_ptr.pass.cpp78
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.assign/weak_ptr_Y.pass.cpp78
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/default.pass.cpp25
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/shared_ptr_Y.pass.cpp95
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/weak_ptr.pass.cpp114
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/weak_ptr_Y.pass.cpp108
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.dest/tested_elsewhere.pass.cpp12
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.mod/reset.pass.cpp41
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.mod/swap.pass.cpp49
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/expired.pass.cpp46
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/lock.pass.cpp58
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/not_less_than.fail.cpp27
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/owner_before_shared_ptr.pass.cpp31
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/owner_before_weak_ptr.pass.cpp31
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.spec/swap.pass.cpp49
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.weakptr/bad_weak_ptr.pass.cpp31
-rw-r--r--test/std/utilities/memory/version.pass.cpp20
-rw-r--r--test/std/utilities/meta/meta.hel/bool_constant.pass.cpp32
-rw-r--r--test/std/utilities/meta/meta.hel/integral_constant.pass.cpp49
-rw-r--r--test/std/utilities/meta/meta.rel/is_base_of.pass.cpp49
-rw-r--r--test/std/utilities/meta/meta.rel/is_convertible.pass.cpp195
-rw-r--r--test/std/utilities/meta/meta.rel/is_convertible_fallback.pass.cpp18
-rw-r--r--test/std/utilities/meta/meta.rel/is_same.pass.cpp59
-rw-r--r--test/std/utilities/meta/meta.rqmts/nothing_to_do.pass.cpp12
-rw-r--r--test/std/utilities/meta/meta.trans/meta.trans.arr/remove_all_extents.pass.cpp41
-rw-r--r--test/std/utilities/meta/meta.trans/meta.trans.arr/remove_extent.pass.cpp42
-rw-r--r--test/std/utilities/meta/meta.trans/meta.trans.cv/add_const.pass.cpp43
-rw-r--r--test/std/utilities/meta/meta.trans/meta.trans.cv/add_cv.pass.cpp43
-rw-r--r--test/std/utilities/meta/meta.trans/meta.trans.cv/add_volatile.pass.cpp43
-rw-r--r--test/std/utilities/meta/meta.trans/meta.trans.cv/remove_const.pass.cpp43
-rw-r--r--test/std/utilities/meta/meta.trans/meta.trans.cv/remove_cv.pass.cpp43
-rw-r--r--test/std/utilities/meta/meta.trans/meta.trans.cv/remove_volatile.pass.cpp43
-rw-r--r--test/std/utilities/meta/meta.trans/meta.trans.other/aligned_storage.pass.cpp194
-rw-r--r--test/std/utilities/meta/meta.trans/meta.trans.other/aligned_union.pass.cpp92
-rw-r--r--test/std/utilities/meta/meta.trans/meta.trans.other/common_type.pass.cpp52
-rw-r--r--test/std/utilities/meta/meta.trans/meta.trans.other/conditional.pass.cpp24
-rw-r--r--test/std/utilities/meta/meta.trans/meta.trans.other/decay.pass.cpp34
-rw-r--r--test/std/utilities/meta/meta.trans/meta.trans.other/enable_if.fail.cpp19
-rw-r--r--test/std/utilities/meta/meta.trans/meta.trans.other/enable_if.pass.cpp24
-rw-r--r--test/std/utilities/meta/meta.trans/meta.trans.other/enable_if2.fail.cpp23
-rw-r--r--test/std/utilities/meta/meta.trans/meta.trans.other/result_of.pass.cpp252
-rw-r--r--test/std/utilities/meta/meta.trans/meta.trans.other/result_of11.pass.cpp88
-rw-r--r--test/std/utilities/meta/meta.trans/meta.trans.other/underlying_type.pass.cpp41
-rw-r--r--test/std/utilities/meta/meta.trans/meta.trans.ptr/add_pointer.pass.cpp34
-rw-r--r--test/std/utilities/meta/meta.trans/meta.trans.ptr/remove_pointer.pass.cpp43
-rw-r--r--test/std/utilities/meta/meta.trans/meta.trans.ref/add_lvalue_ref.pass.cpp34
-rw-r--r--test/std/utilities/meta/meta.trans/meta.trans.ref/add_rvalue_ref.pass.cpp40
-rw-r--r--test/std/utilities/meta/meta.trans/meta.trans.ref/remove_ref.pass.cpp46
-rw-r--r--test/std/utilities/meta/meta.trans/meta.trans.sign/make_signed.pass.cpp64
-rw-r--r--test/std/utilities/meta/meta.trans/meta.trans.sign/make_unsigned.pass.cpp65
-rw-r--r--test/std/utilities/meta/meta.trans/nothing_to_do.pass.cpp12
-rw-r--r--test/std/utilities/meta/meta.type.synop/nothing_to_do.pass.cpp12
-rw-r--r--test/std/utilities/meta/meta.unary.prop.query/alignment_of.pass.cpp47
-rw-r--r--test/std/utilities/meta/meta.unary.prop.query/extent.pass.cpp60
-rw-r--r--test/std/utilities/meta/meta.unary.prop.query/rank.pass.cpp46
-rw-r--r--test/std/utilities/meta/meta.unary.prop.query/void_t.pass.cpp69
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.cat/array.pass.cpp55
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.cat/class.pass.cpp53
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.cat/enum.pass.cpp51
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.cat/floating_point.pass.cpp51
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.cat/function.pass.cpp88
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.cat/integral.pass.cpp65
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.cat/lvalue_ref.pass.cpp41
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.cat/member_function_pointer.pass.cpp136
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.cat/member_function_pointer_no_variadics.pass.cpp76
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.cat/member_object_pointer.pass.cpp53
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.cat/nullptr.pass.cpp52
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.cat/pointer.pass.cpp52
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.cat/rvalue_ref.pass.cpp43
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.cat/union.pass.cpp55
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.cat/void.pass.cpp49
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.comp/array.pass.cpp46
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.comp/class.pass.cpp44
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.comp/enum.pass.cpp42
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.comp/floating_point.pass.cpp42
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.comp/function.pass.cpp43
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.comp/integral.pass.cpp56
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.comp/lvalue_ref.pass.cpp32
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.comp/member_function_pointer.pass.cpp46
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.comp/member_object_pointer.pass.cpp44
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.comp/pointer.pass.cpp43
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.comp/rvalue_ref.pass.cpp34
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.comp/union.pass.cpp46
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.comp/void.pass.cpp40
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.prop/__has_operator_addressof.pass.cpp71
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.prop/has_virtual_destructor.pass.cpp77
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.prop/is_abstract.pass.cpp71
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.prop/is_assignable.pass.cpp76
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.prop/is_const.pass.cpp37
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp86
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.prop/is_copy_assignable.pass.cpp80
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.prop/is_copy_constructible.pass.cpp88
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.prop/is_default_constructible.pass.cpp93
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.prop/is_destructible.pass.cpp121
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.prop/is_empty.pass.cpp65
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.prop/is_final.pass.cpp53
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.prop/is_literal_type.pass.cpp46
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.prop/is_move_assignable.pass.cpp65
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.prop/is_move_constructible.pass.cpp81
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_assignable.pass.cpp55
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_constructible.pass.cpp103
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_copy_assignable.pass.cpp65
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_copy_constructible.pass.cpp61
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_default_constructible.pass.cpp64
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_destructible.pass.cpp91
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_move_assignable.pass.cpp63
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_move_constructible.pass.cpp61
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.prop/is_pod.pass.cpp52
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.prop/is_polymorphic.pass.cpp82
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.prop/is_signed.pass.cpp59
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.prop/is_standard_layout.pass.cpp48
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivial.pass.cpp50
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_assignable.pass.cpp53
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_constructible.pass.cpp61
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copy_assignable.pass.cpp71
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copy_constructible.pass.cpp73
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copyable.pass.cpp63
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_default_constructible.pass.cpp76
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_destructible.pass.cpp83
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_move_assignable.pass.cpp71
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_move_constructible.pass.cpp89
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.prop/is_unsigned.pass.cpp59
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.prop/is_volatile.pass.cpp37
-rw-r--r--test/std/utilities/meta/meta.unary/nothing_to_do.pass.cpp12
-rw-r--r--test/std/utilities/meta/version.pass.cpp20
-rw-r--r--test/std/utilities/nothing_to_do.pass.cpp12
-rw-r--r--test/std/utilities/ratio/ratio.arithmetic/ratio_add.fail.cpp19
-rw-r--r--test/std/utilities/ratio/ratio.arithmetic/ratio_add.pass.cpp76
-rw-r--r--test/std/utilities/ratio/ratio.arithmetic/ratio_divide.fail.cpp19
-rw-r--r--test/std/utilities/ratio/ratio.arithmetic/ratio_divide.pass.cpp58
-rw-r--r--test/std/utilities/ratio/ratio.arithmetic/ratio_multiply.fail.cpp19
-rw-r--r--test/std/utilities/ratio/ratio.arithmetic/ratio_multiply.pass.cpp58
-rw-r--r--test/std/utilities/ratio/ratio.arithmetic/ratio_subtract.fail.cpp19
-rw-r--r--test/std/utilities/ratio/ratio.arithmetic/ratio_subtract.pass.cpp76
-rw-r--r--test/std/utilities/ratio/ratio.comparison/ratio_equal.pass.cpp56
-rw-r--r--test/std/utilities/ratio/ratio.comparison/ratio_greater.pass.cpp56
-rw-r--r--test/std/utilities/ratio/ratio.comparison/ratio_greater_equal.pass.cpp56
-rw-r--r--test/std/utilities/ratio/ratio.comparison/ratio_less.pass.cpp86
-rw-r--r--test/std/utilities/ratio/ratio.comparison/ratio_less_equal.pass.cpp56
-rw-r--r--test/std/utilities/ratio/ratio.comparison/ratio_not_equal.pass.cpp56
-rw-r--r--test/std/utilities/ratio/ratio.ratio/ratio.pass.cpp44
-rw-r--r--test/std/utilities/ratio/ratio.ratio/ratio1.fail.cpp18
-rw-r--r--test/std/utilities/ratio/ratio.ratio/ratio2.fail.cpp19
-rw-r--r--test/std/utilities/ratio/ratio.ratio/ratio3.fail.cpp19
-rw-r--r--test/std/utilities/ratio/ratio.si/nothing_to_do.pass.cpp12
-rw-r--r--test/std/utilities/ratio/typedefs.pass.cpp32
-rw-r--r--test/std/utilities/ratio/version.pass.cpp20
-rw-r--r--test/std/utilities/template.bitset/bitset.cons/char_ptr_ctor.pass.cpp56
-rw-r--r--test/std/utilities/template.bitset/bitset.cons/default.pass.cpp39
-rw-r--r--test/std/utilities/template.bitset/bitset.cons/string_ctor.pass.cpp88
-rw-r--r--test/std/utilities/template.bitset/bitset.cons/ull_ctor.pass.cpp42
-rw-r--r--test/std/utilities/template.bitset/bitset.hash/bitset.pass.cpp44
-rw-r--r--test/std/utilities/template.bitset/bitset.members/all.pass.cpp41
-rw-r--r--test/std/utilities/template.bitset/bitset.members/any.pass.cpp44
-rw-r--r--test/std/utilities/template.bitset/bitset.members/count.pass.cpp51
-rw-r--r--test/std/utilities/template.bitset/bitset.members/flip_all.pass.cpp49
-rw-r--r--test/std/utilities/template.bitset/bitset.members/flip_one.pass.cpp60
-rw-r--r--test/std/utilities/template.bitset/bitset.members/index.pass.cpp67
-rw-r--r--test/std/utilities/template.bitset/bitset.members/index_const.pass.cpp49
-rw-r--r--test/std/utilities/template.bitset/bitset.members/left_shift.pass.cpp50
-rw-r--r--test/std/utilities/template.bitset/bitset.members/left_shift_eq.pass.cpp55
-rw-r--r--test/std/utilities/template.bitset/bitset.members/none.pass.cpp44
-rw-r--r--test/std/utilities/template.bitset/bitset.members/not_all.pass.cpp48
-rw-r--r--test/std/utilities/template.bitset/bitset.members/op_and_eq.pass.cpp50
-rw-r--r--test/std/utilities/template.bitset/bitset.members/op_eq_eq.pass.cpp55
-rw-r--r--test/std/utilities/template.bitset/bitset.members/op_or_eq.pass.cpp50
-rw-r--r--test/std/utilities/template.bitset/bitset.members/op_xor_eq.pass.cpp50
-rw-r--r--test/std/utilities/template.bitset/bitset.members/reset_all.pass.cpp38
-rw-r--r--test/std/utilities/template.bitset/bitset.members/reset_one.pass.cpp50
-rw-r--r--test/std/utilities/template.bitset/bitset.members/right_shift.pass.cpp50
-rw-r--r--test/std/utilities/template.bitset/bitset.members/right_shift_eq.pass.cpp55
-rw-r--r--test/std/utilities/template.bitset/bitset.members/set_all.pass.cpp37
-rw-r--r--test/std/utilities/template.bitset/bitset.members/set_one.pass.cpp52
-rw-r--r--test/std/utilities/template.bitset/bitset.members/size.pass.cpp33
-rw-r--r--test/std/utilities/template.bitset/bitset.members/test.pass.cpp55
-rw-r--r--test/std/utilities/template.bitset/bitset.members/to_string.pass.cpp162
-rw-r--r--test/std/utilities/template.bitset/bitset.members/to_ullong.pass.cpp50
-rw-r--r--test/std/utilities/template.bitset/bitset.members/to_ulong.pass.cpp51
-rw-r--r--test/std/utilities/template.bitset/bitset.operators/op_and.pass.cpp48
-rw-r--r--test/std/utilities/template.bitset/bitset.operators/op_not.pass.cpp48
-rw-r--r--test/std/utilities/template.bitset/bitset.operators/op_or.pass.cpp48
-rw-r--r--test/std/utilities/template.bitset/bitset.operators/stream_in.pass.cpp26
-rw-r--r--test/std/utilities/template.bitset/bitset.operators/stream_out.pass.cpp26
-rw-r--r--test/std/utilities/template.bitset/includes.pass.cpp32
-rw-r--r--test/std/utilities/template.bitset/version.pass.cpp20
-rw-r--r--test/std/utilities/time/clock.h26
-rw-r--r--test/std/utilities/time/hours.pass.cpp27
-rw-r--r--test/std/utilities/time/microseconds.pass.cpp27
-rw-r--r--test/std/utilities/time/milliseconds.pass.cpp27
-rw-r--r--test/std/utilities/time/minutes.pass.cpp27
-rw-r--r--test/std/utilities/time/nanoseconds.pass.cpp27
-rw-r--r--test/std/utilities/time/rep.h27
-rw-r--r--test/std/utilities/time/seconds.pass.cpp27
-rw-r--r--test/std/utilities/time/time.clock.req/nothing_to_do.pass.cpp12
-rw-r--r--test/std/utilities/time/time.clock/nothing_to_do.pass.cpp12
-rw-r--r--test/std/utilities/time/time.clock/time.clock.hires/consistency.pass.cpp34
-rw-r--r--test/std/utilities/time/time.clock/time.clock.hires/now.pass.cpp26
-rw-r--r--test/std/utilities/time/time.clock/time.clock.steady/consistency.pass.cpp35
-rw-r--r--test/std/utilities/time/time.clock/time.clock.steady/now.pass.cpp27
-rw-r--r--test/std/utilities/time/time.clock/time.clock.system/consistency.pass.cpp35
-rw-r--r--test/std/utilities/time/time.clock/time.clock.system/from_time_t.pass.cpp24
-rw-r--r--test/std/utilities/time/time.clock/time.clock.system/now.pass.cpp26
-rw-r--r--test/std/utilities/time/time.clock/time.clock.system/rep_signed.pass.cpp23
-rw-r--r--test/std/utilities/time/time.clock/time.clock.system/to_time_t.pass.cpp24
-rw-r--r--test/std/utilities/time/time.duration/default_ratio.pass.cpp26
-rw-r--r--test/std/utilities/time/time.duration/duration.fail.cpp23
-rw-r--r--test/std/utilities/time/time.duration/positive_num.fail.cpp22
-rw-r--r--test/std/utilities/time/time.duration/ratio.fail.cpp30
-rw-r--r--test/std/utilities/time/time.duration/time.duration.arithmetic/op_++.pass.cpp25
-rw-r--r--test/std/utilities/time/time.duration/time.duration.arithmetic/op_++int.pass.cpp25
-rw-r--r--test/std/utilities/time/time.duration/time.duration.arithmetic/op_+.pass.cpp33
-rw-r--r--test/std/utilities/time/time.duration/time.duration.arithmetic/op_+=.pass.cpp26
-rw-r--r--test/std/utilities/time/time.duration/time.duration.arithmetic/op_--.pass.cpp25
-rw-r--r--test/std/utilities/time/time.duration/time.duration.arithmetic/op_--int.pass.cpp25
-rw-r--r--test/std/utilities/time/time.duration/time.duration.arithmetic/op_-.pass.cpp33
-rw-r--r--test/std/utilities/time/time.duration/time.duration.arithmetic/op_-=.pass.cpp26
-rw-r--r--test/std/utilities/time/time.duration/time.duration.arithmetic/op_divide=.pass.cpp24
-rw-r--r--test/std/utilities/time/time.duration/time.duration.arithmetic/op_mod=duration.pass.cpp27
-rw-r--r--test/std/utilities/time/time.duration/time.duration.arithmetic/op_mod=rep.pass.cpp24
-rw-r--r--test/std/utilities/time/time.duration/time.duration.arithmetic/op_times=.pass.cpp24
-rw-r--r--test/std/utilities/time/time.duration/time.duration.cast/duration_cast.pass.cpp52
-rw-r--r--test/std/utilities/time/time.duration/time.duration.cast/toduration.fail.cpp25
-rw-r--r--test/std/utilities/time/time.duration/time.duration.comparisons/op_equal.pass.cpp115
-rw-r--r--test/std/utilities/time/time.duration/time.duration.comparisons/op_less.pass.cpp153
-rw-r--r--test/std/utilities/time/time.duration/time.duration.cons/convert_exact.pass.cpp36
-rw-r--r--test/std/utilities/time/time.duration/time.duration.cons/convert_float_to_int.fail.cpp25
-rw-r--r--test/std/utilities/time/time.duration/time.duration.cons/convert_inexact.fail.cpp25
-rw-r--r--test/std/utilities/time/time.duration/time.duration.cons/convert_inexact.pass.cpp36
-rw-r--r--test/std/utilities/time/time.duration/time.duration.cons/convert_int_to_float.pass.cpp36
-rw-r--r--test/std/utilities/time/time.duration/time.duration.cons/convert_overflow.pass.cpp37
-rw-r--r--test/std/utilities/time/time.duration/time.duration.cons/default.pass.cpp38
-rw-r--r--test/std/utilities/time/time.duration/time.duration.cons/rep.pass.cpp40
-rw-r--r--test/std/utilities/time/time.duration/time.duration.cons/rep01.fail.cpp26
-rw-r--r--test/std/utilities/time/time.duration/time.duration.cons/rep02.fail.cpp26
-rw-r--r--test/std/utilities/time/time.duration/time.duration.cons/rep02.pass.cpp30
-rw-r--r--test/std/utilities/time/time.duration/time.duration.cons/rep03.fail.cpp24
-rw-r--r--test/std/utilities/time/time.duration/time.duration.literals/literals.pass.cpp59
-rw-r--r--test/std/utilities/time/time.duration/time.duration.literals/literals1.fail.cpp21
-rw-r--r--test/std/utilities/time/time.duration/time.duration.literals/literals1.pass.cpp48
-rw-r--r--test/std/utilities/time/time.duration/time.duration.literals/literals2.fail.cpp22
-rw-r--r--test/std/utilities/time/time.duration/time.duration.literals/literals2.pass.cpp51
-rw-r--r--test/std/utilities/time/time.duration/time.duration.nonmember/op_+.pass.cpp73
-rw-r--r--test/std/utilities/time/time.duration/time.duration.nonmember/op_-.pass.cpp74
-rw-r--r--test/std/utilities/time/time.duration/time.duration.nonmember/op_divide_duration.pass.cpp66
-rw-r--r--test/std/utilities/time/time.duration/time.duration.nonmember/op_divide_rep.fail.cpp26
-rw-r--r--test/std/utilities/time/time.duration/time.duration.nonmember/op_divide_rep.pass.cpp36
-rw-r--r--test/std/utilities/time/time.duration/time.duration.nonmember/op_mod_duration.pass.cpp62
-rw-r--r--test/std/utilities/time/time.duration/time.duration.nonmember/op_mod_rep.fail.cpp26
-rw-r--r--test/std/utilities/time/time.duration/time.duration.nonmember/op_mod_rep.pass.cpp36
-rw-r--r--test/std/utilities/time/time.duration/time.duration.nonmember/op_times_rep.pass.cpp45
-rw-r--r--test/std/utilities/time/time.duration/time.duration.nonmember/op_times_rep1.fail.cpp30
-rw-r--r--test/std/utilities/time/time.duration/time.duration.nonmember/op_times_rep2.fail.cpp30
-rw-r--r--test/std/utilities/time/time.duration/time.duration.observer/tested_elsewhere.pass.cpp12
-rw-r--r--test/std/utilities/time/time.duration/time.duration.special/max.pass.cpp43
-rw-r--r--test/std/utilities/time/time.duration/time.duration.special/min.pass.cpp43
-rw-r--r--test/std/utilities/time/time.duration/time.duration.special/zero.pass.cpp42
-rw-r--r--test/std/utilities/time/time.duration/types.pass.cpp27
-rw-r--r--test/std/utilities/time/time.point/default_duration.pass.cpp26
-rw-r--r--test/std/utilities/time/time.point/duration.fail.cpp22
-rw-r--r--test/std/utilities/time/time.point/time.point.arithmetic/op_+=.pass.cpp26
-rw-r--r--test/std/utilities/time/time.point/time.point.arithmetic/op_-=.pass.cpp26
-rw-r--r--test/std/utilities/time/time.point/time.point.cast/time_point_cast.pass.cpp80
-rw-r--r--test/std/utilities/time/time.point/time.point.cast/toduration.fail.cpp28
-rw-r--r--test/std/utilities/time/time.point/time.point.comparisons/op_equal.fail.cpp40
-rw-r--r--test/std/utilities/time/time.point/time.point.comparisons/op_equal.pass.cpp84
-rw-r--r--test/std/utilities/time/time.point/time.point.comparisons/op_less.fail.cpp48
-rw-r--r--test/std/utilities/time/time.point/time.point.comparisons/op_less.pass.cpp108
-rw-r--r--test/std/utilities/time/time.point/time.point.cons/convert.fail.cpp30
-rw-r--r--test/std/utilities/time/time.point/time.point.cons/convert.pass.cpp37
-rw-r--r--test/std/utilities/time/time.point/time.point.cons/default.pass.cpp35
-rw-r--r--test/std/utilities/time/time.point/time.point.cons/duration.fail.cpp25
-rw-r--r--test/std/utilities/time/time.point/time.point.cons/duration.pass.cpp41
-rw-r--r--test/std/utilities/time/time.point/time.point.nonmember/op_+.pass.cpp46
-rw-r--r--test/std/utilities/time/time.point/time.point.nonmember/op_-duration.pass.cpp38
-rw-r--r--test/std/utilities/time/time.point/time.point.nonmember/op_-time_point.pass.cpp38
-rw-r--r--test/std/utilities/time/time.point/time.point.observer/tested_elsewhere.pass.cpp12
-rw-r--r--test/std/utilities/time/time.point/time.point.special/max.pass.cpp25
-rw-r--r--test/std/utilities/time/time.point/time.point.special/min.pass.cpp25
-rw-r--r--test/std/utilities/time/time.traits/nothing_to_do.pass.cpp12
-rw-r--r--test/std/utilities/time/time.traits/time.traits.duration_values/max.pass.cpp36
-rw-r--r--test/std/utilities/time/time.traits/time.traits.duration_values/min.pass.cpp36
-rw-r--r--test/std/utilities/time/time.traits/time.traits.duration_values/zero.pass.cpp27
-rw-r--r--test/std/utilities/time/time.traits/time.traits.is_fp/treat_as_floating_point.pass.cpp37
-rw-r--r--test/std/utilities/time/time.traits/time.traits.specializations/duration.pass.cpp42
-rw-r--r--test/std/utilities/time/time.traits/time.traits.specializations/time_point.pass.cpp46
-rw-r--r--test/std/utilities/time/version.pass.cpp20
-rw-r--r--test/std/utilities/tuple/tuple.general/tuple.smartptr.pass.cpp38
-rw-r--r--test/std/utilities/tuple/tuple.tuple/TupleFunction.pass.cpp35
-rw-r--r--test/std/utilities/tuple/tuple.tuple/alloc_first.h58
-rw-r--r--test/std/utilities/tuple/tuple.tuple/alloc_last.h58
-rw-r--r--test/std/utilities/tuple/tuple.tuple/empty_member.pass.cpp46
-rw-r--r--test/std/utilities/tuple/tuple.tuple/tuple.assign/const_pair.pass.cpp34
-rw-r--r--test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_copy.pass.cpp77
-rw-r--r--test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_move.pass.cpp91
-rw-r--r--test/std/utilities/tuple/tuple.tuple/tuple.assign/copy.fail.cpp31
-rw-r--r--test/std/utilities/tuple/tuple.tuple/tuple.assign/copy.pass.cpp54
-rw-r--r--test/std/utilities/tuple/tuple.tuple/tuple.assign/move.pass.cpp56
-rw-r--r--test/std/utilities/tuple/tuple.tuple/tuple.assign/move_pair.pass.cpp50
-rw-r--r--test/std/utilities/tuple/tuple.tuple/tuple.assign/tuple_array_template_depth.pass.cpp34
-rw-r--r--test/std/utilities/tuple/tuple.tuple/tuple.cnstr/UTypes.fail.cpp51
-rw-r--r--test/std/utilities/tuple/tuple.tuple/tuple.cnstr/UTypes.pass.cpp146
-rw-r--r--test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc.pass.cpp81
-rw-r--r--test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_UTypes.pass.cpp141
-rw-r--r--test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_const_Types.pass.cpp76
-rw-r--r--test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_const_pair.pass.cpp59
-rw-r--r--test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_convert_copy.pass.cpp69
-rw-r--r--test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_convert_move.pass.cpp84
-rw-r--r--test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_copy.pass.cpp78
-rw-r--r--test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_move.pass.cpp77
-rw-r--r--test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_move_pair.pass.cpp55
-rw-r--r--test/std/utilities/tuple/tuple.tuple/tuple.cnstr/const_Types.fail.cpp27
-rw-r--r--test/std/utilities/tuple/tuple.tuple/tuple.cnstr/const_Types.pass.cpp132
-rw-r--r--test/std/utilities/tuple/tuple.tuple/tuple.cnstr/const_Types2.fail.cpp27
-rw-r--r--test/std/utilities/tuple/tuple.tuple/tuple.cnstr/const_pair.pass.cpp44
-rw-r--r--test/std/utilities/tuple/tuple.tuple/tuple.cnstr/convert_copy.pass.cpp118
-rw-r--r--test/std/utilities/tuple/tuple.tuple/tuple.cnstr/convert_move.pass.cpp84
-rw-r--r--test/std/utilities/tuple/tuple.tuple/tuple.cnstr/copy.fail.cpp30
-rw-r--r--test/std/utilities/tuple/tuple.tuple/tuple.cnstr/copy.pass.cpp68
-rw-r--r--test/std/utilities/tuple/tuple.tuple/tuple.cnstr/default.pass.cpp110
-rw-r--r--test/std/utilities/tuple/tuple.tuple/tuple.cnstr/move.pass.cpp73
-rw-r--r--test/std/utilities/tuple/tuple.tuple/tuple.cnstr/move_pair.pass.cpp48
-rw-r--r--test/std/utilities/tuple/tuple.tuple/tuple.cnstr/tuple_array_template_depth.pass.cpp36
-rw-r--r--test/std/utilities/tuple/tuple.tuple/tuple.creation/forward_as_tuple.pass.cpp86
-rw-r--r--test/std/utilities/tuple/tuple.tuple/tuple.creation/make_tuple.pass.cpp52
-rw-r--r--test/std/utilities/tuple/tuple.tuple/tuple.creation/tie.pass.cpp41
-rw-r--r--test/std/utilities/tuple/tuple.tuple/tuple.creation/tuple_cat.pass.cpp241
-rw-r--r--test/std/utilities/tuple/tuple.tuple/tuple.elem/get_const.fail.cpp41
-rw-r--r--test/std/utilities/tuple/tuple.tuple/tuple.elem/get_const.pass.cpp66
-rw-r--r--test/std/utilities/tuple/tuple.tuple/tuple.elem/get_non_const.pass.cpp83
-rw-r--r--test/std/utilities/tuple/tuple.tuple/tuple.elem/get_rv.pass.cpp33
-rw-r--r--test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type.pass.cpp60
-rw-r--r--test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type1.fail.cpp27
-rw-r--r--test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type2.fail.cpp27
-rw-r--r--test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type3.fail.cpp27
-rw-r--r--test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type4.fail.cpp27
-rw-r--r--test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple.include.array.pass.cpp52
-rw-r--r--test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple.include.utility.pass.cpp49
-rw-r--r--test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_element.pass.cpp49
-rw-r--r--test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size.pass.cpp42
-rw-r--r--test/std/utilities/tuple/tuple.tuple/tuple.rel/eq.pass.cpp156
-rw-r--r--test/std/utilities/tuple/tuple.tuple/tuple.rel/lt.pass.cpp210
-rw-r--r--test/std/utilities/tuple/tuple.tuple/tuple.special/non_member_swap.pass.cpp62
-rw-r--r--test/std/utilities/tuple/tuple.tuple/tuple.swap/member_swap.pass.cpp61
-rw-r--r--test/std/utilities/tuple/tuple.tuple/tuple.traits/uses_allocator.pass.cpp46
-rw-r--r--test/std/utilities/tuple/version.pass.cpp20
-rw-r--r--test/std/utilities/type.index/type.index.hash/hash.pass.cpp32
-rw-r--r--test/std/utilities/type.index/type.index.members/ctor.pass.cpp25
-rw-r--r--test/std/utilities/type.index/type.index.members/eq.pass.cpp27
-rw-r--r--test/std/utilities/type.index/type.index.members/hash_code.pass.cpp24
-rw-r--r--test/std/utilities/type.index/type.index.members/lt.pass.cpp45
-rw-r--r--test/std/utilities/type.index/type.index.members/name.pass.cpp25
-rw-r--r--test/std/utilities/type.index/type.index.overview/copy_assign.pass.cpp26
-rw-r--r--test/std/utilities/type.index/type.index.overview/copy_ctor.pass.cpp24
-rw-r--r--test/std/utilities/type.index/type.index.synopsis/hash_type_index.pass.cpp26
-rw-r--r--test/std/utilities/type.index/version.pass.cpp20
-rw-r--r--test/std/utilities/utilities.general/nothing_to_do.pass.cpp12
-rw-r--r--test/std/utilities/utility.requirements/allocator.requirements/nothing_to_do.pass.cpp12
-rw-r--r--test/std/utilities/utility.requirements/hash.requirements/nothing_to_do.pass.cpp12
-rw-r--r--test/std/utilities/utility.requirements/nothing_to_do.pass.cpp12
-rw-r--r--test/std/utilities/utility.requirements/nullablepointer.requirements/nothing_to_do.pass.cpp12
-rw-r--r--test/std/utilities/utility.requirements/swappable.requirements/nothing_to_do.pass.cpp12
-rw-r--r--test/std/utilities/utility.requirements/utility.arg.requirements/nothing_to_do.pass.cpp12
-rw-r--r--test/std/utilities/utility/declval/declval.pass.cpp30
-rw-r--r--test/std/utilities/utility/exchange/exchange.pass.cpp58
-rw-r--r--test/std/utilities/utility/forward/forward.pass.cpp80
-rw-r--r--test/std/utilities/utility/forward/forward1.fail.cpp24
-rw-r--r--test/std/utilities/utility/forward/forward2.fail.cpp25
-rw-r--r--test/std/utilities/utility/forward/forward3.fail.cpp24
-rw-r--r--test/std/utilities/utility/forward/forward4.fail.cpp25
-rw-r--r--test/std/utilities/utility/forward/forward5.fail.cpp25
-rw-r--r--test/std/utilities/utility/forward/forward6.fail.cpp22
-rw-r--r--test/std/utilities/utility/forward/move_copy.pass.cpp61
-rw-r--r--test/std/utilities/utility/forward/move_if_noexcept.pass.cpp74
-rw-r--r--test/std/utilities/utility/forward/move_only.pass.cpp39
-rw-r--r--test/std/utilities/utility/forward/move_only1.fail.cpp52
-rw-r--r--test/std/utilities/utility/forward/move_only2.fail.cpp52
-rw-r--r--test/std/utilities/utility/forward/move_only3.fail.cpp49
-rw-r--r--test/std/utilities/utility/forward/move_only4.fail.cpp52
-rw-r--r--test/std/utilities/utility/operators/rel_ops.pass.cpp49
-rw-r--r--test/std/utilities/utility/pairs/nothing_to_do.pass.cpp12
-rw-r--r--test/std/utilities/utility/pairs/pair.astuple/get_const.fail.cpp30
-rw-r--r--test/std/utilities/utility/pairs/pair.astuple/get_const.pass.cpp38
-rw-r--r--test/std/utilities/utility/pairs/pair.astuple/get_non_const.pass.cpp51
-rw-r--r--test/std/utilities/utility/pairs/pair.astuple/get_rv.pass.cpp32
-rw-r--r--test/std/utilities/utility/pairs/pair.astuple/pairs.by.type.pass.cpp44
-rw-r--r--test/std/utilities/utility/pairs/pair.astuple/pairs.by.type1.fail.cpp24
-rw-r--r--test/std/utilities/utility/pairs/pair.astuple/pairs.by.type2.fail.cpp24
-rw-r--r--test/std/utilities/utility/pairs/pair.astuple/pairs.by.type3.fail.cpp24
-rw-r--r--test/std/utilities/utility/pairs/pair.astuple/tuple_element.pass.cpp55
-rw-r--r--test/std/utilities/utility/pairs/pair.astuple/tuple_size.pass.cpp36
-rw-r--r--test/std/utilities/utility/pairs/pair.piecewise/piecewise_construct.pass.cpp55
-rw-r--r--test/std/utilities/utility/pairs/pairs.general/nothing_to_do.pass.cpp12
-rw-r--r--test/std/utilities/utility/pairs/pairs.pair/U_V.pass.cpp30
-rw-r--r--test/std/utilities/utility/pairs/pairs.pair/assign_const_pair_U_V.pass.cpp30
-rw-r--r--test/std/utilities/utility/pairs/pairs.pair/assign_rv_pair.pass.cpp32
-rw-r--r--test/std/utilities/utility/pairs/pairs.pair/assign_rv_pair_U_V.pass.cpp43
-rw-r--r--test/std/utilities/utility/pairs/pairs.pair/const_first_const_second.pass.cpp68
-rw-r--r--test/std/utilities/utility/pairs/pairs.pair/const_pair_U_V.pass.cpp40
-rw-r--r--test/std/utilities/utility/pairs/pairs.pair/copy_ctor.pass.cpp40
-rw-r--r--test/std/utilities/utility/pairs/pairs.pair/default.pass.cpp36
-rw-r--r--test/std/utilities/utility/pairs/pairs.pair/piecewise.pass.cpp35
-rw-r--r--test/std/utilities/utility/pairs/pairs.pair/rv_pair_U_V.pass.cpp42
-rw-r--r--test/std/utilities/utility/pairs/pairs.pair/swap.pass.cpp31
-rw-r--r--test/std/utilities/utility/pairs/pairs.pair/types.pass.cpp26
-rw-r--r--test/std/utilities/utility/pairs/pairs.spec/comparison.pass.cpp95
-rw-r--r--test/std/utilities/utility/pairs/pairs.spec/make_pair.pass.cpp51
-rw-r--r--test/std/utilities/utility/pairs/pairs.spec/non_member_swap.pass.cpp31
-rw-r--r--test/std/utilities/utility/utility.swap/swap.pass.cpp53
-rw-r--r--test/std/utilities/utility/utility.swap/swap_array.pass.cpp65
-rw-r--r--test/std/utilities/utility/version.pass.cpp20
-rw-r--r--test/support/Counter.h52
-rw-r--r--test/support/DefaultOnly.h35
-rw-r--r--test/support/MoveOnly.h50
-rw-r--r--test/support/allocators.h185
-rw-r--r--test/support/asan_testing.h37
-rw-r--r--test/support/cmpxchg_loop.h51
-rw-r--r--test/support/constexpr_char_traits.hpp138
-rw-r--r--test/support/count_new.hpp206
-rw-r--r--test/support/counting_predicates.hpp46
-rw-r--r--test/support/hexfloat.h38
-rw-r--r--test/support/is_transparent.h73
-rw-r--r--test/support/min_allocator.h291
-rw-r--r--test/support/nasty_containers.hpp282
-rw-r--r--test/support/nasty_macros.hpp32
-rw-r--r--test/support/nothing_to_do.pass.cpp14
-rw-r--r--test/support/platform_support.h98
-rw-r--r--test/support/private_constructor.hpp31
-rw-r--r--test/support/test_allocator.h226
-rw-r--r--test/support/test_iterators.h329
-rw-r--r--test/support/test_macros.h83
-rw-r--r--test/support/tracked_value.h50
-rw-r--r--test/support/user_defined_integral.hpp44
-rwxr-xr-xtest/testit180
4996 files changed, 417989 insertions, 0 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
new file mode 100644
index 000000000000..ca937a8dba9a
--- /dev/null
+++ b/test/CMakeLists.txt
@@ -0,0 +1,89 @@
+macro(pythonize_bool var)
+ if (${var})
+ set(${var} True)
+ else()
+ set(${var} False)
+ endif()
+endmacro()
+
+set(LIT_EXECUTABLE "" CACHE FILEPATH "Path to LLVM's llvm-lit.")
+
+if(LIBCXX_BUILT_STANDALONE)
+ # Make sure we can use the console pool for recent cmake and ninja > 1.5
+ if(CMAKE_VERSION VERSION_LESS 3.1.20141117)
+ set(cmake_3_2_USES_TERMINAL)
+ else()
+ set(cmake_3_2_USES_TERMINAL USES_TERMINAL)
+ endif()
+else()
+ include(FindPythonInterp)
+ if(PYTHONINTERP_FOUND)
+ set(LIT_EXECUTABLE
+ ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/utils/lit/lit.py)
+ else()
+ message(WARNING "Could not find Python, cannot set LIT_EXECUTABLE.")
+ endif()
+endif()
+
+if (LIT_EXECUTABLE)
+ set(LIT_ARGS_DEFAULT "-sv --show-unsupported --show-xfail")
+ if (MSVC OR XCODE)
+ set(LIT_ARGS_DEFAULT "${LIT_ARGS_DEFAULT} --no-progress-bar")
+ endif()
+ set(LLVM_LIT_ARGS "${LIT_ARGS_DEFAULT}"
+ CACHE STRING "Default options for lit")
+ set(LIT_ARGS "${LLVM_LIT_ARGS}")
+ separate_arguments(LIT_ARGS)
+
+ set(LIBCXX_LIT_VARIANT "libcxx" CACHE STRING
+ "Configuration variant to use for LIT.")
+
+ pythonize_bool(LIBCXX_ENABLE_EXCEPTIONS)
+ pythonize_bool(LIBCXX_ENABLE_RTTI)
+ pythonize_bool(LIBCXX_ENABLE_SHARED)
+ pythonize_bool(LIBCXX_BUILD_32_BITS)
+ pythonize_bool(LIBCXX_ENABLE_GLOBAL_FILESYSTEM_NAMESPACE)
+ pythonize_bool(LIBCXX_ENABLE_STDIN)
+ pythonize_bool(LIBCXX_ENABLE_STDOUT)
+ pythonize_bool(LIBCXX_ENABLE_THREADS)
+ pythonize_bool(LIBCXX_ENABLE_THREAD_UNSAFE_C_FUNCTIONS)
+ pythonize_bool(LIBCXX_ENABLE_MONOTONIC_CLOCK)
+ pythonize_bool(LIBCXX_GENERATE_COVERAGE)
+ pythonize_bool(LIBCXXABI_USE_LLVM_UNWINDER)
+
+ # The tests shouldn't link to any ABI library when it has been linked into
+ # libc++ statically.
+ if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY)
+ set(LIBCXX_CXX_ABI_LIBNAME "none")
+ endif()
+ set(LIBCXX_TARGET_INFO "libcxx.test.target_info.LocalTI" CACHE STRING
+ "TargetInfo to use when setting up test environment.")
+ set(LIBCXX_EXECUTOR "None" CACHE STRING
+ "Executor to use when running tests.")
+
+ set(AUTO_GEN_COMMENT "## Autogenerated by libcxx configuration.\n# Do not edit!")
+
+ configure_file(
+ ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
+ ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
+ @ONLY)
+
+ add_custom_target(check-libcxx
+ COMMAND ${LIT_EXECUTABLE}
+ ${LIT_ARGS}
+ ${CMAKE_CURRENT_BINARY_DIR}
+ DEPENDS cxx
+ COMMENT "Running libcxx tests"
+ ${cmake_3_2_USES_TERMINAL})
+
+ if (LIBCXX_GENERATE_COVERAGE)
+ include(CodeCoverage)
+ set(output_dir "${CMAKE_CURRENT_BINARY_DIR}/coverage")
+ set(capture_dirs "${LIBCXX_LIB_CMAKEFILES_DIR}/cxx.dir/;${CMAKE_CURRENT_BINARY_DIR}")
+ set(extract_dirs "${LIBCXX_SOURCE_DIR}/include;${LIBCXX_SOURCE_DIR}/src")
+ setup_lcov_test_target_coverage("cxx" "${output_dir}" "${capture_dirs}" "${extract_dirs}")
+ endif()
+else()
+ message(WARNING
+ "LIT_EXECUTABLE not set, no check-libcxx target will be available!")
+endif()
diff --git a/test/libcxx/__init__.py b/test/libcxx/__init__.py
new file mode 100644
index 000000000000..e69de29bb2d1
--- /dev/null
+++ b/test/libcxx/__init__.py
diff --git a/test/libcxx/compiler.py b/test/libcxx/compiler.py
new file mode 100644
index 000000000000..7afbed461e31
--- /dev/null
+++ b/test/libcxx/compiler.py
@@ -0,0 +1,152 @@
+import os
+import lit.util
+import libcxx.util
+
+
+class CXXCompiler(object):
+ def __init__(self, path, flags=None, compile_flags=None, link_flags=None,
+ use_ccache=False):
+ self.path = path
+ self.flags = list(flags or [])
+ self.compile_flags = list(compile_flags or [])
+ self.link_flags = list(link_flags or [])
+ self.use_ccache = use_ccache
+ self.type = None
+ self.version = None
+ self._initTypeAndVersion()
+
+ def _initTypeAndVersion(self):
+ # Get compiler type and version
+ macros = self.dumpMacros()
+ if macros is None:
+ return
+ compiler_type = None
+ major_ver = minor_ver = patchlevel = None
+ if '__clang__' in macros.keys():
+ compiler_type = 'clang'
+ # Treat apple's llvm fork differently.
+ if '__apple_build_version__' in macros.keys():
+ compiler_type = 'apple-clang'
+ major_ver = macros['__clang_major__']
+ minor_ver = macros['__clang_minor__']
+ patchlevel = macros['__clang_patchlevel__']
+ elif '__GNUC__' in macros.keys():
+ compiler_type = 'gcc'
+ major_ver = macros['__GNUC__']
+ minor_ver = macros['__GNUC_MINOR__']
+ patchlevel = macros['__GNUC_PATCHLEVEL__']
+ self.type = compiler_type
+ self.version = (major_ver, minor_ver, patchlevel)
+
+ def _basicCmd(self, source_files, out, is_link=False, input_is_cxx=False):
+ cmd = []
+ if self.use_ccache and not is_link:
+ cmd += ['ccache']
+ cmd += [self.path]
+ if out is not None:
+ cmd += ['-o', out]
+ if input_is_cxx:
+ cmd += ['-x', 'c++']
+ if isinstance(source_files, list):
+ cmd += source_files
+ elif isinstance(source_files, str):
+ cmd += [source_files]
+ else:
+ raise TypeError('source_files must be a string or list')
+ return cmd
+
+ def preprocessCmd(self, source_files, out=None, flags=[]):
+ cmd = self._basicCmd(source_files, out, input_is_cxx=True) + ['-E']
+ cmd += self.flags + self.compile_flags + flags
+ return cmd
+
+ def compileCmd(self, source_files, out=None, flags=[]):
+ cmd = self._basicCmd(source_files, out, input_is_cxx=True) + ['-c']
+ cmd += self.flags + self.compile_flags + flags
+ return cmd
+
+ def linkCmd(self, source_files, out=None, flags=[]):
+ cmd = self._basicCmd(source_files, out, is_link=True)
+ cmd += self.flags + self.link_flags + flags
+ return cmd
+
+ def compileLinkCmd(self, source_files, out=None, flags=[]):
+ cmd = self._basicCmd(source_files, out, is_link=True)
+ cmd += self.flags + self.compile_flags + self.link_flags + flags
+ return cmd
+
+ def preprocess(self, source_files, out=None, flags=[], env=None, cwd=None):
+ cmd = self.preprocessCmd(source_files, out, flags)
+ out, err, rc = lit.util.executeCommand(cmd, env=env, cwd=cwd)
+ return cmd, out, err, rc
+
+ def compile(self, source_files, out=None, flags=[], env=None, cwd=None):
+ cmd = self.compileCmd(source_files, out, flags)
+ out, err, rc = lit.util.executeCommand(cmd, env=env, cwd=cwd)
+ return cmd, out, err, rc
+
+ def link(self, source_files, out=None, flags=[], env=None, cwd=None):
+ cmd = self.linkCmd(source_files, out, flags)
+ out, err, rc = lit.util.executeCommand(cmd, env=env, cwd=cwd)
+ return cmd, out, err, rc
+
+ def compileLink(self, source_files, out=None, flags=[], env=None,
+ cwd=None):
+ cmd = self.compileLinkCmd(source_files, out, flags)
+ out, err, rc = lit.util.executeCommand(cmd, env=env, cwd=cwd)
+ return cmd, out, err, rc
+
+ def compileLinkTwoSteps(self, source_file, out=None, object_file=None,
+ flags=[], env=None, cwd=None):
+ if not isinstance(source_file, str):
+ raise TypeError('This function only accepts a single input file')
+ if object_file is None:
+ # Create, use and delete a temporary object file if none is given.
+ with_fn = lambda: libcxx.util.guardedTempFilename(suffix='.o')
+ else:
+ # Otherwise wrap the filename in a context manager function.
+ with_fn = lambda: libcxx.util.nullContext(object_file)
+ with with_fn() as object_file:
+ cc_cmd, cc_stdout, cc_stderr, rc = self.compile(
+ source_file, object_file, flags=flags, env=env, cwd=cwd)
+ if rc != 0:
+ return cc_cmd, cc_stdout, cc_stderr, rc
+
+ link_cmd, link_stdout, link_stderr, rc = self.link(
+ object_file, out=out, flags=flags, env=env, cwd=cwd)
+ return (cc_cmd + ['&&'] + link_cmd, cc_stdout + link_stdout,
+ cc_stderr + link_stderr, rc)
+
+ def dumpMacros(self, source_files=None, flags=[], env=None, cwd=None):
+ if source_files is None:
+ source_files = os.devnull
+ flags = ['-dM'] + flags
+ cmd, out, err, rc = self.preprocess(source_files, flags=flags, env=env,
+ cwd=cwd)
+ if rc != 0:
+ return None
+ parsed_macros = {}
+ lines = [l.strip() for l in out.split('\n') if l.strip()]
+ for l in lines:
+ assert l.startswith('#define ')
+ l = l[len('#define '):]
+ macro, _, value = l.partition(' ')
+ parsed_macros[macro] = value
+ return parsed_macros
+
+ def getTriple(self):
+ cmd = [self.path] + self.flags + ['-dumpmachine']
+ return lit.util.capture(cmd).strip()
+
+ def hasCompileFlag(self, flag):
+ if isinstance(flag, list):
+ flags = list(flag)
+ else:
+ flags = [flag]
+ # Add -Werror to ensure that an unrecognized flag causes a non-zero
+ # exit code. -Werror is supported on all known compiler types.
+ if self.type is not None:
+ flags += ['-Werror']
+ cmd, out, err, rc = self.compile(os.devnull, out=os.devnull,
+ flags=flags)
+ return rc == 0
diff --git a/test/libcxx/containers/unord/unord.set/insert_dup_alloc.pass.cpp b/test/libcxx/containers/unord/unord.set/insert_dup_alloc.pass.cpp
new file mode 100644
index 000000000000..76ceafed2208
--- /dev/null
+++ b/test/libcxx/containers/unord/unord.set/insert_dup_alloc.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// Check that we don't allocate when trying to insert a duplicate value into a
+// unordered_set. See PR12999 http://llvm.org/bugs/show_bug.cgi?id=12999
+
+#include <cassert>
+#include <unordered_set>
+#include "count_new.hpp"
+#include "MoveOnly.h"
+
+int main()
+{
+ {
+ std::unordered_set<int> s;
+ assert(globalMemCounter.checkNewCalledEq(0));
+
+ for(int i=0; i < 100; ++i)
+ s.insert(3);
+
+ assert(s.size() == 1);
+ assert(s.count(3) == 1);
+ assert(globalMemCounter.checkNewCalledEq(2));
+ }
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ globalMemCounter.reset();
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::unordered_set<MoveOnly> s;
+ assert(globalMemCounter.checkNewCalledEq(0));
+
+ for(int i=0; i<100; i++)
+ s.insert(MoveOnly(3));
+
+ assert(s.size() == 1);
+ assert(s.count(MoveOnly(3)) == 1);
+ assert(globalMemCounter.checkNewCalledEq(2));
+ }
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ globalMemCounter.reset();
+#endif
+}
diff --git a/test/libcxx/double_include.sh.cpp b/test/libcxx/double_include.sh.cpp
new file mode 100644
index 000000000000..5620e5b35c2b
--- /dev/null
+++ b/test/libcxx/double_include.sh.cpp
@@ -0,0 +1,114 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// Test that we can include each header in two TU's and link them together.
+
+// RUN: %cxx -c %s -o %t.first.o %flags %compile_flags
+// RUN: %cxx -c %s -o %t.second.o -DWITH_MAIN %flags %compile_flags
+// RUN: %cxx -o %t.exe %t.first.o %t.second.o %flags %link_flags
+// RUN: %run
+
+#include <algorithm>
+#include <array>
+#include <bitset>
+#include <cassert>
+#include <ccomplex>
+#include <cctype>
+#include <cerrno>
+#include <cfenv>
+#include <cfloat>
+#include <chrono>
+#include <cinttypes>
+#include <ciso646>
+#include <climits>
+#include <clocale>
+#include <cmath>
+#include <codecvt>
+#include <complex>
+#include <complex.h>
+#include <condition_variable>
+#include <csetjmp>
+#include <csignal>
+#include <cstdarg>
+#include <cstdbool>
+#include <cstddef>
+#include <cstdint>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+#include <ctgmath>
+#include <ctime>
+#include <cwchar>
+#include <cwctype>
+#include <deque>
+#include <exception>
+#include <experimental/algorithm>
+#include <experimental/chrono>
+#include <experimental/dynarray>
+#include <experimental/optional>
+#include <experimental/string_view>
+#include <experimental/system_error>
+#include <experimental/type_traits>
+#include <experimental/utility>
+#include <ext/hash_map>
+#include <ext/hash_set>
+#include <forward_list>
+#include <fstream>
+#include <functional>
+#include <initializer_list>
+#include <iomanip>
+#include <ios>
+#include <iosfwd>
+#include <iostream>
+#include <istream>
+#include <iterator>
+#include <limits>
+#include <list>
+#include <locale>
+#include <map>
+#include <memory>
+#include <new>
+#include <numeric>
+#include <ostream>
+#include <queue>
+#include <random>
+#include <ratio>
+#include <regex>
+#include <scoped_allocator>
+#include <set>
+#include <sstream>
+#include <stack>
+#include <stdexcept>
+#include <streambuf>
+#include <string>
+#include <strstream>
+#include <system_error>
+#include <tgmath.h>
+#include <tuple>
+#include <typeindex>
+#include <typeinfo>
+#include <type_traits>
+#include <unordered_map>
+#include <unordered_set>
+#include <utility>
+#include <valarray>
+#include <vector>
+
+#ifndef _LIBCPP_HAS_NO_THREADS
+#include <atomic>
+#include <future>
+#include <mutex>
+#include <shared_mutex>
+#include <thread>
+#endif
+
+#if defined(WITH_MAIN)
+int main() {}
+#endif
diff --git a/test/libcxx/experimental/algorithms/header.algorithm.synop/includes.pass.cpp b/test/libcxx/experimental/algorithms/header.algorithm.synop/includes.pass.cpp
new file mode 100644
index 000000000000..accdd699c4f9
--- /dev/null
+++ b/test/libcxx/experimental/algorithms/header.algorithm.synop/includes.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <experimental/algorithm>
+
+#include <experimental/algorithm>
+
+#ifndef _LIBCPP_ALGORITHM
+# error "<experimental/algorithm> must include <algorithm>"
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/experimental/algorithms/version.pass.cpp b/test/libcxx/experimental/algorithms/version.pass.cpp
new file mode 100644
index 000000000000..6d9d0c6b2f38
--- /dev/null
+++ b/test/libcxx/experimental/algorithms/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <experimental/algorithm>
+
+#include <experimental/algorithm>
+
+#ifndef _LIBCPP_VERSION
+# error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/experimental/containers/sequences/dynarray/dynarray.cons/alloc.pass.cpp b/test/libcxx/experimental/containers/sequences/dynarray/dynarray.cons/alloc.pass.cpp
new file mode 100644
index 000000000000..d274bc030881
--- /dev/null
+++ b/test/libcxx/experimental/containers/sequences/dynarray/dynarray.cons/alloc.pass.cpp
@@ -0,0 +1,86 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// dynarray.cons
+
+// template <class Alloc>
+// dynarray(size_type c, const Alloc& alloc);
+// template <class Alloc>
+// dynarray(size_type c, const T& v, const Alloc& alloc);
+// template <class Alloc>
+// dynarray(const dynarray& d, const Alloc& alloc);
+// template <class Alloc>
+// dynarray(initializer_list<T>, const Alloc& alloc);
+
+// ~dynarray();
+
+
+#include <__config>
+
+#if _LIBCPP_STD_VER > 11
+
+#include <experimental/dynarray>
+#include <cassert>
+
+#include <algorithm>
+#include <complex>
+#include <string>
+#include "test_allocator.h"
+
+using std::experimental::dynarray;
+
+template <class T, class Allocator>
+void check_allocator ( const dynarray<T> &dyn, const Allocator &alloc ) {
+ for ( int i = 0; i < dyn.size (); ++i )
+ assert ( dyn[i].get_allocator() == alloc );
+}
+
+template <class T, class Allocator>
+void test ( const std::initializer_list<T> &vals, const Allocator &alloc ) {
+ typedef dynarray<T> dynA;
+
+ dynA d1 ( vals, alloc );
+ assert ( d1.size () == vals.size() );
+ assert ( std::equal ( vals.begin (), vals.end (), d1.begin (), d1.end ()));
+ check_allocator ( d1, alloc );
+ }
+
+
+template <class T, class Allocator>
+void test ( const T &val, const Allocator &alloc1, const Allocator &alloc2 ) {
+ typedef dynarray<T> dynA;
+
+ dynA d1 ( 4, alloc1 );
+ assert ( d1.size () == 4 );
+ assert ( std::all_of ( d1.begin (), d1.end (), []( const T &item ){ return item == T(); } ));
+ check_allocator ( d1, alloc1 );
+
+ dynA d2 ( 7, val, alloc1 );
+ assert ( d2.size () == 7 );
+ assert ( std::all_of ( d2.begin (), d2.end (), [&val]( const T &item ){ return item == val; } ));
+ check_allocator ( d2, alloc1 );
+
+ dynA d3 ( d2, alloc2 );
+ assert ( d3.size () == 7 );
+ assert ( std::all_of ( d3.begin (), d3.end (), [&val]( const T &item ){ return item == val; } ));
+ check_allocator ( d3, alloc2 );
+ }
+
+int main()
+{
+// This test is waiting on the resolution of LWG issue #2235
+// typedef test_allocator<char> Alloc;
+// typedef std::basic_string<char, std::char_traits<char>, Alloc> nstr;
+//
+// test ( nstr("fourteen"), Alloc(3), Alloc(4) );
+// test ( { nstr("1"), nstr("1"), nstr("2"), nstr("3"), nstr("5"), nstr("8")}, Alloc(6));
+}
+#else
+int main() {}
+#endif
diff --git a/test/libcxx/experimental/containers/sequences/dynarray/dynarray.cons/default.pass.cpp b/test/libcxx/experimental/containers/sequences/dynarray/dynarray.cons/default.pass.cpp
new file mode 100644
index 000000000000..0effac2fc142
--- /dev/null
+++ b/test/libcxx/experimental/containers/sequences/dynarray/dynarray.cons/default.pass.cpp
@@ -0,0 +1,95 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// dynarray.cons
+
+// explicit dynarray(size_type c);
+// dynarray(size_type c, const T& v);
+// dynarray(initializer_list<T>);
+// dynarray(const dynarray& d);
+
+// ~dynarray();
+
+
+#include <__config>
+
+#if _LIBCPP_STD_VER > 11
+
+#include <experimental/dynarray>
+#include <cassert>
+
+#include <algorithm>
+#include <complex>
+#include <string>
+
+using std::experimental::dynarray;
+
+template <class T>
+void test ( const std::initializer_list<T> &vals ) {
+ typedef dynarray<T> dynA;
+
+ dynA d1 ( vals );
+ assert ( d1.size () == vals.size() );
+ assert ( std::equal ( vals.begin (), vals.end (), d1.begin (), d1.end ()));
+ }
+
+
+template <class T>
+void test ( const T &val ) {
+ typedef dynarray<T> dynA;
+
+ dynA d1 ( 4 );
+ assert ( d1.size () == 4 );
+ assert ( std::all_of ( d1.begin (), d1.end (), []( const T &item ){ return item == T(); } ));
+
+ dynA d2 ( 7, val );
+ assert ( d2.size () == 7 );
+ assert ( std::all_of ( d2.begin (), d2.end (), [&val]( const T &item ){ return item == val; } ));
+
+ dynA d3 ( d2 );
+ assert ( d3.size () == 7 );
+ assert ( std::all_of ( d3.begin (), d3.end (), [&val]( const T &item ){ return item == val; } ));
+ }
+
+void test_bad_length () {
+ try { dynarray<int> ( std::numeric_limits<size_t>::max() / sizeof ( int ) + 1 ); }
+ catch ( std::bad_array_length & ) { return ; }
+ assert ( false );
+ }
+
+void test_bad_alloc () {
+ try { dynarray<int> ( std::numeric_limits<size_t>::max() / sizeof ( int ) - 1 ); }
+ catch ( std::bad_alloc & ) { return ; }
+ assert ( false );
+ }
+
+int main()
+{
+// test<int> ( 14 ); // ints don't get default initialized
+ test<long> ( 0 );
+ test<double> ( 14.0 );
+ test<std::complex<double>> ( std::complex<double> ( 14, 0 ));
+ test<std::string> ( "fourteen" );
+
+ test ( { 1, 1, 2, 3, 5, 8 } );
+ test ( { 1., 1., 2., 3., 5., 8. } );
+ test ( { std::string("1"), std::string("1"), std::string("2"), std::string("3"),
+ std::string("5"), std::string("8")} );
+
+// Make sure we don't pick up the Allocator version here
+ dynarray<long> d1 ( 20, 3 );
+ assert ( d1.size() == 20 );
+ assert ( std::all_of ( d1.begin (), d1.end (), []( long item ){ return item == 3L; } ));
+
+ test_bad_length ();
+ test_bad_alloc ();
+}
+#else
+int main() {}
+#endif
diff --git a/test/libcxx/experimental/containers/sequences/dynarray/dynarray.data/default.pass.cpp b/test/libcxx/experimental/containers/sequences/dynarray/dynarray.data/default.pass.cpp
new file mode 100644
index 000000000000..b669f25948ed
--- /dev/null
+++ b/test/libcxx/experimental/containers/sequences/dynarray/dynarray.data/default.pass.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// dynarray.data
+
+// T* data() noexcept;
+// const T* data() const noexcept;
+
+
+#include <__config>
+
+#if _LIBCPP_STD_VER > 11
+
+#include <experimental/dynarray>
+#include <cassert>
+
+#include <algorithm>
+#include <complex>
+#include <string>
+
+using std::experimental::dynarray;
+
+template <class T>
+void dyn_test_const ( const dynarray<T> &dyn ) {
+ const T *data = dyn.data ();
+ assert ( data != NULL );
+ assert ( std::equal ( dyn.begin(), dyn.end(), data ));
+ }
+
+template <class T>
+void dyn_test ( dynarray<T> &dyn ) {
+ T *data = dyn.data ();
+ assert ( data != NULL );
+ assert ( std::equal ( dyn.begin(), dyn.end(), data ));
+ }
+
+
+
+template <class T>
+void test ( const T &val ) {
+ typedef dynarray<T> dynA;
+
+ dynA d1 ( 4 );
+ dyn_test ( d1 );
+ dyn_test_const ( d1 );
+
+ dynA d2 ( 7, val );
+ dyn_test ( d2 );
+ dyn_test_const ( d2 );
+ }
+
+int main()
+{
+ test<int> ( 14 );
+ test<double> ( 14.0 );
+ test<std::complex<double>> ( std::complex<double> ( 14, 0 ));
+ test<std::string> ( "fourteen" );
+}
+#else
+int main() {}
+#endif
diff --git a/test/libcxx/experimental/containers/sequences/dynarray/dynarray.mutate/default.pass.cpp b/test/libcxx/experimental/containers/sequences/dynarray/dynarray.mutate/default.pass.cpp
new file mode 100644
index 000000000000..c57887ddaf94
--- /dev/null
+++ b/test/libcxx/experimental/containers/sequences/dynarray/dynarray.mutate/default.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// dynarray.data
+
+// void fill(const T& v);
+// const T* data() const noexcept;
+
+
+#include <__config>
+
+#if _LIBCPP_STD_VER > 11
+
+#include <experimental/dynarray>
+#include <cassert>
+
+#include <algorithm>
+#include <complex>
+#include <string>
+
+using std::experimental::dynarray;
+
+template <class T>
+void test ( const T &val ) {
+ typedef dynarray<T> dynA;
+
+ dynA d1 ( 4 );
+ d1.fill ( val );
+ assert ( std::all_of ( d1.begin (), d1.end (),
+ [&val]( const T &item ){ return item == val; } ));
+ }
+
+int main()
+{
+ test<int> ( 14 );
+ test<double> ( 14.0 );
+ test<std::complex<double>> ( std::complex<double> ( 14, 0 ));
+ test<std::string> ( "fourteen" );
+}
+#else
+int main() {}
+#endif
diff --git a/test/libcxx/experimental/containers/sequences/dynarray/dynarray.overview/at.pass.cpp b/test/libcxx/experimental/containers/sequences/dynarray/dynarray.overview/at.pass.cpp
new file mode 100644
index 000000000000..4d77cf732758
--- /dev/null
+++ b/test/libcxx/experimental/containers/sequences/dynarray/dynarray.overview/at.pass.cpp
@@ -0,0 +1,94 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// dynarray.overview
+
+// const_reference at(size_type n) const;
+// reference at(size_type n);
+
+#include <__config>
+
+#if _LIBCPP_STD_VER > 11
+
+#include <experimental/dynarray>
+#include <cassert>
+
+#include <algorithm>
+#include <complex>
+#include <string>
+
+using std::experimental::dynarray;
+
+template <class T>
+void dyn_at_fail ( dynarray<T> &dyn, size_t sz ) {
+ try { dyn.at (sz); }
+ catch (const std::out_of_range &) { return; }
+ assert ( false );
+ }
+
+template <class T>
+void dyn_at_fail_const ( const dynarray<T> &dyn, size_t sz ) {
+ try { dyn.at (sz); }
+ catch (const std::out_of_range &) { return; }
+ assert ( false );
+ }
+
+
+template <class T>
+void dyn_test_const ( const dynarray<T> &dyn, const std::initializer_list<T> &vals ) {
+ const T *data = dyn.data ();
+ auto it = vals.begin ();
+ for ( size_t i = 0; i < dyn.size(); ++i, ++it ) {
+ assert ( data + i == &dyn.at(i));
+ assert ( *it == dyn.at(i));
+ }
+
+ dyn_at_fail_const ( dyn, dyn.size ());
+ dyn_at_fail_const ( dyn, 2*dyn.size ());
+ dyn_at_fail_const ( dyn, size_t (-1));
+ }
+
+template <class T>
+void dyn_test ( dynarray<T> &dyn, const std::initializer_list<T> &vals ) {
+ T *data = dyn.data ();
+ auto it = vals.begin ();
+ for ( size_t i = 0; i < dyn.size(); ++i, ++it ) {
+ assert ( data + i == &dyn.at(i));
+ assert ( *it == dyn.at(i));
+ }
+
+ dyn_at_fail ( dyn, dyn.size ());
+ dyn_at_fail ( dyn, 2*dyn.size ());
+ dyn_at_fail ( dyn, size_t (-1));
+ }
+
+
+template <class T>
+void test ( std::initializer_list<T> vals ) {
+ typedef dynarray<T> dynA;
+
+ dynA d1 ( vals );
+ dyn_test ( d1, vals );
+ dyn_test_const ( d1, vals );
+ }
+
+int main()
+{
+ test ( { 1, 1, 2, 3, 5, 8 } );
+ test ( { 1., 1., 2., 3., 5., 8. } );
+ test ( { std::string("1"), std::string("1"), std::string("2"), std::string("3"),
+ std::string("5"), std::string("8")} );
+
+ test<int> ( {} );
+ test<std::complex<double>> ( {} );
+ test<std::string> ( {} );
+}
+#else
+int main() {}
+#endif
diff --git a/test/libcxx/experimental/containers/sequences/dynarray/dynarray.overview/begin_end.pass.cpp b/test/libcxx/experimental/containers/sequences/dynarray/dynarray.overview/begin_end.pass.cpp
new file mode 100644
index 000000000000..695e1aa9f14a
--- /dev/null
+++ b/test/libcxx/experimental/containers/sequences/dynarray/dynarray.overview/begin_end.pass.cpp
@@ -0,0 +1,108 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// dynarray.overview
+
+
+// iterator begin() noexcept;
+// const_iterator begin() const noexcept;
+// const_iterator cbegin() const noexcept;
+// iterator end() noexcept;
+// const_iterator end() const noexcept;
+// const_iterator cend() const noexcept;
+//
+// reverse_iterator rbegin() noexcept;
+// const_reverse_iterator rbegin() const noexcept;
+// const_reverse_iterator crbegin() const noexcept;
+// reverse_iterator rend() noexcept;
+// const_reverse_iterator rend() const noexcept;
+// const_reverse_iterator crend() const noexcept;
+
+
+#include <__config>
+
+#if _LIBCPP_STD_VER > 11
+
+#include <experimental/dynarray>
+#include <cassert>
+
+#include <algorithm>
+#include <complex>
+#include <string>
+
+using std::experimental::dynarray;
+
+template <class T>
+void dyn_test_const ( const dynarray<T> &dyn ) {
+ const T *data = dyn.data ();
+ assert ( data == &*dyn.begin ());
+ assert ( data == &*dyn.cbegin ());
+
+ assert ( data + dyn.size() - 1 == &*dyn.rbegin ());
+ assert ( data + dyn.size() - 1 == &*dyn.crbegin ());
+
+ assert ( dyn.size () == std::distance ( dyn.begin(), dyn.end()));
+ assert ( dyn.size () == std::distance ( dyn.cbegin(), dyn.cend()));
+ assert ( dyn.size () == std::distance ( dyn.rbegin(), dyn.rend()));
+ assert ( dyn.size () == std::distance ( dyn.crbegin(), dyn.crend()));
+
+ assert ( dyn.begin () == dyn.cbegin ());
+ assert ( &*dyn.begin () == &*dyn.cbegin ());
+ assert ( dyn.rbegin () == dyn.crbegin ());
+ assert ( &*dyn.rbegin () == &*dyn.crbegin ());
+ assert ( dyn.end () == dyn.cend ());
+ assert ( dyn.rend () == dyn.crend ());
+ }
+
+template <class T>
+void dyn_test ( dynarray<T> &dyn ) {
+ T *data = dyn.data ();
+ assert ( data == &*dyn.begin ());
+ assert ( data == &*dyn.cbegin ());
+
+ assert ( data + dyn.size() - 1 == &*dyn.rbegin ());
+ assert ( data + dyn.size() - 1 == &*dyn.crbegin ());
+
+ assert ( dyn.size () == std::distance ( dyn.begin(), dyn.end()));
+ assert ( dyn.size () == std::distance ( dyn.cbegin(), dyn.cend()));
+ assert ( dyn.size () == std::distance ( dyn.rbegin(), dyn.rend()));
+ assert ( dyn.size () == std::distance ( dyn.crbegin(), dyn.crend()));
+
+ assert ( dyn.begin () == dyn.cbegin ());
+ assert ( &*dyn.begin () == &*dyn.cbegin ());
+ assert ( dyn.rbegin () == dyn.crbegin ());
+ assert ( &*dyn.rbegin () == &*dyn.crbegin ());
+ assert ( dyn.end () == dyn.cend ());
+ assert ( dyn.rend () == dyn.crend ());
+ }
+
+
+template <class T>
+void test ( const T &val ) {
+ typedef dynarray<T> dynA;
+
+ dynA d1 ( 4 );
+ dyn_test ( d1 );
+ dyn_test_const ( d1 );
+
+ dynA d2 ( 7, val );
+ dyn_test ( d2 );
+ dyn_test_const ( d2 );
+ }
+
+int main()
+{
+ test<int> ( 14 );
+ test<double> ( 14.0 );
+ test<std::complex<double>> ( std::complex<double> ( 14, 0 ));
+ test<std::string> ( "fourteen" );
+}
+#else
+int main() {}
+#endif
diff --git a/test/libcxx/experimental/containers/sequences/dynarray/dynarray.overview/capacity.pass.cpp b/test/libcxx/experimental/containers/sequences/dynarray/dynarray.overview/capacity.pass.cpp
new file mode 100644
index 000000000000..6d28eef1b057
--- /dev/null
+++ b/test/libcxx/experimental/containers/sequences/dynarray/dynarray.overview/capacity.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// dynarray.overview
+
+// size_type size() const noexcept;
+// size_type max_size() const noexcept;
+// bool empty() const noexcept;
+
+#include <__config>
+
+#if _LIBCPP_STD_VER > 11
+
+#include <experimental/dynarray>
+#include <cassert>
+
+#include <algorithm>
+#include <complex>
+#include <string>
+
+using std::experimental::dynarray;
+
+template <class T>
+void dyn_test ( const dynarray<T> &dyn, size_t sz ) {
+ assert ( dyn.size () == sz );
+ assert ( dyn.max_size () == sz );
+ assert ( dyn.empty () == ( sz == 0 ));
+ }
+
+template <class T>
+void test ( std::initializer_list<T> vals ) {
+ typedef dynarray<T> dynA;
+
+ dynA d1 ( vals );
+ dyn_test ( d1, vals.size ());
+ }
+
+int main()
+{
+ test ( { 1, 1, 2, 3, 5, 8 } );
+ test ( { 1., 1., 2., 3., 5., 8. } );
+ test ( { std::string("1"), std::string("1"), std::string("2"), std::string("3"),
+ std::string("5"), std::string("8")} );
+
+ test<int> ( {} );
+ test<std::complex<double>> ( {} );
+ test<std::string> ( {} );
+}
+#else
+int main() {}
+#endif
diff --git a/test/libcxx/experimental/containers/sequences/dynarray/dynarray.overview/front_back.pass.cpp b/test/libcxx/experimental/containers/sequences/dynarray/dynarray.overview/front_back.pass.cpp
new file mode 100644
index 000000000000..e82aa64b98b6
--- /dev/null
+++ b/test/libcxx/experimental/containers/sequences/dynarray/dynarray.overview/front_back.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// dynarray.overview
+
+// reference front();
+// const_reference front() const;
+// reference back();
+// const_reference back() const;
+
+
+#include <__config>
+
+#if _LIBCPP_STD_VER > 11
+
+#include <experimental/dynarray>
+#include <cassert>
+
+#include <algorithm>
+#include <complex>
+#include <string>
+
+using std::experimental::dynarray;
+
+template <class T>
+void dyn_test_const ( const dynarray<T> &dyn ) {
+ const T *data = dyn.data ();
+ assert ( *data == dyn.front ());
+ assert ( *(data + dyn.size() - 1 ) == dyn.back ());
+ }
+
+template <class T>
+void dyn_test ( dynarray<T> &dyn ) {
+ T *data = dyn.data ();
+ assert ( *data == dyn.front ());
+ assert ( *(data + dyn.size() - 1 ) == dyn.back ());
+ }
+
+
+template <class T>
+void test ( const T &val ) {
+ typedef dynarray<T> dynA;
+
+ dynA d1 ( 4 );
+ dyn_test ( d1 );
+ dyn_test_const ( d1 );
+
+ dynA d2 ( 7, val );
+ dyn_test ( d2 );
+ dyn_test_const ( d2 );
+ }
+
+int main()
+{
+ test<int> ( 14 );
+ test<double> ( 14.0 );
+ test<std::complex<double>> ( std::complex<double> ( 14, 0 ));
+ test<std::string> ( "fourteen" );
+}
+#else
+int main() {}
+#endif
diff --git a/test/libcxx/experimental/containers/sequences/dynarray/dynarray.overview/indexing.pass.cpp b/test/libcxx/experimental/containers/sequences/dynarray/dynarray.overview/indexing.pass.cpp
new file mode 100644
index 000000000000..7317a2023cb1
--- /dev/null
+++ b/test/libcxx/experimental/containers/sequences/dynarray/dynarray.overview/indexing.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// dynarray.overview
+
+// const_reference at(size_type n) const;
+// reference at(size_type n);
+
+#include <__config>
+
+#if _LIBCPP_STD_VER > 11
+
+#include <experimental/dynarray>
+#include <cassert>
+
+#include <algorithm>
+#include <complex>
+#include <string>
+
+using std::experimental::dynarray;
+
+template <class T>
+void dyn_test_const ( const dynarray<T> &dyn, const std::initializer_list<T> &vals ) {
+ const T *data = dyn.data ();
+ auto it = vals.begin ();
+ for ( size_t i = 0; i < dyn.size(); ++i, ++it ) {
+ assert ( data + i == &dyn[i]);
+ assert ( *it == dyn[i]);
+ }
+ }
+
+template <class T>
+void dyn_test ( dynarray<T> &dyn, const std::initializer_list<T> &vals ) {
+ T *data = dyn.data ();
+ auto it = vals.begin ();
+ for ( size_t i = 0; i < dyn.size(); ++i, ++it ) {
+ assert ( data + i == &dyn[i]);
+ assert ( *it == dyn[i]);
+ }
+ }
+
+
+template <class T>
+void test ( std::initializer_list<T> vals ) {
+ typedef dynarray<T> dynA;
+
+ dynA d1 ( vals );
+ dyn_test ( d1, vals );
+ dyn_test_const ( d1, vals );
+ }
+
+int main()
+{
+ test ( { 1, 1, 2, 3, 5, 8 } );
+ test ( { 1., 1., 2., 3., 5., 8. } );
+ test ( { std::string("1"), std::string("1"), std::string("2"), std::string("3"),
+ std::string("5"), std::string("8")} );
+
+ test<int> ( {} );
+ test<std::complex<double>> ( {} );
+ test<std::string> ( {} );
+}
+#else
+int main() {}
+#endif
diff --git a/test/libcxx/experimental/containers/sequences/dynarray/dynarray.traits/default.pass.cpp b/test/libcxx/experimental/containers/sequences/dynarray/dynarray.traits/default.pass.cpp
new file mode 100644
index 000000000000..9b8240d4cd82
--- /dev/null
+++ b/test/libcxx/experimental/containers/sequences/dynarray/dynarray.traits/default.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// dynarray.data
+
+// template <class Type, class Alloc>
+// struct uses_allocator<dynarray<Type>, Alloc> : true_type { };
+
+
+#include <__config>
+
+#if _LIBCPP_STD_VER > 11
+
+#include <experimental/dynarray>
+#include "test_allocator.h"
+
+using std::experimental::dynarray;
+
+int main()
+{
+ static_assert ( std::uses_allocator<dynarray<int>, test_allocator<int>>::value, "" );
+}
+#else
+int main() {}
+#endif
diff --git a/test/libcxx/experimental/containers/sequences/dynarray/dynarray.zero/default.pass.cpp b/test/libcxx/experimental/containers/sequences/dynarray/dynarray.zero/default.pass.cpp
new file mode 100644
index 000000000000..93f3b18f192f
--- /dev/null
+++ b/test/libcxx/experimental/containers/sequences/dynarray/dynarray.zero/default.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// dynarray.zero
+
+// dynarray shall provide support for the special case of construction with a size of zero.
+// In the case that the size is zero, begin() == end() == unique value.
+// The return value of data() is unspecified.
+// The effect of calling front() or back() for a zero-sized dynarray is undefined.
+
+
+
+#include <__config>
+
+#if _LIBCPP_STD_VER > 11
+
+#include <experimental/dynarray>
+#include <cassert>
+
+#include <algorithm>
+#include <complex>
+#include <string>
+
+using std::experimental::dynarray;
+
+template <class T>
+void test ( ) {
+ typedef dynarray<T> dynA;
+
+ dynA d1 ( 0 );
+ assert ( d1.size() == 0 );
+ assert ( d1.begin() == d1.end ());
+ }
+
+int main()
+{
+ test<int> ();
+ test<double> ();
+ test<std::complex<double>> ();
+ test<std::string> ();
+}
+#else
+int main() {}
+#endif
diff --git a/test/libcxx/experimental/containers/sequences/dynarray/nothing_to_do.pass.cpp b/test/libcxx/experimental/containers/sequences/dynarray/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/libcxx/experimental/containers/sequences/dynarray/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/libcxx/experimental/utilities/ratio/header.ratio.synop/includes.pass.cpp b/test/libcxx/experimental/utilities/ratio/header.ratio.synop/includes.pass.cpp
new file mode 100644
index 000000000000..db9026aebd84
--- /dev/null
+++ b/test/libcxx/experimental/utilities/ratio/header.ratio.synop/includes.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <experimental/ratio>
+
+// Test that <ratio> is included.
+
+#include <experimental/ratio>
+
+#if _LIBCPP_STD_VER > 11
+# ifndef _LIBCPP_RATIO
+# error " <experimental/ratio> must include <ratio>"
+# endif
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/experimental/utilities/ratio/version.pass.cpp b/test/libcxx/experimental/utilities/ratio/version.pass.cpp
new file mode 100644
index 000000000000..8bc583fb6d94
--- /dev/null
+++ b/test/libcxx/experimental/utilities/ratio/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <experimental/ratio>
+
+#include <experimental/ratio>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/experimental/utilities/syserror/header.system_error.synop/includes.pass.cpp b/test/libcxx/experimental/utilities/syserror/header.system_error.synop/includes.pass.cpp
new file mode 100644
index 000000000000..88c7458395d4
--- /dev/null
+++ b/test/libcxx/experimental/utilities/syserror/header.system_error.synop/includes.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <experimental/system_error>
+
+#include <experimental/system_error>
+
+#if _LIBCPP_STD_VER > 11
+# ifndef _LIBCPP_SYSTEM_ERROR
+# error "<experimental/system_error> must include <system_error>"
+# endif
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/experimental/utilities/syserror/version.pass.cpp b/test/libcxx/experimental/utilities/syserror/version.pass.cpp
new file mode 100644
index 000000000000..35f6a59c3876
--- /dev/null
+++ b/test/libcxx/experimental/utilities/syserror/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <experimental/system_error>
+
+#include <experimental/system_error>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/experimental/utilities/time/header.chrono.synop/includes.pass.cpp b/test/libcxx/experimental/utilities/time/header.chrono.synop/includes.pass.cpp
new file mode 100644
index 000000000000..ad4a79105b0b
--- /dev/null
+++ b/test/libcxx/experimental/utilities/time/header.chrono.synop/includes.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <experimental/chrono>
+
+#include <experimental/chrono>
+
+#if _LIBCPP_STD_VER > 11
+# ifndef _LIBCPP_CHRONO
+# error "<experimental/chrono> must include <chrono>"
+# endif
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/experimental/utilities/time/version.pass.cpp b/test/libcxx/experimental/utilities/time/version.pass.cpp
new file mode 100644
index 000000000000..be97466f37c0
--- /dev/null
+++ b/test/libcxx/experimental/utilities/time/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <experimental/chrono>
+
+#include <experimental/chrono>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/experimental/utilities/tuple/header.tuple.synop/includes.pass.cpp b/test/libcxx/experimental/utilities/tuple/header.tuple.synop/includes.pass.cpp
new file mode 100644
index 000000000000..544ddfb269f2
--- /dev/null
+++ b/test/libcxx/experimental/utilities/tuple/header.tuple.synop/includes.pass.cpp
@@ -0,0 +1,21 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <experimental/tuple>
+
+#include <experimental/tuple>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+# ifndef _LIBCPP_TUPLE
+# error "<experimental/tuple> must include <tuple>"
+# endif
+#endif /* _LIBCPP_STD_VER > 11 */
+}
diff --git a/test/libcxx/experimental/utilities/tuple/version.pass.cpp b/test/libcxx/experimental/utilities/tuple/version.pass.cpp
new file mode 100644
index 000000000000..5a3fd2e39647
--- /dev/null
+++ b/test/libcxx/experimental/utilities/tuple/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <experimental/tuple>
+
+#include <experimental/tuple>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/selftest/not_test.sh.cpp b/test/libcxx/selftest/not_test.sh.cpp
new file mode 100644
index 000000000000..5b8348f0eecd
--- /dev/null
+++ b/test/libcxx/selftest/not_test.sh.cpp
@@ -0,0 +1,17 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// RUN: %build
+// RUN: not %run
+
+int main()
+{
+ return 1;
+}
diff --git a/test/libcxx/selftest/test.fail.cpp b/test/libcxx/selftest/test.fail.cpp
new file mode 100644
index 000000000000..2ad608bab260
--- /dev/null
+++ b/test/libcxx/selftest/test.fail.cpp
@@ -0,0 +1,11 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#error This test should not compile.
diff --git a/test/libcxx/selftest/test.pass.cpp b/test/libcxx/selftest/test.pass.cpp
new file mode 100644
index 000000000000..9a59227abdd9
--- /dev/null
+++ b/test/libcxx/selftest/test.pass.cpp
@@ -0,0 +1,13 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/libcxx/selftest/test.sh.cpp b/test/libcxx/selftest/test.sh.cpp
new file mode 100644
index 000000000000..14dc2db8018b
--- /dev/null
+++ b/test/libcxx/selftest/test.sh.cpp
@@ -0,0 +1,16 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// RUN: %build
+// RUN: %run
+
+int main()
+{
+}
diff --git a/test/libcxx/selftest/test_macros.pass.cpp b/test/libcxx/selftest/test_macros.pass.cpp
new file mode 100644
index 000000000000..2c8ed4f454a7
--- /dev/null
+++ b/test/libcxx/selftest/test_macros.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// Test the "test_macros.h" header.
+#include "test_macros.h"
+
+#ifndef TEST_STD_VER
+#error TEST_STD_VER must be defined
+#endif
+
+#ifndef TEST_DECLTYPE
+#error TEST_DECLTYPE must be defined
+#endif
+
+#ifndef TEST_NOEXCEPT
+#error TEST_NOEXCEPT must be defined
+#endif
+
+#ifndef TEST_STATIC_ASSERT
+#error TEST_STATIC_ASSERT must be defined
+#endif
+
+template <class T, class U>
+struct is_same { enum { value = 0 }; };
+
+template <class T>
+struct is_same<T, T> { enum { value = 1 }; };
+
+int foo() { return 0; }
+
+void test_noexcept() TEST_NOEXCEPT
+{
+}
+
+void test_decltype()
+{
+ typedef TEST_DECLTYPE(foo()) MyType;
+ TEST_STATIC_ASSERT((is_same<MyType, int>::value), "is same");
+}
+
+void test_static_assert()
+{
+ TEST_STATIC_ASSERT((is_same<int, int>::value), "is same");
+ TEST_STATIC_ASSERT((!is_same<int, long>::value), "not same");
+}
+
+int main()
+{
+ test_noexcept();
+ test_decltype();
+ test_static_assert();
+}
diff --git a/test/libcxx/test/__init__.py b/test/libcxx/test/__init__.py
new file mode 100644
index 000000000000..e69de29bb2d1
--- /dev/null
+++ b/test/libcxx/test/__init__.py
diff --git a/test/libcxx/test/config.py b/test/libcxx/test/config.py
new file mode 100644
index 000000000000..09fbf66dbba0
--- /dev/null
+++ b/test/libcxx/test/config.py
@@ -0,0 +1,709 @@
+import importlib
+import locale
+import os
+import platform
+import pkgutil
+import re
+import shlex
+import sys
+
+import lit.Test # pylint: disable=import-error,no-name-in-module
+import lit.util # pylint: disable=import-error,no-name-in-module
+
+from libcxx.test.format import LibcxxTestFormat
+from libcxx.compiler import CXXCompiler
+from libcxx.test.executor import *
+from libcxx.test.tracing import *
+
+def loadSiteConfig(lit_config, config, param_name, env_name):
+ # We haven't loaded the site specific configuration (the user is
+ # probably trying to run on a test file directly, and either the site
+ # configuration hasn't been created by the build system, or we are in an
+ # out-of-tree build situation).
+ site_cfg = lit_config.params.get(param_name,
+ os.environ.get(env_name))
+ if not site_cfg:
+ lit_config.warning('No site specific configuration file found!'
+ ' Running the tests in the default configuration.')
+ elif not os.path.isfile(site_cfg):
+ lit_config.fatal(
+ "Specified site configuration file does not exist: '%s'" %
+ site_cfg)
+ else:
+ lit_config.note('using site specific configuration at %s' % site_cfg)
+ ld_fn = lit_config.load_config
+
+ # Null out the load_config function so that lit.site.cfg doesn't
+ # recursively load a config even if it tries.
+ # TODO: This is one hell of a hack. Fix it.
+ def prevent_reload_fn(*args, **kwargs):
+ pass
+ lit_config.load_config = prevent_reload_fn
+ ld_fn(config, site_cfg)
+ lit_config.load_config = ld_fn
+
+
+class Configuration(object):
+ # pylint: disable=redefined-outer-name
+ def __init__(self, lit_config, config):
+ self.lit_config = lit_config
+ self.config = config
+ self.cxx = None
+ self.libcxx_src_root = None
+ self.libcxx_obj_root = None
+ self.cxx_library_root = None
+ self.abi_library_root = None
+ self.env = {}
+ self.use_target = False
+ self.use_system_cxx_lib = False
+ self.use_clang_verify = False
+ self.long_tests = None
+ self.execute_external = False
+
+ def get_lit_conf(self, name, default=None):
+ val = self.lit_config.params.get(name, None)
+ if val is None:
+ val = getattr(self.config, name, None)
+ if val is None:
+ val = default
+ return val
+
+ def get_lit_bool(self, name, default=None):
+ conf = self.get_lit_conf(name)
+ if conf is None:
+ return default
+ if conf.lower() in ('1', 'true'):
+ return True
+ if conf.lower() in ('', '0', 'false'):
+ return False
+ self.lit_config.fatal(
+ "parameter '{}' should be true or false".format(name))
+
+ def configure(self):
+ self.configure_executor()
+ self.configure_target_info()
+ self.configure_cxx()
+ self.configure_triple()
+ self.configure_src_root()
+ self.configure_obj_root()
+ self.configure_cxx_library_root()
+ self.configure_use_system_cxx_lib()
+ self.configure_use_clang_verify()
+ self.configure_execute_external()
+ self.configure_ccache()
+ self.configure_compile_flags()
+ self.configure_link_flags()
+ self.configure_env()
+ self.configure_color_diagnostics()
+ self.configure_debug_mode()
+ self.configure_warnings()
+ self.configure_sanitizer()
+ self.configure_coverage()
+ self.configure_substitutions()
+ self.configure_features()
+
+ def print_config_info(self):
+ # Print the final compile and link flags.
+ self.lit_config.note('Using compiler: %s' % self.cxx.path)
+ self.lit_config.note('Using flags: %s' % self.cxx.flags)
+ self.lit_config.note('Using compile flags: %s'
+ % self.cxx.compile_flags)
+ self.lit_config.note('Using link flags: %s' % self.cxx.link_flags)
+ # Print as list to prevent "set([...])" from being printed.
+ self.lit_config.note('Using available_features: %s' %
+ list(self.config.available_features))
+ self.lit_config.note('Using environment: %r' % self.env)
+
+ def get_test_format(self):
+ return LibcxxTestFormat(
+ self.cxx,
+ self.use_clang_verify,
+ self.execute_external,
+ self.executor,
+ exec_env=self.env)
+
+ def configure_executor(self):
+ exec_str = self.get_lit_conf('executor', "None")
+ te = eval(exec_str)
+ if te:
+ self.lit_config.note("Using executor: %r" % exec_str)
+ if self.lit_config.useValgrind:
+ # We have no way of knowing where in the chain the
+ # ValgrindExecutor is supposed to go. It is likely
+ # that the user wants it at the end, but we have no
+ # way of getting at that easily.
+ selt.lit_config.fatal("Cannot infer how to create a Valgrind "
+ " executor.")
+ else:
+ te = LocalExecutor()
+ if self.lit_config.useValgrind:
+ te = ValgrindExecutor(self.lit_config.valgrindArgs, te)
+ self.executor = te
+
+ def configure_target_info(self):
+ default = "libcxx.test.target_info.LocalTI"
+ info_str = self.get_lit_conf('target_info', default)
+ mod_path, _, info = info_str.rpartition('.')
+ mod = importlib.import_module(mod_path)
+ self.target_info = getattr(mod, info)()
+ if info_str != default:
+ self.lit_config.note("inferred target_info as: %r" % info_str)
+
+ def configure_cxx(self):
+ # Gather various compiler parameters.
+ cxx = self.get_lit_conf('cxx_under_test')
+
+ # If no specific cxx_under_test was given, attempt to infer it as
+ # clang++.
+ if cxx is None:
+ clangxx = lit.util.which('clang++',
+ self.config.environment['PATH'])
+ if clangxx:
+ cxx = clangxx
+ self.lit_config.note(
+ "inferred cxx_under_test as: %r" % cxx)
+ if not cxx:
+ self.lit_config.fatal('must specify user parameter cxx_under_test '
+ '(e.g., --param=cxx_under_test=clang++)')
+ self.cxx = CXXCompiler(cxx)
+ cxx_type = self.cxx.type
+ if cxx_type is not None:
+ assert self.cxx.version is not None
+ maj_v, min_v, _ = self.cxx.version
+ self.config.available_features.add(cxx_type)
+ self.config.available_features.add('%s-%s.%s' % (
+ cxx_type, maj_v, min_v))
+
+ def configure_src_root(self):
+ self.libcxx_src_root = self.get_lit_conf(
+ 'libcxx_src_root', os.path.dirname(self.config.test_source_root))
+
+ def configure_obj_root(self):
+ self.libcxx_obj_root = self.get_lit_conf('libcxx_obj_root')
+
+ def configure_cxx_library_root(self):
+ self.cxx_library_root = self.get_lit_conf('cxx_library_root',
+ self.libcxx_obj_root)
+
+ def configure_use_system_cxx_lib(self):
+ # This test suite supports testing against either the system library or
+ # the locally built one; the former mode is useful for testing ABI
+ # compatibility between the current headers and a shipping dynamic
+ # library.
+ self.use_system_cxx_lib = self.get_lit_bool('use_system_cxx_lib')
+ if self.use_system_cxx_lib is None:
+ # Default to testing against the locally built libc++ library.
+ self.use_system_cxx_lib = False
+ self.lit_config.note(
+ "inferred use_system_cxx_lib as: %r" % self.use_system_cxx_lib)
+
+ def configure_use_clang_verify(self):
+ '''If set, run clang with -verify on failing tests.'''
+ self.use_clang_verify = self.get_lit_bool('use_clang_verify')
+ if self.use_clang_verify is None:
+ # NOTE: We do not test for the -verify flag directly because
+ # -verify will always exit with non-zero on an empty file.
+ self.use_clang_verify = self.cxx.hasCompileFlag(
+ ['-Xclang', '-verify-ignore-unexpected'])
+ self.lit_config.note(
+ "inferred use_clang_verify as: %r" % self.use_clang_verify)
+
+ def configure_execute_external(self):
+ # Choose between lit's internal shell pipeline runner and a real shell.
+ # If LIT_USE_INTERNAL_SHELL is in the environment, we use that as the
+ # default value. Otherwise we default to internal on Windows and
+ # external elsewhere, as bash on Windows is usually very slow.
+ use_lit_shell_default = os.environ.get('LIT_USE_INTERNAL_SHELL')
+ if use_lit_shell_default is not None:
+ use_lit_shell_default = use_lit_shell_default != '0'
+ else:
+ use_lit_shell_default = sys.platform == 'win32'
+ # Check for the command line parameter using the default value if it is
+ # not present.
+ use_lit_shell = self.get_lit_bool('use_lit_shell',
+ use_lit_shell_default)
+ self.execute_external = not use_lit_shell
+
+ def configure_ccache(self):
+ use_ccache_default = os.environ.get('LIBCXX_USE_CCACHE') is not None
+ use_ccache = self.get_lit_bool('use_ccache', use_ccache_default)
+ if use_ccache:
+ self.cxx.use_ccache = True
+ self.lit_config.note('enabling ccache')
+
+ def configure_features(self):
+ additional_features = self.get_lit_conf('additional_features')
+ if additional_features:
+ for f in additional_features.split(','):
+ self.config.available_features.add(f.strip())
+
+ # Figure out which of the required locales we support
+ locales = {
+ 'Darwin': {
+ 'en_US.UTF-8': 'en_US.UTF-8',
+ 'cs_CZ.ISO8859-2': 'cs_CZ.ISO8859-2',
+ 'fr_FR.UTF-8': 'fr_FR.UTF-8',
+ 'fr_CA.ISO8859-1': 'fr_CA.ISO8859-1',
+ 'ru_RU.UTF-8': 'ru_RU.UTF-8',
+ 'zh_CN.UTF-8': 'zh_CN.UTF-8',
+ },
+ 'FreeBSD': {
+ 'en_US.UTF-8': 'en_US.UTF-8',
+ 'cs_CZ.ISO8859-2': 'cs_CZ.ISO8859-2',
+ 'fr_FR.UTF-8': 'fr_FR.UTF-8',
+ 'fr_CA.ISO8859-1': 'fr_CA.ISO8859-1',
+ 'ru_RU.UTF-8': 'ru_RU.UTF-8',
+ 'zh_CN.UTF-8': 'zh_CN.UTF-8',
+ },
+ 'Linux': {
+ 'en_US.UTF-8': 'en_US.UTF-8',
+ 'cs_CZ.ISO8859-2': 'cs_CZ.ISO-8859-2',
+ 'fr_FR.UTF-8': 'fr_FR.UTF-8',
+ 'fr_CA.ISO8859-1': 'fr_CA.ISO-8859-1',
+ 'ru_RU.UTF-8': 'ru_RU.UTF-8',
+ 'zh_CN.UTF-8': 'zh_CN.UTF-8',
+ },
+ 'Windows': {
+ 'en_US.UTF-8': 'English_United States.1252',
+ 'cs_CZ.ISO8859-2': 'Czech_Czech Republic.1250',
+ 'fr_FR.UTF-8': 'French_France.1252',
+ 'fr_CA.ISO8859-1': 'French_Canada.1252',
+ 'ru_RU.UTF-8': 'Russian_Russia.1251',
+ 'zh_CN.UTF-8': 'Chinese_China.936',
+ },
+ }
+
+ target_system = self.target_info.system()
+ target_platform = self.target_info.platform()
+
+ if target_system in locales:
+ default_locale = locale.setlocale(locale.LC_ALL)
+ for feature, loc in locales[target_system].items():
+ try:
+ locale.setlocale(locale.LC_ALL, loc)
+ self.config.available_features.add(
+ 'locale.{0}'.format(feature))
+ except locale.Error:
+ self.lit_config.warning('The locale {0} is not supported by '
+ 'your platform. Some tests will be '
+ 'unsupported.'.format(loc))
+ locale.setlocale(locale.LC_ALL, default_locale)
+ else:
+ # Warn that the user doesn't get any free XFAILs for locale issues
+ self.lit_config.warning("No locales entry for target_system: %s" %
+ target_system)
+
+ # Write an "available feature" that combines the triple when
+ # use_system_cxx_lib is enabled. This is so that we can easily write
+ # XFAIL markers for tests that are known to fail with versions of
+ # libc++ as were shipped with a particular triple.
+ if self.use_system_cxx_lib:
+ self.config.available_features.add(
+ 'with_system_cxx_lib=%s' % self.config.target_triple)
+
+ # Insert the platform name into the available features as a lower case.
+ self.config.available_features.add(target_platform)
+
+ # Some linux distributions have different locale data than others.
+ # Insert the distributions name and name-version into the available
+ # features to allow tests to XFAIL on them.
+ if target_platform == 'linux':
+ name = self.target_info.platform_name()
+ ver = self.target_info.platform_ver()
+ if name:
+ self.config.available_features.add(name)
+ if name and ver:
+ self.config.available_features.add('%s-%s' % (name, ver))
+
+ # Simulator testing can take a really long time for some of these tests
+ # so add a feature check so we can REQUIRES: long_tests in them
+ self.long_tests = self.get_lit_bool('long_tests')
+ if self.long_tests is None:
+ # Default to running long tests.
+ self.long_tests = True
+ self.lit_config.note(
+ "inferred long_tests as: %r" % self.long_tests)
+
+ if self.long_tests:
+ self.config.available_features.add('long_tests')
+
+ # Run a compile test for the -fsized-deallocation flag. This is needed
+ # in test/std/language.support/support.dynamic/new.delete
+ if self.cxx.hasCompileFlag('-fsized-deallocation'):
+ self.config.available_features.add('fsized-deallocation')
+
+ def configure_compile_flags(self):
+ no_default_flags = self.get_lit_bool('no_default_flags', False)
+ if not no_default_flags:
+ self.configure_default_compile_flags()
+ # Configure extra flags
+ compile_flags_str = self.get_lit_conf('compile_flags', '')
+ self.cxx.compile_flags += shlex.split(compile_flags_str)
+
+ def configure_default_compile_flags(self):
+ # Try and get the std version from the command line. Fall back to
+ # default given in lit.site.cfg is not present. If default is not
+ # present then force c++11.
+ std = self.get_lit_conf('std', 'c++11')
+ self.cxx.compile_flags += ['-std={0}'.format(std)]
+ self.config.available_features.add(std)
+ # Configure include paths
+ self.cxx.compile_flags += ['-nostdinc++']
+ self.configure_compile_flags_header_includes()
+ if self.target_info.platform() == 'linux':
+ self.cxx.compile_flags += ['-D__STDC_FORMAT_MACROS',
+ '-D__STDC_LIMIT_MACROS',
+ '-D__STDC_CONSTANT_MACROS']
+ # Configure feature flags.
+ self.configure_compile_flags_exceptions()
+ self.configure_compile_flags_rtti()
+ self.configure_compile_flags_no_global_filesystem_namespace()
+ self.configure_compile_flags_no_stdin()
+ self.configure_compile_flags_no_stdout()
+ enable_32bit = self.get_lit_bool('enable_32bit', False)
+ if enable_32bit:
+ self.cxx.flags += ['-m32']
+ # Configure threading features.
+ enable_threads = self.get_lit_bool('enable_threads', True)
+ enable_monotonic_clock = self.get_lit_bool('enable_monotonic_clock',
+ True)
+ if not enable_threads:
+ self.configure_compile_flags_no_threads()
+ if not enable_monotonic_clock:
+ self.configure_compile_flags_no_monotonic_clock()
+ elif not enable_monotonic_clock:
+ self.lit_config.fatal('enable_monotonic_clock cannot be false when'
+ ' enable_threads is true.')
+ self.configure_compile_flags_no_thread_unsafe_c_functions()
+
+ # Use verbose output for better errors
+ self.cxx.flags += ['-v']
+ sysroot = self.get_lit_conf('sysroot')
+ if sysroot:
+ self.cxx.flags += ['--sysroot', sysroot]
+ gcc_toolchain = self.get_lit_conf('gcc_toolchain')
+ if gcc_toolchain:
+ self.cxx.flags += ['-gcc-toolchain', gcc_toolchain]
+ if self.use_target:
+ self.cxx.flags += ['-target', self.config.target_triple]
+
+ def configure_compile_flags_header_includes(self):
+ support_path = os.path.join(self.libcxx_src_root, 'test/support')
+ self.cxx.compile_flags += ['-I' + support_path]
+ self.cxx.compile_flags += ['-include', os.path.join(support_path, 'nasty_macros.hpp')]
+ libcxx_headers = self.get_lit_conf(
+ 'libcxx_headers', os.path.join(self.libcxx_src_root, 'include'))
+ if not os.path.isdir(libcxx_headers):
+ self.lit_config.fatal("libcxx_headers='%s' is not a directory."
+ % libcxx_headers)
+ self.cxx.compile_flags += ['-I' + libcxx_headers]
+
+ def configure_compile_flags_exceptions(self):
+ enable_exceptions = self.get_lit_bool('enable_exceptions', True)
+ if not enable_exceptions:
+ self.config.available_features.add('libcpp-no-exceptions')
+ self.cxx.compile_flags += ['-fno-exceptions']
+
+ def configure_compile_flags_rtti(self):
+ enable_rtti = self.get_lit_bool('enable_rtti', True)
+ if not enable_rtti:
+ self.config.available_features.add('libcpp-no-rtti')
+ self.cxx.compile_flags += ['-fno-rtti', '-D_LIBCPP_NO_RTTI']
+
+ def configure_compile_flags_no_global_filesystem_namespace(self):
+ enable_global_filesystem_namespace = self.get_lit_bool(
+ 'enable_global_filesystem_namespace', True)
+ if not enable_global_filesystem_namespace:
+ self.config.available_features.add(
+ 'libcpp-has-no-global-filesystem-namespace')
+ self.cxx.compile_flags += [
+ '-D_LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE']
+
+ def configure_compile_flags_no_stdin(self):
+ enable_stdin = self.get_lit_bool('enable_stdin', True)
+ if not enable_stdin:
+ self.config.available_features.add('libcpp-has-no-stdin')
+ self.cxx.compile_flags += ['-D_LIBCPP_HAS_NO_STDIN']
+
+ def configure_compile_flags_no_stdout(self):
+ enable_stdout = self.get_lit_bool('enable_stdout', True)
+ if not enable_stdout:
+ self.config.available_features.add('libcpp-has-no-stdout')
+ self.cxx.compile_flags += ['-D_LIBCPP_HAS_NO_STDOUT']
+
+ def configure_compile_flags_no_threads(self):
+ self.cxx.compile_flags += ['-D_LIBCPP_HAS_NO_THREADS']
+ self.config.available_features.add('libcpp-has-no-threads')
+
+ def configure_compile_flags_no_thread_unsafe_c_functions(self):
+ enable_thread_unsafe_c_functions = self.get_lit_bool(
+ 'enable_thread_unsafe_c_functions', True)
+ if not enable_thread_unsafe_c_functions:
+ self.cxx.compile_flags += [
+ '-D_LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS']
+ self.config.available_features.add(
+ 'libcpp-has-no-thread-unsafe-c-functions')
+
+ def configure_compile_flags_no_monotonic_clock(self):
+ self.cxx.compile_flags += ['-D_LIBCPP_HAS_NO_MONOTONIC_CLOCK']
+ self.config.available_features.add('libcpp-has-no-monotonic-clock')
+
+ def configure_link_flags(self):
+ no_default_flags = self.get_lit_bool('no_default_flags', False)
+ if not no_default_flags:
+ self.cxx.link_flags += ['-nodefaultlibs']
+
+ # Configure library path
+ self.configure_link_flags_cxx_library_path()
+ self.configure_link_flags_abi_library_path()
+
+ # Configure libraries
+ self.configure_link_flags_cxx_library()
+ self.configure_link_flags_abi_library()
+ self.configure_extra_library_flags()
+
+ link_flags_str = self.get_lit_conf('link_flags', '')
+ self.cxx.link_flags += shlex.split(link_flags_str)
+
+ def configure_link_flags_cxx_library_path(self):
+ libcxx_library = self.get_lit_conf('libcxx_library')
+ # Configure libc++ library paths.
+ if libcxx_library is not None:
+ # Check that the given value for libcxx_library is valid.
+ if not os.path.isfile(libcxx_library):
+ self.lit_config.fatal(
+ "libcxx_library='%s' is not a valid file." %
+ libcxx_library)
+ if self.use_system_cxx_lib:
+ self.lit_config.fatal(
+ "Conflicting options: 'libcxx_library' cannot be used "
+ "with 'use_system_cxx_lib=true'")
+ self.cxx.link_flags += ['-Wl,-rpath,' +
+ os.path.dirname(libcxx_library)]
+ elif not self.use_system_cxx_lib and self.cxx_library_root:
+ self.cxx.link_flags += ['-L' + self.cxx_library_root,
+ '-Wl,-rpath,' + self.cxx_library_root]
+
+ def configure_link_flags_abi_library_path(self):
+ # Configure ABI library paths.
+ self.abi_library_root = self.get_lit_conf('abi_library_path')
+ if self.abi_library_root:
+ self.cxx.link_flags += ['-L' + self.abi_library_root,
+ '-Wl,-rpath,' + self.abi_library_root]
+
+ def configure_link_flags_cxx_library(self):
+ libcxx_library = self.get_lit_conf('libcxx_library')
+ if libcxx_library:
+ self.cxx.link_flags += [libcxx_library]
+ else:
+ self.cxx.link_flags += ['-lc++']
+
+ def configure_link_flags_abi_library(self):
+ cxx_abi = self.get_lit_conf('cxx_abi', 'libcxxabi')
+ if cxx_abi == 'libstdc++':
+ self.cxx.link_flags += ['-lstdc++']
+ elif cxx_abi == 'libsupc++':
+ self.cxx.link_flags += ['-lsupc++']
+ elif cxx_abi == 'libcxxabi':
+ # Don't link libc++abi explicitly on OS X because the symbols
+ # should be available in libc++ directly.
+ if self.target_info.platform() != 'darwin':
+ self.cxx.link_flags += ['-lc++abi']
+ elif cxx_abi == 'libcxxrt':
+ self.cxx.link_flags += ['-lcxxrt']
+ elif cxx_abi == 'none':
+ pass
+ else:
+ self.lit_config.fatal(
+ 'C++ ABI setting %s unsupported for tests' % cxx_abi)
+
+ def configure_extra_library_flags(self):
+ enable_threads = self.get_lit_bool('enable_threads', True)
+ llvm_unwinder = self.get_lit_bool('llvm_unwinder', False)
+ target_platform = self.target_info.platform()
+ if target_platform == 'darwin':
+ self.cxx.link_flags += ['-lSystem']
+ elif target_platform == 'linux':
+ if not llvm_unwinder:
+ self.cxx.link_flags += ['-lgcc_eh']
+ self.cxx.link_flags += ['-lc', '-lm']
+ if enable_threads:
+ self.cxx.link_flags += ['-lpthread']
+ self.cxx.link_flags += ['-lrt']
+ if llvm_unwinder:
+ self.cxx.link_flags += ['-lunwind', '-ldl']
+ else:
+ self.cxx.link_flags += ['-lgcc_s']
+ elif target_platform.startswith('freebsd'):
+ self.cxx.link_flags += ['-lc', '-lm', '-lpthread', '-lgcc_s', '-lcxxrt']
+ else:
+ self.lit_config.fatal("unrecognized system: %r" % target_platform)
+
+ def configure_color_diagnostics(self):
+ use_color = self.get_lit_conf('color_diagnostics')
+ if use_color is None:
+ use_color = os.environ.get('LIBCXX_COLOR_DIAGNOSTICS')
+ if use_color is None:
+ return
+ if use_color != '':
+ self.lit_config.fatal('Invalid value for color_diagnostics "%s".'
+ % use_color)
+ color_flag = '-fdiagnostics-color=always'
+ # Check if the compiler supports the color diagnostics flag. Issue a
+ # warning if it does not since color diagnostics have been requested.
+ if not self.cxx.hasCompileFlag(color_flag):
+ self.lit_config.warning(
+ 'color diagnostics have been requested but are not supported '
+ 'by the compiler')
+ else:
+ self.cxx.flags += [color_flag]
+
+ def configure_debug_mode(self):
+ debug_level = self.get_lit_conf('debug_level', None)
+ if not debug_level:
+ return
+ if debug_level not in ['0', '1']:
+ self.lit_config.fatal('Invalid value for debug_level "%s".'
+ % debug_level)
+ self.cxx.compile_flags += ['-D_LIBCPP_DEBUG=%s' % debug_level]
+
+ def configure_warnings(self):
+ enable_warnings = self.get_lit_bool('enable_warnings', False)
+ if enable_warnings:
+ self.cxx.compile_flags += ['-Wsystem-headers', '-Wall', '-Werror']
+ if ('clang' in self.config.available_features or
+ 'apple-clang' in self.config.available_features):
+ self.cxx.compile_flags += ['-Wno-user-defined-literals']
+
+ def configure_sanitizer(self):
+ san = self.get_lit_conf('use_sanitizer', '').strip()
+ if san:
+ # Search for llvm-symbolizer along the compiler path first
+ # and then along the PATH env variable.
+ symbolizer_search_paths = os.environ.get('PATH', '')
+ cxx_path = lit.util.which(self.cxx.path)
+ if cxx_path is not None:
+ symbolizer_search_paths = (
+ os.path.dirname(cxx_path) +
+ os.pathsep + symbolizer_search_paths)
+ llvm_symbolizer = lit.util.which('llvm-symbolizer',
+ symbolizer_search_paths)
+ # Setup the sanitizer compile flags
+ self.cxx.flags += ['-g', '-fno-omit-frame-pointer']
+ if self.target_info.platform() == 'linux':
+ self.cxx.link_flags += ['-ldl']
+ if san == 'Address':
+ self.cxx.flags += ['-fsanitize=address']
+ if llvm_symbolizer is not None:
+ self.env['ASAN_SYMBOLIZER_PATH'] = llvm_symbolizer
+ self.config.available_features.add('asan')
+ self.config.available_features.add('sanitizer-new-delete')
+ elif san == 'Memory' or san == 'MemoryWithOrigins':
+ self.cxx.flags += ['-fsanitize=memory']
+ if san == 'MemoryWithOrigins':
+ self.cxx.compile_flags += [
+ '-fsanitize-memory-track-origins']
+ if llvm_symbolizer is not None:
+ self.env['MSAN_SYMBOLIZER_PATH'] = llvm_symbolizer
+ self.config.available_features.add('msan')
+ self.config.available_features.add('sanitizer-new-delete')
+ elif san == 'Undefined':
+ self.cxx.flags += ['-fsanitize=undefined',
+ '-fno-sanitize=vptr,function',
+ '-fno-sanitize-recover']
+ self.cxx.compile_flags += ['-O3']
+ self.config.available_features.add('ubsan')
+ elif san == 'Thread':
+ self.cxx.flags += ['-fsanitize=thread']
+ self.config.available_features.add('tsan')
+ self.config.available_features.add('sanitizer-new-delete')
+ else:
+ self.lit_config.fatal('unsupported value for '
+ 'use_sanitizer: {0}'.format(san))
+
+ def configure_coverage(self):
+ self.generate_coverage = self.get_lit_bool('generate_coverage', False)
+ if self.generate_coverage:
+ self.cxx.flags += ['-g', '--coverage']
+ self.cxx.compile_flags += ['-O0']
+
+ def configure_substitutions(self):
+ sub = self.config.substitutions
+ # Configure compiler substitions
+ sub.append(('%cxx', self.cxx.path))
+ # Configure flags substitutions
+ flags_str = ' '.join(self.cxx.flags)
+ compile_flags_str = ' '.join(self.cxx.compile_flags)
+ link_flags_str = ' '.join(self.cxx.link_flags)
+ all_flags = '%s %s %s' % (flags_str, compile_flags_str, link_flags_str)
+ sub.append(('%flags', flags_str))
+ sub.append(('%compile_flags', compile_flags_str))
+ sub.append(('%link_flags', link_flags_str))
+ sub.append(('%all_flags', all_flags))
+ # Add compile and link shortcuts
+ compile_str = (self.cxx.path + ' -o %t.o %s -c ' + flags_str
+ + compile_flags_str)
+ link_str = (self.cxx.path + ' -o %t.exe %t.o ' + flags_str
+ + link_flags_str)
+ assert type(link_str) is str
+ build_str = self.cxx.path + ' -o %t.exe %s ' + all_flags
+ sub.append(('%compile', compile_str))
+ sub.append(('%link', link_str))
+ sub.append(('%build', build_str))
+ # Configure exec prefix substitutions.
+ exec_env_str = 'env ' if len(self.env) != 0 else ''
+ for k, v in self.env.items():
+ exec_env_str += ' %s=%s' % (k, v)
+ # Configure run env substitution.
+ exec_str = ''
+ if self.lit_config.useValgrind:
+ exec_str = ' '.join(self.lit_config.valgrindArgs) + exec_env_str
+ sub.append(('%exec', exec_str))
+ # Configure run shortcut
+ sub.append(('%run', exec_str + ' %t.exe'))
+ # Configure not program substitions
+ not_py = os.path.join(self.libcxx_src_root, 'utils', 'not', 'not.py')
+ not_str = '%s %s' % (sys.executable, not_py)
+ sub.append(('not', not_str))
+
+ def configure_triple(self):
+ # Get or infer the target triple.
+ self.config.target_triple = self.get_lit_conf('target_triple')
+ self.use_target = bool(self.config.target_triple)
+ # If no target triple was given, try to infer it from the compiler
+ # under test.
+ if not self.use_target:
+ target_triple = self.cxx.getTriple()
+ # Drop sub-major version components from the triple, because the
+ # current XFAIL handling expects exact matches for feature checks.
+ # Example: x86_64-apple-darwin14.0.0 -> x86_64-apple-darwin14
+ # The 5th group handles triples greater than 3 parts
+ # (ex x86_64-pc-linux-gnu).
+ target_triple = re.sub(r'([^-]+)-([^-]+)-([^.]+)([^-]*)(.*)',
+ r'\1-\2-\3\5', target_triple)
+ # linux-gnu is needed in the triple to properly identify linuxes
+ # that use GLIBC. Handle redhat and opensuse triples as special
+ # cases and append the missing `-gnu` portion.
+ if (target_triple.endswith('redhat-linux') or
+ target_triple.endswith('suse-linux')):
+ target_triple += '-gnu'
+ self.config.target_triple = target_triple
+ self.lit_config.note(
+ "inferred target_triple as: %r" % self.config.target_triple)
+
+ def configure_env(self):
+ if self.target_info.platform() == 'darwin':
+ library_paths = []
+ # Configure the library path for libc++
+ libcxx_library = self.get_lit_conf('libcxx_library')
+ if self.use_system_cxx_lib:
+ pass
+ elif libcxx_library:
+ library_paths += [os.path.dirname(libcxx_library)]
+ elif self.cxx_library_root:
+ library_paths += [self.cxx_library_root]
+ # Configure the abi library path
+ if self.abi_library_root:
+ library_paths += [self.abi_library_root]
+ if library_paths:
+ self.env['DYLD_LIBRARY_PATH'] = ':'.join(library_paths)
diff --git a/test/libcxx/test/executor.py b/test/libcxx/test/executor.py
new file mode 100644
index 000000000000..f0356ceca784
--- /dev/null
+++ b/test/libcxx/test/executor.py
@@ -0,0 +1,191 @@
+import os
+
+from libcxx.test import tracing
+
+from lit.util import executeCommand # pylint: disable=import-error
+
+
+class Executor(object):
+ def run(self, exe_path, cmd, local_cwd, file_deps=None, env=None):
+ """Execute a command.
+ Be very careful not to change shared state in this function.
+ Executor objects are shared between python processes in `lit -jN`.
+ Args:
+ exe_path: str: Local path to the executable to be run
+ cmd: [str]: subprocess.call style command
+ local_cwd: str: Local path to the working directory
+ file_deps: [str]: Files required by the test
+ env: {str: str}: Environment variables to execute under
+ Returns:
+ cmd, out, err, exitCode
+ """
+ raise NotImplementedError
+
+
+class LocalExecutor(Executor):
+ def __init__(self):
+ super(LocalExecutor, self).__init__()
+
+ def run(self, exe_path, cmd=None, work_dir='.', file_deps=None, env=None):
+ cmd = cmd or [exe_path]
+ env_cmd = []
+ if env:
+ env_cmd += ['env']
+ env_cmd += ['%s=%s' % (k, v) for k, v in env.items()]
+ if work_dir == '.':
+ work_dir = os.getcwd()
+ out, err, rc = executeCommand(env_cmd + cmd, cwd=work_dir)
+ return (env_cmd + cmd, out, err, rc)
+
+
+class PrefixExecutor(Executor):
+ """Prefix an executor with some other command wrapper.
+
+ Most useful for setting ulimits on commands, or running an emulator like
+ qemu and valgrind.
+ """
+ def __init__(self, commandPrefix, chain):
+ super(PrefixExecutor, self).__init__()
+
+ self.commandPrefix = commandPrefix
+ self.chain = chain
+
+ def run(self, exe_path, cmd=None, work_dir='.', file_deps=None, env=None):
+ cmd = cmd or [exe_path]
+ return self.chain.run(exe_path, self.commandPrefix + cmd, work_dir,
+ file_deps, env=env)
+
+
+class PostfixExecutor(Executor):
+ """Postfix an executor with some args."""
+ def __init__(self, commandPostfix, chain):
+ super(PostfixExecutor, self).__init__()
+
+ self.commandPostfix = commandPostfix
+ self.chain = chain
+
+ def run(self, exe_path, cmd=None, work_dir='.', file_deps=None, env=None):
+ cmd = cmd or [exe_path]
+ return self.chain.run(cmd + self.commandPostfix, work_dir, file_deps,
+ env=env)
+
+
+
+class TimeoutExecutor(PrefixExecutor):
+ """Execute another action under a timeout.
+
+ Deprecated. http://reviews.llvm.org/D6584 adds timeouts to LIT.
+ """
+ def __init__(self, duration, chain):
+ super(TimeoutExecutor, self).__init__(
+ ['timeout', duration], chain)
+
+
+class RemoteExecutor(Executor):
+ def __init__(self):
+ self.local_run = executeCommand
+
+ def remote_temp_dir(self):
+ return self._remote_temp(True)
+
+ def remote_temp_file(self):
+ return self._remote_temp(False)
+
+ def _remote_temp(self, is_dir):
+ raise NotImplementedError()
+
+ def copy_in(self, local_srcs, remote_dsts):
+ # This could be wrapped up in a tar->scp->untar for performance
+ # if there are lots of files to be copied/moved
+ for src, dst in zip(local_srcs, remote_dsts):
+ self._copy_in_file(src, dst)
+
+ def _copy_in_file(self, src, dst):
+ raise NotImplementedError()
+
+ def delete_remote(self, remote):
+ try:
+ self._execute_command_remote(['rm', '-rf', remote])
+ except OSError:
+ # TODO: Log failure to delete?
+ pass
+
+ def run(self, exe_path, cmd=None, work_dir='.', file_deps=None, env=None):
+ target_exe_path = None
+ target_cwd = None
+ try:
+ target_cwd = self.remote_temp_dir()
+ target_exe_path = os.path.join(target_cwd, 'libcxx_test.exe')
+ if cmd:
+ # Replace exe_path with target_exe_path.
+ cmd = [c if c != exe_path else target_exe_path for c in cmd]
+ else:
+ cmd = [target_exe_path]
+
+ srcs = [exe_path]
+ dsts = [target_exe_path]
+ if file_deps is not None:
+ dev_paths = [os.path.join(target_cwd, os.path.basename(f))
+ for f in file_deps]
+ srcs.extend(file_deps)
+ dsts.extend(dev_paths)
+ self.copy_in(srcs, dsts)
+ # TODO(jroelofs): capture the copy_in and delete_remote commands,
+ # and conjugate them with '&&'s around the first tuple element
+ # returned here:
+ return self._execute_command_remote(cmd, target_cwd, env)
+ finally:
+ if target_cwd:
+ self.delete_remote(target_cwd)
+
+ def _execute_command_remote(self, cmd, remote_work_dir='.', env=None):
+ raise NotImplementedError()
+
+
+class SSHExecutor(RemoteExecutor):
+ def __init__(self, host, username=None):
+ super(SSHExecutor, self).__init__()
+
+ self.user_prefix = username + '@' if username else ''
+ self.host = host
+ self.scp_command = 'scp'
+ self.ssh_command = 'ssh'
+
+ # TODO(jroelofs): switch this on some -super-verbose-debug config flag
+ if False:
+ self.local_run = tracing.trace_function(
+ self.local_run, log_calls=True, log_results=True,
+ label='ssh_local')
+
+ def _remote_temp(self, is_dir):
+ # TODO: detect what the target system is, and use the correct
+ # mktemp command for it. (linux and darwin differ here, and I'm
+ # sure windows has another way to do it)
+
+ # Not sure how to do suffix on osx yet
+ dir_arg = '-d' if is_dir else ''
+ cmd = 'mktemp -q {} /tmp/libcxx.XXXXXXXXXX'.format(dir_arg)
+ temp_path, err, exitCode = self._execute_command_remote([cmd])
+ temp_path = temp_path.strip()
+ if exitCode != 0:
+ raise RuntimeError(err)
+ return temp_path
+
+ def _copy_in_file(self, src, dst):
+ scp = self.scp_command
+ remote = self.host
+ remote = self.user_prefix + remote
+ cmd = [scp, '-p', src, remote + ':' + dst]
+ self.local_run(cmd)
+
+ def _execute_command_remote(self, cmd, remote_work_dir='.', env=None):
+ remote = self.user_prefix + self.host
+ ssh_cmd = [self.ssh_command, '-oBatchMode=yes', remote]
+ if env:
+ env_cmd = ['env'] + ['%s=%s' % (k, v) for k, v in env.items()]
+ else:
+ env_cmd = []
+ remote_cmd = ' '.join(env_cmd + cmd)
+ if remote_work_dir != '.':
+ remote_cmd = 'cd ' + remote_work_dir + ' && ' + remote_cmd
+ return self.local_run(ssh_cmd + [remote_cmd])
diff --git a/test/libcxx/test/format.py b/test/libcxx/test/format.py
new file mode 100644
index 000000000000..238dcdb29af7
--- /dev/null
+++ b/test/libcxx/test/format.py
@@ -0,0 +1,163 @@
+import errno
+import os
+import time
+
+import lit.Test # pylint: disable=import-error
+import lit.TestRunner # pylint: disable=import-error
+import lit.util # pylint: disable=import-error
+
+from libcxx.test.executor import LocalExecutor as LocalExecutor
+import libcxx.util
+
+
+class LibcxxTestFormat(object):
+ """
+ Custom test format handler for use with the test format use by libc++.
+
+ Tests fall into two categories:
+ FOO.pass.cpp - Executable test which should compile, run, and exit with
+ code 0.
+ FOO.fail.cpp - Negative test case which is expected to fail compilation.
+ FOO.sh.cpp - A test that uses LIT's ShTest format.
+ """
+
+ def __init__(self, cxx, use_verify_for_fail, execute_external,
+ executor, exec_env):
+ self.cxx = cxx
+ self.use_verify_for_fail = use_verify_for_fail
+ self.execute_external = execute_external
+ self.executor = executor
+ self.exec_env = dict(exec_env)
+
+ # TODO: Move this into lit's FileBasedTest
+ def getTestsInDirectory(self, testSuite, path_in_suite,
+ litConfig, localConfig):
+ source_path = testSuite.getSourcePath(path_in_suite)
+ for filename in os.listdir(source_path):
+ # Ignore dot files and excluded tests.
+ if filename.startswith('.') or filename in localConfig.excludes:
+ continue
+
+ filepath = os.path.join(source_path, filename)
+ if not os.path.isdir(filepath):
+ if any([filename.endswith(ext)
+ for ext in localConfig.suffixes]):
+ yield lit.Test.Test(testSuite, path_in_suite + (filename,),
+ localConfig)
+
+ def execute(self, test, lit_config):
+ while True:
+ try:
+ return self._execute(test, lit_config)
+ except OSError as oe:
+ if oe.errno != errno.ETXTBSY:
+ raise
+ time.sleep(0.1)
+
+ def _execute(self, test, lit_config):
+ name = test.path_in_suite[-1]
+ is_sh_test = name.endswith('.sh.cpp')
+ is_pass_test = name.endswith('.pass.cpp')
+ is_fail_test = name.endswith('.fail.cpp')
+
+ if test.config.unsupported:
+ return (lit.Test.UNSUPPORTED,
+ "A lit.local.cfg marked this unsupported")
+
+ res = lit.TestRunner.parseIntegratedTestScript(
+ test, require_script=is_sh_test)
+ # Check if a result for the test was returned. If so return that
+ # result.
+ if isinstance(res, lit.Test.Result):
+ return res
+ if lit_config.noExecute:
+ return lit.Test.Result(lit.Test.PASS)
+ # res is not an instance of lit.test.Result. Expand res into its parts.
+ script, tmpBase, execDir = res
+ # Check that we don't have run lines on tests that don't support them.
+ if not is_sh_test and len(script) != 0:
+ lit_config.fatal('Unsupported RUN line found in test %s' % name)
+
+ # Dispatch the test based on its suffix.
+ if is_sh_test:
+ if not isinstance(self.executor, LocalExecutor):
+ # We can't run ShTest tests with a executor yet.
+ # For now, bail on trying to run them
+ return lit.Test.UNSUPPORTED, 'ShTest format not yet supported'
+ return lit.TestRunner._runShTest(test, lit_config,
+ self.execute_external, script,
+ tmpBase, execDir)
+ elif is_fail_test:
+ return self._evaluate_fail_test(test)
+ elif is_pass_test:
+ return self._evaluate_pass_test(test, tmpBase, execDir, lit_config)
+ else:
+ # No other test type is supported
+ assert False
+
+ def _clean(self, exec_path): # pylint: disable=no-self-use
+ libcxx.util.cleanFile(exec_path)
+
+ def _evaluate_pass_test(self, test, tmpBase, execDir, lit_config):
+ source_path = test.getSourcePath()
+ exec_path = tmpBase + '.exe'
+ object_path = tmpBase + '.o'
+ # Create the output directory if it does not already exist.
+ lit.util.mkdir_p(os.path.dirname(tmpBase))
+ try:
+ # Compile the test
+ cmd, out, err, rc = self.cxx.compileLinkTwoSteps(
+ source_path, out=exec_path, object_file=object_path,
+ cwd=execDir)
+ compile_cmd = cmd
+ if rc != 0:
+ report = libcxx.util.makeReport(cmd, out, err, rc)
+ report += "Compilation failed unexpectedly!"
+ return lit.Test.FAIL, report
+ # Run the test
+ local_cwd = os.path.dirname(source_path)
+ env = None
+ if self.exec_env:
+ env = self.exec_env
+ # TODO: Only list actually needed files in file_deps.
+ # Right now we just mark all of the .dat files in the same
+ # directory as dependencies, but it's likely less than that. We
+ # should add a `// FILE-DEP: foo.dat` to each test to track this.
+ data_files = [os.path.join(local_cwd, f)
+ for f in os.listdir(local_cwd) if f.endswith('.dat')]
+ cmd, out, err, rc = self.executor.run(exec_path, [exec_path],
+ local_cwd, data_files, env)
+ if rc != 0:
+ report = libcxx.util.makeReport(cmd, out, err, rc)
+ report = "Compiled With: %s\n%s" % (compile_cmd, report)
+ report += "Compiled test failed unexpectedly!"
+ return lit.Test.FAIL, report
+ return lit.Test.PASS, ''
+ finally:
+ # Note that cleanup of exec_file happens in `_clean()`. If you
+ # override this, cleanup is your reponsibility.
+ libcxx.util.cleanFile(object_path)
+ self._clean(exec_path)
+
+ def _evaluate_fail_test(self, test):
+ source_path = test.getSourcePath()
+ with open(source_path, 'r') as f:
+ contents = f.read()
+ verify_tags = ['expected-note', 'expected-remark', 'expected-warning',
+ 'expected-error', 'expected-no-diagnostics']
+ use_verify = self.use_verify_for_fail and \
+ any([tag in contents for tag in verify_tags])
+ extra_flags = []
+ if use_verify:
+ extra_flags += ['-Xclang', '-verify',
+ '-Xclang', '-verify-ignore-unexpected=note']
+ cmd, out, err, rc = self.cxx.compile(source_path, out=os.devnull,
+ flags=extra_flags)
+ expected_rc = 0 if use_verify else 1
+ if rc == expected_rc:
+ return lit.Test.PASS, ''
+ else:
+ report = libcxx.util.makeReport(cmd, out, err, rc)
+ report_msg = ('Expected compilation to fail!' if not use_verify else
+ 'Expected compilation using verify to pass!')
+ return lit.Test.FAIL, report + report_msg + '\n'
diff --git a/test/libcxx/test/target_info.py b/test/libcxx/test/target_info.py
new file mode 100644
index 000000000000..a61737786896
--- /dev/null
+++ b/test/libcxx/test/target_info.py
@@ -0,0 +1,55 @@
+import locale
+import platform
+import sys
+
+class TargetInfo(object):
+ def platform(self):
+ raise NotImplementedError
+
+ def system(self):
+ raise NotImplementedError
+
+ def platform_ver(self):
+ raise NotImplementedError
+
+ def platform_name(self):
+ raise NotImplementedError
+
+ def supports_locale(self, loc):
+ raise NotImplementedError
+
+
+class LocalTI(TargetInfo):
+ def platform(self):
+ platform_name = sys.platform.lower().strip()
+ # Strip the '2' from linux2.
+ if platform_name.startswith('linux'):
+ platform_name = 'linux'
+ return platform_name
+
+ def system(self):
+ return platform.system()
+
+ def platform_name(self):
+ if self.platform() == 'linux':
+ name, _, _ = platform.linux_distribution()
+ name = name.lower().strip()
+ if name:
+ return name
+ return None
+
+ def platform_ver(self):
+ if self.platform() == 'linux':
+ _, ver, _ = platform.linux_distribution()
+ ver = ver.lower().strip()
+ if ver:
+ return ver
+ return None
+
+ def supports_locale(self, loc):
+ try:
+ locale.setlocale(locale.LC_ALL, loc)
+ return True
+ except locale.Error:
+ return False
+
diff --git a/test/libcxx/test/tracing.py b/test/libcxx/test/tracing.py
new file mode 100644
index 000000000000..efef158160c5
--- /dev/null
+++ b/test/libcxx/test/tracing.py
@@ -0,0 +1,34 @@
+import os
+import inspect
+
+
+def trace_function(function, log_calls, log_results, label=''):
+ def wrapper(*args, **kwargs):
+ kwarg_strs = ['{}={}'.format(k, v) for (k, v) in kwargs]
+ arg_str = ', '.join([str(a) for a in args] + kwarg_strs)
+ call_str = '{}({})'.format(function.func_name, arg_str)
+
+ # Perform the call itself, logging before, after, and anything thrown.
+ try:
+ if log_calls:
+ print '{}: Calling {}'.format(label, call_str)
+ res = function(*args, **kwargs)
+ if log_results:
+ print '{}: {} -> {}'.format(label, call_str, res)
+ return res
+ except Exception as ex:
+ if log_results:
+ print '{}: {} raised {}'.format(label, call_str, type(ex))
+ raise ex
+
+ return wrapper
+
+
+def trace_object(obj, log_calls, log_results, label=''):
+ for name, member in inspect.getmembers(obj):
+ if inspect.ismethod(member):
+ # Skip meta-functions, decorate everything else
+ if not member.func_name.startswith('__'):
+ setattr(obj, name, trace_function(member, log_calls,
+ log_results, label))
+ return obj
diff --git a/test/libcxx/type_traits/convert_to_integral.pass.cpp b/test/libcxx/type_traits/convert_to_integral.pass.cpp
new file mode 100644
index 000000000000..b97832b5e6d7
--- /dev/null
+++ b/test/libcxx/type_traits/convert_to_integral.pass.cpp
@@ -0,0 +1,94 @@
+
+// TODO: Make this test pass for all standards.
+// XFAIL: c++98, c++03
+
+#include <limits>
+#include <type_traits>
+#include <cstdint>
+#include <cassert>
+
+#include "user_defined_integral.hpp"
+
+template <class T>
+struct EnumType
+{
+ enum type : T {E_zero, E_one};
+};
+
+
+template <class From, class To>
+void check_integral_types()
+{
+ typedef std::numeric_limits<From> Limits;
+ const From max = Limits::max();
+ const From min = Limits::min();
+ {
+ auto ret = std::__convert_to_integral((From)max);
+ assert(ret == max);
+ ret = std::__convert_to_integral((From)min);
+ assert(ret == min);
+ static_assert(std::is_same<decltype(ret), To>::value, "");
+ }
+ {
+ UserDefinedIntegral<From> f(max);
+ auto ret = std::__convert_to_integral(f);
+ assert(ret == max);
+ f.value = min;
+ ret = std::__convert_to_integral(f);
+ assert(ret == min);
+ static_assert(std::is_same<decltype(ret), To>::value, "");
+ }
+ {
+ typedef typename EnumType<From>::type Enum;
+ Enum e(static_cast<Enum>(max));
+ auto ret = std::__convert_to_integral(e);
+ assert(ret == max);
+ e = static_cast<Enum>(min);
+ ret = std::__convert_to_integral(min);
+ assert(ret == min);
+ static_assert(std::is_same<decltype(ret), To>::value, "");
+ }
+}
+
+
+template <class From, class To>
+void check_enum_types()
+{
+ auto ret = std::__convert_to_integral((From)1);
+ assert(ret == 1);
+ static_assert(std::is_same<decltype(ret), To>::value, "");
+}
+
+
+enum enum1 { zero = 0, one = 1 };
+enum enum2 {
+ value = std::numeric_limits<unsigned long>::max()
+};
+
+int main()
+{
+ check_integral_types<bool, int>();
+ check_integral_types<char, int>();
+ check_integral_types<signed char, int>();
+ check_integral_types<unsigned char, int>();
+ check_integral_types<wchar_t, decltype(((wchar_t)1) + 1)>();
+ check_integral_types<char16_t, int>();
+ check_integral_types<char32_t, uint32_t>();
+ check_integral_types<short, int>();
+ check_integral_types<unsigned short, int>();
+ check_integral_types<int, int>();
+ check_integral_types<unsigned, unsigned>();
+ check_integral_types<long, long>();
+ check_integral_types<unsigned long, unsigned long>();
+ check_integral_types<long long, long long>();
+ check_integral_types<unsigned long long, unsigned long long>();
+#ifndef _LIBCPP_HAS_NO_INT128
+ check_integral_types<__int128_t, __int128_t>();
+ check_integral_types<__uint128_t, __uint128_t>();
+#endif
+ // TODO(ericwf): Not standard
+ typedef std::underlying_type<enum1>::type Enum1UT;
+ check_enum_types<enum1, decltype(((Enum1UT)1) + 1)>();
+ typedef std::underlying_type<enum2>::type Enum2UT;
+ check_enum_types<enum2, decltype(((Enum2UT)1) + 1)>();
+}
diff --git a/test/libcxx/util.py b/test/libcxx/util.py
new file mode 100644
index 000000000000..28f2619d69cb
--- /dev/null
+++ b/test/libcxx/util.py
@@ -0,0 +1,46 @@
+from contextlib import contextmanager
+import os
+import tempfile
+
+
+def cleanFile(filename):
+ try:
+ os.remove(filename)
+ except OSError:
+ pass
+
+
+@contextmanager
+def guardedTempFilename(suffix='', prefix='', dir=None):
+ # Creates and yeilds a temporary filename within a with statement. The file
+ # is removed upon scope exit.
+ handle, name = tempfile.mkstemp(suffix=suffix, prefix=prefix, dir=dir)
+ os.close(handle)
+ yield name
+ cleanFile(name)
+
+
+@contextmanager
+def guardedFilename(name):
+ # yeilds a filename within a with statement. The file is removed upon scope
+ # exit.
+ yield name
+ cleanFile(name)
+
+
+@contextmanager
+def nullContext(value):
+ # yeilds a variable within a with statement. No action is taken upon scope
+ # exit.
+ yield value
+
+
+def makeReport(cmd, out, err, rc):
+ report = "Command: %s\n" % cmd
+ report += "Exit Code: %d\n" % rc
+ if out:
+ report += "Standard Output:\n--\n%s--\n" % out
+ if err:
+ report += "Standard Error:\n--\n%s--\n" % err
+ report += '\n'
+ return report
diff --git a/test/libcxx/utilities/memory/util.smartptr/race_condition.pass.cpp b/test/libcxx/utilities/memory/util.smartptr/race_condition.pass.cpp
new file mode 100644
index 000000000000..25dd31190685
--- /dev/null
+++ b/test/libcxx/utilities/memory/util.smartptr/race_condition.pass.cpp
@@ -0,0 +1,94 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+//
+// <memory>
+//
+// class shared_ptr
+//
+// This test attempts to create a race condition surrounding use_count()
+// with the hope that TSAN will diagnose it.
+
+#include <memory>
+#include <atomic>
+#include <thread>
+#include <cassert>
+
+typedef std::shared_ptr<int> Ptr;
+typedef std::weak_ptr<int> WeakPtr;
+
+std::atomic_bool Start;
+std::atomic_bool KeepRunning;
+
+struct TestRunner {
+ TestRunner(Ptr xx) : x(xx) {}
+ void operator()() {
+ while (Start == false) {}
+ while (KeepRunning) {
+ // loop to prevent always checking the atomic.
+ for (int i=0; i < 100000; ++i) {
+ Ptr x2 = x; // increment shared count
+ WeakPtr x3 = x; // increment weak count
+ Ptr x4 = x3.lock(); // increment shared count via lock
+ WeakPtr x5 = x3; // increment weak count
+ }
+ }
+ }
+ Ptr x;
+};
+
+void run_test(Ptr p) {
+ Start = false;
+ KeepRunning = true;
+ assert(p.use_count() == 2);
+ TestRunner r(p);
+ assert(p.use_count() == 3);
+ std::thread t1(r); // Start the test thread.
+ assert(p.use_count() == 4);
+ Start = true;
+ // Run until we witness 25 use count changes via both
+ // shared and weak pointer methods.
+ WeakPtr w = p;
+ int shared_changes_count = 0;
+ int weak_changes_count = 0;
+ while (shared_changes_count < 25 && weak_changes_count < 25) {
+ // check use_count on the shared_ptr
+ int last = p.use_count();
+ int new_val = p.use_count();
+ assert(last >= 4);
+ assert(new_val >= 4);
+ if (last != new_val) ++shared_changes_count;
+ // Check use_count on the weak_ptr
+ last = w.use_count();
+ new_val = w.use_count();
+ assert(last >= 4);
+ assert(new_val >= 4);
+ if (last != new_val) ++weak_changes_count;
+ }
+ // kill the test thread.
+ KeepRunning = false;
+ t1.join();
+ assert(p.use_count() == 3);
+}
+
+int main() {
+ {
+ // Test with out-of-place shared_count.
+ Ptr p(new int(42));
+ run_test(p);
+ assert(p.use_count() == 1);
+ }
+ {
+ // Test with in-place shared_count.
+ Ptr p = std::make_shared<int>(42);
+ run_test(p);
+ assert(p.use_count() == 1);
+ }
+}
diff --git a/test/lit.cfg b/test/lit.cfg
new file mode 100644
index 000000000000..f7fa6144f08f
--- /dev/null
+++ b/test/lit.cfg
@@ -0,0 +1,51 @@
+# -*- Python -*- vim: set ft=python ts=4 sw=4 expandtab tw=79:
+# Configuration file for the 'lit' test runner.
+import os
+import site
+
+site.addsitedir(os.path.dirname(__file__))
+
+
+# Tell pylint that we know config and lit_config exist somewhere.
+if 'PYLINT_IMPORT' in os.environ:
+ config = object()
+ lit_config = object()
+
+# name: The name of this test suite.
+config.name = 'libc++'
+
+# suffixes: A list of file extensions to treat as test files.
+config.suffixes = ['.pass.cpp', '.fail.cpp', '.sh.cpp']
+
+# test_source_root: The root path where tests are located.
+config.test_source_root = os.path.dirname(__file__)
+
+# Infer the test_exec_root from the libcxx_object root.
+obj_root = getattr(config, 'libcxx_obj_root', None)
+
+# Check that the test exec root is known.
+if obj_root is None:
+ import libcxx.test.config
+ libcxx.test.config.loadSiteConfig(lit_config, config, 'libcxx_site_config',
+ 'LIBCXX_SITE_CONFIG')
+ obj_root = getattr(config, 'libcxx_obj_root', None)
+ if obj_root is None:
+ import tempfile
+ obj_root = tempfile.mkdtemp(prefix='libcxx-testsuite-')
+ lit_config.warning('Creating temporary directory for object root: %s' %
+ obj_root)
+
+config.test_exec_root = os.path.join(obj_root, 'test')
+
+cfg_variant = getattr(config, 'configuration_variant', 'libcxx')
+if cfg_variant:
+ lit_config.note('Using configuration variant: %s' % cfg_variant)
+
+# Load the Configuration class from the module name <cfg_variant>.test.config.
+config_module_name = '.'.join([cfg_variant, 'test', 'config'])
+config_module = __import__(config_module_name, fromlist=['Configuration'])
+
+configuration = config_module.Configuration(lit_config, config)
+configuration.configure()
+configuration.print_config_info()
+config.test_format = configuration.get_test_format()
diff --git a/test/lit.site.cfg.in b/test/lit.site.cfg.in
new file mode 100644
index 000000000000..17f0686add6e
--- /dev/null
+++ b/test/lit.site.cfg.in
@@ -0,0 +1,30 @@
+@AUTO_GEN_COMMENT@
+config.cxx_under_test = "@LIBCXX_COMPILER@"
+config.std = "@LIBCXX_STD_VERSION@"
+config.libcxx_src_root = "@LIBCXX_SOURCE_DIR@"
+config.libcxx_obj_root = "@LIBCXX_BINARY_DIR@"
+config.cxx_library_root = "@LIBCXX_LIBRARY_DIR@"
+config.enable_exceptions = "@LIBCXX_ENABLE_EXCEPTIONS@"
+config.enable_rtti = "@LIBCXX_ENABLE_RTTI@"
+config.enable_shared = "@LIBCXX_ENABLE_SHARED@"
+config.enable_32bit = "@LIBCXX_BUILD_32_BITS@"
+config.enable_global_filesystem_namespace = "@LIBCXX_ENABLE_GLOBAL_FILESYSTEM_NAMESPACE@"
+config.enable_stdin = "@LIBCXX_ENABLE_STDIN@"
+config.enable_stdout = "@LIBCXX_ENABLE_STDOUT@"
+config.enable_threads = "@LIBCXX_ENABLE_THREADS@"
+config.enable_thread_unsafe_c_functions = "@LIBCXX_ENABLE_THREAD_UNSAFE_C_FUNCTIONS@"
+config.enable_monotonic_clock = "@LIBCXX_ENABLE_MONOTONIC_CLOCK@"
+config.cxx_abi = "@LIBCXX_CXX_ABI_LIBNAME@"
+config.use_sanitizer = "@LLVM_USE_SANITIZER@"
+config.abi_library_path = "@LIBCXX_CXX_ABI_LIBRARY_PATH@"
+config.configuration_variant = "@LIBCXX_LIT_VARIANT@"
+config.target_triple = "@LIBCXX_TARGET_TRIPLE@"
+config.sysroot = "@LIBCXX_SYSROOT@"
+config.gcc_toolchain = "@LIBCXX_GCC_TOOLCHAIN@"
+config.generate_coverage = "@LIBCXX_GENERATE_COVERAGE@"
+config.target_info = "@LIBCXX_TARGET_INFO@"
+config.executor = "@LIBCXX_EXECUTOR@"
+config.llvm_unwinder = "@LIBCXXABI_USE_LLVM_UNWINDER@"
+
+# Let the main config do the real work.
+lit_config.load_config(config, "@LIBCXX_SOURCE_DIR@/test/lit.cfg")
diff --git a/test/nothing_to_do.pass.cpp b/test/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..9a59227abdd9
--- /dev/null
+++ b/test/nothing_to_do.pass.cpp
@@ -0,0 +1,13 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/algorithms/alg.c.library/tested_elsewhere.pass.cpp b/test/std/algorithms/alg.c.library/tested_elsewhere.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/algorithms/alg.c.library/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/algorithms/alg.modifying.operations/alg.copy/copy.pass.cpp b/test/std/algorithms/alg.modifying.operations/alg.copy/copy.pass.cpp
new file mode 100644
index 000000000000..a20d6ab7df86
--- /dev/null
+++ b/test/std/algorithms/alg.modifying.operations/alg.copy/copy.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator InIter, OutputIterator<auto, InIter::reference> OutIter>
+// OutIter
+// copy(InIter first, InIter last, OutIter result);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class InIter, class OutIter>
+void
+test()
+{
+ const unsigned N = 1000;
+ int ia[N];
+ for (unsigned i = 0; i < N; ++i)
+ ia[i] = i;
+ int ib[N] = {0};
+
+ OutIter r = std::copy(InIter(ia), InIter(ia+N), OutIter(ib));
+ assert(base(r) == ib+N);
+ for (unsigned i = 0; i < N; ++i)
+ assert(ia[i] == ib[i]);
+}
+
+int main()
+{
+ test<input_iterator<const int*>, output_iterator<int*> >();
+ test<input_iterator<const int*>, input_iterator<int*> >();
+ test<input_iterator<const int*>, forward_iterator<int*> >();
+ test<input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<input_iterator<const int*>, random_access_iterator<int*> >();
+ test<input_iterator<const int*>, int*>();
+
+ test<forward_iterator<const int*>, output_iterator<int*> >();
+ test<forward_iterator<const int*>, input_iterator<int*> >();
+ test<forward_iterator<const int*>, forward_iterator<int*> >();
+ test<forward_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<forward_iterator<const int*>, random_access_iterator<int*> >();
+ test<forward_iterator<const int*>, int*>();
+
+ test<bidirectional_iterator<const int*>, output_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, input_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, forward_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, int*>();
+
+ test<random_access_iterator<const int*>, output_iterator<int*> >();
+ test<random_access_iterator<const int*>, input_iterator<int*> >();
+ test<random_access_iterator<const int*>, forward_iterator<int*> >();
+ test<random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, random_access_iterator<int*> >();
+ test<random_access_iterator<const int*>, int*>();
+
+ test<const int*, output_iterator<int*> >();
+ test<const int*, input_iterator<int*> >();
+ test<const int*, forward_iterator<int*> >();
+ test<const int*, bidirectional_iterator<int*> >();
+ test<const int*, random_access_iterator<int*> >();
+ test<const int*, int*>();
+}
diff --git a/test/std/algorithms/alg.modifying.operations/alg.copy/copy_backward.pass.cpp b/test/std/algorithms/alg.modifying.operations/alg.copy/copy_backward.pass.cpp
new file mode 100644
index 000000000000..039fd2fe026a
--- /dev/null
+++ b/test/std/algorithms/alg.modifying.operations/alg.copy/copy_backward.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<BidirectionalIterator InIter, BidirectionalIterator OutIter>
+// requires OutputIterator<OutIter, InIter::reference>
+// OutIter
+// copy_backward(InIter first, InIter last, OutIter result);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class InIter, class OutIter>
+void
+test()
+{
+ const unsigned N = 1000;
+ int ia[N];
+ for (unsigned i = 0; i < N; ++i)
+ ia[i] = i;
+ int ib[N] = {0};
+
+ OutIter r = std::copy_backward(InIter(ia), InIter(ia+N), OutIter(ib+N));
+ assert(base(r) == ib);
+ for (unsigned i = 0; i < N; ++i)
+ assert(ia[i] == ib[i]);
+}
+
+int main()
+{
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, int*>();
+
+ test<random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, random_access_iterator<int*> >();
+ test<random_access_iterator<const int*>, int*>();
+
+ test<const int*, bidirectional_iterator<int*> >();
+ test<const int*, random_access_iterator<int*> >();
+ test<const int*, int*>();
+}
diff --git a/test/std/algorithms/alg.modifying.operations/alg.copy/copy_if.pass.cpp b/test/std/algorithms/alg.modifying.operations/alg.copy/copy_if.pass.cpp
new file mode 100644
index 000000000000..ab402a5eb8be
--- /dev/null
+++ b/test/std/algorithms/alg.modifying.operations/alg.copy/copy_if.pass.cpp
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator InIter, OutputIterator<auto, InIter::reference> OutIter,
+// Predicate<auto, InIter::value_type> Pred>
+// requires CopyConstructible<Pred>
+// OutIter
+// copy_if(InIter first, InIter last, OutIter result, Pred pred);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+struct Pred
+{
+ bool operator()(int i) {return i % 3 == 0;}
+};
+
+template <class InIter, class OutIter>
+void
+test()
+{
+ const unsigned N = 1000;
+ int ia[N];
+ for (unsigned i = 0; i < N; ++i)
+ ia[i] = i;
+ int ib[N] = {0};
+
+ OutIter r = std::copy_if(InIter(ia), InIter(ia+N), OutIter(ib), Pred());
+ assert(base(r) == ib+N/3+1);
+ for (unsigned i = 0; i < N/3+1; ++i)
+ assert(ib[i] % 3 == 0);
+}
+
+int main()
+{
+ test<input_iterator<const int*>, output_iterator<int*> >();
+ test<input_iterator<const int*>, input_iterator<int*> >();
+ test<input_iterator<const int*>, forward_iterator<int*> >();
+ test<input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<input_iterator<const int*>, random_access_iterator<int*> >();
+ test<input_iterator<const int*>, int*>();
+
+ test<forward_iterator<const int*>, output_iterator<int*> >();
+ test<forward_iterator<const int*>, input_iterator<int*> >();
+ test<forward_iterator<const int*>, forward_iterator<int*> >();
+ test<forward_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<forward_iterator<const int*>, random_access_iterator<int*> >();
+ test<forward_iterator<const int*>, int*>();
+
+ test<bidirectional_iterator<const int*>, output_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, input_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, forward_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, int*>();
+
+ test<random_access_iterator<const int*>, output_iterator<int*> >();
+ test<random_access_iterator<const int*>, input_iterator<int*> >();
+ test<random_access_iterator<const int*>, forward_iterator<int*> >();
+ test<random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, random_access_iterator<int*> >();
+ test<random_access_iterator<const int*>, int*>();
+
+ test<const int*, output_iterator<int*> >();
+ test<const int*, input_iterator<int*> >();
+ test<const int*, forward_iterator<int*> >();
+ test<const int*, bidirectional_iterator<int*> >();
+ test<const int*, random_access_iterator<int*> >();
+ test<const int*, int*>();
+}
diff --git a/test/std/algorithms/alg.modifying.operations/alg.copy/copy_n.pass.cpp b/test/std/algorithms/alg.modifying.operations/alg.copy/copy_n.pass.cpp
new file mode 100644
index 000000000000..1dba8847c7e5
--- /dev/null
+++ b/test/std/algorithms/alg.modifying.operations/alg.copy/copy_n.pass.cpp
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator InIter, OutputIterator<auto, InIter::reference> OutIter>
+// OutIter
+// copy_n(InIter first, InIter::difference_type n, OutIter result);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "user_defined_integral.hpp"
+
+typedef UserDefinedIntegral<unsigned> UDI;
+
+template <class InIter, class OutIter>
+void
+test()
+{
+ const unsigned N = 1000;
+ int ia[N];
+ for (unsigned i = 0; i < N; ++i)
+ ia[i] = i;
+ int ib[N] = {0};
+
+ OutIter r = std::copy_n(InIter(ia), UDI(N/2), OutIter(ib));
+ assert(base(r) == ib+N/2);
+ for (unsigned i = 0; i < N/2; ++i)
+ assert(ia[i] == ib[i]);
+}
+
+int main()
+{
+ test<input_iterator<const int*>, output_iterator<int*> >();
+ test<input_iterator<const int*>, input_iterator<int*> >();
+ test<input_iterator<const int*>, forward_iterator<int*> >();
+ test<input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<input_iterator<const int*>, random_access_iterator<int*> >();
+ test<input_iterator<const int*>, int*>();
+
+ test<forward_iterator<const int*>, output_iterator<int*> >();
+ test<forward_iterator<const int*>, input_iterator<int*> >();
+ test<forward_iterator<const int*>, forward_iterator<int*> >();
+ test<forward_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<forward_iterator<const int*>, random_access_iterator<int*> >();
+ test<forward_iterator<const int*>, int*>();
+
+ test<bidirectional_iterator<const int*>, output_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, input_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, forward_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, int*>();
+
+ test<random_access_iterator<const int*>, output_iterator<int*> >();
+ test<random_access_iterator<const int*>, input_iterator<int*> >();
+ test<random_access_iterator<const int*>, forward_iterator<int*> >();
+ test<random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, random_access_iterator<int*> >();
+ test<random_access_iterator<const int*>, int*>();
+
+ test<const int*, output_iterator<int*> >();
+ test<const int*, input_iterator<int*> >();
+ test<const int*, forward_iterator<int*> >();
+ test<const int*, bidirectional_iterator<int*> >();
+ test<const int*, random_access_iterator<int*> >();
+ test<const int*, int*>();
+}
diff --git a/test/std/algorithms/alg.modifying.operations/alg.fill/fill.pass.cpp b/test/std/algorithms/alg.modifying.operations/alg.fill/fill.pass.cpp
new file mode 100644
index 000000000000..c72adac9e2e4
--- /dev/null
+++ b/test/std/algorithms/alg.modifying.operations/alg.fill/fill.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter, class T>
+// requires OutputIterator<Iter, const T&>
+// void
+// fill(Iter first, Iter last, const T& value);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter>
+void
+test_char()
+{
+ const unsigned n = 4;
+ char ca[n] = {0};
+ std::fill(Iter(ca), Iter(ca+n), char(1));
+ assert(ca[0] == 1);
+ assert(ca[1] == 1);
+ assert(ca[2] == 1);
+ assert(ca[3] == 1);
+}
+
+template <class Iter>
+void
+test_int()
+{
+ const unsigned n = 4;
+ int ia[n] = {0};
+ std::fill(Iter(ia), Iter(ia+n), 1);
+ assert(ia[0] == 1);
+ assert(ia[1] == 1);
+ assert(ia[2] == 1);
+ assert(ia[3] == 1);
+}
+
+int main()
+{
+ test_char<forward_iterator<char*> >();
+ test_char<bidirectional_iterator<char*> >();
+ test_char<random_access_iterator<char*> >();
+ test_char<char*>();
+
+ test_int<forward_iterator<int*> >();
+ test_int<bidirectional_iterator<int*> >();
+ test_int<random_access_iterator<int*> >();
+ test_int<int*>();
+}
diff --git a/test/std/algorithms/alg.modifying.operations/alg.fill/fill_n.pass.cpp b/test/std/algorithms/alg.modifying.operations/alg.fill/fill_n.pass.cpp
new file mode 100644
index 000000000000..6617cd0916f3
--- /dev/null
+++ b/test/std/algorithms/alg.modifying.operations/alg.fill/fill_n.pass.cpp
@@ -0,0 +1,156 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<class Iter, IntegralLike Size, class T>
+// requires OutputIterator<Iter, const T&>
+// OutputIterator
+// fill_n(Iter first, Size n, const T& value);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "user_defined_integral.hpp"
+
+typedef UserDefinedIntegral<unsigned> UDI;
+
+template <class Iter>
+void
+test_char()
+{
+ const unsigned n = 4;
+ char ca[n] = {0};
+ assert(std::fill_n(Iter(ca), UDI(n), char(1)) == std::next(Iter(ca), n));
+ assert(ca[0] == 1);
+ assert(ca[1] == 1);
+ assert(ca[2] == 1);
+ assert(ca[3] == 1);
+}
+
+template <class Iter>
+void
+test_int()
+{
+ const unsigned n = 4;
+ int ia[n] = {0};
+ assert(std::fill_n(Iter(ia), UDI(n), 1) == std::next(Iter(ia), n));
+ assert(ia[0] == 1);
+ assert(ia[1] == 1);
+ assert(ia[2] == 1);
+ assert(ia[3] == 1);
+}
+
+void
+test_int_array()
+{
+ const unsigned n = 4;
+ int ia[n] = {0};
+ assert(std::fill_n(ia, UDI(n), static_cast<char>(1)) == std::next(ia, n));
+ assert(ia[0] == 1);
+ assert(ia[1] == 1);
+ assert(ia[2] == 1);
+ assert(ia[3] == 1);
+}
+
+struct source {
+ source() : i(0) { }
+
+ operator int() const { return i++; }
+ mutable int i;
+};
+
+void
+test_int_array_struct_source()
+{
+ const unsigned n = 4;
+ int ia[n] = {0};
+ assert(std::fill_n(ia, UDI(n), source()) == std::next(ia, n));
+ assert(ia[0] == 0);
+ assert(ia[1] == 1);
+ assert(ia[2] == 2);
+ assert(ia[3] == 3);
+}
+
+struct test1 {
+ test1() : c(0) { }
+ test1(char c) : c(c + 1) { }
+ char c;
+};
+
+void
+test_struct_array()
+{
+ const unsigned n = 4;
+ test1 test1a[n] = {0};
+ assert(std::fill_n(test1a, UDI(n), static_cast<char>(10)) == std::next(test1a, n));
+ assert(test1a[0].c == 11);
+ assert(test1a[1].c == 11);
+ assert(test1a[2].c == 11);
+ assert(test1a[3].c == 11);
+}
+
+class A
+{
+ char a_;
+public:
+ A() {}
+ explicit A(char a) : a_(a) {}
+ operator unsigned char() const {return 'b';}
+
+ friend bool operator==(const A& x, const A& y)
+ {return x.a_ == y.a_;}
+};
+
+void
+test5()
+{
+ A a[3];
+ assert(std::fill_n(&a[0], UDI(3), A('a')) == a+3);
+ assert(a[0] == A('a'));
+ assert(a[1] == A('a'));
+ assert(a[2] == A('a'));
+}
+
+struct Storage
+{
+ union
+ {
+ unsigned char a;
+ unsigned char b;
+ };
+};
+
+void test6()
+{
+ Storage foo[5];
+ std::fill_n(&foo[0], UDI(5), Storage());
+}
+
+
+int main()
+{
+ test_char<forward_iterator<char*> >();
+ test_char<bidirectional_iterator<char*> >();
+ test_char<random_access_iterator<char*> >();
+ test_char<char*>();
+
+ test_int<forward_iterator<int*> >();
+ test_int<bidirectional_iterator<int*> >();
+ test_int<random_access_iterator<int*> >();
+ test_int<int*>();
+
+ test_int_array();
+ test_int_array_struct_source();
+ test_struct_array();
+
+ test5();
+ test6();
+}
diff --git a/test/std/algorithms/alg.modifying.operations/alg.generate/generate.pass.cpp b/test/std/algorithms/alg.modifying.operations/alg.generate/generate.pass.cpp
new file mode 100644
index 000000000000..f166d67ba2f7
--- /dev/null
+++ b/test/std/algorithms/alg.modifying.operations/alg.generate/generate.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter, Callable Generator>
+// requires OutputIterator<Iter, Generator::result_type>
+// && CopyConstructible<Generator>
+// void
+// generate(Iter first, Iter last, Generator gen);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+struct gen_test
+{
+ int operator()() const {return 1;}
+};
+
+template <class Iter>
+void
+test()
+{
+ const unsigned n = 4;
+ int ia[n] = {0};
+ std::generate(Iter(ia), Iter(ia+n), gen_test());
+ assert(ia[0] == 1);
+ assert(ia[1] == 1);
+ assert(ia[2] == 1);
+ assert(ia[3] == 1);
+}
+
+int main()
+{
+ test<forward_iterator<int*> >();
+ test<bidirectional_iterator<int*> >();
+ test<random_access_iterator<int*> >();
+ test<int*>();
+}
diff --git a/test/std/algorithms/alg.modifying.operations/alg.generate/generate_n.pass.cpp b/test/std/algorithms/alg.modifying.operations/alg.generate/generate_n.pass.cpp
new file mode 100644
index 000000000000..a9ccaf4cd959
--- /dev/null
+++ b/test/std/algorithms/alg.modifying.operations/alg.generate/generate_n.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<class Iter, IntegralLike Size, Callable Generator>
+// requires OutputIterator<Iter, Generator::result_type>
+// && CopyConstructible<Generator>
+// void
+// generate_n(Iter first, Size n, Generator gen);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "user_defined_integral.hpp"
+
+typedef UserDefinedIntegral<unsigned> UDI;
+
+struct gen_test
+{
+ int operator()() const {return 2;}
+};
+
+template <class Iter>
+void
+test()
+{
+ const unsigned n = 4;
+ int ia[n] = {0};
+ assert(std::generate_n(Iter(ia), UDI(n), gen_test()) == Iter(ia+n));
+ assert(ia[0] == 2);
+ assert(ia[1] == 2);
+ assert(ia[2] == 2);
+ assert(ia[3] == 2);
+}
+
+int main()
+{
+ test<forward_iterator<int*> >();
+ test<bidirectional_iterator<int*> >();
+ test<random_access_iterator<int*> >();
+ test<int*>();
+}
diff --git a/test/std/algorithms/alg.modifying.operations/alg.move/move.pass.cpp b/test/std/algorithms/alg.modifying.operations/alg.move/move.pass.cpp
new file mode 100644
index 000000000000..43234be5d3b8
--- /dev/null
+++ b/test/std/algorithms/alg.modifying.operations/alg.move/move.pass.cpp
@@ -0,0 +1,134 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator InIter, typename OutIter>
+// requires OutputIterator<OutIter, RvalueOf<InIter::reference>::type>
+// OutIter
+// move(InIter first, InIter last, OutIter result);
+
+#include <algorithm>
+#include <cassert>
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#include <memory>
+#endif
+
+#include "test_iterators.h"
+
+template <class InIter, class OutIter>
+void
+test()
+{
+ const unsigned N = 1000;
+ int ia[N];
+ for (unsigned i = 0; i < N; ++i)
+ ia[i] = i;
+ int ib[N] = {0};
+
+ OutIter r = std::move(InIter(ia), InIter(ia+N), OutIter(ib));
+ assert(base(r) == ib+N);
+ for (unsigned i = 0; i < N; ++i)
+ assert(ia[i] == ib[i]);
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class InIter, class OutIter>
+void
+test1()
+{
+ const unsigned N = 100;
+ std::unique_ptr<int> ia[N];
+ for (unsigned i = 0; i < N; ++i)
+ ia[i].reset(new int(i));
+ std::unique_ptr<int> ib[N];
+
+ OutIter r = std::move(InIter(ia), InIter(ia+N), OutIter(ib));
+ assert(base(r) == ib+N);
+ for (unsigned i = 0; i < N; ++i)
+ assert(*ib[i] == i);
+}
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+ test<input_iterator<const int*>, output_iterator<int*> >();
+ test<input_iterator<const int*>, input_iterator<int*> >();
+ test<input_iterator<const int*>, forward_iterator<int*> >();
+ test<input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<input_iterator<const int*>, random_access_iterator<int*> >();
+ test<input_iterator<const int*>, int*>();
+
+ test<forward_iterator<const int*>, output_iterator<int*> >();
+ test<forward_iterator<const int*>, input_iterator<int*> >();
+ test<forward_iterator<const int*>, forward_iterator<int*> >();
+ test<forward_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<forward_iterator<const int*>, random_access_iterator<int*> >();
+ test<forward_iterator<const int*>, int*>();
+
+ test<bidirectional_iterator<const int*>, output_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, input_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, forward_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, int*>();
+
+ test<random_access_iterator<const int*>, output_iterator<int*> >();
+ test<random_access_iterator<const int*>, input_iterator<int*> >();
+ test<random_access_iterator<const int*>, forward_iterator<int*> >();
+ test<random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, random_access_iterator<int*> >();
+ test<random_access_iterator<const int*>, int*>();
+
+ test<const int*, output_iterator<int*> >();
+ test<const int*, input_iterator<int*> >();
+ test<const int*, forward_iterator<int*> >();
+ test<const int*, bidirectional_iterator<int*> >();
+ test<const int*, random_access_iterator<int*> >();
+ test<const int*, int*>();
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ test1<input_iterator<std::unique_ptr<int>*>, output_iterator<std::unique_ptr<int>*> >();
+ test1<input_iterator<std::unique_ptr<int>*>, input_iterator<std::unique_ptr<int>*> >();
+ test1<input_iterator<std::unique_ptr<int>*>, forward_iterator<std::unique_ptr<int>*> >();
+ test1<input_iterator<std::unique_ptr<int>*>, bidirectional_iterator<std::unique_ptr<int>*> >();
+ test1<input_iterator<std::unique_ptr<int>*>, random_access_iterator<std::unique_ptr<int>*> >();
+ test1<input_iterator<std::unique_ptr<int>*>, std::unique_ptr<int>*>();
+
+ test1<forward_iterator<std::unique_ptr<int>*>, output_iterator<std::unique_ptr<int>*> >();
+ test1<forward_iterator<std::unique_ptr<int>*>, input_iterator<std::unique_ptr<int>*> >();
+ test1<forward_iterator<std::unique_ptr<int>*>, forward_iterator<std::unique_ptr<int>*> >();
+ test1<forward_iterator<std::unique_ptr<int>*>, bidirectional_iterator<std::unique_ptr<int>*> >();
+ test1<forward_iterator<std::unique_ptr<int>*>, random_access_iterator<std::unique_ptr<int>*> >();
+ test1<forward_iterator<std::unique_ptr<int>*>, std::unique_ptr<int>*>();
+
+ test1<bidirectional_iterator<std::unique_ptr<int>*>, output_iterator<std::unique_ptr<int>*> >();
+ test1<bidirectional_iterator<std::unique_ptr<int>*>, input_iterator<std::unique_ptr<int>*> >();
+ test1<bidirectional_iterator<std::unique_ptr<int>*>, forward_iterator<std::unique_ptr<int>*> >();
+ test1<bidirectional_iterator<std::unique_ptr<int>*>, bidirectional_iterator<std::unique_ptr<int>*> >();
+ test1<bidirectional_iterator<std::unique_ptr<int>*>, random_access_iterator<std::unique_ptr<int>*> >();
+ test1<bidirectional_iterator<std::unique_ptr<int>*>, std::unique_ptr<int>*>();
+
+ test1<random_access_iterator<std::unique_ptr<int>*>, output_iterator<std::unique_ptr<int>*> >();
+ test1<random_access_iterator<std::unique_ptr<int>*>, input_iterator<std::unique_ptr<int>*> >();
+ test1<random_access_iterator<std::unique_ptr<int>*>, forward_iterator<std::unique_ptr<int>*> >();
+ test1<random_access_iterator<std::unique_ptr<int>*>, bidirectional_iterator<std::unique_ptr<int>*> >();
+ test1<random_access_iterator<std::unique_ptr<int>*>, random_access_iterator<std::unique_ptr<int>*> >();
+ test1<random_access_iterator<std::unique_ptr<int>*>, std::unique_ptr<int>*>();
+
+ test1<std::unique_ptr<int>*, output_iterator<std::unique_ptr<int>*> >();
+ test1<std::unique_ptr<int>*, input_iterator<std::unique_ptr<int>*> >();
+ test1<std::unique_ptr<int>*, forward_iterator<std::unique_ptr<int>*> >();
+ test1<std::unique_ptr<int>*, bidirectional_iterator<std::unique_ptr<int>*> >();
+ test1<std::unique_ptr<int>*, random_access_iterator<std::unique_ptr<int>*> >();
+ test1<std::unique_ptr<int>*, std::unique_ptr<int>*>();
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/algorithms/alg.modifying.operations/alg.move/move_backward.pass.cpp b/test/std/algorithms/alg.modifying.operations/alg.move/move_backward.pass.cpp
new file mode 100644
index 000000000000..02b6b16eca0c
--- /dev/null
+++ b/test/std/algorithms/alg.modifying.operations/alg.move/move_backward.pass.cpp
@@ -0,0 +1,88 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<BidirectionalIterator InIter, BidirectionalIterator OutIter>
+// requires OutputIterator<OutIter, RvalueOf<InIter::reference>::type>
+// OutIter
+// move_backward(InIter first, InIter last, OutIter result);
+
+#include <algorithm>
+#include <cassert>
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#include <memory>
+#endif
+
+#include "test_iterators.h"
+
+template <class InIter, class OutIter>
+void
+test()
+{
+ const unsigned N = 1000;
+ int ia[N];
+ for (unsigned i = 0; i < N; ++i)
+ ia[i] = i;
+ int ib[N] = {0};
+
+ OutIter r = std::move_backward(InIter(ia), InIter(ia+N), OutIter(ib+N));
+ assert(base(r) == ib);
+ for (unsigned i = 0; i < N; ++i)
+ assert(ia[i] == ib[i]);
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class InIter, class OutIter>
+void
+test1()
+{
+ const unsigned N = 100;
+ std::unique_ptr<int> ia[N];
+ for (unsigned i = 0; i < N; ++i)
+ ia[i].reset(new int(i));
+ std::unique_ptr<int> ib[N];
+
+ OutIter r = std::move_backward(InIter(ia), InIter(ia+N), OutIter(ib+N));
+ assert(base(r) == ib);
+ for (unsigned i = 0; i < N; ++i)
+ assert(*ib[i] == i);
+}
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, int*>();
+
+ test<random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, random_access_iterator<int*> >();
+ test<random_access_iterator<const int*>, int*>();
+
+ test<const int*, bidirectional_iterator<int*> >();
+ test<const int*, random_access_iterator<int*> >();
+ test<const int*, int*>();
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ test1<bidirectional_iterator<std::unique_ptr<int>*>, bidirectional_iterator<std::unique_ptr<int>*> >();
+ test1<bidirectional_iterator<std::unique_ptr<int>*>, random_access_iterator<std::unique_ptr<int>*> >();
+ test1<bidirectional_iterator<std::unique_ptr<int>*>, std::unique_ptr<int>*>();
+
+ test1<random_access_iterator<std::unique_ptr<int>*>, bidirectional_iterator<std::unique_ptr<int>*> >();
+ test1<random_access_iterator<std::unique_ptr<int>*>, random_access_iterator<std::unique_ptr<int>*> >();
+ test1<random_access_iterator<std::unique_ptr<int>*>, std::unique_ptr<int>*>();
+
+ test1<std::unique_ptr<int>*, bidirectional_iterator<std::unique_ptr<int>*> >();
+ test1<std::unique_ptr<int>*, random_access_iterator<std::unique_ptr<int>*> >();
+ test1<std::unique_ptr<int>*, std::unique_ptr<int>*>();
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/algorithms/alg.modifying.operations/alg.partitions/is_partitioned.pass.cpp b/test/std/algorithms/alg.modifying.operations/alg.partitions/is_partitioned.pass.cpp
new file mode 100644
index 000000000000..aa23d19a8a3b
--- /dev/null
+++ b/test/std/algorithms/alg.modifying.operations/alg.partitions/is_partitioned.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template <class InputIterator, class Predicate>
+// bool
+// is_partitioned(InputIterator first, InputIterator last, Predicate pred);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "counting_predicates.hpp"
+
+struct is_odd
+{
+ bool operator()(const int& i) const {return i & 1;}
+};
+
+int main()
+{
+ {
+ const int ia[] = {1, 2, 3, 4, 5, 6};
+ unary_counting_predicate<is_odd, int> pred((is_odd()));
+ assert(!std::is_partitioned(input_iterator<const int*>(std::begin(ia)),
+ input_iterator<const int*>(std::end(ia)),
+ std::ref(pred)));
+ assert(pred.count() <= std::distance(std::begin(ia), std::end(ia)));
+ }
+ {
+ const int ia[] = {1, 3, 5, 2, 4, 6};
+ unary_counting_predicate<is_odd, int> pred((is_odd()));
+ assert( std::is_partitioned(input_iterator<const int*>(std::begin(ia)),
+ input_iterator<const int*>(std::end(ia)),
+ std::ref(pred)));
+ assert(pred.count() <= std::distance(std::begin(ia), std::end(ia)));
+ }
+ {
+ const int ia[] = {2, 4, 6, 1, 3, 5};
+ unary_counting_predicate<is_odd, int> pred((is_odd()));
+ assert(!std::is_partitioned(input_iterator<const int*>(std::begin(ia)),
+ input_iterator<const int*>(std::end(ia)),
+ std::ref(pred)));
+ assert(pred.count() <= std::distance(std::begin(ia), std::end(ia)));
+ }
+ {
+ const int ia[] = {1, 3, 5, 2, 4, 6, 7};
+ unary_counting_predicate<is_odd, int> pred((is_odd()));
+ assert(!std::is_partitioned(input_iterator<const int*>(std::begin(ia)),
+ input_iterator<const int*>(std::end(ia)),
+ std::ref(pred)));
+ assert(pred.count() <= std::distance(std::begin(ia), std::end(ia)));
+ }
+ {
+ const int ia[] = {1, 3, 5, 2, 4, 6, 7};
+ unary_counting_predicate<is_odd, int> pred((is_odd()));
+ assert( std::is_partitioned(input_iterator<const int*>(std::begin(ia)),
+ input_iterator<const int*>(std::begin(ia)),
+ std::ref(pred)));
+ assert(pred.count() <= std::distance(std::begin(ia), std::begin(ia)));
+ }
+ {
+ const int ia[] = {1, 3, 5, 7, 9, 11, 2};
+ unary_counting_predicate<is_odd, int> pred((is_odd()));
+ assert( std::is_partitioned(input_iterator<const int*>(std::begin(ia)),
+ input_iterator<const int*>(std::end(ia)),
+ std::ref(pred)));
+ assert(pred.count() <= std::distance(std::begin(ia), std::end(ia)));
+ }
+}
diff --git a/test/std/algorithms/alg.modifying.operations/alg.partitions/partition.pass.cpp b/test/std/algorithms/alg.modifying.operations/alg.partitions/partition.pass.cpp
new file mode 100644
index 000000000000..8eddfbc4d048
--- /dev/null
+++ b/test/std/algorithms/alg.modifying.operations/alg.partitions/partition.pass.cpp
@@ -0,0 +1,104 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<BidirectionalIterator Iter, Predicate<auto, Iter::value_type> Pred>
+// requires ShuffleIterator<Iter>
+// && CopyConstructible<Pred>
+// Iter
+// partition(Iter first, Iter last, Pred pred);
+
+#include <algorithm>
+#include <cassert>
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#include <memory>
+#endif
+
+#include "test_iterators.h"
+
+struct is_odd
+{
+ bool operator()(const int& i) const {return i & 1;}
+};
+
+template <class Iter>
+void
+test()
+{
+ // check mixed
+ int ia[] = {1, 2, 3, 4, 5, 6, 7, 8 ,9};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ Iter r = std::partition(Iter(ia), Iter(ia + sa), is_odd());
+ assert(base(r) == ia + 5);
+ for (int* i = ia; i < base(r); ++i)
+ assert(is_odd()(*i));
+ for (int* i = base(r); i < ia+sa; ++i)
+ assert(!is_odd()(*i));
+ // check empty
+ r = std::partition(Iter(ia), Iter(ia), is_odd());
+ assert(base(r) == ia);
+ // check all false
+ for (unsigned i = 0; i < sa; ++i)
+ ia[i] = 2*i;
+ r = std::partition(Iter(ia), Iter(ia+sa), is_odd());
+ assert(base(r) == ia);
+ // check all true
+ for (unsigned i = 0; i < sa; ++i)
+ ia[i] = 2*i+1;
+ r = std::partition(Iter(ia), Iter(ia+sa), is_odd());
+ assert(base(r) == ia+sa);
+ // check all true but last
+ for (unsigned i = 0; i < sa; ++i)
+ ia[i] = 2*i+1;
+ ia[sa-1] = 10;
+ r = std::partition(Iter(ia), Iter(ia+sa), is_odd());
+ assert(base(r) == ia+sa-1);
+ for (int* i = ia; i < base(r); ++i)
+ assert(is_odd()(*i));
+ for (int* i = base(r); i < ia+sa; ++i)
+ assert(!is_odd()(*i));
+ // check all true but first
+ for (unsigned i = 0; i < sa; ++i)
+ ia[i] = 2*i+1;
+ ia[0] = 10;
+ r = std::partition(Iter(ia), Iter(ia+sa), is_odd());
+ assert(base(r) == ia+sa-1);
+ for (int* i = ia; i < base(r); ++i)
+ assert(is_odd()(*i));
+ for (int* i = base(r); i < ia+sa; ++i)
+ assert(!is_odd()(*i));
+ // check all false but last
+ for (unsigned i = 0; i < sa; ++i)
+ ia[i] = 2*i;
+ ia[sa-1] = 11;
+ r = std::partition(Iter(ia), Iter(ia+sa), is_odd());
+ assert(base(r) == ia+1);
+ for (int* i = ia; i < base(r); ++i)
+ assert(is_odd()(*i));
+ for (int* i = base(r); i < ia+sa; ++i)
+ assert(!is_odd()(*i));
+ // check all false but first
+ for (unsigned i = 0; i < sa; ++i)
+ ia[i] = 2*i;
+ ia[0] = 11;
+ r = std::partition(Iter(ia), Iter(ia+sa), is_odd());
+ assert(base(r) == ia+1);
+ for (int* i = ia; i < base(r); ++i)
+ assert(is_odd()(*i));
+ for (int* i = base(r); i < ia+sa; ++i)
+ assert(!is_odd()(*i));
+}
+
+int main()
+{
+ test<bidirectional_iterator<int*> >();
+ test<random_access_iterator<int*> >();
+ test<int*>();
+}
diff --git a/test/std/algorithms/alg.modifying.operations/alg.partitions/partition_copy.pass.cpp b/test/std/algorithms/alg.modifying.operations/alg.partitions/partition_copy.pass.cpp
new file mode 100644
index 000000000000..67e1cccaf730
--- /dev/null
+++ b/test/std/algorithms/alg.modifying.operations/alg.partitions/partition_copy.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template <class InputIterator, class OutputIterator1,
+// class OutputIterator2, class Predicate>
+// pair<OutputIterator1, OutputIterator2>
+// partition_copy(InputIterator first, InputIterator last,
+// OutputIterator1 out_true, OutputIterator2 out_false,
+// Predicate pred);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+struct is_odd
+{
+ bool operator()(const int& i) const {return i & 1;}
+};
+
+int main()
+{
+ {
+ const int ia[] = {1, 2, 3, 4, 6, 8, 5, 7};
+ int r1[10] = {0};
+ int r2[10] = {0};
+ typedef std::pair<output_iterator<int*>, int*> P;
+ P p = std::partition_copy(input_iterator<const int*>(std::begin(ia)),
+ input_iterator<const int*>(std::end(ia)),
+ output_iterator<int*>(r1), r2, is_odd());
+ assert(p.first.base() == r1 + 4);
+ assert(r1[0] == 1);
+ assert(r1[1] == 3);
+ assert(r1[2] == 5);
+ assert(r1[3] == 7);
+ assert(p.second == r2 + 4);
+ assert(r2[0] == 2);
+ assert(r2[1] == 4);
+ assert(r2[2] == 6);
+ assert(r2[3] == 8);
+ }
+}
diff --git a/test/std/algorithms/alg.modifying.operations/alg.partitions/partition_point.pass.cpp b/test/std/algorithms/alg.modifying.operations/alg.partitions/partition_point.pass.cpp
new file mode 100644
index 000000000000..f5b832c66397
--- /dev/null
+++ b/test/std/algorithms/alg.modifying.operations/alg.partitions/partition_point.pass.cpp
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<class ForwardIterator, class Predicate>
+// ForwardIterator
+// partition_point(ForwardIterator first, ForwardIterator last, Predicate pred);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+struct is_odd
+{
+ bool operator()(const int& i) const {return i & 1;}
+};
+
+int main()
+{
+ {
+ const int ia[] = {2, 4, 6, 8, 10};
+ assert(std::partition_point(forward_iterator<const int*>(std::begin(ia)),
+ forward_iterator<const int*>(std::end(ia)),
+ is_odd()) == forward_iterator<const int*>(ia));
+ }
+ {
+ const int ia[] = {1, 2, 4, 6, 8};
+ assert(std::partition_point(forward_iterator<const int*>(std::begin(ia)),
+ forward_iterator<const int*>(std::end(ia)),
+ is_odd()) == forward_iterator<const int*>(ia + 1));
+ }
+ {
+ const int ia[] = {1, 3, 2, 4, 6};
+ assert(std::partition_point(forward_iterator<const int*>(std::begin(ia)),
+ forward_iterator<const int*>(std::end(ia)),
+ is_odd()) == forward_iterator<const int*>(ia + 2));
+ }
+ {
+ const int ia[] = {1, 3, 5, 2, 4, 6};
+ assert(std::partition_point(forward_iterator<const int*>(std::begin(ia)),
+ forward_iterator<const int*>(std::end(ia)),
+ is_odd()) == forward_iterator<const int*>(ia + 3));
+ }
+ {
+ const int ia[] = {1, 3, 5, 7, 2, 4};
+ assert(std::partition_point(forward_iterator<const int*>(std::begin(ia)),
+ forward_iterator<const int*>(std::end(ia)),
+ is_odd()) == forward_iterator<const int*>(ia + 4));
+ }
+ {
+ const int ia[] = {1, 3, 5, 7, 9, 2};
+ assert(std::partition_point(forward_iterator<const int*>(std::begin(ia)),
+ forward_iterator<const int*>(std::end(ia)),
+ is_odd()) == forward_iterator<const int*>(ia + 5));
+ }
+ {
+ const int ia[] = {1, 3, 5, 7, 9, 11};
+ assert(std::partition_point(forward_iterator<const int*>(std::begin(ia)),
+ forward_iterator<const int*>(std::end(ia)),
+ is_odd()) == forward_iterator<const int*>(ia + 6));
+ }
+ {
+ const int ia[] = {1, 3, 5, 2, 4, 6, 7};
+ assert(std::partition_point(forward_iterator<const int*>(std::begin(ia)),
+ forward_iterator<const int*>(std::begin(ia)),
+ is_odd()) == forward_iterator<const int*>(ia));
+ }
+}
diff --git a/test/std/algorithms/alg.modifying.operations/alg.partitions/stable_partition.pass.cpp b/test/std/algorithms/alg.modifying.operations/alg.partitions/stable_partition.pass.cpp
new file mode 100644
index 000000000000..7810dec2fe1b
--- /dev/null
+++ b/test/std/algorithms/alg.modifying.operations/alg.partitions/stable_partition.pass.cpp
@@ -0,0 +1,314 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<BidirectionalIterator Iter, Predicate<auto, Iter::value_type> Pred>
+// requires ShuffleIterator<Iter>
+// && CopyConstructible<Pred>
+// Iter
+// stable_partition(Iter first, Iter last, Pred pred);
+
+#include <algorithm>
+#include <cassert>
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#include <memory>
+#endif
+
+#include "test_iterators.h"
+
+struct is_odd
+{
+ bool operator()(const int& i) const {return i & 1;}
+};
+
+struct odd_first
+{
+ bool operator()(const std::pair<int,int>& p) const
+ {return p.first & 1;}
+};
+
+template <class Iter>
+void
+test()
+{
+ { // check mixed
+ typedef std::pair<int,int> P;
+ P array[] =
+ {
+ P(0, 1),
+ P(0, 2),
+ P(1, 1),
+ P(1, 2),
+ P(2, 1),
+ P(2, 2),
+ P(3, 1),
+ P(3, 2),
+ P(4, 1),
+ P(4, 2)
+ };
+ const unsigned size = sizeof(array)/sizeof(array[0]);
+ Iter r = std::stable_partition(Iter(array), Iter(array+size), odd_first());
+ assert(base(r) == array + 4);
+ assert(array[0] == P(1, 1));
+ assert(array[1] == P(1, 2));
+ assert(array[2] == P(3, 1));
+ assert(array[3] == P(3, 2));
+ assert(array[4] == P(0, 1));
+ assert(array[5] == P(0, 2));
+ assert(array[6] == P(2, 1));
+ assert(array[7] == P(2, 2));
+ assert(array[8] == P(4, 1));
+ assert(array[9] == P(4, 2));
+ }
+ {
+ typedef std::pair<int,int> P;
+ P array[] =
+ {
+ P(0, 1),
+ P(0, 2),
+ P(1, 1),
+ P(1, 2),
+ P(2, 1),
+ P(2, 2),
+ P(3, 1),
+ P(3, 2),
+ P(4, 1),
+ P(4, 2)
+ };
+ const unsigned size = sizeof(array)/sizeof(array[0]);
+ Iter r = std::stable_partition(Iter(array), Iter(array+size), odd_first());
+ assert(base(r) == array + 4);
+ assert(array[0] == P(1, 1));
+ assert(array[1] == P(1, 2));
+ assert(array[2] == P(3, 1));
+ assert(array[3] == P(3, 2));
+ assert(array[4] == P(0, 1));
+ assert(array[5] == P(0, 2));
+ assert(array[6] == P(2, 1));
+ assert(array[7] == P(2, 2));
+ assert(array[8] == P(4, 1));
+ assert(array[9] == P(4, 2));
+ // check empty
+ r = std::stable_partition(Iter(array), Iter(array), odd_first());
+ assert(base(r) == array);
+ // check one true
+ r = std::stable_partition(Iter(array), Iter(array+1), odd_first());
+ assert(base(r) == array+1);
+ assert(array[0] == P(1, 1));
+ // check one false
+ r = std::stable_partition(Iter(array+4), Iter(array+5), odd_first());
+ assert(base(r) == array+4);
+ assert(array[4] == P(0, 1));
+ }
+ { // check all false
+ typedef std::pair<int,int> P;
+ P array[] =
+ {
+ P(0, 1),
+ P(0, 2),
+ P(2, 1),
+ P(2, 2),
+ P(4, 1),
+ P(4, 2),
+ P(6, 1),
+ P(6, 2),
+ P(8, 1),
+ P(8, 2)
+ };
+ const unsigned size = sizeof(array)/sizeof(array[0]);
+ Iter r = std::stable_partition(Iter(array), Iter(array+size), odd_first());
+ assert(base(r) == array);
+ assert(array[0] == P(0, 1));
+ assert(array[1] == P(0, 2));
+ assert(array[2] == P(2, 1));
+ assert(array[3] == P(2, 2));
+ assert(array[4] == P(4, 1));
+ assert(array[5] == P(4, 2));
+ assert(array[6] == P(6, 1));
+ assert(array[7] == P(6, 2));
+ assert(array[8] == P(8, 1));
+ assert(array[9] == P(8, 2));
+ }
+ { // check all true
+ typedef std::pair<int,int> P;
+ P array[] =
+ {
+ P(1, 1),
+ P(1, 2),
+ P(3, 1),
+ P(3, 2),
+ P(5, 1),
+ P(5, 2),
+ P(7, 1),
+ P(7, 2),
+ P(9, 1),
+ P(9, 2)
+ };
+ const unsigned size = sizeof(array)/sizeof(array[0]);
+ Iter r = std::stable_partition(Iter(array), Iter(array+size), odd_first());
+ assert(base(r) == array + size);
+ assert(array[0] == P(1, 1));
+ assert(array[1] == P(1, 2));
+ assert(array[2] == P(3, 1));
+ assert(array[3] == P(3, 2));
+ assert(array[4] == P(5, 1));
+ assert(array[5] == P(5, 2));
+ assert(array[6] == P(7, 1));
+ assert(array[7] == P(7, 2));
+ assert(array[8] == P(9, 1));
+ assert(array[9] == P(9, 2));
+ }
+ { // check all false but first true
+ typedef std::pair<int,int> P;
+ P array[] =
+ {
+ P(1, 1),
+ P(0, 2),
+ P(2, 1),
+ P(2, 2),
+ P(4, 1),
+ P(4, 2),
+ P(6, 1),
+ P(6, 2),
+ P(8, 1),
+ P(8, 2)
+ };
+ const unsigned size = sizeof(array)/sizeof(array[0]);
+ Iter r = std::stable_partition(Iter(array), Iter(array+size), odd_first());
+ assert(base(r) == array + 1);
+ assert(array[0] == P(1, 1));
+ assert(array[1] == P(0, 2));
+ assert(array[2] == P(2, 1));
+ assert(array[3] == P(2, 2));
+ assert(array[4] == P(4, 1));
+ assert(array[5] == P(4, 2));
+ assert(array[6] == P(6, 1));
+ assert(array[7] == P(6, 2));
+ assert(array[8] == P(8, 1));
+ assert(array[9] == P(8, 2));
+ }
+ { // check all false but last true
+ typedef std::pair<int,int> P;
+ P array[] =
+ {
+ P(0, 1),
+ P(0, 2),
+ P(2, 1),
+ P(2, 2),
+ P(4, 1),
+ P(4, 2),
+ P(6, 1),
+ P(6, 2),
+ P(8, 1),
+ P(1, 2)
+ };
+ const unsigned size = sizeof(array)/sizeof(array[0]);
+ Iter r = std::stable_partition(Iter(array), Iter(array+size), odd_first());
+ assert(base(r) == array + 1);
+ assert(array[0] == P(1, 2));
+ assert(array[1] == P(0, 1));
+ assert(array[2] == P(0, 2));
+ assert(array[3] == P(2, 1));
+ assert(array[4] == P(2, 2));
+ assert(array[5] == P(4, 1));
+ assert(array[6] == P(4, 2));
+ assert(array[7] == P(6, 1));
+ assert(array[8] == P(6, 2));
+ assert(array[9] == P(8, 1));
+ }
+ { // check all true but first false
+ typedef std::pair<int,int> P;
+ P array[] =
+ {
+ P(0, 1),
+ P(1, 2),
+ P(3, 1),
+ P(3, 2),
+ P(5, 1),
+ P(5, 2),
+ P(7, 1),
+ P(7, 2),
+ P(9, 1),
+ P(9, 2)
+ };
+ const unsigned size = sizeof(array)/sizeof(array[0]);
+ Iter r = std::stable_partition(Iter(array), Iter(array+size), odd_first());
+ assert(base(r) == array + size-1);
+ assert(array[0] == P(1, 2));
+ assert(array[1] == P(3, 1));
+ assert(array[2] == P(3, 2));
+ assert(array[3] == P(5, 1));
+ assert(array[4] == P(5, 2));
+ assert(array[5] == P(7, 1));
+ assert(array[6] == P(7, 2));
+ assert(array[7] == P(9, 1));
+ assert(array[8] == P(9, 2));
+ assert(array[9] == P(0, 1));
+ }
+ { // check all true but last false
+ typedef std::pair<int,int> P;
+ P array[] =
+ {
+ P(1, 1),
+ P(1, 2),
+ P(3, 1),
+ P(3, 2),
+ P(5, 1),
+ P(5, 2),
+ P(7, 1),
+ P(7, 2),
+ P(9, 1),
+ P(0, 2)
+ };
+ const unsigned size = sizeof(array)/sizeof(array[0]);
+ Iter r = std::stable_partition(Iter(array), Iter(array+size), odd_first());
+ assert(base(r) == array + size-1);
+ assert(array[0] == P(1, 1));
+ assert(array[1] == P(1, 2));
+ assert(array[2] == P(3, 1));
+ assert(array[3] == P(3, 2));
+ assert(array[4] == P(5, 1));
+ assert(array[5] == P(5, 2));
+ assert(array[6] == P(7, 1));
+ assert(array[7] == P(7, 2));
+ assert(array[8] == P(9, 1));
+ assert(array[9] == P(0, 2));
+ }
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+struct is_null
+{
+ template <class P>
+ bool operator()(const P& p) {return p == 0;}
+};
+
+template <class Iter>
+void
+test1()
+{
+ const unsigned size = 5;
+ std::unique_ptr<int> array[size];
+ Iter r = std::stable_partition(Iter(array), Iter(array+size), is_null());
+}
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+ test<bidirectional_iterator<std::pair<int,int>*> >();
+ test<random_access_iterator<std::pair<int,int>*> >();
+ test<std::pair<int,int>*>();
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ test1<bidirectional_iterator<std::unique_ptr<int>*> >();
+#endif
+}
diff --git a/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp b/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp
new file mode 100644
index 000000000000..a14ccf9e5e6c
--- /dev/null
+++ b/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<RandomAccessIterator Iter>
+// requires ShuffleIterator<Iter>
+// void
+// random_shuffle(Iter first, Iter last);
+
+#include <algorithm>
+#include <cassert>
+
+int main()
+{
+ int ia[] = {1, 2, 3, 4};
+ int ia1[] = {1, 4, 3, 2};
+ int ia2[] = {4, 1, 2, 3};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ std::random_shuffle(ia, ia+sa);
+ assert(std::equal(ia, ia+sa, ia1));
+ std::random_shuffle(ia, ia+sa);
+ assert(std::equal(ia, ia+sa, ia2));
+}
diff --git a/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_rand.pass.cpp b/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_rand.pass.cpp
new file mode 100644
index 000000000000..b944c89e3519
--- /dev/null
+++ b/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_rand.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<RandomAccessIterator Iter, Callable<auto, Iter::difference_type> Rand>
+// requires ShuffleIterator<Iter>
+// && Convertible<Rand::result_type, Iter::difference_type>
+// void
+// random_shuffle(Iter first, Iter last, Rand&& rand);
+
+#include <algorithm>
+#include <cassert>
+
+struct gen
+{
+ int operator()(int n)
+ {
+ return n-1;
+ }
+};
+
+int main()
+{
+ int ia[] = {1, 2, 3, 4};
+ int ia1[] = {4, 1, 2, 3};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ gen r;
+ std::random_shuffle(ia, ia+sa, r);
+ assert(std::equal(ia, ia+sa, ia1));
+}
diff --git a/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_urng.pass.cpp b/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_urng.pass.cpp
new file mode 100644
index 000000000000..343ae90101ff
--- /dev/null
+++ b/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_urng.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<class RandomAccessIterator, class UniformRandomNumberGenerator>
+// void shuffle(RandomAccessIterator first, RandomAccessIterator last,
+// UniformRandomNumberGenerator& g);
+
+#include <algorithm>
+#include <random>
+#include <cassert>
+
+int main()
+{
+ int ia[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+ int ia1[] = {2, 7, 1, 4, 3, 6, 5, 10, 9, 8};
+ int ia2[] = {1, 8, 3, 4, 6, 9, 5, 7, 2, 10};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ std::minstd_rand g;
+ std::shuffle(ia, ia+sa, g);
+ assert(std::equal(ia, ia+sa, ia1));
+ std::shuffle(ia, ia+sa, g);
+ assert(std::equal(ia, ia+sa, ia2));
+}
diff --git a/test/std/algorithms/alg.modifying.operations/alg.remove/remove.pass.cpp b/test/std/algorithms/alg.modifying.operations/alg.remove/remove.pass.cpp
new file mode 100644
index 000000000000..80f86568c4d9
--- /dev/null
+++ b/test/std/algorithms/alg.modifying.operations/alg.remove/remove.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter, class T>
+// requires OutputIterator<Iter, RvalueOf<Iter::reference>::type>
+// && HasEqualTo<Iter::value_type, T>
+// Iter
+// remove(Iter first, Iter last, const T& value);
+
+#include <algorithm>
+#include <cassert>
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#include <memory>
+#endif
+
+#include "test_iterators.h"
+
+template <class Iter>
+void
+test()
+{
+ int ia[] = {0, 1, 2, 3, 4, 2, 3, 4, 2};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ Iter r = std::remove(Iter(ia), Iter(ia+sa), 2);
+ assert(base(r) == ia + sa-3);
+ assert(ia[0] == 0);
+ assert(ia[1] == 1);
+ assert(ia[2] == 3);
+ assert(ia[3] == 4);
+ assert(ia[4] == 3);
+ assert(ia[5] == 4);
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class Iter>
+void
+test1()
+{
+ const unsigned sa = 9;
+ std::unique_ptr<int> ia[sa];
+ ia[0].reset(new int(0));
+ ia[1].reset(new int(1));
+ ia[3].reset(new int(3));
+ ia[4].reset(new int(4));
+ ia[6].reset(new int(3));
+ ia[7].reset(new int(4));
+ Iter r = std::remove(Iter(ia), Iter(ia+sa), std::unique_ptr<int>());
+ assert(base(r) == ia + sa-3);
+ assert(*ia[0] == 0);
+ assert(*ia[1] == 1);
+ assert(*ia[2] == 3);
+ assert(*ia[3] == 4);
+ assert(*ia[4] == 3);
+ assert(*ia[5] == 4);
+}
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+ test<forward_iterator<int*> >();
+ test<bidirectional_iterator<int*> >();
+ test<random_access_iterator<int*> >();
+ test<int*>();
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+ test1<forward_iterator<std::unique_ptr<int>*> >();
+ test1<bidirectional_iterator<std::unique_ptr<int>*> >();
+ test1<random_access_iterator<std::unique_ptr<int>*> >();
+ test1<std::unique_ptr<int>*>();
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/algorithms/alg.modifying.operations/alg.remove/remove_copy.pass.cpp b/test/std/algorithms/alg.modifying.operations/alg.remove/remove_copy.pass.cpp
new file mode 100644
index 000000000000..bf5f79cf8359
--- /dev/null
+++ b/test/std/algorithms/alg.modifying.operations/alg.remove/remove_copy.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator InIter, OutputIterator<auto, InIter::reference> OutIter, class T>
+// requires HasEqualTo<InIter::value_type, T>
+// OutIter
+// remove_copy(InIter first, InIter last, OutIter result, const T& value);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class InIter, class OutIter>
+void
+test()
+{
+ int ia[] = {0, 1, 2, 3, 4, 2, 3, 4, 2};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ int ib[sa];
+ OutIter r = std::remove_copy(InIter(ia), InIter(ia+sa), OutIter(ib), 2);
+ assert(base(r) == ib + sa-3);
+ assert(ib[0] == 0);
+ assert(ib[1] == 1);
+ assert(ib[2] == 3);
+ assert(ib[3] == 4);
+ assert(ib[4] == 3);
+ assert(ib[5] == 4);
+}
+
+int main()
+{
+ test<input_iterator<const int*>, output_iterator<int*> >();
+ test<input_iterator<const int*>, forward_iterator<int*> >();
+ test<input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<input_iterator<const int*>, random_access_iterator<int*> >();
+ test<input_iterator<const int*>, int*>();
+
+ test<forward_iterator<const int*>, output_iterator<int*> >();
+ test<forward_iterator<const int*>, forward_iterator<int*> >();
+ test<forward_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<forward_iterator<const int*>, random_access_iterator<int*> >();
+ test<forward_iterator<const int*>, int*>();
+
+ test<bidirectional_iterator<const int*>, output_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, forward_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, int*>();
+
+ test<random_access_iterator<const int*>, output_iterator<int*> >();
+ test<random_access_iterator<const int*>, forward_iterator<int*> >();
+ test<random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, random_access_iterator<int*> >();
+ test<random_access_iterator<const int*>, int*>();
+
+ test<const int*, output_iterator<int*> >();
+ test<const int*, forward_iterator<int*> >();
+ test<const int*, bidirectional_iterator<int*> >();
+ test<const int*, random_access_iterator<int*> >();
+ test<const int*, int*>();
+}
diff --git a/test/std/algorithms/alg.modifying.operations/alg.remove/remove_copy_if.pass.cpp b/test/std/algorithms/alg.modifying.operations/alg.remove/remove_copy_if.pass.cpp
new file mode 100644
index 000000000000..de3f0a741045
--- /dev/null
+++ b/test/std/algorithms/alg.modifying.operations/alg.remove/remove_copy_if.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator InIter, OutputIterator<auto, InIter::reference> OutIter,
+// Predicate<auto, InIter::value_type> Pred>
+// requires CopyConstructible<Pred>
+// OutIter
+// remove_copy_if(InIter first, InIter last, OutIter result, Pred pred);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class InIter, class OutIter>
+void
+test()
+{
+ int ia[] = {0, 1, 2, 3, 4, 2, 3, 4, 2};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ int ib[sa];
+ OutIter r = std::remove_copy_if(InIter(ia), InIter(ia+sa), OutIter(ib),
+ std::bind2nd(std::equal_to<int>(), 2));
+ assert(base(r) == ib + sa-3);
+ assert(ib[0] == 0);
+ assert(ib[1] == 1);
+ assert(ib[2] == 3);
+ assert(ib[3] == 4);
+ assert(ib[4] == 3);
+ assert(ib[5] == 4);
+}
+
+int main()
+{
+ test<input_iterator<const int*>, output_iterator<int*> >();
+ test<input_iterator<const int*>, forward_iterator<int*> >();
+ test<input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<input_iterator<const int*>, random_access_iterator<int*> >();
+ test<input_iterator<const int*>, int*>();
+
+ test<forward_iterator<const int*>, output_iterator<int*> >();
+ test<forward_iterator<const int*>, forward_iterator<int*> >();
+ test<forward_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<forward_iterator<const int*>, random_access_iterator<int*> >();
+ test<forward_iterator<const int*>, int*>();
+
+ test<bidirectional_iterator<const int*>, output_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, forward_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, int*>();
+
+ test<random_access_iterator<const int*>, output_iterator<int*> >();
+ test<random_access_iterator<const int*>, forward_iterator<int*> >();
+ test<random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, random_access_iterator<int*> >();
+ test<random_access_iterator<const int*>, int*>();
+
+ test<const int*, output_iterator<int*> >();
+ test<const int*, forward_iterator<int*> >();
+ test<const int*, bidirectional_iterator<int*> >();
+ test<const int*, random_access_iterator<int*> >();
+ test<const int*, int*>();
+}
diff --git a/test/std/algorithms/alg.modifying.operations/alg.remove/remove_if.pass.cpp b/test/std/algorithms/alg.modifying.operations/alg.remove/remove_if.pass.cpp
new file mode 100644
index 000000000000..b234431295a4
--- /dev/null
+++ b/test/std/algorithms/alg.modifying.operations/alg.remove/remove_if.pass.cpp
@@ -0,0 +1,98 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter, Predicate<auto, Iter::value_type> Pred>
+// requires OutputIterator<Iter, RvalueOf<Iter::reference>::type>
+// && CopyConstructible<Pred>
+// Iter
+// remove_if(Iter first, Iter last, Pred pred);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#include <memory>
+#endif
+
+#include "test_iterators.h"
+#include "counting_predicates.hpp"
+
+bool equal2 ( int i ) { return i == 2; }
+
+template <class Iter>
+void
+test()
+{
+ int ia[] = {0, 1, 2, 3, 4, 2, 3, 4, 2};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+// int* r = std::remove_if(ia, ia+sa, std::bind2nd(std::equal_to<int>(), 2));
+ unary_counting_predicate<bool(*)(int), int> cp(equal2);
+ int* r = std::remove_if(ia, ia+sa, std::ref(cp));
+ assert(r == ia + sa-3);
+ assert(ia[0] == 0);
+ assert(ia[1] == 1);
+ assert(ia[2] == 3);
+ assert(ia[3] == 4);
+ assert(ia[4] == 3);
+ assert(ia[5] == 4);
+ assert(cp.count() == sa);
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+struct pred
+{
+ bool operator()(const std::unique_ptr<int>& i) {return *i == 2;}
+};
+
+template <class Iter>
+void
+test1()
+{
+ const unsigned sa = 9;
+ std::unique_ptr<int> ia[sa];
+ ia[0].reset(new int(0));
+ ia[1].reset(new int(1));
+ ia[2].reset(new int(2));
+ ia[3].reset(new int(3));
+ ia[4].reset(new int(4));
+ ia[5].reset(new int(2));
+ ia[6].reset(new int(3));
+ ia[7].reset(new int(4));
+ ia[8].reset(new int(2));
+ Iter r = std::remove_if(Iter(ia), Iter(ia+sa), pred());
+ assert(base(r) == ia + sa-3);
+ assert(*ia[0] == 0);
+ assert(*ia[1] == 1);
+ assert(*ia[2] == 3);
+ assert(*ia[3] == 4);
+ assert(*ia[4] == 3);
+ assert(*ia[5] == 4);
+}
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+ test<forward_iterator<int*> >();
+ test<bidirectional_iterator<int*> >();
+ test<random_access_iterator<int*> >();
+ test<int*>();
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+ test1<forward_iterator<std::unique_ptr<int>*> >();
+ test1<bidirectional_iterator<std::unique_ptr<int>*> >();
+ test1<random_access_iterator<std::unique_ptr<int>*> >();
+ test1<std::unique_ptr<int>*>();
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/algorithms/alg.modifying.operations/alg.replace/replace.pass.cpp b/test/std/algorithms/alg.modifying.operations/alg.replace/replace.pass.cpp
new file mode 100644
index 000000000000..f6033351ffca
--- /dev/null
+++ b/test/std/algorithms/alg.modifying.operations/alg.replace/replace.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter, class T>
+// requires OutputIterator<Iter, Iter::reference>
+// && OutputIterator<Iter, const T&>
+// && HasEqualTo<Iter::value_type, T>
+// void
+// replace(Iter first, Iter last, const T& old_value, const T& new_value);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter>
+void
+test()
+{
+ int ia[] = {0, 1, 2, 3, 4};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ std::replace(Iter(ia), Iter(ia+sa), 2, 5);
+ assert(ia[0] == 0);
+ assert(ia[1] == 1);
+ assert(ia[2] == 5);
+ assert(ia[3] == 3);
+ assert(ia[4] == 4);
+}
+
+int main()
+{
+ test<forward_iterator<int*> >();
+ test<bidirectional_iterator<int*> >();
+ test<random_access_iterator<int*> >();
+ test<int*>();
+}
diff --git a/test/std/algorithms/alg.modifying.operations/alg.replace/replace_copy.pass.cpp b/test/std/algorithms/alg.modifying.operations/alg.replace/replace_copy.pass.cpp
new file mode 100644
index 000000000000..3c4d0e50817b
--- /dev/null
+++ b/test/std/algorithms/alg.modifying.operations/alg.replace/replace_copy.pass.cpp
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator InIter, typename OutIter, class T>
+// requires OutputIterator<OutIter, InIter::reference>
+// && OutputIterator<OutIter, const T&>
+// && HasEqualTo<InIter::value_type, T>
+// OutIter
+// replace_copy(InIter first, InIter last, OutIter result, const T& old_value,
+// const T& new_value);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class InIter, class OutIter>
+void
+test()
+{
+ int ia[] = {0, 1, 2, 3, 4};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ int ib[sa] = {0};
+ OutIter r = std::replace_copy(InIter(ia), InIter(ia+sa), OutIter(ib), 2, 5);
+ assert(base(r) == ib + sa);
+ assert(ib[0] == 0);
+ assert(ib[1] == 1);
+ assert(ib[2] == 5);
+ assert(ib[3] == 3);
+ assert(ib[4] == 4);
+}
+
+int main()
+{
+ test<input_iterator<const int*>, output_iterator<int*> >();
+ test<input_iterator<const int*>, forward_iterator<int*> >();
+ test<input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<input_iterator<const int*>, random_access_iterator<int*> >();
+ test<input_iterator<const int*>, int*>();
+
+ test<forward_iterator<const int*>, output_iterator<int*> >();
+ test<forward_iterator<const int*>, forward_iterator<int*> >();
+ test<forward_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<forward_iterator<const int*>, random_access_iterator<int*> >();
+ test<forward_iterator<const int*>, int*>();
+
+ test<bidirectional_iterator<const int*>, output_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, forward_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, int*>();
+
+ test<random_access_iterator<const int*>, output_iterator<int*> >();
+ test<random_access_iterator<const int*>, forward_iterator<int*> >();
+ test<random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, random_access_iterator<int*> >();
+ test<random_access_iterator<const int*>, int*>();
+
+ test<const int*, output_iterator<int*> >();
+ test<const int*, forward_iterator<int*> >();
+ test<const int*, bidirectional_iterator<int*> >();
+ test<const int*, random_access_iterator<int*> >();
+ test<const int*, int*>();
+}
diff --git a/test/std/algorithms/alg.modifying.operations/alg.replace/replace_copy_if.pass.cpp b/test/std/algorithms/alg.modifying.operations/alg.replace/replace_copy_if.pass.cpp
new file mode 100644
index 000000000000..1eff3d39e20e
--- /dev/null
+++ b/test/std/algorithms/alg.modifying.operations/alg.replace/replace_copy_if.pass.cpp
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator InIter, typename OutIter,
+// Predicate<auto, InIter::value_type> Pred, class T>
+// requires OutputIterator<OutIter, InIter::reference>
+// && OutputIterator<OutIter, const T&>
+// && CopyConstructible<Pred>
+// OutIter
+// replace_copy_if(InIter first, InIter last, OutIter result, Pred pred, const T& new_value);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class InIter, class OutIter>
+void
+test()
+{
+ int ia[] = {0, 1, 2, 3, 4};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ int ib[sa] = {0};
+ OutIter r = std::replace_copy_if(InIter(ia), InIter(ia+sa), OutIter(ib),
+ std::bind2nd(std::equal_to<int>(), 2), 5);
+ assert(base(r) == ib + sa);
+ assert(ib[0] == 0);
+ assert(ib[1] == 1);
+ assert(ib[2] == 5);
+ assert(ib[3] == 3);
+ assert(ib[4] == 4);
+}
+
+int main()
+{
+ test<input_iterator<const int*>, output_iterator<int*> >();
+ test<input_iterator<const int*>, forward_iterator<int*> >();
+ test<input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<input_iterator<const int*>, random_access_iterator<int*> >();
+ test<input_iterator<const int*>, int*>();
+
+ test<forward_iterator<const int*>, output_iterator<int*> >();
+ test<forward_iterator<const int*>, forward_iterator<int*> >();
+ test<forward_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<forward_iterator<const int*>, random_access_iterator<int*> >();
+ test<forward_iterator<const int*>, int*>();
+
+ test<bidirectional_iterator<const int*>, output_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, forward_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, int*>();
+
+ test<random_access_iterator<const int*>, output_iterator<int*> >();
+ test<random_access_iterator<const int*>, forward_iterator<int*> >();
+ test<random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, random_access_iterator<int*> >();
+ test<random_access_iterator<const int*>, int*>();
+
+ test<const int*, output_iterator<int*> >();
+ test<const int*, forward_iterator<int*> >();
+ test<const int*, bidirectional_iterator<int*> >();
+ test<const int*, random_access_iterator<int*> >();
+ test<const int*, int*>();
+}
diff --git a/test/std/algorithms/alg.modifying.operations/alg.replace/replace_if.pass.cpp b/test/std/algorithms/alg.modifying.operations/alg.replace/replace_if.pass.cpp
new file mode 100644
index 000000000000..8d6ab04e14dd
--- /dev/null
+++ b/test/std/algorithms/alg.modifying.operations/alg.replace/replace_if.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter, Predicate<auto, Iter::value_type> Pred, class T>
+// requires OutputIterator<Iter, Iter::reference>
+// && OutputIterator<Iter, const T&>
+// && CopyConstructible<Pred>
+// void
+// replace_if(Iter first, Iter last, Pred pred, const T& new_value);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter>
+void
+test()
+{
+ int ia[] = {0, 1, 2, 3, 4};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ std::replace_if(Iter(ia), Iter(ia+sa), std::bind2nd(std::equal_to<int>(), 2), 5);
+ assert(ia[0] == 0);
+ assert(ia[1] == 1);
+ assert(ia[2] == 5);
+ assert(ia[3] == 3);
+ assert(ia[4] == 4);
+}
+
+int main()
+{
+ test<forward_iterator<int*> >();
+ test<bidirectional_iterator<int*> >();
+ test<random_access_iterator<int*> >();
+ test<int*>();
+}
diff --git a/test/std/algorithms/alg.modifying.operations/alg.reverse/reverse.pass.cpp b/test/std/algorithms/alg.modifying.operations/alg.reverse/reverse.pass.cpp
new file mode 100644
index 000000000000..6c49605b6616
--- /dev/null
+++ b/test/std/algorithms/alg.modifying.operations/alg.reverse/reverse.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<BidirectionalIterator Iter>
+// requires HasSwap<Iter::reference, Iter::reference>
+// void
+// reverse(Iter first, Iter last);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter>
+void
+test()
+{
+ int ia[] = {0};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ std::reverse(Iter(ia), Iter(ia));
+ assert(ia[0] == 0);
+ std::reverse(Iter(ia), Iter(ia+sa));
+ assert(ia[0] == 0);
+
+ int ib[] = {0, 1};
+ const unsigned sb = sizeof(ib)/sizeof(ib[0]);
+ std::reverse(Iter(ib), Iter(ib+sb));
+ assert(ib[0] == 1);
+ assert(ib[1] == 0);
+
+ int ic[] = {0, 1, 2};
+ const unsigned sc = sizeof(ic)/sizeof(ic[0]);
+ std::reverse(Iter(ic), Iter(ic+sc));
+ assert(ic[0] == 2);
+ assert(ic[1] == 1);
+ assert(ic[2] == 0);
+
+ int id[] = {0, 1, 2, 3};
+ const unsigned sd = sizeof(id)/sizeof(id[0]);
+ std::reverse(Iter(id), Iter(id+sd));
+ assert(id[0] == 3);
+ assert(id[1] == 2);
+ assert(id[2] == 1);
+ assert(id[3] == 0);
+}
+
+int main()
+{
+ test<bidirectional_iterator<int*> >();
+ test<random_access_iterator<int*> >();
+ test<int*>();
+}
diff --git a/test/std/algorithms/alg.modifying.operations/alg.reverse/reverse_copy.pass.cpp b/test/std/algorithms/alg.modifying.operations/alg.reverse/reverse_copy.pass.cpp
new file mode 100644
index 000000000000..70840d187bfb
--- /dev/null
+++ b/test/std/algorithms/alg.modifying.operations/alg.reverse/reverse_copy.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<BidirectionalIterator InIter, OutputIterator<auto, InIter::reference> OutIter>
+// OutIter
+// reverse_copy(InIter first, InIter last, OutIter result);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class InIter, class OutIter>
+void
+test()
+{
+ const int ia[] = {0};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ int ja[sa] = {-1};
+ OutIter r = std::reverse_copy(InIter(ia), InIter(ia), OutIter(ja));
+ assert(base(r) == ja);
+ assert(ja[0] == -1);
+ r = std::reverse_copy(InIter(ia), InIter(ia+sa), OutIter(ja));
+ assert(ja[0] == 0);
+
+ const int ib[] = {0, 1};
+ const unsigned sb = sizeof(ib)/sizeof(ib[0]);
+ int jb[sb] = {-1};
+ r = std::reverse_copy(InIter(ib), InIter(ib+sb), OutIter(jb));
+ assert(base(r) == jb+sb);
+ assert(jb[0] == 1);
+ assert(jb[1] == 0);
+
+ const int ic[] = {0, 1, 2};
+ const unsigned sc = sizeof(ic)/sizeof(ic[0]);
+ int jc[sc] = {-1};
+ r = std::reverse_copy(InIter(ic), InIter(ic+sc), OutIter(jc));
+ assert(base(r) == jc+sc);
+ assert(jc[0] == 2);
+ assert(jc[1] == 1);
+ assert(jc[2] == 0);
+
+ int id[] = {0, 1, 2, 3};
+ const unsigned sd = sizeof(id)/sizeof(id[0]);
+ int jd[sd] = {-1};
+ r = std::reverse_copy(InIter(id), InIter(id+sd), OutIter(jd));
+ assert(base(r) == jd+sd);
+ assert(jd[0] == 3);
+ assert(jd[1] == 2);
+ assert(jd[2] == 1);
+ assert(jd[3] == 0);
+}
+
+int main()
+{
+ test<bidirectional_iterator<const int*>, output_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, forward_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, int*>();
+
+ test<random_access_iterator<const int*>, output_iterator<int*> >();
+ test<random_access_iterator<const int*>, forward_iterator<int*> >();
+ test<random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, random_access_iterator<int*> >();
+ test<random_access_iterator<const int*>, int*>();
+
+ test<const int*, output_iterator<int*> >();
+ test<const int*, forward_iterator<int*> >();
+ test<const int*, bidirectional_iterator<int*> >();
+ test<const int*, random_access_iterator<int*> >();
+ test<const int*, int*>();
+}
diff --git a/test/std/algorithms/alg.modifying.operations/alg.rotate/rotate.pass.cpp b/test/std/algorithms/alg.modifying.operations/alg.rotate/rotate.pass.cpp
new file mode 100644
index 000000000000..b7da7354ca25
--- /dev/null
+++ b/test/std/algorithms/alg.modifying.operations/alg.rotate/rotate.pass.cpp
@@ -0,0 +1,439 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ShuffleIterator Iter>
+// Iter
+// rotate(Iter first, Iter middle, Iter last);
+
+#include <algorithm>
+#include <cassert>
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#include <memory>
+#endif
+
+#include "test_iterators.h"
+
+template <class Iter>
+void
+test()
+{
+ int ia[] = {0};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ Iter r = std::rotate(Iter(ia), Iter(ia), Iter(ia));
+ assert(base(r) == ia);
+ assert(ia[0] == 0);
+ r = std::rotate(Iter(ia), Iter(ia), Iter(ia+sa));
+ assert(base(r) == ia+sa);
+ assert(ia[0] == 0);
+ r = std::rotate(Iter(ia), Iter(ia+sa), Iter(ia+sa));
+ assert(base(r) == ia);
+ assert(ia[0] == 0);
+
+ int ib[] = {0, 1};
+ const unsigned sb = sizeof(ib)/sizeof(ib[0]);
+ r = std::rotate(Iter(ib), Iter(ib), Iter(ib+sb));
+ assert(base(r) == ib+sb);
+ assert(ib[0] == 0);
+ assert(ib[1] == 1);
+ r = std::rotate(Iter(ib), Iter(ib+1), Iter(ib+sb));
+ assert(base(r) == ib+1);
+ assert(ib[0] == 1);
+ assert(ib[1] == 0);
+ r = std::rotate(Iter(ib), Iter(ib+sb), Iter(ib+sb));
+ assert(base(r) == ib);
+ assert(ib[0] == 1);
+ assert(ib[1] == 0);
+
+ int ic[] = {0, 1, 2};
+ const unsigned sc = sizeof(ic)/sizeof(ic[0]);
+ r = std::rotate(Iter(ic), Iter(ic), Iter(ic+sc));
+ assert(base(r) == ic+sc);
+ assert(ic[0] == 0);
+ assert(ic[1] == 1);
+ assert(ic[2] == 2);
+ r = std::rotate(Iter(ic), Iter(ic+1), Iter(ic+sc));
+ assert(base(r) == ic+2);
+ assert(ic[0] == 1);
+ assert(ic[1] == 2);
+ assert(ic[2] == 0);
+ r = std::rotate(Iter(ic), Iter(ic+2), Iter(ic+sc));
+ assert(base(r) == ic+1);
+ assert(ic[0] == 0);
+ assert(ic[1] == 1);
+ assert(ic[2] == 2);
+ r = std::rotate(Iter(ic), Iter(ic+sc), Iter(ic+sc));
+ assert(base(r) == ic);
+ assert(ic[0] == 0);
+ assert(ic[1] == 1);
+ assert(ic[2] == 2);
+
+ int id[] = {0, 1, 2, 3};
+ const unsigned sd = sizeof(id)/sizeof(id[0]);
+ r = std::rotate(Iter(id), Iter(id), Iter(id+sd));
+ assert(base(r) == id+sd);
+ assert(id[0] == 0);
+ assert(id[1] == 1);
+ assert(id[2] == 2);
+ assert(id[3] == 3);
+ r = std::rotate(Iter(id), Iter(id+1), Iter(id+sd));
+ assert(base(r) == id+3);
+ assert(id[0] == 1);
+ assert(id[1] == 2);
+ assert(id[2] == 3);
+ assert(id[3] == 0);
+ r = std::rotate(Iter(id), Iter(id+2), Iter(id+sd));
+ assert(base(r) == id+2);
+ assert(id[0] == 3);
+ assert(id[1] == 0);
+ assert(id[2] == 1);
+ assert(id[3] == 2);
+ r = std::rotate(Iter(id), Iter(id+3), Iter(id+sd));
+ assert(base(r) == id+1);
+ assert(id[0] == 2);
+ assert(id[1] == 3);
+ assert(id[2] == 0);
+ assert(id[3] == 1);
+ r = std::rotate(Iter(id), Iter(id+sd), Iter(id+sd));
+ assert(base(r) == id);
+ assert(id[0] == 2);
+ assert(id[1] == 3);
+ assert(id[2] == 0);
+ assert(id[3] == 1);
+
+ int ie[] = {0, 1, 2, 3, 4};
+ const unsigned se = sizeof(ie)/sizeof(ie[0]);
+ r = std::rotate(Iter(ie), Iter(ie), Iter(ie+se));
+ assert(base(r) == ie+se);
+ assert(ie[0] == 0);
+ assert(ie[1] == 1);
+ assert(ie[2] == 2);
+ assert(ie[3] == 3);
+ assert(ie[4] == 4);
+ r = std::rotate(Iter(ie), Iter(ie+1), Iter(ie+se));
+ assert(base(r) == ie+4);
+ assert(ie[0] == 1);
+ assert(ie[1] == 2);
+ assert(ie[2] == 3);
+ assert(ie[3] == 4);
+ assert(ie[4] == 0);
+ r = std::rotate(Iter(ie), Iter(ie+2), Iter(ie+se));
+ assert(base(r) == ie+3);
+ assert(ie[0] == 3);
+ assert(ie[1] == 4);
+ assert(ie[2] == 0);
+ assert(ie[3] == 1);
+ assert(ie[4] == 2);
+ r = std::rotate(Iter(ie), Iter(ie+3), Iter(ie+se));
+ assert(base(r) == ie+2);
+ assert(ie[0] == 1);
+ assert(ie[1] == 2);
+ assert(ie[2] == 3);
+ assert(ie[3] == 4);
+ assert(ie[4] == 0);
+ r = std::rotate(Iter(ie), Iter(ie+4), Iter(ie+se));
+ assert(base(r) == ie+1);
+ assert(ie[0] == 0);
+ assert(ie[1] == 1);
+ assert(ie[2] == 2);
+ assert(ie[3] == 3);
+ assert(ie[4] == 4);
+ r = std::rotate(Iter(ie), Iter(ie+se), Iter(ie+se));
+ assert(base(r) == ie);
+ assert(ie[0] == 0);
+ assert(ie[1] == 1);
+ assert(ie[2] == 2);
+ assert(ie[3] == 3);
+ assert(ie[4] == 4);
+
+ int ig[] = {0, 1, 2, 3, 4, 5};
+ const unsigned sg = sizeof(ig)/sizeof(ig[0]);
+ r = std::rotate(Iter(ig), Iter(ig), Iter(ig+sg));
+ assert(base(r) == ig+sg);
+ assert(ig[0] == 0);
+ assert(ig[1] == 1);
+ assert(ig[2] == 2);
+ assert(ig[3] == 3);
+ assert(ig[4] == 4);
+ assert(ig[5] == 5);
+ r = std::rotate(Iter(ig), Iter(ig+1), Iter(ig+sg));
+ assert(base(r) == ig+5);
+ assert(ig[0] == 1);
+ assert(ig[1] == 2);
+ assert(ig[2] == 3);
+ assert(ig[3] == 4);
+ assert(ig[4] == 5);
+ assert(ig[5] == 0);
+ r = std::rotate(Iter(ig), Iter(ig+2), Iter(ig+sg));
+ assert(base(r) == ig+4);
+ assert(ig[0] == 3);
+ assert(ig[1] == 4);
+ assert(ig[2] == 5);
+ assert(ig[3] == 0);
+ assert(ig[4] == 1);
+ assert(ig[5] == 2);
+ r = std::rotate(Iter(ig), Iter(ig+3), Iter(ig+sg));
+ assert(base(r) == ig+3);
+ assert(ig[0] == 0);
+ assert(ig[1] == 1);
+ assert(ig[2] == 2);
+ assert(ig[3] == 3);
+ assert(ig[4] == 4);
+ assert(ig[5] == 5);
+ r = std::rotate(Iter(ig), Iter(ig+4), Iter(ig+sg));
+ assert(base(r) == ig+2);
+ assert(ig[0] == 4);
+ assert(ig[1] == 5);
+ assert(ig[2] == 0);
+ assert(ig[3] == 1);
+ assert(ig[4] == 2);
+ assert(ig[5] == 3);
+ r = std::rotate(Iter(ig), Iter(ig+5), Iter(ig+sg));
+ assert(base(r) == ig+1);
+ assert(ig[0] == 3);
+ assert(ig[1] == 4);
+ assert(ig[2] == 5);
+ assert(ig[3] == 0);
+ assert(ig[4] == 1);
+ assert(ig[5] == 2);
+ r = std::rotate(Iter(ig), Iter(ig+sg), Iter(ig+sg));
+ assert(base(r) == ig);
+ assert(ig[0] == 3);
+ assert(ig[1] == 4);
+ assert(ig[2] == 5);
+ assert(ig[3] == 0);
+ assert(ig[4] == 1);
+ assert(ig[5] == 2);
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class Iter>
+void
+test1()
+{
+ std::unique_ptr<int> ia[1];
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ for (int i = 0; i < sa; ++i)
+ ia[i].reset(new int(i));
+ Iter r = std::rotate(Iter(ia), Iter(ia), Iter(ia));
+ assert(base(r) == ia);
+ assert(*ia[0] == 0);
+ r = std::rotate(Iter(ia), Iter(ia), Iter(ia+sa));
+ assert(base(r) == ia+sa);
+ assert(*ia[0] == 0);
+ r = std::rotate(Iter(ia), Iter(ia+sa), Iter(ia+sa));
+ assert(base(r) == ia);
+ assert(*ia[0] == 0);
+
+ std::unique_ptr<int> ib[2];
+ const unsigned sb = sizeof(ib)/sizeof(ib[0]);
+ for (int i = 0; i < sb; ++i)
+ ib[i].reset(new int(i));
+ r = std::rotate(Iter(ib), Iter(ib), Iter(ib+sb));
+ assert(base(r) == ib+sb);
+ assert(*ib[0] == 0);
+ assert(*ib[1] == 1);
+ r = std::rotate(Iter(ib), Iter(ib+1), Iter(ib+sb));
+ assert(base(r) == ib+1);
+ assert(*ib[0] == 1);
+ assert(*ib[1] == 0);
+ r = std::rotate(Iter(ib), Iter(ib+sb), Iter(ib+sb));
+ assert(base(r) == ib);
+ assert(*ib[0] == 1);
+ assert(*ib[1] == 0);
+
+ std::unique_ptr<int> ic[3];
+ const unsigned sc = sizeof(ic)/sizeof(ic[0]);
+ for (int i = 0; i < sc; ++i)
+ ic[i].reset(new int(i));
+ r = std::rotate(Iter(ic), Iter(ic), Iter(ic+sc));
+ assert(base(r) == ic+sc);
+ assert(*ic[0] == 0);
+ assert(*ic[1] == 1);
+ assert(*ic[2] == 2);
+ r = std::rotate(Iter(ic), Iter(ic+1), Iter(ic+sc));
+ assert(base(r) == ic+2);
+ assert(*ic[0] == 1);
+ assert(*ic[1] == 2);
+ assert(*ic[2] == 0);
+ r = std::rotate(Iter(ic), Iter(ic+2), Iter(ic+sc));
+ assert(base(r) == ic+1);
+ assert(*ic[0] == 0);
+ assert(*ic[1] == 1);
+ assert(*ic[2] == 2);
+ r = std::rotate(Iter(ic), Iter(ic+sc), Iter(ic+sc));
+ assert(base(r) == ic);
+ assert(*ic[0] == 0);
+ assert(*ic[1] == 1);
+ assert(*ic[2] == 2);
+
+ std::unique_ptr<int> id[4];
+ const unsigned sd = sizeof(id)/sizeof(id[0]);
+ for (int i = 0; i < sd; ++i)
+ id[i].reset(new int(i));
+ r = std::rotate(Iter(id), Iter(id), Iter(id+sd));
+ assert(base(r) == id+sd);
+ assert(*id[0] == 0);
+ assert(*id[1] == 1);
+ assert(*id[2] == 2);
+ assert(*id[3] == 3);
+ r = std::rotate(Iter(id), Iter(id+1), Iter(id+sd));
+ assert(base(r) == id+3);
+ assert(*id[0] == 1);
+ assert(*id[1] == 2);
+ assert(*id[2] == 3);
+ assert(*id[3] == 0);
+ r = std::rotate(Iter(id), Iter(id+2), Iter(id+sd));
+ assert(base(r) == id+2);
+ assert(*id[0] == 3);
+ assert(*id[1] == 0);
+ assert(*id[2] == 1);
+ assert(*id[3] == 2);
+ r = std::rotate(Iter(id), Iter(id+3), Iter(id+sd));
+ assert(base(r) == id+1);
+ assert(*id[0] == 2);
+ assert(*id[1] == 3);
+ assert(*id[2] == 0);
+ assert(*id[3] == 1);
+ r = std::rotate(Iter(id), Iter(id+sd), Iter(id+sd));
+ assert(base(r) == id);
+ assert(*id[0] == 2);
+ assert(*id[1] == 3);
+ assert(*id[2] == 0);
+ assert(*id[3] == 1);
+
+ std::unique_ptr<int> ie[5];
+ const unsigned se = sizeof(ie)/sizeof(ie[0]);
+ for (int i = 0; i < se; ++i)
+ ie[i].reset(new int(i));
+ r = std::rotate(Iter(ie), Iter(ie), Iter(ie+se));
+ assert(base(r) == ie+se);
+ assert(*ie[0] == 0);
+ assert(*ie[1] == 1);
+ assert(*ie[2] == 2);
+ assert(*ie[3] == 3);
+ assert(*ie[4] == 4);
+ r = std::rotate(Iter(ie), Iter(ie+1), Iter(ie+se));
+ assert(base(r) == ie+4);
+ assert(*ie[0] == 1);
+ assert(*ie[1] == 2);
+ assert(*ie[2] == 3);
+ assert(*ie[3] == 4);
+ assert(*ie[4] == 0);
+ r = std::rotate(Iter(ie), Iter(ie+2), Iter(ie+se));
+ assert(base(r) == ie+3);
+ assert(*ie[0] == 3);
+ assert(*ie[1] == 4);
+ assert(*ie[2] == 0);
+ assert(*ie[3] == 1);
+ assert(*ie[4] == 2);
+ r = std::rotate(Iter(ie), Iter(ie+3), Iter(ie+se));
+ assert(base(r) == ie+2);
+ assert(*ie[0] == 1);
+ assert(*ie[1] == 2);
+ assert(*ie[2] == 3);
+ assert(*ie[3] == 4);
+ assert(*ie[4] == 0);
+ r = std::rotate(Iter(ie), Iter(ie+4), Iter(ie+se));
+ assert(base(r) == ie+1);
+ assert(*ie[0] == 0);
+ assert(*ie[1] == 1);
+ assert(*ie[2] == 2);
+ assert(*ie[3] == 3);
+ assert(*ie[4] == 4);
+ r = std::rotate(Iter(ie), Iter(ie+se), Iter(ie+se));
+ assert(base(r) == ie);
+ assert(*ie[0] == 0);
+ assert(*ie[1] == 1);
+ assert(*ie[2] == 2);
+ assert(*ie[3] == 3);
+ assert(*ie[4] == 4);
+
+ std::unique_ptr<int> ig[6];
+ const unsigned sg = sizeof(ig)/sizeof(ig[0]);
+ for (int i = 0; i < sg; ++i)
+ ig[i].reset(new int(i));
+ r = std::rotate(Iter(ig), Iter(ig), Iter(ig+sg));
+ assert(base(r) == ig+sg);
+ assert(*ig[0] == 0);
+ assert(*ig[1] == 1);
+ assert(*ig[2] == 2);
+ assert(*ig[3] == 3);
+ assert(*ig[4] == 4);
+ assert(*ig[5] == 5);
+ r = std::rotate(Iter(ig), Iter(ig+1), Iter(ig+sg));
+ assert(base(r) == ig+5);
+ assert(*ig[0] == 1);
+ assert(*ig[1] == 2);
+ assert(*ig[2] == 3);
+ assert(*ig[3] == 4);
+ assert(*ig[4] == 5);
+ assert(*ig[5] == 0);
+ r = std::rotate(Iter(ig), Iter(ig+2), Iter(ig+sg));
+ assert(base(r) == ig+4);
+ assert(*ig[0] == 3);
+ assert(*ig[1] == 4);
+ assert(*ig[2] == 5);
+ assert(*ig[3] == 0);
+ assert(*ig[4] == 1);
+ assert(*ig[5] == 2);
+ r = std::rotate(Iter(ig), Iter(ig+3), Iter(ig+sg));
+ assert(base(r) == ig+3);
+ assert(*ig[0] == 0);
+ assert(*ig[1] == 1);
+ assert(*ig[2] == 2);
+ assert(*ig[3] == 3);
+ assert(*ig[4] == 4);
+ assert(*ig[5] == 5);
+ r = std::rotate(Iter(ig), Iter(ig+4), Iter(ig+sg));
+ assert(base(r) == ig+2);
+ assert(*ig[0] == 4);
+ assert(*ig[1] == 5);
+ assert(*ig[2] == 0);
+ assert(*ig[3] == 1);
+ assert(*ig[4] == 2);
+ assert(*ig[5] == 3);
+ r = std::rotate(Iter(ig), Iter(ig+5), Iter(ig+sg));
+ assert(base(r) == ig+1);
+ assert(*ig[0] == 3);
+ assert(*ig[1] == 4);
+ assert(*ig[2] == 5);
+ assert(*ig[3] == 0);
+ assert(*ig[4] == 1);
+ assert(*ig[5] == 2);
+ r = std::rotate(Iter(ig), Iter(ig+sg), Iter(ig+sg));
+ assert(base(r) == ig);
+ assert(*ig[0] == 3);
+ assert(*ig[1] == 4);
+ assert(*ig[2] == 5);
+ assert(*ig[3] == 0);
+ assert(*ig[4] == 1);
+ assert(*ig[5] == 2);
+}
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+ test<forward_iterator<int*> >();
+ test<bidirectional_iterator<int*> >();
+ test<random_access_iterator<int*> >();
+ test<int*>();
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+ test1<forward_iterator<std::unique_ptr<int>*> >();
+ test1<bidirectional_iterator<std::unique_ptr<int>*> >();
+ test1<random_access_iterator<std::unique_ptr<int>*> >();
+ test1<std::unique_ptr<int>*>();
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/algorithms/alg.modifying.operations/alg.rotate/rotate_copy.pass.cpp b/test/std/algorithms/alg.modifying.operations/alg.rotate/rotate_copy.pass.cpp
new file mode 100644
index 000000000000..f2ad535a2f99
--- /dev/null
+++ b/test/std/algorithms/alg.modifying.operations/alg.rotate/rotate_copy.pass.cpp
@@ -0,0 +1,134 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator InIter, OutputIterator<auto, InIter::reference> OutIter>
+// OutIter
+// rotate_copy(InIter first, InIter middle, InIter last, OutIter result);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class InIter, class OutIter>
+void
+test()
+{
+ int ia[] = {0, 1, 2, 3};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ int ib[sa] = {0};
+
+ OutIter r = std::rotate_copy(InIter(ia), InIter(ia), InIter(ia), OutIter(ib));
+ assert(base(r) == ib);
+
+ r = std::rotate_copy(InIter(ia), InIter(ia), InIter(ia+1), OutIter(ib));
+ assert(base(r) == ib+1);
+ assert(ib[0] == 0);
+
+ r = std::rotate_copy(InIter(ia), InIter(ia+1), InIter(ia+1), OutIter(ib));
+ assert(base(r) == ib+1);
+ assert(ib[0] == 0);
+
+ r = std::rotate_copy(InIter(ia), InIter(ia), InIter(ia+2), OutIter(ib));
+ assert(base(r) == ib+2);
+ assert(ib[0] == 0);
+ assert(ib[1] == 1);
+
+ r = std::rotate_copy(InIter(ia), InIter(ia+1), InIter(ia+2), OutIter(ib));
+ assert(base(r) == ib+2);
+ assert(ib[0] == 1);
+ assert(ib[1] == 0);
+
+ r = std::rotate_copy(InIter(ia), InIter(ia+2), InIter(ia+2), OutIter(ib));
+ assert(base(r) == ib+2);
+ assert(ib[0] == 0);
+ assert(ib[1] == 1);
+
+ r = std::rotate_copy(InIter(ia), InIter(ia), InIter(ia+3), OutIter(ib));
+ assert(base(r) == ib+3);
+ assert(ib[0] == 0);
+ assert(ib[1] == 1);
+ assert(ib[2] == 2);
+
+ r = std::rotate_copy(InIter(ia), InIter(ia+1), InIter(ia+3), OutIter(ib));
+ assert(base(r) == ib+3);
+ assert(ib[0] == 1);
+ assert(ib[1] == 2);
+ assert(ib[2] == 0);
+
+ r = std::rotate_copy(InIter(ia), InIter(ia+2), InIter(ia+3), OutIter(ib));
+ assert(base(r) == ib+3);
+ assert(ib[0] == 2);
+ assert(ib[1] == 0);
+ assert(ib[2] == 1);
+
+ r = std::rotate_copy(InIter(ia), InIter(ia+3), InIter(ia+3), OutIter(ib));
+ assert(base(r) == ib+3);
+ assert(ib[0] == 0);
+ assert(ib[1] == 1);
+ assert(ib[2] == 2);
+
+ r = std::rotate_copy(InIter(ia), InIter(ia), InIter(ia+4), OutIter(ib));
+ assert(base(r) == ib+4);
+ assert(ib[0] == 0);
+ assert(ib[1] == 1);
+ assert(ib[2] == 2);
+ assert(ib[3] == 3);
+
+ r = std::rotate_copy(InIter(ia), InIter(ia+1), InIter(ia+4), OutIter(ib));
+ assert(base(r) == ib+4);
+ assert(ib[0] == 1);
+ assert(ib[1] == 2);
+ assert(ib[2] == 3);
+ assert(ib[3] == 0);
+
+ r = std::rotate_copy(InIter(ia), InIter(ia+2), InIter(ia+4), OutIter(ib));
+ assert(base(r) == ib+4);
+ assert(ib[0] == 2);
+ assert(ib[1] == 3);
+ assert(ib[2] == 0);
+ assert(ib[3] == 1);
+
+ r = std::rotate_copy(InIter(ia), InIter(ia+3), InIter(ia+4), OutIter(ib));
+ assert(base(r) == ib+4);
+ assert(ib[0] == 3);
+ assert(ib[1] == 0);
+ assert(ib[2] == 1);
+ assert(ib[3] == 2);
+
+ r = std::rotate_copy(InIter(ia), InIter(ia+4), InIter(ia+4), OutIter(ib));
+ assert(base(r) == ib+4);
+ assert(ib[0] == 0);
+ assert(ib[1] == 1);
+ assert(ib[2] == 2);
+ assert(ib[3] == 3);
+}
+
+int main()
+{
+ test<bidirectional_iterator<const int*>, output_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, forward_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, int*>();
+
+ test<random_access_iterator<const int*>, output_iterator<int*> >();
+ test<random_access_iterator<const int*>, forward_iterator<int*> >();
+ test<random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, random_access_iterator<int*> >();
+ test<random_access_iterator<const int*>, int*>();
+
+ test<const int*, output_iterator<int*> >();
+ test<const int*, forward_iterator<int*> >();
+ test<const int*, bidirectional_iterator<int*> >();
+ test<const int*, random_access_iterator<int*> >();
+ test<const int*, int*>();
+}
diff --git a/test/std/algorithms/alg.modifying.operations/alg.swap/iter_swap.pass.cpp b/test/std/algorithms/alg.modifying.operations/alg.swap/iter_swap.pass.cpp
new file mode 100644
index 000000000000..d68efd994bb3
--- /dev/null
+++ b/test/std/algorithms/alg.modifying.operations/alg.swap/iter_swap.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<Iterator Iter1, Iterator Iter2>
+// requires HasSwap<Iter1::reference, Iter2::reference>
+// void
+// iter_swap(Iter1 a, Iter2 b);
+
+#include <algorithm>
+#include <cassert>
+
+int main()
+{
+ int i = 1;
+ int j = 2;
+ std::iter_swap(&i, &j);
+ assert(i == 2);
+ assert(j == 1);
+}
diff --git a/test/std/algorithms/alg.modifying.operations/alg.swap/swap_ranges.pass.cpp b/test/std/algorithms/alg.modifying.operations/alg.swap/swap_ranges.pass.cpp
new file mode 100644
index 000000000000..64a5a6a5a064
--- /dev/null
+++ b/test/std/algorithms/alg.modifying.operations/alg.swap/swap_ranges.pass.cpp
@@ -0,0 +1,159 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter1, ForwardIterator Iter2>
+// requires HasSwap<Iter1::reference, Iter2::reference>
+// Iter2
+// swap_ranges(Iter1 first1, Iter1 last1, Iter2 first2);
+
+#include <algorithm>
+#include <cassert>
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#include <memory>
+#endif
+
+#include "test_iterators.h"
+
+template<class Iter1, class Iter2>
+void
+test()
+{
+ int i[3] = {1, 2, 3};
+ int j[3] = {4, 5, 6};
+ Iter2 r = std::swap_ranges(Iter1(i), Iter1(i+3), Iter2(j));
+ assert(base(r) == j+3);
+ assert(i[0] == 4);
+ assert(i[1] == 5);
+ assert(i[2] == 6);
+ assert(j[0] == 1);
+ assert(j[1] == 2);
+ assert(j[2] == 3);
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template<class Iter1, class Iter2>
+void
+test1()
+{
+ std::unique_ptr<int> i[3];
+ for (int k = 0; k < 3; ++k)
+ i[k].reset(new int(k+1));
+ std::unique_ptr<int> j[3];
+ for (int k = 0; k < 3; ++k)
+ j[k].reset(new int(k+4));
+ Iter2 r = std::swap_ranges(Iter1(i), Iter1(i+3), Iter2(j));
+ assert(base(r) == j+3);
+ assert(*i[0] == 4);
+ assert(*i[1] == 5);
+ assert(*i[2] == 6);
+ assert(*j[0] == 1);
+ assert(*j[1] == 2);
+ assert(*j[2] == 3);
+}
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+void test2()
+{
+ {
+ int src[2][2] = {{0, 1}, {2, 3}};
+ decltype(src) dest = {{9, 8}, {7, 6}};
+
+ std::swap(src, dest);
+
+ assert ( src[0][0] == 9 );
+ assert ( src[0][1] == 8 );
+ assert ( src[1][0] == 7 );
+ assert ( src[1][1] == 6 );
+
+ assert ( dest[0][0] == 0 );
+ assert ( dest[0][1] == 1 );
+ assert ( dest[1][0] == 2 );
+ assert ( dest[1][1] == 3 );
+ }
+
+ {
+ int src[3][3] = {{0, 1, 2}, {3, 4, 5}, {6, 7, 8}};
+ decltype(src) dest = {{9, 8, 7}, {6, 5, 4}, {3, 2, 1}};
+
+ std::swap(src, dest);
+
+ assert ( src[0][0] == 9 );
+ assert ( src[0][1] == 8 );
+ assert ( src[0][2] == 7 );
+ assert ( src[1][0] == 6 );
+ assert ( src[1][1] == 5 );
+ assert ( src[1][2] == 4 );
+ assert ( src[2][0] == 3 );
+ assert ( src[2][1] == 2 );
+ assert ( src[2][2] == 1 );
+
+ assert ( dest[0][0] == 0 );
+ assert ( dest[0][1] == 1 );
+ assert ( dest[0][2] == 2 );
+ assert ( dest[1][0] == 3 );
+ assert ( dest[1][1] == 4 );
+ assert ( dest[1][2] == 5 );
+ assert ( dest[2][0] == 6 );
+ assert ( dest[2][1] == 7 );
+ assert ( dest[2][2] == 8 );
+ }
+}
+
+int main()
+{
+ test<forward_iterator<int*>, forward_iterator<int*> >();
+ test<forward_iterator<int*>, bidirectional_iterator<int*> >();
+ test<forward_iterator<int*>, random_access_iterator<int*> >();
+ test<forward_iterator<int*>, int*>();
+
+ test<bidirectional_iterator<int*>, forward_iterator<int*> >();
+ test<bidirectional_iterator<int*>, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<int*>, random_access_iterator<int*> >();
+ test<bidirectional_iterator<int*>, int*>();
+
+ test<random_access_iterator<int*>, forward_iterator<int*> >();
+ test<random_access_iterator<int*>, bidirectional_iterator<int*> >();
+ test<random_access_iterator<int*>, random_access_iterator<int*> >();
+ test<random_access_iterator<int*>, int*>();
+
+ test<int*, forward_iterator<int*> >();
+ test<int*, bidirectional_iterator<int*> >();
+ test<int*, random_access_iterator<int*> >();
+ test<int*, int*>();
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+ test1<forward_iterator<std::unique_ptr<int>*>, forward_iterator<std::unique_ptr<int>*> >();
+ test1<forward_iterator<std::unique_ptr<int>*>, bidirectional_iterator<std::unique_ptr<int>*> >();
+ test1<forward_iterator<std::unique_ptr<int>*>, random_access_iterator<std::unique_ptr<int>*> >();
+ test1<forward_iterator<std::unique_ptr<int>*>, std::unique_ptr<int>*>();
+
+ test1<bidirectional_iterator<std::unique_ptr<int>*>, forward_iterator<std::unique_ptr<int>*> >();
+ test1<bidirectional_iterator<std::unique_ptr<int>*>, bidirectional_iterator<std::unique_ptr<int>*> >();
+ test1<bidirectional_iterator<std::unique_ptr<int>*>, random_access_iterator<std::unique_ptr<int>*> >();
+ test1<bidirectional_iterator<std::unique_ptr<int>*>, std::unique_ptr<int>*>();
+
+ test1<random_access_iterator<std::unique_ptr<int>*>, forward_iterator<std::unique_ptr<int>*> >();
+ test1<random_access_iterator<std::unique_ptr<int>*>, bidirectional_iterator<std::unique_ptr<int>*> >();
+ test1<random_access_iterator<std::unique_ptr<int>*>, random_access_iterator<std::unique_ptr<int>*> >();
+ test1<random_access_iterator<std::unique_ptr<int>*>, std::unique_ptr<int>*>();
+
+ test1<std::unique_ptr<int>*, forward_iterator<std::unique_ptr<int>*> >();
+ test1<std::unique_ptr<int>*, bidirectional_iterator<std::unique_ptr<int>*> >();
+ test1<std::unique_ptr<int>*, random_access_iterator<std::unique_ptr<int>*> >();
+ test1<std::unique_ptr<int>*, std::unique_ptr<int>*>();
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+ test2();
+}
diff --git a/test/std/algorithms/alg.modifying.operations/alg.transform/binary_transform.pass.cpp b/test/std/algorithms/alg.modifying.operations/alg.transform/binary_transform.pass.cpp
new file mode 100644
index 000000000000..8491ea59eff6
--- /dev/null
+++ b/test/std/algorithms/alg.modifying.operations/alg.transform/binary_transform.pass.cpp
@@ -0,0 +1,217 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator InIter1, InputIterator InIter2, class OutIter,
+// Callable<auto, const InIter1::value_type&, const InIter2::value_type&> BinaryOp>
+// requires OutputIterator<OutIter, BinaryOp::result_type> && CopyConstructible<BinaryOp>
+// OutIter
+// transform(InIter1 first1, InIter1 last1, InIter2 first2, OutIter result, BinaryOp binary_op);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template<class InIter1, class InIter2, class OutIter>
+void
+test()
+{
+ int ia[] = {0, 1, 2, 3, 4};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ int ib[sa] = {1, 2, 3, 4, 5};
+ OutIter r = std::transform(InIter1(ib), InIter1(ib+sa), InIter2(ia),
+ OutIter(ib), std::minus<int>());
+ assert(base(r) == ib + sa);
+ assert(ib[0] == 1);
+ assert(ib[1] == 1);
+ assert(ib[2] == 1);
+ assert(ib[3] == 1);
+ assert(ib[4] == 1);
+}
+
+int main()
+{
+ test<input_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+ test<input_iterator<const int*>, input_iterator<const int*>, input_iterator<int*> >();
+ test<input_iterator<const int*>, input_iterator<const int*>, forward_iterator<int*> >();
+ test<input_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<input_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+ test<input_iterator<const int*>, input_iterator<const int*>, int*>();
+
+ test<input_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+ test<input_iterator<const int*>, forward_iterator<const int*>, input_iterator<int*> >();
+ test<input_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+ test<input_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<input_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+ test<input_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+ test<input_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+ test<input_iterator<const int*>, bidirectional_iterator<const int*>, input_iterator<int*> >();
+ test<input_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+ test<input_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<input_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+ test<input_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+ test<input_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+ test<input_iterator<const int*>, random_access_iterator<const int*>, input_iterator<int*> >();
+ test<input_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+ test<input_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<input_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+ test<input_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+ test<input_iterator<const int*>, const int*, output_iterator<int*> >();
+ test<input_iterator<const int*>, const int*, input_iterator<int*> >();
+ test<input_iterator<const int*>, const int*, forward_iterator<int*> >();
+ test<input_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+ test<input_iterator<const int*>, const int*, random_access_iterator<int*> >();
+ test<input_iterator<const int*>, const int*, int*>();
+
+ test<forward_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+ test<forward_iterator<const int*>, input_iterator<const int*>, input_iterator<int*> >();
+ test<forward_iterator<const int*>, input_iterator<const int*>, forward_iterator<int*> >();
+ test<forward_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<forward_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+ test<forward_iterator<const int*>, input_iterator<const int*>, int*>();
+
+ test<forward_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+ test<forward_iterator<const int*>, forward_iterator<const int*>, input_iterator<int*> >();
+ test<forward_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+ test<forward_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<forward_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+ test<forward_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+ test<forward_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+ test<forward_iterator<const int*>, bidirectional_iterator<const int*>, input_iterator<int*> >();
+ test<forward_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+ test<forward_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<forward_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+ test<forward_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+ test<forward_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+ test<forward_iterator<const int*>, random_access_iterator<const int*>, input_iterator<int*> >();
+ test<forward_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+ test<forward_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<forward_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+ test<forward_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+ test<forward_iterator<const int*>, const int*, output_iterator<int*> >();
+ test<forward_iterator<const int*>, const int*, input_iterator<int*> >();
+ test<forward_iterator<const int*>, const int*, forward_iterator<int*> >();
+ test<forward_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+ test<forward_iterator<const int*>, const int*, random_access_iterator<int*> >();
+ test<forward_iterator<const int*>, const int*, int*>();
+
+ test<bidirectional_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, input_iterator<const int*>, input_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, input_iterator<const int*>, forward_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, input_iterator<const int*>, int*>();
+
+ test<bidirectional_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, forward_iterator<const int*>, input_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, input_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+ test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, input_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+ test<bidirectional_iterator<const int*>, const int*, output_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, const int*, input_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, const int*, forward_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, const int*, random_access_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, const int*, int*>();
+
+ test<random_access_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+ test<random_access_iterator<const int*>, input_iterator<const int*>, input_iterator<int*> >();
+ test<random_access_iterator<const int*>, input_iterator<const int*>, forward_iterator<int*> >();
+ test<random_access_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+ test<random_access_iterator<const int*>, input_iterator<const int*>, int*>();
+
+ test<random_access_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+ test<random_access_iterator<const int*>, forward_iterator<const int*>, input_iterator<int*> >();
+ test<random_access_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+ test<random_access_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+ test<random_access_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+ test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+ test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, input_iterator<int*> >();
+ test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+ test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+ test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+ test<random_access_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+ test<random_access_iterator<const int*>, random_access_iterator<const int*>, input_iterator<int*> >();
+ test<random_access_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+ test<random_access_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+ test<random_access_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+ test<random_access_iterator<const int*>, const int*, output_iterator<int*> >();
+ test<random_access_iterator<const int*>, const int*, input_iterator<int*> >();
+ test<random_access_iterator<const int*>, const int*, forward_iterator<int*> >();
+ test<random_access_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, const int*, random_access_iterator<int*> >();
+ test<random_access_iterator<const int*>, const int*, int*>();
+
+ test<const int*, input_iterator<const int*>, output_iterator<int*> >();
+ test<const int*, input_iterator<const int*>, input_iterator<int*> >();
+ test<const int*, input_iterator<const int*>, forward_iterator<int*> >();
+ test<const int*, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<const int*, input_iterator<const int*>, random_access_iterator<int*> >();
+ test<const int*, input_iterator<const int*>, int*>();
+
+ test<const int*, forward_iterator<const int*>, output_iterator<int*> >();
+ test<const int*, forward_iterator<const int*>, input_iterator<int*> >();
+ test<const int*, forward_iterator<const int*>, forward_iterator<int*> >();
+ test<const int*, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<const int*, forward_iterator<const int*>, random_access_iterator<int*> >();
+ test<const int*, forward_iterator<const int*>, int*>();
+
+ test<const int*, bidirectional_iterator<const int*>, output_iterator<int*> >();
+ test<const int*, bidirectional_iterator<const int*>, input_iterator<int*> >();
+ test<const int*, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+ test<const int*, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<const int*, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+ test<const int*, bidirectional_iterator<const int*>, int*>();
+
+ test<const int*, random_access_iterator<const int*>, output_iterator<int*> >();
+ test<const int*, random_access_iterator<const int*>, input_iterator<int*> >();
+ test<const int*, random_access_iterator<const int*>, forward_iterator<int*> >();
+ test<const int*, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<const int*, random_access_iterator<const int*>, random_access_iterator<int*> >();
+ test<const int*, random_access_iterator<const int*>, int*>();
+
+ test<const int*, const int*, output_iterator<int*> >();
+ test<const int*, const int*, input_iterator<int*> >();
+ test<const int*, const int*, forward_iterator<int*> >();
+ test<const int*, const int*, bidirectional_iterator<int*> >();
+ test<const int*, const int*, random_access_iterator<int*> >();
+ test<const int*, const int*, int*>();
+}
diff --git a/test/std/algorithms/alg.modifying.operations/alg.transform/unary_transform.pass.cpp b/test/std/algorithms/alg.modifying.operations/alg.transform/unary_transform.pass.cpp
new file mode 100644
index 000000000000..68556fd98817
--- /dev/null
+++ b/test/std/algorithms/alg.modifying.operations/alg.transform/unary_transform.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator InIter, class OutIter,
+// Callable<auto, const InIter::value_type&> Op>
+// requires OutputIterator<OutIter, Op::result_type> && CopyConstructible<Op>
+// OutIter
+// transform(InIter first, InIter last, OutIter result, Op op);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class InIter, class OutIter>
+void
+test()
+{
+ int ia[] = {0, 1, 2, 3, 4};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ int ib[sa] = {0};
+ OutIter r = std::transform(InIter(ia), InIter(ia+sa), OutIter(ib),
+ std::bind2nd(std::plus<int>(), 1));
+ assert(base(r) == ib + sa);
+ assert(ib[0] == 1);
+ assert(ib[1] == 2);
+ assert(ib[2] == 3);
+ assert(ib[3] == 4);
+ assert(ib[4] == 5);
+}
+
+int main()
+{
+ test<input_iterator<const int*>, output_iterator<int*> >();
+ test<input_iterator<const int*>, input_iterator<int*> >();
+ test<input_iterator<const int*>, forward_iterator<int*> >();
+ test<input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<input_iterator<const int*>, random_access_iterator<int*> >();
+ test<input_iterator<const int*>, int*>();
+
+ test<forward_iterator<const int*>, output_iterator<int*> >();
+ test<forward_iterator<const int*>, input_iterator<int*> >();
+ test<forward_iterator<const int*>, forward_iterator<int*> >();
+ test<forward_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<forward_iterator<const int*>, random_access_iterator<int*> >();
+ test<forward_iterator<const int*>, int*>();
+
+ test<bidirectional_iterator<const int*>, output_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, input_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, forward_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, int*>();
+
+ test<random_access_iterator<const int*>, output_iterator<int*> >();
+ test<random_access_iterator<const int*>, input_iterator<int*> >();
+ test<random_access_iterator<const int*>, forward_iterator<int*> >();
+ test<random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, random_access_iterator<int*> >();
+ test<random_access_iterator<const int*>, int*>();
+
+ test<const int*, output_iterator<int*> >();
+ test<const int*, input_iterator<int*> >();
+ test<const int*, forward_iterator<int*> >();
+ test<const int*, bidirectional_iterator<int*> >();
+ test<const int*, random_access_iterator<int*> >();
+ test<const int*, int*>();
+}
diff --git a/test/std/algorithms/alg.modifying.operations/alg.unique/unique.pass.cpp b/test/std/algorithms/alg.modifying.operations/alg.unique/unique.pass.cpp
new file mode 100644
index 000000000000..ab4ffad60f9e
--- /dev/null
+++ b/test/std/algorithms/alg.modifying.operations/alg.unique/unique.pass.cpp
@@ -0,0 +1,189 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter>
+// requires OutputIterator<Iter, Iter::reference>
+// && EqualityComparable<Iter::value_type>
+// Iter
+// unique(Iter first, Iter last);
+
+#include <algorithm>
+#include <cassert>
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#include <memory>
+#endif
+
+#include "test_iterators.h"
+
+template <class Iter>
+void
+test()
+{
+ int ia[] = {0};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ Iter r = std::unique(Iter(ia), Iter(ia+sa));
+ assert(base(r) == ia + sa);
+ assert(ia[0] == 0);
+
+ int ib[] = {0, 1};
+ const unsigned sb = sizeof(ib)/sizeof(ib[0]);
+ r = std::unique(Iter(ib), Iter(ib+sb));
+ assert(base(r) == ib + sb);
+ assert(ib[0] == 0);
+ assert(ib[1] == 1);
+
+ int ic[] = {0, 0};
+ const unsigned sc = sizeof(ic)/sizeof(ic[0]);
+ r = std::unique(Iter(ic), Iter(ic+sc));
+ assert(base(r) == ic + 1);
+ assert(ic[0] == 0);
+
+ int id[] = {0, 0, 1};
+ const unsigned sd = sizeof(id)/sizeof(id[0]);
+ r = std::unique(Iter(id), Iter(id+sd));
+ assert(base(r) == id + 2);
+ assert(id[0] == 0);
+ assert(id[1] == 1);
+
+ int ie[] = {0, 0, 1, 0};
+ const unsigned se = sizeof(ie)/sizeof(ie[0]);
+ r = std::unique(Iter(ie), Iter(ie+se));
+ assert(base(r) == ie + 3);
+ assert(ie[0] == 0);
+ assert(ie[1] == 1);
+ assert(ie[2] == 0);
+
+ int ig[] = {0, 0, 1, 1};
+ const unsigned sg = sizeof(ig)/sizeof(ig[0]);
+ r = std::unique(Iter(ig), Iter(ig+sg));
+ assert(base(r) == ig + 2);
+ assert(ig[0] == 0);
+ assert(ig[1] == 1);
+
+ int ih[] = {0, 1, 1};
+ const unsigned sh = sizeof(ih)/sizeof(ih[0]);
+ r = std::unique(Iter(ih), Iter(ih+sh));
+ assert(base(r) == ih + 2);
+ assert(ih[0] == 0);
+ assert(ih[1] == 1);
+
+ int ii[] = {0, 1, 1, 1, 2, 2, 2};
+ const unsigned si = sizeof(ii)/sizeof(ii[0]);
+ r = std::unique(Iter(ii), Iter(ii+si));
+ assert(base(r) == ii + 3);
+ assert(ii[0] == 0);
+ assert(ii[1] == 1);
+ assert(ii[2] == 2);
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+struct do_nothing
+{
+ void operator()(void*) const {}
+};
+
+typedef std::unique_ptr<int, do_nothing> Ptr;
+
+template <class Iter>
+void
+test1()
+{
+ int one = 1;
+ int two = 2;
+ Ptr ia[1];
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ Iter r = std::unique(Iter(ia), Iter(ia+sa));
+ assert(base(r) == ia + sa);
+ assert(ia[0] == 0);
+
+ Ptr ib[2];
+ ib[1].reset(&one);
+ const unsigned sb = sizeof(ib)/sizeof(ib[0]);
+ r = std::unique(Iter(ib), Iter(ib+sb));
+ assert(base(r) == ib + sb);
+ assert(ib[0] == 0);
+ assert(*ib[1] == 1);
+
+ Ptr ic[2];
+ const unsigned sc = sizeof(ic)/sizeof(ic[0]);
+ r = std::unique(Iter(ic), Iter(ic+sc));
+ assert(base(r) == ic + 1);
+ assert(ic[0] == 0);
+
+ Ptr id[3];
+ id[2].reset(&one);
+ const unsigned sd = sizeof(id)/sizeof(id[0]);
+ r = std::unique(Iter(id), Iter(id+sd));
+ assert(base(r) == id + 2);
+ assert(id[0] == 0);
+ assert(*id[1] == 1);
+
+ Ptr ie[4];
+ ie[2].reset(&one);
+ const unsigned se = sizeof(ie)/sizeof(ie[0]);
+ r = std::unique(Iter(ie), Iter(ie+se));
+ assert(base(r) == ie + 3);
+ assert(ie[0] == 0);
+ assert(*ie[1] == 1);
+ assert(ie[2] == 0);
+
+ Ptr ig[4];
+ ig[2].reset(&one);
+ ig[3].reset(&one);
+ const unsigned sg = sizeof(ig)/sizeof(ig[0]);
+ r = std::unique(Iter(ig), Iter(ig+sg));
+ assert(base(r) == ig + 2);
+ assert(ig[0] == 0);
+ assert(*ig[1] == 1);
+
+ Ptr ih[3];
+ ih[1].reset(&one);
+ ih[2].reset(&one);
+ const unsigned sh = sizeof(ih)/sizeof(ih[0]);
+ r = std::unique(Iter(ih), Iter(ih+sh));
+ assert(base(r) == ih + 2);
+ assert(ih[0] == 0);
+ assert(*ih[1] == 1);
+
+ Ptr ii[7];
+ ii[1].reset(&one);
+ ii[2].reset(&one);
+ ii[3].reset(&one);
+ ii[4].reset(&two);
+ ii[5].reset(&two);
+ ii[6].reset(&two);
+ const unsigned si = sizeof(ii)/sizeof(ii[0]);
+ r = std::unique(Iter(ii), Iter(ii+si));
+ assert(base(r) == ii + 3);
+ assert(ii[0] == 0);
+ assert(*ii[1] == 1);
+ assert(*ii[2] == 2);
+}
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+ test<forward_iterator<int*> >();
+ test<bidirectional_iterator<int*> >();
+ test<random_access_iterator<int*> >();
+ test<int*>();
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+ test1<forward_iterator<Ptr*> >();
+ test1<bidirectional_iterator<Ptr*> >();
+ test1<random_access_iterator<Ptr*> >();
+ test1<Ptr*>();
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/algorithms/alg.modifying.operations/alg.unique/unique_copy.pass.cpp b/test/std/algorithms/alg.modifying.operations/alg.unique/unique_copy.pass.cpp
new file mode 100644
index 000000000000..761dad4ecd05
--- /dev/null
+++ b/test/std/algorithms/alg.modifying.operations/alg.unique/unique_copy.pass.cpp
@@ -0,0 +1,125 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator InIter, class OutIter>
+// requires OutputIterator<OutIter, RvalueOf<InIter::value_type>::type>
+// && EqualityComparable<InIter::value_type>
+// && HasAssign<InIter::value_type, InIter::reference>
+// && Constructible<InIter::value_type, InIter::reference>
+// OutIter
+// unique_copy(InIter first, InIter last, OutIter result);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class InIter, class OutIter>
+void
+test()
+{
+ const int ia[] = {0};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ int ja[sa] = {-1};
+ OutIter r = std::unique_copy(InIter(ia), InIter(ia+sa), OutIter(ja));
+ assert(base(r) == ja + sa);
+ assert(ja[0] == 0);
+
+ const int ib[] = {0, 1};
+ const unsigned sb = sizeof(ib)/sizeof(ib[0]);
+ int jb[sb] = {-1};
+ r = std::unique_copy(InIter(ib), InIter(ib+sb), OutIter(jb));
+ assert(base(r) == jb + sb);
+ assert(jb[0] == 0);
+ assert(jb[1] == 1);
+
+ const int ic[] = {0, 0};
+ const unsigned sc = sizeof(ic)/sizeof(ic[0]);
+ int jc[sc] = {-1};
+ r = std::unique_copy(InIter(ic), InIter(ic+sc), OutIter(jc));
+ assert(base(r) == jc + 1);
+ assert(jc[0] == 0);
+
+ const int id[] = {0, 0, 1};
+ const unsigned sd = sizeof(id)/sizeof(id[0]);
+ int jd[sd] = {-1};
+ r = std::unique_copy(InIter(id), InIter(id+sd), OutIter(jd));
+ assert(base(r) == jd + 2);
+ assert(jd[0] == 0);
+ assert(jd[1] == 1);
+
+ const int ie[] = {0, 0, 1, 0};
+ const unsigned se = sizeof(ie)/sizeof(ie[0]);
+ int je[se] = {-1};
+ r = std::unique_copy(InIter(ie), InIter(ie+se), OutIter(je));
+ assert(base(r) == je + 3);
+ assert(je[0] == 0);
+ assert(je[1] == 1);
+ assert(je[2] == 0);
+
+ const int ig[] = {0, 0, 1, 1};
+ const unsigned sg = sizeof(ig)/sizeof(ig[0]);
+ int jg[sg] = {-1};
+ r = std::unique_copy(InIter(ig), InIter(ig+sg), OutIter(jg));
+ assert(base(r) == jg + 2);
+ assert(jg[0] == 0);
+ assert(jg[1] == 1);
+
+ const int ih[] = {0, 1, 1};
+ const unsigned sh = sizeof(ih)/sizeof(ih[0]);
+ int jh[sh] = {-1};
+ r = std::unique_copy(InIter(ih), InIter(ih+sh), OutIter(jh));
+ assert(base(r) == jh + 2);
+ assert(jh[0] == 0);
+ assert(jh[1] == 1);
+
+ const int ii[] = {0, 1, 1, 1, 2, 2, 2};
+ const unsigned si = sizeof(ii)/sizeof(ii[0]);
+ int ji[si] = {-1};
+ r = std::unique_copy(InIter(ii), InIter(ii+si), OutIter(ji));
+ assert(base(r) == ji + 3);
+ assert(ji[0] == 0);
+ assert(ji[1] == 1);
+ assert(ji[2] == 2);
+}
+
+int main()
+{
+ test<input_iterator<const int*>, output_iterator<int*> >();
+ test<input_iterator<const int*>, forward_iterator<int*> >();
+ test<input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<input_iterator<const int*>, random_access_iterator<int*> >();
+ test<input_iterator<const int*>, int*>();
+
+ test<forward_iterator<const int*>, output_iterator<int*> >();
+ test<forward_iterator<const int*>, forward_iterator<int*> >();
+ test<forward_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<forward_iterator<const int*>, random_access_iterator<int*> >();
+ test<forward_iterator<const int*>, int*>();
+
+ test<bidirectional_iterator<const int*>, output_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, forward_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, int*>();
+
+ test<random_access_iterator<const int*>, output_iterator<int*> >();
+ test<random_access_iterator<const int*>, forward_iterator<int*> >();
+ test<random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, random_access_iterator<int*> >();
+ test<random_access_iterator<const int*>, int*>();
+
+ test<const int*, output_iterator<int*> >();
+ test<const int*, forward_iterator<int*> >();
+ test<const int*, bidirectional_iterator<int*> >();
+ test<const int*, random_access_iterator<int*> >();
+ test<const int*, int*>();
+}
diff --git a/test/std/algorithms/alg.modifying.operations/alg.unique/unique_copy_pred.pass.cpp b/test/std/algorithms/alg.modifying.operations/alg.unique/unique_copy_pred.pass.cpp
new file mode 100644
index 000000000000..6819899a1145
--- /dev/null
+++ b/test/std/algorithms/alg.modifying.operations/alg.unique/unique_copy_pred.pass.cpp
@@ -0,0 +1,152 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator InIter, class OutIter,
+// EquivalenceRelation<auto, InIter::value_type> Pred>
+// requires OutputIterator<OutIter, RvalueOf<InIter::value_type>::type>
+// && HasAssign<InIter::value_type, InIter::reference>
+// && Constructible<InIter::value_type, InIter::reference>
+// && CopyConstructible<Pred>
+// OutIter
+// unique_copy(InIter first, InIter last, OutIter result, Pred pred);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+struct count_equal
+{
+ static unsigned count;
+ template <class T>
+ bool operator()(const T& x, const T& y)
+ {++count; return x == y;}
+};
+
+unsigned count_equal::count = 0;
+
+template <class InIter, class OutIter>
+void
+test()
+{
+ const int ia[] = {0};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ int ja[sa] = {-1};
+ count_equal::count = 0;
+ OutIter r = std::unique_copy(InIter(ia), InIter(ia+sa), OutIter(ja), count_equal());
+ assert(base(r) == ja + sa);
+ assert(ja[0] == 0);
+ assert(count_equal::count == sa-1);
+
+ const int ib[] = {0, 1};
+ const unsigned sb = sizeof(ib)/sizeof(ib[0]);
+ int jb[sb] = {-1};
+ count_equal::count = 0;
+ r = std::unique_copy(InIter(ib), InIter(ib+sb), OutIter(jb), count_equal());
+ assert(base(r) == jb + sb);
+ assert(jb[0] == 0);
+ assert(jb[1] == 1);
+ assert(count_equal::count == sb-1);
+
+ const int ic[] = {0, 0};
+ const unsigned sc = sizeof(ic)/sizeof(ic[0]);
+ int jc[sc] = {-1};
+ count_equal::count = 0;
+ r = std::unique_copy(InIter(ic), InIter(ic+sc), OutIter(jc), count_equal());
+ assert(base(r) == jc + 1);
+ assert(jc[0] == 0);
+ assert(count_equal::count == sc-1);
+
+ const int id[] = {0, 0, 1};
+ const unsigned sd = sizeof(id)/sizeof(id[0]);
+ int jd[sd] = {-1};
+ count_equal::count = 0;
+ r = std::unique_copy(InIter(id), InIter(id+sd), OutIter(jd), count_equal());
+ assert(base(r) == jd + 2);
+ assert(jd[0] == 0);
+ assert(jd[1] == 1);
+ assert(count_equal::count == sd-1);
+
+ const int ie[] = {0, 0, 1, 0};
+ const unsigned se = sizeof(ie)/sizeof(ie[0]);
+ int je[se] = {-1};
+ count_equal::count = 0;
+ r = std::unique_copy(InIter(ie), InIter(ie+se), OutIter(je), count_equal());
+ assert(base(r) == je + 3);
+ assert(je[0] == 0);
+ assert(je[1] == 1);
+ assert(je[2] == 0);
+ assert(count_equal::count == se-1);
+
+ const int ig[] = {0, 0, 1, 1};
+ const unsigned sg = sizeof(ig)/sizeof(ig[0]);
+ int jg[sg] = {-1};
+ count_equal::count = 0;
+ r = std::unique_copy(InIter(ig), InIter(ig+sg), OutIter(jg), count_equal());
+ assert(base(r) == jg + 2);
+ assert(jg[0] == 0);
+ assert(jg[1] == 1);
+ assert(count_equal::count == sg-1);
+
+ const int ih[] = {0, 1, 1};
+ const unsigned sh = sizeof(ih)/sizeof(ih[0]);
+ int jh[sh] = {-1};
+ count_equal::count = 0;
+ r = std::unique_copy(InIter(ih), InIter(ih+sh), OutIter(jh), count_equal());
+ assert(base(r) == jh + 2);
+ assert(jh[0] == 0);
+ assert(jh[1] == 1);
+ assert(count_equal::count == sh-1);
+
+ const int ii[] = {0, 1, 1, 1, 2, 2, 2};
+ const unsigned si = sizeof(ii)/sizeof(ii[0]);
+ int ji[si] = {-1};
+ count_equal::count = 0;
+ r = std::unique_copy(InIter(ii), InIter(ii+si), OutIter(ji), count_equal());
+ assert(base(r) == ji + 3);
+ assert(ji[0] == 0);
+ assert(ji[1] == 1);
+ assert(ji[2] == 2);
+ assert(count_equal::count == si-1);
+}
+
+int main()
+{
+ test<input_iterator<const int*>, output_iterator<int*> >();
+ test<input_iterator<const int*>, forward_iterator<int*> >();
+ test<input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<input_iterator<const int*>, random_access_iterator<int*> >();
+ test<input_iterator<const int*>, int*>();
+
+ test<forward_iterator<const int*>, output_iterator<int*> >();
+ test<forward_iterator<const int*>, forward_iterator<int*> >();
+ test<forward_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<forward_iterator<const int*>, random_access_iterator<int*> >();
+ test<forward_iterator<const int*>, int*>();
+
+ test<bidirectional_iterator<const int*>, output_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, forward_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, int*>();
+
+ test<random_access_iterator<const int*>, output_iterator<int*> >();
+ test<random_access_iterator<const int*>, forward_iterator<int*> >();
+ test<random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, random_access_iterator<int*> >();
+ test<random_access_iterator<const int*>, int*>();
+
+ test<const int*, output_iterator<int*> >();
+ test<const int*, forward_iterator<int*> >();
+ test<const int*, bidirectional_iterator<int*> >();
+ test<const int*, random_access_iterator<int*> >();
+ test<const int*, int*>();
+}
diff --git a/test/std/algorithms/alg.modifying.operations/alg.unique/unique_pred.pass.cpp b/test/std/algorithms/alg.modifying.operations/alg.unique/unique_pred.pass.cpp
new file mode 100644
index 000000000000..c6df235bed6d
--- /dev/null
+++ b/test/std/algorithms/alg.modifying.operations/alg.unique/unique_pred.pass.cpp
@@ -0,0 +1,231 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter, EquivalenceRelation<auto, Iter::value_type> Pred>
+// requires OutputIterator<Iter, RvalueOf<Iter::reference>::type>
+// && CopyConstructible<Pred>
+// Iter
+// unique(Iter first, Iter last, Pred pred);
+
+#include <algorithm>
+#include <cassert>
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#include <memory>
+#endif
+
+#include "test_iterators.h"
+
+struct count_equal
+{
+ static unsigned count;
+ template <class T>
+ bool operator()(const T& x, const T& y)
+ {++count; return x == y;}
+};
+
+unsigned count_equal::count = 0;
+
+template <class Iter>
+void
+test()
+{
+ int ia[] = {0};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ count_equal::count = 0;
+ Iter r = std::unique(Iter(ia), Iter(ia+sa), count_equal());
+ assert(base(r) == ia + sa);
+ assert(ia[0] == 0);
+ assert(count_equal::count == sa-1);
+
+ int ib[] = {0, 1};
+ const unsigned sb = sizeof(ib)/sizeof(ib[0]);
+ count_equal::count = 0;
+ r = std::unique(Iter(ib), Iter(ib+sb), count_equal());
+ assert(base(r) == ib + sb);
+ assert(ib[0] == 0);
+ assert(ib[1] == 1);
+ assert(count_equal::count == sb-1);
+
+ int ic[] = {0, 0};
+ const unsigned sc = sizeof(ic)/sizeof(ic[0]);
+ count_equal::count = 0;
+ r = std::unique(Iter(ic), Iter(ic+sc), count_equal());
+ assert(base(r) == ic + 1);
+ assert(ic[0] == 0);
+ assert(count_equal::count == sc-1);
+
+ int id[] = {0, 0, 1};
+ const unsigned sd = sizeof(id)/sizeof(id[0]);
+ count_equal::count = 0;
+ r = std::unique(Iter(id), Iter(id+sd), count_equal());
+ assert(base(r) == id + 2);
+ assert(id[0] == 0);
+ assert(id[1] == 1);
+ assert(count_equal::count == sd-1);
+
+ int ie[] = {0, 0, 1, 0};
+ const unsigned se = sizeof(ie)/sizeof(ie[0]);
+ count_equal::count = 0;
+ r = std::unique(Iter(ie), Iter(ie+se), count_equal());
+ assert(base(r) == ie + 3);
+ assert(ie[0] == 0);
+ assert(ie[1] == 1);
+ assert(ie[2] == 0);
+ assert(count_equal::count == se-1);
+
+ int ig[] = {0, 0, 1, 1};
+ const unsigned sg = sizeof(ig)/sizeof(ig[0]);
+ count_equal::count = 0;
+ r = std::unique(Iter(ig), Iter(ig+sg), count_equal());
+ assert(base(r) == ig + 2);
+ assert(ig[0] == 0);
+ assert(ig[1] == 1);
+ assert(count_equal::count == sg-1);
+
+ int ih[] = {0, 1, 1};
+ const unsigned sh = sizeof(ih)/sizeof(ih[0]);
+ count_equal::count = 0;
+ r = std::unique(Iter(ih), Iter(ih+sh), count_equal());
+ assert(base(r) == ih + 2);
+ assert(ih[0] == 0);
+ assert(ih[1] == 1);
+ assert(count_equal::count == sh-1);
+
+ int ii[] = {0, 1, 1, 1, 2, 2, 2};
+ const unsigned si = sizeof(ii)/sizeof(ii[0]);
+ count_equal::count = 0;
+ r = std::unique(Iter(ii), Iter(ii+si), count_equal());
+ assert(base(r) == ii + 3);
+ assert(ii[0] == 0);
+ assert(ii[1] == 1);
+ assert(ii[2] == 2);
+ assert(count_equal::count == si-1);
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+struct do_nothing
+{
+ void operator()(void*) const {}
+};
+
+typedef std::unique_ptr<int, do_nothing> Ptr;
+
+template <class Iter>
+void
+test1()
+{
+ int one = 1;
+ int two = 2;
+ Ptr ia[1];
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ count_equal::count = 0;
+ Iter r = std::unique(Iter(ia), Iter(ia+sa), count_equal());
+ assert(base(r) == ia + sa);
+ assert(ia[0] == 0);
+ assert(count_equal::count == sa-1);
+
+ Ptr ib[2];
+ ib[1].reset(&one);
+ const unsigned sb = sizeof(ib)/sizeof(ib[0]);
+ count_equal::count = 0;
+ r = std::unique(Iter(ib), Iter(ib+sb), count_equal());
+ assert(base(r) == ib + sb);
+ assert(ib[0] == 0);
+ assert(*ib[1] == 1);
+ assert(count_equal::count == sb-1);
+
+ Ptr ic[2];
+ const unsigned sc = sizeof(ic)/sizeof(ic[0]);
+ count_equal::count = 0;
+ r = std::unique(Iter(ic), Iter(ic+sc), count_equal());
+ assert(base(r) == ic + 1);
+ assert(ic[0] == 0);
+ assert(count_equal::count == sc-1);
+
+ Ptr id[3];
+ id[2].reset(&one);
+ const unsigned sd = sizeof(id)/sizeof(id[0]);
+ count_equal::count = 0;
+ r = std::unique(Iter(id), Iter(id+sd), count_equal());
+ assert(base(r) == id + 2);
+ assert(id[0] == 0);
+ assert(*id[1] == 1);
+ assert(count_equal::count == sd-1);
+
+ Ptr ie[4];
+ ie[2].reset(&one);
+ const unsigned se = sizeof(ie)/sizeof(ie[0]);
+ count_equal::count = 0;
+ r = std::unique(Iter(ie), Iter(ie+se), count_equal());
+ assert(base(r) == ie + 3);
+ assert(ie[0] == 0);
+ assert(*ie[1] == 1);
+ assert(ie[2] == 0);
+ assert(count_equal::count == se-1);
+
+ Ptr ig[4];
+ ig[2].reset(&one);
+ ig[3].reset(&one);
+ const unsigned sg = sizeof(ig)/sizeof(ig[0]);
+ count_equal::count = 0;
+ r = std::unique(Iter(ig), Iter(ig+sg), count_equal());
+ assert(base(r) == ig + 2);
+ assert(ig[0] == 0);
+ assert(*ig[1] == 1);
+ assert(count_equal::count == sg-1);
+
+ Ptr ih[3];
+ ih[1].reset(&one);
+ ih[2].reset(&one);
+ const unsigned sh = sizeof(ih)/sizeof(ih[0]);
+ count_equal::count = 0;
+ r = std::unique(Iter(ih), Iter(ih+sh), count_equal());
+ assert(base(r) == ih + 2);
+ assert(ih[0] == 0);
+ assert(*ih[1] == 1);
+ assert(count_equal::count == sh-1);
+
+ Ptr ii[7];
+ ii[1].reset(&one);
+ ii[2].reset(&one);
+ ii[3].reset(&one);
+ ii[4].reset(&two);
+ ii[5].reset(&two);
+ ii[6].reset(&two);
+ const unsigned si = sizeof(ii)/sizeof(ii[0]);
+ count_equal::count = 0;
+ r = std::unique(Iter(ii), Iter(ii+si), count_equal());
+ assert(base(r) == ii + 3);
+ assert(ii[0] == 0);
+ assert(*ii[1] == 1);
+ assert(*ii[2] == 2);
+ assert(count_equal::count == si-1);
+}
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+ test<forward_iterator<int*> >();
+ test<bidirectional_iterator<int*> >();
+ test<random_access_iterator<int*> >();
+ test<int*>();
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+ test1<forward_iterator<Ptr*> >();
+ test1<bidirectional_iterator<Ptr*> >();
+ test1<random_access_iterator<Ptr*> >();
+ test1<Ptr*>();
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/algorithms/alg.modifying.operations/nothing_to_do.pass.cpp b/test/std/algorithms/alg.modifying.operations/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/algorithms/alg.modifying.operations/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/algorithms/alg.nonmodifying/alg.adjacent.find/adjacent_find.pass.cpp b/test/std/algorithms/alg.nonmodifying/alg.adjacent.find/adjacent_find.pass.cpp
new file mode 100644
index 000000000000..ee030925d55c
--- /dev/null
+++ b/test/std/algorithms/alg.nonmodifying/alg.adjacent.find/adjacent_find.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter>
+// requires EqualityComparable<Iter::value_type>
+// Iter
+// adjacent_find(Iter first, Iter last);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+int main()
+{
+ int ia[] = {0, 1, 2, 2, 0, 1, 2, 3};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::adjacent_find(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa)) ==
+ forward_iterator<const int*>(ia+2));
+ assert(std::adjacent_find(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia)) ==
+ forward_iterator<const int*>(ia));
+ assert(std::adjacent_find(forward_iterator<const int*>(ia+3),
+ forward_iterator<const int*>(ia + sa)) ==
+ forward_iterator<const int*>(ia+sa));
+}
diff --git a/test/std/algorithms/alg.nonmodifying/alg.adjacent.find/adjacent_find_pred.pass.cpp b/test/std/algorithms/alg.nonmodifying/alg.adjacent.find/adjacent_find_pred.pass.cpp
new file mode 100644
index 000000000000..4d172ff81397
--- /dev/null
+++ b/test/std/algorithms/alg.nonmodifying/alg.adjacent.find/adjacent_find_pred.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter, EquivalenceRelation<auto, Iter::value_type> Pred>
+// requires CopyConstructible<Pred>
+// Iter
+// adjacent_find(Iter first, Iter last, Pred pred);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "test_iterators.h"
+
+int main()
+{
+ int ia[] = {0, 1, 2, 2, 0, 1, 2, 3};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::adjacent_find(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ std::equal_to<int>()) ==
+ forward_iterator<const int*>(ia+2));
+ assert(std::adjacent_find(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia),
+ std::equal_to<int>()) ==
+ forward_iterator<const int*>(ia));
+ assert(std::adjacent_find(forward_iterator<const int*>(ia+3),
+ forward_iterator<const int*>(ia + sa),
+ std::equal_to<int>()) ==
+ forward_iterator<const int*>(ia+sa));
+}
diff --git a/test/std/algorithms/alg.nonmodifying/alg.all_of/all_of.pass.cpp b/test/std/algorithms/alg.nonmodifying/alg.all_of/all_of.pass.cpp
new file mode 100644
index 000000000000..c3c348088195
--- /dev/null
+++ b/test/std/algorithms/alg.nonmodifying/alg.all_of/all_of.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template <class InputIterator, class Predicate>
+// bool
+// all_of(InputIterator first, InputIterator last, Predicate pred);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+struct test1
+{
+ bool operator()(const int& i) const
+ {
+ return i % 2 == 0;
+ }
+};
+
+int main()
+{
+ {
+ int ia[] = {2, 4, 6, 8};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::all_of(input_iterator<const int*>(ia),
+ input_iterator<const int*>(ia + sa), test1()) == true);
+ assert(std::all_of(input_iterator<const int*>(ia),
+ input_iterator<const int*>(ia), test1()) == true);
+ }
+ {
+ const int ia[] = {2, 4, 5, 8};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::all_of(input_iterator<const int*>(ia),
+ input_iterator<const int*>(ia + sa), test1()) == false);
+ assert(std::all_of(input_iterator<const int*>(ia),
+ input_iterator<const int*>(ia), test1()) == true);
+ }
+}
diff --git a/test/std/algorithms/alg.nonmodifying/alg.any_of/any_of.pass.cpp b/test/std/algorithms/alg.nonmodifying/alg.any_of/any_of.pass.cpp
new file mode 100644
index 000000000000..d096e20d2d27
--- /dev/null
+++ b/test/std/algorithms/alg.nonmodifying/alg.any_of/any_of.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template <class InputIterator, class Predicate>
+// bool
+// any_of(InputIterator first, InputIterator last, Predicate pred);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+struct test1
+{
+ bool operator()(const int& i) const
+ {
+ return i % 2 == 0;
+ }
+};
+
+int main()
+{
+ {
+ int ia[] = {2, 4, 6, 8};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::any_of(input_iterator<const int*>(ia),
+ input_iterator<const int*>(ia + sa), test1()) == true);
+ assert(std::any_of(input_iterator<const int*>(ia),
+ input_iterator<const int*>(ia), test1()) == false);
+ }
+ {
+ const int ia[] = {2, 4, 5, 8};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::any_of(input_iterator<const int*>(ia),
+ input_iterator<const int*>(ia + sa), test1()) == true);
+ assert(std::any_of(input_iterator<const int*>(ia),
+ input_iterator<const int*>(ia), test1()) == false);
+ }
+ {
+ const int ia[] = {1, 3, 5, 7};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::any_of(input_iterator<const int*>(ia),
+ input_iterator<const int*>(ia + sa), test1()) == false);
+ assert(std::any_of(input_iterator<const int*>(ia),
+ input_iterator<const int*>(ia), test1()) == false);
+ }
+}
diff --git a/test/std/algorithms/alg.nonmodifying/alg.count/count.pass.cpp b/test/std/algorithms/alg.nonmodifying/alg.count/count.pass.cpp
new file mode 100644
index 000000000000..260e5edece5b
--- /dev/null
+++ b/test/std/algorithms/alg.nonmodifying/alg.count/count.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator Iter, class T>
+// requires HasEqualTo<Iter::value_type, T>
+// Iter::difference_type
+// count(Iter first, Iter last, const T& value);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+int main()
+{
+ int ia[] = {0, 1, 2, 2, 0, 1, 2, 3};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::count(input_iterator<const int*>(ia),
+ input_iterator<const int*>(ia + sa), 2) == 3);
+ assert(std::count(input_iterator<const int*>(ia),
+ input_iterator<const int*>(ia + sa), 7) == 0);
+ assert(std::count(input_iterator<const int*>(ia),
+ input_iterator<const int*>(ia), 2) == 0);
+}
diff --git a/test/std/algorithms/alg.nonmodifying/alg.count/count_if.pass.cpp b/test/std/algorithms/alg.nonmodifying/alg.count/count_if.pass.cpp
new file mode 100644
index 000000000000..025bc06a618d
--- /dev/null
+++ b/test/std/algorithms/alg.nonmodifying/alg.count/count_if.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator Iter, Predicate<auto, Iter::value_type> Pred>
+// requires CopyConstructible<Pred>
+// Iter::difference_type
+// count_if(Iter first, Iter last, Pred pred);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "test_iterators.h"
+
+int main()
+{
+ int ia[] = {0, 1, 2, 2, 0, 1, 2, 3};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::count_if(input_iterator<const int*>(ia),
+ input_iterator<const int*>(ia + sa),
+ std::bind2nd(std::equal_to<int>(),2)) == 3);
+ assert(std::count_if(input_iterator<const int*>(ia),
+ input_iterator<const int*>(ia + sa),
+ std::bind2nd(std::equal_to<int>(),7)) == 0);
+ assert(std::count_if(input_iterator<const int*>(ia),
+ input_iterator<const int*>(ia),
+ std::bind2nd(std::equal_to<int>(),2)) == 0);
+}
diff --git a/test/std/algorithms/alg.nonmodifying/alg.equal/equal.pass.cpp b/test/std/algorithms/alg.nonmodifying/alg.equal/equal.pass.cpp
new file mode 100644
index 000000000000..234879149ae3
--- /dev/null
+++ b/test/std/algorithms/alg.nonmodifying/alg.equal/equal.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator Iter1, InputIterator Iter2>
+// requires HasEqualTo<Iter1::value_type, Iter2::value_type>
+// bool
+// equal(Iter1 first1, Iter1 last1, Iter2 first2);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+#if _LIBCPP_STD_VER > 11
+#define HAS_FOUR_ITERATOR_VERSION
+#endif
+
+int main()
+{
+ int ia[] = {0, 1, 2, 3, 4, 5};
+ const unsigned s = sizeof(ia)/sizeof(ia[0]);
+ int ib[s] = {0, 1, 2, 5, 4, 5};
+ assert(std::equal(input_iterator<const int*>(ia),
+ input_iterator<const int*>(ia+s),
+ input_iterator<const int*>(ia)));
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(std::equal(input_iterator<const int*>(ia),
+ input_iterator<const int*>(ia+s),
+ input_iterator<const int*>(ia),
+ input_iterator<const int*>(ia+s)));
+ assert(std::equal(random_access_iterator<const int*>(ia),
+ random_access_iterator<const int*>(ia+s),
+ random_access_iterator<const int*>(ia),
+ random_access_iterator<const int*>(ia+s)));
+#endif
+ assert(!std::equal(input_iterator<const int*>(ia),
+ input_iterator<const int*>(ia+s),
+ input_iterator<const int*>(ib)));
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(!std::equal(input_iterator<const int*>(ia),
+ input_iterator<const int*>(ia+s),
+ input_iterator<const int*>(ib),
+ input_iterator<const int*>(ib+s)));
+ assert(!std::equal(random_access_iterator<const int*>(ia),
+ random_access_iterator<const int*>(ia+s),
+ random_access_iterator<const int*>(ib),
+ random_access_iterator<const int*>(ib+s)));
+ assert(!std::equal(input_iterator<const int*>(ia),
+ input_iterator<const int*>(ia+s),
+ input_iterator<const int*>(ia),
+ input_iterator<const int*>(ia+s-1)));
+ assert(!std::equal(random_access_iterator<const int*>(ia),
+ random_access_iterator<const int*>(ia+s),
+ random_access_iterator<const int*>(ia),
+ random_access_iterator<const int*>(ia+s-1)));
+
+#endif
+}
diff --git a/test/std/algorithms/alg.nonmodifying/alg.equal/equal_pred.pass.cpp b/test/std/algorithms/alg.nonmodifying/alg.equal/equal_pred.pass.cpp
new file mode 100644
index 000000000000..047f72062ebd
--- /dev/null
+++ b/test/std/algorithms/alg.nonmodifying/alg.equal/equal_pred.pass.cpp
@@ -0,0 +1,87 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator Iter1, InputIterator Iter2,
+// Predicate<auto, Iter1::value_type, Iter2::value_type> Pred>
+// requires CopyConstructible<Pred>
+// bool
+// equal(Iter1 first1, Iter1 last1, Iter2 first2, Pred pred);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "test_iterators.h"
+
+#if _LIBCPP_STD_VER > 11
+#define HAS_FOUR_ITERATOR_VERSION
+#endif
+
+int comparison_count = 0;
+template <typename T>
+bool counting_equals ( const T &a, const T &b ) {
+ ++comparison_count;
+ return a == b;
+}
+
+int main()
+{
+ int ia[] = {0, 1, 2, 3, 4, 5};
+ const unsigned s = sizeof(ia)/sizeof(ia[0]);
+ int ib[s] = {0, 1, 2, 5, 4, 5};
+ assert(std::equal(input_iterator<const int*>(ia),
+ input_iterator<const int*>(ia+s),
+ input_iterator<const int*>(ia),
+ std::equal_to<int>()));
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(std::equal(input_iterator<const int*>(ia),
+ input_iterator<const int*>(ia+s),
+ input_iterator<const int*>(ia),
+ input_iterator<const int*>(ia+s),
+ std::equal_to<int>()));
+ assert(std::equal(random_access_iterator<const int*>(ia),
+ random_access_iterator<const int*>(ia+s),
+ random_access_iterator<const int*>(ia),
+ random_access_iterator<const int*>(ia+s),
+ std::equal_to<int>()));
+
+ comparison_count = 0;
+ assert(!std::equal(input_iterator<const int*>(ia),
+ input_iterator<const int*>(ia+s),
+ input_iterator<const int*>(ia),
+ input_iterator<const int*>(ia+s-1),
+ counting_equals<int>));
+ assert(comparison_count > 0);
+ comparison_count = 0;
+ assert(!std::equal(random_access_iterator<const int*>(ia),
+ random_access_iterator<const int*>(ia+s),
+ random_access_iterator<const int*>(ia),
+ random_access_iterator<const int*>(ia+s-1),
+ counting_equals<int>));
+ assert(comparison_count == 0);
+#endif
+ assert(!std::equal(input_iterator<const int*>(ia),
+ input_iterator<const int*>(ia+s),
+ input_iterator<const int*>(ib),
+ std::equal_to<int>()));
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(!std::equal(input_iterator<const int*>(ia),
+ input_iterator<const int*>(ia+s),
+ input_iterator<const int*>(ib),
+ input_iterator<const int*>(ib+s),
+ std::equal_to<int>()));
+ assert(!std::equal(random_access_iterator<const int*>(ia),
+ random_access_iterator<const int*>(ia+s),
+ random_access_iterator<const int*>(ib),
+ random_access_iterator<const int*>(ib+s),
+ std::equal_to<int>()));
+#endif
+}
diff --git a/test/std/algorithms/alg.nonmodifying/alg.find.end/find_end.pass.cpp b/test/std/algorithms/alg.nonmodifying/alg.find.end/find_end.pass.cpp
new file mode 100644
index 000000000000..e95162b4ad73
--- /dev/null
+++ b/test/std/algorithms/alg.nonmodifying/alg.find.end/find_end.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter1, ForwardIterator Iter2>
+// requires HasEqualTo<Iter1::value_type, Iter2::value_type>
+// Iter1
+// find_end(Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter1, class Iter2>
+void
+test()
+{
+ int ia[] = {0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 0, 1, 2, 3, 0, 1, 2, 0, 1, 0};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ int b[] = {0};
+ assert(std::find_end(Iter1(ia), Iter1(ia+sa), Iter2(b), Iter2(b+1)) == Iter1(ia+sa-1));
+ int c[] = {0, 1};
+ assert(std::find_end(Iter1(ia), Iter1(ia+sa), Iter2(c), Iter2(c+2)) == Iter1(ia+18));
+ int d[] = {0, 1, 2};
+ assert(std::find_end(Iter1(ia), Iter1(ia+sa), Iter2(d), Iter2(d+3)) == Iter1(ia+15));
+ int e[] = {0, 1, 2, 3};
+ assert(std::find_end(Iter1(ia), Iter1(ia+sa), Iter2(e), Iter2(e+4)) == Iter1(ia+11));
+ int f[] = {0, 1, 2, 3, 4};
+ assert(std::find_end(Iter1(ia), Iter1(ia+sa), Iter2(f), Iter2(f+5)) == Iter1(ia+6));
+ int g[] = {0, 1, 2, 3, 4, 5};
+ assert(std::find_end(Iter1(ia), Iter1(ia+sa), Iter2(g), Iter2(g+6)) == Iter1(ia));
+ int h[] = {0, 1, 2, 3, 4, 5, 6};
+ assert(std::find_end(Iter1(ia), Iter1(ia+sa), Iter2(h), Iter2(h+7)) == Iter1(ia+sa));
+ assert(std::find_end(Iter1(ia), Iter1(ia+sa), Iter2(b), Iter2(b)) == Iter1(ia+sa));
+ assert(std::find_end(Iter1(ia), Iter1(ia), Iter2(b), Iter2(b+1)) == Iter1(ia));
+}
+
+int main()
+{
+ test<forward_iterator<const int*>, forward_iterator<const int*> >();
+ test<forward_iterator<const int*>, bidirectional_iterator<const int*> >();
+ test<forward_iterator<const int*>, random_access_iterator<const int*> >();
+ test<bidirectional_iterator<const int*>, forward_iterator<const int*> >();
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*> >();
+ test<bidirectional_iterator<const int*>, random_access_iterator<const int*> >();
+ test<random_access_iterator<const int*>, forward_iterator<const int*> >();
+ test<random_access_iterator<const int*>, bidirectional_iterator<const int*> >();
+ test<random_access_iterator<const int*>, random_access_iterator<const int*> >();
+}
diff --git a/test/std/algorithms/alg.nonmodifying/alg.find.end/find_end_pred.pass.cpp b/test/std/algorithms/alg.nonmodifying/alg.find.end/find_end_pred.pass.cpp
new file mode 100644
index 000000000000..411858d5b76d
--- /dev/null
+++ b/test/std/algorithms/alg.nonmodifying/alg.find.end/find_end_pred.pass.cpp
@@ -0,0 +1,86 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter1, ForwardIterator Iter2,
+// Predicate<auto, Iter1::value_type, Iter2::value_type> Pred>
+// requires CopyConstructible<Pred>
+// Iter1
+// find_end(Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2, Pred pred);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+struct count_equal
+{
+ static unsigned count;
+ template <class T>
+ bool operator()(const T& x, const T& y)
+ {++count; return x == y;}
+};
+
+unsigned count_equal::count = 0;
+
+template <class Iter1, class Iter2>
+void
+test()
+{
+ int ia[] = {0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 0, 1, 2, 3, 0, 1, 2, 0, 1, 0};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ int b[] = {0};
+ count_equal::count = 0;
+ assert(std::find_end(Iter1(ia), Iter1(ia+sa), Iter2(b), Iter2(b+1), count_equal()) == Iter1(ia+sa-1));
+ assert(count_equal::count <= 1*(sa-1+1));
+ int c[] = {0, 1};
+ count_equal::count = 0;
+ assert(std::find_end(Iter1(ia), Iter1(ia+sa), Iter2(c), Iter2(c+2), count_equal()) == Iter1(ia+18));
+ assert(count_equal::count <= 2*(sa-2+1));
+ int d[] = {0, 1, 2};
+ count_equal::count = 0;
+ assert(std::find_end(Iter1(ia), Iter1(ia+sa), Iter2(d), Iter2(d+3), count_equal()) == Iter1(ia+15));
+ assert(count_equal::count <= 3*(sa-3+1));
+ int e[] = {0, 1, 2, 3};
+ count_equal::count = 0;
+ assert(std::find_end(Iter1(ia), Iter1(ia+sa), Iter2(e), Iter2(e+4), count_equal()) == Iter1(ia+11));
+ assert(count_equal::count <= 4*(sa-4+1));
+ int f[] = {0, 1, 2, 3, 4};
+ count_equal::count = 0;
+ assert(std::find_end(Iter1(ia), Iter1(ia+sa), Iter2(f), Iter2(f+5), count_equal()) == Iter1(ia+6));
+ assert(count_equal::count <= 5*(sa-5+1));
+ int g[] = {0, 1, 2, 3, 4, 5};
+ count_equal::count = 0;
+ assert(std::find_end(Iter1(ia), Iter1(ia+sa), Iter2(g), Iter2(g+6), count_equal()) == Iter1(ia));
+ assert(count_equal::count <= 6*(sa-6+1));
+ int h[] = {0, 1, 2, 3, 4, 5, 6};
+ count_equal::count = 0;
+ assert(std::find_end(Iter1(ia), Iter1(ia+sa), Iter2(h), Iter2(h+7), count_equal()) == Iter1(ia+sa));
+ assert(count_equal::count <= 7*(sa-7+1));
+ count_equal::count = 0;
+ assert(std::find_end(Iter1(ia), Iter1(ia+sa), Iter2(b), Iter2(b), count_equal()) == Iter1(ia+sa));
+ assert(count_equal::count <= 0);
+ count_equal::count = 0;
+ assert(std::find_end(Iter1(ia), Iter1(ia), Iter2(b), Iter2(b+1), count_equal()) == Iter1(ia));
+ assert(count_equal::count <= 0);
+}
+
+int main()
+{
+ test<forward_iterator<const int*>, forward_iterator<const int*> >();
+ test<forward_iterator<const int*>, bidirectional_iterator<const int*> >();
+ test<forward_iterator<const int*>, random_access_iterator<const int*> >();
+ test<bidirectional_iterator<const int*>, forward_iterator<const int*> >();
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*> >();
+ test<bidirectional_iterator<const int*>, random_access_iterator<const int*> >();
+ test<random_access_iterator<const int*>, forward_iterator<const int*> >();
+ test<random_access_iterator<const int*>, bidirectional_iterator<const int*> >();
+ test<random_access_iterator<const int*>, random_access_iterator<const int*> >();
+}
diff --git a/test/std/algorithms/alg.nonmodifying/alg.find.first.of/find_first_of.pass.cpp b/test/std/algorithms/alg.nonmodifying/alg.find.first.of/find_first_of.pass.cpp
new file mode 100644
index 000000000000..966207671fc2
--- /dev/null
+++ b/test/std/algorithms/alg.nonmodifying/alg.find.first.of/find_first_of.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator Iter1, ForwardIterator Iter2>
+// requires HasEqualTo<Iter1::value_type, Iter2::value_type>
+// Iter1
+// find_first_of(Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+int main()
+{
+ int ia[] = {0, 1, 2, 3, 0, 1, 2, 3};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ int ib[] = {1, 3, 5, 7};
+ const unsigned sb = sizeof(ib)/sizeof(ib[0]);
+ assert(std::find_first_of(input_iterator<const int*>(ia),
+ input_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sb)) ==
+ input_iterator<const int*>(ia+1));
+ int ic[] = {7};
+ assert(std::find_first_of(input_iterator<const int*>(ia),
+ input_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ic),
+ forward_iterator<const int*>(ic + 1)) ==
+ input_iterator<const int*>(ia+sa));
+ assert(std::find_first_of(input_iterator<const int*>(ia),
+ input_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ic),
+ forward_iterator<const int*>(ic)) ==
+ input_iterator<const int*>(ia+sa));
+ assert(std::find_first_of(input_iterator<const int*>(ia),
+ input_iterator<const int*>(ia),
+ forward_iterator<const int*>(ic),
+ forward_iterator<const int*>(ic+1)) ==
+ input_iterator<const int*>(ia));
+}
diff --git a/test/std/algorithms/alg.nonmodifying/alg.find.first.of/find_first_of_pred.pass.cpp b/test/std/algorithms/alg.nonmodifying/alg.find.first.of/find_first_of_pred.pass.cpp
new file mode 100644
index 000000000000..d1d954ca0cae
--- /dev/null
+++ b/test/std/algorithms/alg.nonmodifying/alg.find.first.of/find_first_of_pred.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator Iter1, ForwardIterator Iter2,
+// Predicate<auto, Iter1::value_type, Iter2::value_type> Pred>
+// requires CopyConstructible<Pred>
+// Iter1
+// find_first_of(Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2, Pred pred);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "test_iterators.h"
+
+int main()
+{
+ int ia[] = {0, 1, 2, 3, 0, 1, 2, 3};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ int ib[] = {1, 3, 5, 7};
+ const unsigned sb = sizeof(ib)/sizeof(ib[0]);
+ assert(std::find_first_of(input_iterator<const int*>(ia),
+ input_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sb),
+ std::equal_to<int>()) ==
+ input_iterator<const int*>(ia+1));
+ int ic[] = {7};
+ assert(std::find_first_of(input_iterator<const int*>(ia),
+ input_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ic),
+ forward_iterator<const int*>(ic + 1),
+ std::equal_to<int>()) ==
+ input_iterator<const int*>(ia+sa));
+ assert(std::find_first_of(input_iterator<const int*>(ia),
+ input_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ic),
+ forward_iterator<const int*>(ic),
+ std::equal_to<int>()) ==
+ input_iterator<const int*>(ia+sa));
+ assert(std::find_first_of(input_iterator<const int*>(ia),
+ input_iterator<const int*>(ia),
+ forward_iterator<const int*>(ic),
+ forward_iterator<const int*>(ic+1),
+ std::equal_to<int>()) ==
+ input_iterator<const int*>(ia));
+}
diff --git a/test/std/algorithms/alg.nonmodifying/alg.find/find.pass.cpp b/test/std/algorithms/alg.nonmodifying/alg.find/find.pass.cpp
new file mode 100644
index 000000000000..09f0f41215c2
--- /dev/null
+++ b/test/std/algorithms/alg.nonmodifying/alg.find/find.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator Iter, class T>
+// requires HasEqualTo<Iter::value_type, T>
+// Iter
+// find(Iter first, Iter last, const T& value);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+int main()
+{
+ int ia[] = {0, 1, 2, 3, 4, 5};
+ const unsigned s = sizeof(ia)/sizeof(ia[0]);
+ input_iterator<const int*> r = std::find(input_iterator<const int*>(ia),
+ input_iterator<const int*>(ia+s), 3);
+ assert(*r == 3);
+ r = std::find(input_iterator<const int*>(ia), input_iterator<const int*>(ia+s), 10);
+ assert(r == input_iterator<const int*>(ia+s));
+}
diff --git a/test/std/algorithms/alg.nonmodifying/alg.find/find_if.pass.cpp b/test/std/algorithms/alg.nonmodifying/alg.find/find_if.pass.cpp
new file mode 100644
index 000000000000..bde6ff389d0c
--- /dev/null
+++ b/test/std/algorithms/alg.nonmodifying/alg.find/find_if.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator Iter, Predicate<auto, Iter::value_type> Pred>
+// requires CopyConstructible<Pred>
+// Iter
+// find_if(Iter first, Iter last, Pred pred);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "test_iterators.h"
+
+int main()
+{
+ int ia[] = {0, 1, 2, 3, 4, 5};
+ const unsigned s = sizeof(ia)/sizeof(ia[0]);
+ input_iterator<const int*> r = std::find_if(input_iterator<const int*>(ia),
+ input_iterator<const int*>(ia+s),
+ std::bind2nd(std::equal_to<int>(), 3));
+ assert(*r == 3);
+ r = std::find_if(input_iterator<const int*>(ia),
+ input_iterator<const int*>(ia+s),
+ std::bind2nd(std::equal_to<int>(), 10));
+ assert(r == input_iterator<const int*>(ia+s));
+}
diff --git a/test/std/algorithms/alg.nonmodifying/alg.find/find_if_not.pass.cpp b/test/std/algorithms/alg.nonmodifying/alg.find/find_if_not.pass.cpp
new file mode 100644
index 000000000000..661e643f07d1
--- /dev/null
+++ b/test/std/algorithms/alg.nonmodifying/alg.find/find_if_not.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator Iter, Predicate<auto, Iter::value_type> Pred>
+// requires CopyConstructible<Pred>
+// Iter
+// find_if_not(Iter first, Iter last, Pred pred);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "test_iterators.h"
+
+int main()
+{
+ int ia[] = {0, 1, 2, 3, 4, 5};
+ const unsigned s = sizeof(ia)/sizeof(ia[0]);
+ input_iterator<const int*> r = std::find_if_not(input_iterator<const int*>(ia),
+ input_iterator<const int*>(ia+s),
+ std::bind2nd(std::not_equal_to<int>(), 3));
+ assert(*r == 3);
+ r = std::find_if_not(input_iterator<const int*>(ia),
+ input_iterator<const int*>(ia+s),
+ std::bind2nd(std::not_equal_to<int>(), 10));
+ assert(r == input_iterator<const int*>(ia+s));
+}
diff --git a/test/std/algorithms/alg.nonmodifying/alg.foreach/test.pass.cpp b/test/std/algorithms/alg.nonmodifying/alg.foreach/test.pass.cpp
new file mode 100644
index 000000000000..bf80c2c6edd4
--- /dev/null
+++ b/test/std/algorithms/alg.nonmodifying/alg.foreach/test.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator Iter, Callable<auto, Iter::reference> Function>
+// requires CopyConstructible<Function>
+// Function
+// for_each(Iter first, Iter last, Function f);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+struct for_each_test
+{
+ for_each_test(int c) : count(c) {}
+ int count;
+ void operator()(int& i) {++i; ++count;}
+};
+
+int main()
+{
+ int ia[] = {0, 1, 2, 3, 4, 5};
+ const unsigned s = sizeof(ia)/sizeof(ia[0]);
+ for_each_test f = std::for_each(input_iterator<int*>(ia),
+ input_iterator<int*>(ia+s),
+ for_each_test(0));
+ assert(f.count == s);
+ for (unsigned i = 0; i < s; ++i)
+ assert(ia[i] == i+1);
+}
diff --git a/test/std/algorithms/alg.nonmodifying/alg.is_permutation/is_permutation.pass.cpp b/test/std/algorithms/alg.nonmodifying/alg.is_permutation/is_permutation.pass.cpp
new file mode 100644
index 000000000000..028aec5e7f29
--- /dev/null
+++ b/test/std/algorithms/alg.nonmodifying/alg.is_permutation/is_permutation.pass.cpp
@@ -0,0 +1,605 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<class ForwardIterator1, class ForwardIterator2>
+// bool
+// is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
+// ForwardIterator2 first2);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+#if _LIBCPP_STD_VER > 11
+#define HAS_FOUR_ITERATOR_VERSION
+#endif
+
+int main()
+{
+ {
+ const int ia[] = {0};
+ const int ib[] = {0};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + 0),
+ forward_iterator<const int*>(ib)) == true);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + 0),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + 0)) == true);
+#endif
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib)) == true);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa)) == true);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa - 1)) == false);
+#endif
+ }
+ {
+ const int ia[] = {0};
+ const int ib[] = {1};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib)) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa)) == false);
+#endif
+ }
+
+ {
+ const int ia[] = {0, 0};
+ const int ib[] = {0, 0};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib)) == true);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa)) == true);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa - 1)) == false);
+#endif
+ }
+ {
+ const int ia[] = {0, 0};
+ const int ib[] = {0, 1};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib)) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa)) == false);
+#endif
+ }
+ {
+ const int ia[] = {0, 0};
+ const int ib[] = {1, 0};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib)) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa)) == false);
+#endif
+ }
+ {
+ const int ia[] = {0, 0};
+ const int ib[] = {1, 1};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib)) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa)) == false);
+#endif
+ }
+ {
+ const int ia[] = {0, 1};
+ const int ib[] = {0, 0};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib)) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa)) == false);
+#endif
+ }
+ {
+ const int ia[] = {0, 1};
+ const int ib[] = {0, 1};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib)) == true);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa)) == true);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa - 1)) == false);
+#endif
+ }
+ {
+ const int ia[] = {0, 1};
+ const int ib[] = {1, 0};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib)) == true);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa)) == true);
+#endif
+ }
+ {
+ const int ia[] = {0, 1};
+ const int ib[] = {1, 1};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib)) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa)) == false);
+#endif
+ }
+ {
+ const int ia[] = {1, 0};
+ const int ib[] = {0, 0};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib)) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa)) == false);
+#endif
+ }
+ {
+ const int ia[] = {1, 0};
+ const int ib[] = {0, 1};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib)) == true);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa)) == true);
+#endif
+ }
+ {
+ const int ia[] = {1, 0};
+ const int ib[] = {1, 0};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib)) == true);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa)) == true);
+#endif
+ }
+ {
+ const int ia[] = {1, 0};
+ const int ib[] = {1, 1};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib)) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa)) == false);
+#endif
+ }
+ {
+ const int ia[] = {1, 1};
+ const int ib[] = {0, 0};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib)) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa)) == false);
+#endif
+ }
+ {
+ const int ia[] = {1, 1};
+ const int ib[] = {0, 1};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib)) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa)) == false);
+#endif
+ }
+ {
+ const int ia[] = {1, 1};
+ const int ib[] = {1, 0};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib)) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa)) == false);
+#endif
+ }
+ {
+ const int ia[] = {1, 1};
+ const int ib[] = {1, 1};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib)) == true);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa)) == true);
+#endif
+ }
+
+ {
+ const int ia[] = {0, 0, 0};
+ const int ib[] = {1, 0, 0};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib)) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa)) == false);
+#endif
+ }
+ {
+ const int ia[] = {0, 0, 0};
+ const int ib[] = {1, 0, 1};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib)) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa)) == false);
+#endif
+ }
+ {
+ const int ia[] = {0, 0, 0};
+ const int ib[] = {1, 0, 2};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib)) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa)) == false);
+#endif
+ }
+ {
+ const int ia[] = {0, 0, 0};
+ const int ib[] = {1, 1, 0};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib)) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa)) == false);
+#endif
+ }
+ {
+ const int ia[] = {0, 0, 0};
+ const int ib[] = {1, 1, 1};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib)) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa)) == false);
+#endif
+ }
+ {
+ const int ia[] = {0, 0, 0};
+ const int ib[] = {1, 1, 2};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib)) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa)) == false);
+#endif
+ }
+ {
+ const int ia[] = {0, 0, 0};
+ const int ib[] = {1, 2, 0};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib)) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa)) == false);
+#endif
+ }
+ {
+ const int ia[] = {0, 0, 0};
+ const int ib[] = {1, 2, 1};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib)) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa)) == false);
+#endif
+ }
+ {
+ const int ia[] = {0, 0, 0};
+ const int ib[] = {1, 2, 2};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib)) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa)) == false);
+#endif
+ }
+ {
+ const int ia[] = {0, 0, 1};
+ const int ib[] = {1, 0, 0};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib)) == true);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa)) == true);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa - 1)) == false);
+#endif
+ }
+ {
+ const int ia[] = {0, 0, 1};
+ const int ib[] = {1, 0, 1};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib)) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa)) == false);
+#endif
+ }
+ {
+ const int ia[] = {0, 1, 2};
+ const int ib[] = {1, 0, 2};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib)) == true);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa)) == true);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa - 1)) == false);
+#endif
+ }
+ {
+ const int ia[] = {0, 1, 2};
+ const int ib[] = {1, 2, 0};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib)) == true);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa)) == true);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa - 1)) == false);
+#endif
+ }
+ {
+ const int ia[] = {0, 1, 2};
+ const int ib[] = {2, 1, 0};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib)) == true);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa)) == true);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa - 1)) == false);
+#endif
+ }
+ {
+ const int ia[] = {0, 1, 2};
+ const int ib[] = {2, 0, 1};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib)) == true);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa)) == true);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa - 1)) == false);
+#endif
+ }
+ {
+ const int ia[] = {0, 0, 1};
+ const int ib[] = {1, 0, 1};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib)) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa)) == false);
+#endif
+ }
+ {
+ const int ia[] = {0, 0, 1};
+ const int ib[] = {1, 0, 0};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib)) == true);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa)) == true);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib + 1),
+ forward_iterator<const int*>(ib + sa)) == false);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa - 1)) == false);
+#endif
+ }
+ {
+ const int ia[] = {0, 1, 2, 3, 0, 5, 6, 2, 4, 4};
+ const int ib[] = {4, 2, 3, 0, 1, 4, 0, 5, 6, 2};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib)) == true);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa)) == true);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib + 1 ),
+ forward_iterator<const int*>(ib + sa)) == false);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa - 1)) == false);
+#endif
+ }
+ {
+ const int ia[] = {0, 1, 2, 3, 0, 5, 6, 2, 4, 4};
+ const int ib[] = {4, 2, 3, 0, 1, 4, 0, 5, 6, 0};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib)) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa)) == false);
+#endif
+ }
+}
diff --git a/test/std/algorithms/alg.nonmodifying/alg.is_permutation/is_permutation_pred.pass.cpp b/test/std/algorithms/alg.nonmodifying/alg.is_permutation/is_permutation_pred.pass.cpp
new file mode 100644
index 000000000000..ceb897da5148
--- /dev/null
+++ b/test/std/algorithms/alg.nonmodifying/alg.is_permutation/is_permutation_pred.pass.cpp
@@ -0,0 +1,729 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
+// bool
+// is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
+// ForwardIterator2 first2, BinaryPredicate pred);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "test_iterators.h"
+
+#if _LIBCPP_STD_VER > 11
+#define HAS_FOUR_ITERATOR_VERSION
+#endif
+
+int comparison_count = 0;
+template <typename T>
+bool counting_equals ( const T &a, const T &b ) {
+ ++comparison_count;
+ return a == b;
+ }
+
+
+int main()
+{
+ {
+ const int ia[] = {0};
+ const int ib[] = {0};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + 0),
+ forward_iterator<const int*>(ib),
+ std::equal_to<const int>()) == true);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ std::equal_to<const int>()) == true);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa),
+ std::equal_to<const int>()) == true);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa - 1),
+ std::equal_to<const int>()) == false);
+#endif
+ }
+ {
+ const int ia[] = {0};
+ const int ib[] = {1};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ std::equal_to<const int>()) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa),
+ std::equal_to<const int>()) == false);
+#endif
+ }
+
+ {
+ const int ia[] = {0, 0};
+ const int ib[] = {0, 0};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ std::equal_to<const int>()) == true);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa),
+ std::equal_to<const int>()) == true);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa - 1),
+ std::equal_to<const int>()) == false);
+#endif
+ }
+ {
+ const int ia[] = {0, 0};
+ const int ib[] = {0, 1};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ std::equal_to<const int>()) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa),
+ std::equal_to<const int>()) == false);
+#endif
+ }
+ {
+ const int ia[] = {0, 0};
+ const int ib[] = {1, 0};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ std::equal_to<const int>()) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa),
+ std::equal_to<const int>()) == false);
+#endif
+ }
+ {
+ const int ia[] = {0, 0};
+ const int ib[] = {1, 1};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ std::equal_to<const int>()) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa),
+ std::equal_to<const int>()) == false);
+#endif
+ }
+ {
+ const int ia[] = {0, 1};
+ const int ib[] = {0, 0};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ std::equal_to<const int>()) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa),
+ std::equal_to<const int>()) == false);
+#endif
+ }
+ {
+ const int ia[] = {0, 1};
+ const int ib[] = {0, 1};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ std::equal_to<const int>()) == true);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa),
+ std::equal_to<const int>()) == true);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa - 1),
+ std::equal_to<const int>()) == false);
+#endif
+ }
+ {
+ const int ia[] = {0, 1};
+ const int ib[] = {1, 0};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ std::equal_to<const int>()) == true);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa),
+ std::equal_to<const int>()) == true);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa - 1),
+ std::equal_to<const int>()) == false);
+#endif
+ }
+ {
+ const int ia[] = {0, 1};
+ const int ib[] = {1, 1};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ std::equal_to<const int>()) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa),
+ std::equal_to<const int>()) == false);
+#endif
+ }
+ {
+ const int ia[] = {1, 0};
+ const int ib[] = {0, 0};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ std::equal_to<const int>()) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa),
+ std::equal_to<const int>()) == false);
+#endif
+ }
+ {
+ const int ia[] = {1, 0};
+ const int ib[] = {0, 1};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ std::equal_to<const int>()) == true);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa),
+ std::equal_to<const int>()) == true);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa - 1),
+ std::equal_to<const int>()) == false);
+#endif
+ }
+ {
+ const int ia[] = {1, 0};
+ const int ib[] = {1, 0};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ std::equal_to<const int>()) == true);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa),
+ std::equal_to<const int>()) == true);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa - 1),
+ std::equal_to<const int>()) == false);
+#endif
+ }
+ {
+ const int ia[] = {1, 0};
+ const int ib[] = {1, 1};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ std::equal_to<const int>()) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa),
+ std::equal_to<const int>()) == false);
+#endif
+ }
+ {
+ const int ia[] = {1, 1};
+ const int ib[] = {0, 0};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ std::equal_to<const int>()) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa),
+ std::equal_to<const int>()) == false);
+#endif
+ }
+ {
+ const int ia[] = {1, 1};
+ const int ib[] = {0, 1};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ std::equal_to<const int>()) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa),
+ std::equal_to<const int>()) == false);
+#endif
+ }
+ {
+ const int ia[] = {1, 1};
+ const int ib[] = {1, 0};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ std::equal_to<const int>()) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa),
+ std::equal_to<const int>()) == false);
+#endif
+ }
+ {
+ const int ia[] = {1, 1};
+ const int ib[] = {1, 1};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ std::equal_to<const int>()) == true);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa),
+ std::equal_to<const int>()) == true);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa - 1),
+ std::equal_to<const int>()) == false);
+#endif
+ }
+
+ {
+ const int ia[] = {0, 0, 0};
+ const int ib[] = {1, 0, 0};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ std::equal_to<const int>()) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa),
+ std::equal_to<const int>()) == false);
+#endif
+ }
+ {
+ const int ia[] = {0, 0, 0};
+ const int ib[] = {1, 0, 1};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ std::equal_to<const int>()) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa),
+ std::equal_to<const int>()) == false);
+#endif
+ }
+ {
+ const int ia[] = {0, 0, 0};
+ const int ib[] = {1, 0, 2};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ std::equal_to<const int>()) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa),
+ std::equal_to<const int>()) == false);
+#endif
+ }
+ {
+ const int ia[] = {0, 0, 0};
+ const int ib[] = {1, 1, 0};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ std::equal_to<const int>()) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa),
+ std::equal_to<const int>()) == false);
+#endif
+ }
+ {
+ const int ia[] = {0, 0, 0};
+ const int ib[] = {1, 1, 1};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ std::equal_to<const int>()) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa),
+ std::equal_to<const int>()) == false);
+#endif
+ }
+ {
+ const int ia[] = {0, 0, 0};
+ const int ib[] = {1, 1, 2};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ std::equal_to<const int>()) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa),
+ std::equal_to<const int>()) == false);
+#endif
+ }
+ {
+ const int ia[] = {0, 0, 0};
+ const int ib[] = {1, 2, 0};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ std::equal_to<const int>()) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa),
+ std::equal_to<const int>()) == false);
+#endif
+ }
+ {
+ const int ia[] = {0, 0, 0};
+ const int ib[] = {1, 2, 1};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ std::equal_to<const int>()) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa),
+ std::equal_to<const int>()) == false);
+#endif
+ }
+ {
+ const int ia[] = {0, 0, 0};
+ const int ib[] = {1, 2, 2};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ std::equal_to<const int>()) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa),
+ std::equal_to<const int>()) == false);
+#endif
+ }
+ {
+ const int ia[] = {0, 0, 1};
+ const int ib[] = {1, 0, 0};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ std::equal_to<const int>()) == true);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa),
+ std::equal_to<const int>()) == true);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa - 1),
+ std::equal_to<const int>()) == false);
+#endif
+ }
+ {
+ const int ia[] = {0, 0, 1};
+ const int ib[] = {1, 0, 1};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ std::equal_to<const int>()) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa),
+ std::equal_to<const int>()) == false);
+#endif
+ }
+ {
+ const int ia[] = {0, 1, 2};
+ const int ib[] = {1, 0, 2};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ std::equal_to<const int>()) == true);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa),
+ std::equal_to<const int>()) == true);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa - 1),
+ std::equal_to<const int>()) == false);
+#endif
+ }
+ {
+ const int ia[] = {0, 1, 2};
+ const int ib[] = {1, 2, 0};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ std::equal_to<const int>()) == true);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa),
+ std::equal_to<const int>()) == true);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa - 1),
+ std::equal_to<const int>()) == false);
+#endif
+ }
+ {
+ const int ia[] = {0, 1, 2};
+ const int ib[] = {2, 1, 0};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ std::equal_to<const int>()) == true);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa),
+ std::equal_to<const int>()) == true);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa - 1),
+ std::equal_to<const int>()) == false);
+#endif
+ }
+ {
+ const int ia[] = {0, 1, 2};
+ const int ib[] = {2, 0, 1};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ std::equal_to<const int>()) == true);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa),
+ std::equal_to<const int>()) == true);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa - 1),
+ std::equal_to<const int>()) == false);
+#endif
+ }
+ {
+ const int ia[] = {0, 0, 1};
+ const int ib[] = {1, 0, 1};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ std::equal_to<const int>()) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa),
+ std::equal_to<const int>()) == false);
+#endif
+ }
+ {
+ const int ia[] = {0, 0, 1};
+ const int ib[] = {1, 0, 0};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ std::equal_to<const int>()) == true);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa),
+ std::equal_to<const int>()) == true);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib + 1),
+ forward_iterator<const int*>(ib + sa),
+ std::equal_to<const int>()) == false);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa - 1),
+ std::equal_to<const int>()) == false);
+#endif
+ }
+ {
+ const int ia[] = {0, 1, 2, 3, 0, 5, 6, 2, 4, 4};
+ const int ib[] = {4, 2, 3, 0, 1, 4, 0, 5, 6, 2};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ std::equal_to<const int>()) == true);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa),
+ std::equal_to<const int>()) == true);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib + 1),
+ forward_iterator<const int*>(ib + sa),
+ std::equal_to<const int>()) == false);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa - 1),
+ std::equal_to<const int>()) == false);
+ comparison_count = 0;
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa - 1),
+ counting_equals<const int>) == false);
+ assert ( comparison_count > 0 );
+ comparison_count = 0;
+ assert(std::is_permutation(random_access_iterator<const int*>(ia),
+ random_access_iterator<const int*>(ia + sa),
+ random_access_iterator<const int*>(ib),
+ random_access_iterator<const int*>(ib + sa - 1),
+ counting_equals<const int>) == false);
+ assert ( comparison_count == 0 );
+#endif
+ }
+ {
+ const int ia[] = {0, 1, 2, 3, 0, 5, 6, 2, 4, 4};
+ const int ib[] = {4, 2, 3, 0, 1, 4, 0, 5, 6, 0};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ std::equal_to<const int>()) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(std::is_permutation(forward_iterator<const int*>(ia),
+ forward_iterator<const int*>(ia + sa),
+ forward_iterator<const int*>(ib),
+ forward_iterator<const int*>(ib + sa),
+ std::equal_to<const int>()) == false);
+#endif
+ }
+}
diff --git a/test/std/algorithms/alg.nonmodifying/alg.none_of/none_of.pass.cpp b/test/std/algorithms/alg.nonmodifying/alg.none_of/none_of.pass.cpp
new file mode 100644
index 000000000000..f4ea161891b2
--- /dev/null
+++ b/test/std/algorithms/alg.nonmodifying/alg.none_of/none_of.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template <class InputIterator, class Predicate>
+// bool
+// none_of(InputIterator first, InputIterator last, Predicate pred);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+struct test1
+{
+ bool operator()(const int& i) const
+ {
+ return i % 2 == 0;
+ }
+};
+
+int main()
+{
+ {
+ int ia[] = {2, 4, 6, 8};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::none_of(input_iterator<const int*>(ia),
+ input_iterator<const int*>(ia + sa), test1()) == false);
+ assert(std::none_of(input_iterator<const int*>(ia),
+ input_iterator<const int*>(ia), test1()) == true);
+ }
+ {
+ const int ia[] = {2, 4, 5, 8};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::none_of(input_iterator<const int*>(ia),
+ input_iterator<const int*>(ia + sa), test1()) == false);
+ assert(std::none_of(input_iterator<const int*>(ia),
+ input_iterator<const int*>(ia), test1()) == true);
+ }
+ {
+ const int ia[] = {1, 3, 5, 7};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::none_of(input_iterator<const int*>(ia),
+ input_iterator<const int*>(ia + sa), test1()) == true);
+ assert(std::none_of(input_iterator<const int*>(ia),
+ input_iterator<const int*>(ia), test1()) == true);
+ }
+}
diff --git a/test/std/algorithms/alg.nonmodifying/alg.search/search.pass.cpp b/test/std/algorithms/alg.nonmodifying/alg.search/search.pass.cpp
new file mode 100644
index 000000000000..e5c2dd29d11f
--- /dev/null
+++ b/test/std/algorithms/alg.nonmodifying/alg.search/search.pass.cpp
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter1, ForwardIterator Iter2>
+// requires HasEqualTo<Iter1::value_type, Iter2::value_type>
+// Iter1
+// search(Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter1, class Iter2>
+void
+test()
+{
+ int ia[] = {0, 1, 2, 3, 4, 5};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia)) == Iter1(ia));
+ assert(std::search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+1)) == Iter1(ia));
+ assert(std::search(Iter1(ia), Iter1(ia+sa), Iter2(ia+1), Iter2(ia+2)) == Iter1(ia+1));
+ assert(std::search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+2)) == Iter1(ia));
+ assert(std::search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+3)) == Iter1(ia+2));
+ assert(std::search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+3)) == Iter1(ia+2));
+ assert(std::search(Iter1(ia), Iter1(ia), Iter2(ia+2), Iter2(ia+3)) == Iter1(ia));
+ assert(std::search(Iter1(ia), Iter1(ia+sa), Iter2(ia+sa-1), Iter2(ia+sa)) == Iter1(ia+sa-1));
+ assert(std::search(Iter1(ia), Iter1(ia+sa), Iter2(ia+sa-3), Iter2(ia+sa)) == Iter1(ia+sa-3));
+ assert(std::search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+sa)) == Iter1(ia));
+ assert(std::search(Iter1(ia), Iter1(ia+sa-1), Iter2(ia), Iter2(ia+sa)) == Iter1(ia+sa-1));
+ assert(std::search(Iter1(ia), Iter1(ia+1), Iter2(ia), Iter2(ia+sa)) == Iter1(ia+1));
+ int ib[] = {0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4};
+ const unsigned sb = sizeof(ib)/sizeof(ib[0]);
+ int ic[] = {1};
+ assert(std::search(Iter1(ib), Iter1(ib+sb), Iter2(ic), Iter2(ic+1)) == Iter1(ib+1));
+ int id[] = {1, 2};
+ assert(std::search(Iter1(ib), Iter1(ib+sb), Iter2(id), Iter2(id+2)) == Iter1(ib+1));
+ int ie[] = {1, 2, 3};
+ assert(std::search(Iter1(ib), Iter1(ib+sb), Iter2(ie), Iter2(ie+3)) == Iter1(ib+4));
+ int ig[] = {1, 2, 3, 4};
+ assert(std::search(Iter1(ib), Iter1(ib+sb), Iter2(ig), Iter2(ig+4)) == Iter1(ib+8));
+ int ih[] = {0, 1, 1, 1, 1, 2, 3, 0, 1, 2, 3, 4};
+ const unsigned sh = sizeof(ih)/sizeof(ih[0]);
+ int ii[] = {1, 1, 2};
+ assert(std::search(Iter1(ih), Iter1(ih+sh), Iter2(ii), Iter2(ii+3)) == Iter1(ih+3));
+ int ij[] = {0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0};
+ const unsigned sj = sizeof(ij)/sizeof(ij[0]);
+ int ik[] = {0, 0, 0, 0, 1, 1, 1, 1, 0, 0};
+ const unsigned sk = sizeof(ik)/sizeof(ik[0]);
+ assert(std::search(Iter1(ij), Iter1(ij+sj), Iter2(ik), Iter2(ik+sk)) == Iter1(ij+6));
+}
+
+int main()
+{
+ test<forward_iterator<const int*>, forward_iterator<const int*> >();
+ test<forward_iterator<const int*>, bidirectional_iterator<const int*> >();
+ test<forward_iterator<const int*>, random_access_iterator<const int*> >();
+ test<bidirectional_iterator<const int*>, forward_iterator<const int*> >();
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*> >();
+ test<bidirectional_iterator<const int*>, random_access_iterator<const int*> >();
+ test<random_access_iterator<const int*>, forward_iterator<const int*> >();
+ test<random_access_iterator<const int*>, bidirectional_iterator<const int*> >();
+ test<random_access_iterator<const int*>, random_access_iterator<const int*> >();
+}
diff --git a/test/std/algorithms/alg.nonmodifying/alg.search/search_n.pass.cpp b/test/std/algorithms/alg.nonmodifying/alg.search/search_n.pass.cpp
new file mode 100644
index 000000000000..f7f8ee092796
--- /dev/null
+++ b/test/std/algorithms/alg.nonmodifying/alg.search/search_n.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<class ForwardIterator, class Size, class T>
+// ForwardIterator
+// search_n(ForwardIterator first, ForwardIterator last, Size count,
+// const T& value);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "user_defined_integral.hpp"
+
+template <class Iter>
+void
+test()
+{
+ int ia[] = {0, 1, 2, 3, 4, 5};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ assert(std::search_n(Iter(ia), Iter(ia+sa), 0, 0) == Iter(ia));
+ assert(std::search_n(Iter(ia), Iter(ia+sa), 1, 0) == Iter(ia+0));
+ assert(std::search_n(Iter(ia), Iter(ia+sa), 2, 0) == Iter(ia+sa));
+ assert(std::search_n(Iter(ia), Iter(ia+sa), sa, 0) == Iter(ia+sa));
+ assert(std::search_n(Iter(ia), Iter(ia+sa), 0, 3) == Iter(ia));
+ assert(std::search_n(Iter(ia), Iter(ia+sa), 1, 3) == Iter(ia+3));
+ assert(std::search_n(Iter(ia), Iter(ia+sa), 2, 3) == Iter(ia+sa));
+ assert(std::search_n(Iter(ia), Iter(ia+sa), sa, 3) == Iter(ia+sa));
+ assert(std::search_n(Iter(ia), Iter(ia+sa), 0, 5) == Iter(ia));
+ assert(std::search_n(Iter(ia), Iter(ia+sa), 1, 5) == Iter(ia+5));
+ assert(std::search_n(Iter(ia), Iter(ia+sa), 2, 5) == Iter(ia+sa));
+ assert(std::search_n(Iter(ia), Iter(ia+sa), sa, 5) == Iter(ia+sa));
+
+ int ib[] = {0, 0, 1, 1, 2, 2};
+ const unsigned sb = sizeof(ib)/sizeof(ib[0]);
+ assert(std::search_n(Iter(ib), Iter(ib+sb), 0, 0) == Iter(ib));
+ assert(std::search_n(Iter(ib), Iter(ib+sb), 1, 0) == Iter(ib+0));
+ assert(std::search_n(Iter(ib), Iter(ib+sb), 2, 0) == Iter(ib+0));
+ assert(std::search_n(Iter(ib), Iter(ib+sb), 3, 0) == Iter(ib+sb));
+ assert(std::search_n(Iter(ib), Iter(ib+sb), sb, 0) == Iter(ib+sb));
+ assert(std::search_n(Iter(ib), Iter(ib+sb), 0, 1) == Iter(ib));
+ assert(std::search_n(Iter(ib), Iter(ib+sb), 1, 1) == Iter(ib+2));
+ assert(std::search_n(Iter(ib), Iter(ib+sb), 2, 1) == Iter(ib+2));
+ assert(std::search_n(Iter(ib), Iter(ib+sb), 3, 1) == Iter(ib+sb));
+ assert(std::search_n(Iter(ib), Iter(ib+sb), sb, 1) == Iter(ib+sb));
+ assert(std::search_n(Iter(ib), Iter(ib+sb), 0, 2) == Iter(ib));
+ assert(std::search_n(Iter(ib), Iter(ib+sb), 1, 2) == Iter(ib+4));
+ assert(std::search_n(Iter(ib), Iter(ib+sb), 2, 2) == Iter(ib+4));
+ assert(std::search_n(Iter(ib), Iter(ib+sb), 3, 2) == Iter(ib+sb));
+ assert(std::search_n(Iter(ib), Iter(ib+sb), sb, 2) == Iter(ib+sb));
+
+ int ic[] = {0, 0, 0};
+ const unsigned sc = sizeof(ic)/sizeof(ic[0]);
+ assert(std::search_n(Iter(ic), Iter(ic+sc), 0, 0) == Iter(ic));
+ assert(std::search_n(Iter(ic), Iter(ic+sc), 1, 0) == Iter(ic));
+ assert(std::search_n(Iter(ic), Iter(ic+sc), 2, 0) == Iter(ic));
+ assert(std::search_n(Iter(ic), Iter(ic+sc), 3, 0) == Iter(ic));
+ assert(std::search_n(Iter(ic), Iter(ic+sc), 4, 0) == Iter(ic+sc));
+
+ // Check that we properly convert the size argument to an integral.
+ std::search_n(Iter(ic), Iter(ic+sc), UserDefinedIntegral<unsigned>(0), 0);
+}
+
+int main()
+{
+ test<forward_iterator<const int*> >();
+ test<bidirectional_iterator<const int*> >();
+ test<random_access_iterator<const int*> >();
+}
diff --git a/test/std/algorithms/alg.nonmodifying/alg.search/search_n_pred.pass.cpp b/test/std/algorithms/alg.nonmodifying/alg.search/search_n_pred.pass.cpp
new file mode 100644
index 000000000000..8bc6f4d26bdb
--- /dev/null
+++ b/test/std/algorithms/alg.nonmodifying/alg.search/search_n_pred.pass.cpp
@@ -0,0 +1,154 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<class ForwardIterator, class Size, class T, class BinaryPredicate>
+// ForwardIterator
+// search_n(ForwardIterator first, ForwardIterator last, Size count,
+// const T& value, BinaryPredicate pred);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "user_defined_integral.hpp"
+
+struct count_equal
+{
+ static unsigned count;
+ template <class T>
+ bool operator()(const T& x, const T& y)
+ {++count; return x == y;}
+};
+
+unsigned count_equal::count = 0;
+
+
+template <class Iter>
+void
+test()
+{
+ int ia[] = {0, 1, 2, 3, 4, 5};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ count_equal::count = 0;
+ assert(std::search_n(Iter(ia), Iter(ia+sa), 0, 0, count_equal()) == Iter(ia));
+ assert(count_equal::count <= sa);
+ count_equal::count = 0;
+ assert(std::search_n(Iter(ia), Iter(ia+sa), 1, 0, count_equal()) == Iter(ia+0));
+ assert(count_equal::count <= sa);
+ count_equal::count = 0;
+ assert(std::search_n(Iter(ia), Iter(ia+sa), 2, 0, count_equal()) == Iter(ia+sa));
+ assert(count_equal::count <= sa);
+ count_equal::count = 0;
+ assert(std::search_n(Iter(ia), Iter(ia+sa), sa, 0, count_equal()) == Iter(ia+sa));
+ assert(count_equal::count <= sa);
+ count_equal::count = 0;
+ assert(std::search_n(Iter(ia), Iter(ia+sa), 0, 3, count_equal()) == Iter(ia));
+ assert(count_equal::count <= sa);
+ count_equal::count = 0;
+ assert(std::search_n(Iter(ia), Iter(ia+sa), 1, 3, count_equal()) == Iter(ia+3));
+ assert(count_equal::count <= sa);
+ count_equal::count = 0;
+ assert(std::search_n(Iter(ia), Iter(ia+sa), 2, 3, count_equal()) == Iter(ia+sa));
+ assert(count_equal::count <= sa);
+ count_equal::count = 0;
+ assert(std::search_n(Iter(ia), Iter(ia+sa), sa, 3, count_equal()) == Iter(ia+sa));
+ assert(count_equal::count <= sa);
+ count_equal::count = 0;
+ assert(std::search_n(Iter(ia), Iter(ia+sa), 0, 5, count_equal()) == Iter(ia));
+ assert(count_equal::count <= sa);
+ count_equal::count = 0;
+ assert(std::search_n(Iter(ia), Iter(ia+sa), 1, 5, count_equal()) == Iter(ia+5));
+ assert(count_equal::count <= sa);
+ count_equal::count = 0;
+ assert(std::search_n(Iter(ia), Iter(ia+sa), 2, 5, count_equal()) == Iter(ia+sa));
+ assert(count_equal::count <= sa);
+ count_equal::count = 0;
+ assert(std::search_n(Iter(ia), Iter(ia+sa), sa, 5, count_equal()) == Iter(ia+sa));
+ assert(count_equal::count <= sa);
+ count_equal::count = 0;
+
+ int ib[] = {0, 0, 1, 1, 2, 2};
+ const unsigned sb = sizeof(ib)/sizeof(ib[0]);
+ assert(std::search_n(Iter(ib), Iter(ib+sb), 0, 0, count_equal()) == Iter(ib));
+ assert(count_equal::count <= sb);
+ count_equal::count = 0;
+ assert(std::search_n(Iter(ib), Iter(ib+sb), 1, 0, count_equal()) == Iter(ib+0));
+ assert(count_equal::count <= sb);
+ count_equal::count = 0;
+ assert(std::search_n(Iter(ib), Iter(ib+sb), 2, 0, count_equal()) == Iter(ib+0));
+ assert(count_equal::count <= sb);
+ count_equal::count = 0;
+ assert(std::search_n(Iter(ib), Iter(ib+sb), 3, 0, count_equal()) == Iter(ib+sb));
+ assert(count_equal::count <= sb);
+ count_equal::count = 0;
+ assert(std::search_n(Iter(ib), Iter(ib+sb), sb, 0, count_equal()) == Iter(ib+sb));
+ assert(count_equal::count <= sb);
+ count_equal::count = 0;
+ assert(std::search_n(Iter(ib), Iter(ib+sb), 0, 1, count_equal()) == Iter(ib));
+ assert(count_equal::count <= sb);
+ count_equal::count = 0;
+ assert(std::search_n(Iter(ib), Iter(ib+sb), 1, 1, count_equal()) == Iter(ib+2));
+ assert(count_equal::count <= sb);
+ count_equal::count = 0;
+ assert(std::search_n(Iter(ib), Iter(ib+sb), 2, 1, count_equal()) == Iter(ib+2));
+ assert(count_equal::count <= sb);
+ count_equal::count = 0;
+ assert(std::search_n(Iter(ib), Iter(ib+sb), 3, 1, count_equal()) == Iter(ib+sb));
+ assert(count_equal::count <= sb);
+ count_equal::count = 0;
+ assert(std::search_n(Iter(ib), Iter(ib+sb), sb, 1, count_equal()) == Iter(ib+sb));
+ assert(count_equal::count <= sb);
+ count_equal::count = 0;
+ assert(std::search_n(Iter(ib), Iter(ib+sb), 0, 2, count_equal()) == Iter(ib));
+ assert(count_equal::count <= sb);
+ count_equal::count = 0;
+ assert(std::search_n(Iter(ib), Iter(ib+sb), 1, 2, count_equal()) == Iter(ib+4));
+ assert(count_equal::count <= sb);
+ count_equal::count = 0;
+ assert(std::search_n(Iter(ib), Iter(ib+sb), 2, 2, count_equal()) == Iter(ib+4));
+ assert(count_equal::count <= sb);
+ count_equal::count = 0;
+ assert(std::search_n(Iter(ib), Iter(ib+sb), 3, 2, count_equal()) == Iter(ib+sb));
+ assert(count_equal::count <= sb);
+ count_equal::count = 0;
+ assert(std::search_n(Iter(ib), Iter(ib+sb), sb, 2, count_equal()) == Iter(ib+sb));
+ assert(count_equal::count <= sb);
+ count_equal::count = 0;
+
+ int ic[] = {0, 0, 0};
+ const unsigned sc = sizeof(ic)/sizeof(ic[0]);
+ assert(std::search_n(Iter(ic), Iter(ic+sc), 0, 0, count_equal()) == Iter(ic));
+ assert(count_equal::count <= sc);
+ count_equal::count = 0;
+ assert(std::search_n(Iter(ic), Iter(ic+sc), 1, 0, count_equal()) == Iter(ic));
+ assert(count_equal::count <= sc);
+ count_equal::count = 0;
+ assert(std::search_n(Iter(ic), Iter(ic+sc), 2, 0, count_equal()) == Iter(ic));
+ assert(count_equal::count <= sc);
+ count_equal::count = 0;
+ assert(std::search_n(Iter(ic), Iter(ic+sc), 3, 0, count_equal()) == Iter(ic));
+ assert(count_equal::count <= sc);
+ count_equal::count = 0;
+ assert(std::search_n(Iter(ic), Iter(ic+sc), 4, 0, count_equal()) == Iter(ic+sc));
+ assert(count_equal::count <= sc);
+ count_equal::count = 0;
+
+ // Check that we properly convert the size argument to an integral.
+ std::search_n(Iter(ic), Iter(ic+sc), UserDefinedIntegral<unsigned>(4), 0, count_equal());
+ count_equal::count = 0;
+}
+
+int main()
+{
+ test<forward_iterator<const int*> >();
+ test<bidirectional_iterator<const int*> >();
+ test<random_access_iterator<const int*> >();
+}
diff --git a/test/std/algorithms/alg.nonmodifying/alg.search/search_pred.pass.cpp b/test/std/algorithms/alg.nonmodifying/alg.search/search_pred.pass.cpp
new file mode 100644
index 000000000000..192da03d67b3
--- /dev/null
+++ b/test/std/algorithms/alg.nonmodifying/alg.search/search_pred.pass.cpp
@@ -0,0 +1,111 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter1, ForwardIterator Iter2>
+// requires HasEqualTo<Iter1::value_type, Iter2::value_type>
+// Iter1
+// search(Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+struct count_equal
+{
+ static unsigned count;
+ template <class T>
+ bool operator()(const T& x, const T& y)
+ {++count; return x == y;}
+};
+
+unsigned count_equal::count = 0;
+
+template <class Iter1, class Iter2>
+void
+test()
+{
+ int ia[] = {0, 1, 2, 3, 4, 5};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ count_equal::count = 0;
+ assert(std::search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia), count_equal()) == Iter1(ia));
+ assert(count_equal::count <= 0);
+ count_equal::count = 0;
+ assert(std::search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+1), count_equal()) == Iter1(ia));
+ assert(count_equal::count <= sa);
+ count_equal::count = 0;
+ assert(std::search(Iter1(ia), Iter1(ia+sa), Iter2(ia+1), Iter2(ia+2), count_equal()) == Iter1(ia+1));
+ assert(count_equal::count <= sa);
+ count_equal::count = 0;
+ assert(std::search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+2), count_equal()) == Iter1(ia));
+ assert(count_equal::count <= 0);
+ count_equal::count = 0;
+ assert(std::search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+3), count_equal()) == Iter1(ia+2));
+ assert(count_equal::count <= sa);
+ count_equal::count = 0;
+ assert(std::search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+3), count_equal()) == Iter1(ia+2));
+ assert(count_equal::count <= sa);
+ count_equal::count = 0;
+ assert(std::search(Iter1(ia), Iter1(ia), Iter2(ia+2), Iter2(ia+3), count_equal()) == Iter1(ia));
+ assert(count_equal::count <= 0);
+ count_equal::count = 0;
+ assert(std::search(Iter1(ia), Iter1(ia+sa), Iter2(ia+sa-1), Iter2(ia+sa), count_equal()) == Iter1(ia+sa-1));
+ assert(count_equal::count <= sa);
+ count_equal::count = 0;
+ assert(std::search(Iter1(ia), Iter1(ia+sa), Iter2(ia+sa-3), Iter2(ia+sa), count_equal()) == Iter1(ia+sa-3));
+ assert(count_equal::count <= sa*3);
+ count_equal::count = 0;
+ assert(std::search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+sa), count_equal()) == Iter1(ia));
+ assert(count_equal::count <= sa*sa);
+ count_equal::count = 0;
+ assert(std::search(Iter1(ia), Iter1(ia+sa-1), Iter2(ia), Iter2(ia+sa), count_equal()) == Iter1(ia+sa-1));
+ assert(count_equal::count <= (sa-1)*sa);
+ count_equal::count = 0;
+ assert(std::search(Iter1(ia), Iter1(ia+1), Iter2(ia), Iter2(ia+sa), count_equal()) == Iter1(ia+1));
+ assert(count_equal::count <= sa);
+ count_equal::count = 0;
+ int ib[] = {0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4};
+ const unsigned sb = sizeof(ib)/sizeof(ib[0]);
+ int ic[] = {1};
+ assert(std::search(Iter1(ib), Iter1(ib+sb), Iter2(ic), Iter2(ic+1), count_equal()) == Iter1(ib+1));
+ assert(count_equal::count <= sb);
+ count_equal::count = 0;
+ int id[] = {1, 2};
+ assert(std::search(Iter1(ib), Iter1(ib+sb), Iter2(id), Iter2(id+2), count_equal()) == Iter1(ib+1));
+ assert(count_equal::count <= sb*2);
+ count_equal::count = 0;
+ int ie[] = {1, 2, 3};
+ assert(std::search(Iter1(ib), Iter1(ib+sb), Iter2(ie), Iter2(ie+3), count_equal()) == Iter1(ib+4));
+ assert(count_equal::count <= sb*3);
+ count_equal::count = 0;
+ int ig[] = {1, 2, 3, 4};
+ assert(std::search(Iter1(ib), Iter1(ib+sb), Iter2(ig), Iter2(ig+4), count_equal()) == Iter1(ib+8));
+ assert(count_equal::count <= sb*4);
+ count_equal::count = 0;
+ int ih[] = {0, 1, 1, 1, 1, 2, 3, 0, 1, 2, 3, 4};
+ const unsigned sh = sizeof(ih)/sizeof(ih[0]);
+ int ii[] = {1, 1, 2};
+ assert(std::search(Iter1(ih), Iter1(ih+sh), Iter2(ii), Iter2(ii+3), count_equal()) == Iter1(ih+3));
+ assert(count_equal::count <= sh*3);
+}
+
+int main()
+{
+ test<forward_iterator<const int*>, forward_iterator<const int*> >();
+ test<forward_iterator<const int*>, bidirectional_iterator<const int*> >();
+ test<forward_iterator<const int*>, random_access_iterator<const int*> >();
+ test<bidirectional_iterator<const int*>, forward_iterator<const int*> >();
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*> >();
+ test<bidirectional_iterator<const int*>, random_access_iterator<const int*> >();
+ test<random_access_iterator<const int*>, forward_iterator<const int*> >();
+ test<random_access_iterator<const int*>, bidirectional_iterator<const int*> >();
+ test<random_access_iterator<const int*>, random_access_iterator<const int*> >();
+}
diff --git a/test/std/algorithms/alg.nonmodifying/mismatch/mismatch.pass.cpp b/test/std/algorithms/alg.nonmodifying/mismatch/mismatch.pass.cpp
new file mode 100644
index 000000000000..abc89dc56097
--- /dev/null
+++ b/test/std/algorithms/alg.nonmodifying/mismatch/mismatch.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator Iter1, InputIterator Iter2>
+// requires HasEqualTo<Iter1::value_type, Iter2::value_type>
+// pair<Iter1, Iter2>
+// mismatch(Iter1 first1, Iter1 last1, Iter2 first2);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+#if _LIBCPP_STD_VER > 11
+#define HAS_FOUR_ITERATOR_VERSION
+#endif
+
+int main()
+{
+ int ia[] = {0, 1, 2, 2, 0, 1, 2, 3};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ int ib[] = {0, 1, 2, 3, 0, 1, 2, 3};
+ const unsigned sb = sizeof(ib)/sizeof(ib[0]);
+
+ typedef input_iterator<const int*> II;
+ typedef random_access_iterator<const int*> RAI;
+
+ assert(std::mismatch(II(ia), II(ia + sa), II(ib))
+ == (std::pair<II, II>(II(ia+3), II(ib+3))));
+
+ assert(std::mismatch(RAI(ia), RAI(ia + sa), RAI(ib))
+ == (std::pair<RAI, RAI>(RAI(ia+3), RAI(ib+3))));
+
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(std::mismatch(II(ia), II(ia + sa), II(ib), II(ib+sb))
+ == (std::pair<II, II>(II(ia+3), II(ib+3))));
+
+ assert(std::mismatch(RAI(ia), RAI(ia + sa), RAI(ib), RAI(ib+sb))
+ == (std::pair<RAI, RAI>(RAI(ia+3), RAI(ib+3))));
+
+
+ assert(std::mismatch(II(ia), II(ia + sa), II(ib), II(ib+2))
+ == (std::pair<II, II>(II(ia+2), II(ib+2))));
+#endif
+}
diff --git a/test/std/algorithms/alg.nonmodifying/mismatch/mismatch_pred.pass.cpp b/test/std/algorithms/alg.nonmodifying/mismatch/mismatch_pred.pass.cpp
new file mode 100644
index 000000000000..8d85d993cd61
--- /dev/null
+++ b/test/std/algorithms/alg.nonmodifying/mismatch/mismatch_pred.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator Iter1, InputIterator Iter2,
+// Predicate<auto, Iter1::value_type, Iter2::value_type> Pred>
+// requires CopyConstructible<Pred>
+// pair<Iter1, Iter2>
+// mismatch(Iter1 first1, Iter1 last1, Iter2 first2, Pred pred);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "counting_predicates.hpp"
+
+#if _LIBCPP_STD_VER > 11
+#define HAS_FOUR_ITERATOR_VERSION
+#endif
+
+int main()
+{
+ int ia[] = {0, 1, 2, 2, 0, 1, 2, 3};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ int ib[] = {0, 1, 2, 3, 0, 1, 2, 3};
+ const unsigned sb = sizeof(ib)/sizeof(ib[0]);
+
+ typedef input_iterator<const int*> II;
+ typedef random_access_iterator<const int*> RAI;
+ typedef std::equal_to<int> EQ;
+
+ assert(std::mismatch(II(ia), II(ia + sa), II(ib), EQ())
+ == (std::pair<II, II>(II(ia+3), II(ib+3))));
+ assert(std::mismatch(RAI(ia), RAI(ia + sa), RAI(ib), EQ())
+ == (std::pair<RAI, RAI>(RAI(ia+3), RAI(ib+3))));
+
+ binary_counting_predicate<EQ, int> bcp((EQ()));
+ assert(std::mismatch(RAI(ia), RAI(ia + sa), RAI(ib), std::ref(bcp))
+ == (std::pair<RAI, RAI>(RAI(ia+3), RAI(ib+3))));
+ assert(bcp.count() > 0 && bcp.count() < sa);
+ bcp.reset();
+
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(std::mismatch(II(ia), II(ia + sa), II(ib), II(ib + sb), EQ())
+ == (std::pair<II, II>(II(ia+3), II(ib+3))));
+ assert(std::mismatch(RAI(ia), RAI(ia + sa), RAI(ib), RAI(ib + sb), EQ())
+ == (std::pair<RAI, RAI>(RAI(ia+3), RAI(ib+3))));
+
+ assert(std::mismatch(II(ia), II(ia + sa), II(ib), II(ib + sb), std::ref(bcp))
+ == (std::pair<II, II>(II(ia+3), II(ib+3))));
+ assert(bcp.count() > 0 && bcp.count() < std::min(sa, sb));
+#endif
+
+ assert(std::mismatch(ia, ia + sa, ib, EQ()) ==
+ (std::pair<int*,int*>(ia+3,ib+3)));
+
+#ifdef HAS_FOUR_ITERATOR_VERSION
+ assert(std::mismatch(ia, ia + sa, ib, ib + sb, EQ()) ==
+ (std::pair<int*,int*>(ia+3,ib+3)));
+ assert(std::mismatch(ia, ia + sa, ib, ib + 2, EQ()) ==
+ (std::pair<int*,int*>(ia+2,ib+2)));
+#endif
+}
diff --git a/test/std/algorithms/alg.nonmodifying/nothing_to_do.pass.cpp b/test/std/algorithms/alg.nonmodifying/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/algorithms/alg.nonmodifying/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/algorithms/alg.sorting/alg.binary.search/binary.search/binary_search.pass.cpp b/test/std/algorithms/alg.sorting/alg.binary.search/binary.search/binary_search.pass.cpp
new file mode 100644
index 000000000000..253e0e38690b
--- /dev/null
+++ b/test/std/algorithms/alg.sorting/alg.binary.search/binary.search/binary_search.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter, class T>
+// requires HasLess<T, Iter::value_type>
+// && HasLess<Iter::value_type, T>
+// bool
+// binary_search(Iter first, Iter last, const T& value);
+
+#include <algorithm>
+#include <vector>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter, class T>
+void
+test(Iter first, Iter last, const T& value, bool x)
+{
+ assert(std::binary_search(first, last, value) == x);
+}
+
+template <class Iter>
+void
+test()
+{
+ const unsigned N = 1000;
+ const unsigned M = 10;
+ std::vector<int> v(N);
+ int x = 0;
+ for (int i = 0; i < v.size(); ++i)
+ {
+ v[i] = x;
+ if (++x == M)
+ x = 0;
+ }
+ std::sort(v.begin(), v.end());
+ for (x = 0; x < M; ++x)
+ test(Iter(v.data()), Iter(v.data()+v.size()), x, true);
+ test(Iter(v.data()), Iter(v.data()+v.size()), -1, false);
+ test(Iter(v.data()), Iter(v.data()+v.size()), M, false);
+}
+
+int main()
+{
+ int d[] = {0, 2, 4, 6};
+ for (int* e = d; e <= d+4; ++e)
+ for (int x = -1; x <= 7; ++x)
+ test(d, e, x, (x % 2 == 0) && ((e-d)*2 > x));
+
+ test<forward_iterator<const int*> >();
+ test<bidirectional_iterator<const int*> >();
+ test<random_access_iterator<const int*> >();
+ test<const int*>();
+}
diff --git a/test/std/algorithms/alg.sorting/alg.binary.search/binary.search/binary_search_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.binary.search/binary.search/binary_search_comp.pass.cpp
new file mode 100644
index 000000000000..1d2840921e83
--- /dev/null
+++ b/test/std/algorithms/alg.sorting/alg.binary.search/binary.search/binary_search_comp.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter, class T, CopyConstructible Compare>
+// requires Predicate<Compare, T, Iter::value_type>
+// && Predicate<Compare, Iter::value_type, T>
+// bool
+// binary_search(Iter first, Iter last, const T& value, Compare comp);
+
+#include <algorithm>
+#include <vector>
+#include <functional>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter, class T>
+void
+test(Iter first, Iter last, const T& value, bool x)
+{
+ assert(std::binary_search(first, last, value, std::greater<int>()) == x);
+}
+
+template <class Iter>
+void
+test()
+{
+ const unsigned N = 1000;
+ const unsigned M = 10;
+ std::vector<int> v(N);
+ int x = 0;
+ for (int i = 0; i < v.size(); ++i)
+ {
+ v[i] = x;
+ if (++x == M)
+ x = 0;
+ }
+ std::sort(v.begin(), v.end(), std::greater<int>());
+ for (x = 0; x < M; ++x)
+ test(Iter(v.data()), Iter(v.data()+v.size()), x, true);
+ test(Iter(v.data()), Iter(v.data()+v.size()), -1, false);
+ test(Iter(v.data()), Iter(v.data()+v.size()), M, false);
+}
+
+int main()
+{
+ int d[] = {6, 4, 2, 0};
+ for (int* e = d; e <= d+4; ++e)
+ for (int x = -1; x <= 7; ++x)
+ test(d, e, x, (x % 2 == 0) && e != d && (-2*(e-d) + 8 <= x));
+
+ test<forward_iterator<const int*> >();
+ test<bidirectional_iterator<const int*> >();
+ test<random_access_iterator<const int*> >();
+ test<const int*>();
+}
diff --git a/test/std/algorithms/alg.sorting/alg.binary.search/equal.range/equal_range.pass.cpp b/test/std/algorithms/alg.sorting/alg.binary.search/equal.range/equal_range.pass.cpp
new file mode 100644
index 000000000000..ce659c1b50f5
--- /dev/null
+++ b/test/std/algorithms/alg.sorting/alg.binary.search/equal.range/equal_range.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter, class T>
+// requires HasLess<T, Iter::value_type>
+// && HasLess<Iter::value_type, T>
+// pair<Iter, Iter>
+// equal_range(Iter first, Iter last, const T& value);
+
+#include <algorithm>
+#include <vector>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter, class T>
+void
+test(Iter first, Iter last, const T& value)
+{
+ std::pair<Iter, Iter> i = std::equal_range(first, last, value);
+ for (Iter j = first; j != i.first; ++j)
+ assert(*j < value);
+ for (Iter j = i.first; j != last; ++j)
+ assert(!(*j < value));
+ for (Iter j = first; j != i.second; ++j)
+ assert(!(value < *j));
+ for (Iter j = i.second; j != last; ++j)
+ assert(value < *j);
+}
+
+template <class Iter>
+void
+test()
+{
+ const unsigned N = 1000;
+ const unsigned M = 10;
+ std::vector<int> v(N);
+ int x = 0;
+ for (int i = 0; i < v.size(); ++i)
+ {
+ v[i] = x;
+ if (++x == M)
+ x = 0;
+ }
+ std::sort(v.begin(), v.end());
+ for (x = 0; x <= M; ++x)
+ test(Iter(v.data()), Iter(v.data()+v.size()), x);
+}
+
+int main()
+{
+ int d[] = {0, 1, 2, 3};
+ for (int* e = d; e <= d+4; ++e)
+ for (int x = -1; x <= 4; ++x)
+ test(d, e, x);
+
+ test<forward_iterator<const int*> >();
+ test<bidirectional_iterator<const int*> >();
+ test<random_access_iterator<const int*> >();
+ test<const int*>();
+}
diff --git a/test/std/algorithms/alg.sorting/alg.binary.search/equal.range/equal_range_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.binary.search/equal.range/equal_range_comp.pass.cpp
new file mode 100644
index 000000000000..2b29e2c84353
--- /dev/null
+++ b/test/std/algorithms/alg.sorting/alg.binary.search/equal.range/equal_range_comp.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter, class T, CopyConstructible Compare>
+// requires Predicate<Compare, T, Iter::value_type>
+// && Predicate<Compare, Iter::value_type, T>
+// pair<Iter, Iter>
+// equal_range(Iter first, Iter last, const T& value, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <vector>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter, class T>
+void
+test(Iter first, Iter last, const T& value)
+{
+ std::pair<Iter, Iter> i = std::equal_range(first, last, value, std::greater<int>());
+ for (Iter j = first; j != i.first; ++j)
+ assert(std::greater<int>()(*j, value));
+ for (Iter j = i.first; j != last; ++j)
+ assert(!std::greater<int>()(*j, value));
+ for (Iter j = first; j != i.second; ++j)
+ assert(!std::greater<int>()(value, *j));
+ for (Iter j = i.second; j != last; ++j)
+ assert(std::greater<int>()(value, *j));
+}
+
+template <class Iter>
+void
+test()
+{
+ const unsigned N = 1000;
+ const unsigned M = 10;
+ std::vector<int> v(N);
+ int x = 0;
+ for (int i = 0; i < v.size(); ++i)
+ {
+ v[i] = x;
+ if (++x == M)
+ x = 0;
+ }
+ std::sort(v.begin(), v.end(), std::greater<int>());
+ for (x = 0; x <= M; ++x)
+ test(Iter(v.data()), Iter(v.data()+v.size()), x);
+}
+
+int main()
+{
+ int d[] = {3, 2, 1, 0};
+ for (int* e = d; e <= d+4; ++e)
+ for (int x = -1; x <= 4; ++x)
+ test(d, e, x);
+
+ test<forward_iterator<const int*> >();
+ test<bidirectional_iterator<const int*> >();
+ test<random_access_iterator<const int*> >();
+ test<const int*>();
+}
diff --git a/test/std/algorithms/alg.sorting/alg.binary.search/lower.bound/lower_bound.pass.cpp b/test/std/algorithms/alg.sorting/alg.binary.search/lower.bound/lower_bound.pass.cpp
new file mode 100644
index 000000000000..ce4f7ced5e63
--- /dev/null
+++ b/test/std/algorithms/alg.sorting/alg.binary.search/lower.bound/lower_bound.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter, class T>
+// requires HasLess<Iter::value_type, T>
+// Iter
+// lower_bound(Iter first, Iter last, const T& value);
+
+#include <algorithm>
+#include <vector>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter, class T>
+void
+test(Iter first, Iter last, const T& value)
+{
+ Iter i = std::lower_bound(first, last, value);
+ for (Iter j = first; j != i; ++j)
+ assert(*j < value);
+ for (Iter j = i; j != last; ++j)
+ assert(!(*j < value));
+}
+
+template <class Iter>
+void
+test()
+{
+ const unsigned N = 1000;
+ const unsigned M = 10;
+ std::vector<int> v(N);
+ int x = 0;
+ for (int i = 0; i < v.size(); ++i)
+ {
+ v[i] = x;
+ if (++x == M)
+ x = 0;
+ }
+ std::sort(v.begin(), v.end());
+ for (x = 0; x <= M; ++x)
+ test(Iter(v.data()), Iter(v.data()+v.size()), x);
+}
+
+int main()
+{
+ int d[] = {0, 1, 2, 3};
+ for (int* e = d; e <= d+4; ++e)
+ for (int x = -1; x <= 4; ++x)
+ test(d, e, x);
+
+ test<forward_iterator<const int*> >();
+ test<bidirectional_iterator<const int*> >();
+ test<random_access_iterator<const int*> >();
+ test<const int*>();
+}
diff --git a/test/std/algorithms/alg.sorting/alg.binary.search/lower.bound/lower_bound_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.binary.search/lower.bound/lower_bound_comp.pass.cpp
new file mode 100644
index 000000000000..ae65c59e3159
--- /dev/null
+++ b/test/std/algorithms/alg.sorting/alg.binary.search/lower.bound/lower_bound_comp.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter, class T>
+// requires HasLess<Iter::value_type, T>
+// Iter
+// lower_bound(Iter first, Iter last, const T& value);
+
+#include <algorithm>
+#include <functional>
+#include <vector>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter, class T>
+void
+test(Iter first, Iter last, const T& value)
+{
+ Iter i = std::lower_bound(first, last, value, std::greater<int>());
+ for (Iter j = first; j != i; ++j)
+ assert(std::greater<int>()(*j, value));
+ for (Iter j = i; j != last; ++j)
+ assert(!std::greater<int>()(*j, value));
+}
+
+template <class Iter>
+void
+test()
+{
+ const unsigned N = 1000;
+ const unsigned M = 10;
+ std::vector<int> v(N);
+ int x = 0;
+ for (int i = 0; i < v.size(); ++i)
+ {
+ v[i] = x;
+ if (++x == M)
+ x = 0;
+ }
+ std::sort(v.begin(), v.end(), std::greater<int>());
+ for (x = 0; x <= M; ++x)
+ test(Iter(v.data()), Iter(v.data()+v.size()), x);
+}
+
+int main()
+{
+ int d[] = {3, 2, 1, 0};
+ for (int* e = d; e <= d+4; ++e)
+ for (int x = -1; x <= 4; ++x)
+ test(d, e, x);
+
+ test<forward_iterator<const int*> >();
+ test<bidirectional_iterator<const int*> >();
+ test<random_access_iterator<const int*> >();
+ test<const int*>();
+}
diff --git a/test/std/algorithms/alg.sorting/alg.binary.search/nothing_to_do.pass.cpp b/test/std/algorithms/alg.sorting/alg.binary.search/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/algorithms/alg.sorting/alg.binary.search/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/algorithms/alg.sorting/alg.binary.search/upper.bound/upper_bound.pass.cpp b/test/std/algorithms/alg.sorting/alg.binary.search/upper.bound/upper_bound.pass.cpp
new file mode 100644
index 000000000000..3659e08fb28e
--- /dev/null
+++ b/test/std/algorithms/alg.sorting/alg.binary.search/upper.bound/upper_bound.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter, class T>
+// requires HasLess<T, Iter::value_type>
+// Iter
+// upper_bound(Iter first, Iter last, const T& value);
+
+#include <algorithm>
+#include <vector>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter, class T>
+void
+test(Iter first, Iter last, const T& value)
+{
+ Iter i = std::upper_bound(first, last, value);
+ for (Iter j = first; j != i; ++j)
+ assert(!(value < *j));
+ for (Iter j = i; j != last; ++j)
+ assert(value < *j);
+}
+
+template <class Iter>
+void
+test()
+{
+ const unsigned N = 1000;
+ const unsigned M = 10;
+ std::vector<int> v(N);
+ int x = 0;
+ for (int i = 0; i < v.size(); ++i)
+ {
+ v[i] = x;
+ if (++x == M)
+ x = 0;
+ }
+ std::sort(v.begin(), v.end());
+ for (x = 0; x <= M; ++x)
+ test(Iter(v.data()), Iter(v.data()+v.size()), x);
+}
+
+int main()
+{
+ int d[] = {0, 1, 2, 3};
+ for (int* e = d; e <= d+4; ++e)
+ for (int x = -1; x <= 4; ++x)
+ test(d, e, x);
+
+ test<forward_iterator<const int*> >();
+ test<bidirectional_iterator<const int*> >();
+ test<random_access_iterator<const int*> >();
+ test<const int*>();
+}
diff --git a/test/std/algorithms/alg.sorting/alg.binary.search/upper.bound/upper_bound_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.binary.search/upper.bound/upper_bound_comp.pass.cpp
new file mode 100644
index 000000000000..dd5fcfc28523
--- /dev/null
+++ b/test/std/algorithms/alg.sorting/alg.binary.search/upper.bound/upper_bound_comp.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter, class T, Predicate<auto, T, Iter::value_type> Compare>
+// requires CopyConstructible<Compare>
+// Iter
+// upper_bound(Iter first, Iter last, const T& value, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <vector>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter, class T>
+void
+test(Iter first, Iter last, const T& value)
+{
+ Iter i = std::upper_bound(first, last, value, std::greater<int>());
+ for (Iter j = first; j != i; ++j)
+ assert(!std::greater<int>()(value, *j));
+ for (Iter j = i; j != last; ++j)
+ assert(std::greater<int>()(value, *j));
+}
+
+template <class Iter>
+void
+test()
+{
+ const unsigned N = 1000;
+ const unsigned M = 10;
+ std::vector<int> v(N);
+ int x = 0;
+ for (int i = 0; i < v.size(); ++i)
+ {
+ v[i] = x;
+ if (++x == M)
+ x = 0;
+ }
+ std::sort(v.begin(), v.end(), std::greater<int>());
+ for (x = 0; x <= M; ++x)
+ test(Iter(v.data()), Iter(v.data()+v.size()), x);
+}
+
+int main()
+{
+ int d[] = {3, 2, 1, 0};
+ for (int* e = d; e <= d+4; ++e)
+ for (int x = -1; x <= 4; ++x)
+ test(d, e, x);
+
+ test<forward_iterator<const int*> >();
+ test<bidirectional_iterator<const int*> >();
+ test<random_access_iterator<const int*> >();
+ test<const int*>();
+}
diff --git a/test/std/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap.pass.cpp b/test/std/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap.pass.cpp
new file mode 100644
index 000000000000..f16b2c3c61ae
--- /dev/null
+++ b/test/std/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap.pass.cpp
@@ -0,0 +1,521 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<RandomAccessIterator Iter>
+// requires LessThanComparable<Iter::value_type>
+// bool
+// is_heap(Iter first, Iter last);
+
+#include <algorithm>
+#include <cassert>
+
+void test()
+{
+ int i1[] = {0, 0};
+ assert(std::is_heap(i1, i1));
+ assert(std::is_heap(i1, i1+1) == (std::is_heap_until(i1, i1+1) == i1+1));
+ int i2[] = {0, 1};
+ int i3[] = {1, 0};
+ assert(std::is_heap(i1, i1+2) == (std::is_heap_until(i1, i1+2) == i1+2));
+ assert(std::is_heap(i2, i2+2) == (std::is_heap_until(i2, i2+2) == i2+2));
+ assert(std::is_heap(i3, i3+2) == (std::is_heap_until(i3, i3+2) == i3+2));
+ int i4[] = {0, 0, 0};
+ int i5[] = {0, 0, 1};
+ int i6[] = {0, 1, 0};
+ int i7[] = {0, 1, 1};
+ int i8[] = {1, 0, 0};
+ int i9[] = {1, 0, 1};
+ int i10[] = {1, 1, 0};
+ assert(std::is_heap(i4, i4+3) == (std::is_heap_until(i4, i4+3) == i4+3));
+ assert(std::is_heap(i5, i5+3) == (std::is_heap_until(i5, i5+3) == i5+3));
+ assert(std::is_heap(i6, i6+3) == (std::is_heap_until(i6, i6+3) == i6+3));
+ assert(std::is_heap(i7, i7+3) == (std::is_heap_until(i7, i7+3) == i7+3));
+ assert(std::is_heap(i8, i8+3) == (std::is_heap_until(i8, i8+3) == i8+3));
+ assert(std::is_heap(i9, i9+3) == (std::is_heap_until(i9, i9+3) == i9+3));
+ assert(std::is_heap(i10, i10+3) == (std::is_heap_until(i10, i10+3) == i10+3));
+ int i11[] = {0, 0, 0, 0};
+ int i12[] = {0, 0, 0, 1};
+ int i13[] = {0, 0, 1, 0};
+ int i14[] = {0, 0, 1, 1};
+ int i15[] = {0, 1, 0, 0};
+ int i16[] = {0, 1, 0, 1};
+ int i17[] = {0, 1, 1, 0};
+ int i18[] = {0, 1, 1, 1};
+ int i19[] = {1, 0, 0, 0};
+ int i20[] = {1, 0, 0, 1};
+ int i21[] = {1, 0, 1, 0};
+ int i22[] = {1, 0, 1, 1};
+ int i23[] = {1, 1, 0, 0};
+ int i24[] = {1, 1, 0, 1};
+ int i25[] = {1, 1, 1, 0};
+ assert(std::is_heap(i11, i11+4) == (std::is_heap_until(i11, i11+4) == i11+4));
+ assert(std::is_heap(i12, i12+4) == (std::is_heap_until(i12, i12+4) == i12+4));
+ assert(std::is_heap(i13, i13+4) == (std::is_heap_until(i13, i13+4) == i13+4));
+ assert(std::is_heap(i14, i14+4) == (std::is_heap_until(i14, i14+4) == i14+4));
+ assert(std::is_heap(i15, i15+4) == (std::is_heap_until(i15, i15+4) == i15+4));
+ assert(std::is_heap(i16, i16+4) == (std::is_heap_until(i16, i16+4) == i16+4));
+ assert(std::is_heap(i17, i17+4) == (std::is_heap_until(i17, i17+4) == i17+4));
+ assert(std::is_heap(i18, i18+4) == (std::is_heap_until(i18, i18+4) == i18+4));
+ assert(std::is_heap(i19, i19+4) == (std::is_heap_until(i19, i19+4) == i19+4));
+ assert(std::is_heap(i20, i20+4) == (std::is_heap_until(i20, i20+4) == i20+4));
+ assert(std::is_heap(i21, i21+4) == (std::is_heap_until(i21, i21+4) == i21+4));
+ assert(std::is_heap(i22, i22+4) == (std::is_heap_until(i22, i22+4) == i22+4));
+ assert(std::is_heap(i23, i23+4) == (std::is_heap_until(i23, i23+4) == i23+4));
+ assert(std::is_heap(i24, i24+4) == (std::is_heap_until(i24, i24+4) == i24+4));
+ assert(std::is_heap(i25, i25+4) == (std::is_heap_until(i25, i25+4) == i25+4));
+ int i26[] = {0, 0, 0, 0, 0};
+ int i27[] = {0, 0, 0, 0, 1};
+ int i28[] = {0, 0, 0, 1, 0};
+ int i29[] = {0, 0, 0, 1, 1};
+ int i30[] = {0, 0, 1, 0, 0};
+ int i31[] = {0, 0, 1, 0, 1};
+ int i32[] = {0, 0, 1, 1, 0};
+ int i33[] = {0, 0, 1, 1, 1};
+ int i34[] = {0, 1, 0, 0, 0};
+ int i35[] = {0, 1, 0, 0, 1};
+ int i36[] = {0, 1, 0, 1, 0};
+ int i37[] = {0, 1, 0, 1, 1};
+ int i38[] = {0, 1, 1, 0, 0};
+ int i39[] = {0, 1, 1, 0, 1};
+ int i40[] = {0, 1, 1, 1, 0};
+ int i41[] = {0, 1, 1, 1, 1};
+ int i42[] = {1, 0, 0, 0, 0};
+ int i43[] = {1, 0, 0, 0, 1};
+ int i44[] = {1, 0, 0, 1, 0};
+ int i45[] = {1, 0, 0, 1, 1};
+ int i46[] = {1, 0, 1, 0, 0};
+ int i47[] = {1, 0, 1, 0, 1};
+ int i48[] = {1, 0, 1, 1, 0};
+ int i49[] = {1, 0, 1, 1, 1};
+ int i50[] = {1, 1, 0, 0, 0};
+ int i51[] = {1, 1, 0, 0, 1};
+ int i52[] = {1, 1, 0, 1, 0};
+ int i53[] = {1, 1, 0, 1, 1};
+ int i54[] = {1, 1, 1, 0, 0};
+ int i55[] = {1, 1, 1, 0, 1};
+ int i56[] = {1, 1, 1, 1, 0};
+ assert(std::is_heap(i26, i26+5) == (std::is_heap_until(i26, i26+5) == i26+5));
+ assert(std::is_heap(i27, i27+5) == (std::is_heap_until(i27, i27+5) == i27+5));
+ assert(std::is_heap(i28, i28+5) == (std::is_heap_until(i28, i28+5) == i28+5));
+ assert(std::is_heap(i29, i29+5) == (std::is_heap_until(i29, i29+5) == i29+5));
+ assert(std::is_heap(i30, i30+5) == (std::is_heap_until(i30, i30+5) == i30+5));
+ assert(std::is_heap(i31, i31+5) == (std::is_heap_until(i31, i31+5) == i31+5));
+ assert(std::is_heap(i32, i32+5) == (std::is_heap_until(i32, i32+5) == i32+5));
+ assert(std::is_heap(i33, i33+5) == (std::is_heap_until(i33, i33+5) == i33+5));
+ assert(std::is_heap(i34, i34+5) == (std::is_heap_until(i34, i34+5) == i34+5));
+ assert(std::is_heap(i35, i35+5) == (std::is_heap_until(i35, i35+5) == i35+5));
+ assert(std::is_heap(i36, i36+5) == (std::is_heap_until(i36, i36+5) == i36+5));
+ assert(std::is_heap(i37, i37+5) == (std::is_heap_until(i37, i37+5) == i37+5));
+ assert(std::is_heap(i38, i38+5) == (std::is_heap_until(i38, i38+5) == i38+5));
+ assert(std::is_heap(i39, i39+5) == (std::is_heap_until(i39, i39+5) == i39+5));
+ assert(std::is_heap(i40, i40+5) == (std::is_heap_until(i40, i40+5) == i40+5));
+ assert(std::is_heap(i41, i41+5) == (std::is_heap_until(i41, i41+5) == i41+5));
+ assert(std::is_heap(i42, i42+5) == (std::is_heap_until(i42, i42+5) == i42+5));
+ assert(std::is_heap(i43, i43+5) == (std::is_heap_until(i43, i43+5) == i43+5));
+ assert(std::is_heap(i44, i44+5) == (std::is_heap_until(i44, i44+5) == i44+5));
+ assert(std::is_heap(i45, i45+5) == (std::is_heap_until(i45, i45+5) == i45+5));
+ assert(std::is_heap(i46, i46+5) == (std::is_heap_until(i46, i46+5) == i46+5));
+ assert(std::is_heap(i47, i47+5) == (std::is_heap_until(i47, i47+5) == i47+5));
+ assert(std::is_heap(i48, i48+5) == (std::is_heap_until(i48, i48+5) == i48+5));
+ assert(std::is_heap(i49, i49+5) == (std::is_heap_until(i49, i49+5) == i49+5));
+ assert(std::is_heap(i50, i50+5) == (std::is_heap_until(i50, i50+5) == i50+5));
+ assert(std::is_heap(i51, i51+5) == (std::is_heap_until(i51, i51+5) == i51+5));
+ assert(std::is_heap(i52, i52+5) == (std::is_heap_until(i52, i52+5) == i52+5));
+ assert(std::is_heap(i53, i53+5) == (std::is_heap_until(i53, i53+5) == i53+5));
+ assert(std::is_heap(i54, i54+5) == (std::is_heap_until(i54, i54+5) == i54+5));
+ assert(std::is_heap(i55, i55+5) == (std::is_heap_until(i55, i55+5) == i55+5));
+ assert(std::is_heap(i56, i56+5) == (std::is_heap_until(i56, i56+5) == i56+5));
+ int i57[] = {0, 0, 0, 0, 0, 0};
+ int i58[] = {0, 0, 0, 0, 0, 1};
+ int i59[] = {0, 0, 0, 0, 1, 0};
+ int i60[] = {0, 0, 0, 0, 1, 1};
+ int i61[] = {0, 0, 0, 1, 0, 0};
+ int i62[] = {0, 0, 0, 1, 0, 1};
+ int i63[] = {0, 0, 0, 1, 1, 0};
+ int i64[] = {0, 0, 0, 1, 1, 1};
+ int i65[] = {0, 0, 1, 0, 0, 0};
+ int i66[] = {0, 0, 1, 0, 0, 1};
+ int i67[] = {0, 0, 1, 0, 1, 0};
+ int i68[] = {0, 0, 1, 0, 1, 1};
+ int i69[] = {0, 0, 1, 1, 0, 0};
+ int i70[] = {0, 0, 1, 1, 0, 1};
+ int i71[] = {0, 0, 1, 1, 1, 0};
+ int i72[] = {0, 0, 1, 1, 1, 1};
+ int i73[] = {0, 1, 0, 0, 0, 0};
+ int i74[] = {0, 1, 0, 0, 0, 1};
+ int i75[] = {0, 1, 0, 0, 1, 0};
+ int i76[] = {0, 1, 0, 0, 1, 1};
+ int i77[] = {0, 1, 0, 1, 0, 0};
+ int i78[] = {0, 1, 0, 1, 0, 1};
+ int i79[] = {0, 1, 0, 1, 1, 0};
+ int i80[] = {0, 1, 0, 1, 1, 1};
+ int i81[] = {0, 1, 1, 0, 0, 0};
+ int i82[] = {0, 1, 1, 0, 0, 1};
+ int i83[] = {0, 1, 1, 0, 1, 0};
+ int i84[] = {0, 1, 1, 0, 1, 1};
+ int i85[] = {0, 1, 1, 1, 0, 0};
+ int i86[] = {0, 1, 1, 1, 0, 1};
+ int i87[] = {0, 1, 1, 1, 1, 0};
+ int i88[] = {0, 1, 1, 1, 1, 1};
+ int i89[] = {1, 0, 0, 0, 0, 0};
+ int i90[] = {1, 0, 0, 0, 0, 1};
+ int i91[] = {1, 0, 0, 0, 1, 0};
+ int i92[] = {1, 0, 0, 0, 1, 1};
+ int i93[] = {1, 0, 0, 1, 0, 0};
+ int i94[] = {1, 0, 0, 1, 0, 1};
+ int i95[] = {1, 0, 0, 1, 1, 0};
+ int i96[] = {1, 0, 0, 1, 1, 1};
+ int i97[] = {1, 0, 1, 0, 0, 0};
+ int i98[] = {1, 0, 1, 0, 0, 1};
+ int i99[] = {1, 0, 1, 0, 1, 0};
+ int i100[] = {1, 0, 1, 0, 1, 1};
+ int i101[] = {1, 0, 1, 1, 0, 0};
+ int i102[] = {1, 0, 1, 1, 0, 1};
+ int i103[] = {1, 0, 1, 1, 1, 0};
+ int i104[] = {1, 0, 1, 1, 1, 1};
+ int i105[] = {1, 1, 0, 0, 0, 0};
+ int i106[] = {1, 1, 0, 0, 0, 1};
+ int i107[] = {1, 1, 0, 0, 1, 0};
+ int i108[] = {1, 1, 0, 0, 1, 1};
+ int i109[] = {1, 1, 0, 1, 0, 0};
+ int i110[] = {1, 1, 0, 1, 0, 1};
+ int i111[] = {1, 1, 0, 1, 1, 0};
+ int i112[] = {1, 1, 0, 1, 1, 1};
+ int i113[] = {1, 1, 1, 0, 0, 0};
+ int i114[] = {1, 1, 1, 0, 0, 1};
+ int i115[] = {1, 1, 1, 0, 1, 0};
+ int i116[] = {1, 1, 1, 0, 1, 1};
+ int i117[] = {1, 1, 1, 1, 0, 0};
+ int i118[] = {1, 1, 1, 1, 0, 1};
+ int i119[] = {1, 1, 1, 1, 1, 0};
+ assert(std::is_heap(i57, i57+6) == (std::is_heap_until(i57, i57+6) == i57+6));
+ assert(std::is_heap(i58, i58+6) == (std::is_heap_until(i58, i58+6) == i58+6));
+ assert(std::is_heap(i59, i59+6) == (std::is_heap_until(i59, i59+6) == i59+6));
+ assert(std::is_heap(i60, i60+6) == (std::is_heap_until(i60, i60+6) == i60+6));
+ assert(std::is_heap(i61, i61+6) == (std::is_heap_until(i61, i61+6) == i61+6));
+ assert(std::is_heap(i62, i62+6) == (std::is_heap_until(i62, i62+6) == i62+6));
+ assert(std::is_heap(i63, i63+6) == (std::is_heap_until(i63, i63+6) == i63+6));
+ assert(std::is_heap(i64, i64+6) == (std::is_heap_until(i64, i64+6) == i64+6));
+ assert(std::is_heap(i65, i65+6) == (std::is_heap_until(i65, i65+6) == i65+6));
+ assert(std::is_heap(i66, i66+6) == (std::is_heap_until(i66, i66+6) == i66+6));
+ assert(std::is_heap(i67, i67+6) == (std::is_heap_until(i67, i67+6) == i67+6));
+ assert(std::is_heap(i68, i68+6) == (std::is_heap_until(i68, i68+6) == i68+6));
+ assert(std::is_heap(i69, i69+6) == (std::is_heap_until(i69, i69+6) == i69+6));
+ assert(std::is_heap(i70, i70+6) == (std::is_heap_until(i70, i70+6) == i70+6));
+ assert(std::is_heap(i71, i71+6) == (std::is_heap_until(i71, i71+6) == i71+6));
+ assert(std::is_heap(i72, i72+6) == (std::is_heap_until(i72, i72+6) == i72+6));
+ assert(std::is_heap(i73, i73+6) == (std::is_heap_until(i73, i73+6) == i73+6));
+ assert(std::is_heap(i74, i74+6) == (std::is_heap_until(i74, i74+6) == i74+6));
+ assert(std::is_heap(i75, i75+6) == (std::is_heap_until(i75, i75+6) == i75+6));
+ assert(std::is_heap(i76, i76+6) == (std::is_heap_until(i76, i76+6) == i76+6));
+ assert(std::is_heap(i77, i77+6) == (std::is_heap_until(i77, i77+6) == i77+6));
+ assert(std::is_heap(i78, i78+6) == (std::is_heap_until(i78, i78+6) == i78+6));
+ assert(std::is_heap(i79, i79+6) == (std::is_heap_until(i79, i79+6) == i79+6));
+ assert(std::is_heap(i80, i80+6) == (std::is_heap_until(i80, i80+6) == i80+6));
+ assert(std::is_heap(i81, i81+6) == (std::is_heap_until(i81, i81+6) == i81+6));
+ assert(std::is_heap(i82, i82+6) == (std::is_heap_until(i82, i82+6) == i82+6));
+ assert(std::is_heap(i83, i83+6) == (std::is_heap_until(i83, i83+6) == i83+6));
+ assert(std::is_heap(i84, i84+6) == (std::is_heap_until(i84, i84+6) == i84+6));
+ assert(std::is_heap(i85, i85+6) == (std::is_heap_until(i85, i85+6) == i85+6));
+ assert(std::is_heap(i86, i86+6) == (std::is_heap_until(i86, i86+6) == i86+6));
+ assert(std::is_heap(i87, i87+6) == (std::is_heap_until(i87, i87+6) == i87+6));
+ assert(std::is_heap(i88, i88+6) == (std::is_heap_until(i88, i88+6) == i88+6));
+ assert(std::is_heap(i89, i89+6) == (std::is_heap_until(i89, i89+6) == i89+6));
+ assert(std::is_heap(i90, i90+6) == (std::is_heap_until(i90, i90+6) == i90+6));
+ assert(std::is_heap(i91, i91+6) == (std::is_heap_until(i91, i91+6) == i91+6));
+ assert(std::is_heap(i92, i92+6) == (std::is_heap_until(i92, i92+6) == i92+6));
+ assert(std::is_heap(i93, i93+6) == (std::is_heap_until(i93, i93+6) == i93+6));
+ assert(std::is_heap(i94, i94+6) == (std::is_heap_until(i94, i94+6) == i94+6));
+ assert(std::is_heap(i95, i95+6) == (std::is_heap_until(i95, i95+6) == i95+6));
+ assert(std::is_heap(i96, i96+6) == (std::is_heap_until(i96, i96+6) == i96+6));
+ assert(std::is_heap(i97, i97+6) == (std::is_heap_until(i97, i97+6) == i97+6));
+ assert(std::is_heap(i98, i98+6) == (std::is_heap_until(i98, i98+6) == i98+6));
+ assert(std::is_heap(i99, i99+6) == (std::is_heap_until(i99, i99+6) == i99+6));
+ assert(std::is_heap(i100, i100+6) == (std::is_heap_until(i100, i100+6) == i100+6));
+ assert(std::is_heap(i101, i101+6) == (std::is_heap_until(i101, i101+6) == i101+6));
+ assert(std::is_heap(i102, i102+6) == (std::is_heap_until(i102, i102+6) == i102+6));
+ assert(std::is_heap(i103, i103+6) == (std::is_heap_until(i103, i103+6) == i103+6));
+ assert(std::is_heap(i104, i104+6) == (std::is_heap_until(i104, i104+6) == i104+6));
+ assert(std::is_heap(i105, i105+6) == (std::is_heap_until(i105, i105+6) == i105+6));
+ assert(std::is_heap(i106, i106+6) == (std::is_heap_until(i106, i106+6) == i106+6));
+ assert(std::is_heap(i107, i107+6) == (std::is_heap_until(i107, i107+6) == i107+6));
+ assert(std::is_heap(i108, i108+6) == (std::is_heap_until(i108, i108+6) == i108+6));
+ assert(std::is_heap(i109, i109+6) == (std::is_heap_until(i109, i109+6) == i109+6));
+ assert(std::is_heap(i110, i110+6) == (std::is_heap_until(i110, i110+6) == i110+6));
+ assert(std::is_heap(i111, i111+6) == (std::is_heap_until(i111, i111+6) == i111+6));
+ assert(std::is_heap(i112, i112+6) == (std::is_heap_until(i112, i112+6) == i112+6));
+ assert(std::is_heap(i113, i113+6) == (std::is_heap_until(i113, i113+6) == i113+6));
+ assert(std::is_heap(i114, i114+6) == (std::is_heap_until(i114, i114+6) == i114+6));
+ assert(std::is_heap(i115, i115+6) == (std::is_heap_until(i115, i115+6) == i115+6));
+ assert(std::is_heap(i116, i116+6) == (std::is_heap_until(i116, i116+6) == i116+6));
+ assert(std::is_heap(i117, i117+6) == (std::is_heap_until(i117, i117+6) == i117+6));
+ assert(std::is_heap(i118, i118+6) == (std::is_heap_until(i118, i118+6) == i118+6));
+ assert(std::is_heap(i119, i119+6) == (std::is_heap_until(i119, i119+6) == i119+6));
+ int i120[] = {0, 0, 0, 0, 0, 0, 0};
+ int i121[] = {0, 0, 0, 0, 0, 0, 1};
+ int i122[] = {0, 0, 0, 0, 0, 1, 0};
+ int i123[] = {0, 0, 0, 0, 0, 1, 1};
+ int i124[] = {0, 0, 0, 0, 1, 0, 0};
+ int i125[] = {0, 0, 0, 0, 1, 0, 1};
+ int i126[] = {0, 0, 0, 0, 1, 1, 0};
+ int i127[] = {0, 0, 0, 0, 1, 1, 1};
+ int i128[] = {0, 0, 0, 1, 0, 0, 0};
+ int i129[] = {0, 0, 0, 1, 0, 0, 1};
+ int i130[] = {0, 0, 0, 1, 0, 1, 0};
+ int i131[] = {0, 0, 0, 1, 0, 1, 1};
+ int i132[] = {0, 0, 0, 1, 1, 0, 0};
+ int i133[] = {0, 0, 0, 1, 1, 0, 1};
+ int i134[] = {0, 0, 0, 1, 1, 1, 0};
+ int i135[] = {0, 0, 0, 1, 1, 1, 1};
+ int i136[] = {0, 0, 1, 0, 0, 0, 0};
+ int i137[] = {0, 0, 1, 0, 0, 0, 1};
+ int i138[] = {0, 0, 1, 0, 0, 1, 0};
+ int i139[] = {0, 0, 1, 0, 0, 1, 1};
+ int i140[] = {0, 0, 1, 0, 1, 0, 0};
+ int i141[] = {0, 0, 1, 0, 1, 0, 1};
+ int i142[] = {0, 0, 1, 0, 1, 1, 0};
+ int i143[] = {0, 0, 1, 0, 1, 1, 1};
+ int i144[] = {0, 0, 1, 1, 0, 0, 0};
+ int i145[] = {0, 0, 1, 1, 0, 0, 1};
+ int i146[] = {0, 0, 1, 1, 0, 1, 0};
+ int i147[] = {0, 0, 1, 1, 0, 1, 1};
+ int i148[] = {0, 0, 1, 1, 1, 0, 0};
+ int i149[] = {0, 0, 1, 1, 1, 0, 1};
+ int i150[] = {0, 0, 1, 1, 1, 1, 0};
+ int i151[] = {0, 0, 1, 1, 1, 1, 1};
+ int i152[] = {0, 1, 0, 0, 0, 0, 0};
+ int i153[] = {0, 1, 0, 0, 0, 0, 1};
+ int i154[] = {0, 1, 0, 0, 0, 1, 0};
+ int i155[] = {0, 1, 0, 0, 0, 1, 1};
+ int i156[] = {0, 1, 0, 0, 1, 0, 0};
+ int i157[] = {0, 1, 0, 0, 1, 0, 1};
+ int i158[] = {0, 1, 0, 0, 1, 1, 0};
+ int i159[] = {0, 1, 0, 0, 1, 1, 1};
+ int i160[] = {0, 1, 0, 1, 0, 0, 0};
+ int i161[] = {0, 1, 0, 1, 0, 0, 1};
+ int i162[] = {0, 1, 0, 1, 0, 1, 0};
+ int i163[] = {0, 1, 0, 1, 0, 1, 1};
+ int i164[] = {0, 1, 0, 1, 1, 0, 0};
+ int i165[] = {0, 1, 0, 1, 1, 0, 1};
+ int i166[] = {0, 1, 0, 1, 1, 1, 0};
+ int i167[] = {0, 1, 0, 1, 1, 1, 1};
+ int i168[] = {0, 1, 1, 0, 0, 0, 0};
+ int i169[] = {0, 1, 1, 0, 0, 0, 1};
+ int i170[] = {0, 1, 1, 0, 0, 1, 0};
+ int i171[] = {0, 1, 1, 0, 0, 1, 1};
+ int i172[] = {0, 1, 1, 0, 1, 0, 0};
+ int i173[] = {0, 1, 1, 0, 1, 0, 1};
+ int i174[] = {0, 1, 1, 0, 1, 1, 0};
+ int i175[] = {0, 1, 1, 0, 1, 1, 1};
+ int i176[] = {0, 1, 1, 1, 0, 0, 0};
+ int i177[] = {0, 1, 1, 1, 0, 0, 1};
+ int i178[] = {0, 1, 1, 1, 0, 1, 0};
+ int i179[] = {0, 1, 1, 1, 0, 1, 1};
+ int i180[] = {0, 1, 1, 1, 1, 0, 0};
+ int i181[] = {0, 1, 1, 1, 1, 0, 1};
+ int i182[] = {0, 1, 1, 1, 1, 1, 0};
+ int i183[] = {0, 1, 1, 1, 1, 1, 1};
+ int i184[] = {1, 0, 0, 0, 0, 0, 0};
+ int i185[] = {1, 0, 0, 0, 0, 0, 1};
+ int i186[] = {1, 0, 0, 0, 0, 1, 0};
+ int i187[] = {1, 0, 0, 0, 0, 1, 1};
+ int i188[] = {1, 0, 0, 0, 1, 0, 0};
+ int i189[] = {1, 0, 0, 0, 1, 0, 1};
+ int i190[] = {1, 0, 0, 0, 1, 1, 0};
+ int i191[] = {1, 0, 0, 0, 1, 1, 1};
+ int i192[] = {1, 0, 0, 1, 0, 0, 0};
+ int i193[] = {1, 0, 0, 1, 0, 0, 1};
+ int i194[] = {1, 0, 0, 1, 0, 1, 0};
+ int i195[] = {1, 0, 0, 1, 0, 1, 1};
+ int i196[] = {1, 0, 0, 1, 1, 0, 0};
+ int i197[] = {1, 0, 0, 1, 1, 0, 1};
+ int i198[] = {1, 0, 0, 1, 1, 1, 0};
+ int i199[] = {1, 0, 0, 1, 1, 1, 1};
+ int i200[] = {1, 0, 1, 0, 0, 0, 0};
+ int i201[] = {1, 0, 1, 0, 0, 0, 1};
+ int i202[] = {1, 0, 1, 0, 0, 1, 0};
+ int i203[] = {1, 0, 1, 0, 0, 1, 1};
+ int i204[] = {1, 0, 1, 0, 1, 0, 0};
+ int i205[] = {1, 0, 1, 0, 1, 0, 1};
+ int i206[] = {1, 0, 1, 0, 1, 1, 0};
+ int i207[] = {1, 0, 1, 0, 1, 1, 1};
+ int i208[] = {1, 0, 1, 1, 0, 0, 0};
+ int i209[] = {1, 0, 1, 1, 0, 0, 1};
+ int i210[] = {1, 0, 1, 1, 0, 1, 0};
+ int i211[] = {1, 0, 1, 1, 0, 1, 1};
+ int i212[] = {1, 0, 1, 1, 1, 0, 0};
+ int i213[] = {1, 0, 1, 1, 1, 0, 1};
+ int i214[] = {1, 0, 1, 1, 1, 1, 0};
+ int i215[] = {1, 0, 1, 1, 1, 1, 1};
+ int i216[] = {1, 1, 0, 0, 0, 0, 0};
+ int i217[] = {1, 1, 0, 0, 0, 0, 1};
+ int i218[] = {1, 1, 0, 0, 0, 1, 0};
+ int i219[] = {1, 1, 0, 0, 0, 1, 1};
+ int i220[] = {1, 1, 0, 0, 1, 0, 0};
+ int i221[] = {1, 1, 0, 0, 1, 0, 1};
+ int i222[] = {1, 1, 0, 0, 1, 1, 0};
+ int i223[] = {1, 1, 0, 0, 1, 1, 1};
+ int i224[] = {1, 1, 0, 1, 0, 0, 0};
+ int i225[] = {1, 1, 0, 1, 0, 0, 1};
+ int i226[] = {1, 1, 0, 1, 0, 1, 0};
+ int i227[] = {1, 1, 0, 1, 0, 1, 1};
+ int i228[] = {1, 1, 0, 1, 1, 0, 0};
+ int i229[] = {1, 1, 0, 1, 1, 0, 1};
+ int i230[] = {1, 1, 0, 1, 1, 1, 0};
+ int i231[] = {1, 1, 0, 1, 1, 1, 1};
+ int i232[] = {1, 1, 1, 0, 0, 0, 0};
+ int i233[] = {1, 1, 1, 0, 0, 0, 1};
+ int i234[] = {1, 1, 1, 0, 0, 1, 0};
+ int i235[] = {1, 1, 1, 0, 0, 1, 1};
+ int i236[] = {1, 1, 1, 0, 1, 0, 0};
+ int i237[] = {1, 1, 1, 0, 1, 0, 1};
+ int i238[] = {1, 1, 1, 0, 1, 1, 0};
+ int i239[] = {1, 1, 1, 0, 1, 1, 1};
+ int i240[] = {1, 1, 1, 1, 0, 0, 0};
+ int i241[] = {1, 1, 1, 1, 0, 0, 1};
+ int i242[] = {1, 1, 1, 1, 0, 1, 0};
+ int i243[] = {1, 1, 1, 1, 0, 1, 1};
+ int i244[] = {1, 1, 1, 1, 1, 0, 0};
+ int i245[] = {1, 1, 1, 1, 1, 0, 1};
+ int i246[] = {1, 1, 1, 1, 1, 1, 0};
+ assert(std::is_heap(i120, i120+7) == (std::is_heap_until(i120, i120+7) == i120+7));
+ assert(std::is_heap(i121, i121+7) == (std::is_heap_until(i121, i121+7) == i121+7));
+ assert(std::is_heap(i122, i122+7) == (std::is_heap_until(i122, i122+7) == i122+7));
+ assert(std::is_heap(i123, i123+7) == (std::is_heap_until(i123, i123+7) == i123+7));
+ assert(std::is_heap(i124, i124+7) == (std::is_heap_until(i124, i124+7) == i124+7));
+ assert(std::is_heap(i125, i125+7) == (std::is_heap_until(i125, i125+7) == i125+7));
+ assert(std::is_heap(i126, i126+7) == (std::is_heap_until(i126, i126+7) == i126+7));
+ assert(std::is_heap(i127, i127+7) == (std::is_heap_until(i127, i127+7) == i127+7));
+ assert(std::is_heap(i128, i128+7) == (std::is_heap_until(i128, i128+7) == i128+7));
+ assert(std::is_heap(i129, i129+7) == (std::is_heap_until(i129, i129+7) == i129+7));
+ assert(std::is_heap(i130, i130+7) == (std::is_heap_until(i130, i130+7) == i130+7));
+ assert(std::is_heap(i131, i131+7) == (std::is_heap_until(i131, i131+7) == i131+7));
+ assert(std::is_heap(i132, i132+7) == (std::is_heap_until(i132, i132+7) == i132+7));
+ assert(std::is_heap(i133, i133+7) == (std::is_heap_until(i133, i133+7) == i133+7));
+ assert(std::is_heap(i134, i134+7) == (std::is_heap_until(i134, i134+7) == i134+7));
+ assert(std::is_heap(i135, i135+7) == (std::is_heap_until(i135, i135+7) == i135+7));
+ assert(std::is_heap(i136, i136+7) == (std::is_heap_until(i136, i136+7) == i136+7));
+ assert(std::is_heap(i137, i137+7) == (std::is_heap_until(i137, i137+7) == i137+7));
+ assert(std::is_heap(i138, i138+7) == (std::is_heap_until(i138, i138+7) == i138+7));
+ assert(std::is_heap(i139, i139+7) == (std::is_heap_until(i139, i139+7) == i139+7));
+ assert(std::is_heap(i140, i140+7) == (std::is_heap_until(i140, i140+7) == i140+7));
+ assert(std::is_heap(i141, i141+7) == (std::is_heap_until(i141, i141+7) == i141+7));
+ assert(std::is_heap(i142, i142+7) == (std::is_heap_until(i142, i142+7) == i142+7));
+ assert(std::is_heap(i143, i143+7) == (std::is_heap_until(i143, i143+7) == i143+7));
+ assert(std::is_heap(i144, i144+7) == (std::is_heap_until(i144, i144+7) == i144+7));
+ assert(std::is_heap(i145, i145+7) == (std::is_heap_until(i145, i145+7) == i145+7));
+ assert(std::is_heap(i146, i146+7) == (std::is_heap_until(i146, i146+7) == i146+7));
+ assert(std::is_heap(i147, i147+7) == (std::is_heap_until(i147, i147+7) == i147+7));
+ assert(std::is_heap(i148, i148+7) == (std::is_heap_until(i148, i148+7) == i148+7));
+ assert(std::is_heap(i149, i149+7) == (std::is_heap_until(i149, i149+7) == i149+7));
+ assert(std::is_heap(i150, i150+7) == (std::is_heap_until(i150, i150+7) == i150+7));
+ assert(std::is_heap(i151, i151+7) == (std::is_heap_until(i151, i151+7) == i151+7));
+ assert(std::is_heap(i152, i152+7) == (std::is_heap_until(i152, i152+7) == i152+7));
+ assert(std::is_heap(i153, i153+7) == (std::is_heap_until(i153, i153+7) == i153+7));
+ assert(std::is_heap(i154, i154+7) == (std::is_heap_until(i154, i154+7) == i154+7));
+ assert(std::is_heap(i155, i155+7) == (std::is_heap_until(i155, i155+7) == i155+7));
+ assert(std::is_heap(i156, i156+7) == (std::is_heap_until(i156, i156+7) == i156+7));
+ assert(std::is_heap(i157, i157+7) == (std::is_heap_until(i157, i157+7) == i157+7));
+ assert(std::is_heap(i158, i158+7) == (std::is_heap_until(i158, i158+7) == i158+7));
+ assert(std::is_heap(i159, i159+7) == (std::is_heap_until(i159, i159+7) == i159+7));
+ assert(std::is_heap(i160, i160+7) == (std::is_heap_until(i160, i160+7) == i160+7));
+ assert(std::is_heap(i161, i161+7) == (std::is_heap_until(i161, i161+7) == i161+7));
+ assert(std::is_heap(i162, i162+7) == (std::is_heap_until(i162, i162+7) == i162+7));
+ assert(std::is_heap(i163, i163+7) == (std::is_heap_until(i163, i163+7) == i163+7));
+ assert(std::is_heap(i164, i164+7) == (std::is_heap_until(i164, i164+7) == i164+7));
+ assert(std::is_heap(i165, i165+7) == (std::is_heap_until(i165, i165+7) == i165+7));
+ assert(std::is_heap(i166, i166+7) == (std::is_heap_until(i166, i166+7) == i166+7));
+ assert(std::is_heap(i167, i167+7) == (std::is_heap_until(i167, i167+7) == i167+7));
+ assert(std::is_heap(i168, i168+7) == (std::is_heap_until(i168, i168+7) == i168+7));
+ assert(std::is_heap(i169, i169+7) == (std::is_heap_until(i169, i169+7) == i169+7));
+ assert(std::is_heap(i170, i170+7) == (std::is_heap_until(i170, i170+7) == i170+7));
+ assert(std::is_heap(i171, i171+7) == (std::is_heap_until(i171, i171+7) == i171+7));
+ assert(std::is_heap(i172, i172+7) == (std::is_heap_until(i172, i172+7) == i172+7));
+ assert(std::is_heap(i173, i173+7) == (std::is_heap_until(i173, i173+7) == i173+7));
+ assert(std::is_heap(i174, i174+7) == (std::is_heap_until(i174, i174+7) == i174+7));
+ assert(std::is_heap(i175, i175+7) == (std::is_heap_until(i175, i175+7) == i175+7));
+ assert(std::is_heap(i176, i176+7) == (std::is_heap_until(i176, i176+7) == i176+7));
+ assert(std::is_heap(i177, i177+7) == (std::is_heap_until(i177, i177+7) == i177+7));
+ assert(std::is_heap(i178, i178+7) == (std::is_heap_until(i178, i178+7) == i178+7));
+ assert(std::is_heap(i179, i179+7) == (std::is_heap_until(i179, i179+7) == i179+7));
+ assert(std::is_heap(i180, i180+7) == (std::is_heap_until(i180, i180+7) == i180+7));
+ assert(std::is_heap(i181, i181+7) == (std::is_heap_until(i181, i181+7) == i181+7));
+ assert(std::is_heap(i182, i182+7) == (std::is_heap_until(i182, i182+7) == i182+7));
+ assert(std::is_heap(i183, i183+7) == (std::is_heap_until(i183, i183+7) == i183+7));
+ assert(std::is_heap(i184, i184+7) == (std::is_heap_until(i184, i184+7) == i184+7));
+ assert(std::is_heap(i185, i185+7) == (std::is_heap_until(i185, i185+7) == i185+7));
+ assert(std::is_heap(i186, i186+7) == (std::is_heap_until(i186, i186+7) == i186+7));
+ assert(std::is_heap(i187, i187+7) == (std::is_heap_until(i187, i187+7) == i187+7));
+ assert(std::is_heap(i188, i188+7) == (std::is_heap_until(i188, i188+7) == i188+7));
+ assert(std::is_heap(i189, i189+7) == (std::is_heap_until(i189, i189+7) == i189+7));
+ assert(std::is_heap(i190, i190+7) == (std::is_heap_until(i190, i190+7) == i190+7));
+ assert(std::is_heap(i191, i191+7) == (std::is_heap_until(i191, i191+7) == i191+7));
+ assert(std::is_heap(i192, i192+7) == (std::is_heap_until(i192, i192+7) == i192+7));
+ assert(std::is_heap(i193, i193+7) == (std::is_heap_until(i193, i193+7) == i193+7));
+ assert(std::is_heap(i194, i194+7) == (std::is_heap_until(i194, i194+7) == i194+7));
+ assert(std::is_heap(i195, i195+7) == (std::is_heap_until(i195, i195+7) == i195+7));
+ assert(std::is_heap(i196, i196+7) == (std::is_heap_until(i196, i196+7) == i196+7));
+ assert(std::is_heap(i197, i197+7) == (std::is_heap_until(i197, i197+7) == i197+7));
+ assert(std::is_heap(i198, i198+7) == (std::is_heap_until(i198, i198+7) == i198+7));
+ assert(std::is_heap(i199, i199+7) == (std::is_heap_until(i199, i199+7) == i199+7));
+ assert(std::is_heap(i200, i200+7) == (std::is_heap_until(i200, i200+7) == i200+7));
+ assert(std::is_heap(i201, i201+7) == (std::is_heap_until(i201, i201+7) == i201+7));
+ assert(std::is_heap(i202, i202+7) == (std::is_heap_until(i202, i202+7) == i202+7));
+ assert(std::is_heap(i203, i203+7) == (std::is_heap_until(i203, i203+7) == i203+7));
+ assert(std::is_heap(i204, i204+7) == (std::is_heap_until(i204, i204+7) == i204+7));
+ assert(std::is_heap(i205, i205+7) == (std::is_heap_until(i205, i205+7) == i205+7));
+ assert(std::is_heap(i206, i206+7) == (std::is_heap_until(i206, i206+7) == i206+7));
+ assert(std::is_heap(i207, i207+7) == (std::is_heap_until(i207, i207+7) == i207+7));
+ assert(std::is_heap(i208, i208+7) == (std::is_heap_until(i208, i208+7) == i208+7));
+ assert(std::is_heap(i209, i209+7) == (std::is_heap_until(i209, i209+7) == i209+7));
+ assert(std::is_heap(i210, i210+7) == (std::is_heap_until(i210, i210+7) == i210+7));
+ assert(std::is_heap(i211, i211+7) == (std::is_heap_until(i211, i211+7) == i211+7));
+ assert(std::is_heap(i212, i212+7) == (std::is_heap_until(i212, i212+7) == i212+7));
+ assert(std::is_heap(i213, i213+7) == (std::is_heap_until(i213, i213+7) == i213+7));
+ assert(std::is_heap(i214, i214+7) == (std::is_heap_until(i214, i214+7) == i214+7));
+ assert(std::is_heap(i215, i215+7) == (std::is_heap_until(i215, i215+7) == i215+7));
+ assert(std::is_heap(i216, i216+7) == (std::is_heap_until(i216, i216+7) == i216+7));
+ assert(std::is_heap(i217, i217+7) == (std::is_heap_until(i217, i217+7) == i217+7));
+ assert(std::is_heap(i218, i218+7) == (std::is_heap_until(i218, i218+7) == i218+7));
+ assert(std::is_heap(i219, i219+7) == (std::is_heap_until(i219, i219+7) == i219+7));
+ assert(std::is_heap(i220, i220+7) == (std::is_heap_until(i220, i220+7) == i220+7));
+ assert(std::is_heap(i221, i221+7) == (std::is_heap_until(i221, i221+7) == i221+7));
+ assert(std::is_heap(i222, i222+7) == (std::is_heap_until(i222, i222+7) == i222+7));
+ assert(std::is_heap(i223, i223+7) == (std::is_heap_until(i223, i223+7) == i223+7));
+ assert(std::is_heap(i224, i224+7) == (std::is_heap_until(i224, i224+7) == i224+7));
+ assert(std::is_heap(i225, i225+7) == (std::is_heap_until(i225, i225+7) == i225+7));
+ assert(std::is_heap(i226, i226+7) == (std::is_heap_until(i226, i226+7) == i226+7));
+ assert(std::is_heap(i227, i227+7) == (std::is_heap_until(i227, i227+7) == i227+7));
+ assert(std::is_heap(i228, i228+7) == (std::is_heap_until(i228, i228+7) == i228+7));
+ assert(std::is_heap(i229, i229+7) == (std::is_heap_until(i229, i229+7) == i229+7));
+ assert(std::is_heap(i230, i230+7) == (std::is_heap_until(i230, i230+7) == i230+7));
+ assert(std::is_heap(i231, i231+7) == (std::is_heap_until(i231, i231+7) == i231+7));
+ assert(std::is_heap(i232, i232+7) == (std::is_heap_until(i232, i232+7) == i232+7));
+ assert(std::is_heap(i233, i233+7) == (std::is_heap_until(i233, i233+7) == i233+7));
+ assert(std::is_heap(i234, i234+7) == (std::is_heap_until(i234, i234+7) == i234+7));
+ assert(std::is_heap(i235, i235+7) == (std::is_heap_until(i235, i235+7) == i235+7));
+ assert(std::is_heap(i236, i236+7) == (std::is_heap_until(i236, i236+7) == i236+7));
+ assert(std::is_heap(i237, i237+7) == (std::is_heap_until(i237, i237+7) == i237+7));
+ assert(std::is_heap(i238, i238+7) == (std::is_heap_until(i238, i238+7) == i238+7));
+ assert(std::is_heap(i239, i239+7) == (std::is_heap_until(i239, i239+7) == i239+7));
+ assert(std::is_heap(i240, i240+7) == (std::is_heap_until(i240, i240+7) == i240+7));
+ assert(std::is_heap(i241, i241+7) == (std::is_heap_until(i241, i241+7) == i241+7));
+ assert(std::is_heap(i242, i242+7) == (std::is_heap_until(i242, i242+7) == i242+7));
+ assert(std::is_heap(i243, i243+7) == (std::is_heap_until(i243, i243+7) == i243+7));
+ assert(std::is_heap(i244, i244+7) == (std::is_heap_until(i244, i244+7) == i244+7));
+ assert(std::is_heap(i245, i245+7) == (std::is_heap_until(i245, i245+7) == i245+7));
+ assert(std::is_heap(i246, i246+7) == (std::is_heap_until(i246, i246+7) == i246+7));
+}
+
+int main()
+{
+ test();
+}
diff --git a/test/std/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap_comp.pass.cpp
new file mode 100644
index 000000000000..af55cc499eda
--- /dev/null
+++ b/test/std/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap_comp.pass.cpp
@@ -0,0 +1,522 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<RandomAccessIterator Iter>
+// requires LessThanComparable<Iter::value_type>
+// bool
+// is_heap(Iter first, Iter last);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+void test()
+{
+ int i1[] = {0, 0};
+ assert(std::is_heap(i1, i1, std::greater<int>()));
+ assert(std::is_heap(i1, i1+1, std::greater<int>()) == (std::is_heap_until(i1, i1+1, std::greater<int>()) == i1+1));
+ int i2[] = {0, 1};
+ int i3[] = {1, 0};
+ assert(std::is_heap(i1, i1+2, std::greater<int>()) == (std::is_heap_until(i1, i1+2, std::greater<int>()) == i1+2));
+ assert(std::is_heap(i2, i2+2, std::greater<int>()) == (std::is_heap_until(i2, i2+2, std::greater<int>()) == i2+2));
+ assert(std::is_heap(i3, i3+2, std::greater<int>()) == (std::is_heap_until(i3, i3+2, std::greater<int>()) == i3+2));
+ int i4[] = {0, 0, 0};
+ int i5[] = {0, 0, 1};
+ int i6[] = {0, 1, 0};
+ int i7[] = {0, 1, 1};
+ int i8[] = {1, 0, 0};
+ int i9[] = {1, 0, 1};
+ int i10[] = {1, 1, 0};
+ assert(std::is_heap(i4, i4+3, std::greater<int>()) == (std::is_heap_until(i4, i4+3, std::greater<int>()) == i4+3));
+ assert(std::is_heap(i5, i5+3, std::greater<int>()) == (std::is_heap_until(i5, i5+3, std::greater<int>()) == i5+3));
+ assert(std::is_heap(i6, i6+3, std::greater<int>()) == (std::is_heap_until(i6, i6+3, std::greater<int>()) == i6+3));
+ assert(std::is_heap(i7, i7+3, std::greater<int>()) == (std::is_heap_until(i7, i7+3, std::greater<int>()) == i7+3));
+ assert(std::is_heap(i8, i8+3, std::greater<int>()) == (std::is_heap_until(i8, i8+3, std::greater<int>()) == i8+3));
+ assert(std::is_heap(i9, i9+3, std::greater<int>()) == (std::is_heap_until(i9, i9+3, std::greater<int>()) == i9+3));
+ assert(std::is_heap(i10, i10+3, std::greater<int>()) == (std::is_heap_until(i10, i10+3, std::greater<int>()) == i10+3));
+ int i11[] = {0, 0, 0, 0};
+ int i12[] = {0, 0, 0, 1};
+ int i13[] = {0, 0, 1, 0};
+ int i14[] = {0, 0, 1, 1};
+ int i15[] = {0, 1, 0, 0};
+ int i16[] = {0, 1, 0, 1};
+ int i17[] = {0, 1, 1, 0};
+ int i18[] = {0, 1, 1, 1};
+ int i19[] = {1, 0, 0, 0};
+ int i20[] = {1, 0, 0, 1};
+ int i21[] = {1, 0, 1, 0};
+ int i22[] = {1, 0, 1, 1};
+ int i23[] = {1, 1, 0, 0};
+ int i24[] = {1, 1, 0, 1};
+ int i25[] = {1, 1, 1, 0};
+ assert(std::is_heap(i11, i11+4, std::greater<int>()) == (std::is_heap_until(i11, i11+4, std::greater<int>()) == i11+4));
+ assert(std::is_heap(i12, i12+4, std::greater<int>()) == (std::is_heap_until(i12, i12+4, std::greater<int>()) == i12+4));
+ assert(std::is_heap(i13, i13+4, std::greater<int>()) == (std::is_heap_until(i13, i13+4, std::greater<int>()) == i13+4));
+ assert(std::is_heap(i14, i14+4, std::greater<int>()) == (std::is_heap_until(i14, i14+4, std::greater<int>()) == i14+4));
+ assert(std::is_heap(i15, i15+4, std::greater<int>()) == (std::is_heap_until(i15, i15+4, std::greater<int>()) == i15+4));
+ assert(std::is_heap(i16, i16+4, std::greater<int>()) == (std::is_heap_until(i16, i16+4, std::greater<int>()) == i16+4));
+ assert(std::is_heap(i17, i17+4, std::greater<int>()) == (std::is_heap_until(i17, i17+4, std::greater<int>()) == i17+4));
+ assert(std::is_heap(i18, i18+4, std::greater<int>()) == (std::is_heap_until(i18, i18+4, std::greater<int>()) == i18+4));
+ assert(std::is_heap(i19, i19+4, std::greater<int>()) == (std::is_heap_until(i19, i19+4, std::greater<int>()) == i19+4));
+ assert(std::is_heap(i20, i20+4, std::greater<int>()) == (std::is_heap_until(i20, i20+4, std::greater<int>()) == i20+4));
+ assert(std::is_heap(i21, i21+4, std::greater<int>()) == (std::is_heap_until(i21, i21+4, std::greater<int>()) == i21+4));
+ assert(std::is_heap(i22, i22+4, std::greater<int>()) == (std::is_heap_until(i22, i22+4, std::greater<int>()) == i22+4));
+ assert(std::is_heap(i23, i23+4, std::greater<int>()) == (std::is_heap_until(i23, i23+4, std::greater<int>()) == i23+4));
+ assert(std::is_heap(i24, i24+4, std::greater<int>()) == (std::is_heap_until(i24, i24+4, std::greater<int>()) == i24+4));
+ assert(std::is_heap(i25, i25+4, std::greater<int>()) == (std::is_heap_until(i25, i25+4, std::greater<int>()) == i25+4));
+ int i26[] = {0, 0, 0, 0, 0};
+ int i27[] = {0, 0, 0, 0, 1};
+ int i28[] = {0, 0, 0, 1, 0};
+ int i29[] = {0, 0, 0, 1, 1};
+ int i30[] = {0, 0, 1, 0, 0};
+ int i31[] = {0, 0, 1, 0, 1};
+ int i32[] = {0, 0, 1, 1, 0};
+ int i33[] = {0, 0, 1, 1, 1};
+ int i34[] = {0, 1, 0, 0, 0};
+ int i35[] = {0, 1, 0, 0, 1};
+ int i36[] = {0, 1, 0, 1, 0};
+ int i37[] = {0, 1, 0, 1, 1};
+ int i38[] = {0, 1, 1, 0, 0};
+ int i39[] = {0, 1, 1, 0, 1};
+ int i40[] = {0, 1, 1, 1, 0};
+ int i41[] = {0, 1, 1, 1, 1};
+ int i42[] = {1, 0, 0, 0, 0};
+ int i43[] = {1, 0, 0, 0, 1};
+ int i44[] = {1, 0, 0, 1, 0};
+ int i45[] = {1, 0, 0, 1, 1};
+ int i46[] = {1, 0, 1, 0, 0};
+ int i47[] = {1, 0, 1, 0, 1};
+ int i48[] = {1, 0, 1, 1, 0};
+ int i49[] = {1, 0, 1, 1, 1};
+ int i50[] = {1, 1, 0, 0, 0};
+ int i51[] = {1, 1, 0, 0, 1};
+ int i52[] = {1, 1, 0, 1, 0};
+ int i53[] = {1, 1, 0, 1, 1};
+ int i54[] = {1, 1, 1, 0, 0};
+ int i55[] = {1, 1, 1, 0, 1};
+ int i56[] = {1, 1, 1, 1, 0};
+ assert(std::is_heap(i26, i26+5, std::greater<int>()) == (std::is_heap_until(i26, i26+5, std::greater<int>()) == i26+5));
+ assert(std::is_heap(i27, i27+5, std::greater<int>()) == (std::is_heap_until(i27, i27+5, std::greater<int>()) == i27+5));
+ assert(std::is_heap(i28, i28+5, std::greater<int>()) == (std::is_heap_until(i28, i28+5, std::greater<int>()) == i28+5));
+ assert(std::is_heap(i29, i29+5, std::greater<int>()) == (std::is_heap_until(i29, i29+5, std::greater<int>()) == i29+5));
+ assert(std::is_heap(i30, i30+5, std::greater<int>()) == (std::is_heap_until(i30, i30+5, std::greater<int>()) == i30+5));
+ assert(std::is_heap(i31, i31+5, std::greater<int>()) == (std::is_heap_until(i31, i31+5, std::greater<int>()) == i31+5));
+ assert(std::is_heap(i32, i32+5, std::greater<int>()) == (std::is_heap_until(i32, i32+5, std::greater<int>()) == i32+5));
+ assert(std::is_heap(i33, i33+5, std::greater<int>()) == (std::is_heap_until(i33, i33+5, std::greater<int>()) == i33+5));
+ assert(std::is_heap(i34, i34+5, std::greater<int>()) == (std::is_heap_until(i34, i34+5, std::greater<int>()) == i34+5));
+ assert(std::is_heap(i35, i35+5, std::greater<int>()) == (std::is_heap_until(i35, i35+5, std::greater<int>()) == i35+5));
+ assert(std::is_heap(i36, i36+5, std::greater<int>()) == (std::is_heap_until(i36, i36+5, std::greater<int>()) == i36+5));
+ assert(std::is_heap(i37, i37+5, std::greater<int>()) == (std::is_heap_until(i37, i37+5, std::greater<int>()) == i37+5));
+ assert(std::is_heap(i38, i38+5, std::greater<int>()) == (std::is_heap_until(i38, i38+5, std::greater<int>()) == i38+5));
+ assert(std::is_heap(i39, i39+5, std::greater<int>()) == (std::is_heap_until(i39, i39+5, std::greater<int>()) == i39+5));
+ assert(std::is_heap(i40, i40+5, std::greater<int>()) == (std::is_heap_until(i40, i40+5, std::greater<int>()) == i40+5));
+ assert(std::is_heap(i41, i41+5, std::greater<int>()) == (std::is_heap_until(i41, i41+5, std::greater<int>()) == i41+5));
+ assert(std::is_heap(i42, i42+5, std::greater<int>()) == (std::is_heap_until(i42, i42+5, std::greater<int>()) == i42+5));
+ assert(std::is_heap(i43, i43+5, std::greater<int>()) == (std::is_heap_until(i43, i43+5, std::greater<int>()) == i43+5));
+ assert(std::is_heap(i44, i44+5, std::greater<int>()) == (std::is_heap_until(i44, i44+5, std::greater<int>()) == i44+5));
+ assert(std::is_heap(i45, i45+5, std::greater<int>()) == (std::is_heap_until(i45, i45+5, std::greater<int>()) == i45+5));
+ assert(std::is_heap(i46, i46+5, std::greater<int>()) == (std::is_heap_until(i46, i46+5, std::greater<int>()) == i46+5));
+ assert(std::is_heap(i47, i47+5, std::greater<int>()) == (std::is_heap_until(i47, i47+5, std::greater<int>()) == i47+5));
+ assert(std::is_heap(i48, i48+5, std::greater<int>()) == (std::is_heap_until(i48, i48+5, std::greater<int>()) == i48+5));
+ assert(std::is_heap(i49, i49+5, std::greater<int>()) == (std::is_heap_until(i49, i49+5, std::greater<int>()) == i49+5));
+ assert(std::is_heap(i50, i50+5, std::greater<int>()) == (std::is_heap_until(i50, i50+5, std::greater<int>()) == i50+5));
+ assert(std::is_heap(i51, i51+5, std::greater<int>()) == (std::is_heap_until(i51, i51+5, std::greater<int>()) == i51+5));
+ assert(std::is_heap(i52, i52+5, std::greater<int>()) == (std::is_heap_until(i52, i52+5, std::greater<int>()) == i52+5));
+ assert(std::is_heap(i53, i53+5, std::greater<int>()) == (std::is_heap_until(i53, i53+5, std::greater<int>()) == i53+5));
+ assert(std::is_heap(i54, i54+5, std::greater<int>()) == (std::is_heap_until(i54, i54+5, std::greater<int>()) == i54+5));
+ assert(std::is_heap(i55, i55+5, std::greater<int>()) == (std::is_heap_until(i55, i55+5, std::greater<int>()) == i55+5));
+ assert(std::is_heap(i56, i56+5, std::greater<int>()) == (std::is_heap_until(i56, i56+5, std::greater<int>()) == i56+5));
+ int i57[] = {0, 0, 0, 0, 0, 0};
+ int i58[] = {0, 0, 0, 0, 0, 1};
+ int i59[] = {0, 0, 0, 0, 1, 0};
+ int i60[] = {0, 0, 0, 0, 1, 1};
+ int i61[] = {0, 0, 0, 1, 0, 0};
+ int i62[] = {0, 0, 0, 1, 0, 1};
+ int i63[] = {0, 0, 0, 1, 1, 0};
+ int i64[] = {0, 0, 0, 1, 1, 1};
+ int i65[] = {0, 0, 1, 0, 0, 0};
+ int i66[] = {0, 0, 1, 0, 0, 1};
+ int i67[] = {0, 0, 1, 0, 1, 0};
+ int i68[] = {0, 0, 1, 0, 1, 1};
+ int i69[] = {0, 0, 1, 1, 0, 0};
+ int i70[] = {0, 0, 1, 1, 0, 1};
+ int i71[] = {0, 0, 1, 1, 1, 0};
+ int i72[] = {0, 0, 1, 1, 1, 1};
+ int i73[] = {0, 1, 0, 0, 0, 0};
+ int i74[] = {0, 1, 0, 0, 0, 1};
+ int i75[] = {0, 1, 0, 0, 1, 0};
+ int i76[] = {0, 1, 0, 0, 1, 1};
+ int i77[] = {0, 1, 0, 1, 0, 0};
+ int i78[] = {0, 1, 0, 1, 0, 1};
+ int i79[] = {0, 1, 0, 1, 1, 0};
+ int i80[] = {0, 1, 0, 1, 1, 1};
+ int i81[] = {0, 1, 1, 0, 0, 0};
+ int i82[] = {0, 1, 1, 0, 0, 1};
+ int i83[] = {0, 1, 1, 0, 1, 0};
+ int i84[] = {0, 1, 1, 0, 1, 1};
+ int i85[] = {0, 1, 1, 1, 0, 0};
+ int i86[] = {0, 1, 1, 1, 0, 1};
+ int i87[] = {0, 1, 1, 1, 1, 0};
+ int i88[] = {0, 1, 1, 1, 1, 1};
+ int i89[] = {1, 0, 0, 0, 0, 0};
+ int i90[] = {1, 0, 0, 0, 0, 1};
+ int i91[] = {1, 0, 0, 0, 1, 0};
+ int i92[] = {1, 0, 0, 0, 1, 1};
+ int i93[] = {1, 0, 0, 1, 0, 0};
+ int i94[] = {1, 0, 0, 1, 0, 1};
+ int i95[] = {1, 0, 0, 1, 1, 0};
+ int i96[] = {1, 0, 0, 1, 1, 1};
+ int i97[] = {1, 0, 1, 0, 0, 0};
+ int i98[] = {1, 0, 1, 0, 0, 1};
+ int i99[] = {1, 0, 1, 0, 1, 0};
+ int i100[] = {1, 0, 1, 0, 1, 1};
+ int i101[] = {1, 0, 1, 1, 0, 0};
+ int i102[] = {1, 0, 1, 1, 0, 1};
+ int i103[] = {1, 0, 1, 1, 1, 0};
+ int i104[] = {1, 0, 1, 1, 1, 1};
+ int i105[] = {1, 1, 0, 0, 0, 0};
+ int i106[] = {1, 1, 0, 0, 0, 1};
+ int i107[] = {1, 1, 0, 0, 1, 0};
+ int i108[] = {1, 1, 0, 0, 1, 1};
+ int i109[] = {1, 1, 0, 1, 0, 0};
+ int i110[] = {1, 1, 0, 1, 0, 1};
+ int i111[] = {1, 1, 0, 1, 1, 0};
+ int i112[] = {1, 1, 0, 1, 1, 1};
+ int i113[] = {1, 1, 1, 0, 0, 0};
+ int i114[] = {1, 1, 1, 0, 0, 1};
+ int i115[] = {1, 1, 1, 0, 1, 0};
+ int i116[] = {1, 1, 1, 0, 1, 1};
+ int i117[] = {1, 1, 1, 1, 0, 0};
+ int i118[] = {1, 1, 1, 1, 0, 1};
+ int i119[] = {1, 1, 1, 1, 1, 0};
+ assert(std::is_heap(i57, i57+6, std::greater<int>()) == (std::is_heap_until(i57, i57+6, std::greater<int>()) == i57+6));
+ assert(std::is_heap(i58, i58+6, std::greater<int>()) == (std::is_heap_until(i58, i58+6, std::greater<int>()) == i58+6));
+ assert(std::is_heap(i59, i59+6, std::greater<int>()) == (std::is_heap_until(i59, i59+6, std::greater<int>()) == i59+6));
+ assert(std::is_heap(i60, i60+6, std::greater<int>()) == (std::is_heap_until(i60, i60+6, std::greater<int>()) == i60+6));
+ assert(std::is_heap(i61, i61+6, std::greater<int>()) == (std::is_heap_until(i61, i61+6, std::greater<int>()) == i61+6));
+ assert(std::is_heap(i62, i62+6, std::greater<int>()) == (std::is_heap_until(i62, i62+6, std::greater<int>()) == i62+6));
+ assert(std::is_heap(i63, i63+6, std::greater<int>()) == (std::is_heap_until(i63, i63+6, std::greater<int>()) == i63+6));
+ assert(std::is_heap(i64, i64+6, std::greater<int>()) == (std::is_heap_until(i64, i64+6, std::greater<int>()) == i64+6));
+ assert(std::is_heap(i65, i65+6, std::greater<int>()) == (std::is_heap_until(i65, i65+6, std::greater<int>()) == i65+6));
+ assert(std::is_heap(i66, i66+6, std::greater<int>()) == (std::is_heap_until(i66, i66+6, std::greater<int>()) == i66+6));
+ assert(std::is_heap(i67, i67+6, std::greater<int>()) == (std::is_heap_until(i67, i67+6, std::greater<int>()) == i67+6));
+ assert(std::is_heap(i68, i68+6, std::greater<int>()) == (std::is_heap_until(i68, i68+6, std::greater<int>()) == i68+6));
+ assert(std::is_heap(i69, i69+6, std::greater<int>()) == (std::is_heap_until(i69, i69+6, std::greater<int>()) == i69+6));
+ assert(std::is_heap(i70, i70+6, std::greater<int>()) == (std::is_heap_until(i70, i70+6, std::greater<int>()) == i70+6));
+ assert(std::is_heap(i71, i71+6, std::greater<int>()) == (std::is_heap_until(i71, i71+6, std::greater<int>()) == i71+6));
+ assert(std::is_heap(i72, i72+6, std::greater<int>()) == (std::is_heap_until(i72, i72+6, std::greater<int>()) == i72+6));
+ assert(std::is_heap(i73, i73+6, std::greater<int>()) == (std::is_heap_until(i73, i73+6, std::greater<int>()) == i73+6));
+ assert(std::is_heap(i74, i74+6, std::greater<int>()) == (std::is_heap_until(i74, i74+6, std::greater<int>()) == i74+6));
+ assert(std::is_heap(i75, i75+6, std::greater<int>()) == (std::is_heap_until(i75, i75+6, std::greater<int>()) == i75+6));
+ assert(std::is_heap(i76, i76+6, std::greater<int>()) == (std::is_heap_until(i76, i76+6, std::greater<int>()) == i76+6));
+ assert(std::is_heap(i77, i77+6, std::greater<int>()) == (std::is_heap_until(i77, i77+6, std::greater<int>()) == i77+6));
+ assert(std::is_heap(i78, i78+6, std::greater<int>()) == (std::is_heap_until(i78, i78+6, std::greater<int>()) == i78+6));
+ assert(std::is_heap(i79, i79+6, std::greater<int>()) == (std::is_heap_until(i79, i79+6, std::greater<int>()) == i79+6));
+ assert(std::is_heap(i80, i80+6, std::greater<int>()) == (std::is_heap_until(i80, i80+6, std::greater<int>()) == i80+6));
+ assert(std::is_heap(i81, i81+6, std::greater<int>()) == (std::is_heap_until(i81, i81+6, std::greater<int>()) == i81+6));
+ assert(std::is_heap(i82, i82+6, std::greater<int>()) == (std::is_heap_until(i82, i82+6, std::greater<int>()) == i82+6));
+ assert(std::is_heap(i83, i83+6, std::greater<int>()) == (std::is_heap_until(i83, i83+6, std::greater<int>()) == i83+6));
+ assert(std::is_heap(i84, i84+6, std::greater<int>()) == (std::is_heap_until(i84, i84+6, std::greater<int>()) == i84+6));
+ assert(std::is_heap(i85, i85+6, std::greater<int>()) == (std::is_heap_until(i85, i85+6, std::greater<int>()) == i85+6));
+ assert(std::is_heap(i86, i86+6, std::greater<int>()) == (std::is_heap_until(i86, i86+6, std::greater<int>()) == i86+6));
+ assert(std::is_heap(i87, i87+6, std::greater<int>()) == (std::is_heap_until(i87, i87+6, std::greater<int>()) == i87+6));
+ assert(std::is_heap(i88, i88+6, std::greater<int>()) == (std::is_heap_until(i88, i88+6, std::greater<int>()) == i88+6));
+ assert(std::is_heap(i89, i89+6, std::greater<int>()) == (std::is_heap_until(i89, i89+6, std::greater<int>()) == i89+6));
+ assert(std::is_heap(i90, i90+6, std::greater<int>()) == (std::is_heap_until(i90, i90+6, std::greater<int>()) == i90+6));
+ assert(std::is_heap(i91, i91+6, std::greater<int>()) == (std::is_heap_until(i91, i91+6, std::greater<int>()) == i91+6));
+ assert(std::is_heap(i92, i92+6, std::greater<int>()) == (std::is_heap_until(i92, i92+6, std::greater<int>()) == i92+6));
+ assert(std::is_heap(i93, i93+6, std::greater<int>()) == (std::is_heap_until(i93, i93+6, std::greater<int>()) == i93+6));
+ assert(std::is_heap(i94, i94+6, std::greater<int>()) == (std::is_heap_until(i94, i94+6, std::greater<int>()) == i94+6));
+ assert(std::is_heap(i95, i95+6, std::greater<int>()) == (std::is_heap_until(i95, i95+6, std::greater<int>()) == i95+6));
+ assert(std::is_heap(i96, i96+6, std::greater<int>()) == (std::is_heap_until(i96, i96+6, std::greater<int>()) == i96+6));
+ assert(std::is_heap(i97, i97+6, std::greater<int>()) == (std::is_heap_until(i97, i97+6, std::greater<int>()) == i97+6));
+ assert(std::is_heap(i98, i98+6, std::greater<int>()) == (std::is_heap_until(i98, i98+6, std::greater<int>()) == i98+6));
+ assert(std::is_heap(i99, i99+6, std::greater<int>()) == (std::is_heap_until(i99, i99+6, std::greater<int>()) == i99+6));
+ assert(std::is_heap(i100, i100+6, std::greater<int>()) == (std::is_heap_until(i100, i100+6, std::greater<int>()) == i100+6));
+ assert(std::is_heap(i101, i101+6, std::greater<int>()) == (std::is_heap_until(i101, i101+6, std::greater<int>()) == i101+6));
+ assert(std::is_heap(i102, i102+6, std::greater<int>()) == (std::is_heap_until(i102, i102+6, std::greater<int>()) == i102+6));
+ assert(std::is_heap(i103, i103+6, std::greater<int>()) == (std::is_heap_until(i103, i103+6, std::greater<int>()) == i103+6));
+ assert(std::is_heap(i104, i104+6, std::greater<int>()) == (std::is_heap_until(i104, i104+6, std::greater<int>()) == i104+6));
+ assert(std::is_heap(i105, i105+6, std::greater<int>()) == (std::is_heap_until(i105, i105+6, std::greater<int>()) == i105+6));
+ assert(std::is_heap(i106, i106+6, std::greater<int>()) == (std::is_heap_until(i106, i106+6, std::greater<int>()) == i106+6));
+ assert(std::is_heap(i107, i107+6, std::greater<int>()) == (std::is_heap_until(i107, i107+6, std::greater<int>()) == i107+6));
+ assert(std::is_heap(i108, i108+6, std::greater<int>()) == (std::is_heap_until(i108, i108+6, std::greater<int>()) == i108+6));
+ assert(std::is_heap(i109, i109+6, std::greater<int>()) == (std::is_heap_until(i109, i109+6, std::greater<int>()) == i109+6));
+ assert(std::is_heap(i110, i110+6, std::greater<int>()) == (std::is_heap_until(i110, i110+6, std::greater<int>()) == i110+6));
+ assert(std::is_heap(i111, i111+6, std::greater<int>()) == (std::is_heap_until(i111, i111+6, std::greater<int>()) == i111+6));
+ assert(std::is_heap(i112, i112+6, std::greater<int>()) == (std::is_heap_until(i112, i112+6, std::greater<int>()) == i112+6));
+ assert(std::is_heap(i113, i113+6, std::greater<int>()) == (std::is_heap_until(i113, i113+6, std::greater<int>()) == i113+6));
+ assert(std::is_heap(i114, i114+6, std::greater<int>()) == (std::is_heap_until(i114, i114+6, std::greater<int>()) == i114+6));
+ assert(std::is_heap(i115, i115+6, std::greater<int>()) == (std::is_heap_until(i115, i115+6, std::greater<int>()) == i115+6));
+ assert(std::is_heap(i116, i116+6, std::greater<int>()) == (std::is_heap_until(i116, i116+6, std::greater<int>()) == i116+6));
+ assert(std::is_heap(i117, i117+6, std::greater<int>()) == (std::is_heap_until(i117, i117+6, std::greater<int>()) == i117+6));
+ assert(std::is_heap(i118, i118+6, std::greater<int>()) == (std::is_heap_until(i118, i118+6, std::greater<int>()) == i118+6));
+ assert(std::is_heap(i119, i119+6, std::greater<int>()) == (std::is_heap_until(i119, i119+6, std::greater<int>()) == i119+6));
+ int i120[] = {0, 0, 0, 0, 0, 0, 0};
+ int i121[] = {0, 0, 0, 0, 0, 0, 1};
+ int i122[] = {0, 0, 0, 0, 0, 1, 0};
+ int i123[] = {0, 0, 0, 0, 0, 1, 1};
+ int i124[] = {0, 0, 0, 0, 1, 0, 0};
+ int i125[] = {0, 0, 0, 0, 1, 0, 1};
+ int i126[] = {0, 0, 0, 0, 1, 1, 0};
+ int i127[] = {0, 0, 0, 0, 1, 1, 1};
+ int i128[] = {0, 0, 0, 1, 0, 0, 0};
+ int i129[] = {0, 0, 0, 1, 0, 0, 1};
+ int i130[] = {0, 0, 0, 1, 0, 1, 0};
+ int i131[] = {0, 0, 0, 1, 0, 1, 1};
+ int i132[] = {0, 0, 0, 1, 1, 0, 0};
+ int i133[] = {0, 0, 0, 1, 1, 0, 1};
+ int i134[] = {0, 0, 0, 1, 1, 1, 0};
+ int i135[] = {0, 0, 0, 1, 1, 1, 1};
+ int i136[] = {0, 0, 1, 0, 0, 0, 0};
+ int i137[] = {0, 0, 1, 0, 0, 0, 1};
+ int i138[] = {0, 0, 1, 0, 0, 1, 0};
+ int i139[] = {0, 0, 1, 0, 0, 1, 1};
+ int i140[] = {0, 0, 1, 0, 1, 0, 0};
+ int i141[] = {0, 0, 1, 0, 1, 0, 1};
+ int i142[] = {0, 0, 1, 0, 1, 1, 0};
+ int i143[] = {0, 0, 1, 0, 1, 1, 1};
+ int i144[] = {0, 0, 1, 1, 0, 0, 0};
+ int i145[] = {0, 0, 1, 1, 0, 0, 1};
+ int i146[] = {0, 0, 1, 1, 0, 1, 0};
+ int i147[] = {0, 0, 1, 1, 0, 1, 1};
+ int i148[] = {0, 0, 1, 1, 1, 0, 0};
+ int i149[] = {0, 0, 1, 1, 1, 0, 1};
+ int i150[] = {0, 0, 1, 1, 1, 1, 0};
+ int i151[] = {0, 0, 1, 1, 1, 1, 1};
+ int i152[] = {0, 1, 0, 0, 0, 0, 0};
+ int i153[] = {0, 1, 0, 0, 0, 0, 1};
+ int i154[] = {0, 1, 0, 0, 0, 1, 0};
+ int i155[] = {0, 1, 0, 0, 0, 1, 1};
+ int i156[] = {0, 1, 0, 0, 1, 0, 0};
+ int i157[] = {0, 1, 0, 0, 1, 0, 1};
+ int i158[] = {0, 1, 0, 0, 1, 1, 0};
+ int i159[] = {0, 1, 0, 0, 1, 1, 1};
+ int i160[] = {0, 1, 0, 1, 0, 0, 0};
+ int i161[] = {0, 1, 0, 1, 0, 0, 1};
+ int i162[] = {0, 1, 0, 1, 0, 1, 0};
+ int i163[] = {0, 1, 0, 1, 0, 1, 1};
+ int i164[] = {0, 1, 0, 1, 1, 0, 0};
+ int i165[] = {0, 1, 0, 1, 1, 0, 1};
+ int i166[] = {0, 1, 0, 1, 1, 1, 0};
+ int i167[] = {0, 1, 0, 1, 1, 1, 1};
+ int i168[] = {0, 1, 1, 0, 0, 0, 0};
+ int i169[] = {0, 1, 1, 0, 0, 0, 1};
+ int i170[] = {0, 1, 1, 0, 0, 1, 0};
+ int i171[] = {0, 1, 1, 0, 0, 1, 1};
+ int i172[] = {0, 1, 1, 0, 1, 0, 0};
+ int i173[] = {0, 1, 1, 0, 1, 0, 1};
+ int i174[] = {0, 1, 1, 0, 1, 1, 0};
+ int i175[] = {0, 1, 1, 0, 1, 1, 1};
+ int i176[] = {0, 1, 1, 1, 0, 0, 0};
+ int i177[] = {0, 1, 1, 1, 0, 0, 1};
+ int i178[] = {0, 1, 1, 1, 0, 1, 0};
+ int i179[] = {0, 1, 1, 1, 0, 1, 1};
+ int i180[] = {0, 1, 1, 1, 1, 0, 0};
+ int i181[] = {0, 1, 1, 1, 1, 0, 1};
+ int i182[] = {0, 1, 1, 1, 1, 1, 0};
+ int i183[] = {0, 1, 1, 1, 1, 1, 1};
+ int i184[] = {1, 0, 0, 0, 0, 0, 0};
+ int i185[] = {1, 0, 0, 0, 0, 0, 1};
+ int i186[] = {1, 0, 0, 0, 0, 1, 0};
+ int i187[] = {1, 0, 0, 0, 0, 1, 1};
+ int i188[] = {1, 0, 0, 0, 1, 0, 0};
+ int i189[] = {1, 0, 0, 0, 1, 0, 1};
+ int i190[] = {1, 0, 0, 0, 1, 1, 0};
+ int i191[] = {1, 0, 0, 0, 1, 1, 1};
+ int i192[] = {1, 0, 0, 1, 0, 0, 0};
+ int i193[] = {1, 0, 0, 1, 0, 0, 1};
+ int i194[] = {1, 0, 0, 1, 0, 1, 0};
+ int i195[] = {1, 0, 0, 1, 0, 1, 1};
+ int i196[] = {1, 0, 0, 1, 1, 0, 0};
+ int i197[] = {1, 0, 0, 1, 1, 0, 1};
+ int i198[] = {1, 0, 0, 1, 1, 1, 0};
+ int i199[] = {1, 0, 0, 1, 1, 1, 1};
+ int i200[] = {1, 0, 1, 0, 0, 0, 0};
+ int i201[] = {1, 0, 1, 0, 0, 0, 1};
+ int i202[] = {1, 0, 1, 0, 0, 1, 0};
+ int i203[] = {1, 0, 1, 0, 0, 1, 1};
+ int i204[] = {1, 0, 1, 0, 1, 0, 0};
+ int i205[] = {1, 0, 1, 0, 1, 0, 1};
+ int i206[] = {1, 0, 1, 0, 1, 1, 0};
+ int i207[] = {1, 0, 1, 0, 1, 1, 1};
+ int i208[] = {1, 0, 1, 1, 0, 0, 0};
+ int i209[] = {1, 0, 1, 1, 0, 0, 1};
+ int i210[] = {1, 0, 1, 1, 0, 1, 0};
+ int i211[] = {1, 0, 1, 1, 0, 1, 1};
+ int i212[] = {1, 0, 1, 1, 1, 0, 0};
+ int i213[] = {1, 0, 1, 1, 1, 0, 1};
+ int i214[] = {1, 0, 1, 1, 1, 1, 0};
+ int i215[] = {1, 0, 1, 1, 1, 1, 1};
+ int i216[] = {1, 1, 0, 0, 0, 0, 0};
+ int i217[] = {1, 1, 0, 0, 0, 0, 1};
+ int i218[] = {1, 1, 0, 0, 0, 1, 0};
+ int i219[] = {1, 1, 0, 0, 0, 1, 1};
+ int i220[] = {1, 1, 0, 0, 1, 0, 0};
+ int i221[] = {1, 1, 0, 0, 1, 0, 1};
+ int i222[] = {1, 1, 0, 0, 1, 1, 0};
+ int i223[] = {1, 1, 0, 0, 1, 1, 1};
+ int i224[] = {1, 1, 0, 1, 0, 0, 0};
+ int i225[] = {1, 1, 0, 1, 0, 0, 1};
+ int i226[] = {1, 1, 0, 1, 0, 1, 0};
+ int i227[] = {1, 1, 0, 1, 0, 1, 1};
+ int i228[] = {1, 1, 0, 1, 1, 0, 0};
+ int i229[] = {1, 1, 0, 1, 1, 0, 1};
+ int i230[] = {1, 1, 0, 1, 1, 1, 0};
+ int i231[] = {1, 1, 0, 1, 1, 1, 1};
+ int i232[] = {1, 1, 1, 0, 0, 0, 0};
+ int i233[] = {1, 1, 1, 0, 0, 0, 1};
+ int i234[] = {1, 1, 1, 0, 0, 1, 0};
+ int i235[] = {1, 1, 1, 0, 0, 1, 1};
+ int i236[] = {1, 1, 1, 0, 1, 0, 0};
+ int i237[] = {1, 1, 1, 0, 1, 0, 1};
+ int i238[] = {1, 1, 1, 0, 1, 1, 0};
+ int i239[] = {1, 1, 1, 0, 1, 1, 1};
+ int i240[] = {1, 1, 1, 1, 0, 0, 0};
+ int i241[] = {1, 1, 1, 1, 0, 0, 1};
+ int i242[] = {1, 1, 1, 1, 0, 1, 0};
+ int i243[] = {1, 1, 1, 1, 0, 1, 1};
+ int i244[] = {1, 1, 1, 1, 1, 0, 0};
+ int i245[] = {1, 1, 1, 1, 1, 0, 1};
+ int i246[] = {1, 1, 1, 1, 1, 1, 0};
+ assert(std::is_heap(i120, i120+7, std::greater<int>()) == (std::is_heap_until(i120, i120+7, std::greater<int>()) == i120+7));
+ assert(std::is_heap(i121, i121+7, std::greater<int>()) == (std::is_heap_until(i121, i121+7, std::greater<int>()) == i121+7));
+ assert(std::is_heap(i122, i122+7, std::greater<int>()) == (std::is_heap_until(i122, i122+7, std::greater<int>()) == i122+7));
+ assert(std::is_heap(i123, i123+7, std::greater<int>()) == (std::is_heap_until(i123, i123+7, std::greater<int>()) == i123+7));
+ assert(std::is_heap(i124, i124+7, std::greater<int>()) == (std::is_heap_until(i124, i124+7, std::greater<int>()) == i124+7));
+ assert(std::is_heap(i125, i125+7, std::greater<int>()) == (std::is_heap_until(i125, i125+7, std::greater<int>()) == i125+7));
+ assert(std::is_heap(i126, i126+7, std::greater<int>()) == (std::is_heap_until(i126, i126+7, std::greater<int>()) == i126+7));
+ assert(std::is_heap(i127, i127+7, std::greater<int>()) == (std::is_heap_until(i127, i127+7, std::greater<int>()) == i127+7));
+ assert(std::is_heap(i128, i128+7, std::greater<int>()) == (std::is_heap_until(i128, i128+7, std::greater<int>()) == i128+7));
+ assert(std::is_heap(i129, i129+7, std::greater<int>()) == (std::is_heap_until(i129, i129+7, std::greater<int>()) == i129+7));
+ assert(std::is_heap(i130, i130+7, std::greater<int>()) == (std::is_heap_until(i130, i130+7, std::greater<int>()) == i130+7));
+ assert(std::is_heap(i131, i131+7, std::greater<int>()) == (std::is_heap_until(i131, i131+7, std::greater<int>()) == i131+7));
+ assert(std::is_heap(i132, i132+7, std::greater<int>()) == (std::is_heap_until(i132, i132+7, std::greater<int>()) == i132+7));
+ assert(std::is_heap(i133, i133+7, std::greater<int>()) == (std::is_heap_until(i133, i133+7, std::greater<int>()) == i133+7));
+ assert(std::is_heap(i134, i134+7, std::greater<int>()) == (std::is_heap_until(i134, i134+7, std::greater<int>()) == i134+7));
+ assert(std::is_heap(i135, i135+7, std::greater<int>()) == (std::is_heap_until(i135, i135+7, std::greater<int>()) == i135+7));
+ assert(std::is_heap(i136, i136+7, std::greater<int>()) == (std::is_heap_until(i136, i136+7, std::greater<int>()) == i136+7));
+ assert(std::is_heap(i137, i137+7, std::greater<int>()) == (std::is_heap_until(i137, i137+7, std::greater<int>()) == i137+7));
+ assert(std::is_heap(i138, i138+7, std::greater<int>()) == (std::is_heap_until(i138, i138+7, std::greater<int>()) == i138+7));
+ assert(std::is_heap(i139, i139+7, std::greater<int>()) == (std::is_heap_until(i139, i139+7, std::greater<int>()) == i139+7));
+ assert(std::is_heap(i140, i140+7, std::greater<int>()) == (std::is_heap_until(i140, i140+7, std::greater<int>()) == i140+7));
+ assert(std::is_heap(i141, i141+7, std::greater<int>()) == (std::is_heap_until(i141, i141+7, std::greater<int>()) == i141+7));
+ assert(std::is_heap(i142, i142+7, std::greater<int>()) == (std::is_heap_until(i142, i142+7, std::greater<int>()) == i142+7));
+ assert(std::is_heap(i143, i143+7, std::greater<int>()) == (std::is_heap_until(i143, i143+7, std::greater<int>()) == i143+7));
+ assert(std::is_heap(i144, i144+7, std::greater<int>()) == (std::is_heap_until(i144, i144+7, std::greater<int>()) == i144+7));
+ assert(std::is_heap(i145, i145+7, std::greater<int>()) == (std::is_heap_until(i145, i145+7, std::greater<int>()) == i145+7));
+ assert(std::is_heap(i146, i146+7, std::greater<int>()) == (std::is_heap_until(i146, i146+7, std::greater<int>()) == i146+7));
+ assert(std::is_heap(i147, i147+7, std::greater<int>()) == (std::is_heap_until(i147, i147+7, std::greater<int>()) == i147+7));
+ assert(std::is_heap(i148, i148+7, std::greater<int>()) == (std::is_heap_until(i148, i148+7, std::greater<int>()) == i148+7));
+ assert(std::is_heap(i149, i149+7, std::greater<int>()) == (std::is_heap_until(i149, i149+7, std::greater<int>()) == i149+7));
+ assert(std::is_heap(i150, i150+7, std::greater<int>()) == (std::is_heap_until(i150, i150+7, std::greater<int>()) == i150+7));
+ assert(std::is_heap(i151, i151+7, std::greater<int>()) == (std::is_heap_until(i151, i151+7, std::greater<int>()) == i151+7));
+ assert(std::is_heap(i152, i152+7, std::greater<int>()) == (std::is_heap_until(i152, i152+7, std::greater<int>()) == i152+7));
+ assert(std::is_heap(i153, i153+7, std::greater<int>()) == (std::is_heap_until(i153, i153+7, std::greater<int>()) == i153+7));
+ assert(std::is_heap(i154, i154+7, std::greater<int>()) == (std::is_heap_until(i154, i154+7, std::greater<int>()) == i154+7));
+ assert(std::is_heap(i155, i155+7, std::greater<int>()) == (std::is_heap_until(i155, i155+7, std::greater<int>()) == i155+7));
+ assert(std::is_heap(i156, i156+7, std::greater<int>()) == (std::is_heap_until(i156, i156+7, std::greater<int>()) == i156+7));
+ assert(std::is_heap(i157, i157+7, std::greater<int>()) == (std::is_heap_until(i157, i157+7, std::greater<int>()) == i157+7));
+ assert(std::is_heap(i158, i158+7, std::greater<int>()) == (std::is_heap_until(i158, i158+7, std::greater<int>()) == i158+7));
+ assert(std::is_heap(i159, i159+7, std::greater<int>()) == (std::is_heap_until(i159, i159+7, std::greater<int>()) == i159+7));
+ assert(std::is_heap(i160, i160+7, std::greater<int>()) == (std::is_heap_until(i160, i160+7, std::greater<int>()) == i160+7));
+ assert(std::is_heap(i161, i161+7, std::greater<int>()) == (std::is_heap_until(i161, i161+7, std::greater<int>()) == i161+7));
+ assert(std::is_heap(i162, i162+7, std::greater<int>()) == (std::is_heap_until(i162, i162+7, std::greater<int>()) == i162+7));
+ assert(std::is_heap(i163, i163+7, std::greater<int>()) == (std::is_heap_until(i163, i163+7, std::greater<int>()) == i163+7));
+ assert(std::is_heap(i164, i164+7, std::greater<int>()) == (std::is_heap_until(i164, i164+7, std::greater<int>()) == i164+7));
+ assert(std::is_heap(i165, i165+7, std::greater<int>()) == (std::is_heap_until(i165, i165+7, std::greater<int>()) == i165+7));
+ assert(std::is_heap(i166, i166+7, std::greater<int>()) == (std::is_heap_until(i166, i166+7, std::greater<int>()) == i166+7));
+ assert(std::is_heap(i167, i167+7, std::greater<int>()) == (std::is_heap_until(i167, i167+7, std::greater<int>()) == i167+7));
+ assert(std::is_heap(i168, i168+7, std::greater<int>()) == (std::is_heap_until(i168, i168+7, std::greater<int>()) == i168+7));
+ assert(std::is_heap(i169, i169+7, std::greater<int>()) == (std::is_heap_until(i169, i169+7, std::greater<int>()) == i169+7));
+ assert(std::is_heap(i170, i170+7, std::greater<int>()) == (std::is_heap_until(i170, i170+7, std::greater<int>()) == i170+7));
+ assert(std::is_heap(i171, i171+7, std::greater<int>()) == (std::is_heap_until(i171, i171+7, std::greater<int>()) == i171+7));
+ assert(std::is_heap(i172, i172+7, std::greater<int>()) == (std::is_heap_until(i172, i172+7, std::greater<int>()) == i172+7));
+ assert(std::is_heap(i173, i173+7, std::greater<int>()) == (std::is_heap_until(i173, i173+7, std::greater<int>()) == i173+7));
+ assert(std::is_heap(i174, i174+7, std::greater<int>()) == (std::is_heap_until(i174, i174+7, std::greater<int>()) == i174+7));
+ assert(std::is_heap(i175, i175+7, std::greater<int>()) == (std::is_heap_until(i175, i175+7, std::greater<int>()) == i175+7));
+ assert(std::is_heap(i176, i176+7, std::greater<int>()) == (std::is_heap_until(i176, i176+7, std::greater<int>()) == i176+7));
+ assert(std::is_heap(i177, i177+7, std::greater<int>()) == (std::is_heap_until(i177, i177+7, std::greater<int>()) == i177+7));
+ assert(std::is_heap(i178, i178+7, std::greater<int>()) == (std::is_heap_until(i178, i178+7, std::greater<int>()) == i178+7));
+ assert(std::is_heap(i179, i179+7, std::greater<int>()) == (std::is_heap_until(i179, i179+7, std::greater<int>()) == i179+7));
+ assert(std::is_heap(i180, i180+7, std::greater<int>()) == (std::is_heap_until(i180, i180+7, std::greater<int>()) == i180+7));
+ assert(std::is_heap(i181, i181+7, std::greater<int>()) == (std::is_heap_until(i181, i181+7, std::greater<int>()) == i181+7));
+ assert(std::is_heap(i182, i182+7, std::greater<int>()) == (std::is_heap_until(i182, i182+7, std::greater<int>()) == i182+7));
+ assert(std::is_heap(i183, i183+7, std::greater<int>()) == (std::is_heap_until(i183, i183+7, std::greater<int>()) == i183+7));
+ assert(std::is_heap(i184, i184+7, std::greater<int>()) == (std::is_heap_until(i184, i184+7, std::greater<int>()) == i184+7));
+ assert(std::is_heap(i185, i185+7, std::greater<int>()) == (std::is_heap_until(i185, i185+7, std::greater<int>()) == i185+7));
+ assert(std::is_heap(i186, i186+7, std::greater<int>()) == (std::is_heap_until(i186, i186+7, std::greater<int>()) == i186+7));
+ assert(std::is_heap(i187, i187+7, std::greater<int>()) == (std::is_heap_until(i187, i187+7, std::greater<int>()) == i187+7));
+ assert(std::is_heap(i188, i188+7, std::greater<int>()) == (std::is_heap_until(i188, i188+7, std::greater<int>()) == i188+7));
+ assert(std::is_heap(i189, i189+7, std::greater<int>()) == (std::is_heap_until(i189, i189+7, std::greater<int>()) == i189+7));
+ assert(std::is_heap(i190, i190+7, std::greater<int>()) == (std::is_heap_until(i190, i190+7, std::greater<int>()) == i190+7));
+ assert(std::is_heap(i191, i191+7, std::greater<int>()) == (std::is_heap_until(i191, i191+7, std::greater<int>()) == i191+7));
+ assert(std::is_heap(i192, i192+7, std::greater<int>()) == (std::is_heap_until(i192, i192+7, std::greater<int>()) == i192+7));
+ assert(std::is_heap(i193, i193+7, std::greater<int>()) == (std::is_heap_until(i193, i193+7, std::greater<int>()) == i193+7));
+ assert(std::is_heap(i194, i194+7, std::greater<int>()) == (std::is_heap_until(i194, i194+7, std::greater<int>()) == i194+7));
+ assert(std::is_heap(i195, i195+7, std::greater<int>()) == (std::is_heap_until(i195, i195+7, std::greater<int>()) == i195+7));
+ assert(std::is_heap(i196, i196+7, std::greater<int>()) == (std::is_heap_until(i196, i196+7, std::greater<int>()) == i196+7));
+ assert(std::is_heap(i197, i197+7, std::greater<int>()) == (std::is_heap_until(i197, i197+7, std::greater<int>()) == i197+7));
+ assert(std::is_heap(i198, i198+7, std::greater<int>()) == (std::is_heap_until(i198, i198+7, std::greater<int>()) == i198+7));
+ assert(std::is_heap(i199, i199+7, std::greater<int>()) == (std::is_heap_until(i199, i199+7, std::greater<int>()) == i199+7));
+ assert(std::is_heap(i200, i200+7, std::greater<int>()) == (std::is_heap_until(i200, i200+7, std::greater<int>()) == i200+7));
+ assert(std::is_heap(i201, i201+7, std::greater<int>()) == (std::is_heap_until(i201, i201+7, std::greater<int>()) == i201+7));
+ assert(std::is_heap(i202, i202+7, std::greater<int>()) == (std::is_heap_until(i202, i202+7, std::greater<int>()) == i202+7));
+ assert(std::is_heap(i203, i203+7, std::greater<int>()) == (std::is_heap_until(i203, i203+7, std::greater<int>()) == i203+7));
+ assert(std::is_heap(i204, i204+7, std::greater<int>()) == (std::is_heap_until(i204, i204+7, std::greater<int>()) == i204+7));
+ assert(std::is_heap(i205, i205+7, std::greater<int>()) == (std::is_heap_until(i205, i205+7, std::greater<int>()) == i205+7));
+ assert(std::is_heap(i206, i206+7, std::greater<int>()) == (std::is_heap_until(i206, i206+7, std::greater<int>()) == i206+7));
+ assert(std::is_heap(i207, i207+7, std::greater<int>()) == (std::is_heap_until(i207, i207+7, std::greater<int>()) == i207+7));
+ assert(std::is_heap(i208, i208+7, std::greater<int>()) == (std::is_heap_until(i208, i208+7, std::greater<int>()) == i208+7));
+ assert(std::is_heap(i209, i209+7, std::greater<int>()) == (std::is_heap_until(i209, i209+7, std::greater<int>()) == i209+7));
+ assert(std::is_heap(i210, i210+7, std::greater<int>()) == (std::is_heap_until(i210, i210+7, std::greater<int>()) == i210+7));
+ assert(std::is_heap(i211, i211+7, std::greater<int>()) == (std::is_heap_until(i211, i211+7, std::greater<int>()) == i211+7));
+ assert(std::is_heap(i212, i212+7, std::greater<int>()) == (std::is_heap_until(i212, i212+7, std::greater<int>()) == i212+7));
+ assert(std::is_heap(i213, i213+7, std::greater<int>()) == (std::is_heap_until(i213, i213+7, std::greater<int>()) == i213+7));
+ assert(std::is_heap(i214, i214+7, std::greater<int>()) == (std::is_heap_until(i214, i214+7, std::greater<int>()) == i214+7));
+ assert(std::is_heap(i215, i215+7, std::greater<int>()) == (std::is_heap_until(i215, i215+7, std::greater<int>()) == i215+7));
+ assert(std::is_heap(i216, i216+7, std::greater<int>()) == (std::is_heap_until(i216, i216+7, std::greater<int>()) == i216+7));
+ assert(std::is_heap(i217, i217+7, std::greater<int>()) == (std::is_heap_until(i217, i217+7, std::greater<int>()) == i217+7));
+ assert(std::is_heap(i218, i218+7, std::greater<int>()) == (std::is_heap_until(i218, i218+7, std::greater<int>()) == i218+7));
+ assert(std::is_heap(i219, i219+7, std::greater<int>()) == (std::is_heap_until(i219, i219+7, std::greater<int>()) == i219+7));
+ assert(std::is_heap(i220, i220+7, std::greater<int>()) == (std::is_heap_until(i220, i220+7, std::greater<int>()) == i220+7));
+ assert(std::is_heap(i221, i221+7, std::greater<int>()) == (std::is_heap_until(i221, i221+7, std::greater<int>()) == i221+7));
+ assert(std::is_heap(i222, i222+7, std::greater<int>()) == (std::is_heap_until(i222, i222+7, std::greater<int>()) == i222+7));
+ assert(std::is_heap(i223, i223+7, std::greater<int>()) == (std::is_heap_until(i223, i223+7, std::greater<int>()) == i223+7));
+ assert(std::is_heap(i224, i224+7, std::greater<int>()) == (std::is_heap_until(i224, i224+7, std::greater<int>()) == i224+7));
+ assert(std::is_heap(i225, i225+7, std::greater<int>()) == (std::is_heap_until(i225, i225+7, std::greater<int>()) == i225+7));
+ assert(std::is_heap(i226, i226+7, std::greater<int>()) == (std::is_heap_until(i226, i226+7, std::greater<int>()) == i226+7));
+ assert(std::is_heap(i227, i227+7, std::greater<int>()) == (std::is_heap_until(i227, i227+7, std::greater<int>()) == i227+7));
+ assert(std::is_heap(i228, i228+7, std::greater<int>()) == (std::is_heap_until(i228, i228+7, std::greater<int>()) == i228+7));
+ assert(std::is_heap(i229, i229+7, std::greater<int>()) == (std::is_heap_until(i229, i229+7, std::greater<int>()) == i229+7));
+ assert(std::is_heap(i230, i230+7, std::greater<int>()) == (std::is_heap_until(i230, i230+7, std::greater<int>()) == i230+7));
+ assert(std::is_heap(i231, i231+7, std::greater<int>()) == (std::is_heap_until(i231, i231+7, std::greater<int>()) == i231+7));
+ assert(std::is_heap(i232, i232+7, std::greater<int>()) == (std::is_heap_until(i232, i232+7, std::greater<int>()) == i232+7));
+ assert(std::is_heap(i233, i233+7, std::greater<int>()) == (std::is_heap_until(i233, i233+7, std::greater<int>()) == i233+7));
+ assert(std::is_heap(i234, i234+7, std::greater<int>()) == (std::is_heap_until(i234, i234+7, std::greater<int>()) == i234+7));
+ assert(std::is_heap(i235, i235+7, std::greater<int>()) == (std::is_heap_until(i235, i235+7, std::greater<int>()) == i235+7));
+ assert(std::is_heap(i236, i236+7, std::greater<int>()) == (std::is_heap_until(i236, i236+7, std::greater<int>()) == i236+7));
+ assert(std::is_heap(i237, i237+7, std::greater<int>()) == (std::is_heap_until(i237, i237+7, std::greater<int>()) == i237+7));
+ assert(std::is_heap(i238, i238+7, std::greater<int>()) == (std::is_heap_until(i238, i238+7, std::greater<int>()) == i238+7));
+ assert(std::is_heap(i239, i239+7, std::greater<int>()) == (std::is_heap_until(i239, i239+7, std::greater<int>()) == i239+7));
+ assert(std::is_heap(i240, i240+7, std::greater<int>()) == (std::is_heap_until(i240, i240+7, std::greater<int>()) == i240+7));
+ assert(std::is_heap(i241, i241+7, std::greater<int>()) == (std::is_heap_until(i241, i241+7, std::greater<int>()) == i241+7));
+ assert(std::is_heap(i242, i242+7, std::greater<int>()) == (std::is_heap_until(i242, i242+7, std::greater<int>()) == i242+7));
+ assert(std::is_heap(i243, i243+7, std::greater<int>()) == (std::is_heap_until(i243, i243+7, std::greater<int>()) == i243+7));
+ assert(std::is_heap(i244, i244+7, std::greater<int>()) == (std::is_heap_until(i244, i244+7, std::greater<int>()) == i244+7));
+ assert(std::is_heap(i245, i245+7, std::greater<int>()) == (std::is_heap_until(i245, i245+7, std::greater<int>()) == i245+7));
+ assert(std::is_heap(i246, i246+7, std::greater<int>()) == (std::is_heap_until(i246, i246+7, std::greater<int>()) == i246+7));
+}
+
+int main()
+{
+ test();
+}
diff --git a/test/std/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap_until.pass.cpp b/test/std/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap_until.pass.cpp
new file mode 100644
index 000000000000..082c04451825
--- /dev/null
+++ b/test/std/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap_until.pass.cpp
@@ -0,0 +1,521 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<RandomAccessIterator Iter>
+// requires LessThanComparable<Iter::value_type>
+// Iter
+// is_heap_until(Iter first, Iter last);
+
+#include <algorithm>
+#include <cassert>
+
+void test()
+{
+ int i1[] = {0, 0};
+ assert(std::is_heap_until(i1, i1) == i1);
+ assert(std::is_heap_until(i1, i1+1) == i1+1);
+ int i2[] = {0, 1};
+ int i3[] = {1, 0};
+ assert(std::is_heap_until(i1, i1+2) == i1+2);
+ assert(std::is_heap_until(i2, i2+2) == i2+1);
+ assert(std::is_heap_until(i3, i3+2) == i3+2);
+ int i4[] = {0, 0, 0};
+ int i5[] = {0, 0, 1};
+ int i6[] = {0, 1, 0};
+ int i7[] = {0, 1, 1};
+ int i8[] = {1, 0, 0};
+ int i9[] = {1, 0, 1};
+ int i10[] = {1, 1, 0};
+ assert(std::is_heap_until(i4, i4+3) == i4+3);
+ assert(std::is_heap_until(i5, i5+3) == i5+2);
+ assert(std::is_heap_until(i6, i6+3) == i6+1);
+ assert(std::is_heap_until(i7, i7+3) == i7+1);
+ assert(std::is_heap_until(i8, i8+3) == i8+3);
+ assert(std::is_heap_until(i9, i9+3) == i9+3);
+ assert(std::is_heap_until(i10, i10+3) == i10+3);
+ int i11[] = {0, 0, 0, 0};
+ int i12[] = {0, 0, 0, 1};
+ int i13[] = {0, 0, 1, 0};
+ int i14[] = {0, 0, 1, 1};
+ int i15[] = {0, 1, 0, 0};
+ int i16[] = {0, 1, 0, 1};
+ int i17[] = {0, 1, 1, 0};
+ int i18[] = {0, 1, 1, 1};
+ int i19[] = {1, 0, 0, 0};
+ int i20[] = {1, 0, 0, 1};
+ int i21[] = {1, 0, 1, 0};
+ int i22[] = {1, 0, 1, 1};
+ int i23[] = {1, 1, 0, 0};
+ int i24[] = {1, 1, 0, 1};
+ int i25[] = {1, 1, 1, 0};
+ assert(std::is_heap_until(i11, i11+4) == i11+4);
+ assert(std::is_heap_until(i12, i12+4) == i12+3);
+ assert(std::is_heap_until(i13, i13+4) == i13+2);
+ assert(std::is_heap_until(i14, i14+4) == i14+2);
+ assert(std::is_heap_until(i15, i15+4) == i15+1);
+ assert(std::is_heap_until(i16, i16+4) == i16+1);
+ assert(std::is_heap_until(i17, i17+4) == i17+1);
+ assert(std::is_heap_until(i18, i18+4) == i18+1);
+ assert(std::is_heap_until(i19, i19+4) == i19+4);
+ assert(std::is_heap_until(i20, i20+4) == i20+3);
+ assert(std::is_heap_until(i21, i21+4) == i21+4);
+ assert(std::is_heap_until(i22, i22+4) == i22+3);
+ assert(std::is_heap_until(i23, i23+4) == i23+4);
+ assert(std::is_heap_until(i24, i24+4) == i24+4);
+ assert(std::is_heap_until(i25, i25+4) == i25+4);
+ int i26[] = {0, 0, 0, 0, 0};
+ int i27[] = {0, 0, 0, 0, 1};
+ int i28[] = {0, 0, 0, 1, 0};
+ int i29[] = {0, 0, 0, 1, 1};
+ int i30[] = {0, 0, 1, 0, 0};
+ int i31[] = {0, 0, 1, 0, 1};
+ int i32[] = {0, 0, 1, 1, 0};
+ int i33[] = {0, 0, 1, 1, 1};
+ int i34[] = {0, 1, 0, 0, 0};
+ int i35[] = {0, 1, 0, 0, 1};
+ int i36[] = {0, 1, 0, 1, 0};
+ int i37[] = {0, 1, 0, 1, 1};
+ int i38[] = {0, 1, 1, 0, 0};
+ int i39[] = {0, 1, 1, 0, 1};
+ int i40[] = {0, 1, 1, 1, 0};
+ int i41[] = {0, 1, 1, 1, 1};
+ int i42[] = {1, 0, 0, 0, 0};
+ int i43[] = {1, 0, 0, 0, 1};
+ int i44[] = {1, 0, 0, 1, 0};
+ int i45[] = {1, 0, 0, 1, 1};
+ int i46[] = {1, 0, 1, 0, 0};
+ int i47[] = {1, 0, 1, 0, 1};
+ int i48[] = {1, 0, 1, 1, 0};
+ int i49[] = {1, 0, 1, 1, 1};
+ int i50[] = {1, 1, 0, 0, 0};
+ int i51[] = {1, 1, 0, 0, 1};
+ int i52[] = {1, 1, 0, 1, 0};
+ int i53[] = {1, 1, 0, 1, 1};
+ int i54[] = {1, 1, 1, 0, 0};
+ int i55[] = {1, 1, 1, 0, 1};
+ int i56[] = {1, 1, 1, 1, 0};
+ assert(std::is_heap_until(i26, i26+5) == i26+5);
+ assert(std::is_heap_until(i27, i27+5) == i27+4);
+ assert(std::is_heap_until(i28, i28+5) == i28+3);
+ assert(std::is_heap_until(i29, i29+5) == i29+3);
+ assert(std::is_heap_until(i30, i30+5) == i30+2);
+ assert(std::is_heap_until(i31, i31+5) == i31+2);
+ assert(std::is_heap_until(i32, i32+5) == i32+2);
+ assert(std::is_heap_until(i33, i33+5) == i33+2);
+ assert(std::is_heap_until(i34, i34+5) == i34+1);
+ assert(std::is_heap_until(i35, i35+5) == i35+1);
+ assert(std::is_heap_until(i36, i36+5) == i36+1);
+ assert(std::is_heap_until(i37, i37+5) == i37+1);
+ assert(std::is_heap_until(i38, i38+5) == i38+1);
+ assert(std::is_heap_until(i39, i39+5) == i39+1);
+ assert(std::is_heap_until(i40, i40+5) == i40+1);
+ assert(std::is_heap_until(i41, i41+5) == i41+1);
+ assert(std::is_heap_until(i42, i42+5) == i42+5);
+ assert(std::is_heap_until(i43, i43+5) == i43+4);
+ assert(std::is_heap_until(i44, i44+5) == i44+3);
+ assert(std::is_heap_until(i45, i45+5) == i45+3);
+ assert(std::is_heap_until(i46, i46+5) == i46+5);
+ assert(std::is_heap_until(i47, i47+5) == i47+4);
+ assert(std::is_heap_until(i48, i48+5) == i48+3);
+ assert(std::is_heap_until(i49, i49+5) == i49+3);
+ assert(std::is_heap_until(i50, i50+5) == i50+5);
+ assert(std::is_heap_until(i51, i51+5) == i51+5);
+ assert(std::is_heap_until(i52, i52+5) == i52+5);
+ assert(std::is_heap_until(i53, i53+5) == i53+5);
+ assert(std::is_heap_until(i54, i54+5) == i54+5);
+ assert(std::is_heap_until(i55, i55+5) == i55+5);
+ assert(std::is_heap_until(i56, i56+5) == i56+5);
+ int i57[] = {0, 0, 0, 0, 0, 0};
+ int i58[] = {0, 0, 0, 0, 0, 1};
+ int i59[] = {0, 0, 0, 0, 1, 0};
+ int i60[] = {0, 0, 0, 0, 1, 1};
+ int i61[] = {0, 0, 0, 1, 0, 0};
+ int i62[] = {0, 0, 0, 1, 0, 1};
+ int i63[] = {0, 0, 0, 1, 1, 0};
+ int i64[] = {0, 0, 0, 1, 1, 1};
+ int i65[] = {0, 0, 1, 0, 0, 0};
+ int i66[] = {0, 0, 1, 0, 0, 1};
+ int i67[] = {0, 0, 1, 0, 1, 0};
+ int i68[] = {0, 0, 1, 0, 1, 1};
+ int i69[] = {0, 0, 1, 1, 0, 0};
+ int i70[] = {0, 0, 1, 1, 0, 1};
+ int i71[] = {0, 0, 1, 1, 1, 0};
+ int i72[] = {0, 0, 1, 1, 1, 1};
+ int i73[] = {0, 1, 0, 0, 0, 0};
+ int i74[] = {0, 1, 0, 0, 0, 1};
+ int i75[] = {0, 1, 0, 0, 1, 0};
+ int i76[] = {0, 1, 0, 0, 1, 1};
+ int i77[] = {0, 1, 0, 1, 0, 0};
+ int i78[] = {0, 1, 0, 1, 0, 1};
+ int i79[] = {0, 1, 0, 1, 1, 0};
+ int i80[] = {0, 1, 0, 1, 1, 1};
+ int i81[] = {0, 1, 1, 0, 0, 0};
+ int i82[] = {0, 1, 1, 0, 0, 1};
+ int i83[] = {0, 1, 1, 0, 1, 0};
+ int i84[] = {0, 1, 1, 0, 1, 1};
+ int i85[] = {0, 1, 1, 1, 0, 0};
+ int i86[] = {0, 1, 1, 1, 0, 1};
+ int i87[] = {0, 1, 1, 1, 1, 0};
+ int i88[] = {0, 1, 1, 1, 1, 1};
+ int i89[] = {1, 0, 0, 0, 0, 0};
+ int i90[] = {1, 0, 0, 0, 0, 1};
+ int i91[] = {1, 0, 0, 0, 1, 0};
+ int i92[] = {1, 0, 0, 0, 1, 1};
+ int i93[] = {1, 0, 0, 1, 0, 0};
+ int i94[] = {1, 0, 0, 1, 0, 1};
+ int i95[] = {1, 0, 0, 1, 1, 0};
+ int i96[] = {1, 0, 0, 1, 1, 1};
+ int i97[] = {1, 0, 1, 0, 0, 0};
+ int i98[] = {1, 0, 1, 0, 0, 1};
+ int i99[] = {1, 0, 1, 0, 1, 0};
+ int i100[] = {1, 0, 1, 0, 1, 1};
+ int i101[] = {1, 0, 1, 1, 0, 0};
+ int i102[] = {1, 0, 1, 1, 0, 1};
+ int i103[] = {1, 0, 1, 1, 1, 0};
+ int i104[] = {1, 0, 1, 1, 1, 1};
+ int i105[] = {1, 1, 0, 0, 0, 0};
+ int i106[] = {1, 1, 0, 0, 0, 1};
+ int i107[] = {1, 1, 0, 0, 1, 0};
+ int i108[] = {1, 1, 0, 0, 1, 1};
+ int i109[] = {1, 1, 0, 1, 0, 0};
+ int i110[] = {1, 1, 0, 1, 0, 1};
+ int i111[] = {1, 1, 0, 1, 1, 0};
+ int i112[] = {1, 1, 0, 1, 1, 1};
+ int i113[] = {1, 1, 1, 0, 0, 0};
+ int i114[] = {1, 1, 1, 0, 0, 1};
+ int i115[] = {1, 1, 1, 0, 1, 0};
+ int i116[] = {1, 1, 1, 0, 1, 1};
+ int i117[] = {1, 1, 1, 1, 0, 0};
+ int i118[] = {1, 1, 1, 1, 0, 1};
+ int i119[] = {1, 1, 1, 1, 1, 0};
+ assert(std::is_heap_until(i57, i57+6) == i57+6);
+ assert(std::is_heap_until(i58, i58+6) == i58+5);
+ assert(std::is_heap_until(i59, i59+6) == i59+4);
+ assert(std::is_heap_until(i60, i60+6) == i60+4);
+ assert(std::is_heap_until(i61, i61+6) == i61+3);
+ assert(std::is_heap_until(i62, i62+6) == i62+3);
+ assert(std::is_heap_until(i63, i63+6) == i63+3);
+ assert(std::is_heap_until(i64, i64+6) == i64+3);
+ assert(std::is_heap_until(i65, i65+6) == i65+2);
+ assert(std::is_heap_until(i66, i66+6) == i66+2);
+ assert(std::is_heap_until(i67, i67+6) == i67+2);
+ assert(std::is_heap_until(i68, i68+6) == i68+2);
+ assert(std::is_heap_until(i69, i69+6) == i69+2);
+ assert(std::is_heap_until(i70, i70+6) == i70+2);
+ assert(std::is_heap_until(i71, i71+6) == i71+2);
+ assert(std::is_heap_until(i72, i72+6) == i72+2);
+ assert(std::is_heap_until(i73, i73+6) == i73+1);
+ assert(std::is_heap_until(i74, i74+6) == i74+1);
+ assert(std::is_heap_until(i75, i75+6) == i75+1);
+ assert(std::is_heap_until(i76, i76+6) == i76+1);
+ assert(std::is_heap_until(i77, i77+6) == i77+1);
+ assert(std::is_heap_until(i78, i78+6) == i78+1);
+ assert(std::is_heap_until(i79, i79+6) == i79+1);
+ assert(std::is_heap_until(i80, i80+6) == i80+1);
+ assert(std::is_heap_until(i81, i81+6) == i81+1);
+ assert(std::is_heap_until(i82, i82+6) == i82+1);
+ assert(std::is_heap_until(i83, i83+6) == i83+1);
+ assert(std::is_heap_until(i84, i84+6) == i84+1);
+ assert(std::is_heap_until(i85, i85+6) == i85+1);
+ assert(std::is_heap_until(i86, i86+6) == i86+1);
+ assert(std::is_heap_until(i87, i87+6) == i87+1);
+ assert(std::is_heap_until(i88, i88+6) == i88+1);
+ assert(std::is_heap_until(i89, i89+6) == i89+6);
+ assert(std::is_heap_until(i90, i90+6) == i90+5);
+ assert(std::is_heap_until(i91, i91+6) == i91+4);
+ assert(std::is_heap_until(i92, i92+6) == i92+4);
+ assert(std::is_heap_until(i93, i93+6) == i93+3);
+ assert(std::is_heap_until(i94, i94+6) == i94+3);
+ assert(std::is_heap_until(i95, i95+6) == i95+3);
+ assert(std::is_heap_until(i96, i96+6) == i96+3);
+ assert(std::is_heap_until(i97, i97+6) == i97+6);
+ assert(std::is_heap_until(i98, i98+6) == i98+6);
+ assert(std::is_heap_until(i99, i99+6) == i99+4);
+ assert(std::is_heap_until(i100, i100+6) == i100+4);
+ assert(std::is_heap_until(i101, i101+6) == i101+3);
+ assert(std::is_heap_until(i102, i102+6) == i102+3);
+ assert(std::is_heap_until(i103, i103+6) == i103+3);
+ assert(std::is_heap_until(i104, i104+6) == i104+3);
+ assert(std::is_heap_until(i105, i105+6) == i105+6);
+ assert(std::is_heap_until(i106, i106+6) == i106+5);
+ assert(std::is_heap_until(i107, i107+6) == i107+6);
+ assert(std::is_heap_until(i108, i108+6) == i108+5);
+ assert(std::is_heap_until(i109, i109+6) == i109+6);
+ assert(std::is_heap_until(i110, i110+6) == i110+5);
+ assert(std::is_heap_until(i111, i111+6) == i111+6);
+ assert(std::is_heap_until(i112, i112+6) == i112+5);
+ assert(std::is_heap_until(i113, i113+6) == i113+6);
+ assert(std::is_heap_until(i114, i114+6) == i114+6);
+ assert(std::is_heap_until(i115, i115+6) == i115+6);
+ assert(std::is_heap_until(i116, i116+6) == i116+6);
+ assert(std::is_heap_until(i117, i117+6) == i117+6);
+ assert(std::is_heap_until(i118, i118+6) == i118+6);
+ assert(std::is_heap_until(i119, i119+6) == i119+6);
+ int i120[] = {0, 0, 0, 0, 0, 0, 0};
+ int i121[] = {0, 0, 0, 0, 0, 0, 1};
+ int i122[] = {0, 0, 0, 0, 0, 1, 0};
+ int i123[] = {0, 0, 0, 0, 0, 1, 1};
+ int i124[] = {0, 0, 0, 0, 1, 0, 0};
+ int i125[] = {0, 0, 0, 0, 1, 0, 1};
+ int i126[] = {0, 0, 0, 0, 1, 1, 0};
+ int i127[] = {0, 0, 0, 0, 1, 1, 1};
+ int i128[] = {0, 0, 0, 1, 0, 0, 0};
+ int i129[] = {0, 0, 0, 1, 0, 0, 1};
+ int i130[] = {0, 0, 0, 1, 0, 1, 0};
+ int i131[] = {0, 0, 0, 1, 0, 1, 1};
+ int i132[] = {0, 0, 0, 1, 1, 0, 0};
+ int i133[] = {0, 0, 0, 1, 1, 0, 1};
+ int i134[] = {0, 0, 0, 1, 1, 1, 0};
+ int i135[] = {0, 0, 0, 1, 1, 1, 1};
+ int i136[] = {0, 0, 1, 0, 0, 0, 0};
+ int i137[] = {0, 0, 1, 0, 0, 0, 1};
+ int i138[] = {0, 0, 1, 0, 0, 1, 0};
+ int i139[] = {0, 0, 1, 0, 0, 1, 1};
+ int i140[] = {0, 0, 1, 0, 1, 0, 0};
+ int i141[] = {0, 0, 1, 0, 1, 0, 1};
+ int i142[] = {0, 0, 1, 0, 1, 1, 0};
+ int i143[] = {0, 0, 1, 0, 1, 1, 1};
+ int i144[] = {0, 0, 1, 1, 0, 0, 0};
+ int i145[] = {0, 0, 1, 1, 0, 0, 1};
+ int i146[] = {0, 0, 1, 1, 0, 1, 0};
+ int i147[] = {0, 0, 1, 1, 0, 1, 1};
+ int i148[] = {0, 0, 1, 1, 1, 0, 0};
+ int i149[] = {0, 0, 1, 1, 1, 0, 1};
+ int i150[] = {0, 0, 1, 1, 1, 1, 0};
+ int i151[] = {0, 0, 1, 1, 1, 1, 1};
+ int i152[] = {0, 1, 0, 0, 0, 0, 0};
+ int i153[] = {0, 1, 0, 0, 0, 0, 1};
+ int i154[] = {0, 1, 0, 0, 0, 1, 0};
+ int i155[] = {0, 1, 0, 0, 0, 1, 1};
+ int i156[] = {0, 1, 0, 0, 1, 0, 0};
+ int i157[] = {0, 1, 0, 0, 1, 0, 1};
+ int i158[] = {0, 1, 0, 0, 1, 1, 0};
+ int i159[] = {0, 1, 0, 0, 1, 1, 1};
+ int i160[] = {0, 1, 0, 1, 0, 0, 0};
+ int i161[] = {0, 1, 0, 1, 0, 0, 1};
+ int i162[] = {0, 1, 0, 1, 0, 1, 0};
+ int i163[] = {0, 1, 0, 1, 0, 1, 1};
+ int i164[] = {0, 1, 0, 1, 1, 0, 0};
+ int i165[] = {0, 1, 0, 1, 1, 0, 1};
+ int i166[] = {0, 1, 0, 1, 1, 1, 0};
+ int i167[] = {0, 1, 0, 1, 1, 1, 1};
+ int i168[] = {0, 1, 1, 0, 0, 0, 0};
+ int i169[] = {0, 1, 1, 0, 0, 0, 1};
+ int i170[] = {0, 1, 1, 0, 0, 1, 0};
+ int i171[] = {0, 1, 1, 0, 0, 1, 1};
+ int i172[] = {0, 1, 1, 0, 1, 0, 0};
+ int i173[] = {0, 1, 1, 0, 1, 0, 1};
+ int i174[] = {0, 1, 1, 0, 1, 1, 0};
+ int i175[] = {0, 1, 1, 0, 1, 1, 1};
+ int i176[] = {0, 1, 1, 1, 0, 0, 0};
+ int i177[] = {0, 1, 1, 1, 0, 0, 1};
+ int i178[] = {0, 1, 1, 1, 0, 1, 0};
+ int i179[] = {0, 1, 1, 1, 0, 1, 1};
+ int i180[] = {0, 1, 1, 1, 1, 0, 0};
+ int i181[] = {0, 1, 1, 1, 1, 0, 1};
+ int i182[] = {0, 1, 1, 1, 1, 1, 0};
+ int i183[] = {0, 1, 1, 1, 1, 1, 1};
+ int i184[] = {1, 0, 0, 0, 0, 0, 0};
+ int i185[] = {1, 0, 0, 0, 0, 0, 1};
+ int i186[] = {1, 0, 0, 0, 0, 1, 0};
+ int i187[] = {1, 0, 0, 0, 0, 1, 1};
+ int i188[] = {1, 0, 0, 0, 1, 0, 0};
+ int i189[] = {1, 0, 0, 0, 1, 0, 1};
+ int i190[] = {1, 0, 0, 0, 1, 1, 0};
+ int i191[] = {1, 0, 0, 0, 1, 1, 1};
+ int i192[] = {1, 0, 0, 1, 0, 0, 0};
+ int i193[] = {1, 0, 0, 1, 0, 0, 1};
+ int i194[] = {1, 0, 0, 1, 0, 1, 0};
+ int i195[] = {1, 0, 0, 1, 0, 1, 1};
+ int i196[] = {1, 0, 0, 1, 1, 0, 0};
+ int i197[] = {1, 0, 0, 1, 1, 0, 1};
+ int i198[] = {1, 0, 0, 1, 1, 1, 0};
+ int i199[] = {1, 0, 0, 1, 1, 1, 1};
+ int i200[] = {1, 0, 1, 0, 0, 0, 0};
+ int i201[] = {1, 0, 1, 0, 0, 0, 1};
+ int i202[] = {1, 0, 1, 0, 0, 1, 0};
+ int i203[] = {1, 0, 1, 0, 0, 1, 1};
+ int i204[] = {1, 0, 1, 0, 1, 0, 0};
+ int i205[] = {1, 0, 1, 0, 1, 0, 1};
+ int i206[] = {1, 0, 1, 0, 1, 1, 0};
+ int i207[] = {1, 0, 1, 0, 1, 1, 1};
+ int i208[] = {1, 0, 1, 1, 0, 0, 0};
+ int i209[] = {1, 0, 1, 1, 0, 0, 1};
+ int i210[] = {1, 0, 1, 1, 0, 1, 0};
+ int i211[] = {1, 0, 1, 1, 0, 1, 1};
+ int i212[] = {1, 0, 1, 1, 1, 0, 0};
+ int i213[] = {1, 0, 1, 1, 1, 0, 1};
+ int i214[] = {1, 0, 1, 1, 1, 1, 0};
+ int i215[] = {1, 0, 1, 1, 1, 1, 1};
+ int i216[] = {1, 1, 0, 0, 0, 0, 0};
+ int i217[] = {1, 1, 0, 0, 0, 0, 1};
+ int i218[] = {1, 1, 0, 0, 0, 1, 0};
+ int i219[] = {1, 1, 0, 0, 0, 1, 1};
+ int i220[] = {1, 1, 0, 0, 1, 0, 0};
+ int i221[] = {1, 1, 0, 0, 1, 0, 1};
+ int i222[] = {1, 1, 0, 0, 1, 1, 0};
+ int i223[] = {1, 1, 0, 0, 1, 1, 1};
+ int i224[] = {1, 1, 0, 1, 0, 0, 0};
+ int i225[] = {1, 1, 0, 1, 0, 0, 1};
+ int i226[] = {1, 1, 0, 1, 0, 1, 0};
+ int i227[] = {1, 1, 0, 1, 0, 1, 1};
+ int i228[] = {1, 1, 0, 1, 1, 0, 0};
+ int i229[] = {1, 1, 0, 1, 1, 0, 1};
+ int i230[] = {1, 1, 0, 1, 1, 1, 0};
+ int i231[] = {1, 1, 0, 1, 1, 1, 1};
+ int i232[] = {1, 1, 1, 0, 0, 0, 0};
+ int i233[] = {1, 1, 1, 0, 0, 0, 1};
+ int i234[] = {1, 1, 1, 0, 0, 1, 0};
+ int i235[] = {1, 1, 1, 0, 0, 1, 1};
+ int i236[] = {1, 1, 1, 0, 1, 0, 0};
+ int i237[] = {1, 1, 1, 0, 1, 0, 1};
+ int i238[] = {1, 1, 1, 0, 1, 1, 0};
+ int i239[] = {1, 1, 1, 0, 1, 1, 1};
+ int i240[] = {1, 1, 1, 1, 0, 0, 0};
+ int i241[] = {1, 1, 1, 1, 0, 0, 1};
+ int i242[] = {1, 1, 1, 1, 0, 1, 0};
+ int i243[] = {1, 1, 1, 1, 0, 1, 1};
+ int i244[] = {1, 1, 1, 1, 1, 0, 0};
+ int i245[] = {1, 1, 1, 1, 1, 0, 1};
+ int i246[] = {1, 1, 1, 1, 1, 1, 0};
+ assert(std::is_heap_until(i120, i120+7) == i120+7);
+ assert(std::is_heap_until(i121, i121+7) == i121+6);
+ assert(std::is_heap_until(i122, i122+7) == i122+5);
+ assert(std::is_heap_until(i123, i123+7) == i123+5);
+ assert(std::is_heap_until(i124, i124+7) == i124+4);
+ assert(std::is_heap_until(i125, i125+7) == i125+4);
+ assert(std::is_heap_until(i126, i126+7) == i126+4);
+ assert(std::is_heap_until(i127, i127+7) == i127+4);
+ assert(std::is_heap_until(i128, i128+7) == i128+3);
+ assert(std::is_heap_until(i129, i129+7) == i129+3);
+ assert(std::is_heap_until(i130, i130+7) == i130+3);
+ assert(std::is_heap_until(i131, i131+7) == i131+3);
+ assert(std::is_heap_until(i132, i132+7) == i132+3);
+ assert(std::is_heap_until(i133, i133+7) == i133+3);
+ assert(std::is_heap_until(i134, i134+7) == i134+3);
+ assert(std::is_heap_until(i135, i135+7) == i135+3);
+ assert(std::is_heap_until(i136, i136+7) == i136+2);
+ assert(std::is_heap_until(i137, i137+7) == i137+2);
+ assert(std::is_heap_until(i138, i138+7) == i138+2);
+ assert(std::is_heap_until(i139, i139+7) == i139+2);
+ assert(std::is_heap_until(i140, i140+7) == i140+2);
+ assert(std::is_heap_until(i141, i141+7) == i141+2);
+ assert(std::is_heap_until(i142, i142+7) == i142+2);
+ assert(std::is_heap_until(i143, i143+7) == i143+2);
+ assert(std::is_heap_until(i144, i144+7) == i144+2);
+ assert(std::is_heap_until(i145, i145+7) == i145+2);
+ assert(std::is_heap_until(i146, i146+7) == i146+2);
+ assert(std::is_heap_until(i147, i147+7) == i147+2);
+ assert(std::is_heap_until(i148, i148+7) == i148+2);
+ assert(std::is_heap_until(i149, i149+7) == i149+2);
+ assert(std::is_heap_until(i150, i150+7) == i150+2);
+ assert(std::is_heap_until(i151, i151+7) == i151+2);
+ assert(std::is_heap_until(i152, i152+7) == i152+1);
+ assert(std::is_heap_until(i153, i153+7) == i153+1);
+ assert(std::is_heap_until(i154, i154+7) == i154+1);
+ assert(std::is_heap_until(i155, i155+7) == i155+1);
+ assert(std::is_heap_until(i156, i156+7) == i156+1);
+ assert(std::is_heap_until(i157, i157+7) == i157+1);
+ assert(std::is_heap_until(i158, i158+7) == i158+1);
+ assert(std::is_heap_until(i159, i159+7) == i159+1);
+ assert(std::is_heap_until(i160, i160+7) == i160+1);
+ assert(std::is_heap_until(i161, i161+7) == i161+1);
+ assert(std::is_heap_until(i162, i162+7) == i162+1);
+ assert(std::is_heap_until(i163, i163+7) == i163+1);
+ assert(std::is_heap_until(i164, i164+7) == i164+1);
+ assert(std::is_heap_until(i165, i165+7) == i165+1);
+ assert(std::is_heap_until(i166, i166+7) == i166+1);
+ assert(std::is_heap_until(i167, i167+7) == i167+1);
+ assert(std::is_heap_until(i168, i168+7) == i168+1);
+ assert(std::is_heap_until(i169, i169+7) == i169+1);
+ assert(std::is_heap_until(i170, i170+7) == i170+1);
+ assert(std::is_heap_until(i171, i171+7) == i171+1);
+ assert(std::is_heap_until(i172, i172+7) == i172+1);
+ assert(std::is_heap_until(i173, i173+7) == i173+1);
+ assert(std::is_heap_until(i174, i174+7) == i174+1);
+ assert(std::is_heap_until(i175, i175+7) == i175+1);
+ assert(std::is_heap_until(i176, i176+7) == i176+1);
+ assert(std::is_heap_until(i177, i177+7) == i177+1);
+ assert(std::is_heap_until(i178, i178+7) == i178+1);
+ assert(std::is_heap_until(i179, i179+7) == i179+1);
+ assert(std::is_heap_until(i180, i180+7) == i180+1);
+ assert(std::is_heap_until(i181, i181+7) == i181+1);
+ assert(std::is_heap_until(i182, i182+7) == i182+1);
+ assert(std::is_heap_until(i183, i183+7) == i183+1);
+ assert(std::is_heap_until(i184, i184+7) == i184+7);
+ assert(std::is_heap_until(i185, i185+7) == i185+6);
+ assert(std::is_heap_until(i186, i186+7) == i186+5);
+ assert(std::is_heap_until(i187, i187+7) == i187+5);
+ assert(std::is_heap_until(i188, i188+7) == i188+4);
+ assert(std::is_heap_until(i189, i189+7) == i189+4);
+ assert(std::is_heap_until(i190, i190+7) == i190+4);
+ assert(std::is_heap_until(i191, i191+7) == i191+4);
+ assert(std::is_heap_until(i192, i192+7) == i192+3);
+ assert(std::is_heap_until(i193, i193+7) == i193+3);
+ assert(std::is_heap_until(i194, i194+7) == i194+3);
+ assert(std::is_heap_until(i195, i195+7) == i195+3);
+ assert(std::is_heap_until(i196, i196+7) == i196+3);
+ assert(std::is_heap_until(i197, i197+7) == i197+3);
+ assert(std::is_heap_until(i198, i198+7) == i198+3);
+ assert(std::is_heap_until(i199, i199+7) == i199+3);
+ assert(std::is_heap_until(i200, i200+7) == i200+7);
+ assert(std::is_heap_until(i201, i201+7) == i201+7);
+ assert(std::is_heap_until(i202, i202+7) == i202+7);
+ assert(std::is_heap_until(i203, i203+7) == i203+7);
+ assert(std::is_heap_until(i204, i204+7) == i204+4);
+ assert(std::is_heap_until(i205, i205+7) == i205+4);
+ assert(std::is_heap_until(i206, i206+7) == i206+4);
+ assert(std::is_heap_until(i207, i207+7) == i207+4);
+ assert(std::is_heap_until(i208, i208+7) == i208+3);
+ assert(std::is_heap_until(i209, i209+7) == i209+3);
+ assert(std::is_heap_until(i210, i210+7) == i210+3);
+ assert(std::is_heap_until(i211, i211+7) == i211+3);
+ assert(std::is_heap_until(i212, i212+7) == i212+3);
+ assert(std::is_heap_until(i213, i213+7) == i213+3);
+ assert(std::is_heap_until(i214, i214+7) == i214+3);
+ assert(std::is_heap_until(i215, i215+7) == i215+3);
+ assert(std::is_heap_until(i216, i216+7) == i216+7);
+ assert(std::is_heap_until(i217, i217+7) == i217+6);
+ assert(std::is_heap_until(i218, i218+7) == i218+5);
+ assert(std::is_heap_until(i219, i219+7) == i219+5);
+ assert(std::is_heap_until(i220, i220+7) == i220+7);
+ assert(std::is_heap_until(i221, i221+7) == i221+6);
+ assert(std::is_heap_until(i222, i222+7) == i222+5);
+ assert(std::is_heap_until(i223, i223+7) == i223+5);
+ assert(std::is_heap_until(i224, i224+7) == i224+7);
+ assert(std::is_heap_until(i225, i225+7) == i225+6);
+ assert(std::is_heap_until(i226, i226+7) == i226+5);
+ assert(std::is_heap_until(i227, i227+7) == i227+5);
+ assert(std::is_heap_until(i228, i228+7) == i228+7);
+ assert(std::is_heap_until(i229, i229+7) == i229+6);
+ assert(std::is_heap_until(i230, i230+7) == i230+5);
+ assert(std::is_heap_until(i231, i231+7) == i231+5);
+ assert(std::is_heap_until(i232, i232+7) == i232+7);
+ assert(std::is_heap_until(i233, i233+7) == i233+7);
+ assert(std::is_heap_until(i234, i234+7) == i234+7);
+ assert(std::is_heap_until(i235, i235+7) == i235+7);
+ assert(std::is_heap_until(i236, i236+7) == i236+7);
+ assert(std::is_heap_until(i237, i237+7) == i237+7);
+ assert(std::is_heap_until(i238, i238+7) == i238+7);
+ assert(std::is_heap_until(i239, i239+7) == i239+7);
+ assert(std::is_heap_until(i240, i240+7) == i240+7);
+ assert(std::is_heap_until(i241, i241+7) == i241+7);
+ assert(std::is_heap_until(i242, i242+7) == i242+7);
+ assert(std::is_heap_until(i243, i243+7) == i243+7);
+ assert(std::is_heap_until(i244, i244+7) == i244+7);
+ assert(std::is_heap_until(i245, i245+7) == i245+7);
+ assert(std::is_heap_until(i246, i246+7) == i246+7);
+}
+
+int main()
+{
+ test();
+}
diff --git a/test/std/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap_until_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap_until_comp.pass.cpp
new file mode 100644
index 000000000000..657c177fee56
--- /dev/null
+++ b/test/std/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap_until_comp.pass.cpp
@@ -0,0 +1,522 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<RandomAccessIterator Iter, StrictWeakOrder<auto, Iter::value_type> Compare>
+// requires CopyConstructible<Compare>
+// Iter
+// is_heap_until(Iter first, Iter last, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+void test()
+{
+ int i1[] = {0, 0};
+ assert(std::is_heap_until(i1, i1, std::greater<int>()) == i1);
+ assert(std::is_heap_until(i1, i1+1, std::greater<int>()) == i1+1);
+ int i2[] = {0, 1};
+ int i3[] = {1, 0};
+ assert(std::is_heap_until(i1, i1+2, std::greater<int>()) == i1+2);
+ assert(std::is_heap_until(i2, i2+2, std::greater<int>()) == i2+2);
+ assert(std::is_heap_until(i3, i3+2, std::greater<int>()) == i3+1);
+ int i4[] = {0, 0, 0};
+ int i5[] = {0, 0, 1};
+ int i6[] = {0, 1, 0};
+ int i7[] = {0, 1, 1};
+ int i8[] = {1, 0, 0};
+ int i9[] = {1, 0, 1};
+ int i10[] = {1, 1, 0};
+ assert(std::is_heap_until(i4, i4+3, std::greater<int>()) == i4+3);
+ assert(std::is_heap_until(i5, i5+3, std::greater<int>()) == i5+3);
+ assert(std::is_heap_until(i6, i6+3, std::greater<int>()) == i6+3);
+ assert(std::is_heap_until(i7, i7+3, std::greater<int>()) == i7+3);
+ assert(std::is_heap_until(i8, i8+3, std::greater<int>()) == i8+1);
+ assert(std::is_heap_until(i9, i9+3, std::greater<int>()) == i9+1);
+ assert(std::is_heap_until(i10, i10+3, std::greater<int>()) == i10+2);
+ int i11[] = {0, 0, 0, 0};
+ int i12[] = {0, 0, 0, 1};
+ int i13[] = {0, 0, 1, 0};
+ int i14[] = {0, 0, 1, 1};
+ int i15[] = {0, 1, 0, 0};
+ int i16[] = {0, 1, 0, 1};
+ int i17[] = {0, 1, 1, 0};
+ int i18[] = {0, 1, 1, 1};
+ int i19[] = {1, 0, 0, 0};
+ int i20[] = {1, 0, 0, 1};
+ int i21[] = {1, 0, 1, 0};
+ int i22[] = {1, 0, 1, 1};
+ int i23[] = {1, 1, 0, 0};
+ int i24[] = {1, 1, 0, 1};
+ int i25[] = {1, 1, 1, 0};
+ assert(std::is_heap_until(i11, i11+4, std::greater<int>()) == i11+4);
+ assert(std::is_heap_until(i12, i12+4, std::greater<int>()) == i12+4);
+ assert(std::is_heap_until(i13, i13+4, std::greater<int>()) == i13+4);
+ assert(std::is_heap_until(i14, i14+4, std::greater<int>()) == i14+4);
+ assert(std::is_heap_until(i15, i15+4, std::greater<int>()) == i15+3);
+ assert(std::is_heap_until(i16, i16+4, std::greater<int>()) == i16+4);
+ assert(std::is_heap_until(i17, i17+4, std::greater<int>()) == i17+3);
+ assert(std::is_heap_until(i18, i18+4, std::greater<int>()) == i18+4);
+ assert(std::is_heap_until(i19, i19+4, std::greater<int>()) == i19+1);
+ assert(std::is_heap_until(i20, i20+4, std::greater<int>()) == i20+1);
+ assert(std::is_heap_until(i21, i21+4, std::greater<int>()) == i21+1);
+ assert(std::is_heap_until(i22, i22+4, std::greater<int>()) == i22+1);
+ assert(std::is_heap_until(i23, i23+4, std::greater<int>()) == i23+2);
+ assert(std::is_heap_until(i24, i24+4, std::greater<int>()) == i24+2);
+ assert(std::is_heap_until(i25, i25+4, std::greater<int>()) == i25+3);
+ int i26[] = {0, 0, 0, 0, 0};
+ int i27[] = {0, 0, 0, 0, 1};
+ int i28[] = {0, 0, 0, 1, 0};
+ int i29[] = {0, 0, 0, 1, 1};
+ int i30[] = {0, 0, 1, 0, 0};
+ int i31[] = {0, 0, 1, 0, 1};
+ int i32[] = {0, 0, 1, 1, 0};
+ int i33[] = {0, 0, 1, 1, 1};
+ int i34[] = {0, 1, 0, 0, 0};
+ int i35[] = {0, 1, 0, 0, 1};
+ int i36[] = {0, 1, 0, 1, 0};
+ int i37[] = {0, 1, 0, 1, 1};
+ int i38[] = {0, 1, 1, 0, 0};
+ int i39[] = {0, 1, 1, 0, 1};
+ int i40[] = {0, 1, 1, 1, 0};
+ int i41[] = {0, 1, 1, 1, 1};
+ int i42[] = {1, 0, 0, 0, 0};
+ int i43[] = {1, 0, 0, 0, 1};
+ int i44[] = {1, 0, 0, 1, 0};
+ int i45[] = {1, 0, 0, 1, 1};
+ int i46[] = {1, 0, 1, 0, 0};
+ int i47[] = {1, 0, 1, 0, 1};
+ int i48[] = {1, 0, 1, 1, 0};
+ int i49[] = {1, 0, 1, 1, 1};
+ int i50[] = {1, 1, 0, 0, 0};
+ int i51[] = {1, 1, 0, 0, 1};
+ int i52[] = {1, 1, 0, 1, 0};
+ int i53[] = {1, 1, 0, 1, 1};
+ int i54[] = {1, 1, 1, 0, 0};
+ int i55[] = {1, 1, 1, 0, 1};
+ int i56[] = {1, 1, 1, 1, 0};
+ assert(std::is_heap_until(i26, i26+5, std::greater<int>()) == i26+5);
+ assert(std::is_heap_until(i27, i27+5, std::greater<int>()) == i27+5);
+ assert(std::is_heap_until(i28, i28+5, std::greater<int>()) == i28+5);
+ assert(std::is_heap_until(i29, i29+5, std::greater<int>()) == i29+5);
+ assert(std::is_heap_until(i30, i30+5, std::greater<int>()) == i30+5);
+ assert(std::is_heap_until(i31, i31+5, std::greater<int>()) == i31+5);
+ assert(std::is_heap_until(i32, i32+5, std::greater<int>()) == i32+5);
+ assert(std::is_heap_until(i33, i33+5, std::greater<int>()) == i33+5);
+ assert(std::is_heap_until(i34, i34+5, std::greater<int>()) == i34+3);
+ assert(std::is_heap_until(i35, i35+5, std::greater<int>()) == i35+3);
+ assert(std::is_heap_until(i36, i36+5, std::greater<int>()) == i36+4);
+ assert(std::is_heap_until(i37, i37+5, std::greater<int>()) == i37+5);
+ assert(std::is_heap_until(i38, i38+5, std::greater<int>()) == i38+3);
+ assert(std::is_heap_until(i39, i39+5, std::greater<int>()) == i39+3);
+ assert(std::is_heap_until(i40, i40+5, std::greater<int>()) == i40+4);
+ assert(std::is_heap_until(i41, i41+5, std::greater<int>()) == i41+5);
+ assert(std::is_heap_until(i42, i42+5, std::greater<int>()) == i42+1);
+ assert(std::is_heap_until(i43, i43+5, std::greater<int>()) == i43+1);
+ assert(std::is_heap_until(i44, i44+5, std::greater<int>()) == i44+1);
+ assert(std::is_heap_until(i45, i45+5, std::greater<int>()) == i45+1);
+ assert(std::is_heap_until(i46, i46+5, std::greater<int>()) == i46+1);
+ assert(std::is_heap_until(i47, i47+5, std::greater<int>()) == i47+1);
+ assert(std::is_heap_until(i48, i48+5, std::greater<int>()) == i48+1);
+ assert(std::is_heap_until(i49, i49+5, std::greater<int>()) == i49+1);
+ assert(std::is_heap_until(i50, i50+5, std::greater<int>()) == i50+2);
+ assert(std::is_heap_until(i51, i51+5, std::greater<int>()) == i51+2);
+ assert(std::is_heap_until(i52, i52+5, std::greater<int>()) == i52+2);
+ assert(std::is_heap_until(i53, i53+5, std::greater<int>()) == i53+2);
+ assert(std::is_heap_until(i54, i54+5, std::greater<int>()) == i54+3);
+ assert(std::is_heap_until(i55, i55+5, std::greater<int>()) == i55+3);
+ assert(std::is_heap_until(i56, i56+5, std::greater<int>()) == i56+4);
+ int i57[] = {0, 0, 0, 0, 0, 0};
+ int i58[] = {0, 0, 0, 0, 0, 1};
+ int i59[] = {0, 0, 0, 0, 1, 0};
+ int i60[] = {0, 0, 0, 0, 1, 1};
+ int i61[] = {0, 0, 0, 1, 0, 0};
+ int i62[] = {0, 0, 0, 1, 0, 1};
+ int i63[] = {0, 0, 0, 1, 1, 0};
+ int i64[] = {0, 0, 0, 1, 1, 1};
+ int i65[] = {0, 0, 1, 0, 0, 0};
+ int i66[] = {0, 0, 1, 0, 0, 1};
+ int i67[] = {0, 0, 1, 0, 1, 0};
+ int i68[] = {0, 0, 1, 0, 1, 1};
+ int i69[] = {0, 0, 1, 1, 0, 0};
+ int i70[] = {0, 0, 1, 1, 0, 1};
+ int i71[] = {0, 0, 1, 1, 1, 0};
+ int i72[] = {0, 0, 1, 1, 1, 1};
+ int i73[] = {0, 1, 0, 0, 0, 0};
+ int i74[] = {0, 1, 0, 0, 0, 1};
+ int i75[] = {0, 1, 0, 0, 1, 0};
+ int i76[] = {0, 1, 0, 0, 1, 1};
+ int i77[] = {0, 1, 0, 1, 0, 0};
+ int i78[] = {0, 1, 0, 1, 0, 1};
+ int i79[] = {0, 1, 0, 1, 1, 0};
+ int i80[] = {0, 1, 0, 1, 1, 1};
+ int i81[] = {0, 1, 1, 0, 0, 0};
+ int i82[] = {0, 1, 1, 0, 0, 1};
+ int i83[] = {0, 1, 1, 0, 1, 0};
+ int i84[] = {0, 1, 1, 0, 1, 1};
+ int i85[] = {0, 1, 1, 1, 0, 0};
+ int i86[] = {0, 1, 1, 1, 0, 1};
+ int i87[] = {0, 1, 1, 1, 1, 0};
+ int i88[] = {0, 1, 1, 1, 1, 1};
+ int i89[] = {1, 0, 0, 0, 0, 0};
+ int i90[] = {1, 0, 0, 0, 0, 1};
+ int i91[] = {1, 0, 0, 0, 1, 0};
+ int i92[] = {1, 0, 0, 0, 1, 1};
+ int i93[] = {1, 0, 0, 1, 0, 0};
+ int i94[] = {1, 0, 0, 1, 0, 1};
+ int i95[] = {1, 0, 0, 1, 1, 0};
+ int i96[] = {1, 0, 0, 1, 1, 1};
+ int i97[] = {1, 0, 1, 0, 0, 0};
+ int i98[] = {1, 0, 1, 0, 0, 1};
+ int i99[] = {1, 0, 1, 0, 1, 0};
+ int i100[] = {1, 0, 1, 0, 1, 1};
+ int i101[] = {1, 0, 1, 1, 0, 0};
+ int i102[] = {1, 0, 1, 1, 0, 1};
+ int i103[] = {1, 0, 1, 1, 1, 0};
+ int i104[] = {1, 0, 1, 1, 1, 1};
+ int i105[] = {1, 1, 0, 0, 0, 0};
+ int i106[] = {1, 1, 0, 0, 0, 1};
+ int i107[] = {1, 1, 0, 0, 1, 0};
+ int i108[] = {1, 1, 0, 0, 1, 1};
+ int i109[] = {1, 1, 0, 1, 0, 0};
+ int i110[] = {1, 1, 0, 1, 0, 1};
+ int i111[] = {1, 1, 0, 1, 1, 0};
+ int i112[] = {1, 1, 0, 1, 1, 1};
+ int i113[] = {1, 1, 1, 0, 0, 0};
+ int i114[] = {1, 1, 1, 0, 0, 1};
+ int i115[] = {1, 1, 1, 0, 1, 0};
+ int i116[] = {1, 1, 1, 0, 1, 1};
+ int i117[] = {1, 1, 1, 1, 0, 0};
+ int i118[] = {1, 1, 1, 1, 0, 1};
+ int i119[] = {1, 1, 1, 1, 1, 0};
+ assert(std::is_heap_until(i57, i57+6, std::greater<int>()) == i57+6);
+ assert(std::is_heap_until(i58, i58+6, std::greater<int>()) == i58+6);
+ assert(std::is_heap_until(i59, i59+6, std::greater<int>()) == i59+6);
+ assert(std::is_heap_until(i60, i60+6, std::greater<int>()) == i60+6);
+ assert(std::is_heap_until(i61, i61+6, std::greater<int>()) == i61+6);
+ assert(std::is_heap_until(i62, i62+6, std::greater<int>()) == i62+6);
+ assert(std::is_heap_until(i63, i63+6, std::greater<int>()) == i63+6);
+ assert(std::is_heap_until(i64, i64+6, std::greater<int>()) == i64+6);
+ assert(std::is_heap_until(i65, i65+6, std::greater<int>()) == i65+5);
+ assert(std::is_heap_until(i66, i66+6, std::greater<int>()) == i66+6);
+ assert(std::is_heap_until(i67, i67+6, std::greater<int>()) == i67+5);
+ assert(std::is_heap_until(i68, i68+6, std::greater<int>()) == i68+6);
+ assert(std::is_heap_until(i69, i69+6, std::greater<int>()) == i69+5);
+ assert(std::is_heap_until(i70, i70+6, std::greater<int>()) == i70+6);
+ assert(std::is_heap_until(i71, i71+6, std::greater<int>()) == i71+5);
+ assert(std::is_heap_until(i72, i72+6, std::greater<int>()) == i72+6);
+ assert(std::is_heap_until(i73, i73+6, std::greater<int>()) == i73+3);
+ assert(std::is_heap_until(i74, i74+6, std::greater<int>()) == i74+3);
+ assert(std::is_heap_until(i75, i75+6, std::greater<int>()) == i75+3);
+ assert(std::is_heap_until(i76, i76+6, std::greater<int>()) == i76+3);
+ assert(std::is_heap_until(i77, i77+6, std::greater<int>()) == i77+4);
+ assert(std::is_heap_until(i78, i78+6, std::greater<int>()) == i78+4);
+ assert(std::is_heap_until(i79, i79+6, std::greater<int>()) == i79+6);
+ assert(std::is_heap_until(i80, i80+6, std::greater<int>()) == i80+6);
+ assert(std::is_heap_until(i81, i81+6, std::greater<int>()) == i81+3);
+ assert(std::is_heap_until(i82, i82+6, std::greater<int>()) == i82+3);
+ assert(std::is_heap_until(i83, i83+6, std::greater<int>()) == i83+3);
+ assert(std::is_heap_until(i84, i84+6, std::greater<int>()) == i84+3);
+ assert(std::is_heap_until(i85, i85+6, std::greater<int>()) == i85+4);
+ assert(std::is_heap_until(i86, i86+6, std::greater<int>()) == i86+4);
+ assert(std::is_heap_until(i87, i87+6, std::greater<int>()) == i87+5);
+ assert(std::is_heap_until(i88, i88+6, std::greater<int>()) == i88+6);
+ assert(std::is_heap_until(i89, i89+6, std::greater<int>()) == i89+1);
+ assert(std::is_heap_until(i90, i90+6, std::greater<int>()) == i90+1);
+ assert(std::is_heap_until(i91, i91+6, std::greater<int>()) == i91+1);
+ assert(std::is_heap_until(i92, i92+6, std::greater<int>()) == i92+1);
+ assert(std::is_heap_until(i93, i93+6, std::greater<int>()) == i93+1);
+ assert(std::is_heap_until(i94, i94+6, std::greater<int>()) == i94+1);
+ assert(std::is_heap_until(i95, i95+6, std::greater<int>()) == i95+1);
+ assert(std::is_heap_until(i96, i96+6, std::greater<int>()) == i96+1);
+ assert(std::is_heap_until(i97, i97+6, std::greater<int>()) == i97+1);
+ assert(std::is_heap_until(i98, i98+6, std::greater<int>()) == i98+1);
+ assert(std::is_heap_until(i99, i99+6, std::greater<int>()) == i99+1);
+ assert(std::is_heap_until(i100, i100+6, std::greater<int>()) == i100+1);
+ assert(std::is_heap_until(i101, i101+6, std::greater<int>()) == i101+1);
+ assert(std::is_heap_until(i102, i102+6, std::greater<int>()) == i102+1);
+ assert(std::is_heap_until(i103, i103+6, std::greater<int>()) == i103+1);
+ assert(std::is_heap_until(i104, i104+6, std::greater<int>()) == i104+1);
+ assert(std::is_heap_until(i105, i105+6, std::greater<int>()) == i105+2);
+ assert(std::is_heap_until(i106, i106+6, std::greater<int>()) == i106+2);
+ assert(std::is_heap_until(i107, i107+6, std::greater<int>()) == i107+2);
+ assert(std::is_heap_until(i108, i108+6, std::greater<int>()) == i108+2);
+ assert(std::is_heap_until(i109, i109+6, std::greater<int>()) == i109+2);
+ assert(std::is_heap_until(i110, i110+6, std::greater<int>()) == i110+2);
+ assert(std::is_heap_until(i111, i111+6, std::greater<int>()) == i111+2);
+ assert(std::is_heap_until(i112, i112+6, std::greater<int>()) == i112+2);
+ assert(std::is_heap_until(i113, i113+6, std::greater<int>()) == i113+3);
+ assert(std::is_heap_until(i114, i114+6, std::greater<int>()) == i114+3);
+ assert(std::is_heap_until(i115, i115+6, std::greater<int>()) == i115+3);
+ assert(std::is_heap_until(i116, i116+6, std::greater<int>()) == i116+3);
+ assert(std::is_heap_until(i117, i117+6, std::greater<int>()) == i117+4);
+ assert(std::is_heap_until(i118, i118+6, std::greater<int>()) == i118+4);
+ assert(std::is_heap_until(i119, i119+6, std::greater<int>()) == i119+5);
+ int i120[] = {0, 0, 0, 0, 0, 0, 0};
+ int i121[] = {0, 0, 0, 0, 0, 0, 1};
+ int i122[] = {0, 0, 0, 0, 0, 1, 0};
+ int i123[] = {0, 0, 0, 0, 0, 1, 1};
+ int i124[] = {0, 0, 0, 0, 1, 0, 0};
+ int i125[] = {0, 0, 0, 0, 1, 0, 1};
+ int i126[] = {0, 0, 0, 0, 1, 1, 0};
+ int i127[] = {0, 0, 0, 0, 1, 1, 1};
+ int i128[] = {0, 0, 0, 1, 0, 0, 0};
+ int i129[] = {0, 0, 0, 1, 0, 0, 1};
+ int i130[] = {0, 0, 0, 1, 0, 1, 0};
+ int i131[] = {0, 0, 0, 1, 0, 1, 1};
+ int i132[] = {0, 0, 0, 1, 1, 0, 0};
+ int i133[] = {0, 0, 0, 1, 1, 0, 1};
+ int i134[] = {0, 0, 0, 1, 1, 1, 0};
+ int i135[] = {0, 0, 0, 1, 1, 1, 1};
+ int i136[] = {0, 0, 1, 0, 0, 0, 0};
+ int i137[] = {0, 0, 1, 0, 0, 0, 1};
+ int i138[] = {0, 0, 1, 0, 0, 1, 0};
+ int i139[] = {0, 0, 1, 0, 0, 1, 1};
+ int i140[] = {0, 0, 1, 0, 1, 0, 0};
+ int i141[] = {0, 0, 1, 0, 1, 0, 1};
+ int i142[] = {0, 0, 1, 0, 1, 1, 0};
+ int i143[] = {0, 0, 1, 0, 1, 1, 1};
+ int i144[] = {0, 0, 1, 1, 0, 0, 0};
+ int i145[] = {0, 0, 1, 1, 0, 0, 1};
+ int i146[] = {0, 0, 1, 1, 0, 1, 0};
+ int i147[] = {0, 0, 1, 1, 0, 1, 1};
+ int i148[] = {0, 0, 1, 1, 1, 0, 0};
+ int i149[] = {0, 0, 1, 1, 1, 0, 1};
+ int i150[] = {0, 0, 1, 1, 1, 1, 0};
+ int i151[] = {0, 0, 1, 1, 1, 1, 1};
+ int i152[] = {0, 1, 0, 0, 0, 0, 0};
+ int i153[] = {0, 1, 0, 0, 0, 0, 1};
+ int i154[] = {0, 1, 0, 0, 0, 1, 0};
+ int i155[] = {0, 1, 0, 0, 0, 1, 1};
+ int i156[] = {0, 1, 0, 0, 1, 0, 0};
+ int i157[] = {0, 1, 0, 0, 1, 0, 1};
+ int i158[] = {0, 1, 0, 0, 1, 1, 0};
+ int i159[] = {0, 1, 0, 0, 1, 1, 1};
+ int i160[] = {0, 1, 0, 1, 0, 0, 0};
+ int i161[] = {0, 1, 0, 1, 0, 0, 1};
+ int i162[] = {0, 1, 0, 1, 0, 1, 0};
+ int i163[] = {0, 1, 0, 1, 0, 1, 1};
+ int i164[] = {0, 1, 0, 1, 1, 0, 0};
+ int i165[] = {0, 1, 0, 1, 1, 0, 1};
+ int i166[] = {0, 1, 0, 1, 1, 1, 0};
+ int i167[] = {0, 1, 0, 1, 1, 1, 1};
+ int i168[] = {0, 1, 1, 0, 0, 0, 0};
+ int i169[] = {0, 1, 1, 0, 0, 0, 1};
+ int i170[] = {0, 1, 1, 0, 0, 1, 0};
+ int i171[] = {0, 1, 1, 0, 0, 1, 1};
+ int i172[] = {0, 1, 1, 0, 1, 0, 0};
+ int i173[] = {0, 1, 1, 0, 1, 0, 1};
+ int i174[] = {0, 1, 1, 0, 1, 1, 0};
+ int i175[] = {0, 1, 1, 0, 1, 1, 1};
+ int i176[] = {0, 1, 1, 1, 0, 0, 0};
+ int i177[] = {0, 1, 1, 1, 0, 0, 1};
+ int i178[] = {0, 1, 1, 1, 0, 1, 0};
+ int i179[] = {0, 1, 1, 1, 0, 1, 1};
+ int i180[] = {0, 1, 1, 1, 1, 0, 0};
+ int i181[] = {0, 1, 1, 1, 1, 0, 1};
+ int i182[] = {0, 1, 1, 1, 1, 1, 0};
+ int i183[] = {0, 1, 1, 1, 1, 1, 1};
+ int i184[] = {1, 0, 0, 0, 0, 0, 0};
+ int i185[] = {1, 0, 0, 0, 0, 0, 1};
+ int i186[] = {1, 0, 0, 0, 0, 1, 0};
+ int i187[] = {1, 0, 0, 0, 0, 1, 1};
+ int i188[] = {1, 0, 0, 0, 1, 0, 0};
+ int i189[] = {1, 0, 0, 0, 1, 0, 1};
+ int i190[] = {1, 0, 0, 0, 1, 1, 0};
+ int i191[] = {1, 0, 0, 0, 1, 1, 1};
+ int i192[] = {1, 0, 0, 1, 0, 0, 0};
+ int i193[] = {1, 0, 0, 1, 0, 0, 1};
+ int i194[] = {1, 0, 0, 1, 0, 1, 0};
+ int i195[] = {1, 0, 0, 1, 0, 1, 1};
+ int i196[] = {1, 0, 0, 1, 1, 0, 0};
+ int i197[] = {1, 0, 0, 1, 1, 0, 1};
+ int i198[] = {1, 0, 0, 1, 1, 1, 0};
+ int i199[] = {1, 0, 0, 1, 1, 1, 1};
+ int i200[] = {1, 0, 1, 0, 0, 0, 0};
+ int i201[] = {1, 0, 1, 0, 0, 0, 1};
+ int i202[] = {1, 0, 1, 0, 0, 1, 0};
+ int i203[] = {1, 0, 1, 0, 0, 1, 1};
+ int i204[] = {1, 0, 1, 0, 1, 0, 0};
+ int i205[] = {1, 0, 1, 0, 1, 0, 1};
+ int i206[] = {1, 0, 1, 0, 1, 1, 0};
+ int i207[] = {1, 0, 1, 0, 1, 1, 1};
+ int i208[] = {1, 0, 1, 1, 0, 0, 0};
+ int i209[] = {1, 0, 1, 1, 0, 0, 1};
+ int i210[] = {1, 0, 1, 1, 0, 1, 0};
+ int i211[] = {1, 0, 1, 1, 0, 1, 1};
+ int i212[] = {1, 0, 1, 1, 1, 0, 0};
+ int i213[] = {1, 0, 1, 1, 1, 0, 1};
+ int i214[] = {1, 0, 1, 1, 1, 1, 0};
+ int i215[] = {1, 0, 1, 1, 1, 1, 1};
+ int i216[] = {1, 1, 0, 0, 0, 0, 0};
+ int i217[] = {1, 1, 0, 0, 0, 0, 1};
+ int i218[] = {1, 1, 0, 0, 0, 1, 0};
+ int i219[] = {1, 1, 0, 0, 0, 1, 1};
+ int i220[] = {1, 1, 0, 0, 1, 0, 0};
+ int i221[] = {1, 1, 0, 0, 1, 0, 1};
+ int i222[] = {1, 1, 0, 0, 1, 1, 0};
+ int i223[] = {1, 1, 0, 0, 1, 1, 1};
+ int i224[] = {1, 1, 0, 1, 0, 0, 0};
+ int i225[] = {1, 1, 0, 1, 0, 0, 1};
+ int i226[] = {1, 1, 0, 1, 0, 1, 0};
+ int i227[] = {1, 1, 0, 1, 0, 1, 1};
+ int i228[] = {1, 1, 0, 1, 1, 0, 0};
+ int i229[] = {1, 1, 0, 1, 1, 0, 1};
+ int i230[] = {1, 1, 0, 1, 1, 1, 0};
+ int i231[] = {1, 1, 0, 1, 1, 1, 1};
+ int i232[] = {1, 1, 1, 0, 0, 0, 0};
+ int i233[] = {1, 1, 1, 0, 0, 0, 1};
+ int i234[] = {1, 1, 1, 0, 0, 1, 0};
+ int i235[] = {1, 1, 1, 0, 0, 1, 1};
+ int i236[] = {1, 1, 1, 0, 1, 0, 0};
+ int i237[] = {1, 1, 1, 0, 1, 0, 1};
+ int i238[] = {1, 1, 1, 0, 1, 1, 0};
+ int i239[] = {1, 1, 1, 0, 1, 1, 1};
+ int i240[] = {1, 1, 1, 1, 0, 0, 0};
+ int i241[] = {1, 1, 1, 1, 0, 0, 1};
+ int i242[] = {1, 1, 1, 1, 0, 1, 0};
+ int i243[] = {1, 1, 1, 1, 0, 1, 1};
+ int i244[] = {1, 1, 1, 1, 1, 0, 0};
+ int i245[] = {1, 1, 1, 1, 1, 0, 1};
+ int i246[] = {1, 1, 1, 1, 1, 1, 0};
+ assert(std::is_heap_until(i120, i120+7, std::greater<int>()) == i120+7);
+ assert(std::is_heap_until(i121, i121+7, std::greater<int>()) == i121+7);
+ assert(std::is_heap_until(i122, i122+7, std::greater<int>()) == i122+7);
+ assert(std::is_heap_until(i123, i123+7, std::greater<int>()) == i123+7);
+ assert(std::is_heap_until(i124, i124+7, std::greater<int>()) == i124+7);
+ assert(std::is_heap_until(i125, i125+7, std::greater<int>()) == i125+7);
+ assert(std::is_heap_until(i126, i126+7, std::greater<int>()) == i126+7);
+ assert(std::is_heap_until(i127, i127+7, std::greater<int>()) == i127+7);
+ assert(std::is_heap_until(i128, i128+7, std::greater<int>()) == i128+7);
+ assert(std::is_heap_until(i129, i129+7, std::greater<int>()) == i129+7);
+ assert(std::is_heap_until(i130, i130+7, std::greater<int>()) == i130+7);
+ assert(std::is_heap_until(i131, i131+7, std::greater<int>()) == i131+7);
+ assert(std::is_heap_until(i132, i132+7, std::greater<int>()) == i132+7);
+ assert(std::is_heap_until(i133, i133+7, std::greater<int>()) == i133+7);
+ assert(std::is_heap_until(i134, i134+7, std::greater<int>()) == i134+7);
+ assert(std::is_heap_until(i135, i135+7, std::greater<int>()) == i135+7);
+ assert(std::is_heap_until(i136, i136+7, std::greater<int>()) == i136+5);
+ assert(std::is_heap_until(i137, i137+7, std::greater<int>()) == i137+5);
+ assert(std::is_heap_until(i138, i138+7, std::greater<int>()) == i138+6);
+ assert(std::is_heap_until(i139, i139+7, std::greater<int>()) == i139+7);
+ assert(std::is_heap_until(i140, i140+7, std::greater<int>()) == i140+5);
+ assert(std::is_heap_until(i141, i141+7, std::greater<int>()) == i141+5);
+ assert(std::is_heap_until(i142, i142+7, std::greater<int>()) == i142+6);
+ assert(std::is_heap_until(i143, i143+7, std::greater<int>()) == i143+7);
+ assert(std::is_heap_until(i144, i144+7, std::greater<int>()) == i144+5);
+ assert(std::is_heap_until(i145, i145+7, std::greater<int>()) == i145+5);
+ assert(std::is_heap_until(i146, i146+7, std::greater<int>()) == i146+6);
+ assert(std::is_heap_until(i147, i147+7, std::greater<int>()) == i147+7);
+ assert(std::is_heap_until(i148, i148+7, std::greater<int>()) == i148+5);
+ assert(std::is_heap_until(i149, i149+7, std::greater<int>()) == i149+5);
+ assert(std::is_heap_until(i150, i150+7, std::greater<int>()) == i150+6);
+ assert(std::is_heap_until(i151, i151+7, std::greater<int>()) == i151+7);
+ assert(std::is_heap_until(i152, i152+7, std::greater<int>()) == i152+3);
+ assert(std::is_heap_until(i153, i153+7, std::greater<int>()) == i153+3);
+ assert(std::is_heap_until(i154, i154+7, std::greater<int>()) == i154+3);
+ assert(std::is_heap_until(i155, i155+7, std::greater<int>()) == i155+3);
+ assert(std::is_heap_until(i156, i156+7, std::greater<int>()) == i156+3);
+ assert(std::is_heap_until(i157, i157+7, std::greater<int>()) == i157+3);
+ assert(std::is_heap_until(i158, i158+7, std::greater<int>()) == i158+3);
+ assert(std::is_heap_until(i159, i159+7, std::greater<int>()) == i159+3);
+ assert(std::is_heap_until(i160, i160+7, std::greater<int>()) == i160+4);
+ assert(std::is_heap_until(i161, i161+7, std::greater<int>()) == i161+4);
+ assert(std::is_heap_until(i162, i162+7, std::greater<int>()) == i162+4);
+ assert(std::is_heap_until(i163, i163+7, std::greater<int>()) == i163+4);
+ assert(std::is_heap_until(i164, i164+7, std::greater<int>()) == i164+7);
+ assert(std::is_heap_until(i165, i165+7, std::greater<int>()) == i165+7);
+ assert(std::is_heap_until(i166, i166+7, std::greater<int>()) == i166+7);
+ assert(std::is_heap_until(i167, i167+7, std::greater<int>()) == i167+7);
+ assert(std::is_heap_until(i168, i168+7, std::greater<int>()) == i168+3);
+ assert(std::is_heap_until(i169, i169+7, std::greater<int>()) == i169+3);
+ assert(std::is_heap_until(i170, i170+7, std::greater<int>()) == i170+3);
+ assert(std::is_heap_until(i171, i171+7, std::greater<int>()) == i171+3);
+ assert(std::is_heap_until(i172, i172+7, std::greater<int>()) == i172+3);
+ assert(std::is_heap_until(i173, i173+7, std::greater<int>()) == i173+3);
+ assert(std::is_heap_until(i174, i174+7, std::greater<int>()) == i174+3);
+ assert(std::is_heap_until(i175, i175+7, std::greater<int>()) == i175+3);
+ assert(std::is_heap_until(i176, i176+7, std::greater<int>()) == i176+4);
+ assert(std::is_heap_until(i177, i177+7, std::greater<int>()) == i177+4);
+ assert(std::is_heap_until(i178, i178+7, std::greater<int>()) == i178+4);
+ assert(std::is_heap_until(i179, i179+7, std::greater<int>()) == i179+4);
+ assert(std::is_heap_until(i180, i180+7, std::greater<int>()) == i180+5);
+ assert(std::is_heap_until(i181, i181+7, std::greater<int>()) == i181+5);
+ assert(std::is_heap_until(i182, i182+7, std::greater<int>()) == i182+6);
+ assert(std::is_heap_until(i183, i183+7, std::greater<int>()) == i183+7);
+ assert(std::is_heap_until(i184, i184+7, std::greater<int>()) == i184+1);
+ assert(std::is_heap_until(i185, i185+7, std::greater<int>()) == i185+1);
+ assert(std::is_heap_until(i186, i186+7, std::greater<int>()) == i186+1);
+ assert(std::is_heap_until(i187, i187+7, std::greater<int>()) == i187+1);
+ assert(std::is_heap_until(i188, i188+7, std::greater<int>()) == i188+1);
+ assert(std::is_heap_until(i189, i189+7, std::greater<int>()) == i189+1);
+ assert(std::is_heap_until(i190, i190+7, std::greater<int>()) == i190+1);
+ assert(std::is_heap_until(i191, i191+7, std::greater<int>()) == i191+1);
+ assert(std::is_heap_until(i192, i192+7, std::greater<int>()) == i192+1);
+ assert(std::is_heap_until(i193, i193+7, std::greater<int>()) == i193+1);
+ assert(std::is_heap_until(i194, i194+7, std::greater<int>()) == i194+1);
+ assert(std::is_heap_until(i195, i195+7, std::greater<int>()) == i195+1);
+ assert(std::is_heap_until(i196, i196+7, std::greater<int>()) == i196+1);
+ assert(std::is_heap_until(i197, i197+7, std::greater<int>()) == i197+1);
+ assert(std::is_heap_until(i198, i198+7, std::greater<int>()) == i198+1);
+ assert(std::is_heap_until(i199, i199+7, std::greater<int>()) == i199+1);
+ assert(std::is_heap_until(i200, i200+7, std::greater<int>()) == i200+1);
+ assert(std::is_heap_until(i201, i201+7, std::greater<int>()) == i201+1);
+ assert(std::is_heap_until(i202, i202+7, std::greater<int>()) == i202+1);
+ assert(std::is_heap_until(i203, i203+7, std::greater<int>()) == i203+1);
+ assert(std::is_heap_until(i204, i204+7, std::greater<int>()) == i204+1);
+ assert(std::is_heap_until(i205, i205+7, std::greater<int>()) == i205+1);
+ assert(std::is_heap_until(i206, i206+7, std::greater<int>()) == i206+1);
+ assert(std::is_heap_until(i207, i207+7, std::greater<int>()) == i207+1);
+ assert(std::is_heap_until(i208, i208+7, std::greater<int>()) == i208+1);
+ assert(std::is_heap_until(i209, i209+7, std::greater<int>()) == i209+1);
+ assert(std::is_heap_until(i210, i210+7, std::greater<int>()) == i210+1);
+ assert(std::is_heap_until(i211, i211+7, std::greater<int>()) == i211+1);
+ assert(std::is_heap_until(i212, i212+7, std::greater<int>()) == i212+1);
+ assert(std::is_heap_until(i213, i213+7, std::greater<int>()) == i213+1);
+ assert(std::is_heap_until(i214, i214+7, std::greater<int>()) == i214+1);
+ assert(std::is_heap_until(i215, i215+7, std::greater<int>()) == i215+1);
+ assert(std::is_heap_until(i216, i216+7, std::greater<int>()) == i216+2);
+ assert(std::is_heap_until(i217, i217+7, std::greater<int>()) == i217+2);
+ assert(std::is_heap_until(i218, i218+7, std::greater<int>()) == i218+2);
+ assert(std::is_heap_until(i219, i219+7, std::greater<int>()) == i219+2);
+ assert(std::is_heap_until(i220, i220+7, std::greater<int>()) == i220+2);
+ assert(std::is_heap_until(i221, i221+7, std::greater<int>()) == i221+2);
+ assert(std::is_heap_until(i222, i222+7, std::greater<int>()) == i222+2);
+ assert(std::is_heap_until(i223, i223+7, std::greater<int>()) == i223+2);
+ assert(std::is_heap_until(i224, i224+7, std::greater<int>()) == i224+2);
+ assert(std::is_heap_until(i225, i225+7, std::greater<int>()) == i225+2);
+ assert(std::is_heap_until(i226, i226+7, std::greater<int>()) == i226+2);
+ assert(std::is_heap_until(i227, i227+7, std::greater<int>()) == i227+2);
+ assert(std::is_heap_until(i228, i228+7, std::greater<int>()) == i228+2);
+ assert(std::is_heap_until(i229, i229+7, std::greater<int>()) == i229+2);
+ assert(std::is_heap_until(i230, i230+7, std::greater<int>()) == i230+2);
+ assert(std::is_heap_until(i231, i231+7, std::greater<int>()) == i231+2);
+ assert(std::is_heap_until(i232, i232+7, std::greater<int>()) == i232+3);
+ assert(std::is_heap_until(i233, i233+7, std::greater<int>()) == i233+3);
+ assert(std::is_heap_until(i234, i234+7, std::greater<int>()) == i234+3);
+ assert(std::is_heap_until(i235, i235+7, std::greater<int>()) == i235+3);
+ assert(std::is_heap_until(i236, i236+7, std::greater<int>()) == i236+3);
+ assert(std::is_heap_until(i237, i237+7, std::greater<int>()) == i237+3);
+ assert(std::is_heap_until(i238, i238+7, std::greater<int>()) == i238+3);
+ assert(std::is_heap_until(i239, i239+7, std::greater<int>()) == i239+3);
+ assert(std::is_heap_until(i240, i240+7, std::greater<int>()) == i240+4);
+ assert(std::is_heap_until(i241, i241+7, std::greater<int>()) == i241+4);
+ assert(std::is_heap_until(i242, i242+7, std::greater<int>()) == i242+4);
+ assert(std::is_heap_until(i243, i243+7, std::greater<int>()) == i243+4);
+ assert(std::is_heap_until(i244, i244+7, std::greater<int>()) == i244+5);
+ assert(std::is_heap_until(i245, i245+7, std::greater<int>()) == i245+5);
+ assert(std::is_heap_until(i246, i246+7, std::greater<int>()) == i246+6);
+}
+
+int main()
+{
+ test();
+}
diff --git a/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap.pass.cpp b/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap.pass.cpp
new file mode 100644
index 000000000000..51b912768f35
--- /dev/null
+++ b/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<RandomAccessIterator Iter>
+// requires ShuffleIterator<Iter> && LessThanComparable<Iter::value_type>
+// void
+// make_heap(Iter first, Iter last);
+
+#include <algorithm>
+#include <cassert>
+
+void test(unsigned N)
+{
+ int* ia = new int [N];
+ for (int i = 0; i < N; ++i)
+ ia[i] = i;
+ std::random_shuffle(ia, ia+N);
+ std::make_heap(ia, ia+N);
+ assert(std::is_heap(ia, ia+N));
+ delete [] ia;
+}
+
+int main()
+{
+ test(0);
+ test(1);
+ test(2);
+ test(3);
+ test(10);
+ test(1000);
+}
diff --git a/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap_comp.pass.cpp
new file mode 100644
index 000000000000..4cde1a7d32eb
--- /dev/null
+++ b/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap_comp.pass.cpp
@@ -0,0 +1,101 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<RandomAccessIterator Iter, StrictWeakOrder<auto, Iter::value_type> Compare>
+// requires ShuffleIterator<Iter> && CopyConstructible<Compare>
+// void
+// make_heap(Iter first, Iter last, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "counting_predicates.hpp"
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#include <memory>
+
+struct indirect_less
+{
+ template <class P>
+ bool operator()(const P& x, const P& y)
+ {return *x < *y;}
+};
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+void test(unsigned N)
+{
+ int* ia = new int [N];
+ {
+ for (int i = 0; i < N; ++i)
+ ia[i] = i;
+ std::random_shuffle(ia, ia+N);
+ std::make_heap(ia, ia+N, std::greater<int>());
+ assert(std::is_heap(ia, ia+N, std::greater<int>()));
+ }
+
+// Ascending
+ {
+ binary_counting_predicate<std::greater<int>, int, int> pred ((std::greater<int>()));
+ for (int i = 0; i < N; ++i)
+ ia[i] = i;
+ std::make_heap(ia, ia+N, std::ref(pred));
+ assert(pred.count() <= 3*N);
+ assert(std::is_heap(ia, ia+N, pred));
+ }
+
+// Descending
+ {
+ binary_counting_predicate<std::greater<int>, int, int> pred ((std::greater<int>()));
+ for (int i = 0; i < N; ++i)
+ ia[N-1-i] = i;
+ std::make_heap(ia, ia+N, std::ref(pred));
+ assert(pred.count() <= 3*N);
+ assert(std::is_heap(ia, ia+N, pred));
+ }
+
+// Random
+ {
+ binary_counting_predicate<std::greater<int>, int, int> pred ((std::greater<int>()));
+ std::random_shuffle(ia, ia+N);
+ std::make_heap(ia, ia+N, std::ref(pred));
+ assert(pred.count() <= 3*N);
+ assert(std::is_heap(ia, ia+N, pred));
+ }
+
+ delete [] ia;
+}
+
+int main()
+{
+ test(0);
+ test(1);
+ test(2);
+ test(3);
+ test(10);
+ test(1000);
+ test(10000);
+ test(100000);
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ const int N = 1000;
+ std::unique_ptr<int>* ia = new std::unique_ptr<int> [N];
+ for (int i = 0; i < N; ++i)
+ ia[i].reset(new int(i));
+ std::random_shuffle(ia, ia+N);
+ std::make_heap(ia, ia+N, indirect_less());
+ assert(std::is_heap(ia, ia+N, indirect_less()));
+ delete [] ia;
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/algorithms/alg.sorting/alg.heap.operations/nothing_to_do.pass.cpp b/test/std/algorithms/alg.sorting/alg.heap.operations/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/algorithms/alg.sorting/alg.heap.operations/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap.pass.cpp b/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap.pass.cpp
new file mode 100644
index 000000000000..823985df6ca0
--- /dev/null
+++ b/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<RandomAccessIterator Iter>
+// requires ShuffleIterator<Iter> && LessThanComparable<Iter::value_type>
+// void
+// pop_heap(Iter first, Iter last);
+
+#include <algorithm>
+#include <cassert>
+
+void test(unsigned N)
+{
+ int* ia = new int [N];
+ for (int i = 0; i < N; ++i)
+ ia[i] = i;
+ std::random_shuffle(ia, ia+N);
+ std::make_heap(ia, ia+N);
+ for (int i = N; i > 0; --i)
+ {
+ std::pop_heap(ia, ia+i);
+ assert(std::is_heap(ia, ia+i-1));
+ }
+ std::pop_heap(ia, ia);
+ delete [] ia;
+}
+
+int main()
+{
+ test(1000);
+}
diff --git a/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap_comp.pass.cpp
new file mode 100644
index 000000000000..1db4428a1c1f
--- /dev/null
+++ b/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap_comp.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<RandomAccessIterator Iter, StrictWeakOrder<auto, Iter::value_type> Compare>
+// requires ShuffleIterator<Iter> && CopyConstructible<Compare>
+// void
+// pop_heap(Iter first, Iter last, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#include <memory>
+
+struct indirect_less
+{
+ template <class P>
+ bool operator()(const P& x, const P& y)
+ {return *x < *y;}
+};
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+void test(unsigned N)
+{
+ int* ia = new int [N];
+ for (int i = 0; i < N; ++i)
+ ia[i] = i;
+ std::random_shuffle(ia, ia+N);
+ std::make_heap(ia, ia+N, std::greater<int>());
+ for (int i = N; i > 0; --i)
+ {
+ std::pop_heap(ia, ia+i, std::greater<int>());
+ assert(std::is_heap(ia, ia+i-1, std::greater<int>()));
+ }
+ std::pop_heap(ia, ia, std::greater<int>());
+ delete [] ia;
+}
+
+int main()
+{
+ test(1000);
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ const int N = 1000;
+ std::unique_ptr<int>* ia = new std::unique_ptr<int> [N];
+ for (int i = 0; i < N; ++i)
+ ia[i].reset(new int(i));
+ std::random_shuffle(ia, ia+N);
+ std::make_heap(ia, ia+N, indirect_less());
+ for (int i = N; i > 0; --i)
+ {
+ std::pop_heap(ia, ia+i, indirect_less());
+ assert(std::is_heap(ia, ia+i-1, indirect_less()));
+ }
+ delete [] ia;
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap.pass.cpp b/test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap.pass.cpp
new file mode 100644
index 000000000000..0fc50a81207e
--- /dev/null
+++ b/test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<RandomAccessIterator Iter>
+// requires ShuffleIterator<Iter>
+// && LessThanComparable<Iter::value_type>
+// void
+// push_heap(Iter first, Iter last);
+
+#include <algorithm>
+#include <cassert>
+
+void test(unsigned N)
+{
+ int* ia = new int [N];
+ for (int i = 0; i < N; ++i)
+ ia[i] = i;
+ std::random_shuffle(ia, ia+N);
+ for (int i = 0; i <= N; ++i)
+ {
+ std::push_heap(ia, ia+i);
+ assert(std::is_heap(ia, ia+i));
+ }
+ delete [] ia;
+}
+
+int main()
+{
+ test(1000);
+}
diff --git a/test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap_comp.pass.cpp
new file mode 100644
index 000000000000..217217b38ee3
--- /dev/null
+++ b/test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap_comp.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<RandomAccessIterator Iter>
+// requires ShuffleIterator<Iter>
+// && LessThanComparable<Iter::value_type>
+// void
+// push_heap(Iter first, Iter last);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#include <memory>
+
+struct indirect_less
+{
+ template <class P>
+ bool operator()(const P& x, const P& y)
+ {return *x < *y;}
+};
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+void test(unsigned N)
+{
+ int* ia = new int [N];
+ for (int i = 0; i < N; ++i)
+ ia[i] = i;
+ std::random_shuffle(ia, ia+N);
+ for (int i = 0; i <= N; ++i)
+ {
+ std::push_heap(ia, ia+i, std::greater<int>());
+ assert(std::is_heap(ia, ia+i, std::greater<int>()));
+ }
+ delete [] ia;
+}
+
+int main()
+{
+ test(1000);
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ const int N = 1000;
+ std::unique_ptr<int>* ia = new std::unique_ptr<int> [N];
+ for (int i = 0; i < N; ++i)
+ ia[i].reset(new int(i));
+ std::random_shuffle(ia, ia+N);
+ for (int i = 0; i <= N; ++i)
+ {
+ std::push_heap(ia, ia+i, indirect_less());
+ assert(std::is_heap(ia, ia+i, indirect_less()));
+ }
+ delete [] ia;
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/algorithms/alg.sorting/alg.heap.operations/sort.heap/sort_heap.pass.cpp b/test/std/algorithms/alg.sorting/alg.heap.operations/sort.heap/sort_heap.pass.cpp
new file mode 100644
index 000000000000..4a08f111e6dd
--- /dev/null
+++ b/test/std/algorithms/alg.sorting/alg.heap.operations/sort.heap/sort_heap.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<RandomAccessIterator Iter>
+// requires ShuffleIterator<Iter> && LessThanComparable<Iter::value_type>
+// void
+// sort_heap(Iter first, Iter last);
+
+#include <algorithm>
+#include <cassert>
+
+void test(unsigned N)
+{
+ int* ia = new int [N];
+ for (int i = 0; i < N; ++i)
+ ia[i] = i;
+ std::random_shuffle(ia, ia+N);
+ std::make_heap(ia, ia+N);
+ std::sort_heap(ia, ia+N);
+ assert(std::is_sorted(ia, ia+N));
+ delete [] ia;
+}
+
+int main()
+{
+ test(0);
+ test(1);
+ test(2);
+ test(3);
+ test(10);
+ test(1000);
+}
diff --git a/test/std/algorithms/alg.sorting/alg.heap.operations/sort.heap/sort_heap_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.heap.operations/sort.heap/sort_heap_comp.pass.cpp
new file mode 100644
index 000000000000..7d3e2d570158
--- /dev/null
+++ b/test/std/algorithms/alg.sorting/alg.heap.operations/sort.heap/sort_heap_comp.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<RandomAccessIterator Iter, StrictWeakOrder<auto, Iter::value_type> Compare>
+// requires ShuffleIterator<Iter> && CopyConstructible<Compare>
+// void
+// sort_heap(Iter first, Iter last, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#include <memory>
+
+struct indirect_less
+{
+ template <class P>
+ bool operator()(const P& x, const P& y)
+ {return *x < *y;}
+};
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+void test(unsigned N)
+{
+ int* ia = new int [N];
+ for (int i = 0; i < N; ++i)
+ ia[i] = i;
+ std::random_shuffle(ia, ia+N);
+ std::make_heap(ia, ia+N, std::greater<int>());
+ std::sort_heap(ia, ia+N, std::greater<int>());
+ assert(std::is_sorted(ia, ia+N, std::greater<int>()));
+ delete [] ia;
+}
+
+int main()
+{
+ test(0);
+ test(1);
+ test(2);
+ test(3);
+ test(10);
+ test(1000);
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ const int N = 1000;
+ std::unique_ptr<int>* ia = new std::unique_ptr<int> [N];
+ for (int i = 0; i < N; ++i)
+ ia[i].reset(new int(i));
+ std::random_shuffle(ia, ia+N);
+ std::make_heap(ia, ia+N, indirect_less());
+ std::sort_heap(ia, ia+N, indirect_less());
+ assert(std::is_sorted(ia, ia+N, indirect_less()));
+ delete [] ia;
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/algorithms/alg.sorting/alg.lex.comparison/lexicographical_compare.pass.cpp b/test/std/algorithms/alg.sorting/alg.lex.comparison/lexicographical_compare.pass.cpp
new file mode 100644
index 000000000000..71dfeefe7e41
--- /dev/null
+++ b/test/std/algorithms/alg.sorting/alg.lex.comparison/lexicographical_compare.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator Iter1, InputIterator Iter2>
+// requires HasLess<Iter1::value_type, Iter2::value_type>
+// && HasLess<Iter2::value_type, Iter1::value_type>
+// bool
+// lexicographical_compare(Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter1, class Iter2>
+void
+test()
+{
+ int ia[] = {1, 2, 3, 4};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ int ib[] = {1, 2, 3};
+ assert(!std::lexicographical_compare(Iter1(ia), Iter1(ia+sa), Iter2(ib), Iter2(ib+2)));
+ assert( std::lexicographical_compare(Iter1(ib), Iter1(ib+2), Iter2(ia), Iter2(ia+sa)));
+ assert(!std::lexicographical_compare(Iter1(ia), Iter1(ia+sa), Iter2(ib), Iter2(ib+3)));
+ assert( std::lexicographical_compare(Iter1(ib), Iter1(ib+3), Iter2(ia), Iter2(ia+sa)));
+ assert( std::lexicographical_compare(Iter1(ia), Iter1(ia+sa), Iter2(ib+1), Iter2(ib+3)));
+ assert(!std::lexicographical_compare(Iter1(ib+1), Iter1(ib+3), Iter2(ia), Iter2(ia+sa)));
+}
+
+int main()
+{
+ test<input_iterator<const int*>, input_iterator<const int*> >();
+ test<input_iterator<const int*>, forward_iterator<const int*> >();
+ test<input_iterator<const int*>, bidirectional_iterator<const int*> >();
+ test<input_iterator<const int*>, random_access_iterator<const int*> >();
+ test<input_iterator<const int*>, const int*>();
+
+ test<forward_iterator<const int*>, input_iterator<const int*> >();
+ test<forward_iterator<const int*>, forward_iterator<const int*> >();
+ test<forward_iterator<const int*>, bidirectional_iterator<const int*> >();
+ test<forward_iterator<const int*>, random_access_iterator<const int*> >();
+ test<forward_iterator<const int*>, const int*>();
+
+ test<bidirectional_iterator<const int*>, input_iterator<const int*> >();
+ test<bidirectional_iterator<const int*>, forward_iterator<const int*> >();
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*> >();
+ test<bidirectional_iterator<const int*>, random_access_iterator<const int*> >();
+ test<bidirectional_iterator<const int*>, const int*>();
+
+ test<random_access_iterator<const int*>, input_iterator<const int*> >();
+ test<random_access_iterator<const int*>, forward_iterator<const int*> >();
+ test<random_access_iterator<const int*>, bidirectional_iterator<const int*> >();
+ test<random_access_iterator<const int*>, random_access_iterator<const int*> >();
+ test<random_access_iterator<const int*>, const int*>();
+
+ test<const int*, input_iterator<const int*> >();
+ test<const int*, forward_iterator<const int*> >();
+ test<const int*, bidirectional_iterator<const int*> >();
+ test<const int*, random_access_iterator<const int*> >();
+ test<const int*, const int*>();
+}
diff --git a/test/std/algorithms/alg.sorting/alg.lex.comparison/lexicographical_compare_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.lex.comparison/lexicographical_compare_comp.pass.cpp
new file mode 100644
index 000000000000..c1851560ef23
--- /dev/null
+++ b/test/std/algorithms/alg.sorting/alg.lex.comparison/lexicographical_compare_comp.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator Iter1, InputIterator Iter2, CopyConstructible Compare>
+// requires Predicate<Compare, Iter1::value_type, Iter2::value_type>
+// && Predicate<Compare, Iter2::value_type, Iter1::value_type>
+// bool
+// lexicographical_compare(Iter1 first1, Iter1 last1,
+// Iter2 first2, Iter2 last2, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter1, class Iter2>
+void
+test()
+{
+ int ia[] = {1, 2, 3, 4};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ int ib[] = {1, 2, 3};
+ typedef std::greater<int> C;
+ C c;
+ assert(!std::lexicographical_compare(Iter1(ia), Iter1(ia+sa), Iter2(ib), Iter2(ib+2), c));
+ assert( std::lexicographical_compare(Iter1(ib), Iter1(ib+2), Iter2(ia), Iter2(ia+sa), c));
+ assert(!std::lexicographical_compare(Iter1(ia), Iter1(ia+sa), Iter2(ib), Iter2(ib+3), c));
+ assert( std::lexicographical_compare(Iter1(ib), Iter1(ib+3), Iter2(ia), Iter2(ia+sa), c));
+ assert(!std::lexicographical_compare(Iter1(ia), Iter1(ia+sa), Iter2(ib+1), Iter2(ib+3), c));
+ assert( std::lexicographical_compare(Iter1(ib+1), Iter1(ib+3), Iter2(ia), Iter2(ia+sa), c));
+}
+
+int main()
+{
+ test<input_iterator<const int*>, input_iterator<const int*> >();
+ test<input_iterator<const int*>, forward_iterator<const int*> >();
+ test<input_iterator<const int*>, bidirectional_iterator<const int*> >();
+ test<input_iterator<const int*>, random_access_iterator<const int*> >();
+ test<input_iterator<const int*>, const int*>();
+
+ test<forward_iterator<const int*>, input_iterator<const int*> >();
+ test<forward_iterator<const int*>, forward_iterator<const int*> >();
+ test<forward_iterator<const int*>, bidirectional_iterator<const int*> >();
+ test<forward_iterator<const int*>, random_access_iterator<const int*> >();
+ test<forward_iterator<const int*>, const int*>();
+
+ test<bidirectional_iterator<const int*>, input_iterator<const int*> >();
+ test<bidirectional_iterator<const int*>, forward_iterator<const int*> >();
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*> >();
+ test<bidirectional_iterator<const int*>, random_access_iterator<const int*> >();
+ test<bidirectional_iterator<const int*>, const int*>();
+
+ test<random_access_iterator<const int*>, input_iterator<const int*> >();
+ test<random_access_iterator<const int*>, forward_iterator<const int*> >();
+ test<random_access_iterator<const int*>, bidirectional_iterator<const int*> >();
+ test<random_access_iterator<const int*>, random_access_iterator<const int*> >();
+ test<random_access_iterator<const int*>, const int*>();
+
+ test<const int*, input_iterator<const int*> >();
+ test<const int*, forward_iterator<const int*> >();
+ test<const int*, bidirectional_iterator<const int*> >();
+ test<const int*, random_access_iterator<const int*> >();
+ test<const int*, const int*>();
+}
diff --git a/test/std/algorithms/alg.sorting/alg.merge/inplace_merge.pass.cpp b/test/std/algorithms/alg.sorting/alg.merge/inplace_merge.pass.cpp
new file mode 100644
index 000000000000..829157353fb3
--- /dev/null
+++ b/test/std/algorithms/alg.sorting/alg.merge/inplace_merge.pass.cpp
@@ -0,0 +1,108 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<BidirectionalIterator Iter>
+// requires ShuffleIterator<Iter>
+// && LessThanComparable<Iter::value_type>
+// void
+// inplace_merge(Iter first, Iter middle, Iter last);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+#if TEST_STD_VER >= 11
+struct S {
+ S() : i_(0) {}
+ S(int i) : i_(i) {}
+
+ S(const S& rhs) : i_(rhs.i_) {}
+ S( S&& rhs) : i_(rhs.i_) { rhs.i_ = -1; }
+
+ S& operator =(const S& rhs) { i_ = rhs.i_; return *this; }
+ S& operator =( S&& rhs) { i_ = rhs.i_; rhs.i_ = -2; assert(this != &rhs); return *this; }
+ S& operator =(int i) { i_ = i; return *this; }
+
+ bool operator <(const S& rhs) const { return i_ < rhs.i_; }
+ bool operator ==(const S& rhs) const { return i_ == rhs.i_; }
+ bool operator ==(int i) const { return i_ == i; }
+
+ void set(int i) { i_ = i; }
+
+ int i_;
+ };
+#endif
+
+template <class Iter>
+void
+test_one(unsigned N, unsigned M)
+{
+ typedef typename std::iterator_traits<Iter>::value_type value_type;
+ assert(M <= N);
+ value_type* ia = new value_type[N];
+ for (unsigned i = 0; i < N; ++i)
+ ia[i] = i;
+ std::random_shuffle(ia, ia+N);
+ std::sort(ia, ia+M);
+ std::sort(ia+M, ia+N);
+ std::inplace_merge(Iter(ia), Iter(ia+M), Iter(ia+N));
+ if(N > 0)
+ {
+ assert(ia[0] == 0);
+ assert(ia[N-1] == N-1);
+ assert(std::is_sorted(ia, ia+N));
+ }
+ delete [] ia;
+}
+
+template <class Iter>
+void
+test(unsigned N)
+{
+ test_one<Iter>(N, 0);
+ test_one<Iter>(N, N/4);
+ test_one<Iter>(N, N/2);
+ test_one<Iter>(N, 3*N/4);
+ test_one<Iter>(N, N);
+}
+
+template <class Iter>
+void
+test()
+{
+ test_one<Iter>(0, 0);
+ test_one<Iter>(1, 0);
+ test_one<Iter>(1, 1);
+ test_one<Iter>(2, 0);
+ test_one<Iter>(2, 1);
+ test_one<Iter>(2, 2);
+ test_one<Iter>(3, 0);
+ test_one<Iter>(3, 1);
+ test_one<Iter>(3, 2);
+ test_one<Iter>(3, 3);
+ test<Iter>(4);
+ test<Iter>(100);
+ test<Iter>(1000);
+}
+
+int main()
+{
+ test<bidirectional_iterator<int*> >();
+ test<random_access_iterator<int*> >();
+ test<int*>();
+
+#if TEST_STD_VER >= 11
+ test<bidirectional_iterator<S*> >();
+ test<random_access_iterator<S*> >();
+ test<S*>();
+#endif // TEST_STD_VER >= 11
+}
diff --git a/test/std/algorithms/alg.sorting/alg.merge/inplace_merge_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.merge/inplace_merge_comp.pass.cpp
new file mode 100644
index 000000000000..ca6f8e40cbd3
--- /dev/null
+++ b/test/std/algorithms/alg.sorting/alg.merge/inplace_merge_comp.pass.cpp
@@ -0,0 +1,146 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<BidirectionalIterator Iter, StrictWeakOrder<auto, Iter::value_type> Compare>
+// requires ShuffleIterator<Iter>
+// && CopyConstructible<Compare>
+// void
+// inplace_merge(Iter first, Iter middle, Iter last, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "test_macros.h"
+
+#if TEST_STD_VER >= 11
+#include <memory>
+
+struct indirect_less
+{
+ template <class P>
+ bool operator()(const P& x, const P& y)
+ {return *x < *y;}
+};
+
+struct S {
+ S() : i_(0) {}
+ S(int i) : i_(i) {}
+
+ S(const S& rhs) : i_(rhs.i_) {}
+ S( S&& rhs) : i_(rhs.i_) { rhs.i_ = -1; }
+
+ S& operator =(const S& rhs) { i_ = rhs.i_; return *this; }
+ S& operator =( S&& rhs) { i_ = rhs.i_; rhs.i_ = -2; assert(this != &rhs); return *this; }
+ S& operator =(int i) { i_ = i; return *this; }
+
+ bool operator <(const S& rhs) const { return i_ < rhs.i_; }
+ bool operator >(const S& rhs) const { return i_ > rhs.i_; }
+ bool operator ==(const S& rhs) const { return i_ == rhs.i_; }
+ bool operator ==(int i) const { return i_ == i; }
+
+ void set(int i) { i_ = i; }
+
+ int i_;
+ };
+
+
+#endif // TEST_STD_VER >= 11
+
+#include "test_iterators.h"
+#include "counting_predicates.hpp"
+
+template <class Iter>
+void
+test_one(unsigned N, unsigned M)
+{
+ assert(M <= N);
+ typedef typename std::iterator_traits<Iter>::value_type value_type;
+ value_type* ia = new value_type[N];
+ for (unsigned i = 0; i < N; ++i)
+ ia[i] = i;
+ std::random_shuffle(ia, ia+N);
+ std::sort(ia, ia+M, std::greater<value_type>());
+ std::sort(ia+M, ia+N, std::greater<value_type>());
+ binary_counting_predicate<std::greater<value_type>, value_type, value_type> pred((std::greater<value_type>()));
+ std::inplace_merge(Iter(ia), Iter(ia+M), Iter(ia+N), std::ref(pred));
+ if(N > 0)
+ {
+ assert(ia[0] == N-1);
+ assert(ia[N-1] == 0);
+ assert(std::is_sorted(ia, ia+N, std::greater<value_type>()));
+ assert(pred.count() <= (N-1));
+ }
+ delete [] ia;
+}
+
+template <class Iter>
+void
+test(unsigned N)
+{
+ test_one<Iter>(N, 0);
+ test_one<Iter>(N, N/4);
+ test_one<Iter>(N, N/2);
+ test_one<Iter>(N, 3*N/4);
+ test_one<Iter>(N, N);
+}
+
+template <class Iter>
+void
+test()
+{
+ test_one<Iter>(0, 0);
+ test_one<Iter>(1, 0);
+ test_one<Iter>(1, 1);
+ test_one<Iter>(2, 0);
+ test_one<Iter>(2, 1);
+ test_one<Iter>(2, 2);
+ test_one<Iter>(3, 0);
+ test_one<Iter>(3, 1);
+ test_one<Iter>(3, 2);
+ test_one<Iter>(3, 3);
+ test<Iter>(4);
+ test<Iter>(20);
+ test<Iter>(100);
+ test<Iter>(1000);
+}
+
+int main()
+{
+ test<bidirectional_iterator<int*> >();
+ test<random_access_iterator<int*> >();
+ test<int*>();
+
+#if TEST_STD_VER >= 11
+ test<bidirectional_iterator<S*> >();
+ test<random_access_iterator<S*> >();
+ test<S*>();
+
+ {
+ unsigned N = 100;
+ unsigned M = 50;
+ std::unique_ptr<int>* ia = new std::unique_ptr<int>[N];
+ for (unsigned i = 0; i < N; ++i)
+ ia[i].reset(new int(i));
+ std::random_shuffle(ia, ia+N);
+ std::sort(ia, ia+M, indirect_less());
+ std::sort(ia+M, ia+N, indirect_less());
+ std::inplace_merge(ia, ia+M, ia+N, indirect_less());
+ if(N > 0)
+ {
+ assert(*ia[0] == 0);
+ assert(*ia[N-1] == N-1);
+ assert(std::is_sorted(ia, ia+N, indirect_less()));
+ }
+ delete [] ia;
+ }
+#endif // TEST_STD_VER >= 11
+}
diff --git a/test/std/algorithms/alg.sorting/alg.merge/merge.pass.cpp b/test/std/algorithms/alg.sorting/alg.merge/merge.pass.cpp
new file mode 100644
index 000000000000..de96c419c4ea
--- /dev/null
+++ b/test/std/algorithms/alg.sorting/alg.merge/merge.pass.cpp
@@ -0,0 +1,224 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// REQUIRES: long_tests
+
+// <algorithm>
+
+// template<InputIterator InIter1, InputIterator InIter2, typename OutIter>
+// requires OutputIterator<OutIter, InIter1::reference>
+// && OutputIterator<OutIter, InIter2::reference>
+// && HasLess<InIter2::value_type, InIter1::value_type>
+// OutIter
+// merge(InIter1 first1, InIter1 last1, InIter2 first2, InIter2 last2, OutIter result);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class InIter1, class InIter2, class OutIter>
+void
+test()
+{
+ {
+ unsigned N = 100000;
+ int* ia = new int[N];
+ int* ib = new int[N];
+ int* ic = new int[2*N];
+ for (unsigned i = 0; i < N; ++i)
+ ia[i] = 2*i;
+ for (unsigned i = 0; i < N; ++i)
+ ib[i] = 2*i+1;
+ OutIter r = std::merge(InIter1(ia), InIter1(ia+N),
+ InIter2(ib), InIter2(ib+N), OutIter(ic));
+ assert(base(r) == ic+2*N);
+ assert(ic[0] == 0);
+ assert(ic[2*N-1] == 2*N-1);
+ assert(std::is_sorted(ic, ic+2*N));
+ delete [] ic;
+ delete [] ib;
+ delete [] ia;
+ }
+ {
+ unsigned N = 100;
+ int* ia = new int[N];
+ int* ib = new int[N];
+ int* ic = new int[2*N];
+ for (unsigned i = 0; i < 2*N; ++i)
+ ic[i] = i;
+ std::random_shuffle(ic, ic+2*N);
+ std::copy(ic, ic+N, ia);
+ std::copy(ic+N, ic+2*N, ib);
+ std::sort(ia, ia+N);
+ std::sort(ib, ib+N);
+ OutIter r = std::merge(InIter1(ia), InIter1(ia+N),
+ InIter2(ib), InIter2(ib+N), OutIter(ic));
+ assert(base(r) == ic+2*N);
+ assert(ic[0] == 0);
+ assert(ic[2*N-1] == 2*N-1);
+ assert(std::is_sorted(ic, ic+2*N));
+ delete [] ic;
+ delete [] ib;
+ delete [] ia;
+ }
+}
+
+int main()
+{
+ test<input_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+ test<input_iterator<const int*>, input_iterator<const int*>, forward_iterator<int*> >();
+ test<input_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<input_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+ test<input_iterator<const int*>, input_iterator<const int*>, int*>();
+
+ test<input_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+ test<input_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+ test<input_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<input_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+ test<input_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+ test<input_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+ test<input_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+ test<input_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<input_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+ test<input_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+ test<input_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+ test<input_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+ test<input_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<input_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+ test<input_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+ test<input_iterator<const int*>, const int*, output_iterator<int*> >();
+ test<input_iterator<const int*>, const int*, forward_iterator<int*> >();
+ test<input_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+ test<input_iterator<const int*>, const int*, random_access_iterator<int*> >();
+ test<input_iterator<const int*>, const int*, int*>();
+
+ test<forward_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+ test<forward_iterator<const int*>, input_iterator<const int*>, forward_iterator<int*> >();
+ test<forward_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<forward_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+ test<forward_iterator<const int*>, input_iterator<const int*>, int*>();
+
+ test<forward_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+ test<forward_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+ test<forward_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<forward_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+ test<forward_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+ test<forward_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+ test<forward_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+ test<forward_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<forward_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+ test<forward_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+ test<forward_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+ test<forward_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+ test<forward_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<forward_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+ test<forward_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+ test<forward_iterator<const int*>, const int*, output_iterator<int*> >();
+ test<forward_iterator<const int*>, const int*, forward_iterator<int*> >();
+ test<forward_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+ test<forward_iterator<const int*>, const int*, random_access_iterator<int*> >();
+ test<forward_iterator<const int*>, const int*, int*>();
+
+ test<bidirectional_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, input_iterator<const int*>, int*>();
+
+ test<bidirectional_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+ test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+ test<bidirectional_iterator<const int*>, const int*, output_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, const int*, forward_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, const int*, random_access_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, const int*, int*>();
+
+ test<random_access_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+ test<random_access_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+ test<random_access_iterator<const int*>, input_iterator<const int*>, int*>();
+
+ test<random_access_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+ test<random_access_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+ test<random_access_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+ test<random_access_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+ test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+ test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+ test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+ test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+ test<random_access_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+ test<random_access_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+ test<random_access_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+ test<random_access_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+ test<random_access_iterator<const int*>, const int*, output_iterator<int*> >();
+ test<random_access_iterator<const int*>, const int*, forward_iterator<int*> >();
+ test<random_access_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, const int*, random_access_iterator<int*> >();
+ test<random_access_iterator<const int*>, const int*, int*>();
+
+ test<const int*, input_iterator<const int*>, output_iterator<int*> >();
+ test<const int*, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<const int*, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<const int*, input_iterator<const int*>, random_access_iterator<int*> >();
+ test<const int*, input_iterator<const int*>, int*>();
+
+ test<const int*, forward_iterator<const int*>, output_iterator<int*> >();
+ test<const int*, forward_iterator<const int*>, forward_iterator<int*> >();
+ test<const int*, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<const int*, forward_iterator<const int*>, random_access_iterator<int*> >();
+ test<const int*, forward_iterator<const int*>, int*>();
+
+ test<const int*, bidirectional_iterator<const int*>, output_iterator<int*> >();
+ test<const int*, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+ test<const int*, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<const int*, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+ test<const int*, bidirectional_iterator<const int*>, int*>();
+
+ test<const int*, random_access_iterator<const int*>, output_iterator<int*> >();
+ test<const int*, random_access_iterator<const int*>, forward_iterator<int*> >();
+ test<const int*, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<const int*, random_access_iterator<const int*>, random_access_iterator<int*> >();
+ test<const int*, random_access_iterator<const int*>, int*>();
+
+ test<const int*, const int*, output_iterator<int*> >();
+ test<const int*, const int*, forward_iterator<int*> >();
+ test<const int*, const int*, bidirectional_iterator<int*> >();
+ test<const int*, const int*, random_access_iterator<int*> >();
+ test<const int*, const int*, int*>();
+}
diff --git a/test/std/algorithms/alg.sorting/alg.merge/merge_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.merge/merge_comp.pass.cpp
new file mode 100644
index 000000000000..bd38d7de6894
--- /dev/null
+++ b/test/std/algorithms/alg.sorting/alg.merge/merge_comp.pass.cpp
@@ -0,0 +1,234 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// REQUIRES: long_tests
+
+// <algorithm>
+
+// template<InputIterator InIter1, InputIterator InIter2, typename OutIter,
+// Predicate<auto, InIter2::value_type, InIter1::value_type> Compare>
+// requires OutputIterator<OutIter, InIter1::reference>
+// && OutputIterator<OutIter, InIter2::reference>
+// && CopyConstructible<Compare>
+// OutIter
+// merge(InIter1 first1, InIter1 last1,
+// InIter2 first2, InIter2 last2, OutIter result, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "counting_predicates.hpp"
+
+template <class InIter1, class InIter2, class OutIter>
+void
+test()
+{
+ {
+ unsigned N = 100000;
+ int* ia = new int[N];
+ int* ib = new int[N];
+ int* ic = new int[2*N];
+ for (unsigned i = 0; i < N; ++i)
+ ia[i] = 2*i;
+ for (unsigned i = 0; i < N; ++i)
+ ib[i] = 2*i+1;
+ std::reverse(ia, ia+N);
+ std::reverse(ib, ib+N);
+ binary_counting_predicate<std::greater<int>, int, int> pred((std::greater<int>()));
+ OutIter r = std::merge(InIter1(ia), InIter1(ia+N),
+ InIter2(ib), InIter2(ib+N), OutIter(ic), pred);
+ assert(base(r) == ic+2*N);
+ assert(ic[0] == 2*N-1);
+ assert(ic[2*N-1] == 0);
+ assert(std::is_sorted(ic, ic+2*N, std::greater<int>()));
+ assert(pred.count() <= (N + N - 1));
+ delete [] ic;
+ delete [] ib;
+ delete [] ia;
+ }
+ {
+ unsigned N = 100;
+ int* ia = new int[N];
+ int* ib = new int[N];
+ int* ic = new int[2*N];
+ for (unsigned i = 0; i < 2*N; ++i)
+ ic[i] = i;
+ std::random_shuffle(ic, ic+2*N);
+ std::copy(ic, ic+N, ia);
+ std::copy(ic+N, ic+2*N, ib);
+ std::sort(ia, ia+N, std::greater<int>());
+ std::sort(ib, ib+N, std::greater<int>());
+ binary_counting_predicate<std::greater<int>, int, int> pred((std::greater<int>()));
+ OutIter r = std::merge(InIter1(ia), InIter1(ia+N),
+ InIter2(ib), InIter2(ib+N), OutIter(ic), pred);
+ assert(base(r) == ic+2*N);
+ assert(ic[0] == 2*N-1);
+ assert(ic[2*N-1] == 0);
+ assert(std::is_sorted(ic, ic+2*N, std::greater<int>()));
+ assert(pred.count() <= (N + N - 1));
+ delete [] ic;
+ delete [] ib;
+ delete [] ia;
+ }
+}
+
+int main()
+{
+ test<input_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+ test<input_iterator<const int*>, input_iterator<const int*>, forward_iterator<int*> >();
+ test<input_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<input_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+ test<input_iterator<const int*>, input_iterator<const int*>, int*>();
+
+ test<input_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+ test<input_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+ test<input_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<input_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+ test<input_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+ test<input_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+ test<input_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+ test<input_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<input_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+ test<input_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+ test<input_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+ test<input_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+ test<input_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<input_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+ test<input_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+ test<input_iterator<const int*>, const int*, output_iterator<int*> >();
+ test<input_iterator<const int*>, const int*, forward_iterator<int*> >();
+ test<input_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+ test<input_iterator<const int*>, const int*, random_access_iterator<int*> >();
+ test<input_iterator<const int*>, const int*, int*>();
+
+ test<forward_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+ test<forward_iterator<const int*>, input_iterator<const int*>, forward_iterator<int*> >();
+ test<forward_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<forward_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+ test<forward_iterator<const int*>, input_iterator<const int*>, int*>();
+
+ test<forward_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+ test<forward_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+ test<forward_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<forward_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+ test<forward_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+ test<forward_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+ test<forward_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+ test<forward_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<forward_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+ test<forward_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+ test<forward_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+ test<forward_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+ test<forward_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<forward_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+ test<forward_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+ test<forward_iterator<const int*>, const int*, output_iterator<int*> >();
+ test<forward_iterator<const int*>, const int*, forward_iterator<int*> >();
+ test<forward_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+ test<forward_iterator<const int*>, const int*, random_access_iterator<int*> >();
+ test<forward_iterator<const int*>, const int*, int*>();
+
+ test<bidirectional_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, input_iterator<const int*>, int*>();
+
+ test<bidirectional_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+ test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+ test<bidirectional_iterator<const int*>, const int*, output_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, const int*, forward_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, const int*, random_access_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, const int*, int*>();
+
+ test<random_access_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+ test<random_access_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+ test<random_access_iterator<const int*>, input_iterator<const int*>, int*>();
+
+ test<random_access_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+ test<random_access_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+ test<random_access_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+ test<random_access_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+ test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+ test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+ test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+ test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+ test<random_access_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+ test<random_access_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+ test<random_access_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+ test<random_access_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+ test<random_access_iterator<const int*>, const int*, output_iterator<int*> >();
+ test<random_access_iterator<const int*>, const int*, forward_iterator<int*> >();
+ test<random_access_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, const int*, random_access_iterator<int*> >();
+ test<random_access_iterator<const int*>, const int*, int*>();
+
+ test<const int*, input_iterator<const int*>, output_iterator<int*> >();
+ test<const int*, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<const int*, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<const int*, input_iterator<const int*>, random_access_iterator<int*> >();
+ test<const int*, input_iterator<const int*>, int*>();
+
+ test<const int*, forward_iterator<const int*>, output_iterator<int*> >();
+ test<const int*, forward_iterator<const int*>, forward_iterator<int*> >();
+ test<const int*, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<const int*, forward_iterator<const int*>, random_access_iterator<int*> >();
+ test<const int*, forward_iterator<const int*>, int*>();
+
+ test<const int*, bidirectional_iterator<const int*>, output_iterator<int*> >();
+ test<const int*, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+ test<const int*, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<const int*, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+ test<const int*, bidirectional_iterator<const int*>, int*>();
+
+ test<const int*, random_access_iterator<const int*>, output_iterator<int*> >();
+ test<const int*, random_access_iterator<const int*>, forward_iterator<int*> >();
+ test<const int*, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<const int*, random_access_iterator<const int*>, random_access_iterator<int*> >();
+ test<const int*, random_access_iterator<const int*>, int*>();
+
+ test<const int*, const int*, output_iterator<int*> >();
+ test<const int*, const int*, forward_iterator<int*> >();
+ test<const int*, const int*, bidirectional_iterator<int*> >();
+ test<const int*, const int*, random_access_iterator<int*> >();
+ test<const int*, const int*, int*>();
+}
diff --git a/test/std/algorithms/alg.sorting/alg.min.max/max.pass.cpp b/test/std/algorithms/alg.sorting/alg.min.max/max.pass.cpp
new file mode 100644
index 000000000000..c560c22f2d72
--- /dev/null
+++ b/test/std/algorithms/alg.sorting/alg.min.max/max.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<LessThanComparable T>
+// const T&
+// max(const T& a, const T& b);
+
+#include <algorithm>
+#include <cassert>
+
+template <class T>
+void
+test(const T& a, const T& b, const T& x)
+{
+ assert(&std::max(a, b) == &x);
+}
+
+int main()
+{
+ {
+ int x = 0;
+ int y = 0;
+ test(x, y, x);
+ test(y, x, y);
+ }
+ {
+ int x = 0;
+ int y = 1;
+ test(x, y, y);
+ test(y, x, y);
+ }
+ {
+ int x = 1;
+ int y = 0;
+ test(x, y, x);
+ test(y, x, x);
+ }
+#if _LIBCPP_STD_VER > 11
+ {
+ constexpr int x = 1;
+ constexpr int y = 0;
+ static_assert(std::max(x, y) == x, "" );
+ static_assert(std::max(y, x) == x, "" );
+ }
+#endif
+}
diff --git a/test/std/algorithms/alg.sorting/alg.min.max/max_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.min.max/max_comp.pass.cpp
new file mode 100644
index 000000000000..95241af50063
--- /dev/null
+++ b/test/std/algorithms/alg.sorting/alg.min.max/max_comp.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<class T, StrictWeakOrder<auto, T> Compare>
+// requires !SameType<T, Compare> && CopyConstructible<Compare>
+// const T&
+// max(const T& a, const T& b, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+template <class T, class C>
+void
+test(const T& a, const T& b, C c, const T& x)
+{
+ assert(&std::max(a, b, c) == &x);
+}
+
+int main()
+{
+ {
+ int x = 0;
+ int y = 0;
+ test(x, y, std::greater<int>(), x);
+ test(y, x, std::greater<int>(), y);
+ }
+ {
+ int x = 0;
+ int y = 1;
+ test(x, y, std::greater<int>(), x);
+ test(y, x, std::greater<int>(), x);
+ }
+ {
+ int x = 1;
+ int y = 0;
+ test(x, y, std::greater<int>(), y);
+ test(y, x, std::greater<int>(), y);
+ }
+#if _LIBCPP_STD_VER > 11
+ {
+ constexpr int x = 1;
+ constexpr int y = 0;
+ static_assert(std::max(x, y, std::greater<int>()) == y, "" );
+ static_assert(std::max(y, x, std::greater<int>()) == y, "" );
+ }
+#endif
+}
diff --git a/test/std/algorithms/alg.sorting/alg.min.max/max_element.pass.cpp b/test/std/algorithms/alg.sorting/alg.min.max/max_element.pass.cpp
new file mode 100644
index 000000000000..2197b97d7f2a
--- /dev/null
+++ b/test/std/algorithms/alg.sorting/alg.min.max/max_element.pass.cpp
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter>
+// requires LessThanComparable<Iter::value_type>
+// Iter
+// max_element(Iter first, Iter last);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter>
+void
+test(Iter first, Iter last)
+{
+ Iter i = std::max_element(first, last);
+ if (first != last)
+ {
+ for (Iter j = first; j != last; ++j)
+ assert(!(*i < *j));
+ }
+ else
+ assert(i == last);
+}
+
+template <class Iter>
+void
+test(unsigned N)
+{
+ int* a = new int[N];
+ for (int i = 0; i < N; ++i)
+ a[i] = i;
+ std::random_shuffle(a, a+N);
+ test(Iter(a), Iter(a+N));
+ delete [] a;
+}
+
+template <class Iter>
+void
+test()
+{
+ test<Iter>(0);
+ test<Iter>(1);
+ test<Iter>(2);
+ test<Iter>(3);
+ test<Iter>(10);
+ test<Iter>(1000);
+}
+
+#if __cplusplus >= 201402L
+constexpr int il[] = { 2, 4, 6, 8, 7, 5, 3, 1 };
+#endif
+
+void constexpr_test()
+{
+#if __cplusplus >= 201402L
+ constexpr auto p = std::max_element(il,il+8);
+ static_assert ( *p == 8, "" );
+#endif
+}
+
+int main()
+{
+ test<forward_iterator<const int*> >();
+ test<bidirectional_iterator<const int*> >();
+ test<random_access_iterator<const int*> >();
+ test<const int*>();
+
+ constexpr_test ();
+}
diff --git a/test/std/algorithms/alg.sorting/alg.min.max/max_element_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.min.max/max_element_comp.pass.cpp
new file mode 100644
index 000000000000..37c181393aa6
--- /dev/null
+++ b/test/std/algorithms/alg.sorting/alg.min.max/max_element_comp.pass.cpp
@@ -0,0 +1,100 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter, StrictWeakOrder<auto, Iter::value_type> Compare>
+// requires CopyConstructible<Compare>
+// Iter
+// max_element(Iter first, Iter last, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter>
+void
+test(Iter first, Iter last)
+{
+ Iter i = std::max_element(first, last, std::greater<int>());
+ if (first != last)
+ {
+ for (Iter j = first; j != last; ++j)
+ assert(!std::greater<int>()(*i, *j));
+ }
+ else
+ assert(i == last);
+}
+
+template <class Iter>
+void
+test(unsigned N)
+{
+ int* a = new int[N];
+ for (int i = 0; i < N; ++i)
+ a[i] = i;
+ std::random_shuffle(a, a+N);
+ test(Iter(a), Iter(a+N));
+ delete [] a;
+}
+
+template <class Iter>
+void
+test()
+{
+ test<Iter>(0);
+ test<Iter>(1);
+ test<Iter>(2);
+ test<Iter>(3);
+ test<Iter>(10);
+ test<Iter>(1000);
+}
+
+template <class Iter, class Pred>
+void test_eq0(Iter first, Iter last, Pred p)
+{
+ assert(first == std::max_element(first, last, p));
+}
+
+void test_eq()
+{
+ const size_t N = 10;
+ int* a = new int[N];
+ for (int i = 0; i < N; ++i)
+ a[i] = 10; // all the same
+ test_eq0(a, a+N, std::less<int>());
+ test_eq0(a, a+N, std::greater<int>());
+ delete [] a;
+}
+
+#if __cplusplus >= 201402L
+constexpr int il[] = { 2, 4, 6, 8, 7, 5, 3, 1 };
+struct less { constexpr bool operator ()( const int &x, const int &y) const { return x < y; }};
+#endif
+
+void constexpr_test()
+{
+#if __cplusplus >= 201402L
+ constexpr auto p = std::max_element(il, il+8, less());
+ static_assert ( *p == 8, "" );
+#endif
+}
+
+int main()
+{
+ test<forward_iterator<const int*> >();
+ test<bidirectional_iterator<const int*> >();
+ test<random_access_iterator<const int*> >();
+ test<const int*>();
+ test_eq();
+
+ constexpr_test();
+}
diff --git a/test/std/algorithms/alg.sorting/alg.min.max/max_init_list.pass.cpp b/test/std/algorithms/alg.sorting/alg.min.max/max_init_list.pass.cpp
new file mode 100644
index 000000000000..0438412d236e
--- /dev/null
+++ b/test/std/algorithms/alg.sorting/alg.min.max/max_init_list.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template <class T>
+// T
+// max(initializer_list<T> t);
+
+#include <algorithm>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ int i = std::max({2, 3, 1});
+ assert(i == 3);
+ i = std::max({2, 1, 3});
+ assert(i == 3);
+ i = std::max({3, 1, 2});
+ assert(i == 3);
+ i = std::max({3, 2, 1});
+ assert(i == 3);
+ i = std::max({1, 2, 3});
+ assert(i == 3);
+ i = std::max({1, 3, 2});
+ assert(i == 3);
+#if _LIBCPP_STD_VER > 11
+ {
+ static_assert(std::max({1, 3, 2}) == 3, "");
+ static_assert(std::max({2, 1, 3}) == 3, "");
+ static_assert(std::max({3, 2, 1}) == 3, "");
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/algorithms/alg.sorting/alg.min.max/max_init_list_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.min.max/max_init_list_comp.pass.cpp
new file mode 100644
index 000000000000..4dd47a73ef3b
--- /dev/null
+++ b/test/std/algorithms/alg.sorting/alg.min.max/max_init_list_comp.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<class T, class Compare>
+// T
+// max(initializer_list<T> t, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ int i = std::max({2, 3, 1}, std::greater<int>());
+ assert(i == 1);
+ i = std::max({2, 1, 3}, std::greater<int>());
+ assert(i == 1);
+ i = std::max({3, 1, 2}, std::greater<int>());
+ assert(i == 1);
+ i = std::max({3, 2, 1}, std::greater<int>());
+ assert(i == 1);
+ i = std::max({1, 2, 3}, std::greater<int>());
+ assert(i == 1);
+ i = std::max({1, 3, 2}, std::greater<int>());
+ assert(i == 1);
+#if _LIBCPP_STD_VER > 11
+ {
+ static_assert(std::max({1, 3, 2}, std::greater<int>()) == 1, "");
+ static_assert(std::max({2, 1, 3}, std::greater<int>()) == 1, "");
+ static_assert(std::max({3, 2, 1}, std::greater<int>()) == 1, "");
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/algorithms/alg.sorting/alg.min.max/min.pass.cpp b/test/std/algorithms/alg.sorting/alg.min.max/min.pass.cpp
new file mode 100644
index 000000000000..bbbd97bc5a4a
--- /dev/null
+++ b/test/std/algorithms/alg.sorting/alg.min.max/min.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<LessThanComparable T>
+// const T&
+// min(const T& a, const T& b);
+
+#include <algorithm>
+#include <cassert>
+
+template <class T>
+void
+test(const T& a, const T& b, const T& x)
+{
+ assert(&std::min(a, b) == &x);
+}
+
+int main()
+{
+ {
+ int x = 0;
+ int y = 0;
+ test(x, y, x);
+ test(y, x, y);
+ }
+ {
+ int x = 0;
+ int y = 1;
+ test(x, y, x);
+ test(y, x, x);
+ }
+ {
+ int x = 1;
+ int y = 0;
+ test(x, y, y);
+ test(y, x, y);
+ }
+#if _LIBCPP_STD_VER > 11
+ {
+ constexpr int x = 1;
+ constexpr int y = 0;
+ static_assert(std::min(x, y) == y, "" );
+ static_assert(std::min(y, x) == y, "" );
+ }
+#endif
+}
diff --git a/test/std/algorithms/alg.sorting/alg.min.max/min_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.min.max/min_comp.pass.cpp
new file mode 100644
index 000000000000..4ef705e77718
--- /dev/null
+++ b/test/std/algorithms/alg.sorting/alg.min.max/min_comp.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<class T, StrictWeakOrder<auto, T> Compare>
+// requires !SameType<T, Compare> && CopyConstructible<Compare>
+// const T&
+// min(const T& a, const T& b, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+template <class T, class C>
+void
+test(const T& a, const T& b, C c, const T& x)
+{
+ assert(&std::min(a, b, c) == &x);
+}
+
+int main()
+{
+ {
+ int x = 0;
+ int y = 0;
+ test(x, y, std::greater<int>(), x);
+ test(y, x, std::greater<int>(), y);
+ }
+ {
+ int x = 0;
+ int y = 1;
+ test(x, y, std::greater<int>(), y);
+ test(y, x, std::greater<int>(), y);
+ }
+ {
+ int x = 1;
+ int y = 0;
+ test(x, y, std::greater<int>(), x);
+ test(y, x, std::greater<int>(), x);
+ }
+#if _LIBCPP_STD_VER > 11
+ {
+ constexpr int x = 1;
+ constexpr int y = 0;
+ static_assert(std::min(x, y, std::greater<int>()) == x, "" );
+ static_assert(std::min(y, x, std::greater<int>()) == x, "" );
+ }
+#endif
+}
diff --git a/test/std/algorithms/alg.sorting/alg.min.max/min_element.pass.cpp b/test/std/algorithms/alg.sorting/alg.min.max/min_element.pass.cpp
new file mode 100644
index 000000000000..a9a9d61340f9
--- /dev/null
+++ b/test/std/algorithms/alg.sorting/alg.min.max/min_element.pass.cpp
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter>
+// requires LessThanComparable<Iter::value_type>
+// Iter
+// min_element(Iter first, Iter last);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter>
+void
+test(Iter first, Iter last)
+{
+ Iter i = std::min_element(first, last);
+ if (first != last)
+ {
+ for (Iter j = first; j != last; ++j)
+ assert(!(*j < *i));
+ }
+ else
+ assert(i == last);
+}
+
+template <class Iter>
+void
+test(unsigned N)
+{
+ int* a = new int[N];
+ for (int i = 0; i < N; ++i)
+ a[i] = i;
+ std::random_shuffle(a, a+N);
+ test(Iter(a), Iter(a+N));
+ delete [] a;
+}
+
+template <class Iter>
+void
+test()
+{
+ test<Iter>(0);
+ test<Iter>(1);
+ test<Iter>(2);
+ test<Iter>(3);
+ test<Iter>(10);
+ test<Iter>(1000);
+}
+
+#if __cplusplus >= 201402L
+constexpr int il[] = { 2, 4, 6, 8, 7, 5, 3, 1 };
+#endif
+
+void constexpr_test()
+{
+#if __cplusplus >= 201402L
+ constexpr auto p = std::min_element(il, il+8);
+ static_assert ( *p == 1, "" );
+#endif
+}
+
+int main()
+{
+ test<forward_iterator<const int*> >();
+ test<bidirectional_iterator<const int*> >();
+ test<random_access_iterator<const int*> >();
+ test<const int*>();
+
+ constexpr_test();
+}
diff --git a/test/std/algorithms/alg.sorting/alg.min.max/min_element_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.min.max/min_element_comp.pass.cpp
new file mode 100644
index 000000000000..9517f7eac945
--- /dev/null
+++ b/test/std/algorithms/alg.sorting/alg.min.max/min_element_comp.pass.cpp
@@ -0,0 +1,100 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter, StrictWeakOrder<auto, Iter::value_type> Compare>
+// requires CopyConstructible<Compare>
+// Iter
+// min_element(Iter first, Iter last, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter>
+void
+test(Iter first, Iter last)
+{
+ Iter i = std::min_element(first, last, std::greater<int>());
+ if (first != last)
+ {
+ for (Iter j = first; j != last; ++j)
+ assert(!std::greater<int>()(*j, *i));
+ }
+ else
+ assert(i == last);
+}
+
+template <class Iter>
+void
+test(unsigned N)
+{
+ int* a = new int[N];
+ for (int i = 0; i < N; ++i)
+ a[i] = i;
+ std::random_shuffle(a, a+N);
+ test(Iter(a), Iter(a+N));
+ delete [] a;
+}
+
+template <class Iter>
+void
+test()
+{
+ test<Iter>(0);
+ test<Iter>(1);
+ test<Iter>(2);
+ test<Iter>(3);
+ test<Iter>(10);
+ test<Iter>(1000);
+}
+
+template <class Iter, class Pred>
+void test_eq0(Iter first, Iter last, Pred p)
+{
+ assert(first == std::min_element(first, last, p));
+}
+
+void test_eq()
+{
+ const size_t N = 10;
+ int* a = new int[N];
+ for (int i = 0; i < N; ++i)
+ a[i] = 10; // all the same
+ test_eq0(a, a+N, std::less<int>());
+ test_eq0(a, a+N, std::greater<int>());
+ delete [] a;
+}
+
+#if __cplusplus >= 201402L
+constexpr int il[] = { 2, 4, 6, 8, 7, 5, 3, 1 };
+struct less { constexpr bool operator ()( const int &x, const int &y) const { return x < y; }};
+#endif
+
+void constexpr_test()
+{
+#if __cplusplus >= 201402L
+ constexpr auto p = std::min_element(il, il+8, less());
+ static_assert(*p == 1, "");
+#endif
+}
+
+int main()
+{
+ test<forward_iterator<const int*> >();
+ test<bidirectional_iterator<const int*> >();
+ test<random_access_iterator<const int*> >();
+ test<const int*>();
+ test_eq();
+
+ constexpr_test();
+}
diff --git a/test/std/algorithms/alg.sorting/alg.min.max/min_init_list.pass.cpp b/test/std/algorithms/alg.sorting/alg.min.max/min_init_list.pass.cpp
new file mode 100644
index 000000000000..eed4ebd45756
--- /dev/null
+++ b/test/std/algorithms/alg.sorting/alg.min.max/min_init_list.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<class T>
+// T
+// min(initializer_list<T> t);
+
+#include <algorithm>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ int i = std::min({2, 3, 1});
+ assert(i == 1);
+ i = std::min({2, 1, 3});
+ assert(i == 1);
+ i = std::min({3, 1, 2});
+ assert(i == 1);
+ i = std::min({3, 2, 1});
+ assert(i == 1);
+ i = std::min({1, 2, 3});
+ assert(i == 1);
+ i = std::min({1, 3, 2});
+ assert(i == 1);
+#if _LIBCPP_STD_VER > 11
+ {
+ static_assert(std::min({1, 3, 2}) == 1, "");
+ static_assert(std::min({2, 1, 3}) == 1, "");
+ static_assert(std::min({3, 2, 1}) == 1, "");
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/algorithms/alg.sorting/alg.min.max/min_init_list_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.min.max/min_init_list_comp.pass.cpp
new file mode 100644
index 000000000000..5e0301b657b9
--- /dev/null
+++ b/test/std/algorithms/alg.sorting/alg.min.max/min_init_list_comp.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<class T, class Compare>
+// T
+// min(initializer_list<T> t, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ int i = std::min({2, 3, 1}, std::greater<int>());
+ assert(i == 3);
+ i = std::min({2, 1, 3}, std::greater<int>());
+ assert(i == 3);
+ i = std::min({3, 1, 2}, std::greater<int>());
+ assert(i == 3);
+ i = std::min({3, 2, 1}, std::greater<int>());
+ assert(i == 3);
+ i = std::min({1, 2, 3}, std::greater<int>());
+ assert(i == 3);
+ i = std::min({1, 3, 2}, std::greater<int>());
+ assert(i == 3);
+#if _LIBCPP_STD_VER > 11
+ {
+ static_assert(std::min({1, 3, 2}, std::greater<int>()) == 3, "");
+ static_assert(std::min({2, 1, 3}, std::greater<int>()) == 3, "");
+ static_assert(std::min({3, 2, 1}, std::greater<int>()) == 3, "");
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/algorithms/alg.sorting/alg.min.max/minmax.pass.cpp b/test/std/algorithms/alg.sorting/alg.min.max/minmax.pass.cpp
new file mode 100644
index 000000000000..6ac972a2547b
--- /dev/null
+++ b/test/std/algorithms/alg.sorting/alg.min.max/minmax.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<LessThanComparable T>
+// pair<const T&, const T&>
+// minmax(const T& a, const T& b);
+
+#include <algorithm>
+#include <cassert>
+
+template <class T>
+void
+test(const T& a, const T& b, const T& x, const T& y)
+{
+ std::pair<const T&, const T&> p = std::minmax(a, b);
+ assert(&p.first == &x);
+ assert(&p.second == &y);
+}
+
+int main()
+{
+ {
+ int x = 0;
+ int y = 0;
+ test(x, y, x, y);
+ test(y, x, y, x);
+ }
+ {
+ int x = 0;
+ int y = 1;
+ test(x, y, x, y);
+ test(y, x, x, y);
+ }
+ {
+ int x = 1;
+ int y = 0;
+ test(x, y, y, x);
+ test(y, x, y, x);
+ }
+#if _LIBCPP_STD_VER > 11
+ {
+// Note that you can't take a reference to a local var, since
+// its address is not a compile-time constant.
+ constexpr static int x = 1;
+ constexpr static int y = 0;
+ constexpr auto p1 = std::minmax (x, y);
+ static_assert(p1.first == y, "");
+ static_assert(p1.second == x, "");
+ constexpr auto p2 = std::minmax (y, x);
+ static_assert(p2.first == y, "");
+ static_assert(p2.second == x, "");
+ }
+#endif
+}
diff --git a/test/std/algorithms/alg.sorting/alg.min.max/minmax_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.min.max/minmax_comp.pass.cpp
new file mode 100644
index 000000000000..771c8f84a740
--- /dev/null
+++ b/test/std/algorithms/alg.sorting/alg.min.max/minmax_comp.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<class T, StrictWeakOrder<auto, T> Compare>
+// requires !SameType<T, Compare> && CopyConstructible<Compare>
+// pair<const T&, const T&>
+// minmax(const T& a, const T& b, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+template <class T, class C>
+void
+test(const T& a, const T& b, C c, const T& x, const T& y)
+{
+ std::pair<const T&, const T&> p = std::minmax(a, b, c);
+ assert(&p.first == &x);
+ assert(&p.second == &y);
+}
+
+
+int main()
+{
+ {
+ int x = 0;
+ int y = 0;
+ test(x, y, std::greater<int>(), x, y);
+ test(y, x, std::greater<int>(), y, x);
+ }
+ {
+ int x = 0;
+ int y = 1;
+ test(x, y, std::greater<int>(), y, x);
+ test(y, x, std::greater<int>(), y, x);
+ }
+ {
+ int x = 1;
+ int y = 0;
+ test(x, y, std::greater<int>(), x, y);
+ test(y, x, std::greater<int>(), x, y);
+ }
+#if _LIBCPP_STD_VER > 11
+ {
+// Note that you can't take a reference to a local var, since
+// its address is not a compile-time constant.
+ constexpr static int x = 1;
+ constexpr static int y = 0;
+ constexpr auto p1 = std::minmax(x, y, std::greater<>());
+ static_assert(p1.first == x, "");
+ static_assert(p1.second == y, "");
+ constexpr auto p2 = std::minmax(y, x, std::greater<>());
+ static_assert(p2.first == x, "");
+ static_assert(p2.second == y, "");
+ }
+#endif
+}
diff --git a/test/std/algorithms/alg.sorting/alg.min.max/minmax_element.pass.cpp b/test/std/algorithms/alg.sorting/alg.min.max/minmax_element.pass.cpp
new file mode 100644
index 000000000000..915b1d176ab4
--- /dev/null
+++ b/test/std/algorithms/alg.sorting/alg.min.max/minmax_element.pass.cpp
@@ -0,0 +1,98 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter>
+// requires LessThanComparable<Iter::value_type>
+// pair<Iter, Iter>
+// minmax_element(Iter first, Iter last);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter>
+void
+test(Iter first, Iter last)
+{
+ std::pair<Iter, Iter> p = std::minmax_element(first, last);
+ if (first != last)
+ {
+ for (Iter j = first; j != last; ++j)
+ {
+ assert(!(*j < *p.first));
+ assert(!(*p.second < *j));
+ }
+ }
+ else
+ {
+ assert(p.first == last);
+ assert(p.second == last);
+ }
+}
+
+template <class Iter>
+void
+test(unsigned N)
+{
+ int* a = new int[N];
+ for (int i = 0; i < N; ++i)
+ a[i] = i;
+ std::random_shuffle(a, a+N);
+ test(Iter(a), Iter(a+N));
+ delete [] a;
+}
+
+template <class Iter>
+void
+test()
+{
+ test<Iter>(0);
+ test<Iter>(1);
+ test<Iter>(2);
+ test<Iter>(3);
+ test<Iter>(10);
+ test<Iter>(1000);
+ {
+ const unsigned N = 100;
+ int* a = new int[N];
+ for (int i = 0; i < N; ++i)
+ a[i] = 5;
+ std::random_shuffle(a, a+N);
+ std::pair<Iter, Iter> p = std::minmax_element(Iter(a), Iter(a+N));
+ assert(base(p.first) == a);
+ assert(base(p.second) == a+N-1);
+ delete [] a;
+ }
+}
+
+#if __cplusplus >= 201402L
+constexpr int il[] = { 2, 4, 6, 8, 7, 5, 3, 1 };
+#endif
+
+void constexpr_test()
+{
+#if __cplusplus >= 201402L
+ constexpr auto p = std::minmax_element(il, il+8);
+ static_assert ( *(p.first) == 1, "" );
+ static_assert ( *(p.second) == 8, "" );
+#endif
+}
+
+int main()
+{
+ test<forward_iterator<const int*> >();
+ test<bidirectional_iterator<const int*> >();
+ test<random_access_iterator<const int*> >();
+ test<const int*>();
+
+ constexpr_test();
+}
diff --git a/test/std/algorithms/alg.sorting/alg.min.max/minmax_element_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.min.max/minmax_element_comp.pass.cpp
new file mode 100644
index 000000000000..d3a067fda3c5
--- /dev/null
+++ b/test/std/algorithms/alg.sorting/alg.min.max/minmax_element_comp.pass.cpp
@@ -0,0 +1,104 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter, StrictWeakOrder<auto, Iter::value_type> Compare>
+// requires CopyConstructible<Compare>
+// pair<Iter, Iter>
+// minmax_element(Iter first, Iter last, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter>
+void
+test(Iter first, Iter last)
+{
+ typedef std::greater<int> Compare;
+ Compare comp;
+ std::pair<Iter, Iter> p = std::minmax_element(first, last, comp);
+ if (first != last)
+ {
+ for (Iter j = first; j != last; ++j)
+ {
+ assert(!comp(*j, *p.first));
+ assert(!comp(*p.second, *j));
+ }
+ }
+ else
+ {
+ assert(p.first == last);
+ assert(p.second == last);
+ }
+}
+
+template <class Iter>
+void
+test(unsigned N)
+{
+ int* a = new int[N];
+ for (int i = 0; i < N; ++i)
+ a[i] = i;
+ std::random_shuffle(a, a+N);
+ test(Iter(a), Iter(a+N));
+ delete [] a;
+}
+
+template <class Iter>
+void
+test()
+{
+ test<Iter>(0);
+ test<Iter>(1);
+ test<Iter>(2);
+ test<Iter>(3);
+ test<Iter>(10);
+ test<Iter>(1000);
+ {
+ const unsigned N = 100;
+ int* a = new int[N];
+ for (int i = 0; i < N; ++i)
+ a[i] = 5;
+ std::random_shuffle(a, a+N);
+ typedef std::greater<int> Compare;
+ Compare comp;
+ std::pair<Iter, Iter> p = std::minmax_element(Iter(a), Iter(a+N), comp);
+ assert(base(p.first) == a);
+ assert(base(p.second) == a+N-1);
+ delete [] a;
+ }
+}
+
+#if __cplusplus >= 201402L
+constexpr int il[] = { 2, 4, 6, 8, 7, 5, 3, 1 };
+struct less { constexpr bool operator ()( const int &x, const int &y) const { return x < y; }};
+#endif
+
+void constexpr_test()
+{
+#if __cplusplus >= 201402L
+ constexpr auto p = std::minmax_element(il, il+8, less());
+ static_assert ( *(p.first) == 1, "" );
+ static_assert ( *(p.second) == 8, "" );
+#endif
+}
+
+int main()
+{
+ test<forward_iterator<const int*> >();
+ test<bidirectional_iterator<const int*> >();
+ test<random_access_iterator<const int*> >();
+ test<const int*>();
+
+ constexpr_test();
+}
diff --git a/test/std/algorithms/alg.sorting/alg.min.max/minmax_init_list.pass.cpp b/test/std/algorithms/alg.sorting/alg.min.max/minmax_init_list.pass.cpp
new file mode 100644
index 000000000000..0196d10dcd96
--- /dev/null
+++ b/test/std/algorithms/alg.sorting/alg.min.max/minmax_init_list.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<class T>
+// pair<T, T>
+// minmax(initializer_list<T> t);
+
+#include <algorithm>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ assert((std::minmax({1, 2, 3}) == std::pair<int, int>(1, 3)));
+ assert((std::minmax({1, 3, 2}) == std::pair<int, int>(1, 3)));
+ assert((std::minmax({2, 1, 3}) == std::pair<int, int>(1, 3)));
+ assert((std::minmax({2, 3, 1}) == std::pair<int, int>(1, 3)));
+ assert((std::minmax({3, 1, 2}) == std::pair<int, int>(1, 3)));
+ assert((std::minmax({3, 2, 1}) == std::pair<int, int>(1, 3)));
+#if _LIBCPP_STD_VER > 11
+ {
+ static_assert((std::minmax({1, 2, 3}) == std::pair<int, int>(1, 3)), "");
+ static_assert((std::minmax({1, 3, 2}) == std::pair<int, int>(1, 3)), "");
+ static_assert((std::minmax({2, 1, 3}) == std::pair<int, int>(1, 3)), "");
+ static_assert((std::minmax({2, 3, 1}) == std::pair<int, int>(1, 3)), "");
+ static_assert((std::minmax({3, 1, 2}) == std::pair<int, int>(1, 3)), "");
+ static_assert((std::minmax({3, 2, 1}) == std::pair<int, int>(1, 3)), "");
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/algorithms/alg.sorting/alg.min.max/minmax_init_list_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.min.max/minmax_init_list_comp.pass.cpp
new file mode 100644
index 000000000000..a66b2ff27cb0
--- /dev/null
+++ b/test/std/algorithms/alg.sorting/alg.min.max/minmax_init_list_comp.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<class T, class Compare>
+// pair<T, T>
+// minmax(initializer_list<T> t, Compare comp);
+//
+// Complexity: At most (3/2) * t.size() applications of the corresponding predicate.
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "counting_predicates.hpp"
+
+bool all_equal(int a, int b) { return false; } // everything is equal
+
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+void test_all_equal(std::initializer_list<int> il)
+{
+ binary_counting_predicate<bool(*)(int, int), int, int> pred (all_equal);
+ std::pair<int, int> p = std::minmax(il, std::ref(pred));
+ const int *ptr = il.end();
+ assert(p.first == *il.begin());
+ assert(p.second == *--ptr);
+ assert(pred.count() <= ((3 * il.size()) / 2));
+}
+#endif
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ assert((std::minmax({1, 2, 3}, std::greater<int>()) == std::pair<int, int>(3, 1)));
+ assert((std::minmax({1, 3, 2}, std::greater<int>()) == std::pair<int, int>(3, 1)));
+ assert((std::minmax({2, 1, 3}, std::greater<int>()) == std::pair<int, int>(3, 1)));
+ assert((std::minmax({2, 3, 1}, std::greater<int>()) == std::pair<int, int>(3, 1)));
+ assert((std::minmax({3, 1, 2}, std::greater<int>()) == std::pair<int, int>(3, 1)));
+ assert((std::minmax({3, 2, 1}, std::greater<int>()) == std::pair<int, int>(3, 1)));
+ assert((std::minmax({1, 2, 3}, all_equal ) == std::pair<int, int>(1, 3)));
+
+ binary_counting_predicate<std::greater<int>, int, int> pred ((std::greater<int>()));
+ assert((std::minmax({1, 2, 2, 3, 3, 3, 5, 5, 5, 5, 5, 3}, std::ref(pred)) == std::pair<int, int>(5, 1)));
+ assert(pred.count() <= 18); // size == 12
+
+ test_all_equal({0});
+ test_all_equal({0,1});
+ test_all_equal({0,1,2});
+ test_all_equal({0,1,2,3});
+ test_all_equal({0,1,2,3,4});
+ test_all_equal({0,1,2,3,4,5});
+ test_all_equal({0,1,2,3,4,5,6});
+ test_all_equal({0,1,2,3,4,5,6,7});
+ test_all_equal({0,1,2,3,4,5,6,7,8});
+ test_all_equal({0,1,2,3,4,5,6,7,8,9});
+ test_all_equal({0,1,2,3,4,5,6,7,8,9,10});
+ test_all_equal({0,1,2,3,4,5,6,7,8,9,10,11});
+
+#if _LIBCPP_STD_VER > 11
+ {
+ static_assert((std::minmax({1, 2, 3}, std::greater<int>()) == std::pair<int, int>(3, 1)), "");
+ static_assert((std::minmax({1, 3, 2}, std::greater<int>()) == std::pair<int, int>(3, 1)), "");
+ static_assert((std::minmax({2, 1, 3}, std::greater<int>()) == std::pair<int, int>(3, 1)), "");
+ static_assert((std::minmax({2, 3, 1}, std::greater<int>()) == std::pair<int, int>(3, 1)), "");
+ static_assert((std::minmax({3, 1, 2}, std::greater<int>()) == std::pair<int, int>(3, 1)), "");
+ static_assert((std::minmax({3, 2, 1}, std::greater<int>()) == std::pair<int, int>(3, 1)), "");
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/algorithms/alg.sorting/alg.nth.element/nth_element.pass.cpp b/test/std/algorithms/alg.sorting/alg.nth.element/nth_element.pass.cpp
new file mode 100644
index 000000000000..dc5564eb3fc9
--- /dev/null
+++ b/test/std/algorithms/alg.sorting/alg.nth.element/nth_element.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<RandomAccessIterator Iter>
+// requires ShuffleIterator<Iter>
+// && LessThanComparable<Iter::value_type>
+// void
+// nth_element(Iter first, Iter nth, Iter last);
+
+#include <algorithm>
+#include <cassert>
+
+void
+test_one(unsigned N, unsigned M)
+{
+ assert(N != 0);
+ assert(M < N);
+ int* array = new int[N];
+ for (int i = 0; i < N; ++i)
+ array[i] = i;
+ std::random_shuffle(array, array+N);
+ std::nth_element(array, array+M, array+N);
+ assert(array[M] == M);
+ std::nth_element(array, array+N, array+N); // begin, end, end
+ delete [] array;
+}
+
+void
+test(unsigned N)
+{
+ test_one(N, 0);
+ test_one(N, 1);
+ test_one(N, 2);
+ test_one(N, 3);
+ test_one(N, N/2-1);
+ test_one(N, N/2);
+ test_one(N, N/2+1);
+ test_one(N, N-3);
+ test_one(N, N-2);
+ test_one(N, N-1);
+}
+
+int main()
+{
+ int d = 0;
+ std::nth_element(&d, &d, &d);
+ assert(d == 0);
+ test(256);
+ test(257);
+ test(499);
+ test(500);
+ test(997);
+ test(1000);
+ test(1009);
+}
diff --git a/test/std/algorithms/alg.sorting/alg.nth.element/nth_element_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.nth.element/nth_element_comp.pass.cpp
new file mode 100644
index 000000000000..cf8659038f14
--- /dev/null
+++ b/test/std/algorithms/alg.sorting/alg.nth.element/nth_element_comp.pass.cpp
@@ -0,0 +1,86 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<RandomAccessIterator Iter, StrictWeakOrder<auto, Iter::value_type> Compare>
+// requires ShuffleIterator<Iter>
+// && CopyConstructible<Compare>
+// void
+// nth_element(Iter first, Iter nth, Iter last, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <vector>
+#include <cassert>
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#include <memory>
+
+struct indirect_less
+{
+ template <class P>
+ bool operator()(const P& x, const P& y)
+ {return *x < *y;}
+};
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+void
+test_one(unsigned N, unsigned M)
+{
+ assert(N != 0);
+ assert(M < N);
+ int* array = new int[N];
+ for (int i = 0; i < N; ++i)
+ array[i] = i;
+ std::random_shuffle(array, array+N);
+ std::nth_element(array, array+M, array+N, std::greater<int>());
+ assert(array[M] == N-M-1);
+ std::nth_element(array, array+N, array+N, std::greater<int>()); // begin, end, end
+ delete [] array;
+}
+
+void
+test(unsigned N)
+{
+ test_one(N, 0);
+ test_one(N, 1);
+ test_one(N, 2);
+ test_one(N, 3);
+ test_one(N, N/2-1);
+ test_one(N, N/2);
+ test_one(N, N/2+1);
+ test_one(N, N-3);
+ test_one(N, N-2);
+ test_one(N, N-1);
+}
+
+int main()
+{
+ int d = 0;
+ std::nth_element(&d, &d, &d);
+ assert(d == 0);
+ test(256);
+ test(257);
+ test(499);
+ test(500);
+ test(997);
+ test(1000);
+ test(1009);
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::vector<std::unique_ptr<int> > v(1000);
+ for (int i = 0; i < v.size(); ++i)
+ v[i].reset(new int(i));
+ std::nth_element(v.begin(), v.begin() + v.size()/2, v.end(), indirect_less());
+ assert(*v[v.size()/2] == v.size()/2);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/algorithms/alg.sorting/alg.permutation.generators/next_permutation.pass.cpp b/test/std/algorithms/alg.sorting/alg.permutation.generators/next_permutation.pass.cpp
new file mode 100644
index 000000000000..fb58c718c7e5
--- /dev/null
+++ b/test/std/algorithms/alg.sorting/alg.permutation.generators/next_permutation.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<BidirectionalIterator Iter>
+// requires ShuffleIterator<Iter>
+// && LessThanComparable<Iter::value_type>
+// bool
+// next_permutation(Iter first, Iter last);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+#include <cstdio>
+
+int factorial(int x)
+{
+ int r = 1;
+ for (; x; --x)
+ r *= x;
+ return r;
+}
+
+template <class Iter>
+void
+test()
+{
+ int ia[] = {1, 2, 3, 4, 5, 6};
+ const int sa = sizeof(ia)/sizeof(ia[0]);
+ int prev[sa];
+ for (int e = 0; e <= sa; ++e)
+ {
+ int count = 0;
+ bool x;
+ do
+ {
+ std::copy(ia, ia+e, prev);
+ x = std::next_permutation(Iter(ia), Iter(ia+e));
+ if (e > 1)
+ {
+ if (x)
+ assert(std::lexicographical_compare(prev, prev+e, ia, ia+e));
+ else
+ assert(std::lexicographical_compare(ia, ia+e, prev, prev+e));
+ }
+ ++count;
+ } while (x);
+ assert(count == factorial(e));
+ }
+}
+
+int main()
+{
+ test<bidirectional_iterator<int*> >();
+ test<random_access_iterator<int*> >();
+ test<int*>();
+}
diff --git a/test/std/algorithms/alg.sorting/alg.permutation.generators/next_permutation_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.permutation.generators/next_permutation_comp.pass.cpp
new file mode 100644
index 000000000000..8e87e9a4351c
--- /dev/null
+++ b/test/std/algorithms/alg.sorting/alg.permutation.generators/next_permutation_comp.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<BidirectionalIterator Iter, StrictWeakOrder<auto, Iter::value_type> Compare>
+// requires ShuffleIterator<Iter>
+// && CopyConstructible<Compare>
+// bool
+// next_permutation(Iter first, Iter last, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "test_iterators.h"
+
+#include <cstdio>
+
+int factorial(int x)
+{
+ int r = 1;
+ for (; x; --x)
+ r *= x;
+ return r;
+}
+
+template <class Iter>
+void
+test()
+{
+ typedef std::greater<int> C;
+ int ia[] = {6, 5, 4, 3, 2, 1};
+ const int sa = sizeof(ia)/sizeof(ia[0]);
+ int prev[sa];
+ for (int e = 0; e <= sa; ++e)
+ {
+ int count = 0;
+ bool x;
+ do
+ {
+ std::copy(ia, ia+e, prev);
+ x = std::next_permutation(Iter(ia), Iter(ia+e), C());
+ if (e > 1)
+ {
+ if (x)
+ assert(std::lexicographical_compare(prev, prev+e, ia, ia+e, C()));
+ else
+ assert(std::lexicographical_compare(ia, ia+e, prev, prev+e, C()));
+ }
+ ++count;
+ } while (x);
+ assert(count == factorial(e));
+ }
+}
+
+int main()
+{
+ test<bidirectional_iterator<int*> >();
+ test<random_access_iterator<int*> >();
+ test<int*>();
+}
diff --git a/test/std/algorithms/alg.sorting/alg.permutation.generators/prev_permutation.pass.cpp b/test/std/algorithms/alg.sorting/alg.permutation.generators/prev_permutation.pass.cpp
new file mode 100644
index 000000000000..d2fa2cb98b03
--- /dev/null
+++ b/test/std/algorithms/alg.sorting/alg.permutation.generators/prev_permutation.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<BidirectionalIterator Iter>
+// requires ShuffleIterator<Iter>
+// && LessThanComparable<Iter::value_type>
+// bool
+// prev_permutation(Iter first, Iter last);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+#include <cstdio>
+
+int factorial(int x)
+{
+ int r = 1;
+ for (; x; --x)
+ r *= x;
+ return r;
+}
+
+template <class Iter>
+void
+test()
+{
+ int ia[] = {6, 5, 4, 3, 2, 1};
+ const int sa = sizeof(ia)/sizeof(ia[0]);
+ int prev[sa];
+ for (int e = 0; e <= sa; ++e)
+ {
+ int count = 0;
+ bool x;
+ do
+ {
+ std::copy(ia, ia+e, prev);
+ x = std::prev_permutation(Iter(ia), Iter(ia+e));
+ if (e > 1)
+ {
+ if (x)
+ assert(std::lexicographical_compare(ia, ia+e, prev, prev+e));
+ else
+ assert(std::lexicographical_compare(prev, prev+e, ia, ia+e));
+ }
+ ++count;
+ } while (x);
+ assert(count == factorial(e));
+ }
+}
+
+int main()
+{
+ test<bidirectional_iterator<int*> >();
+ test<random_access_iterator<int*> >();
+ test<int*>();
+}
diff --git a/test/std/algorithms/alg.sorting/alg.permutation.generators/prev_permutation_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.permutation.generators/prev_permutation_comp.pass.cpp
new file mode 100644
index 000000000000..51b7aa8c11b8
--- /dev/null
+++ b/test/std/algorithms/alg.sorting/alg.permutation.generators/prev_permutation_comp.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<BidirectionalIterator Iter, StrictWeakOrder<auto, Iter::value_type> Compare>
+// requires ShuffleIterator<Iter>
+// && CopyConstructible<Compare>
+// bool
+// prev_permutation(Iter first, Iter last, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "test_iterators.h"
+
+#include <cstdio>
+
+int factorial(int x)
+{
+ int r = 1;
+ for (; x; --x)
+ r *= x;
+ return r;
+}
+
+template <class Iter>
+void
+test()
+{
+ typedef std::greater<int> C;
+ int ia[] = {1, 2, 3, 4, 5, 6};
+ const int sa = sizeof(ia)/sizeof(ia[0]);
+ int prev[sa];
+ for (int e = 0; e <= sa; ++e)
+ {
+ int count = 0;
+ bool x;
+ do
+ {
+ std::copy(ia, ia+e, prev);
+ x = std::prev_permutation(Iter(ia), Iter(ia+e), C());
+ if (e > 1)
+ {
+ if (x)
+ assert(std::lexicographical_compare(ia, ia+e, prev, prev+e, C()));
+ else
+ assert(std::lexicographical_compare(prev, prev+e, ia, ia+e, C()));
+ }
+ ++count;
+ } while (x);
+ assert(count == factorial(e));
+ }
+}
+
+int main()
+{
+ test<bidirectional_iterator<int*> >();
+ test<random_access_iterator<int*> >();
+ test<int*>();
+}
diff --git a/test/std/algorithms/alg.sorting/alg.set.operations/includes/includes.pass.cpp b/test/std/algorithms/alg.sorting/alg.set.operations/includes/includes.pass.cpp
new file mode 100644
index 000000000000..8db8177fb9c8
--- /dev/null
+++ b/test/std/algorithms/alg.sorting/alg.set.operations/includes/includes.pass.cpp
@@ -0,0 +1,84 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator Iter1, InputIterator Iter2>
+// requires HasLess<Iter1::value_type, Iter2::value_type>
+// && HasLess<Iter2::value_type, Iter1::value_type>
+// bool
+// includes(Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter1, class Iter2>
+void
+test()
+{
+ int ia[] = {1, 2, 2, 3, 3, 3, 4, 4, 4, 4};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ int ib[] = {2, 4};
+ const unsigned sb = sizeof(ib)/sizeof(ib[0]);
+ int ic[] = {1, 2};
+ const unsigned sc = sizeof(ic)/sizeof(ic[0]);
+ int id[] = {3, 3, 3, 3};
+ const unsigned sd = sizeof(id)/sizeof(id[0]);
+
+ assert(std::includes(Iter1(ia), Iter1(ia), Iter2(ib), Iter2(ib)));
+ assert(!std::includes(Iter1(ia), Iter1(ia), Iter2(ib), Iter2(ib+1)));
+ assert(std::includes(Iter1(ia), Iter1(ia+1), Iter2(ib), Iter2(ib)));
+ assert(std::includes(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+sa)));
+
+ assert(std::includes(Iter1(ia), Iter1(ia+sa), Iter2(ib), Iter2(ib+sb)));
+ assert(!std::includes(Iter1(ib), Iter1(ib+sb), Iter2(ia), Iter2(ia+sa)));
+
+ assert(std::includes(Iter1(ia), Iter1(ia+2), Iter2(ic), Iter2(ic+2)));
+ assert(!std::includes(Iter1(ia), Iter1(ia+2), Iter2(ib), Iter2(ib+2)));
+
+ assert(std::includes(Iter1(ia), Iter1(ia+sa), Iter2(id), Iter2(id+1)));
+ assert(std::includes(Iter1(ia), Iter1(ia+sa), Iter2(id), Iter2(id+2)));
+ assert(std::includes(Iter1(ia), Iter1(ia+sa), Iter2(id), Iter2(id+3)));
+ assert(!std::includes(Iter1(ia), Iter1(ia+sa), Iter2(id), Iter2(id+4)));
+}
+
+int main()
+{
+ test<input_iterator<const int*>, input_iterator<const int*> >();
+ test<input_iterator<const int*>, forward_iterator<const int*> >();
+ test<input_iterator<const int*>, bidirectional_iterator<const int*> >();
+ test<input_iterator<const int*>, random_access_iterator<const int*> >();
+ test<input_iterator<const int*>, const int*>();
+
+ test<forward_iterator<const int*>, input_iterator<const int*> >();
+ test<forward_iterator<const int*>, forward_iterator<const int*> >();
+ test<forward_iterator<const int*>, bidirectional_iterator<const int*> >();
+ test<forward_iterator<const int*>, random_access_iterator<const int*> >();
+ test<forward_iterator<const int*>, const int*>();
+
+ test<bidirectional_iterator<const int*>, input_iterator<const int*> >();
+ test<bidirectional_iterator<const int*>, forward_iterator<const int*> >();
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*> >();
+ test<bidirectional_iterator<const int*>, random_access_iterator<const int*> >();
+ test<bidirectional_iterator<const int*>, const int*>();
+
+ test<random_access_iterator<const int*>, input_iterator<const int*> >();
+ test<random_access_iterator<const int*>, forward_iterator<const int*> >();
+ test<random_access_iterator<const int*>, bidirectional_iterator<const int*> >();
+ test<random_access_iterator<const int*>, random_access_iterator<const int*> >();
+ test<random_access_iterator<const int*>, const int*>();
+
+ test<const int*, input_iterator<const int*> >();
+ test<const int*, forward_iterator<const int*> >();
+ test<const int*, bidirectional_iterator<const int*> >();
+ test<const int*, random_access_iterator<const int*> >();
+ test<const int*, const int*>();
+}
diff --git a/test/std/algorithms/alg.sorting/alg.set.operations/includes/includes_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.set.operations/includes/includes_comp.pass.cpp
new file mode 100644
index 000000000000..7e1aef4749a5
--- /dev/null
+++ b/test/std/algorithms/alg.sorting/alg.set.operations/includes/includes_comp.pass.cpp
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator Iter1, InputIterator Iter2, typename Compare>
+// requires Predicate<Compare, Iter1::value_type, Iter2::value_type>
+// && Predicate<Compare, Iter2::value_type, Iter1::value_type>
+// bool
+// includes(Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter1, class Iter2>
+void
+test()
+{
+ int ia[] = {1, 2, 2, 3, 3, 3, 4, 4, 4, 4};
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ int ib[] = {2, 4};
+ const unsigned sb = sizeof(ib)/sizeof(ib[0]);
+ int ic[] = {1, 2};
+ const unsigned sc = sizeof(ic)/sizeof(ic[0]);
+ int id[] = {3, 3, 3, 3};
+ const unsigned sd = sizeof(id)/sizeof(id[0]);
+
+ assert(std::includes(Iter1(ia), Iter1(ia), Iter2(ib), Iter2(ib), std::less<int>()));
+ assert(!std::includes(Iter1(ia), Iter1(ia), Iter2(ib), Iter2(ib+1), std::less<int>()));
+ assert(std::includes(Iter1(ia), Iter1(ia+1), Iter2(ib), Iter2(ib), std::less<int>()));
+ assert(std::includes(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+sa), std::less<int>()));
+
+ assert(std::includes(Iter1(ia), Iter1(ia+sa), Iter2(ib), Iter2(ib+sb), std::less<int>()));
+ assert(!std::includes(Iter1(ib), Iter1(ib+sb), Iter2(ia), Iter2(ia+sa), std::less<int>()));
+
+ assert(std::includes(Iter1(ia), Iter1(ia+2), Iter2(ic), Iter2(ic+2), std::less<int>()));
+ assert(!std::includes(Iter1(ia), Iter1(ia+2), Iter2(ib), Iter2(ib+2), std::less<int>()));
+
+ assert(std::includes(Iter1(ia), Iter1(ia+sa), Iter2(id), Iter2(id+1), std::less<int>()));
+ assert(std::includes(Iter1(ia), Iter1(ia+sa), Iter2(id), Iter2(id+2), std::less<int>()));
+ assert(std::includes(Iter1(ia), Iter1(ia+sa), Iter2(id), Iter2(id+3), std::less<int>()));
+ assert(!std::includes(Iter1(ia), Iter1(ia+sa), Iter2(id), Iter2(id+4), std::less<int>()));
+}
+
+int main()
+{
+ test<input_iterator<const int*>, input_iterator<const int*> >();
+ test<input_iterator<const int*>, forward_iterator<const int*> >();
+ test<input_iterator<const int*>, bidirectional_iterator<const int*> >();
+ test<input_iterator<const int*>, random_access_iterator<const int*> >();
+ test<input_iterator<const int*>, const int*>();
+
+ test<forward_iterator<const int*>, input_iterator<const int*> >();
+ test<forward_iterator<const int*>, forward_iterator<const int*> >();
+ test<forward_iterator<const int*>, bidirectional_iterator<const int*> >();
+ test<forward_iterator<const int*>, random_access_iterator<const int*> >();
+ test<forward_iterator<const int*>, const int*>();
+
+ test<bidirectional_iterator<const int*>, input_iterator<const int*> >();
+ test<bidirectional_iterator<const int*>, forward_iterator<const int*> >();
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*> >();
+ test<bidirectional_iterator<const int*>, random_access_iterator<const int*> >();
+ test<bidirectional_iterator<const int*>, const int*>();
+
+ test<random_access_iterator<const int*>, input_iterator<const int*> >();
+ test<random_access_iterator<const int*>, forward_iterator<const int*> >();
+ test<random_access_iterator<const int*>, bidirectional_iterator<const int*> >();
+ test<random_access_iterator<const int*>, random_access_iterator<const int*> >();
+ test<random_access_iterator<const int*>, const int*>();
+
+ test<const int*, input_iterator<const int*> >();
+ test<const int*, forward_iterator<const int*> >();
+ test<const int*, bidirectional_iterator<const int*> >();
+ test<const int*, random_access_iterator<const int*> >();
+ test<const int*, const int*>();
+}
diff --git a/test/std/algorithms/alg.sorting/alg.set.operations/nothing_to_do.pass.cpp b/test/std/algorithms/alg.sorting/alg.set.operations/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/algorithms/alg.sorting/alg.set.operations/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/algorithms/alg.sorting/alg.set.operations/set.difference/set_difference.pass.cpp b/test/std/algorithms/alg.sorting/alg.set.operations/set.difference/set_difference.pass.cpp
new file mode 100644
index 000000000000..c2c20c295ca4
--- /dev/null
+++ b/test/std/algorithms/alg.sorting/alg.set.operations/set.difference/set_difference.pass.cpp
@@ -0,0 +1,200 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator InIter1, InputIterator InIter2, typename OutIter>
+// requires OutputIterator<OutIter, InIter1::reference>
+// && OutputIterator<OutIter, InIter2::reference>
+// && HasLess<InIter2::value_type, InIter1::value_type>
+// && HasLess<InIter1::value_type, InIter2::value_type>
+// OutIter
+// set_difference(InIter1 first1, InIter1 last1, InIter2 first2, InIter2 last2,
+// OutIter result);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter1, class Iter2, class OutIter>
+void
+test()
+{
+ int ia[] = {1, 2, 2, 3, 3, 3, 4, 4, 4, 4};
+ const int sa = sizeof(ia)/sizeof(ia[0]);
+ int ib[] = {2, 4, 4, 6};
+ const int sb = sizeof(ib)/sizeof(ib[0]);
+ int ic[20];
+ int ir[] = {1, 2, 3, 3, 3, 4, 4};
+ const int sr = sizeof(ir)/sizeof(ir[0]);
+ OutIter ce = std::set_difference(Iter1(ia), Iter1(ia+sa),
+ Iter2(ib), Iter2(ib+sb), OutIter(ic));
+ assert(base(ce) - ic == sr);
+ assert(std::lexicographical_compare(ic, base(ce), ir, ir+sr) == 0);
+ int irr[] = {6};
+ const int srr = sizeof(irr)/sizeof(irr[0]);
+ ce = std::set_difference(Iter1(ib), Iter1(ib+sb),
+ Iter2(ia), Iter2(ia+sa), OutIter(ic));
+ assert(base(ce) - ic == srr);
+ assert(std::lexicographical_compare(ic, base(ce), irr, irr+srr) == 0);
+}
+
+int main()
+{
+ test<input_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+ test<input_iterator<const int*>, input_iterator<const int*>, forward_iterator<int*> >();
+ test<input_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<input_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+ test<input_iterator<const int*>, input_iterator<const int*>, int*>();
+
+ test<input_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+ test<input_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+ test<input_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<input_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+ test<input_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+ test<input_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+ test<input_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+ test<input_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<input_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+ test<input_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+ test<input_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+ test<input_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+ test<input_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<input_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+ test<input_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+ test<input_iterator<const int*>, const int*, output_iterator<int*> >();
+ test<input_iterator<const int*>, const int*, forward_iterator<int*> >();
+ test<input_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+ test<input_iterator<const int*>, const int*, random_access_iterator<int*> >();
+ test<input_iterator<const int*>, const int*, int*>();
+
+ test<forward_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+ test<forward_iterator<const int*>, input_iterator<const int*>, forward_iterator<int*> >();
+ test<forward_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<forward_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+ test<forward_iterator<const int*>, input_iterator<const int*>, int*>();
+
+ test<forward_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+ test<forward_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+ test<forward_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<forward_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+ test<forward_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+ test<forward_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+ test<forward_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+ test<forward_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<forward_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+ test<forward_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+ test<forward_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+ test<forward_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+ test<forward_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<forward_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+ test<forward_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+ test<forward_iterator<const int*>, const int*, output_iterator<int*> >();
+ test<forward_iterator<const int*>, const int*, forward_iterator<int*> >();
+ test<forward_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+ test<forward_iterator<const int*>, const int*, random_access_iterator<int*> >();
+ test<forward_iterator<const int*>, const int*, int*>();
+
+ test<bidirectional_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, input_iterator<const int*>, int*>();
+
+ test<bidirectional_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+ test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+ test<bidirectional_iterator<const int*>, const int*, output_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, const int*, forward_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, const int*, random_access_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, const int*, int*>();
+
+ test<random_access_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+ test<random_access_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+ test<random_access_iterator<const int*>, input_iterator<const int*>, int*>();
+
+ test<random_access_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+ test<random_access_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+ test<random_access_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+ test<random_access_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+ test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+ test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+ test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+ test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+ test<random_access_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+ test<random_access_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+ test<random_access_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+ test<random_access_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+ test<random_access_iterator<const int*>, const int*, output_iterator<int*> >();
+ test<random_access_iterator<const int*>, const int*, forward_iterator<int*> >();
+ test<random_access_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, const int*, random_access_iterator<int*> >();
+ test<random_access_iterator<const int*>, const int*, int*>();
+
+ test<const int*, input_iterator<const int*>, output_iterator<int*> >();
+ test<const int*, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<const int*, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<const int*, input_iterator<const int*>, random_access_iterator<int*> >();
+ test<const int*, input_iterator<const int*>, int*>();
+
+ test<const int*, forward_iterator<const int*>, output_iterator<int*> >();
+ test<const int*, forward_iterator<const int*>, forward_iterator<int*> >();
+ test<const int*, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<const int*, forward_iterator<const int*>, random_access_iterator<int*> >();
+ test<const int*, forward_iterator<const int*>, int*>();
+
+ test<const int*, bidirectional_iterator<const int*>, output_iterator<int*> >();
+ test<const int*, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+ test<const int*, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<const int*, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+ test<const int*, bidirectional_iterator<const int*>, int*>();
+
+ test<const int*, random_access_iterator<const int*>, output_iterator<int*> >();
+ test<const int*, random_access_iterator<const int*>, forward_iterator<int*> >();
+ test<const int*, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<const int*, random_access_iterator<const int*>, random_access_iterator<int*> >();
+ test<const int*, random_access_iterator<const int*>, int*>();
+
+ test<const int*, const int*, output_iterator<int*> >();
+ test<const int*, const int*, forward_iterator<int*> >();
+ test<const int*, const int*, bidirectional_iterator<int*> >();
+ test<const int*, const int*, random_access_iterator<int*> >();
+ test<const int*, const int*, int*>();
+}
diff --git a/test/std/algorithms/alg.sorting/alg.set.operations/set.difference/set_difference_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.set.operations/set.difference/set_difference_comp.pass.cpp
new file mode 100644
index 000000000000..2b5a6a9f56bd
--- /dev/null
+++ b/test/std/algorithms/alg.sorting/alg.set.operations/set.difference/set_difference_comp.pass.cpp
@@ -0,0 +1,202 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator InIter1, InputIterator InIter2, typename OutIter,
+// CopyConstructible Compare>
+// requires OutputIterator<OutIter, InIter1::reference>
+// && OutputIterator<OutIter, InIter2::reference>
+// && Predicate<Compare, InIter1::value_type, InIter2::value_type>
+// && Predicate<Compare, InIter2::value_type, InIter1::value_type>
+// OutIter
+// set_difference(InIter1 first1, InIter1 last1, InIter2 first2, InIter2 last2,
+// OutIter result, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter1, class Iter2, class OutIter>
+void
+test()
+{
+ int ia[] = {1, 2, 2, 3, 3, 3, 4, 4, 4, 4};
+ const int sa = sizeof(ia)/sizeof(ia[0]);
+ int ib[] = {2, 4, 4, 6};
+ const int sb = sizeof(ib)/sizeof(ib[0]);
+ int ic[20];
+ int ir[] = {1, 2, 3, 3, 3, 4, 4};
+ const int sr = sizeof(ir)/sizeof(ir[0]);
+ OutIter ce = std::set_difference(Iter1(ia), Iter1(ia+sa),
+ Iter2(ib), Iter2(ib+sb), OutIter(ic), std::less<int>());
+ assert(base(ce) - ic == sr);
+ assert(std::lexicographical_compare(ic, base(ce), ir, ir+sr) == 0);
+ int irr[] = {6};
+ const int srr = sizeof(irr)/sizeof(irr[0]);
+ ce = std::set_difference(Iter1(ib), Iter1(ib+sb),
+ Iter2(ia), Iter2(ia+sa), OutIter(ic), std::less<int>());
+ assert(base(ce) - ic == srr);
+ assert(std::lexicographical_compare(ic, base(ce), irr, irr+srr) == 0);
+}
+
+int main()
+{
+ test<input_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+ test<input_iterator<const int*>, input_iterator<const int*>, forward_iterator<int*> >();
+ test<input_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<input_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+ test<input_iterator<const int*>, input_iterator<const int*>, int*>();
+
+ test<input_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+ test<input_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+ test<input_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<input_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+ test<input_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+ test<input_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+ test<input_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+ test<input_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<input_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+ test<input_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+ test<input_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+ test<input_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+ test<input_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<input_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+ test<input_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+ test<input_iterator<const int*>, const int*, output_iterator<int*> >();
+ test<input_iterator<const int*>, const int*, forward_iterator<int*> >();
+ test<input_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+ test<input_iterator<const int*>, const int*, random_access_iterator<int*> >();
+ test<input_iterator<const int*>, const int*, int*>();
+
+ test<forward_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+ test<forward_iterator<const int*>, input_iterator<const int*>, forward_iterator<int*> >();
+ test<forward_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<forward_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+ test<forward_iterator<const int*>, input_iterator<const int*>, int*>();
+
+ test<forward_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+ test<forward_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+ test<forward_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<forward_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+ test<forward_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+ test<forward_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+ test<forward_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+ test<forward_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<forward_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+ test<forward_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+ test<forward_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+ test<forward_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+ test<forward_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<forward_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+ test<forward_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+ test<forward_iterator<const int*>, const int*, output_iterator<int*> >();
+ test<forward_iterator<const int*>, const int*, forward_iterator<int*> >();
+ test<forward_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+ test<forward_iterator<const int*>, const int*, random_access_iterator<int*> >();
+ test<forward_iterator<const int*>, const int*, int*>();
+
+ test<bidirectional_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, input_iterator<const int*>, int*>();
+
+ test<bidirectional_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+ test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+ test<bidirectional_iterator<const int*>, const int*, output_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, const int*, forward_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, const int*, random_access_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, const int*, int*>();
+
+ test<random_access_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+ test<random_access_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+ test<random_access_iterator<const int*>, input_iterator<const int*>, int*>();
+
+ test<random_access_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+ test<random_access_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+ test<random_access_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+ test<random_access_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+ test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+ test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+ test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+ test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+ test<random_access_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+ test<random_access_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+ test<random_access_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+ test<random_access_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+ test<random_access_iterator<const int*>, const int*, output_iterator<int*> >();
+ test<random_access_iterator<const int*>, const int*, forward_iterator<int*> >();
+ test<random_access_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, const int*, random_access_iterator<int*> >();
+ test<random_access_iterator<const int*>, const int*, int*>();
+
+ test<const int*, input_iterator<const int*>, output_iterator<int*> >();
+ test<const int*, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<const int*, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<const int*, input_iterator<const int*>, random_access_iterator<int*> >();
+ test<const int*, input_iterator<const int*>, int*>();
+
+ test<const int*, forward_iterator<const int*>, output_iterator<int*> >();
+ test<const int*, forward_iterator<const int*>, forward_iterator<int*> >();
+ test<const int*, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<const int*, forward_iterator<const int*>, random_access_iterator<int*> >();
+ test<const int*, forward_iterator<const int*>, int*>();
+
+ test<const int*, bidirectional_iterator<const int*>, output_iterator<int*> >();
+ test<const int*, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+ test<const int*, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<const int*, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+ test<const int*, bidirectional_iterator<const int*>, int*>();
+
+ test<const int*, random_access_iterator<const int*>, output_iterator<int*> >();
+ test<const int*, random_access_iterator<const int*>, forward_iterator<int*> >();
+ test<const int*, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<const int*, random_access_iterator<const int*>, random_access_iterator<int*> >();
+ test<const int*, random_access_iterator<const int*>, int*>();
+
+ test<const int*, const int*, output_iterator<int*> >();
+ test<const int*, const int*, forward_iterator<int*> >();
+ test<const int*, const int*, bidirectional_iterator<int*> >();
+ test<const int*, const int*, random_access_iterator<int*> >();
+ test<const int*, const int*, int*>();
+}
diff --git a/test/std/algorithms/alg.sorting/alg.set.operations/set.intersection/set_intersection.pass.cpp b/test/std/algorithms/alg.sorting/alg.set.operations/set.intersection/set_intersection.pass.cpp
new file mode 100644
index 000000000000..f371890d8e7e
--- /dev/null
+++ b/test/std/algorithms/alg.sorting/alg.set.operations/set.intersection/set_intersection.pass.cpp
@@ -0,0 +1,198 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator InIter1, InputIterator InIter2, typename OutIter>
+// requires OutputIterator<OutIter, InIter1::reference>
+// && OutputIterator<OutIter, InIter2::reference>
+// && HasLess<InIter2::value_type, InIter1::value_type>
+// && HasLess<InIter1::value_type, InIter2::value_type>
+// OutIter
+// set_intersection(InIter1 first1, InIter1 last1, InIter2 first2, InIter2 last2,
+// OutIter result);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter1, class Iter2, class OutIter>
+void
+test()
+{
+ int ia[] = {1, 2, 2, 3, 3, 3, 4, 4, 4, 4};
+ const int sa = sizeof(ia)/sizeof(ia[0]);
+ int ib[] = {2, 4, 4, 6};
+ const int sb = sizeof(ib)/sizeof(ib[0]);
+ int ic[20];
+ int ir[] = {2, 4, 4};
+ const int sr = sizeof(ir)/sizeof(ir[0]);
+ OutIter ce = std::set_intersection(Iter1(ia), Iter1(ia+sa),
+ Iter2(ib), Iter2(ib+sb), OutIter(ic));
+ assert(base(ce) - ic == sr);
+ assert(std::lexicographical_compare(ic, base(ce), ir, ir+sr) == 0);
+ ce = std::set_intersection(Iter1(ib), Iter1(ib+sb),
+ Iter2(ia), Iter2(ia+sa), OutIter(ic));
+ assert(base(ce) - ic == sr);
+ assert(std::lexicographical_compare(ic, base(ce), ir, ir+sr) == 0);
+}
+
+int main()
+{
+ test<input_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+ test<input_iterator<const int*>, input_iterator<const int*>, forward_iterator<int*> >();
+ test<input_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<input_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+ test<input_iterator<const int*>, input_iterator<const int*>, int*>();
+
+ test<input_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+ test<input_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+ test<input_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<input_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+ test<input_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+ test<input_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+ test<input_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+ test<input_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<input_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+ test<input_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+ test<input_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+ test<input_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+ test<input_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<input_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+ test<input_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+ test<input_iterator<const int*>, const int*, output_iterator<int*> >();
+ test<input_iterator<const int*>, const int*, forward_iterator<int*> >();
+ test<input_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+ test<input_iterator<const int*>, const int*, random_access_iterator<int*> >();
+ test<input_iterator<const int*>, const int*, int*>();
+
+ test<forward_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+ test<forward_iterator<const int*>, input_iterator<const int*>, forward_iterator<int*> >();
+ test<forward_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<forward_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+ test<forward_iterator<const int*>, input_iterator<const int*>, int*>();
+
+ test<forward_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+ test<forward_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+ test<forward_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<forward_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+ test<forward_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+ test<forward_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+ test<forward_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+ test<forward_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<forward_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+ test<forward_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+ test<forward_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+ test<forward_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+ test<forward_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<forward_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+ test<forward_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+ test<forward_iterator<const int*>, const int*, output_iterator<int*> >();
+ test<forward_iterator<const int*>, const int*, forward_iterator<int*> >();
+ test<forward_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+ test<forward_iterator<const int*>, const int*, random_access_iterator<int*> >();
+ test<forward_iterator<const int*>, const int*, int*>();
+
+ test<bidirectional_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, input_iterator<const int*>, int*>();
+
+ test<bidirectional_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+ test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+ test<bidirectional_iterator<const int*>, const int*, output_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, const int*, forward_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, const int*, random_access_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, const int*, int*>();
+
+ test<random_access_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+ test<random_access_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+ test<random_access_iterator<const int*>, input_iterator<const int*>, int*>();
+
+ test<random_access_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+ test<random_access_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+ test<random_access_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+ test<random_access_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+ test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+ test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+ test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+ test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+ test<random_access_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+ test<random_access_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+ test<random_access_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+ test<random_access_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+ test<random_access_iterator<const int*>, const int*, output_iterator<int*> >();
+ test<random_access_iterator<const int*>, const int*, forward_iterator<int*> >();
+ test<random_access_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, const int*, random_access_iterator<int*> >();
+ test<random_access_iterator<const int*>, const int*, int*>();
+
+ test<const int*, input_iterator<const int*>, output_iterator<int*> >();
+ test<const int*, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<const int*, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<const int*, input_iterator<const int*>, random_access_iterator<int*> >();
+ test<const int*, input_iterator<const int*>, int*>();
+
+ test<const int*, forward_iterator<const int*>, output_iterator<int*> >();
+ test<const int*, forward_iterator<const int*>, forward_iterator<int*> >();
+ test<const int*, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<const int*, forward_iterator<const int*>, random_access_iterator<int*> >();
+ test<const int*, forward_iterator<const int*>, int*>();
+
+ test<const int*, bidirectional_iterator<const int*>, output_iterator<int*> >();
+ test<const int*, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+ test<const int*, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<const int*, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+ test<const int*, bidirectional_iterator<const int*>, int*>();
+
+ test<const int*, random_access_iterator<const int*>, output_iterator<int*> >();
+ test<const int*, random_access_iterator<const int*>, forward_iterator<int*> >();
+ test<const int*, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<const int*, random_access_iterator<const int*>, random_access_iterator<int*> >();
+ test<const int*, random_access_iterator<const int*>, int*>();
+
+ test<const int*, const int*, output_iterator<int*> >();
+ test<const int*, const int*, forward_iterator<int*> >();
+ test<const int*, const int*, bidirectional_iterator<int*> >();
+ test<const int*, const int*, random_access_iterator<int*> >();
+ test<const int*, const int*, int*>();
+}
diff --git a/test/std/algorithms/alg.sorting/alg.set.operations/set.intersection/set_intersection_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.set.operations/set.intersection/set_intersection_comp.pass.cpp
new file mode 100644
index 000000000000..035522b54624
--- /dev/null
+++ b/test/std/algorithms/alg.sorting/alg.set.operations/set.intersection/set_intersection_comp.pass.cpp
@@ -0,0 +1,200 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator InIter1, InputIterator InIter2, typename OutIter,
+// CopyConstructible Compare>
+// requires OutputIterator<OutIter, InIter1::reference>
+// && OutputIterator<OutIter, InIter2::reference>
+// && Predicate<Compare, InIter1::value_type, InIter2::value_type>
+// && Predicate<Compare, InIter2::value_type, InIter1::value_type>
+// OutIter
+// set_intersection(InIter1 first1, InIter1 last1, InIter2 first2, InIter2 last2,
+// OutIter result, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter1, class Iter2, class OutIter>
+void
+test()
+{
+ int ia[] = {1, 2, 2, 3, 3, 3, 4, 4, 4, 4};
+ const int sa = sizeof(ia)/sizeof(ia[0]);
+ int ib[] = {2, 4, 4, 6};
+ const int sb = sizeof(ib)/sizeof(ib[0]);
+ int ic[20];
+ int ir[] = {2, 4, 4};
+ const int sr = sizeof(ir)/sizeof(ir[0]);
+ OutIter ce = std::set_intersection(Iter1(ia), Iter1(ia+sa),
+ Iter2(ib), Iter2(ib+sb), OutIter(ic), std::less<int>());
+ assert(base(ce) - ic == sr);
+ assert(std::lexicographical_compare(ic, base(ce), ir, ir+sr) == 0);
+ ce = std::set_intersection(Iter1(ib), Iter1(ib+sb),
+ Iter2(ia), Iter2(ia+sa), OutIter(ic), std::less<int>());
+ assert(base(ce) - ic == sr);
+ assert(std::lexicographical_compare(ic, base(ce), ir, ir+sr) == 0);
+}
+
+int main()
+{
+ test<input_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+ test<input_iterator<const int*>, input_iterator<const int*>, forward_iterator<int*> >();
+ test<input_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<input_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+ test<input_iterator<const int*>, input_iterator<const int*>, int*>();
+
+ test<input_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+ test<input_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+ test<input_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<input_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+ test<input_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+ test<input_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+ test<input_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+ test<input_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<input_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+ test<input_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+ test<input_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+ test<input_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+ test<input_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<input_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+ test<input_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+ test<input_iterator<const int*>, const int*, output_iterator<int*> >();
+ test<input_iterator<const int*>, const int*, forward_iterator<int*> >();
+ test<input_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+ test<input_iterator<const int*>, const int*, random_access_iterator<int*> >();
+ test<input_iterator<const int*>, const int*, int*>();
+
+ test<forward_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+ test<forward_iterator<const int*>, input_iterator<const int*>, forward_iterator<int*> >();
+ test<forward_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<forward_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+ test<forward_iterator<const int*>, input_iterator<const int*>, int*>();
+
+ test<forward_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+ test<forward_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+ test<forward_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<forward_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+ test<forward_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+ test<forward_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+ test<forward_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+ test<forward_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<forward_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+ test<forward_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+ test<forward_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+ test<forward_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+ test<forward_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<forward_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+ test<forward_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+ test<forward_iterator<const int*>, const int*, output_iterator<int*> >();
+ test<forward_iterator<const int*>, const int*, forward_iterator<int*> >();
+ test<forward_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+ test<forward_iterator<const int*>, const int*, random_access_iterator<int*> >();
+ test<forward_iterator<const int*>, const int*, int*>();
+
+ test<bidirectional_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, input_iterator<const int*>, int*>();
+
+ test<bidirectional_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+ test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+ test<bidirectional_iterator<const int*>, const int*, output_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, const int*, forward_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, const int*, random_access_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, const int*, int*>();
+
+ test<random_access_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+ test<random_access_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+ test<random_access_iterator<const int*>, input_iterator<const int*>, int*>();
+
+ test<random_access_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+ test<random_access_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+ test<random_access_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+ test<random_access_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+ test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+ test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+ test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+ test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+ test<random_access_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+ test<random_access_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+ test<random_access_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+ test<random_access_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+ test<random_access_iterator<const int*>, const int*, output_iterator<int*> >();
+ test<random_access_iterator<const int*>, const int*, forward_iterator<int*> >();
+ test<random_access_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, const int*, random_access_iterator<int*> >();
+ test<random_access_iterator<const int*>, const int*, int*>();
+
+ test<const int*, input_iterator<const int*>, output_iterator<int*> >();
+ test<const int*, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<const int*, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<const int*, input_iterator<const int*>, random_access_iterator<int*> >();
+ test<const int*, input_iterator<const int*>, int*>();
+
+ test<const int*, forward_iterator<const int*>, output_iterator<int*> >();
+ test<const int*, forward_iterator<const int*>, forward_iterator<int*> >();
+ test<const int*, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<const int*, forward_iterator<const int*>, random_access_iterator<int*> >();
+ test<const int*, forward_iterator<const int*>, int*>();
+
+ test<const int*, bidirectional_iterator<const int*>, output_iterator<int*> >();
+ test<const int*, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+ test<const int*, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<const int*, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+ test<const int*, bidirectional_iterator<const int*>, int*>();
+
+ test<const int*, random_access_iterator<const int*>, output_iterator<int*> >();
+ test<const int*, random_access_iterator<const int*>, forward_iterator<int*> >();
+ test<const int*, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<const int*, random_access_iterator<const int*>, random_access_iterator<int*> >();
+ test<const int*, random_access_iterator<const int*>, int*>();
+
+ test<const int*, const int*, output_iterator<int*> >();
+ test<const int*, const int*, forward_iterator<int*> >();
+ test<const int*, const int*, bidirectional_iterator<int*> >();
+ test<const int*, const int*, random_access_iterator<int*> >();
+ test<const int*, const int*, int*>();
+}
diff --git a/test/std/algorithms/alg.sorting/alg.set.operations/set.symmetric.difference/set_symmetric_difference.pass.cpp b/test/std/algorithms/alg.sorting/alg.set.operations/set.symmetric.difference/set_symmetric_difference.pass.cpp
new file mode 100644
index 000000000000..ea3812a7f1c8
--- /dev/null
+++ b/test/std/algorithms/alg.sorting/alg.set.operations/set.symmetric.difference/set_symmetric_difference.pass.cpp
@@ -0,0 +1,199 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator InIter1, InputIterator InIter2, typename OutIter>
+// requires OutputIterator<OutIter, InIter1::reference>
+// && OutputIterator<OutIter, InIter2::reference>
+// && HasLess<InIter2::value_type, InIter1::value_type>
+// && HasLess<InIter1::value_type, InIter2::value_type>
+// OutIter
+// set_symmetric_difference(InIter1 first1, InIter1 last1,
+// InIter2 first2, InIter2 last2,
+// OutIter result);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter1, class Iter2, class OutIter>
+void
+test()
+{
+ int ia[] = {1, 2, 2, 3, 3, 3, 4, 4, 4, 4};
+ const int sa = sizeof(ia)/sizeof(ia[0]);
+ int ib[] = {2, 4, 4, 6};
+ const int sb = sizeof(ib)/sizeof(ib[0]);
+ int ic[20];
+ int ir[] = {1, 2, 3, 3, 3, 4, 4, 6};
+ const int sr = sizeof(ir)/sizeof(ir[0]);
+ OutIter ce = std::set_symmetric_difference(Iter1(ia), Iter1(ia+sa),
+ Iter2(ib), Iter2(ib+sb), OutIter(ic));
+ assert(base(ce) - ic == sr);
+ assert(std::lexicographical_compare(ic, base(ce), ir, ir+sr) == 0);
+ ce = std::set_symmetric_difference(Iter1(ib), Iter1(ib+sb),
+ Iter2(ia), Iter2(ia+sa), OutIter(ic));
+ assert(base(ce) - ic == sr);
+ assert(std::lexicographical_compare(ic, base(ce), ir, ir+sr) == 0);
+}
+
+int main()
+{
+ test<input_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+ test<input_iterator<const int*>, input_iterator<const int*>, forward_iterator<int*> >();
+ test<input_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<input_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+ test<input_iterator<const int*>, input_iterator<const int*>, int*>();
+
+ test<input_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+ test<input_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+ test<input_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<input_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+ test<input_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+ test<input_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+ test<input_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+ test<input_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<input_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+ test<input_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+ test<input_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+ test<input_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+ test<input_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<input_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+ test<input_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+ test<input_iterator<const int*>, const int*, output_iterator<int*> >();
+ test<input_iterator<const int*>, const int*, forward_iterator<int*> >();
+ test<input_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+ test<input_iterator<const int*>, const int*, random_access_iterator<int*> >();
+ test<input_iterator<const int*>, const int*, int*>();
+
+ test<forward_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+ test<forward_iterator<const int*>, input_iterator<const int*>, forward_iterator<int*> >();
+ test<forward_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<forward_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+ test<forward_iterator<const int*>, input_iterator<const int*>, int*>();
+
+ test<forward_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+ test<forward_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+ test<forward_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<forward_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+ test<forward_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+ test<forward_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+ test<forward_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+ test<forward_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<forward_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+ test<forward_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+ test<forward_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+ test<forward_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+ test<forward_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<forward_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+ test<forward_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+ test<forward_iterator<const int*>, const int*, output_iterator<int*> >();
+ test<forward_iterator<const int*>, const int*, forward_iterator<int*> >();
+ test<forward_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+ test<forward_iterator<const int*>, const int*, random_access_iterator<int*> >();
+ test<forward_iterator<const int*>, const int*, int*>();
+
+ test<bidirectional_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, input_iterator<const int*>, int*>();
+
+ test<bidirectional_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+ test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+ test<bidirectional_iterator<const int*>, const int*, output_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, const int*, forward_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, const int*, random_access_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, const int*, int*>();
+
+ test<random_access_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+ test<random_access_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+ test<random_access_iterator<const int*>, input_iterator<const int*>, int*>();
+
+ test<random_access_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+ test<random_access_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+ test<random_access_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+ test<random_access_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+ test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+ test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+ test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+ test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+ test<random_access_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+ test<random_access_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+ test<random_access_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+ test<random_access_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+ test<random_access_iterator<const int*>, const int*, output_iterator<int*> >();
+ test<random_access_iterator<const int*>, const int*, forward_iterator<int*> >();
+ test<random_access_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, const int*, random_access_iterator<int*> >();
+ test<random_access_iterator<const int*>, const int*, int*>();
+
+ test<const int*, input_iterator<const int*>, output_iterator<int*> >();
+ test<const int*, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<const int*, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<const int*, input_iterator<const int*>, random_access_iterator<int*> >();
+ test<const int*, input_iterator<const int*>, int*>();
+
+ test<const int*, forward_iterator<const int*>, output_iterator<int*> >();
+ test<const int*, forward_iterator<const int*>, forward_iterator<int*> >();
+ test<const int*, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<const int*, forward_iterator<const int*>, random_access_iterator<int*> >();
+ test<const int*, forward_iterator<const int*>, int*>();
+
+ test<const int*, bidirectional_iterator<const int*>, output_iterator<int*> >();
+ test<const int*, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+ test<const int*, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<const int*, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+ test<const int*, bidirectional_iterator<const int*>, int*>();
+
+ test<const int*, random_access_iterator<const int*>, output_iterator<int*> >();
+ test<const int*, random_access_iterator<const int*>, forward_iterator<int*> >();
+ test<const int*, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<const int*, random_access_iterator<const int*>, random_access_iterator<int*> >();
+ test<const int*, random_access_iterator<const int*>, int*>();
+
+ test<const int*, const int*, output_iterator<int*> >();
+ test<const int*, const int*, forward_iterator<int*> >();
+ test<const int*, const int*, bidirectional_iterator<int*> >();
+ test<const int*, const int*, random_access_iterator<int*> >();
+ test<const int*, const int*, int*>();
+}
diff --git a/test/std/algorithms/alg.sorting/alg.set.operations/set.symmetric.difference/set_symmetric_difference_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.set.operations/set.symmetric.difference/set_symmetric_difference_comp.pass.cpp
new file mode 100644
index 000000000000..ba1f61a1067b
--- /dev/null
+++ b/test/std/algorithms/alg.sorting/alg.set.operations/set.symmetric.difference/set_symmetric_difference_comp.pass.cpp
@@ -0,0 +1,203 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator InIter1, InputIterator InIter2, typename OutIter,
+// CopyConstructible Compare>
+// requires OutputIterator<OutIter, InIter1::reference>
+// && OutputIterator<OutIter, InIter2::reference>
+// && Predicate<Compare, InIter1::value_type, InIter2::value_type>
+// && Predicate<Compare, InIter2::value_type, InIter1::value_type>
+// OutIter
+// set_symmetric_difference(InIter1 first1, InIter1 last1,
+// InIter2 first2, InIter2 last2,
+// OutIter result, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter1, class Iter2, class OutIter>
+void
+test()
+{
+ int ia[] = {1, 2, 2, 3, 3, 3, 4, 4, 4, 4};
+ const int sa = sizeof(ia)/sizeof(ia[0]);
+ int ib[] = {2, 4, 4, 6};
+ const int sb = sizeof(ib)/sizeof(ib[0]);
+ int ic[20];
+ int ir[] = {1, 2, 3, 3, 3, 4, 4, 6};
+ const int sr = sizeof(ir)/sizeof(ir[0]);
+ OutIter ce = std::set_symmetric_difference(Iter1(ia), Iter1(ia+sa),
+ Iter2(ib), Iter2(ib+sb),
+ OutIter(ic), std::less<int>());
+ assert(base(ce) - ic == sr);
+ assert(std::lexicographical_compare(ic, base(ce), ir, ir+sr) == 0);
+ ce = std::set_symmetric_difference(Iter1(ib), Iter1(ib+sb),
+ Iter2(ia), Iter2(ia+sa),
+ OutIter(ic), std::less<int>());
+ assert(base(ce) - ic == sr);
+ assert(std::lexicographical_compare(ic, base(ce), ir, ir+sr) == 0);
+}
+
+int main()
+{
+ test<input_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+ test<input_iterator<const int*>, input_iterator<const int*>, forward_iterator<int*> >();
+ test<input_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<input_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+ test<input_iterator<const int*>, input_iterator<const int*>, int*>();
+
+ test<input_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+ test<input_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+ test<input_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<input_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+ test<input_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+ test<input_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+ test<input_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+ test<input_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<input_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+ test<input_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+ test<input_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+ test<input_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+ test<input_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<input_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+ test<input_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+ test<input_iterator<const int*>, const int*, output_iterator<int*> >();
+ test<input_iterator<const int*>, const int*, forward_iterator<int*> >();
+ test<input_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+ test<input_iterator<const int*>, const int*, random_access_iterator<int*> >();
+ test<input_iterator<const int*>, const int*, int*>();
+
+ test<forward_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+ test<forward_iterator<const int*>, input_iterator<const int*>, forward_iterator<int*> >();
+ test<forward_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<forward_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+ test<forward_iterator<const int*>, input_iterator<const int*>, int*>();
+
+ test<forward_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+ test<forward_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+ test<forward_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<forward_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+ test<forward_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+ test<forward_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+ test<forward_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+ test<forward_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<forward_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+ test<forward_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+ test<forward_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+ test<forward_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+ test<forward_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<forward_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+ test<forward_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+ test<forward_iterator<const int*>, const int*, output_iterator<int*> >();
+ test<forward_iterator<const int*>, const int*, forward_iterator<int*> >();
+ test<forward_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+ test<forward_iterator<const int*>, const int*, random_access_iterator<int*> >();
+ test<forward_iterator<const int*>, const int*, int*>();
+
+ test<bidirectional_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, input_iterator<const int*>, int*>();
+
+ test<bidirectional_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+ test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+ test<bidirectional_iterator<const int*>, const int*, output_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, const int*, forward_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, const int*, random_access_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, const int*, int*>();
+
+ test<random_access_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+ test<random_access_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+ test<random_access_iterator<const int*>, input_iterator<const int*>, int*>();
+
+ test<random_access_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+ test<random_access_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+ test<random_access_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+ test<random_access_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+ test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+ test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+ test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+ test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+ test<random_access_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+ test<random_access_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+ test<random_access_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+ test<random_access_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+ test<random_access_iterator<const int*>, const int*, output_iterator<int*> >();
+ test<random_access_iterator<const int*>, const int*, forward_iterator<int*> >();
+ test<random_access_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, const int*, random_access_iterator<int*> >();
+ test<random_access_iterator<const int*>, const int*, int*>();
+
+ test<const int*, input_iterator<const int*>, output_iterator<int*> >();
+ test<const int*, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<const int*, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<const int*, input_iterator<const int*>, random_access_iterator<int*> >();
+ test<const int*, input_iterator<const int*>, int*>();
+
+ test<const int*, forward_iterator<const int*>, output_iterator<int*> >();
+ test<const int*, forward_iterator<const int*>, forward_iterator<int*> >();
+ test<const int*, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<const int*, forward_iterator<const int*>, random_access_iterator<int*> >();
+ test<const int*, forward_iterator<const int*>, int*>();
+
+ test<const int*, bidirectional_iterator<const int*>, output_iterator<int*> >();
+ test<const int*, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+ test<const int*, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<const int*, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+ test<const int*, bidirectional_iterator<const int*>, int*>();
+
+ test<const int*, random_access_iterator<const int*>, output_iterator<int*> >();
+ test<const int*, random_access_iterator<const int*>, forward_iterator<int*> >();
+ test<const int*, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<const int*, random_access_iterator<const int*>, random_access_iterator<int*> >();
+ test<const int*, random_access_iterator<const int*>, int*>();
+
+ test<const int*, const int*, output_iterator<int*> >();
+ test<const int*, const int*, forward_iterator<int*> >();
+ test<const int*, const int*, bidirectional_iterator<int*> >();
+ test<const int*, const int*, random_access_iterator<int*> >();
+ test<const int*, const int*, int*>();
+}
diff --git a/test/std/algorithms/alg.sorting/alg.set.operations/set.union/set_union.pass.cpp b/test/std/algorithms/alg.sorting/alg.set.operations/set.union/set_union.pass.cpp
new file mode 100644
index 000000000000..46578501d772
--- /dev/null
+++ b/test/std/algorithms/alg.sorting/alg.set.operations/set.union/set_union.pass.cpp
@@ -0,0 +1,198 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator InIter1, InputIterator InIter2, typename OutIter>
+// requires OutputIterator<OutIter, InIter1::reference>
+// && OutputIterator<OutIter, InIter2::reference>
+// && HasLess<InIter2::value_type, InIter1::value_type>
+// && HasLess<InIter1::value_type, InIter2::value_type>
+// OutIter
+// set_union(InIter1 first1, InIter1 last1,
+// InIter2 first2, InIter2 last2, OutIter result);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter1, class Iter2, class OutIter>
+void
+test()
+{
+ int ia[] = {1, 2, 2, 3, 3, 3, 4, 4, 4, 4};
+ const int sa = sizeof(ia)/sizeof(ia[0]);
+ int ib[] = {2, 4, 4, 6};
+ const int sb = sizeof(ib)/sizeof(ib[0]);
+ int ic[20];
+ int ir[] = {1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 6};
+ const int sr = sizeof(ir)/sizeof(ir[0]);
+ OutIter ce = std::set_union(Iter1(ia), Iter1(ia+sa),
+ Iter2(ib), Iter2(ib+sb), OutIter(ic));
+ assert(base(ce) - ic == sr);
+ assert(std::lexicographical_compare(ic, base(ce), ir, ir+sr) == 0);
+ ce = std::set_union(Iter1(ib), Iter1(ib+sb),
+ Iter2(ia), Iter2(ia+sa), OutIter(ic));
+ assert(base(ce) - ic == sr);
+ assert(std::lexicographical_compare(ic, base(ce), ir, ir+sr) == 0);
+}
+
+int main()
+{
+ test<input_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+ test<input_iterator<const int*>, input_iterator<const int*>, forward_iterator<int*> >();
+ test<input_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<input_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+ test<input_iterator<const int*>, input_iterator<const int*>, int*>();
+
+ test<input_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+ test<input_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+ test<input_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<input_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+ test<input_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+ test<input_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+ test<input_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+ test<input_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<input_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+ test<input_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+ test<input_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+ test<input_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+ test<input_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<input_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+ test<input_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+ test<input_iterator<const int*>, const int*, output_iterator<int*> >();
+ test<input_iterator<const int*>, const int*, forward_iterator<int*> >();
+ test<input_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+ test<input_iterator<const int*>, const int*, random_access_iterator<int*> >();
+ test<input_iterator<const int*>, const int*, int*>();
+
+ test<forward_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+ test<forward_iterator<const int*>, input_iterator<const int*>, forward_iterator<int*> >();
+ test<forward_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<forward_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+ test<forward_iterator<const int*>, input_iterator<const int*>, int*>();
+
+ test<forward_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+ test<forward_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+ test<forward_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<forward_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+ test<forward_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+ test<forward_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+ test<forward_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+ test<forward_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<forward_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+ test<forward_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+ test<forward_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+ test<forward_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+ test<forward_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<forward_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+ test<forward_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+ test<forward_iterator<const int*>, const int*, output_iterator<int*> >();
+ test<forward_iterator<const int*>, const int*, forward_iterator<int*> >();
+ test<forward_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+ test<forward_iterator<const int*>, const int*, random_access_iterator<int*> >();
+ test<forward_iterator<const int*>, const int*, int*>();
+
+ test<bidirectional_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, input_iterator<const int*>, int*>();
+
+ test<bidirectional_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+ test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+ test<bidirectional_iterator<const int*>, const int*, output_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, const int*, forward_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, const int*, random_access_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, const int*, int*>();
+
+ test<random_access_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+ test<random_access_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+ test<random_access_iterator<const int*>, input_iterator<const int*>, int*>();
+
+ test<random_access_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+ test<random_access_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+ test<random_access_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+ test<random_access_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+ test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+ test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+ test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+ test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+ test<random_access_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+ test<random_access_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+ test<random_access_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+ test<random_access_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+ test<random_access_iterator<const int*>, const int*, output_iterator<int*> >();
+ test<random_access_iterator<const int*>, const int*, forward_iterator<int*> >();
+ test<random_access_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, const int*, random_access_iterator<int*> >();
+ test<random_access_iterator<const int*>, const int*, int*>();
+
+ test<const int*, input_iterator<const int*>, output_iterator<int*> >();
+ test<const int*, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<const int*, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<const int*, input_iterator<const int*>, random_access_iterator<int*> >();
+ test<const int*, input_iterator<const int*>, int*>();
+
+ test<const int*, forward_iterator<const int*>, output_iterator<int*> >();
+ test<const int*, forward_iterator<const int*>, forward_iterator<int*> >();
+ test<const int*, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<const int*, forward_iterator<const int*>, random_access_iterator<int*> >();
+ test<const int*, forward_iterator<const int*>, int*>();
+
+ test<const int*, bidirectional_iterator<const int*>, output_iterator<int*> >();
+ test<const int*, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+ test<const int*, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<const int*, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+ test<const int*, bidirectional_iterator<const int*>, int*>();
+
+ test<const int*, random_access_iterator<const int*>, output_iterator<int*> >();
+ test<const int*, random_access_iterator<const int*>, forward_iterator<int*> >();
+ test<const int*, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<const int*, random_access_iterator<const int*>, random_access_iterator<int*> >();
+ test<const int*, random_access_iterator<const int*>, int*>();
+
+ test<const int*, const int*, output_iterator<int*> >();
+ test<const int*, const int*, forward_iterator<int*> >();
+ test<const int*, const int*, bidirectional_iterator<int*> >();
+ test<const int*, const int*, random_access_iterator<int*> >();
+ test<const int*, const int*, int*>();
+}
diff --git a/test/std/algorithms/alg.sorting/alg.set.operations/set.union/set_union_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.set.operations/set.union/set_union_comp.pass.cpp
new file mode 100644
index 000000000000..3d63e3fb9c4a
--- /dev/null
+++ b/test/std/algorithms/alg.sorting/alg.set.operations/set.union/set_union_comp.pass.cpp
@@ -0,0 +1,200 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator InIter1, InputIterator InIter2, typename OutIter,
+// CopyConstructible Compare>
+// requires OutputIterator<OutIter, InIter1::reference>
+// && OutputIterator<OutIter, InIter2::reference>
+// && Predicate<Compare, InIter1::value_type, InIter2::value_type>
+// && Predicate<Compare, InIter2::value_type, InIter1::value_type>
+// OutIter
+// set_union(InIter1 first1, InIter1 last1, InIter2 first2, InIter2 last2,
+// OutIter result, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter1, class Iter2, class OutIter>
+void
+test()
+{
+ int ia[] = {1, 2, 2, 3, 3, 3, 4, 4, 4, 4};
+ const int sa = sizeof(ia)/sizeof(ia[0]);
+ int ib[] = {2, 4, 4, 6};
+ const int sb = sizeof(ib)/sizeof(ib[0]);
+ int ic[20];
+ int ir[] = {1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 6};
+ const int sr = sizeof(ir)/sizeof(ir[0]);
+ OutIter ce = std::set_union(Iter1(ia), Iter1(ia+sa),
+ Iter2(ib), Iter2(ib+sb), OutIter(ic), std::less<int>());
+ assert(base(ce) - ic == sr);
+ assert(std::lexicographical_compare(ic, base(ce), ir, ir+sr) == 0);
+ ce = std::set_union(Iter1(ib), Iter1(ib+sb),
+ Iter2(ia), Iter2(ia+sa), OutIter(ic), std::less<int>());
+ assert(base(ce) - ic == sr);
+ assert(std::lexicographical_compare(ic, base(ce), ir, ir+sr) == 0);
+}
+
+int main()
+{
+ test<input_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+ test<input_iterator<const int*>, input_iterator<const int*>, forward_iterator<int*> >();
+ test<input_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<input_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+ test<input_iterator<const int*>, input_iterator<const int*>, int*>();
+
+ test<input_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+ test<input_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+ test<input_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<input_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+ test<input_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+ test<input_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+ test<input_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+ test<input_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<input_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+ test<input_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+ test<input_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+ test<input_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+ test<input_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<input_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+ test<input_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+ test<input_iterator<const int*>, const int*, output_iterator<int*> >();
+ test<input_iterator<const int*>, const int*, forward_iterator<int*> >();
+ test<input_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+ test<input_iterator<const int*>, const int*, random_access_iterator<int*> >();
+ test<input_iterator<const int*>, const int*, int*>();
+
+ test<forward_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+ test<forward_iterator<const int*>, input_iterator<const int*>, forward_iterator<int*> >();
+ test<forward_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<forward_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+ test<forward_iterator<const int*>, input_iterator<const int*>, int*>();
+
+ test<forward_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+ test<forward_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+ test<forward_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<forward_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+ test<forward_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+ test<forward_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+ test<forward_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+ test<forward_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<forward_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+ test<forward_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+ test<forward_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+ test<forward_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+ test<forward_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<forward_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+ test<forward_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+ test<forward_iterator<const int*>, const int*, output_iterator<int*> >();
+ test<forward_iterator<const int*>, const int*, forward_iterator<int*> >();
+ test<forward_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+ test<forward_iterator<const int*>, const int*, random_access_iterator<int*> >();
+ test<forward_iterator<const int*>, const int*, int*>();
+
+ test<bidirectional_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, input_iterator<const int*>, int*>();
+
+ test<bidirectional_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+ test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+ test<bidirectional_iterator<const int*>, const int*, output_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, const int*, forward_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, const int*, random_access_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, const int*, int*>();
+
+ test<random_access_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+ test<random_access_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+ test<random_access_iterator<const int*>, input_iterator<const int*>, int*>();
+
+ test<random_access_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+ test<random_access_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+ test<random_access_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+ test<random_access_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+ test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+ test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+ test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+ test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+ test<random_access_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+ test<random_access_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+ test<random_access_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+ test<random_access_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+ test<random_access_iterator<const int*>, const int*, output_iterator<int*> >();
+ test<random_access_iterator<const int*>, const int*, forward_iterator<int*> >();
+ test<random_access_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, const int*, random_access_iterator<int*> >();
+ test<random_access_iterator<const int*>, const int*, int*>();
+
+ test<const int*, input_iterator<const int*>, output_iterator<int*> >();
+ test<const int*, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<const int*, input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<const int*, input_iterator<const int*>, random_access_iterator<int*> >();
+ test<const int*, input_iterator<const int*>, int*>();
+
+ test<const int*, forward_iterator<const int*>, output_iterator<int*> >();
+ test<const int*, forward_iterator<const int*>, forward_iterator<int*> >();
+ test<const int*, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<const int*, forward_iterator<const int*>, random_access_iterator<int*> >();
+ test<const int*, forward_iterator<const int*>, int*>();
+
+ test<const int*, bidirectional_iterator<const int*>, output_iterator<int*> >();
+ test<const int*, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+ test<const int*, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<const int*, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+ test<const int*, bidirectional_iterator<const int*>, int*>();
+
+ test<const int*, random_access_iterator<const int*>, output_iterator<int*> >();
+ test<const int*, random_access_iterator<const int*>, forward_iterator<int*> >();
+ test<const int*, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<const int*, random_access_iterator<const int*>, random_access_iterator<int*> >();
+ test<const int*, random_access_iterator<const int*>, int*>();
+
+ test<const int*, const int*, output_iterator<int*> >();
+ test<const int*, const int*, forward_iterator<int*> >();
+ test<const int*, const int*, bidirectional_iterator<int*> >();
+ test<const int*, const int*, random_access_iterator<int*> >();
+ test<const int*, const int*, int*>();
+}
diff --git a/test/std/algorithms/alg.sorting/alg.sort/is.sorted/is_sorted.pass.cpp b/test/std/algorithms/alg.sorting/alg.sort/is.sorted/is_sorted.pass.cpp
new file mode 100644
index 000000000000..dd6b5c1766ad
--- /dev/null
+++ b/test/std/algorithms/alg.sorting/alg.sort/is.sorted/is_sorted.pass.cpp
@@ -0,0 +1,183 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter>
+// requires LessThanComparable<Iter::value_type>
+// bool
+// is_sorted(Iter first, Iter last);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter>
+void
+test()
+{
+ {
+ int a[] = {0};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(std::is_sorted(Iter(a), Iter(a)));
+ assert(std::is_sorted(Iter(a), Iter(a+sa)));
+ }
+
+ {
+ int a[] = {0, 0};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(std::is_sorted(Iter(a), Iter(a+sa)));
+ }
+ {
+ int a[] = {0, 1};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(std::is_sorted(Iter(a), Iter(a+sa)));
+ }
+ {
+ int a[] = {1, 0};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(!std::is_sorted(Iter(a), Iter(a+sa)));
+ }
+ {
+ int a[] = {1, 1};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(std::is_sorted(Iter(a), Iter(a+sa)));
+ }
+
+ {
+ int a[] = {0, 0, 0};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(std::is_sorted(Iter(a), Iter(a+sa)));
+ }
+ {
+ int a[] = {0, 0, 1};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(std::is_sorted(Iter(a), Iter(a+sa)));
+ }
+ {
+ int a[] = {0, 1, 0};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(!std::is_sorted(Iter(a), Iter(a+sa)));
+ }
+ {
+ int a[] = {0, 1, 1};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(std::is_sorted(Iter(a), Iter(a+sa)));
+ }
+ {
+ int a[] = {1, 0, 0};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(!std::is_sorted(Iter(a), Iter(a+sa)));
+ }
+ {
+ int a[] = {1, 0, 1};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(!std::is_sorted(Iter(a), Iter(a+sa)));
+ }
+ {
+ int a[] = {1, 1, 0};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(!std::is_sorted(Iter(a), Iter(a+sa)));
+ }
+ {
+ int a[] = {1, 1, 1};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(std::is_sorted(Iter(a), Iter(a+sa)));
+ }
+
+ {
+ int a[] = {0, 0, 0, 0};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(std::is_sorted(Iter(a), Iter(a+sa)));
+ }
+ {
+ int a[] = {0, 0, 0, 1};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(std::is_sorted(Iter(a), Iter(a+sa)));
+ }
+ {
+ int a[] = {0, 0, 1, 0};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(!std::is_sorted(Iter(a), Iter(a+sa)));
+ }
+ {
+ int a[] = {0, 0, 1, 1};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(std::is_sorted(Iter(a), Iter(a+sa)));
+ }
+ {
+ int a[] = {0, 1, 0, 0};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(!std::is_sorted(Iter(a), Iter(a+sa)));
+ }
+ {
+ int a[] = {0, 1, 0, 1};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(!std::is_sorted(Iter(a), Iter(a+sa)));
+ }
+ {
+ int a[] = {0, 1, 1, 0};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(!std::is_sorted(Iter(a), Iter(a+sa)));
+ }
+ {
+ int a[] = {0, 1, 1, 1};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(std::is_sorted(Iter(a), Iter(a+sa)));
+ }
+ {
+ int a[] = {1, 0, 0, 0};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(!std::is_sorted(Iter(a), Iter(a+sa)));
+ }
+ {
+ int a[] = {1, 0, 0, 1};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(!std::is_sorted(Iter(a), Iter(a+sa)));
+ }
+ {
+ int a[] = {1, 0, 1, 0};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(!std::is_sorted(Iter(a), Iter(a+sa)));
+ }
+ {
+ int a[] = {1, 0, 1, 1};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(!std::is_sorted(Iter(a), Iter(a+sa)));
+ }
+ {
+ int a[] = {1, 1, 0, 0};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(!std::is_sorted(Iter(a), Iter(a+sa)));
+ }
+ {
+ int a[] = {1, 1, 0, 1};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(!std::is_sorted(Iter(a), Iter(a+sa)));
+ }
+ {
+ int a[] = {1, 1, 1, 0};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(!std::is_sorted(Iter(a), Iter(a+sa)));
+ }
+ {
+ int a[] = {1, 1, 1, 1};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(std::is_sorted(Iter(a), Iter(a+sa)));
+ }
+}
+
+int main()
+{
+ test<forward_iterator<const int*> >();
+ test<bidirectional_iterator<const int*> >();
+ test<random_access_iterator<const int*> >();
+ test<const int*>();
+}
diff --git a/test/std/algorithms/alg.sorting/alg.sort/is.sorted/is_sorted_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.sort/is.sorted/is_sorted_comp.pass.cpp
new file mode 100644
index 000000000000..d5a34e2f2cb3
--- /dev/null
+++ b/test/std/algorithms/alg.sorting/alg.sort/is.sorted/is_sorted_comp.pass.cpp
@@ -0,0 +1,184 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter, StrictWeakOrder<auto, Iter::value_type> Compare>
+// requires CopyConstructible<Compare>
+// bool
+// is_sorted(Iter first, Iter last, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter>
+void
+test()
+{
+ {
+ int a[] = {0};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(std::is_sorted(Iter(a), Iter(a)));
+ assert(std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+ }
+
+ {
+ int a[] = {0, 0};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+ }
+ {
+ int a[] = {0, 1};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(!std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+ }
+ {
+ int a[] = {1, 0};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+ }
+ {
+ int a[] = {1, 1};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+ }
+
+ {
+ int a[] = {0, 0, 0};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+ }
+ {
+ int a[] = {0, 0, 1};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(!std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+ }
+ {
+ int a[] = {0, 1, 0};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(!std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+ }
+ {
+ int a[] = {0, 1, 1};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(!std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+ }
+ {
+ int a[] = {1, 0, 0};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+ }
+ {
+ int a[] = {1, 0, 1};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(!std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+ }
+ {
+ int a[] = {1, 1, 0};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+ }
+ {
+ int a[] = {1, 1, 1};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+ }
+
+ {
+ int a[] = {0, 0, 0, 0};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+ }
+ {
+ int a[] = {0, 0, 0, 1};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(!std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+ }
+ {
+ int a[] = {0, 0, 1, 0};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(!std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+ }
+ {
+ int a[] = {0, 0, 1, 1};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(!std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+ }
+ {
+ int a[] = {0, 1, 0, 0};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(!std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+ }
+ {
+ int a[] = {0, 1, 0, 1};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(!std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+ }
+ {
+ int a[] = {0, 1, 1, 0};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(!std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+ }
+ {
+ int a[] = {0, 1, 1, 1};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(!std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+ }
+ {
+ int a[] = {1, 0, 0, 0};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+ }
+ {
+ int a[] = {1, 0, 0, 1};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(!std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+ }
+ {
+ int a[] = {1, 0, 1, 0};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(!std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+ }
+ {
+ int a[] = {1, 0, 1, 1};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(!std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+ }
+ {
+ int a[] = {1, 1, 0, 0};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+ }
+ {
+ int a[] = {1, 1, 0, 1};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(!std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+ }
+ {
+ int a[] = {1, 1, 1, 0};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+ }
+ {
+ int a[] = {1, 1, 1, 1};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+ }
+}
+
+int main()
+{
+ test<forward_iterator<const int*> >();
+ test<bidirectional_iterator<const int*> >();
+ test<random_access_iterator<const int*> >();
+ test<const int*>();
+}
diff --git a/test/std/algorithms/alg.sorting/alg.sort/is.sorted/is_sorted_until.pass.cpp b/test/std/algorithms/alg.sorting/alg.sort/is.sorted/is_sorted_until.pass.cpp
new file mode 100644
index 000000000000..bef01027472c
--- /dev/null
+++ b/test/std/algorithms/alg.sorting/alg.sort/is.sorted/is_sorted_until.pass.cpp
@@ -0,0 +1,183 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter>
+// requires LessThanComparable<Iter::value_type>
+// Iter
+// is_sorted_until(Iter first, Iter last);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter>
+void
+test()
+{
+ {
+ int a[] = {0};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(std::is_sorted_until(Iter(a), Iter(a)) == Iter(a));
+ assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+sa));
+ }
+
+ {
+ int a[] = {0, 0};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+sa));
+ }
+ {
+ int a[] = {0, 1};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+sa));
+ }
+ {
+ int a[] = {1, 0};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+1));
+ }
+ {
+ int a[] = {1, 1};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+sa));
+ }
+
+ {
+ int a[] = {0, 0, 0};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+sa));
+ }
+ {
+ int a[] = {0, 0, 1};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+sa));
+ }
+ {
+ int a[] = {0, 1, 0};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+2));
+ }
+ {
+ int a[] = {0, 1, 1};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+sa));
+ }
+ {
+ int a[] = {1, 0, 0};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+1));
+ }
+ {
+ int a[] = {1, 0, 1};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+1));
+ }
+ {
+ int a[] = {1, 1, 0};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+2));
+ }
+ {
+ int a[] = {1, 1, 1};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+sa));
+ }
+
+ {
+ int a[] = {0, 0, 0, 0};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+sa));
+ }
+ {
+ int a[] = {0, 0, 0, 1};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+sa));
+ }
+ {
+ int a[] = {0, 0, 1, 0};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+3));
+ }
+ {
+ int a[] = {0, 0, 1, 1};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+sa));
+ }
+ {
+ int a[] = {0, 1, 0, 0};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+2));
+ }
+ {
+ int a[] = {0, 1, 0, 1};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+2));
+ }
+ {
+ int a[] = {0, 1, 1, 0};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+3));
+ }
+ {
+ int a[] = {0, 1, 1, 1};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+sa));
+ }
+ {
+ int a[] = {1, 0, 0, 0};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+1));
+ }
+ {
+ int a[] = {1, 0, 0, 1};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+1));
+ }
+ {
+ int a[] = {1, 0, 1, 0};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+1));
+ }
+ {
+ int a[] = {1, 0, 1, 1};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+1));
+ }
+ {
+ int a[] = {1, 1, 0, 0};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+2));
+ }
+ {
+ int a[] = {1, 1, 0, 1};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+2));
+ }
+ {
+ int a[] = {1, 1, 1, 0};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+3));
+ }
+ {
+ int a[] = {1, 1, 1, 1};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+sa));
+ }
+}
+
+int main()
+{
+ test<forward_iterator<const int*> >();
+ test<bidirectional_iterator<const int*> >();
+ test<random_access_iterator<const int*> >();
+ test<const int*>();
+}
diff --git a/test/std/algorithms/alg.sorting/alg.sort/is.sorted/is_sorted_until_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.sort/is.sorted/is_sorted_until_comp.pass.cpp
new file mode 100644
index 000000000000..68ed29c6f4b8
--- /dev/null
+++ b/test/std/algorithms/alg.sorting/alg.sort/is.sorted/is_sorted_until_comp.pass.cpp
@@ -0,0 +1,184 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter, StrictWeakOrder<auto, Iter::value_type> Compare>
+// requires CopyConstructible<Compare>
+// Iter
+// is_sorted_until(Iter first, Iter last, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter>
+void
+test()
+{
+ {
+ int a[] = {0};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(std::is_sorted_until(Iter(a), Iter(a), std::greater<int>()) == Iter(a));
+ assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+sa));
+ }
+
+ {
+ int a[] = {0, 0};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+sa));
+ }
+ {
+ int a[] = {0, 1};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+1));
+ }
+ {
+ int a[] = {1, 0};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+sa));
+ }
+ {
+ int a[] = {1, 1};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+sa));
+ }
+
+ {
+ int a[] = {0, 0, 0};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+sa));
+ }
+ {
+ int a[] = {0, 0, 1};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+2));
+ }
+ {
+ int a[] = {0, 1, 0};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+1));
+ }
+ {
+ int a[] = {0, 1, 1};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+1));
+ }
+ {
+ int a[] = {1, 0, 0};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+sa));
+ }
+ {
+ int a[] = {1, 0, 1};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+2));
+ }
+ {
+ int a[] = {1, 1, 0};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+sa));
+ }
+ {
+ int a[] = {1, 1, 1};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+sa));
+ }
+
+ {
+ int a[] = {0, 0, 0, 0};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+sa));
+ }
+ {
+ int a[] = {0, 0, 0, 1};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+3));
+ }
+ {
+ int a[] = {0, 0, 1, 0};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+2));
+ }
+ {
+ int a[] = {0, 0, 1, 1};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+2));
+ }
+ {
+ int a[] = {0, 1, 0, 0};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+1));
+ }
+ {
+ int a[] = {0, 1, 0, 1};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+1));
+ }
+ {
+ int a[] = {0, 1, 1, 0};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+1));
+ }
+ {
+ int a[] = {0, 1, 1, 1};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+1));
+ }
+ {
+ int a[] = {1, 0, 0, 0};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+sa));
+ }
+ {
+ int a[] = {1, 0, 0, 1};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+3));
+ }
+ {
+ int a[] = {1, 0, 1, 0};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+2));
+ }
+ {
+ int a[] = {1, 0, 1, 1};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+2));
+ }
+ {
+ int a[] = {1, 1, 0, 0};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+sa));
+ }
+ {
+ int a[] = {1, 1, 0, 1};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+3));
+ }
+ {
+ int a[] = {1, 1, 1, 0};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+sa));
+ }
+ {
+ int a[] = {1, 1, 1, 1};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+sa));
+ }
+}
+
+int main()
+{
+ test<forward_iterator<const int*> >();
+ test<bidirectional_iterator<const int*> >();
+ test<random_access_iterator<const int*> >();
+ test<const int*>();
+}
diff --git a/test/std/algorithms/alg.sorting/alg.sort/nothing_to_do.pass.cpp b/test/std/algorithms/alg.sorting/alg.sort/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/algorithms/alg.sorting/alg.sort/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/algorithms/alg.sorting/alg.sort/partial.sort.copy/partial_sort_copy.pass.cpp b/test/std/algorithms/alg.sorting/alg.sort/partial.sort.copy/partial_sort_copy.pass.cpp
new file mode 100644
index 000000000000..5f298fde7b34
--- /dev/null
+++ b/test/std/algorithms/alg.sorting/alg.sort/partial.sort.copy/partial_sort_copy.pass.cpp
@@ -0,0 +1,86 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator InIter, RandomAccessIterator RAIter>
+// requires ShuffleIterator<RAIter>
+// && OutputIterator<RAIter, InIter::reference>
+// && HasLess<InIter::value_type, RAIter::value_type>
+// && LessThanComparable<RAIter::value_type>
+// RAIter
+// partial_sort_copy(InIter first, InIter last, RAIter result_first, RAIter result_last);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter>
+void
+test_larger_sorts(unsigned N, unsigned M)
+{
+ int* input = new int[N];
+ int* output = new int[M];
+ for (int i = 0; i < N; ++i)
+ input[i] = i;
+ std::random_shuffle(input, input+N);
+ int* r = std::partial_sort_copy(Iter(input), Iter(input+N), output, output+M);
+ int* e = output + std::min(N, M);
+ assert(r == e);
+ int i = 0;
+ for (int* x = output; x < e; ++x, ++i)
+ assert(*x == i);
+ delete [] output;
+ delete [] input;
+}
+
+template <class Iter>
+void
+test_larger_sorts(unsigned N)
+{
+ test_larger_sorts<Iter>(N, 0);
+ test_larger_sorts<Iter>(N, 1);
+ test_larger_sorts<Iter>(N, 2);
+ test_larger_sorts<Iter>(N, 3);
+ test_larger_sorts<Iter>(N, N/2-1);
+ test_larger_sorts<Iter>(N, N/2);
+ test_larger_sorts<Iter>(N, N/2+1);
+ test_larger_sorts<Iter>(N, N-2);
+ test_larger_sorts<Iter>(N, N-1);
+ test_larger_sorts<Iter>(N, N);
+ test_larger_sorts<Iter>(N, N+1000);
+}
+
+template <class Iter>
+void
+test()
+{
+ test_larger_sorts<Iter>(0, 100);
+ test_larger_sorts<Iter>(10);
+ test_larger_sorts<Iter>(256);
+ test_larger_sorts<Iter>(257);
+ test_larger_sorts<Iter>(499);
+ test_larger_sorts<Iter>(500);
+ test_larger_sorts<Iter>(997);
+ test_larger_sorts<Iter>(1000);
+ test_larger_sorts<Iter>(1009);
+}
+
+int main()
+{
+ int i = 0;
+ std::partial_sort_copy(&i, &i, &i, &i+5);
+ assert(i == 0);
+ test<input_iterator<const int*> >();
+ test<forward_iterator<const int*> >();
+ test<bidirectional_iterator<const int*> >();
+ test<random_access_iterator<const int*> >();
+ test<const int*>();
+}
diff --git a/test/std/algorithms/alg.sorting/alg.sort/partial.sort.copy/partial_sort_copy_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.sort/partial.sort.copy/partial_sort_copy_comp.pass.cpp
new file mode 100644
index 000000000000..df8fb9eacacd
--- /dev/null
+++ b/test/std/algorithms/alg.sorting/alg.sort/partial.sort.copy/partial_sort_copy_comp.pass.cpp
@@ -0,0 +1,90 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator InIter, RandomAccessIterator RAIter, class Compare>
+// requires ShuffleIterator<RAIter>
+// && OutputIterator<RAIter, InIter::reference>
+// && Predicate<Compare, InIter::value_type, RAIter::value_type>
+// && StrictWeakOrder<Compare, RAIter::value_type>}
+// && CopyConstructible<Compare>
+// RAIter
+// partial_sort_copy(InIter first, InIter last,
+// RAIter result_first, RAIter result_last, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter>
+void
+test_larger_sorts(unsigned N, unsigned M)
+{
+ int* input = new int[N];
+ int* output = new int[M];
+ for (int i = 0; i < N; ++i)
+ input[i] = i;
+ std::random_shuffle(input, input+N);
+ int* r = std::partial_sort_copy(Iter(input), Iter(input+N), output, output+M,
+ std::greater<int>());
+ int* e = output + std::min(N, M);
+ assert(r == e);
+ int i = 0;
+ for (int* x = output; x < e; ++x, ++i)
+ assert(*x == N-i-1);
+ delete [] output;
+ delete [] input;
+}
+
+template <class Iter>
+void
+test_larger_sorts(unsigned N)
+{
+ test_larger_sorts<Iter>(N, 0);
+ test_larger_sorts<Iter>(N, 1);
+ test_larger_sorts<Iter>(N, 2);
+ test_larger_sorts<Iter>(N, 3);
+ test_larger_sorts<Iter>(N, N/2-1);
+ test_larger_sorts<Iter>(N, N/2);
+ test_larger_sorts<Iter>(N, N/2+1);
+ test_larger_sorts<Iter>(N, N-2);
+ test_larger_sorts<Iter>(N, N-1);
+ test_larger_sorts<Iter>(N, N);
+ test_larger_sorts<Iter>(N, N+1000);
+}
+
+template <class Iter>
+void
+test()
+{
+ test_larger_sorts<Iter>(0, 100);
+ test_larger_sorts<Iter>(10);
+ test_larger_sorts<Iter>(256);
+ test_larger_sorts<Iter>(257);
+ test_larger_sorts<Iter>(499);
+ test_larger_sorts<Iter>(500);
+ test_larger_sorts<Iter>(997);
+ test_larger_sorts<Iter>(1000);
+ test_larger_sorts<Iter>(1009);
+}
+
+int main()
+{
+ int i = 0;
+ std::partial_sort_copy(&i, &i, &i, &i+5);
+ assert(i == 0);
+ test<input_iterator<const int*> >();
+ test<forward_iterator<const int*> >();
+ test<bidirectional_iterator<const int*> >();
+ test<random_access_iterator<const int*> >();
+ test<const int*>();
+}
diff --git a/test/std/algorithms/alg.sorting/alg.sort/partial.sort/partial_sort.pass.cpp b/test/std/algorithms/alg.sorting/alg.sort/partial.sort/partial_sort.pass.cpp
new file mode 100644
index 000000000000..7bb43461cba4
--- /dev/null
+++ b/test/std/algorithms/alg.sorting/alg.sort/partial.sort/partial_sort.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<RandomAccessIterator Iter>
+// requires ShuffleIterator<Iter>
+// && LessThanComparable<Iter::value_type>
+// void
+// partial_sort(Iter first, Iter middle, Iter last);
+
+#include <algorithm>
+#include <cassert>
+
+void
+test_larger_sorts(unsigned N, unsigned M)
+{
+ assert(N != 0);
+ int* array = new int[N];
+ for (int i = 0; i < N; ++i)
+ array[i] = i;
+ std::random_shuffle(array, array+N);
+ std::partial_sort(array, array+M, array+N);
+ for (int i = 0; i < M; ++i)
+ assert(array[i] == i);
+ delete [] array;
+}
+
+void
+test_larger_sorts(unsigned N)
+{
+ test_larger_sorts(N, 0);
+ test_larger_sorts(N, 1);
+ test_larger_sorts(N, 2);
+ test_larger_sorts(N, 3);
+ test_larger_sorts(N, N/2-1);
+ test_larger_sorts(N, N/2);
+ test_larger_sorts(N, N/2+1);
+ test_larger_sorts(N, N-2);
+ test_larger_sorts(N, N-1);
+ test_larger_sorts(N, N);
+}
+
+int main()
+{
+ int i = 0;
+ std::partial_sort(&i, &i, &i);
+ assert(i == 0);
+ test_larger_sorts(10);
+ test_larger_sorts(256);
+ test_larger_sorts(257);
+ test_larger_sorts(499);
+ test_larger_sorts(500);
+ test_larger_sorts(997);
+ test_larger_sorts(1000);
+ test_larger_sorts(1009);
+}
diff --git a/test/std/algorithms/alg.sorting/alg.sort/partial.sort/partial_sort_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.sort/partial.sort/partial_sort_comp.pass.cpp
new file mode 100644
index 000000000000..d822f6c388c1
--- /dev/null
+++ b/test/std/algorithms/alg.sorting/alg.sort/partial.sort/partial_sort_comp.pass.cpp
@@ -0,0 +1,87 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<RandomAccessIterator Iter, StrictWeakOrder<auto, Iter::value_type> Compare>
+// requires ShuffleIterator<Iter>
+// && CopyConstructible<Compare>
+// void
+// partial_sort(Iter first, Iter middle, Iter last, Compare comp);
+
+#include <algorithm>
+#include <vector>
+#include <functional>
+#include <cassert>
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#include <memory>
+
+struct indirect_less
+{
+ template <class P>
+ bool operator()(const P& x, const P& y)
+ {return *x < *y;}
+};
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+void
+test_larger_sorts(unsigned N, unsigned M)
+{
+ assert(N != 0);
+ int* array = new int[N];
+ for (int i = 0; i < N; ++i)
+ array[i] = i;
+ std::random_shuffle(array, array+N);
+ std::partial_sort(array, array+M, array+N, std::greater<int>());
+ for (int i = 0; i < M; ++i)
+ assert(array[i] == N-i-1);
+ delete [] array;
+}
+
+void
+test_larger_sorts(unsigned N)
+{
+ test_larger_sorts(N, 0);
+ test_larger_sorts(N, 1);
+ test_larger_sorts(N, 2);
+ test_larger_sorts(N, 3);
+ test_larger_sorts(N, N/2-1);
+ test_larger_sorts(N, N/2);
+ test_larger_sorts(N, N/2+1);
+ test_larger_sorts(N, N-2);
+ test_larger_sorts(N, N-1);
+ test_larger_sorts(N, N);
+}
+
+int main()
+{
+ int i = 0;
+ std::partial_sort(&i, &i, &i);
+ assert(i == 0);
+ test_larger_sorts(10);
+ test_larger_sorts(256);
+ test_larger_sorts(257);
+ test_larger_sorts(499);
+ test_larger_sorts(500);
+ test_larger_sorts(997);
+ test_larger_sorts(1000);
+ test_larger_sorts(1009);
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::vector<std::unique_ptr<int> > v(1000);
+ for (int i = 0; i < v.size(); ++i)
+ v[i].reset(new int(i));
+ std::partial_sort(v.begin(), v.begin() + v.size()/2, v.end(), indirect_less());
+ for (int i = 0; i < v.size()/2; ++i)
+ assert(*v[i] == i);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/algorithms/alg.sorting/alg.sort/sort/sort.pass.cpp b/test/std/algorithms/alg.sorting/alg.sort/sort/sort.pass.cpp
new file mode 100644
index 000000000000..2ea697a63b2a
--- /dev/null
+++ b/test/std/algorithms/alg.sorting/alg.sort/sort/sort.pass.cpp
@@ -0,0 +1,150 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<RandomAccessIterator Iter>
+// requires ShuffleIterator<Iter>
+// && LessThanComparable<Iter::value_type>
+// void
+// sort(Iter first, Iter last);
+
+#include <algorithm>
+#include <cassert>
+
+template <class RI>
+void
+test_sort_helper(RI f, RI l)
+{
+ typedef typename std::iterator_traits<RI>::value_type value_type;
+ if (f != l)
+ {
+ long len = l - f;
+ value_type* save(new value_type[len]);
+ do
+ {
+ std::copy(f, l, save);
+ std::sort(save, save+len);
+ assert(std::is_sorted(save, save+len));
+ } while (std::next_permutation(f, l));
+ delete [] save;
+ }
+}
+
+template <class RI>
+void
+test_sort_driver_driver(RI f, RI l, int start, RI real_last)
+{
+ for (RI i = l; i > f + start;)
+ {
+ *--i = start;
+ if (f == i)
+ {
+ test_sort_helper(f, real_last);
+ }
+ if (start > 0)
+ test_sort_driver_driver(f, i, start-1, real_last);
+ }
+}
+
+template <class RI>
+void
+test_sort_driver(RI f, RI l, int start)
+{
+ test_sort_driver_driver(f, l, start, l);
+}
+
+template <unsigned sa>
+void
+test_sort_()
+{
+ int ia[sa];
+ for (int i = 0; i < sa; ++i)
+ {
+ test_sort_driver(ia, ia+sa, i);
+ }
+}
+
+void
+test_larger_sorts(unsigned N, unsigned M)
+{
+ assert(N != 0);
+ assert(M != 0);
+ // create array length N filled with M different numbers
+ int* array = new int[N];
+ int x = 0;
+ for (int i = 0; i < N; ++i)
+ {
+ array[i] = x;
+ if (++x == M)
+ x = 0;
+ }
+ // test saw tooth pattern
+ std::sort(array, array+N);
+ assert(std::is_sorted(array, array+N));
+ // test random pattern
+ std::random_shuffle(array, array+N);
+ std::sort(array, array+N);
+ assert(std::is_sorted(array, array+N));
+ // test sorted pattern
+ std::sort(array, array+N);
+ assert(std::is_sorted(array, array+N));
+ // test reverse sorted pattern
+ std::reverse(array, array+N);
+ std::sort(array, array+N);
+ assert(std::is_sorted(array, array+N));
+ // test swap ranges 2 pattern
+ std::swap_ranges(array, array+N/2, array+N/2);
+ std::sort(array, array+N);
+ assert(std::is_sorted(array, array+N));
+ // test reverse swap ranges 2 pattern
+ std::reverse(array, array+N);
+ std::swap_ranges(array, array+N/2, array+N/2);
+ std::sort(array, array+N);
+ assert(std::is_sorted(array, array+N));
+ delete [] array;
+}
+
+void
+test_larger_sorts(unsigned N)
+{
+ test_larger_sorts(N, 1);
+ test_larger_sorts(N, 2);
+ test_larger_sorts(N, 3);
+ test_larger_sorts(N, N/2-1);
+ test_larger_sorts(N, N/2);
+ test_larger_sorts(N, N/2+1);
+ test_larger_sorts(N, N-2);
+ test_larger_sorts(N, N-1);
+ test_larger_sorts(N, N);
+}
+
+int main()
+{
+ // test null range
+ int d = 0;
+ std::sort(&d, &d);
+ // exhaustively test all possibilities up to length 8
+ test_sort_<1>();
+ test_sort_<2>();
+ test_sort_<3>();
+ test_sort_<4>();
+ test_sort_<5>();
+ test_sort_<6>();
+ test_sort_<7>();
+ test_sort_<8>();
+
+ test_larger_sorts(256);
+ test_larger_sorts(257);
+ test_larger_sorts(499);
+ test_larger_sorts(500);
+ test_larger_sorts(997);
+ test_larger_sorts(1000);
+ test_larger_sorts(1009);
+}
diff --git a/test/std/algorithms/alg.sorting/alg.sort/sort/sort_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.sort/sort/sort_comp.pass.cpp
new file mode 100644
index 000000000000..d6c4f0467844
--- /dev/null
+++ b/test/std/algorithms/alg.sorting/alg.sort/sort/sort_comp.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<RandomAccessIterator Iter, StrictWeakOrder<auto, Iter::value_type> Compare>
+// requires ShuffleIterator<Iter>
+// && CopyConstructible<Compare>
+// void
+// sort(Iter first, Iter last, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <vector>
+#include <cassert>
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#include <memory>
+
+struct indirect_less
+{
+ template <class P>
+ bool operator()(const P& x, const P& y)
+ {return *x < *y;}
+};
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+ {
+ std::vector<int> v(1000);
+ for (int i = 0; i < v.size(); ++i)
+ v[i] = i;
+ std::sort(v.begin(), v.end(), std::greater<int>());
+ std::reverse(v.begin(), v.end());
+ assert(std::is_sorted(v.begin(), v.end()));
+ }
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::vector<std::unique_ptr<int> > v(1000);
+ for (int i = 0; i < v.size(); ++i)
+ v[i].reset(new int(i));
+ std::sort(v.begin(), v.end(), indirect_less());
+ assert(std::is_sorted(v.begin(), v.end(), indirect_less()));
+ assert(*v[0] == 0);
+ assert(*v[1] == 1);
+ assert(*v[2] == 2);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/algorithms/alg.sorting/alg.sort/stable.sort/stable_sort.pass.cpp b/test/std/algorithms/alg.sorting/alg.sort/stable.sort/stable_sort.pass.cpp
new file mode 100644
index 000000000000..5faa1682135d
--- /dev/null
+++ b/test/std/algorithms/alg.sorting/alg.sort/stable.sort/stable_sort.pass.cpp
@@ -0,0 +1,150 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<RandomAccessIterator Iter>
+// requires ShuffleIterator<Iter>
+// && LessThanComparable<Iter::value_type>
+// void
+// stable_sort(Iter first, Iter last);
+
+#include <algorithm>
+#include <cassert>
+
+template <class RI>
+void
+test_sort_helper(RI f, RI l)
+{
+ typedef typename std::iterator_traits<RI>::value_type value_type;
+ if (f != l)
+ {
+ long len = l - f;
+ value_type* save(new value_type[len]);
+ do
+ {
+ std::copy(f, l, save);
+ std::stable_sort(save, save+len);
+ assert(std::is_sorted(save, save+len));
+ } while (std::next_permutation(f, l));
+ delete [] save;
+ }
+}
+
+template <class RI>
+void
+test_sort_driver_driver(RI f, RI l, int start, RI real_last)
+{
+ for (RI i = l; i > f + start;)
+ {
+ *--i = start;
+ if (f == i)
+ {
+ test_sort_helper(f, real_last);
+ }
+ if (start > 0)
+ test_sort_driver_driver(f, i, start-1, real_last);
+ }
+}
+
+template <class RI>
+void
+test_sort_driver(RI f, RI l, int start)
+{
+ test_sort_driver_driver(f, l, start, l);
+}
+
+template <unsigned sa>
+void
+test_sort_()
+{
+ int ia[sa];
+ for (int i = 0; i < sa; ++i)
+ {
+ test_sort_driver(ia, ia+sa, i);
+ }
+}
+
+void
+test_larger_sorts(unsigned N, unsigned M)
+{
+ assert(N != 0);
+ assert(M != 0);
+ // create array length N filled with M different numbers
+ int* array = new int[N];
+ int x = 0;
+ for (int i = 0; i < N; ++i)
+ {
+ array[i] = x;
+ if (++x == M)
+ x = 0;
+ }
+ // test saw tooth pattern
+ std::stable_sort(array, array+N);
+ assert(std::is_sorted(array, array+N));
+ // test random pattern
+ std::random_shuffle(array, array+N);
+ std::stable_sort(array, array+N);
+ assert(std::is_sorted(array, array+N));
+ // test sorted pattern
+ std::stable_sort(array, array+N);
+ assert(std::is_sorted(array, array+N));
+ // test reverse sorted pattern
+ std::reverse(array, array+N);
+ std::stable_sort(array, array+N);
+ assert(std::is_sorted(array, array+N));
+ // test swap ranges 2 pattern
+ std::swap_ranges(array, array+N/2, array+N/2);
+ std::stable_sort(array, array+N);
+ assert(std::is_sorted(array, array+N));
+ // test reverse swap ranges 2 pattern
+ std::reverse(array, array+N);
+ std::swap_ranges(array, array+N/2, array+N/2);
+ std::stable_sort(array, array+N);
+ assert(std::is_sorted(array, array+N));
+ delete [] array;
+}
+
+void
+test_larger_sorts(unsigned N)
+{
+ test_larger_sorts(N, 1);
+ test_larger_sorts(N, 2);
+ test_larger_sorts(N, 3);
+ test_larger_sorts(N, N/2-1);
+ test_larger_sorts(N, N/2);
+ test_larger_sorts(N, N/2+1);
+ test_larger_sorts(N, N-2);
+ test_larger_sorts(N, N-1);
+ test_larger_sorts(N, N);
+}
+
+int main()
+{
+ // test null range
+ int d = 0;
+ std::stable_sort(&d, &d);
+ // exhaustively test all possibilities up to length 8
+ test_sort_<1>();
+ test_sort_<2>();
+ test_sort_<3>();
+ test_sort_<4>();
+ test_sort_<5>();
+ test_sort_<6>();
+ test_sort_<7>();
+ test_sort_<8>();
+
+ test_larger_sorts(256);
+ test_larger_sorts(257);
+ test_larger_sorts(499);
+ test_larger_sorts(500);
+ test_larger_sorts(997);
+ test_larger_sorts(1000);
+ test_larger_sorts(1009);
+}
diff --git a/test/std/algorithms/alg.sorting/alg.sort/stable.sort/stable_sort_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.sort/stable.sort/stable_sort_comp.pass.cpp
new file mode 100644
index 000000000000..68e817ebeb3b
--- /dev/null
+++ b/test/std/algorithms/alg.sorting/alg.sort/stable.sort/stable_sort_comp.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<RandomAccessIterator Iter, StrictWeakOrder<auto, Iter::value_type> Compare>
+// requires ShuffleIterator<Iter>
+// && CopyConstructible<Compare>
+// void
+// stable_sort(Iter first, Iter last, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <vector>
+#include <cassert>
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#include <memory>
+
+struct indirect_less
+{
+ template <class P>
+ bool operator()(const P& x, const P& y)
+ {return *x < *y;}
+};
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+struct first_only
+{
+ bool operator()(const std::pair<int, int>& x, const std::pair<int, int>& y)
+ {
+ return x.first < y.first;
+ }
+};
+
+void test()
+{
+ typedef std::pair<int, int> P;
+ const int N = 1000;
+ const int M = 10;
+ std::vector<P> v(N);
+ int x = 0;
+ int ver = 0;
+ for (int i = 0; i < N; ++i)
+ {
+ v[i] = P(x, ver);
+ if (++x == M)
+ {
+ x = 0;
+ ++ver;
+ }
+ }
+ for (int i = 0; i < N - M; i += M)
+ {
+ std::random_shuffle(v.begin() + i, v.begin() + i + M);
+ }
+ std::stable_sort(v.begin(), v.end(), first_only());
+ assert(std::is_sorted(v.begin(), v.end()));
+}
+
+int main()
+{
+ test();
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::vector<std::unique_ptr<int> > v(1000);
+ for (int i = 0; i < v.size(); ++i)
+ v[i].reset(new int(i));
+ std::stable_sort(v.begin(), v.end(), indirect_less());
+ assert(std::is_sorted(v.begin(), v.end(), indirect_less()));
+ assert(*v[0] == 0);
+ assert(*v[1] == 1);
+ assert(*v[2] == 2);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/algorithms/alg.sorting/nothing_to_do.pass.cpp b/test/std/algorithms/alg.sorting/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/algorithms/alg.sorting/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/algorithms/algorithms.general/nothing_to_do.pass.cpp b/test/std/algorithms/algorithms.general/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/algorithms/algorithms.general/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/algorithms/version.pass.cpp b/test/std/algorithms/version.pass.cpp
new file mode 100644
index 000000000000..20f0637e641b
--- /dev/null
+++ b/test/std/algorithms/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+#include <algorithm>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/atomics/atomics.fences/atomic_signal_fence.pass.cpp b/test/std/atomics/atomics.fences/atomic_signal_fence.pass.cpp
new file mode 100644
index 000000000000..aec060c4d5f2
--- /dev/null
+++ b/test/std/atomics/atomics.fences/atomic_signal_fence.pass.cpp
@@ -0,0 +1,21 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <atomic>
+
+// void atomic_signal_fence(memory_order m);
+
+#include <atomic>
+
+int main()
+{
+ std::atomic_signal_fence(std::memory_order_seq_cst);
+}
diff --git a/test/std/atomics/atomics.fences/atomic_thread_fence.pass.cpp b/test/std/atomics/atomics.fences/atomic_thread_fence.pass.cpp
new file mode 100644
index 000000000000..4f3b0e330e3e
--- /dev/null
+++ b/test/std/atomics/atomics.fences/atomic_thread_fence.pass.cpp
@@ -0,0 +1,21 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <atomic>
+
+// void atomic_thread_fence(memory_order m);
+
+#include <atomic>
+
+int main()
+{
+ std::atomic_thread_fence(std::memory_order_seq_cst);
+}
diff --git a/test/std/atomics/atomics.flag/atomic_flag_clear.pass.cpp b/test/std/atomics/atomics.flag/atomic_flag_clear.pass.cpp
new file mode 100644
index 000000000000..8a60f8196dab
--- /dev/null
+++ b/test/std/atomics/atomics.flag/atomic_flag_clear.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <atomic>
+
+// struct atomic_flag
+
+// void atomic_flag_clear(volatile atomic_flag*);
+// void atomic_flag_clear(atomic_flag*);
+
+#include <atomic>
+#include <cassert>
+
+int main()
+{
+ {
+ std::atomic_flag f = ATOMIC_FLAG_INIT;
+ f.test_and_set();
+ atomic_flag_clear(&f);
+ assert(f.test_and_set() == 0);
+ }
+ {
+ volatile std::atomic_flag f = ATOMIC_FLAG_INIT;
+ f.test_and_set();
+ atomic_flag_clear(&f);
+ assert(f.test_and_set() == 0);
+ }
+}
diff --git a/test/std/atomics/atomics.flag/atomic_flag_clear_explicit.pass.cpp b/test/std/atomics/atomics.flag/atomic_flag_clear_explicit.pass.cpp
new file mode 100644
index 000000000000..92e57ecc03f8
--- /dev/null
+++ b/test/std/atomics/atomics.flag/atomic_flag_clear_explicit.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <atomic>
+
+// struct atomic_flag
+
+// void atomic_flag_clear_explicit(volatile atomic_flag*, memory_order);
+// void atomic_flag_clear_explicit(atomic_flag*, memory_order);
+
+#include <atomic>
+#include <cassert>
+
+int main()
+{
+ {
+ std::atomic_flag f = ATOMIC_FLAG_INIT;
+ f.test_and_set();
+ atomic_flag_clear_explicit(&f, std::memory_order_relaxed);
+ assert(f.test_and_set() == 0);
+ }
+ {
+ std::atomic_flag f = ATOMIC_FLAG_INIT;
+ f.test_and_set();
+ atomic_flag_clear_explicit(&f, std::memory_order_release);
+ assert(f.test_and_set() == 0);
+ }
+ {
+ std::atomic_flag f = ATOMIC_FLAG_INIT;
+ f.test_and_set();
+ atomic_flag_clear_explicit(&f, std::memory_order_seq_cst);
+ assert(f.test_and_set() == 0);
+ }
+ {
+ volatile std::atomic_flag f = ATOMIC_FLAG_INIT;
+ f.test_and_set();
+ atomic_flag_clear_explicit(&f, std::memory_order_relaxed);
+ assert(f.test_and_set() == 0);
+ }
+ {
+ volatile std::atomic_flag f = ATOMIC_FLAG_INIT;
+ f.test_and_set();
+ atomic_flag_clear_explicit(&f, std::memory_order_release);
+ assert(f.test_and_set() == 0);
+ }
+ {
+ volatile std::atomic_flag f = ATOMIC_FLAG_INIT;
+ f.test_and_set();
+ atomic_flag_clear_explicit(&f, std::memory_order_seq_cst);
+ assert(f.test_and_set() == 0);
+ }
+}
diff --git a/test/std/atomics/atomics.flag/atomic_flag_test_and_set.pass.cpp b/test/std/atomics/atomics.flag/atomic_flag_test_and_set.pass.cpp
new file mode 100644
index 000000000000..ae82df919549
--- /dev/null
+++ b/test/std/atomics/atomics.flag/atomic_flag_test_and_set.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <atomic>
+
+// struct atomic_flag
+
+// bool atomic_flag_test_and_set(volatile atomic_flag*);
+// bool atomic_flag_test_and_set(atomic_flag*);
+
+#include <atomic>
+#include <cassert>
+
+int main()
+{
+ {
+ std::atomic_flag f;
+ f.clear();
+ assert(atomic_flag_test_and_set(&f) == 0);
+ assert(f.test_and_set() == 1);
+ }
+ {
+ volatile std::atomic_flag f;
+ f.clear();
+ assert(atomic_flag_test_and_set(&f) == 0);
+ assert(f.test_and_set() == 1);
+ }
+}
diff --git a/test/std/atomics/atomics.flag/atomic_flag_test_and_set_explicit.pass.cpp b/test/std/atomics/atomics.flag/atomic_flag_test_and_set_explicit.pass.cpp
new file mode 100644
index 000000000000..154850697c20
--- /dev/null
+++ b/test/std/atomics/atomics.flag/atomic_flag_test_and_set_explicit.pass.cpp
@@ -0,0 +1,96 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <atomic>
+
+// struct atomic_flag
+
+// bool atomic_flag_test_and_set_explicit(volatile atomic_flag*, memory_order);
+// bool atomic_flag_test_and_set_explicit(atomic_flag*, memory_order);
+
+#include <atomic>
+#include <cassert>
+
+int main()
+{
+ {
+ std::atomic_flag f;
+ f.clear();
+ assert(atomic_flag_test_and_set_explicit(&f, std::memory_order_relaxed) == 0);
+ assert(f.test_and_set() == 1);
+ }
+ {
+ std::atomic_flag f;
+ f.clear();
+ assert(atomic_flag_test_and_set_explicit(&f, std::memory_order_consume) == 0);
+ assert(f.test_and_set() == 1);
+ }
+ {
+ std::atomic_flag f;
+ f.clear();
+ assert(atomic_flag_test_and_set_explicit(&f, std::memory_order_acquire) == 0);
+ assert(f.test_and_set() == 1);
+ }
+ {
+ std::atomic_flag f;
+ f.clear();
+ assert(atomic_flag_test_and_set_explicit(&f, std::memory_order_release) == 0);
+ assert(f.test_and_set() == 1);
+ }
+ {
+ std::atomic_flag f;
+ f.clear();
+ assert(atomic_flag_test_and_set_explicit(&f, std::memory_order_acq_rel) == 0);
+ assert(f.test_and_set() == 1);
+ }
+ {
+ std::atomic_flag f;
+ f.clear();
+ assert(atomic_flag_test_and_set_explicit(&f, std::memory_order_seq_cst) == 0);
+ assert(f.test_and_set() == 1);
+ }
+ {
+ volatile std::atomic_flag f;
+ f.clear();
+ assert(atomic_flag_test_and_set_explicit(&f, std::memory_order_relaxed) == 0);
+ assert(f.test_and_set() == 1);
+ }
+ {
+ volatile std::atomic_flag f;
+ f.clear();
+ assert(atomic_flag_test_and_set_explicit(&f, std::memory_order_consume) == 0);
+ assert(f.test_and_set() == 1);
+ }
+ {
+ volatile std::atomic_flag f;
+ f.clear();
+ assert(atomic_flag_test_and_set_explicit(&f, std::memory_order_acquire) == 0);
+ assert(f.test_and_set() == 1);
+ }
+ {
+ volatile std::atomic_flag f;
+ f.clear();
+ assert(atomic_flag_test_and_set_explicit(&f, std::memory_order_release) == 0);
+ assert(f.test_and_set() == 1);
+ }
+ {
+ volatile std::atomic_flag f;
+ f.clear();
+ assert(atomic_flag_test_and_set_explicit(&f, std::memory_order_acq_rel) == 0);
+ assert(f.test_and_set() == 1);
+ }
+ {
+ volatile std::atomic_flag f;
+ f.clear();
+ assert(atomic_flag_test_and_set_explicit(&f, std::memory_order_seq_cst) == 0);
+ assert(f.test_and_set() == 1);
+ }
+}
diff --git a/test/std/atomics/atomics.flag/clear.pass.cpp b/test/std/atomics/atomics.flag/clear.pass.cpp
new file mode 100644
index 000000000000..7c9362680bba
--- /dev/null
+++ b/test/std/atomics/atomics.flag/clear.pass.cpp
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <atomic>
+
+// struct atomic_flag
+
+// void clear(memory_order = memory_order_seq_cst);
+// void clear(memory_order = memory_order_seq_cst) volatile;
+
+#include <atomic>
+#include <cassert>
+
+int main()
+{
+ {
+ std::atomic_flag f = ATOMIC_FLAG_INIT;
+ f.test_and_set();
+ f.clear();
+ assert(f.test_and_set() == 0);
+ }
+ {
+ std::atomic_flag f = ATOMIC_FLAG_INIT;
+ f.test_and_set();
+ f.clear(std::memory_order_relaxed);
+ assert(f.test_and_set() == 0);
+ }
+ {
+ std::atomic_flag f = ATOMIC_FLAG_INIT;
+ f.test_and_set();
+ f.clear(std::memory_order_release);
+ assert(f.test_and_set() == 0);
+ }
+ {
+ std::atomic_flag f = ATOMIC_FLAG_INIT;
+ f.test_and_set();
+ f.clear(std::memory_order_seq_cst);
+ assert(f.test_and_set() == 0);
+ }
+ {
+ volatile std::atomic_flag f = ATOMIC_FLAG_INIT;
+ f.test_and_set();
+ f.clear();
+ assert(f.test_and_set() == 0);
+ }
+ {
+ volatile std::atomic_flag f = ATOMIC_FLAG_INIT;
+ f.test_and_set();
+ f.clear(std::memory_order_relaxed);
+ assert(f.test_and_set() == 0);
+ }
+ {
+ volatile std::atomic_flag f = ATOMIC_FLAG_INIT;
+ f.test_and_set();
+ f.clear(std::memory_order_release);
+ assert(f.test_and_set() == 0);
+ }
+ {
+ volatile std::atomic_flag f = ATOMIC_FLAG_INIT;
+ f.test_and_set();
+ f.clear(std::memory_order_seq_cst);
+ assert(f.test_and_set() == 0);
+ }
+}
diff --git a/test/std/atomics/atomics.flag/copy_assign.fail.cpp b/test/std/atomics/atomics.flag/copy_assign.fail.cpp
new file mode 100644
index 000000000000..762e3a895441
--- /dev/null
+++ b/test/std/atomics/atomics.flag/copy_assign.fail.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <atomic>
+
+// struct atomic_flag
+
+// atomic_flag& operator=(const atomic_flag&) = delete;
+
+#include <atomic>
+#include <cassert>
+
+int main()
+{
+ std::atomic_flag f0;
+ std::atomic_flag f;
+ f = f0;
+}
diff --git a/test/std/atomics/atomics.flag/copy_ctor.fail.cpp b/test/std/atomics/atomics.flag/copy_ctor.fail.cpp
new file mode 100644
index 000000000000..8d6a86537537
--- /dev/null
+++ b/test/std/atomics/atomics.flag/copy_ctor.fail.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <atomic>
+
+// struct atomic_flag
+
+// atomic_flag(const atomic_flag&) = delete;
+
+#include <atomic>
+#include <cassert>
+
+int main()
+{
+ std::atomic_flag f0;
+ std::atomic_flag f(f0);
+}
diff --git a/test/std/atomics/atomics.flag/copy_volatile_assign.fail.cpp b/test/std/atomics/atomics.flag/copy_volatile_assign.fail.cpp
new file mode 100644
index 000000000000..c58c75554391
--- /dev/null
+++ b/test/std/atomics/atomics.flag/copy_volatile_assign.fail.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <atomic>
+
+// struct atomic_flag
+
+// atomic_flag& operator=(const atomic_flag&) = delete;
+
+#include <atomic>
+#include <cassert>
+
+int main()
+{
+ std::atomic_flag f0;
+ volatile std::atomic_flag f;
+ f = f0;
+}
diff --git a/test/std/atomics/atomics.flag/default.pass.cpp b/test/std/atomics/atomics.flag/default.pass.cpp
new file mode 100644
index 000000000000..45f5e709245b
--- /dev/null
+++ b/test/std/atomics/atomics.flag/default.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <atomic>
+
+// struct atomic_flag
+
+// atomic_flag() = default;
+
+#include <atomic>
+#include <new>
+#include <cassert>
+
+int main()
+{
+ std::atomic_flag f;
+
+ {
+ typedef std::atomic_flag A;
+ _ALIGNAS_TYPE(A) char storage[sizeof(A)] = {1};
+ A& zero = *new (storage) A();
+ assert(!zero.test_and_set());
+ zero.~A();
+ }
+}
diff --git a/test/std/atomics/atomics.flag/init.pass.cpp b/test/std/atomics/atomics.flag/init.pass.cpp
new file mode 100644
index 000000000000..c90509d8fbb5
--- /dev/null
+++ b/test/std/atomics/atomics.flag/init.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <atomic>
+
+// struct atomic_flag
+
+// atomic_flag() = ATOMIC_FLAG_INIT;
+
+#include <atomic>
+#include <cassert>
+
+int main()
+{
+ std::atomic_flag f = ATOMIC_FLAG_INIT;
+ assert(f.test_and_set() == 0);
+}
diff --git a/test/std/atomics/atomics.flag/test_and_set.pass.cpp b/test/std/atomics/atomics.flag/test_and_set.pass.cpp
new file mode 100644
index 000000000000..210ba2050bb5
--- /dev/null
+++ b/test/std/atomics/atomics.flag/test_and_set.pass.cpp
@@ -0,0 +1,108 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <atomic>
+
+// struct atomic_flag
+
+// bool test_and_set(memory_order = memory_order_seq_cst);
+// bool test_and_set(memory_order = memory_order_seq_cst) volatile;
+
+#include <atomic>
+#include <cassert>
+
+int main()
+{
+ {
+ std::atomic_flag f;
+ f.clear();
+ assert(f.test_and_set() == 0);
+ assert(f.test_and_set() == 1);
+ }
+ {
+ std::atomic_flag f;
+ f.clear();
+ assert(f.test_and_set(std::memory_order_relaxed) == 0);
+ assert(f.test_and_set(std::memory_order_relaxed) == 1);
+ }
+ {
+ std::atomic_flag f;
+ f.clear();
+ assert(f.test_and_set(std::memory_order_consume) == 0);
+ assert(f.test_and_set(std::memory_order_consume) == 1);
+ }
+ {
+ std::atomic_flag f;
+ f.clear();
+ assert(f.test_and_set(std::memory_order_acquire) == 0);
+ assert(f.test_and_set(std::memory_order_acquire) == 1);
+ }
+ {
+ std::atomic_flag f;
+ f.clear();
+ assert(f.test_and_set(std::memory_order_release) == 0);
+ assert(f.test_and_set(std::memory_order_release) == 1);
+ }
+ {
+ std::atomic_flag f;
+ f.clear();
+ assert(f.test_and_set(std::memory_order_acq_rel) == 0);
+ assert(f.test_and_set(std::memory_order_acq_rel) == 1);
+ }
+ {
+ std::atomic_flag f;
+ f.clear();
+ assert(f.test_and_set(std::memory_order_seq_cst) == 0);
+ assert(f.test_and_set(std::memory_order_seq_cst) == 1);
+ }
+ {
+ volatile std::atomic_flag f;
+ f.clear();
+ assert(f.test_and_set() == 0);
+ assert(f.test_and_set() == 1);
+ }
+ {
+ volatile std::atomic_flag f;
+ f.clear();
+ assert(f.test_and_set(std::memory_order_relaxed) == 0);
+ assert(f.test_and_set(std::memory_order_relaxed) == 1);
+ }
+ {
+ volatile std::atomic_flag f;
+ f.clear();
+ assert(f.test_and_set(std::memory_order_consume) == 0);
+ assert(f.test_and_set(std::memory_order_consume) == 1);
+ }
+ {
+ volatile std::atomic_flag f;
+ f.clear();
+ assert(f.test_and_set(std::memory_order_acquire) == 0);
+ assert(f.test_and_set(std::memory_order_acquire) == 1);
+ }
+ {
+ volatile std::atomic_flag f;
+ f.clear();
+ assert(f.test_and_set(std::memory_order_release) == 0);
+ assert(f.test_and_set(std::memory_order_release) == 1);
+ }
+ {
+ volatile std::atomic_flag f;
+ f.clear();
+ assert(f.test_and_set(std::memory_order_acq_rel) == 0);
+ assert(f.test_and_set(std::memory_order_acq_rel) == 1);
+ }
+ {
+ volatile std::atomic_flag f;
+ f.clear();
+ assert(f.test_and_set(std::memory_order_seq_cst) == 0);
+ assert(f.test_and_set(std::memory_order_seq_cst) == 1);
+ }
+}
diff --git a/test/std/atomics/atomics.general/nothing_to_do.pass.cpp b/test/std/atomics/atomics.general/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..9a59227abdd9
--- /dev/null
+++ b/test/std/atomics/atomics.general/nothing_to_do.pass.cpp
@@ -0,0 +1,13 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/atomics/atomics.general/replace_failure_order.pass.cpp b/test/std/atomics/atomics.general/replace_failure_order.pass.cpp
new file mode 100644
index 000000000000..cd0683d6887d
--- /dev/null
+++ b/test/std/atomics/atomics.general/replace_failure_order.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: libcpp-has-no-threads
+
+// This test verifies behavior specified by [atomics.types.operations.req]/21:
+//
+// When only one memory_order argument is supplied, the value of success is
+// order, and the value of failure is order except that a value of
+// memory_order_acq_rel shall be replaced by the value memory_order_acquire
+// and a value of memory_order_release shall be replaced by the value
+// memory_order_relaxed.
+//
+// Clang's atomic intrinsics do this for us, but GCC's do not. We don't actually
+// have visibility to see what these memory orders are lowered to, but we can at
+// least check that they are lowered at all (otherwise there is a compile
+// failure with GCC).
+
+#include <atomic>
+
+int main() {
+ std::atomic<int> i;
+ volatile std::atomic<int> v;
+ int exp = 0;
+
+ i.compare_exchange_weak(exp, 0, std::memory_order_acq_rel);
+ i.compare_exchange_weak(exp, 0, std::memory_order_release);
+ i.compare_exchange_strong(exp, 0, std::memory_order_acq_rel);
+ i.compare_exchange_strong(exp, 0, std::memory_order_release);
+
+ v.compare_exchange_weak(exp, 0, std::memory_order_acq_rel);
+ v.compare_exchange_weak(exp, 0, std::memory_order_release);
+ v.compare_exchange_strong(exp, 0, std::memory_order_acq_rel);
+ v.compare_exchange_strong(exp, 0, std::memory_order_release);
+
+ return 0;
+}
diff --git a/test/std/atomics/atomics.lockfree/lockfree.pass.cpp b/test/std/atomics/atomics.lockfree/lockfree.pass.cpp
new file mode 100644
index 000000000000..a975a69a66ff
--- /dev/null
+++ b/test/std/atomics/atomics.lockfree/lockfree.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <atomic>
+
+// #define ATOMIC_CHAR_LOCK_FREE unspecified
+// #define ATOMIC_CHAR16_T_LOCK_FREE unspecified
+// #define ATOMIC_CHAR32_T_LOCK_FREE unspecified
+// #define ATOMIC_WCHAR_T_LOCK_FREE unspecified
+// #define ATOMIC_SHORT_LOCK_FREE unspecified
+// #define ATOMIC_INT_LOCK_FREE unspecified
+// #define ATOMIC_LONG_LOCK_FREE unspecified
+// #define ATOMIC_LLONG_LOCK_FREE unspecified
+
+#include <atomic>
+#include <cassert>
+
+int main()
+{
+ assert(ATOMIC_CHAR_LOCK_FREE == 0 ||
+ ATOMIC_CHAR_LOCK_FREE == 1 ||
+ ATOMIC_CHAR_LOCK_FREE == 2);
+ assert(ATOMIC_CHAR16_T_LOCK_FREE == 0 ||
+ ATOMIC_CHAR16_T_LOCK_FREE == 1 ||
+ ATOMIC_CHAR16_T_LOCK_FREE == 2);
+ assert(ATOMIC_CHAR32_T_LOCK_FREE == 0 ||
+ ATOMIC_CHAR32_T_LOCK_FREE == 1 ||
+ ATOMIC_CHAR32_T_LOCK_FREE == 2);
+ assert(ATOMIC_WCHAR_T_LOCK_FREE == 0 ||
+ ATOMIC_WCHAR_T_LOCK_FREE == 1 ||
+ ATOMIC_WCHAR_T_LOCK_FREE == 2);
+ assert(ATOMIC_SHORT_LOCK_FREE == 0 ||
+ ATOMIC_SHORT_LOCK_FREE == 1 ||
+ ATOMIC_SHORT_LOCK_FREE == 2);
+ assert(ATOMIC_INT_LOCK_FREE == 0 ||
+ ATOMIC_INT_LOCK_FREE == 1 ||
+ ATOMIC_INT_LOCK_FREE == 2);
+ assert(ATOMIC_LONG_LOCK_FREE == 0 ||
+ ATOMIC_LONG_LOCK_FREE == 1 ||
+ ATOMIC_LONG_LOCK_FREE == 2);
+ assert(ATOMIC_LLONG_LOCK_FREE == 0 ||
+ ATOMIC_LLONG_LOCK_FREE == 1 ||
+ ATOMIC_LLONG_LOCK_FREE == 2);
+}
diff --git a/test/std/atomics/atomics.order/kill_dependency.pass.cpp b/test/std/atomics/atomics.order/kill_dependency.pass.cpp
new file mode 100644
index 000000000000..0f0bafcbb0a0
--- /dev/null
+++ b/test/std/atomics/atomics.order/kill_dependency.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <atomic>
+
+// template <class T> T kill_dependency(T y);
+
+#include <atomic>
+#include <cassert>
+
+int main()
+{
+ assert(std::kill_dependency(5) == 5);
+ assert(std::kill_dependency(-5.5) == -5.5);
+}
diff --git a/test/std/atomics/atomics.order/memory_order.pass.cpp b/test/std/atomics/atomics.order/memory_order.pass.cpp
new file mode 100644
index 000000000000..e734a4c7597f
--- /dev/null
+++ b/test/std/atomics/atomics.order/memory_order.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <atomic>
+
+// typedef enum memory_order
+// {
+// memory_order_relaxed, memory_order_consume, memory_order_acquire,
+// memory_order_release, memory_order_acq_rel, memory_order_seq_cst
+// } memory_order;
+
+#include <atomic>
+#include <cassert>
+
+int main()
+{
+ assert(std::memory_order_relaxed == 0);
+ assert(std::memory_order_consume == 1);
+ assert(std::memory_order_acquire == 2);
+ assert(std::memory_order_release == 3);
+ assert(std::memory_order_acq_rel == 4);
+ assert(std::memory_order_seq_cst == 5);
+ std::memory_order o = std::memory_order_seq_cst;
+ assert(o == 5);
+}
diff --git a/test/std/atomics/atomics.syn/nothing_to_do.pass.cpp b/test/std/atomics/atomics.syn/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..9a59227abdd9
--- /dev/null
+++ b/test/std/atomics/atomics.syn/nothing_to_do.pass.cpp
@@ -0,0 +1,13 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/atomics/atomics.types.generic/address.pass.cpp b/test/std/atomics/atomics.types.generic/address.pass.cpp
new file mode 100644
index 000000000000..3b9f3ce76cad
--- /dev/null
+++ b/test/std/atomics/atomics.types.generic/address.pass.cpp
@@ -0,0 +1,140 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+// ... test case crashes clang.
+
+// <atomic>
+
+// template <class T>
+// struct atomic<T*>
+// {
+// bool is_lock_free() const volatile;
+// bool is_lock_free() const;
+// void store(T* desr, memory_order m = memory_order_seq_cst) volatile;
+// void store(T* desr, memory_order m = memory_order_seq_cst);
+// T* load(memory_order m = memory_order_seq_cst) const volatile;
+// T* load(memory_order m = memory_order_seq_cst) const;
+// operator T*() const volatile;
+// operator T*() const;
+// T* exchange(T* desr, memory_order m = memory_order_seq_cst) volatile;
+// T* exchange(T* desr, memory_order m = memory_order_seq_cst);
+// bool compare_exchange_weak(T*& expc, T* desr,
+// memory_order s, memory_order f) volatile;
+// bool compare_exchange_weak(T*& expc, T* desr,
+// memory_order s, memory_order f);
+// bool compare_exchange_strong(T*& expc, T* desr,
+// memory_order s, memory_order f) volatile;
+// bool compare_exchange_strong(T*& expc, T* desr,
+// memory_order s, memory_order f);
+// bool compare_exchange_weak(T*& expc, T* desr,
+// memory_order m = memory_order_seq_cst) volatile;
+// bool compare_exchange_weak(T*& expc, T* desr,
+// memory_order m = memory_order_seq_cst);
+// bool compare_exchange_strong(T*& expc, T* desr,
+// memory_order m = memory_order_seq_cst) volatile;
+// bool compare_exchange_strong(T*& expc, T* desr,
+// memory_order m = memory_order_seq_cst);
+// T* fetch_add(ptrdiff_t op, memory_order m = memory_order_seq_cst) volatile;
+// T* fetch_add(ptrdiff_t op, memory_order m = memory_order_seq_cst);
+// T* fetch_sub(ptrdiff_t op, memory_order m = memory_order_seq_cst) volatile;
+// T* fetch_sub(ptrdiff_t op, memory_order m = memory_order_seq_cst);
+//
+// atomic() = default;
+// constexpr atomic(T* desr);
+// atomic(const atomic&) = delete;
+// atomic& operator=(const atomic&) = delete;
+// atomic& operator=(const atomic&) volatile = delete;
+//
+// T* operator=(T*) volatile;
+// T* operator=(T*);
+// T* operator++(int) volatile;
+// T* operator++(int);
+// T* operator--(int) volatile;
+// T* operator--(int);
+// T* operator++() volatile;
+// T* operator++();
+// T* operator--() volatile;
+// T* operator--();
+// T* operator+=(ptrdiff_t op) volatile;
+// T* operator+=(ptrdiff_t op);
+// T* operator-=(ptrdiff_t op) volatile;
+// T* operator-=(ptrdiff_t op);
+// };
+
+#include <atomic>
+#include <new>
+#include <type_traits>
+#include <cassert>
+
+#include <cmpxchg_loop.h>
+
+template <class A, class T>
+void
+do_test()
+{
+ typedef typename std::remove_pointer<T>::type X;
+ A obj(T(0));
+ assert(obj == T(0));
+ std::atomic_init(&obj, T(1));
+ assert(obj == T(1));
+ std::atomic_init(&obj, T(2));
+ assert(obj == T(2));
+ bool b0 = obj.is_lock_free();
+ obj.store(T(0));
+ assert(obj == T(0));
+ obj.store(T(1), std::memory_order_release);
+ assert(obj == T(1));
+ assert(obj.load() == T(1));
+ assert(obj.load(std::memory_order_acquire) == T(1));
+ assert(obj.exchange(T(2)) == T(1));
+ assert(obj == T(2));
+ assert(obj.exchange(T(3), std::memory_order_relaxed) == T(2));
+ assert(obj == T(3));
+ T x = obj;
+ assert(cmpxchg_weak_loop(obj, x, T(2)) == true);
+ assert(obj == T(2));
+ assert(x == T(3));
+ assert(obj.compare_exchange_weak(x, T(1)) == false);
+ assert(obj == T(2));
+ assert(x == T(2));
+ x = T(2);
+ assert(obj.compare_exchange_strong(x, T(1)) == true);
+ assert(obj == T(1));
+ assert(x == T(2));
+ assert(obj.compare_exchange_strong(x, T(0)) == false);
+ assert(obj == T(1));
+ assert(x == T(1));
+ assert((obj = T(0)) == T(0));
+ assert(obj == T(0));
+ obj = T(2*sizeof(X));
+ assert((obj += std::ptrdiff_t(3)) == T(5*sizeof(X)));
+ assert(obj == T(5*sizeof(X)));
+ assert((obj -= std::ptrdiff_t(3)) == T(2*sizeof(X)));
+ assert(obj == T(2*sizeof(X)));
+
+ {
+ _ALIGNAS_TYPE(A) char storage[sizeof(A)] = {23};
+ A& zero = *new (storage) A();
+ assert(zero == 0);
+ zero.~A();
+ }
+}
+
+template <class A, class T>
+void test()
+{
+ do_test<A, T>();
+ do_test<volatile A, T>();
+}
+
+int main()
+{
+ test<std::atomic<int*>, int*>();
+}
diff --git a/test/std/atomics/atomics.types.generic/bool.pass.cpp b/test/std/atomics/atomics.types.generic/bool.pass.cpp
new file mode 100644
index 000000000000..dd851e86530c
--- /dev/null
+++ b/test/std/atomics/atomics.types.generic/bool.pass.cpp
@@ -0,0 +1,237 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <atomic>
+
+// template <class T>
+// struct atomic
+// {
+// bool is_lock_free() const volatile;
+// bool is_lock_free() const;
+// void store(T desr, memory_order m = memory_order_seq_cst) volatile;
+// void store(T desr, memory_order m = memory_order_seq_cst);
+// T load(memory_order m = memory_order_seq_cst) const volatile;
+// T load(memory_order m = memory_order_seq_cst) const;
+// operator T() const volatile;
+// operator T() const;
+// T exchange(T desr, memory_order m = memory_order_seq_cst) volatile;
+// T exchange(T desr, memory_order m = memory_order_seq_cst);
+// bool compare_exchange_weak(T& expc, T desr,
+// memory_order s, memory_order f) volatile;
+// bool compare_exchange_weak(T& expc, T desr, memory_order s, memory_order f);
+// bool compare_exchange_strong(T& expc, T desr,
+// memory_order s, memory_order f) volatile;
+// bool compare_exchange_strong(T& expc, T desr,
+// memory_order s, memory_order f);
+// bool compare_exchange_weak(T& expc, T desr,
+// memory_order m = memory_order_seq_cst) volatile;
+// bool compare_exchange_weak(T& expc, T desr,
+// memory_order m = memory_order_seq_cst);
+// bool compare_exchange_strong(T& expc, T desr,
+// memory_order m = memory_order_seq_cst) volatile;
+// bool compare_exchange_strong(T& expc, T desr,
+// memory_order m = memory_order_seq_cst);
+//
+// atomic() = default;
+// constexpr atomic(T desr);
+// atomic(const atomic&) = delete;
+// atomic& operator=(const atomic&) = delete;
+// atomic& operator=(const atomic&) volatile = delete;
+// T operator=(T) volatile;
+// T operator=(T);
+// };
+//
+// typedef atomic<bool> atomic_bool;
+
+#include <atomic>
+#include <new>
+#include <cassert>
+
+#include <cmpxchg_loop.h>
+
+int main()
+{
+ {
+ volatile std::atomic<bool> _;
+ volatile std::atomic<bool> obj(true);
+ assert(obj == true);
+ std::atomic_init(&obj, false);
+ assert(obj == false);
+ std::atomic_init(&obj, true);
+ assert(obj == true);
+ bool b0 = obj.is_lock_free();
+ (void)b0; // to placate scan-build
+ obj.store(false);
+ assert(obj == false);
+ obj.store(true, std::memory_order_release);
+ assert(obj == true);
+ assert(obj.load() == true);
+ assert(obj.load(std::memory_order_acquire) == true);
+ assert(obj.exchange(false) == true);
+ assert(obj == false);
+ assert(obj.exchange(true, std::memory_order_relaxed) == false);
+ assert(obj == true);
+ bool x = obj;
+ assert(cmpxchg_weak_loop(obj, x, false) == true);
+ assert(obj == false);
+ assert(x == true);
+ assert(obj.compare_exchange_weak(x, true,
+ std::memory_order_seq_cst) == false);
+ assert(obj == false);
+ assert(x == false);
+ obj.store(true);
+ x = true;
+ assert(cmpxchg_weak_loop(obj, x, false,
+ std::memory_order_seq_cst,
+ std::memory_order_seq_cst) == true);
+ assert(obj == false);
+ assert(x == true);
+ x = true;
+ obj.store(true);
+ assert(obj.compare_exchange_strong(x, false) == true);
+ assert(obj == false);
+ assert(x == true);
+ assert(obj.compare_exchange_strong(x, true,
+ std::memory_order_seq_cst) == false);
+ assert(obj == false);
+ assert(x == false);
+ x = true;
+ obj.store(true);
+ assert(obj.compare_exchange_strong(x, false,
+ std::memory_order_seq_cst,
+ std::memory_order_seq_cst) == true);
+ assert(obj == false);
+ assert(x == true);
+ assert((obj = false) == false);
+ assert(obj == false);
+ assert((obj = true) == true);
+ assert(obj == true);
+ }
+ {
+ std::atomic<bool> _;
+ std::atomic<bool> obj(true);
+ assert(obj == true);
+ std::atomic_init(&obj, false);
+ assert(obj == false);
+ std::atomic_init(&obj, true);
+ assert(obj == true);
+ bool b0 = obj.is_lock_free();
+ (void)b0; // to placate scan-build
+ obj.store(false);
+ assert(obj == false);
+ obj.store(true, std::memory_order_release);
+ assert(obj == true);
+ assert(obj.load() == true);
+ assert(obj.load(std::memory_order_acquire) == true);
+ assert(obj.exchange(false) == true);
+ assert(obj == false);
+ assert(obj.exchange(true, std::memory_order_relaxed) == false);
+ assert(obj == true);
+ bool x = obj;
+ assert(cmpxchg_weak_loop(obj, x, false) == true);
+ assert(obj == false);
+ assert(x == true);
+ assert(obj.compare_exchange_weak(x, true,
+ std::memory_order_seq_cst) == false);
+ assert(obj == false);
+ assert(x == false);
+ obj.store(true);
+ x = true;
+ assert(cmpxchg_weak_loop(obj, x, false,
+ std::memory_order_seq_cst,
+ std::memory_order_seq_cst) == true);
+ assert(obj == false);
+ assert(x == true);
+ x = true;
+ obj.store(true);
+ assert(obj.compare_exchange_strong(x, false) == true);
+ assert(obj == false);
+ assert(x == true);
+ assert(obj.compare_exchange_strong(x, true,
+ std::memory_order_seq_cst) == false);
+ assert(obj == false);
+ assert(x == false);
+ x = true;
+ obj.store(true);
+ assert(obj.compare_exchange_strong(x, false,
+ std::memory_order_seq_cst,
+ std::memory_order_seq_cst) == true);
+ assert(obj == false);
+ assert(x == true);
+ assert((obj = false) == false);
+ assert(obj == false);
+ assert((obj = true) == true);
+ assert(obj == true);
+ }
+ {
+ std::atomic_bool _;
+ std::atomic_bool obj(true);
+ assert(obj == true);
+ std::atomic_init(&obj, false);
+ assert(obj == false);
+ std::atomic_init(&obj, true);
+ assert(obj == true);
+ bool b0 = obj.is_lock_free();
+ (void)b0; // to placate scan-build
+ obj.store(false);
+ assert(obj == false);
+ obj.store(true, std::memory_order_release);
+ assert(obj == true);
+ assert(obj.load() == true);
+ assert(obj.load(std::memory_order_acquire) == true);
+ assert(obj.exchange(false) == true);
+ assert(obj == false);
+ assert(obj.exchange(true, std::memory_order_relaxed) == false);
+ assert(obj == true);
+ bool x = obj;
+ assert(cmpxchg_weak_loop(obj, x, false) == true);
+ assert(obj == false);
+ assert(x == true);
+ assert(obj.compare_exchange_weak(x, true,
+ std::memory_order_seq_cst) == false);
+ assert(obj == false);
+ assert(x == false);
+ obj.store(true);
+ x = true;
+ assert(cmpxchg_weak_loop(obj, x, false,
+ std::memory_order_seq_cst,
+ std::memory_order_seq_cst) == true);
+ assert(obj == false);
+ assert(x == true);
+ x = true;
+ obj.store(true);
+ assert(obj.compare_exchange_strong(x, false) == true);
+ assert(obj == false);
+ assert(x == true);
+ assert(obj.compare_exchange_strong(x, true,
+ std::memory_order_seq_cst) == false);
+ assert(obj == false);
+ assert(x == false);
+ x = true;
+ obj.store(true);
+ assert(obj.compare_exchange_strong(x, false,
+ std::memory_order_seq_cst,
+ std::memory_order_seq_cst) == true);
+ assert(obj == false);
+ assert(x == true);
+ assert((obj = false) == false);
+ assert(obj == false);
+ assert((obj = true) == true);
+ assert(obj == true);
+ }
+ {
+ typedef std::atomic<bool> A;
+ _ALIGNAS_TYPE(A) char storage[sizeof(A)] = {1};
+ A& zero = *new (storage) A();
+ assert(zero == false);
+ zero.~A();
+ }
+}
diff --git a/test/std/atomics/atomics.types.generic/cstdint_typedefs.pass.cpp b/test/std/atomics/atomics.types.generic/cstdint_typedefs.pass.cpp
new file mode 100644
index 000000000000..a7874b9f5af4
--- /dev/null
+++ b/test/std/atomics/atomics.types.generic/cstdint_typedefs.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <atomic>
+
+// typedef atomic<int_least8_t> atomic_int_least8_t;
+// typedef atomic<uint_least8_t> atomic_uint_least8_t;
+// typedef atomic<int_least16_t> atomic_int_least16_t;
+// typedef atomic<uint_least16_t> atomic_uint_least16_t;
+// typedef atomic<int_least32_t> atomic_int_least32_t;
+// typedef atomic<uint_least32_t> atomic_uint_least32_t;
+// typedef atomic<int_least64_t> atomic_int_least64_t;
+// typedef atomic<uint_least64_t> atomic_uint_least64_t;
+//
+// typedef atomic<int_fast8_t> atomic_int_fast8_t;
+// typedef atomic<uint_fast8_t> atomic_uint_fast8_t;
+// typedef atomic<int_fast16_t> atomic_int_fast16_t;
+// typedef atomic<uint_fast16_t> atomic_uint_fast16_t;
+// typedef atomic<int_fast32_t> atomic_int_fast32_t;
+// typedef atomic<uint_fast32_t> atomic_uint_fast32_t;
+// typedef atomic<int_fast64_t> atomic_int_fast64_t;
+// typedef atomic<uint_fast64_t> atomic_uint_fast64_t;
+//
+// typedef atomic<intptr_t> atomic_intptr_t;
+// typedef atomic<uintptr_t> atomic_uintptr_t;
+// typedef atomic<size_t> atomic_size_t;
+// typedef atomic<ptrdiff_t> atomic_ptrdiff_t;
+// typedef atomic<intmax_t> atomic_intmax_t;
+// typedef atomic<uintmax_t> atomic_uintmax_t;
+
+#include <atomic>
+#include <type_traits>
+#include <cstdint>
+
+int main()
+{
+ static_assert((std::is_same<std::atomic< std::int_least8_t>, std::atomic_int_least8_t>::value), "");
+ static_assert((std::is_same<std::atomic< std::uint_least8_t>, std::atomic_uint_least8_t>::value), "");
+ static_assert((std::is_same<std::atomic< std::int_least16_t>, std::atomic_int_least16_t>::value), "");
+ static_assert((std::is_same<std::atomic<std::uint_least16_t>, std::atomic_uint_least16_t>::value), "");
+ static_assert((std::is_same<std::atomic< std::int_least32_t>, std::atomic_int_least32_t>::value), "");
+ static_assert((std::is_same<std::atomic<std::uint_least32_t>, std::atomic_uint_least32_t>::value), "");
+ static_assert((std::is_same<std::atomic< std::int_least64_t>, std::atomic_int_least64_t>::value), "");
+ static_assert((std::is_same<std::atomic<std::uint_least64_t>, std::atomic_uint_least64_t>::value), "");
+
+ static_assert((std::is_same<std::atomic< std::int_fast8_t>, std::atomic_int_fast8_t>::value), "");
+ static_assert((std::is_same<std::atomic< std::uint_fast8_t>, std::atomic_uint_fast8_t>::value), "");
+ static_assert((std::is_same<std::atomic< std::int_fast16_t>, std::atomic_int_fast16_t>::value), "");
+ static_assert((std::is_same<std::atomic<std::uint_fast16_t>, std::atomic_uint_fast16_t>::value), "");
+ static_assert((std::is_same<std::atomic< std::int_fast32_t>, std::atomic_int_fast32_t>::value), "");
+ static_assert((std::is_same<std::atomic<std::uint_fast32_t>, std::atomic_uint_fast32_t>::value), "");
+ static_assert((std::is_same<std::atomic< std::int_fast64_t>, std::atomic_int_fast64_t>::value), "");
+ static_assert((std::is_same<std::atomic<std::uint_fast64_t>, std::atomic_uint_fast64_t>::value), "");
+
+ static_assert((std::is_same<std::atomic< std::intptr_t>, std::atomic_intptr_t>::value), "");
+ static_assert((std::is_same<std::atomic<std::uintptr_t>, std::atomic_uintptr_t>::value), "");
+ static_assert((std::is_same<std::atomic< std::size_t>, std::atomic_size_t>::value), "");
+ static_assert((std::is_same<std::atomic<std::ptrdiff_t>, std::atomic_ptrdiff_t>::value), "");
+ static_assert((std::is_same<std::atomic< std::intmax_t>, std::atomic_intmax_t>::value), "");
+ static_assert((std::is_same<std::atomic<std::uintmax_t>, std::atomic_uintmax_t>::value), "");
+}
diff --git a/test/std/atomics/atomics.types.generic/integral.pass.cpp b/test/std/atomics/atomics.types.generic/integral.pass.cpp
new file mode 100644
index 000000000000..f9c758336099
--- /dev/null
+++ b/test/std/atomics/atomics.types.generic/integral.pass.cpp
@@ -0,0 +1,203 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <atomic>
+
+// template <>
+// struct atomic<integral>
+// {
+// bool is_lock_free() const volatile;
+// bool is_lock_free() const;
+// void store(integral desr, memory_order m = memory_order_seq_cst) volatile;
+// void store(integral desr, memory_order m = memory_order_seq_cst);
+// integral load(memory_order m = memory_order_seq_cst) const volatile;
+// integral load(memory_order m = memory_order_seq_cst) const;
+// operator integral() const volatile;
+// operator integral() const;
+// integral exchange(integral desr,
+// memory_order m = memory_order_seq_cst) volatile;
+// integral exchange(integral desr, memory_order m = memory_order_seq_cst);
+// bool compare_exchange_weak(integral& expc, integral desr,
+// memory_order s, memory_order f) volatile;
+// bool compare_exchange_weak(integral& expc, integral desr,
+// memory_order s, memory_order f);
+// bool compare_exchange_strong(integral& expc, integral desr,
+// memory_order s, memory_order f) volatile;
+// bool compare_exchange_strong(integral& expc, integral desr,
+// memory_order s, memory_order f);
+// bool compare_exchange_weak(integral& expc, integral desr,
+// memory_order m = memory_order_seq_cst) volatile;
+// bool compare_exchange_weak(integral& expc, integral desr,
+// memory_order m = memory_order_seq_cst);
+// bool compare_exchange_strong(integral& expc, integral desr,
+// memory_order m = memory_order_seq_cst) volatile;
+// bool compare_exchange_strong(integral& expc, integral desr,
+// memory_order m = memory_order_seq_cst);
+//
+// integral
+// fetch_add(integral op, memory_order m = memory_order_seq_cst) volatile;
+// integral fetch_add(integral op, memory_order m = memory_order_seq_cst);
+// integral
+// fetch_sub(integral op, memory_order m = memory_order_seq_cst) volatile;
+// integral fetch_sub(integral op, memory_order m = memory_order_seq_cst);
+// integral
+// fetch_and(integral op, memory_order m = memory_order_seq_cst) volatile;
+// integral fetch_and(integral op, memory_order m = memory_order_seq_cst);
+// integral
+// fetch_or(integral op, memory_order m = memory_order_seq_cst) volatile;
+// integral fetch_or(integral op, memory_order m = memory_order_seq_cst);
+// integral
+// fetch_xor(integral op, memory_order m = memory_order_seq_cst) volatile;
+// integral fetch_xor(integral op, memory_order m = memory_order_seq_cst);
+//
+// atomic() = default;
+// constexpr atomic(integral desr);
+// atomic(const atomic&) = delete;
+// atomic& operator=(const atomic&) = delete;
+// atomic& operator=(const atomic&) volatile = delete;
+// integral operator=(integral desr) volatile;
+// integral operator=(integral desr);
+//
+// integral operator++(int) volatile;
+// integral operator++(int);
+// integral operator--(int) volatile;
+// integral operator--(int);
+// integral operator++() volatile;
+// integral operator++();
+// integral operator--() volatile;
+// integral operator--();
+// integral operator+=(integral op) volatile;
+// integral operator+=(integral op);
+// integral operator-=(integral op) volatile;
+// integral operator-=(integral op);
+// integral operator&=(integral op) volatile;
+// integral operator&=(integral op);
+// integral operator|=(integral op) volatile;
+// integral operator|=(integral op);
+// integral operator^=(integral op) volatile;
+// integral operator^=(integral op);
+// };
+
+#include <atomic>
+#include <new>
+#include <cassert>
+
+#include <cmpxchg_loop.h>
+
+template <class A, class T>
+void
+do_test()
+{
+ A obj(T(0));
+ assert(obj == T(0));
+ std::atomic_init(&obj, T(1));
+ assert(obj == T(1));
+ std::atomic_init(&obj, T(2));
+ assert(obj == T(2));
+ bool b0 = obj.is_lock_free();
+ obj.store(T(0));
+ assert(obj == T(0));
+ obj.store(T(1), std::memory_order_release);
+ assert(obj == T(1));
+ assert(obj.load() == T(1));
+ assert(obj.load(std::memory_order_acquire) == T(1));
+ assert(obj.exchange(T(2)) == T(1));
+ assert(obj == T(2));
+ assert(obj.exchange(T(3), std::memory_order_relaxed) == T(2));
+ assert(obj == T(3));
+ T x = obj;
+ assert(cmpxchg_weak_loop(obj, x, T(2)) == true);
+ assert(obj == T(2));
+ assert(x == T(3));
+ assert(obj.compare_exchange_weak(x, T(1)) == false);
+ assert(obj == T(2));
+ assert(x == T(2));
+ x = T(2);
+ assert(obj.compare_exchange_strong(x, T(1)) == true);
+ assert(obj == T(1));
+ assert(x == T(2));
+ assert(obj.compare_exchange_strong(x, T(0)) == false);
+ assert(obj == T(1));
+ assert(x == T(1));
+ assert((obj = T(0)) == T(0));
+ assert(obj == T(0));
+ assert(obj++ == T(0));
+ assert(obj == T(1));
+ assert(++obj == T(2));
+ assert(obj == T(2));
+ assert(--obj == T(1));
+ assert(obj == T(1));
+ assert(obj-- == T(1));
+ assert(obj == T(0));
+ obj = T(2);
+ assert((obj += T(3)) == T(5));
+ assert(obj == T(5));
+ assert((obj -= T(3)) == T(2));
+ assert(obj == T(2));
+ assert((obj |= T(5)) == T(7));
+ assert(obj == T(7));
+ assert((obj &= T(0xF)) == T(7));
+ assert(obj == T(7));
+ assert((obj ^= T(0xF)) == T(8));
+ assert(obj == T(8));
+
+ {
+ _ALIGNAS_TYPE(A) char storage[sizeof(A)] = {23};
+ A& zero = *new (storage) A();
+ assert(zero == 0);
+ zero.~A();
+ }
+}
+
+template <class A, class T>
+void test()
+{
+ do_test<A, T>();
+ do_test<volatile A, T>();
+}
+
+
+int main()
+{
+ test<std::atomic_char, char>();
+ test<std::atomic_schar, signed char>();
+ test<std::atomic_uchar, unsigned char>();
+ test<std::atomic_short, short>();
+ test<std::atomic_ushort, unsigned short>();
+ test<std::atomic_int, int>();
+ test<std::atomic_uint, unsigned int>();
+ test<std::atomic_long, long>();
+ test<std::atomic_ulong, unsigned long>();
+ test<std::atomic_llong, long long>();
+ test<std::atomic_ullong, unsigned long long>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<std::atomic_char16_t, char16_t>();
+ test<std::atomic_char32_t, char32_t>();
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<std::atomic_wchar_t, wchar_t>();
+
+ test<volatile std::atomic_char, char>();
+ test<volatile std::atomic_schar, signed char>();
+ test<volatile std::atomic_uchar, unsigned char>();
+ test<volatile std::atomic_short, short>();
+ test<volatile std::atomic_ushort, unsigned short>();
+ test<volatile std::atomic_int, int>();
+ test<volatile std::atomic_uint, unsigned int>();
+ test<volatile std::atomic_long, long>();
+ test<volatile std::atomic_ulong, unsigned long>();
+ test<volatile std::atomic_llong, long long>();
+ test<volatile std::atomic_ullong, unsigned long long>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<volatile std::atomic_char16_t, char16_t>();
+ test<volatile std::atomic_char32_t, char32_t>();
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<volatile std::atomic_wchar_t, wchar_t>();
+}
diff --git a/test/std/atomics/atomics.types.generic/integral_typedefs.pass.cpp b/test/std/atomics/atomics.types.generic/integral_typedefs.pass.cpp
new file mode 100644
index 000000000000..e8fae85fb4b3
--- /dev/null
+++ b/test/std/atomics/atomics.types.generic/integral_typedefs.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <atomic>
+
+// typedef atomic<char> atomic_char;
+// typedef atomic<signed char> atomic_schar;
+// typedef atomic<unsigned char> atomic_uchar;
+// typedef atomic<short> atomic_short;
+// typedef atomic<unsigned short> atomic_ushort;
+// typedef atomic<int> atomic_int;
+// typedef atomic<unsigned int> atomic_uint;
+// typedef atomic<long> atomic_long;
+// typedef atomic<unsigned long> atomic_ulong;
+// typedef atomic<long long> atomic_llong;
+// typedef atomic<unsigned long long> atomic_ullong;
+// typedef atomic<char16_t> atomic_char16_t;
+// typedef atomic<char32_t> atomic_char32_t;
+// typedef atomic<wchar_t> atomic_wchar_t;
+
+#include <atomic>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_same<std::atomic<char>, std::atomic_char>::value), "");
+ static_assert((std::is_same<std::atomic<signed char>, std::atomic_schar>::value), "");
+ static_assert((std::is_same<std::atomic<unsigned char>, std::atomic_uchar>::value), "");
+ static_assert((std::is_same<std::atomic<short>, std::atomic_short>::value), "");
+ static_assert((std::is_same<std::atomic<unsigned short>, std::atomic_ushort>::value), "");
+ static_assert((std::is_same<std::atomic<int>, std::atomic_int>::value), "");
+ static_assert((std::is_same<std::atomic<unsigned int>, std::atomic_uint>::value), "");
+ static_assert((std::is_same<std::atomic<long>, std::atomic_long>::value), "");
+ static_assert((std::is_same<std::atomic<unsigned long>, std::atomic_ulong>::value), "");
+ static_assert((std::is_same<std::atomic<long long>, std::atomic_llong>::value), "");
+ static_assert((std::is_same<std::atomic<unsigned long long>, std::atomic_ullong>::value), "");
+ static_assert((std::is_same<std::atomic<wchar_t>, std::atomic_wchar_t>::value), "");
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+ static_assert((std::is_same<std::atomic<char16_t>, std::atomic_char16_t>::value), "");
+ static_assert((std::is_same<std::atomic<char32_t>, std::atomic_char32_t>::value), "");
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+}
diff --git a/test/std/atomics/atomics.types.generic/trivially_copyable.fail.cpp b/test/std/atomics/atomics.types.generic/trivially_copyable.fail.cpp
new file mode 100644
index 000000000000..f2bf4db0de48
--- /dev/null
+++ b/test/std/atomics/atomics.types.generic/trivially_copyable.fail.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <atomic>
+
+// template <class T>
+// struct atomic
+// {
+// bool is_lock_free() const volatile noexcept;
+// bool is_lock_free() const noexcept;
+// void store(T desr, memory_order m = memory_order_seq_cst) volatile noexcept;
+// void store(T desr, memory_order m = memory_order_seq_cst) noexcept;
+// T load(memory_order m = memory_order_seq_cst) const volatile noexcept;
+// T load(memory_order m = memory_order_seq_cst) const noexcept;
+// operator T() const volatile noexcept;
+// operator T() const noexcept;
+// T exchange(T desr, memory_order m = memory_order_seq_cst) volatile noexcept;
+// T exchange(T desr, memory_order m = memory_order_seq_cst) noexcept;
+// bool compare_exchange_weak(T& expc, T desr,
+// memory_order s, memory_order f) volatile noexcept;
+// bool compare_exchange_weak(T& expc, T desr, memory_order s, memory_order f) noexcept;
+// bool compare_exchange_strong(T& expc, T desr,
+// memory_order s, memory_order f) volatile noexcept;
+// bool compare_exchange_strong(T& expc, T desr,
+// memory_order s, memory_order f) noexcept;
+// bool compare_exchange_weak(T& expc, T desr,
+// memory_order m = memory_order_seq_cst) volatile noexcept;
+// bool compare_exchange_weak(T& expc, T desr,
+// memory_order m = memory_order_seq_cst) noexcept;
+// bool compare_exchange_strong(T& expc, T desr,
+// memory_order m = memory_order_seq_cst) volatile noexcept;
+// bool compare_exchange_strong(T& expc, T desr,
+// memory_order m = memory_order_seq_cst) noexcept;
+//
+// atomic() noexcept = default;
+// constexpr atomic(T desr) noexcept;
+// atomic(const atomic&) = delete;
+// atomic& operator=(const atomic&) = delete;
+// atomic& operator=(const atomic&) volatile = delete;
+// T operator=(T) volatile noexcept;
+// T operator=(T) noexcept;
+// };
+
+#include <atomic>
+#include <new>
+#include <cassert>
+#include <thread> // for thread_id
+#include <chrono> // for nanoseconds
+
+struct NotTriviallyCopyable {
+ NotTriviallyCopyable ( int i ) : i_(i) {}
+ NotTriviallyCopyable ( const NotTriviallyCopyable &rhs) : i_(rhs.i_) {}
+ int i_;
+ };
+
+template <class T>
+void test ( T t ) {
+ std::atomic<T> t0(t);
+ }
+
+int main()
+{
+ test(NotTriviallyCopyable(42));
+}
diff --git a/test/std/atomics/atomics.types.generic/trivially_copyable.pass.cpp b/test/std/atomics/atomics.types.generic/trivially_copyable.pass.cpp
new file mode 100644
index 000000000000..5b094f0a89c1
--- /dev/null
+++ b/test/std/atomics/atomics.types.generic/trivially_copyable.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// NOTE: atomic<> of a TriviallyCopyable class is wrongly rejected by older
+// clang versions. It was fixed right before the llvm 3.5 release. See PR18097.
+// XFAIL: apple-clang-6.0, clang-3.4, clang-3.3
+
+// <atomic>
+
+// template <class T>
+// struct atomic
+// {
+// bool is_lock_free() const volatile noexcept;
+// bool is_lock_free() const noexcept;
+// void store(T desr, memory_order m = memory_order_seq_cst) volatile noexcept;
+// void store(T desr, memory_order m = memory_order_seq_cst) noexcept;
+// T load(memory_order m = memory_order_seq_cst) const volatile noexcept;
+// T load(memory_order m = memory_order_seq_cst) const noexcept;
+// operator T() const volatile noexcept;
+// operator T() const noexcept;
+// T exchange(T desr, memory_order m = memory_order_seq_cst) volatile noexcept;
+// T exchange(T desr, memory_order m = memory_order_seq_cst) noexcept;
+// bool compare_exchange_weak(T& expc, T desr,
+// memory_order s, memory_order f) volatile noexcept;
+// bool compare_exchange_weak(T& expc, T desr, memory_order s, memory_order f) noexcept;
+// bool compare_exchange_strong(T& expc, T desr,
+// memory_order s, memory_order f) volatile noexcept;
+// bool compare_exchange_strong(T& expc, T desr,
+// memory_order s, memory_order f) noexcept;
+// bool compare_exchange_weak(T& expc, T desr,
+// memory_order m = memory_order_seq_cst) volatile noexcept;
+// bool compare_exchange_weak(T& expc, T desr,
+// memory_order m = memory_order_seq_cst) noexcept;
+// bool compare_exchange_strong(T& expc, T desr,
+// memory_order m = memory_order_seq_cst) volatile noexcept;
+// bool compare_exchange_strong(T& expc, T desr,
+// memory_order m = memory_order_seq_cst) noexcept;
+//
+// atomic() noexcept = default;
+// constexpr atomic(T desr) noexcept;
+// atomic(const atomic&) = delete;
+// atomic& operator=(const atomic&) = delete;
+// atomic& operator=(const atomic&) volatile = delete;
+// T operator=(T) volatile noexcept;
+// T operator=(T) noexcept;
+// };
+
+#include <atomic>
+#include <new>
+#include <cassert>
+#include <thread> // for thread_id
+#include <chrono> // for nanoseconds
+
+struct TriviallyCopyable {
+ TriviallyCopyable ( int i ) : i_(i) {}
+ int i_;
+ };
+
+template <class T>
+void test ( T t ) {
+ std::atomic<T> t0(t);
+ }
+
+int main()
+{
+ test(TriviallyCopyable(42));
+ test(std::this_thread::get_id());
+ test(std::chrono::nanoseconds(2));
+}
diff --git a/test/std/atomics/atomics.types.operations/atomics.types.operations.arith/nothing_to_do.pass.cpp b/test/std/atomics/atomics.types.operations/atomics.types.operations.arith/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..9a59227abdd9
--- /dev/null
+++ b/test/std/atomics/atomics.types.operations/atomics.types.operations.arith/nothing_to_do.pass.cpp
@@ -0,0 +1,13 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/atomics/atomics.types.operations/atomics.types.operations.general/nothing_to_do.pass.cpp b/test/std/atomics/atomics.types.operations/atomics.types.operations.general/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..9a59227abdd9
--- /dev/null
+++ b/test/std/atomics/atomics.types.operations/atomics.types.operations.general/nothing_to_do.pass.cpp
@@ -0,0 +1,13 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/atomics/atomics.types.operations/atomics.types.operations.pointer/nothing_to_do.pass.cpp b/test/std/atomics/atomics.types.operations/atomics.types.operations.pointer/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..9a59227abdd9
--- /dev/null
+++ b/test/std/atomics/atomics.types.operations/atomics.types.operations.pointer/nothing_to_do.pass.cpp
@@ -0,0 +1,13 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_strong.pass.cpp b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_strong.pass.cpp
new file mode 100644
index 000000000000..f1cc993ed33e
--- /dev/null
+++ b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_strong.pass.cpp
@@ -0,0 +1,88 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+// ... assertion fails line 34
+
+// <atomic>
+
+// template <class T>
+// bool
+// atomic_compare_exchange_strong(volatile atomic<T>* obj, T* expc, T desr);
+//
+// template <class T>
+// bool
+// atomic_compare_exchange_strong(atomic<T>* obj, T* expc, T desr);
+
+#include <atomic>
+#include <type_traits>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+ {
+ typedef std::atomic<T> A;
+ A a;
+ T t(T(1));
+ std::atomic_init(&a, t);
+ assert(std::atomic_compare_exchange_strong(&a, &t, T(2)) == true);
+ assert(a == T(2));
+ assert(t == T(1));
+ assert(std::atomic_compare_exchange_strong(&a, &t, T(3)) == false);
+ assert(a == T(2));
+ assert(t == T(2));
+ }
+ {
+ typedef std::atomic<T> A;
+ volatile A a;
+ T t(T(1));
+ std::atomic_init(&a, t);
+ assert(std::atomic_compare_exchange_strong(&a, &t, T(2)) == true);
+ assert(a == T(2));
+ assert(t == T(1));
+ assert(std::atomic_compare_exchange_strong(&a, &t, T(3)) == false);
+ assert(a == T(2));
+ assert(t == T(2));
+ }
+}
+
+struct A
+{
+ int i;
+
+ explicit A(int d = 0) noexcept {i=d;}
+
+ friend bool operator==(const A& x, const A& y)
+ {return x.i == y.i;}
+};
+
+int main()
+{
+ test<A>();
+ test<char>();
+ test<signed char>();
+ test<unsigned char>();
+ test<short>();
+ test<unsigned short>();
+ test<int>();
+ test<unsigned int>();
+ test<long>();
+ test<unsigned long>();
+ test<long long>();
+ test<unsigned long long>();
+ test<wchar_t>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<char16_t>();
+ test<char32_t>();
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<int*>();
+ test<const int*>();
+}
diff --git a/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_strong_explicit.pass.cpp b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_strong_explicit.pass.cpp
new file mode 100644
index 000000000000..f667ab7f139b
--- /dev/null
+++ b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_strong_explicit.pass.cpp
@@ -0,0 +1,95 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+// ... assertion fails line 38
+
+// <atomic>
+
+// template <class T>
+// bool
+// atomic_compare_exchange_strong_explicit(volatile atomic<T>* obj, T* expc,
+// T desr,
+// memory_order s, memory_order f);
+//
+// template <class T>
+// bool
+// atomic_compare_exchange_strong_explicit(atomic<T>* obj, T* expc, T desr,
+// memory_order s, memory_order f);
+
+#include <atomic>
+#include <type_traits>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+ {
+ typedef std::atomic<T> A;
+ A a;
+ T t(T(1));
+ std::atomic_init(&a, t);
+ assert(std::atomic_compare_exchange_strong_explicit(&a, &t, T(2),
+ std::memory_order_seq_cst, std::memory_order_seq_cst) == true);
+ assert(a == T(2));
+ assert(t == T(1));
+ assert(std::atomic_compare_exchange_strong_explicit(&a, &t, T(3),
+ std::memory_order_seq_cst, std::memory_order_seq_cst) == false);
+ assert(a == T(2));
+ assert(t == T(2));
+ }
+ {
+ typedef std::atomic<T> A;
+ volatile A a;
+ T t(T(1));
+ std::atomic_init(&a, t);
+ assert(std::atomic_compare_exchange_strong_explicit(&a, &t, T(2),
+ std::memory_order_seq_cst, std::memory_order_seq_cst) == true);
+ assert(a == T(2));
+ assert(t == T(1));
+ assert(std::atomic_compare_exchange_strong_explicit(&a, &t, T(3),
+ std::memory_order_seq_cst, std::memory_order_seq_cst) == false);
+ assert(a == T(2));
+ assert(t == T(2));
+ }
+}
+
+struct A
+{
+ int i;
+
+ explicit A(int d = 0) noexcept {i=d;}
+
+ friend bool operator==(const A& x, const A& y)
+ {return x.i == y.i;}
+};
+
+int main()
+{
+ test<A>();
+ test<char>();
+ test<signed char>();
+ test<unsigned char>();
+ test<short>();
+ test<unsigned short>();
+ test<int>();
+ test<unsigned int>();
+ test<long>();
+ test<unsigned long>();
+ test<long long>();
+ test<unsigned long long>();
+ test<wchar_t>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<char16_t>();
+ test<char32_t>();
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<int*>();
+ test<const int*>();
+}
diff --git a/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_weak.pass.cpp b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_weak.pass.cpp
new file mode 100644
index 000000000000..175c445d4560
--- /dev/null
+++ b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_weak.pass.cpp
@@ -0,0 +1,90 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+// ... assertion fails line 34
+
+// <atomic>
+
+// template <class T>
+// bool
+// atomic_compare_exchange_weak(volatile atomic<T>* obj, T* expc, T desr);
+//
+// template <class T>
+// bool
+// atomic_compare_exchange_weak(atomic<T>* obj, T* expc, T desr);
+
+#include <atomic>
+#include <type_traits>
+#include <cassert>
+
+#include <cmpxchg_loop.h>
+
+template <class T>
+void
+test()
+{
+ {
+ typedef std::atomic<T> A;
+ A a;
+ T t(T(1));
+ std::atomic_init(&a, t);
+ assert(c_cmpxchg_weak_loop(&a, &t, T(2)) == true);
+ assert(a == T(2));
+ assert(t == T(1));
+ assert(std::atomic_compare_exchange_weak(&a, &t, T(3)) == false);
+ assert(a == T(2));
+ assert(t == T(2));
+ }
+ {
+ typedef std::atomic<T> A;
+ volatile A a;
+ T t(T(1));
+ std::atomic_init(&a, t);
+ assert(c_cmpxchg_weak_loop(&a, &t, T(2)) == true);
+ assert(a == T(2));
+ assert(t == T(1));
+ assert(std::atomic_compare_exchange_weak(&a, &t, T(3)) == false);
+ assert(a == T(2));
+ assert(t == T(2));
+ }
+}
+
+struct A
+{
+ int i;
+
+ explicit A(int d = 0) noexcept {i=d;}
+
+ friend bool operator==(const A& x, const A& y)
+ {return x.i == y.i;}
+};
+
+int main()
+{
+ test<A>();
+ test<char>();
+ test<signed char>();
+ test<unsigned char>();
+ test<short>();
+ test<unsigned short>();
+ test<int>();
+ test<unsigned int>();
+ test<long>();
+ test<unsigned long>();
+ test<long long>();
+ test<unsigned long long>();
+ test<wchar_t>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<char16_t>();
+ test<char32_t>();
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<int*>();
+ test<const int*>();
+}
diff --git a/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_weak_explicit.pass.cpp b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_weak_explicit.pass.cpp
new file mode 100644
index 000000000000..46f80bfbcb7b
--- /dev/null
+++ b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_weak_explicit.pass.cpp
@@ -0,0 +1,97 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+// ... assertion fails line 38
+
+// <atomic>
+
+// template <class T>
+// bool
+// atomic_compare_exchange_weak_explicit(volatile atomic<T>* obj, T* expc,
+// T desr,
+// memory_order s, memory_order f);
+//
+// template <class T>
+// bool
+// atomic_compare_exchange_weak_explicit(atomic<T>* obj, T* expc, T desr,
+// memory_order s, memory_order f);
+
+#include <atomic>
+#include <type_traits>
+#include <cassert>
+
+#include <cmpxchg_loop.h>
+
+template <class T>
+void
+test()
+{
+ {
+ typedef std::atomic<T> A;
+ A a;
+ T t(T(1));
+ std::atomic_init(&a, t);
+ assert(c_cmpxchg_weak_loop(&a, &t, T(2),
+ std::memory_order_seq_cst, std::memory_order_seq_cst) == true);
+ assert(a == T(2));
+ assert(t == T(1));
+ assert(std::atomic_compare_exchange_weak_explicit(&a, &t, T(3),
+ std::memory_order_seq_cst, std::memory_order_seq_cst) == false);
+ assert(a == T(2));
+ assert(t == T(2));
+ }
+ {
+ typedef std::atomic<T> A;
+ volatile A a;
+ T t(T(1));
+ std::atomic_init(&a, t);
+ assert(c_cmpxchg_weak_loop(&a, &t, T(2),
+ std::memory_order_seq_cst, std::memory_order_seq_cst) == true);
+ assert(a == T(2));
+ assert(t == T(1));
+ assert(std::atomic_compare_exchange_weak_explicit(&a, &t, T(3),
+ std::memory_order_seq_cst, std::memory_order_seq_cst) == false);
+ assert(a == T(2));
+ assert(t == T(2));
+ }
+}
+
+struct A
+{
+ int i;
+
+ explicit A(int d = 0) noexcept {i=d;}
+
+ friend bool operator==(const A& x, const A& y)
+ {return x.i == y.i;}
+};
+
+int main()
+{
+ test<A>();
+ test<char>();
+ test<signed char>();
+ test<unsigned char>();
+ test<short>();
+ test<unsigned short>();
+ test<int>();
+ test<unsigned int>();
+ test<long>();
+ test<unsigned long>();
+ test<long long>();
+ test<unsigned long long>();
+ test<wchar_t>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<char16_t>();
+ test<char32_t>();
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<int*>();
+ test<const int*>();
+}
diff --git a/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_exchange.pass.cpp b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_exchange.pass.cpp
new file mode 100644
index 000000000000..525e74aa6374
--- /dev/null
+++ b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_exchange.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+// ... fails assertion line 31
+
+// <atomic>
+
+// template <class T>
+// T
+// atomic_exchange(volatile atomic<T>* obj, T desr);
+//
+// template <class T>
+// T
+// atomic_exchange(atomic<T>* obj, T desr);
+
+#include <atomic>
+#include <type_traits>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+ typedef std::atomic<T> A;
+ A t;
+ std::atomic_init(&t, T(1));
+ assert(std::atomic_exchange(&t, T(2)) == T(1));
+ assert(t == T(2));
+ volatile A vt;
+ std::atomic_init(&vt, T(3));
+ assert(std::atomic_exchange(&vt, T(4)) == T(3));
+ assert(vt == T(4));
+}
+
+struct A
+{
+ int i;
+
+ explicit A(int d = 0) noexcept {i=d;}
+
+ friend bool operator==(const A& x, const A& y)
+ {return x.i == y.i;}
+};
+
+int main()
+{
+ test<A>();
+ test<char>();
+ test<signed char>();
+ test<unsigned char>();
+ test<short>();
+ test<unsigned short>();
+ test<int>();
+ test<unsigned int>();
+ test<long>();
+ test<unsigned long>();
+ test<long long>();
+ test<unsigned long long>();
+ test<wchar_t>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<char16_t>();
+ test<char32_t>();
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<int*>();
+ test<const int*>();
+}
diff --git a/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_exchange_explicit.pass.cpp b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_exchange_explicit.pass.cpp
new file mode 100644
index 000000000000..9fe4ac816448
--- /dev/null
+++ b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_exchange_explicit.pass.cpp
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+// ... assertion fails line 32
+
+// <atomic>
+
+// template <class T>
+// T
+// atomic_exchange_explicit(volatile atomic<T>* obj, T desr, memory_order m);
+//
+// template <class T>
+// T
+// atomic_exchange_explicit(atomic<T>* obj, T desr, memory_order m);
+
+#include <atomic>
+#include <type_traits>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+ typedef std::atomic<T> A;
+ A t;
+ std::atomic_init(&t, T(1));
+ assert(std::atomic_exchange_explicit(&t, T(2), std::memory_order_seq_cst)
+ == T(1));
+ assert(t == T(2));
+ volatile A vt;
+ std::atomic_init(&vt, T(3));
+ assert(std::atomic_exchange_explicit(&vt, T(4), std::memory_order_seq_cst)
+ == T(3));
+ assert(vt == T(4));
+}
+
+struct A
+{
+ int i;
+
+ explicit A(int d = 0) noexcept {i=d;}
+
+ friend bool operator==(const A& x, const A& y)
+ {return x.i == y.i;}
+};
+
+int main()
+{
+ test<A>();
+ test<char>();
+ test<signed char>();
+ test<unsigned char>();
+ test<short>();
+ test<unsigned short>();
+ test<int>();
+ test<unsigned int>();
+ test<long>();
+ test<unsigned long>();
+ test<long long>();
+ test<unsigned long long>();
+ test<wchar_t>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<char16_t>();
+ test<char32_t>();
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<int*>();
+ test<const int*>();
+}
diff --git a/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_add.pass.cpp b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_add.pass.cpp
new file mode 100644
index 000000000000..3408def9058a
--- /dev/null
+++ b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_add.pass.cpp
@@ -0,0 +1,111 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+// ... test crashes clang
+
+// <atomic>
+
+// template <class Integral>
+// Integral
+// atomic_fetch_add(volatile atomic<Integral>* obj, Integral op);
+//
+// template <class Integral>
+// Integral
+// atomic_fetch_add(atomic<Integral>* obj, Integral op);
+//
+// template <class T>
+// T*
+// atomic_fetch_add(volatile atomic<T*>* obj, ptrdiff_t op);
+//
+// template <class T>
+// T*
+// atomic_fetch_add(atomic<T*>* obj, ptrdiff_t op);
+
+#include <atomic>
+#include <type_traits>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+ {
+ typedef std::atomic<T> A;
+ A t;
+ std::atomic_init(&t, T(1));
+ assert(std::atomic_fetch_add(&t, T(2)) == T(1));
+ assert(t == T(3));
+ }
+ {
+ typedef std::atomic<T> A;
+ volatile A t;
+ std::atomic_init(&t, T(1));
+ assert(std::atomic_fetch_add(&t, T(2)) == T(1));
+ assert(t == T(3));
+ }
+}
+
+template <class T>
+void
+testp()
+{
+ {
+ typedef std::atomic<T> A;
+ typedef typename std::remove_pointer<T>::type X;
+ A t;
+ std::atomic_init(&t, T(1*sizeof(X)));
+ assert(std::atomic_fetch_add(&t, 2) == T(1*sizeof(X)));
+ assert(t == T(3*sizeof(X)));
+ }
+ {
+ typedef std::atomic<T> A;
+ typedef typename std::remove_pointer<T>::type X;
+ volatile A t;
+ std::atomic_init(&t, T(1*sizeof(X)));
+ assert(std::atomic_fetch_add(&t, 2) == T(1*sizeof(X)));
+ assert(t == T(3*sizeof(X)));
+ }
+}
+
+struct A
+{
+ int i;
+
+ explicit A(int d = 0) noexcept {i=d;}
+ A(const A& a) : i(a.i) {}
+ A(const volatile A& a) : i(a.i) {}
+
+ void operator=(const volatile A& a) volatile {i = a.i;}
+
+ friend bool operator==(const A& x, const A& y)
+ {return x.i == y.i;}
+};
+
+int main()
+{
+ test<char>();
+ test<signed char>();
+ test<unsigned char>();
+ test<short>();
+ test<unsigned short>();
+ test<int>();
+ test<unsigned int>();
+ test<long>();
+ test<unsigned long>();
+ test<long long>();
+ test<unsigned long long>();
+ test<wchar_t>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<char16_t>();
+ test<char32_t>();
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+ testp<int*>();
+ testp<const int*>();
+}
diff --git a/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_add_explicit.pass.cpp b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_add_explicit.pass.cpp
new file mode 100644
index 000000000000..9977bd491e7a
--- /dev/null
+++ b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_add_explicit.pass.cpp
@@ -0,0 +1,115 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+// ... test crashes clang
+
+// <atomic>
+
+// template <class Integral>
+// Integral
+// atomic_fetch_add_explicit(volatile atomic<Integral>* obj, Integral op,
+// memory_order m);
+// template <class Integral>
+// Integral
+// atomic_fetch_add_explicit(atomic<Integral>* obj, Integral op,
+// memory_order m);
+// template <class T>
+// T*
+// atomic_fetch_add_explicit(volatile atomic<T*>* obj, ptrdiff_t op,
+// memory_order m);
+// template <class T>
+// T*
+// atomic_fetch_add_explicit(atomic<T*>* obj, ptrdiff_t op, memory_order m);
+
+#include <atomic>
+#include <type_traits>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+ {
+ typedef std::atomic<T> A;
+ A t;
+ std::atomic_init(&t, T(1));
+ assert(std::atomic_fetch_add_explicit(&t, T(2),
+ std::memory_order_seq_cst) == T(1));
+ assert(t == T(3));
+ }
+ {
+ typedef std::atomic<T> A;
+ volatile A t;
+ std::atomic_init(&t, T(1));
+ assert(std::atomic_fetch_add_explicit(&t, T(2),
+ std::memory_order_seq_cst) == T(1));
+ assert(t == T(3));
+ }
+}
+
+template <class T>
+void
+testp()
+{
+ {
+ typedef std::atomic<T> A;
+ typedef typename std::remove_pointer<T>::type X;
+ A t;
+ std::atomic_init(&t, T(1*sizeof(X)));
+ assert(std::atomic_fetch_add_explicit(&t, 2,
+ std::memory_order_seq_cst) == T(1*sizeof(X)));
+ assert(t == T(3*sizeof(X)));
+ }
+ {
+ typedef std::atomic<T> A;
+ typedef typename std::remove_pointer<T>::type X;
+ volatile A t;
+ std::atomic_init(&t, T(1*sizeof(X)));
+ assert(std::atomic_fetch_add_explicit(&t, 2,
+ std::memory_order_seq_cst) == T(1*sizeof(X)));
+ assert(t == T(3*sizeof(X)));
+ }
+}
+
+struct A
+{
+ int i;
+
+ explicit A(int d = 0) noexcept {i=d;}
+ A(const A& a) : i(a.i) {}
+ A(const volatile A& a) : i(a.i) {}
+
+ void operator=(const volatile A& a) volatile {i = a.i;}
+
+ friend bool operator==(const A& x, const A& y)
+ {return x.i == y.i;}
+};
+
+int main()
+{
+ test<char>();
+ test<signed char>();
+ test<unsigned char>();
+ test<short>();
+ test<unsigned short>();
+ test<int>();
+ test<unsigned int>();
+ test<long>();
+ test<unsigned long>();
+ test<long long>();
+ test<unsigned long long>();
+ test<wchar_t>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<char16_t>();
+ test<char32_t>();
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+ testp<int*>();
+ testp<const int*>();
+}
diff --git a/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_and.pass.cpp b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_and.pass.cpp
new file mode 100644
index 000000000000..4c7c0432efc9
--- /dev/null
+++ b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_and.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <atomic>
+
+// template <class Integral>
+// Integral
+// atomic_fetch_and(volatile atomic<Integral>* obj, Integral op);
+//
+// template <class Integral>
+// Integral
+// atomic_fetch_and(atomic<Integral>* obj, Integral op);
+
+#include <atomic>
+#include <type_traits>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+ {
+ typedef std::atomic<T> A;
+ A t;
+ std::atomic_init(&t, T(1));
+ assert(std::atomic_fetch_and(&t, T(2)) == T(1));
+ assert(t == T(0));
+ }
+ {
+ typedef std::atomic<T> A;
+ volatile A t;
+ std::atomic_init(&t, T(3));
+ assert(std::atomic_fetch_and(&t, T(2)) == T(3));
+ assert(t == T(2));
+ }
+}
+
+int main()
+{
+ test<char>();
+ test<signed char>();
+ test<unsigned char>();
+ test<short>();
+ test<unsigned short>();
+ test<int>();
+ test<unsigned int>();
+ test<long>();
+ test<unsigned long>();
+ test<long long>();
+ test<unsigned long long>();
+ test<wchar_t>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<char16_t>();
+ test<char32_t>();
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+}
diff --git a/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_and_explicit.pass.cpp b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_and_explicit.pass.cpp
new file mode 100644
index 000000000000..d83bbf264de5
--- /dev/null
+++ b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_and_explicit.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <atomic>
+
+// template <class Integral>
+// Integral
+// atomic_fetch_and_explicit(volatile atomic<Integral>* obj, Integral op);
+//
+// template <class Integral>
+// Integral
+// atomic_fetch_and_explicit(atomic<Integral>* obj, Integral op);
+
+#include <atomic>
+#include <type_traits>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+ {
+ typedef std::atomic<T> A;
+ A t;
+ std::atomic_init(&t, T(1));
+ assert(std::atomic_fetch_and_explicit(&t, T(2),
+ std::memory_order_seq_cst) == T(1));
+ assert(t == T(0));
+ }
+ {
+ typedef std::atomic<T> A;
+ volatile A t;
+ std::atomic_init(&t, T(3));
+ assert(std::atomic_fetch_and_explicit(&t, T(2),
+ std::memory_order_seq_cst) == T(3));
+ assert(t == T(2));
+ }
+}
+
+int main()
+{
+ test<char>();
+ test<signed char>();
+ test<unsigned char>();
+ test<short>();
+ test<unsigned short>();
+ test<int>();
+ test<unsigned int>();
+ test<long>();
+ test<unsigned long>();
+ test<long long>();
+ test<unsigned long long>();
+ test<wchar_t>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<char16_t>();
+ test<char32_t>();
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+}
diff --git a/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_or.pass.cpp b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_or.pass.cpp
new file mode 100644
index 000000000000..acf6d439de43
--- /dev/null
+++ b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_or.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <atomic>
+
+// template <class Integral>
+// Integral
+// atomic_fetch_or(volatile atomic<Integral>* obj, Integral op);
+//
+// template <class Integral>
+// Integral
+// atomic_fetch_or(atomic<Integral>* obj, Integral op);
+
+#include <atomic>
+#include <type_traits>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+ {
+ typedef std::atomic<T> A;
+ A t;
+ std::atomic_init(&t, T(1));
+ assert(std::atomic_fetch_or(&t, T(2)) == T(1));
+ assert(t == T(3));
+ }
+ {
+ typedef std::atomic<T> A;
+ volatile A t;
+ std::atomic_init(&t, T(3));
+ assert(std::atomic_fetch_or(&t, T(2)) == T(3));
+ assert(t == T(3));
+ }
+}
+
+int main()
+{
+ test<char>();
+ test<signed char>();
+ test<unsigned char>();
+ test<short>();
+ test<unsigned short>();
+ test<int>();
+ test<unsigned int>();
+ test<long>();
+ test<unsigned long>();
+ test<long long>();
+ test<unsigned long long>();
+ test<wchar_t>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<char16_t>();
+ test<char32_t>();
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+}
diff --git a/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_or_explicit.pass.cpp b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_or_explicit.pass.cpp
new file mode 100644
index 000000000000..72685e4d9408
--- /dev/null
+++ b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_or_explicit.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <atomic>
+
+// template <class Integral>
+// Integral
+// atomic_fetch_or_explicit(volatile atomic<Integral>* obj, Integral op);
+//
+// template <class Integral>
+// Integral
+// atomic_fetch_or_explicit(atomic<Integral>* obj, Integral op);
+
+#include <atomic>
+#include <type_traits>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+ {
+ typedef std::atomic<T> A;
+ A t;
+ std::atomic_init(&t, T(1));
+ assert(std::atomic_fetch_or_explicit(&t, T(2),
+ std::memory_order_seq_cst) == T(1));
+ assert(t == T(3));
+ }
+ {
+ typedef std::atomic<T> A;
+ volatile A t;
+ std::atomic_init(&t, T(3));
+ assert(std::atomic_fetch_or_explicit(&t, T(2),
+ std::memory_order_seq_cst) == T(3));
+ assert(t == T(3));
+ }
+}
+
+int main()
+{
+ test<char>();
+ test<signed char>();
+ test<unsigned char>();
+ test<short>();
+ test<unsigned short>();
+ test<int>();
+ test<unsigned int>();
+ test<long>();
+ test<unsigned long>();
+ test<long long>();
+ test<unsigned long long>();
+ test<wchar_t>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<char16_t>();
+ test<char32_t>();
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+}
diff --git a/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_sub.pass.cpp b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_sub.pass.cpp
new file mode 100644
index 000000000000..ed8b541291af
--- /dev/null
+++ b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_sub.pass.cpp
@@ -0,0 +1,111 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+// ... test crashes clang
+
+// <atomic>
+
+// template <class Integral>
+// Integral
+// atomic_fetch_sub(volatile atomic<Integral>* obj, Integral op);
+//
+// template <class Integral>
+// Integral
+// atomic_fetch_sub(atomic<Integral>* obj, Integral op);
+//
+// template <class T>
+// T*
+// atomic_fetch_sub(volatile atomic<T*>* obj, ptrdiff_t op);
+//
+// template <class T>
+// T*
+// atomic_fetch_sub(atomic<T*>* obj, ptrdiff_t op);
+
+#include <atomic>
+#include <type_traits>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+ {
+ typedef std::atomic<T> A;
+ A t;
+ std::atomic_init(&t, T(3));
+ assert(std::atomic_fetch_sub(&t, T(2)) == T(3));
+ assert(t == T(1));
+ }
+ {
+ typedef std::atomic<T> A;
+ volatile A t;
+ std::atomic_init(&t, T(3));
+ assert(std::atomic_fetch_sub(&t, T(2)) == T(3));
+ assert(t == T(1));
+ }
+}
+
+template <class T>
+void
+testp()
+{
+ {
+ typedef std::atomic<T> A;
+ typedef typename std::remove_pointer<T>::type X;
+ A t;
+ std::atomic_init(&t, T(3*sizeof(X)));
+ assert(std::atomic_fetch_sub(&t, 2) == T(3*sizeof(X)));
+ assert(t == T(1*sizeof(X)));
+ }
+ {
+ typedef std::atomic<T> A;
+ typedef typename std::remove_pointer<T>::type X;
+ volatile A t;
+ std::atomic_init(&t, T(3*sizeof(X)));
+ assert(std::atomic_fetch_sub(&t, 2) == T(3*sizeof(X)));
+ assert(t == T(1*sizeof(X)));
+ }
+}
+
+struct A
+{
+ int i;
+
+ explicit A(int d = 0) noexcept {i=d;}
+ A(const A& a) : i(a.i) {}
+ A(const volatile A& a) : i(a.i) {}
+
+ void operator=(const volatile A& a) volatile {i = a.i;}
+
+ friend bool operator==(const A& x, const A& y)
+ {return x.i == y.i;}
+};
+
+int main()
+{
+ test<char>();
+ test<signed char>();
+ test<unsigned char>();
+ test<short>();
+ test<unsigned short>();
+ test<int>();
+ test<unsigned int>();
+ test<long>();
+ test<unsigned long>();
+ test<long long>();
+ test<unsigned long long>();
+ test<wchar_t>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<char16_t>();
+ test<char32_t>();
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+ testp<int*>();
+ testp<const int*>();
+}
diff --git a/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_sub_explicit.pass.cpp b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_sub_explicit.pass.cpp
new file mode 100644
index 000000000000..e6c92eada6df
--- /dev/null
+++ b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_sub_explicit.pass.cpp
@@ -0,0 +1,116 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+// ... test crashes clang
+
+// <atomic>
+
+// template <class Integral>
+// Integral
+// atomic_fetch_sub_explicit(volatile atomic<Integral>* obj, Integral op,
+// memory_order m);
+// template <class Integral>
+// Integral
+// atomic_fetch_sub_explicit(atomic<Integral>* obj, Integral op,
+// memory_order m);
+//
+// template <class T>
+// T*
+// atomic_fetch_sub_explicit(volatile atomic<T*>* obj, ptrdiff_t op,
+// memory_order m);
+// template <class T>
+// T*
+// atomic_fetch_sub_explicit(atomic<T*>* obj, ptrdiff_t op, memory_order m);
+
+#include <atomic>
+#include <type_traits>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+ {
+ typedef std::atomic<T> A;
+ A t;
+ std::atomic_init(&t, T(3));
+ assert(std::atomic_fetch_sub_explicit(&t, T(2),
+ std::memory_order_seq_cst) == T(3));
+ assert(t == T(1));
+ }
+ {
+ typedef std::atomic<T> A;
+ volatile A t;
+ std::atomic_init(&t, T(3));
+ assert(std::atomic_fetch_sub_explicit(&t, T(2),
+ std::memory_order_seq_cst) == T(3));
+ assert(t == T(1));
+ }
+}
+
+template <class T>
+void
+testp()
+{
+ {
+ typedef std::atomic<T> A;
+ typedef typename std::remove_pointer<T>::type X;
+ A t;
+ std::atomic_init(&t, T(3*sizeof(X)));
+ assert(std::atomic_fetch_sub_explicit(&t, 2,
+ std::memory_order_seq_cst) == T(3*sizeof(X)));
+ assert(t == T(1*sizeof(X)));
+ }
+ {
+ typedef std::atomic<T> A;
+ typedef typename std::remove_pointer<T>::type X;
+ volatile A t;
+ std::atomic_init(&t, T(3*sizeof(X)));
+ assert(std::atomic_fetch_sub_explicit(&t, 2,
+ std::memory_order_seq_cst) == T(3*sizeof(X)));
+ assert(t == T(1*sizeof(X)));
+ }
+}
+
+struct A
+{
+ int i;
+
+ explicit A(int d = 0) noexcept {i=d;}
+ A(const A& a) : i(a.i) {}
+ A(const volatile A& a) : i(a.i) {}
+
+ void operator=(const volatile A& a) volatile {i = a.i;}
+
+ friend bool operator==(const A& x, const A& y)
+ {return x.i == y.i;}
+};
+
+int main()
+{
+ test<char>();
+ test<signed char>();
+ test<unsigned char>();
+ test<short>();
+ test<unsigned short>();
+ test<int>();
+ test<unsigned int>();
+ test<long>();
+ test<unsigned long>();
+ test<long long>();
+ test<unsigned long long>();
+ test<wchar_t>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<char16_t>();
+ test<char32_t>();
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+ testp<int*>();
+ testp<const int*>();
+}
diff --git a/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_xor.pass.cpp b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_xor.pass.cpp
new file mode 100644
index 000000000000..fc6b97b7db45
--- /dev/null
+++ b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_xor.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <atomic>
+
+// template <class Integral>
+// Integral
+// atomic_fetch_xor(volatile atomic<Integral>* obj, Integral op);
+//
+// template <class Integral>
+// Integral
+// atomic_fetch_xor(atomic<Integral>* obj, Integral op);
+
+#include <atomic>
+#include <type_traits>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+ {
+ typedef std::atomic<T> A;
+ A t;
+ std::atomic_init(&t, T(1));
+ assert(std::atomic_fetch_xor(&t, T(2)) == T(1));
+ assert(t == T(3));
+ }
+ {
+ typedef std::atomic<T> A;
+ volatile A t;
+ std::atomic_init(&t, T(3));
+ assert(std::atomic_fetch_xor(&t, T(2)) == T(3));
+ assert(t == T(1));
+ }
+}
+
+int main()
+{
+ test<char>();
+ test<signed char>();
+ test<unsigned char>();
+ test<short>();
+ test<unsigned short>();
+ test<int>();
+ test<unsigned int>();
+ test<long>();
+ test<unsigned long>();
+ test<long long>();
+ test<unsigned long long>();
+ test<wchar_t>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<char16_t>();
+ test<char32_t>();
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+}
diff --git a/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_xor_explicit.pass.cpp b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_xor_explicit.pass.cpp
new file mode 100644
index 000000000000..58772aa4d152
--- /dev/null
+++ b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_xor_explicit.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <atomic>
+
+// template <class Integral>
+// Integral
+// atomic_fetch_xor_explicit(volatile atomic<Integral>* obj, Integral op);
+//
+// template <class Integral>
+// Integral
+// atomic_fetch_xor_explicit(atomic<Integral>* obj, Integral op);
+
+#include <atomic>
+#include <type_traits>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+ {
+ typedef std::atomic<T> A;
+ A t;
+ std::atomic_init(&t, T(1));
+ assert(std::atomic_fetch_xor_explicit(&t, T(2),
+ std::memory_order_seq_cst) == T(1));
+ assert(t == T(3));
+ }
+ {
+ typedef std::atomic<T> A;
+ volatile A t;
+ std::atomic_init(&t, T(3));
+ assert(std::atomic_fetch_xor_explicit(&t, T(2),
+ std::memory_order_seq_cst) == T(3));
+ assert(t == T(1));
+ }
+}
+
+int main()
+{
+ test<char>();
+ test<signed char>();
+ test<unsigned char>();
+ test<short>();
+ test<unsigned short>();
+ test<int>();
+ test<unsigned int>();
+ test<long>();
+ test<unsigned long>();
+ test<long long>();
+ test<unsigned long long>();
+ test<wchar_t>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<char16_t>();
+ test<char32_t>();
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+}
diff --git a/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_init.pass.cpp b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_init.pass.cpp
new file mode 100644
index 000000000000..137b6f60f746
--- /dev/null
+++ b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_init.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+// ... assertion fails line 34
+
+// <atomic>
+
+// template <class T>
+// void
+// atomic_init(volatile atomic<T>* obj, T desr);
+//
+// template <class T>
+// void
+// atomic_init(atomic<T>* obj, T desr);
+
+#include <atomic>
+#include <type_traits>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+ typedef std::atomic<T> A;
+ A t;
+ std::atomic_init(&t, T(1));
+ assert(t == T(1));
+ volatile A vt;
+ std::atomic_init(&vt, T(2));
+ assert(vt == T(2));
+}
+
+struct A
+{
+ int i;
+
+ explicit A(int d = 0) noexcept {i=d;}
+
+ friend bool operator==(const A& x, const A& y)
+ {return x.i == y.i;}
+};
+
+int main()
+{
+ test<A>();
+ test<char>();
+ test<signed char>();
+ test<unsigned char>();
+ test<short>();
+ test<unsigned short>();
+ test<int>();
+ test<unsigned int>();
+ test<long>();
+ test<unsigned long>();
+ test<long long>();
+ test<unsigned long long>();
+ test<wchar_t>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<char16_t>();
+ test<char32_t>();
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<int*>();
+ test<const int*>();
+}
diff --git a/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_is_lock_free.pass.cpp b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_is_lock_free.pass.cpp
new file mode 100644
index 000000000000..18a1605e2092
--- /dev/null
+++ b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_is_lock_free.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <atomic>
+
+// template <class T>
+// bool
+// atomic_is_lock_free(const volatile atomic<T>* obj);
+//
+// template <class T>
+// bool
+// atomic_is_lock_free(const atomic<T>* obj);
+
+#include <atomic>
+
+template <class T>
+void
+test()
+{
+ typedef std::atomic<T> A;
+ A t;
+ bool b1 = std::atomic_is_lock_free(static_cast<const A*>(&t));
+ volatile A vt;
+ bool b2 = std::atomic_is_lock_free(static_cast<const volatile A*>(&vt));
+}
+
+struct A
+{
+ char _[4];
+};
+
+int main()
+{
+ test<A>();
+ test<char>();
+ test<signed char>();
+ test<unsigned char>();
+ test<short>();
+ test<unsigned short>();
+ test<int>();
+ test<unsigned int>();
+ test<long>();
+ test<unsigned long>();
+ test<long long>();
+ test<unsigned long long>();
+ test<wchar_t>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<char16_t>();
+ test<char32_t>();
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<int*>();
+ test<const int*>();
+}
diff --git a/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_load.pass.cpp b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_load.pass.cpp
new file mode 100644
index 000000000000..66918c71f1f6
--- /dev/null
+++ b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_load.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+// ... assertion fails line 34
+
+// <atomic>
+
+// template <class T>
+// T
+// atomic_load(const volatile atomic<T>* obj);
+//
+// template <class T>
+// T
+// atomic_load(const atomic<T>* obj);
+
+#include <atomic>
+#include <type_traits>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+ typedef std::atomic<T> A;
+ A t;
+ std::atomic_init(&t, T(1));
+ assert(std::atomic_load(&t) == T(1));
+ volatile A vt;
+ std::atomic_init(&vt, T(2));
+ assert(std::atomic_load(&vt) == T(2));
+}
+
+struct A
+{
+ int i;
+
+ explicit A(int d = 0) noexcept {i=d;}
+
+ friend bool operator==(const A& x, const A& y)
+ {return x.i == y.i;}
+};
+
+int main()
+{
+ test<A>();
+ test<char>();
+ test<signed char>();
+ test<unsigned char>();
+ test<short>();
+ test<unsigned short>();
+ test<int>();
+ test<unsigned int>();
+ test<long>();
+ test<unsigned long>();
+ test<long long>();
+ test<unsigned long long>();
+ test<wchar_t>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<char16_t>();
+ test<char32_t>();
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<int*>();
+ test<const int*>();
+}
diff --git a/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_load_explicit.pass.cpp b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_load_explicit.pass.cpp
new file mode 100644
index 000000000000..5f402a9f139f
--- /dev/null
+++ b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_load_explicit.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+// ... assertion fails line 31
+
+// <atomic>
+
+// template <class T>
+// T
+// atomic_load_explicit(const volatile atomic<T>* obj, memory_order m);
+//
+// template <class T>
+// T
+// atomic_load_explicit(const atomic<T>* obj, memory_order m);
+
+#include <atomic>
+#include <type_traits>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+ typedef std::atomic<T> A;
+ A t;
+ std::atomic_init(&t, T(1));
+ assert(std::atomic_load_explicit(&t, std::memory_order_seq_cst) == T(1));
+ volatile A vt;
+ std::atomic_init(&vt, T(2));
+ assert(std::atomic_load_explicit(&vt, std::memory_order_seq_cst) == T(2));
+}
+
+struct A
+{
+ int i;
+
+ explicit A(int d = 0) noexcept {i=d;}
+
+ friend bool operator==(const A& x, const A& y)
+ {return x.i == y.i;}
+};
+
+int main()
+{
+ test<A>();
+ test<char>();
+ test<signed char>();
+ test<unsigned char>();
+ test<short>();
+ test<unsigned short>();
+ test<int>();
+ test<unsigned int>();
+ test<long>();
+ test<unsigned long>();
+ test<long long>();
+ test<unsigned long long>();
+ test<wchar_t>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<char16_t>();
+ test<char32_t>();
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<int*>();
+ test<const int*>();
+}
diff --git a/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_store.pass.cpp b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_store.pass.cpp
new file mode 100644
index 000000000000..2b9582b3c522
--- /dev/null
+++ b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_store.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+// ... assertion fails line 31
+
+// <atomic>
+
+// template <class T>
+// void
+// atomic_store(volatile atomic<T>* obj, T desr);
+//
+// template <class T>
+// void
+// atomic_store(atomic<T>* obj, T desr);
+
+#include <atomic>
+#include <type_traits>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+ typedef std::atomic<T> A;
+ A t;
+ std::atomic_store(&t, T(1));
+ assert(t == T(1));
+ volatile A vt;
+ std::atomic_store(&vt, T(2));
+ assert(vt == T(2));
+}
+
+struct A
+{
+ int i;
+
+ explicit A(int d = 0) noexcept {i=d;}
+
+ friend bool operator==(const A& x, const A& y)
+ {return x.i == y.i;}
+};
+
+int main()
+{
+ test<A>();
+ test<char>();
+ test<signed char>();
+ test<unsigned char>();
+ test<short>();
+ test<unsigned short>();
+ test<int>();
+ test<unsigned int>();
+ test<long>();
+ test<unsigned long>();
+ test<long long>();
+ test<unsigned long long>();
+ test<wchar_t>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<char16_t>();
+ test<char32_t>();
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<int*>();
+ test<const int*>();
+}
diff --git a/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_store_explicit.pass.cpp b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_store_explicit.pass.cpp
new file mode 100644
index 000000000000..8fe0c7d88421
--- /dev/null
+++ b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_store_explicit.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+// ... assertion fails line 31
+
+// <atomic>
+
+// template <class T>
+// void
+// atomic_store_explicit(volatile atomic<T>* obj, T desr, memory_order m);
+//
+// template <class T>
+// void
+// atomic_store_explicit(atomic<T>* obj, T desr, memory_order m);
+
+#include <atomic>
+#include <type_traits>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+ typedef std::atomic<T> A;
+ A t;
+ std::atomic_store_explicit(&t, T(1), std::memory_order_seq_cst);
+ assert(t == T(1));
+ volatile A vt;
+ std::atomic_store_explicit(&vt, T(2), std::memory_order_seq_cst);
+ assert(vt == T(2));
+}
+
+struct A
+{
+ int i;
+
+ explicit A(int d = 0) noexcept {i=d;}
+
+ friend bool operator==(const A& x, const A& y)
+ {return x.i == y.i;}
+};
+
+int main()
+{
+ test<A>();
+ test<char>();
+ test<signed char>();
+ test<unsigned char>();
+ test<short>();
+ test<unsigned short>();
+ test<int>();
+ test<unsigned int>();
+ test<long>();
+ test<unsigned long>();
+ test<long long>();
+ test<unsigned long long>();
+ test<wchar_t>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<char16_t>();
+ test<char32_t>();
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<int*>();
+ test<const int*>();
+}
diff --git a/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_var_init.pass.cpp b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_var_init.pass.cpp
new file mode 100644
index 000000000000..5fed691da268
--- /dev/null
+++ b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_var_init.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <atomic>
+
+// #define ATOMIC_VAR_INIT(value)
+
+#include <atomic>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+ std::atomic<int> v = ATOMIC_VAR_INIT(5);
+ assert(v == 5);
+}
diff --git a/test/std/atomics/atomics.types.operations/atomics.types.operations.req/ctor.pass.cpp b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/ctor.pass.cpp
new file mode 100644
index 000000000000..0eda2338d257
--- /dev/null
+++ b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/ctor.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+// UNSUPPORTED: c++98, c++03
+
+// <atomic>
+
+// constexpr atomic<T>::atomic(T value)
+
+#include <atomic>
+#include <type_traits>
+#include <cassert>
+
+struct UserType {
+ int i;
+
+ UserType() noexcept {}
+ constexpr explicit UserType(int d) noexcept : i(d) {}
+
+ friend bool operator==(const UserType& x, const UserType& y) {
+ return x.i == y.i;
+ }
+};
+
+template <class Tp>
+void test() {
+ typedef std::atomic<Tp> Atomic;
+ static_assert(std::is_literal_type<Atomic>::value, "");
+ constexpr Tp t(42);
+ {
+ constexpr Atomic a(t);
+ assert(a == t);
+ }
+ {
+ constexpr Atomic a{t};
+ assert(a == t);
+ }
+ {
+ constexpr Atomic a = ATOMIC_VAR_INIT(t);
+ assert(a == t);
+ }
+}
+
+
+int main()
+{
+ test<int>();
+ test<UserType>();
+}
diff --git a/test/std/atomics/atomics.types.operations/atomics.types.operations.templ/nothing_to_do.pass.cpp b/test/std/atomics/atomics.types.operations/atomics.types.operations.templ/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..9a59227abdd9
--- /dev/null
+++ b/test/std/atomics/atomics.types.operations/atomics.types.operations.templ/nothing_to_do.pass.cpp
@@ -0,0 +1,13 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/atomics/atomics.types.operations/nothing_to_do.pass.cpp b/test/std/atomics/atomics.types.operations/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..9a59227abdd9
--- /dev/null
+++ b/test/std/atomics/atomics.types.operations/nothing_to_do.pass.cpp
@@ -0,0 +1,13 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/atomics/libcpp-has-no-threads.fail.cpp b/test/std/atomics/libcpp-has-no-threads.fail.cpp
new file mode 100644
index 000000000000..fe95e6a5983a
--- /dev/null
+++ b/test/std/atomics/libcpp-has-no-threads.fail.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <atomic>
+
+// Test that including <atomic> fails to compile when _LIBCPP_HAS_NO_THREADS
+// is defined.
+
+#ifndef _LIBCPP_HAS_NO_THREADS
+#define _LIBCPP_HAS_NO_THREADS
+#endif
+
+#include <atomic>
+
+int main()
+{
+}
diff --git a/test/std/atomics/libcpp-has-no-threads.pass.cpp b/test/std/atomics/libcpp-has-no-threads.pass.cpp
new file mode 100644
index 000000000000..9c0cccbda380
--- /dev/null
+++ b/test/std/atomics/libcpp-has-no-threads.pass.cpp
@@ -0,0 +1,18 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// XFAIL: libcpp-has-no-threads
+
+#ifdef _LIBCPP_HAS_NO_THREADS
+#error This should be XFAIL'd for the purpose of detecting that the LIT feature\
+ 'libcpp-has-no-threads' is available iff _LIBCPP_HAS_NO_THREADS is defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/atomics/version.pass.cpp b/test/std/atomics/version.pass.cpp
new file mode 100644
index 000000000000..fae2736d229f
--- /dev/null
+++ b/test/std/atomics/version.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <atomic>
+
+#include <atomic>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/containers/Copyable.h b/test/std/containers/Copyable.h
new file mode 100644
index 000000000000..9542c7e8516f
--- /dev/null
+++ b/test/std/containers/Copyable.h
@@ -0,0 +1,18 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef COPYABLE_H
+#define COPYABLE_H
+
+class Copyable
+{
+public:
+};
+
+#endif // COPYABLE_H
diff --git a/test/std/containers/Emplaceable.h b/test/std/containers/Emplaceable.h
new file mode 100644
index 000000000000..34dd326203b0
--- /dev/null
+++ b/test/std/containers/Emplaceable.h
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef EMPLACEABLE_H
+#define EMPLACEABLE_H
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+class Emplaceable
+{
+ Emplaceable(const Emplaceable&);
+ Emplaceable& operator=(const Emplaceable&);
+
+ int int_;
+ double double_;
+public:
+ Emplaceable() : int_(0), double_(0) {}
+ Emplaceable(int i, double d) : int_(i), double_(d) {}
+ Emplaceable(Emplaceable&& x)
+ : int_(x.int_), double_(x.double_)
+ {x.int_ = 0; x.double_ = 0;}
+ Emplaceable& operator=(Emplaceable&& x)
+ {int_ = x.int_; x.int_ = 0;
+ double_ = x.double_; x.double_ = 0;
+ return *this;}
+
+ bool operator==(const Emplaceable& x) const
+ {return int_ == x.int_ && double_ == x.double_;}
+ bool operator<(const Emplaceable& x) const
+ {return int_ < x.int_ || (int_ == x.int_ && double_ < x.double_);}
+
+ int get() const {return int_;}
+};
+
+namespace std {
+
+template <>
+struct hash<Emplaceable>
+ : public std::unary_function<Emplaceable, std::size_t>
+{
+ std::size_t operator()(const Emplaceable& x) const {return x.get();}
+};
+
+}
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+#endif // EMPLACEABLE_H
diff --git a/test/std/containers/NotConstructible.h b/test/std/containers/NotConstructible.h
new file mode 100644
index 000000000000..ac8b98ef99f0
--- /dev/null
+++ b/test/std/containers/NotConstructible.h
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef NOTCONSTRUCTIBLE_H
+#define NOTCONSTRUCTIBLE_H
+
+#include <functional>
+
+class NotConstructible
+{
+ NotConstructible(const NotConstructible&);
+ NotConstructible& operator=(const NotConstructible&);
+public:
+};
+
+inline
+bool
+operator==(const NotConstructible&, const NotConstructible&)
+{return true;}
+
+namespace std
+{
+
+template <>
+struct hash<NotConstructible>
+ : public std::unary_function<NotConstructible, std::size_t>
+{
+ std::size_t operator()(const NotConstructible&) const {return 0;}
+};
+
+}
+
+#endif // NOTCONSTRUCTIBLE_H
diff --git a/test/std/containers/associative/map/compare.pass.cpp b/test/std/containers/associative/map/compare.pass.cpp
new file mode 100644
index 000000000000..aa4d5999ff46
--- /dev/null
+++ b/test/std/containers/associative/map/compare.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// template <class Key, class T, class Compare = less<Key>,
+// class Allocator = allocator<pair<const Key, T>>>
+// class map
+
+// http://llvm.org/bugs/show_bug.cgi?id=16538
+// http://llvm.org/bugs/show_bug.cgi?id=16549
+
+#include <map>
+
+struct Key {
+ template <typename T> Key(const T&) {}
+ bool operator< (const Key&) const { return false; }
+};
+
+int
+main()
+{
+ std::map<Key, int>::iterator it = std::map<Key, int>().find(Key(0));
+ std::pair<std::map<Key, int>::iterator, bool> result =
+ std::map<Key, int>().insert(std::make_pair(Key(0), 0));
+}
diff --git a/test/std/containers/associative/map/map.access/at.pass.cpp b/test/std/containers/associative/map/map.access/at.pass.cpp
new file mode 100644
index 000000000000..86b1e3d2dfa6
--- /dev/null
+++ b/test/std/containers/associative/map/map.access/at.pass.cpp
@@ -0,0 +1,154 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// mapped_type& at(const key_type& k);
+// const mapped_type& at(const key_type& k) const;
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1.5),
+ V(2, 2.5),
+ V(3, 3.5),
+ V(4, 4.5),
+ V(5, 5.5),
+ V(7, 7.5),
+ V(8, 8.5),
+ };
+ std::map<int, double> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 7);
+ assert(m.at(1) == 1.5);
+ m.at(1) = -1.5;
+ assert(m.at(1) == -1.5);
+ assert(m.at(2) == 2.5);
+ assert(m.at(3) == 3.5);
+ assert(m.at(4) == 4.5);
+ assert(m.at(5) == 5.5);
+ try
+ {
+ m.at(6);
+ assert(false);
+ }
+ catch (std::out_of_range&)
+ {
+ }
+ assert(m.at(7) == 7.5);
+ assert(m.at(8) == 8.5);
+ assert(m.size() == 7);
+ }
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1.5),
+ V(2, 2.5),
+ V(3, 3.5),
+ V(4, 4.5),
+ V(5, 5.5),
+ V(7, 7.5),
+ V(8, 8.5),
+ };
+ const std::map<int, double> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 7);
+ assert(m.at(1) == 1.5);
+ assert(m.at(2) == 2.5);
+ assert(m.at(3) == 3.5);
+ assert(m.at(4) == 4.5);
+ assert(m.at(5) == 5.5);
+ try
+ {
+ m.at(6);
+ assert(false);
+ }
+ catch (std::out_of_range&)
+ {
+ }
+ assert(m.at(7) == 7.5);
+ assert(m.at(8) == 8.5);
+ assert(m.size() == 7);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1.5),
+ V(2, 2.5),
+ V(3, 3.5),
+ V(4, 4.5),
+ V(5, 5.5),
+ V(7, 7.5),
+ V(8, 8.5),
+ };
+ std::map<int, double, std::less<int>, min_allocator<V>> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 7);
+ assert(m.at(1) == 1.5);
+ m.at(1) = -1.5;
+ assert(m.at(1) == -1.5);
+ assert(m.at(2) == 2.5);
+ assert(m.at(3) == 3.5);
+ assert(m.at(4) == 4.5);
+ assert(m.at(5) == 5.5);
+ try
+ {
+ m.at(6);
+ assert(false);
+ }
+ catch (std::out_of_range&)
+ {
+ }
+ assert(m.at(7) == 7.5);
+ assert(m.at(8) == 8.5);
+ assert(m.size() == 7);
+ }
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1.5),
+ V(2, 2.5),
+ V(3, 3.5),
+ V(4, 4.5),
+ V(5, 5.5),
+ V(7, 7.5),
+ V(8, 8.5),
+ };
+ const std::map<int, double, std::less<int>, min_allocator<V>> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 7);
+ assert(m.at(1) == 1.5);
+ assert(m.at(2) == 2.5);
+ assert(m.at(3) == 3.5);
+ assert(m.at(4) == 4.5);
+ assert(m.at(5) == 5.5);
+ try
+ {
+ m.at(6);
+ assert(false);
+ }
+ catch (std::out_of_range&)
+ {
+ }
+ assert(m.at(7) == 7.5);
+ assert(m.at(8) == 8.5);
+ assert(m.size() == 7);
+ }
+#endif
+}
diff --git a/test/std/containers/associative/map/map.access/empty.pass.cpp b/test/std/containers/associative/map/map.access/empty.pass.cpp
new file mode 100644
index 000000000000..b11e94c8042c
--- /dev/null
+++ b/test/std/containers/associative/map/map.access/empty.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// bool empty() const;
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::map<int, double> M;
+ M m;
+ assert(m.empty());
+ m.insert(M::value_type(1, 1.5));
+ assert(!m.empty());
+ m.clear();
+ assert(m.empty());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+ M m;
+ assert(m.empty());
+ m.insert(M::value_type(1, 1.5));
+ assert(!m.empty());
+ m.clear();
+ assert(m.empty());
+ }
+#endif
+}
diff --git a/test/std/containers/associative/map/map.access/index_key.pass.cpp b/test/std/containers/associative/map/map.access/index_key.pass.cpp
new file mode 100644
index 000000000000..ab1144c60afd
--- /dev/null
+++ b/test/std/containers/associative/map/map.access/index_key.pass.cpp
@@ -0,0 +1,105 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// mapped_type& operator[](const key_type& k);
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "private_constructor.hpp"
+
+int main()
+{
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1.5),
+ V(2, 2.5),
+ V(3, 3.5),
+ V(4, 4.5),
+ V(5, 5.5),
+ V(7, 7.5),
+ V(8, 8.5),
+ };
+ std::map<int, double> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 7);
+ assert(m[1] == 1.5);
+ assert(m.size() == 7);
+ m[1] = -1.5;
+ assert(m[1] == -1.5);
+ assert(m.size() == 7);
+ assert(m[6] == 0);
+ assert(m.size() == 8);
+ m[6] = 6.5;
+ assert(m[6] == 6.5);
+ assert(m.size() == 8);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1.5),
+ V(2, 2.5),
+ V(3, 3.5),
+ V(4, 4.5),
+ V(5, 5.5),
+ V(7, 7.5),
+ V(8, 8.5),
+ };
+ std::map<int, double, std::less<int>, min_allocator<V>> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 7);
+ assert(m[1] == 1.5);
+ assert(m.size() == 7);
+ const int i = 1;
+ m[i] = -1.5;
+ assert(m[1] == -1.5);
+ assert(m.size() == 7);
+ assert(m[6] == 0);
+ assert(m.size() == 8);
+ m[6] = 6.5;
+ assert(m[6] == 6.5);
+ assert(m.size() == 8);
+ }
+#endif
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1.5),
+ V(2, 2.5),
+ V(3, 3.5),
+ V(4, 4.5),
+ V(5, 5.5),
+ V(7, 7.5),
+ V(8, 8.5),
+ };
+ std::map<int, double, std::less<>> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+
+ assert(m.size() == 7);
+ assert(m[1] == 1.5);
+ assert(m.size() == 7);
+ m[1] = -1.5;
+ assert(m[1] == -1.5);
+ assert(m.size() == 7);
+ assert(m[6] == 0);
+ assert(m.size() == 8);
+ m[6] = 6.5;
+ assert(m[6] == 6.5);
+ assert(m.size() == 8);
+ }
+#endif
+}
diff --git a/test/std/containers/associative/map/map.access/index_rv_key.pass.cpp b/test/std/containers/associative/map/map.access/index_rv_key.pass.cpp
new file mode 100644
index 000000000000..d14603e1a281
--- /dev/null
+++ b/test/std/containers/associative/map/map.access/index_rv_key.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// mapped_type& operator[](key_type&& k);
+
+#include <map>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::pair<MoveOnly, double> V;
+ std::map<MoveOnly, double> m;
+ assert(m.size() == 0);
+ assert(m[1] == 0.0);
+ assert(m.size() == 1);
+ m[1] = -1.5;
+ assert(m[1] == -1.5);
+ assert(m.size() == 1);
+ assert(m[6] == 0);
+ assert(m.size() == 2);
+ m[6] = 6.5;
+ assert(m[6] == 6.5);
+ assert(m.size() == 2);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<MoveOnly, double> V;
+ std::map<MoveOnly, double, std::less<MoveOnly>, min_allocator<V>> m;
+ assert(m.size() == 0);
+ assert(m[1] == 0.0);
+ assert(m.size() == 1);
+ m[1] = -1.5;
+ assert(m[1] == -1.5);
+ assert(m.size() == 1);
+ assert(m[6] == 0);
+ assert(m.size() == 2);
+ m[6] = 6.5;
+ assert(m[6] == 6.5);
+ assert(m.size() == 2);
+ }
+#endif
+}
diff --git a/test/std/containers/associative/map/map.access/index_tuple.pass.cpp b/test/std/containers/associative/map/map.access/index_tuple.pass.cpp
new file mode 100644
index 000000000000..9a00829eadd6
--- /dev/null
+++ b/test/std/containers/associative/map/map.access/index_tuple.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// mapped_type& operator[](const key_type& k);
+
+// http://llvm.org/bugs/show_bug.cgi?id=16542
+
+#include <map>
+
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+
+#include <tuple>
+
+#endif
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+ using namespace std;
+ map<tuple<int,int>, size_t> m;
+ m[make_tuple(2,3)]=7;
+#endif
+}
diff --git a/test/std/containers/associative/map/map.access/iterator.pass.cpp b/test/std/containers/associative/map/map.access/iterator.pass.cpp
new file mode 100644
index 000000000000..552e87d8fc8d
--- /dev/null
+++ b/test/std/containers/associative/map/map.access/iterator.pass.cpp
@@ -0,0 +1,227 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// iterator begin();
+// const_iterator begin() const;
+// iterator end();
+// const_iterator end() const;
+//
+// reverse_iterator rbegin();
+// const_reverse_iterator rbegin() const;
+// reverse_iterator rend();
+// const_reverse_iterator rend() const;
+//
+// const_iterator cbegin() const;
+// const_iterator cend() const;
+// const_reverse_iterator crbegin() const;
+// const_reverse_iterator crend() const;
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ V(4, 1),
+ V(4, 1.5),
+ V(4, 2),
+ V(5, 1),
+ V(5, 1.5),
+ V(5, 2),
+ V(6, 1),
+ V(6, 1.5),
+ V(6, 2),
+ V(7, 1),
+ V(7, 1.5),
+ V(7, 2),
+ V(8, 1),
+ V(8, 1.5),
+ V(8, 2)
+ };
+ std::map<int, double> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ assert(std::distance(m.begin(), m.end()) == m.size());
+ assert(std::distance(m.rbegin(), m.rend()) == m.size());
+ std::map<int, double>::iterator i;
+ i = m.begin();
+ std::map<int, double>::const_iterator k = i;
+ assert(i == k);
+ for (int j = 1; j <= m.size(); ++j, ++i)
+ {
+ assert(i->first == j);
+ assert(i->second == 1);
+ i->second = 2.5;
+ assert(i->second == 2.5);
+ }
+ }
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ V(4, 1),
+ V(4, 1.5),
+ V(4, 2),
+ V(5, 1),
+ V(5, 1.5),
+ V(5, 2),
+ V(6, 1),
+ V(6, 1.5),
+ V(6, 2),
+ V(7, 1),
+ V(7, 1.5),
+ V(7, 2),
+ V(8, 1),
+ V(8, 1.5),
+ V(8, 2)
+ };
+ const std::map<int, double> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ assert(std::distance(m.begin(), m.end()) == m.size());
+ assert(std::distance(m.cbegin(), m.cend()) == m.size());
+ assert(std::distance(m.rbegin(), m.rend()) == m.size());
+ assert(std::distance(m.crbegin(), m.crend()) == m.size());
+ std::map<int, double>::const_iterator i;
+ i = m.begin();
+ for (int j = 1; j <= m.size(); ++j, ++i)
+ {
+ assert(i->first == j);
+ assert(i->second == 1);
+ }
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ V(4, 1),
+ V(4, 1.5),
+ V(4, 2),
+ V(5, 1),
+ V(5, 1.5),
+ V(5, 2),
+ V(6, 1),
+ V(6, 1.5),
+ V(6, 2),
+ V(7, 1),
+ V(7, 1.5),
+ V(7, 2),
+ V(8, 1),
+ V(8, 1.5),
+ V(8, 2)
+ };
+ std::map<int, double, std::less<int>, min_allocator<V>> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ assert(std::distance(m.begin(), m.end()) == m.size());
+ assert(std::distance(m.rbegin(), m.rend()) == m.size());
+ std::map<int, double, std::less<int>, min_allocator<V>>::iterator i;
+ i = m.begin();
+ std::map<int, double, std::less<int>, min_allocator<V>>::const_iterator k = i;
+ assert(i == k);
+ for (int j = 1; j <= m.size(); ++j, ++i)
+ {
+ assert(i->first == j);
+ assert(i->second == 1);
+ i->second = 2.5;
+ assert(i->second == 2.5);
+ }
+ }
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ V(4, 1),
+ V(4, 1.5),
+ V(4, 2),
+ V(5, 1),
+ V(5, 1.5),
+ V(5, 2),
+ V(6, 1),
+ V(6, 1.5),
+ V(6, 2),
+ V(7, 1),
+ V(7, 1.5),
+ V(7, 2),
+ V(8, 1),
+ V(8, 1.5),
+ V(8, 2)
+ };
+ const std::map<int, double, std::less<int>, min_allocator<V>> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ assert(std::distance(m.begin(), m.end()) == m.size());
+ assert(std::distance(m.cbegin(), m.cend()) == m.size());
+ assert(std::distance(m.rbegin(), m.rend()) == m.size());
+ assert(std::distance(m.crbegin(), m.crend()) == m.size());
+ std::map<int, double, std::less<int>, min_allocator<V>>::const_iterator i;
+ i = m.begin();
+ for (int j = 1; j <= m.size(); ++j, ++i)
+ {
+ assert(i->first == j);
+ assert(i->second == 1);
+ }
+ }
+#endif
+#if _LIBCPP_STD_VER > 11
+ { // N3644 testing
+ typedef std::map<int, double> C;
+ C::iterator ii1{}, ii2{};
+ C::iterator ii4 = ii1;
+ C::const_iterator cii{};
+ assert ( ii1 == ii2 );
+ assert ( ii1 == ii4 );
+
+ assert (!(ii1 != ii2 ));
+
+ assert ( (ii1 == cii ));
+ assert ( (cii == ii1 ));
+ assert (!(ii1 != cii ));
+ assert (!(cii != ii1 ));
+ }
+#endif
+}
diff --git a/test/std/containers/associative/map/map.access/max_size.pass.cpp b/test/std/containers/associative/map/map.access/max_size.pass.cpp
new file mode 100644
index 000000000000..551120d331e1
--- /dev/null
+++ b/test/std/containers/associative/map/map.access/max_size.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// size_type max_size() const;
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::map<int, double> M;
+ M m;
+ assert(m.max_size() != 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+ M m;
+ assert(m.max_size() != 0);
+ }
+#endif
+}
diff --git a/test/std/containers/associative/map/map.access/size.pass.cpp b/test/std/containers/associative/map/map.access/size.pass.cpp
new file mode 100644
index 000000000000..07c12322a460
--- /dev/null
+++ b/test/std/containers/associative/map/map.access/size.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// size_type size() const;
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::map<int, double> M;
+ M m;
+ assert(m.size() == 0);
+ m.insert(M::value_type(2, 1.5));
+ assert(m.size() == 1);
+ m.insert(M::value_type(1, 1.5));
+ assert(m.size() == 2);
+ m.insert(M::value_type(3, 1.5));
+ assert(m.size() == 3);
+ m.erase(m.begin());
+ assert(m.size() == 2);
+ m.erase(m.begin());
+ assert(m.size() == 1);
+ m.erase(m.begin());
+ assert(m.size() == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+ M m;
+ assert(m.size() == 0);
+ m.insert(M::value_type(2, 1.5));
+ assert(m.size() == 1);
+ m.insert(M::value_type(1, 1.5));
+ assert(m.size() == 2);
+ m.insert(M::value_type(3, 1.5));
+ assert(m.size() == 3);
+ m.erase(m.begin());
+ assert(m.size() == 2);
+ m.erase(m.begin());
+ assert(m.size() == 1);
+ m.erase(m.begin());
+ assert(m.size() == 0);
+ }
+#endif
+}
diff --git a/test/std/containers/associative/map/map.cons/alloc.pass.cpp b/test/std/containers/associative/map/map.cons/alloc.pass.cpp
new file mode 100644
index 000000000000..2292c47ef74b
--- /dev/null
+++ b/test/std/containers/associative/map/map.cons/alloc.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// explicit map(const allocator_type& a);
+
+#include <map>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::less<int> C;
+ typedef test_allocator<std::pair<const int, double> > A;
+ std::map<int, double, C, A> m(A(5));
+ assert(m.empty());
+ assert(m.begin() == m.end());
+ assert(m.get_allocator() == A(5));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::less<int> C;
+ typedef min_allocator<std::pair<const int, double> > A;
+ std::map<int, double, C, A> m(A{});
+ assert(m.empty());
+ assert(m.begin() == m.end());
+ assert(m.get_allocator() == A());
+ }
+#endif
+}
diff --git a/test/std/containers/associative/map/map.cons/assign_initializer_list.pass.cpp b/test/std/containers/associative/map/map.cons/assign_initializer_list.pass.cpp
new file mode 100644
index 000000000000..482d1acff840
--- /dev/null
+++ b/test/std/containers/associative/map/map.cons/assign_initializer_list.pass.cpp
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// map& operator=(initializer_list<value_type> il);
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::pair<const int, double> V;
+ std::map<int, double> m =
+ {
+ {20, 1},
+ };
+ m =
+ {
+ {1, 1},
+ {1, 1.5},
+ {1, 2},
+ {2, 1},
+ {2, 1.5},
+ {2, 2},
+ {3, 1},
+ {3, 1.5},
+ {3, 2}
+ };
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(2, 1));
+ assert(*next(m.begin(), 2) == V(3, 1));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<const int, double> V;
+ std::map<int, double, std::less<int>, min_allocator<V>> m =
+ {
+ {20, 1},
+ };
+ m =
+ {
+ {1, 1},
+ {1, 1.5},
+ {1, 2},
+ {2, 1},
+ {2, 1.5},
+ {2, 2},
+ {3, 1},
+ {3, 1.5},
+ {3, 2}
+ };
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(2, 1));
+ assert(*next(m.begin(), 2) == V(3, 1));
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/containers/associative/map/map.cons/compare.pass.cpp b/test/std/containers/associative/map/map.cons/compare.pass.cpp
new file mode 100644
index 000000000000..5a213c8e8b8f
--- /dev/null
+++ b/test/std/containers/associative/map/map.cons/compare.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// explicit map(const key_compare& comp);
+
+#include <map>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef test_compare<std::less<int> > C;
+ std::map<int, double, C> m(C(3));
+ assert(m.empty());
+ assert(m.begin() == m.end());
+ assert(m.key_comp() == C(3));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef test_compare<std::less<int> > C;
+ std::map<int, double, C, min_allocator<std::pair<const int, double>>> m(C(3));
+ assert(m.empty());
+ assert(m.begin() == m.end());
+ assert(m.key_comp() == C(3));
+ }
+#endif
+}
diff --git a/test/std/containers/associative/map/map.cons/compare_alloc.pass.cpp b/test/std/containers/associative/map/map.cons/compare_alloc.pass.cpp
new file mode 100644
index 000000000000..56b3c3315e08
--- /dev/null
+++ b/test/std/containers/associative/map/map.cons/compare_alloc.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// map(const key_compare& comp, const allocator_type& a);
+
+#include <map>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef test_compare<std::less<int> > C;
+ typedef test_allocator<std::pair<const int, double> > A;
+ std::map<int, double, C, A> m(C(4), A(5));
+ assert(m.empty());
+ assert(m.begin() == m.end());
+ assert(m.key_comp() == C(4));
+ assert(m.get_allocator() == A(5));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef test_compare<std::less<int> > C;
+ typedef min_allocator<std::pair<const int, double> > A;
+ std::map<int, double, C, A> m(C(4), A());
+ assert(m.empty());
+ assert(m.begin() == m.end());
+ assert(m.key_comp() == C(4));
+ assert(m.get_allocator() == A());
+ }
+#endif
+}
diff --git a/test/std/containers/associative/map/map.cons/copy.pass.cpp b/test/std/containers/associative/map/map.cons/copy.pass.cpp
new file mode 100644
index 000000000000..be5274133082
--- /dev/null
+++ b/test/std/containers/associative/map/map.cons/copy.pass.cpp
@@ -0,0 +1,131 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// map(const map& m);
+
+#include <map>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ };
+ typedef test_compare<std::less<int> > C;
+ typedef test_allocator<V> A;
+ std::map<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
+ std::map<int, double, C, A> m = mo;
+ assert(m.get_allocator() == A(7));
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(2, 1));
+ assert(*next(m.begin(), 2) == V(3, 1));
+
+ assert(mo.get_allocator() == A(7));
+ assert(mo.key_comp() == C(5));
+ assert(mo.size() == 3);
+ assert(distance(mo.begin(), mo.end()) == 3);
+ assert(*mo.begin() == V(1, 1));
+ assert(*next(mo.begin()) == V(2, 1));
+ assert(*next(mo.begin(), 2) == V(3, 1));
+ }
+#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ };
+ typedef test_compare<std::less<int> > C;
+ typedef other_allocator<V> A;
+ std::map<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
+ std::map<int, double, C, A> m = mo;
+ assert(m.get_allocator() == A(-2));
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(2, 1));
+ assert(*next(m.begin(), 2) == V(3, 1));
+
+ assert(mo.get_allocator() == A(7));
+ assert(mo.key_comp() == C(5));
+ assert(mo.size() == 3);
+ assert(distance(mo.begin(), mo.end()) == 3);
+ assert(*mo.begin() == V(1, 1));
+ assert(*next(mo.begin()) == V(2, 1));
+ assert(*next(mo.begin(), 2) == V(3, 1));
+ }
+#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ };
+ typedef test_compare<std::less<int> > C;
+ typedef min_allocator<V> A;
+ std::map<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A());
+ std::map<int, double, C, A> m = mo;
+ assert(m.get_allocator() == A());
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(2, 1));
+ assert(*next(m.begin(), 2) == V(3, 1));
+
+ assert(mo.get_allocator() == A());
+ assert(mo.key_comp() == C(5));
+ assert(mo.size() == 3);
+ assert(distance(mo.begin(), mo.end()) == 3);
+ assert(*mo.begin() == V(1, 1));
+ assert(*next(mo.begin()) == V(2, 1));
+ assert(*next(mo.begin(), 2) == V(3, 1));
+ }
+#endif
+}
diff --git a/test/std/containers/associative/map/map.cons/copy_alloc.pass.cpp b/test/std/containers/associative/map/map.cons/copy_alloc.pass.cpp
new file mode 100644
index 000000000000..fcbe5976d6da
--- /dev/null
+++ b/test/std/containers/associative/map/map.cons/copy_alloc.pass.cpp
@@ -0,0 +1,95 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// map(const map& m, const allocator_type& a);
+
+#include <map>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ };
+ typedef test_compare<std::less<int> > C;
+ typedef test_allocator<V> A;
+ std::map<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
+ std::map<int, double, C, A> m(mo, A(3));
+ assert(m.get_allocator() == A(3));
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(2, 1));
+ assert(*next(m.begin(), 2) == V(3, 1));
+
+ assert(mo.get_allocator() == A(7));
+ assert(mo.key_comp() == C(5));
+ assert(mo.size() == 3);
+ assert(distance(mo.begin(), mo.end()) == 3);
+ assert(*mo.begin() == V(1, 1));
+ assert(*next(mo.begin()) == V(2, 1));
+ assert(*next(mo.begin(), 2) == V(3, 1));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ };
+ typedef test_compare<std::less<int> > C;
+ typedef min_allocator<V> A;
+ std::map<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A());
+ std::map<int, double, C, A> m(mo, A());
+ assert(m.get_allocator() == A());
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(2, 1));
+ assert(*next(m.begin(), 2) == V(3, 1));
+
+ assert(mo.get_allocator() == A());
+ assert(mo.key_comp() == C(5));
+ assert(mo.size() == 3);
+ assert(distance(mo.begin(), mo.end()) == 3);
+ assert(*mo.begin() == V(1, 1));
+ assert(*next(mo.begin()) == V(2, 1));
+ assert(*next(mo.begin(), 2) == V(3, 1));
+ }
+#endif
+}
diff --git a/test/std/containers/associative/map/map.cons/copy_assign.pass.cpp b/test/std/containers/associative/map/map.cons/copy_assign.pass.cpp
new file mode 100644
index 000000000000..a1bcb30f4294
--- /dev/null
+++ b/test/std/containers/associative/map/map.cons/copy_assign.pass.cpp
@@ -0,0 +1,182 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// map& operator=(const map& m);
+
+#include <map>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2)
+ };
+ typedef test_compare<std::less<int> > C;
+ typedef test_allocator<V> A;
+ std::map<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(2));
+ std::map<int, double, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0])/2, C(3), A(7));
+ m = mo;
+ assert(m.get_allocator() == A(7));
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(2, 1));
+ assert(*next(m.begin(), 2) == V(3, 1));
+
+ assert(mo.get_allocator() == A(2));
+ assert(mo.key_comp() == C(5));
+ assert(mo.size() == 3);
+ assert(distance(mo.begin(), mo.end()) == 3);
+ assert(*mo.begin() == V(1, 1));
+ assert(*next(mo.begin()) == V(2, 1));
+ assert(*next(mo.begin(), 2) == V(3, 1));
+ }
+ {
+ typedef std::pair<const int, double> V;
+ const V ar[] =
+ {
+ V(1, 1),
+ V(2, 1),
+ V(3, 1),
+ };
+ std::map<int, double> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ std::map<int, double> *p = &m;
+ m = *p;
+
+ assert(m.size() == 3);
+ assert(std::equal(m.begin(), m.end(), ar));
+ }
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2)
+ };
+ typedef test_compare<std::less<int> > C;
+ typedef other_allocator<V> A;
+ std::map<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(2));
+ std::map<int, double, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0])/2, C(3), A(7));
+ m = mo;
+ assert(m.get_allocator() == A(2));
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(2, 1));
+ assert(*next(m.begin(), 2) == V(3, 1));
+
+ assert(mo.get_allocator() == A(2));
+ assert(mo.key_comp() == C(5));
+ assert(mo.size() == 3);
+ assert(distance(mo.begin(), mo.end()) == 3);
+ assert(*mo.begin() == V(1, 1));
+ assert(*next(mo.begin()) == V(2, 1));
+ assert(*next(mo.begin(), 2) == V(3, 1));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2)
+ };
+ typedef test_compare<std::less<int> > C;
+ typedef min_allocator<V> A;
+ std::map<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A());
+ std::map<int, double, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0])/2, C(3), A());
+ m = mo;
+ assert(m.get_allocator() == A());
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(2, 1));
+ assert(*next(m.begin(), 2) == V(3, 1));
+
+ assert(mo.get_allocator() == A());
+ assert(mo.key_comp() == C(5));
+ assert(mo.size() == 3);
+ assert(distance(mo.begin(), mo.end()) == 3);
+ assert(*mo.begin() == V(1, 1));
+ assert(*next(mo.begin()) == V(2, 1));
+ assert(*next(mo.begin(), 2) == V(3, 1));
+ }
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2)
+ };
+ typedef test_compare<std::less<int> > C;
+ typedef min_allocator<V> A;
+ std::map<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A());
+ std::map<int, double, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0])/2, C(3), A());
+ m = mo;
+ assert(m.get_allocator() == A());
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(2, 1));
+ assert(*next(m.begin(), 2) == V(3, 1));
+
+ assert(mo.get_allocator() == A());
+ assert(mo.key_comp() == C(5));
+ assert(mo.size() == 3);
+ assert(distance(mo.begin(), mo.end()) == 3);
+ assert(*mo.begin() == V(1, 1));
+ assert(*next(mo.begin()) == V(2, 1));
+ assert(*next(mo.begin(), 2) == V(3, 1));
+ }
+#endif
+}
diff --git a/test/std/containers/associative/map/map.cons/default.pass.cpp b/test/std/containers/associative/map/map.cons/default.pass.cpp
new file mode 100644
index 000000000000..1832a32fffb3
--- /dev/null
+++ b/test/std/containers/associative/map/map.cons/default.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// map();
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::map<int, double> m;
+ assert(m.empty());
+ assert(m.begin() == m.end());
+ }
+#if __cplusplus >= 201103L
+ {
+ std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> m;
+ assert(m.empty());
+ assert(m.begin() == m.end());
+ }
+ {
+ std::map<int, double> m = {};
+ assert(m.empty());
+ assert(m.begin() == m.end());
+ }
+#endif
+}
diff --git a/test/std/containers/associative/map/map.cons/default_noexcept.pass.cpp b/test/std/containers/associative/map/map.cons/default_noexcept.pass.cpp
new file mode 100644
index 000000000000..1f11fc9582ed
--- /dev/null
+++ b/test/std/containers/associative/map/map.cons/default_noexcept.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// map()
+// noexcept(
+// is_nothrow_default_constructible<allocator_type>::value &&
+// is_nothrow_default_constructible<key_compare>::value &&
+// is_nothrow_copy_constructible<key_compare>::value);
+
+// This tests a conforming extension
+
+#include <map>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_comp
+{
+ typedef T value_type;
+ some_comp();
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::map<MoveOnly, MoveOnly> C;
+ static_assert(std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::map<MoveOnly, MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::map<MoveOnly, MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C;
+ static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::map<MoveOnly, MoveOnly, some_comp<MoveOnly>> C;
+ static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+ }
+#endif
+}
diff --git a/test/std/containers/associative/map/map.cons/default_recursive.pass.cpp b/test/std/containers/associative/map/map.cons/default_recursive.pass.cpp
new file mode 100644
index 000000000000..b4b72725fd6e
--- /dev/null
+++ b/test/std/containers/associative/map/map.cons/default_recursive.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// map();
+
+#include <map>
+
+struct X
+{
+ std::map<int, X> m;
+ std::map<int, X>::iterator i;
+ std::map<int, X>::const_iterator ci;
+ std::map<int, X>::reverse_iterator ri;
+ std::map<int, X>::const_reverse_iterator cri;
+};
+
+int main()
+{
+}
diff --git a/test/std/containers/associative/map/map.cons/dtor_noexcept.pass.cpp b/test/std/containers/associative/map/map.cons/dtor_noexcept.pass.cpp
new file mode 100644
index 000000000000..eed26d3a6136
--- /dev/null
+++ b/test/std/containers/associative/map/map.cons/dtor_noexcept.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// ~map() // implied noexcept;
+
+#include <map>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "test_allocator.h"
+
+#if __has_feature(cxx_noexcept)
+
+template <class T>
+struct some_comp
+{
+ typedef T value_type;
+ ~some_comp() noexcept(false);
+};
+
+#endif
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::map<MoveOnly, MoveOnly> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::map<MoveOnly, MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::map<MoveOnly, MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::map<MoveOnly, MoveOnly, some_comp<MoveOnly>> C;
+ static_assert(!std::is_nothrow_destructible<C>::value, "");
+ }
+#endif
+}
diff --git a/test/std/containers/associative/map/map.cons/initializer_list.pass.cpp b/test/std/containers/associative/map/map.cons/initializer_list.pass.cpp
new file mode 100644
index 000000000000..196943653a14
--- /dev/null
+++ b/test/std/containers/associative/map/map.cons/initializer_list.pass.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// map(initializer_list<value_type> il);
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::pair<const int, double> V;
+ std::map<int, double> m =
+ {
+ {1, 1},
+ {1, 1.5},
+ {1, 2},
+ {2, 1},
+ {2, 1.5},
+ {2, 2},
+ {3, 1},
+ {3, 1.5},
+ {3, 2}
+ };
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(2, 1));
+ assert(*next(m.begin(), 2) == V(3, 1));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<const int, double> V;
+ std::map<int, double, std::less<int>, min_allocator<V>> m =
+ {
+ {1, 1},
+ {1, 1.5},
+ {1, 2},
+ {2, 1},
+ {2, 1.5},
+ {2, 2},
+ {3, 1},
+ {3, 1.5},
+ {3, 2}
+ };
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(2, 1));
+ assert(*next(m.begin(), 2) == V(3, 1));
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/containers/associative/map/map.cons/initializer_list_compare.pass.cpp b/test/std/containers/associative/map/map.cons/initializer_list_compare.pass.cpp
new file mode 100644
index 000000000000..08f8a529f030
--- /dev/null
+++ b/test/std/containers/associative/map/map.cons/initializer_list_compare.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// map(initializer_list<value_type> il, const key_compare& comp);
+
+#include <map>
+#include <cassert>
+#include "../../../test_compare.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::pair<const int, double> V;
+ typedef test_compare<std::less<int> > C;
+ std::map<int, double, C> m({
+ {1, 1},
+ {1, 1.5},
+ {1, 2},
+ {2, 1},
+ {2, 1.5},
+ {2, 2},
+ {3, 1},
+ {3, 1.5},
+ {3, 2}
+ }, C(3));
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(2, 1));
+ assert(*next(m.begin(), 2) == V(3, 1));
+ assert(m.key_comp() == C(3));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<const int, double> V;
+ typedef test_compare<std::less<int> > C;
+ std::map<int, double, C, min_allocator<std::pair<const int, double>>> m({
+ {1, 1},
+ {1, 1.5},
+ {1, 2},
+ {2, 1},
+ {2, 1.5},
+ {2, 2},
+ {3, 1},
+ {3, 1.5},
+ {3, 2}
+ }, C(3));
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(2, 1));
+ assert(*next(m.begin(), 2) == V(3, 1));
+ assert(m.key_comp() == C(3));
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/containers/associative/map/map.cons/initializer_list_compare_alloc.pass.cpp b/test/std/containers/associative/map/map.cons/initializer_list_compare_alloc.pass.cpp
new file mode 100644
index 000000000000..765428a631e5
--- /dev/null
+++ b/test/std/containers/associative/map/map.cons/initializer_list_compare_alloc.pass.cpp
@@ -0,0 +1,100 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// map(initializer_list<value_type> il, const key_compare& comp, const allocator_type& a);
+
+#include <map>
+#include <cassert>
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::pair<const int, double> V;
+ typedef test_compare<std::less<int> > C;
+ typedef test_allocator<std::pair<const int, double> > A;
+ std::map<int, double, C, A> m({
+ {1, 1},
+ {1, 1.5},
+ {1, 2},
+ {2, 1},
+ {2, 1.5},
+ {2, 2},
+ {3, 1},
+ {3, 1.5},
+ {3, 2}
+ }, C(3), A(6));
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(2, 1));
+ assert(*next(m.begin(), 2) == V(3, 1));
+ assert(m.key_comp() == C(3));
+ assert(m.get_allocator() == A(6));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<const int, double> V;
+ typedef test_compare<std::less<int> > C;
+ typedef min_allocator<std::pair<const int, double> > A;
+ std::map<int, double, C, A> m({
+ {1, 1},
+ {1, 1.5},
+ {1, 2},
+ {2, 1},
+ {2, 1.5},
+ {2, 2},
+ {3, 1},
+ {3, 1.5},
+ {3, 2}
+ }, C(3), A());
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(2, 1));
+ assert(*next(m.begin(), 2) == V(3, 1));
+ assert(m.key_comp() == C(3));
+ assert(m.get_allocator() == A());
+ }
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::pair<const int, double> V;
+ typedef min_allocator<V> A;
+ typedef test_compare<std::less<int> > C;
+ typedef std::map<int, double, C, A> M;
+ A a;
+ M m ({ {1, 1},
+ {1, 1.5},
+ {1, 2},
+ {2, 1},
+ {2, 1.5},
+ {2, 2},
+ {3, 1},
+ {3, 1.5},
+ {3, 2}
+ }, a);
+
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(2, 1));
+ assert(*next(m.begin(), 2) == V(3, 1));
+ assert(m.get_allocator() == a);
+ }
+#endif
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/containers/associative/map/map.cons/iter_iter.pass.cpp b/test/std/containers/associative/map/map.cons/iter_iter.pass.cpp
new file mode 100644
index 000000000000..c1029af6889e
--- /dev/null
+++ b/test/std/containers/associative/map/map.cons/iter_iter.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// template <class InputIterator>
+// map(InputIterator first, InputIterator last);
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ };
+ std::map<int, double> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(2, 1));
+ assert(*next(m.begin(), 2) == V(3, 1));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ };
+ std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(2, 1));
+ assert(*next(m.begin(), 2) == V(3, 1));
+ }
+#endif
+}
diff --git a/test/std/containers/associative/map/map.cons/iter_iter_comp.pass.cpp b/test/std/containers/associative/map/map.cons/iter_iter_comp.pass.cpp
new file mode 100644
index 000000000000..837fa8c6cdea
--- /dev/null
+++ b/test/std/containers/associative/map/map.cons/iter_iter_comp.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// template <class InputIterator>
+// map(InputIterator first, InputIterator last, const key_compare& comp);
+
+#include <map>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ };
+ typedef test_compare<std::less<int> > C;
+ std::map<int, double, C> m(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5));
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(2, 1));
+ assert(*next(m.begin(), 2) == V(3, 1));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ };
+ typedef test_compare<std::less<int> > C;
+ std::map<int, double, C, min_allocator<std::pair<const int, double>>> m(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5));
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(2, 1));
+ assert(*next(m.begin(), 2) == V(3, 1));
+ }
+#endif
+}
diff --git a/test/std/containers/associative/map/map.cons/iter_iter_comp_alloc.pass.cpp b/test/std/containers/associative/map/map.cons/iter_iter_comp_alloc.pass.cpp
new file mode 100644
index 000000000000..67fb5d644762
--- /dev/null
+++ b/test/std/containers/associative/map/map.cons/iter_iter_comp_alloc.pass.cpp
@@ -0,0 +1,108 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// template <class InputIterator>
+// map(InputIterator first, InputIterator last,
+// const key_compare& comp, const allocator_type& a);
+
+#include <map>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ };
+ typedef test_compare<std::less<int> > C;
+ typedef test_allocator<V> A;
+ std::map<int, double, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
+ assert(m.get_allocator() == A(7));
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(2, 1));
+ assert(*next(m.begin(), 2) == V(3, 1));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ };
+ typedef test_compare<std::less<int> > C;
+ typedef min_allocator<V> A;
+ std::map<int, double, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A());
+ assert(m.get_allocator() == A());
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(2, 1));
+ assert(*next(m.begin(), 2) == V(3, 1));
+ }
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ };
+ typedef std::pair<const int, double> V;
+ typedef min_allocator<V> A;
+ typedef test_compare<std::less<int> > C;
+ A a;
+ std::map<int, double, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0]), a );
+
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(2, 1));
+ assert(*next(m.begin(), 2) == V(3, 1));
+ assert(m.get_allocator() == a);
+ }
+#endif
+#endif
+}
diff --git a/test/std/containers/associative/map/map.cons/move.pass.cpp b/test/std/containers/associative/map/map.cons/move.pass.cpp
new file mode 100644
index 000000000000..c06f2ee5021b
--- /dev/null
+++ b/test/std/containers/associative/map/map.cons/move.pass.cpp
@@ -0,0 +1,120 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// map(map&& m);
+
+#include <map>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ typedef std::pair<const int, double> V;
+ {
+ typedef test_compare<std::less<int> > C;
+ typedef test_allocator<V> A;
+ std::map<int, double, C, A> mo(C(5), A(7));
+ std::map<int, double, C, A> m = std::move(mo);
+ assert(m.get_allocator() == A(7));
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 0);
+ assert(distance(m.begin(), m.end()) == 0);
+
+ assert(mo.get_allocator() == A(7));
+ assert(mo.key_comp() == C(5));
+ assert(mo.size() == 0);
+ assert(distance(mo.begin(), mo.end()) == 0);
+ }
+ {
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ };
+ typedef test_compare<std::less<int> > C;
+ typedef test_allocator<V> A;
+ std::map<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
+ std::map<int, double, C, A> m = std::move(mo);
+ assert(m.get_allocator() == A(7));
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(2, 1));
+ assert(*next(m.begin(), 2) == V(3, 1));
+
+ assert(mo.get_allocator() == A(7));
+ assert(mo.key_comp() == C(5));
+ assert(mo.size() == 0);
+ assert(distance(mo.begin(), mo.end()) == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef test_compare<std::less<int> > C;
+ typedef min_allocator<V> A;
+ std::map<int, double, C, A> mo(C(5), A());
+ std::map<int, double, C, A> m = std::move(mo);
+ assert(m.get_allocator() == A());
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 0);
+ assert(distance(m.begin(), m.end()) == 0);
+
+ assert(mo.get_allocator() == A());
+ assert(mo.key_comp() == C(5));
+ assert(mo.size() == 0);
+ assert(distance(mo.begin(), mo.end()) == 0);
+ }
+ {
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ };
+ typedef test_compare<std::less<int> > C;
+ typedef min_allocator<V> A;
+ std::map<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A());
+ std::map<int, double, C, A> m = std::move(mo);
+ assert(m.get_allocator() == A());
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(2, 1));
+ assert(*next(m.begin(), 2) == V(3, 1));
+
+ assert(mo.get_allocator() == A());
+ assert(mo.key_comp() == C(5));
+ assert(mo.size() == 0);
+ assert(distance(mo.begin(), mo.end()) == 0);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/associative/map/map.cons/move_alloc.pass.cpp b/test/std/containers/associative/map/map.cons/move_alloc.pass.cpp
new file mode 100644
index 000000000000..e5d43f266c08
--- /dev/null
+++ b/test/std/containers/associative/map/map.cons/move_alloc.pass.cpp
@@ -0,0 +1,234 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// map(map&& m, const allocator_type& a);
+
+#include <map>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+#include "Counter.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::pair<MoveOnly, MoveOnly> V;
+ typedef std::pair<const MoveOnly, MoveOnly> VC;
+ typedef test_compare<std::less<MoveOnly> > C;
+ typedef test_allocator<VC> A;
+ typedef std::map<MoveOnly, MoveOnly, C, A> M;
+ typedef std::move_iterator<V*> I;
+ V a1[] =
+ {
+ V(1, 1),
+ V(1, 2),
+ V(1, 3),
+ V(2, 1),
+ V(2, 2),
+ V(2, 3),
+ V(3, 1),
+ V(3, 2),
+ V(3, 3)
+ };
+ M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+ V a2[] =
+ {
+ V(1, 1),
+ V(1, 2),
+ V(1, 3),
+ V(2, 1),
+ V(2, 2),
+ V(2, 3),
+ V(3, 1),
+ V(3, 2),
+ V(3, 3)
+ };
+ M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+ M m3(std::move(m1), A(7));
+ assert(m3 == m2);
+ assert(m3.get_allocator() == A(7));
+ assert(m3.key_comp() == C(5));
+ assert(m1.empty());
+ }
+ {
+ typedef std::pair<MoveOnly, MoveOnly> V;
+ typedef std::pair<const MoveOnly, MoveOnly> VC;
+ typedef test_compare<std::less<MoveOnly> > C;
+ typedef test_allocator<VC> A;
+ typedef std::map<MoveOnly, MoveOnly, C, A> M;
+ typedef std::move_iterator<V*> I;
+ V a1[] =
+ {
+ V(1, 1),
+ V(1, 2),
+ V(1, 3),
+ V(2, 1),
+ V(2, 2),
+ V(2, 3),
+ V(3, 1),
+ V(3, 2),
+ V(3, 3)
+ };
+ M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+ V a2[] =
+ {
+ V(1, 1),
+ V(1, 2),
+ V(1, 3),
+ V(2, 1),
+ V(2, 2),
+ V(2, 3),
+ V(3, 1),
+ V(3, 2),
+ V(3, 3)
+ };
+ M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+ M m3(std::move(m1), A(5));
+ assert(m3 == m2);
+ assert(m3.get_allocator() == A(5));
+ assert(m3.key_comp() == C(5));
+ assert(m1.empty());
+ }
+ {
+ typedef std::pair<MoveOnly, MoveOnly> V;
+ typedef std::pair<const MoveOnly, MoveOnly> VC;
+ typedef test_compare<std::less<MoveOnly> > C;
+ typedef other_allocator<VC> A;
+ typedef std::map<MoveOnly, MoveOnly, C, A> M;
+ typedef std::move_iterator<V*> I;
+ V a1[] =
+ {
+ V(1, 1),
+ V(1, 2),
+ V(1, 3),
+ V(2, 1),
+ V(2, 2),
+ V(2, 3),
+ V(3, 1),
+ V(3, 2),
+ V(3, 3)
+ };
+ M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+ V a2[] =
+ {
+ V(1, 1),
+ V(1, 2),
+ V(1, 3),
+ V(2, 1),
+ V(2, 2),
+ V(2, 3),
+ V(3, 1),
+ V(3, 2),
+ V(3, 3)
+ };
+ M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+ M m3(std::move(m1), A(5));
+ assert(m3 == m2);
+ assert(m3.get_allocator() == A(5));
+ assert(m3.key_comp() == C(5));
+ assert(m1.empty());
+ }
+ {
+ typedef Counter<int> T;
+ typedef std::pair<int, T> V;
+ typedef std::pair<const int, T> VC;
+ typedef test_allocator<VC> A;
+ typedef std::less<int> C;
+ typedef std::map<const int, T, C, A> M;
+ typedef V* I;
+ Counter_base::gConstructed = 0;
+ {
+ V a1[] =
+ {
+ V(1, 1),
+ V(1, 2),
+ V(1, 3),
+ V(2, 1),
+ V(2, 2),
+ V(2, 3),
+ V(3, 1),
+ V(3, 2),
+ V(3, 3)
+ };
+ const size_t num = sizeof(a1)/sizeof(a1[0]);
+ assert(Counter_base::gConstructed == num);
+
+ M m1(I(a1), I(a1+num), C(), A());
+ assert(Counter_base::gConstructed == num+3);
+
+ M m2(m1);
+ assert(m2 == m1);
+ assert(Counter_base::gConstructed == num+6);
+
+ M m3(std::move(m1), A());
+ assert(m3 == m2);
+ assert(m1.empty());
+ assert(Counter_base::gConstructed == num+6);
+
+ {
+ M m4(std::move(m2), A(5));
+ assert(Counter_base::gConstructed == num+6);
+ assert(m4 == m3);
+ assert(m2.empty());
+ }
+ assert(Counter_base::gConstructed == num+3);
+ }
+ assert(Counter_base::gConstructed == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<MoveOnly, MoveOnly> V;
+ typedef std::pair<const MoveOnly, MoveOnly> VC;
+ typedef test_compare<std::less<MoveOnly> > C;
+ typedef min_allocator<VC> A;
+ typedef std::map<MoveOnly, MoveOnly, C, A> M;
+ typedef std::move_iterator<V*> I;
+ V a1[] =
+ {
+ V(1, 1),
+ V(1, 2),
+ V(1, 3),
+ V(2, 1),
+ V(2, 2),
+ V(2, 3),
+ V(3, 1),
+ V(3, 2),
+ V(3, 3)
+ };
+ M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A());
+ V a2[] =
+ {
+ V(1, 1),
+ V(1, 2),
+ V(1, 3),
+ V(2, 1),
+ V(2, 2),
+ V(2, 3),
+ V(3, 1),
+ V(3, 2),
+ V(3, 3)
+ };
+ M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A());
+ M m3(std::move(m1), A());
+ assert(m3 == m2);
+ assert(m3.get_allocator() == A());
+ assert(m3.key_comp() == C(5));
+ assert(m1.empty());
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/associative/map/map.cons/move_assign.pass.cpp b/test/std/containers/associative/map/map.cons/move_assign.pass.cpp
new file mode 100644
index 000000000000..8ae8265cdc12
--- /dev/null
+++ b/test/std/containers/associative/map/map.cons/move_assign.pass.cpp
@@ -0,0 +1,190 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// map& operator=(map&& m);
+
+#include <map>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::pair<MoveOnly, MoveOnly> V;
+ typedef std::pair<const MoveOnly, MoveOnly> VC;
+ typedef test_compare<std::less<MoveOnly> > C;
+ typedef test_allocator<VC> A;
+ typedef std::map<MoveOnly, MoveOnly, C, A> M;
+ typedef std::move_iterator<V*> I;
+ V a1[] =
+ {
+ V(1, 1),
+ V(1, 2),
+ V(1, 3),
+ V(2, 1),
+ V(2, 2),
+ V(2, 3),
+ V(3, 1),
+ V(3, 2),
+ V(3, 3)
+ };
+ M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+ V a2[] =
+ {
+ V(1, 1),
+ V(1, 2),
+ V(1, 3),
+ V(2, 1),
+ V(2, 2),
+ V(2, 3),
+ V(3, 1),
+ V(3, 2),
+ V(3, 3)
+ };
+ M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+ M m3(C(3), A(7));
+ m3 = std::move(m1);
+ assert(m3 == m2);
+ assert(m3.get_allocator() == A(7));
+ assert(m3.key_comp() == C(5));
+ assert(m1.empty());
+ }
+ {
+ typedef std::pair<MoveOnly, MoveOnly> V;
+ typedef std::pair<const MoveOnly, MoveOnly> VC;
+ typedef test_compare<std::less<MoveOnly> > C;
+ typedef test_allocator<VC> A;
+ typedef std::map<MoveOnly, MoveOnly, C, A> M;
+ typedef std::move_iterator<V*> I;
+ V a1[] =
+ {
+ V(1, 1),
+ V(1, 2),
+ V(1, 3),
+ V(2, 1),
+ V(2, 2),
+ V(2, 3),
+ V(3, 1),
+ V(3, 2),
+ V(3, 3)
+ };
+ M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+ V a2[] =
+ {
+ V(1, 1),
+ V(1, 2),
+ V(1, 3),
+ V(2, 1),
+ V(2, 2),
+ V(2, 3),
+ V(3, 1),
+ V(3, 2),
+ V(3, 3)
+ };
+ M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+ M m3(C(3), A(5));
+ m3 = std::move(m1);
+ assert(m3 == m2);
+ assert(m3.get_allocator() == A(5));
+ assert(m3.key_comp() == C(5));
+ assert(m1.empty());
+ }
+ {
+ typedef std::pair<MoveOnly, MoveOnly> V;
+ typedef std::pair<const MoveOnly, MoveOnly> VC;
+ typedef test_compare<std::less<MoveOnly> > C;
+ typedef other_allocator<VC> A;
+ typedef std::map<MoveOnly, MoveOnly, C, A> M;
+ typedef std::move_iterator<V*> I;
+ V a1[] =
+ {
+ V(1, 1),
+ V(1, 2),
+ V(1, 3),
+ V(2, 1),
+ V(2, 2),
+ V(2, 3),
+ V(3, 1),
+ V(3, 2),
+ V(3, 3)
+ };
+ M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+ V a2[] =
+ {
+ V(1, 1),
+ V(1, 2),
+ V(1, 3),
+ V(2, 1),
+ V(2, 2),
+ V(2, 3),
+ V(3, 1),
+ V(3, 2),
+ V(3, 3)
+ };
+ M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+ M m3(C(3), A(5));
+ m3 = std::move(m1);
+ assert(m3 == m2);
+ assert(m3.get_allocator() == A(7));
+ assert(m3.key_comp() == C(5));
+ assert(m1.empty());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<MoveOnly, MoveOnly> V;
+ typedef std::pair<const MoveOnly, MoveOnly> VC;
+ typedef test_compare<std::less<MoveOnly> > C;
+ typedef min_allocator<VC> A;
+ typedef std::map<MoveOnly, MoveOnly, C, A> M;
+ typedef std::move_iterator<V*> I;
+ V a1[] =
+ {
+ V(1, 1),
+ V(1, 2),
+ V(1, 3),
+ V(2, 1),
+ V(2, 2),
+ V(2, 3),
+ V(3, 1),
+ V(3, 2),
+ V(3, 3)
+ };
+ M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A());
+ V a2[] =
+ {
+ V(1, 1),
+ V(1, 2),
+ V(1, 3),
+ V(2, 1),
+ V(2, 2),
+ V(2, 3),
+ V(3, 1),
+ V(3, 2),
+ V(3, 3)
+ };
+ M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A());
+ M m3(C(3), A());
+ m3 = std::move(m1);
+ assert(m3 == m2);
+ assert(m3.get_allocator() == A());
+ assert(m3.key_comp() == C(5));
+ assert(m1.empty());
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/associative/map/map.cons/move_assign_noexcept.pass.cpp b/test/std/containers/associative/map/map.cons/move_assign_noexcept.pass.cpp
new file mode 100644
index 000000000000..f80b1d323178
--- /dev/null
+++ b/test/std/containers/associative/map/map.cons/move_assign_noexcept.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// map& operator=(map&& c)
+// noexcept(
+// allocator_type::propagate_on_container_move_assignment::value &&
+// is_nothrow_move_assignable<allocator_type>::value &&
+// is_nothrow_move_assignable<key_compare>::value);
+
+// This tests a conforming extension
+
+#include <map>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_comp
+{
+ typedef T value_type;
+ some_comp& operator=(const some_comp&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::map<MoveOnly, MoveOnly> C;
+ static_assert(std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::map<MoveOnly, MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::map<MoveOnly, MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::map<MoveOnly, MoveOnly, some_comp<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+ }
+#endif
+}
diff --git a/test/std/containers/associative/map/map.cons/move_noexcept.pass.cpp b/test/std/containers/associative/map/map.cons/move_noexcept.pass.cpp
new file mode 100644
index 000000000000..9347b8329ae3
--- /dev/null
+++ b/test/std/containers/associative/map/map.cons/move_noexcept.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// map(map&&)
+// noexcept(is_nothrow_move_constructible<allocator_type>::value &&
+// is_nothrow_move_constructible<key_compare>::value);
+
+// This tests a conforming extension
+
+#include <map>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_comp
+{
+ typedef T value_type;
+ some_comp(const some_comp&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::map<MoveOnly, MoveOnly> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::map<MoveOnly, MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::map<MoveOnly, MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::map<MoveOnly, MoveOnly, some_comp<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_constructible<C>::value, "");
+ }
+#endif
+}
diff --git a/test/std/containers/associative/map/map.modifiers/clear.pass.cpp b/test/std/containers/associative/map/map.modifiers/clear.pass.cpp
new file mode 100644
index 000000000000..c37499df307a
--- /dev/null
+++ b/test/std/containers/associative/map/map.modifiers/clear.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// void clear();
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::map<int, double> M;
+ typedef std::pair<int, double> P;
+ P ar[] =
+ {
+ P(1, 1.5),
+ P(2, 2.5),
+ P(3, 3.5),
+ P(4, 4.5),
+ P(5, 5.5),
+ P(6, 6.5),
+ P(7, 7.5),
+ P(8, 8.5),
+ };
+ M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 8);
+ m.clear();
+ assert(m.size() == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+ typedef std::pair<int, double> P;
+ P ar[] =
+ {
+ P(1, 1.5),
+ P(2, 2.5),
+ P(3, 3.5),
+ P(4, 4.5),
+ P(5, 5.5),
+ P(6, 6.5),
+ P(7, 7.5),
+ P(8, 8.5),
+ };
+ M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 8);
+ m.clear();
+ assert(m.size() == 0);
+ }
+#endif
+}
diff --git a/test/std/containers/associative/map/map.modifiers/emplace.pass.cpp b/test/std/containers/associative/map/map.modifiers/emplace.pass.cpp
new file mode 100644
index 000000000000..81846c6647c6
--- /dev/null
+++ b/test/std/containers/associative/map/map.modifiers/emplace.pass.cpp
@@ -0,0 +1,165 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// template <class... Args>
+// pair<iterator, bool> emplace(Args&&... args);
+
+#include <map>
+#include <cassert>
+#include <tuple>
+
+#include "../../../Emplaceable.h"
+#include "DefaultOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::map<int, DefaultOnly> M;
+ typedef std::pair<M::iterator, bool> R;
+ M m;
+ assert(DefaultOnly::count == 0);
+ R r = m.emplace();
+ assert(r.second);
+ assert(r.first == m.begin());
+ assert(m.size() == 1);
+ assert(m.begin()->first == 0);
+ assert(m.begin()->second == DefaultOnly());
+ assert(DefaultOnly::count == 1);
+ r = m.emplace(std::piecewise_construct, std::forward_as_tuple(1),
+ std::forward_as_tuple());
+ assert(r.second);
+ assert(r.first == next(m.begin()));
+ assert(m.size() == 2);
+ assert(next(m.begin())->first == 1);
+ assert(next(m.begin())->second == DefaultOnly());
+ assert(DefaultOnly::count == 2);
+ r = m.emplace(std::piecewise_construct, std::forward_as_tuple(1),
+ std::forward_as_tuple());
+ assert(!r.second);
+ assert(r.first == next(m.begin()));
+ assert(m.size() == 2);
+ assert(next(m.begin())->first == 1);
+ assert(next(m.begin())->second == DefaultOnly());
+ assert(DefaultOnly::count == 2);
+ }
+ assert(DefaultOnly::count == 0);
+ {
+ typedef std::map<int, Emplaceable> M;
+ typedef std::pair<M::iterator, bool> R;
+ M m;
+ R r = m.emplace(std::piecewise_construct, std::forward_as_tuple(2),
+ std::forward_as_tuple());
+ assert(r.second);
+ assert(r.first == m.begin());
+ assert(m.size() == 1);
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == Emplaceable());
+ r = m.emplace(std::piecewise_construct, std::forward_as_tuple(1),
+ std::forward_as_tuple(2, 3.5));
+ assert(r.second);
+ assert(r.first == m.begin());
+ assert(m.size() == 2);
+ assert(m.begin()->first == 1);
+ assert(m.begin()->second == Emplaceable(2, 3.5));
+ r = m.emplace(std::piecewise_construct, std::forward_as_tuple(1),
+ std::forward_as_tuple(2, 3.5));
+ assert(!r.second);
+ assert(r.first == m.begin());
+ assert(m.size() == 2);
+ assert(m.begin()->first == 1);
+ assert(m.begin()->second == Emplaceable(2, 3.5));
+ }
+ {
+ typedef std::map<int, double> M;
+ typedef std::pair<M::iterator, bool> R;
+ M m;
+ R r = m.emplace(M::value_type(2, 3.5));
+ assert(r.second);
+ assert(r.first == m.begin());
+ assert(m.size() == 1);
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == 3.5);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::map<int, DefaultOnly, std::less<int>, min_allocator<std::pair<const int, DefaultOnly>>> M;
+ typedef std::pair<M::iterator, bool> R;
+ M m;
+ assert(DefaultOnly::count == 0);
+ R r = m.emplace();
+ assert(r.second);
+ assert(r.first == m.begin());
+ assert(m.size() == 1);
+ assert(m.begin()->first == 0);
+ assert(m.begin()->second == DefaultOnly());
+ assert(DefaultOnly::count == 1);
+ r = m.emplace(std::piecewise_construct, std::forward_as_tuple(1),
+ std::forward_as_tuple());
+ assert(r.second);
+ assert(r.first == next(m.begin()));
+ assert(m.size() == 2);
+ assert(next(m.begin())->first == 1);
+ assert(next(m.begin())->second == DefaultOnly());
+ assert(DefaultOnly::count == 2);
+ r = m.emplace(std::piecewise_construct, std::forward_as_tuple(1),
+ std::forward_as_tuple());
+ assert(!r.second);
+ assert(r.first == next(m.begin()));
+ assert(m.size() == 2);
+ assert(next(m.begin())->first == 1);
+ assert(next(m.begin())->second == DefaultOnly());
+ assert(DefaultOnly::count == 2);
+ }
+ assert(DefaultOnly::count == 0);
+ {
+ typedef std::map<int, Emplaceable, std::less<int>, min_allocator<std::pair<const int, Emplaceable>>> M;
+ typedef std::pair<M::iterator, bool> R;
+ M m;
+ R r = m.emplace(std::piecewise_construct, std::forward_as_tuple(2),
+ std::forward_as_tuple());
+ assert(r.second);
+ assert(r.first == m.begin());
+ assert(m.size() == 1);
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == Emplaceable());
+ r = m.emplace(std::piecewise_construct, std::forward_as_tuple(1),
+ std::forward_as_tuple(2, 3.5));
+ assert(r.second);
+ assert(r.first == m.begin());
+ assert(m.size() == 2);
+ assert(m.begin()->first == 1);
+ assert(m.begin()->second == Emplaceable(2, 3.5));
+ r = m.emplace(std::piecewise_construct, std::forward_as_tuple(1),
+ std::forward_as_tuple(2, 3.5));
+ assert(!r.second);
+ assert(r.first == m.begin());
+ assert(m.size() == 2);
+ assert(m.begin()->first == 1);
+ assert(m.begin()->second == Emplaceable(2, 3.5));
+ }
+ {
+ typedef std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+ typedef std::pair<M::iterator, bool> R;
+ M m;
+ R r = m.emplace(M::value_type(2, 3.5));
+ assert(r.second);
+ assert(r.first == m.begin());
+ assert(m.size() == 1);
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == 3.5);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/associative/map/map.modifiers/emplace_hint.pass.cpp b/test/std/containers/associative/map/map.modifiers/emplace_hint.pass.cpp
new file mode 100644
index 000000000000..15f74b17e786
--- /dev/null
+++ b/test/std/containers/associative/map/map.modifiers/emplace_hint.pass.cpp
@@ -0,0 +1,160 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// template <class... Args>
+// iterator emplace_hint(const_iterator position, Args&&... args);
+
+#include <map>
+#include <cassert>
+
+#include "../../../Emplaceable.h"
+#include "DefaultOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::map<int, DefaultOnly> M;
+ typedef M::iterator R;
+ M m;
+ assert(DefaultOnly::count == 0);
+ R r = m.emplace_hint(m.end());
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(m.begin()->first == 0);
+ assert(m.begin()->second == DefaultOnly());
+ assert(DefaultOnly::count == 1);
+ r = m.emplace_hint(m.end(), std::piecewise_construct,
+ std::forward_as_tuple(1),
+ std::forward_as_tuple());
+ assert(r == next(m.begin()));
+ assert(m.size() == 2);
+ assert(next(m.begin())->first == 1);
+ assert(next(m.begin())->second == DefaultOnly());
+ assert(DefaultOnly::count == 2);
+ r = m.emplace_hint(m.end(), std::piecewise_construct,
+ std::forward_as_tuple(1),
+ std::forward_as_tuple());
+ assert(r == next(m.begin()));
+ assert(m.size() == 2);
+ assert(next(m.begin())->first == 1);
+ assert(next(m.begin())->second == DefaultOnly());
+ assert(DefaultOnly::count == 2);
+ }
+ assert(DefaultOnly::count == 0);
+ {
+ typedef std::map<int, Emplaceable> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.emplace_hint(m.end(), std::piecewise_construct,
+ std::forward_as_tuple(2),
+ std::forward_as_tuple());
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == Emplaceable());
+ r = m.emplace_hint(m.end(), std::piecewise_construct,
+ std::forward_as_tuple(1),
+ std::forward_as_tuple(2, 3.5));
+ assert(r == m.begin());
+ assert(m.size() == 2);
+ assert(m.begin()->first == 1);
+ assert(m.begin()->second == Emplaceable(2, 3.5));
+ r = m.emplace_hint(m.end(), std::piecewise_construct,
+ std::forward_as_tuple(1),
+ std::forward_as_tuple(2, 3.5));
+ assert(r == m.begin());
+ assert(m.size() == 2);
+ assert(m.begin()->first == 1);
+ assert(m.begin()->second == Emplaceable(2, 3.5));
+ }
+ {
+ typedef std::map<int, double> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.emplace_hint(m.end(), M::value_type(2, 3.5));
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == 3.5);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::map<int, DefaultOnly, std::less<int>, min_allocator<std::pair<const int, DefaultOnly>>> M;
+ typedef M::iterator R;
+ M m;
+ assert(DefaultOnly::count == 0);
+ R r = m.emplace_hint(m.end());
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(m.begin()->first == 0);
+ assert(m.begin()->second == DefaultOnly());
+ assert(DefaultOnly::count == 1);
+ r = m.emplace_hint(m.end(), std::piecewise_construct,
+ std::forward_as_tuple(1),
+ std::forward_as_tuple());
+ assert(r == next(m.begin()));
+ assert(m.size() == 2);
+ assert(next(m.begin())->first == 1);
+ assert(next(m.begin())->second == DefaultOnly());
+ assert(DefaultOnly::count == 2);
+ r = m.emplace_hint(m.end(), std::piecewise_construct,
+ std::forward_as_tuple(1),
+ std::forward_as_tuple());
+ assert(r == next(m.begin()));
+ assert(m.size() == 2);
+ assert(next(m.begin())->first == 1);
+ assert(next(m.begin())->second == DefaultOnly());
+ assert(DefaultOnly::count == 2);
+ }
+ assert(DefaultOnly::count == 0);
+ {
+ typedef std::map<int, Emplaceable, std::less<int>, min_allocator<std::pair<const int, Emplaceable>>> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.emplace_hint(m.end(), std::piecewise_construct,
+ std::forward_as_tuple(2),
+ std::forward_as_tuple());
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == Emplaceable());
+ r = m.emplace_hint(m.end(), std::piecewise_construct,
+ std::forward_as_tuple(1),
+ std::forward_as_tuple(2, 3.5));
+ assert(r == m.begin());
+ assert(m.size() == 2);
+ assert(m.begin()->first == 1);
+ assert(m.begin()->second == Emplaceable(2, 3.5));
+ r = m.emplace_hint(m.end(), std::piecewise_construct,
+ std::forward_as_tuple(1),
+ std::forward_as_tuple(2, 3.5));
+ assert(r == m.begin());
+ assert(m.size() == 2);
+ assert(m.begin()->first == 1);
+ assert(m.begin()->second == Emplaceable(2, 3.5));
+ }
+ {
+ typedef std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.emplace_hint(m.end(), M::value_type(2, 3.5));
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == 3.5);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/associative/map/map.modifiers/erase_iter.pass.cpp b/test/std/containers/associative/map/map.modifiers/erase_iter.pass.cpp
new file mode 100644
index 000000000000..15c5ce041b68
--- /dev/null
+++ b/test/std/containers/associative/map/map.modifiers/erase_iter.pass.cpp
@@ -0,0 +1,259 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// iterator erase(const_iterator position);
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+struct TemplateConstructor
+{
+ template<typename T>
+ TemplateConstructor (const T&) {}
+};
+
+bool operator<(const TemplateConstructor&, const TemplateConstructor&) { return false; }
+
+int main()
+{
+ {
+ typedef std::map<int, double> M;
+ typedef std::pair<int, double> P;
+ typedef M::iterator I;
+ P ar[] =
+ {
+ P(1, 1.5),
+ P(2, 2.5),
+ P(3, 3.5),
+ P(4, 4.5),
+ P(5, 5.5),
+ P(6, 6.5),
+ P(7, 7.5),
+ P(8, 8.5),
+ };
+ M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 8);
+ I i = m.erase(next(m.cbegin(), 3));
+ assert(m.size() == 7);
+ assert(i == next(m.begin(), 3));
+ assert(m.begin()->first == 1);
+ assert(m.begin()->second == 1.5);
+ assert(next(m.begin())->first == 2);
+ assert(next(m.begin())->second == 2.5);
+ assert(next(m.begin(), 2)->first == 3);
+ assert(next(m.begin(), 2)->second == 3.5);
+ assert(next(m.begin(), 3)->first == 5);
+ assert(next(m.begin(), 3)->second == 5.5);
+ assert(next(m.begin(), 4)->first == 6);
+ assert(next(m.begin(), 4)->second == 6.5);
+ assert(next(m.begin(), 5)->first == 7);
+ assert(next(m.begin(), 5)->second == 7.5);
+ assert(next(m.begin(), 6)->first == 8);
+ assert(next(m.begin(), 6)->second == 8.5);
+
+ i = m.erase(next(m.cbegin(), 0));
+ assert(m.size() == 6);
+ assert(i == m.begin());
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == 2.5);
+ assert(next(m.begin())->first == 3);
+ assert(next(m.begin())->second == 3.5);
+ assert(next(m.begin(), 2)->first == 5);
+ assert(next(m.begin(), 2)->second == 5.5);
+ assert(next(m.begin(), 3)->first == 6);
+ assert(next(m.begin(), 3)->second == 6.5);
+ assert(next(m.begin(), 4)->first == 7);
+ assert(next(m.begin(), 4)->second == 7.5);
+ assert(next(m.begin(), 5)->first == 8);
+ assert(next(m.begin(), 5)->second == 8.5);
+
+ i = m.erase(next(m.cbegin(), 5));
+ assert(m.size() == 5);
+ assert(i == m.end());
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == 2.5);
+ assert(next(m.begin())->first == 3);
+ assert(next(m.begin())->second == 3.5);
+ assert(next(m.begin(), 2)->first == 5);
+ assert(next(m.begin(), 2)->second == 5.5);
+ assert(next(m.begin(), 3)->first == 6);
+ assert(next(m.begin(), 3)->second == 6.5);
+ assert(next(m.begin(), 4)->first == 7);
+ assert(next(m.begin(), 4)->second == 7.5);
+
+ i = m.erase(next(m.cbegin(), 1));
+ assert(m.size() == 4);
+ assert(i == next(m.begin()));
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == 2.5);
+ assert(next(m.begin())->first == 5);
+ assert(next(m.begin())->second == 5.5);
+ assert(next(m.begin(), 2)->first == 6);
+ assert(next(m.begin(), 2)->second == 6.5);
+ assert(next(m.begin(), 3)->first == 7);
+ assert(next(m.begin(), 3)->second == 7.5);
+
+ i = m.erase(next(m.cbegin(), 2));
+ assert(m.size() == 3);
+ assert(i == next(m.begin(), 2));
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == 2.5);
+ assert(next(m.begin())->first == 5);
+ assert(next(m.begin())->second == 5.5);
+ assert(next(m.begin(), 2)->first == 7);
+ assert(next(m.begin(), 2)->second == 7.5);
+
+ i = m.erase(next(m.cbegin(), 2));
+ assert(m.size() == 2);
+ assert(i == next(m.begin(), 2));
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == 2.5);
+ assert(next(m.begin())->first == 5);
+ assert(next(m.begin())->second == 5.5);
+
+ i = m.erase(next(m.cbegin(), 0));
+ assert(m.size() == 1);
+ assert(i == next(m.begin(), 0));
+ assert(m.begin()->first == 5);
+ assert(m.begin()->second == 5.5);
+
+ i = m.erase(m.cbegin());
+ assert(m.size() == 0);
+ assert(i == m.begin());
+ assert(i == m.end());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+ typedef std::pair<int, double> P;
+ typedef M::iterator I;
+ P ar[] =
+ {
+ P(1, 1.5),
+ P(2, 2.5),
+ P(3, 3.5),
+ P(4, 4.5),
+ P(5, 5.5),
+ P(6, 6.5),
+ P(7, 7.5),
+ P(8, 8.5),
+ };
+ M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 8);
+ I i = m.erase(next(m.cbegin(), 3));
+ assert(m.size() == 7);
+ assert(i == next(m.begin(), 3));
+ assert(m.begin()->first == 1);
+ assert(m.begin()->second == 1.5);
+ assert(next(m.begin())->first == 2);
+ assert(next(m.begin())->second == 2.5);
+ assert(next(m.begin(), 2)->first == 3);
+ assert(next(m.begin(), 2)->second == 3.5);
+ assert(next(m.begin(), 3)->first == 5);
+ assert(next(m.begin(), 3)->second == 5.5);
+ assert(next(m.begin(), 4)->first == 6);
+ assert(next(m.begin(), 4)->second == 6.5);
+ assert(next(m.begin(), 5)->first == 7);
+ assert(next(m.begin(), 5)->second == 7.5);
+ assert(next(m.begin(), 6)->first == 8);
+ assert(next(m.begin(), 6)->second == 8.5);
+
+ i = m.erase(next(m.cbegin(), 0));
+ assert(m.size() == 6);
+ assert(i == m.begin());
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == 2.5);
+ assert(next(m.begin())->first == 3);
+ assert(next(m.begin())->second == 3.5);
+ assert(next(m.begin(), 2)->first == 5);
+ assert(next(m.begin(), 2)->second == 5.5);
+ assert(next(m.begin(), 3)->first == 6);
+ assert(next(m.begin(), 3)->second == 6.5);
+ assert(next(m.begin(), 4)->first == 7);
+ assert(next(m.begin(), 4)->second == 7.5);
+ assert(next(m.begin(), 5)->first == 8);
+ assert(next(m.begin(), 5)->second == 8.5);
+
+ i = m.erase(next(m.cbegin(), 5));
+ assert(m.size() == 5);
+ assert(i == m.end());
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == 2.5);
+ assert(next(m.begin())->first == 3);
+ assert(next(m.begin())->second == 3.5);
+ assert(next(m.begin(), 2)->first == 5);
+ assert(next(m.begin(), 2)->second == 5.5);
+ assert(next(m.begin(), 3)->first == 6);
+ assert(next(m.begin(), 3)->second == 6.5);
+ assert(next(m.begin(), 4)->first == 7);
+ assert(next(m.begin(), 4)->second == 7.5);
+
+ i = m.erase(next(m.cbegin(), 1));
+ assert(m.size() == 4);
+ assert(i == next(m.begin()));
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == 2.5);
+ assert(next(m.begin())->first == 5);
+ assert(next(m.begin())->second == 5.5);
+ assert(next(m.begin(), 2)->first == 6);
+ assert(next(m.begin(), 2)->second == 6.5);
+ assert(next(m.begin(), 3)->first == 7);
+ assert(next(m.begin(), 3)->second == 7.5);
+
+ i = m.erase(next(m.cbegin(), 2));
+ assert(m.size() == 3);
+ assert(i == next(m.begin(), 2));
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == 2.5);
+ assert(next(m.begin())->first == 5);
+ assert(next(m.begin())->second == 5.5);
+ assert(next(m.begin(), 2)->first == 7);
+ assert(next(m.begin(), 2)->second == 7.5);
+
+ i = m.erase(next(m.cbegin(), 2));
+ assert(m.size() == 2);
+ assert(i == next(m.begin(), 2));
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == 2.5);
+ assert(next(m.begin())->first == 5);
+ assert(next(m.begin())->second == 5.5);
+
+ i = m.erase(next(m.cbegin(), 0));
+ assert(m.size() == 1);
+ assert(i == next(m.begin(), 0));
+ assert(m.begin()->first == 5);
+ assert(m.begin()->second == 5.5);
+
+ i = m.erase(m.cbegin());
+ assert(m.size() == 0);
+ assert(i == m.begin());
+ assert(i == m.end());
+ }
+#endif
+#if __cplusplus >= 201402L
+ {
+ // This is LWG #2059
+ typedef TemplateConstructor T;
+ typedef std::map<T, int> C;
+ typedef C::iterator I;
+
+ C c;
+ T a{0};
+ I it = c.find(a);
+ if (it != c.end())
+ c.erase(it);
+ }
+#endif
+}
diff --git a/test/std/containers/associative/map/map.modifiers/erase_iter_iter.pass.cpp b/test/std/containers/associative/map/map.modifiers/erase_iter_iter.pass.cpp
new file mode 100644
index 000000000000..1b49956d8a5a
--- /dev/null
+++ b/test/std/containers/associative/map/map.modifiers/erase_iter_iter.pass.cpp
@@ -0,0 +1,157 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// iterator erase(const_iterator first, const_iterator last);
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::map<int, double> M;
+ typedef std::pair<int, double> P;
+ typedef M::iterator I;
+ P ar[] =
+ {
+ P(1, 1.5),
+ P(2, 2.5),
+ P(3, 3.5),
+ P(4, 4.5),
+ P(5, 5.5),
+ P(6, 6.5),
+ P(7, 7.5),
+ P(8, 8.5),
+ };
+ M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 8);
+ I i = m.erase(m.cbegin(), m.cbegin());
+ assert(m.size() == 8);
+ assert(i == m.begin());
+ assert(m.begin()->first == 1);
+ assert(m.begin()->second == 1.5);
+ assert(next(m.begin())->first == 2);
+ assert(next(m.begin())->second == 2.5);
+ assert(next(m.begin(), 2)->first == 3);
+ assert(next(m.begin(), 2)->second == 3.5);
+ assert(next(m.begin(), 3)->first == 4);
+ assert(next(m.begin(), 3)->second == 4.5);
+ assert(next(m.begin(), 4)->first == 5);
+ assert(next(m.begin(), 4)->second == 5.5);
+ assert(next(m.begin(), 5)->first == 6);
+ assert(next(m.begin(), 5)->second == 6.5);
+ assert(next(m.begin(), 6)->first == 7);
+ assert(next(m.begin(), 6)->second == 7.5);
+ assert(next(m.begin(), 7)->first == 8);
+ assert(next(m.begin(), 7)->second == 8.5);
+
+ i = m.erase(m.cbegin(), next(m.cbegin(), 2));
+ assert(m.size() == 6);
+ assert(i == m.begin());
+ assert(next(m.begin(), 0)->first == 3);
+ assert(next(m.begin(), 0)->second == 3.5);
+ assert(next(m.begin(), 1)->first == 4);
+ assert(next(m.begin(), 1)->second == 4.5);
+ assert(next(m.begin(), 2)->first == 5);
+ assert(next(m.begin(), 2)->second == 5.5);
+ assert(next(m.begin(), 3)->first == 6);
+ assert(next(m.begin(), 3)->second == 6.5);
+ assert(next(m.begin(), 4)->first == 7);
+ assert(next(m.begin(), 4)->second == 7.5);
+ assert(next(m.begin(), 5)->first == 8);
+ assert(next(m.begin(), 5)->second == 8.5);
+
+ i = m.erase(next(m.cbegin(), 2), next(m.cbegin(), 6));
+ assert(m.size() == 2);
+ assert(i == next(m.begin(), 2));
+ assert(next(m.begin(), 0)->first == 3);
+ assert(next(m.begin(), 0)->second == 3.5);
+ assert(next(m.begin(), 1)->first == 4);
+ assert(next(m.begin(), 1)->second == 4.5);
+
+ i = m.erase(m.cbegin(), m.cend());
+ assert(m.size() == 0);
+ assert(i == m.begin());
+ assert(i == m.end());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+ typedef std::pair<int, double> P;
+ typedef M::iterator I;
+ P ar[] =
+ {
+ P(1, 1.5),
+ P(2, 2.5),
+ P(3, 3.5),
+ P(4, 4.5),
+ P(5, 5.5),
+ P(6, 6.5),
+ P(7, 7.5),
+ P(8, 8.5),
+ };
+ M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 8);
+ I i = m.erase(m.cbegin(), m.cbegin());
+ assert(m.size() == 8);
+ assert(i == m.begin());
+ assert(m.begin()->first == 1);
+ assert(m.begin()->second == 1.5);
+ assert(next(m.begin())->first == 2);
+ assert(next(m.begin())->second == 2.5);
+ assert(next(m.begin(), 2)->first == 3);
+ assert(next(m.begin(), 2)->second == 3.5);
+ assert(next(m.begin(), 3)->first == 4);
+ assert(next(m.begin(), 3)->second == 4.5);
+ assert(next(m.begin(), 4)->first == 5);
+ assert(next(m.begin(), 4)->second == 5.5);
+ assert(next(m.begin(), 5)->first == 6);
+ assert(next(m.begin(), 5)->second == 6.5);
+ assert(next(m.begin(), 6)->first == 7);
+ assert(next(m.begin(), 6)->second == 7.5);
+ assert(next(m.begin(), 7)->first == 8);
+ assert(next(m.begin(), 7)->second == 8.5);
+
+ i = m.erase(m.cbegin(), next(m.cbegin(), 2));
+ assert(m.size() == 6);
+ assert(i == m.begin());
+ assert(next(m.begin(), 0)->first == 3);
+ assert(next(m.begin(), 0)->second == 3.5);
+ assert(next(m.begin(), 1)->first == 4);
+ assert(next(m.begin(), 1)->second == 4.5);
+ assert(next(m.begin(), 2)->first == 5);
+ assert(next(m.begin(), 2)->second == 5.5);
+ assert(next(m.begin(), 3)->first == 6);
+ assert(next(m.begin(), 3)->second == 6.5);
+ assert(next(m.begin(), 4)->first == 7);
+ assert(next(m.begin(), 4)->second == 7.5);
+ assert(next(m.begin(), 5)->first == 8);
+ assert(next(m.begin(), 5)->second == 8.5);
+
+ i = m.erase(next(m.cbegin(), 2), next(m.cbegin(), 6));
+ assert(m.size() == 2);
+ assert(i == next(m.begin(), 2));
+ assert(next(m.begin(), 0)->first == 3);
+ assert(next(m.begin(), 0)->second == 3.5);
+ assert(next(m.begin(), 1)->first == 4);
+ assert(next(m.begin(), 1)->second == 4.5);
+
+ i = m.erase(m.cbegin(), m.cend());
+ assert(m.size() == 0);
+ assert(i == m.begin());
+ assert(i == m.end());
+ }
+#endif
+}
diff --git a/test/std/containers/associative/map/map.modifiers/erase_key.pass.cpp b/test/std/containers/associative/map/map.modifiers/erase_key.pass.cpp
new file mode 100644
index 000000000000..e41f5129140e
--- /dev/null
+++ b/test/std/containers/associative/map/map.modifiers/erase_key.pass.cpp
@@ -0,0 +1,275 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// size_type erase(const key_type& k);
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::map<int, double> M;
+ typedef std::pair<int, double> P;
+ typedef M::size_type R;
+ P ar[] =
+ {
+ P(1, 1.5),
+ P(2, 2.5),
+ P(3, 3.5),
+ P(4, 4.5),
+ P(5, 5.5),
+ P(6, 6.5),
+ P(7, 7.5),
+ P(8, 8.5),
+ };
+ M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 8);
+ R s = m.erase(9);
+ assert(s == 0);
+ assert(m.size() == 8);
+ assert(m.begin()->first == 1);
+ assert(m.begin()->second == 1.5);
+ assert(next(m.begin())->first == 2);
+ assert(next(m.begin())->second == 2.5);
+ assert(next(m.begin(), 2)->first == 3);
+ assert(next(m.begin(), 2)->second == 3.5);
+ assert(next(m.begin(), 3)->first == 4);
+ assert(next(m.begin(), 3)->second == 4.5);
+ assert(next(m.begin(), 4)->first == 5);
+ assert(next(m.begin(), 4)->second == 5.5);
+ assert(next(m.begin(), 5)->first == 6);
+ assert(next(m.begin(), 5)->second == 6.5);
+ assert(next(m.begin(), 6)->first == 7);
+ assert(next(m.begin(), 6)->second == 7.5);
+ assert(next(m.begin(), 7)->first == 8);
+ assert(next(m.begin(), 7)->second == 8.5);
+
+ s = m.erase(4);
+ assert(m.size() == 7);
+ assert(s == 1);
+ assert(m.begin()->first == 1);
+ assert(m.begin()->second == 1.5);
+ assert(next(m.begin())->first == 2);
+ assert(next(m.begin())->second == 2.5);
+ assert(next(m.begin(), 2)->first == 3);
+ assert(next(m.begin(), 2)->second == 3.5);
+ assert(next(m.begin(), 3)->first == 5);
+ assert(next(m.begin(), 3)->second == 5.5);
+ assert(next(m.begin(), 4)->first == 6);
+ assert(next(m.begin(), 4)->second == 6.5);
+ assert(next(m.begin(), 5)->first == 7);
+ assert(next(m.begin(), 5)->second == 7.5);
+ assert(next(m.begin(), 6)->first == 8);
+ assert(next(m.begin(), 6)->second == 8.5);
+
+ s = m.erase(1);
+ assert(m.size() == 6);
+ assert(s == 1);
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == 2.5);
+ assert(next(m.begin())->first == 3);
+ assert(next(m.begin())->second == 3.5);
+ assert(next(m.begin(), 2)->first == 5);
+ assert(next(m.begin(), 2)->second == 5.5);
+ assert(next(m.begin(), 3)->first == 6);
+ assert(next(m.begin(), 3)->second == 6.5);
+ assert(next(m.begin(), 4)->first == 7);
+ assert(next(m.begin(), 4)->second == 7.5);
+ assert(next(m.begin(), 5)->first == 8);
+ assert(next(m.begin(), 5)->second == 8.5);
+
+ s = m.erase(8);
+ assert(m.size() == 5);
+ assert(s == 1);
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == 2.5);
+ assert(next(m.begin())->first == 3);
+ assert(next(m.begin())->second == 3.5);
+ assert(next(m.begin(), 2)->first == 5);
+ assert(next(m.begin(), 2)->second == 5.5);
+ assert(next(m.begin(), 3)->first == 6);
+ assert(next(m.begin(), 3)->second == 6.5);
+ assert(next(m.begin(), 4)->first == 7);
+ assert(next(m.begin(), 4)->second == 7.5);
+
+ s = m.erase(3);
+ assert(m.size() == 4);
+ assert(s == 1);
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == 2.5);
+ assert(next(m.begin())->first == 5);
+ assert(next(m.begin())->second == 5.5);
+ assert(next(m.begin(), 2)->first == 6);
+ assert(next(m.begin(), 2)->second == 6.5);
+ assert(next(m.begin(), 3)->first == 7);
+ assert(next(m.begin(), 3)->second == 7.5);
+
+ s = m.erase(6);
+ assert(m.size() == 3);
+ assert(s == 1);
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == 2.5);
+ assert(next(m.begin())->first == 5);
+ assert(next(m.begin())->second == 5.5);
+ assert(next(m.begin(), 2)->first == 7);
+ assert(next(m.begin(), 2)->second == 7.5);
+
+ s = m.erase(7);
+ assert(m.size() == 2);
+ assert(s == 1);
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == 2.5);
+ assert(next(m.begin())->first == 5);
+ assert(next(m.begin())->second == 5.5);
+
+ s = m.erase(2);
+ assert(m.size() == 1);
+ assert(s == 1);
+ assert(m.begin()->first == 5);
+ assert(m.begin()->second == 5.5);
+
+ s = m.erase(5);
+ assert(m.size() == 0);
+ assert(s == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+ typedef std::pair<int, double> P;
+ typedef M::size_type R;
+ P ar[] =
+ {
+ P(1, 1.5),
+ P(2, 2.5),
+ P(3, 3.5),
+ P(4, 4.5),
+ P(5, 5.5),
+ P(6, 6.5),
+ P(7, 7.5),
+ P(8, 8.5),
+ };
+ M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 8);
+ R s = m.erase(9);
+ assert(s == 0);
+ assert(m.size() == 8);
+ assert(m.begin()->first == 1);
+ assert(m.begin()->second == 1.5);
+ assert(next(m.begin())->first == 2);
+ assert(next(m.begin())->second == 2.5);
+ assert(next(m.begin(), 2)->first == 3);
+ assert(next(m.begin(), 2)->second == 3.5);
+ assert(next(m.begin(), 3)->first == 4);
+ assert(next(m.begin(), 3)->second == 4.5);
+ assert(next(m.begin(), 4)->first == 5);
+ assert(next(m.begin(), 4)->second == 5.5);
+ assert(next(m.begin(), 5)->first == 6);
+ assert(next(m.begin(), 5)->second == 6.5);
+ assert(next(m.begin(), 6)->first == 7);
+ assert(next(m.begin(), 6)->second == 7.5);
+ assert(next(m.begin(), 7)->first == 8);
+ assert(next(m.begin(), 7)->second == 8.5);
+
+ s = m.erase(4);
+ assert(m.size() == 7);
+ assert(s == 1);
+ assert(m.begin()->first == 1);
+ assert(m.begin()->second == 1.5);
+ assert(next(m.begin())->first == 2);
+ assert(next(m.begin())->second == 2.5);
+ assert(next(m.begin(), 2)->first == 3);
+ assert(next(m.begin(), 2)->second == 3.5);
+ assert(next(m.begin(), 3)->first == 5);
+ assert(next(m.begin(), 3)->second == 5.5);
+ assert(next(m.begin(), 4)->first == 6);
+ assert(next(m.begin(), 4)->second == 6.5);
+ assert(next(m.begin(), 5)->first == 7);
+ assert(next(m.begin(), 5)->second == 7.5);
+ assert(next(m.begin(), 6)->first == 8);
+ assert(next(m.begin(), 6)->second == 8.5);
+
+ s = m.erase(1);
+ assert(m.size() == 6);
+ assert(s == 1);
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == 2.5);
+ assert(next(m.begin())->first == 3);
+ assert(next(m.begin())->second == 3.5);
+ assert(next(m.begin(), 2)->first == 5);
+ assert(next(m.begin(), 2)->second == 5.5);
+ assert(next(m.begin(), 3)->first == 6);
+ assert(next(m.begin(), 3)->second == 6.5);
+ assert(next(m.begin(), 4)->first == 7);
+ assert(next(m.begin(), 4)->second == 7.5);
+ assert(next(m.begin(), 5)->first == 8);
+ assert(next(m.begin(), 5)->second == 8.5);
+
+ s = m.erase(8);
+ assert(m.size() == 5);
+ assert(s == 1);
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == 2.5);
+ assert(next(m.begin())->first == 3);
+ assert(next(m.begin())->second == 3.5);
+ assert(next(m.begin(), 2)->first == 5);
+ assert(next(m.begin(), 2)->second == 5.5);
+ assert(next(m.begin(), 3)->first == 6);
+ assert(next(m.begin(), 3)->second == 6.5);
+ assert(next(m.begin(), 4)->first == 7);
+ assert(next(m.begin(), 4)->second == 7.5);
+
+ s = m.erase(3);
+ assert(m.size() == 4);
+ assert(s == 1);
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == 2.5);
+ assert(next(m.begin())->first == 5);
+ assert(next(m.begin())->second == 5.5);
+ assert(next(m.begin(), 2)->first == 6);
+ assert(next(m.begin(), 2)->second == 6.5);
+ assert(next(m.begin(), 3)->first == 7);
+ assert(next(m.begin(), 3)->second == 7.5);
+
+ s = m.erase(6);
+ assert(m.size() == 3);
+ assert(s == 1);
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == 2.5);
+ assert(next(m.begin())->first == 5);
+ assert(next(m.begin())->second == 5.5);
+ assert(next(m.begin(), 2)->first == 7);
+ assert(next(m.begin(), 2)->second == 7.5);
+
+ s = m.erase(7);
+ assert(m.size() == 2);
+ assert(s == 1);
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == 2.5);
+ assert(next(m.begin())->first == 5);
+ assert(next(m.begin())->second == 5.5);
+
+ s = m.erase(2);
+ assert(m.size() == 1);
+ assert(s == 1);
+ assert(m.begin()->first == 5);
+ assert(m.begin()->second == 5.5);
+
+ s = m.erase(5);
+ assert(m.size() == 0);
+ assert(s == 1);
+ }
+#endif
+}
diff --git a/test/std/containers/associative/map/map.modifiers/insert_cv.pass.cpp b/test/std/containers/associative/map/map.modifiers/insert_cv.pass.cpp
new file mode 100644
index 000000000000..3d28242fd322
--- /dev/null
+++ b/test/std/containers/associative/map/map.modifiers/insert_cv.pass.cpp
@@ -0,0 +1,89 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// pair<iterator, bool> insert(const value_type& v);
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::map<int, double> M;
+ typedef std::pair<M::iterator, bool> R;
+ M m;
+ R r = m.insert(M::value_type(2, 2.5));
+ assert(r.second);
+ assert(r.first == m.begin());
+ assert(m.size() == 1);
+ assert(r.first->first == 2);
+ assert(r.first->second == 2.5);
+
+ r = m.insert(M::value_type(1, 1.5));
+ assert(r.second);
+ assert(r.first == m.begin());
+ assert(m.size() == 2);
+ assert(r.first->first == 1);
+ assert(r.first->second == 1.5);
+
+ r = m.insert(M::value_type(3, 3.5));
+ assert(r.second);
+ assert(r.first == prev(m.end()));
+ assert(m.size() == 3);
+ assert(r.first->first == 3);
+ assert(r.first->second == 3.5);
+
+ r = m.insert(M::value_type(3, 3.5));
+ assert(!r.second);
+ assert(r.first == prev(m.end()));
+ assert(m.size() == 3);
+ assert(r.first->first == 3);
+ assert(r.first->second == 3.5);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+ typedef std::pair<M::iterator, bool> R;
+ M m;
+ R r = m.insert(M::value_type(2, 2.5));
+ assert(r.second);
+ assert(r.first == m.begin());
+ assert(m.size() == 1);
+ assert(r.first->first == 2);
+ assert(r.first->second == 2.5);
+
+ r = m.insert(M::value_type(1, 1.5));
+ assert(r.second);
+ assert(r.first == m.begin());
+ assert(m.size() == 2);
+ assert(r.first->first == 1);
+ assert(r.first->second == 1.5);
+
+ r = m.insert(M::value_type(3, 3.5));
+ assert(r.second);
+ assert(r.first == prev(m.end()));
+ assert(m.size() == 3);
+ assert(r.first->first == 3);
+ assert(r.first->second == 3.5);
+
+ r = m.insert(M::value_type(3, 3.5));
+ assert(!r.second);
+ assert(r.first == prev(m.end()));
+ assert(m.size() == 3);
+ assert(r.first->first == 3);
+ assert(r.first->second == 3.5);
+ }
+#endif
+}
diff --git a/test/std/containers/associative/map/map.modifiers/insert_initializer_list.pass.cpp b/test/std/containers/associative/map/map.modifiers/insert_initializer_list.pass.cpp
new file mode 100644
index 000000000000..ab325ed45bfc
--- /dev/null
+++ b/test/std/containers/associative/map/map.modifiers/insert_initializer_list.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// void insert(initializer_list<value_type> il);
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::pair<const int, double> V;
+ std::map<int, double> m =
+ {
+ {1, 1},
+ {1, 1.5},
+ {1, 2},
+ {3, 1},
+ {3, 1.5},
+ {3, 2}
+ };
+ m.insert({
+ {2, 1},
+ {2, 1.5},
+ {2, 2},
+ });
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(2, 1));
+ assert(*next(m.begin(), 2) == V(3, 1));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<const int, double> V;
+ std::map<int, double, std::less<int>, min_allocator<V>> m =
+ {
+ {1, 1},
+ {1, 1.5},
+ {1, 2},
+ {3, 1},
+ {3, 1.5},
+ {3, 2}
+ };
+ m.insert({
+ {2, 1},
+ {2, 1.5},
+ {2, 2},
+ });
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(2, 1));
+ assert(*next(m.begin(), 2) == V(3, 1));
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/containers/associative/map/map.modifiers/insert_iter_cv.pass.cpp b/test/std/containers/associative/map/map.modifiers/insert_iter_cv.pass.cpp
new file mode 100644
index 000000000000..278db4631a8c
--- /dev/null
+++ b/test/std/containers/associative/map/map.modifiers/insert_iter_cv.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// iterator insert(const_iterator position, const value_type& v);
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::map<int, double> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.insert(m.end(), M::value_type(2, 2.5));
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(r->first == 2);
+ assert(r->second == 2.5);
+
+ r = m.insert(m.end(), M::value_type(1, 1.5));
+ assert(r == m.begin());
+ assert(m.size() == 2);
+ assert(r->first == 1);
+ assert(r->second == 1.5);
+
+ r = m.insert(m.end(), M::value_type(3, 3.5));
+ assert(r == prev(m.end()));
+ assert(m.size() == 3);
+ assert(r->first == 3);
+ assert(r->second == 3.5);
+
+ r = m.insert(m.end(), M::value_type(3, 3.5));
+ assert(r == prev(m.end()));
+ assert(m.size() == 3);
+ assert(r->first == 3);
+ assert(r->second == 3.5);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.insert(m.end(), M::value_type(2, 2.5));
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(r->first == 2);
+ assert(r->second == 2.5);
+
+ r = m.insert(m.end(), M::value_type(1, 1.5));
+ assert(r == m.begin());
+ assert(m.size() == 2);
+ assert(r->first == 1);
+ assert(r->second == 1.5);
+
+ r = m.insert(m.end(), M::value_type(3, 3.5));
+ assert(r == prev(m.end()));
+ assert(m.size() == 3);
+ assert(r->first == 3);
+ assert(r->second == 3.5);
+
+ r = m.insert(m.end(), M::value_type(3, 3.5));
+ assert(r == prev(m.end()));
+ assert(m.size() == 3);
+ assert(r->first == 3);
+ assert(r->second == 3.5);
+ }
+#endif
+}
diff --git a/test/std/containers/associative/map/map.modifiers/insert_iter_iter.pass.cpp b/test/std/containers/associative/map/map.modifiers/insert_iter_iter.pass.cpp
new file mode 100644
index 000000000000..964738b4a68a
--- /dev/null
+++ b/test/std/containers/associative/map/map.modifiers/insert_iter_iter.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// template <class InputIterator>
+// void insert(InputIterator first, InputIterator last);
+
+#include <map>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::map<int, double> M;
+ typedef std::pair<int, double> P;
+ P ar[] =
+ {
+ P(1, 1),
+ P(1, 1.5),
+ P(1, 2),
+ P(2, 1),
+ P(2, 1.5),
+ P(2, 2),
+ P(3, 1),
+ P(3, 1.5),
+ P(3, 2),
+ };
+ M m;
+ m.insert(input_iterator<P*>(ar), input_iterator<P*>(ar + sizeof(ar)/sizeof(ar[0])));
+ assert(m.size() == 3);
+ assert(m.begin()->first == 1);
+ assert(m.begin()->second == 1);
+ assert(next(m.begin())->first == 2);
+ assert(next(m.begin())->second == 1);
+ assert(next(m.begin(), 2)->first == 3);
+ assert(next(m.begin(), 2)->second == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+ typedef std::pair<int, double> P;
+ P ar[] =
+ {
+ P(1, 1),
+ P(1, 1.5),
+ P(1, 2),
+ P(2, 1),
+ P(2, 1.5),
+ P(2, 2),
+ P(3, 1),
+ P(3, 1.5),
+ P(3, 2),
+ };
+ M m;
+ m.insert(input_iterator<P*>(ar), input_iterator<P*>(ar + sizeof(ar)/sizeof(ar[0])));
+ assert(m.size() == 3);
+ assert(m.begin()->first == 1);
+ assert(m.begin()->second == 1);
+ assert(next(m.begin())->first == 2);
+ assert(next(m.begin())->second == 1);
+ assert(next(m.begin(), 2)->first == 3);
+ assert(next(m.begin(), 2)->second == 1);
+ }
+#endif
+}
diff --git a/test/std/containers/associative/map/map.modifiers/insert_iter_rv.pass.cpp b/test/std/containers/associative/map/map.modifiers/insert_iter_rv.pass.cpp
new file mode 100644
index 000000000000..42b41fd7b867
--- /dev/null
+++ b/test/std/containers/associative/map/map.modifiers/insert_iter_rv.pass.cpp
@@ -0,0 +1,87 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// template <class P>
+// iterator insert(const_iterator position, P&& p);
+
+#include <map>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::map<int, MoveOnly> M;
+ typedef std::pair<int, MoveOnly> P;
+ typedef M::iterator R;
+ M m;
+ R r = m.insert(m.end(), P(2, 2));
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(r->first == 2);
+ assert(r->second == 2);
+
+ r = m.insert(m.end(), P(1, 1));
+ assert(r == m.begin());
+ assert(m.size() == 2);
+ assert(r->first == 1);
+ assert(r->second == 1);
+
+ r = m.insert(m.end(), P(3, 3));
+ assert(r == prev(m.end()));
+ assert(m.size() == 3);
+ assert(r->first == 3);
+ assert(r->second == 3);
+
+ r = m.insert(m.end(), P(3, 3));
+ assert(r == prev(m.end()));
+ assert(m.size() == 3);
+ assert(r->first == 3);
+ assert(r->second == 3);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::map<int, MoveOnly, std::less<int>, min_allocator<std::pair<const int, MoveOnly>>> M;
+ typedef std::pair<int, MoveOnly> P;
+ typedef M::iterator R;
+ M m;
+ R r = m.insert(m.end(), P(2, 2));
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(r->first == 2);
+ assert(r->second == 2);
+
+ r = m.insert(m.end(), P(1, 1));
+ assert(r == m.begin());
+ assert(m.size() == 2);
+ assert(r->first == 1);
+ assert(r->second == 1);
+
+ r = m.insert(m.end(), P(3, 3));
+ assert(r == prev(m.end()));
+ assert(m.size() == 3);
+ assert(r->first == 3);
+ assert(r->second == 3);
+
+ r = m.insert(m.end(), P(3, 3));
+ assert(r == prev(m.end()));
+ assert(m.size() == 3);
+ assert(r->first == 3);
+ assert(r->second == 3);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/associative/map/map.modifiers/insert_or_assign.pass.cpp b/test/std/containers/associative/map/map.modifiers/insert_or_assign.pass.cpp
new file mode 100644
index 000000000000..484ed06247d1
--- /dev/null
+++ b/test/std/containers/associative/map/map.modifiers/insert_or_assign.pass.cpp
@@ -0,0 +1,192 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: c++03, c++11, c++14
+
+// <map>
+
+// class map
+
+// template <class M>
+// pair<iterator, bool> insert_or_assign(const key_type& k, M&& obj); // C++17
+// template <class M>
+// pair<iterator, bool> insert_or_assign(key_type&& k, M&& obj); // C++17
+// template <class M>
+// iterator insert_or_assign(const_iterator hint, const key_type& k, M&& obj); // C++17
+// template <class M>
+// iterator insert_or_assign(const_iterator hint, key_type&& k, M&& obj); // C++17
+
+#include <__config>
+#include <map>
+#include <cassert>
+#include <tuple>
+
+#include <iostream>
+
+class Moveable
+{
+ Moveable(const Moveable&);
+ Moveable& operator=(const Moveable&);
+
+ int int_;
+ double double_;
+public:
+ Moveable() : int_(0), double_(0) {}
+ Moveable(int i, double d) : int_(i), double_(d) {}
+ Moveable(Moveable&& x)
+ : int_(x.int_), double_(x.double_)
+ {x.int_ = -1; x.double_ = -1;}
+ Moveable& operator=(Moveable&& x)
+ {int_ = x.int_; x.int_ = -1;
+ double_ = x.double_; x.double_ = -1;
+ return *this;
+ }
+
+ bool operator==(const Moveable& x) const
+ {return int_ == x.int_ && double_ == x.double_;}
+ bool operator<(const Moveable& x) const
+ {return int_ < x.int_ || (int_ == x.int_ && double_ < x.double_);}
+
+ int get() const {return int_;}
+ bool moved() const {return int_ == -1;}
+};
+
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+
+ { // pair<iterator, bool> insert_or_assign(const key_type& k, M&& obj);
+ typedef std::map<int, Moveable> M;
+ typedef std::pair<M::iterator, bool> R;
+ M m;
+ R r;
+ for ( int i = 0; i < 20; i += 2 )
+ m.emplace ( i, Moveable(i, (double) i));
+ assert(m.size() == 10);
+
+ for (int i=0; i < 20; i += 2)
+ {
+ Moveable mv(i+1, i+1);
+ r = m.insert_or_assign(i, std::move(mv));
+ assert(m.size() == 10);
+ assert(!r.second); // was not inserted
+ assert(mv.moved()); // was moved from
+ assert(r.first->first == i); // key
+ assert(r.first->second.get() == i+1); // value
+ }
+
+ Moveable mv1(5, 5.0);
+ r = m.insert_or_assign(-1, std::move(mv1));
+ assert(m.size() == 11);
+ assert(r.second); // was inserted
+ assert(mv1.moved()); // was moved from
+ assert(r.first->first == -1); // key
+ assert(r.first->second.get() == 5); // value
+
+ Moveable mv2(9, 9.0);
+ r = m.insert_or_assign(3, std::move(mv2));
+ assert(m.size() == 12);
+ assert(r.second); // was inserted
+ assert(mv2.moved()); // was moved from
+ assert(r.first->first == 3); // key
+ assert(r.first->second.get() == 9); // value
+
+ Moveable mv3(-1, 5.0);
+ r = m.insert_or_assign(117, std::move(mv3));
+ assert(m.size() == 13);
+ assert(r.second); // was inserted
+ assert(mv3.moved()); // was moved from
+ assert(r.first->first == 117); // key
+ assert(r.first->second.get() == -1); // value
+ }
+ { // pair<iterator, bool> insert_or_assign(key_type&& k, M&& obj);
+ typedef std::map<Moveable, Moveable> M;
+ typedef std::pair<M::iterator, bool> R;
+ M m;
+ R r;
+ for ( int i = 0; i < 20; i += 2 )
+ m.emplace ( Moveable(i, (double) i), Moveable(i+1, (double) i+1));
+ assert(m.size() == 10);
+
+ Moveable mvkey1(2, 2.0);
+ Moveable mv1(4, 4.0);
+ r = m.insert_or_assign(std::move(mvkey1), std::move(mv1));
+ assert(m.size() == 10);
+ assert(!r.second); // was not inserted
+ assert(!mvkey1.moved()); // was not moved from
+ assert(mv1.moved()); // was moved from
+ assert(r.first->first == mvkey1); // key
+ assert(r.first->second.get() == 4); // value
+
+ Moveable mvkey2(3, 3.0);
+ Moveable mv2(5, 5.0);
+ r = m.try_emplace(std::move(mvkey2), std::move(mv2));
+ assert(m.size() == 11);
+ assert(r.second); // was inserted
+ assert(mv2.moved()); // was moved from
+ assert(mvkey2.moved()); // was moved from
+ assert(r.first->first.get() == 3); // key
+ assert(r.first->second.get() == 5); // value
+ }
+ { // iterator insert_or_assign(const_iterator hint, const key_type& k, M&& obj);
+ typedef std::map<int, Moveable> M;
+ M m;
+ M::iterator r;
+ for ( int i = 0; i < 20; i += 2 )
+ m.emplace ( i, Moveable(i, (double) i));
+ assert(m.size() == 10);
+ M::const_iterator it = m.find(2);
+
+ Moveable mv1(3, 3.0);
+ r = m.insert_or_assign(it, 2, std::move(mv1));
+ assert(m.size() == 10);
+ assert(mv1.moved()); // was moved from
+ assert(r->first == 2); // key
+ assert(r->second.get() == 3); // value
+
+ Moveable mv2(5, 5.0);
+ r = m.insert_or_assign(it, 3, std::move(mv2));
+ assert(m.size() == 11);
+ assert(mv2.moved()); // was moved from
+ assert(r->first == 3); // key
+ assert(r->second.get() == 5); // value
+ }
+ { // iterator insert_or_assign(const_iterator hint, key_type&& k, M&& obj);
+ typedef std::map<Moveable, Moveable> M;
+ M m;
+ M::iterator r;
+ for ( int i = 0; i < 20; i += 2 )
+ m.emplace ( Moveable(i, (double) i), Moveable(i+1, (double) i+1));
+ assert(m.size() == 10);
+ M::const_iterator it = std::next(m.cbegin());
+
+ Moveable mvkey1(2, 2.0);
+ Moveable mv1(4, 4.0);
+ r = m.insert_or_assign(it, std::move(mvkey1), std::move(mv1));
+ assert(m.size() == 10);
+ assert(mv1.moved()); // was moved from
+ assert(!mvkey1.moved()); // was not moved from
+ assert(r->first == mvkey1); // key
+ assert(r->second.get() == 4); // value
+
+ Moveable mvkey2(3, 3.0);
+ Moveable mv2(5, 5.0);
+ r = m.insert_or_assign(it, std::move(mvkey2), std::move(mv2));
+ assert(m.size() == 11);
+ assert(mv2.moved()); // was moved from
+ assert(mvkey2.moved()); // was moved from
+ assert(r->first.get() == 3); // key
+ assert(r->second.get() == 5); // value
+ }
+
+#endif // _LIBCPP_HAS_NO_VARIADICS
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+} \ No newline at end of file
diff --git a/test/std/containers/associative/map/map.modifiers/insert_rv.pass.cpp b/test/std/containers/associative/map/map.modifiers/insert_rv.pass.cpp
new file mode 100644
index 000000000000..a9d3277e6d94
--- /dev/null
+++ b/test/std/containers/associative/map/map.modifiers/insert_rv.pass.cpp
@@ -0,0 +1,93 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// template <class P>
+// pair<iterator, bool> insert(P&& p);
+
+#include <map>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::map<int, MoveOnly> M;
+ typedef std::pair<M::iterator, bool> R;
+ M m;
+ R r = m.insert(M::value_type(2, 2));
+ assert(r.second);
+ assert(r.first == m.begin());
+ assert(m.size() == 1);
+ assert(r.first->first == 2);
+ assert(r.first->second == 2);
+
+ r = m.insert(M::value_type(1, 1));
+ assert(r.second);
+ assert(r.first == m.begin());
+ assert(m.size() == 2);
+ assert(r.first->first == 1);
+ assert(r.first->second == 1);
+
+ r = m.insert(M::value_type(3, 3));
+ assert(r.second);
+ assert(r.first == prev(m.end()));
+ assert(m.size() == 3);
+ assert(r.first->first == 3);
+ assert(r.first->second == 3);
+
+ r = m.insert(M::value_type(3, 3));
+ assert(!r.second);
+ assert(r.first == prev(m.end()));
+ assert(m.size() == 3);
+ assert(r.first->first == 3);
+ assert(r.first->second == 3);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::map<int, MoveOnly, std::less<int>, min_allocator<std::pair<const int, MoveOnly>>> M;
+ typedef std::pair<M::iterator, bool> R;
+ M m;
+ R r = m.insert(M::value_type(2, 2));
+ assert(r.second);
+ assert(r.first == m.begin());
+ assert(m.size() == 1);
+ assert(r.first->first == 2);
+ assert(r.first->second == 2);
+
+ r = m.insert(M::value_type(1, 1));
+ assert(r.second);
+ assert(r.first == m.begin());
+ assert(m.size() == 2);
+ assert(r.first->first == 1);
+ assert(r.first->second == 1);
+
+ r = m.insert(M::value_type(3, 3));
+ assert(r.second);
+ assert(r.first == prev(m.end()));
+ assert(m.size() == 3);
+ assert(r.first->first == 3);
+ assert(r.first->second == 3);
+
+ r = m.insert(M::value_type(3, 3));
+ assert(!r.second);
+ assert(r.first == prev(m.end()));
+ assert(m.size() == 3);
+ assert(r.first->first == 3);
+ assert(r.first->second == 3);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/associative/map/map.modifiers/try.emplace.pass.cpp b/test/std/containers/associative/map/map.modifiers/try.emplace.pass.cpp
new file mode 100644
index 000000000000..8e0dd7577bbd
--- /dev/null
+++ b/test/std/containers/associative/map/map.modifiers/try.emplace.pass.cpp
@@ -0,0 +1,189 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: c++03, c++11, c++14
+
+// <map>
+
+// class map
+
+// template <class... Args>
+// pair<iterator, bool> try_emplace(const key_type& k, Args&&... args); // C++17
+// template <class... Args>
+// pair<iterator, bool> try_emplace(key_type&& k, Args&&... args); // C++17
+// template <class... Args>
+// iterator try_emplace(const_iterator hint, const key_type& k, Args&&... args); // C++17
+// template <class... Args>
+// iterator try_emplace(const_iterator hint, key_type&& k, Args&&... args); // C++17
+
+#include <__config>
+#include <map>
+#include <cassert>
+#include <tuple>
+
+class Moveable
+{
+ Moveable(const Moveable&);
+ Moveable& operator=(const Moveable&);
+
+ int int_;
+ double double_;
+public:
+ Moveable() : int_(0), double_(0) {}
+ Moveable(int i, double d) : int_(i), double_(d) {}
+ Moveable(Moveable&& x)
+ : int_(x.int_), double_(x.double_)
+ {x.int_ = -1; x.double_ = -1;}
+ Moveable& operator=(Moveable&& x)
+ {int_ = x.int_; x.int_ = -1;
+ double_ = x.double_; x.double_ = -1;
+ return *this;
+ }
+
+ bool operator==(const Moveable& x) const
+ {return int_ == x.int_ && double_ == x.double_;}
+ bool operator<(const Moveable& x) const
+ {return int_ < x.int_ || (int_ == x.int_ && double_ < x.double_);}
+
+ int get() const {return int_;}
+ bool moved() const {return int_ == -1;}
+};
+
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+
+ { // pair<iterator, bool> try_emplace(const key_type& k, Args&&... args);
+ typedef std::map<int, Moveable> M;
+ typedef std::pair<M::iterator, bool> R;
+ M m;
+ R r;
+ for (int i = 0; i < 20; i += 2)
+ m.emplace (i, Moveable(i, (double) i));
+ assert(m.size() == 10);
+
+ Moveable mv1(3, 3.0);
+ for (int i=0; i < 20; i += 2)
+ {
+ r = m.try_emplace(i, std::move(mv1));
+ assert(m.size() == 10);
+ assert(!r.second); // was not inserted
+ assert(!mv1.moved()); // was not moved from
+ assert(r.first->first == i); // key
+ }
+
+ r = m.try_emplace(-1, std::move(mv1));
+ assert(m.size() == 11);
+ assert(r.second); // was inserted
+ assert(mv1.moved()); // was moved from
+ assert(r.first->first == -1); // key
+ assert(r.first->second.get() == 3); // value
+
+ Moveable mv2(5, 3.0);
+ r = m.try_emplace(5, std::move(mv2));
+ assert(m.size() == 12);
+ assert(r.second); // was inserted
+ assert(mv2.moved()); // was moved from
+ assert(r.first->first == 5); // key
+ assert(r.first->second.get() == 5); // value
+
+ Moveable mv3(-1, 3.0);
+ r = m.try_emplace(117, std::move(mv2));
+ assert(m.size() == 13);
+ assert(r.second); // was inserted
+ assert(mv2.moved()); // was moved from
+ assert(r.first->first == 117); // key
+ assert(r.first->second.get() == -1); // value
+ }
+
+ { // pair<iterator, bool> try_emplace(key_type&& k, Args&&... args);
+ typedef std::map<Moveable, Moveable> M;
+ typedef std::pair<M::iterator, bool> R;
+ M m;
+ R r;
+ for ( int i = 0; i < 20; i += 2 )
+ m.emplace ( Moveable(i, (double) i), Moveable(i+1, (double) i+1));
+ assert(m.size() == 10);
+
+ Moveable mvkey1(2, 2.0);
+ Moveable mv1(4, 4.0);
+ r = m.try_emplace(std::move(mvkey1), std::move(mv1));
+ assert(m.size() == 10);
+ assert(!r.second); // was not inserted
+ assert(!mv1.moved()); // was not moved from
+ assert(!mvkey1.moved()); // was not moved from
+ assert(r.first->first == mvkey1); // key
+
+ Moveable mvkey2(3, 3.0);
+ r = m.try_emplace(std::move(mvkey2), std::move(mv1));
+ assert(m.size() == 11);
+ assert(r.second); // was inserted
+ assert(mv1.moved()); // was moved from
+ assert(mvkey2.moved()); // was moved from
+ assert(r.first->first.get() == 3); // key
+ assert(r.first->second.get() == 4); // value
+ }
+
+ { // iterator try_emplace(const_iterator hint, const key_type& k, Args&&... args);
+ typedef std::map<int, Moveable> M;
+ M m;
+ M::iterator r;
+ for ( int i = 0; i < 20; i += 2 )
+ m.try_emplace ( i, Moveable(i, (double) i));
+ assert(m.size() == 10);
+ M::const_iterator it = m.find(2);
+
+ Moveable mv1(3, 3.0);
+ for (int i=0; i < 20; i += 2)
+ {
+ r = m.try_emplace(it, i, std::move(mv1));
+ assert(m.size() == 10);
+ assert(!mv1.moved()); // was not moved from
+ assert(r->first == i); // key
+ assert(r->second.get() == i); // value
+ }
+
+ r = m.try_emplace(it, 3, std::move(mv1));
+ assert(m.size() == 11);
+ assert(mv1.moved()); // was moved from
+ assert(r->first == 3); // key
+ assert(r->second.get() == 3); // value
+ }
+
+ { // iterator try_emplace(const_iterator hint, key_type&& k, Args&&... args);
+ typedef std::map<Moveable, Moveable> M;
+ M m;
+ M::iterator r;
+ for ( int i = 0; i < 20; i += 2 )
+ m.emplace ( Moveable(i, (double) i), Moveable(i+1, (double) i+1));
+ assert(m.size() == 10);
+ M::const_iterator it = std::next(m.cbegin());
+
+ Moveable mvkey1(2, 2.0);
+ Moveable mv1(4, 4.0);
+ r = m.try_emplace(it, std::move(mvkey1), std::move(mv1));
+ assert(m.size() == 10);
+ assert(!mv1.moved()); // was not moved from
+ assert(!mvkey1.moved()); // was not moved from
+ assert(r->first == mvkey1); // key
+
+ Moveable mvkey2(3, 3.0);
+ r = m.try_emplace(it, std::move(mvkey2), std::move(mv1));
+ assert(m.size() == 11);
+ assert(mv1.moved()); // was moved from
+ assert(mvkey2.moved()); // was moved from
+ assert(r->first.get() == 3); // key
+ assert(r->second.get() == 4); // value
+ }
+
+#endif // _LIBCPP_HAS_NO_VARIADICS
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/associative/map/map.ops/count.pass.cpp b/test/std/containers/associative/map/map.ops/count.pass.cpp
new file mode 100644
index 000000000000..ae87ae8345e9
--- /dev/null
+++ b/test/std/containers/associative/map/map.ops/count.pass.cpp
@@ -0,0 +1,193 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// size_type count(const key_type& k) const;
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "private_constructor.hpp"
+#include "is_transparent.h"
+
+int main()
+{
+ {
+ typedef std::pair<const int, double> V;
+ typedef std::map<int, double> M;
+ {
+ typedef M::size_type R;
+ V ar[] =
+ {
+ V(5, 5),
+ V(6, 6),
+ V(7, 7),
+ V(8, 8),
+ V(9, 9),
+ V(10, 10),
+ V(11, 11),
+ V(12, 12)
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.count(5);
+ assert(r == 1);
+ r = m.count(6);
+ assert(r == 1);
+ r = m.count(7);
+ assert(r == 1);
+ r = m.count(8);
+ assert(r == 1);
+ r = m.count(9);
+ assert(r == 1);
+ r = m.count(10);
+ assert(r == 1);
+ r = m.count(11);
+ assert(r == 1);
+ r = m.count(12);
+ assert(r == 1);
+ r = m.count(4);
+ assert(r == 0);
+ }
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<const int, double> V;
+ typedef std::map<int, double, std::less<int>, min_allocator<V>> M;
+ {
+ typedef M::size_type R;
+ V ar[] =
+ {
+ V(5, 5),
+ V(6, 6),
+ V(7, 7),
+ V(8, 8),
+ V(9, 9),
+ V(10, 10),
+ V(11, 11),
+ V(12, 12)
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.count(5);
+ assert(r == 1);
+ r = m.count(6);
+ assert(r == 1);
+ r = m.count(7);
+ assert(r == 1);
+ r = m.count(8);
+ assert(r == 1);
+ r = m.count(9);
+ assert(r == 1);
+ r = m.count(10);
+ assert(r == 1);
+ r = m.count(11);
+ assert(r == 1);
+ r = m.count(12);
+ assert(r == 1);
+ r = m.count(4);
+ assert(r == 0);
+ }
+ }
+#endif
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::pair<const int, double> V;
+ typedef std::map<int, double, std::less <>> M;
+ typedef M::size_type R;
+
+ V ar[] =
+ {
+ V(5, 5),
+ V(6, 6),
+ V(7, 7),
+ V(8, 8),
+ V(9, 9),
+ V(10, 10),
+ V(11, 11),
+ V(12, 12)
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.count(5);
+ assert(r == 1);
+ r = m.count(6);
+ assert(r == 1);
+ r = m.count(7);
+ assert(r == 1);
+ r = m.count(8);
+ assert(r == 1);
+ r = m.count(9);
+ assert(r == 1);
+ r = m.count(10);
+ assert(r == 1);
+ r = m.count(11);
+ assert(r == 1);
+ r = m.count(12);
+ assert(r == 1);
+ r = m.count(4);
+ assert(r == 0);
+
+ r = m.count(C2Int(5));
+ assert(r == 1);
+ r = m.count(C2Int(6));
+ assert(r == 1);
+ r = m.count(C2Int(7));
+ assert(r == 1);
+ r = m.count(C2Int(8));
+ assert(r == 1);
+ r = m.count(C2Int(9));
+ assert(r == 1);
+ r = m.count(C2Int(10));
+ assert(r == 1);
+ r = m.count(C2Int(11));
+ assert(r == 1);
+ r = m.count(C2Int(12));
+ assert(r == 1);
+ r = m.count(C2Int(4));
+ assert(r == 0);
+ }
+
+ {
+ typedef PrivateConstructor PC;
+ typedef std::map<PC, double, std::less<>> M;
+ typedef M::size_type R;
+
+ M m;
+ m [ PC::make(5) ] = 5;
+ m [ PC::make(6) ] = 6;
+ m [ PC::make(7) ] = 7;
+ m [ PC::make(8) ] = 8;
+ m [ PC::make(9) ] = 9;
+ m [ PC::make(10) ] = 10;
+ m [ PC::make(11) ] = 11;
+ m [ PC::make(12) ] = 12;
+
+ R r = m.count(5);
+ assert(r == 1);
+ r = m.count(6);
+ assert(r == 1);
+ r = m.count(7);
+ assert(r == 1);
+ r = m.count(8);
+ assert(r == 1);
+ r = m.count(9);
+ assert(r == 1);
+ r = m.count(10);
+ assert(r == 1);
+ r = m.count(11);
+ assert(r == 1);
+ r = m.count(12);
+ assert(r == 1);
+ r = m.count(4);
+ assert(r == 0);
+ }
+#endif
+}
diff --git a/test/std/containers/associative/map/map.ops/count0.pass.cpp b/test/std/containers/associative/map/map.ops/count0.pass.cpp
new file mode 100644
index 000000000000..ce549366e7ab
--- /dev/null
+++ b/test/std/containers/associative/map/map.ops/count0.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// XFAIL: c++03, c++11
+
+// <map>
+
+// class map
+
+// iterator find(const key_type& k);
+// const_iterator find(const key_type& k) const;
+//
+// The member function templates find, count, lower_bound, upper_bound, and
+// equal_range shall not participate in overload resolution unless the
+// qualified-id Compare::is_transparent is valid and denotes a type
+
+
+#include <map>
+#include <cassert>
+
+#include "is_transparent.h"
+
+int main()
+{
+ typedef std::map<int, double, transparent_less> M;
+
+ M().count(C2Int{5});
+}
diff --git a/test/std/containers/associative/map/map.ops/count1.fail.cpp b/test/std/containers/associative/map/map.ops/count1.fail.cpp
new file mode 100644
index 000000000000..9c15059d490e
--- /dev/null
+++ b/test/std/containers/associative/map/map.ops/count1.fail.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// iterator find(const key_type& k);
+// const_iterator find(const key_type& k) const;
+//
+// The member function templates find, count, lower_bound, upper_bound, and
+// equal_range shall not participate in overload resolution unless the
+// qualified-id Compare::is_transparent is valid and denotes a type
+
+
+#include <map>
+#include <cassert>
+
+#include "is_transparent.h"
+
+#if _LIBCPP_STD_VER <= 11
+#error "This test requires is C++14 (or later)"
+#else
+
+int main()
+{
+ {
+ typedef std::map<int, double, transparent_less_no_type> M;
+
+ M().count(C2Int{5});
+ }
+}
+#endif \ No newline at end of file
diff --git a/test/std/containers/associative/map/map.ops/count2.fail.cpp b/test/std/containers/associative/map/map.ops/count2.fail.cpp
new file mode 100644
index 000000000000..7aa1553ef47a
--- /dev/null
+++ b/test/std/containers/associative/map/map.ops/count2.fail.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// iterator find(const key_type& k);
+// const_iterator find(const key_type& k) const;
+//
+// The member function templates find, count, lower_bound, upper_bound, and
+// equal_range shall not participate in overload resolution unless the
+// qualified-id Compare::is_transparent is valid and denotes a type
+
+
+#include <map>
+#include <cassert>
+
+#include "is_transparent.h"
+
+#if _LIBCPP_STD_VER <= 11
+#error "This test requires is C++14 (or later)"
+#else
+
+int main()
+{
+ {
+ typedef std::map<int, double, transparent_less_private> M;
+
+ M().count(C2Int{5});
+ }
+}
+#endif \ No newline at end of file
diff --git a/test/std/containers/associative/map/map.ops/count3.fail.cpp b/test/std/containers/associative/map/map.ops/count3.fail.cpp
new file mode 100644
index 000000000000..7e7bb8f6d370
--- /dev/null
+++ b/test/std/containers/associative/map/map.ops/count3.fail.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// iterator find(const key_type& k);
+// const_iterator find(const key_type& k) const;
+//
+// The member function templates find, count, lower_bound, upper_bound, and
+// equal_range shall not participate in overload resolution unless the
+// qualified-id Compare::is_transparent is valid and denotes a type
+
+
+#include <map>
+#include <cassert>
+
+#include "is_transparent.h"
+
+#if _LIBCPP_STD_VER <= 11
+#error "This test requires is C++14 (or later)"
+#else
+
+int main()
+{
+ {
+ typedef std::map<int, double, transparent_less_not_a_type> M;
+
+ M().count(C2Int{5});
+ }
+}
+#endif \ No newline at end of file
diff --git a/test/std/containers/associative/map/map.ops/equal_range.pass.cpp b/test/std/containers/associative/map/map.ops/equal_range.pass.cpp
new file mode 100644
index 000000000000..a71149a47212
--- /dev/null
+++ b/test/std/containers/associative/map/map.ops/equal_range.pass.cpp
@@ -0,0 +1,490 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// pair<iterator,iterator> equal_range(const key_type& k);
+// pair<const_iterator,const_iterator> equal_range(const key_type& k) const;
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "private_constructor.hpp"
+#include "is_transparent.h"
+
+int main()
+{
+ {
+ typedef std::pair<const int, double> V;
+ typedef std::map<int, double> M;
+ {
+ typedef std::pair<M::iterator, M::iterator> R;
+ V ar[] =
+ {
+ V(5, 5),
+ V(7, 6),
+ V(9, 7),
+ V(11, 8),
+ V(13, 9),
+ V(15, 10),
+ V(17, 11),
+ V(19, 12)
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.equal_range(5);
+ assert(r.first == next(m.begin(), 0));
+ assert(r.second == next(m.begin(), 1));
+ r = m.equal_range(7);
+ assert(r.first == next(m.begin(), 1));
+ assert(r.second == next(m.begin(), 2));
+ r = m.equal_range(9);
+ assert(r.first == next(m.begin(), 2));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(11);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 4));
+ r = m.equal_range(13);
+ assert(r.first == next(m.begin(), 4));
+ assert(r.second == next(m.begin(), 5));
+ r = m.equal_range(15);
+ assert(r.first == next(m.begin(), 5));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(17);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 7));
+ r = m.equal_range(19);
+ assert(r.first == next(m.begin(), 7));
+ assert(r.second == next(m.begin(), 8));
+ r = m.equal_range(4);
+ assert(r.first == next(m.begin(), 0));
+ assert(r.second == next(m.begin(), 0));
+ r = m.equal_range(6);
+ assert(r.first == next(m.begin(), 1));
+ assert(r.second == next(m.begin(), 1));
+ r = m.equal_range(8);
+ assert(r.first == next(m.begin(), 2));
+ assert(r.second == next(m.begin(), 2));
+ r = m.equal_range(10);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(12);
+ assert(r.first == next(m.begin(), 4));
+ assert(r.second == next(m.begin(), 4));
+ r = m.equal_range(14);
+ assert(r.first == next(m.begin(), 5));
+ assert(r.second == next(m.begin(), 5));
+ r = m.equal_range(16);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(18);
+ assert(r.first == next(m.begin(), 7));
+ assert(r.second == next(m.begin(), 7));
+ r = m.equal_range(20);
+ assert(r.first == next(m.begin(), 8));
+ assert(r.second == next(m.begin(), 8));
+ }
+ {
+ typedef std::pair<M::const_iterator, M::const_iterator> R;
+ V ar[] =
+ {
+ V(5, 5),
+ V(7, 6),
+ V(9, 7),
+ V(11, 8),
+ V(13, 9),
+ V(15, 10),
+ V(17, 11),
+ V(19, 12)
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.equal_range(5);
+ assert(r.first == next(m.begin(), 0));
+ assert(r.second == next(m.begin(), 1));
+ r = m.equal_range(7);
+ assert(r.first == next(m.begin(), 1));
+ assert(r.second == next(m.begin(), 2));
+ r = m.equal_range(9);
+ assert(r.first == next(m.begin(), 2));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(11);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 4));
+ r = m.equal_range(13);
+ assert(r.first == next(m.begin(), 4));
+ assert(r.second == next(m.begin(), 5));
+ r = m.equal_range(15);
+ assert(r.first == next(m.begin(), 5));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(17);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 7));
+ r = m.equal_range(19);
+ assert(r.first == next(m.begin(), 7));
+ assert(r.second == next(m.begin(), 8));
+ r = m.equal_range(4);
+ assert(r.first == next(m.begin(), 0));
+ assert(r.second == next(m.begin(), 0));
+ r = m.equal_range(6);
+ assert(r.first == next(m.begin(), 1));
+ assert(r.second == next(m.begin(), 1));
+ r = m.equal_range(8);
+ assert(r.first == next(m.begin(), 2));
+ assert(r.second == next(m.begin(), 2));
+ r = m.equal_range(10);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(12);
+ assert(r.first == next(m.begin(), 4));
+ assert(r.second == next(m.begin(), 4));
+ r = m.equal_range(14);
+ assert(r.first == next(m.begin(), 5));
+ assert(r.second == next(m.begin(), 5));
+ r = m.equal_range(16);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(18);
+ assert(r.first == next(m.begin(), 7));
+ assert(r.second == next(m.begin(), 7));
+ r = m.equal_range(20);
+ assert(r.first == next(m.begin(), 8));
+ assert(r.second == next(m.begin(), 8));
+ }
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<const int, double> V;
+ typedef std::map<int, double, std::less<int>, min_allocator<V>> M;
+ {
+ typedef std::pair<M::iterator, M::iterator> R;
+ V ar[] =
+ {
+ V(5, 5),
+ V(7, 6),
+ V(9, 7),
+ V(11, 8),
+ V(13, 9),
+ V(15, 10),
+ V(17, 11),
+ V(19, 12)
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.equal_range(5);
+ assert(r.first == next(m.begin(), 0));
+ assert(r.second == next(m.begin(), 1));
+ r = m.equal_range(7);
+ assert(r.first == next(m.begin(), 1));
+ assert(r.second == next(m.begin(), 2));
+ r = m.equal_range(9);
+ assert(r.first == next(m.begin(), 2));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(11);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 4));
+ r = m.equal_range(13);
+ assert(r.first == next(m.begin(), 4));
+ assert(r.second == next(m.begin(), 5));
+ r = m.equal_range(15);
+ assert(r.first == next(m.begin(), 5));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(17);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 7));
+ r = m.equal_range(19);
+ assert(r.first == next(m.begin(), 7));
+ assert(r.second == next(m.begin(), 8));
+ r = m.equal_range(4);
+ assert(r.first == next(m.begin(), 0));
+ assert(r.second == next(m.begin(), 0));
+ r = m.equal_range(6);
+ assert(r.first == next(m.begin(), 1));
+ assert(r.second == next(m.begin(), 1));
+ r = m.equal_range(8);
+ assert(r.first == next(m.begin(), 2));
+ assert(r.second == next(m.begin(), 2));
+ r = m.equal_range(10);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(12);
+ assert(r.first == next(m.begin(), 4));
+ assert(r.second == next(m.begin(), 4));
+ r = m.equal_range(14);
+ assert(r.first == next(m.begin(), 5));
+ assert(r.second == next(m.begin(), 5));
+ r = m.equal_range(16);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(18);
+ assert(r.first == next(m.begin(), 7));
+ assert(r.second == next(m.begin(), 7));
+ r = m.equal_range(20);
+ assert(r.first == next(m.begin(), 8));
+ assert(r.second == next(m.begin(), 8));
+ }
+ {
+ typedef std::pair<M::const_iterator, M::const_iterator> R;
+ V ar[] =
+ {
+ V(5, 5),
+ V(7, 6),
+ V(9, 7),
+ V(11, 8),
+ V(13, 9),
+ V(15, 10),
+ V(17, 11),
+ V(19, 12)
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.equal_range(5);
+ assert(r.first == next(m.begin(), 0));
+ assert(r.second == next(m.begin(), 1));
+ r = m.equal_range(7);
+ assert(r.first == next(m.begin(), 1));
+ assert(r.second == next(m.begin(), 2));
+ r = m.equal_range(9);
+ assert(r.first == next(m.begin(), 2));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(11);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 4));
+ r = m.equal_range(13);
+ assert(r.first == next(m.begin(), 4));
+ assert(r.second == next(m.begin(), 5));
+ r = m.equal_range(15);
+ assert(r.first == next(m.begin(), 5));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(17);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 7));
+ r = m.equal_range(19);
+ assert(r.first == next(m.begin(), 7));
+ assert(r.second == next(m.begin(), 8));
+ r = m.equal_range(4);
+ assert(r.first == next(m.begin(), 0));
+ assert(r.second == next(m.begin(), 0));
+ r = m.equal_range(6);
+ assert(r.first == next(m.begin(), 1));
+ assert(r.second == next(m.begin(), 1));
+ r = m.equal_range(8);
+ assert(r.first == next(m.begin(), 2));
+ assert(r.second == next(m.begin(), 2));
+ r = m.equal_range(10);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(12);
+ assert(r.first == next(m.begin(), 4));
+ assert(r.second == next(m.begin(), 4));
+ r = m.equal_range(14);
+ assert(r.first == next(m.begin(), 5));
+ assert(r.second == next(m.begin(), 5));
+ r = m.equal_range(16);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(18);
+ assert(r.first == next(m.begin(), 7));
+ assert(r.second == next(m.begin(), 7));
+ r = m.equal_range(20);
+ assert(r.first == next(m.begin(), 8));
+ assert(r.second == next(m.begin(), 8));
+ }
+ }
+#endif
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::pair<const int, double> V;
+ typedef std::map<int, double, std::less<>> M;
+ typedef std::pair<M::iterator, M::iterator> R;
+
+ V ar[] =
+ {
+ V(5, 5),
+ V(7, 6),
+ V(9, 7),
+ V(11, 8),
+ V(13, 9),
+ V(15, 10),
+ V(17, 11),
+ V(19, 12)
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.equal_range(5);
+ assert(r.first == next(m.begin(), 0));
+ assert(r.second == next(m.begin(), 1));
+ r = m.equal_range(7);
+ assert(r.first == next(m.begin(), 1));
+ assert(r.second == next(m.begin(), 2));
+ r = m.equal_range(9);
+ assert(r.first == next(m.begin(), 2));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(11);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 4));
+ r = m.equal_range(13);
+ assert(r.first == next(m.begin(), 4));
+ assert(r.second == next(m.begin(), 5));
+ r = m.equal_range(15);
+ assert(r.first == next(m.begin(), 5));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(17);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 7));
+ r = m.equal_range(19);
+ assert(r.first == next(m.begin(), 7));
+ assert(r.second == next(m.begin(), 8));
+ r = m.equal_range(4);
+ assert(r.first == next(m.begin(), 0));
+ assert(r.second == next(m.begin(), 0));
+ r = m.equal_range(6);
+ assert(r.first == next(m.begin(), 1));
+ assert(r.second == next(m.begin(), 1));
+ r = m.equal_range(8);
+ assert(r.first == next(m.begin(), 2));
+ assert(r.second == next(m.begin(), 2));
+ r = m.equal_range(10);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(12);
+ assert(r.first == next(m.begin(), 4));
+ assert(r.second == next(m.begin(), 4));
+ r = m.equal_range(14);
+ assert(r.first == next(m.begin(), 5));
+ assert(r.second == next(m.begin(), 5));
+ r = m.equal_range(16);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(18);
+ assert(r.first == next(m.begin(), 7));
+ assert(r.second == next(m.begin(), 7));
+ r = m.equal_range(20);
+ assert(r.first == next(m.begin(), 8));
+ assert(r.second == next(m.begin(), 8));
+
+ r = m.equal_range(C2Int(5));
+ assert(r.first == next(m.begin(), 0));
+ assert(r.second == next(m.begin(), 1));
+ r = m.equal_range(C2Int(7));
+ assert(r.first == next(m.begin(), 1));
+ assert(r.second == next(m.begin(), 2));
+ r = m.equal_range(C2Int(9));
+ assert(r.first == next(m.begin(), 2));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(C2Int(11));
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 4));
+ r = m.equal_range(C2Int(13));
+ assert(r.first == next(m.begin(), 4));
+ assert(r.second == next(m.begin(), 5));
+ r = m.equal_range(C2Int(15));
+ assert(r.first == next(m.begin(), 5));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(C2Int(17));
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 7));
+ r = m.equal_range(C2Int(19));
+ assert(r.first == next(m.begin(), 7));
+ assert(r.second == next(m.begin(), 8));
+ r = m.equal_range(C2Int(4));
+ assert(r.first == next(m.begin(), 0));
+ assert(r.second == next(m.begin(), 0));
+ r = m.equal_range(C2Int(6));
+ assert(r.first == next(m.begin(), 1));
+ assert(r.second == next(m.begin(), 1));
+ r = m.equal_range(C2Int(8));
+ assert(r.first == next(m.begin(), 2));
+ assert(r.second == next(m.begin(), 2));
+ r = m.equal_range(C2Int(10));
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(C2Int(12));
+ assert(r.first == next(m.begin(), 4));
+ assert(r.second == next(m.begin(), 4));
+ r = m.equal_range(C2Int(14));
+ assert(r.first == next(m.begin(), 5));
+ assert(r.second == next(m.begin(), 5));
+ r = m.equal_range(C2Int(16));
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(C2Int(18));
+ assert(r.first == next(m.begin(), 7));
+ assert(r.second == next(m.begin(), 7));
+ r = m.equal_range(C2Int(20));
+ assert(r.first == next(m.begin(), 8));
+ assert(r.second == next(m.begin(), 8));
+ }
+ {
+ typedef PrivateConstructor PC;
+ typedef std::map<PC, double, std::less<>> M;
+ typedef std::pair<M::iterator, M::iterator> R;
+
+ M m;
+ m [ PC::make(5) ] = 5;
+ m [ PC::make(7) ] = 6;
+ m [ PC::make(9) ] = 7;
+ m [ PC::make(11) ] = 8;
+ m [ PC::make(13) ] = 9;
+ m [ PC::make(15) ] = 10;
+ m [ PC::make(17) ] = 11;
+ m [ PC::make(19) ] = 12;
+
+ R r = m.equal_range(5);
+ assert(r.first == next(m.begin(), 0));
+ assert(r.second == next(m.begin(), 1));
+ r = m.equal_range(7);
+ assert(r.first == next(m.begin(), 1));
+ assert(r.second == next(m.begin(), 2));
+ r = m.equal_range(9);
+ assert(r.first == next(m.begin(), 2));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(11);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 4));
+ r = m.equal_range(13);
+ assert(r.first == next(m.begin(), 4));
+ assert(r.second == next(m.begin(), 5));
+ r = m.equal_range(15);
+ assert(r.first == next(m.begin(), 5));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(17);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 7));
+ r = m.equal_range(19);
+ assert(r.first == next(m.begin(), 7));
+ assert(r.second == next(m.begin(), 8));
+ r = m.equal_range(4);
+ assert(r.first == next(m.begin(), 0));
+ assert(r.second == next(m.begin(), 0));
+ r = m.equal_range(6);
+ assert(r.first == next(m.begin(), 1));
+ assert(r.second == next(m.begin(), 1));
+ r = m.equal_range(8);
+ assert(r.first == next(m.begin(), 2));
+ assert(r.second == next(m.begin(), 2));
+ r = m.equal_range(10);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(12);
+ assert(r.first == next(m.begin(), 4));
+ assert(r.second == next(m.begin(), 4));
+ r = m.equal_range(14);
+ assert(r.first == next(m.begin(), 5));
+ assert(r.second == next(m.begin(), 5));
+ r = m.equal_range(16);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(18);
+ assert(r.first == next(m.begin(), 7));
+ assert(r.second == next(m.begin(), 7));
+ r = m.equal_range(20);
+ assert(r.first == next(m.begin(), 8));
+ assert(r.second == next(m.begin(), 8));
+ }
+#endif
+}
diff --git a/test/std/containers/associative/map/map.ops/equal_range0.pass.cpp b/test/std/containers/associative/map/map.ops/equal_range0.pass.cpp
new file mode 100644
index 000000000000..c95c3dffa9a5
--- /dev/null
+++ b/test/std/containers/associative/map/map.ops/equal_range0.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// XFAIL: c++03, c++11
+
+// <map>
+
+// class map
+
+// iterator find(const key_type& k);
+// const_iterator find(const key_type& k) const;
+//
+// The member function templates find, count, lower_bound, upper_bound, and
+// equal_range shall not participate in overload resolution unless the
+// qualified-id Compare::is_transparent is valid and denotes a type
+
+
+#include <map>
+#include <cassert>
+
+#include "is_transparent.h"
+
+int main()
+{
+ typedef std::map<int, double, transparent_less> M;
+
+ M().equal_range(C2Int{5});
+}
diff --git a/test/std/containers/associative/map/map.ops/equal_range1.fail.cpp b/test/std/containers/associative/map/map.ops/equal_range1.fail.cpp
new file mode 100644
index 000000000000..8f0da08eb322
--- /dev/null
+++ b/test/std/containers/associative/map/map.ops/equal_range1.fail.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// iterator find(const key_type& k);
+// const_iterator find(const key_type& k) const;
+//
+// The member function templates find, count, lower_bound, upper_bound, and
+// equal_range shall not participate in overload resolution unless the
+// qualified-id Compare::is_transparent is valid and denotes a type
+
+
+#include <map>
+#include <cassert>
+
+#include "is_transparent.h"
+
+#if _LIBCPP_STD_VER <= 11
+#error "This test requires is C++14 (or later)"
+#else
+
+int main()
+{
+ {
+ typedef std::map<int, double, transparent_less_no_type> M;
+
+ M().equal_range(C2Int{5});
+ }
+}
+#endif \ No newline at end of file
diff --git a/test/std/containers/associative/map/map.ops/equal_range2.fail.cpp b/test/std/containers/associative/map/map.ops/equal_range2.fail.cpp
new file mode 100644
index 000000000000..e73122d6533b
--- /dev/null
+++ b/test/std/containers/associative/map/map.ops/equal_range2.fail.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// iterator find(const key_type& k);
+// const_iterator find(const key_type& k) const;
+//
+// The member function templates find, count, lower_bound, upper_bound, and
+// equal_range shall not participate in overload resolution unless the
+// qualified-id Compare::is_transparent is valid and denotes a type
+
+
+#include <map>
+#include <cassert>
+
+#include "is_transparent.h"
+
+#if _LIBCPP_STD_VER <= 11
+#error "This test requires is C++14 (or later)"
+#else
+
+int main()
+{
+ {
+ typedef std::map<int, double, transparent_less_private> M;
+
+ M().equal_range(C2Int{5});
+ }
+}
+#endif \ No newline at end of file
diff --git a/test/std/containers/associative/map/map.ops/equal_range3.fail.cpp b/test/std/containers/associative/map/map.ops/equal_range3.fail.cpp
new file mode 100644
index 000000000000..bb72e9e7a6d4
--- /dev/null
+++ b/test/std/containers/associative/map/map.ops/equal_range3.fail.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// iterator find(const key_type& k);
+// const_iterator find(const key_type& k) const;
+//
+// The member function templates find, count, lower_bound, upper_bound, and
+// equal_range shall not participate in overload resolution unless the
+// qualified-id Compare::is_transparent is valid and denotes a type
+
+
+#include <map>
+#include <cassert>
+
+#include "is_transparent.h"
+
+#if _LIBCPP_STD_VER <= 11
+#error "This test requires is C++14 (or later)"
+#else
+
+int main()
+{
+ {
+ typedef std::map<int, double, transparent_less_not_a_type> M;
+
+ M().equal_range(C2Int{5});
+ }
+}
+#endif \ No newline at end of file
diff --git a/test/std/containers/associative/map/map.ops/find.pass.cpp b/test/std/containers/associative/map/map.ops/find.pass.cpp
new file mode 100644
index 000000000000..17463b65740f
--- /dev/null
+++ b/test/std/containers/associative/map/map.ops/find.pass.cpp
@@ -0,0 +1,260 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// iterator find(const key_type& k);
+// const_iterator find(const key_type& k) const;
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "private_constructor.hpp"
+#include "is_transparent.h"
+
+int main()
+{
+ {
+ typedef std::pair<const int, double> V;
+ typedef std::map<int, double> M;
+ {
+ typedef M::iterator R;
+ V ar[] =
+ {
+ V(5, 5),
+ V(6, 6),
+ V(7, 7),
+ V(8, 8),
+ V(9, 9),
+ V(10, 10),
+ V(11, 11),
+ V(12, 12)
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.find(5);
+ assert(r == m.begin());
+ r = m.find(6);
+ assert(r == next(m.begin()));
+ r = m.find(7);
+ assert(r == next(m.begin(), 2));
+ r = m.find(8);
+ assert(r == next(m.begin(), 3));
+ r = m.find(9);
+ assert(r == next(m.begin(), 4));
+ r = m.find(10);
+ assert(r == next(m.begin(), 5));
+ r = m.find(11);
+ assert(r == next(m.begin(), 6));
+ r = m.find(12);
+ assert(r == next(m.begin(), 7));
+ r = m.find(4);
+ assert(r == next(m.begin(), 8));
+ }
+ {
+ typedef M::const_iterator R;
+ V ar[] =
+ {
+ V(5, 5),
+ V(6, 6),
+ V(7, 7),
+ V(8, 8),
+ V(9, 9),
+ V(10, 10),
+ V(11, 11),
+ V(12, 12)
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.find(5);
+ assert(r == m.begin());
+ r = m.find(6);
+ assert(r == next(m.begin()));
+ r = m.find(7);
+ assert(r == next(m.begin(), 2));
+ r = m.find(8);
+ assert(r == next(m.begin(), 3));
+ r = m.find(9);
+ assert(r == next(m.begin(), 4));
+ r = m.find(10);
+ assert(r == next(m.begin(), 5));
+ r = m.find(11);
+ assert(r == next(m.begin(), 6));
+ r = m.find(12);
+ assert(r == next(m.begin(), 7));
+ r = m.find(4);
+ assert(r == next(m.begin(), 8));
+ }
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<const int, double> V;
+ typedef std::map<int, double, std::less<int>, min_allocator<V>> M;
+ {
+ typedef M::iterator R;
+ V ar[] =
+ {
+ V(5, 5),
+ V(6, 6),
+ V(7, 7),
+ V(8, 8),
+ V(9, 9),
+ V(10, 10),
+ V(11, 11),
+ V(12, 12)
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.find(5);
+ assert(r == m.begin());
+ r = m.find(6);
+ assert(r == next(m.begin()));
+ r = m.find(7);
+ assert(r == next(m.begin(), 2));
+ r = m.find(8);
+ assert(r == next(m.begin(), 3));
+ r = m.find(9);
+ assert(r == next(m.begin(), 4));
+ r = m.find(10);
+ assert(r == next(m.begin(), 5));
+ r = m.find(11);
+ assert(r == next(m.begin(), 6));
+ r = m.find(12);
+ assert(r == next(m.begin(), 7));
+ r = m.find(4);
+ assert(r == next(m.begin(), 8));
+ }
+ {
+ typedef M::const_iterator R;
+ V ar[] =
+ {
+ V(5, 5),
+ V(6, 6),
+ V(7, 7),
+ V(8, 8),
+ V(9, 9),
+ V(10, 10),
+ V(11, 11),
+ V(12, 12)
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.find(5);
+ assert(r == m.begin());
+ r = m.find(6);
+ assert(r == next(m.begin()));
+ r = m.find(7);
+ assert(r == next(m.begin(), 2));
+ r = m.find(8);
+ assert(r == next(m.begin(), 3));
+ r = m.find(9);
+ assert(r == next(m.begin(), 4));
+ r = m.find(10);
+ assert(r == next(m.begin(), 5));
+ r = m.find(11);
+ assert(r == next(m.begin(), 6));
+ r = m.find(12);
+ assert(r == next(m.begin(), 7));
+ r = m.find(4);
+ assert(r == next(m.begin(), 8));
+ }
+ }
+#endif
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::pair<const int, double> V;
+ typedef std::map<int, double, std::less<>> M;
+ typedef M::iterator R;
+
+ V ar[] =
+ {
+ V(5, 5),
+ V(6, 6),
+ V(7, 7),
+ V(8, 8),
+ V(9, 9),
+ V(10, 10),
+ V(11, 11),
+ V(12, 12)
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.find(5);
+ assert(r == m.begin());
+ r = m.find(6);
+ assert(r == next(m.begin()));
+ r = m.find(7);
+ assert(r == next(m.begin(), 2));
+ r = m.find(8);
+ assert(r == next(m.begin(), 3));
+ r = m.find(9);
+ assert(r == next(m.begin(), 4));
+ r = m.find(10);
+ assert(r == next(m.begin(), 5));
+ r = m.find(11);
+ assert(r == next(m.begin(), 6));
+ r = m.find(12);
+ assert(r == next(m.begin(), 7));
+ r = m.find(4);
+ assert(r == next(m.begin(), 8));
+
+ r = m.find(C2Int(5));
+ assert(r == m.begin());
+ r = m.find(C2Int(6));
+ assert(r == next(m.begin()));
+ r = m.find(C2Int(7));
+ assert(r == next(m.begin(), 2));
+ r = m.find(C2Int(8));
+ assert(r == next(m.begin(), 3));
+ r = m.find(C2Int(9));
+ assert(r == next(m.begin(), 4));
+ r = m.find(C2Int(10));
+ assert(r == next(m.begin(), 5));
+ r = m.find(C2Int(11));
+ assert(r == next(m.begin(), 6));
+ r = m.find(C2Int(12));
+ assert(r == next(m.begin(), 7));
+ r = m.find(C2Int(4));
+ assert(r == next(m.begin(), 8));
+ }
+
+ {
+ typedef PrivateConstructor PC;
+ typedef std::map<PC, double, std::less<>> M;
+ typedef M::iterator R;
+
+ M m;
+ m [ PC::make(5) ] = 5;
+ m [ PC::make(6) ] = 6;
+ m [ PC::make(7) ] = 7;
+ m [ PC::make(8) ] = 8;
+ m [ PC::make(9) ] = 9;
+ m [ PC::make(10) ] = 10;
+ m [ PC::make(11) ] = 11;
+ m [ PC::make(12) ] = 12;
+
+ R r = m.find(5);
+ assert(r == m.begin());
+ r = m.find(6);
+ assert(r == next(m.begin()));
+ r = m.find(7);
+ assert(r == next(m.begin(), 2));
+ r = m.find(8);
+ assert(r == next(m.begin(), 3));
+ r = m.find(9);
+ assert(r == next(m.begin(), 4));
+ r = m.find(10);
+ assert(r == next(m.begin(), 5));
+ r = m.find(11);
+ assert(r == next(m.begin(), 6));
+ r = m.find(12);
+ assert(r == next(m.begin(), 7));
+ r = m.find(4);
+ assert(r == next(m.begin(), 8));
+ }
+#endif
+}
diff --git a/test/std/containers/associative/map/map.ops/find0.pass.cpp b/test/std/containers/associative/map/map.ops/find0.pass.cpp
new file mode 100644
index 000000000000..5f310b07c599
--- /dev/null
+++ b/test/std/containers/associative/map/map.ops/find0.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// XFAIL: c++03, c++11
+
+// <map>
+
+// class map
+
+// iterator find(const key_type& k);
+// const_iterator find(const key_type& k) const;
+//
+// The member function templates find, count, lower_bound, upper_bound, and
+// equal_range shall not participate in overload resolution unless the
+// qualified-id Compare::is_transparent is valid and denotes a type
+
+
+#include <map>
+#include <cassert>
+
+#include "is_transparent.h"
+
+int main()
+{
+ typedef std::map<int, double, transparent_less> M;
+
+ M().find(C2Int{5});
+}
diff --git a/test/std/containers/associative/map/map.ops/find1.fail.cpp b/test/std/containers/associative/map/map.ops/find1.fail.cpp
new file mode 100644
index 000000000000..c33b5a9a34cf
--- /dev/null
+++ b/test/std/containers/associative/map/map.ops/find1.fail.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// iterator find(const key_type& k);
+// const_iterator find(const key_type& k) const;
+//
+// The member function templates find, count, lower_bound, upper_bound, and
+// equal_range shall not participate in overload resolution unless the
+// qualified-id Compare::is_transparent is valid and denotes a type
+
+
+#include <map>
+#include <cassert>
+
+#include "is_transparent.h"
+
+#if _LIBCPP_STD_VER <= 11
+#error "This test requires is C++14 (or later)"
+#else
+
+int main()
+{
+ {
+ typedef std::map<int, double, transparent_less_no_type> M;
+
+ M().find(C2Int{5});
+ }
+}
+#endif \ No newline at end of file
diff --git a/test/std/containers/associative/map/map.ops/find2.fail.cpp b/test/std/containers/associative/map/map.ops/find2.fail.cpp
new file mode 100644
index 000000000000..40bf323a4538
--- /dev/null
+++ b/test/std/containers/associative/map/map.ops/find2.fail.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// iterator find(const key_type& k);
+// const_iterator find(const key_type& k) const;
+//
+// The member function templates find, count, lower_bound, upper_bound, and
+// equal_range shall not participate in overload resolution unless the
+// qualified-id Compare::is_transparent is valid and denotes a type
+
+
+#include <map>
+#include <cassert>
+
+#include "is_transparent.h"
+
+#if _LIBCPP_STD_VER <= 11
+#error "This test requires is C++14 (or later)"
+#else
+
+int main()
+{
+ {
+ typedef std::map<int, double, transparent_less_private> M;
+
+ M().find(C2Int{5});
+ }
+}
+#endif \ No newline at end of file
diff --git a/test/std/containers/associative/map/map.ops/find3.fail.cpp b/test/std/containers/associative/map/map.ops/find3.fail.cpp
new file mode 100644
index 000000000000..9526c0e24d9e
--- /dev/null
+++ b/test/std/containers/associative/map/map.ops/find3.fail.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// iterator find(const key_type& k);
+// const_iterator find(const key_type& k) const;
+//
+// The member function templates find, count, lower_bound, upper_bound, and
+// equal_range shall not participate in overload resolution unless the
+// qualified-id Compare::is_transparent is valid and denotes a type
+
+
+#include <map>
+#include <cassert>
+
+#include "is_transparent.h"
+
+#if _LIBCPP_STD_VER <= 11
+#error "This test requires is C++14 (or later)"
+#else
+
+int main()
+{
+ {
+ typedef std::map<int, double, transparent_less_not_a_type> M;
+
+ M().find(C2Int{5});
+ }
+}
+#endif \ No newline at end of file
diff --git a/test/std/containers/associative/map/map.ops/lower_bound.pass.cpp b/test/std/containers/associative/map/map.ops/lower_bound.pass.cpp
new file mode 100644
index 000000000000..3cbfbf7d869f
--- /dev/null
+++ b/test/std/containers/associative/map/map.ops/lower_bound.pass.cpp
@@ -0,0 +1,372 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// iterator lower_bound(const key_type& k);
+// const_iterator lower_bound(const key_type& k) const;
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "private_constructor.hpp"
+#include "is_transparent.h"
+
+int main()
+{
+ {
+ typedef std::pair<const int, double> V;
+ typedef std::map<int, double> M;
+ {
+ typedef M::iterator R;
+ V ar[] =
+ {
+ V(5, 5),
+ V(7, 6),
+ V(9, 7),
+ V(11, 8),
+ V(13, 9),
+ V(15, 10),
+ V(17, 11),
+ V(19, 12)
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.lower_bound(5);
+ assert(r == m.begin());
+ r = m.lower_bound(7);
+ assert(r == next(m.begin()));
+ r = m.lower_bound(9);
+ assert(r == next(m.begin(), 2));
+ r = m.lower_bound(11);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(13);
+ assert(r == next(m.begin(), 4));
+ r = m.lower_bound(15);
+ assert(r == next(m.begin(), 5));
+ r = m.lower_bound(17);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(19);
+ assert(r == next(m.begin(), 7));
+ r = m.lower_bound(4);
+ assert(r == next(m.begin(), 0));
+ r = m.lower_bound(6);
+ assert(r == next(m.begin(), 1));
+ r = m.lower_bound(8);
+ assert(r == next(m.begin(), 2));
+ r = m.lower_bound(10);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(12);
+ assert(r == next(m.begin(), 4));
+ r = m.lower_bound(14);
+ assert(r == next(m.begin(), 5));
+ r = m.lower_bound(16);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(18);
+ assert(r == next(m.begin(), 7));
+ r = m.lower_bound(20);
+ assert(r == next(m.begin(), 8));
+ }
+ {
+ typedef M::const_iterator R;
+ V ar[] =
+ {
+ V(5, 5),
+ V(7, 6),
+ V(9, 7),
+ V(11, 8),
+ V(13, 9),
+ V(15, 10),
+ V(17, 11),
+ V(19, 12)
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.lower_bound(5);
+ assert(r == m.begin());
+ r = m.lower_bound(7);
+ assert(r == next(m.begin()));
+ r = m.lower_bound(9);
+ assert(r == next(m.begin(), 2));
+ r = m.lower_bound(11);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(13);
+ assert(r == next(m.begin(), 4));
+ r = m.lower_bound(15);
+ assert(r == next(m.begin(), 5));
+ r = m.lower_bound(17);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(19);
+ assert(r == next(m.begin(), 7));
+ r = m.lower_bound(4);
+ assert(r == next(m.begin(), 0));
+ r = m.lower_bound(6);
+ assert(r == next(m.begin(), 1));
+ r = m.lower_bound(8);
+ assert(r == next(m.begin(), 2));
+ r = m.lower_bound(10);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(12);
+ assert(r == next(m.begin(), 4));
+ r = m.lower_bound(14);
+ assert(r == next(m.begin(), 5));
+ r = m.lower_bound(16);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(18);
+ assert(r == next(m.begin(), 7));
+ r = m.lower_bound(20);
+ assert(r == next(m.begin(), 8));
+ }
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<const int, double> V;
+ typedef std::map<int, double, std::less<int>, min_allocator<V>> M;
+ {
+ typedef M::iterator R;
+ V ar[] =
+ {
+ V(5, 5),
+ V(7, 6),
+ V(9, 7),
+ V(11, 8),
+ V(13, 9),
+ V(15, 10),
+ V(17, 11),
+ V(19, 12)
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.lower_bound(5);
+ assert(r == m.begin());
+ r = m.lower_bound(7);
+ assert(r == next(m.begin()));
+ r = m.lower_bound(9);
+ assert(r == next(m.begin(), 2));
+ r = m.lower_bound(11);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(13);
+ assert(r == next(m.begin(), 4));
+ r = m.lower_bound(15);
+ assert(r == next(m.begin(), 5));
+ r = m.lower_bound(17);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(19);
+ assert(r == next(m.begin(), 7));
+ r = m.lower_bound(4);
+ assert(r == next(m.begin(), 0));
+ r = m.lower_bound(6);
+ assert(r == next(m.begin(), 1));
+ r = m.lower_bound(8);
+ assert(r == next(m.begin(), 2));
+ r = m.lower_bound(10);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(12);
+ assert(r == next(m.begin(), 4));
+ r = m.lower_bound(14);
+ assert(r == next(m.begin(), 5));
+ r = m.lower_bound(16);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(18);
+ assert(r == next(m.begin(), 7));
+ r = m.lower_bound(20);
+ assert(r == next(m.begin(), 8));
+ }
+ {
+ typedef M::const_iterator R;
+ V ar[] =
+ {
+ V(5, 5),
+ V(7, 6),
+ V(9, 7),
+ V(11, 8),
+ V(13, 9),
+ V(15, 10),
+ V(17, 11),
+ V(19, 12)
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.lower_bound(5);
+ assert(r == m.begin());
+ r = m.lower_bound(7);
+ assert(r == next(m.begin()));
+ r = m.lower_bound(9);
+ assert(r == next(m.begin(), 2));
+ r = m.lower_bound(11);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(13);
+ assert(r == next(m.begin(), 4));
+ r = m.lower_bound(15);
+ assert(r == next(m.begin(), 5));
+ r = m.lower_bound(17);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(19);
+ assert(r == next(m.begin(), 7));
+ r = m.lower_bound(4);
+ assert(r == next(m.begin(), 0));
+ r = m.lower_bound(6);
+ assert(r == next(m.begin(), 1));
+ r = m.lower_bound(8);
+ assert(r == next(m.begin(), 2));
+ r = m.lower_bound(10);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(12);
+ assert(r == next(m.begin(), 4));
+ r = m.lower_bound(14);
+ assert(r == next(m.begin(), 5));
+ r = m.lower_bound(16);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(18);
+ assert(r == next(m.begin(), 7));
+ r = m.lower_bound(20);
+ assert(r == next(m.begin(), 8));
+ }
+ }
+#endif
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::pair<const int, double> V;
+ typedef std::map<int, double, std::less <>> M;
+ typedef M::iterator R;
+
+ V ar[] =
+ {
+ V(5, 5),
+ V(7, 6),
+ V(9, 7),
+ V(11, 8),
+ V(13, 9),
+ V(15, 10),
+ V(17, 11),
+ V(19, 12)
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.lower_bound(5);
+ assert(r == m.begin());
+ r = m.lower_bound(7);
+ assert(r == next(m.begin()));
+ r = m.lower_bound(9);
+ assert(r == next(m.begin(), 2));
+ r = m.lower_bound(11);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(13);
+ assert(r == next(m.begin(), 4));
+ r = m.lower_bound(15);
+ assert(r == next(m.begin(), 5));
+ r = m.lower_bound(17);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(19);
+ assert(r == next(m.begin(), 7));
+ r = m.lower_bound(4);
+ assert(r == next(m.begin(), 0));
+ r = m.lower_bound(6);
+ assert(r == next(m.begin(), 1));
+ r = m.lower_bound(8);
+ assert(r == next(m.begin(), 2));
+ r = m.lower_bound(10);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(12);
+ assert(r == next(m.begin(), 4));
+ r = m.lower_bound(14);
+ assert(r == next(m.begin(), 5));
+ r = m.lower_bound(16);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(18);
+ assert(r == next(m.begin(), 7));
+ r = m.lower_bound(20);
+ assert(r == next(m.begin(), 8));
+
+ r = m.lower_bound(C2Int(5));
+ assert(r == m.begin());
+ r = m.lower_bound(C2Int(7));
+ assert(r == next(m.begin()));
+ r = m.lower_bound(C2Int(9));
+ assert(r == next(m.begin(), 2));
+ r = m.lower_bound(C2Int(11));
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(C2Int(13));
+ assert(r == next(m.begin(), 4));
+ r = m.lower_bound(C2Int(15));
+ assert(r == next(m.begin(), 5));
+ r = m.lower_bound(C2Int(17));
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(C2Int(19));
+ assert(r == next(m.begin(), 7));
+ r = m.lower_bound(C2Int(4));
+ assert(r == next(m.begin(), 0));
+ r = m.lower_bound(C2Int(6));
+ assert(r == next(m.begin(), 1));
+ r = m.lower_bound(C2Int(8));
+ assert(r == next(m.begin(), 2));
+ r = m.lower_bound(C2Int(10));
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(C2Int(12));
+ assert(r == next(m.begin(), 4));
+ r = m.lower_bound(C2Int(14));
+ assert(r == next(m.begin(), 5));
+ r = m.lower_bound(C2Int(16));
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(C2Int(18));
+ assert(r == next(m.begin(), 7));
+ r = m.lower_bound(C2Int(20));
+ assert(r == next(m.begin(), 8));
+ }
+
+ {
+ typedef PrivateConstructor PC;
+ typedef std::map<PC, double, std::less<>> M;
+ typedef M::iterator R;
+
+ M m;
+ m [ PC::make(5) ] = 5;
+ m [ PC::make(7) ] = 6;
+ m [ PC::make(9) ] = 7;
+ m [ PC::make(11) ] = 8;
+ m [ PC::make(13) ] = 9;
+ m [ PC::make(15) ] = 10;
+ m [ PC::make(17) ] = 11;
+ m [ PC::make(19) ] = 12;
+
+ R r = m.lower_bound(5);
+ assert(r == m.begin());
+ r = m.lower_bound(7);
+ assert(r == next(m.begin()));
+ r = m.lower_bound(9);
+ assert(r == next(m.begin(), 2));
+ r = m.lower_bound(11);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(13);
+ assert(r == next(m.begin(), 4));
+ r = m.lower_bound(15);
+ assert(r == next(m.begin(), 5));
+ r = m.lower_bound(17);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(19);
+ assert(r == next(m.begin(), 7));
+ r = m.lower_bound(4);
+ assert(r == next(m.begin(), 0));
+ r = m.lower_bound(6);
+ assert(r == next(m.begin(), 1));
+ r = m.lower_bound(8);
+ assert(r == next(m.begin(), 2));
+ r = m.lower_bound(10);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(12);
+ assert(r == next(m.begin(), 4));
+ r = m.lower_bound(14);
+ assert(r == next(m.begin(), 5));
+ r = m.lower_bound(16);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(18);
+ assert(r == next(m.begin(), 7));
+ r = m.lower_bound(20);
+ assert(r == next(m.begin(), 8));
+ }
+#endif
+}
diff --git a/test/std/containers/associative/map/map.ops/lower_bound0.pass.cpp b/test/std/containers/associative/map/map.ops/lower_bound0.pass.cpp
new file mode 100644
index 000000000000..2fc095a8f2c1
--- /dev/null
+++ b/test/std/containers/associative/map/map.ops/lower_bound0.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// XFAIL: c++03, c++11
+
+// <map>
+
+// class map
+
+// iterator lower_bound(const key_type& k);
+// const_iterator lower_bound(const key_type& k) const;
+//
+// The member function templates find, count, lower_bound, upper_bound, and
+// equal_range shall not participate in overload resolution unless the
+// qualified-id Compare::is_transparent is valid and denotes a type
+
+
+#include <map>
+#include <cassert>
+
+#include "is_transparent.h"
+
+int main()
+{
+ typedef std::map<int, double, transparent_less> M;
+
+ M().lower_bound(C2Int{5});
+}
diff --git a/test/std/containers/associative/map/map.ops/lower_bound1.fail.cpp b/test/std/containers/associative/map/map.ops/lower_bound1.fail.cpp
new file mode 100644
index 000000000000..a4a986c1a7a4
--- /dev/null
+++ b/test/std/containers/associative/map/map.ops/lower_bound1.fail.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// iterator lower_bound(const key_type& k);
+// const_iterator lower_bound(const key_type& k) const;
+//
+// The member function templates find, count, lower_bound, upper_bound, and
+// equal_range shall not participate in overload resolution unless the
+// qualified-id Compare::is_transparent is valid and denotes a type
+
+
+#include <map>
+#include <cassert>
+
+#include "is_transparent.h"
+
+#if _LIBCPP_STD_VER <= 11
+#error "This test requires is C++14 (or later)"
+#else
+
+int main()
+{
+ {
+ typedef std::map<int, double, transparent_less_no_type> M;
+
+ M().lower_bound(C2Int{5});
+ }
+}
+#endif
diff --git a/test/std/containers/associative/map/map.ops/lower_bound2.fail.cpp b/test/std/containers/associative/map/map.ops/lower_bound2.fail.cpp
new file mode 100644
index 000000000000..3f6380e5e25f
--- /dev/null
+++ b/test/std/containers/associative/map/map.ops/lower_bound2.fail.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// iterator lower_bound(const key_type& k);
+// const_iterator lower_bound(const key_type& k) const;
+//
+// The member function templates find, count, lower_bound, upper_bound, and
+// equal_range shall not participate in overload resolution unless the
+// qualified-id Compare::is_transparent is valid and denotes a type
+
+
+#include <map>
+#include <cassert>
+
+#include "is_transparent.h"
+
+#if _LIBCPP_STD_VER <= 11
+#error "This test requires is C++14 (or later)"
+#else
+
+int main()
+{
+ {
+ typedef std::map<int, double, transparent_less_private> M;
+
+ M().lower_bound(C2Int{5});
+ }
+}
+#endif
diff --git a/test/std/containers/associative/map/map.ops/lower_bound3.fail.cpp b/test/std/containers/associative/map/map.ops/lower_bound3.fail.cpp
new file mode 100644
index 000000000000..18f2c7b71fde
--- /dev/null
+++ b/test/std/containers/associative/map/map.ops/lower_bound3.fail.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// iterator lower_bound(const key_type& k);
+// const_iterator lower_bound(const key_type& k) const;
+//
+// The member function templates find, count, lower_bound, upper_bound, and
+// equal_range shall not participate in overload resolution unless the
+// qualified-id Compare::is_transparent is valid and denotes a type
+
+
+#include <map>
+#include <cassert>
+
+#include "is_transparent.h"
+
+#if _LIBCPP_STD_VER <= 11
+#error "This test requires is C++14 (or later)"
+#else
+
+int main()
+{
+ {
+ typedef std::map<int, double, transparent_less_not_a_type> M;
+
+ M().lower_bound(C2Int{5});
+ }
+}
+#endif
diff --git a/test/std/containers/associative/map/map.ops/upper_bound.pass.cpp b/test/std/containers/associative/map/map.ops/upper_bound.pass.cpp
new file mode 100644
index 000000000000..037ceb962cd8
--- /dev/null
+++ b/test/std/containers/associative/map/map.ops/upper_bound.pass.cpp
@@ -0,0 +1,335 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// iterator upper_bound(const key_type& k);
+// const_iterator upper_bound(const key_type& k) const;
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "private_constructor.hpp"
+
+int main()
+{
+ {
+ typedef std::pair<const int, double> V;
+ typedef std::map<int, double> M;
+ {
+ typedef M::iterator R;
+ V ar[] =
+ {
+ V(5, 5),
+ V(7, 6),
+ V(9, 7),
+ V(11, 8),
+ V(13, 9),
+ V(15, 10),
+ V(17, 11),
+ V(19, 12)
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.upper_bound(5);
+ assert(r == next(m.begin(), 1));
+ r = m.upper_bound(7);
+ assert(r == next(m.begin(), 2));
+ r = m.upper_bound(9);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(11);
+ assert(r == next(m.begin(), 4));
+ r = m.upper_bound(13);
+ assert(r == next(m.begin(), 5));
+ r = m.upper_bound(15);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(17);
+ assert(r == next(m.begin(), 7));
+ r = m.upper_bound(19);
+ assert(r == next(m.begin(), 8));
+ r = m.upper_bound(4);
+ assert(r == next(m.begin(), 0));
+ r = m.upper_bound(6);
+ assert(r == next(m.begin(), 1));
+ r = m.upper_bound(8);
+ assert(r == next(m.begin(), 2));
+ r = m.upper_bound(10);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(12);
+ assert(r == next(m.begin(), 4));
+ r = m.upper_bound(14);
+ assert(r == next(m.begin(), 5));
+ r = m.upper_bound(16);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(18);
+ assert(r == next(m.begin(), 7));
+ r = m.upper_bound(20);
+ assert(r == next(m.begin(), 8));
+ }
+ {
+ typedef M::const_iterator R;
+ V ar[] =
+ {
+ V(5, 5),
+ V(7, 6),
+ V(9, 7),
+ V(11, 8),
+ V(13, 9),
+ V(15, 10),
+ V(17, 11),
+ V(19, 12)
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.upper_bound(5);
+ assert(r == next(m.begin(), 1));
+ r = m.upper_bound(7);
+ assert(r == next(m.begin(), 2));
+ r = m.upper_bound(9);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(11);
+ assert(r == next(m.begin(), 4));
+ r = m.upper_bound(13);
+ assert(r == next(m.begin(), 5));
+ r = m.upper_bound(15);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(17);
+ assert(r == next(m.begin(), 7));
+ r = m.upper_bound(19);
+ assert(r == next(m.begin(), 8));
+ r = m.upper_bound(4);
+ assert(r == next(m.begin(), 0));
+ r = m.upper_bound(6);
+ assert(r == next(m.begin(), 1));
+ r = m.upper_bound(8);
+ assert(r == next(m.begin(), 2));
+ r = m.upper_bound(10);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(12);
+ assert(r == next(m.begin(), 4));
+ r = m.upper_bound(14);
+ assert(r == next(m.begin(), 5));
+ r = m.upper_bound(16);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(18);
+ assert(r == next(m.begin(), 7));
+ r = m.upper_bound(20);
+ assert(r == next(m.begin(), 8));
+ }
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<const int, double> V;
+ typedef std::map<int, double, std::less<int>, min_allocator<V>> M;
+ {
+ typedef M::iterator R;
+ V ar[] =
+ {
+ V(5, 5),
+ V(7, 6),
+ V(9, 7),
+ V(11, 8),
+ V(13, 9),
+ V(15, 10),
+ V(17, 11),
+ V(19, 12)
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.upper_bound(5);
+ assert(r == next(m.begin(), 1));
+ r = m.upper_bound(7);
+ assert(r == next(m.begin(), 2));
+ r = m.upper_bound(9);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(11);
+ assert(r == next(m.begin(), 4));
+ r = m.upper_bound(13);
+ assert(r == next(m.begin(), 5));
+ r = m.upper_bound(15);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(17);
+ assert(r == next(m.begin(), 7));
+ r = m.upper_bound(19);
+ assert(r == next(m.begin(), 8));
+ r = m.upper_bound(4);
+ assert(r == next(m.begin(), 0));
+ r = m.upper_bound(6);
+ assert(r == next(m.begin(), 1));
+ r = m.upper_bound(8);
+ assert(r == next(m.begin(), 2));
+ r = m.upper_bound(10);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(12);
+ assert(r == next(m.begin(), 4));
+ r = m.upper_bound(14);
+ assert(r == next(m.begin(), 5));
+ r = m.upper_bound(16);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(18);
+ assert(r == next(m.begin(), 7));
+ r = m.upper_bound(20);
+ assert(r == next(m.begin(), 8));
+ }
+ {
+ typedef M::const_iterator R;
+ V ar[] =
+ {
+ V(5, 5),
+ V(7, 6),
+ V(9, 7),
+ V(11, 8),
+ V(13, 9),
+ V(15, 10),
+ V(17, 11),
+ V(19, 12)
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.upper_bound(5);
+ assert(r == next(m.begin(), 1));
+ r = m.upper_bound(7);
+ assert(r == next(m.begin(), 2));
+ r = m.upper_bound(9);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(11);
+ assert(r == next(m.begin(), 4));
+ r = m.upper_bound(13);
+ assert(r == next(m.begin(), 5));
+ r = m.upper_bound(15);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(17);
+ assert(r == next(m.begin(), 7));
+ r = m.upper_bound(19);
+ assert(r == next(m.begin(), 8));
+ r = m.upper_bound(4);
+ assert(r == next(m.begin(), 0));
+ r = m.upper_bound(6);
+ assert(r == next(m.begin(), 1));
+ r = m.upper_bound(8);
+ assert(r == next(m.begin(), 2));
+ r = m.upper_bound(10);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(12);
+ assert(r == next(m.begin(), 4));
+ r = m.upper_bound(14);
+ assert(r == next(m.begin(), 5));
+ r = m.upper_bound(16);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(18);
+ assert(r == next(m.begin(), 7));
+ r = m.upper_bound(20);
+ assert(r == next(m.begin(), 8));
+ }
+ }
+#endif
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::pair<const int, double> V;
+ typedef std::map<int, double, std::less<>> M;
+ typedef M::iterator R;
+ V ar[] =
+ {
+ V(5, 5),
+ V(7, 6),
+ V(9, 7),
+ V(11, 8),
+ V(13, 9),
+ V(15, 10),
+ V(17, 11),
+ V(19, 12)
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.upper_bound(5);
+ assert(r == next(m.begin(), 1));
+ r = m.upper_bound(7);
+ assert(r == next(m.begin(), 2));
+ r = m.upper_bound(9);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(11);
+ assert(r == next(m.begin(), 4));
+ r = m.upper_bound(13);
+ assert(r == next(m.begin(), 5));
+ r = m.upper_bound(15);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(17);
+ assert(r == next(m.begin(), 7));
+ r = m.upper_bound(19);
+ assert(r == next(m.begin(), 8));
+ r = m.upper_bound(4);
+ assert(r == next(m.begin(), 0));
+ r = m.upper_bound(6);
+ assert(r == next(m.begin(), 1));
+ r = m.upper_bound(8);
+ assert(r == next(m.begin(), 2));
+ r = m.upper_bound(10);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(12);
+ assert(r == next(m.begin(), 4));
+ r = m.upper_bound(14);
+ assert(r == next(m.begin(), 5));
+ r = m.upper_bound(16);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(18);
+ assert(r == next(m.begin(), 7));
+ r = m.upper_bound(20);
+ assert(r == next(m.begin(), 8));
+ }
+
+ {
+ typedef PrivateConstructor PC;
+ typedef std::map<PC, double, std::less<>> M;
+ typedef M::iterator R;
+
+ M m;
+ m [ PC::make(5) ] = 5;
+ m [ PC::make(7) ] = 6;
+ m [ PC::make(9) ] = 7;
+ m [ PC::make(11) ] = 8;
+ m [ PC::make(13) ] = 9;
+ m [ PC::make(15) ] = 10;
+ m [ PC::make(17) ] = 11;
+ m [ PC::make(19) ] = 12;
+
+ R r = m.upper_bound(5);
+ assert(r == next(m.begin(), 1));
+ r = m.upper_bound(7);
+ assert(r == next(m.begin(), 2));
+ r = m.upper_bound(9);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(11);
+ assert(r == next(m.begin(), 4));
+ r = m.upper_bound(13);
+ assert(r == next(m.begin(), 5));
+ r = m.upper_bound(15);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(17);
+ assert(r == next(m.begin(), 7));
+ r = m.upper_bound(19);
+ assert(r == next(m.begin(), 8));
+ r = m.upper_bound(4);
+ assert(r == next(m.begin(), 0));
+ r = m.upper_bound(6);
+ assert(r == next(m.begin(), 1));
+ r = m.upper_bound(8);
+ assert(r == next(m.begin(), 2));
+ r = m.upper_bound(10);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(12);
+ assert(r == next(m.begin(), 4));
+ r = m.upper_bound(14);
+ assert(r == next(m.begin(), 5));
+ r = m.upper_bound(16);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(18);
+ assert(r == next(m.begin(), 7));
+ r = m.upper_bound(20);
+ assert(r == next(m.begin(), 8));
+ }
+#endif
+}
diff --git a/test/std/containers/associative/map/map.ops/upper_bound0.pass.cpp b/test/std/containers/associative/map/map.ops/upper_bound0.pass.cpp
new file mode 100644
index 000000000000..c58e55f29793
--- /dev/null
+++ b/test/std/containers/associative/map/map.ops/upper_bound0.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// XFAIL: c++03, c++11
+
+// <map>
+
+// class map
+
+// iterator upper_bound(const key_type& k);
+// const_iterator upper_bound(const key_type& k) const;
+//
+// The member function templates find, count, lower_bound, upper_bound, and
+// equal_range shall not participate in overload resolution unless the
+// qualified-id Compare::is_transparent is valid and denotes a type
+
+
+#include <map>
+#include <cassert>
+
+#include "is_transparent.h"
+
+int main()
+{
+ typedef std::map<int, double, transparent_less> M;
+
+ M().upper_bound(C2Int{5});
+}
diff --git a/test/std/containers/associative/map/map.ops/upper_bound1.fail.cpp b/test/std/containers/associative/map/map.ops/upper_bound1.fail.cpp
new file mode 100644
index 000000000000..4647681b5cd1
--- /dev/null
+++ b/test/std/containers/associative/map/map.ops/upper_bound1.fail.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// iterator upper_bound(const key_type& k);
+// const_iterator upper_bound(const key_type& k) const;
+//
+// The member function templates find, count, lower_bound, upper_bound, and
+// equal_range shall not participate in overload resolution unless the
+// qualified-id Compare::is_transparent is valid and denotes a type
+
+
+#include <map>
+#include <cassert>
+
+#include "is_transparent.h"
+
+#if _LIBCPP_STD_VER <= 11
+#error "This test requires is C++14 (or later)"
+#else
+
+int main()
+{
+ {
+ typedef std::map<int, double, transparent_less_no_type> M;
+
+ M().upper_bound(C2Int{5});
+ }
+}
+#endif
diff --git a/test/std/containers/associative/map/map.ops/upper_bound2.fail.cpp b/test/std/containers/associative/map/map.ops/upper_bound2.fail.cpp
new file mode 100644
index 000000000000..11852fe0cc9f
--- /dev/null
+++ b/test/std/containers/associative/map/map.ops/upper_bound2.fail.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// iterator upper_bound(const key_type& k);
+// const_iterator upper_bound(const key_type& k) const;
+//
+// The member function templates find, count, lower_bound, upper_bound, and
+// equal_range shall not participate in overload resolution unless the
+// qualified-id Compare::is_transparent is valid and denotes a type
+
+
+#include <map>
+#include <cassert>
+
+#include "is_transparent.h"
+
+#if _LIBCPP_STD_VER <= 11
+#error "This test requires is C++14 (or later)"
+#else
+
+int main()
+{
+ {
+ typedef std::map<int, double, transparent_less_private> M;
+
+ M().upper_bound(C2Int{5});
+ }
+}
+#endif
diff --git a/test/std/containers/associative/map/map.ops/upper_bound3.fail.cpp b/test/std/containers/associative/map/map.ops/upper_bound3.fail.cpp
new file mode 100644
index 000000000000..9cddeb8acbdc
--- /dev/null
+++ b/test/std/containers/associative/map/map.ops/upper_bound3.fail.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// iterator upper_bound(const key_type& k);
+// const_iterator upper_bound(const key_type& k) const;
+//
+// The member function templates find, count, lower_bound, upper_bound, and
+// equal_range shall not participate in overload resolution unless the
+// qualified-id Compare::is_transparent is valid and denotes a type
+
+
+#include <map>
+#include <cassert>
+
+#include "is_transparent.h"
+
+#if _LIBCPP_STD_VER <= 11
+#error "This test requires is C++14 (or later)"
+#else
+
+int main()
+{
+ {
+ typedef std::map<int, double, transparent_less_not_a_type> M;
+
+ M().upper_bound(C2Int{5});
+ }
+}
+#endif
diff --git a/test/std/containers/associative/map/map.special/member_swap.pass.cpp b/test/std/containers/associative/map/map.special/member_swap.pass.cpp
new file mode 100644
index 000000000000..7c3ad9d50ae4
--- /dev/null
+++ b/test/std/containers/associative/map/map.special/member_swap.pass.cpp
@@ -0,0 +1,176 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// void swap(map& m);
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ typedef std::pair<const int, double> V;
+ {
+ typedef std::map<int, double> M;
+ {
+ M m1;
+ M m2;
+ M m1_save = m1;
+ M m2_save = m2;
+ m1.swap(m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar2[] =
+ {
+ V(5, 5),
+ V(6, 6),
+ V(7, 7),
+ V(8, 8),
+ V(9, 9),
+ V(10, 10),
+ V(11, 11),
+ V(12, 12)
+ };
+ M m1;
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ m1.swap(m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar1[] =
+ {
+ V(1, 1),
+ V(2, 2),
+ V(3, 3),
+ V(4, 4)
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2;
+ M m1_save = m1;
+ M m2_save = m2;
+ m1.swap(m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar1[] =
+ {
+ V(1, 1),
+ V(2, 2),
+ V(3, 3),
+ V(4, 4)
+ };
+ V ar2[] =
+ {
+ V(5, 5),
+ V(6, 6),
+ V(7, 7),
+ V(8, 8),
+ V(9, 9),
+ V(10, 10),
+ V(11, 11),
+ V(12, 12)
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ m1.swap(m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::map<int, double, std::less<int>, min_allocator<V>> M;
+ {
+ M m1;
+ M m2;
+ M m1_save = m1;
+ M m2_save = m2;
+ m1.swap(m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar2[] =
+ {
+ V(5, 5),
+ V(6, 6),
+ V(7, 7),
+ V(8, 8),
+ V(9, 9),
+ V(10, 10),
+ V(11, 11),
+ V(12, 12)
+ };
+ M m1;
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ m1.swap(m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar1[] =
+ {
+ V(1, 1),
+ V(2, 2),
+ V(3, 3),
+ V(4, 4)
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2;
+ M m1_save = m1;
+ M m2_save = m2;
+ m1.swap(m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar1[] =
+ {
+ V(1, 1),
+ V(2, 2),
+ V(3, 3),
+ V(4, 4)
+ };
+ V ar2[] =
+ {
+ V(5, 5),
+ V(6, 6),
+ V(7, 7),
+ V(8, 8),
+ V(9, 9),
+ V(10, 10),
+ V(11, 11),
+ V(12, 12)
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ m1.swap(m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ }
+#endif
+}
diff --git a/test/std/containers/associative/map/map.special/non_member_swap.pass.cpp b/test/std/containers/associative/map/map.special/non_member_swap.pass.cpp
new file mode 100644
index 000000000000..b042a4878f8a
--- /dev/null
+++ b/test/std/containers/associative/map/map.special/non_member_swap.pass.cpp
@@ -0,0 +1,281 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// template <class Key, class T, class Compare, class Allocator>
+// void
+// swap(map<Key, T, Compare, Allocator>& x, map<Key, T, Compare, Allocator>& y);
+
+#include <map>
+#include <cassert>
+#include "test_allocator.h"
+#include "../../../test_compare.h"
+#include "min_allocator.h"
+
+int main()
+{
+ typedef std::pair<const int, double> V;
+ {
+ typedef std::map<int, double> M;
+ {
+ M m1;
+ M m2;
+ M m1_save = m1;
+ M m2_save = m2;
+ swap(m1, m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar2[] =
+ {
+ V(5, 5),
+ V(6, 6),
+ V(7, 7),
+ V(8, 8),
+ V(9, 9),
+ V(10, 10),
+ V(11, 11),
+ V(12, 12)
+ };
+ M m1;
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ swap(m1, m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar1[] =
+ {
+ V(1, 1),
+ V(2, 2),
+ V(3, 3),
+ V(4, 4)
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2;
+ M m1_save = m1;
+ M m2_save = m2;
+ swap(m1, m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar1[] =
+ {
+ V(1, 1),
+ V(2, 2),
+ V(3, 3),
+ V(4, 4)
+ };
+ V ar2[] =
+ {
+ V(5, 5),
+ V(6, 6),
+ V(7, 7),
+ V(8, 8),
+ V(9, 9),
+ V(10, 10),
+ V(11, 11),
+ V(12, 12)
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ swap(m1, m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ typedef test_allocator<V> A;
+ typedef test_compare<std::less<int> > C;
+ typedef std::map<int, double, C, A> M;
+ V ar1[] =
+ {
+ V(1, 1),
+ V(2, 2),
+ V(3, 3),
+ V(4, 4)
+ };
+ V ar2[] =
+ {
+ V(5, 5),
+ V(6, 6),
+ V(7, 7),
+ V(8, 8),
+ V(9, 9),
+ V(10, 10),
+ V(11, 11),
+ V(12, 12)
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]), C(1), A(1));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]), C(2), A(2));
+ M m1_save = m1;
+ M m2_save = m2;
+ swap(m1, m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ assert(m1.key_comp() == C(2));
+ assert(m1.get_allocator() == A(1));
+ assert(m2.key_comp() == C(1));
+ assert(m2.get_allocator() == A(2));
+ }
+ {
+ typedef other_allocator<V> A;
+ typedef test_compare<std::less<int> > C;
+ typedef std::map<int, double, C, A> M;
+ V ar1[] =
+ {
+ V(1, 1),
+ V(2, 2),
+ V(3, 3),
+ V(4, 4)
+ };
+ V ar2[] =
+ {
+ V(5, 5),
+ V(6, 6),
+ V(7, 7),
+ V(8, 8),
+ V(9, 9),
+ V(10, 10),
+ V(11, 11),
+ V(12, 12)
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]), C(1), A(1));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]), C(2), A(2));
+ M m1_save = m1;
+ M m2_save = m2;
+ swap(m1, m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ assert(m1.key_comp() == C(2));
+ assert(m1.get_allocator() == A(2));
+ assert(m2.key_comp() == C(1));
+ assert(m2.get_allocator() == A(1));
+ }
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::map<int, double, std::less<int>, min_allocator<V>> M;
+ {
+ M m1;
+ M m2;
+ M m1_save = m1;
+ M m2_save = m2;
+ swap(m1, m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar2[] =
+ {
+ V(5, 5),
+ V(6, 6),
+ V(7, 7),
+ V(8, 8),
+ V(9, 9),
+ V(10, 10),
+ V(11, 11),
+ V(12, 12)
+ };
+ M m1;
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ swap(m1, m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar1[] =
+ {
+ V(1, 1),
+ V(2, 2),
+ V(3, 3),
+ V(4, 4)
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2;
+ M m1_save = m1;
+ M m2_save = m2;
+ swap(m1, m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar1[] =
+ {
+ V(1, 1),
+ V(2, 2),
+ V(3, 3),
+ V(4, 4)
+ };
+ V ar2[] =
+ {
+ V(5, 5),
+ V(6, 6),
+ V(7, 7),
+ V(8, 8),
+ V(9, 9),
+ V(10, 10),
+ V(11, 11),
+ V(12, 12)
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ swap(m1, m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ typedef min_allocator<V> A;
+ typedef test_compare<std::less<int> > C;
+ typedef std::map<int, double, C, A> M;
+ V ar1[] =
+ {
+ V(1, 1),
+ V(2, 2),
+ V(3, 3),
+ V(4, 4)
+ };
+ V ar2[] =
+ {
+ V(5, 5),
+ V(6, 6),
+ V(7, 7),
+ V(8, 8),
+ V(9, 9),
+ V(10, 10),
+ V(11, 11),
+ V(12, 12)
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]), C(1), A());
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]), C(2), A());
+ M m1_save = m1;
+ M m2_save = m2;
+ swap(m1, m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ assert(m1.key_comp() == C(2));
+ assert(m1.get_allocator() == A());
+ assert(m2.key_comp() == C(1));
+ assert(m2.get_allocator() == A());
+ }
+ }
+#endif
+}
diff --git a/test/std/containers/associative/map/map.special/swap_noexcept.pass.cpp b/test/std/containers/associative/map/map.special/swap_noexcept.pass.cpp
new file mode 100644
index 000000000000..4598e9945d4e
--- /dev/null
+++ b/test/std/containers/associative/map/map.special/swap_noexcept.pass.cpp
@@ -0,0 +1,148 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// void swap(map& c)
+// noexcept(!allocator_type::propagate_on_container_swap::value ||
+// __is_nothrow_swappable<allocator_type>::value);
+//
+// In C++17, the standard says that swap shall have:
+// noexcept(allocator_traits<Allocator>::is_always_equal::value &&
+// noexcept(swap(declval<Compare&>(), declval<Compare&>())));
+
+// This tests a conforming extension
+
+#include <map>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_comp
+{
+ typedef T value_type;
+
+ some_comp() {}
+ some_comp(const some_comp&) {}
+ void deallocate(void*, unsigned) {}
+
+ typedef std::true_type propagate_on_container_swap;
+};
+
+template <class T>
+struct some_comp2
+{
+ typedef T value_type;
+
+ some_comp2() {}
+ some_comp2(const some_comp2&) {}
+ void deallocate(void*, unsigned) {}
+ typedef std::true_type propagate_on_container_swap;
+};
+
+#if TEST_STD_VER >= 14
+template <typename T>
+void swap(some_comp2<T>&, some_comp2<T>&) noexcept {}
+#endif
+
+template <class T>
+struct some_alloc
+{
+ typedef T value_type;
+
+ some_alloc() {}
+ some_alloc(const some_alloc&);
+ void deallocate(void*, unsigned) {}
+
+ typedef std::true_type propagate_on_container_swap;
+};
+
+template <class T>
+struct some_alloc2
+{
+ typedef T value_type;
+
+ some_alloc2() {}
+ some_alloc2(const some_alloc2&);
+ void deallocate(void*, unsigned) {}
+
+ typedef std::false_type propagate_on_container_swap;
+ typedef std::true_type is_always_equal;
+};
+
+template <class T>
+struct some_alloc3
+{
+ typedef T value_type;
+
+ some_alloc3() {}
+ some_alloc3(const some_alloc3&);
+ void deallocate(void*, unsigned) {}
+
+ typedef std::false_type propagate_on_container_swap;
+ typedef std::false_type is_always_equal;
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::map<MoveOnly, MoveOnly> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::map<MoveOnly, MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::map<MoveOnly, MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::map<MoveOnly, MoveOnly, some_comp<MoveOnly>> C;
+ C c1, c2;
+ static_assert(!noexcept(swap(c1, c2)), "");
+ }
+
+#if TEST_STD_VER >= 14
+ { // POCS allocator, throwable swap for comp
+ typedef std::map<MoveOnly, MoveOnly, some_comp <MoveOnly>, some_alloc <MoveOnly>> C;
+ C c1, c2;
+ static_assert(!noexcept(swap(c1, c2)), "");
+ }
+ { // always equal allocator, throwable swap for comp
+ typedef std::map<MoveOnly, MoveOnly, some_comp <MoveOnly>, some_alloc2<MoveOnly>> C;
+ C c1, c2;
+ static_assert(!noexcept(swap(c1, c2)), "");
+ }
+ { // POCS allocator, nothrow swap for comp
+ typedef std::map<MoveOnly, MoveOnly, some_comp2<MoveOnly>, some_alloc <MoveOnly>> C;
+ C c1, c2;
+ static_assert( noexcept(swap(c1, c2)), "");
+ }
+ { // always equal allocator, nothrow swap for comp
+ typedef std::map<MoveOnly, MoveOnly, some_comp2<MoveOnly>, some_alloc2<MoveOnly>> C;
+ C c1, c2;
+ static_assert( noexcept(swap(c1, c2)), "");
+ }
+
+ { // NOT always equal allocator, nothrow swap for comp
+ typedef std::map<MoveOnly, MoveOnly, some_comp2<MoveOnly>, some_alloc3<MoveOnly>> C;
+ C c1, c2;
+ static_assert( noexcept(swap(c1, c2)), "");
+ }
+#endif
+
+#endif
+}
diff --git a/test/std/containers/associative/map/types.pass.cpp b/test/std/containers/associative/map/types.pass.cpp
new file mode 100644
index 000000000000..d117deff693d
--- /dev/null
+++ b/test/std/containers/associative/map/types.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// template <class Key, class T, class Compare = less<Key>,
+// class Allocator = allocator<pair<const Key, T>>>
+// class map
+// {
+// public:
+// // types:
+// typedef Key key_type;
+// typedef T mapped_type;
+// typedef pair<const key_type, mapped_type> value_type;
+// typedef Compare key_compare;
+// typedef Allocator allocator_type;
+// typedef typename allocator_type::reference reference;
+// typedef typename allocator_type::const_reference const_reference;
+// typedef typename allocator_type::pointer pointer;
+// typedef typename allocator_type::const_pointer const_pointer;
+// typedef typename allocator_type::size_type size_type;
+// typedef typename allocator_type::difference_type difference_type;
+// ...
+// };
+
+#include <map>
+#include <type_traits>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::map<int, double> C;
+ static_assert((std::is_same<C::key_type, int>::value), "");
+ static_assert((std::is_same<C::mapped_type, double>::value), "");
+ static_assert((std::is_same<C::value_type, std::pair<const int, double> >::value), "");
+ static_assert((std::is_same<C::key_compare, std::less<int> >::value), "");
+ static_assert((std::is_same<C::allocator_type, std::allocator<std::pair<const int, double> > >::value), "");
+ static_assert((std::is_same<C::reference, std::pair<const int, double>&>::value), "");
+ static_assert((std::is_same<C::const_reference, const std::pair<const int, double>&>::value), "");
+ static_assert((std::is_same<C::pointer, std::pair<const int, double>*>::value), "");
+ static_assert((std::is_same<C::const_pointer, const std::pair<const int, double>*>::value), "");
+ static_assert((std::is_same<C::size_type, std::size_t>::value), "");
+ static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> C;
+ static_assert((std::is_same<C::key_type, int>::value), "");
+ static_assert((std::is_same<C::mapped_type, double>::value), "");
+ static_assert((std::is_same<C::value_type, std::pair<const int, double> >::value), "");
+ static_assert((std::is_same<C::key_compare, std::less<int> >::value), "");
+ static_assert((std::is_same<C::allocator_type, min_allocator<std::pair<const int, double> > >::value), "");
+ static_assert((std::is_same<C::reference, std::pair<const int, double>&>::value), "");
+ static_assert((std::is_same<C::const_reference, const std::pair<const int, double>&>::value), "");
+ static_assert((std::is_same<C::pointer, min_pointer<std::pair<const int, double>>>::value), "");
+ static_assert((std::is_same<C::const_pointer, min_pointer<const std::pair<const int, double>>>::value), "");
+// min_allocator doesn't have a size_type, so one gets synthesized
+ static_assert((std::is_same<C::size_type, std::make_unsigned<C::difference_type>::type>::value), "");
+ static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
+ }
+#endif
+}
diff --git a/test/std/containers/associative/map/version.pass.cpp b/test/std/containers/associative/map/version.pass.cpp
new file mode 100644
index 000000000000..b2e3fa43e787
--- /dev/null
+++ b/test/std/containers/associative/map/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+#include <map>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/containers/associative/multimap/empty.pass.cpp b/test/std/containers/associative/multimap/empty.pass.cpp
new file mode 100644
index 000000000000..2384960d10db
--- /dev/null
+++ b/test/std/containers/associative/multimap/empty.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// bool empty() const;
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::multimap<int, double> M;
+ M m;
+ assert(m.empty());
+ m.insert(M::value_type(1, 1.5));
+ assert(!m.empty());
+ m.clear();
+ assert(m.empty());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+ M m;
+ assert(m.empty());
+ m.insert(M::value_type(1, 1.5));
+ assert(!m.empty());
+ m.clear();
+ assert(m.empty());
+ }
+#endif
+}
diff --git a/test/std/containers/associative/multimap/iterator.pass.cpp b/test/std/containers/associative/multimap/iterator.pass.cpp
new file mode 100644
index 000000000000..2763129acc2a
--- /dev/null
+++ b/test/std/containers/associative/multimap/iterator.pass.cpp
@@ -0,0 +1,231 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// iterator begin();
+// const_iterator begin() const;
+// iterator end();
+// const_iterator end() const;
+//
+// reverse_iterator rbegin();
+// const_reverse_iterator rbegin() const;
+// reverse_iterator rend();
+// const_reverse_iterator rend() const;
+//
+// const_iterator cbegin() const;
+// const_iterator cend() const;
+// const_reverse_iterator crbegin() const;
+// const_reverse_iterator crend() const;
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ V(4, 1),
+ V(4, 1.5),
+ V(4, 2),
+ V(5, 1),
+ V(5, 1.5),
+ V(5, 2),
+ V(6, 1),
+ V(6, 1.5),
+ V(6, 2),
+ V(7, 1),
+ V(7, 1.5),
+ V(7, 2),
+ V(8, 1),
+ V(8, 1.5),
+ V(8, 2)
+ };
+ std::multimap<int, double> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ assert(std::distance(m.begin(), m.end()) == m.size());
+ assert(std::distance(m.rbegin(), m.rend()) == m.size());
+ std::multimap<int, double>::iterator i;
+ i = m.begin();
+ std::multimap<int, double>::const_iterator k = i;
+ assert(i == k);
+ for (int j = 1; j <= 8; ++j)
+ for (double d = 1; d <= 2; d += .5, ++i)
+ {
+ assert(i->first == j);
+ assert(i->second == d);
+ i->second = 2.5;
+ assert(i->second == 2.5);
+ }
+ }
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ V(4, 1),
+ V(4, 1.5),
+ V(4, 2),
+ V(5, 1),
+ V(5, 1.5),
+ V(5, 2),
+ V(6, 1),
+ V(6, 1.5),
+ V(6, 2),
+ V(7, 1),
+ V(7, 1.5),
+ V(7, 2),
+ V(8, 1),
+ V(8, 1.5),
+ V(8, 2)
+ };
+ const std::multimap<int, double> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ assert(std::distance(m.begin(), m.end()) == m.size());
+ assert(std::distance(m.cbegin(), m.cend()) == m.size());
+ assert(std::distance(m.rbegin(), m.rend()) == m.size());
+ assert(std::distance(m.crbegin(), m.crend()) == m.size());
+ std::multimap<int, double>::const_iterator i;
+ i = m.begin();
+ for (int j = 1; j <= 8; ++j)
+ for (double d = 1; d <= 2; d += .5, ++i)
+ {
+ assert(i->first == j);
+ assert(i->second == d);
+ }
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ V(4, 1),
+ V(4, 1.5),
+ V(4, 2),
+ V(5, 1),
+ V(5, 1.5),
+ V(5, 2),
+ V(6, 1),
+ V(6, 1.5),
+ V(6, 2),
+ V(7, 1),
+ V(7, 1.5),
+ V(7, 2),
+ V(8, 1),
+ V(8, 1.5),
+ V(8, 2)
+ };
+ std::multimap<int, double, std::less<int>, min_allocator<V>> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ assert(std::distance(m.begin(), m.end()) == m.size());
+ assert(std::distance(m.rbegin(), m.rend()) == m.size());
+ std::multimap<int, double, std::less<int>, min_allocator<V>>::iterator i;
+ i = m.begin();
+ std::multimap<int, double, std::less<int>, min_allocator<V>>::const_iterator k = i;
+ assert(i == k);
+ for (int j = 1; j <= 8; ++j)
+ for (double d = 1; d <= 2; d += .5, ++i)
+ {
+ assert(i->first == j);
+ assert(i->second == d);
+ i->second = 2.5;
+ assert(i->second == 2.5);
+ }
+ }
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ V(4, 1),
+ V(4, 1.5),
+ V(4, 2),
+ V(5, 1),
+ V(5, 1.5),
+ V(5, 2),
+ V(6, 1),
+ V(6, 1.5),
+ V(6, 2),
+ V(7, 1),
+ V(7, 1.5),
+ V(7, 2),
+ V(8, 1),
+ V(8, 1.5),
+ V(8, 2)
+ };
+ const std::multimap<int, double, std::less<int>, min_allocator<V>> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ assert(std::distance(m.begin(), m.end()) == m.size());
+ assert(std::distance(m.cbegin(), m.cend()) == m.size());
+ assert(std::distance(m.rbegin(), m.rend()) == m.size());
+ assert(std::distance(m.crbegin(), m.crend()) == m.size());
+ std::multimap<int, double, std::less<int>, min_allocator<V>>::const_iterator i;
+ i = m.begin();
+ for (int j = 1; j <= 8; ++j)
+ for (double d = 1; d <= 2; d += .5, ++i)
+ {
+ assert(i->first == j);
+ assert(i->second == d);
+ }
+ }
+#endif
+#if _LIBCPP_STD_VER > 11
+ { // N3644 testing
+ typedef std::multimap<int, double> C;
+ C::iterator ii1{}, ii2{};
+ C::iterator ii4 = ii1;
+ C::const_iterator cii{};
+ assert ( ii1 == ii2 );
+ assert ( ii1 == ii4 );
+
+ assert (!(ii1 != ii2 ));
+
+ assert ( (ii1 == cii ));
+ assert ( (cii == ii1 ));
+ assert (!(ii1 != cii ));
+ assert (!(cii != ii1 ));
+ }
+#endif
+}
diff --git a/test/std/containers/associative/multimap/max_size.pass.cpp b/test/std/containers/associative/multimap/max_size.pass.cpp
new file mode 100644
index 000000000000..ccd8b10638c1
--- /dev/null
+++ b/test/std/containers/associative/multimap/max_size.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// size_type max_size() const;
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::multimap<int, double> M;
+ M m;
+ assert(m.max_size() != 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+ M m;
+ assert(m.max_size() != 0);
+ }
+#endif
+}
diff --git a/test/std/containers/associative/multimap/multimap.cons/alloc.pass.cpp b/test/std/containers/associative/multimap/multimap.cons/alloc.pass.cpp
new file mode 100644
index 000000000000..87bf0447e5be
--- /dev/null
+++ b/test/std/containers/associative/multimap/multimap.cons/alloc.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// explicit multimap(const allocator_type& a);
+
+#include <map>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::less<int> C;
+ typedef test_allocator<std::pair<const int, double> > A;
+ std::multimap<int, double, C, A> m(A(5));
+ assert(m.empty());
+ assert(m.begin() == m.end());
+ assert(m.get_allocator() == A(5));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::less<int> C;
+ typedef min_allocator<std::pair<const int, double> > A;
+ std::multimap<int, double, C, A> m(A{});
+ assert(m.empty());
+ assert(m.begin() == m.end());
+ assert(m.get_allocator() == A());
+ }
+#endif
+}
diff --git a/test/std/containers/associative/multimap/multimap.cons/assign_initializer_list.pass.cpp b/test/std/containers/associative/multimap/multimap.cons/assign_initializer_list.pass.cpp
new file mode 100644
index 000000000000..0c8991832529
--- /dev/null
+++ b/test/std/containers/associative/multimap/multimap.cons/assign_initializer_list.pass.cpp
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// multimap& operator=(initializer_list<value_type> il);
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::multimap<int, double> C;
+ typedef C::value_type V;
+ C m = {{20, 1}};
+ m =
+ {
+ {1, 1},
+ {1, 1.5},
+ {1, 2},
+ {2, 1},
+ {2, 1.5},
+ {2, 2},
+ {3, 1},
+ {3, 1.5},
+ {3, 2}
+ };
+ assert(m.size() == 9);
+ assert(distance(m.begin(), m.end()) == 9);
+ C::const_iterator i = m.cbegin();
+ assert(*i == V(1, 1));
+ assert(*++i == V(1, 1.5));
+ assert(*++i == V(1, 2));
+ assert(*++i == V(2, 1));
+ assert(*++i == V(2, 1.5));
+ assert(*++i == V(2, 2));
+ assert(*++i == V(3, 1));
+ assert(*++i == V(3, 1.5));
+ assert(*++i == V(3, 2));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> C;
+ typedef C::value_type V;
+ C m = {{20, 1}};
+ m =
+ {
+ {1, 1},
+ {1, 1.5},
+ {1, 2},
+ {2, 1},
+ {2, 1.5},
+ {2, 2},
+ {3, 1},
+ {3, 1.5},
+ {3, 2}
+ };
+ assert(m.size() == 9);
+ assert(distance(m.begin(), m.end()) == 9);
+ C::const_iterator i = m.cbegin();
+ assert(*i == V(1, 1));
+ assert(*++i == V(1, 1.5));
+ assert(*++i == V(1, 2));
+ assert(*++i == V(2, 1));
+ assert(*++i == V(2, 1.5));
+ assert(*++i == V(2, 2));
+ assert(*++i == V(3, 1));
+ assert(*++i == V(3, 1.5));
+ assert(*++i == V(3, 2));
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/containers/associative/multimap/multimap.cons/compare.pass.cpp b/test/std/containers/associative/multimap/multimap.cons/compare.pass.cpp
new file mode 100644
index 000000000000..9a4e0f987fd0
--- /dev/null
+++ b/test/std/containers/associative/multimap/multimap.cons/compare.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// explicit multimap(const key_compare& comp);
+
+#include <map>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef test_compare<std::less<int> > C;
+ std::multimap<int, double, C> m(C(3));
+ assert(m.empty());
+ assert(m.begin() == m.end());
+ assert(m.key_comp() == C(3));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef test_compare<std::less<int> > C;
+ std::multimap<int, double, C, min_allocator<std::pair<const int, double>>> m(C(3));
+ assert(m.empty());
+ assert(m.begin() == m.end());
+ assert(m.key_comp() == C(3));
+ }
+#endif
+}
diff --git a/test/std/containers/associative/multimap/multimap.cons/compare_alloc.pass.cpp b/test/std/containers/associative/multimap/multimap.cons/compare_alloc.pass.cpp
new file mode 100644
index 000000000000..1224884939cf
--- /dev/null
+++ b/test/std/containers/associative/multimap/multimap.cons/compare_alloc.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// multimap(const key_compare& comp, const allocator_type& a);
+
+#include <map>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef test_compare<std::less<int> > C;
+ typedef test_allocator<std::pair<const int, double> > A;
+ std::multimap<int, double, C, A> m(C(4), A(5));
+ assert(m.empty());
+ assert(m.begin() == m.end());
+ assert(m.key_comp() == C(4));
+ assert(m.get_allocator() == A(5));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef test_compare<std::less<int> > C;
+ typedef min_allocator<std::pair<const int, double> > A;
+ std::multimap<int, double, C, A> m(C(4), A());
+ assert(m.empty());
+ assert(m.begin() == m.end());
+ assert(m.key_comp() == C(4));
+ assert(m.get_allocator() == A());
+ }
+#endif
+}
diff --git a/test/std/containers/associative/multimap/multimap.cons/copy.pass.cpp b/test/std/containers/associative/multimap/multimap.cons/copy.pass.cpp
new file mode 100644
index 000000000000..3d6626eaadbb
--- /dev/null
+++ b/test/std/containers/associative/multimap/multimap.cons/copy.pass.cpp
@@ -0,0 +1,104 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// multimap(const multimap& m);
+
+#include <map>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ };
+ typedef test_compare<std::less<int> > C;
+ typedef test_allocator<V> A;
+ std::multimap<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
+ std::multimap<int, double, C, A> m = mo;
+ assert(m == mo);
+ assert(m.get_allocator() == A(7));
+ assert(m.key_comp() == C(5));
+
+ assert(mo.get_allocator() == A(7));
+ assert(mo.key_comp() == C(5));
+ }
+#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ };
+ typedef test_compare<std::less<int> > C;
+ typedef other_allocator<V> A;
+ std::multimap<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
+ std::multimap<int, double, C, A> m = mo;
+ assert(m == mo);
+ assert(m.get_allocator() == A(-2));
+ assert(m.key_comp() == C(5));
+
+ assert(mo.get_allocator() == A(7));
+ assert(mo.key_comp() == C(5));
+ }
+#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ };
+ typedef test_compare<std::less<int> > C;
+ typedef min_allocator<V> A;
+ std::multimap<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A());
+ std::multimap<int, double, C, A> m = mo;
+ assert(m == mo);
+ assert(m.get_allocator() == A());
+ assert(m.key_comp() == C(5));
+
+ assert(mo.get_allocator() == A());
+ assert(mo.key_comp() == C(5));
+ }
+#endif
+}
diff --git a/test/std/containers/associative/multimap/multimap.cons/copy_alloc.pass.cpp b/test/std/containers/associative/multimap/multimap.cons/copy_alloc.pass.cpp
new file mode 100644
index 000000000000..22594e32d718
--- /dev/null
+++ b/test/std/containers/associative/multimap/multimap.cons/copy_alloc.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// multimap(const multimap& m, const allocator_type& a);
+
+#include <map>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ };
+ typedef test_compare<std::less<int> > C;
+ typedef test_allocator<V> A;
+ std::multimap<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
+ std::multimap<int, double, C, A> m(mo, A(3));
+ assert(m == mo);
+ assert(m.get_allocator() == A(3));
+ assert(m.key_comp() == C(5));
+
+ assert(mo.get_allocator() == A(7));
+ assert(mo.key_comp() == C(5));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ };
+ typedef test_compare<std::less<int> > C;
+ typedef min_allocator<V> A;
+ std::multimap<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A());
+ std::multimap<int, double, C, A> m(mo, A());
+ assert(m == mo);
+ assert(m.get_allocator() == A());
+ assert(m.key_comp() == C(5));
+
+ assert(mo.get_allocator() == A());
+ assert(mo.key_comp() == C(5));
+ }
+#endif
+}
diff --git a/test/std/containers/associative/multimap/multimap.cons/copy_assign.pass.cpp b/test/std/containers/associative/multimap/multimap.cons/copy_assign.pass.cpp
new file mode 100644
index 000000000000..2bdc4d6a70ab
--- /dev/null
+++ b/test/std/containers/associative/multimap/multimap.cons/copy_assign.pass.cpp
@@ -0,0 +1,125 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// multimap& operator=(const multimap& m);
+
+#include <map>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ };
+ typedef test_compare<std::less<int> > C;
+ typedef test_allocator<V> A;
+ std::multimap<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(2));
+ std::multimap<int, double, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0])/2, C(3), A(7));
+ m = mo;
+ assert(m == mo);
+ assert(m.get_allocator() == A(7));
+ assert(m.key_comp() == C(5));
+
+ assert(mo.get_allocator() == A(2));
+ assert(mo.key_comp() == C(5));
+ }
+ {
+ typedef std::pair<const int, double> V;
+ const V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ };
+ std::multimap<int, double> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ std::multimap<int, double> *p = &m;
+ m = *p;
+ assert(m.size() == sizeof(ar)/sizeof(ar[0]));
+ assert(std::equal(m.begin(), m.end(), ar));
+ }
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ };
+ typedef test_compare<std::less<int> > C;
+ typedef other_allocator<V> A;
+ std::multimap<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(2));
+ std::multimap<int, double, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0])/2, C(3), A(7));
+ m = mo;
+ assert(m == mo);
+ assert(m.get_allocator() == A(2));
+ assert(m.key_comp() == C(5));
+
+ assert(mo.get_allocator() == A(2));
+ assert(mo.key_comp() == C(5));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ };
+ typedef test_compare<std::less<int> > C;
+ typedef min_allocator<V> A;
+ std::multimap<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A());
+ std::multimap<int, double, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0])/2, C(3), A());
+ m = mo;
+ assert(m == mo);
+ assert(m.get_allocator() == A());
+ assert(m.key_comp() == C(5));
+
+ assert(mo.get_allocator() == A());
+ assert(mo.key_comp() == C(5));
+ }
+#endif
+}
diff --git a/test/std/containers/associative/multimap/multimap.cons/default.pass.cpp b/test/std/containers/associative/multimap/multimap.cons/default.pass.cpp
new file mode 100644
index 000000000000..1c3ab8ce6c4b
--- /dev/null
+++ b/test/std/containers/associative/multimap/multimap.cons/default.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// multimap();
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::multimap<int, double> m;
+ assert(m.empty());
+ assert(m.begin() == m.end());
+ }
+#if __cplusplus >= 201103L
+ {
+ std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> m;
+ assert(m.empty());
+ assert(m.begin() == m.end());
+ }
+ {
+ std::multimap<int, double> m = {};
+ assert(m.empty());
+ assert(m.begin() == m.end());
+ }
+#endif
+}
diff --git a/test/std/containers/associative/multimap/multimap.cons/default_noexcept.pass.cpp b/test/std/containers/associative/multimap/multimap.cons/default_noexcept.pass.cpp
new file mode 100644
index 000000000000..d1db40b1fc7a
--- /dev/null
+++ b/test/std/containers/associative/multimap/multimap.cons/default_noexcept.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// multimap()
+// noexcept(
+// is_nothrow_default_constructible<allocator_type>::value &&
+// is_nothrow_default_constructible<key_compare>::value &&
+// is_nothrow_copy_constructible<key_compare>::value);
+
+// This tests a conforming extension
+
+#include <map>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_comp
+{
+ typedef T value_type;
+ some_comp();
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::multimap<MoveOnly, MoveOnly> C;
+ static_assert(std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C;
+ static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::multimap<MoveOnly, MoveOnly, some_comp<MoveOnly>> C;
+ static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+ }
+#endif
+}
diff --git a/test/std/containers/associative/multimap/multimap.cons/default_recursive.pass.cpp b/test/std/containers/associative/multimap/multimap.cons/default_recursive.pass.cpp
new file mode 100644
index 000000000000..08ca8a441e3b
--- /dev/null
+++ b/test/std/containers/associative/multimap/multimap.cons/default_recursive.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// multimap();
+
+#include <map>
+
+struct X
+{
+ std::multimap<int, X> m;
+ std::multimap<int, X>::iterator i;
+ std::multimap<int, X>::const_iterator ci;
+ std::multimap<int, X>::reverse_iterator ri;
+ std::multimap<int, X>::const_reverse_iterator cri;
+};
+
+int main()
+{
+}
diff --git a/test/std/containers/associative/multimap/multimap.cons/dtor_noexcept.pass.cpp b/test/std/containers/associative/multimap/multimap.cons/dtor_noexcept.pass.cpp
new file mode 100644
index 000000000000..cb55e3fb33ec
--- /dev/null
+++ b/test/std/containers/associative/multimap/multimap.cons/dtor_noexcept.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// ~multimap() // implied noexcept;
+
+#include <map>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "test_allocator.h"
+
+#if __has_feature(cxx_noexcept)
+
+template <class T>
+struct some_comp
+{
+ typedef T value_type;
+ ~some_comp() noexcept(false);
+};
+
+#endif
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::multimap<MoveOnly, MoveOnly> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::multimap<MoveOnly, MoveOnly, some_comp<MoveOnly>> C;
+ static_assert(!std::is_nothrow_destructible<C>::value, "");
+ }
+#endif
+}
diff --git a/test/std/containers/associative/multimap/multimap.cons/initializer_list.pass.cpp b/test/std/containers/associative/multimap/multimap.cons/initializer_list.pass.cpp
new file mode 100644
index 000000000000..937a202a55ea
--- /dev/null
+++ b/test/std/containers/associative/multimap/multimap.cons/initializer_list.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// multimap(initializer_list<value_type> il, const key_compare& comp = key_compare());
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::multimap<int, double> C;
+ typedef C::value_type V;
+ C m =
+ {
+ {1, 1},
+ {1, 1.5},
+ {1, 2},
+ {2, 1},
+ {2, 1.5},
+ {2, 2},
+ {3, 1},
+ {3, 1.5},
+ {3, 2}
+ };
+ assert(m.size() == 9);
+ assert(distance(m.begin(), m.end()) == 9);
+ C::const_iterator i = m.cbegin();
+ assert(*i == V(1, 1));
+ assert(*++i == V(1, 1.5));
+ assert(*++i == V(1, 2));
+ assert(*++i == V(2, 1));
+ assert(*++i == V(2, 1.5));
+ assert(*++i == V(2, 2));
+ assert(*++i == V(3, 1));
+ assert(*++i == V(3, 1.5));
+ assert(*++i == V(3, 2));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> C;
+ typedef C::value_type V;
+ C m =
+ {
+ {1, 1},
+ {1, 1.5},
+ {1, 2},
+ {2, 1},
+ {2, 1.5},
+ {2, 2},
+ {3, 1},
+ {3, 1.5},
+ {3, 2}
+ };
+ assert(m.size() == 9);
+ assert(distance(m.begin(), m.end()) == 9);
+ C::const_iterator i = m.cbegin();
+ assert(*i == V(1, 1));
+ assert(*++i == V(1, 1.5));
+ assert(*++i == V(1, 2));
+ assert(*++i == V(2, 1));
+ assert(*++i == V(2, 1.5));
+ assert(*++i == V(2, 2));
+ assert(*++i == V(3, 1));
+ assert(*++i == V(3, 1.5));
+ assert(*++i == V(3, 2));
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/containers/associative/multimap/multimap.cons/initializer_list_compare.pass.cpp b/test/std/containers/associative/multimap/multimap.cons/initializer_list_compare.pass.cpp
new file mode 100644
index 000000000000..e6677039c90c
--- /dev/null
+++ b/test/std/containers/associative/multimap/multimap.cons/initializer_list_compare.pass.cpp
@@ -0,0 +1,91 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// multimap(initializer_list<value_type> il, const key_compare& comp = key_compare());
+
+#include <map>
+#include <cassert>
+#include "../../../test_compare.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef test_compare<std::less<int> > Cmp;
+ typedef std::multimap<int, double, Cmp> C;
+ typedef C::value_type V;
+ C m(
+ {
+ {1, 1},
+ {1, 1.5},
+ {1, 2},
+ {2, 1},
+ {2, 1.5},
+ {2, 2},
+ {3, 1},
+ {3, 1.5},
+ {3, 2}
+ },
+ Cmp(4)
+ );
+ assert(m.size() == 9);
+ assert(distance(m.begin(), m.end()) == 9);
+ C::const_iterator i = m.cbegin();
+ assert(*i == V(1, 1));
+ assert(*++i == V(1, 1.5));
+ assert(*++i == V(1, 2));
+ assert(*++i == V(2, 1));
+ assert(*++i == V(2, 1.5));
+ assert(*++i == V(2, 2));
+ assert(*++i == V(3, 1));
+ assert(*++i == V(3, 1.5));
+ assert(*++i == V(3, 2));
+ assert(m.key_comp() == Cmp(4));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef test_compare<std::less<int> > Cmp;
+ typedef std::multimap<int, double, Cmp, min_allocator<std::pair<const int, double>>> C;
+ typedef C::value_type V;
+ C m(
+ {
+ {1, 1},
+ {1, 1.5},
+ {1, 2},
+ {2, 1},
+ {2, 1.5},
+ {2, 2},
+ {3, 1},
+ {3, 1.5},
+ {3, 2}
+ },
+ Cmp(4)
+ );
+ assert(m.size() == 9);
+ assert(distance(m.begin(), m.end()) == 9);
+ C::const_iterator i = m.cbegin();
+ assert(*i == V(1, 1));
+ assert(*++i == V(1, 1.5));
+ assert(*++i == V(1, 2));
+ assert(*++i == V(2, 1));
+ assert(*++i == V(2, 1.5));
+ assert(*++i == V(2, 2));
+ assert(*++i == V(3, 1));
+ assert(*++i == V(3, 1.5));
+ assert(*++i == V(3, 2));
+ assert(m.key_comp() == Cmp(4));
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/containers/associative/multimap/multimap.cons/initializer_list_compare_alloc.pass.cpp b/test/std/containers/associative/multimap/multimap.cons/initializer_list_compare_alloc.pass.cpp
new file mode 100644
index 000000000000..0e73f72793e5
--- /dev/null
+++ b/test/std/containers/associative/multimap/multimap.cons/initializer_list_compare_alloc.pass.cpp
@@ -0,0 +1,129 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// multimap(initializer_list<value_type> il, const key_compare& comp, const allocator_type& a);
+
+#include <map>
+#include <cassert>
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef test_compare<std::less<int> > Cmp;
+ typedef test_allocator<std::pair<const int, double> > A;
+ typedef std::multimap<int, double, Cmp, A> C;
+ typedef C::value_type V;
+ C m(
+ {
+ {1, 1},
+ {1, 1.5},
+ {1, 2},
+ {2, 1},
+ {2, 1.5},
+ {2, 2},
+ {3, 1},
+ {3, 1.5},
+ {3, 2}
+ },
+ Cmp(4), A(5)
+ );
+ assert(m.size() == 9);
+ assert(distance(m.begin(), m.end()) == 9);
+ C::const_iterator i = m.cbegin();
+ assert(*i == V(1, 1));
+ assert(*++i == V(1, 1.5));
+ assert(*++i == V(1, 2));
+ assert(*++i == V(2, 1));
+ assert(*++i == V(2, 1.5));
+ assert(*++i == V(2, 2));
+ assert(*++i == V(3, 1));
+ assert(*++i == V(3, 1.5));
+ assert(*++i == V(3, 2));
+ assert(m.key_comp() == Cmp(4));
+ assert(m.get_allocator() == A(5));
+ }
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+#if __cplusplus >= 201103L
+ {
+ typedef test_compare<std::less<int> > Cmp;
+ typedef min_allocator<std::pair<const int, double> > A;
+ typedef std::multimap<int, double, Cmp, A> C;
+ typedef C::value_type V;
+ C m(
+ {
+ {1, 1},
+ {1, 1.5},
+ {1, 2},
+ {2, 1},
+ {2, 1.5},
+ {2, 2},
+ {3, 1},
+ {3, 1.5},
+ {3, 2}
+ },
+ Cmp(4), A()
+ );
+ assert(m.size() == 9);
+ assert(distance(m.begin(), m.end()) == 9);
+ C::const_iterator i = m.cbegin();
+ assert(*i == V(1, 1));
+ assert(*++i == V(1, 1.5));
+ assert(*++i == V(1, 2));
+ assert(*++i == V(2, 1));
+ assert(*++i == V(2, 1.5));
+ assert(*++i == V(2, 2));
+ assert(*++i == V(3, 1));
+ assert(*++i == V(3, 1.5));
+ assert(*++i == V(3, 2));
+ assert(m.key_comp() == Cmp(4));
+ assert(m.get_allocator() == A());
+ }
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef test_compare<std::less<int> > C;
+ typedef std::pair<const int, double> V;
+ typedef min_allocator<V> A;
+ typedef std::multimap<int, double, C, A> M;
+ A a;
+ M m ({ {1, 1},
+ {1, 1.5},
+ {1, 2},
+ {2, 1},
+ {2, 1.5},
+ {2, 2},
+ {3, 1},
+ {3, 1.5},
+ {3, 2}
+ }, a);
+
+ assert(m.size() == 9);
+ assert(distance(m.begin(), m.end()) == 9);
+ M::const_iterator i = m.cbegin();
+ assert(*i == V(1, 1));
+ assert(*++i == V(1, 1.5));
+ assert(*++i == V(1, 2));
+ assert(*++i == V(2, 1));
+ assert(*++i == V(2, 1.5));
+ assert(*++i == V(2, 2));
+ assert(*++i == V(3, 1));
+ assert(*++i == V(3, 1.5));
+ assert(*++i == V(3, 2));
+ assert(m.get_allocator() == a);
+ }
+#endif
+#endif
+}
diff --git a/test/std/containers/associative/multimap/multimap.cons/iter_iter.pass.cpp b/test/std/containers/associative/multimap/multimap.cons/iter_iter.pass.cpp
new file mode 100644
index 000000000000..fa062e2be0b8
--- /dev/null
+++ b/test/std/containers/associative/multimap/multimap.cons/iter_iter.pass.cpp
@@ -0,0 +1,112 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// template <class InputIterator>
+// multimap(InputIterator first, InputIterator last);
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ };
+ std::multimap<int, double> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 9);
+ assert(distance(m.begin(), m.end()) == 9);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(1, 1.5));
+ assert(*next(m.begin(), 2) == V(1, 2));
+ assert(*next(m.begin(), 3) == V(2, 1));
+ assert(*next(m.begin(), 4) == V(2, 1.5));
+ assert(*next(m.begin(), 5) == V(2, 2));
+ assert(*next(m.begin(), 6) == V(3, 1));
+ assert(*next(m.begin(), 7) == V(3, 1.5));
+ assert(*next(m.begin(), 8) == V(3, 2));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ };
+ std::multimap<int, double, std::less<int>, min_allocator<V>> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 9);
+ assert(distance(m.begin(), m.end()) == 9);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(1, 1.5));
+ assert(*next(m.begin(), 2) == V(1, 2));
+ assert(*next(m.begin(), 3) == V(2, 1));
+ assert(*next(m.begin(), 4) == V(2, 1.5));
+ assert(*next(m.begin(), 5) == V(2, 2));
+ assert(*next(m.begin(), 6) == V(3, 1));
+ assert(*next(m.begin(), 7) == V(3, 1.5));
+ assert(*next(m.begin(), 8) == V(3, 2));
+ }
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ };
+ typedef min_allocator<std::pair<const int, double>> A;
+ A a;
+ std::multimap<int, double, std::less<int>, A> m(ar, ar+sizeof(ar)/sizeof(ar[0]), a);
+ assert(m.size() == 9);
+ assert(distance(m.begin(), m.end()) == 9);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(1, 1.5));
+ assert(*next(m.begin(), 2) == V(1, 2));
+ assert(*next(m.begin(), 3) == V(2, 1));
+ assert(*next(m.begin(), 4) == V(2, 1.5));
+ assert(*next(m.begin(), 5) == V(2, 2));
+ assert(*next(m.begin(), 6) == V(3, 1));
+ assert(*next(m.begin(), 7) == V(3, 1.5));
+ assert(*next(m.begin(), 8) == V(3, 2));
+ assert(m.get_allocator() == a);
+ }
+#endif
+#endif
+}
diff --git a/test/std/containers/associative/multimap/multimap.cons/iter_iter_comp.pass.cpp b/test/std/containers/associative/multimap/multimap.cons/iter_iter_comp.pass.cpp
new file mode 100644
index 000000000000..d6de59428dd6
--- /dev/null
+++ b/test/std/containers/associative/multimap/multimap.cons/iter_iter_comp.pass.cpp
@@ -0,0 +1,86 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// template <class InputIterator>
+// multimap(InputIterator first, InputIterator last,
+// const key_compare& comp);
+
+#include <map>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ };
+ typedef test_compare<std::less<int> > C;
+ std::multimap<int, double, C> m(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5));
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 9);
+ assert(distance(m.begin(), m.end()) == 9);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(1, 1.5));
+ assert(*next(m.begin(), 2) == V(1, 2));
+ assert(*next(m.begin(), 3) == V(2, 1));
+ assert(*next(m.begin(), 4) == V(2, 1.5));
+ assert(*next(m.begin(), 5) == V(2, 2));
+ assert(*next(m.begin(), 6) == V(3, 1));
+ assert(*next(m.begin(), 7) == V(3, 1.5));
+ assert(*next(m.begin(), 8) == V(3, 2));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ };
+ typedef test_compare<std::less<int> > C;
+ std::multimap<int, double, C, min_allocator<V>> m(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5));
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 9);
+ assert(distance(m.begin(), m.end()) == 9);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(1, 1.5));
+ assert(*next(m.begin(), 2) == V(1, 2));
+ assert(*next(m.begin(), 3) == V(2, 1));
+ assert(*next(m.begin(), 4) == V(2, 1.5));
+ assert(*next(m.begin(), 5) == V(2, 2));
+ assert(*next(m.begin(), 6) == V(3, 1));
+ assert(*next(m.begin(), 7) == V(3, 1.5));
+ assert(*next(m.begin(), 8) == V(3, 2));
+ }
+#endif
+}
diff --git a/test/std/containers/associative/multimap/multimap.cons/iter_iter_comp_alloc.pass.cpp b/test/std/containers/associative/multimap/multimap.cons/iter_iter_comp_alloc.pass.cpp
new file mode 100644
index 000000000000..259fbd145ff6
--- /dev/null
+++ b/test/std/containers/associative/multimap/multimap.cons/iter_iter_comp_alloc.pass.cpp
@@ -0,0 +1,91 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// template <class InputIterator>
+// multimap(InputIterator first, InputIterator last,
+// const key_compare& comp, const allocator_type& a);
+
+#include <map>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ };
+ typedef test_compare<std::less<int> > C;
+ typedef test_allocator<V> A;
+ std::multimap<int, double, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
+ assert(m.get_allocator() == A(7));
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 9);
+ assert(distance(m.begin(), m.end()) == 9);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(1, 1.5));
+ assert(*next(m.begin(), 2) == V(1, 2));
+ assert(*next(m.begin(), 3) == V(2, 1));
+ assert(*next(m.begin(), 4) == V(2, 1.5));
+ assert(*next(m.begin(), 5) == V(2, 2));
+ assert(*next(m.begin(), 6) == V(3, 1));
+ assert(*next(m.begin(), 7) == V(3, 1.5));
+ assert(*next(m.begin(), 8) == V(3, 2));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ };
+ typedef test_compare<std::less<int> > C;
+ typedef min_allocator<V> A;
+ std::multimap<int, double, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A());
+ assert(m.get_allocator() == A());
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 9);
+ assert(distance(m.begin(), m.end()) == 9);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(1, 1.5));
+ assert(*next(m.begin(), 2) == V(1, 2));
+ assert(*next(m.begin(), 3) == V(2, 1));
+ assert(*next(m.begin(), 4) == V(2, 1.5));
+ assert(*next(m.begin(), 5) == V(2, 2));
+ assert(*next(m.begin(), 6) == V(3, 1));
+ assert(*next(m.begin(), 7) == V(3, 1.5));
+ assert(*next(m.begin(), 8) == V(3, 2));
+ }
+#endif
+}
diff --git a/test/std/containers/associative/multimap/multimap.cons/move.pass.cpp b/test/std/containers/associative/multimap/multimap.cons/move.pass.cpp
new file mode 100644
index 000000000000..aed08867c3cc
--- /dev/null
+++ b/test/std/containers/associative/multimap/multimap.cons/move.pass.cpp
@@ -0,0 +1,132 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// multimap(multimap&& m);
+
+#include <map>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ typedef std::pair<const int, double> V;
+ {
+ typedef test_compare<std::less<int> > C;
+ typedef test_allocator<V> A;
+ std::multimap<int, double, C, A> mo(C(5), A(7));
+ std::multimap<int, double, C, A> m = std::move(mo);
+ assert(m.get_allocator() == A(7));
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 0);
+ assert(distance(m.begin(), m.end()) == 0);
+
+ assert(mo.get_allocator() == A(7));
+ assert(mo.key_comp() == C(5));
+ assert(mo.size() == 0);
+ assert(distance(mo.begin(), mo.end()) == 0);
+ }
+ {
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ };
+ typedef test_compare<std::less<int> > C;
+ typedef test_allocator<V> A;
+ std::multimap<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
+ std::multimap<int, double, C, A> m = std::move(mo);
+ assert(m.get_allocator() == A(7));
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 9);
+ assert(distance(m.begin(), m.end()) == 9);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(1, 1.5));
+ assert(*next(m.begin(), 2) == V(1, 2));
+ assert(*next(m.begin(), 3) == V(2, 1));
+ assert(*next(m.begin(), 4) == V(2, 1.5));
+ assert(*next(m.begin(), 5) == V(2, 2));
+ assert(*next(m.begin(), 6) == V(3, 1));
+ assert(*next(m.begin(), 7) == V(3, 1.5));
+ assert(*next(m.begin(), 8) == V(3, 2));
+
+ assert(mo.get_allocator() == A(7));
+ assert(mo.key_comp() == C(5));
+ assert(mo.size() == 0);
+ assert(distance(mo.begin(), mo.end()) == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef test_compare<std::less<int> > C;
+ typedef min_allocator<V> A;
+ std::multimap<int, double, C, A> mo(C(5), A());
+ std::multimap<int, double, C, A> m = std::move(mo);
+ assert(m.get_allocator() == A());
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 0);
+ assert(distance(m.begin(), m.end()) == 0);
+
+ assert(mo.get_allocator() == A());
+ assert(mo.key_comp() == C(5));
+ assert(mo.size() == 0);
+ assert(distance(mo.begin(), mo.end()) == 0);
+ }
+ {
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ };
+ typedef test_compare<std::less<int> > C;
+ typedef min_allocator<V> A;
+ std::multimap<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A());
+ std::multimap<int, double, C, A> m = std::move(mo);
+ assert(m.get_allocator() == A());
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 9);
+ assert(distance(m.begin(), m.end()) == 9);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(1, 1.5));
+ assert(*next(m.begin(), 2) == V(1, 2));
+ assert(*next(m.begin(), 3) == V(2, 1));
+ assert(*next(m.begin(), 4) == V(2, 1.5));
+ assert(*next(m.begin(), 5) == V(2, 2));
+ assert(*next(m.begin(), 6) == V(3, 1));
+ assert(*next(m.begin(), 7) == V(3, 1.5));
+ assert(*next(m.begin(), 8) == V(3, 2));
+
+ assert(mo.get_allocator() == A());
+ assert(mo.key_comp() == C(5));
+ assert(mo.size() == 0);
+ assert(distance(mo.begin(), mo.end()) == 0);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/associative/multimap/multimap.cons/move_alloc.pass.cpp b/test/std/containers/associative/multimap/multimap.cons/move_alloc.pass.cpp
new file mode 100644
index 000000000000..3ec79eea3554
--- /dev/null
+++ b/test/std/containers/associative/multimap/multimap.cons/move_alloc.pass.cpp
@@ -0,0 +1,234 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// multimap(multimap&& m, const allocator_type& a);
+
+#include <map>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+#include "Counter.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::pair<MoveOnly, MoveOnly> V;
+ typedef std::pair<const MoveOnly, MoveOnly> VC;
+ typedef test_compare<std::less<MoveOnly> > C;
+ typedef test_allocator<VC> A;
+ typedef std::multimap<MoveOnly, MoveOnly, C, A> M;
+ typedef std::move_iterator<V*> I;
+ V a1[] =
+ {
+ V(1, 1),
+ V(1, 2),
+ V(1, 3),
+ V(2, 1),
+ V(2, 2),
+ V(2, 3),
+ V(3, 1),
+ V(3, 2),
+ V(3, 3)
+ };
+ M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+ V a2[] =
+ {
+ V(1, 1),
+ V(1, 2),
+ V(1, 3),
+ V(2, 1),
+ V(2, 2),
+ V(2, 3),
+ V(3, 1),
+ V(3, 2),
+ V(3, 3)
+ };
+ M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+ M m3(std::move(m1), A(7));
+ assert(m3 == m2);
+ assert(m3.get_allocator() == A(7));
+ assert(m3.key_comp() == C(5));
+ assert(m1.empty());
+ }
+ {
+ typedef std::pair<MoveOnly, MoveOnly> V;
+ typedef std::pair<const MoveOnly, MoveOnly> VC;
+ typedef test_compare<std::less<MoveOnly> > C;
+ typedef test_allocator<VC> A;
+ typedef std::multimap<MoveOnly, MoveOnly, C, A> M;
+ typedef std::move_iterator<V*> I;
+ V a1[] =
+ {
+ V(1, 1),
+ V(1, 2),
+ V(1, 3),
+ V(2, 1),
+ V(2, 2),
+ V(2, 3),
+ V(3, 1),
+ V(3, 2),
+ V(3, 3)
+ };
+ M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+ V a2[] =
+ {
+ V(1, 1),
+ V(1, 2),
+ V(1, 3),
+ V(2, 1),
+ V(2, 2),
+ V(2, 3),
+ V(3, 1),
+ V(3, 2),
+ V(3, 3)
+ };
+ M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+ M m3(std::move(m1), A(5));
+ assert(m3 == m2);
+ assert(m3.get_allocator() == A(5));
+ assert(m3.key_comp() == C(5));
+ assert(m1.empty());
+ }
+ {
+ typedef std::pair<MoveOnly, MoveOnly> V;
+ typedef std::pair<const MoveOnly, MoveOnly> VC;
+ typedef test_compare<std::less<MoveOnly> > C;
+ typedef other_allocator<VC> A;
+ typedef std::multimap<MoveOnly, MoveOnly, C, A> M;
+ typedef std::move_iterator<V*> I;
+ V a1[] =
+ {
+ V(1, 1),
+ V(1, 2),
+ V(1, 3),
+ V(2, 1),
+ V(2, 2),
+ V(2, 3),
+ V(3, 1),
+ V(3, 2),
+ V(3, 3)
+ };
+ M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+ V a2[] =
+ {
+ V(1, 1),
+ V(1, 2),
+ V(1, 3),
+ V(2, 1),
+ V(2, 2),
+ V(2, 3),
+ V(3, 1),
+ V(3, 2),
+ V(3, 3)
+ };
+ M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+ M m3(std::move(m1), A(5));
+ assert(m3 == m2);
+ assert(m3.get_allocator() == A(5));
+ assert(m3.key_comp() == C(5));
+ assert(m1.empty());
+ }
+ {
+ typedef Counter<int> T;
+ typedef std::pair<int, T> V;
+ typedef std::pair<const int, T> VC;
+ typedef test_allocator<VC> A;
+ typedef std::less<int> C;
+ typedef std::multimap<const int, T, C, A> M;
+ typedef V* I;
+ Counter_base::gConstructed = 0;
+ {
+ V a1[] =
+ {
+ V(1, 1),
+ V(1, 2),
+ V(1, 3),
+ V(2, 1),
+ V(2, 2),
+ V(2, 3),
+ V(3, 1),
+ V(3, 2),
+ V(3, 3)
+ };
+ const size_t num = sizeof(a1)/sizeof(a1[0]);
+ assert(Counter_base::gConstructed == num);
+
+ M m1(I(a1), I(a1+num), C(), A());
+ assert(Counter_base::gConstructed == 2*num);
+
+ M m2(m1);
+ assert(m2 == m1);
+ assert(Counter_base::gConstructed == 3*num);
+
+ M m3(std::move(m1), A());
+ assert(m3 == m2);
+ assert(m1.empty());
+ assert(Counter_base::gConstructed == 3*num);
+
+ {
+ M m4(std::move(m2), A(5));
+ assert(Counter_base::gConstructed == 3*num);
+ assert(m4 == m3);
+ assert(m2.empty());
+ }
+ assert(Counter_base::gConstructed == 2*num);
+ }
+ assert(Counter_base::gConstructed == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<MoveOnly, MoveOnly> V;
+ typedef std::pair<const MoveOnly, MoveOnly> VC;
+ typedef test_compare<std::less<MoveOnly> > C;
+ typedef min_allocator<VC> A;
+ typedef std::multimap<MoveOnly, MoveOnly, C, A> M;
+ typedef std::move_iterator<V*> I;
+ V a1[] =
+ {
+ V(1, 1),
+ V(1, 2),
+ V(1, 3),
+ V(2, 1),
+ V(2, 2),
+ V(2, 3),
+ V(3, 1),
+ V(3, 2),
+ V(3, 3)
+ };
+ M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A());
+ V a2[] =
+ {
+ V(1, 1),
+ V(1, 2),
+ V(1, 3),
+ V(2, 1),
+ V(2, 2),
+ V(2, 3),
+ V(3, 1),
+ V(3, 2),
+ V(3, 3)
+ };
+ M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A());
+ M m3(std::move(m1), A());
+ assert(m3 == m2);
+ assert(m3.get_allocator() == A());
+ assert(m3.key_comp() == C(5));
+ assert(m1.empty());
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/associative/multimap/multimap.cons/move_assign.pass.cpp b/test/std/containers/associative/multimap/multimap.cons/move_assign.pass.cpp
new file mode 100644
index 000000000000..48854e388e10
--- /dev/null
+++ b/test/std/containers/associative/multimap/multimap.cons/move_assign.pass.cpp
@@ -0,0 +1,190 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// multimap& operator=(multimap&& m);
+
+#include <map>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::pair<MoveOnly, MoveOnly> V;
+ typedef std::pair<const MoveOnly, MoveOnly> VC;
+ typedef test_compare<std::less<MoveOnly> > C;
+ typedef test_allocator<VC> A;
+ typedef std::multimap<MoveOnly, MoveOnly, C, A> M;
+ typedef std::move_iterator<V*> I;
+ V a1[] =
+ {
+ V(1, 1),
+ V(1, 2),
+ V(1, 3),
+ V(2, 1),
+ V(2, 2),
+ V(2, 3),
+ V(3, 1),
+ V(3, 2),
+ V(3, 3)
+ };
+ M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+ V a2[] =
+ {
+ V(1, 1),
+ V(1, 2),
+ V(1, 3),
+ V(2, 1),
+ V(2, 2),
+ V(2, 3),
+ V(3, 1),
+ V(3, 2),
+ V(3, 3)
+ };
+ M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+ M m3(C(3), A(7));
+ m3 = std::move(m1);
+ assert(m3 == m2);
+ assert(m3.get_allocator() == A(7));
+ assert(m3.key_comp() == C(5));
+ assert(m1.empty());
+ }
+ {
+ typedef std::pair<MoveOnly, MoveOnly> V;
+ typedef std::pair<const MoveOnly, MoveOnly> VC;
+ typedef test_compare<std::less<MoveOnly> > C;
+ typedef test_allocator<VC> A;
+ typedef std::multimap<MoveOnly, MoveOnly, C, A> M;
+ typedef std::move_iterator<V*> I;
+ V a1[] =
+ {
+ V(1, 1),
+ V(1, 2),
+ V(1, 3),
+ V(2, 1),
+ V(2, 2),
+ V(2, 3),
+ V(3, 1),
+ V(3, 2),
+ V(3, 3)
+ };
+ M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+ V a2[] =
+ {
+ V(1, 1),
+ V(1, 2),
+ V(1, 3),
+ V(2, 1),
+ V(2, 2),
+ V(2, 3),
+ V(3, 1),
+ V(3, 2),
+ V(3, 3)
+ };
+ M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+ M m3(C(3), A(5));
+ m3 = std::move(m1);
+ assert(m3 == m2);
+ assert(m3.get_allocator() == A(5));
+ assert(m3.key_comp() == C(5));
+ assert(m1.empty());
+ }
+ {
+ typedef std::pair<MoveOnly, MoveOnly> V;
+ typedef std::pair<const MoveOnly, MoveOnly> VC;
+ typedef test_compare<std::less<MoveOnly> > C;
+ typedef other_allocator<VC> A;
+ typedef std::multimap<MoveOnly, MoveOnly, C, A> M;
+ typedef std::move_iterator<V*> I;
+ V a1[] =
+ {
+ V(1, 1),
+ V(1, 2),
+ V(1, 3),
+ V(2, 1),
+ V(2, 2),
+ V(2, 3),
+ V(3, 1),
+ V(3, 2),
+ V(3, 3)
+ };
+ M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+ V a2[] =
+ {
+ V(1, 1),
+ V(1, 2),
+ V(1, 3),
+ V(2, 1),
+ V(2, 2),
+ V(2, 3),
+ V(3, 1),
+ V(3, 2),
+ V(3, 3)
+ };
+ M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+ M m3(C(3), A(5));
+ m3 = std::move(m1);
+ assert(m3 == m2);
+ assert(m3.get_allocator() == A(7));
+ assert(m3.key_comp() == C(5));
+ assert(m1.empty());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<MoveOnly, MoveOnly> V;
+ typedef std::pair<const MoveOnly, MoveOnly> VC;
+ typedef test_compare<std::less<MoveOnly> > C;
+ typedef min_allocator<VC> A;
+ typedef std::multimap<MoveOnly, MoveOnly, C, A> M;
+ typedef std::move_iterator<V*> I;
+ V a1[] =
+ {
+ V(1, 1),
+ V(1, 2),
+ V(1, 3),
+ V(2, 1),
+ V(2, 2),
+ V(2, 3),
+ V(3, 1),
+ V(3, 2),
+ V(3, 3)
+ };
+ M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A());
+ V a2[] =
+ {
+ V(1, 1),
+ V(1, 2),
+ V(1, 3),
+ V(2, 1),
+ V(2, 2),
+ V(2, 3),
+ V(3, 1),
+ V(3, 2),
+ V(3, 3)
+ };
+ M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A());
+ M m3(C(3), A());
+ m3 = std::move(m1);
+ assert(m3 == m2);
+ assert(m3.get_allocator() == A());
+ assert(m3.key_comp() == C(5));
+ assert(m1.empty());
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/associative/multimap/multimap.cons/move_assign_noexcept.pass.cpp b/test/std/containers/associative/multimap/multimap.cons/move_assign_noexcept.pass.cpp
new file mode 100644
index 000000000000..8ad9e8b82fd1
--- /dev/null
+++ b/test/std/containers/associative/multimap/multimap.cons/move_assign_noexcept.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// multimap& operator=(multimap&& c)
+// noexcept(
+// allocator_type::propagate_on_container_move_assignment::value &&
+// is_nothrow_move_assignable<allocator_type>::value &&
+// is_nothrow_move_assignable<key_compare>::value);
+
+// This tests a conforming extension
+
+#include <map>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_comp
+{
+ typedef T value_type;
+ some_comp& operator=(const some_comp&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::multimap<MoveOnly, MoveOnly> C;
+ static_assert(std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::multimap<MoveOnly, MoveOnly, some_comp<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+ }
+#endif
+}
diff --git a/test/std/containers/associative/multimap/multimap.cons/move_noexcept.pass.cpp b/test/std/containers/associative/multimap/multimap.cons/move_noexcept.pass.cpp
new file mode 100644
index 000000000000..66ea8737fb75
--- /dev/null
+++ b/test/std/containers/associative/multimap/multimap.cons/move_noexcept.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// multimap(multimap&&)
+// noexcept(is_nothrow_move_constructible<allocator_type>::value &&
+// is_nothrow_move_constructible<key_compare>::value);
+
+// This tests a conforming extension
+
+#include <map>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_comp
+{
+ typedef T value_type;
+ some_comp(const some_comp&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::multimap<MoveOnly, MoveOnly> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::multimap<MoveOnly, MoveOnly, some_comp<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_constructible<C>::value, "");
+ }
+#endif
+}
diff --git a/test/std/containers/associative/multimap/multimap.modifiers/clear.pass.cpp b/test/std/containers/associative/multimap/multimap.modifiers/clear.pass.cpp
new file mode 100644
index 000000000000..fe9b8c8ba128
--- /dev/null
+++ b/test/std/containers/associative/multimap/multimap.modifiers/clear.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// void clear();
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::multimap<int, double> M;
+ typedef std::pair<int, double> P;
+ P ar[] =
+ {
+ P(1, 1.5),
+ P(2, 2.5),
+ P(3, 3.5),
+ P(4, 4.5),
+ P(5, 5.5),
+ P(6, 6.5),
+ P(7, 7.5),
+ P(8, 8.5),
+ };
+ M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 8);
+ m.clear();
+ assert(m.size() == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+ typedef std::pair<int, double> P;
+ P ar[] =
+ {
+ P(1, 1.5),
+ P(2, 2.5),
+ P(3, 3.5),
+ P(4, 4.5),
+ P(5, 5.5),
+ P(6, 6.5),
+ P(7, 7.5),
+ P(8, 8.5),
+ };
+ M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 8);
+ m.clear();
+ assert(m.size() == 0);
+ }
+#endif
+}
diff --git a/test/std/containers/associative/multimap/multimap.modifiers/emplace.pass.cpp b/test/std/containers/associative/multimap/multimap.modifiers/emplace.pass.cpp
new file mode 100644
index 000000000000..03da4af59372
--- /dev/null
+++ b/test/std/containers/associative/multimap/multimap.modifiers/emplace.pass.cpp
@@ -0,0 +1,150 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// template <class... Args>
+// iterator emplace(Args&&... args);
+
+#include <map>
+#include <cassert>
+
+#include "../../../Emplaceable.h"
+#include "DefaultOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::multimap<int, DefaultOnly> M;
+ typedef M::iterator R;
+ M m;
+ assert(DefaultOnly::count == 0);
+ R r = m.emplace();
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(m.begin()->first == 0);
+ assert(m.begin()->second == DefaultOnly());
+ assert(DefaultOnly::count == 1);
+ r = m.emplace(std::piecewise_construct, std::forward_as_tuple(1),
+ std::forward_as_tuple());
+ assert(r == next(m.begin()));
+ assert(m.size() == 2);
+ assert(next(m.begin())->first == 1);
+ assert(next(m.begin())->second == DefaultOnly());
+ assert(DefaultOnly::count == 2);
+ r = m.emplace(std::piecewise_construct, std::forward_as_tuple(1),
+ std::forward_as_tuple());
+ assert(r == next(m.begin(), 2));
+ assert(m.size() == 3);
+ assert(next(m.begin(), 2)->first == 1);
+ assert(next(m.begin(), 2)->second == DefaultOnly());
+ assert(DefaultOnly::count == 3);
+ }
+ assert(DefaultOnly::count == 0);
+ {
+ typedef std::multimap<int, Emplaceable> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.emplace(std::piecewise_construct, std::forward_as_tuple(2),
+ std::forward_as_tuple());
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == Emplaceable());
+ r = m.emplace(std::piecewise_construct, std::forward_as_tuple(1),
+ std::forward_as_tuple(2, 3.5));
+ assert(r == m.begin());
+ assert(m.size() == 2);
+ assert(m.begin()->first == 1);
+ assert(m.begin()->second == Emplaceable(2, 3.5));
+ r = m.emplace(std::piecewise_construct, std::forward_as_tuple(1),
+ std::forward_as_tuple(3, 3.5));
+ assert(r == next(m.begin()));
+ assert(m.size() == 3);
+ assert(r->first == 1);
+ assert(r->second == Emplaceable(3, 3.5));
+ }
+ {
+ typedef std::multimap<int, double> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.emplace(M::value_type(2, 3.5));
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == 3.5);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::multimap<int, DefaultOnly, std::less<int>, min_allocator<std::pair<const int, DefaultOnly>>> M;
+ typedef M::iterator R;
+ M m;
+ assert(DefaultOnly::count == 0);
+ R r = m.emplace();
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(m.begin()->first == 0);
+ assert(m.begin()->second == DefaultOnly());
+ assert(DefaultOnly::count == 1);
+ r = m.emplace(std::piecewise_construct, std::forward_as_tuple(1),
+ std::forward_as_tuple());
+ assert(r == next(m.begin()));
+ assert(m.size() == 2);
+ assert(next(m.begin())->first == 1);
+ assert(next(m.begin())->second == DefaultOnly());
+ assert(DefaultOnly::count == 2);
+ r = m.emplace(std::piecewise_construct, std::forward_as_tuple(1),
+ std::forward_as_tuple());
+ assert(r == next(m.begin(), 2));
+ assert(m.size() == 3);
+ assert(next(m.begin(), 2)->first == 1);
+ assert(next(m.begin(), 2)->second == DefaultOnly());
+ assert(DefaultOnly::count == 3);
+ }
+ assert(DefaultOnly::count == 0);
+ {
+ typedef std::multimap<int, Emplaceable, std::less<int>, min_allocator<std::pair<const int, Emplaceable>>> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.emplace(std::piecewise_construct, std::forward_as_tuple(2),
+ std::forward_as_tuple());
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == Emplaceable());
+ r = m.emplace(std::piecewise_construct, std::forward_as_tuple(1),
+ std::forward_as_tuple(2, 3.5));
+ assert(r == m.begin());
+ assert(m.size() == 2);
+ assert(m.begin()->first == 1);
+ assert(m.begin()->second == Emplaceable(2, 3.5));
+ r = m.emplace(std::piecewise_construct, std::forward_as_tuple(1),
+ std::forward_as_tuple(3, 3.5));
+ assert(r == next(m.begin()));
+ assert(m.size() == 3);
+ assert(r->first == 1);
+ assert(r->second == Emplaceable(3, 3.5));
+ }
+ {
+ typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.emplace(M::value_type(2, 3.5));
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == 3.5);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/associative/multimap/multimap.modifiers/emplace_hint.pass.cpp b/test/std/containers/associative/multimap/multimap.modifiers/emplace_hint.pass.cpp
new file mode 100644
index 000000000000..846d5999a17e
--- /dev/null
+++ b/test/std/containers/associative/multimap/multimap.modifiers/emplace_hint.pass.cpp
@@ -0,0 +1,160 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// template <class... Args>
+// iterator emplace_hint(const_iterator position, Args&&... args);
+
+#include <map>
+#include <cassert>
+
+#include "../../../Emplaceable.h"
+#include "DefaultOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::multimap<int, DefaultOnly> M;
+ typedef M::iterator R;
+ M m;
+ assert(DefaultOnly::count == 0);
+ R r = m.emplace_hint(m.cend());
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(m.begin()->first == 0);
+ assert(m.begin()->second == DefaultOnly());
+ assert(DefaultOnly::count == 1);
+ r = m.emplace_hint(m.cend(), std::piecewise_construct,
+ std::forward_as_tuple(1),
+ std::forward_as_tuple());
+ assert(r == next(m.begin()));
+ assert(m.size() == 2);
+ assert(next(m.begin())->first == 1);
+ assert(next(m.begin())->second == DefaultOnly());
+ assert(DefaultOnly::count == 2);
+ r = m.emplace_hint(m.cend(), std::piecewise_construct,
+ std::forward_as_tuple(1),
+ std::forward_as_tuple());
+ assert(r == next(m.begin(), 2));
+ assert(m.size() == 3);
+ assert(next(m.begin(), 2)->first == 1);
+ assert(next(m.begin(), 2)->second == DefaultOnly());
+ assert(DefaultOnly::count == 3);
+ }
+ assert(DefaultOnly::count == 0);
+ {
+ typedef std::multimap<int, Emplaceable> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.emplace_hint(m.cend(), std::piecewise_construct,
+ std::forward_as_tuple(2),
+ std::forward_as_tuple());
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == Emplaceable());
+ r = m.emplace_hint(m.cbegin(), std::piecewise_construct,
+ std::forward_as_tuple(1),
+ std::forward_as_tuple(2, 3.5));
+ assert(r == m.begin());
+ assert(m.size() == 2);
+ assert(m.begin()->first == 1);
+ assert(m.begin()->second == Emplaceable(2, 3.5));
+ r = m.emplace_hint(m.cbegin(), std::piecewise_construct,
+ std::forward_as_tuple(1),
+ std::forward_as_tuple(3, 3.5));
+ assert(r == m.begin());
+ assert(m.size() == 3);
+ assert(r->first == 1);
+ assert(r->second == Emplaceable(3, 3.5));
+ }
+ {
+ typedef std::multimap<int, double> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.emplace_hint(m.cend(), M::value_type(2, 3.5));
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == 3.5);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::multimap<int, DefaultOnly, std::less<int>, min_allocator<std::pair<const int, DefaultOnly>>> M;
+ typedef M::iterator R;
+ M m;
+ assert(DefaultOnly::count == 0);
+ R r = m.emplace_hint(m.cend());
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(m.begin()->first == 0);
+ assert(m.begin()->second == DefaultOnly());
+ assert(DefaultOnly::count == 1);
+ r = m.emplace_hint(m.cend(), std::piecewise_construct,
+ std::forward_as_tuple(1),
+ std::forward_as_tuple());
+ assert(r == next(m.begin()));
+ assert(m.size() == 2);
+ assert(next(m.begin())->first == 1);
+ assert(next(m.begin())->second == DefaultOnly());
+ assert(DefaultOnly::count == 2);
+ r = m.emplace_hint(m.cend(), std::piecewise_construct,
+ std::forward_as_tuple(1),
+ std::forward_as_tuple());
+ assert(r == next(m.begin(), 2));
+ assert(m.size() == 3);
+ assert(next(m.begin(), 2)->first == 1);
+ assert(next(m.begin(), 2)->second == DefaultOnly());
+ assert(DefaultOnly::count == 3);
+ }
+ assert(DefaultOnly::count == 0);
+ {
+ typedef std::multimap<int, Emplaceable, std::less<int>, min_allocator<std::pair<const int, Emplaceable>>> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.emplace_hint(m.cend(), std::piecewise_construct,
+ std::forward_as_tuple(2),
+ std::forward_as_tuple());
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == Emplaceable());
+ r = m.emplace_hint(m.cbegin(), std::piecewise_construct,
+ std::forward_as_tuple(1),
+ std::forward_as_tuple(2, 3.5));
+ assert(r == m.begin());
+ assert(m.size() == 2);
+ assert(m.begin()->first == 1);
+ assert(m.begin()->second == Emplaceable(2, 3.5));
+ r = m.emplace_hint(m.cbegin(), std::piecewise_construct,
+ std::forward_as_tuple(1),
+ std::forward_as_tuple(3, 3.5));
+ assert(r == m.begin());
+ assert(m.size() == 3);
+ assert(r->first == 1);
+ assert(r->second == Emplaceable(3, 3.5));
+ }
+ {
+ typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.emplace_hint(m.cend(), M::value_type(2, 3.5));
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == 3.5);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/associative/multimap/multimap.modifiers/erase_iter.pass.cpp b/test/std/containers/associative/multimap/multimap.modifiers/erase_iter.pass.cpp
new file mode 100644
index 000000000000..ba55351c0bde
--- /dev/null
+++ b/test/std/containers/associative/multimap/multimap.modifiers/erase_iter.pass.cpp
@@ -0,0 +1,301 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// iterator erase(const_iterator position);
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+struct TemplateConstructor
+{
+ template<typename T>
+ TemplateConstructor (const T&) {}
+};
+
+bool operator<(const TemplateConstructor&, const TemplateConstructor&) { return false; }
+
+int main()
+{
+ {
+ typedef std::multimap<int, double> M;
+ typedef std::pair<int, double> P;
+ typedef M::iterator I;
+ P ar[] =
+ {
+ P(1, 1),
+ P(1, 1.5),
+ P(1, 2),
+ P(2, 1),
+ P(2, 1.5),
+ P(2, 2),
+ P(3, 1),
+ P(3, 1.5),
+ P(3, 2),
+ };
+ M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 9);
+ I i = m.erase(next(m.cbegin(), 3));
+ assert(m.size() == 8);
+ assert(i == next(m.begin(), 3));
+ assert(m.begin()->first == 1);
+ assert(m.begin()->second == 1);
+ assert(next(m.begin())->first == 1);
+ assert(next(m.begin())->second == 1.5);
+ assert(next(m.begin(), 2)->first == 1);
+ assert(next(m.begin(), 2)->second == 2);
+ assert(next(m.begin(), 3)->first == 2);
+ assert(next(m.begin(), 3)->second == 1.5);
+ assert(next(m.begin(), 4)->first == 2);
+ assert(next(m.begin(), 4)->second == 2);
+ assert(next(m.begin(), 5)->first == 3);
+ assert(next(m.begin(), 5)->second == 1);
+ assert(next(m.begin(), 6)->first == 3);
+ assert(next(m.begin(), 6)->second == 1.5);
+ assert(next(m.begin(), 7)->first == 3);
+ assert(next(m.begin(), 7)->second == 2);
+
+ i = m.erase(next(m.cbegin(), 0));
+ assert(m.size() == 7);
+ assert(i == m.begin());
+ assert(next(m.begin(), 0)->first == 1);
+ assert(next(m.begin(), 0)->second == 1.5);
+ assert(next(m.begin(), 1)->first == 1);
+ assert(next(m.begin(), 1)->second == 2);
+ assert(next(m.begin(), 2)->first == 2);
+ assert(next(m.begin(), 2)->second == 1.5);
+ assert(next(m.begin(), 3)->first == 2);
+ assert(next(m.begin(), 3)->second == 2);
+ assert(next(m.begin(), 4)->first == 3);
+ assert(next(m.begin(), 4)->second == 1);
+ assert(next(m.begin(), 5)->first == 3);
+ assert(next(m.begin(), 5)->second == 1.5);
+ assert(next(m.begin(), 6)->first == 3);
+ assert(next(m.begin(), 6)->second == 2);
+
+ i = m.erase(next(m.cbegin(), 5));
+ assert(m.size() == 6);
+ assert(i == prev(m.end()));
+ assert(next(m.begin(), 0)->first == 1);
+ assert(next(m.begin(), 0)->second == 1.5);
+ assert(next(m.begin(), 1)->first == 1);
+ assert(next(m.begin(), 1)->second == 2);
+ assert(next(m.begin(), 2)->first == 2);
+ assert(next(m.begin(), 2)->second == 1.5);
+ assert(next(m.begin(), 3)->first == 2);
+ assert(next(m.begin(), 3)->second == 2);
+ assert(next(m.begin(), 4)->first == 3);
+ assert(next(m.begin(), 4)->second == 1);
+ assert(next(m.begin(), 5)->first == 3);
+ assert(next(m.begin(), 5)->second == 2);
+
+ i = m.erase(next(m.cbegin(), 1));
+ assert(m.size() == 5);
+ assert(i == next(m.begin()));
+ assert(next(m.begin(), 0)->first == 1);
+ assert(next(m.begin(), 0)->second == 1.5);
+ assert(next(m.begin(), 1)->first == 2);
+ assert(next(m.begin(), 1)->second == 1.5);
+ assert(next(m.begin(), 2)->first == 2);
+ assert(next(m.begin(), 2)->second == 2);
+ assert(next(m.begin(), 3)->first == 3);
+ assert(next(m.begin(), 3)->second == 1);
+ assert(next(m.begin(), 4)->first == 3);
+ assert(next(m.begin(), 4)->second == 2);
+
+ i = m.erase(next(m.cbegin(), 2));
+ assert(m.size() == 4);
+ assert(i == next(m.begin(), 2));
+ assert(next(m.begin(), 0)->first == 1);
+ assert(next(m.begin(), 0)->second == 1.5);
+ assert(next(m.begin(), 1)->first == 2);
+ assert(next(m.begin(), 1)->second == 1.5);
+ assert(next(m.begin(), 2)->first == 3);
+ assert(next(m.begin(), 2)->second == 1);
+ assert(next(m.begin(), 3)->first == 3);
+ assert(next(m.begin(), 3)->second == 2);
+
+ i = m.erase(next(m.cbegin(), 2));
+ assert(m.size() == 3);
+ assert(i == next(m.begin(), 2));
+ assert(next(m.begin(), 0)->first == 1);
+ assert(next(m.begin(), 0)->second == 1.5);
+ assert(next(m.begin(), 1)->first == 2);
+ assert(next(m.begin(), 1)->second == 1.5);
+ assert(next(m.begin(), 2)->first == 3);
+ assert(next(m.begin(), 2)->second == 2);
+
+ i = m.erase(next(m.cbegin(), 0));
+ assert(m.size() == 2);
+ assert(i == next(m.begin(), 0));
+ assert(next(m.begin(), 0)->first == 2);
+ assert(next(m.begin(), 0)->second == 1.5);
+ assert(next(m.begin(), 1)->first == 3);
+ assert(next(m.begin(), 1)->second == 2);
+
+ i = m.erase(next(m.cbegin(), 1));
+ assert(m.size() == 1);
+ assert(i == m.end());
+ assert(next(m.begin(), 0)->first == 2);
+ assert(next(m.begin(), 0)->second == 1.5);
+
+ i = m.erase(m.cbegin());
+ assert(m.size() == 0);
+ assert(i == m.begin());
+ assert(i == m.end());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+ typedef std::pair<int, double> P;
+ typedef M::iterator I;
+ P ar[] =
+ {
+ P(1, 1),
+ P(1, 1.5),
+ P(1, 2),
+ P(2, 1),
+ P(2, 1.5),
+ P(2, 2),
+ P(3, 1),
+ P(3, 1.5),
+ P(3, 2),
+ };
+ M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 9);
+ I i = m.erase(next(m.cbegin(), 3));
+ assert(m.size() == 8);
+ assert(i == next(m.begin(), 3));
+ assert(m.begin()->first == 1);
+ assert(m.begin()->second == 1);
+ assert(next(m.begin())->first == 1);
+ assert(next(m.begin())->second == 1.5);
+ assert(next(m.begin(), 2)->first == 1);
+ assert(next(m.begin(), 2)->second == 2);
+ assert(next(m.begin(), 3)->first == 2);
+ assert(next(m.begin(), 3)->second == 1.5);
+ assert(next(m.begin(), 4)->first == 2);
+ assert(next(m.begin(), 4)->second == 2);
+ assert(next(m.begin(), 5)->first == 3);
+ assert(next(m.begin(), 5)->second == 1);
+ assert(next(m.begin(), 6)->first == 3);
+ assert(next(m.begin(), 6)->second == 1.5);
+ assert(next(m.begin(), 7)->first == 3);
+ assert(next(m.begin(), 7)->second == 2);
+
+ i = m.erase(next(m.cbegin(), 0));
+ assert(m.size() == 7);
+ assert(i == m.begin());
+ assert(next(m.begin(), 0)->first == 1);
+ assert(next(m.begin(), 0)->second == 1.5);
+ assert(next(m.begin(), 1)->first == 1);
+ assert(next(m.begin(), 1)->second == 2);
+ assert(next(m.begin(), 2)->first == 2);
+ assert(next(m.begin(), 2)->second == 1.5);
+ assert(next(m.begin(), 3)->first == 2);
+ assert(next(m.begin(), 3)->second == 2);
+ assert(next(m.begin(), 4)->first == 3);
+ assert(next(m.begin(), 4)->second == 1);
+ assert(next(m.begin(), 5)->first == 3);
+ assert(next(m.begin(), 5)->second == 1.5);
+ assert(next(m.begin(), 6)->first == 3);
+ assert(next(m.begin(), 6)->second == 2);
+
+ i = m.erase(next(m.cbegin(), 5));
+ assert(m.size() == 6);
+ assert(i == prev(m.end()));
+ assert(next(m.begin(), 0)->first == 1);
+ assert(next(m.begin(), 0)->second == 1.5);
+ assert(next(m.begin(), 1)->first == 1);
+ assert(next(m.begin(), 1)->second == 2);
+ assert(next(m.begin(), 2)->first == 2);
+ assert(next(m.begin(), 2)->second == 1.5);
+ assert(next(m.begin(), 3)->first == 2);
+ assert(next(m.begin(), 3)->second == 2);
+ assert(next(m.begin(), 4)->first == 3);
+ assert(next(m.begin(), 4)->second == 1);
+ assert(next(m.begin(), 5)->first == 3);
+ assert(next(m.begin(), 5)->second == 2);
+
+ i = m.erase(next(m.cbegin(), 1));
+ assert(m.size() == 5);
+ assert(i == next(m.begin()));
+ assert(next(m.begin(), 0)->first == 1);
+ assert(next(m.begin(), 0)->second == 1.5);
+ assert(next(m.begin(), 1)->first == 2);
+ assert(next(m.begin(), 1)->second == 1.5);
+ assert(next(m.begin(), 2)->first == 2);
+ assert(next(m.begin(), 2)->second == 2);
+ assert(next(m.begin(), 3)->first == 3);
+ assert(next(m.begin(), 3)->second == 1);
+ assert(next(m.begin(), 4)->first == 3);
+ assert(next(m.begin(), 4)->second == 2);
+
+ i = m.erase(next(m.cbegin(), 2));
+ assert(m.size() == 4);
+ assert(i == next(m.begin(), 2));
+ assert(next(m.begin(), 0)->first == 1);
+ assert(next(m.begin(), 0)->second == 1.5);
+ assert(next(m.begin(), 1)->first == 2);
+ assert(next(m.begin(), 1)->second == 1.5);
+ assert(next(m.begin(), 2)->first == 3);
+ assert(next(m.begin(), 2)->second == 1);
+ assert(next(m.begin(), 3)->first == 3);
+ assert(next(m.begin(), 3)->second == 2);
+
+ i = m.erase(next(m.cbegin(), 2));
+ assert(m.size() == 3);
+ assert(i == next(m.begin(), 2));
+ assert(next(m.begin(), 0)->first == 1);
+ assert(next(m.begin(), 0)->second == 1.5);
+ assert(next(m.begin(), 1)->first == 2);
+ assert(next(m.begin(), 1)->second == 1.5);
+ assert(next(m.begin(), 2)->first == 3);
+ assert(next(m.begin(), 2)->second == 2);
+
+ i = m.erase(next(m.cbegin(), 0));
+ assert(m.size() == 2);
+ assert(i == next(m.begin(), 0));
+ assert(next(m.begin(), 0)->first == 2);
+ assert(next(m.begin(), 0)->second == 1.5);
+ assert(next(m.begin(), 1)->first == 3);
+ assert(next(m.begin(), 1)->second == 2);
+
+ i = m.erase(next(m.cbegin(), 1));
+ assert(m.size() == 1);
+ assert(i == m.end());
+ assert(next(m.begin(), 0)->first == 2);
+ assert(next(m.begin(), 0)->second == 1.5);
+
+ i = m.erase(m.cbegin());
+ assert(m.size() == 0);
+ assert(i == m.begin());
+ assert(i == m.end());
+ }
+#endif
+#if __cplusplus >= 201402L
+ {
+ // This is LWG #2059
+ typedef TemplateConstructor T;
+ typedef std::multimap<T, int> C;
+ typedef C::iterator I;
+
+ C c;
+ T a{0};
+ I it = c.find(a);
+ if (it != c.end())
+ c.erase(it);
+ }
+#endif
+}
diff --git a/test/std/containers/associative/multimap/multimap.modifiers/erase_iter_iter.pass.cpp b/test/std/containers/associative/multimap/multimap.modifiers/erase_iter_iter.pass.cpp
new file mode 100644
index 000000000000..4d3789493110
--- /dev/null
+++ b/test/std/containers/associative/multimap/multimap.modifiers/erase_iter_iter.pass.cpp
@@ -0,0 +1,157 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// iterator erase(const_iterator first, const_iterator last);
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::multimap<int, double> M;
+ typedef std::pair<int, double> P;
+ typedef M::iterator I;
+ P ar[] =
+ {
+ P(1, 1.5),
+ P(2, 2.5),
+ P(3, 3.5),
+ P(4, 4.5),
+ P(5, 5.5),
+ P(6, 6.5),
+ P(7, 7.5),
+ P(8, 8.5),
+ };
+ M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 8);
+ I i = m.erase(m.cbegin(), m.cbegin());
+ assert(m.size() == 8);
+ assert(i == m.begin());
+ assert(m.begin()->first == 1);
+ assert(m.begin()->second == 1.5);
+ assert(next(m.begin())->first == 2);
+ assert(next(m.begin())->second == 2.5);
+ assert(next(m.begin(), 2)->first == 3);
+ assert(next(m.begin(), 2)->second == 3.5);
+ assert(next(m.begin(), 3)->first == 4);
+ assert(next(m.begin(), 3)->second == 4.5);
+ assert(next(m.begin(), 4)->first == 5);
+ assert(next(m.begin(), 4)->second == 5.5);
+ assert(next(m.begin(), 5)->first == 6);
+ assert(next(m.begin(), 5)->second == 6.5);
+ assert(next(m.begin(), 6)->first == 7);
+ assert(next(m.begin(), 6)->second == 7.5);
+ assert(next(m.begin(), 7)->first == 8);
+ assert(next(m.begin(), 7)->second == 8.5);
+
+ i = m.erase(m.cbegin(), next(m.cbegin(), 2));
+ assert(m.size() == 6);
+ assert(i == m.begin());
+ assert(next(m.begin(), 0)->first == 3);
+ assert(next(m.begin(), 0)->second == 3.5);
+ assert(next(m.begin(), 1)->first == 4);
+ assert(next(m.begin(), 1)->second == 4.5);
+ assert(next(m.begin(), 2)->first == 5);
+ assert(next(m.begin(), 2)->second == 5.5);
+ assert(next(m.begin(), 3)->first == 6);
+ assert(next(m.begin(), 3)->second == 6.5);
+ assert(next(m.begin(), 4)->first == 7);
+ assert(next(m.begin(), 4)->second == 7.5);
+ assert(next(m.begin(), 5)->first == 8);
+ assert(next(m.begin(), 5)->second == 8.5);
+
+ i = m.erase(next(m.cbegin(), 2), next(m.cbegin(), 6));
+ assert(m.size() == 2);
+ assert(i == next(m.begin(), 2));
+ assert(next(m.begin(), 0)->first == 3);
+ assert(next(m.begin(), 0)->second == 3.5);
+ assert(next(m.begin(), 1)->first == 4);
+ assert(next(m.begin(), 1)->second == 4.5);
+
+ i = m.erase(m.cbegin(), m.cend());
+ assert(m.size() == 0);
+ assert(i == m.begin());
+ assert(i == m.end());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+ typedef std::pair<int, double> P;
+ typedef M::iterator I;
+ P ar[] =
+ {
+ P(1, 1.5),
+ P(2, 2.5),
+ P(3, 3.5),
+ P(4, 4.5),
+ P(5, 5.5),
+ P(6, 6.5),
+ P(7, 7.5),
+ P(8, 8.5),
+ };
+ M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 8);
+ I i = m.erase(m.cbegin(), m.cbegin());
+ assert(m.size() == 8);
+ assert(i == m.begin());
+ assert(m.begin()->first == 1);
+ assert(m.begin()->second == 1.5);
+ assert(next(m.begin())->first == 2);
+ assert(next(m.begin())->second == 2.5);
+ assert(next(m.begin(), 2)->first == 3);
+ assert(next(m.begin(), 2)->second == 3.5);
+ assert(next(m.begin(), 3)->first == 4);
+ assert(next(m.begin(), 3)->second == 4.5);
+ assert(next(m.begin(), 4)->first == 5);
+ assert(next(m.begin(), 4)->second == 5.5);
+ assert(next(m.begin(), 5)->first == 6);
+ assert(next(m.begin(), 5)->second == 6.5);
+ assert(next(m.begin(), 6)->first == 7);
+ assert(next(m.begin(), 6)->second == 7.5);
+ assert(next(m.begin(), 7)->first == 8);
+ assert(next(m.begin(), 7)->second == 8.5);
+
+ i = m.erase(m.cbegin(), next(m.cbegin(), 2));
+ assert(m.size() == 6);
+ assert(i == m.begin());
+ assert(next(m.begin(), 0)->first == 3);
+ assert(next(m.begin(), 0)->second == 3.5);
+ assert(next(m.begin(), 1)->first == 4);
+ assert(next(m.begin(), 1)->second == 4.5);
+ assert(next(m.begin(), 2)->first == 5);
+ assert(next(m.begin(), 2)->second == 5.5);
+ assert(next(m.begin(), 3)->first == 6);
+ assert(next(m.begin(), 3)->second == 6.5);
+ assert(next(m.begin(), 4)->first == 7);
+ assert(next(m.begin(), 4)->second == 7.5);
+ assert(next(m.begin(), 5)->first == 8);
+ assert(next(m.begin(), 5)->second == 8.5);
+
+ i = m.erase(next(m.cbegin(), 2), next(m.cbegin(), 6));
+ assert(m.size() == 2);
+ assert(i == next(m.begin(), 2));
+ assert(next(m.begin(), 0)->first == 3);
+ assert(next(m.begin(), 0)->second == 3.5);
+ assert(next(m.begin(), 1)->first == 4);
+ assert(next(m.begin(), 1)->second == 4.5);
+
+ i = m.erase(m.cbegin(), m.cend());
+ assert(m.size() == 0);
+ assert(i == m.begin());
+ assert(i == m.end());
+ }
+#endif
+}
diff --git a/test/std/containers/associative/multimap/multimap.modifiers/erase_key.pass.cpp b/test/std/containers/associative/multimap/multimap.modifiers/erase_key.pass.cpp
new file mode 100644
index 000000000000..33821d3e3596
--- /dev/null
+++ b/test/std/containers/associative/multimap/multimap.modifiers/erase_key.pass.cpp
@@ -0,0 +1,153 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// size_type erase(const key_type& k);
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::multimap<int, double> M;
+ typedef std::pair<int, double> P;
+ typedef M::size_type I;
+ P ar[] =
+ {
+ P(1, 1),
+ P(1, 1.5),
+ P(1, 2),
+ P(2, 1),
+ P(2, 1.5),
+ P(2, 2),
+ P(3, 1),
+ P(3, 1.5),
+ P(3, 2),
+ };
+ M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 9);
+ I i = m.erase(2);
+ assert(m.size() == 6);
+ assert(i == 3);
+ assert(next(m.begin(), 0)->first == 1);
+ assert(next(m.begin(), 0)->second == 1);
+ assert(next(m.begin(), 1)->first == 1);
+ assert(next(m.begin(), 1)->second == 1.5);
+ assert(next(m.begin(), 2)->first == 1);
+ assert(next(m.begin(), 2)->second == 2);
+ assert(next(m.begin(), 3)->first == 3);
+ assert(next(m.begin(), 3)->second == 1);
+ assert(next(m.begin(), 4)->first == 3);
+ assert(next(m.begin(), 4)->second == 1.5);
+ assert(next(m.begin(), 5)->first == 3);
+ assert(next(m.begin(), 5)->second == 2);
+
+ i = m.erase(2);
+ assert(m.size() == 6);
+ assert(i == 0);
+ assert(next(m.begin(), 0)->first == 1);
+ assert(next(m.begin(), 0)->second == 1);
+ assert(next(m.begin(), 1)->first == 1);
+ assert(next(m.begin(), 1)->second == 1.5);
+ assert(next(m.begin(), 2)->first == 1);
+ assert(next(m.begin(), 2)->second == 2);
+ assert(next(m.begin(), 3)->first == 3);
+ assert(next(m.begin(), 3)->second == 1);
+ assert(next(m.begin(), 4)->first == 3);
+ assert(next(m.begin(), 4)->second == 1.5);
+ assert(next(m.begin(), 5)->first == 3);
+ assert(next(m.begin(), 5)->second == 2);
+
+ i = m.erase(3);
+ assert(i == 3);
+ assert(m.size() == 3);
+ assert(next(m.begin(), 0)->first == 1);
+ assert(next(m.begin(), 0)->second == 1);
+ assert(next(m.begin(), 1)->first == 1);
+ assert(next(m.begin(), 1)->second == 1.5);
+ assert(next(m.begin(), 2)->first == 1);
+ assert(next(m.begin(), 2)->second == 2);
+
+ i = m.erase(1);
+ assert(m.size() == 0);
+ assert(i == 3);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+ typedef std::pair<int, double> P;
+ typedef M::size_type I;
+ P ar[] =
+ {
+ P(1, 1),
+ P(1, 1.5),
+ P(1, 2),
+ P(2, 1),
+ P(2, 1.5),
+ P(2, 2),
+ P(3, 1),
+ P(3, 1.5),
+ P(3, 2),
+ };
+ M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 9);
+ I i = m.erase(2);
+ assert(m.size() == 6);
+ assert(i == 3);
+ assert(next(m.begin(), 0)->first == 1);
+ assert(next(m.begin(), 0)->second == 1);
+ assert(next(m.begin(), 1)->first == 1);
+ assert(next(m.begin(), 1)->second == 1.5);
+ assert(next(m.begin(), 2)->first == 1);
+ assert(next(m.begin(), 2)->second == 2);
+ assert(next(m.begin(), 3)->first == 3);
+ assert(next(m.begin(), 3)->second == 1);
+ assert(next(m.begin(), 4)->first == 3);
+ assert(next(m.begin(), 4)->second == 1.5);
+ assert(next(m.begin(), 5)->first == 3);
+ assert(next(m.begin(), 5)->second == 2);
+
+ i = m.erase(2);
+ assert(m.size() == 6);
+ assert(i == 0);
+ assert(next(m.begin(), 0)->first == 1);
+ assert(next(m.begin(), 0)->second == 1);
+ assert(next(m.begin(), 1)->first == 1);
+ assert(next(m.begin(), 1)->second == 1.5);
+ assert(next(m.begin(), 2)->first == 1);
+ assert(next(m.begin(), 2)->second == 2);
+ assert(next(m.begin(), 3)->first == 3);
+ assert(next(m.begin(), 3)->second == 1);
+ assert(next(m.begin(), 4)->first == 3);
+ assert(next(m.begin(), 4)->second == 1.5);
+ assert(next(m.begin(), 5)->first == 3);
+ assert(next(m.begin(), 5)->second == 2);
+
+ i = m.erase(3);
+ assert(i == 3);
+ assert(m.size() == 3);
+ assert(next(m.begin(), 0)->first == 1);
+ assert(next(m.begin(), 0)->second == 1);
+ assert(next(m.begin(), 1)->first == 1);
+ assert(next(m.begin(), 1)->second == 1.5);
+ assert(next(m.begin(), 2)->first == 1);
+ assert(next(m.begin(), 2)->second == 2);
+
+ i = m.erase(1);
+ assert(m.size() == 0);
+ assert(i == 3);
+ }
+#endif
+}
diff --git a/test/std/containers/associative/multimap/multimap.modifiers/insert_cv.pass.cpp b/test/std/containers/associative/multimap/multimap.modifiers/insert_cv.pass.cpp
new file mode 100644
index 000000000000..d9afc9d0fdf0
--- /dev/null
+++ b/test/std/containers/associative/multimap/multimap.modifiers/insert_cv.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// iterator insert(const value_type& v);
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::multimap<int, double> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.insert(M::value_type(2, 2.5));
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(r->first == 2);
+ assert(r->second == 2.5);
+
+ r = m.insert(M::value_type(1, 1.5));
+ assert(r == m.begin());
+ assert(m.size() == 2);
+ assert(r->first == 1);
+ assert(r->second == 1.5);
+
+ r = m.insert(M::value_type(3, 3.5));
+ assert(r == prev(m.end()));
+ assert(m.size() == 3);
+ assert(r->first == 3);
+ assert(r->second == 3.5);
+
+ r = m.insert(M::value_type(3, 3.5));
+ assert(r == prev(m.end()));
+ assert(m.size() == 4);
+ assert(r->first == 3);
+ assert(r->second == 3.5);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.insert(M::value_type(2, 2.5));
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(r->first == 2);
+ assert(r->second == 2.5);
+
+ r = m.insert(M::value_type(1, 1.5));
+ assert(r == m.begin());
+ assert(m.size() == 2);
+ assert(r->first == 1);
+ assert(r->second == 1.5);
+
+ r = m.insert(M::value_type(3, 3.5));
+ assert(r == prev(m.end()));
+ assert(m.size() == 3);
+ assert(r->first == 3);
+ assert(r->second == 3.5);
+
+ r = m.insert(M::value_type(3, 3.5));
+ assert(r == prev(m.end()));
+ assert(m.size() == 4);
+ assert(r->first == 3);
+ assert(r->second == 3.5);
+ }
+#endif
+}
diff --git a/test/std/containers/associative/multimap/multimap.modifiers/insert_initializer_list.pass.cpp b/test/std/containers/associative/multimap/multimap.modifiers/insert_initializer_list.pass.cpp
new file mode 100644
index 000000000000..5e1a1d4125ef
--- /dev/null
+++ b/test/std/containers/associative/multimap/multimap.modifiers/insert_initializer_list.pass.cpp
@@ -0,0 +1,91 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// void insert(initializer_list<value_type> il);
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::multimap<int, double> C;
+ typedef C::value_type V;
+ C m =
+ {
+ {1, 1},
+ {1, 2},
+ {2, 1},
+ {2, 2},
+ {3, 1},
+ {3, 2}
+ };
+ m.insert(
+ {
+ {1, 1.5},
+ {2, 1.5},
+ {3, 1.5},
+ }
+ );
+ assert(m.size() == 9);
+ assert(distance(m.begin(), m.end()) == 9);
+ C::const_iterator i = m.cbegin();
+ assert(*i == V(1, 1));
+ assert(*++i == V(1, 2));
+ assert(*++i == V(1, 1.5));
+ assert(*++i == V(2, 1));
+ assert(*++i == V(2, 2));
+ assert(*++i == V(2, 1.5));
+ assert(*++i == V(3, 1));
+ assert(*++i == V(3, 2));
+ assert(*++i == V(3, 1.5));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> C;
+ typedef C::value_type V;
+ C m =
+ {
+ {1, 1},
+ {1, 2},
+ {2, 1},
+ {2, 2},
+ {3, 1},
+ {3, 2}
+ };
+ m.insert(
+ {
+ {1, 1.5},
+ {2, 1.5},
+ {3, 1.5},
+ }
+ );
+ assert(m.size() == 9);
+ assert(distance(m.begin(), m.end()) == 9);
+ C::const_iterator i = m.cbegin();
+ assert(*i == V(1, 1));
+ assert(*++i == V(1, 2));
+ assert(*++i == V(1, 1.5));
+ assert(*++i == V(2, 1));
+ assert(*++i == V(2, 2));
+ assert(*++i == V(2, 1.5));
+ assert(*++i == V(3, 1));
+ assert(*++i == V(3, 2));
+ assert(*++i == V(3, 1.5));
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/containers/associative/multimap/multimap.modifiers/insert_iter_cv.pass.cpp b/test/std/containers/associative/multimap/multimap.modifiers/insert_iter_cv.pass.cpp
new file mode 100644
index 000000000000..b83c802c04cf
--- /dev/null
+++ b/test/std/containers/associative/multimap/multimap.modifiers/insert_iter_cv.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// iterator insert(const_iterator position, const value_type& v);
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::multimap<int, double> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.insert(m.end(), M::value_type(2, 2.5));
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(r->first == 2);
+ assert(r->second == 2.5);
+
+ r = m.insert(m.end(), M::value_type(1, 1.5));
+ assert(r == m.begin());
+ assert(m.size() == 2);
+ assert(r->first == 1);
+ assert(r->second == 1.5);
+
+ r = m.insert(m.end(), M::value_type(3, 3.5));
+ assert(r == prev(m.end()));
+ assert(m.size() == 3);
+ assert(r->first == 3);
+ assert(r->second == 3.5);
+
+ r = m.insert(prev(m.end()), M::value_type(3, 4.5));
+ assert(r == prev(m.end(), 2));
+ assert(m.size() == 4);
+ assert(r->first == 3);
+ assert(r->second == 4.5);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.insert(m.end(), M::value_type(2, 2.5));
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(r->first == 2);
+ assert(r->second == 2.5);
+
+ r = m.insert(m.end(), M::value_type(1, 1.5));
+ assert(r == m.begin());
+ assert(m.size() == 2);
+ assert(r->first == 1);
+ assert(r->second == 1.5);
+
+ r = m.insert(m.end(), M::value_type(3, 3.5));
+ assert(r == prev(m.end()));
+ assert(m.size() == 3);
+ assert(r->first == 3);
+ assert(r->second == 3.5);
+
+ r = m.insert(prev(m.end()), M::value_type(3, 4.5));
+ assert(r == prev(m.end(), 2));
+ assert(m.size() == 4);
+ assert(r->first == 3);
+ assert(r->second == 4.5);
+ }
+#endif
+}
diff --git a/test/std/containers/associative/multimap/multimap.modifiers/insert_iter_iter.pass.cpp b/test/std/containers/associative/multimap/multimap.modifiers/insert_iter_iter.pass.cpp
new file mode 100644
index 000000000000..70ff7ef6d6b8
--- /dev/null
+++ b/test/std/containers/associative/multimap/multimap.modifiers/insert_iter_iter.pass.cpp
@@ -0,0 +1,101 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// template <class InputIterator>
+// void insert(InputIterator first, InputIterator last);
+
+#include <map>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::multimap<int, double> M;
+ typedef std::pair<int, double> P;
+ P ar[] =
+ {
+ P(1, 1),
+ P(1, 1.5),
+ P(1, 2),
+ P(2, 1),
+ P(2, 1.5),
+ P(2, 2),
+ P(3, 1),
+ P(3, 1.5),
+ P(3, 2),
+ };
+ M m;
+ m.insert(input_iterator<P*>(ar), input_iterator<P*>(ar + sizeof(ar)/sizeof(ar[0])));
+ assert(m.size() == 9);
+ assert(m.begin()->first == 1);
+ assert(m.begin()->second == 1);
+ assert(next(m.begin())->first == 1);
+ assert(next(m.begin())->second == 1.5);
+ assert(next(m.begin(), 2)->first == 1);
+ assert(next(m.begin(), 2)->second == 2);
+ assert(next(m.begin(), 3)->first == 2);
+ assert(next(m.begin(), 3)->second == 1);
+ assert(next(m.begin(), 4)->first == 2);
+ assert(next(m.begin(), 4)->second == 1.5);
+ assert(next(m.begin(), 5)->first == 2);
+ assert(next(m.begin(), 5)->second == 2);
+ assert(next(m.begin(), 6)->first == 3);
+ assert(next(m.begin(), 6)->second == 1);
+ assert(next(m.begin(), 7)->first == 3);
+ assert(next(m.begin(), 7)->second == 1.5);
+ assert(next(m.begin(), 8)->first == 3);
+ assert(next(m.begin(), 8)->second == 2);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+ typedef std::pair<int, double> P;
+ P ar[] =
+ {
+ P(1, 1),
+ P(1, 1.5),
+ P(1, 2),
+ P(2, 1),
+ P(2, 1.5),
+ P(2, 2),
+ P(3, 1),
+ P(3, 1.5),
+ P(3, 2),
+ };
+ M m;
+ m.insert(input_iterator<P*>(ar), input_iterator<P*>(ar + sizeof(ar)/sizeof(ar[0])));
+ assert(m.size() == 9);
+ assert(m.begin()->first == 1);
+ assert(m.begin()->second == 1);
+ assert(next(m.begin())->first == 1);
+ assert(next(m.begin())->second == 1.5);
+ assert(next(m.begin(), 2)->first == 1);
+ assert(next(m.begin(), 2)->second == 2);
+ assert(next(m.begin(), 3)->first == 2);
+ assert(next(m.begin(), 3)->second == 1);
+ assert(next(m.begin(), 4)->first == 2);
+ assert(next(m.begin(), 4)->second == 1.5);
+ assert(next(m.begin(), 5)->first == 2);
+ assert(next(m.begin(), 5)->second == 2);
+ assert(next(m.begin(), 6)->first == 3);
+ assert(next(m.begin(), 6)->second == 1);
+ assert(next(m.begin(), 7)->first == 3);
+ assert(next(m.begin(), 7)->second == 1.5);
+ assert(next(m.begin(), 8)->first == 3);
+ assert(next(m.begin(), 8)->second == 2);
+ }
+#endif
+}
diff --git a/test/std/containers/associative/multimap/multimap.modifiers/insert_iter_rv.pass.cpp b/test/std/containers/associative/multimap/multimap.modifiers/insert_iter_rv.pass.cpp
new file mode 100644
index 000000000000..b44f46429ec8
--- /dev/null
+++ b/test/std/containers/associative/multimap/multimap.modifiers/insert_iter_rv.pass.cpp
@@ -0,0 +1,87 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// template <class P>
+// iterator insert(const_iterator position, P&& p);
+
+#include <map>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::multimap<int, MoveOnly> M;
+ typedef std::pair<int, MoveOnly> P;
+ typedef M::iterator R;
+ M m;
+ R r = m.insert(m.cend(), P(2, 2));
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(r->first == 2);
+ assert(r->second == 2);
+
+ r = m.insert(m.cend(), P(1, 1));
+ assert(r == m.begin());
+ assert(m.size() == 2);
+ assert(r->first == 1);
+ assert(r->second == 1);
+
+ r = m.insert(m.cend(), P(3, 3));
+ assert(r == prev(m.end()));
+ assert(m.size() == 3);
+ assert(r->first == 3);
+ assert(r->second == 3);
+
+ r = m.insert(m.cend(), P(3, 2));
+ assert(r == prev(m.end()));
+ assert(m.size() == 4);
+ assert(r->first == 3);
+ assert(r->second == 2);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::multimap<int, MoveOnly, std::less<int>, min_allocator<std::pair<const int, MoveOnly>>> M;
+ typedef std::pair<int, MoveOnly> P;
+ typedef M::iterator R;
+ M m;
+ R r = m.insert(m.cend(), P(2, 2));
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(r->first == 2);
+ assert(r->second == 2);
+
+ r = m.insert(m.cend(), P(1, 1));
+ assert(r == m.begin());
+ assert(m.size() == 2);
+ assert(r->first == 1);
+ assert(r->second == 1);
+
+ r = m.insert(m.cend(), P(3, 3));
+ assert(r == prev(m.end()));
+ assert(m.size() == 3);
+ assert(r->first == 3);
+ assert(r->second == 3);
+
+ r = m.insert(m.cend(), P(3, 2));
+ assert(r == prev(m.end()));
+ assert(m.size() == 4);
+ assert(r->first == 3);
+ assert(r->second == 2);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/associative/multimap/multimap.modifiers/insert_rv.pass.cpp b/test/std/containers/associative/multimap/multimap.modifiers/insert_rv.pass.cpp
new file mode 100644
index 000000000000..b1c043586d65
--- /dev/null
+++ b/test/std/containers/associative/multimap/multimap.modifiers/insert_rv.pass.cpp
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// template <class P>
+// iterator insert(P&& p);
+
+#include <map>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::multimap<int, MoveOnly> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.insert(M::value_type(2, 2));
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(r->first == 2);
+ assert(r->second == 2);
+
+ r = m.insert(M::value_type(1, 1));
+ assert(r == m.begin());
+ assert(m.size() == 2);
+ assert(r->first == 1);
+ assert(r->second == 1);
+
+ r = m.insert(M::value_type(3, 3));
+ assert(r == prev(m.end()));
+ assert(m.size() == 3);
+ assert(r->first == 3);
+ assert(r->second == 3);
+
+ r = m.insert(M::value_type(3, 3));
+ assert(r == prev(m.end()));
+ assert(m.size() == 4);
+ assert(r->first == 3);
+ assert(r->second == 3);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::multimap<int, MoveOnly, std::less<int>, min_allocator<std::pair<const int, MoveOnly>>> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.insert(M::value_type(2, 2));
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(r->first == 2);
+ assert(r->second == 2);
+
+ r = m.insert(M::value_type(1, 1));
+ assert(r == m.begin());
+ assert(m.size() == 2);
+ assert(r->first == 1);
+ assert(r->second == 1);
+
+ r = m.insert(M::value_type(3, 3));
+ assert(r == prev(m.end()));
+ assert(m.size() == 3);
+ assert(r->first == 3);
+ assert(r->second == 3);
+
+ r = m.insert(M::value_type(3, 3));
+ assert(r == prev(m.end()));
+ assert(m.size() == 4);
+ assert(r->first == 3);
+ assert(r->second == 3);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/associative/multimap/multimap.ops/count.pass.cpp b/test/std/containers/associative/multimap/multimap.ops/count.pass.cpp
new file mode 100644
index 000000000000..c666c295f3a0
--- /dev/null
+++ b/test/std/containers/associative/multimap/multimap.ops/count.pass.cpp
@@ -0,0 +1,175 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// size_type count(const key_type& k) const;
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "private_constructor.hpp"
+#include "is_transparent.h"
+
+int main()
+{
+ typedef std::pair<const int, double> V;
+ {
+ typedef std::multimap<int, double> M;
+ {
+ typedef M::size_type R;
+ V ar[] =
+ {
+ V(5, 1),
+ V(5, 2),
+ V(5, 3),
+ V(7, 1),
+ V(7, 2),
+ V(7, 3),
+ V(9, 1),
+ V(9, 2),
+ V(9, 3)
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.count(4);
+ assert(r == 0);
+ r = m.count(5);
+ assert(r == 3);
+ r = m.count(6);
+ assert(r == 0);
+ r = m.count(7);
+ assert(r == 3);
+ r = m.count(8);
+ assert(r == 0);
+ r = m.count(9);
+ assert(r == 3);
+ r = m.count(10);
+ assert(r == 0);
+ }
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+ {
+ typedef M::size_type R;
+ V ar[] =
+ {
+ V(5, 1),
+ V(5, 2),
+ V(5, 3),
+ V(7, 1),
+ V(7, 2),
+ V(7, 3),
+ V(9, 1),
+ V(9, 2),
+ V(9, 3)
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.count(4);
+ assert(r == 0);
+ r = m.count(5);
+ assert(r == 3);
+ r = m.count(6);
+ assert(r == 0);
+ r = m.count(7);
+ assert(r == 3);
+ r = m.count(8);
+ assert(r == 0);
+ r = m.count(9);
+ assert(r == 3);
+ r = m.count(10);
+ assert(r == 0);
+ }
+ }
+#endif
+
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::multimap<int, double, std::less<>> M;
+ typedef M::size_type R;
+ V ar[] =
+ {
+ V(5, 1),
+ V(5, 2),
+ V(5, 3),
+ V(7, 1),
+ V(7, 2),
+ V(7, 3),
+ V(9, 1),
+ V(9, 2),
+ V(9, 3)
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.count(4);
+ assert(r == 0);
+ r = m.count(5);
+ assert(r == 3);
+ r = m.count(6);
+ assert(r == 0);
+ r = m.count(7);
+ assert(r == 3);
+ r = m.count(8);
+ assert(r == 0);
+ r = m.count(9);
+ assert(r == 3);
+ r = m.count(10);
+ assert(r == 0);
+
+ r = m.count(C2Int(4));
+ assert(r == 0);
+ r = m.count(C2Int(5));
+ assert(r == 3);
+ r = m.count(C2Int(6));
+ assert(r == 0);
+ r = m.count(C2Int(7));
+ assert(r == 3);
+ r = m.count(C2Int(8));
+ assert(r == 0);
+ r = m.count(C2Int(9));
+ assert(r == 3);
+ r = m.count(C2Int(10));
+ assert(r == 0);
+ }
+
+ {
+ typedef PrivateConstructor PC;
+ typedef std::multimap<PC, double, std::less<>> M;
+ typedef M::size_type R;
+
+ M m;
+ m.insert ( std::make_pair<PC, double> ( PC::make(5), 1 ));
+ m.insert ( std::make_pair<PC, double> ( PC::make(5), 2 ));
+ m.insert ( std::make_pair<PC, double> ( PC::make(5), 3 ));
+ m.insert ( std::make_pair<PC, double> ( PC::make(7), 1 ));
+ m.insert ( std::make_pair<PC, double> ( PC::make(7), 2 ));
+ m.insert ( std::make_pair<PC, double> ( PC::make(7), 3 ));
+ m.insert ( std::make_pair<PC, double> ( PC::make(9), 1 ));
+ m.insert ( std::make_pair<PC, double> ( PC::make(9), 2 ));
+ m.insert ( std::make_pair<PC, double> ( PC::make(9), 3 ));
+
+ R r = m.count(4);
+ assert(r == 0);
+ r = m.count(5);
+ assert(r == 3);
+ r = m.count(6);
+ assert(r == 0);
+ r = m.count(7);
+ assert(r == 3);
+ r = m.count(8);
+ assert(r == 0);
+ r = m.count(9);
+ assert(r == 3);
+ r = m.count(10);
+ assert(r == 0);
+ }
+#endif
+}
diff --git a/test/std/containers/associative/multimap/multimap.ops/count0.pass.cpp b/test/std/containers/associative/multimap/multimap.ops/count0.pass.cpp
new file mode 100644
index 000000000000..7da13bb0d66d
--- /dev/null
+++ b/test/std/containers/associative/multimap/multimap.ops/count0.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// XFAIL: c++03, c++11
+
+// <map>
+
+// class multimap
+
+// iterator find(const key_type& k);
+// const_iterator find(const key_type& k) const;
+//
+// The member function templates find, count, lower_bound, upper_bound, and
+// equal_range shall not participate in overload resolution unless the
+// qualified-id Compare::is_transparent is valid and denotes a type
+
+
+#include <map>
+#include <cassert>
+
+#include "is_transparent.h"
+
+int main()
+{
+ typedef std::multimap<int, double, transparent_less> M;
+
+ M().count(C2Int{5});
+}
diff --git a/test/std/containers/associative/multimap/multimap.ops/count1.fail.cpp b/test/std/containers/associative/multimap/multimap.ops/count1.fail.cpp
new file mode 100644
index 000000000000..f30d1bfd88d6
--- /dev/null
+++ b/test/std/containers/associative/multimap/multimap.ops/count1.fail.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// iterator find(const key_type& k);
+// const_iterator find(const key_type& k) const;
+//
+// The member function templates find, count, lower_bound, upper_bound, and
+// equal_range shall not participate in overload resolution unless the
+// qualified-id Compare::is_transparent is valid and denotes a type
+
+
+#include <map>
+#include <cassert>
+
+#include "is_transparent.h"
+
+#if _LIBCPP_STD_VER <= 11
+#error "This test requires is C++14 (or later)"
+#else
+
+int main()
+{
+ typedef std::multimap<int, double, transparent_less_no_type> M;
+
+ M().count(C2Int{5});
+}
+#endif \ No newline at end of file
diff --git a/test/std/containers/associative/multimap/multimap.ops/count2.fail.cpp b/test/std/containers/associative/multimap/multimap.ops/count2.fail.cpp
new file mode 100644
index 000000000000..ffb7eb6a559a
--- /dev/null
+++ b/test/std/containers/associative/multimap/multimap.ops/count2.fail.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// iterator find(const key_type& k);
+// const_iterator find(const key_type& k) const;
+//
+// The member function templates find, count, lower_bound, upper_bound, and
+// equal_range shall not participate in overload resolution unless the
+// qualified-id Compare::is_transparent is valid and denotes a type
+
+
+#include <map>
+#include <cassert>
+
+#include "is_transparent.h"
+
+#if _LIBCPP_STD_VER <= 11
+#error "This test requires is C++14 (or later)"
+#else
+
+int main()
+{
+ typedef std::multimap<int, double, transparent_less_private> M;
+
+ M().count(C2Int{5});
+}
+#endif \ No newline at end of file
diff --git a/test/std/containers/associative/multimap/multimap.ops/count3.fail.cpp b/test/std/containers/associative/multimap/multimap.ops/count3.fail.cpp
new file mode 100644
index 000000000000..4bb9d14634f3
--- /dev/null
+++ b/test/std/containers/associative/multimap/multimap.ops/count3.fail.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// iterator find(const key_type& k);
+// const_iterator find(const key_type& k) const;
+//
+// The member function templates find, count, lower_bound, upper_bound, and
+// equal_range shall not participate in overload resolution unless the
+// qualified-id Compare::is_transparent is valid and denotes a type
+
+
+#include <map>
+#include <cassert>
+
+#include "is_transparent.h"
+
+#if _LIBCPP_STD_VER <= 11
+#error "This test requires is C++14 (or later)"
+#else
+
+int main()
+{
+ typedef std::multimap<int, double, transparent_less_not_a_type> M;
+
+ M().count(C2Int{5});
+}
+#endif \ No newline at end of file
diff --git a/test/std/containers/associative/multimap/multimap.ops/equal_range.pass.cpp b/test/std/containers/associative/multimap/multimap.ops/equal_range.pass.cpp
new file mode 100644
index 000000000000..5a071042461a
--- /dev/null
+++ b/test/std/containers/associative/multimap/multimap.ops/equal_range.pass.cpp
@@ -0,0 +1,287 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <multimap>
+
+// class multimap
+
+// pair<iterator, iterator> equal_range(const key_type& k);
+// pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "private_constructor.hpp"
+#include "is_transparent.h"
+
+int main()
+{
+ typedef std::pair<const int, double> V;
+ {
+ typedef std::multimap<int, double> M;
+ {
+ typedef std::pair<M::iterator, M::iterator> R;
+ V ar[] =
+ {
+ V(5, 1),
+ V(5, 2),
+ V(5, 3),
+ V(7, 1),
+ V(7, 2),
+ V(7, 3),
+ V(9, 1),
+ V(9, 2),
+ V(9, 3)
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.equal_range(4);
+ assert(r.first == m.begin());
+ assert(r.second == m.begin());
+ r = m.equal_range(5);
+ assert(r.first == m.begin());
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(6);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(7);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(8);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(9);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 9));
+ r = m.equal_range(10);
+ assert(r.first == m.end());
+ assert(r.second == m.end());
+ }
+ {
+ typedef std::pair<M::const_iterator, M::const_iterator> R;
+ V ar[] =
+ {
+ V(5, 1),
+ V(5, 2),
+ V(5, 3),
+ V(7, 1),
+ V(7, 2),
+ V(7, 3),
+ V(9, 1),
+ V(9, 2),
+ V(9, 3)
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.equal_range(4);
+ assert(r.first == m.begin());
+ assert(r.second == m.begin());
+ r = m.equal_range(5);
+ assert(r.first == m.begin());
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(6);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(7);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(8);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(9);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 9));
+ r = m.equal_range(10);
+ assert(r.first == m.end());
+ assert(r.second == m.end());
+ }
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+ {
+ typedef std::pair<M::iterator, M::iterator> R;
+ V ar[] =
+ {
+ V(5, 1),
+ V(5, 2),
+ V(5, 3),
+ V(7, 1),
+ V(7, 2),
+ V(7, 3),
+ V(9, 1),
+ V(9, 2),
+ V(9, 3)
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.equal_range(4);
+ assert(r.first == m.begin());
+ assert(r.second == m.begin());
+ r = m.equal_range(5);
+ assert(r.first == m.begin());
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(6);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(7);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(8);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(9);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 9));
+ r = m.equal_range(10);
+ assert(r.first == m.end());
+ assert(r.second == m.end());
+ }
+ {
+ typedef std::pair<M::const_iterator, M::const_iterator> R;
+ V ar[] =
+ {
+ V(5, 1),
+ V(5, 2),
+ V(5, 3),
+ V(7, 1),
+ V(7, 2),
+ V(7, 3),
+ V(9, 1),
+ V(9, 2),
+ V(9, 3)
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.equal_range(4);
+ assert(r.first == m.begin());
+ assert(r.second == m.begin());
+ r = m.equal_range(5);
+ assert(r.first == m.begin());
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(6);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(7);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(8);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(9);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 9));
+ r = m.equal_range(10);
+ assert(r.first == m.end());
+ assert(r.second == m.end());
+ }
+ }
+#endif
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::pair<const int, double> V;
+ typedef std::multimap<int, double, std::less<>> M;
+
+ typedef std::pair<M::iterator, M::iterator> R;
+ V ar[] =
+ {
+ V(5, 1),
+ V(5, 2),
+ V(5, 3),
+ V(7, 1),
+ V(7, 2),
+ V(7, 3),
+ V(9, 1),
+ V(9, 2),
+ V(9, 3)
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.equal_range(4);
+ assert(r.first == m.begin());
+ assert(r.second == m.begin());
+ r = m.equal_range(5);
+ assert(r.first == m.begin());
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(6);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(7);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(8);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(9);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 9));
+ r = m.equal_range(10);
+ assert(r.first == m.end());
+ assert(r.second == m.end());
+
+ r = m.equal_range(C2Int(4));
+ assert(r.first == m.begin());
+ assert(r.second == m.begin());
+ r = m.equal_range(C2Int(5));
+ assert(r.first == m.begin());
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(C2Int(6));
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(C2Int(7));
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(C2Int(8));
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(C2Int(9));
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 9));
+ r = m.equal_range(C2Int(10));
+ assert(r.first == m.end());
+ assert(r.second == m.end());
+ }
+
+ {
+ typedef PrivateConstructor PC;
+ typedef std::multimap<PC, double, std::less<>> M;
+ typedef std::pair<M::iterator, M::iterator> R;
+
+ M m;
+ m.insert ( std::make_pair<PC, double> ( PC::make(5), 1 ));
+ m.insert ( std::make_pair<PC, double> ( PC::make(5), 2 ));
+ m.insert ( std::make_pair<PC, double> ( PC::make(5), 3 ));
+ m.insert ( std::make_pair<PC, double> ( PC::make(7), 1 ));
+ m.insert ( std::make_pair<PC, double> ( PC::make(7), 2 ));
+ m.insert ( std::make_pair<PC, double> ( PC::make(7), 3 ));
+ m.insert ( std::make_pair<PC, double> ( PC::make(9), 1 ));
+ m.insert ( std::make_pair<PC, double> ( PC::make(9), 2 ));
+ m.insert ( std::make_pair<PC, double> ( PC::make(9), 3 ));
+
+// assert(m.size() == 9);
+ R r = m.equal_range(4);
+ assert(r.first == m.begin());
+ assert(r.second == m.begin());
+ r = m.equal_range(5);
+ assert(r.first == m.begin());
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(6);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(7);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(8);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(9);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 9));
+ r = m.equal_range(10);
+ assert(r.first == m.end());
+ assert(r.second == m.end());
+ }
+#endif
+}
diff --git a/test/std/containers/associative/multimap/multimap.ops/equal_range0.pass.cpp b/test/std/containers/associative/multimap/multimap.ops/equal_range0.pass.cpp
new file mode 100644
index 000000000000..c0f07468ec5e
--- /dev/null
+++ b/test/std/containers/associative/multimap/multimap.ops/equal_range0.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// XFAIL: c++03, c++11
+
+// <map>
+
+// class multimap
+
+// iterator find(const key_type& k);
+// const_iterator find(const key_type& k) const;
+//
+// The member function templates find, count, lower_bound, upper_bound, and
+// equal_range shall not participate in overload resolution unless the
+// qualified-id Compare::is_transparent is valid and denotes a type
+
+
+#include <map>
+#include <cassert>
+
+#include "is_transparent.h"
+
+int main()
+{
+ typedef std::multimap<int, double, transparent_less> M;
+
+ M().equal_range(C2Int{5});
+}
diff --git a/test/std/containers/associative/multimap/multimap.ops/equal_range1.fail.cpp b/test/std/containers/associative/multimap/multimap.ops/equal_range1.fail.cpp
new file mode 100644
index 000000000000..f022e94324fd
--- /dev/null
+++ b/test/std/containers/associative/multimap/multimap.ops/equal_range1.fail.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// iterator find(const key_type& k);
+// const_iterator find(const key_type& k) const;
+//
+// The member function templates find, count, lower_bound, upper_bound, and
+// equal_range shall not participate in overload resolution unless the
+// qualified-id Compare::is_transparent is valid and denotes a type
+
+
+#include <map>
+#include <cassert>
+
+#include "is_transparent.h"
+
+#if _LIBCPP_STD_VER <= 11
+#error "This test requires is C++14 (or later)"
+#else
+
+int main()
+{
+ typedef std::multimap<int, double, transparent_less_no_type> M;
+
+ M().equal_range(C2Int{5});
+}
+#endif \ No newline at end of file
diff --git a/test/std/containers/associative/multimap/multimap.ops/equal_range2.fail.cpp b/test/std/containers/associative/multimap/multimap.ops/equal_range2.fail.cpp
new file mode 100644
index 000000000000..695e71703e3b
--- /dev/null
+++ b/test/std/containers/associative/multimap/multimap.ops/equal_range2.fail.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// iterator find(const key_type& k);
+// const_iterator find(const key_type& k) const;
+//
+// The member function templates find, count, lower_bound, upper_bound, and
+// equal_range shall not participate in overload resolution unless the
+// qualified-id Compare::is_transparent is valid and denotes a type
+
+
+#include <map>
+#include <cassert>
+
+#include "is_transparent.h"
+
+#if _LIBCPP_STD_VER <= 11
+#error "This test requires is C++14 (or later)"
+#else
+
+int main()
+{
+ {
+ typedef std::multimap<int, double, transparent_less_private> M;
+
+ M().equal_range(C2Int{5});
+ }
+}
+#endif \ No newline at end of file
diff --git a/test/std/containers/associative/multimap/multimap.ops/equal_range3.fail.cpp b/test/std/containers/associative/multimap/multimap.ops/equal_range3.fail.cpp
new file mode 100644
index 000000000000..59c2855e8f69
--- /dev/null
+++ b/test/std/containers/associative/multimap/multimap.ops/equal_range3.fail.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// iterator find(const key_type& k);
+// const_iterator find(const key_type& k) const;
+//
+// The member function templates find, count, lower_bound, upper_bound, and
+// equal_range shall not participate in overload resolution unless the
+// qualified-id Compare::is_transparent is valid and denotes a type
+
+
+#include <map>
+#include <cassert>
+
+#include "is_transparent.h"
+
+#if _LIBCPP_STD_VER <= 11
+#error "This test requires is C++14 (or later)"
+#else
+
+int main()
+{
+ {
+ typedef std::multimap<int, double, transparent_less_not_a_type> M;
+
+ M().equal_range(C2Int{5});
+ }
+}
+#endif \ No newline at end of file
diff --git a/test/std/containers/associative/multimap/multimap.ops/find.pass.cpp b/test/std/containers/associative/multimap/multimap.ops/find.pass.cpp
new file mode 100644
index 000000000000..a60e42cf8592
--- /dev/null
+++ b/test/std/containers/associative/multimap/multimap.ops/find.pass.cpp
@@ -0,0 +1,223 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// iterator find(const key_type& k);
+// const_iterator find(const key_type& k) const;
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "private_constructor.hpp"
+#include "is_transparent.h"
+
+int main()
+{
+ typedef std::pair<const int, double> V;
+ {
+ typedef std::multimap<int, double> M;
+ {
+ typedef M::iterator R;
+ V ar[] =
+ {
+ V(5, 1),
+ V(5, 2),
+ V(5, 3),
+ V(7, 1),
+ V(7, 2),
+ V(7, 3),
+ V(9, 1),
+ V(9, 2),
+ V(9, 3)
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.find(5);
+ assert(r == m.begin());
+ r = m.find(6);
+ assert(r == m.end());
+ r = m.find(7);
+ assert(r == next(m.begin(), 3));
+ r = m.find(8);
+ assert(r == m.end());
+ r = m.find(9);
+ assert(r == next(m.begin(), 6));
+ r = m.find(10);
+ assert(r == m.end());
+ }
+ {
+ typedef M::const_iterator R;
+ V ar[] =
+ {
+ V(5, 1),
+ V(5, 2),
+ V(5, 3),
+ V(7, 1),
+ V(7, 2),
+ V(7, 3),
+ V(9, 1),
+ V(9, 2),
+ V(9, 3)
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.find(5);
+ assert(r == m.begin());
+ r = m.find(6);
+ assert(r == m.end());
+ r = m.find(7);
+ assert(r == next(m.begin(), 3));
+ r = m.find(8);
+ assert(r == m.end());
+ r = m.find(9);
+ assert(r == next(m.begin(), 6));
+ r = m.find(10);
+ assert(r == m.end());
+ }
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+ {
+ typedef M::iterator R;
+ V ar[] =
+ {
+ V(5, 1),
+ V(5, 2),
+ V(5, 3),
+ V(7, 1),
+ V(7, 2),
+ V(7, 3),
+ V(9, 1),
+ V(9, 2),
+ V(9, 3)
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.find(5);
+ assert(r == m.begin());
+ r = m.find(6);
+ assert(r == m.end());
+ r = m.find(7);
+ assert(r == next(m.begin(), 3));
+ r = m.find(8);
+ assert(r == m.end());
+ r = m.find(9);
+ assert(r == next(m.begin(), 6));
+ r = m.find(10);
+ assert(r == m.end());
+ }
+ {
+ typedef M::const_iterator R;
+ V ar[] =
+ {
+ V(5, 1),
+ V(5, 2),
+ V(5, 3),
+ V(7, 1),
+ V(7, 2),
+ V(7, 3),
+ V(9, 1),
+ V(9, 2),
+ V(9, 3)
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.find(5);
+ assert(r == m.begin());
+ r = m.find(6);
+ assert(r == m.end());
+ r = m.find(7);
+ assert(r == next(m.begin(), 3));
+ r = m.find(8);
+ assert(r == m.end());
+ r = m.find(9);
+ assert(r == next(m.begin(), 6));
+ r = m.find(10);
+ assert(r == m.end());
+ }
+ }
+#endif
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::pair<const int, double> V;
+ typedef std::multimap<int, double, std::less<>> M;
+ typedef M::iterator R;
+
+ V ar[] =
+ {
+ V(5, 1),
+ V(5, 2),
+ V(5, 3),
+ V(7, 1),
+ V(7, 2),
+ V(7, 3),
+ V(9, 1),
+ V(9, 2),
+ V(9, 3)
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.find(5);
+ assert(r == m.begin());
+ r = m.find(6);
+ assert(r == m.end());
+ r = m.find(7);
+ assert(r == next(m.begin(), 3));
+ r = m.find(8);
+ assert(r == m.end());
+ r = m.find(9);
+ assert(r == next(m.begin(), 6));
+ r = m.find(10);
+ assert(r == m.end());
+
+ r = m.find(C2Int(5));
+ assert(r == m.begin());
+ r = m.find(C2Int(6));
+ assert(r == m.end());
+ r = m.find(C2Int(7));
+ assert(r == next(m.begin(), 3));
+ r = m.find(C2Int(8));
+ assert(r == m.end());
+ r = m.find(C2Int(9));
+ assert(r == next(m.begin(), 6));
+ r = m.find(C2Int(10));
+ assert(r == m.end());
+ }
+
+ {
+ typedef PrivateConstructor PC;
+ typedef std::multimap<PC, double, std::less<>> M;
+ typedef M::iterator R;
+
+ M m;
+ m.insert ( std::make_pair<PC, double> ( PC::make(5), 1 ));
+ m.insert ( std::make_pair<PC, double> ( PC::make(5), 2 ));
+ m.insert ( std::make_pair<PC, double> ( PC::make(5), 3 ));
+ m.insert ( std::make_pair<PC, double> ( PC::make(7), 1 ));
+ m.insert ( std::make_pair<PC, double> ( PC::make(7), 2 ));
+ m.insert ( std::make_pair<PC, double> ( PC::make(7), 3 ));
+ m.insert ( std::make_pair<PC, double> ( PC::make(9), 1 ));
+ m.insert ( std::make_pair<PC, double> ( PC::make(9), 2 ));
+ m.insert ( std::make_pair<PC, double> ( PC::make(9), 3 ));
+
+ R r = m.find(5);
+ assert(r == m.begin());
+ r = m.find(6);
+ assert(r == m.end());
+ r = m.find(7);
+ assert(r == next(m.begin(), 3));
+ r = m.find(8);
+ assert(r == m.end());
+ r = m.find(9);
+ assert(r == next(m.begin(), 6));
+ r = m.find(10);
+ assert(r == m.end());
+ }
+#endif
+}
diff --git a/test/std/containers/associative/multimap/multimap.ops/find0.pass.cpp b/test/std/containers/associative/multimap/multimap.ops/find0.pass.cpp
new file mode 100644
index 000000000000..4f3369870c8f
--- /dev/null
+++ b/test/std/containers/associative/multimap/multimap.ops/find0.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// XFAIL: c++03, c++11
+
+// <map>
+
+// class multimap
+
+// iterator find(const key_type& k);
+// const_iterator find(const key_type& k) const;
+//
+// The member function templates find, count, lower_bound, upper_bound, and
+// equal_range shall not participate in overload resolution unless the
+// qualified-id Compare::is_transparent is valid and denotes a type
+
+
+#include <map>
+#include <cassert>
+
+#include "is_transparent.h"
+
+int main()
+{
+ typedef std::multimap<int, double, transparent_less> M;
+
+ M().find(C2Int{5});
+}
diff --git a/test/std/containers/associative/multimap/multimap.ops/find1.fail.cpp b/test/std/containers/associative/multimap/multimap.ops/find1.fail.cpp
new file mode 100644
index 000000000000..e1eef034064d
--- /dev/null
+++ b/test/std/containers/associative/multimap/multimap.ops/find1.fail.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// iterator find(const key_type& k);
+// const_iterator find(const key_type& k) const;
+//
+// The member function templates find, count, lower_bound, upper_bound, and
+// equal_range shall not participate in overload resolution unless the
+// qualified-id Compare::is_transparent is valid and denotes a type
+
+
+#include <map>
+#include <cassert>
+
+#include "is_transparent.h"
+
+#if _LIBCPP_STD_VER <= 11
+#error "This test requires is C++14 (or later)"
+#else
+
+int main()
+{
+ {
+ typedef std::multimap<int, double, transparent_less_no_type> M;
+
+ M().find(C2Int{5});
+ }
+}
+#endif \ No newline at end of file
diff --git a/test/std/containers/associative/multimap/multimap.ops/find2.fail.cpp b/test/std/containers/associative/multimap/multimap.ops/find2.fail.cpp
new file mode 100644
index 000000000000..4c03f583fa1c
--- /dev/null
+++ b/test/std/containers/associative/multimap/multimap.ops/find2.fail.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// iterator find(const key_type& k);
+// const_iterator find(const key_type& k) const;
+//
+// The member function templates find, count, lower_bound, upper_bound, and
+// equal_range shall not participate in overload resolution unless the
+// qualified-id Compare::is_transparent is valid and denotes a type
+
+
+#include <map>
+#include <cassert>
+
+#include "is_transparent.h"
+
+#if _LIBCPP_STD_VER <= 11
+#error "This test requires is C++14 (or later)"
+#else
+
+int main()
+{
+ {
+ typedef std::multimap<int, double, transparent_less_private> M;
+
+ M().find(C2Int{5});
+ }
+}
+#endif \ No newline at end of file
diff --git a/test/std/containers/associative/multimap/multimap.ops/find3.fail.cpp b/test/std/containers/associative/multimap/multimap.ops/find3.fail.cpp
new file mode 100644
index 000000000000..f10bc60aa864
--- /dev/null
+++ b/test/std/containers/associative/multimap/multimap.ops/find3.fail.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// iterator find(const key_type& k);
+// const_iterator find(const key_type& k) const;
+//
+// The member function templates find, count, lower_bound, upper_bound, and
+// equal_range shall not participate in overload resolution unless the
+// qualified-id Compare::is_transparent is valid and denotes a type
+
+
+#include <map>
+#include <cassert>
+
+#include "is_transparent.h"
+
+#if _LIBCPP_STD_VER <= 11
+#error "This test requires is C++14 (or later)"
+#else
+
+int main()
+{
+ {
+ typedef std::multimap<int, double, transparent_less_not_a_type> M;
+
+ M().find(C2Int{5});
+ }
+}
+#endif \ No newline at end of file
diff --git a/test/std/containers/associative/multimap/multimap.ops/lower_bound.pass.cpp b/test/std/containers/associative/multimap/multimap.ops/lower_bound.pass.cpp
new file mode 100644
index 000000000000..38b931802f8e
--- /dev/null
+++ b/test/std/containers/associative/multimap/multimap.ops/lower_bound.pass.cpp
@@ -0,0 +1,237 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// iterator lower_bound(const key_type& k);
+// const_iterator lower_bound(const key_type& k) const;
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "private_constructor.hpp"
+#include "is_transparent.h"
+
+int main()
+{
+ typedef std::pair<const int, double> V;
+ {
+ typedef std::multimap<int, double> M;
+ {
+ typedef M::iterator R;
+ V ar[] =
+ {
+ V(5, 1),
+ V(5, 2),
+ V(5, 3),
+ V(7, 1),
+ V(7, 2),
+ V(7, 3),
+ V(9, 1),
+ V(9, 2),
+ V(9, 3)
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.lower_bound(4);
+ assert(r == m.begin());
+ r = m.lower_bound(5);
+ assert(r == m.begin());
+ r = m.lower_bound(6);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(7);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(8);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(9);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(10);
+ assert(r == m.end());
+ }
+ {
+ typedef M::const_iterator R;
+ V ar[] =
+ {
+ V(5, 1),
+ V(5, 2),
+ V(5, 3),
+ V(7, 1),
+ V(7, 2),
+ V(7, 3),
+ V(9, 1),
+ V(9, 2),
+ V(9, 3)
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.lower_bound(4);
+ assert(r == m.begin());
+ r = m.lower_bound(5);
+ assert(r == m.begin());
+ r = m.lower_bound(6);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(7);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(8);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(9);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(10);
+ assert(r == m.end());
+ }
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+ {
+ typedef M::iterator R;
+ V ar[] =
+ {
+ V(5, 1),
+ V(5, 2),
+ V(5, 3),
+ V(7, 1),
+ V(7, 2),
+ V(7, 3),
+ V(9, 1),
+ V(9, 2),
+ V(9, 3)
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.lower_bound(4);
+ assert(r == m.begin());
+ r = m.lower_bound(5);
+ assert(r == m.begin());
+ r = m.lower_bound(6);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(7);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(8);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(9);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(10);
+ assert(r == m.end());
+ }
+ {
+ typedef M::const_iterator R;
+ V ar[] =
+ {
+ V(5, 1),
+ V(5, 2),
+ V(5, 3),
+ V(7, 1),
+ V(7, 2),
+ V(7, 3),
+ V(9, 1),
+ V(9, 2),
+ V(9, 3)
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.lower_bound(4);
+ assert(r == m.begin());
+ r = m.lower_bound(5);
+ assert(r == m.begin());
+ r = m.lower_bound(6);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(7);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(8);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(9);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(10);
+ assert(r == m.end());
+ }
+ }
+#endif
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::pair<const int, double> V;
+ typedef std::multimap<int, double, std::less<>> M;
+ typedef M::iterator R;
+ V ar[] =
+ {
+ V(5, 1),
+ V(5, 2),
+ V(5, 3),
+ V(7, 1),
+ V(7, 2),
+ V(7, 3),
+ V(9, 1),
+ V(9, 2),
+ V(9, 3)
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.lower_bound(4);
+ assert(r == m.begin());
+ r = m.lower_bound(5);
+ assert(r == m.begin());
+ r = m.lower_bound(6);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(7);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(8);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(9);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(10);
+ assert(r == m.end());
+
+ r = m.lower_bound(C2Int(4));
+ assert(r == m.begin());
+ r = m.lower_bound(C2Int(5));
+ assert(r == m.begin());
+ r = m.lower_bound(C2Int(6));
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(C2Int(7));
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(C2Int(8));
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(C2Int(9));
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(C2Int(10));
+ assert(r == m.end());
+ }
+
+ {
+ typedef PrivateConstructor PC;
+ typedef std::multimap<PC, double, std::less<>> M;
+ typedef M::iterator R;
+
+ M m;
+ m.insert ( std::make_pair<PC, double> ( PC::make(5), 1 ));
+ m.insert ( std::make_pair<PC, double> ( PC::make(5), 2 ));
+ m.insert ( std::make_pair<PC, double> ( PC::make(5), 3 ));
+ m.insert ( std::make_pair<PC, double> ( PC::make(7), 1 ));
+ m.insert ( std::make_pair<PC, double> ( PC::make(7), 2 ));
+ m.insert ( std::make_pair<PC, double> ( PC::make(7), 3 ));
+ m.insert ( std::make_pair<PC, double> ( PC::make(9), 1 ));
+ m.insert ( std::make_pair<PC, double> ( PC::make(9), 2 ));
+ m.insert ( std::make_pair<PC, double> ( PC::make(9), 3 ));
+
+ R r = m.lower_bound(4);
+ assert(r == m.begin());
+ r = m.lower_bound(5);
+ assert(r == m.begin());
+ r = m.lower_bound(6);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(7);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(8);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(9);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(10);
+ assert(r == m.end());
+ }
+
+#endif
+}
diff --git a/test/std/containers/associative/multimap/multimap.ops/lower_bound0.pass.cpp b/test/std/containers/associative/multimap/multimap.ops/lower_bound0.pass.cpp
new file mode 100644
index 000000000000..c5271f65d7e5
--- /dev/null
+++ b/test/std/containers/associative/multimap/multimap.ops/lower_bound0.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// XFAIL: c++03, c++11
+
+// <map>
+
+// class multimap
+
+// iterator lower_bound(const key_type& k);
+// const_iterator lower_bound(const key_type& k) const;
+//
+// The member function templates find, count, lower_bound, upper_bound, and
+// equal_range shall not participate in overload resolution unless the
+// qualified-id Compare::is_transparent is valid and denotes a type
+
+
+#include <map>
+#include <cassert>
+
+#include "is_transparent.h"
+
+int main()
+{
+ typedef std::multimap<int, double, transparent_less> M;
+
+ M().lower_bound(C2Int{5});
+}
diff --git a/test/std/containers/associative/multimap/multimap.ops/lower_bound1.fail.cpp b/test/std/containers/associative/multimap/multimap.ops/lower_bound1.fail.cpp
new file mode 100644
index 000000000000..b452be864e2b
--- /dev/null
+++ b/test/std/containers/associative/multimap/multimap.ops/lower_bound1.fail.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// iterator lower_bound(const key_type& k);
+// const_iterator lower_bound(const key_type& k) const;
+//
+// The member function templates find, count, lower_bound, upper_bound, and
+// equal_range shall not participate in overload resolution unless the
+// qualified-id Compare::is_transparent is valid and denotes a type
+
+
+#include <map>
+#include <cassert>
+
+#include "is_transparent.h"
+
+#if _LIBCPP_STD_VER <= 11
+#error "This test requires is C++14 (or later)"
+#else
+
+int main()
+{
+ {
+ typedef std::multimap<int, double, transparent_less_no_type> M;
+
+ M().lower_bound(C2Int{5});
+ }
+}
+#endif
diff --git a/test/std/containers/associative/multimap/multimap.ops/lower_bound2.fail.cpp b/test/std/containers/associative/multimap/multimap.ops/lower_bound2.fail.cpp
new file mode 100644
index 000000000000..a2ba30236a40
--- /dev/null
+++ b/test/std/containers/associative/multimap/multimap.ops/lower_bound2.fail.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// iterator lower_bound(const key_type& k);
+// const_iterator lower_bound(const key_type& k) const;
+//
+// The member function templates find, count, lower_bound, upper_bound, and
+// equal_range shall not participate in overload resolution unless the
+// qualified-id Compare::is_transparent is valid and denotes a type
+
+
+#include <map>
+#include <cassert>
+
+#include "is_transparent.h"
+
+#if _LIBCPP_STD_VER <= 11
+#error "This test requires is C++14 (or later)"
+#else
+
+int main()
+{
+ {
+ typedef std::multimap<int, double, transparent_less_private> M;
+
+ M().lower_bound(C2Int{5});
+ }
+}
+#endif
diff --git a/test/std/containers/associative/multimap/multimap.ops/lower_bound3.fail.cpp b/test/std/containers/associative/multimap/multimap.ops/lower_bound3.fail.cpp
new file mode 100644
index 000000000000..50d9fca91ad9
--- /dev/null
+++ b/test/std/containers/associative/multimap/multimap.ops/lower_bound3.fail.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// iterator lower_bound(const key_type& k);
+// const_iterator lower_bound(const key_type& k) const;
+//
+// The member function templates find, count, lower_bound, upper_bound, and
+// equal_range shall not participate in overload resolution unless the
+// qualified-id Compare::is_transparent is valid and denotes a type
+
+
+#include <map>
+#include <cassert>
+
+#include "is_transparent.h"
+
+#if _LIBCPP_STD_VER <= 11
+#error "This test requires is C++14 (or later)"
+#else
+
+int main()
+{
+ {
+ typedef std::multimap<int, double, transparent_less_not_a_type> M;
+
+ M().lower_bound(C2Int{5});
+ }
+}
+#endif
diff --git a/test/std/containers/associative/multimap/multimap.ops/upper_bound.pass.cpp b/test/std/containers/associative/multimap/multimap.ops/upper_bound.pass.cpp
new file mode 100644
index 000000000000..7c647a9426cb
--- /dev/null
+++ b/test/std/containers/associative/multimap/multimap.ops/upper_bound.pass.cpp
@@ -0,0 +1,236 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// iterator upper_bound(const key_type& k);
+// const_iterator upper_bound(const key_type& k) const;
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "private_constructor.hpp"
+#include "is_transparent.h"
+
+int main()
+{
+ typedef std::pair<const int, double> V;
+ {
+ typedef std::multimap<int, double> M;
+ {
+ typedef M::iterator R;
+ V ar[] =
+ {
+ V(5, 1),
+ V(5, 2),
+ V(5, 3),
+ V(7, 1),
+ V(7, 2),
+ V(7, 3),
+ V(9, 1),
+ V(9, 2),
+ V(9, 3)
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.upper_bound(4);
+ assert(r == m.begin());
+ r = m.upper_bound(5);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(6);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(7);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(8);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(9);
+ assert(r == next(m.begin(), 9));
+ r = m.upper_bound(10);
+ assert(r == m.end());
+ }
+ {
+ typedef M::const_iterator R;
+ V ar[] =
+ {
+ V(5, 1),
+ V(5, 2),
+ V(5, 3),
+ V(7, 1),
+ V(7, 2),
+ V(7, 3),
+ V(9, 1),
+ V(9, 2),
+ V(9, 3)
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.upper_bound(4);
+ assert(r == m.begin());
+ r = m.upper_bound(5);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(6);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(7);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(8);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(9);
+ assert(r == next(m.begin(), 9));
+ r = m.upper_bound(10);
+ assert(r == m.end());
+ }
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+ {
+ typedef M::iterator R;
+ V ar[] =
+ {
+ V(5, 1),
+ V(5, 2),
+ V(5, 3),
+ V(7, 1),
+ V(7, 2),
+ V(7, 3),
+ V(9, 1),
+ V(9, 2),
+ V(9, 3)
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.upper_bound(4);
+ assert(r == m.begin());
+ r = m.upper_bound(5);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(6);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(7);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(8);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(9);
+ assert(r == next(m.begin(), 9));
+ r = m.upper_bound(10);
+ assert(r == m.end());
+ }
+ {
+ typedef M::const_iterator R;
+ V ar[] =
+ {
+ V(5, 1),
+ V(5, 2),
+ V(5, 3),
+ V(7, 1),
+ V(7, 2),
+ V(7, 3),
+ V(9, 1),
+ V(9, 2),
+ V(9, 3)
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.upper_bound(4);
+ assert(r == m.begin());
+ r = m.upper_bound(5);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(6);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(7);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(8);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(9);
+ assert(r == next(m.begin(), 9));
+ r = m.upper_bound(10);
+ assert(r == m.end());
+ }
+ }
+#endif
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::pair<const int, double> V;
+ typedef std::multimap<int, double, std::less<>> M;
+ typedef M::iterator R;
+ V ar[] =
+ {
+ V(5, 1),
+ V(5, 2),
+ V(5, 3),
+ V(7, 1),
+ V(7, 2),
+ V(7, 3),
+ V(9, 1),
+ V(9, 2),
+ V(9, 3)
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.upper_bound(4);
+ assert(r == m.begin());
+ r = m.upper_bound(5);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(6);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(7);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(8);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(9);
+ assert(r == next(m.begin(), 9));
+ r = m.upper_bound(10);
+ assert(r == m.end());
+
+ r = m.upper_bound(C2Int(4));
+ assert(r == m.begin());
+ r = m.upper_bound(C2Int(5));
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(C2Int(6));
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(C2Int(7));
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(C2Int(8));
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(C2Int(9));
+ assert(r == next(m.begin(), 9));
+ r = m.upper_bound(C2Int(10));
+ }
+
+ {
+ typedef PrivateConstructor PC;
+ typedef std::multimap<PC, double, std::less<>> M;
+ typedef M::iterator R;
+
+ M m;
+ m.insert ( std::make_pair<PC, double> ( PC::make(5), 1 ));
+ m.insert ( std::make_pair<PC, double> ( PC::make(5), 2 ));
+ m.insert ( std::make_pair<PC, double> ( PC::make(5), 3 ));
+ m.insert ( std::make_pair<PC, double> ( PC::make(7), 1 ));
+ m.insert ( std::make_pair<PC, double> ( PC::make(7), 2 ));
+ m.insert ( std::make_pair<PC, double> ( PC::make(7), 3 ));
+ m.insert ( std::make_pair<PC, double> ( PC::make(9), 1 ));
+ m.insert ( std::make_pair<PC, double> ( PC::make(9), 2 ));
+ m.insert ( std::make_pair<PC, double> ( PC::make(9), 3 ));
+
+ R r = m.upper_bound(4);
+ assert(r == m.begin());
+ r = m.upper_bound(5);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(6);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(7);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(8);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(9);
+ assert(r == next(m.begin(), 9));
+ r = m.upper_bound(10);
+ assert(r == m.end());
+ }
+
+#endif
+}
diff --git a/test/std/containers/associative/multimap/multimap.ops/upper_bound0.pass.cpp b/test/std/containers/associative/multimap/multimap.ops/upper_bound0.pass.cpp
new file mode 100644
index 000000000000..322c6f55130c
--- /dev/null
+++ b/test/std/containers/associative/multimap/multimap.ops/upper_bound0.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// XFAIL: c++03, c++11
+
+// <map>
+
+// class multimap
+
+// iterator upper_bound(const key_type& k);
+// const_iterator upper_bound(const key_type& k) const;
+//
+// The member function templates find, count, lower_bound, upper_bound, and
+// equal_range shall not participate in overload resolution unless the
+// qualified-id Compare::is_transparent is valid and denotes a type
+
+
+#include <map>
+#include <cassert>
+
+#include "is_transparent.h"
+
+int main()
+{
+ typedef std::multimap<int, double, transparent_less> M;
+
+ M().upper_bound(C2Int{5});
+}
diff --git a/test/std/containers/associative/multimap/multimap.ops/upper_bound1.fail.cpp b/test/std/containers/associative/multimap/multimap.ops/upper_bound1.fail.cpp
new file mode 100644
index 000000000000..bb78ad698160
--- /dev/null
+++ b/test/std/containers/associative/multimap/multimap.ops/upper_bound1.fail.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// iterator upper_bound(const key_type& k);
+// const_iterator upper_bound(const key_type& k) const;
+//
+// The member function templates find, count, lower_bound, upper_bound, and
+// equal_range shall not participate in overload resolution unless the
+// qualified-id Compare::is_transparent is valid and denotes a type
+
+
+#include <map>
+#include <cassert>
+
+#include "is_transparent.h"
+
+#if _LIBCPP_STD_VER <= 11
+#error "This test requires is C++14 (or later)"
+#else
+
+int main()
+{
+ {
+ typedef std::multimap<int, double, transparent_less_no_type> M;
+
+ M().upper_bound(C2Int{5});
+ }
+}
+#endif
diff --git a/test/std/containers/associative/multimap/multimap.ops/upper_bound2.fail.cpp b/test/std/containers/associative/multimap/multimap.ops/upper_bound2.fail.cpp
new file mode 100644
index 000000000000..a79d5938e56e
--- /dev/null
+++ b/test/std/containers/associative/multimap/multimap.ops/upper_bound2.fail.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// iterator upper_bound(const key_type& k);
+// const_iterator upper_bound(const key_type& k) const;
+//
+// The member function templates find, count, lower_bound, upper_bound, and
+// equal_range shall not participate in overload resolution unless the
+// qualified-id Compare::is_transparent is valid and denotes a type
+
+
+#include <map>
+#include <cassert>
+
+#include "is_transparent.h"
+
+#if _LIBCPP_STD_VER <= 11
+#error "This test requires is C++14 (or later)"
+#else
+
+int main()
+{
+ {
+ typedef std::multimap<int, double, transparent_less_private> M;
+
+ M().upper_bound(C2Int{5});
+ }
+}
+#endif
diff --git a/test/std/containers/associative/multimap/multimap.ops/upper_bound3.fail.cpp b/test/std/containers/associative/multimap/multimap.ops/upper_bound3.fail.cpp
new file mode 100644
index 000000000000..1c1dc74b72c7
--- /dev/null
+++ b/test/std/containers/associative/multimap/multimap.ops/upper_bound3.fail.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// iterator upper_bound(const key_type& k);
+// const_iterator upper_bound(const key_type& k) const;
+//
+// The member function templates find, count, lower_bound, upper_bound, and
+// equal_range shall not participate in overload resolution unless the
+// qualified-id Compare::is_transparent is valid and denotes a type
+
+
+#include <map>
+#include <cassert>
+
+#include "is_transparent.h"
+
+#if _LIBCPP_STD_VER <= 11
+#error "This test requires is C++14 (or later)"
+#else
+
+int main()
+{
+ {
+ typedef std::multimap<int, double, transparent_less_not_a_type> M;
+
+ M().upper_bound(C2Int{5});
+ }
+}
+#endif
diff --git a/test/std/containers/associative/multimap/multimap.special/member_swap.pass.cpp b/test/std/containers/associative/multimap/multimap.special/member_swap.pass.cpp
new file mode 100644
index 000000000000..fb17e7340bd4
--- /dev/null
+++ b/test/std/containers/associative/multimap/multimap.special/member_swap.pass.cpp
@@ -0,0 +1,176 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// void swap(multimap& m);
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ typedef std::pair<const int, double> V;
+ {
+ typedef std::multimap<int, double> M;
+ {
+ M m1;
+ M m2;
+ M m1_save = m1;
+ M m2_save = m2;
+ m1.swap(m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar2[] =
+ {
+ V(5, 5),
+ V(6, 6),
+ V(7, 7),
+ V(8, 8),
+ V(9, 9),
+ V(10, 10),
+ V(11, 11),
+ V(12, 12)
+ };
+ M m1;
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ m1.swap(m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar1[] =
+ {
+ V(1, 1),
+ V(2, 2),
+ V(3, 3),
+ V(4, 4)
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2;
+ M m1_save = m1;
+ M m2_save = m2;
+ m1.swap(m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar1[] =
+ {
+ V(1, 1),
+ V(2, 2),
+ V(3, 3),
+ V(4, 4)
+ };
+ V ar2[] =
+ {
+ V(5, 5),
+ V(6, 6),
+ V(7, 7),
+ V(8, 8),
+ V(9, 9),
+ V(10, 10),
+ V(11, 11),
+ V(12, 12)
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ m1.swap(m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+ {
+ M m1;
+ M m2;
+ M m1_save = m1;
+ M m2_save = m2;
+ m1.swap(m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar2[] =
+ {
+ V(5, 5),
+ V(6, 6),
+ V(7, 7),
+ V(8, 8),
+ V(9, 9),
+ V(10, 10),
+ V(11, 11),
+ V(12, 12)
+ };
+ M m1;
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ m1.swap(m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar1[] =
+ {
+ V(1, 1),
+ V(2, 2),
+ V(3, 3),
+ V(4, 4)
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2;
+ M m1_save = m1;
+ M m2_save = m2;
+ m1.swap(m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar1[] =
+ {
+ V(1, 1),
+ V(2, 2),
+ V(3, 3),
+ V(4, 4)
+ };
+ V ar2[] =
+ {
+ V(5, 5),
+ V(6, 6),
+ V(7, 7),
+ V(8, 8),
+ V(9, 9),
+ V(10, 10),
+ V(11, 11),
+ V(12, 12)
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ m1.swap(m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ }
+#endif
+}
diff --git a/test/std/containers/associative/multimap/multimap.special/non_member_swap.pass.cpp b/test/std/containers/associative/multimap/multimap.special/non_member_swap.pass.cpp
new file mode 100644
index 000000000000..a91dfebb14a9
--- /dev/null
+++ b/test/std/containers/associative/multimap/multimap.special/non_member_swap.pass.cpp
@@ -0,0 +1,281 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// template <class Key, class T, class Compare, class Allocator>
+// void
+// swap(multimap<Key, T, Compare, Allocator>& x, multimap<Key, T, Compare, Allocator>& y);
+
+#include <map>
+#include <cassert>
+#include "test_allocator.h"
+#include "../../../test_compare.h"
+#include "min_allocator.h"
+
+int main()
+{
+ typedef std::pair<const int, double> V;
+ {
+ typedef std::multimap<int, double> M;
+ {
+ M m1;
+ M m2;
+ M m1_save = m1;
+ M m2_save = m2;
+ swap(m1, m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar2[] =
+ {
+ V(5, 5),
+ V(6, 6),
+ V(7, 7),
+ V(8, 8),
+ V(9, 9),
+ V(10, 10),
+ V(11, 11),
+ V(12, 12)
+ };
+ M m1;
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ swap(m1, m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar1[] =
+ {
+ V(1, 1),
+ V(2, 2),
+ V(3, 3),
+ V(4, 4)
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2;
+ M m1_save = m1;
+ M m2_save = m2;
+ swap(m1, m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar1[] =
+ {
+ V(1, 1),
+ V(2, 2),
+ V(3, 3),
+ V(4, 4)
+ };
+ V ar2[] =
+ {
+ V(5, 5),
+ V(6, 6),
+ V(7, 7),
+ V(8, 8),
+ V(9, 9),
+ V(10, 10),
+ V(11, 11),
+ V(12, 12)
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ swap(m1, m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ typedef test_allocator<V> A;
+ typedef test_compare<std::less<int> > C;
+ typedef std::multimap<int, double, C, A> M;
+ V ar1[] =
+ {
+ V(1, 1),
+ V(2, 2),
+ V(3, 3),
+ V(4, 4)
+ };
+ V ar2[] =
+ {
+ V(5, 5),
+ V(6, 6),
+ V(7, 7),
+ V(8, 8),
+ V(9, 9),
+ V(10, 10),
+ V(11, 11),
+ V(12, 12)
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]), C(1), A(1));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]), C(2), A(2));
+ M m1_save = m1;
+ M m2_save = m2;
+ swap(m1, m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ assert(m1.key_comp() == C(2));
+ assert(m1.get_allocator() == A(1));
+ assert(m2.key_comp() == C(1));
+ assert(m2.get_allocator() == A(2));
+ }
+ {
+ typedef other_allocator<V> A;
+ typedef test_compare<std::less<int> > C;
+ typedef std::multimap<int, double, C, A> M;
+ V ar1[] =
+ {
+ V(1, 1),
+ V(2, 2),
+ V(3, 3),
+ V(4, 4)
+ };
+ V ar2[] =
+ {
+ V(5, 5),
+ V(6, 6),
+ V(7, 7),
+ V(8, 8),
+ V(9, 9),
+ V(10, 10),
+ V(11, 11),
+ V(12, 12)
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]), C(1), A(1));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]), C(2), A(2));
+ M m1_save = m1;
+ M m2_save = m2;
+ swap(m1, m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ assert(m1.key_comp() == C(2));
+ assert(m1.get_allocator() == A(2));
+ assert(m2.key_comp() == C(1));
+ assert(m2.get_allocator() == A(1));
+ }
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+ {
+ M m1;
+ M m2;
+ M m1_save = m1;
+ M m2_save = m2;
+ swap(m1, m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar2[] =
+ {
+ V(5, 5),
+ V(6, 6),
+ V(7, 7),
+ V(8, 8),
+ V(9, 9),
+ V(10, 10),
+ V(11, 11),
+ V(12, 12)
+ };
+ M m1;
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ swap(m1, m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar1[] =
+ {
+ V(1, 1),
+ V(2, 2),
+ V(3, 3),
+ V(4, 4)
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2;
+ M m1_save = m1;
+ M m2_save = m2;
+ swap(m1, m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar1[] =
+ {
+ V(1, 1),
+ V(2, 2),
+ V(3, 3),
+ V(4, 4)
+ };
+ V ar2[] =
+ {
+ V(5, 5),
+ V(6, 6),
+ V(7, 7),
+ V(8, 8),
+ V(9, 9),
+ V(10, 10),
+ V(11, 11),
+ V(12, 12)
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ swap(m1, m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ typedef min_allocator<V> A;
+ typedef test_compare<std::less<int> > C;
+ typedef std::multimap<int, double, C, A> M;
+ V ar1[] =
+ {
+ V(1, 1),
+ V(2, 2),
+ V(3, 3),
+ V(4, 4)
+ };
+ V ar2[] =
+ {
+ V(5, 5),
+ V(6, 6),
+ V(7, 7),
+ V(8, 8),
+ V(9, 9),
+ V(10, 10),
+ V(11, 11),
+ V(12, 12)
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]), C(1), A());
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]), C(2), A());
+ M m1_save = m1;
+ M m2_save = m2;
+ swap(m1, m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ assert(m1.key_comp() == C(2));
+ assert(m1.get_allocator() == A());
+ assert(m2.key_comp() == C(1));
+ assert(m2.get_allocator() == A());
+ }
+ }
+#endif
+}
diff --git a/test/std/containers/associative/multimap/multimap.special/swap_noexcept.pass.cpp b/test/std/containers/associative/multimap/multimap.special/swap_noexcept.pass.cpp
new file mode 100644
index 000000000000..1013c62804b8
--- /dev/null
+++ b/test/std/containers/associative/multimap/multimap.special/swap_noexcept.pass.cpp
@@ -0,0 +1,148 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// void swap(multimap& c)
+// noexcept(!allocator_type::propagate_on_container_swap::value ||
+// __is_nothrow_swappable<allocator_type>::value);
+//
+// In C++17, the standard says that swap shall have:
+// noexcept(allocator_traits<Allocator>::is_always_equal::value &&
+// noexcept(swap(declval<Compare&>(), declval<Compare&>())));
+
+// This tests a conforming extension
+
+#include <map>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_comp
+{
+ typedef T value_type;
+
+ some_comp() {}
+ some_comp(const some_comp&) {}
+ void deallocate(void*, unsigned) {}
+
+ typedef std::true_type propagate_on_container_swap;
+};
+
+template <class T>
+struct some_comp2
+{
+ typedef T value_type;
+
+ some_comp2() {}
+ some_comp2(const some_comp2&) {}
+ void deallocate(void*, unsigned) {}
+ typedef std::true_type propagate_on_container_swap;
+};
+
+#if TEST_STD_VER >= 14
+template <typename T>
+void swap(some_comp2<T>&, some_comp2<T>&) noexcept {}
+#endif
+
+template <class T>
+struct some_alloc
+{
+ typedef T value_type;
+
+ some_alloc() {}
+ some_alloc(const some_alloc&);
+ void deallocate(void*, unsigned) {}
+
+ typedef std::true_type propagate_on_container_swap;
+};
+
+template <class T>
+struct some_alloc2
+{
+ typedef T value_type;
+
+ some_alloc2() {}
+ some_alloc2(const some_alloc2&);
+ void deallocate(void*, unsigned) {}
+
+ typedef std::false_type propagate_on_container_swap;
+ typedef std::true_type is_always_equal;
+};
+
+template <class T>
+struct some_alloc3
+{
+ typedef T value_type;
+
+ some_alloc3() {}
+ some_alloc3(const some_alloc3&);
+ void deallocate(void*, unsigned) {}
+
+ typedef std::false_type propagate_on_container_swap;
+ typedef std::false_type is_always_equal;
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::multimap<MoveOnly, MoveOnly> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::multimap<MoveOnly, MoveOnly, some_comp<MoveOnly>> C;
+ C c1, c2;
+ static_assert(!noexcept(swap(c1, c2)), "");
+ }
+
+#if TEST_STD_VER >= 14
+ { // POCS allocator, throwable swap for comp
+ typedef std::multimap<MoveOnly, MoveOnly, some_comp <MoveOnly>, some_alloc <MoveOnly>> C;
+ C c1, c2;
+ static_assert(!noexcept(swap(c1, c2)), "");
+ }
+ { // always equal allocator, throwable swap for comp
+ typedef std::multimap<MoveOnly, MoveOnly, some_comp <MoveOnly>, some_alloc2<MoveOnly>> C;
+ C c1, c2;
+ static_assert(!noexcept(swap(c1, c2)), "");
+ }
+ { // POCS allocator, nothrow swap for comp
+ typedef std::multimap<MoveOnly, MoveOnly, some_comp2<MoveOnly>, some_alloc <MoveOnly>> C;
+ C c1, c2;
+ static_assert( noexcept(swap(c1, c2)), "");
+ }
+ { // always equal allocator, nothrow swap for comp
+ typedef std::multimap<MoveOnly, MoveOnly, some_comp2<MoveOnly>, some_alloc2<MoveOnly>> C;
+ C c1, c2;
+ static_assert( noexcept(swap(c1, c2)), "");
+ }
+
+ { // NOT always equal allocator, nothrow swap for comp
+ typedef std::map<MoveOnly, MoveOnly, some_comp2<MoveOnly>, some_alloc3<MoveOnly>> C;
+ C c1, c2;
+ static_assert( noexcept(swap(c1, c2)), "");
+ }
+#endif
+
+#endif
+}
diff --git a/test/std/containers/associative/multimap/scary.pass.cpp b/test/std/containers/associative/multimap/scary.pass.cpp
new file mode 100644
index 000000000000..b99d9bc2df91
--- /dev/null
+++ b/test/std/containers/associative/multimap/scary.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map class multimap
+
+// Extension: SCARY/N2913 iterator compatibility between map and multimap
+
+#include <map>
+
+int main()
+{
+ typedef std::map<int, int> M1;
+ typedef std::multimap<int, int> M2;
+ M2::iterator i;
+ M1::iterator j = i;
+}
diff --git a/test/std/containers/associative/multimap/size.pass.cpp b/test/std/containers/associative/multimap/size.pass.cpp
new file mode 100644
index 000000000000..ac71d4c95b64
--- /dev/null
+++ b/test/std/containers/associative/multimap/size.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// size_type size() const;
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::multimap<int, double> M;
+ M m;
+ assert(m.size() == 0);
+ m.insert(M::value_type(2, 1.5));
+ assert(m.size() == 1);
+ m.insert(M::value_type(1, 1.5));
+ assert(m.size() == 2);
+ m.insert(M::value_type(3, 1.5));
+ assert(m.size() == 3);
+ m.erase(m.begin());
+ assert(m.size() == 2);
+ m.erase(m.begin());
+ assert(m.size() == 1);
+ m.erase(m.begin());
+ assert(m.size() == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+ M m;
+ assert(m.size() == 0);
+ m.insert(M::value_type(2, 1.5));
+ assert(m.size() == 1);
+ m.insert(M::value_type(1, 1.5));
+ assert(m.size() == 2);
+ m.insert(M::value_type(3, 1.5));
+ assert(m.size() == 3);
+ m.erase(m.begin());
+ assert(m.size() == 2);
+ m.erase(m.begin());
+ assert(m.size() == 1);
+ m.erase(m.begin());
+ assert(m.size() == 0);
+ }
+#endif
+}
diff --git a/test/std/containers/associative/multimap/types.pass.cpp b/test/std/containers/associative/multimap/types.pass.cpp
new file mode 100644
index 000000000000..a0f4db056a83
--- /dev/null
+++ b/test/std/containers/associative/multimap/types.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// template <class Key, class T, class Compare = less<Key>,
+// class Allocator = allocator<pair<const Key, T>>>
+// class multimap
+// {
+// public:
+// // types:
+// typedef Key key_type;
+// typedef T mapped_type;
+// typedef pair<const key_type, mapped_type> value_type;
+// typedef Compare key_compare;
+// typedef Allocator allocator_type;
+// typedef typename allocator_type::reference reference;
+// typedef typename allocator_type::const_reference const_reference;
+// typedef typename allocator_type::pointer pointer;
+// typedef typename allocator_type::const_pointer const_pointer;
+// typedef typename allocator_type::size_type size_type;
+// typedef typename allocator_type::difference_type difference_type;
+// ...
+// };
+
+#include <map>
+#include <type_traits>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::multimap<int, double> C;
+ static_assert((std::is_same<C::key_type, int>::value), "");
+ static_assert((std::is_same<C::mapped_type, double>::value), "");
+ static_assert((std::is_same<C::value_type, std::pair<const int, double> >::value), "");
+ static_assert((std::is_same<C::key_compare, std::less<int> >::value), "");
+ static_assert((std::is_same<C::allocator_type, std::allocator<std::pair<const int, double> > >::value), "");
+ static_assert((std::is_same<C::reference, std::pair<const int, double>&>::value), "");
+ static_assert((std::is_same<C::const_reference, const std::pair<const int, double>&>::value), "");
+ static_assert((std::is_same<C::pointer, std::pair<const int, double>*>::value), "");
+ static_assert((std::is_same<C::const_pointer, const std::pair<const int, double>*>::value), "");
+ static_assert((std::is_same<C::size_type, std::size_t>::value), "");
+ static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> C;
+ static_assert((std::is_same<C::key_type, int>::value), "");
+ static_assert((std::is_same<C::mapped_type, double>::value), "");
+ static_assert((std::is_same<C::value_type, std::pair<const int, double> >::value), "");
+ static_assert((std::is_same<C::key_compare, std::less<int> >::value), "");
+ static_assert((std::is_same<C::allocator_type, min_allocator<std::pair<const int, double> > >::value), "");
+ static_assert((std::is_same<C::reference, std::pair<const int, double>&>::value), "");
+ static_assert((std::is_same<C::const_reference, const std::pair<const int, double>&>::value), "");
+ static_assert((std::is_same<C::pointer, min_pointer<std::pair<const int, double>>>::value), "");
+ static_assert((std::is_same<C::const_pointer, min_pointer<const std::pair<const int, double>>>::value), "");
+// min_allocator doesn't have a size_type, so one gets synthesized
+ static_assert((std::is_same<C::size_type, std::make_unsigned<C::difference_type>::type>::value), "");
+ static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
+ }
+#endif
+}
diff --git a/test/std/containers/associative/multiset/clear.pass.cpp b/test/std/containers/associative/multiset/clear.pass.cpp
new file mode 100644
index 000000000000..3069de5a300d
--- /dev/null
+++ b/test/std/containers/associative/multiset/clear.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// void clear();
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::multiset<int> M;
+ typedef int V;
+ V ar[] =
+ {
+ 1,
+ 2,
+ 3,
+ 4,
+ 5,
+ 6,
+ 7,
+ 8
+ };
+ M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 8);
+ m.clear();
+ assert(m.size() == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::multiset<int, std::less<int>, min_allocator<int>> M;
+ typedef int V;
+ V ar[] =
+ {
+ 1,
+ 2,
+ 3,
+ 4,
+ 5,
+ 6,
+ 7,
+ 8
+ };
+ M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 8);
+ m.clear();
+ assert(m.size() == 0);
+ }
+#endif
+}
diff --git a/test/std/containers/associative/multiset/count.pass.cpp b/test/std/containers/associative/multiset/count.pass.cpp
new file mode 100644
index 000000000000..93bd6f80eaad
--- /dev/null
+++ b/test/std/containers/associative/multiset/count.pass.cpp
@@ -0,0 +1,160 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// size_type count(const key_type& k) const;
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "private_constructor.hpp"
+
+int main()
+{
+ {
+ typedef int V;
+ typedef std::multiset<int> M;
+ {
+ typedef M::size_type R;
+ V ar[] =
+ {
+ 5,
+ 5,
+ 5,
+ 5,
+ 7,
+ 7,
+ 7,
+ 9,
+ 9
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.count(4);
+ assert(r == 0);
+ r = m.count(5);
+ assert(r == 4);
+ r = m.count(6);
+ assert(r == 0);
+ r = m.count(7);
+ assert(r == 3);
+ r = m.count(8);
+ assert(r == 0);
+ r = m.count(9);
+ assert(r == 2);
+ r = m.count(10);
+ assert(r == 0);
+ }
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int V;
+ typedef std::multiset<int, std::less<int>, min_allocator<int>> M;
+ {
+ typedef M::size_type R;
+ V ar[] =
+ {
+ 5,
+ 5,
+ 5,
+ 5,
+ 7,
+ 7,
+ 7,
+ 9,
+ 9
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.count(4);
+ assert(r == 0);
+ r = m.count(5);
+ assert(r == 4);
+ r = m.count(6);
+ assert(r == 0);
+ r = m.count(7);
+ assert(r == 3);
+ r = m.count(8);
+ assert(r == 0);
+ r = m.count(9);
+ assert(r == 2);
+ r = m.count(10);
+ assert(r == 0);
+ }
+ }
+#endif
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef int V;
+ typedef std::multiset<int, std::less<>> M;
+ typedef M::size_type R;
+ V ar[] =
+ {
+ 5,
+ 5,
+ 5,
+ 5,
+ 7,
+ 7,
+ 7,
+ 9,
+ 9
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.count(4);
+ assert(r == 0);
+ r = m.count(5);
+ assert(r == 4);
+ r = m.count(6);
+ assert(r == 0);
+ r = m.count(7);
+ assert(r == 3);
+ r = m.count(8);
+ assert(r == 0);
+ r = m.count(9);
+ assert(r == 2);
+ r = m.count(10);
+ assert(r == 0);
+ }
+
+ {
+ typedef PrivateConstructor V;
+ typedef std::multiset<V, std::less<>> M;
+ typedef M::size_type R;
+
+ M m;
+ m.insert ( V::make ( 5 ));
+ m.insert ( V::make ( 5 ));
+ m.insert ( V::make ( 5 ));
+ m.insert ( V::make ( 5 ));
+ m.insert ( V::make ( 7 ));
+ m.insert ( V::make ( 7 ));
+ m.insert ( V::make ( 7 ));
+ m.insert ( V::make ( 9 ));
+ m.insert ( V::make ( 9 ));
+
+ R r = m.count(4);
+ assert(r == 0);
+ r = m.count(5);
+ assert(r == 4);
+ r = m.count(6);
+ assert(r == 0);
+ r = m.count(7);
+ assert(r == 3);
+ r = m.count(8);
+ assert(r == 0);
+ r = m.count(9);
+ assert(r == 2);
+ r = m.count(10);
+ assert(r == 0);
+ }
+#endif
+}
diff --git a/test/std/containers/associative/multiset/emplace.pass.cpp b/test/std/containers/associative/multiset/emplace.pass.cpp
new file mode 100644
index 000000000000..450ee6cd35a3
--- /dev/null
+++ b/test/std/containers/associative/multiset/emplace.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// template <class... Args>
+// iterator emplace(Args&&... args);
+
+#include <set>
+#include <cassert>
+
+#include "../../Emplaceable.h"
+#include "DefaultOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::multiset<DefaultOnly> M;
+ typedef M::iterator R;
+ M m;
+ assert(DefaultOnly::count == 0);
+ R r = m.emplace();
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(*m.begin() == DefaultOnly());
+ assert(DefaultOnly::count == 1);
+
+ r = m.emplace();
+ assert(r == next(m.begin()));
+ assert(m.size() == 2);
+ assert(*m.begin() == DefaultOnly());
+ assert(DefaultOnly::count == 2);
+ }
+ assert(DefaultOnly::count == 0);
+ {
+ typedef std::multiset<Emplaceable> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.emplace();
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(*m.begin() == Emplaceable());
+ r = m.emplace(2, 3.5);
+ assert(r == next(m.begin()));
+ assert(m.size() == 2);
+ assert(*r == Emplaceable(2, 3.5));
+ r = m.emplace(2, 3.5);
+ assert(r == next(m.begin(), 2));
+ assert(m.size() == 3);
+ assert(*r == Emplaceable(2, 3.5));
+ }
+ {
+ typedef std::multiset<int> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.emplace(M::value_type(2));
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(*r == 2);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::multiset<int, std::less<int>, min_allocator<int>> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.emplace(M::value_type(2));
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(*r == 2);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/associative/multiset/emplace_hint.pass.cpp b/test/std/containers/associative/multiset/emplace_hint.pass.cpp
new file mode 100644
index 000000000000..194adf761c4c
--- /dev/null
+++ b/test/std/containers/associative/multiset/emplace_hint.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// template <class... Args>
+// iterator emplace_hint(const_iterator position, Args&&... args);
+
+#include <set>
+#include <cassert>
+
+#include "../../Emplaceable.h"
+#include "DefaultOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::multiset<DefaultOnly> M;
+ typedef M::iterator R;
+ M m;
+ assert(DefaultOnly::count == 0);
+ R r = m.emplace_hint(m.cend());
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(*m.begin() == DefaultOnly());
+ assert(DefaultOnly::count == 1);
+
+ r = m.emplace_hint(m.cbegin());
+ assert(r == m.begin());
+ assert(m.size() == 2);
+ assert(*m.begin() == DefaultOnly());
+ assert(DefaultOnly::count == 2);
+ }
+ assert(DefaultOnly::count == 0);
+ {
+ typedef std::multiset<Emplaceable> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.emplace_hint(m.cend());
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(*m.begin() == Emplaceable());
+ r = m.emplace_hint(m.cend(), 2, 3.5);
+ assert(r == next(m.begin()));
+ assert(m.size() == 2);
+ assert(*r == Emplaceable(2, 3.5));
+ r = m.emplace_hint(m.cbegin(), 2, 3.5);
+ assert(r == next(m.begin()));
+ assert(m.size() == 3);
+ assert(*r == Emplaceable(2, 3.5));
+ }
+ {
+ typedef std::multiset<int> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.emplace_hint(m.cend(), M::value_type(2));
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(*r == 2);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::multiset<int, std::less<int>, min_allocator<int>> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.emplace_hint(m.cend(), M::value_type(2));
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(*r == 2);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/associative/multiset/empty.pass.cpp b/test/std/containers/associative/multiset/empty.pass.cpp
new file mode 100644
index 000000000000..32aef90d4188
--- /dev/null
+++ b/test/std/containers/associative/multiset/empty.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// bool empty() const;
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::multiset<int> M;
+ M m;
+ assert(m.empty());
+ m.insert(M::value_type(1));
+ assert(!m.empty());
+ m.clear();
+ assert(m.empty());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::multiset<int, std::less<int>, min_allocator<int>> M;
+ M m;
+ assert(m.empty());
+ m.insert(M::value_type(1));
+ assert(!m.empty());
+ m.clear();
+ assert(m.empty());
+ }
+#endif
+}
diff --git a/test/std/containers/associative/multiset/equal_range.pass.cpp b/test/std/containers/associative/multiset/equal_range.pass.cpp
new file mode 100644
index 000000000000..8c69d0c61ec5
--- /dev/null
+++ b/test/std/containers/associative/multiset/equal_range.pass.cpp
@@ -0,0 +1,263 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// pair<iterator,iterator> equal_range(const key_type& k);
+// pair<const_iterator,const_iterator> equal_range(const key_type& k) const;
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "private_constructor.hpp"
+
+int main()
+{
+ {
+ typedef int V;
+ typedef std::multiset<int> M;
+ {
+ typedef std::pair<M::iterator, M::iterator> R;
+ V ar[] =
+ {
+ 5,
+ 5,
+ 5,
+ 7,
+ 7,
+ 7,
+ 9,
+ 9,
+ 9
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.equal_range(4);
+ assert(r.first == next(m.begin(), 0));
+ assert(r.second == next(m.begin(), 0));
+ r = m.equal_range(5);
+ assert(r.first == next(m.begin(), 0));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(6);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(7);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(8);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(9);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 9));
+ r = m.equal_range(10);
+ assert(r.first == next(m.begin(), 9));
+ assert(r.second == next(m.begin(), 9));
+ }
+ {
+ typedef std::pair<M::const_iterator, M::const_iterator> R;
+ V ar[] =
+ {
+ 5,
+ 5,
+ 5,
+ 7,
+ 7,
+ 7,
+ 9,
+ 9,
+ 9
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.equal_range(4);
+ assert(r.first == next(m.begin(), 0));
+ assert(r.second == next(m.begin(), 0));
+ r = m.equal_range(5);
+ assert(r.first == next(m.begin(), 0));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(6);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(7);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(8);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(9);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 9));
+ r = m.equal_range(10);
+ assert(r.first == next(m.begin(), 9));
+ assert(r.second == next(m.begin(), 9));
+ }
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int V;
+ typedef std::multiset<int, std::less<int>, min_allocator<int>> M;
+ {
+ typedef std::pair<M::iterator, M::iterator> R;
+ V ar[] =
+ {
+ 5,
+ 5,
+ 5,
+ 7,
+ 7,
+ 7,
+ 9,
+ 9,
+ 9
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.equal_range(4);
+ assert(r.first == next(m.begin(), 0));
+ assert(r.second == next(m.begin(), 0));
+ r = m.equal_range(5);
+ assert(r.first == next(m.begin(), 0));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(6);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(7);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(8);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(9);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 9));
+ r = m.equal_range(10);
+ assert(r.first == next(m.begin(), 9));
+ assert(r.second == next(m.begin(), 9));
+ }
+ {
+ typedef std::pair<M::const_iterator, M::const_iterator> R;
+ V ar[] =
+ {
+ 5,
+ 5,
+ 5,
+ 7,
+ 7,
+ 7,
+ 9,
+ 9,
+ 9
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.equal_range(4);
+ assert(r.first == next(m.begin(), 0));
+ assert(r.second == next(m.begin(), 0));
+ r = m.equal_range(5);
+ assert(r.first == next(m.begin(), 0));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(6);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(7);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(8);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(9);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 9));
+ r = m.equal_range(10);
+ assert(r.first == next(m.begin(), 9));
+ assert(r.second == next(m.begin(), 9));
+ }
+ }
+#endif
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef int V;
+ typedef std::multiset<V, std::less<>> M;
+ typedef std::pair<M::iterator, M::iterator> R;
+ V ar[] =
+ {
+ 5,
+ 5,
+ 5,
+ 7,
+ 7,
+ 7,
+ 9,
+ 9,
+ 9
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.equal_range(4);
+ assert(r.first == next(m.begin(), 0));
+ assert(r.second == next(m.begin(), 0));
+ r = m.equal_range(5);
+ assert(r.first == next(m.begin(), 0));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(6);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(7);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(8);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(9);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 9));
+ r = m.equal_range(10);
+ assert(r.first == next(m.begin(), 9));
+ assert(r.second == next(m.begin(), 9));
+ }
+
+ {
+ typedef PrivateConstructor V;
+ typedef std::multiset<V, std::less<>> M;
+ typedef std::pair<M::iterator, M::iterator> R;
+
+ M m;
+ m.insert ( V::make ( 5 ));
+ m.insert ( V::make ( 5 ));
+ m.insert ( V::make ( 5 ));
+ m.insert ( V::make ( 7 ));
+ m.insert ( V::make ( 7 ));
+ m.insert ( V::make ( 7 ));
+ m.insert ( V::make ( 9 ));
+ m.insert ( V::make ( 9 ));
+ m.insert ( V::make ( 9 ));
+
+ R r = m.equal_range(4);
+ assert(r.first == next(m.begin(), 0));
+ assert(r.second == next(m.begin(), 0));
+ r = m.equal_range(5);
+ assert(r.first == next(m.begin(), 0));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(6);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(7);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(8);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(9);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 9));
+ r = m.equal_range(10);
+ assert(r.first == next(m.begin(), 9));
+ assert(r.second == next(m.begin(), 9));
+ }
+#endif
+}
diff --git a/test/std/containers/associative/multiset/erase_iter.pass.cpp b/test/std/containers/associative/multiset/erase_iter.pass.cpp
new file mode 100644
index 000000000000..1d41540edb8a
--- /dev/null
+++ b/test/std/containers/associative/multiset/erase_iter.pass.cpp
@@ -0,0 +1,203 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// iterator erase(const_iterator position);
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+struct TemplateConstructor
+{
+ template<typename T>
+ TemplateConstructor (const T&) {}
+};
+
+bool operator<(const TemplateConstructor&, const TemplateConstructor&) { return false; }
+
+int main()
+{
+ {
+ typedef std::multiset<int> M;
+ typedef int V;
+ typedef M::iterator I;
+ V ar[] =
+ {
+ 1,
+ 2,
+ 3,
+ 4,
+ 5,
+ 6,
+ 7,
+ 8
+ };
+ M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 8);
+ I i = m.erase(next(m.cbegin(), 3));
+ assert(m.size() == 7);
+ assert(i == next(m.begin(), 3));
+ assert(*next(m.begin(), 0) == 1);
+ assert(*next(m.begin(), 1) == 2);
+ assert(*next(m.begin(), 2) == 3);
+ assert(*next(m.begin(), 3) == 5);
+ assert(*next(m.begin(), 4) == 6);
+ assert(*next(m.begin(), 5) == 7);
+ assert(*next(m.begin(), 6) == 8);
+
+ i = m.erase(next(m.cbegin(), 0));
+ assert(m.size() == 6);
+ assert(i == m.begin());
+ assert(*next(m.begin(), 0) == 2);
+ assert(*next(m.begin(), 1) == 3);
+ assert(*next(m.begin(), 2) == 5);
+ assert(*next(m.begin(), 3) == 6);
+ assert(*next(m.begin(), 4) == 7);
+ assert(*next(m.begin(), 5) == 8);
+
+ i = m.erase(next(m.cbegin(), 5));
+ assert(m.size() == 5);
+ assert(i == m.end());
+ assert(*next(m.begin(), 0) == 2);
+ assert(*next(m.begin(), 1) == 3);
+ assert(*next(m.begin(), 2) == 5);
+ assert(*next(m.begin(), 3) == 6);
+ assert(*next(m.begin(), 4) == 7);
+
+ i = m.erase(next(m.cbegin(), 1));
+ assert(m.size() == 4);
+ assert(i == next(m.begin()));
+ assert(*next(m.begin(), 0) == 2);
+ assert(*next(m.begin(), 1) == 5);
+ assert(*next(m.begin(), 2) == 6);
+ assert(*next(m.begin(), 3) == 7);
+
+ i = m.erase(next(m.cbegin(), 2));
+ assert(m.size() == 3);
+ assert(i == next(m.begin(), 2));
+ assert(*next(m.begin(), 0) == 2);
+ assert(*next(m.begin(), 1) == 5);
+ assert(*next(m.begin(), 2) == 7);
+
+ i = m.erase(next(m.cbegin(), 2));
+ assert(m.size() == 2);
+ assert(i == next(m.begin(), 2));
+ assert(*next(m.begin(), 0) == 2);
+ assert(*next(m.begin(), 1) == 5);
+
+ i = m.erase(next(m.cbegin(), 0));
+ assert(m.size() == 1);
+ assert(i == next(m.begin(), 0));
+ assert(*next(m.begin(), 0) == 5);
+
+ i = m.erase(m.cbegin());
+ assert(m.size() == 0);
+ assert(i == m.begin());
+ assert(i == m.end());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::multiset<int, std::less<int>, min_allocator<int>> M;
+ typedef int V;
+ typedef M::iterator I;
+ V ar[] =
+ {
+ 1,
+ 2,
+ 3,
+ 4,
+ 5,
+ 6,
+ 7,
+ 8
+ };
+ M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 8);
+ I i = m.erase(next(m.cbegin(), 3));
+ assert(m.size() == 7);
+ assert(i == next(m.begin(), 3));
+ assert(*next(m.begin(), 0) == 1);
+ assert(*next(m.begin(), 1) == 2);
+ assert(*next(m.begin(), 2) == 3);
+ assert(*next(m.begin(), 3) == 5);
+ assert(*next(m.begin(), 4) == 6);
+ assert(*next(m.begin(), 5) == 7);
+ assert(*next(m.begin(), 6) == 8);
+
+ i = m.erase(next(m.cbegin(), 0));
+ assert(m.size() == 6);
+ assert(i == m.begin());
+ assert(*next(m.begin(), 0) == 2);
+ assert(*next(m.begin(), 1) == 3);
+ assert(*next(m.begin(), 2) == 5);
+ assert(*next(m.begin(), 3) == 6);
+ assert(*next(m.begin(), 4) == 7);
+ assert(*next(m.begin(), 5) == 8);
+
+ i = m.erase(next(m.cbegin(), 5));
+ assert(m.size() == 5);
+ assert(i == m.end());
+ assert(*next(m.begin(), 0) == 2);
+ assert(*next(m.begin(), 1) == 3);
+ assert(*next(m.begin(), 2) == 5);
+ assert(*next(m.begin(), 3) == 6);
+ assert(*next(m.begin(), 4) == 7);
+
+ i = m.erase(next(m.cbegin(), 1));
+ assert(m.size() == 4);
+ assert(i == next(m.begin()));
+ assert(*next(m.begin(), 0) == 2);
+ assert(*next(m.begin(), 1) == 5);
+ assert(*next(m.begin(), 2) == 6);
+ assert(*next(m.begin(), 3) == 7);
+
+ i = m.erase(next(m.cbegin(), 2));
+ assert(m.size() == 3);
+ assert(i == next(m.begin(), 2));
+ assert(*next(m.begin(), 0) == 2);
+ assert(*next(m.begin(), 1) == 5);
+ assert(*next(m.begin(), 2) == 7);
+
+ i = m.erase(next(m.cbegin(), 2));
+ assert(m.size() == 2);
+ assert(i == next(m.begin(), 2));
+ assert(*next(m.begin(), 0) == 2);
+ assert(*next(m.begin(), 1) == 5);
+
+ i = m.erase(next(m.cbegin(), 0));
+ assert(m.size() == 1);
+ assert(i == next(m.begin(), 0));
+ assert(*next(m.begin(), 0) == 5);
+
+ i = m.erase(m.cbegin());
+ assert(m.size() == 0);
+ assert(i == m.begin());
+ assert(i == m.end());
+ }
+#endif
+#if __cplusplus >= 201402L
+ {
+ // This is LWG #2059
+ typedef TemplateConstructor T;
+ typedef std::multiset<T> C;
+ typedef C::iterator I;
+
+ C c;
+ T a{0};
+ I it = c.find(a);
+ if (it != c.end())
+ c.erase(it);
+ }
+#endif
+}
diff --git a/test/std/containers/associative/multiset/erase_iter_iter.pass.cpp b/test/std/containers/associative/multiset/erase_iter_iter.pass.cpp
new file mode 100644
index 000000000000..e1d7090d816f
--- /dev/null
+++ b/test/std/containers/associative/multiset/erase_iter_iter.pass.cpp
@@ -0,0 +1,141 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// iterator erase(const_iterator first, const_iterator last);
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::multiset<int> M;
+ typedef int V;
+ typedef M::iterator I;
+ V ar[] =
+ {
+ 1,
+ 2,
+ 3,
+ 4,
+ 5,
+ 6,
+ 7,
+ 8
+ };
+ M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 8);
+ I i = m.erase(next(m.cbegin(), 5), next(m.cbegin(), 5));
+ assert(m.size() == 8);
+ assert(i == next(m.begin(), 5));
+ assert(*next(m.begin(), 0) == 1);
+ assert(*next(m.begin(), 1) == 2);
+ assert(*next(m.begin(), 2) == 3);
+ assert(*next(m.begin(), 3) == 4);
+ assert(*next(m.begin(), 4) == 5);
+ assert(*next(m.begin(), 5) == 6);
+ assert(*next(m.begin(), 6) == 7);
+ assert(*next(m.begin(), 7) == 8);
+
+ i = m.erase(next(m.cbegin(), 3), next(m.cbegin(), 4));
+ assert(m.size() == 7);
+ assert(i == next(m.begin(), 3));
+ assert(*next(m.begin(), 0) == 1);
+ assert(*next(m.begin(), 1) == 2);
+ assert(*next(m.begin(), 2) == 3);
+ assert(*next(m.begin(), 3) == 5);
+ assert(*next(m.begin(), 4) == 6);
+ assert(*next(m.begin(), 5) == 7);
+ assert(*next(m.begin(), 6) == 8);
+
+ i = m.erase(next(m.cbegin(), 2), next(m.cbegin(), 5));
+ assert(m.size() == 4);
+ assert(i == next(m.begin(), 2));
+ assert(*next(m.begin(), 0) == 1);
+ assert(*next(m.begin(), 1) == 2);
+ assert(*next(m.begin(), 2) == 7);
+ assert(*next(m.begin(), 3) == 8);
+
+ i = m.erase(next(m.cbegin(), 0), next(m.cbegin(), 2));
+ assert(m.size() == 2);
+ assert(i == next(m.begin(), 0));
+ assert(*next(m.begin(), 0) == 7);
+ assert(*next(m.begin(), 1) == 8);
+
+ i = m.erase(m.cbegin(), m.cend());
+ assert(m.size() == 0);
+ assert(i == m.end());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::multiset<int, std::less<int>, min_allocator<int>> M;
+ typedef int V;
+ typedef M::iterator I;
+ V ar[] =
+ {
+ 1,
+ 2,
+ 3,
+ 4,
+ 5,
+ 6,
+ 7,
+ 8
+ };
+ M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 8);
+ I i = m.erase(next(m.cbegin(), 5), next(m.cbegin(), 5));
+ assert(m.size() == 8);
+ assert(i == next(m.begin(), 5));
+ assert(*next(m.begin(), 0) == 1);
+ assert(*next(m.begin(), 1) == 2);
+ assert(*next(m.begin(), 2) == 3);
+ assert(*next(m.begin(), 3) == 4);
+ assert(*next(m.begin(), 4) == 5);
+ assert(*next(m.begin(), 5) == 6);
+ assert(*next(m.begin(), 6) == 7);
+ assert(*next(m.begin(), 7) == 8);
+
+ i = m.erase(next(m.cbegin(), 3), next(m.cbegin(), 4));
+ assert(m.size() == 7);
+ assert(i == next(m.begin(), 3));
+ assert(*next(m.begin(), 0) == 1);
+ assert(*next(m.begin(), 1) == 2);
+ assert(*next(m.begin(), 2) == 3);
+ assert(*next(m.begin(), 3) == 5);
+ assert(*next(m.begin(), 4) == 6);
+ assert(*next(m.begin(), 5) == 7);
+ assert(*next(m.begin(), 6) == 8);
+
+ i = m.erase(next(m.cbegin(), 2), next(m.cbegin(), 5));
+ assert(m.size() == 4);
+ assert(i == next(m.begin(), 2));
+ assert(*next(m.begin(), 0) == 1);
+ assert(*next(m.begin(), 1) == 2);
+ assert(*next(m.begin(), 2) == 7);
+ assert(*next(m.begin(), 3) == 8);
+
+ i = m.erase(next(m.cbegin(), 0), next(m.cbegin(), 2));
+ assert(m.size() == 2);
+ assert(i == next(m.begin(), 0));
+ assert(*next(m.begin(), 0) == 7);
+ assert(*next(m.begin(), 1) == 8);
+
+ i = m.erase(m.cbegin(), m.cend());
+ assert(m.size() == 0);
+ assert(i == m.end());
+ }
+#endif
+}
diff --git a/test/std/containers/associative/multiset/erase_key.pass.cpp b/test/std/containers/associative/multiset/erase_key.pass.cpp
new file mode 100644
index 000000000000..e9bce1e1b640
--- /dev/null
+++ b/test/std/containers/associative/multiset/erase_key.pass.cpp
@@ -0,0 +1,129 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// size_type erase(const key_type& k);
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::multiset<int> M;
+ typedef int V;
+ typedef M::size_type I;
+ V ar[] =
+ {
+ 3,
+ 3,
+ 3,
+ 5,
+ 5,
+ 5,
+ 7,
+ 7,
+ 7
+ };
+ M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 9);
+ I i = m.erase(6);
+ assert(m.size() == 9);
+ assert(i == 0);
+ assert(*next(m.begin(), 0) == 3);
+ assert(*next(m.begin(), 1) == 3);
+ assert(*next(m.begin(), 2) == 3);
+ assert(*next(m.begin(), 3) == 5);
+ assert(*next(m.begin(), 4) == 5);
+ assert(*next(m.begin(), 5) == 5);
+ assert(*next(m.begin(), 6) == 7);
+ assert(*next(m.begin(), 7) == 7);
+ assert(*next(m.begin(), 8) == 7);
+
+ i = m.erase(5);
+ assert(m.size() == 6);
+ assert(i == 3);
+ assert(*next(m.begin(), 0) == 3);
+ assert(*next(m.begin(), 1) == 3);
+ assert(*next(m.begin(), 2) == 3);
+ assert(*next(m.begin(), 3) == 7);
+ assert(*next(m.begin(), 4) == 7);
+ assert(*next(m.begin(), 5) == 7);
+
+ i = m.erase(3);
+ assert(m.size() == 3);
+ assert(i == 3);
+ assert(*next(m.begin(), 0) == 7);
+ assert(*next(m.begin(), 1) == 7);
+ assert(*next(m.begin(), 2) == 7);
+
+ i = m.erase(7);
+ assert(m.size() == 0);
+ assert(i == 3);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::multiset<int, std::less<int>, min_allocator<int>> M;
+ typedef int V;
+ typedef M::size_type I;
+ V ar[] =
+ {
+ 3,
+ 3,
+ 3,
+ 5,
+ 5,
+ 5,
+ 7,
+ 7,
+ 7
+ };
+ M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 9);
+ I i = m.erase(6);
+ assert(m.size() == 9);
+ assert(i == 0);
+ assert(*next(m.begin(), 0) == 3);
+ assert(*next(m.begin(), 1) == 3);
+ assert(*next(m.begin(), 2) == 3);
+ assert(*next(m.begin(), 3) == 5);
+ assert(*next(m.begin(), 4) == 5);
+ assert(*next(m.begin(), 5) == 5);
+ assert(*next(m.begin(), 6) == 7);
+ assert(*next(m.begin(), 7) == 7);
+ assert(*next(m.begin(), 8) == 7);
+
+ i = m.erase(5);
+ assert(m.size() == 6);
+ assert(i == 3);
+ assert(*next(m.begin(), 0) == 3);
+ assert(*next(m.begin(), 1) == 3);
+ assert(*next(m.begin(), 2) == 3);
+ assert(*next(m.begin(), 3) == 7);
+ assert(*next(m.begin(), 4) == 7);
+ assert(*next(m.begin(), 5) == 7);
+
+ i = m.erase(3);
+ assert(m.size() == 3);
+ assert(i == 3);
+ assert(*next(m.begin(), 0) == 7);
+ assert(*next(m.begin(), 1) == 7);
+ assert(*next(m.begin(), 2) == 7);
+
+ i = m.erase(7);
+ assert(m.size() == 0);
+ assert(i == 3);
+ }
+#endif
+}
diff --git a/test/std/containers/associative/multiset/find.pass.cpp b/test/std/containers/associative/multiset/find.pass.cpp
new file mode 100644
index 000000000000..364460a6ca3a
--- /dev/null
+++ b/test/std/containers/associative/multiset/find.pass.cpp
@@ -0,0 +1,240 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// iterator find(const key_type& k);
+// const_iterator find(const key_type& k) const;
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "private_constructor.hpp"
+
+int main()
+{
+ {
+ typedef int V;
+ typedef std::multiset<int> M;
+ {
+ typedef M::iterator R;
+ V ar[] =
+ {
+ 5,
+ 6,
+ 7,
+ 8,
+ 9,
+ 10,
+ 11,
+ 12
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.find(5);
+ assert(r == m.begin());
+ r = m.find(6);
+ assert(r == next(m.begin()));
+ r = m.find(7);
+ assert(r == next(m.begin(), 2));
+ r = m.find(8);
+ assert(r == next(m.begin(), 3));
+ r = m.find(9);
+ assert(r == next(m.begin(), 4));
+ r = m.find(10);
+ assert(r == next(m.begin(), 5));
+ r = m.find(11);
+ assert(r == next(m.begin(), 6));
+ r = m.find(12);
+ assert(r == next(m.begin(), 7));
+ r = m.find(4);
+ assert(r == next(m.begin(), 8));
+ }
+ {
+ typedef M::const_iterator R;
+ V ar[] =
+ {
+ 5,
+ 6,
+ 7,
+ 8,
+ 9,
+ 10,
+ 11,
+ 12
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.find(5);
+ assert(r == m.begin());
+ r = m.find(6);
+ assert(r == next(m.begin()));
+ r = m.find(7);
+ assert(r == next(m.begin(), 2));
+ r = m.find(8);
+ assert(r == next(m.begin(), 3));
+ r = m.find(9);
+ assert(r == next(m.begin(), 4));
+ r = m.find(10);
+ assert(r == next(m.begin(), 5));
+ r = m.find(11);
+ assert(r == next(m.begin(), 6));
+ r = m.find(12);
+ assert(r == next(m.begin(), 7));
+ r = m.find(4);
+ assert(r == next(m.begin(), 8));
+ }
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int V;
+ typedef std::multiset<int, std::less<int>, min_allocator<int>> M;
+ {
+ typedef M::iterator R;
+ V ar[] =
+ {
+ 5,
+ 6,
+ 7,
+ 8,
+ 9,
+ 10,
+ 11,
+ 12
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.find(5);
+ assert(r == m.begin());
+ r = m.find(6);
+ assert(r == next(m.begin()));
+ r = m.find(7);
+ assert(r == next(m.begin(), 2));
+ r = m.find(8);
+ assert(r == next(m.begin(), 3));
+ r = m.find(9);
+ assert(r == next(m.begin(), 4));
+ r = m.find(10);
+ assert(r == next(m.begin(), 5));
+ r = m.find(11);
+ assert(r == next(m.begin(), 6));
+ r = m.find(12);
+ assert(r == next(m.begin(), 7));
+ r = m.find(4);
+ assert(r == next(m.begin(), 8));
+ }
+ {
+ typedef M::const_iterator R;
+ V ar[] =
+ {
+ 5,
+ 6,
+ 7,
+ 8,
+ 9,
+ 10,
+ 11,
+ 12
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.find(5);
+ assert(r == m.begin());
+ r = m.find(6);
+ assert(r == next(m.begin()));
+ r = m.find(7);
+ assert(r == next(m.begin(), 2));
+ r = m.find(8);
+ assert(r == next(m.begin(), 3));
+ r = m.find(9);
+ assert(r == next(m.begin(), 4));
+ r = m.find(10);
+ assert(r == next(m.begin(), 5));
+ r = m.find(11);
+ assert(r == next(m.begin(), 6));
+ r = m.find(12);
+ assert(r == next(m.begin(), 7));
+ r = m.find(4);
+ assert(r == next(m.begin(), 8));
+ }
+ }
+#endif
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef int V;
+ typedef std::multiset<V, std::less<>> M;
+ typedef M::iterator R;
+
+ V ar[] =
+ {
+ 5,
+ 6,
+ 7,
+ 8,
+ 9,
+ 10,
+ 11,
+ 12
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.find(5);
+ assert(r == m.begin());
+ r = m.find(6);
+ assert(r == next(m.begin()));
+ r = m.find(7);
+ assert(r == next(m.begin(), 2));
+ r = m.find(8);
+ assert(r == next(m.begin(), 3));
+ r = m.find(9);
+ assert(r == next(m.begin(), 4));
+ r = m.find(10);
+ assert(r == next(m.begin(), 5));
+ r = m.find(11);
+ assert(r == next(m.begin(), 6));
+ r = m.find(12);
+ assert(r == next(m.begin(), 7));
+ r = m.find(4);
+ assert(r == next(m.begin(), 8));
+ }
+
+ {
+ typedef PrivateConstructor V;
+ typedef std::multiset<V, std::less<>> M;
+ typedef M::iterator R;
+
+ M m;
+ m.insert ( V::make ( 5 ));
+ m.insert ( V::make ( 6 ));
+ m.insert ( V::make ( 7 ));
+ m.insert ( V::make ( 8 ));
+ m.insert ( V::make ( 9 ));
+ m.insert ( V::make ( 10 ));
+ m.insert ( V::make ( 11 ));
+ m.insert ( V::make ( 12 ));
+
+ R r = m.find(5);
+ assert(r == m.begin());
+ r = m.find(6);
+ assert(r == next(m.begin()));
+ r = m.find(7);
+ assert(r == next(m.begin(), 2));
+ r = m.find(8);
+ assert(r == next(m.begin(), 3));
+ r = m.find(9);
+ assert(r == next(m.begin(), 4));
+ r = m.find(10);
+ assert(r == next(m.begin(), 5));
+ r = m.find(11);
+ assert(r == next(m.begin(), 6));
+ r = m.find(12);
+ assert(r == next(m.begin(), 7));
+ r = m.find(4);
+ assert(r == next(m.begin(), 8));
+ }
+#endif
+}
diff --git a/test/std/containers/associative/multiset/insert_cv.pass.cpp b/test/std/containers/associative/multiset/insert_cv.pass.cpp
new file mode 100644
index 000000000000..179715753ab0
--- /dev/null
+++ b/test/std/containers/associative/multiset/insert_cv.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// iterator insert(const value_type& v);
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::multiset<int> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.insert(M::value_type(2));
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(*r == 2);
+
+ r = m.insert(M::value_type(1));
+ assert(r == m.begin());
+ assert(m.size() == 2);
+ assert(*r == 1);
+
+ r = m.insert(M::value_type(3));
+ assert(r == prev(m.end()));
+ assert(m.size() == 3);
+ assert(*r == 3);
+
+ r = m.insert(M::value_type(3));
+ assert(r == prev(m.end()));
+ assert(m.size() == 4);
+ assert(*r == 3);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::multiset<int, std::less<int>, min_allocator<int>> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.insert(M::value_type(2));
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(*r == 2);
+
+ r = m.insert(M::value_type(1));
+ assert(r == m.begin());
+ assert(m.size() == 2);
+ assert(*r == 1);
+
+ r = m.insert(M::value_type(3));
+ assert(r == prev(m.end()));
+ assert(m.size() == 3);
+ assert(*r == 3);
+
+ r = m.insert(M::value_type(3));
+ assert(r == prev(m.end()));
+ assert(m.size() == 4);
+ assert(*r == 3);
+ }
+#endif
+}
diff --git a/test/std/containers/associative/multiset/insert_initializer_list.pass.cpp b/test/std/containers/associative/multiset/insert_initializer_list.pass.cpp
new file mode 100644
index 000000000000..7e923f2516dd
--- /dev/null
+++ b/test/std/containers/associative/multiset/insert_initializer_list.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// void insert(initializer_list<value_type> il);
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::multiset<int> C;
+ typedef C::value_type V;
+ C m = {10, 8};
+ m.insert({1, 2, 3, 4, 5, 6});
+ assert(m.size() == 8);
+ assert(distance(m.begin(), m.end()) == m.size());
+ C::const_iterator i = m.cbegin();
+ assert(*i == V(1));
+ assert(*++i == V(2));
+ assert(*++i == V(3));
+ assert(*++i == V(4));
+ assert(*++i == V(5));
+ assert(*++i == V(6));
+ assert(*++i == V(8));
+ assert(*++i == V(10));
+ }
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+#if __cplusplus >= 201103L
+ {
+ typedef std::multiset<int, std::less<int>, min_allocator<int>> C;
+ typedef C::value_type V;
+ C m = {10, 8};
+ m.insert({1, 2, 3, 4, 5, 6});
+ assert(m.size() == 8);
+ assert(distance(m.begin(), m.end()) == m.size());
+ C::const_iterator i = m.cbegin();
+ assert(*i == V(1));
+ assert(*++i == V(2));
+ assert(*++i == V(3));
+ assert(*++i == V(4));
+ assert(*++i == V(5));
+ assert(*++i == V(6));
+ assert(*++i == V(8));
+ assert(*++i == V(10));
+ }
+#endif
+}
diff --git a/test/std/containers/associative/multiset/insert_iter_cv.pass.cpp b/test/std/containers/associative/multiset/insert_iter_cv.pass.cpp
new file mode 100644
index 000000000000..7d204024c212
--- /dev/null
+++ b/test/std/containers/associative/multiset/insert_iter_cv.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// iterator insert(const_iterator position, const value_type& v);
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::multiset<int> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.insert(m.cend(), M::value_type(2));
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(*r == 2);
+
+ r = m.insert(m.cend(), M::value_type(1));
+ assert(r == m.begin());
+ assert(m.size() == 2);
+ assert(*r == 1);
+
+ r = m.insert(m.cend(), M::value_type(3));
+ assert(r == prev(m.end()));
+ assert(m.size() == 3);
+ assert(*r == 3);
+
+ r = m.insert(m.cend(), M::value_type(3));
+ assert(r == prev(m.end()));
+ assert(m.size() == 4);
+ assert(*r == 3);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::multiset<int, std::less<int>, min_allocator<int>> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.insert(m.cend(), M::value_type(2));
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(*r == 2);
+
+ r = m.insert(m.cend(), M::value_type(1));
+ assert(r == m.begin());
+ assert(m.size() == 2);
+ assert(*r == 1);
+
+ r = m.insert(m.cend(), M::value_type(3));
+ assert(r == prev(m.end()));
+ assert(m.size() == 3);
+ assert(*r == 3);
+
+ r = m.insert(m.cend(), M::value_type(3));
+ assert(r == prev(m.end()));
+ assert(m.size() == 4);
+ assert(*r == 3);
+ }
+#endif
+}
diff --git a/test/std/containers/associative/multiset/insert_iter_iter.pass.cpp b/test/std/containers/associative/multiset/insert_iter_iter.pass.cpp
new file mode 100644
index 000000000000..189c45498669
--- /dev/null
+++ b/test/std/containers/associative/multiset/insert_iter_iter.pass.cpp
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// template <class InputIterator>
+// void insert(InputIterator first, InputIterator last);
+
+#include <set>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::multiset<int> M;
+ typedef int V;
+ V ar[] =
+ {
+ 1,
+ 1,
+ 1,
+ 2,
+ 2,
+ 2,
+ 3,
+ 3,
+ 3
+ };
+ M m;
+ m.insert(input_iterator<const V*>(ar),
+ input_iterator<const V*>(ar + sizeof(ar)/sizeof(ar[0])));
+ assert(m.size() == 9);
+ assert(*next(m.begin(), 0) == 1);
+ assert(*next(m.begin(), 1) == 1);
+ assert(*next(m.begin(), 2) == 1);
+ assert(*next(m.begin(), 3) == 2);
+ assert(*next(m.begin(), 4) == 2);
+ assert(*next(m.begin(), 5) == 2);
+ assert(*next(m.begin(), 6) == 3);
+ assert(*next(m.begin(), 7) == 3);
+ assert(*next(m.begin(), 8) == 3);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::multiset<int, std::less<int>, min_allocator<int>> M;
+ typedef int V;
+ V ar[] =
+ {
+ 1,
+ 1,
+ 1,
+ 2,
+ 2,
+ 2,
+ 3,
+ 3,
+ 3
+ };
+ M m;
+ m.insert(input_iterator<const V*>(ar),
+ input_iterator<const V*>(ar + sizeof(ar)/sizeof(ar[0])));
+ assert(m.size() == 9);
+ assert(*next(m.begin(), 0) == 1);
+ assert(*next(m.begin(), 1) == 1);
+ assert(*next(m.begin(), 2) == 1);
+ assert(*next(m.begin(), 3) == 2);
+ assert(*next(m.begin(), 4) == 2);
+ assert(*next(m.begin(), 5) == 2);
+ assert(*next(m.begin(), 6) == 3);
+ assert(*next(m.begin(), 7) == 3);
+ assert(*next(m.begin(), 8) == 3);
+ }
+#endif
+}
diff --git a/test/std/containers/associative/multiset/insert_iter_rv.pass.cpp b/test/std/containers/associative/multiset/insert_iter_rv.pass.cpp
new file mode 100644
index 000000000000..ee631f005c93
--- /dev/null
+++ b/test/std/containers/associative/multiset/insert_iter_rv.pass.cpp
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// iterator insert(const_iterator position, value_type&& v);
+
+#include <set>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::multiset<MoveOnly> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.insert(m.cend(), M::value_type(2));
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(*r == 2);
+
+ r = m.insert(m.cend(), M::value_type(1));
+ assert(r == m.begin());
+ assert(m.size() == 2);
+ assert(*r == 1);
+
+ r = m.insert(m.cend(), M::value_type(3));
+ assert(r == prev(m.end()));
+ assert(m.size() == 3);
+ assert(*r == 3);
+
+ r = m.insert(m.cend(), M::value_type(3));
+ assert(r == prev(m.end()));
+ assert(m.size() == 4);
+ assert(*r == 3);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if __cplusplus >= 201103L
+ {
+ typedef std::multiset<MoveOnly, std::less<MoveOnly>, min_allocator<MoveOnly>> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.insert(m.cend(), M::value_type(2));
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(*r == 2);
+
+ r = m.insert(m.cend(), M::value_type(1));
+ assert(r == m.begin());
+ assert(m.size() == 2);
+ assert(*r == 1);
+
+ r = m.insert(m.cend(), M::value_type(3));
+ assert(r == prev(m.end()));
+ assert(m.size() == 3);
+ assert(*r == 3);
+
+ r = m.insert(m.cend(), M::value_type(3));
+ assert(r == prev(m.end()));
+ assert(m.size() == 4);
+ assert(*r == 3);
+ }
+#endif
+}
diff --git a/test/std/containers/associative/multiset/insert_rv.pass.cpp b/test/std/containers/associative/multiset/insert_rv.pass.cpp
new file mode 100644
index 000000000000..29c233e9a119
--- /dev/null
+++ b/test/std/containers/associative/multiset/insert_rv.pass.cpp
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// iterator insert(value_type&& v);
+
+#include <set>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::multiset<MoveOnly> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.insert(M::value_type(2));
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(*r == 2);
+
+ r = m.insert(M::value_type(1));
+ assert(r == m.begin());
+ assert(m.size() == 2);
+ assert(*r == 1);
+
+ r = m.insert(M::value_type(3));
+ assert(r == prev(m.end()));
+ assert(m.size() == 3);
+ assert(*r == 3);
+
+ r = m.insert(M::value_type(3));
+ assert(r == prev(m.end()));
+ assert(m.size() == 4);
+ assert(*r == 3);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if __cplusplus >= 201103L
+ {
+ typedef std::multiset<MoveOnly, std::less<MoveOnly>, min_allocator<MoveOnly>> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.insert(M::value_type(2));
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(*r == 2);
+
+ r = m.insert(M::value_type(1));
+ assert(r == m.begin());
+ assert(m.size() == 2);
+ assert(*r == 1);
+
+ r = m.insert(M::value_type(3));
+ assert(r == prev(m.end()));
+ assert(m.size() == 3);
+ assert(*r == 3);
+
+ r = m.insert(M::value_type(3));
+ assert(r == prev(m.end()));
+ assert(m.size() == 4);
+ assert(*r == 3);
+ }
+#endif
+}
diff --git a/test/std/containers/associative/multiset/iterator.pass.cpp b/test/std/containers/associative/multiset/iterator.pass.cpp
new file mode 100644
index 000000000000..d1f0ecfd6aa0
--- /dev/null
+++ b/test/std/containers/associative/multiset/iterator.pass.cpp
@@ -0,0 +1,215 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// iterator begin();
+// const_iterator begin() const;
+// iterator end();
+// const_iterator end() const;
+//
+// reverse_iterator rbegin();
+// const_reverse_iterator rbegin() const;
+// reverse_iterator rend();
+// const_reverse_iterator rend() const;
+//
+// const_iterator cbegin() const;
+// const_iterator cend() const;
+// const_reverse_iterator crbegin() const;
+// const_reverse_iterator crend() const;
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int V;
+ V ar[] =
+ {
+ 1,
+ 1,
+ 1,
+ 2,
+ 2,
+ 2,
+ 3,
+ 3,
+ 3,
+ 4,
+ 4,
+ 4,
+ 5,
+ 5,
+ 5,
+ 6,
+ 6,
+ 6,
+ 7,
+ 7,
+ 7,
+ 8,
+ 8,
+ 8
+ };
+ std::multiset<int> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ assert(std::distance(m.begin(), m.end()) == m.size());
+ assert(std::distance(m.rbegin(), m.rend()) == m.size());
+ std::multiset<int>::iterator i;
+ i = m.begin();
+ std::multiset<int>::const_iterator k = i;
+ assert(i == k);
+ for (int j = 1; j <= 8; ++j)
+ for (int k = 0; k < 3; ++k, ++i)
+ assert(*i == j);
+ }
+ {
+ typedef int V;
+ V ar[] =
+ {
+ 1,
+ 1,
+ 1,
+ 2,
+ 2,
+ 2,
+ 3,
+ 3,
+ 3,
+ 4,
+ 4,
+ 4,
+ 5,
+ 5,
+ 5,
+ 6,
+ 6,
+ 6,
+ 7,
+ 7,
+ 7,
+ 8,
+ 8,
+ 8
+ };
+ const std::multiset<int> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ assert(std::distance(m.begin(), m.end()) == m.size());
+ assert(std::distance(m.cbegin(), m.cend()) == m.size());
+ assert(std::distance(m.rbegin(), m.rend()) == m.size());
+ assert(std::distance(m.crbegin(), m.crend()) == m.size());
+ std::multiset<int>::const_iterator i;
+ i = m.begin();
+ for (int j = 1; j <= 8; ++j)
+ for (int k = 0; k < 3; ++k, ++i)
+ assert(*i == j);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int V;
+ V ar[] =
+ {
+ 1,
+ 1,
+ 1,
+ 2,
+ 2,
+ 2,
+ 3,
+ 3,
+ 3,
+ 4,
+ 4,
+ 4,
+ 5,
+ 5,
+ 5,
+ 6,
+ 6,
+ 6,
+ 7,
+ 7,
+ 7,
+ 8,
+ 8,
+ 8
+ };
+ std::multiset<int, std::less<int>, min_allocator<int>> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ assert(std::distance(m.begin(), m.end()) == m.size());
+ assert(std::distance(m.rbegin(), m.rend()) == m.size());
+ std::multiset<int, std::less<int>, min_allocator<int>>::iterator i;
+ i = m.begin();
+ std::multiset<int, std::less<int>, min_allocator<int>>::const_iterator k = i;
+ assert(i == k);
+ for (int j = 1; j <= 8; ++j)
+ for (int k = 0; k < 3; ++k, ++i)
+ assert(*i == j);
+ }
+ {
+ typedef int V;
+ V ar[] =
+ {
+ 1,
+ 1,
+ 1,
+ 2,
+ 2,
+ 2,
+ 3,
+ 3,
+ 3,
+ 4,
+ 4,
+ 4,
+ 5,
+ 5,
+ 5,
+ 6,
+ 6,
+ 6,
+ 7,
+ 7,
+ 7,
+ 8,
+ 8,
+ 8
+ };
+ const std::multiset<int, std::less<int>, min_allocator<int>> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ assert(std::distance(m.begin(), m.end()) == m.size());
+ assert(std::distance(m.cbegin(), m.cend()) == m.size());
+ assert(std::distance(m.rbegin(), m.rend()) == m.size());
+ assert(std::distance(m.crbegin(), m.crend()) == m.size());
+ std::multiset<int, std::less<int>, min_allocator<int>>::const_iterator i;
+ i = m.begin();
+ for (int j = 1; j <= 8; ++j)
+ for (int k = 0; k < 3; ++k, ++i)
+ assert(*i == j);
+ }
+#endif
+#if _LIBCPP_STD_VER > 11
+ { // N3644 testing
+ typedef std::multiset<int> C;
+ C::iterator ii1{}, ii2{};
+ C::iterator ii4 = ii1;
+ C::const_iterator cii{};
+ assert ( ii1 == ii2 );
+ assert ( ii1 == ii4 );
+
+ assert (!(ii1 != ii2 ));
+
+ assert ( (ii1 == cii ));
+ assert ( (cii == ii1 ));
+ assert (!(ii1 != cii ));
+ assert (!(cii != ii1 ));
+ }
+#endif
+}
diff --git a/test/std/containers/associative/multiset/lower_bound.pass.cpp b/test/std/containers/associative/multiset/lower_bound.pass.cpp
new file mode 100644
index 000000000000..e466791d9356
--- /dev/null
+++ b/test/std/containers/associative/multiset/lower_bound.pass.cpp
@@ -0,0 +1,223 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// iterator lower_bound(const key_type& k);
+// const_iterator lower_bound(const key_type& k) const;
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "private_constructor.hpp"
+
+int main()
+{
+ {
+ typedef int V;
+ typedef std::multiset<int> M;
+ {
+ typedef M::iterator R;
+ V ar[] =
+ {
+ 5,
+ 5,
+ 5,
+ 7,
+ 7,
+ 7,
+ 9,
+ 9,
+ 9
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.lower_bound(4);
+ assert(r == next(m.begin(), 0));
+ r = m.lower_bound(5);
+ assert(r == next(m.begin(), 0));
+ r = m.lower_bound(6);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(7);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(8);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(9);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(11);
+ assert(r == next(m.begin(), 9));
+ }
+ {
+ typedef M::const_iterator R;
+ V ar[] =
+ {
+ 5,
+ 5,
+ 5,
+ 7,
+ 7,
+ 7,
+ 9,
+ 9,
+ 9
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.lower_bound(4);
+ assert(r == next(m.begin(), 0));
+ r = m.lower_bound(5);
+ assert(r == next(m.begin(), 0));
+ r = m.lower_bound(6);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(7);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(8);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(9);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(11);
+ assert(r == next(m.begin(), 9));
+ }
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int V;
+ typedef std::multiset<int, std::less<int>, min_allocator<int>> M;
+ {
+ typedef M::iterator R;
+ V ar[] =
+ {
+ 5,
+ 5,
+ 5,
+ 7,
+ 7,
+ 7,
+ 9,
+ 9,
+ 9
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.lower_bound(4);
+ assert(r == next(m.begin(), 0));
+ r = m.lower_bound(5);
+ assert(r == next(m.begin(), 0));
+ r = m.lower_bound(6);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(7);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(8);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(9);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(11);
+ assert(r == next(m.begin(), 9));
+ }
+ {
+ typedef M::const_iterator R;
+ V ar[] =
+ {
+ 5,
+ 5,
+ 5,
+ 7,
+ 7,
+ 7,
+ 9,
+ 9,
+ 9
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.lower_bound(4);
+ assert(r == next(m.begin(), 0));
+ r = m.lower_bound(5);
+ assert(r == next(m.begin(), 0));
+ r = m.lower_bound(6);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(7);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(8);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(9);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(11);
+ assert(r == next(m.begin(), 9));
+ }
+ }
+#endif
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef int V;
+ typedef std::multiset<V, std::less<>> M;
+
+ typedef M::iterator R;
+ V ar[] =
+ {
+ 5,
+ 5,
+ 5,
+ 7,
+ 7,
+ 7,
+ 9,
+ 9,
+ 9
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+
+ R r = m.lower_bound(4);
+ assert(r == next(m.begin(), 0));
+ r = m.lower_bound(5);
+ assert(r == next(m.begin(), 0));
+ r = m.lower_bound(6);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(7);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(8);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(9);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(11);
+ assert(r == next(m.begin(), 9));
+ }
+
+ {
+ typedef PrivateConstructor V;
+ typedef std::multiset<V, std::less<>> M;
+ typedef M::iterator R;
+
+ M m;
+ m.insert ( V::make ( 5 ));
+ m.insert ( V::make ( 5 ));
+ m.insert ( V::make ( 5 ));
+ m.insert ( V::make ( 7 ));
+ m.insert ( V::make ( 7 ));
+ m.insert ( V::make ( 7 ));
+ m.insert ( V::make ( 9 ));
+ m.insert ( V::make ( 9 ));
+ m.insert ( V::make ( 9 ));
+
+ R r = m.lower_bound(4);
+ assert(r == next(m.begin(), 0));
+ r = m.lower_bound(5);
+ assert(r == next(m.begin(), 0));
+ r = m.lower_bound(6);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(7);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(8);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(9);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(11);
+ assert(r == next(m.begin(), 9));
+ }
+#endif
+}
diff --git a/test/std/containers/associative/multiset/max_size.pass.cpp b/test/std/containers/associative/multiset/max_size.pass.cpp
new file mode 100644
index 000000000000..5524f771b341
--- /dev/null
+++ b/test/std/containers/associative/multiset/max_size.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// size_type max_size() const;
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::multiset<int> M;
+ M m;
+ assert(m.max_size() != 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::multiset<int, std::less<int>, min_allocator<int>> M;
+ M m;
+ assert(m.max_size() != 0);
+ }
+#endif
+}
diff --git a/test/std/containers/associative/multiset/multiset.cons/alloc.pass.cpp b/test/std/containers/associative/multiset/multiset.cons/alloc.pass.cpp
new file mode 100644
index 000000000000..0a7572275afa
--- /dev/null
+++ b/test/std/containers/associative/multiset/multiset.cons/alloc.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// multiset(const allocator_type& a);
+
+#include <set>
+#include <cassert>
+
+#include "test_allocator.h"
+
+int main()
+{
+ typedef std::less<int> C;
+ typedef test_allocator<int> A;
+ std::multiset<int, C, A> m(A(5));
+ assert(m.empty());
+ assert(m.begin() == m.end());
+ assert(m.get_allocator() == A(5));
+}
diff --git a/test/std/containers/associative/multiset/multiset.cons/assign_initializer_list.pass.cpp b/test/std/containers/associative/multiset/multiset.cons/assign_initializer_list.pass.cpp
new file mode 100644
index 000000000000..7d76581d6d8e
--- /dev/null
+++ b/test/std/containers/associative/multiset/multiset.cons/assign_initializer_list.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// multiset& operator=(initializer_list<value_type> il);
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::multiset<int> C;
+ typedef C::value_type V;
+ C m = {10, 8};
+ m = {1, 2, 3, 4, 5, 6};
+ assert(m.size() == 6);
+ assert(distance(m.begin(), m.end()) == 6);
+ C::const_iterator i = m.cbegin();
+ assert(*i == V(1));
+ assert(*++i == V(2));
+ assert(*++i == V(3));
+ assert(*++i == V(4));
+ assert(*++i == V(5));
+ assert(*++i == V(6));
+ }
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+#if __cplusplus >= 201103L
+ {
+ typedef std::multiset<int, std::less<int>, min_allocator<int>> C;
+ typedef C::value_type V;
+ C m = {10, 8};
+ m = {1, 2, 3, 4, 5, 6};
+ assert(m.size() == 6);
+ assert(distance(m.begin(), m.end()) == 6);
+ C::const_iterator i = m.cbegin();
+ assert(*i == V(1));
+ assert(*++i == V(2));
+ assert(*++i == V(3));
+ assert(*++i == V(4));
+ assert(*++i == V(5));
+ assert(*++i == V(6));
+ }
+#endif
+}
diff --git a/test/std/containers/associative/multiset/multiset.cons/compare.pass.cpp b/test/std/containers/associative/multiset/multiset.cons/compare.pass.cpp
new file mode 100644
index 000000000000..84038ca1e142
--- /dev/null
+++ b/test/std/containers/associative/multiset/multiset.cons/compare.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// explicit multiset(const value_compare& comp);
+
+#include <set>
+#include <cassert>
+
+#include "../../../test_compare.h"
+
+int main()
+{
+ typedef test_compare<std::less<int> > C;
+ std::multiset<int, C> m(C(3));
+ assert(m.empty());
+ assert(m.begin() == m.end());
+ assert(m.key_comp() == C(3));
+}
diff --git a/test/std/containers/associative/multiset/multiset.cons/compare_alloc.pass.cpp b/test/std/containers/associative/multiset/multiset.cons/compare_alloc.pass.cpp
new file mode 100644
index 000000000000..76c9f8b2a8a1
--- /dev/null
+++ b/test/std/containers/associative/multiset/multiset.cons/compare_alloc.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// multiset(const value_compare& comp, const allocator_type& a);
+
+#include <set>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+
+int main()
+{
+ typedef test_compare<std::less<int> > C;
+ typedef test_allocator<int> A;
+ std::multiset<int, C, A> m(C(4), A(5));
+ assert(m.empty());
+ assert(m.begin() == m.end());
+ assert(m.key_comp() == C(4));
+ assert(m.get_allocator() == A(5));
+}
diff --git a/test/std/containers/associative/multiset/multiset.cons/copy.pass.cpp b/test/std/containers/associative/multiset/multiset.cons/copy.pass.cpp
new file mode 100644
index 000000000000..dde362872109
--- /dev/null
+++ b/test/std/containers/associative/multiset/multiset.cons/copy.pass.cpp
@@ -0,0 +1,118 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// multiset(const multiset& m);
+
+#include <set>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+
+int main()
+{
+ {
+ typedef int V;
+ V ar[] =
+ {
+ 1,
+ 1,
+ 1,
+ 2,
+ 2,
+ 2,
+ 3,
+ 3,
+ 3
+ };
+ typedef test_compare<std::less<int> > C;
+ typedef test_allocator<V> A;
+ std::multiset<int, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
+ std::multiset<int, C, A> m = mo;
+ assert(m.get_allocator() == A(7));
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 9);
+ assert(distance(m.begin(), m.end()) == 9);
+ assert(*next(m.begin(), 0) == 1);
+ assert(*next(m.begin(), 1) == 1);
+ assert(*next(m.begin(), 2) == 1);
+ assert(*next(m.begin(), 3) == 2);
+ assert(*next(m.begin(), 4) == 2);
+ assert(*next(m.begin(), 5) == 2);
+ assert(*next(m.begin(), 6) == 3);
+ assert(*next(m.begin(), 7) == 3);
+ assert(*next(m.begin(), 8) == 3);
+
+ assert(mo.get_allocator() == A(7));
+ assert(mo.key_comp() == C(5));
+ assert(mo.size() == 9);
+ assert(distance(mo.begin(), mo.end()) == 9);
+ assert(*next(mo.begin(), 0) == 1);
+ assert(*next(mo.begin(), 1) == 1);
+ assert(*next(mo.begin(), 2) == 1);
+ assert(*next(mo.begin(), 3) == 2);
+ assert(*next(mo.begin(), 4) == 2);
+ assert(*next(mo.begin(), 5) == 2);
+ assert(*next(mo.begin(), 6) == 3);
+ assert(*next(mo.begin(), 7) == 3);
+ assert(*next(mo.begin(), 8) == 3);
+ }
+#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+ {
+ typedef int V;
+ V ar[] =
+ {
+ 1,
+ 1,
+ 1,
+ 2,
+ 2,
+ 2,
+ 3,
+ 3,
+ 3
+ };
+ typedef test_compare<std::less<int> > C;
+ typedef other_allocator<V> A;
+ std::multiset<int, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
+ std::multiset<int, C, A> m = mo;
+ assert(m.get_allocator() == A(-2));
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 9);
+ assert(distance(m.begin(), m.end()) == 9);
+ assert(*next(m.begin(), 0) == 1);
+ assert(*next(m.begin(), 1) == 1);
+ assert(*next(m.begin(), 2) == 1);
+ assert(*next(m.begin(), 3) == 2);
+ assert(*next(m.begin(), 4) == 2);
+ assert(*next(m.begin(), 5) == 2);
+ assert(*next(m.begin(), 6) == 3);
+ assert(*next(m.begin(), 7) == 3);
+ assert(*next(m.begin(), 8) == 3);
+
+ assert(mo.get_allocator() == A(7));
+ assert(mo.key_comp() == C(5));
+ assert(mo.size() == 9);
+ assert(distance(mo.begin(), mo.end()) == 9);
+ assert(*next(mo.begin(), 0) == 1);
+ assert(*next(mo.begin(), 1) == 1);
+ assert(*next(mo.begin(), 2) == 1);
+ assert(*next(mo.begin(), 3) == 2);
+ assert(*next(mo.begin(), 4) == 2);
+ assert(*next(mo.begin(), 5) == 2);
+ assert(*next(mo.begin(), 6) == 3);
+ assert(*next(mo.begin(), 7) == 3);
+ assert(*next(mo.begin(), 8) == 3);
+ }
+#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE
+}
diff --git a/test/std/containers/associative/multiset/multiset.cons/copy_alloc.pass.cpp b/test/std/containers/associative/multiset/multiset.cons/copy_alloc.pass.cpp
new file mode 100644
index 000000000000..04a769e73328
--- /dev/null
+++ b/test/std/containers/associative/multiset/multiset.cons/copy_alloc.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// multiset(const multiset& m, const allocator_type& a);
+
+#include <set>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+
+int main()
+{
+ typedef int V;
+ V ar[] =
+ {
+ 1,
+ 1,
+ 1,
+ 2,
+ 2,
+ 2,
+ 3,
+ 3,
+ 3
+ };
+ typedef test_compare<std::less<int> > C;
+ typedef test_allocator<V> A;
+ std::multiset<int, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
+ std::multiset<int, C, A> m(mo, A(3));
+ assert(m.get_allocator() == A(3));
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 9);
+ assert(distance(m.begin(), m.end()) == 9);
+ assert(*next(m.begin(), 0) == 1);
+ assert(*next(m.begin(), 1) == 1);
+ assert(*next(m.begin(), 2) == 1);
+ assert(*next(m.begin(), 3) == 2);
+ assert(*next(m.begin(), 4) == 2);
+ assert(*next(m.begin(), 5) == 2);
+ assert(*next(m.begin(), 6) == 3);
+ assert(*next(m.begin(), 7) == 3);
+ assert(*next(m.begin(), 8) == 3);
+
+ assert(mo.get_allocator() == A(7));
+ assert(mo.key_comp() == C(5));
+ assert(mo.size() == 9);
+ assert(distance(mo.begin(), mo.end()) == 9);
+ assert(*next(mo.begin(), 0) == 1);
+ assert(*next(mo.begin(), 1) == 1);
+ assert(*next(mo.begin(), 2) == 1);
+ assert(*next(mo.begin(), 3) == 2);
+ assert(*next(mo.begin(), 4) == 2);
+ assert(*next(mo.begin(), 5) == 2);
+ assert(*next(mo.begin(), 6) == 3);
+ assert(*next(mo.begin(), 7) == 3);
+ assert(*next(mo.begin(), 8) == 3);
+}
diff --git a/test/std/containers/associative/multiset/multiset.cons/copy_assign.pass.cpp b/test/std/containers/associative/multiset/multiset.cons/copy_assign.pass.cpp
new file mode 100644
index 000000000000..cca636325ffc
--- /dev/null
+++ b/test/std/containers/associative/multiset/multiset.cons/copy_assign.pass.cpp
@@ -0,0 +1,138 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// multiset& operator=(const multiset& s);
+
+#include <set>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+
+int main()
+{
+ {
+ typedef int V;
+ V ar[] =
+ {
+ 1,
+ 1,
+ 1,
+ 2,
+ 2,
+ 2,
+ 3,
+ 3,
+ 3
+ };
+ typedef test_compare<std::less<int> > C;
+ typedef test_allocator<V> A;
+ std::multiset<int, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(2));
+ std::multiset<int, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0])/2, C(3), A(7));
+ m = mo;
+ assert(m.get_allocator() == A(7));
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 9);
+ assert(distance(m.begin(), m.end()) == 9);
+ assert(*next(m.begin(), 0) == 1);
+ assert(*next(m.begin(), 1) == 1);
+ assert(*next(m.begin(), 2) == 1);
+ assert(*next(m.begin(), 3) == 2);
+ assert(*next(m.begin(), 4) == 2);
+ assert(*next(m.begin(), 5) == 2);
+ assert(*next(m.begin(), 6) == 3);
+ assert(*next(m.begin(), 7) == 3);
+ assert(*next(m.begin(), 8) == 3);
+
+ assert(mo.get_allocator() == A(2));
+ assert(mo.key_comp() == C(5));
+ assert(mo.size() == 9);
+ assert(distance(mo.begin(), mo.end()) == 9);
+ assert(*next(mo.begin(), 0) == 1);
+ assert(*next(mo.begin(), 1) == 1);
+ assert(*next(mo.begin(), 2) == 1);
+ assert(*next(mo.begin(), 3) == 2);
+ assert(*next(mo.begin(), 4) == 2);
+ assert(*next(mo.begin(), 5) == 2);
+ assert(*next(mo.begin(), 6) == 3);
+ assert(*next(mo.begin(), 7) == 3);
+ assert(*next(mo.begin(), 8) == 3);
+ }
+ {
+ typedef int V;
+ const V ar[] =
+ {
+ 1,
+ 1,
+ 1,
+ 2,
+ 2,
+ 2,
+ 3,
+ 3,
+ 3
+ };
+ std::multiset<int> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ std::multiset<int> *p = &m;
+ m = *p;
+ assert(m.size() == 9);
+ assert(std::equal(m.begin(), m.end(), ar));
+ }
+ {
+ typedef int V;
+ V ar[] =
+ {
+ 1,
+ 1,
+ 1,
+ 2,
+ 2,
+ 2,
+ 3,
+ 3,
+ 3
+ };
+ typedef test_compare<std::less<int> > C;
+ typedef other_allocator<V> A;
+ std::multiset<int, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(2));
+ std::multiset<int, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0])/2, C(3), A(7));
+ m = mo;
+ assert(m.get_allocator() == A(2));
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 9);
+ assert(distance(m.begin(), m.end()) == 9);
+ assert(*next(m.begin(), 0) == 1);
+ assert(*next(m.begin(), 1) == 1);
+ assert(*next(m.begin(), 2) == 1);
+ assert(*next(m.begin(), 3) == 2);
+ assert(*next(m.begin(), 4) == 2);
+ assert(*next(m.begin(), 5) == 2);
+ assert(*next(m.begin(), 6) == 3);
+ assert(*next(m.begin(), 7) == 3);
+ assert(*next(m.begin(), 8) == 3);
+
+ assert(mo.get_allocator() == A(2));
+ assert(mo.key_comp() == C(5));
+ assert(mo.size() == 9);
+ assert(distance(mo.begin(), mo.end()) == 9);
+ assert(*next(mo.begin(), 0) == 1);
+ assert(*next(mo.begin(), 1) == 1);
+ assert(*next(mo.begin(), 2) == 1);
+ assert(*next(mo.begin(), 3) == 2);
+ assert(*next(mo.begin(), 4) == 2);
+ assert(*next(mo.begin(), 5) == 2);
+ assert(*next(mo.begin(), 6) == 3);
+ assert(*next(mo.begin(), 7) == 3);
+ assert(*next(mo.begin(), 8) == 3);
+ }
+}
diff --git a/test/std/containers/associative/multiset/multiset.cons/default.pass.cpp b/test/std/containers/associative/multiset/multiset.cons/default.pass.cpp
new file mode 100644
index 000000000000..5bb0312f012b
--- /dev/null
+++ b/test/std/containers/associative/multiset/multiset.cons/default.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// multiset();
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::multiset<int> m;
+ assert(m.empty());
+ assert(m.begin() == m.end());
+ }
+#if __cplusplus >= 201103L
+ {
+ std::multiset<int, std::less<int>, min_allocator<int>> m;
+ assert(m.empty());
+ assert(m.begin() == m.end());
+ }
+ {
+ std::multiset<int> m = {};
+ assert(m.empty());
+ assert(m.begin() == m.end());
+ }
+#endif
+}
diff --git a/test/std/containers/associative/multiset/multiset.cons/default_noexcept.pass.cpp b/test/std/containers/associative/multiset/multiset.cons/default_noexcept.pass.cpp
new file mode 100644
index 000000000000..bf8c53b9ee5d
--- /dev/null
+++ b/test/std/containers/associative/multiset/multiset.cons/default_noexcept.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// multiset()
+// noexcept(
+// is_nothrow_default_constructible<allocator_type>::value &&
+// is_nothrow_default_constructible<key_compare>::value &&
+// is_nothrow_copy_constructible<key_compare>::value);
+
+// This tests a conforming extension
+
+#include <set>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_comp
+{
+ typedef T value_type;
+ some_comp();
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::multiset<MoveOnly> C;
+ static_assert(std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::multiset<MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::multiset<MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C;
+ static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::multiset<MoveOnly, some_comp<MoveOnly>> C;
+ static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+ }
+#endif
+}
diff --git a/test/std/containers/associative/multiset/multiset.cons/dtor_noexcept.pass.cpp b/test/std/containers/associative/multiset/multiset.cons/dtor_noexcept.pass.cpp
new file mode 100644
index 000000000000..fd612c06dbbc
--- /dev/null
+++ b/test/std/containers/associative/multiset/multiset.cons/dtor_noexcept.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// ~multiset() // implied noexcept;
+
+#include <set>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "test_allocator.h"
+
+#if __has_feature(cxx_noexcept)
+
+template <class T>
+struct some_comp
+{
+ typedef T value_type;
+ ~some_comp() noexcept(false);
+};
+
+#endif
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::multiset<MoveOnly> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::multiset<MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::multiset<MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::multiset<MoveOnly, some_comp<MoveOnly>> C;
+ static_assert(!std::is_nothrow_destructible<C>::value, "");
+ }
+#endif
+}
diff --git a/test/std/containers/associative/multiset/multiset.cons/initializer_list.pass.cpp b/test/std/containers/associative/multiset/multiset.cons/initializer_list.pass.cpp
new file mode 100644
index 000000000000..dadafec7c3b1
--- /dev/null
+++ b/test/std/containers/associative/multiset/multiset.cons/initializer_list.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// multiset(initializer_list<value_type> il, const key_compare& comp = key_compare());
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::multiset<int> C;
+ typedef C::value_type V;
+ C m = {1, 2, 3, 4, 5, 6};
+ assert(m.size() == 6);
+ assert(distance(m.begin(), m.end()) == 6);
+ C::const_iterator i = m.cbegin();
+ assert(*i == V(1));
+ assert(*++i == V(2));
+ assert(*++i == V(3));
+ assert(*++i == V(4));
+ assert(*++i == V(5));
+ assert(*++i == V(6));
+ }
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+#if __cplusplus >= 201103L
+ {
+ typedef std::multiset<int, std::less<int>, min_allocator<int>> C;
+ typedef C::value_type V;
+ C m = {1, 2, 3, 4, 5, 6};
+ assert(m.size() == 6);
+ assert(distance(m.begin(), m.end()) == 6);
+ C::const_iterator i = m.cbegin();
+ assert(*i == V(1));
+ assert(*++i == V(2));
+ assert(*++i == V(3));
+ assert(*++i == V(4));
+ assert(*++i == V(5));
+ assert(*++i == V(6));
+ }
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::multiset<int, std::less<int>, min_allocator<int>> C;
+ typedef C::value_type V;
+ min_allocator<int> a;
+ C m ({1, 2, 3, 4, 5, 6}, a);
+ assert(m.size() == 6);
+ assert(distance(m.begin(), m.end()) == 6);
+ C::const_iterator i = m.cbegin();
+ assert(*i == V(1));
+ assert(*++i == V(2));
+ assert(*++i == V(3));
+ assert(*++i == V(4));
+ assert(*++i == V(5));
+ assert(*++i == V(6));
+ assert(m.get_allocator() == a);
+ }
+#endif
+#endif
+}
diff --git a/test/std/containers/associative/multiset/multiset.cons/initializer_list_compare.pass.cpp b/test/std/containers/associative/multiset/multiset.cons/initializer_list_compare.pass.cpp
new file mode 100644
index 000000000000..c67657aff8ac
--- /dev/null
+++ b/test/std/containers/associative/multiset/multiset.cons/initializer_list_compare.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// multiset(initializer_list<value_type> il, const key_compare& comp = key_compare());
+
+#include <set>
+#include <cassert>
+#include "../../../test_compare.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ typedef test_compare<std::less<int> > Cmp;
+ typedef std::multiset<int, Cmp> C;
+ typedef C::value_type V;
+ C m({1, 2, 3, 4, 5, 6}, Cmp(10));
+ assert(m.size() == 6);
+ assert(distance(m.begin(), m.end()) == 6);
+ C::const_iterator i = m.cbegin();
+ assert(*i == V(1));
+ assert(*++i == V(2));
+ assert(*++i == V(3));
+ assert(*++i == V(4));
+ assert(*++i == V(5));
+ assert(*++i == V(6));
+ assert(m.key_comp() == Cmp(10));
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/containers/associative/multiset/multiset.cons/initializer_list_compare_alloc.pass.cpp b/test/std/containers/associative/multiset/multiset.cons/initializer_list_compare_alloc.pass.cpp
new file mode 100644
index 000000000000..83114893a1b2
--- /dev/null
+++ b/test/std/containers/associative/multiset/multiset.cons/initializer_list_compare_alloc.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// multiset(initializer_list<value_type> il, const key_compare& comp, const allocator_type& a);
+
+#include <set>
+#include <cassert>
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ typedef test_compare<std::less<int> > Cmp;
+ typedef test_allocator<int> A;
+ typedef std::multiset<int, Cmp, A> C;
+ typedef C::value_type V;
+ C m({1, 2, 3, 4, 5, 6}, Cmp(10), A(4));
+ assert(m.size() == 6);
+ assert(distance(m.begin(), m.end()) == 6);
+ C::const_iterator i = m.cbegin();
+ assert(*i == V(1));
+ assert(*++i == V(2));
+ assert(*++i == V(3));
+ assert(*++i == V(4));
+ assert(*++i == V(5));
+ assert(*++i == V(6));
+ assert(m.key_comp() == Cmp(10));
+ assert(m.get_allocator() == A(4));
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/containers/associative/multiset/multiset.cons/iter_iter.pass.cpp b/test/std/containers/associative/multiset/multiset.cons/iter_iter.pass.cpp
new file mode 100644
index 000000000000..f6c1fd76de14
--- /dev/null
+++ b/test/std/containers/associative/multiset/multiset.cons/iter_iter.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// template <class InputIterator>
+// multiset(InputIterator first, InputIterator last);
+
+#include <set>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int V;
+ V ar[] =
+ {
+ 1,
+ 1,
+ 1,
+ 2,
+ 2,
+ 2,
+ 3,
+ 3,
+ 3
+ };
+ std::multiset<V> m(input_iterator<const int*>(ar),
+ input_iterator<const int*>(ar+sizeof(ar)/sizeof(ar[0])));
+ assert(m.size() == 9);
+ assert(distance(m.begin(), m.end()) == 9);
+ assert(*next(m.begin(), 0) == 1);
+ assert(*next(m.begin(), 1) == 1);
+ assert(*next(m.begin(), 2) == 1);
+ assert(*next(m.begin(), 3) == 2);
+ assert(*next(m.begin(), 4) == 2);
+ assert(*next(m.begin(), 5) == 2);
+ assert(*next(m.begin(), 6) == 3);
+ assert(*next(m.begin(), 7) == 3);
+ assert(*next(m.begin(), 8) == 3);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int V;
+ V ar[] =
+ {
+ 1,
+ 1,
+ 1,
+ 2,
+ 2,
+ 2,
+ 3,
+ 3,
+ 3
+ };
+ std::multiset<V, std::less<V>, min_allocator<V>> m(input_iterator<const int*>(ar),
+ input_iterator<const int*>(ar+sizeof(ar)/sizeof(ar[0])));
+ assert(m.size() == 9);
+ assert(distance(m.begin(), m.end()) == 9);
+ assert(*next(m.begin(), 0) == 1);
+ assert(*next(m.begin(), 1) == 1);
+ assert(*next(m.begin(), 2) == 1);
+ assert(*next(m.begin(), 3) == 2);
+ assert(*next(m.begin(), 4) == 2);
+ assert(*next(m.begin(), 5) == 2);
+ assert(*next(m.begin(), 6) == 3);
+ assert(*next(m.begin(), 7) == 3);
+ assert(*next(m.begin(), 8) == 3);
+ }
+#endif
+}
diff --git a/test/std/containers/associative/multiset/multiset.cons/iter_iter_alloc.pass.cpp b/test/std/containers/associative/multiset/multiset.cons/iter_iter_alloc.pass.cpp
new file mode 100644
index 000000000000..4ed00c7124cc
--- /dev/null
+++ b/test/std/containers/associative/multiset/multiset.cons/iter_iter_alloc.pass.cpp
@@ -0,0 +1,92 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// template <class InputIterator>
+// multiset(InputIterator first, InputIterator last,
+// const value_compare& comp, const allocator_type& a);
+
+#include <set>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+
+int main()
+{
+ typedef int V;
+ V ar[] =
+ {
+ 1,
+ 1,
+ 1,
+ 2,
+ 2,
+ 2,
+ 3,
+ 3,
+ 3
+ };
+ typedef test_compare<std::less<V> > C;
+ typedef test_allocator<V> A;
+ std::multiset<V, C, A> m(input_iterator<const V*>(ar),
+ input_iterator<const V*>(ar+sizeof(ar)/sizeof(ar[0])),
+ C(5), A(7));
+ assert(m.value_comp() == C(5));
+ assert(m.get_allocator() == A(7));
+ assert(m.size() == 9);
+ assert(distance(m.begin(), m.end()) == 9);
+ assert(*next(m.begin(), 0) == 1);
+ assert(*next(m.begin(), 1) == 1);
+ assert(*next(m.begin(), 2) == 1);
+ assert(*next(m.begin(), 3) == 2);
+ assert(*next(m.begin(), 4) == 2);
+ assert(*next(m.begin(), 5) == 2);
+ assert(*next(m.begin(), 6) == 3);
+ assert(*next(m.begin(), 7) == 3);
+ assert(*next(m.begin(), 8) == 3);
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef int V;
+ V ar[] =
+ {
+ 1,
+ 1,
+ 1,
+ 2,
+ 2,
+ 2,
+ 3,
+ 3,
+ 3
+ };
+ typedef test_allocator<V> A;
+ typedef test_compare<std::less<int> > C;
+ A a;
+ std::multiset<V, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0]), a);
+
+ assert(m.size() == 9);
+ assert(distance(m.begin(), m.end()) == 9);
+ assert(*next(m.begin(), 0) == 1);
+ assert(*next(m.begin(), 1) == 1);
+ assert(*next(m.begin(), 2) == 1);
+ assert(*next(m.begin(), 3) == 2);
+ assert(*next(m.begin(), 4) == 2);
+ assert(*next(m.begin(), 5) == 2);
+ assert(*next(m.begin(), 6) == 3);
+ assert(*next(m.begin(), 7) == 3);
+ assert(*next(m.begin(), 8) == 3);
+ assert(m.get_allocator() == a);
+ }
+#endif
+}
diff --git a/test/std/containers/associative/multiset/multiset.cons/iter_iter_comp.pass.cpp b/test/std/containers/associative/multiset/multiset.cons/iter_iter_comp.pass.cpp
new file mode 100644
index 000000000000..0bbaaf12eab3
--- /dev/null
+++ b/test/std/containers/associative/multiset/multiset.cons/iter_iter_comp.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// template <class InputIterator>
+// multiset(InputIterator first, InputIterator last, const value_compare& comp);
+
+#include <set>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "../../../test_compare.h"
+
+int main()
+{
+ typedef int V;
+ V ar[] =
+ {
+ 1,
+ 1,
+ 1,
+ 2,
+ 2,
+ 2,
+ 3,
+ 3,
+ 3
+ };
+ typedef test_compare<std::less<V> > C;
+ std::multiset<V, C> m(input_iterator<const V*>(ar),
+ input_iterator<const V*>(ar+sizeof(ar)/sizeof(ar[0])), C(5));
+ assert(m.value_comp() == C(5));
+ assert(m.size() == 9);
+ assert(distance(m.begin(), m.end()) == 9);
+ assert(*next(m.begin(), 0) == 1);
+ assert(*next(m.begin(), 1) == 1);
+ assert(*next(m.begin(), 2) == 1);
+ assert(*next(m.begin(), 3) == 2);
+ assert(*next(m.begin(), 4) == 2);
+ assert(*next(m.begin(), 5) == 2);
+ assert(*next(m.begin(), 6) == 3);
+ assert(*next(m.begin(), 7) == 3);
+ assert(*next(m.begin(), 8) == 3);
+}
diff --git a/test/std/containers/associative/multiset/multiset.cons/move.pass.cpp b/test/std/containers/associative/multiset/multiset.cons/move.pass.cpp
new file mode 100644
index 000000000000..40321cd247e1
--- /dev/null
+++ b/test/std/containers/associative/multiset/multiset.cons/move.pass.cpp
@@ -0,0 +1,119 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// multiset(multiset&& s);
+
+#include <set>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef int V;
+ typedef test_compare<std::less<int> > C;
+ typedef test_allocator<V> A;
+ std::multiset<int, C, A> mo(C(5), A(7));
+ std::multiset<int, C, A> m = std::move(mo);
+ assert(m.get_allocator() == A(7));
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 0);
+ assert(distance(m.begin(), m.end()) == 0);
+
+ assert(mo.get_allocator() == A(7));
+ assert(mo.key_comp() == C(5));
+ assert(mo.size() == 0);
+ assert(distance(mo.begin(), mo.end()) == 0);
+ }
+ {
+ typedef int V;
+ V ar[] =
+ {
+ 1,
+ 1,
+ 1,
+ 2,
+ 2,
+ 2,
+ 3,
+ 3,
+ 3
+ };
+ typedef test_compare<std::less<int> > C;
+ typedef test_allocator<V> A;
+ std::multiset<int, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
+ std::multiset<int, C, A> m = std::move(mo);
+ assert(m.get_allocator() == A(7));
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 9);
+ assert(distance(m.begin(), m.end()) == 9);
+ assert(*next(m.begin(), 0) == 1);
+ assert(*next(m.begin(), 1) == 1);
+ assert(*next(m.begin(), 2) == 1);
+ assert(*next(m.begin(), 3) == 2);
+ assert(*next(m.begin(), 4) == 2);
+ assert(*next(m.begin(), 5) == 2);
+ assert(*next(m.begin(), 6) == 3);
+ assert(*next(m.begin(), 7) == 3);
+ assert(*next(m.begin(), 8) == 3);
+
+ assert(mo.get_allocator() == A(7));
+ assert(mo.key_comp() == C(5));
+ assert(mo.size() == 0);
+ assert(distance(mo.begin(), mo.end()) == 0);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if __cplusplus >= 201103L
+ {
+ typedef int V;
+ V ar[] =
+ {
+ 1,
+ 1,
+ 1,
+ 2,
+ 2,
+ 2,
+ 3,
+ 3,
+ 3
+ };
+ typedef test_compare<std::less<int> > C;
+ typedef min_allocator<V> A;
+ std::multiset<int, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A());
+ std::multiset<int, C, A> m = std::move(mo);
+ assert(m.get_allocator() == A());
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 9);
+ assert(distance(m.begin(), m.end()) == 9);
+ assert(*next(m.begin(), 0) == 1);
+ assert(*next(m.begin(), 1) == 1);
+ assert(*next(m.begin(), 2) == 1);
+ assert(*next(m.begin(), 3) == 2);
+ assert(*next(m.begin(), 4) == 2);
+ assert(*next(m.begin(), 5) == 2);
+ assert(*next(m.begin(), 6) == 3);
+ assert(*next(m.begin(), 7) == 3);
+ assert(*next(m.begin(), 8) == 3);
+
+ assert(mo.get_allocator() == A());
+ assert(mo.key_comp() == C(5));
+ assert(mo.size() == 0);
+ assert(distance(mo.begin(), mo.end()) == 0);
+ }
+#endif
+}
diff --git a/test/std/containers/associative/multiset/multiset.cons/move_alloc.pass.cpp b/test/std/containers/associative/multiset/multiset.cons/move_alloc.pass.cpp
new file mode 100644
index 000000000000..4408208f2ac4
--- /dev/null
+++ b/test/std/containers/associative/multiset/multiset.cons/move_alloc.pass.cpp
@@ -0,0 +1,187 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// multiset(multiset&& s, const allocator_type& a);
+
+#include <set>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+#include "Counter.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef MoveOnly V;
+ typedef test_compare<std::less<MoveOnly> > C;
+ typedef test_allocator<V> A;
+ typedef std::multiset<MoveOnly, C, A> M;
+ typedef std::move_iterator<V*> I;
+ V a1[] =
+ {
+ V(1),
+ V(1),
+ V(1),
+ V(2),
+ V(2),
+ V(2),
+ V(3),
+ V(3),
+ V(3)
+ };
+ M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+ V a2[] =
+ {
+ V(1),
+ V(1),
+ V(1),
+ V(2),
+ V(2),
+ V(2),
+ V(3),
+ V(3),
+ V(3)
+ };
+ M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+ M m3(std::move(m1), A(7));
+ assert(m3 == m2);
+ assert(m3.get_allocator() == A(7));
+ assert(m3.key_comp() == C(5));
+ assert(m1.empty());
+ }
+ {
+ typedef MoveOnly V;
+ typedef test_compare<std::less<MoveOnly> > C;
+ typedef test_allocator<V> A;
+ typedef std::multiset<MoveOnly, C, A> M;
+ typedef std::move_iterator<V*> I;
+ V a1[] =
+ {
+ V(1),
+ V(1),
+ V(1),
+ V(2),
+ V(2),
+ V(2),
+ V(3),
+ V(3),
+ V(3)
+ };
+ M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+ V a2[] =
+ {
+ V(1),
+ V(1),
+ V(1),
+ V(2),
+ V(2),
+ V(2),
+ V(3),
+ V(3),
+ V(3)
+ };
+ M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+ M m3(std::move(m1), A(5));
+ assert(m3 == m2);
+ assert(m3.get_allocator() == A(5));
+ assert(m3.key_comp() == C(5));
+ assert(m1.empty());
+ }
+ {
+ typedef MoveOnly V;
+ typedef test_compare<std::less<MoveOnly> > C;
+ typedef other_allocator<V> A;
+ typedef std::multiset<MoveOnly, C, A> M;
+ typedef std::move_iterator<V*> I;
+ V a1[] =
+ {
+ V(1),
+ V(1),
+ V(1),
+ V(2),
+ V(2),
+ V(2),
+ V(3),
+ V(3),
+ V(3)
+ };
+ M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+ V a2[] =
+ {
+ V(1),
+ V(1),
+ V(1),
+ V(2),
+ V(2),
+ V(2),
+ V(3),
+ V(3),
+ V(3)
+ };
+ M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+ M m3(std::move(m1), A(5));
+ assert(m3 == m2);
+ assert(m3.get_allocator() == A(5));
+ assert(m3.key_comp() == C(5));
+ assert(m1.empty());
+ }
+ {
+ typedef Counter<int> V;
+ typedef std::less<V> C;
+ typedef test_allocator<V> A;
+ typedef std::multiset<V, C, A> M;
+ typedef V* I;
+ Counter_base::gConstructed = 0;
+ {
+ V a1[] =
+ {
+ V(1),
+ V(1),
+ V(1),
+ V(2),
+ V(2),
+ V(2),
+ V(3),
+ V(3),
+ V(3)
+ };
+ const size_t num = sizeof(a1)/sizeof(a1[0]);
+ assert(Counter_base::gConstructed == num);
+
+ M m1(I(a1), I(a1+num), C(), A());
+ assert(Counter_base::gConstructed == 2*num);
+
+ M m2(m1);
+ assert(m2 == m1);
+ assert(Counter_base::gConstructed == 3*num);
+
+ M m3(std::move(m1), A());
+ assert(m3 == m2);
+ assert(m1.empty());
+ assert(Counter_base::gConstructed == 3*num);
+
+ {
+ M m4(std::move(m2), A(5));
+ assert(Counter_base::gConstructed == 3*num);
+ assert(m4 == m3);
+ assert(m2.empty());
+ }
+ assert(Counter_base::gConstructed == 2*num);
+ }
+ assert(Counter_base::gConstructed == 0);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/associative/multiset/multiset.cons/move_assign.pass.cpp b/test/std/containers/associative/multiset/multiset.cons/move_assign.pass.cpp
new file mode 100644
index 000000000000..ca1ba971f5a4
--- /dev/null
+++ b/test/std/containers/associative/multiset/multiset.cons/move_assign.pass.cpp
@@ -0,0 +1,186 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// multiset& operator=(multiset&& s);
+
+#include <set>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef MoveOnly V;
+ typedef test_compare<std::less<MoveOnly> > C;
+ typedef test_allocator<V> A;
+ typedef std::multiset<MoveOnly, C, A> M;
+ typedef std::move_iterator<V*> I;
+ V a1[] =
+ {
+ V(1),
+ V(1),
+ V(1),
+ V(2),
+ V(2),
+ V(2),
+ V(3),
+ V(3),
+ V(3)
+ };
+ M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+ V a2[] =
+ {
+ V(1),
+ V(1),
+ V(1),
+ V(2),
+ V(2),
+ V(2),
+ V(3),
+ V(3),
+ V(3)
+ };
+ M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+ M m3(C(3), A(7));
+ m3 = std::move(m1);
+ assert(m3 == m2);
+ assert(m3.get_allocator() == A(7));
+ assert(m3.key_comp() == C(5));
+ assert(m1.empty());
+ }
+ {
+ typedef MoveOnly V;
+ typedef test_compare<std::less<MoveOnly> > C;
+ typedef test_allocator<V> A;
+ typedef std::multiset<MoveOnly, C, A> M;
+ typedef std::move_iterator<V*> I;
+ V a1[] =
+ {
+ V(1),
+ V(1),
+ V(1),
+ V(2),
+ V(2),
+ V(2),
+ V(3),
+ V(3),
+ V(3)
+ };
+ M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+ V a2[] =
+ {
+ V(1),
+ V(1),
+ V(1),
+ V(2),
+ V(2),
+ V(2),
+ V(3),
+ V(3),
+ V(3)
+ };
+ M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+ M m3(C(3), A(5));
+ m3 = std::move(m1);
+ assert(m3 == m2);
+ assert(m3.get_allocator() == A(5));
+ assert(m3.key_comp() == C(5));
+ assert(m1.empty());
+ }
+ {
+ typedef MoveOnly V;
+ typedef test_compare<std::less<MoveOnly> > C;
+ typedef other_allocator<V> A;
+ typedef std::multiset<MoveOnly, C, A> M;
+ typedef std::move_iterator<V*> I;
+ V a1[] =
+ {
+ V(1),
+ V(1),
+ V(1),
+ V(2),
+ V(2),
+ V(2),
+ V(3),
+ V(3),
+ V(3)
+ };
+ M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+ V a2[] =
+ {
+ V(1),
+ V(1),
+ V(1),
+ V(2),
+ V(2),
+ V(2),
+ V(3),
+ V(3),
+ V(3)
+ };
+ M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+ M m3(C(3), A(5));
+ m3 = std::move(m1);
+ assert(m3 == m2);
+ assert(m3.get_allocator() == A(7));
+ assert(m3.key_comp() == C(5));
+ assert(m1.empty());
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if __cplusplus >= 201103L
+ {
+ typedef MoveOnly V;
+ typedef test_compare<std::less<MoveOnly> > C;
+ typedef min_allocator<V> A;
+ typedef std::multiset<MoveOnly, C, A> M;
+ typedef std::move_iterator<V*> I;
+ V a1[] =
+ {
+ V(1),
+ V(1),
+ V(1),
+ V(2),
+ V(2),
+ V(2),
+ V(3),
+ V(3),
+ V(3)
+ };
+ M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A());
+ V a2[] =
+ {
+ V(1),
+ V(1),
+ V(1),
+ V(2),
+ V(2),
+ V(2),
+ V(3),
+ V(3),
+ V(3)
+ };
+ M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A());
+ M m3(C(3), A());
+ m3 = std::move(m1);
+ assert(m3 == m2);
+ assert(m3.get_allocator() == A());
+ assert(m3.key_comp() == C(5));
+ assert(m1.empty());
+ }
+#endif
+}
diff --git a/test/std/containers/associative/multiset/multiset.cons/move_assign_noexcept.pass.cpp b/test/std/containers/associative/multiset/multiset.cons/move_assign_noexcept.pass.cpp
new file mode 100644
index 000000000000..211bb36e7e95
--- /dev/null
+++ b/test/std/containers/associative/multiset/multiset.cons/move_assign_noexcept.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// multiset& operator=(multiset&& c)
+// noexcept(
+// allocator_type::propagate_on_container_move_assignment::value &&
+// is_nothrow_move_assignable<allocator_type>::value &&
+// is_nothrow_move_assignable<key_compare>::value);
+
+// This tests a conforming extension
+
+#include <set>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_comp
+{
+ typedef T value_type;
+ some_comp& operator=(const some_comp&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::multiset<MoveOnly> C;
+ static_assert(std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::multiset<MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::multiset<MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::multiset<MoveOnly, some_comp<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+ }
+#endif
+}
diff --git a/test/std/containers/associative/multiset/multiset.cons/move_noexcept.pass.cpp b/test/std/containers/associative/multiset/multiset.cons/move_noexcept.pass.cpp
new file mode 100644
index 000000000000..31a34cbde306
--- /dev/null
+++ b/test/std/containers/associative/multiset/multiset.cons/move_noexcept.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// multiset(multiset&&)
+// noexcept(is_nothrow_move_constructible<allocator_type>::value &&
+// is_nothrow_move_constructible<key_compare>::value);
+
+// This tests a conforming extension
+
+#include <set>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_comp
+{
+ typedef T value_type;
+ some_comp(const some_comp&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::multiset<MoveOnly> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::multiset<MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::multiset<MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::multiset<MoveOnly, some_comp<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_constructible<C>::value, "");
+ }
+#endif
+}
diff --git a/test/std/containers/associative/multiset/multiset.special/member_swap.pass.cpp b/test/std/containers/associative/multiset/multiset.special/member_swap.pass.cpp
new file mode 100644
index 000000000000..7745ddab78c3
--- /dev/null
+++ b/test/std/containers/associative/multiset/multiset.special/member_swap.pass.cpp
@@ -0,0 +1,177 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// void swap(multiset& m);
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int V;
+ typedef std::multiset<int> M;
+ {
+ M m1;
+ M m2;
+ M m1_save = m1;
+ M m2_save = m2;
+ m1.swap(m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar2[] =
+ {
+ 5,
+ 6,
+ 7,
+ 8,
+ 9,
+ 10,
+ 11,
+ 12
+ };
+ M m1;
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ m1.swap(m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar1[] =
+ {
+ 1,
+ 2,
+ 3,
+ 4
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2;
+ M m1_save = m1;
+ M m2_save = m2;
+ m1.swap(m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar1[] =
+ {
+ 1,
+ 2,
+ 3,
+ 4
+ };
+ V ar2[] =
+ {
+ 5,
+ 6,
+ 7,
+ 8,
+ 9,
+ 10,
+ 11,
+ 12
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ m1.swap(m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int V;
+ typedef std::multiset<int, std::less<int>, min_allocator<int>> M;
+ {
+ M m1;
+ M m2;
+ M m1_save = m1;
+ M m2_save = m2;
+ m1.swap(m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar2[] =
+ {
+ 5,
+ 6,
+ 7,
+ 8,
+ 9,
+ 10,
+ 11,
+ 12
+ };
+ M m1;
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ m1.swap(m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar1[] =
+ {
+ 1,
+ 2,
+ 3,
+ 4
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2;
+ M m1_save = m1;
+ M m2_save = m2;
+ m1.swap(m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar1[] =
+ {
+ 1,
+ 2,
+ 3,
+ 4
+ };
+ V ar2[] =
+ {
+ 5,
+ 6,
+ 7,
+ 8,
+ 9,
+ 10,
+ 11,
+ 12
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ m1.swap(m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ }
+#endif
+}
diff --git a/test/std/containers/associative/multiset/multiset.special/non_member_swap.pass.cpp b/test/std/containers/associative/multiset/multiset.special/non_member_swap.pass.cpp
new file mode 100644
index 000000000000..f456de7f6243
--- /dev/null
+++ b/test/std/containers/associative/multiset/multiset.special/non_member_swap.pass.cpp
@@ -0,0 +1,165 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// void swap(multiset& m);
+
+#include <set>
+#include <cassert>
+#include "test_allocator.h"
+#include "../../../test_compare.h"
+
+int main()
+{
+ typedef int V;
+ typedef std::multiset<int> M;
+ {
+ M m1;
+ M m2;
+ M m1_save = m1;
+ M m2_save = m2;
+ swap(m1, m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar2[] =
+ {
+ 5,
+ 6,
+ 7,
+ 8,
+ 9,
+ 10,
+ 11,
+ 12
+ };
+ M m1;
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ swap(m1, m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar1[] =
+ {
+ 1,
+ 2,
+ 3,
+ 4
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2;
+ M m1_save = m1;
+ M m2_save = m2;
+ swap(m1, m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar1[] =
+ {
+ 1,
+ 2,
+ 3,
+ 4
+ };
+ V ar2[] =
+ {
+ 5,
+ 6,
+ 7,
+ 8,
+ 9,
+ 10,
+ 11,
+ 12
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ swap(m1, m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ typedef test_allocator<V> A;
+ typedef test_compare<std::less<int> > C;
+ typedef std::set<int, C, A> M;
+ V ar1[] =
+ {
+ 1,
+ 2,
+ 3,
+ 4
+ };
+ V ar2[] =
+ {
+ 5,
+ 6,
+ 7,
+ 8,
+ 9,
+ 10,
+ 11,
+ 12
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]), C(1), A(1));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]), C(2), A(2));
+ M m1_save = m1;
+ M m2_save = m2;
+ swap(m1, m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ assert(m1.key_comp() == C(2));
+ assert(m1.get_allocator() == A(1));
+ assert(m2.key_comp() == C(1));
+ assert(m2.get_allocator() == A(2));
+ }
+ {
+ typedef other_allocator<V> A;
+ typedef test_compare<std::less<int> > C;
+ typedef std::set<int, C, A> M;
+ V ar1[] =
+ {
+ 1,
+ 2,
+ 3,
+ 4
+ };
+ V ar2[] =
+ {
+ 5,
+ 6,
+ 7,
+ 8,
+ 9,
+ 10,
+ 11,
+ 12
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]), C(1), A(1));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]), C(2), A(2));
+ M m1_save = m1;
+ M m2_save = m2;
+ swap(m1, m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ assert(m1.key_comp() == C(2));
+ assert(m1.get_allocator() == A(2));
+ assert(m2.key_comp() == C(1));
+ assert(m2.get_allocator() == A(1));
+ }
+}
diff --git a/test/std/containers/associative/multiset/multiset.special/swap_noexcept.pass.cpp b/test/std/containers/associative/multiset/multiset.special/swap_noexcept.pass.cpp
new file mode 100644
index 000000000000..8e2c67c9b5ec
--- /dev/null
+++ b/test/std/containers/associative/multiset/multiset.special/swap_noexcept.pass.cpp
@@ -0,0 +1,148 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// void swap(multiset& c)
+// noexcept(!allocator_type::propagate_on_container_swap::value ||
+// __is_nothrow_swappable<allocator_type>::value);
+//
+// In C++17, the standard says that swap shall have:
+// noexcept(allocator_traits<Allocator>::is_always_equal::value &&
+// noexcept(swap(declval<Compare&>(), declval<Compare&>())));
+
+// This tests a conforming extension
+
+#include <set>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_comp
+{
+ typedef T value_type;
+
+ some_comp() {}
+ some_comp(const some_comp&) {}
+ void deallocate(void*, unsigned) {}
+
+ typedef std::true_type propagate_on_container_swap;
+};
+
+template <class T>
+struct some_comp2
+{
+ typedef T value_type;
+
+ some_comp2() {}
+ some_comp2(const some_comp2&) {}
+ void deallocate(void*, unsigned) {}
+ typedef std::true_type propagate_on_container_swap;
+};
+
+#if TEST_STD_VER >= 14
+template <typename T>
+void swap(some_comp2<T>&, some_comp2<T>&) noexcept {}
+#endif
+
+template <class T>
+struct some_alloc
+{
+ typedef T value_type;
+
+ some_alloc() {}
+ some_alloc(const some_alloc&);
+ void deallocate(void*, unsigned) {}
+
+ typedef std::true_type propagate_on_container_swap;
+};
+
+template <class T>
+struct some_alloc2
+{
+ typedef T value_type;
+
+ some_alloc2() {}
+ some_alloc2(const some_alloc2&);
+ void deallocate(void*, unsigned) {}
+
+ typedef std::false_type propagate_on_container_swap;
+ typedef std::true_type is_always_equal;
+};
+
+template <class T>
+struct some_alloc3
+{
+ typedef T value_type;
+
+ some_alloc3() {}
+ some_alloc3(const some_alloc3&);
+ void deallocate(void*, unsigned) {}
+
+ typedef std::false_type propagate_on_container_swap;
+ typedef std::false_type is_always_equal;
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::multiset<MoveOnly> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::multiset<MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::multiset<MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::multiset<MoveOnly, some_comp<MoveOnly>> C;
+ C c1, c2;
+ static_assert(!noexcept(swap(c1, c2)), "");
+ }
+
+#if TEST_STD_VER >= 14
+ { // POCS allocator, throwable swap for comp
+ typedef std::multiset<MoveOnly, some_comp <MoveOnly>, some_alloc <MoveOnly>> C;
+ C c1, c2;
+ static_assert(!noexcept(swap(c1, c2)), "");
+ }
+ { // always equal allocator, throwable swap for comp
+ typedef std::multiset<MoveOnly, some_comp <MoveOnly>, some_alloc2<MoveOnly>> C;
+ C c1, c2;
+ static_assert(!noexcept(swap(c1, c2)), "");
+ }
+ { // POCS allocator, nothrow swap for comp
+ typedef std::multiset<MoveOnly, some_comp2<MoveOnly>, some_alloc <MoveOnly>> C;
+ C c1, c2;
+ static_assert( noexcept(swap(c1, c2)), "");
+ }
+ { // always equal allocator, nothrow swap for comp
+ typedef std::multiset<MoveOnly, some_comp2<MoveOnly>, some_alloc2<MoveOnly>> C;
+ C c1, c2;
+ static_assert( noexcept(swap(c1, c2)), "");
+ }
+
+ { // NOT always equal allocator, nothrow swap for comp
+ typedef std::multiset<MoveOnly, some_comp2<MoveOnly>, some_alloc3<MoveOnly>> C;
+ C c1, c2;
+ static_assert( noexcept(swap(c1, c2)), "");
+ }
+#endif
+
+#endif
+}
diff --git a/test/std/containers/associative/multiset/scary.pass.cpp b/test/std/containers/associative/multiset/scary.pass.cpp
new file mode 100644
index 000000000000..f5ee32714e86
--- /dev/null
+++ b/test/std/containers/associative/multiset/scary.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set class multiset
+
+// Extension: SCARY/N2913 iterator compatibility between set and multiset
+
+#include <set>
+
+int main()
+{
+ typedef std::set<int> M1;
+ typedef std::multiset<int> M2;
+ M2::iterator i;
+ M1::iterator j = i;
+}
diff --git a/test/std/containers/associative/multiset/size.pass.cpp b/test/std/containers/associative/multiset/size.pass.cpp
new file mode 100644
index 000000000000..68099b566dfd
--- /dev/null
+++ b/test/std/containers/associative/multiset/size.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// size_type size() const;
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::multiset<int> M;
+ M m;
+ assert(m.size() == 0);
+ m.insert(M::value_type(2));
+ assert(m.size() == 1);
+ m.insert(M::value_type(1));
+ assert(m.size() == 2);
+ m.insert(M::value_type(2));
+ assert(m.size() == 3);
+ m.erase(m.begin());
+ assert(m.size() == 2);
+ m.erase(m.begin());
+ assert(m.size() == 1);
+ m.erase(m.begin());
+ assert(m.size() == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::multiset<int, std::less<int>, min_allocator<int>> M;
+ M m;
+ assert(m.size() == 0);
+ m.insert(M::value_type(2));
+ assert(m.size() == 1);
+ m.insert(M::value_type(1));
+ assert(m.size() == 2);
+ m.insert(M::value_type(2));
+ assert(m.size() == 3);
+ m.erase(m.begin());
+ assert(m.size() == 2);
+ m.erase(m.begin());
+ assert(m.size() == 1);
+ m.erase(m.begin());
+ assert(m.size() == 0);
+ }
+#endif
+}
diff --git a/test/std/containers/associative/multiset/types.pass.cpp b/test/std/containers/associative/multiset/types.pass.cpp
new file mode 100644
index 000000000000..e1e3ad9100c3
--- /dev/null
+++ b/test/std/containers/associative/multiset/types.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// template <class Key, class Compare = less<Key>,
+// class Allocator = allocator<Key>>
+// class multiset
+// {
+// public:
+// // types:
+// typedef Key key_type;
+// typedef key_type value_type;
+// typedef Compare key_compare;
+// typedef key_compare value_compare;
+// typedef Allocator allocator_type;
+// typedef typename allocator_type::reference reference;
+// typedef typename allocator_type::const_reference const_reference;
+// typedef typename allocator_type::pointer pointer;
+// typedef typename allocator_type::const_pointer const_pointer;
+// typedef typename allocator_type::size_type size_type;
+// typedef typename allocator_type::difference_type difference_type;
+// ...
+// };
+
+#include <set>
+#include <type_traits>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::multiset<int> C;
+ static_assert((std::is_same<C::key_type, int>::value), "");
+ static_assert((std::is_same<C::value_type, int>::value), "");
+ static_assert((std::is_same<C::key_compare, std::less<int> >::value), "");
+ static_assert((std::is_same<C::value_compare, std::less<int> >::value), "");
+ static_assert((std::is_same<C::allocator_type, std::allocator<int> >::value), "");
+ static_assert((std::is_same<C::reference, int&>::value), "");
+ static_assert((std::is_same<C::const_reference, const int&>::value), "");
+ static_assert((std::is_same<C::pointer, int*>::value), "");
+ static_assert((std::is_same<C::const_pointer, const int*>::value), "");
+ static_assert((std::is_same<C::size_type, std::size_t>::value), "");
+ static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::multiset<int, std::less<int>, min_allocator<int>> C;
+ static_assert((std::is_same<C::key_type, int>::value), "");
+ static_assert((std::is_same<C::value_type, int>::value), "");
+ static_assert((std::is_same<C::key_compare, std::less<int> >::value), "");
+ static_assert((std::is_same<C::value_compare, std::less<int> >::value), "");
+ static_assert((std::is_same<C::allocator_type, min_allocator<int>>::value), "");
+ static_assert((std::is_same<C::reference, int&>::value), "");
+ static_assert((std::is_same<C::const_reference, const int&>::value), "");
+ static_assert((std::is_same<C::pointer, min_pointer<int>>::value), "");
+ static_assert((std::is_same<C::const_pointer, min_pointer<const int>>::value), "");
+// min_allocator doesn't have a size_type, so one gets synthesized
+ static_assert((std::is_same<C::size_type, std::make_unsigned<C::difference_type>::type>::value), "");
+ static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
+ }
+#endif
+}
diff --git a/test/std/containers/associative/multiset/upper_bound.pass.cpp b/test/std/containers/associative/multiset/upper_bound.pass.cpp
new file mode 100644
index 000000000000..7ad3d6ced3d6
--- /dev/null
+++ b/test/std/containers/associative/multiset/upper_bound.pass.cpp
@@ -0,0 +1,222 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// iterator upper_bound(const key_type& k);
+// const_iterator upper_bound(const key_type& k) const;
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "private_constructor.hpp"
+
+int main()
+{
+ {
+ typedef int V;
+ typedef std::multiset<int> M;
+ {
+ typedef M::iterator R;
+ V ar[] =
+ {
+ 5,
+ 5,
+ 5,
+ 7,
+ 7,
+ 7,
+ 9,
+ 9,
+ 9
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.upper_bound(4);
+ assert(r == next(m.begin(), 0));
+ r = m.upper_bound(5);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(6);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(7);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(8);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(9);
+ assert(r == next(m.begin(), 9));
+ r = m.upper_bound(11);
+ assert(r == next(m.begin(), 9));
+ }
+ {
+ typedef M::const_iterator R;
+ V ar[] =
+ {
+ 5,
+ 5,
+ 5,
+ 7,
+ 7,
+ 7,
+ 9,
+ 9,
+ 9
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.upper_bound(4);
+ assert(r == next(m.begin(), 0));
+ r = m.upper_bound(5);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(6);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(7);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(8);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(9);
+ assert(r == next(m.begin(), 9));
+ r = m.upper_bound(11);
+ assert(r == next(m.begin(), 9));
+ }
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int V;
+ typedef std::multiset<int, std::less<int>, min_allocator<int>> M;
+ {
+ typedef M::iterator R;
+ V ar[] =
+ {
+ 5,
+ 5,
+ 5,
+ 7,
+ 7,
+ 7,
+ 9,
+ 9,
+ 9
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.upper_bound(4);
+ assert(r == next(m.begin(), 0));
+ r = m.upper_bound(5);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(6);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(7);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(8);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(9);
+ assert(r == next(m.begin(), 9));
+ r = m.upper_bound(11);
+ assert(r == next(m.begin(), 9));
+ }
+ {
+ typedef M::const_iterator R;
+ V ar[] =
+ {
+ 5,
+ 5,
+ 5,
+ 7,
+ 7,
+ 7,
+ 9,
+ 9,
+ 9
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.upper_bound(4);
+ assert(r == next(m.begin(), 0));
+ r = m.upper_bound(5);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(6);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(7);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(8);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(9);
+ assert(r == next(m.begin(), 9));
+ r = m.upper_bound(11);
+ assert(r == next(m.begin(), 9));
+ }
+ }
+#endif
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef int V;
+ typedef std::multiset<V, std::less<>> M;
+
+ typedef M::iterator R;
+ V ar[] =
+ {
+ 5,
+ 5,
+ 5,
+ 7,
+ 7,
+ 7,
+ 9,
+ 9,
+ 9
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.upper_bound(4);
+ assert(r == next(m.begin(), 0));
+ r = m.upper_bound(5);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(6);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(7);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(8);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(9);
+ assert(r == next(m.begin(), 9));
+ r = m.upper_bound(11);
+ assert(r == next(m.begin(), 9));
+ }
+
+ {
+ typedef PrivateConstructor V;
+ typedef std::multiset<V, std::less<>> M;
+
+ typedef M::iterator R;
+ M m;
+ m.insert ( V::make ( 5 ));
+ m.insert ( V::make ( 5 ));
+ m.insert ( V::make ( 5 ));
+ m.insert ( V::make ( 7 ));
+ m.insert ( V::make ( 7 ));
+ m.insert ( V::make ( 7 ));
+ m.insert ( V::make ( 9 ));
+ m.insert ( V::make ( 9 ));
+ m.insert ( V::make ( 9 ));
+
+ R r = m.upper_bound(4);
+ assert(r == next(m.begin(), 0));
+ r = m.upper_bound(5);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(6);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(7);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(8);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(9);
+ assert(r == next(m.begin(), 9));
+ r = m.upper_bound(11);
+ assert(r == next(m.begin(), 9));
+ }
+#endif
+}
diff --git a/test/std/containers/associative/set/clear.pass.cpp b/test/std/containers/associative/set/clear.pass.cpp
new file mode 100644
index 000000000000..4439ad3b1e4e
--- /dev/null
+++ b/test/std/containers/associative/set/clear.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// void clear();
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::set<int> M;
+ typedef int V;
+ V ar[] =
+ {
+ 1,
+ 2,
+ 3,
+ 4,
+ 5,
+ 6,
+ 7,
+ 8
+ };
+ M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 8);
+ m.clear();
+ assert(m.size() == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::set<int, std::less<int>, min_allocator<int>> M;
+ typedef int V;
+ V ar[] =
+ {
+ 1,
+ 2,
+ 3,
+ 4,
+ 5,
+ 6,
+ 7,
+ 8
+ };
+ M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 8);
+ m.clear();
+ assert(m.size() == 0);
+ }
+#endif
+}
diff --git a/test/std/containers/associative/set/count.pass.cpp b/test/std/containers/associative/set/count.pass.cpp
new file mode 100644
index 000000000000..32fe0b8bcee9
--- /dev/null
+++ b/test/std/containers/associative/set/count.pass.cpp
@@ -0,0 +1,168 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// size_type count(const key_type& k) const;
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "private_constructor.hpp"
+
+int main()
+{
+ {
+ typedef int V;
+ typedef std::set<int> M;
+ typedef M::size_type R;
+ V ar[] =
+ {
+ 5,
+ 6,
+ 7,
+ 8,
+ 9,
+ 10,
+ 11,
+ 12
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.count(5);
+ assert(r == 1);
+ r = m.count(6);
+ assert(r == 1);
+ r = m.count(7);
+ assert(r == 1);
+ r = m.count(8);
+ assert(r == 1);
+ r = m.count(9);
+ assert(r == 1);
+ r = m.count(10);
+ assert(r == 1);
+ r = m.count(11);
+ assert(r == 1);
+ r = m.count(12);
+ assert(r == 1);
+ r = m.count(4);
+ assert(r == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int V;
+ typedef std::set<int, std::less<int>, min_allocator<int>> M;
+ typedef M::size_type R;
+ V ar[] =
+ {
+ 5,
+ 6,
+ 7,
+ 8,
+ 9,
+ 10,
+ 11,
+ 12
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.count(5);
+ assert(r == 1);
+ r = m.count(6);
+ assert(r == 1);
+ r = m.count(7);
+ assert(r == 1);
+ r = m.count(8);
+ assert(r == 1);
+ r = m.count(9);
+ assert(r == 1);
+ r = m.count(10);
+ assert(r == 1);
+ r = m.count(11);
+ assert(r == 1);
+ r = m.count(12);
+ assert(r == 1);
+ r = m.count(4);
+ assert(r == 0);
+ }
+#endif
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef int V;
+ typedef std::set<int, std::less<>> M;
+ typedef M::size_type R;
+ V ar[] =
+ {
+ 5,
+ 6,
+ 7,
+ 8,
+ 9,
+ 10,
+ 11,
+ 12
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.count(5);
+ assert(r == 1);
+ r = m.count(6);
+ assert(r == 1);
+ r = m.count(7);
+ assert(r == 1);
+ r = m.count(8);
+ assert(r == 1);
+ r = m.count(9);
+ assert(r == 1);
+ r = m.count(10);
+ assert(r == 1);
+ r = m.count(11);
+ assert(r == 1);
+ r = m.count(12);
+ assert(r == 1);
+ r = m.count(4);
+ assert(r == 0);
+ }
+ {
+ typedef PrivateConstructor V;
+ typedef std::set<V, std::less<>> M;
+ typedef M::size_type R;
+
+ M m;
+ m.insert ( V::make ( 5 ));
+ m.insert ( V::make ( 6 ));
+ m.insert ( V::make ( 7 ));
+ m.insert ( V::make ( 8 ));
+ m.insert ( V::make ( 9 ));
+ m.insert ( V::make ( 10 ));
+ m.insert ( V::make ( 11 ));
+ m.insert ( V::make ( 12 ));
+
+ R r = m.count(5);
+ assert(r == 1);
+ r = m.count(6);
+ assert(r == 1);
+ r = m.count(7);
+ assert(r == 1);
+ r = m.count(8);
+ assert(r == 1);
+ r = m.count(9);
+ assert(r == 1);
+ r = m.count(10);
+ assert(r == 1);
+ r = m.count(11);
+ assert(r == 1);
+ r = m.count(12);
+ assert(r == 1);
+ r = m.count(4);
+ assert(r == 0);
+ }
+#endif
+
+}
diff --git a/test/std/containers/associative/set/emplace.pass.cpp b/test/std/containers/associative/set/emplace.pass.cpp
new file mode 100644
index 000000000000..5ebab4d24b92
--- /dev/null
+++ b/test/std/containers/associative/set/emplace.pass.cpp
@@ -0,0 +1,90 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// template <class... Args>
+// pair<iterator, bool> emplace(Args&&... args);
+
+#include <set>
+#include <cassert>
+
+#include "../../Emplaceable.h"
+#include "DefaultOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::set<DefaultOnly> M;
+ typedef std::pair<M::iterator, bool> R;
+ M m;
+ assert(DefaultOnly::count == 0);
+ R r = m.emplace();
+ assert(r.second);
+ assert(r.first == m.begin());
+ assert(m.size() == 1);
+ assert(*m.begin() == DefaultOnly());
+ assert(DefaultOnly::count == 1);
+
+ r = m.emplace();
+ assert(!r.second);
+ assert(r.first == m.begin());
+ assert(m.size() == 1);
+ assert(*m.begin() == DefaultOnly());
+ assert(DefaultOnly::count == 1);
+ }
+ assert(DefaultOnly::count == 0);
+ {
+ typedef std::set<Emplaceable> M;
+ typedef std::pair<M::iterator, bool> R;
+ M m;
+ R r = m.emplace();
+ assert(r.second);
+ assert(r.first == m.begin());
+ assert(m.size() == 1);
+ assert(*m.begin() == Emplaceable());
+ r = m.emplace(2, 3.5);
+ assert(r.second);
+ assert(r.first == next(m.begin()));
+ assert(m.size() == 2);
+ assert(*r.first == Emplaceable(2, 3.5));
+ r = m.emplace(2, 3.5);
+ assert(!r.second);
+ assert(r.first == next(m.begin()));
+ assert(m.size() == 2);
+ assert(*r.first == Emplaceable(2, 3.5));
+ }
+ {
+ typedef std::set<int> M;
+ typedef std::pair<M::iterator, bool> R;
+ M m;
+ R r = m.emplace(M::value_type(2));
+ assert(r.second);
+ assert(r.first == m.begin());
+ assert(m.size() == 1);
+ assert(*r.first == 2);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::set<int, std::less<int>, min_allocator<int>> M;
+ typedef std::pair<M::iterator, bool> R;
+ M m;
+ R r = m.emplace(M::value_type(2));
+ assert(r.second);
+ assert(r.first == m.begin());
+ assert(m.size() == 1);
+ assert(*r.first == 2);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/associative/set/emplace_hint.pass.cpp b/test/std/containers/associative/set/emplace_hint.pass.cpp
new file mode 100644
index 000000000000..5fdeb4ffef3a
--- /dev/null
+++ b/test/std/containers/associative/set/emplace_hint.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// template <class... Args>
+// iterator emplace_hint(const_iterator position, Args&&... args);
+
+#include <set>
+#include <cassert>
+
+#include "../../Emplaceable.h"
+#include "DefaultOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::set<DefaultOnly> M;
+ typedef M::iterator R;
+ M m;
+ assert(DefaultOnly::count == 0);
+ R r = m.emplace_hint(m.cend());
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(*m.begin() == DefaultOnly());
+ assert(DefaultOnly::count == 1);
+
+ r = m.emplace_hint(m.cbegin());
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(*m.begin() == DefaultOnly());
+ assert(DefaultOnly::count == 1);
+ }
+ assert(DefaultOnly::count == 0);
+ {
+ typedef std::set<Emplaceable> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.emplace_hint(m.cend());
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(*m.begin() == Emplaceable());
+ r = m.emplace_hint(m.cend(), 2, 3.5);
+ assert(r == next(m.begin()));
+ assert(m.size() == 2);
+ assert(*r == Emplaceable(2, 3.5));
+ r = m.emplace_hint(m.cbegin(), 2, 3.5);
+ assert(r == next(m.begin()));
+ assert(m.size() == 2);
+ assert(*r == Emplaceable(2, 3.5));
+ }
+ {
+ typedef std::set<int> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.emplace_hint(m.cend(), M::value_type(2));
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(*r == 2);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::set<int, std::less<int>, min_allocator<int>> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.emplace_hint(m.cend(), M::value_type(2));
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(*r == 2);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/associative/set/empty.pass.cpp b/test/std/containers/associative/set/empty.pass.cpp
new file mode 100644
index 000000000000..eb1080263f4f
--- /dev/null
+++ b/test/std/containers/associative/set/empty.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// bool empty() const;
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::set<int> M;
+ M m;
+ assert(m.empty());
+ m.insert(M::value_type(1));
+ assert(!m.empty());
+ m.clear();
+ assert(m.empty());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::set<int, std::less<int>, min_allocator<int>> M;
+ M m;
+ assert(m.empty());
+ m.insert(M::value_type(1));
+ assert(!m.empty());
+ m.clear();
+ assert(m.empty());
+ }
+#endif
+}
diff --git a/test/std/containers/associative/set/equal_range.pass.cpp b/test/std/containers/associative/set/equal_range.pass.cpp
new file mode 100644
index 000000000000..8a180ef49248
--- /dev/null
+++ b/test/std/containers/associative/set/equal_range.pass.cpp
@@ -0,0 +1,370 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// pair<iterator,iterator> equal_range(const key_type& k);
+// pair<const_iterator,const_iterator> equal_range(const key_type& k) const;
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "private_constructor.hpp"
+
+int main()
+{
+ {
+ typedef int V;
+ typedef std::set<int> M;
+ {
+ typedef std::pair<M::iterator, M::iterator> R;
+ V ar[] =
+ {
+ 5,
+ 7,
+ 9,
+ 11,
+ 13,
+ 15,
+ 17,
+ 19
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.equal_range(5);
+ assert(r.first == next(m.begin(), 0));
+ assert(r.second == next(m.begin(), 1));
+ r = m.equal_range(7);
+ assert(r.first == next(m.begin(), 1));
+ assert(r.second == next(m.begin(), 2));
+ r = m.equal_range(9);
+ assert(r.first == next(m.begin(), 2));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(11);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 4));
+ r = m.equal_range(13);
+ assert(r.first == next(m.begin(), 4));
+ assert(r.second == next(m.begin(), 5));
+ r = m.equal_range(15);
+ assert(r.first == next(m.begin(), 5));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(17);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 7));
+ r = m.equal_range(19);
+ assert(r.first == next(m.begin(), 7));
+ assert(r.second == next(m.begin(), 8));
+ r = m.equal_range(4);
+ assert(r.first == next(m.begin(), 0));
+ assert(r.second == next(m.begin(), 0));
+ r = m.equal_range(6);
+ assert(r.first == next(m.begin(), 1));
+ assert(r.second == next(m.begin(), 1));
+ r = m.equal_range(8);
+ assert(r.first == next(m.begin(), 2));
+ assert(r.second == next(m.begin(), 2));
+ r = m.equal_range(10);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(12);
+ assert(r.first == next(m.begin(), 4));
+ assert(r.second == next(m.begin(), 4));
+ r = m.equal_range(14);
+ assert(r.first == next(m.begin(), 5));
+ assert(r.second == next(m.begin(), 5));
+ r = m.equal_range(16);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(18);
+ assert(r.first == next(m.begin(), 7));
+ assert(r.second == next(m.begin(), 7));
+ r = m.equal_range(20);
+ assert(r.first == next(m.begin(), 8));
+ assert(r.second == next(m.begin(), 8));
+ }
+ {
+ typedef std::pair<M::const_iterator, M::const_iterator> R;
+ V ar[] =
+ {
+ 5,
+ 7,
+ 9,
+ 11,
+ 13,
+ 15,
+ 17,
+ 19
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.equal_range(5);
+ assert(r.first == next(m.begin(), 0));
+ assert(r.second == next(m.begin(), 1));
+ r = m.equal_range(7);
+ assert(r.first == next(m.begin(), 1));
+ assert(r.second == next(m.begin(), 2));
+ r = m.equal_range(9);
+ assert(r.first == next(m.begin(), 2));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(11);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 4));
+ r = m.equal_range(13);
+ assert(r.first == next(m.begin(), 4));
+ assert(r.second == next(m.begin(), 5));
+ r = m.equal_range(15);
+ assert(r.first == next(m.begin(), 5));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(17);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 7));
+ r = m.equal_range(19);
+ assert(r.first == next(m.begin(), 7));
+ assert(r.second == next(m.begin(), 8));
+ r = m.equal_range(4);
+ assert(r.first == next(m.begin(), 0));
+ assert(r.second == next(m.begin(), 0));
+ r = m.equal_range(6);
+ assert(r.first == next(m.begin(), 1));
+ assert(r.second == next(m.begin(), 1));
+ r = m.equal_range(8);
+ assert(r.first == next(m.begin(), 2));
+ assert(r.second == next(m.begin(), 2));
+ r = m.equal_range(10);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(12);
+ assert(r.first == next(m.begin(), 4));
+ assert(r.second == next(m.begin(), 4));
+ r = m.equal_range(14);
+ assert(r.first == next(m.begin(), 5));
+ assert(r.second == next(m.begin(), 5));
+ r = m.equal_range(16);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(18);
+ assert(r.first == next(m.begin(), 7));
+ assert(r.second == next(m.begin(), 7));
+ r = m.equal_range(20);
+ assert(r.first == next(m.begin(), 8));
+ assert(r.second == next(m.begin(), 8));
+ }
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int V;
+ typedef std::set<int, std::less<int>, min_allocator<int>> M;
+ typedef std::pair<M::iterator, M::iterator> R;
+ V ar[] =
+ {
+ 5,
+ 7,
+ 9,
+ 11,
+ 13,
+ 15,
+ 17,
+ 19
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.equal_range(5);
+ assert(r.first == next(m.begin(), 0));
+ assert(r.second == next(m.begin(), 1));
+ r = m.equal_range(7);
+ assert(r.first == next(m.begin(), 1));
+ assert(r.second == next(m.begin(), 2));
+ r = m.equal_range(9);
+ assert(r.first == next(m.begin(), 2));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(11);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 4));
+ r = m.equal_range(13);
+ assert(r.first == next(m.begin(), 4));
+ assert(r.second == next(m.begin(), 5));
+ r = m.equal_range(15);
+ assert(r.first == next(m.begin(), 5));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(17);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 7));
+ r = m.equal_range(19);
+ assert(r.first == next(m.begin(), 7));
+ assert(r.second == next(m.begin(), 8));
+ r = m.equal_range(4);
+ assert(r.first == next(m.begin(), 0));
+ assert(r.second == next(m.begin(), 0));
+ r = m.equal_range(6);
+ assert(r.first == next(m.begin(), 1));
+ assert(r.second == next(m.begin(), 1));
+ r = m.equal_range(8);
+ assert(r.first == next(m.begin(), 2));
+ assert(r.second == next(m.begin(), 2));
+ r = m.equal_range(10);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(12);
+ assert(r.first == next(m.begin(), 4));
+ assert(r.second == next(m.begin(), 4));
+ r = m.equal_range(14);
+ assert(r.first == next(m.begin(), 5));
+ assert(r.second == next(m.begin(), 5));
+ r = m.equal_range(16);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(18);
+ assert(r.first == next(m.begin(), 7));
+ assert(r.second == next(m.begin(), 7));
+ r = m.equal_range(20);
+ assert(r.first == next(m.begin(), 8));
+ assert(r.second == next(m.begin(), 8));
+ }
+#endif
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef int V;
+ typedef std::set<V, std::less<>> M;
+ {
+ typedef std::pair<M::iterator, M::iterator> R;
+ V ar[] =
+ {
+ 5,
+ 7,
+ 9,
+ 11,
+ 13,
+ 15,
+ 17,
+ 19
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.equal_range(5);
+ assert(r.first == next(m.begin(), 0));
+ assert(r.second == next(m.begin(), 1));
+ r = m.equal_range(7);
+ assert(r.first == next(m.begin(), 1));
+ assert(r.second == next(m.begin(), 2));
+ r = m.equal_range(9);
+ assert(r.first == next(m.begin(), 2));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(11);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 4));
+ r = m.equal_range(13);
+ assert(r.first == next(m.begin(), 4));
+ assert(r.second == next(m.begin(), 5));
+ r = m.equal_range(15);
+ assert(r.first == next(m.begin(), 5));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(17);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 7));
+ r = m.equal_range(19);
+ assert(r.first == next(m.begin(), 7));
+ assert(r.second == next(m.begin(), 8));
+ r = m.equal_range(4);
+ assert(r.first == next(m.begin(), 0));
+ assert(r.second == next(m.begin(), 0));
+ r = m.equal_range(6);
+ assert(r.first == next(m.begin(), 1));
+ assert(r.second == next(m.begin(), 1));
+ r = m.equal_range(8);
+ assert(r.first == next(m.begin(), 2));
+ assert(r.second == next(m.begin(), 2));
+ r = m.equal_range(10);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(12);
+ assert(r.first == next(m.begin(), 4));
+ assert(r.second == next(m.begin(), 4));
+ r = m.equal_range(14);
+ assert(r.first == next(m.begin(), 5));
+ assert(r.second == next(m.begin(), 5));
+ r = m.equal_range(16);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(18);
+ assert(r.first == next(m.begin(), 7));
+ assert(r.second == next(m.begin(), 7));
+ r = m.equal_range(20);
+ assert(r.first == next(m.begin(), 8));
+ assert(r.second == next(m.begin(), 8));
+ }
+ }
+ {
+ typedef PrivateConstructor V;
+ typedef std::set<V, std::less<>> M;
+ typedef std::pair<M::iterator, M::iterator> R;
+
+ M m;
+ m.insert ( V::make ( 5 ));
+ m.insert ( V::make ( 7 ));
+ m.insert ( V::make ( 9 ));
+ m.insert ( V::make ( 11 ));
+ m.insert ( V::make ( 13 ));
+ m.insert ( V::make ( 15 ));
+ m.insert ( V::make ( 17 ));
+ m.insert ( V::make ( 19 ));
+
+ R r = m.equal_range(5);
+ assert(r.first == next(m.begin(), 0));
+ assert(r.second == next(m.begin(), 1));
+ r = m.equal_range(7);
+ assert(r.first == next(m.begin(), 1));
+ assert(r.second == next(m.begin(), 2));
+ r = m.equal_range(9);
+ assert(r.first == next(m.begin(), 2));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(11);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 4));
+ r = m.equal_range(13);
+ assert(r.first == next(m.begin(), 4));
+ assert(r.second == next(m.begin(), 5));
+ r = m.equal_range(15);
+ assert(r.first == next(m.begin(), 5));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(17);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 7));
+ r = m.equal_range(19);
+ assert(r.first == next(m.begin(), 7));
+ assert(r.second == next(m.begin(), 8));
+ r = m.equal_range(4);
+ assert(r.first == next(m.begin(), 0));
+ assert(r.second == next(m.begin(), 0));
+ r = m.equal_range(6);
+ assert(r.first == next(m.begin(), 1));
+ assert(r.second == next(m.begin(), 1));
+ r = m.equal_range(8);
+ assert(r.first == next(m.begin(), 2));
+ assert(r.second == next(m.begin(), 2));
+ r = m.equal_range(10);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(12);
+ assert(r.first == next(m.begin(), 4));
+ assert(r.second == next(m.begin(), 4));
+ r = m.equal_range(14);
+ assert(r.first == next(m.begin(), 5));
+ assert(r.second == next(m.begin(), 5));
+ r = m.equal_range(16);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(18);
+ assert(r.first == next(m.begin(), 7));
+ assert(r.second == next(m.begin(), 7));
+ r = m.equal_range(20);
+ assert(r.first == next(m.begin(), 8));
+ assert(r.second == next(m.begin(), 8));
+ }
+#endif
+}
diff --git a/test/std/containers/associative/set/erase_iter.pass.cpp b/test/std/containers/associative/set/erase_iter.pass.cpp
new file mode 100644
index 000000000000..36828be86f28
--- /dev/null
+++ b/test/std/containers/associative/set/erase_iter.pass.cpp
@@ -0,0 +1,203 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// iterator erase(const_iterator position);
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+struct TemplateConstructor
+{
+ template<typename T>
+ TemplateConstructor (const T&) {}
+};
+
+bool operator<(const TemplateConstructor&, const TemplateConstructor&) { return false; }
+
+int main()
+{
+ {
+ typedef std::set<int> M;
+ typedef int V;
+ typedef M::iterator I;
+ V ar[] =
+ {
+ 1,
+ 2,
+ 3,
+ 4,
+ 5,
+ 6,
+ 7,
+ 8
+ };
+ M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 8);
+ I i = m.erase(next(m.cbegin(), 3));
+ assert(m.size() == 7);
+ assert(i == next(m.begin(), 3));
+ assert(*next(m.begin(), 0) == 1);
+ assert(*next(m.begin(), 1) == 2);
+ assert(*next(m.begin(), 2) == 3);
+ assert(*next(m.begin(), 3) == 5);
+ assert(*next(m.begin(), 4) == 6);
+ assert(*next(m.begin(), 5) == 7);
+ assert(*next(m.begin(), 6) == 8);
+
+ i = m.erase(next(m.cbegin(), 0));
+ assert(m.size() == 6);
+ assert(i == m.begin());
+ assert(*next(m.begin(), 0) == 2);
+ assert(*next(m.begin(), 1) == 3);
+ assert(*next(m.begin(), 2) == 5);
+ assert(*next(m.begin(), 3) == 6);
+ assert(*next(m.begin(), 4) == 7);
+ assert(*next(m.begin(), 5) == 8);
+
+ i = m.erase(next(m.cbegin(), 5));
+ assert(m.size() == 5);
+ assert(i == m.end());
+ assert(*next(m.begin(), 0) == 2);
+ assert(*next(m.begin(), 1) == 3);
+ assert(*next(m.begin(), 2) == 5);
+ assert(*next(m.begin(), 3) == 6);
+ assert(*next(m.begin(), 4) == 7);
+
+ i = m.erase(next(m.cbegin(), 1));
+ assert(m.size() == 4);
+ assert(i == next(m.begin()));
+ assert(*next(m.begin(), 0) == 2);
+ assert(*next(m.begin(), 1) == 5);
+ assert(*next(m.begin(), 2) == 6);
+ assert(*next(m.begin(), 3) == 7);
+
+ i = m.erase(next(m.cbegin(), 2));
+ assert(m.size() == 3);
+ assert(i == next(m.begin(), 2));
+ assert(*next(m.begin(), 0) == 2);
+ assert(*next(m.begin(), 1) == 5);
+ assert(*next(m.begin(), 2) == 7);
+
+ i = m.erase(next(m.cbegin(), 2));
+ assert(m.size() == 2);
+ assert(i == next(m.begin(), 2));
+ assert(*next(m.begin(), 0) == 2);
+ assert(*next(m.begin(), 1) == 5);
+
+ i = m.erase(next(m.cbegin(), 0));
+ assert(m.size() == 1);
+ assert(i == next(m.begin(), 0));
+ assert(*next(m.begin(), 0) == 5);
+
+ i = m.erase(m.cbegin());
+ assert(m.size() == 0);
+ assert(i == m.begin());
+ assert(i == m.end());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::set<int, std::less<int>, min_allocator<int>> M;
+ typedef int V;
+ typedef M::iterator I;
+ V ar[] =
+ {
+ 1,
+ 2,
+ 3,
+ 4,
+ 5,
+ 6,
+ 7,
+ 8
+ };
+ M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 8);
+ I i = m.erase(next(m.cbegin(), 3));
+ assert(m.size() == 7);
+ assert(i == next(m.begin(), 3));
+ assert(*next(m.begin(), 0) == 1);
+ assert(*next(m.begin(), 1) == 2);
+ assert(*next(m.begin(), 2) == 3);
+ assert(*next(m.begin(), 3) == 5);
+ assert(*next(m.begin(), 4) == 6);
+ assert(*next(m.begin(), 5) == 7);
+ assert(*next(m.begin(), 6) == 8);
+
+ i = m.erase(next(m.cbegin(), 0));
+ assert(m.size() == 6);
+ assert(i == m.begin());
+ assert(*next(m.begin(), 0) == 2);
+ assert(*next(m.begin(), 1) == 3);
+ assert(*next(m.begin(), 2) == 5);
+ assert(*next(m.begin(), 3) == 6);
+ assert(*next(m.begin(), 4) == 7);
+ assert(*next(m.begin(), 5) == 8);
+
+ i = m.erase(next(m.cbegin(), 5));
+ assert(m.size() == 5);
+ assert(i == m.end());
+ assert(*next(m.begin(), 0) == 2);
+ assert(*next(m.begin(), 1) == 3);
+ assert(*next(m.begin(), 2) == 5);
+ assert(*next(m.begin(), 3) == 6);
+ assert(*next(m.begin(), 4) == 7);
+
+ i = m.erase(next(m.cbegin(), 1));
+ assert(m.size() == 4);
+ assert(i == next(m.begin()));
+ assert(*next(m.begin(), 0) == 2);
+ assert(*next(m.begin(), 1) == 5);
+ assert(*next(m.begin(), 2) == 6);
+ assert(*next(m.begin(), 3) == 7);
+
+ i = m.erase(next(m.cbegin(), 2));
+ assert(m.size() == 3);
+ assert(i == next(m.begin(), 2));
+ assert(*next(m.begin(), 0) == 2);
+ assert(*next(m.begin(), 1) == 5);
+ assert(*next(m.begin(), 2) == 7);
+
+ i = m.erase(next(m.cbegin(), 2));
+ assert(m.size() == 2);
+ assert(i == next(m.begin(), 2));
+ assert(*next(m.begin(), 0) == 2);
+ assert(*next(m.begin(), 1) == 5);
+
+ i = m.erase(next(m.cbegin(), 0));
+ assert(m.size() == 1);
+ assert(i == next(m.begin(), 0));
+ assert(*next(m.begin(), 0) == 5);
+
+ i = m.erase(m.cbegin());
+ assert(m.size() == 0);
+ assert(i == m.begin());
+ assert(i == m.end());
+ }
+#endif
+#if __cplusplus >= 201402L
+ {
+ // This is LWG #2059
+ typedef TemplateConstructor T;
+ typedef std::set<T> C;
+ typedef C::iterator I;
+
+ C c;
+ T a{0};
+ I it = c.find(a);
+ if (it != c.end())
+ c.erase(it);
+ }
+#endif
+}
diff --git a/test/std/containers/associative/set/erase_iter_iter.pass.cpp b/test/std/containers/associative/set/erase_iter_iter.pass.cpp
new file mode 100644
index 000000000000..479950316655
--- /dev/null
+++ b/test/std/containers/associative/set/erase_iter_iter.pass.cpp
@@ -0,0 +1,141 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// iterator erase(const_iterator first, const_iterator last);
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::set<int> M;
+ typedef int V;
+ typedef M::iterator I;
+ V ar[] =
+ {
+ 1,
+ 2,
+ 3,
+ 4,
+ 5,
+ 6,
+ 7,
+ 8
+ };
+ M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 8);
+ I i = m.erase(next(m.cbegin(), 5), next(m.cbegin(), 5));
+ assert(m.size() == 8);
+ assert(i == next(m.begin(), 5));
+ assert(*next(m.begin(), 0) == 1);
+ assert(*next(m.begin(), 1) == 2);
+ assert(*next(m.begin(), 2) == 3);
+ assert(*next(m.begin(), 3) == 4);
+ assert(*next(m.begin(), 4) == 5);
+ assert(*next(m.begin(), 5) == 6);
+ assert(*next(m.begin(), 6) == 7);
+ assert(*next(m.begin(), 7) == 8);
+
+ i = m.erase(next(m.cbegin(), 3), next(m.cbegin(), 4));
+ assert(m.size() == 7);
+ assert(i == next(m.begin(), 3));
+ assert(*next(m.begin(), 0) == 1);
+ assert(*next(m.begin(), 1) == 2);
+ assert(*next(m.begin(), 2) == 3);
+ assert(*next(m.begin(), 3) == 5);
+ assert(*next(m.begin(), 4) == 6);
+ assert(*next(m.begin(), 5) == 7);
+ assert(*next(m.begin(), 6) == 8);
+
+ i = m.erase(next(m.cbegin(), 2), next(m.cbegin(), 5));
+ assert(m.size() == 4);
+ assert(i == next(m.begin(), 2));
+ assert(*next(m.begin(), 0) == 1);
+ assert(*next(m.begin(), 1) == 2);
+ assert(*next(m.begin(), 2) == 7);
+ assert(*next(m.begin(), 3) == 8);
+
+ i = m.erase(next(m.cbegin(), 0), next(m.cbegin(), 2));
+ assert(m.size() == 2);
+ assert(i == next(m.begin(), 0));
+ assert(*next(m.begin(), 0) == 7);
+ assert(*next(m.begin(), 1) == 8);
+
+ i = m.erase(m.cbegin(), m.cend());
+ assert(m.size() == 0);
+ assert(i == m.end());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::set<int, std::less<int>, min_allocator<int>> M;
+ typedef int V;
+ typedef M::iterator I;
+ V ar[] =
+ {
+ 1,
+ 2,
+ 3,
+ 4,
+ 5,
+ 6,
+ 7,
+ 8
+ };
+ M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 8);
+ I i = m.erase(next(m.cbegin(), 5), next(m.cbegin(), 5));
+ assert(m.size() == 8);
+ assert(i == next(m.begin(), 5));
+ assert(*next(m.begin(), 0) == 1);
+ assert(*next(m.begin(), 1) == 2);
+ assert(*next(m.begin(), 2) == 3);
+ assert(*next(m.begin(), 3) == 4);
+ assert(*next(m.begin(), 4) == 5);
+ assert(*next(m.begin(), 5) == 6);
+ assert(*next(m.begin(), 6) == 7);
+ assert(*next(m.begin(), 7) == 8);
+
+ i = m.erase(next(m.cbegin(), 3), next(m.cbegin(), 4));
+ assert(m.size() == 7);
+ assert(i == next(m.begin(), 3));
+ assert(*next(m.begin(), 0) == 1);
+ assert(*next(m.begin(), 1) == 2);
+ assert(*next(m.begin(), 2) == 3);
+ assert(*next(m.begin(), 3) == 5);
+ assert(*next(m.begin(), 4) == 6);
+ assert(*next(m.begin(), 5) == 7);
+ assert(*next(m.begin(), 6) == 8);
+
+ i = m.erase(next(m.cbegin(), 2), next(m.cbegin(), 5));
+ assert(m.size() == 4);
+ assert(i == next(m.begin(), 2));
+ assert(*next(m.begin(), 0) == 1);
+ assert(*next(m.begin(), 1) == 2);
+ assert(*next(m.begin(), 2) == 7);
+ assert(*next(m.begin(), 3) == 8);
+
+ i = m.erase(next(m.cbegin(), 0), next(m.cbegin(), 2));
+ assert(m.size() == 2);
+ assert(i == next(m.begin(), 0));
+ assert(*next(m.begin(), 0) == 7);
+ assert(*next(m.begin(), 1) == 8);
+
+ i = m.erase(m.cbegin(), m.cend());
+ assert(m.size() == 0);
+ assert(i == m.end());
+ }
+#endif
+}
diff --git a/test/std/containers/associative/set/erase_key.pass.cpp b/test/std/containers/associative/set/erase_key.pass.cpp
new file mode 100644
index 000000000000..9d92bd70d700
--- /dev/null
+++ b/test/std/containers/associative/set/erase_key.pass.cpp
@@ -0,0 +1,203 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// size_type erase(const key_type& k);
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::set<int> M;
+ typedef int V;
+ typedef M::size_type I;
+ V ar[] =
+ {
+ 1,
+ 2,
+ 3,
+ 4,
+ 5,
+ 6,
+ 7,
+ 8
+ };
+ M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 8);
+ I i = m.erase(9);
+ assert(m.size() == 8);
+ assert(i == 0);
+ assert(*next(m.begin(), 0) == 1);
+ assert(*next(m.begin(), 1) == 2);
+ assert(*next(m.begin(), 2) == 3);
+ assert(*next(m.begin(), 3) == 4);
+ assert(*next(m.begin(), 4) == 5);
+ assert(*next(m.begin(), 5) == 6);
+ assert(*next(m.begin(), 6) == 7);
+ assert(*next(m.begin(), 7) == 8);
+
+ i = m.erase(4);
+ assert(m.size() == 7);
+ assert(i == 1);
+ assert(*next(m.begin(), 0) == 1);
+ assert(*next(m.begin(), 1) == 2);
+ assert(*next(m.begin(), 2) == 3);
+ assert(*next(m.begin(), 3) == 5);
+ assert(*next(m.begin(), 4) == 6);
+ assert(*next(m.begin(), 5) == 7);
+ assert(*next(m.begin(), 6) == 8);
+
+ i = m.erase(1);
+ assert(m.size() == 6);
+ assert(i == 1);
+ assert(*next(m.begin(), 0) == 2);
+ assert(*next(m.begin(), 1) == 3);
+ assert(*next(m.begin(), 2) == 5);
+ assert(*next(m.begin(), 3) == 6);
+ assert(*next(m.begin(), 4) == 7);
+ assert(*next(m.begin(), 5) == 8);
+
+ i = m.erase(8);
+ assert(m.size() == 5);
+ assert(i == 1);
+ assert(*next(m.begin(), 0) == 2);
+ assert(*next(m.begin(), 1) == 3);
+ assert(*next(m.begin(), 2) == 5);
+ assert(*next(m.begin(), 3) == 6);
+ assert(*next(m.begin(), 4) == 7);
+
+ i = m.erase(3);
+ assert(m.size() == 4);
+ assert(i == 1);
+ assert(*next(m.begin(), 0) == 2);
+ assert(*next(m.begin(), 1) == 5);
+ assert(*next(m.begin(), 2) == 6);
+ assert(*next(m.begin(), 3) == 7);
+
+ i = m.erase(6);
+ assert(m.size() == 3);
+ assert(i == 1);
+ assert(*next(m.begin(), 0) == 2);
+ assert(*next(m.begin(), 1) == 5);
+ assert(*next(m.begin(), 2) == 7);
+
+ i = m.erase(7);
+ assert(m.size() == 2);
+ assert(i == 1);
+ assert(*next(m.begin(), 0) == 2);
+ assert(*next(m.begin(), 1) == 5);
+
+ i = m.erase(2);
+ assert(m.size() == 1);
+ assert(i == 1);
+ assert(*next(m.begin(), 0) == 5);
+
+ i = m.erase(5);
+ assert(m.size() == 0);
+ assert(i == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::set<int, std::less<int>, min_allocator<int>> M;
+ typedef int V;
+ typedef M::size_type I;
+ V ar[] =
+ {
+ 1,
+ 2,
+ 3,
+ 4,
+ 5,
+ 6,
+ 7,
+ 8
+ };
+ M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 8);
+ I i = m.erase(9);
+ assert(m.size() == 8);
+ assert(i == 0);
+ assert(*next(m.begin(), 0) == 1);
+ assert(*next(m.begin(), 1) == 2);
+ assert(*next(m.begin(), 2) == 3);
+ assert(*next(m.begin(), 3) == 4);
+ assert(*next(m.begin(), 4) == 5);
+ assert(*next(m.begin(), 5) == 6);
+ assert(*next(m.begin(), 6) == 7);
+ assert(*next(m.begin(), 7) == 8);
+
+ i = m.erase(4);
+ assert(m.size() == 7);
+ assert(i == 1);
+ assert(*next(m.begin(), 0) == 1);
+ assert(*next(m.begin(), 1) == 2);
+ assert(*next(m.begin(), 2) == 3);
+ assert(*next(m.begin(), 3) == 5);
+ assert(*next(m.begin(), 4) == 6);
+ assert(*next(m.begin(), 5) == 7);
+ assert(*next(m.begin(), 6) == 8);
+
+ i = m.erase(1);
+ assert(m.size() == 6);
+ assert(i == 1);
+ assert(*next(m.begin(), 0) == 2);
+ assert(*next(m.begin(), 1) == 3);
+ assert(*next(m.begin(), 2) == 5);
+ assert(*next(m.begin(), 3) == 6);
+ assert(*next(m.begin(), 4) == 7);
+ assert(*next(m.begin(), 5) == 8);
+
+ i = m.erase(8);
+ assert(m.size() == 5);
+ assert(i == 1);
+ assert(*next(m.begin(), 0) == 2);
+ assert(*next(m.begin(), 1) == 3);
+ assert(*next(m.begin(), 2) == 5);
+ assert(*next(m.begin(), 3) == 6);
+ assert(*next(m.begin(), 4) == 7);
+
+ i = m.erase(3);
+ assert(m.size() == 4);
+ assert(i == 1);
+ assert(*next(m.begin(), 0) == 2);
+ assert(*next(m.begin(), 1) == 5);
+ assert(*next(m.begin(), 2) == 6);
+ assert(*next(m.begin(), 3) == 7);
+
+ i = m.erase(6);
+ assert(m.size() == 3);
+ assert(i == 1);
+ assert(*next(m.begin(), 0) == 2);
+ assert(*next(m.begin(), 1) == 5);
+ assert(*next(m.begin(), 2) == 7);
+
+ i = m.erase(7);
+ assert(m.size() == 2);
+ assert(i == 1);
+ assert(*next(m.begin(), 0) == 2);
+ assert(*next(m.begin(), 1) == 5);
+
+ i = m.erase(2);
+ assert(m.size() == 1);
+ assert(i == 1);
+ assert(*next(m.begin(), 0) == 5);
+
+ i = m.erase(5);
+ assert(m.size() == 0);
+ assert(i == 1);
+ }
+#endif
+}
diff --git a/test/std/containers/associative/set/find.pass.cpp b/test/std/containers/associative/set/find.pass.cpp
new file mode 100644
index 000000000000..d08d2fb1e245
--- /dev/null
+++ b/test/std/containers/associative/set/find.pass.cpp
@@ -0,0 +1,240 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// iterator find(const key_type& k);
+// const_iterator find(const key_type& k) const;
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "private_constructor.hpp"
+
+int main()
+{
+ {
+ typedef int V;
+ typedef std::set<int> M;
+ {
+ typedef M::iterator R;
+ V ar[] =
+ {
+ 5,
+ 6,
+ 7,
+ 8,
+ 9,
+ 10,
+ 11,
+ 12
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.find(5);
+ assert(r == m.begin());
+ r = m.find(6);
+ assert(r == next(m.begin()));
+ r = m.find(7);
+ assert(r == next(m.begin(), 2));
+ r = m.find(8);
+ assert(r == next(m.begin(), 3));
+ r = m.find(9);
+ assert(r == next(m.begin(), 4));
+ r = m.find(10);
+ assert(r == next(m.begin(), 5));
+ r = m.find(11);
+ assert(r == next(m.begin(), 6));
+ r = m.find(12);
+ assert(r == next(m.begin(), 7));
+ r = m.find(4);
+ assert(r == next(m.begin(), 8));
+ }
+ {
+ typedef M::const_iterator R;
+ V ar[] =
+ {
+ 5,
+ 6,
+ 7,
+ 8,
+ 9,
+ 10,
+ 11,
+ 12
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.find(5);
+ assert(r == m.begin());
+ r = m.find(6);
+ assert(r == next(m.begin()));
+ r = m.find(7);
+ assert(r == next(m.begin(), 2));
+ r = m.find(8);
+ assert(r == next(m.begin(), 3));
+ r = m.find(9);
+ assert(r == next(m.begin(), 4));
+ r = m.find(10);
+ assert(r == next(m.begin(), 5));
+ r = m.find(11);
+ assert(r == next(m.begin(), 6));
+ r = m.find(12);
+ assert(r == next(m.begin(), 7));
+ r = m.find(4);
+ assert(r == next(m.begin(), 8));
+ }
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int V;
+ typedef std::set<int, std::less<int>, min_allocator<int>> M;
+ {
+ typedef M::iterator R;
+ V ar[] =
+ {
+ 5,
+ 6,
+ 7,
+ 8,
+ 9,
+ 10,
+ 11,
+ 12
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.find(5);
+ assert(r == m.begin());
+ r = m.find(6);
+ assert(r == next(m.begin()));
+ r = m.find(7);
+ assert(r == next(m.begin(), 2));
+ r = m.find(8);
+ assert(r == next(m.begin(), 3));
+ r = m.find(9);
+ assert(r == next(m.begin(), 4));
+ r = m.find(10);
+ assert(r == next(m.begin(), 5));
+ r = m.find(11);
+ assert(r == next(m.begin(), 6));
+ r = m.find(12);
+ assert(r == next(m.begin(), 7));
+ r = m.find(4);
+ assert(r == next(m.begin(), 8));
+ }
+ {
+ typedef M::const_iterator R;
+ V ar[] =
+ {
+ 5,
+ 6,
+ 7,
+ 8,
+ 9,
+ 10,
+ 11,
+ 12
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.find(5);
+ assert(r == m.begin());
+ r = m.find(6);
+ assert(r == next(m.begin()));
+ r = m.find(7);
+ assert(r == next(m.begin(), 2));
+ r = m.find(8);
+ assert(r == next(m.begin(), 3));
+ r = m.find(9);
+ assert(r == next(m.begin(), 4));
+ r = m.find(10);
+ assert(r == next(m.begin(), 5));
+ r = m.find(11);
+ assert(r == next(m.begin(), 6));
+ r = m.find(12);
+ assert(r == next(m.begin(), 7));
+ r = m.find(4);
+ assert(r == next(m.begin(), 8));
+ }
+ }
+#endif
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef int V;
+ typedef std::set<V, std::less<>> M;
+ typedef M::iterator R;
+
+ V ar[] =
+ {
+ 5,
+ 6,
+ 7,
+ 8,
+ 9,
+ 10,
+ 11,
+ 12
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.find(5);
+ assert(r == m.begin());
+ r = m.find(6);
+ assert(r == next(m.begin()));
+ r = m.find(7);
+ assert(r == next(m.begin(), 2));
+ r = m.find(8);
+ assert(r == next(m.begin(), 3));
+ r = m.find(9);
+ assert(r == next(m.begin(), 4));
+ r = m.find(10);
+ assert(r == next(m.begin(), 5));
+ r = m.find(11);
+ assert(r == next(m.begin(), 6));
+ r = m.find(12);
+ assert(r == next(m.begin(), 7));
+ r = m.find(4);
+ assert(r == next(m.begin(), 8));
+ }
+
+ {
+ typedef PrivateConstructor V;
+ typedef std::set<V, std::less<>> M;
+ typedef M::iterator R;
+
+ M m;
+ m.insert ( V::make ( 5 ));
+ m.insert ( V::make ( 6 ));
+ m.insert ( V::make ( 7 ));
+ m.insert ( V::make ( 8 ));
+ m.insert ( V::make ( 9 ));
+ m.insert ( V::make ( 10 ));
+ m.insert ( V::make ( 11 ));
+ m.insert ( V::make ( 12 ));
+
+ R r = m.find(5);
+ assert(r == m.begin());
+ r = m.find(6);
+ assert(r == next(m.begin()));
+ r = m.find(7);
+ assert(r == next(m.begin(), 2));
+ r = m.find(8);
+ assert(r == next(m.begin(), 3));
+ r = m.find(9);
+ assert(r == next(m.begin(), 4));
+ r = m.find(10);
+ assert(r == next(m.begin(), 5));
+ r = m.find(11);
+ assert(r == next(m.begin(), 6));
+ r = m.find(12);
+ assert(r == next(m.begin(), 7));
+ r = m.find(4);
+ assert(r == next(m.begin(), 8));
+ }
+#endif
+}
diff --git a/test/std/containers/associative/set/insert_cv.pass.cpp b/test/std/containers/associative/set/insert_cv.pass.cpp
new file mode 100644
index 000000000000..18d5c2e03395
--- /dev/null
+++ b/test/std/containers/associative/set/insert_cv.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// pair<iterator, bool> insert(const value_type& v);
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::set<int> M;
+ typedef std::pair<M::iterator, bool> R;
+ M m;
+ R r = m.insert(M::value_type(2));
+ assert(r.second);
+ assert(r.first == m.begin());
+ assert(m.size() == 1);
+ assert(*r.first == 2);
+
+ r = m.insert(M::value_type(1));
+ assert(r.second);
+ assert(r.first == m.begin());
+ assert(m.size() == 2);
+ assert(*r.first == 1);
+
+ r = m.insert(M::value_type(3));
+ assert(r.second);
+ assert(r.first == prev(m.end()));
+ assert(m.size() == 3);
+ assert(*r.first == 3);
+
+ r = m.insert(M::value_type(3));
+ assert(!r.second);
+ assert(r.first == prev(m.end()));
+ assert(m.size() == 3);
+ assert(*r.first == 3);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::set<int, std::less<int>, min_allocator<int>> M;
+ typedef std::pair<M::iterator, bool> R;
+ M m;
+ R r = m.insert(M::value_type(2));
+ assert(r.second);
+ assert(r.first == m.begin());
+ assert(m.size() == 1);
+ assert(*r.first == 2);
+
+ r = m.insert(M::value_type(1));
+ assert(r.second);
+ assert(r.first == m.begin());
+ assert(m.size() == 2);
+ assert(*r.first == 1);
+
+ r = m.insert(M::value_type(3));
+ assert(r.second);
+ assert(r.first == prev(m.end()));
+ assert(m.size() == 3);
+ assert(*r.first == 3);
+
+ r = m.insert(M::value_type(3));
+ assert(!r.second);
+ assert(r.first == prev(m.end()));
+ assert(m.size() == 3);
+ assert(*r.first == 3);
+ }
+#endif
+}
diff --git a/test/std/containers/associative/set/insert_initializer_list.pass.cpp b/test/std/containers/associative/set/insert_initializer_list.pass.cpp
new file mode 100644
index 000000000000..fc6d612b2ebe
--- /dev/null
+++ b/test/std/containers/associative/set/insert_initializer_list.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// void insert(initializer_list<value_type> il);
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::set<int> C;
+ typedef C::value_type V;
+ C m = {10, 8};
+ m.insert({1, 2, 3, 4, 5, 6});
+ assert(m.size() == 8);
+ assert(distance(m.begin(), m.end()) == m.size());
+ C::const_iterator i = m.cbegin();
+ assert(*i == V(1));
+ assert(*++i == V(2));
+ assert(*++i == V(3));
+ assert(*++i == V(4));
+ assert(*++i == V(5));
+ assert(*++i == V(6));
+ assert(*++i == V(8));
+ assert(*++i == V(10));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::set<int, std::less<int>, min_allocator<int>> C;
+ typedef C::value_type V;
+ C m = {10, 8};
+ m.insert({1, 2, 3, 4, 5, 6});
+ assert(m.size() == 8);
+ assert(distance(m.begin(), m.end()) == m.size());
+ C::const_iterator i = m.cbegin();
+ assert(*i == V(1));
+ assert(*++i == V(2));
+ assert(*++i == V(3));
+ assert(*++i == V(4));
+ assert(*++i == V(5));
+ assert(*++i == V(6));
+ assert(*++i == V(8));
+ assert(*++i == V(10));
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/containers/associative/set/insert_iter_cv.pass.cpp b/test/std/containers/associative/set/insert_iter_cv.pass.cpp
new file mode 100644
index 000000000000..718e720559f4
--- /dev/null
+++ b/test/std/containers/associative/set/insert_iter_cv.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// iterator insert(const_iterator position, const value_type& v);
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::set<int> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.insert(m.cend(), M::value_type(2));
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(*r == 2);
+
+ r = m.insert(m.cend(), M::value_type(1));
+ assert(r == m.begin());
+ assert(m.size() == 2);
+ assert(*r == 1);
+
+ r = m.insert(m.cend(), M::value_type(3));
+ assert(r == prev(m.end()));
+ assert(m.size() == 3);
+ assert(*r == 3);
+
+ r = m.insert(m.cend(), M::value_type(3));
+ assert(r == prev(m.end()));
+ assert(m.size() == 3);
+ assert(*r == 3);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::set<int, std::less<int>, min_allocator<int>> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.insert(m.cend(), M::value_type(2));
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(*r == 2);
+
+ r = m.insert(m.cend(), M::value_type(1));
+ assert(r == m.begin());
+ assert(m.size() == 2);
+ assert(*r == 1);
+
+ r = m.insert(m.cend(), M::value_type(3));
+ assert(r == prev(m.end()));
+ assert(m.size() == 3);
+ assert(*r == 3);
+
+ r = m.insert(m.cend(), M::value_type(3));
+ assert(r == prev(m.end()));
+ assert(m.size() == 3);
+ assert(*r == 3);
+ }
+#endif
+}
diff --git a/test/std/containers/associative/set/insert_iter_iter.pass.cpp b/test/std/containers/associative/set/insert_iter_iter.pass.cpp
new file mode 100644
index 000000000000..ff729a0e7b9b
--- /dev/null
+++ b/test/std/containers/associative/set/insert_iter_iter.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// template <class InputIterator>
+// void insert(InputIterator first, InputIterator last);
+
+#include <set>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::set<int> M;
+ typedef int V;
+ V ar[] =
+ {
+ 1,
+ 1,
+ 1,
+ 2,
+ 2,
+ 2,
+ 3,
+ 3,
+ 3
+ };
+ M m;
+ m.insert(input_iterator<const V*>(ar),
+ input_iterator<const V*>(ar + sizeof(ar)/sizeof(ar[0])));
+ assert(m.size() == 3);
+ assert(*m.begin() == 1);
+ assert(*next(m.begin()) == 2);
+ assert(*next(m.begin(), 2) == 3);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::set<int, std::less<int>, min_allocator<int>> M;
+ typedef int V;
+ V ar[] =
+ {
+ 1,
+ 1,
+ 1,
+ 2,
+ 2,
+ 2,
+ 3,
+ 3,
+ 3
+ };
+ M m;
+ m.insert(input_iterator<const V*>(ar),
+ input_iterator<const V*>(ar + sizeof(ar)/sizeof(ar[0])));
+ assert(m.size() == 3);
+ assert(*m.begin() == 1);
+ assert(*next(m.begin()) == 2);
+ assert(*next(m.begin(), 2) == 3);
+ }
+#endif
+}
diff --git a/test/std/containers/associative/set/insert_iter_rv.pass.cpp b/test/std/containers/associative/set/insert_iter_rv.pass.cpp
new file mode 100644
index 000000000000..296ead84914d
--- /dev/null
+++ b/test/std/containers/associative/set/insert_iter_rv.pass.cpp
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// iterator insert(const_iterator position, value_type&& v);
+
+#include <set>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::set<MoveOnly> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.insert(m.cend(), M::value_type(2));
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(*r == 2);
+
+ r = m.insert(m.cend(), M::value_type(1));
+ assert(r == m.begin());
+ assert(m.size() == 2);
+ assert(*r == 1);
+
+ r = m.insert(m.cend(), M::value_type(3));
+ assert(r == prev(m.end()));
+ assert(m.size() == 3);
+ assert(*r == 3);
+
+ r = m.insert(m.cend(), M::value_type(3));
+ assert(r == prev(m.end()));
+ assert(m.size() == 3);
+ assert(*r == 3);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::set<MoveOnly, std::less<MoveOnly>, min_allocator<MoveOnly>> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.insert(m.cend(), M::value_type(2));
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(*r == 2);
+
+ r = m.insert(m.cend(), M::value_type(1));
+ assert(r == m.begin());
+ assert(m.size() == 2);
+ assert(*r == 1);
+
+ r = m.insert(m.cend(), M::value_type(3));
+ assert(r == prev(m.end()));
+ assert(m.size() == 3);
+ assert(*r == 3);
+
+ r = m.insert(m.cend(), M::value_type(3));
+ assert(r == prev(m.end()));
+ assert(m.size() == 3);
+ assert(*r == 3);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/associative/set/insert_rv.pass.cpp b/test/std/containers/associative/set/insert_rv.pass.cpp
new file mode 100644
index 000000000000..32cede154956
--- /dev/null
+++ b/test/std/containers/associative/set/insert_rv.pass.cpp
@@ -0,0 +1,84 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// pair<iterator, bool> insert(value_type&& v);
+
+#include <set>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::set<MoveOnly> M;
+ typedef std::pair<M::iterator, bool> R;
+ M m;
+ R r = m.insert(M::value_type(2));
+ assert(r.second);
+ assert(r.first == m.begin());
+ assert(m.size() == 1);
+ assert(*r.first == 2);
+
+ r = m.insert(M::value_type(1));
+ assert(r.second);
+ assert(r.first == m.begin());
+ assert(m.size() == 2);
+ assert(*r.first == 1);
+
+ r = m.insert(M::value_type(3));
+ assert(r.second);
+ assert(r.first == prev(m.end()));
+ assert(m.size() == 3);
+ assert(*r.first == 3);
+
+ r = m.insert(M::value_type(3));
+ assert(!r.second);
+ assert(r.first == prev(m.end()));
+ assert(m.size() == 3);
+ assert(*r.first == 3);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::set<MoveOnly, std::less<MoveOnly>, min_allocator<MoveOnly>> M;
+ typedef std::pair<M::iterator, bool> R;
+ M m;
+ R r = m.insert(M::value_type(2));
+ assert(r.second);
+ assert(r.first == m.begin());
+ assert(m.size() == 1);
+ assert(*r.first == 2);
+
+ r = m.insert(M::value_type(1));
+ assert(r.second);
+ assert(r.first == m.begin());
+ assert(m.size() == 2);
+ assert(*r.first == 1);
+
+ r = m.insert(M::value_type(3));
+ assert(r.second);
+ assert(r.first == prev(m.end()));
+ assert(m.size() == 3);
+ assert(*r.first == 3);
+
+ r = m.insert(M::value_type(3));
+ assert(!r.second);
+ assert(r.first == prev(m.end()));
+ assert(m.size() == 3);
+ assert(*r.first == 3);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/associative/set/iterator.pass.cpp b/test/std/containers/associative/set/iterator.pass.cpp
new file mode 100644
index 000000000000..ecd950f03a00
--- /dev/null
+++ b/test/std/containers/associative/set/iterator.pass.cpp
@@ -0,0 +1,211 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// iterator begin();
+// const_iterator begin() const;
+// iterator end();
+// const_iterator end() const;
+//
+// reverse_iterator rbegin();
+// const_reverse_iterator rbegin() const;
+// reverse_iterator rend();
+// const_reverse_iterator rend() const;
+//
+// const_iterator cbegin() const;
+// const_iterator cend() const;
+// const_reverse_iterator crbegin() const;
+// const_reverse_iterator crend() const;
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int V;
+ V ar[] =
+ {
+ 1,
+ 1,
+ 1,
+ 2,
+ 2,
+ 2,
+ 3,
+ 3,
+ 3,
+ 4,
+ 4,
+ 4,
+ 5,
+ 5,
+ 5,
+ 6,
+ 6,
+ 6,
+ 7,
+ 7,
+ 7,
+ 8,
+ 8,
+ 8
+ };
+ std::set<int> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ assert(std::distance(m.begin(), m.end()) == m.size());
+ assert(std::distance(m.rbegin(), m.rend()) == m.size());
+ std::set<int>::iterator i;
+ i = m.begin();
+ std::set<int>::const_iterator k = i;
+ assert(i == k);
+ for (int j = 1; j <= m.size(); ++j, ++i)
+ assert(*i == j);
+ }
+ {
+ typedef int V;
+ V ar[] =
+ {
+ 1,
+ 1,
+ 1,
+ 2,
+ 2,
+ 2,
+ 3,
+ 3,
+ 3,
+ 4,
+ 4,
+ 4,
+ 5,
+ 5,
+ 5,
+ 6,
+ 6,
+ 6,
+ 7,
+ 7,
+ 7,
+ 8,
+ 8,
+ 8
+ };
+ const std::set<int> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ assert(std::distance(m.begin(), m.end()) == m.size());
+ assert(std::distance(m.cbegin(), m.cend()) == m.size());
+ assert(std::distance(m.rbegin(), m.rend()) == m.size());
+ assert(std::distance(m.crbegin(), m.crend()) == m.size());
+ std::set<int>::const_iterator i;
+ i = m.begin();
+ for (int j = 1; j <= m.size(); ++j, ++i)
+ assert(*i == j);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int V;
+ V ar[] =
+ {
+ 1,
+ 1,
+ 1,
+ 2,
+ 2,
+ 2,
+ 3,
+ 3,
+ 3,
+ 4,
+ 4,
+ 4,
+ 5,
+ 5,
+ 5,
+ 6,
+ 6,
+ 6,
+ 7,
+ 7,
+ 7,
+ 8,
+ 8,
+ 8
+ };
+ std::set<int, std::less<int>, min_allocator<int>> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ assert(std::distance(m.begin(), m.end()) == m.size());
+ assert(std::distance(m.rbegin(), m.rend()) == m.size());
+ std::set<int, std::less<int>, min_allocator<int>>::iterator i;
+ i = m.begin();
+ std::set<int, std::less<int>, min_allocator<int>>::const_iterator k = i;
+ assert(i == k);
+ for (int j = 1; j <= m.size(); ++j, ++i)
+ assert(*i == j);
+ }
+ {
+ typedef int V;
+ V ar[] =
+ {
+ 1,
+ 1,
+ 1,
+ 2,
+ 2,
+ 2,
+ 3,
+ 3,
+ 3,
+ 4,
+ 4,
+ 4,
+ 5,
+ 5,
+ 5,
+ 6,
+ 6,
+ 6,
+ 7,
+ 7,
+ 7,
+ 8,
+ 8,
+ 8
+ };
+ const std::set<int, std::less<int>, min_allocator<int>> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ assert(std::distance(m.begin(), m.end()) == m.size());
+ assert(std::distance(m.cbegin(), m.cend()) == m.size());
+ assert(std::distance(m.rbegin(), m.rend()) == m.size());
+ assert(std::distance(m.crbegin(), m.crend()) == m.size());
+ std::set<int, std::less<int>, min_allocator<int>>::const_iterator i;
+ i = m.begin();
+ for (int j = 1; j <= m.size(); ++j, ++i)
+ assert(*i == j);
+ }
+#endif
+#if _LIBCPP_STD_VER > 11
+ { // N3644 testing
+ typedef std::set<int> C;
+ C::iterator ii1{}, ii2{};
+ C::iterator ii4 = ii1;
+ C::const_iterator cii{};
+ assert ( ii1 == ii2 );
+ assert ( ii1 == ii4 );
+
+ assert (!(ii1 != ii2 ));
+
+ assert ( (ii1 == cii ));
+ assert ( (cii == ii1 ));
+ assert (!(ii1 != cii ));
+ assert (!(cii != ii1 ));
+ }
+#endif
+}
diff --git a/test/std/containers/associative/set/lower_bound.pass.cpp b/test/std/containers/associative/set/lower_bound.pass.cpp
new file mode 100644
index 000000000000..df202f31a4c3
--- /dev/null
+++ b/test/std/containers/associative/set/lower_bound.pass.cpp
@@ -0,0 +1,337 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// iterator lower_bound(const key_type& k);
+// const_iterator lower_bound(const key_type& k) const;
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "private_constructor.hpp"
+
+int main()
+{
+ {
+ typedef int V;
+ typedef std::set<int> M;
+ {
+ typedef M::iterator R;
+ V ar[] =
+ {
+ 5,
+ 7,
+ 9,
+ 11,
+ 13,
+ 15,
+ 17,
+ 19
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.lower_bound(5);
+ assert(r == m.begin());
+ r = m.lower_bound(7);
+ assert(r == next(m.begin()));
+ r = m.lower_bound(9);
+ assert(r == next(m.begin(), 2));
+ r = m.lower_bound(11);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(13);
+ assert(r == next(m.begin(), 4));
+ r = m.lower_bound(15);
+ assert(r == next(m.begin(), 5));
+ r = m.lower_bound(17);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(19);
+ assert(r == next(m.begin(), 7));
+ r = m.lower_bound(4);
+ assert(r == next(m.begin(), 0));
+ r = m.lower_bound(6);
+ assert(r == next(m.begin(), 1));
+ r = m.lower_bound(8);
+ assert(r == next(m.begin(), 2));
+ r = m.lower_bound(10);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(12);
+ assert(r == next(m.begin(), 4));
+ r = m.lower_bound(14);
+ assert(r == next(m.begin(), 5));
+ r = m.lower_bound(16);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(18);
+ assert(r == next(m.begin(), 7));
+ r = m.lower_bound(20);
+ assert(r == next(m.begin(), 8));
+ }
+ {
+ typedef M::const_iterator R;
+ V ar[] =
+ {
+ 5,
+ 7,
+ 9,
+ 11,
+ 13,
+ 15,
+ 17,
+ 19
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.lower_bound(5);
+ assert(r == m.begin());
+ r = m.lower_bound(7);
+ assert(r == next(m.begin()));
+ r = m.lower_bound(9);
+ assert(r == next(m.begin(), 2));
+ r = m.lower_bound(11);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(13);
+ assert(r == next(m.begin(), 4));
+ r = m.lower_bound(15);
+ assert(r == next(m.begin(), 5));
+ r = m.lower_bound(17);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(19);
+ assert(r == next(m.begin(), 7));
+ r = m.lower_bound(4);
+ assert(r == next(m.begin(), 0));
+ r = m.lower_bound(6);
+ assert(r == next(m.begin(), 1));
+ r = m.lower_bound(8);
+ assert(r == next(m.begin(), 2));
+ r = m.lower_bound(10);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(12);
+ assert(r == next(m.begin(), 4));
+ r = m.lower_bound(14);
+ assert(r == next(m.begin(), 5));
+ r = m.lower_bound(16);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(18);
+ assert(r == next(m.begin(), 7));
+ r = m.lower_bound(20);
+ assert(r == next(m.begin(), 8));
+ }
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int V;
+ typedef std::set<int, std::less<int>, min_allocator<int>> M;
+ {
+ typedef M::iterator R;
+ V ar[] =
+ {
+ 5,
+ 7,
+ 9,
+ 11,
+ 13,
+ 15,
+ 17,
+ 19
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.lower_bound(5);
+ assert(r == m.begin());
+ r = m.lower_bound(7);
+ assert(r == next(m.begin()));
+ r = m.lower_bound(9);
+ assert(r == next(m.begin(), 2));
+ r = m.lower_bound(11);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(13);
+ assert(r == next(m.begin(), 4));
+ r = m.lower_bound(15);
+ assert(r == next(m.begin(), 5));
+ r = m.lower_bound(17);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(19);
+ assert(r == next(m.begin(), 7));
+ r = m.lower_bound(4);
+ assert(r == next(m.begin(), 0));
+ r = m.lower_bound(6);
+ assert(r == next(m.begin(), 1));
+ r = m.lower_bound(8);
+ assert(r == next(m.begin(), 2));
+ r = m.lower_bound(10);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(12);
+ assert(r == next(m.begin(), 4));
+ r = m.lower_bound(14);
+ assert(r == next(m.begin(), 5));
+ r = m.lower_bound(16);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(18);
+ assert(r == next(m.begin(), 7));
+ r = m.lower_bound(20);
+ assert(r == next(m.begin(), 8));
+ }
+ {
+ typedef M::const_iterator R;
+ V ar[] =
+ {
+ 5,
+ 7,
+ 9,
+ 11,
+ 13,
+ 15,
+ 17,
+ 19
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.lower_bound(5);
+ assert(r == m.begin());
+ r = m.lower_bound(7);
+ assert(r == next(m.begin()));
+ r = m.lower_bound(9);
+ assert(r == next(m.begin(), 2));
+ r = m.lower_bound(11);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(13);
+ assert(r == next(m.begin(), 4));
+ r = m.lower_bound(15);
+ assert(r == next(m.begin(), 5));
+ r = m.lower_bound(17);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(19);
+ assert(r == next(m.begin(), 7));
+ r = m.lower_bound(4);
+ assert(r == next(m.begin(), 0));
+ r = m.lower_bound(6);
+ assert(r == next(m.begin(), 1));
+ r = m.lower_bound(8);
+ assert(r == next(m.begin(), 2));
+ r = m.lower_bound(10);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(12);
+ assert(r == next(m.begin(), 4));
+ r = m.lower_bound(14);
+ assert(r == next(m.begin(), 5));
+ r = m.lower_bound(16);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(18);
+ assert(r == next(m.begin(), 7));
+ r = m.lower_bound(20);
+ assert(r == next(m.begin(), 8));
+ }
+ }
+#endif
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef int V;
+ typedef std::set<V, std::less<>> M;
+ typedef M::iterator R;
+
+ V ar[] =
+ {
+ 5,
+ 7,
+ 9,
+ 11,
+ 13,
+ 15,
+ 17,
+ 19
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.lower_bound(5);
+ assert(r == m.begin());
+ r = m.lower_bound(7);
+ assert(r == next(m.begin()));
+ r = m.lower_bound(9);
+ assert(r == next(m.begin(), 2));
+ r = m.lower_bound(11);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(13);
+ assert(r == next(m.begin(), 4));
+ r = m.lower_bound(15);
+ assert(r == next(m.begin(), 5));
+ r = m.lower_bound(17);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(19);
+ assert(r == next(m.begin(), 7));
+ r = m.lower_bound(4);
+ assert(r == next(m.begin(), 0));
+ r = m.lower_bound(6);
+ assert(r == next(m.begin(), 1));
+ r = m.lower_bound(8);
+ assert(r == next(m.begin(), 2));
+ r = m.lower_bound(10);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(12);
+ assert(r == next(m.begin(), 4));
+ r = m.lower_bound(14);
+ assert(r == next(m.begin(), 5));
+ r = m.lower_bound(16);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(18);
+ assert(r == next(m.begin(), 7));
+ r = m.lower_bound(20);
+ assert(r == next(m.begin(), 8));
+ }
+
+ {
+ typedef PrivateConstructor V;
+ typedef std::set<V, std::less<>> M;
+ typedef M::iterator R;
+
+ M m;
+ m.insert ( V::make ( 5 ));
+ m.insert ( V::make ( 7 ));
+ m.insert ( V::make ( 9 ));
+ m.insert ( V::make ( 11 ));
+ m.insert ( V::make ( 13 ));
+ m.insert ( V::make ( 15 ));
+ m.insert ( V::make ( 17 ));
+ m.insert ( V::make ( 19 ));
+
+ R r = m.lower_bound(5);
+ assert(r == m.begin());
+ r = m.lower_bound(7);
+ assert(r == next(m.begin()));
+ r = m.lower_bound(9);
+ assert(r == next(m.begin(), 2));
+ r = m.lower_bound(11);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(13);
+ assert(r == next(m.begin(), 4));
+ r = m.lower_bound(15);
+ assert(r == next(m.begin(), 5));
+ r = m.lower_bound(17);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(19);
+ assert(r == next(m.begin(), 7));
+ r = m.lower_bound(4);
+ assert(r == next(m.begin(), 0));
+ r = m.lower_bound(6);
+ assert(r == next(m.begin(), 1));
+ r = m.lower_bound(8);
+ assert(r == next(m.begin(), 2));
+ r = m.lower_bound(10);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(12);
+ assert(r == next(m.begin(), 4));
+ r = m.lower_bound(14);
+ assert(r == next(m.begin(), 5));
+ r = m.lower_bound(16);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(18);
+ assert(r == next(m.begin(), 7));
+ r = m.lower_bound(20);
+ assert(r == next(m.begin(), 8));
+ }
+#endif
+
+}
diff --git a/test/std/containers/associative/set/max_size.pass.cpp b/test/std/containers/associative/set/max_size.pass.cpp
new file mode 100644
index 000000000000..cde4397c7178
--- /dev/null
+++ b/test/std/containers/associative/set/max_size.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// size_type max_size() const;
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::set<int> M;
+ M m;
+ assert(m.max_size() != 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::set<int, std::less<int>, min_allocator<int>> M;
+ M m;
+ assert(m.max_size() != 0);
+ }
+#endif
+}
diff --git a/test/std/containers/associative/set/set.cons/alloc.pass.cpp b/test/std/containers/associative/set/set.cons/alloc.pass.cpp
new file mode 100644
index 000000000000..67433ff88a01
--- /dev/null
+++ b/test/std/containers/associative/set/set.cons/alloc.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// set(const allocator_type& a);
+
+#include <set>
+#include <cassert>
+
+#include "test_allocator.h"
+
+int main()
+{
+ typedef std::less<int> C;
+ typedef test_allocator<int> A;
+ std::set<int, C, A> m(A(5));
+ assert(m.empty());
+ assert(m.begin() == m.end());
+ assert(m.get_allocator() == A(5));
+}
diff --git a/test/std/containers/associative/set/set.cons/assign_initializer_list.pass.cpp b/test/std/containers/associative/set/set.cons/assign_initializer_list.pass.cpp
new file mode 100644
index 000000000000..892ae5a0a799
--- /dev/null
+++ b/test/std/containers/associative/set/set.cons/assign_initializer_list.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// set& operator=(initializer_list<value_type> il);
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::set<int> C;
+ typedef C::value_type V;
+ C m = {10, 8};
+ m = {1, 2, 3, 4, 5, 6};
+ assert(m.size() == 6);
+ assert(distance(m.begin(), m.end()) == 6);
+ C::const_iterator i = m.cbegin();
+ assert(*i == V(1));
+ assert(*++i == V(2));
+ assert(*++i == V(3));
+ assert(*++i == V(4));
+ assert(*++i == V(5));
+ assert(*++i == V(6));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::set<int, std::less<int>, min_allocator<int>> C;
+ typedef C::value_type V;
+ C m = {10, 8};
+ m = {1, 2, 3, 4, 5, 6};
+ assert(m.size() == 6);
+ assert(distance(m.begin(), m.end()) == 6);
+ C::const_iterator i = m.cbegin();
+ assert(*i == V(1));
+ assert(*++i == V(2));
+ assert(*++i == V(3));
+ assert(*++i == V(4));
+ assert(*++i == V(5));
+ assert(*++i == V(6));
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/containers/associative/set/set.cons/compare.pass.cpp b/test/std/containers/associative/set/set.cons/compare.pass.cpp
new file mode 100644
index 000000000000..af94c70671b8
--- /dev/null
+++ b/test/std/containers/associative/set/set.cons/compare.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// explicit set(const value_compare& comp);
+
+#include <set>
+#include <cassert>
+
+#include "../../../test_compare.h"
+
+int main()
+{
+ typedef test_compare<std::less<int> > C;
+ std::set<int, C> m(C(3));
+ assert(m.empty());
+ assert(m.begin() == m.end());
+ assert(m.key_comp() == C(3));
+}
diff --git a/test/std/containers/associative/set/set.cons/compare_alloc.pass.cpp b/test/std/containers/associative/set/set.cons/compare_alloc.pass.cpp
new file mode 100644
index 000000000000..22b3328d4d79
--- /dev/null
+++ b/test/std/containers/associative/set/set.cons/compare_alloc.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// set(const value_compare& comp, const allocator_type& a);
+
+#include <set>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+
+int main()
+{
+ typedef test_compare<std::less<int> > C;
+ typedef test_allocator<int> A;
+ std::set<int, C, A> m(C(4), A(5));
+ assert(m.empty());
+ assert(m.begin() == m.end());
+ assert(m.key_comp() == C(4));
+ assert(m.get_allocator() == A(5));
+}
diff --git a/test/std/containers/associative/set/set.cons/copy.pass.cpp b/test/std/containers/associative/set/set.cons/copy.pass.cpp
new file mode 100644
index 000000000000..a0e34e48de43
--- /dev/null
+++ b/test/std/containers/associative/set/set.cons/copy.pass.cpp
@@ -0,0 +1,94 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// set(const set& m);
+
+#include <set>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+
+int main()
+{
+ {
+ typedef int V;
+ V ar[] =
+ {
+ 1,
+ 1,
+ 1,
+ 2,
+ 2,
+ 2,
+ 3,
+ 3,
+ 3
+ };
+ typedef test_compare<std::less<int> > C;
+ typedef test_allocator<V> A;
+ std::set<int, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
+ std::set<int, C, A> m = mo;
+ assert(m.get_allocator() == A(7));
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == 1);
+ assert(*next(m.begin()) == 2);
+ assert(*next(m.begin(), 2) == 3);
+
+ assert(mo.get_allocator() == A(7));
+ assert(mo.key_comp() == C(5));
+ assert(mo.size() == 3);
+ assert(distance(mo.begin(), mo.end()) == 3);
+ assert(*mo.begin() == 1);
+ assert(*next(mo.begin()) == 2);
+ assert(*next(mo.begin(), 2) == 3);
+ }
+#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+ {
+ typedef int V;
+ V ar[] =
+ {
+ 1,
+ 1,
+ 1,
+ 2,
+ 2,
+ 2,
+ 3,
+ 3,
+ 3
+ };
+ typedef test_compare<std::less<int> > C;
+ typedef other_allocator<V> A;
+ std::set<int, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
+ std::set<int, C, A> m = mo;
+ assert(m.get_allocator() == A(-2));
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == 1);
+ assert(*next(m.begin()) == 2);
+ assert(*next(m.begin(), 2) == 3);
+
+ assert(mo.get_allocator() == A(7));
+ assert(mo.key_comp() == C(5));
+ assert(mo.size() == 3);
+ assert(distance(mo.begin(), mo.end()) == 3);
+ assert(*mo.begin() == 1);
+ assert(*next(mo.begin()) == 2);
+ assert(*next(mo.begin(), 2) == 3);
+ }
+#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE
+}
diff --git a/test/std/containers/associative/set/set.cons/copy_alloc.pass.cpp b/test/std/containers/associative/set/set.cons/copy_alloc.pass.cpp
new file mode 100644
index 000000000000..1ad03dc1404d
--- /dev/null
+++ b/test/std/containers/associative/set/set.cons/copy_alloc.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// set(const set& m, const allocator_type& a);
+
+#include <set>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+
+int main()
+{
+ typedef int V;
+ V ar[] =
+ {
+ 1,
+ 1,
+ 1,
+ 2,
+ 2,
+ 2,
+ 3,
+ 3,
+ 3
+ };
+ typedef test_compare<std::less<int> > C;
+ typedef test_allocator<V> A;
+ std::set<int, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
+ std::set<int, C, A> m(mo, A(3));
+ assert(m.get_allocator() == A(3));
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == 1);
+ assert(*next(m.begin()) == 2);
+ assert(*next(m.begin(), 2) == 3);
+
+ assert(mo.get_allocator() == A(7));
+ assert(mo.key_comp() == C(5));
+ assert(mo.size() == 3);
+ assert(distance(mo.begin(), mo.end()) == 3);
+ assert(*mo.begin() == 1);
+ assert(*next(mo.begin()) == 2);
+ assert(*next(mo.begin(), 2) == 3);
+}
diff --git a/test/std/containers/associative/set/set.cons/copy_assign.pass.cpp b/test/std/containers/associative/set/set.cons/copy_assign.pass.cpp
new file mode 100644
index 000000000000..7f0f0447625f
--- /dev/null
+++ b/test/std/containers/associative/set/set.cons/copy_assign.pass.cpp
@@ -0,0 +1,109 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// set& operator=(const set& s);
+
+#include <set>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+
+int main()
+{
+ {
+ typedef int V;
+ V ar[] =
+ {
+ 1,
+ 1,
+ 1,
+ 2,
+ 2,
+ 2,
+ 3,
+ 3,
+ 3
+ };
+ typedef test_compare<std::less<int> > C;
+ typedef test_allocator<V> A;
+ std::set<int, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(2));
+ std::set<int, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0])/2, C(3), A(7));
+ m = mo;
+ assert(m.get_allocator() == A(7));
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == 1);
+ assert(*next(m.begin()) == 2);
+ assert(*next(m.begin(), 2) == 3);
+
+ assert(mo.get_allocator() == A(2));
+ assert(mo.key_comp() == C(5));
+ assert(mo.size() == 3);
+ assert(distance(mo.begin(), mo.end()) == 3);
+ assert(*mo.begin() == 1);
+ assert(*next(mo.begin()) == 2);
+ assert(*next(mo.begin(), 2) == 3);
+ }
+ {
+ typedef int V;
+ const V ar[] =
+ {
+ 1,
+ 2,
+ 3
+ };
+ std::set<int> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ std::set<int> *p = &m;
+ m = *p;
+
+ assert(m.size() == 3);
+ assert(std::equal(m.begin(), m.end(), ar));
+ }
+ {
+ typedef int V;
+ V ar[] =
+ {
+ 1,
+ 1,
+ 1,
+ 2,
+ 2,
+ 2,
+ 3,
+ 3,
+ 3
+ };
+ typedef test_compare<std::less<int> > C;
+ typedef other_allocator<V> A;
+ std::set<int, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(2));
+ std::set<int, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0])/2, C(3), A(7));
+ m = mo;
+ assert(m.get_allocator() == A(2));
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == 1);
+ assert(*next(m.begin()) == 2);
+ assert(*next(m.begin(), 2) == 3);
+
+ assert(mo.get_allocator() == A(2));
+ assert(mo.key_comp() == C(5));
+ assert(mo.size() == 3);
+ assert(distance(mo.begin(), mo.end()) == 3);
+ assert(*mo.begin() == 1);
+ assert(*next(mo.begin()) == 2);
+ assert(*next(mo.begin(), 2) == 3);
+ }
+}
diff --git a/test/std/containers/associative/set/set.cons/default.pass.cpp b/test/std/containers/associative/set/set.cons/default.pass.cpp
new file mode 100644
index 000000000000..746a2d173071
--- /dev/null
+++ b/test/std/containers/associative/set/set.cons/default.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// set();
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::set<int> m;
+ assert(m.empty());
+ assert(m.begin() == m.end());
+ }
+#if __cplusplus >= 201103L
+ {
+ std::set<int, std::less<int>, min_allocator<int>> m;
+ assert(m.empty());
+ assert(m.begin() == m.end());
+ }
+ {
+ std::set<int> m = {};
+ assert(m.empty());
+ assert(m.begin() == m.end());
+ }
+#endif
+}
diff --git a/test/std/containers/associative/set/set.cons/default_noexcept.pass.cpp b/test/std/containers/associative/set/set.cons/default_noexcept.pass.cpp
new file mode 100644
index 000000000000..2156169acbc4
--- /dev/null
+++ b/test/std/containers/associative/set/set.cons/default_noexcept.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// set()
+// noexcept(
+// is_nothrow_default_constructible<allocator_type>::value &&
+// is_nothrow_default_constructible<key_compare>::value &&
+// is_nothrow_copy_constructible<key_compare>::value);
+
+// This tests a conforming extension
+
+#include <set>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_comp
+{
+ typedef T value_type;
+ some_comp();
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::set<MoveOnly> C;
+ static_assert(std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::set<MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::set<MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C;
+ static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::set<MoveOnly, some_comp<MoveOnly>> C;
+ static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+ }
+#endif
+}
diff --git a/test/std/containers/associative/set/set.cons/dtor_noexcept.pass.cpp b/test/std/containers/associative/set/set.cons/dtor_noexcept.pass.cpp
new file mode 100644
index 000000000000..b554d828d486
--- /dev/null
+++ b/test/std/containers/associative/set/set.cons/dtor_noexcept.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// ~set() // implied noexcept;
+
+#include <set>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "test_allocator.h"
+
+#if __has_feature(cxx_noexcept)
+
+template <class T>
+struct some_comp
+{
+ typedef T value_type;
+ ~some_comp() noexcept(false);
+};
+
+#endif
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::set<MoveOnly> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::set<MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::set<MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::set<MoveOnly, some_comp<MoveOnly>> C;
+ static_assert(!std::is_nothrow_destructible<C>::value, "");
+ }
+#endif
+}
diff --git a/test/std/containers/associative/set/set.cons/initializer_list.pass.cpp b/test/std/containers/associative/set/set.cons/initializer_list.pass.cpp
new file mode 100644
index 000000000000..2ad538e143f8
--- /dev/null
+++ b/test/std/containers/associative/set/set.cons/initializer_list.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// set(initializer_list<value_type> il, const key_compare& comp = key_compare());
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::set<int> C;
+ typedef C::value_type V;
+ C m = {1, 2, 3, 4, 5, 6};
+ assert(m.size() == 6);
+ assert(distance(m.begin(), m.end()) == 6);
+ C::const_iterator i = m.cbegin();
+ assert(*i == V(1));
+ assert(*++i == V(2));
+ assert(*++i == V(3));
+ assert(*++i == V(4));
+ assert(*++i == V(5));
+ assert(*++i == V(6));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::set<int, std::less<int>, min_allocator<int>> C;
+ typedef C::value_type V;
+ C m = {1, 2, 3, 4, 5, 6};
+ assert(m.size() == 6);
+ assert(distance(m.begin(), m.end()) == 6);
+ C::const_iterator i = m.cbegin();
+ assert(*i == V(1));
+ assert(*++i == V(2));
+ assert(*++i == V(3));
+ assert(*++i == V(4));
+ assert(*++i == V(5));
+ assert(*++i == V(6));
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/containers/associative/set/set.cons/initializer_list_compare.pass.cpp b/test/std/containers/associative/set/set.cons/initializer_list_compare.pass.cpp
new file mode 100644
index 000000000000..a0afa02cf749
--- /dev/null
+++ b/test/std/containers/associative/set/set.cons/initializer_list_compare.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// set(initializer_list<value_type> il, const key_compare& comp = key_compare());
+
+#include <set>
+#include <cassert>
+#include "../../../test_compare.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ typedef test_compare<std::less<int> > Cmp;
+ typedef std::set<int, Cmp> C;
+ typedef C::value_type V;
+ C m({1, 2, 3, 4, 5, 6}, Cmp(10));
+ assert(m.size() == 6);
+ assert(distance(m.begin(), m.end()) == 6);
+ C::const_iterator i = m.cbegin();
+ assert(*i == V(1));
+ assert(*++i == V(2));
+ assert(*++i == V(3));
+ assert(*++i == V(4));
+ assert(*++i == V(5));
+ assert(*++i == V(6));
+ assert(m.key_comp() == Cmp(10));
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/containers/associative/set/set.cons/initializer_list_compare_alloc.pass.cpp b/test/std/containers/associative/set/set.cons/initializer_list_compare_alloc.pass.cpp
new file mode 100644
index 000000000000..821820a1e0ce
--- /dev/null
+++ b/test/std/containers/associative/set/set.cons/initializer_list_compare_alloc.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// set(initializer_list<value_type> il, const key_compare& comp, const allocator_type& a);
+// set(initializer_list<value_type> il, const allocator_type& a);
+
+#include <set>
+#include <cassert>
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef test_compare<std::less<int> > Cmp;
+ typedef test_allocator<int> A;
+ typedef std::set<int, Cmp, A> C;
+ typedef C::value_type V;
+ C m({1, 2, 3, 4, 5, 6}, Cmp(10), A(4));
+ assert(m.size() == 6);
+ assert(distance(m.begin(), m.end()) == 6);
+ C::const_iterator i = m.cbegin();
+ assert(*i == V(1));
+ assert(*++i == V(2));
+ assert(*++i == V(3));
+ assert(*++i == V(4));
+ assert(*++i == V(5));
+ assert(*++i == V(6));
+ assert(m.key_comp() == Cmp(10));
+ assert(m.get_allocator() == A(4));
+ }
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef test_compare<std::less<int> > Cmp;
+ typedef test_allocator<int> A;
+ typedef std::set<int, Cmp, A> C;
+ typedef C::value_type V;
+ C m({1, 2, 3, 4, 5, 6}, A(4));
+ assert(m.size() == 6);
+ assert(distance(m.begin(), m.end()) == 6);
+ C::const_iterator i = m.cbegin();
+ assert(*i == V(1));
+ assert(*++i == V(2));
+ assert(*++i == V(3));
+ assert(*++i == V(4));
+ assert(*++i == V(5));
+ assert(*++i == V(6));
+ assert(m.get_allocator() == A(4));
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/containers/associative/set/set.cons/iter_iter.pass.cpp b/test/std/containers/associative/set/set.cons/iter_iter.pass.cpp
new file mode 100644
index 000000000000..7ca7fe14d6c4
--- /dev/null
+++ b/test/std/containers/associative/set/set.cons/iter_iter.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// template <class InputIterator>
+// set(InputIterator first, InputIterator last);
+
+#include <set>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int V;
+ V ar[] =
+ {
+ 1,
+ 1,
+ 1,
+ 2,
+ 2,
+ 2,
+ 3,
+ 3,
+ 3
+ };
+ std::set<V> m(input_iterator<const int*>(ar),
+ input_iterator<const int*>(ar+sizeof(ar)/sizeof(ar[0])));
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == 1);
+ assert(*next(m.begin()) == 2);
+ assert(*next(m.begin(), 2) == 3);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int V;
+ V ar[] =
+ {
+ 1,
+ 1,
+ 1,
+ 2,
+ 2,
+ 2,
+ 3,
+ 3,
+ 3
+ };
+ std::set<V, std::less<int>, min_allocator<int>> m(input_iterator<const int*>(ar),
+ input_iterator<const int*>(ar+sizeof(ar)/sizeof(ar[0])));
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == 1);
+ assert(*next(m.begin()) == 2);
+ assert(*next(m.begin(), 2) == 3);
+ }
+#endif
+}
diff --git a/test/std/containers/associative/set/set.cons/iter_iter_alloc.pass.cpp b/test/std/containers/associative/set/set.cons/iter_iter_alloc.pass.cpp
new file mode 100644
index 000000000000..5ccb6e5cbcd7
--- /dev/null
+++ b/test/std/containers/associative/set/set.cons/iter_iter_alloc.pass.cpp
@@ -0,0 +1,84 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// template <class InputIterator>
+// set(InputIterator first, InputIterator last,
+// const value_compare& comp, const allocator_type& a);
+//
+// template <class InputIterator>
+// set(InputIterator first, InputIterator last,
+// const allocator_type& a);
+
+#include <set>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+
+int main()
+{
+ typedef int V;
+ V ar[] =
+ {
+ 1,
+ 1,
+ 1,
+ 2,
+ 2,
+ 2,
+ 3,
+ 3,
+ 3
+ };
+ typedef test_compare<std::less<V> > C;
+ typedef test_allocator<V> A;
+ std::set<V, C, A> m(input_iterator<const V*>(ar),
+ input_iterator<const V*>(ar+sizeof(ar)/sizeof(ar[0])),
+ C(5), A(7));
+ assert(m.value_comp() == C(5));
+ assert(m.get_allocator() == A(7));
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == 1);
+ assert(*next(m.begin()) == 2);
+ assert(*next(m.begin(), 2) == 3);
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef int V;
+ V ar[] =
+ {
+ 1,
+ 1,
+ 1,
+ 2,
+ 2,
+ 2,
+ 3,
+ 3,
+ 3
+ };
+ typedef test_allocator<V> A;
+ typedef test_compare<std::less<int> > C;
+ A a(7);
+ std::set<V, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0]), a);
+
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == 1);
+ assert(*next(m.begin()) == 2);
+ assert(*next(m.begin(), 2) == 3);
+ assert(m.get_allocator() == a);
+ }
+#endif
+}
diff --git a/test/std/containers/associative/set/set.cons/iter_iter_comp.pass.cpp b/test/std/containers/associative/set/set.cons/iter_iter_comp.pass.cpp
new file mode 100644
index 000000000000..18bc0839003b
--- /dev/null
+++ b/test/std/containers/associative/set/set.cons/iter_iter_comp.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// template <class InputIterator>
+// set(InputIterator first, InputIterator last, const value_compare& comp);
+
+#include <set>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "../../../test_compare.h"
+
+int main()
+{
+ typedef int V;
+ V ar[] =
+ {
+ 1,
+ 1,
+ 1,
+ 2,
+ 2,
+ 2,
+ 3,
+ 3,
+ 3
+ };
+ typedef test_compare<std::less<V> > C;
+ std::set<V, C> m(input_iterator<const V*>(ar),
+ input_iterator<const V*>(ar+sizeof(ar)/sizeof(ar[0])), C(5));
+ assert(m.value_comp() == C(5));
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == 1);
+ assert(*next(m.begin()) == 2);
+ assert(*next(m.begin(), 2) == 3);
+}
diff --git a/test/std/containers/associative/set/set.cons/move.pass.cpp b/test/std/containers/associative/set/set.cons/move.pass.cpp
new file mode 100644
index 000000000000..4026ec70c3e1
--- /dev/null
+++ b/test/std/containers/associative/set/set.cons/move.pass.cpp
@@ -0,0 +1,107 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// set(set&& s);
+
+#include <set>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef int V;
+ typedef test_compare<std::less<int> > C;
+ typedef test_allocator<V> A;
+ std::set<int, C, A> mo(C(5), A(7));
+ std::set<int, C, A> m = std::move(mo);
+ assert(m.get_allocator() == A(7));
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 0);
+ assert(distance(m.begin(), m.end()) == 0);
+
+ assert(mo.get_allocator() == A(7));
+ assert(mo.key_comp() == C(5));
+ assert(mo.size() == 0);
+ assert(distance(mo.begin(), mo.end()) == 0);
+ }
+ {
+ typedef int V;
+ V ar[] =
+ {
+ 1,
+ 1,
+ 1,
+ 2,
+ 2,
+ 2,
+ 3,
+ 3,
+ 3
+ };
+ typedef test_compare<std::less<int> > C;
+ typedef test_allocator<V> A;
+ std::set<int, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
+ std::set<int, C, A> m = std::move(mo);
+ assert(m.get_allocator() == A(7));
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == 1);
+ assert(*next(m.begin()) == 2);
+ assert(*next(m.begin(), 2) == 3);
+
+ assert(mo.get_allocator() == A(7));
+ assert(mo.key_comp() == C(5));
+ assert(mo.size() == 0);
+ assert(distance(mo.begin(), mo.end()) == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int V;
+ V ar[] =
+ {
+ 1,
+ 1,
+ 1,
+ 2,
+ 2,
+ 2,
+ 3,
+ 3,
+ 3
+ };
+ typedef test_compare<std::less<int> > C;
+ typedef min_allocator<V> A;
+ std::set<int, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A());
+ std::set<int, C, A> m = std::move(mo);
+ assert(m.get_allocator() == A());
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == 1);
+ assert(*next(m.begin()) == 2);
+ assert(*next(m.begin(), 2) == 3);
+
+ assert(mo.get_allocator() == A());
+ assert(mo.key_comp() == C(5));
+ assert(mo.size() == 0);
+ assert(distance(mo.begin(), mo.end()) == 0);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/associative/set/set.cons/move_alloc.pass.cpp b/test/std/containers/associative/set/set.cons/move_alloc.pass.cpp
new file mode 100644
index 000000000000..799f0e402d63
--- /dev/null
+++ b/test/std/containers/associative/set/set.cons/move_alloc.pass.cpp
@@ -0,0 +1,188 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// set(set&& s, const allocator_type& a);
+
+#include <set>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+#include "Counter.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef MoveOnly V;
+ typedef test_compare<std::less<MoveOnly> > C;
+ typedef test_allocator<V> A;
+ typedef std::set<MoveOnly, C, A> M;
+ typedef std::move_iterator<V*> I;
+ V a1[] =
+ {
+ V(1),
+ V(1),
+ V(1),
+ V(2),
+ V(2),
+ V(2),
+ V(3),
+ V(3),
+ V(3)
+ };
+ M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+ V a2[] =
+ {
+ V(1),
+ V(1),
+ V(1),
+ V(2),
+ V(2),
+ V(2),
+ V(3),
+ V(3),
+ V(3)
+ };
+ M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+ M m3(std::move(m1), A(7));
+ assert(m3 == m2);
+ assert(m3.get_allocator() == A(7));
+ assert(m3.key_comp() == C(5));
+ assert(m1.empty());
+ }
+ {
+ typedef MoveOnly V;
+ typedef test_compare<std::less<MoveOnly> > C;
+ typedef test_allocator<V> A;
+ typedef std::set<MoveOnly, C, A> M;
+ typedef std::move_iterator<V*> I;
+ V a1[] =
+ {
+ V(1),
+ V(1),
+ V(1),
+ V(2),
+ V(2),
+ V(2),
+ V(3),
+ V(3),
+ V(3)
+ };
+ M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+ V a2[] =
+ {
+ V(1),
+ V(1),
+ V(1),
+ V(2),
+ V(2),
+ V(2),
+ V(3),
+ V(3),
+ V(3)
+ };
+ M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+ M m3(std::move(m1), A(5));
+ assert(m3 == m2);
+ assert(m3.get_allocator() == A(5));
+ assert(m3.key_comp() == C(5));
+ assert(m1.empty());
+ }
+ {
+ typedef MoveOnly V;
+ typedef test_compare<std::less<MoveOnly> > C;
+ typedef other_allocator<V> A;
+ typedef std::set<MoveOnly, C, A> M;
+ typedef std::move_iterator<V*> I;
+ V a1[] =
+ {
+ V(1),
+ V(1),
+ V(1),
+ V(2),
+ V(2),
+ V(2),
+ V(3),
+ V(3),
+ V(3)
+ };
+ M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+ V a2[] =
+ {
+ V(1),
+ V(1),
+ V(1),
+ V(2),
+ V(2),
+ V(2),
+ V(3),
+ V(3),
+ V(3)
+ };
+ M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+ M m3(std::move(m1), A(5));
+ assert(m3 == m2);
+ assert(m3.get_allocator() == A(5));
+ assert(m3.key_comp() == C(5));
+ assert(m1.empty());
+ }
+ {
+ typedef Counter<int> V;
+ typedef std::less<V> C;
+ typedef test_allocator<V> A;
+ typedef std::set<V, C, A> M;
+ typedef V* I;
+ Counter_base::gConstructed = 0;
+ {
+ V a1[] =
+ {
+ V(1),
+ V(1),
+ V(1),
+ V(2),
+ V(2),
+ V(2),
+ V(3),
+ V(3),
+ V(3)
+ };
+ const size_t num = sizeof(a1)/sizeof(a1[0]);
+ assert(Counter_base::gConstructed == num);
+
+ M m1(I(a1), I(a1+num), C(), A());
+ assert(Counter_base::gConstructed == 3+num);
+
+ M m2(m1);
+ assert(m2 == m1);
+ assert(Counter_base::gConstructed == 6+num);
+
+ M m3(std::move(m1), A());
+ assert(m3 == m2);
+ assert(m1.empty());
+ assert(Counter_base::gConstructed == 6+num);
+
+ {
+ M m4(std::move(m2), A(5));
+ assert(Counter_base::gConstructed == 6+num);
+ assert(m4 == m3);
+ assert(m2.empty());
+ }
+ assert(Counter_base::gConstructed == 3+num);
+ }
+ assert(Counter_base::gConstructed == 0);
+ }
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/associative/set/set.cons/move_assign.pass.cpp b/test/std/containers/associative/set/set.cons/move_assign.pass.cpp
new file mode 100644
index 000000000000..ed0e77ae1796
--- /dev/null
+++ b/test/std/containers/associative/set/set.cons/move_assign.pass.cpp
@@ -0,0 +1,186 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// set& operator=(set&& s);
+
+#include <set>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef MoveOnly V;
+ typedef test_compare<std::less<MoveOnly> > C;
+ typedef test_allocator<V> A;
+ typedef std::set<MoveOnly, C, A> M;
+ typedef std::move_iterator<V*> I;
+ V a1[] =
+ {
+ V(1),
+ V(1),
+ V(1),
+ V(2),
+ V(2),
+ V(2),
+ V(3),
+ V(3),
+ V(3)
+ };
+ M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+ V a2[] =
+ {
+ V(1),
+ V(1),
+ V(1),
+ V(2),
+ V(2),
+ V(2),
+ V(3),
+ V(3),
+ V(3)
+ };
+ M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+ M m3(C(3), A(7));
+ m3 = std::move(m1);
+ assert(m3 == m2);
+ assert(m3.get_allocator() == A(7));
+ assert(m3.key_comp() == C(5));
+ assert(m1.empty());
+ }
+ {
+ typedef MoveOnly V;
+ typedef test_compare<std::less<MoveOnly> > C;
+ typedef test_allocator<V> A;
+ typedef std::set<MoveOnly, C, A> M;
+ typedef std::move_iterator<V*> I;
+ V a1[] =
+ {
+ V(1),
+ V(1),
+ V(1),
+ V(2),
+ V(2),
+ V(2),
+ V(3),
+ V(3),
+ V(3)
+ };
+ M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+ V a2[] =
+ {
+ V(1),
+ V(1),
+ V(1),
+ V(2),
+ V(2),
+ V(2),
+ V(3),
+ V(3),
+ V(3)
+ };
+ M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+ M m3(C(3), A(5));
+ m3 = std::move(m1);
+ assert(m3 == m2);
+ assert(m3.get_allocator() == A(5));
+ assert(m3.key_comp() == C(5));
+ assert(m1.empty());
+ }
+ {
+ typedef MoveOnly V;
+ typedef test_compare<std::less<MoveOnly> > C;
+ typedef other_allocator<V> A;
+ typedef std::set<MoveOnly, C, A> M;
+ typedef std::move_iterator<V*> I;
+ V a1[] =
+ {
+ V(1),
+ V(1),
+ V(1),
+ V(2),
+ V(2),
+ V(2),
+ V(3),
+ V(3),
+ V(3)
+ };
+ M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+ V a2[] =
+ {
+ V(1),
+ V(1),
+ V(1),
+ V(2),
+ V(2),
+ V(2),
+ V(3),
+ V(3),
+ V(3)
+ };
+ M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+ M m3(C(3), A(5));
+ m3 = std::move(m1);
+ assert(m3 == m2);
+ assert(m3.get_allocator() == A(7));
+ assert(m3.key_comp() == C(5));
+ assert(m1.empty());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef MoveOnly V;
+ typedef test_compare<std::less<MoveOnly> > C;
+ typedef min_allocator<V> A;
+ typedef std::set<MoveOnly, C, A> M;
+ typedef std::move_iterator<V*> I;
+ V a1[] =
+ {
+ V(1),
+ V(1),
+ V(1),
+ V(2),
+ V(2),
+ V(2),
+ V(3),
+ V(3),
+ V(3)
+ };
+ M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A());
+ V a2[] =
+ {
+ V(1),
+ V(1),
+ V(1),
+ V(2),
+ V(2),
+ V(2),
+ V(3),
+ V(3),
+ V(3)
+ };
+ M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A());
+ M m3(C(3), A());
+ m3 = std::move(m1);
+ assert(m3 == m2);
+ assert(m3.get_allocator() == A());
+ assert(m3.key_comp() == C(5));
+ assert(m1.empty());
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/associative/set/set.cons/move_assign_noexcept.pass.cpp b/test/std/containers/associative/set/set.cons/move_assign_noexcept.pass.cpp
new file mode 100644
index 000000000000..3999c55e9e7c
--- /dev/null
+++ b/test/std/containers/associative/set/set.cons/move_assign_noexcept.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// set& operator=(set&& c)
+// noexcept(
+// allocator_type::propagate_on_container_move_assignment::value &&
+// is_nothrow_move_assignable<allocator_type>::value &&
+// is_nothrow_move_assignable<key_compare>::value);
+
+// This tests a conforming extension
+
+#include <set>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_comp
+{
+ typedef T value_type;
+ some_comp& operator=(const some_comp&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::set<MoveOnly> C;
+ static_assert(std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::set<MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::set<MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::set<MoveOnly, some_comp<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+ }
+#endif
+}
diff --git a/test/std/containers/associative/set/set.cons/move_noexcept.pass.cpp b/test/std/containers/associative/set/set.cons/move_noexcept.pass.cpp
new file mode 100644
index 000000000000..5ccfed4675c5
--- /dev/null
+++ b/test/std/containers/associative/set/set.cons/move_noexcept.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// set(set&&)
+// noexcept(is_nothrow_move_constructible<allocator_type>::value &&
+// is_nothrow_move_constructible<key_compare>::value);
+
+// This tests a conforming extension
+
+#include <set>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_comp
+{
+ typedef T value_type;
+ some_comp(const some_comp&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::set<MoveOnly> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::set<MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::set<MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::set<MoveOnly, some_comp<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_constructible<C>::value, "");
+ }
+#endif
+}
diff --git a/test/std/containers/associative/set/set.special/member_swap.pass.cpp b/test/std/containers/associative/set/set.special/member_swap.pass.cpp
new file mode 100644
index 000000000000..b5129f880afd
--- /dev/null
+++ b/test/std/containers/associative/set/set.special/member_swap.pass.cpp
@@ -0,0 +1,177 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// void swap(set& m);
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int V;
+ typedef std::set<int> M;
+ {
+ M m1;
+ M m2;
+ M m1_save = m1;
+ M m2_save = m2;
+ m1.swap(m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar2[] =
+ {
+ 5,
+ 6,
+ 7,
+ 8,
+ 9,
+ 10,
+ 11,
+ 12
+ };
+ M m1;
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ m1.swap(m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar1[] =
+ {
+ 1,
+ 2,
+ 3,
+ 4
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2;
+ M m1_save = m1;
+ M m2_save = m2;
+ m1.swap(m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar1[] =
+ {
+ 1,
+ 2,
+ 3,
+ 4
+ };
+ V ar2[] =
+ {
+ 5,
+ 6,
+ 7,
+ 8,
+ 9,
+ 10,
+ 11,
+ 12
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ m1.swap(m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int V;
+ typedef std::set<int, std::less<int>, min_allocator<int>> M;
+ {
+ M m1;
+ M m2;
+ M m1_save = m1;
+ M m2_save = m2;
+ m1.swap(m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar2[] =
+ {
+ 5,
+ 6,
+ 7,
+ 8,
+ 9,
+ 10,
+ 11,
+ 12
+ };
+ M m1;
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ m1.swap(m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar1[] =
+ {
+ 1,
+ 2,
+ 3,
+ 4
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2;
+ M m1_save = m1;
+ M m2_save = m2;
+ m1.swap(m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar1[] =
+ {
+ 1,
+ 2,
+ 3,
+ 4
+ };
+ V ar2[] =
+ {
+ 5,
+ 6,
+ 7,
+ 8,
+ 9,
+ 10,
+ 11,
+ 12
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ m1.swap(m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ }
+#endif
+}
diff --git a/test/std/containers/associative/set/set.special/non_member_swap.pass.cpp b/test/std/containers/associative/set/set.special/non_member_swap.pass.cpp
new file mode 100644
index 000000000000..0ac14464c70f
--- /dev/null
+++ b/test/std/containers/associative/set/set.special/non_member_swap.pass.cpp
@@ -0,0 +1,165 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// void swap(set& m);
+
+#include <set>
+#include <cassert>
+#include "test_allocator.h"
+#include "../../../test_compare.h"
+
+int main()
+{
+ typedef int V;
+ typedef std::set<int> M;
+ {
+ M m1;
+ M m2;
+ M m1_save = m1;
+ M m2_save = m2;
+ swap(m1, m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar2[] =
+ {
+ 5,
+ 6,
+ 7,
+ 8,
+ 9,
+ 10,
+ 11,
+ 12
+ };
+ M m1;
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ swap(m1, m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar1[] =
+ {
+ 1,
+ 2,
+ 3,
+ 4
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2;
+ M m1_save = m1;
+ M m2_save = m2;
+ swap(m1, m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar1[] =
+ {
+ 1,
+ 2,
+ 3,
+ 4
+ };
+ V ar2[] =
+ {
+ 5,
+ 6,
+ 7,
+ 8,
+ 9,
+ 10,
+ 11,
+ 12
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ swap(m1, m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ typedef test_allocator<V> A;
+ typedef test_compare<std::less<int> > C;
+ typedef std::set<int, C, A> M;
+ V ar1[] =
+ {
+ 1,
+ 2,
+ 3,
+ 4
+ };
+ V ar2[] =
+ {
+ 5,
+ 6,
+ 7,
+ 8,
+ 9,
+ 10,
+ 11,
+ 12
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]), C(1), A(1));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]), C(2), A(2));
+ M m1_save = m1;
+ M m2_save = m2;
+ swap(m1, m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ assert(m1.key_comp() == C(2));
+ assert(m1.get_allocator() == A(1));
+ assert(m2.key_comp() == C(1));
+ assert(m2.get_allocator() == A(2));
+ }
+ {
+ typedef other_allocator<V> A;
+ typedef test_compare<std::less<int> > C;
+ typedef std::set<int, C, A> M;
+ V ar1[] =
+ {
+ 1,
+ 2,
+ 3,
+ 4
+ };
+ V ar2[] =
+ {
+ 5,
+ 6,
+ 7,
+ 8,
+ 9,
+ 10,
+ 11,
+ 12
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]), C(1), A(1));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]), C(2), A(2));
+ M m1_save = m1;
+ M m2_save = m2;
+ swap(m1, m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ assert(m1.key_comp() == C(2));
+ assert(m1.get_allocator() == A(2));
+ assert(m2.key_comp() == C(1));
+ assert(m2.get_allocator() == A(1));
+ }
+}
diff --git a/test/std/containers/associative/set/set.special/swap_noexcept.pass.cpp b/test/std/containers/associative/set/set.special/swap_noexcept.pass.cpp
new file mode 100644
index 000000000000..3ec697612754
--- /dev/null
+++ b/test/std/containers/associative/set/set.special/swap_noexcept.pass.cpp
@@ -0,0 +1,148 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// void swap(set& c)
+// noexcept(!allocator_type::propagate_on_container_swap::value ||
+// __is_nothrow_swappable<allocator_type>::value);
+//
+// In C++17, the standard says that swap shall have:
+// noexcept(allocator_traits<Allocator>::is_always_equal::value &&
+// noexcept(swap(declval<Compare&>(), declval<Compare&>())));
+
+// This tests a conforming extension
+
+#include <set>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_comp
+{
+ typedef T value_type;
+
+ some_comp() {}
+ some_comp(const some_comp&) {}
+ void deallocate(void*, unsigned) {}
+
+ typedef std::true_type propagate_on_container_swap;
+};
+
+template <class T>
+struct some_comp2
+{
+ typedef T value_type;
+
+ some_comp2() {}
+ some_comp2(const some_comp2&) {}
+ void deallocate(void*, unsigned) {}
+ typedef std::true_type propagate_on_container_swap;
+};
+
+#if TEST_STD_VER >= 14
+template <typename T>
+void swap(some_comp2<T>&, some_comp2<T>&) noexcept {}
+#endif
+
+template <class T>
+struct some_alloc
+{
+ typedef T value_type;
+
+ some_alloc() {}
+ some_alloc(const some_alloc&);
+ void deallocate(void*, unsigned) {}
+
+ typedef std::true_type propagate_on_container_swap;
+};
+
+template <class T>
+struct some_alloc2
+{
+ typedef T value_type;
+
+ some_alloc2() {}
+ some_alloc2(const some_alloc2&);
+ void deallocate(void*, unsigned) {}
+
+ typedef std::false_type propagate_on_container_swap;
+ typedef std::true_type is_always_equal;
+};
+
+template <class T>
+struct some_alloc3
+{
+ typedef T value_type;
+
+ some_alloc3() {}
+ some_alloc3(const some_alloc3&);
+ void deallocate(void*, unsigned) {}
+
+ typedef std::false_type propagate_on_container_swap;
+ typedef std::false_type is_always_equal;
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::set<MoveOnly> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::set<MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::set<MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::set<MoveOnly, some_comp<MoveOnly>> C;
+ C c1, c2;
+ static_assert(!noexcept(swap(c1, c2)), "");
+ }
+
+#if TEST_STD_VER >= 14
+ { // POCS allocator, throwable swap for comp
+ typedef std::set<MoveOnly, some_comp <MoveOnly>, some_alloc <MoveOnly>> C;
+ C c1, c2;
+ static_assert(!noexcept(swap(c1, c2)), "");
+ }
+ { // always equal allocator, throwable swap for comp
+ typedef std::set<MoveOnly, some_comp <MoveOnly>, some_alloc2<MoveOnly>> C;
+ C c1, c2;
+ static_assert(!noexcept(swap(c1, c2)), "");
+ }
+ { // POCS allocator, nothrow swap for comp
+ typedef std::set<MoveOnly, some_comp2<MoveOnly>, some_alloc <MoveOnly>> C;
+ C c1, c2;
+ static_assert( noexcept(swap(c1, c2)), "");
+ }
+ { // always equal allocator, nothrow swap for comp
+ typedef std::set<MoveOnly, some_comp2<MoveOnly>, some_alloc2<MoveOnly>> C;
+ C c1, c2;
+ static_assert( noexcept(swap(c1, c2)), "");
+ }
+
+ { // NOT always equal allocator, nothrow swap for comp
+ typedef std::set<MoveOnly, some_comp2<MoveOnly>, some_alloc3<MoveOnly>> C;
+ C c1, c2;
+ static_assert( noexcept(swap(c1, c2)), "");
+ }
+#endif
+
+#endif
+}
diff --git a/test/std/containers/associative/set/size.pass.cpp b/test/std/containers/associative/set/size.pass.cpp
new file mode 100644
index 000000000000..e78654735508
--- /dev/null
+++ b/test/std/containers/associative/set/size.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// size_type size() const;
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::set<int> M;
+ M m;
+ assert(m.size() == 0);
+ m.insert(M::value_type(2));
+ assert(m.size() == 1);
+ m.insert(M::value_type(1));
+ assert(m.size() == 2);
+ m.insert(M::value_type(3));
+ assert(m.size() == 3);
+ m.erase(m.begin());
+ assert(m.size() == 2);
+ m.erase(m.begin());
+ assert(m.size() == 1);
+ m.erase(m.begin());
+ assert(m.size() == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::set<int, std::less<int>, min_allocator<int>> M;
+ M m;
+ assert(m.size() == 0);
+ m.insert(M::value_type(2));
+ assert(m.size() == 1);
+ m.insert(M::value_type(1));
+ assert(m.size() == 2);
+ m.insert(M::value_type(3));
+ assert(m.size() == 3);
+ m.erase(m.begin());
+ assert(m.size() == 2);
+ m.erase(m.begin());
+ assert(m.size() == 1);
+ m.erase(m.begin());
+ assert(m.size() == 0);
+ }
+#endif
+}
diff --git a/test/std/containers/associative/set/types.pass.cpp b/test/std/containers/associative/set/types.pass.cpp
new file mode 100644
index 000000000000..3362c42aee42
--- /dev/null
+++ b/test/std/containers/associative/set/types.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// template <class Key, class Compare = less<Key>,
+// class Allocator = allocator<Key>>
+// class set
+// {
+// public:
+// // types:
+// typedef Key key_type;
+// typedef key_type value_type;
+// typedef Compare key_compare;
+// typedef key_compare value_compare;
+// typedef Allocator allocator_type;
+// typedef typename allocator_type::reference reference;
+// typedef typename allocator_type::const_reference const_reference;
+// typedef typename allocator_type::pointer pointer;
+// typedef typename allocator_type::const_pointer const_pointer;
+// typedef typename allocator_type::size_type size_type;
+// typedef typename allocator_type::difference_type difference_type;
+// ...
+// };
+
+#include <set>
+#include <type_traits>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::set<int> C;
+ static_assert((std::is_same<C::key_type, int>::value), "");
+ static_assert((std::is_same<C::value_type, int>::value), "");
+ static_assert((std::is_same<C::key_compare, std::less<int> >::value), "");
+ static_assert((std::is_same<C::value_compare, std::less<int> >::value), "");
+ static_assert((std::is_same<C::allocator_type, std::allocator<int> >::value), "");
+ static_assert((std::is_same<C::reference, int&>::value), "");
+ static_assert((std::is_same<C::const_reference, const int&>::value), "");
+ static_assert((std::is_same<C::pointer, int*>::value), "");
+ static_assert((std::is_same<C::const_pointer, const int*>::value), "");
+ static_assert((std::is_same<C::size_type, std::size_t>::value), "");
+ static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::set<int, std::less<int>, min_allocator<int>> C;
+ static_assert((std::is_same<C::key_type, int>::value), "");
+ static_assert((std::is_same<C::value_type, int>::value), "");
+ static_assert((std::is_same<C::key_compare, std::less<int> >::value), "");
+ static_assert((std::is_same<C::value_compare, std::less<int> >::value), "");
+ static_assert((std::is_same<C::allocator_type, min_allocator<int> >::value), "");
+ static_assert((std::is_same<C::reference, int&>::value), "");
+ static_assert((std::is_same<C::const_reference, const int&>::value), "");
+ static_assert((std::is_same<C::pointer, min_pointer<int>>::value), "");
+ static_assert((std::is_same<C::const_pointer, min_pointer<const int>>::value), "");
+// min_allocator doesn't have a size_type, so one gets synthesized
+ static_assert((std::is_same<C::size_type, std::make_unsigned<C::difference_type>::type>::value), "");
+ static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
+ }
+#endif
+}
diff --git a/test/std/containers/associative/set/upper_bound.pass.cpp b/test/std/containers/associative/set/upper_bound.pass.cpp
new file mode 100644
index 000000000000..10a28f064698
--- /dev/null
+++ b/test/std/containers/associative/set/upper_bound.pass.cpp
@@ -0,0 +1,336 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// iterator upper_bound(const key_type& k);
+// const_iterator upper_bound(const key_type& k) const;
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "private_constructor.hpp"
+
+int main()
+{
+ {
+ typedef int V;
+ typedef std::set<int> M;
+ {
+ typedef M::iterator R;
+ V ar[] =
+ {
+ 5,
+ 7,
+ 9,
+ 11,
+ 13,
+ 15,
+ 17,
+ 19
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.upper_bound(5);
+ assert(r == next(m.begin(), 1));
+ r = m.upper_bound(7);
+ assert(r == next(m.begin(), 2));
+ r = m.upper_bound(9);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(11);
+ assert(r == next(m.begin(), 4));
+ r = m.upper_bound(13);
+ assert(r == next(m.begin(), 5));
+ r = m.upper_bound(15);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(17);
+ assert(r == next(m.begin(), 7));
+ r = m.upper_bound(19);
+ assert(r == next(m.begin(), 8));
+ r = m.upper_bound(4);
+ assert(r == next(m.begin(), 0));
+ r = m.upper_bound(6);
+ assert(r == next(m.begin(), 1));
+ r = m.upper_bound(8);
+ assert(r == next(m.begin(), 2));
+ r = m.upper_bound(10);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(12);
+ assert(r == next(m.begin(), 4));
+ r = m.upper_bound(14);
+ assert(r == next(m.begin(), 5));
+ r = m.upper_bound(16);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(18);
+ assert(r == next(m.begin(), 7));
+ r = m.upper_bound(20);
+ assert(r == next(m.begin(), 8));
+ }
+ {
+ typedef M::const_iterator R;
+ V ar[] =
+ {
+ 5,
+ 7,
+ 9,
+ 11,
+ 13,
+ 15,
+ 17,
+ 19
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.upper_bound(5);
+ assert(r == next(m.begin(), 1));
+ r = m.upper_bound(7);
+ assert(r == next(m.begin(), 2));
+ r = m.upper_bound(9);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(11);
+ assert(r == next(m.begin(), 4));
+ r = m.upper_bound(13);
+ assert(r == next(m.begin(), 5));
+ r = m.upper_bound(15);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(17);
+ assert(r == next(m.begin(), 7));
+ r = m.upper_bound(19);
+ assert(r == next(m.begin(), 8));
+ r = m.upper_bound(4);
+ assert(r == next(m.begin(), 0));
+ r = m.upper_bound(6);
+ assert(r == next(m.begin(), 1));
+ r = m.upper_bound(8);
+ assert(r == next(m.begin(), 2));
+ r = m.upper_bound(10);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(12);
+ assert(r == next(m.begin(), 4));
+ r = m.upper_bound(14);
+ assert(r == next(m.begin(), 5));
+ r = m.upper_bound(16);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(18);
+ assert(r == next(m.begin(), 7));
+ r = m.upper_bound(20);
+ assert(r == next(m.begin(), 8));
+ }
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int V;
+ typedef std::set<int, std::less<int>, min_allocator<int>> M;
+ {
+ typedef M::iterator R;
+ V ar[] =
+ {
+ 5,
+ 7,
+ 9,
+ 11,
+ 13,
+ 15,
+ 17,
+ 19
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.upper_bound(5);
+ assert(r == next(m.begin(), 1));
+ r = m.upper_bound(7);
+ assert(r == next(m.begin(), 2));
+ r = m.upper_bound(9);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(11);
+ assert(r == next(m.begin(), 4));
+ r = m.upper_bound(13);
+ assert(r == next(m.begin(), 5));
+ r = m.upper_bound(15);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(17);
+ assert(r == next(m.begin(), 7));
+ r = m.upper_bound(19);
+ assert(r == next(m.begin(), 8));
+ r = m.upper_bound(4);
+ assert(r == next(m.begin(), 0));
+ r = m.upper_bound(6);
+ assert(r == next(m.begin(), 1));
+ r = m.upper_bound(8);
+ assert(r == next(m.begin(), 2));
+ r = m.upper_bound(10);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(12);
+ assert(r == next(m.begin(), 4));
+ r = m.upper_bound(14);
+ assert(r == next(m.begin(), 5));
+ r = m.upper_bound(16);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(18);
+ assert(r == next(m.begin(), 7));
+ r = m.upper_bound(20);
+ assert(r == next(m.begin(), 8));
+ }
+ {
+ typedef M::const_iterator R;
+ V ar[] =
+ {
+ 5,
+ 7,
+ 9,
+ 11,
+ 13,
+ 15,
+ 17,
+ 19
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.upper_bound(5);
+ assert(r == next(m.begin(), 1));
+ r = m.upper_bound(7);
+ assert(r == next(m.begin(), 2));
+ r = m.upper_bound(9);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(11);
+ assert(r == next(m.begin(), 4));
+ r = m.upper_bound(13);
+ assert(r == next(m.begin(), 5));
+ r = m.upper_bound(15);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(17);
+ assert(r == next(m.begin(), 7));
+ r = m.upper_bound(19);
+ assert(r == next(m.begin(), 8));
+ r = m.upper_bound(4);
+ assert(r == next(m.begin(), 0));
+ r = m.upper_bound(6);
+ assert(r == next(m.begin(), 1));
+ r = m.upper_bound(8);
+ assert(r == next(m.begin(), 2));
+ r = m.upper_bound(10);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(12);
+ assert(r == next(m.begin(), 4));
+ r = m.upper_bound(14);
+ assert(r == next(m.begin(), 5));
+ r = m.upper_bound(16);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(18);
+ assert(r == next(m.begin(), 7));
+ r = m.upper_bound(20);
+ assert(r == next(m.begin(), 8));
+ }
+ }
+#endif
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef int V;
+ typedef std::set<V, std::less<>> M;
+ typedef M::iterator R;
+
+ V ar[] =
+ {
+ 5,
+ 7,
+ 9,
+ 11,
+ 13,
+ 15,
+ 17,
+ 19
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.upper_bound(5);
+ assert(r == next(m.begin(), 1));
+ r = m.upper_bound(7);
+ assert(r == next(m.begin(), 2));
+ r = m.upper_bound(9);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(11);
+ assert(r == next(m.begin(), 4));
+ r = m.upper_bound(13);
+ assert(r == next(m.begin(), 5));
+ r = m.upper_bound(15);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(17);
+ assert(r == next(m.begin(), 7));
+ r = m.upper_bound(19);
+ assert(r == next(m.begin(), 8));
+ r = m.upper_bound(4);
+ assert(r == next(m.begin(), 0));
+ r = m.upper_bound(6);
+ assert(r == next(m.begin(), 1));
+ r = m.upper_bound(8);
+ assert(r == next(m.begin(), 2));
+ r = m.upper_bound(10);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(12);
+ assert(r == next(m.begin(), 4));
+ r = m.upper_bound(14);
+ assert(r == next(m.begin(), 5));
+ r = m.upper_bound(16);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(18);
+ assert(r == next(m.begin(), 7));
+ r = m.upper_bound(20);
+ assert(r == next(m.begin(), 8));
+ }
+
+ {
+ typedef PrivateConstructor V;
+ typedef std::set<V, std::less<>> M;
+ typedef M::iterator R;
+
+ M m;
+ m.insert ( V::make ( 5 ));
+ m.insert ( V::make ( 7 ));
+ m.insert ( V::make ( 9 ));
+ m.insert ( V::make ( 11 ));
+ m.insert ( V::make ( 13 ));
+ m.insert ( V::make ( 15 ));
+ m.insert ( V::make ( 17 ));
+ m.insert ( V::make ( 19 ));
+
+ R r = m.upper_bound(5);
+ assert(r == next(m.begin(), 1));
+ r = m.upper_bound(7);
+ assert(r == next(m.begin(), 2));
+ r = m.upper_bound(9);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(11);
+ assert(r == next(m.begin(), 4));
+ r = m.upper_bound(13);
+ assert(r == next(m.begin(), 5));
+ r = m.upper_bound(15);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(17);
+ assert(r == next(m.begin(), 7));
+ r = m.upper_bound(19);
+ assert(r == next(m.begin(), 8));
+ r = m.upper_bound(4);
+ assert(r == next(m.begin(), 0));
+ r = m.upper_bound(6);
+ assert(r == next(m.begin(), 1));
+ r = m.upper_bound(8);
+ assert(r == next(m.begin(), 2));
+ r = m.upper_bound(10);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(12);
+ assert(r == next(m.begin(), 4));
+ r = m.upper_bound(14);
+ assert(r == next(m.begin(), 5));
+ r = m.upper_bound(16);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(18);
+ assert(r == next(m.begin(), 7));
+ r = m.upper_bound(20);
+ assert(r == next(m.begin(), 8));
+ }
+#endif
+}
diff --git a/test/std/containers/associative/set/version.pass.cpp b/test/std/containers/associative/set/version.pass.cpp
new file mode 100644
index 000000000000..c3c4d926e5c3
--- /dev/null
+++ b/test/std/containers/associative/set/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+#include <set>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/containers/associative/tree_balance_after_insert.pass.cpp b/test/std/containers/associative/tree_balance_after_insert.pass.cpp
new file mode 100644
index 000000000000..b0a3e74cab0a
--- /dev/null
+++ b/test/std/containers/associative/tree_balance_after_insert.pass.cpp
@@ -0,0 +1,1616 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// Not a portable test
+
+// Precondition: __root->__is_black_ == true
+// template <class _NodePtr>
+// void
+// __tree_balance_after_insert(_NodePtr __root, _NodePtr __x)
+
+#include <__tree>
+#include <cassert>
+
+struct Node
+{
+ Node* __left_;
+ Node* __right_;
+ Node* __parent_;
+ bool __is_black_;
+
+ Node() : __left_(), __right_(), __parent_(), __is_black_() {}
+};
+
+void
+test1()
+{
+ {
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+ Node d;
+
+ root.__left_ = &c;
+
+ c.__parent_ = &root;
+ c.__left_ = &b;
+ c.__right_ = &d;
+ c.__is_black_ = true;
+
+ b.__parent_ = &c;
+ b.__left_ = &a;
+ b.__right_ = 0;
+ b.__is_black_ = false;
+
+ d.__parent_ = &c;
+ d.__left_ = 0;
+ d.__right_ = 0;
+ d.__is_black_ = false;
+
+ a.__parent_ = &b;
+ a.__left_ = 0;
+ a.__right_ = 0;
+ a.__is_black_ = false;
+
+ std::__tree_balance_after_insert(root.__left_, &a);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__left_ == &c);
+
+ assert(c.__parent_ == &root);
+ assert(c.__left_ == &b);
+ assert(c.__right_ == &d);
+ assert(c.__is_black_ == true);
+
+ assert(b.__parent_ == &c);
+ assert(b.__left_ == &a);
+ assert(b.__right_ == 0);
+ assert(b.__is_black_ == true);
+
+ assert(d.__parent_ == &c);
+ assert(d.__left_ == 0);
+ assert(d.__right_ == 0);
+ assert(d.__is_black_ == true);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == false);
+ }
+ {
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+ Node d;
+
+ root.__left_ = &c;
+
+ c.__parent_ = &root;
+ c.__left_ = &b;
+ c.__right_ = &d;
+ c.__is_black_ = true;
+
+ b.__parent_ = &c;
+ b.__left_ = 0;
+ b.__right_ = &a;
+ b.__is_black_ = false;
+
+ d.__parent_ = &c;
+ d.__left_ = 0;
+ d.__right_ = 0;
+ d.__is_black_ = false;
+
+ a.__parent_ = &b;
+ a.__left_ = 0;
+ a.__right_ = 0;
+ a.__is_black_ = false;
+
+ std::__tree_balance_after_insert(root.__left_, &a);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__left_ == &c);
+
+ assert(c.__parent_ == &root);
+ assert(c.__left_ == &b);
+ assert(c.__right_ == &d);
+ assert(c.__is_black_ == true);
+
+ assert(b.__parent_ == &c);
+ assert(b.__left_ == 0);
+ assert(b.__right_ == &a);
+ assert(b.__is_black_ == true);
+
+ assert(d.__parent_ == &c);
+ assert(d.__left_ == 0);
+ assert(d.__right_ == 0);
+ assert(d.__is_black_ == true);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == false);
+ }
+ {
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+ Node d;
+
+ root.__left_ = &c;
+
+ c.__parent_ = &root;
+ c.__left_ = &b;
+ c.__right_ = &d;
+ c.__is_black_ = true;
+
+ b.__parent_ = &c;
+ b.__left_ = 0;
+ b.__right_ = 0;
+ b.__is_black_ = false;
+
+ d.__parent_ = &c;
+ d.__left_ = &a;
+ d.__right_ = 0;
+ d.__is_black_ = false;
+
+ a.__parent_ = &d;
+ a.__left_ = 0;
+ a.__right_ = 0;
+ a.__is_black_ = false;
+
+ std::__tree_balance_after_insert(root.__left_, &a);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__left_ == &c);
+
+ assert(c.__parent_ == &root);
+ assert(c.__left_ == &b);
+ assert(c.__right_ == &d);
+ assert(c.__is_black_ == true);
+
+ assert(b.__parent_ == &c);
+ assert(b.__left_ == 0);
+ assert(b.__right_ == 0);
+ assert(b.__is_black_ == true);
+
+ assert(d.__parent_ == &c);
+ assert(d.__left_ == &a);
+ assert(d.__right_ == 0);
+ assert(d.__is_black_ == true);
+
+ assert(a.__parent_ == &d);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == false);
+ }
+ {
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+ Node d;
+
+ root.__left_ = &c;
+
+ c.__parent_ = &root;
+ c.__left_ = &b;
+ c.__right_ = &d;
+ c.__is_black_ = true;
+
+ b.__parent_ = &c;
+ b.__left_ = 0;
+ b.__right_ = 0;
+ b.__is_black_ = false;
+
+ d.__parent_ = &c;
+ d.__left_ = 0;
+ d.__right_ = &a;
+ d.__is_black_ = false;
+
+ a.__parent_ = &d;
+ a.__left_ = 0;
+ a.__right_ = 0;
+ a.__is_black_ = false;
+
+ std::__tree_balance_after_insert(root.__left_, &a);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__left_ == &c);
+
+ assert(c.__parent_ == &root);
+ assert(c.__left_ == &b);
+ assert(c.__right_ == &d);
+ assert(c.__is_black_ == true);
+
+ assert(b.__parent_ == &c);
+ assert(b.__left_ == 0);
+ assert(b.__right_ == 0);
+ assert(b.__is_black_ == true);
+
+ assert(d.__parent_ == &c);
+ assert(d.__left_ == 0);
+ assert(d.__right_ == &a);
+ assert(d.__is_black_ == true);
+
+ assert(a.__parent_ == &d);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == false);
+ }
+ {
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+ Node d;
+ Node e;
+ Node f;
+ Node g;
+ Node h;
+ Node i;
+
+ root.__left_ = &c;
+
+ c.__parent_ = &root;
+ c.__left_ = &b;
+ c.__right_ = &d;
+ c.__is_black_ = true;
+
+ b.__parent_ = &c;
+ b.__left_ = &a;
+ b.__right_ = &g;
+ b.__is_black_ = false;
+
+ d.__parent_ = &c;
+ d.__left_ = &h;
+ d.__right_ = &i;
+ d.__is_black_ = false;
+
+ a.__parent_ = &b;
+ a.__left_ = &e;
+ a.__right_ = &f;
+ a.__is_black_ = false;
+
+ e.__parent_ = &a;
+ e.__is_black_ = true;
+
+ f.__parent_ = &a;
+ f.__is_black_ = true;
+
+ g.__parent_ = &b;
+ g.__is_black_ = true;
+
+ h.__parent_ = &d;
+ h.__is_black_ = true;
+
+ i.__parent_ = &d;
+ i.__is_black_ = true;
+
+ std::__tree_balance_after_insert(root.__left_, &a);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__left_ == &c);
+
+ assert(c.__parent_ == &root);
+ assert(c.__left_ == &b);
+ assert(c.__right_ == &d);
+ assert(c.__is_black_ == true);
+
+ assert(b.__parent_ == &c);
+ assert(b.__left_ == &a);
+ assert(b.__right_ == &g);
+ assert(b.__is_black_ == true);
+
+ assert(d.__parent_ == &c);
+ assert(d.__left_ == &h);
+ assert(d.__right_ == &i);
+ assert(d.__is_black_ == true);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == &e);
+ assert(a.__right_ == &f);
+ assert(a.__is_black_ == false);
+ }
+ {
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+ Node d;
+ Node e;
+ Node f;
+ Node g;
+ Node h;
+ Node i;
+
+ root.__left_ = &c;
+
+ c.__parent_ = &root;
+ c.__left_ = &b;
+ c.__right_ = &d;
+ c.__is_black_ = true;
+
+ b.__parent_ = &c;
+ b.__left_ = &g;
+ b.__right_ = &a;
+ b.__is_black_ = false;
+
+ d.__parent_ = &c;
+ d.__left_ = &h;
+ d.__right_ = &i;
+ d.__is_black_ = false;
+
+ a.__parent_ = &b;
+ a.__left_ = &e;
+ a.__right_ = &f;
+ a.__is_black_ = false;
+
+ e.__parent_ = &a;
+ e.__is_black_ = true;
+
+ f.__parent_ = &a;
+ f.__is_black_ = true;
+
+ g.__parent_ = &b;
+ g.__is_black_ = true;
+
+ h.__parent_ = &d;
+ h.__is_black_ = true;
+
+ i.__parent_ = &d;
+ i.__is_black_ = true;
+
+ std::__tree_balance_after_insert(root.__left_, &a);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__left_ == &c);
+
+ assert(c.__parent_ == &root);
+ assert(c.__left_ == &b);
+ assert(c.__right_ == &d);
+ assert(c.__is_black_ == true);
+
+ assert(b.__parent_ == &c);
+ assert(b.__left_ == &g);
+ assert(b.__right_ == &a);
+ assert(b.__is_black_ == true);
+
+ assert(d.__parent_ == &c);
+ assert(d.__left_ == &h);
+ assert(d.__right_ == &i);
+ assert(d.__is_black_ == true);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == &e);
+ assert(a.__right_ == &f);
+ assert(a.__is_black_ == false);
+ }
+ {
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+ Node d;
+ Node e;
+ Node f;
+ Node g;
+ Node h;
+ Node i;
+
+ root.__left_ = &c;
+
+ c.__parent_ = &root;
+ c.__left_ = &b;
+ c.__right_ = &d;
+ c.__is_black_ = true;
+
+ b.__parent_ = &c;
+ b.__left_ = &g;
+ b.__right_ = &h;
+ b.__is_black_ = false;
+
+ d.__parent_ = &c;
+ d.__left_ = &a;
+ d.__right_ = &i;
+ d.__is_black_ = false;
+
+ a.__parent_ = &d;
+ a.__left_ = &e;
+ a.__right_ = &f;
+ a.__is_black_ = false;
+
+ e.__parent_ = &a;
+ e.__is_black_ = true;
+
+ f.__parent_ = &a;
+ f.__is_black_ = true;
+
+ g.__parent_ = &b;
+ g.__is_black_ = true;
+
+ h.__parent_ = &b;
+ h.__is_black_ = true;
+
+ i.__parent_ = &d;
+ i.__is_black_ = true;
+
+ std::__tree_balance_after_insert(root.__left_, &a);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__left_ == &c);
+
+ assert(c.__parent_ == &root);
+ assert(c.__left_ == &b);
+ assert(c.__right_ == &d);
+ assert(c.__is_black_ == true);
+
+ assert(b.__parent_ == &c);
+ assert(b.__left_ == &g);
+ assert(b.__right_ == &h);
+ assert(b.__is_black_ == true);
+
+ assert(d.__parent_ == &c);
+ assert(d.__left_ == &a);
+ assert(d.__right_ == &i);
+ assert(d.__is_black_ == true);
+
+ assert(a.__parent_ == &d);
+ assert(a.__left_ == &e);
+ assert(a.__right_ == &f);
+ assert(a.__is_black_ == false);
+ }
+ {
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+ Node d;
+ Node e;
+ Node f;
+ Node g;
+ Node h;
+ Node i;
+
+ root.__left_ = &c;
+
+ c.__parent_ = &root;
+ c.__left_ = &b;
+ c.__right_ = &d;
+ c.__is_black_ = true;
+
+ b.__parent_ = &c;
+ b.__left_ = &g;
+ b.__right_ = &h;
+ b.__is_black_ = false;
+
+ d.__parent_ = &c;
+ d.__left_ = &i;
+ d.__right_ = &a;
+ d.__is_black_ = false;
+
+ a.__parent_ = &d;
+ a.__left_ = &e;
+ a.__right_ = &f;
+ a.__is_black_ = false;
+
+ e.__parent_ = &a;
+ e.__is_black_ = true;
+
+ f.__parent_ = &a;
+ f.__is_black_ = true;
+
+ g.__parent_ = &b;
+ g.__is_black_ = true;
+
+ h.__parent_ = &b;
+ h.__is_black_ = true;
+
+ i.__parent_ = &d;
+ i.__is_black_ = true;
+
+ std::__tree_balance_after_insert(root.__left_, &a);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__left_ == &c);
+
+ assert(c.__parent_ == &root);
+ assert(c.__left_ == &b);
+ assert(c.__right_ == &d);
+ assert(c.__is_black_ == true);
+
+ assert(b.__parent_ == &c);
+ assert(b.__left_ == &g);
+ assert(b.__right_ == &h);
+ assert(b.__is_black_ == true);
+
+ assert(d.__parent_ == &c);
+ assert(d.__left_ == &i);
+ assert(d.__right_ == &a);
+ assert(d.__is_black_ == true);
+
+ assert(a.__parent_ == &d);
+ assert(a.__left_ == &e);
+ assert(a.__right_ == &f);
+ assert(a.__is_black_ == false);
+ }
+}
+
+void
+test2()
+{
+ {
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+
+ root.__left_ = &c;
+
+ c.__parent_ = &root;
+ c.__left_ = &a;
+ c.__right_ = 0;
+ c.__is_black_ = true;
+
+ a.__parent_ = &c;
+ a.__left_ = 0;
+ a.__right_ = &b;
+ a.__is_black_ = false;
+
+ b.__parent_ = &a;
+ b.__left_ = 0;
+ b.__right_ = 0;
+ b.__is_black_ = false;
+
+ std::__tree_balance_after_insert(root.__left_, &b);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__left_ == &b);
+
+ assert(c.__parent_ == &b);
+ assert(c.__left_ == 0);
+ assert(c.__right_ == 0);
+ assert(c.__is_black_ == false);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == false);
+
+ assert(b.__parent_ == &root);
+ assert(b.__left_ == &a);
+ assert(b.__right_ == &c);
+ assert(b.__is_black_ == true);
+ }
+ {
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+
+ root.__left_ = &a;
+
+ a.__parent_ = &root;
+ a.__left_ = 0;
+ a.__right_ = &c;
+ a.__is_black_ = true;
+
+ c.__parent_ = &a;
+ c.__left_ = &b;
+ c.__right_ = 0;
+ c.__is_black_ = false;
+
+ b.__parent_ = &c;
+ b.__left_ = 0;
+ b.__right_ = 0;
+ b.__is_black_ = false;
+
+ std::__tree_balance_after_insert(root.__left_, &b);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__left_ == &b);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == false);
+
+ assert(c.__parent_ == &b);
+ assert(c.__left_ == 0);
+ assert(c.__right_ == 0);
+ assert(c.__is_black_ == false);
+
+ assert(b.__parent_ == &root);
+ assert(b.__left_ == &a);
+ assert(b.__right_ == &c);
+ assert(b.__is_black_ == true);
+ }
+ {
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+ Node d;
+ Node e;
+ Node f;
+ Node g;
+
+ root.__left_ = &c;
+
+ c.__parent_ = &root;
+ c.__left_ = &a;
+ c.__right_ = &g;
+ c.__is_black_ = true;
+
+ a.__parent_ = &c;
+ a.__left_ = &d;
+ a.__right_ = &b;
+ a.__is_black_ = false;
+
+ b.__parent_ = &a;
+ b.__left_ = &e;
+ b.__right_ = &f;
+ b.__is_black_ = false;
+
+ d.__parent_ = &a;
+ d.__is_black_ = true;
+
+ e.__parent_ = &b;
+ e.__is_black_ = true;
+
+ f.__parent_ = &b;
+ f.__is_black_ = true;
+
+ g.__parent_ = &c;
+ g.__is_black_ = true;
+
+ std::__tree_balance_after_insert(root.__left_, &b);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__left_ == &b);
+
+ assert(c.__parent_ == &b);
+ assert(c.__left_ == &f);
+ assert(c.__right_ == &g);
+ assert(c.__is_black_ == false);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == &d);
+ assert(a.__right_ == &e);
+ assert(a.__is_black_ == false);
+
+ assert(b.__parent_ == &root);
+ assert(b.__left_ == &a);
+ assert(b.__right_ == &c);
+ assert(b.__is_black_ == true);
+
+ assert(d.__parent_ == &a);
+ assert(d.__is_black_ == true);
+
+ assert(e.__parent_ == &a);
+ assert(e.__is_black_ == true);
+
+ assert(f.__parent_ == &c);
+ assert(f.__is_black_ == true);
+
+ assert(g.__parent_ == &c);
+ assert(g.__is_black_ == true);
+ }
+ {
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+ Node d;
+ Node e;
+ Node f;
+ Node g;
+
+ root.__left_ = &a;
+
+ a.__parent_ = &root;
+ a.__left_ = &d;
+ a.__right_ = &c;
+ a.__is_black_ = true;
+
+ c.__parent_ = &a;
+ c.__left_ = &b;
+ c.__right_ = &g;
+ c.__is_black_ = false;
+
+ b.__parent_ = &c;
+ b.__left_ = &e;
+ b.__right_ = &f;
+ b.__is_black_ = false;
+
+ d.__parent_ = &a;
+ d.__is_black_ = true;
+
+ e.__parent_ = &b;
+ e.__is_black_ = true;
+
+ f.__parent_ = &b;
+ f.__is_black_ = true;
+
+ g.__parent_ = &c;
+ g.__is_black_ = true;
+
+ std::__tree_balance_after_insert(root.__left_, &b);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__left_ == &b);
+
+ assert(c.__parent_ == &b);
+ assert(c.__left_ == &f);
+ assert(c.__right_ == &g);
+ assert(c.__is_black_ == false);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == &d);
+ assert(a.__right_ == &e);
+ assert(a.__is_black_ == false);
+
+ assert(b.__parent_ == &root);
+ assert(b.__left_ == &a);
+ assert(b.__right_ == &c);
+ assert(b.__is_black_ == true);
+
+ assert(d.__parent_ == &a);
+ assert(d.__is_black_ == true);
+
+ assert(e.__parent_ == &a);
+ assert(e.__is_black_ == true);
+
+ assert(f.__parent_ == &c);
+ assert(f.__is_black_ == true);
+
+ assert(g.__parent_ == &c);
+ assert(g.__is_black_ == true);
+ }
+}
+
+void
+test3()
+{
+ {
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+
+ root.__left_ = &c;
+
+ c.__parent_ = &root;
+ c.__left_ = &b;
+ c.__right_ = 0;
+ c.__is_black_ = true;
+
+ b.__parent_ = &c;
+ b.__left_ = &a;
+ b.__right_ = 0;
+ b.__is_black_ = false;
+
+ a.__parent_ = &b;
+ a.__left_ = 0;
+ a.__right_ = 0;
+ a.__is_black_ = false;
+
+ std::__tree_balance_after_insert(root.__left_, &a);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__left_ == &b);
+
+ assert(c.__parent_ == &b);
+ assert(c.__left_ == 0);
+ assert(c.__right_ == 0);
+ assert(c.__is_black_ == false);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == false);
+
+ assert(b.__parent_ == &root);
+ assert(b.__left_ == &a);
+ assert(b.__right_ == &c);
+ assert(b.__is_black_ == true);
+ }
+ {
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+
+ root.__left_ = &a;
+
+ a.__parent_ = &root;
+ a.__left_ = 0;
+ a.__right_ = &b;
+ a.__is_black_ = true;
+
+ b.__parent_ = &a;
+ b.__left_ = 0;
+ b.__right_ = &c;
+ b.__is_black_ = false;
+
+ c.__parent_ = &b;
+ c.__left_ = 0;
+ c.__right_ = 0;
+ c.__is_black_ = false;
+
+ std::__tree_balance_after_insert(root.__left_, &c);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__left_ == &b);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == false);
+
+ assert(c.__parent_ == &b);
+ assert(c.__left_ == 0);
+ assert(c.__right_ == 0);
+ assert(c.__is_black_ == false);
+
+ assert(b.__parent_ == &root);
+ assert(b.__left_ == &a);
+ assert(b.__right_ == &c);
+ assert(b.__is_black_ == true);
+ }
+ {
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+ Node d;
+ Node e;
+ Node f;
+ Node g;
+
+ root.__left_ = &c;
+
+ c.__parent_ = &root;
+ c.__left_ = &b;
+ c.__right_ = &g;
+ c.__is_black_ = true;
+
+ b.__parent_ = &c;
+ b.__left_ = &a;
+ b.__right_ = &f;
+ b.__is_black_ = false;
+
+ a.__parent_ = &b;
+ a.__left_ = &d;
+ a.__right_ = &e;
+ a.__is_black_ = false;
+
+ d.__parent_ = &a;
+ d.__is_black_ = true;
+
+ e.__parent_ = &a;
+ e.__is_black_ = true;
+
+ f.__parent_ = &b;
+ f.__is_black_ = true;
+
+ g.__parent_ = &c;
+ g.__is_black_ = true;
+
+ std::__tree_balance_after_insert(root.__left_, &a);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__left_ == &b);
+
+ assert(c.__parent_ == &b);
+ assert(c.__left_ == &f);
+ assert(c.__right_ == &g);
+ assert(c.__is_black_ == false);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == &d);
+ assert(a.__right_ == &e);
+ assert(a.__is_black_ == false);
+
+ assert(b.__parent_ == &root);
+ assert(b.__left_ == &a);
+ assert(b.__right_ == &c);
+ assert(b.__is_black_ == true);
+
+ assert(d.__parent_ == &a);
+ assert(d.__is_black_ == true);
+
+ assert(e.__parent_ == &a);
+ assert(e.__is_black_ == true);
+
+ assert(f.__parent_ == &c);
+ assert(f.__is_black_ == true);
+
+ assert(g.__parent_ == &c);
+ assert(g.__is_black_ == true);
+ }
+ {
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+ Node d;
+ Node e;
+ Node f;
+ Node g;
+
+ root.__left_ = &a;
+
+ a.__parent_ = &root;
+ a.__left_ = &d;
+ a.__right_ = &b;
+ a.__is_black_ = true;
+
+ b.__parent_ = &a;
+ b.__left_ = &e;
+ b.__right_ = &c;
+ b.__is_black_ = false;
+
+ c.__parent_ = &b;
+ c.__left_ = &f;
+ c.__right_ = &g;
+ c.__is_black_ = false;
+
+ d.__parent_ = &a;
+ d.__is_black_ = true;
+
+ e.__parent_ = &b;
+ e.__is_black_ = true;
+
+ f.__parent_ = &c;
+ f.__is_black_ = true;
+
+ g.__parent_ = &c;
+ g.__is_black_ = true;
+
+ std::__tree_balance_after_insert(root.__left_, &c);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__left_ == &b);
+
+ assert(c.__parent_ == &b);
+ assert(c.__left_ == &f);
+ assert(c.__right_ == &g);
+ assert(c.__is_black_ == false);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == &d);
+ assert(a.__right_ == &e);
+ assert(a.__is_black_ == false);
+
+ assert(b.__parent_ == &root);
+ assert(b.__left_ == &a);
+ assert(b.__right_ == &c);
+ assert(b.__is_black_ == true);
+
+ assert(d.__parent_ == &a);
+ assert(d.__is_black_ == true);
+
+ assert(e.__parent_ == &a);
+ assert(e.__is_black_ == true);
+
+ assert(f.__parent_ == &c);
+ assert(f.__is_black_ == true);
+
+ assert(g.__parent_ == &c);
+ assert(g.__is_black_ == true);
+ }
+}
+
+void
+test4()
+{
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+ Node d;
+ Node e;
+ Node f;
+ Node g;
+ Node h;
+
+ root.__left_ = &a;
+ a.__parent_ = &root;
+
+ std::__tree_balance_after_insert(root.__left_, &a);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &a);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(a.__parent_ == &root);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == true);
+
+ a.__right_ = &b;
+ b.__parent_ = &a;
+
+ std::__tree_balance_after_insert(root.__left_, &b);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &a);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(a.__parent_ == &root);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == &b);
+ assert(a.__is_black_ == true);
+
+ assert(b.__parent_ == &a);
+ assert(b.__left_ == 0);
+ assert(b.__right_ == 0);
+ assert(b.__is_black_ == false);
+
+ b.__right_ = &c;
+ c.__parent_ = &b;
+
+ std::__tree_balance_after_insert(root.__left_, &c);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &b);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == false);
+
+ assert(b.__parent_ == &root);
+ assert(b.__left_ == &a);
+ assert(b.__right_ == &c);
+ assert(b.__is_black_ == true);
+
+ assert(c.__parent_ == &b);
+ assert(c.__left_ == 0);
+ assert(c.__right_ == 0);
+ assert(c.__is_black_ == false);
+
+ c.__right_ = &d;
+ d.__parent_ = &c;
+
+ std::__tree_balance_after_insert(root.__left_, &d);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &b);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == true);
+
+ assert(b.__parent_ == &root);
+ assert(b.__left_ == &a);
+ assert(b.__right_ == &c);
+ assert(b.__is_black_ == true);
+
+ assert(c.__parent_ == &b);
+ assert(c.__left_ == 0);
+ assert(c.__right_ == &d);
+ assert(c.__is_black_ == true);
+
+ assert(d.__parent_ == &c);
+ assert(d.__left_ == 0);
+ assert(d.__right_ == 0);
+ assert(d.__is_black_ == false);
+
+ d.__right_ = &e;
+ e.__parent_ = &d;
+
+ std::__tree_balance_after_insert(root.__left_, &e);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &b);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(b.__parent_ == &root);
+ assert(b.__left_ == &a);
+ assert(b.__right_ == &d);
+ assert(b.__is_black_ == true);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == true);
+
+ assert(d.__parent_ == &b);
+ assert(d.__left_ == &c);
+ assert(d.__right_ == &e);
+ assert(d.__is_black_ == true);
+
+ assert(c.__parent_ == &d);
+ assert(c.__left_ == 0);
+ assert(c.__right_ == 0);
+ assert(c.__is_black_ == false);
+
+ assert(e.__parent_ == &d);
+ assert(e.__left_ == 0);
+ assert(e.__right_ == 0);
+ assert(e.__is_black_ == false);
+
+ e.__right_ = &f;
+ f.__parent_ = &e;
+
+ std::__tree_balance_after_insert(root.__left_, &f);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &b);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(b.__parent_ == &root);
+ assert(b.__left_ == &a);
+ assert(b.__right_ == &d);
+ assert(b.__is_black_ == true);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == true);
+
+ assert(d.__parent_ == &b);
+ assert(d.__left_ == &c);
+ assert(d.__right_ == &e);
+ assert(d.__is_black_ == false);
+
+ assert(c.__parent_ == &d);
+ assert(c.__left_ == 0);
+ assert(c.__right_ == 0);
+ assert(c.__is_black_ == true);
+
+ assert(e.__parent_ == &d);
+ assert(e.__left_ == 0);
+ assert(e.__right_ == &f);
+ assert(e.__is_black_ == true);
+
+ assert(f.__parent_ == &e);
+ assert(f.__left_ == 0);
+ assert(f.__right_ == 0);
+ assert(f.__is_black_ == false);
+
+ f.__right_ = &g;
+ g.__parent_ = &f;
+
+ std::__tree_balance_after_insert(root.__left_, &g);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &b);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(b.__parent_ == &root);
+ assert(b.__left_ == &a);
+ assert(b.__right_ == &d);
+ assert(b.__is_black_ == true);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == true);
+
+ assert(d.__parent_ == &b);
+ assert(d.__left_ == &c);
+ assert(d.__right_ == &f);
+ assert(d.__is_black_ == false);
+
+ assert(c.__parent_ == &d);
+ assert(c.__left_ == 0);
+ assert(c.__right_ == 0);
+ assert(c.__is_black_ == true);
+
+ assert(f.__parent_ == &d);
+ assert(f.__left_ == &e);
+ assert(f.__right_ == &g);
+ assert(f.__is_black_ == true);
+
+ assert(e.__parent_ == &f);
+ assert(e.__left_ == 0);
+ assert(e.__right_ == 0);
+ assert(e.__is_black_ == false);
+
+ assert(g.__parent_ == &f);
+ assert(g.__left_ == 0);
+ assert(g.__right_ == 0);
+ assert(g.__is_black_ == false);
+
+ g.__right_ = &h;
+ h.__parent_ = &g;
+
+ std::__tree_balance_after_insert(root.__left_, &h);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &d);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(d.__parent_ == &root);
+ assert(d.__left_ == &b);
+ assert(d.__right_ == &f);
+ assert(d.__is_black_ == true);
+
+ assert(b.__parent_ == &d);
+ assert(b.__left_ == &a);
+ assert(b.__right_ == &c);
+ assert(b.__is_black_ == false);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == true);
+
+ assert(c.__parent_ == &b);
+ assert(c.__left_ == 0);
+ assert(c.__right_ == 0);
+ assert(c.__is_black_ == true);
+
+ assert(f.__parent_ == &d);
+ assert(f.__left_ == &e);
+ assert(f.__right_ == &g);
+ assert(f.__is_black_ == false);
+
+ assert(e.__parent_ == &f);
+ assert(e.__left_ == 0);
+ assert(e.__right_ == 0);
+ assert(e.__is_black_ == true);
+
+ assert(g.__parent_ == &f);
+ assert(g.__left_ == 0);
+ assert(g.__right_ == &h);
+ assert(g.__is_black_ == true);
+
+ assert(h.__parent_ == &g);
+ assert(h.__left_ == 0);
+ assert(h.__right_ == 0);
+ assert(h.__is_black_ == false);
+}
+
+void
+test5()
+{
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+ Node d;
+ Node e;
+ Node f;
+ Node g;
+ Node h;
+
+ root.__left_ = &h;
+ h.__parent_ = &root;
+
+ std::__tree_balance_after_insert(root.__left_, &h);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &h);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(h.__parent_ == &root);
+ assert(h.__left_ == 0);
+ assert(h.__right_ == 0);
+ assert(h.__is_black_ == true);
+
+ h.__left_ = &g;
+ g.__parent_ = &h;
+
+ std::__tree_balance_after_insert(root.__left_, &g);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &h);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(h.__parent_ == &root);
+ assert(h.__left_ == &g);
+ assert(h.__right_ == 0);
+ assert(h.__is_black_ == true);
+
+ assert(g.__parent_ == &h);
+ assert(g.__left_ == 0);
+ assert(g.__right_ == 0);
+ assert(g.__is_black_ == false);
+
+ g.__left_ = &f;
+ f.__parent_ = &g;
+
+ std::__tree_balance_after_insert(root.__left_, &f);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &g);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(g.__parent_ == &root);
+ assert(g.__left_ == &f);
+ assert(g.__right_ == &h);
+ assert(g.__is_black_ == true);
+
+ assert(f.__parent_ == &g);
+ assert(f.__left_ == 0);
+ assert(f.__right_ == 0);
+ assert(f.__is_black_ == false);
+
+ assert(h.__parent_ == &g);
+ assert(h.__left_ == 0);
+ assert(h.__right_ == 0);
+ assert(h.__is_black_ == false);
+
+ f.__left_ = &e;
+ e.__parent_ = &f;
+
+ std::__tree_balance_after_insert(root.__left_, &e);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &g);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(g.__parent_ == &root);
+ assert(g.__left_ == &f);
+ assert(g.__right_ == &h);
+ assert(g.__is_black_ == true);
+
+ assert(f.__parent_ == &g);
+ assert(f.__left_ == &e);
+ assert(f.__right_ == 0);
+ assert(f.__is_black_ == true);
+
+ assert(e.__parent_ == &f);
+ assert(e.__left_ == 0);
+ assert(e.__right_ == 0);
+ assert(e.__is_black_ == false);
+
+ assert(h.__parent_ == &g);
+ assert(h.__left_ == 0);
+ assert(h.__right_ == 0);
+ assert(h.__is_black_ == true);
+
+ e.__left_ = &d;
+ d.__parent_ = &e;
+
+ std::__tree_balance_after_insert(root.__left_, &d);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &g);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(g.__parent_ == &root);
+ assert(g.__left_ == &e);
+ assert(g.__right_ == &h);
+ assert(g.__is_black_ == true);
+
+ assert(e.__parent_ == &g);
+ assert(e.__left_ == &d);
+ assert(e.__right_ == &f);
+ assert(e.__is_black_ == true);
+
+ assert(d.__parent_ == &e);
+ assert(d.__left_ == 0);
+ assert(d.__right_ == 0);
+ assert(d.__is_black_ == false);
+
+ assert(f.__parent_ == &e);
+ assert(f.__left_ == 0);
+ assert(f.__right_ == 0);
+ assert(f.__is_black_ == false);
+
+ assert(h.__parent_ == &g);
+ assert(h.__left_ == 0);
+ assert(h.__right_ == 0);
+ assert(h.__is_black_ == true);
+
+ d.__left_ = &c;
+ c.__parent_ = &d;
+
+ std::__tree_balance_after_insert(root.__left_, &c);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &g);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(g.__parent_ == &root);
+ assert(g.__left_ == &e);
+ assert(g.__right_ == &h);
+ assert(g.__is_black_ == true);
+
+ assert(e.__parent_ == &g);
+ assert(e.__left_ == &d);
+ assert(e.__right_ == &f);
+ assert(e.__is_black_ == false);
+
+ assert(d.__parent_ == &e);
+ assert(d.__left_ == &c);
+ assert(d.__right_ == 0);
+ assert(d.__is_black_ == true);
+
+ assert(c.__parent_ == &d);
+ assert(c.__left_ == 0);
+ assert(c.__right_ == 0);
+ assert(c.__is_black_ == false);
+
+ assert(f.__parent_ == &e);
+ assert(f.__left_ == 0);
+ assert(f.__right_ == 0);
+ assert(f.__is_black_ == true);
+
+ assert(h.__parent_ == &g);
+ assert(h.__left_ == 0);
+ assert(h.__right_ == 0);
+ assert(h.__is_black_ == true);
+
+ c.__left_ = &b;
+ b.__parent_ = &c;
+
+ std::__tree_balance_after_insert(root.__left_, &b);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &g);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(g.__parent_ == &root);
+ assert(g.__left_ == &e);
+ assert(g.__right_ == &h);
+ assert(g.__is_black_ == true);
+
+ assert(e.__parent_ == &g);
+ assert(e.__left_ == &c);
+ assert(e.__right_ == &f);
+ assert(e.__is_black_ == false);
+
+ assert(c.__parent_ == &e);
+ assert(c.__left_ == &b);
+ assert(c.__right_ == &d);
+ assert(c.__is_black_ == true);
+
+ assert(b.__parent_ == &c);
+ assert(b.__left_ == 0);
+ assert(b.__right_ == 0);
+ assert(b.__is_black_ == false);
+
+ assert(d.__parent_ == &c);
+ assert(d.__left_ == 0);
+ assert(d.__right_ == 0);
+ assert(d.__is_black_ == false);
+
+ assert(f.__parent_ == &e);
+ assert(f.__left_ == 0);
+ assert(f.__right_ == 0);
+ assert(f.__is_black_ == true);
+
+ assert(h.__parent_ == &g);
+ assert(h.__left_ == 0);
+ assert(h.__right_ == 0);
+ assert(h.__is_black_ == true);
+
+ b.__left_ = &a;
+ a.__parent_ = &b;
+
+ std::__tree_balance_after_insert(root.__left_, &a);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &e);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(e.__parent_ == &root);
+ assert(e.__left_ == &c);
+ assert(e.__right_ == &g);
+ assert(e.__is_black_ == true);
+
+ assert(c.__parent_ == &e);
+ assert(c.__left_ == &b);
+ assert(c.__right_ == &d);
+ assert(c.__is_black_ == false);
+
+ assert(b.__parent_ == &c);
+ assert(b.__left_ == &a);
+ assert(b.__right_ == 0);
+ assert(b.__is_black_ == true);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == false);
+
+ assert(d.__parent_ == &c);
+ assert(d.__left_ == 0);
+ assert(d.__right_ == 0);
+ assert(d.__is_black_ == true);
+
+ assert(g.__parent_ == &e);
+ assert(g.__left_ == &f);
+ assert(g.__right_ == &h);
+ assert(g.__is_black_ == false);
+
+ assert(f.__parent_ == &g);
+ assert(f.__left_ == 0);
+ assert(f.__right_ == 0);
+ assert(f.__is_black_ == true);
+
+ assert(h.__parent_ == &g);
+ assert(h.__left_ == 0);
+ assert(h.__right_ == 0);
+ assert(h.__is_black_ == true);
+}
+
+int main()
+{
+ test1();
+ test2();
+ test3();
+ test4();
+ test5();
+}
diff --git a/test/std/containers/associative/tree_left_rotate.pass.cpp b/test/std/containers/associative/tree_left_rotate.pass.cpp
new file mode 100644
index 000000000000..774cbc687985
--- /dev/null
+++ b/test/std/containers/associative/tree_left_rotate.pass.cpp
@@ -0,0 +1,98 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// Not a portable test
+
+// Precondition: __x->__right_ != nullptr
+// template <class _NodePtr>
+// void
+// __tree_left_rotate(_NodePtr __x);
+
+#include <__tree>
+#include <cassert>
+
+struct Node
+{
+ Node* __left_;
+ Node* __right_;
+ Node* __parent_;
+
+ Node() : __left_(), __right_(), __parent_() {}
+};
+
+void
+test1()
+{
+ Node root;
+ Node x;
+ Node y;
+ root.__left_ = &x;
+ x.__left_ = 0;
+ x.__right_ = &y;
+ x.__parent_ = &root;
+ y.__left_ = 0;
+ y.__right_ = 0;
+ y.__parent_ = &x;
+ std::__tree_left_rotate(&x);
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &y);
+ assert(root.__right_ == 0);
+ assert(y.__parent_ == &root);
+ assert(y.__left_ == &x);
+ assert(y.__right_ == 0);
+ assert(x.__parent_ == &y);
+ assert(x.__left_ == 0);
+ assert(x.__right_ == 0);
+}
+
+void
+test2()
+{
+ Node root;
+ Node x;
+ Node y;
+ Node a;
+ Node b;
+ Node c;
+ root.__left_ = &x;
+ x.__left_ = &a;
+ x.__right_ = &y;
+ x.__parent_ = &root;
+ y.__left_ = &b;
+ y.__right_ = &c;
+ y.__parent_ = &x;
+ a.__parent_ = &x;
+ b.__parent_ = &y;
+ c.__parent_ = &y;
+ std::__tree_left_rotate(&x);
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &y);
+ assert(root.__right_ == 0);
+ assert(y.__parent_ == &root);
+ assert(y.__left_ == &x);
+ assert(y.__right_ == &c);
+ assert(x.__parent_ == &y);
+ assert(x.__left_ == &a);
+ assert(x.__right_ == &b);
+ assert(a.__parent_ == &x);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(b.__parent_ == &x);
+ assert(b.__left_ == 0);
+ assert(b.__right_ == 0);
+ assert(c.__parent_ == &y);
+ assert(c.__left_ == 0);
+ assert(c.__right_ == 0);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
diff --git a/test/std/containers/associative/tree_remove.pass.cpp b/test/std/containers/associative/tree_remove.pass.cpp
new file mode 100644
index 000000000000..fb14bd929e91
--- /dev/null
+++ b/test/std/containers/associative/tree_remove.pass.cpp
@@ -0,0 +1,1648 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// Not a portable test
+
+// Returns __tree_next(__z)
+// template <class _NodePtr>
+// void
+// __tree_remove(_NodePtr __root, _NodePtr __z)
+
+#include <__tree>
+#include <cassert>
+
+struct Node
+{
+ Node* __left_;
+ Node* __right_;
+ Node* __parent_;
+ bool __is_black_;
+
+ Node() : __left_(), __right_(), __parent_(), __is_black_() {}
+};
+
+void
+test1()
+{
+ {
+ // Left
+ // Case 1 -> Case 2 -> x is red turned to black
+ Node root;
+ Node b;
+ Node c;
+ Node d;
+ Node e;
+ Node y;
+
+ root.__left_ = &b;
+
+ b.__parent_ = &root;
+ b.__left_ = &y;
+ b.__right_ = &d;
+ b.__is_black_ = true;
+
+ y.__parent_ = &b;
+ y.__left_ = 0;
+ y.__right_ = 0;
+ y.__is_black_ = true;
+
+ d.__parent_ = &b;
+ d.__left_ = &c;
+ d.__right_ = &e;
+ d.__is_black_ = false;
+
+ c.__parent_ = &d;
+ c.__left_ = 0;
+ c.__right_ = 0;
+ c.__is_black_ = true;
+
+ e.__parent_ = &d;
+ e.__left_ = 0;
+ e.__right_ = 0;
+ e.__is_black_ = true;
+
+ std::__tree_remove(root.__left_, &y);
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &d);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(d.__parent_ == &root);
+ assert(d.__left_ == &b);
+ assert(d.__right_ == &e);
+ assert(d.__is_black_ == true);
+
+ assert(b.__parent_ == &d);
+ assert(b.__left_ == 0);
+ assert(b.__right_ == &c);
+ assert(b.__is_black_ == true);
+
+ assert(c.__parent_ == &b);
+ assert(c.__left_ == 0);
+ assert(c.__right_ == 0);
+ assert(c.__is_black_ == false);
+
+ assert(e.__parent_ == &d);
+ assert(e.__left_ == 0);
+ assert(e.__right_ == 0);
+ assert(e.__is_black_ == true);
+ }
+ {
+ // Right
+ // Case 1 -> Case 2 -> x is red turned to black
+ Node root;
+ Node b;
+ Node c;
+ Node d;
+ Node e;
+ Node y;
+
+ root.__left_ = &b;
+
+ b.__parent_ = &root;
+ b.__right_ = &y;
+ b.__left_ = &d;
+ b.__is_black_ = true;
+
+ y.__parent_ = &b;
+ y.__right_ = 0;
+ y.__left_ = 0;
+ y.__is_black_ = true;
+
+ d.__parent_ = &b;
+ d.__right_ = &c;
+ d.__left_ = &e;
+ d.__is_black_ = false;
+
+ c.__parent_ = &d;
+ c.__right_ = 0;
+ c.__left_ = 0;
+ c.__is_black_ = true;
+
+ e.__parent_ = &d;
+ e.__right_ = 0;
+ e.__left_ = 0;
+ e.__is_black_ = true;
+
+ std::__tree_remove(root.__left_, &y);
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &d);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(d.__parent_ == &root);
+ assert(d.__right_ == &b);
+ assert(d.__left_ == &e);
+ assert(d.__is_black_ == true);
+
+ assert(b.__parent_ == &d);
+ assert(b.__right_ == 0);
+ assert(b.__left_ == &c);
+ assert(b.__is_black_ == true);
+
+ assert(c.__parent_ == &b);
+ assert(c.__right_ == 0);
+ assert(c.__left_ == 0);
+ assert(c.__is_black_ == false);
+
+ assert(e.__parent_ == &d);
+ assert(e.__right_ == 0);
+ assert(e.__left_ == 0);
+ assert(e.__is_black_ == true);
+ }
+ {
+ // Left
+ // Case 1 -> Case 3 -> Case 4
+ Node root;
+ Node b;
+ Node c;
+ Node d;
+ Node e;
+ Node f;
+ Node y;
+
+ root.__left_ = &b;
+
+ b.__parent_ = &root;
+ b.__left_ = &y;
+ b.__right_ = &d;
+ b.__is_black_ = true;
+
+ y.__parent_ = &b;
+ y.__left_ = 0;
+ y.__right_ = 0;
+ y.__is_black_ = true;
+
+ d.__parent_ = &b;
+ d.__left_ = &c;
+ d.__right_ = &e;
+ d.__is_black_ = false;
+
+ c.__parent_ = &d;
+ c.__left_ = &f;
+ c.__right_ = 0;
+ c.__is_black_ = true;
+
+ e.__parent_ = &d;
+ e.__left_ = 0;
+ e.__right_ = 0;
+ e.__is_black_ = true;
+
+ f.__parent_ = &c;
+ f.__left_ = 0;
+ f.__right_ = 0;
+ f.__is_black_ = false;
+
+ std::__tree_remove(root.__left_, &y);
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &d);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(d.__parent_ == &root);
+ assert(d.__left_ == &f);
+ assert(d.__right_ == &e);
+ assert(d.__is_black_ == true);
+
+ assert(f.__parent_ == &d);
+ assert(f.__left_ == &b);
+ assert(f.__right_ == &c);
+ assert(f.__is_black_ == false);
+
+ assert(b.__parent_ == &f);
+ assert(b.__left_ == 0);
+ assert(b.__right_ == 0);
+ assert(b.__is_black_ == true);
+
+ assert(c.__parent_ == &f);
+ assert(c.__left_ == 0);
+ assert(c.__right_ == 0);
+ assert(c.__is_black_ == true);
+
+ assert(e.__parent_ == &d);
+ assert(e.__left_ == 0);
+ assert(e.__right_ == 0);
+ assert(e.__is_black_ == true);
+ }
+ {
+ // Right
+ // Case 1 -> Case 3 -> Case 4
+ Node root;
+ Node b;
+ Node c;
+ Node d;
+ Node e;
+ Node f;
+ Node y;
+
+ root.__left_ = &b;
+
+ b.__parent_ = &root;
+ b.__right_ = &y;
+ b.__left_ = &d;
+ b.__is_black_ = true;
+
+ y.__parent_ = &b;
+ y.__right_ = 0;
+ y.__left_ = 0;
+ y.__is_black_ = true;
+
+ d.__parent_ = &b;
+ d.__right_ = &c;
+ d.__left_ = &e;
+ d.__is_black_ = false;
+
+ c.__parent_ = &d;
+ c.__right_ = &f;
+ c.__left_ = 0;
+ c.__is_black_ = true;
+
+ e.__parent_ = &d;
+ e.__right_ = 0;
+ e.__left_ = 0;
+ e.__is_black_ = true;
+
+ f.__parent_ = &c;
+ f.__right_ = 0;
+ f.__left_ = 0;
+ f.__is_black_ = false;
+
+ std::__tree_remove(root.__left_, &y);
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &d);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(d.__parent_ == &root);
+ assert(d.__right_ == &f);
+ assert(d.__left_ == &e);
+ assert(d.__is_black_ == true);
+
+ assert(f.__parent_ == &d);
+ assert(f.__right_ == &b);
+ assert(f.__left_ == &c);
+ assert(f.__is_black_ == false);
+
+ assert(b.__parent_ == &f);
+ assert(b.__right_ == 0);
+ assert(b.__left_ == 0);
+ assert(b.__is_black_ == true);
+
+ assert(c.__parent_ == &f);
+ assert(c.__right_ == 0);
+ assert(c.__left_ == 0);
+ assert(c.__is_black_ == true);
+
+ assert(e.__parent_ == &d);
+ assert(e.__right_ == 0);
+ assert(e.__left_ == 0);
+ assert(e.__is_black_ == true);
+ }
+}
+
+void
+test2()
+{
+ {
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+
+ root.__left_ = &b;
+
+ b.__parent_ = &root;
+ b.__left_ = &a;
+ b.__right_ = &c;
+ b.__is_black_ = true;
+
+ a.__parent_ = &b;
+ a.__left_ = 0;
+ a.__right_ = 0;
+ a.__is_black_ = true;
+
+ c.__parent_ = &b;
+ c.__left_ = 0;
+ c.__right_ = 0;
+ c.__is_black_ = true;
+
+ std::__tree_remove(root.__left_, &a);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &b);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(b.__parent_ == &root);
+ assert(b.__left_ == 0);
+ assert(b.__right_ == &c);
+ assert(b.__is_black_ == true);
+
+ assert(c.__parent_ == &b);
+ assert(c.__left_ == 0);
+ assert(c.__right_ == 0);
+ assert(c.__is_black_ == false);
+
+ std::__tree_remove(root.__left_, &b);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &c);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(c.__parent_ == &root);
+ assert(c.__left_ == 0);
+ assert(c.__right_ == 0);
+ assert(c.__is_black_ == true);
+
+ std::__tree_remove(root.__left_, &c);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == 0);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+ }
+ {
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+
+ root.__left_ = &b;
+
+ b.__parent_ = &root;
+ b.__left_ = &a;
+ b.__right_ = &c;
+ b.__is_black_ = true;
+
+ a.__parent_ = &b;
+ a.__left_ = 0;
+ a.__right_ = 0;
+ a.__is_black_ = false;
+
+ c.__parent_ = &b;
+ c.__left_ = 0;
+ c.__right_ = 0;
+ c.__is_black_ = false;
+
+ std::__tree_remove(root.__left_, &a);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &b);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(b.__parent_ == &root);
+ assert(b.__left_ == 0);
+ assert(b.__right_ == &c);
+ assert(b.__is_black_ == true);
+
+ assert(c.__parent_ == &b);
+ assert(c.__left_ == 0);
+ assert(c.__right_ == 0);
+ assert(c.__is_black_ == false);
+
+ std::__tree_remove(root.__left_, &b);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &c);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(c.__parent_ == &root);
+ assert(c.__left_ == 0);
+ assert(c.__right_ == 0);
+ assert(c.__is_black_ == true);
+
+ std::__tree_remove(root.__left_, &c);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == 0);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+ }
+ {
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+
+ root.__left_ = &b;
+
+ b.__parent_ = &root;
+ b.__left_ = &a;
+ b.__right_ = &c;
+ b.__is_black_ = true;
+
+ a.__parent_ = &b;
+ a.__left_ = 0;
+ a.__right_ = 0;
+ a.__is_black_ = true;
+
+ c.__parent_ = &b;
+ c.__left_ = 0;
+ c.__right_ = 0;
+ c.__is_black_ = true;
+
+ std::__tree_remove(root.__left_, &a);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &b);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(b.__parent_ == &root);
+ assert(b.__left_ == 0);
+ assert(b.__right_ == &c);
+ assert(b.__is_black_ == true);
+
+ assert(c.__parent_ == &b);
+ assert(c.__left_ == 0);
+ assert(c.__right_ == 0);
+ assert(c.__is_black_ == false);
+
+ std::__tree_remove(root.__left_, &c);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &b);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(b.__parent_ == &root);
+ assert(b.__left_ == 0);
+ assert(b.__right_ == 0);
+ assert(b.__is_black_ == true);
+
+ std::__tree_remove(root.__left_, &b);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == 0);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+ }
+ {
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+
+ root.__left_ = &b;
+
+ b.__parent_ = &root;
+ b.__left_ = &a;
+ b.__right_ = &c;
+ b.__is_black_ = true;
+
+ a.__parent_ = &b;
+ a.__left_ = 0;
+ a.__right_ = 0;
+ a.__is_black_ = false;
+
+ c.__parent_ = &b;
+ c.__left_ = 0;
+ c.__right_ = 0;
+ c.__is_black_ = false;
+
+ std::__tree_remove(root.__left_, &a);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &b);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(b.__parent_ == &root);
+ assert(b.__left_ == 0);
+ assert(b.__right_ == &c);
+ assert(b.__is_black_ == true);
+
+ assert(c.__parent_ == &b);
+ assert(c.__left_ == 0);
+ assert(c.__right_ == 0);
+ assert(c.__is_black_ == false);
+
+ std::__tree_remove(root.__left_, &c);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &b);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(b.__parent_ == &root);
+ assert(b.__left_ == 0);
+ assert(b.__right_ == 0);
+ assert(b.__is_black_ == true);
+
+ std::__tree_remove(root.__left_, &b);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == 0);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+ }
+ {
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+
+ root.__left_ = &b;
+
+ b.__parent_ = &root;
+ b.__left_ = &a;
+ b.__right_ = &c;
+ b.__is_black_ = true;
+
+ a.__parent_ = &b;
+ a.__left_ = 0;
+ a.__right_ = 0;
+ a.__is_black_ = true;
+
+ c.__parent_ = &b;
+ c.__left_ = 0;
+ c.__right_ = 0;
+ c.__is_black_ = true;
+
+ std::__tree_remove(root.__left_, &b);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &c);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(a.__parent_ == &c);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == false);
+
+ assert(c.__parent_ == &root);
+ assert(c.__left_ == &a);
+ assert(c.__right_ == 0);
+ assert(c.__is_black_ == true);
+
+ std::__tree_remove(root.__left_, &a);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &c);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(c.__parent_ == &root);
+ assert(c.__left_ == 0);
+ assert(c.__right_ == 0);
+ assert(c.__is_black_ == true);
+
+ std::__tree_remove(root.__left_, &c);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == 0);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+ }
+ {
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+
+ root.__left_ = &b;
+
+ b.__parent_ = &root;
+ b.__left_ = &a;
+ b.__right_ = &c;
+ b.__is_black_ = true;
+
+ a.__parent_ = &b;
+ a.__left_ = 0;
+ a.__right_ = 0;
+ a.__is_black_ = false;
+
+ c.__parent_ = &b;
+ c.__left_ = 0;
+ c.__right_ = 0;
+ c.__is_black_ = false;
+
+ std::__tree_remove(root.__left_, &b);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &c);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(a.__parent_ == &c);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == false);
+
+ assert(c.__parent_ == &root);
+ assert(c.__left_ == &a);
+ assert(c.__right_ == 0);
+ assert(c.__is_black_ == true);
+
+ std::__tree_remove(root.__left_, &a);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &c);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(c.__parent_ == &root);
+ assert(c.__left_ == 0);
+ assert(c.__right_ == 0);
+ assert(c.__is_black_ == true);
+
+ std::__tree_remove(root.__left_, &c);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == 0);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+ }
+ {
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+
+ root.__left_ = &b;
+
+ b.__parent_ = &root;
+ b.__left_ = &a;
+ b.__right_ = &c;
+ b.__is_black_ = true;
+
+ a.__parent_ = &b;
+ a.__left_ = 0;
+ a.__right_ = 0;
+ a.__is_black_ = true;
+
+ c.__parent_ = &b;
+ c.__left_ = 0;
+ c.__right_ = 0;
+ c.__is_black_ = true;
+
+ std::__tree_remove(root.__left_, &b);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &c);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(a.__parent_ == &c);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == false);
+
+ assert(c.__parent_ == &root);
+ assert(c.__left_ == &a);
+ assert(c.__right_ == 0);
+ assert(c.__is_black_ == true);
+
+ std::__tree_remove(root.__left_, &c);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &a);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(a.__parent_ == &root);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == true);
+
+ std::__tree_remove(root.__left_, &a);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == 0);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+ }
+ {
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+
+ root.__left_ = &b;
+
+ b.__parent_ = &root;
+ b.__left_ = &a;
+ b.__right_ = &c;
+ b.__is_black_ = true;
+
+ a.__parent_ = &b;
+ a.__left_ = 0;
+ a.__right_ = 0;
+ a.__is_black_ = false;
+
+ c.__parent_ = &b;
+ c.__left_ = 0;
+ c.__right_ = 0;
+ c.__is_black_ = false;
+
+ std::__tree_remove(root.__left_, &b);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &c);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(a.__parent_ == &c);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == false);
+
+ assert(c.__parent_ == &root);
+ assert(c.__left_ == &a);
+ assert(c.__right_ == 0);
+ assert(c.__is_black_ == true);
+
+ std::__tree_remove(root.__left_, &c);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &a);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(a.__parent_ == &root);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == true);
+
+ std::__tree_remove(root.__left_, &a);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == 0);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+ }
+ {
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+
+ root.__left_ = &b;
+
+ b.__parent_ = &root;
+ b.__left_ = &a;
+ b.__right_ = &c;
+ b.__is_black_ = true;
+
+ a.__parent_ = &b;
+ a.__left_ = 0;
+ a.__right_ = 0;
+ a.__is_black_ = true;
+
+ c.__parent_ = &b;
+ c.__left_ = 0;
+ c.__right_ = 0;
+ c.__is_black_ = true;
+
+ std::__tree_remove(root.__left_, &c);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &b);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == false);
+
+ assert(b.__parent_ == &root);
+ assert(b.__left_ == &a);
+ assert(b.__right_ == 0);
+ assert(b.__is_black_ == true);
+
+ std::__tree_remove(root.__left_, &b);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &a);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(a.__parent_ == &root);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == true);
+
+ std::__tree_remove(root.__left_, &a);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == 0);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+ }
+ {
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+
+ root.__left_ = &b;
+
+ b.__parent_ = &root;
+ b.__left_ = &a;
+ b.__right_ = &c;
+ b.__is_black_ = true;
+
+ a.__parent_ = &b;
+ a.__left_ = 0;
+ a.__right_ = 0;
+ a.__is_black_ = false;
+
+ c.__parent_ = &b;
+ c.__left_ = 0;
+ c.__right_ = 0;
+ c.__is_black_ = false;
+
+ std::__tree_remove(root.__left_, &c);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &b);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == false);
+
+ assert(b.__parent_ == &root);
+ assert(b.__left_ == &a);
+ assert(b.__right_ == 0);
+ assert(b.__is_black_ == true);
+
+ std::__tree_remove(root.__left_, &b);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &a);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(a.__parent_ == &root);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == true);
+
+ std::__tree_remove(root.__left_, &a);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == 0);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+ }
+ {
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+
+ root.__left_ = &b;
+
+ b.__parent_ = &root;
+ b.__left_ = &a;
+ b.__right_ = &c;
+ b.__is_black_ = true;
+
+ a.__parent_ = &b;
+ a.__left_ = 0;
+ a.__right_ = 0;
+ a.__is_black_ = true;
+
+ c.__parent_ = &b;
+ c.__left_ = 0;
+ c.__right_ = 0;
+ c.__is_black_ = true;
+
+ std::__tree_remove(root.__left_, &c);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &b);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == false);
+
+ assert(b.__parent_ == &root);
+ assert(b.__left_ == &a);
+ assert(b.__right_ == 0);
+ assert(b.__is_black_ == true);
+
+ std::__tree_remove(root.__left_, &a);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &b);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(b.__parent_ == &root);
+ assert(b.__left_ == 0);
+ assert(b.__right_ == 0);
+ assert(b.__is_black_ == true);
+
+ std::__tree_remove(root.__left_, &b);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == 0);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+ }
+ {
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+
+ root.__left_ = &b;
+
+ b.__parent_ = &root;
+ b.__left_ = &a;
+ b.__right_ = &c;
+ b.__is_black_ = true;
+
+ a.__parent_ = &b;
+ a.__left_ = 0;
+ a.__right_ = 0;
+ a.__is_black_ = false;
+
+ c.__parent_ = &b;
+ c.__left_ = 0;
+ c.__right_ = 0;
+ c.__is_black_ = false;
+
+ std::__tree_remove(root.__left_, &c);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &b);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == false);
+
+ assert(b.__parent_ == &root);
+ assert(b.__left_ == &a);
+ assert(b.__right_ == 0);
+ assert(b.__is_black_ == true);
+
+ std::__tree_remove(root.__left_, &a);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &b);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(b.__parent_ == &root);
+ assert(b.__left_ == 0);
+ assert(b.__right_ == 0);
+ assert(b.__is_black_ == true);
+
+ std::__tree_remove(root.__left_, &b);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == 0);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+ }
+}
+
+void
+test3()
+{
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+ Node d;
+ Node e;
+ Node f;
+ Node g;
+ Node h;
+
+ root.__left_ = &e;
+
+ e.__parent_ = &root;
+ e.__left_ = &c;
+ e.__right_ = &g;
+ e.__is_black_ = true;
+
+ c.__parent_ = &e;
+ c.__left_ = &b;
+ c.__right_ = &d;
+ c.__is_black_ = false;
+
+ g.__parent_ = &e;
+ g.__left_ = &f;
+ g.__right_ = &h;
+ g.__is_black_ = false;
+
+ b.__parent_ = &c;
+ b.__left_ = &a;
+ b.__right_ = 0;
+ b.__is_black_ = true;
+
+ d.__parent_ = &c;
+ d.__left_ = 0;
+ d.__right_ = 0;
+ d.__is_black_ = true;
+
+ f.__parent_ = &g;
+ f.__left_ = 0;
+ f.__right_ = 0;
+ f.__is_black_ = true;
+
+ h.__parent_ = &g;
+ h.__left_ = 0;
+ h.__right_ = 0;
+ h.__is_black_ = true;
+
+ a.__parent_ = &b;
+ a.__left_ = 0;
+ a.__right_ = 0;
+ a.__is_black_ = false;
+
+ assert(std::__tree_invariant(root.__left_));
+
+ std::__tree_remove(root.__left_, &h);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &e);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(e.__parent_ == &root);
+ assert(e.__left_ == &c);
+ assert(e.__right_ == &g);
+ assert(e.__is_black_ == true);
+
+ assert(c.__parent_ == &e);
+ assert(c.__left_ == &b);
+ assert(c.__right_ == &d);
+ assert(c.__is_black_ == false);
+
+ assert(g.__parent_ == &e);
+ assert(g.__left_ == &f);
+ assert(g.__right_ == 0);
+ assert(g.__is_black_ == true);
+
+ assert(b.__parent_ == &c);
+ assert(b.__left_ == &a);
+ assert(b.__right_ == 0);
+ assert(b.__is_black_ == true);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == false);
+
+ assert(d.__parent_ == &c);
+ assert(d.__left_ == 0);
+ assert(d.__right_ == 0);
+ assert(d.__is_black_ == true);
+
+ assert(f.__parent_ == &g);
+ assert(f.__left_ == 0);
+ assert(f.__right_ == 0);
+ assert(f.__is_black_ == false);
+
+ std::__tree_remove(root.__left_, &g);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &e);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(e.__parent_ == &root);
+ assert(e.__left_ == &c);
+ assert(e.__right_ == &f);
+ assert(e.__is_black_ == true);
+
+ assert(c.__parent_ == &e);
+ assert(c.__left_ == &b);
+ assert(c.__right_ == &d);
+ assert(c.__is_black_ == false);
+
+ assert(b.__parent_ == &c);
+ assert(b.__left_ == &a);
+ assert(b.__right_ == 0);
+ assert(b.__is_black_ == true);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == false);
+
+ assert(d.__parent_ == &c);
+ assert(d.__left_ == 0);
+ assert(d.__right_ == 0);
+ assert(d.__is_black_ == true);
+
+ assert(f.__parent_ == &e);
+ assert(f.__left_ == 0);
+ assert(f.__right_ == 0);
+ assert(f.__is_black_ == true);
+
+ std::__tree_remove(root.__left_, &f);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &c);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(c.__parent_ == &root);
+ assert(c.__left_ == &b);
+ assert(c.__right_ == &e);
+ assert(c.__is_black_ == true);
+
+ assert(b.__parent_ == &c);
+ assert(b.__left_ == &a);
+ assert(b.__right_ == 0);
+ assert(b.__is_black_ == true);
+
+ assert(e.__parent_ == &c);
+ assert(e.__left_ == &d);
+ assert(e.__right_ == 0);
+ assert(e.__is_black_ == true);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == false);
+
+ assert(d.__parent_ == &e);
+ assert(d.__left_ == 0);
+ assert(d.__right_ == 0);
+ assert(d.__is_black_ == false);
+
+ std::__tree_remove(root.__left_, &e);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &c);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(c.__parent_ == &root);
+ assert(c.__left_ == &b);
+ assert(c.__right_ == &d);
+ assert(c.__is_black_ == true);
+
+ assert(b.__parent_ == &c);
+ assert(b.__left_ == &a);
+ assert(b.__right_ == 0);
+ assert(b.__is_black_ == true);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == false);
+
+ assert(d.__parent_ == &c);
+ assert(d.__left_ == 0);
+ assert(d.__right_ == 0);
+ assert(d.__is_black_ == true);
+
+ std::__tree_remove(root.__left_, &d);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &b);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(b.__parent_ == &root);
+ assert(b.__left_ == &a);
+ assert(b.__right_ == &c);
+ assert(b.__is_black_ == true);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == true);
+
+ assert(c.__parent_ == &b);
+ assert(c.__left_ == 0);
+ assert(c.__right_ == 0);
+ assert(c.__is_black_ == true);
+
+ std::__tree_remove(root.__left_, &c);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &b);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(b.__parent_ == &root);
+ assert(b.__left_ == &a);
+ assert(b.__right_ == 0);
+ assert(b.__is_black_ == true);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == false);
+
+ std::__tree_remove(root.__left_, &b);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &a);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(a.__parent_ == &root);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == true);
+
+ std::__tree_remove(root.__left_, &a);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == 0);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+}
+
+void
+test4()
+{
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+ Node d;
+ Node e;
+ Node f;
+ Node g;
+ Node h;
+
+ root.__left_ = &d;
+
+ d.__parent_ = &root;
+ d.__left_ = &b;
+ d.__right_ = &f;
+ d.__is_black_ = true;
+
+ b.__parent_ = &d;
+ b.__left_ = &a;
+ b.__right_ = &c;
+ b.__is_black_ = false;
+
+ f.__parent_ = &d;
+ f.__left_ = &e;
+ f.__right_ = &g;
+ f.__is_black_ = false;
+
+ a.__parent_ = &b;
+ a.__left_ = 0;
+ a.__right_ = 0;
+ a.__is_black_ = true;
+
+ c.__parent_ = &b;
+ c.__left_ = 0;
+ c.__right_ = 0;
+ c.__is_black_ = true;
+
+ e.__parent_ = &f;
+ e.__left_ = 0;
+ e.__right_ = 0;
+ e.__is_black_ = true;
+
+ g.__parent_ = &f;
+ g.__left_ = 0;
+ g.__right_ = &h;
+ g.__is_black_ = true;
+
+ h.__parent_ = &g;
+ h.__left_ = 0;
+ h.__right_ = 0;
+ h.__is_black_ = false;
+
+ assert(std::__tree_invariant(root.__left_));
+
+ std::__tree_remove(root.__left_, &a);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &d);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(d.__parent_ == &root);
+ assert(d.__left_ == &b);
+ assert(d.__right_ == &f);
+ assert(d.__is_black_ == true);
+
+ assert(b.__parent_ == &d);
+ assert(b.__left_ == 0);
+ assert(b.__right_ == &c);
+ assert(b.__is_black_ == true);
+
+ assert(f.__parent_ == &d);
+ assert(f.__left_ == &e);
+ assert(f.__right_ == &g);
+ assert(f.__is_black_ == false);
+
+ assert(c.__parent_ == &b);
+ assert(c.__left_ == 0);
+ assert(c.__right_ == 0);
+ assert(c.__is_black_ == false);
+
+ assert(e.__parent_ == &f);
+ assert(e.__left_ == 0);
+ assert(e.__right_ == 0);
+ assert(e.__is_black_ == true);
+
+ assert(g.__parent_ == &f);
+ assert(g.__left_ == 0);
+ assert(g.__right_ == &h);
+ assert(g.__is_black_ == true);
+
+ assert(h.__parent_ == &g);
+ assert(h.__left_ == 0);
+ assert(h.__right_ == 0);
+ assert(h.__is_black_ == false);
+
+ std::__tree_remove(root.__left_, &b);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &d);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(d.__parent_ == &root);
+ assert(d.__left_ == &c);
+ assert(d.__right_ == &f);
+ assert(d.__is_black_ == true);
+
+ assert(c.__parent_ == &d);
+ assert(c.__left_ == 0);
+ assert(c.__right_ == 0);
+ assert(c.__is_black_ == true);
+
+ assert(f.__parent_ == &d);
+ assert(f.__left_ == &e);
+ assert(f.__right_ == &g);
+ assert(f.__is_black_ == false);
+
+ assert(e.__parent_ == &f);
+ assert(e.__left_ == 0);
+ assert(e.__right_ == 0);
+ assert(e.__is_black_ == true);
+
+ assert(g.__parent_ == &f);
+ assert(g.__left_ == 0);
+ assert(g.__right_ == &h);
+ assert(g.__is_black_ == true);
+
+ assert(h.__parent_ == &g);
+ assert(h.__left_ == 0);
+ assert(h.__right_ == 0);
+ assert(h.__is_black_ == false);
+
+ std::__tree_remove(root.__left_, &c);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &f);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(f.__parent_ == &root);
+ assert(f.__left_ == &d);
+ assert(f.__right_ == &g);
+ assert(f.__is_black_ == true);
+
+ assert(d.__parent_ == &f);
+ assert(d.__left_ == 0);
+ assert(d.__right_ == &e);
+ assert(d.__is_black_ == true);
+
+ assert(g.__parent_ == &f);
+ assert(g.__left_ == 0);
+ assert(g.__right_ == &h);
+ assert(g.__is_black_ == true);
+
+ assert(e.__parent_ == &d);
+ assert(e.__left_ == 0);
+ assert(e.__right_ == 0);
+ assert(e.__is_black_ == false);
+
+ assert(h.__parent_ == &g);
+ assert(h.__left_ == 0);
+ assert(h.__right_ == 0);
+ assert(h.__is_black_ == false);
+
+ std::__tree_remove(root.__left_, &d);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &f);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(f.__parent_ == &root);
+ assert(f.__left_ == &e);
+ assert(f.__right_ == &g);
+ assert(f.__is_black_ == true);
+
+ assert(e.__parent_ == &f);
+ assert(e.__left_ == 0);
+ assert(e.__right_ == 0);
+ assert(e.__is_black_ == true);
+
+ assert(g.__parent_ == &f);
+ assert(g.__left_ == 0);
+ assert(g.__right_ == &h);
+ assert(g.__is_black_ == true);
+
+ assert(h.__parent_ == &g);
+ assert(h.__left_ == 0);
+ assert(h.__right_ == 0);
+ assert(h.__is_black_ == false);
+
+ std::__tree_remove(root.__left_, &e);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &g);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(g.__parent_ == &root);
+ assert(g.__left_ == &f);
+ assert(g.__right_ == &h);
+ assert(g.__is_black_ == true);
+
+ assert(f.__parent_ == &g);
+ assert(f.__left_ == 0);
+ assert(f.__right_ == 0);
+ assert(f.__is_black_ == true);
+
+ assert(h.__parent_ == &g);
+ assert(h.__left_ == 0);
+ assert(h.__right_ == 0);
+ assert(h.__is_black_ == true);
+
+ std::__tree_remove(root.__left_, &f);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &g);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(g.__parent_ == &root);
+ assert(g.__left_ == 0);
+ assert(g.__right_ == &h);
+ assert(g.__is_black_ == true);
+
+ assert(h.__parent_ == &g);
+ assert(h.__left_ == 0);
+ assert(h.__right_ == 0);
+ assert(h.__is_black_ == false);
+
+ std::__tree_remove(root.__left_, &g);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &h);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(h.__parent_ == &root);
+ assert(h.__left_ == 0);
+ assert(h.__right_ == 0);
+ assert(h.__is_black_ == true);
+
+ std::__tree_remove(root.__left_, &h);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == 0);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+}
+
+int main()
+{
+ test1();
+ test2();
+ test3();
+ test4();
+}
diff --git a/test/std/containers/associative/tree_right_rotate.pass.cpp b/test/std/containers/associative/tree_right_rotate.pass.cpp
new file mode 100644
index 000000000000..06ec7b889452
--- /dev/null
+++ b/test/std/containers/associative/tree_right_rotate.pass.cpp
@@ -0,0 +1,98 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// Not a portable test
+
+// Precondition: __x->__left_ != nullptr
+// template <class _NodePtr>
+// void
+// __tree_right_rotate(_NodePtr __x);
+
+#include <__tree>
+#include <cassert>
+
+struct Node
+{
+ Node* __left_;
+ Node* __right_;
+ Node* __parent_;
+
+ Node() : __left_(), __right_(), __parent_() {}
+};
+
+void
+test1()
+{
+ Node root;
+ Node x;
+ Node y;
+ root.__left_ = &x;
+ x.__left_ = &y;
+ x.__right_ = 0;
+ x.__parent_ = &root;
+ y.__left_ = 0;
+ y.__right_ = 0;
+ y.__parent_ = &x;
+ std::__tree_right_rotate(&x);
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &y);
+ assert(root.__right_ == 0);
+ assert(y.__parent_ == &root);
+ assert(y.__left_ == 0);
+ assert(y.__right_ == &x);
+ assert(x.__parent_ == &y);
+ assert(x.__left_ == 0);
+ assert(x.__right_ == 0);
+}
+
+void
+test2()
+{
+ Node root;
+ Node x;
+ Node y;
+ Node a;
+ Node b;
+ Node c;
+ root.__left_ = &x;
+ x.__left_ = &y;
+ x.__right_ = &c;
+ x.__parent_ = &root;
+ y.__left_ = &a;
+ y.__right_ = &b;
+ y.__parent_ = &x;
+ a.__parent_ = &y;
+ b.__parent_ = &y;
+ c.__parent_ = &x;
+ std::__tree_right_rotate(&x);
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &y);
+ assert(root.__right_ == 0);
+ assert(y.__parent_ == &root);
+ assert(y.__left_ == &a);
+ assert(y.__right_ == &x);
+ assert(x.__parent_ == &y);
+ assert(x.__left_ == &b);
+ assert(x.__right_ == &c);
+ assert(a.__parent_ == &y);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(b.__parent_ == &x);
+ assert(b.__left_ == 0);
+ assert(b.__right_ == 0);
+ assert(c.__parent_ == &x);
+ assert(c.__left_ == 0);
+ assert(c.__right_ == 0);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
diff --git a/test/std/containers/container.adaptors/nothing_to_do.pass.cpp b/test/std/containers/container.adaptors/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/containers/container.adaptors/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_alloc.pass.cpp b/test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_alloc.pass.cpp
new file mode 100644
index 000000000000..b102f117d48f
--- /dev/null
+++ b/test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_alloc.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class Alloc>
+// explicit priority_queue(const Alloc& a);
+
+#include <queue>
+#include <cassert>
+
+#include "test_allocator.h"
+
+template <class T>
+struct test
+ : public std::priority_queue<T, std::vector<T, test_allocator<T> > >
+{
+ typedef std::priority_queue<T, std::vector<T, test_allocator<T> > > base;
+ typedef typename base::container_type container_type;
+ typedef typename base::value_compare value_compare;
+
+ explicit test(const test_allocator<int>& a) : base(a) {}
+ test(const value_compare& comp, const test_allocator<int>& a)
+ : base(comp, c, a) {}
+ test(const value_compare& comp, const container_type& c,
+ const test_allocator<int>& a) : base(comp, c, a) {}
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ test(const value_compare& comp, container_type&& c,
+ const test_allocator<int>& a) : base(comp, std::move(c), a) {}
+ test(test&& q, const test_allocator<int>& a) : base(std::move(q), a) {}
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ test_allocator<int> get_allocator() {return c.get_allocator();}
+
+ using base::c;
+};
+
+int main()
+{
+ test<int> q((test_allocator<int>(3)));
+ assert(q.c.get_allocator() == test_allocator<int>(3));
+ assert(q.c.size() == 0);
+}
diff --git a/test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_comp_alloc.pass.cpp b/test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_comp_alloc.pass.cpp
new file mode 100644
index 000000000000..4d99fc14728b
--- /dev/null
+++ b/test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_comp_alloc.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class Alloc>
+// priority_queue(const Compare& comp, const Alloc& a);
+
+#include <queue>
+#include <cassert>
+
+#include "test_allocator.h"
+
+template <class T>
+struct test
+ : public std::priority_queue<T, std::vector<T, test_allocator<T> > >
+{
+ typedef std::priority_queue<T, std::vector<T, test_allocator<T> > > base;
+ typedef typename base::container_type container_type;
+ typedef typename base::value_compare value_compare;
+
+ explicit test(const test_allocator<int>& a) : base(a) {}
+ test(const value_compare& comp, const test_allocator<int>& a)
+ : base(comp, a) {}
+ test(const value_compare& comp, const container_type& c,
+ const test_allocator<int>& a) : base(comp, c, a) {}
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ test(const value_compare& comp, container_type&& c,
+ const test_allocator<int>& a) : base(comp, std::move(c), a) {}
+ test(test&& q, const test_allocator<int>& a) : base(std::move(q), a) {}
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ test_allocator<int> get_allocator() {return c.get_allocator();}
+
+ using base::c;
+};
+
+int main()
+{
+ test<int> q(std::less<int>(), test_allocator<int>(3));
+ assert(q.c.get_allocator() == test_allocator<int>(3));
+ assert(q.c.size() == 0);
+}
diff --git a/test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_comp_cont_alloc.pass.cpp b/test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_comp_cont_alloc.pass.cpp
new file mode 100644
index 000000000000..66ca614126f4
--- /dev/null
+++ b/test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_comp_cont_alloc.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class Alloc>
+// priority_queue(const Compare& comp, const container_type& c,
+// const Alloc& a);
+
+#include <queue>
+#include <cassert>
+
+#include "test_allocator.h"
+
+template <class C>
+C
+make(int n)
+{
+ C c;
+ for (int i = 0; i < n; ++i)
+ c.push_back(i);
+ return c;
+}
+
+template <class T>
+struct test
+ : public std::priority_queue<T, std::vector<T, test_allocator<T> > >
+{
+ typedef std::priority_queue<T, std::vector<T, test_allocator<T> > > base;
+ typedef typename base::container_type container_type;
+ typedef typename base::value_compare value_compare;
+
+ explicit test(const test_allocator<int>& a) : base(a) {}
+ test(const value_compare& comp, const test_allocator<int>& a)
+ : base(comp, a) {}
+ test(const value_compare& comp, const container_type& c,
+ const test_allocator<int>& a) : base(comp, c, a) {}
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ test(const value_compare& comp, container_type&& c,
+ const test_allocator<int>& a) : base(comp, std::move(c), a) {}
+ test(test&& q, const test_allocator<int>& a) : base(std::move(q), a) {}
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ test_allocator<int> get_allocator() {return c.get_allocator();}
+
+ using base::c;
+};
+
+int main()
+{
+ typedef std::vector<int, test_allocator<int> > C;
+ C v = make<C>(5);
+ test<int> q(std::less<int>(), v, test_allocator<int>(3));
+ assert(q.c.get_allocator() == test_allocator<int>(3));
+ assert(q.size() == 5);
+ assert(q.top() == 4);
+}
diff --git a/test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_comp_rcont_alloc.pass.cpp b/test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_comp_rcont_alloc.pass.cpp
new file mode 100644
index 000000000000..643b0c625abb
--- /dev/null
+++ b/test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_comp_rcont_alloc.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class Alloc>
+// priority_queue(const Compare& comp, container_type&& c,
+// const Alloc& a);
+
+#include <queue>
+#include <cassert>
+
+#include "test_allocator.h"
+
+template <class C>
+C
+make(int n)
+{
+ C c;
+ for (int i = 0; i < n; ++i)
+ c.push_back(i);
+ return c;
+}
+
+template <class T>
+struct test
+ : public std::priority_queue<T, std::vector<T, test_allocator<T> > >
+{
+ typedef std::priority_queue<T, std::vector<T, test_allocator<T> > > base;
+ typedef typename base::container_type container_type;
+ typedef typename base::value_compare value_compare;
+
+ explicit test(const test_allocator<int>& a) : base(a) {}
+ test(const value_compare& comp, const test_allocator<int>& a)
+ : base(comp, a) {}
+ test(const value_compare& comp, const container_type& c,
+ const test_allocator<int>& a) : base(comp, c, a) {}
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ test(const value_compare& comp, container_type&& c,
+ const test_allocator<int>& a) : base(comp, std::move(c), a) {}
+ test(test&& q, const test_allocator<int>& a) : base(std::move(q), a) {}
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ test_allocator<int> get_allocator() {return c.get_allocator();}
+
+ using base::c;
+};
+
+int main()
+{
+ typedef std::vector<int, test_allocator<int> > C;
+ test<int> q(std::less<int>(), make<C>(5), test_allocator<int>(3));
+ assert(q.c.get_allocator() == test_allocator<int>(3));
+ assert(q.size() == 5);
+ assert(q.top() == 4);
+}
diff --git a/test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_copy_alloc.pass.cpp b/test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_copy_alloc.pass.cpp
new file mode 100644
index 000000000000..a5a073c079be
--- /dev/null
+++ b/test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_copy_alloc.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class Alloc>
+// priority_queue(const priority_queue& q, const Alloc& a);
+
+#include <queue>
+#include <cassert>
+
+template <class C>
+C
+make(int n)
+{
+ C c;
+ for (int i = 0; i < n; ++i)
+ c.push_back(i);
+ return c;
+}
+
+#include "test_allocator.h"
+
+template <class T>
+struct test
+ : public std::priority_queue<T, std::vector<T, test_allocator<T> > >
+{
+ typedef std::priority_queue<T, std::vector<T, test_allocator<T> > > base;
+ typedef typename base::container_type container_type;
+ typedef typename base::value_compare value_compare;
+
+ explicit test(const test_allocator<int>& a) : base(a) {}
+ test(const value_compare& comp, const test_allocator<int>& a)
+ : base(comp, c, a) {}
+ test(const value_compare& comp, const container_type& c,
+ const test_allocator<int>& a) : base(comp, c, a) {}
+ test(const test& q, const test_allocator<int>& a) : base(q, a) {}
+ test_allocator<int> get_allocator() {return c.get_allocator();}
+
+ using base::c;
+};
+
+int main()
+{
+ test<int> qo(std::less<int>(),
+ make<std::vector<int, test_allocator<int> > >(5),
+ test_allocator<int>(2));
+ test<int> q(qo, test_allocator<int>(6));
+ assert(q.size() == 5);
+ assert(q.c.get_allocator() == test_allocator<int>(6));
+ assert(q.top() == int(4));
+}
diff --git a/test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_move_alloc.pass.cpp b/test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_move_alloc.pass.cpp
new file mode 100644
index 000000000000..8bdf7db863e7
--- /dev/null
+++ b/test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_move_alloc.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class Alloc>
+// priority_queue(priority_queue&& q, const Alloc& a);
+
+#include <queue>
+#include <cassert>
+
+#include "MoveOnly.h"
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class C>
+C
+make(int n)
+{
+ C c;
+ for (int i = 0; i < n; ++i)
+ c.push_back(MoveOnly(i));
+ return c;
+}
+
+#include "test_allocator.h"
+
+template <class T>
+struct test
+ : public std::priority_queue<T, std::vector<T, test_allocator<T> > >
+{
+ typedef std::priority_queue<T, std::vector<T, test_allocator<T> > > base;
+ typedef typename base::container_type container_type;
+ typedef typename base::value_compare value_compare;
+
+ explicit test(const test_allocator<int>& a) : base(a) {}
+ test(const value_compare& comp, const test_allocator<int>& a)
+ : base(comp, c, a) {}
+ test(const value_compare& comp, const container_type& c,
+ const test_allocator<int>& a) : base(comp, c, a) {}
+ test(const value_compare& comp, container_type&& c,
+ const test_allocator<int>& a) : base(comp, std::move(c), a) {}
+ test(test&& q, const test_allocator<int>& a) : base(std::move(q), a) {}
+ test_allocator<int> get_allocator() {return c.get_allocator();}
+
+ using base::c;
+};
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ test<MoveOnly> qo(std::less<MoveOnly>(),
+ make<std::vector<MoveOnly, test_allocator<MoveOnly> > >(5),
+ test_allocator<MoveOnly>(2));
+ test<MoveOnly> q(std::move(qo), test_allocator<MoveOnly>(6));
+ assert(q.size() == 5);
+ assert(q.c.get_allocator() == test_allocator<MoveOnly>(6));
+ assert(q.top() == MoveOnly(4));
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/container.adaptors/priority.queue/priqueue.cons/assign_copy.pass.cpp b/test/std/containers/container.adaptors/priority.queue/priqueue.cons/assign_copy.pass.cpp
new file mode 100644
index 000000000000..82e44b414f64
--- /dev/null
+++ b/test/std/containers/container.adaptors/priority.queue/priqueue.cons/assign_copy.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// priority_queue& operator=(const priority_queue&) = default;
+
+#include <queue>
+#include <cassert>
+#include <functional>
+
+template <class C>
+C
+make(int n)
+{
+ C c;
+ for (int i = 0; i < n; ++i)
+ c.push_back(i);
+ return c;
+}
+
+int main()
+{
+ std::vector<int> v = make<std::vector<int> >(5);
+ std::priority_queue<int, std::vector<int>, std::greater<int> > qo(std::greater<int>(), v);
+ std::priority_queue<int, std::vector<int>, std::greater<int> > q;
+ q = qo;
+ assert(q.size() == 5);
+ assert(q.top() == 0);
+}
diff --git a/test/std/containers/container.adaptors/priority.queue/priqueue.cons/assign_move.pass.cpp b/test/std/containers/container.adaptors/priority.queue/priqueue.cons/assign_move.pass.cpp
new file mode 100644
index 000000000000..d43e53819975
--- /dev/null
+++ b/test/std/containers/container.adaptors/priority.queue/priqueue.cons/assign_move.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// priority_queue& operator=(priority_queue&& q);
+
+#include <queue>
+#include <cassert>
+
+#include "MoveOnly.h"
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class C>
+C
+make(int n)
+{
+ C c;
+ for (int i = 0; i < n; ++i)
+ c.push_back(MoveOnly(i));
+ return c;
+}
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ std::priority_queue<MoveOnly> qo(std::less<MoveOnly>(), make<std::vector<MoveOnly> >(5));
+ std::priority_queue<MoveOnly> q;
+ q = std::move(qo);
+ assert(q.size() == 5);
+ assert(q.top() == MoveOnly(4));
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_comp.pass.cpp b/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_comp.pass.cpp
new file mode 100644
index 000000000000..f543b6379f15
--- /dev/null
+++ b/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_comp.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// explicit priority_queue(const Compare& comp);
+
+#include <queue>
+#include <cassert>
+
+#include "../../../stack_allocator.h"
+
+int main()
+{
+ std::priority_queue<int, std::vector<int, stack_allocator<int, 10> > > q((std::less<int>()));
+ assert(q.size() == 0);
+ q.push(1);
+ q.push(2);
+ assert(q.size() == 2);
+ assert(q.top() == 2);
+}
diff --git a/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_comp_container.pass.cpp b/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_comp_container.pass.cpp
new file mode 100644
index 000000000000..2c73cbc62c60
--- /dev/null
+++ b/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_comp_container.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// explicit priority_queue(const Compare& comp, const container_type& c);
+
+#include <queue>
+#include <cassert>
+#include <functional>
+
+template <class C>
+C
+make(int n)
+{
+ C c;
+ for (int i = 0; i < n; ++i)
+ c.push_back(i);
+ return c;
+}
+
+int main()
+{
+ std::vector<int> v = make<std::vector<int> >(5);
+ std::priority_queue<int, std::vector<int>, std::greater<int> > q(std::greater<int>(), v);
+ assert(q.size() == 5);
+ assert(q.top() == 0);
+}
diff --git a/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_comp_rcontainer.pass.cpp b/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_comp_rcontainer.pass.cpp
new file mode 100644
index 000000000000..b61fb88a5a36
--- /dev/null
+++ b/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_comp_rcontainer.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// explicit priority_queue(const Compare& comp, container_type&& c);
+
+#include <queue>
+#include <cassert>
+
+#include "MoveOnly.h"
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class C>
+C
+make(int n)
+{
+ C c;
+ for (int i = 0; i < n; ++i)
+ c.push_back(MoveOnly(i));
+ return c;
+}
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ std::priority_queue<MoveOnly> q(std::less<MoveOnly>(), make<std::vector<MoveOnly> >(5));
+ assert(q.size() == 5);
+ assert(q.top() == MoveOnly(4));
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_copy.pass.cpp b/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_copy.pass.cpp
new file mode 100644
index 000000000000..f1129bc1bbc1
--- /dev/null
+++ b/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_copy.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// priority_queue(const priority_queue&) = default;
+
+#include <queue>
+#include <cassert>
+#include <functional>
+
+template <class C>
+C
+make(int n)
+{
+ C c;
+ for (int i = 0; i < n; ++i)
+ c.push_back(i);
+ return c;
+}
+
+int main()
+{
+ std::vector<int> v = make<std::vector<int> >(5);
+ std::priority_queue<int, std::vector<int>, std::greater<int> > qo(std::greater<int>(), v);
+ std::priority_queue<int, std::vector<int>, std::greater<int> > q = qo;
+ assert(q.size() == 5);
+ assert(q.top() == 0);
+}
diff --git a/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_default.pass.cpp b/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_default.pass.cpp
new file mode 100644
index 000000000000..2bffe80ae11b
--- /dev/null
+++ b/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_default.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// priority_queue();
+
+#include <queue>
+#include <cassert>
+
+#include "../../../stack_allocator.h"
+
+int main()
+{
+ std::priority_queue<int, std::vector<int, stack_allocator<int, 10> > > q;
+ assert(q.size() == 0);
+ q.push(1);
+ q.push(2);
+ assert(q.size() == 2);
+ assert(q.top() == 2);
+}
diff --git a/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_iter_iter.pass.cpp b/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_iter_iter.pass.cpp
new file mode 100644
index 000000000000..1aaa8a3c6593
--- /dev/null
+++ b/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_iter_iter.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class InputIterator>
+// priority_queue(InputIterator first, InputIterator last);
+
+#include <queue>
+#include <cassert>
+
+int main()
+{
+ int a[] = {3, 5, 2, 0, 6, 8, 1};
+ int* an = a + sizeof(a)/sizeof(a[0]);
+ std::priority_queue<int> q(a, an);
+ assert(q.size() == an - a);
+ assert(q.top() == 8);
+}
diff --git a/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_iter_iter_comp.pass.cpp b/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_iter_iter_comp.pass.cpp
new file mode 100644
index 000000000000..17a698c15dff
--- /dev/null
+++ b/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_iter_iter_comp.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class InputIterator>
+// priority_queue(InputIterator first, InputIterator last, const Compare& comp);
+
+#include <queue>
+#include <cassert>
+#include <functional>
+
+int main()
+{
+ int a[] = {3, 5, 2, 0, 6, 8, 1};
+ int* an = a + sizeof(a)/sizeof(a[0]);
+ std::priority_queue<int, std::vector<int>, std::greater<int> >
+ q(a, an, std::greater<int>());
+ assert(q.size() == an - a);
+ assert(q.top() == 0);
+}
diff --git a/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_iter_iter_comp_cont.pass.cpp b/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_iter_iter_comp_cont.pass.cpp
new file mode 100644
index 000000000000..b44d7d38c6f4
--- /dev/null
+++ b/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_iter_iter_comp_cont.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class InputIterator>
+// priority_queue(InputIterator first, InputIterator last,
+// const Compare& comp, const container_type& c);
+
+#include <queue>
+#include <cassert>
+
+int main()
+{
+ int a[] = {3, 5, 2, 0, 6, 8, 1};
+ const int n = sizeof(a)/sizeof(a[0]);
+ std::vector<int> v(a, a+n/2);
+ std::priority_queue<int> q(a+n/2, a+n, std::less<int>(), v);
+ assert(q.size() == n);
+ assert(q.top() == 8);
+}
diff --git a/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_iter_iter_comp_rcont.pass.cpp b/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_iter_iter_comp_rcont.pass.cpp
new file mode 100644
index 000000000000..7abe796e53ef
--- /dev/null
+++ b/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_iter_iter_comp_rcont.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class InputIterator>
+// priority_queue(InputIterator first, InputIterator last,
+// const Compare& comp, container_type&& c);
+
+#include <queue>
+#include <cassert>
+
+#include "MoveOnly.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ int a[] = {3, 5, 2, 0, 6, 8, 1};
+ const int n = sizeof(a)/sizeof(a[0]);
+ std::priority_queue<MoveOnly> q(a+n/2, a+n,
+ std::less<MoveOnly>(),
+ std::vector<MoveOnly>(a, a+n/2));
+ assert(q.size() == n);
+ assert(q.top() == MoveOnly(8));
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_move.pass.cpp b/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_move.pass.cpp
new file mode 100644
index 000000000000..aac8403e5922
--- /dev/null
+++ b/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_move.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// priority_queue(priority_queue&& q);
+
+#include <queue>
+#include <cassert>
+
+#include "MoveOnly.h"
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class C>
+C
+make(int n)
+{
+ C c;
+ for (int i = 0; i < n; ++i)
+ c.push_back(MoveOnly(i));
+ return c;
+}
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ std::priority_queue<MoveOnly> qo(std::less<MoveOnly>(), make<std::vector<MoveOnly> >(5));
+ std::priority_queue<MoveOnly> q = std::move(qo);
+ assert(q.size() == 5);
+ assert(q.top() == MoveOnly(4));
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/container.adaptors/priority.queue/priqueue.cons/default_noexcept.pass.cpp b/test/std/containers/container.adaptors/priority.queue/priqueue.cons/default_noexcept.pass.cpp
new file mode 100644
index 000000000000..cdfa58b58554
--- /dev/null
+++ b/test/std/containers/container.adaptors/priority.queue/priqueue.cons/default_noexcept.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// priority_queue()
+// noexcept(is_nothrow_default_constructible<container_type>::value &&
+// is_nothrow_default_constructible<Compare>::value);
+
+// This tests a conforming extension
+
+#include <queue>
+#include <cassert>
+
+#include "MoveOnly.h"
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::priority_queue<MoveOnly> C;
+ static_assert(std::is_nothrow_default_constructible<C>::value, "");
+ }
+#endif
+}
diff --git a/test/std/containers/container.adaptors/priority.queue/priqueue.cons/dtor_noexcept.pass.cpp b/test/std/containers/container.adaptors/priority.queue/priqueue.cons/dtor_noexcept.pass.cpp
new file mode 100644
index 000000000000..e3d071d9aad0
--- /dev/null
+++ b/test/std/containers/container.adaptors/priority.queue/priqueue.cons/dtor_noexcept.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// ~priority_queue() // implied noexcept;
+
+#include <queue>
+#include <cassert>
+
+#include "MoveOnly.h"
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::priority_queue<MoveOnly> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+#endif
+}
diff --git a/test/std/containers/container.adaptors/priority.queue/priqueue.cons/move_assign_noexcept.pass.cpp b/test/std/containers/container.adaptors/priority.queue/priqueue.cons/move_assign_noexcept.pass.cpp
new file mode 100644
index 000000000000..590d82fe6da4
--- /dev/null
+++ b/test/std/containers/container.adaptors/priority.queue/priqueue.cons/move_assign_noexcept.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// priority_queue& operator=(priority_queue&& c)
+// noexcept(is_nothrow_move_assignable<container_type>::value &&
+// is_nothrow_move_assignable<Compare>::value);
+
+// This tests a conforming extension
+
+#include <queue>
+#include <cassert>
+
+#include "MoveOnly.h"
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::priority_queue<MoveOnly> C;
+ static_assert(std::is_nothrow_move_assignable<C>::value, "");
+ }
+#endif
+}
diff --git a/test/std/containers/container.adaptors/priority.queue/priqueue.cons/move_noexcept.pass.cpp b/test/std/containers/container.adaptors/priority.queue/priqueue.cons/move_noexcept.pass.cpp
new file mode 100644
index 000000000000..05ff253d31b4
--- /dev/null
+++ b/test/std/containers/container.adaptors/priority.queue/priqueue.cons/move_noexcept.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// priority_queue(priority_queue&&)
+// noexcept(is_nothrow_move_constructible<container_type>::value &&
+// is_nothrow_move_constructible<Compare>::value);
+
+// This tests a conforming extension
+
+#include <queue>
+#include <cassert>
+
+#include "MoveOnly.h"
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::priority_queue<MoveOnly> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+#endif
+}
diff --git a/test/std/containers/container.adaptors/priority.queue/priqueue.members/emplace.pass.cpp b/test/std/containers/container.adaptors/priority.queue/priqueue.members/emplace.pass.cpp
new file mode 100644
index 000000000000..4f14e93f5f52
--- /dev/null
+++ b/test/std/containers/container.adaptors/priority.queue/priqueue.members/emplace.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// priority_queue();
+
+// template <class... Args> void emplace(Args&&... args);
+
+#include <queue>
+#include <cassert>
+
+#include "../../../Emplaceable.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ std::priority_queue<Emplaceable> q;
+ q.emplace(1, 2.5);
+ assert(q.top() == Emplaceable(1, 2.5));
+ q.emplace(3, 4.5);
+ assert(q.top() == Emplaceable(3, 4.5));
+ q.emplace(2, 3.5);
+ assert(q.top() == Emplaceable(3, 4.5));
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/container.adaptors/priority.queue/priqueue.members/empty.pass.cpp b/test/std/containers/container.adaptors/priority.queue/priqueue.members/empty.pass.cpp
new file mode 100644
index 000000000000..f0c914a04271
--- /dev/null
+++ b/test/std/containers/container.adaptors/priority.queue/priqueue.members/empty.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// priority_queue();
+
+// bool empty() const;
+
+#include <queue>
+#include <cassert>
+
+int main()
+{
+ std::priority_queue<int> q;
+ assert(q.empty());
+ q.push(1);
+ assert(!q.empty());
+ q.pop();
+ assert(q.empty());
+}
diff --git a/test/std/containers/container.adaptors/priority.queue/priqueue.members/pop.pass.cpp b/test/std/containers/container.adaptors/priority.queue/priqueue.members/pop.pass.cpp
new file mode 100644
index 000000000000..f41b26f68fb9
--- /dev/null
+++ b/test/std/containers/container.adaptors/priority.queue/priqueue.members/pop.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// priority_queue();
+
+// void pop();
+
+#include <queue>
+#include <cassert>
+
+int main()
+{
+ std::priority_queue<int> q;
+ q.push(1);
+ assert(q.top() == 1);
+ q.push(3);
+ assert(q.top() == 3);
+ q.push(2);
+ assert(q.top() == 3);
+ q.pop();
+ assert(q.top() == 2);
+ q.pop();
+ assert(q.top() == 1);
+ q.pop();
+ assert(q.empty());
+}
diff --git a/test/std/containers/container.adaptors/priority.queue/priqueue.members/push.pass.cpp b/test/std/containers/container.adaptors/priority.queue/priqueue.members/push.pass.cpp
new file mode 100644
index 000000000000..288e858f93f7
--- /dev/null
+++ b/test/std/containers/container.adaptors/priority.queue/priqueue.members/push.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// priority_queue();
+
+// void push(const value_type& v);
+
+#include <queue>
+#include <cassert>
+
+int main()
+{
+ std::priority_queue<int> q;
+ q.push(1);
+ assert(q.top() == 1);
+ q.push(3);
+ assert(q.top() == 3);
+ q.push(2);
+ assert(q.top() == 3);
+}
diff --git a/test/std/containers/container.adaptors/priority.queue/priqueue.members/push_rvalue.pass.cpp b/test/std/containers/container.adaptors/priority.queue/priqueue.members/push_rvalue.pass.cpp
new file mode 100644
index 000000000000..4b20a9bf905f
--- /dev/null
+++ b/test/std/containers/container.adaptors/priority.queue/priqueue.members/push_rvalue.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// priority_queue();
+
+// void push(value_type&& v);
+
+#include <queue>
+#include <cassert>
+
+#include "MoveOnly.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ std::priority_queue<MoveOnly> q;
+ q.push(1);
+ assert(q.top() == 1);
+ q.push(3);
+ assert(q.top() == 3);
+ q.push(2);
+ assert(q.top() == 3);
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/container.adaptors/priority.queue/priqueue.members/size.pass.cpp b/test/std/containers/container.adaptors/priority.queue/priqueue.members/size.pass.cpp
new file mode 100644
index 000000000000..0ed579e060bb
--- /dev/null
+++ b/test/std/containers/container.adaptors/priority.queue/priqueue.members/size.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// priority_queue();
+
+// size_type size() const;
+
+#include <queue>
+#include <cassert>
+
+int main()
+{
+ std::priority_queue<int> q;
+ assert(q.size() == 0);
+ q.push(1);
+ assert(q.size() == 1);
+ q.pop();
+ assert(q.size() == 0);
+}
diff --git a/test/std/containers/container.adaptors/priority.queue/priqueue.members/swap.pass.cpp b/test/std/containers/container.adaptors/priority.queue/priqueue.members/swap.pass.cpp
new file mode 100644
index 000000000000..397d67fab521
--- /dev/null
+++ b/test/std/containers/container.adaptors/priority.queue/priqueue.members/swap.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// priority_queue();
+
+// void swap(priority_queue& q);
+
+#include <queue>
+#include <cassert>
+
+int main()
+{
+ std::priority_queue<int> q1;
+ std::priority_queue<int> q2;
+ q1.push(1);
+ q1.push(3);
+ q1.push(2);
+ q1.swap(q2);
+ assert(q1.empty());
+ assert(q2.size() == 3);
+ assert(q2.top() == 3);
+}
diff --git a/test/std/containers/container.adaptors/priority.queue/priqueue.members/top.pass.cpp b/test/std/containers/container.adaptors/priority.queue/priqueue.members/top.pass.cpp
new file mode 100644
index 000000000000..eddbb926d20f
--- /dev/null
+++ b/test/std/containers/container.adaptors/priority.queue/priqueue.members/top.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// priority_queue();
+
+// const_reference top() const;
+
+#include <queue>
+#include <cassert>
+
+int main()
+{
+ std::priority_queue<int> q;
+ q.push(1);
+ assert(q.top() == 1);
+ q.push(3);
+ assert(q.top() == 3);
+ q.push(2);
+ assert(q.top() == 3);
+}
diff --git a/test/std/containers/container.adaptors/priority.queue/priqueue.special/swap.pass.cpp b/test/std/containers/container.adaptors/priority.queue/priqueue.special/swap.pass.cpp
new file mode 100644
index 000000000000..1a828adde351
--- /dev/null
+++ b/test/std/containers/container.adaptors/priority.queue/priqueue.special/swap.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// priority_queue();
+
+// template <class T, class Container, class Compare>
+// void swap(priority_queue<T, Container, Compare>& x,
+// priority_queue<T, Container, Compare>& y);
+
+#include <queue>
+#include <cassert>
+
+int main()
+{
+ std::priority_queue<int> q1;
+ std::priority_queue<int> q2;
+ q1.push(1);
+ q1.push(3);
+ q1.push(2);
+ swap(q1, q2);
+ assert(q1.empty());
+ assert(q2.size() == 3);
+ assert(q2.top() == 3);
+}
diff --git a/test/std/containers/container.adaptors/priority.queue/priqueue.special/swap_noexcept.pass.cpp b/test/std/containers/container.adaptors/priority.queue/priqueue.special/swap_noexcept.pass.cpp
new file mode 100644
index 000000000000..4d2b441c60ee
--- /dev/null
+++ b/test/std/containers/container.adaptors/priority.queue/priqueue.special/swap_noexcept.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// void swap(priority_queue& c)
+// noexcept(__is_nothrow_swappable<container_type>::value &&
+// __is_nothrow_swappable<Compare>::value);
+
+// This tests a conforming extension
+
+#include <queue>
+#include <cassert>
+
+#include "MoveOnly.h"
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::priority_queue<MoveOnly> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+#endif
+}
diff --git a/test/std/containers/container.adaptors/priority.queue/types.pass.cpp b/test/std/containers/container.adaptors/priority.queue/types.pass.cpp
new file mode 100644
index 000000000000..ade20d47d4e3
--- /dev/null
+++ b/test/std/containers/container.adaptors/priority.queue/types.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class T, class Container = vector<T>,
+// class Compare = less<typename Container::value_type>>
+// class priority_queue
+// {
+// public:
+// typedef Container container_type;
+// typedef typename container_type::value_type value_type;
+// typedef typename container_type::reference reference;
+// typedef typename container_type::const_reference const_reference;
+// typedef typename container_type::size_type size_type;
+//
+// protected:
+// container_type c;
+// Compare comp;
+
+#include <queue>
+#include <cassert>
+#include <type_traits>
+
+struct test
+ : private std::priority_queue<int>
+{
+ test()
+ {
+ c.push_back(1);
+ assert(comp(1, 2));
+ }
+};
+
+struct C
+{
+ typedef int value_type;
+ typedef int& reference;
+ typedef const int& const_reference;
+ typedef int size_type;
+};
+
+int main()
+{
+ static_assert((std::is_same<std::priority_queue<int>::container_type, std::vector<int> >::value), "");
+ static_assert((std::is_same<std::priority_queue<double, std::deque<int> >::container_type, std::deque<int> >::value), "");
+ static_assert((std::is_same<std::priority_queue<double, std::deque<int> >::value_type, int>::value), "");
+ static_assert((std::is_same<std::priority_queue<int>::reference, std::vector<int>::reference>::value), "");
+ static_assert((std::is_same<std::priority_queue<int>::const_reference, std::vector<int>::const_reference>::value), "");
+ static_assert((std::is_same<std::priority_queue<int>::size_type, std::vector<int>::size_type>::value), "");
+ static_assert((std::uses_allocator<std::priority_queue<int>, std::allocator<int> >::value), "");
+ static_assert((!std::uses_allocator<std::priority_queue<int, C>, std::allocator<int> >::value), "");
+ test t;
+}
diff --git a/test/std/containers/container.adaptors/queue/queue.cons.alloc/ctor_alloc.pass.cpp b/test/std/containers/container.adaptors/queue/queue.cons.alloc/ctor_alloc.pass.cpp
new file mode 100644
index 000000000000..b3ee758182a5
--- /dev/null
+++ b/test/std/containers/container.adaptors/queue/queue.cons.alloc/ctor_alloc.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class Alloc>
+// explicit queue(const Alloc& a);
+
+#include <queue>
+#include <cassert>
+
+#include "test_allocator.h"
+
+struct test
+ : private std::queue<int, std::deque<int, test_allocator<int> > >
+{
+ typedef std::queue<int, std::deque<int, test_allocator<int> > > base;
+
+ explicit test(const test_allocator<int>& a) : base(a) {}
+ test(const container_type& c, const test_allocator<int>& a) : base(c, a) {}
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ test(container_type&& c, const test_allocator<int>& a) : base(std::move(c), a) {}
+ test(test&& q, const test_allocator<int>& a) : base(std::move(q), a) {}
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ test_allocator<int> get_allocator() {return c.get_allocator();}
+};
+
+int main()
+{
+ test q(test_allocator<int>(3));
+ assert(q.get_allocator() == test_allocator<int>(3));
+}
diff --git a/test/std/containers/container.adaptors/queue/queue.cons.alloc/ctor_container_alloc.pass.cpp b/test/std/containers/container.adaptors/queue/queue.cons.alloc/ctor_container_alloc.pass.cpp
new file mode 100644
index 000000000000..16ba1747dd8a
--- /dev/null
+++ b/test/std/containers/container.adaptors/queue/queue.cons.alloc/ctor_container_alloc.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class Alloc>
+// queue(const container_type& c, const Alloc& a);
+
+#include <queue>
+#include <cassert>
+
+#include "test_allocator.h"
+
+template <class C>
+C
+make(int n)
+{
+ C c;
+ for (int i = 0; i < n; ++i)
+ c.push_back(i);
+ return c;
+}
+
+typedef std::deque<int, test_allocator<int> > C;
+
+struct test
+ : public std::queue<int, C>
+{
+ typedef std::queue<int, C> base;
+
+ explicit test(const test_allocator<int>& a) : base(a) {}
+ test(const container_type& c, const test_allocator<int>& a) : base(c, a) {}
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ test(container_type&& c, const test_allocator<int>& a) : base(std::move(c), a) {}
+ test(test&& q, const test_allocator<int>& a) : base(std::move(q), a) {}
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ test_allocator<int> get_allocator() {return c.get_allocator();}
+};
+
+int main()
+{
+ C d = make<C>(5);
+ test q(d, test_allocator<int>(4));
+ assert(q.get_allocator() == test_allocator<int>(4));
+ assert(q.size() == 5);
+ for (int i = 0; i < d.size(); ++i)
+ {
+ assert(q.front() == d[i]);
+ q.pop();
+ }
+}
diff --git a/test/std/containers/container.adaptors/queue/queue.cons.alloc/ctor_queue_alloc.pass.cpp b/test/std/containers/container.adaptors/queue/queue.cons.alloc/ctor_queue_alloc.pass.cpp
new file mode 100644
index 000000000000..70eaa18f9e25
--- /dev/null
+++ b/test/std/containers/container.adaptors/queue/queue.cons.alloc/ctor_queue_alloc.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class Alloc>
+// queue(const queue& q, const Alloc& a);
+
+#include <queue>
+#include <cassert>
+
+#include "test_allocator.h"
+
+template <class C>
+C
+make(int n)
+{
+ C c;
+ for (int i = 0; i < n; ++i)
+ c.push_back(i);
+ return c;
+}
+
+typedef std::deque<int, test_allocator<int> > C;
+
+template <class T>
+struct test
+ : public std::queue<T, C>
+{
+ typedef std::queue<T, C> base;
+ typedef test_allocator<int> allocator_type;
+ typedef typename base::container_type container_type;
+
+ explicit test(const allocator_type& a) : base(a) {}
+ test(const container_type& c, const allocator_type& a) : base(c, a) {}
+ test(const test& q, const allocator_type& a) : base(q, a) {}
+ allocator_type get_allocator() {return this->c.get_allocator();}
+};
+
+int main()
+{
+ test<int> q(make<C>(5), test_allocator<int>(4));
+ test<int> q2(q, test_allocator<int>(5));
+ assert(q2.get_allocator() == test_allocator<int>(5));
+ assert(q2.size() == 5);
+}
diff --git a/test/std/containers/container.adaptors/queue/queue.cons.alloc/ctor_rcontainer_alloc.pass.cpp b/test/std/containers/container.adaptors/queue/queue.cons.alloc/ctor_rcontainer_alloc.pass.cpp
new file mode 100644
index 000000000000..0163588efa50
--- /dev/null
+++ b/test/std/containers/container.adaptors/queue/queue.cons.alloc/ctor_rcontainer_alloc.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class Alloc>
+// queue(const container_type& c, const Alloc& a);
+
+#include <queue>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "MoveOnly.h"
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class C>
+C
+make(int n)
+{
+ C c;
+ for (int i = 0; i < n; ++i)
+ c.push_back(MoveOnly(i));
+ return c;
+}
+
+typedef std::deque<MoveOnly, test_allocator<MoveOnly> > C;
+
+template <class T>
+struct test
+ : public std::queue<T, C>
+{
+ typedef std::queue<T, C> base;
+ typedef test_allocator<MoveOnly> allocator_type;
+ typedef typename base::container_type container_type;
+
+ explicit test(const allocator_type& a) : base(a) {}
+ test(const container_type& c, const allocator_type& a) : base(c, a) {}
+ test(container_type&& c, const allocator_type& a) : base(std::move(c), a) {}
+ test(test&& q, const allocator_type& a) : base(std::move(q), a) {}
+ allocator_type get_allocator() {return this->c.get_allocator();}
+};
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ test<MoveOnly> q(make<C>(5), test_allocator<MoveOnly>(4));
+ assert(q.get_allocator() == test_allocator<MoveOnly>(4));
+ assert(q.size() == 5);
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/container.adaptors/queue/queue.cons.alloc/ctor_rqueue_alloc.pass.cpp b/test/std/containers/container.adaptors/queue/queue.cons.alloc/ctor_rqueue_alloc.pass.cpp
new file mode 100644
index 000000000000..7237bf271b0c
--- /dev/null
+++ b/test/std/containers/container.adaptors/queue/queue.cons.alloc/ctor_rqueue_alloc.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class Alloc>
+// queue(queue&& q, const Alloc& a);
+
+#include <queue>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "MoveOnly.h"
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class C>
+C
+make(int n)
+{
+ C c;
+ for (int i = 0; i < n; ++i)
+ c.push_back(MoveOnly(i));
+ return c;
+}
+
+typedef std::deque<MoveOnly, test_allocator<MoveOnly> > C;
+
+template <class T>
+struct test
+ : public std::queue<T, C>
+{
+ typedef std::queue<T, C> base;
+ typedef test_allocator<MoveOnly> allocator_type;
+ typedef typename base::container_type container_type;
+
+ explicit test(const allocator_type& a) : base(a) {}
+ test(const container_type& c, const allocator_type& a) : base(c, a) {}
+ test(container_type&& c, const allocator_type& a) : base(std::move(c), a) {}
+ test(test&& q, const allocator_type& a) : base(std::move(q), a) {}
+ allocator_type get_allocator() {return this->c.get_allocator();}
+};
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ test<MoveOnly> q(make<C>(5), test_allocator<MoveOnly>(4));
+ test<MoveOnly> q2(std::move(q), test_allocator<MoveOnly>(5));
+ assert(q2.get_allocator() == test_allocator<MoveOnly>(5));
+ assert(q2.size() == 5);
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/container.adaptors/queue/queue.cons/ctor_container.pass.cpp b/test/std/containers/container.adaptors/queue/queue.cons/ctor_container.pass.cpp
new file mode 100644
index 000000000000..c4ab955c311b
--- /dev/null
+++ b/test/std/containers/container.adaptors/queue/queue.cons/ctor_container.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// explicit queue(const container_type& c);
+
+#include <queue>
+#include <cassert>
+
+template <class C>
+C
+make(int n)
+{
+ C c;
+ for (int i = 0; i < n; ++i)
+ c.push_back(i);
+ return c;
+}
+
+int main()
+{
+ std::deque<int> d = make<std::deque<int> >(5);
+ std::queue<int> q(d);
+ assert(q.size() == 5);
+ for (int i = 0; i < d.size(); ++i)
+ {
+ assert(q.front() == d[i]);
+ q.pop();
+ }
+}
diff --git a/test/std/containers/container.adaptors/queue/queue.cons/ctor_copy.pass.cpp b/test/std/containers/container.adaptors/queue/queue.cons/ctor_copy.pass.cpp
new file mode 100644
index 000000000000..998f849797cd
--- /dev/null
+++ b/test/std/containers/container.adaptors/queue/queue.cons/ctor_copy.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// queue(const queue&) = default;
+
+#include <queue>
+#include <cassert>
+
+template <class C>
+C
+make(int n)
+{
+ C c;
+ for (int i = 0; i < n; ++i)
+ c.push_back(i);
+ return c;
+}
+
+int main()
+{
+ std::queue<int> q(make<std::deque<int> >(5));
+ std::queue<int> q2 = q;
+ assert(q2 == q);
+}
diff --git a/test/std/containers/container.adaptors/queue/queue.cons/ctor_default.pass.cpp b/test/std/containers/container.adaptors/queue/queue.cons/ctor_default.pass.cpp
new file mode 100644
index 000000000000..e6aadd39dd9b
--- /dev/null
+++ b/test/std/containers/container.adaptors/queue/queue.cons/ctor_default.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// queue();
+
+#include <queue>
+#include <cassert>
+
+#include "../../../stack_allocator.h"
+
+int main()
+{
+ std::queue<int, std::vector<int, stack_allocator<int, 10> > > q;
+ assert(q.size() == 0);
+ q.push(1);
+ q.push(2);
+ assert(q.size() == 2);
+ assert(q.front() == 1);
+ assert(q.back() == 2);
+}
diff --git a/test/std/containers/container.adaptors/queue/queue.cons/ctor_move.pass.cpp b/test/std/containers/container.adaptors/queue/queue.cons/ctor_move.pass.cpp
new file mode 100644
index 000000000000..8dd5d2f64ec3
--- /dev/null
+++ b/test/std/containers/container.adaptors/queue/queue.cons/ctor_move.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// queue(queue&& q);
+
+#include <queue>
+#include <cassert>
+
+#include "MoveOnly.h"
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class C>
+C
+make(int n)
+{
+ C c;
+ for (int i = 0; i < n; ++i)
+ c.push_back(MoveOnly(i));
+ return c;
+}
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ std::queue<MoveOnly> q(make<std::deque<MoveOnly> >(5));
+ std::queue<MoveOnly> q2 = std::move(q);
+ assert(q2.size() == 5);
+ assert(q.empty());
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/container.adaptors/queue/queue.cons/ctor_rcontainer.pass.cpp b/test/std/containers/container.adaptors/queue/queue.cons/ctor_rcontainer.pass.cpp
new file mode 100644
index 000000000000..f72067b0adcc
--- /dev/null
+++ b/test/std/containers/container.adaptors/queue/queue.cons/ctor_rcontainer.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// explicit queue(container_type&& c);
+
+#include <queue>
+#include <cassert>
+
+#include "MoveOnly.h"
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class C>
+C
+make(int n)
+{
+ C c;
+ for (int i = 0; i < n; ++i)
+ c.push_back(MoveOnly(i));
+ return c;
+}
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ std::queue<MoveOnly> q(make<std::deque<MoveOnly> >(5));
+ assert(q.size() == 5);
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/container.adaptors/queue/queue.cons/default_noexcept.pass.cpp b/test/std/containers/container.adaptors/queue/queue.cons/default_noexcept.pass.cpp
new file mode 100644
index 000000000000..392853432669
--- /dev/null
+++ b/test/std/containers/container.adaptors/queue/queue.cons/default_noexcept.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// queue()
+// noexcept(is_nothrow_default_constructible<container_type>::value);
+
+// This tests a conforming extension
+
+#include <queue>
+#include <cassert>
+
+#include "MoveOnly.h"
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::queue<MoveOnly> C;
+ static_assert(std::is_nothrow_default_constructible<C>::value, "");
+ }
+#endif
+}
diff --git a/test/std/containers/container.adaptors/queue/queue.cons/dtor_noexcept.pass.cpp b/test/std/containers/container.adaptors/queue/queue.cons/dtor_noexcept.pass.cpp
new file mode 100644
index 000000000000..d9b8f731f28a
--- /dev/null
+++ b/test/std/containers/container.adaptors/queue/queue.cons/dtor_noexcept.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// ~queue() // implied noexcept;
+
+#include <queue>
+#include <cassert>
+
+#include "MoveOnly.h"
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::queue<MoveOnly> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+#endif
+}
diff --git a/test/std/containers/container.adaptors/queue/queue.cons/move_assign_noexcept.pass.cpp b/test/std/containers/container.adaptors/queue/queue.cons/move_assign_noexcept.pass.cpp
new file mode 100644
index 000000000000..beef0f12ffb7
--- /dev/null
+++ b/test/std/containers/container.adaptors/queue/queue.cons/move_assign_noexcept.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// queue& operator=(queue&& c)
+// noexcept(is_nothrow_move_assignable<container_type>::value);
+
+// This tests a conforming extension
+
+#include <queue>
+#include <cassert>
+
+#include "MoveOnly.h"
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::queue<MoveOnly> C;
+ static_assert(std::is_nothrow_move_assignable<C>::value, "");
+ }
+#endif
+}
diff --git a/test/std/containers/container.adaptors/queue/queue.cons/move_noexcept.pass.cpp b/test/std/containers/container.adaptors/queue/queue.cons/move_noexcept.pass.cpp
new file mode 100644
index 000000000000..2402e609b988
--- /dev/null
+++ b/test/std/containers/container.adaptors/queue/queue.cons/move_noexcept.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// queue(queue&&)
+// noexcept(is_nothrow_move_constructible<container_type>::value);
+
+// This tests a conforming extension
+
+#include <queue>
+#include <cassert>
+
+#include "MoveOnly.h"
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::queue<MoveOnly> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+#endif
+}
diff --git a/test/std/containers/container.adaptors/queue/queue.defn/assign_copy.pass.cpp b/test/std/containers/container.adaptors/queue/queue.defn/assign_copy.pass.cpp
new file mode 100644
index 000000000000..e9afa0b8c61f
--- /dev/null
+++ b/test/std/containers/container.adaptors/queue/queue.defn/assign_copy.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// queue& operator=(const queue& q);
+
+#include <queue>
+#include <cassert>
+
+template <class C>
+C
+make(int n)
+{
+ C c;
+ for (int i = 0; i < n; ++i)
+ c.push_back(i);
+ return c;
+}
+
+int main()
+{
+ std::queue<int> q(make<std::deque<int> >(5));
+ std::queue<int> q2;
+ q2 = q;
+ assert(q2 == q);
+}
diff --git a/test/std/containers/container.adaptors/queue/queue.defn/assign_move.pass.cpp b/test/std/containers/container.adaptors/queue/queue.defn/assign_move.pass.cpp
new file mode 100644
index 000000000000..af1b7e20c338
--- /dev/null
+++ b/test/std/containers/container.adaptors/queue/queue.defn/assign_move.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// queue& operator=(queue&& q);
+
+#include <queue>
+#include <cassert>
+
+#include "MoveOnly.h"
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class C>
+C
+make(int n)
+{
+ C c;
+ for (int i = 0; i < n; ++i)
+ c.push_back(MoveOnly(i));
+ return c;
+}
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ std::queue<MoveOnly> q(make<std::deque<MoveOnly> >(5));
+ std::queue<MoveOnly> q2;
+ q2 = std::move(q);
+ assert(q2.size() == 5);
+ assert(q.empty());
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/container.adaptors/queue/queue.defn/back.pass.cpp b/test/std/containers/container.adaptors/queue/queue.defn/back.pass.cpp
new file mode 100644
index 000000000000..e91edc28308e
--- /dev/null
+++ b/test/std/containers/container.adaptors/queue/queue.defn/back.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// reference back();
+
+#include <queue>
+#include <cassert>
+
+int main()
+{
+ std::queue<int> q;
+ assert(q.size() == 0);
+ q.push(1);
+ q.push(2);
+ q.push(3);
+ int& ir = q.back();
+ assert(ir == 3);
+}
diff --git a/test/std/containers/container.adaptors/queue/queue.defn/back_const.pass.cpp b/test/std/containers/container.adaptors/queue/queue.defn/back_const.pass.cpp
new file mode 100644
index 000000000000..f2696e903fe9
--- /dev/null
+++ b/test/std/containers/container.adaptors/queue/queue.defn/back_const.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// const_reference back() const;
+
+#include <queue>
+#include <cassert>
+
+int main()
+{
+ std::queue<int> q;
+ assert(q.size() == 0);
+ q.push(1);
+ q.push(2);
+ q.push(3);
+ const std::queue<int>& cqr = q;
+ const int& cir = cqr.back();
+ assert(cir == 3);
+}
diff --git a/test/std/containers/container.adaptors/queue/queue.defn/emplace.pass.cpp b/test/std/containers/container.adaptors/queue/queue.defn/emplace.pass.cpp
new file mode 100644
index 000000000000..1d9c08b156b7
--- /dev/null
+++ b/test/std/containers/container.adaptors/queue/queue.defn/emplace.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class... Args> void emplace(Args&&... args);
+
+#include <queue>
+#include <cassert>
+
+#include "../../../Emplaceable.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ std::queue<Emplaceable> q;
+ q.emplace(1, 2.5);
+ q.emplace(2, 3.5);
+ q.emplace(3, 4.5);
+ assert(q.size() == 3);
+ assert(q.front() == Emplaceable(1, 2.5));
+ assert(q.back() == Emplaceable(3, 4.5));
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/container.adaptors/queue/queue.defn/empty.pass.cpp b/test/std/containers/container.adaptors/queue/queue.defn/empty.pass.cpp
new file mode 100644
index 000000000000..deac5fa4d0e2
--- /dev/null
+++ b/test/std/containers/container.adaptors/queue/queue.defn/empty.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// bool empty() const;
+
+#include <queue>
+#include <cassert>
+
+int main()
+{
+ std::queue<int> q;
+ assert(q.empty());
+ q.push(1);
+ assert(!q.empty());
+ q.pop();
+ assert(q.empty());
+}
diff --git a/test/std/containers/container.adaptors/queue/queue.defn/front.pass.cpp b/test/std/containers/container.adaptors/queue/queue.defn/front.pass.cpp
new file mode 100644
index 000000000000..4fbbb0053860
--- /dev/null
+++ b/test/std/containers/container.adaptors/queue/queue.defn/front.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// reference front();
+
+#include <queue>
+#include <cassert>
+
+int main()
+{
+ std::queue<int> q;
+ assert(q.size() == 0);
+ q.push(1);
+ q.push(2);
+ q.push(3);
+ int& ir = q.front();
+ assert(ir == 1);
+}
diff --git a/test/std/containers/container.adaptors/queue/queue.defn/front_const.pass.cpp b/test/std/containers/container.adaptors/queue/queue.defn/front_const.pass.cpp
new file mode 100644
index 000000000000..253a27817eb0
--- /dev/null
+++ b/test/std/containers/container.adaptors/queue/queue.defn/front_const.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// const_reference front() const;
+
+#include <queue>
+#include <cassert>
+
+int main()
+{
+ std::queue<int> q;
+ assert(q.size() == 0);
+ q.push(1);
+ q.push(2);
+ q.push(3);
+ const std::queue<int>& cqr = q;
+ const int& cir = cqr.front();
+ assert(cir == 1);
+}
diff --git a/test/std/containers/container.adaptors/queue/queue.defn/pop.pass.cpp b/test/std/containers/container.adaptors/queue/queue.defn/pop.pass.cpp
new file mode 100644
index 000000000000..3da2d122f341
--- /dev/null
+++ b/test/std/containers/container.adaptors/queue/queue.defn/pop.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// void pop();
+
+#include <queue>
+#include <cassert>
+
+int main()
+{
+ std::queue<int> q;
+ assert(q.size() == 0);
+ q.push(1);
+ q.push(2);
+ q.push(3);
+ assert(q.size() == 3);
+ assert(q.front() == 1);
+ assert(q.back() == 3);
+ q.pop();
+ assert(q.size() == 2);
+ assert(q.front() == 2);
+ assert(q.back() == 3);
+ q.pop();
+ assert(q.size() == 1);
+ assert(q.front() == 3);
+ assert(q.back() == 3);
+ q.pop();
+ assert(q.size() == 0);
+}
diff --git a/test/std/containers/container.adaptors/queue/queue.defn/push.pass.cpp b/test/std/containers/container.adaptors/queue/queue.defn/push.pass.cpp
new file mode 100644
index 000000000000..9d462954c297
--- /dev/null
+++ b/test/std/containers/container.adaptors/queue/queue.defn/push.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// void push(const value_type& v);
+
+#include <queue>
+#include <cassert>
+
+int main()
+{
+ std::queue<int> q;
+ q.push(1);
+ assert(q.size() == 1);
+ assert(q.front() == 1);
+ assert(q.back() == 1);
+ q.push(2);
+ assert(q.size() == 2);
+ assert(q.front() == 1);
+ assert(q.back() == 2);
+ q.push(3);
+ assert(q.size() == 3);
+ assert(q.front() == 1);
+ assert(q.back() == 3);
+}
diff --git a/test/std/containers/container.adaptors/queue/queue.defn/push_rv.pass.cpp b/test/std/containers/container.adaptors/queue/queue.defn/push_rv.pass.cpp
new file mode 100644
index 000000000000..d8992821f1f2
--- /dev/null
+++ b/test/std/containers/container.adaptors/queue/queue.defn/push_rv.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// void push(value_type&& v);
+
+#include <queue>
+#include <cassert>
+
+#include "MoveOnly.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ std::queue<MoveOnly> q;
+ q.push(MoveOnly(1));
+ assert(q.size() == 1);
+ assert(q.front() == MoveOnly(1));
+ assert(q.back() == MoveOnly(1));
+ q.push(MoveOnly(2));
+ assert(q.size() == 2);
+ assert(q.front() == MoveOnly(1));
+ assert(q.back() == MoveOnly(2));
+ q.push(MoveOnly(3));
+ assert(q.size() == 3);
+ assert(q.front() == MoveOnly(1));
+ assert(q.back() == MoveOnly(3));
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/container.adaptors/queue/queue.defn/size.pass.cpp b/test/std/containers/container.adaptors/queue/queue.defn/size.pass.cpp
new file mode 100644
index 000000000000..1c72408f469f
--- /dev/null
+++ b/test/std/containers/container.adaptors/queue/queue.defn/size.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// size_type size() const;
+
+#include <queue>
+#include <cassert>
+
+int main()
+{
+ std::queue<int> q;
+ assert(q.size() == 0);
+ q.push(1);
+ assert(q.size() == 1);
+}
diff --git a/test/std/containers/container.adaptors/queue/queue.defn/swap.pass.cpp b/test/std/containers/container.adaptors/queue/queue.defn/swap.pass.cpp
new file mode 100644
index 000000000000..e07449397485
--- /dev/null
+++ b/test/std/containers/container.adaptors/queue/queue.defn/swap.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// void swap(queue& q);
+
+#include <queue>
+#include <cassert>
+
+template <class C>
+C
+make(int n)
+{
+ C c;
+ for (int i = 0; i < n; ++i)
+ c.push(i);
+ return c;
+}
+
+int main()
+{
+ std::queue<int> q1 = make<std::queue<int> >(5);
+ std::queue<int> q2 = make<std::queue<int> >(10);
+ std::queue<int> q1_save = q1;
+ std::queue<int> q2_save = q2;
+ q1.swap(q2);
+ assert(q1 == q2_save);
+ assert(q2 == q1_save);
+}
diff --git a/test/std/containers/container.adaptors/queue/queue.defn/types.pass.cpp b/test/std/containers/container.adaptors/queue/queue.defn/types.pass.cpp
new file mode 100644
index 000000000000..cc918a361707
--- /dev/null
+++ b/test/std/containers/container.adaptors/queue/queue.defn/types.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class T, class Container = deque<T>>
+// class queue
+// {
+// public:
+// typedef Container container_type;
+// typedef typename container_type::value_type value_type;
+// typedef typename container_type::reference reference;
+// typedef typename container_type::const_reference const_reference;
+// typedef typename container_type::size_type size_type;
+//
+// protected:
+// container_type c;
+// ...
+// };
+
+#include <queue>
+#include <type_traits>
+
+struct test
+ : private std::queue<int>
+{
+ test()
+ {
+ c.push_back(1);
+ }
+};
+
+struct C
+{
+ typedef int value_type;
+ typedef int& reference;
+ typedef const int& const_reference;
+ typedef int size_type;
+};
+
+int main()
+{
+ static_assert((std::is_same<std::queue<int>::container_type, std::deque<int> >::value), "");
+ static_assert((std::is_same<std::queue<double, std::vector<int> >::container_type, std::vector<int> >::value), "");
+ static_assert((std::is_same<std::queue<double, std::vector<int> >::value_type, int>::value), "");
+ static_assert((std::is_same<std::queue<int>::reference, std::deque<int>::reference>::value), "");
+ static_assert((std::is_same<std::queue<int>::const_reference, std::deque<int>::const_reference>::value), "");
+ static_assert((std::is_same<std::queue<int>::size_type, std::deque<int>::size_type>::value), "");
+ static_assert((std::uses_allocator<std::queue<int>, std::allocator<int> >::value), "");
+ static_assert((!std::uses_allocator<std::queue<int, C>, std::allocator<int> >::value), "");
+ test t;
+}
diff --git a/test/std/containers/container.adaptors/queue/queue.ops/eq.pass.cpp b/test/std/containers/container.adaptors/queue/queue.ops/eq.pass.cpp
new file mode 100644
index 000000000000..a2ad32fec147
--- /dev/null
+++ b/test/std/containers/container.adaptors/queue/queue.ops/eq.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class T, class Container>
+// bool operator==(const queue<T, Container>& x,const queue<T, Container>& y);
+//
+// template <class T, class Container>
+// bool operator!=(const queue<T, Container>& x,const queue<T, Container>& y);
+
+#include <queue>
+#include <cassert>
+
+template <class C>
+C
+make(int n)
+{
+ C c;
+ for (int i = 0; i < n; ++i)
+ c.push(i);
+ return c;
+}
+
+int main()
+{
+ std::queue<int> q1 = make<std::queue<int> >(5);
+ std::queue<int> q2 = make<std::queue<int> >(10);
+ std::queue<int> q1_save = q1;
+ std::queue<int> q2_save = q2;
+ assert(q1 == q1_save);
+ assert(q1 != q2);
+ assert(q2 == q2_save);
+}
diff --git a/test/std/containers/container.adaptors/queue/queue.ops/lt.pass.cpp b/test/std/containers/container.adaptors/queue/queue.ops/lt.pass.cpp
new file mode 100644
index 000000000000..af08cbaca48e
--- /dev/null
+++ b/test/std/containers/container.adaptors/queue/queue.ops/lt.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class T, class Container>
+// bool operator< (const queue<T, Container>& x,const queue<T, Container>& y);
+//
+// template <class T, class Container>
+// bool operator> (const queue<T, Container>& x,const queue<T, Container>& y);
+//
+// template <class T, class Container>
+// bool operator>=(const queue<T, Container>& x,const queue<T, Container>& y);
+//
+// template <class T, class Container>
+// bool operator<=(const queue<T, Container>& x,const queue<T, Container>& y);
+
+#include <queue>
+#include <cassert>
+
+template <class C>
+C
+make(int n)
+{
+ C c;
+ for (int i = 0; i < n; ++i)
+ c.push(i);
+ return c;
+}
+
+int main()
+{
+ std::queue<int> q1 = make<std::queue<int> >(5);
+ std::queue<int> q2 = make<std::queue<int> >(10);
+ assert(q1 < q2);
+ assert(q2 > q1);
+ assert(q1 <= q2);
+ assert(q2 >= q1);
+}
diff --git a/test/std/containers/container.adaptors/queue/queue.special/swap.pass.cpp b/test/std/containers/container.adaptors/queue/queue.special/swap.pass.cpp
new file mode 100644
index 000000000000..a3f7c43b792b
--- /dev/null
+++ b/test/std/containers/container.adaptors/queue/queue.special/swap.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class T, class Container>
+// void swap(queue<T, Container>& x, queue<T, Container>& y);
+
+#include <queue>
+#include <cassert>
+
+template <class C>
+C
+make(int n)
+{
+ C c;
+ for (int i = 0; i < n; ++i)
+ c.push(i);
+ return c;
+}
+
+int main()
+{
+ std::queue<int> q1 = make<std::queue<int> >(5);
+ std::queue<int> q2 = make<std::queue<int> >(10);
+ std::queue<int> q1_save = q1;
+ std::queue<int> q2_save = q2;
+ swap(q1, q2);
+ assert(q1 == q2_save);
+ assert(q2 == q1_save);
+}
diff --git a/test/std/containers/container.adaptors/queue/queue.special/swap_noexcept.pass.cpp b/test/std/containers/container.adaptors/queue/queue.special/swap_noexcept.pass.cpp
new file mode 100644
index 000000000000..cfe4a1bb7076
--- /dev/null
+++ b/test/std/containers/container.adaptors/queue/queue.special/swap_noexcept.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// void swap(queue& c)
+// noexcept(__is_nothrow_swappable<container_type>::value);
+
+// This tests a conforming extension
+
+#include <queue>
+#include <cassert>
+
+#include "MoveOnly.h"
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::queue<MoveOnly> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+#endif
+}
diff --git a/test/std/containers/container.adaptors/queue/version.pass.cpp b/test/std/containers/container.adaptors/queue/version.pass.cpp
new file mode 100644
index 000000000000..35b94b33c517
--- /dev/null
+++ b/test/std/containers/container.adaptors/queue/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+#include <queue>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_alloc.pass.cpp b/test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_alloc.pass.cpp
new file mode 100644
index 000000000000..94899d4f1b54
--- /dev/null
+++ b/test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_alloc.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// template <class Alloc>
+// explicit stack(const Alloc& a);
+
+#include <stack>
+#include <cassert>
+
+#include "test_allocator.h"
+
+struct test
+ : private std::stack<int, std::deque<int, test_allocator<int> > >
+{
+ typedef std::stack<int, std::deque<int, test_allocator<int> > > base;
+
+ explicit test(const test_allocator<int>& a) : base(a) {}
+ test(const container_type& c, const test_allocator<int>& a) : base(c, a) {}
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ test(container_type&& c, const test_allocator<int>& a) : base(std::move(c), a) {}
+ test(test&& q, const test_allocator<int>& a) : base(std::move(q), a) {}
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ test_allocator<int> get_allocator() {return c.get_allocator();}
+};
+
+int main()
+{
+ test q(test_allocator<int>(3));
+ assert(q.get_allocator() == test_allocator<int>(3));
+}
diff --git a/test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_container_alloc.pass.cpp b/test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_container_alloc.pass.cpp
new file mode 100644
index 000000000000..fe8622751c95
--- /dev/null
+++ b/test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_container_alloc.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// template <class Alloc>
+// stack(const container_type& c, const Alloc& a);
+
+#include <stack>
+#include <cassert>
+
+#include "test_allocator.h"
+
+template <class C>
+C
+make(int n)
+{
+ C c;
+ for (int i = 0; i < n; ++i)
+ c.push_back(i);
+ return c;
+}
+
+typedef std::deque<int, test_allocator<int> > C;
+
+struct test
+ : public std::stack<int, C>
+{
+ typedef std::stack<int, C> base;
+
+ explicit test(const test_allocator<int>& a) : base(a) {}
+ test(const container_type& c, const test_allocator<int>& a) : base(c, a) {}
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ test(container_type&& c, const test_allocator<int>& a) : base(std::move(c), a) {}
+ test(test&& q, const test_allocator<int>& a) : base(std::move(q), a) {}
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ test_allocator<int> get_allocator() {return c.get_allocator();}
+};
+
+int main()
+{
+ C d = make<C>(5);
+ test q(d, test_allocator<int>(4));
+ assert(q.get_allocator() == test_allocator<int>(4));
+ assert(q.size() == 5);
+ for (int i = 0; i < d.size(); ++i)
+ {
+ assert(q.top() == d[d.size() - i - 1]);
+ q.pop();
+ }
+}
diff --git a/test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_copy_alloc.pass.cpp b/test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_copy_alloc.pass.cpp
new file mode 100644
index 000000000000..33cb4dd52b3c
--- /dev/null
+++ b/test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_copy_alloc.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// template <class Alloc>
+// stack(const stack& q, const Alloc& a);
+
+#include <stack>
+#include <cassert>
+
+#include "test_allocator.h"
+
+template <class C>
+C
+make(int n)
+{
+ C c;
+ for (int i = 0; i < n; ++i)
+ c.push_back(int(i));
+ return c;
+}
+
+typedef std::deque<int, test_allocator<int> > C;
+
+template <class T>
+struct test
+ : public std::stack<T, C>
+{
+ typedef std::stack<T, C> base;
+ typedef test_allocator<int> allocator_type;
+ typedef typename base::container_type container_type;
+
+ explicit test(const allocator_type& a) : base(a) {}
+ test(const container_type& c, const allocator_type& a) : base(c, a) {}
+ test(const test& q, const allocator_type& a) : base(q, a) {}
+ allocator_type get_allocator() {return this->c.get_allocator();}
+};
+
+int main()
+{
+ test<int> q(make<C>(5), test_allocator<int>(4));
+ test<int> q2(q, test_allocator<int>(5));
+ assert(q2.get_allocator() == test_allocator<int>(5));
+ assert(q2.size() == 5);
+}
diff --git a/test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_rcontainer_alloc.pass.cpp b/test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_rcontainer_alloc.pass.cpp
new file mode 100644
index 000000000000..374aa996ffe3
--- /dev/null
+++ b/test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_rcontainer_alloc.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// template <class Alloc>
+// stack(const container_type& c, const Alloc& a);
+
+#include <stack>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "MoveOnly.h"
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class C>
+C
+make(int n)
+{
+ C c;
+ for (int i = 0; i < n; ++i)
+ c.push_back(MoveOnly(i));
+ return c;
+}
+
+typedef std::deque<MoveOnly, test_allocator<MoveOnly> > C;
+
+template <class T>
+struct test
+ : public std::stack<T, C>
+{
+ typedef std::stack<T, C> base;
+ typedef test_allocator<MoveOnly> allocator_type;
+ typedef typename base::container_type container_type;
+
+ explicit test(const allocator_type& a) : base(a) {}
+ test(const container_type& c, const allocator_type& a) : base(c, a) {}
+ test(container_type&& c, const allocator_type& a) : base(std::move(c), a) {}
+ test(test&& q, const allocator_type& a) : base(std::move(q), a) {}
+ allocator_type get_allocator() {return this->c.get_allocator();}
+};
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ test<MoveOnly> q(make<C>(5), test_allocator<MoveOnly>(4));
+ assert(q.get_allocator() == test_allocator<MoveOnly>(4));
+ assert(q.size() == 5);
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_rqueue_alloc.pass.cpp b/test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_rqueue_alloc.pass.cpp
new file mode 100644
index 000000000000..5fa5bd2a8bd2
--- /dev/null
+++ b/test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_rqueue_alloc.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// template <class Alloc>
+// stack(stack&& q, const Alloc& a);
+
+#include <stack>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "MoveOnly.h"
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class C>
+C
+make(int n)
+{
+ C c;
+ for (int i = 0; i < n; ++i)
+ c.push_back(MoveOnly(i));
+ return c;
+}
+
+typedef std::deque<MoveOnly, test_allocator<MoveOnly> > C;
+
+template <class T>
+struct test
+ : public std::stack<T, C>
+{
+ typedef std::stack<T, C> base;
+ typedef test_allocator<MoveOnly> allocator_type;
+ typedef typename base::container_type container_type;
+
+ explicit test(const allocator_type& a) : base(a) {}
+ test(const container_type& c, const allocator_type& a) : base(c, a) {}
+ test(container_type&& c, const allocator_type& a) : base(std::move(c), a) {}
+ test(test&& q, const allocator_type& a) : base(std::move(q), a) {}
+ allocator_type get_allocator() {return this->c.get_allocator();}
+};
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ test<MoveOnly> q(make<C>(5), test_allocator<MoveOnly>(4));
+ test<MoveOnly> q2(std::move(q), test_allocator<MoveOnly>(5));
+ assert(q2.get_allocator() == test_allocator<MoveOnly>(5));
+ assert(q2.size() == 5);
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/container.adaptors/stack/stack.cons/ctor_container.pass.cpp b/test/std/containers/container.adaptors/stack/stack.cons/ctor_container.pass.cpp
new file mode 100644
index 000000000000..9dc05013e3dd
--- /dev/null
+++ b/test/std/containers/container.adaptors/stack/stack.cons/ctor_container.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// explicit stack(const container_type& c);
+
+#include <stack>
+#include <cassert>
+
+template <class C>
+C
+make(int n)
+{
+ C c;
+ for (int i = 0; i < n; ++i)
+ c.push_back(i);
+ return c;
+}
+
+int main()
+{
+ std::deque<int> d = make<std::deque<int> >(5);
+ std::stack<int> q(d);
+ assert(q.size() == 5);
+ for (int i = 0; i < d.size(); ++i)
+ {
+ assert(q.top() == d[d.size() - i - 1]);
+ q.pop();
+ }
+}
diff --git a/test/std/containers/container.adaptors/stack/stack.cons/ctor_copy.pass.cpp b/test/std/containers/container.adaptors/stack/stack.cons/ctor_copy.pass.cpp
new file mode 100644
index 000000000000..8673e06ce930
--- /dev/null
+++ b/test/std/containers/container.adaptors/stack/stack.cons/ctor_copy.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// stack(const stack&) = default;
+
+#include <stack>
+#include <cassert>
+
+template <class C>
+C
+make(int n)
+{
+ C c;
+ for (int i = 0; i < n; ++i)
+ c.push_back(i);
+ return c;
+}
+
+int main()
+{
+ std::stack<int> q(make<std::deque<int> >(5));
+ std::stack<int> q2 = q;
+ assert(q2 == q);
+}
diff --git a/test/std/containers/container.adaptors/stack/stack.cons/ctor_default.pass.cpp b/test/std/containers/container.adaptors/stack/stack.cons/ctor_default.pass.cpp
new file mode 100644
index 000000000000..523cd6811893
--- /dev/null
+++ b/test/std/containers/container.adaptors/stack/stack.cons/ctor_default.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// stack();
+
+#include <stack>
+#include <vector>
+#include <cassert>
+
+#include "../../../stack_allocator.h"
+
+int main()
+{
+ std::stack<int, std::vector<int, stack_allocator<int, 10> > > q;
+ assert(q.size() == 0);
+ q.push(1);
+ q.push(2);
+ assert(q.size() == 2);
+ assert(q.top() == 2);
+}
diff --git a/test/std/containers/container.adaptors/stack/stack.cons/ctor_move.pass.cpp b/test/std/containers/container.adaptors/stack/stack.cons/ctor_move.pass.cpp
new file mode 100644
index 000000000000..44fab41a6c55
--- /dev/null
+++ b/test/std/containers/container.adaptors/stack/stack.cons/ctor_move.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// stack(stack&& q);
+
+#include <stack>
+#include <cassert>
+
+#include "MoveOnly.h"
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class C>
+C
+make(int n)
+{
+ C c;
+ for (int i = 0; i < n; ++i)
+ c.push_back(MoveOnly(i));
+ return c;
+}
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ std::stack<MoveOnly> q(make<std::deque<MoveOnly> >(5));
+ std::stack<MoveOnly> q2 = std::move(q);
+ assert(q2.size() == 5);
+ assert(q.empty());
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/container.adaptors/stack/stack.cons/ctor_rcontainer.pass.cpp b/test/std/containers/container.adaptors/stack/stack.cons/ctor_rcontainer.pass.cpp
new file mode 100644
index 000000000000..ab08da93831e
--- /dev/null
+++ b/test/std/containers/container.adaptors/stack/stack.cons/ctor_rcontainer.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// explicit stack(container_type&& c);
+
+#include <stack>
+#include <cassert>
+
+#include "MoveOnly.h"
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class C>
+C
+make(int n)
+{
+ C c;
+ for (int i = 0; i < n; ++i)
+ c.push_back(MoveOnly(i));
+ return c;
+}
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ std::stack<MoveOnly> q(make<std::deque<MoveOnly> >(5));
+ assert(q.size() == 5);
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/container.adaptors/stack/stack.cons/default_noexcept.pass.cpp b/test/std/containers/container.adaptors/stack/stack.cons/default_noexcept.pass.cpp
new file mode 100644
index 000000000000..bab55863b55f
--- /dev/null
+++ b/test/std/containers/container.adaptors/stack/stack.cons/default_noexcept.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// stack()
+// noexcept(is_nothrow_default_constructible<container_type>::value);
+
+// This tests a conforming extension
+
+#include <stack>
+#include <cassert>
+
+#include "MoveOnly.h"
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::stack<MoveOnly> C;
+ static_assert(std::is_nothrow_default_constructible<C>::value, "");
+ }
+#endif
+}
diff --git a/test/std/containers/container.adaptors/stack/stack.cons/dtor_noexcept.pass.cpp b/test/std/containers/container.adaptors/stack/stack.cons/dtor_noexcept.pass.cpp
new file mode 100644
index 000000000000..477bd57a6d10
--- /dev/null
+++ b/test/std/containers/container.adaptors/stack/stack.cons/dtor_noexcept.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// ~stack() // implied noexcept;
+
+#include <stack>
+#include <cassert>
+
+#include "MoveOnly.h"
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::stack<MoveOnly> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+#endif
+}
diff --git a/test/std/containers/container.adaptors/stack/stack.cons/move_assign_noexcept.pass.cpp b/test/std/containers/container.adaptors/stack/stack.cons/move_assign_noexcept.pass.cpp
new file mode 100644
index 000000000000..dd836796dc17
--- /dev/null
+++ b/test/std/containers/container.adaptors/stack/stack.cons/move_assign_noexcept.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// stack& operator=(stack&& c)
+// noexcept(is_nothrow_move_assignable<container_type>::value);
+
+// This tests a conforming extension
+
+#include <stack>
+#include <cassert>
+
+#include "MoveOnly.h"
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::stack<MoveOnly> C;
+ static_assert(std::is_nothrow_move_assignable<C>::value, "");
+ }
+#endif
+}
diff --git a/test/std/containers/container.adaptors/stack/stack.cons/move_noexcept.pass.cpp b/test/std/containers/container.adaptors/stack/stack.cons/move_noexcept.pass.cpp
new file mode 100644
index 000000000000..cfc660b36def
--- /dev/null
+++ b/test/std/containers/container.adaptors/stack/stack.cons/move_noexcept.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// stack(stack&&)
+// noexcept(is_nothrow_move_constructible<container_type>::value);
+
+// This tests a conforming extension
+
+#include <stack>
+#include <cassert>
+
+#include "MoveOnly.h"
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::stack<MoveOnly> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+#endif
+}
diff --git a/test/std/containers/container.adaptors/stack/stack.defn/assign_copy.pass.cpp b/test/std/containers/container.adaptors/stack/stack.defn/assign_copy.pass.cpp
new file mode 100644
index 000000000000..38769e3fb026
--- /dev/null
+++ b/test/std/containers/container.adaptors/stack/stack.defn/assign_copy.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// stack& operator=(const stack& q);
+
+#include <stack>
+#include <cassert>
+
+template <class C>
+C
+make(int n)
+{
+ C c;
+ for (int i = 0; i < n; ++i)
+ c.push_back(i);
+ return c;
+}
+
+int main()
+{
+ std::stack<int> q(make<std::deque<int> >(5));
+ std::stack<int> q2;
+ q2 = q;
+ assert(q2 == q);
+}
diff --git a/test/std/containers/container.adaptors/stack/stack.defn/assign_move.pass.cpp b/test/std/containers/container.adaptors/stack/stack.defn/assign_move.pass.cpp
new file mode 100644
index 000000000000..75cbec1c47c8
--- /dev/null
+++ b/test/std/containers/container.adaptors/stack/stack.defn/assign_move.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// stack& operator=(stack&& q);
+
+#include <stack>
+#include <cassert>
+
+#include "MoveOnly.h"
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class C>
+C
+make(int n)
+{
+ C c;
+ for (int i = 0; i < n; ++i)
+ c.push_back(MoveOnly(i));
+ return c;
+}
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ std::stack<MoveOnly> q(make<std::deque<MoveOnly> >(5));
+ std::stack<MoveOnly> q2;
+ q2 = std::move(q);
+ assert(q2.size() == 5);
+ assert(q.empty());
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/container.adaptors/stack/stack.defn/emplace.pass.cpp b/test/std/containers/container.adaptors/stack/stack.defn/emplace.pass.cpp
new file mode 100644
index 000000000000..3573c220ece9
--- /dev/null
+++ b/test/std/containers/container.adaptors/stack/stack.defn/emplace.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// template <class... Args> void emplace(Args&&... args);
+
+#include <stack>
+#include <cassert>
+
+#include "../../../Emplaceable.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ std::stack<Emplaceable> q;
+ q.emplace(1, 2.5);
+ q.emplace(2, 3.5);
+ q.emplace(3, 4.5);
+ assert(q.size() == 3);
+ assert(q.top() == Emplaceable(3, 4.5));
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/container.adaptors/stack/stack.defn/empty.pass.cpp b/test/std/containers/container.adaptors/stack/stack.defn/empty.pass.cpp
new file mode 100644
index 000000000000..a4f728174132
--- /dev/null
+++ b/test/std/containers/container.adaptors/stack/stack.defn/empty.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// bool empty() const;
+
+#include <stack>
+#include <cassert>
+
+int main()
+{
+ std::stack<int> q;
+ assert(q.empty());
+ q.push(1);
+ assert(!q.empty());
+ q.pop();
+ assert(q.empty());
+}
diff --git a/test/std/containers/container.adaptors/stack/stack.defn/pop.pass.cpp b/test/std/containers/container.adaptors/stack/stack.defn/pop.pass.cpp
new file mode 100644
index 000000000000..7ec1bf187cea
--- /dev/null
+++ b/test/std/containers/container.adaptors/stack/stack.defn/pop.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// void pop();
+
+#include <stack>
+#include <cassert>
+
+int main()
+{
+ std::stack<int> q;
+ assert(q.size() == 0);
+ q.push(1);
+ q.push(2);
+ q.push(3);
+ assert(q.size() == 3);
+ assert(q.top() == 3);
+ q.pop();
+ assert(q.size() == 2);
+ assert(q.top() == 2);
+ q.pop();
+ assert(q.size() == 1);
+ assert(q.top() == 1);
+ q.pop();
+ assert(q.size() == 0);
+}
diff --git a/test/std/containers/container.adaptors/stack/stack.defn/push.pass.cpp b/test/std/containers/container.adaptors/stack/stack.defn/push.pass.cpp
new file mode 100644
index 000000000000..6d5c90890d2e
--- /dev/null
+++ b/test/std/containers/container.adaptors/stack/stack.defn/push.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// void push(const value_type& v);
+
+#include <stack>
+#include <cassert>
+
+int main()
+{
+ std::stack<int> q;
+ q.push(1);
+ assert(q.size() == 1);
+ assert(q.top() == 1);
+ q.push(2);
+ assert(q.size() == 2);
+ assert(q.top() == 2);
+ q.push(3);
+ assert(q.size() == 3);
+ assert(q.top() == 3);
+}
diff --git a/test/std/containers/container.adaptors/stack/stack.defn/push_rv.pass.cpp b/test/std/containers/container.adaptors/stack/stack.defn/push_rv.pass.cpp
new file mode 100644
index 000000000000..67d0ea3385f6
--- /dev/null
+++ b/test/std/containers/container.adaptors/stack/stack.defn/push_rv.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// void push(value_type&& v);
+
+#include <stack>
+#include <cassert>
+
+#include "MoveOnly.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ std::stack<MoveOnly> q;
+ q.push(MoveOnly(1));
+ assert(q.size() == 1);
+ assert(q.top() == MoveOnly(1));
+ q.push(MoveOnly(2));
+ assert(q.size() == 2);
+ assert(q.top() == MoveOnly(2));
+ q.push(MoveOnly(3));
+ assert(q.size() == 3);
+ assert(q.top() == MoveOnly(3));
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/container.adaptors/stack/stack.defn/size.pass.cpp b/test/std/containers/container.adaptors/stack/stack.defn/size.pass.cpp
new file mode 100644
index 000000000000..2d8024729332
--- /dev/null
+++ b/test/std/containers/container.adaptors/stack/stack.defn/size.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// size_type size() const;
+
+#include <stack>
+#include <cassert>
+
+int main()
+{
+ std::stack<int> q;
+ assert(q.size() == 0);
+ q.push(1);
+ assert(q.size() == 1);
+}
diff --git a/test/std/containers/container.adaptors/stack/stack.defn/swap.pass.cpp b/test/std/containers/container.adaptors/stack/stack.defn/swap.pass.cpp
new file mode 100644
index 000000000000..50a29c48aa2f
--- /dev/null
+++ b/test/std/containers/container.adaptors/stack/stack.defn/swap.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// void swap(stack& q);
+
+#include <stack>
+#include <cassert>
+
+template <class C>
+C
+make(int n)
+{
+ C c;
+ for (int i = 0; i < n; ++i)
+ c.push(i);
+ return c;
+}
+
+int main()
+{
+ std::stack<int> q1 = make<std::stack<int> >(5);
+ std::stack<int> q2 = make<std::stack<int> >(10);
+ std::stack<int> q1_save = q1;
+ std::stack<int> q2_save = q2;
+ q1.swap(q2);
+ assert(q1 == q2_save);
+ assert(q2 == q1_save);
+}
diff --git a/test/std/containers/container.adaptors/stack/stack.defn/top.pass.cpp b/test/std/containers/container.adaptors/stack/stack.defn/top.pass.cpp
new file mode 100644
index 000000000000..6bde162e3ebb
--- /dev/null
+++ b/test/std/containers/container.adaptors/stack/stack.defn/top.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// reference top();
+
+#include <stack>
+#include <cassert>
+
+int main()
+{
+ std::stack<int> q;
+ assert(q.size() == 0);
+ q.push(1);
+ q.push(2);
+ q.push(3);
+ int& ir = q.top();
+ assert(ir == 3);
+}
diff --git a/test/std/containers/container.adaptors/stack/stack.defn/top_const.pass.cpp b/test/std/containers/container.adaptors/stack/stack.defn/top_const.pass.cpp
new file mode 100644
index 000000000000..8e43d05fc682
--- /dev/null
+++ b/test/std/containers/container.adaptors/stack/stack.defn/top_const.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// const_reference top() const;
+
+#include <stack>
+#include <cassert>
+
+int main()
+{
+ std::stack<int> q;
+ assert(q.size() == 0);
+ q.push(1);
+ q.push(2);
+ q.push(3);
+ const std::stack<int>& cqr = q;
+ const int& cir = cqr.top();
+ assert(cir == 3);
+}
diff --git a/test/std/containers/container.adaptors/stack/stack.defn/types.pass.cpp b/test/std/containers/container.adaptors/stack/stack.defn/types.pass.cpp
new file mode 100644
index 000000000000..afc5ebd53753
--- /dev/null
+++ b/test/std/containers/container.adaptors/stack/stack.defn/types.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// template <class T, class Container = deque<T>>
+// class stack
+// {
+// public:
+// typedef Container container_type;
+// typedef typename container_type::value_type value_type;
+// typedef typename container_type::reference reference;
+// typedef typename container_type::const_reference const_reference;
+// typedef typename container_type::size_type size_type;
+//
+// protected:
+// container_type c;
+// ...
+// };
+
+#include <stack>
+#include <vector>
+#include <type_traits>
+
+struct test
+ : private std::stack<int>
+{
+ test()
+ {
+ c.push_back(1);
+ }
+};
+
+struct C
+{
+ typedef int value_type;
+ typedef int& reference;
+ typedef const int& const_reference;
+ typedef int size_type;
+};
+
+int main()
+{
+ static_assert((std::is_same<std::stack<int>::container_type, std::deque<int> >::value), "");
+ static_assert((std::is_same<std::stack<double, std::vector<int> >::container_type, std::vector<int> >::value), "");
+ static_assert((std::is_same<std::stack<double, std::vector<int> >::value_type, int>::value), "");
+ static_assert((std::is_same<std::stack<int>::reference, std::deque<int>::reference>::value), "");
+ static_assert((std::is_same<std::stack<int>::const_reference, std::deque<int>::const_reference>::value), "");
+ static_assert((std::is_same<std::stack<int>::size_type, std::deque<int>::size_type>::value), "");
+ static_assert((std::uses_allocator<std::stack<int>, std::allocator<int> >::value), "");
+ static_assert((!std::uses_allocator<std::stack<int, C>, std::allocator<int> >::value), "");
+ test t;
+}
diff --git a/test/std/containers/container.adaptors/stack/stack.ops/eq.pass.cpp b/test/std/containers/container.adaptors/stack/stack.ops/eq.pass.cpp
new file mode 100644
index 000000000000..9b041f7f8d15
--- /dev/null
+++ b/test/std/containers/container.adaptors/stack/stack.ops/eq.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// template <class T, class Container>
+// bool operator==(const stack<T, Container>& x,const stack<T, Container>& y);
+//
+// template <class T, class Container>
+// bool operator!=(const stack<T, Container>& x,const stack<T, Container>& y);
+
+#include <stack>
+#include <cassert>
+
+template <class C>
+C
+make(int n)
+{
+ C c;
+ for (int i = 0; i < n; ++i)
+ c.push(i);
+ return c;
+}
+
+int main()
+{
+ std::stack<int> q1 = make<std::stack<int> >(5);
+ std::stack<int> q2 = make<std::stack<int> >(10);
+ std::stack<int> q1_save = q1;
+ std::stack<int> q2_save = q2;
+ assert(q1 == q1_save);
+ assert(q1 != q2);
+ assert(q2 == q2_save);
+}
diff --git a/test/std/containers/container.adaptors/stack/stack.ops/lt.pass.cpp b/test/std/containers/container.adaptors/stack/stack.ops/lt.pass.cpp
new file mode 100644
index 000000000000..beb937d4c12e
--- /dev/null
+++ b/test/std/containers/container.adaptors/stack/stack.ops/lt.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// template <class T, class Container>
+// bool operator< (const stack<T, Container>& x,const stack<T, Container>& y);
+//
+// template <class T, class Container>
+// bool operator> (const stack<T, Container>& x,const stack<T, Container>& y);
+//
+// template <class T, class Container>
+// bool operator>=(const stack<T, Container>& x,const stack<T, Container>& y);
+//
+// template <class T, class Container>
+// bool operator<=(const stack<T, Container>& x,const stack<T, Container>& y);
+
+#include <stack>
+#include <cassert>
+
+template <class C>
+C
+make(int n)
+{
+ C c;
+ for (int i = 0; i < n; ++i)
+ c.push(i);
+ return c;
+}
+
+int main()
+{
+ std::stack<int> q1 = make<std::stack<int> >(5);
+ std::stack<int> q2 = make<std::stack<int> >(10);
+ assert(q1 < q2);
+ assert(q2 > q1);
+ assert(q1 <= q2);
+ assert(q2 >= q1);
+}
diff --git a/test/std/containers/container.adaptors/stack/stack.special/swap.pass.cpp b/test/std/containers/container.adaptors/stack/stack.special/swap.pass.cpp
new file mode 100644
index 000000000000..90371146dc0b
--- /dev/null
+++ b/test/std/containers/container.adaptors/stack/stack.special/swap.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// template <class T, class Container>
+// void swap(stack<T, Container>& x, stack<T, Container>& y);
+
+#include <stack>
+#include <cassert>
+
+template <class C>
+C
+make(int n)
+{
+ C c;
+ for (int i = 0; i < n; ++i)
+ c.push(i);
+ return c;
+}
+
+int main()
+{
+ std::stack<int> q1 = make<std::stack<int> >(5);
+ std::stack<int> q2 = make<std::stack<int> >(10);
+ std::stack<int> q1_save = q1;
+ std::stack<int> q2_save = q2;
+ swap(q1, q2);
+ assert(q1 == q2_save);
+ assert(q2 == q1_save);
+}
diff --git a/test/std/containers/container.adaptors/stack/stack.special/swap_noexcept.pass.cpp b/test/std/containers/container.adaptors/stack/stack.special/swap_noexcept.pass.cpp
new file mode 100644
index 000000000000..80e024f5f1e0
--- /dev/null
+++ b/test/std/containers/container.adaptors/stack/stack.special/swap_noexcept.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// void swap(stack& c)
+// noexcept(__is_nothrow_swappable<container_type>::value);
+
+// This tests a conforming extension
+
+#include <stack>
+#include <cassert>
+
+#include "MoveOnly.h"
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::stack<MoveOnly> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+#endif
+}
diff --git a/test/std/containers/container.adaptors/stack/version.pass.cpp b/test/std/containers/container.adaptors/stack/version.pass.cpp
new file mode 100644
index 000000000000..339d0f4dda8f
--- /dev/null
+++ b/test/std/containers/container.adaptors/stack/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+#include <stack>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/containers/container.requirements/associative.reqmts/associative.reqmts.except/nothing_to_do.pass.cpp b/test/std/containers/container.requirements/associative.reqmts/associative.reqmts.except/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/containers/container.requirements/associative.reqmts/associative.reqmts.except/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/containers/container.requirements/associative.reqmts/nothing_to_do.pass.cpp b/test/std/containers/container.requirements/associative.reqmts/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/containers/container.requirements/associative.reqmts/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/containers/container.requirements/container.requirements.dataraces/nothing_to_do.pass.cpp b/test/std/containers/container.requirements/container.requirements.dataraces/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/containers/container.requirements/container.requirements.dataraces/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/containers/container.requirements/container.requirements.general/nothing_to_do.pass.cpp b/test/std/containers/container.requirements/container.requirements.general/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/containers/container.requirements/container.requirements.general/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/containers/container.requirements/nothing_to_do.pass.cpp b/test/std/containers/container.requirements/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/containers/container.requirements/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/containers/container.requirements/sequence.reqmts/nothing_to_do.pass.cpp b/test/std/containers/container.requirements/sequence.reqmts/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/containers/container.requirements/sequence.reqmts/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/containers/container.requirements/unord.req/nothing_to_do.pass.cpp b/test/std/containers/container.requirements/unord.req/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/containers/container.requirements/unord.req/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/containers/container.requirements/unord.req/unord.req.except/nothing_to_do.pass.cpp b/test/std/containers/container.requirements/unord.req/unord.req.except/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/containers/container.requirements/unord.req/unord.req.except/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/containers/containers.general/nothing_to_do.pass.cpp b/test/std/containers/containers.general/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/containers/containers.general/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/containers/nothing_to_do.pass.cpp b/test/std/containers/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/containers/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/containers/sequences/array/array.cons/default.pass.cpp b/test/std/containers/sequences/array/array.cons/default.pass.cpp
new file mode 100644
index 000000000000..7bc62b759c35
--- /dev/null
+++ b/test/std/containers/sequences/array/array.cons/default.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// array();
+
+#include <array>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ C c;
+ assert(c.size() == 3);
+ }
+ {
+ typedef double T;
+ typedef std::array<T, 0> C;
+ C c;
+ assert(c.size() == 0);
+ }
+}
diff --git a/test/std/containers/sequences/array/array.cons/initializer_list.pass.cpp b/test/std/containers/sequences/array/array.cons/initializer_list.pass.cpp
new file mode 100644
index 000000000000..b9775eef0673
--- /dev/null
+++ b/test/std/containers/sequences/array/array.cons/initializer_list.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// Construct with initizializer list
+
+#include <array>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ C c = {1, 2, 3.5};
+ assert(c.size() == 3);
+ assert(c[0] == 1);
+ assert(c[1] == 2);
+ assert(c[2] == 3.5);
+ }
+ {
+ typedef double T;
+ typedef std::array<T, 0> C;
+ C c = {};
+ assert(c.size() == 0);
+ }
+}
diff --git a/test/std/containers/sequences/array/array.data/data.pass.cpp b/test/std/containers/sequences/array/array.data/data.pass.cpp
new file mode 100644
index 000000000000..08e4fd39d377
--- /dev/null
+++ b/test/std/containers/sequences/array/array.data/data.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// T *data();
+
+#include <array>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ C c = {1, 2, 3.5};
+ T* p = c.data();
+ assert(p[0] == 1);
+ assert(p[1] == 2);
+ assert(p[2] == 3.5);
+ }
+ {
+ typedef double T;
+ typedef std::array<T, 0> C;
+ C c = {};
+ T* p = c.data();
+ (void)p; // to placate scan-build
+ }
+}
diff --git a/test/std/containers/sequences/array/array.data/data_const.pass.cpp b/test/std/containers/sequences/array/array.data/data_const.pass.cpp
new file mode 100644
index 000000000000..8eb9762dcb89
--- /dev/null
+++ b/test/std/containers/sequences/array/array.data/data_const.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// const T* data() const;
+
+#include <array>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ const C c = {1, 2, 3.5};
+ const T* p = c.data();
+ assert(p[0] == 1);
+ assert(p[1] == 2);
+ assert(p[2] == 3.5);
+ }
+ {
+ typedef double T;
+ typedef std::array<T, 0> C;
+ const C c = {};
+ const T* p = c.data();
+ (void)p; // to placate scan-build
+ }
+}
diff --git a/test/std/containers/sequences/array/array.fill/fill.pass.cpp b/test/std/containers/sequences/array/array.fill/fill.pass.cpp
new file mode 100644
index 000000000000..675f49500627
--- /dev/null
+++ b/test/std/containers/sequences/array/array.fill/fill.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// void fill(const T& u);
+
+#include <array>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ C c = {1, 2, 3.5};
+ c.fill(5.5);
+ assert(c.size() == 3);
+ assert(c[0] == 5.5);
+ assert(c[1] == 5.5);
+ assert(c[2] == 5.5);
+ }
+ {
+ typedef double T;
+ typedef std::array<T, 0> C;
+ C c = {};
+ c.fill(5.5);
+ assert(c.size() == 0);
+ }
+}
diff --git a/test/std/containers/sequences/array/array.size/size.pass.cpp b/test/std/containers/sequences/array/array.size/size.pass.cpp
new file mode 100644
index 000000000000..fe5a0d5c8db0
--- /dev/null
+++ b/test/std/containers/sequences/array/array.size/size.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// template <class T, size_t N> constexpr size_type array<T,N>::size();
+
+#include <array>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ C c = {1, 2, 3.5};
+ assert(c.size() == 3);
+ assert(c.max_size() == 3);
+ assert(!c.empty());
+ }
+ {
+ typedef double T;
+ typedef std::array<T, 0> C;
+ C c = {};
+ assert(c.size() == 0);
+ assert(c.max_size() == 0);
+ assert(c.empty());
+ }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ constexpr C c = {1, 2, 3.5};
+ static_assert(c.size() == 3, "");
+ static_assert(c.max_size() == 3, "");
+ static_assert(!c.empty(), "");
+ }
+ {
+ typedef double T;
+ typedef std::array<T, 0> C;
+ constexpr C c = {};
+ static_assert(c.size() == 0, "");
+ static_assert(c.max_size() == 0, "");
+ static_assert(c.empty(), "");
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/array/array.special/swap.pass.cpp b/test/std/containers/sequences/array/array.special/swap.pass.cpp
new file mode 100644
index 000000000000..08e437739ee6
--- /dev/null
+++ b/test/std/containers/sequences/array/array.special/swap.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// template <class T, size_t N> void swap(array<T,N>& x, array<T,N>& y);
+
+#include <array>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ C c1 = {1, 2, 3.5};
+ C c2 = {4, 5, 6.5};
+ swap(c1, c2);
+ assert(c1.size() == 3);
+ assert(c1[0] == 4);
+ assert(c1[1] == 5);
+ assert(c1[2] == 6.5);
+ assert(c2.size() == 3);
+ assert(c2[0] == 1);
+ assert(c2[1] == 2);
+ assert(c2[2] == 3.5);
+ }
+ {
+ typedef double T;
+ typedef std::array<T, 0> C;
+ C c1 = {};
+ C c2 = {};
+ swap(c1, c2);
+ assert(c1.size() == 0);
+ assert(c2.size() == 0);
+ }
+}
diff --git a/test/std/containers/sequences/array/array.swap/swap.pass.cpp b/test/std/containers/sequences/array/array.swap/swap.pass.cpp
new file mode 100644
index 000000000000..c7a4cb8df38c
--- /dev/null
+++ b/test/std/containers/sequences/array/array.swap/swap.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// void swap(array& a);
+
+#include <array>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ C c1 = {1, 2, 3.5};
+ C c2 = {4, 5, 6.5};
+ c1.swap(c2);
+ assert(c1.size() == 3);
+ assert(c1[0] == 4);
+ assert(c1[1] == 5);
+ assert(c1[2] == 6.5);
+ assert(c2.size() == 3);
+ assert(c2[0] == 1);
+ assert(c2[1] == 2);
+ assert(c2[2] == 3.5);
+ }
+ {
+ typedef double T;
+ typedef std::array<T, 0> C;
+ C c1 = {};
+ C c2 = {};
+ c1.swap(c2);
+ assert(c1.size() == 0);
+ assert(c2.size() == 0);
+ }
+}
diff --git a/test/std/containers/sequences/array/array.tuple/get.fail.cpp b/test/std/containers/sequences/array/array.tuple/get.fail.cpp
new file mode 100644
index 000000000000..4f4fbcf93af6
--- /dev/null
+++ b/test/std/containers/sequences/array/array.tuple/get.fail.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// template <size_t I, class T, size_t N> T& get(array<T, N>& a);
+
+#include <array>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ C c = {1, 2, 3.5};
+ std::get<3>(c) = 5.5; // Can't get element 3!
+ }
+}
diff --git a/test/std/containers/sequences/array/array.tuple/get.pass.cpp b/test/std/containers/sequences/array/array.tuple/get.pass.cpp
new file mode 100644
index 000000000000..d9e242cd420b
--- /dev/null
+++ b/test/std/containers/sequences/array/array.tuple/get.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// template <size_t I, class T, size_t N> T& get(array<T, N>& a);
+
+#include <array>
+#include <cassert>
+
+#if __cplusplus > 201103L
+struct S {
+ std::array<int, 3> a;
+ int k;
+ constexpr S() : a{1,2,3}, k(std::get<2>(a)) {}
+ };
+
+constexpr std::array<int, 2> getArr () { return { 3, 4 }; }
+#endif
+
+int main()
+{
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ C c = {1, 2, 3.5};
+ std::get<1>(c) = 5.5;
+ assert(c[0] == 1);
+ assert(c[1] == 5.5);
+ assert(c[2] == 3.5);
+ }
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ constexpr C c = {1, 2, 3.5};
+ static_assert(std::get<0>(c) == 1, "");
+ static_assert(std::get<1>(c) == 2, "");
+ static_assert(std::get<2>(c) == 3.5, "");
+ }
+ {
+ static_assert(S().k == 3, "");
+ static_assert(std::get<1>(getArr()) == 4, "");
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/array/array.tuple/get_const.pass.cpp b/test/std/containers/sequences/array/array.tuple/get_const.pass.cpp
new file mode 100644
index 000000000000..1cbdfa4ff393
--- /dev/null
+++ b/test/std/containers/sequences/array/array.tuple/get_const.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// template <size_t I, class T, size_t N> const T& get(const array<T, N>& a);
+
+#include <array>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ const C c = {1, 2, 3.5};
+ assert(std::get<0>(c) == 1);
+ assert(std::get<1>(c) == 2);
+ assert(std::get<2>(c) == 3.5);
+ }
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ constexpr const C c = {1, 2, 3.5};
+ static_assert(std::get<0>(c) == 1, "");
+ static_assert(std::get<1>(c) == 2, "");
+ static_assert(std::get<2>(c) == 3.5, "");
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/array/array.tuple/get_rv.pass.cpp b/test/std/containers/sequences/array/array.tuple/get_rv.pass.cpp
new file mode 100644
index 000000000000..8eec3ceff514
--- /dev/null
+++ b/test/std/containers/sequences/array/array.tuple/get_rv.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// template <size_t I, class T, size_t N> T&& get(array<T, N>&& a);
+
+#include <array>
+#include <memory>
+#include <utility>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::unique_ptr<double> T;
+ typedef std::array<T, 1> C;
+ C c = {std::unique_ptr<double>(new double(3.5))};
+ T t = std::get<0>(std::move(c));
+ assert(*t == 3.5);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/sequences/array/array.tuple/tuple_element.pass.cpp b/test/std/containers/sequences/array/array.tuple/tuple_element.pass.cpp
new file mode 100644
index 000000000000..91d6b4e5da22
--- /dev/null
+++ b/test/std/containers/sequences/array/array.tuple/tuple_element.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// tuple_element<I, array<T, N> >::type
+
+#include <array>
+#include <type_traits>
+
+template <class T>
+void test()
+{
+ {
+ typedef T Exp;
+ typedef std::array<T, 3> C;
+ static_assert((std::is_same<typename std::tuple_element<0, C>::type, Exp>::value), "");
+ static_assert((std::is_same<typename std::tuple_element<1, C>::type, Exp>::value), "");
+ static_assert((std::is_same<typename std::tuple_element<2, C>::type, Exp>::value), "");
+ }
+ {
+ typedef T const Exp;
+ typedef std::array<T, 3> const C;
+ static_assert((std::is_same<typename std::tuple_element<0, C>::type, Exp>::value), "");
+ static_assert((std::is_same<typename std::tuple_element<1, C>::type, Exp>::value), "");
+ static_assert((std::is_same<typename std::tuple_element<2, C>::type, Exp>::value), "");
+ }
+ {
+ typedef T volatile Exp;
+ typedef std::array<T, 3> volatile C;
+ static_assert((std::is_same<typename std::tuple_element<0, C>::type, Exp>::value), "");
+ static_assert((std::is_same<typename std::tuple_element<1, C>::type, Exp>::value), "");
+ static_assert((std::is_same<typename std::tuple_element<2, C>::type, Exp>::value), "");
+ }
+ {
+ typedef T const volatile Exp;
+ typedef std::array<T, 3> const volatile C;
+ static_assert((std::is_same<typename std::tuple_element<0, C>::type, Exp>::value), "");
+ static_assert((std::is_same<typename std::tuple_element<1, C>::type, Exp>::value), "");
+ static_assert((std::is_same<typename std::tuple_element<2, C>::type, Exp>::value), "");
+ }
+}
+
+int main()
+{
+ test<double>();
+ test<int>();
+}
diff --git a/test/std/containers/sequences/array/array.tuple/tuple_size.pass.cpp b/test/std/containers/sequences/array/array.tuple/tuple_size.pass.cpp
new file mode 100644
index 000000000000..1e565d1946e4
--- /dev/null
+++ b/test/std/containers/sequences/array/array.tuple/tuple_size.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// tuple_size<array<T, N> >::value
+
+#include <array>
+
+template <class T, std::size_t N>
+void test()
+{
+ {
+ typedef std::array<T, N> C;
+ static_assert((std::tuple_size<C>::value == N), "");
+ }
+ {
+ typedef std::array<T const, N> C;
+ static_assert((std::tuple_size<C>::value == N), "");
+ }
+ {
+ typedef std::array<T volatile, N> C;
+ static_assert((std::tuple_size<C>::value == N), "");
+ }
+ {
+ typedef std::array<T const volatile, N> C;
+ static_assert((std::tuple_size<C>::value == N), "");
+ }
+}
+
+int main()
+{
+ test<double, 0>();
+ test<double, 3>();
+ test<double, 5>();
+}
diff --git a/test/std/containers/sequences/array/array.zero/tested_elsewhere.pass.cpp b/test/std/containers/sequences/array/array.zero/tested_elsewhere.pass.cpp
new file mode 100644
index 000000000000..0aa2f50d8b4f
--- /dev/null
+++ b/test/std/containers/sequences/array/array.zero/tested_elsewhere.pass.cpp
@@ -0,0 +1,18 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// support for zero-sized array
+
+#include <array>
+
+int main()
+{
+}
diff --git a/test/std/containers/sequences/array/at.pass.cpp b/test/std/containers/sequences/array/at.pass.cpp
new file mode 100644
index 000000000000..b5cf8a5aaa8f
--- /dev/null
+++ b/test/std/containers/sequences/array/at.pass.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// reference operator[] (size_type)
+// const_reference operator[] (size_type); // constexpr in C++14
+// reference at (size_type)
+// const_reference at (size_type); // constexpr in C++14
+
+#include <array>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ C c = {1, 2, 3.5};
+ C::reference r1 = c.at(0);
+ assert(r1 == 1);
+ r1 = 5.5;
+ assert(c.front() == 5.5);
+
+ C::reference r2 = c.at(2);
+ assert(r2 == 3.5);
+ r2 = 7.5;
+ assert(c.back() == 7.5);
+
+ try { (void) c.at(3); }
+ catch (const std::out_of_range &) {}
+ }
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ const C c = {1, 2, 3.5};
+ C::const_reference r1 = c.at(0);
+ assert(r1 == 1);
+
+ C::const_reference r2 = c.at(2);
+ assert(r2 == 3.5);
+
+ try { (void) c.at(3); }
+ catch (const std::out_of_range &) {}
+ }
+
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ constexpr C c = {1, 2, 3.5};
+
+ constexpr T t1 = c.at(0);
+ static_assert (t1 == 1, "");
+
+ constexpr T t2 = c.at(2);
+ static_assert (t2 == 3.5, "");
+ }
+#endif
+
+}
diff --git a/test/std/containers/sequences/array/begin.pass.cpp b/test/std/containers/sequences/array/begin.pass.cpp
new file mode 100644
index 000000000000..9cba0d6fceb0
--- /dev/null
+++ b/test/std/containers/sequences/array/begin.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// iterator begin();
+
+#include <array>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ C c = {1, 2, 3.5};
+ C::iterator i;
+ i = c.begin();
+ assert(*i == 1);
+ assert(&*i == c.data());
+ *i = 5.5;
+ assert(c[0] == 5.5);
+ }
+ {
+ }
+}
diff --git a/test/std/containers/sequences/array/contiguous.pass.cpp b/test/std/containers/sequences/array/contiguous.pass.cpp
new file mode 100644
index 000000000000..27933b0c5df8
--- /dev/null
+++ b/test/std/containers/sequences/array/contiguous.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// An array is a contiguous container
+
+#include <array>
+#include <cassert>
+
+template <class C>
+void test_contiguous ( const C &c )
+{
+ for ( size_t i = 0; i < c.size(); ++i )
+ assert ( *(c.begin() + i) == *(std::addressof(*c.begin()) + i));
+}
+
+int main()
+{
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ test_contiguous (C());
+ }
+}
diff --git a/test/std/containers/sequences/array/front_back.pass.cpp b/test/std/containers/sequences/array/front_back.pass.cpp
new file mode 100644
index 000000000000..45a963b9947d
--- /dev/null
+++ b/test/std/containers/sequences/array/front_back.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// reference front();
+// reference back();
+// const_reference front(); // constexpr in C++14
+// const_reference back(); // constexpr in C++14
+
+#include <array>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ C c = {1, 2, 3.5};
+
+ C::reference r1 = c.front();
+ assert(r1 == 1);
+ r1 = 5.5;
+ assert(c[0] == 5.5);
+
+ C::reference r2 = c.back();
+ assert(r2 == 3.5);
+ r2 = 7.5;
+ assert(c[2] == 7.5);
+ }
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ const C c = {1, 2, 3.5};
+ C::const_reference r1 = c.front();
+ assert(r1 == 1);
+
+ C::const_reference r2 = c.back();
+ assert(r2 == 3.5);
+ }
+
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ constexpr C c = {1, 2, 3.5};
+
+ constexpr T t1 = c.front();
+ static_assert (t1 == 1, "");
+
+ constexpr T t2 = c.back();
+ static_assert (t2 == 3.5, "");
+ }
+#endif
+
+}
diff --git a/test/std/containers/sequences/array/indexing.pass.cpp b/test/std/containers/sequences/array/indexing.pass.cpp
new file mode 100644
index 000000000000..e4dda0dc5cfd
--- /dev/null
+++ b/test/std/containers/sequences/array/indexing.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// reference operator[] (size_type)
+// const_reference operator[] (size_type); // constexpr in C++14
+// reference at (size_type)
+// const_reference at (size_type); // constexpr in C++14
+
+#include <array>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ C c = {1, 2, 3.5};
+ C::reference r1 = c[0];
+ assert(r1 == 1);
+ r1 = 5.5;
+ assert(c.front() == 5.5);
+
+ C::reference r2 = c[2];
+ assert(r2 == 3.5);
+ r2 = 7.5;
+ assert(c.back() == 7.5);
+ }
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ const C c = {1, 2, 3.5};
+ C::const_reference r1 = c[0];
+ assert(r1 == 1);
+ C::const_reference r2 = c[2];
+ assert(r2 == 3.5);
+ }
+
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ constexpr C c = {1, 2, 3.5};
+
+ constexpr T t1 = c[0];
+ static_assert (t1 == 1, "");
+
+ constexpr T t2 = c[2];
+ static_assert (t2 == 3.5, "");
+ }
+#endif
+
+}
diff --git a/test/std/containers/sequences/array/iterators.pass.cpp b/test/std/containers/sequences/array/iterators.pass.cpp
new file mode 100644
index 000000000000..98997d8c26d5
--- /dev/null
+++ b/test/std/containers/sequences/array/iterators.pass.cpp
@@ -0,0 +1,110 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// iterator, const_iterator
+
+#include <array>
+#include <iterator>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::array<int, 5> C;
+ C c;
+ C::iterator i;
+ i = c.begin();
+ C::const_iterator j;
+ j = c.cbegin();
+ assert(i == j);
+ }
+ {
+ typedef std::array<int, 0> C;
+ C c;
+ C::iterator i;
+ i = c.begin();
+ C::const_iterator j;
+ j = c.cbegin();
+ assert(i == j);
+ }
+
+#if _LIBCPP_STD_VER > 11
+ { // N3644 testing
+ {
+ typedef std::array<int, 5> C;
+ C::iterator ii1{}, ii2{};
+ C::iterator ii4 = ii1;
+ C::const_iterator cii{};
+ assert ( ii1 == ii2 );
+ assert ( ii1 == ii4 );
+ assert ( ii1 == cii );
+
+ assert ( !(ii1 != ii2 ));
+ assert ( !(ii1 != cii ));
+
+ C c;
+ assert ( c.begin() == std::begin(c));
+ assert ( c.cbegin() == std::cbegin(c));
+ assert ( c.rbegin() == std::rbegin(c));
+ assert ( c.crbegin() == std::crbegin(c));
+ assert ( c.end() == std::end(c));
+ assert ( c.cend() == std::cend(c));
+ assert ( c.rend() == std::rend(c));
+ assert ( c.crend() == std::crend(c));
+
+ assert ( std::begin(c) != std::end(c));
+ assert ( std::rbegin(c) != std::rend(c));
+ assert ( std::cbegin(c) != std::cend(c));
+ assert ( std::crbegin(c) != std::crend(c));
+ }
+ {
+ typedef std::array<int, 0> C;
+ C::iterator ii1{}, ii2{};
+ C::iterator ii4 = ii1;
+ C::const_iterator cii{};
+ assert ( ii1 == ii2 );
+ assert ( ii1 == ii4 );
+
+ assert (!(ii1 != ii2 ));
+
+ assert ( (ii1 == cii ));
+ assert ( (cii == ii1 ));
+ assert (!(ii1 != cii ));
+ assert (!(cii != ii1 ));
+ assert (!(ii1 < cii ));
+ assert (!(cii < ii1 ));
+ assert ( (ii1 <= cii ));
+ assert ( (cii <= ii1 ));
+ assert (!(ii1 > cii ));
+ assert (!(cii > ii1 ));
+ assert ( (ii1 >= cii ));
+ assert ( (cii >= ii1 ));
+ assert (cii - ii1 == 0);
+ assert (ii1 - cii == 0);
+
+ C c;
+ assert ( c.begin() == std::begin(c));
+ assert ( c.cbegin() == std::cbegin(c));
+ assert ( c.rbegin() == std::rbegin(c));
+ assert ( c.crbegin() == std::crbegin(c));
+ assert ( c.end() == std::end(c));
+ assert ( c.cend() == std::cend(c));
+ assert ( c.rend() == std::rend(c));
+ assert ( c.crend() == std::crend(c));
+
+ assert ( std::begin(c) == std::end(c));
+ assert ( std::rbegin(c) == std::rend(c));
+ assert ( std::cbegin(c) == std::cend(c));
+ assert ( std::crbegin(c) == std::crend(c));
+ }
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/array/types.pass.cpp b/test/std/containers/sequences/array/types.pass.cpp
new file mode 100644
index 000000000000..065ade959d05
--- /dev/null
+++ b/test/std/containers/sequences/array/types.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// template <class T, size_t N >
+// struct array
+// {
+// // types:
+// typedef T& reference;
+// typedef const T& const_reference;
+// typedef implementation defined iterator;
+// typedef implementation defined const_iterator;
+// typedef T value_type;
+// typedef T* pointer;
+// typedef size_t size_type;
+// typedef ptrdiff_t difference_type;
+// typedef T value_type;
+// typedef std::reverse_iterator<iterator> reverse_iterator;
+// typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
+
+#include <array>
+#include <iterator>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef double T;
+ typedef std::array<T, 10> C;
+ static_assert((std::is_same<C::reference, T&>::value), "");
+ static_assert((std::is_same<C::const_reference, const T&>::value), "");
+ static_assert((std::is_same<C::iterator, T*>::value), "");
+ static_assert((std::is_same<C::const_iterator, const T*>::value), "");
+ static_assert((std::is_same<C::pointer, T*>::value), "");
+ static_assert((std::is_same<C::const_pointer, const T*>::value), "");
+ static_assert((std::is_same<C::size_type, std::size_t>::value), "");
+ static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
+ static_assert((std::is_same<C::reverse_iterator, std::reverse_iterator<C::iterator> >::value), "");
+ static_assert((std::is_same<C::const_reverse_iterator, std::reverse_iterator<C::const_iterator> >::value), "");
+ }
+ {
+ typedef int* T;
+ typedef std::array<T, 0> C;
+ static_assert((std::is_same<C::reference, T&>::value), "");
+ static_assert((std::is_same<C::const_reference, const T&>::value), "");
+ static_assert((std::is_same<C::iterator, T*>::value), "");
+ static_assert((std::is_same<C::const_iterator, const T*>::value), "");
+ static_assert((std::is_same<C::pointer, T*>::value), "");
+ static_assert((std::is_same<C::const_pointer, const T*>::value), "");
+ static_assert((std::is_same<C::size_type, std::size_t>::value), "");
+ static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
+ static_assert((std::is_same<C::reverse_iterator, std::reverse_iterator<C::iterator> >::value), "");
+ static_assert((std::is_same<C::const_reverse_iterator, std::reverse_iterator<C::const_iterator> >::value), "");
+ }
+}
diff --git a/test/std/containers/sequences/array/version.pass.cpp b/test/std/containers/sequences/array/version.pass.cpp
new file mode 100644
index 000000000000..b89a8dd8cca3
--- /dev/null
+++ b/test/std/containers/sequences/array/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+#include <array>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/containers/sequences/deque/deque.capacity/access.pass.cpp b/test/std/containers/sequences/deque/deque.capacity/access.pass.cpp
new file mode 100644
index 000000000000..996fc9a18fe7
--- /dev/null
+++ b/test/std/containers/sequences/deque/deque.capacity/access.pass.cpp
@@ -0,0 +1,91 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// reference operator[](size_type __i);
+// const_reference operator[](size_type __i) const;
+//
+// reference at(size_type __i);
+// const_reference at(size_type __i) const;
+//
+// reference front();
+// const_reference front() const;
+//
+// reference back();
+// const_reference back() const;
+
+#include <deque>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class C>
+C
+make(int size, int start = 0 )
+{
+ const int b = 4096 / sizeof(int);
+ int init = 0;
+ if (start > 0)
+ {
+ init = (start+1) / b + ((start+1) % b != 0);
+ init *= b;
+ --init;
+ }
+ C c(init, 0);
+ for (int i = 0; i < init-start; ++i)
+ c.pop_back();
+ for (int i = 0; i < size; ++i)
+ c.push_back(i);
+ for (int i = 0; i < start; ++i)
+ c.pop_front();
+ return c;
+}
+
+int main()
+{
+ {
+ std::deque<int> c = make<std::deque<int> >(10);
+ for (unsigned i = 0; i < 10; ++i)
+ assert(c[i] == i);
+ for (unsigned i = 0; i < 10; ++i)
+ assert(c.at(i) == i);
+ assert(c.front() == 0);
+ assert(c.back() == 9);
+ }
+ {
+ const std::deque<int> c = make<std::deque<int> >(10);
+ for (unsigned i = 0; i < 10; ++i)
+ assert(c[i] == i);
+ for (unsigned i = 0; i < 10; ++i)
+ assert(c.at(i) == i);
+ assert(c.front() == 0);
+ assert(c.back() == 9);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::deque<int, min_allocator<int>> c = make<std::deque<int, min_allocator<int>> >(10);
+ for (unsigned i = 0; i < 10; ++i)
+ assert(c[i] == i);
+ for (unsigned i = 0; i < 10; ++i)
+ assert(c.at(i) == i);
+ assert(c.front() == 0);
+ assert(c.back() == 9);
+ }
+ {
+ const std::deque<int, min_allocator<int>> c = make<std::deque<int, min_allocator<int>> >(10);
+ for (unsigned i = 0; i < 10; ++i)
+ assert(c[i] == i);
+ for (unsigned i = 0; i < 10; ++i)
+ assert(c.at(i) == i);
+ assert(c.front() == 0);
+ assert(c.back() == 9);
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/deque/deque.capacity/resize_size.pass.cpp b/test/std/containers/sequences/deque/deque.capacity/resize_size.pass.cpp
new file mode 100644
index 000000000000..522f839973db
--- /dev/null
+++ b/test/std/containers/sequences/deque/deque.capacity/resize_size.pass.cpp
@@ -0,0 +1,86 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// void resize(size_type n);
+
+#include <deque>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class C>
+C
+make(int size, int start = 0 )
+{
+ const int b = 4096 / sizeof(int);
+ int init = 0;
+ if (start > 0)
+ {
+ init = (start+1) / b + ((start+1) % b != 0);
+ init *= b;
+ --init;
+ }
+ C c(init, 0);
+ for (int i = 0; i < init-start; ++i)
+ c.pop_back();
+ for (int i = 0; i < size; ++i)
+ c.push_back(i);
+ for (int i = 0; i < start; ++i)
+ c.pop_front();
+ return c;
+}
+
+template <class C>
+void
+test(C& c1, int size)
+{
+ typedef typename C::const_iterator CI;
+ typename C::size_type c1_osize = c1.size();
+ c1.resize(size);
+ assert(c1.size() == size);
+ assert(distance(c1.begin(), c1.end()) == c1.size());
+ CI i = c1.begin();
+ for (int j = 0; j < std::min(c1_osize, c1.size()); ++j, ++i)
+ assert(*i == j);
+ for (int j = c1_osize; j < c1.size(); ++j, ++i)
+ assert(*i == 0);
+}
+
+template <class C>
+void
+testN(int start, int N, int M)
+{
+ typedef typename C::const_iterator CI;
+ C c1 = make<C>(N, start);
+ test(c1, M);
+}
+
+int main()
+{
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ for (int k = 0; k < N; ++k)
+ testN<std::deque<int> >(rng[i], rng[j], rng[k]);
+ }
+#if __cplusplus >= 201103L
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ for (int k = 0; k < N; ++k)
+ testN<std::deque<int, min_allocator<int>>>(rng[i], rng[j], rng[k]);
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/deque/deque.capacity/resize_size_value.pass.cpp b/test/std/containers/sequences/deque/deque.capacity/resize_size_value.pass.cpp
new file mode 100644
index 000000000000..9eb514ba92f7
--- /dev/null
+++ b/test/std/containers/sequences/deque/deque.capacity/resize_size_value.pass.cpp
@@ -0,0 +1,86 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// void resize(size_type n, const value_type& v);
+
+#include <deque>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class C>
+C
+make(int size, int start = 0 )
+{
+ const int b = 4096 / sizeof(int);
+ int init = 0;
+ if (start > 0)
+ {
+ init = (start+1) / b + ((start+1) % b != 0);
+ init *= b;
+ --init;
+ }
+ C c(init, 0);
+ for (int i = 0; i < init-start; ++i)
+ c.pop_back();
+ for (int i = 0; i < size; ++i)
+ c.push_back(i);
+ for (int i = 0; i < start; ++i)
+ c.pop_front();
+ return c;
+}
+
+template <class C>
+void
+test(C& c1, int size, int x)
+{
+ typedef typename C::const_iterator CI;
+ typename C::size_type c1_osize = c1.size();
+ c1.resize(size, x);
+ assert(c1.size() == size);
+ assert(distance(c1.begin(), c1.end()) == c1.size());
+ CI i = c1.begin();
+ for (int j = 0; j < std::min(c1_osize, c1.size()); ++j, ++i)
+ assert(*i == j);
+ for (int j = c1_osize; j < c1.size(); ++j, ++i)
+ assert(*i == x);
+}
+
+template <class C>
+void
+testN(int start, int N, int M)
+{
+ typedef typename C::const_iterator CI;
+ C c1 = make<C>(N, start);
+ test(c1, M, -10);
+}
+
+int main()
+{
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ for (int k = 0; k < N; ++k)
+ testN<std::deque<int> >(rng[i], rng[j], rng[k]);
+ }
+#if __cplusplus >= 201103L
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ for (int k = 0; k < N; ++k)
+ testN<std::deque<int, min_allocator<int>>>(rng[i], rng[j], rng[k]);
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/deque/deque.capacity/shrink_to_fit.pass.cpp b/test/std/containers/sequences/deque/deque.capacity/shrink_to_fit.pass.cpp
new file mode 100644
index 000000000000..fb00069f33b6
--- /dev/null
+++ b/test/std/containers/sequences/deque/deque.capacity/shrink_to_fit.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// void shrink_to_fit();
+
+#include <deque>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class C>
+C
+make(int size, int start = 0 )
+{
+ const int b = 4096 / sizeof(int);
+ int init = 0;
+ if (start > 0)
+ {
+ init = (start+1) / b + ((start+1) % b != 0);
+ init *= b;
+ --init;
+ }
+ C c(init, 0);
+ for (int i = 0; i < init-start; ++i)
+ c.pop_back();
+ for (int i = 0; i < size; ++i)
+ c.push_back(i);
+ for (int i = 0; i < start; ++i)
+ c.pop_front();
+ return c;
+}
+
+template <class C>
+void
+test(C& c1)
+{
+ C s = c1;
+ c1.shrink_to_fit();
+ assert(c1 == s);
+}
+
+template <class C>
+void
+testN(int start, int N)
+{
+ typedef typename C::const_iterator CI;
+ C c1 = make<C>(N, start);
+ test(c1);
+}
+
+int main()
+{
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ testN<std::deque<int> >(rng[i], rng[j]);
+ }
+#if __cplusplus >= 201103L
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j]);
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/deque/deque.cons/alloc.pass.cpp b/test/std/containers/sequences/deque/deque.cons/alloc.pass.cpp
new file mode 100644
index 000000000000..841bfd9f8a7f
--- /dev/null
+++ b/test/std/containers/sequences/deque/deque.cons/alloc.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// explicit deque(const allocator_type& a);
+
+#include <deque>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "../../../NotConstructible.h"
+#include "min_allocator.h"
+
+template <class T, class Allocator>
+void
+test(const Allocator& a)
+{
+ std::deque<T, Allocator> d(a);
+ assert(d.size() == 0);
+ assert(d.get_allocator() == a);
+}
+
+int main()
+{
+ test<int>(std::allocator<int>());
+ test<NotConstructible>(test_allocator<NotConstructible>(3));
+#if __cplusplus >= 201103L
+ test<int>(min_allocator<int>());
+ test<NotConstructible>(min_allocator<NotConstructible>{});
+#endif
+}
diff --git a/test/std/containers/sequences/deque/deque.cons/assign_initializer_list.pass.cpp b/test/std/containers/sequences/deque/deque.cons/assign_initializer_list.pass.cpp
new file mode 100644
index 000000000000..c760b4372444
--- /dev/null
+++ b/test/std/containers/sequences/deque/deque.cons/assign_initializer_list.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// void assign(initializer_list<value_type> il);
+
+#include <deque>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ std::deque<int> d;
+ d.assign({3, 4, 5, 6});
+ assert(d.size() == 4);
+ assert(d[0] == 3);
+ assert(d[1] == 4);
+ assert(d[2] == 5);
+ assert(d[3] == 6);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::deque<int, min_allocator<int>> d;
+ d.assign({3, 4, 5, 6});
+ assert(d.size() == 4);
+ assert(d[0] == 3);
+ assert(d[1] == 4);
+ assert(d[2] == 5);
+ assert(d[3] == 6);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/containers/sequences/deque/deque.cons/assign_iter_iter.pass.cpp b/test/std/containers/sequences/deque/deque.cons/assign_iter_iter.pass.cpp
new file mode 100644
index 000000000000..51a37cc33b7a
--- /dev/null
+++ b/test/std/containers/sequences/deque/deque.cons/assign_iter_iter.pass.cpp
@@ -0,0 +1,109 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// template <class InputIterator>
+// void assign(InputIterator f, InputIterator l);
+
+#include <deque>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+template <class C>
+C
+make(int size, int start = 0 )
+{
+ const int b = 4096 / sizeof(int);
+ int init = 0;
+ if (start > 0)
+ {
+ init = (start+1) / b + ((start+1) % b != 0);
+ init *= b;
+ --init;
+ }
+ C c(init, 0);
+ for (int i = 0; i < init-start; ++i)
+ c.pop_back();
+ for (int i = 0; i < size; ++i)
+ c.push_back(i);
+ for (int i = 0; i < start; ++i)
+ c.pop_front();
+ return c;
+}
+
+template <class C>
+void
+test(C& c1, const C& c2)
+{
+ std::size_t c1_osize = c1.size();
+ c1.assign(c2.begin(), c2.end());
+ assert(distance(c1.begin(), c1.end()) == c1.size());
+ assert(c1 == c2);
+}
+
+template <class C>
+void
+testN(int start, int N, int M)
+{
+ typedef typename C::iterator I;
+ typedef typename C::const_iterator CI;
+ C c1 = make<C>(N, start);
+ C c2 = make<C>(M);
+ test(c1, c2);
+}
+
+template <class C>
+void
+testI(C& c1, const C& c2)
+{
+ typedef typename C::const_iterator CI;
+ typedef input_iterator<CI> ICI;
+ std::size_t c1_osize = c1.size();
+ c1.assign(ICI(c2.begin()), ICI(c2.end()));
+ assert(distance(c1.begin(), c1.end()) == c1.size());
+ assert(c1 == c2);
+}
+
+template <class C>
+void
+testNI(int start, int N, int M)
+{
+ typedef typename C::iterator I;
+ typedef typename C::const_iterator CI;
+ C c1 = make<C>(N, start);
+ C c2 = make<C>(M);
+ testI(c1, c2);
+}
+
+int main()
+{
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ for (int k = 0; k < N; ++k)
+ testN<std::deque<int> >(rng[i], rng[j], rng[k]);
+ testNI<std::deque<int> >(1500, 2000, 1000);
+ }
+#if __cplusplus >= 201103L
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ for (int k = 0; k < N; ++k)
+ testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j], rng[k]);
+ testNI<std::deque<int, min_allocator<int>> >(1500, 2000, 1000);
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/deque/deque.cons/assign_size_value.pass.cpp b/test/std/containers/sequences/deque/deque.cons/assign_size_value.pass.cpp
new file mode 100644
index 000000000000..3ab79a095fce
--- /dev/null
+++ b/test/std/containers/sequences/deque/deque.cons/assign_size_value.pass.cpp
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// void assign(size_type n, const value_type& v);
+
+#include <deque>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+template <class C>
+C
+make(int size, int start = 0 )
+{
+ const int b = 4096 / sizeof(int);
+ int init = 0;
+ if (start > 0)
+ {
+ init = (start+1) / b + ((start+1) % b != 0);
+ init *= b;
+ --init;
+ }
+ C c(init, 0);
+ for (int i = 0; i < init-start; ++i)
+ c.pop_back();
+ for (int i = 0; i < size; ++i)
+ c.push_back(i);
+ for (int i = 0; i < start; ++i)
+ c.pop_front();
+ return c;
+}
+
+template <class C>
+void
+test(C& c1, int size, int v)
+{
+ typedef typename C::const_iterator CI;
+ std::size_t c1_osize = c1.size();
+ c1.assign(size, v);
+ assert(c1.size() == size);
+ assert(distance(c1.begin(), c1.end()) == c1.size());
+ for (CI i = c1.begin(); i != c1.end(); ++i)
+ assert(*i == v);
+}
+
+template <class C>
+void
+testN(int start, int N, int M)
+{
+ typedef typename C::iterator I;
+ typedef typename C::const_iterator CI;
+ C c1 = make<C>(N, start);
+ test(c1, M, -10);
+}
+
+int main()
+{
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ for (int k = 0; k < N; ++k)
+ testN<std::deque<int> >(rng[i], rng[j], rng[k]);
+ }
+#if __cplusplus >= 201103L
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ for (int k = 0; k < N; ++k)
+ testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j], rng[k]);
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/deque/deque.cons/copy.pass.cpp b/test/std/containers/sequences/deque/deque.cons/copy.pass.cpp
new file mode 100644
index 000000000000..fa0c1203ede9
--- /dev/null
+++ b/test/std/containers/sequences/deque/deque.cons/copy.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// deque(const deque&);
+
+#include <deque>
+#include <cassert>
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+template <class C>
+void
+test(const C& x)
+{
+ C c(x);
+ assert(c == x);
+}
+
+int main()
+{
+ {
+ int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
+ int* an = ab + sizeof(ab)/sizeof(ab[0]);
+ test(std::deque<int>(ab, an));
+ }
+ {
+ std::deque<int, test_allocator<int> > v(3, 2, test_allocator<int>(5));
+ std::deque<int, test_allocator<int> > v2 = v;
+ assert(v2 == v);
+ assert(v2.get_allocator() == v.get_allocator());
+ }
+#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+ {
+ std::deque<int, other_allocator<int> > v(3, 2, other_allocator<int>(5));
+ std::deque<int, other_allocator<int> > v2 = v;
+ assert(v2 == v);
+ assert(v2.get_allocator() == other_allocator<int>(-2));
+ }
+#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE
+#if __cplusplus >= 201103L
+ {
+ int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
+ int* an = ab + sizeof(ab)/sizeof(ab[0]);
+ test(std::deque<int, min_allocator<int>>(ab, an));
+ }
+ {
+ std::deque<int, min_allocator<int> > v(3, 2, min_allocator<int>());
+ std::deque<int, min_allocator<int> > v2 = v;
+ assert(v2 == v);
+ assert(v2.get_allocator() == v.get_allocator());
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/deque/deque.cons/copy_alloc.pass.cpp b/test/std/containers/sequences/deque/deque.cons/copy_alloc.pass.cpp
new file mode 100644
index 000000000000..efea4948eba1
--- /dev/null
+++ b/test/std/containers/sequences/deque/deque.cons/copy_alloc.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// deque(const deque& c, const allocator_type& a);
+
+#include <deque>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+template <class C>
+void
+test(const C& x, const typename C::allocator_type& a)
+{
+ C c(x, a);
+ assert(c == x);
+ assert(c.get_allocator() == a);
+}
+
+int main()
+{
+ {
+ int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
+ int* an = ab + sizeof(ab)/sizeof(ab[0]);
+ test(std::deque<int, test_allocator<int> >(ab, an, test_allocator<int>(3)),
+ test_allocator<int>(4));
+ }
+ {
+ int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
+ int* an = ab + sizeof(ab)/sizeof(ab[0]);
+ test(std::deque<int, other_allocator<int> >(ab, an, other_allocator<int>(3)),
+ other_allocator<int>(4));
+ }
+#if __cplusplus >= 201103L
+ {
+ int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
+ int* an = ab + sizeof(ab)/sizeof(ab[0]);
+ test(std::deque<int, min_allocator<int> >(ab, an, min_allocator<int>()),
+ min_allocator<int>());
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/deque/deque.cons/default.pass.cpp b/test/std/containers/sequences/deque/deque.cons/default.pass.cpp
new file mode 100644
index 000000000000..b725dade70b2
--- /dev/null
+++ b/test/std/containers/sequences/deque/deque.cons/default.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// deque()
+
+#include <deque>
+#include <cassert>
+
+#include "../../../stack_allocator.h"
+#include "../../../NotConstructible.h"
+#include "min_allocator.h"
+
+template <class T, class Allocator>
+void
+test()
+{
+ std::deque<T, Allocator> d;
+ assert(d.size() == 0);
+#if __cplusplus >= 201103L
+ std::deque<T, Allocator> d1 = {};
+ assert(d1.size() == 0);
+#endif
+}
+
+int main()
+{
+ test<int, std::allocator<int> >();
+ test<NotConstructible, stack_allocator<NotConstructible, 1> >();
+#if __cplusplus >= 201103L
+ test<int, min_allocator<int> >();
+ test<NotConstructible, min_allocator<NotConstructible> >();
+#endif
+}
diff --git a/test/std/containers/sequences/deque/deque.cons/default_noexcept.pass.cpp b/test/std/containers/sequences/deque/deque.cons/default_noexcept.pass.cpp
new file mode 100644
index 000000000000..c612dbc5e838
--- /dev/null
+++ b/test/std/containers/sequences/deque/deque.cons/default_noexcept.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// deque()
+// noexcept(is_nothrow_default_constructible<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <deque>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_alloc
+{
+ typedef T value_type;
+ some_alloc(const some_alloc&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::deque<MoveOnly> C;
+ static_assert(std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::deque<MoveOnly, test_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::deque<MoveOnly, other_allocator<MoveOnly>> C;
+ static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::deque<MoveOnly, some_alloc<MoveOnly>> C;
+ static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/deque/deque.cons/dtor_noexcept.pass.cpp b/test/std/containers/sequences/deque/deque.cons/dtor_noexcept.pass.cpp
new file mode 100644
index 000000000000..ecdc2404c855
--- /dev/null
+++ b/test/std/containers/sequences/deque/deque.cons/dtor_noexcept.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// ~deque() // implied noexcept;
+
+#include <deque>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "test_allocator.h"
+
+#if __has_feature(cxx_noexcept)
+
+template <class T>
+struct some_alloc
+{
+ typedef T value_type;
+ some_alloc(const some_alloc&);
+ ~some_alloc() noexcept(false);
+};
+
+#endif
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::deque<MoveOnly> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::deque<MoveOnly, test_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::deque<MoveOnly, other_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::deque<MoveOnly, some_alloc<MoveOnly>> C;
+ static_assert(!std::is_nothrow_destructible<C>::value, "");
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/deque/deque.cons/initializer_list.pass.cpp b/test/std/containers/sequences/deque/deque.cons/initializer_list.pass.cpp
new file mode 100644
index 000000000000..a9e0218e2e0b
--- /dev/null
+++ b/test/std/containers/sequences/deque/deque.cons/initializer_list.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// deque(initializer_list<value_type> il);
+
+#include <deque>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ std::deque<int> d = {3, 4, 5, 6};
+ assert(d.size() == 4);
+ assert(d[0] == 3);
+ assert(d[1] == 4);
+ assert(d[2] == 5);
+ assert(d[3] == 6);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::deque<int, min_allocator<int>> d = {3, 4, 5, 6};
+ assert(d.size() == 4);
+ assert(d[0] == 3);
+ assert(d[1] == 4);
+ assert(d[2] == 5);
+ assert(d[3] == 6);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/containers/sequences/deque/deque.cons/initializer_list_alloc.pass.cpp b/test/std/containers/sequences/deque/deque.cons/initializer_list_alloc.pass.cpp
new file mode 100644
index 000000000000..36c5af60ee34
--- /dev/null
+++ b/test/std/containers/sequences/deque/deque.cons/initializer_list_alloc.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// deque(initializer_list<value_type> il, const Allocator& a = allocator_type());
+
+#include <deque>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ std::deque<int, test_allocator<int>> d({3, 4, 5, 6}, test_allocator<int>(3));
+ assert(d.get_allocator() == test_allocator<int>(3));
+ assert(d.size() == 4);
+ assert(d[0] == 3);
+ assert(d[1] == 4);
+ assert(d[2] == 5);
+ assert(d[3] == 6);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::deque<int, min_allocator<int>> d({3, 4, 5, 6}, min_allocator<int>());
+ assert(d.get_allocator() == min_allocator<int>());
+ assert(d.size() == 4);
+ assert(d[0] == 3);
+ assert(d[1] == 4);
+ assert(d[2] == 5);
+ assert(d[3] == 6);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/containers/sequences/deque/deque.cons/iter_iter.pass.cpp b/test/std/containers/sequences/deque/deque.cons/iter_iter.pass.cpp
new file mode 100644
index 000000000000..faadf2b1a1db
--- /dev/null
+++ b/test/std/containers/sequences/deque/deque.cons/iter_iter.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// template <class InputIterator> deque(InputIterator f, InputIterator l);
+
+#include <deque>
+#include <cassert>
+
+#include "../../../stack_allocator.h"
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+template <class InputIterator>
+void
+test(InputIterator f, InputIterator l)
+{
+ typedef typename std::iterator_traits<InputIterator>::value_type T;
+ typedef std::allocator<T> Allocator;
+ typedef std::deque<T, Allocator> C;
+ typedef typename C::const_iterator const_iterator;
+ C d(f, l);
+ assert(d.size() == std::distance(f, l));
+ assert(distance(d.begin(), d.end()) == d.size());
+ for (const_iterator i = d.begin(), e = d.end(); i != e; ++i, ++f)
+ assert(*i == *f);
+}
+
+template <class Allocator, class InputIterator>
+void
+test(InputIterator f, InputIterator l)
+{
+ typedef typename std::iterator_traits<InputIterator>::value_type T;
+ typedef std::deque<T, Allocator> C;
+ typedef typename C::const_iterator const_iterator;
+ C d(f, l);
+ assert(d.size() == std::distance(f, l));
+ assert(distance(d.begin(), d.end()) == d.size());
+ for (const_iterator i = d.begin(), e = d.end(); i != e; ++i, ++f)
+ assert(*i == *f);
+}
+
+int main()
+{
+ int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
+ int* an = ab + sizeof(ab)/sizeof(ab[0]);
+ test(input_iterator<const int*>(ab), input_iterator<const int*>(an));
+ test(forward_iterator<const int*>(ab), forward_iterator<const int*>(an));
+ test(bidirectional_iterator<const int*>(ab), bidirectional_iterator<const int*>(an));
+ test(random_access_iterator<const int*>(ab), random_access_iterator<const int*>(an));
+ test<stack_allocator<int, 4096> >(ab, an);
+#if __cplusplus >= 201103L
+ test<min_allocator<int> >(ab, an);
+#endif
+}
diff --git a/test/std/containers/sequences/deque/deque.cons/iter_iter_alloc.pass.cpp b/test/std/containers/sequences/deque/deque.cons/iter_iter_alloc.pass.cpp
new file mode 100644
index 000000000000..b8c3e889929d
--- /dev/null
+++ b/test/std/containers/sequences/deque/deque.cons/iter_iter_alloc.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// template <class InputIterator>
+// deque(InputIterator f, InputIterator l, const allocator_type& a);
+
+#include <deque>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+template <class InputIterator, class Allocator>
+void
+test(InputIterator f, InputIterator l, const Allocator& a)
+{
+ typedef typename std::iterator_traits<InputIterator>::value_type T;
+ typedef std::deque<T, Allocator> C;
+ typedef typename C::const_iterator const_iterator;
+ C d(f, l, a);
+ assert(d.get_allocator() == a);
+ assert(d.size() == std::distance(f, l));
+ assert(distance(d.begin(), d.end()) == d.size());
+ for (const_iterator i = d.begin(), e = d.end(); i != e; ++i, ++f)
+ assert(*i == *f);
+}
+
+int main()
+{
+ int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
+ int* an = ab + sizeof(ab)/sizeof(ab[0]);
+ test(input_iterator<const int*>(ab), input_iterator<const int*>(an), test_allocator<int>(3));
+ test(forward_iterator<const int*>(ab), forward_iterator<const int*>(an), test_allocator<int>(4));
+ test(bidirectional_iterator<const int*>(ab), bidirectional_iterator<const int*>(an), test_allocator<int>(5));
+ test(random_access_iterator<const int*>(ab), random_access_iterator<const int*>(an), test_allocator<int>(6));
+#if __cplusplus >= 201103L
+ test(input_iterator<const int*>(ab), input_iterator<const int*>(an), min_allocator<int>());
+ test(forward_iterator<const int*>(ab), forward_iterator<const int*>(an), min_allocator<int>());
+ test(bidirectional_iterator<const int*>(ab), bidirectional_iterator<const int*>(an), min_allocator<int>());
+ test(random_access_iterator<const int*>(ab), random_access_iterator<const int*>(an), min_allocator<int>());
+#endif
+}
diff --git a/test/std/containers/sequences/deque/deque.cons/move.pass.cpp b/test/std/containers/sequences/deque/deque.cons/move.pass.cpp
new file mode 100644
index 000000000000..4a7aa8a058eb
--- /dev/null
+++ b/test/std/containers/sequences/deque/deque.cons/move.pass.cpp
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// deque(deque&&);
+
+#include <deque>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
+ int* an = ab + sizeof(ab)/sizeof(ab[0]);
+ typedef test_allocator<MoveOnly> A;
+ std::deque<MoveOnly, A> c1(A(1));
+ for (int* p = ab; p < an; ++p)
+ c1.push_back(MoveOnly(*p));
+ std::deque<MoveOnly, A> c2(A(2));
+ for (int* p = ab; p < an; ++p)
+ c2.push_back(MoveOnly(*p));
+ std::deque<MoveOnly, A> c3 = std::move(c1);
+ assert(c2 == c3);
+ assert(c1.size() == 0);
+ assert(c3.get_allocator() == c1.get_allocator());
+ }
+ {
+ int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
+ int* an = ab + sizeof(ab)/sizeof(ab[0]);
+ typedef other_allocator<MoveOnly> A;
+ std::deque<MoveOnly, A> c1(A(1));
+ for (int* p = ab; p < an; ++p)
+ c1.push_back(MoveOnly(*p));
+ std::deque<MoveOnly, A> c2(A(2));
+ for (int* p = ab; p < an; ++p)
+ c2.push_back(MoveOnly(*p));
+ std::deque<MoveOnly, A> c3 = std::move(c1);
+ assert(c2 == c3);
+ assert(c1.size() == 0);
+ assert(c3.get_allocator() == c1.get_allocator());
+ }
+#if __cplusplus >= 201103L
+ {
+ int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
+ int* an = ab + sizeof(ab)/sizeof(ab[0]);
+ typedef min_allocator<MoveOnly> A;
+ std::deque<MoveOnly, A> c1(A{});
+ for (int* p = ab; p < an; ++p)
+ c1.push_back(MoveOnly(*p));
+ std::deque<MoveOnly, A> c2(A{});
+ for (int* p = ab; p < an; ++p)
+ c2.push_back(MoveOnly(*p));
+ std::deque<MoveOnly, A> c3 = std::move(c1);
+ assert(c2 == c3);
+ assert(c1.size() == 0);
+ assert(c3.get_allocator() == c1.get_allocator());
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/sequences/deque/deque.cons/move_alloc.pass.cpp b/test/std/containers/sequences/deque/deque.cons/move_alloc.pass.cpp
new file mode 100644
index 000000000000..1a5db6db6500
--- /dev/null
+++ b/test/std/containers/sequences/deque/deque.cons/move_alloc.pass.cpp
@@ -0,0 +1,87 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// deque(deque&& c, const allocator_type& a);
+
+#include <deque>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
+ int* an = ab + sizeof(ab)/sizeof(ab[0]);
+ typedef test_allocator<MoveOnly> A;
+ std::deque<MoveOnly, A> c1(A(1));
+ for (int* p = ab; p < an; ++p)
+ c1.push_back(MoveOnly(*p));
+ std::deque<MoveOnly, A> c2(A(1));
+ for (int* p = ab; p < an; ++p)
+ c2.push_back(MoveOnly(*p));
+ std::deque<MoveOnly, A> c3(std::move(c1), A(3));
+ assert(c2 == c3);
+ assert(c3.get_allocator() == A(3));
+ assert(c1.size() != 0);
+ }
+ {
+ int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
+ int* an = ab + sizeof(ab)/sizeof(ab[0]);
+ typedef test_allocator<MoveOnly> A;
+ std::deque<MoveOnly, A> c1(A(1));
+ for (int* p = ab; p < an; ++p)
+ c1.push_back(MoveOnly(*p));
+ std::deque<MoveOnly, A> c2(A(1));
+ for (int* p = ab; p < an; ++p)
+ c2.push_back(MoveOnly(*p));
+ std::deque<MoveOnly, A> c3(std::move(c1), A(1));
+ assert(c2 == c3);
+ assert(c3.get_allocator() == A(1));
+ assert(c1.size() == 0);
+ }
+ {
+ int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
+ int* an = ab + sizeof(ab)/sizeof(ab[0]);
+ typedef other_allocator<MoveOnly> A;
+ std::deque<MoveOnly, A> c1(A(1));
+ for (int* p = ab; p < an; ++p)
+ c1.push_back(MoveOnly(*p));
+ std::deque<MoveOnly, A> c2(A(1));
+ for (int* p = ab; p < an; ++p)
+ c2.push_back(MoveOnly(*p));
+ std::deque<MoveOnly, A> c3(std::move(c1), A(3));
+ assert(c2 == c3);
+ assert(c3.get_allocator() == A(3));
+ assert(c1.size() != 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
+ int* an = ab + sizeof(ab)/sizeof(ab[0]);
+ typedef min_allocator<MoveOnly> A;
+ std::deque<MoveOnly, A> c1(A{});
+ for (int* p = ab; p < an; ++p)
+ c1.push_back(MoveOnly(*p));
+ std::deque<MoveOnly, A> c2(A{});
+ for (int* p = ab; p < an; ++p)
+ c2.push_back(MoveOnly(*p));
+ std::deque<MoveOnly, A> c3(std::move(c1), A());
+ assert(c2 == c3);
+ assert(c3.get_allocator() == A());
+ assert(c1.size() == 0);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/sequences/deque/deque.cons/move_assign.pass.cpp b/test/std/containers/sequences/deque/deque.cons/move_assign.pass.cpp
new file mode 100644
index 000000000000..e50cd8ed508d
--- /dev/null
+++ b/test/std/containers/sequences/deque/deque.cons/move_assign.pass.cpp
@@ -0,0 +1,91 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// deque& operator=(deque&& c);
+
+#include <deque>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
+ int* an = ab + sizeof(ab)/sizeof(ab[0]);
+ typedef test_allocator<MoveOnly> A;
+ std::deque<MoveOnly, A> c1(A(5));
+ for (int* p = ab; p < an; ++p)
+ c1.push_back(MoveOnly(*p));
+ std::deque<MoveOnly, A> c2(A(5));
+ for (int* p = ab; p < an; ++p)
+ c2.push_back(MoveOnly(*p));
+ std::deque<MoveOnly, A> c3(A(5));
+ c3 = std::move(c1);
+ assert(c2 == c3);
+ assert(c1.size() == 0);
+ assert(c3.get_allocator() == A(5));
+ }
+ {
+ int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
+ int* an = ab + sizeof(ab)/sizeof(ab[0]);
+ typedef test_allocator<MoveOnly> A;
+ std::deque<MoveOnly, A> c1(A(5));
+ for (int* p = ab; p < an; ++p)
+ c1.push_back(MoveOnly(*p));
+ std::deque<MoveOnly, A> c2(A(5));
+ for (int* p = ab; p < an; ++p)
+ c2.push_back(MoveOnly(*p));
+ std::deque<MoveOnly, A> c3(A(6));
+ c3 = std::move(c1);
+ assert(c2 == c3);
+ assert(c1.size() != 0);
+ assert(c3.get_allocator() == A(6));
+ }
+ {
+ int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
+ int* an = ab + sizeof(ab)/sizeof(ab[0]);
+ typedef other_allocator<MoveOnly> A;
+ std::deque<MoveOnly, A> c1(A(5));
+ for (int* p = ab; p < an; ++p)
+ c1.push_back(MoveOnly(*p));
+ std::deque<MoveOnly, A> c2(A(5));
+ for (int* p = ab; p < an; ++p)
+ c2.push_back(MoveOnly(*p));
+ std::deque<MoveOnly, A> c3(A(6));
+ c3 = std::move(c1);
+ assert(c2 == c3);
+ assert(c1.size() == 0);
+ assert(c3.get_allocator() == A(5));
+ }
+#if __cplusplus >= 201103L
+ {
+ int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
+ int* an = ab + sizeof(ab)/sizeof(ab[0]);
+ typedef min_allocator<MoveOnly> A;
+ std::deque<MoveOnly, A> c1(A{});
+ for (int* p = ab; p < an; ++p)
+ c1.push_back(MoveOnly(*p));
+ std::deque<MoveOnly, A> c2(A{});
+ for (int* p = ab; p < an; ++p)
+ c2.push_back(MoveOnly(*p));
+ std::deque<MoveOnly, A> c3(A{});
+ c3 = std::move(c1);
+ assert(c2 == c3);
+ assert(c1.size() == 0);
+ assert(c3.get_allocator() == A());
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/sequences/deque/deque.cons/move_assign_noexcept.pass.cpp b/test/std/containers/sequences/deque/deque.cons/move_assign_noexcept.pass.cpp
new file mode 100644
index 000000000000..24180b5b5bdd
--- /dev/null
+++ b/test/std/containers/sequences/deque/deque.cons/move_assign_noexcept.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// deque& operator=(deque&& c)
+// noexcept(
+// allocator_type::propagate_on_container_move_assignment::value &&
+// is_nothrow_move_assignable<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <deque>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_alloc
+{
+ typedef T value_type;
+ some_alloc(const some_alloc&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::deque<MoveOnly> C;
+ static_assert(std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::deque<MoveOnly, test_allocator<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::deque<MoveOnly, other_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::deque<MoveOnly, some_alloc<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/deque/deque.cons/move_noexcept.pass.cpp b/test/std/containers/sequences/deque/deque.cons/move_noexcept.pass.cpp
new file mode 100644
index 000000000000..0ea0431be8e2
--- /dev/null
+++ b/test/std/containers/sequences/deque/deque.cons/move_noexcept.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// deque(deque&&)
+// noexcept(is_nothrow_move_constructible<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <deque>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_alloc
+{
+ typedef T value_type;
+ some_alloc(const some_alloc&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::deque<MoveOnly> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::deque<MoveOnly, test_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::deque<MoveOnly, other_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::deque<MoveOnly, some_alloc<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_constructible<C>::value, "");
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/deque/deque.cons/op_equal.pass.cpp b/test/std/containers/sequences/deque/deque.cons/op_equal.pass.cpp
new file mode 100644
index 000000000000..3a6ec8370b84
--- /dev/null
+++ b/test/std/containers/sequences/deque/deque.cons/op_equal.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// deque& operator=(const deque& c);
+
+#include <deque>
+#include <cassert>
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+template <class C>
+void
+test(const C& x)
+{
+ C c;
+ c = x;
+ assert(c == x);
+}
+
+int main()
+{
+ {
+ int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
+ int* an = ab + sizeof(ab)/sizeof(ab[0]);
+ test(std::deque<int>(ab, an));
+ }
+ {
+ std::deque<int, test_allocator<int> > l(3, 2, test_allocator<int>(5));
+ std::deque<int, test_allocator<int> > l2(l, test_allocator<int>(3));
+ l2 = l;
+ assert(l2 == l);
+ assert(l2.get_allocator() == test_allocator<int>(3));
+ }
+ {
+ std::deque<int, other_allocator<int> > l(3, 2, other_allocator<int>(5));
+ std::deque<int, other_allocator<int> > l2(l, other_allocator<int>(3));
+ l2 = l;
+ assert(l2 == l);
+ assert(l2.get_allocator() == other_allocator<int>(5));
+ }
+#if __cplusplus >= 201103L
+ {
+ int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
+ int* an = ab + sizeof(ab)/sizeof(ab[0]);
+ test(std::deque<int, min_allocator<int>>(ab, an));
+ }
+ {
+ std::deque<int, min_allocator<int> > l(3, 2, min_allocator<int>());
+ std::deque<int, min_allocator<int> > l2(l, min_allocator<int>());
+ l2 = l;
+ assert(l2 == l);
+ assert(l2.get_allocator() == min_allocator<int>());
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/deque/deque.cons/op_equal_initializer_list.pass.cpp b/test/std/containers/sequences/deque/deque.cons/op_equal_initializer_list.pass.cpp
new file mode 100644
index 000000000000..6468e4329bda
--- /dev/null
+++ b/test/std/containers/sequences/deque/deque.cons/op_equal_initializer_list.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// deque& operator=(initializer_list<value_type> il);
+
+#include <deque>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ std::deque<int> d;
+ d = {3, 4, 5, 6};
+ assert(d.size() == 4);
+ assert(d[0] == 3);
+ assert(d[1] == 4);
+ assert(d[2] == 5);
+ assert(d[3] == 6);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::deque<int, min_allocator<int>> d;
+ d = {3, 4, 5, 6};
+ assert(d.size() == 4);
+ assert(d[0] == 3);
+ assert(d[1] == 4);
+ assert(d[2] == 5);
+ assert(d[3] == 6);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/containers/sequences/deque/deque.cons/size.pass.cpp b/test/std/containers/sequences/deque/deque.cons/size.pass.cpp
new file mode 100644
index 000000000000..d2e324b0e3f5
--- /dev/null
+++ b/test/std/containers/sequences/deque/deque.cons/size.pass.cpp
@@ -0,0 +1,113 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// explicit deque(size_type n);
+
+#include <deque>
+#include <cassert>
+
+#include "../../../stack_allocator.h"
+#include "DefaultOnly.h"
+#include "min_allocator.h"
+
+template <class T, class Allocator>
+void
+test2(unsigned n)
+{
+#if _LIBCPP_STD_VER > 11
+ typedef std::deque<T, Allocator> C;
+ typedef typename C::const_iterator const_iterator;
+ assert(DefaultOnly::count == 0);
+ {
+ C d(n, Allocator());
+ assert(DefaultOnly::count == n);
+ assert(d.size() == n);
+ assert(distance(d.begin(), d.end()) == d.size());
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ for (const_iterator i = d.begin(), e = d.end(); i != e; ++i)
+ assert(*i == T());
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ }
+ assert(DefaultOnly::count == 0);
+#endif
+}
+
+template <class T, class Allocator>
+void
+test1(unsigned n)
+{
+ typedef std::deque<T, Allocator> C;
+ typedef typename C::const_iterator const_iterator;
+ assert(DefaultOnly::count == 0);
+ {
+ C d(n);
+ assert(DefaultOnly::count == n);
+ assert(d.size() == n);
+ assert(distance(d.begin(), d.end()) == d.size());
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ for (const_iterator i = d.begin(), e = d.end(); i != e; ++i)
+ assert(*i == T());
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ }
+ assert(DefaultOnly::count == 0);
+}
+
+template <class T, class Allocator>
+void
+test3(unsigned n, Allocator const &alloc = Allocator())
+{
+#if _LIBCPP_STD_VER > 11
+ typedef std::deque<T, Allocator> C;
+ typedef typename C::const_iterator const_iterator;
+ {
+ C d(n, alloc);
+ assert(d.size() == n);
+ assert(d.get_allocator() == alloc);
+ }
+#endif
+}
+
+template <class T, class Allocator>
+void
+test(unsigned n)
+{
+ test1<T, Allocator> ( n );
+ test2<T, Allocator> ( n );
+}
+
+int main()
+{
+ test<DefaultOnly, std::allocator<DefaultOnly> >(0);
+ test<DefaultOnly, std::allocator<DefaultOnly> >(1);
+ test<DefaultOnly, std::allocator<DefaultOnly> >(10);
+ test<DefaultOnly, std::allocator<DefaultOnly> >(1023);
+ test<DefaultOnly, std::allocator<DefaultOnly> >(1024);
+ test<DefaultOnly, std::allocator<DefaultOnly> >(1025);
+ test<DefaultOnly, std::allocator<DefaultOnly> >(2047);
+ test<DefaultOnly, std::allocator<DefaultOnly> >(2048);
+ test<DefaultOnly, std::allocator<DefaultOnly> >(2049);
+ test<DefaultOnly, std::allocator<DefaultOnly> >(4095);
+ test<DefaultOnly, std::allocator<DefaultOnly> >(4096);
+ test<DefaultOnly, std::allocator<DefaultOnly> >(4097);
+
+ test1<DefaultOnly, stack_allocator<DefaultOnly, 4096> >(4095);
+
+#if __cplusplus >= 201103L
+ test<DefaultOnly, min_allocator<DefaultOnly> >(4095);
+#endif
+
+#if _LIBCPP_STD_VER > 11
+ test3<DefaultOnly, std::allocator<DefaultOnly>> (1023);
+ test3<int, std::allocator<int>>(1);
+ test3<int, min_allocator<int>> (3);
+#endif
+
+}
diff --git a/test/std/containers/sequences/deque/deque.cons/size_value.pass.cpp b/test/std/containers/sequences/deque/deque.cons/size_value.pass.cpp
new file mode 100644
index 000000000000..859deba1e1ae
--- /dev/null
+++ b/test/std/containers/sequences/deque/deque.cons/size_value.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// deque(size_type n, const value_type& v);
+
+#include <deque>
+#include <cassert>
+
+#include "../../../stack_allocator.h"
+#include "min_allocator.h"
+
+template <class T, class Allocator>
+void
+test(unsigned n, const T& x)
+{
+ typedef std::deque<T, Allocator> C;
+ typedef typename C::const_iterator const_iterator;
+ C d(n, x);
+ assert(d.size() == n);
+ assert(distance(d.begin(), d.end()) == d.size());
+ for (const_iterator i = d.begin(), e = d.end(); i != e; ++i)
+ assert(*i == x);
+}
+
+int main()
+{
+ test<int, std::allocator<int> >(0, 5);
+ test<int, std::allocator<int> >(1, 10);
+ test<int, std::allocator<int> >(10, 11);
+ test<int, std::allocator<int> >(1023, -11);
+ test<int, std::allocator<int> >(1024, 25);
+ test<int, std::allocator<int> >(1025, 0);
+ test<int, std::allocator<int> >(2047, 110);
+ test<int, std::allocator<int> >(2048, -500);
+ test<int, std::allocator<int> >(2049, 654);
+ test<int, std::allocator<int> >(4095, 78);
+ test<int, std::allocator<int> >(4096, 1165);
+ test<int, std::allocator<int> >(4097, 157);
+ test<int, stack_allocator<int, 4096> >(4095, 90);
+#if __cplusplus >= 201103L
+ test<int, min_allocator<int> >(4095, 90);
+#endif
+}
diff --git a/test/std/containers/sequences/deque/deque.cons/size_value_alloc.pass.cpp b/test/std/containers/sequences/deque/deque.cons/size_value_alloc.pass.cpp
new file mode 100644
index 000000000000..5693be702de7
--- /dev/null
+++ b/test/std/containers/sequences/deque/deque.cons/size_value_alloc.pass.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// deque(size_type n, const value_type& v, const allocator_type& a);
+
+#include <deque>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class T, class Allocator>
+void
+test(unsigned n, const T& x, const Allocator& a)
+{
+ typedef std::deque<T, Allocator> C;
+ typedef typename C::const_iterator const_iterator;
+ C d(n, x, a);
+ assert(d.get_allocator() == a);
+ assert(d.size() == n);
+ assert(distance(d.begin(), d.end()) == d.size());
+ for (const_iterator i = d.begin(), e = d.end(); i != e; ++i)
+ assert(*i == x);
+}
+
+int main()
+{
+ {
+ std::allocator<int> a;
+ test(0, 5, a);
+ test(1, 10, a);
+ test(10, 11, a);
+ test(1023, -11, a);
+ test(1024, 25, a);
+ test(1025, 0, a);
+ test(2047, 110, a);
+ test(2048, -500, a);
+ test(2049, 654, a);
+ test(4095, 78, a);
+ test(4096, 1165, a);
+ test(4097, 157, a);
+ }
+#if __cplusplus >= 201103L
+ {
+ min_allocator<int> a;
+ test(0, 5, a);
+ test(1, 10, a);
+ test(10, 11, a);
+ test(1023, -11, a);
+ test(1024, 25, a);
+ test(1025, 0, a);
+ test(2047, 110, a);
+ test(2048, -500, a);
+ test(2049, 654, a);
+ test(4095, 78, a);
+ test(4096, 1165, a);
+ test(4097, 157, a);
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/deque/deque.modifiers/emplace.pass.cpp b/test/std/containers/sequences/deque/deque.modifiers/emplace.pass.cpp
new file mode 100644
index 000000000000..7a0a2512ee2f
--- /dev/null
+++ b/test/std/containers/sequences/deque/deque.modifiers/emplace.pass.cpp
@@ -0,0 +1,112 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// template <class... Args> iterator emplace(const_iterator p, Args&&... args);
+
+#include <deque>
+#include <cassert>
+
+#include "../../../Emplaceable.h"
+#include "min_allocator.h"
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class C>
+C
+make(int size, int start = 0 )
+{
+ const int b = 4096 / sizeof(int);
+ int init = 0;
+ if (start > 0)
+ {
+ init = (start+1) / b + ((start+1) % b != 0);
+ init *= b;
+ --init;
+ }
+ C c(init);
+ for (int i = 0; i < init-start; ++i)
+ c.pop_back();
+ for (int i = 0; i < size; ++i)
+ c.push_back(Emplaceable());
+ for (int i = 0; i < start; ++i)
+ c.pop_front();
+ return c;
+}
+
+template <class C>
+void
+test(int P, C& c1)
+{
+ typedef typename C::iterator I;
+ typedef typename C::const_iterator CI;
+ std::size_t c1_osize = c1.size();
+ CI i = c1.emplace(c1.begin() + P, Emplaceable(1, 2.5));
+ assert(i == c1.begin() + P);
+ assert(c1.size() == c1_osize + 1);
+ assert(distance(c1.begin(), c1.end()) == c1.size());
+ assert(*i == Emplaceable(1, 2.5));
+}
+
+template <class C>
+void
+testN(int start, int N)
+{
+ typedef typename C::iterator I;
+ typedef typename C::const_iterator CI;
+ for (int i = 0; i <= 3; ++i)
+ {
+ if (0 <= i && i <= N)
+ {
+ C c1 = make<C>(N, start);
+ test(i, c1);
+ }
+ }
+ for (int i = N/2-1; i <= N/2+1; ++i)
+ {
+ if (0 <= i && i <= N)
+ {
+ C c1 = make<C>(N, start);
+ test(i, c1);
+ }
+ }
+ for (int i = N - 3; i <= N; ++i)
+ {
+ if (0 <= i && i <= N)
+ {
+ C c1 = make<C>(N, start);
+ test(i, c1);
+ }
+ }
+}
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ testN<std::deque<Emplaceable> >(rng[i], rng[j]);
+ }
+#if __cplusplus >= 201103L
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ testN<std::deque<Emplaceable, min_allocator<Emplaceable>> >(rng[i], rng[j]);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/sequences/deque/deque.modifiers/emplace_back.pass.cpp b/test/std/containers/sequences/deque/deque.modifiers/emplace_back.pass.cpp
new file mode 100644
index 000000000000..cf717c2e2f27
--- /dev/null
+++ b/test/std/containers/sequences/deque/deque.modifiers/emplace_back.pass.cpp
@@ -0,0 +1,87 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// template <class... Args> void emplace_back(Args&&... args);
+
+#include <deque>
+#include <cassert>
+
+#include "../../../Emplaceable.h"
+#include "min_allocator.h"
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class C>
+C
+make(int size, int start = 0 )
+{
+ const int b = 4096 / sizeof(int);
+ int init = 0;
+ if (start > 0)
+ {
+ init = (start+1) / b + ((start+1) % b != 0);
+ init *= b;
+ --init;
+ }
+ C c(init);
+ for (int i = 0; i < init-start; ++i)
+ c.pop_back();
+ for (int i = 0; i < size; ++i)
+ c.push_back(Emplaceable());
+ for (int i = 0; i < start; ++i)
+ c.pop_front();
+ return c;
+}
+
+template <class C>
+void
+test(C& c1)
+{
+ typedef typename C::iterator I;
+ std::size_t c1_osize = c1.size();
+ c1.emplace_back(Emplaceable(1, 2.5));
+ assert(c1.size() == c1_osize + 1);
+ assert(distance(c1.begin(), c1.end()) == c1.size());
+ I i = c1.end();
+ assert(*--i == Emplaceable(1, 2.5));
+}
+
+template <class C>
+void
+testN(int start, int N)
+{
+ C c1 = make<C>(N, start);
+ test(c1);
+}
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ testN<std::deque<Emplaceable> >(rng[i], rng[j]);
+ }
+#if __cplusplus >= 201103L
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ testN<std::deque<Emplaceable, min_allocator<Emplaceable>> >(rng[i], rng[j]);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/sequences/deque/deque.modifiers/emplace_front.pass.cpp b/test/std/containers/sequences/deque/deque.modifiers/emplace_front.pass.cpp
new file mode 100644
index 000000000000..becf94ffb4ef
--- /dev/null
+++ b/test/std/containers/sequences/deque/deque.modifiers/emplace_front.pass.cpp
@@ -0,0 +1,87 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// template <class... Args> void emplace_front(Args&&... args);
+
+#include <deque>
+#include <cassert>
+
+#include "../../../Emplaceable.h"
+#include "min_allocator.h"
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class C>
+C
+make(int size, int start = 0 )
+{
+ const int b = 4096 / sizeof(int);
+ int init = 0;
+ if (start > 0)
+ {
+ init = (start+1) / b + ((start+1) % b != 0);
+ init *= b;
+ --init;
+ }
+ C c(init);
+ for (int i = 0; i < init-start; ++i)
+ c.pop_back();
+ for (int i = 0; i < size; ++i)
+ c.push_back(Emplaceable());
+ for (int i = 0; i < start; ++i)
+ c.pop_front();
+ return c;
+}
+
+template <class C>
+void
+test(C& c1)
+{
+ typedef typename C::iterator I;
+ std::size_t c1_osize = c1.size();
+ c1.emplace_front(Emplaceable(1, 2.5));
+ assert(c1.size() == c1_osize + 1);
+ assert(distance(c1.begin(), c1.end()) == c1.size());
+ I i = c1.begin();
+ assert(*i == Emplaceable(1, 2.5));
+}
+
+template <class C>
+void
+testN(int start, int N)
+{
+ C c1 = make<C>(N, start);
+ test(c1);
+}
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ testN<std::deque<Emplaceable> >(rng[i], rng[j]);
+ }
+#if __cplusplus >= 201103L
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ testN<std::deque<Emplaceable, min_allocator<Emplaceable>> >(rng[i], rng[j]);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/sequences/deque/deque.modifiers/erase_iter.invalidation.pass.cpp b/test/std/containers/sequences/deque/deque.modifiers/erase_iter.invalidation.pass.cpp
new file mode 100644
index 000000000000..49465cddaef7
--- /dev/null
+++ b/test/std/containers/sequences/deque/deque.modifiers/erase_iter.invalidation.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// iterator erase(const_iterator f)
+
+// Erasing items from the beginning or the end of a deque shall not invalidate iterators
+// to items that were not erased.
+
+#include <deque>
+#include <cassert>
+
+template <typename C>
+void del_at_start(C c)
+{
+ typename C::iterator first = c.begin();
+ typename C::iterator it1 = first + 1;
+ typename C::iterator it2 = c.end() - 1;
+
+ c.erase (first);
+
+ typename C::iterator it3 = c.begin();
+ typename C::iterator it4 = c.end() - 1;
+ assert( it1 == it3);
+ assert( *it1 == *it3);
+ assert(&*it1 == &*it3);
+ assert( it2 == it4);
+ assert( *it2 == *it4);
+ assert(&*it2 == &*it4);
+}
+
+template <typename C>
+void del_at_end(C c)
+{
+ typename C::iterator first = c.end() - 1;
+ typename C::iterator it1 = c.begin();
+ typename C::iterator it2 = first - 1;
+
+ c.erase (first);
+
+ typename C::iterator it3 = c.begin();
+ typename C::iterator it4 = c.end() - 1;
+ assert( it1 == it3);
+ assert( *it1 == *it3);
+ assert(&*it1 == &*it3);
+ assert( it2 == it4);
+ assert( *it2 == *it4);
+ assert(&*it2 == &*it4);
+}
+
+int main()
+{
+ std::deque<int> queue;
+ for (int i = 0; i < 20; ++i)
+ queue.push_back(i);
+
+ while (queue.size() > 1)
+ {
+ del_at_start(queue);
+ del_at_end(queue);
+ queue.pop_back();
+ }
+}
diff --git a/test/std/containers/sequences/deque/deque.modifiers/erase_iter.pass.cpp b/test/std/containers/sequences/deque/deque.modifiers/erase_iter.pass.cpp
new file mode 100644
index 000000000000..a45b75d25c9c
--- /dev/null
+++ b/test/std/containers/sequences/deque/deque.modifiers/erase_iter.pass.cpp
@@ -0,0 +1,90 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// iterator erase(const_iterator p)
+
+#include <deque>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class C>
+C
+make(int size, int start = 0 )
+{
+ const int b = 4096 / sizeof(int);
+ int init = 0;
+ if (start > 0)
+ {
+ init = (start+1) / b + ((start+1) % b != 0);
+ init *= b;
+ --init;
+ }
+ C c(init, 0);
+ for (int i = 0; i < init-start; ++i)
+ c.pop_back();
+ for (int i = 0; i < size; ++i)
+ c.push_back(i);
+ for (int i = 0; i < start; ++i)
+ c.pop_front();
+ return c;
+}
+
+template <class C>
+void
+test(int P, C& c1)
+{
+ typedef typename C::iterator I;
+ assert(P < c1.size());
+ std::size_t c1_osize = c1.size();
+ I i = c1.erase(c1.cbegin() + P);
+ assert(i == c1.begin() + P);
+ assert(c1.size() == c1_osize - 1);
+ assert(distance(c1.begin(), c1.end()) == c1.size());
+ i = c1.begin();
+ int j = 0;
+ for (; j < P; ++j, ++i)
+ assert(*i == j);
+ for (++j; j < c1_osize; ++j, ++i)
+ assert(*i == j);
+}
+
+template <class C>
+void
+testN(int start, int N)
+{
+ int pstep = std::max(N / std::max(std::min(N, 10), 1), 1);
+ for (int p = 0; p < N; p += pstep)
+ {
+ C c1 = make<C>(N, start);
+ test(p, c1);
+ }
+}
+
+int main()
+{
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ testN<std::deque<int> >(rng[i], rng[j]);
+ }
+#if __cplusplus >= 201103L
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j]);
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/deque/deque.modifiers/erase_iter_iter.invalidation.pass.cpp b/test/std/containers/sequences/deque/deque.modifiers/erase_iter_iter.invalidation.pass.cpp
new file mode 100644
index 000000000000..c785e264db06
--- /dev/null
+++ b/test/std/containers/sequences/deque/deque.modifiers/erase_iter_iter.invalidation.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// iterator erase(const_iterator f, const_iterator l)
+
+// Erasing items from the beginning or the end of a deque shall not invalidate iterators
+// to items that were not erased.
+
+
+#include <deque>
+#include <cstdint>
+#include <cassert>
+
+template <typename C>
+void del_at_start(C c, size_t num)
+{
+ typename C::iterator first = c.begin();
+ typename C::iterator last = first + num;
+ typename C::iterator it1 = last;
+ typename C::iterator it2 = c.end() - 1;
+
+ c.erase (first, last);
+
+ typename C::iterator it3 = c.begin();
+ typename C::iterator it4 = c.end() - 1;
+ assert( it1 == it3);
+ assert( *it1 == *it3);
+ assert(&*it1 == &*it3);
+ assert( it2 == it4);
+ assert( *it2 == *it4);
+ assert(&*it2 == &*it4);
+}
+
+template <typename C>
+void del_at_end(C c, size_t num)
+{
+ typename C::iterator last = c.end();
+ typename C::iterator first = last - num;
+ typename C::iterator it1 = c.begin();
+ typename C::iterator it2 = first - 1;
+
+ c.erase (first, last);
+
+ typename C::iterator it3 = c.begin();
+ typename C::iterator it4 = c.end() - 1;
+ assert( it1 == it3);
+ assert( *it1 == *it3);
+ assert(&*it1 == &*it3);
+ assert( it2 == it4);
+ assert( *it2 == *it4);
+ assert(&*it2 == &*it4);
+}
+
+
+int main()
+{
+ std::deque<int> queue;
+ for (int i = 0; i < 20; ++i)
+ queue.push_back(i);
+
+ while (queue.size() > 1)
+ {
+ for (size_t i = 1; i < queue.size(); ++i)
+ {
+ del_at_start(queue, i);
+ del_at_end (queue, i);
+ }
+ queue.pop_back();
+ }
+}
diff --git a/test/std/containers/sequences/deque/deque.modifiers/erase_iter_iter.pass.cpp b/test/std/containers/sequences/deque/deque.modifiers/erase_iter_iter.pass.cpp
new file mode 100644
index 000000000000..0576aca5c1a8
--- /dev/null
+++ b/test/std/containers/sequences/deque/deque.modifiers/erase_iter_iter.pass.cpp
@@ -0,0 +1,96 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// REQUIRES: long_tests
+
+// <deque>
+
+// iterator erase(const_iterator f, const_iterator l)
+
+#include <deque>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class C>
+C
+make(int size, int start = 0 )
+{
+ const int b = 4096 / sizeof(int);
+ int init = 0;
+ if (start > 0)
+ {
+ init = (start+1) / b + ((start+1) % b != 0);
+ init *= b;
+ --init;
+ }
+ C c(init, 0);
+ for (int i = 0; i < init-start; ++i)
+ c.pop_back();
+ for (int i = 0; i < size; ++i)
+ c.push_back(i);
+ for (int i = 0; i < start; ++i)
+ c.pop_front();
+ return c;
+}
+
+template <class C>
+void
+test(int P, C& c1, int size)
+{
+ typedef typename C::iterator I;
+ assert(P + size <= c1.size());
+ std::size_t c1_osize = c1.size();
+ I i = c1.erase(c1.cbegin() + P, c1.cbegin() + (P + size));
+ assert(i == c1.begin() + P);
+ assert(c1.size() == c1_osize - size);
+ assert(distance(c1.begin(), c1.end()) == c1.size());
+ i = c1.begin();
+ int j = 0;
+ for (; j < P; ++j, ++i)
+ assert(*i == j);
+ for (j += size; j < c1_osize; ++j, ++i)
+ assert(*i == j);
+}
+
+template <class C>
+void
+testN(int start, int N)
+{
+ int pstep = std::max(N / std::max(std::min(N, 10), 1), 1);
+ for (int p = 0; p <= N; p += pstep)
+ {
+ int sstep = std::max((N - p) / std::max(std::min(N - p, 10), 1), 1);
+ for (int s = 0; s <= N - p; s += sstep)
+ {
+ C c1 = make<C>(N, start);
+ test(p, c1, s);
+ }
+ }
+}
+
+int main()
+{
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ testN<std::deque<int> >(rng[i], rng[j]);
+ }
+#if __cplusplus >= 201103L
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j]);
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/deque/deque.modifiers/insert_iter_initializer_list.pass.cpp b/test/std/containers/sequences/deque/deque.modifiers/insert_iter_initializer_list.pass.cpp
new file mode 100644
index 000000000000..5f7804023c7f
--- /dev/null
+++ b/test/std/containers/sequences/deque/deque.modifiers/insert_iter_initializer_list.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// iterator insert(const_iterator p, initializer_list<value_type> il);
+
+#include <deque>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ std::deque<int> d(10, 1);
+ std::deque<int>::iterator i = d.insert(d.cbegin() + 2, {3, 4, 5, 6});
+ assert(d.size() == 14);
+ assert(i == d.begin() + 2);
+ assert(d[0] == 1);
+ assert(d[1] == 1);
+ assert(d[2] == 3);
+ assert(d[3] == 4);
+ assert(d[4] == 5);
+ assert(d[5] == 6);
+ assert(d[6] == 1);
+ assert(d[7] == 1);
+ assert(d[8] == 1);
+ assert(d[9] == 1);
+ assert(d[10] == 1);
+ assert(d[11] == 1);
+ assert(d[12] == 1);
+ assert(d[13] == 1);
+ }
+ {
+ std::deque<int, min_allocator<int>> d(10, 1);
+ std::deque<int, min_allocator<int>>::iterator i = d.insert(d.cbegin() + 2, {3, 4, 5, 6});
+ assert(d.size() == 14);
+ assert(i == d.begin() + 2);
+ assert(d[0] == 1);
+ assert(d[1] == 1);
+ assert(d[2] == 3);
+ assert(d[3] == 4);
+ assert(d[4] == 5);
+ assert(d[5] == 6);
+ assert(d[6] == 1);
+ assert(d[7] == 1);
+ assert(d[8] == 1);
+ assert(d[9] == 1);
+ assert(d[10] == 1);
+ assert(d[11] == 1);
+ assert(d[12] == 1);
+ assert(d[13] == 1);
+ }
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/containers/sequences/deque/deque.modifiers/insert_iter_iter.pass.cpp b/test/std/containers/sequences/deque/deque.modifiers/insert_iter_iter.pass.cpp
new file mode 100644
index 000000000000..ecb95d72a21e
--- /dev/null
+++ b/test/std/containers/sequences/deque/deque.modifiers/insert_iter_iter.pass.cpp
@@ -0,0 +1,295 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// REQUIRES: long_tests
+
+// <deque>
+
+// template <class InputIterator>
+// iterator insert (const_iterator p, InputIterator f, InputIterator l);
+
+#include <deque>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "MoveOnly.h"
+#include "../../../stack_allocator.h"
+#include "min_allocator.h"
+
+template <class C>
+C
+make(int size, int start = 0 )
+{
+ const int b = 4096 / sizeof(int);
+ int init = 0;
+ if (start > 0)
+ {
+ init = (start+1) / b + ((start+1) % b != 0);
+ init *= b;
+ --init;
+ }
+ C c(init, 0);
+ for (int i = 0; i < init-start; ++i)
+ c.pop_back();
+ for (int i = 0; i < size; ++i)
+ c.push_back(i);
+ for (int i = 0; i < start; ++i)
+ c.pop_front();
+ return c;
+}
+
+template <class C>
+void
+test(int P, const C& c0, const C& c2)
+{
+ {
+ typedef typename C::iterator I;
+ typedef typename C::const_iterator CI;
+ typedef input_iterator<CI> BCI;
+ C c1 = c0;
+ std::size_t c1_osize = c1.size();
+ CI i = c1.insert(c1.begin() + P, BCI(c2.begin()), BCI(c2.end()));
+ assert(i == c1.begin() + P);
+ assert(c1.size() == c1_osize + c2.size());
+ assert(distance(c1.begin(), c1.end()) == c1.size());
+ i = c1.begin();
+ for (int j = 0; j < P; ++j, ++i)
+ assert(*i == j);
+ for (int j = 0; j < c2.size(); ++j, ++i)
+ assert(*i == j);
+ for (int j = P; j < c1_osize; ++j, ++i)
+ assert(*i == j);
+ }
+ {
+ typedef typename C::iterator I;
+ typedef typename C::const_iterator CI;
+ typedef forward_iterator<CI> BCI;
+ C c1 = c0;
+ std::size_t c1_osize = c1.size();
+ CI i = c1.insert(c1.begin() + P, BCI(c2.begin()), BCI(c2.end()));
+ assert(i == c1.begin() + P);
+ assert(c1.size() == c1_osize + c2.size());
+ assert(distance(c1.begin(), c1.end()) == c1.size());
+ i = c1.begin();
+ for (int j = 0; j < P; ++j, ++i)
+ assert(*i == j);
+ for (int j = 0; j < c2.size(); ++j, ++i)
+ assert(*i == j);
+ for (int j = P; j < c1_osize; ++j, ++i)
+ assert(*i == j);
+ }
+ {
+ typedef typename C::iterator I;
+ typedef typename C::const_iterator CI;
+ typedef bidirectional_iterator<CI> BCI;
+ C c1 = c0;
+ std::size_t c1_osize = c1.size();
+ CI i = c1.insert(c1.begin() + P, BCI(c2.begin()), BCI(c2.end()));
+ assert(i == c1.begin() + P);
+ assert(c1.size() == c1_osize + c2.size());
+ assert(distance(c1.begin(), c1.end()) == c1.size());
+ i = c1.begin();
+ for (int j = 0; j < P; ++j, ++i)
+ assert(*i == j);
+ for (int j = 0; j < c2.size(); ++j, ++i)
+ assert(*i == j);
+ for (int j = P; j < c1_osize; ++j, ++i)
+ assert(*i == j);
+ }
+}
+
+template <class C>
+void
+testN(int start, int N, int M)
+{
+ typedef typename C::iterator I;
+ typedef typename C::const_iterator CI;
+ for (int i = 0; i <= 3; ++i)
+ {
+ if (0 <= i && i <= N)
+ {
+ C c1 = make<C>(N, start);
+ C c2 = make<C>(M);
+ test(i, c1, c2);
+ }
+ }
+ for (int i = M-1; i <= M+1; ++i)
+ {
+ if (0 <= i && i <= N)
+ {
+ C c1 = make<C>(N, start);
+ C c2 = make<C>(M);
+ test(i, c1, c2);
+ }
+ }
+ for (int i = N/2-1; i <= N/2+1; ++i)
+ {
+ if (0 <= i && i <= N)
+ {
+ C c1 = make<C>(N, start);
+ C c2 = make<C>(M);
+ test(i, c1, c2);
+ }
+ }
+ for (int i = N - M - 1; i <= N - M + 1; ++i)
+ {
+ if (0 <= i && i <= N)
+ {
+ C c1 = make<C>(N, start);
+ C c2 = make<C>(M);
+ test(i, c1, c2);
+ }
+ }
+ for (int i = N - M - 1; i <= N - M + 1; ++i)
+ {
+ if (0 <= i && i <= N)
+ {
+ C c1 = make<C>(N, start);
+ C c2 = make<C>(M);
+ test(i, c1, c2);
+ }
+ }
+ for (int i = N - 3; i <= N; ++i)
+ {
+ if (0 <= i && i <= N)
+ {
+ C c1 = make<C>(N, start);
+ C c2 = make<C>(M);
+ test(i, c1, c2);
+ }
+ }
+}
+
+template <class C>
+void
+testI(int P, C& c1, const C& c2)
+{
+ typedef typename C::iterator I;
+ typedef typename C::const_iterator CI;
+ typedef input_iterator<CI> ICI;
+ std::size_t c1_osize = c1.size();
+ CI i = c1.insert(c1.begin() + P, ICI(c2.begin()), ICI(c2.end()));
+ assert(i == c1.begin() + P);
+ assert(c1.size() == c1_osize + c2.size());
+ assert(distance(c1.begin(), c1.end()) == c1.size());
+ i = c1.begin();
+ for (int j = 0; j < P; ++j, ++i)
+ assert(*i == j);
+ for (int j = 0; j < c2.size(); ++j, ++i)
+ assert(*i == j);
+ for (int j = P; j < c1_osize; ++j, ++i)
+ assert(*i == j);
+}
+
+template <class C>
+void
+testNI(int start, int N, int M)
+{
+ typedef typename C::iterator I;
+ typedef typename C::const_iterator CI;
+ for (int i = 0; i <= 3; ++i)
+ {
+ if (0 <= i && i <= N)
+ {
+ C c1 = make<C>(N, start);
+ C c2 = make<C>(M);
+ testI(i, c1, c2);
+ }
+ }
+ for (int i = M-1; i <= M+1; ++i)
+ {
+ if (0 <= i && i <= N)
+ {
+ C c1 = make<C>(N, start);
+ C c2 = make<C>(M);
+ testI(i, c1, c2);
+ }
+ }
+ for (int i = N/2-1; i <= N/2+1; ++i)
+ {
+ if (0 <= i && i <= N)
+ {
+ C c1 = make<C>(N, start);
+ C c2 = make<C>(M);
+ testI(i, c1, c2);
+ }
+ }
+ for (int i = N - M - 1; i <= N - M + 1; ++i)
+ {
+ if (0 <= i && i <= N)
+ {
+ C c1 = make<C>(N, start);
+ C c2 = make<C>(M);
+ testI(i, c1, c2);
+ }
+ }
+ for (int i = N - 3; i <= N; ++i)
+ {
+ if (0 <= i && i <= N)
+ {
+ C c1 = make<C>(N, start);
+ C c2 = make<C>(M);
+ testI(i, c1, c2);
+ }
+ }
+}
+
+template <class C>
+void
+test_move()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ C c;
+ typedef typename C::const_iterator CI;
+ {
+ MoveOnly mo(0);
+ typedef MoveOnly* I;
+ c.insert(c.end(), std::move_iterator<I>(&mo), std::move_iterator<I>(&mo+1));
+ }
+ int j = 0;
+ for (CI i = c.begin(); i != c.end(); ++i, ++j)
+ assert(*i == MoveOnly(j));
+ {
+ MoveOnly mo(1);
+ typedef input_iterator<MoveOnly*> I;
+ c.insert(c.end(), std::move_iterator<I>(I(&mo)), std::move_iterator<I>(I(&mo+1)));
+ }
+ j = 0;
+ for (CI i = c.begin(); i != c.end(); ++i, ++j)
+ assert(*i == MoveOnly(j));
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
+
+int main()
+{
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ for (int k = 0; k < N; ++k)
+ testN<std::deque<int> >(rng[i], rng[j], rng[k]);
+ testNI<std::deque<int> >(1500, 2000, 1000);
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ test_move<std::deque<MoveOnly, stack_allocator<MoveOnly, 2000> > >();
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ }
+#if __cplusplus >= 201103L
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ for (int k = 0; k < N; ++k)
+ testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j], rng[k]);
+ testNI<std::deque<int> >(1500, 2000, 1000);
+ test_move<std::deque<MoveOnly, min_allocator<MoveOnly> > >();
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/deque/deque.modifiers/insert_rvalue.pass.cpp b/test/std/containers/sequences/deque/deque.modifiers/insert_rvalue.pass.cpp
new file mode 100644
index 000000000000..b7e73f265028
--- /dev/null
+++ b/test/std/containers/sequences/deque/deque.modifiers/insert_rvalue.pass.cpp
@@ -0,0 +1,118 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// iterator insert (const_iterator p, value_type&& v);
+
+#include <deque>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "min_allocator.h"
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class C>
+C
+make(int size, int start = 0 )
+{
+ const int b = 4096 / sizeof(int);
+ int init = 0;
+ if (start > 0)
+ {
+ init = (start+1) / b + ((start+1) % b != 0);
+ init *= b;
+ --init;
+ }
+ C c(init);
+ for (int i = 0; i < init-start; ++i)
+ c.pop_back();
+ for (int i = 0; i < size; ++i)
+ c.push_back(MoveOnly(i));
+ for (int i = 0; i < start; ++i)
+ c.pop_front();
+ return c;
+}
+
+template <class C>
+void
+test(int P, C& c1, int x)
+{
+ typedef typename C::iterator I;
+ typedef typename C::const_iterator CI;
+ std::size_t c1_osize = c1.size();
+ CI i = c1.insert(c1.begin() + P, MoveOnly(x));
+ assert(i == c1.begin() + P);
+ assert(c1.size() == c1_osize + 1);
+ assert(distance(c1.begin(), c1.end()) == c1.size());
+ i = c1.begin();
+ for (int j = 0; j < P; ++j, ++i)
+ assert(*i == MoveOnly(j));
+ assert(*i == MoveOnly(x));
+ ++i;
+ for (int j = P; j < c1_osize; ++j, ++i)
+ assert(*i == MoveOnly(j));
+}
+
+template <class C>
+void
+testN(int start, int N)
+{
+ typedef typename C::iterator I;
+ typedef typename C::const_iterator CI;
+ for (int i = 0; i <= 3; ++i)
+ {
+ if (0 <= i && i <= N)
+ {
+ C c1 = make<C>(N, start);
+ test(i, c1, -10);
+ }
+ }
+ for (int i = N/2-1; i <= N/2+1; ++i)
+ {
+ if (0 <= i && i <= N)
+ {
+ C c1 = make<C>(N, start);
+ test(i, c1, -10);
+ }
+ }
+ for (int i = N - 3; i <= N; ++i)
+ {
+ if (0 <= i && i <= N)
+ {
+ C c1 = make<C>(N, start);
+ test(i, c1, -10);
+ }
+ }
+}
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ testN<std::deque<MoveOnly> >(rng[i], rng[j]);
+ }
+#if __cplusplus >= 201103L
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ testN<std::deque<MoveOnly, min_allocator<MoveOnly>> >(rng[i], rng[j]);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/sequences/deque/deque.modifiers/insert_size_value.pass.cpp b/test/std/containers/sequences/deque/deque.modifiers/insert_size_value.pass.cpp
new file mode 100644
index 000000000000..2737dfba7739
--- /dev/null
+++ b/test/std/containers/sequences/deque/deque.modifiers/insert_size_value.pass.cpp
@@ -0,0 +1,159 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// REQUIRES: long_tests
+
+// <deque>
+
+// iterator insert (const_iterator p, size_type n, const value_type& v);
+
+#include <deque>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class C>
+C
+make(int size, int start = 0 )
+{
+ const int b = 4096 / sizeof(int);
+ int init = 0;
+ if (start > 0)
+ {
+ init = (start+1) / b + ((start+1) % b != 0);
+ init *= b;
+ --init;
+ }
+ C c(init, 0);
+ for (int i = 0; i < init-start; ++i)
+ c.pop_back();
+ for (int i = 0; i < size; ++i)
+ c.push_back(i);
+ for (int i = 0; i < start; ++i)
+ c.pop_front();
+ return c;
+}
+
+template <class C>
+void
+test(int P, C& c1, int size, int x)
+{
+ typedef typename C::iterator I;
+ typedef typename C::const_iterator CI;
+ std::size_t c1_osize = c1.size();
+ CI i = c1.insert(c1.begin() + P, size, x);
+ assert(i == c1.begin() + P);
+ assert(c1.size() == c1_osize + size);
+ assert(distance(c1.begin(), c1.end()) == c1.size());
+ i = c1.begin();
+ for (int j = 0; j < P; ++j, ++i)
+ assert(*i == j);
+ for (int j = 0; j < size; ++j, ++i)
+ assert(*i == x);
+ for (int j = P; j < c1_osize; ++j, ++i)
+ assert(*i == j);
+}
+
+template <class C>
+void
+testN(int start, int N, int M)
+{
+ typedef typename C::iterator I;
+ typedef typename C::const_iterator CI;
+ for (int i = 0; i <= 3; ++i)
+ {
+ if (0 <= i && i <= N)
+ {
+ C c1 = make<C>(N, start);
+ test(i, c1, M, -10);
+ }
+ }
+ for (int i = M-1; i <= M+1; ++i)
+ {
+ if (0 <= i && i <= N)
+ {
+ C c1 = make<C>(N, start);
+ test(i, c1, M, -10);
+ }
+ }
+ for (int i = N/2-1; i <= N/2+1; ++i)
+ {
+ if (0 <= i && i <= N)
+ {
+ C c1 = make<C>(N, start);
+ test(i, c1, M, -10);
+ }
+ }
+ for (int i = N - M - 1; i <= N - M + 1; ++i)
+ {
+ if (0 <= i && i <= N)
+ {
+ C c1 = make<C>(N, start);
+ test(i, c1, M, -10);
+ }
+ }
+ for (int i = N - 3; i <= N; ++i)
+ {
+ if (0 <= i && i <= N)
+ {
+ C c1 = make<C>(N, start);
+ test(i, c1, M, -10);
+ }
+ }
+}
+
+template <class C>
+void
+self_reference_test()
+{
+ typedef typename C::const_iterator CI;
+ for (int i = 0; i < 20; ++i)
+ {
+ for (int j = 0; j < 20; ++j)
+ {
+ C c = make<C>(20);
+ CI it = c.cbegin() + i;
+ CI jt = c.cbegin() + j;
+ c.insert(it, 5, *jt);
+ assert(c.size() == 25);
+ assert(distance(c.begin(), c.end()) == c.size());
+ it = c.cbegin();
+ for (int k = 0; k < i; ++k, ++it)
+ assert(*it == k);
+ for (int k = 0; k < 5; ++k, ++it)
+ assert(*it == j);
+ for (int k = i; k < 20; ++k, ++it)
+ assert(*it == k);
+ }
+ }
+}
+
+int main()
+{
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ for (int k = 0; k < N; ++k)
+ testN<std::deque<int> >(rng[i], rng[j], rng[k]);
+ self_reference_test<std::deque<int> >();
+ }
+#if __cplusplus >= 201103L
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ for (int k = 0; k < N; ++k)
+ testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j], rng[k]);
+ self_reference_test<std::deque<int, min_allocator<int>> >();
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/deque/deque.modifiers/insert_value.pass.cpp b/test/std/containers/sequences/deque/deque.modifiers/insert_value.pass.cpp
new file mode 100644
index 000000000000..fbbaad4f89e5
--- /dev/null
+++ b/test/std/containers/sequences/deque/deque.modifiers/insert_value.pass.cpp
@@ -0,0 +1,139 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// iterator insert (const_iterator p, const value_type& v);
+
+#include <deque>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class C>
+C
+make(int size, int start = 0 )
+{
+ const int b = 4096 / sizeof(int);
+ int init = 0;
+ if (start > 0)
+ {
+ init = (start+1) / b + ((start+1) % b != 0);
+ init *= b;
+ --init;
+ }
+ C c(init, 0);
+ for (int i = 0; i < init-start; ++i)
+ c.pop_back();
+ for (int i = 0; i < size; ++i)
+ c.push_back(i);
+ for (int i = 0; i < start; ++i)
+ c.pop_front();
+ return c;
+}
+
+template <class C>
+void
+test(int P, C& c1, int x)
+{
+ typedef typename C::iterator I;
+ typedef typename C::const_iterator CI;
+ std::size_t c1_osize = c1.size();
+ CI i = c1.insert(c1.begin() + P, x);
+ assert(i == c1.begin() + P);
+ assert(c1.size() == c1_osize + 1);
+ assert(distance(c1.begin(), c1.end()) == c1.size());
+ i = c1.begin();
+ for (int j = 0; j < P; ++j, ++i)
+ assert(*i == j);
+ assert(*i == x);
+ ++i;
+ for (int j = P; j < c1_osize; ++j, ++i)
+ assert(*i == j);
+}
+
+template <class C>
+void
+testN(int start, int N)
+{
+ typedef typename C::iterator I;
+ typedef typename C::const_iterator CI;
+ for (int i = 0; i <= 3; ++i)
+ {
+ if (0 <= i && i <= N)
+ {
+ C c1 = make<C>(N, start);
+ test(i, c1, -10);
+ }
+ }
+ for (int i = N/2-1; i <= N/2+1; ++i)
+ {
+ if (0 <= i && i <= N)
+ {
+ C c1 = make<C>(N, start);
+ test(i, c1, -10);
+ }
+ }
+ for (int i = N - 3; i <= N; ++i)
+ {
+ if (0 <= i && i <= N)
+ {
+ C c1 = make<C>(N, start);
+ test(i, c1, -10);
+ }
+ }
+}
+
+template <class C>
+void
+self_reference_test()
+{
+ typedef typename C::const_iterator CI;
+ for (int i = 0; i < 20; ++i)
+ {
+ for (int j = 0; j < 20; ++j)
+ {
+ C c = make<C>(20);
+ CI it = c.cbegin() + i;
+ CI jt = c.cbegin() + j;
+ c.insert(it, *jt);
+ assert(c.size() == 21);
+ assert(distance(c.begin(), c.end()) == c.size());
+ it = c.cbegin();
+ for (int k = 0; k < i; ++k, ++it)
+ assert(*it == k);
+ assert(*it == j);
+ ++it;
+ for (int k = i; k < 20; ++k, ++it)
+ assert(*it == k);
+ }
+ }
+}
+
+int main()
+{
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ testN<std::deque<int> >(rng[i], rng[j]);
+ self_reference_test<std::deque<int> >();
+ }
+#if __cplusplus >= 201103L
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j]);
+ self_reference_test<std::deque<int, min_allocator<int>> >();
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/deque/deque.modifiers/pop_back.invalidation.pass.cpp b/test/std/containers/sequences/deque/deque.modifiers/pop_back.invalidation.pass.cpp
new file mode 100644
index 000000000000..1d84f73ccb56
--- /dev/null
+++ b/test/std/containers/sequences/deque/deque.modifiers/pop_back.invalidation.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// void pop_back()
+
+// Erasing items from the beginning or the end of a deque shall not invalidate iterators
+// to items that were not erased.
+
+#include <deque>
+#include <cassert>
+
+template <typename C>
+void test(C c)
+{
+ typename C::iterator it1 = c.begin();
+ typename C::iterator it2 = c.end() - 2;
+
+ c.pop_back();
+
+ typename C::iterator it3 = c.begin();
+ typename C::iterator it4 = c.end() - 1;
+ assert( it1 == it3);
+ assert( *it1 == *it3);
+ assert(&*it1 == &*it3);
+ assert( it2 == it4);
+ assert( *it2 == *it4);
+ assert(&*it2 == &*it4);
+}
+
+int main()
+{
+ std::deque<int> queue;
+ for (int i = 0; i < 20; ++i)
+ queue.push_back(i);
+
+ while (queue.size() > 1)
+ {
+ test(queue);
+ queue.pop_back();
+ }
+}
diff --git a/test/std/containers/sequences/deque/deque.modifiers/pop_back.pass.cpp b/test/std/containers/sequences/deque/deque.modifiers/pop_back.pass.cpp
new file mode 100644
index 000000000000..b345faaf89e9
--- /dev/null
+++ b/test/std/containers/sequences/deque/deque.modifiers/pop_back.pass.cpp
@@ -0,0 +1,84 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// void pop_back()
+
+#include <deque>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class C>
+C
+make(int size, int start = 0 )
+{
+ const int b = 4096 / sizeof(int);
+ int init = 0;
+ if (start > 0)
+ {
+ init = (start+1) / b + ((start+1) % b != 0);
+ init *= b;
+ --init;
+ }
+ C c(init, 0);
+ for (int i = 0; i < init-start; ++i)
+ c.pop_back();
+ for (int i = 0; i < size; ++i)
+ c.push_back(i);
+ for (int i = 0; i < start; ++i)
+ c.pop_front();
+ return c;
+}
+
+template <class C>
+void
+test(C& c1)
+{
+ typedef typename C::iterator I;
+ std::size_t c1_osize = c1.size();
+ c1.pop_back();
+ assert(c1.size() == c1_osize - 1);
+ assert(distance(c1.begin(), c1.end()) == c1.size());
+ I i = c1.begin();
+ for (int j = 0; j < c1.size(); ++j, ++i)
+ assert(*i == j);
+}
+
+template <class C>
+void
+testN(int start, int N)
+{
+ if (N != 0)
+ {
+ C c1 = make<C>(N, start);
+ test(c1);
+ }
+}
+
+int main()
+{
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ testN<std::deque<int> >(rng[i], rng[j]);
+ }
+#if __cplusplus >= 201103L
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j]);
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/deque/deque.modifiers/pop_front.invalidation.pass.cpp b/test/std/containers/sequences/deque/deque.modifiers/pop_front.invalidation.pass.cpp
new file mode 100644
index 000000000000..78317f3a3f9c
--- /dev/null
+++ b/test/std/containers/sequences/deque/deque.modifiers/pop_front.invalidation.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// void pop_front()
+
+// Erasing items from the beginning or the end of a deque shall not invalidate iterators
+// to items that were not erased.
+
+#include <deque>
+#include <cassert>
+
+template <typename C>
+void test(C c)
+{
+ typename C::iterator it1 = c.begin() + 1;
+ typename C::iterator it2 = c.end() - 1;
+
+ c.pop_front();
+
+ typename C::iterator it3 = c.begin();
+ typename C::iterator it4 = c.end() - 1;
+ assert( it1 == it3);
+ assert( *it1 == *it3);
+ assert(&*it1 == &*it3);
+ assert( it2 == it4);
+ assert( *it2 == *it4);
+ assert(&*it2 == &*it4);
+}
+
+int main()
+{
+ std::deque<int> queue;
+ for (int i = 0; i < 20; ++i)
+ queue.push_back(i);
+
+ while (queue.size() > 1)
+ {
+ test(queue);
+ queue.pop_back();
+ }
+}
diff --git a/test/std/containers/sequences/deque/deque.modifiers/pop_front.pass.cpp b/test/std/containers/sequences/deque/deque.modifiers/pop_front.pass.cpp
new file mode 100644
index 000000000000..d570ec333715
--- /dev/null
+++ b/test/std/containers/sequences/deque/deque.modifiers/pop_front.pass.cpp
@@ -0,0 +1,84 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// void pop_front()
+
+#include <deque>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class C>
+C
+make(int size, int start = 0 )
+{
+ const int b = 4096 / sizeof(int);
+ int init = 0;
+ if (start > 0)
+ {
+ init = (start+1) / b + ((start+1) % b != 0);
+ init *= b;
+ --init;
+ }
+ C c(init, 0);
+ for (int i = 0; i < init-start; ++i)
+ c.pop_back();
+ for (int i = 0; i < size; ++i)
+ c.push_back(i);
+ for (int i = 0; i < start; ++i)
+ c.pop_front();
+ return c;
+}
+
+template <class C>
+void
+test(C& c1)
+{
+ typedef typename C::iterator I;
+ std::size_t c1_osize = c1.size();
+ c1.pop_front();
+ assert(c1.size() == c1_osize - 1);
+ assert(distance(c1.begin(), c1.end()) == c1.size());
+ I i = c1.begin();
+ for (int j = 1; j < c1.size(); ++j, ++i)
+ assert(*i == j);
+}
+
+template <class C>
+void
+testN(int start, int N)
+{
+ if (N != 0)
+ {
+ C c1 = make<C>(N, start);
+ test(c1);
+ }
+}
+
+int main()
+{
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ testN<std::deque<int> >(rng[i], rng[j]);
+ }
+#if __cplusplus >= 201103L
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j]);
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/deque/deque.modifiers/push_back.pass.cpp b/test/std/containers/sequences/deque/deque.modifiers/push_back.pass.cpp
new file mode 100644
index 000000000000..96df6097d994
--- /dev/null
+++ b/test/std/containers/sequences/deque/deque.modifiers/push_back.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// void push_back(const value_type& v);
+// void pop_back();
+// void pop_front();
+
+#include <deque>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class C>
+C
+make(int size, int start = 0 )
+{
+ const int b = 4096 / sizeof(int);
+ int init = 0;
+ if (start > 0)
+ {
+ init = (start+1) / b + ((start+1) % b != 0);
+ init *= b;
+ --init;
+ }
+ C c(init, 0);
+ for (int i = 0; i < init-start; ++i)
+ c.pop_back();
+ for (int i = 0; i < size; ++i)
+ c.push_back(i);
+ for (int i = 0; i < start; ++i)
+ c.pop_front();
+ return c;
+}
+
+template <class C>
+void test(int size)
+{
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2046, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int j = 0; j < N; ++j)
+ {
+ C c = make<C>(size, rng[j]);
+ typename C::const_iterator it = c.begin();
+ for (int i = 0; i < size; ++i, ++it)
+ assert(*it == i);
+ }
+}
+
+int main()
+{
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2046, 2047, 2048, 2049, 4094, 4095, 4096};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int j = 0; j < N; ++j)
+ test<std::deque<int> >(rng[j]);
+ }
+#if __cplusplus >= 201103L
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2046, 2047, 2048, 2049, 4094, 4095, 4096};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int j = 0; j < N; ++j)
+ test<std::deque<int, min_allocator<int>> >(rng[j]);
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/deque/deque.modifiers/push_back_exception_safety.pass.cpp b/test/std/containers/sequences/deque/deque.modifiers/push_back_exception_safety.pass.cpp
new file mode 100644
index 000000000000..8ad6b53f1b5f
--- /dev/null
+++ b/test/std/containers/sequences/deque/deque.modifiers/push_back_exception_safety.pass.cpp
@@ -0,0 +1,101 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// void push_back(const value_type& x);
+
+#include <deque>
+#include "test_allocator.h"
+#include <cassert>
+
+// Flag that makes the copy constructor for CMyClass throw an exception
+static bool gCopyConstructorShouldThow = false;
+
+class CMyClass {
+ public: CMyClass(int tag);
+ public: CMyClass(const CMyClass& iOther);
+ public: ~CMyClass();
+
+ bool equal(const CMyClass &rhs) const
+ { return fTag == rhs.fTag && fMagicValue == rhs.fMagicValue; }
+
+ private:
+ int fMagicValue;
+ int fTag;
+
+ private: static int kStartedConstructionMagicValue;
+ private: static int kFinishedConstructionMagicValue;
+};
+
+// Value for fMagicValue when the constructor has started running, but not yet finished
+int CMyClass::kStartedConstructionMagicValue = 0;
+// Value for fMagicValue when the constructor has finished running
+int CMyClass::kFinishedConstructionMagicValue = 12345;
+
+CMyClass::CMyClass(int tag) :
+ fMagicValue(kStartedConstructionMagicValue), fTag(tag)
+{
+ // Signal that the constructor has finished running
+ fMagicValue = kFinishedConstructionMagicValue;
+}
+
+CMyClass::CMyClass(const CMyClass& iOther) :
+ fMagicValue(kStartedConstructionMagicValue), fTag(iOther.fTag)
+{
+ // If requested, throw an exception _before_ setting fMagicValue to kFinishedConstructionMagicValue
+ if (gCopyConstructorShouldThow) {
+ throw std::exception();
+ }
+ // Signal that the constructor has finished running
+ fMagicValue = kFinishedConstructionMagicValue;
+}
+
+CMyClass::~CMyClass() {
+ // Only instances for which the constructor has finished running should be destructed
+ assert(fMagicValue == kFinishedConstructionMagicValue);
+}
+
+bool operator==(const CMyClass &lhs, const CMyClass &rhs) { return lhs.equal(rhs); }
+
+int main()
+{
+ CMyClass instance(42);
+ {
+ std::deque<CMyClass> vec;
+
+ vec.push_back(instance);
+ std::deque<CMyClass> vec2(vec);
+
+ gCopyConstructorShouldThow = true;
+ try {
+ vec.push_back(instance);
+ assert(false);
+ }
+ catch (...) {
+ gCopyConstructorShouldThow = false;
+ assert(vec==vec2);
+ }
+ }
+
+ {
+ typedef std::deque<CMyClass, test_allocator<CMyClass> > C;
+ C vec;
+ C vec2(vec);
+
+ C::allocator_type::throw_after = 1;
+ try {
+ vec.push_back(instance);
+ assert(false);
+ }
+ catch (...) {
+ assert(vec==vec2);
+ }
+ }
+}
diff --git a/test/std/containers/sequences/deque/deque.modifiers/push_back_rvalue.pass.cpp b/test/std/containers/sequences/deque/deque.modifiers/push_back_rvalue.pass.cpp
new file mode 100644
index 000000000000..d4ab0d3e2f26
--- /dev/null
+++ b/test/std/containers/sequences/deque/deque.modifiers/push_back_rvalue.pass.cpp
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// void push_back(value_type&& v);
+// void pop_back();
+// void pop_front();
+
+#include <deque>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "min_allocator.h"
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class C>
+C
+make(int size, int start = 0 )
+{
+ const int b = 4096 / sizeof(int);
+ int init = 0;
+ if (start > 0)
+ {
+ init = (start+1) / b + ((start+1) % b != 0);
+ init *= b;
+ --init;
+ }
+ C c(init);
+ for (int i = 0; i < init-start; ++i)
+ c.pop_back();
+ for (int i = 0; i < size; ++i)
+ c.push_back(MoveOnly(i));
+ for (int i = 0; i < start; ++i)
+ c.pop_front();
+ return c;
+}
+
+template <class C>
+void test(int size)
+{
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2046, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int j = 0; j < N; ++j)
+ {
+ C c = make<C>(size, rng[j]);
+ typename C::const_iterator it = c.begin();
+ for (int i = 0; i < size; ++i, ++it)
+ assert(*it == MoveOnly(i));
+ }
+}
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2046, 2047, 2048, 2049, 4094, 4095, 4096};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int j = 0; j < N; ++j)
+ test<std::deque<MoveOnly> >(rng[j]);
+ }
+#if __cplusplus >= 201103L
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2046, 2047, 2048, 2049, 4094, 4095, 4096};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int j = 0; j < N; ++j)
+ test<std::deque<MoveOnly, min_allocator<MoveOnly>> >(rng[j]);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/sequences/deque/deque.modifiers/push_front.pass.cpp b/test/std/containers/sequences/deque/deque.modifiers/push_front.pass.cpp
new file mode 100644
index 000000000000..4d6443b1f967
--- /dev/null
+++ b/test/std/containers/sequences/deque/deque.modifiers/push_front.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// void push_front(const value_type& v);
+
+#include <deque>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class C>
+C
+make(int size, int start = 0 )
+{
+ const int b = 4096 / sizeof(int);
+ int init = 0;
+ if (start > 0)
+ {
+ init = (start+1) / b + ((start+1) % b != 0);
+ init *= b;
+ --init;
+ }
+ C c(init, 0);
+ for (int i = 0; i < init-start; ++i)
+ c.pop_back();
+ for (int i = 0; i < size; ++i)
+ c.push_back(i);
+ for (int i = 0; i < start; ++i)
+ c.pop_front();
+ return c;
+}
+
+template <class C>
+void
+test(C& c1, int x)
+{
+ typedef typename C::iterator I;
+ std::size_t c1_osize = c1.size();
+ c1.push_front(x);
+ assert(c1.size() == c1_osize + 1);
+ assert(distance(c1.begin(), c1.end()) == c1.size());
+ I i = c1.begin();
+ assert(*i == x);
+ ++i;
+ for (int j = 0; j < c1_osize; ++j, ++i)
+ assert(*i == j);
+}
+
+template <class C>
+void
+testN(int start, int N)
+{
+ C c1 = make<C>(N, start);
+ test(c1, -10);
+}
+
+int main()
+{
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ testN<std::deque<int> >(rng[i], rng[j]);
+ }
+#if __cplusplus >= 201103L
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j]);
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/deque/deque.modifiers/push_front_exception_safety.pass.cpp b/test/std/containers/sequences/deque/deque.modifiers/push_front_exception_safety.pass.cpp
new file mode 100644
index 000000000000..e01b2a224ffd
--- /dev/null
+++ b/test/std/containers/sequences/deque/deque.modifiers/push_front_exception_safety.pass.cpp
@@ -0,0 +1,101 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// void push_front(const value_type& x);
+
+#include <deque>
+#include <cassert>
+#include "test_allocator.h"
+
+// Flag that makes the copy constructor for CMyClass throw an exception
+static bool gCopyConstructorShouldThow = false;
+
+
+class CMyClass {
+ public: CMyClass(int tag);
+ public: CMyClass(const CMyClass& iOther);
+ public: ~CMyClass();
+
+ bool equal(const CMyClass &rhs) const
+ { return fTag == rhs.fTag && fMagicValue == rhs.fMagicValue; }
+ private:
+ int fMagicValue;
+ int fTag;
+
+ private: static int kStartedConstructionMagicValue;
+ private: static int kFinishedConstructionMagicValue;
+};
+
+// Value for fMagicValue when the constructor has started running, but not yet finished
+int CMyClass::kStartedConstructionMagicValue = 0;
+// Value for fMagicValue when the constructor has finished running
+int CMyClass::kFinishedConstructionMagicValue = 12345;
+
+CMyClass::CMyClass(int tag) :
+ fMagicValue(kStartedConstructionMagicValue), fTag(tag)
+{
+ // Signal that the constructor has finished running
+ fMagicValue = kFinishedConstructionMagicValue;
+}
+
+CMyClass::CMyClass(const CMyClass& iOther) :
+ fMagicValue(kStartedConstructionMagicValue), fTag(iOther.fTag)
+{
+ // If requested, throw an exception _before_ setting fMagicValue to kFinishedConstructionMagicValue
+ if (gCopyConstructorShouldThow) {
+ throw std::exception();
+ }
+ // Signal that the constructor has finished running
+ fMagicValue = kFinishedConstructionMagicValue;
+}
+
+CMyClass::~CMyClass() {
+ // Only instances for which the constructor has finished running should be destructed
+ assert(fMagicValue == kFinishedConstructionMagicValue);
+}
+
+bool operator==(const CMyClass &lhs, const CMyClass &rhs) { return lhs.equal(rhs); }
+
+int main()
+{
+ CMyClass instance(42);
+ {
+ std::deque<CMyClass> vec;
+
+ vec.push_front(instance);
+ std::deque<CMyClass> vec2(vec);
+
+ gCopyConstructorShouldThow = true;
+ try {
+ vec.push_front(instance);
+ assert(false);
+ }
+ catch (...) {
+ gCopyConstructorShouldThow = false;
+ assert(vec==vec2);
+ }
+ }
+
+ {
+ typedef std::deque<CMyClass, test_allocator<CMyClass> > C;
+ C vec;
+ C vec2(vec);
+
+ C::allocator_type::throw_after = 1;
+ try {
+ vec.push_front(instance);
+ assert(false);
+ }
+ catch (...) {
+ assert(vec==vec2);
+ }
+ }
+}
diff --git a/test/std/containers/sequences/deque/deque.modifiers/push_front_rvalue.pass.cpp b/test/std/containers/sequences/deque/deque.modifiers/push_front_rvalue.pass.cpp
new file mode 100644
index 000000000000..ea91ec1b0a44
--- /dev/null
+++ b/test/std/containers/sequences/deque/deque.modifiers/push_front_rvalue.pass.cpp
@@ -0,0 +1,90 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// void push_front(value_type&& v);
+
+#include <deque>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "min_allocator.h"
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class C>
+C
+make(int size, int start = 0 )
+{
+ const int b = 4096 / sizeof(int);
+ int init = 0;
+ if (start > 0)
+ {
+ init = (start+1) / b + ((start+1) % b != 0);
+ init *= b;
+ --init;
+ }
+ C c(init);
+ for (int i = 0; i < init-start; ++i)
+ c.pop_back();
+ for (int i = 0; i < size; ++i)
+ c.push_back(MoveOnly(i));
+ for (int i = 0; i < start; ++i)
+ c.pop_front();
+ return c;
+}
+
+template <class C>
+void
+test(C& c1, int x)
+{
+ typedef typename C::iterator I;
+ std::size_t c1_osize = c1.size();
+ c1.push_front(MoveOnly(x));
+ assert(c1.size() == c1_osize + 1);
+ assert(distance(c1.begin(), c1.end()) == c1.size());
+ I i = c1.begin();
+ assert(*i == MoveOnly(x));
+ ++i;
+ for (int j = 0; j < c1_osize; ++j, ++i)
+ assert(*i == MoveOnly(j));
+}
+
+template <class C>
+void
+testN(int start, int N)
+{
+ C c1 = make<C>(N, start);
+ test(c1, -10);
+}
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ testN<std::deque<MoveOnly> >(rng[i], rng[j]);
+ }
+#if __cplusplus >= 201103L
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ testN<std::deque<MoveOnly, min_allocator<MoveOnly>> >(rng[i], rng[j]);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/sequences/deque/deque.special/copy.pass.cpp b/test/std/containers/sequences/deque/deque.special/copy.pass.cpp
new file mode 100644
index 000000000000..3a9962b330a4
--- /dev/null
+++ b/test/std/containers/sequences/deque/deque.special/copy.pass.cpp
@@ -0,0 +1,88 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// Optimization for deque::iterators
+
+// template <class InputIterator, class OutputIterator>
+// OutputIterator
+// copy(InputIterator first, InputIterator last, OutputIterator result);
+
+#include <deque>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+template <class C>
+C
+make(int size, int start = 0 )
+{
+ const int b = 4096 / sizeof(int);
+ int init = 0;
+ if (start > 0)
+ {
+ init = (start+1) / b + ((start+1) % b != 0);
+ init *= b;
+ --init;
+ }
+ C c(init, 0);
+ for (int i = 0; i < init-start; ++i)
+ c.pop_back();
+ for (int i = 0; i < size; ++i)
+ c.push_back(i);
+ for (int i = 0; i < start; ++i)
+ c.pop_front();
+ return c;
+}
+
+template <class C>
+void testN(int start, int N)
+{
+ typedef typename C::iterator I;
+ typedef typename C::const_iterator CI;
+ typedef random_access_iterator<I> RAI;
+ typedef random_access_iterator<CI> RACI;
+ typedef input_iterator<CI> ICI;
+ C c1 = make<C>(N, start);
+ C c2 = make<C>(N);
+ assert(std::copy(c1.cbegin(), c1.cend(), c2.begin()) == c2.end());
+ assert(c1 == c2);
+ assert(std::copy(c2.cbegin(), c2.cend(), c1.begin()) == c1.end());
+ assert(c1 == c2);
+ assert(std::copy(c1.cbegin(), c1.cend(), RAI(c2.begin())) == RAI(c2.end()));
+ assert(c1 == c2);
+ assert(std::copy(c2.cbegin(), c2.cend(), RAI(c1.begin())) == RAI(c1.end()));
+ assert(c1 == c2);
+ assert(std::copy(RACI(c1.cbegin()), RACI(c1.cend()), c2.begin()) == c2.end());
+ assert(c1 == c2);
+ assert(std::copy(ICI(c2.cbegin()), ICI(c2.cend()), c1.begin()) == c1.end());
+ assert(c1 == c2);
+}
+
+int main()
+{
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ testN<std::deque<int> >(rng[i], rng[j]);
+ }
+#if __cplusplus >= 201103L
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j]);
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/deque/deque.special/copy_backward.pass.cpp b/test/std/containers/sequences/deque/deque.special/copy_backward.pass.cpp
new file mode 100644
index 000000000000..ccb30a9997d8
--- /dev/null
+++ b/test/std/containers/sequences/deque/deque.special/copy_backward.pass.cpp
@@ -0,0 +1,87 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// Optimization for deque::iterators
+
+// template <class InputIterator, class OutputIterator>
+// OutputIterator
+// copy_backward(InputIterator first, InputIterator last, OutputIterator result);
+
+#include <deque>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+template <class C>
+C
+make(int size, int start = 0 )
+{
+ const int b = 4096 / sizeof(int);
+ int init = 0;
+ if (start > 0)
+ {
+ init = (start+1) / b + ((start+1) % b != 0);
+ init *= b;
+ --init;
+ }
+ C c(init, 0);
+ for (int i = 0; i < init-start; ++i)
+ c.pop_back();
+ for (int i = 0; i < size; ++i)
+ c.push_back(i);
+ for (int i = 0; i < start; ++i)
+ c.pop_front();
+ return c;
+}
+
+template <class C>
+void testN(int start, int N)
+{
+ typedef typename C::iterator I;
+ typedef typename C::const_iterator CI;
+ typedef random_access_iterator<I> RAI;
+ typedef random_access_iterator<CI> RACI;
+ C c1 = make<C>(N, start);
+ C c2 = make<C>(N);
+ assert(std::copy_backward(c1.cbegin(), c1.cend(), c2.end()) == c2.begin());
+ assert(c1 == c2);
+ assert(std::copy_backward(c2.cbegin(), c2.cend(), c1.end()) == c1.begin());
+ assert(c1 == c2);
+ assert(std::copy_backward(c1.cbegin(), c1.cend(), RAI(c2.end())) == RAI(c2.begin()));
+ assert(c1 == c2);
+ assert(std::copy_backward(c2.cbegin(), c2.cend(), RAI(c1.end())) == RAI(c1.begin()));
+ assert(c1 == c2);
+ assert(std::copy_backward(RACI(c1.cbegin()), RACI(c1.cend()), c2.end()) == c2.begin());
+ assert(c1 == c2);
+ assert(std::copy_backward(RACI(c2.cbegin()), RACI(c2.cend()), c1.end()) == c1.begin());
+ assert(c1 == c2);
+}
+
+int main()
+{
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ testN<std::deque<int> >(rng[i], rng[j]);
+ }
+#if __cplusplus >= 201103L
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j]);
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/deque/deque.special/move.pass.cpp b/test/std/containers/sequences/deque/deque.special/move.pass.cpp
new file mode 100644
index 000000000000..abd8e079975a
--- /dev/null
+++ b/test/std/containers/sequences/deque/deque.special/move.pass.cpp
@@ -0,0 +1,87 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// Optimization for deque::iterators
+
+// template <class InputIterator, class OutputIterator>
+// OutputIterator
+// move(InputIterator first, InputIterator last, OutputIterator result);
+
+#include <deque>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+template <class C>
+C
+make(int size, int start = 0 )
+{
+ const int b = 4096 / sizeof(int);
+ int init = 0;
+ if (start > 0)
+ {
+ init = (start+1) / b + ((start+1) % b != 0);
+ init *= b;
+ --init;
+ }
+ C c(init, 0);
+ for (int i = 0; i < init-start; ++i)
+ c.pop_back();
+ for (int i = 0; i < size; ++i)
+ c.push_back(i);
+ for (int i = 0; i < start; ++i)
+ c.pop_front();
+ return c;
+}
+
+template <class C>
+void testN(int start, int N)
+{
+ typedef typename C::iterator I;
+ typedef typename C::const_iterator CI;
+ typedef random_access_iterator<I> RAI;
+ typedef random_access_iterator<CI> RACI;
+ C c1 = make<C>(N, start);
+ C c2 = make<C>(N);
+ assert(std::move(c1.cbegin(), c1.cend(), c2.begin()) == c2.end());
+ assert(c1 == c2);
+ assert(std::move(c2.cbegin(), c2.cend(), c1.begin()) == c1.end());
+ assert(c1 == c2);
+ assert(std::move(c1.cbegin(), c1.cend(), RAI(c2.begin())) == RAI(c2.end()));
+ assert(c1 == c2);
+ assert(std::move(c2.cbegin(), c2.cend(), RAI(c1.begin())) == RAI(c1.end()));
+ assert(c1 == c2);
+ assert(std::move(RACI(c1.cbegin()), RACI(c1.cend()), c2.begin()) == c2.end());
+ assert(c1 == c2);
+ assert(std::move(RACI(c2.cbegin()), RACI(c2.cend()), c1.begin()) == c1.end());
+ assert(c1 == c2);
+}
+
+int main()
+{
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ testN<std::deque<int> >(rng[i], rng[j]);
+ }
+#if __cplusplus >= 201103L
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j]);
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/deque/deque.special/move_backward.pass.cpp b/test/std/containers/sequences/deque/deque.special/move_backward.pass.cpp
new file mode 100644
index 000000000000..ea04f6a15acf
--- /dev/null
+++ b/test/std/containers/sequences/deque/deque.special/move_backward.pass.cpp
@@ -0,0 +1,87 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// Optimization for deque::iterators
+
+// template <class InputIterator, class OutputIterator>
+// OutputIterator
+// move_backward(InputIterator first, InputIterator last, OutputIterator result);
+
+#include <deque>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+template <class C>
+C
+make(int size, int start = 0 )
+{
+ const int b = 4096 / sizeof(int);
+ int init = 0;
+ if (start > 0)
+ {
+ init = (start+1) / b + ((start+1) % b != 0);
+ init *= b;
+ --init;
+ }
+ C c(init, 0);
+ for (int i = 0; i < init-start; ++i)
+ c.pop_back();
+ for (int i = 0; i < size; ++i)
+ c.push_back(i);
+ for (int i = 0; i < start; ++i)
+ c.pop_front();
+ return c;
+}
+
+template <class C>
+void testN(int start, int N)
+{
+ typedef typename C::iterator I;
+ typedef typename C::const_iterator CI;
+ typedef random_access_iterator<I> RAI;
+ typedef random_access_iterator<CI> RACI;
+ C c1 = make<C>(N, start);
+ C c2 = make<C>(N);
+ assert(std::move_backward(c1.cbegin(), c1.cend(), c2.end()) == c2.begin());
+ assert(c1 == c2);
+ assert(std::move_backward(c2.cbegin(), c2.cend(), c1.end()) == c1.begin());
+ assert(c1 == c2);
+ assert(std::move_backward(c1.cbegin(), c1.cend(), RAI(c2.end())) == RAI(c2.begin()));
+ assert(c1 == c2);
+ assert(std::move_backward(c2.cbegin(), c2.cend(), RAI(c1.end())) == RAI(c1.begin()));
+ assert(c1 == c2);
+ assert(std::move_backward(RACI(c1.cbegin()), RACI(c1.cend()), c2.end()) == c2.begin());
+ assert(c1 == c2);
+ assert(std::move_backward(RACI(c2.cbegin()), RACI(c2.cend()), c1.end()) == c1.begin());
+ assert(c1 == c2);
+}
+
+int main()
+{
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ testN<std::deque<int> >(rng[i], rng[j]);
+ }
+#if __cplusplus >= 201103L
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ testN<std::deque<int, min_allocator<int> > >(rng[i], rng[j]);
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/deque/deque.special/swap.pass.cpp b/test/std/containers/sequences/deque/deque.special/swap.pass.cpp
new file mode 100644
index 000000000000..26757c351f1a
--- /dev/null
+++ b/test/std/containers/sequences/deque/deque.special/swap.pass.cpp
@@ -0,0 +1,110 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// template <class T, class A>
+// void swap(deque<T, A>& x, deque<T, A>& y);
+
+#include <deque>
+#include <cassert>
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+template <class C>
+C
+make(int size, int start = 0 )
+{
+ const int b = 4096 / sizeof(int);
+ int init = 0;
+ if (start > 0)
+ {
+ init = (start+1) / b + ((start+1) % b != 0);
+ init *= b;
+ --init;
+ }
+ C c(init, 0);
+ for (int i = 0; i < init-start; ++i)
+ c.pop_back();
+ for (int i = 0; i < size; ++i)
+ c.push_back(i);
+ for (int i = 0; i < start; ++i)
+ c.pop_front();
+ return c;
+}
+
+template <class C>
+void testN(int start, int N, int M)
+{
+ C c1 = make<C>(N, start);
+ C c2 = make<C>(M);
+ C c1_save = c1;
+ C c2_save = c2;
+ swap(c1, c2);
+ assert(c1 == c2_save);
+ assert(c2 == c1_save);
+}
+
+int main()
+{
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ for (int k = 0; k < N; ++k)
+ testN<std::deque<int> >(rng[i], rng[j], rng[k]);
+ }
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ typedef test_allocator<int> A;
+ std::deque<int, A> c1(a1, a1+sizeof(a1)/sizeof(a1[0]), A(1));
+ std::deque<int, A> c2(a2, a2+sizeof(a2)/sizeof(a2[0]), A(2));
+ swap(c1, c2);
+ assert((c1 == std::deque<int, A>(a2, a2+sizeof(a2)/sizeof(a2[0]))));
+ assert(c1.get_allocator() == A(1));
+ assert((c2 == std::deque<int, A>(a1, a1+sizeof(a1)/sizeof(a1[0]))));
+ assert(c2.get_allocator() == A(2));
+ }
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ typedef other_allocator<int> A;
+ std::deque<int, A> c1(a1, a1+sizeof(a1)/sizeof(a1[0]), A(1));
+ std::deque<int, A> c2(a2, a2+sizeof(a2)/sizeof(a2[0]), A(2));
+ swap(c1, c2);
+ assert((c1 == std::deque<int, A>(a2, a2+sizeof(a2)/sizeof(a2[0]))));
+ assert(c1.get_allocator() == A(2));
+ assert((c2 == std::deque<int, A>(a1, a1+sizeof(a1)/sizeof(a1[0]))));
+ assert(c2.get_allocator() == A(1));
+ }
+#if __cplusplus >= 201103L
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ for (int k = 0; k < N; ++k)
+ testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j], rng[k]);
+ }
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ typedef min_allocator<int> A;
+ std::deque<int, A> c1(a1, a1+sizeof(a1)/sizeof(a1[0]), A());
+ std::deque<int, A> c2(a2, a2+sizeof(a2)/sizeof(a2[0]), A());
+ swap(c1, c2);
+ assert((c1 == std::deque<int, A>(a2, a2+sizeof(a2)/sizeof(a2[0]))));
+ assert(c1.get_allocator() == A());
+ assert((c2 == std::deque<int, A>(a1, a1+sizeof(a1)/sizeof(a1[0]))));
+ assert(c2.get_allocator() == A());
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/deque/deque.special/swap_noexcept.pass.cpp b/test/std/containers/sequences/deque/deque.special/swap_noexcept.pass.cpp
new file mode 100644
index 000000000000..83bcac8997ed
--- /dev/null
+++ b/test/std/containers/sequences/deque/deque.special/swap_noexcept.pass.cpp
@@ -0,0 +1,90 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// void swap(deque& c)
+// noexcept(!allocator_type::propagate_on_container_swap::value ||
+// __is_nothrow_swappable<allocator_type>::value);
+//
+// In C++17, the standard says that swap shall have:
+// noexcept(allocator_traits<Allocator>::is_always_equal::value);
+
+// This tests a conforming extension
+
+#include <deque>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_alloc
+{
+ typedef T value_type;
+
+ some_alloc() {}
+ some_alloc(const some_alloc&);
+ void deallocate(void*, unsigned) {}
+
+ typedef std::true_type propagate_on_container_swap;
+};
+
+template <class T>
+struct some_alloc2
+{
+ typedef T value_type;
+
+ some_alloc2() {}
+ some_alloc2(const some_alloc2&);
+ void deallocate(void*, unsigned) {}
+
+ typedef std::false_type propagate_on_container_swap;
+ typedef std::true_type is_always_equal;
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::deque<MoveOnly> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::deque<MoveOnly, test_allocator<MoveOnly>> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::deque<MoveOnly, other_allocator<MoveOnly>> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::deque<MoveOnly, some_alloc<MoveOnly>> C;
+ C c1, c2;
+#if TEST_STD_VER >= 14
+ // In c++14, if POCS is set, swapping the allocator is required not to throw
+ static_assert( noexcept(swap(c1, c2)), "");
+#else
+ static_assert(!noexcept(swap(c1, c2)), "");
+#endif
+ }
+#if TEST_STD_VER >= 14
+ {
+ typedef std::deque<MoveOnly, some_alloc2<MoveOnly>> C;
+ C c1, c2;
+ // if the allocators are always equal, then the swap can be noexcept
+ static_assert( noexcept(swap(c1, c2)), "");
+ }
+#endif
+
+#endif
+}
diff --git a/test/std/containers/sequences/deque/iterators.pass.cpp b/test/std/containers/sequences/deque/iterators.pass.cpp
new file mode 100644
index 000000000000..8ec491fae4da
--- /dev/null
+++ b/test/std/containers/sequences/deque/iterators.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// Test nested types and default template args:
+
+// template <class T, class Allocator = allocator<T> >
+// class deque;
+
+// iterator, const_iterator
+
+#include <deque>
+#include <iterator>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::deque<int> C;
+ C c;
+ C::iterator i;
+ i = c.begin();
+ C::const_iterator j;
+ j = c.cbegin();
+ assert(i == j);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::deque<int, min_allocator<int>> C;
+ C c;
+ C::iterator i;
+ i = c.begin();
+ C::const_iterator j;
+ j = c.cbegin();
+ assert(i == j);
+ }
+#endif
+#if _LIBCPP_STD_VER > 11
+ { // N3644 testing
+ std::deque<int>::iterator ii1{}, ii2{};
+ std::deque<int>::iterator ii4 = ii1;
+ std::deque<int>::const_iterator cii{};
+ assert ( ii1 == ii2 );
+ assert ( ii1 == ii4 );
+
+ assert (!(ii1 != ii2 ));
+
+ assert ( (ii1 == cii ));
+ assert ( (cii == ii1 ));
+ assert (!(ii1 != cii ));
+ assert (!(cii != ii1 ));
+ assert (!(ii1 < cii ));
+ assert (!(cii < ii1 ));
+ assert ( (ii1 <= cii ));
+ assert ( (cii <= ii1 ));
+ assert (!(ii1 > cii ));
+ assert (!(cii > ii1 ));
+ assert ( (ii1 >= cii ));
+ assert ( (cii >= ii1 ));
+ assert (cii - ii1 == 0);
+ assert (ii1 - cii == 0);
+
+// std::deque<int> c;
+// assert ( ii1 != c.cbegin());
+// assert ( cii != c.begin());
+// assert ( cii != c.cend());
+// assert ( ii1 != c.end());
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/deque/types.pass.cpp b/test/std/containers/sequences/deque/types.pass.cpp
new file mode 100644
index 000000000000..da9470d8a6c6
--- /dev/null
+++ b/test/std/containers/sequences/deque/types.pass.cpp
@@ -0,0 +1,90 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// Test nested types and default template args:
+
+// template <class T, class Allocator = allocator<T> >
+// class deque
+// {
+// public:
+// typedef T value_type;
+// typedef Allocator allocator_type;
+// typedef typename allocator_type::reference reference;
+// typedef typename allocator_type::const_reference const_reference;
+// typedef implementation-defined iterator;
+// typedef implementation-defined const_iterator;
+// typedef typename allocator_type::size_type size_type;
+// typedef typename allocator_type::difference_type difference_type;
+// typedef typename allocator_type::pointer pointer;
+// typedef typename allocator_type::const_pointer const_pointer;
+// typedef std::reverse_iterator<iterator> reverse_iterator;
+// typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
+// };
+
+#include <deque>
+#include <iterator>
+#include <type_traits>
+
+#include "test_allocator.h"
+#include "../../Copyable.h"
+#include "min_allocator.h"
+
+template <class T, class Allocator>
+void
+test()
+{
+ typedef std::deque<T, Allocator> C;
+
+ static_assert((std::is_same<typename C::value_type, T>::value), "");
+ static_assert((std::is_same<typename C::value_type, typename Allocator::value_type>::value), "");
+ static_assert((std::is_same<typename C::allocator_type, Allocator>::value), "");
+ static_assert((std::is_same<typename C::size_type, typename Allocator::size_type>::value), "");
+ static_assert((std::is_same<typename C::difference_type, typename Allocator::difference_type>::value), "");
+ static_assert((std::is_same<typename C::reference, typename Allocator::reference>::value), "");
+ static_assert((std::is_same<typename C::const_reference, typename Allocator::const_reference>::value), "");
+ static_assert((std::is_same<typename C::pointer, typename Allocator::pointer>::value), "");
+ static_assert((std::is_same<typename C::const_pointer, typename Allocator::const_pointer>::value), "");
+ static_assert((std::is_same<
+ typename std::iterator_traits<typename C::iterator>::iterator_category,
+ std::random_access_iterator_tag>::value), "");
+ static_assert((std::is_same<
+ typename std::iterator_traits<typename C::const_iterator>::iterator_category,
+ std::random_access_iterator_tag>::value), "");
+ static_assert((std::is_same<
+ typename C::reverse_iterator,
+ std::reverse_iterator<typename C::iterator> >::value), "");
+ static_assert((std::is_same<
+ typename C::const_reverse_iterator,
+ std::reverse_iterator<typename C::const_iterator> >::value), "");
+}
+
+int main()
+{
+ test<int, test_allocator<int> >();
+ test<int*, std::allocator<int*> >();
+ test<Copyable, test_allocator<Copyable> >();
+ static_assert((std::is_same<std::deque<char>::allocator_type,
+ std::allocator<char> >::value), "");
+#if __cplusplus >= 201103L
+ {
+ typedef std::deque<short, min_allocator<short>> C;
+ static_assert((std::is_same<C::value_type, short>::value), "");
+ static_assert((std::is_same<C::allocator_type, min_allocator<C::value_type> >::value), "");
+ static_assert((std::is_same<C::reference, C::value_type&>::value), "");
+ static_assert((std::is_same<C::const_reference, const C::value_type&>::value), "");
+ static_assert((std::is_same<C::pointer, min_pointer<C::value_type>>::value), "");
+ static_assert((std::is_same<C::const_pointer, min_pointer<const C::value_type>>::value), "");
+// min_allocator doesn't have a size_type, so one gets synthesized
+ static_assert((std::is_same<C::size_type, std::make_unsigned<C::difference_type>::type>::value), "");
+ static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/deque/version.pass.cpp b/test/std/containers/sequences/deque/version.pass.cpp
new file mode 100644
index 000000000000..22e663d9bc22
--- /dev/null
+++ b/test/std/containers/sequences/deque/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+#include <deque>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/containers/sequences/forwardlist/forwardlist.access/front.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.access/front.pass.cpp
new file mode 100644
index 000000000000..2ec9b8713326
--- /dev/null
+++ b/test/std/containers/sequences/forwardlist/forwardlist.access/front.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// reference front();
+// const_reference front() const;
+
+#include <forward_list>
+#include <cassert>
+#include <iterator>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ C c(std::begin(t), std::end(t));
+ assert(c.front() == 0);
+ c.front() = 10;
+ assert(c.front() == 10);
+ assert(*c.begin() == 10);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ const C c(std::begin(t), std::end(t));
+ assert(c.front() == 0);
+ assert(*c.begin() == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ C c(std::begin(t), std::end(t));
+ assert(c.front() == 0);
+ c.front() = 10;
+ assert(c.front() == 10);
+ assert(*c.begin() == 10);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ const C c(std::begin(t), std::end(t));
+ assert(c.front() == 0);
+ assert(*c.begin() == 0);
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/alloc.fail.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/alloc.fail.cpp
new file mode 100644
index 000000000000..cd4d1ede1201
--- /dev/null
+++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/alloc.fail.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// explicit forward_list(const allocator_type& a);
+
+#include <forward_list>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "../../../NotConstructible.h"
+
+int main()
+{
+ {
+ typedef test_allocator<NotConstructible> A;
+ typedef A::value_type T;
+ typedef std::forward_list<T, A> C;
+ C c = A(12);
+ assert(c.get_allocator() == A(12));
+ assert(c.empty());
+ }
+}
diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/alloc.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/alloc.pass.cpp
new file mode 100644
index 000000000000..7aba906ec20d
--- /dev/null
+++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/alloc.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// explicit forward_list(const allocator_type& a);
+
+#include <forward_list>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "../../../NotConstructible.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef test_allocator<NotConstructible> A;
+ typedef A::value_type T;
+ typedef std::forward_list<T, A> C;
+ C c(A(12));
+ assert(c.get_allocator() == A(12));
+ assert(c.empty());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef min_allocator<NotConstructible> A;
+ typedef A::value_type T;
+ typedef std::forward_list<T, A> C;
+ C c(A{});
+ assert(c.get_allocator() == A());
+ assert(c.empty());
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_copy.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_copy.pass.cpp
new file mode 100644
index 000000000000..0b9263db9899
--- /dev/null
+++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_copy.pass.cpp
@@ -0,0 +1,146 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// forward_list& operator=(const forward_list& x);
+
+#include <forward_list>
+#include <cassert>
+#include <iterator>
+
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef test_allocator<int> A;
+ typedef std::forward_list<T, A> C;
+ const T t0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ const T t1[] = {10, 11, 12, 13};
+ C c0(std::begin(t0), std::end(t0), A(10));
+ C c1(std::begin(t1), std::end(t1), A(10));
+ c1 = c0;
+ assert(c1 == c0);
+ assert(c1.get_allocator() == A(10));
+ }
+ {
+ typedef int T;
+ typedef test_allocator<int> A;
+ typedef std::forward_list<T, A> C;
+ const T t0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ const T t1[] = {10, 11, 12, 13};
+ C c0(std::begin(t0), std::end(t0), A(10));
+ C c1(std::begin(t1), std::end(t1), A(11));
+ c1 = c0;
+ assert(c1 == c0);
+ assert(c1.get_allocator() == A(11));
+ }
+ {
+ typedef int T;
+ typedef test_allocator<int> A;
+ typedef std::forward_list<T, A> C;
+ const T t0[] = {10, 11, 12, 13};
+ const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ C c0(std::begin(t0), std::end(t0), A(10));
+ C c1(std::begin(t1), std::end(t1), A(10));
+ c1 = c0;
+ assert(c1 == c0);
+ assert(c1.get_allocator() == A(10));
+ }
+ {
+ typedef int T;
+ typedef test_allocator<int> A;
+ typedef std::forward_list<T, A> C;
+ const T t0[] = {10, 11, 12, 13};
+ const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ C c0(std::begin(t0), std::end(t0), A(10));
+ C c1(std::begin(t1), std::end(t1), A(11));
+ c1 = c0;
+ assert(c1 == c0);
+ assert(c1.get_allocator() == A(11));
+ }
+
+ {
+ typedef int T;
+ typedef other_allocator<int> A;
+ typedef std::forward_list<T, A> C;
+ const T t0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ const T t1[] = {10, 11, 12, 13};
+ C c0(std::begin(t0), std::end(t0), A(10));
+ C c1(std::begin(t1), std::end(t1), A(10));
+ c1 = c0;
+ assert(c1 == c0);
+ assert(c1.get_allocator() == A(10));
+ }
+ {
+ typedef int T;
+ typedef other_allocator<int> A;
+ typedef std::forward_list<T, A> C;
+ const T t0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ const T t1[] = {10, 11, 12, 13};
+ C c0(std::begin(t0), std::end(t0), A(10));
+ C c1(std::begin(t1), std::end(t1), A(11));
+ c1 = c0;
+ assert(c1 == c0);
+ assert(c1.get_allocator() == A(10));
+ }
+ {
+ typedef int T;
+ typedef other_allocator<int> A;
+ typedef std::forward_list<T, A> C;
+ const T t0[] = {10, 11, 12, 13};
+ const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ C c0(std::begin(t0), std::end(t0), A(10));
+ C c1(std::begin(t1), std::end(t1), A(10));
+ c1 = c0;
+ assert(c1 == c0);
+ assert(c1.get_allocator() == A(10));
+ }
+ {
+ typedef int T;
+ typedef other_allocator<int> A;
+ typedef std::forward_list<T, A> C;
+ const T t0[] = {10, 11, 12, 13};
+ const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ C c0(std::begin(t0), std::end(t0), A(10));
+ C c1(std::begin(t1), std::end(t1), A(11));
+ c1 = c0;
+ assert(c1 == c0);
+ assert(c1.get_allocator() == A(10));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef min_allocator<int> A;
+ typedef std::forward_list<T, A> C;
+ const T t0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ const T t1[] = {10, 11, 12, 13};
+ C c0(std::begin(t0), std::end(t0), A());
+ C c1(std::begin(t1), std::end(t1), A());
+ c1 = c0;
+ assert(c1 == c0);
+ assert(c1.get_allocator() == A());
+ }
+ {
+ typedef int T;
+ typedef min_allocator<int> A;
+ typedef std::forward_list<T, A> C;
+ const T t0[] = {10, 11, 12, 13};
+ const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ C c0(std::begin(t0), std::end(t0), A());
+ C c1(std::begin(t1), std::end(t1), A());
+ c1 = c0;
+ assert(c1 == c0);
+ assert(c1.get_allocator() == A());
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_init.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_init.pass.cpp
new file mode 100644
index 000000000000..e0382a10db49
--- /dev/null
+++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_init.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// void assign(initializer_list<value_type> il);
+
+#include <forward_list>
+#include <cassert>
+#include <iterator>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ const T t1[] = {10, 11, 12, 13};
+ C c(std::begin(t1), std::end(t1));
+ c.assign({0, 1, 2, 3, 4, 5, 6, 7, 8, 9});
+ int n = 0;
+ for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
+ assert(*i == n);
+ assert(n == 10);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ C c(std::begin(t1), std::end(t1));
+ c.assign({10, 11, 12, 13});
+ int n = 0;
+ for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
+ assert(*i == 10+n);
+ assert(n == 4);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ const T t1[] = {10, 11, 12, 13};
+ C c(std::begin(t1), std::end(t1));
+ c.assign({0, 1, 2, 3, 4, 5, 6, 7, 8, 9});
+ int n = 0;
+ for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
+ assert(*i == n);
+ assert(n == 10);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ C c(std::begin(t1), std::end(t1));
+ c.assign({10, 11, 12, 13});
+ int n = 0;
+ for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
+ assert(*i == 10+n);
+ assert(n == 4);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_move.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_move.pass.cpp
new file mode 100644
index 000000000000..1532b53e7a83
--- /dev/null
+++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_move.pass.cpp
@@ -0,0 +1,199 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// forward_list& operator=(forward_list&& x);
+
+#include <forward_list>
+#include <cassert>
+#include <iterator>
+
+#include "test_allocator.h"
+#include "MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef MoveOnly T;
+ typedef test_allocator<T> A;
+ typedef std::forward_list<T, A> C;
+ T t0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ T t1[] = {10, 11, 12, 13};
+ typedef std::move_iterator<T*> I;
+ C c0(I(std::begin(t0)), I(std::end(t0)), A(10));
+ C c1(I(std::begin(t1)), I(std::end(t1)), A(10));
+ c1 = std::move(c0);
+ int n = 0;
+ for (C::const_iterator i = c1.cbegin(); i != c1.cend(); ++i, ++n)
+ assert(*i == n);
+ assert(n == 10);
+ assert(c1.get_allocator() == A(10));
+ assert(c0.empty());
+ }
+ {
+ typedef MoveOnly T;
+ typedef test_allocator<T> A;
+ typedef std::forward_list<T, A> C;
+ T t0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ T t1[] = {10, 11, 12, 13};
+ typedef std::move_iterator<T*> I;
+ C c0(I(std::begin(t0)), I(std::end(t0)), A(10));
+ C c1(I(std::begin(t1)), I(std::end(t1)), A(11));
+ c1 = std::move(c0);
+ int n = 0;
+ for (C::const_iterator i = c1.cbegin(); i != c1.cend(); ++i, ++n)
+ assert(*i == n);
+ assert(n == 10);
+ assert(c1.get_allocator() == A(11));
+ assert(!c0.empty());
+ }
+ {
+ typedef MoveOnly T;
+ typedef test_allocator<T> A;
+ typedef std::forward_list<T, A> C;
+ T t0[] = {10, 11, 12, 13};
+ T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ typedef std::move_iterator<T*> I;
+ C c0(I(std::begin(t0)), I(std::end(t0)), A(10));
+ C c1(I(std::begin(t1)), I(std::end(t1)), A(10));
+ c1 = std::move(c0);
+ int n = 0;
+ for (C::const_iterator i = c1.cbegin(); i != c1.cend(); ++i, ++n)
+ assert(*i == 10+n);
+ assert(n == 4);
+ assert(c1.get_allocator() == A(10));
+ assert(c0.empty());
+ }
+ {
+ typedef MoveOnly T;
+ typedef test_allocator<T> A;
+ typedef std::forward_list<T, A> C;
+ T t0[] = {10, 11, 12, 13};
+ T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ typedef std::move_iterator<T*> I;
+ C c0(I(std::begin(t0)), I(std::end(t0)), A(10));
+ C c1(I(std::begin(t1)), I(std::end(t1)), A(11));
+ c1 = std::move(c0);
+ int n = 0;
+ for (C::const_iterator i = c1.cbegin(); i != c1.cend(); ++i, ++n)
+ assert(*i == 10+n);
+ assert(n == 4);
+ assert(c1.get_allocator() == A(11));
+ assert(!c0.empty());
+ }
+
+ {
+ typedef MoveOnly T;
+ typedef other_allocator<T> A;
+ typedef std::forward_list<T, A> C;
+ T t0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ T t1[] = {10, 11, 12, 13};
+ typedef std::move_iterator<T*> I;
+ C c0(I(std::begin(t0)), I(std::end(t0)), A(10));
+ C c1(I(std::begin(t1)), I(std::end(t1)), A(10));
+ c1 = std::move(c0);
+ int n = 0;
+ for (C::const_iterator i = c1.cbegin(); i != c1.cend(); ++i, ++n)
+ assert(*i == n);
+ assert(n == 10);
+ assert(c1.get_allocator() == A(10));
+ assert(c0.empty());
+ }
+ {
+ typedef MoveOnly T;
+ typedef other_allocator<T> A;
+ typedef std::forward_list<T, A> C;
+ T t0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ T t1[] = {10, 11, 12, 13};
+ typedef std::move_iterator<T*> I;
+ C c0(I(std::begin(t0)), I(std::end(t0)), A(10));
+ C c1(I(std::begin(t1)), I(std::end(t1)), A(11));
+ c1 = std::move(c0);
+ int n = 0;
+ for (C::const_iterator i = c1.cbegin(); i != c1.cend(); ++i, ++n)
+ assert(*i == n);
+ assert(n == 10);
+ assert(c1.get_allocator() == A(10));
+ assert(c0.empty());
+ }
+ {
+ typedef MoveOnly T;
+ typedef other_allocator<T> A;
+ typedef std::forward_list<T, A> C;
+ T t0[] = {10, 11, 12, 13};
+ T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ typedef std::move_iterator<T*> I;
+ C c0(I(std::begin(t0)), I(std::end(t0)), A(10));
+ C c1(I(std::begin(t1)), I(std::end(t1)), A(10));
+ c1 = std::move(c0);
+ int n = 0;
+ for (C::const_iterator i = c1.cbegin(); i != c1.cend(); ++i, ++n)
+ assert(*i == 10+n);
+ assert(n == 4);
+ assert(c1.get_allocator() == A(10));
+ assert(c0.empty());
+ }
+ {
+ typedef MoveOnly T;
+ typedef other_allocator<T> A;
+ typedef std::forward_list<T, A> C;
+ T t0[] = {10, 11, 12, 13};
+ T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ typedef std::move_iterator<T*> I;
+ C c0(I(std::begin(t0)), I(std::end(t0)), A(10));
+ C c1(I(std::begin(t1)), I(std::end(t1)), A(11));
+ c1 = std::move(c0);
+ int n = 0;
+ for (C::const_iterator i = c1.cbegin(); i != c1.cend(); ++i, ++n)
+ assert(*i == 10+n);
+ assert(n == 4);
+ assert(c1.get_allocator() == A(10));
+ assert(c0.empty());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef MoveOnly T;
+ typedef min_allocator<T> A;
+ typedef std::forward_list<T, A> C;
+ T t0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ T t1[] = {10, 11, 12, 13};
+ typedef std::move_iterator<T*> I;
+ C c0(I(std::begin(t0)), I(std::end(t0)), A());
+ C c1(I(std::begin(t1)), I(std::end(t1)), A());
+ c1 = std::move(c0);
+ int n = 0;
+ for (C::const_iterator i = c1.cbegin(); i != c1.cend(); ++i, ++n)
+ assert(*i == n);
+ assert(n == 10);
+ assert(c1.get_allocator() == A());
+ assert(c0.empty());
+ }
+ {
+ typedef MoveOnly T;
+ typedef min_allocator<T> A;
+ typedef std::forward_list<T, A> C;
+ T t0[] = {10, 11, 12, 13};
+ T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ typedef std::move_iterator<T*> I;
+ C c0(I(std::begin(t0)), I(std::end(t0)), A());
+ C c1(I(std::begin(t1)), I(std::end(t1)), A());
+ c1 = std::move(c0);
+ int n = 0;
+ for (C::const_iterator i = c1.cbegin(); i != c1.cend(); ++i, ++n)
+ assert(*i == 10+n);
+ assert(n == 4);
+ assert(c1.get_allocator() == A());
+ assert(c0.empty());
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_op_init.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_op_init.pass.cpp
new file mode 100644
index 000000000000..551908fea166
--- /dev/null
+++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_op_init.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// forward_list& operator=(initializer_list<value_type> il);
+
+#include <forward_list>
+#include <cassert>
+#include <iterator>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ const T t1[] = {10, 11, 12, 13};
+ C c(std::begin(t1), std::end(t1));
+ c = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ int n = 0;
+ for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
+ assert(*i == n);
+ assert(n == 10);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ C c(std::begin(t1), std::end(t1));
+ c = {10, 11, 12, 13};
+ int n = 0;
+ for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
+ assert(*i == 10+n);
+ assert(n == 4);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ const T t1[] = {10, 11, 12, 13};
+ C c(std::begin(t1), std::end(t1));
+ c = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ int n = 0;
+ for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
+ assert(*i == n);
+ assert(n == 10);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ C c(std::begin(t1), std::end(t1));
+ c = {10, 11, 12, 13};
+ int n = 0;
+ for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
+ assert(*i == 10+n);
+ assert(n == 4);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_range.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_range.pass.cpp
new file mode 100644
index 000000000000..0b348e6920ca
--- /dev/null
+++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_range.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// template <class InputIterator>
+// void assign(InputIterator first, InputIterator last);
+
+#include <forward_list>
+#include <cassert>
+#include <iterator>
+
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ const T t0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ const T t1[] = {10, 11, 12, 13};
+ C c(std::begin(t1), std::end(t1));
+ typedef input_iterator<const T*> I;
+ c.assign(I(std::begin(t0)), I(std::end(t0)));
+ int n = 0;
+ for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
+ assert(*i == n);
+ assert(n == 10);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ const T t0[] = {10, 11, 12, 13};
+ const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ C c(std::begin(t1), std::end(t1));
+ typedef input_iterator<const T*> I;
+ c.assign(I(std::begin(t0)), I(std::end(t0)));
+ int n = 0;
+ for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
+ assert(*i == 10+n);
+ assert(n == 4);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ const T t0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ const T t1[] = {10, 11, 12, 13};
+ C c(std::begin(t1), std::end(t1));
+ typedef input_iterator<const T*> I;
+ c.assign(I(std::begin(t0)), I(std::end(t0)));
+ int n = 0;
+ for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
+ assert(*i == n);
+ assert(n == 10);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ const T t0[] = {10, 11, 12, 13};
+ const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ C c(std::begin(t1), std::end(t1));
+ typedef input_iterator<const T*> I;
+ c.assign(I(std::begin(t0)), I(std::end(t0)));
+ int n = 0;
+ for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, (void) ++n)
+ assert(*i == 10+n);
+ assert(n == 4);
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_size_value.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_size_value.pass.cpp
new file mode 100644
index 000000000000..ea53e1c37320
--- /dev/null
+++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_size_value.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// void assign(size_type n, const value_type& v);
+
+#include <forward_list>
+#include <cassert>
+#include <iterator>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ const T t1[] = {10, 11, 12, 13};
+ C c(std::begin(t1), std::end(t1));
+ c.assign(10, 1);
+ int n = 0;
+ for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
+ assert(*i == 1);
+ assert(n == 10);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ C c(std::begin(t1), std::end(t1));
+ c.assign(4, 10);
+ int n = 0;
+ for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
+ assert(*i == 10);
+ assert(n == 4);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ const T t1[] = {10, 11, 12, 13};
+ C c(std::begin(t1), std::end(t1));
+ c.assign(10, 1);
+ int n = 0;
+ for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
+ assert(*i == 1);
+ assert(n == 10);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ C c(std::begin(t1), std::end(t1));
+ c.assign(4, 10);
+ int n = 0;
+ for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
+ assert(*i == 10);
+ assert(n == 4);
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/copy.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/copy.pass.cpp
new file mode 100644
index 000000000000..2fc53bc3a514
--- /dev/null
+++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/copy.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// forward_list(const forward_list& x);
+
+#include <forward_list>
+#include <cassert>
+#include <iterator>
+
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef test_allocator<int> A;
+ typedef std::forward_list<T, A> C;
+ const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ C c0(std::begin(t), std::end(t), A(10));
+ C c = c0;
+ unsigned n = 0;
+ for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+ assert(*i == n);
+ assert(n == std::end(t) - std::begin(t));
+ assert(c == c0);
+ assert(c.get_allocator() == A(10));
+ }
+#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+ {
+ typedef int T;
+ typedef other_allocator<int> A;
+ typedef std::forward_list<T, A> C;
+ const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ C c0(std::begin(t), std::end(t), A(10));
+ C c = c0;
+ unsigned n = 0;
+ for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+ assert(*i == n);
+ assert(n == std::end(t) - std::begin(t));
+ assert(c == c0);
+ assert(c.get_allocator() == A(-2));
+ }
+#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef min_allocator<int> A;
+ typedef std::forward_list<T, A> C;
+ const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ C c0(std::begin(t), std::end(t), A());
+ C c = c0;
+ unsigned n = 0;
+ for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+ assert(*i == n);
+ assert(n == std::end(t) - std::begin(t));
+ assert(c == c0);
+ assert(c.get_allocator() == A());
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/copy_alloc.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/copy_alloc.pass.cpp
new file mode 100644
index 000000000000..bcc24e1cc68e
--- /dev/null
+++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/copy_alloc.pass.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// forward_list(const forward_list& x, const allocator_type& a);
+
+#include <forward_list>
+#include <cassert>
+#include <iterator>
+
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef test_allocator<int> A;
+ typedef std::forward_list<T, A> C;
+ const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ C c0(std::begin(t), std::end(t), A(10));
+ C c(c0, A(9));
+ unsigned n = 0;
+ for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+ assert(*i == n);
+ assert(n == std::end(t) - std::begin(t));
+ assert(c == c0);
+ assert(c.get_allocator() == A(9));
+ }
+ {
+ typedef int T;
+ typedef other_allocator<int> A;
+ typedef std::forward_list<T, A> C;
+ const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ C c0(std::begin(t), std::end(t), A(10));
+ C c(c0, A(9));
+ unsigned n = 0;
+ for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+ assert(*i == n);
+ assert(n == std::end(t) - std::begin(t));
+ assert(c == c0);
+ assert(c.get_allocator() == A(9));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef min_allocator<int> A;
+ typedef std::forward_list<T, A> C;
+ const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ C c0(std::begin(t), std::end(t), A());
+ C c(c0, A());
+ unsigned n = 0;
+ for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+ assert(*i == n);
+ assert(n == std::end(t) - std::begin(t));
+ assert(c == c0);
+ assert(c.get_allocator() == A());
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/default.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/default.pass.cpp
new file mode 100644
index 000000000000..38e95fad8396
--- /dev/null
+++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/default.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// forward_list();
+
+#include <forward_list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ C c;
+ assert(c.empty());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ C c;
+ assert(c.empty());
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ C c = {};
+ assert(c.empty());
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/default_noexcept.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/default_noexcept.pass.cpp
new file mode 100644
index 000000000000..5167a065a9ad
--- /dev/null
+++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/default_noexcept.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// forward_list()
+// noexcept(is_nothrow_default_constructible<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <forward_list>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_alloc
+{
+ typedef T value_type;
+ some_alloc(const some_alloc&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::forward_list<MoveOnly> C;
+ static_assert(std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::forward_list<MoveOnly, test_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::forward_list<MoveOnly, other_allocator<MoveOnly>> C;
+ static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::forward_list<MoveOnly, some_alloc<MoveOnly>> C;
+ static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/default_recursive.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/default_recursive.pass.cpp
new file mode 100644
index 000000000000..5ff00e6fe529
--- /dev/null
+++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/default_recursive.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// class forward_list
+
+// forward_list();
+
+#include <forward_list>
+
+struct X
+{
+ std::forward_list<X> q;
+};
+
+int main()
+{
+}
diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/dtor_noexcept.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/dtor_noexcept.pass.cpp
new file mode 100644
index 000000000000..da41bf4eb1fc
--- /dev/null
+++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/dtor_noexcept.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// ~forward_list() // implied noexcept;
+
+#include <forward_list>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "test_allocator.h"
+
+#if __has_feature(cxx_noexcept)
+
+template <class T>
+struct some_alloc
+{
+ typedef T value_type;
+ some_alloc(const some_alloc&);
+ ~some_alloc() noexcept(false);
+};
+
+#endif
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::forward_list<MoveOnly> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::forward_list<MoveOnly, test_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::forward_list<MoveOnly, other_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::forward_list<MoveOnly, some_alloc<MoveOnly>> C;
+ static_assert(!std::is_nothrow_destructible<C>::value, "");
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/init.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/init.pass.cpp
new file mode 100644
index 000000000000..5b31c4dad0a0
--- /dev/null
+++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/init.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// forward_list(initializer_list<value_type> il);
+
+#include <forward_list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ C c = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ unsigned n = 0;
+ for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+ assert(*i == n);
+ assert(n == 10);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ C c = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ unsigned n = 0;
+ for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+ assert(*i == n);
+ assert(n == 10);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/init_alloc.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/init_alloc.pass.cpp
new file mode 100644
index 000000000000..750486b829f2
--- /dev/null
+++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/init_alloc.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// forward_list(initializer_list<value_type> il, const allocator_type& a);
+
+#include <forward_list>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef int T;
+ typedef test_allocator<T> A;
+ typedef std::forward_list<T, A> C;
+ C c({0, 1, 2, 3, 4, 5, 6, 7, 8, 9}, A(14));
+ unsigned n = 0;
+ for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+ assert(*i == n);
+ assert(n == 10);
+ assert(c.get_allocator() == A(14));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef min_allocator<T> A;
+ typedef std::forward_list<T, A> C;
+ C c({0, 1, 2, 3, 4, 5, 6, 7, 8, 9}, A());
+ unsigned n = 0;
+ for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+ assert(*i == n);
+ assert(n == 10);
+ assert(c.get_allocator() == A());
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/move.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/move.pass.cpp
new file mode 100644
index 000000000000..8341f7ba0cb2
--- /dev/null
+++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/move.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// forward_list(forward_list&& x);
+
+#include <forward_list>
+#include <cassert>
+#include <iterator>
+
+#include "test_allocator.h"
+#include "MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef MoveOnly T;
+ typedef test_allocator<int> A;
+ typedef std::forward_list<T, A> C;
+ T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ typedef std::move_iterator<T*> I;
+ C c0(I(std::begin(t)), I(std::end(t)), A(10));
+ C c = std::move(c0);
+ unsigned n = 0;
+ for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+ assert(*i == n);
+ assert(n == std::end(t) - std::begin(t));
+ assert(c0.empty());
+ assert(c.get_allocator() == A(10));
+ }
+ {
+ typedef MoveOnly T;
+ typedef other_allocator<int> A;
+ typedef std::forward_list<T, A> C;
+ T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ typedef std::move_iterator<T*> I;
+ C c0(I(std::begin(t)), I(std::end(t)), A(10));
+ C c = std::move(c0);
+ unsigned n = 0;
+ for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+ assert(*i == n);
+ assert(n == std::end(t) - std::begin(t));
+ assert(c0.empty());
+ assert(c.get_allocator() == A(10));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef MoveOnly T;
+ typedef min_allocator<int> A;
+ typedef std::forward_list<T, A> C;
+ T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ typedef std::move_iterator<T*> I;
+ C c0(I(std::begin(t)), I(std::end(t)), A());
+ C c = std::move(c0);
+ unsigned n = 0;
+ for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+ assert(*i == n);
+ assert(n == std::end(t) - std::begin(t));
+ assert(c0.empty());
+ assert(c.get_allocator() == A());
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/move_alloc.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/move_alloc.pass.cpp
new file mode 100644
index 000000000000..6bb575ef80f1
--- /dev/null
+++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/move_alloc.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// forward_list(forward_list&& x, const allocator_type& a);
+
+#include <forward_list>
+#include <cassert>
+#include <iterator>
+
+#include "test_allocator.h"
+#include "MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef MoveOnly T;
+ typedef test_allocator<int> A;
+ typedef std::forward_list<T, A> C;
+ T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ typedef std::move_iterator<T*> I;
+ C c0(I(std::begin(t)), I(std::end(t)), A(10));
+ C c(std::move(c0), A(10));
+ unsigned n = 0;
+ for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+ assert(*i == n);
+ assert(n == std::end(t) - std::begin(t));
+ assert(c0.empty());
+ assert(c.get_allocator() == A(10));
+ }
+ {
+ typedef MoveOnly T;
+ typedef test_allocator<int> A;
+ typedef std::forward_list<T, A> C;
+ T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ typedef std::move_iterator<T*> I;
+ C c0(I(std::begin(t)), I(std::end(t)), A(10));
+ C c(std::move(c0), A(9));
+ unsigned n = 0;
+ for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+ assert(*i == n);
+ assert(n == std::end(t) - std::begin(t));
+ assert(!c0.empty());
+ assert(c.get_allocator() == A(9));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef MoveOnly T;
+ typedef min_allocator<int> A;
+ typedef std::forward_list<T, A> C;
+ T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ typedef std::move_iterator<T*> I;
+ C c0(I(std::begin(t)), I(std::end(t)), A());
+ C c(std::move(c0), A());
+ unsigned n = 0;
+ for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+ assert(*i == n);
+ assert(n == std::end(t) - std::begin(t));
+ assert(c0.empty());
+ assert(c.get_allocator() == A());
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/move_assign_noexcept.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/move_assign_noexcept.pass.cpp
new file mode 100644
index 000000000000..28ce2c12b619
--- /dev/null
+++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/move_assign_noexcept.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// forward_list& operator=(forward_list&& c)
+// noexcept(
+// allocator_type::propagate_on_container_move_assignment::value &&
+// is_nothrow_move_assignable<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <forward_list>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_alloc
+{
+ typedef T value_type;
+ some_alloc(const some_alloc&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::forward_list<MoveOnly> C;
+ static_assert(std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::forward_list<MoveOnly, test_allocator<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::forward_list<MoveOnly, other_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::forward_list<MoveOnly, some_alloc<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/move_noexcept.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/move_noexcept.pass.cpp
new file mode 100644
index 000000000000..7b001ea67b19
--- /dev/null
+++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/move_noexcept.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// forward_list(forward_list&&)
+// noexcept(is_nothrow_move_constructible<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <forward_list>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_alloc
+{
+ typedef T value_type;
+ some_alloc(const some_alloc&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::forward_list<MoveOnly> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::forward_list<MoveOnly, test_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::forward_list<MoveOnly, other_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::forward_list<MoveOnly, some_alloc<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_constructible<C>::value, "");
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/range.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/range.pass.cpp
new file mode 100644
index 000000000000..763952439f00
--- /dev/null
+++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/range.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// template <class InputIterator>
+// forward_list(InputIterator first, InputIterator last);
+
+#include <forward_list>
+#include <cassert>
+#include <iterator>
+
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ typedef input_iterator<const T*> I;
+ const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ C c(I(std::begin(t)), I(std::end(t)));
+ unsigned n = 0;
+ for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+ assert(*i == n);
+ assert(n == std::end(t) - std::begin(t));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ typedef input_iterator<const T*> I;
+ const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ C c(I(std::begin(t)), I(std::end(t)));
+ unsigned n = 0;
+ for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+ assert(*i == n);
+ assert(n == std::end(t) - std::begin(t));
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/range_alloc.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/range_alloc.pass.cpp
new file mode 100644
index 000000000000..d72c3581022d
--- /dev/null
+++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/range_alloc.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// template <class InputIterator>
+// forward_list(InputIterator first, InputIterator last,
+// const allocator_type& a);
+
+#include <forward_list>
+#include <cassert>
+#include <iterator>
+
+#include "test_allocator.h"
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef test_allocator<T> A;
+ typedef std::forward_list<T, A> C;
+ typedef input_iterator<const T*> I;
+ const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ C c(I(std::begin(t)), I(std::end(t)), A(13));
+ unsigned n = 0;
+ for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+ assert(*i == n);
+ assert(n == std::end(t) - std::begin(t));
+ assert(c.get_allocator() == A(13));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef min_allocator<T> A;
+ typedef std::forward_list<T, A> C;
+ typedef input_iterator<const T*> I;
+ const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ C c(I(std::begin(t)), I(std::end(t)), A());
+ unsigned n = 0;
+ for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+ assert(*i == n);
+ assert(n == std::end(t) - std::begin(t));
+ assert(c.get_allocator() == A());
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/size.fail.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/size.fail.cpp
new file mode 100644
index 000000000000..2d963a1be479
--- /dev/null
+++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/size.fail.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// explicit forward_list(size_type n);
+
+#include <forward_list>
+#include <cassert>
+
+#include "DefaultOnly.h"
+
+int main()
+{
+ {
+ typedef DefaultOnly T;
+ typedef std::forward_list<T> C;
+ unsigned N = 10;
+ C c = N;
+ unsigned n = 0;
+ for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ assert(*i == T());
+#else
+ ;
+#endif
+ assert(n == N);
+ }
+}
diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/size.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/size.pass.cpp
new file mode 100644
index 000000000000..e02dcb4bf691
--- /dev/null
+++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/size.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// explicit forward_list(size_type n);
+// explicit forward_list(size_type n, const Alloc& a);
+
+#include <forward_list>
+#include <cassert>
+
+#include "DefaultOnly.h"
+#include "min_allocator.h"
+
+template <class T, class Allocator>
+void check_allocator(unsigned n, Allocator const &alloc = Allocator())
+{
+#if _LIBCPP_STD_VER > 11
+ typedef std::forward_list<T, Allocator> C;
+ C d(n, alloc);
+ assert(d.get_allocator() == alloc);
+ assert(std::distance(d.begin(), d.end()) == n);
+#endif
+}
+
+int main()
+{
+ {
+ typedef DefaultOnly T;
+ typedef std::forward_list<T> C;
+ unsigned N = 10;
+ C c(N);
+ unsigned n = 0;
+ for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ assert(*i == T());
+#else
+ ;
+#endif
+ assert(n == N);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef DefaultOnly T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ unsigned N = 10;
+ C c(N);
+ unsigned n = 0;
+ for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ assert(*i == T());
+#else
+ ;
+#endif
+ assert(n == N);
+ check_allocator<T, min_allocator<T>> ( 0 );
+ check_allocator<T, min_allocator<T>> ( 3 );
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/size_value.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/size_value.pass.cpp
new file mode 100644
index 000000000000..05ab98bb205d
--- /dev/null
+++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/size_value.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// forward_list(size_type n, const value_type& v);
+
+#include <forward_list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ T v(6);
+ unsigned N = 10;
+ C c(N, v);
+ unsigned n = 0;
+ for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+ assert(*i == v);
+ assert(n == N);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ T v(6);
+ unsigned N = 10;
+ C c(N, v);
+ unsigned n = 0;
+ for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+ assert(*i == v);
+ assert(n == N);
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/size_value_alloc.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/size_value_alloc.pass.cpp
new file mode 100644
index 000000000000..1d631ab12ba1
--- /dev/null
+++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/size_value_alloc.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// forward_list(size_type n, const value_type& v, const allocator_type& a);
+
+#include <forward_list>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef test_allocator<int> A;
+ typedef A::value_type T;
+ typedef std::forward_list<T, A> C;
+ T v(6);
+ unsigned N = 10;
+ C c(N, v, A(12));
+ unsigned n = 0;
+ for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+ assert(*i == v);
+ assert(n == N);
+ assert(c.get_allocator() == A(12));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef min_allocator<int> A;
+ typedef A::value_type T;
+ typedef std::forward_list<T, A> C;
+ T v(6);
+ unsigned N = 10;
+ C c(N, v, A());
+ unsigned n = 0;
+ for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+ assert(*i == v);
+ assert(n == N);
+ assert(c.get_allocator() == A());
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/forwardlist/forwardlist.iter/before_begin.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.iter/before_begin.pass.cpp
new file mode 100644
index 000000000000..083cec2886da
--- /dev/null
+++ b/test/std/containers/sequences/forwardlist/forwardlist.iter/before_begin.pass.cpp
@@ -0,0 +1,104 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// iterator before_begin();
+// const_iterator before_begin() const;
+// const_iterator cbefore_begin() const;
+
+#include <forward_list>
+#include <cassert>
+#include <iterator>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ C c;
+ C::iterator i = c.before_begin();
+ assert(std::distance(i, c.end()) == 1);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ const C c;
+ C::const_iterator i = c.before_begin();
+ assert(std::distance(i, c.end()) == 1);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ const C c;
+ C::const_iterator i = c.cbefore_begin();
+ assert(std::distance(i, c.end()) == 1);
+ assert(c.cbefore_begin() == c.before_begin());
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ C c(std::begin(t), std::end(t));
+ C::iterator i = c.before_begin();
+ assert(std::distance(i, c.end()) == 11);
+ assert(std::next(c.before_begin()) == c.begin());
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ const C c(std::begin(t), std::end(t));
+ C::const_iterator i = c.before_begin();
+ assert(std::distance(i, c.end()) == 11);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ C c;
+ C::iterator i = c.before_begin();
+ assert(std::distance(i, c.end()) == 1);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ const C c;
+ C::const_iterator i = c.before_begin();
+ assert(std::distance(i, c.end()) == 1);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ const C c;
+ C::const_iterator i = c.cbefore_begin();
+ assert(std::distance(i, c.end()) == 1);
+ assert(c.cbefore_begin() == c.before_begin());
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ C c(std::begin(t), std::end(t));
+ C::iterator i = c.before_begin();
+ assert(std::distance(i, c.end()) == 11);
+ assert(std::next(c.before_begin()) == c.begin());
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ const C c(std::begin(t), std::end(t));
+ C::const_iterator i = c.before_begin();
+ assert(std::distance(i, c.end()) == 11);
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/forwardlist/forwardlist.iter/iterators.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.iter/iterators.pass.cpp
new file mode 100644
index 000000000000..6f3ac548db8b
--- /dev/null
+++ b/test/std/containers/sequences/forwardlist/forwardlist.iter/iterators.pass.cpp
@@ -0,0 +1,145 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// iterator begin();
+// iterator end();
+// const_iterator begin() const;
+// const_iterator end() const;
+// const_iterator cbegin() const;
+// const_iterator cend() const;
+
+#include <forward_list>
+#include <cassert>
+#include <iterator>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ C c;
+ C::iterator i = c.begin();
+ C::iterator j = c.end();
+ assert(std::distance(i, j) == 0);
+ assert(i == j);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ const C c;
+ C::const_iterator i = c.begin();
+ C::const_iterator j = c.end();
+ assert(std::distance(i, j) == 0);
+ assert(i == j);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ C c;
+ C::const_iterator i = c.cbegin();
+ C::const_iterator j = c.cend();
+ assert(std::distance(i, j) == 0);
+ assert(i == j);
+ assert(i == c.end());
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ C c(std::begin(t), std::end(t));
+ C::iterator i = c.begin();
+ assert(*i == 0);
+ ++i;
+ assert(*i == 1);
+ *i = 10;
+ assert(*i == 10);
+ assert(std::distance(c.begin(), c.end()) == 10);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ C::iterator i;
+ C::const_iterator j;
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ C c;
+ C::iterator i = c.begin();
+ C::iterator j = c.end();
+ assert(std::distance(i, j) == 0);
+ assert(i == j);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ const C c;
+ C::const_iterator i = c.begin();
+ C::const_iterator j = c.end();
+ assert(std::distance(i, j) == 0);
+ assert(i == j);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ C c;
+ C::const_iterator i = c.cbegin();
+ C::const_iterator j = c.cend();
+ assert(std::distance(i, j) == 0);
+ assert(i == j);
+ assert(i == c.end());
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ C c(std::begin(t), std::end(t));
+ C::iterator i = c.begin();
+ assert(*i == 0);
+ ++i;
+ assert(*i == 1);
+ *i = 10;
+ assert(*i == 10);
+ assert(std::distance(c.begin(), c.end()) == 10);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ C::iterator i;
+ C::const_iterator j;
+ }
+#endif
+#if _LIBCPP_STD_VER > 11
+ { // N3644 testing
+ std::forward_list<int>::iterator ii1{}, ii2{};
+ std::forward_list<int>::iterator ii4 = ii1;
+ std::forward_list<int>::const_iterator cii{};
+ assert ( ii1 == ii2 );
+ assert ( ii1 == ii4 );
+
+ assert (!(ii1 != ii2 ));
+
+ assert ( (ii1 == cii ));
+ assert ( (cii == ii1 ));
+ assert (!(ii1 != cii ));
+ assert (!(cii != ii1 ));
+
+// std::forward_list<int> c;
+// assert ( ii1 != c.cbegin());
+// assert ( cii != c.begin());
+// assert ( cii != c.cend());
+// assert ( ii1 != c.end());
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/forwardlist/forwardlist.modifiers/clear.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/clear.pass.cpp
new file mode 100644
index 000000000000..2739b49d8eb2
--- /dev/null
+++ b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/clear.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// void clear();
+
+#include <forward_list>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef NotConstructible T;
+ typedef std::forward_list<T> C;
+ C c;
+ c.clear();
+ assert(distance(c.begin(), c.end()) == 0);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ const T t[] = {0, 1, 2, 3, 4};
+ C c(std::begin(t), std::end(t));
+
+ c.clear();
+ assert(distance(c.begin(), c.end()) == 0);
+
+ c.clear();
+ assert(distance(c.begin(), c.end()) == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef NotConstructible T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ C c;
+ c.clear();
+ assert(distance(c.begin(), c.end()) == 0);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ const T t[] = {0, 1, 2, 3, 4};
+ C c(std::begin(t), std::end(t));
+
+ c.clear();
+ assert(distance(c.begin(), c.end()) == 0);
+
+ c.clear();
+ assert(distance(c.begin(), c.end()) == 0);
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/forwardlist/forwardlist.modifiers/emplace_after.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/emplace_after.pass.cpp
new file mode 100644
index 000000000000..e305c5b6ab52
--- /dev/null
+++ b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/emplace_after.pass.cpp
@@ -0,0 +1,89 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// template <class... Args>
+// iterator emplace_after(const_iterator p, Args&&... args);
+
+#include <forward_list>
+#include <cassert>
+
+#include "../../../Emplaceable.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef Emplaceable T;
+ typedef std::forward_list<T> C;
+ typedef C::iterator I;
+ C c;
+ I i = c.emplace_after(c.cbefore_begin());
+ assert(i == c.begin());
+ assert(c.front() == Emplaceable());
+ assert(distance(c.begin(), c.end()) == 1);
+
+ i = c.emplace_after(c.cbegin(), 1, 2.5);
+ assert(i == next(c.begin()));
+ assert(c.front() == Emplaceable());
+ assert(*next(c.begin()) == Emplaceable(1, 2.5));
+ assert(distance(c.begin(), c.end()) == 2);
+
+ i = c.emplace_after(next(c.cbegin()), 2, 3.5);
+ assert(i == next(c.begin(), 2));
+ assert(c.front() == Emplaceable());
+ assert(*next(c.begin()) == Emplaceable(1, 2.5));
+ assert(*next(c.begin(), 2) == Emplaceable(2, 3.5));
+ assert(distance(c.begin(), c.end()) == 3);
+
+ i = c.emplace_after(c.cbegin(), 3, 4.5);
+ assert(i == next(c.begin()));
+ assert(c.front() == Emplaceable());
+ assert(*next(c.begin(), 1) == Emplaceable(3, 4.5));
+ assert(*next(c.begin(), 2) == Emplaceable(1, 2.5));
+ assert(*next(c.begin(), 3) == Emplaceable(2, 3.5));
+ assert(distance(c.begin(), c.end()) == 4);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef Emplaceable T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ typedef C::iterator I;
+ C c;
+ I i = c.emplace_after(c.cbefore_begin());
+ assert(i == c.begin());
+ assert(c.front() == Emplaceable());
+ assert(distance(c.begin(), c.end()) == 1);
+
+ i = c.emplace_after(c.cbegin(), 1, 2.5);
+ assert(i == next(c.begin()));
+ assert(c.front() == Emplaceable());
+ assert(*next(c.begin()) == Emplaceable(1, 2.5));
+ assert(distance(c.begin(), c.end()) == 2);
+
+ i = c.emplace_after(next(c.cbegin()), 2, 3.5);
+ assert(i == next(c.begin(), 2));
+ assert(c.front() == Emplaceable());
+ assert(*next(c.begin()) == Emplaceable(1, 2.5));
+ assert(*next(c.begin(), 2) == Emplaceable(2, 3.5));
+ assert(distance(c.begin(), c.end()) == 3);
+
+ i = c.emplace_after(c.cbegin(), 3, 4.5);
+ assert(i == next(c.begin()));
+ assert(c.front() == Emplaceable());
+ assert(*next(c.begin(), 1) == Emplaceable(3, 4.5));
+ assert(*next(c.begin(), 2) == Emplaceable(1, 2.5));
+ assert(*next(c.begin(), 3) == Emplaceable(2, 3.5));
+ assert(distance(c.begin(), c.end()) == 4);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/sequences/forwardlist/forwardlist.modifiers/emplace_front.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/emplace_front.pass.cpp
new file mode 100644
index 000000000000..c02337e0562d
--- /dev/null
+++ b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/emplace_front.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// template <class... Args> void emplace_front(Args&&... args);
+
+#include <forward_list>
+#include <cassert>
+
+#include "../../../Emplaceable.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef Emplaceable T;
+ typedef std::forward_list<T> C;
+ C c;
+ c.emplace_front();
+ assert(c.front() == Emplaceable());
+ assert(distance(c.begin(), c.end()) == 1);
+ c.emplace_front(1, 2.5);
+ assert(c.front() == Emplaceable(1, 2.5));
+ assert(*next(c.begin()) == Emplaceable());
+ assert(distance(c.begin(), c.end()) == 2);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef Emplaceable T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ C c;
+ c.emplace_front();
+ assert(c.front() == Emplaceable());
+ assert(distance(c.begin(), c.end()) == 1);
+ c.emplace_front(1, 2.5);
+ assert(c.front() == Emplaceable(1, 2.5));
+ assert(*next(c.begin()) == Emplaceable());
+ assert(distance(c.begin(), c.end()) == 2);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/sequences/forwardlist/forwardlist.modifiers/erase_after_many.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/erase_after_many.pass.cpp
new file mode 100644
index 000000000000..bd9b15300efa
--- /dev/null
+++ b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/erase_after_many.pass.cpp
@@ -0,0 +1,155 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// iterator erase_after(const_iterator first, const_iterator last);
+
+#include <forward_list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ C c(std::begin(t), std::end(t));
+
+ C::iterator i = c.erase_after(next(c.cbefore_begin(), 4), next(c.cbefore_begin(), 4));
+ assert(i == next(c.cbefore_begin(), 4));
+ assert(distance(c.begin(), c.end()) == 10);
+ assert(*next(c.begin(), 0) == 0);
+ assert(*next(c.begin(), 1) == 1);
+ assert(*next(c.begin(), 2) == 2);
+ assert(*next(c.begin(), 3) == 3);
+ assert(*next(c.begin(), 4) == 4);
+ assert(*next(c.begin(), 5) == 5);
+ assert(*next(c.begin(), 6) == 6);
+ assert(*next(c.begin(), 7) == 7);
+ assert(*next(c.begin(), 8) == 8);
+ assert(*next(c.begin(), 9) == 9);
+
+ i = c.erase_after(next(c.cbefore_begin(), 2), next(c.cbefore_begin(), 5));
+ assert(i == next(c.begin(), 2));
+ assert(distance(c.begin(), c.end()) == 8);
+ assert(*next(c.begin(), 0) == 0);
+ assert(*next(c.begin(), 1) == 1);
+ assert(*next(c.begin(), 2) == 4);
+ assert(*next(c.begin(), 3) == 5);
+ assert(*next(c.begin(), 4) == 6);
+ assert(*next(c.begin(), 5) == 7);
+ assert(*next(c.begin(), 6) == 8);
+ assert(*next(c.begin(), 7) == 9);
+
+ i = c.erase_after(next(c.cbefore_begin(), 2), next(c.cbefore_begin(), 3));
+ assert(i == next(c.begin(), 2));
+ assert(distance(c.begin(), c.end()) == 8);
+ assert(*next(c.begin(), 0) == 0);
+ assert(*next(c.begin(), 1) == 1);
+ assert(*next(c.begin(), 2) == 4);
+ assert(*next(c.begin(), 3) == 5);
+ assert(*next(c.begin(), 4) == 6);
+ assert(*next(c.begin(), 5) == 7);
+ assert(*next(c.begin(), 6) == 8);
+ assert(*next(c.begin(), 7) == 9);
+
+ i = c.erase_after(next(c.cbefore_begin(), 5), next(c.cbefore_begin(), 9));
+ assert(i == c.end());
+ assert(distance(c.begin(), c.end()) == 5);
+ assert(*next(c.begin(), 0) == 0);
+ assert(*next(c.begin(), 1) == 1);
+ assert(*next(c.begin(), 2) == 4);
+ assert(*next(c.begin(), 3) == 5);
+ assert(*next(c.begin(), 4) == 6);
+
+ i = c.erase_after(next(c.cbefore_begin(), 0), next(c.cbefore_begin(), 2));
+ assert(i == c.begin());
+ assert(distance(c.begin(), c.end()) == 4);
+ assert(*next(c.begin(), 0) == 1);
+ assert(*next(c.begin(), 1) == 4);
+ assert(*next(c.begin(), 2) == 5);
+ assert(*next(c.begin(), 3) == 6);
+
+ i = c.erase_after(next(c.cbefore_begin(), 0), next(c.cbefore_begin(), 5));
+ assert(i == c.begin());
+ assert(i == c.end());
+ assert(distance(c.begin(), c.end()) == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ C c(std::begin(t), std::end(t));
+
+ C::iterator i = c.erase_after(next(c.cbefore_begin(), 4), next(c.cbefore_begin(), 4));
+ assert(i == next(c.cbefore_begin(), 4));
+ assert(distance(c.begin(), c.end()) == 10);
+ assert(*next(c.begin(), 0) == 0);
+ assert(*next(c.begin(), 1) == 1);
+ assert(*next(c.begin(), 2) == 2);
+ assert(*next(c.begin(), 3) == 3);
+ assert(*next(c.begin(), 4) == 4);
+ assert(*next(c.begin(), 5) == 5);
+ assert(*next(c.begin(), 6) == 6);
+ assert(*next(c.begin(), 7) == 7);
+ assert(*next(c.begin(), 8) == 8);
+ assert(*next(c.begin(), 9) == 9);
+
+ i = c.erase_after(next(c.cbefore_begin(), 2), next(c.cbefore_begin(), 5));
+ assert(i == next(c.begin(), 2));
+ assert(distance(c.begin(), c.end()) == 8);
+ assert(*next(c.begin(), 0) == 0);
+ assert(*next(c.begin(), 1) == 1);
+ assert(*next(c.begin(), 2) == 4);
+ assert(*next(c.begin(), 3) == 5);
+ assert(*next(c.begin(), 4) == 6);
+ assert(*next(c.begin(), 5) == 7);
+ assert(*next(c.begin(), 6) == 8);
+ assert(*next(c.begin(), 7) == 9);
+
+ i = c.erase_after(next(c.cbefore_begin(), 2), next(c.cbefore_begin(), 3));
+ assert(i == next(c.begin(), 2));
+ assert(distance(c.begin(), c.end()) == 8);
+ assert(*next(c.begin(), 0) == 0);
+ assert(*next(c.begin(), 1) == 1);
+ assert(*next(c.begin(), 2) == 4);
+ assert(*next(c.begin(), 3) == 5);
+ assert(*next(c.begin(), 4) == 6);
+ assert(*next(c.begin(), 5) == 7);
+ assert(*next(c.begin(), 6) == 8);
+ assert(*next(c.begin(), 7) == 9);
+
+ i = c.erase_after(next(c.cbefore_begin(), 5), next(c.cbefore_begin(), 9));
+ assert(i == c.end());
+ assert(distance(c.begin(), c.end()) == 5);
+ assert(*next(c.begin(), 0) == 0);
+ assert(*next(c.begin(), 1) == 1);
+ assert(*next(c.begin(), 2) == 4);
+ assert(*next(c.begin(), 3) == 5);
+ assert(*next(c.begin(), 4) == 6);
+
+ i = c.erase_after(next(c.cbefore_begin(), 0), next(c.cbefore_begin(), 2));
+ assert(i == c.begin());
+ assert(distance(c.begin(), c.end()) == 4);
+ assert(*next(c.begin(), 0) == 1);
+ assert(*next(c.begin(), 1) == 4);
+ assert(*next(c.begin(), 2) == 5);
+ assert(*next(c.begin(), 3) == 6);
+
+ i = c.erase_after(next(c.cbefore_begin(), 0), next(c.cbefore_begin(), 5));
+ assert(i == c.begin());
+ assert(i == c.end());
+ assert(distance(c.begin(), c.end()) == 0);
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/forwardlist/forwardlist.modifiers/erase_after_one.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/erase_after_one.pass.cpp
new file mode 100644
index 000000000000..4f51498bc651
--- /dev/null
+++ b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/erase_after_one.pass.cpp
@@ -0,0 +1,97 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// iterator erase_after(const_iterator p);
+
+#include <forward_list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ const T t[] = {0, 1, 2, 3, 4};
+ C c(std::begin(t), std::end(t));
+
+ C::iterator i = c.erase_after(next(c.cbefore_begin(), 4));
+ assert(i == c.end());
+ assert(distance(c.begin(), c.end()) == 4);
+ assert(*next(c.begin(), 0) == 0);
+ assert(*next(c.begin(), 1) == 1);
+ assert(*next(c.begin(), 2) == 2);
+ assert(*next(c.begin(), 3) == 3);
+
+ i = c.erase_after(next(c.cbefore_begin(), 0));
+ assert(i == c.begin());
+ assert(distance(c.begin(), c.end()) == 3);
+ assert(*next(c.begin(), 0) == 1);
+ assert(*next(c.begin(), 1) == 2);
+ assert(*next(c.begin(), 2) == 3);
+
+ i = c.erase_after(next(c.cbefore_begin(), 1));
+ assert(i == next(c.begin()));
+ assert(distance(c.begin(), c.end()) == 2);
+ assert(*next(c.begin(), 0) == 1);
+ assert(*next(c.begin(), 1) == 3);
+
+ i = c.erase_after(next(c.cbefore_begin(), 1));
+ assert(i == c.end());
+ assert(distance(c.begin(), c.end()) == 1);
+ assert(*next(c.begin(), 0) == 1);
+
+ i = c.erase_after(next(c.cbefore_begin(), 0));
+ assert(i == c.begin());
+ assert(i == c.end());
+ assert(distance(c.begin(), c.end()) == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ const T t[] = {0, 1, 2, 3, 4};
+ C c(std::begin(t), std::end(t));
+
+ C::iterator i = c.erase_after(next(c.cbefore_begin(), 4));
+ assert(i == c.end());
+ assert(distance(c.begin(), c.end()) == 4);
+ assert(*next(c.begin(), 0) == 0);
+ assert(*next(c.begin(), 1) == 1);
+ assert(*next(c.begin(), 2) == 2);
+ assert(*next(c.begin(), 3) == 3);
+
+ i = c.erase_after(next(c.cbefore_begin(), 0));
+ assert(i == c.begin());
+ assert(distance(c.begin(), c.end()) == 3);
+ assert(*next(c.begin(), 0) == 1);
+ assert(*next(c.begin(), 1) == 2);
+ assert(*next(c.begin(), 2) == 3);
+
+ i = c.erase_after(next(c.cbefore_begin(), 1));
+ assert(i == next(c.begin()));
+ assert(distance(c.begin(), c.end()) == 2);
+ assert(*next(c.begin(), 0) == 1);
+ assert(*next(c.begin(), 1) == 3);
+
+ i = c.erase_after(next(c.cbefore_begin(), 1));
+ assert(i == c.end());
+ assert(distance(c.begin(), c.end()) == 1);
+ assert(*next(c.begin(), 0) == 1);
+
+ i = c.erase_after(next(c.cbefore_begin(), 0));
+ assert(i == c.begin());
+ assert(i == c.end());
+ assert(distance(c.begin(), c.end()) == 0);
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_const.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_const.pass.cpp
new file mode 100644
index 000000000000..ec650b695727
--- /dev/null
+++ b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_const.pass.cpp
@@ -0,0 +1,87 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// iterator insert_after(const_iterator p, const value_type& v);
+
+#include <forward_list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ typedef C::iterator I;
+ C c;
+ I i = c.insert_after(c.cbefore_begin(), 0);
+ assert(i == c.begin());
+ assert(c.front() == 0);
+ assert(c.front() == 0);
+ assert(distance(c.begin(), c.end()) == 1);
+
+ i = c.insert_after(c.cbegin(), 1);
+ assert(i == next(c.begin()));
+ assert(c.front() == 0);
+ assert(*next(c.begin()) == 1);
+ assert(distance(c.begin(), c.end()) == 2);
+
+ i = c.insert_after(next(c.cbegin()), 2);
+ assert(i == next(c.begin(), 2));
+ assert(c.front() == 0);
+ assert(*next(c.begin()) == 1);
+ assert(*next(c.begin(), 2) == 2);
+ assert(distance(c.begin(), c.end()) == 3);
+
+ i = c.insert_after(c.cbegin(), 3);
+ assert(i == next(c.begin()));
+ assert(c.front() == 0);
+ assert(*next(c.begin(), 1) == 3);
+ assert(*next(c.begin(), 2) == 1);
+ assert(*next(c.begin(), 3) == 2);
+ assert(distance(c.begin(), c.end()) == 4);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ typedef C::iterator I;
+ C c;
+ I i = c.insert_after(c.cbefore_begin(), 0);
+ assert(i == c.begin());
+ assert(c.front() == 0);
+ assert(c.front() == 0);
+ assert(distance(c.begin(), c.end()) == 1);
+
+ i = c.insert_after(c.cbegin(), 1);
+ assert(i == next(c.begin()));
+ assert(c.front() == 0);
+ assert(*next(c.begin()) == 1);
+ assert(distance(c.begin(), c.end()) == 2);
+
+ i = c.insert_after(next(c.cbegin()), 2);
+ assert(i == next(c.begin(), 2));
+ assert(c.front() == 0);
+ assert(*next(c.begin()) == 1);
+ assert(*next(c.begin(), 2) == 2);
+ assert(distance(c.begin(), c.end()) == 3);
+
+ i = c.insert_after(c.cbegin(), 3);
+ assert(i == next(c.begin()));
+ assert(c.front() == 0);
+ assert(*next(c.begin(), 1) == 3);
+ assert(*next(c.begin(), 2) == 1);
+ assert(*next(c.begin(), 3) == 2);
+ assert(distance(c.begin(), c.end()) == 4);
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_init.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_init.pass.cpp
new file mode 100644
index 000000000000..4d3018199809
--- /dev/null
+++ b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_init.pass.cpp
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// iterator insert_after(const_iterator p, initializer_list<value_type> il);
+
+#include <forward_list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ typedef C::iterator I;
+ C c;
+ I i = c.insert_after(c.cbefore_begin(), {});
+ assert(i == c.before_begin());
+ assert(distance(c.begin(), c.end()) == 0);
+
+ i = c.insert_after(c.cbefore_begin(), {0, 1, 2});
+ assert(i == next(c.before_begin(), 3));
+ assert(distance(c.begin(), c.end()) == 3);
+ assert(*next(c.begin(), 0) == 0);
+ assert(*next(c.begin(), 1) == 1);
+ assert(*next(c.begin(), 2) == 2);
+
+ i = c.insert_after(c.begin(), {3, 4});
+ assert(i == next(c.begin(), 2));
+ assert(distance(c.begin(), c.end()) == 5);
+ assert(*next(c.begin(), 0) == 0);
+ assert(*next(c.begin(), 1) == 3);
+ assert(*next(c.begin(), 2) == 4);
+ assert(*next(c.begin(), 3) == 1);
+ assert(*next(c.begin(), 4) == 2);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ typedef C::iterator I;
+ C c;
+ I i = c.insert_after(c.cbefore_begin(), {});
+ assert(i == c.before_begin());
+ assert(distance(c.begin(), c.end()) == 0);
+
+ i = c.insert_after(c.cbefore_begin(), {0, 1, 2});
+ assert(i == next(c.before_begin(), 3));
+ assert(distance(c.begin(), c.end()) == 3);
+ assert(*next(c.begin(), 0) == 0);
+ assert(*next(c.begin(), 1) == 1);
+ assert(*next(c.begin(), 2) == 2);
+
+ i = c.insert_after(c.begin(), {3, 4});
+ assert(i == next(c.begin(), 2));
+ assert(distance(c.begin(), c.end()) == 5);
+ assert(*next(c.begin(), 0) == 0);
+ assert(*next(c.begin(), 1) == 3);
+ assert(*next(c.begin(), 2) == 4);
+ assert(*next(c.begin(), 3) == 1);
+ assert(*next(c.begin(), 4) == 2);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_range.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_range.pass.cpp
new file mode 100644
index 000000000000..103475f1edab
--- /dev/null
+++ b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_range.pass.cpp
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// template <class InputIterator>
+// iterator insert_after(const_iterator p,
+// InputIterator first, InputIterator last);
+
+#include <forward_list>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ typedef C::iterator I;
+ typedef input_iterator<const T*> J;
+ C c;
+ const T t[] = {0, 1, 2, 3, 4};
+ I i = c.insert_after(c.cbefore_begin(), J(t), J(t));
+ assert(i == c.before_begin());
+ assert(distance(c.begin(), c.end()) == 0);
+
+ i = c.insert_after(c.cbefore_begin(), J(t), J(t+3));
+ assert(i == next(c.before_begin(), 3));
+ assert(distance(c.begin(), c.end()) == 3);
+ assert(*next(c.begin(), 0) == 0);
+ assert(*next(c.begin(), 1) == 1);
+ assert(*next(c.begin(), 2) == 2);
+
+ i = c.insert_after(c.begin(), J(t+3), J(t+5));
+ assert(i == next(c.begin(), 2));
+ assert(distance(c.begin(), c.end()) == 5);
+ assert(*next(c.begin(), 0) == 0);
+ assert(*next(c.begin(), 1) == 3);
+ assert(*next(c.begin(), 2) == 4);
+ assert(*next(c.begin(), 3) == 1);
+ assert(*next(c.begin(), 4) == 2);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ typedef C::iterator I;
+ typedef input_iterator<const T*> J;
+ C c;
+ const T t[] = {0, 1, 2, 3, 4};
+ I i = c.insert_after(c.cbefore_begin(), J(t), J(t));
+ assert(i == c.before_begin());
+ assert(distance(c.begin(), c.end()) == 0);
+
+ i = c.insert_after(c.cbefore_begin(), J(t), J(t+3));
+ assert(i == next(c.before_begin(), 3));
+ assert(distance(c.begin(), c.end()) == 3);
+ assert(*next(c.begin(), 0) == 0);
+ assert(*next(c.begin(), 1) == 1);
+ assert(*next(c.begin(), 2) == 2);
+
+ i = c.insert_after(c.begin(), J(t+3), J(t+5));
+ assert(i == next(c.begin(), 2));
+ assert(distance(c.begin(), c.end()) == 5);
+ assert(*next(c.begin(), 0) == 0);
+ assert(*next(c.begin(), 1) == 3);
+ assert(*next(c.begin(), 2) == 4);
+ assert(*next(c.begin(), 3) == 1);
+ assert(*next(c.begin(), 4) == 2);
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_rv.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_rv.pass.cpp
new file mode 100644
index 000000000000..f7f376caa090
--- /dev/null
+++ b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_rv.pass.cpp
@@ -0,0 +1,90 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// iterator insert_after(const_iterator p, value_type&& v);
+
+#include <forward_list>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef MoveOnly T;
+ typedef std::forward_list<T> C;
+ typedef C::iterator I;
+ C c;
+ I i = c.insert_after(c.cbefore_begin(), 0);
+ assert(i == c.begin());
+ assert(c.front() == 0);
+ assert(c.front() == 0);
+ assert(distance(c.begin(), c.end()) == 1);
+
+ i = c.insert_after(c.cbegin(), 1);
+ assert(i == next(c.begin()));
+ assert(c.front() == 0);
+ assert(*next(c.begin()) == 1);
+ assert(distance(c.begin(), c.end()) == 2);
+
+ i = c.insert_after(next(c.cbegin()), 2);
+ assert(i == next(c.begin(), 2));
+ assert(c.front() == 0);
+ assert(*next(c.begin()) == 1);
+ assert(*next(c.begin(), 2) == 2);
+ assert(distance(c.begin(), c.end()) == 3);
+
+ i = c.insert_after(c.cbegin(), 3);
+ assert(i == next(c.begin()));
+ assert(c.front() == 0);
+ assert(*next(c.begin(), 1) == 3);
+ assert(*next(c.begin(), 2) == 1);
+ assert(*next(c.begin(), 3) == 2);
+ assert(distance(c.begin(), c.end()) == 4);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef MoveOnly T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ typedef C::iterator I;
+ C c;
+ I i = c.insert_after(c.cbefore_begin(), 0);
+ assert(i == c.begin());
+ assert(c.front() == 0);
+ assert(c.front() == 0);
+ assert(distance(c.begin(), c.end()) == 1);
+
+ i = c.insert_after(c.cbegin(), 1);
+ assert(i == next(c.begin()));
+ assert(c.front() == 0);
+ assert(*next(c.begin()) == 1);
+ assert(distance(c.begin(), c.end()) == 2);
+
+ i = c.insert_after(next(c.cbegin()), 2);
+ assert(i == next(c.begin(), 2));
+ assert(c.front() == 0);
+ assert(*next(c.begin()) == 1);
+ assert(*next(c.begin(), 2) == 2);
+ assert(distance(c.begin(), c.end()) == 3);
+
+ i = c.insert_after(c.cbegin(), 3);
+ assert(i == next(c.begin()));
+ assert(c.front() == 0);
+ assert(*next(c.begin(), 1) == 3);
+ assert(*next(c.begin(), 2) == 1);
+ assert(*next(c.begin(), 3) == 2);
+ assert(distance(c.begin(), c.end()) == 4);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_size_value.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_size_value.pass.cpp
new file mode 100644
index 000000000000..b2da2ecd3bbd
--- /dev/null
+++ b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_size_value.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// iterator insert_after(const_iterator p, size_type n, const value_type& v);
+
+#include <forward_list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ typedef C::iterator I;
+ C c;
+ I i = c.insert_after(c.cbefore_begin(), 0, 0);
+ assert(i == c.before_begin());
+ assert(distance(c.begin(), c.end()) == 0);
+
+ i = c.insert_after(c.cbefore_begin(), 3, 3);
+ assert(i == next(c.before_begin(), 3));
+ assert(distance(c.begin(), c.end()) == 3);
+ assert(*next(c.begin(), 0) == 3);
+ assert(*next(c.begin(), 1) == 3);
+ assert(*next(c.begin(), 2) == 3);
+
+ i = c.insert_after(c.begin(), 2, 2);
+ assert(i == next(c.begin(), 2));
+ assert(distance(c.begin(), c.end()) == 5);
+ assert(*next(c.begin(), 0) == 3);
+ assert(*next(c.begin(), 1) == 2);
+ assert(*next(c.begin(), 2) == 2);
+ assert(*next(c.begin(), 3) == 3);
+ assert(*next(c.begin(), 4) == 3);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ typedef C::iterator I;
+ C c;
+ I i = c.insert_after(c.cbefore_begin(), 0, 0);
+ assert(i == c.before_begin());
+ assert(distance(c.begin(), c.end()) == 0);
+
+ i = c.insert_after(c.cbefore_begin(), 3, 3);
+ assert(i == next(c.before_begin(), 3));
+ assert(distance(c.begin(), c.end()) == 3);
+ assert(*next(c.begin(), 0) == 3);
+ assert(*next(c.begin(), 1) == 3);
+ assert(*next(c.begin(), 2) == 3);
+
+ i = c.insert_after(c.begin(), 2, 2);
+ assert(i == next(c.begin(), 2));
+ assert(distance(c.begin(), c.end()) == 5);
+ assert(*next(c.begin(), 0) == 3);
+ assert(*next(c.begin(), 1) == 2);
+ assert(*next(c.begin(), 2) == 2);
+ assert(*next(c.begin(), 3) == 3);
+ assert(*next(c.begin(), 4) == 3);
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/forwardlist/forwardlist.modifiers/pop_front.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/pop_front.pass.cpp
new file mode 100644
index 000000000000..7f14e54a2e6f
--- /dev/null
+++ b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/pop_front.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// void pop_front();
+
+#include <forward_list>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ typedef std::forward_list<T> C;
+ C c;
+ c.push_front(1);
+ c.push_front(3);
+ c.pop_front();
+ assert(distance(c.begin(), c.end()) == 1);
+ assert(c.front() == 1);
+ c.pop_front();
+ assert(distance(c.begin(), c.end()) == 0);
+ }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef MoveOnly T;
+ typedef std::forward_list<T> C;
+ C c;
+ c.push_front(1);
+ c.push_front(3);
+ c.pop_front();
+ assert(distance(c.begin(), c.end()) == 1);
+ assert(c.front() == 1);
+ c.pop_front();
+ assert(distance(c.begin(), c.end()) == 0);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ C c;
+ c.push_front(1);
+ c.push_front(3);
+ c.pop_front();
+ assert(distance(c.begin(), c.end()) == 1);
+ assert(c.front() == 1);
+ c.pop_front();
+ assert(distance(c.begin(), c.end()) == 0);
+ }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef MoveOnly T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ C c;
+ c.push_front(1);
+ c.push_front(3);
+ c.pop_front();
+ assert(distance(c.begin(), c.end()) == 1);
+ assert(c.front() == 1);
+ c.pop_front();
+ assert(distance(c.begin(), c.end()) == 0);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif
+}
diff --git a/test/std/containers/sequences/forwardlist/forwardlist.modifiers/push_front_const.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/push_front_const.pass.cpp
new file mode 100644
index 000000000000..85958afc1ce3
--- /dev/null
+++ b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/push_front_const.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// void push_front(const value_type& v);
+
+#include <forward_list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ C c;
+ c.push_front(1);
+ assert(c.front() == 1);
+ assert(distance(c.begin(), c.end()) == 1);
+ c.push_front(3);
+ assert(c.front() == 3);
+ assert(*next(c.begin()) == 1);
+ assert(distance(c.begin(), c.end()) == 2);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ C c;
+ c.push_front(1);
+ assert(c.front() == 1);
+ assert(distance(c.begin(), c.end()) == 1);
+ c.push_front(3);
+ assert(c.front() == 3);
+ assert(*next(c.begin()) == 1);
+ assert(distance(c.begin(), c.end()) == 2);
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/forwardlist/forwardlist.modifiers/push_front_exception_safety.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/push_front_exception_safety.pass.cpp
new file mode 100644
index 000000000000..43c62eb00cbf
--- /dev/null
+++ b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/push_front_exception_safety.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// void push_front(const value_type& x);
+
+#include <forward_list>
+#include <cassert>
+
+// Flag that makes the copy constructor for CMyClass throw an exception
+static bool gCopyConstructorShouldThow = false;
+
+
+class CMyClass {
+ public: CMyClass();
+ public: CMyClass(const CMyClass& iOther);
+ public: ~CMyClass();
+
+ private: int fMagicValue;
+
+ private: static int kStartedConstructionMagicValue;
+ private: static int kFinishedConstructionMagicValue;
+};
+
+// Value for fMagicValue when the constructor has started running, but not yet finished
+int CMyClass::kStartedConstructionMagicValue = 0;
+// Value for fMagicValue when the constructor has finished running
+int CMyClass::kFinishedConstructionMagicValue = 12345;
+
+CMyClass::CMyClass() :
+ fMagicValue(kStartedConstructionMagicValue)
+{
+ // Signal that the constructor has finished running
+ fMagicValue = kFinishedConstructionMagicValue;
+}
+
+CMyClass::CMyClass(const CMyClass& /*iOther*/) :
+ fMagicValue(kStartedConstructionMagicValue)
+{
+ // If requested, throw an exception _before_ setting fMagicValue to kFinishedConstructionMagicValue
+ if (gCopyConstructorShouldThow) {
+ throw std::exception();
+ }
+ // Signal that the constructor has finished running
+ fMagicValue = kFinishedConstructionMagicValue;
+}
+
+CMyClass::~CMyClass() {
+ // Only instances for which the constructor has finished running should be destructed
+ assert(fMagicValue == kFinishedConstructionMagicValue);
+}
+
+int main()
+{
+ CMyClass instance;
+ std::forward_list<CMyClass> vec;
+
+ vec.push_front(instance);
+
+ gCopyConstructorShouldThow = true;
+ try {
+ vec.push_front(instance);
+ }
+ catch (...) {
+ }
+}
diff --git a/test/std/containers/sequences/forwardlist/forwardlist.modifiers/push_front_rv.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/push_front_rv.pass.cpp
new file mode 100644
index 000000000000..d7c9d758aa03
--- /dev/null
+++ b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/push_front_rv.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// void push_front(value_type&& v);
+
+#include <forward_list>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef MoveOnly T;
+ typedef std::forward_list<T> C;
+ C c;
+ c.push_front(1);
+ assert(c.front() == 1);
+ assert(distance(c.begin(), c.end()) == 1);
+ c.push_front(3);
+ assert(c.front() == 3);
+ assert(*next(c.begin()) == 1);
+ assert(distance(c.begin(), c.end()) == 2);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef MoveOnly T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ C c;
+ c.push_front(1);
+ assert(c.front() == 1);
+ assert(distance(c.begin(), c.end()) == 1);
+ c.push_front(3);
+ assert(c.front() == 3);
+ assert(*next(c.begin()) == 1);
+ assert(distance(c.begin(), c.end()) == 2);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/sequences/forwardlist/forwardlist.modifiers/resize_size.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/resize_size.pass.cpp
new file mode 100644
index 000000000000..ef7ef82626dc
--- /dev/null
+++ b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/resize_size.pass.cpp
@@ -0,0 +1,114 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// void resize(size_type n);
+
+#include <forward_list>
+#include <cassert>
+
+#include "DefaultOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef DefaultOnly T;
+ typedef std::forward_list<T> C;
+ C c;
+ c.resize(0);
+ assert(distance(c.begin(), c.end()) == 0);
+ c.resize(10);
+ assert(distance(c.begin(), c.end()) == 10);
+ c.resize(20);
+ assert(distance(c.begin(), c.end()) == 20);
+ c.resize(5);
+ assert(distance(c.begin(), c.end()) == 5);
+ c.resize(0);
+ assert(distance(c.begin(), c.end()) == 0);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ const T t[] = {0, 1, 2, 3, 4};
+ C c(std::begin(t), std::end(t));
+
+ c.resize(3);
+ assert(distance(c.begin(), c.end()) == 3);
+ assert(*next(c.begin(), 0) == 0);
+ assert(*next(c.begin(), 1) == 1);
+ assert(*next(c.begin(), 2) == 2);
+
+ c.resize(6);
+ assert(distance(c.begin(), c.end()) == 6);
+ assert(*next(c.begin(), 0) == 0);
+ assert(*next(c.begin(), 1) == 1);
+ assert(*next(c.begin(), 2) == 2);
+ assert(*next(c.begin(), 3) == 0);
+ assert(*next(c.begin(), 4) == 0);
+ assert(*next(c.begin(), 5) == 0);
+
+ c.resize(6);
+ assert(distance(c.begin(), c.end()) == 6);
+ assert(*next(c.begin(), 0) == 0);
+ assert(*next(c.begin(), 1) == 1);
+ assert(*next(c.begin(), 2) == 2);
+ assert(*next(c.begin(), 3) == 0);
+ assert(*next(c.begin(), 4) == 0);
+ assert(*next(c.begin(), 5) == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef DefaultOnly T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ C c;
+ c.resize(0);
+ assert(distance(c.begin(), c.end()) == 0);
+ c.resize(10);
+ assert(distance(c.begin(), c.end()) == 10);
+ c.resize(20);
+ assert(distance(c.begin(), c.end()) == 20);
+ c.resize(5);
+ assert(distance(c.begin(), c.end()) == 5);
+ c.resize(0);
+ assert(distance(c.begin(), c.end()) == 0);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ const T t[] = {0, 1, 2, 3, 4};
+ C c(std::begin(t), std::end(t));
+
+ c.resize(3);
+ assert(distance(c.begin(), c.end()) == 3);
+ assert(*next(c.begin(), 0) == 0);
+ assert(*next(c.begin(), 1) == 1);
+ assert(*next(c.begin(), 2) == 2);
+
+ c.resize(6);
+ assert(distance(c.begin(), c.end()) == 6);
+ assert(*next(c.begin(), 0) == 0);
+ assert(*next(c.begin(), 1) == 1);
+ assert(*next(c.begin(), 2) == 2);
+ assert(*next(c.begin(), 3) == 0);
+ assert(*next(c.begin(), 4) == 0);
+ assert(*next(c.begin(), 5) == 0);
+
+ c.resize(6);
+ assert(distance(c.begin(), c.end()) == 6);
+ assert(*next(c.begin(), 0) == 0);
+ assert(*next(c.begin(), 1) == 1);
+ assert(*next(c.begin(), 2) == 2);
+ assert(*next(c.begin(), 3) == 0);
+ assert(*next(c.begin(), 4) == 0);
+ assert(*next(c.begin(), 5) == 0);
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/forwardlist/forwardlist.modifiers/resize_size_value.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/resize_size_value.pass.cpp
new file mode 100644
index 000000000000..d4bd6b4e0111
--- /dev/null
+++ b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/resize_size_value.pass.cpp
@@ -0,0 +1,84 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// void resize(size_type n, const value_type& v);
+
+#include <forward_list>
+#include <cassert>
+
+#include "DefaultOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ const T t[] = {0, 1, 2, 3, 4};
+ C c(std::begin(t), std::end(t));
+
+ c.resize(3, 10);
+ assert(distance(c.begin(), c.end()) == 3);
+ assert(*next(c.begin(), 0) == 0);
+ assert(*next(c.begin(), 1) == 1);
+ assert(*next(c.begin(), 2) == 2);
+
+ c.resize(6, 10);
+ assert(distance(c.begin(), c.end()) == 6);
+ assert(*next(c.begin(), 0) == 0);
+ assert(*next(c.begin(), 1) == 1);
+ assert(*next(c.begin(), 2) == 2);
+ assert(*next(c.begin(), 3) == 10);
+ assert(*next(c.begin(), 4) == 10);
+ assert(*next(c.begin(), 5) == 10);
+
+ c.resize(6, 12);
+ assert(distance(c.begin(), c.end()) == 6);
+ assert(*next(c.begin(), 0) == 0);
+ assert(*next(c.begin(), 1) == 1);
+ assert(*next(c.begin(), 2) == 2);
+ assert(*next(c.begin(), 3) == 10);
+ assert(*next(c.begin(), 4) == 10);
+ assert(*next(c.begin(), 5) == 10);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ const T t[] = {0, 1, 2, 3, 4};
+ C c(std::begin(t), std::end(t));
+
+ c.resize(3, 10);
+ assert(distance(c.begin(), c.end()) == 3);
+ assert(*next(c.begin(), 0) == 0);
+ assert(*next(c.begin(), 1) == 1);
+ assert(*next(c.begin(), 2) == 2);
+
+ c.resize(6, 10);
+ assert(distance(c.begin(), c.end()) == 6);
+ assert(*next(c.begin(), 0) == 0);
+ assert(*next(c.begin(), 1) == 1);
+ assert(*next(c.begin(), 2) == 2);
+ assert(*next(c.begin(), 3) == 10);
+ assert(*next(c.begin(), 4) == 10);
+ assert(*next(c.begin(), 5) == 10);
+
+ c.resize(6, 12);
+ assert(distance(c.begin(), c.end()) == 6);
+ assert(*next(c.begin(), 0) == 0);
+ assert(*next(c.begin(), 1) == 1);
+ assert(*next(c.begin(), 2) == 2);
+ assert(*next(c.begin(), 3) == 10);
+ assert(*next(c.begin(), 4) == 10);
+ assert(*next(c.begin(), 5) == 10);
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/forwardlist/forwardlist.ops/merge.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.ops/merge.pass.cpp
new file mode 100644
index 000000000000..3b6f853c84cd
--- /dev/null
+++ b/test/std/containers/sequences/forwardlist/forwardlist.ops/merge.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// void merge(forward_list&& x);
+
+#include <forward_list>
+#include <iterator>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ const T t1[] = {3, 5, 6, 7, 12, 13};
+ const T t2[] = {0, 1, 2, 4, 8, 9, 10, 11, 14, 15};
+ const T t3[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+ C c1(std::begin(t1), std::end(t1));
+ C c2(std::begin(t2), std::end(t2));
+ c1.merge(c2);
+ C c3(std::begin(t3), std::end(t3));
+ assert(c1 == c3);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ const T t1[] = {3, 5, 6, 7, 12, 13};
+ const T t2[] = {0, 1, 2, 4, 8, 9, 10, 11, 14, 15};
+ const T t3[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+ C c1(std::begin(t1), std::end(t1));
+ C c2(std::begin(t2), std::end(t2));
+ c1.merge(c2);
+ C c3(std::begin(t3), std::end(t3));
+ assert(c1 == c3);
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/forwardlist/forwardlist.ops/merge_pred.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.ops/merge_pred.pass.cpp
new file mode 100644
index 000000000000..7e873bdddd09
--- /dev/null
+++ b/test/std/containers/sequences/forwardlist/forwardlist.ops/merge_pred.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// template <class Compare> void merge(forward_list&& x, Compare comp);
+
+#include <forward_list>
+#include <iterator>
+#include <functional>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ const T t1[] = {13, 12, 7, 6, 5, 3};
+ const T t2[] = {15, 14, 11, 10, 9, 8, 4, 2, 1, 0};
+ const T t3[] = {15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0};
+ C c1(std::begin(t1), std::end(t1));
+ C c2(std::begin(t2), std::end(t2));
+ c1.merge(c2, std::greater<T>());
+ C c3(std::begin(t3), std::end(t3));
+ assert(c1 == c3);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ const T t1[] = {13, 12, 7, 6, 5, 3};
+ const T t2[] = {15, 14, 11, 10, 9, 8, 4, 2, 1, 0};
+ const T t3[] = {15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0};
+ C c1(std::begin(t1), std::end(t1));
+ C c2(std::begin(t2), std::end(t2));
+ c1.merge(c2, std::greater<T>());
+ C c3(std::begin(t3), std::end(t3));
+ assert(c1 == c3);
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/forwardlist/forwardlist.ops/remove.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.ops/remove.pass.cpp
new file mode 100644
index 000000000000..18d4cae8cc61
--- /dev/null
+++ b/test/std/containers/sequences/forwardlist/forwardlist.ops/remove.pass.cpp
@@ -0,0 +1,155 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// void remove(const value_type& v);
+
+#include <forward_list>
+#include <iterator>
+#include <cassert>
+
+#include "min_allocator.h"
+
+struct S {
+ S(int i) : i_(new int(i)) {}
+ S(const S &rhs) : i_(new int(*rhs.i_)) {}
+ S& operator = (const S &rhs) { *i_ = *rhs.i_; return *this; }
+ ~S () { delete i_; i_ = NULL; }
+ bool operator == (const S &rhs) const { return *i_ == *rhs.i_; }
+ int get () const { return *i_; }
+ int *i_;
+ };
+
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ const T t1[] = {0, 5, 5, 0, 0, 0, 5};
+ const T t2[] = {5, 5, 5};
+ C c1(std::begin(t1), std::end(t1));
+ C c2(std::begin(t2), std::end(t2));
+ c1.remove(0);
+ assert(c1 == c2);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ const T t1[] = {0, 0, 0, 0};
+ C c1(std::begin(t1), std::end(t1));
+ C c2;
+ c1.remove(0);
+ assert(c1 == c2);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ const T t1[] = {5, 5, 5};
+ const T t2[] = {5, 5, 5};
+ C c1(std::begin(t1), std::end(t1));
+ C c2(std::begin(t2), std::end(t2));
+ c1.remove(0);
+ assert(c1 == c2);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ C c1;
+ C c2;
+ c1.remove(0);
+ assert(c1 == c2);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ const T t1[] = {5, 5, 5, 0};
+ const T t2[] = {5, 5, 5};
+ C c1(std::begin(t1), std::end(t1));
+ C c2(std::begin(t2), std::end(t2));
+ c1.remove(0);
+ assert(c1 == c2);
+ }
+ { // LWG issue #526
+ typedef int T;
+ typedef std::forward_list<T> C;
+ int t1[] = {1, 2, 1, 3, 5, 8, 11};
+ int t2[] = { 2, 3, 5, 8, 11};
+ C c1(std::begin(t1), std::end(t1));
+ C c2(std::begin(t2), std::end(t2));
+ c1.remove(c1.front());
+ assert(c1 == c2);
+ }
+ {
+ typedef S T;
+ typedef std::forward_list<T> C;
+ int t1[] = {1, 2, 1, 3, 5, 8, 11, 1};
+ int t2[] = { 2, 3, 5, 8, 11 };
+ C c;
+ for(int *ip = std::end(t1); ip != std::begin(t1);)
+ c.push_front(S(*--ip));
+ c.remove(c.front());
+ C::const_iterator it = c.begin();
+ for(int *ip = std::begin(t2); ip != std::end(t2); ++ip, ++it) {
+ assert ( it != c.end());
+ assert ( *ip == it->get());
+ }
+ assert ( it == c.end ());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ const T t1[] = {0, 5, 5, 0, 0, 0, 5};
+ const T t2[] = {5, 5, 5};
+ C c1(std::begin(t1), std::end(t1));
+ C c2(std::begin(t2), std::end(t2));
+ c1.remove(0);
+ assert(c1 == c2);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ const T t1[] = {0, 0, 0, 0};
+ C c1(std::begin(t1), std::end(t1));
+ C c2;
+ c1.remove(0);
+ assert(c1 == c2);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ const T t1[] = {5, 5, 5};
+ const T t2[] = {5, 5, 5};
+ C c1(std::begin(t1), std::end(t1));
+ C c2(std::begin(t2), std::end(t2));
+ c1.remove(0);
+ assert(c1 == c2);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ C c1;
+ C c2;
+ c1.remove(0);
+ assert(c1 == c2);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ const T t1[] = {5, 5, 5, 0};
+ const T t2[] = {5, 5, 5};
+ C c1(std::begin(t1), std::end(t1));
+ C c2(std::begin(t2), std::end(t2));
+ c1.remove(0);
+ assert(c1 == c2);
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/forwardlist/forwardlist.ops/remove_if.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.ops/remove_if.pass.cpp
new file mode 100644
index 000000000000..ed408fbd685c
--- /dev/null
+++ b/test/std/containers/sequences/forwardlist/forwardlist.ops/remove_if.pass.cpp
@@ -0,0 +1,155 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// template <class Predicate> void remove_if(Predicate pred);
+
+#include <forward_list>
+#include <iterator>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "counting_predicates.hpp"
+
+
+bool g(int i)
+{
+ return i < 3;
+}
+
+int main()
+{
+ {
+ typedef int T;
+ typedef unary_counting_predicate<bool(*)(T), T> Predicate;
+ typedef std::forward_list<T> C;
+ const T t1[] = {0, 5, 5, 0, 0, 0, 5};
+ const T t2[] = {5, 5, 5};
+ C c1(std::begin(t1), std::end(t1));
+ C c2(std::begin(t2), std::end(t2));
+ Predicate cp(g);
+ c1.remove_if(std::ref(cp));
+ assert(c1 == c2);
+ assert(cp.count() == std::distance(std::begin(t1), std::end(t1)));
+ }
+ {
+ typedef int T;
+ typedef unary_counting_predicate<bool(*)(T), T> Predicate;
+ typedef std::forward_list<T> C;
+ const T t1[] = {0, 0, 0, 0};
+ C c1(std::begin(t1), std::end(t1));
+ C c2;
+ Predicate cp(g);
+ c1.remove_if(std::ref(cp));
+ assert(c1 == c2);
+ assert(cp.count() == std::distance(std::begin(t1), std::end(t1)));
+ }
+ {
+ typedef int T;
+ typedef unary_counting_predicate<bool(*)(T), T> Predicate;
+ typedef std::forward_list<T> C;
+ const T t1[] = {5, 5, 5};
+ const T t2[] = {5, 5, 5};
+ C c1(std::begin(t1), std::end(t1));
+ C c2(std::begin(t2), std::end(t2));
+ Predicate cp(g);
+ c1.remove_if(std::ref(cp));
+ assert(c1 == c2);
+ assert(cp.count() == std::distance(std::begin(t1), std::end(t1)));
+ }
+ {
+ typedef int T;
+ typedef unary_counting_predicate<bool(*)(T), T> Predicate;
+ typedef std::forward_list<T> C;
+ C c1;
+ C c2;
+ Predicate cp(g);
+ c1.remove_if(std::ref(cp));
+ assert(c1 == c2);
+ assert(cp.count() == 0);
+ }
+ {
+ typedef int T;
+ typedef unary_counting_predicate<bool(*)(T), T> Predicate;
+ typedef std::forward_list<T> C;
+ const T t1[] = {5, 5, 5, 0};
+ const T t2[] = {5, 5, 5};
+ C c1(std::begin(t1), std::end(t1));
+ C c2(std::begin(t2), std::end(t2));
+ Predicate cp(g);
+ c1.remove_if(std::ref(cp));
+ assert(c1 == c2);
+ assert(cp.count() == std::distance(std::begin(t1), std::end(t1)));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef unary_counting_predicate<bool(*)(T), T> Predicate;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ const T t1[] = {0, 5, 5, 0, 0, 0, 5};
+ const T t2[] = {5, 5, 5};
+ C c1(std::begin(t1), std::end(t1));
+ C c2(std::begin(t2), std::end(t2));
+ Predicate cp(g);
+ c1.remove_if(std::ref(cp));
+ assert(c1 == c2);
+ assert(cp.count() == std::distance(std::begin(t1), std::end(t1)));
+ }
+ {
+ typedef int T;
+ typedef unary_counting_predicate<bool(*)(T), T> Predicate;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ const T t1[] = {0, 0, 0, 0};
+ C c1(std::begin(t1), std::end(t1));
+ C c2;
+ Predicate cp(g);
+ c1.remove_if(std::ref(cp));
+ assert(c1 == c2);
+ assert(cp.count() == std::distance(std::begin(t1), std::end(t1)));
+ }
+ {
+ typedef int T;
+ typedef unary_counting_predicate<bool(*)(T), T> Predicate;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ const T t1[] = {5, 5, 5};
+ const T t2[] = {5, 5, 5};
+ C c1(std::begin(t1), std::end(t1));
+ C c2(std::begin(t2), std::end(t2));
+ Predicate cp(g);
+ c1.remove_if(std::ref(cp));
+ assert(c1 == c2);
+ assert(cp.count() == std::distance(std::begin(t1), std::end(t1)));
+ }
+ {
+ typedef int T;
+ typedef unary_counting_predicate<bool(*)(T), T> Predicate;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ C c1;
+ C c2;
+ Predicate cp(g);
+ c1.remove_if(std::ref(cp));
+ assert(c1 == c2);
+ assert(cp.count() == 0);
+ }
+ {
+ typedef int T;
+ typedef unary_counting_predicate<bool(*)(T), T> Predicate;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ const T t1[] = {5, 5, 5, 0};
+ const T t2[] = {5, 5, 5};
+ C c1(std::begin(t1), std::end(t1));
+ C c2(std::begin(t2), std::end(t2));
+ Predicate cp(g);
+ c1.remove_if(std::ref(cp));
+ assert(c1 == c2);
+ assert(cp.count() == std::distance(std::begin(t1), std::end(t1)));
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/forwardlist/forwardlist.ops/reverse.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.ops/reverse.pass.cpp
new file mode 100644
index 000000000000..9bf0d03a8855
--- /dev/null
+++ b/test/std/containers/sequences/forwardlist/forwardlist.ops/reverse.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// void reverse();
+
+#include <forward_list>
+#include <iterator>
+#include <algorithm>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class C>
+void test(int N)
+{
+ C c;
+ for (int i = 0; i < N; ++i)
+ c.push_front(i);
+ c.reverse();
+ assert(distance(c.begin(), c.end()) == N);
+ typename C::const_iterator j = c.begin();
+ for (int i = 0; i < N; ++i, ++j)
+ assert(*j == i);
+}
+
+int main()
+{
+ for (int i = 0; i < 10; ++i)
+ test<std::forward_list<int> >(i);
+#if __cplusplus >= 201103L
+ for (int i = 0; i < 10; ++i)
+ test<std::forward_list<int, min_allocator<int>> >(i);
+#endif
+}
diff --git a/test/std/containers/sequences/forwardlist/forwardlist.ops/sort.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.ops/sort.pass.cpp
new file mode 100644
index 000000000000..06e40c595ecb
--- /dev/null
+++ b/test/std/containers/sequences/forwardlist/forwardlist.ops/sort.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// void sort();
+
+#include <forward_list>
+#include <iterator>
+#include <algorithm>
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class C>
+void test(int N)
+{
+ typedef typename C::value_type T;
+ typedef std::vector<T> V;
+ V v;
+ for (int i = 0; i < N; ++i)
+ v.push_back(i);
+ std::random_shuffle(v.begin(), v.end());
+ C c(v.begin(), v.end());
+ c.sort();
+ assert(distance(c.begin(), c.end()) == N);
+ typename C::const_iterator j = c.begin();
+ for (int i = 0; i < N; ++i, ++j)
+ assert(*j == i);
+}
+
+int main()
+{
+ for (int i = 0; i < 40; ++i)
+ test<std::forward_list<int> >(i);
+#if __cplusplus >= 201103L
+ for (int i = 0; i < 40; ++i)
+ test<std::forward_list<int, min_allocator<int>> >(i);
+#endif
+}
diff --git a/test/std/containers/sequences/forwardlist/forwardlist.ops/sort_pred.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.ops/sort_pred.pass.cpp
new file mode 100644
index 000000000000..8b6ca39b2aab
--- /dev/null
+++ b/test/std/containers/sequences/forwardlist/forwardlist.ops/sort_pred.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// template <class Compare> void sort(Compare comp);
+
+#include <forward_list>
+#include <iterator>
+#include <algorithm>
+#include <vector>
+#include <functional>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class C>
+void test(int N)
+{
+ typedef typename C::value_type T;
+ typedef std::vector<T> V;
+ V v;
+ for (int i = 0; i < N; ++i)
+ v.push_back(i);
+ std::random_shuffle(v.begin(), v.end());
+ C c(v.begin(), v.end());
+ c.sort(std::greater<T>());
+ assert(distance(c.begin(), c.end()) == N);
+ typename C::const_iterator j = c.begin();
+ for (int i = 0; i < N; ++i, ++j)
+ assert(*j == N-1-i);
+}
+
+int main()
+{
+ for (int i = 0; i < 40; ++i)
+ test<std::forward_list<int> >(i);
+#if __cplusplus >= 201103L
+ for (int i = 0; i < 40; ++i)
+ test<std::forward_list<int, min_allocator<int>> >(i);
+#endif
+}
diff --git a/test/std/containers/sequences/forwardlist/forwardlist.ops/splice_after_flist.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.ops/splice_after_flist.pass.cpp
new file mode 100644
index 000000000000..51da651970cd
--- /dev/null
+++ b/test/std/containers/sequences/forwardlist/forwardlist.ops/splice_after_flist.pass.cpp
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// void splice_after(const_iterator p, forward_list&& x);
+
+#include <forward_list>
+#include <cassert>
+#include <iterator>
+
+#include "min_allocator.h"
+
+typedef int T;
+const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7};
+const T t2[] = {10, 11, 12, 13, 14, 15};
+const int size_t1 = std::end(t1) - std::begin(t1);
+const int size_t2 = std::end(t2) - std::begin(t2);
+
+template <class C>
+void
+testd(const C& c, int p, int l)
+{
+ typename C::const_iterator i = c.begin();
+ int n1 = 0;
+ for (; n1 < p; ++n1, ++i)
+ assert(*i == t1[n1]);
+ for (int n2 = 0; n2 < l; ++n2, ++i)
+ assert(*i == t2[n2]);
+ for (; n1 < size_t1; ++n1, ++i)
+ assert(*i == t1[n1]);
+ assert(distance(c.begin(), c.end()) == size_t1 + l);
+}
+
+int main()
+{
+ {
+ // splicing different containers
+ typedef std::forward_list<T> C;
+ for (int l = 0; l <= size_t2; ++l)
+ {
+ for (int p = 0; p <= size_t1; ++p)
+ {
+ C c1(std::begin(t1), std::end(t1));
+ C c2(t2, t2+l);
+
+ c1.splice_after(next(c1.cbefore_begin(), p), std::move(c2));
+ testd(c1, p, l);
+ }
+ }
+ }
+#if __cplusplus >= 201103L
+ {
+ // splicing different containers
+ typedef std::forward_list<T, min_allocator<T>> C;
+ for (int l = 0; l <= size_t2; ++l)
+ {
+ for (int p = 0; p <= size_t1; ++p)
+ {
+ C c1(std::begin(t1), std::end(t1));
+ C c2(t2, t2+l);
+
+ c1.splice_after(next(c1.cbefore_begin(), p), std::move(c2));
+ testd(c1, p, l);
+ }
+ }
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/forwardlist/forwardlist.ops/splice_after_one.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.ops/splice_after_one.pass.cpp
new file mode 100644
index 000000000000..296ffcd6955d
--- /dev/null
+++ b/test/std/containers/sequences/forwardlist/forwardlist.ops/splice_after_one.pass.cpp
@@ -0,0 +1,140 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// void splice_after(const_iterator p, forward_list&& x, const_iterator i);
+
+#include <forward_list>
+#include <cassert>
+#include <iterator>
+
+#include "min_allocator.h"
+
+typedef int T;
+const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7};
+const T t2[] = {10, 11, 12};
+const int size_t1 = std::end(t1) - std::begin(t1);
+const int size_t2 = std::end(t2) - std::begin(t2);
+
+template <class C>
+void
+testd(const C& c, int p, int f)
+{
+ typename C::const_iterator i = c.begin();
+ int n1 = 0;
+ for (; n1 < p; ++n1, ++i)
+ assert(*i == t1[n1]);
+ for (int n2 = f; n2 < f+1; ++n2, ++i)
+ assert(*i == t2[n2]);
+ for (; n1 < size_t1; ++n1, ++i)
+ assert(*i == t1[n1]);
+ assert(distance(c.begin(), c.end()) == size_t1 + 1);
+}
+
+template <class C>
+void
+tests(const C& c, int p, int f)
+{
+ typename C::const_iterator i = c.begin();
+ int n = 0;
+ int d = 1;
+ if (p == f || p == f+1)
+ {
+ for (n = 0; n < size_t1; ++n, ++i)
+ assert(*i == t1[n]);
+ }
+ else if (p < f)
+ {
+ for (n = 0; n < p; ++n, ++i)
+ assert(*i == t1[n]);
+ for (n = f; n < f+1; ++n, ++i)
+ assert(*i == t1[n]);
+ for (n = p; n < f; ++n, ++i)
+ assert(*i == t1[n]);
+ for (n = f+1; n < size_t1; ++n, ++i)
+ assert(*i == t1[n]);
+ }
+ else // p > f+1
+ {
+ for (n = 0; n < f; ++n, ++i)
+ assert(*i == t1[n]);
+ for (n = f+1; n < p; ++n, ++i)
+ assert(*i == t1[n]);
+ for (n = f; n < f+1; ++n, ++i)
+ assert(*i == t1[n]);
+ for (n = p; n < size_t1; ++n, ++i)
+ assert(*i == t1[n]);
+ }
+ assert(distance(c.begin(), c.end()) == size_t1);
+}
+
+int main()
+{
+ {
+ // splicing different containers
+ typedef std::forward_list<T> C;
+ for (int f = 0; f <= size_t2-1; ++f)
+ {
+ for (int p = 0; p <= size_t1; ++p)
+ {
+ C c1(std::begin(t1), std::end(t1));
+ C c2(std::begin(t2), std::end(t2));
+
+ c1.splice_after(next(c1.cbefore_begin(), p), std::move(c2),
+ next(c2.cbefore_begin(), f));
+ testd(c1, p, f);
+ }
+ }
+
+ // splicing within same container
+ for (int f = 0; f <= size_t1-1; ++f)
+ {
+ for (int p = 0; p <= size_t1; ++p)
+ {
+ C c1(std::begin(t1), std::end(t1));
+
+ c1.splice_after(next(c1.cbefore_begin(), p), std::move(c1),
+ next(c1.cbefore_begin(), f));
+ tests(c1, p, f);
+ }
+ }
+ }
+#if __cplusplus >= 201103L
+ {
+ // splicing different containers
+ typedef std::forward_list<T, min_allocator<T>> C;
+ for (int f = 0; f <= size_t2-1; ++f)
+ {
+ for (int p = 0; p <= size_t1; ++p)
+ {
+ C c1(std::begin(t1), std::end(t1));
+ C c2(std::begin(t2), std::end(t2));
+
+ c1.splice_after(next(c1.cbefore_begin(), p), std::move(c2),
+ next(c2.cbefore_begin(), f));
+ testd(c1, p, f);
+ }
+ }
+
+ // splicing within same container
+ for (int f = 0; f <= size_t1-1; ++f)
+ {
+ for (int p = 0; p <= size_t1; ++p)
+ {
+ C c1(std::begin(t1), std::end(t1));
+
+ c1.splice_after(next(c1.cbefore_begin(), p), std::move(c1),
+ next(c1.cbefore_begin(), f));
+ tests(c1, p, f);
+ }
+ }
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/forwardlist/forwardlist.ops/splice_after_range.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.ops/splice_after_range.pass.cpp
new file mode 100644
index 000000000000..90a159959632
--- /dev/null
+++ b/test/std/containers/sequences/forwardlist/forwardlist.ops/splice_after_range.pass.cpp
@@ -0,0 +1,169 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// void splice_after(const_iterator p, forward_list&& x,
+// const_iterator first, const_iterator last);
+
+#include <forward_list>
+#include <cassert>
+#include <iterator>
+
+#include "min_allocator.h"
+
+typedef int T;
+const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7};
+const T t2[] = {10, 11, 12, 13, 14, 15};
+const int size_t1 = std::end(t1) - std::begin(t1);
+const int size_t2 = std::end(t2) - std::begin(t2);
+
+template <class C>
+void
+testd(const C& c, int p, int f, int l)
+{
+ typename C::const_iterator i = c.begin();
+ int n1 = 0;
+ for (; n1 < p; ++n1, ++i)
+ assert(*i == t1[n1]);
+ for (int n2 = f; n2 < l-1; ++n2, ++i)
+ assert(*i == t2[n2]);
+ for (; n1 < size_t1; ++n1, ++i)
+ assert(*i == t1[n1]);
+ assert(distance(c.begin(), c.end()) == size_t1 + (l > f+1 ? l-1-f : 0));
+}
+
+template <class C>
+void
+tests(const C& c, int p, int f, int l)
+{
+ typename C::const_iterator i = c.begin();
+ int n = 0;
+ int d = l > f+1 ? l-1-f : 0;
+ if (d == 0 || p == f)
+ {
+ for (n = 0; n < size_t1; ++n, ++i)
+ assert(*i == t1[n]);
+ }
+ else if (p < f)
+ {
+ for (n = 0; n < p; ++n, ++i)
+ assert(*i == t1[n]);
+ for (n = f; n < l-1; ++n, ++i)
+ assert(*i == t1[n]);
+ for (n = p; n < f; ++n, ++i)
+ assert(*i == t1[n]);
+ for (n = l-1; n < size_t1; ++n, ++i)
+ assert(*i == t1[n]);
+ }
+ else // p > f
+ {
+ for (n = 0; n < f; ++n, ++i)
+ assert(*i == t1[n]);
+ for (n = l-1; n < p; ++n, ++i)
+ assert(*i == t1[n]);
+ for (n = f; n < l-1; ++n, ++i)
+ assert(*i == t1[n]);
+ for (n = p; n < size_t1; ++n, ++i)
+ assert(*i == t1[n]);
+ }
+ assert(distance(c.begin(), c.end()) == size_t1);
+}
+
+int main()
+{
+ {
+ // splicing different containers
+ typedef std::forward_list<T> C;
+ for (int f = 0; f <= size_t2+1; ++f)
+ {
+ for (int l = f; l <= size_t2+1; ++l)
+ {
+ for (int p = 0; p <= size_t1; ++p)
+ {
+ C c1(std::begin(t1), std::end(t1));
+ C c2(std::begin(t2), std::end(t2));
+
+ c1.splice_after(next(c1.cbefore_begin(), p), std::move(c2),
+ next(c2.cbefore_begin(), f), next(c2.cbefore_begin(), l));
+ testd(c1, p, f, l);
+ }
+ }
+ }
+
+ // splicing within same container
+ for (int f = 0; f <= size_t1+1; ++f)
+ {
+ for (int l = f; l <= size_t1; ++l)
+ {
+ for (int p = 0; p <= f; ++p)
+ {
+ C c1(std::begin(t1), std::end(t1));
+
+ c1.splice_after(next(c1.cbefore_begin(), p), std::move(c1),
+ next(c1.cbefore_begin(), f), next(c1.cbefore_begin(), l));
+ tests(c1, p, f, l);
+ }
+ for (int p = l; p <= size_t1; ++p)
+ {
+ C c1(std::begin(t1), std::end(t1));
+
+ c1.splice_after(next(c1.cbefore_begin(), p), std::move(c1),
+ next(c1.cbefore_begin(), f), next(c1.cbefore_begin(), l));
+ tests(c1, p, f, l);
+ }
+ }
+ }
+ }
+#if __cplusplus >= 201103L
+ {
+ // splicing different containers
+ typedef std::forward_list<T, min_allocator<T>> C;
+ for (int f = 0; f <= size_t2+1; ++f)
+ {
+ for (int l = f; l <= size_t2+1; ++l)
+ {
+ for (int p = 0; p <= size_t1; ++p)
+ {
+ C c1(std::begin(t1), std::end(t1));
+ C c2(std::begin(t2), std::end(t2));
+
+ c1.splice_after(next(c1.cbefore_begin(), p), std::move(c2),
+ next(c2.cbefore_begin(), f), next(c2.cbefore_begin(), l));
+ testd(c1, p, f, l);
+ }
+ }
+ }
+
+ // splicing within same container
+ for (int f = 0; f <= size_t1+1; ++f)
+ {
+ for (int l = f; l <= size_t1; ++l)
+ {
+ for (int p = 0; p <= f; ++p)
+ {
+ C c1(std::begin(t1), std::end(t1));
+
+ c1.splice_after(next(c1.cbefore_begin(), p), std::move(c1),
+ next(c1.cbefore_begin(), f), next(c1.cbefore_begin(), l));
+ tests(c1, p, f, l);
+ }
+ for (int p = l; p <= size_t1; ++p)
+ {
+ C c1(std::begin(t1), std::end(t1));
+
+ c1.splice_after(next(c1.cbefore_begin(), p), std::move(c1),
+ next(c1.cbefore_begin(), f), next(c1.cbefore_begin(), l));
+ tests(c1, p, f, l);
+ }
+ }
+ }
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/forwardlist/forwardlist.ops/unique.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.ops/unique.pass.cpp
new file mode 100644
index 000000000000..25db6e64b8a9
--- /dev/null
+++ b/test/std/containers/sequences/forwardlist/forwardlist.ops/unique.pass.cpp
@@ -0,0 +1,120 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// void unique();
+
+#include <forward_list>
+#include <iterator>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ const T t1[] = {0, 5, 5, 0, 0, 0, 5};
+ const T t2[] = {0, 5, 0, 5};
+ C c1(std::begin(t1), std::end(t1));
+ C c2(std::begin(t2), std::end(t2));
+ c1.unique();
+ assert(c1 == c2);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ const T t1[] = {0, 0, 0, 0};
+ const T t2[] = {0};
+ C c1(std::begin(t1), std::end(t1));
+ C c2(std::begin(t2), std::end(t2));
+ c1.unique();
+ assert(c1 == c2);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ const T t1[] = {5, 5, 5};
+ const T t2[] = {5};
+ C c1(std::begin(t1), std::end(t1));
+ C c2(std::begin(t2), std::end(t2));
+ c1.unique();
+ assert(c1 == c2);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ C c1;
+ C c2;
+ c1.unique();
+ assert(c1 == c2);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ const T t1[] = {5, 5, 5, 0};
+ const T t2[] = {5, 0};
+ C c1(std::begin(t1), std::end(t1));
+ C c2(std::begin(t2), std::end(t2));
+ c1.unique();
+ assert(c1 == c2);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ const T t1[] = {0, 5, 5, 0, 0, 0, 5};
+ const T t2[] = {0, 5, 0, 5};
+ C c1(std::begin(t1), std::end(t1));
+ C c2(std::begin(t2), std::end(t2));
+ c1.unique();
+ assert(c1 == c2);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ const T t1[] = {0, 0, 0, 0};
+ const T t2[] = {0};
+ C c1(std::begin(t1), std::end(t1));
+ C c2(std::begin(t2), std::end(t2));
+ c1.unique();
+ assert(c1 == c2);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ const T t1[] = {5, 5, 5};
+ const T t2[] = {5};
+ C c1(std::begin(t1), std::end(t1));
+ C c2(std::begin(t2), std::end(t2));
+ c1.unique();
+ assert(c1 == c2);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ C c1;
+ C c2;
+ c1.unique();
+ assert(c1 == c2);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ const T t1[] = {5, 5, 5, 0};
+ const T t2[] = {5, 0};
+ C c1(std::begin(t1), std::end(t1));
+ C c2(std::begin(t2), std::end(t2));
+ c1.unique();
+ assert(c1 == c2);
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/forwardlist/forwardlist.ops/unique_pred.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.ops/unique_pred.pass.cpp
new file mode 100644
index 000000000000..b7dce20b7092
--- /dev/null
+++ b/test/std/containers/sequences/forwardlist/forwardlist.ops/unique_pred.pass.cpp
@@ -0,0 +1,125 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// template <class BinaryPredicate> void unique(BinaryPredicate binary_pred);
+
+#include <forward_list>
+#include <iterator>
+#include <cassert>
+
+#include "min_allocator.h"
+
+bool g(int x, int y)
+{
+ return x == y;
+}
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ const T t1[] = {0, 5, 5, 0, 0, 0, 5};
+ const T t2[] = {0, 5, 0, 5};
+ C c1(std::begin(t1), std::end(t1));
+ C c2(std::begin(t2), std::end(t2));
+ c1.unique(g);
+ assert(c1 == c2);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ const T t1[] = {0, 0, 0, 0};
+ const T t2[] = {0};
+ C c1(std::begin(t1), std::end(t1));
+ C c2(std::begin(t2), std::end(t2));
+ c1.unique(g);
+ assert(c1 == c2);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ const T t1[] = {5, 5, 5};
+ const T t2[] = {5};
+ C c1(std::begin(t1), std::end(t1));
+ C c2(std::begin(t2), std::end(t2));
+ c1.unique(g);
+ assert(c1 == c2);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ C c1;
+ C c2;
+ c1.unique(g);
+ assert(c1 == c2);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ const T t1[] = {5, 5, 5, 0};
+ const T t2[] = {5, 0};
+ C c1(std::begin(t1), std::end(t1));
+ C c2(std::begin(t2), std::end(t2));
+ c1.unique(g);
+ assert(c1 == c2);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ const T t1[] = {0, 5, 5, 0, 0, 0, 5};
+ const T t2[] = {0, 5, 0, 5};
+ C c1(std::begin(t1), std::end(t1));
+ C c2(std::begin(t2), std::end(t2));
+ c1.unique(g);
+ assert(c1 == c2);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ const T t1[] = {0, 0, 0, 0};
+ const T t2[] = {0};
+ C c1(std::begin(t1), std::end(t1));
+ C c2(std::begin(t2), std::end(t2));
+ c1.unique(g);
+ assert(c1 == c2);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ const T t1[] = {5, 5, 5};
+ const T t2[] = {5};
+ C c1(std::begin(t1), std::end(t1));
+ C c2(std::begin(t2), std::end(t2));
+ c1.unique(g);
+ assert(c1 == c2);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ C c1;
+ C c2;
+ c1.unique(g);
+ assert(c1 == c2);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ const T t1[] = {5, 5, 5, 0};
+ const T t2[] = {5, 0};
+ C c1(std::begin(t1), std::end(t1));
+ C c2(std::begin(t2), std::end(t2));
+ c1.unique(g);
+ assert(c1 == c2);
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/forwardlist/forwardlist.spec/equal.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.spec/equal.pass.cpp
new file mode 100644
index 000000000000..ca673b583683
--- /dev/null
+++ b/test/std/containers/sequences/forwardlist/forwardlist.spec/equal.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// template <class T, class Allocator>
+// bool operator==(const forward_list<T, Allocator>& x,
+// const forward_list<T, Allocator>& y);
+//
+// template <class T, class Allocator>
+// bool operator!=(const forward_list<T, Allocator>& x,
+// const forward_list<T, Allocator>& y);
+
+#include <forward_list>
+#include <iterator>
+#include <algorithm>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class C>
+void test(int N, int M)
+{
+ typedef typename C::value_type T;
+ C c1;
+ for (int i = 0; i < N; ++i)
+ c1.push_front(i);
+ C c2;
+ for (int i = 0; i < M; ++i)
+ c2.push_front(i);
+ if (N == M)
+ assert(c1 == c2);
+ else
+ assert(c1 != c2);
+ c2 = c1;
+ assert(c1 == c2);
+ if (N > 0)
+ {
+ c2.front() = N+1;
+ assert(c1 != c2);
+ }
+}
+
+int main()
+{
+ for (int i = 0; i < 10; ++i)
+ for (int j = 0; j < 10; ++j)
+ test<std::forward_list<int> >(i, j);
+#if __cplusplus >= 201103L
+ for (int i = 0; i < 10; ++i)
+ for (int j = 0; j < 10; ++j)
+ test<std::forward_list<int, min_allocator<int>> >(i, j);
+#endif
+}
diff --git a/test/std/containers/sequences/forwardlist/forwardlist.spec/member_swap.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.spec/member_swap.pass.cpp
new file mode 100644
index 000000000000..2b2be7b6c222
--- /dev/null
+++ b/test/std/containers/sequences/forwardlist/forwardlist.spec/member_swap.pass.cpp
@@ -0,0 +1,259 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// void swap(forward_list& x);
+
+#include <forward_list>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef test_allocator<T> A;
+ typedef std::forward_list<T, A> C;
+ const T t1[] = {0, 1, 2, 3, 4, 5};
+ C c1(std::begin(t1), std::end(t1), A(1));
+ const T t2[] = {10, 11, 12};
+ C c2(std::begin(t2), std::end(t2), A(2));
+ c1.swap(c2);
+
+ assert(distance(c1.begin(), c1.end()) == 3);
+ assert(*next(c1.begin(), 0) == 10);
+ assert(*next(c1.begin(), 1) == 11);
+ assert(*next(c1.begin(), 2) == 12);
+ assert(c1.get_allocator() == A(1));
+
+ assert(distance(c2.begin(), c2.end()) == 6);
+ assert(*next(c2.begin(), 0) == 0);
+ assert(*next(c2.begin(), 1) == 1);
+ assert(*next(c2.begin(), 2) == 2);
+ assert(*next(c2.begin(), 3) == 3);
+ assert(*next(c2.begin(), 4) == 4);
+ assert(*next(c2.begin(), 5) == 5);
+ assert(c2.get_allocator() == A(2));
+ }
+ {
+ typedef int T;
+ typedef test_allocator<T> A;
+ typedef std::forward_list<T, A> C;
+ const T t1[] = {0, 1, 2, 3, 4, 5};
+ C c1(std::begin(t1), std::end(t1), A(1));
+ C c2(A(2));
+ c1.swap(c2);
+
+ assert(distance(c1.begin(), c1.end()) == 0);
+ assert(c1.get_allocator() == A(1));
+
+ assert(distance(c2.begin(), c2.end()) == 6);
+ assert(*next(c2.begin(), 0) == 0);
+ assert(*next(c2.begin(), 1) == 1);
+ assert(*next(c2.begin(), 2) == 2);
+ assert(*next(c2.begin(), 3) == 3);
+ assert(*next(c2.begin(), 4) == 4);
+ assert(*next(c2.begin(), 5) == 5);
+ assert(c2.get_allocator() == A(2));
+ }
+ {
+ typedef int T;
+ typedef test_allocator<T> A;
+ typedef std::forward_list<T, A> C;
+ C c1(A(1));
+ const T t2[] = {10, 11, 12};
+ C c2(std::begin(t2), std::end(t2), A(2));
+ c1.swap(c2);
+
+ assert(distance(c1.begin(), c1.end()) == 3);
+ assert(*next(c1.begin(), 0) == 10);
+ assert(*next(c1.begin(), 1) == 11);
+ assert(*next(c1.begin(), 2) == 12);
+ assert(c1.get_allocator() == A(1));
+
+ assert(distance(c2.begin(), c2.end()) == 0);
+ assert(c2.get_allocator() == A(2));
+ }
+ {
+ typedef int T;
+ typedef test_allocator<T> A;
+ typedef std::forward_list<T, A> C;
+ C c1(A(1));
+ C c2(A(2));
+ c1.swap(c2);
+
+ assert(distance(c1.begin(), c1.end()) == 0);
+ assert(c1.get_allocator() == A(1));
+
+ assert(distance(c2.begin(), c2.end()) == 0);
+ assert(c2.get_allocator() == A(2));
+ }
+
+ {
+ typedef int T;
+ typedef other_allocator<T> A;
+ typedef std::forward_list<T, A> C;
+ const T t1[] = {0, 1, 2, 3, 4, 5};
+ C c1(std::begin(t1), std::end(t1), A(1));
+ const T t2[] = {10, 11, 12};
+ C c2(std::begin(t2), std::end(t2), A(2));
+ c1.swap(c2);
+
+ assert(distance(c1.begin(), c1.end()) == 3);
+ assert(*next(c1.begin(), 0) == 10);
+ assert(*next(c1.begin(), 1) == 11);
+ assert(*next(c1.begin(), 2) == 12);
+ assert(c1.get_allocator() == A(2));
+
+ assert(distance(c2.begin(), c2.end()) == 6);
+ assert(*next(c2.begin(), 0) == 0);
+ assert(*next(c2.begin(), 1) == 1);
+ assert(*next(c2.begin(), 2) == 2);
+ assert(*next(c2.begin(), 3) == 3);
+ assert(*next(c2.begin(), 4) == 4);
+ assert(*next(c2.begin(), 5) == 5);
+ assert(c2.get_allocator() == A(1));
+ }
+ {
+ typedef int T;
+ typedef other_allocator<T> A;
+ typedef std::forward_list<T, A> C;
+ const T t1[] = {0, 1, 2, 3, 4, 5};
+ C c1(std::begin(t1), std::end(t1), A(1));
+ C c2(A(2));
+ c1.swap(c2);
+
+ assert(distance(c1.begin(), c1.end()) == 0);
+ assert(c1.get_allocator() == A(2));
+
+ assert(distance(c2.begin(), c2.end()) == 6);
+ assert(*next(c2.begin(), 0) == 0);
+ assert(*next(c2.begin(), 1) == 1);
+ assert(*next(c2.begin(), 2) == 2);
+ assert(*next(c2.begin(), 3) == 3);
+ assert(*next(c2.begin(), 4) == 4);
+ assert(*next(c2.begin(), 5) == 5);
+ assert(c2.get_allocator() == A(1));
+ }
+ {
+ typedef int T;
+ typedef other_allocator<T> A;
+ typedef std::forward_list<T, A> C;
+ C c1(A(1));
+ const T t2[] = {10, 11, 12};
+ C c2(std::begin(t2), std::end(t2), A(2));
+ c1.swap(c2);
+
+ assert(distance(c1.begin(), c1.end()) == 3);
+ assert(*next(c1.begin(), 0) == 10);
+ assert(*next(c1.begin(), 1) == 11);
+ assert(*next(c1.begin(), 2) == 12);
+ assert(c1.get_allocator() == A(2));
+
+ assert(distance(c2.begin(), c2.end()) == 0);
+ assert(c2.get_allocator() == A(1));
+ }
+ {
+ typedef int T;
+ typedef other_allocator<T> A;
+ typedef std::forward_list<T, A> C;
+ C c1(A(1));
+ C c2(A(2));
+ c1.swap(c2);
+
+ assert(distance(c1.begin(), c1.end()) == 0);
+ assert(c1.get_allocator() == A(2));
+
+ assert(distance(c2.begin(), c2.end()) == 0);
+ assert(c2.get_allocator() == A(1));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef min_allocator<T> A;
+ typedef std::forward_list<T, A> C;
+ const T t1[] = {0, 1, 2, 3, 4, 5};
+ C c1(std::begin(t1), std::end(t1), A());
+ const T t2[] = {10, 11, 12};
+ C c2(std::begin(t2), std::end(t2), A());
+ c1.swap(c2);
+
+ assert(distance(c1.begin(), c1.end()) == 3);
+ assert(*next(c1.begin(), 0) == 10);
+ assert(*next(c1.begin(), 1) == 11);
+ assert(*next(c1.begin(), 2) == 12);
+ assert(c1.get_allocator() == A());
+
+ assert(distance(c2.begin(), c2.end()) == 6);
+ assert(*next(c2.begin(), 0) == 0);
+ assert(*next(c2.begin(), 1) == 1);
+ assert(*next(c2.begin(), 2) == 2);
+ assert(*next(c2.begin(), 3) == 3);
+ assert(*next(c2.begin(), 4) == 4);
+ assert(*next(c2.begin(), 5) == 5);
+ assert(c2.get_allocator() == A());
+ }
+ {
+ typedef int T;
+ typedef min_allocator<T> A;
+ typedef std::forward_list<T, A> C;
+ const T t1[] = {0, 1, 2, 3, 4, 5};
+ C c1(std::begin(t1), std::end(t1), A());
+ C c2(A{});
+ c1.swap(c2);
+
+ assert(distance(c1.begin(), c1.end()) == 0);
+ assert(c1.get_allocator() == A());
+
+ assert(distance(c2.begin(), c2.end()) == 6);
+ assert(*next(c2.begin(), 0) == 0);
+ assert(*next(c2.begin(), 1) == 1);
+ assert(*next(c2.begin(), 2) == 2);
+ assert(*next(c2.begin(), 3) == 3);
+ assert(*next(c2.begin(), 4) == 4);
+ assert(*next(c2.begin(), 5) == 5);
+ assert(c2.get_allocator() == A());
+ }
+ {
+ typedef int T;
+ typedef min_allocator<T> A;
+ typedef std::forward_list<T, A> C;
+ C c1(A{});
+ const T t2[] = {10, 11, 12};
+ C c2(std::begin(t2), std::end(t2), A());
+ c1.swap(c2);
+
+ assert(distance(c1.begin(), c1.end()) == 3);
+ assert(*next(c1.begin(), 0) == 10);
+ assert(*next(c1.begin(), 1) == 11);
+ assert(*next(c1.begin(), 2) == 12);
+ assert(c1.get_allocator() == A());
+
+ assert(distance(c2.begin(), c2.end()) == 0);
+ assert(c2.get_allocator() == A());
+ }
+ {
+ typedef int T;
+ typedef min_allocator<T> A;
+ typedef std::forward_list<T, A> C;
+ C c1(A{});
+ C c2(A{});
+ c1.swap(c2);
+
+ assert(distance(c1.begin(), c1.end()) == 0);
+ assert(c1.get_allocator() == A());
+
+ assert(distance(c2.begin(), c2.end()) == 0);
+ assert(c2.get_allocator() == A());
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/forwardlist/forwardlist.spec/non_member_swap.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.spec/non_member_swap.pass.cpp
new file mode 100644
index 000000000000..d6ba5a47cbe6
--- /dev/null
+++ b/test/std/containers/sequences/forwardlist/forwardlist.spec/non_member_swap.pass.cpp
@@ -0,0 +1,260 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// template <class T, class Allocator>
+// void swap(forward_list<T, Allocator>& x, forward_list<T, Allocator>& y);
+
+#include <forward_list>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef test_allocator<T> A;
+ typedef std::forward_list<T, A> C;
+ const T t1[] = {0, 1, 2, 3, 4, 5};
+ C c1(std::begin(t1), std::end(t1), A(1));
+ const T t2[] = {10, 11, 12};
+ C c2(std::begin(t2), std::end(t2), A(2));
+ swap(c1, c2);
+
+ assert(distance(c1.begin(), c1.end()) == 3);
+ assert(*next(c1.begin(), 0) == 10);
+ assert(*next(c1.begin(), 1) == 11);
+ assert(*next(c1.begin(), 2) == 12);
+ assert(c1.get_allocator() == A(1));
+
+ assert(distance(c2.begin(), c2.end()) == 6);
+ assert(*next(c2.begin(), 0) == 0);
+ assert(*next(c2.begin(), 1) == 1);
+ assert(*next(c2.begin(), 2) == 2);
+ assert(*next(c2.begin(), 3) == 3);
+ assert(*next(c2.begin(), 4) == 4);
+ assert(*next(c2.begin(), 5) == 5);
+ assert(c2.get_allocator() == A(2));
+ }
+ {
+ typedef int T;
+ typedef test_allocator<T> A;
+ typedef std::forward_list<T, A> C;
+ const T t1[] = {0, 1, 2, 3, 4, 5};
+ C c1(std::begin(t1), std::end(t1), A(1));
+ C c2(A(2));
+ swap(c1, c2);
+
+ assert(distance(c1.begin(), c1.end()) == 0);
+ assert(c1.get_allocator() == A(1));
+
+ assert(distance(c2.begin(), c2.end()) == 6);
+ assert(*next(c2.begin(), 0) == 0);
+ assert(*next(c2.begin(), 1) == 1);
+ assert(*next(c2.begin(), 2) == 2);
+ assert(*next(c2.begin(), 3) == 3);
+ assert(*next(c2.begin(), 4) == 4);
+ assert(*next(c2.begin(), 5) == 5);
+ assert(c2.get_allocator() == A(2));
+ }
+ {
+ typedef int T;
+ typedef test_allocator<T> A;
+ typedef std::forward_list<T, A> C;
+ C c1(A(1));
+ const T t2[] = {10, 11, 12};
+ C c2(std::begin(t2), std::end(t2), A(2));
+ swap(c1, c2);
+
+ assert(distance(c1.begin(), c1.end()) == 3);
+ assert(*next(c1.begin(), 0) == 10);
+ assert(*next(c1.begin(), 1) == 11);
+ assert(*next(c1.begin(), 2) == 12);
+ assert(c1.get_allocator() == A(1));
+
+ assert(distance(c2.begin(), c2.end()) == 0);
+ assert(c2.get_allocator() == A(2));
+ }
+ {
+ typedef int T;
+ typedef test_allocator<T> A;
+ typedef std::forward_list<T, A> C;
+ C c1(A(1));
+ C c2(A(2));
+ swap(c1, c2);
+
+ assert(distance(c1.begin(), c1.end()) == 0);
+ assert(c1.get_allocator() == A(1));
+
+ assert(distance(c2.begin(), c2.end()) == 0);
+ assert(c2.get_allocator() == A(2));
+ }
+
+ {
+ typedef int T;
+ typedef other_allocator<T> A;
+ typedef std::forward_list<T, A> C;
+ const T t1[] = {0, 1, 2, 3, 4, 5};
+ C c1(std::begin(t1), std::end(t1), A(1));
+ const T t2[] = {10, 11, 12};
+ C c2(std::begin(t2), std::end(t2), A(2));
+ swap(c1, c2);
+
+ assert(distance(c1.begin(), c1.end()) == 3);
+ assert(*next(c1.begin(), 0) == 10);
+ assert(*next(c1.begin(), 1) == 11);
+ assert(*next(c1.begin(), 2) == 12);
+ assert(c1.get_allocator() == A(2));
+
+ assert(distance(c2.begin(), c2.end()) == 6);
+ assert(*next(c2.begin(), 0) == 0);
+ assert(*next(c2.begin(), 1) == 1);
+ assert(*next(c2.begin(), 2) == 2);
+ assert(*next(c2.begin(), 3) == 3);
+ assert(*next(c2.begin(), 4) == 4);
+ assert(*next(c2.begin(), 5) == 5);
+ assert(c2.get_allocator() == A(1));
+ }
+ {
+ typedef int T;
+ typedef other_allocator<T> A;
+ typedef std::forward_list<T, A> C;
+ const T t1[] = {0, 1, 2, 3, 4, 5};
+ C c1(std::begin(t1), std::end(t1), A(1));
+ C c2(A(2));
+ swap(c1, c2);
+
+ assert(distance(c1.begin(), c1.end()) == 0);
+ assert(c1.get_allocator() == A(2));
+
+ assert(distance(c2.begin(), c2.end()) == 6);
+ assert(*next(c2.begin(), 0) == 0);
+ assert(*next(c2.begin(), 1) == 1);
+ assert(*next(c2.begin(), 2) == 2);
+ assert(*next(c2.begin(), 3) == 3);
+ assert(*next(c2.begin(), 4) == 4);
+ assert(*next(c2.begin(), 5) == 5);
+ assert(c2.get_allocator() == A(1));
+ }
+ {
+ typedef int T;
+ typedef other_allocator<T> A;
+ typedef std::forward_list<T, A> C;
+ C c1(A(1));
+ const T t2[] = {10, 11, 12};
+ C c2(std::begin(t2), std::end(t2), A(2));
+ swap(c1, c2);
+
+ assert(distance(c1.begin(), c1.end()) == 3);
+ assert(*next(c1.begin(), 0) == 10);
+ assert(*next(c1.begin(), 1) == 11);
+ assert(*next(c1.begin(), 2) == 12);
+ assert(c1.get_allocator() == A(2));
+
+ assert(distance(c2.begin(), c2.end()) == 0);
+ assert(c2.get_allocator() == A(1));
+ }
+ {
+ typedef int T;
+ typedef other_allocator<T> A;
+ typedef std::forward_list<T, A> C;
+ C c1(A(1));
+ C c2(A(2));
+ swap(c1, c2);
+
+ assert(distance(c1.begin(), c1.end()) == 0);
+ assert(c1.get_allocator() == A(2));
+
+ assert(distance(c2.begin(), c2.end()) == 0);
+ assert(c2.get_allocator() == A(1));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef min_allocator<T> A;
+ typedef std::forward_list<T, A> C;
+ const T t1[] = {0, 1, 2, 3, 4, 5};
+ C c1(std::begin(t1), std::end(t1), A());
+ const T t2[] = {10, 11, 12};
+ C c2(std::begin(t2), std::end(t2), A());
+ swap(c1, c2);
+
+ assert(distance(c1.begin(), c1.end()) == 3);
+ assert(*next(c1.begin(), 0) == 10);
+ assert(*next(c1.begin(), 1) == 11);
+ assert(*next(c1.begin(), 2) == 12);
+ assert(c1.get_allocator() == A());
+
+ assert(distance(c2.begin(), c2.end()) == 6);
+ assert(*next(c2.begin(), 0) == 0);
+ assert(*next(c2.begin(), 1) == 1);
+ assert(*next(c2.begin(), 2) == 2);
+ assert(*next(c2.begin(), 3) == 3);
+ assert(*next(c2.begin(), 4) == 4);
+ assert(*next(c2.begin(), 5) == 5);
+ assert(c2.get_allocator() == A());
+ }
+ {
+ typedef int T;
+ typedef min_allocator<T> A;
+ typedef std::forward_list<T, A> C;
+ const T t1[] = {0, 1, 2, 3, 4, 5};
+ C c1(std::begin(t1), std::end(t1), A());
+ C c2(A{});
+ swap(c1, c2);
+
+ assert(distance(c1.begin(), c1.end()) == 0);
+ assert(c1.get_allocator() == A());
+
+ assert(distance(c2.begin(), c2.end()) == 6);
+ assert(*next(c2.begin(), 0) == 0);
+ assert(*next(c2.begin(), 1) == 1);
+ assert(*next(c2.begin(), 2) == 2);
+ assert(*next(c2.begin(), 3) == 3);
+ assert(*next(c2.begin(), 4) == 4);
+ assert(*next(c2.begin(), 5) == 5);
+ assert(c2.get_allocator() == A());
+ }
+ {
+ typedef int T;
+ typedef min_allocator<T> A;
+ typedef std::forward_list<T, A> C;
+ C c1(A{});
+ const T t2[] = {10, 11, 12};
+ C c2(std::begin(t2), std::end(t2), A());
+ swap(c1, c2);
+
+ assert(distance(c1.begin(), c1.end()) == 3);
+ assert(*next(c1.begin(), 0) == 10);
+ assert(*next(c1.begin(), 1) == 11);
+ assert(*next(c1.begin(), 2) == 12);
+ assert(c1.get_allocator() == A());
+
+ assert(distance(c2.begin(), c2.end()) == 0);
+ assert(c2.get_allocator() == A());
+ }
+ {
+ typedef int T;
+ typedef min_allocator<T> A;
+ typedef std::forward_list<T, A> C;
+ C c1(A{});
+ C c2(A{});
+ swap(c1, c2);
+
+ assert(distance(c1.begin(), c1.end()) == 0);
+ assert(c1.get_allocator() == A());
+
+ assert(distance(c2.begin(), c2.end()) == 0);
+ assert(c2.get_allocator() == A());
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/forwardlist/forwardlist.spec/relational.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.spec/relational.pass.cpp
new file mode 100644
index 000000000000..42e245d007b0
--- /dev/null
+++ b/test/std/containers/sequences/forwardlist/forwardlist.spec/relational.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// template <class T, class Allocator>
+// bool operator< (const forward_list<T, Allocator>& x,
+// const forward_list<T, Allocator>& y);
+//
+// template <class T, class Allocator>
+// bool operator> (const forward_list<T, Allocator>& x,
+// const forward_list<T, Allocator>& y);
+//
+// template <class T, class Allocator>
+// bool operator>=(const forward_list<T, Allocator>& x,
+// const forward_list<T, Allocator>& y);
+//
+// template <class T, class Allocator>
+// bool operator<=(const forward_list<T, Allocator>& x,
+// const forward_list<T, Allocator>& y);
+
+#include <forward_list>
+#include <iterator>
+#include <algorithm>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class C>
+void test(int N, int M)
+{
+ typedef typename C::value_type T;
+ C c1;
+ for (int i = 0; i < N; ++i)
+ c1.push_front(i);
+ C c2;
+ for (int i = 0; i < M; ++i)
+ c2.push_front(i);
+ if (N < M)
+ assert(c1 < c2);
+ if (N <= M)
+ assert(c1 <= c2);
+ if (N >= M)
+ assert(c1 >= c2);
+ if (N > M)
+ assert(c1 > c2);
+}
+
+int main()
+{
+ for (int i = 0; i < 10; ++i)
+ for (int j = 0; j < 10; ++j)
+ test<std::forward_list<int> >(i, j);
+#if __cplusplus >= 201103L
+ for (int i = 0; i < 10; ++i)
+ for (int j = 0; j < 10; ++j)
+ test<std::forward_list<int, min_allocator<int>> >(i, j);
+#endif
+}
diff --git a/test/std/containers/sequences/forwardlist/forwardlist.spec/swap_noexcept.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.spec/swap_noexcept.pass.cpp
new file mode 100644
index 000000000000..cbe8142eeb4b
--- /dev/null
+++ b/test/std/containers/sequences/forwardlist/forwardlist.spec/swap_noexcept.pass.cpp
@@ -0,0 +1,90 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// void swap(forward_list& c)
+// noexcept(!allocator_type::propagate_on_container_swap::value ||
+// __is_nothrow_swappable<allocator_type>::value);
+//
+// In C++17, the standard says that swap shall have:
+// noexcept(is_always_equal<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <forward_list>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_alloc
+{
+ typedef T value_type;
+
+ some_alloc() {}
+ some_alloc(const some_alloc&);
+ void deallocate(void*, unsigned) {}
+
+ typedef std::true_type propagate_on_container_swap;
+};
+
+template <class T>
+struct some_alloc2
+{
+ typedef T value_type;
+
+ some_alloc2() {}
+ some_alloc2(const some_alloc2&);
+ void deallocate(void*, unsigned) {}
+
+ typedef std::false_type propagate_on_container_swap;
+ typedef std::true_type is_always_equal;
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::forward_list<MoveOnly> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::forward_list<MoveOnly, test_allocator<MoveOnly>> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::forward_list<MoveOnly, other_allocator<MoveOnly>> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::forward_list<MoveOnly, some_alloc<MoveOnly>> C;
+ C c1, c2;
+#if TEST_STD_VER >= 14
+ // In c++14, if POCS is set, swapping the allocator is required not to throw
+ static_assert( noexcept(swap(c1, c2)), "");
+#else
+ static_assert(!noexcept(swap(c1, c2)), "");
+#endif
+ }
+#if TEST_STD_VER >= 14
+ {
+ typedef std::forward_list<MoveOnly, some_alloc2<MoveOnly>> C;
+ C c1, c2;
+ // if the allocators are always equal, then the swap can be noexcept
+ static_assert( noexcept(swap(c1, c2)), "");
+ }
+#endif
+
+#endif
+}
diff --git a/test/std/containers/sequences/forwardlist/max_size.pass.cpp b/test/std/containers/sequences/forwardlist/max_size.pass.cpp
new file mode 100644
index 000000000000..be7ebaf44b03
--- /dev/null
+++ b/test/std/containers/sequences/forwardlist/max_size.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// size_type max_size() const;
+
+#include <forward_list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ C c;
+ assert(c.max_size() > 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ C c;
+ assert(c.max_size() > 0);
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/forwardlist/types.pass.cpp b/test/std/containers/sequences/forwardlist/types.pass.cpp
new file mode 100644
index 000000000000..a1f8862debbe
--- /dev/null
+++ b/test/std/containers/sequences/forwardlist/types.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// template <class T, class Allocator = allocator<T>>
+// class forward_list
+// {
+// public:
+// typedef T value_type;
+// typedef Allocator allocator_type;
+//
+// typedef value_type& reference;
+// typedef const value_type& const_reference;
+// typedef typename allocator_traits<allocator_type>::pointer pointer;
+// typedef typename allocator_traits<allocator_type>::const_pointer const_pointer;
+// typedef typename allocator_traits<allocator_type>::size_type size_type;
+// typedef typename allocator_traits<allocator_type>::difference_type difference_type;
+// ...
+// };
+
+#include <forward_list>
+#include <type_traits>
+
+#include "min_allocator.h"
+
+struct A { std::forward_list<A> v; }; // incomplete type support
+
+int main()
+{
+ {
+ typedef std::forward_list<char> C;
+ static_assert((std::is_same<C::value_type, char>::value), "");
+ static_assert((std::is_same<C::allocator_type, std::allocator<char> >::value), "");
+ static_assert((std::is_same<C::reference, char&>::value), "");
+ static_assert((std::is_same<C::const_reference, const char&>::value), "");
+ static_assert((std::is_same<C::pointer, char*>::value), "");
+ static_assert((std::is_same<C::const_pointer, const char*>::value), "");
+ static_assert((std::is_same<C::size_type, std::size_t>::value), "");
+ static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::forward_list<char, min_allocator<char>> C;
+ static_assert((std::is_same<C::value_type, char>::value), "");
+ static_assert((std::is_same<C::allocator_type, min_allocator<char> >::value), "");
+ static_assert((std::is_same<C::reference, char&>::value), "");
+ static_assert((std::is_same<C::const_reference, const char&>::value), "");
+ static_assert((std::is_same<C::pointer, min_pointer<char>>::value), "");
+ static_assert((std::is_same<C::const_pointer, min_pointer<const char>>::value), "");
+// min_allocator doesn't have a size_type, so one gets synthesized
+ static_assert((std::is_same<C::size_type, std::make_unsigned<C::difference_type>::type>::value), "");
+ static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/forwardlist/version.pass.cpp b/test/std/containers/sequences/forwardlist/version.pass.cpp
new file mode 100644
index 000000000000..918c8dd5d73c
--- /dev/null
+++ b/test/std/containers/sequences/forwardlist/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+#include <forward_list>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/containers/sequences/list/db_back.pass.cpp b/test/std/containers/sequences/list/db_back.pass.cpp
new file mode 100644
index 000000000000..b16c0e90701e
--- /dev/null
+++ b/test/std/containers/sequences/list/db_back.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// Call back() on empty container.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <list>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::list<T> C;
+ C c(1);
+ assert(c.back() == 0);
+ c.clear();
+ assert(c.back() == 0);
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::list<T, min_allocator<T>> C;
+ C c(1);
+ assert(c.back() == 0);
+ c.clear();
+ assert(c.back() == 0);
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/containers/sequences/list/db_cback.pass.cpp b/test/std/containers/sequences/list/db_cback.pass.cpp
new file mode 100644
index 000000000000..ba3977e16f48
--- /dev/null
+++ b/test/std/containers/sequences/list/db_cback.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// Call back() on empty const container.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <list>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::list<T> C;
+ const C c;
+ assert(c.back() == 0);
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::list<T, min_allocator<T>> C;
+ const C c;
+ assert(c.back() == 0);
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/containers/sequences/list/db_cfront.pass.cpp b/test/std/containers/sequences/list/db_cfront.pass.cpp
new file mode 100644
index 000000000000..d42290c43c08
--- /dev/null
+++ b/test/std/containers/sequences/list/db_cfront.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// Call front() on empty const container.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <list>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::list<T> C;
+ const C c;
+ assert(c.front() == 0);
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::list<T, min_allocator<T>> C;
+ const C c;
+ assert(c.front() == 0);
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/containers/sequences/list/db_front.pass.cpp b/test/std/containers/sequences/list/db_front.pass.cpp
new file mode 100644
index 000000000000..037b16035c66
--- /dev/null
+++ b/test/std/containers/sequences/list/db_front.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// Call front() on empty container.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <list>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::list<T> C;
+ C c(1);
+ assert(c.front() == 0);
+ c.clear();
+ assert(c.front() == 0);
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::list<T, min_allocator<T>> C;
+ C c(1);
+ assert(c.front() == 0);
+ c.clear();
+ assert(c.front() == 0);
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/containers/sequences/list/db_iterators_6.pass.cpp b/test/std/containers/sequences/list/db_iterators_6.pass.cpp
new file mode 100644
index 000000000000..a5b8020b3733
--- /dev/null
+++ b/test/std/containers/sequences/list/db_iterators_6.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// Decrement iterator prior to begin.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <list>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::list<T> C;
+ C c(1);
+ C::iterator i = c.end();
+ --i;
+ assert(i == c.begin());
+ --i;
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::list<T, min_allocator<T>> C;
+ C c(1);
+ C::iterator i = c.end();
+ --i;
+ assert(i == c.begin());
+ --i;
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/containers/sequences/list/db_iterators_7.pass.cpp b/test/std/containers/sequences/list/db_iterators_7.pass.cpp
new file mode 100644
index 000000000000..76a491b1184d
--- /dev/null
+++ b/test/std/containers/sequences/list/db_iterators_7.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// Increment iterator past end.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <list>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::list<T> C;
+ C c(1);
+ C::iterator i = c.begin();
+ ++i;
+ assert(i == c.end());
+ ++i;
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::list<T, min_allocator<T>> C;
+ C c(1);
+ C::iterator i = c.begin();
+ ++i;
+ assert(i == c.end());
+ ++i;
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/containers/sequences/list/db_iterators_8.pass.cpp b/test/std/containers/sequences/list/db_iterators_8.pass.cpp
new file mode 100644
index 000000000000..1d1ee23a393a
--- /dev/null
+++ b/test/std/containers/sequences/list/db_iterators_8.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// Dereference non-dereferenceable iterator.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <list>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::list<T> C;
+ C c(1);
+ C::iterator i = c.end();
+ T j = *i;
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::list<T, min_allocator<T>> C;
+ C c(1);
+ C::iterator i = c.end();
+ T j = *i;
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/containers/sequences/list/db_iterators_9.pass.cpp b/test/std/containers/sequences/list/db_iterators_9.pass.cpp
new file mode 100644
index 000000000000..d02fcd6e4497
--- /dev/null
+++ b/test/std/containers/sequences/list/db_iterators_9.pass.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// Operations on "NULL" iterators
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) do { if (!x) throw 1; } while(0)
+
+#include <list>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+struct S { int val; };
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ {
+ unsigned lib_asserts;
+
+ typedef S T;
+ typedef std::list<T> C;
+ C::iterator i{};
+ C::const_iterator ci{};
+
+ lib_asserts = 0;
+ try { ++i; } catch (int) { ++lib_asserts; }
+ try { i++; } catch (int) { ++lib_asserts; }
+ try { ++ci; } catch (int) { ++lib_asserts; }
+ try { ci++; } catch (int) { ++lib_asserts; }
+ assert(lib_asserts == 4);
+
+ lib_asserts = 0;
+ try { --i; } catch (int) { ++lib_asserts; }
+ try { i--; } catch (int) { ++lib_asserts; }
+ try { --ci; } catch (int) { ++lib_asserts; }
+ try { ci--; } catch (int) { ++lib_asserts; }
+ assert(lib_asserts == 4);
+
+ lib_asserts = 0;
+ try { *i; } catch (int) { ++lib_asserts; }
+ try { *ci; } catch (int) { ++lib_asserts; }
+ try { (void) i->val; } catch (int) { ++lib_asserts; }
+ try { (void) ci->val; } catch (int) { ++lib_asserts; }
+ assert(lib_asserts == 4);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/containers/sequences/list/iterators.pass.cpp b/test/std/containers/sequences/list/iterators.pass.cpp
new file mode 100644
index 000000000000..a33ee3ecd2db
--- /dev/null
+++ b/test/std/containers/sequences/list/iterators.pass.cpp
@@ -0,0 +1,159 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// iterator begin();
+// iterator end();
+// const_iterator begin() const;
+// const_iterator end() const;
+// const_iterator cbegin() const;
+// const_iterator cend() const;
+
+#include <list>
+#include <cassert>
+#include <iterator>
+
+#include "min_allocator.h"
+
+struct A
+{
+ int first;
+ int second;
+};
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::list<T> C;
+ C c;
+ C::iterator i = c.begin();
+ C::iterator j = c.end();
+ assert(std::distance(i, j) == 0);
+ assert(i == j);
+ }
+ {
+ typedef int T;
+ typedef std::list<T> C;
+ const C c;
+ C::const_iterator i = c.begin();
+ C::const_iterator j = c.end();
+ assert(std::distance(i, j) == 0);
+ assert(i == j);
+ }
+ {
+ typedef int T;
+ typedef std::list<T> C;
+ C c;
+ C::const_iterator i = c.cbegin();
+ C::const_iterator j = c.cend();
+ assert(std::distance(i, j) == 0);
+ assert(i == j);
+ assert(i == c.end());
+ }
+ {
+ typedef int T;
+ typedef std::list<T> C;
+ const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ C c(std::begin(t), std::end(t));
+ C::iterator i = c.begin();
+ assert(*i == 0);
+ ++i;
+ assert(*i == 1);
+ *i = 10;
+ assert(*i == 10);
+ assert(std::distance(c.begin(), c.end()) == 10);
+ }
+ {
+ typedef int T;
+ typedef std::list<T> C;
+ C::iterator i;
+ C::const_iterator j;
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::list<T, min_allocator<T>> C;
+ C c;
+ C::iterator i = c.begin();
+ C::iterator j = c.end();
+ assert(std::distance(i, j) == 0);
+ assert(i == j);
+ }
+ {
+ typedef int T;
+ typedef std::list<T, min_allocator<T>> C;
+ const C c;
+ C::const_iterator i = c.begin();
+ C::const_iterator j = c.end();
+ assert(std::distance(i, j) == 0);
+ assert(i == j);
+ }
+ {
+ typedef int T;
+ typedef std::list<T, min_allocator<T>> C;
+ C c;
+ C::const_iterator i = c.cbegin();
+ C::const_iterator j = c.cend();
+ assert(std::distance(i, j) == 0);
+ assert(i == j);
+ assert(i == c.end());
+ }
+ {
+ typedef int T;
+ typedef std::list<T, min_allocator<T>> C;
+ const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ C c(std::begin(t), std::end(t));
+ C::iterator i = c.begin();
+ assert(*i == 0);
+ ++i;
+ assert(*i == 1);
+ *i = 10;
+ assert(*i == 10);
+ assert(std::distance(c.begin(), c.end()) == 10);
+ }
+ {
+ typedef int T;
+ typedef std::list<T, min_allocator<T>> C;
+ C::iterator i;
+ C::const_iterator j;
+ }
+ {
+ typedef A T;
+ typedef std::list<T, min_allocator<T>> C;
+ C c = {A{1, 2}};
+ C::iterator i = c.begin();
+ i->first = 3;
+ C::const_iterator j = i;
+ assert(j->first == 3);
+ }
+#endif
+#if _LIBCPP_STD_VER > 11
+ {
+ std::list<int> c;
+ std::list<int>::iterator ii1{}, ii2{};
+ std::list<int>::iterator ii4 = ii1;
+ std::list<int>::const_iterator cii{};
+ assert ( ii1 == ii2 );
+ assert ( ii1 == ii4 );
+
+ assert (!(ii1 != ii2 ));
+
+ assert ( (ii1 == cii ));
+ assert ( (cii == ii1 ));
+ assert (!(ii1 != cii ));
+ assert (!(cii != ii1 ));
+
+ assert ( ii1 != c.cbegin());
+ assert ( cii != c.begin());
+ }
+#endif
+
+}
diff --git a/test/std/containers/sequences/list/list.capacity/resize_size.pass.cpp b/test/std/containers/sequences/list/list.capacity/resize_size.pass.cpp
new file mode 100644
index 000000000000..14629b173a6c
--- /dev/null
+++ b/test/std/containers/sequences/list/list.capacity/resize_size.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void resize(size_type sz);
+
+#include <list>
+#include <cassert>
+#include "DefaultOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::list<int> l(5, 2);
+ l.resize(2);
+ assert(l.size() == 2);
+ assert(std::distance(l.begin(), l.end()) == 2);
+ assert(l == std::list<int>(2, 2));
+ }
+ {
+ std::list<int> l(5, 2);
+ l.resize(10);
+ assert(l.size() == 10);
+ assert(std::distance(l.begin(), l.end()) == 10);
+ assert(l.front() == 2);
+ assert(l.back() == 0);
+ }
+#ifdef __LIBCPP_MOVE
+ {
+ std::list<DefaultOnly> l(10);
+ l.resize(5);
+ assert(l.size() == 5);
+ assert(std::distance(l.begin(), l.end()) == 5);
+ }
+ {
+ std::list<DefaultOnly> l(10);
+ l.resize(20);
+ assert(l.size() == 20);
+ assert(std::distance(l.begin(), l.end()) == 20);
+ }
+#endif // __LIBCPP_MOVE
+#if __cplusplus >= 201103L
+ {
+ std::list<int, min_allocator<int>> l(5, 2);
+ l.resize(2);
+ assert(l.size() == 2);
+ assert(std::distance(l.begin(), l.end()) == 2);
+ assert((l == std::list<int, min_allocator<int>>(2, 2)));
+ }
+ {
+ std::list<int, min_allocator<int>> l(5, 2);
+ l.resize(10);
+ assert(l.size() == 10);
+ assert(std::distance(l.begin(), l.end()) == 10);
+ assert(l.front() == 2);
+ assert(l.back() == 0);
+ }
+#ifdef __LIBCPP_MOVE
+ {
+ std::list<DefaultOnly, min_allocator<DefaultOnly>> l(10);
+ l.resize(5);
+ assert(l.size() == 5);
+ assert(std::distance(l.begin(), l.end()) == 5);
+ }
+ {
+ std::list<DefaultOnly, min_allocator<DefaultOnly>> l(10);
+ l.resize(20);
+ assert(l.size() == 20);
+ assert(std::distance(l.begin(), l.end()) == 20);
+ }
+#endif // __LIBCPP_MOVE
+#endif
+}
diff --git a/test/std/containers/sequences/list/list.capacity/resize_size_value.pass.cpp b/test/std/containers/sequences/list/list.capacity/resize_size_value.pass.cpp
new file mode 100644
index 000000000000..2738ffbbefdd
--- /dev/null
+++ b/test/std/containers/sequences/list/list.capacity/resize_size_value.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void resize(size_type sz, const value_type& x);
+
+#include <list>
+#include <cassert>
+#include "DefaultOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::list<double> l(5, 2);
+ l.resize(2, 3.5);
+ assert(l.size() == 2);
+ assert(std::distance(l.begin(), l.end()) == 2);
+ assert(l == std::list<double>(2, 2));
+ }
+ {
+ std::list<double> l(5, 2);
+ l.resize(10, 3.5);
+ assert(l.size() == 10);
+ assert(std::distance(l.begin(), l.end()) == 10);
+ assert(l.front() == 2);
+ assert(l.back() == 3.5);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::list<double, min_allocator<double>> l(5, 2);
+ l.resize(2, 3.5);
+ assert(l.size() == 2);
+ assert(std::distance(l.begin(), l.end()) == 2);
+ assert((l == std::list<double, min_allocator<double>>(2, 2)));
+ }
+ {
+ std::list<double, min_allocator<double>> l(5, 2);
+ l.resize(10, 3.5);
+ assert(l.size() == 10);
+ assert(std::distance(l.begin(), l.end()) == 10);
+ assert(l.front() == 2);
+ assert(l.back() == 3.5);
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/list/list.cons/assign_copy.pass.cpp b/test/std/containers/sequences/list/list.cons/assign_copy.pass.cpp
new file mode 100644
index 000000000000..b851eb9dc5a0
--- /dev/null
+++ b/test/std/containers/sequences/list/list.cons/assign_copy.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// list& operator=(const list& c);
+
+#include <list>
+#include <cassert>
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::list<int, test_allocator<int> > l(3, 2, test_allocator<int>(5));
+ std::list<int, test_allocator<int> > l2(l, test_allocator<int>(3));
+ l2 = l;
+ assert(l2 == l);
+ assert(l2.get_allocator() == test_allocator<int>(3));
+ }
+ {
+ std::list<int, other_allocator<int> > l(3, 2, other_allocator<int>(5));
+ std::list<int, other_allocator<int> > l2(l, other_allocator<int>(3));
+ l2 = l;
+ assert(l2 == l);
+ assert(l2.get_allocator() == other_allocator<int>(5));
+ }
+#if __cplusplus >= 201103L
+ {
+ std::list<int, min_allocator<int> > l(3, 2, min_allocator<int>());
+ std::list<int, min_allocator<int> > l2(l, min_allocator<int>());
+ l2 = l;
+ assert(l2 == l);
+ assert(l2.get_allocator() == min_allocator<int>());
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/list/list.cons/assign_initializer_list.pass.cpp b/test/std/containers/sequences/list/list.cons/assign_initializer_list.pass.cpp
new file mode 100644
index 000000000000..24bd140c4e4f
--- /dev/null
+++ b/test/std/containers/sequences/list/list.cons/assign_initializer_list.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void assign(initializer_list<value_type> il);
+
+#include <list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ std::list<int> d;
+ d.assign({3, 4, 5, 6});
+ assert(d.size() == 4);
+ std::list<int>::iterator i = d.begin();
+ assert(*i++ == 3);
+ assert(*i++ == 4);
+ assert(*i++ == 5);
+ assert(*i++ == 6);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::list<int, min_allocator<int>> d;
+ d.assign({3, 4, 5, 6});
+ assert(d.size() == 4);
+ std::list<int, min_allocator<int>>::iterator i = d.begin();
+ assert(*i++ == 3);
+ assert(*i++ == 4);
+ assert(*i++ == 5);
+ assert(*i++ == 6);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/containers/sequences/list/list.cons/assign_move.pass.cpp b/test/std/containers/sequences/list/list.cons/assign_move.pass.cpp
new file mode 100644
index 000000000000..0fd586f84af7
--- /dev/null
+++ b/test/std/containers/sequences/list/list.cons/assign_move.pass.cpp
@@ -0,0 +1,82 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// list& operator=(list&& c);
+
+#include <list>
+#include <cassert>
+#include "MoveOnly.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::list<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5));
+ std::list<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5));
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ std::list<MoveOnly, test_allocator<MoveOnly> > l2(test_allocator<MoveOnly>(5));
+ l2 = std::move(l);
+ assert(l2 == lo);
+ assert(l.empty());
+ assert(l2.get_allocator() == lo.get_allocator());
+ }
+ {
+ std::list<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5));
+ std::list<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5));
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ std::list<MoveOnly, test_allocator<MoveOnly> > l2(test_allocator<MoveOnly>(6));
+ l2 = std::move(l);
+ assert(l2 == lo);
+ assert(!l.empty());
+ assert(l2.get_allocator() == test_allocator<MoveOnly>(6));
+ }
+ {
+ std::list<MoveOnly, other_allocator<MoveOnly> > l(other_allocator<MoveOnly>(5));
+ std::list<MoveOnly, other_allocator<MoveOnly> > lo(other_allocator<MoveOnly>(5));
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ std::list<MoveOnly, other_allocator<MoveOnly> > l2(other_allocator<MoveOnly>(6));
+ l2 = std::move(l);
+ assert(l2 == lo);
+ assert(l.empty());
+ assert(l2.get_allocator() == lo.get_allocator());
+ }
+#if __cplusplus >= 201103L
+ {
+ std::list<MoveOnly, min_allocator<MoveOnly> > l(min_allocator<MoveOnly>{});
+ std::list<MoveOnly, min_allocator<MoveOnly> > lo(min_allocator<MoveOnly>{});
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ std::list<MoveOnly, min_allocator<MoveOnly> > l2(min_allocator<MoveOnly>{});
+ l2 = std::move(l);
+ assert(l2 == lo);
+ assert(l.empty());
+ assert(l2.get_allocator() == lo.get_allocator());
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/sequences/list/list.cons/copy.pass.cpp b/test/std/containers/sequences/list/list.cons/copy.pass.cpp
new file mode 100644
index 000000000000..530690a925d4
--- /dev/null
+++ b/test/std/containers/sequences/list/list.cons/copy.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// list(const list& c);
+
+#include <list>
+#include <cassert>
+#include "DefaultOnly.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::list<int> l(3, 2);
+ std::list<int> l2 = l;
+ assert(l2 == l);
+ }
+ {
+ std::list<int, test_allocator<int> > l(3, 2, test_allocator<int>(5));
+ std::list<int, test_allocator<int> > l2 = l;
+ assert(l2 == l);
+ assert(l2.get_allocator() == l.get_allocator());
+ }
+#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+ {
+ std::list<int, other_allocator<int> > l(3, 2, other_allocator<int>(5));
+ std::list<int, other_allocator<int> > l2 = l;
+ assert(l2 == l);
+ assert(l2.get_allocator() == other_allocator<int>(-2));
+ }
+#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE
+#if __cplusplus >= 201103L
+ {
+ std::list<int, min_allocator<int>> l(3, 2);
+ std::list<int, min_allocator<int>> l2 = l;
+ assert(l2 == l);
+ }
+ {
+ std::list<int, min_allocator<int> > l(3, 2, min_allocator<int>());
+ std::list<int, min_allocator<int> > l2 = l;
+ assert(l2 == l);
+ assert(l2.get_allocator() == l.get_allocator());
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/list/list.cons/copy_alloc.pass.cpp b/test/std/containers/sequences/list/list.cons/copy_alloc.pass.cpp
new file mode 100644
index 000000000000..99fe9f115f94
--- /dev/null
+++ b/test/std/containers/sequences/list/list.cons/copy_alloc.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// list(const list& c, const allocator_type& a);
+
+#include <list>
+#include <cassert>
+#include "DefaultOnly.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::list<int, test_allocator<int> > l(3, 2, test_allocator<int>(5));
+ std::list<int, test_allocator<int> > l2(l, test_allocator<int>(3));
+ assert(l2 == l);
+ assert(l2.get_allocator() == test_allocator<int>(3));
+ }
+ {
+ std::list<int, other_allocator<int> > l(3, 2, other_allocator<int>(5));
+ std::list<int, other_allocator<int> > l2(l, other_allocator<int>(3));
+ assert(l2 == l);
+ assert(l2.get_allocator() == other_allocator<int>(3));
+ }
+#if __cplusplus >= 201103L
+ {
+ std::list<int, min_allocator<int> > l(3, 2, min_allocator<int>());
+ std::list<int, min_allocator<int> > l2(l, min_allocator<int>());
+ assert(l2 == l);
+ assert(l2.get_allocator() == min_allocator<int>());
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/list/list.cons/default.pass.cpp b/test/std/containers/sequences/list/list.cons/default.pass.cpp
new file mode 100644
index 000000000000..c05bd74ca79e
--- /dev/null
+++ b/test/std/containers/sequences/list/list.cons/default.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// explicit list(const Alloc& = Alloc());
+
+#include <list>
+#include <cassert>
+#include "DefaultOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::list<int> l;
+ assert(l.size() == 0);
+ assert(std::distance(l.begin(), l.end()) == 0);
+ }
+ {
+ std::list<DefaultOnly> l;
+ assert(l.size() == 0);
+ assert(std::distance(l.begin(), l.end()) == 0);
+ }
+ {
+ std::list<int> l((std::allocator<int>()));
+ assert(l.size() == 0);
+ assert(std::distance(l.begin(), l.end()) == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::list<int, min_allocator<int>> l;
+ assert(l.size() == 0);
+ assert(std::distance(l.begin(), l.end()) == 0);
+ }
+ {
+ std::list<DefaultOnly, min_allocator<DefaultOnly>> l;
+ assert(l.size() == 0);
+ assert(std::distance(l.begin(), l.end()) == 0);
+ }
+ {
+ std::list<int, min_allocator<int>> l((min_allocator<int>()));
+ assert(l.size() == 0);
+ assert(std::distance(l.begin(), l.end()) == 0);
+ }
+ {
+ std::list<int> l = {};
+ assert(l.size() == 0);
+ assert(std::distance(l.begin(), l.end()) == 0);
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/list/list.cons/default_noexcept.pass.cpp b/test/std/containers/sequences/list/list.cons/default_noexcept.pass.cpp
new file mode 100644
index 000000000000..2455fb39a79a
--- /dev/null
+++ b/test/std/containers/sequences/list/list.cons/default_noexcept.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// list()
+// noexcept(is_nothrow_default_constructible<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <list>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_alloc
+{
+ typedef T value_type;
+ some_alloc(const some_alloc&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::list<MoveOnly> C;
+ static_assert(std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::list<MoveOnly, test_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::list<MoveOnly, other_allocator<MoveOnly>> C;
+ static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::list<MoveOnly, some_alloc<MoveOnly>> C;
+ static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/list/list.cons/default_stack_alloc.pass.cpp b/test/std/containers/sequences/list/list.cons/default_stack_alloc.pass.cpp
new file mode 100644
index 000000000000..9d9946b68966
--- /dev/null
+++ b/test/std/containers/sequences/list/list.cons/default_stack_alloc.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// explicit list(const Alloc& = Alloc());
+
+#include <list>
+#include <cassert>
+#include "../../../stack_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::list<int> l;
+ assert(l.size() == 0);
+ assert(std::distance(l.begin(), l.end()) == 0);
+ }
+ {
+ std::list<int> l((std::allocator<int>()));
+ assert(l.size() == 0);
+ assert(std::distance(l.begin(), l.end()) == 0);
+ }
+ {
+ std::list<int, stack_allocator<int, 4> > l;
+ assert(l.size() == 0);
+ assert(std::distance(l.begin(), l.end()) == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::list<int, min_allocator<int>> l;
+ assert(l.size() == 0);
+ assert(std::distance(l.begin(), l.end()) == 0);
+ }
+ {
+ std::list<int, min_allocator<int>> l((min_allocator<int>()));
+ assert(l.size() == 0);
+ assert(std::distance(l.begin(), l.end()) == 0);
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/list/list.cons/dtor_noexcept.pass.cpp b/test/std/containers/sequences/list/list.cons/dtor_noexcept.pass.cpp
new file mode 100644
index 000000000000..ca7ade6d19cb
--- /dev/null
+++ b/test/std/containers/sequences/list/list.cons/dtor_noexcept.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// ~list() // implied noexcept;
+
+#include <list>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "test_allocator.h"
+
+#if __has_feature(cxx_noexcept)
+
+template <class T>
+struct some_alloc
+{
+ typedef T value_type;
+ some_alloc(const some_alloc&);
+ ~some_alloc() noexcept(false);
+};
+
+#endif
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::list<MoveOnly> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::list<MoveOnly, test_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::list<MoveOnly, other_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::list<MoveOnly, some_alloc<MoveOnly>> C;
+ static_assert(!std::is_nothrow_destructible<C>::value, "");
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/list/list.cons/initializer_list.pass.cpp b/test/std/containers/sequences/list/list.cons/initializer_list.pass.cpp
new file mode 100644
index 000000000000..3307017989eb
--- /dev/null
+++ b/test/std/containers/sequences/list/list.cons/initializer_list.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// list(initializer_list<value_type> il);
+
+#include <list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ std::list<int> d = {3, 4, 5, 6};
+ assert(d.size() == 4);
+ std::list<int>::iterator i = d.begin();
+ assert(*i++ == 3);
+ assert(*i++ == 4);
+ assert(*i++ == 5);
+ assert(*i++ == 6);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::list<int, min_allocator<int>> d = {3, 4, 5, 6};
+ assert(d.size() == 4);
+ std::list<int, min_allocator<int>>::iterator i = d.begin();
+ assert(*i++ == 3);
+ assert(*i++ == 4);
+ assert(*i++ == 5);
+ assert(*i++ == 6);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/containers/sequences/list/list.cons/initializer_list_alloc.pass.cpp b/test/std/containers/sequences/list/list.cons/initializer_list_alloc.pass.cpp
new file mode 100644
index 000000000000..4a85e378c1ce
--- /dev/null
+++ b/test/std/containers/sequences/list/list.cons/initializer_list_alloc.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// list(initializer_list<value_type> il, const Allocator& a = allocator_type());
+
+#include <list>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ std::list<int, test_allocator<int>> d({3, 4, 5, 6}, test_allocator<int>(3));
+ assert(d.get_allocator() == test_allocator<int>(3));
+ assert(d.size() == 4);
+ std::list<int>::iterator i = d.begin();
+ assert(*i++ == 3);
+ assert(*i++ == 4);
+ assert(*i++ == 5);
+ assert(*i++ == 6);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::list<int, min_allocator<int>> d({3, 4, 5, 6}, min_allocator<int>());
+ assert(d.get_allocator() == min_allocator<int>());
+ assert(d.size() == 4);
+ std::list<int, min_allocator<int>>::iterator i = d.begin();
+ assert(*i++ == 3);
+ assert(*i++ == 4);
+ assert(*i++ == 5);
+ assert(*i++ == 6);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/containers/sequences/list/list.cons/input_iterator.pass.cpp b/test/std/containers/sequences/list/list.cons/input_iterator.pass.cpp
new file mode 100644
index 000000000000..09eae8ab43c1
--- /dev/null
+++ b/test/std/containers/sequences/list/list.cons/input_iterator.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// template <class InputIterator>
+// list(InputIterator first, InputIterator last, const Allocator& = Allocator());
+
+#include <list>
+#include <cassert>
+#include "test_iterators.h"
+#include "../../../stack_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ int a[] = {0, 1, 2, 3};
+ std::list<int> l(input_iterator<const int*>(a),
+ input_iterator<const int*>(a + sizeof(a)/sizeof(a[0])));
+ assert(l.size() == sizeof(a)/sizeof(a[0]));
+ assert(std::distance(l.begin(), l.end()) == sizeof(a)/sizeof(a[0]));
+ int j = 0;
+ for (std::list<int>::const_iterator i = l.begin(), e = l.end(); i != e; ++i, ++j)
+ assert(*i == j);
+ }
+ {
+ int a[] = {0, 1, 2, 3};
+ std::list<int> l(input_iterator<const int*>(a),
+ input_iterator<const int*>(a + sizeof(a)/sizeof(a[0])),
+ std::allocator<int>());
+ assert(l.size() == sizeof(a)/sizeof(a[0]));
+ assert(std::distance(l.begin(), l.end()) == sizeof(a)/sizeof(a[0]));
+ int j = 0;
+ for (std::list<int>::const_iterator i = l.begin(), e = l.end(); i != e; ++i, ++j)
+ assert(*i == j);
+ }
+ {
+ int a[] = {0, 1, 2, 3};
+ std::list<int, stack_allocator<int, sizeof(a)/sizeof(a[0])> > l(input_iterator<const int*>(a),
+ input_iterator<const int*>(a + sizeof(a)/sizeof(a[0])));
+ assert(l.size() == sizeof(a)/sizeof(a[0]));
+ assert(std::distance(l.begin(), l.end()) == sizeof(a)/sizeof(a[0]));
+ int j = 0;
+ for (std::list<int>::const_iterator i = l.begin(), e = l.end(); i != e; ++i, ++j)
+ assert(*i == j);
+ }
+#if __cplusplus >= 201103L
+ {
+ int a[] = {0, 1, 2, 3};
+ std::list<int, min_allocator<int>> l(input_iterator<const int*>(a),
+ input_iterator<const int*>(a + sizeof(a)/sizeof(a[0])));
+ assert(l.size() == sizeof(a)/sizeof(a[0]));
+ assert(std::distance(l.begin(), l.end()) == sizeof(a)/sizeof(a[0]));
+ int j = 0;
+ for (std::list<int, min_allocator<int>>::const_iterator i = l.begin(), e = l.end(); i != e; ++i, ++j)
+ assert(*i == j);
+ }
+ {
+ int a[] = {0, 1, 2, 3};
+ std::list<int, min_allocator<int>> l(input_iterator<const int*>(a),
+ input_iterator<const int*>(a + sizeof(a)/sizeof(a[0])),
+ min_allocator<int>());
+ assert(l.size() == sizeof(a)/sizeof(a[0]));
+ assert(std::distance(l.begin(), l.end()) == sizeof(a)/sizeof(a[0]));
+ int j = 0;
+ for (std::list<int, min_allocator<int>>::const_iterator i = l.begin(), e = l.end(); i != e; ++i, ++j)
+ assert(*i == j);
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/list/list.cons/move.pass.cpp b/test/std/containers/sequences/list/list.cons/move.pass.cpp
new file mode 100644
index 000000000000..54209a55f7e2
--- /dev/null
+++ b/test/std/containers/sequences/list/list.cons/move.pass.cpp
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// list(list&& c);
+
+#include <list>
+#include <cassert>
+#include "MoveOnly.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::list<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5));
+ std::list<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5));
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ std::list<MoveOnly, test_allocator<MoveOnly> > l2 = std::move(l);
+ assert(l2 == lo);
+ assert(l.empty());
+ assert(l2.get_allocator() == lo.get_allocator());
+ }
+ {
+ std::list<MoveOnly, other_allocator<MoveOnly> > l(other_allocator<MoveOnly>(5));
+ std::list<MoveOnly, other_allocator<MoveOnly> > lo(other_allocator<MoveOnly>(5));
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ std::list<MoveOnly, other_allocator<MoveOnly> > l2 = std::move(l);
+ assert(l2 == lo);
+ assert(l.empty());
+ assert(l2.get_allocator() == lo.get_allocator());
+ }
+#if __cplusplus >= 201103L
+ {
+ std::list<MoveOnly, min_allocator<MoveOnly> > l(min_allocator<MoveOnly>{});
+ std::list<MoveOnly, min_allocator<MoveOnly> > lo(min_allocator<MoveOnly>{});
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ std::list<MoveOnly, min_allocator<MoveOnly> > l2 = std::move(l);
+ assert(l2 == lo);
+ assert(l.empty());
+ assert(l2.get_allocator() == lo.get_allocator());
+ }
+#endif
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::list<int> l1 = {1, 2, 3};
+ std::list<int>::iterator i = l1.begin();
+ std::list<int> l2 = std::move(l1);
+ assert(*l2.erase(i) == 2);
+ assert(l2.size() == 2);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/sequences/list/list.cons/move_alloc.pass.cpp b/test/std/containers/sequences/list/list.cons/move_alloc.pass.cpp
new file mode 100644
index 000000000000..8f82702b296f
--- /dev/null
+++ b/test/std/containers/sequences/list/list.cons/move_alloc.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// list(list&& c, const allocator_type& a);
+
+#include <list>
+#include <cassert>
+#include "MoveOnly.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::list<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5));
+ std::list<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5));
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ std::list<MoveOnly, test_allocator<MoveOnly> > l2(std::move(l), test_allocator<MoveOnly>(6));
+ assert(l2 == lo);
+ assert(!l.empty());
+ assert(l2.get_allocator() == test_allocator<MoveOnly>(6));
+ }
+ {
+ std::list<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5));
+ std::list<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5));
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ std::list<MoveOnly, test_allocator<MoveOnly> > l2(std::move(l), test_allocator<MoveOnly>(5));
+ assert(l2 == lo);
+ assert(l.empty());
+ assert(l2.get_allocator() == test_allocator<MoveOnly>(5));
+ }
+ {
+ std::list<MoveOnly, other_allocator<MoveOnly> > l(other_allocator<MoveOnly>(5));
+ std::list<MoveOnly, other_allocator<MoveOnly> > lo(other_allocator<MoveOnly>(5));
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ std::list<MoveOnly, other_allocator<MoveOnly> > l2(std::move(l), other_allocator<MoveOnly>(4));
+ assert(l2 == lo);
+ assert(!l.empty());
+ assert(l2.get_allocator() == other_allocator<MoveOnly>(4));
+ }
+#if __cplusplus >= 201103L
+ {
+ std::list<MoveOnly, min_allocator<MoveOnly> > l(min_allocator<MoveOnly>{});
+ std::list<MoveOnly, min_allocator<MoveOnly> > lo(min_allocator<MoveOnly>{});
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ std::list<MoveOnly, min_allocator<MoveOnly> > l2(std::move(l), min_allocator<MoveOnly>());
+ assert(l2 == lo);
+ assert(l.empty());
+ assert(l2.get_allocator() == min_allocator<MoveOnly>());
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/sequences/list/list.cons/move_assign_noexcept.pass.cpp b/test/std/containers/sequences/list/list.cons/move_assign_noexcept.pass.cpp
new file mode 100644
index 000000000000..280d93d486e6
--- /dev/null
+++ b/test/std/containers/sequences/list/list.cons/move_assign_noexcept.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// list& operator=(list&& c)
+// noexcept(
+// allocator_type::propagate_on_container_move_assignment::value &&
+// is_nothrow_move_assignable<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <list>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_alloc
+{
+ typedef T value_type;
+ some_alloc(const some_alloc&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::list<MoveOnly> C;
+ static_assert(std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::list<MoveOnly, test_allocator<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::list<MoveOnly, other_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::list<MoveOnly, some_alloc<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/list/list.cons/move_noexcept.pass.cpp b/test/std/containers/sequences/list/list.cons/move_noexcept.pass.cpp
new file mode 100644
index 000000000000..e436a29f5d47
--- /dev/null
+++ b/test/std/containers/sequences/list/list.cons/move_noexcept.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// list(list&&)
+// noexcept(is_nothrow_move_constructible<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <list>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_alloc
+{
+ typedef T value_type;
+ some_alloc(const some_alloc&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::list<MoveOnly> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::list<MoveOnly, test_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::list<MoveOnly, other_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::list<MoveOnly, some_alloc<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_constructible<C>::value, "");
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/list/list.cons/op_equal_initializer_list.pass.cpp b/test/std/containers/sequences/list/list.cons/op_equal_initializer_list.pass.cpp
new file mode 100644
index 000000000000..7b7b8a327b88
--- /dev/null
+++ b/test/std/containers/sequences/list/list.cons/op_equal_initializer_list.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// list& operator=(initializer_list<value_type> il);
+
+#include <list>
+#include <cassert>
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ std::list<int> d;
+ d = {3, 4, 5, 6};
+ assert(d.size() == 4);
+ std::list<int>::iterator i = d.begin();
+ assert(*i++ == 3);
+ assert(*i++ == 4);
+ assert(*i++ == 5);
+ assert(*i++ == 6);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::list<int, min_allocator<int>> d;
+ d = {3, 4, 5, 6};
+ assert(d.size() == 4);
+ std::list<int, min_allocator<int>>::iterator i = d.begin();
+ assert(*i++ == 3);
+ assert(*i++ == 4);
+ assert(*i++ == 5);
+ assert(*i++ == 6);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/containers/sequences/list/list.cons/size_type.pass.cpp b/test/std/containers/sequences/list/list.cons/size_type.pass.cpp
new file mode 100644
index 000000000000..75b93a3dfb6b
--- /dev/null
+++ b/test/std/containers/sequences/list/list.cons/size_type.pass.cpp
@@ -0,0 +1,103 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// explicit list(size_type n);
+
+#include <list>
+#include <cassert>
+#include "DefaultOnly.h"
+#include "../../../stack_allocator.h"
+#include "min_allocator.h"
+
+template <class T, class Allocator>
+void
+test3(unsigned n, Allocator const &alloc = Allocator())
+{
+#if _LIBCPP_STD_VER > 11
+ typedef std::list<T, Allocator> C;
+ typedef typename C::const_iterator const_iterator;
+ {
+ C d(n, alloc);
+ assert(d.size() == n);
+ assert(std::distance(d.begin(), d.end()) == n);
+ assert(d.get_allocator() == alloc);
+ }
+#endif
+}
+
+
+int main()
+{
+ {
+ std::list<int> l(3);
+ assert(l.size() == 3);
+ assert(std::distance(l.begin(), l.end()) == 3);
+ std::list<int>::const_iterator i = l.begin();
+ assert(*i == 0);
+ ++i;
+ assert(*i == 0);
+ ++i;
+ assert(*i == 0);
+ }
+ {
+ std::list<int, stack_allocator<int, 3> > l(3);
+ assert(l.size() == 3);
+ assert(std::distance(l.begin(), l.end()) == 3);
+ std::list<int>::const_iterator i = l.begin();
+ assert(*i == 0);
+ ++i;
+ assert(*i == 0);
+ ++i;
+ assert(*i == 0);
+ }
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::list<int, min_allocator<int> > C;
+ C l(3, min_allocator<int> ());
+ assert(l.size() == 3);
+ assert(std::distance(l.begin(), l.end()) == 3);
+ C::const_iterator i = l.begin();
+ assert(*i == 0);
+ ++i;
+ assert(*i == 0);
+ ++i;
+ assert(*i == 0);
+ test3<int, min_allocator<int>> (3);
+ }
+#endif
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::list<DefaultOnly> l(3);
+ assert(l.size() == 3);
+ assert(std::distance(l.begin(), l.end()) == 3);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if __cplusplus >= 201103L
+ {
+ std::list<int, min_allocator<int>> l(3);
+ assert(l.size() == 3);
+ assert(std::distance(l.begin(), l.end()) == 3);
+ std::list<int, min_allocator<int>>::const_iterator i = l.begin();
+ assert(*i == 0);
+ ++i;
+ assert(*i == 0);
+ ++i;
+ assert(*i == 0);
+ }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::list<DefaultOnly, min_allocator<DefaultOnly>> l(3);
+ assert(l.size() == 3);
+ assert(std::distance(l.begin(), l.end()) == 3);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif
+}
diff --git a/test/std/containers/sequences/list/list.cons/size_value_alloc.pass.cpp b/test/std/containers/sequences/list/list.cons/size_value_alloc.pass.cpp
new file mode 100644
index 000000000000..12da86da0a41
--- /dev/null
+++ b/test/std/containers/sequences/list/list.cons/size_value_alloc.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// list(size_type n, const T& value, const Allocator& = Allocator());
+
+#include <list>
+#include <cassert>
+#include "DefaultOnly.h"
+#include "../../../stack_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::list<int> l(3, 2);
+ assert(l.size() == 3);
+ assert(std::distance(l.begin(), l.end()) == 3);
+ std::list<int>::const_iterator i = l.begin();
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+ }
+ {
+ std::list<int> l(3, 2, std::allocator<int>());
+ assert(l.size() == 3);
+ assert(std::distance(l.begin(), l.end()) == 3);
+ std::list<int>::const_iterator i = l.begin();
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+ }
+ {
+ std::list<int, stack_allocator<int, 3> > l(3, 2);
+ assert(l.size() == 3);
+ assert(std::distance(l.begin(), l.end()) == 3);
+ std::list<int>::const_iterator i = l.begin();
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::list<int, min_allocator<int>> l(3, 2);
+ assert(l.size() == 3);
+ assert(std::distance(l.begin(), l.end()) == 3);
+ std::list<int, min_allocator<int>>::const_iterator i = l.begin();
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+ }
+ {
+ std::list<int, min_allocator<int>> l(3, 2, min_allocator<int>());
+ assert(l.size() == 3);
+ assert(std::distance(l.begin(), l.end()) == 3);
+ std::list<int, min_allocator<int>>::const_iterator i = l.begin();
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/list/list.modifiers/clear.pass.cpp b/test/std/containers/sequences/list/list.modifiers/clear.pass.cpp
new file mode 100644
index 000000000000..38696b6eb503
--- /dev/null
+++ b/test/std/containers/sequences/list/list.modifiers/clear.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void clear();
+
+#include <list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ int a[] = {1, 2, 3};
+ std::list<int> c(a, a+3);
+ c.clear();
+ assert(c.empty());
+ }
+#if __cplusplus >= 201103L
+ {
+ int a[] = {1, 2, 3};
+ std::list<int, min_allocator<int>> c(a, a+3);
+ c.clear();
+ assert(c.empty());
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/list/list.modifiers/emplace.pass.cpp b/test/std/containers/sequences/list/list.modifiers/emplace.pass.cpp
new file mode 100644
index 000000000000..6476d1d6c6ae
--- /dev/null
+++ b/test/std/containers/sequences/list/list.modifiers/emplace.pass.cpp
@@ -0,0 +1,88 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// template <class... Args> void emplace(const_iterator p, Args&&... args);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+class A
+{
+ int i_;
+ double d_;
+
+ A(const A&);
+ A& operator=(const A&);
+public:
+ A(int i, double d)
+ : i_(i), d_(d) {}
+
+ int geti() const {return i_;}
+ double getd() const {return d_;}
+};
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::list<A> c;
+ c.emplace(c.cbegin(), 2, 3.5);
+ assert(c.size() == 1);
+ assert(c.front().geti() == 2);
+ assert(c.front().getd() == 3.5);
+ c.emplace(c.cend(), 3, 4.5);
+ assert(c.size() == 2);
+ assert(c.front().geti() == 2);
+ assert(c.front().getd() == 3.5);
+ assert(c.back().geti() == 3);
+ assert(c.back().getd() == 4.5);
+ }
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::list<A> c1;
+ std::list<A> c2;
+ std::list<A>::iterator i = c1.emplace(c2.cbegin(), 2, 3.5);
+ assert(false);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if __cplusplus >= 201103L
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::list<A, min_allocator<A>> c;
+ c.emplace(c.cbegin(), 2, 3.5);
+ assert(c.size() == 1);
+ assert(c.front().geti() == 2);
+ assert(c.front().getd() == 3.5);
+ c.emplace(c.cend(), 3, 4.5);
+ assert(c.size() == 2);
+ assert(c.front().geti() == 2);
+ assert(c.front().getd() == 3.5);
+ assert(c.back().geti() == 3);
+ assert(c.back().getd() == 4.5);
+ }
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::list<A, min_allocator<A>> c1;
+ std::list<A, min_allocator<A>> c2;
+ std::list<A, min_allocator<A>>::iterator i = c1.emplace(c2.cbegin(), 2, 3.5);
+ assert(false);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif
+}
diff --git a/test/std/containers/sequences/list/list.modifiers/emplace_back.pass.cpp b/test/std/containers/sequences/list/list.modifiers/emplace_back.pass.cpp
new file mode 100644
index 000000000000..5983efc59ad1
--- /dev/null
+++ b/test/std/containers/sequences/list/list.modifiers/emplace_back.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// template <class... Args> void emplace_back(Args&&... args);
+
+#include <list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+class A
+{
+ int i_;
+ double d_;
+
+ A(const A&);
+ A& operator=(const A&);
+public:
+ A(int i, double d)
+ : i_(i), d_(d) {}
+
+ int geti() const {return i_;}
+ double getd() const {return d_;}
+};
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::list<A> c;
+ c.emplace_back(2, 3.5);
+ assert(c.size() == 1);
+ assert(c.front().geti() == 2);
+ assert(c.front().getd() == 3.5);
+ c.emplace_back(3, 4.5);
+ assert(c.size() == 2);
+ assert(c.front().geti() == 2);
+ assert(c.front().getd() == 3.5);
+ assert(c.back().geti() == 3);
+ assert(c.back().getd() == 4.5);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::list<A, min_allocator<A>> c;
+ c.emplace_back(2, 3.5);
+ assert(c.size() == 1);
+ assert(c.front().geti() == 2);
+ assert(c.front().getd() == 3.5);
+ c.emplace_back(3, 4.5);
+ assert(c.size() == 2);
+ assert(c.front().geti() == 2);
+ assert(c.front().getd() == 3.5);
+ assert(c.back().geti() == 3);
+ assert(c.back().getd() == 4.5);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/sequences/list/list.modifiers/emplace_front.pass.cpp b/test/std/containers/sequences/list/list.modifiers/emplace_front.pass.cpp
new file mode 100644
index 000000000000..e2e68e331381
--- /dev/null
+++ b/test/std/containers/sequences/list/list.modifiers/emplace_front.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// template <class... Args> void emplace_front(Args&&... args);
+
+#include <list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+class A
+{
+ int i_;
+ double d_;
+
+ A(const A&);
+ A& operator=(const A&);
+public:
+ A(int i, double d)
+ : i_(i), d_(d) {}
+
+ int geti() const {return i_;}
+ double getd() const {return d_;}
+};
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::list<A> c;
+ c.emplace_front(2, 3.5);
+ assert(c.size() == 1);
+ assert(c.front().geti() == 2);
+ assert(c.front().getd() == 3.5);
+ c.emplace_front(3, 4.5);
+ assert(c.size() == 2);
+ assert(c.front().geti() == 3);
+ assert(c.front().getd() == 4.5);
+ assert(c.back().geti() == 2);
+ assert(c.back().getd() == 3.5);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::list<A, min_allocator<A>> c;
+ c.emplace_front(2, 3.5);
+ assert(c.size() == 1);
+ assert(c.front().geti() == 2);
+ assert(c.front().getd() == 3.5);
+ c.emplace_front(3, 4.5);
+ assert(c.size() == 2);
+ assert(c.front().geti() == 3);
+ assert(c.front().getd() == 4.5);
+ assert(c.back().geti() == 2);
+ assert(c.back().getd() == 3.5);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/sequences/list/list.modifiers/erase_iter.pass.cpp b/test/std/containers/sequences/list/list.modifiers/erase_iter.pass.cpp
new file mode 100644
index 000000000000..c1cc90043670
--- /dev/null
+++ b/test/std/containers/sequences/list/list.modifiers/erase_iter.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// iterator erase(const_iterator position);
+
+#include <list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ int a1[] = {1, 2, 3};
+ std::list<int> l1(a1, a1+3);
+ std::list<int>::const_iterator i = l1.begin();
+ ++i;
+ std::list<int>::iterator j = l1.erase(i);
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ assert(*j == 3);
+ assert(*l1.begin() == 1);
+ assert(*next(l1.begin()) == 3);
+ j = l1.erase(j);
+ assert(j == l1.end());
+ assert(l1.size() == 1);
+ assert(distance(l1.begin(), l1.end()) == 1);
+ assert(*l1.begin() == 1);
+ j = l1.erase(l1.begin());
+ assert(j == l1.end());
+ assert(l1.size() == 0);
+ assert(distance(l1.begin(), l1.end()) == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ int a1[] = {1, 2, 3};
+ std::list<int, min_allocator<int>> l1(a1, a1+3);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ ++i;
+ std::list<int, min_allocator<int>>::iterator j = l1.erase(i);
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ assert(*j == 3);
+ assert(*l1.begin() == 1);
+ assert(*next(l1.begin()) == 3);
+ j = l1.erase(j);
+ assert(j == l1.end());
+ assert(l1.size() == 1);
+ assert(distance(l1.begin(), l1.end()) == 1);
+ assert(*l1.begin() == 1);
+ j = l1.erase(l1.begin());
+ assert(j == l1.end());
+ assert(l1.size() == 0);
+ assert(distance(l1.begin(), l1.end()) == 0);
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/list/list.modifiers/erase_iter_db1.pass.cpp b/test/std/containers/sequences/list/list.modifiers/erase_iter_db1.pass.cpp
new file mode 100644
index 000000000000..18c15eb02c85
--- /dev/null
+++ b/test/std/containers/sequences/list/list.modifiers/erase_iter_db1.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// Call erase(const_iterator position) with end()
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <list>
+#include <cassert>
+#include <cstdlib>
+#include <exception>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ int a1[] = {1, 2, 3};
+ std::list<int> l1(a1, a1+3);
+ std::list<int>::const_iterator i = l1.end();
+ l1.erase(i);
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ int a1[] = {1, 2, 3};
+ std::list<int, min_allocator<int>> l1(a1, a1+3);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.end();
+ l1.erase(i);
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/containers/sequences/list/list.modifiers/erase_iter_db2.pass.cpp b/test/std/containers/sequences/list/list.modifiers/erase_iter_db2.pass.cpp
new file mode 100644
index 000000000000..61ff8409c964
--- /dev/null
+++ b/test/std/containers/sequences/list/list.modifiers/erase_iter_db2.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// Call erase(const_iterator position) with iterator from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <list>
+#include <cassert>
+#include <cstdlib>
+#include <exception>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ int a1[] = {1, 2, 3};
+ std::list<int> l1(a1, a1+3);
+ std::list<int> l2(a1, a1+3);
+ std::list<int>::const_iterator i = l2.begin();
+ l1.erase(i);
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ int a1[] = {1, 2, 3};
+ std::list<int, min_allocator<int>> l1(a1, a1+3);
+ std::list<int, min_allocator<int>> l2(a1, a1+3);
+ std::list<int, min_allocator<int>>::const_iterator i = l2.begin();
+ l1.erase(i);
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/containers/sequences/list/list.modifiers/erase_iter_iter.pass.cpp b/test/std/containers/sequences/list/list.modifiers/erase_iter_iter.pass.cpp
new file mode 100644
index 000000000000..bd3f66b4116a
--- /dev/null
+++ b/test/std/containers/sequences/list/list.modifiers/erase_iter_iter.pass.cpp
@@ -0,0 +1,84 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// iterator erase(const_iterator first, const_iterator last);
+
+#include <list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ int a1[] = {1, 2, 3};
+ {
+ std::list<int> l1(a1, a1+3);
+ std::list<int>::iterator i = l1.erase(l1.cbegin(), l1.cbegin());
+ assert(l1.size() == 3);
+ assert(distance(l1.cbegin(), l1.cend()) == 3);
+ assert(i == l1.begin());
+ }
+ {
+ std::list<int> l1(a1, a1+3);
+ std::list<int>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin()));
+ assert(l1.size() == 2);
+ assert(distance(l1.cbegin(), l1.cend()) == 2);
+ assert(i == l1.begin());
+ assert(l1 == std::list<int>(a1+1, a1+3));
+ }
+ {
+ std::list<int> l1(a1, a1+3);
+ std::list<int>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin(), 2));
+ assert(l1.size() == 1);
+ assert(distance(l1.cbegin(), l1.cend()) == 1);
+ assert(i == l1.begin());
+ assert(l1 == std::list<int>(a1+2, a1+3));
+ }
+ {
+ std::list<int> l1(a1, a1+3);
+ std::list<int>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin(), 3));
+ assert(l1.size() == 0);
+ assert(distance(l1.cbegin(), l1.cend()) == 0);
+ assert(i == l1.begin());
+ }
+#if __cplusplus >= 201103L
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+3);
+ std::list<int, min_allocator<int>>::iterator i = l1.erase(l1.cbegin(), l1.cbegin());
+ assert(l1.size() == 3);
+ assert(distance(l1.cbegin(), l1.cend()) == 3);
+ assert(i == l1.begin());
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+3);
+ std::list<int, min_allocator<int>>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin()));
+ assert(l1.size() == 2);
+ assert(distance(l1.cbegin(), l1.cend()) == 2);
+ assert(i == l1.begin());
+ assert((l1 == std::list<int, min_allocator<int>>(a1+1, a1+3)));
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+3);
+ std::list<int, min_allocator<int>>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin(), 2));
+ assert(l1.size() == 1);
+ assert(distance(l1.cbegin(), l1.cend()) == 1);
+ assert(i == l1.begin());
+ assert((l1 == std::list<int, min_allocator<int>>(a1+2, a1+3)));
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+3);
+ std::list<int, min_allocator<int>>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin(), 3));
+ assert(l1.size() == 0);
+ assert(distance(l1.cbegin(), l1.cend()) == 0);
+ assert(i == l1.begin());
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/list/list.modifiers/erase_iter_iter_db1.pass.cpp b/test/std/containers/sequences/list/list.modifiers/erase_iter_iter_db1.pass.cpp
new file mode 100644
index 000000000000..71ad497e7d97
--- /dev/null
+++ b/test/std/containers/sequences/list/list.modifiers/erase_iter_iter_db1.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// Call erase(const_iterator first, const_iterator last); with first iterator from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <list>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ int a1[] = {1, 2, 3};
+ std::list<int> l1(a1, a1+3);
+ std::list<int> l2(a1, a1+3);
+ std::list<int>::iterator i = l1.erase(l2.cbegin(), next(l1.cbegin()));
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ int a1[] = {1, 2, 3};
+ std::list<int, min_allocator<int>> l1(a1, a1+3);
+ std::list<int, min_allocator<int>> l2(a1, a1+3);
+ std::list<int, min_allocator<int>>::iterator i = l1.erase(l2.cbegin(), next(l1.cbegin()));
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/containers/sequences/list/list.modifiers/erase_iter_iter_db2.pass.cpp b/test/std/containers/sequences/list/list.modifiers/erase_iter_iter_db2.pass.cpp
new file mode 100644
index 000000000000..db76b4de4865
--- /dev/null
+++ b/test/std/containers/sequences/list/list.modifiers/erase_iter_iter_db2.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// Call erase(const_iterator first, const_iterator last); with second iterator from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <list>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ int a1[] = {1, 2, 3};
+ std::list<int> l1(a1, a1+3);
+ std::list<int> l2(a1, a1+3);
+ std::list<int>::iterator i = l1.erase(l1.cbegin(), next(l2.cbegin()));
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ int a1[] = {1, 2, 3};
+ std::list<int, min_allocator<int>> l1(a1, a1+3);
+ std::list<int, min_allocator<int>> l2(a1, a1+3);
+ std::list<int, min_allocator<int>>::iterator i = l1.erase(l1.cbegin(), next(l2.cbegin()));
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/containers/sequences/list/list.modifiers/erase_iter_iter_db3.pass.cpp b/test/std/containers/sequences/list/list.modifiers/erase_iter_iter_db3.pass.cpp
new file mode 100644
index 000000000000..25c5c6147a01
--- /dev/null
+++ b/test/std/containers/sequences/list/list.modifiers/erase_iter_iter_db3.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// Call erase(const_iterator first, const_iterator last); with both iterators from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <list>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ int a1[] = {1, 2, 3};
+ std::list<int> l1(a1, a1+3);
+ std::list<int> l2(a1, a1+3);
+ std::list<int>::iterator i = l1.erase(l2.cbegin(), next(l2.cbegin()));
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ int a1[] = {1, 2, 3};
+ std::list<int, min_allocator<int>> l1(a1, a1+3);
+ std::list<int, min_allocator<int>> l2(a1, a1+3);
+ std::list<int, min_allocator<int>>::iterator i = l1.erase(l2.cbegin(), next(l2.cbegin()));
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/containers/sequences/list/list.modifiers/erase_iter_iter_db4.pass.cpp b/test/std/containers/sequences/list/list.modifiers/erase_iter_iter_db4.pass.cpp
new file mode 100644
index 000000000000..35a4ceb4848a
--- /dev/null
+++ b/test/std/containers/sequences/list/list.modifiers/erase_iter_iter_db4.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// Call erase(const_iterator first, const_iterator last); with a bad range
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <list>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ int a1[] = {1, 2, 3};
+ std::list<int> l1(a1, a1+3);
+ std::list<int>::iterator i = l1.erase(next(l1.cbegin()), l1.cbegin());
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ int a1[] = {1, 2, 3};
+ std::list<int, min_allocator<int>> l1(a1, a1+3);
+ std::list<int, min_allocator<int>>::iterator i = l1.erase(next(l1.cbegin()), l1.cbegin());
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/containers/sequences/list/list.modifiers/insert_iter_initializer_list.pass.cpp b/test/std/containers/sequences/list/list.modifiers/insert_iter_initializer_list.pass.cpp
new file mode 100644
index 000000000000..a82a2696e82a
--- /dev/null
+++ b/test/std/containers/sequences/list/list.modifiers/insert_iter_initializer_list.pass.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// iterator insert(const_iterator p, initializer_list<value_type> il);
+
+#include <list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ std::list<int> d(10, 1);
+ std::list<int>::iterator i = d.insert(next(d.cbegin(), 2), {3, 4, 5, 6});
+ assert(d.size() == 14);
+ assert(i == next(d.begin(), 2));
+ i = d.begin();
+ assert(*i++ == 1);
+ assert(*i++ == 1);
+ assert(*i++ == 3);
+ assert(*i++ == 4);
+ assert(*i++ == 5);
+ assert(*i++ == 6);
+ assert(*i++ == 1);
+ assert(*i++ == 1);
+ assert(*i++ == 1);
+ assert(*i++ == 1);
+ assert(*i++ == 1);
+ assert(*i++ == 1);
+ assert(*i++ == 1);
+ assert(*i++ == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::list<int, min_allocator<int>> d(10, 1);
+ std::list<int, min_allocator<int>>::iterator i = d.insert(next(d.cbegin(), 2), {3, 4, 5, 6});
+ assert(d.size() == 14);
+ assert(i == next(d.begin(), 2));
+ i = d.begin();
+ assert(*i++ == 1);
+ assert(*i++ == 1);
+ assert(*i++ == 3);
+ assert(*i++ == 4);
+ assert(*i++ == 5);
+ assert(*i++ == 6);
+ assert(*i++ == 1);
+ assert(*i++ == 1);
+ assert(*i++ == 1);
+ assert(*i++ == 1);
+ assert(*i++ == 1);
+ assert(*i++ == 1);
+ assert(*i++ == 1);
+ assert(*i++ == 1);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/containers/sequences/list/list.modifiers/insert_iter_iter_iter.pass.cpp b/test/std/containers/sequences/list/list.modifiers/insert_iter_iter_iter.pass.cpp
new file mode 100644
index 000000000000..a7f1917ab856
--- /dev/null
+++ b/test/std/containers/sequences/list/list.modifiers/insert_iter_iter_iter.pass.cpp
@@ -0,0 +1,185 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// template <InputIterator Iter>
+// iterator insert(const_iterator position, Iter first, Iter last);
+
+// UNSUPPORTED: sanitizer-new-delete
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <list>
+#include <cstdlib>
+#include <cassert>
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+int throw_next = 0xFFFF;
+int count = 0;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+ if (throw_next == 0)
+ throw std::bad_alloc();
+ --throw_next;
+ ++count;
+ return std::malloc(s);
+}
+
+void operator delete(void* p) throw()
+{
+ --count;
+ std::free(p);
+}
+
+int main()
+{
+ {
+ int a1[] = {1, 2, 3};
+ std::list<int> l1;
+ std::list<int>::iterator i = l1.insert(l1.begin(), a1, a1+3);
+ assert(i == l1.begin());
+ assert(l1.size() == 3);
+ assert(distance(l1.begin(), l1.end()) == 3);
+ i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 3);
+ int a2[] = {4, 5, 6};
+ i = l1.insert(i, a2, a2+3);
+ assert(*i == 4);
+ assert(l1.size() == 6);
+ assert(distance(l1.begin(), l1.end()) == 6);
+ i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ ++i;
+ assert(*i == 6);
+ ++i;
+ assert(*i == 3);
+ throw_next = 2;
+ int save_count = count;
+ try
+ {
+ i = l1.insert(i, a2, a2+3);
+ assert(false);
+ }
+ catch (...)
+ {
+ }
+ assert(save_count == count);
+ assert(l1.size() == 6);
+ assert(distance(l1.begin(), l1.end()) == 6);
+ i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ ++i;
+ assert(*i == 6);
+ ++i;
+ assert(*i == 3);
+ }
+ throw_next = 0xFFFF;
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::list<int> v(100);
+ std::list<int> v2(100);
+ int a[] = {1, 2, 3, 4, 5};
+ const int N = sizeof(a)/sizeof(a[0]);
+ std::list<int>::iterator i = v.insert(next(v2.cbegin(), 10), input_iterator<const int*>(a),
+ input_iterator<const int*>(a+N));
+ assert(false);
+ }
+#endif
+#if __cplusplus >= 201103L
+ {
+ int a1[] = {1, 2, 3};
+ std::list<int, min_allocator<int>> l1;
+ std::list<int, min_allocator<int>>::iterator i = l1.insert(l1.begin(), a1, a1+3);
+ assert(i == l1.begin());
+ assert(l1.size() == 3);
+ assert(distance(l1.begin(), l1.end()) == 3);
+ i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 3);
+ int a2[] = {4, 5, 6};
+ i = l1.insert(i, a2, a2+3);
+ assert(*i == 4);
+ assert(l1.size() == 6);
+ assert(distance(l1.begin(), l1.end()) == 6);
+ i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ ++i;
+ assert(*i == 6);
+ ++i;
+ assert(*i == 3);
+ throw_next = 2;
+ int save_count = count;
+ try
+ {
+ i = l1.insert(i, a2, a2+3);
+ assert(false);
+ }
+ catch (...)
+ {
+ }
+ assert(save_count == count);
+ assert(l1.size() == 6);
+ assert(distance(l1.begin(), l1.end()) == 6);
+ i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ ++i;
+ assert(*i == 6);
+ ++i;
+ assert(*i == 3);
+ }
+#if _LIBCPP_DEBUG >= 1
+ {
+ throw_next = 0xFFFF;
+ std::list<int, min_allocator<int>> v(100);
+ std::list<int, min_allocator<int>> v2(100);
+ int a[] = {1, 2, 3, 4, 5};
+ const int N = sizeof(a)/sizeof(a[0]);
+ std::list<int, min_allocator<int>>::iterator i = v.insert(next(v2.cbegin(), 10), input_iterator<const int*>(a),
+ input_iterator<const int*>(a+N));
+ assert(false);
+ }
+#endif
+#endif
+}
diff --git a/test/std/containers/sequences/list/list.modifiers/insert_iter_rvalue.pass.cpp b/test/std/containers/sequences/list/list.modifiers/insert_iter_rvalue.pass.cpp
new file mode 100644
index 000000000000..3d5dec299b95
--- /dev/null
+++ b/test/std/containers/sequences/list/list.modifiers/insert_iter_rvalue.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// iterator insert(const_iterator position, value_type&& x);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <list>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::list<MoveOnly> l1;
+ l1.insert(l1.cend(), MoveOnly(1));
+ assert(l1.size() == 1);
+ assert(l1.front() == MoveOnly(1));
+ l1.insert(l1.cbegin(), MoveOnly(2));
+ assert(l1.size() == 2);
+ assert(l1.front() == MoveOnly(2));
+ assert(l1.back() == MoveOnly(1));
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::list<int> v1(3);
+ std::list<int> v2(3);
+ v1.insert(v2.begin(), 4);
+ assert(false);
+ }
+#endif
+#if __cplusplus >= 201103L
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::list<MoveOnly, min_allocator<MoveOnly>> l1;
+ l1.insert(l1.cend(), MoveOnly(1));
+ assert(l1.size() == 1);
+ assert(l1.front() == MoveOnly(1));
+ l1.insert(l1.cbegin(), MoveOnly(2));
+ assert(l1.size() == 2);
+ assert(l1.front() == MoveOnly(2));
+ assert(l1.back() == MoveOnly(1));
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::list<int, min_allocator<int>> v1(3);
+ std::list<int, min_allocator<int>> v2(3);
+ v1.insert(v2.begin(), 4);
+ assert(false);
+ }
+#endif
+#endif
+}
diff --git a/test/std/containers/sequences/list/list.modifiers/insert_iter_size_value.pass.cpp b/test/std/containers/sequences/list/list.modifiers/insert_iter_size_value.pass.cpp
new file mode 100644
index 000000000000..eeb74b83e509
--- /dev/null
+++ b/test/std/containers/sequences/list/list.modifiers/insert_iter_size_value.pass.cpp
@@ -0,0 +1,106 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// iterator insert(const_iterator position, size_type n, const value_type& x);
+
+// UNSUPPORTED: sanitizer-new-delete
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <list>
+#include <cstdlib>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int throw_next = 0xFFFF;
+int count = 0;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+ if (throw_next == 0)
+ throw std::bad_alloc();
+ --throw_next;
+ ++count;
+ return std::malloc(s);
+}
+
+void operator delete(void* p) throw()
+{
+ --count;
+ std::free(p);
+}
+
+int main()
+{
+ {
+ int a1[] = {1, 2, 3};
+ int a2[] = {1, 4, 4, 4, 4, 4, 2, 3};
+ std::list<int> l1(a1, a1+3);
+ std::list<int>::iterator i = l1.insert(next(l1.cbegin()), 5, 4);
+ assert(i == next(l1.begin()));
+ assert(l1 == std::list<int>(a2, a2+8));
+ throw_next = 4;
+ int save_count = count;
+ try
+ {
+ i = l1.insert(i, 5, 5);
+ assert(false);
+ }
+ catch (...)
+ {
+ }
+ throw_next = 0xFFFF;
+ assert(save_count == count);
+ assert(l1 == std::list<int>(a2, a2+8));
+ }
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::list<int> c1(100);
+ std::list<int> c2;
+ std::list<int>::iterator i = c1.insert(next(c2.cbegin(), 10), 5, 1);
+ assert(false);
+ }
+#endif
+#if __cplusplus >= 201103L
+ {
+ int a1[] = {1, 2, 3};
+ int a2[] = {1, 4, 4, 4, 4, 4, 2, 3};
+ std::list<int, min_allocator<int>> l1(a1, a1+3);
+ std::list<int, min_allocator<int>>::iterator i = l1.insert(next(l1.cbegin()), 5, 4);
+ assert(i == next(l1.begin()));
+ assert((l1 == std::list<int, min_allocator<int>>(a2, a2+8)));
+ throw_next = 4;
+ int save_count = count;
+ try
+ {
+ i = l1.insert(i, 5, 5);
+ assert(false);
+ }
+ catch (...)
+ {
+ }
+ throw_next = 0xFFFF;
+ assert(save_count == count);
+ assert((l1 == std::list<int, min_allocator<int>>(a2, a2+8)));
+ }
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::list<int, min_allocator<int>> c1(100);
+ std::list<int, min_allocator<int>> c2;
+ std::list<int, min_allocator<int>>::iterator i = c1.insert(next(c2.cbegin(), 10), 5, 1);
+ assert(false);
+ }
+#endif
+#endif
+}
diff --git a/test/std/containers/sequences/list/list.modifiers/insert_iter_value.pass.cpp b/test/std/containers/sequences/list/list.modifiers/insert_iter_value.pass.cpp
new file mode 100644
index 000000000000..406e93a376a1
--- /dev/null
+++ b/test/std/containers/sequences/list/list.modifiers/insert_iter_value.pass.cpp
@@ -0,0 +1,112 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// iterator insert(const_iterator position, const value_type& x);
+
+// UNSUPPORTED: sanitizer-new-delete
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <list>
+#include <cstdlib>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int throw_next = 0xFFFF;
+int count = 0;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+ if (throw_next == 0)
+ throw std::bad_alloc();
+ --throw_next;
+ ++count;
+ return std::malloc(s);
+}
+
+void operator delete(void* p) throw()
+{
+ --count;
+ std::free(p);
+}
+
+int main()
+{
+ {
+ int a1[] = {1, 2, 3};
+ int a2[] = {1, 4, 2, 3};
+ std::list<int> l1(a1, a1+3);
+ std::list<int>::iterator i = l1.insert(next(l1.cbegin()), 4);
+ assert(i == next(l1.begin()));
+ assert(l1.size() == 4);
+ assert(distance(l1.begin(), l1.end()) == 4);
+ assert(l1 == std::list<int>(a2, a2+4));
+ throw_next = 0;
+ int save_count = count;
+ try
+ {
+ i = l1.insert(i, 5);
+ assert(false);
+ }
+ catch (...)
+ {
+ }
+ throw_next = 0xFFFF;
+ assert(save_count == count);
+ assert(l1 == std::list<int>(a2, a2+4));
+ }
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::list<int> v1(3);
+ std::list<int> v2(3);
+ int i = 4;
+ v1.insert(v2.begin(), i);
+ assert(false);
+ }
+#endif
+#if __cplusplus >= 201103L
+ {
+ int a1[] = {1, 2, 3};
+ int a2[] = {1, 4, 2, 3};
+ std::list<int, min_allocator<int>> l1(a1, a1+3);
+ std::list<int, min_allocator<int>>::iterator i = l1.insert(next(l1.cbegin()), 4);
+ assert(i == next(l1.begin()));
+ assert(l1.size() == 4);
+ assert(distance(l1.begin(), l1.end()) == 4);
+ assert((l1 == std::list<int, min_allocator<int>>(a2, a2+4)));
+ throw_next = 0;
+ int save_count = count;
+ try
+ {
+ i = l1.insert(i, 5);
+ assert(false);
+ }
+ catch (...)
+ {
+ }
+ throw_next = 0xFFFF;
+ assert(save_count == count);
+ assert((l1 == std::list<int, min_allocator<int>>(a2, a2+4)));
+ }
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::list<int, min_allocator<int>> v1(3);
+ std::list<int, min_allocator<int>> v2(3);
+ int i = 4;
+ v1.insert(v2.begin(), i);
+ assert(false);
+ }
+#endif
+#endif
+}
diff --git a/test/std/containers/sequences/list/list.modifiers/pop_back.pass.cpp b/test/std/containers/sequences/list/list.modifiers/pop_back.pass.cpp
new file mode 100644
index 000000000000..3add8518809c
--- /dev/null
+++ b/test/std/containers/sequences/list/list.modifiers/pop_back.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void pop_back();
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ int a[] = {1, 2, 3};
+ std::list<int> c(a, a+3);
+ c.pop_back();
+ assert(c == std::list<int>(a, a+2));
+ c.pop_back();
+ assert(c == std::list<int>(a, a+1));
+ c.pop_back();
+ assert(c.empty());
+#if _LIBCPP_DEBUG >= 1
+ c.pop_back();
+ assert(false);
+#endif
+ }
+#if __cplusplus >= 201103L
+ {
+ int a[] = {1, 2, 3};
+ std::list<int, min_allocator<int>> c(a, a+3);
+ c.pop_back();
+ assert((c == std::list<int, min_allocator<int>>(a, a+2)));
+ c.pop_back();
+ assert((c == std::list<int, min_allocator<int>>(a, a+1)));
+ c.pop_back();
+ assert(c.empty());
+#if _LIBCPP_DEBUG >= 1
+ c.pop_back();
+ assert(false);
+#endif
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/list/list.modifiers/pop_front.pass.cpp b/test/std/containers/sequences/list/list.modifiers/pop_front.pass.cpp
new file mode 100644
index 000000000000..aec17cc08f43
--- /dev/null
+++ b/test/std/containers/sequences/list/list.modifiers/pop_front.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void pop_front();
+
+#include <list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ int a[] = {1, 2, 3};
+ std::list<int> c(a, a+3);
+ c.pop_front();
+ assert(c == std::list<int>(a+1, a+3));
+ c.pop_front();
+ assert(c == std::list<int>(a+2, a+3));
+ c.pop_front();
+ assert(c.empty());
+ }
+#if __cplusplus >= 201103L
+ {
+ int a[] = {1, 2, 3};
+ std::list<int, min_allocator<int>> c(a, a+3);
+ c.pop_front();
+ assert((c == std::list<int, min_allocator<int>>(a+1, a+3)));
+ c.pop_front();
+ assert((c == std::list<int, min_allocator<int>>(a+2, a+3)));
+ c.pop_front();
+ assert(c.empty());
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/list/list.modifiers/push_back.pass.cpp b/test/std/containers/sequences/list/list.modifiers/push_back.pass.cpp
new file mode 100644
index 000000000000..2638c541fa1c
--- /dev/null
+++ b/test/std/containers/sequences/list/list.modifiers/push_back.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void push_back(const value_type& x);
+
+#include <list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::list<int> c;
+ for (int i = 0; i < 5; ++i)
+ c.push_back(i);
+ int a[] = {0, 1, 2, 3, 4};
+ assert(c == std::list<int>(a, a+5));
+ }
+#if __cplusplus >= 201103L
+ {
+ std::list<int, min_allocator<int>> c;
+ for (int i = 0; i < 5; ++i)
+ c.push_back(i);
+ int a[] = {0, 1, 2, 3, 4};
+ assert((c == std::list<int, min_allocator<int>>(a, a+5)));
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/list/list.modifiers/push_back_exception_safety.pass.cpp b/test/std/containers/sequences/list/list.modifiers/push_back_exception_safety.pass.cpp
new file mode 100644
index 000000000000..9d3c05e26b1c
--- /dev/null
+++ b/test/std/containers/sequences/list/list.modifiers/push_back_exception_safety.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void push_back(const value_type& x);
+
+#include <list>
+#include <cassert>
+
+// Flag that makes the copy constructor for CMyClass throw an exception
+static bool gCopyConstructorShouldThow = false;
+
+
+class CMyClass {
+ public: CMyClass();
+ public: CMyClass(const CMyClass& iOther);
+ public: ~CMyClass();
+
+ private: int fMagicValue;
+
+ private: static int kStartedConstructionMagicValue;
+ private: static int kFinishedConstructionMagicValue;
+};
+
+// Value for fMagicValue when the constructor has started running, but not yet finished
+int CMyClass::kStartedConstructionMagicValue = 0;
+// Value for fMagicValue when the constructor has finished running
+int CMyClass::kFinishedConstructionMagicValue = 12345;
+
+CMyClass::CMyClass() :
+ fMagicValue(kStartedConstructionMagicValue)
+{
+ // Signal that the constructor has finished running
+ fMagicValue = kFinishedConstructionMagicValue;
+}
+
+CMyClass::CMyClass(const CMyClass& /*iOther*/) :
+ fMagicValue(kStartedConstructionMagicValue)
+{
+ // If requested, throw an exception _before_ setting fMagicValue to kFinishedConstructionMagicValue
+ if (gCopyConstructorShouldThow) {
+ throw std::exception();
+ }
+ // Signal that the constructor has finished running
+ fMagicValue = kFinishedConstructionMagicValue;
+}
+
+CMyClass::~CMyClass() {
+ // Only instances for which the constructor has finished running should be destructed
+ assert(fMagicValue == kFinishedConstructionMagicValue);
+}
+
+int main()
+{
+ CMyClass instance;
+ std::list<CMyClass> vec;
+
+ vec.push_back(instance);
+
+ gCopyConstructorShouldThow = true;
+ try {
+ vec.push_back(instance);
+ }
+ catch (...) {
+ }
+}
diff --git a/test/std/containers/sequences/list/list.modifiers/push_back_rvalue.pass.cpp b/test/std/containers/sequences/list/list.modifiers/push_back_rvalue.pass.cpp
new file mode 100644
index 000000000000..a2837f813bea
--- /dev/null
+++ b/test/std/containers/sequences/list/list.modifiers/push_back_rvalue.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void push_back(value_type&& x);
+
+#include <list>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::list<MoveOnly> l1;
+ l1.push_back(MoveOnly(1));
+ assert(l1.size() == 1);
+ assert(l1.front() == MoveOnly(1));
+ l1.push_back(MoveOnly(2));
+ assert(l1.size() == 2);
+ assert(l1.front() == MoveOnly(1));
+ assert(l1.back() == MoveOnly(2));
+ }
+#if __cplusplus >= 201103L
+ {
+ std::list<MoveOnly, min_allocator<MoveOnly>> l1;
+ l1.push_back(MoveOnly(1));
+ assert(l1.size() == 1);
+ assert(l1.front() == MoveOnly(1));
+ l1.push_back(MoveOnly(2));
+ assert(l1.size() == 2);
+ assert(l1.front() == MoveOnly(1));
+ assert(l1.back() == MoveOnly(2));
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/sequences/list/list.modifiers/push_front.pass.cpp b/test/std/containers/sequences/list/list.modifiers/push_front.pass.cpp
new file mode 100644
index 000000000000..b7f4febcd385
--- /dev/null
+++ b/test/std/containers/sequences/list/list.modifiers/push_front.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void push_front(const value_type& x);
+
+#include <list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::list<int> c;
+ for (int i = 0; i < 5; ++i)
+ c.push_front(i);
+ int a[] = {4, 3, 2, 1, 0};
+ assert(c == std::list<int>(a, a+5));
+ }
+#if __cplusplus >= 201103L
+ {
+ std::list<int, min_allocator<int>> c;
+ for (int i = 0; i < 5; ++i)
+ c.push_front(i);
+ int a[] = {4, 3, 2, 1, 0};
+ assert((c == std::list<int, min_allocator<int>>(a, a+5)));
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/list/list.modifiers/push_front_exception_safety.pass.cpp b/test/std/containers/sequences/list/list.modifiers/push_front_exception_safety.pass.cpp
new file mode 100644
index 000000000000..6609005262eb
--- /dev/null
+++ b/test/std/containers/sequences/list/list.modifiers/push_front_exception_safety.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void push_front(const value_type& x);
+
+#include <list>
+#include <cassert>
+
+// Flag that makes the copy constructor for CMyClass throw an exception
+static bool gCopyConstructorShouldThow = false;
+
+
+class CMyClass {
+ public: CMyClass();
+ public: CMyClass(const CMyClass& iOther);
+ public: ~CMyClass();
+
+ private: int fMagicValue;
+
+ private: static int kStartedConstructionMagicValue;
+ private: static int kFinishedConstructionMagicValue;
+};
+
+// Value for fMagicValue when the constructor has started running, but not yet finished
+int CMyClass::kStartedConstructionMagicValue = 0;
+// Value for fMagicValue when the constructor has finished running
+int CMyClass::kFinishedConstructionMagicValue = 12345;
+
+CMyClass::CMyClass() :
+ fMagicValue(kStartedConstructionMagicValue)
+{
+ // Signal that the constructor has finished running
+ fMagicValue = kFinishedConstructionMagicValue;
+}
+
+CMyClass::CMyClass(const CMyClass& /*iOther*/) :
+ fMagicValue(kStartedConstructionMagicValue)
+{
+ // If requested, throw an exception _before_ setting fMagicValue to kFinishedConstructionMagicValue
+ if (gCopyConstructorShouldThow) {
+ throw std::exception();
+ }
+ // Signal that the constructor has finished running
+ fMagicValue = kFinishedConstructionMagicValue;
+}
+
+CMyClass::~CMyClass() {
+ // Only instances for which the constructor has finished running should be destructed
+ assert(fMagicValue == kFinishedConstructionMagicValue);
+}
+
+int main()
+{
+ CMyClass instance;
+ std::list<CMyClass> vec;
+
+ vec.push_front(instance);
+
+ gCopyConstructorShouldThow = true;
+ try {
+ vec.push_front(instance);
+ }
+ catch (...) {
+ }
+}
diff --git a/test/std/containers/sequences/list/list.modifiers/push_front_rvalue.pass.cpp b/test/std/containers/sequences/list/list.modifiers/push_front_rvalue.pass.cpp
new file mode 100644
index 000000000000..4f41c3dd390b
--- /dev/null
+++ b/test/std/containers/sequences/list/list.modifiers/push_front_rvalue.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void push_front(value_type&& x);
+
+#include <list>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::list<MoveOnly> l1;
+ l1.push_front(MoveOnly(1));
+ assert(l1.size() == 1);
+ assert(l1.front() == MoveOnly(1));
+ l1.push_front(MoveOnly(2));
+ assert(l1.size() == 2);
+ assert(l1.front() == MoveOnly(2));
+ assert(l1.back() == MoveOnly(1));
+ }
+#if __cplusplus >= 201103L
+ {
+ std::list<MoveOnly, min_allocator<MoveOnly>> l1;
+ l1.push_front(MoveOnly(1));
+ assert(l1.size() == 1);
+ assert(l1.front() == MoveOnly(1));
+ l1.push_front(MoveOnly(2));
+ assert(l1.size() == 2);
+ assert(l1.front() == MoveOnly(2));
+ assert(l1.back() == MoveOnly(1));
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/sequences/list/list.ops/merge.pass.cpp b/test/std/containers/sequences/list/list.ops/merge.pass.cpp
new file mode 100644
index 000000000000..d226ed5dc642
--- /dev/null
+++ b/test/std/containers/sequences/list/list.ops/merge.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void merge(list& x);
+
+#include <list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ int a3[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
+ std::list<int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ std::list<int> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+ c1.merge(c2);
+ assert(c1 == std::list<int>(a3, a3+sizeof(a3)/sizeof(a3[0])));
+ }
+#if __cplusplus >= 201103L
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ int a3[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
+ std::list<int, min_allocator<int>> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ std::list<int, min_allocator<int>> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+ c1.merge(c2);
+ assert((c1 == std::list<int, min_allocator<int>>(a3, a3+sizeof(a3)/sizeof(a3[0]))));
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/list/list.ops/merge_comp.pass.cpp b/test/std/containers/sequences/list/list.ops/merge_comp.pass.cpp
new file mode 100644
index 000000000000..ce861a5dcb88
--- /dev/null
+++ b/test/std/containers/sequences/list/list.ops/merge_comp.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// template <class Compare> void merge(list& x, Compare comp);
+
+#include <list>
+#include <functional>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ int a1[] = {10, 9, 7, 3, 1};
+ int a2[] = {11, 8, 6, 5, 4, 2, 0};
+ int a3[] = {11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0};
+ std::list<int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ std::list<int> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+ c1.merge(c2, std::greater<int>());
+ assert(c1 == std::list<int>(a3, a3+sizeof(a3)/sizeof(a3[0])));
+ }
+#if __cplusplus >= 201103L
+ {
+ int a1[] = {10, 9, 7, 3, 1};
+ int a2[] = {11, 8, 6, 5, 4, 2, 0};
+ int a3[] = {11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0};
+ std::list<int, min_allocator<int>> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ std::list<int, min_allocator<int>> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+ c1.merge(c2, std::greater<int>());
+ assert((c1 == std::list<int, min_allocator<int>>(a3, a3+sizeof(a3)/sizeof(a3[0]))));
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/list/list.ops/remove.pass.cpp b/test/std/containers/sequences/list/list.ops/remove.pass.cpp
new file mode 100644
index 000000000000..f580c94ef486
--- /dev/null
+++ b/test/std/containers/sequences/list/list.ops/remove.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void remove(const value_type& value);
+
+#include <list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+struct S {
+ S(int i) : i_(new int(i)) {}
+ S(const S &rhs) : i_(new int(*rhs.i_)) {}
+ S& operator = (const S &rhs) { *i_ = *rhs.i_; return *this; }
+ ~S () { delete i_; i_ = NULL; }
+ bool operator == (const S &rhs) const { return *i_ == *rhs.i_; }
+ int get () const { return *i_; }
+ int *i_;
+ };
+
+
+int main()
+{
+ {
+ int a1[] = {1, 2, 3, 4};
+ int a2[] = {1, 2, 4};
+ std::list<int> c(a1, a1+4);
+ c.remove(3);
+ assert(c == std::list<int>(a2, a2+3));
+ }
+ { // LWG issue #526
+ int a1[] = {1, 2, 1, 3, 5, 8, 11};
+ int a2[] = { 2, 3, 5, 8, 11};
+ std::list<int> c(a1, a1+7);
+ c.remove(c.front());
+ assert(c == std::list<int>(a2, a2+5));
+ }
+ {
+ int a1[] = {1, 2, 1, 3, 5, 8, 11, 1};
+ int a2[] = { 2, 3, 5, 8, 11 };
+ std::list<S> c;
+ for(int *ip = a1; ip < a1+8; ++ip)
+ c.push_back(S(*ip));
+ c.remove(c.front());
+ std::list<S>::const_iterator it = c.begin();
+ for(int *ip = a2; ip < a2+5; ++ip, ++it) {
+ assert ( it != c.end());
+ assert ( *ip == it->get());
+ }
+ assert ( it == c.end ());
+ }
+#if __cplusplus >= 201103L
+ {
+ int a1[] = {1, 2, 3, 4};
+ int a2[] = {1, 2, 4};
+ std::list<int, min_allocator<int>> c(a1, a1+4);
+ c.remove(3);
+ assert((c == std::list<int, min_allocator<int>>(a2, a2+3)));
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/list/list.ops/remove_if.pass.cpp b/test/std/containers/sequences/list/list.ops/remove_if.pass.cpp
new file mode 100644
index 000000000000..162919ed85de
--- /dev/null
+++ b/test/std/containers/sequences/list/list.ops/remove_if.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// template <class Pred> void remove_if(Pred pred);
+
+#include <list>
+#include <cassert>
+#include <functional>
+
+#include "min_allocator.h"
+#include "counting_predicates.hpp"
+
+bool even(int i)
+{
+ return i % 2 == 0;
+}
+
+bool g(int i)
+{
+ return i < 3;
+}
+
+typedef unary_counting_predicate<bool(*)(int), int> Predicate;
+
+int main()
+{
+ {
+ int a1[] = {1, 2, 3, 4};
+ int a2[] = {3, 4};
+ std::list<int> c(a1, a1+4);
+ Predicate cp(g);
+ c.remove_if(std::ref(cp));
+ assert(c == std::list<int>(a2, a2+2));
+ assert(cp.count() == 4);
+ }
+ {
+ int a1[] = {1, 2, 3, 4};
+ int a2[] = {1, 3};
+ std::list<int> c(a1, a1+4);
+ Predicate cp(even);
+ c.remove_if(std::ref(cp));
+ assert(c == std::list<int>(a2, a2+2));
+ assert(cp.count() == 4);
+ }
+#if __cplusplus >= 201103L
+ {
+ int a1[] = {1, 2, 3, 4};
+ int a2[] = {3, 4};
+ std::list<int, min_allocator<int>> c(a1, a1+4);
+ Predicate cp(g);
+ c.remove_if(std::ref(cp));
+ assert((c == std::list<int, min_allocator<int>>(a2, a2+2)));
+ assert(cp.count() == 4);
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/list/list.ops/reverse.pass.cpp b/test/std/containers/sequences/list/list.ops/reverse.pass.cpp
new file mode 100644
index 000000000000..046453ae5386
--- /dev/null
+++ b/test/std/containers/sequences/list/list.ops/reverse.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void reverse();
+
+#include <list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ int a1[] = {11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0};
+ int a2[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
+ std::list<int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ c1.reverse();
+ assert(c1 == std::list<int>(a2, a2+sizeof(a2)/sizeof(a2[0])));
+ }
+#if __cplusplus >= 201103L
+ {
+ int a1[] = {11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0};
+ int a2[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
+ std::list<int, min_allocator<int>> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ c1.reverse();
+ assert((c1 == std::list<int, min_allocator<int>>(a2, a2+sizeof(a2)/sizeof(a2[0]))));
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/list/list.ops/sort.pass.cpp b/test/std/containers/sequences/list/list.ops/sort.pass.cpp
new file mode 100644
index 000000000000..1c11227237a7
--- /dev/null
+++ b/test/std/containers/sequences/list/list.ops/sort.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void sort();
+
+#include <list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ int a1[] = {4, 8, 1, 0, 5, 7, 2, 3, 6, 11, 10, 9};
+ int a2[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
+ std::list<int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ c1.sort();
+ assert(c1 == std::list<int>(a2, a2+sizeof(a2)/sizeof(a2[0])));
+ }
+#if __cplusplus >= 201103L
+ {
+ int a1[] = {4, 8, 1, 0, 5, 7, 2, 3, 6, 11, 10, 9};
+ int a2[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
+ std::list<int, min_allocator<int>> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ c1.sort();
+ assert((c1 == std::list<int, min_allocator<int>>(a2, a2+sizeof(a2)/sizeof(a2[0]))));
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/list/list.ops/sort_comp.pass.cpp b/test/std/containers/sequences/list/list.ops/sort_comp.pass.cpp
new file mode 100644
index 000000000000..28125ab83c00
--- /dev/null
+++ b/test/std/containers/sequences/list/list.ops/sort_comp.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// template <class Compare> sort(Compare comp);
+
+#include <list>
+#include <functional>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ int a1[] = {4, 8, 1, 0, 5, 7, 2, 3, 6, 11, 10, 9};
+ int a2[] = {11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0};
+ std::list<int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ c1.sort(std::greater<int>());
+ assert(c1 == std::list<int>(a2, a2+sizeof(a2)/sizeof(a2[0])));
+ }
+#if __cplusplus >= 201103L
+ {
+ int a1[] = {4, 8, 1, 0, 5, 7, 2, 3, 6, 11, 10, 9};
+ int a2[] = {11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0};
+ std::list<int, min_allocator<int>> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ c1.sort(std::greater<int>());
+ assert((c1 == std::list<int, min_allocator<int>>(a2, a2+sizeof(a2)/sizeof(a2[0]))));
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/list/list.ops/splice_pos_list.pass.cpp b/test/std/containers/sequences/list/list.ops/splice_pos_list.pass.cpp
new file mode 100644
index 000000000000..354871c20afa
--- /dev/null
+++ b/test/std/containers/sequences/list/list.ops/splice_pos_list.pass.cpp
@@ -0,0 +1,803 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void splice(const_iterator position, list& x);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ int a1[] = {1, 2, 3};
+ int a2[] = {4, 5, 6};
+ {
+ std::list<int> l1;
+ std::list<int> l2;
+ l1.splice(l1.end(), l2);
+ assert(l1.size() == 0);
+ assert(distance(l1.begin(), l1.end()) == 0);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ }
+ {
+ std::list<int> l1;
+ std::list<int> l2(a2, a2+1);
+ l1.splice(l1.end(), l2);
+ assert(l1.size() == 1);
+ assert(distance(l1.begin(), l1.end()) == 1);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 4);
+ }
+ {
+ std::list<int> l1;
+ std::list<int> l2(a2, a2+2);
+ l1.splice(l1.end(), l2);
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ }
+ {
+ std::list<int> l1;
+ std::list<int> l2(a2, a2+3);
+ l1.splice(l1.end(), l2);
+ assert(l1.size() == 3);
+ assert(distance(l1.begin(), l1.end()) == 3);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ ++i;
+ assert(*i == 6);
+ }
+ {
+ std::list<int> l1(a1, a1+1);
+ std::list<int> l2;
+ l1.splice(l1.begin(), l2);
+ assert(l1.size() == 1);
+ assert(distance(l1.begin(), l1.end()) == 1);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ }
+ {
+ std::list<int> l1(a1, a1+1);
+ std::list<int> l2;
+ l1.splice(l1.end(), l2);
+ assert(l1.size() == 1);
+ assert(distance(l1.begin(), l1.end()) == 1);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ }
+ {
+ std::list<int> l1(a1, a1+1);
+ std::list<int> l2(a2, a2+1);
+ l1.splice(l1.begin(), l2);
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 4);
+ ++i;
+ assert(*i == 1);
+ }
+ {
+ std::list<int> l1(a1, a1+1);
+ std::list<int> l2(a2, a2+1);
+ l1.splice(l1.end(), l2);
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 4);
+ }
+ {
+ std::list<int> l1(a1, a1+1);
+ std::list<int> l2(a2, a2+2);
+ l1.splice(l1.begin(), l2);
+ assert(l1.size() == 3);
+ assert(distance(l1.begin(), l1.end()) == 3);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ ++i;
+ assert(*i == 1);
+ }
+ {
+ std::list<int> l1(a1, a1+1);
+ std::list<int> l2(a2, a2+2);
+ l1.splice(l1.end(), l2);
+ assert(l1.size() == 3);
+ assert(distance(l1.begin(), l1.end()) == 3);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ }
+ {
+ std::list<int> l1(a1, a1+1);
+ std::list<int> l2(a2, a2+3);
+ l1.splice(l1.begin(), l2);
+ assert(l1.size() == 4);
+ assert(distance(l1.begin(), l1.end()) == 4);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ ++i;
+ assert(*i == 6);
+ ++i;
+ assert(*i == 1);
+ }
+ {
+ std::list<int> l1(a1, a1+1);
+ std::list<int> l2(a2, a2+3);
+ l1.splice(l1.end(), l2);
+ assert(l1.size() == 4);
+ assert(distance(l1.begin(), l1.end()) == 4);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ ++i;
+ assert(*i == 6);
+ }
+ {
+ std::list<int> l1(a1, a1+2);
+ std::list<int> l2;
+ l1.splice(l1.begin(), l2);
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ }
+ {
+ std::list<int> l1(a1, a1+2);
+ std::list<int> l2;
+ l1.splice(next(l1.begin()), l2);
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ }
+ {
+ std::list<int> l1(a1, a1+2);
+ std::list<int> l2;
+ l1.splice(next(l1.begin(), 2), l2);
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ }
+ {
+ std::list<int> l1(a1, a1+2);
+ std::list<int> l2(a2, a2+1);
+ l1.splice(l1.begin(), l2);
+ assert(l1.size() == 3);
+ assert(distance(l1.begin(), l1.end()) == 3);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 4);
+ ++i;
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ }
+ {
+ std::list<int> l1(a1, a1+2);
+ std::list<int> l2(a2, a2+1);
+ l1.splice(next(l1.begin()), l2);
+ assert(l1.size() == 3);
+ assert(distance(l1.begin(), l1.end()) == 3);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 4);
+ ++i;
+ assert(*i == 2);
+ }
+ {
+ std::list<int> l1(a1, a1+2);
+ std::list<int> l2(a2, a2+1);
+ l1.splice(next(l1.begin(), 2), l2);
+ assert(l1.size() == 3);
+ assert(distance(l1.begin(), l1.end()) == 3);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 4);
+ }
+ {
+ std::list<int> l1(a1, a1+2);
+ std::list<int> l2(a2, a2+2);
+ l1.splice(l1.begin(), l2);
+ assert(l1.size() == 4);
+ assert(distance(l1.begin(), l1.end()) == 4);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ ++i;
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ }
+ {
+ std::list<int> l1(a1, a1+2);
+ std::list<int> l2(a2, a2+2);
+ l1.splice(next(l1.begin()), l2);
+ assert(l1.size() == 4);
+ assert(distance(l1.begin(), l1.end()) == 4);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ ++i;
+ assert(*i == 2);
+ }
+ {
+ std::list<int> l1(a1, a1+2);
+ std::list<int> l2(a2, a2+2);
+ l1.splice(next(l1.begin(), 2), l2);
+ assert(l1.size() == 4);
+ assert(distance(l1.begin(), l1.end()) == 4);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ }
+ {
+ std::list<int> l1(a1, a1+3);
+ std::list<int> l2(a2, a2+3);
+ l1.splice(l1.begin(), l2);
+ assert(l1.size() == 6);
+ assert(distance(l1.begin(), l1.end()) == 6);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ ++i;
+ assert(*i == 6);
+ ++i;
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 3);
+ }
+ {
+ std::list<int> l1(a1, a1+3);
+ std::list<int> l2(a2, a2+3);
+ l1.splice(next(l1.begin()), l2);
+ assert(l1.size() == 6);
+ assert(distance(l1.begin(), l1.end()) == 6);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ ++i;
+ assert(*i == 6);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 3);
+ }
+ {
+ std::list<int> l1(a1, a1+3);
+ std::list<int> l2(a2, a2+3);
+ l1.splice(next(l1.begin(), 2), l2);
+ assert(l1.size() == 6);
+ assert(distance(l1.begin(), l1.end()) == 6);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ ++i;
+ assert(*i == 6);
+ ++i;
+ assert(*i == 3);
+ }
+ {
+ std::list<int> l1(a1, a1+3);
+ std::list<int> l2(a2, a2+3);
+ l1.splice(next(l1.begin(), 3), l2);
+ assert(l1.size() == 6);
+ assert(distance(l1.begin(), l1.end()) == 6);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 3);
+ ++i;
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ ++i;
+ assert(*i == 6);
+ }
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::list<int> v1(3);
+ std::list<int> v2(3);
+ v1.splice(v2.begin(), v2);
+ assert(false);
+ }
+#endif
+#if __cplusplus >= 201103L
+ {
+ std::list<int, min_allocator<int>> l1;
+ std::list<int, min_allocator<int>> l2;
+ l1.splice(l1.end(), l2);
+ assert(l1.size() == 0);
+ assert(distance(l1.begin(), l1.end()) == 0);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ }
+ {
+ std::list<int, min_allocator<int>> l1;
+ std::list<int, min_allocator<int>> l2(a2, a2+1);
+ l1.splice(l1.end(), l2);
+ assert(l1.size() == 1);
+ assert(distance(l1.begin(), l1.end()) == 1);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 4);
+ }
+ {
+ std::list<int, min_allocator<int>> l1;
+ std::list<int, min_allocator<int>> l2(a2, a2+2);
+ l1.splice(l1.end(), l2);
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ }
+ {
+ std::list<int, min_allocator<int>> l1;
+ std::list<int, min_allocator<int>> l2(a2, a2+3);
+ l1.splice(l1.end(), l2);
+ assert(l1.size() == 3);
+ assert(distance(l1.begin(), l1.end()) == 3);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ ++i;
+ assert(*i == 6);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+1);
+ std::list<int, min_allocator<int>> l2;
+ l1.splice(l1.begin(), l2);
+ assert(l1.size() == 1);
+ assert(distance(l1.begin(), l1.end()) == 1);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+1);
+ std::list<int, min_allocator<int>> l2;
+ l1.splice(l1.end(), l2);
+ assert(l1.size() == 1);
+ assert(distance(l1.begin(), l1.end()) == 1);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+1);
+ std::list<int, min_allocator<int>> l2(a2, a2+1);
+ l1.splice(l1.begin(), l2);
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 4);
+ ++i;
+ assert(*i == 1);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+1);
+ std::list<int, min_allocator<int>> l2(a2, a2+1);
+ l1.splice(l1.end(), l2);
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 4);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+1);
+ std::list<int, min_allocator<int>> l2(a2, a2+2);
+ l1.splice(l1.begin(), l2);
+ assert(l1.size() == 3);
+ assert(distance(l1.begin(), l1.end()) == 3);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ ++i;
+ assert(*i == 1);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+1);
+ std::list<int, min_allocator<int>> l2(a2, a2+2);
+ l1.splice(l1.end(), l2);
+ assert(l1.size() == 3);
+ assert(distance(l1.begin(), l1.end()) == 3);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+1);
+ std::list<int, min_allocator<int>> l2(a2, a2+3);
+ l1.splice(l1.begin(), l2);
+ assert(l1.size() == 4);
+ assert(distance(l1.begin(), l1.end()) == 4);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ ++i;
+ assert(*i == 6);
+ ++i;
+ assert(*i == 1);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+1);
+ std::list<int, min_allocator<int>> l2(a2, a2+3);
+ l1.splice(l1.end(), l2);
+ assert(l1.size() == 4);
+ assert(distance(l1.begin(), l1.end()) == 4);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ ++i;
+ assert(*i == 6);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+2);
+ std::list<int, min_allocator<int>> l2;
+ l1.splice(l1.begin(), l2);
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+2);
+ std::list<int, min_allocator<int>> l2;
+ l1.splice(next(l1.begin()), l2);
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+2);
+ std::list<int, min_allocator<int>> l2;
+ l1.splice(next(l1.begin(), 2), l2);
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+2);
+ std::list<int, min_allocator<int>> l2(a2, a2+1);
+ l1.splice(l1.begin(), l2);
+ assert(l1.size() == 3);
+ assert(distance(l1.begin(), l1.end()) == 3);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 4);
+ ++i;
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+2);
+ std::list<int, min_allocator<int>> l2(a2, a2+1);
+ l1.splice(next(l1.begin()), l2);
+ assert(l1.size() == 3);
+ assert(distance(l1.begin(), l1.end()) == 3);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 4);
+ ++i;
+ assert(*i == 2);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+2);
+ std::list<int, min_allocator<int>> l2(a2, a2+1);
+ l1.splice(next(l1.begin(), 2), l2);
+ assert(l1.size() == 3);
+ assert(distance(l1.begin(), l1.end()) == 3);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 4);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+2);
+ std::list<int, min_allocator<int>> l2(a2, a2+2);
+ l1.splice(l1.begin(), l2);
+ assert(l1.size() == 4);
+ assert(distance(l1.begin(), l1.end()) == 4);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ ++i;
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+2);
+ std::list<int, min_allocator<int>> l2(a2, a2+2);
+ l1.splice(next(l1.begin()), l2);
+ assert(l1.size() == 4);
+ assert(distance(l1.begin(), l1.end()) == 4);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ ++i;
+ assert(*i == 2);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+2);
+ std::list<int, min_allocator<int>> l2(a2, a2+2);
+ l1.splice(next(l1.begin(), 2), l2);
+ assert(l1.size() == 4);
+ assert(distance(l1.begin(), l1.end()) == 4);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+3);
+ std::list<int, min_allocator<int>> l2(a2, a2+3);
+ l1.splice(l1.begin(), l2);
+ assert(l1.size() == 6);
+ assert(distance(l1.begin(), l1.end()) == 6);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ ++i;
+ assert(*i == 6);
+ ++i;
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 3);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+3);
+ std::list<int, min_allocator<int>> l2(a2, a2+3);
+ l1.splice(next(l1.begin()), l2);
+ assert(l1.size() == 6);
+ assert(distance(l1.begin(), l1.end()) == 6);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ ++i;
+ assert(*i == 6);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 3);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+3);
+ std::list<int, min_allocator<int>> l2(a2, a2+3);
+ l1.splice(next(l1.begin(), 2), l2);
+ assert(l1.size() == 6);
+ assert(distance(l1.begin(), l1.end()) == 6);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ ++i;
+ assert(*i == 6);
+ ++i;
+ assert(*i == 3);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+3);
+ std::list<int, min_allocator<int>> l2(a2, a2+3);
+ l1.splice(next(l1.begin(), 3), l2);
+ assert(l1.size() == 6);
+ assert(distance(l1.begin(), l1.end()) == 6);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 3);
+ ++i;
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ ++i;
+ assert(*i == 6);
+ }
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::list<int, min_allocator<int>> v1(3);
+ std::list<int, min_allocator<int>> v2(3);
+ v1.splice(v2.begin(), v2);
+ assert(false);
+ }
+#endif
+#endif
+}
diff --git a/test/std/containers/sequences/list/list.ops/splice_pos_list_iter.pass.cpp b/test/std/containers/sequences/list/list.ops/splice_pos_list_iter.pass.cpp
new file mode 100644
index 000000000000..5082c3f85175
--- /dev/null
+++ b/test/std/containers/sequences/list/list.ops/splice_pos_list_iter.pass.cpp
@@ -0,0 +1,357 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void splice(const_iterator position, list<T,Allocator>& x, iterator i);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ int a1[] = {1, 2, 3};
+ int a2[] = {4, 5, 6};
+ {
+ std::list<int> l1;
+ std::list<int> l2(a2, a2+1);
+ l1.splice(l1.end(), l2, l2.begin());
+ assert(l1.size() == 1);
+ assert(distance(l1.begin(), l1.end()) == 1);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 4);
+ }
+ {
+ std::list<int> l1;
+ std::list<int> l2(a2, a2+2);
+ l1.splice(l1.end(), l2, l2.begin());
+ assert(l1.size() == 1);
+ assert(distance(l1.begin(), l1.end()) == 1);
+ assert(l2.size() == 1);
+ assert(distance(l2.begin(), l2.end()) == 1);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 4);
+ i = l2.begin();
+ assert(*i == 5);
+ }
+ {
+ std::list<int> l1;
+ std::list<int> l2(a2, a2+2);
+ l1.splice(l1.end(), l2, next(l2.begin()));
+ assert(l1.size() == 1);
+ assert(distance(l1.begin(), l1.end()) == 1);
+ assert(l2.size() == 1);
+ assert(distance(l2.begin(), l2.end()) == 1);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 5);
+ i = l2.begin();
+ assert(*i == 4);
+ }
+ {
+ std::list<int> l1;
+ std::list<int> l2(a2, a2+3);
+ l1.splice(l1.end(), l2, l2.begin());
+ assert(l1.size() == 1);
+ assert(distance(l1.begin(), l1.end()) == 1);
+ assert(l2.size() == 2);
+ assert(distance(l2.begin(), l2.end()) == 2);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 4);
+ i = l2.begin();
+ assert(*i == 5);
+ ++i;
+ assert(*i == 6);
+ }
+ {
+ std::list<int> l1;
+ std::list<int> l2(a2, a2+3);
+ l1.splice(l1.end(), l2, next(l2.begin()));
+ assert(l1.size() == 1);
+ assert(distance(l1.begin(), l1.end()) == 1);
+ assert(l2.size() == 2);
+ assert(distance(l2.begin(), l2.end()) == 2);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 5);
+ i = l2.begin();
+ assert(*i == 4);
+ ++i;
+ assert(*i == 6);
+ }
+ {
+ std::list<int> l1;
+ std::list<int> l2(a2, a2+3);
+ l1.splice(l1.end(), l2, next(l2.begin(), 2));
+ assert(l1.size() == 1);
+ assert(distance(l1.begin(), l1.end()) == 1);
+ assert(l2.size() == 2);
+ assert(distance(l2.begin(), l2.end()) == 2);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 6);
+ i = l2.begin();
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ }
+ {
+ std::list<int> l1(a1, a1+1);
+ l1.splice(l1.begin(), l1, l1.begin());
+ assert(l1.size() == 1);
+ assert(distance(l1.begin(), l1.end()) == 1);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ }
+ {
+ std::list<int> l1(a1, a1+1);
+ std::list<int> l2(a2, a2+1);
+ l1.splice(l1.begin(), l2, l2.begin());
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 4);
+ ++i;
+ assert(*i == 1);
+ }
+ {
+ std::list<int> l1(a1, a1+1);
+ std::list<int> l2(a2, a2+1);
+ l1.splice(next(l1.begin()), l2, l2.begin());
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 4);
+ }
+ {
+ std::list<int> l1(a1, a1+2);
+ l1.splice(l1.begin(), l1, l1.begin());
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ }
+ {
+ std::list<int> l1(a1, a1+2);
+ l1.splice(l1.begin(), l1, next(l1.begin()));
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 2);
+ ++i;
+ assert(*i == 1);
+ }
+ {
+ std::list<int> l1(a1, a1+2);
+ l1.splice(next(l1.begin()), l1, l1.begin());
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ }
+ {
+ std::list<int> l1(a1, a1+2);
+ l1.splice(next(l1.begin()), l1, next(l1.begin()));
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ }
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::list<int> v1(3);
+ std::list<int> v2(3);
+ v1.splice(v1.begin(), v2, v1.begin());
+ assert(false);
+ }
+#endif
+#if __cplusplus >= 201103L
+ {
+ std::list<int, min_allocator<int>> l1;
+ std::list<int, min_allocator<int>> l2(a2, a2+1);
+ l1.splice(l1.end(), l2, l2.begin());
+ assert(l1.size() == 1);
+ assert(distance(l1.begin(), l1.end()) == 1);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 4);
+ }
+ {
+ std::list<int, min_allocator<int>> l1;
+ std::list<int, min_allocator<int>> l2(a2, a2+2);
+ l1.splice(l1.end(), l2, l2.begin());
+ assert(l1.size() == 1);
+ assert(distance(l1.begin(), l1.end()) == 1);
+ assert(l2.size() == 1);
+ assert(distance(l2.begin(), l2.end()) == 1);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 4);
+ i = l2.begin();
+ assert(*i == 5);
+ }
+ {
+ std::list<int, min_allocator<int>> l1;
+ std::list<int, min_allocator<int>> l2(a2, a2+2);
+ l1.splice(l1.end(), l2, next(l2.begin()));
+ assert(l1.size() == 1);
+ assert(distance(l1.begin(), l1.end()) == 1);
+ assert(l2.size() == 1);
+ assert(distance(l2.begin(), l2.end()) == 1);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 5);
+ i = l2.begin();
+ assert(*i == 4);
+ }
+ {
+ std::list<int, min_allocator<int>> l1;
+ std::list<int, min_allocator<int>> l2(a2, a2+3);
+ l1.splice(l1.end(), l2, l2.begin());
+ assert(l1.size() == 1);
+ assert(distance(l1.begin(), l1.end()) == 1);
+ assert(l2.size() == 2);
+ assert(distance(l2.begin(), l2.end()) == 2);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 4);
+ i = l2.begin();
+ assert(*i == 5);
+ ++i;
+ assert(*i == 6);
+ }
+ {
+ std::list<int, min_allocator<int>> l1;
+ std::list<int, min_allocator<int>> l2(a2, a2+3);
+ l1.splice(l1.end(), l2, next(l2.begin()));
+ assert(l1.size() == 1);
+ assert(distance(l1.begin(), l1.end()) == 1);
+ assert(l2.size() == 2);
+ assert(distance(l2.begin(), l2.end()) == 2);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 5);
+ i = l2.begin();
+ assert(*i == 4);
+ ++i;
+ assert(*i == 6);
+ }
+ {
+ std::list<int, min_allocator<int>> l1;
+ std::list<int, min_allocator<int>> l2(a2, a2+3);
+ l1.splice(l1.end(), l2, next(l2.begin(), 2));
+ assert(l1.size() == 1);
+ assert(distance(l1.begin(), l1.end()) == 1);
+ assert(l2.size() == 2);
+ assert(distance(l2.begin(), l2.end()) == 2);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 6);
+ i = l2.begin();
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+1);
+ l1.splice(l1.begin(), l1, l1.begin());
+ assert(l1.size() == 1);
+ assert(distance(l1.begin(), l1.end()) == 1);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+1);
+ std::list<int, min_allocator<int>> l2(a2, a2+1);
+ l1.splice(l1.begin(), l2, l2.begin());
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 4);
+ ++i;
+ assert(*i == 1);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+1);
+ std::list<int, min_allocator<int>> l2(a2, a2+1);
+ l1.splice(next(l1.begin()), l2, l2.begin());
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 4);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+2);
+ l1.splice(l1.begin(), l1, l1.begin());
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+2);
+ l1.splice(l1.begin(), l1, next(l1.begin()));
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 2);
+ ++i;
+ assert(*i == 1);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+2);
+ l1.splice(next(l1.begin()), l1, l1.begin());
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+2);
+ l1.splice(next(l1.begin()), l1, next(l1.begin()));
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ }
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::list<int, min_allocator<int>> v1(3);
+ std::list<int, min_allocator<int>> v2(3);
+ v1.splice(v1.begin(), v2, v1.begin());
+ assert(false);
+ }
+#endif
+#endif
+}
diff --git a/test/std/containers/sequences/list/list.ops/splice_pos_list_iter_iter.pass.cpp b/test/std/containers/sequences/list/list.ops/splice_pos_list_iter_iter.pass.cpp
new file mode 100644
index 000000000000..fcc4acceec57
--- /dev/null
+++ b/test/std/containers/sequences/list/list.ops/splice_pos_list_iter_iter.pass.cpp
@@ -0,0 +1,237 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void splice(const_iterator position, list& x, iterator first, iterator last);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ int a1[] = {1, 2, 3};
+ int a2[] = {4, 5, 6};
+ {
+ std::list<int> l1(a1, a1+3);
+ l1.splice(l1.begin(), l1, next(l1.begin()), next(l1.begin()));
+ assert(l1.size() == 3);
+ assert(distance(l1.begin(), l1.end()) == 3);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 3);
+ }
+ {
+ std::list<int> l1(a1, a1+3);
+ l1.splice(l1.begin(), l1, next(l1.begin()), next(l1.begin(), 2));
+ assert(l1.size() == 3);
+ assert(distance(l1.begin(), l1.end()) == 3);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 2);
+ ++i;
+ assert(*i == 1);
+ ++i;
+ assert(*i == 3);
+ }
+ {
+ std::list<int> l1(a1, a1+3);
+ l1.splice(l1.begin(), l1, next(l1.begin()), next(l1.begin(), 3));
+ assert(l1.size() == 3);
+ assert(distance(l1.begin(), l1.end()) == 3);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 2);
+ ++i;
+ assert(*i == 3);
+ ++i;
+ assert(*i == 1);
+ }
+ {
+ std::list<int> l1(a1, a1+3);
+ std::list<int> l2(a2, a2+3);
+ l1.splice(l1.begin(), l2, next(l2.begin()), l2.end());
+ assert(l1.size() == 5);
+ assert(distance(l1.begin(), l1.end()) == 5);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 5);
+ ++i;
+ assert(*i == 6);
+ ++i;
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 3);
+ assert(l2.size() == 1);
+ i = l2.begin();
+ assert(*i == 4);
+ }
+ {
+ std::list<int> l1(a1, a1+3);
+ std::list<int> l2(a2, a2+3);
+ l1.splice(next(l1.begin()), l2, next(l2.begin()), l2.end());
+ assert(l1.size() == 5);
+ assert(distance(l1.begin(), l1.end()) == 5);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 5);
+ ++i;
+ assert(*i == 6);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 3);
+ assert(l2.size() == 1);
+ i = l2.begin();
+ assert(*i == 4);
+ }
+ {
+ std::list<int> l1(a1, a1+3);
+ std::list<int> l2(a2, a2+3);
+ l1.splice(l1.end(), l2, next(l2.begin()), l2.end());
+ assert(l1.size() == 5);
+ assert(distance(l1.begin(), l1.end()) == 5);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 3);
+ ++i;
+ assert(*i == 5);
+ ++i;
+ assert(*i == 6);
+ assert(l2.size() == 1);
+ i = l2.begin();
+ assert(*i == 4);
+ }
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::list<int> v1(3);
+ std::list<int> v2(3);
+ v1.splice(v1.begin(), v2, v2.begin(), v1.end());
+ assert(false);
+ }
+#endif
+#if __cplusplus >= 201103L
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+3);
+ l1.splice(l1.begin(), l1, next(l1.begin()), next(l1.begin()));
+ assert(l1.size() == 3);
+ assert(distance(l1.begin(), l1.end()) == 3);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 3);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+3);
+ l1.splice(l1.begin(), l1, next(l1.begin()), next(l1.begin(), 2));
+ assert(l1.size() == 3);
+ assert(distance(l1.begin(), l1.end()) == 3);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 2);
+ ++i;
+ assert(*i == 1);
+ ++i;
+ assert(*i == 3);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+3);
+ l1.splice(l1.begin(), l1, next(l1.begin()), next(l1.begin(), 3));
+ assert(l1.size() == 3);
+ assert(distance(l1.begin(), l1.end()) == 3);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 2);
+ ++i;
+ assert(*i == 3);
+ ++i;
+ assert(*i == 1);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+3);
+ std::list<int, min_allocator<int>> l2(a2, a2+3);
+ l1.splice(l1.begin(), l2, next(l2.begin()), l2.end());
+ assert(l1.size() == 5);
+ assert(distance(l1.begin(), l1.end()) == 5);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 5);
+ ++i;
+ assert(*i == 6);
+ ++i;
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 3);
+ assert(l2.size() == 1);
+ i = l2.begin();
+ assert(*i == 4);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+3);
+ std::list<int, min_allocator<int>> l2(a2, a2+3);
+ l1.splice(next(l1.begin()), l2, next(l2.begin()), l2.end());
+ assert(l1.size() == 5);
+ assert(distance(l1.begin(), l1.end()) == 5);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 5);
+ ++i;
+ assert(*i == 6);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 3);
+ assert(l2.size() == 1);
+ i = l2.begin();
+ assert(*i == 4);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+3);
+ std::list<int, min_allocator<int>> l2(a2, a2+3);
+ l1.splice(l1.end(), l2, next(l2.begin()), l2.end());
+ assert(l1.size() == 5);
+ assert(distance(l1.begin(), l1.end()) == 5);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 3);
+ ++i;
+ assert(*i == 5);
+ ++i;
+ assert(*i == 6);
+ assert(l2.size() == 1);
+ i = l2.begin();
+ assert(*i == 4);
+ }
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::list<int, min_allocator<int>> v1(3);
+ std::list<int, min_allocator<int>> v2(3);
+ v1.splice(v1.begin(), v2, v2.begin(), v1.end());
+ assert(false);
+ }
+#endif
+#endif
+}
diff --git a/test/std/containers/sequences/list/list.ops/unique.pass.cpp b/test/std/containers/sequences/list/list.ops/unique.pass.cpp
new file mode 100644
index 000000000000..48cad1ddd156
--- /dev/null
+++ b/test/std/containers/sequences/list/list.ops/unique.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void unique();
+
+#include <list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ int a1[] = {2, 1, 1, 4, 4, 4, 4, 3, 3};
+ int a2[] = {2, 1, 4, 3};
+ std::list<int> c(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ c.unique();
+ assert(c == std::list<int>(a2, a2+4));
+ }
+#if __cplusplus >= 201103L
+ {
+ int a1[] = {2, 1, 1, 4, 4, 4, 4, 3, 3};
+ int a2[] = {2, 1, 4, 3};
+ std::list<int, min_allocator<int>> c(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ c.unique();
+ assert((c == std::list<int, min_allocator<int>>(a2, a2+4)));
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/list/list.ops/unique_pred.pass.cpp b/test/std/containers/sequences/list/list.ops/unique_pred.pass.cpp
new file mode 100644
index 000000000000..f8935b81f6a7
--- /dev/null
+++ b/test/std/containers/sequences/list/list.ops/unique_pred.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// template <class BinaryPred> void unique(BinaryPred pred);
+
+#include <list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+bool g(int x, int y)
+{
+ return x == y;
+}
+
+int main()
+{
+ {
+ int a1[] = {2, 1, 1, 4, 4, 4, 4, 3, 3};
+ int a2[] = {2, 1, 4, 3};
+ std::list<int> c(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ c.unique(g);
+ assert(c == std::list<int>(a2, a2+4));
+ }
+#if __cplusplus >= 201103L
+ {
+ int a1[] = {2, 1, 1, 4, 4, 4, 4, 3, 3};
+ int a2[] = {2, 1, 4, 3};
+ std::list<int, min_allocator<int>> c(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ c.unique(g);
+ assert((c == std::list<int, min_allocator<int>>(a2, a2+4)));
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/list/list.special/db_swap_1.pass.cpp b/test/std/containers/sequences/list/list.special/db_swap_1.pass.cpp
new file mode 100644
index 000000000000..f7171795cd5f
--- /dev/null
+++ b/test/std/containers/sequences/list/list.special/db_swap_1.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// template <class T, class Alloc>
+// void swap(list<T,Alloc>& x, list<T,Alloc>& y);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <list>
+#include <cassert>
+
+#include <__debug>
+#include "min_allocator.h"
+
+int main()
+{
+#if _LIBCPP_DEBUG >= 1
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ std::list<int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ std::list<int> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+ std::list<int>::iterator i1 = c1.begin();
+ std::list<int>::iterator i2 = c2.begin();
+ swap(c1, c2);
+ c1.erase(i2);
+ c2.erase(i1);
+ std::list<int>::iterator j = i1;
+ c1.erase(i1);
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ std::list<int, min_allocator<int>> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ std::list<int, min_allocator<int>> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+ std::list<int, min_allocator<int>>::iterator i1 = c1.begin();
+ std::list<int, min_allocator<int>>::iterator i2 = c2.begin();
+ swap(c1, c2);
+ c1.erase(i2);
+ c2.erase(i1);
+ std::list<int, min_allocator<int>>::iterator j = i1;
+ c1.erase(i1);
+ assert(false);
+ }
+#endif
+#endif
+}
diff --git a/test/std/containers/sequences/list/list.special/swap.pass.cpp b/test/std/containers/sequences/list/list.special/swap.pass.cpp
new file mode 100644
index 000000000000..bc5f4857edc7
--- /dev/null
+++ b/test/std/containers/sequences/list/list.special/swap.pass.cpp
@@ -0,0 +1,146 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// template <class T, class Alloc>
+// void swap(list<T,Alloc>& x, list<T,Alloc>& y);
+
+#include <list>
+#include <cassert>
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ std::list<int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ std::list<int> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+ swap(c1, c2);
+ assert(c1 == std::list<int>(a2, a2+sizeof(a2)/sizeof(a2[0])));
+ assert(c2 == std::list<int>(a1, a1+sizeof(a1)/sizeof(a1[0])));
+ }
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ std::list<int> c1(a1, a1);
+ std::list<int> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+ swap(c1, c2);
+ assert(c1 == std::list<int>(a2, a2+sizeof(a2)/sizeof(a2[0])));
+ assert(c2.empty());
+ assert(distance(c2.begin(), c2.end()) == 0);
+ }
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ std::list<int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ std::list<int> c2(a2, a2);
+ swap(c1, c2);
+ assert(c1.empty());
+ assert(distance(c1.begin(), c1.end()) == 0);
+ assert(c2 == std::list<int>(a1, a1+sizeof(a1)/sizeof(a1[0])));
+ }
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ std::list<int> c1(a1, a1);
+ std::list<int> c2(a2, a2);
+ swap(c1, c2);
+ assert(c1.empty());
+ assert(distance(c1.begin(), c1.end()) == 0);
+ assert(c2.empty());
+ assert(distance(c2.begin(), c2.end()) == 0);
+ }
+#ifndef _LIBCPP_DEBUG_LEVEL
+// This test known to result in undefined behavior detected by _LIBCPP_DEBUG_LEVEL >= 1
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ typedef test_allocator<int> A;
+ std::list<int, A> c1(a1, a1+sizeof(a1)/sizeof(a1[0]), A(1));
+ std::list<int, A> c2(a2, a2+sizeof(a2)/sizeof(a2[0]), A(2));
+ swap(c1, c2);
+ assert((c1 == std::list<int, A>(a2, a2+sizeof(a2)/sizeof(a2[0]))));
+ assert(c1.get_allocator() == A(1));
+ assert((c2 == std::list<int, A>(a1, a1+sizeof(a1)/sizeof(a1[0]))));
+ assert(c2.get_allocator() == A(2));
+ }
+#endif
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ typedef other_allocator<int> A;
+ std::list<int, A> c1(a1, a1+sizeof(a1)/sizeof(a1[0]), A(1));
+ std::list<int, A> c2(a2, a2+sizeof(a2)/sizeof(a2[0]), A(2));
+ swap(c1, c2);
+ assert((c1 == std::list<int, A>(a2, a2+sizeof(a2)/sizeof(a2[0]))));
+ assert(c1.get_allocator() == A(2));
+ assert((c2 == std::list<int, A>(a1, a1+sizeof(a1)/sizeof(a1[0]))));
+ assert(c2.get_allocator() == A(1));
+ }
+#if __cplusplus >= 201103L
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ std::list<int, min_allocator<int>> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ std::list<int, min_allocator<int>> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+ swap(c1, c2);
+ assert((c1 == std::list<int, min_allocator<int>>(a2, a2+sizeof(a2)/sizeof(a2[0]))));
+ assert((c2 == std::list<int, min_allocator<int>>(a1, a1+sizeof(a1)/sizeof(a1[0]))));
+ }
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ std::list<int, min_allocator<int>> c1(a1, a1);
+ std::list<int, min_allocator<int>> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+ swap(c1, c2);
+ assert((c1 == std::list<int, min_allocator<int>>(a2, a2+sizeof(a2)/sizeof(a2[0]))));
+ assert(c2.empty());
+ assert(distance(c2.begin(), c2.end()) == 0);
+ }
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ std::list<int, min_allocator<int>> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ std::list<int, min_allocator<int>> c2(a2, a2);
+ swap(c1, c2);
+ assert(c1.empty());
+ assert(distance(c1.begin(), c1.end()) == 0);
+ assert((c2 == std::list<int, min_allocator<int>>(a1, a1+sizeof(a1)/sizeof(a1[0]))));
+ }
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ std::list<int, min_allocator<int>> c1(a1, a1);
+ std::list<int, min_allocator<int>> c2(a2, a2);
+ swap(c1, c2);
+ assert(c1.empty());
+ assert(distance(c1.begin(), c1.end()) == 0);
+ assert(c2.empty());
+ assert(distance(c2.begin(), c2.end()) == 0);
+ }
+#ifndef _LIBCPP_DEBUG_LEVEL
+// This test known to result in undefined behavior detected by _LIBCPP_DEBUG_LEVEL >= 1
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ typedef min_allocator<int> A;
+ std::list<int, A> c1(a1, a1+sizeof(a1)/sizeof(a1[0]), A());
+ std::list<int, A> c2(a2, a2+sizeof(a2)/sizeof(a2[0]), A());
+ swap(c1, c2);
+ assert((c1 == std::list<int, A>(a2, a2+sizeof(a2)/sizeof(a2[0]))));
+ assert(c1.get_allocator() == A());
+ assert((c2 == std::list<int, A>(a1, a1+sizeof(a1)/sizeof(a1[0]))));
+ assert(c2.get_allocator() == A());
+ }
+#endif
+#endif
+}
diff --git a/test/std/containers/sequences/list/list.special/swap_noexcept.pass.cpp b/test/std/containers/sequences/list/list.special/swap_noexcept.pass.cpp
new file mode 100644
index 000000000000..9c83ad58fed4
--- /dev/null
+++ b/test/std/containers/sequences/list/list.special/swap_noexcept.pass.cpp
@@ -0,0 +1,90 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void swap(list& c)
+// noexcept(!allocator_type::propagate_on_container_swap::value ||
+// __is_nothrow_swappable<allocator_type>::value);
+//
+// In C++17, the standard says that swap shall have:
+// noexcept(allocator_traits<Allocator>::is_always_equal::value);
+
+// This tests a conforming extension
+
+#include <list>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_alloc
+{
+ typedef T value_type;
+
+ some_alloc() {}
+ some_alloc(const some_alloc&);
+ void deallocate(void*, unsigned) {}
+
+ typedef std::true_type propagate_on_container_swap;
+};
+
+template <class T>
+struct some_alloc2
+{
+ typedef T value_type;
+
+ some_alloc2() {}
+ some_alloc2(const some_alloc2&);
+ void deallocate(void*, unsigned) {}
+
+ typedef std::false_type propagate_on_container_swap;
+ typedef std::true_type is_always_equal;
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::list<MoveOnly> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::list<MoveOnly, test_allocator<MoveOnly>> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::list<MoveOnly, other_allocator<MoveOnly>> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::list<MoveOnly, some_alloc<MoveOnly>> C;
+ C c1, c2;
+#if TEST_STD_VER >= 14
+ // In c++14, if POCS is set, swapping the allocator is required not to throw
+ static_assert( noexcept(swap(c1, c2)), "");
+#else
+ static_assert(!noexcept(swap(c1, c2)), "");
+#endif
+ }
+#if TEST_STD_VER >= 14
+ {
+ typedef std::list<MoveOnly, some_alloc2<MoveOnly>> C;
+ C c1, c2;
+ // if the allocators are always equal, then the swap can be noexcept
+ static_assert( noexcept(swap(c1, c2)), "");
+ }
+#endif
+
+#endif
+}
diff --git a/test/std/containers/sequences/list/types.pass.cpp b/test/std/containers/sequences/list/types.pass.cpp
new file mode 100644
index 000000000000..77303601ae97
--- /dev/null
+++ b/test/std/containers/sequences/list/types.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// template <class T, class Alloc = allocator<T> >
+// class list
+// {
+// public:
+//
+// // types:
+// typedef T value_type;
+// typedef Alloc allocator_type;
+// typedef typename allocator_type::reference reference;
+// typedef typename allocator_type::const_reference const_reference;
+// typedef typename allocator_type::pointer pointer;
+// typedef typename allocator_type::const_pointer const_pointer;
+
+#include <list>
+#include <type_traits>
+
+#include "min_allocator.h"
+
+struct A { std::list<A> v; }; // incomplete type support
+
+int main()
+{
+ static_assert((std::is_same<std::list<int>::value_type, int>::value), "");
+ static_assert((std::is_same<std::list<int>::allocator_type, std::allocator<int> >::value), "");
+ static_assert((std::is_same<std::list<int>::reference, std::allocator<int>::reference>::value), "");
+ static_assert((std::is_same<std::list<int>::const_reference, std::allocator<int>::const_reference>::value), "");
+ static_assert((std::is_same<std::list<int>::pointer, std::allocator<int>::pointer>::value), "");
+ static_assert((std::is_same<std::list<int>::const_pointer, std::allocator<int>::const_pointer>::value), "");
+#if __cplusplus >= 201103L
+ static_assert((std::is_same<std::list<int, min_allocator<int>>::value_type, int>::value), "");
+ static_assert((std::is_same<std::list<int, min_allocator<int>>::allocator_type, min_allocator<int> >::value), "");
+ static_assert((std::is_same<std::list<int, min_allocator<int>>::reference, int&>::value), "");
+ static_assert((std::is_same<std::list<int, min_allocator<int>>::const_reference, const int&>::value), "");
+ static_assert((std::is_same<std::list<int, min_allocator<int>>::pointer, min_pointer<int>>::value), "");
+ static_assert((std::is_same<std::list<int, min_allocator<int>>::const_pointer, min_pointer<const int>>::value), "");
+#endif
+}
diff --git a/test/std/containers/sequences/list/version.pass.cpp b/test/std/containers/sequences/list/version.pass.cpp
new file mode 100644
index 000000000000..097c013f52cb
--- /dev/null
+++ b/test/std/containers/sequences/list/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+#include <list>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/containers/sequences/nothing_to_do.pass.cpp b/test/std/containers/sequences/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/containers/sequences/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/containers/sequences/vector.bool/assign_copy.pass.cpp b/test/std/containers/sequences/vector.bool/assign_copy.pass.cpp
new file mode 100644
index 000000000000..9501799ae3d0
--- /dev/null
+++ b/test/std/containers/sequences/vector.bool/assign_copy.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector& operator=(const vector& c);
+
+#include <vector>
+#include <cassert>
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::vector<bool, test_allocator<bool> > l(3, 2, test_allocator<bool>(5));
+ std::vector<bool, test_allocator<bool> > l2(l, test_allocator<bool>(3));
+ l2 = l;
+ assert(l2 == l);
+ assert(l2.get_allocator() == test_allocator<bool>(3));
+ }
+ {
+ std::vector<bool, other_allocator<bool> > l(3, 2, other_allocator<bool>(5));
+ std::vector<bool, other_allocator<bool> > l2(l, other_allocator<bool>(3));
+ l2 = l;
+ assert(l2 == l);
+ assert(l2.get_allocator() == other_allocator<bool>(5));
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<bool, min_allocator<bool> > l(3, 2, min_allocator<bool>());
+ std::vector<bool, min_allocator<bool> > l2(l, min_allocator<bool>());
+ l2 = l;
+ assert(l2 == l);
+ assert(l2.get_allocator() == min_allocator<bool>());
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/vector.bool/assign_initializer_list.pass.cpp b/test/std/containers/sequences/vector.bool/assign_initializer_list.pass.cpp
new file mode 100644
index 000000000000..2925fbc66745
--- /dev/null
+++ b/test/std/containers/sequences/vector.bool/assign_initializer_list.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// void assign(initializer_list<value_type> il);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ std::vector<bool> d;
+ d.assign({true, false, false, true});
+ assert(d.size() == 4);
+ assert(d[0] == true);
+ assert(d[1] == false);
+ assert(d[2] == false);
+ assert(d[3] == true);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<bool, min_allocator<bool>> d;
+ d.assign({true, false, false, true});
+ assert(d.size() == 4);
+ assert(d[0] == true);
+ assert(d[1] == false);
+ assert(d[2] == false);
+ assert(d[3] == true);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/containers/sequences/vector.bool/assign_move.pass.cpp b/test/std/containers/sequences/vector.bool/assign_move.pass.cpp
new file mode 100644
index 000000000000..df98c817fd59
--- /dev/null
+++ b/test/std/containers/sequences/vector.bool/assign_move.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector& operator=(vector&& c);
+
+#include <vector>
+#include <cassert>
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::vector<bool, test_allocator<bool> > l(test_allocator<bool>(5));
+ std::vector<bool, test_allocator<bool> > lo(test_allocator<bool>(5));
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ std::vector<bool, test_allocator<bool> > l2(test_allocator<bool>(5));
+ l2 = std::move(l);
+ assert(l2 == lo);
+ assert(l.empty());
+ assert(l2.get_allocator() == lo.get_allocator());
+ }
+ {
+ std::vector<bool, test_allocator<bool> > l(test_allocator<bool>(5));
+ std::vector<bool, test_allocator<bool> > lo(test_allocator<bool>(5));
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ std::vector<bool, test_allocator<bool> > l2(test_allocator<bool>(6));
+ l2 = std::move(l);
+ assert(l2 == lo);
+ assert(!l.empty());
+ assert(l2.get_allocator() == test_allocator<bool>(6));
+ }
+ {
+ std::vector<bool, other_allocator<bool> > l(other_allocator<bool>(5));
+ std::vector<bool, other_allocator<bool> > lo(other_allocator<bool>(5));
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ std::vector<bool, other_allocator<bool> > l2(other_allocator<bool>(6));
+ l2 = std::move(l);
+ assert(l2 == lo);
+ assert(l.empty());
+ assert(l2.get_allocator() == lo.get_allocator());
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<bool, min_allocator<bool> > l(min_allocator<bool>{});
+ std::vector<bool, min_allocator<bool> > lo(min_allocator<bool>{});
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ std::vector<bool, min_allocator<bool> > l2(min_allocator<bool>{});
+ l2 = std::move(l);
+ assert(l2 == lo);
+ assert(l.empty());
+ assert(l2.get_allocator() == lo.get_allocator());
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/sequences/vector.bool/capacity.pass.cpp b/test/std/containers/sequences/vector.bool/capacity.pass.cpp
new file mode 100644
index 000000000000..63bff25f9f9a
--- /dev/null
+++ b/test/std/containers/sequences/vector.bool/capacity.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// size_type capacity() const;
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::vector<bool> v;
+ assert(v.capacity() == 0);
+ }
+ {
+ std::vector<bool> v(100);
+ assert(v.capacity() >= 100);
+ v.push_back(0);
+ assert(v.capacity() >= 101);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<bool, min_allocator<bool>> v;
+ assert(v.capacity() == 0);
+ }
+ {
+ std::vector<bool, min_allocator<bool>> v(100);
+ assert(v.capacity() >= 100);
+ v.push_back(0);
+ assert(v.capacity() >= 101);
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/vector.bool/construct_default.pass.cpp b/test/std/containers/sequences/vector.bool/construct_default.pass.cpp
new file mode 100644
index 000000000000..07824098fc6f
--- /dev/null
+++ b/test/std/containers/sequences/vector.bool/construct_default.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// vector(const Alloc& = Alloc());
+
+#include <vector>
+#include <cassert>
+
+#include "test_macros.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+template <class C>
+void
+test0()
+{
+#if TEST_STD_VER > 14
+ static_assert((noexcept(C{})), "" );
+#elif TEST_STD_VER >= 11
+ static_assert((noexcept(C()) == noexcept(typename C::allocator_type())), "" );
+#endif
+ C c;
+ assert(c.__invariants());
+ assert(c.empty());
+ assert(c.get_allocator() == typename C::allocator_type());
+#if TEST_STD_VER >= 11
+ C c1 = {};
+ assert(c1.__invariants());
+ assert(c1.empty());
+ assert(c1.get_allocator() == typename C::allocator_type());
+#endif
+}
+
+template <class C>
+void
+test1(const typename C::allocator_type& a)
+{
+#if TEST_STD_VER > 14
+ static_assert((noexcept(C{typename C::allocator_type{}})), "" );
+#elif TEST_STD_VER >= 11
+ static_assert((noexcept(C(typename C::allocator_type())) == std::is_nothrow_copy_constructible<typename C::allocator_type>::value), "" );
+#endif
+ C c(a);
+ assert(c.__invariants());
+ assert(c.empty());
+ assert(c.get_allocator() == a);
+}
+
+int main()
+{
+ {
+ test0<std::vector<bool> >();
+ test1<std::vector<bool, test_allocator<bool> > >(test_allocator<bool>(3));
+ }
+#if TEST_STD_VER >= 11
+ {
+ test0<std::vector<bool, min_allocator<bool>> >();
+ test1<std::vector<bool, min_allocator<bool> > >(min_allocator<bool>());
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/vector.bool/construct_iter_iter.pass.cpp b/test/std/containers/sequences/vector.bool/construct_iter_iter.pass.cpp
new file mode 100644
index 000000000000..94e6801825d8
--- /dev/null
+++ b/test/std/containers/sequences/vector.bool/construct_iter_iter.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// template <class InputIter> vector(InputIter first, InputIter last);
+
+#include <vector>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+template <class C, class Iterator>
+void
+test(Iterator first, Iterator last)
+{
+ C c(first, last);
+ assert(c.__invariants());
+ assert(c.size() == std::distance(first, last));
+ for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i, ++first)
+ assert(*i == *first);
+}
+
+int main()
+{
+ bool a[] = {0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0};
+ bool* an = a + sizeof(a)/sizeof(a[0]);
+ test<std::vector<bool> >(input_iterator<const bool*>(a), input_iterator<const bool*>(an));
+ test<std::vector<bool> >(forward_iterator<const bool*>(a), forward_iterator<const bool*>(an));
+ test<std::vector<bool> >(bidirectional_iterator<const bool*>(a), bidirectional_iterator<const bool*>(an));
+ test<std::vector<bool> >(random_access_iterator<const bool*>(a), random_access_iterator<const bool*>(an));
+ test<std::vector<bool> >(a, an);
+#if __cplusplus >= 201103L
+ test<std::vector<bool, min_allocator<bool>> >(input_iterator<const bool*>(a), input_iterator<const bool*>(an));
+ test<std::vector<bool, min_allocator<bool>> >(forward_iterator<const bool*>(a), forward_iterator<const bool*>(an));
+ test<std::vector<bool, min_allocator<bool>> >(bidirectional_iterator<const bool*>(a), bidirectional_iterator<const bool*>(an));
+ test<std::vector<bool, min_allocator<bool>> >(random_access_iterator<const bool*>(a), random_access_iterator<const bool*>(an));
+ test<std::vector<bool, min_allocator<bool>> >(a, an);
+#endif
+}
diff --git a/test/std/containers/sequences/vector.bool/construct_iter_iter_alloc.pass.cpp b/test/std/containers/sequences/vector.bool/construct_iter_iter_alloc.pass.cpp
new file mode 100644
index 000000000000..ea9d41d342f8
--- /dev/null
+++ b/test/std/containers/sequences/vector.bool/construct_iter_iter_alloc.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// template <class InputIter> vector(InputIter first, InputIter last,
+// const allocator_type& a);
+
+#include <vector>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+template <class C, class Iterator>
+void
+test(Iterator first, Iterator last, const typename C::allocator_type& a)
+{
+ C c(first, last, a);
+ assert(c.__invariants());
+ assert(c.size() == std::distance(first, last));
+ for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i, ++first)
+ assert(*i == *first);
+}
+
+int main()
+{
+ bool a[] = {0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0};
+ bool* an = a + sizeof(a)/sizeof(a[0]);
+ {
+ std::allocator<bool> alloc;
+ test<std::vector<bool> >(input_iterator<const bool*>(a), input_iterator<const bool*>(an), alloc);
+ test<std::vector<bool> >(forward_iterator<const bool*>(a), forward_iterator<const bool*>(an), alloc);
+ test<std::vector<bool> >(bidirectional_iterator<const bool*>(a), bidirectional_iterator<const bool*>(an), alloc);
+ test<std::vector<bool> >(random_access_iterator<const bool*>(a), random_access_iterator<const bool*>(an), alloc);
+ test<std::vector<bool> >(a, an, alloc);
+ }
+#if __cplusplus >= 201103L
+ {
+ min_allocator<bool> alloc;
+ test<std::vector<bool, min_allocator<bool>> >(input_iterator<const bool*>(a), input_iterator<const bool*>(an), alloc);
+ test<std::vector<bool, min_allocator<bool>> >(forward_iterator<const bool*>(a), forward_iterator<const bool*>(an), alloc);
+ test<std::vector<bool, min_allocator<bool>> >(bidirectional_iterator<const bool*>(a), bidirectional_iterator<const bool*>(an), alloc);
+ test<std::vector<bool, min_allocator<bool>> >(random_access_iterator<const bool*>(a), random_access_iterator<const bool*>(an), alloc);
+ test<std::vector<bool, min_allocator<bool>> >(a, an, alloc);
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/vector.bool/construct_size.pass.cpp b/test/std/containers/sequences/vector.bool/construct_size.pass.cpp
new file mode 100644
index 000000000000..93ecbe87c380
--- /dev/null
+++ b/test/std/containers/sequences/vector.bool/construct_size.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// explicit vector(size_type n);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "test_allocator.h"
+
+template <class C>
+void
+test2(typename C::size_type n, typename C::allocator_type const& a = typename C::allocator_type ())
+{
+#if _LIBCPP_STD_VER > 11
+ C c(n, a);
+ assert(c.__invariants());
+ assert(c.size() == n);
+ assert(c.get_allocator() == a);
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i)
+ assert(*i == typename C::value_type());
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif
+}
+
+template <class C>
+void
+test1(typename C::size_type n)
+{
+ C c(n);
+ assert(c.__invariants());
+ assert(c.size() == n);
+ assert(c.get_allocator() == typename C::allocator_type());
+ for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i)
+ assert(*i == typename C::value_type());
+}
+
+template <class C>
+void
+test(typename C::size_type n)
+{
+ test1<C> ( n );
+ test2<C> ( n );
+}
+
+int main()
+{
+ test<std::vector<bool> >(50);
+#if __cplusplus >= 201103L
+ test<std::vector<bool, min_allocator<bool>> >(50);
+ test2<std::vector<bool, test_allocator<bool>> >( 100, test_allocator<bool>(23));
+#endif
+}
diff --git a/test/std/containers/sequences/vector.bool/construct_size_value.pass.cpp b/test/std/containers/sequences/vector.bool/construct_size_value.pass.cpp
new file mode 100644
index 000000000000..fc772f10dfc4
--- /dev/null
+++ b/test/std/containers/sequences/vector.bool/construct_size_value.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// vector(size_type n, const value_type& x);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class C>
+void
+test(typename C::size_type n, const typename C::value_type& x)
+{
+ C c(n, x);
+ assert(c.__invariants());
+ assert(c.size() == n);
+ for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i)
+ assert(*i == x);
+}
+
+int main()
+{
+ test<std::vector<bool> >(50, 3);
+#if __cplusplus >= 201103L
+ test<std::vector<bool, min_allocator<bool>> >(50, 3);
+#endif
+}
diff --git a/test/std/containers/sequences/vector.bool/construct_size_value_alloc.pass.cpp b/test/std/containers/sequences/vector.bool/construct_size_value_alloc.pass.cpp
new file mode 100644
index 000000000000..6cca948ed834
--- /dev/null
+++ b/test/std/containers/sequences/vector.bool/construct_size_value_alloc.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// vector(size_type n, const value_type& x, const allocator_type& a);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class C>
+void
+test(typename C::size_type n, const typename C::value_type& x,
+ const typename C::allocator_type& a)
+{
+ C c(n, x, a);
+ assert(c.__invariants());
+ assert(a == c.get_allocator());
+ assert(c.size() == n);
+ for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i)
+ assert(*i == x);
+}
+
+int main()
+{
+ test<std::vector<bool> >(50, 3, std::allocator<bool>());
+#if __cplusplus >= 201103L
+ test<std::vector<bool, min_allocator<bool>> >(50, 3, min_allocator<bool>());
+#endif
+}
diff --git a/test/std/containers/sequences/vector.bool/copy.pass.cpp b/test/std/containers/sequences/vector.bool/copy.pass.cpp
new file mode 100644
index 000000000000..58822782ff8b
--- /dev/null
+++ b/test/std/containers/sequences/vector.bool/copy.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// vector(const vector& v);
+
+#include <vector>
+#include <cassert>
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+template <class C>
+void
+test(const C& x)
+{
+ unsigned s = x.size();
+ C c(x);
+ assert(c.__invariants());
+ assert(c.size() == s);
+ assert(c == x);
+}
+
+int main()
+{
+ {
+ bool a[] = {0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0};
+ bool* an = a + sizeof(a)/sizeof(a[0]);
+ test(std::vector<bool>(a, an));
+ }
+ {
+ std::vector<bool, test_allocator<bool> > v(3, 2, test_allocator<bool>(5));
+ std::vector<bool, test_allocator<bool> > v2 = v;
+ assert(v2 == v);
+ assert(v2.get_allocator() == v.get_allocator());
+ }
+#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+ {
+ std::vector<bool, other_allocator<bool> > v(3, 2, other_allocator<bool>(5));
+ std::vector<bool, other_allocator<bool> > v2 = v;
+ assert(v2 == v);
+ assert(v2.get_allocator() == other_allocator<bool>(-2));
+ }
+#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE
+#if __cplusplus >= 201103L
+ {
+ bool a[] = {0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0};
+ bool* an = a + sizeof(a)/sizeof(a[0]);
+ test(std::vector<bool, min_allocator<bool>>(a, an));
+ }
+ {
+ std::vector<bool, min_allocator<bool> > v(3, 2, min_allocator<bool>());
+ std::vector<bool, min_allocator<bool> > v2 = v;
+ assert(v2 == v);
+ assert(v2.get_allocator() == v.get_allocator());
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/vector.bool/copy_alloc.pass.cpp b/test/std/containers/sequences/vector.bool/copy_alloc.pass.cpp
new file mode 100644
index 000000000000..2f0192b995ad
--- /dev/null
+++ b/test/std/containers/sequences/vector.bool/copy_alloc.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector(const vector& v, const allocator_type& a);
+
+#include <vector>
+#include <cassert>
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+template <class C>
+void
+test(const C& x, const typename C::allocator_type& a)
+{
+ unsigned s = x.size();
+ C c(x, a);
+ assert(c.__invariants());
+ assert(c.size() == s);
+ assert(c == x);
+}
+
+int main()
+{
+ {
+ int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 1, 0};
+ int* an = a + sizeof(a)/sizeof(a[0]);
+ test(std::vector<bool>(a, an), std::allocator<bool>());
+ }
+ {
+ std::vector<bool, test_allocator<bool> > l(3, 2, test_allocator<bool>(5));
+ std::vector<bool, test_allocator<bool> > l2(l, test_allocator<bool>(3));
+ assert(l2 == l);
+ assert(l2.get_allocator() == test_allocator<bool>(3));
+ }
+ {
+ std::vector<bool, other_allocator<bool> > l(3, 2, other_allocator<bool>(5));
+ std::vector<bool, other_allocator<bool> > l2(l, other_allocator<bool>(3));
+ assert(l2 == l);
+ assert(l2.get_allocator() == other_allocator<bool>(3));
+ }
+#if __cplusplus >= 201103L
+ {
+ int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 1, 0};
+ int* an = a + sizeof(a)/sizeof(a[0]);
+ test(std::vector<bool, min_allocator<bool>>(a, an), min_allocator<bool>());
+ }
+ {
+ std::vector<bool, min_allocator<bool> > l(3, 2, min_allocator<bool>());
+ std::vector<bool, min_allocator<bool> > l2(l, min_allocator<bool>());
+ assert(l2 == l);
+ assert(l2.get_allocator() == min_allocator<bool>());
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/vector.bool/default_noexcept.pass.cpp b/test/std/containers/sequences/vector.bool/default_noexcept.pass.cpp
new file mode 100644
index 000000000000..b94588ead93b
--- /dev/null
+++ b/test/std/containers/sequences/vector.bool/default_noexcept.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector<bool>()
+// noexcept(is_nothrow_default_constructible<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <vector>
+#include <cassert>
+
+#include "test_allocator.h"
+
+template <class T>
+struct some_alloc
+{
+ typedef T value_type;
+ some_alloc(const some_alloc&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::vector<bool> C;
+ static_assert(std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::vector<bool, test_allocator<bool>> C;
+ static_assert(std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::vector<bool, other_allocator<bool>> C;
+ static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::vector<bool, some_alloc<bool>> C;
+ static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/vector.bool/dtor_noexcept.pass.cpp b/test/std/containers/sequences/vector.bool/dtor_noexcept.pass.cpp
new file mode 100644
index 000000000000..682e74ef03c2
--- /dev/null
+++ b/test/std/containers/sequences/vector.bool/dtor_noexcept.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// ~vector<bool>() // implied noexcept;
+
+#include <vector>
+#include <cassert>
+
+#include "test_allocator.h"
+
+#if __has_feature(cxx_noexcept)
+
+template <class T>
+struct some_alloc
+{
+ typedef T value_type;
+ some_alloc(const some_alloc&);
+ ~some_alloc() noexcept(false);
+};
+
+#endif
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::vector<bool> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::vector<bool, test_allocator<bool>> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::vector<bool, other_allocator<bool>> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::vector<bool, some_alloc<bool>> C;
+ static_assert(!std::is_nothrow_destructible<C>::value, "");
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/vector.bool/emplace.pass.cpp b/test/std/containers/sequences/vector.bool/emplace.pass.cpp
new file mode 100644
index 000000000000..f3fd1e9926f0
--- /dev/null
+++ b/test/std/containers/sequences/vector.bool/emplace.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// template <class... Args> iterator emplace(const_iterator pos, Args&&... args);
+
+#include <vector>
+#include <cassert>
+#include "min_allocator.h"
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::vector<bool> C;
+ C c;
+
+ C::iterator i = c.emplace(c.cbegin());
+ assert(i == c.begin());
+ assert(c.size() == 1);
+ assert(c.front() == false);
+
+ i = c.emplace(c.cend(), true);
+ assert(i == c.end()-1);
+ assert(c.size() == 2);
+ assert(c.front() == false);
+ assert(c.back() == true);
+
+ i = c.emplace(c.cbegin()+1, 1 == 1);
+ assert(i == c.begin()+1);
+ assert(c.size() == 3);
+ assert(c.front() == false);
+ assert(c[1] == true);
+ assert(c.back() == true);
+ }
+ {
+ typedef std::vector<bool, min_allocator<bool>> C;
+ C c;
+
+ C::iterator i = c.emplace(c.cbegin());
+ assert(i == c.begin());
+ assert(c.size() == 1);
+ assert(c.front() == false);
+
+ i = c.emplace(c.cend(), true);
+ assert(i == c.end()-1);
+ assert(c.size() == 2);
+ assert(c.front() == false);
+ assert(c.back() == true);
+
+ i = c.emplace(c.cbegin()+1, 1 == 1);
+ assert(i == c.begin()+1);
+ assert(c.size() == 3);
+ assert(c.size() == 3);
+ assert(c.front() == false);
+ assert(c[1] == true);
+ assert(c.back() == true);
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/vector.bool/emplace_back.pass.cpp b/test/std/containers/sequences/vector.bool/emplace_back.pass.cpp
new file mode 100644
index 000000000000..57aa47822f8a
--- /dev/null
+++ b/test/std/containers/sequences/vector.bool/emplace_back.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector.bool
+
+// template <class... Args> void emplace_back(Args&&... args);
+
+#include <vector>
+#include <cassert>
+#include "min_allocator.h"
+
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::vector<bool> C;
+ C c;
+ c.emplace_back();
+ assert(c.size() == 1);
+ assert(c.front() == false);
+ c.emplace_back(true);
+ assert(c.size() == 2);
+ assert(c.front() == false);
+ assert(c.back() == true);
+ c.emplace_back(1 == 1);
+ assert(c.size() == 3);
+ assert(c.front() == false);
+ assert(c[1] == true);
+ assert(c.back() == true);
+ }
+ {
+ typedef std::vector<bool, min_allocator<bool>> C;
+ C c;
+
+ c.emplace_back();
+ assert(c.size() == 1);
+ assert(c.front() == false);
+ c.emplace_back(true);
+ assert(c.size() == 2);
+ assert(c.front() == false);
+ assert(c.back() == true);
+ c.emplace_back(1 == 1);
+ assert(c.size() == 3);
+ assert(c.front() == false);
+ assert(c[1] == true);
+ assert(c.back() == true);
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/vector.bool/erase_iter.pass.cpp b/test/std/containers/sequences/vector.bool/erase_iter.pass.cpp
new file mode 100644
index 000000000000..cbf26dd570a5
--- /dev/null
+++ b/test/std/containers/sequences/vector.bool/erase_iter.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// iterator erase(const_iterator position);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ bool a1[] = {1, 0, 1};
+ {
+ std::vector<bool> l1(a1, a1+3);
+ std::vector<bool>::const_iterator i = l1.begin();
+ ++i;
+ std::vector<bool>::iterator j = l1.erase(i);
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ assert(*j == true);
+ assert(*l1.begin() == 1);
+ assert(*next(l1.begin()) == true);
+ j = l1.erase(j);
+ assert(j == l1.end());
+ assert(l1.size() == 1);
+ assert(distance(l1.begin(), l1.end()) == 1);
+ assert(*l1.begin() == true);
+ j = l1.erase(l1.begin());
+ assert(j == l1.end());
+ assert(l1.size() == 0);
+ assert(distance(l1.begin(), l1.end()) == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<bool, min_allocator<bool>> l1(a1, a1+3);
+ std::vector<bool, min_allocator<bool>>::const_iterator i = l1.begin();
+ ++i;
+ std::vector<bool, min_allocator<bool>>::iterator j = l1.erase(i);
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ assert(*j == true);
+ assert(*l1.begin() == 1);
+ assert(*next(l1.begin()) == true);
+ j = l1.erase(j);
+ assert(j == l1.end());
+ assert(l1.size() == 1);
+ assert(distance(l1.begin(), l1.end()) == 1);
+ assert(*l1.begin() == true);
+ j = l1.erase(l1.begin());
+ assert(j == l1.end());
+ assert(l1.size() == 0);
+ assert(distance(l1.begin(), l1.end()) == 0);
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/vector.bool/erase_iter_iter.pass.cpp b/test/std/containers/sequences/vector.bool/erase_iter_iter.pass.cpp
new file mode 100644
index 000000000000..2c2c4cc48616
--- /dev/null
+++ b/test/std/containers/sequences/vector.bool/erase_iter_iter.pass.cpp
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// iterator erase(const_iterator first, const_iterator last);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ bool a1[] = {1, 0, 1};
+ {
+ std::vector<bool> l1(a1, a1+3);
+ std::vector<bool>::iterator i = l1.erase(l1.cbegin(), l1.cbegin());
+ assert(l1.size() == 3);
+ assert(distance(l1.cbegin(), l1.cend()) == 3);
+ assert(i == l1.begin());
+ }
+ {
+ std::vector<bool> l1(a1, a1+3);
+ std::vector<bool>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin()));
+ assert(l1.size() == 2);
+ assert(distance(l1.cbegin(), l1.cend()) == 2);
+ assert(i == l1.begin());
+ assert(l1 == std::vector<bool>(a1+1, a1+3));
+ }
+ {
+ std::vector<bool> l1(a1, a1+3);
+ std::vector<bool>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin(), 2));
+ assert(l1.size() == 1);
+ assert(distance(l1.cbegin(), l1.cend()) == 1);
+ assert(i == l1.begin());
+ assert(l1 == std::vector<bool>(a1+2, a1+3));
+ }
+ {
+ std::vector<bool> l1(a1, a1+3);
+ std::vector<bool>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin(), 3));
+ assert(l1.size() == 0);
+ assert(distance(l1.cbegin(), l1.cend()) == 0);
+ assert(i == l1.begin());
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<bool, min_allocator<bool>> l1(a1, a1+3);
+ std::vector<bool, min_allocator<bool>>::iterator i = l1.erase(l1.cbegin(), l1.cbegin());
+ assert(l1.size() == 3);
+ assert(distance(l1.cbegin(), l1.cend()) == 3);
+ assert(i == l1.begin());
+ }
+ {
+ std::vector<bool, min_allocator<bool>> l1(a1, a1+3);
+ std::vector<bool, min_allocator<bool>>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin()));
+ assert(l1.size() == 2);
+ assert(distance(l1.cbegin(), l1.cend()) == 2);
+ assert(i == l1.begin());
+ assert((l1 == std::vector<bool, min_allocator<bool>>(a1+1, a1+3)));
+ }
+ {
+ std::vector<bool, min_allocator<bool>> l1(a1, a1+3);
+ std::vector<bool, min_allocator<bool>>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin(), 2));
+ assert(l1.size() == 1);
+ assert(distance(l1.cbegin(), l1.cend()) == 1);
+ assert(i == l1.begin());
+ assert((l1 == std::vector<bool, min_allocator<bool>>(a1+2, a1+3)));
+ }
+ {
+ std::vector<bool, min_allocator<bool>> l1(a1, a1+3);
+ std::vector<bool, min_allocator<bool>>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin(), 3));
+ assert(l1.size() == 0);
+ assert(distance(l1.cbegin(), l1.cend()) == 0);
+ assert(i == l1.begin());
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/vector.bool/find.pass.cpp b/test/std/containers/sequences/vector.bool/find.pass.cpp
new file mode 100644
index 000000000000..75567a9b7bbc
--- /dev/null
+++ b/test/std/containers/sequences/vector.bool/find.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// std::find with vector<bool>::iterator
+
+// http://llvm.org/bugs/show_bug.cgi?id=16816
+
+#include <vector>
+#include <cassert>
+
+int main()
+{
+ {
+ for (unsigned i = 1; i < 256; ++i)
+ {
+ std::vector<bool> b(i,true);
+ std::vector<bool>::iterator j = std::find(b.begin()+1, b.end(), false);
+ assert(j-b.begin() == i);
+ assert(b.end() == j);
+ }
+ }
+ {
+ for (unsigned i = 1; i < 256; ++i)
+ {
+ std::vector<bool> b(i,false);
+ std::vector<bool>::iterator j = std::find(b.begin()+1, b.end(), true);
+ assert(j-b.begin() == i);
+ assert(b.end() == j);
+ }
+ }
+}
diff --git a/test/std/containers/sequences/vector.bool/initializer_list.pass.cpp b/test/std/containers/sequences/vector.bool/initializer_list.pass.cpp
new file mode 100644
index 000000000000..b9b468654497
--- /dev/null
+++ b/test/std/containers/sequences/vector.bool/initializer_list.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector(initializer_list<value_type> il);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ std::vector<bool> d = {true, false, false, true};
+ assert(d.size() == 4);
+ assert(d[0] == true);
+ assert(d[1] == false);
+ assert(d[2] == false);
+ assert(d[3] == true);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<bool, min_allocator<bool>> d = {true, false, false, true};
+ assert(d.size() == 4);
+ assert(d[0] == true);
+ assert(d[1] == false);
+ assert(d[2] == false);
+ assert(d[3] == true);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/containers/sequences/vector.bool/initializer_list_alloc.pass.cpp b/test/std/containers/sequences/vector.bool/initializer_list_alloc.pass.cpp
new file mode 100644
index 000000000000..aea3ad763cde
--- /dev/null
+++ b/test/std/containers/sequences/vector.bool/initializer_list_alloc.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector(initializer_list<value_type> il, const Allocator& a = allocator_type());
+
+#include <vector>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ std::vector<bool, test_allocator<bool>> d({true, false, false, true}, test_allocator<bool>(3));
+ assert(d.get_allocator() == test_allocator<bool>(3));
+ assert(d.size() == 4);
+ assert(d[0] == true);
+ assert(d[1] == false);
+ assert(d[2] == false);
+ assert(d[3] == true);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<bool, min_allocator<bool>> d({true, false, false, true}, min_allocator<bool>());
+ assert(d.get_allocator() == min_allocator<bool>());
+ assert(d.size() == 4);
+ assert(d[0] == true);
+ assert(d[1] == false);
+ assert(d[2] == false);
+ assert(d[3] == true);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/containers/sequences/vector.bool/insert_iter_initializer_list.pass.cpp b/test/std/containers/sequences/vector.bool/insert_iter_initializer_list.pass.cpp
new file mode 100644
index 000000000000..c081cc81c592
--- /dev/null
+++ b/test/std/containers/sequences/vector.bool/insert_iter_initializer_list.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// iterator insert(const_iterator p, initializer_list<value_type> il);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ std::vector<bool> d(10, true);
+ std::vector<bool>::iterator i = d.insert(d.cbegin() + 2, {false, true, true, false});
+ assert(d.size() == 14);
+ assert(i == d.begin() + 2);
+ assert(d[0] == true);
+ assert(d[1] == true);
+ assert(d[2] == false);
+ assert(d[3] == true);
+ assert(d[4] == true);
+ assert(d[5] == false);
+ assert(d[6] == true);
+ assert(d[7] == true);
+ assert(d[8] == true);
+ assert(d[9] == true);
+ assert(d[10] == true);
+ assert(d[11] == true);
+ assert(d[12] == true);
+ assert(d[13] == true);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<bool, min_allocator<bool>> d(10, true);
+ std::vector<bool, min_allocator<bool>>::iterator i = d.insert(d.cbegin() + 2, {false, true, true, false});
+ assert(d.size() == 14);
+ assert(i == d.begin() + 2);
+ assert(d[0] == true);
+ assert(d[1] == true);
+ assert(d[2] == false);
+ assert(d[3] == true);
+ assert(d[4] == true);
+ assert(d[5] == false);
+ assert(d[6] == true);
+ assert(d[7] == true);
+ assert(d[8] == true);
+ assert(d[9] == true);
+ assert(d[10] == true);
+ assert(d[11] == true);
+ assert(d[12] == true);
+ assert(d[13] == true);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/containers/sequences/vector.bool/insert_iter_iter_iter.pass.cpp b/test/std/containers/sequences/vector.bool/insert_iter_iter_iter.pass.cpp
new file mode 100644
index 000000000000..e51f8b589c7f
--- /dev/null
+++ b/test/std/containers/sequences/vector.bool/insert_iter_iter_iter.pass.cpp
@@ -0,0 +1,126 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// template <class Iter>
+// iterator insert(const_iterator position, Iter first, Iter last);
+
+#include <vector>
+#include <cassert>
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::vector<bool> v(100);
+ bool a[] = {1, 0, 0, 1, 1};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::vector<bool>::iterator i = v.insert(v.cbegin() + 10, input_iterator<const bool*>(a),
+ input_iterator<const bool*>(a+N));
+ assert(v.size() == 100 + N);
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == 0);
+ for (int k = 0; k < N; ++j, ++k)
+ assert(v[j] == a[k]);
+ for (; j < v.size(); ++j)
+ assert(v[j] == 0);
+ }
+ {
+ std::vector<bool> v(100);
+ bool a[] = {1, 0, 0, 1, 1};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::vector<bool>::iterator i = v.insert(v.cbegin() + 10, forward_iterator<const bool*>(a),
+ forward_iterator<const bool*>(a+N));
+ assert(v.size() == 100 + N);
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == 0);
+ for (int k = 0; k < N; ++j, ++k)
+ assert(v[j] == a[k]);
+ for (; j < 105; ++j)
+ assert(v[j] == 0);
+ }
+ {
+ std::vector<bool> v(100);
+ while(v.size() < v.capacity()) v.push_back(false);
+ size_t sz = v.size();
+ bool a[] = {1, 0, 0, 1, 1};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::vector<bool>::iterator i = v.insert(v.cbegin() + 10, forward_iterator<const bool*>(a),
+ forward_iterator<const bool*>(a+N));
+ assert(v.size() == sz + N);
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == 0);
+ for (int k = 0; k < N; ++j, ++k)
+ assert(v[j] == a[k]);
+ for (; j < v.size(); ++j)
+ assert(v[j] == 0);
+ }
+ {
+ std::vector<bool> v(100);
+ while(v.size() < v.capacity()) v.push_back(false);
+ v.pop_back(); v.pop_back(); v.pop_back();
+ size_t sz = v.size();
+ bool a[] = {1, 0, 0, 1, 1};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::vector<bool>::iterator i = v.insert(v.cbegin() + 10, forward_iterator<const bool*>(a),
+ forward_iterator<const bool*>(a+N));
+ assert(v.size() == sz + N);
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == 0);
+ for (int k = 0; k < N; ++j, ++k)
+ assert(v[j] == a[k]);
+ for (; j < v.size(); ++j)
+ assert(v[j] == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<bool, min_allocator<bool>> v(100);
+ bool a[] = {1, 0, 0, 1, 1};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::vector<bool, min_allocator<bool>>::iterator i = v.insert(v.cbegin() + 10, input_iterator<const bool*>(a),
+ input_iterator<const bool*>(a+N));
+ assert(v.size() == 100 + N);
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == 0);
+ for (int k = 0; k < N; ++j, ++k)
+ assert(v[j] == a[k]);
+ for (; j < v.size(); ++j)
+ assert(v[j] == 0);
+ }
+ {
+ std::vector<bool, min_allocator<bool>> v(100);
+ bool a[] = {1, 0, 0, 1, 1};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::vector<bool, min_allocator<bool>>::iterator i = v.insert(v.cbegin() + 10, forward_iterator<const bool*>(a),
+ forward_iterator<const bool*>(a+N));
+ assert(v.size() == 100 + N);
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == 0);
+ for (int k = 0; k < N; ++j, ++k)
+ assert(v[j] == a[k]);
+ for (; j < v.size(); ++j)
+ assert(v[j] == 0);
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/vector.bool/insert_iter_size_value.pass.cpp b/test/std/containers/sequences/vector.bool/insert_iter_size_value.pass.cpp
new file mode 100644
index 000000000000..710ad4885f09
--- /dev/null
+++ b/test/std/containers/sequences/vector.bool/insert_iter_size_value.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// iterator insert(const_iterator position, size_type n, const value_type& x);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::vector<bool> v(100);
+ std::vector<bool>::iterator i = v.insert(v.cbegin() + 10, 5, 1);
+ assert(v.size() == 105);
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == 0);
+ for (; j < 15; ++j)
+ assert(v[j] == 1);
+ for (++j; j < v.size(); ++j)
+ assert(v[j] == 0);
+ }
+ {
+ std::vector<bool> v(100);
+ while(v.size() < v.capacity()) v.push_back(false);
+ size_t sz = v.size();
+ std::vector<bool>::iterator i = v.insert(v.cbegin() + 10, 5, 1);
+ assert(v.size() == sz + 5);
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == 0);
+ for (; j < 15; ++j)
+ assert(v[j] == 1);
+ for (++j; j < v.size(); ++j)
+ assert(v[j] == 0);
+ }
+ {
+ std::vector<bool> v(100);
+ while(v.size() < v.capacity()) v.push_back(false);
+ v.pop_back(); v.pop_back();
+ size_t sz = v.size();
+ std::vector<bool>::iterator i = v.insert(v.cbegin() + 10, 5, 1);
+ assert(v.size() == sz + 5);
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == 0);
+ for (; j < 15; ++j)
+ assert(v[j] == 1);
+ for (++j; j < v.size(); ++j)
+ assert(v[j] == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<bool, min_allocator<bool>> v(100);
+ std::vector<bool, min_allocator<bool>>::iterator i = v.insert(v.cbegin() + 10, 5, 1);
+ assert(v.size() == 105);
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == 0);
+ for (; j < 15; ++j)
+ assert(v[j] == 1);
+ for (++j; j < v.size(); ++j)
+ assert(v[j] == 0);
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/vector.bool/insert_iter_value.pass.cpp b/test/std/containers/sequences/vector.bool/insert_iter_value.pass.cpp
new file mode 100644
index 000000000000..51c4626de0d0
--- /dev/null
+++ b/test/std/containers/sequences/vector.bool/insert_iter_value.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// iterator insert(const_iterator position, const value_type& x);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::vector<bool> v(100);
+ std::vector<bool>::iterator i = v.insert(v.cbegin() + 10, 1);
+ assert(v.size() == 101);
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == 0);
+ assert(v[j] == 1);
+ for (++j; j < v.size(); ++j)
+ assert(v[j] == 0);
+ }
+ {
+ std::vector<bool> v(100);
+ while(v.size() < v.capacity()) v.push_back(false);
+ size_t sz = v.size();
+ std::vector<bool>::iterator i = v.insert(v.cbegin() + 10, 1);
+ assert(v.size() == sz + 1);
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == 0);
+ assert(v[j] == 1);
+ for (++j; j < v.size(); ++j)
+ assert(v[j] == 0);
+ }
+ {
+ std::vector<bool> v(100);
+ while(v.size() < v.capacity()) v.push_back(false);
+ v.pop_back(); v.pop_back();
+ size_t sz = v.size();
+ std::vector<bool>::iterator i = v.insert(v.cbegin() + 10, 1);
+ assert(v.size() == sz + 1);
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == 0);
+ assert(v[j] == 1);
+ for (++j; j < v.size(); ++j)
+ assert(v[j] == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<bool, min_allocator<bool>> v(100);
+ std::vector<bool, min_allocator<bool>>::iterator i = v.insert(v.cbegin() + 10, 1);
+ assert(v.size() == 101);
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == 0);
+ assert(v[j] == 1);
+ for (++j; j < v.size(); ++j)
+ assert(v[j] == 0);
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/vector.bool/iterators.pass.cpp b/test/std/containers/sequences/vector.bool/iterators.pass.cpp
new file mode 100644
index 000000000000..c54fa4a80a95
--- /dev/null
+++ b/test/std/containers/sequences/vector.bool/iterators.pass.cpp
@@ -0,0 +1,123 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// iterator begin();
+// iterator end();
+// const_iterator begin() const;
+// const_iterator end() const;
+// const_iterator cbegin() const;
+// const_iterator cend() const;
+
+#include <vector>
+#include <cassert>
+#include <iterator>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef bool T;
+ typedef std::vector<T> C;
+ C c;
+ C::iterator i = c.begin();
+ C::iterator j = c.end();
+ assert(std::distance(i, j) == 0);
+ assert(i == j);
+ }
+ {
+ typedef bool T;
+ typedef std::vector<T> C;
+ const C c;
+ C::const_iterator i = c.begin();
+ C::const_iterator j = c.end();
+ assert(std::distance(i, j) == 0);
+ assert(i == j);
+ }
+ {
+ typedef bool T;
+ typedef std::vector<T> C;
+ C c;
+ C::const_iterator i = c.cbegin();
+ C::const_iterator j = c.cend();
+ assert(std::distance(i, j) == 0);
+ assert(i == j);
+ assert(i == c.end());
+ }
+ {
+ typedef bool T;
+ typedef std::vector<T> C;
+ C::iterator i;
+ C::const_iterator j;
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef bool T;
+ typedef std::vector<T, min_allocator<T>> C;
+ C c;
+ C::iterator i = c.begin();
+ C::iterator j = c.end();
+ assert(std::distance(i, j) == 0);
+ assert(i == j);
+ }
+ {
+ typedef bool T;
+ typedef std::vector<T, min_allocator<T>> C;
+ const C c;
+ C::const_iterator i = c.begin();
+ C::const_iterator j = c.end();
+ assert(std::distance(i, j) == 0);
+ assert(i == j);
+ }
+ {
+ typedef bool T;
+ typedef std::vector<T, min_allocator<T>> C;
+ C c;
+ C::const_iterator i = c.cbegin();
+ C::const_iterator j = c.cend();
+ assert(std::distance(i, j) == 0);
+ assert(i == j);
+ assert(i == c.end());
+ }
+ {
+ typedef bool T;
+ typedef std::vector<T, min_allocator<T>> C;
+ C::iterator i;
+ C::const_iterator j;
+ }
+#endif
+#if _LIBCPP_STD_VER > 11
+ { // N3644 testing
+ std::vector<bool>::iterator ii1{}, ii2{};
+ std::vector<bool>::iterator ii4 = ii1;
+ std::vector<bool>::const_iterator cii{};
+ assert ( ii1 == ii2 );
+ assert ( ii1 == ii4 );
+
+ assert (!(ii1 != ii2 ));
+
+ assert ( (ii1 == cii ));
+ assert ( (cii == ii1 ));
+ assert (!(ii1 != cii ));
+ assert (!(cii != ii1 ));
+ assert (!(ii1 < cii ));
+ assert (!(cii < ii1 ));
+ assert ( (ii1 <= cii ));
+ assert ( (cii <= ii1 ));
+ assert (!(ii1 > cii ));
+ assert (!(cii > ii1 ));
+ assert ( (ii1 >= cii ));
+ assert ( (cii >= ii1 ));
+ assert (cii - ii1 == 0);
+ assert (ii1 - cii == 0);
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/vector.bool/move.pass.cpp b/test/std/containers/sequences/vector.bool/move.pass.cpp
new file mode 100644
index 000000000000..e877292ced77
--- /dev/null
+++ b/test/std/containers/sequences/vector.bool/move.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector(vector&& c);
+
+#include <vector>
+#include <cassert>
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::vector<bool, test_allocator<bool> > l(test_allocator<bool>(5));
+ std::vector<bool, test_allocator<bool> > lo(test_allocator<bool>(5));
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ std::vector<bool, test_allocator<bool> > l2 = std::move(l);
+ assert(l2 == lo);
+ assert(l.empty());
+ assert(l2.get_allocator() == lo.get_allocator());
+ }
+ {
+ std::vector<bool, other_allocator<bool> > l(other_allocator<bool>(5));
+ std::vector<bool, other_allocator<bool> > lo(other_allocator<bool>(5));
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ std::vector<bool, other_allocator<bool> > l2 = std::move(l);
+ assert(l2 == lo);
+ assert(l.empty());
+ assert(l2.get_allocator() == lo.get_allocator());
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<bool, min_allocator<bool> > l(min_allocator<bool>{});
+ std::vector<bool, min_allocator<bool> > lo(min_allocator<bool>{});
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ std::vector<bool, min_allocator<bool> > l2 = std::move(l);
+ assert(l2 == lo);
+ assert(l.empty());
+ assert(l2.get_allocator() == lo.get_allocator());
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/sequences/vector.bool/move_alloc.pass.cpp b/test/std/containers/sequences/vector.bool/move_alloc.pass.cpp
new file mode 100644
index 000000000000..deee93261971
--- /dev/null
+++ b/test/std/containers/sequences/vector.bool/move_alloc.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector(vector&& c, const allocator_type& a);
+
+#include <vector>
+#include <cassert>
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::vector<bool, test_allocator<bool> > l(test_allocator<bool>(5));
+ std::vector<bool, test_allocator<bool> > lo(test_allocator<bool>(5));
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ std::vector<bool, test_allocator<bool> > l2(std::move(l), test_allocator<bool>(6));
+ assert(l2 == lo);
+ assert(!l.empty());
+ assert(l2.get_allocator() == test_allocator<bool>(6));
+ }
+ {
+ std::vector<bool, test_allocator<bool> > l(test_allocator<bool>(5));
+ std::vector<bool, test_allocator<bool> > lo(test_allocator<bool>(5));
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ std::vector<bool, test_allocator<bool> > l2(std::move(l), test_allocator<bool>(5));
+ assert(l2 == lo);
+ assert(l.empty());
+ assert(l2.get_allocator() == test_allocator<bool>(5));
+ }
+ {
+ std::vector<bool, other_allocator<bool> > l(other_allocator<bool>(5));
+ std::vector<bool, other_allocator<bool> > lo(other_allocator<bool>(5));
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ std::vector<bool, other_allocator<bool> > l2(std::move(l), other_allocator<bool>(4));
+ assert(l2 == lo);
+ assert(!l.empty());
+ assert(l2.get_allocator() == other_allocator<bool>(4));
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<bool, min_allocator<bool> > l(min_allocator<bool>{});
+ std::vector<bool, min_allocator<bool> > lo(min_allocator<bool>{});
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ std::vector<bool, min_allocator<bool> > l2(std::move(l), min_allocator<bool>());
+ assert(l2 == lo);
+ assert(l.empty());
+ assert(l2.get_allocator() == min_allocator<bool>());
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/sequences/vector.bool/move_assign_noexcept.pass.cpp b/test/std/containers/sequences/vector.bool/move_assign_noexcept.pass.cpp
new file mode 100644
index 000000000000..b580eb4ae3b0
--- /dev/null
+++ b/test/std/containers/sequences/vector.bool/move_assign_noexcept.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector& operator=(vector&& c)
+// noexcept(
+// allocator_type::propagate_on_container_move_assignment::value &&
+// is_nothrow_move_assignable<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <vector>
+#include <cassert>
+
+#include "test_allocator.h"
+
+template <class T>
+struct some_alloc
+{
+ typedef T value_type;
+ some_alloc(const some_alloc&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::vector<bool> C;
+ static_assert(std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::vector<bool, test_allocator<bool>> C;
+ static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::vector<bool, other_allocator<bool>> C;
+ static_assert(std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::vector<bool, some_alloc<bool>> C;
+ static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/vector.bool/move_noexcept.pass.cpp b/test/std/containers/sequences/vector.bool/move_noexcept.pass.cpp
new file mode 100644
index 000000000000..132186b555f2
--- /dev/null
+++ b/test/std/containers/sequences/vector.bool/move_noexcept.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector(vector&&)
+// noexcept(is_nothrow_move_constructible<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <vector>
+#include <cassert>
+
+#include "test_allocator.h"
+
+template <class T>
+struct some_alloc
+{
+ typedef T value_type;
+ some_alloc(const some_alloc&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::vector<bool> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::vector<bool, test_allocator<bool>> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::vector<bool, other_allocator<bool>> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::vector<bool, some_alloc<bool>> C;
+ // In C++17, move constructors for allocators are not allowed to throw
+#if TEST_STD_VER > 14
+ static_assert( std::is_nothrow_move_constructible<C>::value, "");
+#else
+ static_assert(!std::is_nothrow_move_constructible<C>::value, "");
+#endif
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/vector.bool/op_equal_initializer_list.pass.cpp b/test/std/containers/sequences/vector.bool/op_equal_initializer_list.pass.cpp
new file mode 100644
index 000000000000..ef3dc5d10796
--- /dev/null
+++ b/test/std/containers/sequences/vector.bool/op_equal_initializer_list.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector& operator=(initializer_list<value_type> il);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ std::vector<bool> d;
+ d = {true, false, false, true};
+ assert(d.size() == 4);
+ assert(d[0] == true);
+ assert(d[1] == false);
+ assert(d[2] == false);
+ assert(d[3] == true);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<bool, min_allocator<bool>> d;
+ d = {true, false, false, true};
+ assert(d.size() == 4);
+ assert(d[0] == true);
+ assert(d[1] == false);
+ assert(d[2] == false);
+ assert(d[3] == true);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/containers/sequences/vector.bool/push_back.pass.cpp b/test/std/containers/sequences/vector.bool/push_back.pass.cpp
new file mode 100644
index 000000000000..c6b0fbf41853
--- /dev/null
+++ b/test/std/containers/sequences/vector.bool/push_back.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// void push_back(const value_type& x);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ bool a[] = {0, 1, 1, 0, 1, 0, 0};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::vector<bool> c;
+ for (unsigned i = 0; i < N; ++i)
+ {
+ c.push_back(a[i]);
+ assert(c.size() == i+1);
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == a[j]);
+ }
+ }
+#if __cplusplus >= 201103L
+ {
+ bool a[] = {0, 1, 1, 0, 1, 0, 0};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::vector<bool, min_allocator<bool>> c;
+ for (unsigned i = 0; i < N; ++i)
+ {
+ c.push_back(a[i]);
+ assert(c.size() == i+1);
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == a[j]);
+ }
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/vector.bool/reserve.pass.cpp b/test/std/containers/sequences/vector.bool/reserve.pass.cpp
new file mode 100644
index 000000000000..be717a3be8a8
--- /dev/null
+++ b/test/std/containers/sequences/vector.bool/reserve.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// void reserve(size_type n);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::vector<bool> v;
+ v.reserve(10);
+ assert(v.capacity() >= 10);
+ }
+ {
+ std::vector<bool> v(100);
+ assert(v.capacity() >= 100);
+ v.reserve(50);
+ assert(v.size() == 100);
+ assert(v.capacity() >= 100);
+ v.reserve(150);
+ assert(v.size() == 100);
+ assert(v.capacity() >= 150);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<bool, min_allocator<bool>> v;
+ v.reserve(10);
+ assert(v.capacity() >= 10);
+ }
+ {
+ std::vector<bool, min_allocator<bool>> v(100);
+ assert(v.capacity() >= 100);
+ v.reserve(50);
+ assert(v.size() == 100);
+ assert(v.capacity() >= 100);
+ v.reserve(150);
+ assert(v.size() == 100);
+ assert(v.capacity() >= 150);
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/vector.bool/resize_size.pass.cpp b/test/std/containers/sequences/vector.bool/resize_size.pass.cpp
new file mode 100644
index 000000000000..f75720c94ea3
--- /dev/null
+++ b/test/std/containers/sequences/vector.bool/resize_size.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// void resize(size_type sz);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::vector<bool> v(100);
+ v.resize(50);
+ assert(v.size() == 50);
+ assert(v.capacity() >= 100);
+ v.resize(200);
+ assert(v.size() == 200);
+ assert(v.capacity() >= 200);
+ v.reserve(400);
+ v.resize(300); // check the case when resizing and we already have room
+ assert(v.size() == 300);
+ assert(v.capacity() >= 400);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<bool, min_allocator<bool>> v(100);
+ v.resize(50);
+ assert(v.size() == 50);
+ assert(v.capacity() >= 100);
+ v.resize(200);
+ assert(v.size() == 200);
+ assert(v.capacity() >= 200);
+ v.reserve(400);
+ v.resize(300); // check the case when resizing and we already have room
+ assert(v.size() == 300);
+ assert(v.capacity() >= 400);
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/vector.bool/resize_size_value.pass.cpp b/test/std/containers/sequences/vector.bool/resize_size_value.pass.cpp
new file mode 100644
index 000000000000..8cecf44d2fb0
--- /dev/null
+++ b/test/std/containers/sequences/vector.bool/resize_size_value.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// void resize(size_type sz, const value_type& x);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::vector<bool> v(100);
+ v.resize(50, 1);
+ assert(v.size() == 50);
+ assert(v.capacity() >= 100);
+ assert(v == std::vector<bool>(50));
+ v.resize(200, 1);
+ assert(v.size() == 200);
+ assert(v.capacity() >= 200);
+ for (unsigned i = 0; i < 50; ++i)
+ assert(v[i] == 0);
+ for (unsigned i = 50; i < 200; ++i)
+ assert(v[i] == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<bool, min_allocator<bool>> v(100);
+ v.resize(50, 1);
+ assert(v.size() == 50);
+ assert(v.capacity() >= 100);
+ assert((v == std::vector<bool, min_allocator<bool>>(50)));
+ v.resize(200, 1);
+ assert(v.size() == 200);
+ assert(v.capacity() >= 200);
+ for (unsigned i = 0; i < 50; ++i)
+ assert(v[i] == 0);
+ for (unsigned i = 50; i < 200; ++i)
+ assert(v[i] == 1);
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/vector.bool/shrink_to_fit.pass.cpp b/test/std/containers/sequences/vector.bool/shrink_to_fit.pass.cpp
new file mode 100644
index 000000000000..1f9fcac3d9bf
--- /dev/null
+++ b/test/std/containers/sequences/vector.bool/shrink_to_fit.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// void shrink_to_fit();
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::vector<bool> v(100);
+ v.push_back(1);
+ v.shrink_to_fit();
+ assert(v.capacity() >= 101);
+ assert(v.size() >= 101);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<bool, min_allocator<bool>> v(100);
+ v.push_back(1);
+ v.shrink_to_fit();
+ assert(v.capacity() >= 101);
+ assert(v.size() >= 101);
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/vector.bool/swap.pass.cpp b/test/std/containers/sequences/vector.bool/swap.pass.cpp
new file mode 100644
index 000000000000..a92c6a6c165f
--- /dev/null
+++ b/test/std/containers/sequences/vector.bool/swap.pass.cpp
@@ -0,0 +1,98 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// void swap(vector& x);
+
+#include <vector>
+#include <cassert>
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::vector<bool> v1(100);
+ std::vector<bool> v2(200);
+ v1.swap(v2);
+ assert(v1.size() == 200);
+ assert(v1.capacity() >= 200);
+ assert(v2.size() == 100);
+ assert(v2.capacity() >= 100);
+ }
+ {
+ typedef test_allocator<bool> A;
+ std::vector<bool, A> v1(100, true, A(1));
+ std::vector<bool, A> v2(200, false, A(2));
+ swap(v1, v2);
+ assert(v1.size() == 200);
+ assert(v1.capacity() >= 200);
+ assert(v2.size() == 100);
+ assert(v2.capacity() >= 100);
+ assert(v1.get_allocator() == A(1));
+ assert(v2.get_allocator() == A(2));
+ }
+ {
+ typedef other_allocator<bool> A;
+ std::vector<bool, A> v1(100, true, A(1));
+ std::vector<bool, A> v2(200, false, A(2));
+ swap(v1, v2);
+ assert(v1.size() == 200);
+ assert(v1.capacity() >= 200);
+ assert(v2.size() == 100);
+ assert(v2.capacity() >= 100);
+ assert(v1.get_allocator() == A(2));
+ assert(v2.get_allocator() == A(1));
+ }
+ {
+ std::vector<bool> v(2);
+ std::vector<bool>::reference r1 = v[0];
+ std::vector<bool>::reference r2 = v[1];
+ r1 = true;
+ using std::swap;
+ swap(r1, r2);
+ assert(v[0] == false);
+ assert(v[1] == true);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<bool, min_allocator<bool>> v1(100);
+ std::vector<bool, min_allocator<bool>> v2(200);
+ v1.swap(v2);
+ assert(v1.size() == 200);
+ assert(v1.capacity() >= 200);
+ assert(v2.size() == 100);
+ assert(v2.capacity() >= 100);
+ }
+ {
+ typedef min_allocator<bool> A;
+ std::vector<bool, A> v1(100, true, A());
+ std::vector<bool, A> v2(200, false, A());
+ swap(v1, v2);
+ assert(v1.size() == 200);
+ assert(v1.capacity() >= 200);
+ assert(v2.size() == 100);
+ assert(v2.capacity() >= 100);
+ assert(v1.get_allocator() == A());
+ assert(v2.get_allocator() == A());
+ }
+ {
+ std::vector<bool, min_allocator<bool>> v(2);
+ std::vector<bool, min_allocator<bool>>::reference r1 = v[0];
+ std::vector<bool, min_allocator<bool>>::reference r2 = v[1];
+ r1 = true;
+ using std::swap;
+ swap(r1, r2);
+ assert(v[0] == false);
+ assert(v[1] == true);
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/vector.bool/swap_noexcept.pass.cpp b/test/std/containers/sequences/vector.bool/swap_noexcept.pass.cpp
new file mode 100644
index 000000000000..6f36473fa989
--- /dev/null
+++ b/test/std/containers/sequences/vector.bool/swap_noexcept.pass.cpp
@@ -0,0 +1,90 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// void swap(vector& c)
+// noexcept(!allocator_type::propagate_on_container_swap::value ||
+// __is_nothrow_swappable<allocator_type>::value);
+//
+// In C++17, the standard says that swap shall have:
+// noexcept(allocator_traits<Allocator>::propagate_on_container_swap::value ||
+// allocator_traits<Allocator>::is_always_equal::value);
+
+// This tests a conforming extension
+
+#include <vector>
+#include <cassert>
+
+#include "test_allocator.h"
+
+template <class T>
+struct some_alloc
+{
+ typedef T value_type;
+
+ some_alloc() {}
+ some_alloc(const some_alloc&);
+ void deallocate(void*, unsigned) {}
+
+ typedef std::true_type propagate_on_container_swap;
+};
+
+template <class T>
+struct some_alloc2
+{
+ typedef T value_type;
+
+ some_alloc2() {}
+ some_alloc2(const some_alloc2&);
+ void deallocate(void*, unsigned) {}
+
+ typedef std::false_type propagate_on_container_swap;
+ typedef std::true_type is_always_equal;
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::vector<bool> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::vector<bool, test_allocator<bool>> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::vector<bool, other_allocator<bool>> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::vector<bool, some_alloc<bool>> C;
+ C c1, c2;
+#if TEST_STD_VER >= 14
+ // In c++14, if POCS is set, swapping the allocator is required not to throw
+ static_assert( noexcept(swap(c1, c2)), "");
+#else
+ static_assert(!noexcept(swap(c1, c2)), "");
+#endif
+ }
+#if TEST_STD_VER >= 14
+ {
+ typedef std::vector<bool, some_alloc2<bool>> C;
+ C c1, c2;
+ // if the allocators are always equal, then the swap can be noexcept
+ static_assert( noexcept(swap(c1, c2)), "");
+ }
+#endif
+
+#endif
+}
diff --git a/test/std/containers/sequences/vector.bool/types.pass.cpp b/test/std/containers/sequences/vector.bool/types.pass.cpp
new file mode 100644
index 000000000000..b266b3bbb927
--- /dev/null
+++ b/test/std/containers/sequences/vector.bool/types.pass.cpp
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Test nested types and default template args:
+
+// template <class Allocator>
+// class vector<bool, Allocator
+// {
+// public:
+// typedef T value_type;
+// typedef Allocator allocator_type;
+// typedef implementation-defined iterator;
+// typedef implementation-defined const_iterator;
+// typedef typename allocator_type::size_type size_type;
+// typedef typename allocator_type::difference_type difference_type;
+// typedef typename allocator_type::pointer pointer;
+// typedef typename allocator_type::const_pointer const_pointer;
+// typedef std::reverse_iterator<iterator> reverse_iterator;
+// typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
+// };
+
+#include <vector>
+#include <iterator>
+#include <type_traits>
+
+#include "test_allocator.h"
+#include "../../Copyable.h"
+#include "min_allocator.h"
+
+template <class Allocator>
+void
+test()
+{
+ typedef std::vector<bool, Allocator> C;
+
+ static_assert((std::is_same<typename C::value_type, bool>::value), "");
+ static_assert((std::is_same<typename C::value_type, typename Allocator::value_type>::value), "");
+ static_assert((std::is_same<typename C::allocator_type, Allocator>::value), "");
+ static_assert((std::is_same<typename C::size_type, typename std::allocator_traits<Allocator>::size_type>::value), "");
+ static_assert((std::is_same<typename C::difference_type, typename std::allocator_traits<Allocator>::difference_type>::value), "");
+ static_assert((std::is_same<
+ typename std::iterator_traits<typename C::iterator>::iterator_category,
+ std::random_access_iterator_tag>::value), "");
+ static_assert((std::is_same<
+ typename std::iterator_traits<typename C::const_iterator>::iterator_category,
+ std::random_access_iterator_tag>::value), "");
+ static_assert((std::is_same<
+ typename C::reverse_iterator,
+ std::reverse_iterator<typename C::iterator> >::value), "");
+ static_assert((std::is_same<
+ typename C::const_reverse_iterator,
+ std::reverse_iterator<typename C::const_iterator> >::value), "");
+}
+
+int main()
+{
+ test<test_allocator<bool> >();
+ test<std::allocator<bool> >();
+ static_assert((std::is_same<std::vector<bool>::allocator_type,
+ std::allocator<bool> >::value), "");
+#if __cplusplus >= 201103L
+ test<min_allocator<bool> >();
+#endif
+}
diff --git a/test/std/containers/sequences/vector.bool/vector_bool.pass.cpp b/test/std/containers/sequences/vector.bool/vector_bool.pass.cpp
new file mode 100644
index 000000000000..a78f4fd590be
--- /dev/null
+++ b/test/std/containers/sequences/vector.bool/vector_bool.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template <class T>
+// struct hash
+// : public unary_function<T, size_t>
+// {
+// size_t operator()(T val) const;
+// };
+
+// Not very portable
+
+#include <vector>
+#include <cassert>
+#include <type_traits>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::vector<bool> T;
+ typedef std::hash<T> H;
+ static_assert((std::is_same<H::argument_type, T>::value), "" );
+ static_assert((std::is_same<H::result_type, std::size_t>::value), "" );
+
+ bool ba[] = {true, false, true, true, false};
+ T vb(std::begin(ba), std::end(ba));
+ H h;
+ assert(h(vb) != 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::vector<bool, min_allocator<bool>> T;
+ typedef std::hash<T> H;
+ static_assert((std::is_base_of<std::unary_function<T, std::size_t>,
+ H>::value), "");
+ bool ba[] = {true, false, true, true, false};
+ T vb(std::begin(ba), std::end(ba));
+ H h;
+ assert(h(vb) != 0);
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/vector/asan.pass.cpp b/test/std/containers/sequences/vector/asan.pass.cpp
new file mode 100644
index 000000000000..86c02b295624
--- /dev/null
+++ b/test/std/containers/sequences/vector/asan.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// reference operator[](size_type n);
+
+#include <vector>
+#include <cassert>
+#include <cstdlib>
+
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+#ifndef _LIBCPP_HAS_NO_ASAN
+extern "C" void __asan_set_error_exit_code(int);
+
+int main()
+{
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::vector<T, min_allocator<T>> C;
+ const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ C c(std::begin(t), std::end(t));
+ c.reserve(2*c.size());
+ T foo = c[c.size()]; // bad, but not caught by ASAN
+ }
+#endif
+
+ __asan_set_error_exit_code(0);
+ {
+ typedef int T;
+ typedef std::vector<T> C;
+ const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ C c(std::begin(t), std::end(t));
+ c.reserve(2*c.size());
+ assert(is_contiguous_container_asan_correct(c));
+ assert(!__sanitizer_verify_contiguous_container ( c.data(), c.data() + 1, c.data() + c.capacity()));
+ T foo = c[c.size()]; // should trigger ASAN
+ assert(false); // if we got here, ASAN didn't trigger
+ }
+}
+#else
+int main () { return 0; }
+#endif
diff --git a/test/std/containers/sequences/vector/asan_throw.pass.cpp b/test/std/containers/sequences/vector/asan_throw.pass.cpp
new file mode 100644
index 000000000000..c100da1aade7
--- /dev/null
+++ b/test/std/containers/sequences/vector/asan_throw.pass.cpp
@@ -0,0 +1,232 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// Test asan vector annotations with a class that throws in a CTOR.
+
+#include <vector>
+#include <cassert>
+
+#include "asan_testing.h"
+
+class X {
+public:
+ X(const X &x) { Init(x.a); }
+ X(char arg) { Init(arg); }
+ X() { Init(42); }
+ X &operator=(const X &x) {
+ Init(x.a);
+ return *this;
+ }
+ void Init(char arg) {
+ if (arg == 42)
+ throw 0;
+ if (arg == 66)
+ arg = 42;
+ a = arg;
+ }
+ char get() const { return a; }
+ void set(char arg) { a = arg; }
+
+private:
+ char a;
+};
+
+class ThrowOnCopy {
+public:
+ ThrowOnCopy() : should_throw(false) {}
+ explicit ThrowOnCopy(bool should_throw) : should_throw(should_throw) {}
+
+ ThrowOnCopy(ThrowOnCopy const & other)
+ : should_throw(other.should_throw)
+ {
+ if (should_throw) {
+ throw 0;
+ }
+ }
+
+ bool should_throw;
+};
+
+void test_push_back() {
+ std::vector<X> v;
+ v.reserve(2);
+ v.push_back(X(2));
+ assert(v.size() == 1);
+ try {
+ v.push_back(X(66));
+ assert(0);
+ } catch (int e) {
+ assert(v.size() == 1);
+ }
+ assert(v.size() == 1);
+ assert(is_contiguous_container_asan_correct(v));
+}
+
+void test_emplace_back() {
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+ std::vector<X> v;
+ v.reserve(2);
+ v.push_back(X(2));
+ assert(v.size() == 1);
+ try {
+ v.emplace_back(42);
+ assert(0);
+ } catch (int e) {
+ assert(v.size() == 1);
+ }
+ assert(v.size() == 1);
+ assert(is_contiguous_container_asan_correct(v));
+#endif // _LIBCPP_HAS_NO_VARIADICS
+}
+
+void test_insert_range() {
+ std::vector<X> v;
+ v.reserve(4);
+ v.push_back(X(1));
+ v.push_back(X(2));
+ assert(v.size() == 2);
+ assert(v.capacity() >= 4);
+ try {
+ char a[2] = {21, 42};
+ v.insert(v.end(), a, a + 2);
+ assert(0);
+ } catch (int e) {
+ assert(v.size() == 3);
+ }
+ assert(v.size() == 3);
+ assert(is_contiguous_container_asan_correct(v));
+}
+
+void test_insert() {
+ std::vector<X> v;
+ v.reserve(3);
+ v.insert(v.end(), X(1));
+ v.insert(v.begin(), X(2));
+ assert(v.size() == 2);
+ try {
+ v.insert(v.end(), X(66));
+ assert(0);
+ } catch (int e) {
+ assert(v.size() == 2);
+ }
+ assert(v.size() == 2);
+ assert(is_contiguous_container_asan_correct(v));
+}
+
+void test_emplace() {
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+ std::vector<X> v;
+ v.reserve(3);
+ v.insert(v.end(), X(1));
+ v.insert(v.begin(), X(2));
+ assert(v.size() == 2);
+ try {
+ v.emplace(v.end(), 42);
+ assert(0);
+ } catch (int e) {
+ assert(v.size() == 2);
+ }
+ assert(v.size() == 2);
+ assert(is_contiguous_container_asan_correct(v));
+#endif // _LIBCPP_HAS_NO_VARIADICS
+}
+
+void test_insert_range2() {
+ std::vector<X> v;
+ v.reserve(4);
+ v.insert(v.end(), X(1));
+ v.insert(v.begin(), X(2));
+ assert(v.size() == 2);
+ assert(v.capacity() >= 4);
+ try {
+ char a[2] = {10, 42};
+ v.insert(v.begin(), a, a + 2);
+ assert(0);
+ } catch (int e) {
+ assert(v.size() <= 4);
+ assert(is_contiguous_container_asan_correct(v));
+ return;
+ }
+ assert(0);
+}
+
+void test_insert_n() {
+ std::vector<X> v;
+ v.reserve(10);
+ v.insert(v.end(), X(1));
+ v.insert(v.begin(), X(2));
+ assert(v.size() == 2);
+ try {
+ v.insert(v.begin(), 1, X(66));
+ assert(0);
+ } catch (int e) {
+ assert(v.size() <= 3);
+ assert(is_contiguous_container_asan_correct(v));
+ return;
+ }
+ assert(0);
+}
+
+
+void test_insert_n2() {
+ std::vector<ThrowOnCopy> v(10);
+ v.reserve(100);
+ assert(v.size() == 10);
+ v[6].should_throw = true;
+ try {
+ v.insert(v.cbegin(), 5, ThrowOnCopy());
+ assert(0);
+ } catch (int e) {
+ assert(v.size() == 11);
+ assert(is_contiguous_container_asan_correct(v));
+ return;
+ }
+ assert(0);
+}
+
+void test_resize() {
+ std::vector<X> v;
+ v.reserve(3);
+ v.push_back(X(0));
+ try {
+ v.resize(3);
+ assert(0);
+ } catch (int e) {
+ assert(v.size() == 1);
+ }
+ assert(v.size() == 1);
+ assert(is_contiguous_container_asan_correct(v));
+}
+
+void test_resize_param() {
+ std::vector<X> v;
+ v.reserve(3);
+ v.push_back(X(0));
+ try {
+ v.resize(3, X(66));
+ assert(0);
+ } catch (int e) {
+ assert(v.size() == 1);
+ }
+ assert(v.size() == 1);
+ assert(is_contiguous_container_asan_correct(v));
+}
+
+int main() {
+ test_push_back();
+ test_emplace_back();
+ test_insert_range();
+ test_insert();
+ test_emplace();
+ test_insert_range2();
+ test_insert_n();
+ test_insert_n2();
+ test_resize();
+ test_resize_param();
+}
diff --git a/test/std/containers/sequences/vector/const_value_type.pass.cpp b/test/std/containers/sequences/vector/const_value_type.pass.cpp
new file mode 100644
index 000000000000..e16e439dec4d
--- /dev/null
+++ b/test/std/containers/sequences/vector/const_value_type.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector<const int> v; // an extension
+
+#include <vector>
+#include <type_traits>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ std::vector<const int> v = {1, 2, 3};
+#endif
+}
diff --git a/test/std/containers/sequences/vector/contiguous.pass.cpp b/test/std/containers/sequences/vector/contiguous.pass.cpp
new file mode 100644
index 000000000000..32f380778335
--- /dev/null
+++ b/test/std/containers/sequences/vector/contiguous.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// An vector is a contiguous container
+
+#include <vector>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+template <class C>
+void test_contiguous ( const C &c )
+{
+ for ( size_t i = 0; i < c.size(); ++i )
+ assert ( *(c.begin() + i) == *(std::addressof(*c.begin()) + i));
+}
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::vector<T> C;
+ test_contiguous(C());
+ test_contiguous(C(3, 5));
+ }
+
+ {
+ typedef double T;
+ typedef test_allocator<T> A;
+ typedef std::vector<T, A> C;
+ test_contiguous(C(A(3)));
+ test_contiguous(C(7, 9.0, A(5)));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef double T;
+ typedef min_allocator<T> A;
+ typedef std::vector<T, A> C;
+ test_contiguous(C(A{}));
+ test_contiguous(C(9, 11.0, A{}));
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/vector/db_back.pass.cpp b/test/std/containers/sequences/vector/db_back.pass.cpp
new file mode 100644
index 000000000000..05f3d07712eb
--- /dev/null
+++ b/test/std/containers/sequences/vector/db_back.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Call back() on empty container.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::vector<T> C;
+ C c(1);
+ assert(c.back() == 0);
+ c.clear();
+ assert(c.back() == 0);
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::vector<T, min_allocator<T>> C;
+ C c(1);
+ assert(c.back() == 0);
+ c.clear();
+ assert(c.back() == 0);
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/containers/sequences/vector/db_cback.pass.cpp b/test/std/containers/sequences/vector/db_cback.pass.cpp
new file mode 100644
index 000000000000..5eb1a353e8b0
--- /dev/null
+++ b/test/std/containers/sequences/vector/db_cback.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Call back() on empty const container.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::vector<T> C;
+ const C c;
+ assert(c.back() == 0);
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::vector<T, min_allocator<T>> C;
+ const C c;
+ assert(c.back() == 0);
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/containers/sequences/vector/db_cfront.pass.cpp b/test/std/containers/sequences/vector/db_cfront.pass.cpp
new file mode 100644
index 000000000000..5e54da1d444e
--- /dev/null
+++ b/test/std/containers/sequences/vector/db_cfront.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Call front() on empty const container.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::vector<T> C;
+ const C c;
+ assert(c.front() == 0);
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::vector<T, min_allocator<T>> C;
+ const C c;
+ assert(c.front() == 0);
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/containers/sequences/vector/db_cindex.pass.cpp b/test/std/containers/sequences/vector/db_cindex.pass.cpp
new file mode 100644
index 000000000000..133aa5652824
--- /dev/null
+++ b/test/std/containers/sequences/vector/db_cindex.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Index const vector out of bounds.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::vector<T> C;
+ const C c(1);
+ assert(c[0] == 0);
+ assert(c[1] == 0);
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::vector<T, min_allocator<T>> C;
+ const C c(1);
+ assert(c[0] == 0);
+ assert(c[1] == 0);
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/containers/sequences/vector/db_front.pass.cpp b/test/std/containers/sequences/vector/db_front.pass.cpp
new file mode 100644
index 000000000000..388058fb3159
--- /dev/null
+++ b/test/std/containers/sequences/vector/db_front.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Call front() on empty container.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::vector<T> C;
+ C c(1);
+ assert(c.front() == 0);
+ c.clear();
+ assert(c.front() == 0);
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::vector<T, min_allocator<T>> C;
+ C c(1);
+ assert(c.front() == 0);
+ c.clear();
+ assert(c.front() == 0);
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/containers/sequences/vector/db_index.pass.cpp b/test/std/containers/sequences/vector/db_index.pass.cpp
new file mode 100644
index 000000000000..1daf076da67c
--- /dev/null
+++ b/test/std/containers/sequences/vector/db_index.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Index vector out of bounds.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::vector<T> C;
+ C c(1);
+ assert(c[0] == 0);
+ c.clear();
+ assert(c[0] == 0);
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::vector<T, min_allocator<T>> C;
+ C c(1);
+ assert(c[0] == 0);
+ c.clear();
+ assert(c[0] == 0);
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/containers/sequences/vector/db_iterators_2.pass.cpp b/test/std/containers/sequences/vector/db_iterators_2.pass.cpp
new file mode 100644
index 000000000000..2d43843067b7
--- /dev/null
+++ b/test/std/containers/sequences/vector/db_iterators_2.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Compare iterators from different containers with <.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::vector<T> C;
+ C c1;
+ C c2;
+ bool b = c1.begin() < c2.begin();
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::vector<T, min_allocator<T>> C;
+ C c1;
+ C c2;
+ bool b = c1.begin() < c2.begin();
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/containers/sequences/vector/db_iterators_3.pass.cpp b/test/std/containers/sequences/vector/db_iterators_3.pass.cpp
new file mode 100644
index 000000000000..051d66c33394
--- /dev/null
+++ b/test/std/containers/sequences/vector/db_iterators_3.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Subtract iterators from different containers.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::vector<T> C;
+ C c1;
+ C c2;
+ int i = c1.begin() - c2.begin();
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::vector<T, min_allocator<T>> C;
+ C c1;
+ C c2;
+ int i = c1.begin() - c2.begin();
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/containers/sequences/vector/db_iterators_4.pass.cpp b/test/std/containers/sequences/vector/db_iterators_4.pass.cpp
new file mode 100644
index 000000000000..4c2aa628de14
--- /dev/null
+++ b/test/std/containers/sequences/vector/db_iterators_4.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Index iterator out of bounds.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::vector<T> C;
+ C c(1);
+ C::iterator i = c.begin();
+ assert(i[0] == 0);
+ assert(i[1] == 0);
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::vector<T, min_allocator<T>> C;
+ C c(1);
+ C::iterator i = c.begin();
+ assert(i[0] == 0);
+ assert(i[1] == 0);
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/containers/sequences/vector/db_iterators_5.pass.cpp b/test/std/containers/sequences/vector/db_iterators_5.pass.cpp
new file mode 100644
index 000000000000..1b1090499c27
--- /dev/null
+++ b/test/std/containers/sequences/vector/db_iterators_5.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Add to iterator out of bounds.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::vector<T> C;
+ C c(1);
+ C::iterator i = c.begin();
+ i += 1;
+ assert(i == c.end());
+ i = c.begin();
+ i += 2;
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::vector<T, min_allocator<T>> C;
+ C c(1);
+ C::iterator i = c.begin();
+ i += 1;
+ assert(i == c.end());
+ i = c.begin();
+ i += 2;
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/containers/sequences/vector/db_iterators_6.pass.cpp b/test/std/containers/sequences/vector/db_iterators_6.pass.cpp
new file mode 100644
index 000000000000..424bc939b136
--- /dev/null
+++ b/test/std/containers/sequences/vector/db_iterators_6.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Decrement iterator prior to begin.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::vector<T> C;
+ C c(1);
+ C::iterator i = c.end();
+ --i;
+ assert(i == c.begin());
+ --i;
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::vector<T, min_allocator<T>> C;
+ C c(1);
+ C::iterator i = c.end();
+ --i;
+ assert(i == c.begin());
+ --i;
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/containers/sequences/vector/db_iterators_7.pass.cpp b/test/std/containers/sequences/vector/db_iterators_7.pass.cpp
new file mode 100644
index 000000000000..72cdb10cbc85
--- /dev/null
+++ b/test/std/containers/sequences/vector/db_iterators_7.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Increment iterator past end.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::vector<T> C;
+ C c(1);
+ C::iterator i = c.begin();
+ ++i;
+ assert(i == c.end());
+ ++i;
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::vector<T, min_allocator<T>> C;
+ C c(1);
+ C::iterator i = c.begin();
+ ++i;
+ assert(i == c.end());
+ ++i;
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/containers/sequences/vector/db_iterators_8.pass.cpp b/test/std/containers/sequences/vector/db_iterators_8.pass.cpp
new file mode 100644
index 000000000000..7b898533197c
--- /dev/null
+++ b/test/std/containers/sequences/vector/db_iterators_8.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Dereference non-dereferenceable iterator.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::vector<T> C;
+ C c(1);
+ C::iterator i = c.end();
+ T j = *i;
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::vector<T, min_allocator<T>> C;
+ C c(1);
+ C::iterator i = c.end();
+ T j = *i;
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/containers/sequences/vector/iterators.pass.cpp b/test/std/containers/sequences/vector/iterators.pass.cpp
new file mode 100644
index 000000000000..75a08287a863
--- /dev/null
+++ b/test/std/containers/sequences/vector/iterators.pass.cpp
@@ -0,0 +1,165 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// iterator begin();
+// iterator end();
+// const_iterator begin() const;
+// const_iterator end() const;
+// const_iterator cbegin() const;
+// const_iterator cend() const;
+
+#include <vector>
+#include <cassert>
+#include <iterator>
+
+#include "min_allocator.h"
+
+struct A
+{
+ int first;
+ int second;
+};
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::vector<T> C;
+ C c;
+ C::iterator i = c.begin();
+ C::iterator j = c.end();
+ assert(std::distance(i, j) == 0);
+ assert(i == j);
+ }
+ {
+ typedef int T;
+ typedef std::vector<T> C;
+ const C c;
+ C::const_iterator i = c.begin();
+ C::const_iterator j = c.end();
+ assert(std::distance(i, j) == 0);
+ assert(i == j);
+ }
+ {
+ typedef int T;
+ typedef std::vector<T> C;
+ C c;
+ C::const_iterator i = c.cbegin();
+ C::const_iterator j = c.cend();
+ assert(std::distance(i, j) == 0);
+ assert(i == j);
+ assert(i == c.end());
+ }
+ {
+ typedef int T;
+ typedef std::vector<T> C;
+ const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ C c(std::begin(t), std::end(t));
+ C::iterator i = c.begin();
+ assert(*i == 0);
+ ++i;
+ assert(*i == 1);
+ *i = 10;
+ assert(*i == 10);
+ assert(std::distance(c.begin(), c.end()) == 10);
+ }
+ {
+ typedef int T;
+ typedef std::vector<T> C;
+ C::iterator i;
+ C::const_iterator j;
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::vector<T, min_allocator<T>> C;
+ C c;
+ C::iterator i = c.begin();
+ C::iterator j = c.end();
+ assert(std::distance(i, j) == 0);
+ assert(i == j);
+ }
+ {
+ typedef int T;
+ typedef std::vector<T, min_allocator<T>> C;
+ const C c;
+ C::const_iterator i = c.begin();
+ C::const_iterator j = c.end();
+ assert(std::distance(i, j) == 0);
+ assert(i == j);
+ }
+ {
+ typedef int T;
+ typedef std::vector<T, min_allocator<T>> C;
+ C c;
+ C::const_iterator i = c.cbegin();
+ C::const_iterator j = c.cend();
+ assert(std::distance(i, j) == 0);
+ assert(i == j);
+ assert(i == c.end());
+ }
+ {
+ typedef int T;
+ typedef std::vector<T, min_allocator<T>> C;
+ const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ C c(std::begin(t), std::end(t));
+ C::iterator i = c.begin();
+ assert(*i == 0);
+ ++i;
+ assert(*i == 1);
+ *i = 10;
+ assert(*i == 10);
+ assert(std::distance(c.begin(), c.end()) == 10);
+ }
+ {
+ typedef int T;
+ typedef std::vector<T, min_allocator<T>> C;
+ C::iterator i;
+ C::const_iterator j;
+ }
+ {
+ typedef A T;
+ typedef std::vector<T, min_allocator<T>> C;
+ C c = {A{1, 2}};
+ C::iterator i = c.begin();
+ i->first = 3;
+ C::const_iterator j = i;
+ assert(j->first == 3);
+ }
+#endif
+#if _LIBCPP_STD_VER > 11
+ { // N3644 testing
+ typedef std::vector<int> C;
+ C::iterator ii1{}, ii2{};
+ C::iterator ii4 = ii1;
+ C::const_iterator cii{};
+ assert ( ii1 == ii2 );
+ assert ( ii1 == ii4 );
+
+ assert (!(ii1 != ii2 ));
+
+ assert ( (ii1 == cii ));
+ assert ( (cii == ii1 ));
+ assert (!(ii1 != cii ));
+ assert (!(cii != ii1 ));
+ assert (!(ii1 < cii ));
+ assert (!(cii < ii1 ));
+ assert ( (ii1 <= cii ));
+ assert ( (cii <= ii1 ));
+ assert (!(ii1 > cii ));
+ assert (!(cii > ii1 ));
+ assert ( (ii1 >= cii ));
+ assert ( (cii >= ii1 ));
+ assert (cii - ii1 == 0);
+ assert (ii1 - cii == 0);
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/vector/types.pass.cpp b/test/std/containers/sequences/vector/types.pass.cpp
new file mode 100644
index 000000000000..0fbc7e38b1a2
--- /dev/null
+++ b/test/std/containers/sequences/vector/types.pass.cpp
@@ -0,0 +1,86 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Test nested types and default template args:
+
+// template <class T, class Allocator = allocator<T> >
+// class vector
+// {
+// public:
+// typedef T value_type;
+// typedef Allocator allocator_type;
+// typedef typename allocator_type::reference reference;
+// typedef typename allocator_type::const_reference const_reference;
+// typedef implementation-defined iterator;
+// typedef implementation-defined const_iterator;
+// typedef typename allocator_type::size_type size_type;
+// typedef typename allocator_type::difference_type difference_type;
+// typedef typename allocator_type::pointer pointer;
+// typedef typename allocator_type::const_pointer const_pointer;
+// typedef std::reverse_iterator<iterator> reverse_iterator;
+// typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
+// };
+
+#include <vector>
+#include <iterator>
+#include <type_traits>
+
+#include "test_allocator.h"
+#include "../../Copyable.h"
+#include "min_allocator.h"
+
+struct A { std::vector<A> v; }; // incomplete type support
+
+template <class T, class Allocator>
+void
+test()
+{
+ typedef std::vector<T, Allocator> C;
+
+ static_assert((std::is_same<typename C::value_type, T>::value), "");
+ static_assert((std::is_same<typename C::value_type, typename Allocator::value_type>::value), "");
+ static_assert((std::is_same<typename C::allocator_type, Allocator>::value), "");
+ static_assert((std::is_same<typename C::size_type, typename Allocator::size_type>::value), "");
+ static_assert((std::is_same<typename C::difference_type, typename Allocator::difference_type>::value), "");
+ static_assert((std::is_same<typename C::reference, typename Allocator::reference>::value), "");
+ static_assert((std::is_same<typename C::const_reference, typename Allocator::const_reference>::value), "");
+ static_assert((std::is_same<typename C::pointer, typename Allocator::pointer>::value), "");
+ static_assert((std::is_same<typename C::const_pointer, typename Allocator::const_pointer>::value), "");
+ static_assert((std::is_same<
+ typename std::iterator_traits<typename C::iterator>::iterator_category,
+ std::random_access_iterator_tag>::value), "");
+ static_assert((std::is_same<
+ typename std::iterator_traits<typename C::const_iterator>::iterator_category,
+ std::random_access_iterator_tag>::value), "");
+ static_assert((std::is_same<
+ typename C::reverse_iterator,
+ std::reverse_iterator<typename C::iterator> >::value), "");
+ static_assert((std::is_same<
+ typename C::const_reverse_iterator,
+ std::reverse_iterator<typename C::const_iterator> >::value), "");
+}
+
+int main()
+{
+ test<int, test_allocator<int> >();
+ test<int*, std::allocator<int*> >();
+ test<Copyable, test_allocator<Copyable> >();
+ static_assert((std::is_same<std::vector<char>::allocator_type,
+ std::allocator<char> >::value), "");
+#if __cplusplus >= 201103L
+ static_assert((std::is_same<std::vector<int, min_allocator<int>>::value_type, int>::value), "");
+ static_assert((std::is_same<std::vector<int, min_allocator<int>>::allocator_type, min_allocator<int> >::value), "");
+ static_assert((std::is_same<std::vector<int, min_allocator<int>>::reference, int&>::value), "");
+ static_assert((std::is_same<std::vector<int, min_allocator<int>>::const_reference, const int&>::value), "");
+ static_assert((std::is_same<std::vector<int, min_allocator<int>>::pointer, min_pointer<int>>::value), "");
+ static_assert((std::is_same<std::vector<int, min_allocator<int>>::const_pointer, min_pointer<const int>>::value), "");
+#endif
+}
diff --git a/test/std/containers/sequences/vector/vector.capacity/capacity.pass.cpp b/test/std/containers/sequences/vector/vector.capacity/capacity.pass.cpp
new file mode 100644
index 000000000000..21082c839f56
--- /dev/null
+++ b/test/std/containers/sequences/vector/vector.capacity/capacity.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// size_type capacity() const;
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+ {
+ std::vector<int> v;
+ assert(v.capacity() == 0);
+ assert(is_contiguous_container_asan_correct(v));
+ }
+ {
+ std::vector<int> v(100);
+ assert(v.capacity() == 100);
+ v.push_back(0);
+ assert(v.capacity() > 101);
+ assert(is_contiguous_container_asan_correct(v));
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<int, min_allocator<int>> v;
+ assert(v.capacity() == 0);
+ assert(is_contiguous_container_asan_correct(v));
+ }
+ {
+ std::vector<int, min_allocator<int>> v(100);
+ assert(v.capacity() == 100);
+ v.push_back(0);
+ assert(v.capacity() > 101);
+ assert(is_contiguous_container_asan_correct(v));
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/vector/vector.capacity/reserve.pass.cpp b/test/std/containers/sequences/vector/vector.capacity/reserve.pass.cpp
new file mode 100644
index 000000000000..4df5702f2ad2
--- /dev/null
+++ b/test/std/containers/sequences/vector/vector.capacity/reserve.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// void reserve(size_type n);
+
+#include <vector>
+#include <cassert>
+#include "../../../stack_allocator.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+ {
+ std::vector<int> v;
+ v.reserve(10);
+ assert(v.capacity() >= 10);
+ assert(is_contiguous_container_asan_correct(v));
+ }
+ {
+ std::vector<int> v(100);
+ assert(v.capacity() == 100);
+ v.reserve(50);
+ assert(v.size() == 100);
+ assert(v.capacity() == 100);
+ v.reserve(150);
+ assert(v.size() == 100);
+ assert(v.capacity() == 150);
+ assert(is_contiguous_container_asan_correct(v));
+ }
+ {
+ std::vector<int, stack_allocator<int, 250> > v(100);
+ assert(v.capacity() == 100);
+ v.reserve(50);
+ assert(v.size() == 100);
+ assert(v.capacity() == 100);
+ v.reserve(150);
+ assert(v.size() == 100);
+ assert(v.capacity() == 150);
+ assert(is_contiguous_container_asan_correct(v));
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<int, min_allocator<int>> v;
+ v.reserve(10);
+ assert(v.capacity() >= 10);
+ assert(is_contiguous_container_asan_correct(v));
+ }
+ {
+ std::vector<int, min_allocator<int>> v(100);
+ assert(v.capacity() == 100);
+ v.reserve(50);
+ assert(v.size() == 100);
+ assert(v.capacity() == 100);
+ v.reserve(150);
+ assert(v.size() == 100);
+ assert(v.capacity() == 150);
+ assert(is_contiguous_container_asan_correct(v));
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/vector/vector.capacity/resize_size.pass.cpp b/test/std/containers/sequences/vector/vector.capacity/resize_size.pass.cpp
new file mode 100644
index 000000000000..c7988d62060a
--- /dev/null
+++ b/test/std/containers/sequences/vector/vector.capacity/resize_size.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// void resize(size_type sz);
+
+#include <vector>
+#include <cassert>
+#include "../../../stack_allocator.h"
+#include "MoveOnly.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::vector<MoveOnly> v(100);
+ v.resize(50);
+ assert(v.size() == 50);
+ assert(v.capacity() == 100);
+ assert(is_contiguous_container_asan_correct(v));
+ v.resize(200);
+ assert(v.size() == 200);
+ assert(v.capacity() >= 200);
+ assert(is_contiguous_container_asan_correct(v));
+ }
+ {
+ std::vector<MoveOnly, stack_allocator<MoveOnly, 300> > v(100);
+ v.resize(50);
+ assert(v.size() == 50);
+ assert(v.capacity() == 100);
+ assert(is_contiguous_container_asan_correct(v));
+ v.resize(200);
+ assert(v.size() == 200);
+ assert(v.capacity() >= 200);
+ assert(is_contiguous_container_asan_correct(v));
+ }
+#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::vector<int> v(100);
+ v.resize(50);
+ assert(v.size() == 50);
+ assert(v.capacity() == 100);
+ assert(is_contiguous_container_asan_correct(v));
+ v.resize(200);
+ assert(v.size() == 200);
+ assert(v.capacity() >= 200);
+ assert(is_contiguous_container_asan_correct(v));
+ }
+ {
+ std::vector<int, stack_allocator<int, 300> > v(100);
+ v.resize(50);
+ assert(v.size() == 50);
+ assert(v.capacity() == 100);
+ assert(is_contiguous_container_asan_correct(v));
+ v.resize(200);
+ assert(v.size() == 200);
+ assert(v.capacity() >= 200);
+ assert(is_contiguous_container_asan_correct(v));
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if __cplusplus >= 201103L
+ {
+ std::vector<MoveOnly, min_allocator<MoveOnly>> v(100);
+ v.resize(50);
+ assert(v.size() == 50);
+ assert(v.capacity() == 100);
+ assert(is_contiguous_container_asan_correct(v));
+ v.resize(200);
+ assert(v.size() == 200);
+ assert(v.capacity() >= 200);
+ assert(is_contiguous_container_asan_correct(v));
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/vector/vector.capacity/resize_size_value.pass.cpp b/test/std/containers/sequences/vector/vector.capacity/resize_size_value.pass.cpp
new file mode 100644
index 000000000000..de5126b03d10
--- /dev/null
+++ b/test/std/containers/sequences/vector/vector.capacity/resize_size_value.pass.cpp
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// void resize(size_type sz, const value_type& x);
+
+#include <vector>
+#include <cassert>
+#include "../../../stack_allocator.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+ {
+ std::vector<int> v(100);
+ v.resize(50, 1);
+ assert(v.size() == 50);
+ assert(v.capacity() == 100);
+ assert(v == std::vector<int>(50));
+ v.resize(200, 1);
+ assert(v.size() == 200);
+ assert(v.capacity() >= 200);
+ assert(is_contiguous_container_asan_correct(v));
+ for (unsigned i = 0; i < 50; ++i)
+ assert(v[i] == 0);
+ for (unsigned i = 50; i < 200; ++i)
+ assert(v[i] == 1);
+ }
+ {
+ std::vector<int, stack_allocator<int, 300> > v(100);
+ v.resize(50, 1);
+ assert(v.size() == 50);
+ assert(v.capacity() == 100);
+ v.resize(200, 1);
+ assert(v.size() == 200);
+ assert(v.capacity() >= 200);
+ assert(is_contiguous_container_asan_correct(v));
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<int, min_allocator<int>> v(100);
+ v.resize(50, 1);
+ assert(v.size() == 50);
+ assert(v.capacity() == 100);
+ assert(is_contiguous_container_asan_correct(v));
+ assert((v == std::vector<int, min_allocator<int>>(50)));
+ v.resize(200, 1);
+ assert(v.size() == 200);
+ assert(v.capacity() >= 200);
+ assert(is_contiguous_container_asan_correct(v));
+ for (unsigned i = 0; i < 50; ++i)
+ assert(v[i] == 0);
+ for (unsigned i = 50; i < 200; ++i)
+ assert(v[i] == 1);
+ }
+ {
+ std::vector<int, min_allocator<int>> v(100);
+ v.resize(50, 1);
+ assert(v.size() == 50);
+ assert(v.capacity() == 100);
+ assert(is_contiguous_container_asan_correct(v));
+ v.resize(200, 1);
+ assert(v.size() == 200);
+ assert(v.capacity() >= 200);
+ assert(is_contiguous_container_asan_correct(v));
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/vector/vector.capacity/shrink_to_fit.pass.cpp b/test/std/containers/sequences/vector/vector.capacity/shrink_to_fit.pass.cpp
new file mode 100644
index 000000000000..49ab9cc71deb
--- /dev/null
+++ b/test/std/containers/sequences/vector/vector.capacity/shrink_to_fit.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// void shrink_to_fit();
+
+#include <vector>
+#include <cassert>
+#include "../../../stack_allocator.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+ {
+ std::vector<int> v(100);
+ v.push_back(1);
+ assert(is_contiguous_container_asan_correct(v));
+ v.shrink_to_fit();
+ assert(v.capacity() == 101);
+ assert(v.size() == 101);
+ assert(is_contiguous_container_asan_correct(v));
+ }
+ {
+ std::vector<int, stack_allocator<int, 401> > v(100);
+ v.push_back(1);
+ assert(is_contiguous_container_asan_correct(v));
+ v.shrink_to_fit();
+ assert(v.capacity() == 101);
+ assert(v.size() == 101);
+ assert(is_contiguous_container_asan_correct(v));
+ }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ {
+ std::vector<int, stack_allocator<int, 400> > v(100);
+ v.push_back(1);
+ assert(is_contiguous_container_asan_correct(v));
+ v.shrink_to_fit();
+ assert(v.capacity() == 200);
+ assert(v.size() == 101);
+ assert(is_contiguous_container_asan_correct(v));
+ }
+#endif
+#if __cplusplus >= 201103L
+ {
+ std::vector<int, min_allocator<int>> v(100);
+ v.push_back(1);
+ assert(is_contiguous_container_asan_correct(v));
+ v.shrink_to_fit();
+ assert(v.capacity() == 101);
+ assert(v.size() == 101);
+ assert(is_contiguous_container_asan_correct(v));
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/vector/vector.capacity/swap.pass.cpp b/test/std/containers/sequences/vector/vector.capacity/swap.pass.cpp
new file mode 100644
index 000000000000..f3d9289c36eb
--- /dev/null
+++ b/test/std/containers/sequences/vector/vector.capacity/swap.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// void swap(vector& x);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+ {
+ std::vector<int> v1(100);
+ std::vector<int> v2(200);
+ assert(is_contiguous_container_asan_correct(v1));
+ assert(is_contiguous_container_asan_correct(v2));
+ v1.swap(v2);
+ assert(v1.size() == 200);
+ assert(v1.capacity() == 200);
+ assert(is_contiguous_container_asan_correct(v1));
+ assert(v2.size() == 100);
+ assert(v2.capacity() == 100);
+ assert(is_contiguous_container_asan_correct(v2));
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<int, min_allocator<int>> v1(100);
+ std::vector<int, min_allocator<int>> v2(200);
+ assert(is_contiguous_container_asan_correct(v1));
+ assert(is_contiguous_container_asan_correct(v2));
+ v1.swap(v2);
+ assert(v1.size() == 200);
+ assert(v1.capacity() == 200);
+ assert(is_contiguous_container_asan_correct(v1));
+ assert(v2.size() == 100);
+ assert(v2.capacity() == 100);
+ assert(is_contiguous_container_asan_correct(v2));
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/vector/vector.cons/assign_copy.pass.cpp b/test/std/containers/sequences/vector/vector.cons/assign_copy.pass.cpp
new file mode 100644
index 000000000000..6f02c3b7bc2b
--- /dev/null
+++ b/test/std/containers/sequences/vector/vector.cons/assign_copy.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector& operator=(const vector& c);
+
+#include <vector>
+#include <cassert>
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::vector<int, test_allocator<int> > l(3, 2, test_allocator<int>(5));
+ std::vector<int, test_allocator<int> > l2(l, test_allocator<int>(3));
+ l2 = l;
+ assert(l2 == l);
+ assert(l2.get_allocator() == test_allocator<int>(3));
+ }
+ {
+ std::vector<int, other_allocator<int> > l(3, 2, other_allocator<int>(5));
+ std::vector<int, other_allocator<int> > l2(l, other_allocator<int>(3));
+ l2 = l;
+ assert(l2 == l);
+ assert(l2.get_allocator() == other_allocator<int>(5));
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<int, min_allocator<int> > l(3, 2, min_allocator<int>());
+ std::vector<int, min_allocator<int> > l2(l, min_allocator<int>());
+ l2 = l;
+ assert(l2 == l);
+ assert(l2.get_allocator() == min_allocator<int>());
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/vector/vector.cons/assign_initializer_list.pass.cpp b/test/std/containers/sequences/vector/vector.cons/assign_initializer_list.pass.cpp
new file mode 100644
index 000000000000..3cb0b3b095f0
--- /dev/null
+++ b/test/std/containers/sequences/vector/vector.cons/assign_initializer_list.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// void assign(initializer_list<value_type> il);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+template <typename Vec>
+void test ( Vec &v )
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ v.assign({3, 4, 5, 6});
+ assert(v.size() == 4);
+ assert(is_contiguous_container_asan_correct(v));
+ assert(v[0] == 3);
+ assert(v[1] == 4);
+ assert(v[2] == 5);
+ assert(v[3] == 6);
+#endif
+}
+
+int main()
+{
+ {
+ typedef std::vector<int> V;
+ V d1;
+ V d2;
+ d2.reserve(10); // no reallocation during assign.
+ test(d1);
+ test(d2);
+ }
+
+#if __cplusplus >= 201103L
+ {
+ typedef std::vector<int, min_allocator<int>> V;
+ V d1;
+ V d2;
+ d2.reserve(10); // no reallocation during assign.
+ test(d1);
+ test(d2);
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/vector/vector.cons/assign_move.pass.cpp b/test/std/containers/sequences/vector/vector.cons/assign_move.pass.cpp
new file mode 100644
index 000000000000..8c8b0a04715b
--- /dev/null
+++ b/test/std/containers/sequences/vector/vector.cons/assign_move.pass.cpp
@@ -0,0 +1,101 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector& operator=(vector&& c);
+
+#include <vector>
+#include <cassert>
+#include "MoveOnly.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::vector<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5));
+ std::vector<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5));
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ assert(is_contiguous_container_asan_correct(l));
+ assert(is_contiguous_container_asan_correct(lo));
+ std::vector<MoveOnly, test_allocator<MoveOnly> > l2(test_allocator<MoveOnly>(5));
+ l2 = std::move(l);
+ assert(l2 == lo);
+ assert(l.empty());
+ assert(l2.get_allocator() == lo.get_allocator());
+ assert(is_contiguous_container_asan_correct(l2));
+ }
+ {
+ std::vector<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5));
+ std::vector<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5));
+ assert(is_contiguous_container_asan_correct(l));
+ assert(is_contiguous_container_asan_correct(lo));
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ assert(is_contiguous_container_asan_correct(l));
+ assert(is_contiguous_container_asan_correct(lo));
+ std::vector<MoveOnly, test_allocator<MoveOnly> > l2(test_allocator<MoveOnly>(6));
+ l2 = std::move(l);
+ assert(l2 == lo);
+ assert(!l.empty());
+ assert(l2.get_allocator() == test_allocator<MoveOnly>(6));
+ assert(is_contiguous_container_asan_correct(l2));
+ }
+ {
+ std::vector<MoveOnly, other_allocator<MoveOnly> > l(other_allocator<MoveOnly>(5));
+ std::vector<MoveOnly, other_allocator<MoveOnly> > lo(other_allocator<MoveOnly>(5));
+ assert(is_contiguous_container_asan_correct(l));
+ assert(is_contiguous_container_asan_correct(lo));
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ assert(is_contiguous_container_asan_correct(l));
+ assert(is_contiguous_container_asan_correct(lo));
+ std::vector<MoveOnly, other_allocator<MoveOnly> > l2(other_allocator<MoveOnly>(6));
+ l2 = std::move(l);
+ assert(l2 == lo);
+ assert(l.empty());
+ assert(l2.get_allocator() == lo.get_allocator());
+ assert(is_contiguous_container_asan_correct(l2));
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<MoveOnly, min_allocator<MoveOnly> > l(min_allocator<MoveOnly>{});
+ std::vector<MoveOnly, min_allocator<MoveOnly> > lo(min_allocator<MoveOnly>{});
+ assert(is_contiguous_container_asan_correct(l));
+ assert(is_contiguous_container_asan_correct(lo));
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ assert(is_contiguous_container_asan_correct(l));
+ assert(is_contiguous_container_asan_correct(lo));
+ std::vector<MoveOnly, min_allocator<MoveOnly> > l2(min_allocator<MoveOnly>{});
+ l2 = std::move(l);
+ assert(l2 == lo);
+ assert(l.empty());
+ assert(l2.get_allocator() == lo.get_allocator());
+ assert(is_contiguous_container_asan_correct(l2));
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/sequences/vector/vector.cons/assign_size_value.pass.cpp b/test/std/containers/sequences/vector/vector.cons/assign_size_value.pass.cpp
new file mode 100644
index 000000000000..e1b30bf11304
--- /dev/null
+++ b/test/std/containers/sequences/vector/vector.cons/assign_size_value.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// void assign(size_type n, const_reference v);
+
+#include <vector>
+#include <algorithm>
+#include <cassert>
+#include <iostream>
+
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+bool is6(int x) { return x == 6; }
+
+template <typename Vec>
+void test ( Vec &v )
+{
+ v.assign(5, 6);
+ assert(v.size() == 5);
+ assert(is_contiguous_container_asan_correct(v));
+ assert(std::all_of(v.begin(), v.end(), is6));
+}
+
+int main()
+{
+ {
+ typedef std::vector<int> V;
+ V d1;
+ V d2;
+ d2.reserve(10); // no reallocation during assign.
+ test(d1);
+ test(d2);
+ }
+
+#if __cplusplus >= 201103L
+ {
+ typedef std::vector<int, min_allocator<int>> V;
+ V d1;
+ V d2;
+ d2.reserve(10); // no reallocation during assign.
+ test(d1);
+ test(d2);
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/vector/vector.cons/construct_default.pass.cpp b/test/std/containers/sequences/vector/vector.cons/construct_default.pass.cpp
new file mode 100644
index 000000000000..5e87c07ef70a
--- /dev/null
+++ b/test/std/containers/sequences/vector/vector.cons/construct_default.pass.cpp
@@ -0,0 +1,90 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector();
+// vector(const Alloc&);
+
+#include <vector>
+#include <cassert>
+
+#include "test_macros.h"
+#include "test_allocator.h"
+#include "../../../NotConstructible.h"
+#include "../../../stack_allocator.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+template <class C>
+void
+test0()
+{
+#if TEST_STD_VER > 14
+ static_assert((noexcept(C{})), "" );
+#elif TEST_STD_VER >= 11
+ static_assert((noexcept(C()) == noexcept(typename C::allocator_type())), "" );
+#endif
+ C c;
+ assert(c.__invariants());
+ assert(c.empty());
+ assert(c.get_allocator() == typename C::allocator_type());
+ assert(is_contiguous_container_asan_correct(c));
+#if TEST_STD_VER >= 11
+ C c1 = {};
+ assert(c1.__invariants());
+ assert(c1.empty());
+ assert(c1.get_allocator() == typename C::allocator_type());
+ assert(is_contiguous_container_asan_correct(c1));
+#endif
+}
+
+template <class C>
+void
+test1(const typename C::allocator_type& a)
+{
+#if TEST_STD_VER > 14
+ static_assert((noexcept(C{typename C::allocator_type{}})), "" );
+#elif TEST_STD_VER >= 11
+ static_assert((noexcept(C(typename C::allocator_type())) == std::is_nothrow_copy_constructible<typename C::allocator_type>::value), "" );
+#endif
+ C c(a);
+ assert(c.__invariants());
+ assert(c.empty());
+ assert(c.get_allocator() == a);
+ assert(is_contiguous_container_asan_correct(c));
+}
+
+int main()
+{
+ {
+ test0<std::vector<int> >();
+ test0<std::vector<NotConstructible> >();
+ test1<std::vector<int, test_allocator<int> > >(test_allocator<int>(3));
+ test1<std::vector<NotConstructible, test_allocator<NotConstructible> > >
+ (test_allocator<NotConstructible>(5));
+ }
+ {
+ std::vector<int, stack_allocator<int, 10> > v;
+ assert(v.empty());
+ }
+#if TEST_STD_VER >= 11
+ {
+ test0<std::vector<int, min_allocator<int>> >();
+ test0<std::vector<NotConstructible, min_allocator<NotConstructible>> >();
+ test1<std::vector<int, min_allocator<int> > >(min_allocator<int>{});
+ test1<std::vector<NotConstructible, min_allocator<NotConstructible> > >
+ (min_allocator<NotConstructible>{});
+ }
+ {
+ std::vector<int, min_allocator<int> > v;
+ assert(v.empty());
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp b/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp
new file mode 100644
index 000000000000..36e231acce12
--- /dev/null
+++ b/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// template <class InputIter> vector(InputIter first, InputIter last);
+
+#include <vector>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "../../../stack_allocator.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+template <class C, class Iterator>
+void
+test(Iterator first, Iterator last)
+{
+ C c(first, last);
+ assert(c.__invariants());
+ assert(c.size() == std::distance(first, last));
+ assert(is_contiguous_container_asan_correct(c));
+ for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i, ++first)
+ assert(*i == *first);
+}
+
+int main()
+{
+ int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 1, 0};
+ int* an = a + sizeof(a)/sizeof(a[0]);
+ test<std::vector<int> >(input_iterator<const int*>(a), input_iterator<const int*>(an));
+ test<std::vector<int> >(forward_iterator<const int*>(a), forward_iterator<const int*>(an));
+ test<std::vector<int> >(bidirectional_iterator<const int*>(a), bidirectional_iterator<const int*>(an));
+ test<std::vector<int> >(random_access_iterator<const int*>(a), random_access_iterator<const int*>(an));
+ test<std::vector<int> >(a, an);
+
+ test<std::vector<int, stack_allocator<int, 63> > >(input_iterator<const int*>(a), input_iterator<const int*>(an));
+ test<std::vector<int, stack_allocator<int, 18> > >(forward_iterator<const int*>(a), forward_iterator<const int*>(an));
+ test<std::vector<int, stack_allocator<int, 18> > >(bidirectional_iterator<const int*>(a), bidirectional_iterator<const int*>(an));
+ test<std::vector<int, stack_allocator<int, 18> > >(random_access_iterator<const int*>(a), random_access_iterator<const int*>(an));
+ test<std::vector<int, stack_allocator<int, 18> > >(a, an);
+#if __cplusplus >= 201103L
+ test<std::vector<int, min_allocator<int>> >(input_iterator<const int*>(a), input_iterator<const int*>(an));
+ test<std::vector<int, min_allocator<int>> >(forward_iterator<const int*>(a), forward_iterator<const int*>(an));
+ test<std::vector<int, min_allocator<int>> >(bidirectional_iterator<const int*>(a), bidirectional_iterator<const int*>(an));
+ test<std::vector<int, min_allocator<int>> >(random_access_iterator<const int*>(a), random_access_iterator<const int*>(an));
+ test<std::vector<int> >(a, an);
+#endif
+}
diff --git a/test/std/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp b/test/std/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp
new file mode 100644
index 000000000000..7fa748a90d71
--- /dev/null
+++ b/test/std/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// template <class InputIter> vector(InputIter first, InputIter last,
+// const allocator_type& a);
+
+#include <vector>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "../../../stack_allocator.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+template <class C, class Iterator, class A>
+void
+test(Iterator first, Iterator last, const A& a)
+{
+ C c(first, last, a);
+ assert(c.__invariants());
+ assert(c.size() == std::distance(first, last));
+ assert(is_contiguous_container_asan_correct(c));
+ for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i, ++first)
+ assert(*i == *first);
+}
+
+#if __cplusplus >= 201103L
+
+template <class T>
+struct implicit_conv_allocator : min_allocator<T>
+{
+ implicit_conv_allocator(void* p) {}
+ implicit_conv_allocator(const implicit_conv_allocator&) = default;
+};
+
+#endif
+
+int main()
+{
+ {
+ int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 1, 0};
+ int* an = a + sizeof(a)/sizeof(a[0]);
+ std::allocator<int> alloc;
+ test<std::vector<int> >(input_iterator<const int*>(a), input_iterator<const int*>(an), alloc);
+ test<std::vector<int> >(forward_iterator<const int*>(a), forward_iterator<const int*>(an), alloc);
+ test<std::vector<int> >(bidirectional_iterator<const int*>(a), bidirectional_iterator<const int*>(an), alloc);
+ test<std::vector<int> >(random_access_iterator<const int*>(a), random_access_iterator<const int*>(an), alloc);
+ test<std::vector<int> >(a, an, alloc);
+ }
+#if __cplusplus >= 201103L
+ {
+ int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 1, 0};
+ int* an = a + sizeof(a)/sizeof(a[0]);
+ min_allocator<int> alloc;
+ test<std::vector<int, min_allocator<int>> >(input_iterator<const int*>(a), input_iterator<const int*>(an), alloc);
+ test<std::vector<int, min_allocator<int>> >(forward_iterator<const int*>(a), forward_iterator<const int*>(an), alloc);
+ test<std::vector<int, min_allocator<int>> >(bidirectional_iterator<const int*>(a), bidirectional_iterator<const int*>(an), alloc);
+ test<std::vector<int, min_allocator<int>> >(random_access_iterator<const int*>(a), random_access_iterator<const int*>(an), alloc);
+ test<std::vector<int, min_allocator<int>> >(a, an, alloc);
+ test<std::vector<int, implicit_conv_allocator<int>> >(a, an, nullptr);
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/vector/vector.cons/construct_size.pass.cpp b/test/std/containers/sequences/vector/vector.cons/construct_size.pass.cpp
new file mode 100644
index 000000000000..e03389593f16
--- /dev/null
+++ b/test/std/containers/sequences/vector/vector.cons/construct_size.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// explicit vector(size_type n);
+
+#include <vector>
+#include <cassert>
+
+#include "DefaultOnly.h"
+#include "min_allocator.h"
+#include "test_allocator.h"
+#include "asan_testing.h"
+
+template <class C>
+void
+test2(typename C::size_type n, typename C::allocator_type const& a = typename C::allocator_type ())
+{
+#if _LIBCPP_STD_VER > 11
+ C c(n, a);
+ assert(c.__invariants());
+ assert(c.size() == n);
+ assert(c.get_allocator() == a);
+ assert(is_contiguous_container_asan_correct(c));
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i)
+ assert(*i == typename C::value_type());
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif
+}
+
+template <class C>
+void
+test1(typename C::size_type n)
+{
+ C c(n);
+ assert(c.__invariants());
+ assert(c.size() == n);
+ assert(c.get_allocator() == typename C::allocator_type());
+ assert(is_contiguous_container_asan_correct(c));
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i)
+ assert(*i == typename C::value_type());
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
+
+template <class C>
+void
+test(typename C::size_type n)
+{
+ test1<C> ( n );
+ test2<C> ( n );
+}
+
+int main()
+{
+ test<std::vector<int> >(50);
+ test<std::vector<DefaultOnly> >(500);
+ assert(DefaultOnly::count == 0);
+#if __cplusplus >= 201103L
+ test<std::vector<int, min_allocator<int>> >(50);
+ test<std::vector<DefaultOnly, min_allocator<DefaultOnly>> >(500);
+ test2<std::vector<DefaultOnly, test_allocator<DefaultOnly>> >( 100, test_allocator<DefaultOnly>(23));
+ assert(DefaultOnly::count == 0);
+#endif
+}
diff --git a/test/std/containers/sequences/vector/vector.cons/construct_size_value.pass.cpp b/test/std/containers/sequences/vector/vector.cons/construct_size_value.pass.cpp
new file mode 100644
index 000000000000..5b6c49857044
--- /dev/null
+++ b/test/std/containers/sequences/vector/vector.cons/construct_size_value.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector(size_type n, const value_type& x);
+
+#include <vector>
+#include <cassert>
+
+#include "../../../stack_allocator.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+template <class C>
+void
+test(typename C::size_type n, const typename C::value_type& x)
+{
+ C c(n, x);
+ assert(c.__invariants());
+ assert(c.size() == n);
+ assert(is_contiguous_container_asan_correct(c));
+ for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i)
+ assert(*i == x);
+}
+
+int main()
+{
+ test<std::vector<int> >(50, 3);
+ test<std::vector<int, stack_allocator<int, 50> > >(50, 5);
+#if __cplusplus >= 201103L
+ test<std::vector<int, min_allocator<int>> >(50, 3);
+#endif
+}
diff --git a/test/std/containers/sequences/vector/vector.cons/construct_size_value_alloc.pass.cpp b/test/std/containers/sequences/vector/vector.cons/construct_size_value_alloc.pass.cpp
new file mode 100644
index 000000000000..c62b84104aba
--- /dev/null
+++ b/test/std/containers/sequences/vector/vector.cons/construct_size_value_alloc.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector(size_type n, const value_type& x, const allocator_type& a);
+
+#include <vector>
+#include <cassert>
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+template <class C>
+void
+test(typename C::size_type n, const typename C::value_type& x,
+ const typename C::allocator_type& a)
+{
+ C c(n, x, a);
+ assert(c.__invariants());
+ assert(a == c.get_allocator());
+ assert(c.size() == n);
+ assert(is_contiguous_container_asan_correct(c));
+ for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i)
+ assert(*i == x);
+}
+
+int main()
+{
+ test<std::vector<int> >(50, 3, std::allocator<int>());
+#if __cplusplus >= 201103L
+ test<std::vector<int, min_allocator<int>> >(50, 3, min_allocator<int>());
+#endif
+}
diff --git a/test/std/containers/sequences/vector/vector.cons/copy.pass.cpp b/test/std/containers/sequences/vector/vector.cons/copy.pass.cpp
new file mode 100644
index 000000000000..677963deeb84
--- /dev/null
+++ b/test/std/containers/sequences/vector/vector.cons/copy.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector(const vector& v);
+
+#include <vector>
+#include <cassert>
+#include "test_allocator.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+template <class C>
+void
+test(const C& x)
+{
+ unsigned s = x.size();
+ C c(x);
+ assert(c.__invariants());
+ assert(c.size() == s);
+ assert(c == x);
+ assert(is_contiguous_container_asan_correct(c));
+}
+
+int main()
+{
+ {
+ int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 1, 0};
+ int* an = a + sizeof(a)/sizeof(a[0]);
+ test(std::vector<int>(a, an));
+ }
+ {
+ std::vector<int, test_allocator<int> > v(3, 2, test_allocator<int>(5));
+ std::vector<int, test_allocator<int> > v2 = v;
+ assert(is_contiguous_container_asan_correct(v));
+ assert(is_contiguous_container_asan_correct(v2));
+ assert(v2 == v);
+ assert(v2.get_allocator() == v.get_allocator());
+ assert(is_contiguous_container_asan_correct(v));
+ assert(is_contiguous_container_asan_correct(v2));
+ }
+#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+ {
+ std::vector<int, other_allocator<int> > v(3, 2, other_allocator<int>(5));
+ std::vector<int, other_allocator<int> > v2 = v;
+ assert(is_contiguous_container_asan_correct(v));
+ assert(is_contiguous_container_asan_correct(v2));
+ assert(v2 == v);
+ assert(v2.get_allocator() == other_allocator<int>(-2));
+ assert(is_contiguous_container_asan_correct(v));
+ assert(is_contiguous_container_asan_correct(v2));
+ }
+#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE
+#if __cplusplus >= 201103L
+ {
+ int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 1, 0};
+ int* an = a + sizeof(a)/sizeof(a[0]);
+ test(std::vector<int, min_allocator<int>>(a, an));
+ }
+ {
+ std::vector<int, min_allocator<int> > v(3, 2, min_allocator<int>());
+ std::vector<int, min_allocator<int> > v2 = v;
+ assert(is_contiguous_container_asan_correct(v));
+ assert(is_contiguous_container_asan_correct(v2));
+ assert(v2 == v);
+ assert(v2.get_allocator() == v.get_allocator());
+ assert(is_contiguous_container_asan_correct(v));
+ assert(is_contiguous_container_asan_correct(v2));
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/vector/vector.cons/copy_alloc.pass.cpp b/test/std/containers/sequences/vector/vector.cons/copy_alloc.pass.cpp
new file mode 100644
index 000000000000..128328c2a7d2
--- /dev/null
+++ b/test/std/containers/sequences/vector/vector.cons/copy_alloc.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector(const vector& v, const allocator_type& a);
+
+#include <vector>
+#include <cassert>
+#include "test_allocator.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+template <class C>
+void
+test(const C& x, const typename C::allocator_type& a)
+{
+ unsigned s = x.size();
+ C c(x, a);
+ assert(c.__invariants());
+ assert(c.size() == s);
+ assert(c == x);
+ assert(is_contiguous_container_asan_correct(c));
+}
+
+int main()
+{
+ {
+ int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 1, 0};
+ int* an = a + sizeof(a)/sizeof(a[0]);
+ test(std::vector<int>(a, an), std::allocator<int>());
+ }
+ {
+ std::vector<int, test_allocator<int> > l(3, 2, test_allocator<int>(5));
+ std::vector<int, test_allocator<int> > l2(l, test_allocator<int>(3));
+ assert(l2 == l);
+ assert(l2.get_allocator() == test_allocator<int>(3));
+ }
+ {
+ std::vector<int, other_allocator<int> > l(3, 2, other_allocator<int>(5));
+ std::vector<int, other_allocator<int> > l2(l, other_allocator<int>(3));
+ assert(l2 == l);
+ assert(l2.get_allocator() == other_allocator<int>(3));
+ }
+#if __cplusplus >= 201103L
+ {
+ int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 1, 0};
+ int* an = a + sizeof(a)/sizeof(a[0]);
+ test(std::vector<int, min_allocator<int>>(a, an), min_allocator<int>());
+ }
+ {
+ std::vector<int, min_allocator<int> > l(3, 2, min_allocator<int>());
+ std::vector<int, min_allocator<int> > l2(l, min_allocator<int>());
+ assert(l2 == l);
+ assert(l2.get_allocator() == min_allocator<int>());
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/vector/vector.cons/default.recursive.pass.cpp b/test/std/containers/sequences/vector/vector.cons/default.recursive.pass.cpp
new file mode 100644
index 000000000000..1a4a1898cc6b
--- /dev/null
+++ b/test/std/containers/sequences/vector/vector.cons/default.recursive.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// class vector
+// vector();
+
+#include <vector>
+
+struct X
+{
+ std::vector<X> q;
+};
+
+int main()
+{
+}
diff --git a/test/std/containers/sequences/vector/vector.cons/default_noexcept.pass.cpp b/test/std/containers/sequences/vector/vector.cons/default_noexcept.pass.cpp
new file mode 100644
index 000000000000..60f7b72c9477
--- /dev/null
+++ b/test/std/containers/sequences/vector/vector.cons/default_noexcept.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector()
+// noexcept(is_nothrow_default_constructible<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <vector>
+#include <cassert>
+
+#include "test_macros.h"
+#include "MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_alloc
+{
+ typedef T value_type;
+ some_alloc(const some_alloc&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::vector<MoveOnly> C;
+ static_assert(std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::vector<MoveOnly, test_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::vector<MoveOnly, other_allocator<MoveOnly>> C;
+ static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::vector<MoveOnly, some_alloc<MoveOnly>> C;
+ static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/vector/vector.cons/dtor_noexcept.pass.cpp b/test/std/containers/sequences/vector/vector.cons/dtor_noexcept.pass.cpp
new file mode 100644
index 000000000000..0e2cae9ee935
--- /dev/null
+++ b/test/std/containers/sequences/vector/vector.cons/dtor_noexcept.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// ~vector() // implied noexcept;
+
+#include <vector>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "test_allocator.h"
+
+#if __has_feature(cxx_noexcept)
+
+template <class T>
+struct some_alloc
+{
+ typedef T value_type;
+ some_alloc(const some_alloc&);
+ ~some_alloc() noexcept(false);
+};
+
+#endif
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::vector<MoveOnly> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::vector<MoveOnly, test_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::vector<MoveOnly, other_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::vector<MoveOnly, some_alloc<MoveOnly>> C;
+ static_assert(!std::is_nothrow_destructible<C>::value, "");
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/vector/vector.cons/initializer_list.pass.cpp b/test/std/containers/sequences/vector/vector.cons/initializer_list.pass.cpp
new file mode 100644
index 000000000000..7eb834ff3877
--- /dev/null
+++ b/test/std/containers/sequences/vector/vector.cons/initializer_list.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector(initializer_list<value_type> il);
+
+#include <vector>
+#include <cassert>
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ std::vector<int> d = {3, 4, 5, 6};
+ assert(d.size() == 4);
+ assert(is_contiguous_container_asan_correct(d));
+ assert(d[0] == 3);
+ assert(d[1] == 4);
+ assert(d[2] == 5);
+ assert(d[3] == 6);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<int, min_allocator<int>> d = {3, 4, 5, 6};
+ assert(d.size() == 4);
+ assert(is_contiguous_container_asan_correct(d));
+ assert(d[0] == 3);
+ assert(d[1] == 4);
+ assert(d[2] == 5);
+ assert(d[3] == 6);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/containers/sequences/vector/vector.cons/initializer_list_alloc.pass.cpp b/test/std/containers/sequences/vector/vector.cons/initializer_list_alloc.pass.cpp
new file mode 100644
index 000000000000..5d7ae884e382
--- /dev/null
+++ b/test/std/containers/sequences/vector/vector.cons/initializer_list_alloc.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector(initializer_list<value_type> il, const Allocator& a = allocator_type());
+
+#include <vector>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ std::vector<int, test_allocator<int>> d({3, 4, 5, 6}, test_allocator<int>(3));
+ assert(d.get_allocator() == test_allocator<int>(3));
+ assert(d.size() == 4);
+ assert(is_contiguous_container_asan_correct(d));
+ assert(d[0] == 3);
+ assert(d[1] == 4);
+ assert(d[2] == 5);
+ assert(d[3] == 6);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<int, min_allocator<int>> d({3, 4, 5, 6}, min_allocator<int>());
+ assert(d.get_allocator() == min_allocator<int>());
+ assert(d.size() == 4);
+ assert(is_contiguous_container_asan_correct(d));
+ assert(d[0] == 3);
+ assert(d[1] == 4);
+ assert(d[2] == 5);
+ assert(d[3] == 6);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/containers/sequences/vector/vector.cons/move.pass.cpp b/test/std/containers/sequences/vector/vector.cons/move.pass.cpp
new file mode 100644
index 000000000000..fb419d825d2b
--- /dev/null
+++ b/test/std/containers/sequences/vector/vector.cons/move.pass.cpp
@@ -0,0 +1,103 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector(vector&& c);
+
+#include <vector>
+#include <cassert>
+#include "MoveOnly.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::vector<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5));
+ std::vector<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5));
+ assert(is_contiguous_container_asan_correct(l));
+ assert(is_contiguous_container_asan_correct(lo));
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ assert(is_contiguous_container_asan_correct(l));
+ assert(is_contiguous_container_asan_correct(lo));
+ std::vector<MoveOnly, test_allocator<MoveOnly> > l2 = std::move(l);
+ assert(l2 == lo);
+ assert(l.empty());
+ assert(l2.get_allocator() == lo.get_allocator());
+ assert(is_contiguous_container_asan_correct(l2));
+ }
+ {
+ std::vector<MoveOnly, other_allocator<MoveOnly> > l(other_allocator<MoveOnly>(5));
+ std::vector<MoveOnly, other_allocator<MoveOnly> > lo(other_allocator<MoveOnly>(5));
+ assert(is_contiguous_container_asan_correct(l));
+ assert(is_contiguous_container_asan_correct(lo));
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ assert(is_contiguous_container_asan_correct(l));
+ assert(is_contiguous_container_asan_correct(lo));
+ std::vector<MoveOnly, other_allocator<MoveOnly> > l2 = std::move(l);
+ assert(l2 == lo);
+ assert(l.empty());
+ assert(l2.get_allocator() == lo.get_allocator());
+ assert(is_contiguous_container_asan_correct(l2));
+ }
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ std::vector<int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ assert(is_contiguous_container_asan_correct(c1));
+ std::vector<int>::const_iterator i = c1.begin();
+ std::vector<int> c2 = std::move(c1);
+ assert(is_contiguous_container_asan_correct(c2));
+ std::vector<int>::iterator j = c2.erase(i);
+ assert(*j == 3);
+ assert(is_contiguous_container_asan_correct(c2));
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<MoveOnly, min_allocator<MoveOnly> > l(min_allocator<MoveOnly>{});
+ std::vector<MoveOnly, min_allocator<MoveOnly> > lo(min_allocator<MoveOnly>{});
+ assert(is_contiguous_container_asan_correct(l));
+ assert(is_contiguous_container_asan_correct(lo));
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ assert(is_contiguous_container_asan_correct(l));
+ assert(is_contiguous_container_asan_correct(lo));
+ std::vector<MoveOnly, min_allocator<MoveOnly> > l2 = std::move(l);
+ assert(l2 == lo);
+ assert(l.empty());
+ assert(l2.get_allocator() == lo.get_allocator());
+ assert(is_contiguous_container_asan_correct(l2));
+ }
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ std::vector<int, min_allocator<int>> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ assert(is_contiguous_container_asan_correct(c1));
+ std::vector<int, min_allocator<int>>::const_iterator i = c1.begin();
+ std::vector<int, min_allocator<int>> c2 = std::move(c1);
+ assert(is_contiguous_container_asan_correct(c2));
+ std::vector<int, min_allocator<int>>::iterator j = c2.erase(i);
+ assert(*j == 3);
+ assert(is_contiguous_container_asan_correct(c2));
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/sequences/vector/vector.cons/move_alloc.pass.cpp b/test/std/containers/sequences/vector/vector.cons/move_alloc.pass.cpp
new file mode 100644
index 000000000000..aef96917cb32
--- /dev/null
+++ b/test/std/containers/sequences/vector/vector.cons/move_alloc.pass.cpp
@@ -0,0 +1,99 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector(vector&& c, const allocator_type& a);
+
+#include <vector>
+#include <cassert>
+#include "MoveOnly.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::vector<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5));
+ std::vector<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5));
+ assert(is_contiguous_container_asan_correct(l));
+ assert(is_contiguous_container_asan_correct(lo));
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ assert(is_contiguous_container_asan_correct(l));
+ assert(is_contiguous_container_asan_correct(lo));
+ std::vector<MoveOnly, test_allocator<MoveOnly> > l2(std::move(l), test_allocator<MoveOnly>(6));
+ assert(l2 == lo);
+ assert(!l.empty());
+ assert(l2.get_allocator() == test_allocator<MoveOnly>(6));
+ assert(is_contiguous_container_asan_correct(l2));
+ }
+ {
+ std::vector<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5));
+ std::vector<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5));
+ assert(is_contiguous_container_asan_correct(l));
+ assert(is_contiguous_container_asan_correct(lo));
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ assert(is_contiguous_container_asan_correct(l));
+ assert(is_contiguous_container_asan_correct(lo));
+ std::vector<MoveOnly, test_allocator<MoveOnly> > l2(std::move(l), test_allocator<MoveOnly>(5));
+ assert(l2 == lo);
+ assert(l.empty());
+ assert(l2.get_allocator() == test_allocator<MoveOnly>(5));
+ assert(is_contiguous_container_asan_correct(l2));
+ }
+ {
+ std::vector<MoveOnly, other_allocator<MoveOnly> > l(other_allocator<MoveOnly>(5));
+ std::vector<MoveOnly, other_allocator<MoveOnly> > lo(other_allocator<MoveOnly>(5));
+ assert(is_contiguous_container_asan_correct(l));
+ assert(is_contiguous_container_asan_correct(lo));
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ assert(is_contiguous_container_asan_correct(l));
+ assert(is_contiguous_container_asan_correct(lo));
+ std::vector<MoveOnly, other_allocator<MoveOnly> > l2(std::move(l), other_allocator<MoveOnly>(4));
+ assert(l2 == lo);
+ assert(!l.empty());
+ assert(l2.get_allocator() == other_allocator<MoveOnly>(4));
+ assert(is_contiguous_container_asan_correct(l2));
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<MoveOnly, min_allocator<MoveOnly> > l(min_allocator<MoveOnly>{});
+ std::vector<MoveOnly, min_allocator<MoveOnly> > lo(min_allocator<MoveOnly>{});
+ assert(is_contiguous_container_asan_correct(l));
+ assert(is_contiguous_container_asan_correct(lo));
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ assert(is_contiguous_container_asan_correct(l));
+ assert(is_contiguous_container_asan_correct(lo));
+ std::vector<MoveOnly, min_allocator<MoveOnly> > l2(std::move(l), min_allocator<MoveOnly>());
+ assert(l2 == lo);
+ assert(l.empty());
+ assert(l2.get_allocator() == min_allocator<MoveOnly>());
+ assert(is_contiguous_container_asan_correct(l2));
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/sequences/vector/vector.cons/move_assign_noexcept.pass.cpp b/test/std/containers/sequences/vector/vector.cons/move_assign_noexcept.pass.cpp
new file mode 100644
index 000000000000..1c4a4f7c9282
--- /dev/null
+++ b/test/std/containers/sequences/vector/vector.cons/move_assign_noexcept.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector& operator=(vector&& c)
+// noexcept(
+// allocator_type::propagate_on_container_move_assignment::value &&
+// is_nothrow_move_assignable<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <vector>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_alloc
+{
+ typedef T value_type;
+ some_alloc(const some_alloc&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::vector<MoveOnly> C;
+ static_assert(std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::vector<MoveOnly, test_allocator<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::vector<MoveOnly, other_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::vector<MoveOnly, some_alloc<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/vector/vector.cons/move_noexcept.pass.cpp b/test/std/containers/sequences/vector/vector.cons/move_noexcept.pass.cpp
new file mode 100644
index 000000000000..b7bbfaa421c4
--- /dev/null
+++ b/test/std/containers/sequences/vector/vector.cons/move_noexcept.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector(vector&&)
+// noexcept(is_nothrow_move_constructible<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <vector>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_alloc
+{
+ typedef T value_type;
+ some_alloc(const some_alloc&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::vector<MoveOnly> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::vector<MoveOnly, test_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::vector<MoveOnly, other_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::vector<MoveOnly, some_alloc<MoveOnly>> C;
+ // In C++17, move constructors for allocators are not allowed to throw
+#if TEST_STD_VER > 14
+ static_assert( std::is_nothrow_move_constructible<C>::value, "");
+#else
+ static_assert(!std::is_nothrow_move_constructible<C>::value, "");
+#endif
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/vector/vector.cons/op_equal_initializer_list.pass.cpp b/test/std/containers/sequences/vector/vector.cons/op_equal_initializer_list.pass.cpp
new file mode 100644
index 000000000000..592b71462767
--- /dev/null
+++ b/test/std/containers/sequences/vector/vector.cons/op_equal_initializer_list.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector& operator=(initializer_list<value_type> il);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ std::vector<int> d;
+ d = {3, 4, 5, 6};
+ assert(d.size() == 4);
+ assert(is_contiguous_container_asan_correct(d));
+ assert(d[0] == 3);
+ assert(d[1] == 4);
+ assert(d[2] == 5);
+ assert(d[3] == 6);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<int, min_allocator<int>> d;
+ d = {3, 4, 5, 6};
+ assert(d.size() == 4);
+ assert(is_contiguous_container_asan_correct(d));
+ assert(d[0] == 3);
+ assert(d[1] == 4);
+ assert(d[2] == 5);
+ assert(d[3] == 6);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/containers/sequences/vector/vector.data/data.pass.cpp b/test/std/containers/sequences/vector/vector.data/data.pass.cpp
new file mode 100644
index 000000000000..aed56bc09310
--- /dev/null
+++ b/test/std/containers/sequences/vector/vector.data/data.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// pointer data();
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+ {
+ std::vector<int> v;
+ assert(v.data() == 0);
+ assert(is_contiguous_container_asan_correct(v));
+ }
+ {
+ std::vector<int> v(100);
+ assert(v.data() == &v.front());
+ assert(is_contiguous_container_asan_correct(v));
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<int, min_allocator<int>> v;
+ assert(v.data() == 0);
+ assert(is_contiguous_container_asan_correct(v));
+ }
+ {
+ std::vector<int, min_allocator<int>> v(100);
+ assert(v.data() == &v.front());
+ assert(is_contiguous_container_asan_correct(v));
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/vector/vector.data/data_const.pass.cpp b/test/std/containers/sequences/vector/vector.data/data_const.pass.cpp
new file mode 100644
index 000000000000..cb6062694e40
--- /dev/null
+++ b/test/std/containers/sequences/vector/vector.data/data_const.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// const_pointer data() const;
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+ {
+ const std::vector<int> v;
+ assert(v.data() == 0);
+ assert(is_contiguous_container_asan_correct(v));
+ }
+ {
+ const std::vector<int> v(100);
+ assert(v.data() == &v.front());
+ assert(is_contiguous_container_asan_correct(v));
+ }
+#if __cplusplus >= 201103L
+ {
+ const std::vector<int, min_allocator<int>> v;
+ assert(v.data() == 0);
+ assert(is_contiguous_container_asan_correct(v));
+ }
+ {
+ const std::vector<int, min_allocator<int>> v(100);
+ assert(v.data() == &v.front());
+ assert(is_contiguous_container_asan_correct(v));
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/vector/vector.modifiers/emplace.pass.cpp b/test/std/containers/sequences/vector/vector.modifiers/emplace.pass.cpp
new file mode 100644
index 000000000000..8af6bdacd0a8
--- /dev/null
+++ b/test/std/containers/sequences/vector/vector.modifiers/emplace.pass.cpp
@@ -0,0 +1,160 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// template <class... Args> iterator emplace(const_iterator pos, Args&&... args);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <vector>
+#include <cassert>
+#include "../../../stack_allocator.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+class A
+{
+ int i_;
+ double d_;
+
+ A(const A&);
+ A& operator=(const A&);
+public:
+ A(int i, double d)
+ : i_(i), d_(d) {}
+
+ A(A&& a)
+ : i_(a.i_),
+ d_(a.d_)
+ {
+ a.i_ = 0;
+ a.d_ = 0;
+ }
+
+ A& operator=(A&& a)
+ {
+ i_ = a.i_;
+ d_ = a.d_;
+ a.i_ = 0;
+ a.d_ = 0;
+ return *this;
+ }
+
+ int geti() const {return i_;}
+ double getd() const {return d_;}
+};
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::vector<A> c;
+ std::vector<A>::iterator i = c.emplace(c.cbegin(), 2, 3.5);
+ assert(i == c.begin());
+ assert(c.size() == 1);
+ assert(c.front().geti() == 2);
+ assert(c.front().getd() == 3.5);
+ assert(is_contiguous_container_asan_correct(c));
+ i = c.emplace(c.cend(), 3, 4.5);
+ assert(i == c.end()-1);
+ assert(c.size() == 2);
+ assert(c.front().geti() == 2);
+ assert(c.front().getd() == 3.5);
+ assert(c.back().geti() == 3);
+ assert(c.back().getd() == 4.5);
+ assert(is_contiguous_container_asan_correct(c));
+ i = c.emplace(c.cbegin()+1, 4, 6.5);
+ assert(i == c.begin()+1);
+ assert(c.size() == 3);
+ assert(c.front().geti() == 2);
+ assert(c.front().getd() == 3.5);
+ assert(c[1].geti() == 4);
+ assert(c[1].getd() == 6.5);
+ assert(c.back().geti() == 3);
+ assert(c.back().getd() == 4.5);
+ assert(is_contiguous_container_asan_correct(c));
+ }
+ {
+ std::vector<A, stack_allocator<A, 7> > c;
+ std::vector<A, stack_allocator<A, 7> >::iterator i = c.emplace(c.cbegin(), 2, 3.5);
+ assert(i == c.begin());
+ assert(c.size() == 1);
+ assert(c.front().geti() == 2);
+ assert(c.front().getd() == 3.5);
+ assert(is_contiguous_container_asan_correct(c));
+ i = c.emplace(c.cend(), 3, 4.5);
+ assert(i == c.end()-1);
+ assert(c.size() == 2);
+ assert(c.front().geti() == 2);
+ assert(c.front().getd() == 3.5);
+ assert(c.back().geti() == 3);
+ assert(c.back().getd() == 4.5);
+ assert(is_contiguous_container_asan_correct(c));
+ i = c.emplace(c.cbegin()+1, 4, 6.5);
+ assert(i == c.begin()+1);
+ assert(c.size() == 3);
+ assert(c.front().geti() == 2);
+ assert(c.front().getd() == 3.5);
+ assert(c[1].geti() == 4);
+ assert(c[1].getd() == 6.5);
+ assert(c.back().geti() == 3);
+ assert(c.back().getd() == 4.5);
+ assert(is_contiguous_container_asan_correct(c));
+ }
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::vector<A> c1;
+ std::vector<A> c2;
+ std::vector<A>::iterator i = c1.emplace(c2.cbegin(), 2, 3.5);
+ assert(false);
+ }
+#endif
+#if __cplusplus >= 201103L
+ {
+ std::vector<A, min_allocator<A>> c;
+ std::vector<A, min_allocator<A>>::iterator i = c.emplace(c.cbegin(), 2, 3.5);
+ assert(i == c.begin());
+ assert(c.size() == 1);
+ assert(c.front().geti() == 2);
+ assert(c.front().getd() == 3.5);
+ i = c.emplace(c.cend(), 3, 4.5);
+ assert(i == c.end()-1);
+ assert(c.size() == 2);
+ assert(c.front().geti() == 2);
+ assert(c.front().getd() == 3.5);
+ assert(c.back().geti() == 3);
+ assert(c.back().getd() == 4.5);
+ i = c.emplace(c.cbegin()+1, 4, 6.5);
+ assert(i == c.begin()+1);
+ assert(c.size() == 3);
+ assert(c.front().geti() == 2);
+ assert(c.front().getd() == 3.5);
+ assert(c[1].geti() == 4);
+ assert(c[1].getd() == 6.5);
+ assert(c.back().geti() == 3);
+ assert(c.back().getd() == 4.5);
+ }
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::vector<A, min_allocator<A>> c1;
+ std::vector<A, min_allocator<A>> c2;
+ std::vector<A, min_allocator<A>>::iterator i = c1.emplace(c2.cbegin(), 2, 3.5);
+ assert(false);
+ }
+#endif
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/sequences/vector/vector.modifiers/emplace_back.pass.cpp b/test/std/containers/sequences/vector/vector.modifiers/emplace_back.pass.cpp
new file mode 100644
index 000000000000..bbf91a4255d7
--- /dev/null
+++ b/test/std/containers/sequences/vector/vector.modifiers/emplace_back.pass.cpp
@@ -0,0 +1,107 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// template <class... Args> void emplace_back(Args&&... args);
+
+#include <vector>
+#include <cassert>
+#include "../../../stack_allocator.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+class A
+{
+ int i_;
+ double d_;
+
+ A(const A&);
+ A& operator=(const A&);
+public:
+ A(int i, double d)
+ : i_(i), d_(d) {}
+
+ A(A&& a)
+ : i_(a.i_),
+ d_(a.d_)
+ {
+ a.i_ = 0;
+ a.d_ = 0;
+ }
+
+ A& operator=(A&& a)
+ {
+ i_ = a.i_;
+ d_ = a.d_;
+ a.i_ = 0;
+ a.d_ = 0;
+ return *this;
+ }
+
+ int geti() const {return i_;}
+ double getd() const {return d_;}
+};
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::vector<A> c;
+ c.emplace_back(2, 3.5);
+ assert(c.size() == 1);
+ assert(c.front().geti() == 2);
+ assert(c.front().getd() == 3.5);
+ assert(is_contiguous_container_asan_correct(c));
+ c.emplace_back(3, 4.5);
+ assert(c.size() == 2);
+ assert(c.front().geti() == 2);
+ assert(c.front().getd() == 3.5);
+ assert(c.back().geti() == 3);
+ assert(c.back().getd() == 4.5);
+ assert(is_contiguous_container_asan_correct(c));
+ }
+ {
+ std::vector<A, stack_allocator<A, 4> > c;
+ c.emplace_back(2, 3.5);
+ assert(c.size() == 1);
+ assert(c.front().geti() == 2);
+ assert(c.front().getd() == 3.5);
+ assert(is_contiguous_container_asan_correct(c));
+ c.emplace_back(3, 4.5);
+ assert(c.size() == 2);
+ assert(c.front().geti() == 2);
+ assert(c.front().getd() == 3.5);
+ assert(c.back().geti() == 3);
+ assert(c.back().getd() == 4.5);
+ assert(is_contiguous_container_asan_correct(c));
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<A, min_allocator<A>> c;
+ c.emplace_back(2, 3.5);
+ assert(c.size() == 1);
+ assert(c.front().geti() == 2);
+ assert(c.front().getd() == 3.5);
+ assert(is_contiguous_container_asan_correct(c));
+ c.emplace_back(3, 4.5);
+ assert(c.size() == 2);
+ assert(c.front().geti() == 2);
+ assert(c.front().getd() == 3.5);
+ assert(c.back().geti() == 3);
+ assert(c.back().getd() == 4.5);
+ assert(is_contiguous_container_asan_correct(c));
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/sequences/vector/vector.modifiers/emplace_extra.pass.cpp b/test/std/containers/sequences/vector/vector.modifiers/emplace_extra.pass.cpp
new file mode 100644
index 000000000000..85a47073bcb2
--- /dev/null
+++ b/test/std/containers/sequences/vector/vector.modifiers/emplace_extra.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// template <class... Args> iterator emplace(const_iterator pos, Args&&... args);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ std::vector<int> v;
+ v.reserve(3);
+ assert(is_contiguous_container_asan_correct(v));
+ v = { 1, 2, 3 };
+ v.emplace(v.begin(), v.back());
+ assert(v[0] == 3);
+ assert(is_contiguous_container_asan_correct(v));
+ }
+ {
+ std::vector<int> v;
+ v.reserve(4);
+ assert(is_contiguous_container_asan_correct(v));
+ v = { 1, 2, 3 };
+ v.emplace(v.begin(), v.back());
+ assert(v[0] == 3);
+ assert(is_contiguous_container_asan_correct(v));
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<int, min_allocator<int>> v;
+ v.reserve(3);
+ assert(is_contiguous_container_asan_correct(v));
+ v = { 1, 2, 3 };
+ v.emplace(v.begin(), v.back());
+ assert(v[0] == 3);
+ assert(is_contiguous_container_asan_correct(v));
+ }
+ {
+ std::vector<int, min_allocator<int>> v;
+ v.reserve(4);
+ assert(is_contiguous_container_asan_correct(v));
+ v = { 1, 2, 3 };
+ v.emplace(v.begin(), v.back());
+ assert(v[0] == 3);
+ assert(is_contiguous_container_asan_correct(v));
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/containers/sequences/vector/vector.modifiers/erase_iter.pass.cpp b/test/std/containers/sequences/vector/vector.modifiers/erase_iter.pass.cpp
new file mode 100644
index 000000000000..4fa07b729a75
--- /dev/null
+++ b/test/std/containers/sequences/vector/vector.modifiers/erase_iter.pass.cpp
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// iterator erase(const_iterator position);
+
+#include <vector>
+#include <iterator>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+ {
+ int a1[] = {1, 2, 3};
+ std::vector<int> l1(a1, a1+3);
+ std::vector<int>::const_iterator i = l1.begin();
+ assert(is_contiguous_container_asan_correct(l1));
+ ++i;
+ std::vector<int>::iterator j = l1.erase(i);
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ assert(*j == 3);
+ assert(*l1.begin() == 1);
+ assert(*next(l1.begin()) == 3);
+ assert(is_contiguous_container_asan_correct(l1));
+ j = l1.erase(j);
+ assert(j == l1.end());
+ assert(l1.size() == 1);
+ assert(distance(l1.begin(), l1.end()) == 1);
+ assert(*l1.begin() == 1);
+ assert(is_contiguous_container_asan_correct(l1));
+ j = l1.erase(l1.begin());
+ assert(j == l1.end());
+ assert(l1.size() == 0);
+ assert(distance(l1.begin(), l1.end()) == 0);
+ assert(is_contiguous_container_asan_correct(l1));
+ }
+#if __cplusplus >= 201103L
+ {
+ int a1[] = {1, 2, 3};
+ std::vector<int, min_allocator<int>> l1(a1, a1+3);
+ std::vector<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(is_contiguous_container_asan_correct(l1));
+ ++i;
+ std::vector<int, min_allocator<int>>::iterator j = l1.erase(i);
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ assert(*j == 3);
+ assert(*l1.begin() == 1);
+ assert(*next(l1.begin()) == 3);
+ assert(is_contiguous_container_asan_correct(l1));
+ j = l1.erase(j);
+ assert(j == l1.end());
+ assert(l1.size() == 1);
+ assert(distance(l1.begin(), l1.end()) == 1);
+ assert(*l1.begin() == 1);
+ assert(is_contiguous_container_asan_correct(l1));
+ j = l1.erase(l1.begin());
+ assert(j == l1.end());
+ assert(l1.size() == 0);
+ assert(distance(l1.begin(), l1.end()) == 0);
+ assert(is_contiguous_container_asan_correct(l1));
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/vector/vector.modifiers/erase_iter_db1.pass.cpp b/test/std/containers/sequences/vector/vector.modifiers/erase_iter_db1.pass.cpp
new file mode 100644
index 000000000000..0478d24c79f6
--- /dev/null
+++ b/test/std/containers/sequences/vector/vector.modifiers/erase_iter_db1.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Call erase(const_iterator position) with end()
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <cstdlib>
+#include <exception>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ int a1[] = {1, 2, 3};
+ std::vector<int> l1(a1, a1+3);
+ std::vector<int>::const_iterator i = l1.end();
+ l1.erase(i);
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ int a1[] = {1, 2, 3};
+ std::vector<int, min_allocator<int>> l1(a1, a1+3);
+ std::vector<int, min_allocator<int>>::const_iterator i = l1.end();
+ l1.erase(i);
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/containers/sequences/vector/vector.modifiers/erase_iter_db2.pass.cpp b/test/std/containers/sequences/vector/vector.modifiers/erase_iter_db2.pass.cpp
new file mode 100644
index 000000000000..c394f197402b
--- /dev/null
+++ b/test/std/containers/sequences/vector/vector.modifiers/erase_iter_db2.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Call erase(const_iterator position) with iterator from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <cstdlib>
+#include <exception>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ int a1[] = {1, 2, 3};
+ std::vector<int> l1(a1, a1+3);
+ std::vector<int> l2(a1, a1+3);
+ std::vector<int>::const_iterator i = l2.begin();
+ l1.erase(i);
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ int a1[] = {1, 2, 3};
+ std::vector<int, min_allocator<int>> l1(a1, a1+3);
+ std::vector<int, min_allocator<int>> l2(a1, a1+3);
+ std::vector<int, min_allocator<int>>::const_iterator i = l2.begin();
+ l1.erase(i);
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter.pass.cpp b/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter.pass.cpp
new file mode 100644
index 000000000000..2e81d133cde0
--- /dev/null
+++ b/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter.pass.cpp
@@ -0,0 +1,128 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// iterator erase(const_iterator first, const_iterator last);
+
+#include <vector>
+#include <iterator>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+ int a1[] = {1, 2, 3};
+ {
+ std::vector<int> l1(a1, a1+3);
+ assert(is_contiguous_container_asan_correct(l1));
+ std::vector<int>::iterator i = l1.erase(l1.cbegin(), l1.cbegin());
+ assert(l1.size() == 3);
+ assert(distance(l1.cbegin(), l1.cend()) == 3);
+ assert(i == l1.begin());
+ assert(is_contiguous_container_asan_correct(l1));
+ }
+ {
+ std::vector<int> l1(a1, a1+3);
+ assert(is_contiguous_container_asan_correct(l1));
+ std::vector<int>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin()));
+ assert(l1.size() == 2);
+ assert(distance(l1.cbegin(), l1.cend()) == 2);
+ assert(i == l1.begin());
+ assert(l1 == std::vector<int>(a1+1, a1+3));
+ assert(is_contiguous_container_asan_correct(l1));
+ }
+ {
+ std::vector<int> l1(a1, a1+3);
+ assert(is_contiguous_container_asan_correct(l1));
+ std::vector<int>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin(), 2));
+ assert(l1.size() == 1);
+ assert(distance(l1.cbegin(), l1.cend()) == 1);
+ assert(i == l1.begin());
+ assert(l1 == std::vector<int>(a1+2, a1+3));
+ assert(is_contiguous_container_asan_correct(l1));
+ }
+ {
+ std::vector<int> l1(a1, a1+3);
+ assert(is_contiguous_container_asan_correct(l1));
+ std::vector<int>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin(), 3));
+ assert(l1.size() == 0);
+ assert(distance(l1.cbegin(), l1.cend()) == 0);
+ assert(i == l1.begin());
+ assert(is_contiguous_container_asan_correct(l1));
+ }
+ {
+ std::vector<std::vector<int> > outer(2, std::vector<int>(1));
+ assert(is_contiguous_container_asan_correct(outer));
+ assert(is_contiguous_container_asan_correct(outer[0]));
+ assert(is_contiguous_container_asan_correct(outer[1]));
+ outer.erase(outer.begin(), outer.begin());
+ assert(outer.size() == 2);
+ assert(outer[0].size() == 1);
+ assert(outer[1].size() == 1);
+ assert(is_contiguous_container_asan_correct(outer));
+ assert(is_contiguous_container_asan_correct(outer[0]));
+ assert(is_contiguous_container_asan_correct(outer[1]));
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<int, min_allocator<int>> l1(a1, a1+3);
+ assert(is_contiguous_container_asan_correct(l1));
+ std::vector<int, min_allocator<int>>::iterator i = l1.erase(l1.cbegin(), l1.cbegin());
+ assert(l1.size() == 3);
+ assert(distance(l1.cbegin(), l1.cend()) == 3);
+ assert(i == l1.begin());
+ assert(is_contiguous_container_asan_correct(l1));
+ }
+ {
+ std::vector<int, min_allocator<int>> l1(a1, a1+3);
+ assert(is_contiguous_container_asan_correct(l1));
+ std::vector<int, min_allocator<int>>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin()));
+ assert(l1.size() == 2);
+ assert(distance(l1.cbegin(), l1.cend()) == 2);
+ assert(i == l1.begin());
+ assert((l1 == std::vector<int, min_allocator<int>>(a1+1, a1+3)));
+ assert(is_contiguous_container_asan_correct(l1));
+ }
+ {
+ std::vector<int, min_allocator<int>> l1(a1, a1+3);
+ assert(is_contiguous_container_asan_correct(l1));
+ std::vector<int, min_allocator<int>>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin(), 2));
+ assert(l1.size() == 1);
+ assert(distance(l1.cbegin(), l1.cend()) == 1);
+ assert(i == l1.begin());
+ assert((l1 == std::vector<int, min_allocator<int>>(a1+2, a1+3)));
+ assert(is_contiguous_container_asan_correct(l1));
+ }
+ {
+ std::vector<int, min_allocator<int>> l1(a1, a1+3);
+ assert(is_contiguous_container_asan_correct(l1));
+ std::vector<int, min_allocator<int>>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin(), 3));
+ assert(l1.size() == 0);
+ assert(distance(l1.cbegin(), l1.cend()) == 0);
+ assert(i == l1.begin());
+ assert(is_contiguous_container_asan_correct(l1));
+ }
+ {
+ std::vector<std::vector<int, min_allocator<int>>, min_allocator<std::vector<int, min_allocator<int>>>> outer(2, std::vector<int, min_allocator<int>>(1));
+ assert(is_contiguous_container_asan_correct(outer));
+ assert(is_contiguous_container_asan_correct(outer[0]));
+ assert(is_contiguous_container_asan_correct(outer[1]));
+ outer.erase(outer.begin(), outer.begin());
+ assert(outer.size() == 2);
+ assert(outer[0].size() == 1);
+ assert(outer[1].size() == 1);
+ assert(is_contiguous_container_asan_correct(outer));
+ assert(is_contiguous_container_asan_correct(outer[0]));
+ assert(is_contiguous_container_asan_correct(outer[1]));
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db1.pass.cpp b/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db1.pass.cpp
new file mode 100644
index 000000000000..af6d0f757892
--- /dev/null
+++ b/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db1.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Call erase(const_iterator first, const_iterator last); with first iterator from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ int a1[] = {1, 2, 3};
+ std::vector<int> l1(a1, a1+3);
+ std::vector<int> l2(a1, a1+3);
+ std::vector<int>::iterator i = l1.erase(l2.cbegin(), l1.cbegin()+1);
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ int a1[] = {1, 2, 3};
+ std::vector<int, min_allocator<int>> l1(a1, a1+3);
+ std::vector<int, min_allocator<int>> l2(a1, a1+3);
+ std::vector<int, min_allocator<int>>::iterator i = l1.erase(l2.cbegin(), l1.cbegin()+1);
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db2.pass.cpp b/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db2.pass.cpp
new file mode 100644
index 000000000000..eee2c66c5c8c
--- /dev/null
+++ b/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db2.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Call erase(const_iterator first, const_iterator last); with second iterator from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ int a1[] = {1, 2, 3};
+ std::vector<int> l1(a1, a1+3);
+ std::vector<int> l2(a1, a1+3);
+ std::vector<int>::iterator i = l1.erase(l1.cbegin(), l2.cbegin()+1);
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ int a1[] = {1, 2, 3};
+ std::vector<int, min_allocator<int>> l1(a1, a1+3);
+ std::vector<int, min_allocator<int>> l2(a1, a1+3);
+ std::vector<int, min_allocator<int>>::iterator i = l1.erase(l1.cbegin(), l2.cbegin()+1);
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db3.pass.cpp b/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db3.pass.cpp
new file mode 100644
index 000000000000..505067d05a1a
--- /dev/null
+++ b/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db3.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Call erase(const_iterator first, const_iterator last); with both iterators from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ int a1[] = {1, 2, 3};
+ std::vector<int> l1(a1, a1+3);
+ std::vector<int> l2(a1, a1+3);
+ std::vector<int>::iterator i = l1.erase(l2.cbegin(), l2.cbegin()+1);
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ int a1[] = {1, 2, 3};
+ std::vector<int, min_allocator<int>> l1(a1, a1+3);
+ std::vector<int, min_allocator<int>> l2(a1, a1+3);
+ std::vector<int, min_allocator<int>>::iterator i = l1.erase(l2.cbegin(), l2.cbegin()+1);
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db4.pass.cpp b/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db4.pass.cpp
new file mode 100644
index 000000000000..c7e4131cb49c
--- /dev/null
+++ b/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db4.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Call erase(const_iterator first, const_iterator last); with a bad range
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ int a1[] = {1, 2, 3};
+ std::vector<int> l1(a1, a1+3);
+ std::vector<int>::iterator i = l1.erase(l1.cbegin()+1, l1.cbegin());
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ int a1[] = {1, 2, 3};
+ std::vector<int, min_allocator<int>> l1(a1, a1+3);
+ std::vector<int, min_allocator<int>>::iterator i = l1.erase(l1.cbegin()+1, l1.cbegin());
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/containers/sequences/vector/vector.modifiers/insert_iter_initializer_list.pass.cpp b/test/std/containers/sequences/vector/vector.modifiers/insert_iter_initializer_list.pass.cpp
new file mode 100644
index 000000000000..30b801788013
--- /dev/null
+++ b/test/std/containers/sequences/vector/vector.modifiers/insert_iter_initializer_list.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// iterator insert(const_iterator p, initializer_list<value_type> il);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ std::vector<int> d(10, 1);
+ std::vector<int>::iterator i = d.insert(d.cbegin() + 2, {3, 4, 5, 6});
+ assert(d.size() == 14);
+ assert(is_contiguous_container_asan_correct(d));
+ assert(i == d.begin() + 2);
+ assert(d[0] == 1);
+ assert(d[1] == 1);
+ assert(d[2] == 3);
+ assert(d[3] == 4);
+ assert(d[4] == 5);
+ assert(d[5] == 6);
+ assert(d[6] == 1);
+ assert(d[7] == 1);
+ assert(d[8] == 1);
+ assert(d[9] == 1);
+ assert(d[10] == 1);
+ assert(d[11] == 1);
+ assert(d[12] == 1);
+ assert(d[13] == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<int, min_allocator<int>> d(10, 1);
+ std::vector<int, min_allocator<int>>::iterator i = d.insert(d.cbegin() + 2, {3, 4, 5, 6});
+ assert(d.size() == 14);
+ assert(is_contiguous_container_asan_correct(d));
+ assert(i == d.begin() + 2);
+ assert(d[0] == 1);
+ assert(d[1] == 1);
+ assert(d[2] == 3);
+ assert(d[3] == 4);
+ assert(d[4] == 5);
+ assert(d[5] == 6);
+ assert(d[6] == 1);
+ assert(d[7] == 1);
+ assert(d[8] == 1);
+ assert(d[9] == 1);
+ assert(d[10] == 1);
+ assert(d[11] == 1);
+ assert(d[12] == 1);
+ assert(d[13] == 1);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/containers/sequences/vector/vector.modifiers/insert_iter_iter_iter.pass.cpp b/test/std/containers/sequences/vector/vector.modifiers/insert_iter_iter_iter.pass.cpp
new file mode 100644
index 000000000000..782437be87f8
--- /dev/null
+++ b/test/std/containers/sequences/vector/vector.modifiers/insert_iter_iter_iter.pass.cpp
@@ -0,0 +1,190 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// template <class Iter>
+// iterator insert(const_iterator position, Iter first, Iter last);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <vector>
+#include <cassert>
+#include "../../../stack_allocator.h"
+#include "test_iterators.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+ {
+ std::vector<int> v(100);
+ int a[] = {1, 2, 3, 4, 5};
+ const int N = sizeof(a)/sizeof(a[0]);
+ std::vector<int>::iterator i = v.insert(v.cbegin() + 10, input_iterator<const int*>(a),
+ input_iterator<const int*>(a+N));
+ assert(v.size() == 100 + N);
+ assert(is_contiguous_container_asan_correct(v));
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == 0);
+ for (int k = 0; k < N; ++j, ++k)
+ assert(v[j] == a[k]);
+ for (; j < 105; ++j)
+ assert(v[j] == 0);
+ }
+ {
+ std::vector<int> v(100);
+ int a[] = {1, 2, 3, 4, 5};
+ const int N = sizeof(a)/sizeof(a[0]);
+ std::vector<int>::iterator i = v.insert(v.cbegin() + 10, forward_iterator<const int*>(a),
+ forward_iterator<const int*>(a+N));
+ assert(v.size() == 100 + N);
+ assert(is_contiguous_container_asan_correct(v));
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == 0);
+ for (int k = 0; k < N; ++j, ++k)
+ assert(v[j] == a[k]);
+ for (; j < 105; ++j)
+ assert(v[j] == 0);
+ }
+ {
+ std::vector<int> v(100);
+ while(v.size() < v.capacity()) v.push_back(0); // force reallocation
+ size_t sz = v.size();
+ int a[] = {1, 2, 3, 4, 5};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::vector<int>::iterator i = v.insert(v.cbegin() + 10, forward_iterator<const int*>(a),
+ forward_iterator<const int*>(a+N));
+ assert(v.size() == sz + N);
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == 0);
+ for (int k = 0; k < N; ++j, ++k)
+ assert(v[j] == a[k]);
+ for (; j < v.size(); ++j)
+ assert(v[j] == 0);
+ }
+ {
+ std::vector<int> v(100);
+ v.reserve(128); // force no reallocation
+ size_t sz = v.size();
+ int a[] = {1, 2, 3, 4, 5};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::vector<int>::iterator i = v.insert(v.cbegin() + 10, forward_iterator<const int*>(a),
+ forward_iterator<const int*>(a+N));
+ assert(v.size() == sz + N);
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == 0);
+ for (int k = 0; k < N; ++j, ++k)
+ assert(v[j] == a[k]);
+ for (; j < v.size(); ++j)
+ assert(v[j] == 0);
+ }
+ {
+ std::vector<int, stack_allocator<int, 308> > v(100);
+ int a[] = {1, 2, 3, 4, 5};
+ const int N = sizeof(a)/sizeof(a[0]);
+ std::vector<int>::iterator i = v.insert(v.cbegin() + 10, input_iterator<const int*>(a),
+ input_iterator<const int*>(a+N));
+ assert(v.size() == 100 + N);
+ assert(is_contiguous_container_asan_correct(v));
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == 0);
+ for (int k = 0; k < N; ++j, ++k)
+ assert(v[j] == a[k]);
+ for (; j < 105; ++j)
+ assert(v[j] == 0);
+ }
+ {
+ std::vector<int, stack_allocator<int, 300> > v(100);
+ int a[] = {1, 2, 3, 4, 5};
+ const int N = sizeof(a)/sizeof(a[0]);
+ std::vector<int>::iterator i = v.insert(v.cbegin() + 10, forward_iterator<const int*>(a),
+ forward_iterator<const int*>(a+N));
+ assert(v.size() == 100 + N);
+ assert(is_contiguous_container_asan_correct(v));
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == 0);
+ for (int k = 0; k < N; ++j, ++k)
+ assert(v[j] == a[k]);
+ for (; j < 105; ++j)
+ assert(v[j] == 0);
+ }
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::vector<int> v(100);
+ std::vector<int> v2(100);
+ int a[] = {1, 2, 3, 4, 5};
+ const int N = sizeof(a)/sizeof(a[0]);
+ std::vector<int>::iterator i = v.insert(v2.cbegin() + 10, input_iterator<const int*>(a),
+ input_iterator<const int*>(a+N));
+ assert(false);
+ }
+#endif
+#if __cplusplus >= 201103L
+ {
+ std::vector<int, min_allocator<int>> v(100);
+ int a[] = {1, 2, 3, 4, 5};
+ const int N = sizeof(a)/sizeof(a[0]);
+ std::vector<int, min_allocator<int>>::iterator i = v.insert(v.cbegin() + 10, input_iterator<const int*>(a),
+ input_iterator<const int*>(a+N));
+ assert(v.size() == 100 + N);
+ assert(is_contiguous_container_asan_correct(v));
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == 0);
+ for (int k = 0; k < N; ++j, ++k)
+ assert(v[j] == a[k]);
+ for (; j < 105; ++j)
+ assert(v[j] == 0);
+ }
+ {
+ std::vector<int, min_allocator<int>> v(100);
+ int a[] = {1, 2, 3, 4, 5};
+ const int N = sizeof(a)/sizeof(a[0]);
+ std::vector<int, min_allocator<int>>::iterator i = v.insert(v.cbegin() + 10, forward_iterator<const int*>(a),
+ forward_iterator<const int*>(a+N));
+ assert(v.size() == 100 + N);
+ assert(is_contiguous_container_asan_correct(v));
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == 0);
+ for (int k = 0; k < N; ++j, ++k)
+ assert(v[j] == a[k]);
+ for (; j < 105; ++j)
+ assert(v[j] == 0);
+ }
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::vector<int, min_allocator<int>> v(100);
+ std::vector<int, min_allocator<int>> v2(100);
+ int a[] = {1, 2, 3, 4, 5};
+ const int N = sizeof(a)/sizeof(a[0]);
+ std::vector<int, min_allocator<int>>::iterator i = v.insert(v2.cbegin() + 10, input_iterator<const int*>(a),
+ input_iterator<const int*>(a+N));
+ assert(false);
+ }
+#endif
+#endif
+}
diff --git a/test/std/containers/sequences/vector/vector.modifiers/insert_iter_rvalue.pass.cpp b/test/std/containers/sequences/vector/vector.modifiers/insert_iter_rvalue.pass.cpp
new file mode 100644
index 000000000000..e12ec45febfc
--- /dev/null
+++ b/test/std/containers/sequences/vector/vector.modifiers/insert_iter_rvalue.pass.cpp
@@ -0,0 +1,86 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// iterator insert(const_iterator position, value_type&& x);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <vector>
+#include <cassert>
+#include "../../../stack_allocator.h"
+#include "MoveOnly.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::vector<MoveOnly> v(100);
+ std::vector<MoveOnly>::iterator i = v.insert(v.cbegin() + 10, MoveOnly(3));
+ assert(v.size() == 101);
+ assert(is_contiguous_container_asan_correct(v));
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == MoveOnly());
+ assert(v[j] == MoveOnly(3));
+ for (++j; j < 101; ++j)
+ assert(v[j] == MoveOnly());
+ }
+ {
+ std::vector<MoveOnly, stack_allocator<MoveOnly, 300> > v(100);
+ std::vector<MoveOnly, stack_allocator<MoveOnly, 300> >::iterator i = v.insert(v.cbegin() + 10, MoveOnly(3));
+ assert(v.size() == 101);
+ assert(is_contiguous_container_asan_correct(v));
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == MoveOnly());
+ assert(v[j] == MoveOnly(3));
+ for (++j; j < 101; ++j)
+ assert(v[j] == MoveOnly());
+ }
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::vector<int> v1(3);
+ std::vector<int> v2(3);
+ v1.insert(v2.begin(), 4);
+ assert(false);
+ }
+#endif
+#if __cplusplus >= 201103L
+ {
+ std::vector<MoveOnly, min_allocator<MoveOnly>> v(100);
+ std::vector<MoveOnly, min_allocator<MoveOnly>>::iterator i = v.insert(v.cbegin() + 10, MoveOnly(3));
+ assert(v.size() == 101);
+ assert(is_contiguous_container_asan_correct(v));
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == MoveOnly());
+ assert(v[j] == MoveOnly(3));
+ for (++j; j < 101; ++j)
+ assert(v[j] == MoveOnly());
+ }
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::vector<int, min_allocator<int>> v1(3);
+ std::vector<int, min_allocator<int>> v2(3);
+ v1.insert(v2.begin(), 4);
+ assert(false);
+ }
+#endif
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/sequences/vector/vector.modifiers/insert_iter_size_value.pass.cpp b/test/std/containers/sequences/vector/vector.modifiers/insert_iter_size_value.pass.cpp
new file mode 100644
index 000000000000..6997284f258c
--- /dev/null
+++ b/test/std/containers/sequences/vector/vector.modifiers/insert_iter_size_value.pass.cpp
@@ -0,0 +1,132 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// iterator insert(const_iterator position, size_type n, const value_type& x);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <vector>
+#include <cassert>
+#include "../../../stack_allocator.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+ {
+ std::vector<int> v(100);
+ std::vector<int>::iterator i = v.insert(v.cbegin() + 10, 5, 1);
+ assert(v.size() == 105);
+ assert(is_contiguous_container_asan_correct(v));
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == 0);
+ for (; j < 15; ++j)
+ assert(v[j] == 1);
+ for (++j; j < 105; ++j)
+ assert(v[j] == 0);
+ }
+ {
+ std::vector<int> v(100);
+ while(v.size() < v.capacity()) v.push_back(0); // force reallocation
+ size_t sz = v.size();
+ std::vector<int>::iterator i = v.insert(v.cbegin() + 10, 5, 1);
+ assert(v.size() == sz + 5);
+ assert(is_contiguous_container_asan_correct(v));
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == 0);
+ for (; j < 15; ++j)
+ assert(v[j] == 1);
+ for (++j; j < v.size(); ++j)
+ assert(v[j] == 0);
+ }
+ {
+ std::vector<int> v(100);
+ v.reserve(128); // force no reallocation
+ size_t sz = v.size();
+ std::vector<int>::iterator i = v.insert(v.cbegin() + 10, 5, 1);
+ assert(v.size() == sz + 5);
+ assert(is_contiguous_container_asan_correct(v));
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == 0);
+ for (; j < 15; ++j)
+ assert(v[j] == 1);
+ for (++j; j < v.size(); ++j)
+ assert(v[j] == 0);
+ }
+ {
+ std::vector<int, stack_allocator<int, 300> > v(100);
+ std::vector<int, stack_allocator<int, 300> >::iterator i = v.insert(v.cbegin() + 10, 5, 1);
+ assert(v.size() == 105);
+ assert(is_contiguous_container_asan_correct(v));
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == 0);
+ for (; j < 15; ++j)
+ assert(v[j] == 1);
+ for (++j; j < 105; ++j)
+ assert(v[j] == 0);
+ }
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::vector<int> c1(100);
+ std::vector<int> c2;
+ std::vector<int>::iterator i = c1.insert(c2.cbegin() + 10, 5, 1);
+ assert(false);
+ }
+#endif
+#if __cplusplus >= 201103L
+ {
+ std::vector<int, min_allocator<int>> v(100);
+ std::vector<int, min_allocator<int>>::iterator i = v.insert(v.cbegin() + 10, 5, 1);
+ assert(v.size() == 105);
+ assert(is_contiguous_container_asan_correct(v));
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == 0);
+ for (; j < 15; ++j)
+ assert(v[j] == 1);
+ for (++j; j < 105; ++j)
+ assert(v[j] == 0);
+ }
+ {
+ std::vector<int, min_allocator<int>> v(100);
+ std::vector<int, min_allocator<int>>::iterator i = v.insert(v.cbegin() + 10, 5, 1);
+ assert(v.size() == 105);
+ assert(is_contiguous_container_asan_correct(v));
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == 0);
+ for (; j < 15; ++j)
+ assert(v[j] == 1);
+ for (++j; j < 105; ++j)
+ assert(v[j] == 0);
+ }
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::vector<int, min_allocator<int>> c1(100);
+ std::vector<int, min_allocator<int>> c2;
+ std::vector<int, min_allocator<int>>::iterator i = c1.insert(c2.cbegin() + 10, 5, 1);
+ assert(false);
+ }
+#endif
+#endif
+}
diff --git a/test/std/containers/sequences/vector/vector.modifiers/insert_iter_value.pass.cpp b/test/std/containers/sequences/vector/vector.modifiers/insert_iter_value.pass.cpp
new file mode 100644
index 000000000000..782e752157a7
--- /dev/null
+++ b/test/std/containers/sequences/vector/vector.modifiers/insert_iter_value.pass.cpp
@@ -0,0 +1,116 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// iterator insert(const_iterator position, const value_type& x);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <vector>
+#include <cassert>
+#include "../../../stack_allocator.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+ {
+ std::vector<int> v(100);
+ std::vector<int>::iterator i = v.insert(v.cbegin() + 10, 1);
+ assert(v.size() == 101);
+ assert(is_contiguous_container_asan_correct(v));
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == 0);
+ assert(v[j] == 1);
+ for (++j; j < 101; ++j)
+ assert(v[j] == 0);
+ }
+ {
+ std::vector<int> v(100);
+ while(v.size() < v.capacity()) v.push_back(0); // force reallocation
+ size_t sz = v.size();
+ std::vector<int>::iterator i = v.insert(v.cbegin() + 10, 1);
+ assert(v.size() == sz + 1);
+ assert(is_contiguous_container_asan_correct(v));
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == 0);
+ assert(v[j] == 1);
+ for (++j; j < v.size(); ++j)
+ assert(v[j] == 0);
+ }
+ {
+ std::vector<int> v(100);
+ while(v.size() < v.capacity()) v.push_back(0);
+ v.pop_back(); v.pop_back(); // force no reallocation
+ size_t sz = v.size();
+ std::vector<int>::iterator i = v.insert(v.cbegin() + 10, 1);
+ assert(v.size() == sz + 1);
+ assert(is_contiguous_container_asan_correct(v));
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == 0);
+ assert(v[j] == 1);
+ for (++j; j < v.size(); ++j)
+ assert(v[j] == 0);
+ }
+ {
+ std::vector<int, stack_allocator<int, 300> > v(100);
+ std::vector<int, stack_allocator<int, 300> >::iterator i = v.insert(v.cbegin() + 10, 1);
+ assert(v.size() == 101);
+ assert(is_contiguous_container_asan_correct(v));
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == 0);
+ assert(v[j] == 1);
+ for (++j; j < 101; ++j)
+ assert(v[j] == 0);
+ }
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::vector<int> v1(3);
+ std::vector<int> v2(3);
+ int i = 4;
+ v1.insert(v2.begin(), i);
+ assert(false);
+ }
+#endif
+#if __cplusplus >= 201103L
+ {
+ std::vector<int, min_allocator<int>> v(100);
+ std::vector<int, min_allocator<int>>::iterator i = v.insert(v.cbegin() + 10, 1);
+ assert(v.size() == 101);
+ assert(is_contiguous_container_asan_correct(v));
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == 0);
+ assert(v[j] == 1);
+ for (++j; j < 101; ++j)
+ assert(v[j] == 0);
+ }
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::vector<int, min_allocator<int>> v1(3);
+ std::vector<int, min_allocator<int>> v2(3);
+ int i = 4;
+ v1.insert(v2.begin(), i);
+ assert(false);
+ }
+#endif
+#endif
+}
diff --git a/test/std/containers/sequences/vector/vector.modifiers/pop_back.pass.cpp b/test/std/containers/sequences/vector/vector.modifiers/pop_back.pass.cpp
new file mode 100644
index 000000000000..62fa60103baa
--- /dev/null
+++ b/test/std/containers/sequences/vector/vector.modifiers/pop_back.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// void pop_back();
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <vector>
+#include <cassert>
+#include "../../../stack_allocator.h"
+#include "min_allocator.h"
+
+#if _LIBCPP_DEBUG >= 1
+#include <cstdlib>
+#include <exception>
+
+#endif
+
+int main()
+{
+ {
+ std::vector<int> c;
+ c.push_back(1);
+ assert(c.size() == 1);
+ c.pop_back();
+ assert(c.size() == 0);
+#if _LIBCPP_DEBUG >= 1
+ c.pop_back();
+ assert(false);
+#endif
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<int, min_allocator<int>> c;
+ c.push_back(1);
+ assert(c.size() == 1);
+ c.pop_back();
+ assert(c.size() == 0);
+#if _LIBCPP_DEBUG >= 1
+ c.pop_back();
+ assert(false);
+#endif
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/vector/vector.modifiers/push_back.pass.cpp b/test/std/containers/sequences/vector/vector.modifiers/push_back.pass.cpp
new file mode 100644
index 000000000000..eeeba6242d93
--- /dev/null
+++ b/test/std/containers/sequences/vector/vector.modifiers/push_back.pass.cpp
@@ -0,0 +1,108 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// void push_back(const value_type& x);
+
+#include <vector>
+#include <cassert>
+#include "../../../stack_allocator.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+ {
+ std::vector<int> c;
+ c.push_back(0);
+ assert(c.size() == 1);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == j);
+ c.push_back(1);
+ assert(c.size() == 2);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == j);
+ c.push_back(2);
+ assert(c.size() == 3);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == j);
+ c.push_back(3);
+ assert(c.size() == 4);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == j);
+ c.push_back(4);
+ assert(c.size() == 5);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == j);
+ }
+ {
+ std::vector<int, stack_allocator<int, 15> > c;
+ c.push_back(0);
+ assert(c.size() == 1);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == j);
+ c.push_back(1);
+ assert(c.size() == 2);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == j);
+ c.push_back(2);
+ assert(c.size() == 3);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == j);
+ c.push_back(3);
+ assert(c.size() == 4);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == j);
+ c.push_back(4);
+ assert(c.size() == 5);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == j);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<int, min_allocator<int>> c;
+ c.push_back(0);
+ assert(c.size() == 1);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == j);
+ c.push_back(1);
+ assert(c.size() == 2);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == j);
+ c.push_back(2);
+ assert(c.size() == 3);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == j);
+ c.push_back(3);
+ assert(c.size() == 4);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == j);
+ c.push_back(4);
+ assert(c.size() == 5);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == j);
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/vector/vector.modifiers/push_back_exception_safety.pass.cpp b/test/std/containers/sequences/vector/vector.modifiers/push_back_exception_safety.pass.cpp
new file mode 100644
index 000000000000..6615a25a620f
--- /dev/null
+++ b/test/std/containers/sequences/vector/vector.modifiers/push_back_exception_safety.pass.cpp
@@ -0,0 +1,86 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// void push_back(const value_type& x);
+
+#include <vector>
+#include <cassert>
+
+#include "asan_testing.h"
+
+// Flag that makes the copy constructor for CMyClass throw an exception
+static bool gCopyConstructorShouldThow = false;
+
+
+class CMyClass {
+ public: CMyClass(int tag);
+ public: CMyClass(const CMyClass& iOther);
+ public: ~CMyClass();
+
+ bool equal(const CMyClass &rhs) const
+ { return fTag == rhs.fTag && fMagicValue == rhs.fMagicValue; }
+ private:
+ int fMagicValue;
+ int fTag;
+
+ private: static int kStartedConstructionMagicValue;
+ private: static int kFinishedConstructionMagicValue;
+};
+
+// Value for fMagicValue when the constructor has started running, but not yet finished
+int CMyClass::kStartedConstructionMagicValue = 0;
+// Value for fMagicValue when the constructor has finished running
+int CMyClass::kFinishedConstructionMagicValue = 12345;
+
+CMyClass::CMyClass(int tag) :
+ fMagicValue(kStartedConstructionMagicValue), fTag(tag)
+{
+ // Signal that the constructor has finished running
+ fMagicValue = kFinishedConstructionMagicValue;
+}
+
+CMyClass::CMyClass(const CMyClass& iOther) :
+ fMagicValue(kStartedConstructionMagicValue), fTag(iOther.fTag)
+{
+ // If requested, throw an exception _before_ setting fMagicValue to kFinishedConstructionMagicValue
+ if (gCopyConstructorShouldThow) {
+ throw std::exception();
+ }
+ // Signal that the constructor has finished running
+ fMagicValue = kFinishedConstructionMagicValue;
+}
+
+CMyClass::~CMyClass() {
+ // Only instances for which the constructor has finished running should be destructed
+ assert(fMagicValue == kFinishedConstructionMagicValue);
+}
+
+bool operator==(const CMyClass &lhs, const CMyClass &rhs) { return lhs.equal(rhs); }
+
+int main()
+{
+ CMyClass instance(42);
+ std::vector<CMyClass> vec;
+
+ vec.push_back(instance);
+ std::vector<CMyClass> vec2(vec);
+ assert(is_contiguous_container_asan_correct(vec));
+ assert(is_contiguous_container_asan_correct(vec2));
+
+ gCopyConstructorShouldThow = true;
+ try {
+ vec.push_back(instance);
+ }
+ catch (...) {
+ assert(vec==vec2);
+ assert(is_contiguous_container_asan_correct(vec));
+ }
+}
diff --git a/test/std/containers/sequences/vector/vector.modifiers/push_back_rvalue.pass.cpp b/test/std/containers/sequences/vector/vector.modifiers/push_back_rvalue.pass.cpp
new file mode 100644
index 000000000000..b143cd773b42
--- /dev/null
+++ b/test/std/containers/sequences/vector/vector.modifiers/push_back_rvalue.pass.cpp
@@ -0,0 +1,111 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// void push_back(value_type&& x);
+
+#include <vector>
+#include <cassert>
+#include "MoveOnly.h"
+#include "../../../stack_allocator.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::vector<MoveOnly> c;
+ c.push_back(MoveOnly(0));
+ assert(c.size() == 1);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == MoveOnly(j));
+ c.push_back(MoveOnly(1));
+ assert(c.size() == 2);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == MoveOnly(j));
+ c.push_back(MoveOnly(2));
+ assert(c.size() == 3);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == MoveOnly(j));
+ c.push_back(MoveOnly(3));
+ assert(c.size() == 4);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == MoveOnly(j));
+ c.push_back(MoveOnly(4));
+ assert(c.size() == 5);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == MoveOnly(j));
+ }
+ {
+ std::vector<MoveOnly, stack_allocator<MoveOnly, 15> > c;
+ c.push_back(MoveOnly(0));
+ assert(c.size() == 1);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == MoveOnly(j));
+ c.push_back(MoveOnly(1));
+ assert(c.size() == 2);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == MoveOnly(j));
+ c.push_back(MoveOnly(2));
+ assert(c.size() == 3);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == MoveOnly(j));
+ c.push_back(MoveOnly(3));
+ assert(c.size() == 4);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == MoveOnly(j));
+ c.push_back(MoveOnly(4));
+ assert(c.size() == 5);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == MoveOnly(j));
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<MoveOnly, min_allocator<MoveOnly>> c;
+ c.push_back(MoveOnly(0));
+ assert(c.size() == 1);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == MoveOnly(j));
+ c.push_back(MoveOnly(1));
+ assert(c.size() == 2);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == MoveOnly(j));
+ c.push_back(MoveOnly(2));
+ assert(c.size() == 3);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == MoveOnly(j));
+ c.push_back(MoveOnly(3));
+ assert(c.size() == 4);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == MoveOnly(j));
+ c.push_back(MoveOnly(4));
+ assert(c.size() == 5);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == MoveOnly(j));
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/sequences/vector/vector.special/db_swap_1.pass.cpp b/test/std/containers/sequences/vector/vector.special/db_swap_1.pass.cpp
new file mode 100644
index 000000000000..e7f6a0011e1a
--- /dev/null
+++ b/test/std/containers/sequences/vector/vector.special/db_swap_1.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// template <class T, class Alloc>
+// void swap(vector<T,Alloc>& x, vector<T,Alloc>& y);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#if _LIBCPP_DEBUG >= 1
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ std::vector<int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ std::vector<int> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+ std::vector<int>::iterator i1 = c1.begin();
+ std::vector<int>::iterator i2 = c2.begin();
+ swap(c1, c2);
+ c1.erase(i2);
+ c2.erase(i1);
+ c1.erase(i1);
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ std::vector<int, min_allocator<int>> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ std::vector<int, min_allocator<int>> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+ std::vector<int, min_allocator<int>>::iterator i1 = c1.begin();
+ std::vector<int, min_allocator<int>>::iterator i2 = c2.begin();
+ swap(c1, c2);
+ c1.erase(i2);
+ c2.erase(i1);
+ c1.erase(i1);
+ assert(false);
+ }
+#endif
+#endif
+}
diff --git a/test/std/containers/sequences/vector/vector.special/swap.pass.cpp b/test/std/containers/sequences/vector/vector.special/swap.pass.cpp
new file mode 100644
index 000000000000..96aaf7131f53
--- /dev/null
+++ b/test/std/containers/sequences/vector/vector.special/swap.pass.cpp
@@ -0,0 +1,188 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// template <class T, class Alloc>
+// void swap(vector<T,Alloc>& x, vector<T,Alloc>& y);
+
+#include <vector>
+#include <iterator>
+#include <cassert>
+#include "test_allocator.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ std::vector<int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ std::vector<int> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+ assert(is_contiguous_container_asan_correct(c1));
+ assert(is_contiguous_container_asan_correct(c2));
+ swap(c1, c2);
+ assert(c1 == std::vector<int>(a2, a2+sizeof(a2)/sizeof(a2[0])));
+ assert(c2 == std::vector<int>(a1, a1+sizeof(a1)/sizeof(a1[0])));
+ assert(is_contiguous_container_asan_correct(c1));
+ assert(is_contiguous_container_asan_correct(c2));
+ }
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ std::vector<int> c1(a1, a1);
+ std::vector<int> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+ assert(is_contiguous_container_asan_correct(c1));
+ assert(is_contiguous_container_asan_correct(c2));
+ swap(c1, c2);
+ assert(c1 == std::vector<int>(a2, a2+sizeof(a2)/sizeof(a2[0])));
+ assert(c2.empty());
+ assert(distance(c2.begin(), c2.end()) == 0);
+ assert(is_contiguous_container_asan_correct(c1));
+ assert(is_contiguous_container_asan_correct(c2));
+ }
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ std::vector<int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ std::vector<int> c2(a2, a2);
+ assert(is_contiguous_container_asan_correct(c1));
+ assert(is_contiguous_container_asan_correct(c2));
+ swap(c1, c2);
+ assert(c1.empty());
+ assert(distance(c1.begin(), c1.end()) == 0);
+ assert(c2 == std::vector<int>(a1, a1+sizeof(a1)/sizeof(a1[0])));
+ assert(is_contiguous_container_asan_correct(c1));
+ assert(is_contiguous_container_asan_correct(c2));
+ }
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ std::vector<int> c1(a1, a1);
+ std::vector<int> c2(a2, a2);
+ assert(is_contiguous_container_asan_correct(c1));
+ assert(is_contiguous_container_asan_correct(c2));
+ swap(c1, c2);
+ assert(c1.empty());
+ assert(distance(c1.begin(), c1.end()) == 0);
+ assert(c2.empty());
+ assert(distance(c2.begin(), c2.end()) == 0);
+ assert(is_contiguous_container_asan_correct(c1));
+ assert(is_contiguous_container_asan_correct(c2));
+ }
+#ifndef _LIBCPP_DEBUG_LEVEL
+// This test known to result in undefined behavior detected by _LIBCPP_DEBUG_LEVEL >= 1
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ typedef test_allocator<int> A;
+ std::vector<int, A> c1(a1, a1+sizeof(a1)/sizeof(a1[0]), A(1));
+ std::vector<int, A> c2(a2, a2+sizeof(a2)/sizeof(a2[0]), A(2));
+ swap(c1, c2);
+ assert((c1 == std::vector<int, A>(a2, a2+sizeof(a2)/sizeof(a2[0]))));
+ assert(c1.get_allocator() == A(1));
+ assert((c2 == std::vector<int, A>(a1, a1+sizeof(a1)/sizeof(a1[0]))));
+ assert(c2.get_allocator() == A(2));
+ }
+#endif
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ typedef other_allocator<int> A;
+ std::vector<int, A> c1(a1, a1+sizeof(a1)/sizeof(a1[0]), A(1));
+ std::vector<int, A> c2(a2, a2+sizeof(a2)/sizeof(a2[0]), A(2));
+ assert(is_contiguous_container_asan_correct(c1));
+ assert(is_contiguous_container_asan_correct(c2));
+ swap(c1, c2);
+ assert((c1 == std::vector<int, A>(a2, a2+sizeof(a2)/sizeof(a2[0]))));
+ assert(c1.get_allocator() == A(2));
+ assert((c2 == std::vector<int, A>(a1, a1+sizeof(a1)/sizeof(a1[0]))));
+ assert(c2.get_allocator() == A(1));
+ assert(is_contiguous_container_asan_correct(c1));
+ assert(is_contiguous_container_asan_correct(c2));
+ }
+#if __cplusplus >= 201103L
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ std::vector<int, min_allocator<int>> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ std::vector<int, min_allocator<int>> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+ assert(is_contiguous_container_asan_correct(c1));
+ assert(is_contiguous_container_asan_correct(c2));
+ swap(c1, c2);
+ assert((c1 == std::vector<int, min_allocator<int>>(a2, a2+sizeof(a2)/sizeof(a2[0]))));
+ assert((c2 == std::vector<int, min_allocator<int>>(a1, a1+sizeof(a1)/sizeof(a1[0]))));
+ assert(is_contiguous_container_asan_correct(c1));
+ assert(is_contiguous_container_asan_correct(c2));
+ }
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ std::vector<int, min_allocator<int>> c1(a1, a1);
+ std::vector<int, min_allocator<int>> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+ assert(is_contiguous_container_asan_correct(c1));
+ assert(is_contiguous_container_asan_correct(c2));
+ swap(c1, c2);
+ assert((c1 == std::vector<int, min_allocator<int>>(a2, a2+sizeof(a2)/sizeof(a2[0]))));
+ assert(c2.empty());
+ assert(distance(c2.begin(), c2.end()) == 0);
+ assert(is_contiguous_container_asan_correct(c1));
+ assert(is_contiguous_container_asan_correct(c2));
+ }
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ std::vector<int, min_allocator<int>> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ std::vector<int, min_allocator<int>> c2(a2, a2);
+ assert(is_contiguous_container_asan_correct(c1));
+ assert(is_contiguous_container_asan_correct(c2));
+ swap(c1, c2);
+ assert(c1.empty());
+ assert(distance(c1.begin(), c1.end()) == 0);
+ assert((c2 == std::vector<int, min_allocator<int>>(a1, a1+sizeof(a1)/sizeof(a1[0]))));
+ assert(is_contiguous_container_asan_correct(c1));
+ assert(is_contiguous_container_asan_correct(c2));
+ }
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ std::vector<int, min_allocator<int>> c1(a1, a1);
+ std::vector<int, min_allocator<int>> c2(a2, a2);
+ assert(is_contiguous_container_asan_correct(c1));
+ assert(is_contiguous_container_asan_correct(c2));
+ swap(c1, c2);
+ assert(c1.empty());
+ assert(distance(c1.begin(), c1.end()) == 0);
+ assert(c2.empty());
+ assert(distance(c2.begin(), c2.end()) == 0);
+ assert(is_contiguous_container_asan_correct(c1));
+ assert(is_contiguous_container_asan_correct(c2));
+ }
+#ifndef _LIBCPP_DEBUG_LEVEL
+// This test known to result in undefined behavior detected by _LIBCPP_DEBUG_LEVEL >= 1
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ typedef min_allocator<int> A;
+ std::vector<int, A> c1(a1, a1+sizeof(a1)/sizeof(a1[0]), A());
+ std::vector<int, A> c2(a2, a2+sizeof(a2)/sizeof(a2[0]), A());
+ assert(is_contiguous_container_asan_correct(c1));
+ assert(is_contiguous_container_asan_correct(c2));
+ swap(c1, c2);
+ assert((c1 == std::vector<int, A>(a2, a2+sizeof(a2)/sizeof(a2[0]))));
+ assert(c1.get_allocator() == A());
+ assert((c2 == std::vector<int, A>(a1, a1+sizeof(a1)/sizeof(a1[0]))));
+ assert(c2.get_allocator() == A());
+ assert(is_contiguous_container_asan_correct(c1));
+ assert(is_contiguous_container_asan_correct(c2));
+ }
+#endif
+#endif
+}
diff --git a/test/std/containers/sequences/vector/vector.special/swap_noexcept.pass.cpp b/test/std/containers/sequences/vector/vector.special/swap_noexcept.pass.cpp
new file mode 100644
index 000000000000..1d00ff387480
--- /dev/null
+++ b/test/std/containers/sequences/vector/vector.special/swap_noexcept.pass.cpp
@@ -0,0 +1,91 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// void swap(vector& c)
+// noexcept(!allocator_type::propagate_on_container_swap::value ||
+// __is_nothrow_swappable<allocator_type>::value);
+//
+// In C++17, the standard says that swap shall have:
+// noexcept(allocator_traits<Allocator>::propagate_on_container_swap::value ||
+// allocator_traits<Allocator>::is_always_equal::value);
+
+// This tests a conforming extension
+
+#include <vector>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_alloc
+{
+ typedef T value_type;
+
+ some_alloc() {}
+ some_alloc(const some_alloc&);
+ void deallocate(void*, unsigned) {}
+
+ typedef std::true_type propagate_on_container_swap;
+};
+
+template <class T>
+struct some_alloc2
+{
+ typedef T value_type;
+
+ some_alloc2() {}
+ some_alloc2(const some_alloc2&);
+ void deallocate(void*, unsigned) {}
+
+ typedef std::false_type propagate_on_container_swap;
+ typedef std::true_type is_always_equal;
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::vector<MoveOnly> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::vector<MoveOnly, test_allocator<MoveOnly>> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::vector<MoveOnly, other_allocator<MoveOnly>> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::vector<MoveOnly, some_alloc<MoveOnly>> C;
+ C c1, c2;
+#if TEST_STD_VER >= 14
+ // In c++14, if POCS is set, swapping the allocator is required not to throw
+ static_assert( noexcept(swap(c1, c2)), "");
+#else
+ static_assert(!noexcept(swap(c1, c2)), "");
+#endif
+ }
+#if TEST_STD_VER >= 14
+ {
+ typedef std::vector<MoveOnly, some_alloc2<MoveOnly>> C;
+ C c1, c2;
+ // if the allocators are always equal, then the swap can be noexcept
+ static_assert( noexcept(swap(c1, c2)), "");
+ }
+#endif
+
+#endif
+}
diff --git a/test/std/containers/sequences/vector/version.pass.cpp b/test/std/containers/sequences/vector/version.pass.cpp
new file mode 100644
index 000000000000..2c4fa1263de3
--- /dev/null
+++ b/test/std/containers/sequences/vector/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+#include <vector>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/containers/stack_allocator.h b/test/std/containers/stack_allocator.h
new file mode 100644
index 000000000000..d5fab025c9d0
--- /dev/null
+++ b/test/std/containers/stack_allocator.h
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef STACK_ALLOCATOR_H
+#define STACK_ALLOCATOR_H
+
+#include <cstddef>
+#include <new>
+
+template <class T, std::size_t N>
+class stack_allocator
+{
+ char buf_[sizeof(T)*N];
+ char* ptr_;
+public:
+ typedef T value_type;
+ typedef value_type* pointer;
+ typedef const value_type* const_pointer;
+ typedef value_type& reference;
+ typedef const value_type& const_reference;
+ typedef std::size_t size_type;
+ typedef std::ptrdiff_t difference_type;
+
+ template <class U> struct rebind {typedef stack_allocator<U, N> other;};
+
+ stack_allocator() : ptr_(buf_) {}
+
+private:
+ stack_allocator(const stack_allocator&);// = delete;
+ stack_allocator& operator=(const stack_allocator&);// = delete;
+
+public:
+ pointer allocate(size_type n, const void* = 0)
+ {
+ if (n > N - (ptr_ - buf_) / sizeof(value_type)) {
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ throw std::bad_alloc();
+#else
+ std::terminate();
+#endif
+ }
+ pointer r = (T*)ptr_;
+ ptr_ += n * sizeof(T);
+ return r;
+ }
+ void deallocate(pointer p, size_type n)
+ {
+ if ((char*)(p + n) == ptr_)
+ ptr_ = (char*)p;
+ }
+
+ size_type max_size() const {return N;}
+};
+
+template <class T, std::size_t N>
+inline
+void
+swap(stack_allocator<T, N>& x, stack_allocator<T, N>& y) {}
+
+#endif // STACK_ALLOCATOR_H
diff --git a/test/std/containers/test_compare.h b/test/std/containers/test_compare.h
new file mode 100644
index 000000000000..9c54799172e0
--- /dev/null
+++ b/test/std/containers/test_compare.h
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef TEST_COMPARE_H
+#define TEST_COMPARE_H
+
+#include <cstddef>
+#include <type_traits>
+#include <cstdlib>
+#include <new>
+#include <climits>
+
+template <class C>
+class test_compare
+ : private C
+{
+ int data_;
+public:
+ explicit test_compare(int data = 0) : data_(data) {}
+
+ typename C::result_type
+ operator()(typename std::add_lvalue_reference<const typename C::first_argument_type>::type x,
+ typename std::add_lvalue_reference<const typename C::second_argument_type>::type y) const
+ {return C::operator()(x, y);}
+
+ bool operator==(const test_compare& c) const
+ {return data_ == c.data_;}
+};
+
+#endif // TEST_COMPARE_H
diff --git a/test/std/containers/test_hash.h b/test/std/containers/test_hash.h
new file mode 100644
index 000000000000..1a70e7cbdd9a
--- /dev/null
+++ b/test/std/containers/test_hash.h
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef TEST_HASH_H
+#define TEST_HASH_H
+
+#include <cstddef>
+#include <type_traits>
+
+template <class C>
+class test_hash
+ : private C
+{
+ int data_;
+public:
+ explicit test_hash(int data = 0) : data_(data) {}
+
+ std::size_t
+ operator()(typename std::add_lvalue_reference<const typename C::argument_type>::type x) const
+ {return C::operator()(x);}
+
+ bool operator==(const test_hash& c) const
+ {return data_ == c.data_;}
+};
+
+#endif // TEST_HASH_H
diff --git a/test/std/containers/unord/next_prime.pass.cpp b/test/std/containers/unord/next_prime.pass.cpp
new file mode 100644
index 000000000000..266d7f1f9d1e
--- /dev/null
+++ b/test/std/containers/unord/next_prime.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// REQUIRES: long_tests
+
+// Not a portable test
+
+// <__hash_table>
+
+// size_t __next_prime(size_t n);
+
+// If n == 0, return 0, else return the lowest prime greater than or equal to n
+
+#include <__hash_table>
+#include <cassert>
+
+bool
+is_prime(size_t n)
+{
+ switch (n)
+ {
+ case 0:
+ case 1:
+ return false;
+ }
+ for (size_t i = 2; i*i <= n; ++i)
+ {
+ if (n % i == 0)
+ return false;
+ }
+ return true;
+}
+
+int main()
+{
+ assert(std::__next_prime(0) == 0);
+ for (std::size_t n = 1; n <= 100000; ++n)
+ {
+ std::size_t p = std::__next_prime(n);
+ assert(p >= n);
+ for (std::size_t i = n; i < p; ++i)
+ assert(!is_prime(i));
+ assert(is_prime(p));
+ }
+}
diff --git a/test/std/containers/unord/unord.map/bucket.pass.cpp b/test/std/containers/unord/unord.map/bucket.pass.cpp
new file mode 100644
index 000000000000..6837294e35bc
--- /dev/null
+++ b/test/std/containers/unord/unord.map/bucket.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// size_type bucket(const key_type& __k) const;
+
+#ifdef _LIBCPP_DEBUG
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ const C c(std::begin(a), std::end(a));
+ size_t bc = c.bucket_count();
+ assert(bc >= 5);
+ for (size_t i = 0; i < 13; ++i)
+ assert(c.bucket(i) == i % bc);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ const C c(std::begin(a), std::end(a));
+ size_t bc = c.bucket_count();
+ assert(bc >= 5);
+ for (size_t i = 0; i < 13; ++i)
+ assert(c.bucket(i) == i % bc);
+ }
+#endif
+#if _LIBCPP_DEBUG_LEVEL >= 1
+ {
+ typedef std::unordered_map<int, std::string> C;
+ C c;
+ C::size_type i = c.bucket(3);
+ assert(false);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.map/bucket_count.pass.cpp b/test/std/containers/unord/unord.map/bucket_count.pass.cpp
new file mode 100644
index 000000000000..d3e80d86379a
--- /dev/null
+++ b/test/std/containers/unord/unord.map/bucket_count.pass.cpp
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// size_type bucket_count() const;
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef C::const_iterator I;
+ typedef std::pair<int, std::string> P;
+ const C c;
+ assert(c.bucket_count() == 0);
+ }
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef C::const_iterator I;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ const C c(std::begin(a), std::end(a));
+ assert(c.bucket_count() >= 11);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef C::const_iterator I;
+ typedef std::pair<int, std::string> P;
+ const C c;
+ assert(c.bucket_count() == 0);
+ }
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef C::const_iterator I;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ const C c(std::begin(a), std::end(a));
+ assert(c.bucket_count() >= 11);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.map/bucket_size.pass.cpp b/test/std/containers/unord/unord.map/bucket_size.pass.cpp
new file mode 100644
index 000000000000..f3ab8fff4e43
--- /dev/null
+++ b/test/std/containers/unord/unord.map/bucket_size.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// size_type bucket_size(size_type n) const
+
+#ifdef _LIBCPP_DEBUG
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ const C c(std::begin(a), std::end(a));
+ assert(c.bucket_count() >= 5);
+ assert(c.bucket_size(0) == 0);
+ assert(c.bucket_size(1) == 1);
+ assert(c.bucket_size(2) == 1);
+ assert(c.bucket_size(3) == 1);
+ assert(c.bucket_size(4) == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ const C c(std::begin(a), std::end(a));
+ assert(c.bucket_count() >= 5);
+ assert(c.bucket_size(0) == 0);
+ assert(c.bucket_size(1) == 1);
+ assert(c.bucket_size(2) == 1);
+ assert(c.bucket_size(3) == 1);
+ assert(c.bucket_size(4) == 1);
+ }
+#endif
+#if _LIBCPP_DEBUG_LEVEL >= 1
+ {
+ typedef std::unordered_map<int, std::string> C;
+ C c;
+ C::size_type i = c.bucket_size(3);
+ assert(false);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.map/compare.pass.cpp b/test/std/containers/unord/unord.map/compare.pass.cpp
new file mode 100644
index 000000000000..8979a3a34ad6
--- /dev/null
+++ b/test/std/containers/unord/unord.map/compare.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// http://llvm.org/bugs/show_bug.cgi?id=16538
+// http://llvm.org/bugs/show_bug.cgi?id=16549
+
+#include <unordered_map>
+
+struct Key {
+ template <typename T> Key(const T&) {}
+ bool operator== (const Key&) const { return true; }
+};
+
+namespace std
+{
+ template <>
+ struct hash<Key>
+ {
+ size_t operator()(Key const &) const {return 0;}
+ };
+}
+
+int
+main()
+{
+ std::unordered_map<Key, int>::iterator it =
+ std::unordered_map<Key, int>().find(Key(0));
+ std::pair<std::unordered_map<Key, int>::iterator, bool> result =
+ std::unordered_map<Key, int>().insert(std::make_pair(Key(0), 0));
+}
diff --git a/test/std/containers/unord/unord.map/count.pass.cpp b/test/std/containers/unord/unord.map/count.pass.cpp
new file mode 100644
index 000000000000..50abb53464ec
--- /dev/null
+++ b/test/std/containers/unord/unord.map/count.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// size_type count(const key_type& k) const;
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ const C c(std::begin(a), std::end(a));
+ assert(c.count(30) == 1);
+ assert(c.count(5) == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ const C c(std::begin(a), std::end(a));
+ assert(c.count(30) == 1);
+ assert(c.count(5) == 0);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.map/db_iterators_7.pass.cpp b/test/std/containers/unord/unord.map/db_iterators_7.pass.cpp
new file mode 100644
index 000000000000..b8db0a35ffc3
--- /dev/null
+++ b/test/std/containers/unord/unord.map/db_iterators_7.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Increment iterator past end.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ C c;
+ c.insert(std::make_pair(1, "one"));
+ C::iterator i = c.begin();
+ ++i;
+ assert(i == c.end());
+ ++i;
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ C c;
+ c.insert(std::make_pair(1, "one"));
+ C::iterator i = c.begin();
+ ++i;
+ assert(i == c.end());
+ ++i;
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/containers/unord/unord.map/db_iterators_8.pass.cpp b/test/std/containers/unord/unord.map/db_iterators_8.pass.cpp
new file mode 100644
index 000000000000..c923dd77862e
--- /dev/null
+++ b/test/std/containers/unord/unord.map/db_iterators_8.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Dereference non-dereferenceable iterator.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ C c;
+ c.insert(std::make_pair(1, "one"));
+ C::iterator i = c.end();
+ C::value_type j = *i;
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ C c;
+ c.insert(std::make_pair(1, "one"));
+ C::iterator i = c.end();
+ C::value_type j = *i;
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/containers/unord/unord.map/db_local_iterators_7.pass.cpp b/test/std/containers/unord/unord.map/db_local_iterators_7.pass.cpp
new file mode 100644
index 000000000000..fa1886bfff18
--- /dev/null
+++ b/test/std/containers/unord/unord.map/db_local_iterators_7.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Increment local_iterator past end.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ C c(1);
+ C::local_iterator i = c.begin(0);
+ ++i;
+ ++i;
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ C c(1);
+ C::local_iterator i = c.begin(0);
+ ++i;
+ ++i;
+ assert(false);
+ }
+#endif
+
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/containers/unord/unord.map/db_local_iterators_8.pass.cpp b/test/std/containers/unord/unord.map/db_local_iterators_8.pass.cpp
new file mode 100644
index 000000000000..4b071cad7b47
--- /dev/null
+++ b/test/std/containers/unord/unord.map/db_local_iterators_8.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Dereference non-dereferenceable iterator.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ C c(1);
+ C::local_iterator i = c.end(0);
+ C::value_type j = *i;
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ C c(1);
+ C::local_iterator i = c.end(0);
+ C::value_type j = *i;
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/containers/unord/unord.map/eq.pass.cpp b/test/std/containers/unord/unord.map/eq.pass.cpp
new file mode 100644
index 000000000000..9258378eb09a
--- /dev/null
+++ b/test/std/containers/unord/unord.map/eq.pass.cpp
@@ -0,0 +1,163 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash, class Pred, class Alloc>
+// bool
+// operator==(const unordered_map<Key, T, Hash, Pred, Alloc>& x,
+// const unordered_map<Key, T, Hash, Pred, Alloc>& y);
+//
+// template <class Key, class T, class Hash, class Pred, class Alloc>
+// bool
+// operator!=(const unordered_map<Key, T, Hash, Pred, Alloc>& x,
+// const unordered_map<Key, T, Hash, Pred, Alloc>& y);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ const C c1(std::begin(a), std::end(a));
+ const C c2;
+ assert(!(c1 == c2));
+ assert( (c1 != c2));
+ }
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ const C c1(std::begin(a), std::end(a));
+ const C c2 = c1;
+ assert( (c1 == c2));
+ assert(!(c1 != c2));
+ }
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c1(std::begin(a), std::end(a));
+ C c2 = c1;
+ c2.rehash(30);
+ assert( (c1 == c2));
+ assert(!(c1 != c2));
+ c2.insert(P(90, "ninety"));
+ assert(!(c1 == c2));
+ assert( (c1 != c2));
+ c1.insert(P(90, "ninety"));
+ assert( (c1 == c2));
+ assert(!(c1 != c2));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ const C c1(std::begin(a), std::end(a));
+ const C c2;
+ assert(!(c1 == c2));
+ assert( (c1 != c2));
+ }
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ const C c1(std::begin(a), std::end(a));
+ const C c2 = c1;
+ assert( (c1 == c2));
+ assert(!(c1 != c2));
+ }
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c1(std::begin(a), std::end(a));
+ C c2 = c1;
+ c2.rehash(30);
+ assert( (c1 == c2));
+ assert(!(c1 != c2));
+ c2.insert(P(90, "ninety"));
+ assert(!(c1 == c2));
+ assert( (c1 != c2));
+ c1.insert(P(90, "ninety"));
+ assert( (c1 == c2));
+ assert(!(c1 != c2));
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.map/equal_range_const.pass.cpp b/test/std/containers/unord/unord.map/equal_range_const.pass.cpp
new file mode 100644
index 000000000000..fe166c965b16
--- /dev/null
+++ b/test/std/containers/unord/unord.map/equal_range_const.pass.cpp
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef C::const_iterator I;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ const C c(std::begin(a), std::end(a));
+ std::pair<I, I> r = c.equal_range(30);
+ assert(std::distance(r.first, r.second) == 1);
+ assert(r.first->first == 30);
+ assert(r.first->second == "thirty");
+ r = c.equal_range(5);
+ assert(std::distance(r.first, r.second) == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef C::const_iterator I;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ const C c(std::begin(a), std::end(a));
+ std::pair<I, I> r = c.equal_range(30);
+ assert(std::distance(r.first, r.second) == 1);
+ assert(r.first->first == 30);
+ assert(r.first->second == "thirty");
+ r = c.equal_range(5);
+ assert(std::distance(r.first, r.second) == 0);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.map/equal_range_non_const.pass.cpp b/test/std/containers/unord/unord.map/equal_range_non_const.pass.cpp
new file mode 100644
index 000000000000..9e8d1a9644c5
--- /dev/null
+++ b/test/std/containers/unord/unord.map/equal_range_non_const.pass.cpp
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// pair<iterator, iterator> equal_range(const key_type& k);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef C::iterator I;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c(std::begin(a), std::end(a));
+ std::pair<I, I> r = c.equal_range(30);
+ assert(std::distance(r.first, r.second) == 1);
+ assert(r.first->first == 30);
+ assert(r.first->second == "thirty");
+ r = c.equal_range(5);
+ assert(std::distance(r.first, r.second) == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef C::iterator I;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c(std::begin(a), std::end(a));
+ std::pair<I, I> r = c.equal_range(30);
+ assert(std::distance(r.first, r.second) == 1);
+ assert(r.first->first == 30);
+ assert(r.first->second == "thirty");
+ r = c.equal_range(5);
+ assert(std::distance(r.first, r.second) == 0);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.map/find_const.pass.cpp b/test/std/containers/unord/unord.map/find_const.pass.cpp
new file mode 100644
index 000000000000..120efa3061b1
--- /dev/null
+++ b/test/std/containers/unord/unord.map/find_const.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// const_iterator find(const key_type& k) const;
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ const C c(std::begin(a), std::end(a));
+ C::const_iterator i = c.find(30);
+ assert(i->first == 30);
+ assert(i->second == "thirty");
+ i = c.find(5);
+ assert(i == c.cend());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ const C c(std::begin(a), std::end(a));
+ C::const_iterator i = c.find(30);
+ assert(i->first == 30);
+ assert(i->second == "thirty");
+ i = c.find(5);
+ assert(i == c.cend());
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.map/find_non_const.pass.cpp b/test/std/containers/unord/unord.map/find_non_const.pass.cpp
new file mode 100644
index 000000000000..7582a796dd7c
--- /dev/null
+++ b/test/std/containers/unord/unord.map/find_non_const.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// iterator find(const key_type& k);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c(std::begin(a), std::end(a));
+ C::iterator i = c.find(30);
+ assert(i->first == 30);
+ assert(i->second == "thirty");
+ i = c.find(5);
+ assert(i == c.end());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c(std::begin(a), std::end(a));
+ C::iterator i = c.find(30);
+ assert(i->first == 30);
+ assert(i->second == "thirty");
+ i = c.find(5);
+ assert(i == c.end());
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.map/iterators.pass.cpp b/test/std/containers/unord/unord.map/iterators.pass.cpp
new file mode 100644
index 000000000000..47b1d7386684
--- /dev/null
+++ b/test/std/containers/unord/unord.map/iterators.pass.cpp
@@ -0,0 +1,128 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// iterator begin() {return __table_.begin();}
+// iterator end() {return __table_.end();}
+// const_iterator begin() const {return __table_.begin();}
+// const_iterator end() const {return __table_.end();}
+// const_iterator cbegin() const {return __table_.begin();}
+// const_iterator cend() const {return __table_.end();}
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 5);
+ assert(c.size() == 4);
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ C::iterator i;
+ }
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 5);
+ assert(c.size() == 4);
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ C::const_iterator i;
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 5);
+ assert(c.size() == 4);
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ C::iterator i;
+ }
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 5);
+ assert(c.size() == 4);
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ C::const_iterator i;
+ }
+#endif
+#if _LIBCPP_STD_VER > 11
+ { // N3644 testing
+ typedef std::unordered_map<int,double> C;
+ C::iterator ii1{}, ii2{};
+ C::iterator ii4 = ii1;
+ C::const_iterator cii{};
+ assert ( ii1 == ii2 );
+ assert ( ii1 == ii4 );
+
+ assert (!(ii1 != ii2 ));
+
+ assert ( (ii1 == cii ));
+ assert ( (cii == ii1 ));
+ assert (!(ii1 != cii ));
+ assert (!(cii != ii1 ));
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.map/load_factor.pass.cpp b/test/std/containers/unord/unord.map/load_factor.pass.cpp
new file mode 100644
index 000000000000..472e41abf6e0
--- /dev/null
+++ b/test/std/containers/unord/unord.map/load_factor.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// float load_factor() const
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ const C c(std::begin(a), std::end(a));
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ }
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ const C c;
+ assert(c.load_factor() == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ const C c(std::begin(a), std::end(a));
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ }
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ const C c;
+ assert(c.load_factor() == 0);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.map/local_iterators.pass.cpp b/test/std/containers/unord/unord.map/local_iterators.pass.cpp
new file mode 100644
index 000000000000..770b1ace7a3e
--- /dev/null
+++ b/test/std/containers/unord/unord.map/local_iterators.pass.cpp
@@ -0,0 +1,421 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// local_iterator begin (size_type n);
+// local_iterator end (size_type n);
+// const_local_iterator begin (size_type n) const;
+// const_local_iterator end (size_type n) const;
+// const_local_iterator cbegin(size_type n) const;
+// const_local_iterator cend (size_type n) const;
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ typedef C::local_iterator I;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 5);
+ C::size_type b = c.bucket(0);
+ I i = c.begin(b);
+ I j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 1);
+ assert(i->second == "one");
+
+ b = c.bucket(2);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 2);
+ assert(i->second == "two");
+
+ b = c.bucket(3);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 3);
+ assert(i->second == "three");
+
+ b = c.bucket(4);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 4);
+ assert(i->second == "four");
+ }
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ typedef C::const_local_iterator I;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 5);
+ C::size_type b = c.bucket(0);
+ I i = c.begin(b);
+ I j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 1);
+ assert(i->second == "one");
+
+ b = c.bucket(2);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 2);
+ assert(i->second == "two");
+
+ b = c.bucket(3);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 3);
+ assert(i->second == "three");
+
+ b = c.bucket(4);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 4);
+ assert(i->second == "four");
+ }
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ typedef C::const_local_iterator I;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 5);
+ C::size_type b = c.bucket(0);
+ I i = c.cbegin(b);
+ I j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 1);
+ assert(i->second == "one");
+
+ b = c.bucket(2);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 2);
+ assert(i->second == "two");
+
+ b = c.bucket(3);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 3);
+ assert(i->second == "three");
+
+ b = c.bucket(4);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 4);
+ assert(i->second == "four");
+ }
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ typedef C::const_local_iterator I;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 5);
+ C::size_type b = c.bucket(0);
+ I i = c.cbegin(b);
+ I j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 1);
+ assert(i->second == "one");
+
+ b = c.bucket(2);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 2);
+ assert(i->second == "two");
+
+ b = c.bucket(3);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 3);
+ assert(i->second == "three");
+
+ b = c.bucket(4);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 4);
+ assert(i->second == "four");
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ typedef C::local_iterator I;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 5);
+ C::size_type b = c.bucket(0);
+ I i = c.begin(b);
+ I j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 1);
+ assert(i->second == "one");
+
+ b = c.bucket(2);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 2);
+ assert(i->second == "two");
+
+ b = c.bucket(3);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 3);
+ assert(i->second == "three");
+
+ b = c.bucket(4);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 4);
+ assert(i->second == "four");
+ }
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ typedef C::const_local_iterator I;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 5);
+ C::size_type b = c.bucket(0);
+ I i = c.begin(b);
+ I j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 1);
+ assert(i->second == "one");
+
+ b = c.bucket(2);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 2);
+ assert(i->second == "two");
+
+ b = c.bucket(3);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 3);
+ assert(i->second == "three");
+
+ b = c.bucket(4);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 4);
+ assert(i->second == "four");
+ }
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ typedef C::const_local_iterator I;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 5);
+ C::size_type b = c.bucket(0);
+ I i = c.cbegin(b);
+ I j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 1);
+ assert(i->second == "one");
+
+ b = c.bucket(2);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 2);
+ assert(i->second == "two");
+
+ b = c.bucket(3);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 3);
+ assert(i->second == "three");
+
+ b = c.bucket(4);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 4);
+ assert(i->second == "four");
+ }
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ typedef C::const_local_iterator I;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 5);
+ C::size_type b = c.bucket(0);
+ I i = c.cbegin(b);
+ I j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 1);
+ assert(i->second == "one");
+
+ b = c.bucket(2);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 2);
+ assert(i->second == "two");
+
+ b = c.bucket(3);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 3);
+ assert(i->second == "three");
+
+ b = c.bucket(4);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 4);
+ assert(i->second == "four");
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.map/max_bucket_count.pass.cpp b/test/std/containers/unord/unord.map/max_bucket_count.pass.cpp
new file mode 100644
index 000000000000..b4ca8eb04472
--- /dev/null
+++ b/test/std/containers/unord/unord.map/max_bucket_count.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// size_type max_bucket_count() const;
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef C::const_iterator I;
+ typedef std::pair<int, std::string> P;
+ const C c;
+ assert(c.max_bucket_count() > 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef C::const_iterator I;
+ typedef std::pair<int, std::string> P;
+ const C c;
+ assert(c.max_bucket_count() > 0);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.map/max_load_factor.pass.cpp b/test/std/containers/unord/unord.map/max_load_factor.pass.cpp
new file mode 100644
index 000000000000..69fd70d2a172
--- /dev/null
+++ b/test/std/containers/unord/unord.map/max_load_factor.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// float max_load_factor() const;
+// void max_load_factor(float mlf);
+
+#ifdef _LIBCPP_DEBUG
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ const C c;
+ assert(c.max_load_factor() == 1);
+ }
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ C c;
+ assert(c.max_load_factor() == 1);
+ c.max_load_factor(2.5);
+ assert(c.max_load_factor() == 2.5);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ const C c;
+ assert(c.max_load_factor() == 1);
+ }
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ C c;
+ assert(c.max_load_factor() == 1);
+ c.max_load_factor(2.5);
+ assert(c.max_load_factor() == 2.5);
+ }
+#endif
+#if _LIBCPP_DEBUG_LEVEL >= 1
+ {
+ typedef std::unordered_map<int, std::string> C;
+ C c;
+ c.max_load_factor(0);
+ assert(false);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.map/max_size.pass.cpp b/test/std/containers/unord/unord.map/max_size.pass.cpp
new file mode 100644
index 000000000000..7d5ae3a8e46d
--- /dev/null
+++ b/test/std/containers/unord/unord.map/max_size.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// size_type max_size() const;
+
+#include <unordered_map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::unordered_map<int, int> u;
+ assert(u.max_size() > 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::unordered_map<int, int, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, int>>> u;
+ assert(u.max_size() > 0);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.map/rehash.pass.cpp b/test/std/containers/unord/unord.map/rehash.pass.cpp
new file mode 100644
index 000000000000..84ece2355511
--- /dev/null
+++ b/test/std/containers/unord/unord.map/rehash.pass.cpp
@@ -0,0 +1,91 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// void rehash(size_type n);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class C>
+void test(const C& c)
+{
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+}
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ test(c);
+ assert(c.bucket_count() >= 5);
+ c.rehash(3);
+ assert(c.bucket_count() == 5);
+ test(c);
+ c.max_load_factor(2);
+ c.rehash(3);
+ assert(c.bucket_count() == 3);
+ test(c);
+ c.rehash(31);
+ assert(c.bucket_count() == 31);
+ test(c);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ test(c);
+ assert(c.bucket_count() >= 5);
+ c.rehash(3);
+ assert(c.bucket_count() == 5);
+ test(c);
+ c.max_load_factor(2);
+ c.rehash(3);
+ assert(c.bucket_count() == 3);
+ test(c);
+ c.rehash(31);
+ assert(c.bucket_count() == 31);
+ test(c);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.map/reserve.pass.cpp b/test/std/containers/unord/unord.map/reserve.pass.cpp
new file mode 100644
index 000000000000..48667cdc7f92
--- /dev/null
+++ b/test/std/containers/unord/unord.map/reserve.pass.cpp
@@ -0,0 +1,91 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// void reserve(size_type n);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class C>
+void test(const C& c)
+{
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+}
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ test(c);
+ assert(c.bucket_count() >= 5);
+ c.reserve(3);
+ assert(c.bucket_count() == 5);
+ test(c);
+ c.max_load_factor(2);
+ c.reserve(3);
+ assert(c.bucket_count() >= 2);
+ test(c);
+ c.reserve(31);
+ assert(c.bucket_count() >= 16);
+ test(c);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ test(c);
+ assert(c.bucket_count() >= 5);
+ c.reserve(3);
+ assert(c.bucket_count() == 5);
+ test(c);
+ c.max_load_factor(2);
+ c.reserve(3);
+ assert(c.bucket_count() >= 2);
+ test(c);
+ c.reserve(31);
+ assert(c.bucket_count() >= 16);
+ test(c);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.map/swap_member.pass.cpp b/test/std/containers/unord/unord.map/swap_member.pass.cpp
new file mode 100644
index 000000000000..8ab1eb6211b8
--- /dev/null
+++ b/test/std/containers/unord/unord.map/swap_member.pass.cpp
@@ -0,0 +1,572 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// void swap(unordered_map& __u);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "../../test_compare.h"
+#include "../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef test_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ C c1(0, Hash(1), Compare(1), Alloc(1));
+ C c2(0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(1));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(2));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef test_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a2[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c1(0, Hash(1), Compare(1), Alloc(1));
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(c1.at(10) == "ten");
+ assert(c1.at(20) == "twenty");
+ assert(c1.at(30) == "thirty");
+ assert(c1.at(40) == "forty");
+ assert(c1.at(50) == "fifty");
+ assert(c1.at(60) == "sixty");
+ assert(c1.at(70) == "seventy");
+ assert(c1.at(80) == "eighty");
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(1));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(2));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef test_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a1[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+ C c2(0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(1));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 5);
+ assert(c2.size() == 4);
+ assert(c2.at(1) == "one");
+ assert(c2.at(2) == "two");
+ assert(c2.at(3) == "three");
+ assert(c2.at(4) == "four");
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(2));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef test_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a1[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ P a2[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(c1.at(10) == "ten");
+ assert(c1.at(20) == "twenty");
+ assert(c1.at(30) == "thirty");
+ assert(c1.at(40) == "forty");
+ assert(c1.at(50) == "fifty");
+ assert(c1.at(60) == "sixty");
+ assert(c1.at(70) == "seventy");
+ assert(c1.at(80) == "eighty");
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(1));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 5);
+ assert(c2.size() == 4);
+ assert(c2.at(1) == "one");
+ assert(c2.at(2) == "two");
+ assert(c2.at(3) == "three");
+ assert(c2.at(4) == "four");
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(2));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef other_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ C c1(0, Hash(1), Compare(1), Alloc(1));
+ C c2(0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(2));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(1));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef other_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a2[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c1(0, Hash(1), Compare(1), Alloc(1));
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(c1.at(10) == "ten");
+ assert(c1.at(20) == "twenty");
+ assert(c1.at(30) == "thirty");
+ assert(c1.at(40) == "forty");
+ assert(c1.at(50) == "fifty");
+ assert(c1.at(60) == "sixty");
+ assert(c1.at(70) == "seventy");
+ assert(c1.at(80) == "eighty");
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(2));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(1));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef other_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a1[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+ C c2(0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(2));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 5);
+ assert(c2.size() == 4);
+ assert(c2.at(1) == "one");
+ assert(c2.at(2) == "two");
+ assert(c2.at(3) == "three");
+ assert(c2.at(4) == "four");
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(1));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef other_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a1[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ P a2[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(c1.at(10) == "ten");
+ assert(c1.at(20) == "twenty");
+ assert(c1.at(30) == "thirty");
+ assert(c1.at(40) == "forty");
+ assert(c1.at(50) == "fifty");
+ assert(c1.at(60) == "sixty");
+ assert(c1.at(70) == "seventy");
+ assert(c1.at(80) == "eighty");
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(2));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 5);
+ assert(c2.size() == 4);
+ assert(c2.at(1) == "one");
+ assert(c2.at(2) == "two");
+ assert(c2.at(3) == "three");
+ assert(c2.at(4) == "four");
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(1));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef min_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ C c1(0, Hash(1), Compare(1), Alloc());
+ C c2(0, Hash(2), Compare(2), Alloc());
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc());
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc());
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef min_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a2[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c1(0, Hash(1), Compare(1), Alloc());
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc());
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(c1.at(10) == "ten");
+ assert(c1.at(20) == "twenty");
+ assert(c1.at(30) == "thirty");
+ assert(c1.at(40) == "forty");
+ assert(c1.at(50) == "fifty");
+ assert(c1.at(60) == "sixty");
+ assert(c1.at(70) == "seventy");
+ assert(c1.at(80) == "eighty");
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc());
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc());
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef min_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a1[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc());
+ C c2(0, Hash(2), Compare(2), Alloc());
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc());
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 5);
+ assert(c2.size() == 4);
+ assert(c2.at(1) == "one");
+ assert(c2.at(2) == "two");
+ assert(c2.at(3) == "three");
+ assert(c2.at(4) == "four");
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc());
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef min_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a1[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ P a2[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc());
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc());
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(c1.at(10) == "ten");
+ assert(c1.at(20) == "twenty");
+ assert(c1.at(30) == "thirty");
+ assert(c1.at(40) == "forty");
+ assert(c1.at(50) == "fifty");
+ assert(c1.at(60) == "sixty");
+ assert(c1.at(70) == "seventy");
+ assert(c1.at(80) == "eighty");
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc());
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 5);
+ assert(c2.size() == 4);
+ assert(c2.at(1) == "one");
+ assert(c2.at(2) == "two");
+ assert(c2.at(3) == "three");
+ assert(c2.at(4) == "four");
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc());
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.map/types.pass.cpp b/test/std/containers/unord/unord.map/types.pass.cpp
new file mode 100644
index 000000000000..b53ff8e1540a
--- /dev/null
+++ b/test/std/containers/unord/unord.map/types.pass.cpp
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+// {
+// public:
+// // types
+// typedef Key key_type;
+// typedef T mapped_type;
+// typedef Hash hasher;
+// typedef Pred key_equal;
+// typedef Alloc allocator_type;
+// typedef pair<const key_type, mapped_type> value_type;
+// typedef value_type& reference;
+// typedef const value_type& const_reference;
+// typedef typename allocator_traits<allocator_type>::pointer pointer;
+// typedef typename allocator_traits<allocator_type>::const_pointer const_pointer;
+// typedef typename allocator_traits<allocator_type>::size_type size_type;
+// typedef typename allocator_traits<allocator_type>::difference_type difference_type;
+
+#include <unordered_map>
+#include <type_traits>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<char, short> C;
+ static_assert((std::is_same<C::key_type, char>::value), "");
+ static_assert((std::is_same<C::mapped_type, short>::value), "");
+ static_assert((std::is_same<C::hasher, std::hash<C::key_type> >::value), "");
+ static_assert((std::is_same<C::key_equal, std::equal_to<C::key_type> >::value), "");
+ static_assert((std::is_same<C::allocator_type, std::allocator<C::value_type> >::value), "");
+ static_assert((std::is_same<C::value_type, std::pair<const C::key_type, C::mapped_type> >::value), "");
+ static_assert((std::is_same<C::reference, C::value_type&>::value), "");
+ static_assert((std::is_same<C::const_reference, const C::value_type&>::value), "");
+ static_assert((std::is_same<C::pointer, C::value_type*>::value), "");
+ static_assert((std::is_same<C::const_pointer, const C::value_type*>::value), "");
+ static_assert((std::is_same<C::size_type, std::size_t>::value), "");
+ static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<char, short, std::hash<char>, std::equal_to<char>,
+ min_allocator<std::pair<const char, short>>> C;
+ static_assert((std::is_same<C::key_type, char>::value), "");
+ static_assert((std::is_same<C::mapped_type, short>::value), "");
+ static_assert((std::is_same<C::hasher, std::hash<C::key_type> >::value), "");
+ static_assert((std::is_same<C::key_equal, std::equal_to<C::key_type> >::value), "");
+ static_assert((std::is_same<C::allocator_type, min_allocator<C::value_type> >::value), "");
+ static_assert((std::is_same<C::value_type, std::pair<const C::key_type, C::mapped_type> >::value), "");
+ static_assert((std::is_same<C::reference, C::value_type&>::value), "");
+ static_assert((std::is_same<C::const_reference, const C::value_type&>::value), "");
+ static_assert((std::is_same<C::pointer, min_pointer<C::value_type>>::value), "");
+ static_assert((std::is_same<C::const_pointer, min_pointer<const C::value_type>>::value), "");
+ // min_allocator doesn't have a size_type, so one gets synthesized
+ static_assert((std::is_same<C::size_type, std::make_unsigned<C::difference_type>::type>::value), "");
+ static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.map/unord.map.cnstr/allocator.pass.cpp b/test/std/containers/unord/unord.map/unord.map.cnstr/allocator.pass.cpp
new file mode 100644
index 000000000000..0fc76db0fb2f
--- /dev/null
+++ b/test/std/containers/unord/unord.map/unord.map.cnstr/allocator.pass.cpp
@@ -0,0 +1,111 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// explicit unordered_map(const allocator_type& __a);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<NotConstructible, NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ test_allocator<std::pair<const NotConstructible,
+ NotConstructible> >
+ > C;
+ C c(test_allocator<std::pair<const NotConstructible, NotConstructible> >(10));
+ assert(c.bucket_count() == 0);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const NotConstructible, NotConstructible> >(10)));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<NotConstructible, NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ min_allocator<std::pair<const NotConstructible,
+ NotConstructible> >
+ > C;
+ C c(min_allocator<std::pair<const NotConstructible, NotConstructible> >{});
+ assert(c.bucket_count() == 0);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef NotConstructible T;
+ typedef test_allocator<std::pair<const T, T>> A;
+ typedef test_hash<std::hash<T>> HF;
+ typedef test_compare<std::equal_to<T>> Comp;
+ typedef std::unordered_map<T, T, HF, Comp, A> C;
+
+ A a(10);
+ C c(2, a);
+ assert(c.bucket_count() == 2);
+ assert(c.hash_function() == HF());
+ assert(c.key_eq() == Comp());
+ assert(c.get_allocator() == a);
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+ {
+ typedef NotConstructible T;
+ typedef test_allocator<std::pair<const T, T>> A;
+ typedef test_hash<std::hash<T>> HF;
+ typedef test_compare<std::equal_to<T>> Comp;
+ typedef std::unordered_map<T, T, HF, Comp, A> C;
+
+ A a(10);
+ HF hf(12);
+ C c(2, hf, a);
+ assert(c.bucket_count() == 2);
+ assert(c.hash_function() == hf);
+ assert(!(c.hash_function() == HF()));
+ assert(c.key_eq() == Comp());
+ assert(c.get_allocator() == a);
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+#endif
+}
diff --git a/test/std/containers/unord/unord.map/unord.map.cnstr/assign_copy.pass.cpp b/test/std/containers/unord/unord.map/unord.map.cnstr/assign_copy.pass.cpp
new file mode 100644
index 000000000000..fa0105604f15
--- /dev/null
+++ b/test/std/containers/unord/unord.map/unord.map.cnstr/assign_copy.pass.cpp
@@ -0,0 +1,185 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map& operator=(const unordered_map& u);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef test_allocator<std::pair<const int, std::string> > A;
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A(10)
+ );
+ C c(a, a + 2,
+ 7,
+ test_hash<std::hash<int> >(2),
+ test_compare<std::equal_to<int> >(3),
+ A(4)
+ );
+ c = c0;
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == A(4));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<const int, std::string> P;
+ const P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ C *p = &c;
+ c = *p;
+ assert(c.size() == 4);
+ assert(std::is_permutation(c.begin(), c.end(), a));
+ }
+ {
+ typedef other_allocator<std::pair<const int, std::string> > A;
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A(10)
+ );
+ C c(a, a + 2,
+ 7,
+ test_hash<std::hash<int> >(2),
+ test_compare<std::equal_to<int> >(3),
+ A(4)
+ );
+ c = c0;
+ assert(c.bucket_count() >= 5);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == A(10));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef min_allocator<std::pair<const int, std::string> > A;
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A()
+ );
+ C c(a, a + 2,
+ 7,
+ test_hash<std::hash<int> >(2),
+ test_compare<std::equal_to<int> >(3),
+ A()
+ );
+ c = c0;
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == A());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.map/unord.map.cnstr/assign_init.pass.cpp b/test/std/containers/unord/unord.map/unord.map.cnstr/assign_init.pass.cpp
new file mode 100644
index 000000000000..3a854e106543
--- /dev/null
+++ b/test/std/containers/unord/unord.map/unord.map.cnstr/assign_init.pass.cpp
@@ -0,0 +1,97 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map& operator=(initializer_list<value_type> il);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::allocator<std::pair<const int, std::string> > A;
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef std::pair<int, std::string> P;
+ C c = {
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ c = {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ assert(c.bucket_count() >= 5);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef min_allocator<std::pair<const int, std::string> > A;
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef std::pair<int, std::string> P;
+ C c = {
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ c = {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ assert(c.bucket_count() >= 5);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/containers/unord/unord.map/unord.map.cnstr/assign_move.pass.cpp b/test/std/containers/unord/unord.map/unord.map.cnstr/assign_move.pass.cpp
new file mode 100644
index 000000000000..dd57c58214fa
--- /dev/null
+++ b/test/std/containers/unord/unord.map/unord.map.cnstr/assign_move.pass.cpp
@@ -0,0 +1,229 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map& operator=(unordered_map&& u);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef test_allocator<std::pair<const int, std::string> > A;
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A(10)
+ );
+ C c(a, a + 2,
+ 7,
+ test_hash<std::hash<int> >(2),
+ test_compare<std::equal_to<int> >(3),
+ A(4)
+ );
+ c = std::move(c0);
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == A(4));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+ {
+ typedef test_allocator<std::pair<const int, std::string> > A;
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A(10)
+ );
+ C c(a, a + 2,
+ 7,
+ test_hash<std::hash<int> >(2),
+ test_compare<std::equal_to<int> >(3),
+ A(10)
+ );
+ c = std::move(c0);
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == A(10));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c0.size() == 0);
+ }
+ {
+ typedef other_allocator<std::pair<const int, std::string> > A;
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A(10)
+ );
+ C c(a, a + 2,
+ 7,
+ test_hash<std::hash<int> >(2),
+ test_compare<std::equal_to<int> >(3),
+ A(4)
+ );
+ c = std::move(c0);
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == A(10));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c0.size() == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef min_allocator<std::pair<const int, std::string> > A;
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A()
+ );
+ C c(a, a + 2,
+ 7,
+ test_hash<std::hash<int> >(2),
+ test_compare<std::equal_to<int> >(3),
+ A()
+ );
+ c = std::move(c0);
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == A());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c0.size() == 0);
+ }
+#endif
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::unordered_map<int, int> s1 = {{1, 1}, {2, 2}, {3, 3}};
+ std::unordered_map<int, int>::iterator i = s1.begin();
+ std::pair<const int, int> k = *i;
+ std::unordered_map<int, int> s2;
+ s2 = std::move(s1);
+ assert(*i == k);
+ s2.erase(i);
+ assert(s2.size() == 2);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/unord/unord.map/unord.map.cnstr/copy.pass.cpp b/test/std/containers/unord/unord.map/unord.map.cnstr/copy.pass.cpp
new file mode 100644
index 000000000000..227343e6d5b7
--- /dev/null
+++ b/test/std/containers/unord/unord.map/unord.map.cnstr/copy.pass.cpp
@@ -0,0 +1,151 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map(const unordered_map& u);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ test_allocator<std::pair<const int, std::string> >(10)
+ );
+ C c = c0;
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const int, std::string> >(10)));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ other_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ other_allocator<std::pair<const int, std::string> >(10)
+ );
+ C c = c0;
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() ==
+ (other_allocator<std::pair<const int, std::string> >(-2)));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ min_allocator<std::pair<const int, std::string> >()
+ );
+ C c = c0;
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const int, std::string> >()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.map/unord.map.cnstr/copy_alloc.pass.cpp b/test/std/containers/unord/unord.map/unord.map.cnstr/copy_alloc.pass.cpp
new file mode 100644
index 000000000000..d1757d8a3c1b
--- /dev/null
+++ b/test/std/containers/unord/unord.map/unord.map.cnstr/copy_alloc.pass.cpp
@@ -0,0 +1,110 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map(const unordered_map& u, const allocator_type& a);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ test_allocator<std::pair<const int, std::string> >(10)
+ );
+ C c(c0, test_allocator<std::pair<const int, std::string> >(5));
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const int, std::string> >(5)));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ min_allocator<std::pair<const int, std::string> >()
+ );
+ C c(c0, min_allocator<std::pair<const int, std::string> >());
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const int, std::string> >()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.map/unord.map.cnstr/default.pass.cpp b/test/std/containers/unord/unord.map/unord.map.cnstr/default.pass.cpp
new file mode 100644
index 000000000000..a0825db1ecd2
--- /dev/null
+++ b/test/std/containers/unord/unord.map/unord.map.cnstr/default.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map();
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<NotConstructible, NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ test_allocator<std::pair<const NotConstructible,
+ NotConstructible> >
+ > C;
+ C c;
+ assert(c.bucket_count() == 0);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<NotConstructible, NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ min_allocator<std::pair<const NotConstructible,
+ NotConstructible> >
+ > C;
+ C c;
+ assert(c.bucket_count() == 0);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+ {
+ std::unordered_map<int, int> c = {};
+ assert(c.bucket_count() == 0);
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.map/unord.map.cnstr/default_noexcept.pass.cpp b/test/std/containers/unord/unord.map/unord.map.cnstr/default_noexcept.pass.cpp
new file mode 100644
index 000000000000..30e0dc1705a3
--- /dev/null
+++ b/test/std/containers/unord/unord.map/unord.map.cnstr/default_noexcept.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// unordered_map()
+// noexcept(
+// is_nothrow_default_constructible<allocator_type>::value &&
+// is_nothrow_default_constructible<key_compare>::value &&
+// is_nothrow_copy_constructible<key_compare>::value);
+
+// This tests a conforming extension
+
+#include <unordered_map>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "test_allocator.h"
+#include "../../../test_hash.h"
+
+template <class T>
+struct some_comp
+{
+ typedef T value_type;
+ some_comp();
+ some_comp(const some_comp&);
+};
+
+template <class T>
+struct some_hash
+{
+ typedef T value_type;
+ some_hash();
+ some_hash(const some_hash&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly> C;
+ static_assert(std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, test_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+ static_assert(std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, other_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+ static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly, some_hash<MoveOnly>> C;
+ static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ some_comp<MoveOnly>> C;
+ static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.map/unord.map.cnstr/dtor_noexcept.pass.cpp b/test/std/containers/unord/unord.map/unord.map.cnstr/dtor_noexcept.pass.cpp
new file mode 100644
index 000000000000..7fb4200605cf
--- /dev/null
+++ b/test/std/containers/unord/unord.map/unord.map.cnstr/dtor_noexcept.pass.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// ~unordered_map() // implied noexcept;
+
+#include <unordered_map>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "test_allocator.h"
+
+#if __has_feature(cxx_noexcept)
+
+template <class T>
+struct some_comp
+{
+ typedef T value_type;
+ ~some_comp() noexcept(false);
+};
+
+template <class T>
+struct some_hash
+{
+ typedef T value_type;
+ some_hash();
+ some_hash(const some_hash&);
+ ~some_hash() noexcept(false);
+};
+
+#endif
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, test_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, other_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly, some_hash<MoveOnly>> C;
+ static_assert(!std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ some_comp<MoveOnly>> C;
+ static_assert(!std::is_nothrow_destructible<C>::value, "");
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.map/unord.map.cnstr/init.pass.cpp b/test/std/containers/unord/unord.map/unord.map.cnstr/init.pass.cpp
new file mode 100644
index 000000000000..dbc48f816c8b
--- /dev/null
+++ b/test/std/containers/unord/unord.map/unord.map.cnstr/init.pass.cpp
@@ -0,0 +1,162 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map(initializer_list<value_type> il);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ C c = {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ assert(c.bucket_count() >= 5);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >());
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const int, std::string> >()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ C c = {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ assert(c.bucket_count() >= 5);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >());
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const int, std::string> >()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::pair<int, std::string> P;
+ typedef test_allocator<std::pair<const int, std::string>> A;
+ typedef test_hash<std::hash<int>> HF;
+ typedef test_compare<std::equal_to<int>> Comp;
+ typedef std::unordered_map<int, std::string, HF, Comp, A> C;
+
+ A a(42);
+ C c ( {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ }, 12, a);
+ assert(c.bucket_count() >= 12);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >());
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() == a);
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+ {
+ typedef std::pair<int, std::string> P;
+ typedef test_allocator<std::pair<const int, std::string>> A;
+ typedef test_hash<std::hash<int>> HF;
+ typedef test_compare<std::equal_to<int>> Comp;
+ typedef std::unordered_map<int, std::string, HF, Comp, A> C;
+
+ HF hf(42);
+ A a(43);
+ C c ( {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ }, 12, hf, a);
+ assert(c.bucket_count() >= 12);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == hf);
+ assert(!(c.hash_function() == test_hash<std::hash<int> >()));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() == a);
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/containers/unord/unord.map/unord.map.cnstr/init_size.pass.cpp b/test/std/containers/unord/unord.map/unord.map.cnstr/init_size.pass.cpp
new file mode 100644
index 000000000000..ac09053b1ebc
--- /dev/null
+++ b/test/std/containers/unord/unord.map/unord.map.cnstr/init_size.pass.cpp
@@ -0,0 +1,100 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map(initializer_list<value_type> il, size_type n);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ C c({
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ },
+ 7
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >());
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const int, std::string> >()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ C c({
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ },
+ 7
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >());
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const int, std::string> >()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/containers/unord/unord.map/unord.map.cnstr/init_size_hash.pass.cpp b/test/std/containers/unord/unord.map/unord.map.cnstr/init_size_hash.pass.cpp
new file mode 100644
index 000000000000..7a4130bde8fa
--- /dev/null
+++ b/test/std/containers/unord/unord.map/unord.map.cnstr/init_size_hash.pass.cpp
@@ -0,0 +1,102 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map(initializer_list<value_type> il, size_type n, const hasher& hf);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ C c({
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ },
+ 7,
+ test_hash<std::hash<int> >(8)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const int, std::string> >()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ C c({
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ },
+ 7,
+ test_hash<std::hash<int> >(8)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const int, std::string> >()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/containers/unord/unord.map/unord.map.cnstr/init_size_hash_equal.pass.cpp b/test/std/containers/unord/unord.map/unord.map.cnstr/init_size_hash_equal.pass.cpp
new file mode 100644
index 000000000000..036008c0b863
--- /dev/null
+++ b/test/std/containers/unord/unord.map/unord.map.cnstr/init_size_hash_equal.pass.cpp
@@ -0,0 +1,105 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map(initializer_list<value_type> il, size_type n,
+// const hasher& hf, const key_equal& eql);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ C c({
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ },
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const int, std::string> >()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ C c({
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ },
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const int, std::string> >()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/containers/unord/unord.map/unord.map.cnstr/init_size_hash_equal_allocator.pass.cpp b/test/std/containers/unord/unord.map/unord.map.cnstr/init_size_hash_equal_allocator.pass.cpp
new file mode 100644
index 000000000000..7c83192b664c
--- /dev/null
+++ b/test/std/containers/unord/unord.map/unord.map.cnstr/init_size_hash_equal_allocator.pass.cpp
@@ -0,0 +1,107 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map(initializer_list<value_type> il, size_type n,
+// const hasher& hf, const key_equal& eql, const allocator_type& a);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ C c({
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ },
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ test_allocator<std::pair<const int, std::string> >(10)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const int, std::string> >(10)));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ C c({
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ },
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ min_allocator<std::pair<const int, std::string> >()
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const int, std::string> >()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/containers/unord/unord.map/unord.map.cnstr/move.pass.cpp b/test/std/containers/unord/unord.map/unord.map.cnstr/move.pass.cpp
new file mode 100644
index 000000000000..18e6683011c8
--- /dev/null
+++ b/test/std/containers/unord/unord.map/unord.map.cnstr/move.pass.cpp
@@ -0,0 +1,199 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map(unordered_map&& u);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ test_allocator<std::pair<const int, std::string> >(10)
+ );
+ C c = std::move(c0);
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 0);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const int, std::string> >(10)));
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+
+ assert(c0.empty());
+ }
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ test_allocator<std::pair<const int, std::string> >(10)
+ );
+ C c = std::move(c0);
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const int, std::string> >(10)));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+
+ assert(c0.empty());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ min_allocator<std::pair<const int, std::string> >()
+ );
+ C c = std::move(c0);
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 0);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const int, std::string> >()));
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+
+ assert(c0.empty());
+ }
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ min_allocator<std::pair<const int, std::string> >()
+ );
+ C c = std::move(c0);
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const int, std::string> >()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+
+ assert(c0.empty());
+ }
+#endif
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::unordered_map<int, int> s1 = {{1, 1}, {2, 2}, {3, 3}};
+ std::unordered_map<int, int>::iterator i = s1.begin();
+ std::pair<const int, int> k = *i;
+ std::unordered_map<int, int> s2 = std::move(s1);
+ assert(*i == k);
+ s2.erase(i);
+ assert(s2.size() == 2);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/unord/unord.map/unord.map.cnstr/move_alloc.pass.cpp b/test/std/containers/unord/unord.map/unord.map.cnstr/move_alloc.pass.cpp
new file mode 100644
index 000000000000..091a72f0d160
--- /dev/null
+++ b/test/std/containers/unord/unord.map/unord.map.cnstr/move_alloc.pass.cpp
@@ -0,0 +1,157 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map(unordered_map&& u, const allocator_type& a);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::pair<int, std::string> P;
+ typedef test_allocator<std::pair<const int, std::string>> A;
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A(10)
+ );
+ C c(std::move(c0), A(12));
+ assert(c.bucket_count() >= 5);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == A(12));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+
+ assert(c0.empty());
+ }
+ {
+ typedef std::pair<int, std::string> P;
+ typedef test_allocator<std::pair<const int, std::string>> A;
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A(10)
+ );
+ C c(std::move(c0), A(10));
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == A(10));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+
+ assert(c0.empty());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<int, std::string> P;
+ typedef min_allocator<std::pair<const int, std::string>> A;
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A()
+ );
+ C c(std::move(c0), A());
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == A());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+
+ assert(c0.empty());
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/unord/unord.map/unord.map.cnstr/move_assign_noexcept.pass.cpp b/test/std/containers/unord/unord.map/unord.map.cnstr/move_assign_noexcept.pass.cpp
new file mode 100644
index 000000000000..fc3fc6f05f8a
--- /dev/null
+++ b/test/std/containers/unord/unord.map/unord.map.cnstr/move_assign_noexcept.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// unordered_map& operator=(unordered_map&& c)
+// noexcept(
+// allocator_type::propagate_on_container_move_assignment::value &&
+// is_nothrow_move_assignable<allocator_type>::value &&
+// is_nothrow_move_assignable<key_compare>::value);
+
+// This tests a conforming extension
+
+#include <unordered_map>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_comp
+{
+ typedef T value_type;
+ some_comp& operator=(const some_comp&);
+};
+
+template <class T>
+struct some_hash
+{
+ typedef T value_type;
+ some_hash();
+ some_hash(const some_hash&);
+ some_hash& operator=(const some_hash&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly> C;
+ static_assert(std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, test_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+ static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, other_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+ static_assert(std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly, some_hash<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ some_comp<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.map/unord.map.cnstr/move_noexcept.pass.cpp b/test/std/containers/unord/unord.map/unord.map.cnstr/move_noexcept.pass.cpp
new file mode 100644
index 000000000000..f292011cd7b6
--- /dev/null
+++ b/test/std/containers/unord/unord.map/unord.map.cnstr/move_noexcept.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// unordered_map(unordered_map&&)
+// noexcept(is_nothrow_move_constructible<allocator_type>::value &&
+// is_nothrow_move_constructible<key_compare>::value);
+
+// This tests a conforming extension
+
+#include <unordered_map>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_comp
+{
+ typedef T value_type;
+ some_comp(const some_comp&);
+};
+
+template <class T>
+struct some_hash
+{
+ typedef T value_type;
+ some_hash();
+ some_hash(const some_hash&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, test_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, other_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly, some_hash<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ some_comp<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_constructible<C>::value, "");
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.map/unord.map.cnstr/range.pass.cpp b/test/std/containers/unord/unord.map/unord.map.cnstr/range.pass.cpp
new file mode 100644
index 000000000000..c1784d63b293
--- /dev/null
+++ b/test/std/containers/unord/unord.map/unord.map.cnstr/range.pass.cpp
@@ -0,0 +1,170 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// template <class InputIterator>
+// unordered_map(InputIterator first, InputIterator last);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "test_iterators.h"
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])));
+ assert(c.bucket_count() >= 5);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >());
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const int, std::string> >()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])));
+ assert(c.bucket_count() >= 5);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >());
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const int, std::string> >()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::pair<int, std::string> P;
+ typedef test_allocator<std::pair<const int, std::string>> A;
+ typedef test_hash<std::hash<int>> HF;
+ typedef test_compare<std::equal_to<int>> Comp;
+ typedef std::unordered_map<int, std::string, HF, Comp, A> C;
+
+ P arr[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(input_iterator<P*>(arr), input_iterator<P*>(arr + sizeof(arr)/sizeof(arr[0])), 14);
+ assert(c.bucket_count() >= 14);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == HF());
+ assert(c.key_eq() == Comp());
+ assert(c.get_allocator() == A());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+ {
+ typedef std::pair<int, std::string> P;
+ typedef test_allocator<std::pair<const int, std::string>> A;
+ typedef test_hash<std::hash<int>> HF;
+ typedef test_compare<std::equal_to<int>> Comp;
+ typedef std::unordered_map<int, std::string, HF, Comp, A> C;
+
+ P arr[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ HF hf(42);
+ A a(43);
+ C c(input_iterator<P*>(arr), input_iterator<P*>(arr + sizeof(arr)/sizeof(arr[0])), 14, hf, a);
+ assert(c.bucket_count() >= 14);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == hf);
+ assert(!(c.hash_function() == HF()));
+ assert(c.key_eq() == Comp());
+ assert(c.get_allocator() == a);
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+#endif
+}
diff --git a/test/std/containers/unord/unord.map/unord.map.cnstr/range_size.pass.cpp b/test/std/containers/unord/unord.map/unord.map.cnstr/range_size.pass.cpp
new file mode 100644
index 000000000000..f914b3060718
--- /dev/null
+++ b/test/std/containers/unord/unord.map/unord.map.cnstr/range_size.pass.cpp
@@ -0,0 +1,105 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// template <class InputIterator>
+// unordered_map(InputIterator first, InputIterator last, size_type n);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "test_iterators.h"
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+ 10
+ );
+ assert(c.bucket_count() == 11);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >());
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const int, std::string> >()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+ 10
+ );
+ assert(c.bucket_count() == 11);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >());
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const int, std::string> >()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.map/unord.map.cnstr/range_size_hash.pass.cpp b/test/std/containers/unord/unord.map/unord.map.cnstr/range_size_hash.pass.cpp
new file mode 100644
index 000000000000..7a0dbceb17c1
--- /dev/null
+++ b/test/std/containers/unord/unord.map/unord.map.cnstr/range_size_hash.pass.cpp
@@ -0,0 +1,108 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// template <class InputIterator>
+// unordered_map(InputIterator first, InputIterator last, size_type n,
+// const hasher& hf);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "test_iterators.h"
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+ 7,
+ test_hash<std::hash<int> >(8)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const int, std::string> >()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+ 7,
+ test_hash<std::hash<int> >(8)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const int, std::string> >()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.map/unord.map.cnstr/range_size_hash_equal.pass.cpp b/test/std/containers/unord/unord.map/unord.map.cnstr/range_size_hash_equal.pass.cpp
new file mode 100644
index 000000000000..61eef5bc40a4
--- /dev/null
+++ b/test/std/containers/unord/unord.map/unord.map.cnstr/range_size_hash_equal.pass.cpp
@@ -0,0 +1,110 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// template <class InputIterator>
+// unordered_map(InputIterator first, InputIterator last, size_type n,
+// const hasher& hf, const key_equal& eql);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "test_iterators.h"
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const int, std::string> >()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const int, std::string> >()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.map/unord.map.cnstr/range_size_hash_equal_allocator.pass.cpp b/test/std/containers/unord/unord.map/unord.map.cnstr/range_size_hash_equal_allocator.pass.cpp
new file mode 100644
index 000000000000..99493fad32c5
--- /dev/null
+++ b/test/std/containers/unord/unord.map/unord.map.cnstr/range_size_hash_equal_allocator.pass.cpp
@@ -0,0 +1,113 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// template <class InputIterator>
+// unordered_map(InputIterator first, InputIterator last, size_type n,
+// const hasher& hf, const key_equal& eql,
+// const allocator_type& a);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "test_iterators.h"
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ test_allocator<std::pair<const int, std::string> >(10)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const int, std::string> >(10)));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ min_allocator<std::pair<const int, std::string> >()
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const int, std::string> >()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.map/unord.map.cnstr/size.fail.cpp b/test/std/containers/unord/unord.map/unord.map.cnstr/size.fail.cpp
new file mode 100644
index 000000000000..0a3ae3a117f1
--- /dev/null
+++ b/test/std/containers/unord/unord.map/unord.map.cnstr/size.fail.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map(size_type n);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<NotConstructible, NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ test_allocator<std::pair<const NotConstructible,
+ NotConstructible> >
+ > C;
+ C c = 7;
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<NotConstructible, NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ min_allocator<std::pair<const NotConstructible,
+ NotConstructible> >
+ > C;
+ C c = 7;
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.map/unord.map.cnstr/size.pass.cpp b/test/std/containers/unord/unord.map/unord.map.cnstr/size.pass.cpp
new file mode 100644
index 000000000000..708dc2362739
--- /dev/null
+++ b/test/std/containers/unord/unord.map/unord.map.cnstr/size.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map(size_type n);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<NotConstructible, NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ test_allocator<std::pair<const NotConstructible,
+ NotConstructible> >
+ > C;
+ C c(7);
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<NotConstructible, NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ min_allocator<std::pair<const NotConstructible,
+ NotConstructible> >
+ > C;
+ C c(7);
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.map/unord.map.cnstr/size_hash.pass.cpp b/test/std/containers/unord/unord.map/unord.map.cnstr/size_hash.pass.cpp
new file mode 100644
index 000000000000..6c975ec72030
--- /dev/null
+++ b/test/std/containers/unord/unord.map/unord.map.cnstr/size_hash.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map(size_type n, const hasher& hf);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<NotConstructible, NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ test_allocator<std::pair<const NotConstructible,
+ NotConstructible> >
+ > C;
+ C c(7,
+ test_hash<std::hash<NotConstructible> >(8)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<NotConstructible, NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ min_allocator<std::pair<const NotConstructible,
+ NotConstructible> >
+ > C;
+ C c(7,
+ test_hash<std::hash<NotConstructible> >(8)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.map/unord.map.cnstr/size_hash_equal.pass.cpp b/test/std/containers/unord/unord.map/unord.map.cnstr/size_hash_equal.pass.cpp
new file mode 100644
index 000000000000..8b2bb317987e
--- /dev/null
+++ b/test/std/containers/unord/unord.map/unord.map.cnstr/size_hash_equal.pass.cpp
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map(size_type n, const hasher& hf, const key_equal& eql);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<NotConstructible, NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ test_allocator<std::pair<const NotConstructible,
+ NotConstructible> >
+ > C;
+ C c(7,
+ test_hash<std::hash<NotConstructible> >(8),
+ test_compare<std::equal_to<NotConstructible> >(9)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >(9));
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<NotConstructible, NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ min_allocator<std::pair<const NotConstructible,
+ NotConstructible> >
+ > C;
+ C c(7,
+ test_hash<std::hash<NotConstructible> >(8),
+ test_compare<std::equal_to<NotConstructible> >(9)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >(9));
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.map/unord.map.cnstr/size_hash_equal_allocator.pass.cpp b/test/std/containers/unord/unord.map/unord.map.cnstr/size_hash_equal_allocator.pass.cpp
new file mode 100644
index 000000000000..bcf7b91503ad
--- /dev/null
+++ b/test/std/containers/unord/unord.map/unord.map.cnstr/size_hash_equal_allocator.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map(size_type n, const hasher& hf, const key_equal& eql, const allocator_type& a);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<NotConstructible, NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ test_allocator<std::pair<const NotConstructible,
+ NotConstructible> >
+ > C;
+ C c(7,
+ test_hash<std::hash<NotConstructible> >(8),
+ test_compare<std::equal_to<NotConstructible> >(9),
+ test_allocator<std::pair<const NotConstructible, NotConstructible> >(10)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >(9));
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const NotConstructible, NotConstructible> >(10)));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<NotConstructible, NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ min_allocator<std::pair<const NotConstructible,
+ NotConstructible> >
+ > C;
+ C c(7,
+ test_hash<std::hash<NotConstructible> >(8),
+ test_compare<std::equal_to<NotConstructible> >(9),
+ min_allocator<std::pair<const NotConstructible, NotConstructible> >()
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >(9));
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.map/unord.map.elem/at.pass.cpp b/test/std/containers/unord/unord.map/unord.map.elem/at.pass.cpp
new file mode 100644
index 000000000000..5fd9f9d6114a
--- /dev/null
+++ b/test/std/containers/unord/unord.map/unord.map.elem/at.pass.cpp
@@ -0,0 +1,134 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// mapped_type& at(const key_type& k);
+// const mapped_type& at(const key_type& k) const;
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.size() == 4);
+ c.at(1) = "ONE";
+ assert(c.at(1) == "ONE");
+ try
+ {
+ c.at(11) = "eleven";
+ assert(false);
+ }
+ catch (std::out_of_range&)
+ {
+ }
+ assert(c.size() == 4);
+ }
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ try
+ {
+ c.at(11);
+ assert(false);
+ }
+ catch (std::out_of_range&)
+ {
+ }
+ assert(c.size() == 4);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.size() == 4);
+ c.at(1) = "ONE";
+ assert(c.at(1) == "ONE");
+ try
+ {
+ c.at(11) = "eleven";
+ assert(false);
+ }
+ catch (std::out_of_range&)
+ {
+ }
+ assert(c.size() == 4);
+ }
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ try
+ {
+ c.at(11);
+ assert(false);
+ }
+ catch (std::out_of_range&)
+ {
+ }
+ assert(c.size() == 4);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.map/unord.map.elem/index.pass.cpp b/test/std/containers/unord/unord.map/unord.map.elem/index.pass.cpp
new file mode 100644
index 000000000000..c072248f866a
--- /dev/null
+++ b/test/std/containers/unord/unord.map/unord.map.elem/index.pass.cpp
@@ -0,0 +1,115 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// mapped_type& operator[](const key_type& k);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.size() == 4);
+ c[1] = "ONE";
+ assert(c.at(1) == "ONE");
+ c[11] = "eleven";
+ assert(c.size() == 5);
+ assert(c.at(11) == "eleven");
+ }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::unordered_map<MoveOnly, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.size() == 4);
+ c[1] = "ONE";
+ assert(c.at(1) == "ONE");
+ c[11] = "eleven";
+ assert(c.size() == 5);
+ assert(c.at(11) == "eleven");
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.size() == 4);
+ c[1] = "ONE";
+ assert(c.at(1) == "ONE");
+ c[11] = "eleven";
+ assert(c.size() == 5);
+ assert(c.at(11) == "eleven");
+ }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::unordered_map<MoveOnly, std::string, std::hash<MoveOnly>, std::equal_to<MoveOnly>,
+ min_allocator<std::pair<const MoveOnly, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.size() == 4);
+ c[1] = "ONE";
+ assert(c.at(1) == "ONE");
+ c[11] = "eleven";
+ assert(c.size() == 5);
+ assert(c.at(11) == "eleven");
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif
+}
diff --git a/test/std/containers/unord/unord.map/unord.map.elem/index_tuple.pass.cpp b/test/std/containers/unord/unord.map/unord.map.elem/index_tuple.pass.cpp
new file mode 100644
index 000000000000..c319b5c30b2c
--- /dev/null
+++ b/test/std/containers/unord/unord.map/unord.map.elem/index_tuple.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// mapped_type& operator[](const key_type& k);
+
+// http://llvm.org/bugs/show_bug.cgi?id=16542
+
+#include <unordered_map>
+
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+
+#include <tuple>
+
+using namespace std;
+
+struct my_hash
+{
+ size_t operator()(const tuple<int,int>&) const {return 0;}
+};
+
+#endif
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+ unordered_map<tuple<int,int>, size_t, my_hash> m;
+ m[make_tuple(2,3)]=7;
+#endif
+}
diff --git a/test/std/containers/unord/unord.map/unord.map.swap/db_swap_1.pass.cpp b/test/std/containers/unord/unord.map/unord.map.swap/db_swap_1.pass.cpp
new file mode 100644
index 000000000000..6ab9c923da31
--- /dev/null
+++ b/test/std/containers/unord/unord.map/unord.map.swap/db_swap_1.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class Value, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, Value>>>
+// class unordered_map
+
+// void swap(unordered_map& x, unordered_map& y);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_map>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_DEBUG >= 1
+ {
+ typedef std::pair<int, int> P;
+ P a1[] = {P(1, 1), P(3, 3), P(7, 7), P(9, 9), P(10, 10)};
+ P a2[] = {P(0, 0), P(2, 2), P(4, 4), P(5, 5), P(6, 6), P(8, 8), P(11, 11)};
+ std::unordered_map<int, int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ std::unordered_map<int, int> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+ std::unordered_map<int, int>::iterator i1 = c1.begin();
+ std::unordered_map<int, int>::iterator i2 = c2.begin();
+ swap(c1, c2);
+ c1.erase(i2);
+ c2.erase(i1);
+ std::unordered_map<int, int>::iterator j = i1;
+ c1.erase(i1);
+ assert(false);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.map/unord.map.swap/swap_noexcept.pass.cpp b/test/std/containers/unord/unord.map/unord.map.swap/swap_noexcept.pass.cpp
new file mode 100644
index 000000000000..1056c231f0db
--- /dev/null
+++ b/test/std/containers/unord/unord.map/unord.map.swap/swap_noexcept.pass.cpp
@@ -0,0 +1,199 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// void swap(unordered_map& c)
+// noexcept(
+// (!allocator_type::propagate_on_container_swap::value ||
+// __is_nothrow_swappable<allocator_type>::value) &&
+// __is_nothrow_swappable<hasher>::value &&
+// __is_nothrow_swappable<key_equal>::value);
+//
+// In C++17, the standard says that swap shall have:
+// noexcept(allocator_traits<Allocator>::is_always_equal::value &&
+// noexcept(swap(declval<Hash&>(), declval<Hash&>())) &&
+// noexcept(swap(declval<Pred&>(), declval<Pred&>())));
+
+// This tests a conforming extension
+
+#include <unordered_map>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_comp
+{
+ typedef T value_type;
+
+ some_comp() {}
+ some_comp(const some_comp&) {}
+};
+
+template <class T>
+struct some_comp2
+{
+ typedef T value_type;
+
+ some_comp2() {}
+ some_comp2(const some_comp2&) {}
+ void deallocate(void*, unsigned) {}
+ typedef std::true_type propagate_on_container_swap;
+};
+
+#if TEST_STD_VER >= 14
+template <typename T>
+void swap(some_comp2<T>&, some_comp2<T>&) noexcept {}
+#endif
+
+template <class T>
+struct some_hash
+{
+ typedef T value_type;
+ some_hash() {}
+ some_hash(const some_hash&);
+};
+
+template <class T>
+struct some_hash2
+{
+ typedef T value_type;
+ some_hash2() {}
+ some_hash2(const some_hash2&);
+};
+
+#if TEST_STD_VER >= 14
+template <typename T>
+void swap(some_hash2<T>&, some_hash2<T>&) noexcept {}
+#endif
+
+template <class T>
+struct some_alloc
+{
+ typedef T value_type;
+
+ some_alloc() {}
+ some_alloc(const some_alloc&);
+ void deallocate(void*, unsigned) {}
+
+ typedef std::true_type propagate_on_container_swap;
+};
+
+template <class T>
+struct some_alloc2
+{
+ typedef T value_type;
+
+ some_alloc2() {}
+ some_alloc2(const some_alloc2&);
+ void deallocate(void*, unsigned) {}
+
+ typedef std::false_type propagate_on_container_swap;
+ typedef std::true_type is_always_equal;
+};
+
+template <class T>
+struct some_alloc3
+{
+ typedef T value_type;
+
+ some_alloc3() {}
+ some_alloc3(const some_alloc3&);
+ void deallocate(void*, unsigned) {}
+
+ typedef std::false_type propagate_on_container_swap;
+ typedef std::false_type is_always_equal;
+};
+
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ typedef std::pair<const MoveOnly, MoveOnly> MapType;
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, test_allocator<MapType>> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, other_allocator<MapType>> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly, some_hash<MoveOnly>> C;
+ C c1, c2;
+ static_assert(!noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ some_comp<MoveOnly>> C;
+ C c1, c2;
+ static_assert(!noexcept(swap(c1, c2)), "");
+ }
+
+#if TEST_STD_VER >= 14
+ { // POCS allocator, throwable swap for hash, throwable swap for comp
+ typedef std::unordered_map<MoveOnly, MoveOnly, some_hash<MoveOnly>, some_comp <MoveOnly>, some_alloc <MapType>> C;
+ C c1, c2;
+ static_assert(!noexcept(swap(c1, c2)), "");
+ }
+ { // always equal allocator, throwable swap for hash, throwable swap for comp
+ typedef std::unordered_map<MoveOnly, MoveOnly, some_hash<MoveOnly>, some_comp <MoveOnly>, some_alloc2<MapType>> C;
+ C c1, c2;
+ static_assert(!noexcept(swap(c1, c2)), "");
+ }
+ { // POCS allocator, throwable swap for hash, nothrow swap for comp
+ typedef std::unordered_map<MoveOnly, MoveOnly, some_hash<MoveOnly>, some_comp2<MoveOnly>, some_alloc <MapType>> C;
+ C c1, c2;
+ static_assert(!noexcept(swap(c1, c2)), "");
+ }
+ { // always equal allocator, throwable swap for hash, nothrow swap for comp
+ typedef std::unordered_map<MoveOnly, MoveOnly, some_hash<MoveOnly>, some_comp2<MoveOnly>, some_alloc2<MapType>> C;
+ C c1, c2;
+ static_assert(!noexcept(swap(c1, c2)), "");
+ }
+ { // POCS allocator, nothrow swap for hash, throwable swap for comp
+ typedef std::unordered_map<MoveOnly, MoveOnly, some_hash2<MoveOnly>, some_comp <MoveOnly>, some_alloc <MapType>> C;
+ C c1, c2;
+ static_assert(!noexcept(swap(c1, c2)), "");
+ }
+ { // always equal allocator, nothrow swap for hash, throwable swap for comp
+ typedef std::unordered_map<MoveOnly, MoveOnly, some_hash2<MoveOnly>, some_comp <MoveOnly>, some_alloc2<MapType>> C;
+ C c1, c2;
+ static_assert(!noexcept(swap(c1, c2)), "");
+ }
+ { // POCS allocator, nothrow swap for hash, nothrow swap for comp
+ typedef std::unordered_map<MoveOnly, MoveOnly, some_hash2<MoveOnly>, some_comp2<MoveOnly>, some_alloc <MapType>> C;
+ C c1, c2;
+ static_assert( noexcept(swap(c1, c2)), "");
+ }
+ { // always equal allocator, nothrow swap for hash, nothrow swap for comp
+ typedef std::unordered_map<MoveOnly, MoveOnly, some_hash2<MoveOnly>, some_comp2<MoveOnly>, some_alloc2<MapType>> C;
+ C c1, c2;
+ static_assert( noexcept(swap(c1, c2)), "");
+ }
+
+ { // NOT always equal allocator, nothrow swap for hash, nothrow swap for comp
+ typedef std::unordered_map<MoveOnly, MoveOnly, some_hash2<MoveOnly>, some_comp2<MoveOnly>, some_alloc3<MapType>> C;
+ C c1, c2;
+ static_assert( noexcept(swap(c1, c2)), "");
+ }
+#endif
+#endif
+}
diff --git a/test/std/containers/unord/unord.map/unord.map.swap/swap_non_member.pass.cpp b/test/std/containers/unord/unord.map/unord.map.swap/swap_non_member.pass.cpp
new file mode 100644
index 000000000000..7e04b8db117c
--- /dev/null
+++ b/test/std/containers/unord/unord.map/unord.map.swap/swap_non_member.pass.cpp
@@ -0,0 +1,572 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// void swap(unordered_map& __u);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef test_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ C c1(0, Hash(1), Compare(1), Alloc(1));
+ C c2(0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(1));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(2));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef test_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a2[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c1(0, Hash(1), Compare(1), Alloc(1));
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(c1.at(10) == "ten");
+ assert(c1.at(20) == "twenty");
+ assert(c1.at(30) == "thirty");
+ assert(c1.at(40) == "forty");
+ assert(c1.at(50) == "fifty");
+ assert(c1.at(60) == "sixty");
+ assert(c1.at(70) == "seventy");
+ assert(c1.at(80) == "eighty");
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(1));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(2));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef test_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a1[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+ C c2(0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(1));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 5);
+ assert(c2.size() == 4);
+ assert(c2.at(1) == "one");
+ assert(c2.at(2) == "two");
+ assert(c2.at(3) == "three");
+ assert(c2.at(4) == "four");
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(2));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef test_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a1[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ P a2[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(c1.at(10) == "ten");
+ assert(c1.at(20) == "twenty");
+ assert(c1.at(30) == "thirty");
+ assert(c1.at(40) == "forty");
+ assert(c1.at(50) == "fifty");
+ assert(c1.at(60) == "sixty");
+ assert(c1.at(70) == "seventy");
+ assert(c1.at(80) == "eighty");
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(1));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 5);
+ assert(c2.size() == 4);
+ assert(c2.at(1) == "one");
+ assert(c2.at(2) == "two");
+ assert(c2.at(3) == "three");
+ assert(c2.at(4) == "four");
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(2));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef other_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ C c1(0, Hash(1), Compare(1), Alloc(1));
+ C c2(0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(2));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(1));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef other_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a2[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c1(0, Hash(1), Compare(1), Alloc(1));
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(c1.at(10) == "ten");
+ assert(c1.at(20) == "twenty");
+ assert(c1.at(30) == "thirty");
+ assert(c1.at(40) == "forty");
+ assert(c1.at(50) == "fifty");
+ assert(c1.at(60) == "sixty");
+ assert(c1.at(70) == "seventy");
+ assert(c1.at(80) == "eighty");
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(2));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(1));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef other_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a1[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+ C c2(0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(2));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 5);
+ assert(c2.size() == 4);
+ assert(c2.at(1) == "one");
+ assert(c2.at(2) == "two");
+ assert(c2.at(3) == "three");
+ assert(c2.at(4) == "four");
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(1));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef other_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a1[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ P a2[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(c1.at(10) == "ten");
+ assert(c1.at(20) == "twenty");
+ assert(c1.at(30) == "thirty");
+ assert(c1.at(40) == "forty");
+ assert(c1.at(50) == "fifty");
+ assert(c1.at(60) == "sixty");
+ assert(c1.at(70) == "seventy");
+ assert(c1.at(80) == "eighty");
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(2));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 5);
+ assert(c2.size() == 4);
+ assert(c2.at(1) == "one");
+ assert(c2.at(2) == "two");
+ assert(c2.at(3) == "three");
+ assert(c2.at(4) == "four");
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(1));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef min_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ C c1(0, Hash(1), Compare(1), Alloc());
+ C c2(0, Hash(2), Compare(2), Alloc());
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc());
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc());
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef min_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a2[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c1(0, Hash(1), Compare(1), Alloc());
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc());
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(c1.at(10) == "ten");
+ assert(c1.at(20) == "twenty");
+ assert(c1.at(30) == "thirty");
+ assert(c1.at(40) == "forty");
+ assert(c1.at(50) == "fifty");
+ assert(c1.at(60) == "sixty");
+ assert(c1.at(70) == "seventy");
+ assert(c1.at(80) == "eighty");
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc());
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc());
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef min_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a1[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc());
+ C c2(0, Hash(2), Compare(2), Alloc());
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc());
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 5);
+ assert(c2.size() == 4);
+ assert(c2.at(1) == "one");
+ assert(c2.at(2) == "two");
+ assert(c2.at(3) == "three");
+ assert(c2.at(4) == "four");
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc());
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef min_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a1[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ P a2[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc());
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc());
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(c1.at(10) == "ten");
+ assert(c1.at(20) == "twenty");
+ assert(c1.at(30) == "thirty");
+ assert(c1.at(40) == "forty");
+ assert(c1.at(50) == "fifty");
+ assert(c1.at(60) == "sixty");
+ assert(c1.at(70) == "seventy");
+ assert(c1.at(80) == "eighty");
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc());
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 5);
+ assert(c2.size() == 4);
+ assert(c2.at(1) == "one");
+ assert(c2.at(2) == "two");
+ assert(c2.at(3) == "three");
+ assert(c2.at(4) == "four");
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc());
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.map/unorder.map.modifiers/clear.pass.cpp b/test/std/containers/unord/unord.map/unorder.map.modifiers/clear.pass.cpp
new file mode 100644
index 000000000000..9f320e949479
--- /dev/null
+++ b/test/std/containers/unord/unord.map/unorder.map.modifiers/clear.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// void clear()
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ c.clear();
+ assert(c.size() == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ c.clear();
+ assert(c.size() == 0);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.map/unorder.map.modifiers/emplace.pass.cpp b/test/std/containers/unord/unord.map/unorder.map.modifiers/emplace.pass.cpp
new file mode 100644
index 000000000000..5de74d2e6c92
--- /dev/null
+++ b/test/std/containers/unord/unord.map/unorder.map.modifiers/emplace.pass.cpp
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// template <class... Args>
+// pair<iterator, bool> emplace(Args&&... args);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../Emplaceable.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::unordered_map<int, Emplaceable> C;
+ typedef std::pair<C::iterator, bool> R;
+ C c;
+ R r = c.emplace(std::piecewise_construct, std::forward_as_tuple(3),
+ std::forward_as_tuple());
+ assert(r.second);
+ assert(c.size() == 1);
+ assert(r.first->first == 3);
+ assert(r.first->second == Emplaceable());
+
+ r = c.emplace(std::pair<const int, Emplaceable>(4, Emplaceable(5, 6)));
+ assert(r.second);
+ assert(c.size() == 2);
+ assert(r.first->first == 4);
+ assert(r.first->second == Emplaceable(5, 6));
+
+ r = c.emplace(std::piecewise_construct, std::forward_as_tuple(5),
+ std::forward_as_tuple(6, 7));
+ assert(r.second);
+ assert(c.size() == 3);
+ assert(r.first->first == 5);
+ assert(r.first->second == Emplaceable(6, 7));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, Emplaceable, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, Emplaceable>>> C;
+ typedef std::pair<C::iterator, bool> R;
+ C c;
+ R r = c.emplace(std::piecewise_construct, std::forward_as_tuple(3),
+ std::forward_as_tuple());
+ assert(r.second);
+ assert(c.size() == 1);
+ assert(r.first->first == 3);
+ assert(r.first->second == Emplaceable());
+
+ r = c.emplace(std::pair<const int, Emplaceable>(4, Emplaceable(5, 6)));
+ assert(r.second);
+ assert(c.size() == 2);
+ assert(r.first->first == 4);
+ assert(r.first->second == Emplaceable(5, 6));
+
+ r = c.emplace(std::piecewise_construct, std::forward_as_tuple(5),
+ std::forward_as_tuple(6, 7));
+ assert(r.second);
+ assert(c.size() == 3);
+ assert(r.first->first == 5);
+ assert(r.first->second == Emplaceable(6, 7));
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/unord/unord.map/unorder.map.modifiers/emplace_hint.pass.cpp b/test/std/containers/unord/unord.map/unorder.map.modifiers/emplace_hint.pass.cpp
new file mode 100644
index 000000000000..21a4689658ae
--- /dev/null
+++ b/test/std/containers/unord/unord.map/unorder.map.modifiers/emplace_hint.pass.cpp
@@ -0,0 +1,93 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// template <class... Args>
+// iterator emplace_hint(const_iterator p, Args&&... args);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../Emplaceable.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::unordered_map<int, Emplaceable> C;
+ typedef C::iterator R;
+ C c;
+ C::const_iterator e = c.end();
+ R r = c.emplace_hint(e, std::piecewise_construct, std::forward_as_tuple(3),
+ std::forward_as_tuple());
+ assert(c.size() == 1);
+ assert(r->first == 3);
+ assert(r->second == Emplaceable());
+
+ r = c.emplace_hint(c.end(), std::pair<const int, Emplaceable>(4, Emplaceable(5, 6)));
+ assert(c.size() == 2);
+ assert(r->first == 4);
+ assert(r->second == Emplaceable(5, 6));
+
+ r = c.emplace_hint(c.end(), std::piecewise_construct, std::forward_as_tuple(5),
+ std::forward_as_tuple(6, 7));
+ assert(c.size() == 3);
+ assert(r->first == 5);
+ assert(r->second == Emplaceable(6, 7));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, Emplaceable, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, Emplaceable>>> C;
+ typedef C::iterator R;
+ C c;
+ C::const_iterator e = c.end();
+ R r = c.emplace_hint(e, std::piecewise_construct, std::forward_as_tuple(3),
+ std::forward_as_tuple());
+ assert(c.size() == 1);
+ assert(r->first == 3);
+ assert(r->second == Emplaceable());
+
+ r = c.emplace_hint(c.end(), std::pair<const int, Emplaceable>(4, Emplaceable(5, 6)));
+ assert(c.size() == 2);
+ assert(r->first == 4);
+ assert(r->second == Emplaceable(5, 6));
+
+ r = c.emplace_hint(c.end(), std::piecewise_construct, std::forward_as_tuple(5),
+ std::forward_as_tuple(6, 7));
+ assert(c.size() == 3);
+ assert(r->first == 5);
+ assert(r->second == Emplaceable(6, 7));
+ }
+#endif
+#if _LIBCPP_DEBUG >= 1
+ {
+ typedef std::unordered_map<int, Emplaceable> C;
+ typedef C::iterator R;
+ typedef C::value_type P;
+ C c;
+ C c2;
+ R r = c.emplace_hint(c2.end(), std::piecewise_construct,
+ std::forward_as_tuple(3),
+ std::forward_as_tuple());
+ assert(false);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_const_iter.pass.cpp b/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_const_iter.pass.cpp
new file mode 100644
index 000000000000..dbb812974d46
--- /dev/null
+++ b/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_const_iter.pass.cpp
@@ -0,0 +1,92 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// iterator erase(const_iterator p)
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+struct TemplateConstructor
+{
+ template<typename T>
+ TemplateConstructor (const T&) {}
+};
+
+bool operator==(const TemplateConstructor&, const TemplateConstructor&) { return false; }
+struct Hash { size_t operator() (const TemplateConstructor &) const { return 0; } };
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ C::const_iterator i = c.find(2);
+ C::iterator j = c.erase(i);
+ assert(c.size() == 3);
+ assert(c.at(1) == "one");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ C::const_iterator i = c.find(2);
+ C::iterator j = c.erase(i);
+ assert(c.size() == 3);
+ assert(c.at(1) == "one");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ }
+#endif
+#if __cplusplus >= 201402L
+ {
+ // This is LWG #2059
+ typedef TemplateConstructor T;
+ typedef std::unordered_map<T, int, Hash> C;
+ typedef C::iterator I;
+
+ C m;
+ T a{0};
+ I it = m.find(a);
+ if (it != m.end())
+ m.erase(it);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_db1.pass.cpp b/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_db1.pass.cpp
new file mode 100644
index 000000000000..60b093553f18
--- /dev/null
+++ b/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_db1.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Call erase(const_iterator position) with end()
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::pair<int, int> P;
+ P a1[] = {P(1, 1), P(2, 2), P(3, 3)};
+ std::unordered_map<int, int> l1(a1, a1+3);
+ std::unordered_map<int, int>::const_iterator i = l1.end();
+ l1.erase(i);
+ assert(false);
+ }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_db2.pass.cpp b/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_db2.pass.cpp
new file mode 100644
index 000000000000..05046f5dedc1
--- /dev/null
+++ b/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_db2.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Call erase(const_iterator position) with iterator from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <cassert>
+#include <cstdlib>
+#include <exception>
+
+int main()
+{
+ {
+ typedef std::pair<int, int> P;
+ P a1[] = {P(1, 1), P(2, 2), P(3, 3)};
+ std::unordered_map<int, int> l1(a1, a1+3);
+ std::unordered_map<int, int> l2(a1, a1+3);
+ std::unordered_map<int, int>::const_iterator i = l2.begin();
+ l1.erase(i);
+ assert(false);
+ }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db1.pass.cpp b/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db1.pass.cpp
new file mode 100644
index 000000000000..81a8d3de1576
--- /dev/null
+++ b/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db1.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Call erase(const_iterator first, const_iterator last); with first iterator from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+int main()
+{
+ {
+ typedef std::pair<int, int> P;
+ P a1[] = {P(1, 1), P(2, 2), P(3, 3)};
+ std::unordered_map<int, int> l1(a1, a1+3);
+ std::unordered_map<int, int> l2(a1, a1+3);
+ std::unordered_map<int, int>::iterator i = l1.erase(l2.cbegin(), next(l1.cbegin()));
+ assert(false);
+ }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db2.pass.cpp b/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db2.pass.cpp
new file mode 100644
index 000000000000..4b103a0ad75c
--- /dev/null
+++ b/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db2.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Call erase(const_iterator first, const_iterator last); with second iterator from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+int main()
+{
+ {
+ typedef std::pair<int, int> P;
+ P a1[] = {P(1, 1), P(2, 2), P(3, 3)};
+ std::unordered_map<int, int> l1(a1, a1+3);
+ std::unordered_map<int, int> l2(a1, a1+3);
+ std::unordered_map<int, int>::iterator i = l1.erase(l1.cbegin(), next(l2.cbegin()));
+ assert(false);
+ }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db3.pass.cpp b/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db3.pass.cpp
new file mode 100644
index 000000000000..6ef1e07add1e
--- /dev/null
+++ b/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db3.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Call erase(const_iterator first, const_iterator last); with both iterators from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+int main()
+{
+ {
+ typedef std::pair<int, int> P;
+ P a1[] = {P(1, 1), P(2, 2), P(3, 3)};
+ std::unordered_map<int, int> l1(a1, a1+3);
+ std::unordered_map<int, int> l2(a1, a1+3);
+ std::unordered_map<int, int>::iterator i = l1.erase(l2.cbegin(), next(l2.cbegin()));
+ assert(false);
+ }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db4.pass.cpp b/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db4.pass.cpp
new file mode 100644
index 000000000000..1185ddf8fd4a
--- /dev/null
+++ b/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db4.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Call erase(const_iterator first, const_iterator last); with a bad range
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+int main()
+{
+ {
+ typedef std::pair<int, int> P;
+ P a1[] = {P(1, 1), P(2, 2), P(3, 3)};
+ std::unordered_map<int, int> l1(a1, a1+3);
+ std::unordered_map<int, int>::iterator i = l1.erase(next(l1.cbegin()), l1.cbegin());
+ assert(false);
+ }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_key.pass.cpp b/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_key.pass.cpp
new file mode 100644
index 000000000000..0e8ef8b895a7
--- /dev/null
+++ b/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_key.pass.cpp
@@ -0,0 +1,177 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// size_type erase(const key_type& k);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+#if __cplusplus >= 201103L
+template <typename Unordered>
+bool only_deletions ( const Unordered &whole, const Unordered &part ) {
+ typename Unordered::const_iterator w = whole.begin();
+ typename Unordered::const_iterator p = part.begin();
+
+ while ( w != whole.end () && p != part.end()) {
+ if ( *w == *p )
+ p++;
+ w++;
+ }
+
+ return p == part.end();
+}
+#endif
+
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.erase(5) == 0);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+
+ assert(c.erase(2) == 1);
+ assert(c.size() == 3);
+ assert(c.at(1) == "one");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+
+ assert(c.erase(2) == 0);
+ assert(c.size() == 3);
+ assert(c.at(1) == "one");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+
+ assert(c.erase(4) == 1);
+ assert(c.size() == 2);
+ assert(c.at(1) == "one");
+ assert(c.at(3) == "three");
+
+ assert(c.erase(4) == 0);
+ assert(c.size() == 2);
+ assert(c.at(1) == "one");
+ assert(c.at(3) == "three");
+
+ assert(c.erase(1) == 1);
+ assert(c.size() == 1);
+ assert(c.at(3) == "three");
+
+ assert(c.erase(1) == 0);
+ assert(c.size() == 1);
+ assert(c.at(3) == "three");
+
+ assert(c.erase(3) == 1);
+ assert(c.size() == 0);
+
+ assert(c.erase(3) == 0);
+ assert(c.size() == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.erase(5) == 0);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+
+ assert(c.erase(2) == 1);
+ assert(c.size() == 3);
+ assert(c.at(1) == "one");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+
+ assert(c.erase(2) == 0);
+ assert(c.size() == 3);
+ assert(c.at(1) == "one");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+
+ assert(c.erase(4) == 1);
+ assert(c.size() == 2);
+ assert(c.at(1) == "one");
+ assert(c.at(3) == "three");
+
+ assert(c.erase(4) == 0);
+ assert(c.size() == 2);
+ assert(c.at(1) == "one");
+ assert(c.at(3) == "three");
+
+ assert(c.erase(1) == 1);
+ assert(c.size() == 1);
+ assert(c.at(3) == "three");
+
+ assert(c.erase(1) == 0);
+ assert(c.size() == 1);
+ assert(c.at(3) == "three");
+
+ assert(c.erase(3) == 1);
+ assert(c.size() == 0);
+
+ assert(c.erase(3) == 0);
+ assert(c.size() == 0);
+ }
+ {
+ typedef std::unordered_map<int, int> C;
+ C m, m2;
+ for ( int i = 0; i < 10; ++i ) {
+ m[i] = i;
+ m2[i] = i;
+ }
+
+ C::iterator i = m2.begin();
+ int ctr = 0;
+ while (i != m2.end()) {
+ if (ctr++ % 2 == 0)
+ m2.erase(i++);
+ else
+ ++i;
+ }
+
+ assert (only_deletions (m, m2));
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_range.pass.cpp b/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_range.pass.cpp
new file mode 100644
index 000000000000..f0664c3c3ffc
--- /dev/null
+++ b/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_range.pass.cpp
@@ -0,0 +1,99 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// iterator erase(const_iterator first, const_iterator last)
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ C::const_iterator i = c.find(2);
+ C::const_iterator j = next(i, 1);
+ C::iterator k = c.erase(i, i);
+ assert(k == i);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+
+ k = c.erase(i, j);
+ assert(c.size() == 3);
+ assert(k == j);
+ assert(c.at(1) == "one");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+
+ k = c.erase(c.cbegin(), c.cend());
+ assert(k == c.cend());
+ assert(c.size() == 0);
+ assert(k == c.end());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ C::const_iterator i = c.find(2);
+ C::const_iterator j = next(i, 1);
+ C::iterator k = c.erase(i, i);
+ assert(k == i);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+
+ k = c.erase(i, j);
+ assert(c.size() == 3);
+ assert(k == j);
+ assert(c.at(1) == "one");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+
+ k = c.erase(c.cbegin(), c.cend());
+ assert(k == c.cend());
+ assert(c.size() == 0);
+ assert(k == c.end());
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.map/unorder.map.modifiers/insert_const_lvalue.pass.cpp b/test/std/containers/unord/unord.map/unorder.map.modifiers/insert_const_lvalue.pass.cpp
new file mode 100644
index 000000000000..a16f097b4c01
--- /dev/null
+++ b/test/std/containers/unord/unord.map/unorder.map.modifiers/insert_const_lvalue.pass.cpp
@@ -0,0 +1,86 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// pair<iterator, bool> insert(const value_type& x);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<double, int> C;
+ typedef std::pair<C::iterator, bool> R;
+ typedef C::value_type P;
+ C c;
+ R r = c.insert(P(3.5, 3));
+ assert(r.second);
+ assert(c.size() == 1);
+ assert(r.first->first == 3.5);
+ assert(r.first->second == 3);
+
+ r = c.insert(P(3.5, 4));
+ assert(!r.second);
+ assert(c.size() == 1);
+ assert(r.first->first == 3.5);
+ assert(r.first->second == 3);
+
+ r = c.insert(P(4.5, 4));
+ assert(r.second);
+ assert(c.size() == 2);
+ assert(r.first->first == 4.5);
+ assert(r.first->second == 4);
+
+ r = c.insert(P(5.5, 4));
+ assert(r.second);
+ assert(c.size() == 3);
+ assert(r.first->first == 5.5);
+ assert(r.first->second == 4);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<double, int, std::hash<double>, std::equal_to<double>,
+ min_allocator<std::pair<const double, int>>> C;
+ typedef std::pair<C::iterator, bool> R;
+ typedef C::value_type P;
+ C c;
+ R r = c.insert(P(3.5, 3));
+ assert(r.second);
+ assert(c.size() == 1);
+ assert(r.first->first == 3.5);
+ assert(r.first->second == 3);
+
+ r = c.insert(P(3.5, 4));
+ assert(!r.second);
+ assert(c.size() == 1);
+ assert(r.first->first == 3.5);
+ assert(r.first->second == 3);
+
+ r = c.insert(P(4.5, 4));
+ assert(r.second);
+ assert(c.size() == 2);
+ assert(r.first->first == 4.5);
+ assert(r.first->second == 4);
+
+ r = c.insert(P(5.5, 4));
+ assert(r.second);
+ assert(c.size() == 3);
+ assert(r.first->first == 5.5);
+ assert(r.first->second == 4);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.map/unorder.map.modifiers/insert_hint_const_lvalue.pass.cpp b/test/std/containers/unord/unord.map/unorder.map.modifiers/insert_hint_const_lvalue.pass.cpp
new file mode 100644
index 000000000000..981b8fb18a0a
--- /dev/null
+++ b/test/std/containers/unord/unord.map/unorder.map.modifiers/insert_hint_const_lvalue.pass.cpp
@@ -0,0 +1,97 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// iterator insert(const_iterator p, const value_type& x);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<double, int> C;
+ typedef C::iterator R;
+ typedef C::value_type P;
+ C c;
+ C::const_iterator e = c.end();
+ R r = c.insert(e, P(3.5, 3));
+ assert(c.size() == 1);
+ assert(r->first == 3.5);
+ assert(r->second == 3);
+
+ r = c.insert(c.end(), P(3.5, 4));
+ assert(c.size() == 1);
+ assert(r->first == 3.5);
+ assert(r->second == 3);
+
+ r = c.insert(c.end(), P(4.5, 4));
+ assert(c.size() == 2);
+ assert(r->first == 4.5);
+ assert(r->second == 4);
+
+ r = c.insert(c.end(), P(5.5, 4));
+ assert(c.size() == 3);
+ assert(r->first == 5.5);
+ assert(r->second == 4);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<double, int, std::hash<double>, std::equal_to<double>,
+ min_allocator<std::pair<const double, int>>> C;
+ typedef C::iterator R;
+ typedef C::value_type P;
+ C c;
+ C::const_iterator e = c.end();
+ R r = c.insert(e, P(3.5, 3));
+ assert(c.size() == 1);
+ assert(r->first == 3.5);
+ assert(r->second == 3);
+
+ r = c.insert(c.end(), P(3.5, 4));
+ assert(c.size() == 1);
+ assert(r->first == 3.5);
+ assert(r->second == 3);
+
+ r = c.insert(c.end(), P(4.5, 4));
+ assert(c.size() == 2);
+ assert(r->first == 4.5);
+ assert(r->second == 4);
+
+ r = c.insert(c.end(), P(5.5, 4));
+ assert(c.size() == 3);
+ assert(r->first == 5.5);
+ assert(r->second == 4);
+ }
+#endif
+#if _LIBCPP_DEBUG >= 1
+ {
+ typedef std::unordered_map<double, int> C;
+ typedef C::iterator R;
+ typedef C::value_type P;
+ C c;
+ C c2;
+ C::const_iterator e = c2.end();
+ P v(3.5, 3);
+ R r = c.insert(e, v);
+ assert(false);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.map/unorder.map.modifiers/insert_hint_rvalue.pass.cpp b/test/std/containers/unord/unord.map/unorder.map.modifiers/insert_hint_rvalue.pass.cpp
new file mode 100644
index 000000000000..1618c1019e1c
--- /dev/null
+++ b/test/std/containers/unord/unord.map/unorder.map.modifiers/insert_hint_rvalue.pass.cpp
@@ -0,0 +1,156 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// template <class P,
+// class = typename enable_if<is_convertible<P, value_type>::value>::type>
+// iterator insert(const_iterator p, P&& x);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_map>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<double, int> C;
+ typedef C::iterator R;
+ typedef std::pair<double, short> P;
+ C c;
+ C::const_iterator e = c.end();
+ R r = c.insert(e, P(3.5, 3));
+ assert(c.size() == 1);
+ assert(r->first == 3.5);
+ assert(r->second == 3);
+
+ r = c.insert(c.end(), P(3.5, 4));
+ assert(c.size() == 1);
+ assert(r->first == 3.5);
+ assert(r->second == 3);
+
+ r = c.insert(c.end(), P(4.5, 4));
+ assert(c.size() == 2);
+ assert(r->first == 4.5);
+ assert(r->second == 4);
+
+ r = c.insert(c.end(), P(5.5, 4));
+ assert(c.size() == 3);
+ assert(r->first == 5.5);
+ assert(r->second == 4);
+ }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly> C;
+ typedef C::iterator R;
+ typedef std::pair<MoveOnly, MoveOnly> P;
+ C c;
+ C::const_iterator e = c.end();
+ R r = c.insert(e, P(3, 3));
+ assert(c.size() == 1);
+ assert(r->first == 3);
+ assert(r->second == 3);
+
+ r = c.insert(c.end(), P(3, 4));
+ assert(c.size() == 1);
+ assert(r->first == 3);
+ assert(r->second == 3);
+
+ r = c.insert(c.end(), P(4, 4));
+ assert(c.size() == 2);
+ assert(r->first == 4);
+ assert(r->second == 4);
+
+ r = c.insert(c.end(), P(5, 4));
+ assert(c.size() == 3);
+ assert(r->first == 5);
+ assert(r->second == 4);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<double, int, std::hash<double>, std::equal_to<double>,
+ min_allocator<std::pair<const double, int>>> C;
+ typedef C::iterator R;
+ typedef std::pair<double, short> P;
+ C c;
+ C::const_iterator e = c.end();
+ R r = c.insert(e, P(3.5, 3));
+ assert(c.size() == 1);
+ assert(r->first == 3.5);
+ assert(r->second == 3);
+
+ r = c.insert(c.end(), P(3.5, 4));
+ assert(c.size() == 1);
+ assert(r->first == 3.5);
+ assert(r->second == 3);
+
+ r = c.insert(c.end(), P(4.5, 4));
+ assert(c.size() == 2);
+ assert(r->first == 4.5);
+ assert(r->second == 4);
+
+ r = c.insert(c.end(), P(5.5, 4));
+ assert(c.size() == 3);
+ assert(r->first == 5.5);
+ assert(r->second == 4);
+ }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>,
+ min_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+ typedef C::iterator R;
+ typedef std::pair<MoveOnly, MoveOnly> P;
+ C c;
+ C::const_iterator e = c.end();
+ R r = c.insert(e, P(3, 3));
+ assert(c.size() == 1);
+ assert(r->first == 3);
+ assert(r->second == 3);
+
+ r = c.insert(c.end(), P(3, 4));
+ assert(c.size() == 1);
+ assert(r->first == 3);
+ assert(r->second == 3);
+
+ r = c.insert(c.end(), P(4, 4));
+ assert(c.size() == 2);
+ assert(r->first == 4);
+ assert(r->second == 4);
+
+ r = c.insert(c.end(), P(5, 4));
+ assert(c.size() == 3);
+ assert(r->first == 5);
+ assert(r->second == 4);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if _LIBCPP_DEBUG >= 1
+ {
+ typedef std::unordered_map<double, int> C;
+ typedef C::iterator R;
+ typedef C::value_type P;
+ C c;
+ C c2;
+ C::const_iterator e = c2.end();
+ R r = c.insert(e, P(3.5, 3));
+ assert(false);
+ }
+#endif
+#endif
+}
diff --git a/test/std/containers/unord/unord.map/unorder.map.modifiers/insert_init.pass.cpp b/test/std/containers/unord/unord.map/unorder.map.modifiers/insert_init.pass.cpp
new file mode 100644
index 000000000000..81e8a468d83f
--- /dev/null
+++ b/test/std/containers/unord/unord.map/unorder.map.modifiers/insert_init.pass.cpp
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// void insert(initializer_list<value_type> il);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ C c;
+ c.insert(
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ }
+ );
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ C c;
+ c.insert(
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ }
+ );
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/containers/unord/unord.map/unorder.map.modifiers/insert_or_assign.pass.cpp b/test/std/containers/unord/unord.map/unorder.map.modifiers/insert_or_assign.pass.cpp
new file mode 100644
index 000000000000..89929c856ec9
--- /dev/null
+++ b/test/std/containers/unord/unord.map/unorder.map.modifiers/insert_or_assign.pass.cpp
@@ -0,0 +1,198 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: c++03, c++11, c++14
+
+// <unordered_map>
+
+// class unordered_map
+
+// template <class M>
+// pair<iterator, bool> insert_or_assign(const key_type& k, M&& obj); // C++17
+// template <class M>
+// pair<iterator, bool> insert_or_assign(key_type&& k, M&& obj); // C++17
+// template <class M>
+// iterator insert_or_assign(const_iterator hint, const key_type& k, M&& obj); // C++17
+// template <class M>
+// iterator insert_or_assign(const_iterator hint, key_type&& k, M&& obj); // C++17
+
+#include <__config>
+#include <unordered_map>
+#include <cassert>
+#include <tuple>
+
+#include <iostream>
+
+class Moveable
+{
+ Moveable(const Moveable&);
+ Moveable& operator=(const Moveable&);
+
+ int int_;
+ double double_;
+public:
+ Moveable() : int_(0), double_(0) {}
+ Moveable(int i, double d) : int_(i), double_(d) {}
+ Moveable(Moveable&& x)
+ : int_(x.int_), double_(x.double_)
+ {x.int_ = -1; x.double_ = -1;}
+ Moveable& operator=(Moveable&& x)
+ {int_ = x.int_; x.int_ = -1;
+ double_ = x.double_; x.double_ = -1;
+ return *this;
+ }
+
+ bool operator==(const Moveable& x) const
+ {return int_ == x.int_ && double_ == x.double_;}
+ bool operator<(const Moveable& x) const
+ {return int_ < x.int_ || (int_ == x.int_ && double_ < x.double_);}
+ size_t hash () const { return std::hash<int>()(int_) + std::hash<double>()(double_); }
+
+ int get() const {return int_;}
+ bool moved() const {return int_ == -1;}
+};
+
+namespace std {
+ template <> struct hash<Moveable> {
+ size_t operator () (const Moveable &m) const { return m.hash(); }
+ };
+}
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+
+ { // pair<iterator, bool> insert_or_assign(const key_type& k, M&& obj);
+ typedef std::unordered_map<int, Moveable> M;
+ typedef std::pair<M::iterator, bool> R;
+ M m;
+ R r;
+ for (int i = 0; i < 20; i += 2)
+ m.emplace ( i, Moveable(i, (double) i));
+ assert(m.size() == 10);
+
+ for (int i=0; i < 20; i += 2)
+ {
+ Moveable mv(i+1, i+1);
+ r = m.insert_or_assign(i, std::move(mv));
+ assert(m.size() == 10);
+ assert(!r.second); // was not inserted
+ assert(mv.moved()); // was moved from
+ assert(r.first->first == i); // key
+ assert(r.first->second.get() == i+1); // value
+ }
+
+ Moveable mv1(5, 5.0);
+ r = m.insert_or_assign(-1, std::move(mv1));
+ assert(m.size() == 11);
+ assert(r.second); // was inserted
+ assert(mv1.moved()); // was moved from
+ assert(r.first->first == -1); // key
+ assert(r.first->second.get() == 5); // value
+
+ Moveable mv2(9, 9.0);
+ r = m.insert_or_assign(3, std::move(mv2));
+ assert(m.size() == 12);
+ assert(r.second); // was inserted
+ assert(mv2.moved()); // was moved from
+ assert(r.first->first == 3); // key
+ assert(r.first->second.get() == 9); // value
+
+ Moveable mv3(-1, 5.0);
+ r = m.insert_or_assign(117, std::move(mv3));
+ assert(m.size() == 13);
+ assert(r.second); // was inserted
+ assert(mv3.moved()); // was moved from
+ assert(r.first->first == 117); // key
+ assert(r.first->second.get() == -1); // value
+ }
+ { // pair<iterator, bool> insert_or_assign(key_type&& k, M&& obj);
+ typedef std::unordered_map<Moveable, Moveable> M;
+ typedef std::pair<M::iterator, bool> R;
+ M m;
+ R r;
+ for (int i = 0; i < 20; i += 2)
+ m.emplace ( Moveable(i, (double) i), Moveable(i+1, (double) i+1));
+ assert(m.size() == 10);
+
+ Moveable mvkey1(2, 2.0);
+ Moveable mv1(4, 4.0);
+ r = m.insert_or_assign(std::move(mvkey1), std::move(mv1));
+ assert(m.size() == 10);
+ assert(!r.second); // was not inserted
+ assert(!mvkey1.moved()); // was not moved from
+ assert(mv1.moved()); // was moved from
+ assert(r.first->first == mvkey1); // key
+ assert(r.first->second.get() == 4); // value
+
+ Moveable mvkey2(3, 3.0);
+ Moveable mv2(5, 5.0);
+ r = m.try_emplace(std::move(mvkey2), std::move(mv2));
+ assert(m.size() == 11);
+ assert(r.second); // was inserted
+ assert(mv2.moved()); // was moved from
+ assert(mvkey2.moved()); // was moved from
+ assert(r.first->first.get() == 3); // key
+ assert(r.first->second.get() == 5); // value
+ }
+ { // iterator insert_or_assign(const_iterator hint, const key_type& k, M&& obj);
+ typedef std::unordered_map<int, Moveable> M;
+ M m;
+ M::iterator r;
+ for (int i = 0; i < 20; i += 2)
+ m.emplace ( i, Moveable(i, (double) i));
+ assert(m.size() == 10);
+ M::const_iterator it = m.find(2);
+
+ Moveable mv1(3, 3.0);
+ r = m.insert_or_assign(it, 2, std::move(mv1));
+ assert(m.size() == 10);
+ assert(mv1.moved()); // was moved from
+ assert(r->first == 2); // key
+ assert(r->second.get() == 3); // value
+
+ Moveable mv2(5, 5.0);
+ r = m.insert_or_assign(it, 3, std::move(mv2));
+ assert(m.size() == 11);
+ assert(mv2.moved()); // was moved from
+ assert(r->first == 3); // key
+ assert(r->second.get() == 5); // value
+ }
+ { // iterator insert_or_assign(const_iterator hint, key_type&& k, M&& obj);
+ typedef std::unordered_map<Moveable, Moveable> M;
+ M m;
+ M::iterator r;
+ for (int i = 0; i < 20; i += 2)
+ m.emplace ( Moveable(i, (double) i), Moveable(i+1, (double) i+1));
+ assert(m.size() == 10);
+ M::const_iterator it = std::next(m.cbegin());
+
+ Moveable mvkey1(2, 2.0);
+ Moveable mv1(4, 4.0);
+ r = m.insert_or_assign(it, std::move(mvkey1), std::move(mv1));
+ assert(m.size() == 10);
+ assert(mv1.moved()); // was moved from
+ assert(!mvkey1.moved()); // was not moved from
+ assert(r->first == mvkey1); // key
+ assert(r->second.get() == 4); // value
+
+ Moveable mvkey2(3, 3.0);
+ Moveable mv2(5, 5.0);
+ r = m.insert_or_assign(it, std::move(mvkey2), std::move(mv2));
+ assert(m.size() == 11);
+ assert(mv2.moved()); // was moved from
+ assert(mvkey2.moved()); // was moved from
+ assert(r->first.get() == 3); // key
+ assert(r->second.get() == 5); // value
+ }
+
+#endif // _LIBCPP_HAS_NO_VARIADICS
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+} \ No newline at end of file
diff --git a/test/std/containers/unord/unord.map/unorder.map.modifiers/insert_range.pass.cpp b/test/std/containers/unord/unord.map/unorder.map.modifiers/insert_range.pass.cpp
new file mode 100644
index 000000000000..fc44e7828ffa
--- /dev/null
+++ b/test/std/containers/unord/unord.map/unorder.map.modifiers/insert_range.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// template <class InputIterator>
+// void insert(InputIterator first, InputIterator last);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c;
+ c.insert(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])));
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c;
+ c.insert(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])));
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.map/unorder.map.modifiers/insert_rvalue.pass.cpp b/test/std/containers/unord/unord.map/unorder.map.modifiers/insert_rvalue.pass.cpp
new file mode 100644
index 000000000000..f53dc6c7e97a
--- /dev/null
+++ b/test/std/containers/unord/unord.map/unorder.map.modifiers/insert_rvalue.pass.cpp
@@ -0,0 +1,152 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// template <class P,
+// class = typename enable_if<is_convertible<P, value_type>::value>::type>
+// pair<iterator, bool> insert(P&& x);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<double, int> C;
+ typedef std::pair<C::iterator, bool> R;
+ typedef std::pair<double, short> P;
+ C c;
+ R r = c.insert(P(3.5, 3));
+ assert(r.second);
+ assert(c.size() == 1);
+ assert(r.first->first == 3.5);
+ assert(r.first->second == 3);
+
+ r = c.insert(P(3.5, 4));
+ assert(!r.second);
+ assert(c.size() == 1);
+ assert(r.first->first == 3.5);
+ assert(r.first->second == 3);
+
+ r = c.insert(P(4.5, 4));
+ assert(r.second);
+ assert(c.size() == 2);
+ assert(r.first->first == 4.5);
+ assert(r.first->second == 4);
+
+ r = c.insert(P(5.5, 4));
+ assert(r.second);
+ assert(c.size() == 3);
+ assert(r.first->first == 5.5);
+ assert(r.first->second == 4);
+ }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly> C;
+ typedef std::pair<C::iterator, bool> R;
+ typedef std::pair<MoveOnly, MoveOnly> P;
+ C c;
+ R r = c.insert(P(3, 3));
+ assert(r.second);
+ assert(c.size() == 1);
+ assert(r.first->first == 3);
+ assert(r.first->second == 3);
+
+ r = c.insert(P(3, 4));
+ assert(!r.second);
+ assert(c.size() == 1);
+ assert(r.first->first == 3);
+ assert(r.first->second == 3);
+
+ r = c.insert(P(4, 4));
+ assert(r.second);
+ assert(c.size() == 2);
+ assert(r.first->first == 4);
+ assert(r.first->second == 4);
+
+ r = c.insert(P(5, 4));
+ assert(r.second);
+ assert(c.size() == 3);
+ assert(r.first->first == 5);
+ assert(r.first->second == 4);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<double, int, std::hash<double>, std::equal_to<double>,
+ min_allocator<std::pair<const double, int>>> C;
+ typedef std::pair<C::iterator, bool> R;
+ typedef std::pair<double, short> P;
+ C c;
+ R r = c.insert(P(3.5, 3));
+ assert(r.second);
+ assert(c.size() == 1);
+ assert(r.first->first == 3.5);
+ assert(r.first->second == 3);
+
+ r = c.insert(P(3.5, 4));
+ assert(!r.second);
+ assert(c.size() == 1);
+ assert(r.first->first == 3.5);
+ assert(r.first->second == 3);
+
+ r = c.insert(P(4.5, 4));
+ assert(r.second);
+ assert(c.size() == 2);
+ assert(r.first->first == 4.5);
+ assert(r.first->second == 4);
+
+ r = c.insert(P(5.5, 4));
+ assert(r.second);
+ assert(c.size() == 3);
+ assert(r.first->first == 5.5);
+ assert(r.first->second == 4);
+ }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>,
+ min_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+ typedef std::pair<C::iterator, bool> R;
+ typedef std::pair<MoveOnly, MoveOnly> P;
+ C c;
+ R r = c.insert(P(3, 3));
+ assert(r.second);
+ assert(c.size() == 1);
+ assert(r.first->first == 3);
+ assert(r.first->second == 3);
+
+ r = c.insert(P(3, 4));
+ assert(!r.second);
+ assert(c.size() == 1);
+ assert(r.first->first == 3);
+ assert(r.first->second == 3);
+
+ r = c.insert(P(4, 4));
+ assert(r.second);
+ assert(c.size() == 2);
+ assert(r.first->first == 4);
+ assert(r.first->second == 4);
+
+ r = c.insert(P(5, 4));
+ assert(r.second);
+ assert(c.size() == 3);
+ assert(r.first->first == 5);
+ assert(r.first->second == 4);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif
+}
diff --git a/test/std/containers/unord/unord.map/unorder.map.modifiers/try.emplace.pass.cpp b/test/std/containers/unord/unord.map/unorder.map.modifiers/try.emplace.pass.cpp
new file mode 100644
index 000000000000..e6964ce947b5
--- /dev/null
+++ b/test/std/containers/unord/unord.map/unorder.map.modifiers/try.emplace.pass.cpp
@@ -0,0 +1,195 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: c++03, c++11, c++14
+
+// <unordered_map>
+
+// class unordered_map
+
+// template <class... Args>
+// pair<iterator, bool> try_emplace(const key_type& k, Args&&... args); // C++17
+// template <class... Args>
+// pair<iterator, bool> try_emplace(key_type&& k, Args&&... args); // C++17
+// template <class... Args>
+// iterator try_emplace(const_iterator hint, const key_type& k, Args&&... args); // C++17
+// template <class... Args>
+// iterator try_emplace(const_iterator hint, key_type&& k, Args&&... args); // C++17
+
+#include <__config>
+#include <unordered_map>
+#include <cassert>
+#include <tuple>
+
+class Moveable
+{
+ Moveable(const Moveable&);
+ Moveable& operator=(const Moveable&);
+
+ int int_;
+ double double_;
+public:
+ Moveable() : int_(0), double_(0) {}
+ Moveable(int i, double d) : int_(i), double_(d) {}
+ Moveable(Moveable&& x)
+ : int_(x.int_), double_(x.double_)
+ {x.int_ = -1; x.double_ = -1;}
+ Moveable& operator=(Moveable&& x)
+ {int_ = x.int_; x.int_ = -1;
+ double_ = x.double_; x.double_ = -1;
+ return *this;
+ }
+
+ bool operator==(const Moveable& x) const
+ {return int_ == x.int_ && double_ == x.double_;}
+ bool operator<(const Moveable& x) const
+ {return int_ < x.int_ || (int_ == x.int_ && double_ < x.double_);}
+ size_t hash () const { return std::hash<int>()(int_) + std::hash<double>()(double_); }
+
+ int get() const {return int_;}
+ bool moved() const {return int_ == -1;}
+};
+
+namespace std {
+ template <> struct hash<Moveable> {
+ size_t operator () (const Moveable &m) const { return m.hash(); }
+ };
+}
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+
+ { // pair<iterator, bool> try_emplace(const key_type& k, Args&&... args);
+ typedef std::unordered_map<int, Moveable> M;
+ typedef std::pair<M::iterator, bool> R;
+ M m;
+ R r;
+ for (int i = 0; i < 20; i += 2)
+ m.emplace (i, Moveable(i, (double) i));
+ assert(m.size() == 10);
+
+ Moveable mv1(3, 3.0);
+ for (int i=0; i < 20; i += 2)
+ {
+ r = m.try_emplace(i, std::move(mv1));
+ assert(m.size() == 10);
+ assert(!r.second); // was not inserted
+ assert(!mv1.moved()); // was not moved from
+ assert(r.first->first == i); // key
+ }
+
+ r = m.try_emplace(-1, std::move(mv1));
+ assert(m.size() == 11);
+ assert(r.second); // was inserted
+ assert(mv1.moved()); // was moved from
+ assert(r.first->first == -1); // key
+ assert(r.first->second.get() == 3); // value
+
+ Moveable mv2(5, 3.0);
+ r = m.try_emplace(5, std::move(mv2));
+ assert(m.size() == 12);
+ assert(r.second); // was inserted
+ assert(mv2.moved()); // was moved from
+ assert(r.first->first == 5); // key
+ assert(r.first->second.get() == 5); // value
+
+ Moveable mv3(-1, 3.0);
+ r = m.try_emplace(117, std::move(mv2));
+ assert(m.size() == 13);
+ assert(r.second); // was inserted
+ assert(mv2.moved()); // was moved from
+ assert(r.first->first == 117); // key
+ assert(r.first->second.get() == -1); // value
+ }
+
+ { // pair<iterator, bool> try_emplace(key_type&& k, Args&&... args);
+ typedef std::unordered_map<Moveable, Moveable> M;
+ typedef std::pair<M::iterator, bool> R;
+ M m;
+ R r;
+ for (int i = 0; i < 20; i += 2)
+ m.emplace ( Moveable(i, (double) i), Moveable(i+1, (double) i+1));
+ assert(m.size() == 10);
+
+ Moveable mvkey1(2, 2.0);
+ Moveable mv1(4, 4.0);
+ r = m.try_emplace(std::move(mvkey1), std::move(mv1));
+ assert(m.size() == 10);
+ assert(!r.second); // was not inserted
+ assert(!mv1.moved()); // was not moved from
+ assert(!mvkey1.moved()); // was not moved from
+ assert(r.first->first == mvkey1); // key
+
+ Moveable mvkey2(3, 3.0);
+ r = m.try_emplace(std::move(mvkey2), std::move(mv1));
+ assert(m.size() == 11);
+ assert(r.second); // was inserted
+ assert(mv1.moved()); // was moved from
+ assert(mvkey2.moved()); // was moved from
+ assert(r.first->first.get() == 3); // key
+ assert(r.first->second.get() == 4); // value
+ }
+
+ { // iterator try_emplace(const_iterator hint, const key_type& k, Args&&... args);
+ typedef std::unordered_map<int, Moveable> M;
+ M m;
+ M::iterator r;
+ for (int i = 0; i < 20; i += 2)
+ m.try_emplace ( i, Moveable(i, (double) i));
+ assert(m.size() == 10);
+ M::const_iterator it = m.find(2);
+
+ Moveable mv1(3, 3.0);
+ for (int i=0; i < 20; i += 2)
+ {
+ r = m.try_emplace(it, i, std::move(mv1));
+ assert(m.size() == 10);
+ assert(!mv1.moved()); // was not moved from
+ assert(r->first == i); // key
+ assert(r->second.get() == i); // value
+ }
+
+ r = m.try_emplace(it, 3, std::move(mv1));
+ assert(m.size() == 11);
+ assert(mv1.moved()); // was moved from
+ assert(r->first == 3); // key
+ assert(r->second.get() == 3); // value
+ }
+
+ { // iterator try_emplace(const_iterator hint, key_type&& k, Args&&... args);
+ typedef std::unordered_map<Moveable, Moveable> M;
+ M m;
+ M::iterator r;
+ for ( int i = 0; i < 20; i += 2 )
+ m.emplace ( Moveable(i, (double) i), Moveable(i+1, (double) i+1));
+ assert(m.size() == 10);
+ M::const_iterator it = std::next(m.cbegin());
+
+ Moveable mvkey1(2, 2.0);
+ Moveable mv1(4, 4.0);
+ r = m.try_emplace(it, std::move(mvkey1), std::move(mv1));
+ assert(m.size() == 10);
+ assert(!mv1.moved()); // was not moved from
+ assert(!mvkey1.moved()); // was not moved from
+ assert(r->first == mvkey1); // key
+
+ Moveable mvkey2(3, 3.0);
+ r = m.try_emplace(it, std::move(mvkey2), std::move(mv1));
+ assert(m.size() == 11);
+ assert(mv1.moved()); // was moved from
+ assert(mvkey2.moved()); // was moved from
+ assert(r->first.get() == 3); // key
+ assert(r->second.get() == 4); // value
+ }
+
+#endif // _LIBCPP_HAS_NO_VARIADICS
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/unord/unord.map/version.pass.cpp b/test/std/containers/unord/unord.map/version.pass.cpp
new file mode 100644
index 000000000000..fc47a326c571
--- /dev/null
+++ b/test/std/containers/unord/unord.map/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+#include <unordered_map>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/containers/unord/unord.multimap/bucket.pass.cpp b/test/std/containers/unord/unord.multimap/bucket.pass.cpp
new file mode 100644
index 000000000000..be5acc196308
--- /dev/null
+++ b/test/std/containers/unord/unord.multimap/bucket.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// size_type bucket(const key_type& __k) const;
+
+#ifdef _LIBCPP_DEBUG
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ const C c(std::begin(a), std::end(a));
+ size_t bc = c.bucket_count();
+ assert(bc >= 7);
+ for (size_t i = 0; i < 13; ++i)
+ assert(c.bucket(i) == i % bc);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ const C c(std::begin(a), std::end(a));
+ size_t bc = c.bucket_count();
+ assert(bc >= 7);
+ for (size_t i = 0; i < 13; ++i)
+ assert(c.bucket(i) == i % bc);
+ }
+#endif
+#if _LIBCPP_DEBUG_LEVEL >= 1
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ C c;
+ C::size_type i = c.bucket(3);
+ assert(false);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multimap/bucket_count.pass.cpp b/test/std/containers/unord/unord.multimap/bucket_count.pass.cpp
new file mode 100644
index 000000000000..d44412fedf6d
--- /dev/null
+++ b/test/std/containers/unord/unord.multimap/bucket_count.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// size_type bucket_count() const;
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef C::const_iterator I;
+ typedef std::pair<int, std::string> P;
+ const C c;
+ assert(c.bucket_count() == 0);
+ }
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef C::const_iterator I;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ const C c(std::begin(a), std::end(a));
+ assert(c.bucket_count() >= 11);
+ }
+}
diff --git a/test/std/containers/unord/unord.multimap/bucket_size.pass.cpp b/test/std/containers/unord/unord.multimap/bucket_size.pass.cpp
new file mode 100644
index 000000000000..a02f72efc6c2
--- /dev/null
+++ b/test/std/containers/unord/unord.multimap/bucket_size.pass.cpp
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// size_type bucket_size(size_type n) const
+
+#ifdef _LIBCPP_DEBUG
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ const C c(std::begin(a), std::end(a));
+ assert(c.bucket_count() >= 7);
+ assert(c.bucket_size(0) == 0);
+ assert(c.bucket_size(1) == 2);
+ assert(c.bucket_size(2) == 2);
+ assert(c.bucket_size(3) == 1);
+ assert(c.bucket_size(4) == 1);
+ assert(c.bucket_size(5) == 0);
+ assert(c.bucket_size(6) == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ const C c(std::begin(a), std::end(a));
+ assert(c.bucket_count() >= 7);
+ assert(c.bucket_size(0) == 0);
+ assert(c.bucket_size(1) == 2);
+ assert(c.bucket_size(2) == 2);
+ assert(c.bucket_size(3) == 1);
+ assert(c.bucket_size(4) == 1);
+ assert(c.bucket_size(5) == 0);
+ assert(c.bucket_size(6) == 0);
+ }
+#endif
+#if _LIBCPP_DEBUG_LEVEL >= 1
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ C c;
+ C::size_type i = c.bucket_size(3);
+ assert(false);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multimap/count.pass.cpp b/test/std/containers/unord/unord.multimap/count.pass.cpp
new file mode 100644
index 000000000000..efaf02e3a572
--- /dev/null
+++ b/test/std/containers/unord/unord.multimap/count.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// size_type count(const key_type& k) const;
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(50, "fiftyA"),
+ P(50, "fiftyB"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ const C c(std::begin(a), std::end(a));
+ assert(c.count(30) == 1);
+ assert(c.count(50) == 3);
+ assert(c.count(5) == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(50, "fiftyA"),
+ P(50, "fiftyB"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ const C c(std::begin(a), std::end(a));
+ assert(c.count(30) == 1);
+ assert(c.count(50) == 3);
+ assert(c.count(5) == 0);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multimap/db_iterators_7.pass.cpp b/test/std/containers/unord/unord.multimap/db_iterators_7.pass.cpp
new file mode 100644
index 000000000000..b6ba8d6194a4
--- /dev/null
+++ b/test/std/containers/unord/unord.multimap/db_iterators_7.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Increment iterator past end.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ C c;
+ c.insert(std::make_pair(1, "one"));
+ C::iterator i = c.begin();
+ ++i;
+ assert(i == c.end());
+ ++i;
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ C c;
+ c.insert(std::make_pair(1, "one"));
+ C::iterator i = c.begin();
+ ++i;
+ assert(i == c.end());
+ ++i;
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/containers/unord/unord.multimap/db_iterators_8.pass.cpp b/test/std/containers/unord/unord.multimap/db_iterators_8.pass.cpp
new file mode 100644
index 000000000000..f5ea5089349b
--- /dev/null
+++ b/test/std/containers/unord/unord.multimap/db_iterators_8.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Dereference non-dereferenceable iterator.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ C c;
+ c.insert(std::make_pair(1, "one"));
+ C::iterator i = c.end();
+ C::value_type j = *i;
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ C c;
+ c.insert(std::make_pair(1, "one"));
+ C::iterator i = c.end();
+ C::value_type j = *i;
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/containers/unord/unord.multimap/db_local_iterators_7.pass.cpp b/test/std/containers/unord/unord.multimap/db_local_iterators_7.pass.cpp
new file mode 100644
index 000000000000..93cbd5433f47
--- /dev/null
+++ b/test/std/containers/unord/unord.multimap/db_local_iterators_7.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Increment local_iterator past end.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ C c(1);
+ C::local_iterator i = c.begin(0);
+ ++i;
+ ++i;
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ C c(1);
+ C::local_iterator i = c.begin(0);
+ ++i;
+ ++i;
+ assert(false);
+ }
+#endif
+
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/containers/unord/unord.multimap/db_local_iterators_8.pass.cpp b/test/std/containers/unord/unord.multimap/db_local_iterators_8.pass.cpp
new file mode 100644
index 000000000000..159ae4963532
--- /dev/null
+++ b/test/std/containers/unord/unord.multimap/db_local_iterators_8.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Dereference non-dereferenceable iterator.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ C c(1);
+ C::local_iterator i = c.end(0);
+ C::value_type j = *i;
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ C c(1);
+ C::local_iterator i = c.end(0);
+ C::value_type j = *i;
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/containers/unord/unord.multimap/eq.pass.cpp b/test/std/containers/unord/unord.multimap/eq.pass.cpp
new file mode 100644
index 000000000000..3604e7792c13
--- /dev/null
+++ b/test/std/containers/unord/unord.multimap/eq.pass.cpp
@@ -0,0 +1,181 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash, class Pred, class Alloc>
+// bool
+// operator==(const unordered_multimap<Key, T, Hash, Pred, Alloc>& x,
+// const unordered_multimap<Key, T, Hash, Pred, Alloc>& y);
+//
+// template <class Key, class T, class Hash, class Pred, class Alloc>
+// bool
+// operator!=(const unordered_multimap<Key, T, Hash, Pred, Alloc>& x,
+// const unordered_multimap<Key, T, Hash, Pred, Alloc>& y);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(20, "twenty 2"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(50, "fifty 2"),
+ P(50, "fifty 3"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ const C c1(std::begin(a), std::end(a));
+ const C c2;
+ assert(!(c1 == c2));
+ assert( (c1 != c2));
+ }
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(20, "twenty 2"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(50, "fifty 2"),
+ P(50, "fifty 3"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ const C c1(std::begin(a), std::end(a));
+ const C c2 = c1;
+ assert( (c1 == c2));
+ assert(!(c1 != c2));
+ }
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(20, "twenty 2"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(50, "fifty 2"),
+ P(50, "fifty 3"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c1(std::begin(a), std::end(a));
+ C c2 = c1;
+ c2.rehash(30);
+ assert( (c1 == c2));
+ assert(!(c1 != c2));
+ c2.insert(P(90, "ninety"));
+ assert(!(c1 == c2));
+ assert( (c1 != c2));
+ c1.insert(P(90, "ninety"));
+ assert( (c1 == c2));
+ assert(!(c1 != c2));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(20, "twenty 2"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(50, "fifty 2"),
+ P(50, "fifty 3"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ const C c1(std::begin(a), std::end(a));
+ const C c2;
+ assert(!(c1 == c2));
+ assert( (c1 != c2));
+ }
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(20, "twenty 2"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(50, "fifty 2"),
+ P(50, "fifty 3"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ const C c1(std::begin(a), std::end(a));
+ const C c2 = c1;
+ assert( (c1 == c2));
+ assert(!(c1 != c2));
+ }
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(20, "twenty 2"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(50, "fifty 2"),
+ P(50, "fifty 3"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c1(std::begin(a), std::end(a));
+ C c2 = c1;
+ c2.rehash(30);
+ assert( (c1 == c2));
+ assert(!(c1 != c2));
+ c2.insert(P(90, "ninety"));
+ assert(!(c1 == c2));
+ assert( (c1 != c2));
+ c1.insert(P(90, "ninety"));
+ assert( (c1 == c2));
+ assert(!(c1 != c2));
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multimap/equal_range_const.pass.cpp b/test/std/containers/unord/unord.multimap/equal_range_const.pass.cpp
new file mode 100644
index 000000000000..67613b094bfc
--- /dev/null
+++ b/test/std/containers/unord/unord.multimap/equal_range_const.pass.cpp
@@ -0,0 +1,97 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef C::const_iterator I;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(50, "fiftyA"),
+ P(50, "fiftyB"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ const C c(std::begin(a), std::end(a));
+ std::pair<I, I> r = c.equal_range(30);
+ assert(std::distance(r.first, r.second) == 1);
+ assert(r.first->first == 30);
+ assert(r.first->second == "thirty");
+ r = c.equal_range(5);
+ assert(std::distance(r.first, r.second) == 0);
+ r = c.equal_range(50);
+ assert(r.first->first == 50);
+ assert(r.first->second == "fifty");
+ ++r.first;
+ assert(r.first->first == 50);
+ assert(r.first->second == "fiftyA");
+ ++r.first;
+ assert(r.first->first == 50);
+ assert(r.first->second == "fiftyB");
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef C::const_iterator I;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(50, "fiftyA"),
+ P(50, "fiftyB"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ const C c(std::begin(a), std::end(a));
+ std::pair<I, I> r = c.equal_range(30);
+ assert(std::distance(r.first, r.second) == 1);
+ assert(r.first->first == 30);
+ assert(r.first->second == "thirty");
+ r = c.equal_range(5);
+ assert(std::distance(r.first, r.second) == 0);
+ r = c.equal_range(50);
+ assert(r.first->first == 50);
+ assert(r.first->second == "fifty");
+ ++r.first;
+ assert(r.first->first == 50);
+ assert(r.first->second == "fiftyA");
+ ++r.first;
+ assert(r.first->first == 50);
+ assert(r.first->second == "fiftyB");
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multimap/equal_range_non_const.pass.cpp b/test/std/containers/unord/unord.multimap/equal_range_non_const.pass.cpp
new file mode 100644
index 000000000000..eb4c019af951
--- /dev/null
+++ b/test/std/containers/unord/unord.multimap/equal_range_non_const.pass.cpp
@@ -0,0 +1,97 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// pair<iterator, iterator> equal_range(const key_type& k);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef C::iterator I;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(50, "fiftyA"),
+ P(50, "fiftyB"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c(std::begin(a), std::end(a));
+ std::pair<I, I> r = c.equal_range(30);
+ assert(std::distance(r.first, r.second) == 1);
+ assert(r.first->first == 30);
+ assert(r.first->second == "thirty");
+ r = c.equal_range(5);
+ assert(std::distance(r.first, r.second) == 0);
+ r = c.equal_range(50);
+ assert(r.first->first == 50);
+ assert(r.first->second == "fifty");
+ ++r.first;
+ assert(r.first->first == 50);
+ assert(r.first->second == "fiftyA");
+ ++r.first;
+ assert(r.first->first == 50);
+ assert(r.first->second == "fiftyB");
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef C::iterator I;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(50, "fiftyA"),
+ P(50, "fiftyB"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c(std::begin(a), std::end(a));
+ std::pair<I, I> r = c.equal_range(30);
+ assert(std::distance(r.first, r.second) == 1);
+ assert(r.first->first == 30);
+ assert(r.first->second == "thirty");
+ r = c.equal_range(5);
+ assert(std::distance(r.first, r.second) == 0);
+ r = c.equal_range(50);
+ assert(r.first->first == 50);
+ assert(r.first->second == "fifty");
+ ++r.first;
+ assert(r.first->first == 50);
+ assert(r.first->second == "fiftyA");
+ ++r.first;
+ assert(r.first->first == 50);
+ assert(r.first->second == "fiftyB");
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multimap/find_const.pass.cpp b/test/std/containers/unord/unord.multimap/find_const.pass.cpp
new file mode 100644
index 000000000000..bc2650d111f3
--- /dev/null
+++ b/test/std/containers/unord/unord.multimap/find_const.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// const_iterator find(const key_type& k) const;
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ const C c(std::begin(a), std::end(a));
+ C::const_iterator i = c.find(30);
+ assert(i->first == 30);
+ assert(i->second == "thirty");
+ i = c.find(5);
+ assert(i == c.cend());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ const C c(std::begin(a), std::end(a));
+ C::const_iterator i = c.find(30);
+ assert(i->first == 30);
+ assert(i->second == "thirty");
+ i = c.find(5);
+ assert(i == c.cend());
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multimap/find_non_const.pass.cpp b/test/std/containers/unord/unord.multimap/find_non_const.pass.cpp
new file mode 100644
index 000000000000..5a128c0f37e1
--- /dev/null
+++ b/test/std/containers/unord/unord.multimap/find_non_const.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// iterator find(const key_type& k);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c(std::begin(a), std::end(a));
+ C::iterator i = c.find(30);
+ assert(i->first == 30);
+ assert(i->second == "thirty");
+ i = c.find(5);
+ assert(i == c.end());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c(std::begin(a), std::end(a));
+ C::iterator i = c.find(30);
+ assert(i->first == 30);
+ assert(i->second == "thirty");
+ i = c.find(5);
+ assert(i == c.end());
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multimap/iterators.fail.cpp b/test/std/containers/unord/unord.multimap/iterators.fail.cpp
new file mode 100644
index 000000000000..d0adb2c25d5e
--- /dev/null
+++ b/test/std/containers/unord/unord.multimap/iterators.fail.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// iterator begin() {return __table_.begin();}
+// iterator end() {return __table_.end();}
+// const_iterator begin() const {return __table_.begin();}
+// const_iterator end() const {return __table_.end();}
+// const_iterator cbegin() const {return __table_.begin();}
+// const_iterator cend() const {return __table_.end();}
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ C::iterator i = c.begin();
+ i->second = "ONE";
+ assert(i->second == "ONE");
+ i->first = 2;
+ }
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ }
+}
diff --git a/test/std/containers/unord/unord.multimap/iterators.pass.cpp b/test/std/containers/unord/unord.multimap/iterators.pass.cpp
new file mode 100644
index 000000000000..1831cf1149b1
--- /dev/null
+++ b/test/std/containers/unord/unord.multimap/iterators.pass.cpp
@@ -0,0 +1,134 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// iterator begin() {return __table_.begin();}
+// iterator end() {return __table_.end();}
+// const_iterator begin() const {return __table_.begin();}
+// const_iterator end() const {return __table_.end();}
+// const_iterator cbegin() const {return __table_.begin();}
+// const_iterator cend() const {return __table_.end();}
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 7);
+ assert(c.size() == 6);
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ C::iterator i;
+ i = c.begin();
+ i->second = "ONE";
+ assert(i->second == "ONE");
+ }
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 7);
+ assert(c.size() == 6);
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ C::const_iterator i;
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 7);
+ assert(c.size() == 6);
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ C::iterator i;
+ i = c.begin();
+ i->second = "ONE";
+ assert(i->second == "ONE");
+ }
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 7);
+ assert(c.size() == 6);
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ C::const_iterator i;
+ }
+#endif
+#if _LIBCPP_STD_VER > 11
+ { // N3644 testing
+ typedef std::unordered_multimap<int,double> C;
+ C::iterator ii1{}, ii2{};
+ C::iterator ii4 = ii1;
+ C::const_iterator cii{};
+ assert ( ii1 == ii2 );
+ assert ( ii1 == ii4 );
+
+ assert (!(ii1 != ii2 ));
+
+ assert ( (ii1 == cii ));
+ assert ( (cii == ii1 ));
+ assert (!(ii1 != cii ));
+ assert (!(cii != ii1 ));
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multimap/load_factor.pass.cpp b/test/std/containers/unord/unord.multimap/load_factor.pass.cpp
new file mode 100644
index 000000000000..f407097dc0c6
--- /dev/null
+++ b/test/std/containers/unord/unord.multimap/load_factor.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// float load_factor() const
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ const C c(std::begin(a), std::end(a));
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ }
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ const C c;
+ assert(c.load_factor() == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ const C c(std::begin(a), std::end(a));
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ }
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ const C c;
+ assert(c.load_factor() == 0);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multimap/local_iterators.fail.cpp b/test/std/containers/unord/unord.multimap/local_iterators.fail.cpp
new file mode 100644
index 000000000000..5f66cfe287e3
--- /dev/null
+++ b/test/std/containers/unord/unord.multimap/local_iterators.fail.cpp
@@ -0,0 +1,286 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// local_iterator begin (size_type n);
+// local_iterator end (size_type n);
+// const_local_iterator begin (size_type n) const;
+// const_local_iterator end (size_type n) const;
+// const_local_iterator cbegin(size_type n) const;
+// const_local_iterator cend (size_type n) const;
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ typedef C::local_iterator I;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() == 7);
+ C::size_type b = c.bucket(0);
+ I i = c.begin(b);
+ I j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 2);
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ i->first = 2;
+
+ b = c.bucket(2);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 2);
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ b = c.bucket(3);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 3);
+ assert(i->second == "three");
+
+ b = c.bucket(4);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 4);
+ assert(i->second == "four");
+
+ b = c.bucket(5);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(6);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 0);
+ }
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ typedef C::const_local_iterator I;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() == 7);
+ C::size_type b = c.bucket(0);
+ I i = c.begin(b);
+ I j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 2);
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+
+ b = c.bucket(2);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 2);
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ b = c.bucket(3);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 3);
+ assert(i->second == "three");
+
+ b = c.bucket(4);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 4);
+ assert(i->second == "four");
+
+ b = c.bucket(5);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(6);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 0);
+ }
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ typedef C::const_local_iterator I;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() == 7);
+ C::size_type b = c.bucket(0);
+ I i = c.cbegin(b);
+ I j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 2);
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+
+ b = c.bucket(2);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 2);
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ b = c.bucket(3);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 3);
+ assert(i->second == "three");
+
+ b = c.bucket(4);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 4);
+ assert(i->second == "four");
+
+ b = c.bucket(5);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(6);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+ }
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ typedef C::const_local_iterator I;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() == 7);
+ C::size_type b = c.bucket(0);
+ I i = c.cbegin(b);
+ I j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 2);
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+
+ b = c.bucket(2);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 2);
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ b = c.bucket(3);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 3);
+ assert(i->second == "three");
+
+ b = c.bucket(4);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 4);
+ assert(i->second == "four");
+
+ b = c.bucket(5);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(6);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+ }
+}
diff --git a/test/std/containers/unord/unord.multimap/local_iterators.pass.cpp b/test/std/containers/unord/unord.multimap/local_iterators.pass.cpp
new file mode 100644
index 000000000000..35e4c772fd33
--- /dev/null
+++ b/test/std/containers/unord/unord.multimap/local_iterators.pass.cpp
@@ -0,0 +1,549 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// local_iterator begin (size_type n);
+// local_iterator end (size_type n);
+// const_local_iterator begin (size_type n) const;
+// const_local_iterator end (size_type n) const;
+// const_local_iterator cbegin(size_type n) const;
+// const_local_iterator cend (size_type n) const;
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ typedef C::local_iterator I;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 7);
+ C::size_type b = c.bucket(0);
+ I i = c.begin(b);
+ I j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 2);
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+
+ b = c.bucket(2);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 2);
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ b = c.bucket(3);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 3);
+ assert(i->second == "three");
+
+ b = c.bucket(4);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 4);
+ assert(i->second == "four");
+
+ b = c.bucket(5);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(6);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 0);
+ }
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ typedef C::const_local_iterator I;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 7);
+ C::size_type b = c.bucket(0);
+ I i = c.begin(b);
+ I j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 2);
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+
+ b = c.bucket(2);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 2);
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ b = c.bucket(3);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 3);
+ assert(i->second == "three");
+
+ b = c.bucket(4);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 4);
+ assert(i->second == "four");
+
+ b = c.bucket(5);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(6);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 0);
+ }
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ typedef C::const_local_iterator I;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 7);
+ C::size_type b = c.bucket(0);
+ I i = c.cbegin(b);
+ I j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 2);
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+
+ b = c.bucket(2);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 2);
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ b = c.bucket(3);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 3);
+ assert(i->second == "three");
+
+ b = c.bucket(4);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 4);
+ assert(i->second == "four");
+
+ b = c.bucket(5);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(6);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+ }
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ typedef C::const_local_iterator I;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 7);
+ C::size_type b = c.bucket(0);
+ I i = c.cbegin(b);
+ I j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 2);
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+
+ b = c.bucket(2);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 2);
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ b = c.bucket(3);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 3);
+ assert(i->second == "three");
+
+ b = c.bucket(4);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 4);
+ assert(i->second == "four");
+
+ b = c.bucket(5);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(6);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ typedef C::local_iterator I;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 7);
+ C::size_type b = c.bucket(0);
+ I i = c.begin(b);
+ I j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 2);
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+
+ b = c.bucket(2);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 2);
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ b = c.bucket(3);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 3);
+ assert(i->second == "three");
+
+ b = c.bucket(4);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 4);
+ assert(i->second == "four");
+
+ b = c.bucket(5);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(6);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 0);
+ }
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ typedef C::const_local_iterator I;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 7);
+ C::size_type b = c.bucket(0);
+ I i = c.begin(b);
+ I j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 2);
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+
+ b = c.bucket(2);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 2);
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ b = c.bucket(3);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 3);
+ assert(i->second == "three");
+
+ b = c.bucket(4);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 4);
+ assert(i->second == "four");
+
+ b = c.bucket(5);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(6);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 0);
+ }
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ typedef C::const_local_iterator I;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 7);
+ C::size_type b = c.bucket(0);
+ I i = c.cbegin(b);
+ I j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 2);
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+
+ b = c.bucket(2);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 2);
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ b = c.bucket(3);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 3);
+ assert(i->second == "three");
+
+ b = c.bucket(4);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 4);
+ assert(i->second == "four");
+
+ b = c.bucket(5);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(6);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+ }
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ typedef C::const_local_iterator I;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 7);
+ C::size_type b = c.bucket(0);
+ I i = c.cbegin(b);
+ I j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 2);
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+
+ b = c.bucket(2);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 2);
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ b = c.bucket(3);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 3);
+ assert(i->second == "three");
+
+ b = c.bucket(4);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 4);
+ assert(i->second == "four");
+
+ b = c.bucket(5);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(6);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multimap/max_bucket_count.pass.cpp b/test/std/containers/unord/unord.multimap/max_bucket_count.pass.cpp
new file mode 100644
index 000000000000..23b90579ec41
--- /dev/null
+++ b/test/std/containers/unord/unord.multimap/max_bucket_count.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// size_type max_bucket_count() const;
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef C::const_iterator I;
+ typedef std::pair<int, std::string> P;
+ const C c;
+ assert(c.max_bucket_count() > 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef C::const_iterator I;
+ typedef std::pair<int, std::string> P;
+ const C c;
+ assert(c.max_bucket_count() > 0);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multimap/max_load_factor.pass.cpp b/test/std/containers/unord/unord.multimap/max_load_factor.pass.cpp
new file mode 100644
index 000000000000..39b7feeba4e5
--- /dev/null
+++ b/test/std/containers/unord/unord.multimap/max_load_factor.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// float max_load_factor() const;
+// void max_load_factor(float mlf);
+
+#ifdef _LIBCPP_DEBUG
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ const C c;
+ assert(c.max_load_factor() == 1);
+ }
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ C c;
+ assert(c.max_load_factor() == 1);
+ c.max_load_factor(2.5);
+ assert(c.max_load_factor() == 2.5);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ const C c;
+ assert(c.max_load_factor() == 1);
+ }
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ C c;
+ assert(c.max_load_factor() == 1);
+ c.max_load_factor(2.5);
+ assert(c.max_load_factor() == 2.5);
+ }
+#endif
+#if _LIBCPP_DEBUG_LEVEL >= 1
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ C c;
+ c.max_load_factor(0);
+ assert(false);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multimap/max_size.pass.cpp b/test/std/containers/unord/unord.multimap/max_size.pass.cpp
new file mode 100644
index 000000000000..caba5932b23c
--- /dev/null
+++ b/test/std/containers/unord/unord.multimap/max_size.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// size_type max_size() const;
+
+#include <unordered_map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::unordered_multimap<int, int> u;
+ assert(u.max_size() > 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::unordered_multimap<int, int, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, int>>> u;
+ assert(u.max_size() > 0);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multimap/rehash.pass.cpp b/test/std/containers/unord/unord.multimap/rehash.pass.cpp
new file mode 100644
index 000000000000..1d99208596c1
--- /dev/null
+++ b/test/std/containers/unord/unord.multimap/rehash.pass.cpp
@@ -0,0 +1,119 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// void rehash(size_type n);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "min_allocator.h"
+
+template <class C>
+void test(const C& c)
+{
+ assert(c.size() == 6);
+ typedef std::pair<typename C::const_iterator, typename C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ typename C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+}
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ test(c);
+ assert(c.bucket_count() >= 7);
+ c.rehash(3);
+ assert(c.bucket_count() == 7);
+ test(c);
+ c.max_load_factor(2);
+ c.rehash(3);
+ assert(c.bucket_count() == 3);
+ test(c);
+ c.rehash(31);
+ assert(c.bucket_count() == 31);
+ test(c);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ test(c);
+ assert(c.bucket_count() >= 7);
+ c.rehash(3);
+ assert(c.bucket_count() == 7);
+ test(c);
+ c.max_load_factor(2);
+ c.rehash(3);
+ assert(c.bucket_count() == 3);
+ test(c);
+ c.rehash(31);
+ assert(c.bucket_count() == 31);
+ test(c);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multimap/reserve.pass.cpp b/test/std/containers/unord/unord.multimap/reserve.pass.cpp
new file mode 100644
index 000000000000..801c74457d74
--- /dev/null
+++ b/test/std/containers/unord/unord.multimap/reserve.pass.cpp
@@ -0,0 +1,93 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// void rehash(size_type n);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class C>
+void test(const C& c)
+{
+ assert(c.size() == 6);
+ assert(c.find(1)->second == "one");
+ assert(next(c.find(1))->second == "four");
+ assert(c.find(2)->second == "two");
+ assert(next(c.find(2))->second == "four");
+ assert(c.find(3)->second == "three");
+ assert(c.find(4)->second == "four");
+}
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ test(c);
+ assert(c.bucket_count() >= 7);
+ c.reserve(3);
+ assert(c.bucket_count() == 7);
+ test(c);
+ c.max_load_factor(2);
+ c.reserve(3);
+ assert(c.bucket_count() == 3);
+ test(c);
+ c.reserve(31);
+ assert(c.bucket_count() >= 16);
+ test(c);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ test(c);
+ assert(c.bucket_count() >= 7);
+ c.reserve(3);
+ assert(c.bucket_count() == 7);
+ test(c);
+ c.max_load_factor(2);
+ c.reserve(3);
+ assert(c.bucket_count() == 3);
+ test(c);
+ c.reserve(31);
+ assert(c.bucket_count() >= 16);
+ test(c);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multimap/scary.pass.cpp b/test/std/containers/unord/unord.multimap/scary.pass.cpp
new file mode 100644
index 000000000000..e619a7a54294
--- /dev/null
+++ b/test/std/containers/unord/unord.multimap/scary.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// class unordered_map class unordered_multimap
+
+// Extension: SCARY/N2913 iterator compatibility between unordered_map and unordered_multimap
+
+#include <unordered_map>
+
+int main()
+{
+ typedef std::unordered_map<int, int> M1;
+ typedef std::unordered_multimap<int, int> M2;
+ M2::iterator i;
+ M1::iterator j = i;
+}
diff --git a/test/std/containers/unord/unord.multimap/swap_member.pass.cpp b/test/std/containers/unord/unord.multimap/swap_member.pass.cpp
new file mode 100644
index 000000000000..225eccd4793f
--- /dev/null
+++ b/test/std/containers/unord/unord.multimap/swap_member.pass.cpp
@@ -0,0 +1,585 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// void swap(unordered_multimap& __u);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "../../test_compare.h"
+#include "../../test_hash.h"
+#include "test_allocator.h"
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef test_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ C c1(0, Hash(1), Compare(1), Alloc(1));
+ C c2(0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(1));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(2));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef test_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a2[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c1(0, Hash(1), Compare(1), Alloc(1));
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(c1.find(10)->second == "ten");
+ assert(c1.find(20)->second == "twenty");
+ assert(c1.find(30)->second == "thirty");
+ assert(c1.find(40)->second == "forty");
+ assert(c1.find(50)->second == "fifty");
+ assert(c1.find(60)->second == "sixty");
+ assert(c1.find(70)->second == "seventy");
+ assert(c1.find(80)->second == "eighty");
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(1));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(2));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef test_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a1[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+ C c2(0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(1));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 7);
+ assert(c2.size() == 6);
+ assert(c2.find(1)->second == "one");
+ assert(next(c2.find(1))->second == "four");
+ assert(c2.find(2)->second == "two");
+ assert(next(c2.find(2))->second == "four");
+ assert(c2.find(3)->second == "three");
+ assert(c2.find(4)->second == "four");
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(2));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef test_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a1[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ P a2[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(c1.find(10)->second == "ten");
+ assert(c1.find(20)->second == "twenty");
+ assert(c1.find(30)->second == "thirty");
+ assert(c1.find(40)->second == "forty");
+ assert(c1.find(50)->second == "fifty");
+ assert(c1.find(60)->second == "sixty");
+ assert(c1.find(70)->second == "seventy");
+ assert(c1.find(80)->second == "eighty");
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(1));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 7);
+ assert(c2.size() == 6);
+ assert(c2.find(1)->second == "one");
+ assert(next(c2.find(1))->second == "four");
+ assert(c2.find(2)->second == "two");
+ assert(next(c2.find(2))->second == "four");
+ assert(c2.find(3)->second == "three");
+ assert(c2.find(4)->second == "four");
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(2));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef other_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ C c1(0, Hash(1), Compare(1), Alloc(1));
+ C c2(0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(2));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(1));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef other_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a2[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c1(0, Hash(1), Compare(1), Alloc(1));
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(c1.find(10)->second == "ten");
+ assert(c1.find(20)->second == "twenty");
+ assert(c1.find(30)->second == "thirty");
+ assert(c1.find(40)->second == "forty");
+ assert(c1.find(50)->second == "fifty");
+ assert(c1.find(60)->second == "sixty");
+ assert(c1.find(70)->second == "seventy");
+ assert(c1.find(80)->second == "eighty");
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(2));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(1));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef other_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a1[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+ C c2(0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(2));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 7);
+ assert(c2.size() == 6);
+ assert(c2.find(1)->second == "one");
+ assert(next(c2.find(1))->second == "four");
+ assert(c2.find(2)->second == "two");
+ assert(next(c2.find(2))->second == "four");
+ assert(c2.find(3)->second == "three");
+ assert(c2.find(4)->second == "four");
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(1));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef other_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a1[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ P a2[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(c1.find(10)->second == "ten");
+ assert(c1.find(20)->second == "twenty");
+ assert(c1.find(30)->second == "thirty");
+ assert(c1.find(40)->second == "forty");
+ assert(c1.find(50)->second == "fifty");
+ assert(c1.find(60)->second == "sixty");
+ assert(c1.find(70)->second == "seventy");
+ assert(c1.find(80)->second == "eighty");
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(2));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 7);
+ assert(c2.size() == 6);
+ assert(c2.find(1)->second == "one");
+ assert(next(c2.find(1))->second == "four");
+ assert(c2.find(2)->second == "two");
+ assert(next(c2.find(2))->second == "four");
+ assert(c2.find(3)->second == "three");
+ assert(c2.find(4)->second == "four");
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(1));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef min_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ C c1(0, Hash(1), Compare(1), Alloc());
+ C c2(0, Hash(2), Compare(2), Alloc());
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc());
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc());
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef min_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a2[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c1(0, Hash(1), Compare(1), Alloc());
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc());
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(c1.find(10)->second == "ten");
+ assert(c1.find(20)->second == "twenty");
+ assert(c1.find(30)->second == "thirty");
+ assert(c1.find(40)->second == "forty");
+ assert(c1.find(50)->second == "fifty");
+ assert(c1.find(60)->second == "sixty");
+ assert(c1.find(70)->second == "seventy");
+ assert(c1.find(80)->second == "eighty");
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc());
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc());
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef min_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a1[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc());
+ C c2(0, Hash(2), Compare(2), Alloc());
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc());
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 7);
+ assert(c2.size() == 6);
+ assert(c2.find(1)->second == "one");
+ assert(next(c2.find(1))->second == "four");
+ assert(c2.find(2)->second == "two");
+ assert(next(c2.find(2))->second == "four");
+ assert(c2.find(3)->second == "three");
+ assert(c2.find(4)->second == "four");
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc());
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef min_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a1[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ P a2[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc());
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc());
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(c1.find(10)->second == "ten");
+ assert(c1.find(20)->second == "twenty");
+ assert(c1.find(30)->second == "thirty");
+ assert(c1.find(40)->second == "forty");
+ assert(c1.find(50)->second == "fifty");
+ assert(c1.find(60)->second == "sixty");
+ assert(c1.find(70)->second == "seventy");
+ assert(c1.find(80)->second == "eighty");
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc());
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 7);
+ assert(c2.size() == 6);
+ assert(c2.find(1)->second == "one");
+ assert(next(c2.find(1))->second == "four");
+ assert(c2.find(2)->second == "two");
+ assert(next(c2.find(2))->second == "four");
+ assert(c2.find(3)->second == "three");
+ assert(c2.find(4)->second == "four");
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc());
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multimap/types.pass.cpp b/test/std/containers/unord/unord.multimap/types.pass.cpp
new file mode 100644
index 000000000000..55ae749746c1
--- /dev/null
+++ b/test/std/containers/unord/unord.multimap/types.pass.cpp
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+// {
+// public:
+// // types
+// typedef Key key_type;
+// typedef T mapped_type;
+// typedef Hash hasher;
+// typedef Pred key_equal;
+// typedef Alloc allocator_type;
+// typedef pair<const key_type, mapped_type> value_type;
+// typedef value_type& reference;
+// typedef const value_type& const_reference;
+// typedef typename allocator_traits<allocator_type>::pointer pointer;
+// typedef typename allocator_traits<allocator_type>::const_pointer const_pointer;
+// typedef typename allocator_traits<allocator_type>::size_type size_type;
+// typedef typename allocator_traits<allocator_type>::difference_type difference_type;
+
+#include <unordered_map>
+#include <type_traits>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<char, short> C;
+ static_assert((std::is_same<C::key_type, char>::value), "");
+ static_assert((std::is_same<C::mapped_type, short>::value), "");
+ static_assert((std::is_same<C::hasher, std::hash<C::key_type> >::value), "");
+ static_assert((std::is_same<C::key_equal, std::equal_to<C::key_type> >::value), "");
+ static_assert((std::is_same<C::allocator_type, std::allocator<C::value_type> >::value), "");
+ static_assert((std::is_same<C::value_type, std::pair<const C::key_type, C::mapped_type> >::value), "");
+ static_assert((std::is_same<C::reference, C::value_type&>::value), "");
+ static_assert((std::is_same<C::const_reference, const C::value_type&>::value), "");
+ static_assert((std::is_same<C::pointer, C::value_type*>::value), "");
+ static_assert((std::is_same<C::const_pointer, const C::value_type*>::value), "");
+ static_assert((std::is_same<C::size_type, std::size_t>::value), "");
+ static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<char, short, std::hash<char>, std::equal_to<char>,
+ min_allocator<std::pair<const char, short>>> C;
+ static_assert((std::is_same<C::key_type, char>::value), "");
+ static_assert((std::is_same<C::mapped_type, short>::value), "");
+ static_assert((std::is_same<C::hasher, std::hash<C::key_type> >::value), "");
+ static_assert((std::is_same<C::key_equal, std::equal_to<C::key_type> >::value), "");
+ static_assert((std::is_same<C::allocator_type, min_allocator<C::value_type> >::value), "");
+ static_assert((std::is_same<C::value_type, std::pair<const C::key_type, C::mapped_type> >::value), "");
+ static_assert((std::is_same<C::reference, C::value_type&>::value), "");
+ static_assert((std::is_same<C::const_reference, const C::value_type&>::value), "");
+ static_assert((std::is_same<C::pointer, min_pointer<C::value_type>>::value), "");
+ static_assert((std::is_same<C::const_pointer, min_pointer<const C::value_type>>::value), "");
+ // min_allocator doesn't have a size_type, so one gets synthesized
+ static_assert((std::is_same<C::size_type, std::make_unsigned<C::difference_type>::type>::value), "");
+ static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/allocator.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/allocator.pass.cpp
new file mode 100644
index 000000000000..dc41fad29af8
--- /dev/null
+++ b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/allocator.pass.cpp
@@ -0,0 +1,111 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// explicit unordered_multimap(const allocator_type& __a);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<NotConstructible, NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ test_allocator<std::pair<const NotConstructible,
+ NotConstructible> >
+ > C;
+ C c(test_allocator<std::pair<const NotConstructible, NotConstructible> >(10));
+ assert(c.bucket_count() == 0);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const NotConstructible, NotConstructible> >(10)));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<NotConstructible, NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ min_allocator<std::pair<const NotConstructible,
+ NotConstructible> >
+ > C;
+ C c(min_allocator<std::pair<const NotConstructible, NotConstructible> >{});
+ assert(c.bucket_count() == 0);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef NotConstructible T;
+ typedef test_allocator<std::pair<const T, T>> A;
+ typedef test_hash<std::hash<T>> HF;
+ typedef test_compare<std::equal_to<T>> Comp;
+ typedef std::unordered_multimap<T, T, HF, Comp, A> C;
+
+ A a(10);
+ C c(2, a);
+ assert(c.bucket_count() == 2);
+ assert(c.hash_function() == HF());
+ assert(c.key_eq() == Comp());
+ assert(c.get_allocator() == a);
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+ {
+ typedef NotConstructible T;
+ typedef test_allocator<std::pair<const T, T>> A;
+ typedef test_hash<std::hash<T>> HF;
+ typedef test_compare<std::equal_to<T>> Comp;
+ typedef std::unordered_multimap<T, T, HF, Comp, A> C;
+
+ A a(10);
+ HF hf(12);
+ C c(2, hf, a);
+ assert(c.bucket_count() == 2);
+ assert(c.hash_function() == hf);
+ assert(!(c.hash_function() == HF()));
+ assert(c.key_eq() == Comp());
+ assert(c.get_allocator() == a);
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+#endif
+}
diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/assign_copy.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/assign_copy.pass.cpp
new file mode 100644
index 000000000000..df566b396f99
--- /dev/null
+++ b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/assign_copy.pass.cpp
@@ -0,0 +1,227 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap& operator=(const unordered_multimap& u);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef test_allocator<std::pair<const int, std::string> > A;
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A(10)
+ );
+ C c(a, a + 2,
+ 7,
+ test_hash<std::hash<int> >(2),
+ test_compare<std::equal_to<int> >(3),
+ A(4)
+ );
+ c = c0;
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ C::const_iterator i = c.cbegin();
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+ ++i;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ ++i;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == A(4));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<const int, std::string> P;
+ const P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a+sizeof(a)/sizeof(a[0]));
+ C *p = &c;
+ c = *p;
+ assert(c.size() == 6);
+ assert(std::is_permutation(c.begin(), c.end(), a));
+ }
+ {
+ typedef other_allocator<std::pair<const int, std::string> > A;
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A(10)
+ );
+ C c(a, a + 2,
+ 7,
+ test_hash<std::hash<int> >(2),
+ test_compare<std::equal_to<int> >(3),
+ A(4)
+ );
+ c = c0;
+ assert(c.bucket_count() >= 7);
+ assert(c.size() == 6);
+ C::const_iterator i = c.cbegin();
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+ ++i;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ ++i;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == A(10));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef min_allocator<std::pair<const int, std::string> > A;
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A()
+ );
+ C c(a, a + 2,
+ 7,
+ test_hash<std::hash<int> >(2),
+ test_compare<std::equal_to<int> >(3),
+ A()
+ );
+ c = c0;
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ C::const_iterator i = c.cbegin();
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+ ++i;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ ++i;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == A());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/assign_init.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/assign_init.pass.cpp
new file mode 100644
index 000000000000..2d3c1434d69f
--- /dev/null
+++ b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/assign_init.pass.cpp
@@ -0,0 +1,146 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap& operator=(initializer_list<value_type> il);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef test_allocator<std::pair<const int, std::string> > A;
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef std::pair<int, std::string> P;
+ C c = {
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ c = {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ assert(c.bucket_count() >= 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef min_allocator<std::pair<const int, std::string> > A;
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef std::pair<int, std::string> P;
+ C c = {
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ c = {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ assert(c.bucket_count() >= 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/assign_move.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/assign_move.pass.cpp
new file mode 100644
index 000000000000..0c43fa8f06ed
--- /dev/null
+++ b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/assign_move.pass.cpp
@@ -0,0 +1,306 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap& operator=(unordered_multimap&& u);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef test_allocator<std::pair<const int, std::string> > A;
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A(10)
+ );
+ C c(a, a + 2,
+ 7,
+ test_hash<std::hash<int> >(2),
+ test_compare<std::equal_to<int> >(3),
+ A(4)
+ );
+ c = std::move(c0);
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+ {
+ typedef test_allocator<std::pair<const int, std::string> > A;
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A(10)
+ );
+ C c(a, a + 2,
+ 7,
+ test_hash<std::hash<int> >(2),
+ test_compare<std::equal_to<int> >(3),
+ A(10)
+ );
+ c = std::move(c0);
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+ {
+ typedef other_allocator<std::pair<const int, std::string> > A;
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A(10)
+ );
+ C c(a, a + 2,
+ 7,
+ test_hash<std::hash<int> >(2),
+ test_compare<std::equal_to<int> >(3),
+ A(4)
+ );
+ c = std::move(c0);
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef min_allocator<std::pair<const int, std::string> > A;
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A()
+ );
+ C c(a, a + 2,
+ 7,
+ test_hash<std::hash<int> >(2),
+ test_compare<std::equal_to<int> >(3),
+ A()
+ );
+ c = std::move(c0);
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::unordered_multimap<int, int> s1 = {{1, 1}, {2, 2}, {3, 3}};
+ std::unordered_multimap<int, int>::iterator i = s1.begin();
+ std::pair<const int, int> k = *i;
+ std::unordered_multimap<int, int> s2;
+ s2 = std::move(s1);
+ assert(*i == k);
+ s2.erase(i);
+ assert(s2.size() == 2);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/copy.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/copy.pass.cpp
new file mode 100644
index 000000000000..d71838f1dfb4
--- /dev/null
+++ b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/copy.pass.cpp
@@ -0,0 +1,193 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap(const unordered_multimap& u);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ test_allocator<std::pair<const int, std::string> >(10)
+ );
+ C c = c0;
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ C::const_iterator i = c.cbegin();
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+ ++i;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ ++i;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const int, std::string> >(10)));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ other_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ other_allocator<std::pair<const int, std::string> >(10)
+ );
+ C c = c0;
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ C::const_iterator i = c.cbegin();
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+ ++i;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ ++i;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() ==
+ (other_allocator<std::pair<const int, std::string> >(-2)));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ min_allocator<std::pair<const int, std::string> >()
+ );
+ C c = c0;
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ C::const_iterator i = c.cbegin();
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+ ++i;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ ++i;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const int, std::string> >()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/copy_alloc.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/copy_alloc.pass.cpp
new file mode 100644
index 000000000000..2a064c5b5f62
--- /dev/null
+++ b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/copy_alloc.pass.cpp
@@ -0,0 +1,138 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap(const unordered_multimap& u, const allocator_type& a);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ test_allocator<std::pair<const int, std::string> >(10)
+ );
+ C c(c0, test_allocator<std::pair<const int, std::string> >(5));
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ C::const_iterator i = c.cbegin();
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+ ++i;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ ++i;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const int, std::string> >(5)));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ min_allocator<std::pair<const int, std::string> >()
+ );
+ C c(c0, min_allocator<std::pair<const int, std::string> >());
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ C::const_iterator i = c.cbegin();
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+ ++i;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ ++i;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const int, std::string> >()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/default.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/default.pass.cpp
new file mode 100644
index 000000000000..1884065ce0c8
--- /dev/null
+++ b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/default.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap();
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<NotConstructible, NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ test_allocator<std::pair<const NotConstructible,
+ NotConstructible> >
+ > C;
+ C c;
+ assert(c.bucket_count() == 0);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<NotConstructible, NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ min_allocator<std::pair<const NotConstructible,
+ NotConstructible> >
+ > C;
+ C c;
+ assert(c.bucket_count() == 0);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+ {
+ std::unordered_multimap<int, int> c = {};
+ assert(c.bucket_count() == 0);
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/default_noexcept.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/default_noexcept.pass.cpp
new file mode 100644
index 000000000000..fac3cec63d70
--- /dev/null
+++ b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/default_noexcept.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// unordered_multimap()
+// noexcept(
+// is_nothrow_default_constructible<allocator_type>::value &&
+// is_nothrow_default_constructible<key_compare>::value &&
+// is_nothrow_copy_constructible<key_compare>::value);
+
+// This tests a conforming extension
+
+#include <unordered_map>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "test_allocator.h"
+#include "../../../test_hash.h"
+
+template <class T>
+struct some_comp
+{
+ typedef T value_type;
+ some_comp();
+ some_comp(const some_comp&);
+};
+
+template <class T>
+struct some_hash
+{
+ typedef T value_type;
+ some_hash();
+ some_hash(const some_hash&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::unordered_multimap<MoveOnly, MoveOnly> C;
+ static_assert(std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, test_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+ static_assert(std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, other_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+ static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_multimap<MoveOnly, MoveOnly, some_hash<MoveOnly>> C;
+ static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ some_comp<MoveOnly>> C;
+ static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/dtor_noexcept.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/dtor_noexcept.pass.cpp
new file mode 100644
index 000000000000..220785196791
--- /dev/null
+++ b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/dtor_noexcept.pass.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// ~unordered_multimap() // implied noexcept;
+
+#include <unordered_map>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "test_allocator.h"
+
+#if __has_feature(cxx_noexcept)
+
+template <class T>
+struct some_comp
+{
+ typedef T value_type;
+ ~some_comp() noexcept(false);
+};
+
+template <class T>
+struct some_hash
+{
+ typedef T value_type;
+ some_hash();
+ some_hash(const some_hash&);
+ ~some_hash() noexcept(false);
+};
+
+#endif
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::unordered_multimap<MoveOnly, MoveOnly> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, test_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, other_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_multimap<MoveOnly, MoveOnly, some_hash<MoveOnly>> C;
+ static_assert(!std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ some_comp<MoveOnly>> C;
+ static_assert(!std::is_nothrow_destructible<C>::value, "");
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init.pass.cpp
new file mode 100644
index 000000000000..cc5532adbe08
--- /dev/null
+++ b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init.pass.cpp
@@ -0,0 +1,254 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap(initializer_list<value_type> il);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ C c = {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ assert(c.bucket_count() >= 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >());
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >()));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ C c = {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ assert(c.bucket_count() >= 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >());
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert((c.get_allocator() == min_allocator<std::pair<const int, std::string> >()));
+ }
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::pair<int, std::string> P;
+ typedef test_allocator<std::pair<const int, std::string>> A;
+ typedef test_hash<std::hash<int>> HF;
+ typedef test_compare<std::equal_to<int>> Comp;
+ typedef std::unordered_multimap<int, std::string, HF, Comp, A> C;
+
+ A a(42);
+ C c ({
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ }, 12, a );
+ assert(c.bucket_count() >= 12);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == HF());
+ assert(c.key_eq() == Comp());
+ assert(c.get_allocator() == a);
+ assert(!(c.get_allocator() == A()));
+ }
+ {
+ typedef std::pair<int, std::string> P;
+ typedef test_allocator<std::pair<const int, std::string>> A;
+ typedef test_hash<std::hash<int>> HF;
+ typedef test_compare<std::equal_to<int>> Comp;
+ typedef std::unordered_multimap<int, std::string, HF, Comp, A> C;
+
+ HF hf(42);
+ A a(43);
+ C c ({
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ }, 12, hf, a );
+ assert(c.bucket_count() >= 12);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == hf);
+ assert(!(c.hash_function() == HF()));
+ assert(c.key_eq() == Comp());
+ assert(c.get_allocator() == a);
+ assert(!(c.get_allocator() == A()));
+ }
+#endif
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size.pass.cpp
new file mode 100644
index 000000000000..48239db1fa22
--- /dev/null
+++ b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size.pass.cpp
@@ -0,0 +1,144 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap(initializer_list<value_type> il, size_type n);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ C c({
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ },
+ 7
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >());
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >()));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ C c({
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ },
+ 7
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >());
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert((c.get_allocator() == min_allocator<std::pair<const int, std::string> >()));
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash.pass.cpp
new file mode 100644
index 000000000000..ff0054677055
--- /dev/null
+++ b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash.pass.cpp
@@ -0,0 +1,146 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap(initializer_list<value_type> il, size_type n, const hasher& hf);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ C c({
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ },
+ 7,
+ test_hash<std::hash<int> >(8)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >()));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ C c({
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ },
+ 7,
+ test_hash<std::hash<int> >(8)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert((c.get_allocator() == min_allocator<std::pair<const int, std::string> >()));
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash_equal.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash_equal.pass.cpp
new file mode 100644
index 000000000000..095e9c327f0e
--- /dev/null
+++ b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash_equal.pass.cpp
@@ -0,0 +1,149 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap(initializer_list<value_type> il, size_type n,
+// const hasher& hf, const key_equal& eql);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ C c({
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ },
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >()));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ C c({
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ },
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert((c.get_allocator() == min_allocator<std::pair<const int, std::string> >()));
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash_equal_allocator.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash_equal_allocator.pass.cpp
new file mode 100644
index 000000000000..d2f698ac2bcb
--- /dev/null
+++ b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash_equal_allocator.pass.cpp
@@ -0,0 +1,151 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap(initializer_list<value_type> il, size_type n,
+// const hasher& hf, const key_equal& eql, const allocator_type& a);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ C c({
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ },
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ test_allocator<std::pair<const int, std::string> >(10)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >(10)));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ C c({
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ },
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ min_allocator<std::pair<const int, std::string> >()
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert((c.get_allocator() == min_allocator<std::pair<const int, std::string> >()));
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move.pass.cpp
new file mode 100644
index 000000000000..fd70ff10a70a
--- /dev/null
+++ b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move.pass.cpp
@@ -0,0 +1,243 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap(unordered_multimap&& u);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ test_allocator<std::pair<const int, std::string> >(10)
+ );
+ C c = std::move(c0);
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 0);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const int, std::string> >(10)));
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+
+ assert(c0.empty());
+ }
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ test_allocator<std::pair<const int, std::string> >(10)
+ );
+ C c = std::move(c0);
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >(10)));
+
+ assert(c0.empty());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ min_allocator<std::pair<const int, std::string> >()
+ );
+ C c = std::move(c0);
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 0);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const int, std::string> >()));
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+
+ assert(c0.empty());
+ }
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ min_allocator<std::pair<const int, std::string> >()
+ );
+ C c = std::move(c0);
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert((c.get_allocator() == min_allocator<std::pair<const int, std::string> >()));
+
+ assert(c0.empty());
+ }
+#endif
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::unordered_multimap<int, int> s1 = {{1, 1}, {2, 2}, {3, 3}};
+ std::unordered_multimap<int, int>::iterator i = s1.begin();
+ std::pair<const int, int> k = *i;
+ std::unordered_multimap<int, int> s2 = std::move(s1);
+ assert(*i == k);
+ s2.erase(i);
+ assert(s2.size() == 2);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_alloc.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_alloc.pass.cpp
new file mode 100644
index 000000000000..d958e23ddd04
--- /dev/null
+++ b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_alloc.pass.cpp
@@ -0,0 +1,228 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap(unordered_multimap&& u, const allocator_type& a);
+
+#include <iostream>
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::pair<int, std::string> P;
+ typedef test_allocator<std::pair<const int, std::string>> A;
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A(10)
+ );
+ C c(std::move(c0), A(12));
+ assert(c.bucket_count() >= 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >(12)));
+
+ assert(c0.empty());
+ }
+ {
+ typedef std::pair<int, std::string> P;
+ typedef test_allocator<std::pair<const int, std::string>> A;
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A(10)
+ );
+ C c(std::move(c0), A(10));
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >(10)));
+
+ assert(c0.empty());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<int, std::string> P;
+ typedef min_allocator<std::pair<const int, std::string>> A;
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A()
+ );
+ C c(std::move(c0), A());
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert((c.get_allocator() == min_allocator<std::pair<const int, std::string> >()));
+
+ assert(c0.empty());
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_assign_noexcept.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_assign_noexcept.pass.cpp
new file mode 100644
index 000000000000..47e61ab70b83
--- /dev/null
+++ b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_assign_noexcept.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// unordered_multimap& operator=(unordered_multimap&& c)
+// noexcept(
+// allocator_type::propagate_on_container_move_assignment::value &&
+// is_nothrow_move_assignable<allocator_type>::value &&
+// is_nothrow_move_assignable<key_compare>::value);
+
+// This tests a conforming extension
+
+#include <unordered_map>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_comp
+{
+ typedef T value_type;
+ some_comp& operator=(const some_comp&);
+};
+
+template <class T>
+struct some_hash
+{
+ typedef T value_type;
+ some_hash();
+ some_hash(const some_hash&);
+ some_hash& operator=(const some_hash&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::unordered_multimap<MoveOnly, MoveOnly> C;
+ static_assert(std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, test_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+ static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, other_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+ static_assert(std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::unordered_multimap<MoveOnly, MoveOnly, some_hash<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ some_comp<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_noexcept.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_noexcept.pass.cpp
new file mode 100644
index 000000000000..37f17876973a
--- /dev/null
+++ b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_noexcept.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// unordered_multimap(unordered_multimap&&)
+// noexcept(is_nothrow_move_constructible<allocator_type>::value &&
+// is_nothrow_move_constructible<key_compare>::value);
+
+// This tests a conforming extension
+
+#include <unordered_map>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_comp
+{
+ typedef T value_type;
+ some_comp(const some_comp&);
+};
+
+template <class T>
+struct some_hash
+{
+ typedef T value_type;
+ some_hash();
+ some_hash(const some_hash&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::unordered_multimap<MoveOnly, MoveOnly> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, test_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, other_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_multimap<MoveOnly, MoveOnly, some_hash<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ some_comp<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_constructible<C>::value, "");
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range.pass.cpp
new file mode 100644
index 000000000000..bb700ec565dc
--- /dev/null
+++ b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range.pass.cpp
@@ -0,0 +1,263 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// template <class InputIterator>
+// unordered_multimap(InputIterator first, InputIterator last);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "test_iterators.h"
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])));
+ assert(c.bucket_count() >= 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >());
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >()));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])));
+ assert(c.bucket_count() >= 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >());
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert((c.get_allocator() == min_allocator<std::pair<const int, std::string> >()));
+ }
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::pair<int, std::string> P;
+ typedef test_allocator<std::pair<const int, std::string>> A;
+ typedef test_hash<std::hash<int>> HF;
+ typedef test_compare<std::equal_to<int>> Comp;
+ typedef std::unordered_multimap<int, std::string, HF, Comp, A> C;
+
+ P arr[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ A a(42);
+ C c(input_iterator<P*>(arr), input_iterator<P*>(arr + sizeof(arr)/sizeof(arr[0])), 14, a);
+ assert(c.bucket_count() >= 14);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == HF());
+ assert(c.key_eq() == Comp());
+ assert(c.get_allocator() == a);
+ assert(!(c.get_allocator() == A()));
+ }
+ {
+ typedef std::pair<int, std::string> P;
+ typedef test_allocator<std::pair<const int, std::string>> A;
+ typedef test_hash<std::hash<int>> HF;
+ typedef test_compare<std::equal_to<int>> Comp;
+ typedef std::unordered_multimap<int, std::string, HF, Comp, A> C;
+
+ P arr[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ A a(42);
+ HF hf (43);
+ C c(input_iterator<P*>(arr), input_iterator<P*>(arr + sizeof(arr)/sizeof(arr[0])), 12, hf, a );
+ assert(c.bucket_count() >= 12);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == hf);
+ assert(!(c.hash_function() == HF()));
+ assert(c.key_eq() == Comp());
+ assert(c.get_allocator() == a);
+ assert(!(c.get_allocator() == A()));
+ }
+#endif
+#endif
+}
diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size.pass.cpp
new file mode 100644
index 000000000000..a3fd4d14573d
--- /dev/null
+++ b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size.pass.cpp
@@ -0,0 +1,149 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// template <class InputIterator>
+// unordered_multimap(InputIterator first, InputIterator last, size_type n);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "test_iterators.h"
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+ 10
+ );
+ assert(c.bucket_count() == 11);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >());
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >()));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+ 10
+ );
+ assert(c.bucket_count() == 11);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >());
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert((c.get_allocator() == min_allocator<std::pair<const int, std::string> >()));
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash.pass.cpp
new file mode 100644
index 000000000000..4e7b1ac17a20
--- /dev/null
+++ b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash.pass.cpp
@@ -0,0 +1,152 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// template <class InputIterator>
+// unordered_multimap(InputIterator first, InputIterator last, size_type n,
+// const hasher& hf);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "test_iterators.h"
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+ 7,
+ test_hash<std::hash<int> >(8)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >()));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+ 7,
+ test_hash<std::hash<int> >(8)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert((c.get_allocator() == min_allocator<std::pair<const int, std::string> >()));
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash_equal.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash_equal.pass.cpp
new file mode 100644
index 000000000000..879e6811f2d9
--- /dev/null
+++ b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash_equal.pass.cpp
@@ -0,0 +1,154 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// template <class InputIterator>
+// unordered_multimap(InputIterator first, InputIterator last, size_type n,
+// const hasher& hf, const key_equal& eql);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "test_iterators.h"
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >()));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert((c.get_allocator() == min_allocator<std::pair<const int, std::string> >()));
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash_equal_allocator.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash_equal_allocator.pass.cpp
new file mode 100644
index 000000000000..8e42ca7245ee
--- /dev/null
+++ b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash_equal_allocator.pass.cpp
@@ -0,0 +1,157 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// template <class InputIterator>
+// unordered_multimap(InputIterator first, InputIterator last, size_type n,
+// const hasher& hf, const key_equal& eql,
+// const allocator_type& a);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "test_iterators.h"
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ test_allocator<std::pair<const int, std::string> >(10)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >(10)));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ min_allocator<std::pair<const int, std::string> >()
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert((c.get_allocator() == min_allocator<std::pair<const int, std::string> >()));
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size.fail.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size.fail.cpp
new file mode 100644
index 000000000000..44cf84ff323c
--- /dev/null
+++ b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size.fail.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap(size_type n);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<NotConstructible, NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ test_allocator<std::pair<const NotConstructible,
+ NotConstructible> >
+ > C;
+ C c = 7;
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<NotConstructible, NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ min_allocator<std::pair<const NotConstructible,
+ NotConstructible> >
+ > C;
+ C c = 7;
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size.pass.cpp
new file mode 100644
index 000000000000..bd56a41fd71f
--- /dev/null
+++ b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap(size_type n);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<NotConstructible, NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ test_allocator<std::pair<const NotConstructible,
+ NotConstructible> >
+ > C;
+ C c(7);
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<NotConstructible, NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ min_allocator<std::pair<const NotConstructible,
+ NotConstructible> >
+ > C;
+ C c(7);
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash.pass.cpp
new file mode 100644
index 000000000000..33460612ce3f
--- /dev/null
+++ b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap(size_type n, const hasher& hf);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<NotConstructible, NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ test_allocator<std::pair<const NotConstructible,
+ NotConstructible> >
+ > C;
+ C c(7,
+ test_hash<std::hash<NotConstructible> >(8)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<NotConstructible, NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ min_allocator<std::pair<const NotConstructible,
+ NotConstructible> >
+ > C;
+ C c(7,
+ test_hash<std::hash<NotConstructible> >(8)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash_equal.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash_equal.pass.cpp
new file mode 100644
index 000000000000..c2420ce9e6f5
--- /dev/null
+++ b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash_equal.pass.cpp
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap(size_type n, const hasher& hf, const key_equal& eql);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<NotConstructible, NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ test_allocator<std::pair<const NotConstructible,
+ NotConstructible> >
+ > C;
+ C c(7,
+ test_hash<std::hash<NotConstructible> >(8),
+ test_compare<std::equal_to<NotConstructible> >(9)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >(9));
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<NotConstructible, NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ min_allocator<std::pair<const NotConstructible,
+ NotConstructible> >
+ > C;
+ C c(7,
+ test_hash<std::hash<NotConstructible> >(8),
+ test_compare<std::equal_to<NotConstructible> >(9)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >(9));
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash_equal_allocator.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash_equal_allocator.pass.cpp
new file mode 100644
index 000000000000..33886670b3b4
--- /dev/null
+++ b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash_equal_allocator.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap(size_type n, const hasher& hf, const key_equal& eql, const allocator_type& a);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<NotConstructible, NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ test_allocator<std::pair<const NotConstructible,
+ NotConstructible> >
+ > C;
+ C c(7,
+ test_hash<std::hash<NotConstructible> >(8),
+ test_compare<std::equal_to<NotConstructible> >(9),
+ test_allocator<std::pair<const NotConstructible, NotConstructible> >(10)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >(9));
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const NotConstructible, NotConstructible> >(10)));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<NotConstructible, NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ min_allocator<std::pair<const NotConstructible,
+ NotConstructible> >
+ > C;
+ C c(7,
+ test_hash<std::hash<NotConstructible> >(8),
+ test_compare<std::equal_to<NotConstructible> >(9),
+ min_allocator<std::pair<const NotConstructible, NotConstructible> >()
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >(9));
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/clear.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/clear.pass.cpp
new file mode 100644
index 000000000000..4efcfaa6ce53
--- /dev/null
+++ b/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/clear.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// void clear()
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ c.clear();
+ assert(c.size() == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ c.clear();
+ assert(c.size() == 0);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/emplace.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/emplace.pass.cpp
new file mode 100644
index 000000000000..4f2e8ef061fa
--- /dev/null
+++ b/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/emplace.pass.cpp
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// template <class... Args>
+// iterator emplace(Args&&... args);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../Emplaceable.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::unordered_multimap<int, Emplaceable> C;
+ typedef C::iterator R;
+ C c;
+ R r = c.emplace(std::piecewise_construct, std::forward_as_tuple(3),
+ std::forward_as_tuple());
+ assert(c.size() == 1);
+ assert(r->first == 3);
+ assert(r->second == Emplaceable());
+
+ r = c.emplace(std::pair<const int, Emplaceable>(4, Emplaceable(5, 6)));
+ assert(c.size() == 2);
+ assert(r->first == 4);
+ assert(r->second == Emplaceable(5, 6));
+
+ r = c.emplace(std::piecewise_construct, std::forward_as_tuple(5),
+ std::forward_as_tuple(6, 7));
+ assert(c.size() == 3);
+ assert(r->first == 5);
+ assert(r->second == Emplaceable(6, 7));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, Emplaceable, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, Emplaceable>>> C;
+ typedef C::iterator R;
+ C c;
+ R r = c.emplace(std::piecewise_construct, std::forward_as_tuple(3),
+ std::forward_as_tuple());
+ assert(c.size() == 1);
+ assert(r->first == 3);
+ assert(r->second == Emplaceable());
+
+ r = c.emplace(std::pair<const int, Emplaceable>(4, Emplaceable(5, 6)));
+ assert(c.size() == 2);
+ assert(r->first == 4);
+ assert(r->second == Emplaceable(5, 6));
+
+ r = c.emplace(std::piecewise_construct, std::forward_as_tuple(5),
+ std::forward_as_tuple(6, 7));
+ assert(c.size() == 3);
+ assert(r->first == 5);
+ assert(r->second == Emplaceable(6, 7));
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/emplace_hint.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/emplace_hint.pass.cpp
new file mode 100644
index 000000000000..4d141ad137c8
--- /dev/null
+++ b/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/emplace_hint.pass.cpp
@@ -0,0 +1,109 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// template <class... Args>
+// iterator emplace_hint(const_iterator p, Args&&... args);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../Emplaceable.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::unordered_multimap<int, Emplaceable> C;
+ typedef C::iterator R;
+ C c;
+ C::const_iterator e = c.end();
+ R r = c.emplace_hint(e, std::piecewise_construct, std::forward_as_tuple(3),
+ std::forward_as_tuple());
+ assert(c.size() == 1);
+ assert(r->first == 3);
+ assert(r->second == Emplaceable());
+
+ r = c.emplace_hint(c.end(), std::pair<const int, Emplaceable>(3, Emplaceable(5, 6)));
+ assert(c.size() == 2);
+ assert(r->first == 3);
+ assert(r->second == Emplaceable(5, 6));
+ assert(r == next(c.begin()));
+
+ r = c.emplace_hint(r, std::piecewise_construct, std::forward_as_tuple(3),
+ std::forward_as_tuple(6, 7));
+ assert(c.size() == 3);
+ assert(r->first == 3);
+ assert(r->second == Emplaceable(6, 7));
+ assert(r == next(c.begin()));
+ r = c.begin();
+ assert(r->first == 3);
+ assert(r->second == Emplaceable());
+ r = next(r, 2);
+ assert(r->first == 3);
+ assert(r->second == Emplaceable(5, 6));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, Emplaceable, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, Emplaceable>>> C;
+ typedef C::iterator R;
+ C c;
+ C::const_iterator e = c.end();
+ R r = c.emplace_hint(e, std::piecewise_construct, std::forward_as_tuple(3),
+ std::forward_as_tuple());
+ assert(c.size() == 1);
+ assert(r->first == 3);
+ assert(r->second == Emplaceable());
+
+ r = c.emplace_hint(c.end(), std::pair<const int, Emplaceable>(3, Emplaceable(5, 6)));
+ assert(c.size() == 2);
+ assert(r->first == 3);
+ assert(r->second == Emplaceable(5, 6));
+ assert(r == next(c.begin()));
+
+ r = c.emplace_hint(r, std::piecewise_construct, std::forward_as_tuple(3),
+ std::forward_as_tuple(6, 7));
+ assert(c.size() == 3);
+ assert(r->first == 3);
+ assert(r->second == Emplaceable(6, 7));
+ assert(r == next(c.begin()));
+ r = c.begin();
+ assert(r->first == 3);
+ assert(r->second == Emplaceable());
+ r = next(r, 2);
+ assert(r->first == 3);
+ assert(r->second == Emplaceable(5, 6));
+ }
+#endif
+#if _LIBCPP_DEBUG >= 1
+ {
+ typedef std::unordered_multimap<int, Emplaceable> C;
+ typedef C::iterator R;
+ typedef C::value_type P;
+ C c;
+ C c2;
+ R r = c.emplace_hint(c2.end(), std::piecewise_construct,
+ std::forward_as_tuple(3),
+ std::forward_as_tuple());
+ assert(false);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_const_iter.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_const_iter.pass.cpp
new file mode 100644
index 000000000000..b31a4e56b31e
--- /dev/null
+++ b/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_const_iter.pass.cpp
@@ -0,0 +1,140 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// iterator erase(const_iterator p)
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+struct TemplateConstructor
+{
+ template<typename T>
+ TemplateConstructor (const T&) {}
+};
+
+bool operator==(const TemplateConstructor&, const TemplateConstructor&) { return false; }
+struct Hash { size_t operator() (const TemplateConstructor &) const { return 0; } };
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ C::const_iterator i = c.find(2);
+ C::iterator j = c.erase(i);
+
+ assert(c.size() == 5);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator k = eq.first;
+ assert(k->first == 1);
+ assert(k->second == "one");
+ ++k;
+ assert(k->first == 1);
+ assert(k->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 2);
+ assert(k->second == "four");
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 3);
+ assert(k->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 4);
+ assert(k->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ C::const_iterator i = c.find(2);
+ C::iterator j = c.erase(i);
+
+ assert(c.size() == 5);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator k = eq.first;
+ assert(k->first == 1);
+ assert(k->second == "one");
+ ++k;
+ assert(k->first == 1);
+ assert(k->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 2);
+ assert(k->second == "four");
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 3);
+ assert(k->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 4);
+ assert(k->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ }
+#endif
+#if __cplusplus >= 201402L
+ {
+ // This is LWG #2059
+ typedef TemplateConstructor T;
+ typedef std::unordered_multimap<T, int, Hash> C;
+ typedef C::iterator I;
+
+ C m;
+ T a{0};
+ I it = m.find(a);
+ if (it != m.end())
+ m.erase(it);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_db1.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_db1.pass.cpp
new file mode 100644
index 000000000000..83ccf3b73967
--- /dev/null
+++ b/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_db1.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Call erase(const_iterator position) with end()
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::pair<int, int> P;
+ P a1[] = {P(1, 1), P(2, 2), P(3, 3)};
+ std::unordered_multimap<int, int> l1(a1, a1+3);
+ std::unordered_multimap<int, int>::const_iterator i = l1.end();
+ l1.erase(i);
+ assert(false);
+ }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_db2.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_db2.pass.cpp
new file mode 100644
index 000000000000..fffcfa691427
--- /dev/null
+++ b/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_db2.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Call erase(const_iterator position) with iterator from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <cassert>
+#include <cstdlib>
+#include <exception>
+
+int main()
+{
+ {
+ typedef std::pair<int, int> P;
+ P a1[] = {P(1, 1), P(2, 2), P(3, 3)};
+ std::unordered_multimap<int, int> l1(a1, a1+3);
+ std::unordered_multimap<int, int> l2(a1, a1+3);
+ std::unordered_multimap<int, int>::const_iterator i = l2.begin();
+ l1.erase(i);
+ assert(false);
+ }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db1.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db1.pass.cpp
new file mode 100644
index 000000000000..be6caba59027
--- /dev/null
+++ b/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db1.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Call erase(const_iterator first, const_iterator last); with first iterator from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+int main()
+{
+ {
+ typedef std::pair<int, int> P;
+ P a1[] = {P(1, 1), P(2, 2), P(3, 3)};
+ std::unordered_multimap<int, int> l1(a1, a1+3);
+ std::unordered_multimap<int, int> l2(a1, a1+3);
+ std::unordered_multimap<int, int>::iterator i = l1.erase(l2.cbegin(), next(l1.cbegin()));
+ assert(false);
+ }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db2.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db2.pass.cpp
new file mode 100644
index 000000000000..a6d54084e726
--- /dev/null
+++ b/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db2.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Call erase(const_iterator first, const_iterator last); with second iterator from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+int main()
+{
+ {
+ typedef std::pair<int, int> P;
+ P a1[] = {P(1, 1), P(2, 2), P(3, 3)};
+ std::unordered_multimap<int, int> l1(a1, a1+3);
+ std::unordered_multimap<int, int> l2(a1, a1+3);
+ std::unordered_multimap<int, int>::iterator i = l1.erase(l1.cbegin(), next(l2.cbegin()));
+ assert(false);
+ }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db3.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db3.pass.cpp
new file mode 100644
index 000000000000..301cfb4402d0
--- /dev/null
+++ b/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db3.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Call erase(const_iterator first, const_iterator last); with both iterators from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+int main()
+{
+ {
+ typedef std::pair<int, int> P;
+ P a1[] = {P(1, 1), P(2, 2), P(3, 3)};
+ std::unordered_multimap<int, int> l1(a1, a1+3);
+ std::unordered_multimap<int, int> l2(a1, a1+3);
+ std::unordered_multimap<int, int>::iterator i = l1.erase(l2.cbegin(), next(l2.cbegin()));
+ assert(false);
+ }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db4.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db4.pass.cpp
new file mode 100644
index 000000000000..b53b486a56a7
--- /dev/null
+++ b/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db4.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Call erase(const_iterator first, const_iterator last); with a bad range
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+int main()
+{
+ {
+ typedef std::pair<int, int> P;
+ P a1[] = {P(1, 1), P(2, 2), P(3, 3)};
+ std::unordered_multimap<int, int> l1(a1, a1+3);
+ std::unordered_multimap<int, int>::iterator i = l1.erase(next(l1.cbegin()), l1.cbegin());
+ assert(false);
+ }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_key.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_key.pass.cpp
new file mode 100644
index 000000000000..892f8a247502
--- /dev/null
+++ b/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_key.pass.cpp
@@ -0,0 +1,388 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// size_type erase(const key_type& k);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+#if __cplusplus >= 201103L
+template <typename Unordered>
+bool only_deletions ( const Unordered &whole, const Unordered &part ) {
+ typename Unordered::const_iterator w = whole.begin();
+ typename Unordered::const_iterator p = part.begin();
+
+ while ( w != whole.end () && p != part.end()) {
+ if ( *w == *p )
+ p++;
+ w++;
+ }
+
+ return p == part.end();
+}
+#endif
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.erase(5) == 0);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator k = eq.first;
+ assert(k->first == 1);
+ assert(k->second == "one");
+ ++k;
+ assert(k->first == 1);
+ assert(k->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ k = eq.first;
+ assert(k->first == 2);
+ assert(k->second == "two");
+ ++k;
+ assert(k->first == 2);
+ assert(k->second == "four");
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 3);
+ assert(k->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 4);
+ assert(k->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+ assert(c.erase(2) == 2);
+ assert(c.size() == 4);
+ eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ k = eq.first;
+ assert(k->first == 1);
+ assert(k->second == "one");
+ ++k;
+ assert(k->first == 1);
+ assert(k->second == "four");
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 3);
+ assert(k->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 4);
+ assert(k->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+ assert(c.erase(2) == 0);
+ assert(c.size() == 4);
+ eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ k = eq.first;
+ assert(k->first == 1);
+ assert(k->second == "one");
+ ++k;
+ assert(k->first == 1);
+ assert(k->second == "four");
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 3);
+ assert(k->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 4);
+ assert(k->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+ assert(c.erase(4) == 1);
+ assert(c.size() == 3);
+ eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ k = eq.first;
+ assert(k->first == 1);
+ assert(k->second == "one");
+ ++k;
+ assert(k->first == 1);
+ assert(k->second == "four");
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 3);
+ assert(k->second == "three");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+ assert(c.erase(4) == 0);
+ assert(c.size() == 3);
+ eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ k = eq.first;
+ assert(k->first == 1);
+ assert(k->second == "one");
+ ++k;
+ assert(k->first == 1);
+ assert(k->second == "four");
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 3);
+ assert(k->second == "three");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+ assert(c.erase(1) == 2);
+ assert(c.size() == 1);
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 3);
+ assert(k->second == "three");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+ assert(c.erase(1) == 0);
+ assert(c.size() == 1);
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 3);
+ assert(k->second == "three");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+ assert(c.erase(3) == 1);
+ assert(c.size() == 0);
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 0);
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+ assert(c.erase(3) == 0);
+ assert(c.size() == 0);
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 0);
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.erase(5) == 0);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator k = eq.first;
+ assert(k->first == 1);
+ assert(k->second == "one");
+ ++k;
+ assert(k->first == 1);
+ assert(k->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ k = eq.first;
+ assert(k->first == 2);
+ assert(k->second == "two");
+ ++k;
+ assert(k->first == 2);
+ assert(k->second == "four");
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 3);
+ assert(k->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 4);
+ assert(k->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+ assert(c.erase(2) == 2);
+ assert(c.size() == 4);
+ eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ k = eq.first;
+ assert(k->first == 1);
+ assert(k->second == "one");
+ ++k;
+ assert(k->first == 1);
+ assert(k->second == "four");
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 3);
+ assert(k->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 4);
+ assert(k->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+ assert(c.erase(2) == 0);
+ assert(c.size() == 4);
+ eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ k = eq.first;
+ assert(k->first == 1);
+ assert(k->second == "one");
+ ++k;
+ assert(k->first == 1);
+ assert(k->second == "four");
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 3);
+ assert(k->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 4);
+ assert(k->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+ assert(c.erase(4) == 1);
+ assert(c.size() == 3);
+ eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ k = eq.first;
+ assert(k->first == 1);
+ assert(k->second == "one");
+ ++k;
+ assert(k->first == 1);
+ assert(k->second == "four");
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 3);
+ assert(k->second == "three");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+ assert(c.erase(4) == 0);
+ assert(c.size() == 3);
+ eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ k = eq.first;
+ assert(k->first == 1);
+ assert(k->second == "one");
+ ++k;
+ assert(k->first == 1);
+ assert(k->second == "four");
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 3);
+ assert(k->second == "three");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+ assert(c.erase(1) == 2);
+ assert(c.size() == 1);
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 3);
+ assert(k->second == "three");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+ assert(c.erase(1) == 0);
+ assert(c.size() == 1);
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 3);
+ assert(k->second == "three");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+ assert(c.erase(3) == 1);
+ assert(c.size() == 0);
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 0);
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+ assert(c.erase(3) == 0);
+ assert(c.size() == 0);
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 0);
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ }
+ {
+ typedef std::unordered_multimap<int, int> C;
+ C m, m2;
+ for ( int i = 0; i < 10; ++i ) {
+ for (int j = 0; j < 2; ++j ) {
+ m.insert (std::make_pair(i,j));
+ m2.insert(std::make_pair(i,j));
+ }
+ }
+
+ C::iterator i = m2.begin();
+ int ctr = 0;
+ while (i != m2.end()) {
+ if (ctr++ % 2 == 0)
+ m2.erase(i++);
+ else
+ ++i;
+ }
+
+ assert (only_deletions (m, m2));
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_range.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_range.pass.cpp
new file mode 100644
index 000000000000..f60ec071ff70
--- /dev/null
+++ b/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_range.pass.cpp
@@ -0,0 +1,179 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// iterator erase(const_iterator first, const_iterator last)
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ C::const_iterator i = c.find(2);
+ C::const_iterator j = next(i, 2);
+ C::iterator k = c.erase(i, i);
+ assert(k == i);
+ assert(c.size() == 6);
+ typedef std::pair<C::iterator, C::iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ k = eq.first;
+ assert(k->first == 1);
+ assert(k->second == "one");
+ ++k;
+ assert(k->first == 1);
+ assert(k->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ k = eq.first;
+ assert(k->first == 2);
+ assert(k->second == "two");
+ ++k;
+ assert(k->first == 2);
+ assert(k->second == "four");
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 3);
+ assert(k->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 4);
+ assert(k->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+ k = c.erase(i, j);
+ assert(c.size() == 4);
+ eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ k = eq.first;
+ assert(k->first == 1);
+ assert(k->second == "one");
+ ++k;
+ assert(k->first == 1);
+ assert(k->second == "four");
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 3);
+ assert(k->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 4);
+ assert(k->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+ k = c.erase(c.cbegin(), c.cend());
+ assert(c.size() == 0);
+ assert(k == c.end());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ C::const_iterator i = c.find(2);
+ C::const_iterator j = next(i, 2);
+ C::iterator k = c.erase(i, i);
+ assert(k == i);
+ assert(c.size() == 6);
+ typedef std::pair<C::iterator, C::iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ k = eq.first;
+ assert(k->first == 1);
+ assert(k->second == "one");
+ ++k;
+ assert(k->first == 1);
+ assert(k->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ k = eq.first;
+ assert(k->first == 2);
+ assert(k->second == "two");
+ ++k;
+ assert(k->first == 2);
+ assert(k->second == "four");
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 3);
+ assert(k->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 4);
+ assert(k->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+ k = c.erase(i, j);
+ assert(c.size() == 4);
+ eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ k = eq.first;
+ assert(k->first == 1);
+ assert(k->second == "one");
+ ++k;
+ assert(k->first == 1);
+ assert(k->second == "four");
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 3);
+ assert(k->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 4);
+ assert(k->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+ k = c.erase(c.cbegin(), c.cend());
+ assert(c.size() == 0);
+ assert(k == c.end());
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_const_lvalue.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_const_lvalue.pass.cpp
new file mode 100644
index 000000000000..e7e7cb03b6d0
--- /dev/null
+++ b/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_const_lvalue.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// iterator insert(const value_type& x);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<double, int> C;
+ typedef C::iterator R;
+ typedef C::value_type P;
+ C c;
+ R r = c.insert(P(3.5, 3));
+ assert(c.size() == 1);
+ assert(r->first == 3.5);
+ assert(r->second == 3);
+
+ r = c.insert(P(3.5, 4));
+ assert(c.size() == 2);
+ assert(r->first == 3.5);
+ assert(r->second == 4);
+
+ r = c.insert(P(4.5, 4));
+ assert(c.size() == 3);
+ assert(r->first == 4.5);
+ assert(r->second == 4);
+
+ r = c.insert(P(5.5, 4));
+ assert(c.size() == 4);
+ assert(r->first == 5.5);
+ assert(r->second == 4);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<double, int, std::hash<double>, std::equal_to<double>,
+ min_allocator<std::pair<const double, int>>> C;
+ typedef C::iterator R;
+ typedef C::value_type P;
+ C c;
+ R r = c.insert(P(3.5, 3));
+ assert(c.size() == 1);
+ assert(r->first == 3.5);
+ assert(r->second == 3);
+
+ r = c.insert(P(3.5, 4));
+ assert(c.size() == 2);
+ assert(r->first == 3.5);
+ assert(r->second == 4);
+
+ r = c.insert(P(4.5, 4));
+ assert(c.size() == 3);
+ assert(r->first == 4.5);
+ assert(r->second == 4);
+
+ r = c.insert(P(5.5, 4));
+ assert(c.size() == 4);
+ assert(r->first == 5.5);
+ assert(r->second == 4);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_const_lvalue.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_const_lvalue.pass.cpp
new file mode 100644
index 000000000000..c7cb1f4c014b
--- /dev/null
+++ b/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_const_lvalue.pass.cpp
@@ -0,0 +1,97 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// iterator insert(const_iterator p, const value_type& x);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<double, int> C;
+ typedef C::iterator R;
+ typedef C::value_type P;
+ C c;
+ C::const_iterator e = c.end();
+ R r = c.insert(e, P(3.5, 3));
+ assert(c.size() == 1);
+ assert(r->first == 3.5);
+ assert(r->second == 3);
+
+ r = c.insert(c.end(), P(3.5, 4));
+ assert(c.size() == 2);
+ assert(r->first == 3.5);
+ assert(r->second == 4);
+
+ r = c.insert(c.end(), P(4.5, 4));
+ assert(c.size() == 3);
+ assert(r->first == 4.5);
+ assert(r->second == 4);
+
+ r = c.insert(c.end(), P(5.5, 4));
+ assert(c.size() == 4);
+ assert(r->first == 5.5);
+ assert(r->second == 4);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<double, int, std::hash<double>, std::equal_to<double>,
+ min_allocator<std::pair<const double, int>>> C;
+ typedef C::iterator R;
+ typedef C::value_type P;
+ C c;
+ C::const_iterator e = c.end();
+ R r = c.insert(e, P(3.5, 3));
+ assert(c.size() == 1);
+ assert(r->first == 3.5);
+ assert(r->second == 3);
+
+ r = c.insert(c.end(), P(3.5, 4));
+ assert(c.size() == 2);
+ assert(r->first == 3.5);
+ assert(r->second == 4);
+
+ r = c.insert(c.end(), P(4.5, 4));
+ assert(c.size() == 3);
+ assert(r->first == 4.5);
+ assert(r->second == 4);
+
+ r = c.insert(c.end(), P(5.5, 4));
+ assert(c.size() == 4);
+ assert(r->first == 5.5);
+ assert(r->second == 4);
+ }
+#endif
+#if _LIBCPP_DEBUG >= 1
+ {
+ typedef std::unordered_multimap<double, int> C;
+ typedef C::iterator R;
+ typedef C::value_type P;
+ C c;
+ C c2;
+ C::const_iterator e = c2.end();
+ P v(3.5, 3);
+ R r = c.insert(e, v);
+ assert(false);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_rvalue.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_rvalue.pass.cpp
new file mode 100644
index 000000000000..7116fa02b6f5
--- /dev/null
+++ b/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_rvalue.pass.cpp
@@ -0,0 +1,156 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// template <class P,
+// class = typename enable_if<is_convertible<P, value_type>::value>::type>
+// iterator insert(const_iterator p, P&& x);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_map>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<double, int> C;
+ typedef C::iterator R;
+ typedef std::pair<double, short> P;
+ C c;
+ C::const_iterator e = c.end();
+ R r = c.insert(e, P(3.5, 3));
+ assert(c.size() == 1);
+ assert(r->first == 3.5);
+ assert(r->second == 3);
+
+ r = c.insert(r, P(3.5, 4));
+ assert(c.size() == 2);
+ assert(r->first == 3.5);
+ assert(r->second == 4);
+
+ r = c.insert(c.end(), P(4.5, 4));
+ assert(c.size() == 3);
+ assert(r->first == 4.5);
+ assert(r->second == 4);
+
+ r = c.insert(c.end(), P(5.5, 4));
+ assert(c.size() == 4);
+ assert(r->first == 5.5);
+ assert(r->second == 4);
+ }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::unordered_multimap<MoveOnly, MoveOnly> C;
+ typedef C::iterator R;
+ typedef std::pair<MoveOnly, MoveOnly> P;
+ C c;
+ C::const_iterator e = c.end();
+ R r = c.insert(e, P(3, 3));
+ assert(c.size() == 1);
+ assert(r->first == 3);
+ assert(r->second == 3);
+
+ r = c.insert(r, P(3, 4));
+ assert(c.size() == 2);
+ assert(r->first == 3);
+ assert(r->second == 4);
+
+ r = c.insert(c.end(), P(4, 4));
+ assert(c.size() == 3);
+ assert(r->first == 4);
+ assert(r->second == 4);
+
+ r = c.insert(c.end(), P(5, 4));
+ assert(c.size() == 4);
+ assert(r->first == 5);
+ assert(r->second == 4);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<double, int, std::hash<double>, std::equal_to<double>,
+ min_allocator<std::pair<const double, int>>> C;
+ typedef C::iterator R;
+ typedef std::pair<double, short> P;
+ C c;
+ C::const_iterator e = c.end();
+ R r = c.insert(e, P(3.5, 3));
+ assert(c.size() == 1);
+ assert(r->first == 3.5);
+ assert(r->second == 3);
+
+ r = c.insert(r, P(3.5, 4));
+ assert(c.size() == 2);
+ assert(r->first == 3.5);
+ assert(r->second == 4);
+
+ r = c.insert(c.end(), P(4.5, 4));
+ assert(c.size() == 3);
+ assert(r->first == 4.5);
+ assert(r->second == 4);
+
+ r = c.insert(c.end(), P(5.5, 4));
+ assert(c.size() == 4);
+ assert(r->first == 5.5);
+ assert(r->second == 4);
+ }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>,
+ min_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+ typedef C::iterator R;
+ typedef std::pair<MoveOnly, MoveOnly> P;
+ C c;
+ C::const_iterator e = c.end();
+ R r = c.insert(e, P(3, 3));
+ assert(c.size() == 1);
+ assert(r->first == 3);
+ assert(r->second == 3);
+
+ r = c.insert(r, P(3, 4));
+ assert(c.size() == 2);
+ assert(r->first == 3);
+ assert(r->second == 4);
+
+ r = c.insert(c.end(), P(4, 4));
+ assert(c.size() == 3);
+ assert(r->first == 4);
+ assert(r->second == 4);
+
+ r = c.insert(c.end(), P(5, 4));
+ assert(c.size() == 4);
+ assert(r->first == 5);
+ assert(r->second == 4);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if _LIBCPP_DEBUG >= 1
+ {
+ typedef std::unordered_multimap<double, int> C;
+ typedef C::iterator R;
+ typedef C::value_type P;
+ C c;
+ C c2;
+ C::const_iterator e = c2.end();
+ R r = c.insert(e, P(3.5, 3));
+ assert(false);
+ }
+#endif
+#endif
+}
diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_init.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_init.pass.cpp
new file mode 100644
index 000000000000..23dbe84a3c51
--- /dev/null
+++ b/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_init.pass.cpp
@@ -0,0 +1,122 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// void insert(initializer_list<value_type> il);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ C c;
+ c.insert(
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ }
+ );
+ assert(c.size() == 6);
+ typedef std::pair<C::iterator, C::iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::iterator k = eq.first;
+ assert(k->first == 1);
+ assert(k->second == "one");
+ ++k;
+ assert(k->first == 1);
+ assert(k->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ k = eq.first;
+ assert(k->first == 2);
+ assert(k->second == "two");
+ ++k;
+ assert(k->first == 2);
+ assert(k->second == "four");
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 3);
+ assert(k->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 4);
+ assert(k->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ C c;
+ c.insert(
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ }
+ );
+ assert(c.size() == 6);
+ typedef std::pair<C::iterator, C::iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::iterator k = eq.first;
+ assert(k->first == 1);
+ assert(k->second == "one");
+ ++k;
+ assert(k->first == 1);
+ assert(k->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ k = eq.first;
+ assert(k->first == 2);
+ assert(k->second == "two");
+ ++k;
+ assert(k->first == 2);
+ assert(k->second == "four");
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 3);
+ assert(k->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 4);
+ assert(k->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_range.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_range.pass.cpp
new file mode 100644
index 000000000000..2820639b4ea0
--- /dev/null
+++ b/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_range.pass.cpp
@@ -0,0 +1,121 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// template <class InputIterator>
+// void insert(InputIterator first, InputIterator last);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c;
+ c.insert(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])));
+ assert(c.size() == 6);
+ typedef std::pair<C::iterator, C::iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::iterator k = eq.first;
+ assert(k->first == 1);
+ assert(k->second == "one");
+ ++k;
+ assert(k->first == 1);
+ assert(k->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ k = eq.first;
+ assert(k->first == 2);
+ assert(k->second == "two");
+ ++k;
+ assert(k->first == 2);
+ assert(k->second == "four");
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 3);
+ assert(k->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 4);
+ assert(k->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c;
+ c.insert(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])));
+ assert(c.size() == 6);
+ typedef std::pair<C::iterator, C::iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::iterator k = eq.first;
+ assert(k->first == 1);
+ assert(k->second == "one");
+ ++k;
+ assert(k->first == 1);
+ assert(k->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ k = eq.first;
+ assert(k->first == 2);
+ assert(k->second == "two");
+ ++k;
+ assert(k->first == 2);
+ assert(k->second == "four");
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 3);
+ assert(k->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 4);
+ assert(k->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_rvalue.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_rvalue.pass.cpp
new file mode 100644
index 000000000000..5a98467e9d0f
--- /dev/null
+++ b/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_rvalue.pass.cpp
@@ -0,0 +1,136 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// template <class P,
+// class = typename enable_if<is_convertible<P, value_type>::value>::type>
+// iterator insert(P&& x);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<double, int> C;
+ typedef C::iterator R;
+ typedef std::pair<double, short> P;
+ C c;
+ R r = c.insert(P(3.5, 3));
+ assert(c.size() == 1);
+ assert(r->first == 3.5);
+ assert(r->second == 3);
+
+ r = c.insert(P(3.5, 4));
+ assert(c.size() == 2);
+ assert(r->first == 3.5);
+ assert(r->second == 4);
+
+ r = c.insert(P(4.5, 4));
+ assert(c.size() == 3);
+ assert(r->first == 4.5);
+ assert(r->second == 4);
+
+ r = c.insert(P(5.5, 4));
+ assert(c.size() == 4);
+ assert(r->first == 5.5);
+ assert(r->second == 4);
+ }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::unordered_multimap<MoveOnly, MoveOnly> C;
+ typedef C::iterator R;
+ typedef std::pair<MoveOnly, MoveOnly> P;
+ C c;
+ R r = c.insert(P(3, 3));
+ assert(c.size() == 1);
+ assert(r->first == 3);
+ assert(r->second == 3);
+
+ r = c.insert(P(3, 4));
+ assert(c.size() == 2);
+ assert(r->first == 3);
+ assert(r->second == 4);
+
+ r = c.insert(P(4, 4));
+ assert(c.size() == 3);
+ assert(r->first == 4);
+ assert(r->second == 4);
+
+ r = c.insert(P(5, 4));
+ assert(c.size() == 4);
+ assert(r->first == 5);
+ assert(r->second == 4);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<double, int, std::hash<double>, std::equal_to<double>,
+ min_allocator<std::pair<const double, int>>> C;
+ typedef C::iterator R;
+ typedef std::pair<double, short> P;
+ C c;
+ R r = c.insert(P(3.5, 3));
+ assert(c.size() == 1);
+ assert(r->first == 3.5);
+ assert(r->second == 3);
+
+ r = c.insert(P(3.5, 4));
+ assert(c.size() == 2);
+ assert(r->first == 3.5);
+ assert(r->second == 4);
+
+ r = c.insert(P(4.5, 4));
+ assert(c.size() == 3);
+ assert(r->first == 4.5);
+ assert(r->second == 4);
+
+ r = c.insert(P(5.5, 4));
+ assert(c.size() == 4);
+ assert(r->first == 5.5);
+ assert(r->second == 4);
+ }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>,
+ min_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+ typedef C::iterator R;
+ typedef std::pair<MoveOnly, MoveOnly> P;
+ C c;
+ R r = c.insert(P(3, 3));
+ assert(c.size() == 1);
+ assert(r->first == 3);
+ assert(r->second == 3);
+
+ r = c.insert(P(3, 4));
+ assert(c.size() == 2);
+ assert(r->first == 3);
+ assert(r->second == 4);
+
+ r = c.insert(P(4, 4));
+ assert(c.size() == 3);
+ assert(r->first == 4);
+ assert(r->second == 4);
+
+ r = c.insert(P(5, 4));
+ assert(c.size() == 4);
+ assert(r->first == 5);
+ assert(r->second == 4);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif
+}
diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.swap/db_swap_1.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.swap/db_swap_1.pass.cpp
new file mode 100644
index 000000000000..a332b6fa4189
--- /dev/null
+++ b/test/std/containers/unord/unord.multimap/unord.multimap.swap/db_swap_1.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class Value, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, Value>>>
+// class unordered_multimap
+
+// void swap(unordered_multimap& x, unordered_multimap& y);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_map>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_DEBUG >= 1
+ {
+ typedef std::pair<int, int> P;
+ P a1[] = {P(1, 1), P(3, 3), P(7, 7), P(9, 9), P(10, 10)};
+ P a2[] = {P(0, 0), P(2, 2), P(4, 4), P(5, 5), P(6, 6), P(8, 8), P(11, 11)};
+ std::unordered_multimap<int, int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ std::unordered_multimap<int, int> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+ std::unordered_multimap<int, int>::iterator i1 = c1.begin();
+ std::unordered_multimap<int, int>::iterator i2 = c2.begin();
+ swap(c1, c2);
+ c1.erase(i2);
+ c2.erase(i1);
+ std::unordered_multimap<int, int>::iterator j = i1;
+ c1.erase(i1);
+ assert(false);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.swap/swap_noexcept.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.swap/swap_noexcept.pass.cpp
new file mode 100644
index 000000000000..37c8119060b7
--- /dev/null
+++ b/test/std/containers/unord/unord.multimap/unord.multimap.swap/swap_noexcept.pass.cpp
@@ -0,0 +1,198 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// void swap(unordered_multimap& c)
+// noexcept(
+// (!allocator_type::propagate_on_container_swap::value ||
+// __is_nothrow_swappable<allocator_type>::value) &&
+// __is_nothrow_swappable<hasher>::value &&
+// __is_nothrow_swappable<key_equal>::value);
+//
+// In C++17, the standard says that swap shall have:
+// noexcept(allocator_traits<allocator_type>::is_always_equal::value &&
+// __is_nothrow_swappable<hasher>::value &&
+// __is_nothrow_swappable<key_equal>::value);
+
+// This tests a conforming extension
+
+#include <unordered_map>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_comp
+{
+ typedef T value_type;
+
+ some_comp() {}
+ some_comp(const some_comp&) {}
+};
+
+template <class T>
+struct some_comp2
+{
+ typedef T value_type;
+
+ some_comp2() {}
+ some_comp2(const some_comp2&) {}
+ void deallocate(void*, unsigned) {}
+ typedef std::true_type propagate_on_container_swap;
+};
+
+#if TEST_STD_VER >= 14
+template <typename T>
+void swap(some_comp2<T>&, some_comp2<T>&) noexcept {}
+#endif
+
+template <class T>
+struct some_hash
+{
+ typedef T value_type;
+ some_hash() {}
+ some_hash(const some_hash&);
+};
+
+template <class T>
+struct some_hash2
+{
+ typedef T value_type;
+ some_hash2() {}
+ some_hash2(const some_hash2&);
+};
+
+#if TEST_STD_VER >= 14
+template <typename T>
+void swap(some_hash2<T>&, some_hash2<T>&) noexcept {}
+#endif
+
+template <class T>
+struct some_alloc
+{
+ typedef T value_type;
+
+ some_alloc() {}
+ some_alloc(const some_alloc&);
+ void deallocate(void*, unsigned) {}
+
+ typedef std::true_type propagate_on_container_swap;
+};
+
+template <class T>
+struct some_alloc2
+{
+ typedef T value_type;
+
+ some_alloc2() {}
+ some_alloc2(const some_alloc2&);
+ void deallocate(void*, unsigned) {}
+
+ typedef std::false_type propagate_on_container_swap;
+ typedef std::true_type is_always_equal;
+};
+
+template <class T>
+struct some_alloc3
+{
+ typedef T value_type;
+
+ some_alloc3() {}
+ some_alloc3(const some_alloc3&);
+ void deallocate(void*, unsigned) {}
+
+ typedef std::false_type propagate_on_container_swap;
+ typedef std::false_type is_always_equal;
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ typedef std::pair<const MoveOnly, MoveOnly> MapType;
+ {
+ typedef std::unordered_multimap<MoveOnly, MoveOnly> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, test_allocator<MapType>> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, other_allocator<MapType>> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::unordered_multimap<MoveOnly, MoveOnly, some_hash<MoveOnly>> C;
+ C c1, c2;
+ static_assert(!noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ some_comp<MoveOnly>> C;
+ C c1, c2;
+ static_assert(!noexcept(swap(c1, c2)), "");
+ }
+
+#if TEST_STD_VER >= 14
+ { // POCS allocator, throwable swap for hash, throwable swap for comp
+ typedef std::unordered_multimap<MoveOnly, MoveOnly, some_hash<MoveOnly>, some_comp <MoveOnly>, some_alloc <MapType>> C;
+ C c1, c2;
+ static_assert(!noexcept(swap(c1, c2)), "");
+ }
+ { // always equal allocator, throwable swap for hash, throwable swap for comp
+ typedef std::unordered_multimap<MoveOnly, MoveOnly, some_hash<MoveOnly>, some_comp <MoveOnly>, some_alloc2<MapType>> C;
+ C c1, c2;
+ static_assert(!noexcept(swap(c1, c2)), "");
+ }
+ { // POCS allocator, throwable swap for hash, nothrow swap for comp
+ typedef std::unordered_multimap<MoveOnly, MoveOnly, some_hash<MoveOnly>, some_comp2<MoveOnly>, some_alloc <MapType>> C;
+ C c1, c2;
+ static_assert(!noexcept(swap(c1, c2)), "");
+ }
+ { // always equal allocator, throwable swap for hash, nothrow swap for comp
+ typedef std::unordered_multimap<MoveOnly, MoveOnly, some_hash<MoveOnly>, some_comp2<MoveOnly>, some_alloc2<MapType>> C;
+ C c1, c2;
+ static_assert(!noexcept(swap(c1, c2)), "");
+ }
+ { // POCS allocator, nothrow swap for hash, throwable swap for comp
+ typedef std::unordered_multimap<MoveOnly, MoveOnly, some_hash2<MoveOnly>, some_comp <MoveOnly>, some_alloc <MapType>> C;
+ C c1, c2;
+ static_assert(!noexcept(swap(c1, c2)), "");
+ }
+ { // always equal allocator, nothrow swap for hash, throwable swap for comp
+ typedef std::unordered_multimap<MoveOnly, MoveOnly, some_hash2<MoveOnly>, some_comp <MoveOnly>, some_alloc2<MapType>> C;
+ C c1, c2;
+ static_assert(!noexcept(swap(c1, c2)), "");
+ }
+ { // POCS allocator, nothrow swap for hash, nothrow swap for comp
+ typedef std::unordered_multimap<MoveOnly, MoveOnly, some_hash2<MoveOnly>, some_comp2<MoveOnly>, some_alloc <MapType>> C;
+ C c1, c2;
+ static_assert( noexcept(swap(c1, c2)), "");
+ }
+ { // always equal allocator, nothrow swap for hash, nothrow swap for comp
+ typedef std::unordered_multimap<MoveOnly, MoveOnly, some_hash2<MoveOnly>, some_comp2<MoveOnly>, some_alloc2<MapType>> C;
+ C c1, c2;
+ static_assert( noexcept(swap(c1, c2)), "");
+ }
+ { // NOT always equal allocator, nothrow swap for hash, nothrow swap for comp
+ typedef std::unordered_multimap<MoveOnly, MoveOnly, some_hash2<MoveOnly>, some_comp2<MoveOnly>, some_alloc3<MapType>> C;
+ C c1, c2;
+ static_assert( noexcept(swap(c1, c2)), "");
+ }
+#endif
+
+#endif
+}
diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.swap/swap_non_member.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.swap/swap_non_member.pass.cpp
new file mode 100644
index 000000000000..0f579e091683
--- /dev/null
+++ b/test/std/containers/unord/unord.multimap/unord.multimap.swap/swap_non_member.pass.cpp
@@ -0,0 +1,584 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// void swap(unordered_multimap& __u);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef test_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ C c1(0, Hash(1), Compare(1), Alloc(1));
+ C c2(0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(1));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(2));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef test_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a2[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c1(0, Hash(1), Compare(1), Alloc(1));
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(c1.find(10)->second == "ten");
+ assert(c1.find(20)->second == "twenty");
+ assert(c1.find(30)->second == "thirty");
+ assert(c1.find(40)->second == "forty");
+ assert(c1.find(50)->second == "fifty");
+ assert(c1.find(60)->second == "sixty");
+ assert(c1.find(70)->second == "seventy");
+ assert(c1.find(80)->second == "eighty");
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(1));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(2));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef test_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a1[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+ C c2(0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(1));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 7);
+ assert(c2.size() == 6);
+ assert(c2.find(1)->second == "one");
+ assert(next(c2.find(1))->second == "four");
+ assert(c2.find(2)->second == "two");
+ assert(next(c2.find(2))->second == "four");
+ assert(c2.find(3)->second == "three");
+ assert(c2.find(4)->second == "four");
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(2));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef test_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a1[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ P a2[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(c1.find(10)->second == "ten");
+ assert(c1.find(20)->second == "twenty");
+ assert(c1.find(30)->second == "thirty");
+ assert(c1.find(40)->second == "forty");
+ assert(c1.find(50)->second == "fifty");
+ assert(c1.find(60)->second == "sixty");
+ assert(c1.find(70)->second == "seventy");
+ assert(c1.find(80)->second == "eighty");
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(1));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 7);
+ assert(c2.size() == 6);
+ assert(c2.find(1)->second == "one");
+ assert(next(c2.find(1))->second == "four");
+ assert(c2.find(2)->second == "two");
+ assert(next(c2.find(2))->second == "four");
+ assert(c2.find(3)->second == "three");
+ assert(c2.find(4)->second == "four");
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(2));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef other_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ C c1(0, Hash(1), Compare(1), Alloc(1));
+ C c2(0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(2));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(1));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef other_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a2[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c1(0, Hash(1), Compare(1), Alloc(1));
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(c1.find(10)->second == "ten");
+ assert(c1.find(20)->second == "twenty");
+ assert(c1.find(30)->second == "thirty");
+ assert(c1.find(40)->second == "forty");
+ assert(c1.find(50)->second == "fifty");
+ assert(c1.find(60)->second == "sixty");
+ assert(c1.find(70)->second == "seventy");
+ assert(c1.find(80)->second == "eighty");
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(2));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(1));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef other_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a1[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+ C c2(0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(2));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 7);
+ assert(c2.size() == 6);
+ assert(c2.find(1)->second == "one");
+ assert(next(c2.find(1))->second == "four");
+ assert(c2.find(2)->second == "two");
+ assert(next(c2.find(2))->second == "four");
+ assert(c2.find(3)->second == "three");
+ assert(c2.find(4)->second == "four");
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(1));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef other_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a1[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ P a2[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(c1.find(10)->second == "ten");
+ assert(c1.find(20)->second == "twenty");
+ assert(c1.find(30)->second == "thirty");
+ assert(c1.find(40)->second == "forty");
+ assert(c1.find(50)->second == "fifty");
+ assert(c1.find(60)->second == "sixty");
+ assert(c1.find(70)->second == "seventy");
+ assert(c1.find(80)->second == "eighty");
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(2));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 7);
+ assert(c2.size() == 6);
+ assert(c2.find(1)->second == "one");
+ assert(next(c2.find(1))->second == "four");
+ assert(c2.find(2)->second == "two");
+ assert(next(c2.find(2))->second == "four");
+ assert(c2.find(3)->second == "three");
+ assert(c2.find(4)->second == "four");
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(1));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef min_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ C c1(0, Hash(1), Compare(1), Alloc());
+ C c2(0, Hash(2), Compare(2), Alloc());
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc());
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc());
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef min_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a2[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c1(0, Hash(1), Compare(1), Alloc());
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc());
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(c1.find(10)->second == "ten");
+ assert(c1.find(20)->second == "twenty");
+ assert(c1.find(30)->second == "thirty");
+ assert(c1.find(40)->second == "forty");
+ assert(c1.find(50)->second == "fifty");
+ assert(c1.find(60)->second == "sixty");
+ assert(c1.find(70)->second == "seventy");
+ assert(c1.find(80)->second == "eighty");
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc());
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc());
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef min_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a1[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc());
+ C c2(0, Hash(2), Compare(2), Alloc());
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc());
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 7);
+ assert(c2.size() == 6);
+ assert(c2.find(1)->second == "one");
+ assert(next(c2.find(1))->second == "four");
+ assert(c2.find(2)->second == "two");
+ assert(next(c2.find(2))->second == "four");
+ assert(c2.find(3)->second == "three");
+ assert(c2.find(4)->second == "four");
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc());
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef min_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a1[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ P a2[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc());
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc());
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(c1.find(10)->second == "ten");
+ assert(c1.find(20)->second == "twenty");
+ assert(c1.find(30)->second == "thirty");
+ assert(c1.find(40)->second == "forty");
+ assert(c1.find(50)->second == "fifty");
+ assert(c1.find(60)->second == "sixty");
+ assert(c1.find(70)->second == "seventy");
+ assert(c1.find(80)->second == "eighty");
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc());
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 7);
+ assert(c2.size() == 6);
+ assert(c2.find(1)->second == "one");
+ assert(next(c2.find(1))->second == "four");
+ assert(c2.find(2)->second == "two");
+ assert(next(c2.find(2))->second == "four");
+ assert(c2.find(3)->second == "three");
+ assert(c2.find(4)->second == "four");
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc());
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multiset/bucket.pass.cpp b/test/std/containers/unord/unord.multiset/bucket.pass.cpp
new file mode 100644
index 000000000000..0293133d494a
--- /dev/null
+++ b/test/std/containers/unord/unord.multiset/bucket.pass.cpp
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// size_type bucket(const key_type& __k) const;
+
+#ifdef _LIBCPP_DEBUG
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multiset<int> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ const C c(std::begin(a), std::end(a));
+ size_t bc = c.bucket_count();
+ assert(bc >= 7);
+ for (size_t i = 0; i < 13; ++i)
+ assert(c.bucket(i) == i % bc);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ const C c(std::begin(a), std::end(a));
+ size_t bc = c.bucket_count();
+ assert(bc >= 7);
+ for (size_t i = 0; i < 13; ++i)
+ assert(c.bucket(i) == i % bc);
+ }
+#endif
+#if _LIBCPP_DEBUG_LEVEL >= 1
+ {
+ typedef std::unordered_multiset<int> C;
+ C c;
+ C::size_type i = c.bucket(3);
+ assert(false);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multiset/bucket_count.pass.cpp b/test/std/containers/unord/unord.multiset/bucket_count.pass.cpp
new file mode 100644
index 000000000000..c7842e5c1977
--- /dev/null
+++ b/test/std/containers/unord/unord.multiset/bucket_count.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// size_type bucket_count() const;
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multiset<int> C;
+ typedef C::const_iterator I;
+ typedef int P;
+ const C c;
+ assert(c.bucket_count() == 0);
+ }
+ {
+ typedef std::unordered_multiset<int> C;
+ typedef C::const_iterator I;
+ typedef int P;
+ P a[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ const C c(std::begin(a), std::end(a));
+ assert(c.bucket_count() >= 11);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef C::const_iterator I;
+ typedef int P;
+ const C c;
+ assert(c.bucket_count() == 0);
+ }
+ {
+ typedef std::unordered_multiset<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef C::const_iterator I;
+ typedef int P;
+ P a[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ const C c(std::begin(a), std::end(a));
+ assert(c.bucket_count() >= 11);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multiset/bucket_size.pass.cpp b/test/std/containers/unord/unord.multiset/bucket_size.pass.cpp
new file mode 100644
index 000000000000..639d7ac37965
--- /dev/null
+++ b/test/std/containers/unord/unord.multiset/bucket_size.pass.cpp
@@ -0,0 +1,84 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// size_type bucket_size(size_type n) const
+
+#ifdef _LIBCPP_DEBUG
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multiset<int> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ const C c(std::begin(a), std::end(a));
+ assert(c.bucket_count() >= 7);
+ assert(c.bucket_size(0) == 0);
+ assert(c.bucket_size(1) == 2);
+ assert(c.bucket_size(2) == 2);
+ assert(c.bucket_size(3) == 1);
+ assert(c.bucket_size(4) == 1);
+ assert(c.bucket_size(5) == 0);
+ assert(c.bucket_size(6) == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ const C c(std::begin(a), std::end(a));
+ assert(c.bucket_count() >= 7);
+ assert(c.bucket_size(0) == 0);
+ assert(c.bucket_size(1) == 2);
+ assert(c.bucket_size(2) == 2);
+ assert(c.bucket_size(3) == 1);
+ assert(c.bucket_size(4) == 1);
+ assert(c.bucket_size(5) == 0);
+ assert(c.bucket_size(6) == 0);
+ }
+#endif
+#if _LIBCPP_DEBUG_LEVEL >= 1
+ {
+ typedef std::unordered_multiset<int> C;
+ C c;
+ C::size_type i = c.bucket_size(3);
+ assert(false);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multiset/clear.pass.cpp b/test/std/containers/unord/unord.multiset/clear.pass.cpp
new file mode 100644
index 000000000000..61ca847e7c4a
--- /dev/null
+++ b/test/std/containers/unord/unord.multiset/clear.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// void clear()
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multiset<int> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ c.clear();
+ assert(c.size() == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ c.clear();
+ assert(c.size() == 0);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multiset/count.pass.cpp b/test/std/containers/unord/unord.multiset/count.pass.cpp
new file mode 100644
index 000000000000..e548324d9545
--- /dev/null
+++ b/test/std/containers/unord/unord.multiset/count.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// size_type count(const key_type& k) const;
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multiset<int> C;
+ typedef int P;
+ P a[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(50),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ const C c(std::begin(a), std::end(a));
+ assert(c.count(30) == 1);
+ assert(c.count(50) == 3);
+ assert(c.count(5) == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ P a[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(50),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ const C c(std::begin(a), std::end(a));
+ assert(c.count(30) == 1);
+ assert(c.count(50) == 3);
+ assert(c.count(5) == 0);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multiset/db_iterators_7.pass.cpp b/test/std/containers/unord/unord.multiset/db_iterators_7.pass.cpp
new file mode 100644
index 000000000000..c8ef2fbca163
--- /dev/null
+++ b/test/std/containers/unord/unord.multiset/db_iterators_7.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// Increment iterator past end.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_set>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::unordered_multiset<T> C;
+ C c(1);
+ C::iterator i = c.begin();
+ ++i;
+ assert(i == c.end());
+ ++i;
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::unordered_multiset<T, min_allocator<T>> C;
+ C c(1);
+ C::iterator i = c.begin();
+ ++i;
+ assert(i == c.end());
+ ++i;
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/containers/unord/unord.multiset/db_iterators_8.pass.cpp b/test/std/containers/unord/unord.multiset/db_iterators_8.pass.cpp
new file mode 100644
index 000000000000..eef799787947
--- /dev/null
+++ b/test/std/containers/unord/unord.multiset/db_iterators_8.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// Dereference non-dereferenceable iterator.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_set>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::unordered_multiset<T> C;
+ C c(1);
+ C::iterator i = c.end();
+ T j = *i;
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::unordered_multiset<T, min_allocator<T>> C;
+ C c(1);
+ C::iterator i = c.end();
+ T j = *i;
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/containers/unord/unord.multiset/db_local_iterators_7.pass.cpp b/test/std/containers/unord/unord.multiset/db_local_iterators_7.pass.cpp
new file mode 100644
index 000000000000..c1de95cace71
--- /dev/null
+++ b/test/std/containers/unord/unord.multiset/db_local_iterators_7.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// Increment local_iterator past end.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_set>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::unordered_multiset<T> C;
+ C c(1);
+ C::local_iterator i = c.begin(0);
+ ++i;
+ ++i;
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::unordered_multiset<T, min_allocator<T>> C;
+ C c(1);
+ C::local_iterator i = c.begin(0);
+ ++i;
+ ++i;
+ assert(false);
+ }
+#endif
+
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/containers/unord/unord.multiset/db_local_iterators_8.pass.cpp b/test/std/containers/unord/unord.multiset/db_local_iterators_8.pass.cpp
new file mode 100644
index 000000000000..962b85298ae1
--- /dev/null
+++ b/test/std/containers/unord/unord.multiset/db_local_iterators_8.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// Dereference non-dereferenceable iterator.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_set>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::unordered_multiset<T> C;
+ C c(1);
+ C::local_iterator i = c.end(0);
+ T j = *i;
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::unordered_multiset<T, min_allocator<T>> C;
+ C c(1);
+ C::local_iterator i = c.end(0);
+ T j = *i;
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/containers/unord/unord.multiset/emplace.pass.cpp b/test/std/containers/unord/unord.multiset/emplace.pass.cpp
new file mode 100644
index 000000000000..13787d9b4037
--- /dev/null
+++ b/test/std/containers/unord/unord.multiset/emplace.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// template <class... Args>
+// iterator emplace(Args&&... args);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../Emplaceable.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::unordered_multiset<Emplaceable> C;
+ typedef C::iterator R;
+ C c;
+ R r = c.emplace();
+ assert(c.size() == 1);
+ assert(*r == Emplaceable());
+
+ r = c.emplace(Emplaceable(5, 6));
+ assert(c.size() == 2);
+ assert(*r == Emplaceable(5, 6));
+
+ r = c.emplace(5, 6);
+ assert(c.size() == 3);
+ assert(*r == Emplaceable(5, 6));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<Emplaceable, std::hash<Emplaceable>,
+ std::equal_to<Emplaceable>, min_allocator<Emplaceable>> C;
+ typedef C::iterator R;
+ C c;
+ R r = c.emplace();
+ assert(c.size() == 1);
+ assert(*r == Emplaceable());
+
+ r = c.emplace(Emplaceable(5, 6));
+ assert(c.size() == 2);
+ assert(*r == Emplaceable(5, 6));
+
+ r = c.emplace(5, 6);
+ assert(c.size() == 3);
+ assert(*r == Emplaceable(5, 6));
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/unord/unord.multiset/emplace_hint.pass.cpp b/test/std/containers/unord/unord.multiset/emplace_hint.pass.cpp
new file mode 100644
index 000000000000..8885cc03cf03
--- /dev/null
+++ b/test/std/containers/unord/unord.multiset/emplace_hint.pass.cpp
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// template <class... Args>
+// iterator emplace_hint(const_iterator p, Args&&... args);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../Emplaceable.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::unordered_multiset<Emplaceable> C;
+ typedef C::iterator R;
+ C c;
+ C::const_iterator e = c.end();
+ R r = c.emplace_hint(e);
+ assert(c.size() == 1);
+ assert(*r == Emplaceable());
+
+ r = c.emplace_hint(c.end(), Emplaceable(5, 6));
+ assert(c.size() == 2);
+ assert(*r == Emplaceable(5, 6));
+
+ r = c.emplace_hint(r, 5, 6);
+ assert(c.size() == 3);
+ assert(*r == Emplaceable(5, 6));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<Emplaceable, std::hash<Emplaceable>,
+ std::equal_to<Emplaceable>, min_allocator<Emplaceable>> C;
+ typedef C::iterator R;
+ C c;
+ C::const_iterator e = c.end();
+ R r = c.emplace_hint(e);
+ assert(c.size() == 1);
+ assert(*r == Emplaceable());
+
+ r = c.emplace_hint(c.end(), Emplaceable(5, 6));
+ assert(c.size() == 2);
+ assert(*r == Emplaceable(5, 6));
+
+ r = c.emplace_hint(r, 5, 6);
+ assert(c.size() == 3);
+ assert(*r == Emplaceable(5, 6));
+ }
+#endif
+#if _LIBCPP_DEBUG >= 1
+ {
+ typedef std::unordered_multiset<Emplaceable> C;
+ typedef C::iterator R;
+ C c1;
+ C c2;
+ R r = c1.emplace_hint(c2.begin(), 5, 6);
+ assert(false);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/unord/unord.multiset/eq.pass.cpp b/test/std/containers/unord/unord.multiset/eq.pass.cpp
new file mode 100644
index 000000000000..bbedbc905a4b
--- /dev/null
+++ b/test/std/containers/unord/unord.multiset/eq.pass.cpp
@@ -0,0 +1,180 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Key, class Hash, class Pred, class Alloc>
+// bool
+// operator==(const unordered_multiset<Key, Hash, Pred, Alloc>& x,
+// const unordered_multiset<Key, Hash, Pred, Alloc>& y);
+//
+// template <class Key, class Hash, class Pred, class Alloc>
+// bool
+// operator!=(const unordered_multiset<Key, Hash, Pred, Alloc>& x,
+// const unordered_multiset<Key, Hash, Pred, Alloc>& y);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multiset<int> C;
+ typedef int P;
+ P a[] =
+ {
+ P(10),
+ P(20),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(50),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ const C c1(std::begin(a), std::end(a));
+ const C c2;
+ assert(!(c1 == c2));
+ assert( (c1 != c2));
+ }
+ {
+ typedef std::unordered_multiset<int> C;
+ typedef int P;
+ P a[] =
+ {
+ P(10),
+ P(20),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(50),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ const C c1(std::begin(a), std::end(a));
+ const C c2 = c1;
+ assert( (c1 == c2));
+ assert(!(c1 != c2));
+ }
+ {
+ typedef std::unordered_multiset<int> C;
+ typedef int P;
+ P a[] =
+ {
+ P(10),
+ P(20),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(50),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ C c1(std::begin(a), std::end(a));
+ C c2 = c1;
+ c2.rehash(30);
+ assert( (c1 == c2));
+ assert(!(c1 != c2));
+ c2.insert(P(90));
+ assert(!(c1 == c2));
+ assert( (c1 != c2));
+ c1.insert(P(90));
+ assert( (c1 == c2));
+ assert(!(c1 != c2));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ P a[] =
+ {
+ P(10),
+ P(20),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(50),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ const C c1(std::begin(a), std::end(a));
+ const C c2;
+ assert(!(c1 == c2));
+ assert( (c1 != c2));
+ }
+ {
+ typedef std::unordered_multiset<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ P a[] =
+ {
+ P(10),
+ P(20),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(50),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ const C c1(std::begin(a), std::end(a));
+ const C c2 = c1;
+ assert( (c1 == c2));
+ assert(!(c1 != c2));
+ }
+ {
+ typedef std::unordered_multiset<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ P a[] =
+ {
+ P(10),
+ P(20),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(50),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ C c1(std::begin(a), std::end(a));
+ C c2 = c1;
+ c2.rehash(30);
+ assert( (c1 == c2));
+ assert(!(c1 != c2));
+ c2.insert(P(90));
+ assert(!(c1 == c2));
+ assert( (c1 != c2));
+ c1.insert(P(90));
+ assert( (c1 == c2));
+ assert(!(c1 != c2));
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multiset/equal_range_const.pass.cpp b/test/std/containers/unord/unord.multiset/equal_range_const.pass.cpp
new file mode 100644
index 000000000000..a0aaac2bd868
--- /dev/null
+++ b/test/std/containers/unord/unord.multiset/equal_range_const.pass.cpp
@@ -0,0 +1,90 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multiset<int> C;
+ typedef C::const_iterator I;
+ typedef int P;
+ P a[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(50),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ const C c(std::begin(a), std::end(a));
+ std::pair<I, I> r = c.equal_range(30);
+ assert(std::distance(r.first, r.second) == 1);
+ assert(*r.first == 30);
+ r = c.equal_range(5);
+ assert(std::distance(r.first, r.second) == 0);
+ r = c.equal_range(50);
+ assert(std::distance(r.first, r.second) == 3);
+ assert(*r.first == 50);
+ ++r.first;
+ assert(*r.first == 50);
+ ++r.first;
+ assert(*r.first == 50);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef C::const_iterator I;
+ typedef int P;
+ P a[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(50),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ const C c(std::begin(a), std::end(a));
+ std::pair<I, I> r = c.equal_range(30);
+ assert(std::distance(r.first, r.second) == 1);
+ assert(*r.first == 30);
+ r = c.equal_range(5);
+ assert(std::distance(r.first, r.second) == 0);
+ r = c.equal_range(50);
+ assert(std::distance(r.first, r.second) == 3);
+ assert(*r.first == 50);
+ ++r.first;
+ assert(*r.first == 50);
+ ++r.first;
+ assert(*r.first == 50);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multiset/equal_range_non_const.pass.cpp b/test/std/containers/unord/unord.multiset/equal_range_non_const.pass.cpp
new file mode 100644
index 000000000000..73d44f7a56b7
--- /dev/null
+++ b/test/std/containers/unord/unord.multiset/equal_range_non_const.pass.cpp
@@ -0,0 +1,90 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// pair<iterator, iterator> equal_range(const key_type& k);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multiset<int> C;
+ typedef C::iterator I;
+ typedef int P;
+ P a[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(50),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ C c(std::begin(a), std::end(a));
+ std::pair<I, I> r = c.equal_range(30);
+ assert(std::distance(r.first, r.second) == 1);
+ assert(*r.first == 30);
+ r = c.equal_range(5);
+ assert(std::distance(r.first, r.second) == 0);
+ r = c.equal_range(50);
+ assert(std::distance(r.first, r.second) == 3);
+ assert(*r.first == 50);
+ ++r.first;
+ assert(*r.first == 50);
+ ++r.first;
+ assert(*r.first == 50);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef C::iterator I;
+ typedef int P;
+ P a[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(50),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ C c(std::begin(a), std::end(a));
+ std::pair<I, I> r = c.equal_range(30);
+ assert(std::distance(r.first, r.second) == 1);
+ assert(*r.first == 30);
+ r = c.equal_range(5);
+ assert(std::distance(r.first, r.second) == 0);
+ r = c.equal_range(50);
+ assert(std::distance(r.first, r.second) == 3);
+ assert(*r.first == 50);
+ ++r.first;
+ assert(*r.first == 50);
+ ++r.first;
+ assert(*r.first == 50);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multiset/erase_const_iter.pass.cpp b/test/std/containers/unord/unord.multiset/erase_const_iter.pass.cpp
new file mode 100644
index 000000000000..d3be2b6d6365
--- /dev/null
+++ b/test/std/containers/unord/unord.multiset/erase_const_iter.pass.cpp
@@ -0,0 +1,93 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// iterator erase(const_iterator p)
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+struct TemplateConstructor
+{
+ template<typename T>
+ TemplateConstructor (const T&) {}
+};
+
+bool operator==(const TemplateConstructor&, const TemplateConstructor&) { return false; }
+struct Hash { size_t operator() (const TemplateConstructor &) const { return 0; } };
+
+int main()
+{
+ {
+ typedef std::unordered_multiset<int> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ C::const_iterator i = c.find(2);
+ C::iterator j = c.erase(i);
+ assert(c.size() == 5);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ C::const_iterator i = c.find(2);
+ C::iterator j = c.erase(i);
+ assert(c.size() == 5);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ }
+#endif
+#if __cplusplus >= 201402L
+ {
+ // This is LWG #2059
+ typedef TemplateConstructor T;
+ typedef std::unordered_set<T, Hash> C;
+ typedef C::iterator I;
+
+ C m;
+ T a{0};
+ I it = m.find(a);
+ if (it != m.end())
+ m.erase(it);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multiset/erase_iter_db1.pass.cpp b/test/std/containers/unord/unord.multiset/erase_iter_db1.pass.cpp
new file mode 100644
index 000000000000..baad3858bd41
--- /dev/null
+++ b/test/std/containers/unord/unord.multiset/erase_iter_db1.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// Call erase(const_iterator position) with end()
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_set>
+#include <cassert>
+
+int main()
+{
+ {
+ int a1[] = {1, 2, 3};
+ std::unordered_multiset<int> l1(a1, a1+3);
+ std::unordered_multiset<int>::const_iterator i = l1.end();
+ l1.erase(i);
+ assert(false);
+ }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/containers/unord/unord.multiset/erase_iter_db2.pass.cpp b/test/std/containers/unord/unord.multiset/erase_iter_db2.pass.cpp
new file mode 100644
index 000000000000..a21f29ef7b4a
--- /dev/null
+++ b/test/std/containers/unord/unord.multiset/erase_iter_db2.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// Call erase(const_iterator position) with iterator from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_set>
+#include <cassert>
+#include <cstdlib>
+#include <exception>
+
+int main()
+{
+ {
+ int a1[] = {1, 2, 3};
+ std::unordered_multiset<int> l1(a1, a1+3);
+ std::unordered_multiset<int> l2(a1, a1+3);
+ std::unordered_multiset<int>::const_iterator i = l2.begin();
+ l1.erase(i);
+ assert(false);
+ }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/containers/unord/unord.multiset/erase_iter_iter_db1.pass.cpp b/test/std/containers/unord/unord.multiset/erase_iter_iter_db1.pass.cpp
new file mode 100644
index 000000000000..03c9ec5d048d
--- /dev/null
+++ b/test/std/containers/unord/unord.multiset/erase_iter_iter_db1.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// Call erase(const_iterator first, const_iterator last); with first iterator from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_set>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+int main()
+{
+ {
+ int a1[] = {1, 2, 3};
+ std::unordered_multiset<int> l1(a1, a1+3);
+ std::unordered_multiset<int> l2(a1, a1+3);
+ std::unordered_multiset<int>::iterator i = l1.erase(l2.cbegin(), next(l1.cbegin()));
+ assert(false);
+ }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/containers/unord/unord.multiset/erase_iter_iter_db2.pass.cpp b/test/std/containers/unord/unord.multiset/erase_iter_iter_db2.pass.cpp
new file mode 100644
index 000000000000..4c6f209f1a44
--- /dev/null
+++ b/test/std/containers/unord/unord.multiset/erase_iter_iter_db2.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// Call erase(const_iterator first, const_iterator last); with second iterator from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_set>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+int main()
+{
+ {
+ int a1[] = {1, 2, 3};
+ std::unordered_multiset<int> l1(a1, a1+3);
+ std::unordered_multiset<int> l2(a1, a1+3);
+ std::unordered_multiset<int>::iterator i = l1.erase(l1.cbegin(), next(l2.cbegin()));
+ assert(false);
+ }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/containers/unord/unord.multiset/erase_iter_iter_db3.pass.cpp b/test/std/containers/unord/unord.multiset/erase_iter_iter_db3.pass.cpp
new file mode 100644
index 000000000000..5ce378974c90
--- /dev/null
+++ b/test/std/containers/unord/unord.multiset/erase_iter_iter_db3.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// Call erase(const_iterator first, const_iterator last); with both iterators from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_set>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+int main()
+{
+ {
+ int a1[] = {1, 2, 3};
+ std::unordered_multiset<int> l1(a1, a1+3);
+ std::unordered_multiset<int> l2(a1, a1+3);
+ std::unordered_multiset<int>::iterator i = l1.erase(l2.cbegin(), next(l2.cbegin()));
+ assert(false);
+ }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/containers/unord/unord.multiset/erase_iter_iter_db4.pass.cpp b/test/std/containers/unord/unord.multiset/erase_iter_iter_db4.pass.cpp
new file mode 100644
index 000000000000..7c362a2a2b1b
--- /dev/null
+++ b/test/std/containers/unord/unord.multiset/erase_iter_iter_db4.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// Call erase(const_iterator first, const_iterator last); with a bad range
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_set>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+int main()
+{
+ {
+ int a1[] = {1, 2, 3};
+ std::unordered_multiset<int> l1(a1, a1+3);
+ std::unordered_multiset<int>::iterator i = l1.erase(next(l1.cbegin()), l1.cbegin());
+ assert(false);
+ }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/containers/unord/unord.multiset/erase_key.pass.cpp b/test/std/containers/unord/unord.multiset/erase_key.pass.cpp
new file mode 100644
index 000000000000..7c243973f163
--- /dev/null
+++ b/test/std/containers/unord/unord.multiset/erase_key.pass.cpp
@@ -0,0 +1,176 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// size_type erase(const key_type& k);
+
+#include <unordered_set>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+#if __cplusplus >= 201103L
+template <typename Unordered>
+bool only_deletions ( const Unordered &whole, const Unordered &part ) {
+ typename Unordered::const_iterator w = whole.begin();
+ typename Unordered::const_iterator p = part.begin();
+
+ while ( w != whole.end () && p != part.end()) {
+ if ( *w == *p )
+ p++;
+ w++;
+ }
+
+ return p == part.end();
+}
+#endif
+
+int main()
+{
+ {
+ typedef std::unordered_multiset<int> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.erase(5) == 0);
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+
+ assert(c.erase(2) == 2);
+ assert(c.size() == 4);
+ assert(c.count(1) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+
+ assert(c.erase(2) == 0);
+ assert(c.size() == 4);
+ assert(c.count(1) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+
+ assert(c.erase(4) == 1);
+ assert(c.size() == 3);
+ assert(c.count(1) == 2);
+ assert(c.count(3) == 1);
+
+ assert(c.erase(4) == 0);
+ assert(c.size() == 3);
+ assert(c.count(1) == 2);
+ assert(c.count(3) == 1);
+
+ assert(c.erase(1) == 2);
+ assert(c.size() == 1);
+ assert(c.count(3) == 1);
+
+ assert(c.erase(1) == 0);
+ assert(c.size() == 1);
+ assert(c.count(3) == 1);
+
+ assert(c.erase(3) == 1);
+ assert(c.size() == 0);
+
+ assert(c.erase(3) == 0);
+ assert(c.size() == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.erase(5) == 0);
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+
+ assert(c.erase(2) == 2);
+ assert(c.size() == 4);
+ assert(c.count(1) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+
+ assert(c.erase(2) == 0);
+ assert(c.size() == 4);
+ assert(c.count(1) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+
+ assert(c.erase(4) == 1);
+ assert(c.size() == 3);
+ assert(c.count(1) == 2);
+ assert(c.count(3) == 1);
+
+ assert(c.erase(4) == 0);
+ assert(c.size() == 3);
+ assert(c.count(1) == 2);
+ assert(c.count(3) == 1);
+
+ assert(c.erase(1) == 2);
+ assert(c.size() == 1);
+ assert(c.count(3) == 1);
+
+ assert(c.erase(1) == 0);
+ assert(c.size() == 1);
+ assert(c.count(3) == 1);
+
+ assert(c.erase(3) == 1);
+ assert(c.size() == 0);
+
+ assert(c.erase(3) == 0);
+ assert(c.size() == 0);
+ }
+ {
+ typedef std::unordered_multiset<int> C;
+ C m, m2;
+ for ( int i = 0; i < 10; ++i ) {
+ m.insert(i); m.insert(i);
+ m2.insert(i); m2.insert(i);
+ }
+
+ C::iterator i = m2.begin();
+ int ctr = 0;
+ while (i != m2.end()) {
+ if (ctr++ % 2 == 0)
+ m2.erase(i++);
+ else
+ ++i;
+ }
+
+ assert (only_deletions (m, m2));
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multiset/erase_range.pass.cpp b/test/std/containers/unord/unord.multiset/erase_range.pass.cpp
new file mode 100644
index 000000000000..baac08eddc1e
--- /dev/null
+++ b/test/std/containers/unord/unord.multiset/erase_range.pass.cpp
@@ -0,0 +1,94 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// iterator erase(const_iterator first, const_iterator last)
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multiset<int> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ C::const_iterator i = c.find(2);
+ C::const_iterator j = next(i, 2);
+ C::iterator k = c.erase(i, i);
+ assert(k == i);
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+
+ k = c.erase(i, j);
+ assert(c.size() == 4);
+ assert(c.count(1) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+
+ k = c.erase(c.cbegin(), c.cend());
+ assert(c.size() == 0);
+ assert(k == c.end());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ C::const_iterator i = c.find(2);
+ C::const_iterator j = next(i, 2);
+ C::iterator k = c.erase(i, i);
+ assert(k == i);
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+
+ k = c.erase(i, j);
+ assert(c.size() == 4);
+ assert(c.count(1) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+
+ k = c.erase(c.cbegin(), c.cend());
+ assert(c.size() == 0);
+ assert(k == c.end());
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multiset/find_const.pass.cpp b/test/std/containers/unord/unord.multiset/find_const.pass.cpp
new file mode 100644
index 000000000000..5caaf207aaf2
--- /dev/null
+++ b/test/std/containers/unord/unord.multiset/find_const.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// const_iterator find(const key_type& k) const;
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multiset<int> C;
+ typedef int P;
+ P a[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ const C c(std::begin(a), std::end(a));
+ C::const_iterator i = c.find(30);
+ assert(*i == 30);
+ i = c.find(5);
+ assert(i == c.cend());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ P a[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ const C c(std::begin(a), std::end(a));
+ C::const_iterator i = c.find(30);
+ assert(*i == 30);
+ i = c.find(5);
+ assert(i == c.cend());
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multiset/find_non_const.pass.cpp b/test/std/containers/unord/unord.multiset/find_non_const.pass.cpp
new file mode 100644
index 000000000000..030487863f98
--- /dev/null
+++ b/test/std/containers/unord/unord.multiset/find_non_const.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// iterator find(const key_type& k);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multiset<int> C;
+ typedef int P;
+ P a[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ C c(std::begin(a), std::end(a));
+ C::iterator i = c.find(30);
+ assert(*i == 30);
+ i = c.find(5);
+ assert(i == c.cend());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ P a[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ C c(std::begin(a), std::end(a));
+ C::iterator i = c.find(30);
+ assert(*i == 30);
+ i = c.find(5);
+ assert(i == c.cend());
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multiset/insert_const_lvalue.pass.cpp b/test/std/containers/unord/unord.multiset/insert_const_lvalue.pass.cpp
new file mode 100644
index 000000000000..0051e497fd7a
--- /dev/null
+++ b/test/std/containers/unord/unord.multiset/insert_const_lvalue.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// iterator insert(const value_type& x);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multiset<double> C;
+ typedef C::iterator R;
+ typedef C::value_type P;
+ C c;
+ R r = c.insert(P(3.5));
+ assert(c.size() == 1);
+ assert(*r == 3.5);
+
+ r = c.insert(P(3.5));
+ assert(c.size() == 2);
+ assert(*r == 3.5);
+
+ r = c.insert(P(4.5));
+ assert(c.size() == 3);
+ assert(*r == 4.5);
+
+ r = c.insert(P(5.5));
+ assert(c.size() == 4);
+ assert(*r == 5.5);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<double, std::hash<double>,
+ std::equal_to<double>, min_allocator<double>> C;
+ typedef C::iterator R;
+ typedef C::value_type P;
+ C c;
+ R r = c.insert(P(3.5));
+ assert(c.size() == 1);
+ assert(*r == 3.5);
+
+ r = c.insert(P(3.5));
+ assert(c.size() == 2);
+ assert(*r == 3.5);
+
+ r = c.insert(P(4.5));
+ assert(c.size() == 3);
+ assert(*r == 4.5);
+
+ r = c.insert(P(5.5));
+ assert(c.size() == 4);
+ assert(*r == 5.5);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multiset/insert_hint_const_lvalue.pass.cpp b/test/std/containers/unord/unord.multiset/insert_hint_const_lvalue.pass.cpp
new file mode 100644
index 000000000000..25b4bc1aa04a
--- /dev/null
+++ b/test/std/containers/unord/unord.multiset/insert_hint_const_lvalue.pass.cpp
@@ -0,0 +1,89 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// iterator insert(const_iterator p, const value_type& x);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multiset<double> C;
+ typedef C::iterator R;
+ typedef C::value_type P;
+ C c;
+ C::const_iterator e = c.end();
+ R r = c.insert(e, P(3.5));
+ assert(c.size() == 1);
+ assert(*r == 3.5);
+
+ r = c.insert(c.end(), P(3.5));
+ assert(c.size() == 2);
+ assert(*r == 3.5);
+
+ r = c.insert(c.end(), P(4.5));
+ assert(c.size() == 3);
+ assert(*r == 4.5);
+
+ r = c.insert(c.end(), P(5.5));
+ assert(c.size() == 4);
+ assert(*r == 5.5);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<double, std::hash<double>,
+ std::equal_to<double>, min_allocator<double>> C;
+ typedef C::iterator R;
+ typedef C::value_type P;
+ C c;
+ C::const_iterator e = c.end();
+ R r = c.insert(e, P(3.5));
+ assert(c.size() == 1);
+ assert(*r == 3.5);
+
+ r = c.insert(c.end(), P(3.5));
+ assert(c.size() == 2);
+ assert(*r == 3.5);
+
+ r = c.insert(c.end(), P(4.5));
+ assert(c.size() == 3);
+ assert(*r == 4.5);
+
+ r = c.insert(c.end(), P(5.5));
+ assert(c.size() == 4);
+ assert(*r == 5.5);
+ }
+#endif
+#if _LIBCPP_DEBUG >= 1
+ {
+ typedef std::unordered_multiset<double> C;
+ typedef C::iterator R;
+ typedef C::value_type P;
+ C c;
+ C c2;
+ C::const_iterator e = c2.end();
+ P v(3.5);
+ R r = c.insert(e, v);
+ assert(false);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multiset/insert_hint_rvalue.pass.cpp b/test/std/containers/unord/unord.multiset/insert_hint_rvalue.pass.cpp
new file mode 100644
index 000000000000..481ec80231c9
--- /dev/null
+++ b/test/std/containers/unord/unord.multiset/insert_hint_rvalue.pass.cpp
@@ -0,0 +1,138 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// iterator insert(const_iterator p, value_type&& x);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_set>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multiset<double> C;
+ typedef C::iterator R;
+ typedef double P;
+ C c;
+ C::const_iterator e = c.end();
+ R r = c.insert(e, P(3.5));
+ assert(c.size() == 1);
+ assert(*r == 3.5);
+
+ r = c.insert(r, P(3.5));
+ assert(c.size() == 2);
+ assert(*r == 3.5);
+
+ r = c.insert(c.end(), P(4.5));
+ assert(c.size() == 3);
+ assert(*r == 4.5);
+
+ r = c.insert(c.end(), P(5.5));
+ assert(c.size() == 4);
+ assert(*r == 5.5);
+ }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::unordered_multiset<MoveOnly> C;
+ typedef C::iterator R;
+ typedef MoveOnly P;
+ C c;
+ C::const_iterator e = c.end();
+ R r = c.insert(e, P(3));
+ assert(c.size() == 1);
+ assert(*r == 3);
+
+ r = c.insert(r, P(3));
+ assert(c.size() == 2);
+ assert(*r == 3);
+
+ r = c.insert(c.end(), P(4));
+ assert(c.size() == 3);
+ assert(*r == 4);
+
+ r = c.insert(c.end(), P(5));
+ assert(c.size() == 4);
+ assert(*r == 5);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<double, std::hash<double>,
+ std::equal_to<double>, min_allocator<double>> C;
+ typedef C::iterator R;
+ typedef double P;
+ C c;
+ C::const_iterator e = c.end();
+ R r = c.insert(e, P(3.5));
+ assert(c.size() == 1);
+ assert(*r == 3.5);
+
+ r = c.insert(r, P(3.5));
+ assert(c.size() == 2);
+ assert(*r == 3.5);
+
+ r = c.insert(c.end(), P(4.5));
+ assert(c.size() == 3);
+ assert(*r == 4.5);
+
+ r = c.insert(c.end(), P(5.5));
+ assert(c.size() == 4);
+ assert(*r == 5.5);
+ }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, min_allocator<MoveOnly>> C;
+ typedef C::iterator R;
+ typedef MoveOnly P;
+ C c;
+ C::const_iterator e = c.end();
+ R r = c.insert(e, P(3));
+ assert(c.size() == 1);
+ assert(*r == 3);
+
+ r = c.insert(r, P(3));
+ assert(c.size() == 2);
+ assert(*r == 3);
+
+ r = c.insert(c.end(), P(4));
+ assert(c.size() == 3);
+ assert(*r == 4);
+
+ r = c.insert(c.end(), P(5));
+ assert(c.size() == 4);
+ assert(*r == 5);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if _LIBCPP_DEBUG >= 1
+ {
+ typedef std::unordered_multiset<double> C;
+ typedef C::iterator R;
+ typedef C::value_type P;
+ C c;
+ C c2;
+ C::const_iterator e = c2.end();
+ R r = c.insert(e, P(3.5));
+ assert(false);
+ }
+#endif
+#endif
+}
diff --git a/test/std/containers/unord/unord.multiset/insert_init.pass.cpp b/test/std/containers/unord/unord.multiset/insert_init.pass.cpp
new file mode 100644
index 000000000000..6941d86f6197
--- /dev/null
+++ b/test/std/containers/unord/unord.multiset/insert_init.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// void insert(initializer_list<value_type> il);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::unordered_multiset<int> C;
+ typedef int P;
+ C c;
+ c.insert(
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ }
+ );
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ C c;
+ c.insert(
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ }
+ );
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/containers/unord/unord.multiset/insert_range.pass.cpp b/test/std/containers/unord/unord.multiset/insert_range.pass.cpp
new file mode 100644
index 000000000000..41c9d8136feb
--- /dev/null
+++ b/test/std/containers/unord/unord.multiset/insert_range.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// template <class InputIterator>
+// void insert(InputIterator first, InputIterator last);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multiset<int> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c;
+ c.insert(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])));
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c;
+ c.insert(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])));
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multiset/insert_rvalue.pass.cpp b/test/std/containers/unord/unord.multiset/insert_rvalue.pass.cpp
new file mode 100644
index 000000000000..2718324b4d08
--- /dev/null
+++ b/test/std/containers/unord/unord.multiset/insert_rvalue.pass.cpp
@@ -0,0 +1,118 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// iterator insert(value_type&& x);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multiset<double> C;
+ typedef C::iterator R;
+ typedef double P;
+ C c;
+ R r = c.insert(P(3.5));
+ assert(c.size() == 1);
+ assert(*r == 3.5);
+
+ r = c.insert(P(3.5));
+ assert(c.size() == 2);
+ assert(*r == 3.5);
+
+ r = c.insert(P(4.5));
+ assert(c.size() == 3);
+ assert(*r == 4.5);
+
+ r = c.insert(P(5.5));
+ assert(c.size() == 4);
+ assert(*r == 5.5);
+ }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::unordered_multiset<MoveOnly> C;
+ typedef C::iterator R;
+ typedef MoveOnly P;
+ C c;
+ R r = c.insert(P(3));
+ assert(c.size() == 1);
+ assert(*r == 3);
+
+ r = c.insert(P(3));
+ assert(c.size() == 2);
+ assert(*r == 3);
+
+ r = c.insert(P(4));
+ assert(c.size() == 3);
+ assert(*r == 4);
+
+ r = c.insert(P(5));
+ assert(c.size() == 4);
+ assert(*r == 5);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<double, std::hash<double>,
+ std::equal_to<double>, min_allocator<double>> C;
+ typedef C::iterator R;
+ typedef double P;
+ C c;
+ R r = c.insert(P(3.5));
+ assert(c.size() == 1);
+ assert(*r == 3.5);
+
+ r = c.insert(P(3.5));
+ assert(c.size() == 2);
+ assert(*r == 3.5);
+
+ r = c.insert(P(4.5));
+ assert(c.size() == 3);
+ assert(*r == 4.5);
+
+ r = c.insert(P(5.5));
+ assert(c.size() == 4);
+ assert(*r == 5.5);
+ }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, min_allocator<MoveOnly>> C;
+ typedef C::iterator R;
+ typedef MoveOnly P;
+ C c;
+ R r = c.insert(P(3));
+ assert(c.size() == 1);
+ assert(*r == 3);
+
+ r = c.insert(P(3));
+ assert(c.size() == 2);
+ assert(*r == 3);
+
+ r = c.insert(P(4));
+ assert(c.size() == 3);
+ assert(*r == 4);
+
+ r = c.insert(P(5));
+ assert(c.size() == 4);
+ assert(*r == 5);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif
+}
diff --git a/test/std/containers/unord/unord.multiset/iterators.fail.cpp b/test/std/containers/unord/unord.multiset/iterators.fail.cpp
new file mode 100644
index 000000000000..f78bccbd423f
--- /dev/null
+++ b/test/std/containers/unord/unord.multiset/iterators.fail.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// iterator begin() {return __table_.begin();}
+// iterator end() {return __table_.end();}
+// const_iterator begin() const {return __table_.begin();}
+// const_iterator end() const {return __table_.end();}
+// const_iterator cbegin() const {return __table_.begin();}
+// const_iterator cend() const {return __table_.end();}
+
+#include <unordered_set>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::unordered_multiset<int> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ C::iterator i = c.begin();
+ assert(*i == 1);
+ *i = 2;
+ }
+ {
+ typedef std::unordered_multiset<int> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ }
+}
diff --git a/test/std/containers/unord/unord.multiset/iterators.pass.cpp b/test/std/containers/unord/unord.multiset/iterators.pass.cpp
new file mode 100644
index 000000000000..be95b44517fe
--- /dev/null
+++ b/test/std/containers/unord/unord.multiset/iterators.pass.cpp
@@ -0,0 +1,127 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// iterator begin();
+// iterator end();
+// const_iterator begin() const;
+// const_iterator end() const;
+// const_iterator cbegin() const;
+// const_iterator cend() const;
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multiset<int> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 7);
+ assert(c.size() == 6);
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ C::iterator i;
+ }
+ {
+ typedef std::unordered_multiset<int> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 7);
+ assert(c.size() == 6);
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ C::const_iterator i;
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 7);
+ assert(c.size() == 6);
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ C::iterator i;
+ }
+ {
+ typedef std::unordered_multiset<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 7);
+ assert(c.size() == 6);
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ C::const_iterator i;
+ }
+#endif
+#if _LIBCPP_STD_VER > 11
+ { // N3644 testing
+ typedef std::unordered_multiset<int> C;
+ C::iterator ii1{}, ii2{};
+ C::iterator ii4 = ii1;
+ C::const_iterator cii{};
+ assert ( ii1 == ii2 );
+ assert ( ii1 == ii4 );
+
+ assert (!(ii1 != ii2 ));
+
+ assert ( (ii1 == cii ));
+ assert ( (cii == ii1 ));
+ assert (!(ii1 != cii ));
+ assert (!(cii != ii1 ));
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multiset/load_factor.pass.cpp b/test/std/containers/unord/unord.multiset/load_factor.pass.cpp
new file mode 100644
index 000000000000..07980c2afc85
--- /dev/null
+++ b/test/std/containers/unord/unord.multiset/load_factor.pass.cpp
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// float load_factor() const
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multiset<int> C;
+ typedef int P;
+ P a[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ const C c(std::begin(a), std::end(a));
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ }
+ {
+ typedef std::unordered_multiset<int> C;
+ typedef int P;
+ const C c;
+ assert(c.load_factor() == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ P a[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ const C c(std::begin(a), std::end(a));
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ }
+ {
+ typedef std::unordered_multiset<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ const C c;
+ assert(c.load_factor() == 0);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multiset/local_iterators.fail.cpp b/test/std/containers/unord/unord.multiset/local_iterators.fail.cpp
new file mode 100644
index 000000000000..4118987c2ae0
--- /dev/null
+++ b/test/std/containers/unord/unord.multiset/local_iterators.fail.cpp
@@ -0,0 +1,261 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// local_iterator begin (size_type n);
+// local_iterator end (size_type n);
+// const_local_iterator begin (size_type n) const;
+// const_local_iterator end (size_type n) const;
+// const_local_iterator cbegin(size_type n) const;
+// const_local_iterator cend (size_type n) const;
+
+#include <unordered_set>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::unordered_multiset<int> C;
+ typedef int P;
+ typedef C::local_iterator I;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() == 7);
+ C::size_type b = c.bucket(0);
+ I i = c.begin(b);
+ I j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 2);
+ assert(*i == 1);
+ ++i;
+ assert(*i == 1);
+ *i = 2;
+
+ b = c.bucket(2);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 2);
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+
+ b = c.bucket(3);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 3);
+
+ b = c.bucket(4);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 4);
+
+ b = c.bucket(5);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(6);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 0);
+ }
+ {
+ typedef std::unordered_multiset<int> C;
+ typedef int P;
+ typedef C::const_local_iterator I;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() == 7);
+ C::size_type b = c.bucket(0);
+ I i = c.begin(b);
+ I j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 2);
+ assert(*i == 1);
+ ++i;
+ assert(*i == 1);
+
+ b = c.bucket(2);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 2);
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+
+ b = c.bucket(3);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 3);
+
+ b = c.bucket(4);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 4);
+
+ b = c.bucket(5);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(6);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 0);
+ }
+ {
+ typedef std::unordered_multiset<int> C;
+ typedef int P;
+ typedef C::const_local_iterator I;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() == 7);
+ C::size_type b = c.bucket(0);
+ I i = c.cbegin(b);
+ I j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 2);
+ assert(*i == 1);
+ ++i;
+ assert(*i == 1);
+
+ b = c.bucket(2);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 2);
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+
+ b = c.bucket(3);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 3);
+
+ b = c.bucket(4);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 4);
+
+ b = c.bucket(5);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(6);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+ }
+ {
+ typedef std::unordered_multiset<int> C;
+ typedef int P;
+ typedef C::const_local_iterator I;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() == 7);
+ C::size_type b = c.bucket(0);
+ I i = c.cbegin(b);
+ I j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 2);
+ assert(*i == 1);
+ ++i;
+ assert(*i == 1);
+
+ b = c.bucket(2);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 2);
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+
+ b = c.bucket(3);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 3);
+
+ b = c.bucket(4);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 4);
+
+ b = c.bucket(5);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(6);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+ }
+}
diff --git a/test/std/containers/unord/unord.multiset/local_iterators.pass.cpp b/test/std/containers/unord/unord.multiset/local_iterators.pass.cpp
new file mode 100644
index 000000000000..3471707e42a1
--- /dev/null
+++ b/test/std/containers/unord/unord.multiset/local_iterators.pass.cpp
@@ -0,0 +1,500 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// local_iterator begin (size_type n);
+// local_iterator end (size_type n);
+// const_local_iterator begin (size_type n) const;
+// const_local_iterator end (size_type n) const;
+// const_local_iterator cbegin(size_type n) const;
+// const_local_iterator cend (size_type n) const;
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multiset<int> C;
+ typedef int P;
+ typedef C::local_iterator I;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 7);
+ C::size_type b = c.bucket(0);
+ I i = c.begin(b);
+ I j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 2);
+ assert(*i == 1);
+ ++i;
+ assert(*i == 1);
+
+ b = c.bucket(2);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 2);
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+
+ b = c.bucket(3);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 3);
+
+ b = c.bucket(4);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 4);
+
+ b = c.bucket(5);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(6);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 0);
+ }
+ {
+ typedef std::unordered_multiset<int> C;
+ typedef int P;
+ typedef C::const_local_iterator I;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 7);
+ C::size_type b = c.bucket(0);
+ I i = c.begin(b);
+ I j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 2);
+ assert(*i == 1);
+ ++i;
+ assert(*i == 1);
+
+ b = c.bucket(2);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 2);
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+
+ b = c.bucket(3);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 3);
+
+ b = c.bucket(4);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 4);
+
+ b = c.bucket(5);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(6);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 0);
+ }
+ {
+ typedef std::unordered_multiset<int> C;
+ typedef int P;
+ typedef C::const_local_iterator I;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 7);
+ C::size_type b = c.bucket(0);
+ I i = c.cbegin(b);
+ I j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 2);
+ assert(*i == 1);
+ ++i;
+ assert(*i == 1);
+
+ b = c.bucket(2);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 2);
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+
+ b = c.bucket(3);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 3);
+
+ b = c.bucket(4);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 4);
+
+ b = c.bucket(5);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(6);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+ }
+ {
+ typedef std::unordered_multiset<int> C;
+ typedef int P;
+ typedef C::const_local_iterator I;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 7);
+ C::size_type b = c.bucket(0);
+ I i = c.cbegin(b);
+ I j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 2);
+ assert(*i == 1);
+ ++i;
+ assert(*i == 1);
+
+ b = c.bucket(2);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 2);
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+
+ b = c.bucket(3);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 3);
+
+ b = c.bucket(4);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 4);
+
+ b = c.bucket(5);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(6);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ typedef C::local_iterator I;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 7);
+ C::size_type b = c.bucket(0);
+ I i = c.begin(b);
+ I j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 2);
+ assert(*i == 1);
+ ++i;
+ assert(*i == 1);
+
+ b = c.bucket(2);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 2);
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+
+ b = c.bucket(3);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 3);
+
+ b = c.bucket(4);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 4);
+
+ b = c.bucket(5);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(6);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 0);
+ }
+ {
+ typedef std::unordered_multiset<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ typedef C::const_local_iterator I;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 7);
+ C::size_type b = c.bucket(0);
+ I i = c.begin(b);
+ I j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 2);
+ assert(*i == 1);
+ ++i;
+ assert(*i == 1);
+
+ b = c.bucket(2);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 2);
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+
+ b = c.bucket(3);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 3);
+
+ b = c.bucket(4);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 4);
+
+ b = c.bucket(5);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(6);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 0);
+ }
+ {
+ typedef std::unordered_multiset<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ typedef C::const_local_iterator I;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 7);
+ C::size_type b = c.bucket(0);
+ I i = c.cbegin(b);
+ I j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 2);
+ assert(*i == 1);
+ ++i;
+ assert(*i == 1);
+
+ b = c.bucket(2);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 2);
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+
+ b = c.bucket(3);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 3);
+
+ b = c.bucket(4);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 4);
+
+ b = c.bucket(5);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(6);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+ }
+ {
+ typedef std::unordered_multiset<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ typedef C::const_local_iterator I;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 7);
+ C::size_type b = c.bucket(0);
+ I i = c.cbegin(b);
+ I j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 2);
+ assert(*i == 1);
+ ++i;
+ assert(*i == 1);
+
+ b = c.bucket(2);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 2);
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+
+ b = c.bucket(3);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 3);
+
+ b = c.bucket(4);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 4);
+
+ b = c.bucket(5);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(6);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multiset/max_bucket_count.pass.cpp b/test/std/containers/unord/unord.multiset/max_bucket_count.pass.cpp
new file mode 100644
index 000000000000..619a8cf1266f
--- /dev/null
+++ b/test/std/containers/unord/unord.multiset/max_bucket_count.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// size_type max_bucket_count() const;
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multiset<int> C;
+ const C c;
+ assert(c.max_bucket_count() > 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ const C c;
+ assert(c.max_bucket_count() > 0);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multiset/max_load_factor.pass.cpp b/test/std/containers/unord/unord.multiset/max_load_factor.pass.cpp
new file mode 100644
index 000000000000..08f52bb70840
--- /dev/null
+++ b/test/std/containers/unord/unord.multiset/max_load_factor.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// float max_load_factor() const;
+// void max_load_factor(float mlf);
+
+#ifdef _LIBCPP_DEBUG
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multiset<int> C;
+ typedef int P;
+ const C c;
+ assert(c.max_load_factor() == 1);
+ }
+ {
+ typedef std::unordered_multiset<int> C;
+ typedef int P;
+ C c;
+ assert(c.max_load_factor() == 1);
+ c.max_load_factor(2.5);
+ assert(c.max_load_factor() == 2.5);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ const C c;
+ assert(c.max_load_factor() == 1);
+ }
+ {
+ typedef std::unordered_multiset<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ C c;
+ assert(c.max_load_factor() == 1);
+ c.max_load_factor(2.5);
+ assert(c.max_load_factor() == 2.5);
+ }
+#endif
+#if _LIBCPP_DEBUG_LEVEL >= 1
+ {
+ typedef std::unordered_multiset<int> C;
+ C c;
+ c.max_load_factor(0);
+ assert(false);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multiset/max_size.pass.cpp b/test/std/containers/unord/unord.multiset/max_size.pass.cpp
new file mode 100644
index 000000000000..a5d0b5538bce
--- /dev/null
+++ b/test/std/containers/unord/unord.multiset/max_size.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// size_type max_size() const;
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::unordered_multiset<int> u;
+ assert(u.max_size() > 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::unordered_multiset<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> u;
+ assert(u.max_size() > 0);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multiset/rehash.pass.cpp b/test/std/containers/unord/unord.multiset/rehash.pass.cpp
new file mode 100644
index 000000000000..bc8d461c60bf
--- /dev/null
+++ b/test/std/containers/unord/unord.multiset/rehash.pass.cpp
@@ -0,0 +1,90 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// void rehash(size_type n);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class C>
+void test(const C& c)
+{
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+}
+
+int main()
+{
+ {
+ typedef std::unordered_multiset<int> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ test(c);
+ assert(c.bucket_count() >= 7);
+ c.rehash(3);
+ assert(c.bucket_count() == 7);
+ test(c);
+ c.max_load_factor(2);
+ c.rehash(3);
+ assert(c.bucket_count() == 3);
+ test(c);
+ c.rehash(31);
+ assert(c.bucket_count() == 31);
+ test(c);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ test(c);
+ assert(c.bucket_count() >= 7);
+ c.rehash(3);
+ assert(c.bucket_count() == 7);
+ test(c);
+ c.max_load_factor(2);
+ c.rehash(3);
+ assert(c.bucket_count() == 3);
+ test(c);
+ c.rehash(31);
+ assert(c.bucket_count() == 31);
+ test(c);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multiset/reserve.pass.cpp b/test/std/containers/unord/unord.multiset/reserve.pass.cpp
new file mode 100644
index 000000000000..0c17583d371d
--- /dev/null
+++ b/test/std/containers/unord/unord.multiset/reserve.pass.cpp
@@ -0,0 +1,90 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// void reserve(size_type n);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class C>
+void test(const C& c)
+{
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+}
+
+int main()
+{
+ {
+ typedef std::unordered_multiset<int> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ test(c);
+ assert(c.bucket_count() >= 7);
+ c.reserve(3);
+ assert(c.bucket_count() == 7);
+ test(c);
+ c.max_load_factor(2);
+ c.reserve(3);
+ assert(c.bucket_count() == 3);
+ test(c);
+ c.reserve(31);
+ assert(c.bucket_count() >= 16);
+ test(c);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ test(c);
+ assert(c.bucket_count() >= 7);
+ c.reserve(3);
+ assert(c.bucket_count() == 7);
+ test(c);
+ c.max_load_factor(2);
+ c.reserve(3);
+ assert(c.bucket_count() == 3);
+ test(c);
+ c.reserve(31);
+ assert(c.bucket_count() >= 16);
+ test(c);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multiset/scary.pass.cpp b/test/std/containers/unord/unord.multiset/scary.pass.cpp
new file mode 100644
index 000000000000..dfd144bb3170
--- /dev/null
+++ b/test/std/containers/unord/unord.multiset/scary.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// class unordered_set class unordered_multiset
+
+// Extension: SCARY/N2913 iterator compatibility between unordered_set and unordered_multiset
+
+#include <unordered_set>
+
+int main()
+{
+ typedef std::unordered_set<int> M1;
+ typedef std::unordered_multiset<int> M2;
+ M2::iterator i;
+ M1::iterator j = i;
+}
diff --git a/test/std/containers/unord/unord.multiset/swap_member.pass.cpp b/test/std/containers/unord/unord.multiset/swap_member.pass.cpp
new file mode 100644
index 000000000000..275ff4094e81
--- /dev/null
+++ b/test/std/containers/unord/unord.multiset/swap_member.pass.cpp
@@ -0,0 +1,571 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// void swap(unordered_multiset& __u);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../test_compare.h"
+#include "../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef test_allocator<int> Alloc;
+ typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ C c1(0, Hash(1), Compare(1), Alloc(1));
+ C c2(0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(1));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(2));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef test_allocator<int> Alloc;
+ typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ P a2[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ C c1(0, Hash(1), Compare(1), Alloc(1));
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(*c1.find(10) == 10);
+ assert(*c1.find(20) == 20);
+ assert(*c1.find(30) == 30);
+ assert(*c1.find(40) == 40);
+ assert(*c1.find(50) == 50);
+ assert(*c1.find(60) == 60);
+ assert(*c1.find(70) == 70);
+ assert(*c1.find(80) == 80);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(1));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(2));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef test_allocator<int> Alloc;
+ typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ P a1[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+ C c2(0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(1));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 7);
+ assert(c2.size() == 6);
+ assert(c2.count(1) == 2);
+ assert(c2.count(2) == 2);
+ assert(c2.count(3) == 1);
+ assert(c2.count(4) == 1);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(2));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef test_allocator<int> Alloc;
+ typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ P a1[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ P a2[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(*c1.find(10) == 10);
+ assert(*c1.find(20) == 20);
+ assert(*c1.find(30) == 30);
+ assert(*c1.find(40) == 40);
+ assert(*c1.find(50) == 50);
+ assert(*c1.find(60) == 60);
+ assert(*c1.find(70) == 70);
+ assert(*c1.find(80) == 80);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(1));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 7);
+ assert(c2.size() == 6);
+ assert(c2.count(1) == 2);
+ assert(c2.count(2) == 2);
+ assert(c2.count(3) == 1);
+ assert(c2.count(4) == 1);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(2));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef other_allocator<int> Alloc;
+ typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ C c1(0, Hash(1), Compare(1), Alloc(1));
+ C c2(0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(2));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(1));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef other_allocator<int> Alloc;
+ typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ P a2[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ C c1(0, Hash(1), Compare(1), Alloc(1));
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(*c1.find(10) == 10);
+ assert(*c1.find(20) == 20);
+ assert(*c1.find(30) == 30);
+ assert(*c1.find(40) == 40);
+ assert(*c1.find(50) == 50);
+ assert(*c1.find(60) == 60);
+ assert(*c1.find(70) == 70);
+ assert(*c1.find(80) == 80);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(2));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(1));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef other_allocator<int> Alloc;
+ typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ P a1[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+ C c2(0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(2));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 7);
+ assert(c2.size() == 6);
+ assert(c2.count(1) == 2);
+ assert(c2.count(2) == 2);
+ assert(c2.count(3) == 1);
+ assert(c2.count(4) == 1);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(1));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef other_allocator<int> Alloc;
+ typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ P a1[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ P a2[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(*c1.find(10) == 10);
+ assert(*c1.find(20) == 20);
+ assert(*c1.find(30) == 30);
+ assert(*c1.find(40) == 40);
+ assert(*c1.find(50) == 50);
+ assert(*c1.find(60) == 60);
+ assert(*c1.find(70) == 70);
+ assert(*c1.find(80) == 80);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(2));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 7);
+ assert(c2.size() == 6);
+ assert(c2.count(1) == 2);
+ assert(c2.count(2) == 2);
+ assert(c2.count(3) == 1);
+ assert(c2.count(4) == 1);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(1));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef min_allocator<int> Alloc;
+ typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ C c1(0, Hash(1), Compare(1), Alloc());
+ C c2(0, Hash(2), Compare(2), Alloc());
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc());
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc());
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef min_allocator<int> Alloc;
+ typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ P a2[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ C c1(0, Hash(1), Compare(1), Alloc());
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc());
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(*c1.find(10) == 10);
+ assert(*c1.find(20) == 20);
+ assert(*c1.find(30) == 30);
+ assert(*c1.find(40) == 40);
+ assert(*c1.find(50) == 50);
+ assert(*c1.find(60) == 60);
+ assert(*c1.find(70) == 70);
+ assert(*c1.find(80) == 80);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc());
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc());
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef min_allocator<int> Alloc;
+ typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ P a1[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc());
+ C c2(0, Hash(2), Compare(2), Alloc());
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc());
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 7);
+ assert(c2.size() == 6);
+ assert(c2.count(1) == 2);
+ assert(c2.count(2) == 2);
+ assert(c2.count(3) == 1);
+ assert(c2.count(4) == 1);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc());
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef min_allocator<int> Alloc;
+ typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ P a1[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ P a2[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc());
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc());
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(*c1.find(10) == 10);
+ assert(*c1.find(20) == 20);
+ assert(*c1.find(30) == 30);
+ assert(*c1.find(40) == 40);
+ assert(*c1.find(50) == 50);
+ assert(*c1.find(60) == 60);
+ assert(*c1.find(70) == 70);
+ assert(*c1.find(80) == 80);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc());
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 7);
+ assert(c2.size() == 6);
+ assert(c2.count(1) == 2);
+ assert(c2.count(2) == 2);
+ assert(c2.count(3) == 1);
+ assert(c2.count(4) == 1);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc());
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multiset/types.pass.cpp b/test/std/containers/unord/unord.multiset/types.pass.cpp
new file mode 100644
index 000000000000..5222222d8197
--- /dev/null
+++ b/test/std/containers/unord/unord.multiset/types.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+// {
+// public:
+// // types
+// typedef Value value_type;
+// typedef value_type key_type;
+// typedef Hash hasher;
+// typedef Pred key_equal;
+// typedef Alloc allocator_type;
+// typedef value_type& reference;
+// typedef const value_type& const_reference;
+// typedef typename allocator_traits<allocator_type>::pointer pointer;
+// typedef typename allocator_traits<allocator_type>::const_pointer const_pointer;
+// typedef typename allocator_traits<allocator_type>::size_type size_type;
+// typedef typename allocator_traits<allocator_type>::difference_type difference_type;
+
+#include <unordered_set>
+#include <type_traits>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multiset<short> C;
+ static_assert((std::is_same<C::value_type, short>::value), "");
+ static_assert((std::is_same<C::key_type, short>::value), "");
+ static_assert((std::is_same<C::hasher, std::hash<C::key_type> >::value), "");
+ static_assert((std::is_same<C::key_equal, std::equal_to<C::key_type> >::value), "");
+ static_assert((std::is_same<C::allocator_type, std::allocator<C::value_type> >::value), "");
+ static_assert((std::is_same<C::reference, C::value_type&>::value), "");
+ static_assert((std::is_same<C::const_reference, const C::value_type&>::value), "");
+ static_assert((std::is_same<C::pointer, C::value_type*>::value), "");
+ static_assert((std::is_same<C::const_pointer, const C::value_type*>::value), "");
+ static_assert((std::is_same<C::size_type, std::size_t>::value), "");
+ static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<short, std::hash<short>,
+ std::equal_to<short>, min_allocator<short>> C;
+ static_assert((std::is_same<C::value_type, short>::value), "");
+ static_assert((std::is_same<C::key_type, short>::value), "");
+ static_assert((std::is_same<C::hasher, std::hash<C::key_type> >::value), "");
+ static_assert((std::is_same<C::key_equal, std::equal_to<C::key_type> >::value), "");
+ static_assert((std::is_same<C::allocator_type, min_allocator<C::value_type> >::value), "");
+ static_assert((std::is_same<C::reference, C::value_type&>::value), "");
+ static_assert((std::is_same<C::const_reference, const C::value_type&>::value), "");
+ static_assert((std::is_same<C::pointer, min_pointer<C::value_type>>::value), "");
+ static_assert((std::is_same<C::const_pointer, min_pointer<const C::value_type>>::value), "");
+ // min_allocator doesn't have a size_type, so one gets synthesized
+ static_assert((std::is_same<C::size_type, std::make_unsigned<C::difference_type>::type>::value), "");
+ static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/allocator.pass.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/allocator.pass.cpp
new file mode 100644
index 000000000000..ccd21a58b22c
--- /dev/null
+++ b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/allocator.pass.cpp
@@ -0,0 +1,109 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// explicit unordered_multiset(const allocator_type& __a);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multiset<NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ test_allocator<NotConstructible>
+ > C;
+ C c(test_allocator<NotConstructible>(10));
+ assert(c.bucket_count() == 0);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() == test_allocator<NotConstructible>(10));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ min_allocator<NotConstructible>
+ > C;
+ C c(min_allocator<NotConstructible>{});
+ assert(c.bucket_count() == 0);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() == min_allocator<NotConstructible>());
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef NotConstructible T;
+ typedef test_hash<std::hash<T>> HF;
+ typedef test_compare<std::equal_to<T>> Comp;
+ typedef test_allocator<T> A;
+ typedef std::unordered_multiset<T, HF, Comp, A> C;
+
+ A a(43);
+ C c(3, a);
+ assert(c.bucket_count() == 3);
+ assert(c.hash_function() == HF());
+ assert(c.key_eq() == Comp ());
+ assert(c.get_allocator() == a);
+ assert(!(c.get_allocator() == A()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+ {
+ typedef NotConstructible T;
+ typedef test_hash<std::hash<T>> HF;
+ typedef test_compare<std::equal_to<T>> Comp;
+ typedef test_allocator<T> A;
+ typedef std::unordered_multiset<T, HF, Comp, A> C;
+
+ HF hf(42);
+ A a(43);
+ C c(4, hf, a);
+ assert(c.bucket_count() == 4);
+ assert(c.hash_function() == hf);
+ assert(!(c.hash_function() == HF()));
+ assert(c.key_eq() == Comp ());
+ assert(c.get_allocator() == a);
+ assert(!(c.get_allocator() == A()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+#endif
+}
diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/assign_copy.pass.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/assign_copy.pass.cpp
new file mode 100644
index 000000000000..2042f69fd772
--- /dev/null
+++ b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/assign_copy.pass.cpp
@@ -0,0 +1,209 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// unordered_multiset& operator=(const unordered_multiset& u);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef test_allocator<int> A;
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A(10)
+ );
+ C c(a, a + 2,
+ 7,
+ test_hash<std::hash<int> >(2),
+ test_compare<std::equal_to<int> >(3),
+ A(4)
+ );
+ c = c0;
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ C::const_iterator i = c.cbegin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 3);
+ ++i;
+ assert(*i == 4);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == A(4));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+ {
+ typedef std::unordered_multiset<int> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ C *p = &c;
+ c = *p;
+
+ assert(c.size() == 6);
+ assert(std::is_permutation(c.begin(), c.end(), a));
+ }
+ {
+ typedef other_allocator<int> A;
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A(10)
+ );
+ C c(a, a + 2,
+ 7,
+ test_hash<std::hash<int> >(2),
+ test_compare<std::equal_to<int> >(3),
+ A(4)
+ );
+ c = c0;
+ assert(c.bucket_count() >= 7);
+ assert(c.size() == 6);
+ C::const_iterator i = c.cbegin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 3);
+ ++i;
+ assert(*i == 4);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == A(10));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef min_allocator<int> A;
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A()
+ );
+ C c(a, a + 2,
+ 7,
+ test_hash<std::hash<int> >(2),
+ test_compare<std::equal_to<int> >(3),
+ A()
+ );
+ c = c0;
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ C::const_iterator i = c.cbegin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 3);
+ ++i;
+ assert(*i == 4);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == A());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/assign_init.pass.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/assign_init.pass.cpp
new file mode 100644
index 000000000000..4eaf2c5779f3
--- /dev/null
+++ b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/assign_init.pass.cpp
@@ -0,0 +1,97 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// unordered_multiset& operator=(initializer_list<value_type> il);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef test_allocator<int> A;
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef int P;
+ C c = {
+ P(4),
+ P(1),
+ P(2)
+ };
+ c = {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ assert(c.bucket_count() >= 7);
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef min_allocator<int> A;
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef int P;
+ C c = {
+ P(4),
+ P(1),
+ P(2)
+ };
+ c = {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ assert(c.bucket_count() >= 7);
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/assign_move.pass.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/assign_move.pass.cpp
new file mode 100644
index 000000000000..4b0e52c5930c
--- /dev/null
+++ b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/assign_move.pass.cpp
@@ -0,0 +1,286 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// unordered_multiset& operator=(unordered_multiset&& u);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef test_allocator<int> A;
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A(10)
+ );
+ C c(a, a + 2,
+ 7,
+ test_hash<std::hash<int> >(2),
+ test_compare<std::equal_to<int> >(3),
+ A(4)
+ );
+ c = std::move(c0);
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ C::const_iterator i = c.cbegin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 3);
+ ++i;
+ assert(*i == 4);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == A(4));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+ {
+ typedef test_allocator<int> A;
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A(10)
+ );
+ C c(a, a + 2,
+ 7,
+ test_hash<std::hash<int> >(2),
+ test_compare<std::equal_to<int> >(3),
+ A(10)
+ );
+ c = std::move(c0);
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == A(10));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+ {
+ typedef other_allocator<int> A;
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A(10)
+ );
+ C c(a, a + 2,
+ 7,
+ test_hash<std::hash<int> >(2),
+ test_compare<std::equal_to<int> >(3),
+ A(4)
+ );
+ c = std::move(c0);
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == A(10));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef test_allocator<int> A;
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A()
+ );
+ C c(a, a + 2,
+ 7,
+ test_hash<std::hash<int> >(2),
+ test_compare<std::equal_to<int> >(3),
+ A()
+ );
+ c = std::move(c0);
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ C::const_iterator i = c.cbegin();
+ assert(*i == 4);
+ ++i;
+ assert(*i == 3);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 1);
+ ++i;
+ assert(*i == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == A());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+ {
+ typedef min_allocator<int> A;
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A()
+ );
+ C c(a, a + 2,
+ 7,
+ test_hash<std::hash<int> >(2),
+ test_compare<std::equal_to<int> >(3),
+ A()
+ );
+ c = std::move(c0);
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == A());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::unordered_multiset<int> s1 = {1, 2, 3};
+ std::unordered_multiset<int>::iterator i = s1.begin();
+ int k = *i;
+ std::unordered_multiset<int> s2;
+ s2 = std::move(s1);
+ assert(*i == k);
+ s2.erase(i);
+ assert(s2.size() == 2);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/copy.pass.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/copy.pass.cpp
new file mode 100644
index 000000000000..94241830a06c
--- /dev/null
+++ b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/copy.pass.cpp
@@ -0,0 +1,171 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// unordered_multiset(const unordered_multiset& u);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<int>
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ test_allocator<int>(10)
+ );
+ C c = c0;
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ C::const_iterator i = c.cbegin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 3);
+ ++i;
+ assert(*i == 4);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == test_allocator<int>(10));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+ {
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ other_allocator<int>
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ other_allocator<int>(10)
+ );
+ C c = c0;
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ C::const_iterator i = c.cbegin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 3);
+ ++i;
+ assert(*i == 4);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == other_allocator<int>(-2));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<int>
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ min_allocator<int>()
+ );
+ C c = c0;
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ C::const_iterator i = c.cbegin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 3);
+ ++i;
+ assert(*i == 4);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == min_allocator<int>());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/copy_alloc.pass.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/copy_alloc.pass.cpp
new file mode 100644
index 000000000000..22e372bb3ad1
--- /dev/null
+++ b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/copy_alloc.pass.cpp
@@ -0,0 +1,123 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// unordered_multiset(const unordered_multiset& u, const allocator_type& a);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<int>
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ test_allocator<int>(10)
+ );
+ C c(c0, test_allocator<int>(5));
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ C::const_iterator i = c.cbegin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 3);
+ ++i;
+ assert(*i == 4);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == test_allocator<int>(5));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<int>
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ min_allocator<int>()
+ );
+ C c(c0, min_allocator<int>());
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ C::const_iterator i = c.cbegin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 3);
+ ++i;
+ assert(*i == 4);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == min_allocator<int>());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/default.pass.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/default.pass.cpp
new file mode 100644
index 000000000000..737ae2dae793
--- /dev/null
+++ b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/default.pass.cpp
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// unordered_multiset();
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multiset<NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ test_allocator<NotConstructible>
+ > C;
+ C c;
+ assert(c.bucket_count() == 0);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() == (test_allocator<NotConstructible>()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ min_allocator<NotConstructible>
+ > C;
+ C c;
+ assert(c.bucket_count() == 0);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() == (min_allocator<NotConstructible>()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+ {
+ std::unordered_multiset<int> c = {};
+ assert(c.bucket_count() == 0);
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/default_noexcept.pass.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/default_noexcept.pass.cpp
new file mode 100644
index 000000000000..391609fd144a
--- /dev/null
+++ b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/default_noexcept.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// unordered_multiset()
+// noexcept(
+// is_nothrow_default_constructible<allocator_type>::value &&
+// is_nothrow_default_constructible<key_compare>::value &&
+// is_nothrow_copy_constructible<key_compare>::value);
+
+// This tests a conforming extension
+
+#include <unordered_set>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "test_allocator.h"
+#include "../../../test_hash.h"
+
+template <class T>
+struct some_comp
+{
+ typedef T value_type;
+ some_comp();
+ some_comp(const some_comp&);
+};
+
+template <class T>
+struct some_hash
+{
+ typedef T value_type;
+ some_hash();
+ some_hash(const some_hash&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::unordered_multiset<MoveOnly> C;
+ static_assert(std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, test_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, other_allocator<MoveOnly>> C;
+ static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_multiset<MoveOnly, some_hash<MoveOnly>> C;
+ static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>,
+ some_comp<MoveOnly>> C;
+ static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/dtor_noexcept.pass.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/dtor_noexcept.pass.cpp
new file mode 100644
index 000000000000..a549288afc14
--- /dev/null
+++ b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/dtor_noexcept.pass.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// ~unordered_multiset() // implied noexcept;
+
+#include <unordered_set>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "test_allocator.h"
+
+#if __has_feature(cxx_noexcept)
+
+template <class T>
+struct some_comp
+{
+ typedef T value_type;
+ ~some_comp() noexcept(false);
+};
+
+template <class T>
+struct some_hash
+{
+ typedef T value_type;
+ some_hash();
+ some_hash(const some_hash&);
+ ~some_hash() noexcept(false);
+};
+
+#endif
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::unordered_multiset<MoveOnly> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, test_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, other_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_multiset<MoveOnly, some_hash<MoveOnly>> C;
+ static_assert(!std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>,
+ some_comp<MoveOnly>> C;
+ static_assert(!std::is_nothrow_destructible<C>::value, "");
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init.pass.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init.pass.cpp
new file mode 100644
index 000000000000..416c28cf83db
--- /dev/null
+++ b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init.pass.cpp
@@ -0,0 +1,163 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// unordered_multiset(initializer_list<value_type> il);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<int>
+ > C;
+ typedef int P;
+ C c = {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ assert(c.bucket_count() >= 7);
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >());
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() == test_allocator<int>());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<int>
+ > C;
+ typedef int P;
+ C c = {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ assert(c.bucket_count() >= 7);
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >());
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() == min_allocator<int>());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef int T;
+ typedef test_hash<std::hash<T>> HF;
+ typedef test_compare<std::equal_to<T>> Comp;
+ typedef test_allocator<T> A;
+ typedef std::unordered_multiset<T, HF, Comp, A> C;
+
+ A a(42);
+ C c({
+ T(1),
+ T(2),
+ T(3),
+ T(4),
+ T(1),
+ T(2)
+ }, 12, a);
+
+ assert(c.bucket_count() >= 12);
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == HF());
+ assert(c.key_eq() == Comp());
+ assert(c.get_allocator() == a);
+ assert(!(c.get_allocator() == A()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+ {
+ typedef int T;
+ typedef test_hash<std::hash<T>> HF;
+ typedef test_compare<std::equal_to<T>> Comp;
+ typedef test_allocator<T> A;
+ typedef std::unordered_multiset<T, HF, Comp, A> C;
+
+ A a(42);
+ HF hf(43);
+ C c({
+ T(1),
+ T(2),
+ T(3),
+ T(4),
+ T(1),
+ T(2)
+ }, 12, hf, a);
+
+ assert(c.bucket_count() >= 12);
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == hf);
+ assert(!(c.hash_function() == HF()));
+ assert(c.key_eq() == Comp());
+ assert(c.get_allocator() == a);
+ assert(!(c.get_allocator() == A()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init_size.pass.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init_size.pass.cpp
new file mode 100644
index 000000000000..a6543a0e6f46
--- /dev/null
+++ b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init_size.pass.cpp
@@ -0,0 +1,97 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// unordered_multiset(initializer_list<value_type> il, size_type n);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<int>
+ > C;
+ typedef int P;
+ C c({
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ },
+ 7
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >());
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() == test_allocator<int>());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<int>
+ > C;
+ typedef int P;
+ C c({
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ },
+ 7
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >());
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() == min_allocator<int>());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash.pass.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash.pass.cpp
new file mode 100644
index 000000000000..7d0f37163a1f
--- /dev/null
+++ b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash.pass.cpp
@@ -0,0 +1,100 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// unordered_multiset(initializer_list<value_type> il, size_type n,
+// const hasher& hf);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<int>
+ > C;
+ typedef int P;
+ C c({
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ },
+ 7,
+ test_hash<std::hash<int> >(8)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() == test_allocator<int>());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<int>
+ > C;
+ typedef int P;
+ C c({
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ },
+ 7,
+ test_hash<std::hash<int> >(8)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() == min_allocator<int>());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash_equal.pass.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash_equal.pass.cpp
new file mode 100644
index 000000000000..cd013f9554ae
--- /dev/null
+++ b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash_equal.pass.cpp
@@ -0,0 +1,102 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// unordered_multiset(initializer_list<value_type> il, size_type n,
+// const hasher& hf, const key_equal& eql);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<int>
+ > C;
+ typedef int P;
+ C c({
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ },
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == test_allocator<int>());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<int>
+ > C;
+ typedef int P;
+ C c({
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ },
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == min_allocator<int>());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash_equal_allocator.pass.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash_equal_allocator.pass.cpp
new file mode 100644
index 000000000000..4621c7fbb3ff
--- /dev/null
+++ b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash_equal_allocator.pass.cpp
@@ -0,0 +1,104 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// unordered_multiset(initializer_list<value_type> il, size_type n,
+// const hasher& hf, const key_equal& eql, const allocator_type& a);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<int>
+ > C;
+ typedef int P;
+ C c({
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ },
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ test_allocator<int>(10)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == test_allocator<int>(10));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<int>
+ > C;
+ typedef int P;
+ C c({
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ },
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ min_allocator<int>()
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == min_allocator<int>());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move.pass.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move.pass.cpp
new file mode 100644
index 000000000000..a68cfe8cd3bb
--- /dev/null
+++ b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move.pass.cpp
@@ -0,0 +1,194 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// unordered_multiset(unordered_multiset&& u);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<int>
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c0(7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ test_allocator<int>(10)
+ );
+ C c = std::move(c0);
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 0);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == test_allocator<int>(10));
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+
+ assert(c0.empty());
+ }
+ {
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<int>
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ test_allocator<int>(10)
+ );
+ C c = std::move(c0);
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == test_allocator<int>(10));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+
+ assert(c0.empty());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<int>
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c0(7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ min_allocator<int>()
+ );
+ C c = std::move(c0);
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 0);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == min_allocator<int>());
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+
+ assert(c0.empty());
+ }
+ {
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<int>
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ min_allocator<int>()
+ );
+ C c = std::move(c0);
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == min_allocator<int>());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+
+ assert(c0.empty());
+ }
+#endif
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::unordered_multiset<int> s1 = {1, 2, 3};
+ std::unordered_multiset<int>::iterator i = s1.begin();
+ int k = *i;
+ std::unordered_multiset<int> s2 = std::move(s1);
+ assert(*i == k);
+ s2.erase(i);
+ assert(s2.size() == 2);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move_alloc.pass.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move_alloc.pass.cpp
new file mode 100644
index 000000000000..9eee69a58e5d
--- /dev/null
+++ b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move_alloc.pass.cpp
@@ -0,0 +1,213 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// unordered_multiset(unordered_multiset&& u, const allocator_type& a);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef int P;
+ typedef test_allocator<int> A;
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A(10)
+ );
+ C c(std::move(c0), A(12));
+ assert(c.bucket_count() >= 7);
+ assert(c.size() == 6);
+ C::const_iterator i = c.cbegin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 3);
+ ++i;
+ assert(*i == 4);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == A(12));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+
+ assert(c0.empty());
+ }
+ {
+ typedef int P;
+ typedef test_allocator<int> A;
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A(10)
+ );
+ C c(std::move(c0), A(10));
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == A(10));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+
+ assert(c0.empty());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int P;
+ typedef min_allocator<int> A;
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A()
+ );
+ C c(std::move(c0), A());
+ assert(c.bucket_count() >= 7);
+ assert(c.size() == 6);
+ C::const_iterator i = c.cbegin();
+ assert(*i == 4);
+ ++i;
+ assert(*i == 3);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 1);
+ ++i;
+ assert(*i == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == A());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+
+ assert(c0.empty());
+ }
+ {
+ typedef int P;
+ typedef min_allocator<int> A;
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A()
+ );
+ C c(std::move(c0), A());
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == A());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+
+ assert(c0.empty());
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move_assign_noexcept.pass.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move_assign_noexcept.pass.cpp
new file mode 100644
index 000000000000..2f86f018d9fe
--- /dev/null
+++ b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move_assign_noexcept.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// unordered_multiset& operator=(unordered_multiset&& c)
+// noexcept(
+// allocator_type::propagate_on_container_move_assignment::value &&
+// is_nothrow_move_assignable<allocator_type>::value &&
+// is_nothrow_move_assignable<key_compare>::value);
+
+// This tests a conforming extension
+
+#include <unordered_set>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_comp
+{
+ typedef T value_type;
+ some_comp& operator=(const some_comp&);
+};
+
+template <class T>
+struct some_hash
+{
+ typedef T value_type;
+ some_hash();
+ some_hash(const some_hash&);
+ some_hash& operator=(const some_hash&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::unordered_multiset<MoveOnly> C;
+ static_assert(std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, test_allocator<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, other_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::unordered_multiset<MoveOnly, some_hash<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>,
+ some_comp<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move_noexcept.pass.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move_noexcept.pass.cpp
new file mode 100644
index 000000000000..8a4c3c945364
--- /dev/null
+++ b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move_noexcept.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// unordered_multiset(unordered_multiset&&)
+// noexcept(is_nothrow_move_constructible<allocator_type>::value &&
+// is_nothrow_move_constructible<key_compare>::value);
+
+// This tests a conforming extension
+
+#include <unordered_set>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_comp
+{
+ typedef T value_type;
+ some_comp(const some_comp&);
+};
+
+template <class T>
+struct some_hash
+{
+ typedef T value_type;
+ some_hash();
+ some_hash(const some_hash&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::unordered_multiset<MoveOnly> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, test_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, other_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_multiset<MoveOnly, some_hash<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>,
+ some_comp<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_constructible<C>::value, "");
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range.pass.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range.pass.cpp
new file mode 100644
index 000000000000..cd2bb1e7bbcd
--- /dev/null
+++ b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range.pass.cpp
@@ -0,0 +1,167 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// template <class InputIterator>
+// unordered_multiset(InputIterator first, InputIterator last);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "test_iterators.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<int>
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])));
+ assert(c.bucket_count() >= 7);
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >());
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() == test_allocator<int>());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<int>
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])));
+ assert(c.bucket_count() >= 7);
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >());
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() == min_allocator<int>());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef int T;
+ typedef test_hash<std::hash<T>> HF;
+ typedef test_compare<std::equal_to<T>> Comp;
+ typedef test_allocator<T> A;
+ typedef std::unordered_multiset<T, HF, Comp, A> C;
+ T arr[] =
+ {
+ T(1),
+ T(2),
+ T(3),
+ T(4),
+ T(1),
+ T(2)
+ };
+ A a(42);
+ C c(input_iterator<T*>(arr), input_iterator<T*>(arr + sizeof(arr)/sizeof(arr[0])), 12, a);
+ assert(c.bucket_count() >= 12);
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == HF());
+ assert(c.key_eq() == Comp());
+ assert(c.get_allocator() == a);
+ assert(!(c.get_allocator() == A()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+ {
+ typedef int T;
+ typedef test_hash<std::hash<T>> HF;
+ typedef test_compare<std::equal_to<T>> Comp;
+ typedef test_allocator<T> A;
+ typedef std::unordered_multiset<T, HF, Comp, A> C;
+ T arr[] =
+ {
+ T(1),
+ T(2),
+ T(3),
+ T(4),
+ T(1),
+ T(2)
+ };
+ HF hf(43);
+ A a(42);
+ C c(input_iterator<T*>(arr), input_iterator<T*>(arr + sizeof(arr)/sizeof(arr[0])), 16, hf, a);
+ assert(c.bucket_count() >= 16);
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == hf);
+ assert(!(c.hash_function() == HF()));
+ assert(c.key_eq() == Comp());
+ assert(c.get_allocator() == a);
+ assert(!(c.get_allocator() == A()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+#endif
+}
diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range_size.pass.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range_size.pass.cpp
new file mode 100644
index 000000000000..4f5e03e28f4e
--- /dev/null
+++ b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range_size.pass.cpp
@@ -0,0 +1,101 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// template <class InputIterator>
+// unordered_multiset(InputIterator first, InputIterator last, size_type n);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "test_iterators.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<int>
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+ 7
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >());
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() == test_allocator<int>());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<int>
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+ 7
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >());
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() == min_allocator<int>());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash.pass.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash.pass.cpp
new file mode 100644
index 000000000000..6b83bde9bc5e
--- /dev/null
+++ b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash.pass.cpp
@@ -0,0 +1,104 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// template <class InputIterator>
+// unordered_multiset(InputIterator first, InputIterator last, size_type n,
+// const hasher& hf);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "test_iterators.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<int>
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+ 7,
+ test_hash<std::hash<int> >(8)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() == test_allocator<int>());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<int>
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+ 7,
+ test_hash<std::hash<int> >(8)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() == min_allocator<int>());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash_equal.pass.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash_equal.pass.cpp
new file mode 100644
index 000000000000..89e7c7fa2e3d
--- /dev/null
+++ b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash_equal.pass.cpp
@@ -0,0 +1,106 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// template <class InputIterator>
+// unordered_multiset(InputIterator first, InputIterator last, size_type n,
+// const hasher& hf, const key_equal& eql);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "test_iterators.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<int>
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == test_allocator<int>());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<int>
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == min_allocator<int>());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash_equal_allocator.pass.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash_equal_allocator.pass.cpp
new file mode 100644
index 000000000000..b712a96f05bc
--- /dev/null
+++ b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash_equal_allocator.pass.cpp
@@ -0,0 +1,109 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// template <class InputIterator>
+// unordered_multiset(InputIterator first, InputIterator last, size_type n,
+// const hasher& hf, const key_equal& eql,
+// const allocator_type& a);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "test_iterators.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<int>
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ test_allocator<int>(10)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == test_allocator<int>(10));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<int>
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ min_allocator<int>()
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == min_allocator<int>());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/size.fail.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/size.fail.cpp
new file mode 100644
index 000000000000..e55db7ca2aaf
--- /dev/null
+++ b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/size.fail.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// explicit unordered_multiset(size_type n);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multiset<NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ test_allocator<NotConstructible>
+ > C;
+ C c = 7;
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() == (test_allocator<NotConstructible>()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ min_allocator<NotConstructible>
+ > C;
+ C c = 7;
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() == (min_allocator<NotConstructible>()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/size.pass.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/size.pass.cpp
new file mode 100644
index 000000000000..35bfbe331b41
--- /dev/null
+++ b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/size.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// explicit unordered_multiset(size_type n);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multiset<NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ test_allocator<NotConstructible>
+ > C;
+ C c(7);
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() == (test_allocator<NotConstructible>()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ min_allocator<NotConstructible>
+ > C;
+ C c(7);
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() == (min_allocator<NotConstructible>()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/size_hash.pass.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/size_hash.pass.cpp
new file mode 100644
index 000000000000..0171ea64ebb1
--- /dev/null
+++ b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/size_hash.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// unordered_multiset(size_type n, const hasher& hf);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multiset<NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ test_allocator<NotConstructible>
+ > C;
+ C c(7,
+ test_hash<std::hash<NotConstructible> >(8)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() == (test_allocator<NotConstructible>()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ min_allocator<NotConstructible>
+ > C;
+ C c(7,
+ test_hash<std::hash<NotConstructible> >(8)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() == (min_allocator<NotConstructible>()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/size_hash_equal.pass.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/size_hash_equal.pass.cpp
new file mode 100644
index 000000000000..785cdf246368
--- /dev/null
+++ b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/size_hash_equal.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// unordered_multiset(size_type n, const hasher& hf, const key_equal& eql);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multiset<NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ test_allocator<NotConstructible>
+ > C;
+ C c(7,
+ test_hash<std::hash<NotConstructible> >(8),
+ test_compare<std::equal_to<NotConstructible> >(9)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >(9));
+ assert(c.get_allocator() == (test_allocator<NotConstructible>()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ min_allocator<NotConstructible>
+ > C;
+ C c(7,
+ test_hash<std::hash<NotConstructible> >(8),
+ test_compare<std::equal_to<NotConstructible> >(9)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >(9));
+ assert(c.get_allocator() == (min_allocator<NotConstructible>()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/size_hash_equal_allocator.pass.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/size_hash_equal_allocator.pass.cpp
new file mode 100644
index 000000000000..50dd3c95ee52
--- /dev/null
+++ b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/size_hash_equal_allocator.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// unordered_multiset(size_type n, const hasher& hf, const key_equal& eql, const allocator_type& a);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multiset<NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ test_allocator<NotConstructible>
+ > C;
+ C c(7,
+ test_hash<std::hash<NotConstructible> >(8),
+ test_compare<std::equal_to<NotConstructible> >(9),
+ test_allocator<std::pair<const NotConstructible, NotConstructible> >(10)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >(9));
+ assert(c.get_allocator() == (test_allocator<NotConstructible>(10)));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ min_allocator<NotConstructible>
+ > C;
+ C c(7,
+ test_hash<std::hash<NotConstructible> >(8),
+ test_compare<std::equal_to<NotConstructible> >(9),
+ min_allocator<std::pair<const NotConstructible, NotConstructible> >()
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >(9));
+ assert(c.get_allocator() == (min_allocator<NotConstructible>()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.swap/db_swap_1.pass.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.swap/db_swap_1.pass.cpp
new file mode 100644
index 000000000000..9470b1a6fa88
--- /dev/null
+++ b/test/std/containers/unord/unord.multiset/unord.multiset.swap/db_swap_1.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// void swap(unordered_multiset& x, unordered_multiset& y);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_set>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_DEBUG >= 1
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ std::unordered_multiset<int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ std::unordered_multiset<int> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+ std::unordered_multiset<int>::iterator i1 = c1.begin();
+ std::unordered_multiset<int>::iterator i2 = c2.begin();
+ swap(c1, c2);
+ c1.erase(i2);
+ c2.erase(i1);
+ std::unordered_multiset<int>::iterator j = i1;
+ c1.erase(i1);
+ assert(false);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.swap/swap_noexcept.pass.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.swap/swap_noexcept.pass.cpp
new file mode 100644
index 000000000000..63642fcd7cca
--- /dev/null
+++ b/test/std/containers/unord/unord.multiset/unord.multiset.swap/swap_noexcept.pass.cpp
@@ -0,0 +1,198 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// void swap(unordered_multiset& c)
+// noexcept(
+// (!allocator_type::propagate_on_container_swap::value ||
+// __is_nothrow_swappable<allocator_type>::value) &&
+// __is_nothrow_swappable<hasher>::value &&
+// __is_nothrow_swappable<key_equal>::value);
+//
+// In C++17, the standard says that swap shall have:
+// noexcept(allocator_traits<Allocator>::is_always_equal::value &&
+// noexcept(swap(declval<Hash&>(), declval<Hash&>())) &&
+// noexcept(swap(declval<Pred&>(), declval<Pred&>())));
+
+// This tests a conforming extension
+
+#include <unordered_set>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_comp
+{
+ typedef T value_type;
+
+ some_comp() {}
+ some_comp(const some_comp&) {}
+};
+
+template <class T>
+struct some_comp2
+{
+ typedef T value_type;
+
+ some_comp2() {}
+ some_comp2(const some_comp2&) {}
+ void deallocate(void*, unsigned) {}
+ typedef std::true_type propagate_on_container_swap;
+};
+
+#if TEST_STD_VER >= 14
+template <typename T>
+void swap(some_comp2<T>&, some_comp2<T>&) noexcept {}
+#endif
+
+template <class T>
+struct some_hash
+{
+ typedef T value_type;
+ some_hash() {}
+ some_hash(const some_hash&);
+};
+
+template <class T>
+struct some_hash2
+{
+ typedef T value_type;
+ some_hash2() {}
+ some_hash2(const some_hash2&);
+};
+
+#if TEST_STD_VER >= 14
+template <typename T>
+void swap(some_hash2<T>&, some_hash2<T>&) noexcept {}
+#endif
+
+template <class T>
+struct some_alloc
+{
+ typedef T value_type;
+
+ some_alloc() {}
+ some_alloc(const some_alloc&);
+ void deallocate(void*, unsigned) {}
+
+ typedef std::true_type propagate_on_container_swap;
+};
+
+template <class T>
+struct some_alloc2
+{
+ typedef T value_type;
+
+ some_alloc2() {}
+ some_alloc2(const some_alloc2&);
+ void deallocate(void*, unsigned) {}
+
+ typedef std::false_type propagate_on_container_swap;
+ typedef std::true_type is_always_equal;
+};
+
+template <class T>
+struct some_alloc3
+{
+ typedef T value_type;
+
+ some_alloc3() {}
+ some_alloc3(const some_alloc3&);
+ void deallocate(void*, unsigned) {}
+
+ typedef std::false_type propagate_on_container_swap;
+ typedef std::false_type is_always_equal;
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::unordered_multiset<MoveOnly> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, test_allocator<MoveOnly>> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, other_allocator<MoveOnly>> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::unordered_multiset<MoveOnly, some_hash<MoveOnly>> C;
+ C c1, c2;
+ static_assert(!noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>,
+ some_comp<MoveOnly>> C;
+ C c1, c2;
+ static_assert(!noexcept(swap(c1, c2)), "");
+ }
+
+#if TEST_STD_VER >= 14
+ { // POCS allocator, throwable swap for hash, throwable swap for comp
+ typedef std::unordered_multiset<MoveOnly, some_hash<MoveOnly>, some_comp <MoveOnly>, some_alloc <MoveOnly>> C;
+ C c1, c2;
+ static_assert(!noexcept(swap(c1, c2)), "");
+ }
+ { // always equal allocator, throwable swap for hash, throwable swap for comp
+ typedef std::unordered_multiset<MoveOnly, some_hash<MoveOnly>, some_comp <MoveOnly>, some_alloc2<MoveOnly>> C;
+ C c1, c2;
+ static_assert(!noexcept(swap(c1, c2)), "");
+ }
+ { // POCS allocator, throwable swap for hash, nothrow swap for comp
+ typedef std::unordered_multiset<MoveOnly, some_hash<MoveOnly>, some_comp2<MoveOnly>, some_alloc <MoveOnly>> C;
+ C c1, c2;
+ static_assert(!noexcept(swap(c1, c2)), "");
+ }
+ { // always equal allocator, throwable swap for hash, nothrow swap for comp
+ typedef std::unordered_multiset<MoveOnly, some_hash<MoveOnly>, some_comp2<MoveOnly>, some_alloc2<MoveOnly>> C;
+ C c1, c2;
+ static_assert(!noexcept(swap(c1, c2)), "");
+ }
+ { // POCS allocator, nothrow swap for hash, throwable swap for comp
+ typedef std::unordered_multiset<MoveOnly, some_hash2<MoveOnly>, some_comp <MoveOnly>, some_alloc <MoveOnly>> C;
+ C c1, c2;
+ static_assert(!noexcept(swap(c1, c2)), "");
+ }
+ { // always equal allocator, nothrow swap for hash, throwable swap for comp
+ typedef std::unordered_multiset<MoveOnly, some_hash2<MoveOnly>, some_comp <MoveOnly>, some_alloc2<MoveOnly>> C;
+ C c1, c2;
+ static_assert(!noexcept(swap(c1, c2)), "");
+ }
+ { // POCS allocator, nothrow swap for hash, nothrow swap for comp
+ typedef std::unordered_multiset<MoveOnly, some_hash2<MoveOnly>, some_comp2<MoveOnly>, some_alloc <MoveOnly>> C;
+ C c1, c2;
+ static_assert( noexcept(swap(c1, c2)), "");
+ }
+ { // always equal allocator, nothrow swap for hash, nothrow swap for comp
+ typedef std::unordered_multiset<MoveOnly, some_hash2<MoveOnly>, some_comp2<MoveOnly>, some_alloc2<MoveOnly>> C;
+ C c1, c2;
+ static_assert( noexcept(swap(c1, c2)), "");
+ }
+
+ { // NOT always equal allocator, nothrow swap for hash, nothrow swap for comp
+ typedef std::unordered_multiset<MoveOnly, some_hash2<MoveOnly>, some_comp2<MoveOnly>, some_alloc3<MoveOnly>> C;
+ C c1, c2;
+ static_assert( noexcept(swap(c1, c2)), "");
+ }
+#endif
+
+#endif
+}
diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.swap/swap_non_member.pass.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.swap/swap_non_member.pass.cpp
new file mode 100644
index 000000000000..624b81c5eb3e
--- /dev/null
+++ b/test/std/containers/unord/unord.multiset/unord.multiset.swap/swap_non_member.pass.cpp
@@ -0,0 +1,571 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// void swap(unordered_multiset& x, unordered_multiset& y);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef test_allocator<int> Alloc;
+ typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ C c1(0, Hash(1), Compare(1), Alloc(1));
+ C c2(0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(1));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(2));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef test_allocator<int> Alloc;
+ typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ P a2[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ C c1(0, Hash(1), Compare(1), Alloc(1));
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(*c1.find(10) == 10);
+ assert(*c1.find(20) == 20);
+ assert(*c1.find(30) == 30);
+ assert(*c1.find(40) == 40);
+ assert(*c1.find(50) == 50);
+ assert(*c1.find(60) == 60);
+ assert(*c1.find(70) == 70);
+ assert(*c1.find(80) == 80);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(1));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(2));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef test_allocator<int> Alloc;
+ typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ P a1[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+ C c2(0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(1));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 7);
+ assert(c2.size() == 6);
+ assert(c2.count(1) == 2);
+ assert(c2.count(2) == 2);
+ assert(c2.count(3) == 1);
+ assert(c2.count(4) == 1);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(2));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef test_allocator<int> Alloc;
+ typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ P a1[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ P a2[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(*c1.find(10) == 10);
+ assert(*c1.find(20) == 20);
+ assert(*c1.find(30) == 30);
+ assert(*c1.find(40) == 40);
+ assert(*c1.find(50) == 50);
+ assert(*c1.find(60) == 60);
+ assert(*c1.find(70) == 70);
+ assert(*c1.find(80) == 80);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(1));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 7);
+ assert(c2.size() == 6);
+ assert(c2.count(1) == 2);
+ assert(c2.count(2) == 2);
+ assert(c2.count(3) == 1);
+ assert(c2.count(4) == 1);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(2));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef other_allocator<int> Alloc;
+ typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ C c1(0, Hash(1), Compare(1), Alloc(1));
+ C c2(0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(2));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(1));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef other_allocator<int> Alloc;
+ typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ P a2[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ C c1(0, Hash(1), Compare(1), Alloc(1));
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(*c1.find(10) == 10);
+ assert(*c1.find(20) == 20);
+ assert(*c1.find(30) == 30);
+ assert(*c1.find(40) == 40);
+ assert(*c1.find(50) == 50);
+ assert(*c1.find(60) == 60);
+ assert(*c1.find(70) == 70);
+ assert(*c1.find(80) == 80);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(2));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(1));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef other_allocator<int> Alloc;
+ typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ P a1[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+ C c2(0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(2));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 7);
+ assert(c2.size() == 6);
+ assert(c2.count(1) == 2);
+ assert(c2.count(2) == 2);
+ assert(c2.count(3) == 1);
+ assert(c2.count(4) == 1);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(1));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef other_allocator<int> Alloc;
+ typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ P a1[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ P a2[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(*c1.find(10) == 10);
+ assert(*c1.find(20) == 20);
+ assert(*c1.find(30) == 30);
+ assert(*c1.find(40) == 40);
+ assert(*c1.find(50) == 50);
+ assert(*c1.find(60) == 60);
+ assert(*c1.find(70) == 70);
+ assert(*c1.find(80) == 80);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(2));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 7);
+ assert(c2.size() == 6);
+ assert(c2.count(1) == 2);
+ assert(c2.count(2) == 2);
+ assert(c2.count(3) == 1);
+ assert(c2.count(4) == 1);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(1));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef min_allocator<int> Alloc;
+ typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ C c1(0, Hash(1), Compare(1), Alloc());
+ C c2(0, Hash(2), Compare(2), Alloc());
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc());
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc());
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef min_allocator<int> Alloc;
+ typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ P a2[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ C c1(0, Hash(1), Compare(1), Alloc());
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc());
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(*c1.find(10) == 10);
+ assert(*c1.find(20) == 20);
+ assert(*c1.find(30) == 30);
+ assert(*c1.find(40) == 40);
+ assert(*c1.find(50) == 50);
+ assert(*c1.find(60) == 60);
+ assert(*c1.find(70) == 70);
+ assert(*c1.find(80) == 80);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc());
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc());
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef min_allocator<int> Alloc;
+ typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ P a1[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc());
+ C c2(0, Hash(2), Compare(2), Alloc());
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc());
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 7);
+ assert(c2.size() == 6);
+ assert(c2.count(1) == 2);
+ assert(c2.count(2) == 2);
+ assert(c2.count(3) == 1);
+ assert(c2.count(4) == 1);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc());
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef min_allocator<int> Alloc;
+ typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ P a1[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ P a2[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc());
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc());
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(*c1.find(10) == 10);
+ assert(*c1.find(20) == 20);
+ assert(*c1.find(30) == 30);
+ assert(*c1.find(40) == 40);
+ assert(*c1.find(50) == 50);
+ assert(*c1.find(60) == 60);
+ assert(*c1.find(70) == 70);
+ assert(*c1.find(80) == 80);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc());
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 7);
+ assert(c2.size() == 6);
+ assert(c2.count(1) == 2);
+ assert(c2.count(2) == 2);
+ assert(c2.count(3) == 1);
+ assert(c2.count(4) == 1);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc());
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.set/bucket.pass.cpp b/test/std/containers/unord/unord.set/bucket.pass.cpp
new file mode 100644
index 000000000000..0dae664e0b23
--- /dev/null
+++ b/test/std/containers/unord/unord.set/bucket.pass.cpp
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// size_type bucket(const key_type& __k) const;
+
+#ifdef _LIBCPP_DEBUG
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_set<int> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ const C c(std::begin(a), std::end(a));
+ size_t bc = c.bucket_count();
+ assert(bc >= 5);
+ for (size_t i = 0; i < 13; ++i)
+ assert(c.bucket(i) == i % bc);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ const C c(std::begin(a), std::end(a));
+ size_t bc = c.bucket_count();
+ assert(bc >= 5);
+ for (size_t i = 0; i < 13; ++i)
+ assert(c.bucket(i) == i % bc);
+ }
+#endif
+#if _LIBCPP_DEBUG_LEVEL >= 1
+ {
+ typedef std::unordered_set<int> C;
+ C c;
+ C::size_type i = c.bucket(3);
+ assert(false);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.set/bucket_count.pass.cpp b/test/std/containers/unord/unord.set/bucket_count.pass.cpp
new file mode 100644
index 000000000000..caaa5a6011a9
--- /dev/null
+++ b/test/std/containers/unord/unord.set/bucket_count.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// size_type bucket_count() const;
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_set<int> C;
+ typedef C::const_iterator I;
+ typedef int P;
+ const C c;
+ assert(c.bucket_count() == 0);
+ }
+ {
+ typedef std::unordered_set<int> C;
+ typedef C::const_iterator I;
+ typedef int P;
+ P a[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ const C c(std::begin(a), std::end(a));
+ assert(c.bucket_count() >= 11);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C;
+ typedef C::const_iterator I;
+ typedef int P;
+ const C c;
+ assert(c.bucket_count() == 0);
+ }
+ {
+ typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C;
+ typedef C::const_iterator I;
+ typedef int P;
+ P a[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ const C c(std::begin(a), std::end(a));
+ assert(c.bucket_count() >= 11);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.set/bucket_size.pass.cpp b/test/std/containers/unord/unord.set/bucket_size.pass.cpp
new file mode 100644
index 000000000000..628d55737a82
--- /dev/null
+++ b/test/std/containers/unord/unord.set/bucket_size.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// size_type bucket_size(size_type n) const
+
+#ifdef _LIBCPP_DEBUG
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_set<int> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ const C c(std::begin(a), std::end(a));
+ assert(c.bucket_count() >= 5);
+ assert(c.bucket_size(0) == 0);
+ assert(c.bucket_size(1) == 1);
+ assert(c.bucket_size(2) == 1);
+ assert(c.bucket_size(3) == 1);
+ assert(c.bucket_size(4) == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ const C c(std::begin(a), std::end(a));
+ assert(c.bucket_count() >= 5);
+ assert(c.bucket_size(0) == 0);
+ assert(c.bucket_size(1) == 1);
+ assert(c.bucket_size(2) == 1);
+ assert(c.bucket_size(3) == 1);
+ assert(c.bucket_size(4) == 1);
+ }
+#endif
+#if _LIBCPP_DEBUG_LEVEL >= 1
+ {
+ typedef std::unordered_set<int> C;
+ C c;
+ C::size_type i = c.bucket_size(3);
+ assert(false);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.set/clear.pass.cpp b/test/std/containers/unord/unord.set/clear.pass.cpp
new file mode 100644
index 000000000000..6da15308508c
--- /dev/null
+++ b/test/std/containers/unord/unord.set/clear.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// void clear()
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_set<int> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ c.clear();
+ assert(c.size() == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ c.clear();
+ assert(c.size() == 0);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.set/count.pass.cpp b/test/std/containers/unord/unord.set/count.pass.cpp
new file mode 100644
index 000000000000..83bb8aaa2be0
--- /dev/null
+++ b/test/std/containers/unord/unord.set/count.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// size_type count(const key_type& k) const;
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_set<int> C;
+ typedef int P;
+ P a[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(50),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ const C c(std::begin(a), std::end(a));
+ assert(c.count(30) == 1);
+ assert(c.count(50) == 1);
+ assert(c.count(5) == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ P a[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(50),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ const C c(std::begin(a), std::end(a));
+ assert(c.count(30) == 1);
+ assert(c.count(50) == 1);
+ assert(c.count(5) == 0);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.set/db_iterators_7.pass.cpp b/test/std/containers/unord/unord.set/db_iterators_7.pass.cpp
new file mode 100644
index 000000000000..80b1a49c5758
--- /dev/null
+++ b/test/std/containers/unord/unord.set/db_iterators_7.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// Increment iterator past end.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_set>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::unordered_set<T> C;
+ C c(1);
+ C::iterator i = c.begin();
+ ++i;
+ assert(i == c.end());
+ ++i;
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::unordered_set<T, min_allocator<T>> C;
+ C c(1);
+ C::iterator i = c.begin();
+ ++i;
+ assert(i == c.end());
+ ++i;
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/containers/unord/unord.set/db_iterators_8.pass.cpp b/test/std/containers/unord/unord.set/db_iterators_8.pass.cpp
new file mode 100644
index 000000000000..8b266bbf664f
--- /dev/null
+++ b/test/std/containers/unord/unord.set/db_iterators_8.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// Dereference non-dereferenceable iterator.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_set>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::unordered_set<T> C;
+ C c(1);
+ C::iterator i = c.end();
+ T j = *i;
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::unordered_set<T, min_allocator<T>> C;
+ C c(1);
+ C::iterator i = c.end();
+ T j = *i;
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/containers/unord/unord.set/db_local_iterators_7.pass.cpp b/test/std/containers/unord/unord.set/db_local_iterators_7.pass.cpp
new file mode 100644
index 000000000000..b9fcb8c4ae0c
--- /dev/null
+++ b/test/std/containers/unord/unord.set/db_local_iterators_7.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// Increment local_iterator past end.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_set>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::unordered_set<T> C;
+ C c(1);
+ C::local_iterator i = c.begin(0);
+ ++i;
+ ++i;
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::unordered_set<T, min_allocator<T>> C;
+ C c(1);
+ C::local_iterator i = c.begin(0);
+ ++i;
+ ++i;
+ assert(false);
+ }
+#endif
+
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/containers/unord/unord.set/db_local_iterators_8.pass.cpp b/test/std/containers/unord/unord.set/db_local_iterators_8.pass.cpp
new file mode 100644
index 000000000000..74d131b19abe
--- /dev/null
+++ b/test/std/containers/unord/unord.set/db_local_iterators_8.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// Dereference non-dereferenceable iterator.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_set>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::unordered_set<T> C;
+ C c(1);
+ C::local_iterator i = c.end(0);
+ T j = *i;
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::unordered_set<T, min_allocator<T>> C;
+ C c(1);
+ C::local_iterator i = c.end(0);
+ T j = *i;
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/containers/unord/unord.set/emplace.pass.cpp b/test/std/containers/unord/unord.set/emplace.pass.cpp
new file mode 100644
index 000000000000..d105e7ac0f4e
--- /dev/null
+++ b/test/std/containers/unord/unord.set/emplace.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// template <class... Args>
+// pair<iterator, bool> emplace(Args&&... args);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../Emplaceable.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::unordered_set<Emplaceable> C;
+ typedef std::pair<C::iterator, bool> R;
+ C c;
+ R r = c.emplace();
+ assert(c.size() == 1);
+ assert(*r.first == Emplaceable());
+ assert(r.second);
+
+ r = c.emplace(Emplaceable(5, 6));
+ assert(c.size() == 2);
+ assert(*r.first == Emplaceable(5, 6));
+ assert(r.second);
+
+ r = c.emplace(5, 6);
+ assert(c.size() == 2);
+ assert(*r.first == Emplaceable(5, 6));
+ assert(!r.second);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<Emplaceable, std::hash<Emplaceable>,
+ std::equal_to<Emplaceable>, min_allocator<Emplaceable>> C;
+ typedef std::pair<C::iterator, bool> R;
+ C c;
+ R r = c.emplace();
+ assert(c.size() == 1);
+ assert(*r.first == Emplaceable());
+ assert(r.second);
+
+ r = c.emplace(Emplaceable(5, 6));
+ assert(c.size() == 2);
+ assert(*r.first == Emplaceable(5, 6));
+ assert(r.second);
+
+ r = c.emplace(5, 6);
+ assert(c.size() == 2);
+ assert(*r.first == Emplaceable(5, 6));
+ assert(!r.second);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/unord/unord.set/emplace_hint.pass.cpp b/test/std/containers/unord/unord.set/emplace_hint.pass.cpp
new file mode 100644
index 000000000000..50b0035165d2
--- /dev/null
+++ b/test/std/containers/unord/unord.set/emplace_hint.pass.cpp
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// template <class... Args>
+// iterator emplace_hint(const_iterator p, Args&&... args);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../Emplaceable.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::unordered_set<Emplaceable> C;
+ typedef C::iterator R;
+ C c;
+ C::const_iterator e = c.end();
+ R r = c.emplace_hint(e);
+ assert(c.size() == 1);
+ assert(*r == Emplaceable());
+
+ r = c.emplace_hint(e, Emplaceable(5, 6));
+ assert(c.size() == 2);
+ assert(*r == Emplaceable(5, 6));
+
+ r = c.emplace_hint(r, 5, 6);
+ assert(c.size() == 2);
+ assert(*r == Emplaceable(5, 6));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<Emplaceable, std::hash<Emplaceable>,
+ std::equal_to<Emplaceable>, min_allocator<Emplaceable>> C;
+ typedef C::iterator R;
+ C c;
+ C::const_iterator e = c.end();
+ R r = c.emplace_hint(e);
+ assert(c.size() == 1);
+ assert(*r == Emplaceable());
+
+ r = c.emplace_hint(e, Emplaceable(5, 6));
+ assert(c.size() == 2);
+ assert(*r == Emplaceable(5, 6));
+
+ r = c.emplace_hint(r, 5, 6);
+ assert(c.size() == 2);
+ assert(*r == Emplaceable(5, 6));
+ }
+#endif
+#if _LIBCPP_DEBUG >= 1
+ {
+ typedef std::unordered_set<Emplaceable> C;
+ typedef C::iterator R;
+ C c1;
+ C c2;
+ R r = c1.emplace_hint(c2.begin(), 5, 6);
+ assert(false);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/unord/unord.set/eq.pass.cpp b/test/std/containers/unord/unord.set/eq.pass.cpp
new file mode 100644
index 000000000000..54a9c2eced34
--- /dev/null
+++ b/test/std/containers/unord/unord.set/eq.pass.cpp
@@ -0,0 +1,159 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Key, class Hash, class Pred, class Alloc>
+// bool
+// operator==(const unordered_set<Key, Hash, Pred, Alloc>& x,
+// const unordered_set<Key, Hash, Pred, Alloc>& y);
+//
+// template <class Key, class Hash, class Pred, class Alloc>
+// bool
+// operator!=(const unordered_set<Key, Hash, Pred, Alloc>& x,
+// const unordered_set<Key, Hash, Pred, Alloc>& y);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_set<int> C;
+ typedef int P;
+ P a[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ const C c1(std::begin(a), std::end(a));
+ const C c2;
+ assert(!(c1 == c2));
+ assert( (c1 != c2));
+ }
+ {
+ typedef std::unordered_set<int> C;
+ typedef int P;
+ P a[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ const C c1(std::begin(a), std::end(a));
+ const C c2 = c1;
+ assert( (c1 == c2));
+ assert(!(c1 != c2));
+ }
+ {
+ typedef std::unordered_set<int> C;
+ typedef int P;
+ P a[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ C c1(std::begin(a), std::end(a));
+ C c2 = c1;
+ c2.rehash(30);
+ assert( (c1 == c2));
+ assert(!(c1 != c2));
+ c2.insert(P(90));
+ assert(!(c1 == c2));
+ assert( (c1 != c2));
+ c1.insert(P(90));
+ assert( (c1 == c2));
+ assert(!(c1 != c2));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ P a[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ const C c1(std::begin(a), std::end(a));
+ const C c2;
+ assert(!(c1 == c2));
+ assert( (c1 != c2));
+ }
+ {
+ typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ P a[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ const C c1(std::begin(a), std::end(a));
+ const C c2 = c1;
+ assert( (c1 == c2));
+ assert(!(c1 != c2));
+ }
+ {
+ typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ P a[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ C c1(std::begin(a), std::end(a));
+ C c2 = c1;
+ c2.rehash(30);
+ assert( (c1 == c2));
+ assert(!(c1 != c2));
+ c2.insert(P(90));
+ assert(!(c1 == c2));
+ assert( (c1 != c2));
+ c1.insert(P(90));
+ assert( (c1 == c2));
+ assert(!(c1 != c2));
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.set/equal_range_const.pass.cpp b/test/std/containers/unord/unord.set/equal_range_const.pass.cpp
new file mode 100644
index 000000000000..4168903e0200
--- /dev/null
+++ b/test/std/containers/unord/unord.set/equal_range_const.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_set<int> C;
+ typedef C::const_iterator I;
+ typedef int P;
+ P a[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(50),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ const C c(std::begin(a), std::end(a));
+ std::pair<I, I> r = c.equal_range(30);
+ assert(std::distance(r.first, r.second) == 1);
+ assert(*r.first == 30);
+ r = c.equal_range(5);
+ assert(std::distance(r.first, r.second) == 0);
+ r = c.equal_range(50);
+ assert(std::distance(r.first, r.second) == 1);
+ assert(*r.first == 50);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C;
+ typedef C::const_iterator I;
+ typedef int P;
+ P a[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(50),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ const C c(std::begin(a), std::end(a));
+ std::pair<I, I> r = c.equal_range(30);
+ assert(std::distance(r.first, r.second) == 1);
+ assert(*r.first == 30);
+ r = c.equal_range(5);
+ assert(std::distance(r.first, r.second) == 0);
+ r = c.equal_range(50);
+ assert(std::distance(r.first, r.second) == 1);
+ assert(*r.first == 50);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.set/equal_range_non_const.pass.cpp b/test/std/containers/unord/unord.set/equal_range_non_const.pass.cpp
new file mode 100644
index 000000000000..5a55083ba8ab
--- /dev/null
+++ b/test/std/containers/unord/unord.set/equal_range_non_const.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// pair<iterator, iterator> equal_range(const key_type& k);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_set<int> C;
+ typedef C::iterator I;
+ typedef int P;
+ P a[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(50),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ C c(std::begin(a), std::end(a));
+ std::pair<I, I> r = c.equal_range(30);
+ assert(std::distance(r.first, r.second) == 1);
+ assert(*r.first == 30);
+ r = c.equal_range(5);
+ assert(std::distance(r.first, r.second) == 0);
+ r = c.equal_range(50);
+ assert(std::distance(r.first, r.second) == 1);
+ assert(*r.first == 50);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C;
+ typedef C::iterator I;
+ typedef int P;
+ P a[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(50),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ C c(std::begin(a), std::end(a));
+ std::pair<I, I> r = c.equal_range(30);
+ assert(std::distance(r.first, r.second) == 1);
+ assert(*r.first == 30);
+ r = c.equal_range(5);
+ assert(std::distance(r.first, r.second) == 0);
+ r = c.equal_range(50);
+ assert(std::distance(r.first, r.second) == 1);
+ assert(*r.first == 50);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.set/erase_const_iter.pass.cpp b/test/std/containers/unord/unord.set/erase_const_iter.pass.cpp
new file mode 100644
index 000000000000..4110953badb6
--- /dev/null
+++ b/test/std/containers/unord/unord.set/erase_const_iter.pass.cpp
@@ -0,0 +1,90 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// iterator erase(const_iterator p)
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+struct TemplateConstructor
+{
+ template<typename T>
+ TemplateConstructor (const T&) {}
+};
+
+bool operator==(const TemplateConstructor&, const TemplateConstructor&) { return false; }
+struct Hash { size_t operator() (const TemplateConstructor &) const { return 0; } };
+
+int main()
+{
+ {
+ typedef std::unordered_set<int> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ C::const_iterator i = c.find(2);
+ C::iterator j = c.erase(i);
+ assert(c.size() == 3);
+ assert(c.count(1) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ C::const_iterator i = c.find(2);
+ C::iterator j = c.erase(i);
+ assert(c.size() == 3);
+ assert(c.count(1) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ }
+#endif
+#if __cplusplus >= 201402L
+ {
+ // This is LWG #2059
+ typedef TemplateConstructor T;
+ typedef std::unordered_set<T, Hash> C;
+ typedef C::iterator I;
+
+ C m;
+ T a{0};
+ I it = m.find(a);
+ if (it != m.end())
+ m.erase(it);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.set/erase_iter_db1.pass.cpp b/test/std/containers/unord/unord.set/erase_iter_db1.pass.cpp
new file mode 100644
index 000000000000..231152d14f4c
--- /dev/null
+++ b/test/std/containers/unord/unord.set/erase_iter_db1.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// Call erase(const_iterator position) with end()
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_set>
+#include <cassert>
+
+int main()
+{
+ {
+ int a1[] = {1, 2, 3};
+ std::unordered_set<int> l1(a1, a1+3);
+ std::unordered_set<int>::const_iterator i = l1.end();
+ l1.erase(i);
+ assert(false);
+ }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/containers/unord/unord.set/erase_iter_db2.pass.cpp b/test/std/containers/unord/unord.set/erase_iter_db2.pass.cpp
new file mode 100644
index 000000000000..06d61db017de
--- /dev/null
+++ b/test/std/containers/unord/unord.set/erase_iter_db2.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// Call erase(const_iterator position) with iterator from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_set>
+#include <cassert>
+#include <cstdlib>
+#include <exception>
+
+int main()
+{
+ {
+ int a1[] = {1, 2, 3};
+ std::unordered_set<int> l1(a1, a1+3);
+ std::unordered_set<int> l2(a1, a1+3);
+ std::unordered_set<int>::const_iterator i = l2.begin();
+ l1.erase(i);
+ assert(false);
+ }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/containers/unord/unord.set/erase_iter_iter_db1.pass.cpp b/test/std/containers/unord/unord.set/erase_iter_iter_db1.pass.cpp
new file mode 100644
index 000000000000..92c77f5567dd
--- /dev/null
+++ b/test/std/containers/unord/unord.set/erase_iter_iter_db1.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// Call erase(const_iterator first, const_iterator last); with first iterator from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_set>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+int main()
+{
+ {
+ int a1[] = {1, 2, 3};
+ std::unordered_set<int> l1(a1, a1+3);
+ std::unordered_set<int> l2(a1, a1+3);
+ std::unordered_set<int>::iterator i = l1.erase(l2.cbegin(), next(l1.cbegin()));
+ assert(false);
+ }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/containers/unord/unord.set/erase_iter_iter_db2.pass.cpp b/test/std/containers/unord/unord.set/erase_iter_iter_db2.pass.cpp
new file mode 100644
index 000000000000..d60665896249
--- /dev/null
+++ b/test/std/containers/unord/unord.set/erase_iter_iter_db2.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// Call erase(const_iterator first, const_iterator last); with second iterator from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_set>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+int main()
+{
+ {
+ int a1[] = {1, 2, 3};
+ std::unordered_set<int> l1(a1, a1+3);
+ std::unordered_set<int> l2(a1, a1+3);
+ std::unordered_set<int>::iterator i = l1.erase(l1.cbegin(), next(l2.cbegin()));
+ assert(false);
+ }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/containers/unord/unord.set/erase_iter_iter_db3.pass.cpp b/test/std/containers/unord/unord.set/erase_iter_iter_db3.pass.cpp
new file mode 100644
index 000000000000..f7ff42621fec
--- /dev/null
+++ b/test/std/containers/unord/unord.set/erase_iter_iter_db3.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// Call erase(const_iterator first, const_iterator last); with both iterators from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_set>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+int main()
+{
+ {
+ int a1[] = {1, 2, 3};
+ std::unordered_set<int> l1(a1, a1+3);
+ std::unordered_set<int> l2(a1, a1+3);
+ std::unordered_set<int>::iterator i = l1.erase(l2.cbegin(), next(l2.cbegin()));
+ assert(false);
+ }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/containers/unord/unord.set/erase_iter_iter_db4.pass.cpp b/test/std/containers/unord/unord.set/erase_iter_iter_db4.pass.cpp
new file mode 100644
index 000000000000..6cde216f4a95
--- /dev/null
+++ b/test/std/containers/unord/unord.set/erase_iter_iter_db4.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// Call erase(const_iterator first, const_iterator last); with a bad range
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_set>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+int main()
+{
+ {
+ int a1[] = {1, 2, 3};
+ std::unordered_set<int> l1(a1, a1+3);
+ std::unordered_set<int>::iterator i = l1.erase(next(l1.cbegin()), l1.cbegin());
+ assert(false);
+ }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/containers/unord/unord.set/erase_key.pass.cpp b/test/std/containers/unord/unord.set/erase_key.pass.cpp
new file mode 100644
index 000000000000..ca165083b023
--- /dev/null
+++ b/test/std/containers/unord/unord.set/erase_key.pass.cpp
@@ -0,0 +1,175 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// size_type erase(const key_type& k);
+
+#include <unordered_set>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+#if __cplusplus >= 201103L
+template <typename Unordered>
+bool only_deletions ( const Unordered &whole, const Unordered &part ) {
+ typename Unordered::const_iterator w = whole.begin();
+ typename Unordered::const_iterator p = part.begin();
+
+ while ( w != whole.end () && p != part.end()) {
+ if ( *w == *p )
+ p++;
+ w++;
+ }
+
+ return p == part.end();
+}
+#endif
+
+int main()
+{
+ {
+ typedef std::unordered_set<int> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.erase(5) == 0);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+
+ assert(c.erase(2) == 1);
+ assert(c.size() == 3);
+ assert(c.count(1) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+
+ assert(c.erase(2) == 0);
+ assert(c.size() == 3);
+ assert(c.count(1) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+
+ assert(c.erase(4) == 1);
+ assert(c.size() == 2);
+ assert(c.count(1) == 1);
+ assert(c.count(3) == 1);
+
+ assert(c.erase(4) == 0);
+ assert(c.size() == 2);
+ assert(c.count(1) == 1);
+ assert(c.count(3) == 1);
+
+ assert(c.erase(1) == 1);
+ assert(c.size() == 1);
+ assert(c.count(3) == 1);
+
+ assert(c.erase(1) == 0);
+ assert(c.size() == 1);
+ assert(c.count(3) == 1);
+
+ assert(c.erase(3) == 1);
+ assert(c.size() == 0);
+
+ assert(c.erase(3) == 0);
+ assert(c.size() == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.erase(5) == 0);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+
+ assert(c.erase(2) == 1);
+ assert(c.size() == 3);
+ assert(c.count(1) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+
+ assert(c.erase(2) == 0);
+ assert(c.size() == 3);
+ assert(c.count(1) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+
+ assert(c.erase(4) == 1);
+ assert(c.size() == 2);
+ assert(c.count(1) == 1);
+ assert(c.count(3) == 1);
+
+ assert(c.erase(4) == 0);
+ assert(c.size() == 2);
+ assert(c.count(1) == 1);
+ assert(c.count(3) == 1);
+
+ assert(c.erase(1) == 1);
+ assert(c.size() == 1);
+ assert(c.count(3) == 1);
+
+ assert(c.erase(1) == 0);
+ assert(c.size() == 1);
+ assert(c.count(3) == 1);
+
+ assert(c.erase(3) == 1);
+ assert(c.size() == 0);
+
+ assert(c.erase(3) == 0);
+ assert(c.size() == 0);
+ }
+ {
+ typedef std::unordered_set<int> C;
+ C m, m2;
+ for ( int i = 0; i < 10; ++i ) {
+ m.insert(i);
+ m2.insert(i);
+ }
+
+ C::iterator i = m2.begin();
+ int ctr = 0;
+ while (i != m2.end()) {
+ if (ctr++ % 2 == 0)
+ m2.erase(i++);
+ else
+ ++i;
+ }
+
+ assert (only_deletions (m, m2));
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.set/erase_range.pass.cpp b/test/std/containers/unord/unord.set/erase_range.pass.cpp
new file mode 100644
index 000000000000..a8a900551c7b
--- /dev/null
+++ b/test/std/containers/unord/unord.set/erase_range.pass.cpp
@@ -0,0 +1,93 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// iterator erase(const_iterator first, const_iterator last)
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_set<int> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ C::const_iterator i = c.find(2);
+ C::const_iterator j = next(i);
+ C::iterator k = c.erase(i, i);
+ assert(k == i);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+
+ k = c.erase(i, j);
+ assert(c.size() == 3);
+ assert(c.count(1) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+
+ k = c.erase(c.cbegin(), c.cend());
+ assert(c.size() == 0);
+ assert(k == c.end());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ C::const_iterator i = c.find(2);
+ C::const_iterator j = next(i);
+ C::iterator k = c.erase(i, i);
+ assert(k == i);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+
+ k = c.erase(i, j);
+ assert(c.size() == 3);
+ assert(c.count(1) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+
+ k = c.erase(c.cbegin(), c.cend());
+ assert(c.size() == 0);
+ assert(k == c.end());
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.set/find_const.pass.cpp b/test/std/containers/unord/unord.set/find_const.pass.cpp
new file mode 100644
index 000000000000..e2238e5665f9
--- /dev/null
+++ b/test/std/containers/unord/unord.set/find_const.pass.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// const_iterator find(const key_type& k) const;
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_set<int> C;
+ typedef int P;
+ P a[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ const C c(std::begin(a), std::end(a));
+ C::const_iterator i = c.find(30);
+ assert(*i == 30);
+ i = c.find(5);
+ assert(i == c.cend());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ P a[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ const C c(std::begin(a), std::end(a));
+ C::const_iterator i = c.find(30);
+ assert(*i == 30);
+ i = c.find(5);
+ assert(i == c.cend());
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.set/find_non_const.pass.cpp b/test/std/containers/unord/unord.set/find_non_const.pass.cpp
new file mode 100644
index 000000000000..8afe32abd72f
--- /dev/null
+++ b/test/std/containers/unord/unord.set/find_non_const.pass.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// iterator find(const key_type& k);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_set<int> C;
+ typedef int P;
+ P a[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ C c(std::begin(a), std::end(a));
+ C::iterator i = c.find(30);
+ assert(*i == 30);
+ i = c.find(5);
+ assert(i == c.cend());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ P a[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ C c(std::begin(a), std::end(a));
+ C::iterator i = c.find(30);
+ assert(*i == 30);
+ i = c.find(5);
+ assert(i == c.cend());
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.set/insert_const_lvalue.pass.cpp b/test/std/containers/unord/unord.set/insert_const_lvalue.pass.cpp
new file mode 100644
index 000000000000..321e9054af6c
--- /dev/null
+++ b/test/std/containers/unord/unord.set/insert_const_lvalue.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// pair<iterator, bool> insert(const value_type& x);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_set<double> C;
+ typedef std::pair<C::iterator, bool> R;
+ typedef C::value_type P;
+ C c;
+ R r = c.insert(P(3.5));
+ assert(c.size() == 1);
+ assert(*r.first == 3.5);
+ assert(r.second);
+
+ r = c.insert(P(3.5));
+ assert(c.size() == 1);
+ assert(*r.first == 3.5);
+ assert(!r.second);
+
+ r = c.insert(P(4.5));
+ assert(c.size() == 2);
+ assert(*r.first == 4.5);
+ assert(r.second);
+
+ r = c.insert(P(5.5));
+ assert(c.size() == 3);
+ assert(*r.first == 5.5);
+ assert(r.second);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<double, std::hash<double>,
+ std::equal_to<double>, min_allocator<double>> C;
+ typedef std::pair<C::iterator, bool> R;
+ typedef C::value_type P;
+ C c;
+ R r = c.insert(P(3.5));
+ assert(c.size() == 1);
+ assert(*r.first == 3.5);
+ assert(r.second);
+
+ r = c.insert(P(3.5));
+ assert(c.size() == 1);
+ assert(*r.first == 3.5);
+ assert(!r.second);
+
+ r = c.insert(P(4.5));
+ assert(c.size() == 2);
+ assert(*r.first == 4.5);
+ assert(r.second);
+
+ r = c.insert(P(5.5));
+ assert(c.size() == 3);
+ assert(*r.first == 5.5);
+ assert(r.second);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.set/insert_hint_const_lvalue.pass.cpp b/test/std/containers/unord/unord.set/insert_hint_const_lvalue.pass.cpp
new file mode 100644
index 000000000000..1393f5420111
--- /dev/null
+++ b/test/std/containers/unord/unord.set/insert_hint_const_lvalue.pass.cpp
@@ -0,0 +1,89 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// iterator insert(const_iterator p, const value_type& x);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_set<double> C;
+ typedef C::iterator R;
+ typedef C::value_type P;
+ C c;
+ C::const_iterator e = c.end();
+ R r = c.insert(e, P(3.5));
+ assert(c.size() == 1);
+ assert(*r == 3.5);
+
+ r = c.insert(e, P(3.5));
+ assert(c.size() == 1);
+ assert(*r == 3.5);
+
+ r = c.insert(e, P(4.5));
+ assert(c.size() == 2);
+ assert(*r == 4.5);
+
+ r = c.insert(e, P(5.5));
+ assert(c.size() == 3);
+ assert(*r == 5.5);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<double, std::hash<double>,
+ std::equal_to<double>, min_allocator<double>> C;
+ typedef C::iterator R;
+ typedef C::value_type P;
+ C c;
+ C::const_iterator e = c.end();
+ R r = c.insert(e, P(3.5));
+ assert(c.size() == 1);
+ assert(*r == 3.5);
+
+ r = c.insert(e, P(3.5));
+ assert(c.size() == 1);
+ assert(*r == 3.5);
+
+ r = c.insert(e, P(4.5));
+ assert(c.size() == 2);
+ assert(*r == 4.5);
+
+ r = c.insert(e, P(5.5));
+ assert(c.size() == 3);
+ assert(*r == 5.5);
+ }
+#endif
+#if _LIBCPP_DEBUG >= 1
+ {
+ typedef std::unordered_set<double> C;
+ typedef C::iterator R;
+ typedef C::value_type P;
+ C c;
+ C c2;
+ C::const_iterator e = c2.end();
+ P v(3.5);
+ R r = c.insert(e, v);
+ assert(false);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.set/insert_hint_rvalue.pass.cpp b/test/std/containers/unord/unord.set/insert_hint_rvalue.pass.cpp
new file mode 100644
index 000000000000..3f04dbb89984
--- /dev/null
+++ b/test/std/containers/unord/unord.set/insert_hint_rvalue.pass.cpp
@@ -0,0 +1,138 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// iterator insert(const_iterator p, value_type&& x);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_set>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_set<double> C;
+ typedef C::iterator R;
+ typedef double P;
+ C c;
+ C::const_iterator e = c.end();
+ R r = c.insert(e, P(3.5));
+ assert(c.size() == 1);
+ assert(*r == 3.5);
+
+ r = c.insert(r, P(3.5));
+ assert(c.size() == 1);
+ assert(*r == 3.5);
+
+ r = c.insert(e, P(4.5));
+ assert(c.size() == 2);
+ assert(*r == 4.5);
+
+ r = c.insert(e, P(5.5));
+ assert(c.size() == 3);
+ assert(*r == 5.5);
+ }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::unordered_set<MoveOnly> C;
+ typedef C::iterator R;
+ typedef MoveOnly P;
+ C c;
+ C::const_iterator e = c.end();
+ R r = c.insert(e, P(3));
+ assert(c.size() == 1);
+ assert(*r == 3);
+
+ r = c.insert(r, P(3));
+ assert(c.size() == 1);
+ assert(*r == 3);
+
+ r = c.insert(e, P(4));
+ assert(c.size() == 2);
+ assert(*r == 4);
+
+ r = c.insert(e, P(5));
+ assert(c.size() == 3);
+ assert(*r == 5);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<double, std::hash<double>,
+ std::equal_to<double>, min_allocator<double>> C;
+ typedef C::iterator R;
+ typedef double P;
+ C c;
+ C::const_iterator e = c.end();
+ R r = c.insert(e, P(3.5));
+ assert(c.size() == 1);
+ assert(*r == 3.5);
+
+ r = c.insert(r, P(3.5));
+ assert(c.size() == 1);
+ assert(*r == 3.5);
+
+ r = c.insert(e, P(4.5));
+ assert(c.size() == 2);
+ assert(*r == 4.5);
+
+ r = c.insert(e, P(5.5));
+ assert(c.size() == 3);
+ assert(*r == 5.5);
+ }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, min_allocator<MoveOnly>> C;
+ typedef C::iterator R;
+ typedef MoveOnly P;
+ C c;
+ C::const_iterator e = c.end();
+ R r = c.insert(e, P(3));
+ assert(c.size() == 1);
+ assert(*r == 3);
+
+ r = c.insert(r, P(3));
+ assert(c.size() == 1);
+ assert(*r == 3);
+
+ r = c.insert(e, P(4));
+ assert(c.size() == 2);
+ assert(*r == 4);
+
+ r = c.insert(e, P(5));
+ assert(c.size() == 3);
+ assert(*r == 5);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if _LIBCPP_DEBUG >= 1
+ {
+ typedef std::unordered_set<double> C;
+ typedef C::iterator R;
+ typedef C::value_type P;
+ C c;
+ C c2;
+ C::const_iterator e = c2.end();
+ R r = c.insert(e, P(3.5));
+ assert(false);
+ }
+#endif
+#endif
+}
diff --git a/test/std/containers/unord/unord.set/insert_init.pass.cpp b/test/std/containers/unord/unord.set/insert_init.pass.cpp
new file mode 100644
index 000000000000..2d8eafba4891
--- /dev/null
+++ b/test/std/containers/unord/unord.set/insert_init.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// void insert(initializer_list<value_type> il);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::unordered_set<int> C;
+ typedef int P;
+ C c;
+ c.insert(
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ }
+ );
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ C c;
+ c.insert(
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ }
+ );
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/containers/unord/unord.set/insert_range.pass.cpp b/test/std/containers/unord/unord.set/insert_range.pass.cpp
new file mode 100644
index 000000000000..72a83abf74e9
--- /dev/null
+++ b/test/std/containers/unord/unord.set/insert_range.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// template <class InputIterator>
+// void insert(InputIterator first, InputIterator last);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_set<int> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c;
+ c.insert(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])));
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c;
+ c.insert(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])));
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.set/insert_rvalue.pass.cpp b/test/std/containers/unord/unord.set/insert_rvalue.pass.cpp
new file mode 100644
index 000000000000..e043579bf971
--- /dev/null
+++ b/test/std/containers/unord/unord.set/insert_rvalue.pass.cpp
@@ -0,0 +1,134 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// pair<iterator, bool> insert(value_type&& x);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_set<double> C;
+ typedef std::pair<C::iterator, bool> R;
+ typedef double P;
+ C c;
+ R r = c.insert(P(3.5));
+ assert(c.size() == 1);
+ assert(*r.first == 3.5);
+ assert(r.second);
+
+ r = c.insert(P(3.5));
+ assert(c.size() == 1);
+ assert(*r.first == 3.5);
+ assert(!r.second);
+
+ r = c.insert(P(4.5));
+ assert(c.size() == 2);
+ assert(*r.first == 4.5);
+ assert(r.second);
+
+ r = c.insert(P(5.5));
+ assert(c.size() == 3);
+ assert(*r.first == 5.5);
+ assert(r.second);
+ }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::unordered_set<MoveOnly> C;
+ typedef std::pair<C::iterator, bool> R;
+ typedef MoveOnly P;
+ C c;
+ R r = c.insert(P(3));
+ assert(c.size() == 1);
+ assert(*r.first == 3);
+ assert(r.second);
+
+ r = c.insert(P(3));
+ assert(c.size() == 1);
+ assert(*r.first == 3);
+ assert(!r.second);
+
+ r = c.insert(P(4));
+ assert(c.size() == 2);
+ assert(*r.first == 4);
+ assert(r.second);
+
+ r = c.insert(P(5));
+ assert(c.size() == 3);
+ assert(*r.first == 5);
+ assert(r.second);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<double, std::hash<double>,
+ std::equal_to<double>, min_allocator<double>> C;
+ typedef std::pair<C::iterator, bool> R;
+ typedef double P;
+ C c;
+ R r = c.insert(P(3.5));
+ assert(c.size() == 1);
+ assert(*r.first == 3.5);
+ assert(r.second);
+
+ r = c.insert(P(3.5));
+ assert(c.size() == 1);
+ assert(*r.first == 3.5);
+ assert(!r.second);
+
+ r = c.insert(P(4.5));
+ assert(c.size() == 2);
+ assert(*r.first == 4.5);
+ assert(r.second);
+
+ r = c.insert(P(5.5));
+ assert(c.size() == 3);
+ assert(*r.first == 5.5);
+ assert(r.second);
+ }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, min_allocator<MoveOnly>> C;
+ typedef std::pair<C::iterator, bool> R;
+ typedef MoveOnly P;
+ C c;
+ R r = c.insert(P(3));
+ assert(c.size() == 1);
+ assert(*r.first == 3);
+ assert(r.second);
+
+ r = c.insert(P(3));
+ assert(c.size() == 1);
+ assert(*r.first == 3);
+ assert(!r.second);
+
+ r = c.insert(P(4));
+ assert(c.size() == 2);
+ assert(*r.first == 4);
+ assert(r.second);
+
+ r = c.insert(P(5));
+ assert(c.size() == 3);
+ assert(*r.first == 5);
+ assert(r.second);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif
+}
diff --git a/test/std/containers/unord/unord.set/iterators.fail.cpp b/test/std/containers/unord/unord.set/iterators.fail.cpp
new file mode 100644
index 000000000000..2bb180b6e216
--- /dev/null
+++ b/test/std/containers/unord/unord.set/iterators.fail.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// iterator begin() {return __table_.begin();}
+// iterator end() {return __table_.end();}
+// const_iterator begin() const {return __table_.begin();}
+// const_iterator end() const {return __table_.end();}
+// const_iterator cbegin() const {return __table_.begin();}
+// const_iterator cend() const {return __table_.end();}
+
+#include <unordered_set>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::unordered_set<int> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 5);
+ assert(c.size() == 6);
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ C::iterator i = c.begin();
+ assert(*i == 1);
+ *i = 2;
+ }
+ {
+ typedef std::unordered_set<int> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 5);
+ assert(c.size() == 6);
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ }
+}
diff --git a/test/std/containers/unord/unord.set/iterators.pass.cpp b/test/std/containers/unord/unord.set/iterators.pass.cpp
new file mode 100644
index 000000000000..d3a45801f162
--- /dev/null
+++ b/test/std/containers/unord/unord.set/iterators.pass.cpp
@@ -0,0 +1,127 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// iterator begin() {return __table_.begin();}
+// iterator end() {return __table_.end();}
+// const_iterator begin() const {return __table_.begin();}
+// const_iterator end() const {return __table_.end();}
+// const_iterator cbegin() const {return __table_.begin();}
+// const_iterator cend() const {return __table_.end();}
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_set<int> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 5);
+ assert(c.size() == 4);
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ C::iterator i;
+ }
+ {
+ typedef std::unordered_set<int> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 5);
+ assert(c.size() == 4);
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ C::const_iterator i;
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 5);
+ assert(c.size() == 4);
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ C::iterator i;
+ }
+ {
+ typedef std::unordered_set<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 5);
+ assert(c.size() == 4);
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ C::const_iterator i;
+ }
+#endif
+#if _LIBCPP_STD_VER > 11
+ { // N3644 testing
+ typedef std::unordered_set<int> C;
+ C::iterator ii1{}, ii2{};
+ C::iterator ii4 = ii1;
+ C::const_iterator cii{};
+ assert ( ii1 == ii2 );
+ assert ( ii1 == ii4 );
+
+ assert (!(ii1 != ii2 ));
+
+ assert ( (ii1 == cii ));
+ assert ( (cii == ii1 ));
+ assert (!(ii1 != cii ));
+ assert (!(cii != ii1 ));
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.set/load_factor.pass.cpp b/test/std/containers/unord/unord.set/load_factor.pass.cpp
new file mode 100644
index 000000000000..e0ed1694b05b
--- /dev/null
+++ b/test/std/containers/unord/unord.set/load_factor.pass.cpp
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// float load_factor() const
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_set<int> C;
+ typedef int P;
+ P a[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ const C c(std::begin(a), std::end(a));
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ }
+ {
+ typedef std::unordered_set<int> C;
+ typedef int P;
+ const C c;
+ assert(c.load_factor() == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ P a[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ const C c(std::begin(a), std::end(a));
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ }
+ {
+ typedef std::unordered_set<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ const C c;
+ assert(c.load_factor() == 0);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.set/local_iterators.fail.cpp b/test/std/containers/unord/unord.set/local_iterators.fail.cpp
new file mode 100644
index 000000000000..eb671a442f16
--- /dev/null
+++ b/test/std/containers/unord/unord.set/local_iterators.fail.cpp
@@ -0,0 +1,261 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// local_iterator begin (size_type n);
+// local_iterator end (size_type n);
+// const_local_iterator begin (size_type n) const;
+// const_local_iterator end (size_type n) const;
+// const_local_iterator cbegin(size_type n) const;
+// const_local_iterator cend (size_type n) const;
+
+#include <unordered_set>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::unordered_set<int> C;
+ typedef int P;
+ typedef C::local_iterator I;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 5);
+ C::size_type b = c.bucket(0);
+ I i = c.begin(b);
+ I j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 2);
+ assert(*i == 1);
+ ++i;
+ assert(*i == 1);
+ *i = 2;
+
+ b = c.bucket(2);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 2);
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+
+ b = c.bucket(3);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 3);
+
+ b = c.bucket(4);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 4);
+
+ b = c.bucket(5);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(6);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 0);
+ }
+ {
+ typedef std::unordered_set<int> C;
+ typedef int P;
+ typedef C::const_local_iterator I;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 5);
+ C::size_type b = c.bucket(0);
+ I i = c.begin(b);
+ I j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 2);
+ assert(*i == 1);
+ ++i;
+ assert(*i == 1);
+
+ b = c.bucket(2);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 2);
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+
+ b = c.bucket(3);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 3);
+
+ b = c.bucket(4);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 4);
+
+ b = c.bucket(5);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(6);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 0);
+ }
+ {
+ typedef std::unordered_set<int> C;
+ typedef int P;
+ typedef C::const_local_iterator I;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 5);
+ C::size_type b = c.bucket(0);
+ I i = c.cbegin(b);
+ I j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 2);
+ assert(*i == 1);
+ ++i;
+ assert(*i == 1);
+
+ b = c.bucket(2);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 2);
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+
+ b = c.bucket(3);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 3);
+
+ b = c.bucket(4);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 4);
+
+ b = c.bucket(5);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(6);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+ }
+ {
+ typedef std::unordered_set<int> C;
+ typedef int P;
+ typedef C::const_local_iterator I;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 5);
+ C::size_type b = c.bucket(0);
+ I i = c.cbegin(b);
+ I j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 2);
+ assert(*i == 1);
+ ++i;
+ assert(*i == 1);
+
+ b = c.bucket(2);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 2);
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+
+ b = c.bucket(3);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 3);
+
+ b = c.bucket(4);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 4);
+
+ b = c.bucket(5);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(6);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+ }
+}
diff --git a/test/std/containers/unord/unord.set/local_iterators.pass.cpp b/test/std/containers/unord/unord.set/local_iterators.pass.cpp
new file mode 100644
index 000000000000..2ffd93f30d19
--- /dev/null
+++ b/test/std/containers/unord/unord.set/local_iterators.pass.cpp
@@ -0,0 +1,388 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// local_iterator begin (size_type n);
+// local_iterator end (size_type n);
+// const_local_iterator begin (size_type n) const;
+// const_local_iterator end (size_type n) const;
+// const_local_iterator cbegin(size_type n) const;
+// const_local_iterator cend (size_type n) const;
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_set<int> C;
+ typedef int P;
+ typedef C::local_iterator I;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 5);
+ C::size_type b = c.bucket(0);
+ I i = c.begin(b);
+ I j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 1);
+
+ b = c.bucket(2);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 2);
+
+ b = c.bucket(3);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 3);
+
+ b = c.bucket(4);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 4);
+ }
+ {
+ typedef std::unordered_set<int> C;
+ typedef int P;
+ typedef C::const_local_iterator I;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 5);
+ C::size_type b = c.bucket(0);
+ I i = c.begin(b);
+ I j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 1);
+
+ b = c.bucket(2);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 2);
+
+ b = c.bucket(3);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 3);
+
+ b = c.bucket(4);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 4);
+ }
+ {
+ typedef std::unordered_set<int> C;
+ typedef int P;
+ typedef C::const_local_iterator I;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 5);
+ C::size_type b = c.bucket(0);
+ I i = c.cbegin(b);
+ I j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 1);
+
+ b = c.bucket(2);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 2);
+
+ b = c.bucket(3);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 3);
+
+ b = c.bucket(4);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 4);
+ }
+ {
+ typedef std::unordered_set<int> C;
+ typedef int P;
+ typedef C::const_local_iterator I;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 5);
+ C::size_type b = c.bucket(0);
+ I i = c.cbegin(b);
+ I j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 1);
+
+ b = c.bucket(2);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 2);
+
+ b = c.bucket(3);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 3);
+
+ b = c.bucket(4);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 4);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ typedef C::local_iterator I;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 5);
+ C::size_type b = c.bucket(0);
+ I i = c.begin(b);
+ I j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 1);
+
+ b = c.bucket(2);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 2);
+
+ b = c.bucket(3);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 3);
+
+ b = c.bucket(4);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 4);
+ }
+ {
+ typedef std::unordered_set<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ typedef C::const_local_iterator I;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 5);
+ C::size_type b = c.bucket(0);
+ I i = c.begin(b);
+ I j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 1);
+
+ b = c.bucket(2);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 2);
+
+ b = c.bucket(3);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 3);
+
+ b = c.bucket(4);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 4);
+ }
+ {
+ typedef std::unordered_set<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ typedef C::const_local_iterator I;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 5);
+ C::size_type b = c.bucket(0);
+ I i = c.cbegin(b);
+ I j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 1);
+
+ b = c.bucket(2);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 2);
+
+ b = c.bucket(3);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 3);
+
+ b = c.bucket(4);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 4);
+ }
+ {
+ typedef std::unordered_set<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ typedef C::const_local_iterator I;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 5);
+ C::size_type b = c.bucket(0);
+ I i = c.cbegin(b);
+ I j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 1);
+
+ b = c.bucket(2);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 2);
+
+ b = c.bucket(3);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 3);
+
+ b = c.bucket(4);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 4);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.set/max_bucket_count.pass.cpp b/test/std/containers/unord/unord.set/max_bucket_count.pass.cpp
new file mode 100644
index 000000000000..8b5e265de3f2
--- /dev/null
+++ b/test/std/containers/unord/unord.set/max_bucket_count.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// size_type max_bucket_count() const;
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_set<int> C;
+ const C c;
+ assert(c.max_bucket_count() > 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ const C c;
+ assert(c.max_bucket_count() > 0);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.set/max_load_factor.pass.cpp b/test/std/containers/unord/unord.set/max_load_factor.pass.cpp
new file mode 100644
index 000000000000..d326f4a2d7e2
--- /dev/null
+++ b/test/std/containers/unord/unord.set/max_load_factor.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// float max_load_factor() const;
+// void max_load_factor(float mlf);
+
+#ifdef _LIBCPP_DEBUG
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_set<int> C;
+ typedef int P;
+ const C c;
+ assert(c.max_load_factor() == 1);
+ }
+ {
+ typedef std::unordered_set<int> C;
+ typedef int P;
+ C c;
+ assert(c.max_load_factor() == 1);
+ c.max_load_factor(2.5);
+ assert(c.max_load_factor() == 2.5);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ const C c;
+ assert(c.max_load_factor() == 1);
+ }
+ {
+ typedef std::unordered_set<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ C c;
+ assert(c.max_load_factor() == 1);
+ c.max_load_factor(2.5);
+ assert(c.max_load_factor() == 2.5);
+ }
+#endif
+#if _LIBCPP_DEBUG_LEVEL >= 1
+ {
+ typedef std::unordered_set<int> C;
+ C c;
+ c.max_load_factor(-0.5f);
+ assert(false);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.set/max_size.pass.cpp b/test/std/containers/unord/unord.set/max_size.pass.cpp
new file mode 100644
index 000000000000..1c6e74125c7d
--- /dev/null
+++ b/test/std/containers/unord/unord.set/max_size.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// size_type max_size() const;
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::unordered_set<int> u;
+ assert(u.max_size() > 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::unordered_set<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> u;
+ assert(u.max_size() > 0);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.set/rehash.pass.cpp b/test/std/containers/unord/unord.set/rehash.pass.cpp
new file mode 100644
index 000000000000..30fffa561f78
--- /dev/null
+++ b/test/std/containers/unord/unord.set/rehash.pass.cpp
@@ -0,0 +1,90 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// void rehash(size_type n);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class C>
+void test(const C& c)
+{
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+}
+
+int main()
+{
+ {
+ typedef std::unordered_set<int> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ test(c);
+ assert(c.bucket_count() >= 5);
+ c.rehash(3);
+ assert(c.bucket_count() == 5);
+ test(c);
+ c.max_load_factor(2);
+ c.rehash(3);
+ assert(c.bucket_count() == 3);
+ test(c);
+ c.rehash(31);
+ assert(c.bucket_count() == 31);
+ test(c);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ test(c);
+ assert(c.bucket_count() >= 5);
+ c.rehash(3);
+ assert(c.bucket_count() == 5);
+ test(c);
+ c.max_load_factor(2);
+ c.rehash(3);
+ assert(c.bucket_count() == 3);
+ test(c);
+ c.rehash(31);
+ assert(c.bucket_count() == 31);
+ test(c);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.set/reserve.pass.cpp b/test/std/containers/unord/unord.set/reserve.pass.cpp
new file mode 100644
index 000000000000..7d6656a18674
--- /dev/null
+++ b/test/std/containers/unord/unord.set/reserve.pass.cpp
@@ -0,0 +1,90 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// void reserve(size_type n);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class C>
+void test(const C& c)
+{
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+}
+
+int main()
+{
+ {
+ typedef std::unordered_set<int> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ test(c);
+ assert(c.bucket_count() >= 5);
+ c.reserve(3);
+ assert(c.bucket_count() == 5);
+ test(c);
+ c.max_load_factor(2);
+ c.reserve(3);
+ assert(c.bucket_count() >= 2);
+ test(c);
+ c.reserve(31);
+ assert(c.bucket_count() >= 16);
+ test(c);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ test(c);
+ assert(c.bucket_count() >= 5);
+ c.reserve(3);
+ assert(c.bucket_count() == 5);
+ test(c);
+ c.max_load_factor(2);
+ c.reserve(3);
+ assert(c.bucket_count() >= 2);
+ test(c);
+ c.reserve(31);
+ assert(c.bucket_count() >= 16);
+ test(c);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.set/swap_member.pass.cpp b/test/std/containers/unord/unord.set/swap_member.pass.cpp
new file mode 100644
index 000000000000..89ec986d08f3
--- /dev/null
+++ b/test/std/containers/unord/unord.set/swap_member.pass.cpp
@@ -0,0 +1,571 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// void swap(unordered_set& u);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../test_compare.h"
+#include "../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef test_allocator<int> Alloc;
+ typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ C c1(0, Hash(1), Compare(1), Alloc(1));
+ C c2(0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(1));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(2));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef test_allocator<int> Alloc;
+ typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ P a2[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ C c1(0, Hash(1), Compare(1), Alloc(1));
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(*c1.find(10) == 10);
+ assert(*c1.find(20) == 20);
+ assert(*c1.find(30) == 30);
+ assert(*c1.find(40) == 40);
+ assert(*c1.find(50) == 50);
+ assert(*c1.find(60) == 60);
+ assert(*c1.find(70) == 70);
+ assert(*c1.find(80) == 80);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(1));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(2));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef test_allocator<int> Alloc;
+ typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ P a1[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+ C c2(0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(1));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 5);
+ assert(c2.size() == 4);
+ assert(c2.count(1) == 1);
+ assert(c2.count(2) == 1);
+ assert(c2.count(3) == 1);
+ assert(c2.count(4) == 1);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(2));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef test_allocator<int> Alloc;
+ typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ P a1[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ P a2[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(*c1.find(10) == 10);
+ assert(*c1.find(20) == 20);
+ assert(*c1.find(30) == 30);
+ assert(*c1.find(40) == 40);
+ assert(*c1.find(50) == 50);
+ assert(*c1.find(60) == 60);
+ assert(*c1.find(70) == 70);
+ assert(*c1.find(80) == 80);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(1));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 5);
+ assert(c2.size() == 4);
+ assert(c2.count(1) == 1);
+ assert(c2.count(2) == 1);
+ assert(c2.count(3) == 1);
+ assert(c2.count(4) == 1);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(2));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef other_allocator<int> Alloc;
+ typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ C c1(0, Hash(1), Compare(1), Alloc(1));
+ C c2(0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(2));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(1));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef other_allocator<int> Alloc;
+ typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ P a2[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ C c1(0, Hash(1), Compare(1), Alloc(1));
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(*c1.find(10) == 10);
+ assert(*c1.find(20) == 20);
+ assert(*c1.find(30) == 30);
+ assert(*c1.find(40) == 40);
+ assert(*c1.find(50) == 50);
+ assert(*c1.find(60) == 60);
+ assert(*c1.find(70) == 70);
+ assert(*c1.find(80) == 80);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(2));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(1));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef other_allocator<int> Alloc;
+ typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ P a1[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+ C c2(0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(2));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 5);
+ assert(c2.size() == 4);
+ assert(c2.count(1) == 1);
+ assert(c2.count(2) == 1);
+ assert(c2.count(3) == 1);
+ assert(c2.count(4) == 1);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(1));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef other_allocator<int> Alloc;
+ typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ P a1[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ P a2[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(*c1.find(10) == 10);
+ assert(*c1.find(20) == 20);
+ assert(*c1.find(30) == 30);
+ assert(*c1.find(40) == 40);
+ assert(*c1.find(50) == 50);
+ assert(*c1.find(60) == 60);
+ assert(*c1.find(70) == 70);
+ assert(*c1.find(80) == 80);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(2));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 5);
+ assert(c2.size() == 4);
+ assert(c2.count(1) == 1);
+ assert(c2.count(2) == 1);
+ assert(c2.count(3) == 1);
+ assert(c2.count(4) == 1);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(1));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef min_allocator<int> Alloc;
+ typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ C c1(0, Hash(1), Compare(1), Alloc());
+ C c2(0, Hash(2), Compare(2), Alloc());
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc());
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc());
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef min_allocator<int> Alloc;
+ typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ P a2[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ C c1(0, Hash(1), Compare(1), Alloc());
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc());
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(*c1.find(10) == 10);
+ assert(*c1.find(20) == 20);
+ assert(*c1.find(30) == 30);
+ assert(*c1.find(40) == 40);
+ assert(*c1.find(50) == 50);
+ assert(*c1.find(60) == 60);
+ assert(*c1.find(70) == 70);
+ assert(*c1.find(80) == 80);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc());
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc());
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef min_allocator<int> Alloc;
+ typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ P a1[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc());
+ C c2(0, Hash(2), Compare(2), Alloc());
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc());
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 5);
+ assert(c2.size() == 4);
+ assert(c2.count(1) == 1);
+ assert(c2.count(2) == 1);
+ assert(c2.count(3) == 1);
+ assert(c2.count(4) == 1);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc());
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef min_allocator<int> Alloc;
+ typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ P a1[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ P a2[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc());
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc());
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(*c1.find(10) == 10);
+ assert(*c1.find(20) == 20);
+ assert(*c1.find(30) == 30);
+ assert(*c1.find(40) == 40);
+ assert(*c1.find(50) == 50);
+ assert(*c1.find(60) == 60);
+ assert(*c1.find(70) == 70);
+ assert(*c1.find(80) == 80);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc());
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 5);
+ assert(c2.size() == 4);
+ assert(c2.count(1) == 1);
+ assert(c2.count(2) == 1);
+ assert(c2.count(3) == 1);
+ assert(c2.count(4) == 1);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc());
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.set/types.pass.cpp b/test/std/containers/unord/unord.set/types.pass.cpp
new file mode 100644
index 000000000000..7e752a434ece
--- /dev/null
+++ b/test/std/containers/unord/unord.set/types.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+// {
+// public:
+// // types
+// typedef Value value_type;
+// typedef value_type key_type;
+// typedef Hash hasher;
+// typedef Pred key_equal;
+// typedef Alloc allocator_type;
+// typedef value_type& reference;
+// typedef const value_type& const_reference;
+// typedef typename allocator_traits<allocator_type>::pointer pointer;
+// typedef typename allocator_traits<allocator_type>::const_pointer const_pointer;
+// typedef typename allocator_traits<allocator_type>::size_type size_type;
+// typedef typename allocator_traits<allocator_type>::difference_type difference_type;
+
+#include <unordered_set>
+#include <type_traits>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_set<short> C;
+ static_assert((std::is_same<C::value_type, short>::value), "");
+ static_assert((std::is_same<C::key_type, short>::value), "");
+ static_assert((std::is_same<C::hasher, std::hash<C::key_type> >::value), "");
+ static_assert((std::is_same<C::key_equal, std::equal_to<C::key_type> >::value), "");
+ static_assert((std::is_same<C::allocator_type, std::allocator<C::value_type> >::value), "");
+ static_assert((std::is_same<C::reference, C::value_type&>::value), "");
+ static_assert((std::is_same<C::const_reference, const C::value_type&>::value), "");
+ static_assert((std::is_same<C::pointer, C::value_type*>::value), "");
+ static_assert((std::is_same<C::const_pointer, const C::value_type*>::value), "");
+ static_assert((std::is_same<C::size_type, std::size_t>::value), "");
+ static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<short, std::hash<short>,
+ std::equal_to<short>, min_allocator<short>> C;
+ static_assert((std::is_same<C::value_type, short>::value), "");
+ static_assert((std::is_same<C::key_type, short>::value), "");
+ static_assert((std::is_same<C::hasher, std::hash<C::key_type> >::value), "");
+ static_assert((std::is_same<C::key_equal, std::equal_to<C::key_type> >::value), "");
+ static_assert((std::is_same<C::allocator_type, min_allocator<C::value_type> >::value), "");
+ static_assert((std::is_same<C::reference, C::value_type&>::value), "");
+ static_assert((std::is_same<C::const_reference, const C::value_type&>::value), "");
+ static_assert((std::is_same<C::pointer, min_pointer<C::value_type>>::value), "");
+ static_assert((std::is_same<C::const_pointer, min_pointer<const C::value_type>>::value), "");
+ // min_allocator doesn't have a size_type, so one gets synthesized
+ static_assert((std::is_same<C::size_type, std::make_unsigned<C::difference_type>::type>::value), "");
+ static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.set/unord.set.cnstr/allocator.pass.cpp b/test/std/containers/unord/unord.set/unord.set.cnstr/allocator.pass.cpp
new file mode 100644
index 000000000000..30905aeb9fe2
--- /dev/null
+++ b/test/std/containers/unord/unord.set/unord.set.cnstr/allocator.pass.cpp
@@ -0,0 +1,109 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// explicit unordered_set(const allocator_type& __a);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_set<NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ test_allocator<NotConstructible>
+ > C;
+ C c(test_allocator<NotConstructible>(10));
+ assert(c.bucket_count() == 0);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() == test_allocator<NotConstructible>(10));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ min_allocator<NotConstructible>
+ > C;
+ C c(min_allocator<NotConstructible>{});
+ assert(c.bucket_count() == 0);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() == min_allocator<NotConstructible>());
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef NotConstructible T;
+ typedef test_hash<std::hash<T>> HF;
+ typedef test_compare<std::equal_to<T>> Comp;
+ typedef test_allocator<T> A;
+ typedef std::unordered_set<T, HF, Comp, A> C;
+
+ A a(43);
+ C c(3, a);
+ assert(c.bucket_count() == 3);
+ assert(c.hash_function() == HF());
+ assert(c.key_eq() == Comp ());
+ assert(c.get_allocator() == a);
+ assert(!(c.get_allocator() == A()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+ {
+ typedef NotConstructible T;
+ typedef test_hash<std::hash<T>> HF;
+ typedef test_compare<std::equal_to<T>> Comp;
+ typedef test_allocator<T> A;
+ typedef std::unordered_set<T, HF, Comp, A> C;
+
+ HF hf(42);
+ A a(43);
+ C c(4, hf, a);
+ assert(c.bucket_count() == 4);
+ assert(c.hash_function() == hf);
+ assert(!(c.hash_function() == HF()));
+ assert(c.key_eq() == Comp ());
+ assert(c.get_allocator() == a);
+ assert(!(c.get_allocator() == A()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+#endif
+}
diff --git a/test/std/containers/unord/unord.set/unord.set.cnstr/assign_copy.pass.cpp b/test/std/containers/unord/unord.set/unord.set.cnstr/assign_copy.pass.cpp
new file mode 100644
index 000000000000..6925e3045412
--- /dev/null
+++ b/test/std/containers/unord/unord.set/unord.set.cnstr/assign_copy.pass.cpp
@@ -0,0 +1,184 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// unordered_set& operator=(const unordered_set& u);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef test_allocator<int> A;
+ typedef std::unordered_set<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A(10)
+ );
+ C c(a, a + 2,
+ 7,
+ test_hash<std::hash<int> >(2),
+ test_compare<std::equal_to<int> >(3),
+ A(4)
+ );
+ c = c0;
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == A(4));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+ {
+ typedef std::unordered_set<int> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ C *p = &c;
+ c = *p;
+ assert(c.size() == 4);
+ assert(std::is_permutation(c.begin(), c.end(), a));
+ }
+ {
+ typedef other_allocator<int> A;
+ typedef std::unordered_set<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A(10)
+ );
+ C c(a, a + 2,
+ 7,
+ test_hash<std::hash<int> >(2),
+ test_compare<std::equal_to<int> >(3),
+ A(4)
+ );
+ c = c0;
+ assert(c.bucket_count() >= 5);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == A(10));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef min_allocator<int> A;
+ typedef std::unordered_set<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A()
+ );
+ C c(a, a + 2,
+ 7,
+ test_hash<std::hash<int> >(2),
+ test_compare<std::equal_to<int> >(3),
+ A()
+ );
+ c = c0;
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == A());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.set/unord.set.cnstr/assign_init.pass.cpp b/test/std/containers/unord/unord.set/unord.set.cnstr/assign_init.pass.cpp
new file mode 100644
index 000000000000..69d19a4dac2e
--- /dev/null
+++ b/test/std/containers/unord/unord.set/unord.set.cnstr/assign_init.pass.cpp
@@ -0,0 +1,97 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// unordered_set& operator=(initializer_list<value_type> il);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef test_allocator<int> A;
+ typedef std::unordered_set<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef int P;
+ C c = {
+ P(4),
+ P(1),
+ P(2)
+ };
+ c = {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ assert(c.bucket_count() >= 5);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef min_allocator<int> A;
+ typedef std::unordered_set<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef int P;
+ C c = {
+ P(4),
+ P(1),
+ P(2)
+ };
+ c = {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ assert(c.bucket_count() >= 5);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/containers/unord/unord.set/unord.set.cnstr/assign_move.pass.cpp b/test/std/containers/unord/unord.set/unord.set.cnstr/assign_move.pass.cpp
new file mode 100644
index 000000000000..e8712b7431c4
--- /dev/null
+++ b/test/std/containers/unord/unord.set/unord.set.cnstr/assign_move.pass.cpp
@@ -0,0 +1,225 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// unordered_set& operator=(unordered_set&& u);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef test_allocator<int> A;
+ typedef std::unordered_set<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A(10)
+ );
+ C c(a, a + 2,
+ 7,
+ test_hash<std::hash<int> >(2),
+ test_compare<std::equal_to<int> >(3),
+ A(4)
+ );
+ c = std::move(c0);
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == A(4));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+ {
+ typedef test_allocator<int> A;
+ typedef std::unordered_set<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A(10)
+ );
+ C c(a, a + 2,
+ 7,
+ test_hash<std::hash<int> >(2),
+ test_compare<std::equal_to<int> >(3),
+ A(10)
+ );
+ c = std::move(c0);
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == A(10));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+ {
+ typedef other_allocator<int> A;
+ typedef std::unordered_set<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A(10)
+ );
+ C c(a, a + 2,
+ 7,
+ test_hash<std::hash<int> >(2),
+ test_compare<std::equal_to<int> >(3),
+ A(4)
+ );
+ c = std::move(c0);
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == A(10));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef min_allocator<int> A;
+ typedef std::unordered_set<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A()
+ );
+ C c(a, a + 2,
+ 7,
+ test_hash<std::hash<int> >(2),
+ test_compare<std::equal_to<int> >(3),
+ A()
+ );
+ c = std::move(c0);
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == A());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::unordered_set<int> s1 = {1, 2, 3};
+ std::unordered_set<int>::iterator i = s1.begin();
+ int k = *i;
+ std::unordered_set<int> s2;
+ s2 = std::move(s1);
+ assert(*i == k);
+ s2.erase(i);
+ assert(s2.size() == 2);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/unord/unord.set/unord.set.cnstr/copy.pass.cpp b/test/std/containers/unord/unord.set/unord.set.cnstr/copy.pass.cpp
new file mode 100644
index 000000000000..ee05acd6be90
--- /dev/null
+++ b/test/std/containers/unord/unord.set/unord.set.cnstr/copy.pass.cpp
@@ -0,0 +1,147 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// unordered_set(const unordered_set& u);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_set<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<int>
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ test_allocator<int>(10)
+ );
+ C c = c0;
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == test_allocator<int>(10));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+ {
+ typedef std::unordered_set<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ other_allocator<int>
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ other_allocator<int>(10)
+ );
+ C c = c0;
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == other_allocator<int>(-2));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<int>
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ min_allocator<int>()
+ );
+ C c = c0;
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == min_allocator<int>());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.set/unord.set.cnstr/copy_alloc.pass.cpp b/test/std/containers/unord/unord.set/unord.set.cnstr/copy_alloc.pass.cpp
new file mode 100644
index 000000000000..8e1ecd8167f2
--- /dev/null
+++ b/test/std/containers/unord/unord.set/unord.set.cnstr/copy_alloc.pass.cpp
@@ -0,0 +1,107 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// unordered_set(const unordered_set& u, const allocator_type& a);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_set<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<int>
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ test_allocator<int>(10)
+ );
+ C c(c0, test_allocator<int>(5));
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == test_allocator<int>(5));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<int>
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ min_allocator<int>()
+ );
+ C c(c0, min_allocator<int>());
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == min_allocator<int>());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.set/unord.set.cnstr/default.pass.cpp b/test/std/containers/unord/unord.set/unord.set.cnstr/default.pass.cpp
new file mode 100644
index 000000000000..6efa9ed8d1de
--- /dev/null
+++ b/test/std/containers/unord/unord.set/unord.set.cnstr/default.pass.cpp
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// unordered_set();
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_set<NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ test_allocator<NotConstructible>
+ > C;
+ C c;
+ assert(c.bucket_count() == 0);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() == (test_allocator<NotConstructible>()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ min_allocator<NotConstructible>
+ > C;
+ C c;
+ assert(c.bucket_count() == 0);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() == (min_allocator<NotConstructible>()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+ {
+ std::unordered_set<int> c = {};
+ assert(c.bucket_count() == 0);
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.set/unord.set.cnstr/default_noexcept.pass.cpp b/test/std/containers/unord/unord.set/unord.set.cnstr/default_noexcept.pass.cpp
new file mode 100644
index 000000000000..f419c31c4796
--- /dev/null
+++ b/test/std/containers/unord/unord.set/unord.set.cnstr/default_noexcept.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// unordered_set()
+// noexcept(
+// is_nothrow_default_constructible<allocator_type>::value &&
+// is_nothrow_default_constructible<key_compare>::value &&
+// is_nothrow_copy_constructible<key_compare>::value);
+
+// This tests a conforming extension
+
+#include <unordered_set>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "test_allocator.h"
+#include "../../../test_hash.h"
+
+template <class T>
+struct some_comp
+{
+ typedef T value_type;
+ some_comp();
+ some_comp(const some_comp&);
+};
+
+template <class T>
+struct some_hash
+{
+ typedef T value_type;
+ some_hash();
+ some_hash(const some_hash&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::unordered_set<MoveOnly> C;
+ static_assert(std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, test_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, other_allocator<MoveOnly>> C;
+ static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_set<MoveOnly, some_hash<MoveOnly>> C;
+ static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>,
+ some_comp<MoveOnly>> C;
+ static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.set/unord.set.cnstr/dtor_noexcept.pass.cpp b/test/std/containers/unord/unord.set/unord.set.cnstr/dtor_noexcept.pass.cpp
new file mode 100644
index 000000000000..1e196b2e119e
--- /dev/null
+++ b/test/std/containers/unord/unord.set/unord.set.cnstr/dtor_noexcept.pass.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// ~unordered_set() // implied noexcept;
+
+#include <unordered_set>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "test_allocator.h"
+
+#if __has_feature(cxx_noexcept)
+
+template <class T>
+struct some_comp
+{
+ typedef T value_type;
+ ~some_comp() noexcept(false);
+};
+
+template <class T>
+struct some_hash
+{
+ typedef T value_type;
+ some_hash();
+ some_hash(const some_hash&);
+ ~some_hash() noexcept(false);
+};
+
+#endif
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::unordered_set<MoveOnly> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, test_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, other_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_set<MoveOnly, some_hash<MoveOnly>> C;
+ static_assert(!std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>,
+ some_comp<MoveOnly>> C;
+ static_assert(!std::is_nothrow_destructible<C>::value, "");
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.set/unord.set.cnstr/init.pass.cpp b/test/std/containers/unord/unord.set/unord.set.cnstr/init.pass.cpp
new file mode 100644
index 000000000000..2c31d575b635
--- /dev/null
+++ b/test/std/containers/unord/unord.set/unord.set.cnstr/init.pass.cpp
@@ -0,0 +1,163 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// unordered_set(initializer_list<value_type> il);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::unordered_set<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<int>
+ > C;
+ typedef int P;
+ C c = {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ assert(c.bucket_count() >= 5);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >());
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() == test_allocator<int>());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<int>
+ > C;
+ typedef int P;
+ C c = {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ assert(c.bucket_count() >= 5);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >());
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() == min_allocator<int>());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef int T;
+ typedef test_hash<std::hash<T>> HF;
+ typedef test_compare<std::equal_to<T>> Comp;
+ typedef test_allocator<T> A;
+ typedef std::unordered_set<T, HF, Comp, A> C;
+
+ A a(42);
+ C c({
+ T(1),
+ T(2),
+ T(3),
+ T(4),
+ T(1),
+ T(2)
+ }, 12, a);
+
+ assert(c.bucket_count() >= 12);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == HF());
+ assert(c.key_eq() == Comp());
+ assert(c.get_allocator() == a);
+ assert(!(c.get_allocator() == A()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+ {
+ typedef int T;
+ typedef test_hash<std::hash<T>> HF;
+ typedef test_compare<std::equal_to<T>> Comp;
+ typedef test_allocator<T> A;
+ typedef std::unordered_set<T, HF, Comp, A> C;
+
+ A a(42);
+ HF hf(43);
+ C c({
+ T(1),
+ T(2),
+ T(3),
+ T(4),
+ T(1),
+ T(2)
+ }, 12, hf, a);
+
+ assert(c.bucket_count() >= 12);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == hf);
+ assert(!(c.hash_function() == HF()));
+ assert(c.key_eq() == Comp());
+ assert(c.get_allocator() == a);
+ assert(!(c.get_allocator() == A()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/containers/unord/unord.set/unord.set.cnstr/init_size.pass.cpp b/test/std/containers/unord/unord.set/unord.set.cnstr/init_size.pass.cpp
new file mode 100644
index 000000000000..36dab799c789
--- /dev/null
+++ b/test/std/containers/unord/unord.set/unord.set.cnstr/init_size.pass.cpp
@@ -0,0 +1,97 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// unordered_set(initializer_list<value_type> il, size_type n);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::unordered_set<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<int>
+ > C;
+ typedef int P;
+ C c({
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ },
+ 7
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >());
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() == test_allocator<int>());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<int>
+ > C;
+ typedef int P;
+ C c({
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ },
+ 7
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >());
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() == min_allocator<int>());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/containers/unord/unord.set/unord.set.cnstr/init_size_hash.pass.cpp b/test/std/containers/unord/unord.set/unord.set.cnstr/init_size_hash.pass.cpp
new file mode 100644
index 000000000000..81af2b41bae2
--- /dev/null
+++ b/test/std/containers/unord/unord.set/unord.set.cnstr/init_size_hash.pass.cpp
@@ -0,0 +1,100 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// unordered_set(initializer_list<value_type> il, size_type n,
+// const hasher& hf);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::unordered_set<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<int>
+ > C;
+ typedef int P;
+ C c({
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ },
+ 7,
+ test_hash<std::hash<int> >(8)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() == test_allocator<int>());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<int>
+ > C;
+ typedef int P;
+ C c({
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ },
+ 7,
+ test_hash<std::hash<int> >(8)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() == min_allocator<int>());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/containers/unord/unord.set/unord.set.cnstr/init_size_hash_equal.pass.cpp b/test/std/containers/unord/unord.set/unord.set.cnstr/init_size_hash_equal.pass.cpp
new file mode 100644
index 000000000000..f35dd1afa876
--- /dev/null
+++ b/test/std/containers/unord/unord.set/unord.set.cnstr/init_size_hash_equal.pass.cpp
@@ -0,0 +1,102 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// unordered_set(initializer_list<value_type> il, size_type n,
+// const hasher& hf, const key_equal& eql);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::unordered_set<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<int>
+ > C;
+ typedef int P;
+ C c({
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ },
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == test_allocator<int>());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<int>
+ > C;
+ typedef int P;
+ C c({
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ },
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == min_allocator<int>());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/containers/unord/unord.set/unord.set.cnstr/init_size_hash_equal_allocator.pass.cpp b/test/std/containers/unord/unord.set/unord.set.cnstr/init_size_hash_equal_allocator.pass.cpp
new file mode 100644
index 000000000000..34ff62ea77b5
--- /dev/null
+++ b/test/std/containers/unord/unord.set/unord.set.cnstr/init_size_hash_equal_allocator.pass.cpp
@@ -0,0 +1,104 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// unordered_set(initializer_list<value_type> il, size_type n,
+// const hasher& hf, const key_equal& eql, const allocator_type& a);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::unordered_set<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<int>
+ > C;
+ typedef int P;
+ C c({
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ },
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ test_allocator<int>(10)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == test_allocator<int>(10));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<int>
+ > C;
+ typedef int P;
+ C c({
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ },
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ min_allocator<int>()
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == min_allocator<int>());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/containers/unord/unord.set/unord.set.cnstr/move.pass.cpp b/test/std/containers/unord/unord.set/unord.set.cnstr/move.pass.cpp
new file mode 100644
index 000000000000..6bda4afc99cf
--- /dev/null
+++ b/test/std/containers/unord/unord.set/unord.set.cnstr/move.pass.cpp
@@ -0,0 +1,194 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// unordered_set(unordered_set&& u);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::unordered_set<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<int>
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c0(7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ test_allocator<int>(10)
+ );
+ C c = std::move(c0);
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 0);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == test_allocator<int>(10));
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+
+ assert(c0.empty());
+ }
+ {
+ typedef std::unordered_set<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<int>
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ test_allocator<int>(10)
+ );
+ C c = std::move(c0);
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == test_allocator<int>(10));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+
+ assert(c0.empty());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<int>
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c0(7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ min_allocator<int>()
+ );
+ C c = std::move(c0);
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 0);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == min_allocator<int>());
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+
+ assert(c0.empty());
+ }
+ {
+ typedef std::unordered_set<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<int>
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ min_allocator<int>()
+ );
+ C c = std::move(c0);
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == min_allocator<int>());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+
+ assert(c0.empty());
+ }
+#endif
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::unordered_set<int> s1 = {1, 2, 3};
+ std::unordered_set<int>::iterator i = s1.begin();
+ int k = *i;
+ std::unordered_set<int> s2 = std::move(s1);
+ assert(*i == k);
+ s2.erase(i);
+ assert(s2.size() == 2);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/unord/unord.set/unord.set.cnstr/move_alloc.pass.cpp b/test/std/containers/unord/unord.set/unord.set.cnstr/move_alloc.pass.cpp
new file mode 100644
index 000000000000..229e79925f23
--- /dev/null
+++ b/test/std/containers/unord/unord.set/unord.set.cnstr/move_alloc.pass.cpp
@@ -0,0 +1,156 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// unordered_set(unordered_set&& u, const allocator_type& a);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef int P;
+ typedef test_allocator<int> A;
+ typedef std::unordered_set<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A(10)
+ );
+ C c(std::move(c0), A(12));
+ assert(c.bucket_count() >= 5);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == A(12));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+
+ assert(c0.empty());
+ }
+ {
+ typedef int P;
+ typedef test_allocator<int> A;
+ typedef std::unordered_set<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A(10)
+ );
+ C c(std::move(c0), A(10));
+ assert(c.bucket_count() >= 5);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == A(10));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+
+ assert(c0.empty());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int P;
+ typedef min_allocator<int> A;
+ typedef std::unordered_set<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A()
+ );
+ C c(std::move(c0), A());
+ assert(c.bucket_count() >= 5);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == A());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+
+ assert(c0.empty());
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/unord/unord.set/unord.set.cnstr/move_assign_noexcept.pass.cpp b/test/std/containers/unord/unord.set/unord.set.cnstr/move_assign_noexcept.pass.cpp
new file mode 100644
index 000000000000..02af34d8f885
--- /dev/null
+++ b/test/std/containers/unord/unord.set/unord.set.cnstr/move_assign_noexcept.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// unordered_set& operator=(unordered_set&& c)
+// noexcept(
+// allocator_type::propagate_on_container_move_assignment::value &&
+// is_nothrow_move_assignable<allocator_type>::value &&
+// is_nothrow_move_assignable<key_compare>::value);
+
+// This tests a conforming extension
+
+#include <unordered_set>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_comp
+{
+ typedef T value_type;
+ some_comp& operator=(const some_comp&);
+};
+
+template <class T>
+struct some_hash
+{
+ typedef T value_type;
+ some_hash();
+ some_hash(const some_hash&);
+ some_hash& operator=(const some_hash&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::unordered_set<MoveOnly> C;
+ static_assert(std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, test_allocator<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, other_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::unordered_set<MoveOnly, some_hash<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>,
+ some_comp<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.set/unord.set.cnstr/move_noexcept.pass.cpp b/test/std/containers/unord/unord.set/unord.set.cnstr/move_noexcept.pass.cpp
new file mode 100644
index 000000000000..b2d89ba5c33b
--- /dev/null
+++ b/test/std/containers/unord/unord.set/unord.set.cnstr/move_noexcept.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// unordered_set(unordered_set&&)
+// noexcept(is_nothrow_move_constructible<allocator_type>::value &&
+// is_nothrow_move_constructible<key_compare>::value);
+
+// This tests a conforming extension
+
+#include <unordered_set>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_comp
+{
+ typedef T value_type;
+ some_comp(const some_comp&);
+};
+
+template <class T>
+struct some_hash
+{
+ typedef T value_type;
+ some_hash();
+ some_hash(const some_hash&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::unordered_set<MoveOnly> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, test_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, other_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_set<MoveOnly, some_hash<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>,
+ some_comp<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_constructible<C>::value, "");
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.set/unord.set.cnstr/range.pass.cpp b/test/std/containers/unord/unord.set/unord.set.cnstr/range.pass.cpp
new file mode 100644
index 000000000000..40f3f4f4d7f9
--- /dev/null
+++ b/test/std/containers/unord/unord.set/unord.set.cnstr/range.pass.cpp
@@ -0,0 +1,168 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// template <class InputIterator>
+// unordered_set(InputIterator first, InputIterator last);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "test_iterators.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_set<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<int>
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])));
+ assert(c.bucket_count() >= 5);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >());
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() == test_allocator<int>());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<int>
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])));
+ assert(c.bucket_count() >= 5);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >());
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() == min_allocator<int>());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef int T;
+ typedef test_hash<std::hash<T>> HF;
+ typedef test_compare<std::equal_to<T>> Comp;
+ typedef test_allocator<T> A;
+ typedef std::unordered_set<T, HF, Comp, A> C;
+ T arr[] =
+ {
+ T(1),
+ T(2),
+ T(3),
+ T(4),
+ T(1),
+ T(2)
+ };
+ A a(42);
+ C c(input_iterator<T*>(arr), input_iterator<T*>(arr + sizeof(arr)/sizeof(arr[0])), 12, a);
+ assert(c.bucket_count() >= 12);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == HF());
+ assert(c.key_eq() == Comp());
+ assert(c.get_allocator() == a);
+ assert(!(c.get_allocator() == A()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+ {
+ typedef int T;
+ typedef test_hash<std::hash<T>> HF;
+ typedef test_compare<std::equal_to<T>> Comp;
+ typedef test_allocator<T> A;
+ typedef std::unordered_set<T, HF, Comp, A> C;
+ T arr[] =
+ {
+ T(1),
+ T(2),
+ T(3),
+ T(4),
+ T(1),
+ T(2)
+ };
+ HF hf(43);
+ A a(42);
+ C c(input_iterator<T*>(arr), input_iterator<T*>(arr + sizeof(arr)/sizeof(arr[0])), 16, hf, a);
+ assert(c.bucket_count() >= 16);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == hf);
+ assert(!(c.hash_function() == HF()));
+ assert(c.key_eq() == Comp());
+ assert(c.get_allocator() == a);
+ assert(!(c.get_allocator() == A()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+
+#endif
+#endif
+}
diff --git a/test/std/containers/unord/unord.set/unord.set.cnstr/range_size.pass.cpp b/test/std/containers/unord/unord.set/unord.set.cnstr/range_size.pass.cpp
new file mode 100644
index 000000000000..179f73d7e184
--- /dev/null
+++ b/test/std/containers/unord/unord.set/unord.set.cnstr/range_size.pass.cpp
@@ -0,0 +1,101 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// template <class InputIterator>
+// unordered_set(InputIterator first, InputIterator last, size_type n);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "test_iterators.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_set<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<int>
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+ 7
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >());
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() == test_allocator<int>());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<int>
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+ 7
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >());
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() == min_allocator<int>());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.set/unord.set.cnstr/range_size_hash.pass.cpp b/test/std/containers/unord/unord.set/unord.set.cnstr/range_size_hash.pass.cpp
new file mode 100644
index 000000000000..60350de962c7
--- /dev/null
+++ b/test/std/containers/unord/unord.set/unord.set.cnstr/range_size_hash.pass.cpp
@@ -0,0 +1,104 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// template <class InputIterator>
+// unordered_set(InputIterator first, InputIterator last, size_type n,
+// const hasher& hf);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "test_iterators.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_set<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<int>
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+ 7,
+ test_hash<std::hash<int> >(8)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() == test_allocator<int>());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<int>
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+ 7,
+ test_hash<std::hash<int> >(8)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() == min_allocator<int>());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.set/unord.set.cnstr/range_size_hash_equal.pass.cpp b/test/std/containers/unord/unord.set/unord.set.cnstr/range_size_hash_equal.pass.cpp
new file mode 100644
index 000000000000..70e82d034647
--- /dev/null
+++ b/test/std/containers/unord/unord.set/unord.set.cnstr/range_size_hash_equal.pass.cpp
@@ -0,0 +1,106 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// template <class InputIterator>
+// unordered_set(InputIterator first, InputIterator last, size_type n,
+// const hasher& hf, const key_equal& eql);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "test_iterators.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_set<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<int>
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == test_allocator<int>());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<int>
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == min_allocator<int>());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.set/unord.set.cnstr/range_size_hash_equal_allocator.pass.cpp b/test/std/containers/unord/unord.set/unord.set.cnstr/range_size_hash_equal_allocator.pass.cpp
new file mode 100644
index 000000000000..a6fb2e667ae1
--- /dev/null
+++ b/test/std/containers/unord/unord.set/unord.set.cnstr/range_size_hash_equal_allocator.pass.cpp
@@ -0,0 +1,109 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// template <class InputIterator>
+// unordered_set(InputIterator first, InputIterator last, size_type n,
+// const hasher& hf, const key_equal& eql,
+// const allocator_type& a);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "test_iterators.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_set<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<int>
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ test_allocator<int>(10)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == test_allocator<int>(10));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<int>
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ min_allocator<int>()
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == min_allocator<int>());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.set/unord.set.cnstr/size.fail.cpp b/test/std/containers/unord/unord.set/unord.set.cnstr/size.fail.cpp
new file mode 100644
index 000000000000..389c54c58cde
--- /dev/null
+++ b/test/std/containers/unord/unord.set/unord.set.cnstr/size.fail.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// explicit unordered_set(size_type n);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_set<NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ test_allocator<NotConstructible>
+ > C;
+ C c = 7;
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() == (test_allocator<NotConstructible>()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+}
diff --git a/test/std/containers/unord/unord.set/unord.set.cnstr/size.pass.cpp b/test/std/containers/unord/unord.set/unord.set.cnstr/size.pass.cpp
new file mode 100644
index 000000000000..8f6228ad8ec4
--- /dev/null
+++ b/test/std/containers/unord/unord.set/unord.set.cnstr/size.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// explicit unordered_set(size_type n);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_set<NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ test_allocator<NotConstructible>
+ > C;
+ C c(7);
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() == (test_allocator<NotConstructible>()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ min_allocator<NotConstructible>
+ > C;
+ C c(7);
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() == (min_allocator<NotConstructible>()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.set/unord.set.cnstr/size_hash.pass.cpp b/test/std/containers/unord/unord.set/unord.set.cnstr/size_hash.pass.cpp
new file mode 100644
index 000000000000..4c2c18edd1ce
--- /dev/null
+++ b/test/std/containers/unord/unord.set/unord.set.cnstr/size_hash.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// unordered_set(size_type n, const hasher& hf);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_set<NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ test_allocator<NotConstructible>
+ > C;
+ C c(7,
+ test_hash<std::hash<NotConstructible> >(8)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() == (test_allocator<NotConstructible>()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ min_allocator<NotConstructible>
+ > C;
+ C c(7,
+ test_hash<std::hash<NotConstructible> >(8)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() == (min_allocator<NotConstructible>()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.set/unord.set.cnstr/size_hash_equal.pass.cpp b/test/std/containers/unord/unord.set/unord.set.cnstr/size_hash_equal.pass.cpp
new file mode 100644
index 000000000000..e9368782ad9a
--- /dev/null
+++ b/test/std/containers/unord/unord.set/unord.set.cnstr/size_hash_equal.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// unordered_set(size_type n, const hasher& hf, const key_equal& eql);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_set<NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ test_allocator<NotConstructible>
+ > C;
+ C c(7,
+ test_hash<std::hash<NotConstructible> >(8),
+ test_compare<std::equal_to<NotConstructible> >(9)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >(9));
+ assert(c.get_allocator() == (test_allocator<NotConstructible>()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ min_allocator<NotConstructible>
+ > C;
+ C c(7,
+ test_hash<std::hash<NotConstructible> >(8),
+ test_compare<std::equal_to<NotConstructible> >(9)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >(9));
+ assert(c.get_allocator() == (min_allocator<NotConstructible>()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.set/unord.set.cnstr/size_hash_equal_allocator.pass.cpp b/test/std/containers/unord/unord.set/unord.set.cnstr/size_hash_equal_allocator.pass.cpp
new file mode 100644
index 000000000000..96233e187af5
--- /dev/null
+++ b/test/std/containers/unord/unord.set/unord.set.cnstr/size_hash_equal_allocator.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// unordered_set(size_type n, const hasher& hf, const key_equal& eql, const allocator_type& a);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_set<NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ test_allocator<NotConstructible>
+ > C;
+ C c(7,
+ test_hash<std::hash<NotConstructible> >(8),
+ test_compare<std::equal_to<NotConstructible> >(9),
+ test_allocator<NotConstructible>(10)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >(9));
+ assert(c.get_allocator() == (test_allocator<NotConstructible>(10)));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ min_allocator<NotConstructible>
+ > C;
+ C c(7,
+ test_hash<std::hash<NotConstructible> >(8),
+ test_compare<std::equal_to<NotConstructible> >(9),
+ min_allocator<NotConstructible>()
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >(9));
+ assert(c.get_allocator() == (min_allocator<NotConstructible>()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.set/unord.set.swap/db_swap_1.pass.cpp b/test/std/containers/unord/unord.set/unord.set.swap/db_swap_1.pass.cpp
new file mode 100644
index 000000000000..2e8250ef783a
--- /dev/null
+++ b/test/std/containers/unord/unord.set/unord.set.swap/db_swap_1.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// void swap(unordered_set& x, unordered_set& y);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_set>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_DEBUG >= 1
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ std::unordered_set<int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ std::unordered_set<int> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+ std::unordered_set<int>::iterator i1 = c1.begin();
+ std::unordered_set<int>::iterator i2 = c2.begin();
+ swap(c1, c2);
+ c1.erase(i2);
+ c2.erase(i1);
+ std::unordered_set<int>::iterator j = i1;
+ c1.erase(i1);
+ assert(false);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.set/unord.set.swap/swap_noexcept.pass.cpp b/test/std/containers/unord/unord.set/unord.set.swap/swap_noexcept.pass.cpp
new file mode 100644
index 000000000000..5d746407a80c
--- /dev/null
+++ b/test/std/containers/unord/unord.set/unord.set.swap/swap_noexcept.pass.cpp
@@ -0,0 +1,198 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// void swap(unordered_set& c)
+// noexcept(
+// (!allocator_type::propagate_on_container_swap::value ||
+// __is_nothrow_swappable<allocator_type>::value) &&
+// __is_nothrow_swappable<hasher>::value &&
+// __is_nothrow_swappable<key_equal>::value);
+//
+// In C++17, the standard says that swap shall have:
+// noexcept(allocator_traits<Allocator>::is_always_equal::value &&
+// noexcept(swap(declval<Hash&>(), declval<Hash&>())) &&
+// noexcept(swap(declval<Pred&>(), declval<Pred&>())));
+
+// This tests a conforming extension
+
+#include <unordered_set>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_comp
+{
+ typedef T value_type;
+
+ some_comp() {}
+ some_comp(const some_comp&) {}
+};
+
+template <class T>
+struct some_comp2
+{
+ typedef T value_type;
+
+ some_comp2() {}
+ some_comp2(const some_comp2&) {}
+ void deallocate(void*, unsigned) {}
+ typedef std::true_type propagate_on_container_swap;
+};
+
+#if TEST_STD_VER >= 14
+template <typename T>
+void swap(some_comp2<T>&, some_comp2<T>&) noexcept {}
+#endif
+
+template <class T>
+struct some_hash
+{
+ typedef T value_type;
+ some_hash() {}
+ some_hash(const some_hash&);
+};
+
+template <class T>
+struct some_hash2
+{
+ typedef T value_type;
+ some_hash2() {}
+ some_hash2(const some_hash2&);
+};
+
+#if TEST_STD_VER >= 14
+template <typename T>
+void swap(some_hash2<T>&, some_hash2<T>&) noexcept {}
+#endif
+
+template <class T>
+struct some_alloc
+{
+ typedef T value_type;
+
+ some_alloc() {}
+ some_alloc(const some_alloc&);
+ void deallocate(void*, unsigned) {}
+
+ typedef std::true_type propagate_on_container_swap;
+};
+
+template <class T>
+struct some_alloc2
+{
+ typedef T value_type;
+
+ some_alloc2() {}
+ some_alloc2(const some_alloc2&);
+ void deallocate(void*, unsigned) {}
+
+ typedef std::false_type propagate_on_container_swap;
+ typedef std::true_type is_always_equal;
+};
+
+template <class T>
+struct some_alloc3
+{
+ typedef T value_type;
+
+ some_alloc3() {}
+ some_alloc3(const some_alloc3&);
+ void deallocate(void*, unsigned) {}
+
+ typedef std::false_type propagate_on_container_swap;
+ typedef std::false_type is_always_equal;
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::unordered_set<MoveOnly> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, test_allocator<MoveOnly>> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, other_allocator<MoveOnly>> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::unordered_set<MoveOnly, some_hash<MoveOnly>> C;
+ C c1, c2;
+ static_assert(!noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>,
+ some_comp<MoveOnly>> C;
+ C c1, c2;
+ static_assert(!noexcept(swap(c1, c2)), "");
+ }
+
+#if TEST_STD_VER >= 14
+ { // POCS allocator, throwable swap for hash, throwable swap for comp
+ typedef std::unordered_set<MoveOnly, some_hash<MoveOnly>, some_comp <MoveOnly>, some_alloc <MoveOnly>> C;
+ C c1, c2;
+ static_assert(!noexcept(swap(c1, c2)), "");
+ }
+ { // always equal allocator, throwable swap for hash, throwable swap for comp
+ typedef std::unordered_set<MoveOnly, some_hash<MoveOnly>, some_comp <MoveOnly>, some_alloc2<MoveOnly>> C;
+ C c1, c2;
+ static_assert(!noexcept(swap(c1, c2)), "");
+ }
+ { // POCS allocator, throwable swap for hash, nothrow swap for comp
+ typedef std::unordered_set<MoveOnly, some_hash<MoveOnly>, some_comp2<MoveOnly>, some_alloc <MoveOnly>> C;
+ C c1, c2;
+ static_assert(!noexcept(swap(c1, c2)), "");
+ }
+ { // always equal allocator, throwable swap for hash, nothrow swap for comp
+ typedef std::unordered_set<MoveOnly, some_hash<MoveOnly>, some_comp2<MoveOnly>, some_alloc2<MoveOnly>> C;
+ C c1, c2;
+ static_assert(!noexcept(swap(c1, c2)), "");
+ }
+ { // POCS allocator, nothrow swap for hash, throwable swap for comp
+ typedef std::unordered_set<MoveOnly, some_hash2<MoveOnly>, some_comp <MoveOnly>, some_alloc <MoveOnly>> C;
+ C c1, c2;
+ static_assert(!noexcept(swap(c1, c2)), "");
+ }
+ { // always equal allocator, nothrow swap for hash, throwable swap for comp
+ typedef std::unordered_set<MoveOnly, some_hash2<MoveOnly>, some_comp <MoveOnly>, some_alloc2<MoveOnly>> C;
+ C c1, c2;
+ static_assert(!noexcept(swap(c1, c2)), "");
+ }
+ { // POCS allocator, nothrow swap for hash, nothrow swap for comp
+ typedef std::unordered_set<MoveOnly, some_hash2<MoveOnly>, some_comp2<MoveOnly>, some_alloc <MoveOnly>> C;
+ C c1, c2;
+ static_assert( noexcept(swap(c1, c2)), "");
+ }
+ { // always equal allocator, nothrow swap for hash, nothrow swap for comp
+ typedef std::unordered_set<MoveOnly, some_hash2<MoveOnly>, some_comp2<MoveOnly>, some_alloc2<MoveOnly>> C;
+ C c1, c2;
+ static_assert( noexcept(swap(c1, c2)), "");
+ }
+
+ { // NOT always equal allocator, nothrow swap for hash, nothrow swap for comp
+ typedef std::unordered_set<MoveOnly, some_hash2<MoveOnly>, some_comp2<MoveOnly>, some_alloc3<MoveOnly>> C;
+ C c1, c2;
+ static_assert( noexcept(swap(c1, c2)), "");
+ }
+#endif
+
+#endif
+}
diff --git a/test/std/containers/unord/unord.set/unord.set.swap/swap_non_member.pass.cpp b/test/std/containers/unord/unord.set/unord.set.swap/swap_non_member.pass.cpp
new file mode 100644
index 000000000000..7415e2977716
--- /dev/null
+++ b/test/std/containers/unord/unord.set/unord.set.swap/swap_non_member.pass.cpp
@@ -0,0 +1,571 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// void swap(unordered_set& x, unordered_set& y);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef test_allocator<int> Alloc;
+ typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ C c1(0, Hash(1), Compare(1), Alloc(1));
+ C c2(0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(1));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(2));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef test_allocator<int> Alloc;
+ typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ P a2[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ C c1(0, Hash(1), Compare(1), Alloc(1));
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(*c1.find(10) == 10);
+ assert(*c1.find(20) == 20);
+ assert(*c1.find(30) == 30);
+ assert(*c1.find(40) == 40);
+ assert(*c1.find(50) == 50);
+ assert(*c1.find(60) == 60);
+ assert(*c1.find(70) == 70);
+ assert(*c1.find(80) == 80);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(1));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(2));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef test_allocator<int> Alloc;
+ typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ P a1[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+ C c2(0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(1));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 5);
+ assert(c2.size() == 4);
+ assert(c2.count(1) == 1);
+ assert(c2.count(2) == 1);
+ assert(c2.count(3) == 1);
+ assert(c2.count(4) == 1);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(2));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef test_allocator<int> Alloc;
+ typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ P a1[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ P a2[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(*c1.find(10) == 10);
+ assert(*c1.find(20) == 20);
+ assert(*c1.find(30) == 30);
+ assert(*c1.find(40) == 40);
+ assert(*c1.find(50) == 50);
+ assert(*c1.find(60) == 60);
+ assert(*c1.find(70) == 70);
+ assert(*c1.find(80) == 80);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(1));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 5);
+ assert(c2.size() == 4);
+ assert(c2.count(1) == 1);
+ assert(c2.count(2) == 1);
+ assert(c2.count(3) == 1);
+ assert(c2.count(4) == 1);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(2));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef other_allocator<int> Alloc;
+ typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ C c1(0, Hash(1), Compare(1), Alloc(1));
+ C c2(0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(2));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(1));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef other_allocator<int> Alloc;
+ typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ P a2[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ C c1(0, Hash(1), Compare(1), Alloc(1));
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(*c1.find(10) == 10);
+ assert(*c1.find(20) == 20);
+ assert(*c1.find(30) == 30);
+ assert(*c1.find(40) == 40);
+ assert(*c1.find(50) == 50);
+ assert(*c1.find(60) == 60);
+ assert(*c1.find(70) == 70);
+ assert(*c1.find(80) == 80);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(2));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(1));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef other_allocator<int> Alloc;
+ typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ P a1[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+ C c2(0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(2));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 5);
+ assert(c2.size() == 4);
+ assert(c2.count(1) == 1);
+ assert(c2.count(2) == 1);
+ assert(c2.count(3) == 1);
+ assert(c2.count(4) == 1);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(1));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef other_allocator<int> Alloc;
+ typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ P a1[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ P a2[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(*c1.find(10) == 10);
+ assert(*c1.find(20) == 20);
+ assert(*c1.find(30) == 30);
+ assert(*c1.find(40) == 40);
+ assert(*c1.find(50) == 50);
+ assert(*c1.find(60) == 60);
+ assert(*c1.find(70) == 70);
+ assert(*c1.find(80) == 80);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(2));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 5);
+ assert(c2.size() == 4);
+ assert(c2.count(1) == 1);
+ assert(c2.count(2) == 1);
+ assert(c2.count(3) == 1);
+ assert(c2.count(4) == 1);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(1));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef min_allocator<int> Alloc;
+ typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ C c1(0, Hash(1), Compare(1), Alloc());
+ C c2(0, Hash(2), Compare(2), Alloc());
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc());
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc());
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef min_allocator<int> Alloc;
+ typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ P a2[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ C c1(0, Hash(1), Compare(1), Alloc());
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc());
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(*c1.find(10) == 10);
+ assert(*c1.find(20) == 20);
+ assert(*c1.find(30) == 30);
+ assert(*c1.find(40) == 40);
+ assert(*c1.find(50) == 50);
+ assert(*c1.find(60) == 60);
+ assert(*c1.find(70) == 70);
+ assert(*c1.find(80) == 80);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc());
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc());
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef min_allocator<int> Alloc;
+ typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ P a1[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc());
+ C c2(0, Hash(2), Compare(2), Alloc());
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc());
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 5);
+ assert(c2.size() == 4);
+ assert(c2.count(1) == 1);
+ assert(c2.count(2) == 1);
+ assert(c2.count(3) == 1);
+ assert(c2.count(4) == 1);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc());
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef min_allocator<int> Alloc;
+ typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ P a1[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ P a2[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc());
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc());
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(*c1.find(10) == 10);
+ assert(*c1.find(20) == 20);
+ assert(*c1.find(30) == 30);
+ assert(*c1.find(40) == 40);
+ assert(*c1.find(50) == 50);
+ assert(*c1.find(60) == 60);
+ assert(*c1.find(70) == 70);
+ assert(*c1.find(80) == 80);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc());
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 5);
+ assert(c2.size() == 4);
+ assert(c2.count(1) == 1);
+ assert(c2.count(2) == 1);
+ assert(c2.count(3) == 1);
+ assert(c2.count(4) == 1);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc());
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/test/std/containers/unord/unord.set/version.pass.cpp b/test/std/containers/unord/unord.set/version.pass.cpp
new file mode 100644
index 000000000000..d651ebdfc456
--- /dev/null
+++ b/test/std/containers/unord/unord.set/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+#include <unordered_set>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/depr/depr.auto.ptr/auto.ptr/A.h b/test/std/depr/depr.auto.ptr/auto.ptr/A.h
new file mode 100644
index 000000000000..cc16abe06d72
--- /dev/null
+++ b/test/std/depr/depr.auto.ptr/auto.ptr/A.h
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef A_H
+#define A_H
+
+#include <cassert>
+
+class A
+{
+ int id_;
+public:
+ explicit A(int id) : id_(id) {++count;}
+ A(const A& a) : id_(a.id_) {++count;}
+ ~A() {assert(id_ >= 0); id_ = -1; --count;}
+
+ int id() const {return id_;}
+
+ static int count;
+};
+
+int A::count = 0;
+
+#endif // A_H
diff --git a/test/std/depr/depr.auto.ptr/auto.ptr/AB.h b/test/std/depr/depr.auto.ptr/auto.ptr/AB.h
new file mode 100644
index 000000000000..b7ec9882a050
--- /dev/null
+++ b/test/std/depr/depr.auto.ptr/auto.ptr/AB.h
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef AB_H
+#define AB_H
+
+#include <cassert>
+
+class A
+{
+ int id_;
+public:
+ explicit A(int id) : id_(id) {++count;}
+ A(const A& a) : id_(a.id_) {++count;}
+ virtual ~A() {assert(id_ >= 0); id_ = -1; --count;}
+
+ static int count;
+};
+
+int A::count = 0;
+
+class B
+ : public A
+{
+public:
+ explicit B(int id) : A(id) {++count;}
+ B(const B& a) : A(a) {++count;}
+ virtual ~B() {--count;}
+
+ static int count;
+};
+
+int B::count = 0;
+
+#endif // AB_H
diff --git a/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/assignment.fail.cpp b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/assignment.fail.cpp
new file mode 100644
index 000000000000..88f0904abb3b
--- /dev/null
+++ b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/assignment.fail.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class X> class auto_ptr;
+
+// auto_ptr& operator=(auto_ptr& a) throw();
+
+#include <memory>
+#include <cassert>
+
+#include "../A.h"
+
+void
+test()
+{
+ {
+ A* p1 = new A(1);
+ const std::auto_ptr<A> ap1(p1);
+ A* p2 = new A(2);
+ std::auto_ptr<A> ap2(p2);
+ assert(A::count == 2);
+ assert(ap1.get() == p1);
+ assert(ap2.get() == p2);
+ std::auto_ptr<A>& apr = ap2 = ap1;
+ assert(&apr == &ap2);
+ assert(A::count == 1);
+ assert(ap1.get() == 0);
+ assert(ap2.get() == p1);
+ }
+ assert(A::count == 0);
+}
+
+int main()
+{
+ test();
+}
diff --git a/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/assignment.pass.cpp b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/assignment.pass.cpp
new file mode 100644
index 000000000000..2c6acb5af12c
--- /dev/null
+++ b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/assignment.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class X> class auto_ptr;
+
+// auto_ptr& operator=(auto_ptr& a) throw();
+
+#include <memory>
+#include <cassert>
+
+#include "../A.h"
+
+void
+test()
+{
+ {
+ A* p1 = new A(1);
+ std::auto_ptr<A> ap1(p1);
+ A* p2 = new A(2);
+ std::auto_ptr<A> ap2(p2);
+ assert(A::count == 2);
+ assert(ap1.get() == p1);
+ assert(ap2.get() == p2);
+ std::auto_ptr<A>& apr = ap2 = ap1;
+ assert(&apr == &ap2);
+ assert(A::count == 1);
+ assert(ap1.get() == 0);
+ assert(ap2.get() == p1);
+ }
+ assert(A::count == 0);
+}
+
+int main()
+{
+ test();
+}
diff --git a/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert.fail.cpp b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert.fail.cpp
new file mode 100644
index 000000000000..d5f38c1e22b4
--- /dev/null
+++ b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert.fail.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class X> class auto_ptr;
+
+// auto_ptr(auto_ptr& a) throw();
+
+#include <memory>
+#include <cassert>
+
+#include "../AB.h"
+
+void
+test()
+{
+ {
+ B* p = new B(1);
+ const std::auto_ptr<B> ap1(p);
+ std::auto_ptr<A> ap2(ap1);
+ assert(ap1.get() == 0);
+ assert(ap2.get() == p);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
+
+int main()
+{
+ test();
+}
diff --git a/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert.pass.cpp b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert.pass.cpp
new file mode 100644
index 000000000000..aeea7dec9e34
--- /dev/null
+++ b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class X> class auto_ptr;
+
+// auto_ptr(auto_ptr& a) throw();
+
+#include <memory>
+#include <cassert>
+
+#include "../AB.h"
+
+void
+test()
+{
+ {
+ B* p = new B(1);
+ std::auto_ptr<B> ap1(p);
+ std::auto_ptr<A> ap2(ap1);
+ assert(ap1.get() == 0);
+ assert(ap2.get() == p);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
+
+int main()
+{
+ test();
+}
diff --git a/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert_assignment.fail.cpp b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert_assignment.fail.cpp
new file mode 100644
index 000000000000..be95d2c19de8
--- /dev/null
+++ b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert_assignment.fail.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class X> class auto_ptr;
+
+// template<class Y> auto_ptr& operator=(auto_ptr<Y>& a) throw();
+
+#include <memory>
+#include <cassert>
+
+#include "../AB.h"
+
+void
+test()
+{
+ {
+ B* p1 = new B(1);
+ const std::auto_ptr<B> ap1(p1);
+ A* p2 = new A(2);
+ std::auto_ptr<A> ap2(p2);
+ assert(A::count == 2);
+ assert(B::count == 1);
+ assert(ap1.get() == p1);
+ assert(ap2.get() == p2);
+ std::auto_ptr<A>& apr = ap2 = ap1;
+ assert(&apr == &ap2);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ assert(ap1.get() == 0);
+ assert(ap2.get() == p1);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
+
+int main()
+{
+ test();
+}
diff --git a/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert_assignment.pass.cpp b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert_assignment.pass.cpp
new file mode 100644
index 000000000000..6809073c2d0c
--- /dev/null
+++ b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert_assignment.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class X> class auto_ptr;
+
+// template<class Y> auto_ptr& operator=(auto_ptr<Y>& a) throw();
+
+#include <memory>
+#include <cassert>
+
+#include "../AB.h"
+
+void
+test()
+{
+ {
+ B* p1 = new B(1);
+ std::auto_ptr<B> ap1(p1);
+ A* p2 = new A(2);
+ std::auto_ptr<A> ap2(p2);
+ assert(A::count == 2);
+ assert(B::count == 1);
+ assert(ap1.get() == p1);
+ assert(ap2.get() == p2);
+ std::auto_ptr<A>& apr = ap2 = ap1;
+ assert(&apr == &ap2);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ assert(ap1.get() == 0);
+ assert(ap2.get() == p1);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
+
+int main()
+{
+ test();
+}
diff --git a/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/copy.fail.cpp b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/copy.fail.cpp
new file mode 100644
index 000000000000..78423e518ba2
--- /dev/null
+++ b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/copy.fail.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class X> class auto_ptr;
+
+// auto_ptr(auto_ptr& a) throw();
+
+#include <memory>
+#include <cassert>
+
+#include "../A.h"
+
+void
+test()
+{
+ {
+ A* p = new A(1);
+ const std::auto_ptr<A> ap1(p);
+ std::auto_ptr<A> ap2(ap1);
+ assert(ap1.get() == 0);
+ assert(ap2.get() == p);
+ assert(A::count == 1);
+ }
+ assert(A::count == 0);
+}
+
+int main()
+{
+ test();
+}
diff --git a/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/copy.pass.cpp b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/copy.pass.cpp
new file mode 100644
index 000000000000..27ba0e513e45
--- /dev/null
+++ b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/copy.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class X> class auto_ptr;
+
+// auto_ptr(auto_ptr& a) throw();
+
+#include <memory>
+#include <cassert>
+
+#include "../A.h"
+
+void
+test()
+{
+ {
+ A* p = new A(1);
+ std::auto_ptr<A> ap1(p);
+ std::auto_ptr<A> ap2(ap1);
+ assert(ap1.get() == 0);
+ assert(ap2.get() == p);
+ assert(A::count == 1);
+ }
+ assert(A::count == 0);
+}
+
+int main()
+{
+ test();
+}
diff --git a/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/explicit.fail.cpp b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/explicit.fail.cpp
new file mode 100644
index 000000000000..54eb162f0688
--- /dev/null
+++ b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/explicit.fail.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class X> class auto_ptr;
+
+// explicit auto_ptr(X* p =0) throw();
+
+#include <memory>
+#include <cassert>
+
+#include "../A.h"
+
+void
+test()
+{
+ {
+ A* p = new A(1);
+ std::auto_ptr<A> ap = p;
+ assert(ap.get() == p);
+ assert(A::count == 1);
+ }
+ assert(A::count == 0);
+ {
+ std::auto_ptr<A> ap;
+ assert(ap.get() == 0);
+ }
+}
+
+int main()
+{
+ test();
+}
diff --git a/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/pointer.pass.cpp b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/pointer.pass.cpp
new file mode 100644
index 000000000000..e29ff2e78244
--- /dev/null
+++ b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/pointer.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class X> class auto_ptr;
+
+// explicit auto_ptr(X* p =0) throw();
+
+#include <memory>
+#include <cassert>
+
+#include "../A.h"
+
+void
+test()
+{
+ {
+ A* p = new A(1);
+ std::auto_ptr<A> ap(p);
+ assert(ap.get() == p);
+ assert(A::count == 1);
+ }
+ assert(A::count == 0);
+ {
+ std::auto_ptr<A> ap;
+ assert(ap.get() == 0);
+ }
+}
+
+int main()
+{
+ test();
+}
diff --git a/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/assign_from_auto_ptr_ref.pass.cpp b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/assign_from_auto_ptr_ref.pass.cpp
new file mode 100644
index 000000000000..6f53581af422
--- /dev/null
+++ b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/assign_from_auto_ptr_ref.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class X> class auto_ptr;
+
+// auto_ptr& operator=(auto_ptr_ref<X> r) throw()
+
+#include <memory>
+#include <cassert>
+
+#include "../A.h"
+
+void
+test()
+{
+ {
+ A* p1 = new A(1);
+ std::auto_ptr<A> ap1(p1);
+ std::auto_ptr_ref<A> apr = ap1;
+ std::auto_ptr<A> ap2(new A(2));
+ ap2 = apr;
+ assert(A::count == 1);
+ assert(ap2.get() == p1);
+ assert(ap1.get() == 0);
+ }
+ assert(A::count == 0);
+}
+
+int main()
+{
+ test();
+}
diff --git a/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_from_auto_ptr_ref.pass.cpp b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_from_auto_ptr_ref.pass.cpp
new file mode 100644
index 000000000000..375780527cf0
--- /dev/null
+++ b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_from_auto_ptr_ref.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class X> class auto_ptr;
+
+// auto_ptr(auto_ptr_ref<X> r) throw();
+
+#include <memory>
+#include <cassert>
+
+#include "../AB.h"
+
+void
+test()
+{
+ {
+ B* p1 = new B(1);
+ std::auto_ptr<B> ap1(p1);
+ std::auto_ptr_ref<A> apr = ap1;
+ std::auto_ptr<A> ap2(apr);
+ assert(ap2.get() == p1);
+ assert(ap1.get() == 0);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
+
+int main()
+{
+ test();
+}
diff --git a/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_to_auto_ptr.pass.cpp b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_to_auto_ptr.pass.cpp
new file mode 100644
index 000000000000..00c0f6d30caf
--- /dev/null
+++ b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_to_auto_ptr.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class X> class auto_ptr;
+
+// template<class Y> operator auto_ptr<Y>() throw();
+
+#include <memory>
+#include <cassert>
+
+#include "../AB.h"
+
+std::auto_ptr<B>
+source()
+{
+ return std::auto_ptr<B>(new B(1));
+}
+
+void
+test()
+{
+ std::auto_ptr<A> ap2(source());
+}
+
+int main()
+{
+ test();
+}
diff --git a/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_to_auto_ptr_ref.pass.cpp b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_to_auto_ptr_ref.pass.cpp
new file mode 100644
index 000000000000..f61a28e84d4c
--- /dev/null
+++ b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_to_auto_ptr_ref.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class X> class auto_ptr;
+
+// template<class Y> operator auto_ptr_ref<Y>() throw();
+
+#include <memory>
+#include <cassert>
+
+#include "../AB.h"
+
+void
+test()
+{
+ B* p1 = new B(1);
+ std::auto_ptr<B> ap1(p1);
+ std::auto_ptr_ref<A> apr = ap1;
+ delete p1;
+}
+
+int main()
+{
+ test();
+}
diff --git a/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/arrow.pass.cpp b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/arrow.pass.cpp
new file mode 100644
index 000000000000..fce9332df846
--- /dev/null
+++ b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/arrow.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class X> class auto_ptr;
+
+// X& operator*() const throw();
+
+#include <memory>
+#include <cassert>
+
+#include "../A.h"
+
+void
+test()
+{
+ {
+ A* p = new A(1);
+ std::auto_ptr<A> ap(p);
+ assert(ap->id() == 1);
+ *ap = A(3);
+ assert(ap->id() == 3);
+ }
+ assert(A::count == 0);
+}
+
+int main()
+{
+ test();
+}
diff --git a/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/deref.pass.cpp b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/deref.pass.cpp
new file mode 100644
index 000000000000..dd5669563e35
--- /dev/null
+++ b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/deref.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class X> class auto_ptr;
+
+// X& operator*() const throw();
+
+#include <memory>
+#include <cassert>
+
+#include "../A.h"
+
+void
+test()
+{
+ {
+ A* p = new A(1);
+ const std::auto_ptr<A> ap(p);
+ assert((*ap).id() == 1);
+ *ap = A(3);
+ assert((*ap).id() == 3);
+ }
+ assert(A::count == 0);
+}
+
+int main()
+{
+ test();
+}
diff --git a/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/release.pass.cpp b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/release.pass.cpp
new file mode 100644
index 000000000000..5860eb411143
--- /dev/null
+++ b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/release.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class X> class auto_ptr;
+
+// X* release() throw();
+
+#include <memory>
+#include <cassert>
+
+#include "../A.h"
+
+void
+test()
+{
+ {
+ A* p = new A(1);
+ std::auto_ptr<A> ap(p);
+ A* p2 = ap.release();
+ assert(p2 == p);
+ assert(ap.get() == 0);
+ delete p;
+ }
+ assert(A::count == 0);
+}
+
+int main()
+{
+ test();
+}
diff --git a/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/reset.pass.cpp b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/reset.pass.cpp
new file mode 100644
index 000000000000..cdbdd73ab72d
--- /dev/null
+++ b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/reset.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class X> class auto_ptr;
+
+// void reset(X* p=0) throw();
+
+#include <memory>
+#include <cassert>
+
+#include "../A.h"
+
+void
+test()
+{
+ {
+ A* p = new A(1);
+ std::auto_ptr<A> ap(p);
+ ap.reset();
+ assert(ap.get() == 0);
+ assert(A::count == 0);
+ }
+ assert(A::count == 0);
+ {
+ A* p = new A(1);
+ std::auto_ptr<A> ap(p);
+ ap.reset(p);
+ assert(ap.get() == p);
+ assert(A::count == 1);
+ }
+ assert(A::count == 0);
+ {
+ A* p = new A(1);
+ std::auto_ptr<A> ap(p);
+ A* p2 = new A(2);
+ ap.reset(p2);
+ assert(ap.get() == p2);
+ assert(A::count == 1);
+ }
+ assert(A::count == 0);
+}
+
+int main()
+{
+ test();
+}
diff --git a/test/std/depr/depr.auto.ptr/auto.ptr/element_type.pass.cpp b/test/std/depr/depr.auto.ptr/auto.ptr/element_type.pass.cpp
new file mode 100644
index 000000000000..2d1c2af8062d
--- /dev/null
+++ b/test/std/depr/depr.auto.ptr/auto.ptr/element_type.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class X>
+// class auto_ptr
+// {
+// public:
+// typedef X element_type;
+// ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+template <class T>
+void
+test()
+{
+ static_assert((std::is_same<typename std::auto_ptr<T>::element_type, T>::value), "");
+}
+
+int main()
+{
+ test<int>();
+ test<double>();
+ test<void>();
+ std::auto_ptr<void> p;
+}
diff --git a/test/std/depr/depr.auto.ptr/nothing_to_do.pass.cpp b/test/std/depr/depr.auto.ptr/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/depr/depr.auto.ptr/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/depr/depr.c.headers/assert_h.pass.cpp b/test/std/depr/depr.c.headers/assert_h.pass.cpp
new file mode 100644
index 000000000000..39a73467dbbc
--- /dev/null
+++ b/test/std/depr/depr.c.headers/assert_h.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test <assert.h>
+
+#include <assert.h>
+
+#ifndef assert
+#error assert not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/depr/depr.c.headers/ciso646.pass.cpp b/test/std/depr/depr.c.headers/ciso646.pass.cpp
new file mode 100644
index 000000000000..725a7ab1331b
--- /dev/null
+++ b/test/std/depr/depr.c.headers/ciso646.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ciso646>
+
+#include <ciso646>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/depr/depr.c.headers/complex.h.pass.cpp b/test/std/depr/depr.c.headers/complex.h.pass.cpp
new file mode 100644
index 000000000000..da0707990d80
--- /dev/null
+++ b/test/std/depr/depr.c.headers/complex.h.pass.cpp
@@ -0,0 +1,21 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex.h>
+
+#include <complex.h>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+ std::complex<double> d;
+}
diff --git a/test/std/depr/depr.c.headers/ctype_h.pass.cpp b/test/std/depr/depr.c.headers/ctype_h.pass.cpp
new file mode 100644
index 000000000000..042084e9853d
--- /dev/null
+++ b/test/std/depr/depr.c.headers/ctype_h.pass.cpp
@@ -0,0 +1,103 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ctype.h>
+
+#include <ctype.h>
+#include <type_traits>
+#include <cassert>
+
+#ifdef isalnum
+#error isalnum defined
+#endif
+
+#ifdef isalpha
+#error isalpha defined
+#endif
+
+#ifdef isblank
+#error isblank defined
+#endif
+
+#ifdef iscntrl
+#error iscntrl defined
+#endif
+
+#ifdef isdigit
+#error isdigit defined
+#endif
+
+#ifdef isgraph
+#error isgraph defined
+#endif
+
+#ifdef islower
+#error islower defined
+#endif
+
+#ifdef isprint
+#error isprint defined
+#endif
+
+#ifdef ispunct
+#error ispunct defined
+#endif
+
+#ifdef isspace
+#error isspace defined
+#endif
+
+#ifdef isupper
+#error isupper defined
+#endif
+
+#ifdef isxdigit
+#error isxdigit defined
+#endif
+
+#ifdef tolower
+#error tolower defined
+#endif
+
+#ifdef toupper
+#error toupper defined
+#endif
+
+int main()
+{
+ static_assert((std::is_same<decltype(isalnum(0)), int>::value), "");
+ static_assert((std::is_same<decltype(isalpha(0)), int>::value), "");
+ static_assert((std::is_same<decltype(isblank(0)), int>::value), "");
+ static_assert((std::is_same<decltype(iscntrl(0)), int>::value), "");
+ static_assert((std::is_same<decltype(isdigit(0)), int>::value), "");
+ static_assert((std::is_same<decltype(isgraph(0)), int>::value), "");
+ static_assert((std::is_same<decltype(islower(0)), int>::value), "");
+ static_assert((std::is_same<decltype(isprint(0)), int>::value), "");
+ static_assert((std::is_same<decltype(ispunct(0)), int>::value), "");
+ static_assert((std::is_same<decltype(isspace(0)), int>::value), "");
+ static_assert((std::is_same<decltype(isupper(0)), int>::value), "");
+ static_assert((std::is_same<decltype(isxdigit(0)), int>::value), "");
+ static_assert((std::is_same<decltype(tolower(0)), int>::value), "");
+ static_assert((std::is_same<decltype(toupper(0)), int>::value), "");
+
+ assert(isalnum('a'));
+ assert(isalpha('a'));
+ assert(isblank(' '));
+ assert(!iscntrl(' '));
+ assert(!isdigit('a'));
+ assert(isgraph('a'));
+ assert(islower('a'));
+ assert(isprint('a'));
+ assert(!ispunct('a'));
+ assert(!isspace('a'));
+ assert(!isupper('a'));
+ assert(isxdigit('a'));
+ assert(tolower('A') == 'a');
+ assert(toupper('a') == 'A');
+}
diff --git a/test/std/depr/depr.c.headers/errno_h.pass.cpp b/test/std/depr/depr.c.headers/errno_h.pass.cpp
new file mode 100644
index 000000000000..4d955a5b4763
--- /dev/null
+++ b/test/std/depr/depr.c.headers/errno_h.pass.cpp
@@ -0,0 +1,33 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test <errno.h>
+
+#include <errno.h>
+
+#ifndef EDOM
+#error EDOM not defined
+#endif
+
+#ifndef EILSEQ
+#error EILSEQ not defined
+#endif
+
+#ifndef ERANGE
+#error ERANGE not defined
+#endif
+
+#ifndef errno
+#error errno not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/depr/depr.c.headers/fenv_h.pass.cpp b/test/std/depr/depr.c.headers/fenv_h.pass.cpp
new file mode 100644
index 000000000000..f2fcf4914cfd
--- /dev/null
+++ b/test/std/depr/depr.c.headers/fenv_h.pass.cpp
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// XFAIL: newlib
+
+// <fenv.h>
+
+#include <fenv.h>
+#include <type_traits>
+
+#ifndef FE_DIVBYZERO
+#error FE_DIVBYZERO not defined
+#endif
+
+#ifndef FE_INEXACT
+#error FE_INEXACT not defined
+#endif
+
+#ifndef FE_INVALID
+#error FE_INVALID not defined
+#endif
+
+#ifndef FE_OVERFLOW
+#error FE_OVERFLOW not defined
+#endif
+
+#ifndef FE_UNDERFLOW
+#error FE_UNDERFLOW not defined
+#endif
+
+#ifndef FE_ALL_EXCEPT
+#error FE_ALL_EXCEPT not defined
+#endif
+
+#ifndef FE_DOWNWARD
+#error FE_DOWNWARD not defined
+#endif
+
+#ifndef FE_TONEAREST
+#error FE_TONEAREST not defined
+#endif
+
+#ifndef FE_TOWARDZERO
+#error FE_TOWARDZERO not defined
+#endif
+
+#ifndef FE_UPWARD
+#error FE_UPWARD not defined
+#endif
+
+#ifndef FE_DFL_ENV
+#error FE_DFL_ENV not defined
+#endif
+
+int main()
+{
+ fenv_t fenv = {0};
+ fexcept_t fex = 0;
+ static_assert((std::is_same<decltype(feclearexcept(0)), int>::value), "");
+ static_assert((std::is_same<decltype(fegetexceptflag(&fex, 0)), int>::value), "");
+ static_assert((std::is_same<decltype(feraiseexcept(0)), int>::value), "");
+ static_assert((std::is_same<decltype(fesetexceptflag(&fex, 0)), int>::value), "");
+ static_assert((std::is_same<decltype(fetestexcept(0)), int>::value), "");
+ static_assert((std::is_same<decltype(fegetround()), int>::value), "");
+ static_assert((std::is_same<decltype(fesetround(0)), int>::value), "");
+ static_assert((std::is_same<decltype(fegetenv(&fenv)), int>::value), "");
+ static_assert((std::is_same<decltype(feholdexcept(&fenv)), int>::value), "");
+ static_assert((std::is_same<decltype(fesetenv(&fenv)), int>::value), "");
+ static_assert((std::is_same<decltype(feupdateenv(&fenv)), int>::value), "");
+}
diff --git a/test/std/depr/depr.c.headers/float_h.pass.cpp b/test/std/depr/depr.c.headers/float_h.pass.cpp
new file mode 100644
index 000000000000..5b2e45163705
--- /dev/null
+++ b/test/std/depr/depr.c.headers/float_h.pass.cpp
@@ -0,0 +1,140 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+ // test <float.h>
+
+#include <float.h>
+
+#ifndef FLT_ROUNDS
+#error FLT_ROUNDS not defined
+#endif
+
+#ifndef FLT_EVAL_METHOD
+#error FLT_EVAL_METHOD not defined
+#endif
+
+#ifndef FLT_RADIX
+#error FLT_RADIX not defined
+#endif
+
+#ifndef FLT_MANT_DIG
+#error FLT_MANT_DIG not defined
+#endif
+
+#ifndef DBL_MANT_DIG
+#error DBL_MANT_DIG not defined
+#endif
+
+#ifndef LDBL_MANT_DIG
+#error LDBL_MANT_DIG not defined
+#endif
+
+#ifndef DECIMAL_DIG
+#error DECIMAL_DIG not defined
+#endif
+
+#ifndef FLT_DIG
+#error FLT_DIG not defined
+#endif
+
+#ifndef DBL_DIG
+#error DBL_DIG not defined
+#endif
+
+#ifndef LDBL_DIG
+#error LDBL_DIG not defined
+#endif
+
+#ifndef FLT_MIN_EXP
+#error FLT_MIN_EXP not defined
+#endif
+
+#ifndef DBL_MIN_EXP
+#error DBL_MIN_EXP not defined
+#endif
+
+#ifndef LDBL_MIN_EXP
+#error LDBL_MIN_EXP not defined
+#endif
+
+#ifndef FLT_MIN_10_EXP
+#error FLT_MIN_10_EXP not defined
+#endif
+
+#ifndef DBL_MIN_10_EXP
+#error DBL_MIN_10_EXP not defined
+#endif
+
+#ifndef LDBL_MIN_10_EXP
+#error LDBL_MIN_10_EXP not defined
+#endif
+
+#ifndef FLT_MAX_EXP
+#error FLT_MAX_EXP not defined
+#endif
+
+#ifndef DBL_MAX_EXP
+#error DBL_MAX_EXP not defined
+#endif
+
+#ifndef LDBL_MAX_EXP
+#error LDBL_MAX_EXP not defined
+#endif
+
+#ifndef FLT_MAX_10_EXP
+#error FLT_MAX_10_EXP not defined
+#endif
+
+#ifndef DBL_MAX_10_EXP
+#error DBL_MAX_10_EXP not defined
+#endif
+
+#ifndef LDBL_MAX_10_EXP
+#error LDBL_MAX_10_EXP not defined
+#endif
+
+#ifndef FLT_MAX
+#error FLT_MAX not defined
+#endif
+
+#ifndef DBL_MAX
+#error DBL_MAX not defined
+#endif
+
+#ifndef LDBL_MAX
+#error LDBL_MAX not defined
+#endif
+
+#ifndef FLT_EPSILON
+#error FLT_EPSILON not defined
+#endif
+
+#ifndef DBL_EPSILON
+#error DBL_EPSILON not defined
+#endif
+
+#ifndef LDBL_EPSILON
+#error LDBL_EPSILON not defined
+#endif
+
+#ifndef FLT_MIN
+#error FLT_MIN not defined
+#endif
+
+#ifndef DBL_MIN
+#error DBL_MIN not defined
+#endif
+
+#ifndef LDBL_MIN
+#error LDBL_MIN not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/depr/depr.c.headers/inttypes_h.pass.cpp b/test/std/depr/depr.c.headers/inttypes_h.pass.cpp
new file mode 100644
index 000000000000..4adf82da95ec
--- /dev/null
+++ b/test/std/depr/depr.c.headers/inttypes_h.pass.cpp
@@ -0,0 +1,643 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test <inttypes.h>
+
+#include <inttypes.h>
+#include <type_traits>
+
+#ifndef PRId8
+#error PRId8 not defined
+#endif
+
+#ifndef PRId16
+#error PRId16 not defined
+#endif
+
+#ifndef PRId32
+#error PRId32 not defined
+#endif
+
+#ifndef PRId64
+#error PRId64 not defined
+#endif
+
+#ifndef PRIdLEAST8
+#error PRIdLEAST8 not defined
+#endif
+
+#ifndef PRIdLEAST16
+#error PRIdLEAST16 not defined
+#endif
+
+#ifndef PRIdLEAST32
+#error PRIdLEAST32 not defined
+#endif
+
+#ifndef PRIdLEAST64
+#error PRIdLEAST64 not defined
+#endif
+
+#ifndef PRIdFAST8
+#error PRIdFAST8 not defined
+#endif
+
+#ifndef PRIdFAST16
+#error PRIdFAST16 not defined
+#endif
+
+#ifndef PRIdFAST32
+#error PRIdFAST32 not defined
+#endif
+
+#ifndef PRIdFAST64
+#error PRIdFAST64 not defined
+#endif
+
+#ifndef PRIdMAX
+#error PRIdMAX not defined
+#endif
+
+#ifndef PRIdPTR
+#error PRIdPTR not defined
+#endif
+
+#ifndef PRIi8
+#error PRIi8 not defined
+#endif
+
+#ifndef PRIi16
+#error PRIi16 not defined
+#endif
+
+#ifndef PRIi32
+#error PRIi32 not defined
+#endif
+
+#ifndef PRIi64
+#error PRIi64 not defined
+#endif
+
+#ifndef PRIiLEAST8
+#error PRIiLEAST8 not defined
+#endif
+
+#ifndef PRIiLEAST16
+#error PRIiLEAST16 not defined
+#endif
+
+#ifndef PRIiLEAST32
+#error PRIiLEAST32 not defined
+#endif
+
+#ifndef PRIiLEAST64
+#error PRIiLEAST64 not defined
+#endif
+
+#ifndef PRIiFAST8
+#error PRIiFAST8 not defined
+#endif
+
+#ifndef PRIiFAST16
+#error PRIiFAST16 not defined
+#endif
+
+#ifndef PRIiFAST32
+#error PRIiFAST32 not defined
+#endif
+
+#ifndef PRIiFAST64
+#error PRIiFAST64 not defined
+#endif
+
+#ifndef PRIiMAX
+#error PRIiMAX not defined
+#endif
+
+#ifndef PRIiPTR
+#error PRIiPTR not defined
+#endif
+
+#ifndef PRIo8
+#error PRIo8 not defined
+#endif
+
+#ifndef PRIo16
+#error PRIo16 not defined
+#endif
+
+#ifndef PRIo32
+#error PRIo32 not defined
+#endif
+
+#ifndef PRIo64
+#error PRIo64 not defined
+#endif
+
+#ifndef PRIoLEAST8
+#error PRIoLEAST8 not defined
+#endif
+
+#ifndef PRIoLEAST16
+#error PRIoLEAST16 not defined
+#endif
+
+#ifndef PRIoLEAST32
+#error PRIoLEAST32 not defined
+#endif
+
+#ifndef PRIoLEAST64
+#error PRIoLEAST64 not defined
+#endif
+
+#ifndef PRIoFAST8
+#error PRIoFAST8 not defined
+#endif
+
+#ifndef PRIoFAST16
+#error PRIoFAST16 not defined
+#endif
+
+#ifndef PRIoFAST32
+#error PRIoFAST32 not defined
+#endif
+
+#ifndef PRIoFAST64
+#error PRIoFAST64 not defined
+#endif
+
+#ifndef PRIoMAX
+#error PRIoMAX not defined
+#endif
+
+#ifndef PRIoPTR
+#error PRIoPTR not defined
+#endif
+
+#ifndef PRIu8
+#error PRIu8 not defined
+#endif
+
+#ifndef PRIu16
+#error PRIu16 not defined
+#endif
+
+#ifndef PRIu32
+#error PRIu32 not defined
+#endif
+
+#ifndef PRIu64
+#error PRIu64 not defined
+#endif
+
+#ifndef PRIuLEAST8
+#error PRIuLEAST8 not defined
+#endif
+
+#ifndef PRIuLEAST16
+#error PRIuLEAST16 not defined
+#endif
+
+#ifndef PRIuLEAST32
+#error PRIuLEAST32 not defined
+#endif
+
+#ifndef PRIuLEAST64
+#error PRIuLEAST64 not defined
+#endif
+
+#ifndef PRIuFAST8
+#error PRIuFAST8 not defined
+#endif
+
+#ifndef PRIuFAST16
+#error PRIuFAST16 not defined
+#endif
+
+#ifndef PRIuFAST32
+#error PRIuFAST32 not defined
+#endif
+
+#ifndef PRIuFAST64
+#error PRIuFAST64 not defined
+#endif
+
+#ifndef PRIuMAX
+#error PRIuMAX not defined
+#endif
+
+#ifndef PRIuPTR
+#error PRIuPTR not defined
+#endif
+
+#ifndef PRIx8
+#error PRIx8 not defined
+#endif
+
+#ifndef PRIx16
+#error PRIx16 not defined
+#endif
+
+#ifndef PRIx32
+#error PRIx32 not defined
+#endif
+
+#ifndef PRIx64
+#error PRIx64 not defined
+#endif
+
+#ifndef PRIxLEAST8
+#error PRIxLEAST8 not defined
+#endif
+
+#ifndef PRIxLEAST16
+#error PRIxLEAST16 not defined
+#endif
+
+#ifndef PRIxLEAST32
+#error PRIxLEAST32 not defined
+#endif
+
+#ifndef PRIxLEAST64
+#error PRIxLEAST64 not defined
+#endif
+
+#ifndef PRIxFAST8
+#error PRIxFAST8 not defined
+#endif
+
+#ifndef PRIxFAST16
+#error PRIxFAST16 not defined
+#endif
+
+#ifndef PRIxFAST32
+#error PRIxFAST32 not defined
+#endif
+
+#ifndef PRIxFAST64
+#error PRIxFAST64 not defined
+#endif
+
+#ifndef PRIxMAX
+#error PRIxMAX not defined
+#endif
+
+#ifndef PRIxPTR
+#error PRIxPTR not defined
+#endif
+
+#ifndef PRIX8
+#error PRIX8 not defined
+#endif
+
+#ifndef PRIX16
+#error PRIX16 not defined
+#endif
+
+#ifndef PRIX32
+#error PRIX32 not defined
+#endif
+
+#ifndef PRIX64
+#error PRIX64 not defined
+#endif
+
+#ifndef PRIXLEAST8
+#error PRIXLEAST8 not defined
+#endif
+
+#ifndef PRIXLEAST16
+#error PRIXLEAST16 not defined
+#endif
+
+#ifndef PRIXLEAST32
+#error PRIXLEAST32 not defined
+#endif
+
+#ifndef PRIXLEAST64
+#error PRIXLEAST64 not defined
+#endif
+
+#ifndef PRIXFAST8
+#error PRIXFAST8 not defined
+#endif
+
+#ifndef PRIXFAST16
+#error PRIXFAST16 not defined
+#endif
+
+#ifndef PRIXFAST32
+#error PRIXFAST32 not defined
+#endif
+
+#ifndef PRIXFAST64
+#error PRIXFAST64 not defined
+#endif
+
+#ifndef PRIXMAX
+#error PRIXMAX not defined
+#endif
+
+#ifndef PRIXPTR
+#error PRIXPTR not defined
+#endif
+
+#ifndef SCNd8
+#error SCNd8 not defined
+#endif
+
+#ifndef SCNd16
+#error SCNd16 not defined
+#endif
+
+#ifndef SCNd32
+#error SCNd32 not defined
+#endif
+
+#ifndef SCNd64
+#error SCNd64 not defined
+#endif
+
+#ifndef SCNdLEAST8
+#error SCNdLEAST8 not defined
+#endif
+
+#ifndef SCNdLEAST16
+#error SCNdLEAST16 not defined
+#endif
+
+#ifndef SCNdLEAST32
+#error SCNdLEAST32 not defined
+#endif
+
+#ifndef SCNdLEAST64
+#error SCNdLEAST64 not defined
+#endif
+
+#ifndef SCNdFAST8
+#error SCNdFAST8 not defined
+#endif
+
+#ifndef SCNdFAST16
+#error SCNdFAST16 not defined
+#endif
+
+#ifndef SCNdFAST32
+#error SCNdFAST32 not defined
+#endif
+
+#ifndef SCNdFAST64
+#error SCNdFAST64 not defined
+#endif
+
+#ifndef SCNdMAX
+#error SCNdMAX not defined
+#endif
+
+#ifndef SCNdPTR
+#error SCNdPTR not defined
+#endif
+
+#ifndef SCNi8
+#error SCNi8 not defined
+#endif
+
+#ifndef SCNi16
+#error SCNi16 not defined
+#endif
+
+#ifndef SCNi32
+#error SCNi32 not defined
+#endif
+
+#ifndef SCNi64
+#error SCNi64 not defined
+#endif
+
+#ifndef SCNiLEAST8
+#error SCNiLEAST8 not defined
+#endif
+
+#ifndef SCNiLEAST16
+#error SCNiLEAST16 not defined
+#endif
+
+#ifndef SCNiLEAST32
+#error SCNiLEAST32 not defined
+#endif
+
+#ifndef SCNiLEAST64
+#error SCNiLEAST64 not defined
+#endif
+
+#ifndef SCNiFAST8
+#error SCNiFAST8 not defined
+#endif
+
+#ifndef SCNiFAST16
+#error SCNiFAST16 not defined
+#endif
+
+#ifndef SCNiFAST32
+#error SCNiFAST32 not defined
+#endif
+
+#ifndef SCNiFAST64
+#error SCNiFAST64 not defined
+#endif
+
+#ifndef SCNiMAX
+#error SCNiMAX not defined
+#endif
+
+#ifndef SCNiPTR
+#error SCNiPTR not defined
+#endif
+
+#ifndef SCNo8
+#error SCNo8 not defined
+#endif
+
+#ifndef SCNo16
+#error SCNo16 not defined
+#endif
+
+#ifndef SCNo32
+#error SCNo32 not defined
+#endif
+
+#ifndef SCNo64
+#error SCNo64 not defined
+#endif
+
+#ifndef SCNoLEAST8
+#error SCNoLEAST8 not defined
+#endif
+
+#ifndef SCNoLEAST16
+#error SCNoLEAST16 not defined
+#endif
+
+#ifndef SCNoLEAST32
+#error SCNoLEAST32 not defined
+#endif
+
+#ifndef SCNoLEAST64
+#error SCNoLEAST64 not defined
+#endif
+
+#ifndef SCNoFAST8
+#error SCNoFAST8 not defined
+#endif
+
+#ifndef SCNoFAST16
+#error SCNoFAST16 not defined
+#endif
+
+#ifndef SCNoFAST32
+#error SCNoFAST32 not defined
+#endif
+
+#ifndef SCNoFAST64
+#error SCNoFAST64 not defined
+#endif
+
+#ifndef SCNoMAX
+#error SCNoMAX not defined
+#endif
+
+#ifndef SCNoPTR
+#error SCNoPTR not defined
+#endif
+
+#ifndef SCNu8
+#error SCNu8 not defined
+#endif
+
+#ifndef SCNu16
+#error SCNu16 not defined
+#endif
+
+#ifndef SCNu32
+#error SCNu32 not defined
+#endif
+
+#ifndef SCNu64
+#error SCNu64 not defined
+#endif
+
+#ifndef SCNuLEAST8
+#error SCNuLEAST8 not defined
+#endif
+
+#ifndef SCNuLEAST16
+#error SCNuLEAST16 not defined
+#endif
+
+#ifndef SCNuLEAST32
+#error SCNuLEAST32 not defined
+#endif
+
+#ifndef SCNuLEAST64
+#error SCNuLEAST64 not defined
+#endif
+
+#ifndef SCNuFAST8
+#error SCNuFAST8 not defined
+#endif
+
+#ifndef SCNuFAST16
+#error SCNuFAST16 not defined
+#endif
+
+#ifndef SCNuFAST32
+#error SCNuFAST32 not defined
+#endif
+
+#ifndef SCNuFAST64
+#error SCNuFAST64 not defined
+#endif
+
+#ifndef SCNuMAX
+#error SCNuMAX not defined
+#endif
+
+#ifndef SCNuPTR
+#error SCNuPTR not defined
+#endif
+
+#ifndef SCNx8
+#error SCNx8 not defined
+#endif
+
+#ifndef SCNx16
+#error SCNx16 not defined
+#endif
+
+#ifndef SCNx32
+#error SCNx32 not defined
+#endif
+
+#ifndef SCNx64
+#error SCNx64 not defined
+#endif
+
+#ifndef SCNxLEAST8
+#error SCNxLEAST8 not defined
+#endif
+
+#ifndef SCNxLEAST16
+#error SCNxLEAST16 not defined
+#endif
+
+#ifndef SCNxLEAST32
+#error SCNxLEAST32 not defined
+#endif
+
+#ifndef SCNxLEAST64
+#error SCNxLEAST64 not defined
+#endif
+
+#ifndef SCNxFAST8
+#error SCNxFAST8 not defined
+#endif
+
+#ifndef SCNxFAST16
+#error SCNxFAST16 not defined
+#endif
+
+#ifndef SCNxFAST32
+#error SCNxFAST32 not defined
+#endif
+
+#ifndef SCNxFAST64
+#error SCNxFAST64 not defined
+#endif
+
+#ifndef SCNxMAX
+#error SCNxMAX not defined
+#endif
+
+#ifndef SCNxPTR
+#error SCNxPTR not defined
+#endif
+
+int main()
+{
+ {
+ imaxdiv_t i1 = {0};
+ }
+ intmax_t i = 0;
+ static_assert((std::is_same<decltype(imaxabs(i)), intmax_t>::value), "");
+ static_assert((std::is_same<decltype(imaxdiv(i, i)), imaxdiv_t>::value), "");
+ static_assert((std::is_same<decltype(strtoimax("", (char**)0, 0)), intmax_t>::value), "");
+ static_assert((std::is_same<decltype(strtoumax("", (char**)0, 0)), uintmax_t>::value), "");
+ static_assert((std::is_same<decltype(wcstoimax(L"", (wchar_t**)0, 0)), intmax_t>::value), "");
+ static_assert((std::is_same<decltype(wcstoumax(L"", (wchar_t**)0, 0)), uintmax_t>::value), "");
+}
diff --git a/test/std/depr/depr.c.headers/iso646_h.pass.cpp b/test/std/depr/depr.c.headers/iso646_h.pass.cpp
new file mode 100644
index 000000000000..b40a4e06cf72
--- /dev/null
+++ b/test/std/depr/depr.c.headers/iso646_h.pass.cpp
@@ -0,0 +1,17 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iso646.h>
+
+#include <iso646.h>
+
+int main()
+{
+ // Nothing to test
+}
diff --git a/test/std/depr/depr.c.headers/limits_h.pass.cpp b/test/std/depr/depr.c.headers/limits_h.pass.cpp
new file mode 100644
index 000000000000..3b78a835dedf
--- /dev/null
+++ b/test/std/depr/depr.c.headers/limits_h.pass.cpp
@@ -0,0 +1,92 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+ // test limits.h
+
+#include <limits.h>
+
+#ifndef CHAR_BIT
+#error CHAR_BIT not defined
+#endif
+
+#ifndef SCHAR_MIN
+#error SCHAR_MIN not defined
+#endif
+
+#ifndef SCHAR_MAX
+#error SCHAR_MAX not defined
+#endif
+
+#ifndef UCHAR_MAX
+#error UCHAR_MAX not defined
+#endif
+
+#ifndef CHAR_MIN
+#error CHAR_MIN not defined
+#endif
+
+#ifndef CHAR_MAX
+#error CHAR_MAX not defined
+#endif
+
+#ifndef MB_LEN_MAX
+#error MB_LEN_MAX not defined
+#endif
+
+#ifndef SHRT_MIN
+#error SHRT_MIN not defined
+#endif
+
+#ifndef SHRT_MAX
+#error SHRT_MAX not defined
+#endif
+
+#ifndef USHRT_MAX
+#error USHRT_MAX not defined
+#endif
+
+#ifndef INT_MIN
+#error INT_MIN not defined
+#endif
+
+#ifndef INT_MAX
+#error INT_MAX not defined
+#endif
+
+#ifndef UINT_MAX
+#error UINT_MAX not defined
+#endif
+
+#ifndef LONG_MIN
+#error LONG_MIN not defined
+#endif
+
+#ifndef LONG_MAX
+#error LONG_MAX not defined
+#endif
+
+#ifndef ULONG_MAX
+#error ULONG_MAX not defined
+#endif
+
+#ifndef LLONG_MIN
+#error LLONG_MIN not defined
+#endif
+
+#ifndef LLONG_MAX
+#error LLONG_MAX not defined
+#endif
+
+#ifndef ULLONG_MAX
+#error ULLONG_MAX not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/depr/depr.c.headers/locale_h.pass.cpp b/test/std/depr/depr.c.headers/locale_h.pass.cpp
new file mode 100644
index 000000000000..6ecf5a82e8dd
--- /dev/null
+++ b/test/std/depr/depr.c.headers/locale_h.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale.h>
+
+#include <locale.h>
+#include <type_traits>
+
+#ifndef LC_ALL
+#error LC_ALL not defined
+#endif
+
+#ifndef LC_COLLATE
+#error LC_COLLATE not defined
+#endif
+
+#ifndef LC_CTYPE
+#error LC_CTYPE not defined
+#endif
+
+#ifndef LC_MONETARY
+#error LC_MONETARY not defined
+#endif
+
+#ifndef LC_NUMERIC
+#error LC_NUMERIC not defined
+#endif
+
+#ifndef LC_TIME
+#error LC_TIME not defined
+#endif
+
+#ifndef NULL
+#error NULL not defined
+#endif
+
+int main()
+{
+ lconv lc;
+ static_assert((std::is_same<decltype(setlocale(0, "")), char*>::value), "");
+ static_assert((std::is_same<decltype(localeconv()), lconv*>::value), "");
+}
diff --git a/test/std/depr/depr.c.headers/math_h.pass.cpp b/test/std/depr/depr.c.headers/math_h.pass.cpp
new file mode 100644
index 000000000000..b03a61b15e11
--- /dev/null
+++ b/test/std/depr/depr.c.headers/math_h.pass.cpp
@@ -0,0 +1,683 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <math.h>
+
+// XFAIL: linux
+
+#include <math.h>
+#include <type_traits>
+#include <cassert>
+
+#include "hexfloat.h"
+
+void test_acos()
+{
+ static_assert((std::is_same<decltype(acos((double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(acosf(0)), float>::value), "");
+ static_assert((std::is_same<decltype(acosl(0)), long double>::value), "");
+ assert(acos(1) == 0);
+}
+
+void test_asin()
+{
+ static_assert((std::is_same<decltype(asin((double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(asinf(0)), float>::value), "");
+ static_assert((std::is_same<decltype(asinl(0)), long double>::value), "");
+ assert(asin(0) == 0);
+}
+
+void test_atan()
+{
+ static_assert((std::is_same<decltype(atan((double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(atanf(0)), float>::value), "");
+ static_assert((std::is_same<decltype(atanl(0)), long double>::value), "");
+ assert(atan(0) == 0);
+}
+
+void test_atan2()
+{
+ static_assert((std::is_same<decltype(atan2((double)0, (double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(atan2f(0,0)), float>::value), "");
+ static_assert((std::is_same<decltype(atan2l(0,0)), long double>::value), "");
+ assert(atan2(0,1) == 0);
+}
+
+void test_ceil()
+{
+ static_assert((std::is_same<decltype(ceil((double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(ceilf(0)), float>::value), "");
+ static_assert((std::is_same<decltype(ceill(0)), long double>::value), "");
+ assert(ceil(0) == 0);
+}
+
+void test_cos()
+{
+ static_assert((std::is_same<decltype(cos((double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(cosf(0)), float>::value), "");
+ static_assert((std::is_same<decltype(cosl(0)), long double>::value), "");
+ assert(cos(0) == 1);
+}
+
+void test_cosh()
+{
+ static_assert((std::is_same<decltype(cosh((double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(coshf(0)), float>::value), "");
+ static_assert((std::is_same<decltype(coshl(0)), long double>::value), "");
+ assert(cosh(0) == 1);
+}
+
+void test_exp()
+{
+ static_assert((std::is_same<decltype(exp((double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(expf(0)), float>::value), "");
+ static_assert((std::is_same<decltype(expl(0)), long double>::value), "");
+ assert(exp(0) == 1);
+}
+
+void test_fabs()
+{
+ static_assert((std::is_same<decltype(fabs((double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(fabsf(0.f)), float>::value), "");
+ static_assert((std::is_same<decltype(fabsl(0.L)), long double>::value), "");
+ assert(fabs(-1.f) == 1);
+}
+
+void test_floor()
+{
+ static_assert((std::is_same<decltype(floor((double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(floorf(0)), float>::value), "");
+ static_assert((std::is_same<decltype(floorl(0)), long double>::value), "");
+ assert(floor(1) == 1);
+}
+
+void test_fmod()
+{
+ static_assert((std::is_same<decltype(fmod((double)0, (double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(fmodf(0,0)), float>::value), "");
+ static_assert((std::is_same<decltype(fmodl(0,0)), long double>::value), "");
+ assert(fmod(1.5,1) == .5);
+}
+
+void test_frexp()
+{
+ int ip;
+ static_assert((std::is_same<decltype(frexp((double)0, &ip)), double>::value), "");
+ static_assert((std::is_same<decltype(frexpf(0, &ip)), float>::value), "");
+ static_assert((std::is_same<decltype(frexpl(0, &ip)), long double>::value), "");
+ assert(frexp(0, &ip) == 0);
+}
+
+void test_ldexp()
+{
+ int ip = 1;
+ static_assert((std::is_same<decltype(ldexp((double)0, ip)), double>::value), "");
+ static_assert((std::is_same<decltype(ldexpf(0, ip)), float>::value), "");
+ static_assert((std::is_same<decltype(ldexpl(0, ip)), long double>::value), "");
+ assert(ldexp(1, ip) == 2);
+}
+
+void test_log()
+{
+ static_assert((std::is_same<decltype(log((double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(logf(0)), float>::value), "");
+ static_assert((std::is_same<decltype(logl(0)), long double>::value), "");
+ assert(log(1) == 0);
+}
+
+void test_log10()
+{
+ static_assert((std::is_same<decltype(log10((double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(log10f(0)), float>::value), "");
+ static_assert((std::is_same<decltype(log10l(0)), long double>::value), "");
+ assert(log10(1) == 0);
+}
+
+void test_modf()
+{
+ static_assert((std::is_same<decltype(modf((double)0, (double*)0)), double>::value), "");
+ static_assert((std::is_same<decltype(modff(0, (float*)0)), float>::value), "");
+ static_assert((std::is_same<decltype(modfl(0, (long double*)0)), long double>::value), "");
+ double i;
+ assert(modf(1., &i) == 0);
+}
+
+void test_pow()
+{
+ static_assert((std::is_same<decltype(pow((double)0, (double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(powf(0,0)), float>::value), "");
+ static_assert((std::is_same<decltype(powl(0,0)), long double>::value), "");
+ assert(pow(1,1) == 1);
+}
+
+void test_sin()
+{
+ static_assert((std::is_same<decltype(sin((double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(sinf(0)), float>::value), "");
+ static_assert((std::is_same<decltype(sinl(0)), long double>::value), "");
+ assert(sin(0) == 0);
+}
+
+void test_sinh()
+{
+ static_assert((std::is_same<decltype(sinh((double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(sinhf(0)), float>::value), "");
+ static_assert((std::is_same<decltype(sinhl(0)), long double>::value), "");
+ assert(sinh(0) == 0);
+}
+
+void test_sqrt()
+{
+ static_assert((std::is_same<decltype(sqrt((double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(sqrtf(0)), float>::value), "");
+ static_assert((std::is_same<decltype(sqrtl(0)), long double>::value), "");
+ assert(sqrt(4) == 2);
+}
+
+void test_tan()
+{
+ static_assert((std::is_same<decltype(tan((double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(tanf(0)), float>::value), "");
+ static_assert((std::is_same<decltype(tanl(0)), long double>::value), "");
+ assert(tan(0) == 0);
+}
+
+void test_tanh()
+{
+ static_assert((std::is_same<decltype(tanh((double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(tanhf(0)), float>::value), "");
+ static_assert((std::is_same<decltype(tanhl(0)), long double>::value), "");
+ assert(tanh(0) == 0);
+}
+
+void test_signbit()
+{
+ static_assert((std::is_same<decltype(signbit((float)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(signbit((double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(signbit((long double)0)), bool>::value), "");
+ assert(signbit(-1.0) == true);
+}
+
+void test_fpclassify()
+{
+ static_assert((std::is_same<decltype(fpclassify((float)0)), int>::value), "");
+ static_assert((std::is_same<decltype(fpclassify((double)0)), int>::value), "");
+ static_assert((std::is_same<decltype(fpclassify((long double)0)), int>::value), "");
+ assert(fpclassify(-1.0) == FP_NORMAL);
+}
+
+void test_isfinite()
+{
+ static_assert((std::is_same<decltype(isfinite((float)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(isfinite((double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(isfinite((long double)0)), bool>::value), "");
+ assert(isfinite(-1.0) == true);
+}
+
+void test_isinf()
+{
+ static_assert((std::is_same<decltype(isinf((float)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(isinf((double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(isinf((long double)0)), bool>::value), "");
+ assert(isinf(-1.0) == false);
+}
+
+void test_isnan()
+{
+ static_assert((std::is_same<decltype(isnan((float)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(isnan((double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(isnan((long double)0)), bool>::value), "");
+ assert(isnan(-1.0) == false);
+}
+
+void test_isnormal()
+{
+ static_assert((std::is_same<decltype(isnormal((float)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(isnormal((double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(isnormal((long double)0)), bool>::value), "");
+ assert(isnormal(-1.0) == true);
+}
+
+void test_isgreater()
+{
+ static_assert((std::is_same<decltype(isgreater((float)0, (float)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(isgreater((float)0, (double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(isgreater((float)0, (long double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(isgreater((double)0, (float)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(isgreater((double)0, (double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(isgreater((double)0, (long double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(isgreater((long double)0, (float)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(isgreater((long double)0, (double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(isgreater((long double)0, (long double)0)), bool>::value), "");
+ assert(isgreater(-1.0, 0.F) == false);
+}
+
+void test_isgreaterequal()
+{
+ static_assert((std::is_same<decltype(isgreaterequal((float)0, (float)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(isgreaterequal((float)0, (double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(isgreaterequal((float)0, (long double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(isgreaterequal((double)0, (float)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(isgreaterequal((double)0, (double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(isgreaterequal((double)0, (long double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(isgreaterequal((long double)0, (float)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(isgreaterequal((long double)0, (double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(isgreaterequal((long double)0, (long double)0)), bool>::value), "");
+ assert(isgreaterequal(-1.0, 0.F) == false);
+}
+
+void test_isless()
+{
+ static_assert((std::is_same<decltype(isless((float)0, (float)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(isless((float)0, (double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(isless((float)0, (long double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(isless((double)0, (float)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(isless((double)0, (double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(isless((double)0, (long double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(isless((long double)0, (float)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(isless((long double)0, (double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(isless((long double)0, (long double)0)), bool>::value), "");
+ assert(isless(-1.0, 0.F) == true);
+}
+
+void test_islessequal()
+{
+ static_assert((std::is_same<decltype(islessequal((float)0, (float)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(islessequal((float)0, (double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(islessequal((float)0, (long double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(islessequal((double)0, (float)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(islessequal((double)0, (double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(islessequal((double)0, (long double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(islessequal((long double)0, (float)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(islessequal((long double)0, (double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(islessequal((long double)0, (long double)0)), bool>::value), "");
+ assert(islessequal(-1.0, 0.F) == true);
+}
+
+void test_islessgreater()
+{
+ static_assert((std::is_same<decltype(islessgreater((float)0, (float)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(islessgreater((float)0, (double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(islessgreater((float)0, (long double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(islessgreater((double)0, (float)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(islessgreater((double)0, (double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(islessgreater((double)0, (long double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(islessgreater((long double)0, (float)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(islessgreater((long double)0, (double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(islessgreater((long double)0, (long double)0)), bool>::value), "");
+ assert(islessgreater(-1.0, 0.F) == true);
+}
+
+void test_isunordered()
+{
+ static_assert((std::is_same<decltype(isunordered((float)0, (float)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(isunordered((float)0, (double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(isunordered((float)0, (long double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(isunordered((double)0, (float)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(isunordered((double)0, (double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(isunordered((double)0, (long double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(isunordered((long double)0, (float)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(isunordered((long double)0, (double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(isunordered((long double)0, (long double)0)), bool>::value), "");
+ assert(isunordered(-1.0, 0.F) == false);
+}
+
+void test_acosh()
+{
+ static_assert((std::is_same<decltype(acosh((double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(acoshf(0)), float>::value), "");
+ static_assert((std::is_same<decltype(acoshl(0)), long double>::value), "");
+ assert(acosh(1) == 0);
+}
+
+void test_asinh()
+{
+ static_assert((std::is_same<decltype(asinh((double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(asinhf(0)), float>::value), "");
+ static_assert((std::is_same<decltype(asinhl(0)), long double>::value), "");
+ assert(asinh(0) == 0);
+}
+
+void test_atanh()
+{
+ static_assert((std::is_same<decltype(atanh((double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(atanhf(0)), float>::value), "");
+ static_assert((std::is_same<decltype(atanhl(0)), long double>::value), "");
+ assert(atanh(0) == 0);
+}
+
+void test_cbrt()
+{
+ static_assert((std::is_same<decltype(cbrt((double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(cbrtf(0)), float>::value), "");
+ static_assert((std::is_same<decltype(cbrtl(0)), long double>::value), "");
+ assert(cbrt(1) == 1);
+}
+
+void test_copysign()
+{
+ static_assert((std::is_same<decltype(copysign((double)0, (double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(copysignf(0,0)), float>::value), "");
+ static_assert((std::is_same<decltype(copysignl(0,0)), long double>::value), "");
+ assert(copysign(1,1) == 1);
+}
+
+void test_erf()
+{
+ static_assert((std::is_same<decltype(erf((double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(erff(0)), float>::value), "");
+ static_assert((std::is_same<decltype(erfl(0)), long double>::value), "");
+ assert(erf(0) == 0);
+}
+
+void test_erfc()
+{
+ static_assert((std::is_same<decltype(erfc((double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(erfcf(0)), float>::value), "");
+ static_assert((std::is_same<decltype(erfcl(0)), long double>::value), "");
+ assert(erfc(0) == 1);
+}
+
+void test_exp2()
+{
+ static_assert((std::is_same<decltype(exp2((double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(exp2f(0)), float>::value), "");
+ static_assert((std::is_same<decltype(exp2l(0)), long double>::value), "");
+ assert(exp2(1) == 2);
+}
+
+void test_expm1()
+{
+ static_assert((std::is_same<decltype(expm1((double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(expm1f(0)), float>::value), "");
+ static_assert((std::is_same<decltype(expm1l(0)), long double>::value), "");
+ assert(expm1(0) == 0);
+}
+
+void test_fdim()
+{
+ static_assert((std::is_same<decltype(fdim((double)0, (double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(fdimf(0,0)), float>::value), "");
+ static_assert((std::is_same<decltype(fdiml(0,0)), long double>::value), "");
+ assert(fdim(1,0) == 1);
+}
+
+void test_fma()
+{
+ static_assert((std::is_same<decltype(fma((double)0, (double)0, (double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(fmaf(0,0,0)), float>::value), "");
+ static_assert((std::is_same<decltype(fmal(0,0,0)), long double>::value), "");
+ assert(fma(1,1,1) == 2);
+}
+
+void test_fmax()
+{
+ static_assert((std::is_same<decltype(fmax((double)0, (double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(fmaxf(0,0)), float>::value), "");
+ static_assert((std::is_same<decltype(fmaxl(0,0)), long double>::value), "");
+ assert(fmax(1,0) == 1);
+}
+
+void test_fmin()
+{
+ static_assert((std::is_same<decltype(fmin((double)0, (double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(fminf(0,0)), float>::value), "");
+ static_assert((std::is_same<decltype(fminl(0,0)), long double>::value), "");
+ assert(fmin(1,0) == 0);
+}
+
+void test_hypot()
+{
+ static_assert((std::is_same<decltype(hypot((double)0, (double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(hypotf(0,0)), float>::value), "");
+ static_assert((std::is_same<decltype(hypotl(0,0)), long double>::value), "");
+ assert(hypot(3,4) == 5);
+}
+
+void test_ilogb()
+{
+ static_assert((std::is_same<decltype(ilogb((double)0)), int>::value), "");
+ static_assert((std::is_same<decltype(ilogbf(0)), int>::value), "");
+ static_assert((std::is_same<decltype(ilogbl(0)), int>::value), "");
+ assert(ilogb(1) == 0);
+}
+
+void test_lgamma()
+{
+ static_assert((std::is_same<decltype(lgamma((double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(lgammaf(0)), float>::value), "");
+ static_assert((std::is_same<decltype(lgammal(0)), long double>::value), "");
+ assert(lgamma(1) == 0);
+}
+
+void test_llrint()
+{
+ static_assert((std::is_same<decltype(llrint((double)0)), long long>::value), "");
+ static_assert((std::is_same<decltype(llrintf(0)), long long>::value), "");
+ static_assert((std::is_same<decltype(llrintl(0)), long long>::value), "");
+ assert(llrint(1) == 1LL);
+}
+
+void test_llround()
+{
+ static_assert((std::is_same<decltype(llround((double)0)), long long>::value), "");
+ static_assert((std::is_same<decltype(llroundf(0)), long long>::value), "");
+ static_assert((std::is_same<decltype(llroundl(0)), long long>::value), "");
+ assert(llround(1) == 1LL);
+}
+
+void test_log1p()
+{
+ static_assert((std::is_same<decltype(log1p((double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(log1pf(0)), float>::value), "");
+ static_assert((std::is_same<decltype(log1pl(0)), long double>::value), "");
+ assert(log1p(0) == 0);
+}
+
+void test_log2()
+{
+ static_assert((std::is_same<decltype(log2((double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(log2f(0)), float>::value), "");
+ static_assert((std::is_same<decltype(log2l(0)), long double>::value), "");
+ assert(log2(1) == 0);
+}
+
+void test_logb()
+{
+ static_assert((std::is_same<decltype(logb((double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(logbf(0)), float>::value), "");
+ static_assert((std::is_same<decltype(logbl(0)), long double>::value), "");
+ assert(logb(1) == 0);
+}
+
+void test_lrint()
+{
+ static_assert((std::is_same<decltype(lrint((double)0)), long>::value), "");
+ static_assert((std::is_same<decltype(lrintf(0)), long>::value), "");
+ static_assert((std::is_same<decltype(lrintl(0)), long>::value), "");
+ assert(lrint(1) == 1L);
+}
+
+void test_lround()
+{
+ static_assert((std::is_same<decltype(lround((double)0)), long>::value), "");
+ static_assert((std::is_same<decltype(lroundf(0)), long>::value), "");
+ static_assert((std::is_same<decltype(lroundl(0)), long>::value), "");
+ assert(lround(1) == 1L);
+}
+
+void test_nan()
+{
+ static_assert((std::is_same<decltype(nan("")), double>::value), "");
+ static_assert((std::is_same<decltype(nanf("")), float>::value), "");
+ static_assert((std::is_same<decltype(nanl("")), long double>::value), "");
+}
+
+void test_nearbyint()
+{
+ static_assert((std::is_same<decltype(nearbyint((double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(nearbyintf(0)), float>::value), "");
+ static_assert((std::is_same<decltype(nearbyintl(0)), long double>::value), "");
+ assert(nearbyint(1) == 1);
+}
+
+void test_nextafter()
+{
+ static_assert((std::is_same<decltype(nextafter((double)0, (double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(nextafterf(0,0)), float>::value), "");
+ static_assert((std::is_same<decltype(nextafterl(0,0)), long double>::value), "");
+ assert(nextafter(0,1) == hexfloat<double>(0x1, 0, -1074));
+}
+
+void test_nexttoward()
+{
+ static_assert((std::is_same<decltype(nexttoward((double)0, (long double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(nexttowardf(0, (long double)0)), float>::value), "");
+ static_assert((std::is_same<decltype(nexttowardl(0, (long double)0)), long double>::value), "");
+ assert(nexttoward(0, 1) == hexfloat<double>(0x1, 0, -1074));
+}
+
+void test_remainder()
+{
+ static_assert((std::is_same<decltype(remainder((double)0, (double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(remainderf(0,0)), float>::value), "");
+ static_assert((std::is_same<decltype(remainderl(0,0)), long double>::value), "");
+ static_assert((std::is_same<decltype(remainder((int)0, (int)0)), double>::value), "");
+ assert(remainder(0.5,1) == 0.5);
+}
+
+void test_remquo()
+{
+ int ip;
+ static_assert((std::is_same<decltype(remquo((double)0, (double)0, &ip)), double>::value), "");
+ static_assert((std::is_same<decltype(remquof(0,0, &ip)), float>::value), "");
+ static_assert((std::is_same<decltype(remquol(0,0, &ip)), long double>::value), "");
+ assert(remquo(0.5,1, &ip) == 0.5);
+}
+
+void test_rint()
+{
+ static_assert((std::is_same<decltype(rint((double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(rintf(0)), float>::value), "");
+ static_assert((std::is_same<decltype(rintl(0)), long double>::value), "");
+ assert(rint(1) == 1);
+}
+
+void test_round()
+{
+ static_assert((std::is_same<decltype(round((double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(roundf(0)), float>::value), "");
+ static_assert((std::is_same<decltype(roundl(0)), long double>::value), "");
+ assert(round(1) == 1);
+}
+
+void test_scalbln()
+{
+ static_assert((std::is_same<decltype(scalbln((double)0, (long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(scalblnf(0, (long)0)), float>::value), "");
+ static_assert((std::is_same<decltype(scalblnl(0, (long)0)), long double>::value), "");
+ assert(scalbln(1, 1) == 2);
+}
+
+void test_scalbn()
+{
+ static_assert((std::is_same<decltype(scalbn((double)0, (int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(scalbnf(0, (int)0)), float>::value), "");
+ static_assert((std::is_same<decltype(scalbnl(0, (int)0)), long double>::value), "");
+ assert(scalbn(1, 1) == 2);
+}
+
+void test_tgamma()
+{
+ static_assert((std::is_same<decltype(tgamma((double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(tgammaf(0)), float>::value), "");
+ static_assert((std::is_same<decltype(tgammal(0)), long double>::value), "");
+ assert(tgamma(1) == 1);
+}
+
+void test_trunc()
+{
+ static_assert((std::is_same<decltype(trunc((double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(truncf(0)), float>::value), "");
+ static_assert((std::is_same<decltype(truncl(0)), long double>::value), "");
+ assert(trunc(1) == 1);
+}
+
+int main()
+{
+ test_acos();
+ test_asin();
+ test_atan();
+ test_atan2();
+ test_ceil();
+ test_cos();
+ test_cosh();
+ test_exp();
+ test_fabs();
+ test_floor();
+ test_fmod();
+ test_frexp();
+ test_ldexp();
+ test_log();
+ test_log10();
+ test_modf();
+ test_pow();
+ test_sin();
+ test_sinh();
+ test_sqrt();
+ test_tan();
+ test_tanh();
+ test_signbit();
+ test_fpclassify();
+ test_isfinite();
+ test_isinf();
+ test_isnan();
+ test_isnormal();
+ test_isgreater();
+ test_isgreaterequal();
+ test_isless();
+ test_islessequal();
+ test_islessgreater();
+ test_isunordered();
+ test_acosh();
+ test_asinh();
+ test_atanh();
+ test_cbrt();
+ test_copysign();
+ test_erf();
+ test_erfc();
+ test_exp2();
+ test_expm1();
+ test_fdim();
+ test_fma();
+ test_fmax();
+ test_fmin();
+ test_hypot();
+ test_ilogb();
+ test_lgamma();
+ test_llrint();
+ test_llround();
+ test_log1p();
+ test_log2();
+ test_logb();
+ test_lrint();
+ test_lround();
+ test_nan();
+ test_nearbyint();
+ test_nextafter();
+ test_nexttoward();
+ test_remainder();
+ test_remquo();
+ test_rint();
+ test_round();
+ test_scalbln();
+ test_scalbn();
+ test_tgamma();
+ test_trunc();
+}
diff --git a/test/std/depr/depr.c.headers/setjmp_h.pass.cpp b/test/std/depr/depr.c.headers/setjmp_h.pass.cpp
new file mode 100644
index 000000000000..36f425390694
--- /dev/null
+++ b/test/std/depr/depr.c.headers/setjmp_h.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test <setjmp.h>
+
+#include <setjmp.h>
+#include <type_traits>
+
+int main()
+{
+ jmp_buf jb;
+ static_assert((std::is_same<decltype(longjmp(jb, 0)), void>::value),
+ "std::is_same<decltype(longjmp(jb, 0)), void>::value");
+}
diff --git a/test/std/depr/depr.c.headers/signal_h.pass.cpp b/test/std/depr/depr.c.headers/signal_h.pass.cpp
new file mode 100644
index 000000000000..a8ef5f993fe6
--- /dev/null
+++ b/test/std/depr/depr.c.headers/signal_h.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test <signal.h>
+
+#include <signal.h>
+#include <type_traits>
+
+#ifndef SIG_DFL
+#error SIG_DFL not defined
+#endif
+
+#ifndef SIG_ERR
+#error SIG_ERR not defined
+#endif
+
+#ifndef SIG_IGN
+#error SIG_IGN not defined
+#endif
+
+#ifndef SIGABRT
+#error SIGABRT not defined
+#endif
+
+#ifndef SIGFPE
+#error SIGFPE not defined
+#endif
+
+#ifndef SIGILL
+#error SIGILL not defined
+#endif
+
+#ifndef SIGINT
+#error SIGINT not defined
+#endif
+
+#ifndef SIGSEGV
+#error SIGSEGV not defined
+#endif
+
+#ifndef SIGTERM
+#error SIGTERM not defined
+#endif
+
+int main()
+{
+ sig_atomic_t sig;
+ typedef void (*func)(int);
+ static_assert((std::is_same<decltype(signal(0, (func)0)), func>::value), "");
+ static_assert((std::is_same<decltype(raise(0)), int>::value), "");
+}
diff --git a/test/std/depr/depr.c.headers/stdarg_h.pass.cpp b/test/std/depr/depr.c.headers/stdarg_h.pass.cpp
new file mode 100644
index 000000000000..7a60902529ea
--- /dev/null
+++ b/test/std/depr/depr.c.headers/stdarg_h.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test <stdarg.h>
+
+#include <stdarg.h>
+
+#ifndef va_arg
+#error va_arg not defined
+#endif
+
+#if __cplusplus >= 201103L
+# ifndef va_copy
+# error va_copy is not defined when c++ >= 11
+# endif
+#endif
+
+#ifndef va_end
+#error va_end not defined
+#endif
+
+#ifndef va_start
+#error va_start not defined
+#endif
+
+int main()
+{
+ va_list va;
+}
diff --git a/test/std/depr/depr.c.headers/stdbool_h.pass.cpp b/test/std/depr/depr.c.headers/stdbool_h.pass.cpp
new file mode 100644
index 000000000000..cd4d4c4b21f6
--- /dev/null
+++ b/test/std/depr/depr.c.headers/stdbool_h.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test <stdbool.h>
+
+#include <stdbool.h>
+
+#ifndef __bool_true_false_are_defined
+#error __bool_true_false_are_defined not defined
+#endif
+
+#ifdef bool
+#error bool should not be defined
+#endif
+
+#ifdef true
+#error true should not be defined
+#endif
+
+#ifdef false
+#error false should not be defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/depr/depr.c.headers/stddef_h.pass.cpp b/test/std/depr/depr.c.headers/stddef_h.pass.cpp
new file mode 100644
index 000000000000..140c91b53e6e
--- /dev/null
+++ b/test/std/depr/depr.c.headers/stddef_h.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <stddef.h>
+
+#include <stddef.h>
+#include <type_traits>
+
+#ifndef NULL
+#error NULL not defined
+#endif
+
+#ifndef offsetof
+#error offsetof not defined
+#endif
+
+int main()
+{
+ static_assert(sizeof(size_t) == sizeof(void*),
+ "sizeof(size_t) == sizeof(void*)");
+ static_assert(std::is_unsigned<size_t>::value,
+ "std::is_unsigned<size_t>::value");
+ static_assert(std::is_integral<size_t>::value,
+ "std::is_integral<size_t>::value");
+ static_assert(sizeof(ptrdiff_t) == sizeof(void*),
+ "sizeof(ptrdiff_t) == sizeof(void*)");
+ static_assert(std::is_signed<ptrdiff_t>::value,
+ "std::is_signed<ptrdiff_t>::value");
+ static_assert(std::is_integral<ptrdiff_t>::value,
+ "std::is_integral<ptrdiff_t>::value");
+}
diff --git a/test/std/depr/depr.c.headers/stdint_h.pass.cpp b/test/std/depr/depr.c.headers/stdint_h.pass.cpp
new file mode 100644
index 000000000000..3861ee509753
--- /dev/null
+++ b/test/std/depr/depr.c.headers/stdint_h.pass.cpp
@@ -0,0 +1,291 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test <stdint.h>
+
+#include <stdint.h>
+#include <cstddef>
+#include <csignal>
+#include <cwctype>
+#include <climits>
+#include <type_traits>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ // typedef int8_t
+ static_assert(sizeof(int8_t)*CHAR_BIT == 8,
+ "sizeof(int8_t)*CHAR_BIT == 8");
+ static_assert(std::is_signed<int8_t>::value,
+ "std::is_signed<int8_t>::value");
+ // typedef int16_t
+ static_assert(sizeof(int16_t)*CHAR_BIT == 16,
+ "sizeof(int16_t)*CHAR_BIT == 16");
+ static_assert(std::is_signed<int16_t>::value,
+ "std::is_signed<int16_t>::value");
+ // typedef int32_t
+ static_assert(sizeof(int32_t)*CHAR_BIT == 32,
+ "sizeof(int32_t)*CHAR_BIT == 32");
+ static_assert(std::is_signed<int32_t>::value,
+ "std::is_signed<int32_t>::value");
+ // typedef int64_t
+ static_assert(sizeof(int64_t)*CHAR_BIT == 64,
+ "sizeof(int64_t)*CHAR_BIT == 64");
+ static_assert(std::is_signed<int64_t>::value,
+ "std::is_signed<int64_t>::value");
+
+ // typedef uint8_t
+ static_assert(sizeof(uint8_t)*CHAR_BIT == 8,
+ "sizeof(uint8_t)*CHAR_BIT == 8");
+ static_assert(std::is_unsigned<uint8_t>::value,
+ "std::is_unsigned<uint8_t>::value");
+ // typedef uint16_t
+ static_assert(sizeof(uint16_t)*CHAR_BIT == 16,
+ "sizeof(uint16_t)*CHAR_BIT == 16");
+ static_assert(std::is_unsigned<uint16_t>::value,
+ "std::is_unsigned<uint16_t>::value");
+ // typedef uint32_t
+ static_assert(sizeof(uint32_t)*CHAR_BIT == 32,
+ "sizeof(uint32_t)*CHAR_BIT == 32");
+ static_assert(std::is_unsigned<uint32_t>::value,
+ "std::is_unsigned<uint32_t>::value");
+ // typedef uint64_t
+ static_assert(sizeof(uint64_t)*CHAR_BIT == 64,
+ "sizeof(uint64_t)*CHAR_BIT == 64");
+ static_assert(std::is_unsigned<uint64_t>::value,
+ "std::is_unsigned<uint64_t>::value");
+
+ // typedef int_least8_t
+ static_assert(sizeof(int_least8_t)*CHAR_BIT >= 8,
+ "sizeof(int_least8_t)*CHAR_BIT >= 8");
+ static_assert(std::is_signed<int_least8_t>::value,
+ "std::is_signed<int_least8_t>::value");
+ // typedef int_least16_t
+ static_assert(sizeof(int_least16_t)*CHAR_BIT >= 16,
+ "sizeof(int_least16_t)*CHAR_BIT >= 16");
+ static_assert(std::is_signed<int_least16_t>::value,
+ "std::is_signed<int_least16_t>::value");
+ // typedef int_least32_t
+ static_assert(sizeof(int_least32_t)*CHAR_BIT >= 32,
+ "sizeof(int_least32_t)*CHAR_BIT >= 32");
+ static_assert(std::is_signed<int_least32_t>::value,
+ "std::is_signed<int_least32_t>::value");
+ // typedef int_least64_t
+ static_assert(sizeof(int_least64_t)*CHAR_BIT >= 64,
+ "sizeof(int_least64_t)*CHAR_BIT >= 64");
+ static_assert(std::is_signed<int_least64_t>::value,
+ "std::is_signed<int_least64_t>::value");
+
+ // typedef uint_least8_t
+ static_assert(sizeof(uint_least8_t)*CHAR_BIT >= 8,
+ "sizeof(uint_least8_t)*CHAR_BIT >= 8");
+ static_assert(std::is_unsigned<uint_least8_t>::value,
+ "std::is_unsigned<uint_least8_t>::value");
+ // typedef uint_least16_t
+ static_assert(sizeof(uint_least16_t)*CHAR_BIT >= 16,
+ "sizeof(uint_least16_t)*CHAR_BIT >= 16");
+ static_assert(std::is_unsigned<uint_least16_t>::value,
+ "std::is_unsigned<uint_least16_t>::value");
+ // typedef uint_least32_t
+ static_assert(sizeof(uint_least32_t)*CHAR_BIT >= 32,
+ "sizeof(uint_least32_t)*CHAR_BIT >= 32");
+ static_assert(std::is_unsigned<uint_least32_t>::value,
+ "std::is_unsigned<uint_least32_t>::value");
+ // typedef uint_least64_t
+ static_assert(sizeof(uint_least64_t)*CHAR_BIT >= 64,
+ "sizeof(uint_least64_t)*CHAR_BIT >= 64");
+ static_assert(std::is_unsigned<uint_least64_t>::value,
+ "std::is_unsigned<uint_least64_t>::value");
+
+ // typedef int_fast8_t
+ static_assert(sizeof(int_fast8_t)*CHAR_BIT >= 8,
+ "sizeof(int_fast8_t)*CHAR_BIT >= 8");
+ static_assert(std::is_signed<int_fast8_t>::value,
+ "std::is_signed<int_fast8_t>::value");
+ // typedef int_fast16_t
+ static_assert(sizeof(int_fast16_t)*CHAR_BIT >= 16,
+ "sizeof(int_fast16_t)*CHAR_BIT >= 16");
+ static_assert(std::is_signed<int_fast16_t>::value,
+ "std::is_signed<int_fast16_t>::value");
+ // typedef int_fast32_t
+ static_assert(sizeof(int_fast32_t)*CHAR_BIT >= 32,
+ "sizeof(int_fast32_t)*CHAR_BIT >= 32");
+ static_assert(std::is_signed<int_fast32_t>::value,
+ "std::is_signed<int_fast32_t>::value");
+ // typedef int_fast64_t
+ static_assert(sizeof(int_fast64_t)*CHAR_BIT >= 64,
+ "sizeof(int_fast64_t)*CHAR_BIT >= 64");
+ static_assert(std::is_signed<int_fast64_t>::value,
+ "std::is_signed<int_fast64_t>::value");
+
+ // typedef uint_fast8_t
+ static_assert(sizeof(uint_fast8_t)*CHAR_BIT >= 8,
+ "sizeof(uint_fast8_t)*CHAR_BIT >= 8");
+ static_assert(std::is_unsigned<uint_fast8_t>::value,
+ "std::is_unsigned<uint_fast8_t>::value");
+ // typedef uint_fast16_t
+ static_assert(sizeof(uint_fast16_t)*CHAR_BIT >= 16,
+ "sizeof(uint_fast16_t)*CHAR_BIT >= 16");
+ static_assert(std::is_unsigned<uint_fast16_t>::value,
+ "std::is_unsigned<uint_fast16_t>::value");
+ // typedef uint_fast32_t
+ static_assert(sizeof(uint_fast32_t)*CHAR_BIT >= 32,
+ "sizeof(uint_fast32_t)*CHAR_BIT >= 32");
+ static_assert(std::is_unsigned<uint_fast32_t>::value,
+ "std::is_unsigned<uint_fast32_t>::value");
+ // typedef uint_fast64_t
+ static_assert(sizeof(uint_fast64_t)*CHAR_BIT >= 64,
+ "sizeof(uint_fast64_t)*CHAR_BIT >= 64");
+ static_assert(std::is_unsigned<uint_fast64_t>::value,
+ "std::is_unsigned<uint_fast64_t>::value");
+
+ // typedef intptr_t
+ static_assert(sizeof(intptr_t) >= sizeof(void*),
+ "sizeof(intptr_t) >= sizeof(void*)");
+ static_assert(std::is_signed<intptr_t>::value,
+ "std::is_signed<intptr_t>::value");
+ // typedef uintptr_t
+ static_assert(sizeof(uintptr_t) >= sizeof(void*),
+ "sizeof(uintptr_t) >= sizeof(void*)");
+ static_assert(std::is_unsigned<uintptr_t>::value,
+ "std::is_unsigned<uintptr_t>::value");
+
+ // typedef intmax_t
+ static_assert(sizeof(intmax_t) >= sizeof(long long),
+ "sizeof(intmax_t) >= sizeof(long long)");
+ static_assert(std::is_signed<intmax_t>::value,
+ "std::is_signed<intmax_t>::value");
+ // typedef uintmax_t
+ static_assert(sizeof(uintmax_t) >= sizeof(unsigned long long),
+ "sizeof(uintmax_t) >= sizeof(unsigned long long)");
+ static_assert(std::is_unsigned<uintmax_t>::value,
+ "std::is_unsigned<uintmax_t>::value");
+
+ // INTN_MIN
+ static_assert(INT8_MIN == -128, "INT8_MIN == -128");
+ static_assert(INT16_MIN == -32768, "INT16_MIN == -32768");
+ static_assert(INT32_MIN == -2147483648U, "INT32_MIN == -2147483648");
+ static_assert(INT64_MIN == -9223372036854775808ULL, "INT64_MIN == -9223372036854775808LL");
+
+ // INTN_MAX
+ static_assert(INT8_MAX == 127, "INT8_MAX == 127");
+ static_assert(INT16_MAX == 32767, "INT16_MAX == 32767");
+ static_assert(INT32_MAX == 2147483647, "INT32_MAX == 2147483647");
+ static_assert(INT64_MAX == 9223372036854775807LL, "INT64_MAX == 9223372036854775807LL");
+
+ // UINTN_MAX
+ static_assert(UINT8_MAX == 255, "UINT8_MAX == 255");
+ static_assert(UINT16_MAX == 65535, "UINT16_MAX == 65535");
+ static_assert(UINT32_MAX == 4294967295U, "UINT32_MAX == 4294967295");
+ static_assert(UINT64_MAX == 18446744073709551615ULL, "UINT64_MAX == 18446744073709551615ULL");
+
+ // INT_FASTN_MIN
+ static_assert(INT_FAST8_MIN <= -128, "INT_FAST8_MIN <= -128");
+ static_assert(INT_FAST16_MIN <= -32768, "INT_FAST16_MIN <= -32768");
+ static_assert(INT_FAST32_MIN <= -2147483648U, "INT_FAST32_MIN <= -2147483648");
+ static_assert(INT_FAST64_MIN <= -9223372036854775808ULL, "INT_FAST64_MIN <= -9223372036854775808LL");
+
+ // INT_FASTN_MAX
+ static_assert(INT_FAST8_MAX >= 127, "INT_FAST8_MAX >= 127");
+ static_assert(INT_FAST16_MAX >= 32767, "INT_FAST16_MAX >= 32767");
+ static_assert(INT_FAST32_MAX >= 2147483647, "INT_FAST32_MAX >= 2147483647");
+ static_assert(INT_FAST64_MAX >= 9223372036854775807LL, "INT_FAST64_MAX >= 9223372036854775807LL");
+
+ // UINT_FASTN_MAX
+ static_assert(UINT_FAST8_MAX >= 255, "UINT_FAST8_MAX >= 255");
+ static_assert(UINT_FAST16_MAX >= 65535, "UINT_FAST16_MAX >= 65535");
+ static_assert(UINT_FAST32_MAX >= 4294967295U, "UINT_FAST32_MAX >= 4294967295");
+ static_assert(UINT_FAST64_MAX >= 18446744073709551615ULL, "UINT_FAST64_MAX >= 18446744073709551615ULL");
+
+ // INTPTR_MIN
+ assert(INTPTR_MIN == std::numeric_limits<intptr_t>::min());
+
+ // INTPTR_MAX
+ assert(INTPTR_MAX == std::numeric_limits<intptr_t>::max());
+
+ // UINTPTR_MAX
+ assert(UINTPTR_MAX == std::numeric_limits<uintptr_t>::max());
+
+ // INTMAX_MIN
+ assert(INTMAX_MIN == std::numeric_limits<intmax_t>::min());
+
+ // INTMAX_MAX
+ assert(INTMAX_MAX == std::numeric_limits<intmax_t>::max());
+
+ // UINTMAX_MAX
+ assert(UINTMAX_MAX == std::numeric_limits<uintmax_t>::max());
+
+ // PTRDIFF_MIN
+ assert(PTRDIFF_MIN == std::numeric_limits<ptrdiff_t>::min());
+
+ // PTRDIFF_MAX
+ assert(PTRDIFF_MAX == std::numeric_limits<ptrdiff_t>::max());
+
+ // SIG_ATOMIC_MIN
+ assert(SIG_ATOMIC_MIN == std::numeric_limits<sig_atomic_t>::min());
+
+ // SIG_ATOMIC_MAX
+ assert(SIG_ATOMIC_MAX == std::numeric_limits<sig_atomic_t>::max());
+
+ // SIZE_MAX
+ assert(SIZE_MAX == std::numeric_limits<size_t>::max());
+
+ // WCHAR_MIN
+ assert(WCHAR_MIN == std::numeric_limits<wchar_t>::min());
+
+ // WCHAR_MAX
+ assert(WCHAR_MAX == std::numeric_limits<wchar_t>::max());
+
+ // WINT_MIN
+ assert(WINT_MIN == std::numeric_limits<wint_t>::min());
+
+ // WINT_MAX
+ assert(WINT_MAX == std::numeric_limits<wint_t>::max());
+
+#ifndef INT8_C
+#error INT8_C not defined
+#endif
+
+#ifndef INT16_C
+#error INT16_C not defined
+#endif
+
+#ifndef INT32_C
+#error INT32_C not defined
+#endif
+
+#ifndef INT64_C
+#error INT64_C not defined
+#endif
+
+#ifndef UINT8_C
+#error UINT8_C not defined
+#endif
+
+#ifndef UINT16_C
+#error UINT16_C not defined
+#endif
+
+#ifndef UINT32_C
+#error UINT32_C not defined
+#endif
+
+#ifndef UINT64_C
+#error UINT64_C not defined
+#endif
+
+#ifndef INTMAX_C
+#error INTMAX_C not defined
+#endif
+
+#ifndef UINTMAX_C
+#error UINTMAX_C not defined
+#endif
+}
diff --git a/test/std/depr/depr.c.headers/stdio_h.pass.cpp b/test/std/depr/depr.c.headers/stdio_h.pass.cpp
new file mode 100644
index 000000000000..d4cfbc80a5ce
--- /dev/null
+++ b/test/std/depr/depr.c.headers/stdio_h.pass.cpp
@@ -0,0 +1,138 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test <stdio.h>
+
+#include <stdio.h>
+#include <type_traits>
+
+#ifndef BUFSIZ
+#error BUFSIZ not defined
+#endif
+
+#ifndef EOF
+#error EOF not defined
+#endif
+
+#ifndef FILENAME_MAX
+#error FILENAME_MAX not defined
+#endif
+
+#ifndef FOPEN_MAX
+#error FOPEN_MAX not defined
+#endif
+
+#ifndef L_tmpnam
+#error L_tmpnam not defined
+#endif
+
+#ifndef NULL
+#error NULL not defined
+#endif
+
+#ifndef SEEK_CUR
+#error SEEK_CUR not defined
+#endif
+
+#ifndef SEEK_END
+#error SEEK_END not defined
+#endif
+
+#ifndef SEEK_SET
+#error SEEK_SET not defined
+#endif
+
+#ifndef TMP_MAX
+#error TMP_MAX not defined
+#endif
+
+#ifndef _IOFBF
+#error _IOFBF not defined
+#endif
+
+#ifndef _IOLBF
+#error _IOLBF not defined
+#endif
+
+#ifndef _IONBF
+#error _IONBF not defined
+#endif
+
+#ifndef stderr
+#error stderr not defined
+#endif
+
+#ifndef stdin
+#error stdin not defined
+#endif
+
+#ifndef stdout
+#error stdout not defined
+#endif
+
+#include <cstdarg>
+
+#pragma clang diagnostic ignored "-Wformat-zero-length"
+
+int main()
+{
+ FILE* fp = 0;
+ fpos_t fpos = {0};
+ size_t s = 0;
+ char* cp = 0;
+ va_list va;
+ static_assert((std::is_same<decltype(remove("")), int>::value), "");
+ static_assert((std::is_same<decltype(rename("","")), int>::value), "");
+ static_assert((std::is_same<decltype(tmpfile()), FILE*>::value), "");
+ static_assert((std::is_same<decltype(tmpnam(cp)), char*>::value), "");
+ static_assert((std::is_same<decltype(fclose(fp)), int>::value), "");
+ static_assert((std::is_same<decltype(fflush(fp)), int>::value), "");
+ static_assert((std::is_same<decltype(fopen("", "")), FILE*>::value), "");
+ static_assert((std::is_same<decltype(freopen("", "", fp)), FILE*>::value), "");
+ static_assert((std::is_same<decltype(setbuf(fp,cp)), void>::value), "");
+ static_assert((std::is_same<decltype(vfprintf(fp,"",va)), int>::value), "");
+ static_assert((std::is_same<decltype(fprintf(fp," ")), int>::value), "");
+ static_assert((std::is_same<decltype(fscanf(fp,"")), int>::value), "");
+ static_assert((std::is_same<decltype(printf("\n")), int>::value), "");
+ static_assert((std::is_same<decltype(scanf("\n")), int>::value), "");
+ static_assert((std::is_same<decltype(snprintf(cp,0,"p")), int>::value), "");
+ static_assert((std::is_same<decltype(sprintf(cp," ")), int>::value), "");
+ static_assert((std::is_same<decltype(sscanf("","")), int>::value), "");
+ static_assert((std::is_same<decltype(vfprintf(fp,"",va)), int>::value), "");
+ static_assert((std::is_same<decltype(vfscanf(fp,"",va)), int>::value), "");
+ static_assert((std::is_same<decltype(vprintf(" ",va)), int>::value), "");
+ static_assert((std::is_same<decltype(vscanf("",va)), int>::value), "");
+ static_assert((std::is_same<decltype(vsnprintf(cp,0," ",va)), int>::value), "");
+ static_assert((std::is_same<decltype(vsprintf(cp," ",va)), int>::value), "");
+ static_assert((std::is_same<decltype(vsscanf("","",va)), int>::value), "");
+ static_assert((std::is_same<decltype(fgetc(fp)), int>::value), "");
+ static_assert((std::is_same<decltype(fgets(cp,0,fp)), char*>::value), "");
+ static_assert((std::is_same<decltype(fputc(0,fp)), int>::value), "");
+ static_assert((std::is_same<decltype(fputs("",fp)), int>::value), "");
+ static_assert((std::is_same<decltype(getc(fp)), int>::value), "");
+ static_assert((std::is_same<decltype(getchar()), int>::value), "");
+#if _LIBCPP_STD_VER < 14
+ static_assert((std::is_same<decltype(gets(cp)), char*>::value), "");
+#endif
+ static_assert((std::is_same<decltype(putc(0,fp)), int>::value), "");
+ static_assert((std::is_same<decltype(putchar(0)), int>::value), "");
+ static_assert((std::is_same<decltype(puts("")), int>::value), "");
+ static_assert((std::is_same<decltype(ungetc(0,fp)), int>::value), "");
+ static_assert((std::is_same<decltype(fread((void*)0,0,0,fp)), size_t>::value), "");
+ static_assert((std::is_same<decltype(fwrite((const void*)0,0,0,fp)), size_t>::value), "");
+ static_assert((std::is_same<decltype(fgetpos(fp, &fpos)), int>::value), "");
+ static_assert((std::is_same<decltype(fseek(fp, 0,0)), int>::value), "");
+ static_assert((std::is_same<decltype(fsetpos(fp, &fpos)), int>::value), "");
+ static_assert((std::is_same<decltype(ftell(fp)), long>::value), "");
+ static_assert((std::is_same<decltype(rewind(fp)), void>::value), "");
+ static_assert((std::is_same<decltype(clearerr(fp)), void>::value), "");
+ static_assert((std::is_same<decltype(feof(fp)), int>::value), "");
+ static_assert((std::is_same<decltype(ferror(fp)), int>::value), "");
+ static_assert((std::is_same<decltype(perror("")), void>::value), "");
+}
diff --git a/test/std/depr/depr.c.headers/stdlib_h.pass.cpp b/test/std/depr/depr.c.headers/stdlib_h.pass.cpp
new file mode 100644
index 000000000000..47e1527fb175
--- /dev/null
+++ b/test/std/depr/depr.c.headers/stdlib_h.pass.cpp
@@ -0,0 +1,84 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test <stdlib.h>
+
+#include <stdlib.h>
+#include <type_traits>
+
+#ifndef EXIT_FAILURE
+#error EXIT_FAILURE not defined
+#endif
+
+#ifndef EXIT_SUCCESS
+#error EXIT_SUCCESS not defined
+#endif
+
+#ifndef MB_CUR_MAX
+#error MB_CUR_MAX not defined
+#endif
+
+#ifndef NULL
+#error NULL not defined
+#endif
+
+#ifndef RAND_MAX
+#error RAND_MAX not defined
+#endif
+
+int main()
+{
+ size_t s = 0;
+ div_t d;
+ ldiv_t ld;
+ lldiv_t lld;
+ char** endptr = 0;
+ static_assert((std::is_same<decltype(atof("")), double>::value), "");
+ static_assert((std::is_same<decltype(atoi("")), int>::value), "");
+ static_assert((std::is_same<decltype(atol("")), long>::value), "");
+ static_assert((std::is_same<decltype(atoll("")), long long>::value), "");
+ static_assert((std::is_same<decltype(getenv("")), char*>::value), "");
+ static_assert((std::is_same<decltype(strtod("", endptr)), double>::value), "");
+ static_assert((std::is_same<decltype(strtof("", endptr)), float>::value), "");
+ static_assert((std::is_same<decltype(strtold("", endptr)), long double>::value), "");
+ static_assert((std::is_same<decltype(strtol("", endptr,0)), long>::value), "");
+ static_assert((std::is_same<decltype(strtoll("", endptr,0)), long long>::value), "");
+ static_assert((std::is_same<decltype(strtoul("", endptr,0)), unsigned long>::value), "");
+ static_assert((std::is_same<decltype(strtoull("", endptr,0)), unsigned long long>::value), "");
+ static_assert((std::is_same<decltype(rand()), int>::value), "");
+ static_assert((std::is_same<decltype(srand(0)), void>::value), "");
+ static_assert((std::is_same<decltype(calloc(0,0)), void*>::value), "");
+ static_assert((std::is_same<decltype(free(0)), void>::value), "");
+ static_assert((std::is_same<decltype(malloc(0)), void*>::value), "");
+ static_assert((std::is_same<decltype(realloc(0,0)), void*>::value), "");
+ static_assert((std::is_same<decltype(abort()), void>::value), "");
+ static_assert((std::is_same<decltype(atexit(0)), int>::value), "");
+ static_assert((std::is_same<decltype(exit(0)), void>::value), "");
+ static_assert((std::is_same<decltype(_Exit(0)), void>::value), "");
+ static_assert((std::is_same<decltype(getenv("")), char*>::value), "");
+ static_assert((std::is_same<decltype(system("")), int>::value), "");
+ static_assert((std::is_same<decltype(bsearch(0,0,0,0,0)), void*>::value), "");
+ static_assert((std::is_same<decltype(qsort(0,0,0,0)), void>::value), "");
+ static_assert((std::is_same<decltype(abs(0)), int>::value), "");
+ static_assert((std::is_same<decltype(labs((long)0)), long>::value), "");
+ static_assert((std::is_same<decltype(llabs((long long)0)), long long>::value), "");
+ static_assert((std::is_same<decltype(div(0,0)), div_t>::value), "");
+ static_assert((std::is_same<decltype(ldiv(0L,0L)), ldiv_t>::value), "");
+ static_assert((std::is_same<decltype(lldiv(0LL,0LL)), lldiv_t>::value), "");
+ wchar_t* pw = 0;
+ const wchar_t* pwc = 0;
+ char* pc = 0;
+#ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
+ static_assert((std::is_same<decltype(mblen("",0)), int>::value), "");
+ static_assert((std::is_same<decltype(mbtowc(pw,"",0)), int>::value), "");
+ static_assert((std::is_same<decltype(wctomb(pc,L' ')), int>::value), "");
+#endif
+ static_assert((std::is_same<decltype(mbstowcs(pw,"",0)), size_t>::value), "");
+ static_assert((std::is_same<decltype(wcstombs(pc,pwc,0)), size_t>::value), "");
+}
diff --git a/test/std/depr/depr.c.headers/string_h.pass.cpp b/test/std/depr/depr.c.headers/string_h.pass.cpp
new file mode 100644
index 000000000000..afc784f74b89
--- /dev/null
+++ b/test/std/depr/depr.c.headers/string_h.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string.h>
+
+#include <string.h>
+#include <type_traits>
+
+#ifndef NULL
+#error NULL not defined
+#endif
+
+int main()
+{
+ size_t s = 0;
+ void* vp = 0;
+ const void* vpc = 0;
+ char* cp = 0;
+ const char* cpc = 0;
+ static_assert((std::is_same<decltype(memcpy(vp, vpc, s)), void*>::value), "");
+ static_assert((std::is_same<decltype(memmove(vp, vpc, s)), void*>::value), "");
+ static_assert((std::is_same<decltype(strcpy(cp, cpc)), char*>::value), "");
+ static_assert((std::is_same<decltype(strncpy(cp, cpc, s)), char*>::value), "");
+ static_assert((std::is_same<decltype(strcat(cp, cpc)), char*>::value), "");
+ static_assert((std::is_same<decltype(strncat(cp, cpc, s)), char*>::value), "");
+ static_assert((std::is_same<decltype(memcmp(vpc, vpc, s)), int>::value), "");
+ static_assert((std::is_same<decltype(strcmp(cpc, cpc)), int>::value), "");
+ static_assert((std::is_same<decltype(strncmp(cpc, cpc, s)), int>::value), "");
+ static_assert((std::is_same<decltype(strcoll(cpc, cpc)), int>::value), "");
+ static_assert((std::is_same<decltype(strxfrm(cp, cpc, s)), size_t>::value), "");
+ static_assert((std::is_same<decltype(memchr(vp, 0, s)), void*>::value), "");
+ static_assert((std::is_same<decltype(strchr(cp, 0)), char*>::value), "");
+ static_assert((std::is_same<decltype(strcspn(cpc, cpc)), size_t>::value), "");
+ static_assert((std::is_same<decltype(strpbrk(cp, cpc)), char*>::value), "");
+ static_assert((std::is_same<decltype(strrchr(cp, 0)), char*>::value), "");
+ static_assert((std::is_same<decltype(strspn(cpc, cpc)), size_t>::value), "");
+ static_assert((std::is_same<decltype(strstr(cp, cpc)), char*>::value), "");
+#ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
+ static_assert((std::is_same<decltype(strtok(cp, cpc)), char*>::value), "");
+#endif
+ static_assert((std::is_same<decltype(memset(vp, 0, s)), void*>::value), "");
+ static_assert((std::is_same<decltype(strerror(0)), char*>::value), "");
+ static_assert((std::is_same<decltype(strlen(cpc)), size_t>::value), "");
+}
diff --git a/test/std/depr/depr.c.headers/tgmath_h.pass.cpp b/test/std/depr/depr.c.headers/tgmath_h.pass.cpp
new file mode 100644
index 000000000000..a2ef814dcae1
--- /dev/null
+++ b/test/std/depr/depr.c.headers/tgmath_h.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tgmath.h>
+
+#include <tgmath.h>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+ std::complex<double> cd;
+ double x = sin(1.0);
+ (void)x; // to placate scan-build
+}
diff --git a/test/std/depr/depr.c.headers/time_h.pass.cpp b/test/std/depr/depr.c.headers/time_h.pass.cpp
new file mode 100644
index 000000000000..c468693ccb26
--- /dev/null
+++ b/test/std/depr/depr.c.headers/time_h.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test <time.h>
+
+#include <time.h>
+#include <type_traits>
+
+#ifndef NULL
+#error NULL not defined
+#endif
+
+#ifndef CLOCKS_PER_SEC
+#error CLOCKS_PER_SEC not defined
+#endif
+
+int main()
+{
+ clock_t c = 0;
+ size_t s = 0;
+ time_t t = 0;
+ tm tmv = {0};
+ static_assert((std::is_same<decltype(clock()), clock_t>::value), "");
+ static_assert((std::is_same<decltype(difftime(t,t)), double>::value), "");
+ static_assert((std::is_same<decltype(mktime(&tmv)), time_t>::value), "");
+ static_assert((std::is_same<decltype(time(&t)), time_t>::value), "");
+ static_assert((std::is_same<decltype(asctime(&tmv)), char*>::value), "");
+ static_assert((std::is_same<decltype(ctime(&t)), char*>::value), "");
+ static_assert((std::is_same<decltype(gmtime(&t)), tm*>::value), "");
+ static_assert((std::is_same<decltype(localtime(&t)), tm*>::value), "");
+ char* c1 = 0;
+ const char* c2 = 0;
+ static_assert((std::is_same<decltype(strftime(c1,s,c2,&tmv)), size_t>::value), "");
+}
diff --git a/test/std/depr/depr.c.headers/uchar_h.pass.cpp b/test/std/depr/depr.c.headers/uchar_h.pass.cpp
new file mode 100644
index 000000000000..f5f69f8e553b
--- /dev/null
+++ b/test/std/depr/depr.c.headers/uchar_h.pass.cpp
@@ -0,0 +1,19 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// XFAIL: apple-darwin
+// XFAIL: newlib
+
+// <uchar.h>
+
+#include <uchar.h>
+
+int main()
+{
+}
diff --git a/test/std/depr/depr.c.headers/wchar_h.pass.cpp b/test/std/depr/depr.c.headers/wchar_h.pass.cpp
new file mode 100644
index 000000000000..68bea49cfe03
--- /dev/null
+++ b/test/std/depr/depr.c.headers/wchar_h.pass.cpp
@@ -0,0 +1,104 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <wchar.h>
+
+#include <wchar.h>
+#include <type_traits>
+
+#ifndef NULL
+#error NULL not defined
+#endif
+
+#ifndef WCHAR_MAX
+#error WCHAR_MAX not defined
+#endif
+
+#ifndef WCHAR_MIN
+#error WCHAR_MIN not defined
+#endif
+
+#ifndef WEOF
+#error WEOF not defined
+#endif
+
+int main()
+{
+ mbstate_t mb = {0};
+ size_t s = 0;
+ tm *tm = 0;
+ wint_t w = 0;
+ ::FILE* fp = 0;
+#ifdef __APPLE__
+ __darwin_va_list va;
+#else
+ __builtin_va_list va;
+#endif
+ char* ns = 0;
+ wchar_t* ws = 0;
+ static_assert((std::is_same<decltype(fwprintf(fp, L"")), int>::value), "");
+ static_assert((std::is_same<decltype(fwscanf(fp, L"")), int>::value), "");
+ static_assert((std::is_same<decltype(swprintf(ws, s, L"")), int>::value), "");
+ static_assert((std::is_same<decltype(swscanf(L"", L"")), int>::value), "");
+ static_assert((std::is_same<decltype(vfwprintf(fp, L"", va)), int>::value), "");
+ static_assert((std::is_same<decltype(vfwscanf(fp, L"", va)), int>::value), "");
+ static_assert((std::is_same<decltype(vswprintf(ws, s, L"", va)), int>::value), "");
+ static_assert((std::is_same<decltype(vswscanf(L"", L"", va)), int>::value), "");
+ static_assert((std::is_same<decltype(vwprintf(L"", va)), int>::value), "");
+ static_assert((std::is_same<decltype(vwscanf(L"", va)), int>::value), "");
+ static_assert((std::is_same<decltype(wprintf(L"")), int>::value), "");
+ static_assert((std::is_same<decltype(wscanf(L"")), int>::value), "");
+ static_assert((std::is_same<decltype(fgetwc(fp)), wint_t>::value), "");
+ static_assert((std::is_same<decltype(fgetws(ws, 0, fp)), wchar_t*>::value), "");
+ static_assert((std::is_same<decltype(fputwc(L' ', fp)), wint_t>::value), "");
+ static_assert((std::is_same<decltype(fputws(L"", fp)), int>::value), "");
+ static_assert((std::is_same<decltype(fwide(fp, 0)), int>::value), "");
+ static_assert((std::is_same<decltype(getwc(fp)), wint_t>::value), "");
+ static_assert((std::is_same<decltype(getwchar()), wint_t>::value), "");
+ static_assert((std::is_same<decltype(putwc(L' ', fp)), wint_t>::value), "");
+ static_assert((std::is_same<decltype(putwchar(L' ')), wint_t>::value), "");
+ static_assert((std::is_same<decltype(ungetwc(L' ', fp)), wint_t>::value), "");
+ static_assert((std::is_same<decltype(wcstod(L"", (wchar_t**)0)), double>::value), "");
+ static_assert((std::is_same<decltype(wcstof(L"", (wchar_t**)0)), float>::value), "");
+ static_assert((std::is_same<decltype(wcstold(L"", (wchar_t**)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(wcstol(L"", (wchar_t**)0, 0)), long>::value), "");
+ static_assert((std::is_same<decltype(wcstoll(L"", (wchar_t**)0, 0)), long long>::value), "");
+ static_assert((std::is_same<decltype(wcstoul(L"", (wchar_t**)0, 0)), unsigned long>::value), "");
+ static_assert((std::is_same<decltype(wcstoull(L"", (wchar_t**)0, 0)), unsigned long long>::value), "");
+ static_assert((std::is_same<decltype(wcscpy(ws, L"")), wchar_t*>::value), "");
+ static_assert((std::is_same<decltype(wcsncpy(ws, L"", s)), wchar_t*>::value), "");
+ static_assert((std::is_same<decltype(wcscat(ws, L"")), wchar_t*>::value), "");
+ static_assert((std::is_same<decltype(wcsncat(ws, L"", s)), wchar_t*>::value), "");
+ static_assert((std::is_same<decltype(wcscmp(L"", L"")), int>::value), "");
+ static_assert((std::is_same<decltype(wcscoll(L"", L"")), int>::value), "");
+ static_assert((std::is_same<decltype(wcsncmp(L"", L"", s)), int>::value), "");
+ static_assert((std::is_same<decltype(wcsxfrm(ws, L"", s)), size_t>::value), "");
+ static_assert((std::is_same<decltype(wcschr((wchar_t*)0, L' ')), wchar_t*>::value), "");
+ static_assert((std::is_same<decltype(wcscspn(L"", L"")), size_t>::value), "");
+ static_assert((std::is_same<decltype(wcslen(L"")), size_t>::value), "");
+ static_assert((std::is_same<decltype(wcspbrk((wchar_t*)0, L"")), wchar_t*>::value), "");
+ static_assert((std::is_same<decltype(wcsrchr((wchar_t*)0, L' ')), wchar_t*>::value), "");
+ static_assert((std::is_same<decltype(wcsspn(L"", L"")), size_t>::value), "");
+ static_assert((std::is_same<decltype(wcsstr((wchar_t*)0, L"")), wchar_t*>::value), "");
+ static_assert((std::is_same<decltype(wcstok(ws, L"", (wchar_t**)0)), wchar_t*>::value), "");
+ static_assert((std::is_same<decltype(wmemchr((wchar_t*)0, L' ', s)), wchar_t*>::value), "");
+ static_assert((std::is_same<decltype(wmemcmp(L"", L"", s)), int>::value), "");
+ static_assert((std::is_same<decltype(wmemcpy(ws, L"", s)), wchar_t*>::value), "");
+ static_assert((std::is_same<decltype(wmemmove(ws, L"", s)), wchar_t*>::value), "");
+ static_assert((std::is_same<decltype(wmemset(ws, L' ', s)), wchar_t*>::value), "");
+ static_assert((std::is_same<decltype(wcsftime(ws, s, L"", tm)), size_t>::value), "");
+ static_assert((std::is_same<decltype(btowc(0)), wint_t>::value), "");
+ static_assert((std::is_same<decltype(wctob(w)), int>::value), "");
+ static_assert((std::is_same<decltype(mbsinit(&mb)), int>::value), "");
+ static_assert((std::is_same<decltype(mbrlen("", s, &mb)), size_t>::value), "");
+ static_assert((std::is_same<decltype(mbrtowc(ws, "", s, &mb)), size_t>::value), "");
+ static_assert((std::is_same<decltype(wcrtomb(ns, L' ', &mb)), size_t>::value), "");
+ static_assert((std::is_same<decltype(mbsrtowcs(ws, (const char**)0, s, &mb)), size_t>::value), "");
+ static_assert((std::is_same<decltype(wcsrtombs(ns, (const wchar_t**)0, s, &mb)), size_t>::value), "");
+}
diff --git a/test/std/depr/depr.c.headers/wctype_h.pass.cpp b/test/std/depr/depr.c.headers/wctype_h.pass.cpp
new file mode 100644
index 000000000000..ad3107100f06
--- /dev/null
+++ b/test/std/depr/depr.c.headers/wctype_h.pass.cpp
@@ -0,0 +1,114 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <wctype.h>
+
+#include <wctype.h>
+#include <type_traits>
+
+#ifndef WEOF
+#error WEOF not defined
+#endif
+
+#ifdef iswalnum
+#error iswalnum defined
+#endif
+
+#ifdef iswalpha
+#error iswalpha defined
+#endif
+
+#ifdef iswblank
+#error iswblank defined
+#endif
+
+#ifdef iswcntrl
+#error iswcntrl defined
+#endif
+
+#ifdef iswdigit
+#error iswdigit defined
+#endif
+
+#ifdef iswgraph
+#error iswgraph defined
+#endif
+
+#ifdef iswlower
+#error iswlower defined
+#endif
+
+#ifdef iswprint
+#error iswprint defined
+#endif
+
+#ifdef iswpunct
+#error iswpunct defined
+#endif
+
+#ifdef iswspace
+#error iswspace defined
+#endif
+
+#ifdef iswupper
+#error iswupper defined
+#endif
+
+#ifdef iswxdigit
+#error iswxdigit defined
+#endif
+
+#ifdef iswctype
+#error iswctype defined
+#endif
+
+#ifdef wctype
+#error wctype defined
+#endif
+
+#ifdef towlower
+#error towlower defined
+#endif
+
+#ifdef towupper
+#error towupper defined
+#endif
+
+#ifdef towctrans
+#error towctrans defined
+#endif
+
+#ifdef wctrans
+#error wctrans defined
+#endif
+
+int main()
+{
+ wint_t w = 0;
+ wctrans_t wctr = 0;
+ wctype_t wct = 0;
+ static_assert((std::is_same<decltype(iswalnum(w)), int>::value), "");
+ static_assert((std::is_same<decltype(iswalpha(w)), int>::value), "");
+ static_assert((std::is_same<decltype(iswblank(w)), int>::value), "");
+ static_assert((std::is_same<decltype(iswcntrl(w)), int>::value), "");
+ static_assert((std::is_same<decltype(iswdigit(w)), int>::value), "");
+ static_assert((std::is_same<decltype(iswgraph(w)), int>::value), "");
+ static_assert((std::is_same<decltype(iswlower(w)), int>::value), "");
+ static_assert((std::is_same<decltype(iswprint(w)), int>::value), "");
+ static_assert((std::is_same<decltype(iswpunct(w)), int>::value), "");
+ static_assert((std::is_same<decltype(iswspace(w)), int>::value), "");
+ static_assert((std::is_same<decltype(iswupper(w)), int>::value), "");
+ static_assert((std::is_same<decltype(iswxdigit(w)), int>::value), "");
+ static_assert((std::is_same<decltype(iswctype(w, wct)), int>::value), "");
+ static_assert((std::is_same<decltype(wctype("")), wctype_t>::value), "");
+ static_assert((std::is_same<decltype(towlower(w)), wint_t>::value), "");
+ static_assert((std::is_same<decltype(towupper(w)), wint_t>::value), "");
+ static_assert((std::is_same<decltype(towctrans(w, wctr)), wint_t>::value), "");
+ static_assert((std::is_same<decltype(wctrans("")), wctrans_t>::value), "");
+}
diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/pointer_to_binary_function.pass.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/pointer_to_binary_function.pass.cpp
new file mode 100644
index 000000000000..41c99998caeb
--- /dev/null
+++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/pointer_to_binary_function.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// pointer_to_binary_function
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+double binary_f(int i, short j) {return i - j + .75;}
+
+int main()
+{
+ typedef std::pointer_to_binary_function<int, short, double> F;
+ static_assert((std::is_base_of<std::binary_function<int, short, double>, F>::value), "");
+ const F f(binary_f);
+ assert(f(36, 27) == 9.75);
+}
diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/pointer_to_unary_function.pass.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/pointer_to_unary_function.pass.cpp
new file mode 100644
index 000000000000..126cf32af436
--- /dev/null
+++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/pointer_to_unary_function.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// pointer_to_unary_function
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+double unary_f(int i) {return 0.5 - i;}
+
+int main()
+{
+ typedef std::pointer_to_unary_function<int, double> F;
+ static_assert((std::is_base_of<std::unary_function<int, double>, F>::value), "");
+ const F f(unary_f);
+ assert(f(36) == -35.5);
+}
diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/ptr_fun1.pass.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/ptr_fun1.pass.cpp
new file mode 100644
index 000000000000..c7ce90df3eb7
--- /dev/null
+++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/ptr_fun1.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template <CopyConstructible Arg, Returnable Result>
+// pointer_to_unary_function<Arg, Result>
+// ptr_fun(Result (*f)(Arg));
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+double unary_f(int i) {return 0.5 - i;}
+
+int main()
+{
+ assert(std::ptr_fun(unary_f)(36) == -35.5);
+}
diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/ptr_fun2.pass.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/ptr_fun2.pass.cpp
new file mode 100644
index 000000000000..17c4b611a319
--- /dev/null
+++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/ptr_fun2.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template <CopyConstructible Arg1, CopyConstructible Arg2, Returnable Result>
+// pointer_to_binary_function<Arg1,Arg2,Result>
+// ptr_fun(Result (*f)(Arg1, Arg2));
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+double binary_f(int i, short j) {return i - j + .75;}
+
+int main()
+{
+ assert(std::ptr_fun(binary_f)(36, 27) == 9.75);
+}
diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun.pass.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun.pass.cpp
new file mode 100644
index 000000000000..455eed9b3e3c
--- /dev/null
+++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template<cReturnable S, ClassType T>
+// const_mem_fun_t<S,T>
+// mem_fun(S (T::*f)() const);
+
+#include <functional>
+#include <cassert>
+
+struct A
+{
+ char a1() {return 5;}
+ short a2(int i) {return short(i+1);}
+ int a3() const {return 1;}
+ double a4(unsigned i) const {return i-1;}
+};
+
+int main()
+{
+ const A a = A();
+ assert(std::mem_fun(&A::a3)(&a) == 1);
+}
diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1.pass.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1.pass.cpp
new file mode 100644
index 000000000000..46fd6d28d514
--- /dev/null
+++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template<Returnable S, ClassType T, CopyConstructible A>
+// const_mem_fun1_t<S,T,A>
+// mem_fun(S (T::*f)(A) const);
+
+#include <functional>
+#include <cassert>
+
+struct A
+{
+ char a1() {return 5;}
+ short a2(int i) {return short(i+1);}
+ int a3() const {return 1;}
+ double a4(unsigned i) const {return i-1;}
+};
+
+int main()
+{
+ const A a = A();
+ assert(std::mem_fun(&A::a4)(&a, 6) == 5);
+}
diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1_ref_t.pass.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1_ref_t.pass.cpp
new file mode 100644
index 000000000000..0c4bb93ff524
--- /dev/null
+++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1_ref_t.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// const_mem_fun1_ref_t
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+struct A
+{
+ char a1() {return 5;}
+ short a2(int i) {return short(i+1);}
+ int a3() const {return 1;}
+ double a4(unsigned i) const {return i-1;}
+};
+
+int main()
+{
+ typedef std::const_mem_fun1_ref_t<double, A, unsigned> F;
+ static_assert((std::is_base_of<std::binary_function<A, unsigned, double>, F>::value), "");
+ const F f(&A::a4);
+ const A a = A();
+ assert(f(a, 6) == 5);
+}
diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1_t.pass.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1_t.pass.cpp
new file mode 100644
index 000000000000..ca670bcde109
--- /dev/null
+++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1_t.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// const_mem_fun1_t
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+struct A
+{
+ char a1() {return 5;}
+ short a2(int i) {return short(i+1);}
+ int a3() const {return 1;}
+ double a4(unsigned i) const {return i-1;}
+};
+
+int main()
+{
+ typedef std::const_mem_fun1_t<double, A, unsigned> F;
+ static_assert((std::is_base_of<std::binary_function<const A*, unsigned, double>, F>::value), "");
+ const F f(&A::a4);
+ const A a = A();
+ assert(f(&a, 6) == 5);
+}
diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref.pass.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref.pass.cpp
new file mode 100644
index 000000000000..74d8950dea7f
--- /dev/null
+++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template<Returnable S, ClassType T>
+// const_mem_fun_ref_t<S,T>
+// mem_fun_ref(S (T::*f)() const);
+
+#include <functional>
+#include <cassert>
+
+struct A
+{
+ char a1() {return 5;}
+ short a2(int i) {return short(i+1);}
+ int a3() const {return 1;}
+ double a4(unsigned i) const {return i-1;}
+};
+
+int main()
+{
+ const A a = A();
+ assert(std::mem_fun_ref(&A::a3)(a) == 1);
+}
diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref1.pass.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref1.pass.cpp
new file mode 100644
index 000000000000..b858561ae757
--- /dev/null
+++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref1.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template<Returnable S, ClassType T, CopyConstructible A>
+// const_mem_fun1_ref_t<S,T,A>
+// mem_fun_ref(S (T::*f)(A) const);
+
+#include <functional>
+#include <cassert>
+
+struct A
+{
+ char a1() {return 5;}
+ short a2(int i) {return short(i+1);}
+ int a3() const {return 1;}
+ double a4(unsigned i) const {return i-1;}
+};
+
+int main()
+{
+ const A a = A();
+ assert(std::mem_fun_ref(&A::a4)(a, 6) == 5);
+}
diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref_t.pass.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref_t.pass.cpp
new file mode 100644
index 000000000000..9eec24e5743c
--- /dev/null
+++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref_t.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// const_mem_fun_ref_t
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+struct A
+{
+ char a1() {return 5;}
+ short a2(int i) {return short(i+1);}
+ int a3() const {return 1;}
+ double a4(unsigned i) const {return i-1;}
+};
+
+int main()
+{
+ typedef std::const_mem_fun_ref_t<int, A> F;
+ static_assert((std::is_base_of<std::unary_function<A, int>, F>::value), "");
+ const F f(&A::a3);
+ const A a = A();
+ assert(f(a) == 1);
+}
diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_t.pass.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_t.pass.cpp
new file mode 100644
index 000000000000..9681b74d7e61
--- /dev/null
+++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_t.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// const_mem_fun_t
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+struct A
+{
+ char a1() {return 5;}
+ short a2(int i) {return short(i+1);}
+ int a3() const {return 1;}
+ double a4(unsigned i) const {return i-1;}
+};
+
+int main()
+{
+ typedef std::const_mem_fun_t<int, A> F;
+ static_assert((std::is_base_of<std::unary_function<const A*, int>, F>::value), "");
+ const F f(&A::a3);
+ const A a = A();
+ assert(f(&a) == 1);
+}
diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun.pass.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun.pass.cpp
new file mode 100644
index 000000000000..d0d286009ada
--- /dev/null
+++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template<Returnable S, ClassType T>
+// mem_fun_t<S,T>
+// mem_fun(S (T::*f)());
+
+#include <functional>
+#include <cassert>
+
+struct A
+{
+ char a1() {return 5;}
+ short a2(int i) {return short(i+1);}
+ int a3() const {return 1;}
+ double a4(unsigned i) const {return i-1;}
+};
+
+int main()
+{
+ A a;
+ assert(std::mem_fun(&A::a1)(&a) == 5);
+}
diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1.pass.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1.pass.cpp
new file mode 100644
index 000000000000..acee9afeec7a
--- /dev/null
+++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template<Returnable S, ClassType T, CopyConstructible A>
+// mem_fun1_t<S,T,A>
+// mem_fun(S (T::*f)(A));
+
+#include <functional>
+#include <cassert>
+
+struct A
+{
+ char a1() {return 5;}
+ short a2(int i) {return short(i+1);}
+ int a3() const {return 1;}
+ double a4(unsigned i) const {return i-1;}
+};
+
+int main()
+{
+ A a;
+ assert(std::mem_fun(&A::a2)(&a, 5) == 6);
+}
diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1_ref_t.pass.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1_ref_t.pass.cpp
new file mode 100644
index 000000000000..a78cbf25c191
--- /dev/null
+++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1_ref_t.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// mem_fun1_ref_t
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+struct A
+{
+ char a1() {return 5;}
+ short a2(int i) {return short(i+1);}
+ int a3() const {return 1;}
+ double a4(unsigned i) const {return i-1;}
+};
+
+int main()
+{
+ typedef std::mem_fun1_ref_t<short, A, int> F;
+ static_assert((std::is_base_of<std::binary_function<A, int, short>, F>::value), "");
+ const F f(&A::a2);
+ A a;
+ assert(f(a, 5) == 6);
+}
diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1_t.pass.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1_t.pass.cpp
new file mode 100644
index 000000000000..90ba9bbf788d
--- /dev/null
+++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1_t.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// mem_fun1_t
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+struct A
+{
+ char a1() {return 5;}
+ short a2(int i) {return short(i+1);}
+ int a3() const {return 1;}
+ double a4(unsigned i) const {return i-1;}
+};
+
+int main()
+{
+ typedef std::mem_fun1_t<short, A, int> F;
+ static_assert((std::is_base_of<std::binary_function<A*, int, short>, F>::value), "");
+ const F f(&A::a2);
+ A a;
+ assert(f(&a, 5) == 6);
+}
diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref.pass.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref.pass.cpp
new file mode 100644
index 000000000000..d3843fc5344c
--- /dev/null
+++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template<Returnable S, ClassType T>
+// mem_fun_ref_t<S,T>
+// mem_fun_ref(S (T::*f)());
+
+#include <functional>
+#include <cassert>
+
+struct A
+{
+ char a1() {return 5;}
+ short a2(int i) {return short(i+1);}
+ int a3() const {return 1;}
+ double a4(unsigned i) const {return i-1;}
+};
+
+int main()
+{
+ A a;
+ assert(std::mem_fun_ref(&A::a1)(a) == 5);
+}
diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref1.pass.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref1.pass.cpp
new file mode 100644
index 000000000000..39a324d10bc4
--- /dev/null
+++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref1.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template<Returnable S, ClassType T, CopyConstructible A>
+// mem_fun1_ref_t<S,T,A>
+// mem_fun_ref(S (T::*f)(A));
+
+#include <functional>
+#include <cassert>
+
+struct A
+{
+ char a1() {return 5;}
+ short a2(int i) {return short(i+1);}
+ int a3() const {return 1;}
+ double a4(unsigned i) const {return i-1;}
+};
+
+int main()
+{
+ A a;
+ assert(std::mem_fun_ref(&A::a2)(a, 5) == 6);
+}
diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref_t.pass.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref_t.pass.cpp
new file mode 100644
index 000000000000..236d8d0945fb
--- /dev/null
+++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref_t.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// mem_fun_ref_t
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+struct A
+{
+ char a1() {return 5;}
+ short a2(int i) {return short(i+1);}
+ int a3() const {return 1;}
+ double a4(unsigned i) const {return i-1;}
+};
+
+int main()
+{
+ typedef std::mem_fun_ref_t<char, A> F;
+ static_assert((std::is_base_of<std::unary_function<A, char>, F>::value), "");
+ const F f(&A::a1);
+ A a;
+ assert(f(a) == 5);
+}
diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_t.pass.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_t.pass.cpp
new file mode 100644
index 000000000000..3fc84cd05c63
--- /dev/null
+++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_t.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// mem_fun_t
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+struct A
+{
+ char a1() {return 5;}
+ short a2(int i) {return short(i+1);}
+ int a3() const {return 1;}
+ double a4(unsigned i) const {return i-1;}
+};
+
+int main()
+{
+ typedef std::mem_fun_t<char, A> F;
+ static_assert((std::is_base_of<std::unary_function<A*, char>, F>::value), "");
+ const F f(&A::a1);
+ A a;
+ assert(f(&a) == 5);
+}
diff --git a/test/std/depr/depr.function.objects/depr.adaptors/nothing_to_do.pass.cpp b/test/std/depr/depr.function.objects/depr.adaptors/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/depr/depr.function.objects/depr.adaptors/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/depr/depr.function.objects/depr.base/binary_function.pass.cpp b/test/std/depr/depr.function.objects/depr.base/binary_function.pass.cpp
new file mode 100644
index 000000000000..ddca8fdd63a4
--- /dev/null
+++ b/test/std/depr/depr.function.objects/depr.base/binary_function.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template <class Arg1, class Arg2, class Result>
+// struct binary_function
+// {
+// typedef Arg1 first_argument_type;
+// typedef Arg2 second_argument_type;
+// typedef Result result_type;
+// };
+
+#include <functional>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_same<std::binary_function<int, unsigned, char>::first_argument_type, int>::value), "");
+ static_assert((std::is_same<std::binary_function<int, unsigned, char>::second_argument_type, unsigned>::value), "");
+ static_assert((std::is_same<std::binary_function<int, unsigned, char>::result_type, char>::value), "");
+}
diff --git a/test/std/depr/depr.function.objects/depr.base/unary_function.pass.cpp b/test/std/depr/depr.function.objects/depr.base/unary_function.pass.cpp
new file mode 100644
index 000000000000..87cfe09a33cd
--- /dev/null
+++ b/test/std/depr/depr.function.objects/depr.base/unary_function.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template <class Arg, class Result>
+// struct unary_function
+// {
+// typedef Arg argument_type;
+// typedef Result result_type;
+// };
+
+#include <functional>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_same<std::unary_function<unsigned, char>::argument_type, unsigned>::value), "");
+ static_assert((std::is_same<std::unary_function<unsigned, char>::result_type, char>::value), "");
+}
diff --git a/test/std/depr/depr.function.objects/nothing_to_do.pass.cpp b/test/std/depr/depr.function.objects/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/depr/depr.function.objects/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/depr/depr.ios.members/io_state.pass.cpp b/test/std/depr/depr.ios.members/io_state.pass.cpp
new file mode 100644
index 000000000000..15bfbf197802
--- /dev/null
+++ b/test/std/depr/depr.ios.members/io_state.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+//
+// class ios_base
+// {
+// public:
+// typedef T1 io_state;
+// };
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+ std::strstream::io_state b = std::strstream::eofbit;
+ assert(b == std::ios::eofbit);
+}
diff --git a/test/std/depr/depr.ios.members/open_mode.pass.cpp b/test/std/depr/depr.ios.members/open_mode.pass.cpp
new file mode 100644
index 000000000000..12a8e9458809
--- /dev/null
+++ b/test/std/depr/depr.ios.members/open_mode.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+//
+// class ios_base
+// {
+// public:
+// typedef T2 open_mode;
+// };
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+ std::strstream::open_mode b = std::strstream::app;
+ assert(b == std::ios::app);
+}
diff --git a/test/std/depr/depr.ios.members/seek_dir.pass.cpp b/test/std/depr/depr.ios.members/seek_dir.pass.cpp
new file mode 100644
index 000000000000..891a7a345638
--- /dev/null
+++ b/test/std/depr/depr.ios.members/seek_dir.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+//
+// class ios_base
+// {
+// public:
+// typedef T3 seek_dir;
+// };
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+ std::strstream::seek_dir b = std::strstream::cur;
+ assert(b == std::ios::cur);
+}
diff --git a/test/std/depr/depr.ios.members/streamoff.pass.cpp b/test/std/depr/depr.ios.members/streamoff.pass.cpp
new file mode 100644
index 000000000000..4ccfd1f7d225
--- /dev/null
+++ b/test/std/depr/depr.ios.members/streamoff.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+//
+// class ios_base
+// {
+// public:
+// typedef OFF_T streamoff;
+// };
+
+#include <ios>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_integral<std::ios_base::streamoff>::value), "");
+ static_assert((std::is_signed<std::ios_base::streamoff>::value), "");
+}
diff --git a/test/std/depr/depr.ios.members/streampos.pass.cpp b/test/std/depr/depr.ios.members/streampos.pass.cpp
new file mode 100644
index 000000000000..315118cb3e3d
--- /dev/null
+++ b/test/std/depr/depr.ios.members/streampos.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+//
+// class ios_base
+// {
+// public:
+// typedef POS_T streampos;
+// };
+
+#include <ios>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_same<std::ios_base::streampos, std::streampos>::value), "");
+}
diff --git a/test/std/depr/depr.lib.binders/depr.lib.bind.1st/bind1st.pass.cpp b/test/std/depr/depr.lib.binders/depr.lib.bind.1st/bind1st.pass.cpp
new file mode 100644
index 000000000000..b6b75263c602
--- /dev/null
+++ b/test/std/depr/depr.lib.binders/depr.lib.bind.1st/bind1st.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template <class Fn, class T>
+// binder1st<Fn>
+// bind1st(const Fn& fn, const T& x);
+
+#include <functional>
+#include <cassert>
+
+#include "../test_func.h"
+
+int main()
+{
+ assert(std::bind1st(test_func(1), 5)(10.) == -5.);
+}
diff --git a/test/std/depr/depr.lib.binders/depr.lib.bind.2nd/bind2nd.pass.cpp b/test/std/depr/depr.lib.binders/depr.lib.bind.2nd/bind2nd.pass.cpp
new file mode 100644
index 000000000000..b7feb243b839
--- /dev/null
+++ b/test/std/depr/depr.lib.binders/depr.lib.bind.2nd/bind2nd.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template <class Fn, class T>
+// binder2nd<Fn>
+// bind2nd(const Fn& op, const T& x);
+
+#include <functional>
+#include <cassert>
+
+#include "../test_func.h"
+
+int main()
+{
+ assert(std::bind2nd(test_func(1), 5)(10) == 5.);
+}
diff --git a/test/std/depr/depr.lib.binders/depr.lib.binder.1st/binder1st.pass.cpp b/test/std/depr/depr.lib.binders/depr.lib.binder.1st/binder1st.pass.cpp
new file mode 100644
index 000000000000..8b7aaf0fdae1
--- /dev/null
+++ b/test/std/depr/depr.lib.binders/depr.lib.binder.1st/binder1st.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template <class Fn>
+// class binder1st
+// : public unary_function<typename Fn::second_argument_type, typename Fn::result_type>
+// {
+// protected:
+// Fn op;
+// typename Fn::first_argument_type value;
+// public:
+// binder2nd(const Fn& x, const typename Fn::second_argument_type& y);
+//
+// typename Fn::result_type operator()(const typename Fn::first_argument_type& x) const;
+// typename Fn::result_type operator()(typename Fn::first_argument_type& x) const;
+// };
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+#include "../test_func.h"
+
+class test
+ : public std::binder1st<test_func>
+{
+ typedef std::binder1st<test_func> base;
+public:
+ test() : std::binder1st<test_func>(test_func(2), 30) {}
+
+ void do_test()
+ {
+ static_assert((std::is_base_of<
+ std::unary_function<test_func::second_argument_type,
+ test_func::result_type>,
+ test>::value), "");
+ assert(op.id() == 2);
+ assert(value == 30);
+
+ double d = 5;
+ assert((*this)(d) == 35);
+ assert((*this)(5) == 25);
+ }
+};
+
+int main()
+{
+ test t;
+ t.do_test();
+}
diff --git a/test/std/depr/depr.lib.binders/depr.lib.binder.2nd/binder2nd.pass.cpp b/test/std/depr/depr.lib.binders/depr.lib.binder.2nd/binder2nd.pass.cpp
new file mode 100644
index 000000000000..645c1688c18a
--- /dev/null
+++ b/test/std/depr/depr.lib.binders/depr.lib.binder.2nd/binder2nd.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template <class Fn>
+// class binder2nd
+// : public unary_function<typename Fn::first_argument_type, typename Fn::result_type>
+// {
+// protected:
+// Fn op;
+// typename Fn::second_argument_type value;
+// public:
+// binder2nd(const Fn& x, const typename Fn::second_argument_type& y);
+//
+// typename Fn::result_type operator()(const typename Fn::first_argument_type& x) const;
+// typename Fn::result_type operator()(typename Fn::first_argument_type& x) const;
+// };
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+#include "../test_func.h"
+
+class test
+ : public std::binder2nd<test_func>
+{
+ typedef std::binder2nd<test_func> base;
+public:
+ test() : std::binder2nd<test_func>(test_func(3), 4.5) {}
+
+ void do_test()
+ {
+ static_assert((std::is_base_of<
+ std::unary_function<test_func::first_argument_type,
+ test_func::result_type>,
+ test>::value), "");
+ assert(op.id() == 3);
+ assert(value == 4.5);
+
+ int i = 5;
+ assert((*this)(i) == 22.5);
+ assert((*this)(5) == 0.5);
+ }
+};
+
+int main()
+{
+ test t;
+ t.do_test();
+}
diff --git a/test/std/depr/depr.lib.binders/nothing_to_do.pass.cpp b/test/std/depr/depr.lib.binders/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/depr/depr.lib.binders/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/depr/depr.lib.binders/test_func.h b/test/std/depr/depr.lib.binders/test_func.h
new file mode 100644
index 000000000000..1c1a46774e8b
--- /dev/null
+++ b/test/std/depr/depr.lib.binders/test_func.h
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef TEST_FUNC_H
+#define TEST_FUNC_H
+
+class test_func
+{
+ int id_;
+public:
+ typedef int first_argument_type;
+ typedef double second_argument_type;
+ typedef long double result_type;
+
+ explicit test_func(int id) : id_(id) {}
+
+ int id() const {return id_;}
+
+ result_type operator() (const first_argument_type& x, second_argument_type& y) const
+ {return x+y;}
+ result_type operator() (const first_argument_type& x, const second_argument_type& y) const
+ {return x-y;}
+ result_type operator() (first_argument_type& x, const second_argument_type& y) const
+ {return x*y;}
+};
+
+#endif // TEST_FUNC_H
diff --git a/test/std/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/ccp.pass.cpp b/test/std/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/ccp.pass.cpp
new file mode 100644
index 000000000000..9911df715078
--- /dev/null
+++ b/test/std/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/ccp.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class istrstream
+
+// explicit istrstream(const char* s);
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+ {
+ const char buf[] = "123 4.5 dog";
+ std::istrstream in(buf);
+ int i;
+ in >> i;
+ assert(i == 123);
+ double d;
+ in >> d;
+ assert(d == 4.5);
+ std::string s;
+ in >> s;
+ assert(s == "dog");
+ assert(in.eof());
+ assert(!in.fail());
+ in.clear();
+ in.putback('g');
+ assert(!in.fail());
+ in.putback('g');
+ assert(in.fail());
+ assert(buf[9] == 'o');
+ assert(buf[10] == 'g');
+ }
+}
diff --git a/test/std/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/ccp_size.pass.cpp b/test/std/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/ccp_size.pass.cpp
new file mode 100644
index 000000000000..a80095099401
--- /dev/null
+++ b/test/std/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/ccp_size.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class istrstream
+
+// explicit istrstream(const char* s, streamsize n);
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+ {
+ const char buf[] = "123 4.5 dog";
+ std::istrstream in(buf, 7);
+ int i;
+ in >> i;
+ assert(i == 123);
+ double d;
+ in >> d;
+ assert(d == 4.5);
+ std::string s;
+ in >> s;
+ assert(s == "");
+ assert(in.eof());
+ assert(in.fail());
+ in.clear();
+ in.putback('5');
+ assert(!in.fail());
+ in.putback('5');
+ assert(in.fail());
+ assert(buf[5] == '.');
+ assert(buf[6] == '5');
+ }
+}
diff --git a/test/std/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/cp.pass.cpp b/test/std/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/cp.pass.cpp
new file mode 100644
index 000000000000..edd6c1f6286c
--- /dev/null
+++ b/test/std/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/cp.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class istrstream
+
+// explicit istrstream(char* s);
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+ {
+ char buf[] = "123 4.5 dog";
+ std::istrstream in(buf);
+ int i;
+ in >> i;
+ assert(i == 123);
+ double d;
+ in >> d;
+ assert(d == 4.5);
+ std::string s;
+ in >> s;
+ assert(s == "dog");
+ assert(in.eof());
+ assert(!in.fail());
+ in.clear();
+ in.putback('g');
+ assert(!in.fail());
+ in.putback('g');
+ assert(!in.fail());
+ assert(buf[9] == 'g');
+ assert(buf[10] == 'g');
+ }
+}
diff --git a/test/std/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/cp_size.pass.cpp b/test/std/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/cp_size.pass.cpp
new file mode 100644
index 000000000000..5d01715ba1b7
--- /dev/null
+++ b/test/std/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/cp_size.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class istrstream
+
+// explicit istrstream(char* s, streamsize n);
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+ {
+ char buf[] = "123 4.5 dog";
+ std::istrstream in(buf, 7);
+ int i;
+ in >> i;
+ assert(i == 123);
+ double d;
+ in >> d;
+ assert(d == 4.5);
+ std::string s;
+ in >> s;
+ assert(s == "");
+ assert(in.eof());
+ assert(in.fail());
+ in.clear();
+ in.putback('5');
+ assert(!in.fail());
+ in.putback('5');
+ assert(!in.fail());
+ assert(buf[5] == '5');
+ assert(buf[6] == '5');
+ }
+}
diff --git a/test/std/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.members/rdbuf.pass.cpp b/test/std/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.members/rdbuf.pass.cpp
new file mode 100644
index 000000000000..0c273b3460b7
--- /dev/null
+++ b/test/std/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.members/rdbuf.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class istrstream
+
+// strstreambuf* rdbuf() const;
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+ {
+ const char buf[] = "123 4.5 dog";
+ const std::istrstream in(buf);
+ std::strstreambuf* sb = in.rdbuf();
+ assert(sb->sgetc() == '1');
+ }
+}
diff --git a/test/std/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.members/str.pass.cpp b/test/std/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.members/str.pass.cpp
new file mode 100644
index 000000000000..deb43d6f6362
--- /dev/null
+++ b/test/std/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.members/str.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class istrstream
+
+// char* str();
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+ {
+ const char buf[] = "123 4.5 dog";
+ std::istrstream in(buf);
+ assert(in.str() == std::string("123 4.5 dog"));
+ }
+}
diff --git a/test/std/depr/depr.str.strstreams/depr.istrstream/types.pass.cpp b/test/std/depr/depr.str.strstreams/depr.istrstream/types.pass.cpp
new file mode 100644
index 000000000000..4e158c6f0633
--- /dev/null
+++ b/test/std/depr/depr.str.strstreams/depr.istrstream/types.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class istrstream
+// : public basic_istream<char>
+// {
+// ...
+
+#include <strstream>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_base_of<std::istream, std::istrstream>::value), "");
+}
diff --git a/test/std/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.cons/cp_size_mode.pass.cpp b/test/std/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.cons/cp_size_mode.pass.cpp
new file mode 100644
index 000000000000..1ad0bfa8e269
--- /dev/null
+++ b/test/std/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.cons/cp_size_mode.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class ostrstream
+
+// ostrstream(char* s, int n, ios_base::openmode mode = ios_base::out);
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+ {
+ char buf[] = "123 4.5 dog";
+ std::ostrstream out(buf, 0);
+ assert(out.str() == std::string("123 4.5 dog"));
+ int i = 321;
+ double d = 5.5;
+ std::string s("cat");
+ out << i << ' ' << d << ' ' << s << std::ends;
+ assert(out.str() == std::string("321 5.5 cat"));
+ }
+ {
+ char buf[23] = "123 4.5 dog";
+ std::ostrstream out(buf, 11, std::ios::app);
+ assert(out.str() == std::string("123 4.5 dog"));
+ int i = 321;
+ double d = 5.5;
+ std::string s("cat");
+ out << i << ' ' << d << ' ' << s << std::ends;
+ assert(out.str() == std::string("123 4.5 dog321 5.5 cat"));
+ }
+}
diff --git a/test/std/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.cons/default.pass.cpp b/test/std/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.cons/default.pass.cpp
new file mode 100644
index 000000000000..5ea4988ffa6f
--- /dev/null
+++ b/test/std/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.cons/default.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class ostrstream
+
+// ostrstream();
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+ std::ostrstream out;
+ int i = 123;
+ double d = 4.5;
+ std::string s("dog");
+ out << i << ' ' << d << ' ' << s << std::ends;
+ assert(out.str() == std::string("123 4.5 dog"));
+ out.freeze(false);
+}
diff --git a/test/std/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.members/freeze.pass.cpp b/test/std/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.members/freeze.pass.cpp
new file mode 100644
index 000000000000..a60c7cba601c
--- /dev/null
+++ b/test/std/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.members/freeze.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class ostrstream
+
+// void freeze(bool freezefl = true);
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::ostrstream out;
+ out.freeze();
+ assert(!out.fail());
+ out << 'a';
+ assert(out.fail());
+ out.clear();
+ out.freeze(false);
+ out << 'a';
+ out << char(0);
+ assert(out.str() == std::string("a"));
+ out.freeze(false);
+ }
+}
diff --git a/test/std/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.members/pcount.pass.cpp b/test/std/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.members/pcount.pass.cpp
new file mode 100644
index 000000000000..4a752d659b82
--- /dev/null
+++ b/test/std/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.members/pcount.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class ostrstream
+
+// int pcount() const;
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::ostrstream out;
+ assert(out.pcount() == 0);
+ out << 123 << ' ' << 4.5 << ' ' << "dog";
+ assert(out.pcount() == 11);
+ }
+}
diff --git a/test/std/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.members/rdbuf.pass.cpp b/test/std/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.members/rdbuf.pass.cpp
new file mode 100644
index 000000000000..b8a23b227384
--- /dev/null
+++ b/test/std/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.members/rdbuf.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class ostrstream
+
+// strstreambuf* rdbuf() const;
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+ {
+ char buf[] = "123 4.5 dog";
+ const std::ostrstream out(buf, 0);
+ std::strstreambuf* sb = out.rdbuf();
+ assert(sb->sputc('a') == 'a');
+ assert(buf == std::string("a23 4.5 dog"));
+ }
+}
diff --git a/test/std/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.members/str.pass.cpp b/test/std/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.members/str.pass.cpp
new file mode 100644
index 000000000000..9a7160f455d2
--- /dev/null
+++ b/test/std/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.members/str.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class ostrstream
+
+// char* str();
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::ostrstream out;
+ out << 123 << ' ' << 4.5 << ' ' << "dog" << std::ends;
+ assert(out.str() == std::string("123 4.5 dog"));
+ out.freeze(false);
+ }
+}
diff --git a/test/std/depr/depr.str.strstreams/depr.ostrstream/types.pass.cpp b/test/std/depr/depr.str.strstreams/depr.ostrstream/types.pass.cpp
new file mode 100644
index 000000000000..88ab272a71dc
--- /dev/null
+++ b/test/std/depr/depr.str.strstreams/depr.ostrstream/types.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class ostrstream
+// : public basic_ostream<char>
+// {
+// ...
+
+#include <strstream>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_base_of<std::ostream, std::ostrstream>::value), "");
+}
diff --git a/test/std/depr/depr.str.strstreams/depr.strstream/depr.strstream.cons/cp_size_mode.pass.cpp b/test/std/depr/depr.str.strstreams/depr.strstream/depr.strstream.cons/cp_size_mode.pass.cpp
new file mode 100644
index 000000000000..2a4c0ec5aa20
--- /dev/null
+++ b/test/std/depr/depr.str.strstreams/depr.strstream/depr.strstream.cons/cp_size_mode.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class strstream
+
+// strstream(char* s, int n, ios_base::openmode mode = ios_base::in | ios_base::out);
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+ {
+ char buf[] = "123 4.5 dog";
+ std::strstream inout(buf, 0);
+ assert(inout.str() == std::string("123 4.5 dog"));
+ int i = 321;
+ double d = 5.5;
+ std::string s("cat");
+ inout >> i;
+ assert(inout.fail());
+ inout.clear();
+ inout << i << ' ' << d << ' ' << s;
+ assert(inout.str() == std::string("321 5.5 cat"));
+ i = 0;
+ d = 0;
+ s = "";
+ inout >> i >> d >> s;
+ assert(i == 321);
+ assert(d == 5.5);
+ assert(s == "cat");
+ }
+ {
+ char buf[23] = "123 4.5 dog";
+ std::strstream inout(buf, 11, std::ios::app);
+ assert(inout.str() == std::string("123 4.5 dog"));
+ int i = 0;
+ double d = 0;
+ std::string s;
+ inout >> i >> d >> s;
+ assert(i == 123);
+ assert(d == 4.5);
+ assert(s == "dog");
+ i = 321;
+ d = 5.5;
+ s = "cat";
+ inout.clear();
+ inout << i << ' ' << d << ' ' << s;
+ assert(inout.str() == std::string("123 4.5 dog321 5.5 cat"));
+ }
+}
diff --git a/test/std/depr/depr.str.strstreams/depr.strstream/depr.strstream.cons/default.pass.cpp b/test/std/depr/depr.str.strstreams/depr.strstream/depr.strstream.cons/default.pass.cpp
new file mode 100644
index 000000000000..2ec5e7f748e1
--- /dev/null
+++ b/test/std/depr/depr.str.strstreams/depr.strstream/depr.strstream.cons/default.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class strstream
+
+// strstream();
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+ std::strstream inout;
+ int i = 123;
+ double d = 4.5;
+ std::string s("dog");
+ inout << i << ' ' << d << ' ' << s << std::ends;
+ assert(inout.str() == std::string("123 4.5 dog"));
+ i = 0;
+ d = 0;
+ s = "";
+ inout >> i >> d >> s;
+ assert(i == 123);
+ assert(d == 4.5);
+ assert(strcmp(s.c_str(), "dog") == 0);
+ inout.freeze(false);
+}
diff --git a/test/std/depr/depr.str.strstreams/depr.strstream/depr.strstream.dest/rdbuf.pass.cpp b/test/std/depr/depr.str.strstreams/depr.strstream/depr.strstream.dest/rdbuf.pass.cpp
new file mode 100644
index 000000000000..4adb179b3dda
--- /dev/null
+++ b/test/std/depr/depr.str.strstreams/depr.strstream/depr.strstream.dest/rdbuf.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class strstream
+
+// strstreambuf* rdbuf() const;
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+ {
+ char buf[] = "123 4.5 dog";
+ const std::strstream out(buf, 0);
+ std::strstreambuf* sb = out.rdbuf();
+ assert(sb->sputc('a') == 'a');
+ assert(buf == std::string("a23 4.5 dog"));
+ }
+}
diff --git a/test/std/depr/depr.str.strstreams/depr.strstream/depr.strstream.oper/freeze.pass.cpp b/test/std/depr/depr.str.strstreams/depr.strstream/depr.strstream.oper/freeze.pass.cpp
new file mode 100644
index 000000000000..47343388501d
--- /dev/null
+++ b/test/std/depr/depr.str.strstreams/depr.strstream/depr.strstream.oper/freeze.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class strstream
+
+// void freeze(bool freezefl = true);
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::strstream out;
+ out.freeze();
+ assert(!out.fail());
+ out << 'a';
+ assert(out.fail());
+ out.clear();
+ out.freeze(false);
+ out << 'a';
+ out << char(0);
+ assert(out.str() == std::string("a"));
+ out.freeze(false);
+ }
+}
diff --git a/test/std/depr/depr.str.strstreams/depr.strstream/depr.strstream.oper/pcount.pass.cpp b/test/std/depr/depr.str.strstreams/depr.strstream/depr.strstream.oper/pcount.pass.cpp
new file mode 100644
index 000000000000..18b6350d58c0
--- /dev/null
+++ b/test/std/depr/depr.str.strstreams/depr.strstream/depr.strstream.oper/pcount.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class strstream
+
+// int pcount() const;
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::strstream out;
+ assert(out.pcount() == 0);
+ out << 123 << ' ' << 4.5 << ' ' << "dog";
+ assert(out.pcount() == 11);
+ }
+}
diff --git a/test/std/depr/depr.str.strstreams/depr.strstream/depr.strstream.oper/str.pass.cpp b/test/std/depr/depr.str.strstreams/depr.strstream/depr.strstream.oper/str.pass.cpp
new file mode 100644
index 000000000000..5c273dc45d2d
--- /dev/null
+++ b/test/std/depr/depr.str.strstreams/depr.strstream/depr.strstream.oper/str.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class strstream
+
+// char* str();
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::strstream out;
+ out << 123 << ' ' << 4.5 << ' ' << "dog" << std::ends;
+ assert(out.str() == std::string("123 4.5 dog"));
+ out.freeze(false);
+ }
+}
diff --git a/test/std/depr/depr.str.strstreams/depr.strstream/types.pass.cpp b/test/std/depr/depr.str.strstreams/depr.strstream/types.pass.cpp
new file mode 100644
index 000000000000..67ea32432248
--- /dev/null
+++ b/test/std/depr/depr.str.strstreams/depr.strstream/types.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class strstream
+// : public basic_iostream<char>
+// {
+// public:
+// // Types
+// typedef char char_type;
+// typedef char_traits<char>::int_type int_type;
+// typedef char_traits<char>::pos_type pos_type;
+// typedef char_traits<char>::off_type off_type;
+
+#include <strstream>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_base_of<std::iostream, std::strstream>::value), "");
+ static_assert((std::is_same<std::strstream::char_type, char>::value), "");
+ static_assert((std::is_same<std::strstream::int_type, std::char_traits<char>::int_type>::value), "");
+ static_assert((std::is_same<std::strstream::pos_type, std::char_traits<char>::pos_type>::value), "");
+ static_assert((std::is_same<std::strstream::off_type, std::char_traits<char>::off_type>::value), "");
+}
diff --git a/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/ccp_size.pass.cpp b/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/ccp_size.pass.cpp
new file mode 100644
index 000000000000..04eaab5adca7
--- /dev/null
+++ b/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/ccp_size.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class strstreambuf
+
+// strstreambuf(const char* gnext_arg, streamsize n);
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+ {
+ const char buf[] = "abcd";
+ std::strstreambuf sb(buf, sizeof(buf));
+ assert(sb.sgetc() == 'a');
+ assert(sb.snextc() == 'b');
+ assert(sb.snextc() == 'c');
+ assert(sb.snextc() == 'd');
+ assert(sb.snextc() == 0);
+ assert(sb.snextc() == EOF);
+ }
+ {
+ const char buf[] = "abcd";
+ std::strstreambuf sb(buf, 0);
+ assert(sb.sgetc() == 'a');
+ assert(sb.snextc() == 'b');
+ assert(sb.snextc() == 'c');
+ assert(sb.snextc() == 'd');
+ assert(sb.snextc() == EOF);
+ }
+}
diff --git a/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/cp_size_cp.pass.cpp b/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/cp_size_cp.pass.cpp
new file mode 100644
index 000000000000..5d345f13dd41
--- /dev/null
+++ b/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/cp_size_cp.pass.cpp
@@ -0,0 +1,96 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class strstreambuf
+
+// strstreambuf(char* gnext_arg, streamsize n, char* pbeg_arg = 0);
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+ {
+ char buf[] = "abcd";
+ std::strstreambuf sb(buf, sizeof(buf));
+ assert(sb.sgetc() == 'a');
+ assert(sb.snextc() == 'b');
+ assert(sb.snextc() == 'c');
+ assert(sb.snextc() == 'd');
+ assert(sb.snextc() == 0);
+ assert(sb.snextc() == EOF);
+ }
+ {
+ char buf[] = "abcd";
+ std::strstreambuf sb(buf, 0);
+ assert(sb.sgetc() == 'a');
+ assert(sb.snextc() == 'b');
+ assert(sb.snextc() == 'c');
+ assert(sb.snextc() == 'd');
+ assert(sb.snextc() == EOF);
+ }
+ {
+ char buf[] = "abcd";
+ std::strstreambuf sb(buf, sizeof(buf), buf);
+ assert(sb.sgetc() == EOF);
+ assert(sb.sputc('e') == 'e');
+ assert(sb.sputc('f') == 'f');
+ assert(sb.sputc('g') == 'g');
+ assert(sb.sputc('h') == 'h');
+ assert(sb.sputc('i') == 'i');
+ assert(sb.sputc('j') == EOF);
+ assert(sb.sgetc() == 'e');
+ assert(sb.snextc() == 'f');
+ assert(sb.snextc() == 'g');
+ assert(sb.snextc() == 'h');
+ assert(sb.snextc() == 'i');
+ assert(sb.snextc() == EOF);
+ }
+ {
+ char buf[] = "abcd";
+ std::strstreambuf sb(buf, 0, buf);
+ assert(sb.sgetc() == EOF);
+ assert(sb.sputc('e') == 'e');
+ assert(sb.sputc('f') == 'f');
+ assert(sb.sputc('g') == 'g');
+ assert(sb.sputc('h') == 'h');
+ assert(sb.sputc('i') == EOF);
+ assert(sb.sgetc() == 'e');
+ assert(sb.snextc() == 'f');
+ assert(sb.snextc() == 'g');
+ assert(sb.snextc() == 'h');
+ assert(sb.snextc() == EOF);
+ }
+ {
+ char buf[10] = "abcd";
+ int s = std::strlen(buf);
+ std::strstreambuf sb(buf, sizeof(buf)-s, buf + s);
+ assert(sb.sgetc() == 'a');
+ assert(sb.snextc() == 'b');
+ assert(sb.snextc() == 'c');
+ assert(sb.snextc() == 'd');
+ assert(sb.snextc() == EOF);
+ assert(sb.sputc('e') == 'e');
+ assert(sb.sputc('f') == 'f');
+ assert(sb.sputc('g') == 'g');
+ assert(sb.sputc('h') == 'h');
+ assert(sb.sputc('i') == 'i');
+ assert(sb.sputc('j') == 'j');
+ assert(sb.sputc('j') == EOF);
+ assert(sb.sgetc() == 'e');
+ assert(sb.snextc() == 'f');
+ assert(sb.snextc() == 'g');
+ assert(sb.snextc() == 'h');
+ assert(sb.snextc() == 'i');
+ assert(sb.snextc() == 'j');
+ assert(sb.snextc() == EOF);
+ }
+}
diff --git a/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/cscp_size.pass.cpp b/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/cscp_size.pass.cpp
new file mode 100644
index 000000000000..13ae427a173c
--- /dev/null
+++ b/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/cscp_size.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class strstreambuf
+
+// strstreambuf(const signed char* gnext_arg, streamsize n);
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+ {
+ const signed char buf[] = "abcd";
+ std::strstreambuf sb(buf, sizeof(buf));
+ assert(sb.sgetc() == 'a');
+ assert(sb.snextc() == 'b');
+ assert(sb.snextc() == 'c');
+ assert(sb.snextc() == 'd');
+ assert(sb.snextc() == 0);
+ assert(sb.snextc() == EOF);
+ }
+ {
+ const signed char buf[] = "abcd";
+ std::strstreambuf sb(buf, 0);
+ assert(sb.sgetc() == 'a');
+ assert(sb.snextc() == 'b');
+ assert(sb.snextc() == 'c');
+ assert(sb.snextc() == 'd');
+ assert(sb.snextc() == EOF);
+ }
+}
diff --git a/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/cucp_size.pass.cpp b/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/cucp_size.pass.cpp
new file mode 100644
index 000000000000..3a09711c0fac
--- /dev/null
+++ b/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/cucp_size.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class strstreambuf
+
+// strstreambuf(const unsigned char* gnext_arg, streamsize n);
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+ {
+ unsigned char buf[] = "abcd";
+ std::strstreambuf sb(buf, sizeof(buf));
+ assert(sb.sgetc() == 'a');
+ assert(sb.snextc() == 'b');
+ assert(sb.snextc() == 'c');
+ assert(sb.snextc() == 'd');
+ assert(sb.snextc() == 0);
+ assert(sb.snextc() == EOF);
+ }
+ {
+ unsigned char buf[] = "abcd";
+ std::strstreambuf sb(buf, 0);
+ assert(sb.sgetc() == 'a');
+ assert(sb.snextc() == 'b');
+ assert(sb.snextc() == 'c');
+ assert(sb.snextc() == 'd');
+ assert(sb.snextc() == EOF);
+ }
+}
diff --git a/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/custom_alloc.pass.cpp b/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/custom_alloc.pass.cpp
new file mode 100644
index 000000000000..12a1fb874c30
--- /dev/null
+++ b/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/custom_alloc.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class strstreambuf
+
+// strstreambuf(void* (*palloc_arg)(size_t), void (*pfree_arg)(void*));
+
+#include <strstream>
+#include <cassert>
+
+int called = 0;
+
+void* my_alloc(std::size_t n)
+{
+ static char buf[10000];
+ ++called;
+ return buf;
+}
+
+void my_free(void*)
+{
+ ++called;
+}
+
+struct test
+ : std::strstreambuf
+{
+ test(void* (*palloc_arg)(size_t), void (*pfree_arg)(void*))
+ : std::strstreambuf(palloc_arg, pfree_arg) {}
+ virtual int_type overflow(int_type c)
+ {return std::strstreambuf::overflow(c);}
+};
+
+int main()
+{
+ {
+ test s(my_alloc, my_free);
+ assert(called == 0);
+ s.overflow('a');
+ assert(called == 1);
+ }
+ assert(called == 2);
+}
diff --git a/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/default.pass.cpp b/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/default.pass.cpp
new file mode 100644
index 000000000000..1e5635e46ec5
--- /dev/null
+++ b/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/default.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class strstreambuf
+
+// explicit strstreambuf(streamsize alsize_arg = 0);
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::strstreambuf s;
+ assert(s.str() == nullptr);
+ assert(s.pcount() == 0);
+ }
+ {
+ std::strstreambuf s(1024);
+ assert(s.str() == nullptr);
+ assert(s.pcount() == 0);
+ }
+}
diff --git a/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/scp_size_scp.pass.cpp b/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/scp_size_scp.pass.cpp
new file mode 100644
index 000000000000..c827850abf3a
--- /dev/null
+++ b/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/scp_size_scp.pass.cpp
@@ -0,0 +1,96 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class strstreambuf
+
+// strstreambuf(signed char* gnext_arg, streamsize n, signed char* pbeg_arg = 0);
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+ {
+ signed char buf[] = "abcd";
+ std::strstreambuf sb(buf, sizeof(buf));
+ assert(sb.sgetc() == 'a');
+ assert(sb.snextc() == 'b');
+ assert(sb.snextc() == 'c');
+ assert(sb.snextc() == 'd');
+ assert(sb.snextc() == 0);
+ assert(sb.snextc() == EOF);
+ }
+ {
+ signed char buf[] = "abcd";
+ std::strstreambuf sb(buf, 0);
+ assert(sb.sgetc() == 'a');
+ assert(sb.snextc() == 'b');
+ assert(sb.snextc() == 'c');
+ assert(sb.snextc() == 'd');
+ assert(sb.snextc() == EOF);
+ }
+ {
+ signed char buf[] = "abcd";
+ std::strstreambuf sb(buf, sizeof(buf), buf);
+ assert(sb.sgetc() == EOF);
+ assert(sb.sputc('e') == 'e');
+ assert(sb.sputc('f') == 'f');
+ assert(sb.sputc('g') == 'g');
+ assert(sb.sputc('h') == 'h');
+ assert(sb.sputc('i') == 'i');
+ assert(sb.sputc('j') == EOF);
+ assert(sb.sgetc() == 'e');
+ assert(sb.snextc() == 'f');
+ assert(sb.snextc() == 'g');
+ assert(sb.snextc() == 'h');
+ assert(sb.snextc() == 'i');
+ assert(sb.snextc() == EOF);
+ }
+ {
+ signed char buf[] = "abcd";
+ std::strstreambuf sb(buf, 0, buf);
+ assert(sb.sgetc() == EOF);
+ assert(sb.sputc('e') == 'e');
+ assert(sb.sputc('f') == 'f');
+ assert(sb.sputc('g') == 'g');
+ assert(sb.sputc('h') == 'h');
+ assert(sb.sputc('i') == EOF);
+ assert(sb.sgetc() == 'e');
+ assert(sb.snextc() == 'f');
+ assert(sb.snextc() == 'g');
+ assert(sb.snextc() == 'h');
+ assert(sb.snextc() == EOF);
+ }
+ {
+ signed char buf[10] = "abcd";
+ int s = std::strlen((char*)buf);
+ std::strstreambuf sb(buf, sizeof(buf)-s, buf + s);
+ assert(sb.sgetc() == 'a');
+ assert(sb.snextc() == 'b');
+ assert(sb.snextc() == 'c');
+ assert(sb.snextc() == 'd');
+ assert(sb.snextc() == EOF);
+ assert(sb.sputc('e') == 'e');
+ assert(sb.sputc('f') == 'f');
+ assert(sb.sputc('g') == 'g');
+ assert(sb.sputc('h') == 'h');
+ assert(sb.sputc('i') == 'i');
+ assert(sb.sputc('j') == 'j');
+ assert(sb.sputc('j') == EOF);
+ assert(sb.sgetc() == 'e');
+ assert(sb.snextc() == 'f');
+ assert(sb.snextc() == 'g');
+ assert(sb.snextc() == 'h');
+ assert(sb.snextc() == 'i');
+ assert(sb.snextc() == 'j');
+ assert(sb.snextc() == EOF);
+ }
+}
diff --git a/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/ucp_size_ucp.pass.cpp b/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/ucp_size_ucp.pass.cpp
new file mode 100644
index 000000000000..46c11e4afaf0
--- /dev/null
+++ b/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/ucp_size_ucp.pass.cpp
@@ -0,0 +1,96 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class strstreambuf
+
+// strstreambuf(unsigned char* gnext_arg, streamsize n, unsigned char* pbeg_arg = 0);
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+ {
+ unsigned char buf[] = "abcd";
+ std::strstreambuf sb(buf, sizeof(buf));
+ assert(sb.sgetc() == 'a');
+ assert(sb.snextc() == 'b');
+ assert(sb.snextc() == 'c');
+ assert(sb.snextc() == 'd');
+ assert(sb.snextc() == 0);
+ assert(sb.snextc() == EOF);
+ }
+ {
+ unsigned char buf[] = "abcd";
+ std::strstreambuf sb(buf, 0);
+ assert(sb.sgetc() == 'a');
+ assert(sb.snextc() == 'b');
+ assert(sb.snextc() == 'c');
+ assert(sb.snextc() == 'd');
+ assert(sb.snextc() == EOF);
+ }
+ {
+ unsigned char buf[] = "abcd";
+ std::strstreambuf sb(buf, sizeof(buf), buf);
+ assert(sb.sgetc() == EOF);
+ assert(sb.sputc('e') == 'e');
+ assert(sb.sputc('f') == 'f');
+ assert(sb.sputc('g') == 'g');
+ assert(sb.sputc('h') == 'h');
+ assert(sb.sputc('i') == 'i');
+ assert(sb.sputc('j') == EOF);
+ assert(sb.sgetc() == 'e');
+ assert(sb.snextc() == 'f');
+ assert(sb.snextc() == 'g');
+ assert(sb.snextc() == 'h');
+ assert(sb.snextc() == 'i');
+ assert(sb.snextc() == EOF);
+ }
+ {
+ unsigned char buf[] = "abcd";
+ std::strstreambuf sb(buf, 0, buf);
+ assert(sb.sgetc() == EOF);
+ assert(sb.sputc('e') == 'e');
+ assert(sb.sputc('f') == 'f');
+ assert(sb.sputc('g') == 'g');
+ assert(sb.sputc('h') == 'h');
+ assert(sb.sputc('i') == EOF);
+ assert(sb.sgetc() == 'e');
+ assert(sb.snextc() == 'f');
+ assert(sb.snextc() == 'g');
+ assert(sb.snextc() == 'h');
+ assert(sb.snextc() == EOF);
+ }
+ {
+ unsigned char buf[10] = "abcd";
+ int s = std::strlen((char*)buf);
+ std::strstreambuf sb(buf, sizeof(buf)-s, buf + s);
+ assert(sb.sgetc() == 'a');
+ assert(sb.snextc() == 'b');
+ assert(sb.snextc() == 'c');
+ assert(sb.snextc() == 'd');
+ assert(sb.snextc() == EOF);
+ assert(sb.sputc('e') == 'e');
+ assert(sb.sputc('f') == 'f');
+ assert(sb.sputc('g') == 'g');
+ assert(sb.sputc('h') == 'h');
+ assert(sb.sputc('i') == 'i');
+ assert(sb.sputc('j') == 'j');
+ assert(sb.sputc('j') == EOF);
+ assert(sb.sgetc() == 'e');
+ assert(sb.snextc() == 'f');
+ assert(sb.snextc() == 'g');
+ assert(sb.snextc() == 'h');
+ assert(sb.snextc() == 'i');
+ assert(sb.snextc() == 'j');
+ assert(sb.snextc() == EOF);
+ }
+}
diff --git a/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.members/freeze.pass.cpp b/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.members/freeze.pass.cpp
new file mode 100644
index 000000000000..9572ef30d41b
--- /dev/null
+++ b/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.members/freeze.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class strstreambuf
+
+// void freeze(bool freezefl = true);
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::strstreambuf sb;
+ sb.freeze(true);
+ assert(sb.sputc('a') == EOF);
+ sb.freeze(false);
+ assert(sb.sputc('a') == 'a');
+ }
+}
diff --git a/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.members/pcount.pass.cpp b/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.members/pcount.pass.cpp
new file mode 100644
index 000000000000..d96f0f769f62
--- /dev/null
+++ b/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.members/pcount.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class strstreambuf
+
+// int pcount() const;
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::strstreambuf sb;
+ assert(sb.pcount() == 0);
+ assert(sb.sputc('a') == 'a');
+ assert(sb.pcount() == 1);
+ assert(sb.sputc(0) == 0);
+ assert(sb.pcount() == 2);
+ assert(sb.str() == std::string("a"));
+ assert(sb.pcount() == 2);
+ sb.freeze(false);
+ }
+}
diff --git a/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.members/str.pass.cpp b/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.members/str.pass.cpp
new file mode 100644
index 000000000000..27de56f2cef6
--- /dev/null
+++ b/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.members/str.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class strstreambuf
+
+// char* str();
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::strstreambuf sb;
+ assert(sb.sputc('a') == 'a');
+ assert(sb.sputc(0) == 0);
+ assert(sb.str() == std::string("a"));
+ sb.freeze(false);
+ }
+}
diff --git a/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/overflow.pass.cpp b/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/overflow.pass.cpp
new file mode 100644
index 000000000000..843450b71ead
--- /dev/null
+++ b/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/overflow.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class strstreambuf
+
+// int_type overflow(int_type c = EOF);
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+ {
+ char buf[12] = "abc";
+ std::strstreambuf sb(buf, sizeof(buf), buf);
+ assert(sb.sputc('1') == '1');
+ assert(sb.str() == std::string("1bc"));
+ assert(sb.sputc('2') == '2');
+ assert(sb.str() == std::string("12c"));
+ assert(sb.sputc('3') == '3');
+ assert(sb.str() == std::string("123"));
+ assert(sb.sputc('4') == '4');
+ assert(sb.str() == std::string("1234"));
+ assert(sb.sputc('5') == '5');
+ assert(sb.str() == std::string("12345"));
+ assert(sb.sputc('6') == '6');
+ assert(sb.str() == std::string("123456"));
+ assert(sb.sputc('7') == '7');
+ assert(sb.str() == std::string("1234567"));
+ assert(sb.sputc('8') == '8');
+ assert(sb.str() == std::string("12345678"));
+ assert(sb.sputc('9') == '9');
+ assert(sb.str() == std::string("123456789"));
+ assert(sb.sputc('0') == '0');
+ assert(sb.str() == std::string("1234567890"));
+ assert(sb.sputc('1') == '1');
+ assert(sb.str() == std::string("12345678901"));
+ }
+}
diff --git a/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/pbackfail.pass.cpp b/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/pbackfail.pass.cpp
new file mode 100644
index 000000000000..2a3fe202e308
--- /dev/null
+++ b/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/pbackfail.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class strstreambuf
+
+// int_type pbackfail(int_type c = EOF);
+
+#include <strstream>
+#include <cassert>
+
+struct test
+ : public std::strstreambuf
+{
+ typedef std::strstreambuf base;
+ test(char* gnext_arg, std::streamsize n, char* pbeg_arg = 0)
+ : base(gnext_arg, n, pbeg_arg) {}
+ test(const char* gnext_arg, std::streamsize n)
+ : base(gnext_arg, n) {}
+
+ virtual int_type pbackfail(int_type c = EOF) {return base::pbackfail(c);}
+};
+
+int main()
+{
+ {
+ const char buf[] = "123";
+ test sb(buf, 0);
+ assert(sb.sgetc() == '1');
+ assert(sb.snextc() == '2');
+ assert(sb.snextc() == '3');
+ assert(sb.sgetc() == '3');
+ assert(sb.snextc() == EOF);
+ assert(sb.pbackfail('3') == '3');
+ assert(sb.pbackfail('3') == EOF);
+ assert(sb.pbackfail('2') == '2');
+ assert(sb.pbackfail(EOF) != EOF);
+ assert(sb.pbackfail(EOF) == EOF);
+ assert(sb.str() == std::string("123"));
+ }
+ {
+ char buf[] = "123";
+ test sb(buf, 0);
+ assert(sb.sgetc() == '1');
+ assert(sb.snextc() == '2');
+ assert(sb.snextc() == '3');
+ assert(sb.sgetc() == '3');
+ assert(sb.snextc() == EOF);
+ assert(sb.pbackfail('3') == '3');
+ assert(sb.pbackfail('3') == '3');
+ assert(sb.pbackfail(EOF) != EOF);
+ assert(sb.pbackfail(EOF) == EOF);
+ assert(sb.str() == std::string("133"));
+ }
+}
diff --git a/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/seekoff.pass.cpp b/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/seekoff.pass.cpp
new file mode 100644
index 000000000000..27d5d29dbc45
--- /dev/null
+++ b/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/seekoff.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class strstreambuf
+
+// pos_type seekoff(off_type off, ios_base::seekdir way,
+// ios_base::openmode which = ios_base::in | ios_base::out);
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+ {
+ char buf[] = "0123456789";
+ std::strstreambuf sb(buf, 0);
+ assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::out) == -1);
+ assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::out) == -1);
+ assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::out) == -1);
+ assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::in | std::ios_base::out) == -1);
+ assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::in | std::ios_base::out) == -1);
+ assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::in | std::ios_base::out) == -1);
+ assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::in) == 3);
+ assert(sb.sgetc() == '3');
+ assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::in) == 6);
+ assert(sb.sgetc() == '6');
+ assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::in) == 7);
+ assert(sb.sgetc() == '7');
+ }
+ {
+ char buf[] = "0123456789";
+ std::strstreambuf sb(buf, 0, buf);
+ assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::in) == 3);
+ assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::in) == 6);
+ assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::in) == 7);
+ assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::out | std::ios_base::in) == 3);
+ assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::out | std::ios_base::in) == -1);
+ assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::out | std::ios_base::in) == 7);
+ assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::out) == 3);
+ assert(sb.sputc('a') == 'a');
+ assert(sb.str() == std::string("012a456789"));
+ assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::out) == 7);
+ assert(sb.sputc('b') == 'b');
+ assert(sb.str() == std::string("012a456b89"));
+ assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::out) == 7);
+ assert(sb.sputc('c') == 'c');
+ assert(sb.str() == std::string("012a456c89"));
+ }
+}
diff --git a/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/seekpos.pass.cpp b/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/seekpos.pass.cpp
new file mode 100644
index 000000000000..d412479d850e
--- /dev/null
+++ b/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/seekpos.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class strstreambuf
+
+// pos_type seekpos(pos_type sp,
+// ios_base::openmode which = ios_base::in | ios_base::out);
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+ {
+ char buf[] = "0123456789";
+ std::strstreambuf sb(buf, 0);
+ assert(sb.pubseekpos(3, std::ios_base::out) == -1);
+ assert(sb.pubseekpos(3, std::ios_base::in | std::ios_base::out) == -1);
+ assert(sb.pubseekpos(3, std::ios_base::in) == 3);
+ assert(sb.sgetc() == '3');
+ }
+ {
+ char buf[] = "0123456789";
+ std::strstreambuf sb(buf, 0, buf);
+ assert(sb.pubseekpos(3, std::ios_base::in) == 3);
+ assert(sb.pubseekpos(3, std::ios_base::out | std::ios_base::in) == 3);
+ assert(sb.pubseekpos(3, std::ios_base::out) == 3);
+ assert(sb.sputc('a') == 'a');
+ assert(sb.str() == std::string("012a456789"));
+ }
+}
diff --git a/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/setbuf.pass.cpp b/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/setbuf.pass.cpp
new file mode 100644
index 000000000000..99eb9e93a0ff
--- /dev/null
+++ b/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/setbuf.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class strstreambuf
+
+// streambuf* setbuf(char* s, streamsize n);
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+ {
+ char buf[] = "0123456789";
+ std::strstreambuf sb(buf, 0);
+ assert(sb.pubsetbuf(0, 0) == &sb);
+ assert(sb.str() == std::string("0123456789"));
+ }
+}
diff --git a/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/underflow.pass.cpp b/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/underflow.pass.cpp
new file mode 100644
index 000000000000..1b16a37aaf0c
--- /dev/null
+++ b/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/underflow.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class strstreambuf
+
+// int_type underflow();
+
+#include <strstream>
+#include <cassert>
+
+struct test
+ : public std::strstreambuf
+{
+ typedef std::strstreambuf base;
+ test(char* gnext_arg, std::streamsize n, char* pbeg_arg = 0)
+ : base(gnext_arg, n, pbeg_arg) {}
+ test(const char* gnext_arg, std::streamsize n)
+ : base(gnext_arg, n) {}
+
+ base::int_type underflow() {return base::underflow();}
+};
+
+int main()
+{
+ {
+ char buf[10] = "123";
+ test sb(buf, 0, buf + 3);
+ assert(sb.underflow() == '1');
+ assert(sb.underflow() == '1');
+ assert(sb.snextc() == '2');
+ assert(sb.underflow() == '2');
+ assert(sb.underflow() == '2');
+ assert(sb.snextc() == '3');
+ assert(sb.underflow() == '3');
+ assert(sb.underflow() == '3');
+ assert(sb.snextc() == EOF);
+ assert(sb.underflow() == EOF);
+ assert(sb.underflow() == EOF);
+ sb.sputc('4');
+ assert(sb.underflow() == '4');
+ assert(sb.underflow() == '4');
+ }
+}
diff --git a/test/std/depr/depr.str.strstreams/depr.strstreambuf/types.pass.cpp b/test/std/depr/depr.str.strstreams/depr.strstreambuf/types.pass.cpp
new file mode 100644
index 000000000000..c4a1562bf869
--- /dev/null
+++ b/test/std/depr/depr.str.strstreams/depr.strstreambuf/types.pass.cpp
@@ -0,0 +1,21 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class strstreambuf
+// : public basic_streambuf<char>
+
+#include <strstream>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_base_of<std::streambuf, std::strstreambuf>::value), "");
+}
diff --git a/test/std/depr/depr.str.strstreams/version.pass.cpp b/test/std/depr/depr.str.strstreams/version.pass.cpp
new file mode 100644
index 000000000000..f27665f15bcd
--- /dev/null
+++ b/test/std/depr/depr.str.strstreams/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+#include <strstream>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/depr/exception.unexpected/nothing_to_do.pass.cpp b/test/std/depr/exception.unexpected/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/depr/exception.unexpected/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/depr/exception.unexpected/set.unexpected/get_unexpected.pass.cpp b/test/std/depr/exception.unexpected/set.unexpected/get_unexpected.pass.cpp
new file mode 100644
index 000000000000..8b0a0b979de0
--- /dev/null
+++ b/test/std/depr/exception.unexpected/set.unexpected/get_unexpected.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test get_unexpected
+
+#include <exception>
+#include <cassert>
+#include <cstdlib>
+
+void f1() {}
+void f2() {}
+
+void f3()
+{
+ std::exit(0);
+}
+
+int main()
+{
+
+ std::unexpected_handler old = std::get_unexpected();
+ // verify there is a previous unexpected handler
+ assert(old);
+ std::set_unexpected(f1);
+ assert(std::get_unexpected() == f1);
+ // verify f1 was replace with f2
+ std::set_unexpected(f2);
+ assert(std::get_unexpected() == f2);
+ // verify calling original unexpected handler calls terminate
+ std::set_terminate(f3);
+ (*old)();
+ assert(0);
+}
diff --git a/test/std/depr/exception.unexpected/set.unexpected/set_unexpected.pass.cpp b/test/std/depr/exception.unexpected/set.unexpected/set_unexpected.pass.cpp
new file mode 100644
index 000000000000..ed02fa618e8e
--- /dev/null
+++ b/test/std/depr/exception.unexpected/set.unexpected/set_unexpected.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test set_unexpected
+
+#include <exception>
+#include <cassert>
+#include <cstdlib>
+
+void f1() {}
+void f2() {}
+
+void f3()
+{
+ std::exit(0);
+}
+
+int main()
+{
+ std::unexpected_handler old = std::set_unexpected(f1);
+ // verify there is a previous unexpected handler
+ assert(old);
+ // verify f1 was replace with f2
+ assert(std::set_unexpected(f2) == f1);
+ // verify calling original unexpected handler calls terminate
+ std::set_terminate(f3);
+ (*old)();
+ assert(0);
+}
diff --git a/test/std/depr/exception.unexpected/unexpected.handler/unexpected_handler.pass.cpp b/test/std/depr/exception.unexpected/unexpected.handler/unexpected_handler.pass.cpp
new file mode 100644
index 000000000000..7fab50081d2a
--- /dev/null
+++ b/test/std/depr/exception.unexpected/unexpected.handler/unexpected_handler.pass.cpp
@@ -0,0 +1,19 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test unexpected_handler
+
+#include <exception>
+
+void f() {}
+
+int main()
+{
+ std::unexpected_handler p = f;
+}
diff --git a/test/std/depr/exception.unexpected/unexpected/unexpected.pass.cpp b/test/std/depr/exception.unexpected/unexpected/unexpected.pass.cpp
new file mode 100644
index 000000000000..03b484f7631a
--- /dev/null
+++ b/test/std/depr/exception.unexpected/unexpected/unexpected.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test unexpected
+
+#include <exception>
+#include <cstdlib>
+#include <cassert>
+
+void f1()
+{
+ std::exit(0);
+}
+
+int main()
+{
+ std::set_unexpected(f1);
+ std::unexpected();
+ assert(false);
+}
diff --git a/test/std/depr/nothing_to_do.pass.cpp b/test/std/depr/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/depr/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/diagnostics/assertions/cassert.pass.cpp b/test/std/diagnostics/assertions/cassert.pass.cpp
new file mode 100644
index 000000000000..bed7a394ee4a
--- /dev/null
+++ b/test/std/diagnostics/assertions/cassert.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test <cassert>
+
+#include <cassert>
+
+#ifndef assert
+#error assert not defined
+#endif
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/diagnostics/diagnostics.general/nothing_to_do.pass.cpp b/test/std/diagnostics/diagnostics.general/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/diagnostics/diagnostics.general/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/diagnostics/errno/cerrno.pass.cpp b/test/std/diagnostics/errno/cerrno.pass.cpp
new file mode 100644
index 000000000000..c6743fb79e7f
--- /dev/null
+++ b/test/std/diagnostics/errno/cerrno.pass.cpp
@@ -0,0 +1,349 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test <cerrno>
+
+#include <cerrno>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+#ifndef E2BIG
+#error E2BIG not defined
+#endif
+
+#ifndef EACCES
+#error EACCES not defined
+#endif
+
+#ifndef EACCES
+#error EACCES not defined
+#endif
+
+#ifndef EADDRINUSE
+#error EADDRINUSE not defined
+#endif
+
+#ifndef EADDRNOTAVAIL
+#error EADDRNOTAVAIL not defined
+#endif
+
+#ifndef EAFNOSUPPORT
+#error EAFNOSUPPORT not defined
+#endif
+
+#ifndef EAGAIN
+#error EAGAIN not defined
+#endif
+
+#ifndef EALREADY
+#error EALREADY not defined
+#endif
+
+#ifndef EBADF
+#error EBADF not defined
+#endif
+
+#ifndef EBADMSG
+#error EBADMSG not defined
+#endif
+
+#ifndef EBUSY
+#error EBUSY not defined
+#endif
+
+#ifndef ECANCELED
+#error ECANCELED not defined
+#endif
+
+#ifndef ECHILD
+#error ECHILD not defined
+#endif
+
+#ifndef ECONNABORTED
+#error ECONNABORTED not defined
+#endif
+
+#ifndef ECONNREFUSED
+#error ECONNREFUSED not defined
+#endif
+
+#ifndef ECONNRESET
+#error ECONNRESET not defined
+#endif
+
+#ifndef EDEADLK
+#error EDEADLK not defined
+#endif
+
+#ifndef EDESTADDRREQ
+#error EDESTADDRREQ not defined
+#endif
+
+#ifndef EDOM
+#error EDOM not defined
+#endif
+
+#ifndef EEXIST
+#error EEXIST not defined
+#endif
+
+#ifndef EFAULT
+#error EFAULT not defined
+#endif
+
+#ifndef EFBIG
+#error EFBIG not defined
+#endif
+
+#ifndef EHOSTUNREACH
+#error EHOSTUNREACH not defined
+#endif
+
+#ifndef EIDRM
+#error EIDRM not defined
+#endif
+
+#ifndef EILSEQ
+#error EILSEQ not defined
+#endif
+
+#ifndef EINPROGRESS
+#error EINPROGRESS not defined
+#endif
+
+#ifndef EINTR
+#error EINTR not defined
+#endif
+
+#ifndef EINVAL
+#error EINVAL not defined
+#endif
+
+#ifndef EIO
+#error EIO not defined
+#endif
+
+#ifndef EISCONN
+#error EISCONN not defined
+#endif
+
+#ifndef EISDIR
+#error EISDIR not defined
+#endif
+
+#ifndef ELOOP
+#error ELOOP not defined
+#endif
+
+#ifndef EMFILE
+#error EMFILE not defined
+#endif
+
+#ifndef EMLINK
+#error EMLINK not defined
+#endif
+
+#ifndef EMSGSIZE
+#error EMSGSIZE not defined
+#endif
+
+#ifndef ENAMETOOLONG
+#error ENAMETOOLONG not defined
+#endif
+
+#ifndef ENETDOWN
+#error ENETDOWN not defined
+#endif
+
+#ifndef ENETRESET
+#error ENETRESET not defined
+#endif
+
+#ifndef ENETUNREACH
+#error ENETUNREACH not defined
+#endif
+
+#ifndef ENFILE
+#error ENFILE not defined
+#endif
+
+#ifndef ENOBUFS
+#error ENOBUFS not defined
+#endif
+
+#if (defined(_XOPEN_STREAMS) && _XOPEN_STREAMS != -1)
+#ifndef ENODATA
+#error ENODATA not defined
+#endif
+#endif
+
+#ifndef ENODEV
+#error ENODEV not defined
+#endif
+
+#ifndef ENOENT
+#error ENOENT not defined
+#endif
+
+#ifndef ENOEXEC
+#error ENOEXEC not defined
+#endif
+
+#ifndef ENOLCK
+#error ENOLCK not defined
+#endif
+
+#ifndef ENOLINK
+#error ENOLINK not defined
+#endif
+
+#ifndef ENOMEM
+#error ENOMEM not defined
+#endif
+
+#ifndef ENOMSG
+#error ENOMSG not defined
+#endif
+
+#ifndef ENOPROTOOPT
+#error ENOPROTOOPT not defined
+#endif
+
+#ifndef ENOSPC
+#error ENOSPC not defined
+#endif
+
+#if (defined(_XOPEN_STREAMS) && _XOPEN_STREAMS != -1)
+#ifndef ENOSR
+#error ENOSR not defined
+#endif
+#endif
+
+#if (defined(_XOPEN_STREAMS) && _XOPEN_STREAMS != -1)
+#ifndef ENOSTR
+#error ENOSTR not defined
+#endif
+#endif
+
+#ifndef ENOSYS
+#error ENOSYS not defined
+#endif
+
+#ifndef ENOTCONN
+#error ENOTCONN not defined
+#endif
+
+#ifndef ENOTDIR
+#error ENOTDIR not defined
+#endif
+
+#ifndef ENOTEMPTY
+#error ENOTEMPTY not defined
+#endif
+
+#ifndef ENOTRECOVERABLE
+#error ENOTRECOVERABLE not defined
+#endif
+
+#ifndef ENOTSOCK
+#error ENOTSOCK not defined
+#endif
+
+#ifndef ENOTSUP
+#error ENOTSUP not defined
+#endif
+
+#ifndef ENOTTY
+#error ENOTTY not defined
+#endif
+
+#ifndef ENXIO
+#error ENXIO not defined
+#endif
+
+#ifndef EOPNOTSUPP
+#error EOPNOTSUPP not defined
+#endif
+
+#ifndef EOVERFLOW
+#error EOVERFLOW not defined
+#endif
+
+#ifndef EOWNERDEAD
+#error EOWNERDEAD not defined
+#endif
+
+#ifndef EPERM
+#error EPERM not defined
+#endif
+
+#ifndef EPIPE
+#error EPIPE not defined
+#endif
+
+#ifndef EPROTO
+#error EPROTO not defined
+#endif
+
+#ifndef EPROTONOSUPPORT
+#error EPROTONOSUPPORT not defined
+#endif
+
+#ifndef EPROTOTYPE
+#error EPROTOTYPE not defined
+#endif
+
+#ifndef ERANGE
+#error ERANGE not defined
+#endif
+
+#ifndef EROFS
+#error EROFS not defined
+#endif
+
+#ifndef ESPIPE
+#error ESPIPE not defined
+#endif
+
+#ifndef ESRCH
+#error ESRCH not defined
+#endif
+
+#if (defined(_XOPEN_STREAMS) && _XOPEN_STREAMS != -1)
+#ifndef ETIME
+#error ETIME not defined
+#endif
+#endif
+
+#ifndef ETIMEDOUT
+#error ETIMEDOUT not defined
+#endif
+
+#ifndef ETXTBSY
+#error ETXTBSY not defined
+#endif
+
+#ifndef EWOULDBLOCK
+#error EWOULDBLOCK not defined
+#endif
+
+#ifndef EXDEV
+#error EXDEV not defined
+#endif
+
+#ifndef errno
+#error errno not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/diagnostics/nothing_to_do.pass.cpp b/test/std/diagnostics/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/diagnostics/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/diagnostics/std.exceptions/domain.error/domain_error.pass.cpp b/test/std/diagnostics/std.exceptions/domain.error/domain_error.pass.cpp
new file mode 100644
index 000000000000..5769d2505374
--- /dev/null
+++ b/test/std/diagnostics/std.exceptions/domain.error/domain_error.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test domain_error
+
+#include <stdexcept>
+#include <type_traits>
+#include <cstring>
+#include <string>
+#include <cassert>
+
+int main()
+{
+ static_assert((std::is_base_of<std::logic_error, std::domain_error>::value),
+ "std::is_base_of<std::logic_error, std::domain_error>::value");
+ static_assert(std::is_polymorphic<std::domain_error>::value,
+ "std::is_polymorphic<std::domain_error>::value");
+ {
+ const char* msg = "domain_error message";
+ std::domain_error e(msg);
+ assert(std::strcmp(e.what(), msg) == 0);
+ std::domain_error e2(e);
+ assert(std::strcmp(e2.what(), msg) == 0);
+ e2 = e;
+ assert(std::strcmp(e2.what(), msg) == 0);
+ }
+ {
+ std::string msg("another domain_error message");
+ std::domain_error e(msg);
+ assert(e.what() == msg);
+ std::domain_error e2(e);
+ assert(e2.what() == msg);
+ e2 = e;
+ assert(e2.what() == msg);
+ }
+}
diff --git a/test/std/diagnostics/std.exceptions/invalid.argument/invalid_argument.pass.cpp b/test/std/diagnostics/std.exceptions/invalid.argument/invalid_argument.pass.cpp
new file mode 100644
index 000000000000..e360275a6835
--- /dev/null
+++ b/test/std/diagnostics/std.exceptions/invalid.argument/invalid_argument.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test invalid_argument
+
+#include <stdexcept>
+#include <type_traits>
+#include <cstring>
+#include <string>
+#include <cassert>
+
+int main()
+{
+ static_assert((std::is_base_of<std::logic_error, std::invalid_argument>::value),
+ "std::is_base_of<std::logic_error, std::invalid_argument>::value");
+ static_assert(std::is_polymorphic<std::invalid_argument>::value,
+ "std::is_polymorphic<std::invalid_argument>::value");
+ {
+ const char* msg = "invalid_argument message";
+ std::invalid_argument e(msg);
+ assert(std::strcmp(e.what(), msg) == 0);
+ std::invalid_argument e2(e);
+ assert(std::strcmp(e2.what(), msg) == 0);
+ e2 = e;
+ assert(std::strcmp(e2.what(), msg) == 0);
+ }
+ {
+ std::string msg("another invalid_argument message");
+ std::invalid_argument e(msg);
+ assert(e.what() == msg);
+ std::invalid_argument e2(e);
+ assert(e2.what() == msg);
+ e2 = e;
+ assert(e2.what() == msg);
+ }
+}
diff --git a/test/std/diagnostics/std.exceptions/length.error/length_error.pass.cpp b/test/std/diagnostics/std.exceptions/length.error/length_error.pass.cpp
new file mode 100644
index 000000000000..3a9144121a0c
--- /dev/null
+++ b/test/std/diagnostics/std.exceptions/length.error/length_error.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test length_error
+
+#include <stdexcept>
+#include <type_traits>
+#include <cstring>
+#include <string>
+#include <cassert>
+
+int main()
+{
+ static_assert((std::is_base_of<std::logic_error, std::length_error>::value),
+ "std::is_base_of<std::logic_error, std::length_error>::value");
+ static_assert(std::is_polymorphic<std::length_error>::value,
+ "std::is_polymorphic<std::length_error>::value");
+ {
+ const char* msg = "length_error message";
+ std::length_error e(msg);
+ assert(std::strcmp(e.what(), msg) == 0);
+ std::length_error e2(e);
+ assert(std::strcmp(e2.what(), msg) == 0);
+ e2 = e;
+ assert(std::strcmp(e2.what(), msg) == 0);
+ }
+ {
+ std::string msg("another length_error message");
+ std::length_error e(msg);
+ assert(e.what() == msg);
+ std::length_error e2(e);
+ assert(e2.what() == msg);
+ e2 = e;
+ assert(e2.what() == msg);
+ }
+}
diff --git a/test/std/diagnostics/std.exceptions/logic.error/logic_error.pass.cpp b/test/std/diagnostics/std.exceptions/logic.error/logic_error.pass.cpp
new file mode 100644
index 000000000000..3c3d4f4f9711
--- /dev/null
+++ b/test/std/diagnostics/std.exceptions/logic.error/logic_error.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test logic_error
+
+#include <stdexcept>
+#include <type_traits>
+#include <cstring>
+#include <string>
+#include <cassert>
+
+int main()
+{
+ static_assert((std::is_base_of<std::exception, std::logic_error>::value),
+ "std::is_base_of<std::exception, std::logic_error>::value");
+ static_assert(std::is_polymorphic<std::logic_error>::value,
+ "std::is_polymorphic<std::logic_error>::value");
+ {
+ const char* msg = "logic_error message";
+ std::logic_error e(msg);
+ assert(std::strcmp(e.what(), msg) == 0);
+ std::logic_error e2(e);
+ assert(std::strcmp(e2.what(), msg) == 0);
+ e2 = e;
+ assert(std::strcmp(e2.what(), msg) == 0);
+ }
+ {
+ std::string msg("another logic_error message");
+ std::logic_error e(msg);
+ assert(e.what() == msg);
+ std::logic_error e2(e);
+ assert(e2.what() == msg);
+ e2 = e;
+ assert(e2.what() == msg);
+ }
+}
diff --git a/test/std/diagnostics/std.exceptions/out.of.range/out_of_range.pass.cpp b/test/std/diagnostics/std.exceptions/out.of.range/out_of_range.pass.cpp
new file mode 100644
index 000000000000..f358d2b76521
--- /dev/null
+++ b/test/std/diagnostics/std.exceptions/out.of.range/out_of_range.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test out_of_range
+
+#include <stdexcept>
+#include <type_traits>
+#include <cstring>
+#include <string>
+#include <cassert>
+
+int main()
+{
+ static_assert((std::is_base_of<std::logic_error, std::out_of_range>::value),
+ "std::is_base_of<std::logic_error, std::out_of_range>::value");
+ static_assert(std::is_polymorphic<std::out_of_range>::value,
+ "std::is_polymorphic<std::out_of_range>::value");
+ {
+ const char* msg = "out_of_range message";
+ std::out_of_range e(msg);
+ assert(std::strcmp(e.what(), msg) == 0);
+ std::out_of_range e2(e);
+ assert(std::strcmp(e2.what(), msg) == 0);
+ e2 = e;
+ assert(std::strcmp(e2.what(), msg) == 0);
+ }
+ {
+ std::string msg("another out_of_range message");
+ std::out_of_range e(msg);
+ assert(e.what() == msg);
+ std::out_of_range e2(e);
+ assert(e2.what() == msg);
+ e2 = e;
+ assert(e2.what() == msg);
+ }
+}
diff --git a/test/std/diagnostics/std.exceptions/overflow.error/overflow_error.pass.cpp b/test/std/diagnostics/std.exceptions/overflow.error/overflow_error.pass.cpp
new file mode 100644
index 000000000000..47f75eb0f396
--- /dev/null
+++ b/test/std/diagnostics/std.exceptions/overflow.error/overflow_error.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test overflow_error
+
+#include <stdexcept>
+#include <type_traits>
+#include <cstring>
+#include <string>
+#include <cassert>
+
+int main()
+{
+ static_assert((std::is_base_of<std::runtime_error, std::overflow_error>::value),
+ "std::is_base_of<std::runtime_error, std::overflow_error>::value");
+ static_assert(std::is_polymorphic<std::overflow_error>::value,
+ "std::is_polymorphic<std::overflow_error>::value");
+ {
+ const char* msg = "overflow_error message";
+ std::overflow_error e(msg);
+ assert(std::strcmp(e.what(), msg) == 0);
+ std::overflow_error e2(e);
+ assert(std::strcmp(e2.what(), msg) == 0);
+ e2 = e;
+ assert(std::strcmp(e2.what(), msg) == 0);
+ }
+ {
+ std::string msg("another overflow_error message");
+ std::overflow_error e(msg);
+ assert(e.what() == msg);
+ std::overflow_error e2(e);
+ assert(e2.what() == msg);
+ e2 = e;
+ assert(e2.what() == msg);
+ }
+}
diff --git a/test/std/diagnostics/std.exceptions/range.error/range_error.pass.cpp b/test/std/diagnostics/std.exceptions/range.error/range_error.pass.cpp
new file mode 100644
index 000000000000..8c82a918921b
--- /dev/null
+++ b/test/std/diagnostics/std.exceptions/range.error/range_error.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test range_error
+
+#include <stdexcept>
+#include <type_traits>
+#include <cstring>
+#include <string>
+#include <cassert>
+
+int main()
+{
+ static_assert((std::is_base_of<std::runtime_error, std::range_error>::value),
+ "std::is_base_of<std::runtime_error, std::range_error>::value");
+ static_assert(std::is_polymorphic<std::range_error>::value,
+ "std::is_polymorphic<std::range_error>::value");
+ {
+ const char* msg = "range_error message";
+ std::range_error e(msg);
+ assert(std::strcmp(e.what(), msg) == 0);
+ std::range_error e2(e);
+ assert(std::strcmp(e2.what(), msg) == 0);
+ e2 = e;
+ assert(std::strcmp(e2.what(), msg) == 0);
+ }
+ {
+ std::string msg("another range_error message");
+ std::range_error e(msg);
+ assert(e.what() == msg);
+ std::range_error e2(e);
+ assert(e2.what() == msg);
+ e2 = e;
+ assert(e2.what() == msg);
+ }
+}
diff --git a/test/std/diagnostics/std.exceptions/runtime.error/runtime_error.pass.cpp b/test/std/diagnostics/std.exceptions/runtime.error/runtime_error.pass.cpp
new file mode 100644
index 000000000000..2b2fe20c6628
--- /dev/null
+++ b/test/std/diagnostics/std.exceptions/runtime.error/runtime_error.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test runtime_error
+
+#include <stdexcept>
+#include <type_traits>
+#include <cstring>
+#include <string>
+#include <cassert>
+
+int main()
+{
+ static_assert((std::is_base_of<std::exception, std::runtime_error>::value),
+ "std::is_base_of<std::exception, std::runtime_error>::value");
+ static_assert(std::is_polymorphic<std::runtime_error>::value,
+ "std::is_polymorphic<std::runtime_error>::value");
+ {
+ const char* msg = "runtime_error message";
+ std::runtime_error e(msg);
+ assert(std::strcmp(e.what(), msg) == 0);
+ std::runtime_error e2(e);
+ assert(std::strcmp(e2.what(), msg) == 0);
+ e2 = e;
+ assert(std::strcmp(e2.what(), msg) == 0);
+ }
+ {
+ std::string msg("another runtime_error message");
+ std::runtime_error e(msg);
+ assert(e.what() == msg);
+ std::runtime_error e2(e);
+ assert(e2.what() == msg);
+ e2 = e;
+ assert(e2.what() == msg);
+ }
+}
diff --git a/test/std/diagnostics/std.exceptions/underflow.error/underflow_error.pass.cpp b/test/std/diagnostics/std.exceptions/underflow.error/underflow_error.pass.cpp
new file mode 100644
index 000000000000..103c290ac40c
--- /dev/null
+++ b/test/std/diagnostics/std.exceptions/underflow.error/underflow_error.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test underflow_error
+
+#include <stdexcept>
+#include <type_traits>
+#include <cstring>
+#include <string>
+#include <cassert>
+
+int main()
+{
+ static_assert((std::is_base_of<std::runtime_error, std::underflow_error>::value),
+ "std::is_base_of<std::runtime_error, std::underflow_error>::value");
+ static_assert(std::is_polymorphic<std::underflow_error>::value,
+ "std::is_polymorphic<std::underflow_error>::value");
+ {
+ const char* msg = "underflow_error message";
+ std::underflow_error e(msg);
+ assert(std::strcmp(e.what(), msg) == 0);
+ std::underflow_error e2(e);
+ assert(std::strcmp(e2.what(), msg) == 0);
+ e2 = e;
+ assert(std::strcmp(e2.what(), msg) == 0);
+ }
+ {
+ std::string msg("another underflow_error message");
+ std::underflow_error e(msg);
+ assert(e.what() == msg);
+ std::underflow_error e2(e);
+ assert(e2.what() == msg);
+ e2 = e;
+ assert(e2.what() == msg);
+ }
+}
diff --git a/test/std/diagnostics/std.exceptions/version.pass.cpp b/test/std/diagnostics/std.exceptions/version.pass.cpp
new file mode 100644
index 000000000000..d9ab009a4365
--- /dev/null
+++ b/test/std/diagnostics/std.exceptions/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <stdexcept>
+
+#include <stdexcept>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/diagnostics/syserr/errc.pass.cpp b/test/std/diagnostics/syserr/errc.pass.cpp
new file mode 100644
index 000000000000..247e10bf8d6b
--- /dev/null
+++ b/test/std/diagnostics/syserr/errc.pass.cpp
@@ -0,0 +1,104 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// enum errc {...}
+
+#include <system_error>
+
+int main()
+{
+ static_assert(static_cast<int>(std::errc::address_family_not_supported) == EAFNOSUPPORT, "");
+ static_assert(static_cast<int>(std::errc::address_in_use) == EADDRINUSE, "");
+ static_assert(static_cast<int>(std::errc::address_not_available) == EADDRNOTAVAIL, "");
+ static_assert(static_cast<int>(std::errc::already_connected) == EISCONN, "");
+ static_assert(static_cast<int>(std::errc::argument_list_too_long) == E2BIG, "");
+ static_assert(static_cast<int>(std::errc::argument_out_of_domain) == EDOM, "");
+ static_assert(static_cast<int>(std::errc::bad_address) == EFAULT, "");
+ static_assert(static_cast<int>(std::errc::bad_file_descriptor) == EBADF, "");
+ static_assert(static_cast<int>(std::errc::bad_message) == EBADMSG, "");
+ static_assert(static_cast<int>(std::errc::broken_pipe) == EPIPE, "");
+ static_assert(static_cast<int>(std::errc::connection_aborted) == ECONNABORTED, "");
+ static_assert(static_cast<int>(std::errc::connection_already_in_progress) == EALREADY, "");
+ static_assert(static_cast<int>(std::errc::connection_refused) == ECONNREFUSED, "");
+ static_assert(static_cast<int>(std::errc::connection_reset) == ECONNRESET, "");
+ static_assert(static_cast<int>(std::errc::cross_device_link) == EXDEV, "");
+ static_assert(static_cast<int>(std::errc::destination_address_required) == EDESTADDRREQ, "");
+ static_assert(static_cast<int>(std::errc::device_or_resource_busy) == EBUSY, "");
+ static_assert(static_cast<int>(std::errc::directory_not_empty) == ENOTEMPTY, "");
+ static_assert(static_cast<int>(std::errc::executable_format_error) == ENOEXEC, "");
+ static_assert(static_cast<int>(std::errc::file_exists) == EEXIST, "");
+ static_assert(static_cast<int>(std::errc::file_too_large) == EFBIG, "");
+ static_assert(static_cast<int>(std::errc::filename_too_long) == ENAMETOOLONG, "");
+ static_assert(static_cast<int>(std::errc::function_not_supported) == ENOSYS, "");
+ static_assert(static_cast<int>(std::errc::host_unreachable) == EHOSTUNREACH, "");
+ static_assert(static_cast<int>(std::errc::identifier_removed) == EIDRM, "");
+ static_assert(static_cast<int>(std::errc::illegal_byte_sequence) == EILSEQ, "");
+ static_assert(static_cast<int>(std::errc::inappropriate_io_control_operation) == ENOTTY, "");
+ static_assert(static_cast<int>(std::errc::interrupted) == EINTR, "");
+ static_assert(static_cast<int>(std::errc::invalid_argument) == EINVAL, "");
+ static_assert(static_cast<int>(std::errc::invalid_seek) == ESPIPE, "");
+ static_assert(static_cast<int>(std::errc::io_error) == EIO, "");
+ static_assert(static_cast<int>(std::errc::is_a_directory) == EISDIR, "");
+ static_assert(static_cast<int>(std::errc::message_size) == EMSGSIZE, "");
+ static_assert(static_cast<int>(std::errc::network_down) == ENETDOWN, "");
+ static_assert(static_cast<int>(std::errc::network_reset) == ENETRESET, "");
+ static_assert(static_cast<int>(std::errc::network_unreachable) == ENETUNREACH, "");
+ static_assert(static_cast<int>(std::errc::no_buffer_space) == ENOBUFS, "");
+ static_assert(static_cast<int>(std::errc::no_child_process) == ECHILD, "");
+ static_assert(static_cast<int>(std::errc::no_link) == ENOLINK, "");
+ static_assert(static_cast<int>(std::errc::no_lock_available) == ENOLCK, "");
+#if (defined(_XOPEN_STREAMS) && _XOPEN_STREAMS != -1)
+ static_assert(static_cast<int>(std::errc::no_message_available) == ENODATA, "");
+#endif
+ static_assert(static_cast<int>(std::errc::no_message) == ENOMSG, "");
+ static_assert(static_cast<int>(std::errc::no_protocol_option) == ENOPROTOOPT, "");
+ static_assert(static_cast<int>(std::errc::no_space_on_device) == ENOSPC, "");
+#if (defined(_XOPEN_STREAMS) && _XOPEN_STREAMS != -1)
+ static_assert(static_cast<int>(std::errc::no_stream_resources) == ENOSR, "");
+#endif
+ static_assert(static_cast<int>(std::errc::no_such_device_or_address) == ENXIO, "");
+ static_assert(static_cast<int>(std::errc::no_such_device) == ENODEV, "");
+ static_assert(static_cast<int>(std::errc::no_such_file_or_directory) == ENOENT, "");
+ static_assert(static_cast<int>(std::errc::no_such_process) == ESRCH, "");
+ static_assert(static_cast<int>(std::errc::not_a_directory) == ENOTDIR, "");
+ static_assert(static_cast<int>(std::errc::not_a_socket) == ENOTSOCK, "");
+#if (defined(_XOPEN_STREAMS) && _XOPEN_STREAMS != -1)
+ static_assert(static_cast<int>(std::errc::not_a_stream) == ENOSTR, "");
+#endif
+ static_assert(static_cast<int>(std::errc::not_connected) == ENOTCONN, "");
+ static_assert(static_cast<int>(std::errc::not_enough_memory) == ENOMEM, "");
+ static_assert(static_cast<int>(std::errc::not_supported) == ENOTSUP, "");
+ static_assert(static_cast<int>(std::errc::operation_canceled) == ECANCELED, "");
+ static_assert(static_cast<int>(std::errc::operation_in_progress) == EINPROGRESS, "");
+ static_assert(static_cast<int>(std::errc::operation_not_permitted) == EPERM, "");
+ static_assert(static_cast<int>(std::errc::operation_not_supported) == EOPNOTSUPP, "");
+ static_assert(static_cast<int>(std::errc::operation_would_block) == EWOULDBLOCK, "");
+ static_assert(static_cast<int>(std::errc::owner_dead) == EOWNERDEAD, "");
+ static_assert(static_cast<int>(std::errc::permission_denied) == EACCES, "");
+ static_assert(static_cast<int>(std::errc::protocol_error) == EPROTO, "");
+ static_assert(static_cast<int>(std::errc::protocol_not_supported) == EPROTONOSUPPORT, "");
+ static_assert(static_cast<int>(std::errc::read_only_file_system) == EROFS, "");
+ static_assert(static_cast<int>(std::errc::resource_deadlock_would_occur) == EDEADLK, "");
+ static_assert(static_cast<int>(std::errc::resource_unavailable_try_again) == EAGAIN, "");
+ static_assert(static_cast<int>(std::errc::result_out_of_range) == ERANGE, "");
+ static_assert(static_cast<int>(std::errc::state_not_recoverable) == ENOTRECOVERABLE, "");
+#if (defined(_XOPEN_STREAMS) && _XOPEN_STREAMS != -1)
+ static_assert(static_cast<int>(std::errc::stream_timeout) == ETIME, "");
+#endif
+ static_assert(static_cast<int>(std::errc::text_file_busy) == ETXTBSY, "");
+ static_assert(static_cast<int>(std::errc::timed_out) == ETIMEDOUT, "");
+ static_assert(static_cast<int>(std::errc::too_many_files_open_in_system) == ENFILE, "");
+ static_assert(static_cast<int>(std::errc::too_many_files_open) == EMFILE, "");
+ static_assert(static_cast<int>(std::errc::too_many_links) == EMLINK, "");
+ static_assert(static_cast<int>(std::errc::too_many_symbolic_link_levels) == ELOOP, "");
+ static_assert(static_cast<int>(std::errc::value_too_large) == EOVERFLOW, "");
+ static_assert(static_cast<int>(std::errc::wrong_protocol_type) == EPROTOTYPE, "");
+}
diff --git a/test/std/diagnostics/syserr/syserr.compare/eq_error_code_error_code.pass.cpp b/test/std/diagnostics/syserr/syserr.compare/eq_error_code_error_code.pass.cpp
new file mode 100644
index 000000000000..e2e7aeda822b
--- /dev/null
+++ b/test/std/diagnostics/syserr/syserr.compare/eq_error_code_error_code.pass.cpp
@@ -0,0 +1,106 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// bool operator==(const error_code& lhs, const error_code& rhs);
+// bool operator==(const error_code& lhs, const error_condition& rhs);
+// bool operator==(const error_condition& lhs, const error_code& rhs);
+// bool operator==(const error_condition& lhs, const error_condition& rhs);
+// bool operator!=(const error_code& lhs, const error_code& rhs);
+// bool operator!=(const error_code& lhs, const error_condition& rhs);
+// bool operator!=(const error_condition& lhs, const error_code& rhs);
+// bool operator!=(const error_condition& lhs, const error_condition& rhs);
+
+#include <system_error>
+#include <cassert>
+
+int main()
+{
+ std::error_code e_code1(5, std::generic_category());
+ std::error_code e_code2(5, std::system_category());
+ std::error_code e_code3(6, std::generic_category());
+ std::error_code e_code4(6, std::system_category());
+ std::error_condition e_condition1(5, std::generic_category());
+ std::error_condition e_condition2(5, std::system_category());
+ std::error_condition e_condition3(6, std::generic_category());
+ std::error_condition e_condition4(6, std::system_category());
+
+ assert(e_code1 == e_code1);
+ assert(e_code1 != e_code2);
+ assert(e_code1 != e_code3);
+ assert(e_code1 != e_code4);
+ assert(e_code1 == e_condition1);
+ assert(e_code1 != e_condition2);
+ assert(e_code1 != e_condition3);
+ assert(e_code1 != e_condition4);
+
+ assert(e_code2 != e_code1);
+ assert(e_code2 == e_code2);
+ assert(e_code2 != e_code3);
+ assert(e_code2 != e_code4);
+ assert(e_code2 == e_condition1); // ?
+ assert(e_code2 == e_condition2);
+ assert(e_code2 != e_condition3);
+ assert(e_code2 != e_condition4);
+
+ assert(e_code3 != e_code1);
+ assert(e_code3 != e_code2);
+ assert(e_code3 == e_code3);
+ assert(e_code3 != e_code4);
+ assert(e_code3 != e_condition1);
+ assert(e_code3 != e_condition2);
+ assert(e_code3 == e_condition3);
+ assert(e_code3 != e_condition4);
+
+ assert(e_code4 != e_code1);
+ assert(e_code4 != e_code2);
+ assert(e_code4 != e_code3);
+ assert(e_code4 == e_code4);
+ assert(e_code4 != e_condition1);
+ assert(e_code4 != e_condition2);
+ assert(e_code4 == e_condition3); // ?
+ assert(e_code4 == e_condition4);
+
+ assert(e_condition1 == e_code1);
+ assert(e_condition1 == e_code2); // ?
+ assert(e_condition1 != e_code3);
+ assert(e_condition1 != e_code4);
+ assert(e_condition1 == e_condition1);
+ assert(e_condition1 != e_condition2);
+ assert(e_condition1 != e_condition3);
+ assert(e_condition1 != e_condition4);
+
+ assert(e_condition2 != e_code1);
+ assert(e_condition2 == e_code2);
+ assert(e_condition2 != e_code3);
+ assert(e_condition2 != e_code4);
+ assert(e_condition2 != e_condition1);
+ assert(e_condition2 == e_condition2);
+ assert(e_condition2 != e_condition3);
+ assert(e_condition2 != e_condition4);
+
+ assert(e_condition3 != e_code1);
+ assert(e_condition3 != e_code2);
+ assert(e_condition3 == e_code3);
+ assert(e_condition3 == e_code4); // ?
+ assert(e_condition3 != e_condition1);
+ assert(e_condition3 != e_condition2);
+ assert(e_condition3 == e_condition3);
+ assert(e_condition3 != e_condition4);
+
+ assert(e_condition4 != e_code1);
+ assert(e_condition4 != e_code2);
+ assert(e_condition4 != e_code3);
+ assert(e_condition4 == e_code4);
+ assert(e_condition4 != e_condition1);
+ assert(e_condition4 != e_condition2);
+ assert(e_condition4 != e_condition3);
+ assert(e_condition4 == e_condition4);
+}
diff --git a/test/std/diagnostics/syserr/syserr.errcat/nothing_to_do.pass.cpp b/test/std/diagnostics/syserr/syserr.errcat/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/diagnostics/syserr/syserr.errcat/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.derived/message.pass.cpp b/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.derived/message.pass.cpp
new file mode 100644
index 000000000000..82770fb438b1
--- /dev/null
+++ b/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.derived/message.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_category
+
+// virtual string message(int ev) const = 0;
+
+#include <system_error>
+#include <cassert>
+#include <string>
+
+#include <stdio.h>
+
+int main()
+{
+ const std::error_category& e_cat1 = std::generic_category();
+ const std::error_category& e_cat2 = std::system_category();
+ std::string m1 = e_cat1.message(5);
+ std::string m2 = e_cat2.message(5);
+ std::string m3 = e_cat2.message(6);
+ assert(!m1.empty());
+ assert(!m2.empty());
+ assert(!m3.empty());
+ assert(m1 == m2);
+ assert(m1 != m3);
+}
diff --git a/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.nonvirtuals/default_ctor.pass.cpp b/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.nonvirtuals/default_ctor.pass.cpp
new file mode 100644
index 000000000000..0573ef862efd
--- /dev/null
+++ b/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.nonvirtuals/default_ctor.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_category
+
+// constexpr error_category() noexcept;
+
+#include <system_error>
+#include <type_traits>
+#include <string>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+class test1
+ : public std::error_category
+{
+public:
+ constexpr test1() = default; // won't compile if error_category() is not constexpr
+ virtual const char* name() const noexcept {return nullptr;}
+ virtual std::string message(int ev) const {return std::string();}
+};
+
+#endif // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ static_assert(std::is_nothrow_default_constructible<test1>::value,
+ "error_category() must exist and be noexcept");
+#endif // _LIBCPP_STD_VER > 11
+}
diff --git a/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.nonvirtuals/eq.pass.cpp b/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.nonvirtuals/eq.pass.cpp
new file mode 100644
index 000000000000..bec5e630aecf
--- /dev/null
+++ b/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.nonvirtuals/eq.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_category
+
+// bool operator==(const error_category& rhs) const;
+
+#include <system_error>
+#include <cassert>
+
+int main()
+{
+ const std::error_category& e_cat1 = std::generic_category();
+ const std::error_category& e_cat2 = std::generic_category();
+ const std::error_category& e_cat3 = std::system_category();
+ assert(e_cat1 == e_cat2);
+ assert(!(e_cat1 == e_cat3));
+}
diff --git a/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.nonvirtuals/lt.pass.cpp b/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.nonvirtuals/lt.pass.cpp
new file mode 100644
index 000000000000..707604e486a4
--- /dev/null
+++ b/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.nonvirtuals/lt.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_category
+
+// bool operator<(const error_category& rhs) const;
+
+#include <system_error>
+#include <cassert>
+
+int main()
+{
+ const std::error_category& e_cat1 = std::generic_category();
+ const std::error_category& e_cat2 = std::generic_category();
+ const std::error_category& e_cat3 = std::system_category();
+ assert(!(e_cat1 < e_cat2) && !(e_cat2 < e_cat1));
+ assert((e_cat1 < e_cat3) || (e_cat3 < e_cat1));
+}
diff --git a/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.nonvirtuals/neq.pass.cpp b/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.nonvirtuals/neq.pass.cpp
new file mode 100644
index 000000000000..e74458f3fbb6
--- /dev/null
+++ b/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.nonvirtuals/neq.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_category
+
+// bool operator!=(const error_category& rhs) const;
+
+#include <system_error>
+#include <cassert>
+
+int main()
+{
+ const std::error_category& e_cat1 = std::generic_category();
+ const std::error_category& e_cat2 = std::generic_category();
+ const std::error_category& e_cat3 = std::system_category();
+ assert(!(e_cat1 != e_cat2));
+ assert(e_cat1 != e_cat3);
+}
diff --git a/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/generic_category.pass.cpp b/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/generic_category.pass.cpp
new file mode 100644
index 000000000000..972299936ddf
--- /dev/null
+++ b/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/generic_category.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_category
+
+// const error_category& generic_category();
+
+#include <system_error>
+#include <cassert>
+#include <string>
+
+int main()
+{
+ const std::error_category& e_cat1 = std::generic_category();
+ std::string m1 = e_cat1.name();
+ assert(m1 == "generic");
+}
diff --git a/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/system_category.pass.cpp b/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/system_category.pass.cpp
new file mode 100644
index 000000000000..b5cb18ad7653
--- /dev/null
+++ b/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/system_category.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_category
+
+// const error_category& system_category();
+
+#include <system_error>
+#include <cassert>
+#include <string>
+
+int main()
+{
+ const std::error_category& e_cat1 = std::system_category();
+ std::error_condition e_cond = e_cat1.default_error_condition(5);
+ assert(e_cond.value() == 5);
+ assert(e_cond.category() == std::generic_category());
+ e_cond = e_cat1.default_error_condition(5000);
+ assert(e_cond.value() == 5000);
+ assert(e_cond.category() == std::system_category());
+}
diff --git a/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.overview/error_category.pass.cpp b/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.overview/error_category.pass.cpp
new file mode 100644
index 000000000000..235305878390
--- /dev/null
+++ b/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.overview/error_category.pass.cpp
@@ -0,0 +1,19 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_category
+
+#include <system_error>
+
+int main()
+{
+ std::error_category* p = 0;
+}
diff --git a/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.virtuals/default_error_condition.pass.cpp b/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.virtuals/default_error_condition.pass.cpp
new file mode 100644
index 000000000000..dd51827128b1
--- /dev/null
+++ b/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.virtuals/default_error_condition.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_category
+
+// virtual error_condition default_error_condition(int ev) const;
+
+#include <system_error>
+#include <cassert>
+
+int main()
+{
+ const std::error_category& e_cat = std::generic_category();
+ std::error_condition e_cond = e_cat.default_error_condition(static_cast<int>(std::errc::not_a_directory));
+ assert(e_cond.category() == e_cat);
+ assert(e_cond.value() == static_cast<int>(std::errc::not_a_directory));
+}
diff --git a/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.virtuals/equivalent_error_code_int.pass.cpp b/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.virtuals/equivalent_error_code_int.pass.cpp
new file mode 100644
index 000000000000..d26541d943f3
--- /dev/null
+++ b/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.virtuals/equivalent_error_code_int.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_category
+
+// virtual bool equivalent(const error_code& code, int condition) const;
+
+#include <system_error>
+#include <cassert>
+
+int main()
+{
+ const std::error_category& e_cat = std::generic_category();
+ assert(e_cat.equivalent(std::error_code(5, e_cat), 5));
+ assert(!e_cat.equivalent(std::error_code(5, e_cat), 6));
+}
diff --git a/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.virtuals/equivalent_int_error_condition.pass.cpp b/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.virtuals/equivalent_int_error_condition.pass.cpp
new file mode 100644
index 000000000000..d7cf844dffe4
--- /dev/null
+++ b/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.virtuals/equivalent_int_error_condition.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_category
+
+// virtual bool equivalent(int code, const error_condition& condition) const;
+
+#include <system_error>
+#include <cassert>
+
+int main()
+{
+ const std::error_category& e_cat = std::generic_category();
+ std::error_condition e_cond = e_cat.default_error_condition(5);
+ assert(e_cat.equivalent(5, e_cond));
+ assert(!e_cat.equivalent(6, e_cond));
+}
diff --git a/test/std/diagnostics/syserr/syserr.errcode/nothing_to_do.pass.cpp b/test/std/diagnostics/syserr/syserr.errcode/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/diagnostics/syserr/syserr.errcode/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.constructors/ErrorCodeEnum.pass.cpp b/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.constructors/ErrorCodeEnum.pass.cpp
new file mode 100644
index 000000000000..0100b1c77724
--- /dev/null
+++ b/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.constructors/ErrorCodeEnum.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_code
+
+// template <ErrorCodeEnum E> error_code(E e);
+
+#include <system_error>
+#include <cassert>
+
+enum testing
+{
+ zero, one, two
+};
+
+namespace std
+{
+
+template <> struct is_error_code_enum<testing> : public std::true_type {};
+
+}
+
+std::error_code
+make_error_code(testing x)
+{
+ return std::error_code(static_cast<int>(x), std::generic_category());
+}
+
+int main()
+{
+ {
+ std::error_code ec(two);
+ assert(ec.value() == 2);
+ assert(ec.category() == std::generic_category());
+ }
+}
diff --git a/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.constructors/default.pass.cpp b/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.constructors/default.pass.cpp
new file mode 100644
index 000000000000..569681b751e8
--- /dev/null
+++ b/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.constructors/default.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_code
+
+// error_code();
+
+#include <system_error>
+#include <cassert>
+
+int main()
+{
+ std::error_code ec;
+ assert(ec.value() == 0);
+ assert(ec.category() == std::system_category());
+}
diff --git a/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.constructors/int_error_category.pass.cpp b/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.constructors/int_error_category.pass.cpp
new file mode 100644
index 000000000000..56489bb71b17
--- /dev/null
+++ b/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.constructors/int_error_category.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_code
+
+// error_code(int val, const error_category& cat);
+
+#include <system_error>
+#include <cassert>
+
+int main()
+{
+ {
+ std::error_code ec(6, std::system_category());
+ assert(ec.value() == 6);
+ assert(ec.category() == std::system_category());
+ }
+ {
+ std::error_code ec(8, std::generic_category());
+ assert(ec.value() == 8);
+ assert(ec.category() == std::generic_category());
+ }
+}
diff --git a/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.modifiers/ErrorCodeEnum.pass.cpp b/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.modifiers/ErrorCodeEnum.pass.cpp
new file mode 100644
index 000000000000..6c073c9fd151
--- /dev/null
+++ b/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.modifiers/ErrorCodeEnum.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_code
+
+// template <ErrorCodeEnum E> error_code& operator=(E e);
+
+#include <system_error>
+#include <cassert>
+
+enum testing
+{
+ zero, one, two
+};
+
+namespace std
+{
+
+template <> struct is_error_code_enum<testing> : public std::true_type {};
+
+}
+
+std::error_code
+make_error_code(testing x)
+{
+ return std::error_code(static_cast<int>(x), std::generic_category());
+}
+
+int main()
+{
+ {
+ std::error_code ec;
+ ec = two;
+ assert(ec.value() == 2);
+ assert(ec.category() == std::generic_category());
+ }
+}
diff --git a/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.modifiers/assign.pass.cpp b/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.modifiers/assign.pass.cpp
new file mode 100644
index 000000000000..967692a4f1dc
--- /dev/null
+++ b/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.modifiers/assign.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_code
+
+// void assign(int val, const error_category& cat);
+
+#include <system_error>
+#include <cassert>
+
+int main()
+{
+ {
+ std::error_code ec;
+ ec.assign(6, std::system_category());
+ assert(ec.value() == 6);
+ assert(ec.category() == std::system_category());
+ }
+ {
+ std::error_code ec;
+ ec.assign(8, std::generic_category());
+ assert(ec.value() == 8);
+ assert(ec.category() == std::generic_category());
+ }
+}
diff --git a/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.modifiers/clear.pass.cpp b/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.modifiers/clear.pass.cpp
new file mode 100644
index 000000000000..83faa03d28fa
--- /dev/null
+++ b/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.modifiers/clear.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_code
+
+// void clear();
+
+#include <system_error>
+#include <cassert>
+
+int main()
+{
+ {
+ std::error_code ec;
+ ec.assign(6, std::generic_category());
+ assert(ec.value() == 6);
+ assert(ec.category() == std::generic_category());
+ ec.clear();
+ assert(ec.value() == 0);
+ assert(ec.category() == std::system_category());
+ }
+}
diff --git a/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.nonmembers/lt.pass.cpp b/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.nonmembers/lt.pass.cpp
new file mode 100644
index 000000000000..01abc42b3ea9
--- /dev/null
+++ b/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.nonmembers/lt.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_code
+
+// bool operator<(const error_code& lhs, const error_code& rhs);
+
+#include <system_error>
+#include <string>
+#include <cassert>
+
+int main()
+{
+ {
+ const std::error_code ec1(6, std::generic_category());
+ const std::error_code ec2(7, std::generic_category());
+ assert(ec1 < ec2);
+ }
+}
diff --git a/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.nonmembers/make_error_code.pass.cpp b/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.nonmembers/make_error_code.pass.cpp
new file mode 100644
index 000000000000..fc4e0f2b25eb
--- /dev/null
+++ b/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.nonmembers/make_error_code.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_code
+
+// error_code make_error_code(errc e);
+
+#include <system_error>
+#include <cassert>
+
+int main()
+{
+ {
+ std::error_code ec = make_error_code(std::errc::operation_canceled);
+ assert(ec.value() == static_cast<int>(std::errc::operation_canceled));
+ assert(ec.category() == std::generic_category());
+ }
+}
diff --git a/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.nonmembers/stream_inserter.pass.cpp b/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.nonmembers/stream_inserter.pass.cpp
new file mode 100644
index 000000000000..09c87e5cea1c
--- /dev/null
+++ b/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.nonmembers/stream_inserter.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_code
+
+// template <class charT, class traits>
+// basic_ostream<charT,traits>&
+// operator<<(basic_ostream<charT,traits>& os, const error_code& ec);
+
+#include <system_error>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ std::ostringstream out;
+ out << std::error_code(std::io_errc::stream);
+ assert(out.str() == "iostream:1");
+}
diff --git a/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/bool.pass.cpp b/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/bool.pass.cpp
new file mode 100644
index 000000000000..0b20024013fc
--- /dev/null
+++ b/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/bool.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_code
+
+// explicit operator bool() const;
+
+#include <system_error>
+#include <string>
+#include <cassert>
+
+int main()
+{
+ {
+ const std::error_code ec(6, std::generic_category());
+ assert(static_cast<bool>(ec));
+ }
+ {
+ const std::error_code ec(0, std::generic_category());
+ assert(!static_cast<bool>(ec));
+ }
+}
diff --git a/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/category.pass.cpp b/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/category.pass.cpp
new file mode 100644
index 000000000000..f2e50cf65ce1
--- /dev/null
+++ b/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/category.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_code
+
+// const error_category& category() const;
+
+#include <system_error>
+#include <cassert>
+
+int main()
+{
+ const std::error_code ec(6, std::generic_category());
+ assert(ec.category() == std::generic_category());
+}
diff --git a/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/default_error_condition.pass.cpp b/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/default_error_condition.pass.cpp
new file mode 100644
index 000000000000..0a67cd5db6ad
--- /dev/null
+++ b/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/default_error_condition.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_code
+
+// error_condition default_error_condition() const;
+
+#include <system_error>
+#include <cassert>
+
+int main()
+{
+ {
+ const std::error_code ec(6, std::generic_category());
+ std::error_condition e_cond = ec.default_error_condition();
+ assert(e_cond == ec);
+ }
+ {
+ const std::error_code ec(6, std::system_category());
+ std::error_condition e_cond = ec.default_error_condition();
+ assert(e_cond == ec);
+ }
+}
diff --git a/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/message.pass.cpp b/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/message.pass.cpp
new file mode 100644
index 000000000000..530f42ca9b89
--- /dev/null
+++ b/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/message.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_code
+
+// string message() const;
+
+#include <system_error>
+#include <string>
+#include <cassert>
+
+int main()
+{
+ const std::error_code ec(6, std::generic_category());
+ assert(ec.message() == std::generic_category().message(6));
+}
diff --git a/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/value.pass.cpp b/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/value.pass.cpp
new file mode 100644
index 000000000000..1047b7d4213e
--- /dev/null
+++ b/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/value.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_code
+
+// int value() const;
+
+#include <system_error>
+#include <cassert>
+
+int main()
+{
+ const std::error_code ec(6, std::system_category());
+ assert(ec.value() == 6);
+}
diff --git a/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.overview/nothing_to_do.pass.cpp b/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.overview/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.overview/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/diagnostics/syserr/syserr.errcondition/nothing_to_do.pass.cpp b/test/std/diagnostics/syserr/syserr.errcondition/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/diagnostics/syserr/syserr.errcondition/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/diagnostics/syserr/syserr.errcondition/syserr.errcondition.constructors/ErrorConditionEnum.pass.cpp b/test/std/diagnostics/syserr/syserr.errcondition/syserr.errcondition.constructors/ErrorConditionEnum.pass.cpp
new file mode 100644
index 000000000000..fbc03f1aa029
--- /dev/null
+++ b/test/std/diagnostics/syserr/syserr.errcondition/syserr.errcondition.constructors/ErrorConditionEnum.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_condition
+
+// template <ErrorConditionEnum E> error_condition(E e);
+
+#include <system_error>
+#include <cassert>
+
+int main()
+{
+ {
+ std::error_condition ec(std::errc::not_a_directory);
+ assert(ec.value() == static_cast<int>(std::errc::not_a_directory));
+ assert(ec.category() == std::generic_category());
+ }
+}
diff --git a/test/std/diagnostics/syserr/syserr.errcondition/syserr.errcondition.constructors/default.pass.cpp b/test/std/diagnostics/syserr/syserr.errcondition/syserr.errcondition.constructors/default.pass.cpp
new file mode 100644
index 000000000000..a430ee2f7d82
--- /dev/null
+++ b/test/std/diagnostics/syserr/syserr.errcondition/syserr.errcondition.constructors/default.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_condition
+
+// error_condition();
+
+#include <system_error>
+#include <cassert>
+
+int main()
+{
+ std::error_condition ec;
+ assert(ec.value() == 0);
+ assert(ec.category() == std::generic_category());
+}
diff --git a/test/std/diagnostics/syserr/syserr.errcondition/syserr.errcondition.constructors/int_error_category.pass.cpp b/test/std/diagnostics/syserr/syserr.errcondition/syserr.errcondition.constructors/int_error_category.pass.cpp
new file mode 100644
index 000000000000..f3b9eada7651
--- /dev/null
+++ b/test/std/diagnostics/syserr/syserr.errcondition/syserr.errcondition.constructors/int_error_category.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_condition
+
+// error_condition(int val, const error_category& cat);
+
+#include <system_error>
+#include <cassert>
+
+int main()
+{
+ {
+ std::error_condition ec(6, std::system_category());
+ assert(ec.value() == 6);
+ assert(ec.category() == std::system_category());
+ }
+ {
+ std::error_condition ec(8, std::generic_category());
+ assert(ec.value() == 8);
+ assert(ec.category() == std::generic_category());
+ }
+}
diff --git a/test/std/diagnostics/syserr/syserr.errcondition/syserr.errcondition.modifiers/ErrorConditionEnum.pass.cpp b/test/std/diagnostics/syserr/syserr.errcondition/syserr.errcondition.modifiers/ErrorConditionEnum.pass.cpp
new file mode 100644
index 000000000000..3773872c7e39
--- /dev/null
+++ b/test/std/diagnostics/syserr/syserr.errcondition/syserr.errcondition.modifiers/ErrorConditionEnum.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_condition
+
+// template <ErrorConditionEnum E> error_condition& operator=(E e);
+
+#include <system_error>
+#include <cassert>
+
+int main()
+{
+ {
+ std::error_condition ec;
+ ec = std::errc::not_enough_memory;
+ assert(ec.value() == static_cast<int>(std::errc::not_enough_memory));
+ assert(ec.category() == std::generic_category());
+ }
+}
diff --git a/test/std/diagnostics/syserr/syserr.errcondition/syserr.errcondition.modifiers/assign.pass.cpp b/test/std/diagnostics/syserr/syserr.errcondition/syserr.errcondition.modifiers/assign.pass.cpp
new file mode 100644
index 000000000000..8fcfcc3603a5
--- /dev/null
+++ b/test/std/diagnostics/syserr/syserr.errcondition/syserr.errcondition.modifiers/assign.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_condition
+
+// void assign(int val, const error_category& cat);
+
+#include <system_error>
+#include <cassert>
+
+int main()
+{
+ {
+ std::error_condition ec;
+ ec.assign(6, std::system_category());
+ assert(ec.value() == 6);
+ assert(ec.category() == std::system_category());
+ }
+ {
+ std::error_condition ec;
+ ec.assign(8, std::generic_category());
+ assert(ec.value() == 8);
+ assert(ec.category() == std::generic_category());
+ }
+}
diff --git a/test/std/diagnostics/syserr/syserr.errcondition/syserr.errcondition.modifiers/clear.pass.cpp b/test/std/diagnostics/syserr/syserr.errcondition/syserr.errcondition.modifiers/clear.pass.cpp
new file mode 100644
index 000000000000..509a8b981187
--- /dev/null
+++ b/test/std/diagnostics/syserr/syserr.errcondition/syserr.errcondition.modifiers/clear.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_condition
+
+// void clear();
+
+#include <system_error>
+#include <cassert>
+
+int main()
+{
+ {
+ std::error_condition ec;
+ ec.assign(6, std::system_category());
+ assert(ec.value() == 6);
+ assert(ec.category() == std::system_category());
+ ec.clear();
+ assert(ec.value() == 0);
+ assert(ec.category() == std::generic_category());
+ }
+}
diff --git a/test/std/diagnostics/syserr/syserr.errcondition/syserr.errcondition.nonmembers/lt.pass.cpp b/test/std/diagnostics/syserr/syserr.errcondition/syserr.errcondition.nonmembers/lt.pass.cpp
new file mode 100644
index 000000000000..7ab063853d9d
--- /dev/null
+++ b/test/std/diagnostics/syserr/syserr.errcondition/syserr.errcondition.nonmembers/lt.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_condition
+
+// bool operator<(const error_condition& lhs, const error_condition& rhs);
+
+#include <system_error>
+#include <string>
+#include <cassert>
+
+int main()
+{
+ {
+ const std::error_condition ec1(6, std::generic_category());
+ const std::error_condition ec2(7, std::generic_category());
+ assert(ec1 < ec2);
+ }
+}
diff --git a/test/std/diagnostics/syserr/syserr.errcondition/syserr.errcondition.nonmembers/make_error_condition.pass.cpp b/test/std/diagnostics/syserr/syserr.errcondition/syserr.errcondition.nonmembers/make_error_condition.pass.cpp
new file mode 100644
index 000000000000..acefc4655abf
--- /dev/null
+++ b/test/std/diagnostics/syserr/syserr.errcondition/syserr.errcondition.nonmembers/make_error_condition.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_condition
+
+// error_condition make_error_condition(errc e);
+
+#include <system_error>
+#include <cassert>
+
+int main()
+{
+ {
+ const std::error_condition ec1 = std::make_error_condition(std::errc::message_size);
+ assert(ec1.value() == static_cast<int>(std::errc::message_size));
+ assert(ec1.category() == std::generic_category());
+ }
+}
diff --git a/test/std/diagnostics/syserr/syserr.errcondition/syserr.errcondition.observers/bool.pass.cpp b/test/std/diagnostics/syserr/syserr.errcondition/syserr.errcondition.observers/bool.pass.cpp
new file mode 100644
index 000000000000..edeca06d38b5
--- /dev/null
+++ b/test/std/diagnostics/syserr/syserr.errcondition/syserr.errcondition.observers/bool.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_condition
+
+// explicit operator bool() const;
+
+#include <system_error>
+#include <string>
+#include <cassert>
+
+int main()
+{
+ {
+ const std::error_condition ec(6, std::generic_category());
+ assert(static_cast<bool>(ec));
+ }
+ {
+ const std::error_condition ec(0, std::generic_category());
+ assert(!static_cast<bool>(ec));
+ }
+}
diff --git a/test/std/diagnostics/syserr/syserr.errcondition/syserr.errcondition.observers/category.pass.cpp b/test/std/diagnostics/syserr/syserr.errcondition/syserr.errcondition.observers/category.pass.cpp
new file mode 100644
index 000000000000..fd3e698566b2
--- /dev/null
+++ b/test/std/diagnostics/syserr/syserr.errcondition/syserr.errcondition.observers/category.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_condition
+
+// const error_category& category() const;
+
+#include <system_error>
+#include <cassert>
+
+int main()
+{
+ const std::error_condition ec(6, std::generic_category());
+ assert(ec.category() == std::generic_category());
+}
diff --git a/test/std/diagnostics/syserr/syserr.errcondition/syserr.errcondition.observers/message.pass.cpp b/test/std/diagnostics/syserr/syserr.errcondition/syserr.errcondition.observers/message.pass.cpp
new file mode 100644
index 000000000000..6a60f50f410d
--- /dev/null
+++ b/test/std/diagnostics/syserr/syserr.errcondition/syserr.errcondition.observers/message.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_condition
+
+// string message() const;
+
+#include <system_error>
+#include <string>
+#include <cassert>
+
+int main()
+{
+ const std::error_condition ec(6, std::generic_category());
+ assert(ec.message() == std::generic_category().message(6));
+}
diff --git a/test/std/diagnostics/syserr/syserr.errcondition/syserr.errcondition.observers/value.pass.cpp b/test/std/diagnostics/syserr/syserr.errcondition/syserr.errcondition.observers/value.pass.cpp
new file mode 100644
index 000000000000..c755673126bd
--- /dev/null
+++ b/test/std/diagnostics/syserr/syserr.errcondition/syserr.errcondition.observers/value.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_condition
+
+// int value() const;
+
+#include <system_error>
+#include <cassert>
+
+int main()
+{
+ const std::error_condition ec(6, std::system_category());
+ assert(ec.value() == 6);
+}
diff --git a/test/std/diagnostics/syserr/syserr.errcondition/syserr.errcondition.overview/nothing_to_do.pass.cpp b/test/std/diagnostics/syserr/syserr.errcondition/syserr.errcondition.overview/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/diagnostics/syserr/syserr.errcondition/syserr.errcondition.overview/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/diagnostics/syserr/syserr.hash/error_code.pass.cpp b/test/std/diagnostics/syserr/syserr.hash/error_code.pass.cpp
new file mode 100644
index 000000000000..b812e364bbc5
--- /dev/null
+++ b/test/std/diagnostics/syserr/syserr.hash/error_code.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template <class T>
+// struct hash
+// : public unary_function<T, size_t>
+// {
+// size_t operator()(T val) const;
+// };
+
+// Not very portable
+
+#include <system_error>
+#include <cassert>
+#include <type_traits>
+
+void
+test(int i)
+{
+ typedef std::error_code T;
+ typedef std::hash<T> H;
+ static_assert((std::is_same<H::argument_type, T>::value), "" );
+ static_assert((std::is_same<H::result_type, std::size_t>::value), "" );
+ H h;
+ T ec(i, std::system_category());
+ assert(h(ec) == i);
+}
+
+int main()
+{
+ test(0);
+ test(2);
+ test(10);
+}
diff --git a/test/std/diagnostics/syserr/syserr.syserr/nothing_to_do.pass.cpp b/test/std/diagnostics/syserr/syserr.syserr/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/diagnostics/syserr/syserr.syserr/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/diagnostics/syserr/syserr.syserr/syserr.syserr.members/ctor_error_code.pass.cpp b/test/std/diagnostics/syserr/syserr.syserr/syserr.syserr.members/ctor_error_code.pass.cpp
new file mode 100644
index 000000000000..c059ba3253c2
--- /dev/null
+++ b/test/std/diagnostics/syserr/syserr.syserr/syserr.syserr.members/ctor_error_code.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class system_error
+
+// system_error(error_code ec);
+
+// Test is slightly non-portable
+
+#include <system_error>
+#include <string>
+#include <cassert>
+
+int main()
+{
+ std::system_error se(static_cast<int>(std::errc::not_a_directory),
+ std::generic_category(), "some text");
+ assert(se.code() == std::make_error_code(std::errc::not_a_directory));
+ std::string what_message(se.what());
+ assert(what_message.find("Not a directory") != std::string::npos);
+}
diff --git a/test/std/diagnostics/syserr/syserr.syserr/syserr.syserr.members/ctor_error_code_const_char_pointer.pass.cpp b/test/std/diagnostics/syserr/syserr.syserr/syserr.syserr.members/ctor_error_code_const_char_pointer.pass.cpp
new file mode 100644
index 000000000000..cd8e3fefbf99
--- /dev/null
+++ b/test/std/diagnostics/syserr/syserr.syserr/syserr.syserr.members/ctor_error_code_const_char_pointer.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class system_error
+
+// system_error(error_code ec, const char* what_arg);
+
+// Test is slightly non-portable
+
+#include <system_error>
+#include <string>
+#include <cassert>
+
+int main()
+{
+ std::string what_arg("test message");
+ std::system_error se(make_error_code(std::errc::not_a_directory), what_arg.c_str());
+ assert(se.code() == std::make_error_code(std::errc::not_a_directory));
+ std::string what_message(se.what());
+ assert(what_message.find(what_arg) != std::string::npos);
+ assert(what_message.find("Not a directory") != std::string::npos);
+}
diff --git a/test/std/diagnostics/syserr/syserr.syserr/syserr.syserr.members/ctor_error_code_string.pass.cpp b/test/std/diagnostics/syserr/syserr.syserr/syserr.syserr.members/ctor_error_code_string.pass.cpp
new file mode 100644
index 000000000000..b891a6d973d4
--- /dev/null
+++ b/test/std/diagnostics/syserr/syserr.syserr/syserr.syserr.members/ctor_error_code_string.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class system_error
+
+// system_error(error_code ec, const string& what_arg);
+
+// Test is slightly non-portable
+
+#include <system_error>
+#include <string>
+#include <cassert>
+
+int main()
+{
+ std::string what_arg("test message");
+ std::system_error se(make_error_code(std::errc::not_a_directory), what_arg);
+ assert(se.code() == std::make_error_code(std::errc::not_a_directory));
+ std::string what_message(se.what());
+ assert(what_message.find(what_arg) != std::string::npos);
+ assert(what_message.find("Not a directory") != std::string::npos);
+}
diff --git a/test/std/diagnostics/syserr/syserr.syserr/syserr.syserr.members/ctor_int_error_category.pass.cpp b/test/std/diagnostics/syserr/syserr.syserr/syserr.syserr.members/ctor_int_error_category.pass.cpp
new file mode 100644
index 000000000000..acf6387fc24a
--- /dev/null
+++ b/test/std/diagnostics/syserr/syserr.syserr/syserr.syserr.members/ctor_int_error_category.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class system_error
+
+// system_error(int ev, const error_category& ecat);
+
+// Test is slightly non-portable
+
+#include <system_error>
+#include <string>
+#include <cassert>
+
+int main()
+{
+ std::system_error se(static_cast<int>(std::errc::not_a_directory),
+ std::generic_category());
+ assert(se.code() == std::make_error_code(std::errc::not_a_directory));
+ std::string what_message(se.what());
+ assert(what_message.find("Not a directory") != std::string::npos);
+}
diff --git a/test/std/diagnostics/syserr/syserr.syserr/syserr.syserr.members/ctor_int_error_category_const_char_pointer.pass.cpp b/test/std/diagnostics/syserr/syserr.syserr/syserr.syserr.members/ctor_int_error_category_const_char_pointer.pass.cpp
new file mode 100644
index 000000000000..4f697016ce15
--- /dev/null
+++ b/test/std/diagnostics/syserr/syserr.syserr/syserr.syserr.members/ctor_int_error_category_const_char_pointer.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class system_error
+
+// system_error(int ev, const error_category& ecat, const char* what_arg);
+
+// Test is slightly non-portable
+
+#include <system_error>
+#include <string>
+#include <cassert>
+
+int main()
+{
+ std::string what_arg("test message");
+ std::system_error se(static_cast<int>(std::errc::not_a_directory),
+ std::generic_category(), what_arg.c_str());
+ assert(se.code() == std::make_error_code(std::errc::not_a_directory));
+ std::string what_message(se.what());
+ assert(what_message.find(what_arg) != std::string::npos);
+ assert(what_message.find("Not a directory") != std::string::npos);
+}
diff --git a/test/std/diagnostics/syserr/syserr.syserr/syserr.syserr.members/ctor_int_error_category_string.pass.cpp b/test/std/diagnostics/syserr/syserr.syserr/syserr.syserr.members/ctor_int_error_category_string.pass.cpp
new file mode 100644
index 000000000000..87814b19079b
--- /dev/null
+++ b/test/std/diagnostics/syserr/syserr.syserr/syserr.syserr.members/ctor_int_error_category_string.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class system_error
+
+// system_error(int ev, const error_category& ecat, const string& what_arg);
+
+// Test is slightly non-portable
+
+#include <system_error>
+#include <string>
+#include <cassert>
+
+int main()
+{
+ std::string what_arg("test message");
+ std::system_error se(static_cast<int>(std::errc::not_a_directory),
+ std::generic_category(), what_arg);
+ assert(se.code() == std::make_error_code(std::errc::not_a_directory));
+ std::string what_message(se.what());
+ assert(what_message.find(what_arg) != std::string::npos);
+ assert(what_message.find("Not a directory") != std::string::npos);
+}
diff --git a/test/std/diagnostics/syserr/syserr.syserr/syserr.syserr.overview/nothing_to_do.pass.cpp b/test/std/diagnostics/syserr/syserr.syserr/syserr.syserr.overview/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/diagnostics/syserr/syserr.syserr/syserr.syserr.overview/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/diagnostics/syserr/version.pass.cpp b/test/std/diagnostics/syserr/version.pass.cpp
new file mode 100644
index 000000000000..3851150fdf90
--- /dev/null
+++ b/test/std/diagnostics/syserr/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+#include <system_error>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/experimental/algorithms/alg.random.sample/sample.fail.cpp b/test/std/experimental/algorithms/alg.random.sample/sample.fail.cpp
new file mode 100644
index 000000000000..eeb437379325
--- /dev/null
+++ b/test/std/experimental/algorithms/alg.random.sample/sample.fail.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template <class PopulationIterator, class SampleIterator, class Distance,
+// class UniformRandomNumberGenerator>
+// SampleIterator sample(PopulationIterator first, PopulationIterator last,
+// SampleIterator out, Distance n,
+// UniformRandomNumberGenerator &&g);
+
+#include <experimental/algorithm>
+#include <random>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class PopulationIterator, class SampleIterator> void test() {
+ int ia[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+ const unsigned is = sizeof(ia) / sizeof(ia[0]);
+ const unsigned os = 4;
+ int oa[os];
+ std::minstd_rand g;
+ std::experimental::sample(PopulationIterator(ia), PopulationIterator(ia + is),
+ SampleIterator(oa), os, g);
+}
+
+int main() {
+ test<input_iterator<int *>, output_iterator<int *> >();
+}
diff --git a/test/std/experimental/algorithms/alg.random.sample/sample.pass.cpp b/test/std/experimental/algorithms/alg.random.sample/sample.pass.cpp
new file mode 100644
index 000000000000..0f0784d6ee90
--- /dev/null
+++ b/test/std/experimental/algorithms/alg.random.sample/sample.pass.cpp
@@ -0,0 +1,146 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template <class PopulationIterator, class SampleIterator, class Distance,
+// class UniformRandomNumberGenerator>
+// SampleIterator sample(PopulationIterator first, PopulationIterator last,
+// SampleIterator out, Distance n,
+// UniformRandomNumberGenerator &&g);
+
+#include <experimental/algorithm>
+#include <random>
+#include <cassert>
+
+#include "test_iterators.h"
+
+struct ReservoirSampleExpectations {
+ enum { os = 4 };
+ static int oa1[os];
+ static int oa2[os];
+};
+
+int ReservoirSampleExpectations::oa1[] = {10, 5, 9, 4};
+int ReservoirSampleExpectations::oa2[] = {5, 2, 10, 4};
+
+struct SelectionSampleExpectations {
+ enum { os = 4 };
+ static int oa1[os];
+ static int oa2[os];
+};
+
+int SelectionSampleExpectations::oa1[] = {1, 4, 6, 7};
+int SelectionSampleExpectations::oa2[] = {1, 2, 6, 8};
+
+template <class IteratorCategory> struct TestExpectations
+ : public SelectionSampleExpectations {};
+
+template <>
+struct TestExpectations<std::input_iterator_tag>
+ : public ReservoirSampleExpectations {};
+
+template <template<class> class PopulationIteratorType, class PopulationItem,
+ template<class> class SampleIteratorType, class SampleItem>
+void test() {
+ typedef PopulationIteratorType<PopulationItem *> PopulationIterator;
+ typedef SampleIteratorType<SampleItem *> SampleIterator;
+ PopulationItem ia[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+ const unsigned is = sizeof(ia) / sizeof(ia[0]);
+ typedef TestExpectations<typename std::iterator_traits<
+ PopulationIterator>::iterator_category> Expectations;
+ const unsigned os = Expectations::os;
+ SampleItem oa[os];
+ const int *oa1 = Expectations::oa1;
+ const int *oa2 = Expectations::oa2;
+ std::minstd_rand g;
+ SampleIterator end;
+ end = std::experimental::sample(PopulationIterator(ia),
+ PopulationIterator(ia + is),
+ SampleIterator(oa), os, g);
+ assert(&*end - oa == std::min(os, is));
+ assert(std::equal(oa, oa + os, oa1));
+ end = std::experimental::sample(PopulationIterator(ia),
+ PopulationIterator(ia + is),
+ SampleIterator(oa), os, g);
+ assert(&*end - oa == std::min(os, is));
+ assert(std::equal(oa, oa + os, oa2));
+}
+
+template <template<class> class PopulationIteratorType, class PopulationItem,
+ template<class> class SampleIteratorType, class SampleItem>
+void test_empty_population() {
+ typedef PopulationIteratorType<PopulationItem *> PopulationIterator;
+ typedef SampleIteratorType<SampleItem *> SampleIterator;
+ PopulationItem ia[] = {42};
+ const unsigned os = 4;
+ SampleItem oa[os];
+ std::minstd_rand g;
+ SampleIterator end =
+ std::experimental::sample(PopulationIterator(ia), PopulationIterator(ia),
+ SampleIterator(oa), os, g);
+ assert(&*end == oa);
+}
+
+template <template<class> class PopulationIteratorType, class PopulationItem,
+ template<class> class SampleIteratorType, class SampleItem>
+void test_empty_sample() {
+ typedef PopulationIteratorType<PopulationItem *> PopulationIterator;
+ typedef SampleIteratorType<SampleItem *> SampleIterator;
+ PopulationItem ia[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+ const unsigned is = sizeof(ia) / sizeof(ia[0]);
+ SampleItem oa[1];
+ std::minstd_rand g;
+ SampleIterator end =
+ std::experimental::sample(PopulationIterator(ia), PopulationIterator(ia + is),
+ SampleIterator(oa), 0, g);
+ assert(&*end == oa);
+}
+
+template <template<class> class PopulationIteratorType, class PopulationItem,
+ template<class> class SampleIteratorType, class SampleItem>
+void test_small_population() {
+ // The population size is less than the sample size.
+ typedef PopulationIteratorType<PopulationItem *> PopulationIterator;
+ typedef SampleIteratorType<SampleItem *> SampleIterator;
+ PopulationItem ia[] = {1, 2, 3, 4, 5};
+ const unsigned is = sizeof(ia) / sizeof(ia[0]);
+ const unsigned os = 8;
+ SampleItem oa[os];
+ const SampleItem oa1[] = {1, 2, 3, 4, 5};
+ std::minstd_rand g;
+ SampleIterator end;
+ end = std::experimental::sample(PopulationIterator(ia),
+ PopulationIterator(ia + is),
+ SampleIterator(oa), os, g);
+ assert(&*end - oa == std::min(os, is));
+ assert(std::equal(oa, &*end, oa1));
+}
+
+int main() {
+ test<input_iterator, int, random_access_iterator, int>();
+ test<forward_iterator, int, output_iterator, int>();
+ test<forward_iterator, int, random_access_iterator, int>();
+
+ test<input_iterator, int, random_access_iterator, double>();
+ test<forward_iterator, int, output_iterator, double>();
+ test<forward_iterator, int, random_access_iterator, double>();
+
+ test_empty_population<input_iterator, int, random_access_iterator, int>();
+ test_empty_population<forward_iterator, int, output_iterator, int>();
+ test_empty_population<forward_iterator, int, random_access_iterator, int>();
+
+ test_empty_sample<input_iterator, int, random_access_iterator, int>();
+ test_empty_sample<forward_iterator, int, output_iterator, int>();
+ test_empty_sample<forward_iterator, int, random_access_iterator, int>();
+
+ test_small_population<input_iterator, int, random_access_iterator, int>();
+ test_small_population<forward_iterator, int, output_iterator, int>();
+ test_small_population<forward_iterator, int, random_access_iterator, int>();
+}
diff --git a/test/std/experimental/algorithms/alg.random.sample/sample.stable.pass.cpp b/test/std/experimental/algorithms/alg.random.sample/sample.stable.pass.cpp
new file mode 100644
index 000000000000..c805c66fa5e7
--- /dev/null
+++ b/test/std/experimental/algorithms/alg.random.sample/sample.stable.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template <class PopulationIterator, class SampleIterator, class Distance,
+// class UniformRandomNumberGenerator>
+// SampleIterator sample(PopulationIterator first, PopulationIterator last,
+// SampleIterator out, Distance n,
+// UniformRandomNumberGenerator &&g);
+
+#include <experimental/algorithm>
+#include <random>
+#include <cassert>
+
+#include "test_iterators.h"
+
+// Stable if and only if PopulationIterator meets the requirements of a
+// ForwardIterator type.
+template <class PopulationIterator, class SampleIterator>
+void test_stability(bool expect_stable) {
+ const unsigned kPopulationSize = 100;
+ int ia[kPopulationSize];
+ for (unsigned i = 0; i < kPopulationSize; ++i)
+ ia[i] = i;
+ PopulationIterator first(ia);
+ PopulationIterator last(ia + kPopulationSize);
+
+ const unsigned kSampleSize = 20;
+ int oa[kPopulationSize];
+ SampleIterator out(oa);
+
+ std::minstd_rand g;
+
+ const int kIterations = 1000;
+ bool unstable = false;
+ for (int i = 0; i < kIterations; ++i) {
+ std::experimental::sample(first, last, out, kSampleSize, g);
+ unstable |= !std::is_sorted(oa, oa + kSampleSize);
+ }
+ assert(expect_stable == !unstable);
+}
+
+int main() {
+ test_stability<forward_iterator<int *>, output_iterator<int *> >(true);
+ test_stability<input_iterator<int *>, random_access_iterator<int *> >(false);
+}
diff --git a/test/std/experimental/nothing_to_do.pass.cpp b/test/std/experimental/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..c21f8a701685
--- /dev/null
+++ b/test/std/experimental/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <experimental/string_view>
+
+int main () {}
diff --git a/test/std/experimental/optional/optional.bad_optional_access/default.pass.cpp b/test/std/experimental/optional/optional.bad_optional_access/default.pass.cpp
new file mode 100644
index 000000000000..cecf98a3518b
--- /dev/null
+++ b/test/std/experimental/optional/optional.bad_optional_access/default.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// class bad_optional_access is default constructible
+
+#include <experimental/optional>
+#include <type_traits>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ using std::experimental::bad_optional_access;
+ bad_optional_access ex;
+#endif // _LIBCPP_STD_VER > 11
+}
diff --git a/test/std/experimental/optional/optional.bad_optional_access/derive.pass.cpp b/test/std/experimental/optional/optional.bad_optional_access/derive.pass.cpp
new file mode 100644
index 000000000000..c13d6603990a
--- /dev/null
+++ b/test/std/experimental/optional/optional.bad_optional_access/derive.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// class bad_optional_access : public logic_error
+
+#include <experimental/optional>
+#include <type_traits>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ using std::experimental::bad_optional_access;
+
+ static_assert(std::is_base_of<std::logic_error, bad_optional_access>::value, "");
+ static_assert(std::is_convertible<bad_optional_access*, std::logic_error*>::value, "");
+#endif // _LIBCPP_STD_VER > 11
+}
diff --git a/test/std/experimental/optional/optional.comp_with_t/equal.pass.cpp b/test/std/experimental/optional/optional.comp_with_t/equal.pass.cpp
new file mode 100644
index 000000000000..e796723cc097
--- /dev/null
+++ b/test/std/experimental/optional/optional.comp_with_t/equal.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// template <class T> constexpr bool operator==(const optional<T>& x, const T& v);
+// template <class T> constexpr bool operator==(const T& v, const optional<T>& x);
+
+#include <experimental/optional>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+
+struct X
+{
+ int i_;
+
+ constexpr X(int i) : i_(i) {}
+};
+
+constexpr bool operator == ( const X &lhs, const X &rhs )
+ { return lhs.i_ == rhs.i_ ; }
+
+#endif
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef X T;
+ typedef optional<T> O;
+
+ constexpr T val(2);
+ constexpr O o1; // disengaged
+ constexpr O o2{1}; // engaged
+ constexpr O o3{val}; // engaged
+
+ static_assert ( !(o1 == T(1)), "" );
+ static_assert ( (o2 == T(1)), "" );
+ static_assert ( !(o3 == T(1)), "" );
+ static_assert ( (o3 == T(2)), "" );
+ static_assert ( (o3 == val), "" );
+
+ static_assert ( !(T(1) == o1), "" );
+ static_assert ( (T(1) == o2), "" );
+ static_assert ( !(T(1) == o3), "" );
+ static_assert ( (T(2) == o3), "" );
+ static_assert ( (val == o3), "" );
+ }
+#endif
+}
diff --git a/test/std/experimental/optional/optional.comp_with_t/greater.pass.cpp b/test/std/experimental/optional/optional.comp_with_t/greater.pass.cpp
new file mode 100644
index 000000000000..cf3923bb4fb0
--- /dev/null
+++ b/test/std/experimental/optional/optional.comp_with_t/greater.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// template <class T> constexpr bool operator>(const optional<T>& x, const T& v);
+// template <class T> constexpr bool operator>(const T& v, const optional<T>& x);
+
+#include <experimental/optional>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+
+struct X
+{
+ int i_;
+
+ constexpr X(int i) : i_(i) {}
+};
+
+constexpr bool operator < ( const X &lhs, const X &rhs )
+ { return lhs.i_ < rhs.i_ ; }
+
+#endif
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+
+ {
+ typedef X T;
+ typedef optional<T> O;
+
+ constexpr T val(2);
+ constexpr O o1; // disengaged
+ constexpr O o2{1}; // engaged
+ constexpr O o3{val}; // engaged
+
+ static_assert ( !(o1 > T(1)), "" );
+ static_assert ( !(o2 > T(1)), "" ); // equal
+ static_assert ( (o3 > T(1)), "" );
+ static_assert ( !(o2 > val), "" );
+ static_assert ( !(o3 > val), "" ); // equal
+ static_assert ( !(o3 > T(3)), "" );
+
+ static_assert ( (T(1) > o1), "" );
+ static_assert ( !(T(1) > o2), "" ); // equal
+ static_assert ( !(T(1) > o3), "" );
+ static_assert ( (val > o2), "" );
+ static_assert ( !(val > o3), "" ); // equal
+ static_assert ( (T(3) > o3), "" );
+ }
+#endif
+}
diff --git a/test/std/experimental/optional/optional.comp_with_t/greater_equal.pass.cpp b/test/std/experimental/optional/optional.comp_with_t/greater_equal.pass.cpp
new file mode 100644
index 000000000000..85fea1377b3c
--- /dev/null
+++ b/test/std/experimental/optional/optional.comp_with_t/greater_equal.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// template <class T> constexpr bool operator>=(const optional<T>& x, const T& v);
+// template <class T> constexpr bool operator>=(const T& v, const optional<T>& x);
+
+#include <experimental/optional>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+
+struct X
+{
+ int i_;
+
+ constexpr X(int i) : i_(i) {}
+};
+
+constexpr bool operator < ( const X &lhs, const X &rhs )
+ { return lhs.i_ < rhs.i_ ; }
+
+#endif
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+
+ {
+ typedef X T;
+ typedef optional<T> O;
+
+ constexpr T val(2);
+ constexpr O o1; // disengaged
+ constexpr O o2{1}; // engaged
+ constexpr O o3{val}; // engaged
+
+ static_assert ( !(o1 >= T(1)), "" );
+ static_assert ( (o2 >= T(1)), "" ); // equal
+ static_assert ( (o3 >= T(1)), "" );
+ static_assert ( !(o2 >= val), "" );
+ static_assert ( (o3 >= val), "" ); // equal
+ static_assert ( !(o3 >= T(3)), "" );
+
+ static_assert ( (T(1) >= o1), "" );
+ static_assert ( (T(1) >= o2), "" ); // equal
+ static_assert ( !(T(1) >= o3), "" );
+ static_assert ( (val >= o2), "" );
+ static_assert ( (val >= o3), "" ); // equal
+ static_assert ( (T(3) >= o3), "" );
+ }
+#endif
+}
diff --git a/test/std/experimental/optional/optional.comp_with_t/less_equal.pass.cpp b/test/std/experimental/optional/optional.comp_with_t/less_equal.pass.cpp
new file mode 100644
index 000000000000..333f7cdea219
--- /dev/null
+++ b/test/std/experimental/optional/optional.comp_with_t/less_equal.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// template <class T> constexpr bool operator<=(const optional<T>& x, const T& v);
+// template <class T> constexpr bool operator<=(const T& v, const optional<T>& x);
+
+#include <experimental/optional>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+
+struct X
+{
+ int i_;
+
+ constexpr X(int i) : i_(i) {}
+};
+
+constexpr bool operator < ( const X &lhs, const X &rhs )
+ { return lhs.i_ < rhs.i_ ; }
+
+#endif
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+
+ {
+ typedef X T;
+ typedef optional<T> O;
+
+ constexpr T val(2);
+ constexpr O o1; // disengaged
+ constexpr O o2{1}; // engaged
+ constexpr O o3{val}; // engaged
+
+ static_assert ( (o1 <= T(1)), "" );
+ static_assert ( (o2 <= T(1)), "" ); // equal
+ static_assert ( !(o3 <= T(1)), "" );
+ static_assert ( (o2 <= val), "" );
+ static_assert ( (o3 <= val), "" ); // equal
+ static_assert ( (o3 <= T(3)), "" );
+
+ static_assert ( !(T(1) <= o1), "" );
+ static_assert ( (T(1) <= o2), "" ); // equal
+ static_assert ( (T(1) <= o3), "" );
+ static_assert ( !(val <= o2), "" );
+ static_assert ( (val <= o3), "" ); // equal
+ static_assert ( !(T(3) <= o3), "" );
+ }
+#endif
+}
diff --git a/test/std/experimental/optional/optional.comp_with_t/less_than.pass.cpp b/test/std/experimental/optional/optional.comp_with_t/less_than.pass.cpp
new file mode 100644
index 000000000000..e35df21bbabb
--- /dev/null
+++ b/test/std/experimental/optional/optional.comp_with_t/less_than.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// template <class T> constexpr bool operator<(const optional<T>& x, const T& v);
+// template <class T> constexpr bool operator<(const T& v, const optional<T>& x);
+
+#include <experimental/optional>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+
+struct X
+{
+ int i_;
+
+ constexpr X(int i) : i_(i) {}
+};
+
+constexpr bool operator < ( const X &lhs, const X &rhs )
+ { return lhs.i_ < rhs.i_ ; }
+
+#endif
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+
+ {
+ typedef X T;
+ typedef optional<T> O;
+
+ constexpr T val(2);
+ constexpr O o1; // disengaged
+ constexpr O o2{1}; // engaged
+ constexpr O o3{val}; // engaged
+
+ static_assert ( (o1 < T(1)), "" );
+ static_assert ( !(o2 < T(1)), "" ); // equal
+ static_assert ( !(o3 < T(1)), "" );
+ static_assert ( (o2 < val), "" );
+ static_assert ( !(o3 < val), "" ); // equal
+ static_assert ( (o3 < T(3)), "" );
+
+ static_assert ( !(T(1) < o1), "" );
+ static_assert ( !(T(1) < o2), "" ); // equal
+ static_assert ( (T(1) < o3), "" );
+ static_assert ( !(val < o2), "" );
+ static_assert ( !(val < o3), "" ); // equal
+ static_assert ( !(T(3) < o3), "" );
+ }
+#endif
+}
diff --git a/test/std/experimental/optional/optional.comp_with_t/not_equal.pass.cpp b/test/std/experimental/optional/optional.comp_with_t/not_equal.pass.cpp
new file mode 100644
index 000000000000..0dad68d38635
--- /dev/null
+++ b/test/std/experimental/optional/optional.comp_with_t/not_equal.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// template <class T> constexpr bool operator!=(const optional<T>& x, const T& v);
+// template <class T> constexpr bool operator!=(const T& v, const optional<T>& x);
+
+#include <experimental/optional>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+
+struct X
+{
+ int i_;
+
+ constexpr X(int i) : i_(i) {}
+};
+
+constexpr bool operator == ( const X &lhs, const X &rhs )
+ { return lhs.i_ == rhs.i_ ; }
+
+#endif
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef X T;
+ typedef optional<T> O;
+
+ constexpr T val(2);
+ constexpr O o1; // disengaged
+ constexpr O o2{1}; // engaged
+ constexpr O o3{val}; // engaged
+
+ static_assert ( (o1 != T(1)), "" );
+ static_assert ( !(o2 != T(1)), "" );
+ static_assert ( (o3 != T(1)), "" );
+ static_assert ( !(o3 != T(2)), "" );
+ static_assert ( !(o3 != val), "" );
+
+ static_assert ( (T(1) != o1), "" );
+ static_assert ( !(T(1) != o2), "" );
+ static_assert ( (T(1) != o3), "" );
+ static_assert ( !(T(2) != o3), "" );
+ static_assert ( !(val != o3), "" );
+ }
+#endif
+}
diff --git a/test/std/experimental/optional/optional.defs/tested_elsewhere.pass.cpp b/test/std/experimental/optional/optional.defs/tested_elsewhere.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/experimental/optional/optional.defs/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/experimental/optional/optional.general/nothing_to_do.pass.cpp b/test/std/experimental/optional/optional.general/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/experimental/optional/optional.general/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/experimental/optional/optional.hash/hash.pass.cpp b/test/std/experimental/optional/optional.hash/hash.pass.cpp
new file mode 100644
index 000000000000..9e5fb55c833f
--- /dev/null
+++ b/test/std/experimental/optional/optional.hash/hash.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// template <class T> struct hash<optional<T>>;
+
+#include <experimental/optional>
+#include <string>
+#include <memory>
+#include <cassert>
+
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ using std::experimental::optional;
+
+ {
+ typedef int T;
+ optional<T> opt;
+ assert(std::hash<optional<T>>{}(opt) == 0);
+ opt = 2;
+ assert(std::hash<optional<T>>{}(opt) == std::hash<T>{}(*opt));
+ }
+ {
+ typedef std::string T;
+ optional<T> opt;
+ assert(std::hash<optional<T>>{}(opt) == 0);
+ opt = std::string("123");
+ assert(std::hash<optional<T>>{}(opt) == std::hash<T>{}(*opt));
+ }
+ {
+ typedef std::unique_ptr<int> T;
+ optional<T> opt;
+ assert(std::hash<optional<T>>{}(opt) == 0);
+ opt = std::unique_ptr<int>(new int(3));
+ assert(std::hash<optional<T>>{}(opt) == std::hash<T>{}(*opt));
+ }
+#endif // _LIBCPP_STD_VER > 11
+}
diff --git a/test/std/experimental/optional/optional.inplace/in_place_t.pass.cpp b/test/std/experimental/optional/optional.inplace/in_place_t.pass.cpp
new file mode 100644
index 000000000000..360b9d91671e
--- /dev/null
+++ b/test/std/experimental/optional/optional.inplace/in_place_t.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// struct in_place_t{};
+// constexpr in_place_t in_place{};
+
+#include <experimental/optional>
+#include <type_traits>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+using std::experimental::in_place_t;
+using std::experimental::in_place;
+
+constexpr
+int
+test(const in_place_t&)
+{
+ return 3;
+}
+
+#endif
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+
+ static_assert((std::is_class<in_place_t>::value), "");
+ static_assert((std::is_empty<in_place_t>::value), "");
+
+ static_assert(test(in_place) == 3, "");
+#endif
+}
diff --git a/test/std/experimental/optional/optional.nullops/equal.pass.cpp b/test/std/experimental/optional/optional.nullops/equal.pass.cpp
new file mode 100644
index 000000000000..931db6144256
--- /dev/null
+++ b/test/std/experimental/optional/optional.nullops/equal.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+
+// <optional>
+
+// template <class T> constexpr bool operator==(const optional<T>& x, nullopt_t) noexcept;
+// template <class T> constexpr bool operator==(nullopt_t, const optional<T>& x) noexcept;
+
+#include <experimental/optional>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ using std::experimental::optional;
+ using std::experimental::nullopt_t;
+ using std::experimental::nullopt;
+
+ {
+ typedef int T;
+ typedef optional<T> O;
+
+ constexpr O o1; // disengaged
+ constexpr O o2{1}; // engaged
+
+ static_assert ( (nullopt == o1), "" );
+ static_assert ( !(nullopt == o2), "" );
+ static_assert ( (o1 == nullopt), "" );
+ static_assert ( !(o2 == nullopt), "" );
+
+ static_assert (noexcept(nullopt == o1), "");
+ static_assert (noexcept(o1 == nullopt), "");
+ }
+#endif
+}
diff --git a/test/std/experimental/optional/optional.nullops/greater.pass.cpp b/test/std/experimental/optional/optional.nullops/greater.pass.cpp
new file mode 100644
index 000000000000..b72a4d3f1a6a
--- /dev/null
+++ b/test/std/experimental/optional/optional.nullops/greater.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+
+// <optional>
+
+// template <class T> constexpr bool operator>(const optional<T>& x, nullopt_t) noexcept;
+// template <class T> constexpr bool operator>(nullopt_t, const optional<T>& x) noexcept;
+
+#include <experimental/optional>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ using std::experimental::optional;
+ using std::experimental::nullopt_t;
+ using std::experimental::nullopt;
+
+ {
+ typedef int T;
+ typedef optional<T> O;
+
+ constexpr O o1; // disengaged
+ constexpr O o2{1}; // engaged
+
+ static_assert ( !(nullopt > o1), "" );
+ static_assert ( !(nullopt > o2), "" );
+ static_assert ( !(o1 > nullopt), "" );
+ static_assert ( (o2 > nullopt), "" );
+
+ static_assert (noexcept(nullopt > o1), "");
+ static_assert (noexcept(o1 > nullopt), "");
+ }
+#endif
+}
diff --git a/test/std/experimental/optional/optional.nullops/greater_equal.pass.cpp b/test/std/experimental/optional/optional.nullops/greater_equal.pass.cpp
new file mode 100644
index 000000000000..86c8743b5558
--- /dev/null
+++ b/test/std/experimental/optional/optional.nullops/greater_equal.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+
+// <optional>
+
+// template <class T> constexpr bool operator>=(const optional<T>& x, nullopt_t) noexcept;
+// template <class T> constexpr bool operator>=(nullopt_t, const optional<T>& x) noexcept;
+
+#include <experimental/optional>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ using std::experimental::optional;
+ using std::experimental::nullopt_t;
+ using std::experimental::nullopt;
+
+ {
+ typedef int T;
+ typedef optional<T> O;
+
+ constexpr O o1; // disengaged
+ constexpr O o2{1}; // engaged
+
+ static_assert ( (nullopt >= o1), "" );
+ static_assert ( !(nullopt >= o2), "" );
+ static_assert ( (o1 >= nullopt), "" );
+ static_assert ( (o2 >= nullopt), "" );
+
+ static_assert (noexcept(nullopt >= o1), "");
+ static_assert (noexcept(o1 >= nullopt), "");
+ }
+#endif
+}
diff --git a/test/std/experimental/optional/optional.nullops/less_equal.pass.cpp b/test/std/experimental/optional/optional.nullops/less_equal.pass.cpp
new file mode 100644
index 000000000000..3e8444bc73f0
--- /dev/null
+++ b/test/std/experimental/optional/optional.nullops/less_equal.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+
+// <optional>
+
+// template <class T> constexpr bool operator<=(const optional<T>& x, nullopt_t) noexcept;
+// template <class T> constexpr bool operator<=(nullopt_t, const optional<T>& x) noexcept;
+
+#include <experimental/optional>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ using std::experimental::optional;
+ using std::experimental::nullopt_t;
+ using std::experimental::nullopt;
+
+ {
+ typedef int T;
+ typedef optional<T> O;
+
+ constexpr O o1; // disengaged
+ constexpr O o2{1}; // engaged
+
+ static_assert ( (nullopt <= o1), "" );
+ static_assert ( (nullopt <= o2), "" );
+ static_assert ( (o1 <= nullopt), "" );
+ static_assert ( !(o2 <= nullopt), "" );
+
+ static_assert (noexcept(nullopt <= o1), "");
+ static_assert (noexcept(o1 <= nullopt), "");
+ }
+#endif
+}
diff --git a/test/std/experimental/optional/optional.nullops/less_than.pass.cpp b/test/std/experimental/optional/optional.nullops/less_than.pass.cpp
new file mode 100644
index 000000000000..149c809b0403
--- /dev/null
+++ b/test/std/experimental/optional/optional.nullops/less_than.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+
+// <optional>
+
+// template <class T> constexpr bool operator<(const optional<T>& x, nullopt_t) noexcept;
+// template <class T> constexpr bool operator<(nullopt_t, const optional<T>& x) noexcept;
+
+#include <experimental/optional>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ using std::experimental::optional;
+ using std::experimental::nullopt_t;
+ using std::experimental::nullopt;
+
+ {
+ typedef int T;
+ typedef optional<T> O;
+
+ constexpr O o1; // disengaged
+ constexpr O o2{1}; // engaged
+
+ static_assert ( !(nullopt < o1), "" );
+ static_assert ( (nullopt < o2), "" );
+ static_assert ( !(o1 < nullopt), "" );
+ static_assert ( !(o2 < nullopt), "" );
+
+ static_assert (noexcept(nullopt < o1), "");
+ static_assert (noexcept(o1 < nullopt), "");
+ }
+#endif
+}
diff --git a/test/std/experimental/optional/optional.nullops/not_equal.pass.cpp b/test/std/experimental/optional/optional.nullops/not_equal.pass.cpp
new file mode 100644
index 000000000000..6f28edf6d266
--- /dev/null
+++ b/test/std/experimental/optional/optional.nullops/not_equal.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+
+// <optional>
+
+// template <class T> constexpr bool operator!=(const optional<T>& x, nullopt_t) noexcept;
+// template <class T> constexpr bool operator!=(nullopt_t, const optional<T>& x) noexcept;
+
+#include <experimental/optional>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ using std::experimental::optional;
+ using std::experimental::nullopt_t;
+ using std::experimental::nullopt;
+
+ {
+ typedef int T;
+ typedef optional<T> O;
+
+ constexpr O o1; // disengaged
+ constexpr O o2{1}; // engaged
+
+ static_assert ( !(nullopt != o1), "" );
+ static_assert ( (nullopt != o2), "" );
+ static_assert ( !(o1 != nullopt), "" );
+ static_assert ( (o2 != nullopt), "" );
+
+ static_assert (noexcept(nullopt != o1), "");
+ static_assert (noexcept(o1 != nullopt), "");
+ }
+#endif
+}
diff --git a/test/std/experimental/optional/optional.nullopt/nullopt_t.pass.cpp b/test/std/experimental/optional/optional.nullopt/nullopt_t.pass.cpp
new file mode 100644
index 000000000000..de1e83b653ce
--- /dev/null
+++ b/test/std/experimental/optional/optional.nullopt/nullopt_t.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// struct nullopt_t{see below};
+// constexpr nullopt_t nullopt(unspecified);
+
+#include <experimental/optional>
+#include <type_traits>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+using std::experimental::nullopt_t;
+using std::experimental::nullopt;
+
+constexpr
+int
+test(const nullopt_t&)
+{
+ return 3;
+}
+
+#endif
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ static_assert((std::is_class<nullopt_t>::value), "");
+ static_assert((std::is_empty<nullopt_t>::value), "");
+ static_assert((std::is_literal_type<nullopt_t>::value), "");
+ static_assert((!std::is_default_constructible<nullopt_t>::value), "");
+
+ static_assert(test(nullopt) == 3, "");
+#endif
+}
diff --git a/test/std/experimental/optional/optional.object/optional.object.assign/assign_value.pass.cpp b/test/std/experimental/optional/optional.object/optional.object.assign/assign_value.pass.cpp
new file mode 100644
index 000000000000..e256a098f1ac
--- /dev/null
+++ b/test/std/experimental/optional/optional.object/optional.object.assign/assign_value.pass.cpp
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// template <class U> optional<T>& operator=(U&& v);
+
+#include <experimental/optional>
+#include <type_traits>
+#include <cassert>
+#include <memory>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+
+struct X
+{
+};
+
+#endif // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ static_assert(std::is_assignable<optional<int>, int>::value, "");
+ static_assert(std::is_assignable<optional<int>, int&>::value, "");
+ static_assert(std::is_assignable<optional<int>&, int>::value, "");
+ static_assert(std::is_assignable<optional<int>&, int&>::value, "");
+ static_assert(std::is_assignable<optional<int>&, const int&>::value, "");
+ static_assert(!std::is_assignable<const optional<int>&, const int&>::value, "");
+ static_assert(!std::is_assignable<optional<int>, X>::value, "");
+ {
+ optional<int> opt;
+ opt = 1;
+ assert(static_cast<bool>(opt) == true);
+ assert(*opt == 1);
+ }
+ {
+ optional<int> opt;
+ const int i = 2;
+ opt = i;
+ assert(static_cast<bool>(opt) == true);
+ assert(*opt == i);
+ }
+ {
+ optional<int> opt(3);
+ const int i = 2;
+ opt = i;
+ assert(static_cast<bool>(opt) == true);
+ assert(*opt == i);
+ }
+ {
+ optional<std::unique_ptr<int>> opt;
+ opt = std::unique_ptr<int>(new int(3));
+ assert(static_cast<bool>(opt) == true);
+ assert(**opt == 3);
+ }
+ {
+ optional<std::unique_ptr<int>> opt(std::unique_ptr<int>(new int(2)));
+ opt = std::unique_ptr<int>(new int(3));
+ assert(static_cast<bool>(opt) == true);
+ assert(**opt == 3);
+ }
+#endif // _LIBCPP_STD_VER > 11
+}
diff --git a/test/std/experimental/optional/optional.object/optional.object.assign/copy.pass.cpp b/test/std/experimental/optional/optional.object/optional.object.assign/copy.pass.cpp
new file mode 100644
index 000000000000..81c3b4e6dfa2
--- /dev/null
+++ b/test/std/experimental/optional/optional.object/optional.object.assign/copy.pass.cpp
@@ -0,0 +1,90 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// optional<T>& operator=(const optional<T>& rhs);
+
+#include <experimental/optional>
+#include <type_traits>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+
+struct X
+{
+ static bool throw_now;
+
+ X() = default;
+ X(const X&)
+ {
+ if (throw_now)
+ throw 6;
+ }
+};
+
+bool X::throw_now = false;
+
+#endif // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ {
+ optional<int> opt;
+ constexpr optional<int> opt2;
+ opt = opt2;
+ static_assert(static_cast<bool>(opt2) == false, "");
+ assert(static_cast<bool>(opt) == static_cast<bool>(opt2));
+ }
+ {
+ optional<int> opt;
+ constexpr optional<int> opt2(2);
+ opt = opt2;
+ static_assert(static_cast<bool>(opt2) == true, "");
+ static_assert(*opt2 == 2, "");
+ assert(static_cast<bool>(opt) == static_cast<bool>(opt2));
+ assert(*opt == *opt2);
+ }
+ {
+ optional<int> opt(3);
+ constexpr optional<int> opt2;
+ opt = opt2;
+ static_assert(static_cast<bool>(opt2) == false, "");
+ assert(static_cast<bool>(opt) == static_cast<bool>(opt2));
+ }
+ {
+ optional<int> opt(3);
+ constexpr optional<int> opt2(2);
+ opt = opt2;
+ static_assert(static_cast<bool>(opt2) == true, "");
+ static_assert(*opt2 == 2, "");
+ assert(static_cast<bool>(opt) == static_cast<bool>(opt2));
+ assert(*opt == *opt2);
+ }
+ {
+ optional<X> opt;
+ optional<X> opt2(X{});
+ assert(static_cast<bool>(opt2) == true);
+ try
+ {
+ X::throw_now = true;
+ opt = opt2;
+ assert(false);
+ }
+ catch (int i)
+ {
+ assert(i == 6);
+ assert(static_cast<bool>(opt) == false);
+ }
+ }
+#endif // _LIBCPP_STD_VER > 11
+}
diff --git a/test/std/experimental/optional/optional.object/optional.object.assign/emplace.pass.cpp b/test/std/experimental/optional/optional.object/optional.object.assign/emplace.pass.cpp
new file mode 100644
index 000000000000..c4361ea5178d
--- /dev/null
+++ b/test/std/experimental/optional/optional.object/optional.object.assign/emplace.pass.cpp
@@ -0,0 +1,148 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// template <class... Args> void optional<T>::emplace(Args&&... args);
+
+#include <experimental/optional>
+#include <type_traits>
+#include <cassert>
+#include <memory>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+
+class X
+{
+ int i_;
+ int j_ = 0;
+public:
+ X() : i_(0) {}
+ X(int i) : i_(i) {}
+ X(int i, int j) : i_(i), j_(j) {}
+
+ friend bool operator==(const X& x, const X& y)
+ {return x.i_ == y.i_ && x.j_ == y.j_;}
+};
+
+class Y
+{
+public:
+ static bool dtor_called;
+ Y() = default;
+ ~Y() {dtor_called = true;}
+};
+
+bool Y::dtor_called = false;
+
+class Z
+{
+public:
+ static bool dtor_called;
+ Z() = default;
+ Z(int) {throw 6;}
+ ~Z() {dtor_called = true;}
+};
+
+bool Z::dtor_called = false;
+
+#endif // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ {
+ optional<int> opt;
+ opt.emplace();
+ assert(static_cast<bool>(opt) == true);
+ assert(*opt == 0);
+ }
+ {
+ optional<int> opt;
+ opt.emplace(1);
+ assert(static_cast<bool>(opt) == true);
+ assert(*opt == 1);
+ }
+ {
+ optional<int> opt(2);
+ opt.emplace();
+ assert(static_cast<bool>(opt) == true);
+ assert(*opt == 0);
+ }
+ {
+ optional<int> opt(2);
+ opt.emplace(1);
+ assert(static_cast<bool>(opt) == true);
+ assert(*opt == 1);
+ }
+ {
+ optional<X> opt;
+ opt.emplace();
+ assert(static_cast<bool>(opt) == true);
+ assert(*opt == X());
+ }
+ {
+ optional<X> opt;
+ opt.emplace(1);
+ assert(static_cast<bool>(opt) == true);
+ assert(*opt == X(1));
+ }
+ {
+ optional<X> opt;
+ opt.emplace(1, 2);
+ assert(static_cast<bool>(opt) == true);
+ assert(*opt == X(1, 2));
+ }
+ {
+ optional<X> opt(X{3});
+ opt.emplace();
+ assert(static_cast<bool>(opt) == true);
+ assert(*opt == X());
+ }
+ {
+ optional<X> opt(X{3});
+ opt.emplace(1);
+ assert(static_cast<bool>(opt) == true);
+ assert(*opt == X(1));
+ }
+ {
+ optional<X> opt(X{3});
+ opt.emplace(1, 2);
+ assert(static_cast<bool>(opt) == true);
+ assert(*opt == X(1, 2));
+ }
+ {
+ Y y;
+ {
+ optional<Y> opt(y);
+ assert(Y::dtor_called == false);
+ opt.emplace();
+ assert(Y::dtor_called == true);
+ }
+ }
+ {
+ Z z;
+ optional<Z> opt(z);
+ try
+ {
+ assert(static_cast<bool>(opt) == true);
+ assert(Z::dtor_called == false);
+ opt.emplace(1);
+ }
+ catch (int i)
+ {
+ assert(i == 6);
+ assert(static_cast<bool>(opt) == false);
+ assert(Z::dtor_called == true);
+ }
+ }
+#endif // _LIBCPP_STD_VER > 11
+}
diff --git a/test/std/experimental/optional/optional.object/optional.object.assign/emplace_initializer_list.pass.cpp b/test/std/experimental/optional/optional.object/optional.object.assign/emplace_initializer_list.pass.cpp
new file mode 100644
index 000000000000..8d20be3de19a
--- /dev/null
+++ b/test/std/experimental/optional/optional.object/optional.object.assign/emplace_initializer_list.pass.cpp
@@ -0,0 +1,116 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// template <class U, class... Args>
+// void optional<T>::emplace(initializer_list<U> il, Args&&... args);
+
+#include <experimental/optional>
+#include <type_traits>
+#include <cassert>
+#include <vector>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+
+class X
+{
+ int i_;
+ int j_ = 0;
+public:
+ static bool dtor_called;
+ constexpr X() : i_(0) {}
+ constexpr X(int i) : i_(i) {}
+ constexpr X(std::initializer_list<int> il) : i_(il.begin()[0]), j_(il.begin()[1]) {}
+ ~X() {dtor_called = true;}
+
+ friend constexpr bool operator==(const X& x, const X& y)
+ {return x.i_ == y.i_ && x.j_ == y.j_;}
+};
+
+bool X::dtor_called = false;
+
+class Y
+{
+ int i_;
+ int j_ = 0;
+public:
+ constexpr Y() : i_(0) {}
+ constexpr Y(int i) : i_(i) {}
+ constexpr Y(std::initializer_list<int> il) : i_(il.begin()[0]), j_(il.begin()[1]) {}
+
+ friend constexpr bool operator==(const Y& x, const Y& y)
+ {return x.i_ == y.i_ && x.j_ == y.j_;}
+};
+
+class Z
+{
+ int i_;
+ int j_ = 0;
+public:
+ static bool dtor_called;
+ constexpr Z() : i_(0) {}
+ constexpr Z(int i) : i_(i) {}
+ constexpr Z(std::initializer_list<int> il) : i_(il.begin()[0]), j_(il.begin()[1])
+ {throw 6;}
+ ~Z() {dtor_called = true;}
+
+ friend constexpr bool operator==(const Z& x, const Z& y)
+ {return x.i_ == y.i_ && x.j_ == y.j_;}
+};
+
+bool Z::dtor_called = false;
+
+#endif // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ {
+ X x;
+ {
+ optional<X> opt(x);
+ assert(X::dtor_called == false);
+ opt.emplace({1, 2});
+ assert(X::dtor_called == true);
+ assert(*opt == X({1, 2}));
+ }
+ }
+ {
+ optional<std::vector<int>> opt;
+ opt.emplace({1, 2, 3}, std::allocator<int>());
+ assert(static_cast<bool>(opt) == true);
+ assert(*opt == std::vector<int>({1, 2, 3}));
+ }
+ {
+ optional<Y> opt;
+ opt.emplace({1, 2});
+ assert(static_cast<bool>(opt) == true);
+ assert(*opt == Y({1, 2}));
+ }
+ {
+ Z z;
+ optional<Z> opt(z);
+ try
+ {
+ assert(static_cast<bool>(opt) == true);
+ assert(Z::dtor_called == false);
+ opt.emplace({1, 2});
+ }
+ catch (int i)
+ {
+ assert(i == 6);
+ assert(static_cast<bool>(opt) == false);
+ assert(Z::dtor_called == true);
+ }
+ }
+#endif // _LIBCPP_STD_VER > 11
+}
diff --git a/test/std/experimental/optional/optional.object/optional.object.assign/move.pass.cpp b/test/std/experimental/optional/optional.object/optional.object.assign/move.pass.cpp
new file mode 100644
index 000000000000..d27313dad42b
--- /dev/null
+++ b/test/std/experimental/optional/optional.object/optional.object.assign/move.pass.cpp
@@ -0,0 +1,103 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// optional<T>& operator=(optional<T>&& rhs)
+// noexcept(is_nothrow_move_assignable<T>::value &&
+// is_nothrow_move_constructible<T>::value);
+
+#include <experimental/optional>
+#include <type_traits>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+
+struct X
+{
+ static bool throw_now;
+
+ X() = default;
+ X(X&&)
+ {
+ if (throw_now)
+ throw 6;
+ }
+ X& operator=(X&&) noexcept
+ {
+ return *this;
+ }
+};
+
+struct Y {};
+
+bool X::throw_now = false;
+
+#endif // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ {
+ static_assert(std::is_nothrow_move_assignable<optional<int>>::value, "");
+ optional<int> opt;
+ constexpr optional<int> opt2;
+ opt = std::move(opt2);
+ static_assert(static_cast<bool>(opt2) == false, "");
+ assert(static_cast<bool>(opt) == static_cast<bool>(opt2));
+ }
+ {
+ optional<int> opt;
+ constexpr optional<int> opt2(2);
+ opt = std::move(opt2);
+ static_assert(static_cast<bool>(opt2) == true, "");
+ static_assert(*opt2 == 2, "");
+ assert(static_cast<bool>(opt) == static_cast<bool>(opt2));
+ assert(*opt == *opt2);
+ }
+ {
+ optional<int> opt(3);
+ constexpr optional<int> opt2;
+ opt = std::move(opt2);
+ static_assert(static_cast<bool>(opt2) == false, "");
+ assert(static_cast<bool>(opt) == static_cast<bool>(opt2));
+ }
+ {
+ optional<int> opt(3);
+ constexpr optional<int> opt2(2);
+ opt = std::move(opt2);
+ static_assert(static_cast<bool>(opt2) == true, "");
+ static_assert(*opt2 == 2, "");
+ assert(static_cast<bool>(opt) == static_cast<bool>(opt2));
+ assert(*opt == *opt2);
+ }
+ {
+ static_assert(!std::is_nothrow_move_assignable<optional<X>>::value, "");
+ optional<X> opt;
+ optional<X> opt2(X{});
+ assert(static_cast<bool>(opt2) == true);
+ try
+ {
+ X::throw_now = true;
+ opt = std::move(opt2);
+ assert(false);
+ }
+ catch (int i)
+ {
+ assert(i == 6);
+ assert(static_cast<bool>(opt) == false);
+ }
+ }
+ {
+ static_assert(std::is_nothrow_move_assignable<optional<Y>>::value, "");
+ }
+#endif // _LIBCPP_STD_VER > 11
+}
diff --git a/test/std/experimental/optional/optional.object/optional.object.assign/nullopt_t.pass.cpp b/test/std/experimental/optional/optional.object/optional.object.assign/nullopt_t.pass.cpp
new file mode 100644
index 000000000000..7f39744f0557
--- /dev/null
+++ b/test/std/experimental/optional/optional.object/optional.object.assign/nullopt_t.pass.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// optional<T>& operator=(nullopt_t) noexcept;
+
+#include <experimental/optional>
+#include <type_traits>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+using std::experimental::nullopt_t;
+using std::experimental::nullopt;
+
+struct X
+{
+ static bool dtor_called;
+ ~X() {dtor_called = true;}
+};
+
+bool X::dtor_called = false;
+
+#endif // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ {
+ optional<int> opt;
+ static_assert(noexcept(opt = nullopt) == true, "");
+ opt = nullopt;
+ assert(static_cast<bool>(opt) == false);
+ }
+ {
+ optional<int> opt(3);
+ opt = nullopt;
+ assert(static_cast<bool>(opt) == false);
+ }
+ {
+ optional<X> opt;
+ static_assert(noexcept(opt = nullopt) == true, "");
+ assert(X::dtor_called == false);
+ opt = nullopt;
+ assert(X::dtor_called == false);
+ assert(static_cast<bool>(opt) == false);
+ }
+ {
+ X x;
+ {
+ optional<X> opt(x);
+ assert(X::dtor_called == false);
+ opt = nullopt;
+ assert(X::dtor_called == true);
+ assert(static_cast<bool>(opt) == false);
+ }
+ }
+#endif // _LIBCPP_STD_VER > 11
+}
diff --git a/test/std/experimental/optional/optional.object/optional.object.ctor/const_T.pass.cpp b/test/std/experimental/optional/optional.object/optional.object.ctor/const_T.pass.cpp
new file mode 100644
index 000000000000..071f5943b972
--- /dev/null
+++ b/test/std/experimental/optional/optional.object/optional.object.ctor/const_T.pass.cpp
@@ -0,0 +1,117 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// constexpr optional(const T& v);
+
+#include <experimental/optional>
+#include <type_traits>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+
+class X
+{
+ int i_;
+public:
+ X(int i) : i_(i) {}
+
+ friend bool operator==(const X& x, const X& y) {return x.i_ == y.i_;}
+};
+
+class Y
+{
+ int i_;
+public:
+ constexpr Y(int i) : i_(i) {}
+
+ friend constexpr bool operator==(const Y& x, const Y& y) {return x.i_ == y.i_;}
+};
+
+class Z
+{
+ int i_;
+public:
+ Z(int i) : i_(i) {}
+ Z(const Z&) {throw 6;}
+};
+
+
+#endif // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef int T;
+ constexpr T t(5);
+ constexpr optional<T> opt(t);
+ static_assert(static_cast<bool>(opt) == true, "");
+ static_assert(*opt == 5, "");
+
+ struct test_constexpr_ctor
+ : public optional<T>
+ {
+ constexpr test_constexpr_ctor(const T&) {}
+ };
+
+ }
+ {
+ typedef double T;
+ constexpr T t(3);
+ constexpr optional<T> opt(t);
+ static_assert(static_cast<bool>(opt) == true, "");
+ static_assert(*opt == 3, "");
+
+ struct test_constexpr_ctor
+ : public optional<T>
+ {
+ constexpr test_constexpr_ctor(const T&) {}
+ };
+
+ }
+ {
+ typedef X T;
+ const T t(3);
+ optional<T> opt(t);
+ assert(static_cast<bool>(opt) == true);
+ assert(*opt == 3);
+ }
+ {
+ typedef Y T;
+ constexpr T t(3);
+ constexpr optional<T> opt(t);
+ static_assert(static_cast<bool>(opt) == true, "");
+ static_assert(*opt == 3, "");
+
+ struct test_constexpr_ctor
+ : public optional<T>
+ {
+ constexpr test_constexpr_ctor(const T&) {}
+ };
+
+ }
+ {
+ typedef Z T;
+ try
+ {
+ const T t(3);
+ optional<T> opt(t);
+ assert(false);
+ }
+ catch (int i)
+ {
+ assert(i == 6);
+ }
+ }
+#endif // _LIBCPP_STD_VER > 11
+}
diff --git a/test/std/experimental/optional/optional.object/optional.object.ctor/copy.pass.cpp b/test/std/experimental/optional/optional.object/optional.object.ctor/copy.pass.cpp
new file mode 100644
index 000000000000..8726f95a00c0
--- /dev/null
+++ b/test/std/experimental/optional/optional.object/optional.object.ctor/copy.pass.cpp
@@ -0,0 +1,124 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// optional(const optional<T>& rhs);
+
+#include <experimental/optional>
+#include <type_traits>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+
+template <class T>
+void
+test(const optional<T>& rhs, bool is_going_to_throw = false)
+{
+ bool rhs_engaged = static_cast<bool>(rhs);
+ try
+ {
+ optional<T> lhs = rhs;
+ assert(is_going_to_throw == false);
+ assert(static_cast<bool>(lhs) == rhs_engaged);
+ if (rhs_engaged)
+ assert(*lhs == *rhs);
+ }
+ catch (int i)
+ {
+ assert(i == 6);
+ }
+}
+
+class X
+{
+ int i_;
+public:
+ X(int i) : i_(i) {}
+ X(const X& x) : i_(x.i_) {}
+ ~X() {i_ = 0;}
+ friend bool operator==(const X& x, const X& y) {return x.i_ == y.i_;}
+};
+
+class Y
+{
+ int i_;
+public:
+ Y(int i) : i_(i) {}
+ Y(const Y& x) : i_(x.i_) {}
+
+ friend constexpr bool operator==(const Y& x, const Y& y) {return x.i_ == y.i_;}
+};
+
+int count = 0;
+
+class Z
+{
+ int i_;
+public:
+ Z(int i) : i_(i) {}
+ Z(const Z&)
+ {
+ if (++count == 2)
+ throw 6;
+ }
+
+ friend constexpr bool operator==(const Z& x, const Z& y) {return x.i_ == y.i_;}
+};
+
+
+#endif // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef int T;
+ optional<T> rhs;
+ test(rhs);
+ }
+ {
+ typedef int T;
+ optional<T> rhs(3);
+ test(rhs);
+ }
+ {
+ typedef X T;
+ optional<T> rhs;
+ test(rhs);
+ }
+ {
+ typedef X T;
+ optional<T> rhs(X(3));
+ test(rhs);
+ }
+ {
+ typedef Y T;
+ optional<T> rhs;
+ test(rhs);
+ }
+ {
+ typedef Y T;
+ optional<T> rhs(Y(3));
+ test(rhs);
+ }
+ {
+ typedef Z T;
+ optional<T> rhs;
+ test(rhs);
+ }
+ {
+ typedef Z T;
+ optional<T> rhs(Z(3));
+ test(rhs, true);
+ }
+#endif // _LIBCPP_STD_VER > 11
+}
diff --git a/test/std/experimental/optional/optional.object/optional.object.ctor/default.pass.cpp b/test/std/experimental/optional/optional.object/optional.object.ctor/default.pass.cpp
new file mode 100644
index 000000000000..6a1763de22bd
--- /dev/null
+++ b/test/std/experimental/optional/optional.object/optional.object.ctor/default.pass.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// constexpr optional() noexcept;
+
+#include <experimental/optional>
+#include <type_traits>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+
+template <class Opt>
+void
+test_constexpr()
+{
+ static_assert(std::is_nothrow_default_constructible<Opt>::value, "");
+ constexpr Opt opt;
+ static_assert(static_cast<bool>(opt) == false, "");
+
+ struct test_constexpr_ctor
+ : public Opt
+ {
+ constexpr test_constexpr_ctor() {}
+ };
+
+}
+
+template <class Opt>
+void
+test()
+{
+ static_assert(std::is_nothrow_default_constructible<Opt>::value, "");
+ Opt opt;
+ assert(static_cast<bool>(opt) == false);
+
+ struct test_constexpr_ctor
+ : public Opt
+ {
+ constexpr test_constexpr_ctor() {}
+ };
+}
+
+struct X
+{
+ X();
+};
+
+#endif // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ test_constexpr<optional<int>>();
+ test_constexpr<optional<int*>>();
+ test<optional<X>>();
+#endif // _LIBCPP_STD_VER > 11
+}
diff --git a/test/std/experimental/optional/optional.object/optional.object.ctor/in_place_t.pass.cpp b/test/std/experimental/optional/optional.object/optional.object.ctor/in_place_t.pass.cpp
new file mode 100644
index 000000000000..412c993ffbd7
--- /dev/null
+++ b/test/std/experimental/optional/optional.object/optional.object.ctor/in_place_t.pass.cpp
@@ -0,0 +1,145 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// template <class... Args>
+// constexpr explicit optional(in_place_t, Args&&... args);
+
+#include <experimental/optional>
+#include <type_traits>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+using std::experimental::in_place_t;
+using std::experimental::in_place;
+
+class X
+{
+ int i_;
+ int j_ = 0;
+public:
+ X() : i_(0) {}
+ X(int i) : i_(i) {}
+ X(int i, int j) : i_(i), j_(j) {}
+
+ ~X() {}
+
+ friend bool operator==(const X& x, const X& y)
+ {return x.i_ == y.i_ && x.j_ == y.j_;}
+};
+
+class Y
+{
+ int i_;
+ int j_ = 0;
+public:
+ constexpr Y() : i_(0) {}
+ constexpr Y(int i) : i_(i) {}
+ constexpr Y(int i, int j) : i_(i), j_(j) {}
+
+ friend constexpr bool operator==(const Y& x, const Y& y)
+ {return x.i_ == y.i_ && x.j_ == y.j_;}
+};
+
+class Z
+{
+ int i_;
+public:
+ Z(int i) : i_(i) {throw 6;}
+};
+
+
+#endif // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ {
+ constexpr optional<int> opt(in_place, 5);
+ static_assert(static_cast<bool>(opt) == true, "");
+ static_assert(*opt == 5, "");
+
+ struct test_constexpr_ctor
+ : public optional<int>
+ {
+ constexpr test_constexpr_ctor(in_place_t, int i)
+ : optional<int>(in_place, i) {}
+ };
+
+ }
+ {
+ const optional<X> opt(in_place);
+ assert(static_cast<bool>(opt) == true);
+ assert(*opt == X());
+ }
+ {
+ const optional<X> opt(in_place, 5);
+ assert(static_cast<bool>(opt) == true);
+ assert(*opt == X(5));
+ }
+ {
+ const optional<X> opt(in_place, 5, 4);
+ assert(static_cast<bool>(opt) == true);
+ assert(*opt == X(5, 4));
+ }
+ {
+ constexpr optional<Y> opt(in_place);
+ static_assert(static_cast<bool>(opt) == true, "");
+ static_assert(*opt == Y(), "");
+
+ struct test_constexpr_ctor
+ : public optional<Y>
+ {
+ constexpr test_constexpr_ctor(in_place_t)
+ : optional<Y>(in_place) {}
+ };
+
+ }
+ {
+ constexpr optional<Y> opt(in_place, 5);
+ static_assert(static_cast<bool>(opt) == true, "");
+ static_assert(*opt == Y(5), "");
+
+ struct test_constexpr_ctor
+ : public optional<Y>
+ {
+ constexpr test_constexpr_ctor(in_place_t, int i)
+ : optional<Y>(in_place, i) {}
+ };
+
+ }
+ {
+ constexpr optional<Y> opt(in_place, 5, 4);
+ static_assert(static_cast<bool>(opt) == true, "");
+ static_assert(*opt == Y(5, 4), "");
+
+ struct test_constexpr_ctor
+ : public optional<Y>
+ {
+ constexpr test_constexpr_ctor(in_place_t, int i, int j)
+ : optional<Y>(in_place, i, j) {}
+ };
+
+ }
+ {
+ try
+ {
+ const optional<Z> opt(in_place, 1);
+ assert(false);
+ }
+ catch (int i)
+ {
+ assert(i == 6);
+ }
+ }
+#endif // _LIBCPP_STD_VER > 11
+}
diff --git a/test/std/experimental/optional/optional.object/optional.object.ctor/initializer_list.pass.cpp b/test/std/experimental/optional/optional.object/optional.object.ctor/initializer_list.pass.cpp
new file mode 100644
index 000000000000..98cb929dc51e
--- /dev/null
+++ b/test/std/experimental/optional/optional.object/optional.object.ctor/initializer_list.pass.cpp
@@ -0,0 +1,126 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// template <class U, class... Args>
+// constexpr
+// explicit optional(in_place_t, initializer_list<U> il, Args&&... args);
+
+#include <experimental/optional>
+#include <type_traits>
+#include <vector>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+using std::experimental::in_place_t;
+using std::experimental::in_place;
+
+class X
+{
+ int i_;
+ int j_ = 0;
+public:
+ X() : i_(0) {}
+ X(int i) : i_(i) {}
+ X(int i, int j) : i_(i), j_(j) {}
+
+ ~X() {}
+
+ friend bool operator==(const X& x, const X& y)
+ {return x.i_ == y.i_ && x.j_ == y.j_;}
+};
+
+class Y
+{
+ int i_;
+ int j_ = 0;
+public:
+ constexpr Y() : i_(0) {}
+ constexpr Y(int i) : i_(i) {}
+ constexpr Y(std::initializer_list<int> il) : i_(il.begin()[0]), j_(il.begin()[1]) {}
+
+ friend constexpr bool operator==(const Y& x, const Y& y)
+ {return x.i_ == y.i_ && x.j_ == y.j_;}
+};
+
+class Z
+{
+ int i_;
+ int j_ = 0;
+public:
+ constexpr Z() : i_(0) {}
+ constexpr Z(int i) : i_(i) {}
+ constexpr Z(std::initializer_list<int> il) : i_(il.begin()[0]), j_(il.begin()[1])
+ {throw 6;}
+
+ friend constexpr bool operator==(const Z& x, const Z& y)
+ {return x.i_ == y.i_ && x.j_ == y.j_;}
+};
+
+
+#endif // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ {
+ static_assert(!std::is_constructible<X, std::initializer_list<int>&>::value, "");
+ static_assert(!std::is_constructible<optional<X>, std::initializer_list<int>&>::value, "");
+ }
+ {
+ optional<std::vector<int>> opt(in_place, {3, 1});
+ assert(static_cast<bool>(opt) == true);
+ assert((*opt == std::vector<int>{3, 1}));
+ assert(opt->size() == 2);
+ }
+ {
+ optional<std::vector<int>> opt(in_place, {3, 1}, std::allocator<int>());
+ assert(static_cast<bool>(opt) == true);
+ assert((*opt == std::vector<int>{3, 1}));
+ assert(opt->size() == 2);
+ }
+ {
+ static_assert(std::is_constructible<optional<Y>, std::initializer_list<int>&>::value, "");
+ constexpr optional<Y> opt(in_place, {3, 1});
+ static_assert(static_cast<bool>(opt) == true, "");
+ static_assert(*opt == Y{3, 1}, "");
+
+ struct test_constexpr_ctor
+ : public optional<Y>
+ {
+ constexpr test_constexpr_ctor(in_place_t, std::initializer_list<int> i)
+ : optional<Y>(in_place, i) {}
+ };
+
+ }
+ {
+ static_assert(std::is_constructible<optional<Z>, std::initializer_list<int>&>::value, "");
+ try
+ {
+ optional<Z> opt(in_place, {3, 1});
+ assert(false);
+ }
+ catch (int i)
+ {
+ assert(i == 6);
+ }
+
+ struct test_constexpr_ctor
+ : public optional<Z>
+ {
+ constexpr test_constexpr_ctor(in_place_t, std::initializer_list<int> i)
+ : optional<Z>(in_place, i) {}
+ };
+
+ }
+#endif // _LIBCPP_STD_VER > 11
+}
diff --git a/test/std/experimental/optional/optional.object/optional.object.ctor/move.pass.cpp b/test/std/experimental/optional/optional.object/optional.object.ctor/move.pass.cpp
new file mode 100644
index 000000000000..b320c95c5827
--- /dev/null
+++ b/test/std/experimental/optional/optional.object/optional.object.ctor/move.pass.cpp
@@ -0,0 +1,124 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// optional(optional<T>&& rhs) noexcept(is_nothrow_move_constructible<T>::value);
+
+#include <experimental/optional>
+#include <type_traits>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+
+template <class T>
+void
+test(optional<T>& rhs, bool is_going_to_throw = false)
+{
+ static_assert(std::is_nothrow_move_constructible<optional<T>>::value ==
+ std::is_nothrow_move_constructible<T>::value, "");
+ bool rhs_engaged = static_cast<bool>(rhs);
+ try
+ {
+ optional<T> lhs = std::move(rhs);
+ assert(is_going_to_throw == false);
+ assert(static_cast<bool>(lhs) == rhs_engaged);
+ }
+ catch (int i)
+ {
+ assert(i == 6);
+ }
+}
+
+class X
+{
+ int i_;
+public:
+ X(int i) : i_(i) {}
+ X(X&& x) : i_(x.i_) {x.i_ = 0;}
+ ~X() {i_ = 0;}
+ friend bool operator==(const X& x, const X& y) {return x.i_ == y.i_;}
+};
+
+class Y
+{
+ int i_;
+public:
+ Y(int i) : i_(i) {}
+ Y(Y&& x) noexcept : i_(x.i_) {x.i_ = 0;}
+
+ friend constexpr bool operator==(const Y& x, const Y& y) {return x.i_ == y.i_;}
+};
+
+int count = 0;
+
+class Z
+{
+ int i_;
+public:
+ Z(int i) : i_(i) {}
+ Z(Z&&)
+ {
+ if (++count == 2)
+ throw 6;
+ }
+
+ friend constexpr bool operator==(const Z& x, const Z& y) {return x.i_ == y.i_;}
+};
+
+
+#endif // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef int T;
+ optional<T> rhs;
+ test(rhs);
+ }
+ {
+ typedef int T;
+ optional<T> rhs(3);
+ test(rhs);
+ }
+ {
+ typedef X T;
+ optional<T> rhs;
+ test(rhs);
+ }
+ {
+ typedef X T;
+ optional<T> rhs(X(3));
+ test(rhs);
+ }
+ {
+ typedef Y T;
+ optional<T> rhs;
+ test(rhs);
+ }
+ {
+ typedef Y T;
+ optional<T> rhs(Y(3));
+ test(rhs);
+ }
+ {
+ typedef Z T;
+ optional<T> rhs;
+ test(rhs);
+ }
+ {
+ typedef Z T;
+ optional<T> rhs(Z(3));
+ test(rhs, true);
+ }
+#endif // _LIBCPP_STD_VER > 11
+}
diff --git a/test/std/experimental/optional/optional.object/optional.object.ctor/nullopt_t.pass.cpp b/test/std/experimental/optional/optional.object/optional.object.ctor/nullopt_t.pass.cpp
new file mode 100644
index 000000000000..c307a2e1e258
--- /dev/null
+++ b/test/std/experimental/optional/optional.object/optional.object.ctor/nullopt_t.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// constexpr optional(nullopt_t) noexcept;
+
+#include <experimental/optional>
+#include <type_traits>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+using std::experimental::nullopt_t;
+using std::experimental::nullopt;
+
+template <class Opt>
+void
+test_constexpr()
+{
+ static_assert(noexcept(Opt(nullopt)), "");
+ constexpr Opt opt(nullopt);
+ static_assert(static_cast<bool>(opt) == false, "");
+
+ struct test_constexpr_ctor
+ : public Opt
+ {
+ constexpr test_constexpr_ctor() {}
+ };
+}
+
+template <class Opt>
+void
+test()
+{
+ static_assert(noexcept(Opt(nullopt)), "");
+ Opt opt(nullopt);
+ assert(static_cast<bool>(opt) == false);
+
+ struct test_constexpr_ctor
+ : public Opt
+ {
+ constexpr test_constexpr_ctor() {}
+ };
+}
+
+struct X
+{
+ X();
+};
+
+#endif // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ test_constexpr<optional<int>>();
+ test_constexpr<optional<int*>>();
+ test<optional<X>>();
+#endif // _LIBCPP_STD_VER > 11
+}
diff --git a/test/std/experimental/optional/optional.object/optional.object.ctor/rvalue_T.pass.cpp b/test/std/experimental/optional/optional.object/optional.object.ctor/rvalue_T.pass.cpp
new file mode 100644
index 000000000000..ac52a42d5953
--- /dev/null
+++ b/test/std/experimental/optional/optional.object/optional.object.ctor/rvalue_T.pass.cpp
@@ -0,0 +1,110 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// constexpr optional(T&& v);
+
+#include <experimental/optional>
+#include <type_traits>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+
+class X
+{
+ int i_;
+public:
+ X(int i) : i_(i) {}
+ X(X&& x) : i_(x.i_) {}
+
+ friend bool operator==(const X& x, const X& y) {return x.i_ == y.i_;}
+};
+
+class Y
+{
+ int i_;
+public:
+ constexpr Y(int i) : i_(i) {}
+ constexpr Y(Y&& x) : i_(x.i_) {}
+
+ friend constexpr bool operator==(const Y& x, const Y& y) {return x.i_ == y.i_;}
+};
+
+class Z
+{
+ int i_;
+public:
+ Z(int i) : i_(i) {}
+ Z(Z&&) {throw 6;}
+};
+
+#endif // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef int T;
+ constexpr optional<T> opt(T(5));
+ static_assert(static_cast<bool>(opt) == true, "");
+ static_assert(*opt == 5, "");
+
+ struct test_constexpr_ctor
+ : public optional<T>
+ {
+ constexpr test_constexpr_ctor(T&&) {}
+ };
+ }
+ {
+ typedef double T;
+ constexpr optional<T> opt(T(3));
+ static_assert(static_cast<bool>(opt) == true, "");
+ static_assert(*opt == 3, "");
+
+ struct test_constexpr_ctor
+ : public optional<T>
+ {
+ constexpr test_constexpr_ctor(T&&) {}
+ };
+ }
+ {
+ typedef X T;
+ optional<T> opt(T(3));
+ assert(static_cast<bool>(opt) == true);
+ assert(*opt == 3);
+ }
+ {
+ typedef Y T;
+ constexpr optional<T> opt(T(3));
+ static_assert(static_cast<bool>(opt) == true, "");
+ static_assert(*opt == 3, "");
+
+ struct test_constexpr_ctor
+ : public optional<T>
+ {
+ constexpr test_constexpr_ctor(T&&) {}
+ };
+ }
+ {
+ typedef Z T;
+ try
+ {
+ optional<T> opt(T(3));
+ assert(false);
+ }
+ catch (int i)
+ {
+ assert(i == 6);
+ }
+ }
+#endif // _LIBCPP_STD_VER > 11
+}
diff --git a/test/std/experimental/optional/optional.object/optional.object.dtor/dtor.pass.cpp b/test/std/experimental/optional/optional.object/optional.object.dtor/dtor.pass.cpp
new file mode 100644
index 000000000000..2697799f0e5e
--- /dev/null
+++ b/test/std/experimental/optional/optional.object/optional.object.dtor/dtor.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// ~optional();
+
+#include <experimental/optional>
+#include <type_traits>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+
+class X
+{
+public:
+ static bool dtor_called;
+ X() = default;
+ ~X() {dtor_called = true;}
+};
+
+bool X::dtor_called = false;
+
+#endif // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef int T;
+ static_assert(std::is_trivially_destructible<T>::value, "");
+ static_assert(std::is_trivially_destructible<optional<T>>::value, "");
+ }
+ {
+ typedef double T;
+ static_assert(std::is_trivially_destructible<T>::value, "");
+ static_assert(std::is_trivially_destructible<optional<T>>::value, "");
+ }
+ {
+ typedef X T;
+ static_assert(!std::is_trivially_destructible<T>::value, "");
+ static_assert(!std::is_trivially_destructible<optional<T>>::value, "");
+ {
+ X x;
+ optional<X> opt{x};
+ assert(X::dtor_called == false);
+ }
+ assert(X::dtor_called == true);
+ }
+#endif // _LIBCPP_STD_VER > 11
+}
diff --git a/test/std/experimental/optional/optional.object/optional.object.observe/bool.pass.cpp b/test/std/experimental/optional/optional.object/optional.object.observe/bool.pass.cpp
new file mode 100644
index 000000000000..a3724375cf4d
--- /dev/null
+++ b/test/std/experimental/optional/optional.object/optional.object.observe/bool.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// constexpr explicit optional<T>::operator bool() const noexcept;
+
+#include <experimental/optional>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ using std::experimental::optional;
+
+ {
+ constexpr optional<int> opt;
+ static_assert(!opt, "");
+ }
+ {
+ constexpr optional<int> opt(0);
+ static_assert(opt, "");
+ }
+#endif // _LIBCPP_STD_VER > 11
+}
diff --git a/test/std/experimental/optional/optional.object/optional.object.observe/dereference.pass.cpp b/test/std/experimental/optional/optional.object/optional.object.observe/dereference.pass.cpp
new file mode 100644
index 000000000000..98e5dac9719e
--- /dev/null
+++ b/test/std/experimental/optional/optional.object/optional.object.observe/dereference.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// T& optional<T>::operator*();
+
+#ifdef _LIBCPP_DEBUG
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <experimental/optional>
+#include <type_traits>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+
+struct X
+{
+ constexpr int test() const {return 3;}
+ int test() {return 4;}
+};
+
+#endif // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ {
+ optional<X> opt(X{});
+ assert((*opt).test() == 4);
+ }
+#ifdef _LIBCPP_DEBUG
+ {
+ optional<X> opt;
+ assert((*opt).test() == 3);
+ assert(false);
+ }
+#endif // _LIBCPP_DEBUG
+#endif // _LIBCPP_STD_VER > 11
+}
diff --git a/test/std/experimental/optional/optional.object/optional.object.observe/dereference_const.pass.cpp b/test/std/experimental/optional/optional.object/optional.object.observe/dereference_const.pass.cpp
new file mode 100644
index 000000000000..c72a57852a32
--- /dev/null
+++ b/test/std/experimental/optional/optional.object/optional.object.observe/dereference_const.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// constexpr const T& optional<T>::operator*() const;
+
+#ifdef _LIBCPP_DEBUG
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <experimental/optional>
+#include <type_traits>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+
+struct X
+{
+ constexpr int test() const {return 3;}
+};
+
+struct Y
+{
+ int test() const {return 2;}
+};
+
+#endif // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ {
+ constexpr optional<X> opt(X{});
+ static_assert((*opt).test() == 3, "");
+ }
+ {
+ constexpr optional<Y> opt(Y{});
+ assert((*opt).test() == 2);
+ }
+#ifdef _LIBCPP_DEBUG
+ {
+ const optional<X> opt;
+ assert((*opt).test() == 3);
+ assert(false);
+ }
+#endif // _LIBCPP_DEBUG
+#endif // _LIBCPP_STD_VER > 11
+}
diff --git a/test/std/experimental/optional/optional.object/optional.object.observe/op_arrow.pass.cpp b/test/std/experimental/optional/optional.object/optional.object.observe/op_arrow.pass.cpp
new file mode 100644
index 000000000000..b17fcf8d3050
--- /dev/null
+++ b/test/std/experimental/optional/optional.object/optional.object.observe/op_arrow.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// constexpr T* optional<T>::operator->();
+
+#ifdef _LIBCPP_DEBUG
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <experimental/optional>
+#include <type_traits>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+
+struct X
+{
+ constexpr int test() const {return 3;}
+};
+
+#endif // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ {
+ constexpr optional<X> opt(X{});
+ static_assert(opt->test() == 3, "");
+ }
+#ifdef _LIBCPP_DEBUG
+ {
+ optional<X> opt;
+ assert(opt->test() == 3);
+ assert(false);
+ }
+#endif // _LIBCPP_DEBUG
+#endif // _LIBCPP_STD_VER > 11
+}
diff --git a/test/std/experimental/optional/optional.object/optional.object.observe/op_arrow_const.pass.cpp b/test/std/experimental/optional/optional.object/optional.object.observe/op_arrow_const.pass.cpp
new file mode 100644
index 000000000000..e813dd992a5b
--- /dev/null
+++ b/test/std/experimental/optional/optional.object/optional.object.observe/op_arrow_const.pass.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// constexpr const T* optional<T>::operator->() const;
+
+#ifdef _LIBCPP_DEBUG
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <experimental/optional>
+#include <type_traits>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+
+struct X
+{
+ constexpr int test() const {return 3;}
+};
+
+struct Y
+{
+ int test() const {return 2;}
+};
+
+struct Z
+{
+ const Z* operator&() const {return this;}
+ constexpr int test() const {return 1;}
+};
+
+#endif // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ {
+ constexpr optional<X> opt(X{});
+ static_assert(opt->test() == 3, "");
+ }
+ {
+ constexpr optional<Y> opt(Y{});
+ assert(opt->test() == 2);
+ }
+ {
+ constexpr optional<Z> opt(Z{});
+ assert(opt->test() == 1);
+ }
+#ifdef _LIBCPP_DEBUG
+ {
+ const optional<X> opt;
+ assert(opt->test() == 3);
+ assert(false);
+ }
+#endif // _LIBCPP_DEBUG
+#endif // _LIBCPP_STD_VER > 11
+}
diff --git a/test/std/experimental/optional/optional.object/optional.object.observe/value.pass.cpp b/test/std/experimental/optional/optional.object/optional.object.observe/value.pass.cpp
new file mode 100644
index 000000000000..e91805e9c8e5
--- /dev/null
+++ b/test/std/experimental/optional/optional.object/optional.object.observe/value.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// T& optional<T>::value();
+
+#include <experimental/optional>
+#include <type_traits>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+using std::experimental::bad_optional_access;
+
+struct X
+{
+ X() = default;
+ X(const X&) = delete;
+ constexpr int test() const {return 3;}
+ int test() {return 4;}
+};
+
+#endif // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ {
+ optional<X> opt;
+ opt.emplace();
+ assert(opt.value().test() == 4);
+ }
+ {
+ optional<X> opt;
+ try
+ {
+ opt.value();
+ assert(false);
+ }
+ catch (const bad_optional_access&)
+ {
+ }
+ }
+#endif // _LIBCPP_STD_VER > 11
+}
diff --git a/test/std/experimental/optional/optional.object/optional.object.observe/value_const.fail.cpp b/test/std/experimental/optional/optional.object/optional.object.observe/value_const.fail.cpp
new file mode 100644
index 000000000000..f0f8af6da45d
--- /dev/null
+++ b/test/std/experimental/optional/optional.object/optional.object.observe/value_const.fail.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// constexpr const T& optional<T>::value() const;
+
+#include <experimental/optional>
+#include <type_traits>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+
+struct X
+{
+ constexpr int test() const {return 3;}
+ int test() {return 4;}
+};
+
+#endif // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ {
+ constexpr optional<X> opt;
+ static_assert(opt.value().test() == 3, "");
+ }
+#else
+#error
+#endif // _LIBCPP_STD_VER > 11
+}
diff --git a/test/std/experimental/optional/optional.object/optional.object.observe/value_const.pass.cpp b/test/std/experimental/optional/optional.object/optional.object.observe/value_const.pass.cpp
new file mode 100644
index 000000000000..39bf687ff3c5
--- /dev/null
+++ b/test/std/experimental/optional/optional.object/optional.object.observe/value_const.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// constexpr const T& optional<T>::value() const;
+
+#include <experimental/optional>
+#include <type_traits>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+using std::experimental::in_place_t;
+using std::experimental::in_place;
+using std::experimental::bad_optional_access;
+
+struct X
+{
+ X() = default;
+ X(const X&) = delete;
+ constexpr int test() const {return 3;}
+ int test() {return 4;}
+};
+
+#endif // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ {
+ constexpr optional<X> opt(in_place);
+ static_assert(opt.value().test() == 3, "");
+ }
+ {
+ const optional<X> opt(in_place);
+ assert(opt.value().test() == 3);
+ }
+ {
+ const optional<X> opt;
+ try
+ {
+ opt.value();
+ assert(false);
+ }
+ catch (const bad_optional_access&)
+ {
+ }
+ }
+#endif // _LIBCPP_STD_VER > 11
+}
diff --git a/test/std/experimental/optional/optional.object/optional.object.observe/value_or.pass.cpp b/test/std/experimental/optional/optional.object/optional.object.observe/value_or.pass.cpp
new file mode 100644
index 000000000000..6118c44bb5ba
--- /dev/null
+++ b/test/std/experimental/optional/optional.object/optional.object.observe/value_or.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// template <class U> T optional<T>::value_or(U&& v) &&;
+
+#include <experimental/optional>
+#include <type_traits>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+using std::experimental::in_place_t;
+using std::experimental::in_place;
+
+struct Y
+{
+ int i_;
+
+ Y(int i) : i_(i) {}
+};
+
+struct X
+{
+ int i_;
+
+ X(int i) : i_(i) {}
+ X(X&& x) : i_(x.i_) {x.i_ = 0;}
+ X(const Y& y) : i_(y.i_) {}
+ X(Y&& y) : i_(y.i_+1) {}
+ friend constexpr bool operator==(const X& x, const X& y)
+ {return x.i_ == y.i_;}
+};
+
+#endif // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ {
+ optional<X> opt(in_place, 2);
+ Y y(3);
+ assert(std::move(opt).value_or(y) == 2);
+ assert(*opt == 0);
+ }
+ {
+ optional<X> opt(in_place, 2);
+ assert(std::move(opt).value_or(Y(3)) == 2);
+ assert(*opt == 0);
+ }
+ {
+ optional<X> opt;
+ Y y(3);
+ assert(std::move(opt).value_or(y) == 3);
+ assert(!opt);
+ }
+ {
+ optional<X> opt;
+ assert(std::move(opt).value_or(Y(3)) == 4);
+ assert(!opt);
+ }
+#endif // _LIBCPP_STD_VER > 11
+}
diff --git a/test/std/experimental/optional/optional.object/optional.object.observe/value_or_const.pass.cpp b/test/std/experimental/optional/optional.object/optional.object.observe/value_or_const.pass.cpp
new file mode 100644
index 000000000000..d51f18abbd28
--- /dev/null
+++ b/test/std/experimental/optional/optional.object/optional.object.observe/value_or_const.pass.cpp
@@ -0,0 +1,82 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// template <class U> constexpr T optional<T>::value_or(U&& v) const&;
+
+#include <experimental/optional>
+#include <type_traits>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+
+struct Y
+{
+ int i_;
+
+ constexpr Y(int i) : i_(i) {}
+};
+
+struct X
+{
+ int i_;
+
+ constexpr X(int i) : i_(i) {}
+ constexpr X(const Y& y) : i_(y.i_) {}
+ constexpr X(Y&& y) : i_(y.i_+1) {}
+ friend constexpr bool operator==(const X& x, const X& y)
+ {return x.i_ == y.i_;}
+};
+
+#endif // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ {
+ constexpr optional<X> opt(2);
+ constexpr Y y(3);
+ static_assert(opt.value_or(y) == 2, "");
+ }
+ {
+ constexpr optional<X> opt(2);
+ static_assert(opt.value_or(Y(3)) == 2, "");
+ }
+ {
+ constexpr optional<X> opt;
+ constexpr Y y(3);
+ static_assert(opt.value_or(y) == 3, "");
+ }
+ {
+ constexpr optional<X> opt;
+ static_assert(opt.value_or(Y(3)) == 4, "");
+ }
+ {
+ const optional<X> opt(2);
+ const Y y(3);
+ assert(opt.value_or(y) == 2);
+ }
+ {
+ const optional<X> opt(2);
+ assert(opt.value_or(Y(3)) == 2);
+ }
+ {
+ const optional<X> opt;
+ const Y y(3);
+ assert(opt.value_or(y) == 3);
+ }
+ {
+ const optional<X> opt;
+ assert(opt.value_or(Y(3)) == 4);
+ }
+#endif // _LIBCPP_STD_VER > 11
+}
diff --git a/test/std/experimental/optional/optional.object/optional.object.swap/swap.pass.cpp b/test/std/experimental/optional/optional.object/optional.object.swap/swap.pass.cpp
new file mode 100644
index 000000000000..e0ecfdebb8cf
--- /dev/null
+++ b/test/std/experimental/optional/optional.object/optional.object.swap/swap.pass.cpp
@@ -0,0 +1,306 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// void swap(optional&)
+// noexcept(is_nothrow_move_constructible<T>::value &&
+// noexcept(swap(declval<T&>(), declval<T&>())));
+
+#include <experimental/optional>
+#include <type_traits>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+
+class X
+{
+ int i_;
+public:
+ static unsigned dtor_called;
+ X(int i) : i_(i) {}
+ X(X&& x) = default;
+ X& operator=(X&&) = default;
+ ~X() {++dtor_called;}
+
+ friend bool operator==(const X& x, const X& y) {return x.i_ == y.i_;}
+};
+
+unsigned X::dtor_called = 0;
+
+class Y
+{
+ int i_;
+public:
+ static unsigned dtor_called;
+ Y(int i) : i_(i) {}
+ Y(Y&&) = default;
+ ~Y() {++dtor_called;}
+
+ friend constexpr bool operator==(const Y& x, const Y& y) {return x.i_ == y.i_;}
+ friend void swap(Y& x, Y& y) {std::swap(x.i_, y.i_);}
+};
+
+unsigned Y::dtor_called = 0;
+
+class Z
+{
+ int i_;
+public:
+ Z(int i) : i_(i) {}
+ Z(Z&&) {throw 7;}
+
+ friend constexpr bool operator==(const Z& x, const Z& y) {return x.i_ == y.i_;}
+ friend void swap(Z& x, Z& y) {throw 6;}
+};
+
+
+#endif // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ {
+ optional<int> opt1;
+ optional<int> opt2;
+ static_assert(noexcept(opt1.swap(opt2)) == true, "");
+ assert(static_cast<bool>(opt1) == false);
+ assert(static_cast<bool>(opt2) == false);
+ opt1.swap(opt2);
+ assert(static_cast<bool>(opt1) == false);
+ assert(static_cast<bool>(opt2) == false);
+ }
+ {
+ optional<int> opt1(1);
+ optional<int> opt2;
+ static_assert(noexcept(opt1.swap(opt2)) == true, "");
+ assert(static_cast<bool>(opt1) == true);
+ assert(*opt1 == 1);
+ assert(static_cast<bool>(opt2) == false);
+ opt1.swap(opt2);
+ assert(static_cast<bool>(opt1) == false);
+ assert(static_cast<bool>(opt2) == true);
+ assert(*opt2 == 1);
+ }
+ {
+ optional<int> opt1;
+ optional<int> opt2(2);
+ static_assert(noexcept(opt1.swap(opt2)) == true, "");
+ assert(static_cast<bool>(opt1) == false);
+ assert(static_cast<bool>(opt2) == true);
+ assert(*opt2 == 2);
+ opt1.swap(opt2);
+ assert(static_cast<bool>(opt1) == true);
+ assert(*opt1 == 2);
+ assert(static_cast<bool>(opt2) == false);
+ }
+ {
+ optional<int> opt1(1);
+ optional<int> opt2(2);
+ static_assert(noexcept(opt1.swap(opt2)) == true, "");
+ assert(static_cast<bool>(opt1) == true);
+ assert(*opt1 == 1);
+ assert(static_cast<bool>(opt2) == true);
+ assert(*opt2 == 2);
+ opt1.swap(opt2);
+ assert(static_cast<bool>(opt1) == true);
+ assert(*opt1 == 2);
+ assert(static_cast<bool>(opt2) == true);
+ assert(*opt2 == 1);
+ }
+ {
+ optional<X> opt1;
+ optional<X> opt2;
+ static_assert(noexcept(opt1.swap(opt2)) == true, "");
+ assert(static_cast<bool>(opt1) == false);
+ assert(static_cast<bool>(opt2) == false);
+ opt1.swap(opt2);
+ assert(static_cast<bool>(opt1) == false);
+ assert(static_cast<bool>(opt2) == false);
+ assert(X::dtor_called == 0);
+ }
+ {
+ optional<X> opt1(1);
+ optional<X> opt2;
+ static_assert(noexcept(opt1.swap(opt2)) == true, "");
+ assert(static_cast<bool>(opt1) == true);
+ assert(*opt1 == 1);
+ assert(static_cast<bool>(opt2) == false);
+ X::dtor_called = 0;
+ opt1.swap(opt2);
+ assert(X::dtor_called == 1);
+ assert(static_cast<bool>(opt1) == false);
+ assert(static_cast<bool>(opt2) == true);
+ assert(*opt2 == 1);
+ }
+ {
+ optional<X> opt1;
+ optional<X> opt2(2);
+ static_assert(noexcept(opt1.swap(opt2)) == true, "");
+ assert(static_cast<bool>(opt1) == false);
+ assert(static_cast<bool>(opt2) == true);
+ assert(*opt2 == 2);
+ X::dtor_called = 0;
+ opt1.swap(opt2);
+ assert(X::dtor_called == 1);
+ assert(static_cast<bool>(opt1) == true);
+ assert(*opt1 == 2);
+ assert(static_cast<bool>(opt2) == false);
+ }
+ {
+ optional<X> opt1(1);
+ optional<X> opt2(2);
+ static_assert(noexcept(opt1.swap(opt2)) == true, "");
+ assert(static_cast<bool>(opt1) == true);
+ assert(*opt1 == 1);
+ assert(static_cast<bool>(opt2) == true);
+ assert(*opt2 == 2);
+ X::dtor_called = 0;
+ opt1.swap(opt2);
+ assert(X::dtor_called == 1); // from inside std::swap
+ assert(static_cast<bool>(opt1) == true);
+ assert(*opt1 == 2);
+ assert(static_cast<bool>(opt2) == true);
+ assert(*opt2 == 1);
+ }
+ {
+ optional<Y> opt1;
+ optional<Y> opt2;
+ static_assert(noexcept(opt1.swap(opt2)) == false, "");
+ assert(static_cast<bool>(opt1) == false);
+ assert(static_cast<bool>(opt2) == false);
+ opt1.swap(opt2);
+ assert(static_cast<bool>(opt1) == false);
+ assert(static_cast<bool>(opt2) == false);
+ assert(Y::dtor_called == 0);
+ }
+ {
+ optional<Y> opt1(1);
+ optional<Y> opt2;
+ static_assert(noexcept(opt1.swap(opt2)) == false, "");
+ assert(static_cast<bool>(opt1) == true);
+ assert(*opt1 == 1);
+ assert(static_cast<bool>(opt2) == false);
+ Y::dtor_called = 0;
+ opt1.swap(opt2);
+ assert(Y::dtor_called == 1);
+ assert(static_cast<bool>(opt1) == false);
+ assert(static_cast<bool>(opt2) == true);
+ assert(*opt2 == 1);
+ }
+ {
+ optional<Y> opt1;
+ optional<Y> opt2(2);
+ static_assert(noexcept(opt1.swap(opt2)) == false, "");
+ assert(static_cast<bool>(opt1) == false);
+ assert(static_cast<bool>(opt2) == true);
+ assert(*opt2 == 2);
+ Y::dtor_called = 0;
+ opt1.swap(opt2);
+ assert(Y::dtor_called == 1);
+ assert(static_cast<bool>(opt1) == true);
+ assert(*opt1 == 2);
+ assert(static_cast<bool>(opt2) == false);
+ }
+ {
+ optional<Y> opt1(1);
+ optional<Y> opt2(2);
+ static_assert(noexcept(opt1.swap(opt2)) == false, "");
+ assert(static_cast<bool>(opt1) == true);
+ assert(*opt1 == 1);
+ assert(static_cast<bool>(opt2) == true);
+ assert(*opt2 == 2);
+ Y::dtor_called = 0;
+ opt1.swap(opt2);
+ assert(Y::dtor_called == 0);
+ assert(static_cast<bool>(opt1) == true);
+ assert(*opt1 == 2);
+ assert(static_cast<bool>(opt2) == true);
+ assert(*opt2 == 1);
+ }
+ {
+ optional<Z> opt1;
+ optional<Z> opt2;
+ static_assert(noexcept(opt1.swap(opt2)) == false, "");
+ assert(static_cast<bool>(opt1) == false);
+ assert(static_cast<bool>(opt2) == false);
+ opt1.swap(opt2);
+ assert(static_cast<bool>(opt1) == false);
+ assert(static_cast<bool>(opt2) == false);
+ }
+ {
+ optional<Z> opt1;
+ opt1.emplace(1);
+ optional<Z> opt2;
+ static_assert(noexcept(opt1.swap(opt2)) == false, "");
+ assert(static_cast<bool>(opt1) == true);
+ assert(*opt1 == 1);
+ assert(static_cast<bool>(opt2) == false);
+ try
+ {
+ opt1.swap(opt2);
+ assert(false);
+ }
+ catch (int i)
+ {
+ assert(i == 7);
+ }
+ assert(static_cast<bool>(opt1) == true);
+ assert(*opt1 == 1);
+ assert(static_cast<bool>(opt2) == false);
+ }
+ {
+ optional<Z> opt1;
+ optional<Z> opt2;
+ opt2.emplace(2);
+ static_assert(noexcept(opt1.swap(opt2)) == false, "");
+ assert(static_cast<bool>(opt1) == false);
+ assert(static_cast<bool>(opt2) == true);
+ assert(*opt2 == 2);
+ try
+ {
+ opt1.swap(opt2);
+ assert(false);
+ }
+ catch (int i)
+ {
+ assert(i == 7);
+ }
+ assert(static_cast<bool>(opt1) == false);
+ assert(static_cast<bool>(opt2) == true);
+ assert(*opt2 == 2);
+ }
+ {
+ optional<Z> opt1;
+ opt1.emplace(1);
+ optional<Z> opt2;
+ opt2.emplace(2);
+ static_assert(noexcept(opt1.swap(opt2)) == false, "");
+ assert(static_cast<bool>(opt1) == true);
+ assert(*opt1 == 1);
+ assert(static_cast<bool>(opt2) == true);
+ assert(*opt2 == 2);
+ try
+ {
+ opt1.swap(opt2);
+ assert(false);
+ }
+ catch (int i)
+ {
+ assert(i == 6);
+ }
+ assert(static_cast<bool>(opt1) == true);
+ assert(*opt1 == 1);
+ assert(static_cast<bool>(opt2) == true);
+ assert(*opt2 == 2);
+ }
+#endif // _LIBCPP_STD_VER > 11
+}
diff --git a/test/std/experimental/optional/optional.object/optional_const_void.fail.cpp b/test/std/experimental/optional/optional.object/optional_const_void.fail.cpp
new file mode 100644
index 000000000000..6999cf2451f1
--- /dev/null
+++ b/test/std/experimental/optional/optional.object/optional_const_void.fail.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// T shall be an object type and shall satisfy the requirements of Destructible
+
+#include <experimental/optional>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ using std::experimental::optional;
+
+ optional<const void> opt;
+#else
+#error
+#endif // _LIBCPP_STD_VER > 11
+}
diff --git a/test/std/experimental/optional/optional.object/optional_not_destructible.fail.cpp b/test/std/experimental/optional/optional.object/optional_not_destructible.fail.cpp
new file mode 100644
index 000000000000..61470af01195
--- /dev/null
+++ b/test/std/experimental/optional/optional.object/optional_not_destructible.fail.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// T shall be an object type and shall satisfy the requirements of Destructible
+
+#include <experimental/optional>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+
+struct X
+{
+private:
+ ~X() {}
+};
+
+#endif // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ optional<X> opt;
+#else
+#error
+#endif // _LIBCPP_STD_VER > 11
+}
diff --git a/test/std/experimental/optional/optional.object/optional_not_noexcept_destructible.fail.cpp b/test/std/experimental/optional/optional.object/optional_not_noexcept_destructible.fail.cpp
new file mode 100644
index 000000000000..eaee02014c2f
--- /dev/null
+++ b/test/std/experimental/optional/optional.object/optional_not_noexcept_destructible.fail.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// T shall be an object type and shall satisfy the requirements of Destructible
+
+#include <experimental/optional>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+
+struct X
+{
+ ~X() noexcept(false) {}
+};
+
+#endif // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ optional<X> opt;
+#else
+#error
+#endif // _LIBCPP_STD_VER > 11
+}
diff --git a/test/std/experimental/optional/optional.object/optional_void.fail.cpp b/test/std/experimental/optional/optional.object/optional_void.fail.cpp
new file mode 100644
index 000000000000..f911e9a2d6d4
--- /dev/null
+++ b/test/std/experimental/optional/optional.object/optional_void.fail.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// T shall be an object type and shall satisfy the requirements of Destructible
+
+#include <experimental/optional>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ using std::experimental::optional;
+
+ optional<void> opt;
+#else
+#error
+#endif // _LIBCPP_STD_VER > 11
+}
diff --git a/test/std/experimental/optional/optional.object/types.pass.cpp b/test/std/experimental/optional/optional.object/types.pass.cpp
new file mode 100644
index 000000000000..8b9ad2e19570
--- /dev/null
+++ b/test/std/experimental/optional/optional.object/types.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// template <class T>
+// class optional
+// {
+// public:
+// typedef T value_type;
+// ...
+
+#include <experimental/optional>
+#include <type_traits>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+
+template <class Opt, class T>
+void
+test()
+{
+ static_assert(std::is_same<typename Opt::value_type, T>::value, "");
+}
+
+#endif // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ test<optional<int>, int>();
+ test<optional<const int>, const int>();
+ test<optional<double>, double>();
+ test<optional<const double>, const double>();
+#endif // _LIBCPP_STD_VER > 11
+}
diff --git a/test/std/experimental/optional/optional.relops/equal.pass.cpp b/test/std/experimental/optional/optional.relops/equal.pass.cpp
new file mode 100644
index 000000000000..03b9d3fda5cf
--- /dev/null
+++ b/test/std/experimental/optional/optional.relops/equal.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// template <class T> constexpr bool operator==(const optional<T>& x, const optional<T>& y);
+
+#include <experimental/optional>
+#include <type_traits>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+
+struct X
+{
+ int i_;
+
+ constexpr X(int i) : i_(i) {}
+};
+
+constexpr bool operator == ( const X &lhs, const X &rhs )
+ { return lhs.i_ == rhs.i_ ; }
+
+#endif
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef X T;
+ typedef optional<T> O;
+
+ constexpr O o1; // disengaged
+ constexpr O o2; // disengaged
+ constexpr O o3{1}; // engaged
+ constexpr O o4{2}; // engaged
+ constexpr O o5{1}; // engaged
+
+ static_assert ( o1 == o1 , "" );
+ static_assert ( o1 == o2 , "" );
+ static_assert ( !(o1 == o3), "" );
+ static_assert ( !(o1 == o4), "" );
+ static_assert ( !(o1 == o5), "" );
+
+ static_assert ( o2 == o1 , "" );
+ static_assert ( o2 == o2 , "" );
+ static_assert ( !(o2 == o3), "" );
+ static_assert ( !(o2 == o4), "" );
+ static_assert ( !(o2 == o5), "" );
+
+ static_assert ( !(o3 == o1), "" );
+ static_assert ( !(o3 == o2), "" );
+ static_assert ( o3 == o3 , "" );
+ static_assert ( !(o3 == o4), "" );
+ static_assert ( o3 == o5 , "" );
+
+ static_assert ( !(o4 == o1), "" );
+ static_assert ( !(o4 == o2), "" );
+ static_assert ( !(o4 == o3), "" );
+ static_assert ( o4 == o4 , "" );
+ static_assert ( !(o4 == o5), "" );
+
+ static_assert ( !(o5 == o1), "" );
+ static_assert ( !(o5 == o2), "" );
+ static_assert ( o5 == o3 , "" );
+ static_assert ( !(o5 == o4), "" );
+ static_assert ( o5 == o5 , "" );
+
+ }
+#endif
+}
diff --git a/test/std/experimental/optional/optional.relops/greater_equal.pass.cpp b/test/std/experimental/optional/optional.relops/greater_equal.pass.cpp
new file mode 100644
index 000000000000..98d6855f9313
--- /dev/null
+++ b/test/std/experimental/optional/optional.relops/greater_equal.pass.cpp
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// template <class T> constexpr bool operator>= (const optional<T>& x, const optional<T>& y);
+
+#include <experimental/optional>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+
+struct X
+{
+ int i_;
+
+ constexpr X(int i) : i_(i) {}
+};
+
+constexpr bool operator < ( const X &lhs, const X &rhs )
+ { return lhs.i_ < rhs.i_ ; }
+
+#endif
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef optional<X> O;
+
+ constexpr O o1; // disengaged
+ constexpr O o2; // disengaged
+ constexpr O o3{1}; // engaged
+ constexpr O o4{2}; // engaged
+ constexpr O o5{1}; // engaged
+
+ static_assert ( (o1 >= o1), "" );
+ static_assert ( (o1 >= o2), "" );
+ static_assert ( !(o1 >= o3), "" );
+ static_assert ( !(o1 >= o4), "" );
+ static_assert ( !(o1 >= o5), "" );
+
+ static_assert ( (o2 >= o1), "" );
+ static_assert ( (o2 >= o2), "" );
+ static_assert ( !(o2 >= o3), "" );
+ static_assert ( !(o2 >= o4), "" );
+ static_assert ( !(o2 >= o5), "" );
+
+ static_assert ( (o3 >= o1), "" );
+ static_assert ( (o3 >= o2), "" );
+ static_assert ( (o3 >= o3), "" );
+ static_assert ( !(o3 >= o4), "" );
+ static_assert ( (o3 >= o5), "" );
+
+ static_assert ( (o4 >= o1), "" );
+ static_assert ( (o4 >= o2), "" );
+ static_assert ( (o4 >= o3), "" );
+ static_assert ( (o4 >= o4), "" );
+ static_assert ( (o4 >= o5), "" );
+
+ static_assert ( (o5 >= o1), "" );
+ static_assert ( (o5 >= o2), "" );
+ static_assert ( (o5 >= o3), "" );
+ static_assert ( !(o5 >= o4), "" );
+ static_assert ( (o5 >= o5), "" );
+ }
+#endif
+}
diff --git a/test/std/experimental/optional/optional.relops/greater_than.pass.cpp b/test/std/experimental/optional/optional.relops/greater_than.pass.cpp
new file mode 100644
index 000000000000..d51bd4f2ac46
--- /dev/null
+++ b/test/std/experimental/optional/optional.relops/greater_than.pass.cpp
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// template <class T> constexpr bool operator> (const optional<T>& x, const optional<T>& y);
+
+#include <experimental/optional>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+
+struct X
+{
+ int i_;
+
+ constexpr X(int i) : i_(i) {}
+};
+
+constexpr bool operator < ( const X &lhs, const X &rhs )
+ { return lhs.i_ < rhs.i_ ; }
+
+#endif
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef optional<X> O;
+
+ constexpr O o1; // disengaged
+ constexpr O o2; // disengaged
+ constexpr O o3{1}; // engaged
+ constexpr O o4{2}; // engaged
+ constexpr O o5{1}; // engaged
+
+ static_assert ( !(o1 > o1), "" );
+ static_assert ( !(o1 > o2), "" );
+ static_assert ( !(o1 > o3), "" );
+ static_assert ( !(o1 > o4), "" );
+ static_assert ( !(o1 > o5), "" );
+
+ static_assert ( !(o2 > o1), "" );
+ static_assert ( !(o2 > o2), "" );
+ static_assert ( !(o2 > o3), "" );
+ static_assert ( !(o2 > o4), "" );
+ static_assert ( !(o2 > o5), "" );
+
+ static_assert ( (o3 > o1), "" );
+ static_assert ( (o3 > o2), "" );
+ static_assert ( !(o3 > o3), "" );
+ static_assert ( !(o3 > o4), "" );
+ static_assert ( !(o3 > o5), "" );
+
+ static_assert ( (o4 > o1), "" );
+ static_assert ( (o4 > o2), "" );
+ static_assert ( (o4 > o3), "" );
+ static_assert ( !(o4 > o4), "" );
+ static_assert ( (o4 > o5), "" );
+
+ static_assert ( (o5 > o1), "" );
+ static_assert ( (o5 > o2), "" );
+ static_assert ( !(o5 > o3), "" );
+ static_assert ( !(o5 > o4), "" );
+ static_assert ( !(o5 > o5), "" );
+ }
+#endif
+}
diff --git a/test/std/experimental/optional/optional.relops/less_equal.pass.cpp b/test/std/experimental/optional/optional.relops/less_equal.pass.cpp
new file mode 100644
index 000000000000..326f3a896493
--- /dev/null
+++ b/test/std/experimental/optional/optional.relops/less_equal.pass.cpp
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// template <class T> constexpr bool operator<= (const optional<T>& x, const optional<T>& y);
+
+#include <experimental/optional>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+
+struct X
+{
+ int i_;
+
+ constexpr X(int i) : i_(i) {}
+};
+
+constexpr bool operator < ( const X &lhs, const X &rhs )
+ { return lhs.i_ < rhs.i_ ; }
+
+#endif
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef optional<X> O;
+
+ constexpr O o1; // disengaged
+ constexpr O o2; // disengaged
+ constexpr O o3{1}; // engaged
+ constexpr O o4{2}; // engaged
+ constexpr O o5{1}; // engaged
+
+ static_assert ( (o1 <= o1), "" );
+ static_assert ( (o1 <= o2), "" );
+ static_assert ( (o1 <= o3), "" );
+ static_assert ( (o1 <= o4), "" );
+ static_assert ( (o1 <= o5), "" );
+
+ static_assert ( (o2 <= o1), "" );
+ static_assert ( (o2 <= o2), "" );
+ static_assert ( (o2 <= o3), "" );
+ static_assert ( (o2 <= o4), "" );
+ static_assert ( (o2 <= o5), "" );
+
+ static_assert ( !(o3 <= o1), "" );
+ static_assert ( !(o3 <= o2), "" );
+ static_assert ( (o3 <= o3), "" );
+ static_assert ( (o3 <= o4), "" );
+ static_assert ( (o3 <= o5), "" );
+
+ static_assert ( !(o4 <= o1), "" );
+ static_assert ( !(o4 <= o2), "" );
+ static_assert ( !(o4 <= o3), "" );
+ static_assert ( (o4 <= o4), "" );
+ static_assert ( !(o4 <= o5), "" );
+
+ static_assert ( !(o5 <= o1), "" );
+ static_assert ( !(o5 <= o2), "" );
+ static_assert ( (o5 <= o3), "" );
+ static_assert ( (o5 <= o4), "" );
+ static_assert ( (o5 <= o5), "" );
+ }
+#endif
+}
diff --git a/test/std/experimental/optional/optional.relops/less_than.pass.cpp b/test/std/experimental/optional/optional.relops/less_than.pass.cpp
new file mode 100644
index 000000000000..37f7e1942982
--- /dev/null
+++ b/test/std/experimental/optional/optional.relops/less_than.pass.cpp
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// template <class T> constexpr bool operator< (const optional<T>& x, const optional<T>& y);
+
+#include <experimental/optional>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+
+struct X
+{
+ int i_;
+
+ constexpr X(int i) : i_(i) {}
+};
+
+constexpr bool operator < ( const X &lhs, const X &rhs )
+ { return lhs.i_ < rhs.i_ ; }
+
+#endif
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef optional<X> O;
+
+ constexpr O o1; // disengaged
+ constexpr O o2; // disengaged
+ constexpr O o3{1}; // engaged
+ constexpr O o4{2}; // engaged
+ constexpr O o5{1}; // engaged
+
+ static_assert ( !(o1 < o1), "" );
+ static_assert ( !(o1 < o2), "" );
+ static_assert ( (o1 < o3), "" );
+ static_assert ( (o1 < o4), "" );
+ static_assert ( (o1 < o5), "" );
+
+ static_assert ( !(o2 < o1), "" );
+ static_assert ( !(o2 < o2), "" );
+ static_assert ( (o2 < o3), "" );
+ static_assert ( (o2 < o4), "" );
+ static_assert ( (o2 < o5), "" );
+
+ static_assert ( !(o3 < o1), "" );
+ static_assert ( !(o3 < o2), "" );
+ static_assert ( !(o3 < o3), "" );
+ static_assert ( (o3 < o4), "" );
+ static_assert ( !(o3 < o5), "" );
+
+ static_assert ( !(o4 < o1), "" );
+ static_assert ( !(o4 < o2), "" );
+ static_assert ( !(o4 < o3), "" );
+ static_assert ( !(o4 < o4), "" );
+ static_assert ( !(o4 < o5), "" );
+
+ static_assert ( !(o5 < o1), "" );
+ static_assert ( !(o5 < o2), "" );
+ static_assert ( !(o5 < o3), "" );
+ static_assert ( (o5 < o4), "" );
+ static_assert ( !(o5 < o5), "" );
+ }
+#endif
+}
diff --git a/test/std/experimental/optional/optional.relops/not_equal.pass.cpp b/test/std/experimental/optional/optional.relops/not_equal.pass.cpp
new file mode 100644
index 000000000000..f386c7e361ec
--- /dev/null
+++ b/test/std/experimental/optional/optional.relops/not_equal.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// template <class T> constexpr bool operator!=(const optional<T>& x, const optional<T>& y);
+
+#include <experimental/optional>
+#include <type_traits>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+
+struct X
+{
+ int i_;
+
+ constexpr X(int i) : i_(i) {}
+};
+
+constexpr bool operator == ( const X &lhs, const X &rhs )
+ { return lhs.i_ == rhs.i_ ; }
+
+#endif
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef X T;
+ typedef optional<T> O;
+
+ constexpr O o1; // disengaged
+ constexpr O o2; // disengaged
+ constexpr O o3{1}; // engaged
+ constexpr O o4{2}; // engaged
+ constexpr O o5{1}; // engaged
+
+ static_assert ( !(o1 != o1), "" );
+ static_assert ( !(o1 != o2), "" );
+ static_assert ( (o1 != o3), "" );
+ static_assert ( (o1 != o4), "" );
+ static_assert ( (o1 != o5), "" );
+
+ static_assert ( !(o2 != o1), "" );
+ static_assert ( !(o2 != o2), "" );
+ static_assert ( (o2 != o3), "" );
+ static_assert ( (o2 != o4), "" );
+ static_assert ( (o2 != o5), "" );
+
+ static_assert ( (o3 != o1), "" );
+ static_assert ( (o3 != o2), "" );
+ static_assert ( !(o3 != o3), "" );
+ static_assert ( (o3 != o4), "" );
+ static_assert ( !(o3 != o5), "" );
+
+ static_assert ( (o4 != o1), "" );
+ static_assert ( (o4 != o2), "" );
+ static_assert ( (o4 != o3), "" );
+ static_assert ( !(o4 != o4), "" );
+ static_assert ( (o4 != o5), "" );
+
+ static_assert ( (o5 != o1), "" );
+ static_assert ( (o5 != o2), "" );
+ static_assert ( !(o5 != o3), "" );
+ static_assert ( (o5 != o4), "" );
+ static_assert ( !(o5 != o5), "" );
+
+ }
+#endif
+}
diff --git a/test/std/experimental/optional/optional.specalg/make_optional.pass.cpp b/test/std/experimental/optional/optional.specalg/make_optional.pass.cpp
new file mode 100644
index 000000000000..cc95e6110e8d
--- /dev/null
+++ b/test/std/experimental/optional/optional.specalg/make_optional.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// template <class T>
+// constexpr
+// optional<typename decay<T>::type>
+// make_optional(T&& v);
+
+#include <experimental/optional>
+#include <string>
+#include <memory>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ using std::experimental::optional;
+ using std::experimental::make_optional;
+
+ {
+ optional<int> opt = make_optional(2);
+ assert(*opt == 2);
+ }
+ {
+ std::string s("123");
+ optional<std::string> opt = make_optional(s);
+ assert(*opt == s);
+ }
+ {
+ std::string s("123");
+ optional<std::string> opt = make_optional(std::move(s));
+ assert(*opt == "123");
+ assert(s.empty());
+ }
+ {
+ std::unique_ptr<int> s(new int(3));
+ optional<std::unique_ptr<int>> opt = make_optional(std::move(s));
+ assert(**opt == 3);
+ assert(s == nullptr);
+ }
+#endif // _LIBCPP_STD_VER > 11
+}
diff --git a/test/std/experimental/optional/optional.specalg/swap.pass.cpp b/test/std/experimental/optional/optional.specalg/swap.pass.cpp
new file mode 100644
index 000000000000..e31d2173425b
--- /dev/null
+++ b/test/std/experimental/optional/optional.specalg/swap.pass.cpp
@@ -0,0 +1,305 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// template <class T> void swap(optional<T>& x, optional<T>& y)
+// noexcept(noexcept(x.swap(y)));
+
+#include <experimental/optional>
+#include <type_traits>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+
+class X
+{
+ int i_;
+public:
+ static unsigned dtor_called;
+ X(int i) : i_(i) {}
+ X(X&& x) = default;
+ X& operator=(X&&) = default;
+ ~X() {++dtor_called;}
+
+ friend bool operator==(const X& x, const X& y) {return x.i_ == y.i_;}
+};
+
+unsigned X::dtor_called = 0;
+
+class Y
+{
+ int i_;
+public:
+ static unsigned dtor_called;
+ Y(int i) : i_(i) {}
+ Y(Y&&) = default;
+ ~Y() {++dtor_called;}
+
+ friend constexpr bool operator==(const Y& x, const Y& y) {return x.i_ == y.i_;}
+ friend void swap(Y& x, Y& y) {std::swap(x.i_, y.i_);}
+};
+
+unsigned Y::dtor_called = 0;
+
+class Z
+{
+ int i_;
+public:
+ Z(int i) : i_(i) {}
+ Z(Z&&) {throw 7;}
+
+ friend constexpr bool operator==(const Z& x, const Z& y) {return x.i_ == y.i_;}
+ friend void swap(Z& x, Z& y) {throw 6;}
+};
+
+
+#endif // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ {
+ optional<int> opt1;
+ optional<int> opt2;
+ static_assert(noexcept(swap(opt1, opt2)) == true, "");
+ assert(static_cast<bool>(opt1) == false);
+ assert(static_cast<bool>(opt2) == false);
+ swap(opt1, opt2);
+ assert(static_cast<bool>(opt1) == false);
+ assert(static_cast<bool>(opt2) == false);
+ }
+ {
+ optional<int> opt1(1);
+ optional<int> opt2;
+ static_assert(noexcept(swap(opt1, opt2)) == true, "");
+ assert(static_cast<bool>(opt1) == true);
+ assert(*opt1 == 1);
+ assert(static_cast<bool>(opt2) == false);
+ swap(opt1, opt2);
+ assert(static_cast<bool>(opt1) == false);
+ assert(static_cast<bool>(opt2) == true);
+ assert(*opt2 == 1);
+ }
+ {
+ optional<int> opt1;
+ optional<int> opt2(2);
+ static_assert(noexcept(swap(opt1, opt2)) == true, "");
+ assert(static_cast<bool>(opt1) == false);
+ assert(static_cast<bool>(opt2) == true);
+ assert(*opt2 == 2);
+ swap(opt1, opt2);
+ assert(static_cast<bool>(opt1) == true);
+ assert(*opt1 == 2);
+ assert(static_cast<bool>(opt2) == false);
+ }
+ {
+ optional<int> opt1(1);
+ optional<int> opt2(2);
+ static_assert(noexcept(swap(opt1, opt2)) == true, "");
+ assert(static_cast<bool>(opt1) == true);
+ assert(*opt1 == 1);
+ assert(static_cast<bool>(opt2) == true);
+ assert(*opt2 == 2);
+ swap(opt1, opt2);
+ assert(static_cast<bool>(opt1) == true);
+ assert(*opt1 == 2);
+ assert(static_cast<bool>(opt2) == true);
+ assert(*opt2 == 1);
+ }
+ {
+ optional<X> opt1;
+ optional<X> opt2;
+ static_assert(noexcept(swap(opt1, opt2)) == true, "");
+ assert(static_cast<bool>(opt1) == false);
+ assert(static_cast<bool>(opt2) == false);
+ swap(opt1, opt2);
+ assert(static_cast<bool>(opt1) == false);
+ assert(static_cast<bool>(opt2) == false);
+ assert(X::dtor_called == 0);
+ }
+ {
+ optional<X> opt1(1);
+ optional<X> opt2;
+ static_assert(noexcept(swap(opt1, opt2)) == true, "");
+ assert(static_cast<bool>(opt1) == true);
+ assert(*opt1 == 1);
+ assert(static_cast<bool>(opt2) == false);
+ X::dtor_called = 0;
+ swap(opt1, opt2);
+ assert(X::dtor_called == 1);
+ assert(static_cast<bool>(opt1) == false);
+ assert(static_cast<bool>(opt2) == true);
+ assert(*opt2 == 1);
+ }
+ {
+ optional<X> opt1;
+ optional<X> opt2(2);
+ static_assert(noexcept(swap(opt1, opt2)) == true, "");
+ assert(static_cast<bool>(opt1) == false);
+ assert(static_cast<bool>(opt2) == true);
+ assert(*opt2 == 2);
+ X::dtor_called = 0;
+ swap(opt1, opt2);
+ assert(X::dtor_called == 1);
+ assert(static_cast<bool>(opt1) == true);
+ assert(*opt1 == 2);
+ assert(static_cast<bool>(opt2) == false);
+ }
+ {
+ optional<X> opt1(1);
+ optional<X> opt2(2);
+ static_assert(noexcept(swap(opt1, opt2)) == true, "");
+ assert(static_cast<bool>(opt1) == true);
+ assert(*opt1 == 1);
+ assert(static_cast<bool>(opt2) == true);
+ assert(*opt2 == 2);
+ X::dtor_called = 0;
+ swap(opt1, opt2);
+ assert(X::dtor_called == 1); // from inside std::swap
+ assert(static_cast<bool>(opt1) == true);
+ assert(*opt1 == 2);
+ assert(static_cast<bool>(opt2) == true);
+ assert(*opt2 == 1);
+ }
+ {
+ optional<Y> opt1;
+ optional<Y> opt2;
+ static_assert(noexcept(swap(opt1, opt2)) == false, "");
+ assert(static_cast<bool>(opt1) == false);
+ assert(static_cast<bool>(opt2) == false);
+ swap(opt1, opt2);
+ assert(static_cast<bool>(opt1) == false);
+ assert(static_cast<bool>(opt2) == false);
+ assert(Y::dtor_called == 0);
+ }
+ {
+ optional<Y> opt1(1);
+ optional<Y> opt2;
+ static_assert(noexcept(swap(opt1, opt2)) == false, "");
+ assert(static_cast<bool>(opt1) == true);
+ assert(*opt1 == 1);
+ assert(static_cast<bool>(opt2) == false);
+ Y::dtor_called = 0;
+ swap(opt1, opt2);
+ assert(Y::dtor_called == 1);
+ assert(static_cast<bool>(opt1) == false);
+ assert(static_cast<bool>(opt2) == true);
+ assert(*opt2 == 1);
+ }
+ {
+ optional<Y> opt1;
+ optional<Y> opt2(2);
+ static_assert(noexcept(swap(opt1, opt2)) == false, "");
+ assert(static_cast<bool>(opt1) == false);
+ assert(static_cast<bool>(opt2) == true);
+ assert(*opt2 == 2);
+ Y::dtor_called = 0;
+ swap(opt1, opt2);
+ assert(Y::dtor_called == 1);
+ assert(static_cast<bool>(opt1) == true);
+ assert(*opt1 == 2);
+ assert(static_cast<bool>(opt2) == false);
+ }
+ {
+ optional<Y> opt1(1);
+ optional<Y> opt2(2);
+ static_assert(noexcept(swap(opt1, opt2)) == false, "");
+ assert(static_cast<bool>(opt1) == true);
+ assert(*opt1 == 1);
+ assert(static_cast<bool>(opt2) == true);
+ assert(*opt2 == 2);
+ Y::dtor_called = 0;
+ swap(opt1, opt2);
+ assert(Y::dtor_called == 0);
+ assert(static_cast<bool>(opt1) == true);
+ assert(*opt1 == 2);
+ assert(static_cast<bool>(opt2) == true);
+ assert(*opt2 == 1);
+ }
+ {
+ optional<Z> opt1;
+ optional<Z> opt2;
+ static_assert(noexcept(swap(opt1, opt2)) == false, "");
+ assert(static_cast<bool>(opt1) == false);
+ assert(static_cast<bool>(opt2) == false);
+ swap(opt1, opt2);
+ assert(static_cast<bool>(opt1) == false);
+ assert(static_cast<bool>(opt2) == false);
+ }
+ {
+ optional<Z> opt1;
+ opt1.emplace(1);
+ optional<Z> opt2;
+ static_assert(noexcept(swap(opt1, opt2)) == false, "");
+ assert(static_cast<bool>(opt1) == true);
+ assert(*opt1 == 1);
+ assert(static_cast<bool>(opt2) == false);
+ try
+ {
+ swap(opt1, opt2);
+ assert(false);
+ }
+ catch (int i)
+ {
+ assert(i == 7);
+ }
+ assert(static_cast<bool>(opt1) == true);
+ assert(*opt1 == 1);
+ assert(static_cast<bool>(opt2) == false);
+ }
+ {
+ optional<Z> opt1;
+ optional<Z> opt2;
+ opt2.emplace(2);
+ static_assert(noexcept(swap(opt1, opt2)) == false, "");
+ assert(static_cast<bool>(opt1) == false);
+ assert(static_cast<bool>(opt2) == true);
+ assert(*opt2 == 2);
+ try
+ {
+ swap(opt1, opt2);
+ assert(false);
+ }
+ catch (int i)
+ {
+ assert(i == 7);
+ }
+ assert(static_cast<bool>(opt1) == false);
+ assert(static_cast<bool>(opt2) == true);
+ assert(*opt2 == 2);
+ }
+ {
+ optional<Z> opt1;
+ opt1.emplace(1);
+ optional<Z> opt2;
+ opt2.emplace(2);
+ static_assert(noexcept(swap(opt1, opt2)) == false, "");
+ assert(static_cast<bool>(opt1) == true);
+ assert(*opt1 == 1);
+ assert(static_cast<bool>(opt2) == true);
+ assert(*opt2 == 2);
+ try
+ {
+ swap(opt1, opt2);
+ assert(false);
+ }
+ catch (int i)
+ {
+ assert(i == 6);
+ }
+ assert(static_cast<bool>(opt1) == true);
+ assert(*opt1 == 1);
+ assert(static_cast<bool>(opt2) == true);
+ assert(*opt2 == 2);
+ }
+#endif // _LIBCPP_STD_VER > 11
+}
diff --git a/test/std/experimental/optional/optional.syn/optional_const_in_place_t.fail.cpp b/test/std/experimental/optional/optional.syn/optional_const_in_place_t.fail.cpp
new file mode 100644
index 000000000000..60836ae2396e
--- /dev/null
+++ b/test/std/experimental/optional/optional.syn/optional_const_in_place_t.fail.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// A program that necessitates the instantiation of template optional for
+// (possibly cv-qualified) in_place_t is ill-formed.
+
+#include <experimental/optional>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ using std::experimental::optional;
+ using std::experimental::in_place_t;
+ using std::experimental::in_place;
+
+ optional<const in_place_t> opt;
+#else
+#error
+#endif // _LIBCPP_STD_VER > 11
+}
diff --git a/test/std/experimental/optional/optional.syn/optional_const_lvalue_ref.fail.cpp b/test/std/experimental/optional/optional.syn/optional_const_lvalue_ref.fail.cpp
new file mode 100644
index 000000000000..9a4ba1a027a1
--- /dev/null
+++ b/test/std/experimental/optional/optional.syn/optional_const_lvalue_ref.fail.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// A program that necessitates the instantiation of template optional for a
+// reference type is ill-formed.
+
+#include <experimental/optional>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ using std::experimental::optional;
+
+ optional<const int&> opt;
+#else
+#error
+#endif // _LIBCPP_STD_VER > 11
+}
diff --git a/test/std/experimental/optional/optional.syn/optional_const_nullopt_t.fail.cpp b/test/std/experimental/optional/optional.syn/optional_const_nullopt_t.fail.cpp
new file mode 100644
index 000000000000..f6220bda69c4
--- /dev/null
+++ b/test/std/experimental/optional/optional.syn/optional_const_nullopt_t.fail.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// A program that necessitates the instantiation of template optional for
+// (possibly cv-qualified) null_opt_t is ill-formed.
+
+#include <experimental/optional>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ using std::experimental::optional;
+ using std::experimental::nullopt_t;
+ using std::experimental::nullopt;
+
+ optional<const nullopt_t> opt;
+#else
+#error
+#endif // _LIBCPP_STD_VER > 11
+}
diff --git a/test/std/experimental/optional/optional.syn/optional_in_place_t.fail.cpp b/test/std/experimental/optional/optional.syn/optional_in_place_t.fail.cpp
new file mode 100644
index 000000000000..12f291fcd228
--- /dev/null
+++ b/test/std/experimental/optional/optional.syn/optional_in_place_t.fail.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// A program that necessitates the instantiation of template optional for
+// (possibly cv-qualified) in_place_t is ill-formed.
+
+#include <experimental/optional>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ using std::experimental::optional;
+ using std::experimental::in_place_t;
+ using std::experimental::in_place;
+
+ optional<in_place_t> opt;
+#else
+#error
+#endif // _LIBCPP_STD_VER > 11
+}
diff --git a/test/std/experimental/optional/optional.syn/optional_includes_initializer_list.pass.cpp b/test/std/experimental/optional/optional.syn/optional_includes_initializer_list.pass.cpp
new file mode 100644
index 000000000000..7e6697ff6e50
--- /dev/null
+++ b/test/std/experimental/optional/optional.syn/optional_includes_initializer_list.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// #include <initializer_list>
+
+#include <experimental/optional>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ using std::experimental::optional;
+
+ std::initializer_list<int> list;
+#endif // _LIBCPP_STD_VER > 11
+}
diff --git a/test/std/experimental/optional/optional.syn/optional_lvalue_ref.fail.cpp b/test/std/experimental/optional/optional.syn/optional_lvalue_ref.fail.cpp
new file mode 100644
index 000000000000..850df342aef0
--- /dev/null
+++ b/test/std/experimental/optional/optional.syn/optional_lvalue_ref.fail.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// A program that necessitates the instantiation of template optional for a
+// reference type is ill-formed.
+
+#include <experimental/optional>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ using std::experimental::optional;
+
+ optional<int&> opt;
+#else
+#error
+#endif // _LIBCPP_STD_VER > 11
+}
diff --git a/test/std/experimental/optional/optional.syn/optional_nullopt_t.fail.cpp b/test/std/experimental/optional/optional.syn/optional_nullopt_t.fail.cpp
new file mode 100644
index 000000000000..20955ace834a
--- /dev/null
+++ b/test/std/experimental/optional/optional.syn/optional_nullopt_t.fail.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// A program that necessitates the instantiation of template optional for
+// (possibly cv-qualified) null_opt_t is ill-formed.
+
+#include <experimental/optional>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ using std::experimental::optional;
+ using std::experimental::nullopt_t;
+ using std::experimental::nullopt;
+
+ optional<nullopt_t> opt;
+#else
+#error
+#endif // _LIBCPP_STD_VER > 11
+}
diff --git a/test/std/experimental/optional/optional.syn/optional_rvalue_ref.fail.cpp b/test/std/experimental/optional/optional.syn/optional_rvalue_ref.fail.cpp
new file mode 100644
index 000000000000..d773e993df22
--- /dev/null
+++ b/test/std/experimental/optional/optional.syn/optional_rvalue_ref.fail.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// A program that necessitates the instantiation of template optional for a
+// reference type is ill-formed.
+
+#include <experimental/optional>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ using std::experimental::optional;
+
+ optional<int&&> opt;
+#else
+#error
+#endif // _LIBCPP_STD_VER > 11
+}
diff --git a/test/std/experimental/optional/version.pass.cpp b/test/std/experimental/optional/version.pass.cpp
new file mode 100644
index 000000000000..585b7a24eea5
--- /dev/null
+++ b/test/std/experimental/optional/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+#include <experimental/optional>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/experimental/string.view/nothing_to_do.pass.cpp b/test/std/experimental/string.view/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..c21f8a701685
--- /dev/null
+++ b/test/std/experimental/string.view/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <experimental/string_view>
+
+int main () {}
diff --git a/test/std/experimental/string.view/string.view.access/at.pass.cpp b/test/std/experimental/string.view/string.view.access/at.pass.cpp
new file mode 100644
index 000000000000..3003ea835470
--- /dev/null
+++ b/test/std/experimental/string.view/string.view.access/at.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// NOTE: Older versions of clang have a bug where they fail to evalute
+// string_view::at as a constant expression.
+// XFAIL: clang-3.4, clang-3.3
+
+// <string_view>
+
+// constexpr const _CharT& at(size_type _pos) const;
+
+#include <experimental/string_view>
+#include <cassert>
+
+template <typename CharT>
+void test ( const CharT *s, size_t len ) {
+ std::experimental::basic_string_view<CharT> sv ( s, len );
+ assert ( sv.length() == len );
+ for ( size_t i = 0; i < len; ++i ) {
+ assert ( sv.at(i) == s[i] );
+ assert ( &sv.at(i) == s + i );
+ }
+
+ try { sv.at(len); } catch ( const std::out_of_range & ) { return ; }
+ assert ( false );
+ }
+
+int main () {
+ test ( "ABCDE", 5 );
+ test ( "a", 1 );
+
+ test ( L"ABCDE", 5 );
+ test ( L"a", 1 );
+
+#if __cplusplus >= 201103L
+ test ( u"ABCDE", 5 );
+ test ( u"a", 1 );
+
+ test ( U"ABCDE", 5 );
+ test ( U"a", 1 );
+#endif
+
+#if __cplusplus >= 201103L
+ {
+ constexpr std::experimental::basic_string_view<char> sv ( "ABC", 2 );
+ static_assert ( sv.length() == 2, "" );
+ static_assert ( sv.at(0) == 'A', "" );
+ static_assert ( sv.at(1) == 'B', "" );
+ }
+#endif
+}
diff --git a/test/std/experimental/string.view/string.view.access/back.pass.cpp b/test/std/experimental/string.view/string.view.access/back.pass.cpp
new file mode 100644
index 000000000000..093a858a4805
--- /dev/null
+++ b/test/std/experimental/string.view/string.view.access/back.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+
+// <string_view>
+
+// constexpr const _CharT& front();
+
+#include <experimental/string_view>
+#include <cassert>
+
+template <typename CharT>
+bool test ( const CharT *s, size_t len ) {
+ std::experimental::basic_string_view<CharT> sv ( s, len );
+ assert ( sv.length() == len );
+ assert ( sv.back() == s[len-1] );
+ return &sv.back() == s + len - 1;
+ }
+
+int main () {
+ assert ( test ( "ABCDE", 5 ));
+ assert ( test ( "a", 1 ));
+
+ assert ( test ( L"ABCDE", 5 ));
+ assert ( test ( L"a", 1 ));
+
+#if __cplusplus >= 201103L
+ assert ( test ( u"ABCDE", 5 ));
+ assert ( test ( u"a", 1 ));
+
+ assert ( test ( U"ABCDE", 5 ));
+ assert ( test ( U"a", 1 ));
+#endif
+
+#if __cplusplus >= 201103L
+ {
+ constexpr std::experimental::basic_string_view<char> sv ( "ABC", 2 );
+ static_assert ( sv.length() == 2, "" );
+ static_assert ( sv.back() == 'B', "" );
+ }
+#endif
+}
diff --git a/test/std/experimental/string.view/string.view.access/data.pass.cpp b/test/std/experimental/string.view/string.view.access/data.pass.cpp
new file mode 100644
index 000000000000..562a765f50ce
--- /dev/null
+++ b/test/std/experimental/string.view/string.view.access/data.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+
+// <string_view>
+
+// constexpr const _CharT* data() const noexcept;
+
+#include <experimental/string_view>
+#include <cassert>
+
+template <typename CharT>
+void test ( const CharT *s, size_t len ) {
+ std::experimental::basic_string_view<CharT> sv ( s, len );
+ assert ( sv.length() == len );
+ assert ( sv.data() == s );
+ }
+
+int main () {
+ test ( "ABCDE", 5 );
+ test ( "a", 1 );
+
+ test ( L"ABCDE", 5 );
+ test ( L"a", 1 );
+
+#if __cplusplus >= 201103L
+ test ( u"ABCDE", 5 );
+ test ( u"a", 1 );
+
+ test ( U"ABCDE", 5 );
+ test ( U"a", 1 );
+#endif
+
+#if _LIBCPP_STD_VER > 11
+ {
+ constexpr const char *s = "ABC";
+ constexpr std::experimental::basic_string_view<char> sv( s, 2 );
+ static_assert( sv.length() == 2, "" );
+ static_assert( sv.data() == s, "" );
+ }
+#endif
+}
diff --git a/test/std/experimental/string.view/string.view.access/front.pass.cpp b/test/std/experimental/string.view/string.view.access/front.pass.cpp
new file mode 100644
index 000000000000..e9df44b19b1a
--- /dev/null
+++ b/test/std/experimental/string.view/string.view.access/front.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+
+// <string_view>
+
+// constexpr const _CharT& back();
+
+#include <experimental/string_view>
+#include <cassert>
+
+template <typename CharT>
+bool test ( const CharT *s, size_t len ) {
+ std::experimental::basic_string_view<CharT> sv ( s, len );
+ assert ( sv.length() == len );
+ assert ( sv.front() == s[0] );
+ return &sv.front() == s;
+ }
+
+int main () {
+ assert ( test ( "ABCDE", 5 ));
+ assert ( test ( "a", 1 ));
+
+ assert ( test ( L"ABCDE", 5 ));
+ assert ( test ( L"a", 1 ));
+
+#if __cplusplus >= 201103L
+ assert ( test ( u"ABCDE", 5 ));
+ assert ( test ( u"a", 1 ));
+
+ assert ( test ( U"ABCDE", 5 ));
+ assert ( test ( U"a", 1 ));
+#endif
+
+#if __cplusplus >= 201103L
+ {
+ constexpr std::experimental::basic_string_view<char> sv ( "ABC", 2 );
+ static_assert ( sv.length() == 2, "" );
+ static_assert ( sv.front() == 'A', "" );
+ }
+#endif
+}
diff --git a/test/std/experimental/string.view/string.view.access/index.pass.cpp b/test/std/experimental/string.view/string.view.access/index.pass.cpp
new file mode 100644
index 000000000000..4491207cbb85
--- /dev/null
+++ b/test/std/experimental/string.view/string.view.access/index.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+
+// <string_view>
+
+// constexpr const _CharT& operator[](size_type _pos) const;
+
+#include <experimental/string_view>
+#include <cassert>
+
+template <typename CharT>
+void test ( const CharT *s, size_t len ) {
+ std::experimental::basic_string_view<CharT> sv ( s, len );
+ assert ( sv.length() == len );
+ for ( size_t i = 0; i < len; ++i ) {
+ assert ( sv[i] == s[i] );
+ assert ( &sv[i] == s + i );
+ }
+ }
+
+int main () {
+ test ( "ABCDE", 5 );
+ test ( "a", 1 );
+
+ test ( L"ABCDE", 5 );
+ test ( L"a", 1 );
+
+#if __cplusplus >= 201103L
+ test ( u"ABCDE", 5 );
+ test ( u"a", 1 );
+
+ test ( U"ABCDE", 5 );
+ test ( U"a", 1 );
+#endif
+
+#if _LIBCPP_STD_VER > 11
+ {
+ constexpr std::experimental::basic_string_view<char> sv ( "ABC", 2 );
+ static_assert ( sv.length() == 2, "" );
+ static_assert ( sv[0] == 'A', "" );
+ static_assert ( sv[1] == 'B', "" );
+ }
+#endif
+}
diff --git a/test/std/experimental/string.view/string.view.capacity/capacity.pass.cpp b/test/std/experimental/string.view/string.view.capacity/capacity.pass.cpp
new file mode 100644
index 000000000000..eb802165930d
--- /dev/null
+++ b/test/std/experimental/string.view/string.view.capacity/capacity.pass.cpp
@@ -0,0 +1,87 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+
+// <string_view>
+
+// [string.view.capacity], capacity
+// constexpr size_type size() const noexcept;
+// constexpr size_type length() const noexcept;
+// constexpr size_type max_size() const noexcept;
+// constexpr bool empty() const noexcept;
+
+#include <experimental/string_view>
+#include <cassert>
+
+template<typename SV>
+void test1 () {
+#if _LIBCPP_STD_VER > 11
+ {
+ constexpr SV sv1;
+ static_assert ( sv1.size() == 0, "" );
+ static_assert ( sv1.empty(), "");
+ static_assert ( sv1.size() == sv1.length(), "" );
+ static_assert ( sv1.max_size() > sv1.size(), "");
+ }
+#endif
+
+ {
+ SV sv1;
+ assert ( sv1.size() == 0 );
+ assert ( sv1.empty());
+ assert ( sv1.size() == sv1.length());
+ assert ( sv1.max_size() > sv1.size());
+ }
+}
+
+template<typename CharT>
+void test2 ( const CharT *s, size_t len ) {
+ {
+ std::experimental::basic_string_view<CharT> sv1 ( s );
+ assert ( sv1.size() == len );
+ assert ( sv1.data() == s );
+ assert ( sv1.empty() == (len == 0));
+ assert ( sv1.size() == sv1.length());
+ assert ( sv1.max_size() > sv1.size());
+ }
+}
+
+int main () {
+ typedef std::experimental::string_view string_view;
+ typedef std::experimental::u16string_view u16string_view;
+ typedef std::experimental::u32string_view u32string_view;
+ typedef std::experimental::wstring_view wstring_view;
+
+ test1<string_view> ();
+ test1<u16string_view> ();
+ test1<u32string_view> ();
+ test1<wstring_view> ();
+
+ test2 ( "ABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDE", 105 );
+ test2 ( "ABCDE", 5 );
+ test2 ( "a", 1 );
+ test2 ( "", 0 );
+
+ test2 ( L"ABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDE", 105 );
+ test2 ( L"ABCDE", 5 );
+ test2 ( L"a", 1 );
+ test2 ( L"", 0 );
+
+#if __cplusplus >= 201103L
+ test2 ( u"ABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDE", 105 );
+ test2 ( u"ABCDE", 5 );
+ test2 ( u"a", 1 );
+ test2 ( u"", 0 );
+
+ test2 ( U"ABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDE", 105 );
+ test2 ( U"ABCDE", 5 );
+ test2 ( U"a", 1 );
+ test2 ( U"", 0 );
+#endif
+}
diff --git a/test/std/experimental/string.view/string.view.comparison/opeq.string_view.pointer.pass.cpp b/test/std/experimental/string.view/string.view.comparison/opeq.string_view.pointer.pass.cpp
new file mode 100644
index 000000000000..148dc18d7ec8
--- /dev/null
+++ b/test/std/experimental/string.view/string.view.comparison/opeq.string_view.pointer.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits>
+// constexpr bool operator==(basic_string_view<charT,traits> lhs, const charT* rhs);
+// template<class charT, class traits>
+// constexpr bool operator==(const charT* lhs, basic_string_view<charT,traits> rhs);
+
+#include <experimental/string_view>
+#include <cassert>
+
+#include "constexpr_char_traits.hpp"
+
+template <class S>
+void
+test(S lhs, const typename S::value_type* rhs, bool x)
+{
+ assert((lhs == rhs) == x);
+ assert((rhs == lhs) == x);
+}
+
+int main()
+{
+ {
+ typedef std::experimental::string_view S;
+ test(S(""), "", true);
+ test(S(""), "abcde", false);
+ test(S(""), "abcdefghij", false);
+ test(S(""), "abcdefghijklmnopqrst", false);
+ test(S("abcde"), "", false);
+ test(S("abcde"), "abcde", true);
+ test(S("abcde"), "abcdefghij", false);
+ test(S("abcde"), "abcdefghijklmnopqrst", false);
+ test(S("abcdefghij"), "", false);
+ test(S("abcdefghij"), "abcde", false);
+ test(S("abcdefghij"), "abcdefghij", true);
+ test(S("abcdefghij"), "abcdefghijklmnopqrst", false);
+ test(S("abcdefghijklmnopqrst"), "", false);
+ test(S("abcdefghijklmnopqrst"), "abcde", false);
+ test(S("abcdefghijklmnopqrst"), "abcdefghij", false);
+ test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", true);
+ }
+
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::experimental::basic_string_view<char, constexpr_char_traits<char>> SV;
+ constexpr SV sv1;
+ constexpr SV sv2 { "abcde", 5 };
+ static_assert ( sv1 == "", "" );
+ static_assert ( "" == sv1, "" );
+ static_assert (!(sv1 == "abcde"), "" );
+ static_assert (!("abcde" == sv1), "" );
+
+ static_assert ( sv2 == "abcde", "" );
+ static_assert ( "abcde" == sv2, "" );
+ static_assert (!(sv2 == "abcde0"), "" );
+ static_assert (!("abcde0" == sv2), "" );
+ }
+#endif
+}
diff --git a/test/std/experimental/string.view/string.view.comparison/opeq.string_view.string.pass.cpp b/test/std/experimental/string.view/string.view.comparison/opeq.string_view.string.pass.cpp
new file mode 100644
index 000000000000..23a2aef242d7
--- /dev/null
+++ b/test/std/experimental/string.view/string.view.comparison/opeq.string_view.string.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+// bool operator==(const charT* lhs, const basic_string<charT,traits> rhs);
+// template<class charT, class traits, class Allocator>
+// bool operator==(const basic_string_view<charT,traits> lhs, const CharT* rhs);
+
+#include <experimental/string_view>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+template <class S>
+void
+test(const std::string &lhs, S rhs, bool x)
+{
+ assert((lhs == rhs) == x);
+ assert((rhs == lhs) == x);
+}
+
+int main()
+{
+ {
+ typedef std::experimental::string_view S;
+ test("", S(""), true);
+ test("", S("abcde"), false);
+ test("", S("abcdefghij"), false);
+ test("", S("abcdefghijklmnopqrst"), false);
+ test("abcde", S(""), false);
+ test("abcde", S("abcde"), true);
+ test("abcde", S("abcdefghij"), false);
+ test("abcde", S("abcdefghijklmnopqrst"), false);
+ test("abcdefghij", S(""), false);
+ test("abcdefghij", S("abcde"), false);
+ test("abcdefghij", S("abcdefghij"), true);
+ test("abcdefghij", S("abcdefghijklmnopqrst"), false);
+ test("abcdefghijklmnopqrst", S(""), false);
+ test("abcdefghijklmnopqrst", S("abcde"), false);
+ test("abcdefghijklmnopqrst", S("abcdefghij"), false);
+ test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), true);
+ }
+}
+#else
+int main () {}
+#endif
diff --git a/test/std/experimental/string.view/string.view.comparison/opeq.string_view.string_view.pass.cpp b/test/std/experimental/string.view/string.view.comparison/opeq.string_view.string_view.pass.cpp
new file mode 100644
index 000000000000..5971f6974380
--- /dev/null
+++ b/test/std/experimental/string.view/string.view.comparison/opeq.string_view.string_view.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string_view>
+
+// template<class charT, class traits, class Allocator>
+// constexpr bool operator==(const basic_string_view<charT,traits> lhs,
+// const basic_string_view<charT,traits> rhs);
+
+#include <experimental/string_view>
+#include <cassert>
+
+#include "constexpr_char_traits.hpp"
+
+template <class S>
+void
+test(S lhs, S rhs, bool x)
+{
+ assert((lhs == rhs) == x);
+ assert((rhs == lhs) == x);
+}
+
+int main()
+{
+ {
+ typedef std::experimental::string_view S;
+ test(S(""), S(""), true);
+ test(S(""), S("abcde"), false);
+ test(S(""), S("abcdefghij"), false);
+ test(S(""), S("abcdefghijklmnopqrst"), false);
+ test(S("abcde"), S(""), false);
+ test(S("abcde"), S("abcde"), true);
+ test(S("abcde"), S("abcdefghij"), false);
+ test(S("abcde"), S("abcdefghijklmnopqrst"), false);
+ test(S("abcdefghij"), S(""), false);
+ test(S("abcdefghij"), S("abcde"), false);
+ test(S("abcdefghij"), S("abcdefghij"), true);
+ test(S("abcdefghij"), S("abcdefghijklmnopqrst"), false);
+ test(S("abcdefghijklmnopqrst"), S(""), false);
+ test(S("abcdefghijklmnopqrst"), S("abcde"), false);
+ test(S("abcdefghijklmnopqrst"), S("abcdefghij"), false);
+ test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), true);
+ }
+
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::experimental::basic_string_view<char, constexpr_char_traits<char>> SV;
+ constexpr SV sv1;
+ constexpr SV sv2;
+ constexpr SV sv3 { "abcde", 5 };
+ static_assert ( sv1 == sv2, "" );
+ static_assert (!(sv1 == sv3), "" );
+ }
+#endif
+}
diff --git a/test/std/experimental/string.view/string.view.comparison/opge.string_view.pointer.pass.cpp b/test/std/experimental/string.view/string.view.comparison/opge.string_view.pointer.pass.cpp
new file mode 100644
index 000000000000..f02459b01c49
--- /dev/null
+++ b/test/std/experimental/string.view/string.view.comparison/opge.string_view.pointer.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+// constexpr bool operator>=(const charT* lhs, basic_string_wiew<charT,traits> rhs);
+// template<class charT, class traits, class Allocator>
+// constexpr bool operator>=(basic_string_wiew<charT,traits> lhs, const charT* rhs);
+
+#include <experimental/string_view>
+#include <cassert>
+
+#include "constexpr_char_traits.hpp"
+
+template <class S>
+void
+test(const typename S::value_type* lhs, const S& rhs, bool x, bool y)
+{
+ assert((lhs >= rhs) == x);
+ assert((rhs >= lhs) == y);
+}
+
+int main()
+{
+ {
+ typedef std::experimental::string_view S;
+ test("", S(""), true, true);
+ test("", S("abcde"), false, true);
+ test("", S("abcdefghij"), false, true);
+ test("", S("abcdefghijklmnopqrst"), false, true);
+ test("abcde", S(""), true, false);
+ test("abcde", S("abcde"), true, true);
+ test("abcde", S("abcdefghij"), false, true);
+ test("abcde", S("abcdefghijklmnopqrst"), false, true);
+ test("abcdefghij", S(""), true, false);
+ test("abcdefghij", S("abcde"), true, false);
+ test("abcdefghij", S("abcdefghij"), true, true);
+ test("abcdefghij", S("abcdefghijklmnopqrst"), false, true);
+ test("abcdefghijklmnopqrst", S(""), true, false);
+ test("abcdefghijklmnopqrst", S("abcde"), true, false);
+ test("abcdefghijklmnopqrst", S("abcdefghij"), true, false);
+ test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), true, true);
+ }
+
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::experimental::basic_string_view<char, constexpr_char_traits<char>> SV;
+ constexpr SV sv1;
+ constexpr SV sv2 { "abcde", 5 };
+
+ static_assert ( sv1 >= "", "" );
+ static_assert ( "" >= sv1, "" );
+ static_assert (!(sv1 >= "abcde"), "" );
+ static_assert ( "abcde" >= sv1, "" );
+
+ static_assert ( sv2 >= "", "" );
+ static_assert (!("" >= sv2), "" );
+ static_assert ( sv2 >= "abcde", "" );
+ static_assert ( "abcde" >= sv2, "" );
+ static_assert (!(sv2 >= "abcde0"), "" );
+ static_assert ( "abcde0" >= sv2, "" );
+ }
+#endif
+}
diff --git a/test/std/experimental/string.view/string.view.comparison/opge.string_view.string.pass.cpp b/test/std/experimental/string.view/string.view.comparison/opge.string_view.string.pass.cpp
new file mode 100644
index 000000000000..0790f80f863c
--- /dev/null
+++ b/test/std/experimental/string.view/string.view.comparison/opge.string_view.string.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+// bool operator>=(const basic_string<charT,traits,Allocator>& lhs,
+// basic_string_view<charT,traits> rhs);
+// bool operator>=(basic_string_view<charT,traits> lhs,
+// const basic_string<charT,traits,Allocator>& rhs);
+
+#include <experimental/string_view>
+#include <cassert>
+
+template <class S>
+void
+test(const S& lhs, const typename S::value_type* rhs, bool x, bool y)
+{
+ assert((lhs >= rhs) == x);
+ assert((rhs >= lhs) == y);
+}
+
+int main()
+{
+ {
+ typedef std::experimental::string_view S;
+ test(S(""), "", true, true);
+ test(S(""), "abcde", false, true);
+ test(S(""), "abcdefghij", false, true);
+ test(S(""), "abcdefghijklmnopqrst", false, true);
+ test(S("abcde"), "", true, false);
+ test(S("abcde"), "abcde", true, true);
+ test(S("abcde"), "abcdefghij", false, true);
+ test(S("abcde"), "abcdefghijklmnopqrst", false, true);
+ test(S("abcdefghij"), "", true, false);
+ test(S("abcdefghij"), "abcde", true, false);
+ test(S("abcdefghij"), "abcdefghij", true, true);
+ test(S("abcdefghij"), "abcdefghijklmnopqrst", false, true);
+ test(S("abcdefghijklmnopqrst"), "", true, false);
+ test(S("abcdefghijklmnopqrst"), "abcde", true, false);
+ test(S("abcdefghijklmnopqrst"), "abcdefghij", true, false);
+ test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", true, true);
+ }
+}
diff --git a/test/std/experimental/string.view/string.view.comparison/opge.string_view.string_view.pass.cpp b/test/std/experimental/string.view/string.view.comparison/opge.string_view.string_view.pass.cpp
new file mode 100644
index 000000000000..e13a4ea119d1
--- /dev/null
+++ b/test/std/experimental/string.view/string.view.comparison/opge.string_view.string_view.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits>
+// constexpr bool operator>=(basic_string_view<charT,traits> lhs,
+// basic_string_view<charT,traits> rhs);
+
+#include <experimental/string_view>
+#include <cassert>
+
+#include "constexpr_char_traits.hpp"
+
+template <class S>
+void
+test(const S& lhs, const S& rhs, bool x, bool y)
+{
+ assert((lhs >= rhs) == x);
+ assert((rhs >= lhs) == y);
+}
+
+int main()
+{
+ {
+ typedef std::experimental::string_view S;
+ test(S(""), S(""), true, true);
+ test(S(""), S("abcde"), false, true);
+ test(S(""), S("abcdefghij"), false, true);
+ test(S(""), S("abcdefghijklmnopqrst"), false, true);
+ test(S("abcde"), S(""), true, false);
+ test(S("abcde"), S("abcde"), true, true);
+ test(S("abcde"), S("abcdefghij"), false, true);
+ test(S("abcde"), S("abcdefghijklmnopqrst"), false, true);
+ test(S("abcdefghij"), S(""), true, false);
+ test(S("abcdefghij"), S("abcde"), true, false);
+ test(S("abcdefghij"), S("abcdefghij"), true, true);
+ test(S("abcdefghij"), S("abcdefghijklmnopqrst"), false, true);
+ test(S("abcdefghijklmnopqrst"), S(""), true, false);
+ test(S("abcdefghijklmnopqrst"), S("abcde"), true, false);
+ test(S("abcdefghijklmnopqrst"), S("abcdefghij"), true, false);
+ test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), true, true);
+ }
+
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::experimental::basic_string_view<char, constexpr_char_traits<char>> SV;
+ constexpr SV sv1;
+ constexpr SV sv2 { "abcde", 5 };
+
+ static_assert ( sv1 >= sv1, "" );
+ static_assert ( sv2 >= sv2, "" );
+
+ static_assert (!(sv1 >= sv2), "" );
+ static_assert ( sv2 >= sv1, "" );
+ }
+#endif
+}
diff --git a/test/std/experimental/string.view/string.view.comparison/opgt.string_view.pointer.pass.cpp b/test/std/experimental/string.view/string.view.comparison/opgt.string_view.pointer.pass.cpp
new file mode 100644
index 000000000000..48703cac612f
--- /dev/null
+++ b/test/std/experimental/string.view/string.view.comparison/opgt.string_view.pointer.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// constexpr template<class charT, class traits, class Allocator>
+// bool operator>(const charT* lhs, basic_string_wiew<charT,traits> rhs);
+// constexpr template<class charT, class traits, class Allocator>
+// bool operator>(basic_string_wiew<charT,traits> lhs, const charT* rhs);
+
+#include <experimental/string_view>
+#include <cassert>
+
+#include "constexpr_char_traits.hpp"
+
+template <class S>
+void
+test(const typename S::value_type* lhs, const S& rhs, bool x, bool y)
+{
+ assert((lhs > rhs) == x);
+ assert((rhs > lhs) == y);
+}
+
+int main()
+{
+ {
+ typedef std::experimental::string_view S;
+ test("", S(""), false, false);
+ test("", S("abcde"), false, true);
+ test("", S("abcdefghij"), false, true);
+ test("", S("abcdefghijklmnopqrst"), false, true);
+ test("abcde", S(""), true, false);
+ test("abcde", S("abcde"), false, false);
+ test("abcde", S("abcdefghij"), false, true);
+ test("abcde", S("abcdefghijklmnopqrst"), false, true);
+ test("abcdefghij", S(""), true, false);
+ test("abcdefghij", S("abcde"), true, false);
+ test("abcdefghij", S("abcdefghij"), false, false);
+ test("abcdefghij", S("abcdefghijklmnopqrst"), false, true);
+ test("abcdefghijklmnopqrst", S(""), true, false);
+ test("abcdefghijklmnopqrst", S("abcde"), true, false);
+ test("abcdefghijklmnopqrst", S("abcdefghij"), true, false);
+ test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), false, false);
+ }
+
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::experimental::basic_string_view<char, constexpr_char_traits<char>> SV;
+ constexpr SV sv1;
+ constexpr SV sv2 { "abcde", 5 };
+
+ static_assert (!(sv1 > ""), "" );
+ static_assert (!("" > sv1), "" );
+ static_assert (!(sv1 > "abcde"), "" );
+ static_assert ( "abcde" > sv1, "" );
+
+ static_assert ( sv2 > "", "" );
+ static_assert (!("" > sv2), "" );
+ static_assert (!(sv2 > "abcde"), "" );
+ static_assert (!("abcde" > sv2), "" );
+ static_assert (!(sv2 > "abcde0"), "" );
+ static_assert ( "abcde0" > sv2, "" );
+ }
+#endif
+}
diff --git a/test/std/experimental/string.view/string.view.comparison/opgt.string_view.string.pass.cpp b/test/std/experimental/string.view/string.view.comparison/opgt.string_view.string.pass.cpp
new file mode 100644
index 000000000000..92f812f8249c
--- /dev/null
+++ b/test/std/experimental/string.view/string.view.comparison/opgt.string_view.string.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+// bool operator>(const basic_string<charT,traits,Allocator>& lhs,
+// basic_string_view<charT,traits> rhs);
+// bool operator>(basic_string_view<charT,traits> lhs,
+// const basic_string<charT,traits,Allocator>& rhs);
+
+#include <experimental/string_view>
+#include <cassert>
+
+template <class S>
+void
+test(const S& lhs, const typename S::value_type* rhs, bool x, bool y)
+{
+ assert((lhs > rhs) == x);
+ assert((rhs > lhs) == y);
+}
+
+int main()
+{
+ {
+ typedef std::experimental::string_view S;
+ test(S(""), "", false, false);
+ test(S(""), "abcde", false, true);
+ test(S(""), "abcdefghij", false, true);
+ test(S(""), "abcdefghijklmnopqrst", false, true);
+ test(S("abcde"), "", true, false);
+ test(S("abcde"), "abcde", false, false);
+ test(S("abcde"), "abcdefghij", false, true);
+ test(S("abcde"), "abcdefghijklmnopqrst", false, true);
+ test(S("abcdefghij"), "", true, false);
+ test(S("abcdefghij"), "abcde", true, false);
+ test(S("abcdefghij"), "abcdefghij", false, false);
+ test(S("abcdefghij"), "abcdefghijklmnopqrst", false, true);
+ test(S("abcdefghijklmnopqrst"), "", true, false);
+ test(S("abcdefghijklmnopqrst"), "abcde", true, false);
+ test(S("abcdefghijklmnopqrst"), "abcdefghij", true, false);
+ test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", false, false);
+ }
+}
diff --git a/test/std/experimental/string.view/string.view.comparison/opgt.string_view.string_view.pass.cpp b/test/std/experimental/string.view/string.view.comparison/opgt.string_view.string_view.pass.cpp
new file mode 100644
index 000000000000..3047cc7be118
--- /dev/null
+++ b/test/std/experimental/string.view/string.view.comparison/opgt.string_view.string_view.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits>
+// constexpr bool operator>(basic_string_view<charT,traits> lhs,
+// basic_string_view<charT,traits> rhs);
+
+#include <experimental/string_view>
+#include <cassert>
+
+#include "constexpr_char_traits.hpp"
+
+template <class S>
+void
+test(const S& lhs, const S& rhs, bool x, bool y)
+{
+ assert((lhs > rhs) == x);
+ assert((rhs > lhs) == y);
+}
+
+int main()
+{
+ {
+ typedef std::experimental::string_view S;
+ test(S(""), S(""), false, false);
+ test(S(""), S("abcde"), false, true);
+ test(S(""), S("abcdefghij"), false, true);
+ test(S(""), S("abcdefghijklmnopqrst"), false, true);
+ test(S("abcde"), S(""), true, false);
+ test(S("abcde"), S("abcde"), false, false);
+ test(S("abcde"), S("abcdefghij"), false, true);
+ test(S("abcde"), S("abcdefghijklmnopqrst"), false, true);
+ test(S("abcdefghij"), S(""), true, false);
+ test(S("abcdefghij"), S("abcde"), true, false);
+ test(S("abcdefghij"), S("abcdefghij"), false, false);
+ test(S("abcdefghij"), S("abcdefghijklmnopqrst"), false, true);
+ test(S("abcdefghijklmnopqrst"), S(""), true, false);
+ test(S("abcdefghijklmnopqrst"), S("abcde"), true, false);
+ test(S("abcdefghijklmnopqrst"), S("abcdefghij"), true, false);
+ test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), false, false);
+ }
+
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::experimental::basic_string_view<char, constexpr_char_traits<char>> SV;
+ constexpr SV sv1;
+ constexpr SV sv2 { "abcde", 5 };
+
+ static_assert (!(sv1 > sv1), "" );
+ static_assert (!(sv2 > sv2), "" );
+
+ static_assert (!(sv1 > sv2), "" );
+ static_assert ( sv2 > sv1, "" );
+ }
+#endif
+}
diff --git a/test/std/experimental/string.view/string.view.comparison/ople.string_view.pointer.pass.cpp b/test/std/experimental/string.view/string.view.comparison/ople.string_view.pointer.pass.cpp
new file mode 100644
index 000000000000..539f5fa5402e
--- /dev/null
+++ b/test/std/experimental/string.view/string.view.comparison/ople.string_view.pointer.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+// constexpr bool operator<=(const charT* lhs, basic_string_wiew<charT,traits> rhs);
+// template<class charT, class traits, class Allocator>
+// constexpr bool operator<=(basic_string_wiew<charT,traits> lhs, const charT* rhs);
+
+#include <experimental/string_view>
+#include <cassert>
+
+#include "constexpr_char_traits.hpp"
+
+template <class S>
+void
+test(const typename S::value_type* lhs, const S& rhs, bool x, bool y)
+{
+ assert((lhs <= rhs) == x);
+ assert((rhs <= lhs) == y);
+}
+
+int main()
+{
+ {
+ typedef std::experimental::string_view S;
+ test("", S(""), true, true);
+ test("", S("abcde"), true, false);
+ test("", S("abcdefghij"), true, false);
+ test("", S("abcdefghijklmnopqrst"), true, false);
+ test("abcde", S(""), false, true);
+ test("abcde", S("abcde"), true, true);
+ test("abcde", S("abcdefghij"), true, false);
+ test("abcde", S("abcdefghijklmnopqrst"), true, false);
+ test("abcdefghij", S(""), false, true);
+ test("abcdefghij", S("abcde"), false, true);
+ test("abcdefghij", S("abcdefghij"), true, true);
+ test("abcdefghij", S("abcdefghijklmnopqrst"), true, false);
+ test("abcdefghijklmnopqrst", S(""), false, true);
+ test("abcdefghijklmnopqrst", S("abcde"), false, true);
+ test("abcdefghijklmnopqrst", S("abcdefghij"), false, true);
+ test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), true, true);
+ }
+
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::experimental::basic_string_view<char, constexpr_char_traits<char>> SV;
+ constexpr SV sv1;
+ constexpr SV sv2 { "abcde", 5 };
+
+ static_assert ( sv1 <= "", "" );
+ static_assert ( "" <= sv1, "" );
+ static_assert ( sv1 <= "abcde", "" );
+ static_assert (!("abcde" <= sv1), "" );
+
+ static_assert (!(sv2 <= ""), "" );
+ static_assert ( "" <= sv2, "" );
+ static_assert ( sv2 <= "abcde", "" );
+ static_assert ( "abcde" <= sv2, "" );
+ static_assert ( sv2 <= "abcde0", "" );
+ static_assert (!("abcde0" <= sv2), "" );
+ }
+#endif
+}
diff --git a/test/std/experimental/string.view/string.view.comparison/ople.string_view.string.pass.cpp b/test/std/experimental/string.view/string.view.comparison/ople.string_view.string.pass.cpp
new file mode 100644
index 000000000000..39abbd04fc5d
--- /dev/null
+++ b/test/std/experimental/string.view/string.view.comparison/ople.string_view.string.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+// bool operator<=(const basic_string<charT,traits,Allocator>& lhs,
+// basic_string_view<charT,traits> rhs);
+// bool operator<=(basic_string_view<charT,traits> lhs,
+// const basic_string<charT,traits,Allocator>& rhs);
+
+#include <experimental/string_view>
+#include <cassert>
+
+template <class S>
+void
+test(const S& lhs, const typename S::value_type* rhs, bool x, bool y)
+{
+ assert((lhs <= rhs) == x);
+ assert((rhs <= lhs) == y);
+}
+
+int main()
+{
+ {
+ typedef std::experimental::string_view S;
+ test(S(""), "", true, true);
+ test(S(""), "abcde", true, false);
+ test(S(""), "abcdefghij", true, false);
+ test(S(""), "abcdefghijklmnopqrst", true, false);
+ test(S("abcde"), "", false, true);
+ test(S("abcde"), "abcde", true, true);
+ test(S("abcde"), "abcdefghij", true, false);
+ test(S("abcde"), "abcdefghijklmnopqrst", true, false);
+ test(S("abcdefghij"), "", false, true);
+ test(S("abcdefghij"), "abcde", false, true);
+ test(S("abcdefghij"), "abcdefghij", true, true);
+ test(S("abcdefghij"), "abcdefghijklmnopqrst", true, false);
+ test(S("abcdefghijklmnopqrst"), "", false, true);
+ test(S("abcdefghijklmnopqrst"), "abcde", false, true);
+ test(S("abcdefghijklmnopqrst"), "abcdefghij", false, true);
+ test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", true, true);
+ }
+}
diff --git a/test/std/experimental/string.view/string.view.comparison/ople.string_view.string_view.pass.cpp b/test/std/experimental/string.view/string.view.comparison/ople.string_view.string_view.pass.cpp
new file mode 100644
index 000000000000..17219a42602c
--- /dev/null
+++ b/test/std/experimental/string.view/string.view.comparison/ople.string_view.string_view.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits>
+// constexpr bool operator<=(basic_string_view<charT,traits> lhs,
+// basic_string_view<charT,traits> rhs);
+
+#include <experimental/string_view>
+#include <cassert>
+
+#include "constexpr_char_traits.hpp"
+
+template <class S>
+void
+test(const S& lhs, const S& rhs, bool x, bool y)
+{
+ assert((lhs <= rhs) == x);
+ assert((rhs <= lhs) == y);
+}
+
+int main()
+{
+ {
+ typedef std::experimental::string_view S;
+ test(S(""), S(""), true, true);
+ test(S(""), S("abcde"), true, false);
+ test(S(""), S("abcdefghij"), true, false);
+ test(S(""), S("abcdefghijklmnopqrst"), true, false);
+ test(S("abcde"), S(""), false, true);
+ test(S("abcde"), S("abcde"), true, true);
+ test(S("abcde"), S("abcdefghij"), true, false);
+ test(S("abcde"), S("abcdefghijklmnopqrst"), true, false);
+ test(S("abcdefghij"), S(""), false, true);
+ test(S("abcdefghij"), S("abcde"), false, true);
+ test(S("abcdefghij"), S("abcdefghij"), true, true);
+ test(S("abcdefghij"), S("abcdefghijklmnopqrst"), true, false);
+ test(S("abcdefghijklmnopqrst"), S(""), false, true);
+ test(S("abcdefghijklmnopqrst"), S("abcde"), false, true);
+ test(S("abcdefghijklmnopqrst"), S("abcdefghij"), false, true);
+ test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), true, true);
+ }
+
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::experimental::basic_string_view<char, constexpr_char_traits<char>> SV;
+ constexpr SV sv1;
+ constexpr SV sv2 { "abcde", 5 };
+
+ static_assert ( sv1 <= sv1, "" );
+ static_assert ( sv2 <= sv2, "" );
+
+ static_assert ( sv1 <= sv2, "" );
+ static_assert (!(sv2 <= sv1), "" );
+ }
+#endif
+}
diff --git a/test/std/experimental/string.view/string.view.comparison/oplt.string_view.pointer.pass.cpp b/test/std/experimental/string.view/string.view.comparison/oplt.string_view.pointer.pass.cpp
new file mode 100644
index 000000000000..a1013e4d8152
--- /dev/null
+++ b/test/std/experimental/string.view/string.view.comparison/oplt.string_view.pointer.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+// constexpr bool operator<(const charT* lhs, basic_string_wiew<charT,traits> rhs);
+// template<class charT, class traits, class Allocator>
+// constexpr bool operator<(basic_string_wiew<charT,traits> lhs, const charT* rhs);
+
+#include <experimental/string_view>
+#include <cassert>
+
+#include "constexpr_char_traits.hpp"
+
+template <class S>
+void
+test(const typename S::value_type* lhs, const S& rhs, bool x, bool y)
+{
+ assert((lhs < rhs) == x);
+ assert((rhs < lhs) == y);
+}
+
+int main()
+{
+ {
+ typedef std::experimental::string_view S;
+ test("", S(""), false, false);
+ test("", S("abcde"), true, false);
+ test("", S("abcdefghij"), true, false);
+ test("", S("abcdefghijklmnopqrst"), true, false);
+ test("abcde", S(""), false, true);
+ test("abcde", S("abcde"), false, false);
+ test("abcde", S("abcdefghij"), true, false);
+ test("abcde", S("abcdefghijklmnopqrst"), true, false);
+ test("abcdefghij", S(""), false, true);
+ test("abcdefghij", S("abcde"), false, true);
+ test("abcdefghij", S("abcdefghij"), false, false);
+ test("abcdefghij", S("abcdefghijklmnopqrst"), true, false);
+ test("abcdefghijklmnopqrst", S(""), false, true);
+ test("abcdefghijklmnopqrst", S("abcde"), false, true);
+ test("abcdefghijklmnopqrst", S("abcdefghij"), false, true);
+ test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), false, false);
+ }
+
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::experimental::basic_string_view<char, constexpr_char_traits<char>> SV;
+ constexpr SV sv1;
+ constexpr SV sv2 { "abcde", 5 };
+
+ static_assert (!(sv1 < ""), "" );
+ static_assert (!("" < sv1), "" );
+ static_assert ( sv1 < "abcde", "" );
+ static_assert (!("abcde" < sv1), "" );
+
+ static_assert (!(sv2 < ""), "" );
+ static_assert ( "" < sv2, "" );
+ static_assert (!(sv2 < "abcde"), "" );
+ static_assert (!("abcde" < sv2), "" );
+ static_assert ( sv2 < "abcde0", "" );
+ static_assert (!("abcde0" < sv2), "" );
+ }
+#endif
+}
diff --git a/test/std/experimental/string.view/string.view.comparison/oplt.string_view.string.pass.cpp b/test/std/experimental/string.view/string.view.comparison/oplt.string_view.string.pass.cpp
new file mode 100644
index 000000000000..51ea639ba432
--- /dev/null
+++ b/test/std/experimental/string.view/string.view.comparison/oplt.string_view.string.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+// bool operator<(const basic_string<charT,traits,Allocator>& lhs,
+// basic_string_view<charT,traits> rhs);
+// bool operator<(basic_string_view<charT,traits> lhs,
+// const basic_string<charT,traits,Allocator>& rhs);
+
+#include <experimental/string_view>
+#include <cassert>
+
+template <class S>
+void
+test(const S& lhs, const typename S::value_type* rhs, bool x, bool y)
+{
+ assert((lhs < rhs) == x);
+ assert((rhs < lhs) == y);
+}
+
+int main()
+{
+ {
+ typedef std::experimental::string_view S;
+ test(S(""), "", false, false);
+ test(S(""), "abcde", true, false);
+ test(S(""), "abcdefghij", true, false);
+ test(S(""), "abcdefghijklmnopqrst", true, false);
+ test(S("abcde"), "", false, true);
+ test(S("abcde"), "abcde", false, false);
+ test(S("abcde"), "abcdefghij", true, false);
+ test(S("abcde"), "abcdefghijklmnopqrst", true, false);
+ test(S("abcdefghij"), "", false, true);
+ test(S("abcdefghij"), "abcde", false, true);
+ test(S("abcdefghij"), "abcdefghij", false, false);
+ test(S("abcdefghij"), "abcdefghijklmnopqrst", true, false);
+ test(S("abcdefghijklmnopqrst"), "", false, true);
+ test(S("abcdefghijklmnopqrst"), "abcde", false, true);
+ test(S("abcdefghijklmnopqrst"), "abcdefghij", false, true);
+ test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", false, false);
+ }
+}
diff --git a/test/std/experimental/string.view/string.view.comparison/oplt.string_view.string_view.pass.cpp b/test/std/experimental/string.view/string.view.comparison/oplt.string_view.string_view.pass.cpp
new file mode 100644
index 000000000000..df9e90893f7c
--- /dev/null
+++ b/test/std/experimental/string.view/string.view.comparison/oplt.string_view.string_view.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits>
+// constexpr bool operator<(basic_string_view<charT,traits> lhs,
+// basic_string_view<charT,traits> rhs);
+
+#include <experimental/string_view>
+#include <cassert>
+
+#include "constexpr_char_traits.hpp"
+
+template <class S>
+void
+test(const S& lhs, const S& rhs, bool x, bool y)
+{
+ assert((lhs < rhs) == x);
+ assert((rhs < lhs) == y);
+}
+
+int main()
+{
+ {
+ typedef std::experimental::string_view S;
+ test(S(""), S(""), false, false);
+ test(S(""), S("abcde"), true, false);
+ test(S(""), S("abcdefghij"), true, false);
+ test(S(""), S("abcdefghijklmnopqrst"), true, false);
+ test(S("abcde"), S(""), false, true);
+ test(S("abcde"), S("abcde"), false, false);
+ test(S("abcde"), S("abcdefghij"), true, false);
+ test(S("abcde"), S("abcdefghijklmnopqrst"), true, false);
+ test(S("abcdefghij"), S(""), false, true);
+ test(S("abcdefghij"), S("abcde"), false, true);
+ test(S("abcdefghij"), S("abcdefghij"), false, false);
+ test(S("abcdefghij"), S("abcdefghijklmnopqrst"), true, false);
+ test(S("abcdefghijklmnopqrst"), S(""), false, true);
+ test(S("abcdefghijklmnopqrst"), S("abcde"), false, true);
+ test(S("abcdefghijklmnopqrst"), S("abcdefghij"), false, true);
+ test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), false, false);
+ }
+
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::experimental::basic_string_view<char, constexpr_char_traits<char>> SV;
+ constexpr SV sv1;
+ constexpr SV sv2 { "abcde", 5 };
+
+ static_assert (!(sv1 < sv1), "" );
+ static_assert (!(sv2 < sv2), "" );
+
+ static_assert ( sv1 < sv2, "" );
+ static_assert (!(sv2 < sv1), "" );
+ }
+#endif
+}
diff --git a/test/std/experimental/string.view/string.view.comparison/opne.string_view.pointer.pass.cpp b/test/std/experimental/string.view/string.view.comparison/opne.string_view.pointer.pass.cpp
new file mode 100644
index 000000000000..299be934a811
--- /dev/null
+++ b/test/std/experimental/string.view/string.view.comparison/opne.string_view.pointer.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits>
+// constexpr bool operator!=(basic_string_view<charT,traits> lhs, const charT* rhs);
+// template<class charT, class traits>
+// constexpr bool operator!=(const charT* lhs, basic_string_view<charT,traits> rhs);
+
+#include <experimental/string_view>
+#include <cassert>
+
+#include "constexpr_char_traits.hpp"
+
+template <class S>
+void
+test(S lhs, const typename S::value_type* rhs, bool x)
+{
+ assert((lhs != rhs) == x);
+ assert((rhs != lhs) == x);
+}
+
+int main()
+{
+ {
+ typedef std::experimental::string_view S;
+ test(S(""), "", false);
+ test(S(""), "abcde", true);
+ test(S(""), "abcdefghij", true);
+ test(S(""), "abcdefghijklmnopqrst", true);
+ test(S("abcde"), "", true);
+ test(S("abcde"), "abcde", false);
+ test(S("abcde"), "abcdefghij", true);
+ test(S("abcde"), "abcdefghijklmnopqrst", true);
+ test(S("abcdefghij"), "", true);
+ test(S("abcdefghij"), "abcde", true);
+ test(S("abcdefghij"), "abcdefghij", false);
+ test(S("abcdefghij"), "abcdefghijklmnopqrst", true);
+ test(S("abcdefghijklmnopqrst"), "", true);
+ test(S("abcdefghijklmnopqrst"), "abcde", true);
+ test(S("abcdefghijklmnopqrst"), "abcdefghij", true);
+ test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", false);
+ }
+
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::experimental::basic_string_view<char, constexpr_char_traits<char>> SV;
+ constexpr SV sv1;
+ constexpr SV sv2 { "abcde", 5 };
+
+ static_assert (!(sv1 != ""), "" );
+ static_assert (!("" != sv1), "" );
+ static_assert ( sv1 != "abcde", "" );
+ static_assert ( "abcde" != sv1, "" );
+
+ static_assert (!(sv2 != "abcde"), "" );
+ static_assert (!("abcde" != sv2), "" );
+ static_assert ( sv2 != "abcde0", "" );
+ static_assert ( "abcde0" != sv2, "" );
+ }
+#endif
+}
diff --git a/test/std/experimental/string.view/string.view.comparison/opne.string_view.string.pass.cpp b/test/std/experimental/string.view/string.view.comparison/opne.string_view.string.pass.cpp
new file mode 100644
index 000000000000..9ed0ac1d0fda
--- /dev/null
+++ b/test/std/experimental/string.view/string.view.comparison/opne.string_view.string.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+// bool operator!=(const basic_string<charT, traits, Allocator> &lhs, basic_string_view<charT,traits> rhs);
+// template<class charT, class traits, class Allocator>
+// bool operator!=(basic_string_view<charT,traits> lhs, const basic_string<charT, traits, Allocator> &rhs);
+
+#include <experimental/string_view>
+#include <cassert>
+
+template <class S>
+void
+test(const std::string &lhs, S rhs, bool x)
+{
+ assert((lhs != rhs) == x);
+ assert((rhs != lhs) == x);
+}
+
+int main()
+{
+ {
+ typedef std::experimental::string_view S;
+ test("", S(""), false);
+ test("", S("abcde"), true);
+ test("", S("abcdefghij"), true);
+ test("", S("abcdefghijklmnopqrst"), true);
+ test("abcde", S(""), true);
+ test("abcde", S("abcde"), false);
+ test("abcde", S("abcdefghij"), true);
+ test("abcde", S("abcdefghijklmnopqrst"), true);
+ test("abcdefghij", S(""), true);
+ test("abcdefghij", S("abcde"), true);
+ test("abcdefghij", S("abcdefghij"), false);
+ test("abcdefghij", S("abcdefghijklmnopqrst"), true);
+ test("abcdefghijklmnopqrst", S(""), true);
+ test("abcdefghijklmnopqrst", S("abcde"), true);
+ test("abcdefghijklmnopqrst", S("abcdefghij"), true);
+ test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), false);
+ }
+}
diff --git a/test/std/experimental/string.view/string.view.comparison/opne.string_view.string_view.pass.cpp b/test/std/experimental/string.view/string.view.comparison/opne.string_view.string_view.pass.cpp
new file mode 100644
index 000000000000..c99489eb3070
--- /dev/null
+++ b/test/std/experimental/string.view/string.view.comparison/opne.string_view.string_view.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string_view>
+
+// template<class charT, class traits, class Allocator>
+// constexpr bool operator!=(const basic_string_view<charT,traits> lhs,
+// const basic_string_view<charT,traits> rhs);
+
+#include <experimental/string_view>
+#include <cassert>
+
+#include "constexpr_char_traits.hpp"
+
+template <class S>
+void
+test(S lhs, S rhs, bool x)
+{
+ assert((lhs != rhs) == x);
+ assert((rhs != lhs) == x);
+}
+
+int main()
+{
+ {
+ typedef std::experimental::string_view S;
+ test(S(""), S(""), false);
+ test(S(""), S("abcde"), true);
+ test(S(""), S("abcdefghij"), true);
+ test(S(""), S("abcdefghijklmnopqrst"), true);
+ test(S("abcde"), S(""), true);
+ test(S("abcde"), S("abcde"), false);
+ test(S("abcde"), S("abcdefghij"), true);
+ test(S("abcde"), S("abcdefghijklmnopqrst"), true);
+ test(S("abcdefghij"), S(""), true);
+ test(S("abcdefghij"), S("abcde"), true);
+ test(S("abcdefghij"), S("abcdefghij"), false);
+ test(S("abcdefghij"), S("abcdefghijklmnopqrst"), true);
+ test(S("abcdefghijklmnopqrst"), S(""), true);
+ test(S("abcdefghijklmnopqrst"), S("abcde"), true);
+ test(S("abcdefghijklmnopqrst"), S("abcdefghij"), true);
+ test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), false);
+ }
+
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::experimental::basic_string_view<char, constexpr_char_traits<char>> SV;
+ constexpr SV sv1;
+ constexpr SV sv2;
+ constexpr SV sv3 { "abcde", 5 };
+ static_assert (!( sv1 != sv2), "" );
+ static_assert ( sv1 != sv3, "" );
+ }
+#endif
+}
diff --git a/test/std/experimental/string.view/string.view.cons/default.pass.cpp b/test/std/experimental/string.view/string.view.cons/default.pass.cpp
new file mode 100644
index 000000000000..e1d69f4a3dfe
--- /dev/null
+++ b/test/std/experimental/string.view/string.view.cons/default.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+
+// <string_view>
+
+// constexpr basic_string_view () noexcept;
+
+#include <experimental/string_view>
+#include <cassert>
+
+template<typename T>
+void test () {
+#if _LIBCPP_STD_VER > 11
+ {
+ constexpr T sv1;
+ static_assert ( sv1.size() == 0, "" );
+ static_assert ( sv1.empty(), "");
+ }
+#endif
+
+ {
+ T sv1;
+ assert ( sv1.size() == 0 );
+ assert ( sv1.empty());
+ }
+}
+
+int main () {
+ typedef std::experimental::string_view string_view;
+ typedef std::experimental::u16string_view u16string_view;
+ typedef std::experimental::u32string_view u32string_view;
+ typedef std::experimental::wstring_view wstring_view;
+
+ test<string_view> ();
+ test<u16string_view> ();
+ test<u32string_view> ();
+ test<wstring_view> ();
+
+}
diff --git a/test/std/experimental/string.view/string.view.cons/from_literal.pass.cpp b/test/std/experimental/string.view/string.view.cons/from_literal.pass.cpp
new file mode 100644
index 000000000000..82d0d7954149
--- /dev/null
+++ b/test/std/experimental/string.view/string.view.cons/from_literal.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+
+// <string_view>
+
+// constexpr basic_string_view(const _CharT* _s)
+// : __data (_s), __size(_Traits::length(_s)) {}
+
+
+#include <experimental/string_view>
+#include <string>
+#include <cassert>
+
+#include "constexpr_char_traits.hpp"
+
+template<typename CharT>
+size_t StrLen ( const CharT *s ) {
+ size_t retVal = 0;
+ while ( *s != 0 ) { ++retVal; ++s; }
+ return retVal;
+ }
+
+template<typename CharT>
+void test ( const CharT *s ) {
+ std::experimental::basic_string_view<CharT> sv1 ( s );
+ assert ( sv1.size() == StrLen( s ));
+ assert ( sv1.data() == s );
+ }
+
+
+int main () {
+
+ test ( "QBCDE" );
+ test ( "A" );
+ test ( "" );
+
+ test ( L"QBCDE" );
+ test ( L"A" );
+ test ( L"" );
+
+#if __cplusplus >= 201103L
+ test ( u"QBCDE" );
+ test ( u"A" );
+ test ( u"" );
+
+ test ( U"QBCDE" );
+ test ( U"A" );
+ test ( U"" );
+#endif
+
+#if _LIBCPP_STD_VER > 11
+ {
+ constexpr std::experimental::basic_string_view<char, constexpr_char_traits<char>> sv1 ( "ABCDE" );
+ static_assert ( sv1.size() == 5, "");
+ }
+#endif
+}
diff --git a/test/std/experimental/string.view/string.view.cons/from_ptr_len.pass.cpp b/test/std/experimental/string.view/string.view.cons/from_ptr_len.pass.cpp
new file mode 100644
index 000000000000..1038d0484f8c
--- /dev/null
+++ b/test/std/experimental/string.view/string.view.cons/from_ptr_len.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+
+// <string_view>
+
+// constexpr basic_string_view(const _CharT* _s, size_type _len)
+// : __data (_s), __size(_len) {}
+
+
+#include <experimental/string_view>
+#include <string>
+#include <cassert>
+
+template<typename CharT>
+void test ( const CharT *s, size_t sz ) {
+ {
+ std::experimental::basic_string_view<CharT> sv1 ( s, sz );
+ assert ( sv1.size() == sz );
+ assert ( sv1.data() == s );
+ }
+}
+
+int main () {
+
+ test ( "QBCDE", 5 );
+ test ( "QBCDE", 2 );
+ test ( "", 0 );
+#if _LIBCPP_STD_VER > 11
+ {
+ constexpr const char *s = "QBCDE";
+ constexpr std::experimental::basic_string_view<char> sv1 ( s, 2 );
+ static_assert ( sv1.size() == 2, "" );
+ static_assert ( sv1.data() == s, "" );
+ }
+#endif
+
+ test ( L"QBCDE", 5 );
+ test ( L"QBCDE", 2 );
+ test ( L"", 0 );
+#if _LIBCPP_STD_VER > 11
+ {
+ constexpr const wchar_t *s = L"QBCDE";
+ constexpr std::experimental::basic_string_view<wchar_t> sv1 ( s, 2 );
+ static_assert ( sv1.size() == 2, "" );
+ static_assert ( sv1.data() == s, "" );
+ }
+#endif
+
+#if __cplusplus >= 201103L
+ test ( u"QBCDE", 5 );
+ test ( u"QBCDE", 2 );
+ test ( u"", 0 );
+#if _LIBCPP_STD_VER > 11
+ {
+ constexpr const char16_t *s = u"QBCDE";
+ constexpr std::experimental::basic_string_view<char16_t> sv1 ( s, 2 );
+ static_assert ( sv1.size() == 2, "" );
+ static_assert ( sv1.data() == s, "" );
+ }
+#endif
+
+ test ( U"QBCDE", 5 );
+ test ( U"QBCDE", 2 );
+ test ( U"", 0 );
+#if _LIBCPP_STD_VER > 11
+ {
+ constexpr const char32_t *s = U"QBCDE";
+ constexpr std::experimental::basic_string_view<char32_t> sv1 ( s, 2 );
+ static_assert ( sv1.size() == 2, "" );
+ static_assert ( sv1.data() == s, "" );
+ }
+#endif
+#endif
+}
diff --git a/test/std/experimental/string.view/string.view.cons/from_string.pass.cpp b/test/std/experimental/string.view/string.view.cons/from_string.pass.cpp
new file mode 100644
index 000000000000..670c033a653f
--- /dev/null
+++ b/test/std/experimental/string.view/string.view.cons/from_string.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+
+// <string_view>
+
+// template<class Allocator>
+// basic_string_view(const basic_string<_CharT, _Traits, Allocator>& _str) noexcept
+
+
+#include <experimental/string_view>
+#include <string>
+#include <cassert>
+
+struct dummy_char_traits : public std::char_traits<char> {};
+
+template<typename CharT, typename Traits>
+void test ( const std::basic_string<CharT, Traits> &str ) {
+ std::experimental::basic_string_view<CharT, Traits> sv1 ( str );
+ assert ( sv1.size() == str.size());
+ assert ( sv1.data() == str.data());
+}
+
+int main () {
+
+ test ( std::string("QBCDE") );
+ test ( std::string("") );
+ test ( std::string() );
+
+ test ( std::wstring(L"QBCDE") );
+ test ( std::wstring(L"") );
+ test ( std::wstring() );
+
+#if __cplusplus >= 201103L
+ test ( std::u16string{u"QBCDE"} );
+ test ( std::u16string{u""} );
+ test ( std::u16string{} );
+
+ test ( std::u32string{U"QBCDE"} );
+ test ( std::u32string{U""} );
+ test ( std::u32string{} );
+#endif
+
+ test ( std::basic_string<char, dummy_char_traits>("QBCDE") );
+ test ( std::basic_string<char, dummy_char_traits>("") );
+ test ( std::basic_string<char, dummy_char_traits>() );
+
+}
diff --git a/test/std/experimental/string.view/string.view.cons/from_string1.fail.cpp b/test/std/experimental/string.view/string.view.cons/from_string1.fail.cpp
new file mode 100644
index 000000000000..6ef4b9669bf4
--- /dev/null
+++ b/test/std/experimental/string.view/string.view.cons/from_string1.fail.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+
+// <string_view>
+
+// template<class Allocator>
+// basic_string_view(const basic_string<_CharT, _Traits, Allocator>& _str) noexcept
+
+#include <experimental/string_view>
+#include <string>
+#include <cassert>
+
+struct dummy_char_traits : public std::char_traits<char> {};
+
+int main () {
+ using string_view = std::experimental::basic_string_view<char>;
+ using string = std:: basic_string <char, dummy_char_traits>;
+
+ {
+ string s{"QBCDE"};
+ string_view sv1 ( s );
+ assert ( sv1.size() == s.size());
+ assert ( sv1.data() == s.data());
+ }
+} \ No newline at end of file
diff --git a/test/std/experimental/string.view/string.view.cons/from_string2.fail.cpp b/test/std/experimental/string.view/string.view.cons/from_string2.fail.cpp
new file mode 100644
index 000000000000..6c77a3f99a2b
--- /dev/null
+++ b/test/std/experimental/string.view/string.view.cons/from_string2.fail.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+
+// <string_view>
+
+// template<class Allocator>
+// basic_string_view(const basic_string<_CharT, _Traits, Allocator>& _str) noexcept
+
+#include <experimental/string_view>
+#include <string>
+#include <cassert>
+
+struct dummy_char_traits : public std::char_traits<char> {};
+
+int main () {
+ using string_view = std::experimental::basic_string_view<char, dummy_char_traits>;
+ using string = std:: basic_string <char>;
+
+ {
+ string s{"QBCDE"};
+ string_view sv1 ( s );
+ assert ( sv1.size() == s.size());
+ assert ( sv1.data() == s.data());
+ }
+}
diff --git a/test/std/experimental/string.view/string.view.find/find_char_size.pass.cpp b/test/std/experimental/string.view/string.view.find/find_char_size.pass.cpp
new file mode 100644
index 000000000000..6e6a1f55710a
--- /dev/null
+++ b/test/std/experimental/string.view/string.view.find/find_char_size.pass.cpp
@@ -0,0 +1,84 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string_view>
+
+// constexpr size_type find(charT c, size_type pos = 0) const;
+
+#include <experimental/string_view>
+#include <cassert>
+
+#include "constexpr_char_traits.hpp"
+
+template <class S>
+void
+test(const S& s, typename S::value_type c, typename S::size_type pos,
+ typename S::size_type x)
+{
+ assert(s.find(c, pos) == x);
+ if (x != S::npos)
+ assert(pos <= x && x + 1 <= s.size());
+}
+
+template <class S>
+void
+test(const S& s, typename S::value_type c, typename S::size_type x)
+{
+ assert(s.find(c) == x);
+ if (x != S::npos)
+ assert(0 <= x && x + 1 <= s.size());
+}
+
+int main()
+{
+ {
+ typedef std::experimental::string_view S;
+ test(S(""), 'c', 0, S::npos);
+ test(S(""), 'c', 1, S::npos);
+ test(S("abcde"), 'c', 0, 2);
+ test(S("abcde"), 'c', 1, 2);
+ test(S("abcde"), 'c', 2, 2);
+ test(S("abcde"), 'c', 4, S::npos);
+ test(S("abcde"), 'c', 5, S::npos);
+ test(S("abcde"), 'c', 6, S::npos);
+ test(S("abcdeabcde"), 'c', 0, 2);
+ test(S("abcdeabcde"), 'c', 1, 2);
+ test(S("abcdeabcde"), 'c', 5, 7);
+ test(S("abcdeabcde"), 'c', 9, S::npos);
+ test(S("abcdeabcde"), 'c', 10, S::npos);
+ test(S("abcdeabcde"), 'c', 11, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), 'c', 0, 2);
+ test(S("abcdeabcdeabcdeabcde"), 'c', 1, 2);
+ test(S("abcdeabcdeabcdeabcde"), 'c', 10, 12);
+ test(S("abcdeabcdeabcdeabcde"), 'c', 19, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), 'c', 20, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), 'c', 21, S::npos);
+
+ test(S(""), 'c', S::npos);
+ test(S("abcde"), 'c', 2);
+ test(S("abcdeabcde"), 'c', 2);
+ test(S("abcdeabcdeabcdeabcde"), 'c', 2);
+ }
+
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::experimental::basic_string_view<char, constexpr_char_traits<char>> SV;
+ constexpr SV sv1;
+ constexpr SV sv2 { "abcde", 5 };
+
+ static_assert (sv1.find( 'c', 0 ) == SV::npos, "" );
+ static_assert (sv1.find( 'c', 1 ) == SV::npos, "" );
+ static_assert (sv2.find( 'c', 0 ) == 2, "" );
+ static_assert (sv2.find( 'c', 1 ) == 2, "" );
+ static_assert (sv2.find( 'c', 2 ) == 2, "" );
+ static_assert (sv2.find( 'c', 3 ) == SV::npos, "" );
+ static_assert (sv2.find( 'c', 4 ) == SV::npos, "" );
+ }
+#endif
+}
diff --git a/test/std/experimental/string.view/string.view.find/find_first_not_of_char_size.pass.cpp b/test/std/experimental/string.view/string.view.find/find_first_not_of_char_size.pass.cpp
new file mode 100644
index 000000000000..73580aed89ad
--- /dev/null
+++ b/test/std/experimental/string.view/string.view.find/find_first_not_of_char_size.pass.cpp
@@ -0,0 +1,84 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string_view>
+
+// constexpr size_type find_first_not_of(charT c, size_type pos = 0) const;
+
+#include <experimental/string_view>
+#include <cassert>
+
+#include "constexpr_char_traits.hpp"
+
+template <class S>
+void
+test(const S& s, typename S::value_type c, typename S::size_type pos,
+ typename S::size_type x)
+{
+ assert(s.find_first_not_of(c, pos) == x);
+ if (x != S::npos)
+ assert(pos <= x && x < s.size());
+}
+
+template <class S>
+void
+test(const S& s, typename S::value_type c, typename S::size_type x)
+{
+ assert(s.find_first_not_of(c) == x);
+ if (x != S::npos)
+ assert(x < s.size());
+}
+
+int main()
+{
+ {
+ typedef std::experimental::string_view S;
+ test(S(""), 'q', 0, S::npos);
+ test(S(""), 'q', 1, S::npos);
+ test(S("kitcj"), 'q', 0, 0);
+ test(S("qkamf"), 'q', 1, 1);
+ test(S("nhmko"), 'q', 2, 2);
+ test(S("tpsaf"), 'q', 4, 4);
+ test(S("lahfb"), 'q', 5, S::npos);
+ test(S("irkhs"), 'q', 6, S::npos);
+ test(S("gmfhdaipsr"), 'q', 0, 0);
+ test(S("kantesmpgj"), 'q', 1, 1);
+ test(S("odaftiegpm"), 'q', 5, 5);
+ test(S("oknlrstdpi"), 'q', 9, 9);
+ test(S("eolhfgpjqk"), 'q', 10, S::npos);
+ test(S("pcdrofikas"), 'q', 11, S::npos);
+ test(S("nbatdlmekrgcfqsophij"), 'q', 0, 0);
+ test(S("bnrpehidofmqtcksjgla"), 'q', 1, 1);
+ test(S("jdmciepkaqgotsrfnhlb"), 'q', 10, 10);
+ test(S("jtdaefblsokrmhpgcnqi"), 'q', 19, 19);
+ test(S("hkbgspofltajcnedqmri"), 'q', 20, S::npos);
+ test(S("oselktgbcapndfjihrmq"), 'q', 21, S::npos);
+
+ test(S(""), 'q', S::npos);
+ test(S("q"), 'q', S::npos);
+ test(S("qqq"), 'q', S::npos);
+ test(S("csope"), 'q', 0);
+ test(S("gfsmthlkon"), 'q', 0);
+ test(S("laenfsbridchgotmkqpj"), 'q', 0);
+ }
+
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::experimental::basic_string_view<char, constexpr_char_traits<char>> SV;
+ constexpr SV sv1;
+ constexpr SV sv2 { "abcde", 5 };
+
+ static_assert (sv1.find_first_not_of( 'q', 0 ) == SV::npos, "" );
+ static_assert (sv1.find_first_not_of( 'q', 1 ) == SV::npos, "" );
+ static_assert (sv2.find_first_not_of( 'q', 0 ) == 0, "" );
+ static_assert (sv2.find_first_not_of( 'q', 1 ) == 1, "" );
+ static_assert (sv2.find_first_not_of( 'q', 5 ) == SV::npos, "" );
+ }
+#endif
+}
diff --git a/test/std/experimental/string.view/string.view.find/find_first_not_of_pointer_size.pass.cpp b/test/std/experimental/string.view/string.view.find/find_first_not_of_pointer_size.pass.cpp
new file mode 100644
index 000000000000..de93288cc010
--- /dev/null
+++ b/test/std/experimental/string.view/string.view.find/find_first_not_of_pointer_size.pass.cpp
@@ -0,0 +1,165 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string_view>
+
+// constexpr size_type find_first_not_of(const charT* s, size_type pos = 0) const;
+
+#include <experimental/string_view>
+#include <cassert>
+
+#include "constexpr_char_traits.hpp"
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type pos,
+ typename S::size_type x)
+{
+ assert(s.find_first_not_of(str, pos) == x);
+ if (x != S::npos)
+ assert(pos <= x && x < s.size());
+}
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type x)
+{
+ assert(s.find_first_not_of(str) == x);
+ if (x != S::npos)
+ assert(x < s.size());
+}
+
+template <class S>
+void test0()
+{
+ test(S(""), "", 0, S::npos);
+ test(S(""), "laenf", 0, S::npos);
+ test(S(""), "pqlnkmbdjo", 0, S::npos);
+ test(S(""), "qkamfogpnljdcshbreti", 0, S::npos);
+ test(S(""), "", 1, S::npos);
+ test(S(""), "bjaht", 1, S::npos);
+ test(S(""), "hjlcmgpket", 1, S::npos);
+ test(S(""), "htaobedqikfplcgjsmrn", 1, S::npos);
+ test(S("fodgq"), "", 0, 0);
+ test(S("qanej"), "dfkap", 0, 0);
+ test(S("clbao"), "ihqrfebgad", 0, 0);
+ test(S("mekdn"), "ngtjfcalbseiqrphmkdo", 0, S::npos);
+ test(S("srdfq"), "", 1, 1);
+ test(S("oemth"), "ikcrq", 1, 1);
+ test(S("cdaih"), "dmajblfhsg", 1, 3);
+ test(S("qohtk"), "oqftjhdmkgsblacenirp", 1, S::npos);
+ test(S("cshmd"), "", 2, 2);
+ test(S("lhcdo"), "oebqi", 2, 2);
+ test(S("qnsoh"), "kojhpmbsfe", 2, S::npos);
+ test(S("pkrof"), "acbsjqogpltdkhinfrem", 2, S::npos);
+ test(S("fmtsp"), "", 4, 4);
+ test(S("khbpm"), "aobjd", 4, 4);
+ test(S("pbsji"), "pcbahntsje", 4, 4);
+ test(S("mprdj"), "fhepcrntkoagbmldqijs", 4, S::npos);
+ test(S("eqmpa"), "", 5, S::npos);
+ test(S("omigs"), "kocgb", 5, S::npos);
+ test(S("onmje"), "fbslrjiqkm", 5, S::npos);
+ test(S("oqmrj"), "jeidpcmalhfnqbgtrsko", 5, S::npos);
+ test(S("schfa"), "", 6, S::npos);
+ test(S("igdsc"), "qngpd", 6, S::npos);
+ test(S("brqgo"), "rodhqklgmb", 6, S::npos);
+ test(S("tnrph"), "thdjgafrlbkoiqcspmne", 6, S::npos);
+ test(S("hcjitbfapl"), "", 0, 0);
+ test(S("daiprenocl"), "ashjd", 0, 2);
+ test(S("litpcfdghe"), "mgojkldsqh", 0, 1);
+ test(S("aidjksrolc"), "imqnaghkfrdtlopbjesc", 0, S::npos);
+ test(S("qpghtfbaji"), "", 1, 1);
+ test(S("gfshlcmdjr"), "nadkh", 1, 1);
+ test(S("nkodajteqp"), "ofdrqmkebl", 1, 4);
+ test(S("gbmetiprqd"), "bdfjqgatlksriohemnpc", 1, S::npos);
+ test(S("crnklpmegd"), "", 5, 5);
+ test(S("jsbtafedoc"), "prqgn", 5, 5);
+ test(S("qnmodrtkeb"), "pejafmnokr", 5, 6);
+ test(S("cpebqsfmnj"), "odnqkgijrhabfmcestlp", 5, S::npos);
+ test(S("lmofqdhpki"), "", 9, 9);
+ test(S("hnefkqimca"), "rtjpa", 9, S::npos);
+ test(S("drtasbgmfp"), "ktsrmnqagd", 9, 9);
+ test(S("lsaijeqhtr"), "rtdhgcisbnmoaqkfpjle", 9, S::npos);
+ test(S("elgofjmbrq"), "", 10, S::npos);
+ test(S("mjqdgalkpc"), "dplqa", 10, S::npos);
+ test(S("kthqnfcerm"), "dkacjoptns", 10, S::npos);
+ test(S("dfsjhanorc"), "hqfimtrgnbekpdcsjalo", 10, S::npos);
+ test(S("eqsgalomhb"), "", 11, S::npos);
+ test(S("akiteljmoh"), "lofbc", 11, S::npos);
+ test(S("hlbdfreqjo"), "astoegbfpn", 11, S::npos);
+ test(S("taqobhlerg"), "pdgreqomsncafklhtibj", 11, S::npos);
+ test(S("snafbdlghrjkpqtoceim"), "", 0, 0);
+ test(S("aemtbrgcklhndjisfpoq"), "lbtqd", 0, 0);
+ test(S("pnracgfkjdiholtbqsem"), "tboimldpjh", 0, 1);
+ test(S("dicfltehbsgrmojnpkaq"), "slcerthdaiqjfnobgkpm", 0, S::npos);
+ test(S("jlnkraeodhcspfgbqitm"), "", 1, 1);
+ test(S("lhosrngtmfjikbqpcade"), "aqibs", 1, 1);
+ test(S("rbtaqjhgkneisldpmfoc"), "gtfblmqinc", 1, 3);
+ test(S("gpifsqlrdkbonjtmheca"), "mkqpbtdalgniorhfescj", 1, S::npos);
+ test(S("hdpkobnsalmcfijregtq"), "", 10, 10);
+ test(S("jtlshdgqaiprkbcoenfm"), "pblas", 10, 11);
+ test(S("fkdrbqltsgmcoiphneaj"), "arosdhcfme", 10, 13);
+ test(S("crsplifgtqedjohnabmk"), "blkhjeogicatqfnpdmsr", 10, S::npos);
+ test(S("niptglfbosehkamrdqcj"), "", 19, 19);
+ test(S("copqdhstbingamjfkler"), "djkqc", 19, 19);
+ test(S("mrtaefilpdsgocnhqbjk"), "lgokshjtpb", 19, S::npos);
+ test(S("kojatdhlcmigpbfrqnes"), "bqjhtkfepimcnsgrlado", 19, S::npos);
+ test(S("eaintpchlqsbdgrkjofm"), "", 20, S::npos);
+ test(S("gjnhidfsepkrtaqbmclo"), "nocfa", 20, S::npos);
+ test(S("spocfaktqdbiejlhngmr"), "bgtajmiedc", 20, S::npos);
+ test(S("rphmlekgfscndtaobiqj"), "lsckfnqgdahejiopbtmr", 20, S::npos);
+ test(S("liatsqdoegkmfcnbhrpj"), "", 21, S::npos);
+ test(S("binjagtfldkrspcomqeh"), "gfsrt", 21, S::npos);
+ test(S("latkmisecnorjbfhqpdg"), "pfsocbhjtm", 21, S::npos);
+ test(S("lecfratdjkhnsmqpoigb"), "tpflmdnoicjgkberhqsa", 21, S::npos);
+}
+
+template <class S>
+void test1()
+{
+ test(S(""), "", S::npos);
+ test(S(""), "laenf", S::npos);
+ test(S(""), "pqlnkmbdjo", S::npos);
+ test(S(""), "qkamfogpnljdcshbreti", S::npos);
+ test(S("nhmko"), "", 0);
+ test(S("lahfb"), "irkhs", 0);
+ test(S("gmfhd"), "kantesmpgj", 2);
+ test(S("odaft"), "oknlrstdpiqmjbaghcfe", S::npos);
+ test(S("eolhfgpjqk"), "", 0);
+ test(S("nbatdlmekr"), "bnrpe", 2);
+ test(S("jdmciepkaq"), "jtdaefblso", 2);
+ test(S("hkbgspoflt"), "oselktgbcapndfjihrmq", S::npos);
+ test(S("gprdcokbnjhlsfmtieqa"), "", 0);
+ test(S("qjghlnftcaismkropdeb"), "bjaht", 0);
+ test(S("pnalfrdtkqcmojiesbhg"), "hjlcmgpket", 1);
+ test(S("pniotcfrhqsmgdkjbael"), "htaobedqikfplcgjsmrn", S::npos);
+}
+
+int main()
+{
+ {
+ typedef std::experimental::string_view S;
+ test0<S>();
+ test1<S>();
+ }
+
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::experimental::basic_string_view<char, constexpr_char_traits<char>> SV;
+ constexpr SV sv1;
+ constexpr SV sv2 { "abcde", 5 };
+
+ static_assert (sv1.find_first_not_of( "", 0) == SV::npos, "" );
+ static_assert (sv1.find_first_not_of( "irkhs", 0) == SV::npos, "" );
+ static_assert (sv2.find_first_not_of( "", 0) == 0, "" );
+ static_assert (sv2.find_first_not_of( "gfsrt", 0) == 0, "" );
+ static_assert (sv2.find_first_not_of( "lecar", 0) == 1, "" );
+ }
+#endif
+}
diff --git a/test/std/experimental/string.view/string.view.find/find_first_not_of_pointer_size_size.pass.cpp b/test/std/experimental/string.view/string.view.find/find_first_not_of_pointer_size_size.pass.cpp
new file mode 100644
index 000000000000..cfb0029fa180
--- /dev/null
+++ b/test/std/experimental/string.view/string.view.find/find_first_not_of_pointer_size_size.pass.cpp
@@ -0,0 +1,392 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string_view>
+
+// constexpr size_type find_first_not_of(const charT* s, size_type pos, size_type n) const;
+
+#include <experimental/string_view>
+#include <cassert>
+
+#include "constexpr_char_traits.hpp"
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type pos,
+ typename S::size_type n, typename S::size_type x)
+{
+ assert(s.find_first_not_of(str, pos, n) == x);
+ if (x != S::npos)
+ assert(pos <= x && x < s.size());
+}
+
+template <class S>
+void test0()
+{
+ test(S(""), "", 0, 0, S::npos);
+ test(S(""), "irkhs", 0, 0, S::npos);
+ test(S(""), "kante", 0, 1, S::npos);
+ test(S(""), "oknlr", 0, 2, S::npos);
+ test(S(""), "pcdro", 0, 4, S::npos);
+ test(S(""), "bnrpe", 0, 5, S::npos);
+ test(S(""), "jtdaefblso", 0, 0, S::npos);
+ test(S(""), "oselktgbca", 0, 1, S::npos);
+ test(S(""), "eqgaplhckj", 0, 5, S::npos);
+ test(S(""), "bjahtcmnlp", 0, 9, S::npos);
+ test(S(""), "hjlcmgpket", 0, 10, S::npos);
+ test(S(""), "htaobedqikfplcgjsmrn", 0, 0, S::npos);
+ test(S(""), "hpqiarojkcdlsgnmfetb", 0, 1, S::npos);
+ test(S(""), "dfkaprhjloqetcsimnbg", 0, 10, S::npos);
+ test(S(""), "ihqrfebgadntlpmjksoc", 0, 19, S::npos);
+ test(S(""), "ngtjfcalbseiqrphmkdo", 0, 20, S::npos);
+ test(S(""), "", 1, 0, S::npos);
+ test(S(""), "lbtqd", 1, 0, S::npos);
+ test(S(""), "tboim", 1, 1, S::npos);
+ test(S(""), "slcer", 1, 2, S::npos);
+ test(S(""), "cbjfs", 1, 4, S::npos);
+ test(S(""), "aqibs", 1, 5, S::npos);
+ test(S(""), "gtfblmqinc", 1, 0, S::npos);
+ test(S(""), "mkqpbtdalg", 1, 1, S::npos);
+ test(S(""), "kphatlimcd", 1, 5, S::npos);
+ test(S(""), "pblasqogic", 1, 9, S::npos);
+ test(S(""), "arosdhcfme", 1, 10, S::npos);
+ test(S(""), "blkhjeogicatqfnpdmsr", 1, 0, S::npos);
+ test(S(""), "bmhineprjcoadgstflqk", 1, 1, S::npos);
+ test(S(""), "djkqcmetslnghpbarfoi", 1, 10, S::npos);
+ test(S(""), "lgokshjtpbemarcdqnfi", 1, 19, S::npos);
+ test(S(""), "bqjhtkfepimcnsgrlado", 1, 20, S::npos);
+ test(S("eaint"), "", 0, 0, 0);
+ test(S("binja"), "gfsrt", 0, 0, 0);
+ test(S("latkm"), "pfsoc", 0, 1, 0);
+ test(S("lecfr"), "tpflm", 0, 2, 0);
+ test(S("eqkst"), "sgkec", 0, 4, 1);
+ test(S("cdafr"), "romds", 0, 5, 0);
+ test(S("prbhe"), "qhjistlgmr", 0, 0, 0);
+ test(S("lbisk"), "pedfirsglo", 0, 1, 0);
+ test(S("hrlpd"), "aqcoslgrmk", 0, 5, 0);
+ test(S("ehmja"), "dabckmepqj", 0, 9, 1);
+ test(S("mhqgd"), "pqscrjthli", 0, 10, 0);
+ test(S("tgklq"), "kfphdcsjqmobliagtren", 0, 0, 0);
+ test(S("bocjs"), "rokpefncljibsdhqtagm", 0, 1, 0);
+ test(S("grbsd"), "afionmkphlebtcjqsgrd", 0, 10, 0);
+ test(S("ofjqr"), "aenmqplidhkofrjbctsg", 0, 19, S::npos);
+ test(S("btlfi"), "osjmbtcadhiklegrpqnf", 0, 20, S::npos);
+ test(S("clrgb"), "", 1, 0, 1);
+ test(S("tjmek"), "osmia", 1, 0, 1);
+ test(S("bgstp"), "ckonl", 1, 1, 1);
+ test(S("hstrk"), "ilcaj", 1, 2, 1);
+ test(S("kmspj"), "lasiq", 1, 4, 1);
+ test(S("tjboh"), "kfqmr", 1, 5, 1);
+ test(S("ilbcj"), "klnitfaobg", 1, 0, 1);
+ test(S("jkngf"), "gjhmdlqikp", 1, 1, 1);
+ test(S("gfcql"), "skbgtahqej", 1, 5, 1);
+ test(S("dqtlg"), "bjsdgtlpkf", 1, 9, 1);
+ test(S("bthpg"), "bjgfmnlkio", 1, 10, 1);
+ test(S("dgsnq"), "lbhepotfsjdqigcnamkr", 1, 0, 1);
+ test(S("rmfhp"), "tebangckmpsrqdlfojhi", 1, 1, 1);
+ test(S("jfdam"), "joflqbdkhtegimscpanr", 1, 10, 3);
+ test(S("edapb"), "adpmcohetfbsrjinlqkg", 1, 19, S::npos);
+ test(S("brfsm"), "iacldqjpfnogbsrhmetk", 1, 20, S::npos);
+ test(S("ndrhl"), "", 2, 0, 2);
+ test(S("mrecp"), "otkgb", 2, 0, 2);
+ test(S("qlasf"), "cqsjl", 2, 1, 2);
+ test(S("smaqd"), "dpifl", 2, 2, 2);
+ test(S("hjeni"), "oapht", 2, 4, 2);
+ test(S("ocmfj"), "cifts", 2, 5, 2);
+ test(S("hmftq"), "nmsckbgalo", 2, 0, 2);
+ test(S("fklad"), "tpksqhamle", 2, 1, 2);
+ test(S("dirnm"), "tpdrchmkji", 2, 5, 3);
+ test(S("hrgdc"), "ijagfkblst", 2, 9, 3);
+ test(S("ifakg"), "kpocsignjb", 2, 10, 2);
+ test(S("ebrgd"), "pecqtkjsnbdrialgmohf", 2, 0, 2);
+ test(S("rcjml"), "aiortphfcmkjebgsndql", 2, 1, 2);
+ test(S("peqmt"), "sdbkeamglhipojqftrcn", 2, 10, 2);
+ test(S("frehn"), "ljqncehgmfktroapidbs", 2, 19, S::npos);
+ test(S("tqolf"), "rtcfodilamkbenjghqps", 2, 20, S::npos);
+ test(S("cjgao"), "", 4, 0, 4);
+ test(S("kjplq"), "mabns", 4, 0, 4);
+ test(S("herni"), "bdnrp", 4, 1, 4);
+ test(S("tadrb"), "scidp", 4, 2, 4);
+ test(S("pkfeo"), "agbjl", 4, 4, 4);
+ test(S("hoser"), "jfmpr", 4, 5, S::npos);
+ test(S("kgrsp"), "rbpefghsmj", 4, 0, 4);
+ test(S("pgejb"), "apsfntdoqc", 4, 1, 4);
+ test(S("thlnq"), "ndkjeisgcl", 4, 5, 4);
+ test(S("nbmit"), "rnfpqatdeo", 4, 9, S::npos);
+ test(S("jgmib"), "bntjlqrfik", 4, 10, S::npos);
+ test(S("ncrfj"), "kcrtmpolnaqejghsfdbi", 4, 0, 4);
+ test(S("ncsik"), "lobheanpkmqidsrtcfgj", 4, 1, 4);
+ test(S("sgbfh"), "athdkljcnreqbgpmisof", 4, 10, S::npos);
+ test(S("dktbn"), "qkdmjialrscpbhefgont", 4, 19, S::npos);
+ test(S("fthqm"), "dmasojntqleribkgfchp", 4, 20, S::npos);
+ test(S("klopi"), "", 5, 0, S::npos);
+ test(S("dajhn"), "psthd", 5, 0, S::npos);
+ test(S("jbgno"), "rpmjd", 5, 1, S::npos);
+ test(S("hkjae"), "dfsmk", 5, 2, S::npos);
+}
+
+template <class S>
+void test1()
+{
+ test(S("gbhqo"), "skqne", 5, 4, S::npos);
+ test(S("ktdor"), "kipnf", 5, 5, S::npos);
+ test(S("ldprn"), "hmrnqdgifl", 5, 0, S::npos);
+ test(S("egmjk"), "fsmjcdairn", 5, 1, S::npos);
+ test(S("armql"), "pcdgltbrfj", 5, 5, S::npos);
+ test(S("cdhjo"), "aekfctpirg", 5, 9, S::npos);
+ test(S("jcons"), "ledihrsgpf", 5, 10, S::npos);
+ test(S("cbrkp"), "mqcklahsbtirgopefndj", 5, 0, S::npos);
+ test(S("fhgna"), "kmlthaoqgecrnpdbjfis", 5, 1, S::npos);
+ test(S("ejfcd"), "sfhbamcdptojlkrenqgi", 5, 10, S::npos);
+ test(S("kqjhe"), "pbniofmcedrkhlstgaqj", 5, 19, S::npos);
+ test(S("pbdjl"), "mongjratcskbhqiepfdl", 5, 20, S::npos);
+ test(S("gajqn"), "", 6, 0, S::npos);
+ test(S("stedk"), "hrnat", 6, 0, S::npos);
+ test(S("tjkaf"), "gsqdt", 6, 1, S::npos);
+ test(S("dthpe"), "bspkd", 6, 2, S::npos);
+ test(S("klhde"), "ohcmb", 6, 4, S::npos);
+ test(S("bhlki"), "heatr", 6, 5, S::npos);
+ test(S("lqmoh"), "pmblckedfn", 6, 0, S::npos);
+ test(S("mtqin"), "aceqmsrbik", 6, 1, S::npos);
+ test(S("dpqbr"), "lmbtdehjrn", 6, 5, S::npos);
+ test(S("kdhmo"), "teqmcrlgib", 6, 9, S::npos);
+ test(S("jblqp"), "njolbmspac", 6, 10, S::npos);
+ test(S("qmjgl"), "pofnhidklamecrbqjgst", 6, 0, S::npos);
+ test(S("rothp"), "jbhckmtgrqnosafedpli", 6, 1, S::npos);
+ test(S("ghknq"), "dobntpmqklicsahgjerf", 6, 10, S::npos);
+ test(S("eopfi"), "tpdshainjkbfoemlrgcq", 6, 19, S::npos);
+ test(S("dsnmg"), "oldpfgeakrnitscbjmqh", 6, 20, S::npos);
+ test(S("jnkrfhotgl"), "", 0, 0, 0);
+ test(S("dltjfngbko"), "rqegt", 0, 0, 0);
+ test(S("bmjlpkiqde"), "dashm", 0, 1, 0);
+ test(S("skrflobnqm"), "jqirk", 0, 2, 0);
+ test(S("jkpldtshrm"), "rckeg", 0, 4, 0);
+ test(S("ghasdbnjqo"), "jscie", 0, 5, 0);
+ test(S("igrkhpbqjt"), "efsphndliq", 0, 0, 0);
+ test(S("ikthdgcamf"), "gdicosleja", 0, 1, 0);
+ test(S("pcofgeniam"), "qcpjibosfl", 0, 5, 2);
+ test(S("rlfjgesqhc"), "lrhmefnjcq", 0, 9, 4);
+ test(S("itphbqsker"), "dtablcrseo", 0, 10, 0);
+ test(S("skjafcirqm"), "apckjsftedbhgomrnilq", 0, 0, 0);
+ test(S("tcqomarsfd"), "pcbrgflehjtiadnsokqm", 0, 1, 0);
+ test(S("rocfeldqpk"), "nsiadegjklhobrmtqcpf", 0, 10, 0);
+ test(S("cfpegndlkt"), "cpmajdqnolikhgsbretf", 0, 19, 1);
+ test(S("fqbtnkeasj"), "jcflkntmgiqrphdosaeb", 0, 20, S::npos);
+ test(S("shbcqnmoar"), "", 1, 0, 1);
+ test(S("bdoshlmfin"), "ontrs", 1, 0, 1);
+ test(S("khfrebnsgq"), "pfkna", 1, 1, 1);
+ test(S("getcrsaoji"), "ekosa", 1, 2, 2);
+ test(S("fjiknedcpq"), "anqhk", 1, 4, 1);
+ test(S("tkejgnafrm"), "jekca", 1, 5, 4);
+ test(S("jnakolqrde"), "ikemsjgacf", 1, 0, 1);
+ test(S("lcjptsmgbe"), "arolgsjkhm", 1, 1, 1);
+ test(S("itfsmcjorl"), "oftkbldhre", 1, 5, 3);
+ test(S("omchkfrjea"), "gbkqdoeftl", 1, 9, 1);
+ test(S("cigfqkated"), "sqcflrgtim", 1, 10, 5);
+ test(S("tscenjikml"), "fmhbkislrjdpanogqcet", 1, 0, 1);
+ test(S("qcpaemsinf"), "rnioadktqlgpbcjsmhef", 1, 1, 1);
+ test(S("gltkojeipd"), "oakgtnldpsefihqmjcbr", 1, 10, 5);
+ test(S("qistfrgnmp"), "gbnaelosidmcjqktfhpr", 1, 19, 5);
+ test(S("bdnpfcqaem"), "akbripjhlosndcmqgfet", 1, 20, S::npos);
+ test(S("ectnhskflp"), "", 5, 0, 5);
+ test(S("fgtianblpq"), "pijag", 5, 0, 5);
+ test(S("mfeqklirnh"), "jrckd", 5, 1, 5);
+ test(S("astedncjhk"), "qcloh", 5, 2, 5);
+ test(S("fhlqgcajbr"), "thlmp", 5, 4, 5);
+ test(S("epfhocmdng"), "qidmo", 5, 5, 5);
+ test(S("apcnsibger"), "lnegpsjqrd", 5, 0, 5);
+ test(S("aqkocrbign"), "rjqdablmfs", 5, 1, 6);
+ test(S("ijsmdtqgce"), "enkgpbsjaq", 5, 5, 5);
+ test(S("clobgsrken"), "kdsgoaijfh", 5, 9, 6);
+ test(S("jbhcfposld"), "trfqgmckbe", 5, 10, 5);
+ test(S("oqnpblhide"), "igetsracjfkdnpoblhqm", 5, 0, 5);
+ test(S("lroeasctif"), "nqctfaogirshlekbdjpm", 5, 1, 5);
+ test(S("bpjlgmiedh"), "csehfgomljdqinbartkp", 5, 10, 6);
+ test(S("pamkeoidrj"), "qahoegcmplkfsjbdnitr", 5, 19, 8);
+ test(S("espogqbthk"), "dpteiajrqmsognhlfbkc", 5, 20, S::npos);
+ test(S("shoiedtcjb"), "", 9, 0, 9);
+ test(S("ebcinjgads"), "tqbnh", 9, 0, 9);
+ test(S("dqmregkcfl"), "akmle", 9, 1, 9);
+ test(S("ngcrieqajf"), "iqfkm", 9, 2, 9);
+ test(S("qosmilgnjb"), "tqjsr", 9, 4, 9);
+ test(S("ikabsjtdfl"), "jplqg", 9, 5, S::npos);
+ test(S("ersmicafdh"), "oilnrbcgtj", 9, 0, 9);
+ test(S("fdnplotmgh"), "morkglpesn", 9, 1, 9);
+ test(S("fdbicojerm"), "dmicerngat", 9, 5, S::npos);
+ test(S("mbtafndjcq"), "radgeskbtc", 9, 9, 9);
+ test(S("mlenkpfdtc"), "ljikprsmqo", 9, 10, 9);
+ test(S("ahlcifdqgs"), "trqihkcgsjamfdbolnpe", 9, 0, 9);
+ test(S("bgjemaltks"), "lqmthbsrekajgnofcipd", 9, 1, 9);
+ test(S("pdhslbqrfc"), "jtalmedribkgqsopcnfh", 9, 10, 9);
+ test(S("dirhtsnjkc"), "spqfoiclmtagejbndkrh", 9, 19, S::npos);
+ test(S("dlroktbcja"), "nmotklspigjrdhcfaebq", 9, 20, S::npos);
+ test(S("ncjpmaekbs"), "", 10, 0, S::npos);
+ test(S("hlbosgmrak"), "hpmsd", 10, 0, S::npos);
+ test(S("pqfhsgilen"), "qnpor", 10, 1, S::npos);
+ test(S("gqtjsbdckh"), "otdma", 10, 2, S::npos);
+ test(S("cfkqpjlegi"), "efhjg", 10, 4, S::npos);
+ test(S("beanrfodgj"), "odpte", 10, 5, S::npos);
+ test(S("adtkqpbjfi"), "bctdgfmolr", 10, 0, S::npos);
+ test(S("iomkfthagj"), "oaklidrbqg", 10, 1, S::npos);
+}
+
+template <class S>
+void test2()
+{
+ test(S("sdpcilonqj"), "dnjfsagktr", 10, 5, S::npos);
+ test(S("gtfbdkqeml"), "nejaktmiqg", 10, 9, S::npos);
+ test(S("bmeqgcdorj"), "pjqonlebsf", 10, 10, S::npos);
+ test(S("etqlcanmob"), "dshmnbtolcjepgaikfqr", 10, 0, S::npos);
+ test(S("roqmkbdtia"), "iogfhpabtjkqlrnemcds", 10, 1, S::npos);
+ test(S("kadsithljf"), "ngridfabjsecpqltkmoh", 10, 10, S::npos);
+ test(S("sgtkpbfdmh"), "athmknplcgofrqejsdib", 10, 19, S::npos);
+ test(S("qgmetnabkl"), "ldobhmqcafnjtkeisgrp", 10, 20, S::npos);
+ test(S("cqjohampgd"), "", 11, 0, S::npos);
+ test(S("hobitmpsan"), "aocjb", 11, 0, S::npos);
+ test(S("tjehkpsalm"), "jbrnk", 11, 1, S::npos);
+ test(S("ngfbojitcl"), "tqedg", 11, 2, S::npos);
+ test(S("rcfkdbhgjo"), "nqskp", 11, 4, S::npos);
+ test(S("qghptonrea"), "eaqkl", 11, 5, S::npos);
+ test(S("hnprfgqjdl"), "reaoicljqm", 11, 0, S::npos);
+ test(S("hlmgabenti"), "lsftgajqpm", 11, 1, S::npos);
+ test(S("ofcjanmrbs"), "rlpfogmits", 11, 5, S::npos);
+ test(S("jqedtkornm"), "shkncmiaqj", 11, 9, S::npos);
+ test(S("rfedlasjmg"), "fpnatrhqgs", 11, 10, S::npos);
+ test(S("talpqjsgkm"), "sjclemqhnpdbgikarfot", 11, 0, S::npos);
+ test(S("lrkcbtqpie"), "otcmedjikgsfnqbrhpla", 11, 1, S::npos);
+ test(S("cipogdskjf"), "bonsaefdqiprkhlgtjcm", 11, 10, S::npos);
+ test(S("nqedcojahi"), "egpscmahijlfnkrodqtb", 11, 19, S::npos);
+ test(S("hefnrkmctj"), "kmqbfepjthgilscrndoa", 11, 20, S::npos);
+ test(S("atqirnmekfjolhpdsgcb"), "", 0, 0, 0);
+ test(S("echfkmlpribjnqsaogtd"), "prboq", 0, 0, 0);
+ test(S("qnhiftdgcleajbpkrosm"), "fjcqh", 0, 1, 0);
+ test(S("chamfknorbedjitgslpq"), "fmosa", 0, 2, 0);
+ test(S("njhqpibfmtlkaecdrgso"), "qdbok", 0, 4, 0);
+ test(S("ebnghfsqkprmdcljoiat"), "amslg", 0, 5, 0);
+ test(S("letjomsgihfrpqbkancd"), "smpltjneqb", 0, 0, 0);
+ test(S("nblgoipcrqeaktshjdmf"), "flitskrnge", 0, 1, 0);
+ test(S("cehkbngtjoiflqapsmrd"), "pgqihmlbef", 0, 5, 0);
+ test(S("mignapfoklbhcqjetdrs"), "cfpdqjtgsb", 0, 9, 0);
+ test(S("ceatbhlsqjgpnokfrmdi"), "htpsiaflom", 0, 10, 0);
+ test(S("ocihkjgrdelpfnmastqb"), "kpjfiaceghsrdtlbnomq", 0, 0, 0);
+ test(S("noelgschdtbrjfmiqkap"), "qhtbomidljgafneksprc", 0, 1, 0);
+ test(S("dkclqfombepritjnghas"), "nhtjobkcefldimpsaqgr", 0, 10, 0);
+ test(S("miklnresdgbhqcojftap"), "prabcjfqnoeskilmtgdh", 0, 19, 11);
+ test(S("htbcigojaqmdkfrnlsep"), "dtrgmchilkasqoebfpjn", 0, 20, S::npos);
+ test(S("febhmqtjanokscdirpgl"), "", 1, 0, 1);
+ test(S("loakbsqjpcrdhftniegm"), "sqome", 1, 0, 1);
+ test(S("reagphsqflbitdcjmkno"), "smfte", 1, 1, 1);
+ test(S("jitlfrqemsdhkopncabg"), "ciboh", 1, 2, 2);
+ test(S("mhtaepscdnrjqgbkifol"), "haois", 1, 4, 2);
+ test(S("tocesrfmnglpbjihqadk"), "abfki", 1, 5, 1);
+ test(S("lpfmctjrhdagneskbqoi"), "frdkocntmq", 1, 0, 1);
+ test(S("lsmqaepkdhncirbtjfgo"), "oasbpedlnr", 1, 1, 1);
+ test(S("epoiqmtldrabnkjhcfsg"), "kltqmhgand", 1, 5, 1);
+ test(S("emgasrilpknqojhtbdcf"), "gdtfjchpmr", 1, 9, 3);
+ test(S("hnfiagdpcklrjetqbsom"), "ponmcqblet", 1, 10, 2);
+ test(S("nsdfebgajhmtricpoklq"), "sgphqdnofeiklatbcmjr", 1, 0, 1);
+ test(S("atjgfsdlpobmeiqhncrk"), "ljqprsmigtfoneadckbh", 1, 1, 1);
+ test(S("sitodfgnrejlahcbmqkp"), "ligeojhafnkmrcsqtbdp", 1, 10, 2);
+ test(S("fraghmbiceknltjpqosd"), "lsimqfnjarbopedkhcgt", 1, 19, 13);
+ test(S("pmafenlhqtdbkirjsogc"), "abedmfjlghniorcqptks", 1, 20, S::npos);
+ test(S("pihgmoeqtnakrjslcbfd"), "", 10, 0, 10);
+ test(S("gjdkeprctqblnhiafsom"), "hqtoa", 10, 0, 10);
+ test(S("mkpnblfdsahrcqijteog"), "cahif", 10, 1, 10);
+ test(S("gckarqnelodfjhmbptis"), "kehis", 10, 2, 10);
+ test(S("gqpskidtbclomahnrjfe"), "kdlmh", 10, 4, 11);
+ test(S("pkldjsqrfgitbhmaecno"), "paeql", 10, 5, 10);
+ test(S("aftsijrbeklnmcdqhgop"), "aghoqiefnb", 10, 0, 10);
+ test(S("mtlgdrhafjkbiepqnsoc"), "jrbqaikpdo", 10, 1, 10);
+ test(S("pqgirnaefthokdmbsclj"), "smjonaeqcl", 10, 5, 10);
+ test(S("kpdbgjmtherlsfcqoina"), "eqbdrkcfah", 10, 9, 11);
+ test(S("jrlbothiknqmdgcfasep"), "kapmsienhf", 10, 10, 10);
+ test(S("mjogldqferckabinptsh"), "jpqotrlenfcsbhkaimdg", 10, 0, 10);
+ test(S("apoklnefbhmgqcdrisjt"), "jlbmhnfgtcqprikeados", 10, 1, 10);
+ test(S("ifeopcnrjbhkdgatmqls"), "stgbhfmdaljnpqoicker", 10, 10, 11);
+ test(S("ckqhaiesmjdnrgolbtpf"), "oihcetflbjagdsrkmqpn", 10, 19, 11);
+ test(S("bnlgapfimcoterskqdjh"), "adtclebmnpjsrqfkigoh", 10, 20, S::npos);
+ test(S("kgdlrobpmjcthqsafeni"), "", 19, 0, 19);
+ test(S("dfkechomjapgnslbtqir"), "beafg", 19, 0, 19);
+ test(S("rloadknfbqtgmhcsipje"), "iclat", 19, 1, 19);
+ test(S("mgjhkolrnadqbpetcifs"), "rkhnf", 19, 2, 19);
+ test(S("cmlfakiojdrgtbsphqen"), "clshq", 19, 4, 19);
+ test(S("kghbfipeomsntdalrqjc"), "dtcoj", 19, 5, S::npos);
+ test(S("eldiqckrnmtasbghjfpo"), "rqosnjmfth", 19, 0, 19);
+ test(S("abqjcfedgotihlnspkrm"), "siatdfqglh", 19, 1, 19);
+ test(S("qfbadrtjsimkolcenhpg"), "mrlshtpgjq", 19, 5, 19);
+ test(S("abseghclkjqifmtodrnp"), "adlcskgqjt", 19, 9, 19);
+ test(S("ibmsnlrjefhtdokacqpg"), "drshcjknaf", 19, 10, 19);
+ test(S("mrkfciqjebaponsthldg"), "etsaqroinghpkjdlfcbm", 19, 0, 19);
+ test(S("mjkticdeoqshpalrfbgn"), "sgepdnkqliambtrocfhj", 19, 1, 19);
+ test(S("rqnoclbdejgiphtfsakm"), "nlmcjaqgbsortfdihkpe", 19, 10, S::npos);
+ test(S("plkqbhmtfaeodjcrsing"), "racfnpmosldibqkghjet", 19, 19, S::npos);
+ test(S("oegalhmstjrfickpbndq"), "fjhdsctkqeiolagrnmbp", 19, 20, S::npos);
+ test(S("rdtgjcaohpblniekmsfq"), "", 20, 0, S::npos);
+ test(S("ofkqbnjetrmsaidphglc"), "ejanp", 20, 0, S::npos);
+ test(S("grkpahljcftesdmonqib"), "odife", 20, 1, S::npos);
+ test(S("jimlgbhfqkteospardcn"), "okaqd", 20, 2, S::npos);
+ test(S("gftenihpmslrjkqadcob"), "lcdbi", 20, 4, S::npos);
+ test(S("bmhldogtckrfsanijepq"), "fsqbj", 20, 5, S::npos);
+ test(S("nfqkrpjdesabgtlcmoih"), "bigdomnplq", 20, 0, S::npos);
+ test(S("focalnrpiqmdkstehbjg"), "apiblotgcd", 20, 1, S::npos);
+ test(S("rhqdspkmebiflcotnjga"), "acfhdenops", 20, 5, S::npos);
+ test(S("rahdtmsckfboqlpniegj"), "jopdeamcrk", 20, 9, S::npos);
+ test(S("fbkeiopclstmdqranjhg"), "trqncbkgmh", 20, 10, S::npos);
+ test(S("lifhpdgmbconstjeqark"), "tomglrkencbsfjqpihda", 20, 0, S::npos);
+}
+
+template <class S>
+void test3()
+{
+ test(S("pboqganrhedjmltsicfk"), "gbkhdnpoietfcmrslajq", 20, 1, S::npos);
+ test(S("klchabsimetjnqgorfpd"), "rtfnmbsglkjaichoqedp", 20, 10, S::npos);
+ test(S("sirfgmjqhctndbklaepo"), "ohkmdpfqbsacrtjnlgei", 20, 19, S::npos);
+ test(S("rlbdsiceaonqjtfpghkm"), "dlbrteoisgphmkncajfq", 20, 20, S::npos);
+ test(S("ecgdanriptblhjfqskom"), "", 21, 0, S::npos);
+ test(S("fdmiarlpgcskbhoteqjn"), "sjrlo", 21, 0, S::npos);
+ test(S("rlbstjqopignecmfadkh"), "qjpor", 21, 1, S::npos);
+ test(S("grjpqmbshektdolcafni"), "odhfn", 21, 2, S::npos);
+ test(S("sakfcohtqnibprjmlged"), "qtfin", 21, 4, S::npos);
+ test(S("mjtdglasihqpocebrfkn"), "hpqfo", 21, 5, S::npos);
+ test(S("okaplfrntghqbmeicsdj"), "fabmertkos", 21, 0, S::npos);
+ test(S("sahngemrtcjidqbklfpo"), "brqtgkmaej", 21, 1, S::npos);
+ test(S("dlmsipcnekhbgoaftqjr"), "nfrdeihsgl", 21, 5, S::npos);
+ test(S("ahegrmqnoiklpfsdbcjt"), "hlfrosekpi", 21, 9, S::npos);
+ test(S("hdsjbnmlegtkqripacof"), "atgbkrjdsm", 21, 10, S::npos);
+ test(S("pcnedrfjihqbalkgtoms"), "blnrptjgqmaifsdkhoec", 21, 0, S::npos);
+ test(S("qjidealmtpskrbfhocng"), "ctpmdahebfqjgknloris", 21, 1, S::npos);
+ test(S("qeindtagmokpfhsclrbj"), "apnkeqthrmlbfodiscgj", 21, 10, S::npos);
+ test(S("kpfegbjhsrnodltqciam"), "jdgictpframeoqlsbknh", 21, 19, S::npos);
+ test(S("hnbrcplsjfgiktoedmaq"), "qprlsfojamgndekthibc", 21, 20, S::npos);
+}
+
+int main()
+{
+ {
+ typedef std::experimental::string_view S;
+ test0<S>();
+ test1<S>();
+ test2<S>();
+ test3<S>();
+ }
+
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::experimental::basic_string_view<char, constexpr_char_traits<char>> SV;
+ constexpr SV sv1;
+ constexpr SV sv2 { "abcde", 5 };
+
+ static_assert (sv1.find_first_not_of( "", 0, 0) == SV::npos, "" );
+ static_assert (sv1.find_first_not_of( "irkhs", 0, 5) == SV::npos, "" );
+ static_assert (sv2.find_first_not_of( "", 0, 0) == 0, "" );
+ static_assert (sv2.find_first_not_of( "gfsrt", 0, 5) == 0, "" );
+ static_assert (sv2.find_first_not_of( "lecar", 0, 5) == 1, "" );
+ }
+#endif
+}
diff --git a/test/std/experimental/string.view/string.view.find/find_first_not_of_string_view_size.pass.cpp b/test/std/experimental/string.view/string.view.find/find_first_not_of_string_view_size.pass.cpp
new file mode 100644
index 000000000000..700231294092
--- /dev/null
+++ b/test/std/experimental/string.view/string.view.find/find_first_not_of_string_view_size.pass.cpp
@@ -0,0 +1,148 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string_view>
+
+// size_type find_first_not_of(const basic_string& str, size_type pos = 0) const;
+
+#include <experimental/string_view>
+#include <cassert>
+
+template <class S>
+void
+test(const S& s, const S& str, typename S::size_type pos, typename S::size_type x)
+{
+ assert(s.find_first_not_of(str, pos) == x);
+ if (x != S::npos)
+ assert(pos <= x && x < s.size());
+}
+
+template <class S>
+void
+test(const S& s, const S& str, typename S::size_type x)
+{
+ assert(s.find_first_not_of(str) == x);
+ if (x != S::npos)
+ assert(x < s.size());
+}
+
+template <class S>
+void test0()
+{
+ test(S(""), S(""), 0, S::npos);
+ test(S(""), S("laenf"), 0, S::npos);
+ test(S(""), S("pqlnkmbdjo"), 0, S::npos);
+ test(S(""), S("qkamfogpnljdcshbreti"), 0, S::npos);
+ test(S(""), S(""), 1, S::npos);
+ test(S(""), S("bjaht"), 1, S::npos);
+ test(S(""), S("hjlcmgpket"), 1, S::npos);
+ test(S(""), S("htaobedqikfplcgjsmrn"), 1, S::npos);
+ test(S("fodgq"), S(""), 0, 0);
+ test(S("qanej"), S("dfkap"), 0, 0);
+ test(S("clbao"), S("ihqrfebgad"), 0, 0);
+ test(S("mekdn"), S("ngtjfcalbseiqrphmkdo"), 0, S::npos);
+ test(S("srdfq"), S(""), 1, 1);
+ test(S("oemth"), S("ikcrq"), 1, 1);
+ test(S("cdaih"), S("dmajblfhsg"), 1, 3);
+ test(S("qohtk"), S("oqftjhdmkgsblacenirp"), 1, S::npos);
+ test(S("cshmd"), S(""), 2, 2);
+ test(S("lhcdo"), S("oebqi"), 2, 2);
+ test(S("qnsoh"), S("kojhpmbsfe"), 2, S::npos);
+ test(S("pkrof"), S("acbsjqogpltdkhinfrem"), 2, S::npos);
+ test(S("fmtsp"), S(""), 4, 4);
+ test(S("khbpm"), S("aobjd"), 4, 4);
+ test(S("pbsji"), S("pcbahntsje"), 4, 4);
+ test(S("mprdj"), S("fhepcrntkoagbmldqijs"), 4, S::npos);
+ test(S("eqmpa"), S(""), 5, S::npos);
+ test(S("omigs"), S("kocgb"), 5, S::npos);
+ test(S("onmje"), S("fbslrjiqkm"), 5, S::npos);
+ test(S("oqmrj"), S("jeidpcmalhfnqbgtrsko"), 5, S::npos);
+ test(S("schfa"), S(""), 6, S::npos);
+ test(S("igdsc"), S("qngpd"), 6, S::npos);
+ test(S("brqgo"), S("rodhqklgmb"), 6, S::npos);
+ test(S("tnrph"), S("thdjgafrlbkoiqcspmne"), 6, S::npos);
+ test(S("hcjitbfapl"), S(""), 0, 0);
+ test(S("daiprenocl"), S("ashjd"), 0, 2);
+ test(S("litpcfdghe"), S("mgojkldsqh"), 0, 1);
+ test(S("aidjksrolc"), S("imqnaghkfrdtlopbjesc"), 0, S::npos);
+ test(S("qpghtfbaji"), S(""), 1, 1);
+ test(S("gfshlcmdjr"), S("nadkh"), 1, 1);
+ test(S("nkodajteqp"), S("ofdrqmkebl"), 1, 4);
+ test(S("gbmetiprqd"), S("bdfjqgatlksriohemnpc"), 1, S::npos);
+ test(S("crnklpmegd"), S(""), 5, 5);
+ test(S("jsbtafedoc"), S("prqgn"), 5, 5);
+ test(S("qnmodrtkeb"), S("pejafmnokr"), 5, 6);
+ test(S("cpebqsfmnj"), S("odnqkgijrhabfmcestlp"), 5, S::npos);
+ test(S("lmofqdhpki"), S(""), 9, 9);
+ test(S("hnefkqimca"), S("rtjpa"), 9, S::npos);
+ test(S("drtasbgmfp"), S("ktsrmnqagd"), 9, 9);
+ test(S("lsaijeqhtr"), S("rtdhgcisbnmoaqkfpjle"), 9, S::npos);
+ test(S("elgofjmbrq"), S(""), 10, S::npos);
+ test(S("mjqdgalkpc"), S("dplqa"), 10, S::npos);
+ test(S("kthqnfcerm"), S("dkacjoptns"), 10, S::npos);
+ test(S("dfsjhanorc"), S("hqfimtrgnbekpdcsjalo"), 10, S::npos);
+ test(S("eqsgalomhb"), S(""), 11, S::npos);
+ test(S("akiteljmoh"), S("lofbc"), 11, S::npos);
+ test(S("hlbdfreqjo"), S("astoegbfpn"), 11, S::npos);
+ test(S("taqobhlerg"), S("pdgreqomsncafklhtibj"), 11, S::npos);
+ test(S("snafbdlghrjkpqtoceim"), S(""), 0, 0);
+ test(S("aemtbrgcklhndjisfpoq"), S("lbtqd"), 0, 0);
+ test(S("pnracgfkjdiholtbqsem"), S("tboimldpjh"), 0, 1);
+ test(S("dicfltehbsgrmojnpkaq"), S("slcerthdaiqjfnobgkpm"), 0, S::npos);
+ test(S("jlnkraeodhcspfgbqitm"), S(""), 1, 1);
+ test(S("lhosrngtmfjikbqpcade"), S("aqibs"), 1, 1);
+ test(S("rbtaqjhgkneisldpmfoc"), S("gtfblmqinc"), 1, 3);
+ test(S("gpifsqlrdkbonjtmheca"), S("mkqpbtdalgniorhfescj"), 1, S::npos);
+ test(S("hdpkobnsalmcfijregtq"), S(""), 10, 10);
+ test(S("jtlshdgqaiprkbcoenfm"), S("pblas"), 10, 11);
+ test(S("fkdrbqltsgmcoiphneaj"), S("arosdhcfme"), 10, 13);
+ test(S("crsplifgtqedjohnabmk"), S("blkhjeogicatqfnpdmsr"), 10, S::npos);
+ test(S("niptglfbosehkamrdqcj"), S(""), 19, 19);
+ test(S("copqdhstbingamjfkler"), S("djkqc"), 19, 19);
+ test(S("mrtaefilpdsgocnhqbjk"), S("lgokshjtpb"), 19, S::npos);
+ test(S("kojatdhlcmigpbfrqnes"), S("bqjhtkfepimcnsgrlado"), 19, S::npos);
+ test(S("eaintpchlqsbdgrkjofm"), S(""), 20, S::npos);
+ test(S("gjnhidfsepkrtaqbmclo"), S("nocfa"), 20, S::npos);
+ test(S("spocfaktqdbiejlhngmr"), S("bgtajmiedc"), 20, S::npos);
+ test(S("rphmlekgfscndtaobiqj"), S("lsckfnqgdahejiopbtmr"), 20, S::npos);
+ test(S("liatsqdoegkmfcnbhrpj"), S(""), 21, S::npos);
+ test(S("binjagtfldkrspcomqeh"), S("gfsrt"), 21, S::npos);
+ test(S("latkmisecnorjbfhqpdg"), S("pfsocbhjtm"), 21, S::npos);
+ test(S("lecfratdjkhnsmqpoigb"), S("tpflmdnoicjgkberhqsa"), 21, S::npos);
+}
+
+template <class S>
+void test1()
+{
+ test(S(""), S(""), S::npos);
+ test(S(""), S("laenf"), S::npos);
+ test(S(""), S("pqlnkmbdjo"), S::npos);
+ test(S(""), S("qkamfogpnljdcshbreti"), S::npos);
+ test(S("nhmko"), S(""), 0);
+ test(S("lahfb"), S("irkhs"), 0);
+ test(S("gmfhd"), S("kantesmpgj"), 2);
+ test(S("odaft"), S("oknlrstdpiqmjbaghcfe"), S::npos);
+ test(S("eolhfgpjqk"), S(""), 0);
+ test(S("nbatdlmekr"), S("bnrpe"), 2);
+ test(S("jdmciepkaq"), S("jtdaefblso"), 2);
+ test(S("hkbgspoflt"), S("oselktgbcapndfjihrmq"), S::npos);
+ test(S("gprdcokbnjhlsfmtieqa"), S(""), 0);
+ test(S("qjghlnftcaismkropdeb"), S("bjaht"), 0);
+ test(S("pnalfrdtkqcmojiesbhg"), S("hjlcmgpket"), 1);
+ test(S("pniotcfrhqsmgdkjbael"), S("htaobedqikfplcgjsmrn"), S::npos);
+}
+
+int main()
+{
+ {
+ typedef std::experimental::string_view S;
+ test0<S>();
+ test1<S>();
+ }
+}
diff --git a/test/std/experimental/string.view/string.view.find/find_first_of_char_size.pass.cpp b/test/std/experimental/string.view/string.view.find/find_first_of_char_size.pass.cpp
new file mode 100644
index 000000000000..dde2f2c9f378
--- /dev/null
+++ b/test/std/experimental/string.view/string.view.find/find_first_of_char_size.pass.cpp
@@ -0,0 +1,82 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// constexpr size_type find_first_of(charT c, size_type pos = 0) const;
+
+#include <experimental/string_view>
+#include <cassert>
+
+#include "constexpr_char_traits.hpp"
+
+template <class S>
+void
+test(const S& s, typename S::value_type c, typename S::size_type pos,
+ typename S::size_type x)
+{
+ assert(s.find_first_of(c, pos) == x);
+ if (x != S::npos)
+ assert(pos <= x && x < s.size());
+}
+
+template <class S>
+void
+test(const S& s, typename S::value_type c, typename S::size_type x)
+{
+ assert(s.find_first_of(c) == x);
+ if (x != S::npos)
+ assert(x < s.size());
+}
+
+int main()
+{
+ {
+ typedef std::experimental::string_view S;
+ test(S(""), 'e', 0, S::npos);
+ test(S(""), 'e', 1, S::npos);
+ test(S("kitcj"), 'e', 0, S::npos);
+ test(S("qkamf"), 'e', 1, S::npos);
+ test(S("nhmko"), 'e', 2, S::npos);
+ test(S("tpsaf"), 'e', 4, S::npos);
+ test(S("lahfb"), 'e', 5, S::npos);
+ test(S("irkhs"), 'e', 6, S::npos);
+ test(S("gmfhdaipsr"), 'e', 0, S::npos);
+ test(S("kantesmpgj"), 'e', 1, 4);
+ test(S("odaftiegpm"), 'e', 5, 6);
+ test(S("oknlrstdpi"), 'e', 9, S::npos);
+ test(S("eolhfgpjqk"), 'e', 10, S::npos);
+ test(S("pcdrofikas"), 'e', 11, S::npos);
+ test(S("nbatdlmekrgcfqsophij"), 'e', 0, 7);
+ test(S("bnrpehidofmqtcksjgla"), 'e', 1, 4);
+ test(S("jdmciepkaqgotsrfnhlb"), 'e', 10, S::npos);
+ test(S("jtdaefblsokrmhpgcnqi"), 'e', 19, S::npos);
+ test(S("hkbgspofltajcnedqmri"), 'e', 20, S::npos);
+ test(S("oselktgbcapndfjihrmq"), 'e', 21, S::npos);
+
+ test(S(""), 'e', S::npos);
+ test(S("csope"), 'e', 4);
+ test(S("gfsmthlkon"), 'e', S::npos);
+ test(S("laenfsbridchgotmkqpj"), 'e', 2);
+ }
+
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::experimental::basic_string_view<char, constexpr_char_traits<char>> SV;
+ constexpr SV sv1;
+ constexpr SV sv2 { "abcde", 5 };
+
+ static_assert (sv1.find_first_of( 'e', 0 ) == SV::npos, "" );
+ static_assert (sv1.find_first_of( 'e', 1 ) == SV::npos, "" );
+ static_assert (sv2.find_first_of( 'q', 0 ) == SV::npos, "" );
+ static_assert (sv2.find_first_of( 'e', 1 ) == 4, "" );
+ static_assert (sv2.find_first_of( 'e', 5 ) == SV::npos, "" );
+ }
+#endif
+}
diff --git a/test/std/experimental/string.view/string.view.find/find_first_of_pointer_size.pass.cpp b/test/std/experimental/string.view/string.view.find/find_first_of_pointer_size.pass.cpp
new file mode 100644
index 000000000000..e49e82ccab11
--- /dev/null
+++ b/test/std/experimental/string.view/string.view.find/find_first_of_pointer_size.pass.cpp
@@ -0,0 +1,165 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// constexpr size_type find_first_of(const charT* s, size_type pos = 0) const;
+
+#include <experimental/string_view>
+#include <cassert>
+
+#include "constexpr_char_traits.hpp"
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type pos,
+ typename S::size_type x)
+{
+ assert(s.find_first_of(str, pos) == x);
+ if (x != S::npos)
+ assert(pos <= x && x < s.size());
+}
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type x)
+{
+ assert(s.find_first_of(str) == x);
+ if (x != S::npos)
+ assert(x < s.size());
+}
+
+template <class S>
+void test0()
+{
+ test(S(""), "", 0, S::npos);
+ test(S(""), "laenf", 0, S::npos);
+ test(S(""), "pqlnkmbdjo", 0, S::npos);
+ test(S(""), "qkamfogpnljdcshbreti", 0, S::npos);
+ test(S(""), "", 1, S::npos);
+ test(S(""), "bjaht", 1, S::npos);
+ test(S(""), "hjlcmgpket", 1, S::npos);
+ test(S(""), "htaobedqikfplcgjsmrn", 1, S::npos);
+ test(S("fodgq"), "", 0, S::npos);
+ test(S("qanej"), "dfkap", 0, 1);
+ test(S("clbao"), "ihqrfebgad", 0, 2);
+ test(S("mekdn"), "ngtjfcalbseiqrphmkdo", 0, 0);
+ test(S("srdfq"), "", 1, S::npos);
+ test(S("oemth"), "ikcrq", 1, S::npos);
+ test(S("cdaih"), "dmajblfhsg", 1, 1);
+ test(S("qohtk"), "oqftjhdmkgsblacenirp", 1, 1);
+ test(S("cshmd"), "", 2, S::npos);
+ test(S("lhcdo"), "oebqi", 2, 4);
+ test(S("qnsoh"), "kojhpmbsfe", 2, 2);
+ test(S("pkrof"), "acbsjqogpltdkhinfrem", 2, 2);
+ test(S("fmtsp"), "", 4, S::npos);
+ test(S("khbpm"), "aobjd", 4, S::npos);
+ test(S("pbsji"), "pcbahntsje", 4, S::npos);
+ test(S("mprdj"), "fhepcrntkoagbmldqijs", 4, 4);
+ test(S("eqmpa"), "", 5, S::npos);
+ test(S("omigs"), "kocgb", 5, S::npos);
+ test(S("onmje"), "fbslrjiqkm", 5, S::npos);
+ test(S("oqmrj"), "jeidpcmalhfnqbgtrsko", 5, S::npos);
+ test(S("schfa"), "", 6, S::npos);
+ test(S("igdsc"), "qngpd", 6, S::npos);
+ test(S("brqgo"), "rodhqklgmb", 6, S::npos);
+ test(S("tnrph"), "thdjgafrlbkoiqcspmne", 6, S::npos);
+ test(S("hcjitbfapl"), "", 0, S::npos);
+ test(S("daiprenocl"), "ashjd", 0, 0);
+ test(S("litpcfdghe"), "mgojkldsqh", 0, 0);
+ test(S("aidjksrolc"), "imqnaghkfrdtlopbjesc", 0, 0);
+ test(S("qpghtfbaji"), "", 1, S::npos);
+ test(S("gfshlcmdjr"), "nadkh", 1, 3);
+ test(S("nkodajteqp"), "ofdrqmkebl", 1, 1);
+ test(S("gbmetiprqd"), "bdfjqgatlksriohemnpc", 1, 1);
+ test(S("crnklpmegd"), "", 5, S::npos);
+ test(S("jsbtafedoc"), "prqgn", 5, S::npos);
+ test(S("qnmodrtkeb"), "pejafmnokr", 5, 5);
+ test(S("cpebqsfmnj"), "odnqkgijrhabfmcestlp", 5, 5);
+ test(S("lmofqdhpki"), "", 9, S::npos);
+ test(S("hnefkqimca"), "rtjpa", 9, 9);
+ test(S("drtasbgmfp"), "ktsrmnqagd", 9, S::npos);
+ test(S("lsaijeqhtr"), "rtdhgcisbnmoaqkfpjle", 9, 9);
+ test(S("elgofjmbrq"), "", 10, S::npos);
+ test(S("mjqdgalkpc"), "dplqa", 10, S::npos);
+ test(S("kthqnfcerm"), "dkacjoptns", 10, S::npos);
+ test(S("dfsjhanorc"), "hqfimtrgnbekpdcsjalo", 10, S::npos);
+ test(S("eqsgalomhb"), "", 11, S::npos);
+ test(S("akiteljmoh"), "lofbc", 11, S::npos);
+ test(S("hlbdfreqjo"), "astoegbfpn", 11, S::npos);
+ test(S("taqobhlerg"), "pdgreqomsncafklhtibj", 11, S::npos);
+ test(S("snafbdlghrjkpqtoceim"), "", 0, S::npos);
+ test(S("aemtbrgcklhndjisfpoq"), "lbtqd", 0, 3);
+ test(S("pnracgfkjdiholtbqsem"), "tboimldpjh", 0, 0);
+ test(S("dicfltehbsgrmojnpkaq"), "slcerthdaiqjfnobgkpm", 0, 0);
+ test(S("jlnkraeodhcspfgbqitm"), "", 1, S::npos);
+ test(S("lhosrngtmfjikbqpcade"), "aqibs", 1, 3);
+ test(S("rbtaqjhgkneisldpmfoc"), "gtfblmqinc", 1, 1);
+ test(S("gpifsqlrdkbonjtmheca"), "mkqpbtdalgniorhfescj", 1, 1);
+ test(S("hdpkobnsalmcfijregtq"), "", 10, S::npos);
+ test(S("jtlshdgqaiprkbcoenfm"), "pblas", 10, 10);
+ test(S("fkdrbqltsgmcoiphneaj"), "arosdhcfme", 10, 10);
+ test(S("crsplifgtqedjohnabmk"), "blkhjeogicatqfnpdmsr", 10, 10);
+ test(S("niptglfbosehkamrdqcj"), "", 19, S::npos);
+ test(S("copqdhstbingamjfkler"), "djkqc", 19, S::npos);
+ test(S("mrtaefilpdsgocnhqbjk"), "lgokshjtpb", 19, 19);
+ test(S("kojatdhlcmigpbfrqnes"), "bqjhtkfepimcnsgrlado", 19, 19);
+ test(S("eaintpchlqsbdgrkjofm"), "", 20, S::npos);
+ test(S("gjnhidfsepkrtaqbmclo"), "nocfa", 20, S::npos);
+ test(S("spocfaktqdbiejlhngmr"), "bgtajmiedc", 20, S::npos);
+ test(S("rphmlekgfscndtaobiqj"), "lsckfnqgdahejiopbtmr", 20, S::npos);
+ test(S("liatsqdoegkmfcnbhrpj"), "", 21, S::npos);
+ test(S("binjagtfldkrspcomqeh"), "gfsrt", 21, S::npos);
+ test(S("latkmisecnorjbfhqpdg"), "pfsocbhjtm", 21, S::npos);
+ test(S("lecfratdjkhnsmqpoigb"), "tpflmdnoicjgkberhqsa", 21, S::npos);
+}
+
+template <class S>
+void test1()
+{
+ test(S(""), "", S::npos);
+ test(S(""), "laenf", S::npos);
+ test(S(""), "pqlnkmbdjo", S::npos);
+ test(S(""), "qkamfogpnljdcshbreti", S::npos);
+ test(S("nhmko"), "", S::npos);
+ test(S("lahfb"), "irkhs", 2);
+ test(S("gmfhd"), "kantesmpgj", 0);
+ test(S("odaft"), "oknlrstdpiqmjbaghcfe", 0);
+ test(S("eolhfgpjqk"), "", S::npos);
+ test(S("nbatdlmekr"), "bnrpe", 0);
+ test(S("jdmciepkaq"), "jtdaefblso", 0);
+ test(S("hkbgspoflt"), "oselktgbcapndfjihrmq", 0);
+ test(S("gprdcokbnjhlsfmtieqa"), "", S::npos);
+ test(S("qjghlnftcaismkropdeb"), "bjaht", 1);
+ test(S("pnalfrdtkqcmojiesbhg"), "hjlcmgpket", 0);
+ test(S("pniotcfrhqsmgdkjbael"), "htaobedqikfplcgjsmrn", 0);
+}
+
+int main()
+{
+ {
+ typedef std::experimental::string_view S;
+ test0<S>();
+ test1<S>();
+ }
+
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::experimental::basic_string_view<char, constexpr_char_traits<char>> SV;
+ constexpr SV sv1;
+ constexpr SV sv2 { "abcde", 5 };
+
+ static_assert (sv1.find_first_of( "", 0) == SV::npos, "" );
+ static_assert (sv1.find_first_of( "irkhs", 0) == SV::npos, "" );
+ static_assert (sv2.find_first_of( "", 0) == SV::npos, "" );
+ static_assert (sv2.find_first_of( "gfsrt", 0) == SV::npos, "" );
+ static_assert (sv2.find_first_of( "lecar", 0) == 0, "" );
+ }
+#endif
+}
diff --git a/test/std/experimental/string.view/string.view.find/find_first_of_pointer_size_size.pass.cpp b/test/std/experimental/string.view/string.view.find/find_first_of_pointer_size_size.pass.cpp
new file mode 100644
index 000000000000..1dc8d85472c7
--- /dev/null
+++ b/test/std/experimental/string.view/string.view.find/find_first_of_pointer_size_size.pass.cpp
@@ -0,0 +1,392 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// constexpr size_type find_first_of(const charT* s, size_type pos, size_type n) const;
+
+#include <experimental/string_view>
+#include <cassert>
+
+#include "constexpr_char_traits.hpp"
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type pos,
+ typename S::size_type n, typename S::size_type x)
+{
+ assert(s.find_first_of(str, pos, n) == x);
+ if (x != S::npos)
+ assert(pos <= x && x < s.size());
+}
+
+template <class S>
+void test0()
+{
+ test(S(""), "", 0, 0, S::npos);
+ test(S(""), "irkhs", 0, 0, S::npos);
+ test(S(""), "kante", 0, 1, S::npos);
+ test(S(""), "oknlr", 0, 2, S::npos);
+ test(S(""), "pcdro", 0, 4, S::npos);
+ test(S(""), "bnrpe", 0, 5, S::npos);
+ test(S(""), "jtdaefblso", 0, 0, S::npos);
+ test(S(""), "oselktgbca", 0, 1, S::npos);
+ test(S(""), "eqgaplhckj", 0, 5, S::npos);
+ test(S(""), "bjahtcmnlp", 0, 9, S::npos);
+ test(S(""), "hjlcmgpket", 0, 10, S::npos);
+ test(S(""), "htaobedqikfplcgjsmrn", 0, 0, S::npos);
+ test(S(""), "hpqiarojkcdlsgnmfetb", 0, 1, S::npos);
+ test(S(""), "dfkaprhjloqetcsimnbg", 0, 10, S::npos);
+ test(S(""), "ihqrfebgadntlpmjksoc", 0, 19, S::npos);
+ test(S(""), "ngtjfcalbseiqrphmkdo", 0, 20, S::npos);
+ test(S(""), "", 1, 0, S::npos);
+ test(S(""), "lbtqd", 1, 0, S::npos);
+ test(S(""), "tboim", 1, 1, S::npos);
+ test(S(""), "slcer", 1, 2, S::npos);
+ test(S(""), "cbjfs", 1, 4, S::npos);
+ test(S(""), "aqibs", 1, 5, S::npos);
+ test(S(""), "gtfblmqinc", 1, 0, S::npos);
+ test(S(""), "mkqpbtdalg", 1, 1, S::npos);
+ test(S(""), "kphatlimcd", 1, 5, S::npos);
+ test(S(""), "pblasqogic", 1, 9, S::npos);
+ test(S(""), "arosdhcfme", 1, 10, S::npos);
+ test(S(""), "blkhjeogicatqfnpdmsr", 1, 0, S::npos);
+ test(S(""), "bmhineprjcoadgstflqk", 1, 1, S::npos);
+ test(S(""), "djkqcmetslnghpbarfoi", 1, 10, S::npos);
+ test(S(""), "lgokshjtpbemarcdqnfi", 1, 19, S::npos);
+ test(S(""), "bqjhtkfepimcnsgrlado", 1, 20, S::npos);
+ test(S("eaint"), "", 0, 0, S::npos);
+ test(S("binja"), "gfsrt", 0, 0, S::npos);
+ test(S("latkm"), "pfsoc", 0, 1, S::npos);
+ test(S("lecfr"), "tpflm", 0, 2, S::npos);
+ test(S("eqkst"), "sgkec", 0, 4, 0);
+ test(S("cdafr"), "romds", 0, 5, 1);
+ test(S("prbhe"), "qhjistlgmr", 0, 0, S::npos);
+ test(S("lbisk"), "pedfirsglo", 0, 1, S::npos);
+ test(S("hrlpd"), "aqcoslgrmk", 0, 5, S::npos);
+ test(S("ehmja"), "dabckmepqj", 0, 9, 0);
+ test(S("mhqgd"), "pqscrjthli", 0, 10, 1);
+ test(S("tgklq"), "kfphdcsjqmobliagtren", 0, 0, S::npos);
+ test(S("bocjs"), "rokpefncljibsdhqtagm", 0, 1, S::npos);
+ test(S("grbsd"), "afionmkphlebtcjqsgrd", 0, 10, S::npos);
+ test(S("ofjqr"), "aenmqplidhkofrjbctsg", 0, 19, 0);
+ test(S("btlfi"), "osjmbtcadhiklegrpqnf", 0, 20, 0);
+ test(S("clrgb"), "", 1, 0, S::npos);
+ test(S("tjmek"), "osmia", 1, 0, S::npos);
+ test(S("bgstp"), "ckonl", 1, 1, S::npos);
+ test(S("hstrk"), "ilcaj", 1, 2, S::npos);
+ test(S("kmspj"), "lasiq", 1, 4, 2);
+ test(S("tjboh"), "kfqmr", 1, 5, S::npos);
+ test(S("ilbcj"), "klnitfaobg", 1, 0, S::npos);
+ test(S("jkngf"), "gjhmdlqikp", 1, 1, 3);
+ test(S("gfcql"), "skbgtahqej", 1, 5, S::npos);
+ test(S("dqtlg"), "bjsdgtlpkf", 1, 9, 2);
+ test(S("bthpg"), "bjgfmnlkio", 1, 10, 4);
+ test(S("dgsnq"), "lbhepotfsjdqigcnamkr", 1, 0, S::npos);
+ test(S("rmfhp"), "tebangckmpsrqdlfojhi", 1, 1, S::npos);
+ test(S("jfdam"), "joflqbdkhtegimscpanr", 1, 10, 1);
+ test(S("edapb"), "adpmcohetfbsrjinlqkg", 1, 19, 1);
+ test(S("brfsm"), "iacldqjpfnogbsrhmetk", 1, 20, 1);
+ test(S("ndrhl"), "", 2, 0, S::npos);
+ test(S("mrecp"), "otkgb", 2, 0, S::npos);
+ test(S("qlasf"), "cqsjl", 2, 1, S::npos);
+ test(S("smaqd"), "dpifl", 2, 2, 4);
+ test(S("hjeni"), "oapht", 2, 4, S::npos);
+ test(S("ocmfj"), "cifts", 2, 5, 3);
+ test(S("hmftq"), "nmsckbgalo", 2, 0, S::npos);
+ test(S("fklad"), "tpksqhamle", 2, 1, S::npos);
+ test(S("dirnm"), "tpdrchmkji", 2, 5, 2);
+ test(S("hrgdc"), "ijagfkblst", 2, 9, 2);
+ test(S("ifakg"), "kpocsignjb", 2, 10, 3);
+ test(S("ebrgd"), "pecqtkjsnbdrialgmohf", 2, 0, S::npos);
+ test(S("rcjml"), "aiortphfcmkjebgsndql", 2, 1, S::npos);
+ test(S("peqmt"), "sdbkeamglhipojqftrcn", 2, 10, 3);
+ test(S("frehn"), "ljqncehgmfktroapidbs", 2, 19, 2);
+ test(S("tqolf"), "rtcfodilamkbenjghqps", 2, 20, 2);
+ test(S("cjgao"), "", 4, 0, S::npos);
+ test(S("kjplq"), "mabns", 4, 0, S::npos);
+ test(S("herni"), "bdnrp", 4, 1, S::npos);
+ test(S("tadrb"), "scidp", 4, 2, S::npos);
+ test(S("pkfeo"), "agbjl", 4, 4, S::npos);
+ test(S("hoser"), "jfmpr", 4, 5, 4);
+ test(S("kgrsp"), "rbpefghsmj", 4, 0, S::npos);
+ test(S("pgejb"), "apsfntdoqc", 4, 1, S::npos);
+ test(S("thlnq"), "ndkjeisgcl", 4, 5, S::npos);
+ test(S("nbmit"), "rnfpqatdeo", 4, 9, 4);
+ test(S("jgmib"), "bntjlqrfik", 4, 10, 4);
+ test(S("ncrfj"), "kcrtmpolnaqejghsfdbi", 4, 0, S::npos);
+ test(S("ncsik"), "lobheanpkmqidsrtcfgj", 4, 1, S::npos);
+ test(S("sgbfh"), "athdkljcnreqbgpmisof", 4, 10, 4);
+ test(S("dktbn"), "qkdmjialrscpbhefgont", 4, 19, 4);
+ test(S("fthqm"), "dmasojntqleribkgfchp", 4, 20, 4);
+ test(S("klopi"), "", 5, 0, S::npos);
+ test(S("dajhn"), "psthd", 5, 0, S::npos);
+ test(S("jbgno"), "rpmjd", 5, 1, S::npos);
+ test(S("hkjae"), "dfsmk", 5, 2, S::npos);
+}
+
+template <class S>
+void test1()
+{
+ test(S("gbhqo"), "skqne", 5, 4, S::npos);
+ test(S("ktdor"), "kipnf", 5, 5, S::npos);
+ test(S("ldprn"), "hmrnqdgifl", 5, 0, S::npos);
+ test(S("egmjk"), "fsmjcdairn", 5, 1, S::npos);
+ test(S("armql"), "pcdgltbrfj", 5, 5, S::npos);
+ test(S("cdhjo"), "aekfctpirg", 5, 9, S::npos);
+ test(S("jcons"), "ledihrsgpf", 5, 10, S::npos);
+ test(S("cbrkp"), "mqcklahsbtirgopefndj", 5, 0, S::npos);
+ test(S("fhgna"), "kmlthaoqgecrnpdbjfis", 5, 1, S::npos);
+ test(S("ejfcd"), "sfhbamcdptojlkrenqgi", 5, 10, S::npos);
+ test(S("kqjhe"), "pbniofmcedrkhlstgaqj", 5, 19, S::npos);
+ test(S("pbdjl"), "mongjratcskbhqiepfdl", 5, 20, S::npos);
+ test(S("gajqn"), "", 6, 0, S::npos);
+ test(S("stedk"), "hrnat", 6, 0, S::npos);
+ test(S("tjkaf"), "gsqdt", 6, 1, S::npos);
+ test(S("dthpe"), "bspkd", 6, 2, S::npos);
+ test(S("klhde"), "ohcmb", 6, 4, S::npos);
+ test(S("bhlki"), "heatr", 6, 5, S::npos);
+ test(S("lqmoh"), "pmblckedfn", 6, 0, S::npos);
+ test(S("mtqin"), "aceqmsrbik", 6, 1, S::npos);
+ test(S("dpqbr"), "lmbtdehjrn", 6, 5, S::npos);
+ test(S("kdhmo"), "teqmcrlgib", 6, 9, S::npos);
+ test(S("jblqp"), "njolbmspac", 6, 10, S::npos);
+ test(S("qmjgl"), "pofnhidklamecrbqjgst", 6, 0, S::npos);
+ test(S("rothp"), "jbhckmtgrqnosafedpli", 6, 1, S::npos);
+ test(S("ghknq"), "dobntpmqklicsahgjerf", 6, 10, S::npos);
+ test(S("eopfi"), "tpdshainjkbfoemlrgcq", 6, 19, S::npos);
+ test(S("dsnmg"), "oldpfgeakrnitscbjmqh", 6, 20, S::npos);
+ test(S("jnkrfhotgl"), "", 0, 0, S::npos);
+ test(S("dltjfngbko"), "rqegt", 0, 0, S::npos);
+ test(S("bmjlpkiqde"), "dashm", 0, 1, 8);
+ test(S("skrflobnqm"), "jqirk", 0, 2, 8);
+ test(S("jkpldtshrm"), "rckeg", 0, 4, 1);
+ test(S("ghasdbnjqo"), "jscie", 0, 5, 3);
+ test(S("igrkhpbqjt"), "efsphndliq", 0, 0, S::npos);
+ test(S("ikthdgcamf"), "gdicosleja", 0, 1, 5);
+ test(S("pcofgeniam"), "qcpjibosfl", 0, 5, 0);
+ test(S("rlfjgesqhc"), "lrhmefnjcq", 0, 9, 0);
+ test(S("itphbqsker"), "dtablcrseo", 0, 10, 1);
+ test(S("skjafcirqm"), "apckjsftedbhgomrnilq", 0, 0, S::npos);
+ test(S("tcqomarsfd"), "pcbrgflehjtiadnsokqm", 0, 1, S::npos);
+ test(S("rocfeldqpk"), "nsiadegjklhobrmtqcpf", 0, 10, 4);
+ test(S("cfpegndlkt"), "cpmajdqnolikhgsbretf", 0, 19, 0);
+ test(S("fqbtnkeasj"), "jcflkntmgiqrphdosaeb", 0, 20, 0);
+ test(S("shbcqnmoar"), "", 1, 0, S::npos);
+ test(S("bdoshlmfin"), "ontrs", 1, 0, S::npos);
+ test(S("khfrebnsgq"), "pfkna", 1, 1, S::npos);
+ test(S("getcrsaoji"), "ekosa", 1, 2, 1);
+ test(S("fjiknedcpq"), "anqhk", 1, 4, 4);
+ test(S("tkejgnafrm"), "jekca", 1, 5, 1);
+ test(S("jnakolqrde"), "ikemsjgacf", 1, 0, S::npos);
+ test(S("lcjptsmgbe"), "arolgsjkhm", 1, 1, S::npos);
+ test(S("itfsmcjorl"), "oftkbldhre", 1, 5, 1);
+ test(S("omchkfrjea"), "gbkqdoeftl", 1, 9, 4);
+ test(S("cigfqkated"), "sqcflrgtim", 1, 10, 1);
+ test(S("tscenjikml"), "fmhbkislrjdpanogqcet", 1, 0, S::npos);
+ test(S("qcpaemsinf"), "rnioadktqlgpbcjsmhef", 1, 1, S::npos);
+ test(S("gltkojeipd"), "oakgtnldpsefihqmjcbr", 1, 10, 1);
+ test(S("qistfrgnmp"), "gbnaelosidmcjqktfhpr", 1, 19, 1);
+ test(S("bdnpfcqaem"), "akbripjhlosndcmqgfet", 1, 20, 1);
+ test(S("ectnhskflp"), "", 5, 0, S::npos);
+ test(S("fgtianblpq"), "pijag", 5, 0, S::npos);
+ test(S("mfeqklirnh"), "jrckd", 5, 1, S::npos);
+ test(S("astedncjhk"), "qcloh", 5, 2, 6);
+ test(S("fhlqgcajbr"), "thlmp", 5, 4, S::npos);
+ test(S("epfhocmdng"), "qidmo", 5, 5, 6);
+ test(S("apcnsibger"), "lnegpsjqrd", 5, 0, S::npos);
+ test(S("aqkocrbign"), "rjqdablmfs", 5, 1, 5);
+ test(S("ijsmdtqgce"), "enkgpbsjaq", 5, 5, 7);
+ test(S("clobgsrken"), "kdsgoaijfh", 5, 9, 5);
+ test(S("jbhcfposld"), "trfqgmckbe", 5, 10, S::npos);
+ test(S("oqnpblhide"), "igetsracjfkdnpoblhqm", 5, 0, S::npos);
+ test(S("lroeasctif"), "nqctfaogirshlekbdjpm", 5, 1, S::npos);
+ test(S("bpjlgmiedh"), "csehfgomljdqinbartkp", 5, 10, 5);
+ test(S("pamkeoidrj"), "qahoegcmplkfsjbdnitr", 5, 19, 5);
+ test(S("espogqbthk"), "dpteiajrqmsognhlfbkc", 5, 20, 5);
+ test(S("shoiedtcjb"), "", 9, 0, S::npos);
+ test(S("ebcinjgads"), "tqbnh", 9, 0, S::npos);
+ test(S("dqmregkcfl"), "akmle", 9, 1, S::npos);
+ test(S("ngcrieqajf"), "iqfkm", 9, 2, S::npos);
+ test(S("qosmilgnjb"), "tqjsr", 9, 4, S::npos);
+ test(S("ikabsjtdfl"), "jplqg", 9, 5, 9);
+ test(S("ersmicafdh"), "oilnrbcgtj", 9, 0, S::npos);
+ test(S("fdnplotmgh"), "morkglpesn", 9, 1, S::npos);
+ test(S("fdbicojerm"), "dmicerngat", 9, 5, 9);
+ test(S("mbtafndjcq"), "radgeskbtc", 9, 9, S::npos);
+ test(S("mlenkpfdtc"), "ljikprsmqo", 9, 10, S::npos);
+ test(S("ahlcifdqgs"), "trqihkcgsjamfdbolnpe", 9, 0, S::npos);
+ test(S("bgjemaltks"), "lqmthbsrekajgnofcipd", 9, 1, S::npos);
+ test(S("pdhslbqrfc"), "jtalmedribkgqsopcnfh", 9, 10, S::npos);
+ test(S("dirhtsnjkc"), "spqfoiclmtagejbndkrh", 9, 19, 9);
+ test(S("dlroktbcja"), "nmotklspigjrdhcfaebq", 9, 20, 9);
+ test(S("ncjpmaekbs"), "", 10, 0, S::npos);
+ test(S("hlbosgmrak"), "hpmsd", 10, 0, S::npos);
+ test(S("pqfhsgilen"), "qnpor", 10, 1, S::npos);
+ test(S("gqtjsbdckh"), "otdma", 10, 2, S::npos);
+ test(S("cfkqpjlegi"), "efhjg", 10, 4, S::npos);
+ test(S("beanrfodgj"), "odpte", 10, 5, S::npos);
+ test(S("adtkqpbjfi"), "bctdgfmolr", 10, 0, S::npos);
+ test(S("iomkfthagj"), "oaklidrbqg", 10, 1, S::npos);
+}
+
+template <class S>
+void test2()
+{
+ test(S("sdpcilonqj"), "dnjfsagktr", 10, 5, S::npos);
+ test(S("gtfbdkqeml"), "nejaktmiqg", 10, 9, S::npos);
+ test(S("bmeqgcdorj"), "pjqonlebsf", 10, 10, S::npos);
+ test(S("etqlcanmob"), "dshmnbtolcjepgaikfqr", 10, 0, S::npos);
+ test(S("roqmkbdtia"), "iogfhpabtjkqlrnemcds", 10, 1, S::npos);
+ test(S("kadsithljf"), "ngridfabjsecpqltkmoh", 10, 10, S::npos);
+ test(S("sgtkpbfdmh"), "athmknplcgofrqejsdib", 10, 19, S::npos);
+ test(S("qgmetnabkl"), "ldobhmqcafnjtkeisgrp", 10, 20, S::npos);
+ test(S("cqjohampgd"), "", 11, 0, S::npos);
+ test(S("hobitmpsan"), "aocjb", 11, 0, S::npos);
+ test(S("tjehkpsalm"), "jbrnk", 11, 1, S::npos);
+ test(S("ngfbojitcl"), "tqedg", 11, 2, S::npos);
+ test(S("rcfkdbhgjo"), "nqskp", 11, 4, S::npos);
+ test(S("qghptonrea"), "eaqkl", 11, 5, S::npos);
+ test(S("hnprfgqjdl"), "reaoicljqm", 11, 0, S::npos);
+ test(S("hlmgabenti"), "lsftgajqpm", 11, 1, S::npos);
+ test(S("ofcjanmrbs"), "rlpfogmits", 11, 5, S::npos);
+ test(S("jqedtkornm"), "shkncmiaqj", 11, 9, S::npos);
+ test(S("rfedlasjmg"), "fpnatrhqgs", 11, 10, S::npos);
+ test(S("talpqjsgkm"), "sjclemqhnpdbgikarfot", 11, 0, S::npos);
+ test(S("lrkcbtqpie"), "otcmedjikgsfnqbrhpla", 11, 1, S::npos);
+ test(S("cipogdskjf"), "bonsaefdqiprkhlgtjcm", 11, 10, S::npos);
+ test(S("nqedcojahi"), "egpscmahijlfnkrodqtb", 11, 19, S::npos);
+ test(S("hefnrkmctj"), "kmqbfepjthgilscrndoa", 11, 20, S::npos);
+ test(S("atqirnmekfjolhpdsgcb"), "", 0, 0, S::npos);
+ test(S("echfkmlpribjnqsaogtd"), "prboq", 0, 0, S::npos);
+ test(S("qnhiftdgcleajbpkrosm"), "fjcqh", 0, 1, 4);
+ test(S("chamfknorbedjitgslpq"), "fmosa", 0, 2, 3);
+ test(S("njhqpibfmtlkaecdrgso"), "qdbok", 0, 4, 3);
+ test(S("ebnghfsqkprmdcljoiat"), "amslg", 0, 5, 3);
+ test(S("letjomsgihfrpqbkancd"), "smpltjneqb", 0, 0, S::npos);
+ test(S("nblgoipcrqeaktshjdmf"), "flitskrnge", 0, 1, 19);
+ test(S("cehkbngtjoiflqapsmrd"), "pgqihmlbef", 0, 5, 2);
+ test(S("mignapfoklbhcqjetdrs"), "cfpdqjtgsb", 0, 9, 2);
+ test(S("ceatbhlsqjgpnokfrmdi"), "htpsiaflom", 0, 10, 2);
+ test(S("ocihkjgrdelpfnmastqb"), "kpjfiaceghsrdtlbnomq", 0, 0, S::npos);
+ test(S("noelgschdtbrjfmiqkap"), "qhtbomidljgafneksprc", 0, 1, 16);
+ test(S("dkclqfombepritjnghas"), "nhtjobkcefldimpsaqgr", 0, 10, 1);
+ test(S("miklnresdgbhqcojftap"), "prabcjfqnoeskilmtgdh", 0, 19, 0);
+ test(S("htbcigojaqmdkfrnlsep"), "dtrgmchilkasqoebfpjn", 0, 20, 0);
+ test(S("febhmqtjanokscdirpgl"), "", 1, 0, S::npos);
+ test(S("loakbsqjpcrdhftniegm"), "sqome", 1, 0, S::npos);
+ test(S("reagphsqflbitdcjmkno"), "smfte", 1, 1, 6);
+ test(S("jitlfrqemsdhkopncabg"), "ciboh", 1, 2, 1);
+ test(S("mhtaepscdnrjqgbkifol"), "haois", 1, 4, 1);
+ test(S("tocesrfmnglpbjihqadk"), "abfki", 1, 5, 6);
+ test(S("lpfmctjrhdagneskbqoi"), "frdkocntmq", 1, 0, S::npos);
+ test(S("lsmqaepkdhncirbtjfgo"), "oasbpedlnr", 1, 1, 19);
+ test(S("epoiqmtldrabnkjhcfsg"), "kltqmhgand", 1, 5, 4);
+ test(S("emgasrilpknqojhtbdcf"), "gdtfjchpmr", 1, 9, 1);
+ test(S("hnfiagdpcklrjetqbsom"), "ponmcqblet", 1, 10, 1);
+ test(S("nsdfebgajhmtricpoklq"), "sgphqdnofeiklatbcmjr", 1, 0, S::npos);
+ test(S("atjgfsdlpobmeiqhncrk"), "ljqprsmigtfoneadckbh", 1, 1, 7);
+ test(S("sitodfgnrejlahcbmqkp"), "ligeojhafnkmrcsqtbdp", 1, 10, 1);
+ test(S("fraghmbiceknltjpqosd"), "lsimqfnjarbopedkhcgt", 1, 19, 1);
+ test(S("pmafenlhqtdbkirjsogc"), "abedmfjlghniorcqptks", 1, 20, 1);
+ test(S("pihgmoeqtnakrjslcbfd"), "", 10, 0, S::npos);
+ test(S("gjdkeprctqblnhiafsom"), "hqtoa", 10, 0, S::npos);
+ test(S("mkpnblfdsahrcqijteog"), "cahif", 10, 1, 12);
+ test(S("gckarqnelodfjhmbptis"), "kehis", 10, 2, S::npos);
+ test(S("gqpskidtbclomahnrjfe"), "kdlmh", 10, 4, 10);
+ test(S("pkldjsqrfgitbhmaecno"), "paeql", 10, 5, 15);
+ test(S("aftsijrbeklnmcdqhgop"), "aghoqiefnb", 10, 0, S::npos);
+ test(S("mtlgdrhafjkbiepqnsoc"), "jrbqaikpdo", 10, 1, S::npos);
+ test(S("pqgirnaefthokdmbsclj"), "smjonaeqcl", 10, 5, 11);
+ test(S("kpdbgjmtherlsfcqoina"), "eqbdrkcfah", 10, 9, 10);
+ test(S("jrlbothiknqmdgcfasep"), "kapmsienhf", 10, 10, 11);
+ test(S("mjogldqferckabinptsh"), "jpqotrlenfcsbhkaimdg", 10, 0, S::npos);
+ test(S("apoklnefbhmgqcdrisjt"), "jlbmhnfgtcqprikeados", 10, 1, 18);
+ test(S("ifeopcnrjbhkdgatmqls"), "stgbhfmdaljnpqoicker", 10, 10, 10);
+ test(S("ckqhaiesmjdnrgolbtpf"), "oihcetflbjagdsrkmqpn", 10, 19, 10);
+ test(S("bnlgapfimcoterskqdjh"), "adtclebmnpjsrqfkigoh", 10, 20, 10);
+ test(S("kgdlrobpmjcthqsafeni"), "", 19, 0, S::npos);
+ test(S("dfkechomjapgnslbtqir"), "beafg", 19, 0, S::npos);
+ test(S("rloadknfbqtgmhcsipje"), "iclat", 19, 1, S::npos);
+ test(S("mgjhkolrnadqbpetcifs"), "rkhnf", 19, 2, S::npos);
+ test(S("cmlfakiojdrgtbsphqen"), "clshq", 19, 4, S::npos);
+ test(S("kghbfipeomsntdalrqjc"), "dtcoj", 19, 5, 19);
+ test(S("eldiqckrnmtasbghjfpo"), "rqosnjmfth", 19, 0, S::npos);
+ test(S("abqjcfedgotihlnspkrm"), "siatdfqglh", 19, 1, S::npos);
+ test(S("qfbadrtjsimkolcenhpg"), "mrlshtpgjq", 19, 5, S::npos);
+ test(S("abseghclkjqifmtodrnp"), "adlcskgqjt", 19, 9, S::npos);
+ test(S("ibmsnlrjefhtdokacqpg"), "drshcjknaf", 19, 10, S::npos);
+ test(S("mrkfciqjebaponsthldg"), "etsaqroinghpkjdlfcbm", 19, 0, S::npos);
+ test(S("mjkticdeoqshpalrfbgn"), "sgepdnkqliambtrocfhj", 19, 1, S::npos);
+ test(S("rqnoclbdejgiphtfsakm"), "nlmcjaqgbsortfdihkpe", 19, 10, 19);
+ test(S("plkqbhmtfaeodjcrsing"), "racfnpmosldibqkghjet", 19, 19, 19);
+ test(S("oegalhmstjrfickpbndq"), "fjhdsctkqeiolagrnmbp", 19, 20, 19);
+ test(S("rdtgjcaohpblniekmsfq"), "", 20, 0, S::npos);
+ test(S("ofkqbnjetrmsaidphglc"), "ejanp", 20, 0, S::npos);
+ test(S("grkpahljcftesdmonqib"), "odife", 20, 1, S::npos);
+ test(S("jimlgbhfqkteospardcn"), "okaqd", 20, 2, S::npos);
+ test(S("gftenihpmslrjkqadcob"), "lcdbi", 20, 4, S::npos);
+ test(S("bmhldogtckrfsanijepq"), "fsqbj", 20, 5, S::npos);
+ test(S("nfqkrpjdesabgtlcmoih"), "bigdomnplq", 20, 0, S::npos);
+ test(S("focalnrpiqmdkstehbjg"), "apiblotgcd", 20, 1, S::npos);
+ test(S("rhqdspkmebiflcotnjga"), "acfhdenops", 20, 5, S::npos);
+ test(S("rahdtmsckfboqlpniegj"), "jopdeamcrk", 20, 9, S::npos);
+ test(S("fbkeiopclstmdqranjhg"), "trqncbkgmh", 20, 10, S::npos);
+ test(S("lifhpdgmbconstjeqark"), "tomglrkencbsfjqpihda", 20, 0, S::npos);
+}
+
+template <class S>
+void test3()
+{
+ test(S("pboqganrhedjmltsicfk"), "gbkhdnpoietfcmrslajq", 20, 1, S::npos);
+ test(S("klchabsimetjnqgorfpd"), "rtfnmbsglkjaichoqedp", 20, 10, S::npos);
+ test(S("sirfgmjqhctndbklaepo"), "ohkmdpfqbsacrtjnlgei", 20, 19, S::npos);
+ test(S("rlbdsiceaonqjtfpghkm"), "dlbrteoisgphmkncajfq", 20, 20, S::npos);
+ test(S("ecgdanriptblhjfqskom"), "", 21, 0, S::npos);
+ test(S("fdmiarlpgcskbhoteqjn"), "sjrlo", 21, 0, S::npos);
+ test(S("rlbstjqopignecmfadkh"), "qjpor", 21, 1, S::npos);
+ test(S("grjpqmbshektdolcafni"), "odhfn", 21, 2, S::npos);
+ test(S("sakfcohtqnibprjmlged"), "qtfin", 21, 4, S::npos);
+ test(S("mjtdglasihqpocebrfkn"), "hpqfo", 21, 5, S::npos);
+ test(S("okaplfrntghqbmeicsdj"), "fabmertkos", 21, 0, S::npos);
+ test(S("sahngemrtcjidqbklfpo"), "brqtgkmaej", 21, 1, S::npos);
+ test(S("dlmsipcnekhbgoaftqjr"), "nfrdeihsgl", 21, 5, S::npos);
+ test(S("ahegrmqnoiklpfsdbcjt"), "hlfrosekpi", 21, 9, S::npos);
+ test(S("hdsjbnmlegtkqripacof"), "atgbkrjdsm", 21, 10, S::npos);
+ test(S("pcnedrfjihqbalkgtoms"), "blnrptjgqmaifsdkhoec", 21, 0, S::npos);
+ test(S("qjidealmtpskrbfhocng"), "ctpmdahebfqjgknloris", 21, 1, S::npos);
+ test(S("qeindtagmokpfhsclrbj"), "apnkeqthrmlbfodiscgj", 21, 10, S::npos);
+ test(S("kpfegbjhsrnodltqciam"), "jdgictpframeoqlsbknh", 21, 19, S::npos);
+ test(S("hnbrcplsjfgiktoedmaq"), "qprlsfojamgndekthibc", 21, 20, S::npos);
+}
+
+int main()
+{
+ {
+ typedef std::experimental::string_view S;
+ test0<S>();
+ test1<S>();
+ test2<S>();
+ test3<S>();
+ }
+
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::experimental::basic_string_view<char, constexpr_char_traits<char>> SV;
+ constexpr SV sv1;
+ constexpr SV sv2 { "abcde", 5 };
+
+ static_assert (sv1.find_first_of( "", 0, 0) == SV::npos, "" );
+ static_assert (sv1.find_first_of( "irkhs", 0, 5) == SV::npos, "" );
+ static_assert (sv2.find_first_of( "", 0, 0) == SV::npos, "" );
+ static_assert (sv2.find_first_of( "gfsrt", 0, 5) == SV::npos, "" );
+ static_assert (sv2.find_first_of( "lecar", 0, 5) == 0, "" );
+ }
+#endif
+}
diff --git a/test/std/experimental/string.view/string.view.find/find_first_of_string_view_size.pass.cpp b/test/std/experimental/string.view/string.view.find/find_first_of_string_view_size.pass.cpp
new file mode 100644
index 000000000000..fddd47171dd8
--- /dev/null
+++ b/test/std/experimental/string.view/string.view.find/find_first_of_string_view_size.pass.cpp
@@ -0,0 +1,148 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type find_first_of(const basic_string_view& str, size_type pos = 0) const;
+
+#include <experimental/string_view>
+#include <cassert>
+
+template <class S>
+void
+test(const S& s, const S& str, typename S::size_type pos, typename S::size_type x)
+{
+ assert(s.find_first_of(str, pos) == x);
+ if (x != S::npos)
+ assert(pos <= x && x < s.size());
+}
+
+template <class S>
+void
+test(const S& s, const S& str, typename S::size_type x)
+{
+ assert(s.find_first_of(str) == x);
+ if (x != S::npos)
+ assert(x < s.size());
+}
+
+template <class S>
+void test0()
+{
+ test(S(""), S(""), 0, S::npos);
+ test(S(""), S("laenf"), 0, S::npos);
+ test(S(""), S("pqlnkmbdjo"), 0, S::npos);
+ test(S(""), S("qkamfogpnljdcshbreti"), 0, S::npos);
+ test(S(""), S(""), 1, S::npos);
+ test(S(""), S("bjaht"), 1, S::npos);
+ test(S(""), S("hjlcmgpket"), 1, S::npos);
+ test(S(""), S("htaobedqikfplcgjsmrn"), 1, S::npos);
+ test(S("fodgq"), S(""), 0, S::npos);
+ test(S("qanej"), S("dfkap"), 0, 1);
+ test(S("clbao"), S("ihqrfebgad"), 0, 2);
+ test(S("mekdn"), S("ngtjfcalbseiqrphmkdo"), 0, 0);
+ test(S("srdfq"), S(""), 1, S::npos);
+ test(S("oemth"), S("ikcrq"), 1, S::npos);
+ test(S("cdaih"), S("dmajblfhsg"), 1, 1);
+ test(S("qohtk"), S("oqftjhdmkgsblacenirp"), 1, 1);
+ test(S("cshmd"), S(""), 2, S::npos);
+ test(S("lhcdo"), S("oebqi"), 2, 4);
+ test(S("qnsoh"), S("kojhpmbsfe"), 2, 2);
+ test(S("pkrof"), S("acbsjqogpltdkhinfrem"), 2, 2);
+ test(S("fmtsp"), S(""), 4, S::npos);
+ test(S("khbpm"), S("aobjd"), 4, S::npos);
+ test(S("pbsji"), S("pcbahntsje"), 4, S::npos);
+ test(S("mprdj"), S("fhepcrntkoagbmldqijs"), 4, 4);
+ test(S("eqmpa"), S(""), 5, S::npos);
+ test(S("omigs"), S("kocgb"), 5, S::npos);
+ test(S("onmje"), S("fbslrjiqkm"), 5, S::npos);
+ test(S("oqmrj"), S("jeidpcmalhfnqbgtrsko"), 5, S::npos);
+ test(S("schfa"), S(""), 6, S::npos);
+ test(S("igdsc"), S("qngpd"), 6, S::npos);
+ test(S("brqgo"), S("rodhqklgmb"), 6, S::npos);
+ test(S("tnrph"), S("thdjgafrlbkoiqcspmne"), 6, S::npos);
+ test(S("hcjitbfapl"), S(""), 0, S::npos);
+ test(S("daiprenocl"), S("ashjd"), 0, 0);
+ test(S("litpcfdghe"), S("mgojkldsqh"), 0, 0);
+ test(S("aidjksrolc"), S("imqnaghkfrdtlopbjesc"), 0, 0);
+ test(S("qpghtfbaji"), S(""), 1, S::npos);
+ test(S("gfshlcmdjr"), S("nadkh"), 1, 3);
+ test(S("nkodajteqp"), S("ofdrqmkebl"), 1, 1);
+ test(S("gbmetiprqd"), S("bdfjqgatlksriohemnpc"), 1, 1);
+ test(S("crnklpmegd"), S(""), 5, S::npos);
+ test(S("jsbtafedoc"), S("prqgn"), 5, S::npos);
+ test(S("qnmodrtkeb"), S("pejafmnokr"), 5, 5);
+ test(S("cpebqsfmnj"), S("odnqkgijrhabfmcestlp"), 5, 5);
+ test(S("lmofqdhpki"), S(""), 9, S::npos);
+ test(S("hnefkqimca"), S("rtjpa"), 9, 9);
+ test(S("drtasbgmfp"), S("ktsrmnqagd"), 9, S::npos);
+ test(S("lsaijeqhtr"), S("rtdhgcisbnmoaqkfpjle"), 9, 9);
+ test(S("elgofjmbrq"), S(""), 10, S::npos);
+ test(S("mjqdgalkpc"), S("dplqa"), 10, S::npos);
+ test(S("kthqnfcerm"), S("dkacjoptns"), 10, S::npos);
+ test(S("dfsjhanorc"), S("hqfimtrgnbekpdcsjalo"), 10, S::npos);
+ test(S("eqsgalomhb"), S(""), 11, S::npos);
+ test(S("akiteljmoh"), S("lofbc"), 11, S::npos);
+ test(S("hlbdfreqjo"), S("astoegbfpn"), 11, S::npos);
+ test(S("taqobhlerg"), S("pdgreqomsncafklhtibj"), 11, S::npos);
+ test(S("snafbdlghrjkpqtoceim"), S(""), 0, S::npos);
+ test(S("aemtbrgcklhndjisfpoq"), S("lbtqd"), 0, 3);
+ test(S("pnracgfkjdiholtbqsem"), S("tboimldpjh"), 0, 0);
+ test(S("dicfltehbsgrmojnpkaq"), S("slcerthdaiqjfnobgkpm"), 0, 0);
+ test(S("jlnkraeodhcspfgbqitm"), S(""), 1, S::npos);
+ test(S("lhosrngtmfjikbqpcade"), S("aqibs"), 1, 3);
+ test(S("rbtaqjhgkneisldpmfoc"), S("gtfblmqinc"), 1, 1);
+ test(S("gpifsqlrdkbonjtmheca"), S("mkqpbtdalgniorhfescj"), 1, 1);
+ test(S("hdpkobnsalmcfijregtq"), S(""), 10, S::npos);
+ test(S("jtlshdgqaiprkbcoenfm"), S("pblas"), 10, 10);
+ test(S("fkdrbqltsgmcoiphneaj"), S("arosdhcfme"), 10, 10);
+ test(S("crsplifgtqedjohnabmk"), S("blkhjeogicatqfnpdmsr"), 10, 10);
+ test(S("niptglfbosehkamrdqcj"), S(""), 19, S::npos);
+ test(S("copqdhstbingamjfkler"), S("djkqc"), 19, S::npos);
+ test(S("mrtaefilpdsgocnhqbjk"), S("lgokshjtpb"), 19, 19);
+ test(S("kojatdhlcmigpbfrqnes"), S("bqjhtkfepimcnsgrlado"), 19, 19);
+ test(S("eaintpchlqsbdgrkjofm"), S(""), 20, S::npos);
+ test(S("gjnhidfsepkrtaqbmclo"), S("nocfa"), 20, S::npos);
+ test(S("spocfaktqdbiejlhngmr"), S("bgtajmiedc"), 20, S::npos);
+ test(S("rphmlekgfscndtaobiqj"), S("lsckfnqgdahejiopbtmr"), 20, S::npos);
+ test(S("liatsqdoegkmfcnbhrpj"), S(""), 21, S::npos);
+ test(S("binjagtfldkrspcomqeh"), S("gfsrt"), 21, S::npos);
+ test(S("latkmisecnorjbfhqpdg"), S("pfsocbhjtm"), 21, S::npos);
+ test(S("lecfratdjkhnsmqpoigb"), S("tpflmdnoicjgkberhqsa"), 21, S::npos);
+}
+
+template <class S>
+void test1()
+{
+ test(S(""), S(""), S::npos);
+ test(S(""), S("laenf"), S::npos);
+ test(S(""), S("pqlnkmbdjo"), S::npos);
+ test(S(""), S("qkamfogpnljdcshbreti"), S::npos);
+ test(S("nhmko"), S(""), S::npos);
+ test(S("lahfb"), S("irkhs"), 2);
+ test(S("gmfhd"), S("kantesmpgj"), 0);
+ test(S("odaft"), S("oknlrstdpiqmjbaghcfe"), 0);
+ test(S("eolhfgpjqk"), S(""), S::npos);
+ test(S("nbatdlmekr"), S("bnrpe"), 0);
+ test(S("jdmciepkaq"), S("jtdaefblso"), 0);
+ test(S("hkbgspoflt"), S("oselktgbcapndfjihrmq"), 0);
+ test(S("gprdcokbnjhlsfmtieqa"), S(""), S::npos);
+ test(S("qjghlnftcaismkropdeb"), S("bjaht"), 1);
+ test(S("pnalfrdtkqcmojiesbhg"), S("hjlcmgpket"), 0);
+ test(S("pniotcfrhqsmgdkjbael"), S("htaobedqikfplcgjsmrn"), 0);
+}
+
+int main()
+{
+ {
+ typedef std::experimental::string_view S;
+ test0<S>();
+ test1<S>();
+ }
+}
diff --git a/test/std/experimental/string.view/string.view.find/find_last_not_of_char_size.pass.cpp b/test/std/experimental/string.view/string.view.find/find_last_not_of_char_size.pass.cpp
new file mode 100644
index 000000000000..ed1a35e91845
--- /dev/null
+++ b/test/std/experimental/string.view/string.view.find/find_last_not_of_char_size.pass.cpp
@@ -0,0 +1,82 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string_view>
+
+// const size_type find_last_not_of(charT c, size_type pos = npos) const;
+
+#include <experimental/string_view>
+#include <cassert>
+
+#include "constexpr_char_traits.hpp"
+
+template <class S>
+void
+test(const S& s, typename S::value_type c, typename S::size_type pos,
+ typename S::size_type x)
+{
+ assert(s.find_last_not_of(c, pos) == x);
+ if (x != S::npos)
+ assert(x <= pos && x < s.size());
+}
+
+template <class S>
+void
+test(const S& s, typename S::value_type c, typename S::size_type x)
+{
+ assert(s.find_last_not_of(c) == x);
+ if (x != S::npos)
+ assert(x < s.size());
+}
+
+int main()
+{
+ {
+ typedef std::experimental::string_view S;
+ test(S(""), 'i', 0, S::npos);
+ test(S(""), 'i', 1, S::npos);
+ test(S("kitcj"), 'i', 0, 0);
+ test(S("qkamf"), 'i', 1, 1);
+ test(S("nhmko"), 'i', 2, 2);
+ test(S("tpsaf"), 'i', 4, 4);
+ test(S("lahfb"), 'i', 5, 4);
+ test(S("irkhs"), 'i', 6, 4);
+ test(S("gmfhdaipsr"), 'i', 0, 0);
+ test(S("kantesmpgj"), 'i', 1, 1);
+ test(S("odaftiegpm"), 'i', 5, 4);
+ test(S("oknlrstdpi"), 'i', 9, 8);
+ test(S("eolhfgpjqk"), 'i', 10, 9);
+ test(S("pcdrofikas"), 'i', 11, 9);
+ test(S("nbatdlmekrgcfqsophij"), 'i', 0, 0);
+ test(S("bnrpehidofmqtcksjgla"), 'i', 1, 1);
+ test(S("jdmciepkaqgotsrfnhlb"), 'i', 10, 10);
+ test(S("jtdaefblsokrmhpgcnqi"), 'i', 19, 18);
+ test(S("hkbgspofltajcnedqmri"), 'i', 20, 18);
+ test(S("oselktgbcapndfjihrmq"), 'i', 21, 19);
+
+ test(S(""), 'i', S::npos);
+ test(S("csope"), 'i', 4);
+ test(S("gfsmthlkon"), 'i', 9);
+ test(S("laenfsbridchgotmkqpj"), 'i', 19);
+ }
+
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::experimental::basic_string_view<char, constexpr_char_traits<char>> SV;
+ constexpr SV sv1;
+ constexpr SV sv2 { "abcde", 5 };
+
+ static_assert (sv1.find_last_not_of( 'i', 0 ) == SV::npos, "" );
+ static_assert (sv1.find_last_not_of( 'i', 1 ) == SV::npos, "" );
+ static_assert (sv2.find_last_not_of( 'a', 0 ) == SV::npos, "" );
+ static_assert (sv2.find_last_not_of( 'a', 1 ) == 1, "" );
+ static_assert (sv2.find_last_not_of( 'e', 5 ) == 3, "" );
+ }
+#endif
+}
diff --git a/test/std/experimental/string.view/string.view.find/find_last_not_of_pointer_size.pass.cpp b/test/std/experimental/string.view/string.view.find/find_last_not_of_pointer_size.pass.cpp
new file mode 100644
index 000000000000..e07c4f361da3
--- /dev/null
+++ b/test/std/experimental/string.view/string.view.find/find_last_not_of_pointer_size.pass.cpp
@@ -0,0 +1,165 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string_view>
+
+// constexpr size_type find_last_not_of(const charT* s, size_type pos = npos) const;
+
+#include <experimental/string_view>
+#include <cassert>
+
+#include "constexpr_char_traits.hpp"
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type pos,
+ typename S::size_type x)
+{
+ assert(s.find_last_not_of(str, pos) == x);
+ if (x != S::npos)
+ assert(x <= pos && x < s.size());
+}
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type x)
+{
+ assert(s.find_last_not_of(str) == x);
+ if (x != S::npos)
+ assert(x < s.size());
+}
+
+template <class S>
+void test0()
+{
+ test(S(""), "", 0, S::npos);
+ test(S(""), "laenf", 0, S::npos);
+ test(S(""), "pqlnkmbdjo", 0, S::npos);
+ test(S(""), "qkamfogpnljdcshbreti", 0, S::npos);
+ test(S(""), "", 1, S::npos);
+ test(S(""), "bjaht", 1, S::npos);
+ test(S(""), "hjlcmgpket", 1, S::npos);
+ test(S(""), "htaobedqikfplcgjsmrn", 1, S::npos);
+ test(S("fodgq"), "", 0, 0);
+ test(S("qanej"), "dfkap", 0, 0);
+ test(S("clbao"), "ihqrfebgad", 0, 0);
+ test(S("mekdn"), "ngtjfcalbseiqrphmkdo", 0, S::npos);
+ test(S("srdfq"), "", 1, 1);
+ test(S("oemth"), "ikcrq", 1, 1);
+ test(S("cdaih"), "dmajblfhsg", 1, 0);
+ test(S("qohtk"), "oqftjhdmkgsblacenirp", 1, S::npos);
+ test(S("cshmd"), "", 2, 2);
+ test(S("lhcdo"), "oebqi", 2, 2);
+ test(S("qnsoh"), "kojhpmbsfe", 2, 1);
+ test(S("pkrof"), "acbsjqogpltdkhinfrem", 2, S::npos);
+ test(S("fmtsp"), "", 4, 4);
+ test(S("khbpm"), "aobjd", 4, 4);
+ test(S("pbsji"), "pcbahntsje", 4, 4);
+ test(S("mprdj"), "fhepcrntkoagbmldqijs", 4, S::npos);
+ test(S("eqmpa"), "", 5, 4);
+ test(S("omigs"), "kocgb", 5, 4);
+ test(S("onmje"), "fbslrjiqkm", 5, 4);
+ test(S("oqmrj"), "jeidpcmalhfnqbgtrsko", 5, S::npos);
+ test(S("schfa"), "", 6, 4);
+ test(S("igdsc"), "qngpd", 6, 4);
+ test(S("brqgo"), "rodhqklgmb", 6, S::npos);
+ test(S("tnrph"), "thdjgafrlbkoiqcspmne", 6, S::npos);
+ test(S("hcjitbfapl"), "", 0, 0);
+ test(S("daiprenocl"), "ashjd", 0, S::npos);
+ test(S("litpcfdghe"), "mgojkldsqh", 0, S::npos);
+ test(S("aidjksrolc"), "imqnaghkfrdtlopbjesc", 0, S::npos);
+ test(S("qpghtfbaji"), "", 1, 1);
+ test(S("gfshlcmdjr"), "nadkh", 1, 1);
+ test(S("nkodajteqp"), "ofdrqmkebl", 1, 0);
+ test(S("gbmetiprqd"), "bdfjqgatlksriohemnpc", 1, S::npos);
+ test(S("crnklpmegd"), "", 5, 5);
+ test(S("jsbtafedoc"), "prqgn", 5, 5);
+ test(S("qnmodrtkeb"), "pejafmnokr", 5, 4);
+ test(S("cpebqsfmnj"), "odnqkgijrhabfmcestlp", 5, S::npos);
+ test(S("lmofqdhpki"), "", 9, 9);
+ test(S("hnefkqimca"), "rtjpa", 9, 8);
+ test(S("drtasbgmfp"), "ktsrmnqagd", 9, 9);
+ test(S("lsaijeqhtr"), "rtdhgcisbnmoaqkfpjle", 9, S::npos);
+ test(S("elgofjmbrq"), "", 10, 9);
+ test(S("mjqdgalkpc"), "dplqa", 10, 9);
+ test(S("kthqnfcerm"), "dkacjoptns", 10, 9);
+ test(S("dfsjhanorc"), "hqfimtrgnbekpdcsjalo", 10, S::npos);
+ test(S("eqsgalomhb"), "", 11, 9);
+ test(S("akiteljmoh"), "lofbc", 11, 9);
+ test(S("hlbdfreqjo"), "astoegbfpn", 11, 8);
+ test(S("taqobhlerg"), "pdgreqomsncafklhtibj", 11, S::npos);
+ test(S("snafbdlghrjkpqtoceim"), "", 0, 0);
+ test(S("aemtbrgcklhndjisfpoq"), "lbtqd", 0, 0);
+ test(S("pnracgfkjdiholtbqsem"), "tboimldpjh", 0, S::npos);
+ test(S("dicfltehbsgrmojnpkaq"), "slcerthdaiqjfnobgkpm", 0, S::npos);
+ test(S("jlnkraeodhcspfgbqitm"), "", 1, 1);
+ test(S("lhosrngtmfjikbqpcade"), "aqibs", 1, 1);
+ test(S("rbtaqjhgkneisldpmfoc"), "gtfblmqinc", 1, 0);
+ test(S("gpifsqlrdkbonjtmheca"), "mkqpbtdalgniorhfescj", 1, S::npos);
+ test(S("hdpkobnsalmcfijregtq"), "", 10, 10);
+ test(S("jtlshdgqaiprkbcoenfm"), "pblas", 10, 9);
+ test(S("fkdrbqltsgmcoiphneaj"), "arosdhcfme", 10, 9);
+ test(S("crsplifgtqedjohnabmk"), "blkhjeogicatqfnpdmsr", 10, S::npos);
+ test(S("niptglfbosehkamrdqcj"), "", 19, 19);
+ test(S("copqdhstbingamjfkler"), "djkqc", 19, 19);
+ test(S("mrtaefilpdsgocnhqbjk"), "lgokshjtpb", 19, 16);
+ test(S("kojatdhlcmigpbfrqnes"), "bqjhtkfepimcnsgrlado", 19, S::npos);
+ test(S("eaintpchlqsbdgrkjofm"), "", 20, 19);
+ test(S("gjnhidfsepkrtaqbmclo"), "nocfa", 20, 18);
+ test(S("spocfaktqdbiejlhngmr"), "bgtajmiedc", 20, 19);
+ test(S("rphmlekgfscndtaobiqj"), "lsckfnqgdahejiopbtmr", 20, S::npos);
+ test(S("liatsqdoegkmfcnbhrpj"), "", 21, 19);
+ test(S("binjagtfldkrspcomqeh"), "gfsrt", 21, 19);
+ test(S("latkmisecnorjbfhqpdg"), "pfsocbhjtm", 21, 19);
+ test(S("lecfratdjkhnsmqpoigb"), "tpflmdnoicjgkberhqsa", 21, S::npos);
+}
+
+template <class S>
+void test1()
+{
+ test(S(""), "", S::npos);
+ test(S(""), "laenf", S::npos);
+ test(S(""), "pqlnkmbdjo", S::npos);
+ test(S(""), "qkamfogpnljdcshbreti", S::npos);
+ test(S("nhmko"), "", 4);
+ test(S("lahfb"), "irkhs", 4);
+ test(S("gmfhd"), "kantesmpgj", 4);
+ test(S("odaft"), "oknlrstdpiqmjbaghcfe", S::npos);
+ test(S("eolhfgpjqk"), "", 9);
+ test(S("nbatdlmekr"), "bnrpe", 8);
+ test(S("jdmciepkaq"), "jtdaefblso", 9);
+ test(S("hkbgspoflt"), "oselktgbcapndfjihrmq", S::npos);
+ test(S("gprdcokbnjhlsfmtieqa"), "", 19);
+ test(S("qjghlnftcaismkropdeb"), "bjaht", 18);
+ test(S("pnalfrdtkqcmojiesbhg"), "hjlcmgpket", 17);
+ test(S("pniotcfrhqsmgdkjbael"), "htaobedqikfplcgjsmrn", S::npos);
+}
+
+int main()
+{
+ {
+ typedef std::experimental::string_view S;
+ test0<S>();
+ test1<S>();
+ }
+
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::experimental::basic_string_view<char, constexpr_char_traits<char>> SV;
+ constexpr SV sv1;
+ constexpr SV sv2 { "abcde", 5 };
+
+ static_assert (sv1.find_last_not_of( "", 0) == SV::npos, "" );
+ static_assert (sv1.find_last_not_of( "irkhs", 5) == SV::npos, "" );
+ static_assert (sv2.find_last_not_of( "", 0) == 0, "" );
+ static_assert (sv2.find_last_not_of( "gfsrt", 5) == 4, "" );
+ static_assert (sv2.find_last_not_of( "lecar", 5) == 3, "" );
+ }
+#endif
+}
diff --git a/test/std/experimental/string.view/string.view.find/find_last_not_of_pointer_size_size.pass.cpp b/test/std/experimental/string.view/string.view.find/find_last_not_of_pointer_size_size.pass.cpp
new file mode 100644
index 000000000000..3ddf03365060
--- /dev/null
+++ b/test/std/experimental/string.view/string.view.find/find_last_not_of_pointer_size_size.pass.cpp
@@ -0,0 +1,392 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// constexpr size_type find_last_not_of(const charT* s, size_type pos, size_type n) const;
+
+#include <experimental/string_view>
+#include <cassert>
+
+#include "constexpr_char_traits.hpp"
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type pos,
+ typename S::size_type n, typename S::size_type x)
+{
+ assert(s.find_last_not_of(str, pos, n) == x);
+ if (x != S::npos)
+ assert(x <= pos && x < s.size());
+}
+
+template <class S>
+void test0()
+{
+ test(S(""), "", 0, 0, S::npos);
+ test(S(""), "irkhs", 0, 0, S::npos);
+ test(S(""), "kante", 0, 1, S::npos);
+ test(S(""), "oknlr", 0, 2, S::npos);
+ test(S(""), "pcdro", 0, 4, S::npos);
+ test(S(""), "bnrpe", 0, 5, S::npos);
+ test(S(""), "jtdaefblso", 0, 0, S::npos);
+ test(S(""), "oselktgbca", 0, 1, S::npos);
+ test(S(""), "eqgaplhckj", 0, 5, S::npos);
+ test(S(""), "bjahtcmnlp", 0, 9, S::npos);
+ test(S(""), "hjlcmgpket", 0, 10, S::npos);
+ test(S(""), "htaobedqikfplcgjsmrn", 0, 0, S::npos);
+ test(S(""), "hpqiarojkcdlsgnmfetb", 0, 1, S::npos);
+ test(S(""), "dfkaprhjloqetcsimnbg", 0, 10, S::npos);
+ test(S(""), "ihqrfebgadntlpmjksoc", 0, 19, S::npos);
+ test(S(""), "ngtjfcalbseiqrphmkdo", 0, 20, S::npos);
+ test(S(""), "", 1, 0, S::npos);
+ test(S(""), "lbtqd", 1, 0, S::npos);
+ test(S(""), "tboim", 1, 1, S::npos);
+ test(S(""), "slcer", 1, 2, S::npos);
+ test(S(""), "cbjfs", 1, 4, S::npos);
+ test(S(""), "aqibs", 1, 5, S::npos);
+ test(S(""), "gtfblmqinc", 1, 0, S::npos);
+ test(S(""), "mkqpbtdalg", 1, 1, S::npos);
+ test(S(""), "kphatlimcd", 1, 5, S::npos);
+ test(S(""), "pblasqogic", 1, 9, S::npos);
+ test(S(""), "arosdhcfme", 1, 10, S::npos);
+ test(S(""), "blkhjeogicatqfnpdmsr", 1, 0, S::npos);
+ test(S(""), "bmhineprjcoadgstflqk", 1, 1, S::npos);
+ test(S(""), "djkqcmetslnghpbarfoi", 1, 10, S::npos);
+ test(S(""), "lgokshjtpbemarcdqnfi", 1, 19, S::npos);
+ test(S(""), "bqjhtkfepimcnsgrlado", 1, 20, S::npos);
+ test(S("eaint"), "", 0, 0, 0);
+ test(S("binja"), "gfsrt", 0, 0, 0);
+ test(S("latkm"), "pfsoc", 0, 1, 0);
+ test(S("lecfr"), "tpflm", 0, 2, 0);
+ test(S("eqkst"), "sgkec", 0, 4, S::npos);
+ test(S("cdafr"), "romds", 0, 5, 0);
+ test(S("prbhe"), "qhjistlgmr", 0, 0, 0);
+ test(S("lbisk"), "pedfirsglo", 0, 1, 0);
+ test(S("hrlpd"), "aqcoslgrmk", 0, 5, 0);
+ test(S("ehmja"), "dabckmepqj", 0, 9, S::npos);
+ test(S("mhqgd"), "pqscrjthli", 0, 10, 0);
+ test(S("tgklq"), "kfphdcsjqmobliagtren", 0, 0, 0);
+ test(S("bocjs"), "rokpefncljibsdhqtagm", 0, 1, 0);
+ test(S("grbsd"), "afionmkphlebtcjqsgrd", 0, 10, 0);
+ test(S("ofjqr"), "aenmqplidhkofrjbctsg", 0, 19, S::npos);
+ test(S("btlfi"), "osjmbtcadhiklegrpqnf", 0, 20, S::npos);
+ test(S("clrgb"), "", 1, 0, 1);
+ test(S("tjmek"), "osmia", 1, 0, 1);
+ test(S("bgstp"), "ckonl", 1, 1, 1);
+ test(S("hstrk"), "ilcaj", 1, 2, 1);
+ test(S("kmspj"), "lasiq", 1, 4, 1);
+ test(S("tjboh"), "kfqmr", 1, 5, 1);
+ test(S("ilbcj"), "klnitfaobg", 1, 0, 1);
+ test(S("jkngf"), "gjhmdlqikp", 1, 1, 1);
+ test(S("gfcql"), "skbgtahqej", 1, 5, 1);
+ test(S("dqtlg"), "bjsdgtlpkf", 1, 9, 1);
+ test(S("bthpg"), "bjgfmnlkio", 1, 10, 1);
+ test(S("dgsnq"), "lbhepotfsjdqigcnamkr", 1, 0, 1);
+ test(S("rmfhp"), "tebangckmpsrqdlfojhi", 1, 1, 1);
+ test(S("jfdam"), "joflqbdkhtegimscpanr", 1, 10, S::npos);
+ test(S("edapb"), "adpmcohetfbsrjinlqkg", 1, 19, S::npos);
+ test(S("brfsm"), "iacldqjpfnogbsrhmetk", 1, 20, S::npos);
+ test(S("ndrhl"), "", 2, 0, 2);
+ test(S("mrecp"), "otkgb", 2, 0, 2);
+ test(S("qlasf"), "cqsjl", 2, 1, 2);
+ test(S("smaqd"), "dpifl", 2, 2, 2);
+ test(S("hjeni"), "oapht", 2, 4, 2);
+ test(S("ocmfj"), "cifts", 2, 5, 2);
+ test(S("hmftq"), "nmsckbgalo", 2, 0, 2);
+ test(S("fklad"), "tpksqhamle", 2, 1, 2);
+ test(S("dirnm"), "tpdrchmkji", 2, 5, 1);
+ test(S("hrgdc"), "ijagfkblst", 2, 9, 1);
+ test(S("ifakg"), "kpocsignjb", 2, 10, 2);
+ test(S("ebrgd"), "pecqtkjsnbdrialgmohf", 2, 0, 2);
+ test(S("rcjml"), "aiortphfcmkjebgsndql", 2, 1, 2);
+ test(S("peqmt"), "sdbkeamglhipojqftrcn", 2, 10, 2);
+ test(S("frehn"), "ljqncehgmfktroapidbs", 2, 19, S::npos);
+ test(S("tqolf"), "rtcfodilamkbenjghqps", 2, 20, S::npos);
+ test(S("cjgao"), "", 4, 0, 4);
+ test(S("kjplq"), "mabns", 4, 0, 4);
+ test(S("herni"), "bdnrp", 4, 1, 4);
+ test(S("tadrb"), "scidp", 4, 2, 4);
+ test(S("pkfeo"), "agbjl", 4, 4, 4);
+ test(S("hoser"), "jfmpr", 4, 5, 3);
+ test(S("kgrsp"), "rbpefghsmj", 4, 0, 4);
+ test(S("pgejb"), "apsfntdoqc", 4, 1, 4);
+ test(S("thlnq"), "ndkjeisgcl", 4, 5, 4);
+ test(S("nbmit"), "rnfpqatdeo", 4, 9, 3);
+ test(S("jgmib"), "bntjlqrfik", 4, 10, 2);
+ test(S("ncrfj"), "kcrtmpolnaqejghsfdbi", 4, 0, 4);
+ test(S("ncsik"), "lobheanpkmqidsrtcfgj", 4, 1, 4);
+ test(S("sgbfh"), "athdkljcnreqbgpmisof", 4, 10, 3);
+ test(S("dktbn"), "qkdmjialrscpbhefgont", 4, 19, 2);
+ test(S("fthqm"), "dmasojntqleribkgfchp", 4, 20, S::npos);
+ test(S("klopi"), "", 5, 0, 4);
+ test(S("dajhn"), "psthd", 5, 0, 4);
+ test(S("jbgno"), "rpmjd", 5, 1, 4);
+ test(S("hkjae"), "dfsmk", 5, 2, 4);
+}
+
+template <class S>
+void test1()
+{
+ test(S("gbhqo"), "skqne", 5, 4, 4);
+ test(S("ktdor"), "kipnf", 5, 5, 4);
+ test(S("ldprn"), "hmrnqdgifl", 5, 0, 4);
+ test(S("egmjk"), "fsmjcdairn", 5, 1, 4);
+ test(S("armql"), "pcdgltbrfj", 5, 5, 3);
+ test(S("cdhjo"), "aekfctpirg", 5, 9, 4);
+ test(S("jcons"), "ledihrsgpf", 5, 10, 3);
+ test(S("cbrkp"), "mqcklahsbtirgopefndj", 5, 0, 4);
+ test(S("fhgna"), "kmlthaoqgecrnpdbjfis", 5, 1, 4);
+ test(S("ejfcd"), "sfhbamcdptojlkrenqgi", 5, 10, 1);
+ test(S("kqjhe"), "pbniofmcedrkhlstgaqj", 5, 19, 2);
+ test(S("pbdjl"), "mongjratcskbhqiepfdl", 5, 20, S::npos);
+ test(S("gajqn"), "", 6, 0, 4);
+ test(S("stedk"), "hrnat", 6, 0, 4);
+ test(S("tjkaf"), "gsqdt", 6, 1, 4);
+ test(S("dthpe"), "bspkd", 6, 2, 4);
+ test(S("klhde"), "ohcmb", 6, 4, 4);
+ test(S("bhlki"), "heatr", 6, 5, 4);
+ test(S("lqmoh"), "pmblckedfn", 6, 0, 4);
+ test(S("mtqin"), "aceqmsrbik", 6, 1, 4);
+ test(S("dpqbr"), "lmbtdehjrn", 6, 5, 4);
+ test(S("kdhmo"), "teqmcrlgib", 6, 9, 4);
+ test(S("jblqp"), "njolbmspac", 6, 10, 3);
+ test(S("qmjgl"), "pofnhidklamecrbqjgst", 6, 0, 4);
+ test(S("rothp"), "jbhckmtgrqnosafedpli", 6, 1, 4);
+ test(S("ghknq"), "dobntpmqklicsahgjerf", 6, 10, 1);
+ test(S("eopfi"), "tpdshainjkbfoemlrgcq", 6, 19, S::npos);
+ test(S("dsnmg"), "oldpfgeakrnitscbjmqh", 6, 20, S::npos);
+ test(S("jnkrfhotgl"), "", 0, 0, 0);
+ test(S("dltjfngbko"), "rqegt", 0, 0, 0);
+ test(S("bmjlpkiqde"), "dashm", 0, 1, 0);
+ test(S("skrflobnqm"), "jqirk", 0, 2, 0);
+ test(S("jkpldtshrm"), "rckeg", 0, 4, 0);
+ test(S("ghasdbnjqo"), "jscie", 0, 5, 0);
+ test(S("igrkhpbqjt"), "efsphndliq", 0, 0, 0);
+ test(S("ikthdgcamf"), "gdicosleja", 0, 1, 0);
+ test(S("pcofgeniam"), "qcpjibosfl", 0, 5, S::npos);
+ test(S("rlfjgesqhc"), "lrhmefnjcq", 0, 9, S::npos);
+ test(S("itphbqsker"), "dtablcrseo", 0, 10, 0);
+ test(S("skjafcirqm"), "apckjsftedbhgomrnilq", 0, 0, 0);
+ test(S("tcqomarsfd"), "pcbrgflehjtiadnsokqm", 0, 1, 0);
+ test(S("rocfeldqpk"), "nsiadegjklhobrmtqcpf", 0, 10, 0);
+ test(S("cfpegndlkt"), "cpmajdqnolikhgsbretf", 0, 19, S::npos);
+ test(S("fqbtnkeasj"), "jcflkntmgiqrphdosaeb", 0, 20, S::npos);
+ test(S("shbcqnmoar"), "", 1, 0, 1);
+ test(S("bdoshlmfin"), "ontrs", 1, 0, 1);
+ test(S("khfrebnsgq"), "pfkna", 1, 1, 1);
+ test(S("getcrsaoji"), "ekosa", 1, 2, 0);
+ test(S("fjiknedcpq"), "anqhk", 1, 4, 1);
+ test(S("tkejgnafrm"), "jekca", 1, 5, 0);
+ test(S("jnakolqrde"), "ikemsjgacf", 1, 0, 1);
+ test(S("lcjptsmgbe"), "arolgsjkhm", 1, 1, 1);
+ test(S("itfsmcjorl"), "oftkbldhre", 1, 5, 0);
+ test(S("omchkfrjea"), "gbkqdoeftl", 1, 9, 1);
+ test(S("cigfqkated"), "sqcflrgtim", 1, 10, S::npos);
+ test(S("tscenjikml"), "fmhbkislrjdpanogqcet", 1, 0, 1);
+ test(S("qcpaemsinf"), "rnioadktqlgpbcjsmhef", 1, 1, 1);
+ test(S("gltkojeipd"), "oakgtnldpsefihqmjcbr", 1, 10, S::npos);
+ test(S("qistfrgnmp"), "gbnaelosidmcjqktfhpr", 1, 19, S::npos);
+ test(S("bdnpfcqaem"), "akbripjhlosndcmqgfet", 1, 20, S::npos);
+ test(S("ectnhskflp"), "", 5, 0, 5);
+ test(S("fgtianblpq"), "pijag", 5, 0, 5);
+ test(S("mfeqklirnh"), "jrckd", 5, 1, 5);
+ test(S("astedncjhk"), "qcloh", 5, 2, 5);
+ test(S("fhlqgcajbr"), "thlmp", 5, 4, 5);
+ test(S("epfhocmdng"), "qidmo", 5, 5, 5);
+ test(S("apcnsibger"), "lnegpsjqrd", 5, 0, 5);
+ test(S("aqkocrbign"), "rjqdablmfs", 5, 1, 4);
+ test(S("ijsmdtqgce"), "enkgpbsjaq", 5, 5, 5);
+ test(S("clobgsrken"), "kdsgoaijfh", 5, 9, 3);
+ test(S("jbhcfposld"), "trfqgmckbe", 5, 10, 5);
+ test(S("oqnpblhide"), "igetsracjfkdnpoblhqm", 5, 0, 5);
+ test(S("lroeasctif"), "nqctfaogirshlekbdjpm", 5, 1, 5);
+ test(S("bpjlgmiedh"), "csehfgomljdqinbartkp", 5, 10, 1);
+ test(S("pamkeoidrj"), "qahoegcmplkfsjbdnitr", 5, 19, S::npos);
+ test(S("espogqbthk"), "dpteiajrqmsognhlfbkc", 5, 20, S::npos);
+ test(S("shoiedtcjb"), "", 9, 0, 9);
+ test(S("ebcinjgads"), "tqbnh", 9, 0, 9);
+ test(S("dqmregkcfl"), "akmle", 9, 1, 9);
+ test(S("ngcrieqajf"), "iqfkm", 9, 2, 9);
+ test(S("qosmilgnjb"), "tqjsr", 9, 4, 9);
+ test(S("ikabsjtdfl"), "jplqg", 9, 5, 8);
+ test(S("ersmicafdh"), "oilnrbcgtj", 9, 0, 9);
+ test(S("fdnplotmgh"), "morkglpesn", 9, 1, 9);
+ test(S("fdbicojerm"), "dmicerngat", 9, 5, 8);
+ test(S("mbtafndjcq"), "radgeskbtc", 9, 9, 9);
+ test(S("mlenkpfdtc"), "ljikprsmqo", 9, 10, 9);
+ test(S("ahlcifdqgs"), "trqihkcgsjamfdbolnpe", 9, 0, 9);
+ test(S("bgjemaltks"), "lqmthbsrekajgnofcipd", 9, 1, 9);
+ test(S("pdhslbqrfc"), "jtalmedribkgqsopcnfh", 9, 10, 9);
+ test(S("dirhtsnjkc"), "spqfoiclmtagejbndkrh", 9, 19, 3);
+ test(S("dlroktbcja"), "nmotklspigjrdhcfaebq", 9, 20, S::npos);
+ test(S("ncjpmaekbs"), "", 10, 0, 9);
+ test(S("hlbosgmrak"), "hpmsd", 10, 0, 9);
+ test(S("pqfhsgilen"), "qnpor", 10, 1, 9);
+ test(S("gqtjsbdckh"), "otdma", 10, 2, 9);
+ test(S("cfkqpjlegi"), "efhjg", 10, 4, 9);
+ test(S("beanrfodgj"), "odpte", 10, 5, 9);
+ test(S("adtkqpbjfi"), "bctdgfmolr", 10, 0, 9);
+ test(S("iomkfthagj"), "oaklidrbqg", 10, 1, 9);
+}
+
+template <class S>
+void test2()
+{
+ test(S("sdpcilonqj"), "dnjfsagktr", 10, 5, 8);
+ test(S("gtfbdkqeml"), "nejaktmiqg", 10, 9, 9);
+ test(S("bmeqgcdorj"), "pjqonlebsf", 10, 10, 8);
+ test(S("etqlcanmob"), "dshmnbtolcjepgaikfqr", 10, 0, 9);
+ test(S("roqmkbdtia"), "iogfhpabtjkqlrnemcds", 10, 1, 9);
+ test(S("kadsithljf"), "ngridfabjsecpqltkmoh", 10, 10, 7);
+ test(S("sgtkpbfdmh"), "athmknplcgofrqejsdib", 10, 19, 5);
+ test(S("qgmetnabkl"), "ldobhmqcafnjtkeisgrp", 10, 20, S::npos);
+ test(S("cqjohampgd"), "", 11, 0, 9);
+ test(S("hobitmpsan"), "aocjb", 11, 0, 9);
+ test(S("tjehkpsalm"), "jbrnk", 11, 1, 9);
+ test(S("ngfbojitcl"), "tqedg", 11, 2, 9);
+ test(S("rcfkdbhgjo"), "nqskp", 11, 4, 9);
+ test(S("qghptonrea"), "eaqkl", 11, 5, 7);
+ test(S("hnprfgqjdl"), "reaoicljqm", 11, 0, 9);
+ test(S("hlmgabenti"), "lsftgajqpm", 11, 1, 9);
+ test(S("ofcjanmrbs"), "rlpfogmits", 11, 5, 9);
+ test(S("jqedtkornm"), "shkncmiaqj", 11, 9, 7);
+ test(S("rfedlasjmg"), "fpnatrhqgs", 11, 10, 8);
+ test(S("talpqjsgkm"), "sjclemqhnpdbgikarfot", 11, 0, 9);
+ test(S("lrkcbtqpie"), "otcmedjikgsfnqbrhpla", 11, 1, 9);
+ test(S("cipogdskjf"), "bonsaefdqiprkhlgtjcm", 11, 10, 8);
+ test(S("nqedcojahi"), "egpscmahijlfnkrodqtb", 11, 19, S::npos);
+ test(S("hefnrkmctj"), "kmqbfepjthgilscrndoa", 11, 20, S::npos);
+ test(S("atqirnmekfjolhpdsgcb"), "", 0, 0, 0);
+ test(S("echfkmlpribjnqsaogtd"), "prboq", 0, 0, 0);
+ test(S("qnhiftdgcleajbpkrosm"), "fjcqh", 0, 1, 0);
+ test(S("chamfknorbedjitgslpq"), "fmosa", 0, 2, 0);
+ test(S("njhqpibfmtlkaecdrgso"), "qdbok", 0, 4, 0);
+ test(S("ebnghfsqkprmdcljoiat"), "amslg", 0, 5, 0);
+ test(S("letjomsgihfrpqbkancd"), "smpltjneqb", 0, 0, 0);
+ test(S("nblgoipcrqeaktshjdmf"), "flitskrnge", 0, 1, 0);
+ test(S("cehkbngtjoiflqapsmrd"), "pgqihmlbef", 0, 5, 0);
+ test(S("mignapfoklbhcqjetdrs"), "cfpdqjtgsb", 0, 9, 0);
+ test(S("ceatbhlsqjgpnokfrmdi"), "htpsiaflom", 0, 10, 0);
+ test(S("ocihkjgrdelpfnmastqb"), "kpjfiaceghsrdtlbnomq", 0, 0, 0);
+ test(S("noelgschdtbrjfmiqkap"), "qhtbomidljgafneksprc", 0, 1, 0);
+ test(S("dkclqfombepritjnghas"), "nhtjobkcefldimpsaqgr", 0, 10, 0);
+ test(S("miklnresdgbhqcojftap"), "prabcjfqnoeskilmtgdh", 0, 19, S::npos);
+ test(S("htbcigojaqmdkfrnlsep"), "dtrgmchilkasqoebfpjn", 0, 20, S::npos);
+ test(S("febhmqtjanokscdirpgl"), "", 1, 0, 1);
+ test(S("loakbsqjpcrdhftniegm"), "sqome", 1, 0, 1);
+ test(S("reagphsqflbitdcjmkno"), "smfte", 1, 1, 1);
+ test(S("jitlfrqemsdhkopncabg"), "ciboh", 1, 2, 0);
+ test(S("mhtaepscdnrjqgbkifol"), "haois", 1, 4, 0);
+ test(S("tocesrfmnglpbjihqadk"), "abfki", 1, 5, 1);
+ test(S("lpfmctjrhdagneskbqoi"), "frdkocntmq", 1, 0, 1);
+ test(S("lsmqaepkdhncirbtjfgo"), "oasbpedlnr", 1, 1, 1);
+ test(S("epoiqmtldrabnkjhcfsg"), "kltqmhgand", 1, 5, 1);
+ test(S("emgasrilpknqojhtbdcf"), "gdtfjchpmr", 1, 9, 0);
+ test(S("hnfiagdpcklrjetqbsom"), "ponmcqblet", 1, 10, 0);
+ test(S("nsdfebgajhmtricpoklq"), "sgphqdnofeiklatbcmjr", 1, 0, 1);
+ test(S("atjgfsdlpobmeiqhncrk"), "ljqprsmigtfoneadckbh", 1, 1, 1);
+ test(S("sitodfgnrejlahcbmqkp"), "ligeojhafnkmrcsqtbdp", 1, 10, 0);
+ test(S("fraghmbiceknltjpqosd"), "lsimqfnjarbopedkhcgt", 1, 19, S::npos);
+ test(S("pmafenlhqtdbkirjsogc"), "abedmfjlghniorcqptks", 1, 20, S::npos);
+ test(S("pihgmoeqtnakrjslcbfd"), "", 10, 0, 10);
+ test(S("gjdkeprctqblnhiafsom"), "hqtoa", 10, 0, 10);
+ test(S("mkpnblfdsahrcqijteog"), "cahif", 10, 1, 10);
+ test(S("gckarqnelodfjhmbptis"), "kehis", 10, 2, 10);
+ test(S("gqpskidtbclomahnrjfe"), "kdlmh", 10, 4, 9);
+ test(S("pkldjsqrfgitbhmaecno"), "paeql", 10, 5, 10);
+ test(S("aftsijrbeklnmcdqhgop"), "aghoqiefnb", 10, 0, 10);
+ test(S("mtlgdrhafjkbiepqnsoc"), "jrbqaikpdo", 10, 1, 10);
+ test(S("pqgirnaefthokdmbsclj"), "smjonaeqcl", 10, 5, 10);
+ test(S("kpdbgjmtherlsfcqoina"), "eqbdrkcfah", 10, 9, 8);
+ test(S("jrlbothiknqmdgcfasep"), "kapmsienhf", 10, 10, 10);
+ test(S("mjogldqferckabinptsh"), "jpqotrlenfcsbhkaimdg", 10, 0, 10);
+ test(S("apoklnefbhmgqcdrisjt"), "jlbmhnfgtcqprikeados", 10, 1, 10);
+ test(S("ifeopcnrjbhkdgatmqls"), "stgbhfmdaljnpqoicker", 10, 10, 8);
+ test(S("ckqhaiesmjdnrgolbtpf"), "oihcetflbjagdsrkmqpn", 10, 19, S::npos);
+ test(S("bnlgapfimcoterskqdjh"), "adtclebmnpjsrqfkigoh", 10, 20, S::npos);
+ test(S("kgdlrobpmjcthqsafeni"), "", 19, 0, 19);
+ test(S("dfkechomjapgnslbtqir"), "beafg", 19, 0, 19);
+ test(S("rloadknfbqtgmhcsipje"), "iclat", 19, 1, 19);
+ test(S("mgjhkolrnadqbpetcifs"), "rkhnf", 19, 2, 19);
+ test(S("cmlfakiojdrgtbsphqen"), "clshq", 19, 4, 19);
+ test(S("kghbfipeomsntdalrqjc"), "dtcoj", 19, 5, 17);
+ test(S("eldiqckrnmtasbghjfpo"), "rqosnjmfth", 19, 0, 19);
+ test(S("abqjcfedgotihlnspkrm"), "siatdfqglh", 19, 1, 19);
+ test(S("qfbadrtjsimkolcenhpg"), "mrlshtpgjq", 19, 5, 19);
+ test(S("abseghclkjqifmtodrnp"), "adlcskgqjt", 19, 9, 19);
+ test(S("ibmsnlrjefhtdokacqpg"), "drshcjknaf", 19, 10, 19);
+ test(S("mrkfciqjebaponsthldg"), "etsaqroinghpkjdlfcbm", 19, 0, 19);
+ test(S("mjkticdeoqshpalrfbgn"), "sgepdnkqliambtrocfhj", 19, 1, 19);
+ test(S("rqnoclbdejgiphtfsakm"), "nlmcjaqgbsortfdihkpe", 19, 10, 18);
+ test(S("plkqbhmtfaeodjcrsing"), "racfnpmosldibqkghjet", 19, 19, 7);
+ test(S("oegalhmstjrfickpbndq"), "fjhdsctkqeiolagrnmbp", 19, 20, S::npos);
+ test(S("rdtgjcaohpblniekmsfq"), "", 20, 0, 19);
+ test(S("ofkqbnjetrmsaidphglc"), "ejanp", 20, 0, 19);
+ test(S("grkpahljcftesdmonqib"), "odife", 20, 1, 19);
+ test(S("jimlgbhfqkteospardcn"), "okaqd", 20, 2, 19);
+ test(S("gftenihpmslrjkqadcob"), "lcdbi", 20, 4, 18);
+ test(S("bmhldogtckrfsanijepq"), "fsqbj", 20, 5, 18);
+ test(S("nfqkrpjdesabgtlcmoih"), "bigdomnplq", 20, 0, 19);
+ test(S("focalnrpiqmdkstehbjg"), "apiblotgcd", 20, 1, 19);
+ test(S("rhqdspkmebiflcotnjga"), "acfhdenops", 20, 5, 18);
+ test(S("rahdtmsckfboqlpniegj"), "jopdeamcrk", 20, 9, 18);
+ test(S("fbkeiopclstmdqranjhg"), "trqncbkgmh", 20, 10, 17);
+ test(S("lifhpdgmbconstjeqark"), "tomglrkencbsfjqpihda", 20, 0, 19);
+}
+
+template <class S>
+void test3()
+{
+ test(S("pboqganrhedjmltsicfk"), "gbkhdnpoietfcmrslajq", 20, 1, 19);
+ test(S("klchabsimetjnqgorfpd"), "rtfnmbsglkjaichoqedp", 20, 10, 19);
+ test(S("sirfgmjqhctndbklaepo"), "ohkmdpfqbsacrtjnlgei", 20, 19, 1);
+ test(S("rlbdsiceaonqjtfpghkm"), "dlbrteoisgphmkncajfq", 20, 20, S::npos);
+ test(S("ecgdanriptblhjfqskom"), "", 21, 0, 19);
+ test(S("fdmiarlpgcskbhoteqjn"), "sjrlo", 21, 0, 19);
+ test(S("rlbstjqopignecmfadkh"), "qjpor", 21, 1, 19);
+ test(S("grjpqmbshektdolcafni"), "odhfn", 21, 2, 19);
+ test(S("sakfcohtqnibprjmlged"), "qtfin", 21, 4, 19);
+ test(S("mjtdglasihqpocebrfkn"), "hpqfo", 21, 5, 19);
+ test(S("okaplfrntghqbmeicsdj"), "fabmertkos", 21, 0, 19);
+ test(S("sahngemrtcjidqbklfpo"), "brqtgkmaej", 21, 1, 19);
+ test(S("dlmsipcnekhbgoaftqjr"), "nfrdeihsgl", 21, 5, 18);
+ test(S("ahegrmqnoiklpfsdbcjt"), "hlfrosekpi", 21, 9, 19);
+ test(S("hdsjbnmlegtkqripacof"), "atgbkrjdsm", 21, 10, 19);
+ test(S("pcnedrfjihqbalkgtoms"), "blnrptjgqmaifsdkhoec", 21, 0, 19);
+ test(S("qjidealmtpskrbfhocng"), "ctpmdahebfqjgknloris", 21, 1, 19);
+ test(S("qeindtagmokpfhsclrbj"), "apnkeqthrmlbfodiscgj", 21, 10, 19);
+ test(S("kpfegbjhsrnodltqciam"), "jdgictpframeoqlsbknh", 21, 19, 7);
+ test(S("hnbrcplsjfgiktoedmaq"), "qprlsfojamgndekthibc", 21, 20, S::npos);
+}
+
+int main()
+{
+ {
+ typedef std::experimental::string_view S;
+ test0<S>();
+ test1<S>();
+ test2<S>();
+ test3<S>();
+ }
+
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::experimental::basic_string_view<char, constexpr_char_traits<char>> SV;
+ constexpr SV sv1;
+ constexpr SV sv2 { "abcde", 5 };
+
+ static_assert (sv1.find_last_not_of( "", 0, 0) == SV::npos, "" );
+ static_assert (sv1.find_last_not_of( "irkhs", 0, 5) == SV::npos, "" );
+ static_assert (sv2.find_last_not_of( "", 0, 0) == 0, "" );
+ static_assert (sv2.find_last_not_of( "gfsrt", 5, 0) == 4, "" );
+ static_assert (sv2.find_last_not_of( "lecar", 5, 0) == 4, "" );
+ }
+#endif
+}
diff --git a/test/std/experimental/string.view/string.view.find/find_last_not_of_string_view_size.pass.cpp b/test/std/experimental/string.view/string.view.find/find_last_not_of_string_view_size.pass.cpp
new file mode 100644
index 000000000000..40c867d6b46c
--- /dev/null
+++ b/test/std/experimental/string.view/string.view.find/find_last_not_of_string_view_size.pass.cpp
@@ -0,0 +1,148 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string_view>
+
+// size_type find_last_not_of(const basic_string& str, size_type pos = npos) const;
+
+#include <experimental/string_view>
+#include <cassert>
+
+template <class S>
+void
+test(const S& s, const S& str, typename S::size_type pos, typename S::size_type x)
+{
+ assert(s.find_last_not_of(str, pos) == x);
+ if (x != S::npos)
+ assert(x <= pos && x < s.size());
+}
+
+template <class S>
+void
+test(const S& s, const S& str, typename S::size_type x)
+{
+ assert(s.find_last_not_of(str) == x);
+ if (x != S::npos)
+ assert(x < s.size());
+}
+
+template <class S>
+void test0()
+{
+ test(S(""), S(""), 0, S::npos);
+ test(S(""), S("laenf"), 0, S::npos);
+ test(S(""), S("pqlnkmbdjo"), 0, S::npos);
+ test(S(""), S("qkamfogpnljdcshbreti"), 0, S::npos);
+ test(S(""), S(""), 1, S::npos);
+ test(S(""), S("bjaht"), 1, S::npos);
+ test(S(""), S("hjlcmgpket"), 1, S::npos);
+ test(S(""), S("htaobedqikfplcgjsmrn"), 1, S::npos);
+ test(S("fodgq"), S(""), 0, 0);
+ test(S("qanej"), S("dfkap"), 0, 0);
+ test(S("clbao"), S("ihqrfebgad"), 0, 0);
+ test(S("mekdn"), S("ngtjfcalbseiqrphmkdo"), 0, S::npos);
+ test(S("srdfq"), S(""), 1, 1);
+ test(S("oemth"), S("ikcrq"), 1, 1);
+ test(S("cdaih"), S("dmajblfhsg"), 1, 0);
+ test(S("qohtk"), S("oqftjhdmkgsblacenirp"), 1, S::npos);
+ test(S("cshmd"), S(""), 2, 2);
+ test(S("lhcdo"), S("oebqi"), 2, 2);
+ test(S("qnsoh"), S("kojhpmbsfe"), 2, 1);
+ test(S("pkrof"), S("acbsjqogpltdkhinfrem"), 2, S::npos);
+ test(S("fmtsp"), S(""), 4, 4);
+ test(S("khbpm"), S("aobjd"), 4, 4);
+ test(S("pbsji"), S("pcbahntsje"), 4, 4);
+ test(S("mprdj"), S("fhepcrntkoagbmldqijs"), 4, S::npos);
+ test(S("eqmpa"), S(""), 5, 4);
+ test(S("omigs"), S("kocgb"), 5, 4);
+ test(S("onmje"), S("fbslrjiqkm"), 5, 4);
+ test(S("oqmrj"), S("jeidpcmalhfnqbgtrsko"), 5, S::npos);
+ test(S("schfa"), S(""), 6, 4);
+ test(S("igdsc"), S("qngpd"), 6, 4);
+ test(S("brqgo"), S("rodhqklgmb"), 6, S::npos);
+ test(S("tnrph"), S("thdjgafrlbkoiqcspmne"), 6, S::npos);
+ test(S("hcjitbfapl"), S(""), 0, 0);
+ test(S("daiprenocl"), S("ashjd"), 0, S::npos);
+ test(S("litpcfdghe"), S("mgojkldsqh"), 0, S::npos);
+ test(S("aidjksrolc"), S("imqnaghkfrdtlopbjesc"), 0, S::npos);
+ test(S("qpghtfbaji"), S(""), 1, 1);
+ test(S("gfshlcmdjr"), S("nadkh"), 1, 1);
+ test(S("nkodajteqp"), S("ofdrqmkebl"), 1, 0);
+ test(S("gbmetiprqd"), S("bdfjqgatlksriohemnpc"), 1, S::npos);
+ test(S("crnklpmegd"), S(""), 5, 5);
+ test(S("jsbtafedoc"), S("prqgn"), 5, 5);
+ test(S("qnmodrtkeb"), S("pejafmnokr"), 5, 4);
+ test(S("cpebqsfmnj"), S("odnqkgijrhabfmcestlp"), 5, S::npos);
+ test(S("lmofqdhpki"), S(""), 9, 9);
+ test(S("hnefkqimca"), S("rtjpa"), 9, 8);
+ test(S("drtasbgmfp"), S("ktsrmnqagd"), 9, 9);
+ test(S("lsaijeqhtr"), S("rtdhgcisbnmoaqkfpjle"), 9, S::npos);
+ test(S("elgofjmbrq"), S(""), 10, 9);
+ test(S("mjqdgalkpc"), S("dplqa"), 10, 9);
+ test(S("kthqnfcerm"), S("dkacjoptns"), 10, 9);
+ test(S("dfsjhanorc"), S("hqfimtrgnbekpdcsjalo"), 10, S::npos);
+ test(S("eqsgalomhb"), S(""), 11, 9);
+ test(S("akiteljmoh"), S("lofbc"), 11, 9);
+ test(S("hlbdfreqjo"), S("astoegbfpn"), 11, 8);
+ test(S("taqobhlerg"), S("pdgreqomsncafklhtibj"), 11, S::npos);
+ test(S("snafbdlghrjkpqtoceim"), S(""), 0, 0);
+ test(S("aemtbrgcklhndjisfpoq"), S("lbtqd"), 0, 0);
+ test(S("pnracgfkjdiholtbqsem"), S("tboimldpjh"), 0, S::npos);
+ test(S("dicfltehbsgrmojnpkaq"), S("slcerthdaiqjfnobgkpm"), 0, S::npos);
+ test(S("jlnkraeodhcspfgbqitm"), S(""), 1, 1);
+ test(S("lhosrngtmfjikbqpcade"), S("aqibs"), 1, 1);
+ test(S("rbtaqjhgkneisldpmfoc"), S("gtfblmqinc"), 1, 0);
+ test(S("gpifsqlrdkbonjtmheca"), S("mkqpbtdalgniorhfescj"), 1, S::npos);
+ test(S("hdpkobnsalmcfijregtq"), S(""), 10, 10);
+ test(S("jtlshdgqaiprkbcoenfm"), S("pblas"), 10, 9);
+ test(S("fkdrbqltsgmcoiphneaj"), S("arosdhcfme"), 10, 9);
+ test(S("crsplifgtqedjohnabmk"), S("blkhjeogicatqfnpdmsr"), 10, S::npos);
+ test(S("niptglfbosehkamrdqcj"), S(""), 19, 19);
+ test(S("copqdhstbingamjfkler"), S("djkqc"), 19, 19);
+ test(S("mrtaefilpdsgocnhqbjk"), S("lgokshjtpb"), 19, 16);
+ test(S("kojatdhlcmigpbfrqnes"), S("bqjhtkfepimcnsgrlado"), 19, S::npos);
+ test(S("eaintpchlqsbdgrkjofm"), S(""), 20, 19);
+ test(S("gjnhidfsepkrtaqbmclo"), S("nocfa"), 20, 18);
+ test(S("spocfaktqdbiejlhngmr"), S("bgtajmiedc"), 20, 19);
+ test(S("rphmlekgfscndtaobiqj"), S("lsckfnqgdahejiopbtmr"), 20, S::npos);
+ test(S("liatsqdoegkmfcnbhrpj"), S(""), 21, 19);
+ test(S("binjagtfldkrspcomqeh"), S("gfsrt"), 21, 19);
+ test(S("latkmisecnorjbfhqpdg"), S("pfsocbhjtm"), 21, 19);
+ test(S("lecfratdjkhnsmqpoigb"), S("tpflmdnoicjgkberhqsa"), 21, S::npos);
+}
+
+template <class S>
+void test1()
+{
+ test(S(""), S(""), S::npos);
+ test(S(""), S("laenf"), S::npos);
+ test(S(""), S("pqlnkmbdjo"), S::npos);
+ test(S(""), S("qkamfogpnljdcshbreti"), S::npos);
+ test(S("nhmko"), S(""), 4);
+ test(S("lahfb"), S("irkhs"), 4);
+ test(S("gmfhd"), S("kantesmpgj"), 4);
+ test(S("odaft"), S("oknlrstdpiqmjbaghcfe"), S::npos);
+ test(S("eolhfgpjqk"), S(""), 9);
+ test(S("nbatdlmekr"), S("bnrpe"), 8);
+ test(S("jdmciepkaq"), S("jtdaefblso"), 9);
+ test(S("hkbgspoflt"), S("oselktgbcapndfjihrmq"), S::npos);
+ test(S("gprdcokbnjhlsfmtieqa"), S(""), 19);
+ test(S("qjghlnftcaismkropdeb"), S("bjaht"), 18);
+ test(S("pnalfrdtkqcmojiesbhg"), S("hjlcmgpket"), 17);
+ test(S("pniotcfrhqsmgdkjbael"), S("htaobedqikfplcgjsmrn"), S::npos);
+}
+
+int main()
+{
+ {
+ typedef std::experimental::string_view S;
+ test0<S>();
+ test1<S>();
+ }
+}
diff --git a/test/std/experimental/string.view/string.view.find/find_last_of_char_size.pass.cpp b/test/std/experimental/string.view/string.view.find/find_last_of_char_size.pass.cpp
new file mode 100644
index 000000000000..d28e0079561f
--- /dev/null
+++ b/test/std/experimental/string.view/string.view.find/find_last_of_char_size.pass.cpp
@@ -0,0 +1,82 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string_view>
+
+// constexpr size_type find_last_of(charT c, size_type pos = npos) const;
+
+#include <experimental/string_view>
+#include <cassert>
+
+#include "constexpr_char_traits.hpp"
+
+template <class S>
+void
+test(const S& s, typename S::value_type c, typename S::size_type pos,
+ typename S::size_type x)
+{
+ assert(s.find_last_of(c, pos) == x);
+ if (x != S::npos)
+ assert(x <= pos && x < s.size());
+}
+
+template <class S>
+void
+test(const S& s, typename S::value_type c, typename S::size_type x)
+{
+ assert(s.find_last_of(c) == x);
+ if (x != S::npos)
+ assert(x < s.size());
+}
+
+int main()
+{
+ {
+ typedef std::experimental::string_view S;
+ test(S(""), 'm', 0, S::npos);
+ test(S(""), 'm', 1, S::npos);
+ test(S("kitcj"), 'm', 0, S::npos);
+ test(S("qkamf"), 'm', 1, S::npos);
+ test(S("nhmko"), 'm', 2, 2);
+ test(S("tpsaf"), 'm', 4, S::npos);
+ test(S("lahfb"), 'm', 5, S::npos);
+ test(S("irkhs"), 'm', 6, S::npos);
+ test(S("gmfhdaipsr"), 'm', 0, S::npos);
+ test(S("kantesmpgj"), 'm', 1, S::npos);
+ test(S("odaftiegpm"), 'm', 5, S::npos);
+ test(S("oknlrstdpi"), 'm', 9, S::npos);
+ test(S("eolhfgpjqk"), 'm', 10, S::npos);
+ test(S("pcdrofikas"), 'm', 11, S::npos);
+ test(S("nbatdlmekrgcfqsophij"), 'm', 0, S::npos);
+ test(S("bnrpehidofmqtcksjgla"), 'm', 1, S::npos);
+ test(S("jdmciepkaqgotsrfnhlb"), 'm', 10, 2);
+ test(S("jtdaefblsokrmhpgcnqi"), 'm', 19, 12);
+ test(S("hkbgspofltajcnedqmri"), 'm', 20, 17);
+ test(S("oselktgbcapndfjihrmq"), 'm', 21, 18);
+
+ test(S(""), 'm', S::npos);
+ test(S("csope"), 'm', S::npos);
+ test(S("gfsmthlkon"), 'm', 3);
+ test(S("laenfsbridchgotmkqpj"), 'm', 15);
+ }
+
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::experimental::basic_string_view<char, constexpr_char_traits<char>> SV;
+ constexpr SV sv1;
+ constexpr SV sv2 { "abcde", 5 };
+
+ static_assert (sv1.find_last_of( 'i', 0 ) == SV::npos, "" );
+ static_assert (sv1.find_last_of( 'i', 1 ) == SV::npos, "" );
+ static_assert (sv2.find_last_of( 'a', 0 ) == 0, "" );
+ static_assert (sv2.find_last_of( 'a', 1 ) == 0, "" );
+ static_assert (sv2.find_last_of( 'e', 5 ) == 4, "" );
+ }
+#endif
+}
diff --git a/test/std/experimental/string.view/string.view.find/find_last_of_pointer_size.pass.cpp b/test/std/experimental/string.view/string.view.find/find_last_of_pointer_size.pass.cpp
new file mode 100644
index 000000000000..f01e277f5ada
--- /dev/null
+++ b/test/std/experimental/string.view/string.view.find/find_last_of_pointer_size.pass.cpp
@@ -0,0 +1,165 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string_view>
+
+// constexpr size_type find_last_of(const charT* s, size_type pos = npos) const;
+
+#include <experimental/string_view>
+#include <cassert>
+
+#include "constexpr_char_traits.hpp"
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type pos,
+ typename S::size_type x)
+{
+ assert(s.find_last_of(str, pos) == x);
+ if (x != S::npos)
+ assert(x <= pos && x < s.size());
+}
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type x)
+{
+ assert(s.find_last_of(str) == x);
+ if (x != S::npos)
+ assert(x < s.size());
+}
+
+template <class S>
+void test0()
+{
+ test(S(""), "", 0, S::npos);
+ test(S(""), "laenf", 0, S::npos);
+ test(S(""), "pqlnkmbdjo", 0, S::npos);
+ test(S(""), "qkamfogpnljdcshbreti", 0, S::npos);
+ test(S(""), "", 1, S::npos);
+ test(S(""), "bjaht", 1, S::npos);
+ test(S(""), "hjlcmgpket", 1, S::npos);
+ test(S(""), "htaobedqikfplcgjsmrn", 1, S::npos);
+ test(S("fodgq"), "", 0, S::npos);
+ test(S("qanej"), "dfkap", 0, S::npos);
+ test(S("clbao"), "ihqrfebgad", 0, S::npos);
+ test(S("mekdn"), "ngtjfcalbseiqrphmkdo", 0, 0);
+ test(S("srdfq"), "", 1, S::npos);
+ test(S("oemth"), "ikcrq", 1, S::npos);
+ test(S("cdaih"), "dmajblfhsg", 1, 1);
+ test(S("qohtk"), "oqftjhdmkgsblacenirp", 1, 1);
+ test(S("cshmd"), "", 2, S::npos);
+ test(S("lhcdo"), "oebqi", 2, S::npos);
+ test(S("qnsoh"), "kojhpmbsfe", 2, 2);
+ test(S("pkrof"), "acbsjqogpltdkhinfrem", 2, 2);
+ test(S("fmtsp"), "", 4, S::npos);
+ test(S("khbpm"), "aobjd", 4, 2);
+ test(S("pbsji"), "pcbahntsje", 4, 3);
+ test(S("mprdj"), "fhepcrntkoagbmldqijs", 4, 4);
+ test(S("eqmpa"), "", 5, S::npos);
+ test(S("omigs"), "kocgb", 5, 3);
+ test(S("onmje"), "fbslrjiqkm", 5, 3);
+ test(S("oqmrj"), "jeidpcmalhfnqbgtrsko", 5, 4);
+ test(S("schfa"), "", 6, S::npos);
+ test(S("igdsc"), "qngpd", 6, 2);
+ test(S("brqgo"), "rodhqklgmb", 6, 4);
+ test(S("tnrph"), "thdjgafrlbkoiqcspmne", 6, 4);
+ test(S("hcjitbfapl"), "", 0, S::npos);
+ test(S("daiprenocl"), "ashjd", 0, 0);
+ test(S("litpcfdghe"), "mgojkldsqh", 0, 0);
+ test(S("aidjksrolc"), "imqnaghkfrdtlopbjesc", 0, 0);
+ test(S("qpghtfbaji"), "", 1, S::npos);
+ test(S("gfshlcmdjr"), "nadkh", 1, S::npos);
+ test(S("nkodajteqp"), "ofdrqmkebl", 1, 1);
+ test(S("gbmetiprqd"), "bdfjqgatlksriohemnpc", 1, 1);
+ test(S("crnklpmegd"), "", 5, S::npos);
+ test(S("jsbtafedoc"), "prqgn", 5, S::npos);
+ test(S("qnmodrtkeb"), "pejafmnokr", 5, 5);
+ test(S("cpebqsfmnj"), "odnqkgijrhabfmcestlp", 5, 5);
+ test(S("lmofqdhpki"), "", 9, S::npos);
+ test(S("hnefkqimca"), "rtjpa", 9, 9);
+ test(S("drtasbgmfp"), "ktsrmnqagd", 9, 7);
+ test(S("lsaijeqhtr"), "rtdhgcisbnmoaqkfpjle", 9, 9);
+ test(S("elgofjmbrq"), "", 10, S::npos);
+ test(S("mjqdgalkpc"), "dplqa", 10, 8);
+ test(S("kthqnfcerm"), "dkacjoptns", 10, 6);
+ test(S("dfsjhanorc"), "hqfimtrgnbekpdcsjalo", 10, 9);
+ test(S("eqsgalomhb"), "", 11, S::npos);
+ test(S("akiteljmoh"), "lofbc", 11, 8);
+ test(S("hlbdfreqjo"), "astoegbfpn", 11, 9);
+ test(S("taqobhlerg"), "pdgreqomsncafklhtibj", 11, 9);
+ test(S("snafbdlghrjkpqtoceim"), "", 0, S::npos);
+ test(S("aemtbrgcklhndjisfpoq"), "lbtqd", 0, S::npos);
+ test(S("pnracgfkjdiholtbqsem"), "tboimldpjh", 0, 0);
+ test(S("dicfltehbsgrmojnpkaq"), "slcerthdaiqjfnobgkpm", 0, 0);
+ test(S("jlnkraeodhcspfgbqitm"), "", 1, S::npos);
+ test(S("lhosrngtmfjikbqpcade"), "aqibs", 1, S::npos);
+ test(S("rbtaqjhgkneisldpmfoc"), "gtfblmqinc", 1, 1);
+ test(S("gpifsqlrdkbonjtmheca"), "mkqpbtdalgniorhfescj", 1, 1);
+ test(S("hdpkobnsalmcfijregtq"), "", 10, S::npos);
+ test(S("jtlshdgqaiprkbcoenfm"), "pblas", 10, 10);
+ test(S("fkdrbqltsgmcoiphneaj"), "arosdhcfme", 10, 10);
+ test(S("crsplifgtqedjohnabmk"), "blkhjeogicatqfnpdmsr", 10, 10);
+ test(S("niptglfbosehkamrdqcj"), "", 19, S::npos);
+ test(S("copqdhstbingamjfkler"), "djkqc", 19, 16);
+ test(S("mrtaefilpdsgocnhqbjk"), "lgokshjtpb", 19, 19);
+ test(S("kojatdhlcmigpbfrqnes"), "bqjhtkfepimcnsgrlado", 19, 19);
+ test(S("eaintpchlqsbdgrkjofm"), "", 20, S::npos);
+ test(S("gjnhidfsepkrtaqbmclo"), "nocfa", 20, 19);
+ test(S("spocfaktqdbiejlhngmr"), "bgtajmiedc", 20, 18);
+ test(S("rphmlekgfscndtaobiqj"), "lsckfnqgdahejiopbtmr", 20, 19);
+ test(S("liatsqdoegkmfcnbhrpj"), "", 21, S::npos);
+ test(S("binjagtfldkrspcomqeh"), "gfsrt", 21, 12);
+ test(S("latkmisecnorjbfhqpdg"), "pfsocbhjtm", 21, 17);
+ test(S("lecfratdjkhnsmqpoigb"), "tpflmdnoicjgkberhqsa", 21, 19);
+}
+
+template <class S>
+void test1()
+{
+ test(S(""), "", S::npos);
+ test(S(""), "laenf", S::npos);
+ test(S(""), "pqlnkmbdjo", S::npos);
+ test(S(""), "qkamfogpnljdcshbreti", S::npos);
+ test(S("nhmko"), "", S::npos);
+ test(S("lahfb"), "irkhs", 2);
+ test(S("gmfhd"), "kantesmpgj", 1);
+ test(S("odaft"), "oknlrstdpiqmjbaghcfe", 4);
+ test(S("eolhfgpjqk"), "", S::npos);
+ test(S("nbatdlmekr"), "bnrpe", 9);
+ test(S("jdmciepkaq"), "jtdaefblso", 8);
+ test(S("hkbgspoflt"), "oselktgbcapndfjihrmq", 9);
+ test(S("gprdcokbnjhlsfmtieqa"), "", S::npos);
+ test(S("qjghlnftcaismkropdeb"), "bjaht", 19);
+ test(S("pnalfrdtkqcmojiesbhg"), "hjlcmgpket", 19);
+ test(S("pniotcfrhqsmgdkjbael"), "htaobedqikfplcgjsmrn", 19);
+}
+
+int main()
+{
+ {
+ typedef std::experimental::string_view S;
+ test0<S>();
+ test1<S>();
+ }
+
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::experimental::basic_string_view<char, constexpr_char_traits<char>> SV;
+ constexpr SV sv1;
+ constexpr SV sv2 { "abcde", 5 };
+
+ static_assert (sv1.find_last_of( "", 0) == SV::npos, "" );
+ static_assert (sv1.find_last_of( "irkhs", 5) == SV::npos, "" );
+ static_assert (sv2.find_last_of( "", 0) == SV::npos, "" );
+ static_assert (sv2.find_last_of( "gfsrt", 5) == SV::npos, "" );
+ static_assert (sv2.find_last_of( "lecar", 5) == 4, "" );
+ }
+#endif
+}
diff --git a/test/std/experimental/string.view/string.view.find/find_last_of_pointer_size_size.pass.cpp b/test/std/experimental/string.view/string.view.find/find_last_of_pointer_size_size.pass.cpp
new file mode 100644
index 000000000000..a38ffa692f48
--- /dev/null
+++ b/test/std/experimental/string.view/string.view.find/find_last_of_pointer_size_size.pass.cpp
@@ -0,0 +1,392 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string_view>
+
+// constexpr size_type find_last_of(const charT* s, size_type pos, size_type n) const;
+
+#include <experimental/string_view>
+#include <cassert>
+
+#include "constexpr_char_traits.hpp"
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type pos,
+ typename S::size_type n, typename S::size_type x)
+{
+ assert(s.find_last_of(str, pos, n) == x);
+ if (x != S::npos)
+ assert(x <= pos && x < s.size());
+}
+
+template <class S>
+void test0()
+{
+ test(S(""), "", 0, 0, S::npos);
+ test(S(""), "irkhs", 0, 0, S::npos);
+ test(S(""), "kante", 0, 1, S::npos);
+ test(S(""), "oknlr", 0, 2, S::npos);
+ test(S(""), "pcdro", 0, 4, S::npos);
+ test(S(""), "bnrpe", 0, 5, S::npos);
+ test(S(""), "jtdaefblso", 0, 0, S::npos);
+ test(S(""), "oselktgbca", 0, 1, S::npos);
+ test(S(""), "eqgaplhckj", 0, 5, S::npos);
+ test(S(""), "bjahtcmnlp", 0, 9, S::npos);
+ test(S(""), "hjlcmgpket", 0, 10, S::npos);
+ test(S(""), "htaobedqikfplcgjsmrn", 0, 0, S::npos);
+ test(S(""), "hpqiarojkcdlsgnmfetb", 0, 1, S::npos);
+ test(S(""), "dfkaprhjloqetcsimnbg", 0, 10, S::npos);
+ test(S(""), "ihqrfebgadntlpmjksoc", 0, 19, S::npos);
+ test(S(""), "ngtjfcalbseiqrphmkdo", 0, 20, S::npos);
+ test(S(""), "", 1, 0, S::npos);
+ test(S(""), "lbtqd", 1, 0, S::npos);
+ test(S(""), "tboim", 1, 1, S::npos);
+ test(S(""), "slcer", 1, 2, S::npos);
+ test(S(""), "cbjfs", 1, 4, S::npos);
+ test(S(""), "aqibs", 1, 5, S::npos);
+ test(S(""), "gtfblmqinc", 1, 0, S::npos);
+ test(S(""), "mkqpbtdalg", 1, 1, S::npos);
+ test(S(""), "kphatlimcd", 1, 5, S::npos);
+ test(S(""), "pblasqogic", 1, 9, S::npos);
+ test(S(""), "arosdhcfme", 1, 10, S::npos);
+ test(S(""), "blkhjeogicatqfnpdmsr", 1, 0, S::npos);
+ test(S(""), "bmhineprjcoadgstflqk", 1, 1, S::npos);
+ test(S(""), "djkqcmetslnghpbarfoi", 1, 10, S::npos);
+ test(S(""), "lgokshjtpbemarcdqnfi", 1, 19, S::npos);
+ test(S(""), "bqjhtkfepimcnsgrlado", 1, 20, S::npos);
+ test(S("eaint"), "", 0, 0, S::npos);
+ test(S("binja"), "gfsrt", 0, 0, S::npos);
+ test(S("latkm"), "pfsoc", 0, 1, S::npos);
+ test(S("lecfr"), "tpflm", 0, 2, S::npos);
+ test(S("eqkst"), "sgkec", 0, 4, 0);
+ test(S("cdafr"), "romds", 0, 5, S::npos);
+ test(S("prbhe"), "qhjistlgmr", 0, 0, S::npos);
+ test(S("lbisk"), "pedfirsglo", 0, 1, S::npos);
+ test(S("hrlpd"), "aqcoslgrmk", 0, 5, S::npos);
+ test(S("ehmja"), "dabckmepqj", 0, 9, 0);
+ test(S("mhqgd"), "pqscrjthli", 0, 10, S::npos);
+ test(S("tgklq"), "kfphdcsjqmobliagtren", 0, 0, S::npos);
+ test(S("bocjs"), "rokpefncljibsdhqtagm", 0, 1, S::npos);
+ test(S("grbsd"), "afionmkphlebtcjqsgrd", 0, 10, S::npos);
+ test(S("ofjqr"), "aenmqplidhkofrjbctsg", 0, 19, 0);
+ test(S("btlfi"), "osjmbtcadhiklegrpqnf", 0, 20, 0);
+ test(S("clrgb"), "", 1, 0, S::npos);
+ test(S("tjmek"), "osmia", 1, 0, S::npos);
+ test(S("bgstp"), "ckonl", 1, 1, S::npos);
+ test(S("hstrk"), "ilcaj", 1, 2, S::npos);
+ test(S("kmspj"), "lasiq", 1, 4, S::npos);
+ test(S("tjboh"), "kfqmr", 1, 5, S::npos);
+ test(S("ilbcj"), "klnitfaobg", 1, 0, S::npos);
+ test(S("jkngf"), "gjhmdlqikp", 1, 1, S::npos);
+ test(S("gfcql"), "skbgtahqej", 1, 5, 0);
+ test(S("dqtlg"), "bjsdgtlpkf", 1, 9, 0);
+ test(S("bthpg"), "bjgfmnlkio", 1, 10, 0);
+ test(S("dgsnq"), "lbhepotfsjdqigcnamkr", 1, 0, S::npos);
+ test(S("rmfhp"), "tebangckmpsrqdlfojhi", 1, 1, S::npos);
+ test(S("jfdam"), "joflqbdkhtegimscpanr", 1, 10, 1);
+ test(S("edapb"), "adpmcohetfbsrjinlqkg", 1, 19, 1);
+ test(S("brfsm"), "iacldqjpfnogbsrhmetk", 1, 20, 1);
+ test(S("ndrhl"), "", 2, 0, S::npos);
+ test(S("mrecp"), "otkgb", 2, 0, S::npos);
+ test(S("qlasf"), "cqsjl", 2, 1, S::npos);
+ test(S("smaqd"), "dpifl", 2, 2, S::npos);
+ test(S("hjeni"), "oapht", 2, 4, 0);
+ test(S("ocmfj"), "cifts", 2, 5, 1);
+ test(S("hmftq"), "nmsckbgalo", 2, 0, S::npos);
+ test(S("fklad"), "tpksqhamle", 2, 1, S::npos);
+ test(S("dirnm"), "tpdrchmkji", 2, 5, 2);
+ test(S("hrgdc"), "ijagfkblst", 2, 9, 2);
+ test(S("ifakg"), "kpocsignjb", 2, 10, 0);
+ test(S("ebrgd"), "pecqtkjsnbdrialgmohf", 2, 0, S::npos);
+ test(S("rcjml"), "aiortphfcmkjebgsndql", 2, 1, S::npos);
+ test(S("peqmt"), "sdbkeamglhipojqftrcn", 2, 10, 1);
+ test(S("frehn"), "ljqncehgmfktroapidbs", 2, 19, 2);
+ test(S("tqolf"), "rtcfodilamkbenjghqps", 2, 20, 2);
+ test(S("cjgao"), "", 4, 0, S::npos);
+ test(S("kjplq"), "mabns", 4, 0, S::npos);
+ test(S("herni"), "bdnrp", 4, 1, S::npos);
+ test(S("tadrb"), "scidp", 4, 2, S::npos);
+ test(S("pkfeo"), "agbjl", 4, 4, S::npos);
+ test(S("hoser"), "jfmpr", 4, 5, 4);
+ test(S("kgrsp"), "rbpefghsmj", 4, 0, S::npos);
+ test(S("pgejb"), "apsfntdoqc", 4, 1, S::npos);
+ test(S("thlnq"), "ndkjeisgcl", 4, 5, 3);
+ test(S("nbmit"), "rnfpqatdeo", 4, 9, 4);
+ test(S("jgmib"), "bntjlqrfik", 4, 10, 4);
+ test(S("ncrfj"), "kcrtmpolnaqejghsfdbi", 4, 0, S::npos);
+ test(S("ncsik"), "lobheanpkmqidsrtcfgj", 4, 1, S::npos);
+ test(S("sgbfh"), "athdkljcnreqbgpmisof", 4, 10, 4);
+ test(S("dktbn"), "qkdmjialrscpbhefgont", 4, 19, 4);
+ test(S("fthqm"), "dmasojntqleribkgfchp", 4, 20, 4);
+ test(S("klopi"), "", 5, 0, S::npos);
+ test(S("dajhn"), "psthd", 5, 0, S::npos);
+ test(S("jbgno"), "rpmjd", 5, 1, S::npos);
+ test(S("hkjae"), "dfsmk", 5, 2, S::npos);
+}
+
+template <class S>
+void test1()
+{
+ test(S("gbhqo"), "skqne", 5, 4, 3);
+ test(S("ktdor"), "kipnf", 5, 5, 0);
+ test(S("ldprn"), "hmrnqdgifl", 5, 0, S::npos);
+ test(S("egmjk"), "fsmjcdairn", 5, 1, S::npos);
+ test(S("armql"), "pcdgltbrfj", 5, 5, 4);
+ test(S("cdhjo"), "aekfctpirg", 5, 9, 0);
+ test(S("jcons"), "ledihrsgpf", 5, 10, 4);
+ test(S("cbrkp"), "mqcklahsbtirgopefndj", 5, 0, S::npos);
+ test(S("fhgna"), "kmlthaoqgecrnpdbjfis", 5, 1, S::npos);
+ test(S("ejfcd"), "sfhbamcdptojlkrenqgi", 5, 10, 4);
+ test(S("kqjhe"), "pbniofmcedrkhlstgaqj", 5, 19, 4);
+ test(S("pbdjl"), "mongjratcskbhqiepfdl", 5, 20, 4);
+ test(S("gajqn"), "", 6, 0, S::npos);
+ test(S("stedk"), "hrnat", 6, 0, S::npos);
+ test(S("tjkaf"), "gsqdt", 6, 1, S::npos);
+ test(S("dthpe"), "bspkd", 6, 2, S::npos);
+ test(S("klhde"), "ohcmb", 6, 4, 2);
+ test(S("bhlki"), "heatr", 6, 5, 1);
+ test(S("lqmoh"), "pmblckedfn", 6, 0, S::npos);
+ test(S("mtqin"), "aceqmsrbik", 6, 1, S::npos);
+ test(S("dpqbr"), "lmbtdehjrn", 6, 5, 3);
+ test(S("kdhmo"), "teqmcrlgib", 6, 9, 3);
+ test(S("jblqp"), "njolbmspac", 6, 10, 4);
+ test(S("qmjgl"), "pofnhidklamecrbqjgst", 6, 0, S::npos);
+ test(S("rothp"), "jbhckmtgrqnosafedpli", 6, 1, S::npos);
+ test(S("ghknq"), "dobntpmqklicsahgjerf", 6, 10, 4);
+ test(S("eopfi"), "tpdshainjkbfoemlrgcq", 6, 19, 4);
+ test(S("dsnmg"), "oldpfgeakrnitscbjmqh", 6, 20, 4);
+ test(S("jnkrfhotgl"), "", 0, 0, S::npos);
+ test(S("dltjfngbko"), "rqegt", 0, 0, S::npos);
+ test(S("bmjlpkiqde"), "dashm", 0, 1, S::npos);
+ test(S("skrflobnqm"), "jqirk", 0, 2, S::npos);
+ test(S("jkpldtshrm"), "rckeg", 0, 4, S::npos);
+ test(S("ghasdbnjqo"), "jscie", 0, 5, S::npos);
+ test(S("igrkhpbqjt"), "efsphndliq", 0, 0, S::npos);
+ test(S("ikthdgcamf"), "gdicosleja", 0, 1, S::npos);
+ test(S("pcofgeniam"), "qcpjibosfl", 0, 5, 0);
+ test(S("rlfjgesqhc"), "lrhmefnjcq", 0, 9, 0);
+ test(S("itphbqsker"), "dtablcrseo", 0, 10, S::npos);
+ test(S("skjafcirqm"), "apckjsftedbhgomrnilq", 0, 0, S::npos);
+ test(S("tcqomarsfd"), "pcbrgflehjtiadnsokqm", 0, 1, S::npos);
+ test(S("rocfeldqpk"), "nsiadegjklhobrmtqcpf", 0, 10, S::npos);
+ test(S("cfpegndlkt"), "cpmajdqnolikhgsbretf", 0, 19, 0);
+ test(S("fqbtnkeasj"), "jcflkntmgiqrphdosaeb", 0, 20, 0);
+ test(S("shbcqnmoar"), "", 1, 0, S::npos);
+ test(S("bdoshlmfin"), "ontrs", 1, 0, S::npos);
+ test(S("khfrebnsgq"), "pfkna", 1, 1, S::npos);
+ test(S("getcrsaoji"), "ekosa", 1, 2, 1);
+ test(S("fjiknedcpq"), "anqhk", 1, 4, S::npos);
+ test(S("tkejgnafrm"), "jekca", 1, 5, 1);
+ test(S("jnakolqrde"), "ikemsjgacf", 1, 0, S::npos);
+ test(S("lcjptsmgbe"), "arolgsjkhm", 1, 1, S::npos);
+ test(S("itfsmcjorl"), "oftkbldhre", 1, 5, 1);
+ test(S("omchkfrjea"), "gbkqdoeftl", 1, 9, 0);
+ test(S("cigfqkated"), "sqcflrgtim", 1, 10, 1);
+ test(S("tscenjikml"), "fmhbkislrjdpanogqcet", 1, 0, S::npos);
+ test(S("qcpaemsinf"), "rnioadktqlgpbcjsmhef", 1, 1, S::npos);
+ test(S("gltkojeipd"), "oakgtnldpsefihqmjcbr", 1, 10, 1);
+ test(S("qistfrgnmp"), "gbnaelosidmcjqktfhpr", 1, 19, 1);
+ test(S("bdnpfcqaem"), "akbripjhlosndcmqgfet", 1, 20, 1);
+ test(S("ectnhskflp"), "", 5, 0, S::npos);
+ test(S("fgtianblpq"), "pijag", 5, 0, S::npos);
+ test(S("mfeqklirnh"), "jrckd", 5, 1, S::npos);
+ test(S("astedncjhk"), "qcloh", 5, 2, S::npos);
+ test(S("fhlqgcajbr"), "thlmp", 5, 4, 2);
+ test(S("epfhocmdng"), "qidmo", 5, 5, 4);
+ test(S("apcnsibger"), "lnegpsjqrd", 5, 0, S::npos);
+ test(S("aqkocrbign"), "rjqdablmfs", 5, 1, 5);
+ test(S("ijsmdtqgce"), "enkgpbsjaq", 5, 5, S::npos);
+ test(S("clobgsrken"), "kdsgoaijfh", 5, 9, 5);
+ test(S("jbhcfposld"), "trfqgmckbe", 5, 10, 4);
+ test(S("oqnpblhide"), "igetsracjfkdnpoblhqm", 5, 0, S::npos);
+ test(S("lroeasctif"), "nqctfaogirshlekbdjpm", 5, 1, S::npos);
+ test(S("bpjlgmiedh"), "csehfgomljdqinbartkp", 5, 10, 5);
+ test(S("pamkeoidrj"), "qahoegcmplkfsjbdnitr", 5, 19, 5);
+ test(S("espogqbthk"), "dpteiajrqmsognhlfbkc", 5, 20, 5);
+ test(S("shoiedtcjb"), "", 9, 0, S::npos);
+ test(S("ebcinjgads"), "tqbnh", 9, 0, S::npos);
+ test(S("dqmregkcfl"), "akmle", 9, 1, S::npos);
+ test(S("ngcrieqajf"), "iqfkm", 9, 2, 6);
+ test(S("qosmilgnjb"), "tqjsr", 9, 4, 8);
+ test(S("ikabsjtdfl"), "jplqg", 9, 5, 9);
+ test(S("ersmicafdh"), "oilnrbcgtj", 9, 0, S::npos);
+ test(S("fdnplotmgh"), "morkglpesn", 9, 1, 7);
+ test(S("fdbicojerm"), "dmicerngat", 9, 5, 9);
+ test(S("mbtafndjcq"), "radgeskbtc", 9, 9, 6);
+ test(S("mlenkpfdtc"), "ljikprsmqo", 9, 10, 5);
+ test(S("ahlcifdqgs"), "trqihkcgsjamfdbolnpe", 9, 0, S::npos);
+ test(S("bgjemaltks"), "lqmthbsrekajgnofcipd", 9, 1, 6);
+ test(S("pdhslbqrfc"), "jtalmedribkgqsopcnfh", 9, 10, 7);
+ test(S("dirhtsnjkc"), "spqfoiclmtagejbndkrh", 9, 19, 9);
+ test(S("dlroktbcja"), "nmotklspigjrdhcfaebq", 9, 20, 9);
+ test(S("ncjpmaekbs"), "", 10, 0, S::npos);
+ test(S("hlbosgmrak"), "hpmsd", 10, 0, S::npos);
+ test(S("pqfhsgilen"), "qnpor", 10, 1, 1);
+ test(S("gqtjsbdckh"), "otdma", 10, 2, 2);
+ test(S("cfkqpjlegi"), "efhjg", 10, 4, 7);
+ test(S("beanrfodgj"), "odpte", 10, 5, 7);
+ test(S("adtkqpbjfi"), "bctdgfmolr", 10, 0, S::npos);
+ test(S("iomkfthagj"), "oaklidrbqg", 10, 1, 1);
+}
+
+template <class S>
+void test2()
+{
+ test(S("sdpcilonqj"), "dnjfsagktr", 10, 5, 9);
+ test(S("gtfbdkqeml"), "nejaktmiqg", 10, 9, 8);
+ test(S("bmeqgcdorj"), "pjqonlebsf", 10, 10, 9);
+ test(S("etqlcanmob"), "dshmnbtolcjepgaikfqr", 10, 0, S::npos);
+ test(S("roqmkbdtia"), "iogfhpabtjkqlrnemcds", 10, 1, 8);
+ test(S("kadsithljf"), "ngridfabjsecpqltkmoh", 10, 10, 9);
+ test(S("sgtkpbfdmh"), "athmknplcgofrqejsdib", 10, 19, 9);
+ test(S("qgmetnabkl"), "ldobhmqcafnjtkeisgrp", 10, 20, 9);
+ test(S("cqjohampgd"), "", 11, 0, S::npos);
+ test(S("hobitmpsan"), "aocjb", 11, 0, S::npos);
+ test(S("tjehkpsalm"), "jbrnk", 11, 1, 1);
+ test(S("ngfbojitcl"), "tqedg", 11, 2, 7);
+ test(S("rcfkdbhgjo"), "nqskp", 11, 4, 3);
+ test(S("qghptonrea"), "eaqkl", 11, 5, 9);
+ test(S("hnprfgqjdl"), "reaoicljqm", 11, 0, S::npos);
+ test(S("hlmgabenti"), "lsftgajqpm", 11, 1, 1);
+ test(S("ofcjanmrbs"), "rlpfogmits", 11, 5, 7);
+ test(S("jqedtkornm"), "shkncmiaqj", 11, 9, 9);
+ test(S("rfedlasjmg"), "fpnatrhqgs", 11, 10, 9);
+ test(S("talpqjsgkm"), "sjclemqhnpdbgikarfot", 11, 0, S::npos);
+ test(S("lrkcbtqpie"), "otcmedjikgsfnqbrhpla", 11, 1, S::npos);
+ test(S("cipogdskjf"), "bonsaefdqiprkhlgtjcm", 11, 10, 9);
+ test(S("nqedcojahi"), "egpscmahijlfnkrodqtb", 11, 19, 9);
+ test(S("hefnrkmctj"), "kmqbfepjthgilscrndoa", 11, 20, 9);
+ test(S("atqirnmekfjolhpdsgcb"), "", 0, 0, S::npos);
+ test(S("echfkmlpribjnqsaogtd"), "prboq", 0, 0, S::npos);
+ test(S("qnhiftdgcleajbpkrosm"), "fjcqh", 0, 1, S::npos);
+ test(S("chamfknorbedjitgslpq"), "fmosa", 0, 2, S::npos);
+ test(S("njhqpibfmtlkaecdrgso"), "qdbok", 0, 4, S::npos);
+ test(S("ebnghfsqkprmdcljoiat"), "amslg", 0, 5, S::npos);
+ test(S("letjomsgihfrpqbkancd"), "smpltjneqb", 0, 0, S::npos);
+ test(S("nblgoipcrqeaktshjdmf"), "flitskrnge", 0, 1, S::npos);
+ test(S("cehkbngtjoiflqapsmrd"), "pgqihmlbef", 0, 5, S::npos);
+ test(S("mignapfoklbhcqjetdrs"), "cfpdqjtgsb", 0, 9, S::npos);
+ test(S("ceatbhlsqjgpnokfrmdi"), "htpsiaflom", 0, 10, S::npos);
+ test(S("ocihkjgrdelpfnmastqb"), "kpjfiaceghsrdtlbnomq", 0, 0, S::npos);
+ test(S("noelgschdtbrjfmiqkap"), "qhtbomidljgafneksprc", 0, 1, S::npos);
+ test(S("dkclqfombepritjnghas"), "nhtjobkcefldimpsaqgr", 0, 10, S::npos);
+ test(S("miklnresdgbhqcojftap"), "prabcjfqnoeskilmtgdh", 0, 19, 0);
+ test(S("htbcigojaqmdkfrnlsep"), "dtrgmchilkasqoebfpjn", 0, 20, 0);
+ test(S("febhmqtjanokscdirpgl"), "", 1, 0, S::npos);
+ test(S("loakbsqjpcrdhftniegm"), "sqome", 1, 0, S::npos);
+ test(S("reagphsqflbitdcjmkno"), "smfte", 1, 1, S::npos);
+ test(S("jitlfrqemsdhkopncabg"), "ciboh", 1, 2, 1);
+ test(S("mhtaepscdnrjqgbkifol"), "haois", 1, 4, 1);
+ test(S("tocesrfmnglpbjihqadk"), "abfki", 1, 5, S::npos);
+ test(S("lpfmctjrhdagneskbqoi"), "frdkocntmq", 1, 0, S::npos);
+ test(S("lsmqaepkdhncirbtjfgo"), "oasbpedlnr", 1, 1, S::npos);
+ test(S("epoiqmtldrabnkjhcfsg"), "kltqmhgand", 1, 5, S::npos);
+ test(S("emgasrilpknqojhtbdcf"), "gdtfjchpmr", 1, 9, 1);
+ test(S("hnfiagdpcklrjetqbsom"), "ponmcqblet", 1, 10, 1);
+ test(S("nsdfebgajhmtricpoklq"), "sgphqdnofeiklatbcmjr", 1, 0, S::npos);
+ test(S("atjgfsdlpobmeiqhncrk"), "ljqprsmigtfoneadckbh", 1, 1, S::npos);
+ test(S("sitodfgnrejlahcbmqkp"), "ligeojhafnkmrcsqtbdp", 1, 10, 1);
+ test(S("fraghmbiceknltjpqosd"), "lsimqfnjarbopedkhcgt", 1, 19, 1);
+ test(S("pmafenlhqtdbkirjsogc"), "abedmfjlghniorcqptks", 1, 20, 1);
+ test(S("pihgmoeqtnakrjslcbfd"), "", 10, 0, S::npos);
+ test(S("gjdkeprctqblnhiafsom"), "hqtoa", 10, 0, S::npos);
+ test(S("mkpnblfdsahrcqijteog"), "cahif", 10, 1, S::npos);
+ test(S("gckarqnelodfjhmbptis"), "kehis", 10, 2, 7);
+ test(S("gqpskidtbclomahnrjfe"), "kdlmh", 10, 4, 10);
+ test(S("pkldjsqrfgitbhmaecno"), "paeql", 10, 5, 6);
+ test(S("aftsijrbeklnmcdqhgop"), "aghoqiefnb", 10, 0, S::npos);
+ test(S("mtlgdrhafjkbiepqnsoc"), "jrbqaikpdo", 10, 1, 9);
+ test(S("pqgirnaefthokdmbsclj"), "smjonaeqcl", 10, 5, 5);
+ test(S("kpdbgjmtherlsfcqoina"), "eqbdrkcfah", 10, 9, 10);
+ test(S("jrlbothiknqmdgcfasep"), "kapmsienhf", 10, 10, 9);
+ test(S("mjogldqferckabinptsh"), "jpqotrlenfcsbhkaimdg", 10, 0, S::npos);
+ test(S("apoklnefbhmgqcdrisjt"), "jlbmhnfgtcqprikeados", 10, 1, S::npos);
+ test(S("ifeopcnrjbhkdgatmqls"), "stgbhfmdaljnpqoicker", 10, 10, 10);
+ test(S("ckqhaiesmjdnrgolbtpf"), "oihcetflbjagdsrkmqpn", 10, 19, 10);
+ test(S("bnlgapfimcoterskqdjh"), "adtclebmnpjsrqfkigoh", 10, 20, 10);
+ test(S("kgdlrobpmjcthqsafeni"), "", 19, 0, S::npos);
+ test(S("dfkechomjapgnslbtqir"), "beafg", 19, 0, S::npos);
+ test(S("rloadknfbqtgmhcsipje"), "iclat", 19, 1, 16);
+ test(S("mgjhkolrnadqbpetcifs"), "rkhnf", 19, 2, 7);
+ test(S("cmlfakiojdrgtbsphqen"), "clshq", 19, 4, 16);
+ test(S("kghbfipeomsntdalrqjc"), "dtcoj", 19, 5, 19);
+ test(S("eldiqckrnmtasbghjfpo"), "rqosnjmfth", 19, 0, S::npos);
+ test(S("abqjcfedgotihlnspkrm"), "siatdfqglh", 19, 1, 15);
+ test(S("qfbadrtjsimkolcenhpg"), "mrlshtpgjq", 19, 5, 17);
+ test(S("abseghclkjqifmtodrnp"), "adlcskgqjt", 19, 9, 16);
+ test(S("ibmsnlrjefhtdokacqpg"), "drshcjknaf", 19, 10, 16);
+ test(S("mrkfciqjebaponsthldg"), "etsaqroinghpkjdlfcbm", 19, 0, S::npos);
+ test(S("mjkticdeoqshpalrfbgn"), "sgepdnkqliambtrocfhj", 19, 1, 10);
+ test(S("rqnoclbdejgiphtfsakm"), "nlmcjaqgbsortfdihkpe", 19, 10, 19);
+ test(S("plkqbhmtfaeodjcrsing"), "racfnpmosldibqkghjet", 19, 19, 19);
+ test(S("oegalhmstjrfickpbndq"), "fjhdsctkqeiolagrnmbp", 19, 20, 19);
+ test(S("rdtgjcaohpblniekmsfq"), "", 20, 0, S::npos);
+ test(S("ofkqbnjetrmsaidphglc"), "ejanp", 20, 0, S::npos);
+ test(S("grkpahljcftesdmonqib"), "odife", 20, 1, 15);
+ test(S("jimlgbhfqkteospardcn"), "okaqd", 20, 2, 12);
+ test(S("gftenihpmslrjkqadcob"), "lcdbi", 20, 4, 19);
+ test(S("bmhldogtckrfsanijepq"), "fsqbj", 20, 5, 19);
+ test(S("nfqkrpjdesabgtlcmoih"), "bigdomnplq", 20, 0, S::npos);
+ test(S("focalnrpiqmdkstehbjg"), "apiblotgcd", 20, 1, 3);
+ test(S("rhqdspkmebiflcotnjga"), "acfhdenops", 20, 5, 19);
+ test(S("rahdtmsckfboqlpniegj"), "jopdeamcrk", 20, 9, 19);
+ test(S("fbkeiopclstmdqranjhg"), "trqncbkgmh", 20, 10, 19);
+ test(S("lifhpdgmbconstjeqark"), "tomglrkencbsfjqpihda", 20, 0, S::npos);
+}
+
+template <class S>
+void test3()
+{
+ test(S("pboqganrhedjmltsicfk"), "gbkhdnpoietfcmrslajq", 20, 1, 4);
+ test(S("klchabsimetjnqgorfpd"), "rtfnmbsglkjaichoqedp", 20, 10, 17);
+ test(S("sirfgmjqhctndbklaepo"), "ohkmdpfqbsacrtjnlgei", 20, 19, 19);
+ test(S("rlbdsiceaonqjtfpghkm"), "dlbrteoisgphmkncajfq", 20, 20, 19);
+ test(S("ecgdanriptblhjfqskom"), "", 21, 0, S::npos);
+ test(S("fdmiarlpgcskbhoteqjn"), "sjrlo", 21, 0, S::npos);
+ test(S("rlbstjqopignecmfadkh"), "qjpor", 21, 1, 6);
+ test(S("grjpqmbshektdolcafni"), "odhfn", 21, 2, 13);
+ test(S("sakfcohtqnibprjmlged"), "qtfin", 21, 4, 10);
+ test(S("mjtdglasihqpocebrfkn"), "hpqfo", 21, 5, 17);
+ test(S("okaplfrntghqbmeicsdj"), "fabmertkos", 21, 0, S::npos);
+ test(S("sahngemrtcjidqbklfpo"), "brqtgkmaej", 21, 1, 14);
+ test(S("dlmsipcnekhbgoaftqjr"), "nfrdeihsgl", 21, 5, 19);
+ test(S("ahegrmqnoiklpfsdbcjt"), "hlfrosekpi", 21, 9, 14);
+ test(S("hdsjbnmlegtkqripacof"), "atgbkrjdsm", 21, 10, 16);
+ test(S("pcnedrfjihqbalkgtoms"), "blnrptjgqmaifsdkhoec", 21, 0, S::npos);
+ test(S("qjidealmtpskrbfhocng"), "ctpmdahebfqjgknloris", 21, 1, 17);
+ test(S("qeindtagmokpfhsclrbj"), "apnkeqthrmlbfodiscgj", 21, 10, 17);
+ test(S("kpfegbjhsrnodltqciam"), "jdgictpframeoqlsbknh", 21, 19, 19);
+ test(S("hnbrcplsjfgiktoedmaq"), "qprlsfojamgndekthibc", 21, 20, 19);
+}
+
+int main()
+{
+ {
+ typedef std::experimental::string_view S;
+ test0<S>();
+ test1<S>();
+ test2<S>();
+ test3<S>();
+ }
+
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::experimental::basic_string_view<char, constexpr_char_traits<char>> SV;
+ constexpr SV sv1;
+ constexpr SV sv2 { "abcde", 5 };
+
+ static_assert (sv1.find_last_of( "", 0, 0) == SV::npos, "" );
+ static_assert (sv1.find_last_of( "irkhs", 0, 5) == SV::npos, "" );
+ static_assert (sv2.find_last_of( "", 0, 0) == SV::npos, "" );
+ static_assert (sv2.find_last_of( "gfsrt", 5, 5) == SV::npos, "" );
+ static_assert (sv2.find_last_of( "lecar", 5, 5) == 4, "" );
+ }
+#endif
+}
diff --git a/test/std/experimental/string.view/string.view.find/find_last_of_string_view_size.pass.cpp b/test/std/experimental/string.view/string.view.find/find_last_of_string_view_size.pass.cpp
new file mode 100644
index 000000000000..6fd3772fcc7d
--- /dev/null
+++ b/test/std/experimental/string.view/string.view.find/find_last_of_string_view_size.pass.cpp
@@ -0,0 +1,148 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string_view>
+
+// size_type find_last_of(const basic_string& str, size_type pos = npos) const;
+
+#include <experimental/string_view>
+#include <cassert>
+
+template <class S>
+void
+test(const S& s, const S& str, typename S::size_type pos, typename S::size_type x)
+{
+ assert(s.find_last_of(str, pos) == x);
+ if (x != S::npos)
+ assert(x <= pos && x < s.size());
+}
+
+template <class S>
+void
+test(const S& s, const S& str, typename S::size_type x)
+{
+ assert(s.find_last_of(str) == x);
+ if (x != S::npos)
+ assert(x < s.size());
+}
+
+template <class S>
+void test0()
+{
+ test(S(""), S(""), 0, S::npos);
+ test(S(""), S("laenf"), 0, S::npos);
+ test(S(""), S("pqlnkmbdjo"), 0, S::npos);
+ test(S(""), S("qkamfogpnljdcshbreti"), 0, S::npos);
+ test(S(""), S(""), 1, S::npos);
+ test(S(""), S("bjaht"), 1, S::npos);
+ test(S(""), S("hjlcmgpket"), 1, S::npos);
+ test(S(""), S("htaobedqikfplcgjsmrn"), 1, S::npos);
+ test(S("fodgq"), S(""), 0, S::npos);
+ test(S("qanej"), S("dfkap"), 0, S::npos);
+ test(S("clbao"), S("ihqrfebgad"), 0, S::npos);
+ test(S("mekdn"), S("ngtjfcalbseiqrphmkdo"), 0, 0);
+ test(S("srdfq"), S(""), 1, S::npos);
+ test(S("oemth"), S("ikcrq"), 1, S::npos);
+ test(S("cdaih"), S("dmajblfhsg"), 1, 1);
+ test(S("qohtk"), S("oqftjhdmkgsblacenirp"), 1, 1);
+ test(S("cshmd"), S(""), 2, S::npos);
+ test(S("lhcdo"), S("oebqi"), 2, S::npos);
+ test(S("qnsoh"), S("kojhpmbsfe"), 2, 2);
+ test(S("pkrof"), S("acbsjqogpltdkhinfrem"), 2, 2);
+ test(S("fmtsp"), S(""), 4, S::npos);
+ test(S("khbpm"), S("aobjd"), 4, 2);
+ test(S("pbsji"), S("pcbahntsje"), 4, 3);
+ test(S("mprdj"), S("fhepcrntkoagbmldqijs"), 4, 4);
+ test(S("eqmpa"), S(""), 5, S::npos);
+ test(S("omigs"), S("kocgb"), 5, 3);
+ test(S("onmje"), S("fbslrjiqkm"), 5, 3);
+ test(S("oqmrj"), S("jeidpcmalhfnqbgtrsko"), 5, 4);
+ test(S("schfa"), S(""), 6, S::npos);
+ test(S("igdsc"), S("qngpd"), 6, 2);
+ test(S("brqgo"), S("rodhqklgmb"), 6, 4);
+ test(S("tnrph"), S("thdjgafrlbkoiqcspmne"), 6, 4);
+ test(S("hcjitbfapl"), S(""), 0, S::npos);
+ test(S("daiprenocl"), S("ashjd"), 0, 0);
+ test(S("litpcfdghe"), S("mgojkldsqh"), 0, 0);
+ test(S("aidjksrolc"), S("imqnaghkfrdtlopbjesc"), 0, 0);
+ test(S("qpghtfbaji"), S(""), 1, S::npos);
+ test(S("gfshlcmdjr"), S("nadkh"), 1, S::npos);
+ test(S("nkodajteqp"), S("ofdrqmkebl"), 1, 1);
+ test(S("gbmetiprqd"), S("bdfjqgatlksriohemnpc"), 1, 1);
+ test(S("crnklpmegd"), S(""), 5, S::npos);
+ test(S("jsbtafedoc"), S("prqgn"), 5, S::npos);
+ test(S("qnmodrtkeb"), S("pejafmnokr"), 5, 5);
+ test(S("cpebqsfmnj"), S("odnqkgijrhabfmcestlp"), 5, 5);
+ test(S("lmofqdhpki"), S(""), 9, S::npos);
+ test(S("hnefkqimca"), S("rtjpa"), 9, 9);
+ test(S("drtasbgmfp"), S("ktsrmnqagd"), 9, 7);
+ test(S("lsaijeqhtr"), S("rtdhgcisbnmoaqkfpjle"), 9, 9);
+ test(S("elgofjmbrq"), S(""), 10, S::npos);
+ test(S("mjqdgalkpc"), S("dplqa"), 10, 8);
+ test(S("kthqnfcerm"), S("dkacjoptns"), 10, 6);
+ test(S("dfsjhanorc"), S("hqfimtrgnbekpdcsjalo"), 10, 9);
+ test(S("eqsgalomhb"), S(""), 11, S::npos);
+ test(S("akiteljmoh"), S("lofbc"), 11, 8);
+ test(S("hlbdfreqjo"), S("astoegbfpn"), 11, 9);
+ test(S("taqobhlerg"), S("pdgreqomsncafklhtibj"), 11, 9);
+ test(S("snafbdlghrjkpqtoceim"), S(""), 0, S::npos);
+ test(S("aemtbrgcklhndjisfpoq"), S("lbtqd"), 0, S::npos);
+ test(S("pnracgfkjdiholtbqsem"), S("tboimldpjh"), 0, 0);
+ test(S("dicfltehbsgrmojnpkaq"), S("slcerthdaiqjfnobgkpm"), 0, 0);
+ test(S("jlnkraeodhcspfgbqitm"), S(""), 1, S::npos);
+ test(S("lhosrngtmfjikbqpcade"), S("aqibs"), 1, S::npos);
+ test(S("rbtaqjhgkneisldpmfoc"), S("gtfblmqinc"), 1, 1);
+ test(S("gpifsqlrdkbonjtmheca"), S("mkqpbtdalgniorhfescj"), 1, 1);
+ test(S("hdpkobnsalmcfijregtq"), S(""), 10, S::npos);
+ test(S("jtlshdgqaiprkbcoenfm"), S("pblas"), 10, 10);
+ test(S("fkdrbqltsgmcoiphneaj"), S("arosdhcfme"), 10, 10);
+ test(S("crsplifgtqedjohnabmk"), S("blkhjeogicatqfnpdmsr"), 10, 10);
+ test(S("niptglfbosehkamrdqcj"), S(""), 19, S::npos);
+ test(S("copqdhstbingamjfkler"), S("djkqc"), 19, 16);
+ test(S("mrtaefilpdsgocnhqbjk"), S("lgokshjtpb"), 19, 19);
+ test(S("kojatdhlcmigpbfrqnes"), S("bqjhtkfepimcnsgrlado"), 19, 19);
+ test(S("eaintpchlqsbdgrkjofm"), S(""), 20, S::npos);
+ test(S("gjnhidfsepkrtaqbmclo"), S("nocfa"), 20, 19);
+ test(S("spocfaktqdbiejlhngmr"), S("bgtajmiedc"), 20, 18);
+ test(S("rphmlekgfscndtaobiqj"), S("lsckfnqgdahejiopbtmr"), 20, 19);
+ test(S("liatsqdoegkmfcnbhrpj"), S(""), 21, S::npos);
+ test(S("binjagtfldkrspcomqeh"), S("gfsrt"), 21, 12);
+ test(S("latkmisecnorjbfhqpdg"), S("pfsocbhjtm"), 21, 17);
+ test(S("lecfratdjkhnsmqpoigb"), S("tpflmdnoicjgkberhqsa"), 21, 19);
+}
+
+template <class S>
+void test1()
+{
+ test(S(""), S(""), S::npos);
+ test(S(""), S("laenf"), S::npos);
+ test(S(""), S("pqlnkmbdjo"), S::npos);
+ test(S(""), S("qkamfogpnljdcshbreti"), S::npos);
+ test(S("nhmko"), S(""), S::npos);
+ test(S("lahfb"), S("irkhs"), 2);
+ test(S("gmfhd"), S("kantesmpgj"), 1);
+ test(S("odaft"), S("oknlrstdpiqmjbaghcfe"), 4);
+ test(S("eolhfgpjqk"), S(""), S::npos);
+ test(S("nbatdlmekr"), S("bnrpe"), 9);
+ test(S("jdmciepkaq"), S("jtdaefblso"), 8);
+ test(S("hkbgspoflt"), S("oselktgbcapndfjihrmq"), 9);
+ test(S("gprdcokbnjhlsfmtieqa"), S(""), S::npos);
+ test(S("qjghlnftcaismkropdeb"), S("bjaht"), 19);
+ test(S("pnalfrdtkqcmojiesbhg"), S("hjlcmgpket"), 19);
+ test(S("pniotcfrhqsmgdkjbael"), S("htaobedqikfplcgjsmrn"), 19);
+}
+
+int main()
+{
+ {
+ typedef std::experimental::string_view S;
+ test0<S>();
+ test1<S>();
+ }
+}
diff --git a/test/std/experimental/string.view/string.view.find/find_pointer_size.pass.cpp b/test/std/experimental/string.view/string.view.find/find_pointer_size.pass.cpp
new file mode 100644
index 000000000000..5ebe414be096
--- /dev/null
+++ b/test/std/experimental/string.view/string.view.find/find_pointer_size.pass.cpp
@@ -0,0 +1,171 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// constexpr size_type find(const charT* s, size_type pos = 0) const;
+
+#include <experimental/string_view>
+#include <cassert>
+
+#include "constexpr_char_traits.hpp"
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type pos,
+ typename S::size_type x)
+{
+ assert(s.find(str, pos) == x);
+ if (x != S::npos)
+ {
+ typename S::size_type n = S::traits_type::length(str);
+ assert(pos <= x && x + n <= s.size());
+ }
+}
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type x)
+{
+ assert(s.find(str) == x);
+ if (x != S::npos)
+ {
+ typename S::size_type n = S::traits_type::length(str);
+ assert(0 <= x && x + n <= s.size());
+ }
+}
+
+template <class S>
+void test0()
+{
+ test(S(""), "", 0, 0);
+ test(S(""), "abcde", 0, S::npos);
+ test(S(""), "abcdeabcde", 0, S::npos);
+ test(S(""), "abcdeabcdeabcdeabcde", 0, S::npos);
+ test(S(""), "", 1, S::npos);
+ test(S(""), "abcde", 1, S::npos);
+ test(S(""), "abcdeabcde", 1, S::npos);
+ test(S(""), "abcdeabcdeabcdeabcde", 1, S::npos);
+ test(S("abcde"), "", 0, 0);
+ test(S("abcde"), "abcde", 0, 0);
+ test(S("abcde"), "abcdeabcde", 0, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 0, S::npos);
+ test(S("abcde"), "", 1, 1);
+ test(S("abcde"), "abcde", 1, S::npos);
+ test(S("abcde"), "abcdeabcde", 1, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 1, S::npos);
+ test(S("abcde"), "", 2, 2);
+ test(S("abcde"), "abcde", 2, S::npos);
+ test(S("abcde"), "abcdeabcde", 2, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 2, S::npos);
+ test(S("abcde"), "", 4, 4);
+ test(S("abcde"), "abcde", 4, S::npos);
+ test(S("abcde"), "abcdeabcde", 4, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 4, S::npos);
+ test(S("abcde"), "", 5, 5);
+ test(S("abcde"), "abcde", 5, S::npos);
+ test(S("abcde"), "abcdeabcde", 5, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 5, S::npos);
+ test(S("abcde"), "", 6, S::npos);
+ test(S("abcde"), "abcde", 6, S::npos);
+ test(S("abcde"), "abcdeabcde", 6, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 6, S::npos);
+ test(S("abcdeabcde"), "", 0, 0);
+ test(S("abcdeabcde"), "abcde", 0, 0);
+ test(S("abcdeabcde"), "abcdeabcde", 0, 0);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 0, S::npos);
+ test(S("abcdeabcde"), "", 1, 1);
+ test(S("abcdeabcde"), "abcde", 1, 5);
+ test(S("abcdeabcde"), "abcdeabcde", 1, S::npos);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 1, S::npos);
+ test(S("abcdeabcde"), "", 5, 5);
+ test(S("abcdeabcde"), "abcde", 5, 5);
+ test(S("abcdeabcde"), "abcdeabcde", 5, S::npos);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 5, S::npos);
+ test(S("abcdeabcde"), "", 9, 9);
+ test(S("abcdeabcde"), "abcde", 9, S::npos);
+ test(S("abcdeabcde"), "abcdeabcde", 9, S::npos);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 9, S::npos);
+ test(S("abcdeabcde"), "", 10, 10);
+ test(S("abcdeabcde"), "abcde", 10, S::npos);
+ test(S("abcdeabcde"), "abcdeabcde", 10, S::npos);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 10, S::npos);
+ test(S("abcdeabcde"), "", 11, S::npos);
+ test(S("abcdeabcde"), "abcde", 11, S::npos);
+ test(S("abcdeabcde"), "abcdeabcde", 11, S::npos);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 11, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "", 0, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 0, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 0, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0, 0);
+ test(S("abcdeabcdeabcdeabcde"), "", 1, 1);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 1, 5);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 1, 5);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 1, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "", 10, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 10, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 10, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 10, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "", 19, 19);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 19, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 19, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 19, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "", 20, 20);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 20, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 20, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 20, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "", 21, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 21, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 21, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 21, S::npos);
+}
+
+template <class S>
+void test1()
+{
+ test(S(""), "", 0);
+ test(S(""), "abcde", S::npos);
+ test(S(""), "abcdeabcde", S::npos);
+ test(S(""), "abcdeabcdeabcdeabcde", S::npos);
+ test(S("abcde"), "", 0);
+ test(S("abcde"), "abcde", 0);
+ test(S("abcde"), "abcdeabcde", S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", S::npos);
+ test(S("abcdeabcde"), "", 0);
+ test(S("abcdeabcde"), "abcde", 0);
+ test(S("abcdeabcde"), "abcdeabcde", 0);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "", 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0);
+}
+
+int main()
+{
+ {
+ typedef std::experimental::string_view S;
+ test0<S>();
+ test1<S>();
+ }
+
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::experimental::basic_string_view<char, constexpr_char_traits<char>> SV;
+ constexpr SV sv1;
+ constexpr SV sv2 { "abcde", 5 };
+
+ static_assert (sv1.find( "") == 0, "" );
+ static_assert (sv1.find( "abcde") == SV::npos, "" );
+ static_assert (sv2.find( "") == 0, "" );
+ static_assert (sv2.find( "abcde") == 0, "" );
+ static_assert (sv2.find( "abcde", 1) == SV::npos, "" );
+ }
+#endif
+}
diff --git a/test/std/experimental/string.view/string.view.find/find_pointer_size_size.pass.cpp b/test/std/experimental/string.view/string.view.find/find_pointer_size_size.pass.cpp
new file mode 100644
index 000000000000..382cbaf07934
--- /dev/null
+++ b/test/std/experimental/string.view/string.view.find/find_pointer_size_size.pass.cpp
@@ -0,0 +1,393 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string_view>
+
+// constexpr size_type find(const charT* s, size_type pos, size_type n) const;
+
+#include <experimental/string_view>
+#include <cassert>
+
+#include "constexpr_char_traits.hpp"
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type pos,
+ typename S::size_type n, typename S::size_type x)
+{
+ assert(s.find(str, pos, n) == x);
+ if (x != S::npos)
+ assert(pos <= x && x + n <= s.size());
+}
+
+template <class S>
+void test0()
+{
+ test(S(""), "", 0, 0, 0);
+ test(S(""), "abcde", 0, 0, 0);
+ test(S(""), "abcde", 0, 1, S::npos);
+ test(S(""), "abcde", 0, 2, S::npos);
+ test(S(""), "abcde", 0, 4, S::npos);
+ test(S(""), "abcde", 0, 5, S::npos);
+ test(S(""), "abcdeabcde", 0, 0, 0);
+ test(S(""), "abcdeabcde", 0, 1, S::npos);
+ test(S(""), "abcdeabcde", 0, 5, S::npos);
+ test(S(""), "abcdeabcde", 0, 9, S::npos);
+ test(S(""), "abcdeabcde", 0, 10, S::npos);
+ test(S(""), "abcdeabcdeabcdeabcde", 0, 0, 0);
+ test(S(""), "abcdeabcdeabcdeabcde", 0, 1, S::npos);
+ test(S(""), "abcdeabcdeabcdeabcde", 0, 10, S::npos);
+ test(S(""), "abcdeabcdeabcdeabcde", 0, 19, S::npos);
+ test(S(""), "abcdeabcdeabcdeabcde", 0, 20, S::npos);
+ test(S(""), "", 1, 0, S::npos);
+ test(S(""), "abcde", 1, 0, S::npos);
+ test(S(""), "abcde", 1, 1, S::npos);
+ test(S(""), "abcde", 1, 2, S::npos);
+ test(S(""), "abcde", 1, 4, S::npos);
+ test(S(""), "abcde", 1, 5, S::npos);
+ test(S(""), "abcdeabcde", 1, 0, S::npos);
+ test(S(""), "abcdeabcde", 1, 1, S::npos);
+ test(S(""), "abcdeabcde", 1, 5, S::npos);
+ test(S(""), "abcdeabcde", 1, 9, S::npos);
+ test(S(""), "abcdeabcde", 1, 10, S::npos);
+ test(S(""), "abcdeabcdeabcdeabcde", 1, 0, S::npos);
+ test(S(""), "abcdeabcdeabcdeabcde", 1, 1, S::npos);
+ test(S(""), "abcdeabcdeabcdeabcde", 1, 10, S::npos);
+ test(S(""), "abcdeabcdeabcdeabcde", 1, 19, S::npos);
+ test(S(""), "abcdeabcdeabcdeabcde", 1, 20, S::npos);
+ test(S("abcde"), "", 0, 0, 0);
+ test(S("abcde"), "abcde", 0, 0, 0);
+ test(S("abcde"), "abcde", 0, 1, 0);
+ test(S("abcde"), "abcde", 0, 2, 0);
+ test(S("abcde"), "abcde", 0, 4, 0);
+ test(S("abcde"), "abcde", 0, 5, 0);
+ test(S("abcde"), "abcdeabcde", 0, 0, 0);
+ test(S("abcde"), "abcdeabcde", 0, 1, 0);
+ test(S("abcde"), "abcdeabcde", 0, 5, 0);
+ test(S("abcde"), "abcdeabcde", 0, 9, S::npos);
+ test(S("abcde"), "abcdeabcde", 0, 10, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 0, 0, 0);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 0, 1, 0);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 0, 10, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 0, 19, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 0, 20, S::npos);
+ test(S("abcde"), "", 1, 0, 1);
+ test(S("abcde"), "abcde", 1, 0, 1);
+ test(S("abcde"), "abcde", 1, 1, S::npos);
+ test(S("abcde"), "abcde", 1, 2, S::npos);
+ test(S("abcde"), "abcde", 1, 4, S::npos);
+ test(S("abcde"), "abcde", 1, 5, S::npos);
+ test(S("abcde"), "abcdeabcde", 1, 0, 1);
+ test(S("abcde"), "abcdeabcde", 1, 1, S::npos);
+ test(S("abcde"), "abcdeabcde", 1, 5, S::npos);
+ test(S("abcde"), "abcdeabcde", 1, 9, S::npos);
+ test(S("abcde"), "abcdeabcde", 1, 10, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 1, 0, 1);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 1, 1, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 1, 10, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 1, 19, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 1, 20, S::npos);
+ test(S("abcde"), "", 2, 0, 2);
+ test(S("abcde"), "abcde", 2, 0, 2);
+ test(S("abcde"), "abcde", 2, 1, S::npos);
+ test(S("abcde"), "abcde", 2, 2, S::npos);
+ test(S("abcde"), "abcde", 2, 4, S::npos);
+ test(S("abcde"), "abcde", 2, 5, S::npos);
+ test(S("abcde"), "abcdeabcde", 2, 0, 2);
+ test(S("abcde"), "abcdeabcde", 2, 1, S::npos);
+ test(S("abcde"), "abcdeabcde", 2, 5, S::npos);
+ test(S("abcde"), "abcdeabcde", 2, 9, S::npos);
+ test(S("abcde"), "abcdeabcde", 2, 10, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 2, 0, 2);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 2, 1, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 2, 10, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 2, 19, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 2, 20, S::npos);
+ test(S("abcde"), "", 4, 0, 4);
+ test(S("abcde"), "abcde", 4, 0, 4);
+ test(S("abcde"), "abcde", 4, 1, S::npos);
+ test(S("abcde"), "abcde", 4, 2, S::npos);
+ test(S("abcde"), "abcde", 4, 4, S::npos);
+ test(S("abcde"), "abcde", 4, 5, S::npos);
+ test(S("abcde"), "abcdeabcde", 4, 0, 4);
+ test(S("abcde"), "abcdeabcde", 4, 1, S::npos);
+ test(S("abcde"), "abcdeabcde", 4, 5, S::npos);
+ test(S("abcde"), "abcdeabcde", 4, 9, S::npos);
+ test(S("abcde"), "abcdeabcde", 4, 10, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 4, 0, 4);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 4, 1, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 4, 10, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 4, 19, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 4, 20, S::npos);
+ test(S("abcde"), "", 5, 0, 5);
+ test(S("abcde"), "abcde", 5, 0, 5);
+ test(S("abcde"), "abcde", 5, 1, S::npos);
+ test(S("abcde"), "abcde", 5, 2, S::npos);
+}
+
+template <class S>
+void test1()
+{
+ test(S("abcde"), "abcde", 5, 4, S::npos);
+ test(S("abcde"), "abcde", 5, 5, S::npos);
+ test(S("abcde"), "abcdeabcde", 5, 0, 5);
+ test(S("abcde"), "abcdeabcde", 5, 1, S::npos);
+ test(S("abcde"), "abcdeabcde", 5, 5, S::npos);
+ test(S("abcde"), "abcdeabcde", 5, 9, S::npos);
+ test(S("abcde"), "abcdeabcde", 5, 10, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 5, 0, 5);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 5, 1, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 5, 10, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 5, 19, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 5, 20, S::npos);
+ test(S("abcde"), "", 6, 0, S::npos);
+ test(S("abcde"), "abcde", 6, 0, S::npos);
+ test(S("abcde"), "abcde", 6, 1, S::npos);
+ test(S("abcde"), "abcde", 6, 2, S::npos);
+ test(S("abcde"), "abcde", 6, 4, S::npos);
+ test(S("abcde"), "abcde", 6, 5, S::npos);
+ test(S("abcde"), "abcdeabcde", 6, 0, S::npos);
+ test(S("abcde"), "abcdeabcde", 6, 1, S::npos);
+ test(S("abcde"), "abcdeabcde", 6, 5, S::npos);
+ test(S("abcde"), "abcdeabcde", 6, 9, S::npos);
+ test(S("abcde"), "abcdeabcde", 6, 10, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 6, 0, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 6, 1, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 6, 10, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 6, 19, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 6, 20, S::npos);
+ test(S("abcdeabcde"), "", 0, 0, 0);
+ test(S("abcdeabcde"), "abcde", 0, 0, 0);
+ test(S("abcdeabcde"), "abcde", 0, 1, 0);
+ test(S("abcdeabcde"), "abcde", 0, 2, 0);
+ test(S("abcdeabcde"), "abcde", 0, 4, 0);
+ test(S("abcdeabcde"), "abcde", 0, 5, 0);
+ test(S("abcdeabcde"), "abcdeabcde", 0, 0, 0);
+ test(S("abcdeabcde"), "abcdeabcde", 0, 1, 0);
+ test(S("abcdeabcde"), "abcdeabcde", 0, 5, 0);
+ test(S("abcdeabcde"), "abcdeabcde", 0, 9, 0);
+ test(S("abcdeabcde"), "abcdeabcde", 0, 10, 0);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 0, 0, 0);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 0, 1, 0);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 0, 10, 0);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 0, 19, S::npos);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 0, 20, S::npos);
+ test(S("abcdeabcde"), "", 1, 0, 1);
+ test(S("abcdeabcde"), "abcde", 1, 0, 1);
+ test(S("abcdeabcde"), "abcde", 1, 1, 5);
+ test(S("abcdeabcde"), "abcde", 1, 2, 5);
+ test(S("abcdeabcde"), "abcde", 1, 4, 5);
+ test(S("abcdeabcde"), "abcde", 1, 5, 5);
+ test(S("abcdeabcde"), "abcdeabcde", 1, 0, 1);
+ test(S("abcdeabcde"), "abcdeabcde", 1, 1, 5);
+ test(S("abcdeabcde"), "abcdeabcde", 1, 5, 5);
+ test(S("abcdeabcde"), "abcdeabcde", 1, 9, S::npos);
+ test(S("abcdeabcde"), "abcdeabcde", 1, 10, S::npos);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 1, 0, 1);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 1, 1, 5);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 1, 10, S::npos);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 1, 19, S::npos);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 1, 20, S::npos);
+ test(S("abcdeabcde"), "", 5, 0, 5);
+ test(S("abcdeabcde"), "abcde", 5, 0, 5);
+ test(S("abcdeabcde"), "abcde", 5, 1, 5);
+ test(S("abcdeabcde"), "abcde", 5, 2, 5);
+ test(S("abcdeabcde"), "abcde", 5, 4, 5);
+ test(S("abcdeabcde"), "abcde", 5, 5, 5);
+ test(S("abcdeabcde"), "abcdeabcde", 5, 0, 5);
+ test(S("abcdeabcde"), "abcdeabcde", 5, 1, 5);
+ test(S("abcdeabcde"), "abcdeabcde", 5, 5, 5);
+ test(S("abcdeabcde"), "abcdeabcde", 5, 9, S::npos);
+ test(S("abcdeabcde"), "abcdeabcde", 5, 10, S::npos);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 5, 0, 5);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 5, 1, 5);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 5, 10, S::npos);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 5, 19, S::npos);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 5, 20, S::npos);
+ test(S("abcdeabcde"), "", 9, 0, 9);
+ test(S("abcdeabcde"), "abcde", 9, 0, 9);
+ test(S("abcdeabcde"), "abcde", 9, 1, S::npos);
+ test(S("abcdeabcde"), "abcde", 9, 2, S::npos);
+ test(S("abcdeabcde"), "abcde", 9, 4, S::npos);
+ test(S("abcdeabcde"), "abcde", 9, 5, S::npos);
+ test(S("abcdeabcde"), "abcdeabcde", 9, 0, 9);
+ test(S("abcdeabcde"), "abcdeabcde", 9, 1, S::npos);
+ test(S("abcdeabcde"), "abcdeabcde", 9, 5, S::npos);
+ test(S("abcdeabcde"), "abcdeabcde", 9, 9, S::npos);
+ test(S("abcdeabcde"), "abcdeabcde", 9, 10, S::npos);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 9, 0, 9);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 9, 1, S::npos);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 9, 10, S::npos);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 9, 19, S::npos);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 9, 20, S::npos);
+ test(S("abcdeabcde"), "", 10, 0, 10);
+ test(S("abcdeabcde"), "abcde", 10, 0, 10);
+ test(S("abcdeabcde"), "abcde", 10, 1, S::npos);
+ test(S("abcdeabcde"), "abcde", 10, 2, S::npos);
+ test(S("abcdeabcde"), "abcde", 10, 4, S::npos);
+ test(S("abcdeabcde"), "abcde", 10, 5, S::npos);
+ test(S("abcdeabcde"), "abcdeabcde", 10, 0, 10);
+ test(S("abcdeabcde"), "abcdeabcde", 10, 1, S::npos);
+}
+
+template <class S>
+void test2()
+{
+ test(S("abcdeabcde"), "abcdeabcde", 10, 5, S::npos);
+ test(S("abcdeabcde"), "abcdeabcde", 10, 9, S::npos);
+ test(S("abcdeabcde"), "abcdeabcde", 10, 10, S::npos);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 10, 0, 10);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 10, 1, S::npos);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 10, 10, S::npos);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 10, 19, S::npos);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 10, 20, S::npos);
+ test(S("abcdeabcde"), "", 11, 0, S::npos);
+ test(S("abcdeabcde"), "abcde", 11, 0, S::npos);
+ test(S("abcdeabcde"), "abcde", 11, 1, S::npos);
+ test(S("abcdeabcde"), "abcde", 11, 2, S::npos);
+ test(S("abcdeabcde"), "abcde", 11, 4, S::npos);
+ test(S("abcdeabcde"), "abcde", 11, 5, S::npos);
+ test(S("abcdeabcde"), "abcdeabcde", 11, 0, S::npos);
+ test(S("abcdeabcde"), "abcdeabcde", 11, 1, S::npos);
+ test(S("abcdeabcde"), "abcdeabcde", 11, 5, S::npos);
+ test(S("abcdeabcde"), "abcdeabcde", 11, 9, S::npos);
+ test(S("abcdeabcde"), "abcdeabcde", 11, 10, S::npos);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 11, 0, S::npos);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 11, 1, S::npos);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 11, 10, S::npos);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 11, 19, S::npos);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 11, 20, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "", 0, 0, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 0, 0, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 0, 1, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 0, 2, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 0, 4, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 0, 5, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 0, 0, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 0, 1, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 0, 5, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 0, 9, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 0, 10, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0, 0, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0, 1, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0, 10, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0, 19, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0, 20, 0);
+ test(S("abcdeabcdeabcdeabcde"), "", 1, 0, 1);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 1, 0, 1);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 1, 1, 5);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 1, 2, 5);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 1, 4, 5);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 1, 5, 5);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 1, 0, 1);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 1, 1, 5);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 1, 5, 5);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 1, 9, 5);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 1, 10, 5);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 1, 0, 1);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 1, 1, 5);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 1, 10, 5);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 1, 19, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 1, 20, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "", 10, 0, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 10, 0, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 10, 1, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 10, 2, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 10, 4, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 10, 5, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 10, 0, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 10, 1, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 10, 5, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 10, 9, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 10, 10, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 10, 0, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 10, 1, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 10, 10, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 10, 19, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 10, 20, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "", 19, 0, 19);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 19, 0, 19);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 19, 1, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 19, 2, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 19, 4, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 19, 5, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 19, 0, 19);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 19, 1, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 19, 5, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 19, 9, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 19, 10, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 19, 0, 19);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 19, 1, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 19, 10, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 19, 19, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 19, 20, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "", 20, 0, 20);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 20, 0, 20);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 20, 1, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 20, 2, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 20, 4, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 20, 5, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 20, 0, 20);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 20, 1, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 20, 5, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 20, 9, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 20, 10, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 20, 0, 20);
+}
+
+template <class S>
+void test3()
+{
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 20, 1, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 20, 10, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 20, 19, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 20, 20, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "", 21, 0, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 21, 0, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 21, 1, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 21, 2, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 21, 4, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 21, 5, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 21, 0, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 21, 1, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 21, 5, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 21, 9, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 21, 10, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 21, 0, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 21, 1, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 21, 10, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 21, 19, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 21, 20, S::npos);
+}
+
+int main()
+{
+ {
+ typedef std::experimental::string_view S;
+ test0<S>();
+ test1<S>();
+ test2<S>();
+ test3<S>();
+ }
+
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::experimental::basic_string_view<char, constexpr_char_traits<char>> SV;
+ constexpr SV sv1;
+ constexpr SV sv2 { "abcde", 5 };
+
+ static_assert (sv1.find( "", 0, 0 ) == 0, "" );
+ static_assert (sv1.find( "abcde", 0, 0 ) == 0, "" );
+ static_assert (sv1.find( "abcde", 0, 1 ) == SV::npos, "" );
+ static_assert (sv2.find( "", 0, 0 ) == 0, "" );
+ static_assert (sv2.find( "abcde", 0, 0 ) == 0, "" );
+ static_assert (sv2.find( "abcde", 0, 1 ) == 0, "" );
+ }
+#endif
+}
diff --git a/test/std/experimental/string.view/string.view.find/find_string_view_size.pass.cpp b/test/std/experimental/string.view/string.view.find/find_string_view_size.pass.cpp
new file mode 100644
index 000000000000..84132ac7a161
--- /dev/null
+++ b/test/std/experimental/string.view/string.view.find/find_string_view_size.pass.cpp
@@ -0,0 +1,164 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string_view>
+
+// constexpr size_type find(const basic_string_view& str, size_type pos = 0) const;
+
+#include <experimental/string_view>
+#include <cassert>
+
+#include "constexpr_char_traits.hpp"
+
+template <class S>
+void
+test(const S& s, const S& str, typename S::size_type pos, typename S::size_type x)
+{
+ assert(s.find(str, pos) == x);
+ if (x != S::npos)
+ assert(pos <= x && x + str.size() <= s.size());
+}
+
+template <class S>
+void
+test(const S& s, const S& str, typename S::size_type x)
+{
+ assert(s.find(str) == x);
+ if (x != S::npos)
+ assert(0 <= x && x + str.size() <= s.size());
+}
+
+template <class S>
+void test0()
+{
+ test(S(""), S(""), 0, 0);
+ test(S(""), S("abcde"), 0, S::npos);
+ test(S(""), S("abcdeabcde"), 0, S::npos);
+ test(S(""), S("abcdeabcdeabcdeabcde"), 0, S::npos);
+ test(S(""), S(""), 1, S::npos);
+ test(S(""), S("abcde"), 1, S::npos);
+ test(S(""), S("abcdeabcde"), 1, S::npos);
+ test(S(""), S("abcdeabcdeabcdeabcde"), 1, S::npos);
+ test(S("abcde"), S(""), 0, 0);
+ test(S("abcde"), S("abcde"), 0, 0);
+ test(S("abcde"), S("abcdeabcde"), 0, S::npos);
+ test(S("abcde"), S("abcdeabcdeabcdeabcde"), 0, S::npos);
+ test(S("abcde"), S(""), 1, 1);
+ test(S("abcde"), S("abcde"), 1, S::npos);
+ test(S("abcde"), S("abcdeabcde"), 1, S::npos);
+ test(S("abcde"), S("abcdeabcdeabcdeabcde"), 1, S::npos);
+ test(S("abcde"), S(""), 2, 2);
+ test(S("abcde"), S("abcde"), 2, S::npos);
+ test(S("abcde"), S("abcdeabcde"), 2, S::npos);
+ test(S("abcde"), S("abcdeabcdeabcdeabcde"), 2, S::npos);
+ test(S("abcde"), S(""), 4, 4);
+ test(S("abcde"), S("abcde"), 4, S::npos);
+ test(S("abcde"), S("abcdeabcde"), 4, S::npos);
+ test(S("abcde"), S("abcdeabcdeabcdeabcde"), 4, S::npos);
+ test(S("abcde"), S(""), 5, 5);
+ test(S("abcde"), S("abcde"), 5, S::npos);
+ test(S("abcde"), S("abcdeabcde"), 5, S::npos);
+ test(S("abcde"), S("abcdeabcdeabcdeabcde"), 5, S::npos);
+ test(S("abcde"), S(""), 6, S::npos);
+ test(S("abcde"), S("abcde"), 6, S::npos);
+ test(S("abcde"), S("abcdeabcde"), 6, S::npos);
+ test(S("abcde"), S("abcdeabcdeabcdeabcde"), 6, S::npos);
+ test(S("abcdeabcde"), S(""), 0, 0);
+ test(S("abcdeabcde"), S("abcde"), 0, 0);
+ test(S("abcdeabcde"), S("abcdeabcde"), 0, 0);
+ test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), 0, S::npos);
+ test(S("abcdeabcde"), S(""), 1, 1);
+ test(S("abcdeabcde"), S("abcde"), 1, 5);
+ test(S("abcdeabcde"), S("abcdeabcde"), 1, S::npos);
+ test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), 1, S::npos);
+ test(S("abcdeabcde"), S(""), 5, 5);
+ test(S("abcdeabcde"), S("abcde"), 5, 5);
+ test(S("abcdeabcde"), S("abcdeabcde"), 5, S::npos);
+ test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), 5, S::npos);
+ test(S("abcdeabcde"), S(""), 9, 9);
+ test(S("abcdeabcde"), S("abcde"), 9, S::npos);
+ test(S("abcdeabcde"), S("abcdeabcde"), 9, S::npos);
+ test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), 9, S::npos);
+ test(S("abcdeabcde"), S(""), 10, 10);
+ test(S("abcdeabcde"), S("abcde"), 10, S::npos);
+ test(S("abcdeabcde"), S("abcdeabcde"), 10, S::npos);
+ test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), 10, S::npos);
+ test(S("abcdeabcde"), S(""), 11, S::npos);
+ test(S("abcdeabcde"), S("abcde"), 11, S::npos);
+ test(S("abcdeabcde"), S("abcdeabcde"), 11, S::npos);
+ test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), 11, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), S(""), 0, 0);
+ test(S("abcdeabcdeabcdeabcde"), S("abcde"), 0, 0);
+ test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 0, 0);
+ test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 0, 0);
+ test(S("abcdeabcdeabcdeabcde"), S(""), 1, 1);
+ test(S("abcdeabcdeabcdeabcde"), S("abcde"), 1, 5);
+ test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 1, 5);
+ test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 1, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), S(""), 10, 10);
+ test(S("abcdeabcdeabcdeabcde"), S("abcde"), 10, 10);
+ test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 10, 10);
+ test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 10, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), S(""), 19, 19);
+ test(S("abcdeabcdeabcdeabcde"), S("abcde"), 19, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 19, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 19, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), S(""), 20, 20);
+ test(S("abcdeabcdeabcdeabcde"), S("abcde"), 20, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 20, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 20, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), S(""), 21, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), S("abcde"), 21, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 21, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 21, S::npos);
+}
+
+template <class S>
+void test1()
+{
+ test(S(""), S(""), 0);
+ test(S(""), S("abcde"), S::npos);
+ test(S(""), S("abcdeabcde"), S::npos);
+ test(S(""), S("abcdeabcdeabcdeabcde"), S::npos);
+ test(S("abcde"), S(""), 0);
+ test(S("abcde"), S("abcde"), 0);
+ test(S("abcde"), S("abcdeabcde"), S::npos);
+ test(S("abcde"), S("abcdeabcdeabcdeabcde"), S::npos);
+ test(S("abcdeabcde"), S(""), 0);
+ test(S("abcdeabcde"), S("abcde"), 0);
+ test(S("abcdeabcde"), S("abcdeabcde"), 0);
+ test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), S::npos);
+ test(S("abcdeabcdeabcdeabcde"), S(""), 0);
+ test(S("abcdeabcdeabcdeabcde"), S("abcde"), 0);
+ test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 0);
+ test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 0);
+}
+
+int main()
+{
+ {
+ typedef std::experimental::string_view S;
+ test0<S>();
+ test1<S>();
+ }
+
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::experimental::basic_string_view<char, constexpr_char_traits<char>> SV;
+ constexpr SV sv1;
+ constexpr SV sv2 { "abcde", 5 };
+
+ static_assert (sv1.find(sv1) == 0, "" );
+ static_assert (sv1.find(sv2) == SV::npos, "" );
+ static_assert (sv2.find(sv1) == 0, "" );
+ static_assert (sv2.find(sv2) == 0, "" );
+ static_assert (sv2.find(sv2, 1 ) == SV::npos, "" );
+ }
+#endif
+}
diff --git a/test/std/experimental/string.view/string.view.find/rfind_char_size.pass.cpp b/test/std/experimental/string.view/string.view.find/rfind_char_size.pass.cpp
new file mode 100644
index 000000000000..9014d888d4ef
--- /dev/null
+++ b/test/std/experimental/string.view/string.view.find/rfind_char_size.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string_view>
+// constexpr size_type rfind(charT c, size_type pos = npos) const;
+
+#include <experimental/string_view>
+#include <cassert>
+
+#include "constexpr_char_traits.hpp"
+
+template <class S>
+void
+test(const S& s, typename S::value_type c, typename S::size_type pos,
+ typename S::size_type x)
+{
+ assert(s.rfind(c, pos) == x);
+ if (x != S::npos)
+ assert(x <= pos && x + 1 <= s.size());
+}
+
+template <class S>
+void
+test(const S& s, typename S::value_type c, typename S::size_type x)
+{
+ assert(s.rfind(c) == x);
+ if (x != S::npos)
+ assert(x + 1 <= s.size());
+}
+
+int main()
+{
+ {
+ typedef std::experimental::string_view S;
+ test(S(""), 'b', 0, S::npos);
+ test(S(""), 'b', 1, S::npos);
+ test(S("abcde"), 'b', 0, S::npos);
+ test(S("abcde"), 'b', 1, 1);
+ test(S("abcde"), 'b', 2, 1);
+ test(S("abcde"), 'b', 4, 1);
+ test(S("abcde"), 'b', 5, 1);
+ test(S("abcde"), 'b', 6, 1);
+ test(S("abcdeabcde"), 'b', 0, S::npos);
+ test(S("abcdeabcde"), 'b', 1, 1);
+ test(S("abcdeabcde"), 'b', 5, 1);
+ test(S("abcdeabcde"), 'b', 9, 6);
+ test(S("abcdeabcde"), 'b', 10, 6);
+ test(S("abcdeabcde"), 'b', 11, 6);
+ test(S("abcdeabcdeabcdeabcde"), 'b', 0, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), 'b', 1, 1);
+ test(S("abcdeabcdeabcdeabcde"), 'b', 10, 6);
+ test(S("abcdeabcdeabcdeabcde"), 'b', 19, 16);
+ test(S("abcdeabcdeabcdeabcde"), 'b', 20, 16);
+ test(S("abcdeabcdeabcdeabcde"), 'b', 21, 16);
+
+ test(S(""), 'b', S::npos);
+ test(S("abcde"), 'b', 1);
+ test(S("abcdeabcde"), 'b', 6);
+ test(S("abcdeabcdeabcdeabcde"), 'b', 16);
+ }
+
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::experimental::basic_string_view<char, constexpr_char_traits<char>> SV;
+ constexpr SV sv1;
+ constexpr SV sv2 { "abcde", 5 };
+
+ static_assert (sv1.rfind( 'b', 0 ) == SV::npos, "" );
+ static_assert (sv1.rfind( 'b', 1 ) == SV::npos, "" );
+ static_assert (sv2.rfind( 'b', 0 ) == SV::npos, "" );
+ static_assert (sv2.rfind( 'b', 1 ) == 1, "" );
+ static_assert (sv2.rfind( 'b', 2 ) == 1, "" );
+ static_assert (sv2.rfind( 'b', 3 ) == 1, "" );
+ static_assert (sv2.rfind( 'b', 4 ) == 1, "" );
+ }
+#endif
+}
diff --git a/test/std/experimental/string.view/string.view.find/rfind_pointer_size.pass.cpp b/test/std/experimental/string.view/string.view.find/rfind_pointer_size.pass.cpp
new file mode 100644
index 000000000000..0559d3121db9
--- /dev/null
+++ b/test/std/experimental/string.view/string.view.find/rfind_pointer_size.pass.cpp
@@ -0,0 +1,171 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string_view>
+// constexpr size_type rfind(const charT* s, size_type pos = npos) const;
+
+#include <experimental/string_view>
+#include <cassert>
+
+#include "constexpr_char_traits.hpp"
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type pos,
+ typename S::size_type x)
+{
+ assert(s.rfind(str, pos) == x);
+ if (x != S::npos)
+ {
+ typename S::size_type n = S::traits_type::length(str);
+ assert(x <= pos && x + n <= s.size());
+ }
+}
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type x)
+{
+ assert(s.rfind(str) == x);
+ if (x != S::npos)
+ {
+ typename S::size_type pos = s.size();
+ typename S::size_type n = S::traits_type::length(str);
+ assert(x <= pos && x + n <= s.size());
+ }
+}
+
+template <class S>
+void test0()
+{
+ test(S(""), "", 0, 0);
+ test(S(""), "abcde", 0, S::npos);
+ test(S(""), "abcdeabcde", 0, S::npos);
+ test(S(""), "abcdeabcdeabcdeabcde", 0, S::npos);
+ test(S(""), "", 1, 0);
+ test(S(""), "abcde", 1, S::npos);
+ test(S(""), "abcdeabcde", 1, S::npos);
+ test(S(""), "abcdeabcdeabcdeabcde", 1, S::npos);
+ test(S("abcde"), "", 0, 0);
+ test(S("abcde"), "abcde", 0, 0);
+ test(S("abcde"), "abcdeabcde", 0, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 0, S::npos);
+ test(S("abcde"), "", 1, 1);
+ test(S("abcde"), "abcde", 1, 0);
+ test(S("abcde"), "abcdeabcde", 1, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 1, S::npos);
+ test(S("abcde"), "", 2, 2);
+ test(S("abcde"), "abcde", 2, 0);
+ test(S("abcde"), "abcdeabcde", 2, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 2, S::npos);
+ test(S("abcde"), "", 4, 4);
+ test(S("abcde"), "abcde", 4, 0);
+ test(S("abcde"), "abcdeabcde", 4, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 4, S::npos);
+ test(S("abcde"), "", 5, 5);
+ test(S("abcde"), "abcde", 5, 0);
+ test(S("abcde"), "abcdeabcde", 5, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 5, S::npos);
+ test(S("abcde"), "", 6, 5);
+ test(S("abcde"), "abcde", 6, 0);
+ test(S("abcde"), "abcdeabcde", 6, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 6, S::npos);
+ test(S("abcdeabcde"), "", 0, 0);
+ test(S("abcdeabcde"), "abcde", 0, 0);
+ test(S("abcdeabcde"), "abcdeabcde", 0, 0);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 0, S::npos);
+ test(S("abcdeabcde"), "", 1, 1);
+ test(S("abcdeabcde"), "abcde", 1, 0);
+ test(S("abcdeabcde"), "abcdeabcde", 1, 0);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 1, S::npos);
+ test(S("abcdeabcde"), "", 5, 5);
+ test(S("abcdeabcde"), "abcde", 5, 5);
+ test(S("abcdeabcde"), "abcdeabcde", 5, 0);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 5, S::npos);
+ test(S("abcdeabcde"), "", 9, 9);
+ test(S("abcdeabcde"), "abcde", 9, 5);
+ test(S("abcdeabcde"), "abcdeabcde", 9, 0);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 9, S::npos);
+ test(S("abcdeabcde"), "", 10, 10);
+ test(S("abcdeabcde"), "abcde", 10, 5);
+ test(S("abcdeabcde"), "abcdeabcde", 10, 0);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 10, S::npos);
+ test(S("abcdeabcde"), "", 11, 10);
+ test(S("abcdeabcde"), "abcde", 11, 5);
+ test(S("abcdeabcde"), "abcdeabcde", 11, 0);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 11, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "", 0, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 0, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 0, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0, 0);
+ test(S("abcdeabcdeabcdeabcde"), "", 1, 1);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 1, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 1, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 1, 0);
+ test(S("abcdeabcdeabcdeabcde"), "", 10, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 10, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 10, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 10, 0);
+ test(S("abcdeabcdeabcdeabcde"), "", 19, 19);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 19, 15);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 19, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 19, 0);
+ test(S("abcdeabcdeabcdeabcde"), "", 20, 20);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 20, 15);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 20, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 20, 0);
+ test(S("abcdeabcdeabcdeabcde"), "", 21, 20);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 21, 15);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 21, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 21, 0);
+}
+
+template <class S>
+void test1()
+{
+ test(S(""), "", 0);
+ test(S(""), "abcde", S::npos);
+ test(S(""), "abcdeabcde", S::npos);
+ test(S(""), "abcdeabcdeabcdeabcde", S::npos);
+ test(S("abcde"), "", 5);
+ test(S("abcde"), "abcde", 0);
+ test(S("abcde"), "abcdeabcde", S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", S::npos);
+ test(S("abcdeabcde"), "", 10);
+ test(S("abcdeabcde"), "abcde", 5);
+ test(S("abcdeabcde"), "abcdeabcde", 0);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "", 20);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 15);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0);
+}
+
+int main()
+{
+ {
+ typedef std::experimental::string_view S;
+ test0<S>();
+ test1<S>();
+ }
+
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::experimental::basic_string_view<char, constexpr_char_traits<char>> SV;
+ constexpr SV sv1;
+ constexpr SV sv2 { "abcde", 5 };
+
+ static_assert (sv1.rfind( "") == 0, "" );
+ static_assert (sv1.rfind( "abcde") == SV::npos, "" );
+ static_assert (sv2.rfind( "") == 5, "" );
+ static_assert (sv2.rfind( "abcde") == 0, "" );
+ static_assert (sv2.rfind( "abcde", 1) == 0, "" );
+ }
+#endif
+}
diff --git a/test/std/experimental/string.view/string.view.find/rfind_pointer_size_size.pass.cpp b/test/std/experimental/string.view/string.view.find/rfind_pointer_size_size.pass.cpp
new file mode 100644
index 000000000000..9116e3aa95a8
--- /dev/null
+++ b/test/std/experimental/string.view/string.view.find/rfind_pointer_size_size.pass.cpp
@@ -0,0 +1,392 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string_view>
+// constexpr size_type rfind(const charT* s, size_type pos, size_type n) const;
+
+#include <experimental/string_view>
+#include <cassert>
+
+#include "constexpr_char_traits.hpp"
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type pos,
+ typename S::size_type n, typename S::size_type x)
+{
+ assert(s.rfind(str, pos, n) == x);
+ if (x != S::npos)
+ assert(x <= pos && x + n <= s.size());
+}
+
+template <class S>
+void test0()
+{
+ test(S(""), "", 0, 0, 0);
+ test(S(""), "abcde", 0, 0, 0);
+ test(S(""), "abcde", 0, 1, S::npos);
+ test(S(""), "abcde", 0, 2, S::npos);
+ test(S(""), "abcde", 0, 4, S::npos);
+ test(S(""), "abcde", 0, 5, S::npos);
+ test(S(""), "abcdeabcde", 0, 0, 0);
+ test(S(""), "abcdeabcde", 0, 1, S::npos);
+ test(S(""), "abcdeabcde", 0, 5, S::npos);
+ test(S(""), "abcdeabcde", 0, 9, S::npos);
+ test(S(""), "abcdeabcde", 0, 10, S::npos);
+ test(S(""), "abcdeabcdeabcdeabcde", 0, 0, 0);
+ test(S(""), "abcdeabcdeabcdeabcde", 0, 1, S::npos);
+ test(S(""), "abcdeabcdeabcdeabcde", 0, 10, S::npos);
+ test(S(""), "abcdeabcdeabcdeabcde", 0, 19, S::npos);
+ test(S(""), "abcdeabcdeabcdeabcde", 0, 20, S::npos);
+ test(S(""), "", 1, 0, 0);
+ test(S(""), "abcde", 1, 0, 0);
+ test(S(""), "abcde", 1, 1, S::npos);
+ test(S(""), "abcde", 1, 2, S::npos);
+ test(S(""), "abcde", 1, 4, S::npos);
+ test(S(""), "abcde", 1, 5, S::npos);
+ test(S(""), "abcdeabcde", 1, 0, 0);
+ test(S(""), "abcdeabcde", 1, 1, S::npos);
+ test(S(""), "abcdeabcde", 1, 5, S::npos);
+ test(S(""), "abcdeabcde", 1, 9, S::npos);
+ test(S(""), "abcdeabcde", 1, 10, S::npos);
+ test(S(""), "abcdeabcdeabcdeabcde", 1, 0, 0);
+ test(S(""), "abcdeabcdeabcdeabcde", 1, 1, S::npos);
+ test(S(""), "abcdeabcdeabcdeabcde", 1, 10, S::npos);
+ test(S(""), "abcdeabcdeabcdeabcde", 1, 19, S::npos);
+ test(S(""), "abcdeabcdeabcdeabcde", 1, 20, S::npos);
+ test(S("abcde"), "", 0, 0, 0);
+ test(S("abcde"), "abcde", 0, 0, 0);
+ test(S("abcde"), "abcde", 0, 1, 0);
+ test(S("abcde"), "abcde", 0, 2, 0);
+ test(S("abcde"), "abcde", 0, 4, 0);
+ test(S("abcde"), "abcde", 0, 5, 0);
+ test(S("abcde"), "abcdeabcde", 0, 0, 0);
+ test(S("abcde"), "abcdeabcde", 0, 1, 0);
+ test(S("abcde"), "abcdeabcde", 0, 5, 0);
+ test(S("abcde"), "abcdeabcde", 0, 9, S::npos);
+ test(S("abcde"), "abcdeabcde", 0, 10, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 0, 0, 0);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 0, 1, 0);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 0, 10, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 0, 19, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 0, 20, S::npos);
+ test(S("abcde"), "", 1, 0, 1);
+ test(S("abcde"), "abcde", 1, 0, 1);
+ test(S("abcde"), "abcde", 1, 1, 0);
+ test(S("abcde"), "abcde", 1, 2, 0);
+ test(S("abcde"), "abcde", 1, 4, 0);
+ test(S("abcde"), "abcde", 1, 5, 0);
+ test(S("abcde"), "abcdeabcde", 1, 0, 1);
+ test(S("abcde"), "abcdeabcde", 1, 1, 0);
+ test(S("abcde"), "abcdeabcde", 1, 5, 0);
+ test(S("abcde"), "abcdeabcde", 1, 9, S::npos);
+ test(S("abcde"), "abcdeabcde", 1, 10, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 1, 0, 1);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 1, 1, 0);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 1, 10, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 1, 19, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 1, 20, S::npos);
+ test(S("abcde"), "", 2, 0, 2);
+ test(S("abcde"), "abcde", 2, 0, 2);
+ test(S("abcde"), "abcde", 2, 1, 0);
+ test(S("abcde"), "abcde", 2, 2, 0);
+ test(S("abcde"), "abcde", 2, 4, 0);
+ test(S("abcde"), "abcde", 2, 5, 0);
+ test(S("abcde"), "abcdeabcde", 2, 0, 2);
+ test(S("abcde"), "abcdeabcde", 2, 1, 0);
+ test(S("abcde"), "abcdeabcde", 2, 5, 0);
+ test(S("abcde"), "abcdeabcde", 2, 9, S::npos);
+ test(S("abcde"), "abcdeabcde", 2, 10, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 2, 0, 2);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 2, 1, 0);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 2, 10, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 2, 19, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 2, 20, S::npos);
+ test(S("abcde"), "", 4, 0, 4);
+ test(S("abcde"), "abcde", 4, 0, 4);
+ test(S("abcde"), "abcde", 4, 1, 0);
+ test(S("abcde"), "abcde", 4, 2, 0);
+ test(S("abcde"), "abcde", 4, 4, 0);
+ test(S("abcde"), "abcde", 4, 5, 0);
+ test(S("abcde"), "abcdeabcde", 4, 0, 4);
+ test(S("abcde"), "abcdeabcde", 4, 1, 0);
+ test(S("abcde"), "abcdeabcde", 4, 5, 0);
+ test(S("abcde"), "abcdeabcde", 4, 9, S::npos);
+ test(S("abcde"), "abcdeabcde", 4, 10, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 4, 0, 4);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 4, 1, 0);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 4, 10, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 4, 19, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 4, 20, S::npos);
+ test(S("abcde"), "", 5, 0, 5);
+ test(S("abcde"), "abcde", 5, 0, 5);
+ test(S("abcde"), "abcde", 5, 1, 0);
+ test(S("abcde"), "abcde", 5, 2, 0);
+}
+
+template <class S>
+void test1()
+{
+ test(S("abcde"), "abcde", 5, 4, 0);
+ test(S("abcde"), "abcde", 5, 5, 0);
+ test(S("abcde"), "abcdeabcde", 5, 0, 5);
+ test(S("abcde"), "abcdeabcde", 5, 1, 0);
+ test(S("abcde"), "abcdeabcde", 5, 5, 0);
+ test(S("abcde"), "abcdeabcde", 5, 9, S::npos);
+ test(S("abcde"), "abcdeabcde", 5, 10, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 5, 0, 5);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 5, 1, 0);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 5, 10, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 5, 19, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 5, 20, S::npos);
+ test(S("abcde"), "", 6, 0, 5);
+ test(S("abcde"), "abcde", 6, 0, 5);
+ test(S("abcde"), "abcde", 6, 1, 0);
+ test(S("abcde"), "abcde", 6, 2, 0);
+ test(S("abcde"), "abcde", 6, 4, 0);
+ test(S("abcde"), "abcde", 6, 5, 0);
+ test(S("abcde"), "abcdeabcde", 6, 0, 5);
+ test(S("abcde"), "abcdeabcde", 6, 1, 0);
+ test(S("abcde"), "abcdeabcde", 6, 5, 0);
+ test(S("abcde"), "abcdeabcde", 6, 9, S::npos);
+ test(S("abcde"), "abcdeabcde", 6, 10, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 6, 0, 5);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 6, 1, 0);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 6, 10, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 6, 19, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 6, 20, S::npos);
+ test(S("abcdeabcde"), "", 0, 0, 0);
+ test(S("abcdeabcde"), "abcde", 0, 0, 0);
+ test(S("abcdeabcde"), "abcde", 0, 1, 0);
+ test(S("abcdeabcde"), "abcde", 0, 2, 0);
+ test(S("abcdeabcde"), "abcde", 0, 4, 0);
+ test(S("abcdeabcde"), "abcde", 0, 5, 0);
+ test(S("abcdeabcde"), "abcdeabcde", 0, 0, 0);
+ test(S("abcdeabcde"), "abcdeabcde", 0, 1, 0);
+ test(S("abcdeabcde"), "abcdeabcde", 0, 5, 0);
+ test(S("abcdeabcde"), "abcdeabcde", 0, 9, 0);
+ test(S("abcdeabcde"), "abcdeabcde", 0, 10, 0);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 0, 0, 0);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 0, 1, 0);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 0, 10, 0);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 0, 19, S::npos);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 0, 20, S::npos);
+ test(S("abcdeabcde"), "", 1, 0, 1);
+ test(S("abcdeabcde"), "abcde", 1, 0, 1);
+ test(S("abcdeabcde"), "abcde", 1, 1, 0);
+ test(S("abcdeabcde"), "abcde", 1, 2, 0);
+ test(S("abcdeabcde"), "abcde", 1, 4, 0);
+ test(S("abcdeabcde"), "abcde", 1, 5, 0);
+ test(S("abcdeabcde"), "abcdeabcde", 1, 0, 1);
+ test(S("abcdeabcde"), "abcdeabcde", 1, 1, 0);
+ test(S("abcdeabcde"), "abcdeabcde", 1, 5, 0);
+ test(S("abcdeabcde"), "abcdeabcde", 1, 9, 0);
+ test(S("abcdeabcde"), "abcdeabcde", 1, 10, 0);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 1, 0, 1);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 1, 1, 0);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 1, 10, 0);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 1, 19, S::npos);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 1, 20, S::npos);
+ test(S("abcdeabcde"), "", 5, 0, 5);
+ test(S("abcdeabcde"), "abcde", 5, 0, 5);
+ test(S("abcdeabcde"), "abcde", 5, 1, 5);
+ test(S("abcdeabcde"), "abcde", 5, 2, 5);
+ test(S("abcdeabcde"), "abcde", 5, 4, 5);
+ test(S("abcdeabcde"), "abcde", 5, 5, 5);
+ test(S("abcdeabcde"), "abcdeabcde", 5, 0, 5);
+ test(S("abcdeabcde"), "abcdeabcde", 5, 1, 5);
+ test(S("abcdeabcde"), "abcdeabcde", 5, 5, 5);
+ test(S("abcdeabcde"), "abcdeabcde", 5, 9, 0);
+ test(S("abcdeabcde"), "abcdeabcde", 5, 10, 0);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 5, 0, 5);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 5, 1, 5);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 5, 10, 0);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 5, 19, S::npos);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 5, 20, S::npos);
+ test(S("abcdeabcde"), "", 9, 0, 9);
+ test(S("abcdeabcde"), "abcde", 9, 0, 9);
+ test(S("abcdeabcde"), "abcde", 9, 1, 5);
+ test(S("abcdeabcde"), "abcde", 9, 2, 5);
+ test(S("abcdeabcde"), "abcde", 9, 4, 5);
+ test(S("abcdeabcde"), "abcde", 9, 5, 5);
+ test(S("abcdeabcde"), "abcdeabcde", 9, 0, 9);
+ test(S("abcdeabcde"), "abcdeabcde", 9, 1, 5);
+ test(S("abcdeabcde"), "abcdeabcde", 9, 5, 5);
+ test(S("abcdeabcde"), "abcdeabcde", 9, 9, 0);
+ test(S("abcdeabcde"), "abcdeabcde", 9, 10, 0);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 9, 0, 9);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 9, 1, 5);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 9, 10, 0);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 9, 19, S::npos);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 9, 20, S::npos);
+ test(S("abcdeabcde"), "", 10, 0, 10);
+ test(S("abcdeabcde"), "abcde", 10, 0, 10);
+ test(S("abcdeabcde"), "abcde", 10, 1, 5);
+ test(S("abcdeabcde"), "abcde", 10, 2, 5);
+ test(S("abcdeabcde"), "abcde", 10, 4, 5);
+ test(S("abcdeabcde"), "abcde", 10, 5, 5);
+ test(S("abcdeabcde"), "abcdeabcde", 10, 0, 10);
+ test(S("abcdeabcde"), "abcdeabcde", 10, 1, 5);
+}
+
+template <class S>
+void test2()
+{
+ test(S("abcdeabcde"), "abcdeabcde", 10, 5, 5);
+ test(S("abcdeabcde"), "abcdeabcde", 10, 9, 0);
+ test(S("abcdeabcde"), "abcdeabcde", 10, 10, 0);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 10, 0, 10);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 10, 1, 5);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 10, 10, 0);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 10, 19, S::npos);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 10, 20, S::npos);
+ test(S("abcdeabcde"), "", 11, 0, 10);
+ test(S("abcdeabcde"), "abcde", 11, 0, 10);
+ test(S("abcdeabcde"), "abcde", 11, 1, 5);
+ test(S("abcdeabcde"), "abcde", 11, 2, 5);
+ test(S("abcdeabcde"), "abcde", 11, 4, 5);
+ test(S("abcdeabcde"), "abcde", 11, 5, 5);
+ test(S("abcdeabcde"), "abcdeabcde", 11, 0, 10);
+ test(S("abcdeabcde"), "abcdeabcde", 11, 1, 5);
+ test(S("abcdeabcde"), "abcdeabcde", 11, 5, 5);
+ test(S("abcdeabcde"), "abcdeabcde", 11, 9, 0);
+ test(S("abcdeabcde"), "abcdeabcde", 11, 10, 0);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 11, 0, 10);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 11, 1, 5);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 11, 10, 0);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 11, 19, S::npos);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 11, 20, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "", 0, 0, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 0, 0, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 0, 1, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 0, 2, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 0, 4, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 0, 5, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 0, 0, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 0, 1, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 0, 5, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 0, 9, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 0, 10, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0, 0, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0, 1, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0, 10, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0, 19, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0, 20, 0);
+ test(S("abcdeabcdeabcdeabcde"), "", 1, 0, 1);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 1, 0, 1);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 1, 1, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 1, 2, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 1, 4, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 1, 5, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 1, 0, 1);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 1, 1, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 1, 5, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 1, 9, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 1, 10, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 1, 0, 1);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 1, 1, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 1, 10, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 1, 19, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 1, 20, 0);
+ test(S("abcdeabcdeabcdeabcde"), "", 10, 0, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 10, 0, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 10, 1, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 10, 2, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 10, 4, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 10, 5, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 10, 0, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 10, 1, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 10, 5, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 10, 9, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 10, 10, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 10, 0, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 10, 1, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 10, 10, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 10, 19, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 10, 20, 0);
+ test(S("abcdeabcdeabcdeabcde"), "", 19, 0, 19);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 19, 0, 19);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 19, 1, 15);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 19, 2, 15);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 19, 4, 15);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 19, 5, 15);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 19, 0, 19);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 19, 1, 15);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 19, 5, 15);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 19, 9, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 19, 10, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 19, 0, 19);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 19, 1, 15);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 19, 10, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 19, 19, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 19, 20, 0);
+ test(S("abcdeabcdeabcdeabcde"), "", 20, 0, 20);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 20, 0, 20);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 20, 1, 15);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 20, 2, 15);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 20, 4, 15);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 20, 5, 15);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 20, 0, 20);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 20, 1, 15);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 20, 5, 15);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 20, 9, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 20, 10, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 20, 0, 20);
+}
+
+template <class S>
+void test3()
+{
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 20, 1, 15);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 20, 10, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 20, 19, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 20, 20, 0);
+ test(S("abcdeabcdeabcdeabcde"), "", 21, 0, 20);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 21, 0, 20);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 21, 1, 15);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 21, 2, 15);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 21, 4, 15);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 21, 5, 15);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 21, 0, 20);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 21, 1, 15);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 21, 5, 15);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 21, 9, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 21, 10, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 21, 0, 20);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 21, 1, 15);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 21, 10, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 21, 19, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 21, 20, 0);
+}
+
+int main()
+{
+ {
+ typedef std::experimental::string_view S;
+ test0<S>();
+ test1<S>();
+ test2<S>();
+ test3<S>();
+ }
+
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::experimental::basic_string_view<char, constexpr_char_traits<char>> SV;
+ constexpr SV sv1;
+ constexpr SV sv2 { "abcde", 5 };
+
+ static_assert (sv1.rfind( "", 0, 0 ) == 0, "" );
+ static_assert (sv1.rfind( "abcde", 0, 0 ) == 0, "" );
+ static_assert (sv1.rfind( "abcde", 0, 1 ) == SV::npos, "" );
+ static_assert (sv2.rfind( "", 0, 0 ) == 0, "" );
+ static_assert (sv2.rfind( "abcde", 0, 0 ) == 0, "" );
+ static_assert (sv2.rfind( "abcde", 0, 1 ) == 0, "" );
+ }
+#endif
+}
diff --git a/test/std/experimental/string.view/string.view.find/rfind_string_view_size.pass.cpp b/test/std/experimental/string.view/string.view.find/rfind_string_view_size.pass.cpp
new file mode 100644
index 000000000000..88457c662016
--- /dev/null
+++ b/test/std/experimental/string.view/string.view.find/rfind_string_view_size.pass.cpp
@@ -0,0 +1,164 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string_view>
+
+// constexpr size_type rfind(const basic_string& str, size_type pos = npos) const;
+
+#include <experimental/string_view>
+#include <cassert>
+
+#include "constexpr_char_traits.hpp"
+
+template <class S>
+void
+test(const S& s, const S& str, typename S::size_type pos, typename S::size_type x)
+{
+ assert(s.rfind(str, pos) == x);
+ if (x != S::npos)
+ assert(x <= pos && x + str.size() <= s.size());
+}
+
+template <class S>
+void
+test(const S& s, const S& str, typename S::size_type x)
+{
+ assert(s.rfind(str) == x);
+ if (x != S::npos)
+ assert(0 <= x && x + str.size() <= s.size());
+}
+
+template <class S>
+void test0()
+{
+ test(S(""), S(""), 0, 0);
+ test(S(""), S("abcde"), 0, S::npos);
+ test(S(""), S("abcdeabcde"), 0, S::npos);
+ test(S(""), S("abcdeabcdeabcdeabcde"), 0, S::npos);
+ test(S(""), S(""), 1, 0);
+ test(S(""), S("abcde"), 1, S::npos);
+ test(S(""), S("abcdeabcde"), 1, S::npos);
+ test(S(""), S("abcdeabcdeabcdeabcde"), 1, S::npos);
+ test(S("abcde"), S(""), 0, 0);
+ test(S("abcde"), S("abcde"), 0, 0);
+ test(S("abcde"), S("abcdeabcde"), 0, S::npos);
+ test(S("abcde"), S("abcdeabcdeabcdeabcde"), 0, S::npos);
+ test(S("abcde"), S(""), 1, 1);
+ test(S("abcde"), S("abcde"), 1, 0);
+ test(S("abcde"), S("abcdeabcde"), 1, S::npos);
+ test(S("abcde"), S("abcdeabcdeabcdeabcde"), 1, S::npos);
+ test(S("abcde"), S(""), 2, 2);
+ test(S("abcde"), S("abcde"), 2, 0);
+ test(S("abcde"), S("abcdeabcde"), 2, S::npos);
+ test(S("abcde"), S("abcdeabcdeabcdeabcde"), 2, S::npos);
+ test(S("abcde"), S(""), 4, 4);
+ test(S("abcde"), S("abcde"), 4, 0);
+ test(S("abcde"), S("abcdeabcde"), 4, S::npos);
+ test(S("abcde"), S("abcdeabcdeabcdeabcde"), 4, S::npos);
+ test(S("abcde"), S(""), 5, 5);
+ test(S("abcde"), S("abcde"), 5, 0);
+ test(S("abcde"), S("abcdeabcde"), 5, S::npos);
+ test(S("abcde"), S("abcdeabcdeabcdeabcde"), 5, S::npos);
+ test(S("abcde"), S(""), 6, 5);
+ test(S("abcde"), S("abcde"), 6, 0);
+ test(S("abcde"), S("abcdeabcde"), 6, S::npos);
+ test(S("abcde"), S("abcdeabcdeabcdeabcde"), 6, S::npos);
+ test(S("abcdeabcde"), S(""), 0, 0);
+ test(S("abcdeabcde"), S("abcde"), 0, 0);
+ test(S("abcdeabcde"), S("abcdeabcde"), 0, 0);
+ test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), 0, S::npos);
+ test(S("abcdeabcde"), S(""), 1, 1);
+ test(S("abcdeabcde"), S("abcde"), 1, 0);
+ test(S("abcdeabcde"), S("abcdeabcde"), 1, 0);
+ test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), 1, S::npos);
+ test(S("abcdeabcde"), S(""), 5, 5);
+ test(S("abcdeabcde"), S("abcde"), 5, 5);
+ test(S("abcdeabcde"), S("abcdeabcde"), 5, 0);
+ test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), 5, S::npos);
+ test(S("abcdeabcde"), S(""), 9, 9);
+ test(S("abcdeabcde"), S("abcde"), 9, 5);
+ test(S("abcdeabcde"), S("abcdeabcde"), 9, 0);
+ test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), 9, S::npos);
+ test(S("abcdeabcde"), S(""), 10, 10);
+ test(S("abcdeabcde"), S("abcde"), 10, 5);
+ test(S("abcdeabcde"), S("abcdeabcde"), 10, 0);
+ test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), 10, S::npos);
+ test(S("abcdeabcde"), S(""), 11, 10);
+ test(S("abcdeabcde"), S("abcde"), 11, 5);
+ test(S("abcdeabcde"), S("abcdeabcde"), 11, 0);
+ test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), 11, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), S(""), 0, 0);
+ test(S("abcdeabcdeabcdeabcde"), S("abcde"), 0, 0);
+ test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 0, 0);
+ test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 0, 0);
+ test(S("abcdeabcdeabcdeabcde"), S(""), 1, 1);
+ test(S("abcdeabcdeabcdeabcde"), S("abcde"), 1, 0);
+ test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 1, 0);
+ test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 1, 0);
+ test(S("abcdeabcdeabcdeabcde"), S(""), 10, 10);
+ test(S("abcdeabcdeabcdeabcde"), S("abcde"), 10, 10);
+ test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 10, 10);
+ test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 10, 0);
+ test(S("abcdeabcdeabcdeabcde"), S(""), 19, 19);
+ test(S("abcdeabcdeabcdeabcde"), S("abcde"), 19, 15);
+ test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 19, 10);
+ test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 19, 0);
+ test(S("abcdeabcdeabcdeabcde"), S(""), 20, 20);
+ test(S("abcdeabcdeabcdeabcde"), S("abcde"), 20, 15);
+ test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 20, 10);
+ test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 20, 0);
+ test(S("abcdeabcdeabcdeabcde"), S(""), 21, 20);
+ test(S("abcdeabcdeabcdeabcde"), S("abcde"), 21, 15);
+ test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 21, 10);
+ test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 21, 0);
+}
+
+template <class S>
+void test1()
+{
+ test(S(""), S(""), 0);
+ test(S(""), S("abcde"), S::npos);
+ test(S(""), S("abcdeabcde"), S::npos);
+ test(S(""), S("abcdeabcdeabcdeabcde"), S::npos);
+ test(S("abcde"), S(""), 5);
+ test(S("abcde"), S("abcde"), 0);
+ test(S("abcde"), S("abcdeabcde"), S::npos);
+ test(S("abcde"), S("abcdeabcdeabcdeabcde"), S::npos);
+ test(S("abcdeabcde"), S(""), 10);
+ test(S("abcdeabcde"), S("abcde"), 5);
+ test(S("abcdeabcde"), S("abcdeabcde"), 0);
+ test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), S::npos);
+ test(S("abcdeabcdeabcdeabcde"), S(""), 20);
+ test(S("abcdeabcdeabcdeabcde"), S("abcde"), 15);
+ test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 10);
+ test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 0);
+}
+
+int main()
+{
+ {
+ typedef std::experimental::string_view S;
+ test0<S>();
+ test1<S>();
+ }
+
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::experimental::basic_string_view<char, constexpr_char_traits<char>> SV;
+ constexpr SV sv1;
+ constexpr SV sv2 { "abcde", 5 };
+
+ static_assert (sv1.rfind(sv1) == 0, "" );
+ static_assert (sv1.rfind(sv2) == SV::npos, "" );
+ static_assert (sv2.rfind(sv1) == 5, "" );
+ static_assert (sv2.rfind(sv2) == 0, "" );
+ static_assert (sv2.rfind(sv2, 1) == 0, "" );
+ }
+#endif
+}
diff --git a/test/std/experimental/string.view/string.view.hash/string_view.pass.cpp b/test/std/experimental/string.view/string.view.hash/string_view.pass.cpp
new file mode 100644
index 000000000000..6b16971bfeb2
--- /dev/null
+++ b/test/std/experimental/string.view/string.view.hash/string_view.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template <class T>
+// struct hash
+// : public unary_function<T, size_t>
+// {
+// size_t operator()(T val) const;
+// };
+
+// Not very portable
+
+#include <experimental/string_view>
+#include <cassert>
+#include <type_traits>
+
+using std::experimental::string_view;
+
+template <class T>
+void
+test()
+{
+ typedef std::hash<T> H;
+ static_assert((std::is_same<typename H::argument_type, T>::value), "" );
+ static_assert((std::is_same<typename H::result_type, std::size_t>::value), "" );
+ H h;
+// std::string g1 = "1234567890";
+// std::string g2 = "1234567891";
+ typedef typename T::value_type char_type;
+ char_type g1 [ 10 ];
+ char_type g2 [ 10 ];
+ for ( int i = 0; i < 10; ++i )
+ g1[i] = g2[9-i] = '0' + i;
+ T s1(g1, 10);
+ T s2(g2, 10);
+ assert(h(s1) != h(s2));
+}
+
+int main()
+{
+ test<std::experimental::string_view>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<std::experimental::u16string_view>();
+ test<std::experimental::u32string_view>();
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<std::experimental::wstring_view>();
+}
diff --git a/test/std/experimental/string.view/string.view.io/stream_insert.pass.cpp b/test/std/experimental/string.view/string.view.io/stream_insert.pass.cpp
new file mode 100644
index 000000000000..4f3f962a3111
--- /dev/null
+++ b/test/std/experimental/string.view/string.view.io/stream_insert.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+// basic_ostream<charT, traits>&
+// operator<<(basic_ostream<charT, traits>& os,
+// const basic_string_view<charT,traits> str);
+
+#include <experimental/string_view>
+#include <sstream>
+#include <cassert>
+
+using std::experimental::string_view;
+using std::experimental::wstring_view;
+
+int main()
+{
+ {
+ std::ostringstream out;
+ string_view sv("some text");
+ out << sv;
+ assert(out.good());
+ assert(sv == out.str());
+ }
+ {
+ std::ostringstream out;
+ std::string s("some text");
+ string_view sv(s);
+ out.width(12);
+ out << sv;
+ assert(out.good());
+ assert(" " + s == out.str());
+ }
+ {
+ std::wostringstream out;
+ wstring_view sv(L"some text");
+ out << sv;
+ assert(out.good());
+ assert(sv == out.str());
+ }
+ {
+ std::wostringstream out;
+ std::wstring s(L"some text");
+ wstring_view sv(s);
+ out.width(12);
+ out << sv;
+ assert(out.good());
+ assert(L" " + s == out.str());
+ }
+}
diff --git a/test/std/experimental/string.view/string.view.iterators/begin.pass.cpp b/test/std/experimental/string.view/string.view.iterators/begin.pass.cpp
new file mode 100644
index 000000000000..07f3b36e1d2b
--- /dev/null
+++ b/test/std/experimental/string.view/string.view.iterators/begin.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string_view>
+
+// constexpr const_iterator begin() const;
+
+#include <experimental/string_view>
+#include <cassert>
+
+template <class S>
+void
+test(S s)
+{
+ const S& cs = s;
+ typename S::iterator b = s.begin();
+ typename S::const_iterator cb1 = cs.begin();
+ typename S::const_iterator cb2 = s.cbegin();
+ if (!s.empty())
+ {
+ assert( *b == s[0]);
+ assert( &*b == &s[0]);
+ assert( *cb1 == s[0]);
+ assert(&*cb1 == &s[0]);
+ assert( *cb2 == s[0]);
+ assert(&*cb2 == &s[0]);
+
+ }
+ assert( b == cb1);
+ assert( b == cb2);
+ assert(cb1 == cb2);
+}
+
+
+int main()
+{
+ typedef std::experimental::string_view string_view;
+ typedef std::experimental::u16string_view u16string_view;
+ typedef std::experimental::u32string_view u32string_view;
+ typedef std::experimental::wstring_view wstring_view;
+
+ test(string_view ());
+ test(u16string_view());
+ test(u32string_view());
+ test(wstring_view ());
+ test(string_view ( "123"));
+ test(wstring_view (L"123"));
+#if __cplusplus >= 201103L
+ test(u16string_view{u"123"});
+ test(u32string_view{U"123"});
+#endif
+
+#if _LIBCPP_STD_VER > 11
+ {
+ constexpr string_view sv { "123", 3 };
+ constexpr u16string_view u16sv {u"123", 3 };
+ constexpr u32string_view u32sv {U"123", 3 };
+ constexpr wstring_view wsv {L"123", 3 };
+
+ static_assert ( *sv.begin() == sv[0], "" );
+ static_assert ( *u16sv.begin() == u16sv[0], "" );
+ static_assert ( *u32sv.begin() == u32sv[0], "" );
+ static_assert ( *wsv.begin() == wsv[0], "" );
+
+ static_assert ( *sv.cbegin() == sv[0], "" );
+ static_assert ( *u16sv.cbegin() == u16sv[0], "" );
+ static_assert ( *u32sv.cbegin() == u32sv[0], "" );
+ static_assert ( *wsv.cbegin() == wsv[0], "" );
+ }
+#endif
+}
diff --git a/test/std/experimental/string.view/string.view.iterators/end.pass.cpp b/test/std/experimental/string.view/string.view.iterators/end.pass.cpp
new file mode 100644
index 000000000000..2ed52b8de947
--- /dev/null
+++ b/test/std/experimental/string.view/string.view.iterators/end.pass.cpp
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string_view>
+
+// constexpr const_iterator end() const;
+
+#include <experimental/string_view>
+#include <cassert>
+
+template <class S>
+void
+test(S s)
+{
+ const S& cs = s;
+ typename S::iterator e = s.end();
+ typename S::const_iterator ce1 = cs.end();
+ typename S::const_iterator ce2 = s.cend();
+
+ if (s.empty())
+ {
+ assert( e == s.begin());
+ assert(ce1 == cs.begin());
+ assert(ce2 == s.begin());
+ }
+ else
+ {
+ assert( e != s.begin());
+ assert(ce1 != cs.begin());
+ assert(ce2 != s.begin());
+ }
+
+ assert( e - s.begin() == s.size());
+ assert(ce1 - cs.begin() == cs.size());
+ assert(ce2 - s.cbegin() == s.size());
+
+ assert( e == ce1);
+ assert( e == ce2);
+ assert(ce1 == ce2);
+}
+
+
+int main()
+{
+ typedef std::experimental::string_view string_view;
+ typedef std::experimental::u16string_view u16string_view;
+ typedef std::experimental::u32string_view u32string_view;
+ typedef std::experimental::wstring_view wstring_view;
+
+ test(string_view ());
+ test(u16string_view());
+ test(u32string_view());
+ test(wstring_view ());
+ test(string_view ( "123"));
+ test(wstring_view (L"123"));
+#if __cplusplus >= 201103L
+ test(u16string_view{u"123"});
+ test(u32string_view{U"123"});
+#endif
+
+#if _LIBCPP_STD_VER > 11
+ {
+ constexpr string_view sv { "123", 3 };
+ constexpr u16string_view u16sv {u"123", 3 };
+ constexpr u32string_view u32sv {U"123", 3 };
+ constexpr wstring_view wsv {L"123", 3 };
+
+ static_assert ( sv.begin() != sv.end(), "" );
+ static_assert ( u16sv.begin() != u16sv.end(), "" );
+ static_assert ( u32sv.begin() != u32sv.end(), "" );
+ static_assert ( wsv.begin() != wsv.end(), "" );
+
+ static_assert ( sv.begin() != sv.cend(), "" );
+ static_assert ( u16sv.begin() != u16sv.cend(), "" );
+ static_assert ( u32sv.begin() != u32sv.cend(), "" );
+ static_assert ( wsv.begin() != wsv.cend(), "" );
+ }
+#endif
+}
diff --git a/test/std/experimental/string.view/string.view.iterators/rbegin.pass.cpp b/test/std/experimental/string.view/string.view.iterators/rbegin.pass.cpp
new file mode 100644
index 000000000000..7d1c7003eaf4
--- /dev/null
+++ b/test/std/experimental/string.view/string.view.iterators/rbegin.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string_view>
+
+// const_iterator rbegin() const;
+
+#include <experimental/string_view>
+#include <cassert>
+
+template <class S>
+void
+test(S s)
+{
+ const S& cs = s;
+ typename S::reverse_iterator b = s.rbegin();
+ typename S::const_reverse_iterator cb1 = cs.rbegin();
+ typename S::const_reverse_iterator cb2 = s.crbegin();
+ if (!s.empty())
+ {
+ const size_t last = s.size() - 1;
+ assert( *b == s[last]);
+ assert( &*b == &s[last]);
+ assert( *cb1 == s[last]);
+ assert(&*cb1 == &s[last]);
+ assert( *cb2 == s[last]);
+ assert(&*cb2 == &s[last]);
+
+ }
+ assert( b == cb1);
+ assert( b == cb2);
+ assert(cb1 == cb2);
+}
+
+
+int main()
+{
+ typedef std::experimental::string_view string_view;
+ typedef std::experimental::u16string_view u16string_view;
+ typedef std::experimental::u32string_view u32string_view;
+ typedef std::experimental::wstring_view wstring_view;
+
+ test(string_view ());
+ test(u16string_view());
+ test(u32string_view());
+ test(wstring_view ());
+ test(string_view ( "123"));
+ test(wstring_view (L"123"));
+#if __cplusplus >= 201103L
+ test(u16string_view{u"123"});
+ test(u32string_view{U"123"});
+#endif
+}
diff --git a/test/std/experimental/string.view/string.view.iterators/rend.pass.cpp b/test/std/experimental/string.view/string.view.iterators/rend.pass.cpp
new file mode 100644
index 000000000000..57002f30518f
--- /dev/null
+++ b/test/std/experimental/string.view/string.view.iterators/rend.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string_view>
+
+// constexpr const_iterator rend() const;
+
+#include <experimental/string_view>
+#include <cassert>
+
+template <class S>
+void
+test(S s)
+{
+ const S& cs = s;
+ typename S::reverse_iterator e = s.rend();
+ typename S::const_reverse_iterator ce1 = cs.rend();
+ typename S::const_reverse_iterator ce2 = s.crend();
+
+ if (s.empty())
+ {
+ assert( e == s.rbegin());
+ assert(ce1 == cs.rbegin());
+ assert(ce2 == s.rbegin());
+ }
+ else
+ {
+ assert( e != s.rbegin());
+ assert(ce1 != cs.rbegin());
+ assert(ce2 != s.rbegin());
+ }
+
+ assert( e - s.rbegin() == s.size());
+ assert(ce1 - cs.rbegin() == cs.size());
+ assert(ce2 - s.crbegin() == s.size());
+
+ assert( e == ce1);
+ assert( e == ce2);
+ assert(ce1 == ce2);
+}
+
+
+int main()
+{
+ typedef std::experimental::string_view string_view;
+ typedef std::experimental::u16string_view u16string_view;
+ typedef std::experimental::u32string_view u32string_view;
+ typedef std::experimental::wstring_view wstring_view;
+
+ test(string_view ());
+ test(u16string_view());
+ test(u32string_view());
+ test(wstring_view ());
+ test(string_view ( "123"));
+ test(wstring_view (L"123"));
+#if __cplusplus >= 201103L
+ test(u16string_view{u"123"});
+ test(u32string_view{U"123"});
+#endif
+}
diff --git a/test/std/experimental/string.view/string.view.modifiers/clear.pass.cpp b/test/std/experimental/string.view/string.view.modifiers/clear.pass.cpp
new file mode 100644
index 000000000000..6a9982e0d3a5
--- /dev/null
+++ b/test/std/experimental/string.view/string.view.modifiers/clear.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+
+// <string_view>
+
+// void clear() noexcept
+
+#include <experimental/string_view>
+#include <cassert>
+
+template<typename CharT>
+void test ( const CharT *s, size_t len ) {
+ typedef std::experimental::basic_string_view<CharT> SV;
+ {
+ SV sv1 ( s );
+ assert ( sv1.size() == len );
+ assert ( sv1.data() == s );
+
+ sv1.clear ();
+ assert ( sv1.data() == nullptr );
+ assert ( sv1.size() == 0 );
+ assert ( sv1 == SV());
+ }
+}
+
+#if _LIBCPP_STD_VER > 11
+constexpr size_t test_ce ( size_t n ) {
+ typedef std::experimental::basic_string_view<char> SV;
+ SV sv1{ "ABCDEFGHIJKL", n };
+ sv1.clear();
+ return sv1.size();
+}
+#endif
+
+int main () {
+ test ( "ABCDE", 5 );
+ test ( "a", 1 );
+ test ( "", 0 );
+
+ test ( L"ABCDE", 5 );
+ test ( L"a", 1 );
+ test ( L"", 0 );
+
+#if __cplusplus >= 201103L
+ test ( u"ABCDE", 5 );
+ test ( u"a", 1 );
+ test ( u"", 0 );
+
+ test ( U"ABCDE", 5 );
+ test ( U"a", 1 );
+ test ( U"", 0 );
+#endif
+
+#if _LIBCPP_STD_VER > 11
+ static_assert ( test_ce (5) == 0, "" );
+#endif
+
+}
diff --git a/test/std/experimental/string.view/string.view.modifiers/remove_prefix.pass.cpp b/test/std/experimental/string.view/string.view.modifiers/remove_prefix.pass.cpp
new file mode 100644
index 000000000000..0a2dd6d9329c
--- /dev/null
+++ b/test/std/experimental/string.view/string.view.modifiers/remove_prefix.pass.cpp
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+
+// <string_view>
+
+// void remove_prefix(size_type _n)
+
+#include <experimental/string_view>
+#include <cassert>
+#include <iostream>
+
+template<typename CharT>
+void test ( const CharT *s, size_t len ) {
+ typedef std::experimental::basic_string_view<CharT> SV;
+ {
+ SV sv1 ( s );
+ assert ( sv1.size() == len );
+ assert ( sv1.data() == s );
+
+ if ( len > 0 ) {
+ sv1.remove_prefix ( 1 );
+ assert ( sv1.size() == (len - 1));
+ assert ( sv1.data() == (s + 1));
+ sv1.remove_prefix ( len - 1 );
+ }
+
+ assert ( sv1.size() == 0 );
+ sv1.remove_prefix ( 0 );
+ assert ( sv1.size() == 0 );
+ }
+}
+
+#if _LIBCPP_STD_VER > 11
+constexpr size_t test_ce ( size_t n, size_t k ) {
+ typedef std::experimental::basic_string_view<char> SV;
+ SV sv1{ "ABCDEFGHIJKL", n };
+ sv1.remove_prefix ( k );
+ return sv1.size();
+}
+#endif
+
+int main () {
+ test ( "ABCDE", 5 );
+ test ( "a", 1 );
+ test ( "", 0 );
+
+ test ( L"ABCDE", 5 );
+ test ( L"a", 1 );
+ test ( L"", 0 );
+
+#if __cplusplus >= 201103L
+ test ( u"ABCDE", 5 );
+ test ( u"a", 1 );
+ test ( u"", 0 );
+
+ test ( U"ABCDE", 5 );
+ test ( U"a", 1 );
+ test ( U"", 0 );
+#endif
+
+#if _LIBCPP_STD_VER > 11
+ {
+ static_assert ( test_ce ( 5, 0 ) == 5, "" );
+ static_assert ( test_ce ( 5, 1 ) == 4, "" );
+ static_assert ( test_ce ( 5, 5 ) == 0, "" );
+ static_assert ( test_ce ( 9, 3 ) == 6, "" );
+ }
+#endif
+}
diff --git a/test/std/experimental/string.view/string.view.modifiers/remove_suffix.pass.cpp b/test/std/experimental/string.view/string.view.modifiers/remove_suffix.pass.cpp
new file mode 100644
index 000000000000..9dd59882cce6
--- /dev/null
+++ b/test/std/experimental/string.view/string.view.modifiers/remove_suffix.pass.cpp
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+
+// <string_view>
+
+// void remove_suffix(size_type _n)
+
+#include <experimental/string_view>
+#include <cassert>
+
+template<typename CharT>
+void test ( const CharT *s, size_t len ) {
+ typedef std::experimental::basic_string_view<CharT> SV;
+ {
+ SV sv1 ( s );
+ assert ( sv1.size() == len );
+ assert ( sv1.data() == s );
+
+ if ( len > 0 ) {
+ sv1.remove_suffix ( 1 );
+ assert ( sv1.size() == (len - 1));
+ assert ( sv1.data() == s);
+ sv1.remove_suffix ( len - 1 );
+ }
+
+ assert ( sv1.size() == 0 );
+ sv1.remove_suffix ( 0 );
+ assert ( sv1.size() == 0 );
+ }
+
+}
+
+#if _LIBCPP_STD_VER > 11
+constexpr size_t test_ce ( size_t n, size_t k ) {
+ typedef std::experimental::basic_string_view<char> SV;
+ SV sv1{ "ABCDEFGHIJKL", n };
+ sv1.remove_suffix ( k );
+ return sv1.size();
+}
+#endif
+
+int main () {
+ test ( "ABCDE", 5 );
+ test ( "a", 1 );
+ test ( "", 0 );
+
+ test ( L"ABCDE", 5 );
+ test ( L"a", 1 );
+ test ( L"", 0 );
+
+#if __cplusplus >= 201103L
+ test ( u"ABCDE", 5 );
+ test ( u"a", 1 );
+ test ( u"", 0 );
+
+ test ( U"ABCDE", 5 );
+ test ( U"a", 1 );
+ test ( U"", 0 );
+#endif
+
+#if _LIBCPP_STD_VER > 11
+ {
+ static_assert ( test_ce ( 5, 0 ) == 5, "" );
+ static_assert ( test_ce ( 5, 1 ) == 4, "" );
+ static_assert ( test_ce ( 5, 5 ) == 0, "" );
+ static_assert ( test_ce ( 9, 3 ) == 6, "" );
+ }
+#endif
+}
diff --git a/test/std/experimental/string.view/string.view.modifiers/swap.pass.cpp b/test/std/experimental/string.view/string.view.modifiers/swap.pass.cpp
new file mode 100644
index 000000000000..cacb8ed40b88
--- /dev/null
+++ b/test/std/experimental/string.view/string.view.modifiers/swap.pass.cpp
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+
+// <string_view>
+
+// void swap(basic_string_view& _other) noexcept
+
+#include <experimental/string_view>
+#include <cassert>
+
+template<typename CharT>
+void test ( const CharT *s, size_t len ) {
+ typedef std::experimental::basic_string_view<CharT> SV;
+ {
+ SV sv1(s);
+ SV sv2;
+
+ assert ( sv1.size() == len );
+ assert ( sv1.data() == s );
+ assert ( sv2.size() == 0 );
+
+ sv1.swap ( sv2 );
+ assert ( sv1.size() == 0 );
+ assert ( sv2.size() == len );
+ assert ( sv2.data() == s );
+ }
+
+}
+
+#if _LIBCPP_STD_VER > 11
+constexpr size_t test_ce ( size_t n, size_t k ) {
+ typedef std::experimental::basic_string_view<char> SV;
+ SV sv1{ "ABCDEFGHIJKL", n };
+ SV sv2 { sv1.data(), k };
+ sv1.swap ( sv2 );
+ return sv1.size();
+}
+#endif
+
+
+int main () {
+ test ( "ABCDE", 5 );
+ test ( "a", 1 );
+ test ( "", 0 );
+
+ test ( L"ABCDE", 5 );
+ test ( L"a", 1 );
+ test ( L"", 0 );
+
+#if __cplusplus >= 201103L
+ test ( u"ABCDE", 5 );
+ test ( u"a", 1 );
+ test ( u"", 0 );
+
+ test ( U"ABCDE", 5 );
+ test ( U"a", 1 );
+ test ( U"", 0 );
+#endif
+
+#if _LIBCPP_STD_VER > 11
+ {
+ static_assert ( test_ce (2, 3) == 3, "" );
+ static_assert ( test_ce (5, 3) == 3, "" );
+ static_assert ( test_ce (0, 1) == 1, "" );
+ }
+#endif
+}
diff --git a/test/std/experimental/string.view/string.view.nonmem/quoted.pass.cpp b/test/std/experimental/string.view/string.view.nonmem/quoted.pass.cpp
new file mode 100644
index 000000000000..c86e9619f193
--- /dev/null
+++ b/test/std/experimental/string.view/string.view.nonmem/quoted.pass.cpp
@@ -0,0 +1,212 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iomanip>
+
+// quoted
+
+#include <iomanip>
+#include <sstream>
+#include <experimental/string_view>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+// quoted is C++14 only
+
+bool is_skipws ( const std::istream *is ) {
+ return ( is->flags() & std::ios_base::skipws ) != 0;
+ }
+
+
+bool is_skipws ( const std::wistream *is ) {
+ return ( is->flags() & std::ios_base::skipws ) != 0;
+ }
+
+void round_trip ( const char *p ) {
+ std::stringstream ss;
+ bool skippingws = is_skipws ( &ss );
+ std::experimental::string_view sv {p};
+
+ ss << std::quoted(sv);
+ std::string s;
+ ss >> std::quoted(s);
+ assert ( s == sv );
+ assert ( skippingws == is_skipws ( &ss ));
+ }
+
+void round_trip_ws ( const char *p ) {
+ std::stringstream ss;
+ std::noskipws ( ss );
+ bool skippingws = is_skipws ( &ss );
+ std::experimental::string_view sv {p};
+
+ ss << std::quoted(sv);
+ std::string s;
+ ss >> std::quoted(s);
+ assert ( s == sv );
+ assert ( skippingws == is_skipws ( &ss ));
+ }
+
+void round_trip_d ( const char *p, char delim ) {
+ std::stringstream ss;
+ std::experimental::string_view sv {p};
+
+ ss << std::quoted(sv, delim);
+ std::string s;
+ ss >> std::quoted(s, delim);
+ assert ( s == sv );
+ }
+
+void round_trip_e ( const char *p, char escape ) {
+ std::stringstream ss;
+ std::experimental::string_view sv {p};
+
+ ss << std::quoted(sv, '"', escape );
+ std::string s;
+ ss >> std::quoted(s, '"', escape );
+ assert ( s == sv );
+ }
+
+
+
+std::string quote ( const char *p, char delim='"', char escape='\\' ) {
+ std::stringstream ss;
+ ss << std::quoted(p, delim, escape);
+ std::string s;
+ ss >> s; // no quote
+ return s;
+}
+
+std::string unquote ( const char *p, char delim='"', char escape='\\' ) {
+ std::stringstream ss;
+ ss << p;
+ std::string s;
+ ss >> std::quoted(s, delim, escape);
+ return s;
+}
+
+
+void round_trip ( const wchar_t *p ) {
+ std::wstringstream ss;
+ bool skippingws = is_skipws ( &ss );
+ std::experimental::wstring_view sv {p};
+
+ ss << std::quoted(sv);
+ std::wstring s;
+ ss >> std::quoted(s);
+ assert ( s == sv );
+ assert ( skippingws == is_skipws ( &ss ));
+ }
+
+
+void round_trip_ws ( const wchar_t *p ) {
+ std::wstringstream ss;
+ std::noskipws ( ss );
+ bool skippingws = is_skipws ( &ss );
+ std::experimental::wstring_view sv {p};
+
+ ss << std::quoted(sv);
+ std::wstring s;
+ ss >> std::quoted(s);
+ assert ( s == sv );
+ assert ( skippingws == is_skipws ( &ss ));
+ }
+
+void round_trip_d ( const wchar_t *p, wchar_t delim ) {
+ std::wstringstream ss;
+ std::experimental::wstring_view sv {p};
+
+ ss << std::quoted(sv, delim);
+ std::wstring s;
+ ss >> std::quoted(s, delim);
+ assert ( s == sv );
+ }
+
+void round_trip_e ( const wchar_t *p, wchar_t escape ) {
+ std::wstringstream ss;
+ std::experimental::wstring_view sv {p};
+
+ ss << std::quoted(sv, wchar_t('"'), escape );
+ std::wstring s;
+ ss >> std::quoted(s, wchar_t('"'), escape );
+ assert ( s == sv );
+ }
+
+
+std::wstring quote ( const wchar_t *p, wchar_t delim='"', wchar_t escape='\\' ) {
+ std::wstringstream ss;
+ std::experimental::wstring_view sv {p};
+
+ ss << std::quoted(sv, delim, escape);
+ std::wstring s;
+ ss >> s; // no quote
+ return s;
+}
+
+std::wstring unquote ( const wchar_t *p, wchar_t delim='"', wchar_t escape='\\' ) {
+ std::wstringstream ss;
+ std::experimental::wstring_view sv {p};
+
+ ss << sv;
+ std::wstring s;
+ ss >> std::quoted(s, delim, escape);
+ return s;
+}
+
+int main()
+{
+ round_trip ( "" );
+ round_trip_ws ( "" );
+ round_trip_d ( "", 'q' );
+ round_trip_e ( "", 'q' );
+
+ round_trip ( L"" );
+ round_trip_ws ( L"" );
+ round_trip_d ( L"", 'q' );
+ round_trip_e ( L"", 'q' );
+
+ round_trip ( "Hi" );
+ round_trip_ws ( "Hi" );
+ round_trip_d ( "Hi", '!' );
+ round_trip_e ( "Hi", '!' );
+ assert ( quote ( "Hi", '!' ) == "!Hi!" );
+ assert ( quote ( "Hi!", '!' ) == R"(!Hi\!!)" );
+
+ round_trip ( L"Hi" );
+ round_trip_ws ( L"Hi" );
+ round_trip_d ( L"Hi", '!' );
+ round_trip_e ( L"Hi", '!' );
+ assert ( quote ( L"Hi", '!' ) == L"!Hi!" );
+ assert ( quote ( L"Hi!", '!' ) == LR"(!Hi\!!)" );
+
+ round_trip ( "Hi Mom" );
+ round_trip_ws ( "Hi Mom" );
+ round_trip ( L"Hi Mom" );
+ round_trip_ws ( L"Hi Mom" );
+
+ assert ( quote ( "" ) == "\"\"" );
+ assert ( quote ( L"" ) == L"\"\"" );
+ assert ( quote ( "a" ) == "\"a\"" );
+ assert ( quote ( L"a" ) == L"\"a\"" );
+
+// missing end quote - must not hang
+ assert ( unquote ( "\"abc" ) == "abc" );
+ assert ( unquote ( L"\"abc" ) == L"abc" );
+
+ assert ( unquote ( "abc" ) == "abc" ); // no delimiter
+ assert ( unquote ( L"abc" ) == L"abc" ); // no delimiter
+ assert ( unquote ( "abc def" ) == "abc" ); // no delimiter
+ assert ( unquote ( L"abc def" ) == L"abc" ); // no delimiter
+
+ assert ( unquote ( "" ) == "" ); // nothing there
+ assert ( unquote ( L"" ) == L"" ); // nothing there
+ }
+#else
+int main() {}
+#endif
diff --git a/test/std/experimental/string.view/string.view.ops/basic_string.pass.cpp b/test/std/experimental/string.view/string.view.ops/basic_string.pass.cpp
new file mode 100644
index 000000000000..29f5064d81dc
--- /dev/null
+++ b/test/std/experimental/string.view/string.view.ops/basic_string.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+
+// <string_view>
+
+// template<class _Allocator>
+// explicit operator basic_string<_CharT, _Traits, _Allocator>() const
+
+#include <experimental/string_view>
+#include <cassert>
+
+template<typename CharT>
+void test ( const CharT *s ) {
+ typedef std::experimental::basic_string_view<CharT> string_view_t;
+ typedef std::basic_string<CharT> string_t;
+
+ {
+ string_view_t sv1 ( s );
+ string_t str = (string_t) sv1;
+
+ assert ( sv1.size() == str.size ());
+ assert ( std::char_traits<CharT>::compare ( sv1.data(), str.data(), sv1.size()) == 0 );
+ }
+
+ {
+ string_view_t sv1;
+ string_t str = (string_t) sv1;
+
+ assert ( sv1.size() == 0);
+ assert ( sv1.size() == str.size ());
+ }
+}
+
+int main () {
+ test ( "ABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDE" );
+ test ( "ABCDE");
+ test ( "a" );
+ test ( "" );
+
+ test ( L"ABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDE" );
+ test ( L"ABCDE" );
+ test ( L"a" );
+ test ( L"" );
+
+#if __cplusplus >= 201103L
+ test ( u"ABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDE" );
+ test ( u"ABCDE" );
+ test ( u"a" );
+ test ( u"" );
+
+ test ( U"ABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDE" );
+ test ( U"ABCDE" );
+ test ( U"a" );
+ test ( U"" );
+#endif
+}
diff --git a/test/std/experimental/string.view/string.view.ops/compare.pointer.pass.cpp b/test/std/experimental/string.view/string.view.ops/compare.pointer.pass.cpp
new file mode 100644
index 000000000000..6ccec9b3729a
--- /dev/null
+++ b/test/std/experimental/string.view/string.view.ops/compare.pointer.pass.cpp
@@ -0,0 +1,126 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string_view>
+
+// constexpr int compare(const charT* s) const;
+
+#include <experimental/string_view>
+#include <cassert>
+
+#include "constexpr_char_traits.hpp"
+
+int sign ( int x ) { return x > 0 ? 1 : ( x < 0 ? -1 : 0 ); }
+
+template<typename CharT>
+void test1 ( std::experimental::basic_string_view<CharT> sv1, const CharT *s, int expected ) {
+ assert ( sign( sv1.compare(s)) == sign(expected));
+}
+
+template<typename CharT>
+void
+test( const CharT *s1, const CharT *s2, int expected)
+{
+ typedef std::experimental::basic_string_view<CharT> string_view_t;
+ string_view_t sv1 ( s1 );
+ test1 ( sv1, s2, expected );
+}
+
+int main()
+{
+ {
+ test("", "", 0);
+ test("", "abcde", -5);
+ test("", "abcdefghij", -10);
+ test("", "abcdefghijklmnopqrst", -20);
+ test("abcde", "", 5);
+ test("abcde", "abcde", 0);
+ test("abcde", "abcdefghij", -5);
+ test("abcde", "abcdefghijklmnopqrst", -15);
+ test("abcdefghij", "", 10);
+ test("abcdefghij", "abcde", 5);
+ test("abcdefghij", "abcdefghij", 0);
+ test("abcdefghij", "abcdefghijklmnopqrst", -10);
+ test("abcdefghijklmnopqrst", "", 20);
+ test("abcdefghijklmnopqrst", "abcde", 15);
+ test("abcdefghijklmnopqrst", "abcdefghij", 10);
+ test("abcdefghijklmnopqrst", "abcdefghijklmnopqrst", 0);
+ }
+
+ {
+ test(L"", L"", 0);
+ test(L"", L"abcde", -5);
+ test(L"", L"abcdefghij", -10);
+ test(L"", L"abcdefghijklmnopqrst", -20);
+ test(L"abcde", L"", 5);
+ test(L"abcde", L"abcde", 0);
+ test(L"abcde", L"abcdefghij", -5);
+ test(L"abcde", L"abcdefghijklmnopqrst", -15);
+ test(L"abcdefghij", L"", 10);
+ test(L"abcdefghij", L"abcde", 5);
+ test(L"abcdefghij", L"abcdefghij", 0);
+ test(L"abcdefghij", L"abcdefghijklmnopqrst", -10);
+ test(L"abcdefghijklmnopqrst", L"", 20);
+ test(L"abcdefghijklmnopqrst", L"abcde", 15);
+ test(L"abcdefghijklmnopqrst", L"abcdefghij", 10);
+ test(L"abcdefghijklmnopqrst", L"abcdefghijklmnopqrst", 0);
+ }
+
+#if __cplusplus >= 201103L
+ {
+ test(U"", U"", 0);
+ test(U"", U"abcde", -5);
+ test(U"", U"abcdefghij", -10);
+ test(U"", U"abcdefghijklmnopqrst", -20);
+ test(U"abcde", U"", 5);
+ test(U"abcde", U"abcde", 0);
+ test(U"abcde", U"abcdefghij", -5);
+ test(U"abcde", U"abcdefghijklmnopqrst", -15);
+ test(U"abcdefghij", U"", 10);
+ test(U"abcdefghij", U"abcde", 5);
+ test(U"abcdefghij", U"abcdefghij", 0);
+ test(U"abcdefghij", U"abcdefghijklmnopqrst", -10);
+ test(U"abcdefghijklmnopqrst", U"", 20);
+ test(U"abcdefghijklmnopqrst", U"abcde", 15);
+ test(U"abcdefghijklmnopqrst", U"abcdefghij", 10);
+ test(U"abcdefghijklmnopqrst", U"abcdefghijklmnopqrst", 0);
+ }
+
+ {
+ test(u"", u"", 0);
+ test(u"", u"abcde", -5);
+ test(u"", u"abcdefghij", -10);
+ test(u"", u"abcdefghijklmnopqrst", -20);
+ test(u"abcde", u"", 5);
+ test(u"abcde", u"abcde", 0);
+ test(u"abcde", u"abcdefghij", -5);
+ test(u"abcde", u"abcdefghijklmnopqrst", -15);
+ test(u"abcdefghij", u"", 10);
+ test(u"abcdefghij", u"abcde", 5);
+ test(u"abcdefghij", u"abcdefghij", 0);
+ test(u"abcdefghij", u"abcdefghijklmnopqrst", -10);
+ test(u"abcdefghijklmnopqrst", u"", 20);
+ test(u"abcdefghijklmnopqrst", u"abcde", 15);
+ test(u"abcdefghijklmnopqrst", u"abcdefghij", 10);
+ test(u"abcdefghijklmnopqrst", u"abcdefghijklmnopqrst", 0);
+ }
+#endif
+
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::experimental::basic_string_view<char, constexpr_char_traits<char>> SV;
+ constexpr SV sv1;
+ constexpr SV sv2 { "abcde", 5 };
+ static_assert ( sv1.compare("") == 0, "" );
+ static_assert ( sv1.compare("abcde") == -1, "" );
+ static_assert ( sv2.compare("") == 1, "" );
+ static_assert ( sv2.compare("abcde") == 0, "" );
+ }
+#endif
+}
diff --git a/test/std/experimental/string.view/string.view.ops/compare.pointer_size.pass.cpp b/test/std/experimental/string.view/string.view.ops/compare.pointer_size.pass.cpp
new file mode 100644
index 000000000000..6b20639f7752
--- /dev/null
+++ b/test/std/experimental/string.view/string.view.ops/compare.pointer_size.pass.cpp
@@ -0,0 +1,444 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string_view>
+
+// constexpr int compare(size_type pos1, size_type n1, const charT* s) const;
+
+#include <experimental/string_view>
+#include <cassert>
+
+#include "constexpr_char_traits.hpp"
+
+int sign ( int x ) { return x > 0 ? 1 : ( x < 0 ? -1 : 0 ); }
+
+template<typename CharT>
+void test1 ( std::experimental::basic_string_view<CharT> sv1,
+ size_t pos1, size_t n1, const CharT *s, int expected ) {
+ try {
+ assert(sign(sv1.compare(pos1, n1, s)) == sign(expected));
+ assert(pos1 <= sv1.size());
+ }
+ catch (const std::out_of_range&) { assert(pos1 > sv1.size()); }
+}
+
+template<typename CharT>
+void
+test( const CharT *s1, size_t pos1, size_t n1, const CharT *s2, int expected)
+{
+ typedef std::experimental::basic_string_view<CharT> string_view_t;
+ string_view_t sv1 ( s1 );
+ test1 ( sv1, pos1, n1, s2, expected );
+}
+
+void test0()
+{
+ test("", 0, 0, "", 0);
+ test("", 0, 0, "abcde", -5);
+ test("", 0, 0, "abcdefghij", -10);
+ test("", 0, 0, "abcdefghijklmnopqrst", -20);
+ test("", 0, 1, "", 0);
+ test("", 0, 1, "abcde", -5);
+ test("", 0, 1, "abcdefghij", -10);
+ test("", 0, 1, "abcdefghijklmnopqrst", -20);
+ test("", 1, 0, "", 0);
+ test("", 1, 0, "abcde", 0);
+ test("", 1, 0, "abcdefghij", 0);
+ test("", 1, 0, "abcdefghijklmnopqrst", 0);
+ test("abcde", 0, 0, "", 0);
+ test("abcde", 0, 0, "abcde", -5);
+ test("abcde", 0, 0, "abcdefghij", -10);
+ test("abcde", 0, 0, "abcdefghijklmnopqrst", -20);
+ test("abcde", 0, 1, "", 1);
+ test("abcde", 0, 1, "abcde", -4);
+ test("abcde", 0, 1, "abcdefghij", -9);
+ test("abcde", 0, 1, "abcdefghijklmnopqrst", -19);
+ test("abcde", 0, 2, "", 2);
+ test("abcde", 0, 2, "abcde", -3);
+ test("abcde", 0, 2, "abcdefghij", -8);
+ test("abcde", 0, 2, "abcdefghijklmnopqrst", -18);
+ test("abcde", 0, 4, "", 4);
+ test("abcde", 0, 4, "abcde", -1);
+ test("abcde", 0, 4, "abcdefghij", -6);
+ test("abcde", 0, 4, "abcdefghijklmnopqrst", -16);
+ test("abcde", 0, 5, "", 5);
+ test("abcde", 0, 5, "abcde", 0);
+ test("abcde", 0, 5, "abcdefghij", -5);
+ test("abcde", 0, 5, "abcdefghijklmnopqrst", -15);
+ test("abcde", 0, 6, "", 5);
+ test("abcde", 0, 6, "abcde", 0);
+ test("abcde", 0, 6, "abcdefghij", -5);
+ test("abcde", 0, 6, "abcdefghijklmnopqrst", -15);
+ test("abcde", 1, 0, "", 0);
+ test("abcde", 1, 0, "abcde", -5);
+ test("abcde", 1, 0, "abcdefghij", -10);
+ test("abcde", 1, 0, "abcdefghijklmnopqrst", -20);
+ test("abcde", 1, 1, "", 1);
+ test("abcde", 1, 1, "abcde", 1);
+ test("abcde", 1, 1, "abcdefghij", 1);
+ test("abcde", 1, 1, "abcdefghijklmnopqrst", 1);
+ test("abcde", 1, 2, "", 2);
+ test("abcde", 1, 2, "abcde", 1);
+ test("abcde", 1, 2, "abcdefghij", 1);
+ test("abcde", 1, 2, "abcdefghijklmnopqrst", 1);
+ test("abcde", 1, 3, "", 3);
+ test("abcde", 1, 3, "abcde", 1);
+ test("abcde", 1, 3, "abcdefghij", 1);
+ test("abcde", 1, 3, "abcdefghijklmnopqrst", 1);
+ test("abcde", 1, 4, "", 4);
+ test("abcde", 1, 4, "abcde", 1);
+ test("abcde", 1, 4, "abcdefghij", 1);
+ test("abcde", 1, 4, "abcdefghijklmnopqrst", 1);
+ test("abcde", 1, 5, "", 4);
+ test("abcde", 1, 5, "abcde", 1);
+ test("abcde", 1, 5, "abcdefghij", 1);
+ test("abcde", 1, 5, "abcdefghijklmnopqrst", 1);
+ test("abcde", 2, 0, "", 0);
+ test("abcde", 2, 0, "abcde", -5);
+ test("abcde", 2, 0, "abcdefghij", -10);
+ test("abcde", 2, 0, "abcdefghijklmnopqrst", -20);
+ test("abcde", 2, 1, "", 1);
+ test("abcde", 2, 1, "abcde", 2);
+ test("abcde", 2, 1, "abcdefghij", 2);
+ test("abcde", 2, 1, "abcdefghijklmnopqrst", 2);
+ test("abcde", 2, 2, "", 2);
+ test("abcde", 2, 2, "abcde", 2);
+ test("abcde", 2, 2, "abcdefghij", 2);
+ test("abcde", 2, 2, "abcdefghijklmnopqrst", 2);
+ test("abcde", 2, 3, "", 3);
+ test("abcde", 2, 3, "abcde", 2);
+ test("abcde", 2, 3, "abcdefghij", 2);
+ test("abcde", 2, 3, "abcdefghijklmnopqrst", 2);
+ test("abcde", 2, 4, "", 3);
+ test("abcde", 2, 4, "abcde", 2);
+ test("abcde", 2, 4, "abcdefghij", 2);
+ test("abcde", 2, 4, "abcdefghijklmnopqrst", 2);
+ test("abcde", 4, 0, "", 0);
+ test("abcde", 4, 0, "abcde", -5);
+ test("abcde", 4, 0, "abcdefghij", -10);
+ test("abcde", 4, 0, "abcdefghijklmnopqrst", -20);
+ test("abcde", 4, 1, "", 1);
+ test("abcde", 4, 1, "abcde", 4);
+ test("abcde", 4, 1, "abcdefghij", 4);
+ test("abcde", 4, 1, "abcdefghijklmnopqrst", 4);
+ test("abcde", 4, 2, "", 1);
+ test("abcde", 4, 2, "abcde", 4);
+ test("abcde", 4, 2, "abcdefghij", 4);
+ test("abcde", 4, 2, "abcdefghijklmnopqrst", 4);
+ test("abcde", 5, 0, "", 0);
+ test("abcde", 5, 0, "abcde", -5);
+ test("abcde", 5, 0, "abcdefghij", -10);
+ test("abcde", 5, 0, "abcdefghijklmnopqrst", -20);
+ test("abcde", 5, 1, "", 0);
+ test("abcde", 5, 1, "abcde", -5);
+ test("abcde", 5, 1, "abcdefghij", -10);
+ test("abcde", 5, 1, "abcdefghijklmnopqrst", -20);
+}
+
+void test1()
+{
+ test("abcde", 6, 0, "", 0);
+ test("abcde", 6, 0, "abcde", 0);
+ test("abcde", 6, 0, "abcdefghij", 0);
+ test("abcde", 6, 0, "abcdefghijklmnopqrst", 0);
+ test("abcdefghij", 0, 0, "", 0);
+ test("abcdefghij", 0, 0, "abcde", -5);
+ test("abcdefghij", 0, 0, "abcdefghij", -10);
+ test("abcdefghij", 0, 0, "abcdefghijklmnopqrst", -20);
+ test("abcdefghij", 0, 1, "", 1);
+ test("abcdefghij", 0, 1, "abcde", -4);
+ test("abcdefghij", 0, 1, "abcdefghij", -9);
+ test("abcdefghij", 0, 1, "abcdefghijklmnopqrst", -19);
+ test("abcdefghij", 0, 5, "", 5);
+ test("abcdefghij", 0, 5, "abcde", 0);
+ test("abcdefghij", 0, 5, "abcdefghij", -5);
+ test("abcdefghij", 0, 5, "abcdefghijklmnopqrst", -15);
+ test("abcdefghij", 0, 9, "", 9);
+ test("abcdefghij", 0, 9, "abcde", 4);
+ test("abcdefghij", 0, 9, "abcdefghij", -1);
+ test("abcdefghij", 0, 9, "abcdefghijklmnopqrst", -11);
+ test("abcdefghij", 0, 10, "", 10);
+ test("abcdefghij", 0, 10, "abcde", 5);
+ test("abcdefghij", 0, 10, "abcdefghij", 0);
+ test("abcdefghij", 0, 10, "abcdefghijklmnopqrst", -10);
+ test("abcdefghij", 0, 11, "", 10);
+ test("abcdefghij", 0, 11, "abcde", 5);
+ test("abcdefghij", 0, 11, "abcdefghij", 0);
+ test("abcdefghij", 0, 11, "abcdefghijklmnopqrst", -10);
+ test("abcdefghij", 1, 0, "", 0);
+ test("abcdefghij", 1, 0, "abcde", -5);
+ test("abcdefghij", 1, 0, "abcdefghij", -10);
+ test("abcdefghij", 1, 0, "abcdefghijklmnopqrst", -20);
+ test("abcdefghij", 1, 1, "", 1);
+ test("abcdefghij", 1, 1, "abcde", 1);
+ test("abcdefghij", 1, 1, "abcdefghij", 1);
+ test("abcdefghij", 1, 1, "abcdefghijklmnopqrst", 1);
+ test("abcdefghij", 1, 4, "", 4);
+ test("abcdefghij", 1, 4, "abcde", 1);
+ test("abcdefghij", 1, 4, "abcdefghij", 1);
+ test("abcdefghij", 1, 4, "abcdefghijklmnopqrst", 1);
+ test("abcdefghij", 1, 8, "", 8);
+ test("abcdefghij", 1, 8, "abcde", 1);
+ test("abcdefghij", 1, 8, "abcdefghij", 1);
+ test("abcdefghij", 1, 8, "abcdefghijklmnopqrst", 1);
+ test("abcdefghij", 1, 9, "", 9);
+ test("abcdefghij", 1, 9, "abcde", 1);
+ test("abcdefghij", 1, 9, "abcdefghij", 1);
+ test("abcdefghij", 1, 9, "abcdefghijklmnopqrst", 1);
+ test("abcdefghij", 1, 10, "", 9);
+ test("abcdefghij", 1, 10, "abcde", 1);
+ test("abcdefghij", 1, 10, "abcdefghij", 1);
+ test("abcdefghij", 1, 10, "abcdefghijklmnopqrst", 1);
+ test("abcdefghij", 5, 0, "", 0);
+ test("abcdefghij", 5, 0, "abcde", -5);
+ test("abcdefghij", 5, 0, "abcdefghij", -10);
+ test("abcdefghij", 5, 0, "abcdefghijklmnopqrst", -20);
+ test("abcdefghij", 5, 1, "", 1);
+ test("abcdefghij", 5, 1, "abcde", 5);
+ test("abcdefghij", 5, 1, "abcdefghij", 5);
+ test("abcdefghij", 5, 1, "abcdefghijklmnopqrst", 5);
+ test("abcdefghij", 5, 2, "", 2);
+ test("abcdefghij", 5, 2, "abcde", 5);
+ test("abcdefghij", 5, 2, "abcdefghij", 5);
+ test("abcdefghij", 5, 2, "abcdefghijklmnopqrst", 5);
+ test("abcdefghij", 5, 4, "", 4);
+ test("abcdefghij", 5, 4, "abcde", 5);
+ test("abcdefghij", 5, 4, "abcdefghij", 5);
+ test("abcdefghij", 5, 4, "abcdefghijklmnopqrst", 5);
+ test("abcdefghij", 5, 5, "", 5);
+ test("abcdefghij", 5, 5, "abcde", 5);
+ test("abcdefghij", 5, 5, "abcdefghij", 5);
+ test("abcdefghij", 5, 5, "abcdefghijklmnopqrst", 5);
+ test("abcdefghij", 5, 6, "", 5);
+ test("abcdefghij", 5, 6, "abcde", 5);
+ test("abcdefghij", 5, 6, "abcdefghij", 5);
+ test("abcdefghij", 5, 6, "abcdefghijklmnopqrst", 5);
+ test("abcdefghij", 9, 0, "", 0);
+ test("abcdefghij", 9, 0, "abcde", -5);
+ test("abcdefghij", 9, 0, "abcdefghij", -10);
+ test("abcdefghij", 9, 0, "abcdefghijklmnopqrst", -20);
+ test("abcdefghij", 9, 1, "", 1);
+ test("abcdefghij", 9, 1, "abcde", 9);
+ test("abcdefghij", 9, 1, "abcdefghij", 9);
+ test("abcdefghij", 9, 1, "abcdefghijklmnopqrst", 9);
+ test("abcdefghij", 9, 2, "", 1);
+ test("abcdefghij", 9, 2, "abcde", 9);
+ test("abcdefghij", 9, 2, "abcdefghij", 9);
+ test("abcdefghij", 9, 2, "abcdefghijklmnopqrst", 9);
+ test("abcdefghij", 10, 0, "", 0);
+ test("abcdefghij", 10, 0, "abcde", -5);
+ test("abcdefghij", 10, 0, "abcdefghij", -10);
+ test("abcdefghij", 10, 0, "abcdefghijklmnopqrst", -20);
+ test("abcdefghij", 10, 1, "", 0);
+ test("abcdefghij", 10, 1, "abcde", -5);
+ test("abcdefghij", 10, 1, "abcdefghij", -10);
+ test("abcdefghij", 10, 1, "abcdefghijklmnopqrst", -20);
+ test("abcdefghij", 11, 0, "", 0);
+ test("abcdefghij", 11, 0, "abcde", 0);
+ test("abcdefghij", 11, 0, "abcdefghij", 0);
+ test("abcdefghij", 11, 0, "abcdefghijklmnopqrst", 0);
+}
+
+void test2()
+{
+ test("abcdefghijklmnopqrst", 0, 0, "", 0);
+ test("abcdefghijklmnopqrst", 0, 0, "abcde", -5);
+ test("abcdefghijklmnopqrst", 0, 0, "abcdefghij", -10);
+ test("abcdefghijklmnopqrst", 0, 0, "abcdefghijklmnopqrst", -20);
+ test("abcdefghijklmnopqrst", 0, 1, "", 1);
+ test("abcdefghijklmnopqrst", 0, 1, "abcde", -4);
+ test("abcdefghijklmnopqrst", 0, 1, "abcdefghij", -9);
+ test("abcdefghijklmnopqrst", 0, 1, "abcdefghijklmnopqrst", -19);
+ test("abcdefghijklmnopqrst", 0, 10, "", 10);
+ test("abcdefghijklmnopqrst", 0, 10, "abcde", 5);
+ test("abcdefghijklmnopqrst", 0, 10, "abcdefghij", 0);
+ test("abcdefghijklmnopqrst", 0, 10, "abcdefghijklmnopqrst", -10);
+ test("abcdefghijklmnopqrst", 0, 19, "", 19);
+ test("abcdefghijklmnopqrst", 0, 19, "abcde", 14);
+ test("abcdefghijklmnopqrst", 0, 19, "abcdefghij", 9);
+ test("abcdefghijklmnopqrst", 0, 19, "abcdefghijklmnopqrst", -1);
+ test("abcdefghijklmnopqrst", 0, 20, "", 20);
+ test("abcdefghijklmnopqrst", 0, 20, "abcde", 15);
+ test("abcdefghijklmnopqrst", 0, 20, "abcdefghij", 10);
+ test("abcdefghijklmnopqrst", 0, 20, "abcdefghijklmnopqrst", 0);
+ test("abcdefghijklmnopqrst", 0, 21, "", 20);
+ test("abcdefghijklmnopqrst", 0, 21, "abcde", 15);
+ test("abcdefghijklmnopqrst", 0, 21, "abcdefghij", 10);
+ test("abcdefghijklmnopqrst", 0, 21, "abcdefghijklmnopqrst", 0);
+ test("abcdefghijklmnopqrst", 1, 0, "", 0);
+ test("abcdefghijklmnopqrst", 1, 0, "abcde", -5);
+ test("abcdefghijklmnopqrst", 1, 0, "abcdefghij", -10);
+ test("abcdefghijklmnopqrst", 1, 0, "abcdefghijklmnopqrst", -20);
+ test("abcdefghijklmnopqrst", 1, 1, "", 1);
+ test("abcdefghijklmnopqrst", 1, 1, "abcde", 1);
+ test("abcdefghijklmnopqrst", 1, 1, "abcdefghij", 1);
+ test("abcdefghijklmnopqrst", 1, 1, "abcdefghijklmnopqrst", 1);
+ test("abcdefghijklmnopqrst", 1, 9, "", 9);
+ test("abcdefghijklmnopqrst", 1, 9, "abcde", 1);
+ test("abcdefghijklmnopqrst", 1, 9, "abcdefghij", 1);
+ test("abcdefghijklmnopqrst", 1, 9, "abcdefghijklmnopqrst", 1);
+ test("abcdefghijklmnopqrst", 1, 18, "", 18);
+ test("abcdefghijklmnopqrst", 1, 18, "abcde", 1);
+ test("abcdefghijklmnopqrst", 1, 18, "abcdefghij", 1);
+ test("abcdefghijklmnopqrst", 1, 18, "abcdefghijklmnopqrst", 1);
+ test("abcdefghijklmnopqrst", 1, 19, "", 19);
+ test("abcdefghijklmnopqrst", 1, 19, "abcde", 1);
+ test("abcdefghijklmnopqrst", 1, 19, "abcdefghij", 1);
+ test("abcdefghijklmnopqrst", 1, 19, "abcdefghijklmnopqrst", 1);
+ test("abcdefghijklmnopqrst", 1, 20, "", 19);
+ test("abcdefghijklmnopqrst", 1, 20, "abcde", 1);
+ test("abcdefghijklmnopqrst", 1, 20, "abcdefghij", 1);
+ test("abcdefghijklmnopqrst", 1, 20, "abcdefghijklmnopqrst", 1);
+ test("abcdefghijklmnopqrst", 10, 0, "", 0);
+ test("abcdefghijklmnopqrst", 10, 0, "abcde", -5);
+ test("abcdefghijklmnopqrst", 10, 0, "abcdefghij", -10);
+ test("abcdefghijklmnopqrst", 10, 0, "abcdefghijklmnopqrst", -20);
+ test("abcdefghijklmnopqrst", 10, 1, "", 1);
+ test("abcdefghijklmnopqrst", 10, 1, "abcde", 10);
+ test("abcdefghijklmnopqrst", 10, 1, "abcdefghij", 10);
+ test("abcdefghijklmnopqrst", 10, 1, "abcdefghijklmnopqrst", 10);
+ test("abcdefghijklmnopqrst", 10, 5, "", 5);
+ test("abcdefghijklmnopqrst", 10, 5, "abcde", 10);
+ test("abcdefghijklmnopqrst", 10, 5, "abcdefghij", 10);
+ test("abcdefghijklmnopqrst", 10, 5, "abcdefghijklmnopqrst", 10);
+ test("abcdefghijklmnopqrst", 10, 9, "", 9);
+ test("abcdefghijklmnopqrst", 10, 9, "abcde", 10);
+ test("abcdefghijklmnopqrst", 10, 9, "abcdefghij", 10);
+ test("abcdefghijklmnopqrst", 10, 9, "abcdefghijklmnopqrst", 10);
+ test("abcdefghijklmnopqrst", 10, 10, "", 10);
+ test("abcdefghijklmnopqrst", 10, 10, "abcde", 10);
+ test("abcdefghijklmnopqrst", 10, 10, "abcdefghij", 10);
+ test("abcdefghijklmnopqrst", 10, 10, "abcdefghijklmnopqrst", 10);
+ test("abcdefghijklmnopqrst", 10, 11, "", 10);
+ test("abcdefghijklmnopqrst", 10, 11, "abcde", 10);
+ test("abcdefghijklmnopqrst", 10, 11, "abcdefghij", 10);
+ test("abcdefghijklmnopqrst", 10, 11, "abcdefghijklmnopqrst", 10);
+ test("abcdefghijklmnopqrst", 19, 0, "", 0);
+ test("abcdefghijklmnopqrst", 19, 0, "abcde", -5);
+ test("abcdefghijklmnopqrst", 19, 0, "abcdefghij", -10);
+ test("abcdefghijklmnopqrst", 19, 0, "abcdefghijklmnopqrst", -20);
+ test("abcdefghijklmnopqrst", 19, 1, "", 1);
+ test("abcdefghijklmnopqrst", 19, 1, "abcde", 19);
+ test("abcdefghijklmnopqrst", 19, 1, "abcdefghij", 19);
+ test("abcdefghijklmnopqrst", 19, 1, "abcdefghijklmnopqrst", 19);
+ test("abcdefghijklmnopqrst", 19, 2, "", 1);
+ test("abcdefghijklmnopqrst", 19, 2, "abcde", 19);
+ test("abcdefghijklmnopqrst", 19, 2, "abcdefghij", 19);
+ test("abcdefghijklmnopqrst", 19, 2, "abcdefghijklmnopqrst", 19);
+ test("abcdefghijklmnopqrst", 20, 0, "", 0);
+ test("abcdefghijklmnopqrst", 20, 0, "abcde", -5);
+ test("abcdefghijklmnopqrst", 20, 0, "abcdefghij", -10);
+ test("abcdefghijklmnopqrst", 20, 0, "abcdefghijklmnopqrst", -20);
+ test("abcdefghijklmnopqrst", 20, 1, "", 0);
+ test("abcdefghijklmnopqrst", 20, 1, "abcde", -5);
+ test("abcdefghijklmnopqrst", 20, 1, "abcdefghij", -10);
+ test("abcdefghijklmnopqrst", 20, 1, "abcdefghijklmnopqrst", -20);
+ test("abcdefghijklmnopqrst", 21, 0, "", 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcde", 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcdefghij", 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcdefghijklmnopqrst", 0);
+}
+
+
+int main()
+{
+ test0();
+ test1();
+ test2();
+
+ {
+ test("", 0, 0, "", 0);
+ test("", 0, 0, "abcde", -5);
+ test("", 0, 0, "abcdefghij", -10);
+ test("", 0, 0, "abcdefghijklmnopqrst", -20);
+ test("abcde", 0, 2, "", 5);
+ test("abcde", 0, 6,"abcde", 0);
+ test("abcde", 0, 6, "abcdefghij", -5);
+ test("abcde", 0, 6, "abcdefghijklmnopqrst", -15);
+ test("abcdefghij", 3, 3, "", 10);
+ test("abcdefghij", 3, 3,"abcde", 5);
+ test("abcdefghij", 3, 3, "def", 0);
+ test("abcdefghij", 0, 4, "abcdefghijklmnopqrst", -10);
+ test("abcdefghijklmnopqrst", 5, 5, "", 20);
+ test("abcdefghijklmnopqrst", 0, 8, "abcde", 15);
+ test("abcdefghijklmnopqrst", 0, 12, "abcdefghij", 10);
+ test("abcdefghijklmnopqrst", 0, -1, "abcdefghijklmnopqrst", 0);
+ }
+
+ {
+ test(L"", 0, 0, L"", 0);
+ test(L"", 0, 0, L"abcde", -5);
+ test(L"", 0, 0, L"abcdefghij", -10);
+ test(L"", 0, 0, L"abcdefghijklmnopqrst", -20);
+ test(L"abcde", 0, 2, L"", 5);
+ test(L"abcde", 0, 6, L"abcde", 0);
+ test(L"abcde", 0, 6, L"abcdefghij", -5);
+ test(L"abcde", 0, 6, L"abcdefghijklmnopqrst", -15);
+ test(L"abcdefghij", 3, 3, L"", 10);
+ test(L"abcdefghij", 3, 3, L"abcde", 5);
+ test(L"abcdefghij", 3, 3, L"def", 0);
+ test(L"abcdefghij", 0, 4, L"abcdefghijklmnopqrst", -10);
+ test(L"abcdefghijklmnopqrst", 5, 5, L"", 20);
+ test(L"abcdefghijklmnopqrst", 0, 8, L"abcde", 15);
+ test(L"abcdefghijklmnopqrst", 0, 12, L"abcdefghij", 10);
+ test(L"abcdefghijklmnopqrst", 0, -1, L"abcdefghijklmnopqrst", 0);
+ }
+
+#if __cplusplus >= 201103L
+ {
+ test(U"", 0, 0, U"", 0);
+ test(U"", 0, 0, U"abcde", -5);
+ test(U"", 0, 0, U"abcdefghij", -10);
+ test(U"", 0, 0, U"abcdefghijklmnopqrst", -20);
+ test(U"abcde", 0, 2, U"", 5);
+ test(U"abcde", 0, 6, U"abcde", 0);
+ test(U"abcde", 0, 6, U"abcdefghij", -5);
+ test(U"abcde", 0, 6, U"abcdefghijklmnopqrst", -15);
+ test(U"abcdefghij", 3, 3, U"", 10);
+ test(U"abcdefghij", 3, 3, U"abcde", 5);
+ test(U"abcdefghij", 3, 3, U"def", 0);
+ test(U"abcdefghij", 0, 4, U"abcdefghijklmnopqrst", -10);
+ test(U"abcdefghijklmnopqrst", 5, 5, U"", 20);
+ test(U"abcdefghijklmnopqrst", 0, 8, U"abcde", 15);
+ test(U"abcdefghijklmnopqrst", 0, 12, U"abcdefghij", 10);
+ test(U"abcdefghijklmnopqrst", 0, -1, U"abcdefghijklmnopqrst", 0);
+ }
+
+ {
+ test(u"", 0, 0, u"", 0);
+ test(u"", 0, 0, u"abcde", -5);
+ test(u"", 0, 0, u"abcdefghij", -10);
+ test(u"", 0, 0, u"abcdefghijklmnopqrst", -20);
+ test(u"abcde", 0, 2, u"", 5);
+ test(u"abcde", 0, 6, u"abcde", 0);
+ test(u"abcde", 0, 6, u"abcdefghij", -5);
+ test(u"abcde", 0, 6, u"abcdefghijklmnopqrst", -15);
+ test(u"abcdefghij", 3, 3, u"", 10);
+ test(u"abcdefghij", 3, 3, u"abcde", 5);
+ test(u"abcdefghij", 3, 3, u"def", 0);
+ test(u"abcdefghij", 0, 4, u"abcdefghijklmnopqrst", -10);
+ test(u"abcdefghijklmnopqrst", 5, 5, u"", 20);
+ test(u"abcdefghijklmnopqrst", 0, 8, u"abcde", 15);
+ test(u"abcdefghijklmnopqrst", 0, 12, u"abcdefghij", 10);
+ test(u"abcdefghijklmnopqrst", 0, -1, u"abcdefghijklmnopqrst", 0);
+ }
+#endif
+
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::experimental::basic_string_view<char, constexpr_char_traits<char>> SV;
+ constexpr SV sv1;
+ constexpr SV sv2 { "abcde", 5 };
+ static_assert ( sv1.compare(0, 0, "") == 0, "" );
+ static_assert ( sv1.compare(0, 0, "abcde") == -1, "" );
+ static_assert ( sv2.compare(0, 2, "") == 1, "" );
+ static_assert ( sv2.compare(0, 6, "abcde") == 0, "" );
+ }
+#endif
+}
diff --git a/test/std/experimental/string.view/string.view.ops/compare.size_size_sv.pass.cpp b/test/std/experimental/string.view/string.view.ops/compare.size_size_sv.pass.cpp
new file mode 100644
index 000000000000..2047862b0002
--- /dev/null
+++ b/test/std/experimental/string.view/string.view.ops/compare.size_size_sv.pass.cpp
@@ -0,0 +1,397 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+
+// <string_view>
+
+// constexpr int compare(size_type pos1, size_type n1, basic_string_view str) const;
+
+#include <experimental/string_view>
+#include <cassert>
+
+#include "constexpr_char_traits.hpp"
+
+int sign ( int x ) { return x > 0 ? 1 : ( x < 0 ? -1 : 0 ); }
+
+template<typename CharT>
+void test1 ( std::experimental::basic_string_view<CharT> sv1, size_t pos1, size_t n1,
+ std::experimental::basic_string_view<CharT> sv2, int expected ) {
+
+ try
+ {
+ assert ( sign( sv1.compare(pos1, n1, sv2)) == sign(expected));
+ assert(pos1 <= sv1.size());
+ }
+ catch (const std::out_of_range&) { assert(pos1 > sv1.size()); }
+}
+
+
+template<typename CharT>
+void test ( const CharT *s1, size_t pos1, size_t n1, const CharT *s2, int expected ) {
+ typedef std::experimental::basic_string_view<CharT> string_view_t;
+
+ string_view_t sv1 ( s1 );
+ string_view_t sv2 ( s2 );
+ test1(sv1, pos1, n1, sv2, expected);
+}
+
+void test0()
+{
+ test("", 0, 0, "", 0);
+ test("", 0, 0, "abcde", -5);
+ test("", 0, 0, "abcdefghij", -10);
+ test("", 0, 0, "abcdefghijklmnopqrst", -20);
+ test("", 0, 1, "", 0);
+ test("", 0, 1, "abcde", -5);
+ test("", 0, 1, "abcdefghij", -10);
+ test("", 0, 1, "abcdefghijklmnopqrst", -20);
+ test("", 1, 0, "", 0);
+ test("", 1, 0, "abcde", 0);
+ test("", 1, 0, "abcdefghij", 0);
+ test("", 1, 0, "abcdefghijklmnopqrst", 0);
+ test("abcde", 0, 0, "", 0);
+ test("abcde", 0, 0, "abcde", -5);
+ test("abcde", 0, 0, "abcdefghij", -10);
+ test("abcde", 0, 0, "abcdefghijklmnopqrst", -20);
+ test("abcde", 0, 1, "", 1);
+ test("abcde", 0, 1, "abcde", -4);
+ test("abcde", 0, 1, "abcdefghij", -9);
+ test("abcde", 0, 1, "abcdefghijklmnopqrst", -19);
+ test("abcde", 0, 2, "", 2);
+ test("abcde", 0, 2, "abcde", -3);
+ test("abcde", 0, 2, "abcdefghij", -8);
+ test("abcde", 0, 2, "abcdefghijklmnopqrst", -18);
+ test("abcde", 0, 4, "", 4);
+ test("abcde", 0, 4, "abcde", -1);
+ test("abcde", 0, 4, "abcdefghij", -6);
+ test("abcde", 0, 4, "abcdefghijklmnopqrst", -16);
+ test("abcde", 0, 5, "", 5);
+ test("abcde", 0, 5, "abcde", 0);
+ test("abcde", 0, 5, "abcdefghij", -5);
+ test("abcde", 0, 5, "abcdefghijklmnopqrst", -15);
+ test("abcde", 0, 6, "", 5);
+ test("abcde", 0, 6, "abcde", 0);
+ test("abcde", 0, 6, "abcdefghij", -5);
+ test("abcde", 0, 6, "abcdefghijklmnopqrst", -15);
+ test("abcde", 1, 0, "", 0);
+ test("abcde", 1, 0, "abcde", -5);
+ test("abcde", 1, 0, "abcdefghij", -10);
+ test("abcde", 1, 0, "abcdefghijklmnopqrst", -20);
+ test("abcde", 1, 1, "", 1);
+ test("abcde", 1, 1, "abcde", 1);
+ test("abcde", 1, 1, "abcdefghij", 1);
+ test("abcde", 1, 1, "abcdefghijklmnopqrst", 1);
+ test("abcde", 1, 2, "", 2);
+ test("abcde", 1, 2, "abcde", 1);
+ test("abcde", 1, 2, "abcdefghij", 1);
+ test("abcde", 1, 2, "abcdefghijklmnopqrst", 1);
+ test("abcde", 1, 3, "", 3);
+ test("abcde", 1, 3, "abcde", 1);
+ test("abcde", 1, 3, "abcdefghij", 1);
+ test("abcde", 1, 3, "abcdefghijklmnopqrst", 1);
+ test("abcde", 1, 4, "", 4);
+ test("abcde", 1, 4, "abcde", 1);
+ test("abcde", 1, 4, "abcdefghij", 1);
+ test("abcde", 1, 4, "abcdefghijklmnopqrst", 1);
+ test("abcde", 1, 5, "", 4);
+ test("abcde", 1, 5, "abcde", 1);
+ test("abcde", 1, 5, "abcdefghij", 1);
+ test("abcde", 1, 5, "abcdefghijklmnopqrst", 1);
+ test("abcde", 2, 0, "", 0);
+ test("abcde", 2, 0, "abcde", -5);
+ test("abcde", 2, 0, "abcdefghij", -10);
+ test("abcde", 2, 0, "abcdefghijklmnopqrst", -20);
+ test("abcde", 2, 1, "", 1);
+ test("abcde", 2, 1, "abcde", 2);
+ test("abcde", 2, 1, "abcdefghij", 2);
+ test("abcde", 2, 1, "abcdefghijklmnopqrst", 2);
+ test("abcde", 2, 2, "", 2);
+ test("abcde", 2, 2, "abcde", 2);
+ test("abcde", 2, 2, "abcdefghij", 2);
+ test("abcde", 2, 2, "abcdefghijklmnopqrst", 2);
+ test("abcde", 2, 3, "", 3);
+ test("abcde", 2, 3, "abcde", 2);
+ test("abcde", 2, 3, "abcdefghij", 2);
+ test("abcde", 2, 3, "abcdefghijklmnopqrst", 2);
+ test("abcde", 2, 4, "", 3);
+ test("abcde", 2, 4, "abcde", 2);
+ test("abcde", 2, 4, "abcdefghij", 2);
+ test("abcde", 2, 4, "abcdefghijklmnopqrst", 2);
+ test("abcde", 4, 0, "", 0);
+ test("abcde", 4, 0, "abcde", -5);
+ test("abcde", 4, 0, "abcdefghij", -10);
+ test("abcde", 4, 0, "abcdefghijklmnopqrst", -20);
+ test("abcde", 4, 1, "", 1);
+ test("abcde", 4, 1, "abcde", 4);
+ test("abcde", 4, 1, "abcdefghij", 4);
+ test("abcde", 4, 1, "abcdefghijklmnopqrst", 4);
+ test("abcde", 4, 2, "", 1);
+ test("abcde", 4, 2, "abcde", 4);
+ test("abcde", 4, 2, "abcdefghij", 4);
+ test("abcde", 4, 2, "abcdefghijklmnopqrst", 4);
+ test("abcde", 5, 0, "", 0);
+ test("abcde", 5, 0, "abcde", -5);
+ test("abcde", 5, 0, "abcdefghij", -10);
+ test("abcde", 5, 0, "abcdefghijklmnopqrst", -20);
+ test("abcde", 5, 1, "", 0);
+ test("abcde", 5, 1, "abcde", -5);
+ test("abcde", 5, 1, "abcdefghij", -10);
+ test("abcde", 5, 1, "abcdefghijklmnopqrst", -20);
+}
+
+void test1()
+{
+ test("abcde", 6, 0, "", 0);
+ test("abcde", 6, 0, "abcde", 0);
+ test("abcde", 6, 0, "abcdefghij", 0);
+ test("abcde", 6, 0, "abcdefghijklmnopqrst", 0);
+ test("abcdefghij", 0, 0, "", 0);
+ test("abcdefghij", 0, 0, "abcde", -5);
+ test("abcdefghij", 0, 0, "abcdefghij", -10);
+ test("abcdefghij", 0, 0, "abcdefghijklmnopqrst", -20);
+ test("abcdefghij", 0, 1, "", 1);
+ test("abcdefghij", 0, 1, "abcde", -4);
+ test("abcdefghij", 0, 1, "abcdefghij", -9);
+ test("abcdefghij", 0, 1, "abcdefghijklmnopqrst", -19);
+ test("abcdefghij", 0, 5, "", 5);
+ test("abcdefghij", 0, 5, "abcde", 0);
+ test("abcdefghij", 0, 5, "abcdefghij", -5);
+ test("abcdefghij", 0, 5, "abcdefghijklmnopqrst", -15);
+ test("abcdefghij", 0, 9, "", 9);
+ test("abcdefghij", 0, 9, "abcde", 4);
+ test("abcdefghij", 0, 9, "abcdefghij", -1);
+ test("abcdefghij", 0, 9, "abcdefghijklmnopqrst", -11);
+ test("abcdefghij", 0, 10, "", 10);
+ test("abcdefghij", 0, 10, "abcde", 5);
+ test("abcdefghij", 0, 10, "abcdefghij", 0);
+ test("abcdefghij", 0, 10, "abcdefghijklmnopqrst", -10);
+ test("abcdefghij", 0, 11, "", 10);
+ test("abcdefghij", 0, 11, "abcde", 5);
+ test("abcdefghij", 0, 11, "abcdefghij", 0);
+ test("abcdefghij", 0, 11, "abcdefghijklmnopqrst", -10);
+ test("abcdefghij", 1, 0, "", 0);
+ test("abcdefghij", 1, 0, "abcde", -5);
+ test("abcdefghij", 1, 0, "abcdefghij", -10);
+ test("abcdefghij", 1, 0, "abcdefghijklmnopqrst", -20);
+ test("abcdefghij", 1, 1, "", 1);
+ test("abcdefghij", 1, 1, "abcde", 1);
+ test("abcdefghij", 1, 1, "abcdefghij", 1);
+ test("abcdefghij", 1, 1, "abcdefghijklmnopqrst", 1);
+ test("abcdefghij", 1, 4, "", 4);
+ test("abcdefghij", 1, 4, "abcde", 1);
+ test("abcdefghij", 1, 4, "abcdefghij", 1);
+ test("abcdefghij", 1, 4, "abcdefghijklmnopqrst", 1);
+ test("abcdefghij", 1, 8, "", 8);
+ test("abcdefghij", 1, 8, "abcde", 1);
+ test("abcdefghij", 1, 8, "abcdefghij", 1);
+ test("abcdefghij", 1, 8, "abcdefghijklmnopqrst", 1);
+ test("abcdefghij", 1, 9, "", 9);
+ test("abcdefghij", 1, 9, "abcde", 1);
+ test("abcdefghij", 1, 9, "abcdefghij", 1);
+ test("abcdefghij", 1, 9, "abcdefghijklmnopqrst", 1);
+ test("abcdefghij", 1, 10, "", 9);
+ test("abcdefghij", 1, 10, "abcde", 1);
+ test("abcdefghij", 1, 10, "abcdefghij", 1);
+ test("abcdefghij", 1, 10, "abcdefghijklmnopqrst", 1);
+ test("abcdefghij", 5, 0, "", 0);
+ test("abcdefghij", 5, 0, "abcde", -5);
+ test("abcdefghij", 5, 0, "abcdefghij", -10);
+ test("abcdefghij", 5, 0, "abcdefghijklmnopqrst", -20);
+ test("abcdefghij", 5, 1, "", 1);
+ test("abcdefghij", 5, 1, "abcde", 5);
+ test("abcdefghij", 5, 1, "abcdefghij", 5);
+ test("abcdefghij", 5, 1, "abcdefghijklmnopqrst", 5);
+ test("abcdefghij", 5, 2, "", 2);
+ test("abcdefghij", 5, 2, "abcde", 5);
+ test("abcdefghij", 5, 2, "abcdefghij", 5);
+ test("abcdefghij", 5, 2, "abcdefghijklmnopqrst", 5);
+ test("abcdefghij", 5, 4, "", 4);
+ test("abcdefghij", 5, 4, "abcde", 5);
+ test("abcdefghij", 5, 4, "abcdefghij", 5);
+ test("abcdefghij", 5, 4, "abcdefghijklmnopqrst", 5);
+ test("abcdefghij", 5, 5, "", 5);
+ test("abcdefghij", 5, 5, "abcde", 5);
+ test("abcdefghij", 5, 5, "abcdefghij", 5);
+ test("abcdefghij", 5, 5, "abcdefghijklmnopqrst", 5);
+ test("abcdefghij", 5, 6, "", 5);
+ test("abcdefghij", 5, 6, "abcde", 5);
+ test("abcdefghij", 5, 6, "abcdefghij", 5);
+ test("abcdefghij", 5, 6, "abcdefghijklmnopqrst", 5);
+ test("abcdefghij", 9, 0, "", 0);
+ test("abcdefghij", 9, 0, "abcde", -5);
+ test("abcdefghij", 9, 0, "abcdefghij", -10);
+ test("abcdefghij", 9, 0, "abcdefghijklmnopqrst", -20);
+ test("abcdefghij", 9, 1, "", 1);
+ test("abcdefghij", 9, 1, "abcde", 9);
+ test("abcdefghij", 9, 1, "abcdefghij", 9);
+ test("abcdefghij", 9, 1, "abcdefghijklmnopqrst", 9);
+ test("abcdefghij", 9, 2, "", 1);
+ test("abcdefghij", 9, 2, "abcde", 9);
+ test("abcdefghij", 9, 2, "abcdefghij", 9);
+ test("abcdefghij", 9, 2, "abcdefghijklmnopqrst", 9);
+ test("abcdefghij", 10, 0, "", 0);
+ test("abcdefghij", 10, 0, "abcde", -5);
+ test("abcdefghij", 10, 0, "abcdefghij", -10);
+ test("abcdefghij", 10, 0, "abcdefghijklmnopqrst", -20);
+ test("abcdefghij", 10, 1, "", 0);
+ test("abcdefghij", 10, 1, "abcde", -5);
+ test("abcdefghij", 10, 1, "abcdefghij", -10);
+ test("abcdefghij", 10, 1, "abcdefghijklmnopqrst", -20);
+ test("abcdefghij", 11, 0, "", 0);
+ test("abcdefghij", 11, 0, "abcde", 0);
+ test("abcdefghij", 11, 0, "abcdefghij", 0);
+ test("abcdefghij", 11, 0, "abcdefghijklmnopqrst", 0);
+}
+
+void test2()
+{
+ test("abcdefghijklmnopqrst", 0, 0, "", 0);
+ test("abcdefghijklmnopqrst", 0, 0, "abcde", -5);
+ test("abcdefghijklmnopqrst", 0, 0, "abcdefghij", -10);
+ test("abcdefghijklmnopqrst", 0, 0, "abcdefghijklmnopqrst", -20);
+ test("abcdefghijklmnopqrst", 0, 1, "", 1);
+ test("abcdefghijklmnopqrst", 0, 1, "abcde", -4);
+ test("abcdefghijklmnopqrst", 0, 1, "abcdefghij", -9);
+ test("abcdefghijklmnopqrst", 0, 1, "abcdefghijklmnopqrst", -19);
+ test("abcdefghijklmnopqrst", 0, 10, "", 10);
+ test("abcdefghijklmnopqrst", 0, 10, "abcde", 5);
+ test("abcdefghijklmnopqrst", 0, 10, "abcdefghij", 0);
+ test("abcdefghijklmnopqrst", 0, 10, "abcdefghijklmnopqrst", -10);
+ test("abcdefghijklmnopqrst", 0, 19, "", 19);
+ test("abcdefghijklmnopqrst", 0, 19, "abcde", 14);
+ test("abcdefghijklmnopqrst", 0, 19, "abcdefghij", 9);
+ test("abcdefghijklmnopqrst", 0, 19, "abcdefghijklmnopqrst", -1);
+ test("abcdefghijklmnopqrst", 0, 20, "", 20);
+ test("abcdefghijklmnopqrst", 0, 20, "abcde", 15);
+ test("abcdefghijklmnopqrst", 0, 20, "abcdefghij", 10);
+ test("abcdefghijklmnopqrst", 0, 20, "abcdefghijklmnopqrst", 0);
+ test("abcdefghijklmnopqrst", 0, 21, "", 20);
+ test("abcdefghijklmnopqrst", 0, 21, "abcde", 15);
+ test("abcdefghijklmnopqrst", 0, 21, "abcdefghij", 10);
+ test("abcdefghijklmnopqrst", 0, 21, "abcdefghijklmnopqrst", 0);
+ test("abcdefghijklmnopqrst", 1, 0, "", 0);
+ test("abcdefghijklmnopqrst", 1, 0, "abcde", -5);
+ test("abcdefghijklmnopqrst", 1, 0, "abcdefghij", -10);
+ test("abcdefghijklmnopqrst", 1, 0, "abcdefghijklmnopqrst", -20);
+ test("abcdefghijklmnopqrst", 1, 1, "", 1);
+ test("abcdefghijklmnopqrst", 1, 1, "abcde", 1);
+ test("abcdefghijklmnopqrst", 1, 1, "abcdefghij", 1);
+ test("abcdefghijklmnopqrst", 1, 1, "abcdefghijklmnopqrst", 1);
+ test("abcdefghijklmnopqrst", 1, 9, "", 9);
+ test("abcdefghijklmnopqrst", 1, 9, "abcde", 1);
+ test("abcdefghijklmnopqrst", 1, 9, "abcdefghij", 1);
+ test("abcdefghijklmnopqrst", 1, 9, "abcdefghijklmnopqrst", 1);
+ test("abcdefghijklmnopqrst", 1, 18, "", 18);
+ test("abcdefghijklmnopqrst", 1, 18, "abcde", 1);
+ test("abcdefghijklmnopqrst", 1, 18, "abcdefghij", 1);
+ test("abcdefghijklmnopqrst", 1, 18, "abcdefghijklmnopqrst", 1);
+ test("abcdefghijklmnopqrst", 1, 19, "", 19);
+ test("abcdefghijklmnopqrst", 1, 19, "abcde", 1);
+ test("abcdefghijklmnopqrst", 1, 19, "abcdefghij", 1);
+ test("abcdefghijklmnopqrst", 1, 19, "abcdefghijklmnopqrst", 1);
+ test("abcdefghijklmnopqrst", 1, 20, "", 19);
+ test("abcdefghijklmnopqrst", 1, 20, "abcde", 1);
+ test("abcdefghijklmnopqrst", 1, 20, "abcdefghij", 1);
+ test("abcdefghijklmnopqrst", 1, 20, "abcdefghijklmnopqrst", 1);
+ test("abcdefghijklmnopqrst", 10, 0, "", 0);
+ test("abcdefghijklmnopqrst", 10, 0, "abcde", -5);
+ test("abcdefghijklmnopqrst", 10, 0, "abcdefghij", -10);
+ test("abcdefghijklmnopqrst", 10, 0, "abcdefghijklmnopqrst", -20);
+ test("abcdefghijklmnopqrst", 10, 1, "", 1);
+ test("abcdefghijklmnopqrst", 10, 1, "abcde", 10);
+ test("abcdefghijklmnopqrst", 10, 1, "abcdefghij", 10);
+ test("abcdefghijklmnopqrst", 10, 1, "abcdefghijklmnopqrst", 10);
+ test("abcdefghijklmnopqrst", 10, 5, "", 5);
+ test("abcdefghijklmnopqrst", 10, 5, "abcde", 10);
+ test("abcdefghijklmnopqrst", 10, 5, "abcdefghij", 10);
+ test("abcdefghijklmnopqrst", 10, 5, "abcdefghijklmnopqrst", 10);
+ test("abcdefghijklmnopqrst", 10, 9, "", 9);
+ test("abcdefghijklmnopqrst", 10, 9, "abcde", 10);
+ test("abcdefghijklmnopqrst", 10, 9, "abcdefghij", 10);
+ test("abcdefghijklmnopqrst", 10, 9, "abcdefghijklmnopqrst", 10);
+ test("abcdefghijklmnopqrst", 10, 10, "", 10);
+ test("abcdefghijklmnopqrst", 10, 10, "abcde", 10);
+ test("abcdefghijklmnopqrst", 10, 10, "abcdefghij", 10);
+ test("abcdefghijklmnopqrst", 10, 10, "abcdefghijklmnopqrst", 10);
+ test("abcdefghijklmnopqrst", 10, 11, "", 10);
+ test("abcdefghijklmnopqrst", 10, 11, "abcde", 10);
+ test("abcdefghijklmnopqrst", 10, 11, "abcdefghij", 10);
+ test("abcdefghijklmnopqrst", 10, 11, "abcdefghijklmnopqrst", 10);
+ test("abcdefghijklmnopqrst", 19, 0, "", 0);
+ test("abcdefghijklmnopqrst", 19, 0, "abcde", -5);
+ test("abcdefghijklmnopqrst", 19, 0, "abcdefghij", -10);
+ test("abcdefghijklmnopqrst", 19, 0, "abcdefghijklmnopqrst", -20);
+ test("abcdefghijklmnopqrst", 19, 1, "", 1);
+ test("abcdefghijklmnopqrst", 19, 1, "abcde", 19);
+ test("abcdefghijklmnopqrst", 19, 1, "abcdefghij", 19);
+ test("abcdefghijklmnopqrst", 19, 1, "abcdefghijklmnopqrst", 19);
+ test("abcdefghijklmnopqrst", 19, 2, "", 1);
+ test("abcdefghijklmnopqrst", 19, 2, "abcde", 19);
+ test("abcdefghijklmnopqrst", 19, 2, "abcdefghij", 19);
+ test("abcdefghijklmnopqrst", 19, 2, "abcdefghijklmnopqrst", 19);
+ test("abcdefghijklmnopqrst", 20, 0, "", 0);
+ test("abcdefghijklmnopqrst", 20, 0, "abcde", -5);
+ test("abcdefghijklmnopqrst", 20, 0, "abcdefghij", -10);
+ test("abcdefghijklmnopqrst", 20, 0, "abcdefghijklmnopqrst", -20);
+ test("abcdefghijklmnopqrst", 20, 1, "", 0);
+ test("abcdefghijklmnopqrst", 20, 1, "abcde", -5);
+ test("abcdefghijklmnopqrst", 20, 1, "abcdefghij", -10);
+ test("abcdefghijklmnopqrst", 20, 1, "abcdefghijklmnopqrst", -20);
+ test("abcdefghijklmnopqrst", 21, 0, "", 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcde", 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcdefghij", 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcdefghijklmnopqrst", 0);
+}
+
+
+int main () {
+ test0();
+ test1();
+ test2();
+
+ {
+ test("abcde", 5, 1, "", 0);
+ test("abcde", 2, 4, "", 3);
+ test("abcde", 2, 4, "abcde", 2);
+ test("ABCde", 2, 4, "abcde", -1);
+ }
+
+ {
+ test(L"abcde", 5, 1, L"", 0);
+ test(L"abcde", 2, 4, L"", 3);
+ test(L"abcde", 2, 4, L"abcde", 2);
+ test(L"ABCde", 2, 4, L"abcde", -1);
+ }
+
+#if __cplusplus >= 201103L
+ {
+ test(u"abcde", 5, 1, u"", 0);
+ test(u"abcde", 2, 4, u"", 3);
+ test(u"abcde", 2, 4, u"abcde", 2);
+ test(u"ABCde", 2, 4, u"abcde", -1);
+ }
+
+ {
+ test(U"abcde", 5, 1, U"", 0);
+ test(U"abcde", 2, 4, U"", 3);
+ test(U"abcde", 2, 4, U"abcde", 2);
+ test(U"ABCde", 2, 4, U"abcde", -1);
+ }
+#endif
+
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::experimental::basic_string_view<char, constexpr_char_traits<char>> SV;
+ constexpr SV sv1 { "abcde", 5 };
+ constexpr SV sv2 { "abcde", 0 };
+ static_assert ( sv1.compare(5, 1, sv2) == 0, "" );
+ static_assert ( sv1.compare(2, 4, sv2) == 1, "" );
+ }
+#endif
+}
diff --git a/test/std/experimental/string.view/string.view.ops/compare.size_size_sv_pointer_size.pass.cpp b/test/std/experimental/string.view/string.view.ops/compare.size_size_sv_pointer_size.pass.cpp
new file mode 100644
index 000000000000..acb48f5fb6cc
--- /dev/null
+++ b/test/std/experimental/string.view/string.view.ops/compare.size_size_sv_pointer_size.pass.cpp
@@ -0,0 +1,1349 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+
+// <string_view>
+
+// constexpr int compare(size_type pos1, size_type n1,
+// const charT* s, size_type n2) const;
+
+#include <experimental/string_view>
+#include <cassert>
+
+#include "constexpr_char_traits.hpp"
+
+int sign ( int x ) { return x > 0 ? 1 : ( x < 0 ? -1 : 0 ); }
+
+template<typename CharT>
+void test1 ( std::experimental::basic_string_view<CharT> sv1, size_t pos1, size_t n1,
+ const CharT *s2, size_t n2,
+ int expected ) {
+
+ try
+ {
+ assert ( sign( sv1.compare(pos1, n1, s2, n2)) == sign(expected));
+ assert(pos1 <= sv1.size());
+ }
+ catch (const std::out_of_range&) { assert(pos1 > sv1.size()); }
+}
+
+
+template<typename CharT>
+void test ( const CharT *s1, size_t pos1, size_t n1,
+ const CharT *s2, size_t n2,
+ int expected ) {
+ typedef std::experimental::basic_string_view<CharT> string_view_t;
+
+ string_view_t sv1 ( s1 );
+ test1 (sv1, pos1, n1, s2, n2, expected);
+}
+
+
+void test0()
+{
+ test("", 0, 0, "", 0, 0);
+ test("", 0, 0, "abcde", 0, 0);
+ test("", 0, 0, "abcde", 1, -1);
+ test("", 0, 0, "abcde", 2, -2);
+ test("", 0, 0, "abcde", 4, -4);
+ test("", 0, 0, "abcde", 5, -5);
+ test("", 0, 0, "abcdefghij", 0, 0);
+ test("", 0, 0, "abcdefghij", 1, -1);
+ test("", 0, 0, "abcdefghij", 5, -5);
+ test("", 0, 0, "abcdefghij", 9, -9);
+ test("", 0, 0, "abcdefghij", 10, -10);
+ test("", 0, 0, "abcdefghijklmnopqrst", 0, 0);
+ test("", 0, 0, "abcdefghijklmnopqrst", 1, -1);
+ test("", 0, 0, "abcdefghijklmnopqrst", 10, -10);
+ test("", 0, 0, "abcdefghijklmnopqrst", 19, -19);
+ test("", 0, 0, "abcdefghijklmnopqrst", 20, -20);
+ test("", 0, 1, "", 0, 0);
+ test("", 0, 1, "abcde", 0, 0);
+ test("", 0, 1, "abcde", 1, -1);
+ test("", 0, 1, "abcde", 2, -2);
+ test("", 0, 1, "abcde", 4, -4);
+ test("", 0, 1, "abcde", 5, -5);
+ test("", 0, 1, "abcdefghij", 0, 0);
+ test("", 0, 1, "abcdefghij", 1, -1);
+ test("", 0, 1, "abcdefghij", 5, -5);
+ test("", 0, 1, "abcdefghij", 9, -9);
+ test("", 0, 1, "abcdefghij", 10, -10);
+ test("", 0, 1, "abcdefghijklmnopqrst", 0, 0);
+ test("", 0, 1, "abcdefghijklmnopqrst", 1, -1);
+ test("", 0, 1, "abcdefghijklmnopqrst", 10, -10);
+ test("", 0, 1, "abcdefghijklmnopqrst", 19, -19);
+ test("", 0, 1, "abcdefghijklmnopqrst", 20, -20);
+ test("", 1, 0, "", 0, 0);
+ test("", 1, 0, "abcde", 0, 0);
+ test("", 1, 0, "abcde", 1, 0);
+ test("", 1, 0, "abcde", 2, 0);
+ test("", 1, 0, "abcde", 4, 0);
+ test("", 1, 0, "abcde", 5, 0);
+ test("", 1, 0, "abcdefghij", 0, 0);
+ test("", 1, 0, "abcdefghij", 1, 0);
+ test("", 1, 0, "abcdefghij", 5, 0);
+ test("", 1, 0, "abcdefghij", 9, 0);
+ test("", 1, 0, "abcdefghij", 10, 0);
+ test("", 1, 0, "abcdefghijklmnopqrst", 0, 0);
+ test("", 1, 0, "abcdefghijklmnopqrst", 1, 0);
+ test("", 1, 0, "abcdefghijklmnopqrst", 10, 0);
+ test("", 1, 0, "abcdefghijklmnopqrst", 19, 0);
+ test("", 1, 0, "abcdefghijklmnopqrst", 20, 0);
+ test("abcde", 0, 0, "", 0, 0);
+ test("abcde", 0, 0, "abcde", 0, 0);
+ test("abcde", 0, 0, "abcde", 1, -1);
+ test("abcde", 0, 0, "abcde", 2, -2);
+ test("abcde", 0, 0, "abcde", 4, -4);
+ test("abcde", 0, 0, "abcde", 5, -5);
+ test("abcde", 0, 0, "abcdefghij", 0, 0);
+ test("abcde", 0, 0, "abcdefghij", 1, -1);
+ test("abcde", 0, 0, "abcdefghij", 5, -5);
+ test("abcde", 0, 0, "abcdefghij", 9, -9);
+ test("abcde", 0, 0, "abcdefghij", 10, -10);
+ test("abcde", 0, 0, "abcdefghijklmnopqrst", 0, 0);
+ test("abcde", 0, 0, "abcdefghijklmnopqrst", 1, -1);
+ test("abcde", 0, 0, "abcdefghijklmnopqrst", 10, -10);
+ test("abcde", 0, 0, "abcdefghijklmnopqrst", 19, -19);
+ test("abcde", 0, 0, "abcdefghijklmnopqrst", 20, -20);
+ test("abcde", 0, 1, "", 0, 1);
+ test("abcde", 0, 1, "abcde", 0, 1);
+ test("abcde", 0, 1, "abcde", 1, 0);
+ test("abcde", 0, 1, "abcde", 2, -1);
+ test("abcde", 0, 1, "abcde", 4, -3);
+ test("abcde", 0, 1, "abcde", 5, -4);
+ test("abcde", 0, 1, "abcdefghij", 0, 1);
+ test("abcde", 0, 1, "abcdefghij", 1, 0);
+ test("abcde", 0, 1, "abcdefghij", 5, -4);
+ test("abcde", 0, 1, "abcdefghij", 9, -8);
+ test("abcde", 0, 1, "abcdefghij", 10, -9);
+ test("abcde", 0, 1, "abcdefghijklmnopqrst", 0, 1);
+ test("abcde", 0, 1, "abcdefghijklmnopqrst", 1, 0);
+ test("abcde", 0, 1, "abcdefghijklmnopqrst", 10, -9);
+ test("abcde", 0, 1, "abcdefghijklmnopqrst", 19, -18);
+ test("abcde", 0, 1, "abcdefghijklmnopqrst", 20, -19);
+ test("abcde", 0, 2, "", 0, 2);
+ test("abcde", 0, 2, "abcde", 0, 2);
+ test("abcde", 0, 2, "abcde", 1, 1);
+ test("abcde", 0, 2, "abcde", 2, 0);
+ test("abcde", 0, 2, "abcde", 4, -2);
+ test("abcde", 0, 2, "abcde", 5, -3);
+ test("abcde", 0, 2, "abcdefghij", 0, 2);
+ test("abcde", 0, 2, "abcdefghij", 1, 1);
+ test("abcde", 0, 2, "abcdefghij", 5, -3);
+ test("abcde", 0, 2, "abcdefghij", 9, -7);
+ test("abcde", 0, 2, "abcdefghij", 10, -8);
+ test("abcde", 0, 2, "abcdefghijklmnopqrst", 0, 2);
+ test("abcde", 0, 2, "abcdefghijklmnopqrst", 1, 1);
+ test("abcde", 0, 2, "abcdefghijklmnopqrst", 10, -8);
+ test("abcde", 0, 2, "abcdefghijklmnopqrst", 19, -17);
+ test("abcde", 0, 2, "abcdefghijklmnopqrst", 20, -18);
+ test("abcde", 0, 4, "", 0, 4);
+ test("abcde", 0, 4, "abcde", 0, 4);
+ test("abcde", 0, 4, "abcde", 1, 3);
+ test("abcde", 0, 4, "abcde", 2, 2);
+}
+
+
+void test1()
+{
+ test("abcde", 0, 4, "abcde", 4, 0);
+ test("abcde", 0, 4, "abcde", 5, -1);
+ test("abcde", 0, 4, "abcdefghij", 0, 4);
+ test("abcde", 0, 4, "abcdefghij", 1, 3);
+ test("abcde", 0, 4, "abcdefghij", 5, -1);
+ test("abcde", 0, 4, "abcdefghij", 9, -5);
+ test("abcde", 0, 4, "abcdefghij", 10, -6);
+ test("abcde", 0, 4, "abcdefghijklmnopqrst", 0, 4);
+ test("abcde", 0, 4, "abcdefghijklmnopqrst", 1, 3);
+ test("abcde", 0, 4, "abcdefghijklmnopqrst", 10, -6);
+ test("abcde", 0, 4, "abcdefghijklmnopqrst", 19, -15);
+ test("abcde", 0, 4, "abcdefghijklmnopqrst", 20, -16);
+ test("abcde", 0, 5, "", 0, 5);
+ test("abcde", 0, 5, "abcde", 0, 5);
+ test("abcde", 0, 5, "abcde", 1, 4);
+ test("abcde", 0, 5, "abcde", 2, 3);
+ test("abcde", 0, 5, "abcde", 4, 1);
+ test("abcde", 0, 5, "abcde", 5, 0);
+ test("abcde", 0, 5, "abcdefghij", 0, 5);
+ test("abcde", 0, 5, "abcdefghij", 1, 4);
+ test("abcde", 0, 5, "abcdefghij", 5, 0);
+ test("abcde", 0, 5, "abcdefghij", 9, -4);
+ test("abcde", 0, 5, "abcdefghij", 10, -5);
+ test("abcde", 0, 5, "abcdefghijklmnopqrst", 0, 5);
+ test("abcde", 0, 5, "abcdefghijklmnopqrst", 1, 4);
+ test("abcde", 0, 5, "abcdefghijklmnopqrst", 10, -5);
+ test("abcde", 0, 5, "abcdefghijklmnopqrst", 19, -14);
+ test("abcde", 0, 5, "abcdefghijklmnopqrst", 20, -15);
+ test("abcde", 0, 6, "", 0, 5);
+ test("abcde", 0, 6, "abcde", 0, 5);
+ test("abcde", 0, 6, "abcde", 1, 4);
+ test("abcde", 0, 6, "abcde", 2, 3);
+ test("abcde", 0, 6, "abcde", 4, 1);
+ test("abcde", 0, 6, "abcde", 5, 0);
+ test("abcde", 0, 6, "abcdefghij", 0, 5);
+ test("abcde", 0, 6, "abcdefghij", 1, 4);
+ test("abcde", 0, 6, "abcdefghij", 5, 0);
+ test("abcde", 0, 6, "abcdefghij", 9, -4);
+ test("abcde", 0, 6, "abcdefghij", 10, -5);
+ test("abcde", 0, 6, "abcdefghijklmnopqrst", 0, 5);
+ test("abcde", 0, 6, "abcdefghijklmnopqrst", 1, 4);
+ test("abcde", 0, 6, "abcdefghijklmnopqrst", 10, -5);
+ test("abcde", 0, 6, "abcdefghijklmnopqrst", 19, -14);
+ test("abcde", 0, 6, "abcdefghijklmnopqrst", 20, -15);
+ test("abcde", 1, 0, "", 0, 0);
+ test("abcde", 1, 0, "abcde", 0, 0);
+ test("abcde", 1, 0, "abcde", 1, -1);
+ test("abcde", 1, 0, "abcde", 2, -2);
+ test("abcde", 1, 0, "abcde", 4, -4);
+ test("abcde", 1, 0, "abcde", 5, -5);
+ test("abcde", 1, 0, "abcdefghij", 0, 0);
+ test("abcde", 1, 0, "abcdefghij", 1, -1);
+ test("abcde", 1, 0, "abcdefghij", 5, -5);
+ test("abcde", 1, 0, "abcdefghij", 9, -9);
+ test("abcde", 1, 0, "abcdefghij", 10, -10);
+ test("abcde", 1, 0, "abcdefghijklmnopqrst", 0, 0);
+ test("abcde", 1, 0, "abcdefghijklmnopqrst", 1, -1);
+ test("abcde", 1, 0, "abcdefghijklmnopqrst", 10, -10);
+ test("abcde", 1, 0, "abcdefghijklmnopqrst", 19, -19);
+ test("abcde", 1, 0, "abcdefghijklmnopqrst", 20, -20);
+ test("abcde", 1, 1, "", 0, 1);
+ test("abcde", 1, 1, "abcde", 0, 1);
+ test("abcde", 1, 1, "abcde", 1, 1);
+ test("abcde", 1, 1, "abcde", 2, 1);
+ test("abcde", 1, 1, "abcde", 4, 1);
+ test("abcde", 1, 1, "abcde", 5, 1);
+ test("abcde", 1, 1, "abcdefghij", 0, 1);
+ test("abcde", 1, 1, "abcdefghij", 1, 1);
+ test("abcde", 1, 1, "abcdefghij", 5, 1);
+ test("abcde", 1, 1, "abcdefghij", 9, 1);
+ test("abcde", 1, 1, "abcdefghij", 10, 1);
+ test("abcde", 1, 1, "abcdefghijklmnopqrst", 0, 1);
+ test("abcde", 1, 1, "abcdefghijklmnopqrst", 1, 1);
+ test("abcde", 1, 1, "abcdefghijklmnopqrst", 10, 1);
+ test("abcde", 1, 1, "abcdefghijklmnopqrst", 19, 1);
+ test("abcde", 1, 1, "abcdefghijklmnopqrst", 20, 1);
+ test("abcde", 1, 2, "", 0, 2);
+ test("abcde", 1, 2, "abcde", 0, 2);
+ test("abcde", 1, 2, "abcde", 1, 1);
+ test("abcde", 1, 2, "abcde", 2, 1);
+ test("abcde", 1, 2, "abcde", 4, 1);
+ test("abcde", 1, 2, "abcde", 5, 1);
+ test("abcde", 1, 2, "abcdefghij", 0, 2);
+ test("abcde", 1, 2, "abcdefghij", 1, 1);
+ test("abcde", 1, 2, "abcdefghij", 5, 1);
+ test("abcde", 1, 2, "abcdefghij", 9, 1);
+ test("abcde", 1, 2, "abcdefghij", 10, 1);
+ test("abcde", 1, 2, "abcdefghijklmnopqrst", 0, 2);
+ test("abcde", 1, 2, "abcdefghijklmnopqrst", 1, 1);
+ test("abcde", 1, 2, "abcdefghijklmnopqrst", 10, 1);
+ test("abcde", 1, 2, "abcdefghijklmnopqrst", 19, 1);
+ test("abcde", 1, 2, "abcdefghijklmnopqrst", 20, 1);
+ test("abcde", 1, 3, "", 0, 3);
+ test("abcde", 1, 3, "abcde", 0, 3);
+ test("abcde", 1, 3, "abcde", 1, 1);
+ test("abcde", 1, 3, "abcde", 2, 1);
+ test("abcde", 1, 3, "abcde", 4, 1);
+ test("abcde", 1, 3, "abcde", 5, 1);
+ test("abcde", 1, 3, "abcdefghij", 0, 3);
+ test("abcde", 1, 3, "abcdefghij", 1, 1);
+}
+
+
+void test2()
+{
+ test("abcde", 1, 3, "abcdefghij", 5, 1);
+ test("abcde", 1, 3, "abcdefghij", 9, 1);
+ test("abcde", 1, 3, "abcdefghij", 10, 1);
+ test("abcde", 1, 3, "abcdefghijklmnopqrst", 0, 3);
+ test("abcde", 1, 3, "abcdefghijklmnopqrst", 1, 1);
+ test("abcde", 1, 3, "abcdefghijklmnopqrst", 10, 1);
+ test("abcde", 1, 3, "abcdefghijklmnopqrst", 19, 1);
+ test("abcde", 1, 3, "abcdefghijklmnopqrst", 20, 1);
+ test("abcde", 1, 4, "", 0, 4);
+ test("abcde", 1, 4, "abcde", 0, 4);
+ test("abcde", 1, 4, "abcde", 1, 1);
+ test("abcde", 1, 4, "abcde", 2, 1);
+ test("abcde", 1, 4, "abcde", 4, 1);
+ test("abcde", 1, 4, "abcde", 5, 1);
+ test("abcde", 1, 4, "abcdefghij", 0, 4);
+ test("abcde", 1, 4, "abcdefghij", 1, 1);
+ test("abcde", 1, 4, "abcdefghij", 5, 1);
+ test("abcde", 1, 4, "abcdefghij", 9, 1);
+ test("abcde", 1, 4, "abcdefghij", 10, 1);
+ test("abcde", 1, 4, "abcdefghijklmnopqrst", 0, 4);
+ test("abcde", 1, 4, "abcdefghijklmnopqrst", 1, 1);
+ test("abcde", 1, 4, "abcdefghijklmnopqrst", 10, 1);
+ test("abcde", 1, 4, "abcdefghijklmnopqrst", 19, 1);
+ test("abcde", 1, 4, "abcdefghijklmnopqrst", 20, 1);
+ test("abcde", 1, 5, "", 0, 4);
+ test("abcde", 1, 5, "abcde", 0, 4);
+ test("abcde", 1, 5, "abcde", 1, 1);
+ test("abcde", 1, 5, "abcde", 2, 1);
+ test("abcde", 1, 5, "abcde", 4, 1);
+ test("abcde", 1, 5, "abcde", 5, 1);
+ test("abcde", 1, 5, "abcdefghij", 0, 4);
+ test("abcde", 1, 5, "abcdefghij", 1, 1);
+ test("abcde", 1, 5, "abcdefghij", 5, 1);
+ test("abcde", 1, 5, "abcdefghij", 9, 1);
+ test("abcde", 1, 5, "abcdefghij", 10, 1);
+ test("abcde", 1, 5, "abcdefghijklmnopqrst", 0, 4);
+ test("abcde", 1, 5, "abcdefghijklmnopqrst", 1, 1);
+ test("abcde", 1, 5, "abcdefghijklmnopqrst", 10, 1);
+ test("abcde", 1, 5, "abcdefghijklmnopqrst", 19, 1);
+ test("abcde", 1, 5, "abcdefghijklmnopqrst", 20, 1);
+ test("abcde", 2, 0, "", 0, 0);
+ test("abcde", 2, 0, "abcde", 0, 0);
+ test("abcde", 2, 0, "abcde", 1, -1);
+ test("abcde", 2, 0, "abcde", 2, -2);
+ test("abcde", 2, 0, "abcde", 4, -4);
+ test("abcde", 2, 0, "abcde", 5, -5);
+ test("abcde", 2, 0, "abcdefghij", 0, 0);
+ test("abcde", 2, 0, "abcdefghij", 1, -1);
+ test("abcde", 2, 0, "abcdefghij", 5, -5);
+ test("abcde", 2, 0, "abcdefghij", 9, -9);
+ test("abcde", 2, 0, "abcdefghij", 10, -10);
+ test("abcde", 2, 0, "abcdefghijklmnopqrst", 0, 0);
+ test("abcde", 2, 0, "abcdefghijklmnopqrst", 1, -1);
+ test("abcde", 2, 0, "abcdefghijklmnopqrst", 10, -10);
+ test("abcde", 2, 0, "abcdefghijklmnopqrst", 19, -19);
+ test("abcde", 2, 0, "abcdefghijklmnopqrst", 20, -20);
+ test("abcde", 2, 1, "", 0, 1);
+ test("abcde", 2, 1, "abcde", 0, 1);
+ test("abcde", 2, 1, "abcde", 1, 2);
+ test("abcde", 2, 1, "abcde", 2, 2);
+ test("abcde", 2, 1, "abcde", 4, 2);
+ test("abcde", 2, 1, "abcde", 5, 2);
+ test("abcde", 2, 1, "abcdefghij", 0, 1);
+ test("abcde", 2, 1, "abcdefghij", 1, 2);
+ test("abcde", 2, 1, "abcdefghij", 5, 2);
+ test("abcde", 2, 1, "abcdefghij", 9, 2);
+ test("abcde", 2, 1, "abcdefghij", 10, 2);
+ test("abcde", 2, 1, "abcdefghijklmnopqrst", 0, 1);
+ test("abcde", 2, 1, "abcdefghijklmnopqrst", 1, 2);
+ test("abcde", 2, 1, "abcdefghijklmnopqrst", 10, 2);
+ test("abcde", 2, 1, "abcdefghijklmnopqrst", 19, 2);
+ test("abcde", 2, 1, "abcdefghijklmnopqrst", 20, 2);
+ test("abcde", 2, 2, "", 0, 2);
+ test("abcde", 2, 2, "abcde", 0, 2);
+ test("abcde", 2, 2, "abcde", 1, 2);
+ test("abcde", 2, 2, "abcde", 2, 2);
+ test("abcde", 2, 2, "abcde", 4, 2);
+ test("abcde", 2, 2, "abcde", 5, 2);
+ test("abcde", 2, 2, "abcdefghij", 0, 2);
+ test("abcde", 2, 2, "abcdefghij", 1, 2);
+ test("abcde", 2, 2, "abcdefghij", 5, 2);
+ test("abcde", 2, 2, "abcdefghij", 9, 2);
+ test("abcde", 2, 2, "abcdefghij", 10, 2);
+ test("abcde", 2, 2, "abcdefghijklmnopqrst", 0, 2);
+ test("abcde", 2, 2, "abcdefghijklmnopqrst", 1, 2);
+ test("abcde", 2, 2, "abcdefghijklmnopqrst", 10, 2);
+ test("abcde", 2, 2, "abcdefghijklmnopqrst", 19, 2);
+ test("abcde", 2, 2, "abcdefghijklmnopqrst", 20, 2);
+ test("abcde", 2, 3, "", 0, 3);
+ test("abcde", 2, 3, "abcde", 0, 3);
+ test("abcde", 2, 3, "abcde", 1, 2);
+ test("abcde", 2, 3, "abcde", 2, 2);
+ test("abcde", 2, 3, "abcde", 4, 2);
+ test("abcde", 2, 3, "abcde", 5, 2);
+ test("abcde", 2, 3, "abcdefghij", 0, 3);
+ test("abcde", 2, 3, "abcdefghij", 1, 2);
+ test("abcde", 2, 3, "abcdefghij", 5, 2);
+ test("abcde", 2, 3, "abcdefghij", 9, 2);
+ test("abcde", 2, 3, "abcdefghij", 10, 2);
+ test("abcde", 2, 3, "abcdefghijklmnopqrst", 0, 3);
+}
+
+
+void test3()
+{
+ test("abcde", 2, 3, "abcdefghijklmnopqrst", 1, 2);
+ test("abcde", 2, 3, "abcdefghijklmnopqrst", 10, 2);
+ test("abcde", 2, 3, "abcdefghijklmnopqrst", 19, 2);
+ test("abcde", 2, 3, "abcdefghijklmnopqrst", 20, 2);
+ test("abcde", 2, 4, "", 0, 3);
+ test("abcde", 2, 4, "abcde", 0, 3);
+ test("abcde", 2, 4, "abcde", 1, 2);
+ test("abcde", 2, 4, "abcde", 2, 2);
+ test("abcde", 2, 4, "abcde", 4, 2);
+ test("abcde", 2, 4, "abcde", 5, 2);
+ test("abcde", 2, 4, "abcdefghij", 0, 3);
+ test("abcde", 2, 4, "abcdefghij", 1, 2);
+ test("abcde", 2, 4, "abcdefghij", 5, 2);
+ test("abcde", 2, 4, "abcdefghij", 9, 2);
+ test("abcde", 2, 4, "abcdefghij", 10, 2);
+ test("abcde", 2, 4, "abcdefghijklmnopqrst", 0, 3);
+ test("abcde", 2, 4, "abcdefghijklmnopqrst", 1, 2);
+ test("abcde", 2, 4, "abcdefghijklmnopqrst", 10, 2);
+ test("abcde", 2, 4, "abcdefghijklmnopqrst", 19, 2);
+ test("abcde", 2, 4, "abcdefghijklmnopqrst", 20, 2);
+ test("abcde", 4, 0, "", 0, 0);
+ test("abcde", 4, 0, "abcde", 0, 0);
+ test("abcde", 4, 0, "abcde", 1, -1);
+ test("abcde", 4, 0, "abcde", 2, -2);
+ test("abcde", 4, 0, "abcde", 4, -4);
+ test("abcde", 4, 0, "abcde", 5, -5);
+ test("abcde", 4, 0, "abcdefghij", 0, 0);
+ test("abcde", 4, 0, "abcdefghij", 1, -1);
+ test("abcde", 4, 0, "abcdefghij", 5, -5);
+ test("abcde", 4, 0, "abcdefghij", 9, -9);
+ test("abcde", 4, 0, "abcdefghij", 10, -10);
+ test("abcde", 4, 0, "abcdefghijklmnopqrst", 0, 0);
+ test("abcde", 4, 0, "abcdefghijklmnopqrst", 1, -1);
+ test("abcde", 4, 0, "abcdefghijklmnopqrst", 10, -10);
+ test("abcde", 4, 0, "abcdefghijklmnopqrst", 19, -19);
+ test("abcde", 4, 0, "abcdefghijklmnopqrst", 20, -20);
+ test("abcde", 4, 1, "", 0, 1);
+ test("abcde", 4, 1, "abcde", 0, 1);
+ test("abcde", 4, 1, "abcde", 1, 4);
+ test("abcde", 4, 1, "abcde", 2, 4);
+ test("abcde", 4, 1, "abcde", 4, 4);
+ test("abcde", 4, 1, "abcde", 5, 4);
+ test("abcde", 4, 1, "abcdefghij", 0, 1);
+ test("abcde", 4, 1, "abcdefghij", 1, 4);
+ test("abcde", 4, 1, "abcdefghij", 5, 4);
+ test("abcde", 4, 1, "abcdefghij", 9, 4);
+ test("abcde", 4, 1, "abcdefghij", 10, 4);
+ test("abcde", 4, 1, "abcdefghijklmnopqrst", 0, 1);
+ test("abcde", 4, 1, "abcdefghijklmnopqrst", 1, 4);
+ test("abcde", 4, 1, "abcdefghijklmnopqrst", 10, 4);
+ test("abcde", 4, 1, "abcdefghijklmnopqrst", 19, 4);
+ test("abcde", 4, 1, "abcdefghijklmnopqrst", 20, 4);
+ test("abcde", 4, 2, "", 0, 1);
+ test("abcde", 4, 2, "abcde", 0, 1);
+ test("abcde", 4, 2, "abcde", 1, 4);
+ test("abcde", 4, 2, "abcde", 2, 4);
+ test("abcde", 4, 2, "abcde", 4, 4);
+ test("abcde", 4, 2, "abcde", 5, 4);
+ test("abcde", 4, 2, "abcdefghij", 0, 1);
+ test("abcde", 4, 2, "abcdefghij", 1, 4);
+ test("abcde", 4, 2, "abcdefghij", 5, 4);
+ test("abcde", 4, 2, "abcdefghij", 9, 4);
+ test("abcde", 4, 2, "abcdefghij", 10, 4);
+ test("abcde", 4, 2, "abcdefghijklmnopqrst", 0, 1);
+ test("abcde", 4, 2, "abcdefghijklmnopqrst", 1, 4);
+ test("abcde", 4, 2, "abcdefghijklmnopqrst", 10, 4);
+ test("abcde", 4, 2, "abcdefghijklmnopqrst", 19, 4);
+ test("abcde", 4, 2, "abcdefghijklmnopqrst", 20, 4);
+ test("abcde", 5, 0, "", 0, 0);
+ test("abcde", 5, 0, "abcde", 0, 0);
+ test("abcde", 5, 0, "abcde", 1, -1);
+ test("abcde", 5, 0, "abcde", 2, -2);
+ test("abcde", 5, 0, "abcde", 4, -4);
+ test("abcde", 5, 0, "abcde", 5, -5);
+ test("abcde", 5, 0, "abcdefghij", 0, 0);
+ test("abcde", 5, 0, "abcdefghij", 1, -1);
+ test("abcde", 5, 0, "abcdefghij", 5, -5);
+ test("abcde", 5, 0, "abcdefghij", 9, -9);
+ test("abcde", 5, 0, "abcdefghij", 10, -10);
+ test("abcde", 5, 0, "abcdefghijklmnopqrst", 0, 0);
+ test("abcde", 5, 0, "abcdefghijklmnopqrst", 1, -1);
+ test("abcde", 5, 0, "abcdefghijklmnopqrst", 10, -10);
+ test("abcde", 5, 0, "abcdefghijklmnopqrst", 19, -19);
+ test("abcde", 5, 0, "abcdefghijklmnopqrst", 20, -20);
+ test("abcde", 5, 1, "", 0, 0);
+ test("abcde", 5, 1, "abcde", 0, 0);
+ test("abcde", 5, 1, "abcde", 1, -1);
+ test("abcde", 5, 1, "abcde", 2, -2);
+ test("abcde", 5, 1, "abcde", 4, -4);
+ test("abcde", 5, 1, "abcde", 5, -5);
+ test("abcde", 5, 1, "abcdefghij", 0, 0);
+ test("abcde", 5, 1, "abcdefghij", 1, -1);
+ test("abcde", 5, 1, "abcdefghij", 5, -5);
+ test("abcde", 5, 1, "abcdefghij", 9, -9);
+ test("abcde", 5, 1, "abcdefghij", 10, -10);
+ test("abcde", 5, 1, "abcdefghijklmnopqrst", 0, 0);
+ test("abcde", 5, 1, "abcdefghijklmnopqrst", 1, -1);
+ test("abcde", 5, 1, "abcdefghijklmnopqrst", 10, -10);
+ test("abcde", 5, 1, "abcdefghijklmnopqrst", 19, -19);
+ test("abcde", 5, 1, "abcdefghijklmnopqrst", 20, -20);
+}
+
+
+void test4()
+{
+ test("abcde", 6, 0, "", 0, 0);
+ test("abcde", 6, 0, "abcde", 0, 0);
+ test("abcde", 6, 0, "abcde", 1, 0);
+ test("abcde", 6, 0, "abcde", 2, 0);
+ test("abcde", 6, 0, "abcde", 4, 0);
+ test("abcde", 6, 0, "abcde", 5, 0);
+ test("abcde", 6, 0, "abcdefghij", 0, 0);
+ test("abcde", 6, 0, "abcdefghij", 1, 0);
+ test("abcde", 6, 0, "abcdefghij", 5, 0);
+ test("abcde", 6, 0, "abcdefghij", 9, 0);
+ test("abcde", 6, 0, "abcdefghij", 10, 0);
+ test("abcde", 6, 0, "abcdefghijklmnopqrst", 0, 0);
+ test("abcde", 6, 0, "abcdefghijklmnopqrst", 1, 0);
+ test("abcde", 6, 0, "abcdefghijklmnopqrst", 10, 0);
+ test("abcde", 6, 0, "abcdefghijklmnopqrst", 19, 0);
+ test("abcde", 6, 0, "abcdefghijklmnopqrst", 20, 0);
+ test("abcdefghij", 0, 0, "", 0, 0);
+ test("abcdefghij", 0, 0, "abcde", 0, 0);
+ test("abcdefghij", 0, 0, "abcde", 1, -1);
+ test("abcdefghij", 0, 0, "abcde", 2, -2);
+ test("abcdefghij", 0, 0, "abcde", 4, -4);
+ test("abcdefghij", 0, 0, "abcde", 5, -5);
+ test("abcdefghij", 0, 0, "abcdefghij", 0, 0);
+ test("abcdefghij", 0, 0, "abcdefghij", 1, -1);
+ test("abcdefghij", 0, 0, "abcdefghij", 5, -5);
+ test("abcdefghij", 0, 0, "abcdefghij", 9, -9);
+ test("abcdefghij", 0, 0, "abcdefghij", 10, -10);
+ test("abcdefghij", 0, 0, "abcdefghijklmnopqrst", 0, 0);
+ test("abcdefghij", 0, 0, "abcdefghijklmnopqrst", 1, -1);
+ test("abcdefghij", 0, 0, "abcdefghijklmnopqrst", 10, -10);
+ test("abcdefghij", 0, 0, "abcdefghijklmnopqrst", 19, -19);
+ test("abcdefghij", 0, 0, "abcdefghijklmnopqrst", 20, -20);
+ test("abcdefghij", 0, 1, "", 0, 1);
+ test("abcdefghij", 0, 1, "abcde", 0, 1);
+ test("abcdefghij", 0, 1, "abcde", 1, 0);
+ test("abcdefghij", 0, 1, "abcde", 2, -1);
+ test("abcdefghij", 0, 1, "abcde", 4, -3);
+ test("abcdefghij", 0, 1, "abcde", 5, -4);
+ test("abcdefghij", 0, 1, "abcdefghij", 0, 1);
+ test("abcdefghij", 0, 1, "abcdefghij", 1, 0);
+ test("abcdefghij", 0, 1, "abcdefghij", 5, -4);
+ test("abcdefghij", 0, 1, "abcdefghij", 9, -8);
+ test("abcdefghij", 0, 1, "abcdefghij", 10, -9);
+ test("abcdefghij", 0, 1, "abcdefghijklmnopqrst", 0, 1);
+ test("abcdefghij", 0, 1, "abcdefghijklmnopqrst", 1, 0);
+ test("abcdefghij", 0, 1, "abcdefghijklmnopqrst", 10, -9);
+ test("abcdefghij", 0, 1, "abcdefghijklmnopqrst", 19, -18);
+ test("abcdefghij", 0, 1, "abcdefghijklmnopqrst", 20, -19);
+ test("abcdefghij", 0, 5, "", 0, 5);
+ test("abcdefghij", 0, 5, "abcde", 0, 5);
+ test("abcdefghij", 0, 5, "abcde", 1, 4);
+ test("abcdefghij", 0, 5, "abcde", 2, 3);
+ test("abcdefghij", 0, 5, "abcde", 4, 1);
+ test("abcdefghij", 0, 5, "abcde", 5, 0);
+ test("abcdefghij", 0, 5, "abcdefghij", 0, 5);
+ test("abcdefghij", 0, 5, "abcdefghij", 1, 4);
+ test("abcdefghij", 0, 5, "abcdefghij", 5, 0);
+ test("abcdefghij", 0, 5, "abcdefghij", 9, -4);
+ test("abcdefghij", 0, 5, "abcdefghij", 10, -5);
+ test("abcdefghij", 0, 5, "abcdefghijklmnopqrst", 0, 5);
+ test("abcdefghij", 0, 5, "abcdefghijklmnopqrst", 1, 4);
+ test("abcdefghij", 0, 5, "abcdefghijklmnopqrst", 10, -5);
+ test("abcdefghij", 0, 5, "abcdefghijklmnopqrst", 19, -14);
+ test("abcdefghij", 0, 5, "abcdefghijklmnopqrst", 20, -15);
+ test("abcdefghij", 0, 9, "", 0, 9);
+ test("abcdefghij", 0, 9, "abcde", 0, 9);
+ test("abcdefghij", 0, 9, "abcde", 1, 8);
+ test("abcdefghij", 0, 9, "abcde", 2, 7);
+ test("abcdefghij", 0, 9, "abcde", 4, 5);
+ test("abcdefghij", 0, 9, "abcde", 5, 4);
+ test("abcdefghij", 0, 9, "abcdefghij", 0, 9);
+ test("abcdefghij", 0, 9, "abcdefghij", 1, 8);
+ test("abcdefghij", 0, 9, "abcdefghij", 5, 4);
+ test("abcdefghij", 0, 9, "abcdefghij", 9, 0);
+ test("abcdefghij", 0, 9, "abcdefghij", 10, -1);
+ test("abcdefghij", 0, 9, "abcdefghijklmnopqrst", 0, 9);
+ test("abcdefghij", 0, 9, "abcdefghijklmnopqrst", 1, 8);
+ test("abcdefghij", 0, 9, "abcdefghijklmnopqrst", 10, -1);
+ test("abcdefghij", 0, 9, "abcdefghijklmnopqrst", 19, -10);
+ test("abcdefghij", 0, 9, "abcdefghijklmnopqrst", 20, -11);
+ test("abcdefghij", 0, 10, "", 0, 10);
+ test("abcdefghij", 0, 10, "abcde", 0, 10);
+ test("abcdefghij", 0, 10, "abcde", 1, 9);
+ test("abcdefghij", 0, 10, "abcde", 2, 8);
+ test("abcdefghij", 0, 10, "abcde", 4, 6);
+ test("abcdefghij", 0, 10, "abcde", 5, 5);
+ test("abcdefghij", 0, 10, "abcdefghij", 0, 10);
+ test("abcdefghij", 0, 10, "abcdefghij", 1, 9);
+ test("abcdefghij", 0, 10, "abcdefghij", 5, 5);
+ test("abcdefghij", 0, 10, "abcdefghij", 9, 1);
+ test("abcdefghij", 0, 10, "abcdefghij", 10, 0);
+ test("abcdefghij", 0, 10, "abcdefghijklmnopqrst", 0, 10);
+ test("abcdefghij", 0, 10, "abcdefghijklmnopqrst", 1, 9);
+ test("abcdefghij", 0, 10, "abcdefghijklmnopqrst", 10, 0);
+ test("abcdefghij", 0, 10, "abcdefghijklmnopqrst", 19, -9);
+ test("abcdefghij", 0, 10, "abcdefghijklmnopqrst", 20, -10);
+ test("abcdefghij", 0, 11, "", 0, 10);
+ test("abcdefghij", 0, 11, "abcde", 0, 10);
+ test("abcdefghij", 0, 11, "abcde", 1, 9);
+ test("abcdefghij", 0, 11, "abcde", 2, 8);
+}
+
+
+void test5()
+{
+ test("abcdefghij", 0, 11, "abcde", 4, 6);
+ test("abcdefghij", 0, 11, "abcde", 5, 5);
+ test("abcdefghij", 0, 11, "abcdefghij", 0, 10);
+ test("abcdefghij", 0, 11, "abcdefghij", 1, 9);
+ test("abcdefghij", 0, 11, "abcdefghij", 5, 5);
+ test("abcdefghij", 0, 11, "abcdefghij", 9, 1);
+ test("abcdefghij", 0, 11, "abcdefghij", 10, 0);
+ test("abcdefghij", 0, 11, "abcdefghijklmnopqrst", 0, 10);
+ test("abcdefghij", 0, 11, "abcdefghijklmnopqrst", 1, 9);
+ test("abcdefghij", 0, 11, "abcdefghijklmnopqrst", 10, 0);
+ test("abcdefghij", 0, 11, "abcdefghijklmnopqrst", 19, -9);
+ test("abcdefghij", 0, 11, "abcdefghijklmnopqrst", 20, -10);
+ test("abcdefghij", 1, 0, "", 0, 0);
+ test("abcdefghij", 1, 0, "abcde", 0, 0);
+ test("abcdefghij", 1, 0, "abcde", 1, -1);
+ test("abcdefghij", 1, 0, "abcde", 2, -2);
+ test("abcdefghij", 1, 0, "abcde", 4, -4);
+ test("abcdefghij", 1, 0, "abcde", 5, -5);
+ test("abcdefghij", 1, 0, "abcdefghij", 0, 0);
+ test("abcdefghij", 1, 0, "abcdefghij", 1, -1);
+ test("abcdefghij", 1, 0, "abcdefghij", 5, -5);
+ test("abcdefghij", 1, 0, "abcdefghij", 9, -9);
+ test("abcdefghij", 1, 0, "abcdefghij", 10, -10);
+ test("abcdefghij", 1, 0, "abcdefghijklmnopqrst", 0, 0);
+ test("abcdefghij", 1, 0, "abcdefghijklmnopqrst", 1, -1);
+ test("abcdefghij", 1, 0, "abcdefghijklmnopqrst", 10, -10);
+ test("abcdefghij", 1, 0, "abcdefghijklmnopqrst", 19, -19);
+ test("abcdefghij", 1, 0, "abcdefghijklmnopqrst", 20, -20);
+ test("abcdefghij", 1, 1, "", 0, 1);
+ test("abcdefghij", 1, 1, "abcde", 0, 1);
+ test("abcdefghij", 1, 1, "abcde", 1, 1);
+ test("abcdefghij", 1, 1, "abcde", 2, 1);
+ test("abcdefghij", 1, 1, "abcde", 4, 1);
+ test("abcdefghij", 1, 1, "abcde", 5, 1);
+ test("abcdefghij", 1, 1, "abcdefghij", 0, 1);
+ test("abcdefghij", 1, 1, "abcdefghij", 1, 1);
+ test("abcdefghij", 1, 1, "abcdefghij", 5, 1);
+ test("abcdefghij", 1, 1, "abcdefghij", 9, 1);
+ test("abcdefghij", 1, 1, "abcdefghij", 10, 1);
+ test("abcdefghij", 1, 1, "abcdefghijklmnopqrst", 0, 1);
+ test("abcdefghij", 1, 1, "abcdefghijklmnopqrst", 1, 1);
+ test("abcdefghij", 1, 1, "abcdefghijklmnopqrst", 10, 1);
+ test("abcdefghij", 1, 1, "abcdefghijklmnopqrst", 19, 1);
+ test("abcdefghij", 1, 1, "abcdefghijklmnopqrst", 20, 1);
+ test("abcdefghij", 1, 4, "", 0, 4);
+ test("abcdefghij", 1, 4, "abcde", 0, 4);
+ test("abcdefghij", 1, 4, "abcde", 1, 1);
+ test("abcdefghij", 1, 4, "abcde", 2, 1);
+ test("abcdefghij", 1, 4, "abcde", 4, 1);
+ test("abcdefghij", 1, 4, "abcde", 5, 1);
+ test("abcdefghij", 1, 4, "abcdefghij", 0, 4);
+ test("abcdefghij", 1, 4, "abcdefghij", 1, 1);
+ test("abcdefghij", 1, 4, "abcdefghij", 5, 1);
+ test("abcdefghij", 1, 4, "abcdefghij", 9, 1);
+ test("abcdefghij", 1, 4, "abcdefghij", 10, 1);
+ test("abcdefghij", 1, 4, "abcdefghijklmnopqrst", 0, 4);
+ test("abcdefghij", 1, 4, "abcdefghijklmnopqrst", 1, 1);
+ test("abcdefghij", 1, 4, "abcdefghijklmnopqrst", 10, 1);
+ test("abcdefghij", 1, 4, "abcdefghijklmnopqrst", 19, 1);
+ test("abcdefghij", 1, 4, "abcdefghijklmnopqrst", 20, 1);
+ test("abcdefghij", 1, 8, "", 0, 8);
+ test("abcdefghij", 1, 8, "abcde", 0, 8);
+ test("abcdefghij", 1, 8, "abcde", 1, 1);
+ test("abcdefghij", 1, 8, "abcde", 2, 1);
+ test("abcdefghij", 1, 8, "abcde", 4, 1);
+ test("abcdefghij", 1, 8, "abcde", 5, 1);
+ test("abcdefghij", 1, 8, "abcdefghij", 0, 8);
+ test("abcdefghij", 1, 8, "abcdefghij", 1, 1);
+ test("abcdefghij", 1, 8, "abcdefghij", 5, 1);
+ test("abcdefghij", 1, 8, "abcdefghij", 9, 1);
+ test("abcdefghij", 1, 8, "abcdefghij", 10, 1);
+ test("abcdefghij", 1, 8, "abcdefghijklmnopqrst", 0, 8);
+ test("abcdefghij", 1, 8, "abcdefghijklmnopqrst", 1, 1);
+ test("abcdefghij", 1, 8, "abcdefghijklmnopqrst", 10, 1);
+ test("abcdefghij", 1, 8, "abcdefghijklmnopqrst", 19, 1);
+ test("abcdefghij", 1, 8, "abcdefghijklmnopqrst", 20, 1);
+ test("abcdefghij", 1, 9, "", 0, 9);
+ test("abcdefghij", 1, 9, "abcde", 0, 9);
+ test("abcdefghij", 1, 9, "abcde", 1, 1);
+ test("abcdefghij", 1, 9, "abcde", 2, 1);
+ test("abcdefghij", 1, 9, "abcde", 4, 1);
+ test("abcdefghij", 1, 9, "abcde", 5, 1);
+ test("abcdefghij", 1, 9, "abcdefghij", 0, 9);
+ test("abcdefghij", 1, 9, "abcdefghij", 1, 1);
+ test("abcdefghij", 1, 9, "abcdefghij", 5, 1);
+ test("abcdefghij", 1, 9, "abcdefghij", 9, 1);
+ test("abcdefghij", 1, 9, "abcdefghij", 10, 1);
+ test("abcdefghij", 1, 9, "abcdefghijklmnopqrst", 0, 9);
+ test("abcdefghij", 1, 9, "abcdefghijklmnopqrst", 1, 1);
+ test("abcdefghij", 1, 9, "abcdefghijklmnopqrst", 10, 1);
+ test("abcdefghij", 1, 9, "abcdefghijklmnopqrst", 19, 1);
+ test("abcdefghij", 1, 9, "abcdefghijklmnopqrst", 20, 1);
+ test("abcdefghij", 1, 10, "", 0, 9);
+ test("abcdefghij", 1, 10, "abcde", 0, 9);
+ test("abcdefghij", 1, 10, "abcde", 1, 1);
+ test("abcdefghij", 1, 10, "abcde", 2, 1);
+ test("abcdefghij", 1, 10, "abcde", 4, 1);
+ test("abcdefghij", 1, 10, "abcde", 5, 1);
+ test("abcdefghij", 1, 10, "abcdefghij", 0, 9);
+ test("abcdefghij", 1, 10, "abcdefghij", 1, 1);
+}
+
+
+void test6()
+{
+ test("abcdefghij", 1, 10, "abcdefghij", 5, 1);
+ test("abcdefghij", 1, 10, "abcdefghij", 9, 1);
+ test("abcdefghij", 1, 10, "abcdefghij", 10, 1);
+ test("abcdefghij", 1, 10, "abcdefghijklmnopqrst", 0, 9);
+ test("abcdefghij", 1, 10, "abcdefghijklmnopqrst", 1, 1);
+ test("abcdefghij", 1, 10, "abcdefghijklmnopqrst", 10, 1);
+ test("abcdefghij", 1, 10, "abcdefghijklmnopqrst", 19, 1);
+ test("abcdefghij", 1, 10, "abcdefghijklmnopqrst", 20, 1);
+ test("abcdefghij", 5, 0, "", 0, 0);
+ test("abcdefghij", 5, 0, "abcde", 0, 0);
+ test("abcdefghij", 5, 0, "abcde", 1, -1);
+ test("abcdefghij", 5, 0, "abcde", 2, -2);
+ test("abcdefghij", 5, 0, "abcde", 4, -4);
+ test("abcdefghij", 5, 0, "abcde", 5, -5);
+ test("abcdefghij", 5, 0, "abcdefghij", 0, 0);
+ test("abcdefghij", 5, 0, "abcdefghij", 1, -1);
+ test("abcdefghij", 5, 0, "abcdefghij", 5, -5);
+ test("abcdefghij", 5, 0, "abcdefghij", 9, -9);
+ test("abcdefghij", 5, 0, "abcdefghij", 10, -10);
+ test("abcdefghij", 5, 0, "abcdefghijklmnopqrst", 0, 0);
+ test("abcdefghij", 5, 0, "abcdefghijklmnopqrst", 1, -1);
+ test("abcdefghij", 5, 0, "abcdefghijklmnopqrst", 10, -10);
+ test("abcdefghij", 5, 0, "abcdefghijklmnopqrst", 19, -19);
+ test("abcdefghij", 5, 0, "abcdefghijklmnopqrst", 20, -20);
+ test("abcdefghij", 5, 1, "", 0, 1);
+ test("abcdefghij", 5, 1, "abcde", 0, 1);
+ test("abcdefghij", 5, 1, "abcde", 1, 5);
+ test("abcdefghij", 5, 1, "abcde", 2, 5);
+ test("abcdefghij", 5, 1, "abcde", 4, 5);
+ test("abcdefghij", 5, 1, "abcde", 5, 5);
+ test("abcdefghij", 5, 1, "abcdefghij", 0, 1);
+ test("abcdefghij", 5, 1, "abcdefghij", 1, 5);
+ test("abcdefghij", 5, 1, "abcdefghij", 5, 5);
+ test("abcdefghij", 5, 1, "abcdefghij", 9, 5);
+ test("abcdefghij", 5, 1, "abcdefghij", 10, 5);
+ test("abcdefghij", 5, 1, "abcdefghijklmnopqrst", 0, 1);
+ test("abcdefghij", 5, 1, "abcdefghijklmnopqrst", 1, 5);
+ test("abcdefghij", 5, 1, "abcdefghijklmnopqrst", 10, 5);
+ test("abcdefghij", 5, 1, "abcdefghijklmnopqrst", 19, 5);
+ test("abcdefghij", 5, 1, "abcdefghijklmnopqrst", 20, 5);
+ test("abcdefghij", 5, 2, "", 0, 2);
+ test("abcdefghij", 5, 2, "abcde", 0, 2);
+ test("abcdefghij", 5, 2, "abcde", 1, 5);
+ test("abcdefghij", 5, 2, "abcde", 2, 5);
+ test("abcdefghij", 5, 2, "abcde", 4, 5);
+ test("abcdefghij", 5, 2, "abcde", 5, 5);
+ test("abcdefghij", 5, 2, "abcdefghij", 0, 2);
+ test("abcdefghij", 5, 2, "abcdefghij", 1, 5);
+ test("abcdefghij", 5, 2, "abcdefghij", 5, 5);
+ test("abcdefghij", 5, 2, "abcdefghij", 9, 5);
+ test("abcdefghij", 5, 2, "abcdefghij", 10, 5);
+ test("abcdefghij", 5, 2, "abcdefghijklmnopqrst", 0, 2);
+ test("abcdefghij", 5, 2, "abcdefghijklmnopqrst", 1, 5);
+ test("abcdefghij", 5, 2, "abcdefghijklmnopqrst", 10, 5);
+ test("abcdefghij", 5, 2, "abcdefghijklmnopqrst", 19, 5);
+ test("abcdefghij", 5, 2, "abcdefghijklmnopqrst", 20, 5);
+ test("abcdefghij", 5, 4, "", 0, 4);
+ test("abcdefghij", 5, 4, "abcde", 0, 4);
+ test("abcdefghij", 5, 4, "abcde", 1, 5);
+ test("abcdefghij", 5, 4, "abcde", 2, 5);
+ test("abcdefghij", 5, 4, "abcde", 4, 5);
+ test("abcdefghij", 5, 4, "abcde", 5, 5);
+ test("abcdefghij", 5, 4, "abcdefghij", 0, 4);
+ test("abcdefghij", 5, 4, "abcdefghij", 1, 5);
+ test("abcdefghij", 5, 4, "abcdefghij", 5, 5);
+ test("abcdefghij", 5, 4, "abcdefghij", 9, 5);
+ test("abcdefghij", 5, 4, "abcdefghij", 10, 5);
+ test("abcdefghij", 5, 4, "abcdefghijklmnopqrst", 0, 4);
+ test("abcdefghij", 5, 4, "abcdefghijklmnopqrst", 1, 5);
+ test("abcdefghij", 5, 4, "abcdefghijklmnopqrst", 10, 5);
+ test("abcdefghij", 5, 4, "abcdefghijklmnopqrst", 19, 5);
+ test("abcdefghij", 5, 4, "abcdefghijklmnopqrst", 20, 5);
+ test("abcdefghij", 5, 5, "", 0, 5);
+ test("abcdefghij", 5, 5, "abcde", 0, 5);
+ test("abcdefghij", 5, 5, "abcde", 1, 5);
+ test("abcdefghij", 5, 5, "abcde", 2, 5);
+ test("abcdefghij", 5, 5, "abcde", 4, 5);
+ test("abcdefghij", 5, 5, "abcde", 5, 5);
+ test("abcdefghij", 5, 5, "abcdefghij", 0, 5);
+ test("abcdefghij", 5, 5, "abcdefghij", 1, 5);
+ test("abcdefghij", 5, 5, "abcdefghij", 5, 5);
+ test("abcdefghij", 5, 5, "abcdefghij", 9, 5);
+ test("abcdefghij", 5, 5, "abcdefghij", 10, 5);
+ test("abcdefghij", 5, 5, "abcdefghijklmnopqrst", 0, 5);
+ test("abcdefghij", 5, 5, "abcdefghijklmnopqrst", 1, 5);
+ test("abcdefghij", 5, 5, "abcdefghijklmnopqrst", 10, 5);
+ test("abcdefghij", 5, 5, "abcdefghijklmnopqrst", 19, 5);
+ test("abcdefghij", 5, 5, "abcdefghijklmnopqrst", 20, 5);
+ test("abcdefghij", 5, 6, "", 0, 5);
+ test("abcdefghij", 5, 6, "abcde", 0, 5);
+ test("abcdefghij", 5, 6, "abcde", 1, 5);
+ test("abcdefghij", 5, 6, "abcde", 2, 5);
+ test("abcdefghij", 5, 6, "abcde", 4, 5);
+ test("abcdefghij", 5, 6, "abcde", 5, 5);
+ test("abcdefghij", 5, 6, "abcdefghij", 0, 5);
+ test("abcdefghij", 5, 6, "abcdefghij", 1, 5);
+ test("abcdefghij", 5, 6, "abcdefghij", 5, 5);
+ test("abcdefghij", 5, 6, "abcdefghij", 9, 5);
+ test("abcdefghij", 5, 6, "abcdefghij", 10, 5);
+ test("abcdefghij", 5, 6, "abcdefghijklmnopqrst", 0, 5);
+}
+
+
+void test7()
+{
+ test("abcdefghij", 5, 6, "abcdefghijklmnopqrst", 1, 5);
+ test("abcdefghij", 5, 6, "abcdefghijklmnopqrst", 10, 5);
+ test("abcdefghij", 5, 6, "abcdefghijklmnopqrst", 19, 5);
+ test("abcdefghij", 5, 6, "abcdefghijklmnopqrst", 20, 5);
+ test("abcdefghij", 9, 0, "", 0, 0);
+ test("abcdefghij", 9, 0, "abcde", 0, 0);
+ test("abcdefghij", 9, 0, "abcde", 1, -1);
+ test("abcdefghij", 9, 0, "abcde", 2, -2);
+ test("abcdefghij", 9, 0, "abcde", 4, -4);
+ test("abcdefghij", 9, 0, "abcde", 5, -5);
+ test("abcdefghij", 9, 0, "abcdefghij", 0, 0);
+ test("abcdefghij", 9, 0, "abcdefghij", 1, -1);
+ test("abcdefghij", 9, 0, "abcdefghij", 5, -5);
+ test("abcdefghij", 9, 0, "abcdefghij", 9, -9);
+ test("abcdefghij", 9, 0, "abcdefghij", 10, -10);
+ test("abcdefghij", 9, 0, "abcdefghijklmnopqrst", 0, 0);
+ test("abcdefghij", 9, 0, "abcdefghijklmnopqrst", 1, -1);
+ test("abcdefghij", 9, 0, "abcdefghijklmnopqrst", 10, -10);
+ test("abcdefghij", 9, 0, "abcdefghijklmnopqrst", 19, -19);
+ test("abcdefghij", 9, 0, "abcdefghijklmnopqrst", 20, -20);
+ test("abcdefghij", 9, 1, "", 0, 1);
+ test("abcdefghij", 9, 1, "abcde", 0, 1);
+ test("abcdefghij", 9, 1, "abcde", 1, 9);
+ test("abcdefghij", 9, 1, "abcde", 2, 9);
+ test("abcdefghij", 9, 1, "abcde", 4, 9);
+ test("abcdefghij", 9, 1, "abcde", 5, 9);
+ test("abcdefghij", 9, 1, "abcdefghij", 0, 1);
+ test("abcdefghij", 9, 1, "abcdefghij", 1, 9);
+ test("abcdefghij", 9, 1, "abcdefghij", 5, 9);
+ test("abcdefghij", 9, 1, "abcdefghij", 9, 9);
+ test("abcdefghij", 9, 1, "abcdefghij", 10, 9);
+ test("abcdefghij", 9, 1, "abcdefghijklmnopqrst", 0, 1);
+ test("abcdefghij", 9, 1, "abcdefghijklmnopqrst", 1, 9);
+ test("abcdefghij", 9, 1, "abcdefghijklmnopqrst", 10, 9);
+ test("abcdefghij", 9, 1, "abcdefghijklmnopqrst", 19, 9);
+ test("abcdefghij", 9, 1, "abcdefghijklmnopqrst", 20, 9);
+ test("abcdefghij", 9, 2, "", 0, 1);
+ test("abcdefghij", 9, 2, "abcde", 0, 1);
+ test("abcdefghij", 9, 2, "abcde", 1, 9);
+ test("abcdefghij", 9, 2, "abcde", 2, 9);
+ test("abcdefghij", 9, 2, "abcde", 4, 9);
+ test("abcdefghij", 9, 2, "abcde", 5, 9);
+ test("abcdefghij", 9, 2, "abcdefghij", 0, 1);
+ test("abcdefghij", 9, 2, "abcdefghij", 1, 9);
+ test("abcdefghij", 9, 2, "abcdefghij", 5, 9);
+ test("abcdefghij", 9, 2, "abcdefghij", 9, 9);
+ test("abcdefghij", 9, 2, "abcdefghij", 10, 9);
+ test("abcdefghij", 9, 2, "abcdefghijklmnopqrst", 0, 1);
+ test("abcdefghij", 9, 2, "abcdefghijklmnopqrst", 1, 9);
+ test("abcdefghij", 9, 2, "abcdefghijklmnopqrst", 10, 9);
+ test("abcdefghij", 9, 2, "abcdefghijklmnopqrst", 19, 9);
+ test("abcdefghij", 9, 2, "abcdefghijklmnopqrst", 20, 9);
+ test("abcdefghij", 10, 0, "", 0, 0);
+ test("abcdefghij", 10, 0, "abcde", 0, 0);
+ test("abcdefghij", 10, 0, "abcde", 1, -1);
+ test("abcdefghij", 10, 0, "abcde", 2, -2);
+ test("abcdefghij", 10, 0, "abcde", 4, -4);
+ test("abcdefghij", 10, 0, "abcde", 5, -5);
+ test("abcdefghij", 10, 0, "abcdefghij", 0, 0);
+ test("abcdefghij", 10, 0, "abcdefghij", 1, -1);
+ test("abcdefghij", 10, 0, "abcdefghij", 5, -5);
+ test("abcdefghij", 10, 0, "abcdefghij", 9, -9);
+ test("abcdefghij", 10, 0, "abcdefghij", 10, -10);
+ test("abcdefghij", 10, 0, "abcdefghijklmnopqrst", 0, 0);
+ test("abcdefghij", 10, 0, "abcdefghijklmnopqrst", 1, -1);
+ test("abcdefghij", 10, 0, "abcdefghijklmnopqrst", 10, -10);
+ test("abcdefghij", 10, 0, "abcdefghijklmnopqrst", 19, -19);
+ test("abcdefghij", 10, 0, "abcdefghijklmnopqrst", 20, -20);
+ test("abcdefghij", 10, 1, "", 0, 0);
+ test("abcdefghij", 10, 1, "abcde", 0, 0);
+ test("abcdefghij", 10, 1, "abcde", 1, -1);
+ test("abcdefghij", 10, 1, "abcde", 2, -2);
+ test("abcdefghij", 10, 1, "abcde", 4, -4);
+ test("abcdefghij", 10, 1, "abcde", 5, -5);
+ test("abcdefghij", 10, 1, "abcdefghij", 0, 0);
+ test("abcdefghij", 10, 1, "abcdefghij", 1, -1);
+ test("abcdefghij", 10, 1, "abcdefghij", 5, -5);
+ test("abcdefghij", 10, 1, "abcdefghij", 9, -9);
+ test("abcdefghij", 10, 1, "abcdefghij", 10, -10);
+ test("abcdefghij", 10, 1, "abcdefghijklmnopqrst", 0, 0);
+ test("abcdefghij", 10, 1, "abcdefghijklmnopqrst", 1, -1);
+ test("abcdefghij", 10, 1, "abcdefghijklmnopqrst", 10, -10);
+ test("abcdefghij", 10, 1, "abcdefghijklmnopqrst", 19, -19);
+ test("abcdefghij", 10, 1, "abcdefghijklmnopqrst", 20, -20);
+ test("abcdefghij", 11, 0, "", 0, 0);
+ test("abcdefghij", 11, 0, "abcde", 0, 0);
+ test("abcdefghij", 11, 0, "abcde", 1, 0);
+ test("abcdefghij", 11, 0, "abcde", 2, 0);
+ test("abcdefghij", 11, 0, "abcde", 4, 0);
+ test("abcdefghij", 11, 0, "abcde", 5, 0);
+ test("abcdefghij", 11, 0, "abcdefghij", 0, 0);
+ test("abcdefghij", 11, 0, "abcdefghij", 1, 0);
+ test("abcdefghij", 11, 0, "abcdefghij", 5, 0);
+ test("abcdefghij", 11, 0, "abcdefghij", 9, 0);
+ test("abcdefghij", 11, 0, "abcdefghij", 10, 0);
+ test("abcdefghij", 11, 0, "abcdefghijklmnopqrst", 0, 0);
+ test("abcdefghij", 11, 0, "abcdefghijklmnopqrst", 1, 0);
+ test("abcdefghij", 11, 0, "abcdefghijklmnopqrst", 10, 0);
+ test("abcdefghij", 11, 0, "abcdefghijklmnopqrst", 19, 0);
+ test("abcdefghij", 11, 0, "abcdefghijklmnopqrst", 20, 0);
+}
+
+void test8()
+{
+ test("abcdefghijklmnopqrst", 0, 0, "", 0, 0);
+ test("abcdefghijklmnopqrst", 0, 0, "abcde", 0, 0);
+ test("abcdefghijklmnopqrst", 0, 0, "abcde", 1, -1);
+ test("abcdefghijklmnopqrst", 0, 0, "abcde", 2, -2);
+ test("abcdefghijklmnopqrst", 0, 0, "abcde", 4, -4);
+ test("abcdefghijklmnopqrst", 0, 0, "abcde", 5, -5);
+ test("abcdefghijklmnopqrst", 0, 0, "abcdefghij", 0, 0);
+ test("abcdefghijklmnopqrst", 0, 0, "abcdefghij", 1, -1);
+ test("abcdefghijklmnopqrst", 0, 0, "abcdefghij", 5, -5);
+ test("abcdefghijklmnopqrst", 0, 0, "abcdefghij", 9, -9);
+ test("abcdefghijklmnopqrst", 0, 0, "abcdefghij", 10, -10);
+ test("abcdefghijklmnopqrst", 0, 0, "abcdefghijklmnopqrst", 0, 0);
+ test("abcdefghijklmnopqrst", 0, 0, "abcdefghijklmnopqrst", 1, -1);
+ test("abcdefghijklmnopqrst", 0, 0, "abcdefghijklmnopqrst", 10, -10);
+ test("abcdefghijklmnopqrst", 0, 0, "abcdefghijklmnopqrst", 19, -19);
+ test("abcdefghijklmnopqrst", 0, 0, "abcdefghijklmnopqrst", 20, -20);
+ test("abcdefghijklmnopqrst", 0, 1, "", 0, 1);
+ test("abcdefghijklmnopqrst", 0, 1, "abcde", 0, 1);
+ test("abcdefghijklmnopqrst", 0, 1, "abcde", 1, 0);
+ test("abcdefghijklmnopqrst", 0, 1, "abcde", 2, -1);
+ test("abcdefghijklmnopqrst", 0, 1, "abcde", 4, -3);
+ test("abcdefghijklmnopqrst", 0, 1, "abcde", 5, -4);
+ test("abcdefghijklmnopqrst", 0, 1, "abcdefghij", 0, 1);
+ test("abcdefghijklmnopqrst", 0, 1, "abcdefghij", 1, 0);
+ test("abcdefghijklmnopqrst", 0, 1, "abcdefghij", 5, -4);
+ test("abcdefghijklmnopqrst", 0, 1, "abcdefghij", 9, -8);
+ test("abcdefghijklmnopqrst", 0, 1, "abcdefghij", 10, -9);
+ test("abcdefghijklmnopqrst", 0, 1, "abcdefghijklmnopqrst", 0, 1);
+ test("abcdefghijklmnopqrst", 0, 1, "abcdefghijklmnopqrst", 1, 0);
+ test("abcdefghijklmnopqrst", 0, 1, "abcdefghijklmnopqrst", 10, -9);
+ test("abcdefghijklmnopqrst", 0, 1, "abcdefghijklmnopqrst", 19, -18);
+ test("abcdefghijklmnopqrst", 0, 1, "abcdefghijklmnopqrst", 20, -19);
+ test("abcdefghijklmnopqrst", 0, 10, "", 0, 10);
+ test("abcdefghijklmnopqrst", 0, 10, "abcde", 0, 10);
+ test("abcdefghijklmnopqrst", 0, 10, "abcde", 1, 9);
+ test("abcdefghijklmnopqrst", 0, 10, "abcde", 2, 8);
+ test("abcdefghijklmnopqrst", 0, 10, "abcde", 4, 6);
+ test("abcdefghijklmnopqrst", 0, 10, "abcde", 5, 5);
+ test("abcdefghijklmnopqrst", 0, 10, "abcdefghij", 0, 10);
+ test("abcdefghijklmnopqrst", 0, 10, "abcdefghij", 1, 9);
+ test("abcdefghijklmnopqrst", 0, 10, "abcdefghij", 5, 5);
+ test("abcdefghijklmnopqrst", 0, 10, "abcdefghij", 9, 1);
+ test("abcdefghijklmnopqrst", 0, 10, "abcdefghij", 10, 0);
+ test("abcdefghijklmnopqrst", 0, 10, "abcdefghijklmnopqrst", 0, 10);
+ test("abcdefghijklmnopqrst", 0, 10, "abcdefghijklmnopqrst", 1, 9);
+ test("abcdefghijklmnopqrst", 0, 10, "abcdefghijklmnopqrst", 10, 0);
+ test("abcdefghijklmnopqrst", 0, 10, "abcdefghijklmnopqrst", 19, -9);
+ test("abcdefghijklmnopqrst", 0, 10, "abcdefghijklmnopqrst", 20, -10);
+ test("abcdefghijklmnopqrst", 0, 19, "", 0, 19);
+ test("abcdefghijklmnopqrst", 0, 19, "abcde", 0, 19);
+ test("abcdefghijklmnopqrst", 0, 19, "abcde", 1, 18);
+ test("abcdefghijklmnopqrst", 0, 19, "abcde", 2, 17);
+ test("abcdefghijklmnopqrst", 0, 19, "abcde", 4, 15);
+ test("abcdefghijklmnopqrst", 0, 19, "abcde", 5, 14);
+ test("abcdefghijklmnopqrst", 0, 19, "abcdefghij", 0, 19);
+ test("abcdefghijklmnopqrst", 0, 19, "abcdefghij", 1, 18);
+ test("abcdefghijklmnopqrst", 0, 19, "abcdefghij", 5, 14);
+ test("abcdefghijklmnopqrst", 0, 19, "abcdefghij", 9, 10);
+ test("abcdefghijklmnopqrst", 0, 19, "abcdefghij", 10, 9);
+ test("abcdefghijklmnopqrst", 0, 19, "abcdefghijklmnopqrst", 0, 19);
+ test("abcdefghijklmnopqrst", 0, 19, "abcdefghijklmnopqrst", 1, 18);
+ test("abcdefghijklmnopqrst", 0, 19, "abcdefghijklmnopqrst", 10, 9);
+ test("abcdefghijklmnopqrst", 0, 19, "abcdefghijklmnopqrst", 19, 0);
+ test("abcdefghijklmnopqrst", 0, 19, "abcdefghijklmnopqrst", 20, -1);
+ test("abcdefghijklmnopqrst", 0, 20, "", 0, 20);
+ test("abcdefghijklmnopqrst", 0, 20, "abcde", 0, 20);
+ test("abcdefghijklmnopqrst", 0, 20, "abcde", 1, 19);
+ test("abcdefghijklmnopqrst", 0, 20, "abcde", 2, 18);
+ test("abcdefghijklmnopqrst", 0, 20, "abcde", 4, 16);
+ test("abcdefghijklmnopqrst", 0, 20, "abcde", 5, 15);
+ test("abcdefghijklmnopqrst", 0, 20, "abcdefghij", 0, 20);
+ test("abcdefghijklmnopqrst", 0, 20, "abcdefghij", 1, 19);
+ test("abcdefghijklmnopqrst", 0, 20, "abcdefghij", 5, 15);
+ test("abcdefghijklmnopqrst", 0, 20, "abcdefghij", 9, 11);
+ test("abcdefghijklmnopqrst", 0, 20, "abcdefghij", 10, 10);
+ test("abcdefghijklmnopqrst", 0, 20, "abcdefghijklmnopqrst", 0, 20);
+ test("abcdefghijklmnopqrst", 0, 20, "abcdefghijklmnopqrst", 1, 19);
+ test("abcdefghijklmnopqrst", 0, 20, "abcdefghijklmnopqrst", 10, 10);
+ test("abcdefghijklmnopqrst", 0, 20, "abcdefghijklmnopqrst", 19, 1);
+ test("abcdefghijklmnopqrst", 0, 20, "abcdefghijklmnopqrst", 20, 0);
+ test("abcdefghijklmnopqrst", 0, 21, "", 0, 20);
+ test("abcdefghijklmnopqrst", 0, 21, "abcde", 0, 20);
+ test("abcdefghijklmnopqrst", 0, 21, "abcde", 1, 19);
+ test("abcdefghijklmnopqrst", 0, 21, "abcde", 2, 18);
+ test("abcdefghijklmnopqrst", 0, 21, "abcde", 4, 16);
+ test("abcdefghijklmnopqrst", 0, 21, "abcde", 5, 15);
+ test("abcdefghijklmnopqrst", 0, 21, "abcdefghij", 0, 20);
+ test("abcdefghijklmnopqrst", 0, 21, "abcdefghij", 1, 19);
+ test("abcdefghijklmnopqrst", 0, 21, "abcdefghij", 5, 15);
+ test("abcdefghijklmnopqrst", 0, 21, "abcdefghij", 9, 11);
+ test("abcdefghijklmnopqrst", 0, 21, "abcdefghij", 10, 10);
+ test("abcdefghijklmnopqrst", 0, 21, "abcdefghijklmnopqrst", 0, 20);
+ test("abcdefghijklmnopqrst", 0, 21, "abcdefghijklmnopqrst", 1, 19);
+ test("abcdefghijklmnopqrst", 0, 21, "abcdefghijklmnopqrst", 10, 10);
+ test("abcdefghijklmnopqrst", 0, 21, "abcdefghijklmnopqrst", 19, 1);
+ test("abcdefghijklmnopqrst", 0, 21, "abcdefghijklmnopqrst", 20, 0);
+ test("abcdefghijklmnopqrst", 1, 0, "", 0, 0);
+ test("abcdefghijklmnopqrst", 1, 0, "abcde", 0, 0);
+ test("abcdefghijklmnopqrst", 1, 0, "abcde", 1, -1);
+ test("abcdefghijklmnopqrst", 1, 0, "abcde", 2, -2);
+}
+
+
+void test9()
+{
+ test("abcdefghijklmnopqrst", 1, 0, "abcde", 4, -4);
+ test("abcdefghijklmnopqrst", 1, 0, "abcde", 5, -5);
+ test("abcdefghijklmnopqrst", 1, 0, "abcdefghij", 0, 0);
+ test("abcdefghijklmnopqrst", 1, 0, "abcdefghij", 1, -1);
+ test("abcdefghijklmnopqrst", 1, 0, "abcdefghij", 5, -5);
+ test("abcdefghijklmnopqrst", 1, 0, "abcdefghij", 9, -9);
+ test("abcdefghijklmnopqrst", 1, 0, "abcdefghij", 10, -10);
+ test("abcdefghijklmnopqrst", 1, 0, "abcdefghijklmnopqrst", 0, 0);
+ test("abcdefghijklmnopqrst", 1, 0, "abcdefghijklmnopqrst", 1, -1);
+ test("abcdefghijklmnopqrst", 1, 0, "abcdefghijklmnopqrst", 10, -10);
+ test("abcdefghijklmnopqrst", 1, 0, "abcdefghijklmnopqrst", 19, -19);
+ test("abcdefghijklmnopqrst", 1, 0, "abcdefghijklmnopqrst", 20, -20);
+ test("abcdefghijklmnopqrst", 1, 1, "", 0, 1);
+ test("abcdefghijklmnopqrst", 1, 1, "abcde", 0, 1);
+ test("abcdefghijklmnopqrst", 1, 1, "abcde", 1, 1);
+ test("abcdefghijklmnopqrst", 1, 1, "abcde", 2, 1);
+ test("abcdefghijklmnopqrst", 1, 1, "abcde", 4, 1);
+ test("abcdefghijklmnopqrst", 1, 1, "abcde", 5, 1);
+ test("abcdefghijklmnopqrst", 1, 1, "abcdefghij", 0, 1);
+ test("abcdefghijklmnopqrst", 1, 1, "abcdefghij", 1, 1);
+ test("abcdefghijklmnopqrst", 1, 1, "abcdefghij", 5, 1);
+ test("abcdefghijklmnopqrst", 1, 1, "abcdefghij", 9, 1);
+ test("abcdefghijklmnopqrst", 1, 1, "abcdefghij", 10, 1);
+ test("abcdefghijklmnopqrst", 1, 1, "abcdefghijklmnopqrst", 0, 1);
+ test("abcdefghijklmnopqrst", 1, 1, "abcdefghijklmnopqrst", 1, 1);
+ test("abcdefghijklmnopqrst", 1, 1, "abcdefghijklmnopqrst", 10, 1);
+ test("abcdefghijklmnopqrst", 1, 1, "abcdefghijklmnopqrst", 19, 1);
+ test("abcdefghijklmnopqrst", 1, 1, "abcdefghijklmnopqrst", 20, 1);
+ test("abcdefghijklmnopqrst", 1, 9, "", 0, 9);
+ test("abcdefghijklmnopqrst", 1, 9, "abcde", 0, 9);
+ test("abcdefghijklmnopqrst", 1, 9, "abcde", 1, 1);
+ test("abcdefghijklmnopqrst", 1, 9, "abcde", 2, 1);
+ test("abcdefghijklmnopqrst", 1, 9, "abcde", 4, 1);
+ test("abcdefghijklmnopqrst", 1, 9, "abcde", 5, 1);
+ test("abcdefghijklmnopqrst", 1, 9, "abcdefghij", 0, 9);
+ test("abcdefghijklmnopqrst", 1, 9, "abcdefghij", 1, 1);
+ test("abcdefghijklmnopqrst", 1, 9, "abcdefghij", 5, 1);
+ test("abcdefghijklmnopqrst", 1, 9, "abcdefghij", 9, 1);
+ test("abcdefghijklmnopqrst", 1, 9, "abcdefghij", 10, 1);
+ test("abcdefghijklmnopqrst", 1, 9, "abcdefghijklmnopqrst", 0, 9);
+ test("abcdefghijklmnopqrst", 1, 9, "abcdefghijklmnopqrst", 1, 1);
+ test("abcdefghijklmnopqrst", 1, 9, "abcdefghijklmnopqrst", 10, 1);
+ test("abcdefghijklmnopqrst", 1, 9, "abcdefghijklmnopqrst", 19, 1);
+ test("abcdefghijklmnopqrst", 1, 9, "abcdefghijklmnopqrst", 20, 1);
+ test("abcdefghijklmnopqrst", 1, 18, "", 0, 18);
+ test("abcdefghijklmnopqrst", 1, 18, "abcde", 0, 18);
+ test("abcdefghijklmnopqrst", 1, 18, "abcde", 1, 1);
+ test("abcdefghijklmnopqrst", 1, 18, "abcde", 2, 1);
+ test("abcdefghijklmnopqrst", 1, 18, "abcde", 4, 1);
+ test("abcdefghijklmnopqrst", 1, 18, "abcde", 5, 1);
+ test("abcdefghijklmnopqrst", 1, 18, "abcdefghij", 0, 18);
+ test("abcdefghijklmnopqrst", 1, 18, "abcdefghij", 1, 1);
+ test("abcdefghijklmnopqrst", 1, 18, "abcdefghij", 5, 1);
+ test("abcdefghijklmnopqrst", 1, 18, "abcdefghij", 9, 1);
+ test("abcdefghijklmnopqrst", 1, 18, "abcdefghij", 10, 1);
+ test("abcdefghijklmnopqrst", 1, 18, "abcdefghijklmnopqrst", 0, 18);
+ test("abcdefghijklmnopqrst", 1, 18, "abcdefghijklmnopqrst", 1, 1);
+ test("abcdefghijklmnopqrst", 1, 18, "abcdefghijklmnopqrst", 10, 1);
+ test("abcdefghijklmnopqrst", 1, 18, "abcdefghijklmnopqrst", 19, 1);
+ test("abcdefghijklmnopqrst", 1, 18, "abcdefghijklmnopqrst", 20, 1);
+ test("abcdefghijklmnopqrst", 1, 19, "", 0, 19);
+ test("abcdefghijklmnopqrst", 1, 19, "abcde", 0, 19);
+ test("abcdefghijklmnopqrst", 1, 19, "abcde", 1, 1);
+ test("abcdefghijklmnopqrst", 1, 19, "abcde", 2, 1);
+ test("abcdefghijklmnopqrst", 1, 19, "abcde", 4, 1);
+ test("abcdefghijklmnopqrst", 1, 19, "abcde", 5, 1);
+ test("abcdefghijklmnopqrst", 1, 19, "abcdefghij", 0, 19);
+ test("abcdefghijklmnopqrst", 1, 19, "abcdefghij", 1, 1);
+ test("abcdefghijklmnopqrst", 1, 19, "abcdefghij", 5, 1);
+ test("abcdefghijklmnopqrst", 1, 19, "abcdefghij", 9, 1);
+ test("abcdefghijklmnopqrst", 1, 19, "abcdefghij", 10, 1);
+ test("abcdefghijklmnopqrst", 1, 19, "abcdefghijklmnopqrst", 0, 19);
+ test("abcdefghijklmnopqrst", 1, 19, "abcdefghijklmnopqrst", 1, 1);
+ test("abcdefghijklmnopqrst", 1, 19, "abcdefghijklmnopqrst", 10, 1);
+ test("abcdefghijklmnopqrst", 1, 19, "abcdefghijklmnopqrst", 19, 1);
+ test("abcdefghijklmnopqrst", 1, 19, "abcdefghijklmnopqrst", 20, 1);
+ test("abcdefghijklmnopqrst", 1, 20, "", 0, 19);
+ test("abcdefghijklmnopqrst", 1, 20, "abcde", 0, 19);
+ test("abcdefghijklmnopqrst", 1, 20, "abcde", 1, 1);
+ test("abcdefghijklmnopqrst", 1, 20, "abcde", 2, 1);
+ test("abcdefghijklmnopqrst", 1, 20, "abcde", 4, 1);
+ test("abcdefghijklmnopqrst", 1, 20, "abcde", 5, 1);
+ test("abcdefghijklmnopqrst", 1, 20, "abcdefghij", 0, 19);
+ test("abcdefghijklmnopqrst", 1, 20, "abcdefghij", 1, 1);
+ test("abcdefghijklmnopqrst", 1, 20, "abcdefghij", 5, 1);
+ test("abcdefghijklmnopqrst", 1, 20, "abcdefghij", 9, 1);
+ test("abcdefghijklmnopqrst", 1, 20, "abcdefghij", 10, 1);
+ test("abcdefghijklmnopqrst", 1, 20, "abcdefghijklmnopqrst", 0, 19);
+ test("abcdefghijklmnopqrst", 1, 20, "abcdefghijklmnopqrst", 1, 1);
+ test("abcdefghijklmnopqrst", 1, 20, "abcdefghijklmnopqrst", 10, 1);
+ test("abcdefghijklmnopqrst", 1, 20, "abcdefghijklmnopqrst", 19, 1);
+ test("abcdefghijklmnopqrst", 1, 20, "abcdefghijklmnopqrst", 20, 1);
+ test("abcdefghijklmnopqrst", 10, 0, "", 0, 0);
+ test("abcdefghijklmnopqrst", 10, 0, "abcde", 0, 0);
+ test("abcdefghijklmnopqrst", 10, 0, "abcde", 1, -1);
+ test("abcdefghijklmnopqrst", 10, 0, "abcde", 2, -2);
+ test("abcdefghijklmnopqrst", 10, 0, "abcde", 4, -4);
+ test("abcdefghijklmnopqrst", 10, 0, "abcde", 5, -5);
+ test("abcdefghijklmnopqrst", 10, 0, "abcdefghij", 0, 0);
+ test("abcdefghijklmnopqrst", 10, 0, "abcdefghij", 1, -1);
+}
+
+
+void test10()
+{
+ test("abcdefghijklmnopqrst", 10, 0, "abcdefghij", 5, -5);
+ test("abcdefghijklmnopqrst", 10, 0, "abcdefghij", 9, -9);
+ test("abcdefghijklmnopqrst", 10, 0, "abcdefghij", 10, -10);
+ test("abcdefghijklmnopqrst", 10, 0, "abcdefghijklmnopqrst", 0, 0);
+ test("abcdefghijklmnopqrst", 10, 0, "abcdefghijklmnopqrst", 1, -1);
+ test("abcdefghijklmnopqrst", 10, 0, "abcdefghijklmnopqrst", 10, -10);
+ test("abcdefghijklmnopqrst", 10, 0, "abcdefghijklmnopqrst", 19, -19);
+ test("abcdefghijklmnopqrst", 10, 0, "abcdefghijklmnopqrst", 20, -20);
+ test("abcdefghijklmnopqrst", 10, 1, "", 0, 1);
+ test("abcdefghijklmnopqrst", 10, 1, "abcde", 0, 1);
+ test("abcdefghijklmnopqrst", 10, 1, "abcde", 1, 10);
+ test("abcdefghijklmnopqrst", 10, 1, "abcde", 2, 10);
+ test("abcdefghijklmnopqrst", 10, 1, "abcde", 4, 10);
+ test("abcdefghijklmnopqrst", 10, 1, "abcde", 5, 10);
+ test("abcdefghijklmnopqrst", 10, 1, "abcdefghij", 0, 1);
+ test("abcdefghijklmnopqrst", 10, 1, "abcdefghij", 1, 10);
+ test("abcdefghijklmnopqrst", 10, 1, "abcdefghij", 5, 10);
+ test("abcdefghijklmnopqrst", 10, 1, "abcdefghij", 9, 10);
+ test("abcdefghijklmnopqrst", 10, 1, "abcdefghij", 10, 10);
+ test("abcdefghijklmnopqrst", 10, 1, "abcdefghijklmnopqrst", 0, 1);
+ test("abcdefghijklmnopqrst", 10, 1, "abcdefghijklmnopqrst", 1, 10);
+ test("abcdefghijklmnopqrst", 10, 1, "abcdefghijklmnopqrst", 10, 10);
+ test("abcdefghijklmnopqrst", 10, 1, "abcdefghijklmnopqrst", 19, 10);
+ test("abcdefghijklmnopqrst", 10, 1, "abcdefghijklmnopqrst", 20, 10);
+ test("abcdefghijklmnopqrst", 10, 5, "", 0, 5);
+ test("abcdefghijklmnopqrst", 10, 5, "abcde", 0, 5);
+ test("abcdefghijklmnopqrst", 10, 5, "abcde", 1, 10);
+ test("abcdefghijklmnopqrst", 10, 5, "abcde", 2, 10);
+ test("abcdefghijklmnopqrst", 10, 5, "abcde", 4, 10);
+ test("abcdefghijklmnopqrst", 10, 5, "abcde", 5, 10);
+ test("abcdefghijklmnopqrst", 10, 5, "abcdefghij", 0, 5);
+ test("abcdefghijklmnopqrst", 10, 5, "abcdefghij", 1, 10);
+ test("abcdefghijklmnopqrst", 10, 5, "abcdefghij", 5, 10);
+ test("abcdefghijklmnopqrst", 10, 5, "abcdefghij", 9, 10);
+ test("abcdefghijklmnopqrst", 10, 5, "abcdefghij", 10, 10);
+ test("abcdefghijklmnopqrst", 10, 5, "abcdefghijklmnopqrst", 0, 5);
+ test("abcdefghijklmnopqrst", 10, 5, "abcdefghijklmnopqrst", 1, 10);
+ test("abcdefghijklmnopqrst", 10, 5, "abcdefghijklmnopqrst", 10, 10);
+ test("abcdefghijklmnopqrst", 10, 5, "abcdefghijklmnopqrst", 19, 10);
+ test("abcdefghijklmnopqrst", 10, 5, "abcdefghijklmnopqrst", 20, 10);
+ test("abcdefghijklmnopqrst", 10, 9, "", 0, 9);
+ test("abcdefghijklmnopqrst", 10, 9, "abcde", 0, 9);
+ test("abcdefghijklmnopqrst", 10, 9, "abcde", 1, 10);
+ test("abcdefghijklmnopqrst", 10, 9, "abcde", 2, 10);
+ test("abcdefghijklmnopqrst", 10, 9, "abcde", 4, 10);
+ test("abcdefghijklmnopqrst", 10, 9, "abcde", 5, 10);
+ test("abcdefghijklmnopqrst", 10, 9, "abcdefghij", 0, 9);
+ test("abcdefghijklmnopqrst", 10, 9, "abcdefghij", 1, 10);
+ test("abcdefghijklmnopqrst", 10, 9, "abcdefghij", 5, 10);
+ test("abcdefghijklmnopqrst", 10, 9, "abcdefghij", 9, 10);
+ test("abcdefghijklmnopqrst", 10, 9, "abcdefghij", 10, 10);
+ test("abcdefghijklmnopqrst", 10, 9, "abcdefghijklmnopqrst", 0, 9);
+ test("abcdefghijklmnopqrst", 10, 9, "abcdefghijklmnopqrst", 1, 10);
+ test("abcdefghijklmnopqrst", 10, 9, "abcdefghijklmnopqrst", 10, 10);
+ test("abcdefghijklmnopqrst", 10, 9, "abcdefghijklmnopqrst", 19, 10);
+ test("abcdefghijklmnopqrst", 10, 9, "abcdefghijklmnopqrst", 20, 10);
+ test("abcdefghijklmnopqrst", 10, 10, "", 0, 10);
+ test("abcdefghijklmnopqrst", 10, 10, "abcde", 0, 10);
+ test("abcdefghijklmnopqrst", 10, 10, "abcde", 1, 10);
+ test("abcdefghijklmnopqrst", 10, 10, "abcde", 2, 10);
+ test("abcdefghijklmnopqrst", 10, 10, "abcde", 4, 10);
+ test("abcdefghijklmnopqrst", 10, 10, "abcde", 5, 10);
+ test("abcdefghijklmnopqrst", 10, 10, "abcdefghij", 0, 10);
+ test("abcdefghijklmnopqrst", 10, 10, "abcdefghij", 1, 10);
+ test("abcdefghijklmnopqrst", 10, 10, "abcdefghij", 5, 10);
+ test("abcdefghijklmnopqrst", 10, 10, "abcdefghij", 9, 10);
+ test("abcdefghijklmnopqrst", 10, 10, "abcdefghij", 10, 10);
+ test("abcdefghijklmnopqrst", 10, 10, "abcdefghijklmnopqrst", 0, 10);
+ test("abcdefghijklmnopqrst", 10, 10, "abcdefghijklmnopqrst", 1, 10);
+ test("abcdefghijklmnopqrst", 10, 10, "abcdefghijklmnopqrst", 10, 10);
+ test("abcdefghijklmnopqrst", 10, 10, "abcdefghijklmnopqrst", 19, 10);
+ test("abcdefghijklmnopqrst", 10, 10, "abcdefghijklmnopqrst", 20, 10);
+ test("abcdefghijklmnopqrst", 10, 11, "", 0, 10);
+ test("abcdefghijklmnopqrst", 10, 11, "abcde", 0, 10);
+ test("abcdefghijklmnopqrst", 10, 11, "abcde", 1, 10);
+ test("abcdefghijklmnopqrst", 10, 11, "abcde", 2, 10);
+ test("abcdefghijklmnopqrst", 10, 11, "abcde", 4, 10);
+ test("abcdefghijklmnopqrst", 10, 11, "abcde", 5, 10);
+ test("abcdefghijklmnopqrst", 10, 11, "abcdefghij", 0, 10);
+ test("abcdefghijklmnopqrst", 10, 11, "abcdefghij", 1, 10);
+ test("abcdefghijklmnopqrst", 10, 11, "abcdefghij", 5, 10);
+ test("abcdefghijklmnopqrst", 10, 11, "abcdefghij", 9, 10);
+ test("abcdefghijklmnopqrst", 10, 11, "abcdefghij", 10, 10);
+ test("abcdefghijklmnopqrst", 10, 11, "abcdefghijklmnopqrst", 0, 10);
+ test("abcdefghijklmnopqrst", 10, 11, "abcdefghijklmnopqrst", 1, 10);
+ test("abcdefghijklmnopqrst", 10, 11, "abcdefghijklmnopqrst", 10, 10);
+ test("abcdefghijklmnopqrst", 10, 11, "abcdefghijklmnopqrst", 19, 10);
+ test("abcdefghijklmnopqrst", 10, 11, "abcdefghijklmnopqrst", 20, 10);
+ test("abcdefghijklmnopqrst", 19, 0, "", 0, 0);
+ test("abcdefghijklmnopqrst", 19, 0, "abcde", 0, 0);
+ test("abcdefghijklmnopqrst", 19, 0, "abcde", 1, -1);
+ test("abcdefghijklmnopqrst", 19, 0, "abcde", 2, -2);
+ test("abcdefghijklmnopqrst", 19, 0, "abcde", 4, -4);
+ test("abcdefghijklmnopqrst", 19, 0, "abcde", 5, -5);
+ test("abcdefghijklmnopqrst", 19, 0, "abcdefghij", 0, 0);
+ test("abcdefghijklmnopqrst", 19, 0, "abcdefghij", 1, -1);
+ test("abcdefghijklmnopqrst", 19, 0, "abcdefghij", 5, -5);
+ test("abcdefghijklmnopqrst", 19, 0, "abcdefghij", 9, -9);
+ test("abcdefghijklmnopqrst", 19, 0, "abcdefghij", 10, -10);
+ test("abcdefghijklmnopqrst", 19, 0, "abcdefghijklmnopqrst", 0, 0);
+}
+
+
+void test11()
+{
+ test("abcdefghijklmnopqrst", 19, 0, "abcdefghijklmnopqrst", 1, -1);
+ test("abcdefghijklmnopqrst", 19, 0, "abcdefghijklmnopqrst", 10, -10);
+ test("abcdefghijklmnopqrst", 19, 0, "abcdefghijklmnopqrst", 19, -19);
+ test("abcdefghijklmnopqrst", 19, 0, "abcdefghijklmnopqrst", 20, -20);
+ test("abcdefghijklmnopqrst", 19, 1, "", 0, 1);
+ test("abcdefghijklmnopqrst", 19, 1, "abcde", 0, 1);
+ test("abcdefghijklmnopqrst", 19, 1, "abcde", 1, 19);
+ test("abcdefghijklmnopqrst", 19, 1, "abcde", 2, 19);
+ test("abcdefghijklmnopqrst", 19, 1, "abcde", 4, 19);
+ test("abcdefghijklmnopqrst", 19, 1, "abcde", 5, 19);
+ test("abcdefghijklmnopqrst", 19, 1, "abcdefghij", 0, 1);
+ test("abcdefghijklmnopqrst", 19, 1, "abcdefghij", 1, 19);
+ test("abcdefghijklmnopqrst", 19, 1, "abcdefghij", 5, 19);
+ test("abcdefghijklmnopqrst", 19, 1, "abcdefghij", 9, 19);
+ test("abcdefghijklmnopqrst", 19, 1, "abcdefghij", 10, 19);
+ test("abcdefghijklmnopqrst", 19, 1, "abcdefghijklmnopqrst", 0, 1);
+ test("abcdefghijklmnopqrst", 19, 1, "abcdefghijklmnopqrst", 1, 19);
+ test("abcdefghijklmnopqrst", 19, 1, "abcdefghijklmnopqrst", 10, 19);
+ test("abcdefghijklmnopqrst", 19, 1, "abcdefghijklmnopqrst", 19, 19);
+ test("abcdefghijklmnopqrst", 19, 1, "abcdefghijklmnopqrst", 20, 19);
+ test("abcdefghijklmnopqrst", 19, 2, "", 0, 1);
+ test("abcdefghijklmnopqrst", 19, 2, "abcde", 0, 1);
+ test("abcdefghijklmnopqrst", 19, 2, "abcde", 1, 19);
+ test("abcdefghijklmnopqrst", 19, 2, "abcde", 2, 19);
+ test("abcdefghijklmnopqrst", 19, 2, "abcde", 4, 19);
+ test("abcdefghijklmnopqrst", 19, 2, "abcde", 5, 19);
+ test("abcdefghijklmnopqrst", 19, 2, "abcdefghij", 0, 1);
+ test("abcdefghijklmnopqrst", 19, 2, "abcdefghij", 1, 19);
+ test("abcdefghijklmnopqrst", 19, 2, "abcdefghij", 5, 19);
+ test("abcdefghijklmnopqrst", 19, 2, "abcdefghij", 9, 19);
+ test("abcdefghijklmnopqrst", 19, 2, "abcdefghij", 10, 19);
+ test("abcdefghijklmnopqrst", 19, 2, "abcdefghijklmnopqrst", 0, 1);
+ test("abcdefghijklmnopqrst", 19, 2, "abcdefghijklmnopqrst", 1, 19);
+ test("abcdefghijklmnopqrst", 19, 2, "abcdefghijklmnopqrst", 10, 19);
+ test("abcdefghijklmnopqrst", 19, 2, "abcdefghijklmnopqrst", 19, 19);
+ test("abcdefghijklmnopqrst", 19, 2, "abcdefghijklmnopqrst", 20, 19);
+ test("abcdefghijklmnopqrst", 20, 0, "", 0, 0);
+ test("abcdefghijklmnopqrst", 20, 0, "abcde", 0, 0);
+ test("abcdefghijklmnopqrst", 20, 0, "abcde", 1, -1);
+ test("abcdefghijklmnopqrst", 20, 0, "abcde", 2, -2);
+ test("abcdefghijklmnopqrst", 20, 0, "abcde", 4, -4);
+ test("abcdefghijklmnopqrst", 20, 0, "abcde", 5, -5);
+ test("abcdefghijklmnopqrst", 20, 0, "abcdefghij", 0, 0);
+ test("abcdefghijklmnopqrst", 20, 0, "abcdefghij", 1, -1);
+ test("abcdefghijklmnopqrst", 20, 0, "abcdefghij", 5, -5);
+ test("abcdefghijklmnopqrst", 20, 0, "abcdefghij", 9, -9);
+ test("abcdefghijklmnopqrst", 20, 0, "abcdefghij", 10, -10);
+ test("abcdefghijklmnopqrst", 20, 0, "abcdefghijklmnopqrst", 0, 0);
+ test("abcdefghijklmnopqrst", 20, 0, "abcdefghijklmnopqrst", 1, -1);
+ test("abcdefghijklmnopqrst", 20, 0, "abcdefghijklmnopqrst", 10, -10);
+ test("abcdefghijklmnopqrst", 20, 0, "abcdefghijklmnopqrst", 19, -19);
+ test("abcdefghijklmnopqrst", 20, 0, "abcdefghijklmnopqrst", 20, -20);
+ test("abcdefghijklmnopqrst", 20, 1, "", 0, 0);
+ test("abcdefghijklmnopqrst", 20, 1, "abcde", 0, 0);
+ test("abcdefghijklmnopqrst", 20, 1, "abcde", 1, -1);
+ test("abcdefghijklmnopqrst", 20, 1, "abcde", 2, -2);
+ test("abcdefghijklmnopqrst", 20, 1, "abcde", 4, -4);
+ test("abcdefghijklmnopqrst", 20, 1, "abcde", 5, -5);
+ test("abcdefghijklmnopqrst", 20, 1, "abcdefghij", 0, 0);
+ test("abcdefghijklmnopqrst", 20, 1, "abcdefghij", 1, -1);
+ test("abcdefghijklmnopqrst", 20, 1, "abcdefghij", 5, -5);
+ test("abcdefghijklmnopqrst", 20, 1, "abcdefghij", 9, -9);
+ test("abcdefghijklmnopqrst", 20, 1, "abcdefghij", 10, -10);
+ test("abcdefghijklmnopqrst", 20, 1, "abcdefghijklmnopqrst", 0, 0);
+ test("abcdefghijklmnopqrst", 20, 1, "abcdefghijklmnopqrst", 1, -1);
+ test("abcdefghijklmnopqrst", 20, 1, "abcdefghijklmnopqrst", 10, -10);
+ test("abcdefghijklmnopqrst", 20, 1, "abcdefghijklmnopqrst", 19, -19);
+ test("abcdefghijklmnopqrst", 20, 1, "abcdefghijklmnopqrst", 20, -20);
+ test("abcdefghijklmnopqrst", 21, 0, "", 0, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcde", 0, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcde", 1, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcde", 2, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcde", 4, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcde", 5, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcdefghij", 0, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcdefghij", 1, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcdefghij", 5, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcdefghij", 9, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcdefghij", 10, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcdefghijklmnopqrst", 0, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcdefghijklmnopqrst", 1, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcdefghijklmnopqrst", 10, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcdefghijklmnopqrst", 19, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcdefghijklmnopqrst", 20, 0);
+ }
+
+
+int main () {
+ test0();
+ test1();
+ test2();
+ test3();
+ test4();
+ test5();
+ test6();
+ test7();
+ test8();
+ test9();
+ test10();
+ test11();
+
+ {
+ test("", 0, 0, "abcde", 0, 0);
+ test("", 0, 0, "abcde", 1, -1);
+ test("abcdefghijklmnopqrst", 21, 0, "abcde", 0, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcde", 1, 0);
+ test("abcdefghijklmnopqrst", 10, 0, "abcdefghij", 10, -10);
+ }
+
+ {
+ test(L"", 0, 0, L"abcde", 0, 0);
+ test(L"", 0, 0, L"abcde", 1, -1);
+ test(L"abcdefghijklmnopqrst", 21, 0, L"abcde", 0, 0);
+ test(L"abcdefghijklmnopqrst", 21, 0, L"abcde", 1, 0);
+ test(L"abcdefghijklmnopqrst", 10, 0, L"abcdefghij", 10, -10);
+ }
+
+#if __cplusplus >= 201103L
+ {
+ test(U"", 0, 0, U"abcde", 0, 0);
+ test(U"", 0, 0, U"abcde", 1, -1);
+ test(U"abcdefghijklmnopqrst", 21, 0, U"abcde", 0, 0);
+ test(U"abcdefghijklmnopqrst", 21, 0, U"abcde", 1, 0);
+ test(U"abcdefghijklmnopqrst", 10, 0, U"abcdefghij", 10, -10);
+ }
+
+ {
+ test(U"", 0, 0, U"abcde", 0, 0);
+ test(U"", 0, 0, U"abcde", 1, -1);
+ test(U"abcdefghijklmnopqrst", 21, 0, U"abcde", 0, 0);
+ test(U"abcdefghijklmnopqrst", 21, 0, U"abcde", 1, 0);
+ test(U"abcdefghijklmnopqrst", 10, 0, U"abcdefghij", 10, -10);
+ }
+#endif
+
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::experimental::basic_string_view<char, constexpr_char_traits<char>> SV;
+ constexpr SV sv1;
+ constexpr SV sv2 { "abcdefghijklmnopqrst", 21 };
+ static_assert ( sv1.compare(0, 0, "abcde", 0) == 0, "" );
+ static_assert ( sv1.compare(0, 0, "abcde", 1) == -1, "" );
+ static_assert ( sv2.compare(0, 0, "abcde", 1, 0) == 0, "" );
+ }
+#endif
+}
diff --git a/test/std/experimental/string.view/string.view.ops/compare.size_size_sv_size_size.pass.cpp b/test/std/experimental/string.view/string.view.ops/compare.size_size_sv_size_size.pass.cpp
new file mode 100644
index 000000000000..33407ef0747e
--- /dev/null
+++ b/test/std/experimental/string.view/string.view.ops/compare.size_size_sv_size_size.pass.cpp
@@ -0,0 +1,5843 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+
+// <string_view>
+
+// constexpr int compare(size_type pos1, size_type n1, basic_string_view str,
+// size_type pos2, size_type n2) const;
+
+#include <experimental/string_view>
+#include <cassert>
+
+#include "constexpr_char_traits.hpp"
+
+int sign ( int x ) { return x > 0 ? 1 : ( x < 0 ? -1 : 0 ); }
+
+template<typename CharT>
+void test1 ( std::experimental::basic_string_view<CharT> sv1, size_t pos1, size_t n1,
+ std::experimental::basic_string_view<CharT> sv2, size_t pos2, size_t n2,
+ int expected ) {
+
+ try
+ {
+ assert ( sign( sv1.compare(pos1, n1, sv2, pos2, n2)) == sign(expected));
+ assert(pos1 <= sv1.size());
+ assert(pos2 <= sv2.size());
+ }
+ catch (const std::out_of_range&) { assert(pos1 > sv1.size() || pos2 > sv2.size()); }
+}
+
+
+template<typename CharT>
+void test ( const CharT *s1, size_t pos1, size_t n1,
+ const CharT *s2, size_t pos2, size_t n2,
+ int expected ) {
+ typedef std::experimental::basic_string_view<CharT> string_view_t;
+
+ string_view_t sv1 ( s1 );
+ string_view_t sv2 ( s2 );
+ test1(sv1, pos1, n1, sv2, pos2, n2, expected);
+}
+
+void test0()
+{
+ test("", 0, 0, "", 0, 0, 0);
+ test("", 0, 0, "", 0, 1, 0);
+ test("", 0, 0, "", 1, 0, 0);
+ test("", 0, 0, "abcde", 0, 0, 0);
+ test("", 0, 0, "abcde", 0, 1, -1);
+ test("", 0, 0, "abcde", 0, 2, -2);
+ test("", 0, 0, "abcde", 0, 4, -4);
+ test("", 0, 0, "abcde", 0, 5, -5);
+ test("", 0, 0, "abcde", 0, 6, -5);
+ test("", 0, 0, "abcde", 1, 0, 0);
+ test("", 0, 0, "abcde", 1, 1, -1);
+ test("", 0, 0, "abcde", 1, 2, -2);
+ test("", 0, 0, "abcde", 1, 3, -3);
+ test("", 0, 0, "abcde", 1, 4, -4);
+ test("", 0, 0, "abcde", 1, 5, -4);
+ test("", 0, 0, "abcde", 2, 0, 0);
+ test("", 0, 0, "abcde", 2, 1, -1);
+ test("", 0, 0, "abcde", 2, 2, -2);
+ test("", 0, 0, "abcde", 2, 3, -3);
+ test("", 0, 0, "abcde", 2, 4, -3);
+ test("", 0, 0, "abcde", 4, 0, 0);
+ test("", 0, 0, "abcde", 4, 1, -1);
+ test("", 0, 0, "abcde", 4, 2, -1);
+ test("", 0, 0, "abcde", 5, 0, 0);
+ test("", 0, 0, "abcde", 5, 1, 0);
+ test("", 0, 0, "abcde", 6, 0, 0);
+ test("", 0, 0, "abcdefghij", 0, 0, 0);
+ test("", 0, 0, "abcdefghij", 0, 1, -1);
+ test("", 0, 0, "abcdefghij", 0, 5, -5);
+ test("", 0, 0, "abcdefghij", 0, 9, -9);
+ test("", 0, 0, "abcdefghij", 0, 10, -10);
+ test("", 0, 0, "abcdefghij", 0, 11, -10);
+ test("", 0, 0, "abcdefghij", 1, 0, 0);
+ test("", 0, 0, "abcdefghij", 1, 1, -1);
+ test("", 0, 0, "abcdefghij", 1, 4, -4);
+ test("", 0, 0, "abcdefghij", 1, 8, -8);
+ test("", 0, 0, "abcdefghij", 1, 9, -9);
+ test("", 0, 0, "abcdefghij", 1, 10, -9);
+ test("", 0, 0, "abcdefghij", 5, 0, 0);
+ test("", 0, 0, "abcdefghij", 5, 1, -1);
+ test("", 0, 0, "abcdefghij", 5, 2, -2);
+ test("", 0, 0, "abcdefghij", 5, 4, -4);
+ test("", 0, 0, "abcdefghij", 5, 5, -5);
+ test("", 0, 0, "abcdefghij", 5, 6, -5);
+ test("", 0, 0, "abcdefghij", 9, 0, 0);
+ test("", 0, 0, "abcdefghij", 9, 1, -1);
+ test("", 0, 0, "abcdefghij", 9, 2, -1);
+ test("", 0, 0, "abcdefghij", 10, 0, 0);
+ test("", 0, 0, "abcdefghij", 10, 1, 0);
+ test("", 0, 0, "abcdefghij", 11, 0, 0);
+ test("", 0, 0, "abcdefghijklmnopqrst", 0, 0, 0);
+ test("", 0, 0, "abcdefghijklmnopqrst", 0, 1, -1);
+ test("", 0, 0, "abcdefghijklmnopqrst", 0, 10, -10);
+ test("", 0, 0, "abcdefghijklmnopqrst", 0, 19, -19);
+ test("", 0, 0, "abcdefghijklmnopqrst", 0, 20, -20);
+ test("", 0, 0, "abcdefghijklmnopqrst", 0, 21, -20);
+ test("", 0, 0, "abcdefghijklmnopqrst", 1, 0, 0);
+ test("", 0, 0, "abcdefghijklmnopqrst", 1, 1, -1);
+ test("", 0, 0, "abcdefghijklmnopqrst", 1, 9, -9);
+ test("", 0, 0, "abcdefghijklmnopqrst", 1, 18, -18);
+ test("", 0, 0, "abcdefghijklmnopqrst", 1, 19, -19);
+ test("", 0, 0, "abcdefghijklmnopqrst", 1, 20, -19);
+ test("", 0, 0, "abcdefghijklmnopqrst", 10, 0, 0);
+ test("", 0, 0, "abcdefghijklmnopqrst", 10, 1, -1);
+ test("", 0, 0, "abcdefghijklmnopqrst", 10, 5, -5);
+ test("", 0, 0, "abcdefghijklmnopqrst", 10, 9, -9);
+ test("", 0, 0, "abcdefghijklmnopqrst", 10, 10, -10);
+ test("", 0, 0, "abcdefghijklmnopqrst", 10, 11, -10);
+ test("", 0, 0, "abcdefghijklmnopqrst", 19, 0, 0);
+ test("", 0, 0, "abcdefghijklmnopqrst", 19, 1, -1);
+ test("", 0, 0, "abcdefghijklmnopqrst", 19, 2, -1);
+ test("", 0, 0, "abcdefghijklmnopqrst", 20, 0, 0);
+ test("", 0, 0, "abcdefghijklmnopqrst", 20, 1, 0);
+ test("", 0, 0, "abcdefghijklmnopqrst", 21, 0, 0);
+ test("", 0, 1, "", 0, 0, 0);
+ test("", 0, 1, "", 0, 1, 0);
+ test("", 0, 1, "", 1, 0, 0);
+ test("", 0, 1, "abcde", 0, 0, 0);
+ test("", 0, 1, "abcde", 0, 1, -1);
+ test("", 0, 1, "abcde", 0, 2, -2);
+ test("", 0, 1, "abcde", 0, 4, -4);
+ test("", 0, 1, "abcde", 0, 5, -5);
+ test("", 0, 1, "abcde", 0, 6, -5);
+ test("", 0, 1, "abcde", 1, 0, 0);
+ test("", 0, 1, "abcde", 1, 1, -1);
+ test("", 0, 1, "abcde", 1, 2, -2);
+ test("", 0, 1, "abcde", 1, 3, -3);
+ test("", 0, 1, "abcde", 1, 4, -4);
+ test("", 0, 1, "abcde", 1, 5, -4);
+ test("", 0, 1, "abcde", 2, 0, 0);
+ test("", 0, 1, "abcde", 2, 1, -1);
+ test("", 0, 1, "abcde", 2, 2, -2);
+ test("", 0, 1, "abcde", 2, 3, -3);
+ test("", 0, 1, "abcde", 2, 4, -3);
+ test("", 0, 1, "abcde", 4, 0, 0);
+ test("", 0, 1, "abcde", 4, 1, -1);
+ test("", 0, 1, "abcde", 4, 2, -1);
+ test("", 0, 1, "abcde", 5, 0, 0);
+ test("", 0, 1, "abcde", 5, 1, 0);
+ test("", 0, 1, "abcde", 6, 0, 0);
+}
+
+void test1()
+{
+ test("", 0, 1, "abcdefghij", 0, 0, 0);
+ test("", 0, 1, "abcdefghij", 0, 1, -1);
+ test("", 0, 1, "abcdefghij", 0, 5, -5);
+ test("", 0, 1, "abcdefghij", 0, 9, -9);
+ test("", 0, 1, "abcdefghij", 0, 10, -10);
+ test("", 0, 1, "abcdefghij", 0, 11, -10);
+ test("", 0, 1, "abcdefghij", 1, 0, 0);
+ test("", 0, 1, "abcdefghij", 1, 1, -1);
+ test("", 0, 1, "abcdefghij", 1, 4, -4);
+ test("", 0, 1, "abcdefghij", 1, 8, -8);
+ test("", 0, 1, "abcdefghij", 1, 9, -9);
+ test("", 0, 1, "abcdefghij", 1, 10, -9);
+ test("", 0, 1, "abcdefghij", 5, 0, 0);
+ test("", 0, 1, "abcdefghij", 5, 1, -1);
+ test("", 0, 1, "abcdefghij", 5, 2, -2);
+ test("", 0, 1, "abcdefghij", 5, 4, -4);
+ test("", 0, 1, "abcdefghij", 5, 5, -5);
+ test("", 0, 1, "abcdefghij", 5, 6, -5);
+ test("", 0, 1, "abcdefghij", 9, 0, 0);
+ test("", 0, 1, "abcdefghij", 9, 1, -1);
+ test("", 0, 1, "abcdefghij", 9, 2, -1);
+ test("", 0, 1, "abcdefghij", 10, 0, 0);
+ test("", 0, 1, "abcdefghij", 10, 1, 0);
+ test("", 0, 1, "abcdefghij", 11, 0, 0);
+ test("", 0, 1, "abcdefghijklmnopqrst", 0, 0, 0);
+ test("", 0, 1, "abcdefghijklmnopqrst", 0, 1, -1);
+ test("", 0, 1, "abcdefghijklmnopqrst", 0, 10, -10);
+ test("", 0, 1, "abcdefghijklmnopqrst", 0, 19, -19);
+ test("", 0, 1, "abcdefghijklmnopqrst", 0, 20, -20);
+ test("", 0, 1, "abcdefghijklmnopqrst", 0, 21, -20);
+ test("", 0, 1, "abcdefghijklmnopqrst", 1, 0, 0);
+ test("", 0, 1, "abcdefghijklmnopqrst", 1, 1, -1);
+ test("", 0, 1, "abcdefghijklmnopqrst", 1, 9, -9);
+ test("", 0, 1, "abcdefghijklmnopqrst", 1, 18, -18);
+ test("", 0, 1, "abcdefghijklmnopqrst", 1, 19, -19);
+ test("", 0, 1, "abcdefghijklmnopqrst", 1, 20, -19);
+ test("", 0, 1, "abcdefghijklmnopqrst", 10, 0, 0);
+ test("", 0, 1, "abcdefghijklmnopqrst", 10, 1, -1);
+ test("", 0, 1, "abcdefghijklmnopqrst", 10, 5, -5);
+ test("", 0, 1, "abcdefghijklmnopqrst", 10, 9, -9);
+ test("", 0, 1, "abcdefghijklmnopqrst", 10, 10, -10);
+ test("", 0, 1, "abcdefghijklmnopqrst", 10, 11, -10);
+ test("", 0, 1, "abcdefghijklmnopqrst", 19, 0, 0);
+ test("", 0, 1, "abcdefghijklmnopqrst", 19, 1, -1);
+ test("", 0, 1, "abcdefghijklmnopqrst", 19, 2, -1);
+ test("", 0, 1, "abcdefghijklmnopqrst", 20, 0, 0);
+ test("", 0, 1, "abcdefghijklmnopqrst", 20, 1, 0);
+ test("", 0, 1, "abcdefghijklmnopqrst", 21, 0, 0);
+ test("", 1, 0, "", 0, 0, 0);
+ test("", 1, 0, "", 0, 1, 0);
+ test("", 1, 0, "", 1, 0, 0);
+ test("", 1, 0, "abcde", 0, 0, 0);
+ test("", 1, 0, "abcde", 0, 1, 0);
+ test("", 1, 0, "abcde", 0, 2, 0);
+ test("", 1, 0, "abcde", 0, 4, 0);
+ test("", 1, 0, "abcde", 0, 5, 0);
+ test("", 1, 0, "abcde", 0, 6, 0);
+ test("", 1, 0, "abcde", 1, 0, 0);
+ test("", 1, 0, "abcde", 1, 1, 0);
+ test("", 1, 0, "abcde", 1, 2, 0);
+ test("", 1, 0, "abcde", 1, 3, 0);
+ test("", 1, 0, "abcde", 1, 4, 0);
+ test("", 1, 0, "abcde", 1, 5, 0);
+ test("", 1, 0, "abcde", 2, 0, 0);
+ test("", 1, 0, "abcde", 2, 1, 0);
+ test("", 1, 0, "abcde", 2, 2, 0);
+ test("", 1, 0, "abcde", 2, 3, 0);
+ test("", 1, 0, "abcde", 2, 4, 0);
+ test("", 1, 0, "abcde", 4, 0, 0);
+ test("", 1, 0, "abcde", 4, 1, 0);
+ test("", 1, 0, "abcde", 4, 2, 0);
+ test("", 1, 0, "abcde", 5, 0, 0);
+ test("", 1, 0, "abcde", 5, 1, 0);
+ test("", 1, 0, "abcde", 6, 0, 0);
+ test("", 1, 0, "abcdefghij", 0, 0, 0);
+ test("", 1, 0, "abcdefghij", 0, 1, 0);
+ test("", 1, 0, "abcdefghij", 0, 5, 0);
+ test("", 1, 0, "abcdefghij", 0, 9, 0);
+ test("", 1, 0, "abcdefghij", 0, 10, 0);
+ test("", 1, 0, "abcdefghij", 0, 11, 0);
+ test("", 1, 0, "abcdefghij", 1, 0, 0);
+ test("", 1, 0, "abcdefghij", 1, 1, 0);
+ test("", 1, 0, "abcdefghij", 1, 4, 0);
+ test("", 1, 0, "abcdefghij", 1, 8, 0);
+ test("", 1, 0, "abcdefghij", 1, 9, 0);
+ test("", 1, 0, "abcdefghij", 1, 10, 0);
+ test("", 1, 0, "abcdefghij", 5, 0, 0);
+ test("", 1, 0, "abcdefghij", 5, 1, 0);
+ test("", 1, 0, "abcdefghij", 5, 2, 0);
+ test("", 1, 0, "abcdefghij", 5, 4, 0);
+ test("", 1, 0, "abcdefghij", 5, 5, 0);
+ test("", 1, 0, "abcdefghij", 5, 6, 0);
+ test("", 1, 0, "abcdefghij", 9, 0, 0);
+ test("", 1, 0, "abcdefghij", 9, 1, 0);
+ test("", 1, 0, "abcdefghij", 9, 2, 0);
+ test("", 1, 0, "abcdefghij", 10, 0, 0);
+ test("", 1, 0, "abcdefghij", 10, 1, 0);
+ test("", 1, 0, "abcdefghij", 11, 0, 0);
+ test("", 1, 0, "abcdefghijklmnopqrst", 0, 0, 0);
+ test("", 1, 0, "abcdefghijklmnopqrst", 0, 1, 0);
+}
+
+void test2()
+{
+ test("", 1, 0, "abcdefghijklmnopqrst", 0, 10, 0);
+ test("", 1, 0, "abcdefghijklmnopqrst", 0, 19, 0);
+ test("", 1, 0, "abcdefghijklmnopqrst", 0, 20, 0);
+ test("", 1, 0, "abcdefghijklmnopqrst", 0, 21, 0);
+ test("", 1, 0, "abcdefghijklmnopqrst", 1, 0, 0);
+ test("", 1, 0, "abcdefghijklmnopqrst", 1, 1, 0);
+ test("", 1, 0, "abcdefghijklmnopqrst", 1, 9, 0);
+ test("", 1, 0, "abcdefghijklmnopqrst", 1, 18, 0);
+ test("", 1, 0, "abcdefghijklmnopqrst", 1, 19, 0);
+ test("", 1, 0, "abcdefghijklmnopqrst", 1, 20, 0);
+ test("", 1, 0, "abcdefghijklmnopqrst", 10, 0, 0);
+ test("", 1, 0, "abcdefghijklmnopqrst", 10, 1, 0);
+ test("", 1, 0, "abcdefghijklmnopqrst", 10, 5, 0);
+ test("", 1, 0, "abcdefghijklmnopqrst", 10, 9, 0);
+ test("", 1, 0, "abcdefghijklmnopqrst", 10, 10, 0);
+ test("", 1, 0, "abcdefghijklmnopqrst", 10, 11, 0);
+ test("", 1, 0, "abcdefghijklmnopqrst", 19, 0, 0);
+ test("", 1, 0, "abcdefghijklmnopqrst", 19, 1, 0);
+ test("", 1, 0, "abcdefghijklmnopqrst", 19, 2, 0);
+ test("", 1, 0, "abcdefghijklmnopqrst", 20, 0, 0);
+ test("", 1, 0, "abcdefghijklmnopqrst", 20, 1, 0);
+ test("", 1, 0, "abcdefghijklmnopqrst", 21, 0, 0);
+ test("abcde", 0, 0, "", 0, 0, 0);
+ test("abcde", 0, 0, "", 0, 1, 0);
+ test("abcde", 0, 0, "", 1, 0, 0);
+ test("abcde", 0, 0, "abcde", 0, 0, 0);
+ test("abcde", 0, 0, "abcde", 0, 1, -1);
+ test("abcde", 0, 0, "abcde", 0, 2, -2);
+ test("abcde", 0, 0, "abcde", 0, 4, -4);
+ test("abcde", 0, 0, "abcde", 0, 5, -5);
+ test("abcde", 0, 0, "abcde", 0, 6, -5);
+ test("abcde", 0, 0, "abcde", 1, 0, 0);
+ test("abcde", 0, 0, "abcde", 1, 1, -1);
+ test("abcde", 0, 0, "abcde", 1, 2, -2);
+ test("abcde", 0, 0, "abcde", 1, 3, -3);
+ test("abcde", 0, 0, "abcde", 1, 4, -4);
+ test("abcde", 0, 0, "abcde", 1, 5, -4);
+ test("abcde", 0, 0, "abcde", 2, 0, 0);
+ test("abcde", 0, 0, "abcde", 2, 1, -1);
+ test("abcde", 0, 0, "abcde", 2, 2, -2);
+ test("abcde", 0, 0, "abcde", 2, 3, -3);
+ test("abcde", 0, 0, "abcde", 2, 4, -3);
+ test("abcde", 0, 0, "abcde", 4, 0, 0);
+ test("abcde", 0, 0, "abcde", 4, 1, -1);
+ test("abcde", 0, 0, "abcde", 4, 2, -1);
+ test("abcde", 0, 0, "abcde", 5, 0, 0);
+ test("abcde", 0, 0, "abcde", 5, 1, 0);
+ test("abcde", 0, 0, "abcde", 6, 0, 0);
+ test("abcde", 0, 0, "abcdefghij", 0, 0, 0);
+ test("abcde", 0, 0, "abcdefghij", 0, 1, -1);
+ test("abcde", 0, 0, "abcdefghij", 0, 5, -5);
+ test("abcde", 0, 0, "abcdefghij", 0, 9, -9);
+ test("abcde", 0, 0, "abcdefghij", 0, 10, -10);
+ test("abcde", 0, 0, "abcdefghij", 0, 11, -10);
+ test("abcde", 0, 0, "abcdefghij", 1, 0, 0);
+ test("abcde", 0, 0, "abcdefghij", 1, 1, -1);
+ test("abcde", 0, 0, "abcdefghij", 1, 4, -4);
+ test("abcde", 0, 0, "abcdefghij", 1, 8, -8);
+ test("abcde", 0, 0, "abcdefghij", 1, 9, -9);
+ test("abcde", 0, 0, "abcdefghij", 1, 10, -9);
+ test("abcde", 0, 0, "abcdefghij", 5, 0, 0);
+ test("abcde", 0, 0, "abcdefghij", 5, 1, -1);
+ test("abcde", 0, 0, "abcdefghij", 5, 2, -2);
+ test("abcde", 0, 0, "abcdefghij", 5, 4, -4);
+ test("abcde", 0, 0, "abcdefghij", 5, 5, -5);
+ test("abcde", 0, 0, "abcdefghij", 5, 6, -5);
+ test("abcde", 0, 0, "abcdefghij", 9, 0, 0);
+ test("abcde", 0, 0, "abcdefghij", 9, 1, -1);
+ test("abcde", 0, 0, "abcdefghij", 9, 2, -1);
+ test("abcde", 0, 0, "abcdefghij", 10, 0, 0);
+ test("abcde", 0, 0, "abcdefghij", 10, 1, 0);
+ test("abcde", 0, 0, "abcdefghij", 11, 0, 0);
+ test("abcde", 0, 0, "abcdefghijklmnopqrst", 0, 0, 0);
+ test("abcde", 0, 0, "abcdefghijklmnopqrst", 0, 1, -1);
+ test("abcde", 0, 0, "abcdefghijklmnopqrst", 0, 10, -10);
+ test("abcde", 0, 0, "abcdefghijklmnopqrst", 0, 19, -19);
+ test("abcde", 0, 0, "abcdefghijklmnopqrst", 0, 20, -20);
+ test("abcde", 0, 0, "abcdefghijklmnopqrst", 0, 21, -20);
+ test("abcde", 0, 0, "abcdefghijklmnopqrst", 1, 0, 0);
+ test("abcde", 0, 0, "abcdefghijklmnopqrst", 1, 1, -1);
+ test("abcde", 0, 0, "abcdefghijklmnopqrst", 1, 9, -9);
+ test("abcde", 0, 0, "abcdefghijklmnopqrst", 1, 18, -18);
+ test("abcde", 0, 0, "abcdefghijklmnopqrst", 1, 19, -19);
+ test("abcde", 0, 0, "abcdefghijklmnopqrst", 1, 20, -19);
+ test("abcde", 0, 0, "abcdefghijklmnopqrst", 10, 0, 0);
+ test("abcde", 0, 0, "abcdefghijklmnopqrst", 10, 1, -1);
+ test("abcde", 0, 0, "abcdefghijklmnopqrst", 10, 5, -5);
+ test("abcde", 0, 0, "abcdefghijklmnopqrst", 10, 9, -9);
+ test("abcde", 0, 0, "abcdefghijklmnopqrst", 10, 10, -10);
+ test("abcde", 0, 0, "abcdefghijklmnopqrst", 10, 11, -10);
+ test("abcde", 0, 0, "abcdefghijklmnopqrst", 19, 0, 0);
+ test("abcde", 0, 0, "abcdefghijklmnopqrst", 19, 1, -1);
+ test("abcde", 0, 0, "abcdefghijklmnopqrst", 19, 2, -1);
+ test("abcde", 0, 0, "abcdefghijklmnopqrst", 20, 0, 0);
+ test("abcde", 0, 0, "abcdefghijklmnopqrst", 20, 1, 0);
+ test("abcde", 0, 0, "abcdefghijklmnopqrst", 21, 0, 0);
+ test("abcde", 0, 1, "", 0, 0, 1);
+ test("abcde", 0, 1, "", 0, 1, 1);
+ test("abcde", 0, 1, "", 1, 0, 0);
+ test("abcde", 0, 1, "abcde", 0, 0, 1);
+}
+
+void test3()
+{
+ test("abcde", 0, 1, "abcde", 0, 1, 0);
+ test("abcde", 0, 1, "abcde", 0, 2, -1);
+ test("abcde", 0, 1, "abcde", 0, 4, -3);
+ test("abcde", 0, 1, "abcde", 0, 5, -4);
+ test("abcde", 0, 1, "abcde", 0, 6, -4);
+ test("abcde", 0, 1, "abcde", 1, 0, 1);
+ test("abcde", 0, 1, "abcde", 1, 1, -1);
+ test("abcde", 0, 1, "abcde", 1, 2, -1);
+ test("abcde", 0, 1, "abcde", 1, 3, -1);
+ test("abcde", 0, 1, "abcde", 1, 4, -1);
+ test("abcde", 0, 1, "abcde", 1, 5, -1);
+ test("abcde", 0, 1, "abcde", 2, 0, 1);
+ test("abcde", 0, 1, "abcde", 2, 1, -2);
+ test("abcde", 0, 1, "abcde", 2, 2, -2);
+ test("abcde", 0, 1, "abcde", 2, 3, -2);
+ test("abcde", 0, 1, "abcde", 2, 4, -2);
+ test("abcde", 0, 1, "abcde", 4, 0, 1);
+ test("abcde", 0, 1, "abcde", 4, 1, -4);
+ test("abcde", 0, 1, "abcde", 4, 2, -4);
+ test("abcde", 0, 1, "abcde", 5, 0, 1);
+ test("abcde", 0, 1, "abcde", 5, 1, 1);
+ test("abcde", 0, 1, "abcde", 6, 0, 0);
+ test("abcde", 0, 1, "abcdefghij", 0, 0, 1);
+ test("abcde", 0, 1, "abcdefghij", 0, 1, 0);
+ test("abcde", 0, 1, "abcdefghij", 0, 5, -4);
+ test("abcde", 0, 1, "abcdefghij", 0, 9, -8);
+ test("abcde", 0, 1, "abcdefghij", 0, 10, -9);
+ test("abcde", 0, 1, "abcdefghij", 0, 11, -9);
+ test("abcde", 0, 1, "abcdefghij", 1, 0, 1);
+ test("abcde", 0, 1, "abcdefghij", 1, 1, -1);
+ test("abcde", 0, 1, "abcdefghij", 1, 4, -1);
+ test("abcde", 0, 1, "abcdefghij", 1, 8, -1);
+ test("abcde", 0, 1, "abcdefghij", 1, 9, -1);
+ test("abcde", 0, 1, "abcdefghij", 1, 10, -1);
+ test("abcde", 0, 1, "abcdefghij", 5, 0, 1);
+ test("abcde", 0, 1, "abcdefghij", 5, 1, -5);
+ test("abcde", 0, 1, "abcdefghij", 5, 2, -5);
+ test("abcde", 0, 1, "abcdefghij", 5, 4, -5);
+ test("abcde", 0, 1, "abcdefghij", 5, 5, -5);
+ test("abcde", 0, 1, "abcdefghij", 5, 6, -5);
+ test("abcde", 0, 1, "abcdefghij", 9, 0, 1);
+ test("abcde", 0, 1, "abcdefghij", 9, 1, -9);
+ test("abcde", 0, 1, "abcdefghij", 9, 2, -9);
+ test("abcde", 0, 1, "abcdefghij", 10, 0, 1);
+ test("abcde", 0, 1, "abcdefghij", 10, 1, 1);
+ test("abcde", 0, 1, "abcdefghij", 11, 0, 0);
+ test("abcde", 0, 1, "abcdefghijklmnopqrst", 0, 0, 1);
+ test("abcde", 0, 1, "abcdefghijklmnopqrst", 0, 1, 0);
+ test("abcde", 0, 1, "abcdefghijklmnopqrst", 0, 10, -9);
+ test("abcde", 0, 1, "abcdefghijklmnopqrst", 0, 19, -18);
+ test("abcde", 0, 1, "abcdefghijklmnopqrst", 0, 20, -19);
+ test("abcde", 0, 1, "abcdefghijklmnopqrst", 0, 21, -19);
+ test("abcde", 0, 1, "abcdefghijklmnopqrst", 1, 0, 1);
+ test("abcde", 0, 1, "abcdefghijklmnopqrst", 1, 1, -1);
+ test("abcde", 0, 1, "abcdefghijklmnopqrst", 1, 9, -1);
+ test("abcde", 0, 1, "abcdefghijklmnopqrst", 1, 18, -1);
+ test("abcde", 0, 1, "abcdefghijklmnopqrst", 1, 19, -1);
+ test("abcde", 0, 1, "abcdefghijklmnopqrst", 1, 20, -1);
+ test("abcde", 0, 1, "abcdefghijklmnopqrst", 10, 0, 1);
+ test("abcde", 0, 1, "abcdefghijklmnopqrst", 10, 1, -10);
+ test("abcde", 0, 1, "abcdefghijklmnopqrst", 10, 5, -10);
+ test("abcde", 0, 1, "abcdefghijklmnopqrst", 10, 9, -10);
+ test("abcde", 0, 1, "abcdefghijklmnopqrst", 10, 10, -10);
+ test("abcde", 0, 1, "abcdefghijklmnopqrst", 10, 11, -10);
+ test("abcde", 0, 1, "abcdefghijklmnopqrst", 19, 0, 1);
+ test("abcde", 0, 1, "abcdefghijklmnopqrst", 19, 1, -19);
+ test("abcde", 0, 1, "abcdefghijklmnopqrst", 19, 2, -19);
+ test("abcde", 0, 1, "abcdefghijklmnopqrst", 20, 0, 1);
+ test("abcde", 0, 1, "abcdefghijklmnopqrst", 20, 1, 1);
+ test("abcde", 0, 1, "abcdefghijklmnopqrst", 21, 0, 0);
+ test("abcde", 0, 2, "", 0, 0, 2);
+ test("abcde", 0, 2, "", 0, 1, 2);
+ test("abcde", 0, 2, "", 1, 0, 0);
+ test("abcde", 0, 2, "abcde", 0, 0, 2);
+ test("abcde", 0, 2, "abcde", 0, 1, 1);
+ test("abcde", 0, 2, "abcde", 0, 2, 0);
+ test("abcde", 0, 2, "abcde", 0, 4, -2);
+ test("abcde", 0, 2, "abcde", 0, 5, -3);
+ test("abcde", 0, 2, "abcde", 0, 6, -3);
+ test("abcde", 0, 2, "abcde", 1, 0, 2);
+ test("abcde", 0, 2, "abcde", 1, 1, -1);
+ test("abcde", 0, 2, "abcde", 1, 2, -1);
+ test("abcde", 0, 2, "abcde", 1, 3, -1);
+ test("abcde", 0, 2, "abcde", 1, 4, -1);
+ test("abcde", 0, 2, "abcde", 1, 5, -1);
+ test("abcde", 0, 2, "abcde", 2, 0, 2);
+ test("abcde", 0, 2, "abcde", 2, 1, -2);
+ test("abcde", 0, 2, "abcde", 2, 2, -2);
+ test("abcde", 0, 2, "abcde", 2, 3, -2);
+ test("abcde", 0, 2, "abcde", 2, 4, -2);
+ test("abcde", 0, 2, "abcde", 4, 0, 2);
+ test("abcde", 0, 2, "abcde", 4, 1, -4);
+ test("abcde", 0, 2, "abcde", 4, 2, -4);
+ test("abcde", 0, 2, "abcde", 5, 0, 2);
+ test("abcde", 0, 2, "abcde", 5, 1, 2);
+ test("abcde", 0, 2, "abcde", 6, 0, 0);
+ test("abcde", 0, 2, "abcdefghij", 0, 0, 2);
+ test("abcde", 0, 2, "abcdefghij", 0, 1, 1);
+ test("abcde", 0, 2, "abcdefghij", 0, 5, -3);
+ test("abcde", 0, 2, "abcdefghij", 0, 9, -7);
+}
+
+void test4()
+{
+ test("abcde", 0, 2, "abcdefghij", 0, 10, -8);
+ test("abcde", 0, 2, "abcdefghij", 0, 11, -8);
+ test("abcde", 0, 2, "abcdefghij", 1, 0, 2);
+ test("abcde", 0, 2, "abcdefghij", 1, 1, -1);
+ test("abcde", 0, 2, "abcdefghij", 1, 4, -1);
+ test("abcde", 0, 2, "abcdefghij", 1, 8, -1);
+ test("abcde", 0, 2, "abcdefghij", 1, 9, -1);
+ test("abcde", 0, 2, "abcdefghij", 1, 10, -1);
+ test("abcde", 0, 2, "abcdefghij", 5, 0, 2);
+ test("abcde", 0, 2, "abcdefghij", 5, 1, -5);
+ test("abcde", 0, 2, "abcdefghij", 5, 2, -5);
+ test("abcde", 0, 2, "abcdefghij", 5, 4, -5);
+ test("abcde", 0, 2, "abcdefghij", 5, 5, -5);
+ test("abcde", 0, 2, "abcdefghij", 5, 6, -5);
+ test("abcde", 0, 2, "abcdefghij", 9, 0, 2);
+ test("abcde", 0, 2, "abcdefghij", 9, 1, -9);
+ test("abcde", 0, 2, "abcdefghij", 9, 2, -9);
+ test("abcde", 0, 2, "abcdefghij", 10, 0, 2);
+ test("abcde", 0, 2, "abcdefghij", 10, 1, 2);
+ test("abcde", 0, 2, "abcdefghij", 11, 0, 0);
+ test("abcde", 0, 2, "abcdefghijklmnopqrst", 0, 0, 2);
+ test("abcde", 0, 2, "abcdefghijklmnopqrst", 0, 1, 1);
+ test("abcde", 0, 2, "abcdefghijklmnopqrst", 0, 10, -8);
+ test("abcde", 0, 2, "abcdefghijklmnopqrst", 0, 19, -17);
+ test("abcde", 0, 2, "abcdefghijklmnopqrst", 0, 20, -18);
+ test("abcde", 0, 2, "abcdefghijklmnopqrst", 0, 21, -18);
+ test("abcde", 0, 2, "abcdefghijklmnopqrst", 1, 0, 2);
+ test("abcde", 0, 2, "abcdefghijklmnopqrst", 1, 1, -1);
+ test("abcde", 0, 2, "abcdefghijklmnopqrst", 1, 9, -1);
+ test("abcde", 0, 2, "abcdefghijklmnopqrst", 1, 18, -1);
+ test("abcde", 0, 2, "abcdefghijklmnopqrst", 1, 19, -1);
+ test("abcde", 0, 2, "abcdefghijklmnopqrst", 1, 20, -1);
+ test("abcde", 0, 2, "abcdefghijklmnopqrst", 10, 0, 2);
+ test("abcde", 0, 2, "abcdefghijklmnopqrst", 10, 1, -10);
+ test("abcde", 0, 2, "abcdefghijklmnopqrst", 10, 5, -10);
+ test("abcde", 0, 2, "abcdefghijklmnopqrst", 10, 9, -10);
+ test("abcde", 0, 2, "abcdefghijklmnopqrst", 10, 10, -10);
+ test("abcde", 0, 2, "abcdefghijklmnopqrst", 10, 11, -10);
+ test("abcde", 0, 2, "abcdefghijklmnopqrst", 19, 0, 2);
+ test("abcde", 0, 2, "abcdefghijklmnopqrst", 19, 1, -19);
+ test("abcde", 0, 2, "abcdefghijklmnopqrst", 19, 2, -19);
+ test("abcde", 0, 2, "abcdefghijklmnopqrst", 20, 0, 2);
+ test("abcde", 0, 2, "abcdefghijklmnopqrst", 20, 1, 2);
+ test("abcde", 0, 2, "abcdefghijklmnopqrst", 21, 0, 0);
+ test("abcde", 0, 4, "", 0, 0, 4);
+ test("abcde", 0, 4, "", 0, 1, 4);
+ test("abcde", 0, 4, "", 1, 0, 0);
+ test("abcde", 0, 4, "abcde", 0, 0, 4);
+ test("abcde", 0, 4, "abcde", 0, 1, 3);
+ test("abcde", 0, 4, "abcde", 0, 2, 2);
+ test("abcde", 0, 4, "abcde", 0, 4, 0);
+ test("abcde", 0, 4, "abcde", 0, 5, -1);
+ test("abcde", 0, 4, "abcde", 0, 6, -1);
+ test("abcde", 0, 4, "abcde", 1, 0, 4);
+ test("abcde", 0, 4, "abcde", 1, 1, -1);
+ test("abcde", 0, 4, "abcde", 1, 2, -1);
+ test("abcde", 0, 4, "abcde", 1, 3, -1);
+ test("abcde", 0, 4, "abcde", 1, 4, -1);
+ test("abcde", 0, 4, "abcde", 1, 5, -1);
+ test("abcde", 0, 4, "abcde", 2, 0, 4);
+ test("abcde", 0, 4, "abcde", 2, 1, -2);
+ test("abcde", 0, 4, "abcde", 2, 2, -2);
+ test("abcde", 0, 4, "abcde", 2, 3, -2);
+ test("abcde", 0, 4, "abcde", 2, 4, -2);
+ test("abcde", 0, 4, "abcde", 4, 0, 4);
+ test("abcde", 0, 4, "abcde", 4, 1, -4);
+ test("abcde", 0, 4, "abcde", 4, 2, -4);
+ test("abcde", 0, 4, "abcde", 5, 0, 4);
+ test("abcde", 0, 4, "abcde", 5, 1, 4);
+ test("abcde", 0, 4, "abcde", 6, 0, 0);
+ test("abcde", 0, 4, "abcdefghij", 0, 0, 4);
+ test("abcde", 0, 4, "abcdefghij", 0, 1, 3);
+ test("abcde", 0, 4, "abcdefghij", 0, 5, -1);
+ test("abcde", 0, 4, "abcdefghij", 0, 9, -5);
+ test("abcde", 0, 4, "abcdefghij", 0, 10, -6);
+ test("abcde", 0, 4, "abcdefghij", 0, 11, -6);
+ test("abcde", 0, 4, "abcdefghij", 1, 0, 4);
+ test("abcde", 0, 4, "abcdefghij", 1, 1, -1);
+ test("abcde", 0, 4, "abcdefghij", 1, 4, -1);
+ test("abcde", 0, 4, "abcdefghij", 1, 8, -1);
+ test("abcde", 0, 4, "abcdefghij", 1, 9, -1);
+ test("abcde", 0, 4, "abcdefghij", 1, 10, -1);
+ test("abcde", 0, 4, "abcdefghij", 5, 0, 4);
+ test("abcde", 0, 4, "abcdefghij", 5, 1, -5);
+ test("abcde", 0, 4, "abcdefghij", 5, 2, -5);
+ test("abcde", 0, 4, "abcdefghij", 5, 4, -5);
+ test("abcde", 0, 4, "abcdefghij", 5, 5, -5);
+ test("abcde", 0, 4, "abcdefghij", 5, 6, -5);
+ test("abcde", 0, 4, "abcdefghij", 9, 0, 4);
+ test("abcde", 0, 4, "abcdefghij", 9, 1, -9);
+ test("abcde", 0, 4, "abcdefghij", 9, 2, -9);
+ test("abcde", 0, 4, "abcdefghij", 10, 0, 4);
+ test("abcde", 0, 4, "abcdefghij", 10, 1, 4);
+ test("abcde", 0, 4, "abcdefghij", 11, 0, 0);
+ test("abcde", 0, 4, "abcdefghijklmnopqrst", 0, 0, 4);
+ test("abcde", 0, 4, "abcdefghijklmnopqrst", 0, 1, 3);
+ test("abcde", 0, 4, "abcdefghijklmnopqrst", 0, 10, -6);
+ test("abcde", 0, 4, "abcdefghijklmnopqrst", 0, 19, -15);
+ test("abcde", 0, 4, "abcdefghijklmnopqrst", 0, 20, -16);
+ test("abcde", 0, 4, "abcdefghijklmnopqrst", 0, 21, -16);
+}
+
+void test5()
+{
+ test("abcde", 0, 4, "abcdefghijklmnopqrst", 1, 0, 4);
+ test("abcde", 0, 4, "abcdefghijklmnopqrst", 1, 1, -1);
+ test("abcde", 0, 4, "abcdefghijklmnopqrst", 1, 9, -1);
+ test("abcde", 0, 4, "abcdefghijklmnopqrst", 1, 18, -1);
+ test("abcde", 0, 4, "abcdefghijklmnopqrst", 1, 19, -1);
+ test("abcde", 0, 4, "abcdefghijklmnopqrst", 1, 20, -1);
+ test("abcde", 0, 4, "abcdefghijklmnopqrst", 10, 0, 4);
+ test("abcde", 0, 4, "abcdefghijklmnopqrst", 10, 1, -10);
+ test("abcde", 0, 4, "abcdefghijklmnopqrst", 10, 5, -10);
+ test("abcde", 0, 4, "abcdefghijklmnopqrst", 10, 9, -10);
+ test("abcde", 0, 4, "abcdefghijklmnopqrst", 10, 10, -10);
+ test("abcde", 0, 4, "abcdefghijklmnopqrst", 10, 11, -10);
+ test("abcde", 0, 4, "abcdefghijklmnopqrst", 19, 0, 4);
+ test("abcde", 0, 4, "abcdefghijklmnopqrst", 19, 1, -19);
+ test("abcde", 0, 4, "abcdefghijklmnopqrst", 19, 2, -19);
+ test("abcde", 0, 4, "abcdefghijklmnopqrst", 20, 0, 4);
+ test("abcde", 0, 4, "abcdefghijklmnopqrst", 20, 1, 4);
+ test("abcde", 0, 4, "abcdefghijklmnopqrst", 21, 0, 0);
+ test("abcde", 0, 5, "", 0, 0, 5);
+ test("abcde", 0, 5, "", 0, 1, 5);
+ test("abcde", 0, 5, "", 1, 0, 0);
+ test("abcde", 0, 5, "abcde", 0, 0, 5);
+ test("abcde", 0, 5, "abcde", 0, 1, 4);
+ test("abcde", 0, 5, "abcde", 0, 2, 3);
+ test("abcde", 0, 5, "abcde", 0, 4, 1);
+ test("abcde", 0, 5, "abcde", 0, 5, 0);
+ test("abcde", 0, 5, "abcde", 0, 6, 0);
+ test("abcde", 0, 5, "abcde", 1, 0, 5);
+ test("abcde", 0, 5, "abcde", 1, 1, -1);
+ test("abcde", 0, 5, "abcde", 1, 2, -1);
+ test("abcde", 0, 5, "abcde", 1, 3, -1);
+ test("abcde", 0, 5, "abcde", 1, 4, -1);
+ test("abcde", 0, 5, "abcde", 1, 5, -1);
+ test("abcde", 0, 5, "abcde", 2, 0, 5);
+ test("abcde", 0, 5, "abcde", 2, 1, -2);
+ test("abcde", 0, 5, "abcde", 2, 2, -2);
+ test("abcde", 0, 5, "abcde", 2, 3, -2);
+ test("abcde", 0, 5, "abcde", 2, 4, -2);
+ test("abcde", 0, 5, "abcde", 4, 0, 5);
+ test("abcde", 0, 5, "abcde", 4, 1, -4);
+ test("abcde", 0, 5, "abcde", 4, 2, -4);
+ test("abcde", 0, 5, "abcde", 5, 0, 5);
+ test("abcde", 0, 5, "abcde", 5, 1, 5);
+ test("abcde", 0, 5, "abcde", 6, 0, 0);
+ test("abcde", 0, 5, "abcdefghij", 0, 0, 5);
+ test("abcde", 0, 5, "abcdefghij", 0, 1, 4);
+ test("abcde", 0, 5, "abcdefghij", 0, 5, 0);
+ test("abcde", 0, 5, "abcdefghij", 0, 9, -4);
+ test("abcde", 0, 5, "abcdefghij", 0, 10, -5);
+ test("abcde", 0, 5, "abcdefghij", 0, 11, -5);
+ test("abcde", 0, 5, "abcdefghij", 1, 0, 5);
+ test("abcde", 0, 5, "abcdefghij", 1, 1, -1);
+ test("abcde", 0, 5, "abcdefghij", 1, 4, -1);
+ test("abcde", 0, 5, "abcdefghij", 1, 8, -1);
+ test("abcde", 0, 5, "abcdefghij", 1, 9, -1);
+ test("abcde", 0, 5, "abcdefghij", 1, 10, -1);
+ test("abcde", 0, 5, "abcdefghij", 5, 0, 5);
+ test("abcde", 0, 5, "abcdefghij", 5, 1, -5);
+ test("abcde", 0, 5, "abcdefghij", 5, 2, -5);
+ test("abcde", 0, 5, "abcdefghij", 5, 4, -5);
+ test("abcde", 0, 5, "abcdefghij", 5, 5, -5);
+ test("abcde", 0, 5, "abcdefghij", 5, 6, -5);
+ test("abcde", 0, 5, "abcdefghij", 9, 0, 5);
+ test("abcde", 0, 5, "abcdefghij", 9, 1, -9);
+ test("abcde", 0, 5, "abcdefghij", 9, 2, -9);
+ test("abcde", 0, 5, "abcdefghij", 10, 0, 5);
+ test("abcde", 0, 5, "abcdefghij", 10, 1, 5);
+ test("abcde", 0, 5, "abcdefghij", 11, 0, 0);
+ test("abcde", 0, 5, "abcdefghijklmnopqrst", 0, 0, 5);
+ test("abcde", 0, 5, "abcdefghijklmnopqrst", 0, 1, 4);
+ test("abcde", 0, 5, "abcdefghijklmnopqrst", 0, 10, -5);
+ test("abcde", 0, 5, "abcdefghijklmnopqrst", 0, 19, -14);
+ test("abcde", 0, 5, "abcdefghijklmnopqrst", 0, 20, -15);
+ test("abcde", 0, 5, "abcdefghijklmnopqrst", 0, 21, -15);
+ test("abcde", 0, 5, "abcdefghijklmnopqrst", 1, 0, 5);
+ test("abcde", 0, 5, "abcdefghijklmnopqrst", 1, 1, -1);
+ test("abcde", 0, 5, "abcdefghijklmnopqrst", 1, 9, -1);
+ test("abcde", 0, 5, "abcdefghijklmnopqrst", 1, 18, -1);
+ test("abcde", 0, 5, "abcdefghijklmnopqrst", 1, 19, -1);
+ test("abcde", 0, 5, "abcdefghijklmnopqrst", 1, 20, -1);
+ test("abcde", 0, 5, "abcdefghijklmnopqrst", 10, 0, 5);
+ test("abcde", 0, 5, "abcdefghijklmnopqrst", 10, 1, -10);
+ test("abcde", 0, 5, "abcdefghijklmnopqrst", 10, 5, -10);
+ test("abcde", 0, 5, "abcdefghijklmnopqrst", 10, 9, -10);
+ test("abcde", 0, 5, "abcdefghijklmnopqrst", 10, 10, -10);
+ test("abcde", 0, 5, "abcdefghijklmnopqrst", 10, 11, -10);
+ test("abcde", 0, 5, "abcdefghijklmnopqrst", 19, 0, 5);
+ test("abcde", 0, 5, "abcdefghijklmnopqrst", 19, 1, -19);
+ test("abcde", 0, 5, "abcdefghijklmnopqrst", 19, 2, -19);
+ test("abcde", 0, 5, "abcdefghijklmnopqrst", 20, 0, 5);
+ test("abcde", 0, 5, "abcdefghijklmnopqrst", 20, 1, 5);
+ test("abcde", 0, 5, "abcdefghijklmnopqrst", 21, 0, 0);
+ test("abcde", 0, 6, "", 0, 0, 5);
+ test("abcde", 0, 6, "", 0, 1, 5);
+ test("abcde", 0, 6, "", 1, 0, 0);
+ test("abcde", 0, 6, "abcde", 0, 0, 5);
+ test("abcde", 0, 6, "abcde", 0, 1, 4);
+ test("abcde", 0, 6, "abcde", 0, 2, 3);
+ test("abcde", 0, 6, "abcde", 0, 4, 1);
+ test("abcde", 0, 6, "abcde", 0, 5, 0);
+}
+
+void test6()
+{
+ test("abcde", 0, 6, "abcde", 0, 6, 0);
+ test("abcde", 0, 6, "abcde", 1, 0, 5);
+ test("abcde", 0, 6, "abcde", 1, 1, -1);
+ test("abcde", 0, 6, "abcde", 1, 2, -1);
+ test("abcde", 0, 6, "abcde", 1, 3, -1);
+ test("abcde", 0, 6, "abcde", 1, 4, -1);
+ test("abcde", 0, 6, "abcde", 1, 5, -1);
+ test("abcde", 0, 6, "abcde", 2, 0, 5);
+ test("abcde", 0, 6, "abcde", 2, 1, -2);
+ test("abcde", 0, 6, "abcde", 2, 2, -2);
+ test("abcde", 0, 6, "abcde", 2, 3, -2);
+ test("abcde", 0, 6, "abcde", 2, 4, -2);
+ test("abcde", 0, 6, "abcde", 4, 0, 5);
+ test("abcde", 0, 6, "abcde", 4, 1, -4);
+ test("abcde", 0, 6, "abcde", 4, 2, -4);
+ test("abcde", 0, 6, "abcde", 5, 0, 5);
+ test("abcde", 0, 6, "abcde", 5, 1, 5);
+ test("abcde", 0, 6, "abcde", 6, 0, 0);
+ test("abcde", 0, 6, "abcdefghij", 0, 0, 5);
+ test("abcde", 0, 6, "abcdefghij", 0, 1, 4);
+ test("abcde", 0, 6, "abcdefghij", 0, 5, 0);
+ test("abcde", 0, 6, "abcdefghij", 0, 9, -4);
+ test("abcde", 0, 6, "abcdefghij", 0, 10, -5);
+ test("abcde", 0, 6, "abcdefghij", 0, 11, -5);
+ test("abcde", 0, 6, "abcdefghij", 1, 0, 5);
+ test("abcde", 0, 6, "abcdefghij", 1, 1, -1);
+ test("abcde", 0, 6, "abcdefghij", 1, 4, -1);
+ test("abcde", 0, 6, "abcdefghij", 1, 8, -1);
+ test("abcde", 0, 6, "abcdefghij", 1, 9, -1);
+ test("abcde", 0, 6, "abcdefghij", 1, 10, -1);
+ test("abcde", 0, 6, "abcdefghij", 5, 0, 5);
+ test("abcde", 0, 6, "abcdefghij", 5, 1, -5);
+ test("abcde", 0, 6, "abcdefghij", 5, 2, -5);
+ test("abcde", 0, 6, "abcdefghij", 5, 4, -5);
+ test("abcde", 0, 6, "abcdefghij", 5, 5, -5);
+ test("abcde", 0, 6, "abcdefghij", 5, 6, -5);
+ test("abcde", 0, 6, "abcdefghij", 9, 0, 5);
+ test("abcde", 0, 6, "abcdefghij", 9, 1, -9);
+ test("abcde", 0, 6, "abcdefghij", 9, 2, -9);
+ test("abcde", 0, 6, "abcdefghij", 10, 0, 5);
+ test("abcde", 0, 6, "abcdefghij", 10, 1, 5);
+ test("abcde", 0, 6, "abcdefghij", 11, 0, 0);
+ test("abcde", 0, 6, "abcdefghijklmnopqrst", 0, 0, 5);
+ test("abcde", 0, 6, "abcdefghijklmnopqrst", 0, 1, 4);
+ test("abcde", 0, 6, "abcdefghijklmnopqrst", 0, 10, -5);
+ test("abcde", 0, 6, "abcdefghijklmnopqrst", 0, 19, -14);
+ test("abcde", 0, 6, "abcdefghijklmnopqrst", 0, 20, -15);
+ test("abcde", 0, 6, "abcdefghijklmnopqrst", 0, 21, -15);
+ test("abcde", 0, 6, "abcdefghijklmnopqrst", 1, 0, 5);
+ test("abcde", 0, 6, "abcdefghijklmnopqrst", 1, 1, -1);
+ test("abcde", 0, 6, "abcdefghijklmnopqrst", 1, 9, -1);
+ test("abcde", 0, 6, "abcdefghijklmnopqrst", 1, 18, -1);
+ test("abcde", 0, 6, "abcdefghijklmnopqrst", 1, 19, -1);
+ test("abcde", 0, 6, "abcdefghijklmnopqrst", 1, 20, -1);
+ test("abcde", 0, 6, "abcdefghijklmnopqrst", 10, 0, 5);
+ test("abcde", 0, 6, "abcdefghijklmnopqrst", 10, 1, -10);
+ test("abcde", 0, 6, "abcdefghijklmnopqrst", 10, 5, -10);
+ test("abcde", 0, 6, "abcdefghijklmnopqrst", 10, 9, -10);
+ test("abcde", 0, 6, "abcdefghijklmnopqrst", 10, 10, -10);
+ test("abcde", 0, 6, "abcdefghijklmnopqrst", 10, 11, -10);
+ test("abcde", 0, 6, "abcdefghijklmnopqrst", 19, 0, 5);
+ test("abcde", 0, 6, "abcdefghijklmnopqrst", 19, 1, -19);
+ test("abcde", 0, 6, "abcdefghijklmnopqrst", 19, 2, -19);
+ test("abcde", 0, 6, "abcdefghijklmnopqrst", 20, 0, 5);
+ test("abcde", 0, 6, "abcdefghijklmnopqrst", 20, 1, 5);
+ test("abcde", 0, 6, "abcdefghijklmnopqrst", 21, 0, 0);
+ test("abcde", 1, 0, "", 0, 0, 0);
+ test("abcde", 1, 0, "", 0, 1, 0);
+ test("abcde", 1, 0, "", 1, 0, 0);
+ test("abcde", 1, 0, "abcde", 0, 0, 0);
+ test("abcde", 1, 0, "abcde", 0, 1, -1);
+ test("abcde", 1, 0, "abcde", 0, 2, -2);
+ test("abcde", 1, 0, "abcde", 0, 4, -4);
+ test("abcde", 1, 0, "abcde", 0, 5, -5);
+ test("abcde", 1, 0, "abcde", 0, 6, -5);
+ test("abcde", 1, 0, "abcde", 1, 0, 0);
+ test("abcde", 1, 0, "abcde", 1, 1, -1);
+ test("abcde", 1, 0, "abcde", 1, 2, -2);
+ test("abcde", 1, 0, "abcde", 1, 3, -3);
+ test("abcde", 1, 0, "abcde", 1, 4, -4);
+ test("abcde", 1, 0, "abcde", 1, 5, -4);
+ test("abcde", 1, 0, "abcde", 2, 0, 0);
+ test("abcde", 1, 0, "abcde", 2, 1, -1);
+ test("abcde", 1, 0, "abcde", 2, 2, -2);
+ test("abcde", 1, 0, "abcde", 2, 3, -3);
+ test("abcde", 1, 0, "abcde", 2, 4, -3);
+ test("abcde", 1, 0, "abcde", 4, 0, 0);
+ test("abcde", 1, 0, "abcde", 4, 1, -1);
+ test("abcde", 1, 0, "abcde", 4, 2, -1);
+ test("abcde", 1, 0, "abcde", 5, 0, 0);
+ test("abcde", 1, 0, "abcde", 5, 1, 0);
+ test("abcde", 1, 0, "abcde", 6, 0, 0);
+ test("abcde", 1, 0, "abcdefghij", 0, 0, 0);
+ test("abcde", 1, 0, "abcdefghij", 0, 1, -1);
+ test("abcde", 1, 0, "abcdefghij", 0, 5, -5);
+ test("abcde", 1, 0, "abcdefghij", 0, 9, -9);
+ test("abcde", 1, 0, "abcdefghij", 0, 10, -10);
+ test("abcde", 1, 0, "abcdefghij", 0, 11, -10);
+ test("abcde", 1, 0, "abcdefghij", 1, 0, 0);
+ test("abcde", 1, 0, "abcdefghij", 1, 1, -1);
+}
+
+void test7()
+{
+ test("abcde", 1, 0, "abcdefghij", 1, 4, -4);
+ test("abcde", 1, 0, "abcdefghij", 1, 8, -8);
+ test("abcde", 1, 0, "abcdefghij", 1, 9, -9);
+ test("abcde", 1, 0, "abcdefghij", 1, 10, -9);
+ test("abcde", 1, 0, "abcdefghij", 5, 0, 0);
+ test("abcde", 1, 0, "abcdefghij", 5, 1, -1);
+ test("abcde", 1, 0, "abcdefghij", 5, 2, -2);
+ test("abcde", 1, 0, "abcdefghij", 5, 4, -4);
+ test("abcde", 1, 0, "abcdefghij", 5, 5, -5);
+ test("abcde", 1, 0, "abcdefghij", 5, 6, -5);
+ test("abcde", 1, 0, "abcdefghij", 9, 0, 0);
+ test("abcde", 1, 0, "abcdefghij", 9, 1, -1);
+ test("abcde", 1, 0, "abcdefghij", 9, 2, -1);
+ test("abcde", 1, 0, "abcdefghij", 10, 0, 0);
+ test("abcde", 1, 0, "abcdefghij", 10, 1, 0);
+ test("abcde", 1, 0, "abcdefghij", 11, 0, 0);
+ test("abcde", 1, 0, "abcdefghijklmnopqrst", 0, 0, 0);
+ test("abcde", 1, 0, "abcdefghijklmnopqrst", 0, 1, -1);
+ test("abcde", 1, 0, "abcdefghijklmnopqrst", 0, 10, -10);
+ test("abcde", 1, 0, "abcdefghijklmnopqrst", 0, 19, -19);
+ test("abcde", 1, 0, "abcdefghijklmnopqrst", 0, 20, -20);
+ test("abcde", 1, 0, "abcdefghijklmnopqrst", 0, 21, -20);
+ test("abcde", 1, 0, "abcdefghijklmnopqrst", 1, 0, 0);
+ test("abcde", 1, 0, "abcdefghijklmnopqrst", 1, 1, -1);
+ test("abcde", 1, 0, "abcdefghijklmnopqrst", 1, 9, -9);
+ test("abcde", 1, 0, "abcdefghijklmnopqrst", 1, 18, -18);
+ test("abcde", 1, 0, "abcdefghijklmnopqrst", 1, 19, -19);
+ test("abcde", 1, 0, "abcdefghijklmnopqrst", 1, 20, -19);
+ test("abcde", 1, 0, "abcdefghijklmnopqrst", 10, 0, 0);
+ test("abcde", 1, 0, "abcdefghijklmnopqrst", 10, 1, -1);
+ test("abcde", 1, 0, "abcdefghijklmnopqrst", 10, 5, -5);
+ test("abcde", 1, 0, "abcdefghijklmnopqrst", 10, 9, -9);
+ test("abcde", 1, 0, "abcdefghijklmnopqrst", 10, 10, -10);
+ test("abcde", 1, 0, "abcdefghijklmnopqrst", 10, 11, -10);
+ test("abcde", 1, 0, "abcdefghijklmnopqrst", 19, 0, 0);
+ test("abcde", 1, 0, "abcdefghijklmnopqrst", 19, 1, -1);
+ test("abcde", 1, 0, "abcdefghijklmnopqrst", 19, 2, -1);
+ test("abcde", 1, 0, "abcdefghijklmnopqrst", 20, 0, 0);
+ test("abcde", 1, 0, "abcdefghijklmnopqrst", 20, 1, 0);
+ test("abcde", 1, 0, "abcdefghijklmnopqrst", 21, 0, 0);
+ test("abcde", 1, 1, "", 0, 0, 1);
+ test("abcde", 1, 1, "", 0, 1, 1);
+ test("abcde", 1, 1, "", 1, 0, 0);
+ test("abcde", 1, 1, "abcde", 0, 0, 1);
+ test("abcde", 1, 1, "abcde", 0, 1, 1);
+ test("abcde", 1, 1, "abcde", 0, 2, 1);
+ test("abcde", 1, 1, "abcde", 0, 4, 1);
+ test("abcde", 1, 1, "abcde", 0, 5, 1);
+ test("abcde", 1, 1, "abcde", 0, 6, 1);
+ test("abcde", 1, 1, "abcde", 1, 0, 1);
+ test("abcde", 1, 1, "abcde", 1, 1, 0);
+ test("abcde", 1, 1, "abcde", 1, 2, -1);
+ test("abcde", 1, 1, "abcde", 1, 3, -2);
+ test("abcde", 1, 1, "abcde", 1, 4, -3);
+ test("abcde", 1, 1, "abcde", 1, 5, -3);
+ test("abcde", 1, 1, "abcde", 2, 0, 1);
+ test("abcde", 1, 1, "abcde", 2, 1, -1);
+ test("abcde", 1, 1, "abcde", 2, 2, -1);
+ test("abcde", 1, 1, "abcde", 2, 3, -1);
+ test("abcde", 1, 1, "abcde", 2, 4, -1);
+ test("abcde", 1, 1, "abcde", 4, 0, 1);
+ test("abcde", 1, 1, "abcde", 4, 1, -3);
+ test("abcde", 1, 1, "abcde", 4, 2, -3);
+ test("abcde", 1, 1, "abcde", 5, 0, 1);
+ test("abcde", 1, 1, "abcde", 5, 1, 1);
+ test("abcde", 1, 1, "abcde", 6, 0, 0);
+ test("abcde", 1, 1, "abcdefghij", 0, 0, 1);
+ test("abcde", 1, 1, "abcdefghij", 0, 1, 1);
+ test("abcde", 1, 1, "abcdefghij", 0, 5, 1);
+ test("abcde", 1, 1, "abcdefghij", 0, 9, 1);
+ test("abcde", 1, 1, "abcdefghij", 0, 10, 1);
+ test("abcde", 1, 1, "abcdefghij", 0, 11, 1);
+ test("abcde", 1, 1, "abcdefghij", 1, 0, 1);
+ test("abcde", 1, 1, "abcdefghij", 1, 1, 0);
+ test("abcde", 1, 1, "abcdefghij", 1, 4, -3);
+ test("abcde", 1, 1, "abcdefghij", 1, 8, -7);
+ test("abcde", 1, 1, "abcdefghij", 1, 9, -8);
+ test("abcde", 1, 1, "abcdefghij", 1, 10, -8);
+ test("abcde", 1, 1, "abcdefghij", 5, 0, 1);
+ test("abcde", 1, 1, "abcdefghij", 5, 1, -4);
+ test("abcde", 1, 1, "abcdefghij", 5, 2, -4);
+ test("abcde", 1, 1, "abcdefghij", 5, 4, -4);
+ test("abcde", 1, 1, "abcdefghij", 5, 5, -4);
+ test("abcde", 1, 1, "abcdefghij", 5, 6, -4);
+ test("abcde", 1, 1, "abcdefghij", 9, 0, 1);
+ test("abcde", 1, 1, "abcdefghij", 9, 1, -8);
+ test("abcde", 1, 1, "abcdefghij", 9, 2, -8);
+ test("abcde", 1, 1, "abcdefghij", 10, 0, 1);
+ test("abcde", 1, 1, "abcdefghij", 10, 1, 1);
+ test("abcde", 1, 1, "abcdefghij", 11, 0, 0);
+ test("abcde", 1, 1, "abcdefghijklmnopqrst", 0, 0, 1);
+ test("abcde", 1, 1, "abcdefghijklmnopqrst", 0, 1, 1);
+ test("abcde", 1, 1, "abcdefghijklmnopqrst", 0, 10, 1);
+ test("abcde", 1, 1, "abcdefghijklmnopqrst", 0, 19, 1);
+ test("abcde", 1, 1, "abcdefghijklmnopqrst", 0, 20, 1);
+ test("abcde", 1, 1, "abcdefghijklmnopqrst", 0, 21, 1);
+ test("abcde", 1, 1, "abcdefghijklmnopqrst", 1, 0, 1);
+ test("abcde", 1, 1, "abcdefghijklmnopqrst", 1, 1, 0);
+ test("abcde", 1, 1, "abcdefghijklmnopqrst", 1, 9, -8);
+ test("abcde", 1, 1, "abcdefghijklmnopqrst", 1, 18, -17);
+}
+
+void test8()
+{
+ test("abcde", 1, 1, "abcdefghijklmnopqrst", 1, 19, -18);
+ test("abcde", 1, 1, "abcdefghijklmnopqrst", 1, 20, -18);
+ test("abcde", 1, 1, "abcdefghijklmnopqrst", 10, 0, 1);
+ test("abcde", 1, 1, "abcdefghijklmnopqrst", 10, 1, -9);
+ test("abcde", 1, 1, "abcdefghijklmnopqrst", 10, 5, -9);
+ test("abcde", 1, 1, "abcdefghijklmnopqrst", 10, 9, -9);
+ test("abcde", 1, 1, "abcdefghijklmnopqrst", 10, 10, -9);
+ test("abcde", 1, 1, "abcdefghijklmnopqrst", 10, 11, -9);
+ test("abcde", 1, 1, "abcdefghijklmnopqrst", 19, 0, 1);
+ test("abcde", 1, 1, "abcdefghijklmnopqrst", 19, 1, -18);
+ test("abcde", 1, 1, "abcdefghijklmnopqrst", 19, 2, -18);
+ test("abcde", 1, 1, "abcdefghijklmnopqrst", 20, 0, 1);
+ test("abcde", 1, 1, "abcdefghijklmnopqrst", 20, 1, 1);
+ test("abcde", 1, 1, "abcdefghijklmnopqrst", 21, 0, 0);
+ test("abcde", 1, 2, "", 0, 0, 2);
+ test("abcde", 1, 2, "", 0, 1, 2);
+ test("abcde", 1, 2, "", 1, 0, 0);
+ test("abcde", 1, 2, "abcde", 0, 0, 2);
+ test("abcde", 1, 2, "abcde", 0, 1, 1);
+ test("abcde", 1, 2, "abcde", 0, 2, 1);
+ test("abcde", 1, 2, "abcde", 0, 4, 1);
+ test("abcde", 1, 2, "abcde", 0, 5, 1);
+ test("abcde", 1, 2, "abcde", 0, 6, 1);
+ test("abcde", 1, 2, "abcde", 1, 0, 2);
+ test("abcde", 1, 2, "abcde", 1, 1, 1);
+ test("abcde", 1, 2, "abcde", 1, 2, 0);
+ test("abcde", 1, 2, "abcde", 1, 3, -1);
+ test("abcde", 1, 2, "abcde", 1, 4, -2);
+ test("abcde", 1, 2, "abcde", 1, 5, -2);
+ test("abcde", 1, 2, "abcde", 2, 0, 2);
+ test("abcde", 1, 2, "abcde", 2, 1, -1);
+ test("abcde", 1, 2, "abcde", 2, 2, -1);
+ test("abcde", 1, 2, "abcde", 2, 3, -1);
+ test("abcde", 1, 2, "abcde", 2, 4, -1);
+ test("abcde", 1, 2, "abcde", 4, 0, 2);
+ test("abcde", 1, 2, "abcde", 4, 1, -3);
+ test("abcde", 1, 2, "abcde", 4, 2, -3);
+ test("abcde", 1, 2, "abcde", 5, 0, 2);
+ test("abcde", 1, 2, "abcde", 5, 1, 2);
+ test("abcde", 1, 2, "abcde", 6, 0, 0);
+ test("abcde", 1, 2, "abcdefghij", 0, 0, 2);
+ test("abcde", 1, 2, "abcdefghij", 0, 1, 1);
+ test("abcde", 1, 2, "abcdefghij", 0, 5, 1);
+ test("abcde", 1, 2, "abcdefghij", 0, 9, 1);
+ test("abcde", 1, 2, "abcdefghij", 0, 10, 1);
+ test("abcde", 1, 2, "abcdefghij", 0, 11, 1);
+ test("abcde", 1, 2, "abcdefghij", 1, 0, 2);
+ test("abcde", 1, 2, "abcdefghij", 1, 1, 1);
+ test("abcde", 1, 2, "abcdefghij", 1, 4, -2);
+ test("abcde", 1, 2, "abcdefghij", 1, 8, -6);
+ test("abcde", 1, 2, "abcdefghij", 1, 9, -7);
+ test("abcde", 1, 2, "abcdefghij", 1, 10, -7);
+ test("abcde", 1, 2, "abcdefghij", 5, 0, 2);
+ test("abcde", 1, 2, "abcdefghij", 5, 1, -4);
+ test("abcde", 1, 2, "abcdefghij", 5, 2, -4);
+ test("abcde", 1, 2, "abcdefghij", 5, 4, -4);
+ test("abcde", 1, 2, "abcdefghij", 5, 5, -4);
+ test("abcde", 1, 2, "abcdefghij", 5, 6, -4);
+ test("abcde", 1, 2, "abcdefghij", 9, 0, 2);
+ test("abcde", 1, 2, "abcdefghij", 9, 1, -8);
+ test("abcde", 1, 2, "abcdefghij", 9, 2, -8);
+ test("abcde", 1, 2, "abcdefghij", 10, 0, 2);
+ test("abcde", 1, 2, "abcdefghij", 10, 1, 2);
+ test("abcde", 1, 2, "abcdefghij", 11, 0, 0);
+ test("abcde", 1, 2, "abcdefghijklmnopqrst", 0, 0, 2);
+ test("abcde", 1, 2, "abcdefghijklmnopqrst", 0, 1, 1);
+ test("abcde", 1, 2, "abcdefghijklmnopqrst", 0, 10, 1);
+ test("abcde", 1, 2, "abcdefghijklmnopqrst", 0, 19, 1);
+ test("abcde", 1, 2, "abcdefghijklmnopqrst", 0, 20, 1);
+ test("abcde", 1, 2, "abcdefghijklmnopqrst", 0, 21, 1);
+ test("abcde", 1, 2, "abcdefghijklmnopqrst", 1, 0, 2);
+ test("abcde", 1, 2, "abcdefghijklmnopqrst", 1, 1, 1);
+ test("abcde", 1, 2, "abcdefghijklmnopqrst", 1, 9, -7);
+ test("abcde", 1, 2, "abcdefghijklmnopqrst", 1, 18, -16);
+ test("abcde", 1, 2, "abcdefghijklmnopqrst", 1, 19, -17);
+ test("abcde", 1, 2, "abcdefghijklmnopqrst", 1, 20, -17);
+ test("abcde", 1, 2, "abcdefghijklmnopqrst", 10, 0, 2);
+ test("abcde", 1, 2, "abcdefghijklmnopqrst", 10, 1, -9);
+ test("abcde", 1, 2, "abcdefghijklmnopqrst", 10, 5, -9);
+ test("abcde", 1, 2, "abcdefghijklmnopqrst", 10, 9, -9);
+ test("abcde", 1, 2, "abcdefghijklmnopqrst", 10, 10, -9);
+ test("abcde", 1, 2, "abcdefghijklmnopqrst", 10, 11, -9);
+ test("abcde", 1, 2, "abcdefghijklmnopqrst", 19, 0, 2);
+ test("abcde", 1, 2, "abcdefghijklmnopqrst", 19, 1, -18);
+ test("abcde", 1, 2, "abcdefghijklmnopqrst", 19, 2, -18);
+ test("abcde", 1, 2, "abcdefghijklmnopqrst", 20, 0, 2);
+ test("abcde", 1, 2, "abcdefghijklmnopqrst", 20, 1, 2);
+ test("abcde", 1, 2, "abcdefghijklmnopqrst", 21, 0, 0);
+ test("abcde", 1, 3, "", 0, 0, 3);
+ test("abcde", 1, 3, "", 0, 1, 3);
+ test("abcde", 1, 3, "", 1, 0, 0);
+ test("abcde", 1, 3, "abcde", 0, 0, 3);
+ test("abcde", 1, 3, "abcde", 0, 1, 1);
+ test("abcde", 1, 3, "abcde", 0, 2, 1);
+ test("abcde", 1, 3, "abcde", 0, 4, 1);
+ test("abcde", 1, 3, "abcde", 0, 5, 1);
+ test("abcde", 1, 3, "abcde", 0, 6, 1);
+ test("abcde", 1, 3, "abcde", 1, 0, 3);
+ test("abcde", 1, 3, "abcde", 1, 1, 2);
+ test("abcde", 1, 3, "abcde", 1, 2, 1);
+}
+
+void test9()
+{
+ test("abcde", 1, 3, "abcde", 1, 3, 0);
+ test("abcde", 1, 3, "abcde", 1, 4, -1);
+ test("abcde", 1, 3, "abcde", 1, 5, -1);
+ test("abcde", 1, 3, "abcde", 2, 0, 3);
+ test("abcde", 1, 3, "abcde", 2, 1, -1);
+ test("abcde", 1, 3, "abcde", 2, 2, -1);
+ test("abcde", 1, 3, "abcde", 2, 3, -1);
+ test("abcde", 1, 3, "abcde", 2, 4, -1);
+ test("abcde", 1, 3, "abcde", 4, 0, 3);
+ test("abcde", 1, 3, "abcde", 4, 1, -3);
+ test("abcde", 1, 3, "abcde", 4, 2, -3);
+ test("abcde", 1, 3, "abcde", 5, 0, 3);
+ test("abcde", 1, 3, "abcde", 5, 1, 3);
+ test("abcde", 1, 3, "abcde", 6, 0, 0);
+ test("abcde", 1, 3, "abcdefghij", 0, 0, 3);
+ test("abcde", 1, 3, "abcdefghij", 0, 1, 1);
+ test("abcde", 1, 3, "abcdefghij", 0, 5, 1);
+ test("abcde", 1, 3, "abcdefghij", 0, 9, 1);
+ test("abcde", 1, 3, "abcdefghij", 0, 10, 1);
+ test("abcde", 1, 3, "abcdefghij", 0, 11, 1);
+ test("abcde", 1, 3, "abcdefghij", 1, 0, 3);
+ test("abcde", 1, 3, "abcdefghij", 1, 1, 2);
+ test("abcde", 1, 3, "abcdefghij", 1, 4, -1);
+ test("abcde", 1, 3, "abcdefghij", 1, 8, -5);
+ test("abcde", 1, 3, "abcdefghij", 1, 9, -6);
+ test("abcde", 1, 3, "abcdefghij", 1, 10, -6);
+ test("abcde", 1, 3, "abcdefghij", 5, 0, 3);
+ test("abcde", 1, 3, "abcdefghij", 5, 1, -4);
+ test("abcde", 1, 3, "abcdefghij", 5, 2, -4);
+ test("abcde", 1, 3, "abcdefghij", 5, 4, -4);
+ test("abcde", 1, 3, "abcdefghij", 5, 5, -4);
+ test("abcde", 1, 3, "abcdefghij", 5, 6, -4);
+ test("abcde", 1, 3, "abcdefghij", 9, 0, 3);
+ test("abcde", 1, 3, "abcdefghij", 9, 1, -8);
+ test("abcde", 1, 3, "abcdefghij", 9, 2, -8);
+ test("abcde", 1, 3, "abcdefghij", 10, 0, 3);
+ test("abcde", 1, 3, "abcdefghij", 10, 1, 3);
+ test("abcde", 1, 3, "abcdefghij", 11, 0, 0);
+ test("abcde", 1, 3, "abcdefghijklmnopqrst", 0, 0, 3);
+ test("abcde", 1, 3, "abcdefghijklmnopqrst", 0, 1, 1);
+ test("abcde", 1, 3, "abcdefghijklmnopqrst", 0, 10, 1);
+ test("abcde", 1, 3, "abcdefghijklmnopqrst", 0, 19, 1);
+ test("abcde", 1, 3, "abcdefghijklmnopqrst", 0, 20, 1);
+ test("abcde", 1, 3, "abcdefghijklmnopqrst", 0, 21, 1);
+ test("abcde", 1, 3, "abcdefghijklmnopqrst", 1, 0, 3);
+ test("abcde", 1, 3, "abcdefghijklmnopqrst", 1, 1, 2);
+ test("abcde", 1, 3, "abcdefghijklmnopqrst", 1, 9, -6);
+ test("abcde", 1, 3, "abcdefghijklmnopqrst", 1, 18, -15);
+ test("abcde", 1, 3, "abcdefghijklmnopqrst", 1, 19, -16);
+ test("abcde", 1, 3, "abcdefghijklmnopqrst", 1, 20, -16);
+ test("abcde", 1, 3, "abcdefghijklmnopqrst", 10, 0, 3);
+ test("abcde", 1, 3, "abcdefghijklmnopqrst", 10, 1, -9);
+ test("abcde", 1, 3, "abcdefghijklmnopqrst", 10, 5, -9);
+ test("abcde", 1, 3, "abcdefghijklmnopqrst", 10, 9, -9);
+ test("abcde", 1, 3, "abcdefghijklmnopqrst", 10, 10, -9);
+ test("abcde", 1, 3, "abcdefghijklmnopqrst", 10, 11, -9);
+ test("abcde", 1, 3, "abcdefghijklmnopqrst", 19, 0, 3);
+ test("abcde", 1, 3, "abcdefghijklmnopqrst", 19, 1, -18);
+ test("abcde", 1, 3, "abcdefghijklmnopqrst", 19, 2, -18);
+ test("abcde", 1, 3, "abcdefghijklmnopqrst", 20, 0, 3);
+ test("abcde", 1, 3, "abcdefghijklmnopqrst", 20, 1, 3);
+ test("abcde", 1, 3, "abcdefghijklmnopqrst", 21, 0, 0);
+ test("abcde", 1, 4, "", 0, 0, 4);
+ test("abcde", 1, 4, "", 0, 1, 4);
+ test("abcde", 1, 4, "", 1, 0, 0);
+ test("abcde", 1, 4, "abcde", 0, 0, 4);
+ test("abcde", 1, 4, "abcde", 0, 1, 1);
+ test("abcde", 1, 4, "abcde", 0, 2, 1);
+ test("abcde", 1, 4, "abcde", 0, 4, 1);
+ test("abcde", 1, 4, "abcde", 0, 5, 1);
+ test("abcde", 1, 4, "abcde", 0, 6, 1);
+ test("abcde", 1, 4, "abcde", 1, 0, 4);
+ test("abcde", 1, 4, "abcde", 1, 1, 3);
+ test("abcde", 1, 4, "abcde", 1, 2, 2);
+ test("abcde", 1, 4, "abcde", 1, 3, 1);
+ test("abcde", 1, 4, "abcde", 1, 4, 0);
+ test("abcde", 1, 4, "abcde", 1, 5, 0);
+ test("abcde", 1, 4, "abcde", 2, 0, 4);
+ test("abcde", 1, 4, "abcde", 2, 1, -1);
+ test("abcde", 1, 4, "abcde", 2, 2, -1);
+ test("abcde", 1, 4, "abcde", 2, 3, -1);
+ test("abcde", 1, 4, "abcde", 2, 4, -1);
+ test("abcde", 1, 4, "abcde", 4, 0, 4);
+ test("abcde", 1, 4, "abcde", 4, 1, -3);
+ test("abcde", 1, 4, "abcde", 4, 2, -3);
+ test("abcde", 1, 4, "abcde", 5, 0, 4);
+ test("abcde", 1, 4, "abcde", 5, 1, 4);
+ test("abcde", 1, 4, "abcde", 6, 0, 0);
+ test("abcde", 1, 4, "abcdefghij", 0, 0, 4);
+ test("abcde", 1, 4, "abcdefghij", 0, 1, 1);
+ test("abcde", 1, 4, "abcdefghij", 0, 5, 1);
+ test("abcde", 1, 4, "abcdefghij", 0, 9, 1);
+ test("abcde", 1, 4, "abcdefghij", 0, 10, 1);
+ test("abcde", 1, 4, "abcdefghij", 0, 11, 1);
+ test("abcde", 1, 4, "abcdefghij", 1, 0, 4);
+ test("abcde", 1, 4, "abcdefghij", 1, 1, 3);
+ test("abcde", 1, 4, "abcdefghij", 1, 4, 0);
+ test("abcde", 1, 4, "abcdefghij", 1, 8, -4);
+ test("abcde", 1, 4, "abcdefghij", 1, 9, -5);
+ test("abcde", 1, 4, "abcdefghij", 1, 10, -5);
+}
+
+void test10()
+{
+ test("abcde", 1, 4, "abcdefghij", 5, 0, 4);
+ test("abcde", 1, 4, "abcdefghij", 5, 1, -4);
+ test("abcde", 1, 4, "abcdefghij", 5, 2, -4);
+ test("abcde", 1, 4, "abcdefghij", 5, 4, -4);
+ test("abcde", 1, 4, "abcdefghij", 5, 5, -4);
+ test("abcde", 1, 4, "abcdefghij", 5, 6, -4);
+ test("abcde", 1, 4, "abcdefghij", 9, 0, 4);
+ test("abcde", 1, 4, "abcdefghij", 9, 1, -8);
+ test("abcde", 1, 4, "abcdefghij", 9, 2, -8);
+ test("abcde", 1, 4, "abcdefghij", 10, 0, 4);
+ test("abcde", 1, 4, "abcdefghij", 10, 1, 4);
+ test("abcde", 1, 4, "abcdefghij", 11, 0, 0);
+ test("abcde", 1, 4, "abcdefghijklmnopqrst", 0, 0, 4);
+ test("abcde", 1, 4, "abcdefghijklmnopqrst", 0, 1, 1);
+ test("abcde", 1, 4, "abcdefghijklmnopqrst", 0, 10, 1);
+ test("abcde", 1, 4, "abcdefghijklmnopqrst", 0, 19, 1);
+ test("abcde", 1, 4, "abcdefghijklmnopqrst", 0, 20, 1);
+ test("abcde", 1, 4, "abcdefghijklmnopqrst", 0, 21, 1);
+ test("abcde", 1, 4, "abcdefghijklmnopqrst", 1, 0, 4);
+ test("abcde", 1, 4, "abcdefghijklmnopqrst", 1, 1, 3);
+ test("abcde", 1, 4, "abcdefghijklmnopqrst", 1, 9, -5);
+ test("abcde", 1, 4, "abcdefghijklmnopqrst", 1, 18, -14);
+ test("abcde", 1, 4, "abcdefghijklmnopqrst", 1, 19, -15);
+ test("abcde", 1, 4, "abcdefghijklmnopqrst", 1, 20, -15);
+ test("abcde", 1, 4, "abcdefghijklmnopqrst", 10, 0, 4);
+ test("abcde", 1, 4, "abcdefghijklmnopqrst", 10, 1, -9);
+ test("abcde", 1, 4, "abcdefghijklmnopqrst", 10, 5, -9);
+ test("abcde", 1, 4, "abcdefghijklmnopqrst", 10, 9, -9);
+ test("abcde", 1, 4, "abcdefghijklmnopqrst", 10, 10, -9);
+ test("abcde", 1, 4, "abcdefghijklmnopqrst", 10, 11, -9);
+ test("abcde", 1, 4, "abcdefghijklmnopqrst", 19, 0, 4);
+ test("abcde", 1, 4, "abcdefghijklmnopqrst", 19, 1, -18);
+ test("abcde", 1, 4, "abcdefghijklmnopqrst", 19, 2, -18);
+ test("abcde", 1, 4, "abcdefghijklmnopqrst", 20, 0, 4);
+ test("abcde", 1, 4, "abcdefghijklmnopqrst", 20, 1, 4);
+ test("abcde", 1, 4, "abcdefghijklmnopqrst", 21, 0, 0);
+ test("abcde", 1, 5, "", 0, 0, 4);
+ test("abcde", 1, 5, "", 0, 1, 4);
+ test("abcde", 1, 5, "", 1, 0, 0);
+ test("abcde", 1, 5, "abcde", 0, 0, 4);
+ test("abcde", 1, 5, "abcde", 0, 1, 1);
+ test("abcde", 1, 5, "abcde", 0, 2, 1);
+ test("abcde", 1, 5, "abcde", 0, 4, 1);
+ test("abcde", 1, 5, "abcde", 0, 5, 1);
+ test("abcde", 1, 5, "abcde", 0, 6, 1);
+ test("abcde", 1, 5, "abcde", 1, 0, 4);
+ test("abcde", 1, 5, "abcde", 1, 1, 3);
+ test("abcde", 1, 5, "abcde", 1, 2, 2);
+ test("abcde", 1, 5, "abcde", 1, 3, 1);
+ test("abcde", 1, 5, "abcde", 1, 4, 0);
+ test("abcde", 1, 5, "abcde", 1, 5, 0);
+ test("abcde", 1, 5, "abcde", 2, 0, 4);
+ test("abcde", 1, 5, "abcde", 2, 1, -1);
+ test("abcde", 1, 5, "abcde", 2, 2, -1);
+ test("abcde", 1, 5, "abcde", 2, 3, -1);
+ test("abcde", 1, 5, "abcde", 2, 4, -1);
+ test("abcde", 1, 5, "abcde", 4, 0, 4);
+ test("abcde", 1, 5, "abcde", 4, 1, -3);
+ test("abcde", 1, 5, "abcde", 4, 2, -3);
+ test("abcde", 1, 5, "abcde", 5, 0, 4);
+ test("abcde", 1, 5, "abcde", 5, 1, 4);
+ test("abcde", 1, 5, "abcde", 6, 0, 0);
+ test("abcde", 1, 5, "abcdefghij", 0, 0, 4);
+ test("abcde", 1, 5, "abcdefghij", 0, 1, 1);
+ test("abcde", 1, 5, "abcdefghij", 0, 5, 1);
+ test("abcde", 1, 5, "abcdefghij", 0, 9, 1);
+ test("abcde", 1, 5, "abcdefghij", 0, 10, 1);
+ test("abcde", 1, 5, "abcdefghij", 0, 11, 1);
+ test("abcde", 1, 5, "abcdefghij", 1, 0, 4);
+ test("abcde", 1, 5, "abcdefghij", 1, 1, 3);
+ test("abcde", 1, 5, "abcdefghij", 1, 4, 0);
+ test("abcde", 1, 5, "abcdefghij", 1, 8, -4);
+ test("abcde", 1, 5, "abcdefghij", 1, 9, -5);
+ test("abcde", 1, 5, "abcdefghij", 1, 10, -5);
+ test("abcde", 1, 5, "abcdefghij", 5, 0, 4);
+ test("abcde", 1, 5, "abcdefghij", 5, 1, -4);
+ test("abcde", 1, 5, "abcdefghij", 5, 2, -4);
+ test("abcde", 1, 5, "abcdefghij", 5, 4, -4);
+ test("abcde", 1, 5, "abcdefghij", 5, 5, -4);
+ test("abcde", 1, 5, "abcdefghij", 5, 6, -4);
+ test("abcde", 1, 5, "abcdefghij", 9, 0, 4);
+ test("abcde", 1, 5, "abcdefghij", 9, 1, -8);
+ test("abcde", 1, 5, "abcdefghij", 9, 2, -8);
+ test("abcde", 1, 5, "abcdefghij", 10, 0, 4);
+ test("abcde", 1, 5, "abcdefghij", 10, 1, 4);
+ test("abcde", 1, 5, "abcdefghij", 11, 0, 0);
+ test("abcde", 1, 5, "abcdefghijklmnopqrst", 0, 0, 4);
+ test("abcde", 1, 5, "abcdefghijklmnopqrst", 0, 1, 1);
+ test("abcde", 1, 5, "abcdefghijklmnopqrst", 0, 10, 1);
+ test("abcde", 1, 5, "abcdefghijklmnopqrst", 0, 19, 1);
+ test("abcde", 1, 5, "abcdefghijklmnopqrst", 0, 20, 1);
+ test("abcde", 1, 5, "abcdefghijklmnopqrst", 0, 21, 1);
+ test("abcde", 1, 5, "abcdefghijklmnopqrst", 1, 0, 4);
+ test("abcde", 1, 5, "abcdefghijklmnopqrst", 1, 1, 3);
+ test("abcde", 1, 5, "abcdefghijklmnopqrst", 1, 9, -5);
+ test("abcde", 1, 5, "abcdefghijklmnopqrst", 1, 18, -14);
+ test("abcde", 1, 5, "abcdefghijklmnopqrst", 1, 19, -15);
+ test("abcde", 1, 5, "abcdefghijklmnopqrst", 1, 20, -15);
+ test("abcde", 1, 5, "abcdefghijklmnopqrst", 10, 0, 4);
+ test("abcde", 1, 5, "abcdefghijklmnopqrst", 10, 1, -9);
+}
+
+void test11()
+{
+ test("abcde", 1, 5, "abcdefghijklmnopqrst", 10, 5, -9);
+ test("abcde", 1, 5, "abcdefghijklmnopqrst", 10, 9, -9);
+ test("abcde", 1, 5, "abcdefghijklmnopqrst", 10, 10, -9);
+ test("abcde", 1, 5, "abcdefghijklmnopqrst", 10, 11, -9);
+ test("abcde", 1, 5, "abcdefghijklmnopqrst", 19, 0, 4);
+ test("abcde", 1, 5, "abcdefghijklmnopqrst", 19, 1, -18);
+ test("abcde", 1, 5, "abcdefghijklmnopqrst", 19, 2, -18);
+ test("abcde", 1, 5, "abcdefghijklmnopqrst", 20, 0, 4);
+ test("abcde", 1, 5, "abcdefghijklmnopqrst", 20, 1, 4);
+ test("abcde", 1, 5, "abcdefghijklmnopqrst", 21, 0, 0);
+ test("abcde", 2, 0, "", 0, 0, 0);
+ test("abcde", 2, 0, "", 0, 1, 0);
+ test("abcde", 2, 0, "", 1, 0, 0);
+ test("abcde", 2, 0, "abcde", 0, 0, 0);
+ test("abcde", 2, 0, "abcde", 0, 1, -1);
+ test("abcde", 2, 0, "abcde", 0, 2, -2);
+ test("abcde", 2, 0, "abcde", 0, 4, -4);
+ test("abcde", 2, 0, "abcde", 0, 5, -5);
+ test("abcde", 2, 0, "abcde", 0, 6, -5);
+ test("abcde", 2, 0, "abcde", 1, 0, 0);
+ test("abcde", 2, 0, "abcde", 1, 1, -1);
+ test("abcde", 2, 0, "abcde", 1, 2, -2);
+ test("abcde", 2, 0, "abcde", 1, 3, -3);
+ test("abcde", 2, 0, "abcde", 1, 4, -4);
+ test("abcde", 2, 0, "abcde", 1, 5, -4);
+ test("abcde", 2, 0, "abcde", 2, 0, 0);
+ test("abcde", 2, 0, "abcde", 2, 1, -1);
+ test("abcde", 2, 0, "abcde", 2, 2, -2);
+ test("abcde", 2, 0, "abcde", 2, 3, -3);
+ test("abcde", 2, 0, "abcde", 2, 4, -3);
+ test("abcde", 2, 0, "abcde", 4, 0, 0);
+ test("abcde", 2, 0, "abcde", 4, 1, -1);
+ test("abcde", 2, 0, "abcde", 4, 2, -1);
+ test("abcde", 2, 0, "abcde", 5, 0, 0);
+ test("abcde", 2, 0, "abcde", 5, 1, 0);
+ test("abcde", 2, 0, "abcde", 6, 0, 0);
+ test("abcde", 2, 0, "abcdefghij", 0, 0, 0);
+ test("abcde", 2, 0, "abcdefghij", 0, 1, -1);
+ test("abcde", 2, 0, "abcdefghij", 0, 5, -5);
+ test("abcde", 2, 0, "abcdefghij", 0, 9, -9);
+ test("abcde", 2, 0, "abcdefghij", 0, 10, -10);
+ test("abcde", 2, 0, "abcdefghij", 0, 11, -10);
+ test("abcde", 2, 0, "abcdefghij", 1, 0, 0);
+ test("abcde", 2, 0, "abcdefghij", 1, 1, -1);
+ test("abcde", 2, 0, "abcdefghij", 1, 4, -4);
+ test("abcde", 2, 0, "abcdefghij", 1, 8, -8);
+ test("abcde", 2, 0, "abcdefghij", 1, 9, -9);
+ test("abcde", 2, 0, "abcdefghij", 1, 10, -9);
+ test("abcde", 2, 0, "abcdefghij", 5, 0, 0);
+ test("abcde", 2, 0, "abcdefghij", 5, 1, -1);
+ test("abcde", 2, 0, "abcdefghij", 5, 2, -2);
+ test("abcde", 2, 0, "abcdefghij", 5, 4, -4);
+ test("abcde", 2, 0, "abcdefghij", 5, 5, -5);
+ test("abcde", 2, 0, "abcdefghij", 5, 6, -5);
+ test("abcde", 2, 0, "abcdefghij", 9, 0, 0);
+ test("abcde", 2, 0, "abcdefghij", 9, 1, -1);
+ test("abcde", 2, 0, "abcdefghij", 9, 2, -1);
+ test("abcde", 2, 0, "abcdefghij", 10, 0, 0);
+ test("abcde", 2, 0, "abcdefghij", 10, 1, 0);
+ test("abcde", 2, 0, "abcdefghij", 11, 0, 0);
+ test("abcde", 2, 0, "abcdefghijklmnopqrst", 0, 0, 0);
+ test("abcde", 2, 0, "abcdefghijklmnopqrst", 0, 1, -1);
+ test("abcde", 2, 0, "abcdefghijklmnopqrst", 0, 10, -10);
+ test("abcde", 2, 0, "abcdefghijklmnopqrst", 0, 19, -19);
+ test("abcde", 2, 0, "abcdefghijklmnopqrst", 0, 20, -20);
+ test("abcde", 2, 0, "abcdefghijklmnopqrst", 0, 21, -20);
+ test("abcde", 2, 0, "abcdefghijklmnopqrst", 1, 0, 0);
+ test("abcde", 2, 0, "abcdefghijklmnopqrst", 1, 1, -1);
+ test("abcde", 2, 0, "abcdefghijklmnopqrst", 1, 9, -9);
+ test("abcde", 2, 0, "abcdefghijklmnopqrst", 1, 18, -18);
+ test("abcde", 2, 0, "abcdefghijklmnopqrst", 1, 19, -19);
+ test("abcde", 2, 0, "abcdefghijklmnopqrst", 1, 20, -19);
+ test("abcde", 2, 0, "abcdefghijklmnopqrst", 10, 0, 0);
+ test("abcde", 2, 0, "abcdefghijklmnopqrst", 10, 1, -1);
+ test("abcde", 2, 0, "abcdefghijklmnopqrst", 10, 5, -5);
+ test("abcde", 2, 0, "abcdefghijklmnopqrst", 10, 9, -9);
+ test("abcde", 2, 0, "abcdefghijklmnopqrst", 10, 10, -10);
+ test("abcde", 2, 0, "abcdefghijklmnopqrst", 10, 11, -10);
+ test("abcde", 2, 0, "abcdefghijklmnopqrst", 19, 0, 0);
+ test("abcde", 2, 0, "abcdefghijklmnopqrst", 19, 1, -1);
+ test("abcde", 2, 0, "abcdefghijklmnopqrst", 19, 2, -1);
+ test("abcde", 2, 0, "abcdefghijklmnopqrst", 20, 0, 0);
+ test("abcde", 2, 0, "abcdefghijklmnopqrst", 20, 1, 0);
+ test("abcde", 2, 0, "abcdefghijklmnopqrst", 21, 0, 0);
+ test("abcde", 2, 1, "", 0, 0, 1);
+ test("abcde", 2, 1, "", 0, 1, 1);
+ test("abcde", 2, 1, "", 1, 0, 0);
+ test("abcde", 2, 1, "abcde", 0, 0, 1);
+ test("abcde", 2, 1, "abcde", 0, 1, 2);
+ test("abcde", 2, 1, "abcde", 0, 2, 2);
+ test("abcde", 2, 1, "abcde", 0, 4, 2);
+ test("abcde", 2, 1, "abcde", 0, 5, 2);
+ test("abcde", 2, 1, "abcde", 0, 6, 2);
+ test("abcde", 2, 1, "abcde", 1, 0, 1);
+ test("abcde", 2, 1, "abcde", 1, 1, 1);
+ test("abcde", 2, 1, "abcde", 1, 2, 1);
+ test("abcde", 2, 1, "abcde", 1, 3, 1);
+ test("abcde", 2, 1, "abcde", 1, 4, 1);
+ test("abcde", 2, 1, "abcde", 1, 5, 1);
+ test("abcde", 2, 1, "abcde", 2, 0, 1);
+}
+
+void test12()
+{
+ test("abcde", 2, 1, "abcde", 2, 1, 0);
+ test("abcde", 2, 1, "abcde", 2, 2, -1);
+ test("abcde", 2, 1, "abcde", 2, 3, -2);
+ test("abcde", 2, 1, "abcde", 2, 4, -2);
+ test("abcde", 2, 1, "abcde", 4, 0, 1);
+ test("abcde", 2, 1, "abcde", 4, 1, -2);
+ test("abcde", 2, 1, "abcde", 4, 2, -2);
+ test("abcde", 2, 1, "abcde", 5, 0, 1);
+ test("abcde", 2, 1, "abcde", 5, 1, 1);
+ test("abcde", 2, 1, "abcde", 6, 0, 0);
+ test("abcde", 2, 1, "abcdefghij", 0, 0, 1);
+ test("abcde", 2, 1, "abcdefghij", 0, 1, 2);
+ test("abcde", 2, 1, "abcdefghij", 0, 5, 2);
+ test("abcde", 2, 1, "abcdefghij", 0, 9, 2);
+ test("abcde", 2, 1, "abcdefghij", 0, 10, 2);
+ test("abcde", 2, 1, "abcdefghij", 0, 11, 2);
+ test("abcde", 2, 1, "abcdefghij", 1, 0, 1);
+ test("abcde", 2, 1, "abcdefghij", 1, 1, 1);
+ test("abcde", 2, 1, "abcdefghij", 1, 4, 1);
+ test("abcde", 2, 1, "abcdefghij", 1, 8, 1);
+ test("abcde", 2, 1, "abcdefghij", 1, 9, 1);
+ test("abcde", 2, 1, "abcdefghij", 1, 10, 1);
+ test("abcde", 2, 1, "abcdefghij", 5, 0, 1);
+ test("abcde", 2, 1, "abcdefghij", 5, 1, -3);
+ test("abcde", 2, 1, "abcdefghij", 5, 2, -3);
+ test("abcde", 2, 1, "abcdefghij", 5, 4, -3);
+ test("abcde", 2, 1, "abcdefghij", 5, 5, -3);
+ test("abcde", 2, 1, "abcdefghij", 5, 6, -3);
+ test("abcde", 2, 1, "abcdefghij", 9, 0, 1);
+ test("abcde", 2, 1, "abcdefghij", 9, 1, -7);
+ test("abcde", 2, 1, "abcdefghij", 9, 2, -7);
+ test("abcde", 2, 1, "abcdefghij", 10, 0, 1);
+ test("abcde", 2, 1, "abcdefghij", 10, 1, 1);
+ test("abcde", 2, 1, "abcdefghij", 11, 0, 0);
+ test("abcde", 2, 1, "abcdefghijklmnopqrst", 0, 0, 1);
+ test("abcde", 2, 1, "abcdefghijklmnopqrst", 0, 1, 2);
+ test("abcde", 2, 1, "abcdefghijklmnopqrst", 0, 10, 2);
+ test("abcde", 2, 1, "abcdefghijklmnopqrst", 0, 19, 2);
+ test("abcde", 2, 1, "abcdefghijklmnopqrst", 0, 20, 2);
+ test("abcde", 2, 1, "abcdefghijklmnopqrst", 0, 21, 2);
+ test("abcde", 2, 1, "abcdefghijklmnopqrst", 1, 0, 1);
+ test("abcde", 2, 1, "abcdefghijklmnopqrst", 1, 1, 1);
+ test("abcde", 2, 1, "abcdefghijklmnopqrst", 1, 9, 1);
+ test("abcde", 2, 1, "abcdefghijklmnopqrst", 1, 18, 1);
+ test("abcde", 2, 1, "abcdefghijklmnopqrst", 1, 19, 1);
+ test("abcde", 2, 1, "abcdefghijklmnopqrst", 1, 20, 1);
+ test("abcde", 2, 1, "abcdefghijklmnopqrst", 10, 0, 1);
+ test("abcde", 2, 1, "abcdefghijklmnopqrst", 10, 1, -8);
+ test("abcde", 2, 1, "abcdefghijklmnopqrst", 10, 5, -8);
+ test("abcde", 2, 1, "abcdefghijklmnopqrst", 10, 9, -8);
+ test("abcde", 2, 1, "abcdefghijklmnopqrst", 10, 10, -8);
+ test("abcde", 2, 1, "abcdefghijklmnopqrst", 10, 11, -8);
+ test("abcde", 2, 1, "abcdefghijklmnopqrst", 19, 0, 1);
+ test("abcde", 2, 1, "abcdefghijklmnopqrst", 19, 1, -17);
+ test("abcde", 2, 1, "abcdefghijklmnopqrst", 19, 2, -17);
+ test("abcde", 2, 1, "abcdefghijklmnopqrst", 20, 0, 1);
+ test("abcde", 2, 1, "abcdefghijklmnopqrst", 20, 1, 1);
+ test("abcde", 2, 1, "abcdefghijklmnopqrst", 21, 0, 0);
+ test("abcde", 2, 2, "", 0, 0, 2);
+ test("abcde", 2, 2, "", 0, 1, 2);
+ test("abcde", 2, 2, "", 1, 0, 0);
+ test("abcde", 2, 2, "abcde", 0, 0, 2);
+ test("abcde", 2, 2, "abcde", 0, 1, 2);
+ test("abcde", 2, 2, "abcde", 0, 2, 2);
+ test("abcde", 2, 2, "abcde", 0, 4, 2);
+ test("abcde", 2, 2, "abcde", 0, 5, 2);
+ test("abcde", 2, 2, "abcde", 0, 6, 2);
+ test("abcde", 2, 2, "abcde", 1, 0, 2);
+ test("abcde", 2, 2, "abcde", 1, 1, 1);
+ test("abcde", 2, 2, "abcde", 1, 2, 1);
+ test("abcde", 2, 2, "abcde", 1, 3, 1);
+ test("abcde", 2, 2, "abcde", 1, 4, 1);
+ test("abcde", 2, 2, "abcde", 1, 5, 1);
+ test("abcde", 2, 2, "abcde", 2, 0, 2);
+ test("abcde", 2, 2, "abcde", 2, 1, 1);
+ test("abcde", 2, 2, "abcde", 2, 2, 0);
+ test("abcde", 2, 2, "abcde", 2, 3, -1);
+ test("abcde", 2, 2, "abcde", 2, 4, -1);
+ test("abcde", 2, 2, "abcde", 4, 0, 2);
+ test("abcde", 2, 2, "abcde", 4, 1, -2);
+ test("abcde", 2, 2, "abcde", 4, 2, -2);
+ test("abcde", 2, 2, "abcde", 5, 0, 2);
+ test("abcde", 2, 2, "abcde", 5, 1, 2);
+ test("abcde", 2, 2, "abcde", 6, 0, 0);
+ test("abcde", 2, 2, "abcdefghij", 0, 0, 2);
+ test("abcde", 2, 2, "abcdefghij", 0, 1, 2);
+ test("abcde", 2, 2, "abcdefghij", 0, 5, 2);
+ test("abcde", 2, 2, "abcdefghij", 0, 9, 2);
+ test("abcde", 2, 2, "abcdefghij", 0, 10, 2);
+ test("abcde", 2, 2, "abcdefghij", 0, 11, 2);
+ test("abcde", 2, 2, "abcdefghij", 1, 0, 2);
+ test("abcde", 2, 2, "abcdefghij", 1, 1, 1);
+ test("abcde", 2, 2, "abcdefghij", 1, 4, 1);
+ test("abcde", 2, 2, "abcdefghij", 1, 8, 1);
+ test("abcde", 2, 2, "abcdefghij", 1, 9, 1);
+ test("abcde", 2, 2, "abcdefghij", 1, 10, 1);
+ test("abcde", 2, 2, "abcdefghij", 5, 0, 2);
+ test("abcde", 2, 2, "abcdefghij", 5, 1, -3);
+ test("abcde", 2, 2, "abcdefghij", 5, 2, -3);
+ test("abcde", 2, 2, "abcdefghij", 5, 4, -3);
+}
+
+void test13()
+{
+ test("abcde", 2, 2, "abcdefghij", 5, 5, -3);
+ test("abcde", 2, 2, "abcdefghij", 5, 6, -3);
+ test("abcde", 2, 2, "abcdefghij", 9, 0, 2);
+ test("abcde", 2, 2, "abcdefghij", 9, 1, -7);
+ test("abcde", 2, 2, "abcdefghij", 9, 2, -7);
+ test("abcde", 2, 2, "abcdefghij", 10, 0, 2);
+ test("abcde", 2, 2, "abcdefghij", 10, 1, 2);
+ test("abcde", 2, 2, "abcdefghij", 11, 0, 0);
+ test("abcde", 2, 2, "abcdefghijklmnopqrst", 0, 0, 2);
+ test("abcde", 2, 2, "abcdefghijklmnopqrst", 0, 1, 2);
+ test("abcde", 2, 2, "abcdefghijklmnopqrst", 0, 10, 2);
+ test("abcde", 2, 2, "abcdefghijklmnopqrst", 0, 19, 2);
+ test("abcde", 2, 2, "abcdefghijklmnopqrst", 0, 20, 2);
+ test("abcde", 2, 2, "abcdefghijklmnopqrst", 0, 21, 2);
+ test("abcde", 2, 2, "abcdefghijklmnopqrst", 1, 0, 2);
+ test("abcde", 2, 2, "abcdefghijklmnopqrst", 1, 1, 1);
+ test("abcde", 2, 2, "abcdefghijklmnopqrst", 1, 9, 1);
+ test("abcde", 2, 2, "abcdefghijklmnopqrst", 1, 18, 1);
+ test("abcde", 2, 2, "abcdefghijklmnopqrst", 1, 19, 1);
+ test("abcde", 2, 2, "abcdefghijklmnopqrst", 1, 20, 1);
+ test("abcde", 2, 2, "abcdefghijklmnopqrst", 10, 0, 2);
+ test("abcde", 2, 2, "abcdefghijklmnopqrst", 10, 1, -8);
+ test("abcde", 2, 2, "abcdefghijklmnopqrst", 10, 5, -8);
+ test("abcde", 2, 2, "abcdefghijklmnopqrst", 10, 9, -8);
+ test("abcde", 2, 2, "abcdefghijklmnopqrst", 10, 10, -8);
+ test("abcde", 2, 2, "abcdefghijklmnopqrst", 10, 11, -8);
+ test("abcde", 2, 2, "abcdefghijklmnopqrst", 19, 0, 2);
+ test("abcde", 2, 2, "abcdefghijklmnopqrst", 19, 1, -17);
+ test("abcde", 2, 2, "abcdefghijklmnopqrst", 19, 2, -17);
+ test("abcde", 2, 2, "abcdefghijklmnopqrst", 20, 0, 2);
+ test("abcde", 2, 2, "abcdefghijklmnopqrst", 20, 1, 2);
+ test("abcde", 2, 2, "abcdefghijklmnopqrst", 21, 0, 0);
+ test("abcde", 2, 3, "", 0, 0, 3);
+ test("abcde", 2, 3, "", 0, 1, 3);
+ test("abcde", 2, 3, "", 1, 0, 0);
+ test("abcde", 2, 3, "abcde", 0, 0, 3);
+ test("abcde", 2, 3, "abcde", 0, 1, 2);
+ test("abcde", 2, 3, "abcde", 0, 2, 2);
+ test("abcde", 2, 3, "abcde", 0, 4, 2);
+ test("abcde", 2, 3, "abcde", 0, 5, 2);
+ test("abcde", 2, 3, "abcde", 0, 6, 2);
+ test("abcde", 2, 3, "abcde", 1, 0, 3);
+ test("abcde", 2, 3, "abcde", 1, 1, 1);
+ test("abcde", 2, 3, "abcde", 1, 2, 1);
+ test("abcde", 2, 3, "abcde", 1, 3, 1);
+ test("abcde", 2, 3, "abcde", 1, 4, 1);
+ test("abcde", 2, 3, "abcde", 1, 5, 1);
+ test("abcde", 2, 3, "abcde", 2, 0, 3);
+ test("abcde", 2, 3, "abcde", 2, 1, 2);
+ test("abcde", 2, 3, "abcde", 2, 2, 1);
+ test("abcde", 2, 3, "abcde", 2, 3, 0);
+ test("abcde", 2, 3, "abcde", 2, 4, 0);
+ test("abcde", 2, 3, "abcde", 4, 0, 3);
+ test("abcde", 2, 3, "abcde", 4, 1, -2);
+ test("abcde", 2, 3, "abcde", 4, 2, -2);
+ test("abcde", 2, 3, "abcde", 5, 0, 3);
+ test("abcde", 2, 3, "abcde", 5, 1, 3);
+ test("abcde", 2, 3, "abcde", 6, 0, 0);
+ test("abcde", 2, 3, "abcdefghij", 0, 0, 3);
+ test("abcde", 2, 3, "abcdefghij", 0, 1, 2);
+ test("abcde", 2, 3, "abcdefghij", 0, 5, 2);
+ test("abcde", 2, 3, "abcdefghij", 0, 9, 2);
+ test("abcde", 2, 3, "abcdefghij", 0, 10, 2);
+ test("abcde", 2, 3, "abcdefghij", 0, 11, 2);
+ test("abcde", 2, 3, "abcdefghij", 1, 0, 3);
+ test("abcde", 2, 3, "abcdefghij", 1, 1, 1);
+ test("abcde", 2, 3, "abcdefghij", 1, 4, 1);
+ test("abcde", 2, 3, "abcdefghij", 1, 8, 1);
+ test("abcde", 2, 3, "abcdefghij", 1, 9, 1);
+ test("abcde", 2, 3, "abcdefghij", 1, 10, 1);
+ test("abcde", 2, 3, "abcdefghij", 5, 0, 3);
+ test("abcde", 2, 3, "abcdefghij", 5, 1, -3);
+ test("abcde", 2, 3, "abcdefghij", 5, 2, -3);
+ test("abcde", 2, 3, "abcdefghij", 5, 4, -3);
+ test("abcde", 2, 3, "abcdefghij", 5, 5, -3);
+ test("abcde", 2, 3, "abcdefghij", 5, 6, -3);
+ test("abcde", 2, 3, "abcdefghij", 9, 0, 3);
+ test("abcde", 2, 3, "abcdefghij", 9, 1, -7);
+ test("abcde", 2, 3, "abcdefghij", 9, 2, -7);
+ test("abcde", 2, 3, "abcdefghij", 10, 0, 3);
+ test("abcde", 2, 3, "abcdefghij", 10, 1, 3);
+ test("abcde", 2, 3, "abcdefghij", 11, 0, 0);
+ test("abcde", 2, 3, "abcdefghijklmnopqrst", 0, 0, 3);
+ test("abcde", 2, 3, "abcdefghijklmnopqrst", 0, 1, 2);
+ test("abcde", 2, 3, "abcdefghijklmnopqrst", 0, 10, 2);
+ test("abcde", 2, 3, "abcdefghijklmnopqrst", 0, 19, 2);
+ test("abcde", 2, 3, "abcdefghijklmnopqrst", 0, 20, 2);
+ test("abcde", 2, 3, "abcdefghijklmnopqrst", 0, 21, 2);
+ test("abcde", 2, 3, "abcdefghijklmnopqrst", 1, 0, 3);
+ test("abcde", 2, 3, "abcdefghijklmnopqrst", 1, 1, 1);
+ test("abcde", 2, 3, "abcdefghijklmnopqrst", 1, 9, 1);
+ test("abcde", 2, 3, "abcdefghijklmnopqrst", 1, 18, 1);
+ test("abcde", 2, 3, "abcdefghijklmnopqrst", 1, 19, 1);
+ test("abcde", 2, 3, "abcdefghijklmnopqrst", 1, 20, 1);
+ test("abcde", 2, 3, "abcdefghijklmnopqrst", 10, 0, 3);
+ test("abcde", 2, 3, "abcdefghijklmnopqrst", 10, 1, -8);
+ test("abcde", 2, 3, "abcdefghijklmnopqrst", 10, 5, -8);
+ test("abcde", 2, 3, "abcdefghijklmnopqrst", 10, 9, -8);
+ test("abcde", 2, 3, "abcdefghijklmnopqrst", 10, 10, -8);
+ test("abcde", 2, 3, "abcdefghijklmnopqrst", 10, 11, -8);
+}
+
+void test14()
+{
+ test("abcde", 2, 3, "abcdefghijklmnopqrst", 19, 0, 3);
+ test("abcde", 2, 3, "abcdefghijklmnopqrst", 19, 1, -17);
+ test("abcde", 2, 3, "abcdefghijklmnopqrst", 19, 2, -17);
+ test("abcde", 2, 3, "abcdefghijklmnopqrst", 20, 0, 3);
+ test("abcde", 2, 3, "abcdefghijklmnopqrst", 20, 1, 3);
+ test("abcde", 2, 3, "abcdefghijklmnopqrst", 21, 0, 0);
+ test("abcde", 2, 4, "", 0, 0, 3);
+ test("abcde", 2, 4, "", 0, 1, 3);
+ test("abcde", 2, 4, "", 1, 0, 0);
+ test("abcde", 2, 4, "abcde", 0, 0, 3);
+ test("abcde", 2, 4, "abcde", 0, 1, 2);
+ test("abcde", 2, 4, "abcde", 0, 2, 2);
+ test("abcde", 2, 4, "abcde", 0, 4, 2);
+ test("abcde", 2, 4, "abcde", 0, 5, 2);
+ test("abcde", 2, 4, "abcde", 0, 6, 2);
+ test("abcde", 2, 4, "abcde", 1, 0, 3);
+ test("abcde", 2, 4, "abcde", 1, 1, 1);
+ test("abcde", 2, 4, "abcde", 1, 2, 1);
+ test("abcde", 2, 4, "abcde", 1, 3, 1);
+ test("abcde", 2, 4, "abcde", 1, 4, 1);
+ test("abcde", 2, 4, "abcde", 1, 5, 1);
+ test("abcde", 2, 4, "abcde", 2, 0, 3);
+ test("abcde", 2, 4, "abcde", 2, 1, 2);
+ test("abcde", 2, 4, "abcde", 2, 2, 1);
+ test("abcde", 2, 4, "abcde", 2, 3, 0);
+ test("abcde", 2, 4, "abcde", 2, 4, 0);
+ test("abcde", 2, 4, "abcde", 4, 0, 3);
+ test("abcde", 2, 4, "abcde", 4, 1, -2);
+ test("abcde", 2, 4, "abcde", 4, 2, -2);
+ test("abcde", 2, 4, "abcde", 5, 0, 3);
+ test("abcde", 2, 4, "abcde", 5, 1, 3);
+ test("abcde", 2, 4, "abcde", 6, 0, 0);
+ test("abcde", 2, 4, "abcdefghij", 0, 0, 3);
+ test("abcde", 2, 4, "abcdefghij", 0, 1, 2);
+ test("abcde", 2, 4, "abcdefghij", 0, 5, 2);
+ test("abcde", 2, 4, "abcdefghij", 0, 9, 2);
+ test("abcde", 2, 4, "abcdefghij", 0, 10, 2);
+ test("abcde", 2, 4, "abcdefghij", 0, 11, 2);
+ test("abcde", 2, 4, "abcdefghij", 1, 0, 3);
+ test("abcde", 2, 4, "abcdefghij", 1, 1, 1);
+ test("abcde", 2, 4, "abcdefghij", 1, 4, 1);
+ test("abcde", 2, 4, "abcdefghij", 1, 8, 1);
+ test("abcde", 2, 4, "abcdefghij", 1, 9, 1);
+ test("abcde", 2, 4, "abcdefghij", 1, 10, 1);
+ test("abcde", 2, 4, "abcdefghij", 5, 0, 3);
+ test("abcde", 2, 4, "abcdefghij", 5, 1, -3);
+ test("abcde", 2, 4, "abcdefghij", 5, 2, -3);
+ test("abcde", 2, 4, "abcdefghij", 5, 4, -3);
+ test("abcde", 2, 4, "abcdefghij", 5, 5, -3);
+ test("abcde", 2, 4, "abcdefghij", 5, 6, -3);
+ test("abcde", 2, 4, "abcdefghij", 9, 0, 3);
+ test("abcde", 2, 4, "abcdefghij", 9, 1, -7);
+ test("abcde", 2, 4, "abcdefghij", 9, 2, -7);
+ test("abcde", 2, 4, "abcdefghij", 10, 0, 3);
+ test("abcde", 2, 4, "abcdefghij", 10, 1, 3);
+ test("abcde", 2, 4, "abcdefghij", 11, 0, 0);
+ test("abcde", 2, 4, "abcdefghijklmnopqrst", 0, 0, 3);
+ test("abcde", 2, 4, "abcdefghijklmnopqrst", 0, 1, 2);
+ test("abcde", 2, 4, "abcdefghijklmnopqrst", 0, 10, 2);
+ test("abcde", 2, 4, "abcdefghijklmnopqrst", 0, 19, 2);
+ test("abcde", 2, 4, "abcdefghijklmnopqrst", 0, 20, 2);
+ test("abcde", 2, 4, "abcdefghijklmnopqrst", 0, 21, 2);
+ test("abcde", 2, 4, "abcdefghijklmnopqrst", 1, 0, 3);
+ test("abcde", 2, 4, "abcdefghijklmnopqrst", 1, 1, 1);
+ test("abcde", 2, 4, "abcdefghijklmnopqrst", 1, 9, 1);
+ test("abcde", 2, 4, "abcdefghijklmnopqrst", 1, 18, 1);
+ test("abcde", 2, 4, "abcdefghijklmnopqrst", 1, 19, 1);
+ test("abcde", 2, 4, "abcdefghijklmnopqrst", 1, 20, 1);
+ test("abcde", 2, 4, "abcdefghijklmnopqrst", 10, 0, 3);
+ test("abcde", 2, 4, "abcdefghijklmnopqrst", 10, 1, -8);
+ test("abcde", 2, 4, "abcdefghijklmnopqrst", 10, 5, -8);
+ test("abcde", 2, 4, "abcdefghijklmnopqrst", 10, 9, -8);
+ test("abcde", 2, 4, "abcdefghijklmnopqrst", 10, 10, -8);
+ test("abcde", 2, 4, "abcdefghijklmnopqrst", 10, 11, -8);
+ test("abcde", 2, 4, "abcdefghijklmnopqrst", 19, 0, 3);
+ test("abcde", 2, 4, "abcdefghijklmnopqrst", 19, 1, -17);
+ test("abcde", 2, 4, "abcdefghijklmnopqrst", 19, 2, -17);
+ test("abcde", 2, 4, "abcdefghijklmnopqrst", 20, 0, 3);
+ test("abcde", 2, 4, "abcdefghijklmnopqrst", 20, 1, 3);
+ test("abcde", 2, 4, "abcdefghijklmnopqrst", 21, 0, 0);
+ test("abcde", 4, 0, "", 0, 0, 0);
+ test("abcde", 4, 0, "", 0, 1, 0);
+ test("abcde", 4, 0, "", 1, 0, 0);
+ test("abcde", 4, 0, "abcde", 0, 0, 0);
+ test("abcde", 4, 0, "abcde", 0, 1, -1);
+ test("abcde", 4, 0, "abcde", 0, 2, -2);
+ test("abcde", 4, 0, "abcde", 0, 4, -4);
+ test("abcde", 4, 0, "abcde", 0, 5, -5);
+ test("abcde", 4, 0, "abcde", 0, 6, -5);
+ test("abcde", 4, 0, "abcde", 1, 0, 0);
+ test("abcde", 4, 0, "abcde", 1, 1, -1);
+ test("abcde", 4, 0, "abcde", 1, 2, -2);
+ test("abcde", 4, 0, "abcde", 1, 3, -3);
+ test("abcde", 4, 0, "abcde", 1, 4, -4);
+ test("abcde", 4, 0, "abcde", 1, 5, -4);
+ test("abcde", 4, 0, "abcde", 2, 0, 0);
+ test("abcde", 4, 0, "abcde", 2, 1, -1);
+ test("abcde", 4, 0, "abcde", 2, 2, -2);
+ test("abcde", 4, 0, "abcde", 2, 3, -3);
+ test("abcde", 4, 0, "abcde", 2, 4, -3);
+}
+
+void test15()
+{
+ test("abcde", 4, 0, "abcde", 4, 0, 0);
+ test("abcde", 4, 0, "abcde", 4, 1, -1);
+ test("abcde", 4, 0, "abcde", 4, 2, -1);
+ test("abcde", 4, 0, "abcde", 5, 0, 0);
+ test("abcde", 4, 0, "abcde", 5, 1, 0);
+ test("abcde", 4, 0, "abcde", 6, 0, 0);
+ test("abcde", 4, 0, "abcdefghij", 0, 0, 0);
+ test("abcde", 4, 0, "abcdefghij", 0, 1, -1);
+ test("abcde", 4, 0, "abcdefghij", 0, 5, -5);
+ test("abcde", 4, 0, "abcdefghij", 0, 9, -9);
+ test("abcde", 4, 0, "abcdefghij", 0, 10, -10);
+ test("abcde", 4, 0, "abcdefghij", 0, 11, -10);
+ test("abcde", 4, 0, "abcdefghij", 1, 0, 0);
+ test("abcde", 4, 0, "abcdefghij", 1, 1, -1);
+ test("abcde", 4, 0, "abcdefghij", 1, 4, -4);
+ test("abcde", 4, 0, "abcdefghij", 1, 8, -8);
+ test("abcde", 4, 0, "abcdefghij", 1, 9, -9);
+ test("abcde", 4, 0, "abcdefghij", 1, 10, -9);
+ test("abcde", 4, 0, "abcdefghij", 5, 0, 0);
+ test("abcde", 4, 0, "abcdefghij", 5, 1, -1);
+ test("abcde", 4, 0, "abcdefghij", 5, 2, -2);
+ test("abcde", 4, 0, "abcdefghij", 5, 4, -4);
+ test("abcde", 4, 0, "abcdefghij", 5, 5, -5);
+ test("abcde", 4, 0, "abcdefghij", 5, 6, -5);
+ test("abcde", 4, 0, "abcdefghij", 9, 0, 0);
+ test("abcde", 4, 0, "abcdefghij", 9, 1, -1);
+ test("abcde", 4, 0, "abcdefghij", 9, 2, -1);
+ test("abcde", 4, 0, "abcdefghij", 10, 0, 0);
+ test("abcde", 4, 0, "abcdefghij", 10, 1, 0);
+ test("abcde", 4, 0, "abcdefghij", 11, 0, 0);
+ test("abcde", 4, 0, "abcdefghijklmnopqrst", 0, 0, 0);
+ test("abcde", 4, 0, "abcdefghijklmnopqrst", 0, 1, -1);
+ test("abcde", 4, 0, "abcdefghijklmnopqrst", 0, 10, -10);
+ test("abcde", 4, 0, "abcdefghijklmnopqrst", 0, 19, -19);
+ test("abcde", 4, 0, "abcdefghijklmnopqrst", 0, 20, -20);
+ test("abcde", 4, 0, "abcdefghijklmnopqrst", 0, 21, -20);
+ test("abcde", 4, 0, "abcdefghijklmnopqrst", 1, 0, 0);
+ test("abcde", 4, 0, "abcdefghijklmnopqrst", 1, 1, -1);
+ test("abcde", 4, 0, "abcdefghijklmnopqrst", 1, 9, -9);
+ test("abcde", 4, 0, "abcdefghijklmnopqrst", 1, 18, -18);
+ test("abcde", 4, 0, "abcdefghijklmnopqrst", 1, 19, -19);
+ test("abcde", 4, 0, "abcdefghijklmnopqrst", 1, 20, -19);
+ test("abcde", 4, 0, "abcdefghijklmnopqrst", 10, 0, 0);
+ test("abcde", 4, 0, "abcdefghijklmnopqrst", 10, 1, -1);
+ test("abcde", 4, 0, "abcdefghijklmnopqrst", 10, 5, -5);
+ test("abcde", 4, 0, "abcdefghijklmnopqrst", 10, 9, -9);
+ test("abcde", 4, 0, "abcdefghijklmnopqrst", 10, 10, -10);
+ test("abcde", 4, 0, "abcdefghijklmnopqrst", 10, 11, -10);
+ test("abcde", 4, 0, "abcdefghijklmnopqrst", 19, 0, 0);
+ test("abcde", 4, 0, "abcdefghijklmnopqrst", 19, 1, -1);
+ test("abcde", 4, 0, "abcdefghijklmnopqrst", 19, 2, -1);
+ test("abcde", 4, 0, "abcdefghijklmnopqrst", 20, 0, 0);
+ test("abcde", 4, 0, "abcdefghijklmnopqrst", 20, 1, 0);
+ test("abcde", 4, 0, "abcdefghijklmnopqrst", 21, 0, 0);
+ test("abcde", 4, 1, "", 0, 0, 1);
+ test("abcde", 4, 1, "", 0, 1, 1);
+ test("abcde", 4, 1, "", 1, 0, 0);
+ test("abcde", 4, 1, "abcde", 0, 0, 1);
+ test("abcde", 4, 1, "abcde", 0, 1, 4);
+ test("abcde", 4, 1, "abcde", 0, 2, 4);
+ test("abcde", 4, 1, "abcde", 0, 4, 4);
+ test("abcde", 4, 1, "abcde", 0, 5, 4);
+ test("abcde", 4, 1, "abcde", 0, 6, 4);
+ test("abcde", 4, 1, "abcde", 1, 0, 1);
+ test("abcde", 4, 1, "abcde", 1, 1, 3);
+ test("abcde", 4, 1, "abcde", 1, 2, 3);
+ test("abcde", 4, 1, "abcde", 1, 3, 3);
+ test("abcde", 4, 1, "abcde", 1, 4, 3);
+ test("abcde", 4, 1, "abcde", 1, 5, 3);
+ test("abcde", 4, 1, "abcde", 2, 0, 1);
+ test("abcde", 4, 1, "abcde", 2, 1, 2);
+ test("abcde", 4, 1, "abcde", 2, 2, 2);
+ test("abcde", 4, 1, "abcde", 2, 3, 2);
+ test("abcde", 4, 1, "abcde", 2, 4, 2);
+ test("abcde", 4, 1, "abcde", 4, 0, 1);
+ test("abcde", 4, 1, "abcde", 4, 1, 0);
+ test("abcde", 4, 1, "abcde", 4, 2, 0);
+ test("abcde", 4, 1, "abcde", 5, 0, 1);
+ test("abcde", 4, 1, "abcde", 5, 1, 1);
+ test("abcde", 4, 1, "abcde", 6, 0, 0);
+ test("abcde", 4, 1, "abcdefghij", 0, 0, 1);
+ test("abcde", 4, 1, "abcdefghij", 0, 1, 4);
+ test("abcde", 4, 1, "abcdefghij", 0, 5, 4);
+ test("abcde", 4, 1, "abcdefghij", 0, 9, 4);
+ test("abcde", 4, 1, "abcdefghij", 0, 10, 4);
+ test("abcde", 4, 1, "abcdefghij", 0, 11, 4);
+ test("abcde", 4, 1, "abcdefghij", 1, 0, 1);
+ test("abcde", 4, 1, "abcdefghij", 1, 1, 3);
+ test("abcde", 4, 1, "abcdefghij", 1, 4, 3);
+ test("abcde", 4, 1, "abcdefghij", 1, 8, 3);
+ test("abcde", 4, 1, "abcdefghij", 1, 9, 3);
+ test("abcde", 4, 1, "abcdefghij", 1, 10, 3);
+ test("abcde", 4, 1, "abcdefghij", 5, 0, 1);
+ test("abcde", 4, 1, "abcdefghij", 5, 1, -1);
+ test("abcde", 4, 1, "abcdefghij", 5, 2, -1);
+ test("abcde", 4, 1, "abcdefghij", 5, 4, -1);
+ test("abcde", 4, 1, "abcdefghij", 5, 5, -1);
+ test("abcde", 4, 1, "abcdefghij", 5, 6, -1);
+ test("abcde", 4, 1, "abcdefghij", 9, 0, 1);
+ test("abcde", 4, 1, "abcdefghij", 9, 1, -5);
+}
+
+void test16()
+{
+ test("abcde", 4, 1, "abcdefghij", 9, 2, -5);
+ test("abcde", 4, 1, "abcdefghij", 10, 0, 1);
+ test("abcde", 4, 1, "abcdefghij", 10, 1, 1);
+ test("abcde", 4, 1, "abcdefghij", 11, 0, 0);
+ test("abcde", 4, 1, "abcdefghijklmnopqrst", 0, 0, 1);
+ test("abcde", 4, 1, "abcdefghijklmnopqrst", 0, 1, 4);
+ test("abcde", 4, 1, "abcdefghijklmnopqrst", 0, 10, 4);
+ test("abcde", 4, 1, "abcdefghijklmnopqrst", 0, 19, 4);
+ test("abcde", 4, 1, "abcdefghijklmnopqrst", 0, 20, 4);
+ test("abcde", 4, 1, "abcdefghijklmnopqrst", 0, 21, 4);
+ test("abcde", 4, 1, "abcdefghijklmnopqrst", 1, 0, 1);
+ test("abcde", 4, 1, "abcdefghijklmnopqrst", 1, 1, 3);
+ test("abcde", 4, 1, "abcdefghijklmnopqrst", 1, 9, 3);
+ test("abcde", 4, 1, "abcdefghijklmnopqrst", 1, 18, 3);
+ test("abcde", 4, 1, "abcdefghijklmnopqrst", 1, 19, 3);
+ test("abcde", 4, 1, "abcdefghijklmnopqrst", 1, 20, 3);
+ test("abcde", 4, 1, "abcdefghijklmnopqrst", 10, 0, 1);
+ test("abcde", 4, 1, "abcdefghijklmnopqrst", 10, 1, -6);
+ test("abcde", 4, 1, "abcdefghijklmnopqrst", 10, 5, -6);
+ test("abcde", 4, 1, "abcdefghijklmnopqrst", 10, 9, -6);
+ test("abcde", 4, 1, "abcdefghijklmnopqrst", 10, 10, -6);
+ test("abcde", 4, 1, "abcdefghijklmnopqrst", 10, 11, -6);
+ test("abcde", 4, 1, "abcdefghijklmnopqrst", 19, 0, 1);
+ test("abcde", 4, 1, "abcdefghijklmnopqrst", 19, 1, -15);
+ test("abcde", 4, 1, "abcdefghijklmnopqrst", 19, 2, -15);
+ test("abcde", 4, 1, "abcdefghijklmnopqrst", 20, 0, 1);
+ test("abcde", 4, 1, "abcdefghijklmnopqrst", 20, 1, 1);
+ test("abcde", 4, 1, "abcdefghijklmnopqrst", 21, 0, 0);
+ test("abcde", 4, 2, "", 0, 0, 1);
+ test("abcde", 4, 2, "", 0, 1, 1);
+ test("abcde", 4, 2, "", 1, 0, 0);
+ test("abcde", 4, 2, "abcde", 0, 0, 1);
+ test("abcde", 4, 2, "abcde", 0, 1, 4);
+ test("abcde", 4, 2, "abcde", 0, 2, 4);
+ test("abcde", 4, 2, "abcde", 0, 4, 4);
+ test("abcde", 4, 2, "abcde", 0, 5, 4);
+ test("abcde", 4, 2, "abcde", 0, 6, 4);
+ test("abcde", 4, 2, "abcde", 1, 0, 1);
+ test("abcde", 4, 2, "abcde", 1, 1, 3);
+ test("abcde", 4, 2, "abcde", 1, 2, 3);
+ test("abcde", 4, 2, "abcde", 1, 3, 3);
+ test("abcde", 4, 2, "abcde", 1, 4, 3);
+ test("abcde", 4, 2, "abcde", 1, 5, 3);
+ test("abcde", 4, 2, "abcde", 2, 0, 1);
+ test("abcde", 4, 2, "abcde", 2, 1, 2);
+ test("abcde", 4, 2, "abcde", 2, 2, 2);
+ test("abcde", 4, 2, "abcde", 2, 3, 2);
+ test("abcde", 4, 2, "abcde", 2, 4, 2);
+ test("abcde", 4, 2, "abcde", 4, 0, 1);
+ test("abcde", 4, 2, "abcde", 4, 1, 0);
+ test("abcde", 4, 2, "abcde", 4, 2, 0);
+ test("abcde", 4, 2, "abcde", 5, 0, 1);
+ test("abcde", 4, 2, "abcde", 5, 1, 1);
+ test("abcde", 4, 2, "abcde", 6, 0, 0);
+ test("abcde", 4, 2, "abcdefghij", 0, 0, 1);
+ test("abcde", 4, 2, "abcdefghij", 0, 1, 4);
+ test("abcde", 4, 2, "abcdefghij", 0, 5, 4);
+ test("abcde", 4, 2, "abcdefghij", 0, 9, 4);
+ test("abcde", 4, 2, "abcdefghij", 0, 10, 4);
+ test("abcde", 4, 2, "abcdefghij", 0, 11, 4);
+ test("abcde", 4, 2, "abcdefghij", 1, 0, 1);
+ test("abcde", 4, 2, "abcdefghij", 1, 1, 3);
+ test("abcde", 4, 2, "abcdefghij", 1, 4, 3);
+ test("abcde", 4, 2, "abcdefghij", 1, 8, 3);
+ test("abcde", 4, 2, "abcdefghij", 1, 9, 3);
+ test("abcde", 4, 2, "abcdefghij", 1, 10, 3);
+ test("abcde", 4, 2, "abcdefghij", 5, 0, 1);
+ test("abcde", 4, 2, "abcdefghij", 5, 1, -1);
+ test("abcde", 4, 2, "abcdefghij", 5, 2, -1);
+ test("abcde", 4, 2, "abcdefghij", 5, 4, -1);
+ test("abcde", 4, 2, "abcdefghij", 5, 5, -1);
+ test("abcde", 4, 2, "abcdefghij", 5, 6, -1);
+ test("abcde", 4, 2, "abcdefghij", 9, 0, 1);
+ test("abcde", 4, 2, "abcdefghij", 9, 1, -5);
+ test("abcde", 4, 2, "abcdefghij", 9, 2, -5);
+ test("abcde", 4, 2, "abcdefghij", 10, 0, 1);
+ test("abcde", 4, 2, "abcdefghij", 10, 1, 1);
+ test("abcde", 4, 2, "abcdefghij", 11, 0, 0);
+ test("abcde", 4, 2, "abcdefghijklmnopqrst", 0, 0, 1);
+ test("abcde", 4, 2, "abcdefghijklmnopqrst", 0, 1, 4);
+ test("abcde", 4, 2, "abcdefghijklmnopqrst", 0, 10, 4);
+ test("abcde", 4, 2, "abcdefghijklmnopqrst", 0, 19, 4);
+ test("abcde", 4, 2, "abcdefghijklmnopqrst", 0, 20, 4);
+ test("abcde", 4, 2, "abcdefghijklmnopqrst", 0, 21, 4);
+ test("abcde", 4, 2, "abcdefghijklmnopqrst", 1, 0, 1);
+ test("abcde", 4, 2, "abcdefghijklmnopqrst", 1, 1, 3);
+ test("abcde", 4, 2, "abcdefghijklmnopqrst", 1, 9, 3);
+ test("abcde", 4, 2, "abcdefghijklmnopqrst", 1, 18, 3);
+ test("abcde", 4, 2, "abcdefghijklmnopqrst", 1, 19, 3);
+ test("abcde", 4, 2, "abcdefghijklmnopqrst", 1, 20, 3);
+ test("abcde", 4, 2, "abcdefghijklmnopqrst", 10, 0, 1);
+ test("abcde", 4, 2, "abcdefghijklmnopqrst", 10, 1, -6);
+ test("abcde", 4, 2, "abcdefghijklmnopqrst", 10, 5, -6);
+ test("abcde", 4, 2, "abcdefghijklmnopqrst", 10, 9, -6);
+ test("abcde", 4, 2, "abcdefghijklmnopqrst", 10, 10, -6);
+ test("abcde", 4, 2, "abcdefghijklmnopqrst", 10, 11, -6);
+ test("abcde", 4, 2, "abcdefghijklmnopqrst", 19, 0, 1);
+ test("abcde", 4, 2, "abcdefghijklmnopqrst", 19, 1, -15);
+ test("abcde", 4, 2, "abcdefghijklmnopqrst", 19, 2, -15);
+ test("abcde", 4, 2, "abcdefghijklmnopqrst", 20, 0, 1);
+}
+
+void test17()
+{
+ test("abcde", 4, 2, "abcdefghijklmnopqrst", 20, 1, 1);
+ test("abcde", 4, 2, "abcdefghijklmnopqrst", 21, 0, 0);
+ test("abcde", 5, 0, "", 0, 0, 0);
+ test("abcde", 5, 0, "", 0, 1, 0);
+ test("abcde", 5, 0, "", 1, 0, 0);
+ test("abcde", 5, 0, "abcde", 0, 0, 0);
+ test("abcde", 5, 0, "abcde", 0, 1, -1);
+ test("abcde", 5, 0, "abcde", 0, 2, -2);
+ test("abcde", 5, 0, "abcde", 0, 4, -4);
+ test("abcde", 5, 0, "abcde", 0, 5, -5);
+ test("abcde", 5, 0, "abcde", 0, 6, -5);
+ test("abcde", 5, 0, "abcde", 1, 0, 0);
+ test("abcde", 5, 0, "abcde", 1, 1, -1);
+ test("abcde", 5, 0, "abcde", 1, 2, -2);
+ test("abcde", 5, 0, "abcde", 1, 3, -3);
+ test("abcde", 5, 0, "abcde", 1, 4, -4);
+ test("abcde", 5, 0, "abcde", 1, 5, -4);
+ test("abcde", 5, 0, "abcde", 2, 0, 0);
+ test("abcde", 5, 0, "abcde", 2, 1, -1);
+ test("abcde", 5, 0, "abcde", 2, 2, -2);
+ test("abcde", 5, 0, "abcde", 2, 3, -3);
+ test("abcde", 5, 0, "abcde", 2, 4, -3);
+ test("abcde", 5, 0, "abcde", 4, 0, 0);
+ test("abcde", 5, 0, "abcde", 4, 1, -1);
+ test("abcde", 5, 0, "abcde", 4, 2, -1);
+ test("abcde", 5, 0, "abcde", 5, 0, 0);
+ test("abcde", 5, 0, "abcde", 5, 1, 0);
+ test("abcde", 5, 0, "abcde", 6, 0, 0);
+ test("abcde", 5, 0, "abcdefghij", 0, 0, 0);
+ test("abcde", 5, 0, "abcdefghij", 0, 1, -1);
+ test("abcde", 5, 0, "abcdefghij", 0, 5, -5);
+ test("abcde", 5, 0, "abcdefghij", 0, 9, -9);
+ test("abcde", 5, 0, "abcdefghij", 0, 10, -10);
+ test("abcde", 5, 0, "abcdefghij", 0, 11, -10);
+ test("abcde", 5, 0, "abcdefghij", 1, 0, 0);
+ test("abcde", 5, 0, "abcdefghij", 1, 1, -1);
+ test("abcde", 5, 0, "abcdefghij", 1, 4, -4);
+ test("abcde", 5, 0, "abcdefghij", 1, 8, -8);
+ test("abcde", 5, 0, "abcdefghij", 1, 9, -9);
+ test("abcde", 5, 0, "abcdefghij", 1, 10, -9);
+ test("abcde", 5, 0, "abcdefghij", 5, 0, 0);
+ test("abcde", 5, 0, "abcdefghij", 5, 1, -1);
+ test("abcde", 5, 0, "abcdefghij", 5, 2, -2);
+ test("abcde", 5, 0, "abcdefghij", 5, 4, -4);
+ test("abcde", 5, 0, "abcdefghij", 5, 5, -5);
+ test("abcde", 5, 0, "abcdefghij", 5, 6, -5);
+ test("abcde", 5, 0, "abcdefghij", 9, 0, 0);
+ test("abcde", 5, 0, "abcdefghij", 9, 1, -1);
+ test("abcde", 5, 0, "abcdefghij", 9, 2, -1);
+ test("abcde", 5, 0, "abcdefghij", 10, 0, 0);
+ test("abcde", 5, 0, "abcdefghij", 10, 1, 0);
+ test("abcde", 5, 0, "abcdefghij", 11, 0, 0);
+ test("abcde", 5, 0, "abcdefghijklmnopqrst", 0, 0, 0);
+ test("abcde", 5, 0, "abcdefghijklmnopqrst", 0, 1, -1);
+ test("abcde", 5, 0, "abcdefghijklmnopqrst", 0, 10, -10);
+ test("abcde", 5, 0, "abcdefghijklmnopqrst", 0, 19, -19);
+ test("abcde", 5, 0, "abcdefghijklmnopqrst", 0, 20, -20);
+ test("abcde", 5, 0, "abcdefghijklmnopqrst", 0, 21, -20);
+ test("abcde", 5, 0, "abcdefghijklmnopqrst", 1, 0, 0);
+ test("abcde", 5, 0, "abcdefghijklmnopqrst", 1, 1, -1);
+ test("abcde", 5, 0, "abcdefghijklmnopqrst", 1, 9, -9);
+ test("abcde", 5, 0, "abcdefghijklmnopqrst", 1, 18, -18);
+ test("abcde", 5, 0, "abcdefghijklmnopqrst", 1, 19, -19);
+ test("abcde", 5, 0, "abcdefghijklmnopqrst", 1, 20, -19);
+ test("abcde", 5, 0, "abcdefghijklmnopqrst", 10, 0, 0);
+ test("abcde", 5, 0, "abcdefghijklmnopqrst", 10, 1, -1);
+ test("abcde", 5, 0, "abcdefghijklmnopqrst", 10, 5, -5);
+ test("abcde", 5, 0, "abcdefghijklmnopqrst", 10, 9, -9);
+ test("abcde", 5, 0, "abcdefghijklmnopqrst", 10, 10, -10);
+ test("abcde", 5, 0, "abcdefghijklmnopqrst", 10, 11, -10);
+ test("abcde", 5, 0, "abcdefghijklmnopqrst", 19, 0, 0);
+ test("abcde", 5, 0, "abcdefghijklmnopqrst", 19, 1, -1);
+ test("abcde", 5, 0, "abcdefghijklmnopqrst", 19, 2, -1);
+ test("abcde", 5, 0, "abcdefghijklmnopqrst", 20, 0, 0);
+ test("abcde", 5, 0, "abcdefghijklmnopqrst", 20, 1, 0);
+ test("abcde", 5, 0, "abcdefghijklmnopqrst", 21, 0, 0);
+ test("abcde", 5, 1, "", 0, 0, 0);
+ test("abcde", 5, 1, "", 0, 1, 0);
+ test("abcde", 5, 1, "", 1, 0, 0);
+ test("abcde", 5, 1, "abcde", 0, 0, 0);
+ test("abcde", 5, 1, "abcde", 0, 1, -1);
+ test("abcde", 5, 1, "abcde", 0, 2, -2);
+ test("abcde", 5, 1, "abcde", 0, 4, -4);
+ test("abcde", 5, 1, "abcde", 0, 5, -5);
+ test("abcde", 5, 1, "abcde", 0, 6, -5);
+ test("abcde", 5, 1, "abcde", 1, 0, 0);
+ test("abcde", 5, 1, "abcde", 1, 1, -1);
+ test("abcde", 5, 1, "abcde", 1, 2, -2);
+ test("abcde", 5, 1, "abcde", 1, 3, -3);
+ test("abcde", 5, 1, "abcde", 1, 4, -4);
+ test("abcde", 5, 1, "abcde", 1, 5, -4);
+ test("abcde", 5, 1, "abcde", 2, 0, 0);
+ test("abcde", 5, 1, "abcde", 2, 1, -1);
+ test("abcde", 5, 1, "abcde", 2, 2, -2);
+ test("abcde", 5, 1, "abcde", 2, 3, -3);
+ test("abcde", 5, 1, "abcde", 2, 4, -3);
+ test("abcde", 5, 1, "abcde", 4, 0, 0);
+ test("abcde", 5, 1, "abcde", 4, 1, -1);
+ test("abcde", 5, 1, "abcde", 4, 2, -1);
+ test("abcde", 5, 1, "abcde", 5, 0, 0);
+}
+
+void test18()
+{
+ test("abcde", 5, 1, "abcde", 5, 1, 0);
+ test("abcde", 5, 1, "abcde", 6, 0, 0);
+ test("abcde", 5, 1, "abcdefghij", 0, 0, 0);
+ test("abcde", 5, 1, "abcdefghij", 0, 1, -1);
+ test("abcde", 5, 1, "abcdefghij", 0, 5, -5);
+ test("abcde", 5, 1, "abcdefghij", 0, 9, -9);
+ test("abcde", 5, 1, "abcdefghij", 0, 10, -10);
+ test("abcde", 5, 1, "abcdefghij", 0, 11, -10);
+ test("abcde", 5, 1, "abcdefghij", 1, 0, 0);
+ test("abcde", 5, 1, "abcdefghij", 1, 1, -1);
+ test("abcde", 5, 1, "abcdefghij", 1, 4, -4);
+ test("abcde", 5, 1, "abcdefghij", 1, 8, -8);
+ test("abcde", 5, 1, "abcdefghij", 1, 9, -9);
+ test("abcde", 5, 1, "abcdefghij", 1, 10, -9);
+ test("abcde", 5, 1, "abcdefghij", 5, 0, 0);
+ test("abcde", 5, 1, "abcdefghij", 5, 1, -1);
+ test("abcde", 5, 1, "abcdefghij", 5, 2, -2);
+ test("abcde", 5, 1, "abcdefghij", 5, 4, -4);
+ test("abcde", 5, 1, "abcdefghij", 5, 5, -5);
+ test("abcde", 5, 1, "abcdefghij", 5, 6, -5);
+ test("abcde", 5, 1, "abcdefghij", 9, 0, 0);
+ test("abcde", 5, 1, "abcdefghij", 9, 1, -1);
+ test("abcde", 5, 1, "abcdefghij", 9, 2, -1);
+ test("abcde", 5, 1, "abcdefghij", 10, 0, 0);
+ test("abcde", 5, 1, "abcdefghij", 10, 1, 0);
+ test("abcde", 5, 1, "abcdefghij", 11, 0, 0);
+ test("abcde", 5, 1, "abcdefghijklmnopqrst", 0, 0, 0);
+ test("abcde", 5, 1, "abcdefghijklmnopqrst", 0, 1, -1);
+ test("abcde", 5, 1, "abcdefghijklmnopqrst", 0, 10, -10);
+ test("abcde", 5, 1, "abcdefghijklmnopqrst", 0, 19, -19);
+ test("abcde", 5, 1, "abcdefghijklmnopqrst", 0, 20, -20);
+ test("abcde", 5, 1, "abcdefghijklmnopqrst", 0, 21, -20);
+ test("abcde", 5, 1, "abcdefghijklmnopqrst", 1, 0, 0);
+ test("abcde", 5, 1, "abcdefghijklmnopqrst", 1, 1, -1);
+ test("abcde", 5, 1, "abcdefghijklmnopqrst", 1, 9, -9);
+ test("abcde", 5, 1, "abcdefghijklmnopqrst", 1, 18, -18);
+ test("abcde", 5, 1, "abcdefghijklmnopqrst", 1, 19, -19);
+ test("abcde", 5, 1, "abcdefghijklmnopqrst", 1, 20, -19);
+ test("abcde", 5, 1, "abcdefghijklmnopqrst", 10, 0, 0);
+ test("abcde", 5, 1, "abcdefghijklmnopqrst", 10, 1, -1);
+ test("abcde", 5, 1, "abcdefghijklmnopqrst", 10, 5, -5);
+ test("abcde", 5, 1, "abcdefghijklmnopqrst", 10, 9, -9);
+ test("abcde", 5, 1, "abcdefghijklmnopqrst", 10, 10, -10);
+ test("abcde", 5, 1, "abcdefghijklmnopqrst", 10, 11, -10);
+ test("abcde", 5, 1, "abcdefghijklmnopqrst", 19, 0, 0);
+ test("abcde", 5, 1, "abcdefghijklmnopqrst", 19, 1, -1);
+ test("abcde", 5, 1, "abcdefghijklmnopqrst", 19, 2, -1);
+ test("abcde", 5, 1, "abcdefghijklmnopqrst", 20, 0, 0);
+ test("abcde", 5, 1, "abcdefghijklmnopqrst", 20, 1, 0);
+ test("abcde", 5, 1, "abcdefghijklmnopqrst", 21, 0, 0);
+ test("abcde", 6, 0, "", 0, 0, 0);
+ test("abcde", 6, 0, "", 0, 1, 0);
+ test("abcde", 6, 0, "", 1, 0, 0);
+ test("abcde", 6, 0, "abcde", 0, 0, 0);
+ test("abcde", 6, 0, "abcde", 0, 1, 0);
+ test("abcde", 6, 0, "abcde", 0, 2, 0);
+ test("abcde", 6, 0, "abcde", 0, 4, 0);
+ test("abcde", 6, 0, "abcde", 0, 5, 0);
+ test("abcde", 6, 0, "abcde", 0, 6, 0);
+ test("abcde", 6, 0, "abcde", 1, 0, 0);
+ test("abcde", 6, 0, "abcde", 1, 1, 0);
+ test("abcde", 6, 0, "abcde", 1, 2, 0);
+ test("abcde", 6, 0, "abcde", 1, 3, 0);
+ test("abcde", 6, 0, "abcde", 1, 4, 0);
+ test("abcde", 6, 0, "abcde", 1, 5, 0);
+ test("abcde", 6, 0, "abcde", 2, 0, 0);
+ test("abcde", 6, 0, "abcde", 2, 1, 0);
+ test("abcde", 6, 0, "abcde", 2, 2, 0);
+ test("abcde", 6, 0, "abcde", 2, 3, 0);
+ test("abcde", 6, 0, "abcde", 2, 4, 0);
+ test("abcde", 6, 0, "abcde", 4, 0, 0);
+ test("abcde", 6, 0, "abcde", 4, 1, 0);
+ test("abcde", 6, 0, "abcde", 4, 2, 0);
+ test("abcde", 6, 0, "abcde", 5, 0, 0);
+ test("abcde", 6, 0, "abcde", 5, 1, 0);
+ test("abcde", 6, 0, "abcde", 6, 0, 0);
+ test("abcde", 6, 0, "abcdefghij", 0, 0, 0);
+ test("abcde", 6, 0, "abcdefghij", 0, 1, 0);
+ test("abcde", 6, 0, "abcdefghij", 0, 5, 0);
+ test("abcde", 6, 0, "abcdefghij", 0, 9, 0);
+ test("abcde", 6, 0, "abcdefghij", 0, 10, 0);
+ test("abcde", 6, 0, "abcdefghij", 0, 11, 0);
+ test("abcde", 6, 0, "abcdefghij", 1, 0, 0);
+ test("abcde", 6, 0, "abcdefghij", 1, 1, 0);
+ test("abcde", 6, 0, "abcdefghij", 1, 4, 0);
+ test("abcde", 6, 0, "abcdefghij", 1, 8, 0);
+ test("abcde", 6, 0, "abcdefghij", 1, 9, 0);
+ test("abcde", 6, 0, "abcdefghij", 1, 10, 0);
+ test("abcde", 6, 0, "abcdefghij", 5, 0, 0);
+ test("abcde", 6, 0, "abcdefghij", 5, 1, 0);
+ test("abcde", 6, 0, "abcdefghij", 5, 2, 0);
+ test("abcde", 6, 0, "abcdefghij", 5, 4, 0);
+ test("abcde", 6, 0, "abcdefghij", 5, 5, 0);
+ test("abcde", 6, 0, "abcdefghij", 5, 6, 0);
+ test("abcde", 6, 0, "abcdefghij", 9, 0, 0);
+ test("abcde", 6, 0, "abcdefghij", 9, 1, 0);
+ test("abcde", 6, 0, "abcdefghij", 9, 2, 0);
+ test("abcde", 6, 0, "abcdefghij", 10, 0, 0);
+ test("abcde", 6, 0, "abcdefghij", 10, 1, 0);
+ test("abcde", 6, 0, "abcdefghij", 11, 0, 0);
+}
+
+void test19()
+{
+ test("abcde", 6, 0, "abcdefghijklmnopqrst", 0, 0, 0);
+ test("abcde", 6, 0, "abcdefghijklmnopqrst", 0, 1, 0);
+ test("abcde", 6, 0, "abcdefghijklmnopqrst", 0, 10, 0);
+ test("abcde", 6, 0, "abcdefghijklmnopqrst", 0, 19, 0);
+ test("abcde", 6, 0, "abcdefghijklmnopqrst", 0, 20, 0);
+ test("abcde", 6, 0, "abcdefghijklmnopqrst", 0, 21, 0);
+ test("abcde", 6, 0, "abcdefghijklmnopqrst", 1, 0, 0);
+ test("abcde", 6, 0, "abcdefghijklmnopqrst", 1, 1, 0);
+ test("abcde", 6, 0, "abcdefghijklmnopqrst", 1, 9, 0);
+ test("abcde", 6, 0, "abcdefghijklmnopqrst", 1, 18, 0);
+ test("abcde", 6, 0, "abcdefghijklmnopqrst", 1, 19, 0);
+ test("abcde", 6, 0, "abcdefghijklmnopqrst", 1, 20, 0);
+ test("abcde", 6, 0, "abcdefghijklmnopqrst", 10, 0, 0);
+ test("abcde", 6, 0, "abcdefghijklmnopqrst", 10, 1, 0);
+ test("abcde", 6, 0, "abcdefghijklmnopqrst", 10, 5, 0);
+ test("abcde", 6, 0, "abcdefghijklmnopqrst", 10, 9, 0);
+ test("abcde", 6, 0, "abcdefghijklmnopqrst", 10, 10, 0);
+ test("abcde", 6, 0, "abcdefghijklmnopqrst", 10, 11, 0);
+ test("abcde", 6, 0, "abcdefghijklmnopqrst", 19, 0, 0);
+ test("abcde", 6, 0, "abcdefghijklmnopqrst", 19, 1, 0);
+ test("abcde", 6, 0, "abcdefghijklmnopqrst", 19, 2, 0);
+ test("abcde", 6, 0, "abcdefghijklmnopqrst", 20, 0, 0);
+ test("abcde", 6, 0, "abcdefghijklmnopqrst", 20, 1, 0);
+ test("abcde", 6, 0, "abcdefghijklmnopqrst", 21, 0, 0);
+ test("abcdefghij", 0, 0, "", 0, 0, 0);
+ test("abcdefghij", 0, 0, "", 0, 1, 0);
+ test("abcdefghij", 0, 0, "", 1, 0, 0);
+ test("abcdefghij", 0, 0, "abcde", 0, 0, 0);
+ test("abcdefghij", 0, 0, "abcde", 0, 1, -1);
+ test("abcdefghij", 0, 0, "abcde", 0, 2, -2);
+ test("abcdefghij", 0, 0, "abcde", 0, 4, -4);
+ test("abcdefghij", 0, 0, "abcde", 0, 5, -5);
+ test("abcdefghij", 0, 0, "abcde", 0, 6, -5);
+ test("abcdefghij", 0, 0, "abcde", 1, 0, 0);
+ test("abcdefghij", 0, 0, "abcde", 1, 1, -1);
+ test("abcdefghij", 0, 0, "abcde", 1, 2, -2);
+ test("abcdefghij", 0, 0, "abcde", 1, 3, -3);
+ test("abcdefghij", 0, 0, "abcde", 1, 4, -4);
+ test("abcdefghij", 0, 0, "abcde", 1, 5, -4);
+ test("abcdefghij", 0, 0, "abcde", 2, 0, 0);
+ test("abcdefghij", 0, 0, "abcde", 2, 1, -1);
+ test("abcdefghij", 0, 0, "abcde", 2, 2, -2);
+ test("abcdefghij", 0, 0, "abcde", 2, 3, -3);
+ test("abcdefghij", 0, 0, "abcde", 2, 4, -3);
+ test("abcdefghij", 0, 0, "abcde", 4, 0, 0);
+ test("abcdefghij", 0, 0, "abcde", 4, 1, -1);
+ test("abcdefghij", 0, 0, "abcde", 4, 2, -1);
+ test("abcdefghij", 0, 0, "abcde", 5, 0, 0);
+ test("abcdefghij", 0, 0, "abcde", 5, 1, 0);
+ test("abcdefghij", 0, 0, "abcde", 6, 0, 0);
+ test("abcdefghij", 0, 0, "abcdefghij", 0, 0, 0);
+ test("abcdefghij", 0, 0, "abcdefghij", 0, 1, -1);
+ test("abcdefghij", 0, 0, "abcdefghij", 0, 5, -5);
+ test("abcdefghij", 0, 0, "abcdefghij", 0, 9, -9);
+ test("abcdefghij", 0, 0, "abcdefghij", 0, 10, -10);
+ test("abcdefghij", 0, 0, "abcdefghij", 0, 11, -10);
+ test("abcdefghij", 0, 0, "abcdefghij", 1, 0, 0);
+ test("abcdefghij", 0, 0, "abcdefghij", 1, 1, -1);
+ test("abcdefghij", 0, 0, "abcdefghij", 1, 4, -4);
+ test("abcdefghij", 0, 0, "abcdefghij", 1, 8, -8);
+ test("abcdefghij", 0, 0, "abcdefghij", 1, 9, -9);
+ test("abcdefghij", 0, 0, "abcdefghij", 1, 10, -9);
+ test("abcdefghij", 0, 0, "abcdefghij", 5, 0, 0);
+ test("abcdefghij", 0, 0, "abcdefghij", 5, 1, -1);
+ test("abcdefghij", 0, 0, "abcdefghij", 5, 2, -2);
+ test("abcdefghij", 0, 0, "abcdefghij", 5, 4, -4);
+ test("abcdefghij", 0, 0, "abcdefghij", 5, 5, -5);
+ test("abcdefghij", 0, 0, "abcdefghij", 5, 6, -5);
+ test("abcdefghij", 0, 0, "abcdefghij", 9, 0, 0);
+ test("abcdefghij", 0, 0, "abcdefghij", 9, 1, -1);
+ test("abcdefghij", 0, 0, "abcdefghij", 9, 2, -1);
+ test("abcdefghij", 0, 0, "abcdefghij", 10, 0, 0);
+ test("abcdefghij", 0, 0, "abcdefghij", 10, 1, 0);
+ test("abcdefghij", 0, 0, "abcdefghij", 11, 0, 0);
+ test("abcdefghij", 0, 0, "abcdefghijklmnopqrst", 0, 0, 0);
+ test("abcdefghij", 0, 0, "abcdefghijklmnopqrst", 0, 1, -1);
+ test("abcdefghij", 0, 0, "abcdefghijklmnopqrst", 0, 10, -10);
+ test("abcdefghij", 0, 0, "abcdefghijklmnopqrst", 0, 19, -19);
+ test("abcdefghij", 0, 0, "abcdefghijklmnopqrst", 0, 20, -20);
+ test("abcdefghij", 0, 0, "abcdefghijklmnopqrst", 0, 21, -20);
+ test("abcdefghij", 0, 0, "abcdefghijklmnopqrst", 1, 0, 0);
+ test("abcdefghij", 0, 0, "abcdefghijklmnopqrst", 1, 1, -1);
+ test("abcdefghij", 0, 0, "abcdefghijklmnopqrst", 1, 9, -9);
+ test("abcdefghij", 0, 0, "abcdefghijklmnopqrst", 1, 18, -18);
+ test("abcdefghij", 0, 0, "abcdefghijklmnopqrst", 1, 19, -19);
+ test("abcdefghij", 0, 0, "abcdefghijklmnopqrst", 1, 20, -19);
+ test("abcdefghij", 0, 0, "abcdefghijklmnopqrst", 10, 0, 0);
+ test("abcdefghij", 0, 0, "abcdefghijklmnopqrst", 10, 1, -1);
+ test("abcdefghij", 0, 0, "abcdefghijklmnopqrst", 10, 5, -5);
+ test("abcdefghij", 0, 0, "abcdefghijklmnopqrst", 10, 9, -9);
+ test("abcdefghij", 0, 0, "abcdefghijklmnopqrst", 10, 10, -10);
+ test("abcdefghij", 0, 0, "abcdefghijklmnopqrst", 10, 11, -10);
+ test("abcdefghij", 0, 0, "abcdefghijklmnopqrst", 19, 0, 0);
+ test("abcdefghij", 0, 0, "abcdefghijklmnopqrst", 19, 1, -1);
+ test("abcdefghij", 0, 0, "abcdefghijklmnopqrst", 19, 2, -1);
+ test("abcdefghij", 0, 0, "abcdefghijklmnopqrst", 20, 0, 0);
+ test("abcdefghij", 0, 0, "abcdefghijklmnopqrst", 20, 1, 0);
+ test("abcdefghij", 0, 0, "abcdefghijklmnopqrst", 21, 0, 0);
+ test("abcdefghij", 0, 1, "", 0, 0, 1);
+ test("abcdefghij", 0, 1, "", 0, 1, 1);
+}
+
+void test20()
+{
+ test("abcdefghij", 0, 1, "", 1, 0, 0);
+ test("abcdefghij", 0, 1, "abcde", 0, 0, 1);
+ test("abcdefghij", 0, 1, "abcde", 0, 1, 0);
+ test("abcdefghij", 0, 1, "abcde", 0, 2, -1);
+ test("abcdefghij", 0, 1, "abcde", 0, 4, -3);
+ test("abcdefghij", 0, 1, "abcde", 0, 5, -4);
+ test("abcdefghij", 0, 1, "abcde", 0, 6, -4);
+ test("abcdefghij", 0, 1, "abcde", 1, 0, 1);
+ test("abcdefghij", 0, 1, "abcde", 1, 1, -1);
+ test("abcdefghij", 0, 1, "abcde", 1, 2, -1);
+ test("abcdefghij", 0, 1, "abcde", 1, 3, -1);
+ test("abcdefghij", 0, 1, "abcde", 1, 4, -1);
+ test("abcdefghij", 0, 1, "abcde", 1, 5, -1);
+ test("abcdefghij", 0, 1, "abcde", 2, 0, 1);
+ test("abcdefghij", 0, 1, "abcde", 2, 1, -2);
+ test("abcdefghij", 0, 1, "abcde", 2, 2, -2);
+ test("abcdefghij", 0, 1, "abcde", 2, 3, -2);
+ test("abcdefghij", 0, 1, "abcde", 2, 4, -2);
+ test("abcdefghij", 0, 1, "abcde", 4, 0, 1);
+ test("abcdefghij", 0, 1, "abcde", 4, 1, -4);
+ test("abcdefghij", 0, 1, "abcde", 4, 2, -4);
+ test("abcdefghij", 0, 1, "abcde", 5, 0, 1);
+ test("abcdefghij", 0, 1, "abcde", 5, 1, 1);
+ test("abcdefghij", 0, 1, "abcde", 6, 0, 0);
+ test("abcdefghij", 0, 1, "abcdefghij", 0, 0, 1);
+ test("abcdefghij", 0, 1, "abcdefghij", 0, 1, 0);
+ test("abcdefghij", 0, 1, "abcdefghij", 0, 5, -4);
+ test("abcdefghij", 0, 1, "abcdefghij", 0, 9, -8);
+ test("abcdefghij", 0, 1, "abcdefghij", 0, 10, -9);
+ test("abcdefghij", 0, 1, "abcdefghij", 0, 11, -9);
+ test("abcdefghij", 0, 1, "abcdefghij", 1, 0, 1);
+ test("abcdefghij", 0, 1, "abcdefghij", 1, 1, -1);
+ test("abcdefghij", 0, 1, "abcdefghij", 1, 4, -1);
+ test("abcdefghij", 0, 1, "abcdefghij", 1, 8, -1);
+ test("abcdefghij", 0, 1, "abcdefghij", 1, 9, -1);
+ test("abcdefghij", 0, 1, "abcdefghij", 1, 10, -1);
+ test("abcdefghij", 0, 1, "abcdefghij", 5, 0, 1);
+ test("abcdefghij", 0, 1, "abcdefghij", 5, 1, -5);
+ test("abcdefghij", 0, 1, "abcdefghij", 5, 2, -5);
+ test("abcdefghij", 0, 1, "abcdefghij", 5, 4, -5);
+ test("abcdefghij", 0, 1, "abcdefghij", 5, 5, -5);
+ test("abcdefghij", 0, 1, "abcdefghij", 5, 6, -5);
+ test("abcdefghij", 0, 1, "abcdefghij", 9, 0, 1);
+ test("abcdefghij", 0, 1, "abcdefghij", 9, 1, -9);
+ test("abcdefghij", 0, 1, "abcdefghij", 9, 2, -9);
+ test("abcdefghij", 0, 1, "abcdefghij", 10, 0, 1);
+ test("abcdefghij", 0, 1, "abcdefghij", 10, 1, 1);
+ test("abcdefghij", 0, 1, "abcdefghij", 11, 0, 0);
+ test("abcdefghij", 0, 1, "abcdefghijklmnopqrst", 0, 0, 1);
+ test("abcdefghij", 0, 1, "abcdefghijklmnopqrst", 0, 1, 0);
+ test("abcdefghij", 0, 1, "abcdefghijklmnopqrst", 0, 10, -9);
+ test("abcdefghij", 0, 1, "abcdefghijklmnopqrst", 0, 19, -18);
+ test("abcdefghij", 0, 1, "abcdefghijklmnopqrst", 0, 20, -19);
+ test("abcdefghij", 0, 1, "abcdefghijklmnopqrst", 0, 21, -19);
+ test("abcdefghij", 0, 1, "abcdefghijklmnopqrst", 1, 0, 1);
+ test("abcdefghij", 0, 1, "abcdefghijklmnopqrst", 1, 1, -1);
+ test("abcdefghij", 0, 1, "abcdefghijklmnopqrst", 1, 9, -1);
+ test("abcdefghij", 0, 1, "abcdefghijklmnopqrst", 1, 18, -1);
+ test("abcdefghij", 0, 1, "abcdefghijklmnopqrst", 1, 19, -1);
+ test("abcdefghij", 0, 1, "abcdefghijklmnopqrst", 1, 20, -1);
+ test("abcdefghij", 0, 1, "abcdefghijklmnopqrst", 10, 0, 1);
+ test("abcdefghij", 0, 1, "abcdefghijklmnopqrst", 10, 1, -10);
+ test("abcdefghij", 0, 1, "abcdefghijklmnopqrst", 10, 5, -10);
+ test("abcdefghij", 0, 1, "abcdefghijklmnopqrst", 10, 9, -10);
+ test("abcdefghij", 0, 1, "abcdefghijklmnopqrst", 10, 10, -10);
+ test("abcdefghij", 0, 1, "abcdefghijklmnopqrst", 10, 11, -10);
+ test("abcdefghij", 0, 1, "abcdefghijklmnopqrst", 19, 0, 1);
+ test("abcdefghij", 0, 1, "abcdefghijklmnopqrst", 19, 1, -19);
+ test("abcdefghij", 0, 1, "abcdefghijklmnopqrst", 19, 2, -19);
+ test("abcdefghij", 0, 1, "abcdefghijklmnopqrst", 20, 0, 1);
+ test("abcdefghij", 0, 1, "abcdefghijklmnopqrst", 20, 1, 1);
+ test("abcdefghij", 0, 1, "abcdefghijklmnopqrst", 21, 0, 0);
+ test("abcdefghij", 0, 5, "", 0, 0, 5);
+ test("abcdefghij", 0, 5, "", 0, 1, 5);
+ test("abcdefghij", 0, 5, "", 1, 0, 0);
+ test("abcdefghij", 0, 5, "abcde", 0, 0, 5);
+ test("abcdefghij", 0, 5, "abcde", 0, 1, 4);
+ test("abcdefghij", 0, 5, "abcde", 0, 2, 3);
+ test("abcdefghij", 0, 5, "abcde", 0, 4, 1);
+ test("abcdefghij", 0, 5, "abcde", 0, 5, 0);
+ test("abcdefghij", 0, 5, "abcde", 0, 6, 0);
+ test("abcdefghij", 0, 5, "abcde", 1, 0, 5);
+ test("abcdefghij", 0, 5, "abcde", 1, 1, -1);
+ test("abcdefghij", 0, 5, "abcde", 1, 2, -1);
+ test("abcdefghij", 0, 5, "abcde", 1, 3, -1);
+ test("abcdefghij", 0, 5, "abcde", 1, 4, -1);
+ test("abcdefghij", 0, 5, "abcde", 1, 5, -1);
+ test("abcdefghij", 0, 5, "abcde", 2, 0, 5);
+ test("abcdefghij", 0, 5, "abcde", 2, 1, -2);
+ test("abcdefghij", 0, 5, "abcde", 2, 2, -2);
+ test("abcdefghij", 0, 5, "abcde", 2, 3, -2);
+ test("abcdefghij", 0, 5, "abcde", 2, 4, -2);
+ test("abcdefghij", 0, 5, "abcde", 4, 0, 5);
+ test("abcdefghij", 0, 5, "abcde", 4, 1, -4);
+ test("abcdefghij", 0, 5, "abcde", 4, 2, -4);
+ test("abcdefghij", 0, 5, "abcde", 5, 0, 5);
+ test("abcdefghij", 0, 5, "abcde", 5, 1, 5);
+ test("abcdefghij", 0, 5, "abcde", 6, 0, 0);
+ test("abcdefghij", 0, 5, "abcdefghij", 0, 0, 5);
+ test("abcdefghij", 0, 5, "abcdefghij", 0, 1, 4);
+}
+
+void test21()
+{
+ test("abcdefghij", 0, 5, "abcdefghij", 0, 5, 0);
+ test("abcdefghij", 0, 5, "abcdefghij", 0, 9, -4);
+ test("abcdefghij", 0, 5, "abcdefghij", 0, 10, -5);
+ test("abcdefghij", 0, 5, "abcdefghij", 0, 11, -5);
+ test("abcdefghij", 0, 5, "abcdefghij", 1, 0, 5);
+ test("abcdefghij", 0, 5, "abcdefghij", 1, 1, -1);
+ test("abcdefghij", 0, 5, "abcdefghij", 1, 4, -1);
+ test("abcdefghij", 0, 5, "abcdefghij", 1, 8, -1);
+ test("abcdefghij", 0, 5, "abcdefghij", 1, 9, -1);
+ test("abcdefghij", 0, 5, "abcdefghij", 1, 10, -1);
+ test("abcdefghij", 0, 5, "abcdefghij", 5, 0, 5);
+ test("abcdefghij", 0, 5, "abcdefghij", 5, 1, -5);
+ test("abcdefghij", 0, 5, "abcdefghij", 5, 2, -5);
+ test("abcdefghij", 0, 5, "abcdefghij", 5, 4, -5);
+ test("abcdefghij", 0, 5, "abcdefghij", 5, 5, -5);
+ test("abcdefghij", 0, 5, "abcdefghij", 5, 6, -5);
+ test("abcdefghij", 0, 5, "abcdefghij", 9, 0, 5);
+ test("abcdefghij", 0, 5, "abcdefghij", 9, 1, -9);
+ test("abcdefghij", 0, 5, "abcdefghij", 9, 2, -9);
+ test("abcdefghij", 0, 5, "abcdefghij", 10, 0, 5);
+ test("abcdefghij", 0, 5, "abcdefghij", 10, 1, 5);
+ test("abcdefghij", 0, 5, "abcdefghij", 11, 0, 0);
+ test("abcdefghij", 0, 5, "abcdefghijklmnopqrst", 0, 0, 5);
+ test("abcdefghij", 0, 5, "abcdefghijklmnopqrst", 0, 1, 4);
+ test("abcdefghij", 0, 5, "abcdefghijklmnopqrst", 0, 10, -5);
+ test("abcdefghij", 0, 5, "abcdefghijklmnopqrst", 0, 19, -14);
+ test("abcdefghij", 0, 5, "abcdefghijklmnopqrst", 0, 20, -15);
+ test("abcdefghij", 0, 5, "abcdefghijklmnopqrst", 0, 21, -15);
+ test("abcdefghij", 0, 5, "abcdefghijklmnopqrst", 1, 0, 5);
+ test("abcdefghij", 0, 5, "abcdefghijklmnopqrst", 1, 1, -1);
+ test("abcdefghij", 0, 5, "abcdefghijklmnopqrst", 1, 9, -1);
+ test("abcdefghij", 0, 5, "abcdefghijklmnopqrst", 1, 18, -1);
+ test("abcdefghij", 0, 5, "abcdefghijklmnopqrst", 1, 19, -1);
+ test("abcdefghij", 0, 5, "abcdefghijklmnopqrst", 1, 20, -1);
+ test("abcdefghij", 0, 5, "abcdefghijklmnopqrst", 10, 0, 5);
+ test("abcdefghij", 0, 5, "abcdefghijklmnopqrst", 10, 1, -10);
+ test("abcdefghij", 0, 5, "abcdefghijklmnopqrst", 10, 5, -10);
+ test("abcdefghij", 0, 5, "abcdefghijklmnopqrst", 10, 9, -10);
+ test("abcdefghij", 0, 5, "abcdefghijklmnopqrst", 10, 10, -10);
+ test("abcdefghij", 0, 5, "abcdefghijklmnopqrst", 10, 11, -10);
+ test("abcdefghij", 0, 5, "abcdefghijklmnopqrst", 19, 0, 5);
+ test("abcdefghij", 0, 5, "abcdefghijklmnopqrst", 19, 1, -19);
+ test("abcdefghij", 0, 5, "abcdefghijklmnopqrst", 19, 2, -19);
+ test("abcdefghij", 0, 5, "abcdefghijklmnopqrst", 20, 0, 5);
+ test("abcdefghij", 0, 5, "abcdefghijklmnopqrst", 20, 1, 5);
+ test("abcdefghij", 0, 5, "abcdefghijklmnopqrst", 21, 0, 0);
+ test("abcdefghij", 0, 9, "", 0, 0, 9);
+ test("abcdefghij", 0, 9, "", 0, 1, 9);
+ test("abcdefghij", 0, 9, "", 1, 0, 0);
+ test("abcdefghij", 0, 9, "abcde", 0, 0, 9);
+ test("abcdefghij", 0, 9, "abcde", 0, 1, 8);
+ test("abcdefghij", 0, 9, "abcde", 0, 2, 7);
+ test("abcdefghij", 0, 9, "abcde", 0, 4, 5);
+ test("abcdefghij", 0, 9, "abcde", 0, 5, 4);
+ test("abcdefghij", 0, 9, "abcde", 0, 6, 4);
+ test("abcdefghij", 0, 9, "abcde", 1, 0, 9);
+ test("abcdefghij", 0, 9, "abcde", 1, 1, -1);
+ test("abcdefghij", 0, 9, "abcde", 1, 2, -1);
+ test("abcdefghij", 0, 9, "abcde", 1, 3, -1);
+ test("abcdefghij", 0, 9, "abcde", 1, 4, -1);
+ test("abcdefghij", 0, 9, "abcde", 1, 5, -1);
+ test("abcdefghij", 0, 9, "abcde", 2, 0, 9);
+ test("abcdefghij", 0, 9, "abcde", 2, 1, -2);
+ test("abcdefghij", 0, 9, "abcde", 2, 2, -2);
+ test("abcdefghij", 0, 9, "abcde", 2, 3, -2);
+ test("abcdefghij", 0, 9, "abcde", 2, 4, -2);
+ test("abcdefghij", 0, 9, "abcde", 4, 0, 9);
+ test("abcdefghij", 0, 9, "abcde", 4, 1, -4);
+ test("abcdefghij", 0, 9, "abcde", 4, 2, -4);
+ test("abcdefghij", 0, 9, "abcde", 5, 0, 9);
+ test("abcdefghij", 0, 9, "abcde", 5, 1, 9);
+ test("abcdefghij", 0, 9, "abcde", 6, 0, 0);
+ test("abcdefghij", 0, 9, "abcdefghij", 0, 0, 9);
+ test("abcdefghij", 0, 9, "abcdefghij", 0, 1, 8);
+ test("abcdefghij", 0, 9, "abcdefghij", 0, 5, 4);
+ test("abcdefghij", 0, 9, "abcdefghij", 0, 9, 0);
+ test("abcdefghij", 0, 9, "abcdefghij", 0, 10, -1);
+ test("abcdefghij", 0, 9, "abcdefghij", 0, 11, -1);
+ test("abcdefghij", 0, 9, "abcdefghij", 1, 0, 9);
+ test("abcdefghij", 0, 9, "abcdefghij", 1, 1, -1);
+ test("abcdefghij", 0, 9, "abcdefghij", 1, 4, -1);
+ test("abcdefghij", 0, 9, "abcdefghij", 1, 8, -1);
+ test("abcdefghij", 0, 9, "abcdefghij", 1, 9, -1);
+ test("abcdefghij", 0, 9, "abcdefghij", 1, 10, -1);
+ test("abcdefghij", 0, 9, "abcdefghij", 5, 0, 9);
+ test("abcdefghij", 0, 9, "abcdefghij", 5, 1, -5);
+ test("abcdefghij", 0, 9, "abcdefghij", 5, 2, -5);
+ test("abcdefghij", 0, 9, "abcdefghij", 5, 4, -5);
+ test("abcdefghij", 0, 9, "abcdefghij", 5, 5, -5);
+ test("abcdefghij", 0, 9, "abcdefghij", 5, 6, -5);
+ test("abcdefghij", 0, 9, "abcdefghij", 9, 0, 9);
+ test("abcdefghij", 0, 9, "abcdefghij", 9, 1, -9);
+ test("abcdefghij", 0, 9, "abcdefghij", 9, 2, -9);
+ test("abcdefghij", 0, 9, "abcdefghij", 10, 0, 9);
+ test("abcdefghij", 0, 9, "abcdefghij", 10, 1, 9);
+ test("abcdefghij", 0, 9, "abcdefghij", 11, 0, 0);
+ test("abcdefghij", 0, 9, "abcdefghijklmnopqrst", 0, 0, 9);
+ test("abcdefghij", 0, 9, "abcdefghijklmnopqrst", 0, 1, 8);
+ test("abcdefghij", 0, 9, "abcdefghijklmnopqrst", 0, 10, -1);
+ test("abcdefghij", 0, 9, "abcdefghijklmnopqrst", 0, 19, -10);
+}
+
+void test22()
+{
+ test("abcdefghij", 0, 9, "abcdefghijklmnopqrst", 0, 20, -11);
+ test("abcdefghij", 0, 9, "abcdefghijklmnopqrst", 0, 21, -11);
+ test("abcdefghij", 0, 9, "abcdefghijklmnopqrst", 1, 0, 9);
+ test("abcdefghij", 0, 9, "abcdefghijklmnopqrst", 1, 1, -1);
+ test("abcdefghij", 0, 9, "abcdefghijklmnopqrst", 1, 9, -1);
+ test("abcdefghij", 0, 9, "abcdefghijklmnopqrst", 1, 18, -1);
+ test("abcdefghij", 0, 9, "abcdefghijklmnopqrst", 1, 19, -1);
+ test("abcdefghij", 0, 9, "abcdefghijklmnopqrst", 1, 20, -1);
+ test("abcdefghij", 0, 9, "abcdefghijklmnopqrst", 10, 0, 9);
+ test("abcdefghij", 0, 9, "abcdefghijklmnopqrst", 10, 1, -10);
+ test("abcdefghij", 0, 9, "abcdefghijklmnopqrst", 10, 5, -10);
+ test("abcdefghij", 0, 9, "abcdefghijklmnopqrst", 10, 9, -10);
+ test("abcdefghij", 0, 9, "abcdefghijklmnopqrst", 10, 10, -10);
+ test("abcdefghij", 0, 9, "abcdefghijklmnopqrst", 10, 11, -10);
+ test("abcdefghij", 0, 9, "abcdefghijklmnopqrst", 19, 0, 9);
+ test("abcdefghij", 0, 9, "abcdefghijklmnopqrst", 19, 1, -19);
+ test("abcdefghij", 0, 9, "abcdefghijklmnopqrst", 19, 2, -19);
+ test("abcdefghij", 0, 9, "abcdefghijklmnopqrst", 20, 0, 9);
+ test("abcdefghij", 0, 9, "abcdefghijklmnopqrst", 20, 1, 9);
+ test("abcdefghij", 0, 9, "abcdefghijklmnopqrst", 21, 0, 0);
+ test("abcdefghij", 0, 10, "", 0, 0, 10);
+ test("abcdefghij", 0, 10, "", 0, 1, 10);
+ test("abcdefghij", 0, 10, "", 1, 0, 0);
+ test("abcdefghij", 0, 10, "abcde", 0, 0, 10);
+ test("abcdefghij", 0, 10, "abcde", 0, 1, 9);
+ test("abcdefghij", 0, 10, "abcde", 0, 2, 8);
+ test("abcdefghij", 0, 10, "abcde", 0, 4, 6);
+ test("abcdefghij", 0, 10, "abcde", 0, 5, 5);
+ test("abcdefghij", 0, 10, "abcde", 0, 6, 5);
+ test("abcdefghij", 0, 10, "abcde", 1, 0, 10);
+ test("abcdefghij", 0, 10, "abcde", 1, 1, -1);
+ test("abcdefghij", 0, 10, "abcde", 1, 2, -1);
+ test("abcdefghij", 0, 10, "abcde", 1, 3, -1);
+ test("abcdefghij", 0, 10, "abcde", 1, 4, -1);
+ test("abcdefghij", 0, 10, "abcde", 1, 5, -1);
+ test("abcdefghij", 0, 10, "abcde", 2, 0, 10);
+ test("abcdefghij", 0, 10, "abcde", 2, 1, -2);
+ test("abcdefghij", 0, 10, "abcde", 2, 2, -2);
+ test("abcdefghij", 0, 10, "abcde", 2, 3, -2);
+ test("abcdefghij", 0, 10, "abcde", 2, 4, -2);
+ test("abcdefghij", 0, 10, "abcde", 4, 0, 10);
+ test("abcdefghij", 0, 10, "abcde", 4, 1, -4);
+ test("abcdefghij", 0, 10, "abcde", 4, 2, -4);
+ test("abcdefghij", 0, 10, "abcde", 5, 0, 10);
+ test("abcdefghij", 0, 10, "abcde", 5, 1, 10);
+ test("abcdefghij", 0, 10, "abcde", 6, 0, 0);
+ test("abcdefghij", 0, 10, "abcdefghij", 0, 0, 10);
+ test("abcdefghij", 0, 10, "abcdefghij", 0, 1, 9);
+ test("abcdefghij", 0, 10, "abcdefghij", 0, 5, 5);
+ test("abcdefghij", 0, 10, "abcdefghij", 0, 9, 1);
+ test("abcdefghij", 0, 10, "abcdefghij", 0, 10, 0);
+ test("abcdefghij", 0, 10, "abcdefghij", 0, 11, 0);
+ test("abcdefghij", 0, 10, "abcdefghij", 1, 0, 10);
+ test("abcdefghij", 0, 10, "abcdefghij", 1, 1, -1);
+ test("abcdefghij", 0, 10, "abcdefghij", 1, 4, -1);
+ test("abcdefghij", 0, 10, "abcdefghij", 1, 8, -1);
+ test("abcdefghij", 0, 10, "abcdefghij", 1, 9, -1);
+ test("abcdefghij", 0, 10, "abcdefghij", 1, 10, -1);
+ test("abcdefghij", 0, 10, "abcdefghij", 5, 0, 10);
+ test("abcdefghij", 0, 10, "abcdefghij", 5, 1, -5);
+ test("abcdefghij", 0, 10, "abcdefghij", 5, 2, -5);
+ test("abcdefghij", 0, 10, "abcdefghij", 5, 4, -5);
+ test("abcdefghij", 0, 10, "abcdefghij", 5, 5, -5);
+ test("abcdefghij", 0, 10, "abcdefghij", 5, 6, -5);
+ test("abcdefghij", 0, 10, "abcdefghij", 9, 0, 10);
+ test("abcdefghij", 0, 10, "abcdefghij", 9, 1, -9);
+ test("abcdefghij", 0, 10, "abcdefghij", 9, 2, -9);
+ test("abcdefghij", 0, 10, "abcdefghij", 10, 0, 10);
+ test("abcdefghij", 0, 10, "abcdefghij", 10, 1, 10);
+ test("abcdefghij", 0, 10, "abcdefghij", 11, 0, 0);
+ test("abcdefghij", 0, 10, "abcdefghijklmnopqrst", 0, 0, 10);
+ test("abcdefghij", 0, 10, "abcdefghijklmnopqrst", 0, 1, 9);
+ test("abcdefghij", 0, 10, "abcdefghijklmnopqrst", 0, 10, 0);
+ test("abcdefghij", 0, 10, "abcdefghijklmnopqrst", 0, 19, -9);
+ test("abcdefghij", 0, 10, "abcdefghijklmnopqrst", 0, 20, -10);
+ test("abcdefghij", 0, 10, "abcdefghijklmnopqrst", 0, 21, -10);
+ test("abcdefghij", 0, 10, "abcdefghijklmnopqrst", 1, 0, 10);
+ test("abcdefghij", 0, 10, "abcdefghijklmnopqrst", 1, 1, -1);
+ test("abcdefghij", 0, 10, "abcdefghijklmnopqrst", 1, 9, -1);
+ test("abcdefghij", 0, 10, "abcdefghijklmnopqrst", 1, 18, -1);
+ test("abcdefghij", 0, 10, "abcdefghijklmnopqrst", 1, 19, -1);
+ test("abcdefghij", 0, 10, "abcdefghijklmnopqrst", 1, 20, -1);
+ test("abcdefghij", 0, 10, "abcdefghijklmnopqrst", 10, 0, 10);
+ test("abcdefghij", 0, 10, "abcdefghijklmnopqrst", 10, 1, -10);
+ test("abcdefghij", 0, 10, "abcdefghijklmnopqrst", 10, 5, -10);
+ test("abcdefghij", 0, 10, "abcdefghijklmnopqrst", 10, 9, -10);
+ test("abcdefghij", 0, 10, "abcdefghijklmnopqrst", 10, 10, -10);
+ test("abcdefghij", 0, 10, "abcdefghijklmnopqrst", 10, 11, -10);
+ test("abcdefghij", 0, 10, "abcdefghijklmnopqrst", 19, 0, 10);
+ test("abcdefghij", 0, 10, "abcdefghijklmnopqrst", 19, 1, -19);
+ test("abcdefghij", 0, 10, "abcdefghijklmnopqrst", 19, 2, -19);
+ test("abcdefghij", 0, 10, "abcdefghijklmnopqrst", 20, 0, 10);
+ test("abcdefghij", 0, 10, "abcdefghijklmnopqrst", 20, 1, 10);
+ test("abcdefghij", 0, 10, "abcdefghijklmnopqrst", 21, 0, 0);
+ test("abcdefghij", 0, 11, "", 0, 0, 10);
+ test("abcdefghij", 0, 11, "", 0, 1, 10);
+ test("abcdefghij", 0, 11, "", 1, 0, 0);
+ test("abcdefghij", 0, 11, "abcde", 0, 0, 10);
+ test("abcdefghij", 0, 11, "abcde", 0, 1, 9);
+ test("abcdefghij", 0, 11, "abcde", 0, 2, 8);
+}
+
+void test23()
+{
+ test("abcdefghij", 0, 11, "abcde", 0, 4, 6);
+ test("abcdefghij", 0, 11, "abcde", 0, 5, 5);
+ test("abcdefghij", 0, 11, "abcde", 0, 6, 5);
+ test("abcdefghij", 0, 11, "abcde", 1, 0, 10);
+ test("abcdefghij", 0, 11, "abcde", 1, 1, -1);
+ test("abcdefghij", 0, 11, "abcde", 1, 2, -1);
+ test("abcdefghij", 0, 11, "abcde", 1, 3, -1);
+ test("abcdefghij", 0, 11, "abcde", 1, 4, -1);
+ test("abcdefghij", 0, 11, "abcde", 1, 5, -1);
+ test("abcdefghij", 0, 11, "abcde", 2, 0, 10);
+ test("abcdefghij", 0, 11, "abcde", 2, 1, -2);
+ test("abcdefghij", 0, 11, "abcde", 2, 2, -2);
+ test("abcdefghij", 0, 11, "abcde", 2, 3, -2);
+ test("abcdefghij", 0, 11, "abcde", 2, 4, -2);
+ test("abcdefghij", 0, 11, "abcde", 4, 0, 10);
+ test("abcdefghij", 0, 11, "abcde", 4, 1, -4);
+ test("abcdefghij", 0, 11, "abcde", 4, 2, -4);
+ test("abcdefghij", 0, 11, "abcde", 5, 0, 10);
+ test("abcdefghij", 0, 11, "abcde", 5, 1, 10);
+ test("abcdefghij", 0, 11, "abcde", 6, 0, 0);
+ test("abcdefghij", 0, 11, "abcdefghij", 0, 0, 10);
+ test("abcdefghij", 0, 11, "abcdefghij", 0, 1, 9);
+ test("abcdefghij", 0, 11, "abcdefghij", 0, 5, 5);
+ test("abcdefghij", 0, 11, "abcdefghij", 0, 9, 1);
+ test("abcdefghij", 0, 11, "abcdefghij", 0, 10, 0);
+ test("abcdefghij", 0, 11, "abcdefghij", 0, 11, 0);
+ test("abcdefghij", 0, 11, "abcdefghij", 1, 0, 10);
+ test("abcdefghij", 0, 11, "abcdefghij", 1, 1, -1);
+ test("abcdefghij", 0, 11, "abcdefghij", 1, 4, -1);
+ test("abcdefghij", 0, 11, "abcdefghij", 1, 8, -1);
+ test("abcdefghij", 0, 11, "abcdefghij", 1, 9, -1);
+ test("abcdefghij", 0, 11, "abcdefghij", 1, 10, -1);
+ test("abcdefghij", 0, 11, "abcdefghij", 5, 0, 10);
+ test("abcdefghij", 0, 11, "abcdefghij", 5, 1, -5);
+ test("abcdefghij", 0, 11, "abcdefghij", 5, 2, -5);
+ test("abcdefghij", 0, 11, "abcdefghij", 5, 4, -5);
+ test("abcdefghij", 0, 11, "abcdefghij", 5, 5, -5);
+ test("abcdefghij", 0, 11, "abcdefghij", 5, 6, -5);
+ test("abcdefghij", 0, 11, "abcdefghij", 9, 0, 10);
+ test("abcdefghij", 0, 11, "abcdefghij", 9, 1, -9);
+ test("abcdefghij", 0, 11, "abcdefghij", 9, 2, -9);
+ test("abcdefghij", 0, 11, "abcdefghij", 10, 0, 10);
+ test("abcdefghij", 0, 11, "abcdefghij", 10, 1, 10);
+ test("abcdefghij", 0, 11, "abcdefghij", 11, 0, 0);
+ test("abcdefghij", 0, 11, "abcdefghijklmnopqrst", 0, 0, 10);
+ test("abcdefghij", 0, 11, "abcdefghijklmnopqrst", 0, 1, 9);
+ test("abcdefghij", 0, 11, "abcdefghijklmnopqrst", 0, 10, 0);
+ test("abcdefghij", 0, 11, "abcdefghijklmnopqrst", 0, 19, -9);
+ test("abcdefghij", 0, 11, "abcdefghijklmnopqrst", 0, 20, -10);
+ test("abcdefghij", 0, 11, "abcdefghijklmnopqrst", 0, 21, -10);
+ test("abcdefghij", 0, 11, "abcdefghijklmnopqrst", 1, 0, 10);
+ test("abcdefghij", 0, 11, "abcdefghijklmnopqrst", 1, 1, -1);
+ test("abcdefghij", 0, 11, "abcdefghijklmnopqrst", 1, 9, -1);
+ test("abcdefghij", 0, 11, "abcdefghijklmnopqrst", 1, 18, -1);
+ test("abcdefghij", 0, 11, "abcdefghijklmnopqrst", 1, 19, -1);
+ test("abcdefghij", 0, 11, "abcdefghijklmnopqrst", 1, 20, -1);
+ test("abcdefghij", 0, 11, "abcdefghijklmnopqrst", 10, 0, 10);
+ test("abcdefghij", 0, 11, "abcdefghijklmnopqrst", 10, 1, -10);
+ test("abcdefghij", 0, 11, "abcdefghijklmnopqrst", 10, 5, -10);
+ test("abcdefghij", 0, 11, "abcdefghijklmnopqrst", 10, 9, -10);
+ test("abcdefghij", 0, 11, "abcdefghijklmnopqrst", 10, 10, -10);
+ test("abcdefghij", 0, 11, "abcdefghijklmnopqrst", 10, 11, -10);
+ test("abcdefghij", 0, 11, "abcdefghijklmnopqrst", 19, 0, 10);
+ test("abcdefghij", 0, 11, "abcdefghijklmnopqrst", 19, 1, -19);
+ test("abcdefghij", 0, 11, "abcdefghijklmnopqrst", 19, 2, -19);
+ test("abcdefghij", 0, 11, "abcdefghijklmnopqrst", 20, 0, 10);
+ test("abcdefghij", 0, 11, "abcdefghijklmnopqrst", 20, 1, 10);
+ test("abcdefghij", 0, 11, "abcdefghijklmnopqrst", 21, 0, 0);
+ test("abcdefghij", 1, 0, "", 0, 0, 0);
+ test("abcdefghij", 1, 0, "", 0, 1, 0);
+ test("abcdefghij", 1, 0, "", 1, 0, 0);
+ test("abcdefghij", 1, 0, "abcde", 0, 0, 0);
+ test("abcdefghij", 1, 0, "abcde", 0, 1, -1);
+ test("abcdefghij", 1, 0, "abcde", 0, 2, -2);
+ test("abcdefghij", 1, 0, "abcde", 0, 4, -4);
+ test("abcdefghij", 1, 0, "abcde", 0, 5, -5);
+ test("abcdefghij", 1, 0, "abcde", 0, 6, -5);
+ test("abcdefghij", 1, 0, "abcde", 1, 0, 0);
+ test("abcdefghij", 1, 0, "abcde", 1, 1, -1);
+ test("abcdefghij", 1, 0, "abcde", 1, 2, -2);
+ test("abcdefghij", 1, 0, "abcde", 1, 3, -3);
+ test("abcdefghij", 1, 0, "abcde", 1, 4, -4);
+ test("abcdefghij", 1, 0, "abcde", 1, 5, -4);
+ test("abcdefghij", 1, 0, "abcde", 2, 0, 0);
+ test("abcdefghij", 1, 0, "abcde", 2, 1, -1);
+ test("abcdefghij", 1, 0, "abcde", 2, 2, -2);
+ test("abcdefghij", 1, 0, "abcde", 2, 3, -3);
+ test("abcdefghij", 1, 0, "abcde", 2, 4, -3);
+ test("abcdefghij", 1, 0, "abcde", 4, 0, 0);
+ test("abcdefghij", 1, 0, "abcde", 4, 1, -1);
+ test("abcdefghij", 1, 0, "abcde", 4, 2, -1);
+ test("abcdefghij", 1, 0, "abcde", 5, 0, 0);
+ test("abcdefghij", 1, 0, "abcde", 5, 1, 0);
+ test("abcdefghij", 1, 0, "abcde", 6, 0, 0);
+ test("abcdefghij", 1, 0, "abcdefghij", 0, 0, 0);
+ test("abcdefghij", 1, 0, "abcdefghij", 0, 1, -1);
+ test("abcdefghij", 1, 0, "abcdefghij", 0, 5, -5);
+ test("abcdefghij", 1, 0, "abcdefghij", 0, 9, -9);
+ test("abcdefghij", 1, 0, "abcdefghij", 0, 10, -10);
+ test("abcdefghij", 1, 0, "abcdefghij", 0, 11, -10);
+}
+
+void test24()
+{
+ test("abcdefghij", 1, 0, "abcdefghij", 1, 0, 0);
+ test("abcdefghij", 1, 0, "abcdefghij", 1, 1, -1);
+ test("abcdefghij", 1, 0, "abcdefghij", 1, 4, -4);
+ test("abcdefghij", 1, 0, "abcdefghij", 1, 8, -8);
+ test("abcdefghij", 1, 0, "abcdefghij", 1, 9, -9);
+ test("abcdefghij", 1, 0, "abcdefghij", 1, 10, -9);
+ test("abcdefghij", 1, 0, "abcdefghij", 5, 0, 0);
+ test("abcdefghij", 1, 0, "abcdefghij", 5, 1, -1);
+ test("abcdefghij", 1, 0, "abcdefghij", 5, 2, -2);
+ test("abcdefghij", 1, 0, "abcdefghij", 5, 4, -4);
+ test("abcdefghij", 1, 0, "abcdefghij", 5, 5, -5);
+ test("abcdefghij", 1, 0, "abcdefghij", 5, 6, -5);
+ test("abcdefghij", 1, 0, "abcdefghij", 9, 0, 0);
+ test("abcdefghij", 1, 0, "abcdefghij", 9, 1, -1);
+ test("abcdefghij", 1, 0, "abcdefghij", 9, 2, -1);
+ test("abcdefghij", 1, 0, "abcdefghij", 10, 0, 0);
+ test("abcdefghij", 1, 0, "abcdefghij", 10, 1, 0);
+ test("abcdefghij", 1, 0, "abcdefghij", 11, 0, 0);
+ test("abcdefghij", 1, 0, "abcdefghijklmnopqrst", 0, 0, 0);
+ test("abcdefghij", 1, 0, "abcdefghijklmnopqrst", 0, 1, -1);
+ test("abcdefghij", 1, 0, "abcdefghijklmnopqrst", 0, 10, -10);
+ test("abcdefghij", 1, 0, "abcdefghijklmnopqrst", 0, 19, -19);
+ test("abcdefghij", 1, 0, "abcdefghijklmnopqrst", 0, 20, -20);
+ test("abcdefghij", 1, 0, "abcdefghijklmnopqrst", 0, 21, -20);
+ test("abcdefghij", 1, 0, "abcdefghijklmnopqrst", 1, 0, 0);
+ test("abcdefghij", 1, 0, "abcdefghijklmnopqrst", 1, 1, -1);
+ test("abcdefghij", 1, 0, "abcdefghijklmnopqrst", 1, 9, -9);
+ test("abcdefghij", 1, 0, "abcdefghijklmnopqrst", 1, 18, -18);
+ test("abcdefghij", 1, 0, "abcdefghijklmnopqrst", 1, 19, -19);
+ test("abcdefghij", 1, 0, "abcdefghijklmnopqrst", 1, 20, -19);
+ test("abcdefghij", 1, 0, "abcdefghijklmnopqrst", 10, 0, 0);
+ test("abcdefghij", 1, 0, "abcdefghijklmnopqrst", 10, 1, -1);
+ test("abcdefghij", 1, 0, "abcdefghijklmnopqrst", 10, 5, -5);
+ test("abcdefghij", 1, 0, "abcdefghijklmnopqrst", 10, 9, -9);
+ test("abcdefghij", 1, 0, "abcdefghijklmnopqrst", 10, 10, -10);
+ test("abcdefghij", 1, 0, "abcdefghijklmnopqrst", 10, 11, -10);
+ test("abcdefghij", 1, 0, "abcdefghijklmnopqrst", 19, 0, 0);
+ test("abcdefghij", 1, 0, "abcdefghijklmnopqrst", 19, 1, -1);
+ test("abcdefghij", 1, 0, "abcdefghijklmnopqrst", 19, 2, -1);
+ test("abcdefghij", 1, 0, "abcdefghijklmnopqrst", 20, 0, 0);
+ test("abcdefghij", 1, 0, "abcdefghijklmnopqrst", 20, 1, 0);
+ test("abcdefghij", 1, 0, "abcdefghijklmnopqrst", 21, 0, 0);
+ test("abcdefghij", 1, 1, "", 0, 0, 1);
+ test("abcdefghij", 1, 1, "", 0, 1, 1);
+ test("abcdefghij", 1, 1, "", 1, 0, 0);
+ test("abcdefghij", 1, 1, "abcde", 0, 0, 1);
+ test("abcdefghij", 1, 1, "abcde", 0, 1, 1);
+ test("abcdefghij", 1, 1, "abcde", 0, 2, 1);
+ test("abcdefghij", 1, 1, "abcde", 0, 4, 1);
+ test("abcdefghij", 1, 1, "abcde", 0, 5, 1);
+ test("abcdefghij", 1, 1, "abcde", 0, 6, 1);
+ test("abcdefghij", 1, 1, "abcde", 1, 0, 1);
+ test("abcdefghij", 1, 1, "abcde", 1, 1, 0);
+ test("abcdefghij", 1, 1, "abcde", 1, 2, -1);
+ test("abcdefghij", 1, 1, "abcde", 1, 3, -2);
+ test("abcdefghij", 1, 1, "abcde", 1, 4, -3);
+ test("abcdefghij", 1, 1, "abcde", 1, 5, -3);
+ test("abcdefghij", 1, 1, "abcde", 2, 0, 1);
+ test("abcdefghij", 1, 1, "abcde", 2, 1, -1);
+ test("abcdefghij", 1, 1, "abcde", 2, 2, -1);
+ test("abcdefghij", 1, 1, "abcde", 2, 3, -1);
+ test("abcdefghij", 1, 1, "abcde", 2, 4, -1);
+ test("abcdefghij", 1, 1, "abcde", 4, 0, 1);
+ test("abcdefghij", 1, 1, "abcde", 4, 1, -3);
+ test("abcdefghij", 1, 1, "abcde", 4, 2, -3);
+ test("abcdefghij", 1, 1, "abcde", 5, 0, 1);
+ test("abcdefghij", 1, 1, "abcde", 5, 1, 1);
+ test("abcdefghij", 1, 1, "abcde", 6, 0, 0);
+ test("abcdefghij", 1, 1, "abcdefghij", 0, 0, 1);
+ test("abcdefghij", 1, 1, "abcdefghij", 0, 1, 1);
+ test("abcdefghij", 1, 1, "abcdefghij", 0, 5, 1);
+ test("abcdefghij", 1, 1, "abcdefghij", 0, 9, 1);
+ test("abcdefghij", 1, 1, "abcdefghij", 0, 10, 1);
+ test("abcdefghij", 1, 1, "abcdefghij", 0, 11, 1);
+ test("abcdefghij", 1, 1, "abcdefghij", 1, 0, 1);
+ test("abcdefghij", 1, 1, "abcdefghij", 1, 1, 0);
+ test("abcdefghij", 1, 1, "abcdefghij", 1, 4, -3);
+ test("abcdefghij", 1, 1, "abcdefghij", 1, 8, -7);
+ test("abcdefghij", 1, 1, "abcdefghij", 1, 9, -8);
+ test("abcdefghij", 1, 1, "abcdefghij", 1, 10, -8);
+ test("abcdefghij", 1, 1, "abcdefghij", 5, 0, 1);
+ test("abcdefghij", 1, 1, "abcdefghij", 5, 1, -4);
+ test("abcdefghij", 1, 1, "abcdefghij", 5, 2, -4);
+ test("abcdefghij", 1, 1, "abcdefghij", 5, 4, -4);
+ test("abcdefghij", 1, 1, "abcdefghij", 5, 5, -4);
+ test("abcdefghij", 1, 1, "abcdefghij", 5, 6, -4);
+ test("abcdefghij", 1, 1, "abcdefghij", 9, 0, 1);
+ test("abcdefghij", 1, 1, "abcdefghij", 9, 1, -8);
+ test("abcdefghij", 1, 1, "abcdefghij", 9, 2, -8);
+ test("abcdefghij", 1, 1, "abcdefghij", 10, 0, 1);
+ test("abcdefghij", 1, 1, "abcdefghij", 10, 1, 1);
+ test("abcdefghij", 1, 1, "abcdefghij", 11, 0, 0);
+ test("abcdefghij", 1, 1, "abcdefghijklmnopqrst", 0, 0, 1);
+ test("abcdefghij", 1, 1, "abcdefghijklmnopqrst", 0, 1, 1);
+ test("abcdefghij", 1, 1, "abcdefghijklmnopqrst", 0, 10, 1);
+ test("abcdefghij", 1, 1, "abcdefghijklmnopqrst", 0, 19, 1);
+ test("abcdefghij", 1, 1, "abcdefghijklmnopqrst", 0, 20, 1);
+ test("abcdefghij", 1, 1, "abcdefghijklmnopqrst", 0, 21, 1);
+ test("abcdefghij", 1, 1, "abcdefghijklmnopqrst", 1, 0, 1);
+ test("abcdefghij", 1, 1, "abcdefghijklmnopqrst", 1, 1, 0);
+}
+
+void test25()
+{
+ test("abcdefghij", 1, 1, "abcdefghijklmnopqrst", 1, 9, -8);
+ test("abcdefghij", 1, 1, "abcdefghijklmnopqrst", 1, 18, -17);
+ test("abcdefghij", 1, 1, "abcdefghijklmnopqrst", 1, 19, -18);
+ test("abcdefghij", 1, 1, "abcdefghijklmnopqrst", 1, 20, -18);
+ test("abcdefghij", 1, 1, "abcdefghijklmnopqrst", 10, 0, 1);
+ test("abcdefghij", 1, 1, "abcdefghijklmnopqrst", 10, 1, -9);
+ test("abcdefghij", 1, 1, "abcdefghijklmnopqrst", 10, 5, -9);
+ test("abcdefghij", 1, 1, "abcdefghijklmnopqrst", 10, 9, -9);
+ test("abcdefghij", 1, 1, "abcdefghijklmnopqrst", 10, 10, -9);
+ test("abcdefghij", 1, 1, "abcdefghijklmnopqrst", 10, 11, -9);
+ test("abcdefghij", 1, 1, "abcdefghijklmnopqrst", 19, 0, 1);
+ test("abcdefghij", 1, 1, "abcdefghijklmnopqrst", 19, 1, -18);
+ test("abcdefghij", 1, 1, "abcdefghijklmnopqrst", 19, 2, -18);
+ test("abcdefghij", 1, 1, "abcdefghijklmnopqrst", 20, 0, 1);
+ test("abcdefghij", 1, 1, "abcdefghijklmnopqrst", 20, 1, 1);
+ test("abcdefghij", 1, 1, "abcdefghijklmnopqrst", 21, 0, 0);
+ test("abcdefghij", 1, 4, "", 0, 0, 4);
+ test("abcdefghij", 1, 4, "", 0, 1, 4);
+ test("abcdefghij", 1, 4, "", 1, 0, 0);
+ test("abcdefghij", 1, 4, "abcde", 0, 0, 4);
+ test("abcdefghij", 1, 4, "abcde", 0, 1, 1);
+ test("abcdefghij", 1, 4, "abcde", 0, 2, 1);
+ test("abcdefghij", 1, 4, "abcde", 0, 4, 1);
+ test("abcdefghij", 1, 4, "abcde", 0, 5, 1);
+ test("abcdefghij", 1, 4, "abcde", 0, 6, 1);
+ test("abcdefghij", 1, 4, "abcde", 1, 0, 4);
+ test("abcdefghij", 1, 4, "abcde", 1, 1, 3);
+ test("abcdefghij", 1, 4, "abcde", 1, 2, 2);
+ test("abcdefghij", 1, 4, "abcde", 1, 3, 1);
+ test("abcdefghij", 1, 4, "abcde", 1, 4, 0);
+ test("abcdefghij", 1, 4, "abcde", 1, 5, 0);
+ test("abcdefghij", 1, 4, "abcde", 2, 0, 4);
+ test("abcdefghij", 1, 4, "abcde", 2, 1, -1);
+ test("abcdefghij", 1, 4, "abcde", 2, 2, -1);
+ test("abcdefghij", 1, 4, "abcde", 2, 3, -1);
+ test("abcdefghij", 1, 4, "abcde", 2, 4, -1);
+ test("abcdefghij", 1, 4, "abcde", 4, 0, 4);
+ test("abcdefghij", 1, 4, "abcde", 4, 1, -3);
+ test("abcdefghij", 1, 4, "abcde", 4, 2, -3);
+ test("abcdefghij", 1, 4, "abcde", 5, 0, 4);
+ test("abcdefghij", 1, 4, "abcde", 5, 1, 4);
+ test("abcdefghij", 1, 4, "abcde", 6, 0, 0);
+ test("abcdefghij", 1, 4, "abcdefghij", 0, 0, 4);
+ test("abcdefghij", 1, 4, "abcdefghij", 0, 1, 1);
+ test("abcdefghij", 1, 4, "abcdefghij", 0, 5, 1);
+ test("abcdefghij", 1, 4, "abcdefghij", 0, 9, 1);
+ test("abcdefghij", 1, 4, "abcdefghij", 0, 10, 1);
+ test("abcdefghij", 1, 4, "abcdefghij", 0, 11, 1);
+ test("abcdefghij", 1, 4, "abcdefghij", 1, 0, 4);
+ test("abcdefghij", 1, 4, "abcdefghij", 1, 1, 3);
+ test("abcdefghij", 1, 4, "abcdefghij", 1, 4, 0);
+ test("abcdefghij", 1, 4, "abcdefghij", 1, 8, -4);
+ test("abcdefghij", 1, 4, "abcdefghij", 1, 9, -5);
+ test("abcdefghij", 1, 4, "abcdefghij", 1, 10, -5);
+ test("abcdefghij", 1, 4, "abcdefghij", 5, 0, 4);
+ test("abcdefghij", 1, 4, "abcdefghij", 5, 1, -4);
+ test("abcdefghij", 1, 4, "abcdefghij", 5, 2, -4);
+ test("abcdefghij", 1, 4, "abcdefghij", 5, 4, -4);
+ test("abcdefghij", 1, 4, "abcdefghij", 5, 5, -4);
+ test("abcdefghij", 1, 4, "abcdefghij", 5, 6, -4);
+ test("abcdefghij", 1, 4, "abcdefghij", 9, 0, 4);
+ test("abcdefghij", 1, 4, "abcdefghij", 9, 1, -8);
+ test("abcdefghij", 1, 4, "abcdefghij", 9, 2, -8);
+ test("abcdefghij", 1, 4, "abcdefghij", 10, 0, 4);
+ test("abcdefghij", 1, 4, "abcdefghij", 10, 1, 4);
+ test("abcdefghij", 1, 4, "abcdefghij", 11, 0, 0);
+ test("abcdefghij", 1, 4, "abcdefghijklmnopqrst", 0, 0, 4);
+ test("abcdefghij", 1, 4, "abcdefghijklmnopqrst", 0, 1, 1);
+ test("abcdefghij", 1, 4, "abcdefghijklmnopqrst", 0, 10, 1);
+ test("abcdefghij", 1, 4, "abcdefghijklmnopqrst", 0, 19, 1);
+ test("abcdefghij", 1, 4, "abcdefghijklmnopqrst", 0, 20, 1);
+ test("abcdefghij", 1, 4, "abcdefghijklmnopqrst", 0, 21, 1);
+ test("abcdefghij", 1, 4, "abcdefghijklmnopqrst", 1, 0, 4);
+ test("abcdefghij", 1, 4, "abcdefghijklmnopqrst", 1, 1, 3);
+ test("abcdefghij", 1, 4, "abcdefghijklmnopqrst", 1, 9, -5);
+ test("abcdefghij", 1, 4, "abcdefghijklmnopqrst", 1, 18, -14);
+ test("abcdefghij", 1, 4, "abcdefghijklmnopqrst", 1, 19, -15);
+ test("abcdefghij", 1, 4, "abcdefghijklmnopqrst", 1, 20, -15);
+ test("abcdefghij", 1, 4, "abcdefghijklmnopqrst", 10, 0, 4);
+ test("abcdefghij", 1, 4, "abcdefghijklmnopqrst", 10, 1, -9);
+ test("abcdefghij", 1, 4, "abcdefghijklmnopqrst", 10, 5, -9);
+ test("abcdefghij", 1, 4, "abcdefghijklmnopqrst", 10, 9, -9);
+ test("abcdefghij", 1, 4, "abcdefghijklmnopqrst", 10, 10, -9);
+ test("abcdefghij", 1, 4, "abcdefghijklmnopqrst", 10, 11, -9);
+ test("abcdefghij", 1, 4, "abcdefghijklmnopqrst", 19, 0, 4);
+ test("abcdefghij", 1, 4, "abcdefghijklmnopqrst", 19, 1, -18);
+ test("abcdefghij", 1, 4, "abcdefghijklmnopqrst", 19, 2, -18);
+ test("abcdefghij", 1, 4, "abcdefghijklmnopqrst", 20, 0, 4);
+ test("abcdefghij", 1, 4, "abcdefghijklmnopqrst", 20, 1, 4);
+ test("abcdefghij", 1, 4, "abcdefghijklmnopqrst", 21, 0, 0);
+ test("abcdefghij", 1, 8, "", 0, 0, 8);
+ test("abcdefghij", 1, 8, "", 0, 1, 8);
+ test("abcdefghij", 1, 8, "", 1, 0, 0);
+ test("abcdefghij", 1, 8, "abcde", 0, 0, 8);
+ test("abcdefghij", 1, 8, "abcde", 0, 1, 1);
+ test("abcdefghij", 1, 8, "abcde", 0, 2, 1);
+ test("abcdefghij", 1, 8, "abcde", 0, 4, 1);
+ test("abcdefghij", 1, 8, "abcde", 0, 5, 1);
+ test("abcdefghij", 1, 8, "abcde", 0, 6, 1);
+ test("abcdefghij", 1, 8, "abcde", 1, 0, 8);
+}
+
+void test26()
+{
+ test("abcdefghij", 1, 8, "abcde", 1, 1, 7);
+ test("abcdefghij", 1, 8, "abcde", 1, 2, 6);
+ test("abcdefghij", 1, 8, "abcde", 1, 3, 5);
+ test("abcdefghij", 1, 8, "abcde", 1, 4, 4);
+ test("abcdefghij", 1, 8, "abcde", 1, 5, 4);
+ test("abcdefghij", 1, 8, "abcde", 2, 0, 8);
+ test("abcdefghij", 1, 8, "abcde", 2, 1, -1);
+ test("abcdefghij", 1, 8, "abcde", 2, 2, -1);
+ test("abcdefghij", 1, 8, "abcde", 2, 3, -1);
+ test("abcdefghij", 1, 8, "abcde", 2, 4, -1);
+ test("abcdefghij", 1, 8, "abcde", 4, 0, 8);
+ test("abcdefghij", 1, 8, "abcde", 4, 1, -3);
+ test("abcdefghij", 1, 8, "abcde", 4, 2, -3);
+ test("abcdefghij", 1, 8, "abcde", 5, 0, 8);
+ test("abcdefghij", 1, 8, "abcde", 5, 1, 8);
+ test("abcdefghij", 1, 8, "abcde", 6, 0, 0);
+ test("abcdefghij", 1, 8, "abcdefghij", 0, 0, 8);
+ test("abcdefghij", 1, 8, "abcdefghij", 0, 1, 1);
+ test("abcdefghij", 1, 8, "abcdefghij", 0, 5, 1);
+ test("abcdefghij", 1, 8, "abcdefghij", 0, 9, 1);
+ test("abcdefghij", 1, 8, "abcdefghij", 0, 10, 1);
+ test("abcdefghij", 1, 8, "abcdefghij", 0, 11, 1);
+ test("abcdefghij", 1, 8, "abcdefghij", 1, 0, 8);
+ test("abcdefghij", 1, 8, "abcdefghij", 1, 1, 7);
+ test("abcdefghij", 1, 8, "abcdefghij", 1, 4, 4);
+ test("abcdefghij", 1, 8, "abcdefghij", 1, 8, 0);
+ test("abcdefghij", 1, 8, "abcdefghij", 1, 9, -1);
+ test("abcdefghij", 1, 8, "abcdefghij", 1, 10, -1);
+ test("abcdefghij", 1, 8, "abcdefghij", 5, 0, 8);
+ test("abcdefghij", 1, 8, "abcdefghij", 5, 1, -4);
+ test("abcdefghij", 1, 8, "abcdefghij", 5, 2, -4);
+ test("abcdefghij", 1, 8, "abcdefghij", 5, 4, -4);
+ test("abcdefghij", 1, 8, "abcdefghij", 5, 5, -4);
+ test("abcdefghij", 1, 8, "abcdefghij", 5, 6, -4);
+ test("abcdefghij", 1, 8, "abcdefghij", 9, 0, 8);
+ test("abcdefghij", 1, 8, "abcdefghij", 9, 1, -8);
+ test("abcdefghij", 1, 8, "abcdefghij", 9, 2, -8);
+ test("abcdefghij", 1, 8, "abcdefghij", 10, 0, 8);
+ test("abcdefghij", 1, 8, "abcdefghij", 10, 1, 8);
+ test("abcdefghij", 1, 8, "abcdefghij", 11, 0, 0);
+ test("abcdefghij", 1, 8, "abcdefghijklmnopqrst", 0, 0, 8);
+ test("abcdefghij", 1, 8, "abcdefghijklmnopqrst", 0, 1, 1);
+ test("abcdefghij", 1, 8, "abcdefghijklmnopqrst", 0, 10, 1);
+ test("abcdefghij", 1, 8, "abcdefghijklmnopqrst", 0, 19, 1);
+ test("abcdefghij", 1, 8, "abcdefghijklmnopqrst", 0, 20, 1);
+ test("abcdefghij", 1, 8, "abcdefghijklmnopqrst", 0, 21, 1);
+ test("abcdefghij", 1, 8, "abcdefghijklmnopqrst", 1, 0, 8);
+ test("abcdefghij", 1, 8, "abcdefghijklmnopqrst", 1, 1, 7);
+ test("abcdefghij", 1, 8, "abcdefghijklmnopqrst", 1, 9, -1);
+ test("abcdefghij", 1, 8, "abcdefghijklmnopqrst", 1, 18, -10);
+ test("abcdefghij", 1, 8, "abcdefghijklmnopqrst", 1, 19, -11);
+ test("abcdefghij", 1, 8, "abcdefghijklmnopqrst", 1, 20, -11);
+ test("abcdefghij", 1, 8, "abcdefghijklmnopqrst", 10, 0, 8);
+ test("abcdefghij", 1, 8, "abcdefghijklmnopqrst", 10, 1, -9);
+ test("abcdefghij", 1, 8, "abcdefghijklmnopqrst", 10, 5, -9);
+ test("abcdefghij", 1, 8, "abcdefghijklmnopqrst", 10, 9, -9);
+ test("abcdefghij", 1, 8, "abcdefghijklmnopqrst", 10, 10, -9);
+ test("abcdefghij", 1, 8, "abcdefghijklmnopqrst", 10, 11, -9);
+ test("abcdefghij", 1, 8, "abcdefghijklmnopqrst", 19, 0, 8);
+ test("abcdefghij", 1, 8, "abcdefghijklmnopqrst", 19, 1, -18);
+ test("abcdefghij", 1, 8, "abcdefghijklmnopqrst", 19, 2, -18);
+ test("abcdefghij", 1, 8, "abcdefghijklmnopqrst", 20, 0, 8);
+ test("abcdefghij", 1, 8, "abcdefghijklmnopqrst", 20, 1, 8);
+ test("abcdefghij", 1, 8, "abcdefghijklmnopqrst", 21, 0, 0);
+ test("abcdefghij", 1, 9, "", 0, 0, 9);
+ test("abcdefghij", 1, 9, "", 0, 1, 9);
+ test("abcdefghij", 1, 9, "", 1, 0, 0);
+ test("abcdefghij", 1, 9, "abcde", 0, 0, 9);
+ test("abcdefghij", 1, 9, "abcde", 0, 1, 1);
+ test("abcdefghij", 1, 9, "abcde", 0, 2, 1);
+ test("abcdefghij", 1, 9, "abcde", 0, 4, 1);
+ test("abcdefghij", 1, 9, "abcde", 0, 5, 1);
+ test("abcdefghij", 1, 9, "abcde", 0, 6, 1);
+ test("abcdefghij", 1, 9, "abcde", 1, 0, 9);
+ test("abcdefghij", 1, 9, "abcde", 1, 1, 8);
+ test("abcdefghij", 1, 9, "abcde", 1, 2, 7);
+ test("abcdefghij", 1, 9, "abcde", 1, 3, 6);
+ test("abcdefghij", 1, 9, "abcde", 1, 4, 5);
+ test("abcdefghij", 1, 9, "abcde", 1, 5, 5);
+ test("abcdefghij", 1, 9, "abcde", 2, 0, 9);
+ test("abcdefghij", 1, 9, "abcde", 2, 1, -1);
+ test("abcdefghij", 1, 9, "abcde", 2, 2, -1);
+ test("abcdefghij", 1, 9, "abcde", 2, 3, -1);
+ test("abcdefghij", 1, 9, "abcde", 2, 4, -1);
+ test("abcdefghij", 1, 9, "abcde", 4, 0, 9);
+ test("abcdefghij", 1, 9, "abcde", 4, 1, -3);
+ test("abcdefghij", 1, 9, "abcde", 4, 2, -3);
+ test("abcdefghij", 1, 9, "abcde", 5, 0, 9);
+ test("abcdefghij", 1, 9, "abcde", 5, 1, 9);
+ test("abcdefghij", 1, 9, "abcde", 6, 0, 0);
+ test("abcdefghij", 1, 9, "abcdefghij", 0, 0, 9);
+ test("abcdefghij", 1, 9, "abcdefghij", 0, 1, 1);
+ test("abcdefghij", 1, 9, "abcdefghij", 0, 5, 1);
+ test("abcdefghij", 1, 9, "abcdefghij", 0, 9, 1);
+ test("abcdefghij", 1, 9, "abcdefghij", 0, 10, 1);
+ test("abcdefghij", 1, 9, "abcdefghij", 0, 11, 1);
+ test("abcdefghij", 1, 9, "abcdefghij", 1, 0, 9);
+ test("abcdefghij", 1, 9, "abcdefghij", 1, 1, 8);
+ test("abcdefghij", 1, 9, "abcdefghij", 1, 4, 5);
+ test("abcdefghij", 1, 9, "abcdefghij", 1, 8, 1);
+}
+
+void test27()
+{
+ test("abcdefghij", 1, 9, "abcdefghij", 1, 9, 0);
+ test("abcdefghij", 1, 9, "abcdefghij", 1, 10, 0);
+ test("abcdefghij", 1, 9, "abcdefghij", 5, 0, 9);
+ test("abcdefghij", 1, 9, "abcdefghij", 5, 1, -4);
+ test("abcdefghij", 1, 9, "abcdefghij", 5, 2, -4);
+ test("abcdefghij", 1, 9, "abcdefghij", 5, 4, -4);
+ test("abcdefghij", 1, 9, "abcdefghij", 5, 5, -4);
+ test("abcdefghij", 1, 9, "abcdefghij", 5, 6, -4);
+ test("abcdefghij", 1, 9, "abcdefghij", 9, 0, 9);
+ test("abcdefghij", 1, 9, "abcdefghij", 9, 1, -8);
+ test("abcdefghij", 1, 9, "abcdefghij", 9, 2, -8);
+ test("abcdefghij", 1, 9, "abcdefghij", 10, 0, 9);
+ test("abcdefghij", 1, 9, "abcdefghij", 10, 1, 9);
+ test("abcdefghij", 1, 9, "abcdefghij", 11, 0, 0);
+ test("abcdefghij", 1, 9, "abcdefghijklmnopqrst", 0, 0, 9);
+ test("abcdefghij", 1, 9, "abcdefghijklmnopqrst", 0, 1, 1);
+ test("abcdefghij", 1, 9, "abcdefghijklmnopqrst", 0, 10, 1);
+ test("abcdefghij", 1, 9, "abcdefghijklmnopqrst", 0, 19, 1);
+ test("abcdefghij", 1, 9, "abcdefghijklmnopqrst", 0, 20, 1);
+ test("abcdefghij", 1, 9, "abcdefghijklmnopqrst", 0, 21, 1);
+ test("abcdefghij", 1, 9, "abcdefghijklmnopqrst", 1, 0, 9);
+ test("abcdefghij", 1, 9, "abcdefghijklmnopqrst", 1, 1, 8);
+ test("abcdefghij", 1, 9, "abcdefghijklmnopqrst", 1, 9, 0);
+ test("abcdefghij", 1, 9, "abcdefghijklmnopqrst", 1, 18, -9);
+ test("abcdefghij", 1, 9, "abcdefghijklmnopqrst", 1, 19, -10);
+ test("abcdefghij", 1, 9, "abcdefghijklmnopqrst", 1, 20, -10);
+ test("abcdefghij", 1, 9, "abcdefghijklmnopqrst", 10, 0, 9);
+ test("abcdefghij", 1, 9, "abcdefghijklmnopqrst", 10, 1, -9);
+ test("abcdefghij", 1, 9, "abcdefghijklmnopqrst", 10, 5, -9);
+ test("abcdefghij", 1, 9, "abcdefghijklmnopqrst", 10, 9, -9);
+ test("abcdefghij", 1, 9, "abcdefghijklmnopqrst", 10, 10, -9);
+ test("abcdefghij", 1, 9, "abcdefghijklmnopqrst", 10, 11, -9);
+ test("abcdefghij", 1, 9, "abcdefghijklmnopqrst", 19, 0, 9);
+ test("abcdefghij", 1, 9, "abcdefghijklmnopqrst", 19, 1, -18);
+ test("abcdefghij", 1, 9, "abcdefghijklmnopqrst", 19, 2, -18);
+ test("abcdefghij", 1, 9, "abcdefghijklmnopqrst", 20, 0, 9);
+ test("abcdefghij", 1, 9, "abcdefghijklmnopqrst", 20, 1, 9);
+ test("abcdefghij", 1, 9, "abcdefghijklmnopqrst", 21, 0, 0);
+ test("abcdefghij", 1, 10, "", 0, 0, 9);
+ test("abcdefghij", 1, 10, "", 0, 1, 9);
+ test("abcdefghij", 1, 10, "", 1, 0, 0);
+ test("abcdefghij", 1, 10, "abcde", 0, 0, 9);
+ test("abcdefghij", 1, 10, "abcde", 0, 1, 1);
+ test("abcdefghij", 1, 10, "abcde", 0, 2, 1);
+ test("abcdefghij", 1, 10, "abcde", 0, 4, 1);
+ test("abcdefghij", 1, 10, "abcde", 0, 5, 1);
+ test("abcdefghij", 1, 10, "abcde", 0, 6, 1);
+ test("abcdefghij", 1, 10, "abcde", 1, 0, 9);
+ test("abcdefghij", 1, 10, "abcde", 1, 1, 8);
+ test("abcdefghij", 1, 10, "abcde", 1, 2, 7);
+ test("abcdefghij", 1, 10, "abcde", 1, 3, 6);
+ test("abcdefghij", 1, 10, "abcde", 1, 4, 5);
+ test("abcdefghij", 1, 10, "abcde", 1, 5, 5);
+ test("abcdefghij", 1, 10, "abcde", 2, 0, 9);
+ test("abcdefghij", 1, 10, "abcde", 2, 1, -1);
+ test("abcdefghij", 1, 10, "abcde", 2, 2, -1);
+ test("abcdefghij", 1, 10, "abcde", 2, 3, -1);
+ test("abcdefghij", 1, 10, "abcde", 2, 4, -1);
+ test("abcdefghij", 1, 10, "abcde", 4, 0, 9);
+ test("abcdefghij", 1, 10, "abcde", 4, 1, -3);
+ test("abcdefghij", 1, 10, "abcde", 4, 2, -3);
+ test("abcdefghij", 1, 10, "abcde", 5, 0, 9);
+ test("abcdefghij", 1, 10, "abcde", 5, 1, 9);
+ test("abcdefghij", 1, 10, "abcde", 6, 0, 0);
+ test("abcdefghij", 1, 10, "abcdefghij", 0, 0, 9);
+ test("abcdefghij", 1, 10, "abcdefghij", 0, 1, 1);
+ test("abcdefghij", 1, 10, "abcdefghij", 0, 5, 1);
+ test("abcdefghij", 1, 10, "abcdefghij", 0, 9, 1);
+ test("abcdefghij", 1, 10, "abcdefghij", 0, 10, 1);
+ test("abcdefghij", 1, 10, "abcdefghij", 0, 11, 1);
+ test("abcdefghij", 1, 10, "abcdefghij", 1, 0, 9);
+ test("abcdefghij", 1, 10, "abcdefghij", 1, 1, 8);
+ test("abcdefghij", 1, 10, "abcdefghij", 1, 4, 5);
+ test("abcdefghij", 1, 10, "abcdefghij", 1, 8, 1);
+ test("abcdefghij", 1, 10, "abcdefghij", 1, 9, 0);
+ test("abcdefghij", 1, 10, "abcdefghij", 1, 10, 0);
+ test("abcdefghij", 1, 10, "abcdefghij", 5, 0, 9);
+ test("abcdefghij", 1, 10, "abcdefghij", 5, 1, -4);
+ test("abcdefghij", 1, 10, "abcdefghij", 5, 2, -4);
+ test("abcdefghij", 1, 10, "abcdefghij", 5, 4, -4);
+ test("abcdefghij", 1, 10, "abcdefghij", 5, 5, -4);
+ test("abcdefghij", 1, 10, "abcdefghij", 5, 6, -4);
+ test("abcdefghij", 1, 10, "abcdefghij", 9, 0, 9);
+ test("abcdefghij", 1, 10, "abcdefghij", 9, 1, -8);
+ test("abcdefghij", 1, 10, "abcdefghij", 9, 2, -8);
+ test("abcdefghij", 1, 10, "abcdefghij", 10, 0, 9);
+ test("abcdefghij", 1, 10, "abcdefghij", 10, 1, 9);
+ test("abcdefghij", 1, 10, "abcdefghij", 11, 0, 0);
+ test("abcdefghij", 1, 10, "abcdefghijklmnopqrst", 0, 0, 9);
+ test("abcdefghij", 1, 10, "abcdefghijklmnopqrst", 0, 1, 1);
+ test("abcdefghij", 1, 10, "abcdefghijklmnopqrst", 0, 10, 1);
+ test("abcdefghij", 1, 10, "abcdefghijklmnopqrst", 0, 19, 1);
+ test("abcdefghij", 1, 10, "abcdefghijklmnopqrst", 0, 20, 1);
+ test("abcdefghij", 1, 10, "abcdefghijklmnopqrst", 0, 21, 1);
+ test("abcdefghij", 1, 10, "abcdefghijklmnopqrst", 1, 0, 9);
+ test("abcdefghij", 1, 10, "abcdefghijklmnopqrst", 1, 1, 8);
+ test("abcdefghij", 1, 10, "abcdefghijklmnopqrst", 1, 9, 0);
+ test("abcdefghij", 1, 10, "abcdefghijklmnopqrst", 1, 18, -9);
+ test("abcdefghij", 1, 10, "abcdefghijklmnopqrst", 1, 19, -10);
+ test("abcdefghij", 1, 10, "abcdefghijklmnopqrst", 1, 20, -10);
+}
+
+void test28()
+{
+ test("abcdefghij", 1, 10, "abcdefghijklmnopqrst", 10, 0, 9);
+ test("abcdefghij", 1, 10, "abcdefghijklmnopqrst", 10, 1, -9);
+ test("abcdefghij", 1, 10, "abcdefghijklmnopqrst", 10, 5, -9);
+ test("abcdefghij", 1, 10, "abcdefghijklmnopqrst", 10, 9, -9);
+ test("abcdefghij", 1, 10, "abcdefghijklmnopqrst", 10, 10, -9);
+ test("abcdefghij", 1, 10, "abcdefghijklmnopqrst", 10, 11, -9);
+ test("abcdefghij", 1, 10, "abcdefghijklmnopqrst", 19, 0, 9);
+ test("abcdefghij", 1, 10, "abcdefghijklmnopqrst", 19, 1, -18);
+ test("abcdefghij", 1, 10, "abcdefghijklmnopqrst", 19, 2, -18);
+ test("abcdefghij", 1, 10, "abcdefghijklmnopqrst", 20, 0, 9);
+ test("abcdefghij", 1, 10, "abcdefghijklmnopqrst", 20, 1, 9);
+ test("abcdefghij", 1, 10, "abcdefghijklmnopqrst", 21, 0, 0);
+ test("abcdefghij", 5, 0, "", 0, 0, 0);
+ test("abcdefghij", 5, 0, "", 0, 1, 0);
+ test("abcdefghij", 5, 0, "", 1, 0, 0);
+ test("abcdefghij", 5, 0, "abcde", 0, 0, 0);
+ test("abcdefghij", 5, 0, "abcde", 0, 1, -1);
+ test("abcdefghij", 5, 0, "abcde", 0, 2, -2);
+ test("abcdefghij", 5, 0, "abcde", 0, 4, -4);
+ test("abcdefghij", 5, 0, "abcde", 0, 5, -5);
+ test("abcdefghij", 5, 0, "abcde", 0, 6, -5);
+ test("abcdefghij", 5, 0, "abcde", 1, 0, 0);
+ test("abcdefghij", 5, 0, "abcde", 1, 1, -1);
+ test("abcdefghij", 5, 0, "abcde", 1, 2, -2);
+ test("abcdefghij", 5, 0, "abcde", 1, 3, -3);
+ test("abcdefghij", 5, 0, "abcde", 1, 4, -4);
+ test("abcdefghij", 5, 0, "abcde", 1, 5, -4);
+ test("abcdefghij", 5, 0, "abcde", 2, 0, 0);
+ test("abcdefghij", 5, 0, "abcde", 2, 1, -1);
+ test("abcdefghij", 5, 0, "abcde", 2, 2, -2);
+ test("abcdefghij", 5, 0, "abcde", 2, 3, -3);
+ test("abcdefghij", 5, 0, "abcde", 2, 4, -3);
+ test("abcdefghij", 5, 0, "abcde", 4, 0, 0);
+ test("abcdefghij", 5, 0, "abcde", 4, 1, -1);
+ test("abcdefghij", 5, 0, "abcde", 4, 2, -1);
+ test("abcdefghij", 5, 0, "abcde", 5, 0, 0);
+ test("abcdefghij", 5, 0, "abcde", 5, 1, 0);
+ test("abcdefghij", 5, 0, "abcde", 6, 0, 0);
+ test("abcdefghij", 5, 0, "abcdefghij", 0, 0, 0);
+ test("abcdefghij", 5, 0, "abcdefghij", 0, 1, -1);
+ test("abcdefghij", 5, 0, "abcdefghij", 0, 5, -5);
+ test("abcdefghij", 5, 0, "abcdefghij", 0, 9, -9);
+ test("abcdefghij", 5, 0, "abcdefghij", 0, 10, -10);
+ test("abcdefghij", 5, 0, "abcdefghij", 0, 11, -10);
+ test("abcdefghij", 5, 0, "abcdefghij", 1, 0, 0);
+ test("abcdefghij", 5, 0, "abcdefghij", 1, 1, -1);
+ test("abcdefghij", 5, 0, "abcdefghij", 1, 4, -4);
+ test("abcdefghij", 5, 0, "abcdefghij", 1, 8, -8);
+ test("abcdefghij", 5, 0, "abcdefghij", 1, 9, -9);
+ test("abcdefghij", 5, 0, "abcdefghij", 1, 10, -9);
+ test("abcdefghij", 5, 0, "abcdefghij", 5, 0, 0);
+ test("abcdefghij", 5, 0, "abcdefghij", 5, 1, -1);
+ test("abcdefghij", 5, 0, "abcdefghij", 5, 2, -2);
+ test("abcdefghij", 5, 0, "abcdefghij", 5, 4, -4);
+ test("abcdefghij", 5, 0, "abcdefghij", 5, 5, -5);
+ test("abcdefghij", 5, 0, "abcdefghij", 5, 6, -5);
+ test("abcdefghij", 5, 0, "abcdefghij", 9, 0, 0);
+ test("abcdefghij", 5, 0, "abcdefghij", 9, 1, -1);
+ test("abcdefghij", 5, 0, "abcdefghij", 9, 2, -1);
+ test("abcdefghij", 5, 0, "abcdefghij", 10, 0, 0);
+ test("abcdefghij", 5, 0, "abcdefghij", 10, 1, 0);
+ test("abcdefghij", 5, 0, "abcdefghij", 11, 0, 0);
+ test("abcdefghij", 5, 0, "abcdefghijklmnopqrst", 0, 0, 0);
+ test("abcdefghij", 5, 0, "abcdefghijklmnopqrst", 0, 1, -1);
+ test("abcdefghij", 5, 0, "abcdefghijklmnopqrst", 0, 10, -10);
+ test("abcdefghij", 5, 0, "abcdefghijklmnopqrst", 0, 19, -19);
+ test("abcdefghij", 5, 0, "abcdefghijklmnopqrst", 0, 20, -20);
+ test("abcdefghij", 5, 0, "abcdefghijklmnopqrst", 0, 21, -20);
+ test("abcdefghij", 5, 0, "abcdefghijklmnopqrst", 1, 0, 0);
+ test("abcdefghij", 5, 0, "abcdefghijklmnopqrst", 1, 1, -1);
+ test("abcdefghij", 5, 0, "abcdefghijklmnopqrst", 1, 9, -9);
+ test("abcdefghij", 5, 0, "abcdefghijklmnopqrst", 1, 18, -18);
+ test("abcdefghij", 5, 0, "abcdefghijklmnopqrst", 1, 19, -19);
+ test("abcdefghij", 5, 0, "abcdefghijklmnopqrst", 1, 20, -19);
+ test("abcdefghij", 5, 0, "abcdefghijklmnopqrst", 10, 0, 0);
+ test("abcdefghij", 5, 0, "abcdefghijklmnopqrst", 10, 1, -1);
+ test("abcdefghij", 5, 0, "abcdefghijklmnopqrst", 10, 5, -5);
+ test("abcdefghij", 5, 0, "abcdefghijklmnopqrst", 10, 9, -9);
+ test("abcdefghij", 5, 0, "abcdefghijklmnopqrst", 10, 10, -10);
+ test("abcdefghij", 5, 0, "abcdefghijklmnopqrst", 10, 11, -10);
+ test("abcdefghij", 5, 0, "abcdefghijklmnopqrst", 19, 0, 0);
+ test("abcdefghij", 5, 0, "abcdefghijklmnopqrst", 19, 1, -1);
+ test("abcdefghij", 5, 0, "abcdefghijklmnopqrst", 19, 2, -1);
+ test("abcdefghij", 5, 0, "abcdefghijklmnopqrst", 20, 0, 0);
+ test("abcdefghij", 5, 0, "abcdefghijklmnopqrst", 20, 1, 0);
+ test("abcdefghij", 5, 0, "abcdefghijklmnopqrst", 21, 0, 0);
+ test("abcdefghij", 5, 1, "", 0, 0, 1);
+ test("abcdefghij", 5, 1, "", 0, 1, 1);
+ test("abcdefghij", 5, 1, "", 1, 0, 0);
+ test("abcdefghij", 5, 1, "abcde", 0, 0, 1);
+ test("abcdefghij", 5, 1, "abcde", 0, 1, 5);
+ test("abcdefghij", 5, 1, "abcde", 0, 2, 5);
+ test("abcdefghij", 5, 1, "abcde", 0, 4, 5);
+ test("abcdefghij", 5, 1, "abcde", 0, 5, 5);
+ test("abcdefghij", 5, 1, "abcde", 0, 6, 5);
+ test("abcdefghij", 5, 1, "abcde", 1, 0, 1);
+ test("abcdefghij", 5, 1, "abcde", 1, 1, 4);
+ test("abcdefghij", 5, 1, "abcde", 1, 2, 4);
+ test("abcdefghij", 5, 1, "abcde", 1, 3, 4);
+ test("abcdefghij", 5, 1, "abcde", 1, 4, 4);
+}
+
+void test29()
+{
+ test("abcdefghij", 5, 1, "abcde", 1, 5, 4);
+ test("abcdefghij", 5, 1, "abcde", 2, 0, 1);
+ test("abcdefghij", 5, 1, "abcde", 2, 1, 3);
+ test("abcdefghij", 5, 1, "abcde", 2, 2, 3);
+ test("abcdefghij", 5, 1, "abcde", 2, 3, 3);
+ test("abcdefghij", 5, 1, "abcde", 2, 4, 3);
+ test("abcdefghij", 5, 1, "abcde", 4, 0, 1);
+ test("abcdefghij", 5, 1, "abcde", 4, 1, 1);
+ test("abcdefghij", 5, 1, "abcde", 4, 2, 1);
+ test("abcdefghij", 5, 1, "abcde", 5, 0, 1);
+ test("abcdefghij", 5, 1, "abcde", 5, 1, 1);
+ test("abcdefghij", 5, 1, "abcde", 6, 0, 0);
+ test("abcdefghij", 5, 1, "abcdefghij", 0, 0, 1);
+ test("abcdefghij", 5, 1, "abcdefghij", 0, 1, 5);
+ test("abcdefghij", 5, 1, "abcdefghij", 0, 5, 5);
+ test("abcdefghij", 5, 1, "abcdefghij", 0, 9, 5);
+ test("abcdefghij", 5, 1, "abcdefghij", 0, 10, 5);
+ test("abcdefghij", 5, 1, "abcdefghij", 0, 11, 5);
+ test("abcdefghij", 5, 1, "abcdefghij", 1, 0, 1);
+ test("abcdefghij", 5, 1, "abcdefghij", 1, 1, 4);
+ test("abcdefghij", 5, 1, "abcdefghij", 1, 4, 4);
+ test("abcdefghij", 5, 1, "abcdefghij", 1, 8, 4);
+ test("abcdefghij", 5, 1, "abcdefghij", 1, 9, 4);
+ test("abcdefghij", 5, 1, "abcdefghij", 1, 10, 4);
+ test("abcdefghij", 5, 1, "abcdefghij", 5, 0, 1);
+ test("abcdefghij", 5, 1, "abcdefghij", 5, 1, 0);
+ test("abcdefghij", 5, 1, "abcdefghij", 5, 2, -1);
+ test("abcdefghij", 5, 1, "abcdefghij", 5, 4, -3);
+ test("abcdefghij", 5, 1, "abcdefghij", 5, 5, -4);
+ test("abcdefghij", 5, 1, "abcdefghij", 5, 6, -4);
+ test("abcdefghij", 5, 1, "abcdefghij", 9, 0, 1);
+ test("abcdefghij", 5, 1, "abcdefghij", 9, 1, -4);
+ test("abcdefghij", 5, 1, "abcdefghij", 9, 2, -4);
+ test("abcdefghij", 5, 1, "abcdefghij", 10, 0, 1);
+ test("abcdefghij", 5, 1, "abcdefghij", 10, 1, 1);
+ test("abcdefghij", 5, 1, "abcdefghij", 11, 0, 0);
+ test("abcdefghij", 5, 1, "abcdefghijklmnopqrst", 0, 0, 1);
+ test("abcdefghij", 5, 1, "abcdefghijklmnopqrst", 0, 1, 5);
+ test("abcdefghij", 5, 1, "abcdefghijklmnopqrst", 0, 10, 5);
+ test("abcdefghij", 5, 1, "abcdefghijklmnopqrst", 0, 19, 5);
+ test("abcdefghij", 5, 1, "abcdefghijklmnopqrst", 0, 20, 5);
+ test("abcdefghij", 5, 1, "abcdefghijklmnopqrst", 0, 21, 5);
+ test("abcdefghij", 5, 1, "abcdefghijklmnopqrst", 1, 0, 1);
+ test("abcdefghij", 5, 1, "abcdefghijklmnopqrst", 1, 1, 4);
+ test("abcdefghij", 5, 1, "abcdefghijklmnopqrst", 1, 9, 4);
+ test("abcdefghij", 5, 1, "abcdefghijklmnopqrst", 1, 18, 4);
+ test("abcdefghij", 5, 1, "abcdefghijklmnopqrst", 1, 19, 4);
+ test("abcdefghij", 5, 1, "abcdefghijklmnopqrst", 1, 20, 4);
+ test("abcdefghij", 5, 1, "abcdefghijklmnopqrst", 10, 0, 1);
+ test("abcdefghij", 5, 1, "abcdefghijklmnopqrst", 10, 1, -5);
+ test("abcdefghij", 5, 1, "abcdefghijklmnopqrst", 10, 5, -5);
+ test("abcdefghij", 5, 1, "abcdefghijklmnopqrst", 10, 9, -5);
+ test("abcdefghij", 5, 1, "abcdefghijklmnopqrst", 10, 10, -5);
+ test("abcdefghij", 5, 1, "abcdefghijklmnopqrst", 10, 11, -5);
+ test("abcdefghij", 5, 1, "abcdefghijklmnopqrst", 19, 0, 1);
+ test("abcdefghij", 5, 1, "abcdefghijklmnopqrst", 19, 1, -14);
+ test("abcdefghij", 5, 1, "abcdefghijklmnopqrst", 19, 2, -14);
+ test("abcdefghij", 5, 1, "abcdefghijklmnopqrst", 20, 0, 1);
+ test("abcdefghij", 5, 1, "abcdefghijklmnopqrst", 20, 1, 1);
+ test("abcdefghij", 5, 1, "abcdefghijklmnopqrst", 21, 0, 0);
+ test("abcdefghij", 5, 2, "", 0, 0, 2);
+ test("abcdefghij", 5, 2, "", 0, 1, 2);
+ test("abcdefghij", 5, 2, "", 1, 0, 0);
+ test("abcdefghij", 5, 2, "abcde", 0, 0, 2);
+ test("abcdefghij", 5, 2, "abcde", 0, 1, 5);
+ test("abcdefghij", 5, 2, "abcde", 0, 2, 5);
+ test("abcdefghij", 5, 2, "abcde", 0, 4, 5);
+ test("abcdefghij", 5, 2, "abcde", 0, 5, 5);
+ test("abcdefghij", 5, 2, "abcde", 0, 6, 5);
+ test("abcdefghij", 5, 2, "abcde", 1, 0, 2);
+ test("abcdefghij", 5, 2, "abcde", 1, 1, 4);
+ test("abcdefghij", 5, 2, "abcde", 1, 2, 4);
+ test("abcdefghij", 5, 2, "abcde", 1, 3, 4);
+ test("abcdefghij", 5, 2, "abcde", 1, 4, 4);
+ test("abcdefghij", 5, 2, "abcde", 1, 5, 4);
+ test("abcdefghij", 5, 2, "abcde", 2, 0, 2);
+ test("abcdefghij", 5, 2, "abcde", 2, 1, 3);
+ test("abcdefghij", 5, 2, "abcde", 2, 2, 3);
+ test("abcdefghij", 5, 2, "abcde", 2, 3, 3);
+ test("abcdefghij", 5, 2, "abcde", 2, 4, 3);
+ test("abcdefghij", 5, 2, "abcde", 4, 0, 2);
+ test("abcdefghij", 5, 2, "abcde", 4, 1, 1);
+ test("abcdefghij", 5, 2, "abcde", 4, 2, 1);
+ test("abcdefghij", 5, 2, "abcde", 5, 0, 2);
+ test("abcdefghij", 5, 2, "abcde", 5, 1, 2);
+ test("abcdefghij", 5, 2, "abcde", 6, 0, 0);
+ test("abcdefghij", 5, 2, "abcdefghij", 0, 0, 2);
+ test("abcdefghij", 5, 2, "abcdefghij", 0, 1, 5);
+ test("abcdefghij", 5, 2, "abcdefghij", 0, 5, 5);
+ test("abcdefghij", 5, 2, "abcdefghij", 0, 9, 5);
+ test("abcdefghij", 5, 2, "abcdefghij", 0, 10, 5);
+ test("abcdefghij", 5, 2, "abcdefghij", 0, 11, 5);
+ test("abcdefghij", 5, 2, "abcdefghij", 1, 0, 2);
+ test("abcdefghij", 5, 2, "abcdefghij", 1, 1, 4);
+ test("abcdefghij", 5, 2, "abcdefghij", 1, 4, 4);
+ test("abcdefghij", 5, 2, "abcdefghij", 1, 8, 4);
+ test("abcdefghij", 5, 2, "abcdefghij", 1, 9, 4);
+ test("abcdefghij", 5, 2, "abcdefghij", 1, 10, 4);
+ test("abcdefghij", 5, 2, "abcdefghij", 5, 0, 2);
+ test("abcdefghij", 5, 2, "abcdefghij", 5, 1, 1);
+}
+
+void test30()
+{
+ test("abcdefghij", 5, 2, "abcdefghij", 5, 2, 0);
+ test("abcdefghij", 5, 2, "abcdefghij", 5, 4, -2);
+ test("abcdefghij", 5, 2, "abcdefghij", 5, 5, -3);
+ test("abcdefghij", 5, 2, "abcdefghij", 5, 6, -3);
+ test("abcdefghij", 5, 2, "abcdefghij", 9, 0, 2);
+ test("abcdefghij", 5, 2, "abcdefghij", 9, 1, -4);
+ test("abcdefghij", 5, 2, "abcdefghij", 9, 2, -4);
+ test("abcdefghij", 5, 2, "abcdefghij", 10, 0, 2);
+ test("abcdefghij", 5, 2, "abcdefghij", 10, 1, 2);
+ test("abcdefghij", 5, 2, "abcdefghij", 11, 0, 0);
+ test("abcdefghij", 5, 2, "abcdefghijklmnopqrst", 0, 0, 2);
+ test("abcdefghij", 5, 2, "abcdefghijklmnopqrst", 0, 1, 5);
+ test("abcdefghij", 5, 2, "abcdefghijklmnopqrst", 0, 10, 5);
+ test("abcdefghij", 5, 2, "abcdefghijklmnopqrst", 0, 19, 5);
+ test("abcdefghij", 5, 2, "abcdefghijklmnopqrst", 0, 20, 5);
+ test("abcdefghij", 5, 2, "abcdefghijklmnopqrst", 0, 21, 5);
+ test("abcdefghij", 5, 2, "abcdefghijklmnopqrst", 1, 0, 2);
+ test("abcdefghij", 5, 2, "abcdefghijklmnopqrst", 1, 1, 4);
+ test("abcdefghij", 5, 2, "abcdefghijklmnopqrst", 1, 9, 4);
+ test("abcdefghij", 5, 2, "abcdefghijklmnopqrst", 1, 18, 4);
+ test("abcdefghij", 5, 2, "abcdefghijklmnopqrst", 1, 19, 4);
+ test("abcdefghij", 5, 2, "abcdefghijklmnopqrst", 1, 20, 4);
+ test("abcdefghij", 5, 2, "abcdefghijklmnopqrst", 10, 0, 2);
+ test("abcdefghij", 5, 2, "abcdefghijklmnopqrst", 10, 1, -5);
+ test("abcdefghij", 5, 2, "abcdefghijklmnopqrst", 10, 5, -5);
+ test("abcdefghij", 5, 2, "abcdefghijklmnopqrst", 10, 9, -5);
+ test("abcdefghij", 5, 2, "abcdefghijklmnopqrst", 10, 10, -5);
+ test("abcdefghij", 5, 2, "abcdefghijklmnopqrst", 10, 11, -5);
+ test("abcdefghij", 5, 2, "abcdefghijklmnopqrst", 19, 0, 2);
+ test("abcdefghij", 5, 2, "abcdefghijklmnopqrst", 19, 1, -14);
+ test("abcdefghij", 5, 2, "abcdefghijklmnopqrst", 19, 2, -14);
+ test("abcdefghij", 5, 2, "abcdefghijklmnopqrst", 20, 0, 2);
+ test("abcdefghij", 5, 2, "abcdefghijklmnopqrst", 20, 1, 2);
+ test("abcdefghij", 5, 2, "abcdefghijklmnopqrst", 21, 0, 0);
+ test("abcdefghij", 5, 4, "", 0, 0, 4);
+ test("abcdefghij", 5, 4, "", 0, 1, 4);
+ test("abcdefghij", 5, 4, "", 1, 0, 0);
+ test("abcdefghij", 5, 4, "abcde", 0, 0, 4);
+ test("abcdefghij", 5, 4, "abcde", 0, 1, 5);
+ test("abcdefghij", 5, 4, "abcde", 0, 2, 5);
+ test("abcdefghij", 5, 4, "abcde", 0, 4, 5);
+ test("abcdefghij", 5, 4, "abcde", 0, 5, 5);
+ test("abcdefghij", 5, 4, "abcde", 0, 6, 5);
+ test("abcdefghij", 5, 4, "abcde", 1, 0, 4);
+ test("abcdefghij", 5, 4, "abcde", 1, 1, 4);
+ test("abcdefghij", 5, 4, "abcde", 1, 2, 4);
+ test("abcdefghij", 5, 4, "abcde", 1, 3, 4);
+ test("abcdefghij", 5, 4, "abcde", 1, 4, 4);
+ test("abcdefghij", 5, 4, "abcde", 1, 5, 4);
+ test("abcdefghij", 5, 4, "abcde", 2, 0, 4);
+ test("abcdefghij", 5, 4, "abcde", 2, 1, 3);
+ test("abcdefghij", 5, 4, "abcde", 2, 2, 3);
+ test("abcdefghij", 5, 4, "abcde", 2, 3, 3);
+ test("abcdefghij", 5, 4, "abcde", 2, 4, 3);
+ test("abcdefghij", 5, 4, "abcde", 4, 0, 4);
+ test("abcdefghij", 5, 4, "abcde", 4, 1, 1);
+ test("abcdefghij", 5, 4, "abcde", 4, 2, 1);
+ test("abcdefghij", 5, 4, "abcde", 5, 0, 4);
+ test("abcdefghij", 5, 4, "abcde", 5, 1, 4);
+ test("abcdefghij", 5, 4, "abcde", 6, 0, 0);
+ test("abcdefghij", 5, 4, "abcdefghij", 0, 0, 4);
+ test("abcdefghij", 5, 4, "abcdefghij", 0, 1, 5);
+ test("abcdefghij", 5, 4, "abcdefghij", 0, 5, 5);
+ test("abcdefghij", 5, 4, "abcdefghij", 0, 9, 5);
+ test("abcdefghij", 5, 4, "abcdefghij", 0, 10, 5);
+ test("abcdefghij", 5, 4, "abcdefghij", 0, 11, 5);
+ test("abcdefghij", 5, 4, "abcdefghij", 1, 0, 4);
+ test("abcdefghij", 5, 4, "abcdefghij", 1, 1, 4);
+ test("abcdefghij", 5, 4, "abcdefghij", 1, 4, 4);
+ test("abcdefghij", 5, 4, "abcdefghij", 1, 8, 4);
+ test("abcdefghij", 5, 4, "abcdefghij", 1, 9, 4);
+ test("abcdefghij", 5, 4, "abcdefghij", 1, 10, 4);
+ test("abcdefghij", 5, 4, "abcdefghij", 5, 0, 4);
+ test("abcdefghij", 5, 4, "abcdefghij", 5, 1, 3);
+ test("abcdefghij", 5, 4, "abcdefghij", 5, 2, 2);
+ test("abcdefghij", 5, 4, "abcdefghij", 5, 4, 0);
+ test("abcdefghij", 5, 4, "abcdefghij", 5, 5, -1);
+ test("abcdefghij", 5, 4, "abcdefghij", 5, 6, -1);
+ test("abcdefghij", 5, 4, "abcdefghij", 9, 0, 4);
+ test("abcdefghij", 5, 4, "abcdefghij", 9, 1, -4);
+ test("abcdefghij", 5, 4, "abcdefghij", 9, 2, -4);
+ test("abcdefghij", 5, 4, "abcdefghij", 10, 0, 4);
+ test("abcdefghij", 5, 4, "abcdefghij", 10, 1, 4);
+ test("abcdefghij", 5, 4, "abcdefghij", 11, 0, 0);
+ test("abcdefghij", 5, 4, "abcdefghijklmnopqrst", 0, 0, 4);
+ test("abcdefghij", 5, 4, "abcdefghijklmnopqrst", 0, 1, 5);
+ test("abcdefghij", 5, 4, "abcdefghijklmnopqrst", 0, 10, 5);
+ test("abcdefghij", 5, 4, "abcdefghijklmnopqrst", 0, 19, 5);
+ test("abcdefghij", 5, 4, "abcdefghijklmnopqrst", 0, 20, 5);
+ test("abcdefghij", 5, 4, "abcdefghijklmnopqrst", 0, 21, 5);
+ test("abcdefghij", 5, 4, "abcdefghijklmnopqrst", 1, 0, 4);
+ test("abcdefghij", 5, 4, "abcdefghijklmnopqrst", 1, 1, 4);
+ test("abcdefghij", 5, 4, "abcdefghijklmnopqrst", 1, 9, 4);
+ test("abcdefghij", 5, 4, "abcdefghijklmnopqrst", 1, 18, 4);
+ test("abcdefghij", 5, 4, "abcdefghijklmnopqrst", 1, 19, 4);
+ test("abcdefghij", 5, 4, "abcdefghijklmnopqrst", 1, 20, 4);
+ test("abcdefghij", 5, 4, "abcdefghijklmnopqrst", 10, 0, 4);
+ test("abcdefghij", 5, 4, "abcdefghijklmnopqrst", 10, 1, -5);
+ test("abcdefghij", 5, 4, "abcdefghijklmnopqrst", 10, 5, -5);
+ test("abcdefghij", 5, 4, "abcdefghijklmnopqrst", 10, 9, -5);
+}
+
+void test31()
+{
+ test("abcdefghij", 5, 4, "abcdefghijklmnopqrst", 10, 10, -5);
+ test("abcdefghij", 5, 4, "abcdefghijklmnopqrst", 10, 11, -5);
+ test("abcdefghij", 5, 4, "abcdefghijklmnopqrst", 19, 0, 4);
+ test("abcdefghij", 5, 4, "abcdefghijklmnopqrst", 19, 1, -14);
+ test("abcdefghij", 5, 4, "abcdefghijklmnopqrst", 19, 2, -14);
+ test("abcdefghij", 5, 4, "abcdefghijklmnopqrst", 20, 0, 4);
+ test("abcdefghij", 5, 4, "abcdefghijklmnopqrst", 20, 1, 4);
+ test("abcdefghij", 5, 4, "abcdefghijklmnopqrst", 21, 0, 0);
+ test("abcdefghij", 5, 5, "", 0, 0, 5);
+ test("abcdefghij", 5, 5, "", 0, 1, 5);
+ test("abcdefghij", 5, 5, "", 1, 0, 0);
+ test("abcdefghij", 5, 5, "abcde", 0, 0, 5);
+ test("abcdefghij", 5, 5, "abcde", 0, 1, 5);
+ test("abcdefghij", 5, 5, "abcde", 0, 2, 5);
+ test("abcdefghij", 5, 5, "abcde", 0, 4, 5);
+ test("abcdefghij", 5, 5, "abcde", 0, 5, 5);
+ test("abcdefghij", 5, 5, "abcde", 0, 6, 5);
+ test("abcdefghij", 5, 5, "abcde", 1, 0, 5);
+ test("abcdefghij", 5, 5, "abcde", 1, 1, 4);
+ test("abcdefghij", 5, 5, "abcde", 1, 2, 4);
+ test("abcdefghij", 5, 5, "abcde", 1, 3, 4);
+ test("abcdefghij", 5, 5, "abcde", 1, 4, 4);
+ test("abcdefghij", 5, 5, "abcde", 1, 5, 4);
+ test("abcdefghij", 5, 5, "abcde", 2, 0, 5);
+ test("abcdefghij", 5, 5, "abcde", 2, 1, 3);
+ test("abcdefghij", 5, 5, "abcde", 2, 2, 3);
+ test("abcdefghij", 5, 5, "abcde", 2, 3, 3);
+ test("abcdefghij", 5, 5, "abcde", 2, 4, 3);
+ test("abcdefghij", 5, 5, "abcde", 4, 0, 5);
+ test("abcdefghij", 5, 5, "abcde", 4, 1, 1);
+ test("abcdefghij", 5, 5, "abcde", 4, 2, 1);
+ test("abcdefghij", 5, 5, "abcde", 5, 0, 5);
+ test("abcdefghij", 5, 5, "abcde", 5, 1, 5);
+ test("abcdefghij", 5, 5, "abcde", 6, 0, 0);
+ test("abcdefghij", 5, 5, "abcdefghij", 0, 0, 5);
+ test("abcdefghij", 5, 5, "abcdefghij", 0, 1, 5);
+ test("abcdefghij", 5, 5, "abcdefghij", 0, 5, 5);
+ test("abcdefghij", 5, 5, "abcdefghij", 0, 9, 5);
+ test("abcdefghij", 5, 5, "abcdefghij", 0, 10, 5);
+ test("abcdefghij", 5, 5, "abcdefghij", 0, 11, 5);
+ test("abcdefghij", 5, 5, "abcdefghij", 1, 0, 5);
+ test("abcdefghij", 5, 5, "abcdefghij", 1, 1, 4);
+ test("abcdefghij", 5, 5, "abcdefghij", 1, 4, 4);
+ test("abcdefghij", 5, 5, "abcdefghij", 1, 8, 4);
+ test("abcdefghij", 5, 5, "abcdefghij", 1, 9, 4);
+ test("abcdefghij", 5, 5, "abcdefghij", 1, 10, 4);
+ test("abcdefghij", 5, 5, "abcdefghij", 5, 0, 5);
+ test("abcdefghij", 5, 5, "abcdefghij", 5, 1, 4);
+ test("abcdefghij", 5, 5, "abcdefghij", 5, 2, 3);
+ test("abcdefghij", 5, 5, "abcdefghij", 5, 4, 1);
+ test("abcdefghij", 5, 5, "abcdefghij", 5, 5, 0);
+ test("abcdefghij", 5, 5, "abcdefghij", 5, 6, 0);
+ test("abcdefghij", 5, 5, "abcdefghij", 9, 0, 5);
+ test("abcdefghij", 5, 5, "abcdefghij", 9, 1, -4);
+ test("abcdefghij", 5, 5, "abcdefghij", 9, 2, -4);
+ test("abcdefghij", 5, 5, "abcdefghij", 10, 0, 5);
+ test("abcdefghij", 5, 5, "abcdefghij", 10, 1, 5);
+ test("abcdefghij", 5, 5, "abcdefghij", 11, 0, 0);
+ test("abcdefghij", 5, 5, "abcdefghijklmnopqrst", 0, 0, 5);
+ test("abcdefghij", 5, 5, "abcdefghijklmnopqrst", 0, 1, 5);
+ test("abcdefghij", 5, 5, "abcdefghijklmnopqrst", 0, 10, 5);
+ test("abcdefghij", 5, 5, "abcdefghijklmnopqrst", 0, 19, 5);
+ test("abcdefghij", 5, 5, "abcdefghijklmnopqrst", 0, 20, 5);
+ test("abcdefghij", 5, 5, "abcdefghijklmnopqrst", 0, 21, 5);
+ test("abcdefghij", 5, 5, "abcdefghijklmnopqrst", 1, 0, 5);
+ test("abcdefghij", 5, 5, "abcdefghijklmnopqrst", 1, 1, 4);
+ test("abcdefghij", 5, 5, "abcdefghijklmnopqrst", 1, 9, 4);
+ test("abcdefghij", 5, 5, "abcdefghijklmnopqrst", 1, 18, 4);
+ test("abcdefghij", 5, 5, "abcdefghijklmnopqrst", 1, 19, 4);
+ test("abcdefghij", 5, 5, "abcdefghijklmnopqrst", 1, 20, 4);
+ test("abcdefghij", 5, 5, "abcdefghijklmnopqrst", 10, 0, 5);
+ test("abcdefghij", 5, 5, "abcdefghijklmnopqrst", 10, 1, -5);
+ test("abcdefghij", 5, 5, "abcdefghijklmnopqrst", 10, 5, -5);
+ test("abcdefghij", 5, 5, "abcdefghijklmnopqrst", 10, 9, -5);
+ test("abcdefghij", 5, 5, "abcdefghijklmnopqrst", 10, 10, -5);
+ test("abcdefghij", 5, 5, "abcdefghijklmnopqrst", 10, 11, -5);
+ test("abcdefghij", 5, 5, "abcdefghijklmnopqrst", 19, 0, 5);
+ test("abcdefghij", 5, 5, "abcdefghijklmnopqrst", 19, 1, -14);
+ test("abcdefghij", 5, 5, "abcdefghijklmnopqrst", 19, 2, -14);
+ test("abcdefghij", 5, 5, "abcdefghijklmnopqrst", 20, 0, 5);
+ test("abcdefghij", 5, 5, "abcdefghijklmnopqrst", 20, 1, 5);
+ test("abcdefghij", 5, 5, "abcdefghijklmnopqrst", 21, 0, 0);
+ test("abcdefghij", 5, 6, "", 0, 0, 5);
+ test("abcdefghij", 5, 6, "", 0, 1, 5);
+ test("abcdefghij", 5, 6, "", 1, 0, 0);
+ test("abcdefghij", 5, 6, "abcde", 0, 0, 5);
+ test("abcdefghij", 5, 6, "abcde", 0, 1, 5);
+ test("abcdefghij", 5, 6, "abcde", 0, 2, 5);
+ test("abcdefghij", 5, 6, "abcde", 0, 4, 5);
+ test("abcdefghij", 5, 6, "abcde", 0, 5, 5);
+ test("abcdefghij", 5, 6, "abcde", 0, 6, 5);
+ test("abcdefghij", 5, 6, "abcde", 1, 0, 5);
+ test("abcdefghij", 5, 6, "abcde", 1, 1, 4);
+ test("abcdefghij", 5, 6, "abcde", 1, 2, 4);
+ test("abcdefghij", 5, 6, "abcde", 1, 3, 4);
+ test("abcdefghij", 5, 6, "abcde", 1, 4, 4);
+ test("abcdefghij", 5, 6, "abcde", 1, 5, 4);
+ test("abcdefghij", 5, 6, "abcde", 2, 0, 5);
+ test("abcdefghij", 5, 6, "abcde", 2, 1, 3);
+ test("abcdefghij", 5, 6, "abcde", 2, 2, 3);
+}
+
+void test32()
+{
+ test("abcdefghij", 5, 6, "abcde", 2, 3, 3);
+ test("abcdefghij", 5, 6, "abcde", 2, 4, 3);
+ test("abcdefghij", 5, 6, "abcde", 4, 0, 5);
+ test("abcdefghij", 5, 6, "abcde", 4, 1, 1);
+ test("abcdefghij", 5, 6, "abcde", 4, 2, 1);
+ test("abcdefghij", 5, 6, "abcde", 5, 0, 5);
+ test("abcdefghij", 5, 6, "abcde", 5, 1, 5);
+ test("abcdefghij", 5, 6, "abcde", 6, 0, 0);
+ test("abcdefghij", 5, 6, "abcdefghij", 0, 0, 5);
+ test("abcdefghij", 5, 6, "abcdefghij", 0, 1, 5);
+ test("abcdefghij", 5, 6, "abcdefghij", 0, 5, 5);
+ test("abcdefghij", 5, 6, "abcdefghij", 0, 9, 5);
+ test("abcdefghij", 5, 6, "abcdefghij", 0, 10, 5);
+ test("abcdefghij", 5, 6, "abcdefghij", 0, 11, 5);
+ test("abcdefghij", 5, 6, "abcdefghij", 1, 0, 5);
+ test("abcdefghij", 5, 6, "abcdefghij", 1, 1, 4);
+ test("abcdefghij", 5, 6, "abcdefghij", 1, 4, 4);
+ test("abcdefghij", 5, 6, "abcdefghij", 1, 8, 4);
+ test("abcdefghij", 5, 6, "abcdefghij", 1, 9, 4);
+ test("abcdefghij", 5, 6, "abcdefghij", 1, 10, 4);
+ test("abcdefghij", 5, 6, "abcdefghij", 5, 0, 5);
+ test("abcdefghij", 5, 6, "abcdefghij", 5, 1, 4);
+ test("abcdefghij", 5, 6, "abcdefghij", 5, 2, 3);
+ test("abcdefghij", 5, 6, "abcdefghij", 5, 4, 1);
+ test("abcdefghij", 5, 6, "abcdefghij", 5, 5, 0);
+ test("abcdefghij", 5, 6, "abcdefghij", 5, 6, 0);
+ test("abcdefghij", 5, 6, "abcdefghij", 9, 0, 5);
+ test("abcdefghij", 5, 6, "abcdefghij", 9, 1, -4);
+ test("abcdefghij", 5, 6, "abcdefghij", 9, 2, -4);
+ test("abcdefghij", 5, 6, "abcdefghij", 10, 0, 5);
+ test("abcdefghij", 5, 6, "abcdefghij", 10, 1, 5);
+ test("abcdefghij", 5, 6, "abcdefghij", 11, 0, 0);
+ test("abcdefghij", 5, 6, "abcdefghijklmnopqrst", 0, 0, 5);
+ test("abcdefghij", 5, 6, "abcdefghijklmnopqrst", 0, 1, 5);
+ test("abcdefghij", 5, 6, "abcdefghijklmnopqrst", 0, 10, 5);
+ test("abcdefghij", 5, 6, "abcdefghijklmnopqrst", 0, 19, 5);
+ test("abcdefghij", 5, 6, "abcdefghijklmnopqrst", 0, 20, 5);
+ test("abcdefghij", 5, 6, "abcdefghijklmnopqrst", 0, 21, 5);
+ test("abcdefghij", 5, 6, "abcdefghijklmnopqrst", 1, 0, 5);
+ test("abcdefghij", 5, 6, "abcdefghijklmnopqrst", 1, 1, 4);
+ test("abcdefghij", 5, 6, "abcdefghijklmnopqrst", 1, 9, 4);
+ test("abcdefghij", 5, 6, "abcdefghijklmnopqrst", 1, 18, 4);
+ test("abcdefghij", 5, 6, "abcdefghijklmnopqrst", 1, 19, 4);
+ test("abcdefghij", 5, 6, "abcdefghijklmnopqrst", 1, 20, 4);
+ test("abcdefghij", 5, 6, "abcdefghijklmnopqrst", 10, 0, 5);
+ test("abcdefghij", 5, 6, "abcdefghijklmnopqrst", 10, 1, -5);
+ test("abcdefghij", 5, 6, "abcdefghijklmnopqrst", 10, 5, -5);
+ test("abcdefghij", 5, 6, "abcdefghijklmnopqrst", 10, 9, -5);
+ test("abcdefghij", 5, 6, "abcdefghijklmnopqrst", 10, 10, -5);
+ test("abcdefghij", 5, 6, "abcdefghijklmnopqrst", 10, 11, -5);
+ test("abcdefghij", 5, 6, "abcdefghijklmnopqrst", 19, 0, 5);
+ test("abcdefghij", 5, 6, "abcdefghijklmnopqrst", 19, 1, -14);
+ test("abcdefghij", 5, 6, "abcdefghijklmnopqrst", 19, 2, -14);
+ test("abcdefghij", 5, 6, "abcdefghijklmnopqrst", 20, 0, 5);
+ test("abcdefghij", 5, 6, "abcdefghijklmnopqrst", 20, 1, 5);
+ test("abcdefghij", 5, 6, "abcdefghijklmnopqrst", 21, 0, 0);
+ test("abcdefghij", 9, 0, "", 0, 0, 0);
+ test("abcdefghij", 9, 0, "", 0, 1, 0);
+ test("abcdefghij", 9, 0, "", 1, 0, 0);
+ test("abcdefghij", 9, 0, "abcde", 0, 0, 0);
+ test("abcdefghij", 9, 0, "abcde", 0, 1, -1);
+ test("abcdefghij", 9, 0, "abcde", 0, 2, -2);
+ test("abcdefghij", 9, 0, "abcde", 0, 4, -4);
+ test("abcdefghij", 9, 0, "abcde", 0, 5, -5);
+ test("abcdefghij", 9, 0, "abcde", 0, 6, -5);
+ test("abcdefghij", 9, 0, "abcde", 1, 0, 0);
+ test("abcdefghij", 9, 0, "abcde", 1, 1, -1);
+ test("abcdefghij", 9, 0, "abcde", 1, 2, -2);
+ test("abcdefghij", 9, 0, "abcde", 1, 3, -3);
+ test("abcdefghij", 9, 0, "abcde", 1, 4, -4);
+ test("abcdefghij", 9, 0, "abcde", 1, 5, -4);
+ test("abcdefghij", 9, 0, "abcde", 2, 0, 0);
+ test("abcdefghij", 9, 0, "abcde", 2, 1, -1);
+ test("abcdefghij", 9, 0, "abcde", 2, 2, -2);
+ test("abcdefghij", 9, 0, "abcde", 2, 3, -3);
+ test("abcdefghij", 9, 0, "abcde", 2, 4, -3);
+ test("abcdefghij", 9, 0, "abcde", 4, 0, 0);
+ test("abcdefghij", 9, 0, "abcde", 4, 1, -1);
+ test("abcdefghij", 9, 0, "abcde", 4, 2, -1);
+ test("abcdefghij", 9, 0, "abcde", 5, 0, 0);
+ test("abcdefghij", 9, 0, "abcde", 5, 1, 0);
+ test("abcdefghij", 9, 0, "abcde", 6, 0, 0);
+ test("abcdefghij", 9, 0, "abcdefghij", 0, 0, 0);
+ test("abcdefghij", 9, 0, "abcdefghij", 0, 1, -1);
+ test("abcdefghij", 9, 0, "abcdefghij", 0, 5, -5);
+ test("abcdefghij", 9, 0, "abcdefghij", 0, 9, -9);
+ test("abcdefghij", 9, 0, "abcdefghij", 0, 10, -10);
+ test("abcdefghij", 9, 0, "abcdefghij", 0, 11, -10);
+ test("abcdefghij", 9, 0, "abcdefghij", 1, 0, 0);
+ test("abcdefghij", 9, 0, "abcdefghij", 1, 1, -1);
+ test("abcdefghij", 9, 0, "abcdefghij", 1, 4, -4);
+ test("abcdefghij", 9, 0, "abcdefghij", 1, 8, -8);
+ test("abcdefghij", 9, 0, "abcdefghij", 1, 9, -9);
+ test("abcdefghij", 9, 0, "abcdefghij", 1, 10, -9);
+ test("abcdefghij", 9, 0, "abcdefghij", 5, 0, 0);
+ test("abcdefghij", 9, 0, "abcdefghij", 5, 1, -1);
+ test("abcdefghij", 9, 0, "abcdefghij", 5, 2, -2);
+ test("abcdefghij", 9, 0, "abcdefghij", 5, 4, -4);
+ test("abcdefghij", 9, 0, "abcdefghij", 5, 5, -5);
+ test("abcdefghij", 9, 0, "abcdefghij", 5, 6, -5);
+}
+
+void test33()
+{
+ test("abcdefghij", 9, 0, "abcdefghij", 9, 0, 0);
+ test("abcdefghij", 9, 0, "abcdefghij", 9, 1, -1);
+ test("abcdefghij", 9, 0, "abcdefghij", 9, 2, -1);
+ test("abcdefghij", 9, 0, "abcdefghij", 10, 0, 0);
+ test("abcdefghij", 9, 0, "abcdefghij", 10, 1, 0);
+ test("abcdefghij", 9, 0, "abcdefghij", 11, 0, 0);
+ test("abcdefghij", 9, 0, "abcdefghijklmnopqrst", 0, 0, 0);
+ test("abcdefghij", 9, 0, "abcdefghijklmnopqrst", 0, 1, -1);
+ test("abcdefghij", 9, 0, "abcdefghijklmnopqrst", 0, 10, -10);
+ test("abcdefghij", 9, 0, "abcdefghijklmnopqrst", 0, 19, -19);
+ test("abcdefghij", 9, 0, "abcdefghijklmnopqrst", 0, 20, -20);
+ test("abcdefghij", 9, 0, "abcdefghijklmnopqrst", 0, 21, -20);
+ test("abcdefghij", 9, 0, "abcdefghijklmnopqrst", 1, 0, 0);
+ test("abcdefghij", 9, 0, "abcdefghijklmnopqrst", 1, 1, -1);
+ test("abcdefghij", 9, 0, "abcdefghijklmnopqrst", 1, 9, -9);
+ test("abcdefghij", 9, 0, "abcdefghijklmnopqrst", 1, 18, -18);
+ test("abcdefghij", 9, 0, "abcdefghijklmnopqrst", 1, 19, -19);
+ test("abcdefghij", 9, 0, "abcdefghijklmnopqrst", 1, 20, -19);
+ test("abcdefghij", 9, 0, "abcdefghijklmnopqrst", 10, 0, 0);
+ test("abcdefghij", 9, 0, "abcdefghijklmnopqrst", 10, 1, -1);
+ test("abcdefghij", 9, 0, "abcdefghijklmnopqrst", 10, 5, -5);
+ test("abcdefghij", 9, 0, "abcdefghijklmnopqrst", 10, 9, -9);
+ test("abcdefghij", 9, 0, "abcdefghijklmnopqrst", 10, 10, -10);
+ test("abcdefghij", 9, 0, "abcdefghijklmnopqrst", 10, 11, -10);
+ test("abcdefghij", 9, 0, "abcdefghijklmnopqrst", 19, 0, 0);
+ test("abcdefghij", 9, 0, "abcdefghijklmnopqrst", 19, 1, -1);
+ test("abcdefghij", 9, 0, "abcdefghijklmnopqrst", 19, 2, -1);
+ test("abcdefghij", 9, 0, "abcdefghijklmnopqrst", 20, 0, 0);
+ test("abcdefghij", 9, 0, "abcdefghijklmnopqrst", 20, 1, 0);
+ test("abcdefghij", 9, 0, "abcdefghijklmnopqrst", 21, 0, 0);
+ test("abcdefghij", 9, 1, "", 0, 0, 1);
+ test("abcdefghij", 9, 1, "", 0, 1, 1);
+ test("abcdefghij", 9, 1, "", 1, 0, 0);
+ test("abcdefghij", 9, 1, "abcde", 0, 0, 1);
+ test("abcdefghij", 9, 1, "abcde", 0, 1, 9);
+ test("abcdefghij", 9, 1, "abcde", 0, 2, 9);
+ test("abcdefghij", 9, 1, "abcde", 0, 4, 9);
+ test("abcdefghij", 9, 1, "abcde", 0, 5, 9);
+ test("abcdefghij", 9, 1, "abcde", 0, 6, 9);
+ test("abcdefghij", 9, 1, "abcde", 1, 0, 1);
+ test("abcdefghij", 9, 1, "abcde", 1, 1, 8);
+ test("abcdefghij", 9, 1, "abcde", 1, 2, 8);
+ test("abcdefghij", 9, 1, "abcde", 1, 3, 8);
+ test("abcdefghij", 9, 1, "abcde", 1, 4, 8);
+ test("abcdefghij", 9, 1, "abcde", 1, 5, 8);
+ test("abcdefghij", 9, 1, "abcde", 2, 0, 1);
+ test("abcdefghij", 9, 1, "abcde", 2, 1, 7);
+ test("abcdefghij", 9, 1, "abcde", 2, 2, 7);
+ test("abcdefghij", 9, 1, "abcde", 2, 3, 7);
+ test("abcdefghij", 9, 1, "abcde", 2, 4, 7);
+ test("abcdefghij", 9, 1, "abcde", 4, 0, 1);
+ test("abcdefghij", 9, 1, "abcde", 4, 1, 5);
+ test("abcdefghij", 9, 1, "abcde", 4, 2, 5);
+ test("abcdefghij", 9, 1, "abcde", 5, 0, 1);
+ test("abcdefghij", 9, 1, "abcde", 5, 1, 1);
+ test("abcdefghij", 9, 1, "abcde", 6, 0, 0);
+ test("abcdefghij", 9, 1, "abcdefghij", 0, 0, 1);
+ test("abcdefghij", 9, 1, "abcdefghij", 0, 1, 9);
+ test("abcdefghij", 9, 1, "abcdefghij", 0, 5, 9);
+ test("abcdefghij", 9, 1, "abcdefghij", 0, 9, 9);
+ test("abcdefghij", 9, 1, "abcdefghij", 0, 10, 9);
+ test("abcdefghij", 9, 1, "abcdefghij", 0, 11, 9);
+ test("abcdefghij", 9, 1, "abcdefghij", 1, 0, 1);
+ test("abcdefghij", 9, 1, "abcdefghij", 1, 1, 8);
+ test("abcdefghij", 9, 1, "abcdefghij", 1, 4, 8);
+ test("abcdefghij", 9, 1, "abcdefghij", 1, 8, 8);
+ test("abcdefghij", 9, 1, "abcdefghij", 1, 9, 8);
+ test("abcdefghij", 9, 1, "abcdefghij", 1, 10, 8);
+ test("abcdefghij", 9, 1, "abcdefghij", 5, 0, 1);
+ test("abcdefghij", 9, 1, "abcdefghij", 5, 1, 4);
+ test("abcdefghij", 9, 1, "abcdefghij", 5, 2, 4);
+ test("abcdefghij", 9, 1, "abcdefghij", 5, 4, 4);
+ test("abcdefghij", 9, 1, "abcdefghij", 5, 5, 4);
+ test("abcdefghij", 9, 1, "abcdefghij", 5, 6, 4);
+ test("abcdefghij", 9, 1, "abcdefghij", 9, 0, 1);
+ test("abcdefghij", 9, 1, "abcdefghij", 9, 1, 0);
+ test("abcdefghij", 9, 1, "abcdefghij", 9, 2, 0);
+ test("abcdefghij", 9, 1, "abcdefghij", 10, 0, 1);
+ test("abcdefghij", 9, 1, "abcdefghij", 10, 1, 1);
+ test("abcdefghij", 9, 1, "abcdefghij", 11, 0, 0);
+ test("abcdefghij", 9, 1, "abcdefghijklmnopqrst", 0, 0, 1);
+ test("abcdefghij", 9, 1, "abcdefghijklmnopqrst", 0, 1, 9);
+ test("abcdefghij", 9, 1, "abcdefghijklmnopqrst", 0, 10, 9);
+ test("abcdefghij", 9, 1, "abcdefghijklmnopqrst", 0, 19, 9);
+ test("abcdefghij", 9, 1, "abcdefghijklmnopqrst", 0, 20, 9);
+ test("abcdefghij", 9, 1, "abcdefghijklmnopqrst", 0, 21, 9);
+ test("abcdefghij", 9, 1, "abcdefghijklmnopqrst", 1, 0, 1);
+ test("abcdefghij", 9, 1, "abcdefghijklmnopqrst", 1, 1, 8);
+ test("abcdefghij", 9, 1, "abcdefghijklmnopqrst", 1, 9, 8);
+ test("abcdefghij", 9, 1, "abcdefghijklmnopqrst", 1, 18, 8);
+ test("abcdefghij", 9, 1, "abcdefghijklmnopqrst", 1, 19, 8);
+ test("abcdefghij", 9, 1, "abcdefghijklmnopqrst", 1, 20, 8);
+ test("abcdefghij", 9, 1, "abcdefghijklmnopqrst", 10, 0, 1);
+ test("abcdefghij", 9, 1, "abcdefghijklmnopqrst", 10, 1, -1);
+ test("abcdefghij", 9, 1, "abcdefghijklmnopqrst", 10, 5, -1);
+ test("abcdefghij", 9, 1, "abcdefghijklmnopqrst", 10, 9, -1);
+ test("abcdefghij", 9, 1, "abcdefghijklmnopqrst", 10, 10, -1);
+ test("abcdefghij", 9, 1, "abcdefghijklmnopqrst", 10, 11, -1);
+ test("abcdefghij", 9, 1, "abcdefghijklmnopqrst", 19, 0, 1);
+ test("abcdefghij", 9, 1, "abcdefghijklmnopqrst", 19, 1, -10);
+}
+
+void test34()
+{
+ test("abcdefghij", 9, 1, "abcdefghijklmnopqrst", 19, 2, -10);
+ test("abcdefghij", 9, 1, "abcdefghijklmnopqrst", 20, 0, 1);
+ test("abcdefghij", 9, 1, "abcdefghijklmnopqrst", 20, 1, 1);
+ test("abcdefghij", 9, 1, "abcdefghijklmnopqrst", 21, 0, 0);
+ test("abcdefghij", 9, 2, "", 0, 0, 1);
+ test("abcdefghij", 9, 2, "", 0, 1, 1);
+ test("abcdefghij", 9, 2, "", 1, 0, 0);
+ test("abcdefghij", 9, 2, "abcde", 0, 0, 1);
+ test("abcdefghij", 9, 2, "abcde", 0, 1, 9);
+ test("abcdefghij", 9, 2, "abcde", 0, 2, 9);
+ test("abcdefghij", 9, 2, "abcde", 0, 4, 9);
+ test("abcdefghij", 9, 2, "abcde", 0, 5, 9);
+ test("abcdefghij", 9, 2, "abcde", 0, 6, 9);
+ test("abcdefghij", 9, 2, "abcde", 1, 0, 1);
+ test("abcdefghij", 9, 2, "abcde", 1, 1, 8);
+ test("abcdefghij", 9, 2, "abcde", 1, 2, 8);
+ test("abcdefghij", 9, 2, "abcde", 1, 3, 8);
+ test("abcdefghij", 9, 2, "abcde", 1, 4, 8);
+ test("abcdefghij", 9, 2, "abcde", 1, 5, 8);
+ test("abcdefghij", 9, 2, "abcde", 2, 0, 1);
+ test("abcdefghij", 9, 2, "abcde", 2, 1, 7);
+ test("abcdefghij", 9, 2, "abcde", 2, 2, 7);
+ test("abcdefghij", 9, 2, "abcde", 2, 3, 7);
+ test("abcdefghij", 9, 2, "abcde", 2, 4, 7);
+ test("abcdefghij", 9, 2, "abcde", 4, 0, 1);
+ test("abcdefghij", 9, 2, "abcde", 4, 1, 5);
+ test("abcdefghij", 9, 2, "abcde", 4, 2, 5);
+ test("abcdefghij", 9, 2, "abcde", 5, 0, 1);
+ test("abcdefghij", 9, 2, "abcde", 5, 1, 1);
+ test("abcdefghij", 9, 2, "abcde", 6, 0, 0);
+ test("abcdefghij", 9, 2, "abcdefghij", 0, 0, 1);
+ test("abcdefghij", 9, 2, "abcdefghij", 0, 1, 9);
+ test("abcdefghij", 9, 2, "abcdefghij", 0, 5, 9);
+ test("abcdefghij", 9, 2, "abcdefghij", 0, 9, 9);
+ test("abcdefghij", 9, 2, "abcdefghij", 0, 10, 9);
+ test("abcdefghij", 9, 2, "abcdefghij", 0, 11, 9);
+ test("abcdefghij", 9, 2, "abcdefghij", 1, 0, 1);
+ test("abcdefghij", 9, 2, "abcdefghij", 1, 1, 8);
+ test("abcdefghij", 9, 2, "abcdefghij", 1, 4, 8);
+ test("abcdefghij", 9, 2, "abcdefghij", 1, 8, 8);
+ test("abcdefghij", 9, 2, "abcdefghij", 1, 9, 8);
+ test("abcdefghij", 9, 2, "abcdefghij", 1, 10, 8);
+ test("abcdefghij", 9, 2, "abcdefghij", 5, 0, 1);
+ test("abcdefghij", 9, 2, "abcdefghij", 5, 1, 4);
+ test("abcdefghij", 9, 2, "abcdefghij", 5, 2, 4);
+ test("abcdefghij", 9, 2, "abcdefghij", 5, 4, 4);
+ test("abcdefghij", 9, 2, "abcdefghij", 5, 5, 4);
+ test("abcdefghij", 9, 2, "abcdefghij", 5, 6, 4);
+ test("abcdefghij", 9, 2, "abcdefghij", 9, 0, 1);
+ test("abcdefghij", 9, 2, "abcdefghij", 9, 1, 0);
+ test("abcdefghij", 9, 2, "abcdefghij", 9, 2, 0);
+ test("abcdefghij", 9, 2, "abcdefghij", 10, 0, 1);
+ test("abcdefghij", 9, 2, "abcdefghij", 10, 1, 1);
+ test("abcdefghij", 9, 2, "abcdefghij", 11, 0, 0);
+ test("abcdefghij", 9, 2, "abcdefghijklmnopqrst", 0, 0, 1);
+ test("abcdefghij", 9, 2, "abcdefghijklmnopqrst", 0, 1, 9);
+ test("abcdefghij", 9, 2, "abcdefghijklmnopqrst", 0, 10, 9);
+ test("abcdefghij", 9, 2, "abcdefghijklmnopqrst", 0, 19, 9);
+ test("abcdefghij", 9, 2, "abcdefghijklmnopqrst", 0, 20, 9);
+ test("abcdefghij", 9, 2, "abcdefghijklmnopqrst", 0, 21, 9);
+ test("abcdefghij", 9, 2, "abcdefghijklmnopqrst", 1, 0, 1);
+ test("abcdefghij", 9, 2, "abcdefghijklmnopqrst", 1, 1, 8);
+ test("abcdefghij", 9, 2, "abcdefghijklmnopqrst", 1, 9, 8);
+ test("abcdefghij", 9, 2, "abcdefghijklmnopqrst", 1, 18, 8);
+ test("abcdefghij", 9, 2, "abcdefghijklmnopqrst", 1, 19, 8);
+ test("abcdefghij", 9, 2, "abcdefghijklmnopqrst", 1, 20, 8);
+ test("abcdefghij", 9, 2, "abcdefghijklmnopqrst", 10, 0, 1);
+ test("abcdefghij", 9, 2, "abcdefghijklmnopqrst", 10, 1, -1);
+ test("abcdefghij", 9, 2, "abcdefghijklmnopqrst", 10, 5, -1);
+ test("abcdefghij", 9, 2, "abcdefghijklmnopqrst", 10, 9, -1);
+ test("abcdefghij", 9, 2, "abcdefghijklmnopqrst", 10, 10, -1);
+ test("abcdefghij", 9, 2, "abcdefghijklmnopqrst", 10, 11, -1);
+ test("abcdefghij", 9, 2, "abcdefghijklmnopqrst", 19, 0, 1);
+ test("abcdefghij", 9, 2, "abcdefghijklmnopqrst", 19, 1, -10);
+ test("abcdefghij", 9, 2, "abcdefghijklmnopqrst", 19, 2, -10);
+ test("abcdefghij", 9, 2, "abcdefghijklmnopqrst", 20, 0, 1);
+ test("abcdefghij", 9, 2, "abcdefghijklmnopqrst", 20, 1, 1);
+ test("abcdefghij", 9, 2, "abcdefghijklmnopqrst", 21, 0, 0);
+ test("abcdefghij", 10, 0, "", 0, 0, 0);
+ test("abcdefghij", 10, 0, "", 0, 1, 0);
+ test("abcdefghij", 10, 0, "", 1, 0, 0);
+ test("abcdefghij", 10, 0, "abcde", 0, 0, 0);
+ test("abcdefghij", 10, 0, "abcde", 0, 1, -1);
+ test("abcdefghij", 10, 0, "abcde", 0, 2, -2);
+ test("abcdefghij", 10, 0, "abcde", 0, 4, -4);
+ test("abcdefghij", 10, 0, "abcde", 0, 5, -5);
+ test("abcdefghij", 10, 0, "abcde", 0, 6, -5);
+ test("abcdefghij", 10, 0, "abcde", 1, 0, 0);
+ test("abcdefghij", 10, 0, "abcde", 1, 1, -1);
+ test("abcdefghij", 10, 0, "abcde", 1, 2, -2);
+ test("abcdefghij", 10, 0, "abcde", 1, 3, -3);
+ test("abcdefghij", 10, 0, "abcde", 1, 4, -4);
+ test("abcdefghij", 10, 0, "abcde", 1, 5, -4);
+ test("abcdefghij", 10, 0, "abcde", 2, 0, 0);
+ test("abcdefghij", 10, 0, "abcde", 2, 1, -1);
+ test("abcdefghij", 10, 0, "abcde", 2, 2, -2);
+ test("abcdefghij", 10, 0, "abcde", 2, 3, -3);
+ test("abcdefghij", 10, 0, "abcde", 2, 4, -3);
+ test("abcdefghij", 10, 0, "abcde", 4, 0, 0);
+ test("abcdefghij", 10, 0, "abcde", 4, 1, -1);
+}
+
+void test35()
+{
+ test("abcdefghij", 10, 0, "abcde", 4, 2, -1);
+ test("abcdefghij", 10, 0, "abcde", 5, 0, 0);
+ test("abcdefghij", 10, 0, "abcde", 5, 1, 0);
+ test("abcdefghij", 10, 0, "abcde", 6, 0, 0);
+ test("abcdefghij", 10, 0, "abcdefghij", 0, 0, 0);
+ test("abcdefghij", 10, 0, "abcdefghij", 0, 1, -1);
+ test("abcdefghij", 10, 0, "abcdefghij", 0, 5, -5);
+ test("abcdefghij", 10, 0, "abcdefghij", 0, 9, -9);
+ test("abcdefghij", 10, 0, "abcdefghij", 0, 10, -10);
+ test("abcdefghij", 10, 0, "abcdefghij", 0, 11, -10);
+ test("abcdefghij", 10, 0, "abcdefghij", 1, 0, 0);
+ test("abcdefghij", 10, 0, "abcdefghij", 1, 1, -1);
+ test("abcdefghij", 10, 0, "abcdefghij", 1, 4, -4);
+ test("abcdefghij", 10, 0, "abcdefghij", 1, 8, -8);
+ test("abcdefghij", 10, 0, "abcdefghij", 1, 9, -9);
+ test("abcdefghij", 10, 0, "abcdefghij", 1, 10, -9);
+ test("abcdefghij", 10, 0, "abcdefghij", 5, 0, 0);
+ test("abcdefghij", 10, 0, "abcdefghij", 5, 1, -1);
+ test("abcdefghij", 10, 0, "abcdefghij", 5, 2, -2);
+ test("abcdefghij", 10, 0, "abcdefghij", 5, 4, -4);
+ test("abcdefghij", 10, 0, "abcdefghij", 5, 5, -5);
+ test("abcdefghij", 10, 0, "abcdefghij", 5, 6, -5);
+ test("abcdefghij", 10, 0, "abcdefghij", 9, 0, 0);
+ test("abcdefghij", 10, 0, "abcdefghij", 9, 1, -1);
+ test("abcdefghij", 10, 0, "abcdefghij", 9, 2, -1);
+ test("abcdefghij", 10, 0, "abcdefghij", 10, 0, 0);
+ test("abcdefghij", 10, 0, "abcdefghij", 10, 1, 0);
+ test("abcdefghij", 10, 0, "abcdefghij", 11, 0, 0);
+ test("abcdefghij", 10, 0, "abcdefghijklmnopqrst", 0, 0, 0);
+ test("abcdefghij", 10, 0, "abcdefghijklmnopqrst", 0, 1, -1);
+ test("abcdefghij", 10, 0, "abcdefghijklmnopqrst", 0, 10, -10);
+ test("abcdefghij", 10, 0, "abcdefghijklmnopqrst", 0, 19, -19);
+ test("abcdefghij", 10, 0, "abcdefghijklmnopqrst", 0, 20, -20);
+ test("abcdefghij", 10, 0, "abcdefghijklmnopqrst", 0, 21, -20);
+ test("abcdefghij", 10, 0, "abcdefghijklmnopqrst", 1, 0, 0);
+ test("abcdefghij", 10, 0, "abcdefghijklmnopqrst", 1, 1, -1);
+ test("abcdefghij", 10, 0, "abcdefghijklmnopqrst", 1, 9, -9);
+ test("abcdefghij", 10, 0, "abcdefghijklmnopqrst", 1, 18, -18);
+ test("abcdefghij", 10, 0, "abcdefghijklmnopqrst", 1, 19, -19);
+ test("abcdefghij", 10, 0, "abcdefghijklmnopqrst", 1, 20, -19);
+ test("abcdefghij", 10, 0, "abcdefghijklmnopqrst", 10, 0, 0);
+ test("abcdefghij", 10, 0, "abcdefghijklmnopqrst", 10, 1, -1);
+ test("abcdefghij", 10, 0, "abcdefghijklmnopqrst", 10, 5, -5);
+ test("abcdefghij", 10, 0, "abcdefghijklmnopqrst", 10, 9, -9);
+ test("abcdefghij", 10, 0, "abcdefghijklmnopqrst", 10, 10, -10);
+ test("abcdefghij", 10, 0, "abcdefghijklmnopqrst", 10, 11, -10);
+ test("abcdefghij", 10, 0, "abcdefghijklmnopqrst", 19, 0, 0);
+ test("abcdefghij", 10, 0, "abcdefghijklmnopqrst", 19, 1, -1);
+ test("abcdefghij", 10, 0, "abcdefghijklmnopqrst", 19, 2, -1);
+ test("abcdefghij", 10, 0, "abcdefghijklmnopqrst", 20, 0, 0);
+ test("abcdefghij", 10, 0, "abcdefghijklmnopqrst", 20, 1, 0);
+ test("abcdefghij", 10, 0, "abcdefghijklmnopqrst", 21, 0, 0);
+ test("abcdefghij", 10, 1, "", 0, 0, 0);
+ test("abcdefghij", 10, 1, "", 0, 1, 0);
+ test("abcdefghij", 10, 1, "", 1, 0, 0);
+ test("abcdefghij", 10, 1, "abcde", 0, 0, 0);
+ test("abcdefghij", 10, 1, "abcde", 0, 1, -1);
+ test("abcdefghij", 10, 1, "abcde", 0, 2, -2);
+ test("abcdefghij", 10, 1, "abcde", 0, 4, -4);
+ test("abcdefghij", 10, 1, "abcde", 0, 5, -5);
+ test("abcdefghij", 10, 1, "abcde", 0, 6, -5);
+ test("abcdefghij", 10, 1, "abcde", 1, 0, 0);
+ test("abcdefghij", 10, 1, "abcde", 1, 1, -1);
+ test("abcdefghij", 10, 1, "abcde", 1, 2, -2);
+ test("abcdefghij", 10, 1, "abcde", 1, 3, -3);
+ test("abcdefghij", 10, 1, "abcde", 1, 4, -4);
+ test("abcdefghij", 10, 1, "abcde", 1, 5, -4);
+ test("abcdefghij", 10, 1, "abcde", 2, 0, 0);
+ test("abcdefghij", 10, 1, "abcde", 2, 1, -1);
+ test("abcdefghij", 10, 1, "abcde", 2, 2, -2);
+ test("abcdefghij", 10, 1, "abcde", 2, 3, -3);
+ test("abcdefghij", 10, 1, "abcde", 2, 4, -3);
+ test("abcdefghij", 10, 1, "abcde", 4, 0, 0);
+ test("abcdefghij", 10, 1, "abcde", 4, 1, -1);
+ test("abcdefghij", 10, 1, "abcde", 4, 2, -1);
+ test("abcdefghij", 10, 1, "abcde", 5, 0, 0);
+ test("abcdefghij", 10, 1, "abcde", 5, 1, 0);
+ test("abcdefghij", 10, 1, "abcde", 6, 0, 0);
+ test("abcdefghij", 10, 1, "abcdefghij", 0, 0, 0);
+ test("abcdefghij", 10, 1, "abcdefghij", 0, 1, -1);
+ test("abcdefghij", 10, 1, "abcdefghij", 0, 5, -5);
+ test("abcdefghij", 10, 1, "abcdefghij", 0, 9, -9);
+ test("abcdefghij", 10, 1, "abcdefghij", 0, 10, -10);
+ test("abcdefghij", 10, 1, "abcdefghij", 0, 11, -10);
+ test("abcdefghij", 10, 1, "abcdefghij", 1, 0, 0);
+ test("abcdefghij", 10, 1, "abcdefghij", 1, 1, -1);
+ test("abcdefghij", 10, 1, "abcdefghij", 1, 4, -4);
+ test("abcdefghij", 10, 1, "abcdefghij", 1, 8, -8);
+ test("abcdefghij", 10, 1, "abcdefghij", 1, 9, -9);
+ test("abcdefghij", 10, 1, "abcdefghij", 1, 10, -9);
+ test("abcdefghij", 10, 1, "abcdefghij", 5, 0, 0);
+ test("abcdefghij", 10, 1, "abcdefghij", 5, 1, -1);
+ test("abcdefghij", 10, 1, "abcdefghij", 5, 2, -2);
+ test("abcdefghij", 10, 1, "abcdefghij", 5, 4, -4);
+ test("abcdefghij", 10, 1, "abcdefghij", 5, 5, -5);
+ test("abcdefghij", 10, 1, "abcdefghij", 5, 6, -5);
+ test("abcdefghij", 10, 1, "abcdefghij", 9, 0, 0);
+ test("abcdefghij", 10, 1, "abcdefghij", 9, 1, -1);
+ test("abcdefghij", 10, 1, "abcdefghij", 9, 2, -1);
+ test("abcdefghij", 10, 1, "abcdefghij", 10, 0, 0);
+}
+
+void test36()
+{
+ test("abcdefghij", 10, 1, "abcdefghij", 10, 1, 0);
+ test("abcdefghij", 10, 1, "abcdefghij", 11, 0, 0);
+ test("abcdefghij", 10, 1, "abcdefghijklmnopqrst", 0, 0, 0);
+ test("abcdefghij", 10, 1, "abcdefghijklmnopqrst", 0, 1, -1);
+ test("abcdefghij", 10, 1, "abcdefghijklmnopqrst", 0, 10, -10);
+ test("abcdefghij", 10, 1, "abcdefghijklmnopqrst", 0, 19, -19);
+ test("abcdefghij", 10, 1, "abcdefghijklmnopqrst", 0, 20, -20);
+ test("abcdefghij", 10, 1, "abcdefghijklmnopqrst", 0, 21, -20);
+ test("abcdefghij", 10, 1, "abcdefghijklmnopqrst", 1, 0, 0);
+ test("abcdefghij", 10, 1, "abcdefghijklmnopqrst", 1, 1, -1);
+ test("abcdefghij", 10, 1, "abcdefghijklmnopqrst", 1, 9, -9);
+ test("abcdefghij", 10, 1, "abcdefghijklmnopqrst", 1, 18, -18);
+ test("abcdefghij", 10, 1, "abcdefghijklmnopqrst", 1, 19, -19);
+ test("abcdefghij", 10, 1, "abcdefghijklmnopqrst", 1, 20, -19);
+ test("abcdefghij", 10, 1, "abcdefghijklmnopqrst", 10, 0, 0);
+ test("abcdefghij", 10, 1, "abcdefghijklmnopqrst", 10, 1, -1);
+ test("abcdefghij", 10, 1, "abcdefghijklmnopqrst", 10, 5, -5);
+ test("abcdefghij", 10, 1, "abcdefghijklmnopqrst", 10, 9, -9);
+ test("abcdefghij", 10, 1, "abcdefghijklmnopqrst", 10, 10, -10);
+ test("abcdefghij", 10, 1, "abcdefghijklmnopqrst", 10, 11, -10);
+ test("abcdefghij", 10, 1, "abcdefghijklmnopqrst", 19, 0, 0);
+ test("abcdefghij", 10, 1, "abcdefghijklmnopqrst", 19, 1, -1);
+ test("abcdefghij", 10, 1, "abcdefghijklmnopqrst", 19, 2, -1);
+ test("abcdefghij", 10, 1, "abcdefghijklmnopqrst", 20, 0, 0);
+ test("abcdefghij", 10, 1, "abcdefghijklmnopqrst", 20, 1, 0);
+ test("abcdefghij", 10, 1, "abcdefghijklmnopqrst", 21, 0, 0);
+ test("abcdefghij", 11, 0, "", 0, 0, 0);
+ test("abcdefghij", 11, 0, "", 0, 1, 0);
+ test("abcdefghij", 11, 0, "", 1, 0, 0);
+ test("abcdefghij", 11, 0, "abcde", 0, 0, 0);
+ test("abcdefghij", 11, 0, "abcde", 0, 1, 0);
+ test("abcdefghij", 11, 0, "abcde", 0, 2, 0);
+ test("abcdefghij", 11, 0, "abcde", 0, 4, 0);
+ test("abcdefghij", 11, 0, "abcde", 0, 5, 0);
+ test("abcdefghij", 11, 0, "abcde", 0, 6, 0);
+ test("abcdefghij", 11, 0, "abcde", 1, 0, 0);
+ test("abcdefghij", 11, 0, "abcde", 1, 1, 0);
+ test("abcdefghij", 11, 0, "abcde", 1, 2, 0);
+ test("abcdefghij", 11, 0, "abcde", 1, 3, 0);
+ test("abcdefghij", 11, 0, "abcde", 1, 4, 0);
+ test("abcdefghij", 11, 0, "abcde", 1, 5, 0);
+ test("abcdefghij", 11, 0, "abcde", 2, 0, 0);
+ test("abcdefghij", 11, 0, "abcde", 2, 1, 0);
+ test("abcdefghij", 11, 0, "abcde", 2, 2, 0);
+ test("abcdefghij", 11, 0, "abcde", 2, 3, 0);
+ test("abcdefghij", 11, 0, "abcde", 2, 4, 0);
+ test("abcdefghij", 11, 0, "abcde", 4, 0, 0);
+ test("abcdefghij", 11, 0, "abcde", 4, 1, 0);
+ test("abcdefghij", 11, 0, "abcde", 4, 2, 0);
+ test("abcdefghij", 11, 0, "abcde", 5, 0, 0);
+ test("abcdefghij", 11, 0, "abcde", 5, 1, 0);
+ test("abcdefghij", 11, 0, "abcde", 6, 0, 0);
+ test("abcdefghij", 11, 0, "abcdefghij", 0, 0, 0);
+ test("abcdefghij", 11, 0, "abcdefghij", 0, 1, 0);
+ test("abcdefghij", 11, 0, "abcdefghij", 0, 5, 0);
+ test("abcdefghij", 11, 0, "abcdefghij", 0, 9, 0);
+ test("abcdefghij", 11, 0, "abcdefghij", 0, 10, 0);
+ test("abcdefghij", 11, 0, "abcdefghij", 0, 11, 0);
+ test("abcdefghij", 11, 0, "abcdefghij", 1, 0, 0);
+ test("abcdefghij", 11, 0, "abcdefghij", 1, 1, 0);
+ test("abcdefghij", 11, 0, "abcdefghij", 1, 4, 0);
+ test("abcdefghij", 11, 0, "abcdefghij", 1, 8, 0);
+ test("abcdefghij", 11, 0, "abcdefghij", 1, 9, 0);
+ test("abcdefghij", 11, 0, "abcdefghij", 1, 10, 0);
+ test("abcdefghij", 11, 0, "abcdefghij", 5, 0, 0);
+ test("abcdefghij", 11, 0, "abcdefghij", 5, 1, 0);
+ test("abcdefghij", 11, 0, "abcdefghij", 5, 2, 0);
+ test("abcdefghij", 11, 0, "abcdefghij", 5, 4, 0);
+ test("abcdefghij", 11, 0, "abcdefghij", 5, 5, 0);
+ test("abcdefghij", 11, 0, "abcdefghij", 5, 6, 0);
+ test("abcdefghij", 11, 0, "abcdefghij", 9, 0, 0);
+ test("abcdefghij", 11, 0, "abcdefghij", 9, 1, 0);
+ test("abcdefghij", 11, 0, "abcdefghij", 9, 2, 0);
+ test("abcdefghij", 11, 0, "abcdefghij", 10, 0, 0);
+ test("abcdefghij", 11, 0, "abcdefghij", 10, 1, 0);
+ test("abcdefghij", 11, 0, "abcdefghij", 11, 0, 0);
+ test("abcdefghij", 11, 0, "abcdefghijklmnopqrst", 0, 0, 0);
+ test("abcdefghij", 11, 0, "abcdefghijklmnopqrst", 0, 1, 0);
+ test("abcdefghij", 11, 0, "abcdefghijklmnopqrst", 0, 10, 0);
+ test("abcdefghij", 11, 0, "abcdefghijklmnopqrst", 0, 19, 0);
+ test("abcdefghij", 11, 0, "abcdefghijklmnopqrst", 0, 20, 0);
+ test("abcdefghij", 11, 0, "abcdefghijklmnopqrst", 0, 21, 0);
+ test("abcdefghij", 11, 0, "abcdefghijklmnopqrst", 1, 0, 0);
+ test("abcdefghij", 11, 0, "abcdefghijklmnopqrst", 1, 1, 0);
+ test("abcdefghij", 11, 0, "abcdefghijklmnopqrst", 1, 9, 0);
+ test("abcdefghij", 11, 0, "abcdefghijklmnopqrst", 1, 18, 0);
+ test("abcdefghij", 11, 0, "abcdefghijklmnopqrst", 1, 19, 0);
+ test("abcdefghij", 11, 0, "abcdefghijklmnopqrst", 1, 20, 0);
+ test("abcdefghij", 11, 0, "abcdefghijklmnopqrst", 10, 0, 0);
+ test("abcdefghij", 11, 0, "abcdefghijklmnopqrst", 10, 1, 0);
+ test("abcdefghij", 11, 0, "abcdefghijklmnopqrst", 10, 5, 0);
+ test("abcdefghij", 11, 0, "abcdefghijklmnopqrst", 10, 9, 0);
+ test("abcdefghij", 11, 0, "abcdefghijklmnopqrst", 10, 10, 0);
+ test("abcdefghij", 11, 0, "abcdefghijklmnopqrst", 10, 11, 0);
+ test("abcdefghij", 11, 0, "abcdefghijklmnopqrst", 19, 0, 0);
+ test("abcdefghij", 11, 0, "abcdefghijklmnopqrst", 19, 1, 0);
+ test("abcdefghij", 11, 0, "abcdefghijklmnopqrst", 19, 2, 0);
+ test("abcdefghij", 11, 0, "abcdefghijklmnopqrst", 20, 0, 0);
+ test("abcdefghij", 11, 0, "abcdefghijklmnopqrst", 20, 1, 0);
+ test("abcdefghij", 11, 0, "abcdefghijklmnopqrst", 21, 0, 0);
+}
+
+void test37()
+{
+ test("abcdefghijklmnopqrst", 0, 0, "", 0, 0, 0);
+ test("abcdefghijklmnopqrst", 0, 0, "", 0, 1, 0);
+ test("abcdefghijklmnopqrst", 0, 0, "", 1, 0, 0);
+ test("abcdefghijklmnopqrst", 0, 0, "abcde", 0, 0, 0);
+ test("abcdefghijklmnopqrst", 0, 0, "abcde", 0, 1, -1);
+ test("abcdefghijklmnopqrst", 0, 0, "abcde", 0, 2, -2);
+ test("abcdefghijklmnopqrst", 0, 0, "abcde", 0, 4, -4);
+ test("abcdefghijklmnopqrst", 0, 0, "abcde", 0, 5, -5);
+ test("abcdefghijklmnopqrst", 0, 0, "abcde", 0, 6, -5);
+ test("abcdefghijklmnopqrst", 0, 0, "abcde", 1, 0, 0);
+ test("abcdefghijklmnopqrst", 0, 0, "abcde", 1, 1, -1);
+ test("abcdefghijklmnopqrst", 0, 0, "abcde", 1, 2, -2);
+ test("abcdefghijklmnopqrst", 0, 0, "abcde", 1, 3, -3);
+ test("abcdefghijklmnopqrst", 0, 0, "abcde", 1, 4, -4);
+ test("abcdefghijklmnopqrst", 0, 0, "abcde", 1, 5, -4);
+ test("abcdefghijklmnopqrst", 0, 0, "abcde", 2, 0, 0);
+ test("abcdefghijklmnopqrst", 0, 0, "abcde", 2, 1, -1);
+ test("abcdefghijklmnopqrst", 0, 0, "abcde", 2, 2, -2);
+ test("abcdefghijklmnopqrst", 0, 0, "abcde", 2, 3, -3);
+ test("abcdefghijklmnopqrst", 0, 0, "abcde", 2, 4, -3);
+ test("abcdefghijklmnopqrst", 0, 0, "abcde", 4, 0, 0);
+ test("abcdefghijklmnopqrst", 0, 0, "abcde", 4, 1, -1);
+ test("abcdefghijklmnopqrst", 0, 0, "abcde", 4, 2, -1);
+ test("abcdefghijklmnopqrst", 0, 0, "abcde", 5, 0, 0);
+ test("abcdefghijklmnopqrst", 0, 0, "abcde", 5, 1, 0);
+ test("abcdefghijklmnopqrst", 0, 0, "abcde", 6, 0, 0);
+ test("abcdefghijklmnopqrst", 0, 0, "abcdefghij", 0, 0, 0);
+ test("abcdefghijklmnopqrst", 0, 0, "abcdefghij", 0, 1, -1);
+ test("abcdefghijklmnopqrst", 0, 0, "abcdefghij", 0, 5, -5);
+ test("abcdefghijklmnopqrst", 0, 0, "abcdefghij", 0, 9, -9);
+ test("abcdefghijklmnopqrst", 0, 0, "abcdefghij", 0, 10, -10);
+ test("abcdefghijklmnopqrst", 0, 0, "abcdefghij", 0, 11, -10);
+ test("abcdefghijklmnopqrst", 0, 0, "abcdefghij", 1, 0, 0);
+ test("abcdefghijklmnopqrst", 0, 0, "abcdefghij", 1, 1, -1);
+ test("abcdefghijklmnopqrst", 0, 0, "abcdefghij", 1, 4, -4);
+ test("abcdefghijklmnopqrst", 0, 0, "abcdefghij", 1, 8, -8);
+ test("abcdefghijklmnopqrst", 0, 0, "abcdefghij", 1, 9, -9);
+ test("abcdefghijklmnopqrst", 0, 0, "abcdefghij", 1, 10, -9);
+ test("abcdefghijklmnopqrst", 0, 0, "abcdefghij", 5, 0, 0);
+ test("abcdefghijklmnopqrst", 0, 0, "abcdefghij", 5, 1, -1);
+ test("abcdefghijklmnopqrst", 0, 0, "abcdefghij", 5, 2, -2);
+ test("abcdefghijklmnopqrst", 0, 0, "abcdefghij", 5, 4, -4);
+ test("abcdefghijklmnopqrst", 0, 0, "abcdefghij", 5, 5, -5);
+ test("abcdefghijklmnopqrst", 0, 0, "abcdefghij", 5, 6, -5);
+ test("abcdefghijklmnopqrst", 0, 0, "abcdefghij", 9, 0, 0);
+ test("abcdefghijklmnopqrst", 0, 0, "abcdefghij", 9, 1, -1);
+ test("abcdefghijklmnopqrst", 0, 0, "abcdefghij", 9, 2, -1);
+ test("abcdefghijklmnopqrst", 0, 0, "abcdefghij", 10, 0, 0);
+ test("abcdefghijklmnopqrst", 0, 0, "abcdefghij", 10, 1, 0);
+ test("abcdefghijklmnopqrst", 0, 0, "abcdefghij", 11, 0, 0);
+ test("abcdefghijklmnopqrst", 0, 0, "abcdefghijklmnopqrst", 0, 0, 0);
+ test("abcdefghijklmnopqrst", 0, 0, "abcdefghijklmnopqrst", 0, 1, -1);
+ test("abcdefghijklmnopqrst", 0, 0, "abcdefghijklmnopqrst", 0, 10, -10);
+ test("abcdefghijklmnopqrst", 0, 0, "abcdefghijklmnopqrst", 0, 19, -19);
+ test("abcdefghijklmnopqrst", 0, 0, "abcdefghijklmnopqrst", 0, 20, -20);
+ test("abcdefghijklmnopqrst", 0, 0, "abcdefghijklmnopqrst", 0, 21, -20);
+ test("abcdefghijklmnopqrst", 0, 0, "abcdefghijklmnopqrst", 1, 0, 0);
+ test("abcdefghijklmnopqrst", 0, 0, "abcdefghijklmnopqrst", 1, 1, -1);
+ test("abcdefghijklmnopqrst", 0, 0, "abcdefghijklmnopqrst", 1, 9, -9);
+ test("abcdefghijklmnopqrst", 0, 0, "abcdefghijklmnopqrst", 1, 18, -18);
+ test("abcdefghijklmnopqrst", 0, 0, "abcdefghijklmnopqrst", 1, 19, -19);
+ test("abcdefghijklmnopqrst", 0, 0, "abcdefghijklmnopqrst", 1, 20, -19);
+ test("abcdefghijklmnopqrst", 0, 0, "abcdefghijklmnopqrst", 10, 0, 0);
+ test("abcdefghijklmnopqrst", 0, 0, "abcdefghijklmnopqrst", 10, 1, -1);
+ test("abcdefghijklmnopqrst", 0, 0, "abcdefghijklmnopqrst", 10, 5, -5);
+ test("abcdefghijklmnopqrst", 0, 0, "abcdefghijklmnopqrst", 10, 9, -9);
+ test("abcdefghijklmnopqrst", 0, 0, "abcdefghijklmnopqrst", 10, 10, -10);
+ test("abcdefghijklmnopqrst", 0, 0, "abcdefghijklmnopqrst", 10, 11, -10);
+ test("abcdefghijklmnopqrst", 0, 0, "abcdefghijklmnopqrst", 19, 0, 0);
+ test("abcdefghijklmnopqrst", 0, 0, "abcdefghijklmnopqrst", 19, 1, -1);
+ test("abcdefghijklmnopqrst", 0, 0, "abcdefghijklmnopqrst", 19, 2, -1);
+ test("abcdefghijklmnopqrst", 0, 0, "abcdefghijklmnopqrst", 20, 0, 0);
+ test("abcdefghijklmnopqrst", 0, 0, "abcdefghijklmnopqrst", 20, 1, 0);
+ test("abcdefghijklmnopqrst", 0, 0, "abcdefghijklmnopqrst", 21, 0, 0);
+ test("abcdefghijklmnopqrst", 0, 1, "", 0, 0, 1);
+ test("abcdefghijklmnopqrst", 0, 1, "", 0, 1, 1);
+ test("abcdefghijklmnopqrst", 0, 1, "", 1, 0, 0);
+ test("abcdefghijklmnopqrst", 0, 1, "abcde", 0, 0, 1);
+ test("abcdefghijklmnopqrst", 0, 1, "abcde", 0, 1, 0);
+ test("abcdefghijklmnopqrst", 0, 1, "abcde", 0, 2, -1);
+ test("abcdefghijklmnopqrst", 0, 1, "abcde", 0, 4, -3);
+ test("abcdefghijklmnopqrst", 0, 1, "abcde", 0, 5, -4);
+ test("abcdefghijklmnopqrst", 0, 1, "abcde", 0, 6, -4);
+ test("abcdefghijklmnopqrst", 0, 1, "abcde", 1, 0, 1);
+ test("abcdefghijklmnopqrst", 0, 1, "abcde", 1, 1, -1);
+ test("abcdefghijklmnopqrst", 0, 1, "abcde", 1, 2, -1);
+ test("abcdefghijklmnopqrst", 0, 1, "abcde", 1, 3, -1);
+ test("abcdefghijklmnopqrst", 0, 1, "abcde", 1, 4, -1);
+ test("abcdefghijklmnopqrst", 0, 1, "abcde", 1, 5, -1);
+ test("abcdefghijklmnopqrst", 0, 1, "abcde", 2, 0, 1);
+ test("abcdefghijklmnopqrst", 0, 1, "abcde", 2, 1, -2);
+ test("abcdefghijklmnopqrst", 0, 1, "abcde", 2, 2, -2);
+ test("abcdefghijklmnopqrst", 0, 1, "abcde", 2, 3, -2);
+ test("abcdefghijklmnopqrst", 0, 1, "abcde", 2, 4, -2);
+ test("abcdefghijklmnopqrst", 0, 1, "abcde", 4, 0, 1);
+ test("abcdefghijklmnopqrst", 0, 1, "abcde", 4, 1, -4);
+ test("abcdefghijklmnopqrst", 0, 1, "abcde", 4, 2, -4);
+ test("abcdefghijklmnopqrst", 0, 1, "abcde", 5, 0, 1);
+ test("abcdefghijklmnopqrst", 0, 1, "abcde", 5, 1, 1);
+ test("abcdefghijklmnopqrst", 0, 1, "abcde", 6, 0, 0);
+}
+
+void test38()
+{
+ test("abcdefghijklmnopqrst", 0, 1, "abcdefghij", 0, 0, 1);
+ test("abcdefghijklmnopqrst", 0, 1, "abcdefghij", 0, 1, 0);
+ test("abcdefghijklmnopqrst", 0, 1, "abcdefghij", 0, 5, -4);
+ test("abcdefghijklmnopqrst", 0, 1, "abcdefghij", 0, 9, -8);
+ test("abcdefghijklmnopqrst", 0, 1, "abcdefghij", 0, 10, -9);
+ test("abcdefghijklmnopqrst", 0, 1, "abcdefghij", 0, 11, -9);
+ test("abcdefghijklmnopqrst", 0, 1, "abcdefghij", 1, 0, 1);
+ test("abcdefghijklmnopqrst", 0, 1, "abcdefghij", 1, 1, -1);
+ test("abcdefghijklmnopqrst", 0, 1, "abcdefghij", 1, 4, -1);
+ test("abcdefghijklmnopqrst", 0, 1, "abcdefghij", 1, 8, -1);
+ test("abcdefghijklmnopqrst", 0, 1, "abcdefghij", 1, 9, -1);
+ test("abcdefghijklmnopqrst", 0, 1, "abcdefghij", 1, 10, -1);
+ test("abcdefghijklmnopqrst", 0, 1, "abcdefghij", 5, 0, 1);
+ test("abcdefghijklmnopqrst", 0, 1, "abcdefghij", 5, 1, -5);
+ test("abcdefghijklmnopqrst", 0, 1, "abcdefghij", 5, 2, -5);
+ test("abcdefghijklmnopqrst", 0, 1, "abcdefghij", 5, 4, -5);
+ test("abcdefghijklmnopqrst", 0, 1, "abcdefghij", 5, 5, -5);
+ test("abcdefghijklmnopqrst", 0, 1, "abcdefghij", 5, 6, -5);
+ test("abcdefghijklmnopqrst", 0, 1, "abcdefghij", 9, 0, 1);
+ test("abcdefghijklmnopqrst", 0, 1, "abcdefghij", 9, 1, -9);
+ test("abcdefghijklmnopqrst", 0, 1, "abcdefghij", 9, 2, -9);
+ test("abcdefghijklmnopqrst", 0, 1, "abcdefghij", 10, 0, 1);
+ test("abcdefghijklmnopqrst", 0, 1, "abcdefghij", 10, 1, 1);
+ test("abcdefghijklmnopqrst", 0, 1, "abcdefghij", 11, 0, 0);
+ test("abcdefghijklmnopqrst", 0, 1, "abcdefghijklmnopqrst", 0, 0, 1);
+ test("abcdefghijklmnopqrst", 0, 1, "abcdefghijklmnopqrst", 0, 1, 0);
+ test("abcdefghijklmnopqrst", 0, 1, "abcdefghijklmnopqrst", 0, 10, -9);
+ test("abcdefghijklmnopqrst", 0, 1, "abcdefghijklmnopqrst", 0, 19, -18);
+ test("abcdefghijklmnopqrst", 0, 1, "abcdefghijklmnopqrst", 0, 20, -19);
+ test("abcdefghijklmnopqrst", 0, 1, "abcdefghijklmnopqrst", 0, 21, -19);
+ test("abcdefghijklmnopqrst", 0, 1, "abcdefghijklmnopqrst", 1, 0, 1);
+ test("abcdefghijklmnopqrst", 0, 1, "abcdefghijklmnopqrst", 1, 1, -1);
+ test("abcdefghijklmnopqrst", 0, 1, "abcdefghijklmnopqrst", 1, 9, -1);
+ test("abcdefghijklmnopqrst", 0, 1, "abcdefghijklmnopqrst", 1, 18, -1);
+ test("abcdefghijklmnopqrst", 0, 1, "abcdefghijklmnopqrst", 1, 19, -1);
+ test("abcdefghijklmnopqrst", 0, 1, "abcdefghijklmnopqrst", 1, 20, -1);
+ test("abcdefghijklmnopqrst", 0, 1, "abcdefghijklmnopqrst", 10, 0, 1);
+ test("abcdefghijklmnopqrst", 0, 1, "abcdefghijklmnopqrst", 10, 1, -10);
+ test("abcdefghijklmnopqrst", 0, 1, "abcdefghijklmnopqrst", 10, 5, -10);
+ test("abcdefghijklmnopqrst", 0, 1, "abcdefghijklmnopqrst", 10, 9, -10);
+ test("abcdefghijklmnopqrst", 0, 1, "abcdefghijklmnopqrst", 10, 10, -10);
+ test("abcdefghijklmnopqrst", 0, 1, "abcdefghijklmnopqrst", 10, 11, -10);
+ test("abcdefghijklmnopqrst", 0, 1, "abcdefghijklmnopqrst", 19, 0, 1);
+ test("abcdefghijklmnopqrst", 0, 1, "abcdefghijklmnopqrst", 19, 1, -19);
+ test("abcdefghijklmnopqrst", 0, 1, "abcdefghijklmnopqrst", 19, 2, -19);
+ test("abcdefghijklmnopqrst", 0, 1, "abcdefghijklmnopqrst", 20, 0, 1);
+ test("abcdefghijklmnopqrst", 0, 1, "abcdefghijklmnopqrst", 20, 1, 1);
+ test("abcdefghijklmnopqrst", 0, 1, "abcdefghijklmnopqrst", 21, 0, 0);
+ test("abcdefghijklmnopqrst", 0, 10, "", 0, 0, 10);
+ test("abcdefghijklmnopqrst", 0, 10, "", 0, 1, 10);
+ test("abcdefghijklmnopqrst", 0, 10, "", 1, 0, 0);
+ test("abcdefghijklmnopqrst", 0, 10, "abcde", 0, 0, 10);
+ test("abcdefghijklmnopqrst", 0, 10, "abcde", 0, 1, 9);
+ test("abcdefghijklmnopqrst", 0, 10, "abcde", 0, 2, 8);
+ test("abcdefghijklmnopqrst", 0, 10, "abcde", 0, 4, 6);
+ test("abcdefghijklmnopqrst", 0, 10, "abcde", 0, 5, 5);
+ test("abcdefghijklmnopqrst", 0, 10, "abcde", 0, 6, 5);
+ test("abcdefghijklmnopqrst", 0, 10, "abcde", 1, 0, 10);
+ test("abcdefghijklmnopqrst", 0, 10, "abcde", 1, 1, -1);
+ test("abcdefghijklmnopqrst", 0, 10, "abcde", 1, 2, -1);
+ test("abcdefghijklmnopqrst", 0, 10, "abcde", 1, 3, -1);
+ test("abcdefghijklmnopqrst", 0, 10, "abcde", 1, 4, -1);
+ test("abcdefghijklmnopqrst", 0, 10, "abcde", 1, 5, -1);
+ test("abcdefghijklmnopqrst", 0, 10, "abcde", 2, 0, 10);
+ test("abcdefghijklmnopqrst", 0, 10, "abcde", 2, 1, -2);
+ test("abcdefghijklmnopqrst", 0, 10, "abcde", 2, 2, -2);
+ test("abcdefghijklmnopqrst", 0, 10, "abcde", 2, 3, -2);
+ test("abcdefghijklmnopqrst", 0, 10, "abcde", 2, 4, -2);
+ test("abcdefghijklmnopqrst", 0, 10, "abcde", 4, 0, 10);
+ test("abcdefghijklmnopqrst", 0, 10, "abcde", 4, 1, -4);
+ test("abcdefghijklmnopqrst", 0, 10, "abcde", 4, 2, -4);
+ test("abcdefghijklmnopqrst", 0, 10, "abcde", 5, 0, 10);
+ test("abcdefghijklmnopqrst", 0, 10, "abcde", 5, 1, 10);
+ test("abcdefghijklmnopqrst", 0, 10, "abcde", 6, 0, 0);
+ test("abcdefghijklmnopqrst", 0, 10, "abcdefghij", 0, 0, 10);
+ test("abcdefghijklmnopqrst", 0, 10, "abcdefghij", 0, 1, 9);
+ test("abcdefghijklmnopqrst", 0, 10, "abcdefghij", 0, 5, 5);
+ test("abcdefghijklmnopqrst", 0, 10, "abcdefghij", 0, 9, 1);
+ test("abcdefghijklmnopqrst", 0, 10, "abcdefghij", 0, 10, 0);
+ test("abcdefghijklmnopqrst", 0, 10, "abcdefghij", 0, 11, 0);
+ test("abcdefghijklmnopqrst", 0, 10, "abcdefghij", 1, 0, 10);
+ test("abcdefghijklmnopqrst", 0, 10, "abcdefghij", 1, 1, -1);
+ test("abcdefghijklmnopqrst", 0, 10, "abcdefghij", 1, 4, -1);
+ test("abcdefghijklmnopqrst", 0, 10, "abcdefghij", 1, 8, -1);
+ test("abcdefghijklmnopqrst", 0, 10, "abcdefghij", 1, 9, -1);
+ test("abcdefghijklmnopqrst", 0, 10, "abcdefghij", 1, 10, -1);
+ test("abcdefghijklmnopqrst", 0, 10, "abcdefghij", 5, 0, 10);
+ test("abcdefghijklmnopqrst", 0, 10, "abcdefghij", 5, 1, -5);
+ test("abcdefghijklmnopqrst", 0, 10, "abcdefghij", 5, 2, -5);
+ test("abcdefghijklmnopqrst", 0, 10, "abcdefghij", 5, 4, -5);
+ test("abcdefghijklmnopqrst", 0, 10, "abcdefghij", 5, 5, -5);
+ test("abcdefghijklmnopqrst", 0, 10, "abcdefghij", 5, 6, -5);
+ test("abcdefghijklmnopqrst", 0, 10, "abcdefghij", 9, 0, 10);
+ test("abcdefghijklmnopqrst", 0, 10, "abcdefghij", 9, 1, -9);
+ test("abcdefghijklmnopqrst", 0, 10, "abcdefghij", 9, 2, -9);
+ test("abcdefghijklmnopqrst", 0, 10, "abcdefghij", 10, 0, 10);
+ test("abcdefghijklmnopqrst", 0, 10, "abcdefghij", 10, 1, 10);
+ test("abcdefghijklmnopqrst", 0, 10, "abcdefghij", 11, 0, 0);
+ test("abcdefghijklmnopqrst", 0, 10, "abcdefghijklmnopqrst", 0, 0, 10);
+ test("abcdefghijklmnopqrst", 0, 10, "abcdefghijklmnopqrst", 0, 1, 9);
+}
+
+void test39()
+{
+ test("abcdefghijklmnopqrst", 0, 10, "abcdefghijklmnopqrst", 0, 10, 0);
+ test("abcdefghijklmnopqrst", 0, 10, "abcdefghijklmnopqrst", 0, 19, -9);
+ test("abcdefghijklmnopqrst", 0, 10, "abcdefghijklmnopqrst", 0, 20, -10);
+ test("abcdefghijklmnopqrst", 0, 10, "abcdefghijklmnopqrst", 0, 21, -10);
+ test("abcdefghijklmnopqrst", 0, 10, "abcdefghijklmnopqrst", 1, 0, 10);
+ test("abcdefghijklmnopqrst", 0, 10, "abcdefghijklmnopqrst", 1, 1, -1);
+ test("abcdefghijklmnopqrst", 0, 10, "abcdefghijklmnopqrst", 1, 9, -1);
+ test("abcdefghijklmnopqrst", 0, 10, "abcdefghijklmnopqrst", 1, 18, -1);
+ test("abcdefghijklmnopqrst", 0, 10, "abcdefghijklmnopqrst", 1, 19, -1);
+ test("abcdefghijklmnopqrst", 0, 10, "abcdefghijklmnopqrst", 1, 20, -1);
+ test("abcdefghijklmnopqrst", 0, 10, "abcdefghijklmnopqrst", 10, 0, 10);
+ test("abcdefghijklmnopqrst", 0, 10, "abcdefghijklmnopqrst", 10, 1, -10);
+ test("abcdefghijklmnopqrst", 0, 10, "abcdefghijklmnopqrst", 10, 5, -10);
+ test("abcdefghijklmnopqrst", 0, 10, "abcdefghijklmnopqrst", 10, 9, -10);
+ test("abcdefghijklmnopqrst", 0, 10, "abcdefghijklmnopqrst", 10, 10, -10);
+ test("abcdefghijklmnopqrst", 0, 10, "abcdefghijklmnopqrst", 10, 11, -10);
+ test("abcdefghijklmnopqrst", 0, 10, "abcdefghijklmnopqrst", 19, 0, 10);
+ test("abcdefghijklmnopqrst", 0, 10, "abcdefghijklmnopqrst", 19, 1, -19);
+ test("abcdefghijklmnopqrst", 0, 10, "abcdefghijklmnopqrst", 19, 2, -19);
+ test("abcdefghijklmnopqrst", 0, 10, "abcdefghijklmnopqrst", 20, 0, 10);
+ test("abcdefghijklmnopqrst", 0, 10, "abcdefghijklmnopqrst", 20, 1, 10);
+ test("abcdefghijklmnopqrst", 0, 10, "abcdefghijklmnopqrst", 21, 0, 0);
+ test("abcdefghijklmnopqrst", 0, 19, "", 0, 0, 19);
+ test("abcdefghijklmnopqrst", 0, 19, "", 0, 1, 19);
+ test("abcdefghijklmnopqrst", 0, 19, "", 1, 0, 0);
+ test("abcdefghijklmnopqrst", 0, 19, "abcde", 0, 0, 19);
+ test("abcdefghijklmnopqrst", 0, 19, "abcde", 0, 1, 18);
+ test("abcdefghijklmnopqrst", 0, 19, "abcde", 0, 2, 17);
+ test("abcdefghijklmnopqrst", 0, 19, "abcde", 0, 4, 15);
+ test("abcdefghijklmnopqrst", 0, 19, "abcde", 0, 5, 14);
+ test("abcdefghijklmnopqrst", 0, 19, "abcde", 0, 6, 14);
+ test("abcdefghijklmnopqrst", 0, 19, "abcde", 1, 0, 19);
+ test("abcdefghijklmnopqrst", 0, 19, "abcde", 1, 1, -1);
+ test("abcdefghijklmnopqrst", 0, 19, "abcde", 1, 2, -1);
+ test("abcdefghijklmnopqrst", 0, 19, "abcde", 1, 3, -1);
+ test("abcdefghijklmnopqrst", 0, 19, "abcde", 1, 4, -1);
+ test("abcdefghijklmnopqrst", 0, 19, "abcde", 1, 5, -1);
+ test("abcdefghijklmnopqrst", 0, 19, "abcde", 2, 0, 19);
+ test("abcdefghijklmnopqrst", 0, 19, "abcde", 2, 1, -2);
+ test("abcdefghijklmnopqrst", 0, 19, "abcde", 2, 2, -2);
+ test("abcdefghijklmnopqrst", 0, 19, "abcde", 2, 3, -2);
+ test("abcdefghijklmnopqrst", 0, 19, "abcde", 2, 4, -2);
+ test("abcdefghijklmnopqrst", 0, 19, "abcde", 4, 0, 19);
+ test("abcdefghijklmnopqrst", 0, 19, "abcde", 4, 1, -4);
+ test("abcdefghijklmnopqrst", 0, 19, "abcde", 4, 2, -4);
+ test("abcdefghijklmnopqrst", 0, 19, "abcde", 5, 0, 19);
+ test("abcdefghijklmnopqrst", 0, 19, "abcde", 5, 1, 19);
+ test("abcdefghijklmnopqrst", 0, 19, "abcde", 6, 0, 0);
+ test("abcdefghijklmnopqrst", 0, 19, "abcdefghij", 0, 0, 19);
+ test("abcdefghijklmnopqrst", 0, 19, "abcdefghij", 0, 1, 18);
+ test("abcdefghijklmnopqrst", 0, 19, "abcdefghij", 0, 5, 14);
+ test("abcdefghijklmnopqrst", 0, 19, "abcdefghij", 0, 9, 10);
+ test("abcdefghijklmnopqrst", 0, 19, "abcdefghij", 0, 10, 9);
+ test("abcdefghijklmnopqrst", 0, 19, "abcdefghij", 0, 11, 9);
+ test("abcdefghijklmnopqrst", 0, 19, "abcdefghij", 1, 0, 19);
+ test("abcdefghijklmnopqrst", 0, 19, "abcdefghij", 1, 1, -1);
+ test("abcdefghijklmnopqrst", 0, 19, "abcdefghij", 1, 4, -1);
+ test("abcdefghijklmnopqrst", 0, 19, "abcdefghij", 1, 8, -1);
+ test("abcdefghijklmnopqrst", 0, 19, "abcdefghij", 1, 9, -1);
+ test("abcdefghijklmnopqrst", 0, 19, "abcdefghij", 1, 10, -1);
+ test("abcdefghijklmnopqrst", 0, 19, "abcdefghij", 5, 0, 19);
+ test("abcdefghijklmnopqrst", 0, 19, "abcdefghij", 5, 1, -5);
+ test("abcdefghijklmnopqrst", 0, 19, "abcdefghij", 5, 2, -5);
+ test("abcdefghijklmnopqrst", 0, 19, "abcdefghij", 5, 4, -5);
+ test("abcdefghijklmnopqrst", 0, 19, "abcdefghij", 5, 5, -5);
+ test("abcdefghijklmnopqrst", 0, 19, "abcdefghij", 5, 6, -5);
+ test("abcdefghijklmnopqrst", 0, 19, "abcdefghij", 9, 0, 19);
+ test("abcdefghijklmnopqrst", 0, 19, "abcdefghij", 9, 1, -9);
+ test("abcdefghijklmnopqrst", 0, 19, "abcdefghij", 9, 2, -9);
+ test("abcdefghijklmnopqrst", 0, 19, "abcdefghij", 10, 0, 19);
+ test("abcdefghijklmnopqrst", 0, 19, "abcdefghij", 10, 1, 19);
+ test("abcdefghijklmnopqrst", 0, 19, "abcdefghij", 11, 0, 0);
+ test("abcdefghijklmnopqrst", 0, 19, "abcdefghijklmnopqrst", 0, 0, 19);
+ test("abcdefghijklmnopqrst", 0, 19, "abcdefghijklmnopqrst", 0, 1, 18);
+ test("abcdefghijklmnopqrst", 0, 19, "abcdefghijklmnopqrst", 0, 10, 9);
+ test("abcdefghijklmnopqrst", 0, 19, "abcdefghijklmnopqrst", 0, 19, 0);
+ test("abcdefghijklmnopqrst", 0, 19, "abcdefghijklmnopqrst", 0, 20, -1);
+ test("abcdefghijklmnopqrst", 0, 19, "abcdefghijklmnopqrst", 0, 21, -1);
+ test("abcdefghijklmnopqrst", 0, 19, "abcdefghijklmnopqrst", 1, 0, 19);
+ test("abcdefghijklmnopqrst", 0, 19, "abcdefghijklmnopqrst", 1, 1, -1);
+ test("abcdefghijklmnopqrst", 0, 19, "abcdefghijklmnopqrst", 1, 9, -1);
+ test("abcdefghijklmnopqrst", 0, 19, "abcdefghijklmnopqrst", 1, 18, -1);
+ test("abcdefghijklmnopqrst", 0, 19, "abcdefghijklmnopqrst", 1, 19, -1);
+ test("abcdefghijklmnopqrst", 0, 19, "abcdefghijklmnopqrst", 1, 20, -1);
+ test("abcdefghijklmnopqrst", 0, 19, "abcdefghijklmnopqrst", 10, 0, 19);
+ test("abcdefghijklmnopqrst", 0, 19, "abcdefghijklmnopqrst", 10, 1, -10);
+ test("abcdefghijklmnopqrst", 0, 19, "abcdefghijklmnopqrst", 10, 5, -10);
+ test("abcdefghijklmnopqrst", 0, 19, "abcdefghijklmnopqrst", 10, 9, -10);
+ test("abcdefghijklmnopqrst", 0, 19, "abcdefghijklmnopqrst", 10, 10, -10);
+ test("abcdefghijklmnopqrst", 0, 19, "abcdefghijklmnopqrst", 10, 11, -10);
+ test("abcdefghijklmnopqrst", 0, 19, "abcdefghijklmnopqrst", 19, 0, 19);
+ test("abcdefghijklmnopqrst", 0, 19, "abcdefghijklmnopqrst", 19, 1, -19);
+ test("abcdefghijklmnopqrst", 0, 19, "abcdefghijklmnopqrst", 19, 2, -19);
+ test("abcdefghijklmnopqrst", 0, 19, "abcdefghijklmnopqrst", 20, 0, 19);
+ test("abcdefghijklmnopqrst", 0, 19, "abcdefghijklmnopqrst", 20, 1, 19);
+ test("abcdefghijklmnopqrst", 0, 19, "abcdefghijklmnopqrst", 21, 0, 0);
+ test("abcdefghijklmnopqrst", 0, 20, "", 0, 0, 20);
+ test("abcdefghijklmnopqrst", 0, 20, "", 0, 1, 20);
+ test("abcdefghijklmnopqrst", 0, 20, "", 1, 0, 0);
+ test("abcdefghijklmnopqrst", 0, 20, "abcde", 0, 0, 20);
+}
+
+void test40()
+{
+ test("abcdefghijklmnopqrst", 0, 20, "abcde", 0, 1, 19);
+ test("abcdefghijklmnopqrst", 0, 20, "abcde", 0, 2, 18);
+ test("abcdefghijklmnopqrst", 0, 20, "abcde", 0, 4, 16);
+ test("abcdefghijklmnopqrst", 0, 20, "abcde", 0, 5, 15);
+ test("abcdefghijklmnopqrst", 0, 20, "abcde", 0, 6, 15);
+ test("abcdefghijklmnopqrst", 0, 20, "abcde", 1, 0, 20);
+ test("abcdefghijklmnopqrst", 0, 20, "abcde", 1, 1, -1);
+ test("abcdefghijklmnopqrst", 0, 20, "abcde", 1, 2, -1);
+ test("abcdefghijklmnopqrst", 0, 20, "abcde", 1, 3, -1);
+ test("abcdefghijklmnopqrst", 0, 20, "abcde", 1, 4, -1);
+ test("abcdefghijklmnopqrst", 0, 20, "abcde", 1, 5, -1);
+ test("abcdefghijklmnopqrst", 0, 20, "abcde", 2, 0, 20);
+ test("abcdefghijklmnopqrst", 0, 20, "abcde", 2, 1, -2);
+ test("abcdefghijklmnopqrst", 0, 20, "abcde", 2, 2, -2);
+ test("abcdefghijklmnopqrst", 0, 20, "abcde", 2, 3, -2);
+ test("abcdefghijklmnopqrst", 0, 20, "abcde", 2, 4, -2);
+ test("abcdefghijklmnopqrst", 0, 20, "abcde", 4, 0, 20);
+ test("abcdefghijklmnopqrst", 0, 20, "abcde", 4, 1, -4);
+ test("abcdefghijklmnopqrst", 0, 20, "abcde", 4, 2, -4);
+ test("abcdefghijklmnopqrst", 0, 20, "abcde", 5, 0, 20);
+ test("abcdefghijklmnopqrst", 0, 20, "abcde", 5, 1, 20);
+ test("abcdefghijklmnopqrst", 0, 20, "abcde", 6, 0, 0);
+ test("abcdefghijklmnopqrst", 0, 20, "abcdefghij", 0, 0, 20);
+ test("abcdefghijklmnopqrst", 0, 20, "abcdefghij", 0, 1, 19);
+ test("abcdefghijklmnopqrst", 0, 20, "abcdefghij", 0, 5, 15);
+ test("abcdefghijklmnopqrst", 0, 20, "abcdefghij", 0, 9, 11);
+ test("abcdefghijklmnopqrst", 0, 20, "abcdefghij", 0, 10, 10);
+ test("abcdefghijklmnopqrst", 0, 20, "abcdefghij", 0, 11, 10);
+ test("abcdefghijklmnopqrst", 0, 20, "abcdefghij", 1, 0, 20);
+ test("abcdefghijklmnopqrst", 0, 20, "abcdefghij", 1, 1, -1);
+ test("abcdefghijklmnopqrst", 0, 20, "abcdefghij", 1, 4, -1);
+ test("abcdefghijklmnopqrst", 0, 20, "abcdefghij", 1, 8, -1);
+ test("abcdefghijklmnopqrst", 0, 20, "abcdefghij", 1, 9, -1);
+ test("abcdefghijklmnopqrst", 0, 20, "abcdefghij", 1, 10, -1);
+ test("abcdefghijklmnopqrst", 0, 20, "abcdefghij", 5, 0, 20);
+ test("abcdefghijklmnopqrst", 0, 20, "abcdefghij", 5, 1, -5);
+ test("abcdefghijklmnopqrst", 0, 20, "abcdefghij", 5, 2, -5);
+ test("abcdefghijklmnopqrst", 0, 20, "abcdefghij", 5, 4, -5);
+ test("abcdefghijklmnopqrst", 0, 20, "abcdefghij", 5, 5, -5);
+ test("abcdefghijklmnopqrst", 0, 20, "abcdefghij", 5, 6, -5);
+ test("abcdefghijklmnopqrst", 0, 20, "abcdefghij", 9, 0, 20);
+ test("abcdefghijklmnopqrst", 0, 20, "abcdefghij", 9, 1, -9);
+ test("abcdefghijklmnopqrst", 0, 20, "abcdefghij", 9, 2, -9);
+ test("abcdefghijklmnopqrst", 0, 20, "abcdefghij", 10, 0, 20);
+ test("abcdefghijklmnopqrst", 0, 20, "abcdefghij", 10, 1, 20);
+ test("abcdefghijklmnopqrst", 0, 20, "abcdefghij", 11, 0, 0);
+ test("abcdefghijklmnopqrst", 0, 20, "abcdefghijklmnopqrst", 0, 0, 20);
+ test("abcdefghijklmnopqrst", 0, 20, "abcdefghijklmnopqrst", 0, 1, 19);
+ test("abcdefghijklmnopqrst", 0, 20, "abcdefghijklmnopqrst", 0, 10, 10);
+ test("abcdefghijklmnopqrst", 0, 20, "abcdefghijklmnopqrst", 0, 19, 1);
+ test("abcdefghijklmnopqrst", 0, 20, "abcdefghijklmnopqrst", 0, 20, 0);
+ test("abcdefghijklmnopqrst", 0, 20, "abcdefghijklmnopqrst", 0, 21, 0);
+ test("abcdefghijklmnopqrst", 0, 20, "abcdefghijklmnopqrst", 1, 0, 20);
+ test("abcdefghijklmnopqrst", 0, 20, "abcdefghijklmnopqrst", 1, 1, -1);
+ test("abcdefghijklmnopqrst", 0, 20, "abcdefghijklmnopqrst", 1, 9, -1);
+ test("abcdefghijklmnopqrst", 0, 20, "abcdefghijklmnopqrst", 1, 18, -1);
+ test("abcdefghijklmnopqrst", 0, 20, "abcdefghijklmnopqrst", 1, 19, -1);
+ test("abcdefghijklmnopqrst", 0, 20, "abcdefghijklmnopqrst", 1, 20, -1);
+ test("abcdefghijklmnopqrst", 0, 20, "abcdefghijklmnopqrst", 10, 0, 20);
+ test("abcdefghijklmnopqrst", 0, 20, "abcdefghijklmnopqrst", 10, 1, -10);
+ test("abcdefghijklmnopqrst", 0, 20, "abcdefghijklmnopqrst", 10, 5, -10);
+ test("abcdefghijklmnopqrst", 0, 20, "abcdefghijklmnopqrst", 10, 9, -10);
+ test("abcdefghijklmnopqrst", 0, 20, "abcdefghijklmnopqrst", 10, 10, -10);
+ test("abcdefghijklmnopqrst", 0, 20, "abcdefghijklmnopqrst", 10, 11, -10);
+ test("abcdefghijklmnopqrst", 0, 20, "abcdefghijklmnopqrst", 19, 0, 20);
+ test("abcdefghijklmnopqrst", 0, 20, "abcdefghijklmnopqrst", 19, 1, -19);
+ test("abcdefghijklmnopqrst", 0, 20, "abcdefghijklmnopqrst", 19, 2, -19);
+ test("abcdefghijklmnopqrst", 0, 20, "abcdefghijklmnopqrst", 20, 0, 20);
+ test("abcdefghijklmnopqrst", 0, 20, "abcdefghijklmnopqrst", 20, 1, 20);
+ test("abcdefghijklmnopqrst", 0, 20, "abcdefghijklmnopqrst", 21, 0, 0);
+ test("abcdefghijklmnopqrst", 0, 21, "", 0, 0, 20);
+ test("abcdefghijklmnopqrst", 0, 21, "", 0, 1, 20);
+ test("abcdefghijklmnopqrst", 0, 21, "", 1, 0, 0);
+ test("abcdefghijklmnopqrst", 0, 21, "abcde", 0, 0, 20);
+ test("abcdefghijklmnopqrst", 0, 21, "abcde", 0, 1, 19);
+ test("abcdefghijklmnopqrst", 0, 21, "abcde", 0, 2, 18);
+ test("abcdefghijklmnopqrst", 0, 21, "abcde", 0, 4, 16);
+ test("abcdefghijklmnopqrst", 0, 21, "abcde", 0, 5, 15);
+ test("abcdefghijklmnopqrst", 0, 21, "abcde", 0, 6, 15);
+ test("abcdefghijklmnopqrst", 0, 21, "abcde", 1, 0, 20);
+ test("abcdefghijklmnopqrst", 0, 21, "abcde", 1, 1, -1);
+ test("abcdefghijklmnopqrst", 0, 21, "abcde", 1, 2, -1);
+ test("abcdefghijklmnopqrst", 0, 21, "abcde", 1, 3, -1);
+ test("abcdefghijklmnopqrst", 0, 21, "abcde", 1, 4, -1);
+ test("abcdefghijklmnopqrst", 0, 21, "abcde", 1, 5, -1);
+ test("abcdefghijklmnopqrst", 0, 21, "abcde", 2, 0, 20);
+ test("abcdefghijklmnopqrst", 0, 21, "abcde", 2, 1, -2);
+ test("abcdefghijklmnopqrst", 0, 21, "abcde", 2, 2, -2);
+ test("abcdefghijklmnopqrst", 0, 21, "abcde", 2, 3, -2);
+ test("abcdefghijklmnopqrst", 0, 21, "abcde", 2, 4, -2);
+ test("abcdefghijklmnopqrst", 0, 21, "abcde", 4, 0, 20);
+ test("abcdefghijklmnopqrst", 0, 21, "abcde", 4, 1, -4);
+ test("abcdefghijklmnopqrst", 0, 21, "abcde", 4, 2, -4);
+ test("abcdefghijklmnopqrst", 0, 21, "abcde", 5, 0, 20);
+ test("abcdefghijklmnopqrst", 0, 21, "abcde", 5, 1, 20);
+ test("abcdefghijklmnopqrst", 0, 21, "abcde", 6, 0, 0);
+ test("abcdefghijklmnopqrst", 0, 21, "abcdefghij", 0, 0, 20);
+ test("abcdefghijklmnopqrst", 0, 21, "abcdefghij", 0, 1, 19);
+ test("abcdefghijklmnopqrst", 0, 21, "abcdefghij", 0, 5, 15);
+ test("abcdefghijklmnopqrst", 0, 21, "abcdefghij", 0, 9, 11);
+}
+
+void test41()
+{
+ test("abcdefghijklmnopqrst", 0, 21, "abcdefghij", 0, 10, 10);
+ test("abcdefghijklmnopqrst", 0, 21, "abcdefghij", 0, 11, 10);
+ test("abcdefghijklmnopqrst", 0, 21, "abcdefghij", 1, 0, 20);
+ test("abcdefghijklmnopqrst", 0, 21, "abcdefghij", 1, 1, -1);
+ test("abcdefghijklmnopqrst", 0, 21, "abcdefghij", 1, 4, -1);
+ test("abcdefghijklmnopqrst", 0, 21, "abcdefghij", 1, 8, -1);
+ test("abcdefghijklmnopqrst", 0, 21, "abcdefghij", 1, 9, -1);
+ test("abcdefghijklmnopqrst", 0, 21, "abcdefghij", 1, 10, -1);
+ test("abcdefghijklmnopqrst", 0, 21, "abcdefghij", 5, 0, 20);
+ test("abcdefghijklmnopqrst", 0, 21, "abcdefghij", 5, 1, -5);
+ test("abcdefghijklmnopqrst", 0, 21, "abcdefghij", 5, 2, -5);
+ test("abcdefghijklmnopqrst", 0, 21, "abcdefghij", 5, 4, -5);
+ test("abcdefghijklmnopqrst", 0, 21, "abcdefghij", 5, 5, -5);
+ test("abcdefghijklmnopqrst", 0, 21, "abcdefghij", 5, 6, -5);
+ test("abcdefghijklmnopqrst", 0, 21, "abcdefghij", 9, 0, 20);
+ test("abcdefghijklmnopqrst", 0, 21, "abcdefghij", 9, 1, -9);
+ test("abcdefghijklmnopqrst", 0, 21, "abcdefghij", 9, 2, -9);
+ test("abcdefghijklmnopqrst", 0, 21, "abcdefghij", 10, 0, 20);
+ test("abcdefghijklmnopqrst", 0, 21, "abcdefghij", 10, 1, 20);
+ test("abcdefghijklmnopqrst", 0, 21, "abcdefghij", 11, 0, 0);
+ test("abcdefghijklmnopqrst", 0, 21, "abcdefghijklmnopqrst", 0, 0, 20);
+ test("abcdefghijklmnopqrst", 0, 21, "abcdefghijklmnopqrst", 0, 1, 19);
+ test("abcdefghijklmnopqrst", 0, 21, "abcdefghijklmnopqrst", 0, 10, 10);
+ test("abcdefghijklmnopqrst", 0, 21, "abcdefghijklmnopqrst", 0, 19, 1);
+ test("abcdefghijklmnopqrst", 0, 21, "abcdefghijklmnopqrst", 0, 20, 0);
+ test("abcdefghijklmnopqrst", 0, 21, "abcdefghijklmnopqrst", 0, 21, 0);
+ test("abcdefghijklmnopqrst", 0, 21, "abcdefghijklmnopqrst", 1, 0, 20);
+ test("abcdefghijklmnopqrst", 0, 21, "abcdefghijklmnopqrst", 1, 1, -1);
+ test("abcdefghijklmnopqrst", 0, 21, "abcdefghijklmnopqrst", 1, 9, -1);
+ test("abcdefghijklmnopqrst", 0, 21, "abcdefghijklmnopqrst", 1, 18, -1);
+ test("abcdefghijklmnopqrst", 0, 21, "abcdefghijklmnopqrst", 1, 19, -1);
+ test("abcdefghijklmnopqrst", 0, 21, "abcdefghijklmnopqrst", 1, 20, -1);
+ test("abcdefghijklmnopqrst", 0, 21, "abcdefghijklmnopqrst", 10, 0, 20);
+ test("abcdefghijklmnopqrst", 0, 21, "abcdefghijklmnopqrst", 10, 1, -10);
+ test("abcdefghijklmnopqrst", 0, 21, "abcdefghijklmnopqrst", 10, 5, -10);
+ test("abcdefghijklmnopqrst", 0, 21, "abcdefghijklmnopqrst", 10, 9, -10);
+ test("abcdefghijklmnopqrst", 0, 21, "abcdefghijklmnopqrst", 10, 10, -10);
+ test("abcdefghijklmnopqrst", 0, 21, "abcdefghijklmnopqrst", 10, 11, -10);
+ test("abcdefghijklmnopqrst", 0, 21, "abcdefghijklmnopqrst", 19, 0, 20);
+ test("abcdefghijklmnopqrst", 0, 21, "abcdefghijklmnopqrst", 19, 1, -19);
+ test("abcdefghijklmnopqrst", 0, 21, "abcdefghijklmnopqrst", 19, 2, -19);
+ test("abcdefghijklmnopqrst", 0, 21, "abcdefghijklmnopqrst", 20, 0, 20);
+ test("abcdefghijklmnopqrst", 0, 21, "abcdefghijklmnopqrst", 20, 1, 20);
+ test("abcdefghijklmnopqrst", 0, 21, "abcdefghijklmnopqrst", 21, 0, 0);
+ test("abcdefghijklmnopqrst", 1, 0, "", 0, 0, 0);
+ test("abcdefghijklmnopqrst", 1, 0, "", 0, 1, 0);
+ test("abcdefghijklmnopqrst", 1, 0, "", 1, 0, 0);
+ test("abcdefghijklmnopqrst", 1, 0, "abcde", 0, 0, 0);
+ test("abcdefghijklmnopqrst", 1, 0, "abcde", 0, 1, -1);
+ test("abcdefghijklmnopqrst", 1, 0, "abcde", 0, 2, -2);
+ test("abcdefghijklmnopqrst", 1, 0, "abcde", 0, 4, -4);
+ test("abcdefghijklmnopqrst", 1, 0, "abcde", 0, 5, -5);
+ test("abcdefghijklmnopqrst", 1, 0, "abcde", 0, 6, -5);
+ test("abcdefghijklmnopqrst", 1, 0, "abcde", 1, 0, 0);
+ test("abcdefghijklmnopqrst", 1, 0, "abcde", 1, 1, -1);
+ test("abcdefghijklmnopqrst", 1, 0, "abcde", 1, 2, -2);
+ test("abcdefghijklmnopqrst", 1, 0, "abcde", 1, 3, -3);
+ test("abcdefghijklmnopqrst", 1, 0, "abcde", 1, 4, -4);
+ test("abcdefghijklmnopqrst", 1, 0, "abcde", 1, 5, -4);
+ test("abcdefghijklmnopqrst", 1, 0, "abcde", 2, 0, 0);
+ test("abcdefghijklmnopqrst", 1, 0, "abcde", 2, 1, -1);
+ test("abcdefghijklmnopqrst", 1, 0, "abcde", 2, 2, -2);
+ test("abcdefghijklmnopqrst", 1, 0, "abcde", 2, 3, -3);
+ test("abcdefghijklmnopqrst", 1, 0, "abcde", 2, 4, -3);
+ test("abcdefghijklmnopqrst", 1, 0, "abcde", 4, 0, 0);
+ test("abcdefghijklmnopqrst", 1, 0, "abcde", 4, 1, -1);
+ test("abcdefghijklmnopqrst", 1, 0, "abcde", 4, 2, -1);
+ test("abcdefghijklmnopqrst", 1, 0, "abcde", 5, 0, 0);
+ test("abcdefghijklmnopqrst", 1, 0, "abcde", 5, 1, 0);
+ test("abcdefghijklmnopqrst", 1, 0, "abcde", 6, 0, 0);
+ test("abcdefghijklmnopqrst", 1, 0, "abcdefghij", 0, 0, 0);
+ test("abcdefghijklmnopqrst", 1, 0, "abcdefghij", 0, 1, -1);
+ test("abcdefghijklmnopqrst", 1, 0, "abcdefghij", 0, 5, -5);
+ test("abcdefghijklmnopqrst", 1, 0, "abcdefghij", 0, 9, -9);
+ test("abcdefghijklmnopqrst", 1, 0, "abcdefghij", 0, 10, -10);
+ test("abcdefghijklmnopqrst", 1, 0, "abcdefghij", 0, 11, -10);
+ test("abcdefghijklmnopqrst", 1, 0, "abcdefghij", 1, 0, 0);
+ test("abcdefghijklmnopqrst", 1, 0, "abcdefghij", 1, 1, -1);
+ test("abcdefghijklmnopqrst", 1, 0, "abcdefghij", 1, 4, -4);
+ test("abcdefghijklmnopqrst", 1, 0, "abcdefghij", 1, 8, -8);
+ test("abcdefghijklmnopqrst", 1, 0, "abcdefghij", 1, 9, -9);
+ test("abcdefghijklmnopqrst", 1, 0, "abcdefghij", 1, 10, -9);
+ test("abcdefghijklmnopqrst", 1, 0, "abcdefghij", 5, 0, 0);
+ test("abcdefghijklmnopqrst", 1, 0, "abcdefghij", 5, 1, -1);
+ test("abcdefghijklmnopqrst", 1, 0, "abcdefghij", 5, 2, -2);
+ test("abcdefghijklmnopqrst", 1, 0, "abcdefghij", 5, 4, -4);
+ test("abcdefghijklmnopqrst", 1, 0, "abcdefghij", 5, 5, -5);
+ test("abcdefghijklmnopqrst", 1, 0, "abcdefghij", 5, 6, -5);
+ test("abcdefghijklmnopqrst", 1, 0, "abcdefghij", 9, 0, 0);
+ test("abcdefghijklmnopqrst", 1, 0, "abcdefghij", 9, 1, -1);
+ test("abcdefghijklmnopqrst", 1, 0, "abcdefghij", 9, 2, -1);
+ test("abcdefghijklmnopqrst", 1, 0, "abcdefghij", 10, 0, 0);
+ test("abcdefghijklmnopqrst", 1, 0, "abcdefghij", 10, 1, 0);
+ test("abcdefghijklmnopqrst", 1, 0, "abcdefghij", 11, 0, 0);
+ test("abcdefghijklmnopqrst", 1, 0, "abcdefghijklmnopqrst", 0, 0, 0);
+ test("abcdefghijklmnopqrst", 1, 0, "abcdefghijklmnopqrst", 0, 1, -1);
+ test("abcdefghijklmnopqrst", 1, 0, "abcdefghijklmnopqrst", 0, 10, -10);
+ test("abcdefghijklmnopqrst", 1, 0, "abcdefghijklmnopqrst", 0, 19, -19);
+ test("abcdefghijklmnopqrst", 1, 0, "abcdefghijklmnopqrst", 0, 20, -20);
+ test("abcdefghijklmnopqrst", 1, 0, "abcdefghijklmnopqrst", 0, 21, -20);
+}
+
+void test42()
+{
+ test("abcdefghijklmnopqrst", 1, 0, "abcdefghijklmnopqrst", 1, 0, 0);
+ test("abcdefghijklmnopqrst", 1, 0, "abcdefghijklmnopqrst", 1, 1, -1);
+ test("abcdefghijklmnopqrst", 1, 0, "abcdefghijklmnopqrst", 1, 9, -9);
+ test("abcdefghijklmnopqrst", 1, 0, "abcdefghijklmnopqrst", 1, 18, -18);
+ test("abcdefghijklmnopqrst", 1, 0, "abcdefghijklmnopqrst", 1, 19, -19);
+ test("abcdefghijklmnopqrst", 1, 0, "abcdefghijklmnopqrst", 1, 20, -19);
+ test("abcdefghijklmnopqrst", 1, 0, "abcdefghijklmnopqrst", 10, 0, 0);
+ test("abcdefghijklmnopqrst", 1, 0, "abcdefghijklmnopqrst", 10, 1, -1);
+ test("abcdefghijklmnopqrst", 1, 0, "abcdefghijklmnopqrst", 10, 5, -5);
+ test("abcdefghijklmnopqrst", 1, 0, "abcdefghijklmnopqrst", 10, 9, -9);
+ test("abcdefghijklmnopqrst", 1, 0, "abcdefghijklmnopqrst", 10, 10, -10);
+ test("abcdefghijklmnopqrst", 1, 0, "abcdefghijklmnopqrst", 10, 11, -10);
+ test("abcdefghijklmnopqrst", 1, 0, "abcdefghijklmnopqrst", 19, 0, 0);
+ test("abcdefghijklmnopqrst", 1, 0, "abcdefghijklmnopqrst", 19, 1, -1);
+ test("abcdefghijklmnopqrst", 1, 0, "abcdefghijklmnopqrst", 19, 2, -1);
+ test("abcdefghijklmnopqrst", 1, 0, "abcdefghijklmnopqrst", 20, 0, 0);
+ test("abcdefghijklmnopqrst", 1, 0, "abcdefghijklmnopqrst", 20, 1, 0);
+ test("abcdefghijklmnopqrst", 1, 0, "abcdefghijklmnopqrst", 21, 0, 0);
+ test("abcdefghijklmnopqrst", 1, 1, "", 0, 0, 1);
+ test("abcdefghijklmnopqrst", 1, 1, "", 0, 1, 1);
+ test("abcdefghijklmnopqrst", 1, 1, "", 1, 0, 0);
+ test("abcdefghijklmnopqrst", 1, 1, "abcde", 0, 0, 1);
+ test("abcdefghijklmnopqrst", 1, 1, "abcde", 0, 1, 1);
+ test("abcdefghijklmnopqrst", 1, 1, "abcde", 0, 2, 1);
+ test("abcdefghijklmnopqrst", 1, 1, "abcde", 0, 4, 1);
+ test("abcdefghijklmnopqrst", 1, 1, "abcde", 0, 5, 1);
+ test("abcdefghijklmnopqrst", 1, 1, "abcde", 0, 6, 1);
+ test("abcdefghijklmnopqrst", 1, 1, "abcde", 1, 0, 1);
+ test("abcdefghijklmnopqrst", 1, 1, "abcde", 1, 1, 0);
+ test("abcdefghijklmnopqrst", 1, 1, "abcde", 1, 2, -1);
+ test("abcdefghijklmnopqrst", 1, 1, "abcde", 1, 3, -2);
+ test("abcdefghijklmnopqrst", 1, 1, "abcde", 1, 4, -3);
+ test("abcdefghijklmnopqrst", 1, 1, "abcde", 1, 5, -3);
+ test("abcdefghijklmnopqrst", 1, 1, "abcde", 2, 0, 1);
+ test("abcdefghijklmnopqrst", 1, 1, "abcde", 2, 1, -1);
+ test("abcdefghijklmnopqrst", 1, 1, "abcde", 2, 2, -1);
+ test("abcdefghijklmnopqrst", 1, 1, "abcde", 2, 3, -1);
+ test("abcdefghijklmnopqrst", 1, 1, "abcde", 2, 4, -1);
+ test("abcdefghijklmnopqrst", 1, 1, "abcde", 4, 0, 1);
+ test("abcdefghijklmnopqrst", 1, 1, "abcde", 4, 1, -3);
+ test("abcdefghijklmnopqrst", 1, 1, "abcde", 4, 2, -3);
+ test("abcdefghijklmnopqrst", 1, 1, "abcde", 5, 0, 1);
+ test("abcdefghijklmnopqrst", 1, 1, "abcde", 5, 1, 1);
+ test("abcdefghijklmnopqrst", 1, 1, "abcde", 6, 0, 0);
+ test("abcdefghijklmnopqrst", 1, 1, "abcdefghij", 0, 0, 1);
+ test("abcdefghijklmnopqrst", 1, 1, "abcdefghij", 0, 1, 1);
+ test("abcdefghijklmnopqrst", 1, 1, "abcdefghij", 0, 5, 1);
+ test("abcdefghijklmnopqrst", 1, 1, "abcdefghij", 0, 9, 1);
+ test("abcdefghijklmnopqrst", 1, 1, "abcdefghij", 0, 10, 1);
+ test("abcdefghijklmnopqrst", 1, 1, "abcdefghij", 0, 11, 1);
+ test("abcdefghijklmnopqrst", 1, 1, "abcdefghij", 1, 0, 1);
+ test("abcdefghijklmnopqrst", 1, 1, "abcdefghij", 1, 1, 0);
+ test("abcdefghijklmnopqrst", 1, 1, "abcdefghij", 1, 4, -3);
+ test("abcdefghijklmnopqrst", 1, 1, "abcdefghij", 1, 8, -7);
+ test("abcdefghijklmnopqrst", 1, 1, "abcdefghij", 1, 9, -8);
+ test("abcdefghijklmnopqrst", 1, 1, "abcdefghij", 1, 10, -8);
+ test("abcdefghijklmnopqrst", 1, 1, "abcdefghij", 5, 0, 1);
+ test("abcdefghijklmnopqrst", 1, 1, "abcdefghij", 5, 1, -4);
+ test("abcdefghijklmnopqrst", 1, 1, "abcdefghij", 5, 2, -4);
+ test("abcdefghijklmnopqrst", 1, 1, "abcdefghij", 5, 4, -4);
+ test("abcdefghijklmnopqrst", 1, 1, "abcdefghij", 5, 5, -4);
+ test("abcdefghijklmnopqrst", 1, 1, "abcdefghij", 5, 6, -4);
+ test("abcdefghijklmnopqrst", 1, 1, "abcdefghij", 9, 0, 1);
+ test("abcdefghijklmnopqrst", 1, 1, "abcdefghij", 9, 1, -8);
+ test("abcdefghijklmnopqrst", 1, 1, "abcdefghij", 9, 2, -8);
+ test("abcdefghijklmnopqrst", 1, 1, "abcdefghij", 10, 0, 1);
+ test("abcdefghijklmnopqrst", 1, 1, "abcdefghij", 10, 1, 1);
+ test("abcdefghijklmnopqrst", 1, 1, "abcdefghij", 11, 0, 0);
+ test("abcdefghijklmnopqrst", 1, 1, "abcdefghijklmnopqrst", 0, 0, 1);
+ test("abcdefghijklmnopqrst", 1, 1, "abcdefghijklmnopqrst", 0, 1, 1);
+ test("abcdefghijklmnopqrst", 1, 1, "abcdefghijklmnopqrst", 0, 10, 1);
+ test("abcdefghijklmnopqrst", 1, 1, "abcdefghijklmnopqrst", 0, 19, 1);
+ test("abcdefghijklmnopqrst", 1, 1, "abcdefghijklmnopqrst", 0, 20, 1);
+ test("abcdefghijklmnopqrst", 1, 1, "abcdefghijklmnopqrst", 0, 21, 1);
+ test("abcdefghijklmnopqrst", 1, 1, "abcdefghijklmnopqrst", 1, 0, 1);
+ test("abcdefghijklmnopqrst", 1, 1, "abcdefghijklmnopqrst", 1, 1, 0);
+ test("abcdefghijklmnopqrst", 1, 1, "abcdefghijklmnopqrst", 1, 9, -8);
+ test("abcdefghijklmnopqrst", 1, 1, "abcdefghijklmnopqrst", 1, 18, -17);
+ test("abcdefghijklmnopqrst", 1, 1, "abcdefghijklmnopqrst", 1, 19, -18);
+ test("abcdefghijklmnopqrst", 1, 1, "abcdefghijklmnopqrst", 1, 20, -18);
+ test("abcdefghijklmnopqrst", 1, 1, "abcdefghijklmnopqrst", 10, 0, 1);
+ test("abcdefghijklmnopqrst", 1, 1, "abcdefghijklmnopqrst", 10, 1, -9);
+ test("abcdefghijklmnopqrst", 1, 1, "abcdefghijklmnopqrst", 10, 5, -9);
+ test("abcdefghijklmnopqrst", 1, 1, "abcdefghijklmnopqrst", 10, 9, -9);
+ test("abcdefghijklmnopqrst", 1, 1, "abcdefghijklmnopqrst", 10, 10, -9);
+ test("abcdefghijklmnopqrst", 1, 1, "abcdefghijklmnopqrst", 10, 11, -9);
+ test("abcdefghijklmnopqrst", 1, 1, "abcdefghijklmnopqrst", 19, 0, 1);
+ test("abcdefghijklmnopqrst", 1, 1, "abcdefghijklmnopqrst", 19, 1, -18);
+ test("abcdefghijklmnopqrst", 1, 1, "abcdefghijklmnopqrst", 19, 2, -18);
+ test("abcdefghijklmnopqrst", 1, 1, "abcdefghijklmnopqrst", 20, 0, 1);
+ test("abcdefghijklmnopqrst", 1, 1, "abcdefghijklmnopqrst", 20, 1, 1);
+ test("abcdefghijklmnopqrst", 1, 1, "abcdefghijklmnopqrst", 21, 0, 0);
+ test("abcdefghijklmnopqrst", 1, 9, "", 0, 0, 9);
+ test("abcdefghijklmnopqrst", 1, 9, "", 0, 1, 9);
+ test("abcdefghijklmnopqrst", 1, 9, "", 1, 0, 0);
+ test("abcdefghijklmnopqrst", 1, 9, "abcde", 0, 0, 9);
+ test("abcdefghijklmnopqrst", 1, 9, "abcde", 0, 1, 1);
+ test("abcdefghijklmnopqrst", 1, 9, "abcde", 0, 2, 1);
+ test("abcdefghijklmnopqrst", 1, 9, "abcde", 0, 4, 1);
+ test("abcdefghijklmnopqrst", 1, 9, "abcde", 0, 5, 1);
+}
+
+void test43()
+{
+ test("abcdefghijklmnopqrst", 1, 9, "abcde", 0, 6, 1);
+ test("abcdefghijklmnopqrst", 1, 9, "abcde", 1, 0, 9);
+ test("abcdefghijklmnopqrst", 1, 9, "abcde", 1, 1, 8);
+ test("abcdefghijklmnopqrst", 1, 9, "abcde", 1, 2, 7);
+ test("abcdefghijklmnopqrst", 1, 9, "abcde", 1, 3, 6);
+ test("abcdefghijklmnopqrst", 1, 9, "abcde", 1, 4, 5);
+ test("abcdefghijklmnopqrst", 1, 9, "abcde", 1, 5, 5);
+ test("abcdefghijklmnopqrst", 1, 9, "abcde", 2, 0, 9);
+ test("abcdefghijklmnopqrst", 1, 9, "abcde", 2, 1, -1);
+ test("abcdefghijklmnopqrst", 1, 9, "abcde", 2, 2, -1);
+ test("abcdefghijklmnopqrst", 1, 9, "abcde", 2, 3, -1);
+ test("abcdefghijklmnopqrst", 1, 9, "abcde", 2, 4, -1);
+ test("abcdefghijklmnopqrst", 1, 9, "abcde", 4, 0, 9);
+ test("abcdefghijklmnopqrst", 1, 9, "abcde", 4, 1, -3);
+ test("abcdefghijklmnopqrst", 1, 9, "abcde", 4, 2, -3);
+ test("abcdefghijklmnopqrst", 1, 9, "abcde", 5, 0, 9);
+ test("abcdefghijklmnopqrst", 1, 9, "abcde", 5, 1, 9);
+ test("abcdefghijklmnopqrst", 1, 9, "abcde", 6, 0, 0);
+ test("abcdefghijklmnopqrst", 1, 9, "abcdefghij", 0, 0, 9);
+ test("abcdefghijklmnopqrst", 1, 9, "abcdefghij", 0, 1, 1);
+ test("abcdefghijklmnopqrst", 1, 9, "abcdefghij", 0, 5, 1);
+ test("abcdefghijklmnopqrst", 1, 9, "abcdefghij", 0, 9, 1);
+ test("abcdefghijklmnopqrst", 1, 9, "abcdefghij", 0, 10, 1);
+ test("abcdefghijklmnopqrst", 1, 9, "abcdefghij", 0, 11, 1);
+ test("abcdefghijklmnopqrst", 1, 9, "abcdefghij", 1, 0, 9);
+ test("abcdefghijklmnopqrst", 1, 9, "abcdefghij", 1, 1, 8);
+ test("abcdefghijklmnopqrst", 1, 9, "abcdefghij", 1, 4, 5);
+ test("abcdefghijklmnopqrst", 1, 9, "abcdefghij", 1, 8, 1);
+ test("abcdefghijklmnopqrst", 1, 9, "abcdefghij", 1, 9, 0);
+ test("abcdefghijklmnopqrst", 1, 9, "abcdefghij", 1, 10, 0);
+ test("abcdefghijklmnopqrst", 1, 9, "abcdefghij", 5, 0, 9);
+ test("abcdefghijklmnopqrst", 1, 9, "abcdefghij", 5, 1, -4);
+ test("abcdefghijklmnopqrst", 1, 9, "abcdefghij", 5, 2, -4);
+ test("abcdefghijklmnopqrst", 1, 9, "abcdefghij", 5, 4, -4);
+ test("abcdefghijklmnopqrst", 1, 9, "abcdefghij", 5, 5, -4);
+ test("abcdefghijklmnopqrst", 1, 9, "abcdefghij", 5, 6, -4);
+ test("abcdefghijklmnopqrst", 1, 9, "abcdefghij", 9, 0, 9);
+ test("abcdefghijklmnopqrst", 1, 9, "abcdefghij", 9, 1, -8);
+ test("abcdefghijklmnopqrst", 1, 9, "abcdefghij", 9, 2, -8);
+ test("abcdefghijklmnopqrst", 1, 9, "abcdefghij", 10, 0, 9);
+ test("abcdefghijklmnopqrst", 1, 9, "abcdefghij", 10, 1, 9);
+ test("abcdefghijklmnopqrst", 1, 9, "abcdefghij", 11, 0, 0);
+ test("abcdefghijklmnopqrst", 1, 9, "abcdefghijklmnopqrst", 0, 0, 9);
+ test("abcdefghijklmnopqrst", 1, 9, "abcdefghijklmnopqrst", 0, 1, 1);
+ test("abcdefghijklmnopqrst", 1, 9, "abcdefghijklmnopqrst", 0, 10, 1);
+ test("abcdefghijklmnopqrst", 1, 9, "abcdefghijklmnopqrst", 0, 19, 1);
+ test("abcdefghijklmnopqrst", 1, 9, "abcdefghijklmnopqrst", 0, 20, 1);
+ test("abcdefghijklmnopqrst", 1, 9, "abcdefghijklmnopqrst", 0, 21, 1);
+ test("abcdefghijklmnopqrst", 1, 9, "abcdefghijklmnopqrst", 1, 0, 9);
+ test("abcdefghijklmnopqrst", 1, 9, "abcdefghijklmnopqrst", 1, 1, 8);
+ test("abcdefghijklmnopqrst", 1, 9, "abcdefghijklmnopqrst", 1, 9, 0);
+ test("abcdefghijklmnopqrst", 1, 9, "abcdefghijklmnopqrst", 1, 18, -9);
+ test("abcdefghijklmnopqrst", 1, 9, "abcdefghijklmnopqrst", 1, 19, -10);
+ test("abcdefghijklmnopqrst", 1, 9, "abcdefghijklmnopqrst", 1, 20, -10);
+ test("abcdefghijklmnopqrst", 1, 9, "abcdefghijklmnopqrst", 10, 0, 9);
+ test("abcdefghijklmnopqrst", 1, 9, "abcdefghijklmnopqrst", 10, 1, -9);
+ test("abcdefghijklmnopqrst", 1, 9, "abcdefghijklmnopqrst", 10, 5, -9);
+ test("abcdefghijklmnopqrst", 1, 9, "abcdefghijklmnopqrst", 10, 9, -9);
+ test("abcdefghijklmnopqrst", 1, 9, "abcdefghijklmnopqrst", 10, 10, -9);
+ test("abcdefghijklmnopqrst", 1, 9, "abcdefghijklmnopqrst", 10, 11, -9);
+ test("abcdefghijklmnopqrst", 1, 9, "abcdefghijklmnopqrst", 19, 0, 9);
+ test("abcdefghijklmnopqrst", 1, 9, "abcdefghijklmnopqrst", 19, 1, -18);
+ test("abcdefghijklmnopqrst", 1, 9, "abcdefghijklmnopqrst", 19, 2, -18);
+ test("abcdefghijklmnopqrst", 1, 9, "abcdefghijklmnopqrst", 20, 0, 9);
+ test("abcdefghijklmnopqrst", 1, 9, "abcdefghijklmnopqrst", 20, 1, 9);
+ test("abcdefghijklmnopqrst", 1, 9, "abcdefghijklmnopqrst", 21, 0, 0);
+ test("abcdefghijklmnopqrst", 1, 18, "", 0, 0, 18);
+ test("abcdefghijklmnopqrst", 1, 18, "", 0, 1, 18);
+ test("abcdefghijklmnopqrst", 1, 18, "", 1, 0, 0);
+ test("abcdefghijklmnopqrst", 1, 18, "abcde", 0, 0, 18);
+ test("abcdefghijklmnopqrst", 1, 18, "abcde", 0, 1, 1);
+ test("abcdefghijklmnopqrst", 1, 18, "abcde", 0, 2, 1);
+ test("abcdefghijklmnopqrst", 1, 18, "abcde", 0, 4, 1);
+ test("abcdefghijklmnopqrst", 1, 18, "abcde", 0, 5, 1);
+ test("abcdefghijklmnopqrst", 1, 18, "abcde", 0, 6, 1);
+ test("abcdefghijklmnopqrst", 1, 18, "abcde", 1, 0, 18);
+ test("abcdefghijklmnopqrst", 1, 18, "abcde", 1, 1, 17);
+ test("abcdefghijklmnopqrst", 1, 18, "abcde", 1, 2, 16);
+ test("abcdefghijklmnopqrst", 1, 18, "abcde", 1, 3, 15);
+ test("abcdefghijklmnopqrst", 1, 18, "abcde", 1, 4, 14);
+ test("abcdefghijklmnopqrst", 1, 18, "abcde", 1, 5, 14);
+ test("abcdefghijklmnopqrst", 1, 18, "abcde", 2, 0, 18);
+ test("abcdefghijklmnopqrst", 1, 18, "abcde", 2, 1, -1);
+ test("abcdefghijklmnopqrst", 1, 18, "abcde", 2, 2, -1);
+ test("abcdefghijklmnopqrst", 1, 18, "abcde", 2, 3, -1);
+ test("abcdefghijklmnopqrst", 1, 18, "abcde", 2, 4, -1);
+ test("abcdefghijklmnopqrst", 1, 18, "abcde", 4, 0, 18);
+ test("abcdefghijklmnopqrst", 1, 18, "abcde", 4, 1, -3);
+ test("abcdefghijklmnopqrst", 1, 18, "abcde", 4, 2, -3);
+ test("abcdefghijklmnopqrst", 1, 18, "abcde", 5, 0, 18);
+ test("abcdefghijklmnopqrst", 1, 18, "abcde", 5, 1, 18);
+ test("abcdefghijklmnopqrst", 1, 18, "abcde", 6, 0, 0);
+ test("abcdefghijklmnopqrst", 1, 18, "abcdefghij", 0, 0, 18);
+ test("abcdefghijklmnopqrst", 1, 18, "abcdefghij", 0, 1, 1);
+ test("abcdefghijklmnopqrst", 1, 18, "abcdefghij", 0, 5, 1);
+ test("abcdefghijklmnopqrst", 1, 18, "abcdefghij", 0, 9, 1);
+ test("abcdefghijklmnopqrst", 1, 18, "abcdefghij", 0, 10, 1);
+ test("abcdefghijklmnopqrst", 1, 18, "abcdefghij", 0, 11, 1);
+ test("abcdefghijklmnopqrst", 1, 18, "abcdefghij", 1, 0, 18);
+ test("abcdefghijklmnopqrst", 1, 18, "abcdefghij", 1, 1, 17);
+}
+
+void test44()
+{
+ test("abcdefghijklmnopqrst", 1, 18, "abcdefghij", 1, 4, 14);
+ test("abcdefghijklmnopqrst", 1, 18, "abcdefghij", 1, 8, 10);
+ test("abcdefghijklmnopqrst", 1, 18, "abcdefghij", 1, 9, 9);
+ test("abcdefghijklmnopqrst", 1, 18, "abcdefghij", 1, 10, 9);
+ test("abcdefghijklmnopqrst", 1, 18, "abcdefghij", 5, 0, 18);
+ test("abcdefghijklmnopqrst", 1, 18, "abcdefghij", 5, 1, -4);
+ test("abcdefghijklmnopqrst", 1, 18, "abcdefghij", 5, 2, -4);
+ test("abcdefghijklmnopqrst", 1, 18, "abcdefghij", 5, 4, -4);
+ test("abcdefghijklmnopqrst", 1, 18, "abcdefghij", 5, 5, -4);
+ test("abcdefghijklmnopqrst", 1, 18, "abcdefghij", 5, 6, -4);
+ test("abcdefghijklmnopqrst", 1, 18, "abcdefghij", 9, 0, 18);
+ test("abcdefghijklmnopqrst", 1, 18, "abcdefghij", 9, 1, -8);
+ test("abcdefghijklmnopqrst", 1, 18, "abcdefghij", 9, 2, -8);
+ test("abcdefghijklmnopqrst", 1, 18, "abcdefghij", 10, 0, 18);
+ test("abcdefghijklmnopqrst", 1, 18, "abcdefghij", 10, 1, 18);
+ test("abcdefghijklmnopqrst", 1, 18, "abcdefghij", 11, 0, 0);
+ test("abcdefghijklmnopqrst", 1, 18, "abcdefghijklmnopqrst", 0, 0, 18);
+ test("abcdefghijklmnopqrst", 1, 18, "abcdefghijklmnopqrst", 0, 1, 1);
+ test("abcdefghijklmnopqrst", 1, 18, "abcdefghijklmnopqrst", 0, 10, 1);
+ test("abcdefghijklmnopqrst", 1, 18, "abcdefghijklmnopqrst", 0, 19, 1);
+ test("abcdefghijklmnopqrst", 1, 18, "abcdefghijklmnopqrst", 0, 20, 1);
+ test("abcdefghijklmnopqrst", 1, 18, "abcdefghijklmnopqrst", 0, 21, 1);
+ test("abcdefghijklmnopqrst", 1, 18, "abcdefghijklmnopqrst", 1, 0, 18);
+ test("abcdefghijklmnopqrst", 1, 18, "abcdefghijklmnopqrst", 1, 1, 17);
+ test("abcdefghijklmnopqrst", 1, 18, "abcdefghijklmnopqrst", 1, 9, 9);
+ test("abcdefghijklmnopqrst", 1, 18, "abcdefghijklmnopqrst", 1, 18, 0);
+ test("abcdefghijklmnopqrst", 1, 18, "abcdefghijklmnopqrst", 1, 19, -1);
+ test("abcdefghijklmnopqrst", 1, 18, "abcdefghijklmnopqrst", 1, 20, -1);
+ test("abcdefghijklmnopqrst", 1, 18, "abcdefghijklmnopqrst", 10, 0, 18);
+ test("abcdefghijklmnopqrst", 1, 18, "abcdefghijklmnopqrst", 10, 1, -9);
+ test("abcdefghijklmnopqrst", 1, 18, "abcdefghijklmnopqrst", 10, 5, -9);
+ test("abcdefghijklmnopqrst", 1, 18, "abcdefghijklmnopqrst", 10, 9, -9);
+ test("abcdefghijklmnopqrst", 1, 18, "abcdefghijklmnopqrst", 10, 10, -9);
+ test("abcdefghijklmnopqrst", 1, 18, "abcdefghijklmnopqrst", 10, 11, -9);
+ test("abcdefghijklmnopqrst", 1, 18, "abcdefghijklmnopqrst", 19, 0, 18);
+ test("abcdefghijklmnopqrst", 1, 18, "abcdefghijklmnopqrst", 19, 1, -18);
+ test("abcdefghijklmnopqrst", 1, 18, "abcdefghijklmnopqrst", 19, 2, -18);
+ test("abcdefghijklmnopqrst", 1, 18, "abcdefghijklmnopqrst", 20, 0, 18);
+ test("abcdefghijklmnopqrst", 1, 18, "abcdefghijklmnopqrst", 20, 1, 18);
+ test("abcdefghijklmnopqrst", 1, 18, "abcdefghijklmnopqrst", 21, 0, 0);
+ test("abcdefghijklmnopqrst", 1, 19, "", 0, 0, 19);
+ test("abcdefghijklmnopqrst", 1, 19, "", 0, 1, 19);
+ test("abcdefghijklmnopqrst", 1, 19, "", 1, 0, 0);
+ test("abcdefghijklmnopqrst", 1, 19, "abcde", 0, 0, 19);
+ test("abcdefghijklmnopqrst", 1, 19, "abcde", 0, 1, 1);
+ test("abcdefghijklmnopqrst", 1, 19, "abcde", 0, 2, 1);
+ test("abcdefghijklmnopqrst", 1, 19, "abcde", 0, 4, 1);
+ test("abcdefghijklmnopqrst", 1, 19, "abcde", 0, 5, 1);
+ test("abcdefghijklmnopqrst", 1, 19, "abcde", 0, 6, 1);
+ test("abcdefghijklmnopqrst", 1, 19, "abcde", 1, 0, 19);
+ test("abcdefghijklmnopqrst", 1, 19, "abcde", 1, 1, 18);
+ test("abcdefghijklmnopqrst", 1, 19, "abcde", 1, 2, 17);
+ test("abcdefghijklmnopqrst", 1, 19, "abcde", 1, 3, 16);
+ test("abcdefghijklmnopqrst", 1, 19, "abcde", 1, 4, 15);
+ test("abcdefghijklmnopqrst", 1, 19, "abcde", 1, 5, 15);
+ test("abcdefghijklmnopqrst", 1, 19, "abcde", 2, 0, 19);
+ test("abcdefghijklmnopqrst", 1, 19, "abcde", 2, 1, -1);
+ test("abcdefghijklmnopqrst", 1, 19, "abcde", 2, 2, -1);
+ test("abcdefghijklmnopqrst", 1, 19, "abcde", 2, 3, -1);
+ test("abcdefghijklmnopqrst", 1, 19, "abcde", 2, 4, -1);
+ test("abcdefghijklmnopqrst", 1, 19, "abcde", 4, 0, 19);
+ test("abcdefghijklmnopqrst", 1, 19, "abcde", 4, 1, -3);
+ test("abcdefghijklmnopqrst", 1, 19, "abcde", 4, 2, -3);
+ test("abcdefghijklmnopqrst", 1, 19, "abcde", 5, 0, 19);
+ test("abcdefghijklmnopqrst", 1, 19, "abcde", 5, 1, 19);
+ test("abcdefghijklmnopqrst", 1, 19, "abcde", 6, 0, 0);
+ test("abcdefghijklmnopqrst", 1, 19, "abcdefghij", 0, 0, 19);
+ test("abcdefghijklmnopqrst", 1, 19, "abcdefghij", 0, 1, 1);
+ test("abcdefghijklmnopqrst", 1, 19, "abcdefghij", 0, 5, 1);
+ test("abcdefghijklmnopqrst", 1, 19, "abcdefghij", 0, 9, 1);
+ test("abcdefghijklmnopqrst", 1, 19, "abcdefghij", 0, 10, 1);
+ test("abcdefghijklmnopqrst", 1, 19, "abcdefghij", 0, 11, 1);
+ test("abcdefghijklmnopqrst", 1, 19, "abcdefghij", 1, 0, 19);
+ test("abcdefghijklmnopqrst", 1, 19, "abcdefghij", 1, 1, 18);
+ test("abcdefghijklmnopqrst", 1, 19, "abcdefghij", 1, 4, 15);
+ test("abcdefghijklmnopqrst", 1, 19, "abcdefghij", 1, 8, 11);
+ test("abcdefghijklmnopqrst", 1, 19, "abcdefghij", 1, 9, 10);
+ test("abcdefghijklmnopqrst", 1, 19, "abcdefghij", 1, 10, 10);
+ test("abcdefghijklmnopqrst", 1, 19, "abcdefghij", 5, 0, 19);
+ test("abcdefghijklmnopqrst", 1, 19, "abcdefghij", 5, 1, -4);
+ test("abcdefghijklmnopqrst", 1, 19, "abcdefghij", 5, 2, -4);
+ test("abcdefghijklmnopqrst", 1, 19, "abcdefghij", 5, 4, -4);
+ test("abcdefghijklmnopqrst", 1, 19, "abcdefghij", 5, 5, -4);
+ test("abcdefghijklmnopqrst", 1, 19, "abcdefghij", 5, 6, -4);
+ test("abcdefghijklmnopqrst", 1, 19, "abcdefghij", 9, 0, 19);
+ test("abcdefghijklmnopqrst", 1, 19, "abcdefghij", 9, 1, -8);
+ test("abcdefghijklmnopqrst", 1, 19, "abcdefghij", 9, 2, -8);
+ test("abcdefghijklmnopqrst", 1, 19, "abcdefghij", 10, 0, 19);
+ test("abcdefghijklmnopqrst", 1, 19, "abcdefghij", 10, 1, 19);
+ test("abcdefghijklmnopqrst", 1, 19, "abcdefghij", 11, 0, 0);
+ test("abcdefghijklmnopqrst", 1, 19, "abcdefghijklmnopqrst", 0, 0, 19);
+ test("abcdefghijklmnopqrst", 1, 19, "abcdefghijklmnopqrst", 0, 1, 1);
+ test("abcdefghijklmnopqrst", 1, 19, "abcdefghijklmnopqrst", 0, 10, 1);
+ test("abcdefghijklmnopqrst", 1, 19, "abcdefghijklmnopqrst", 0, 19, 1);
+ test("abcdefghijklmnopqrst", 1, 19, "abcdefghijklmnopqrst", 0, 20, 1);
+ test("abcdefghijklmnopqrst", 1, 19, "abcdefghijklmnopqrst", 0, 21, 1);
+ test("abcdefghijklmnopqrst", 1, 19, "abcdefghijklmnopqrst", 1, 0, 19);
+ test("abcdefghijklmnopqrst", 1, 19, "abcdefghijklmnopqrst", 1, 1, 18);
+ test("abcdefghijklmnopqrst", 1, 19, "abcdefghijklmnopqrst", 1, 9, 10);
+ test("abcdefghijklmnopqrst", 1, 19, "abcdefghijklmnopqrst", 1, 18, 1);
+}
+
+void test45()
+{
+ test("abcdefghijklmnopqrst", 1, 19, "abcdefghijklmnopqrst", 1, 19, 0);
+ test("abcdefghijklmnopqrst", 1, 19, "abcdefghijklmnopqrst", 1, 20, 0);
+ test("abcdefghijklmnopqrst", 1, 19, "abcdefghijklmnopqrst", 10, 0, 19);
+ test("abcdefghijklmnopqrst", 1, 19, "abcdefghijklmnopqrst", 10, 1, -9);
+ test("abcdefghijklmnopqrst", 1, 19, "abcdefghijklmnopqrst", 10, 5, -9);
+ test("abcdefghijklmnopqrst", 1, 19, "abcdefghijklmnopqrst", 10, 9, -9);
+ test("abcdefghijklmnopqrst", 1, 19, "abcdefghijklmnopqrst", 10, 10, -9);
+ test("abcdefghijklmnopqrst", 1, 19, "abcdefghijklmnopqrst", 10, 11, -9);
+ test("abcdefghijklmnopqrst", 1, 19, "abcdefghijklmnopqrst", 19, 0, 19);
+ test("abcdefghijklmnopqrst", 1, 19, "abcdefghijklmnopqrst", 19, 1, -18);
+ test("abcdefghijklmnopqrst", 1, 19, "abcdefghijklmnopqrst", 19, 2, -18);
+ test("abcdefghijklmnopqrst", 1, 19, "abcdefghijklmnopqrst", 20, 0, 19);
+ test("abcdefghijklmnopqrst", 1, 19, "abcdefghijklmnopqrst", 20, 1, 19);
+ test("abcdefghijklmnopqrst", 1, 19, "abcdefghijklmnopqrst", 21, 0, 0);
+ test("abcdefghijklmnopqrst", 1, 20, "", 0, 0, 19);
+ test("abcdefghijklmnopqrst", 1, 20, "", 0, 1, 19);
+ test("abcdefghijklmnopqrst", 1, 20, "", 1, 0, 0);
+ test("abcdefghijklmnopqrst", 1, 20, "abcde", 0, 0, 19);
+ test("abcdefghijklmnopqrst", 1, 20, "abcde", 0, 1, 1);
+ test("abcdefghijklmnopqrst", 1, 20, "abcde", 0, 2, 1);
+ test("abcdefghijklmnopqrst", 1, 20, "abcde", 0, 4, 1);
+ test("abcdefghijklmnopqrst", 1, 20, "abcde", 0, 5, 1);
+ test("abcdefghijklmnopqrst", 1, 20, "abcde", 0, 6, 1);
+ test("abcdefghijklmnopqrst", 1, 20, "abcde", 1, 0, 19);
+ test("abcdefghijklmnopqrst", 1, 20, "abcde", 1, 1, 18);
+ test("abcdefghijklmnopqrst", 1, 20, "abcde", 1, 2, 17);
+ test("abcdefghijklmnopqrst", 1, 20, "abcde", 1, 3, 16);
+ test("abcdefghijklmnopqrst", 1, 20, "abcde", 1, 4, 15);
+ test("abcdefghijklmnopqrst", 1, 20, "abcde", 1, 5, 15);
+ test("abcdefghijklmnopqrst", 1, 20, "abcde", 2, 0, 19);
+ test("abcdefghijklmnopqrst", 1, 20, "abcde", 2, 1, -1);
+ test("abcdefghijklmnopqrst", 1, 20, "abcde", 2, 2, -1);
+ test("abcdefghijklmnopqrst", 1, 20, "abcde", 2, 3, -1);
+ test("abcdefghijklmnopqrst", 1, 20, "abcde", 2, 4, -1);
+ test("abcdefghijklmnopqrst", 1, 20, "abcde", 4, 0, 19);
+ test("abcdefghijklmnopqrst", 1, 20, "abcde", 4, 1, -3);
+ test("abcdefghijklmnopqrst", 1, 20, "abcde", 4, 2, -3);
+ test("abcdefghijklmnopqrst", 1, 20, "abcde", 5, 0, 19);
+ test("abcdefghijklmnopqrst", 1, 20, "abcde", 5, 1, 19);
+ test("abcdefghijklmnopqrst", 1, 20, "abcde", 6, 0, 0);
+ test("abcdefghijklmnopqrst", 1, 20, "abcdefghij", 0, 0, 19);
+ test("abcdefghijklmnopqrst", 1, 20, "abcdefghij", 0, 1, 1);
+ test("abcdefghijklmnopqrst", 1, 20, "abcdefghij", 0, 5, 1);
+ test("abcdefghijklmnopqrst", 1, 20, "abcdefghij", 0, 9, 1);
+ test("abcdefghijklmnopqrst", 1, 20, "abcdefghij", 0, 10, 1);
+ test("abcdefghijklmnopqrst", 1, 20, "abcdefghij", 0, 11, 1);
+ test("abcdefghijklmnopqrst", 1, 20, "abcdefghij", 1, 0, 19);
+ test("abcdefghijklmnopqrst", 1, 20, "abcdefghij", 1, 1, 18);
+ test("abcdefghijklmnopqrst", 1, 20, "abcdefghij", 1, 4, 15);
+ test("abcdefghijklmnopqrst", 1, 20, "abcdefghij", 1, 8, 11);
+ test("abcdefghijklmnopqrst", 1, 20, "abcdefghij", 1, 9, 10);
+ test("abcdefghijklmnopqrst", 1, 20, "abcdefghij", 1, 10, 10);
+ test("abcdefghijklmnopqrst", 1, 20, "abcdefghij", 5, 0, 19);
+ test("abcdefghijklmnopqrst", 1, 20, "abcdefghij", 5, 1, -4);
+ test("abcdefghijklmnopqrst", 1, 20, "abcdefghij", 5, 2, -4);
+ test("abcdefghijklmnopqrst", 1, 20, "abcdefghij", 5, 4, -4);
+ test("abcdefghijklmnopqrst", 1, 20, "abcdefghij", 5, 5, -4);
+ test("abcdefghijklmnopqrst", 1, 20, "abcdefghij", 5, 6, -4);
+ test("abcdefghijklmnopqrst", 1, 20, "abcdefghij", 9, 0, 19);
+ test("abcdefghijklmnopqrst", 1, 20, "abcdefghij", 9, 1, -8);
+ test("abcdefghijklmnopqrst", 1, 20, "abcdefghij", 9, 2, -8);
+ test("abcdefghijklmnopqrst", 1, 20, "abcdefghij", 10, 0, 19);
+ test("abcdefghijklmnopqrst", 1, 20, "abcdefghij", 10, 1, 19);
+ test("abcdefghijklmnopqrst", 1, 20, "abcdefghij", 11, 0, 0);
+ test("abcdefghijklmnopqrst", 1, 20, "abcdefghijklmnopqrst", 0, 0, 19);
+ test("abcdefghijklmnopqrst", 1, 20, "abcdefghijklmnopqrst", 0, 1, 1);
+ test("abcdefghijklmnopqrst", 1, 20, "abcdefghijklmnopqrst", 0, 10, 1);
+ test("abcdefghijklmnopqrst", 1, 20, "abcdefghijklmnopqrst", 0, 19, 1);
+ test("abcdefghijklmnopqrst", 1, 20, "abcdefghijklmnopqrst", 0, 20, 1);
+ test("abcdefghijklmnopqrst", 1, 20, "abcdefghijklmnopqrst", 0, 21, 1);
+ test("abcdefghijklmnopqrst", 1, 20, "abcdefghijklmnopqrst", 1, 0, 19);
+ test("abcdefghijklmnopqrst", 1, 20, "abcdefghijklmnopqrst", 1, 1, 18);
+ test("abcdefghijklmnopqrst", 1, 20, "abcdefghijklmnopqrst", 1, 9, 10);
+ test("abcdefghijklmnopqrst", 1, 20, "abcdefghijklmnopqrst", 1, 18, 1);
+ test("abcdefghijklmnopqrst", 1, 20, "abcdefghijklmnopqrst", 1, 19, 0);
+ test("abcdefghijklmnopqrst", 1, 20, "abcdefghijklmnopqrst", 1, 20, 0);
+ test("abcdefghijklmnopqrst", 1, 20, "abcdefghijklmnopqrst", 10, 0, 19);
+ test("abcdefghijklmnopqrst", 1, 20, "abcdefghijklmnopqrst", 10, 1, -9);
+ test("abcdefghijklmnopqrst", 1, 20, "abcdefghijklmnopqrst", 10, 5, -9);
+ test("abcdefghijklmnopqrst", 1, 20, "abcdefghijklmnopqrst", 10, 9, -9);
+ test("abcdefghijklmnopqrst", 1, 20, "abcdefghijklmnopqrst", 10, 10, -9);
+ test("abcdefghijklmnopqrst", 1, 20, "abcdefghijklmnopqrst", 10, 11, -9);
+ test("abcdefghijklmnopqrst", 1, 20, "abcdefghijklmnopqrst", 19, 0, 19);
+ test("abcdefghijklmnopqrst", 1, 20, "abcdefghijklmnopqrst", 19, 1, -18);
+ test("abcdefghijklmnopqrst", 1, 20, "abcdefghijklmnopqrst", 19, 2, -18);
+ test("abcdefghijklmnopqrst", 1, 20, "abcdefghijklmnopqrst", 20, 0, 19);
+ test("abcdefghijklmnopqrst", 1, 20, "abcdefghijklmnopqrst", 20, 1, 19);
+ test("abcdefghijklmnopqrst", 1, 20, "abcdefghijklmnopqrst", 21, 0, 0);
+ test("abcdefghijklmnopqrst", 10, 0, "", 0, 0, 0);
+ test("abcdefghijklmnopqrst", 10, 0, "", 0, 1, 0);
+ test("abcdefghijklmnopqrst", 10, 0, "", 1, 0, 0);
+ test("abcdefghijklmnopqrst", 10, 0, "abcde", 0, 0, 0);
+ test("abcdefghijklmnopqrst", 10, 0, "abcde", 0, 1, -1);
+ test("abcdefghijklmnopqrst", 10, 0, "abcde", 0, 2, -2);
+ test("abcdefghijklmnopqrst", 10, 0, "abcde", 0, 4, -4);
+ test("abcdefghijklmnopqrst", 10, 0, "abcde", 0, 5, -5);
+ test("abcdefghijklmnopqrst", 10, 0, "abcde", 0, 6, -5);
+ test("abcdefghijklmnopqrst", 10, 0, "abcde", 1, 0, 0);
+ test("abcdefghijklmnopqrst", 10, 0, "abcde", 1, 1, -1);
+ test("abcdefghijklmnopqrst", 10, 0, "abcde", 1, 2, -2);
+}
+
+void test46()
+{
+ test("abcdefghijklmnopqrst", 10, 0, "abcde", 1, 3, -3);
+ test("abcdefghijklmnopqrst", 10, 0, "abcde", 1, 4, -4);
+ test("abcdefghijklmnopqrst", 10, 0, "abcde", 1, 5, -4);
+ test("abcdefghijklmnopqrst", 10, 0, "abcde", 2, 0, 0);
+ test("abcdefghijklmnopqrst", 10, 0, "abcde", 2, 1, -1);
+ test("abcdefghijklmnopqrst", 10, 0, "abcde", 2, 2, -2);
+ test("abcdefghijklmnopqrst", 10, 0, "abcde", 2, 3, -3);
+ test("abcdefghijklmnopqrst", 10, 0, "abcde", 2, 4, -3);
+ test("abcdefghijklmnopqrst", 10, 0, "abcde", 4, 0, 0);
+ test("abcdefghijklmnopqrst", 10, 0, "abcde", 4, 1, -1);
+ test("abcdefghijklmnopqrst", 10, 0, "abcde", 4, 2, -1);
+ test("abcdefghijklmnopqrst", 10, 0, "abcde", 5, 0, 0);
+ test("abcdefghijklmnopqrst", 10, 0, "abcde", 5, 1, 0);
+ test("abcdefghijklmnopqrst", 10, 0, "abcde", 6, 0, 0);
+ test("abcdefghijklmnopqrst", 10, 0, "abcdefghij", 0, 0, 0);
+ test("abcdefghijklmnopqrst", 10, 0, "abcdefghij", 0, 1, -1);
+ test("abcdefghijklmnopqrst", 10, 0, "abcdefghij", 0, 5, -5);
+ test("abcdefghijklmnopqrst", 10, 0, "abcdefghij", 0, 9, -9);
+ test("abcdefghijklmnopqrst", 10, 0, "abcdefghij", 0, 10, -10);
+ test("abcdefghijklmnopqrst", 10, 0, "abcdefghij", 0, 11, -10);
+ test("abcdefghijklmnopqrst", 10, 0, "abcdefghij", 1, 0, 0);
+ test("abcdefghijklmnopqrst", 10, 0, "abcdefghij", 1, 1, -1);
+ test("abcdefghijklmnopqrst", 10, 0, "abcdefghij", 1, 4, -4);
+ test("abcdefghijklmnopqrst", 10, 0, "abcdefghij", 1, 8, -8);
+ test("abcdefghijklmnopqrst", 10, 0, "abcdefghij", 1, 9, -9);
+ test("abcdefghijklmnopqrst", 10, 0, "abcdefghij", 1, 10, -9);
+ test("abcdefghijklmnopqrst", 10, 0, "abcdefghij", 5, 0, 0);
+ test("abcdefghijklmnopqrst", 10, 0, "abcdefghij", 5, 1, -1);
+ test("abcdefghijklmnopqrst", 10, 0, "abcdefghij", 5, 2, -2);
+ test("abcdefghijklmnopqrst", 10, 0, "abcdefghij", 5, 4, -4);
+ test("abcdefghijklmnopqrst", 10, 0, "abcdefghij", 5, 5, -5);
+ test("abcdefghijklmnopqrst", 10, 0, "abcdefghij", 5, 6, -5);
+ test("abcdefghijklmnopqrst", 10, 0, "abcdefghij", 9, 0, 0);
+ test("abcdefghijklmnopqrst", 10, 0, "abcdefghij", 9, 1, -1);
+ test("abcdefghijklmnopqrst", 10, 0, "abcdefghij", 9, 2, -1);
+ test("abcdefghijklmnopqrst", 10, 0, "abcdefghij", 10, 0, 0);
+ test("abcdefghijklmnopqrst", 10, 0, "abcdefghij", 10, 1, 0);
+ test("abcdefghijklmnopqrst", 10, 0, "abcdefghij", 11, 0, 0);
+ test("abcdefghijklmnopqrst", 10, 0, "abcdefghijklmnopqrst", 0, 0, 0);
+ test("abcdefghijklmnopqrst", 10, 0, "abcdefghijklmnopqrst", 0, 1, -1);
+ test("abcdefghijklmnopqrst", 10, 0, "abcdefghijklmnopqrst", 0, 10, -10);
+ test("abcdefghijklmnopqrst", 10, 0, "abcdefghijklmnopqrst", 0, 19, -19);
+ test("abcdefghijklmnopqrst", 10, 0, "abcdefghijklmnopqrst", 0, 20, -20);
+ test("abcdefghijklmnopqrst", 10, 0, "abcdefghijklmnopqrst", 0, 21, -20);
+ test("abcdefghijklmnopqrst", 10, 0, "abcdefghijklmnopqrst", 1, 0, 0);
+ test("abcdefghijklmnopqrst", 10, 0, "abcdefghijklmnopqrst", 1, 1, -1);
+ test("abcdefghijklmnopqrst", 10, 0, "abcdefghijklmnopqrst", 1, 9, -9);
+ test("abcdefghijklmnopqrst", 10, 0, "abcdefghijklmnopqrst", 1, 18, -18);
+ test("abcdefghijklmnopqrst", 10, 0, "abcdefghijklmnopqrst", 1, 19, -19);
+ test("abcdefghijklmnopqrst", 10, 0, "abcdefghijklmnopqrst", 1, 20, -19);
+ test("abcdefghijklmnopqrst", 10, 0, "abcdefghijklmnopqrst", 10, 0, 0);
+ test("abcdefghijklmnopqrst", 10, 0, "abcdefghijklmnopqrst", 10, 1, -1);
+ test("abcdefghijklmnopqrst", 10, 0, "abcdefghijklmnopqrst", 10, 5, -5);
+ test("abcdefghijklmnopqrst", 10, 0, "abcdefghijklmnopqrst", 10, 9, -9);
+ test("abcdefghijklmnopqrst", 10, 0, "abcdefghijklmnopqrst", 10, 10, -10);
+ test("abcdefghijklmnopqrst", 10, 0, "abcdefghijklmnopqrst", 10, 11, -10);
+ test("abcdefghijklmnopqrst", 10, 0, "abcdefghijklmnopqrst", 19, 0, 0);
+ test("abcdefghijklmnopqrst", 10, 0, "abcdefghijklmnopqrst", 19, 1, -1);
+ test("abcdefghijklmnopqrst", 10, 0, "abcdefghijklmnopqrst", 19, 2, -1);
+ test("abcdefghijklmnopqrst", 10, 0, "abcdefghijklmnopqrst", 20, 0, 0);
+ test("abcdefghijklmnopqrst", 10, 0, "abcdefghijklmnopqrst", 20, 1, 0);
+ test("abcdefghijklmnopqrst", 10, 0, "abcdefghijklmnopqrst", 21, 0, 0);
+ test("abcdefghijklmnopqrst", 10, 1, "", 0, 0, 1);
+ test("abcdefghijklmnopqrst", 10, 1, "", 0, 1, 1);
+ test("abcdefghijklmnopqrst", 10, 1, "", 1, 0, 0);
+ test("abcdefghijklmnopqrst", 10, 1, "abcde", 0, 0, 1);
+ test("abcdefghijklmnopqrst", 10, 1, "abcde", 0, 1, 10);
+ test("abcdefghijklmnopqrst", 10, 1, "abcde", 0, 2, 10);
+ test("abcdefghijklmnopqrst", 10, 1, "abcde", 0, 4, 10);
+ test("abcdefghijklmnopqrst", 10, 1, "abcde", 0, 5, 10);
+ test("abcdefghijklmnopqrst", 10, 1, "abcde", 0, 6, 10);
+ test("abcdefghijklmnopqrst", 10, 1, "abcde", 1, 0, 1);
+ test("abcdefghijklmnopqrst", 10, 1, "abcde", 1, 1, 9);
+ test("abcdefghijklmnopqrst", 10, 1, "abcde", 1, 2, 9);
+ test("abcdefghijklmnopqrst", 10, 1, "abcde", 1, 3, 9);
+ test("abcdefghijklmnopqrst", 10, 1, "abcde", 1, 4, 9);
+ test("abcdefghijklmnopqrst", 10, 1, "abcde", 1, 5, 9);
+ test("abcdefghijklmnopqrst", 10, 1, "abcde", 2, 0, 1);
+ test("abcdefghijklmnopqrst", 10, 1, "abcde", 2, 1, 8);
+ test("abcdefghijklmnopqrst", 10, 1, "abcde", 2, 2, 8);
+ test("abcdefghijklmnopqrst", 10, 1, "abcde", 2, 3, 8);
+ test("abcdefghijklmnopqrst", 10, 1, "abcde", 2, 4, 8);
+ test("abcdefghijklmnopqrst", 10, 1, "abcde", 4, 0, 1);
+ test("abcdefghijklmnopqrst", 10, 1, "abcde", 4, 1, 6);
+ test("abcdefghijklmnopqrst", 10, 1, "abcde", 4, 2, 6);
+ test("abcdefghijklmnopqrst", 10, 1, "abcde", 5, 0, 1);
+ test("abcdefghijklmnopqrst", 10, 1, "abcde", 5, 1, 1);
+ test("abcdefghijklmnopqrst", 10, 1, "abcde", 6, 0, 0);
+ test("abcdefghijklmnopqrst", 10, 1, "abcdefghij", 0, 0, 1);
+ test("abcdefghijklmnopqrst", 10, 1, "abcdefghij", 0, 1, 10);
+ test("abcdefghijklmnopqrst", 10, 1, "abcdefghij", 0, 5, 10);
+ test("abcdefghijklmnopqrst", 10, 1, "abcdefghij", 0, 9, 10);
+ test("abcdefghijklmnopqrst", 10, 1, "abcdefghij", 0, 10, 10);
+ test("abcdefghijklmnopqrst", 10, 1, "abcdefghij", 0, 11, 10);
+ test("abcdefghijklmnopqrst", 10, 1, "abcdefghij", 1, 0, 1);
+ test("abcdefghijklmnopqrst", 10, 1, "abcdefghij", 1, 1, 9);
+ test("abcdefghijklmnopqrst", 10, 1, "abcdefghij", 1, 4, 9);
+ test("abcdefghijklmnopqrst", 10, 1, "abcdefghij", 1, 8, 9);
+ test("abcdefghijklmnopqrst", 10, 1, "abcdefghij", 1, 9, 9);
+ test("abcdefghijklmnopqrst", 10, 1, "abcdefghij", 1, 10, 9);
+}
+
+void test47()
+{
+ test("abcdefghijklmnopqrst", 10, 1, "abcdefghij", 5, 0, 1);
+ test("abcdefghijklmnopqrst", 10, 1, "abcdefghij", 5, 1, 5);
+ test("abcdefghijklmnopqrst", 10, 1, "abcdefghij", 5, 2, 5);
+ test("abcdefghijklmnopqrst", 10, 1, "abcdefghij", 5, 4, 5);
+ test("abcdefghijklmnopqrst", 10, 1, "abcdefghij", 5, 5, 5);
+ test("abcdefghijklmnopqrst", 10, 1, "abcdefghij", 5, 6, 5);
+ test("abcdefghijklmnopqrst", 10, 1, "abcdefghij", 9, 0, 1);
+ test("abcdefghijklmnopqrst", 10, 1, "abcdefghij", 9, 1, 1);
+ test("abcdefghijklmnopqrst", 10, 1, "abcdefghij", 9, 2, 1);
+ test("abcdefghijklmnopqrst", 10, 1, "abcdefghij", 10, 0, 1);
+ test("abcdefghijklmnopqrst", 10, 1, "abcdefghij", 10, 1, 1);
+ test("abcdefghijklmnopqrst", 10, 1, "abcdefghij", 11, 0, 0);
+ test("abcdefghijklmnopqrst", 10, 1, "abcdefghijklmnopqrst", 0, 0, 1);
+ test("abcdefghijklmnopqrst", 10, 1, "abcdefghijklmnopqrst", 0, 1, 10);
+ test("abcdefghijklmnopqrst", 10, 1, "abcdefghijklmnopqrst", 0, 10, 10);
+ test("abcdefghijklmnopqrst", 10, 1, "abcdefghijklmnopqrst", 0, 19, 10);
+ test("abcdefghijklmnopqrst", 10, 1, "abcdefghijklmnopqrst", 0, 20, 10);
+ test("abcdefghijklmnopqrst", 10, 1, "abcdefghijklmnopqrst", 0, 21, 10);
+ test("abcdefghijklmnopqrst", 10, 1, "abcdefghijklmnopqrst", 1, 0, 1);
+ test("abcdefghijklmnopqrst", 10, 1, "abcdefghijklmnopqrst", 1, 1, 9);
+ test("abcdefghijklmnopqrst", 10, 1, "abcdefghijklmnopqrst", 1, 9, 9);
+ test("abcdefghijklmnopqrst", 10, 1, "abcdefghijklmnopqrst", 1, 18, 9);
+ test("abcdefghijklmnopqrst", 10, 1, "abcdefghijklmnopqrst", 1, 19, 9);
+ test("abcdefghijklmnopqrst", 10, 1, "abcdefghijklmnopqrst", 1, 20, 9);
+ test("abcdefghijklmnopqrst", 10, 1, "abcdefghijklmnopqrst", 10, 0, 1);
+ test("abcdefghijklmnopqrst", 10, 1, "abcdefghijklmnopqrst", 10, 1, 0);
+ test("abcdefghijklmnopqrst", 10, 1, "abcdefghijklmnopqrst", 10, 5, -4);
+ test("abcdefghijklmnopqrst", 10, 1, "abcdefghijklmnopqrst", 10, 9, -8);
+ test("abcdefghijklmnopqrst", 10, 1, "abcdefghijklmnopqrst", 10, 10, -9);
+ test("abcdefghijklmnopqrst", 10, 1, "abcdefghijklmnopqrst", 10, 11, -9);
+ test("abcdefghijklmnopqrst", 10, 1, "abcdefghijklmnopqrst", 19, 0, 1);
+ test("abcdefghijklmnopqrst", 10, 1, "abcdefghijklmnopqrst", 19, 1, -9);
+ test("abcdefghijklmnopqrst", 10, 1, "abcdefghijklmnopqrst", 19, 2, -9);
+ test("abcdefghijklmnopqrst", 10, 1, "abcdefghijklmnopqrst", 20, 0, 1);
+ test("abcdefghijklmnopqrst", 10, 1, "abcdefghijklmnopqrst", 20, 1, 1);
+ test("abcdefghijklmnopqrst", 10, 1, "abcdefghijklmnopqrst", 21, 0, 0);
+ test("abcdefghijklmnopqrst", 10, 5, "", 0, 0, 5);
+ test("abcdefghijklmnopqrst", 10, 5, "", 0, 1, 5);
+ test("abcdefghijklmnopqrst", 10, 5, "", 1, 0, 0);
+ test("abcdefghijklmnopqrst", 10, 5, "abcde", 0, 0, 5);
+ test("abcdefghijklmnopqrst", 10, 5, "abcde", 0, 1, 10);
+ test("abcdefghijklmnopqrst", 10, 5, "abcde", 0, 2, 10);
+ test("abcdefghijklmnopqrst", 10, 5, "abcde", 0, 4, 10);
+ test("abcdefghijklmnopqrst", 10, 5, "abcde", 0, 5, 10);
+ test("abcdefghijklmnopqrst", 10, 5, "abcde", 0, 6, 10);
+ test("abcdefghijklmnopqrst", 10, 5, "abcde", 1, 0, 5);
+ test("abcdefghijklmnopqrst", 10, 5, "abcde", 1, 1, 9);
+ test("abcdefghijklmnopqrst", 10, 5, "abcde", 1, 2, 9);
+ test("abcdefghijklmnopqrst", 10, 5, "abcde", 1, 3, 9);
+ test("abcdefghijklmnopqrst", 10, 5, "abcde", 1, 4, 9);
+ test("abcdefghijklmnopqrst", 10, 5, "abcde", 1, 5, 9);
+ test("abcdefghijklmnopqrst", 10, 5, "abcde", 2, 0, 5);
+ test("abcdefghijklmnopqrst", 10, 5, "abcde", 2, 1, 8);
+ test("abcdefghijklmnopqrst", 10, 5, "abcde", 2, 2, 8);
+ test("abcdefghijklmnopqrst", 10, 5, "abcde", 2, 3, 8);
+ test("abcdefghijklmnopqrst", 10, 5, "abcde", 2, 4, 8);
+ test("abcdefghijklmnopqrst", 10, 5, "abcde", 4, 0, 5);
+ test("abcdefghijklmnopqrst", 10, 5, "abcde", 4, 1, 6);
+ test("abcdefghijklmnopqrst", 10, 5, "abcde", 4, 2, 6);
+ test("abcdefghijklmnopqrst", 10, 5, "abcde", 5, 0, 5);
+ test("abcdefghijklmnopqrst", 10, 5, "abcde", 5, 1, 5);
+ test("abcdefghijklmnopqrst", 10, 5, "abcde", 6, 0, 0);
+ test("abcdefghijklmnopqrst", 10, 5, "abcdefghij", 0, 0, 5);
+ test("abcdefghijklmnopqrst", 10, 5, "abcdefghij", 0, 1, 10);
+ test("abcdefghijklmnopqrst", 10, 5, "abcdefghij", 0, 5, 10);
+ test("abcdefghijklmnopqrst", 10, 5, "abcdefghij", 0, 9, 10);
+ test("abcdefghijklmnopqrst", 10, 5, "abcdefghij", 0, 10, 10);
+ test("abcdefghijklmnopqrst", 10, 5, "abcdefghij", 0, 11, 10);
+ test("abcdefghijklmnopqrst", 10, 5, "abcdefghij", 1, 0, 5);
+ test("abcdefghijklmnopqrst", 10, 5, "abcdefghij", 1, 1, 9);
+ test("abcdefghijklmnopqrst", 10, 5, "abcdefghij", 1, 4, 9);
+ test("abcdefghijklmnopqrst", 10, 5, "abcdefghij", 1, 8, 9);
+ test("abcdefghijklmnopqrst", 10, 5, "abcdefghij", 1, 9, 9);
+ test("abcdefghijklmnopqrst", 10, 5, "abcdefghij", 1, 10, 9);
+ test("abcdefghijklmnopqrst", 10, 5, "abcdefghij", 5, 0, 5);
+ test("abcdefghijklmnopqrst", 10, 5, "abcdefghij", 5, 1, 5);
+ test("abcdefghijklmnopqrst", 10, 5, "abcdefghij", 5, 2, 5);
+ test("abcdefghijklmnopqrst", 10, 5, "abcdefghij", 5, 4, 5);
+ test("abcdefghijklmnopqrst", 10, 5, "abcdefghij", 5, 5, 5);
+ test("abcdefghijklmnopqrst", 10, 5, "abcdefghij", 5, 6, 5);
+ test("abcdefghijklmnopqrst", 10, 5, "abcdefghij", 9, 0, 5);
+ test("abcdefghijklmnopqrst", 10, 5, "abcdefghij", 9, 1, 1);
+ test("abcdefghijklmnopqrst", 10, 5, "abcdefghij", 9, 2, 1);
+ test("abcdefghijklmnopqrst", 10, 5, "abcdefghij", 10, 0, 5);
+ test("abcdefghijklmnopqrst", 10, 5, "abcdefghij", 10, 1, 5);
+ test("abcdefghijklmnopqrst", 10, 5, "abcdefghij", 11, 0, 0);
+ test("abcdefghijklmnopqrst", 10, 5, "abcdefghijklmnopqrst", 0, 0, 5);
+ test("abcdefghijklmnopqrst", 10, 5, "abcdefghijklmnopqrst", 0, 1, 10);
+ test("abcdefghijklmnopqrst", 10, 5, "abcdefghijklmnopqrst", 0, 10, 10);
+ test("abcdefghijklmnopqrst", 10, 5, "abcdefghijklmnopqrst", 0, 19, 10);
+ test("abcdefghijklmnopqrst", 10, 5, "abcdefghijklmnopqrst", 0, 20, 10);
+ test("abcdefghijklmnopqrst", 10, 5, "abcdefghijklmnopqrst", 0, 21, 10);
+ test("abcdefghijklmnopqrst", 10, 5, "abcdefghijklmnopqrst", 1, 0, 5);
+ test("abcdefghijklmnopqrst", 10, 5, "abcdefghijklmnopqrst", 1, 1, 9);
+ test("abcdefghijklmnopqrst", 10, 5, "abcdefghijklmnopqrst", 1, 9, 9);
+ test("abcdefghijklmnopqrst", 10, 5, "abcdefghijklmnopqrst", 1, 18, 9);
+ test("abcdefghijklmnopqrst", 10, 5, "abcdefghijklmnopqrst", 1, 19, 9);
+ test("abcdefghijklmnopqrst", 10, 5, "abcdefghijklmnopqrst", 1, 20, 9);
+ test("abcdefghijklmnopqrst", 10, 5, "abcdefghijklmnopqrst", 10, 0, 5);
+ test("abcdefghijklmnopqrst", 10, 5, "abcdefghijklmnopqrst", 10, 1, 4);
+}
+
+void test48()
+{
+ test("abcdefghijklmnopqrst", 10, 5, "abcdefghijklmnopqrst", 10, 5, 0);
+ test("abcdefghijklmnopqrst", 10, 5, "abcdefghijklmnopqrst", 10, 9, -4);
+ test("abcdefghijklmnopqrst", 10, 5, "abcdefghijklmnopqrst", 10, 10, -5);
+ test("abcdefghijklmnopqrst", 10, 5, "abcdefghijklmnopqrst", 10, 11, -5);
+ test("abcdefghijklmnopqrst", 10, 5, "abcdefghijklmnopqrst", 19, 0, 5);
+ test("abcdefghijklmnopqrst", 10, 5, "abcdefghijklmnopqrst", 19, 1, -9);
+ test("abcdefghijklmnopqrst", 10, 5, "abcdefghijklmnopqrst", 19, 2, -9);
+ test("abcdefghijklmnopqrst", 10, 5, "abcdefghijklmnopqrst", 20, 0, 5);
+ test("abcdefghijklmnopqrst", 10, 5, "abcdefghijklmnopqrst", 20, 1, 5);
+ test("abcdefghijklmnopqrst", 10, 5, "abcdefghijklmnopqrst", 21, 0, 0);
+ test("abcdefghijklmnopqrst", 10, 9, "", 0, 0, 9);
+ test("abcdefghijklmnopqrst", 10, 9, "", 0, 1, 9);
+ test("abcdefghijklmnopqrst", 10, 9, "", 1, 0, 0);
+ test("abcdefghijklmnopqrst", 10, 9, "abcde", 0, 0, 9);
+ test("abcdefghijklmnopqrst", 10, 9, "abcde", 0, 1, 10);
+ test("abcdefghijklmnopqrst", 10, 9, "abcde", 0, 2, 10);
+ test("abcdefghijklmnopqrst", 10, 9, "abcde", 0, 4, 10);
+ test("abcdefghijklmnopqrst", 10, 9, "abcde", 0, 5, 10);
+ test("abcdefghijklmnopqrst", 10, 9, "abcde", 0, 6, 10);
+ test("abcdefghijklmnopqrst", 10, 9, "abcde", 1, 0, 9);
+ test("abcdefghijklmnopqrst", 10, 9, "abcde", 1, 1, 9);
+ test("abcdefghijklmnopqrst", 10, 9, "abcde", 1, 2, 9);
+ test("abcdefghijklmnopqrst", 10, 9, "abcde", 1, 3, 9);
+ test("abcdefghijklmnopqrst", 10, 9, "abcde", 1, 4, 9);
+ test("abcdefghijklmnopqrst", 10, 9, "abcde", 1, 5, 9);
+ test("abcdefghijklmnopqrst", 10, 9, "abcde", 2, 0, 9);
+ test("abcdefghijklmnopqrst", 10, 9, "abcde", 2, 1, 8);
+ test("abcdefghijklmnopqrst", 10, 9, "abcde", 2, 2, 8);
+ test("abcdefghijklmnopqrst", 10, 9, "abcde", 2, 3, 8);
+ test("abcdefghijklmnopqrst", 10, 9, "abcde", 2, 4, 8);
+ test("abcdefghijklmnopqrst", 10, 9, "abcde", 4, 0, 9);
+ test("abcdefghijklmnopqrst", 10, 9, "abcde", 4, 1, 6);
+ test("abcdefghijklmnopqrst", 10, 9, "abcde", 4, 2, 6);
+ test("abcdefghijklmnopqrst", 10, 9, "abcde", 5, 0, 9);
+ test("abcdefghijklmnopqrst", 10, 9, "abcde", 5, 1, 9);
+ test("abcdefghijklmnopqrst", 10, 9, "abcde", 6, 0, 0);
+ test("abcdefghijklmnopqrst", 10, 9, "abcdefghij", 0, 0, 9);
+ test("abcdefghijklmnopqrst", 10, 9, "abcdefghij", 0, 1, 10);
+ test("abcdefghijklmnopqrst", 10, 9, "abcdefghij", 0, 5, 10);
+ test("abcdefghijklmnopqrst", 10, 9, "abcdefghij", 0, 9, 10);
+ test("abcdefghijklmnopqrst", 10, 9, "abcdefghij", 0, 10, 10);
+ test("abcdefghijklmnopqrst", 10, 9, "abcdefghij", 0, 11, 10);
+ test("abcdefghijklmnopqrst", 10, 9, "abcdefghij", 1, 0, 9);
+ test("abcdefghijklmnopqrst", 10, 9, "abcdefghij", 1, 1, 9);
+ test("abcdefghijklmnopqrst", 10, 9, "abcdefghij", 1, 4, 9);
+ test("abcdefghijklmnopqrst", 10, 9, "abcdefghij", 1, 8, 9);
+ test("abcdefghijklmnopqrst", 10, 9, "abcdefghij", 1, 9, 9);
+ test("abcdefghijklmnopqrst", 10, 9, "abcdefghij", 1, 10, 9);
+ test("abcdefghijklmnopqrst", 10, 9, "abcdefghij", 5, 0, 9);
+ test("abcdefghijklmnopqrst", 10, 9, "abcdefghij", 5, 1, 5);
+ test("abcdefghijklmnopqrst", 10, 9, "abcdefghij", 5, 2, 5);
+ test("abcdefghijklmnopqrst", 10, 9, "abcdefghij", 5, 4, 5);
+ test("abcdefghijklmnopqrst", 10, 9, "abcdefghij", 5, 5, 5);
+ test("abcdefghijklmnopqrst", 10, 9, "abcdefghij", 5, 6, 5);
+ test("abcdefghijklmnopqrst", 10, 9, "abcdefghij", 9, 0, 9);
+ test("abcdefghijklmnopqrst", 10, 9, "abcdefghij", 9, 1, 1);
+ test("abcdefghijklmnopqrst", 10, 9, "abcdefghij", 9, 2, 1);
+ test("abcdefghijklmnopqrst", 10, 9, "abcdefghij", 10, 0, 9);
+ test("abcdefghijklmnopqrst", 10, 9, "abcdefghij", 10, 1, 9);
+ test("abcdefghijklmnopqrst", 10, 9, "abcdefghij", 11, 0, 0);
+ test("abcdefghijklmnopqrst", 10, 9, "abcdefghijklmnopqrst", 0, 0, 9);
+ test("abcdefghijklmnopqrst", 10, 9, "abcdefghijklmnopqrst", 0, 1, 10);
+ test("abcdefghijklmnopqrst", 10, 9, "abcdefghijklmnopqrst", 0, 10, 10);
+ test("abcdefghijklmnopqrst", 10, 9, "abcdefghijklmnopqrst", 0, 19, 10);
+ test("abcdefghijklmnopqrst", 10, 9, "abcdefghijklmnopqrst", 0, 20, 10);
+ test("abcdefghijklmnopqrst", 10, 9, "abcdefghijklmnopqrst", 0, 21, 10);
+ test("abcdefghijklmnopqrst", 10, 9, "abcdefghijklmnopqrst", 1, 0, 9);
+ test("abcdefghijklmnopqrst", 10, 9, "abcdefghijklmnopqrst", 1, 1, 9);
+ test("abcdefghijklmnopqrst", 10, 9, "abcdefghijklmnopqrst", 1, 9, 9);
+ test("abcdefghijklmnopqrst", 10, 9, "abcdefghijklmnopqrst", 1, 18, 9);
+ test("abcdefghijklmnopqrst", 10, 9, "abcdefghijklmnopqrst", 1, 19, 9);
+ test("abcdefghijklmnopqrst", 10, 9, "abcdefghijklmnopqrst", 1, 20, 9);
+ test("abcdefghijklmnopqrst", 10, 9, "abcdefghijklmnopqrst", 10, 0, 9);
+ test("abcdefghijklmnopqrst", 10, 9, "abcdefghijklmnopqrst", 10, 1, 8);
+ test("abcdefghijklmnopqrst", 10, 9, "abcdefghijklmnopqrst", 10, 5, 4);
+ test("abcdefghijklmnopqrst", 10, 9, "abcdefghijklmnopqrst", 10, 9, 0);
+ test("abcdefghijklmnopqrst", 10, 9, "abcdefghijklmnopqrst", 10, 10, -1);
+ test("abcdefghijklmnopqrst", 10, 9, "abcdefghijklmnopqrst", 10, 11, -1);
+ test("abcdefghijklmnopqrst", 10, 9, "abcdefghijklmnopqrst", 19, 0, 9);
+ test("abcdefghijklmnopqrst", 10, 9, "abcdefghijklmnopqrst", 19, 1, -9);
+ test("abcdefghijklmnopqrst", 10, 9, "abcdefghijklmnopqrst", 19, 2, -9);
+ test("abcdefghijklmnopqrst", 10, 9, "abcdefghijklmnopqrst", 20, 0, 9);
+ test("abcdefghijklmnopqrst", 10, 9, "abcdefghijklmnopqrst", 20, 1, 9);
+ test("abcdefghijklmnopqrst", 10, 9, "abcdefghijklmnopqrst", 21, 0, 0);
+ test("abcdefghijklmnopqrst", 10, 10, "", 0, 0, 10);
+ test("abcdefghijklmnopqrst", 10, 10, "", 0, 1, 10);
+ test("abcdefghijklmnopqrst", 10, 10, "", 1, 0, 0);
+ test("abcdefghijklmnopqrst", 10, 10, "abcde", 0, 0, 10);
+ test("abcdefghijklmnopqrst", 10, 10, "abcde", 0, 1, 10);
+ test("abcdefghijklmnopqrst", 10, 10, "abcde", 0, 2, 10);
+ test("abcdefghijklmnopqrst", 10, 10, "abcde", 0, 4, 10);
+ test("abcdefghijklmnopqrst", 10, 10, "abcde", 0, 5, 10);
+ test("abcdefghijklmnopqrst", 10, 10, "abcde", 0, 6, 10);
+ test("abcdefghijklmnopqrst", 10, 10, "abcde", 1, 0, 10);
+ test("abcdefghijklmnopqrst", 10, 10, "abcde", 1, 1, 9);
+ test("abcdefghijklmnopqrst", 10, 10, "abcde", 1, 2, 9);
+ test("abcdefghijklmnopqrst", 10, 10, "abcde", 1, 3, 9);
+ test("abcdefghijklmnopqrst", 10, 10, "abcde", 1, 4, 9);
+ test("abcdefghijklmnopqrst", 10, 10, "abcde", 1, 5, 9);
+ test("abcdefghijklmnopqrst", 10, 10, "abcde", 2, 0, 10);
+}
+
+void test49()
+{
+ test("abcdefghijklmnopqrst", 10, 10, "abcde", 2, 1, 8);
+ test("abcdefghijklmnopqrst", 10, 10, "abcde", 2, 2, 8);
+ test("abcdefghijklmnopqrst", 10, 10, "abcde", 2, 3, 8);
+ test("abcdefghijklmnopqrst", 10, 10, "abcde", 2, 4, 8);
+ test("abcdefghijklmnopqrst", 10, 10, "abcde", 4, 0, 10);
+ test("abcdefghijklmnopqrst", 10, 10, "abcde", 4, 1, 6);
+ test("abcdefghijklmnopqrst", 10, 10, "abcde", 4, 2, 6);
+ test("abcdefghijklmnopqrst", 10, 10, "abcde", 5, 0, 10);
+ test("abcdefghijklmnopqrst", 10, 10, "abcde", 5, 1, 10);
+ test("abcdefghijklmnopqrst", 10, 10, "abcde", 6, 0, 0);
+ test("abcdefghijklmnopqrst", 10, 10, "abcdefghij", 0, 0, 10);
+ test("abcdefghijklmnopqrst", 10, 10, "abcdefghij", 0, 1, 10);
+ test("abcdefghijklmnopqrst", 10, 10, "abcdefghij", 0, 5, 10);
+ test("abcdefghijklmnopqrst", 10, 10, "abcdefghij", 0, 9, 10);
+ test("abcdefghijklmnopqrst", 10, 10, "abcdefghij", 0, 10, 10);
+ test("abcdefghijklmnopqrst", 10, 10, "abcdefghij", 0, 11, 10);
+ test("abcdefghijklmnopqrst", 10, 10, "abcdefghij", 1, 0, 10);
+ test("abcdefghijklmnopqrst", 10, 10, "abcdefghij", 1, 1, 9);
+ test("abcdefghijklmnopqrst", 10, 10, "abcdefghij", 1, 4, 9);
+ test("abcdefghijklmnopqrst", 10, 10, "abcdefghij", 1, 8, 9);
+ test("abcdefghijklmnopqrst", 10, 10, "abcdefghij", 1, 9, 9);
+ test("abcdefghijklmnopqrst", 10, 10, "abcdefghij", 1, 10, 9);
+ test("abcdefghijklmnopqrst", 10, 10, "abcdefghij", 5, 0, 10);
+ test("abcdefghijklmnopqrst", 10, 10, "abcdefghij", 5, 1, 5);
+ test("abcdefghijklmnopqrst", 10, 10, "abcdefghij", 5, 2, 5);
+ test("abcdefghijklmnopqrst", 10, 10, "abcdefghij", 5, 4, 5);
+ test("abcdefghijklmnopqrst", 10, 10, "abcdefghij", 5, 5, 5);
+ test("abcdefghijklmnopqrst", 10, 10, "abcdefghij", 5, 6, 5);
+ test("abcdefghijklmnopqrst", 10, 10, "abcdefghij", 9, 0, 10);
+ test("abcdefghijklmnopqrst", 10, 10, "abcdefghij", 9, 1, 1);
+ test("abcdefghijklmnopqrst", 10, 10, "abcdefghij", 9, 2, 1);
+ test("abcdefghijklmnopqrst", 10, 10, "abcdefghij", 10, 0, 10);
+ test("abcdefghijklmnopqrst", 10, 10, "abcdefghij", 10, 1, 10);
+ test("abcdefghijklmnopqrst", 10, 10, "abcdefghij", 11, 0, 0);
+ test("abcdefghijklmnopqrst", 10, 10, "abcdefghijklmnopqrst", 0, 0, 10);
+ test("abcdefghijklmnopqrst", 10, 10, "abcdefghijklmnopqrst", 0, 1, 10);
+ test("abcdefghijklmnopqrst", 10, 10, "abcdefghijklmnopqrst", 0, 10, 10);
+ test("abcdefghijklmnopqrst", 10, 10, "abcdefghijklmnopqrst", 0, 19, 10);
+ test("abcdefghijklmnopqrst", 10, 10, "abcdefghijklmnopqrst", 0, 20, 10);
+ test("abcdefghijklmnopqrst", 10, 10, "abcdefghijklmnopqrst", 0, 21, 10);
+ test("abcdefghijklmnopqrst", 10, 10, "abcdefghijklmnopqrst", 1, 0, 10);
+ test("abcdefghijklmnopqrst", 10, 10, "abcdefghijklmnopqrst", 1, 1, 9);
+ test("abcdefghijklmnopqrst", 10, 10, "abcdefghijklmnopqrst", 1, 9, 9);
+ test("abcdefghijklmnopqrst", 10, 10, "abcdefghijklmnopqrst", 1, 18, 9);
+ test("abcdefghijklmnopqrst", 10, 10, "abcdefghijklmnopqrst", 1, 19, 9);
+ test("abcdefghijklmnopqrst", 10, 10, "abcdefghijklmnopqrst", 1, 20, 9);
+ test("abcdefghijklmnopqrst", 10, 10, "abcdefghijklmnopqrst", 10, 0, 10);
+ test("abcdefghijklmnopqrst", 10, 10, "abcdefghijklmnopqrst", 10, 1, 9);
+ test("abcdefghijklmnopqrst", 10, 10, "abcdefghijklmnopqrst", 10, 5, 5);
+ test("abcdefghijklmnopqrst", 10, 10, "abcdefghijklmnopqrst", 10, 9, 1);
+ test("abcdefghijklmnopqrst", 10, 10, "abcdefghijklmnopqrst", 10, 10, 0);
+ test("abcdefghijklmnopqrst", 10, 10, "abcdefghijklmnopqrst", 10, 11, 0);
+ test("abcdefghijklmnopqrst", 10, 10, "abcdefghijklmnopqrst", 19, 0, 10);
+ test("abcdefghijklmnopqrst", 10, 10, "abcdefghijklmnopqrst", 19, 1, -9);
+ test("abcdefghijklmnopqrst", 10, 10, "abcdefghijklmnopqrst", 19, 2, -9);
+ test("abcdefghijklmnopqrst", 10, 10, "abcdefghijklmnopqrst", 20, 0, 10);
+ test("abcdefghijklmnopqrst", 10, 10, "abcdefghijklmnopqrst", 20, 1, 10);
+ test("abcdefghijklmnopqrst", 10, 10, "abcdefghijklmnopqrst", 21, 0, 0);
+ test("abcdefghijklmnopqrst", 10, 11, "", 0, 0, 10);
+ test("abcdefghijklmnopqrst", 10, 11, "", 0, 1, 10);
+ test("abcdefghijklmnopqrst", 10, 11, "", 1, 0, 0);
+ test("abcdefghijklmnopqrst", 10, 11, "abcde", 0, 0, 10);
+ test("abcdefghijklmnopqrst", 10, 11, "abcde", 0, 1, 10);
+ test("abcdefghijklmnopqrst", 10, 11, "abcde", 0, 2, 10);
+ test("abcdefghijklmnopqrst", 10, 11, "abcde", 0, 4, 10);
+ test("abcdefghijklmnopqrst", 10, 11, "abcde", 0, 5, 10);
+ test("abcdefghijklmnopqrst", 10, 11, "abcde", 0, 6, 10);
+ test("abcdefghijklmnopqrst", 10, 11, "abcde", 1, 0, 10);
+ test("abcdefghijklmnopqrst", 10, 11, "abcde", 1, 1, 9);
+ test("abcdefghijklmnopqrst", 10, 11, "abcde", 1, 2, 9);
+ test("abcdefghijklmnopqrst", 10, 11, "abcde", 1, 3, 9);
+ test("abcdefghijklmnopqrst", 10, 11, "abcde", 1, 4, 9);
+ test("abcdefghijklmnopqrst", 10, 11, "abcde", 1, 5, 9);
+ test("abcdefghijklmnopqrst", 10, 11, "abcde", 2, 0, 10);
+ test("abcdefghijklmnopqrst", 10, 11, "abcde", 2, 1, 8);
+ test("abcdefghijklmnopqrst", 10, 11, "abcde", 2, 2, 8);
+ test("abcdefghijklmnopqrst", 10, 11, "abcde", 2, 3, 8);
+ test("abcdefghijklmnopqrst", 10, 11, "abcde", 2, 4, 8);
+ test("abcdefghijklmnopqrst", 10, 11, "abcde", 4, 0, 10);
+ test("abcdefghijklmnopqrst", 10, 11, "abcde", 4, 1, 6);
+ test("abcdefghijklmnopqrst", 10, 11, "abcde", 4, 2, 6);
+ test("abcdefghijklmnopqrst", 10, 11, "abcde", 5, 0, 10);
+ test("abcdefghijklmnopqrst", 10, 11, "abcde", 5, 1, 10);
+ test("abcdefghijklmnopqrst", 10, 11, "abcde", 6, 0, 0);
+ test("abcdefghijklmnopqrst", 10, 11, "abcdefghij", 0, 0, 10);
+ test("abcdefghijklmnopqrst", 10, 11, "abcdefghij", 0, 1, 10);
+ test("abcdefghijklmnopqrst", 10, 11, "abcdefghij", 0, 5, 10);
+ test("abcdefghijklmnopqrst", 10, 11, "abcdefghij", 0, 9, 10);
+ test("abcdefghijklmnopqrst", 10, 11, "abcdefghij", 0, 10, 10);
+ test("abcdefghijklmnopqrst", 10, 11, "abcdefghij", 0, 11, 10);
+ test("abcdefghijklmnopqrst", 10, 11, "abcdefghij", 1, 0, 10);
+ test("abcdefghijklmnopqrst", 10, 11, "abcdefghij", 1, 1, 9);
+ test("abcdefghijklmnopqrst", 10, 11, "abcdefghij", 1, 4, 9);
+ test("abcdefghijklmnopqrst", 10, 11, "abcdefghij", 1, 8, 9);
+ test("abcdefghijklmnopqrst", 10, 11, "abcdefghij", 1, 9, 9);
+ test("abcdefghijklmnopqrst", 10, 11, "abcdefghij", 1, 10, 9);
+ test("abcdefghijklmnopqrst", 10, 11, "abcdefghij", 5, 0, 10);
+ test("abcdefghijklmnopqrst", 10, 11, "abcdefghij", 5, 1, 5);
+ test("abcdefghijklmnopqrst", 10, 11, "abcdefghij", 5, 2, 5);
+ test("abcdefghijklmnopqrst", 10, 11, "abcdefghij", 5, 4, 5);
+}
+
+void test50()
+{
+ test("abcdefghijklmnopqrst", 10, 11, "abcdefghij", 5, 5, 5);
+ test("abcdefghijklmnopqrst", 10, 11, "abcdefghij", 5, 6, 5);
+ test("abcdefghijklmnopqrst", 10, 11, "abcdefghij", 9, 0, 10);
+ test("abcdefghijklmnopqrst", 10, 11, "abcdefghij", 9, 1, 1);
+ test("abcdefghijklmnopqrst", 10, 11, "abcdefghij", 9, 2, 1);
+ test("abcdefghijklmnopqrst", 10, 11, "abcdefghij", 10, 0, 10);
+ test("abcdefghijklmnopqrst", 10, 11, "abcdefghij", 10, 1, 10);
+ test("abcdefghijklmnopqrst", 10, 11, "abcdefghij", 11, 0, 0);
+ test("abcdefghijklmnopqrst", 10, 11, "abcdefghijklmnopqrst", 0, 0, 10);
+ test("abcdefghijklmnopqrst", 10, 11, "abcdefghijklmnopqrst", 0, 1, 10);
+ test("abcdefghijklmnopqrst", 10, 11, "abcdefghijklmnopqrst", 0, 10, 10);
+ test("abcdefghijklmnopqrst", 10, 11, "abcdefghijklmnopqrst", 0, 19, 10);
+ test("abcdefghijklmnopqrst", 10, 11, "abcdefghijklmnopqrst", 0, 20, 10);
+ test("abcdefghijklmnopqrst", 10, 11, "abcdefghijklmnopqrst", 0, 21, 10);
+ test("abcdefghijklmnopqrst", 10, 11, "abcdefghijklmnopqrst", 1, 0, 10);
+ test("abcdefghijklmnopqrst", 10, 11, "abcdefghijklmnopqrst", 1, 1, 9);
+ test("abcdefghijklmnopqrst", 10, 11, "abcdefghijklmnopqrst", 1, 9, 9);
+ test("abcdefghijklmnopqrst", 10, 11, "abcdefghijklmnopqrst", 1, 18, 9);
+ test("abcdefghijklmnopqrst", 10, 11, "abcdefghijklmnopqrst", 1, 19, 9);
+ test("abcdefghijklmnopqrst", 10, 11, "abcdefghijklmnopqrst", 1, 20, 9);
+ test("abcdefghijklmnopqrst", 10, 11, "abcdefghijklmnopqrst", 10, 0, 10);
+ test("abcdefghijklmnopqrst", 10, 11, "abcdefghijklmnopqrst", 10, 1, 9);
+ test("abcdefghijklmnopqrst", 10, 11, "abcdefghijklmnopqrst", 10, 5, 5);
+ test("abcdefghijklmnopqrst", 10, 11, "abcdefghijklmnopqrst", 10, 9, 1);
+ test("abcdefghijklmnopqrst", 10, 11, "abcdefghijklmnopqrst", 10, 10, 0);
+ test("abcdefghijklmnopqrst", 10, 11, "abcdefghijklmnopqrst", 10, 11, 0);
+ test("abcdefghijklmnopqrst", 10, 11, "abcdefghijklmnopqrst", 19, 0, 10);
+ test("abcdefghijklmnopqrst", 10, 11, "abcdefghijklmnopqrst", 19, 1, -9);
+ test("abcdefghijklmnopqrst", 10, 11, "abcdefghijklmnopqrst", 19, 2, -9);
+ test("abcdefghijklmnopqrst", 10, 11, "abcdefghijklmnopqrst", 20, 0, 10);
+ test("abcdefghijklmnopqrst", 10, 11, "abcdefghijklmnopqrst", 20, 1, 10);
+ test("abcdefghijklmnopqrst", 10, 11, "abcdefghijklmnopqrst", 21, 0, 0);
+ test("abcdefghijklmnopqrst", 19, 0, "", 0, 0, 0);
+ test("abcdefghijklmnopqrst", 19, 0, "", 0, 1, 0);
+ test("abcdefghijklmnopqrst", 19, 0, "", 1, 0, 0);
+ test("abcdefghijklmnopqrst", 19, 0, "abcde", 0, 0, 0);
+ test("abcdefghijklmnopqrst", 19, 0, "abcde", 0, 1, -1);
+ test("abcdefghijklmnopqrst", 19, 0, "abcde", 0, 2, -2);
+ test("abcdefghijklmnopqrst", 19, 0, "abcde", 0, 4, -4);
+ test("abcdefghijklmnopqrst", 19, 0, "abcde", 0, 5, -5);
+ test("abcdefghijklmnopqrst", 19, 0, "abcde", 0, 6, -5);
+ test("abcdefghijklmnopqrst", 19, 0, "abcde", 1, 0, 0);
+ test("abcdefghijklmnopqrst", 19, 0, "abcde", 1, 1, -1);
+ test("abcdefghijklmnopqrst", 19, 0, "abcde", 1, 2, -2);
+ test("abcdefghijklmnopqrst", 19, 0, "abcde", 1, 3, -3);
+ test("abcdefghijklmnopqrst", 19, 0, "abcde", 1, 4, -4);
+ test("abcdefghijklmnopqrst", 19, 0, "abcde", 1, 5, -4);
+ test("abcdefghijklmnopqrst", 19, 0, "abcde", 2, 0, 0);
+ test("abcdefghijklmnopqrst", 19, 0, "abcde", 2, 1, -1);
+ test("abcdefghijklmnopqrst", 19, 0, "abcde", 2, 2, -2);
+ test("abcdefghijklmnopqrst", 19, 0, "abcde", 2, 3, -3);
+ test("abcdefghijklmnopqrst", 19, 0, "abcde", 2, 4, -3);
+ test("abcdefghijklmnopqrst", 19, 0, "abcde", 4, 0, 0);
+ test("abcdefghijklmnopqrst", 19, 0, "abcde", 4, 1, -1);
+ test("abcdefghijklmnopqrst", 19, 0, "abcde", 4, 2, -1);
+ test("abcdefghijklmnopqrst", 19, 0, "abcde", 5, 0, 0);
+ test("abcdefghijklmnopqrst", 19, 0, "abcde", 5, 1, 0);
+ test("abcdefghijklmnopqrst", 19, 0, "abcde", 6, 0, 0);
+ test("abcdefghijklmnopqrst", 19, 0, "abcdefghij", 0, 0, 0);
+ test("abcdefghijklmnopqrst", 19, 0, "abcdefghij", 0, 1, -1);
+ test("abcdefghijklmnopqrst", 19, 0, "abcdefghij", 0, 5, -5);
+ test("abcdefghijklmnopqrst", 19, 0, "abcdefghij", 0, 9, -9);
+ test("abcdefghijklmnopqrst", 19, 0, "abcdefghij", 0, 10, -10);
+ test("abcdefghijklmnopqrst", 19, 0, "abcdefghij", 0, 11, -10);
+ test("abcdefghijklmnopqrst", 19, 0, "abcdefghij", 1, 0, 0);
+ test("abcdefghijklmnopqrst", 19, 0, "abcdefghij", 1, 1, -1);
+ test("abcdefghijklmnopqrst", 19, 0, "abcdefghij", 1, 4, -4);
+ test("abcdefghijklmnopqrst", 19, 0, "abcdefghij", 1, 8, -8);
+ test("abcdefghijklmnopqrst", 19, 0, "abcdefghij", 1, 9, -9);
+ test("abcdefghijklmnopqrst", 19, 0, "abcdefghij", 1, 10, -9);
+ test("abcdefghijklmnopqrst", 19, 0, "abcdefghij", 5, 0, 0);
+ test("abcdefghijklmnopqrst", 19, 0, "abcdefghij", 5, 1, -1);
+ test("abcdefghijklmnopqrst", 19, 0, "abcdefghij", 5, 2, -2);
+ test("abcdefghijklmnopqrst", 19, 0, "abcdefghij", 5, 4, -4);
+ test("abcdefghijklmnopqrst", 19, 0, "abcdefghij", 5, 5, -5);
+ test("abcdefghijklmnopqrst", 19, 0, "abcdefghij", 5, 6, -5);
+ test("abcdefghijklmnopqrst", 19, 0, "abcdefghij", 9, 0, 0);
+ test("abcdefghijklmnopqrst", 19, 0, "abcdefghij", 9, 1, -1);
+ test("abcdefghijklmnopqrst", 19, 0, "abcdefghij", 9, 2, -1);
+ test("abcdefghijklmnopqrst", 19, 0, "abcdefghij", 10, 0, 0);
+ test("abcdefghijklmnopqrst", 19, 0, "abcdefghij", 10, 1, 0);
+ test("abcdefghijklmnopqrst", 19, 0, "abcdefghij", 11, 0, 0);
+ test("abcdefghijklmnopqrst", 19, 0, "abcdefghijklmnopqrst", 0, 0, 0);
+ test("abcdefghijklmnopqrst", 19, 0, "abcdefghijklmnopqrst", 0, 1, -1);
+ test("abcdefghijklmnopqrst", 19, 0, "abcdefghijklmnopqrst", 0, 10, -10);
+ test("abcdefghijklmnopqrst", 19, 0, "abcdefghijklmnopqrst", 0, 19, -19);
+ test("abcdefghijklmnopqrst", 19, 0, "abcdefghijklmnopqrst", 0, 20, -20);
+ test("abcdefghijklmnopqrst", 19, 0, "abcdefghijklmnopqrst", 0, 21, -20);
+ test("abcdefghijklmnopqrst", 19, 0, "abcdefghijklmnopqrst", 1, 0, 0);
+ test("abcdefghijklmnopqrst", 19, 0, "abcdefghijklmnopqrst", 1, 1, -1);
+ test("abcdefghijklmnopqrst", 19, 0, "abcdefghijklmnopqrst", 1, 9, -9);
+ test("abcdefghijklmnopqrst", 19, 0, "abcdefghijklmnopqrst", 1, 18, -18);
+ test("abcdefghijklmnopqrst", 19, 0, "abcdefghijklmnopqrst", 1, 19, -19);
+ test("abcdefghijklmnopqrst", 19, 0, "abcdefghijklmnopqrst", 1, 20, -19);
+ test("abcdefghijklmnopqrst", 19, 0, "abcdefghijklmnopqrst", 10, 0, 0);
+ test("abcdefghijklmnopqrst", 19, 0, "abcdefghijklmnopqrst", 10, 1, -1);
+ test("abcdefghijklmnopqrst", 19, 0, "abcdefghijklmnopqrst", 10, 5, -5);
+ test("abcdefghijklmnopqrst", 19, 0, "abcdefghijklmnopqrst", 10, 9, -9);
+ test("abcdefghijklmnopqrst", 19, 0, "abcdefghijklmnopqrst", 10, 10, -10);
+ test("abcdefghijklmnopqrst", 19, 0, "abcdefghijklmnopqrst", 10, 11, -10);
+}
+
+void test51()
+{
+ test("abcdefghijklmnopqrst", 19, 0, "abcdefghijklmnopqrst", 19, 0, 0);
+ test("abcdefghijklmnopqrst", 19, 0, "abcdefghijklmnopqrst", 19, 1, -1);
+ test("abcdefghijklmnopqrst", 19, 0, "abcdefghijklmnopqrst", 19, 2, -1);
+ test("abcdefghijklmnopqrst", 19, 0, "abcdefghijklmnopqrst", 20, 0, 0);
+ test("abcdefghijklmnopqrst", 19, 0, "abcdefghijklmnopqrst", 20, 1, 0);
+ test("abcdefghijklmnopqrst", 19, 0, "abcdefghijklmnopqrst", 21, 0, 0);
+ test("abcdefghijklmnopqrst", 19, 1, "", 0, 0, 1);
+ test("abcdefghijklmnopqrst", 19, 1, "", 0, 1, 1);
+ test("abcdefghijklmnopqrst", 19, 1, "", 1, 0, 0);
+ test("abcdefghijklmnopqrst", 19, 1, "abcde", 0, 0, 1);
+ test("abcdefghijklmnopqrst", 19, 1, "abcde", 0, 1, 19);
+ test("abcdefghijklmnopqrst", 19, 1, "abcde", 0, 2, 19);
+ test("abcdefghijklmnopqrst", 19, 1, "abcde", 0, 4, 19);
+ test("abcdefghijklmnopqrst", 19, 1, "abcde", 0, 5, 19);
+ test("abcdefghijklmnopqrst", 19, 1, "abcde", 0, 6, 19);
+ test("abcdefghijklmnopqrst", 19, 1, "abcde", 1, 0, 1);
+ test("abcdefghijklmnopqrst", 19, 1, "abcde", 1, 1, 18);
+ test("abcdefghijklmnopqrst", 19, 1, "abcde", 1, 2, 18);
+ test("abcdefghijklmnopqrst", 19, 1, "abcde", 1, 3, 18);
+ test("abcdefghijklmnopqrst", 19, 1, "abcde", 1, 4, 18);
+ test("abcdefghijklmnopqrst", 19, 1, "abcde", 1, 5, 18);
+ test("abcdefghijklmnopqrst", 19, 1, "abcde", 2, 0, 1);
+ test("abcdefghijklmnopqrst", 19, 1, "abcde", 2, 1, 17);
+ test("abcdefghijklmnopqrst", 19, 1, "abcde", 2, 2, 17);
+ test("abcdefghijklmnopqrst", 19, 1, "abcde", 2, 3, 17);
+ test("abcdefghijklmnopqrst", 19, 1, "abcde", 2, 4, 17);
+ test("abcdefghijklmnopqrst", 19, 1, "abcde", 4, 0, 1);
+ test("abcdefghijklmnopqrst", 19, 1, "abcde", 4, 1, 15);
+ test("abcdefghijklmnopqrst", 19, 1, "abcde", 4, 2, 15);
+ test("abcdefghijklmnopqrst", 19, 1, "abcde", 5, 0, 1);
+ test("abcdefghijklmnopqrst", 19, 1, "abcde", 5, 1, 1);
+ test("abcdefghijklmnopqrst", 19, 1, "abcde", 6, 0, 0);
+ test("abcdefghijklmnopqrst", 19, 1, "abcdefghij", 0, 0, 1);
+ test("abcdefghijklmnopqrst", 19, 1, "abcdefghij", 0, 1, 19);
+ test("abcdefghijklmnopqrst", 19, 1, "abcdefghij", 0, 5, 19);
+ test("abcdefghijklmnopqrst", 19, 1, "abcdefghij", 0, 9, 19);
+ test("abcdefghijklmnopqrst", 19, 1, "abcdefghij", 0, 10, 19);
+ test("abcdefghijklmnopqrst", 19, 1, "abcdefghij", 0, 11, 19);
+ test("abcdefghijklmnopqrst", 19, 1, "abcdefghij", 1, 0, 1);
+ test("abcdefghijklmnopqrst", 19, 1, "abcdefghij", 1, 1, 18);
+ test("abcdefghijklmnopqrst", 19, 1, "abcdefghij", 1, 4, 18);
+ test("abcdefghijklmnopqrst", 19, 1, "abcdefghij", 1, 8, 18);
+ test("abcdefghijklmnopqrst", 19, 1, "abcdefghij", 1, 9, 18);
+ test("abcdefghijklmnopqrst", 19, 1, "abcdefghij", 1, 10, 18);
+ test("abcdefghijklmnopqrst", 19, 1, "abcdefghij", 5, 0, 1);
+ test("abcdefghijklmnopqrst", 19, 1, "abcdefghij", 5, 1, 14);
+ test("abcdefghijklmnopqrst", 19, 1, "abcdefghij", 5, 2, 14);
+ test("abcdefghijklmnopqrst", 19, 1, "abcdefghij", 5, 4, 14);
+ test("abcdefghijklmnopqrst", 19, 1, "abcdefghij", 5, 5, 14);
+ test("abcdefghijklmnopqrst", 19, 1, "abcdefghij", 5, 6, 14);
+ test("abcdefghijklmnopqrst", 19, 1, "abcdefghij", 9, 0, 1);
+ test("abcdefghijklmnopqrst", 19, 1, "abcdefghij", 9, 1, 10);
+ test("abcdefghijklmnopqrst", 19, 1, "abcdefghij", 9, 2, 10);
+ test("abcdefghijklmnopqrst", 19, 1, "abcdefghij", 10, 0, 1);
+ test("abcdefghijklmnopqrst", 19, 1, "abcdefghij", 10, 1, 1);
+ test("abcdefghijklmnopqrst", 19, 1, "abcdefghij", 11, 0, 0);
+ test("abcdefghijklmnopqrst", 19, 1, "abcdefghijklmnopqrst", 0, 0, 1);
+ test("abcdefghijklmnopqrst", 19, 1, "abcdefghijklmnopqrst", 0, 1, 19);
+ test("abcdefghijklmnopqrst", 19, 1, "abcdefghijklmnopqrst", 0, 10, 19);
+ test("abcdefghijklmnopqrst", 19, 1, "abcdefghijklmnopqrst", 0, 19, 19);
+ test("abcdefghijklmnopqrst", 19, 1, "abcdefghijklmnopqrst", 0, 20, 19);
+ test("abcdefghijklmnopqrst", 19, 1, "abcdefghijklmnopqrst", 0, 21, 19);
+ test("abcdefghijklmnopqrst", 19, 1, "abcdefghijklmnopqrst", 1, 0, 1);
+ test("abcdefghijklmnopqrst", 19, 1, "abcdefghijklmnopqrst", 1, 1, 18);
+ test("abcdefghijklmnopqrst", 19, 1, "abcdefghijklmnopqrst", 1, 9, 18);
+ test("abcdefghijklmnopqrst", 19, 1, "abcdefghijklmnopqrst", 1, 18, 18);
+ test("abcdefghijklmnopqrst", 19, 1, "abcdefghijklmnopqrst", 1, 19, 18);
+ test("abcdefghijklmnopqrst", 19, 1, "abcdefghijklmnopqrst", 1, 20, 18);
+ test("abcdefghijklmnopqrst", 19, 1, "abcdefghijklmnopqrst", 10, 0, 1);
+ test("abcdefghijklmnopqrst", 19, 1, "abcdefghijklmnopqrst", 10, 1, 9);
+ test("abcdefghijklmnopqrst", 19, 1, "abcdefghijklmnopqrst", 10, 5, 9);
+ test("abcdefghijklmnopqrst", 19, 1, "abcdefghijklmnopqrst", 10, 9, 9);
+ test("abcdefghijklmnopqrst", 19, 1, "abcdefghijklmnopqrst", 10, 10, 9);
+ test("abcdefghijklmnopqrst", 19, 1, "abcdefghijklmnopqrst", 10, 11, 9);
+ test("abcdefghijklmnopqrst", 19, 1, "abcdefghijklmnopqrst", 19, 0, 1);
+ test("abcdefghijklmnopqrst", 19, 1, "abcdefghijklmnopqrst", 19, 1, 0);
+ test("abcdefghijklmnopqrst", 19, 1, "abcdefghijklmnopqrst", 19, 2, 0);
+ test("abcdefghijklmnopqrst", 19, 1, "abcdefghijklmnopqrst", 20, 0, 1);
+ test("abcdefghijklmnopqrst", 19, 1, "abcdefghijklmnopqrst", 20, 1, 1);
+ test("abcdefghijklmnopqrst", 19, 1, "abcdefghijklmnopqrst", 21, 0, 0);
+ test("abcdefghijklmnopqrst", 19, 2, "", 0, 0, 1);
+ test("abcdefghijklmnopqrst", 19, 2, "", 0, 1, 1);
+ test("abcdefghijklmnopqrst", 19, 2, "", 1, 0, 0);
+ test("abcdefghijklmnopqrst", 19, 2, "abcde", 0, 0, 1);
+ test("abcdefghijklmnopqrst", 19, 2, "abcde", 0, 1, 19);
+ test("abcdefghijklmnopqrst", 19, 2, "abcde", 0, 2, 19);
+ test("abcdefghijklmnopqrst", 19, 2, "abcde", 0, 4, 19);
+ test("abcdefghijklmnopqrst", 19, 2, "abcde", 0, 5, 19);
+ test("abcdefghijklmnopqrst", 19, 2, "abcde", 0, 6, 19);
+ test("abcdefghijklmnopqrst", 19, 2, "abcde", 1, 0, 1);
+ test("abcdefghijklmnopqrst", 19, 2, "abcde", 1, 1, 18);
+ test("abcdefghijklmnopqrst", 19, 2, "abcde", 1, 2, 18);
+ test("abcdefghijklmnopqrst", 19, 2, "abcde", 1, 3, 18);
+ test("abcdefghijklmnopqrst", 19, 2, "abcde", 1, 4, 18);
+ test("abcdefghijklmnopqrst", 19, 2, "abcde", 1, 5, 18);
+ test("abcdefghijklmnopqrst", 19, 2, "abcde", 2, 0, 1);
+ test("abcdefghijklmnopqrst", 19, 2, "abcde", 2, 1, 17);
+ test("abcdefghijklmnopqrst", 19, 2, "abcde", 2, 2, 17);
+ test("abcdefghijklmnopqrst", 19, 2, "abcde", 2, 3, 17);
+ test("abcdefghijklmnopqrst", 19, 2, "abcde", 2, 4, 17);
+}
+
+void test52()
+{
+ test("abcdefghijklmnopqrst", 19, 2, "abcde", 4, 0, 1);
+ test("abcdefghijklmnopqrst", 19, 2, "abcde", 4, 1, 15);
+ test("abcdefghijklmnopqrst", 19, 2, "abcde", 4, 2, 15);
+ test("abcdefghijklmnopqrst", 19, 2, "abcde", 5, 0, 1);
+ test("abcdefghijklmnopqrst", 19, 2, "abcde", 5, 1, 1);
+ test("abcdefghijklmnopqrst", 19, 2, "abcde", 6, 0, 0);
+ test("abcdefghijklmnopqrst", 19, 2, "abcdefghij", 0, 0, 1);
+ test("abcdefghijklmnopqrst", 19, 2, "abcdefghij", 0, 1, 19);
+ test("abcdefghijklmnopqrst", 19, 2, "abcdefghij", 0, 5, 19);
+ test("abcdefghijklmnopqrst", 19, 2, "abcdefghij", 0, 9, 19);
+ test("abcdefghijklmnopqrst", 19, 2, "abcdefghij", 0, 10, 19);
+ test("abcdefghijklmnopqrst", 19, 2, "abcdefghij", 0, 11, 19);
+ test("abcdefghijklmnopqrst", 19, 2, "abcdefghij", 1, 0, 1);
+ test("abcdefghijklmnopqrst", 19, 2, "abcdefghij", 1, 1, 18);
+ test("abcdefghijklmnopqrst", 19, 2, "abcdefghij", 1, 4, 18);
+ test("abcdefghijklmnopqrst", 19, 2, "abcdefghij", 1, 8, 18);
+ test("abcdefghijklmnopqrst", 19, 2, "abcdefghij", 1, 9, 18);
+ test("abcdefghijklmnopqrst", 19, 2, "abcdefghij", 1, 10, 18);
+ test("abcdefghijklmnopqrst", 19, 2, "abcdefghij", 5, 0, 1);
+ test("abcdefghijklmnopqrst", 19, 2, "abcdefghij", 5, 1, 14);
+ test("abcdefghijklmnopqrst", 19, 2, "abcdefghij", 5, 2, 14);
+ test("abcdefghijklmnopqrst", 19, 2, "abcdefghij", 5, 4, 14);
+ test("abcdefghijklmnopqrst", 19, 2, "abcdefghij", 5, 5, 14);
+ test("abcdefghijklmnopqrst", 19, 2, "abcdefghij", 5, 6, 14);
+ test("abcdefghijklmnopqrst", 19, 2, "abcdefghij", 9, 0, 1);
+ test("abcdefghijklmnopqrst", 19, 2, "abcdefghij", 9, 1, 10);
+ test("abcdefghijklmnopqrst", 19, 2, "abcdefghij", 9, 2, 10);
+ test("abcdefghijklmnopqrst", 19, 2, "abcdefghij", 10, 0, 1);
+ test("abcdefghijklmnopqrst", 19, 2, "abcdefghij", 10, 1, 1);
+ test("abcdefghijklmnopqrst", 19, 2, "abcdefghij", 11, 0, 0);
+ test("abcdefghijklmnopqrst", 19, 2, "abcdefghijklmnopqrst", 0, 0, 1);
+ test("abcdefghijklmnopqrst", 19, 2, "abcdefghijklmnopqrst", 0, 1, 19);
+ test("abcdefghijklmnopqrst", 19, 2, "abcdefghijklmnopqrst", 0, 10, 19);
+ test("abcdefghijklmnopqrst", 19, 2, "abcdefghijklmnopqrst", 0, 19, 19);
+ test("abcdefghijklmnopqrst", 19, 2, "abcdefghijklmnopqrst", 0, 20, 19);
+ test("abcdefghijklmnopqrst", 19, 2, "abcdefghijklmnopqrst", 0, 21, 19);
+ test("abcdefghijklmnopqrst", 19, 2, "abcdefghijklmnopqrst", 1, 0, 1);
+ test("abcdefghijklmnopqrst", 19, 2, "abcdefghijklmnopqrst", 1, 1, 18);
+ test("abcdefghijklmnopqrst", 19, 2, "abcdefghijklmnopqrst", 1, 9, 18);
+ test("abcdefghijklmnopqrst", 19, 2, "abcdefghijklmnopqrst", 1, 18, 18);
+ test("abcdefghijklmnopqrst", 19, 2, "abcdefghijklmnopqrst", 1, 19, 18);
+ test("abcdefghijklmnopqrst", 19, 2, "abcdefghijklmnopqrst", 1, 20, 18);
+ test("abcdefghijklmnopqrst", 19, 2, "abcdefghijklmnopqrst", 10, 0, 1);
+ test("abcdefghijklmnopqrst", 19, 2, "abcdefghijklmnopqrst", 10, 1, 9);
+ test("abcdefghijklmnopqrst", 19, 2, "abcdefghijklmnopqrst", 10, 5, 9);
+ test("abcdefghijklmnopqrst", 19, 2, "abcdefghijklmnopqrst", 10, 9, 9);
+ test("abcdefghijklmnopqrst", 19, 2, "abcdefghijklmnopqrst", 10, 10, 9);
+ test("abcdefghijklmnopqrst", 19, 2, "abcdefghijklmnopqrst", 10, 11, 9);
+ test("abcdefghijklmnopqrst", 19, 2, "abcdefghijklmnopqrst", 19, 0, 1);
+ test("abcdefghijklmnopqrst", 19, 2, "abcdefghijklmnopqrst", 19, 1, 0);
+ test("abcdefghijklmnopqrst", 19, 2, "abcdefghijklmnopqrst", 19, 2, 0);
+ test("abcdefghijklmnopqrst", 19, 2, "abcdefghijklmnopqrst", 20, 0, 1);
+ test("abcdefghijklmnopqrst", 19, 2, "abcdefghijklmnopqrst", 20, 1, 1);
+ test("abcdefghijklmnopqrst", 19, 2, "abcdefghijklmnopqrst", 21, 0, 0);
+ test("abcdefghijklmnopqrst", 20, 0, "", 0, 0, 0);
+ test("abcdefghijklmnopqrst", 20, 0, "", 0, 1, 0);
+ test("abcdefghijklmnopqrst", 20, 0, "", 1, 0, 0);
+ test("abcdefghijklmnopqrst", 20, 0, "abcde", 0, 0, 0);
+ test("abcdefghijklmnopqrst", 20, 0, "abcde", 0, 1, -1);
+ test("abcdefghijklmnopqrst", 20, 0, "abcde", 0, 2, -2);
+ test("abcdefghijklmnopqrst", 20, 0, "abcde", 0, 4, -4);
+ test("abcdefghijklmnopqrst", 20, 0, "abcde", 0, 5, -5);
+ test("abcdefghijklmnopqrst", 20, 0, "abcde", 0, 6, -5);
+ test("abcdefghijklmnopqrst", 20, 0, "abcde", 1, 0, 0);
+ test("abcdefghijklmnopqrst", 20, 0, "abcde", 1, 1, -1);
+ test("abcdefghijklmnopqrst", 20, 0, "abcde", 1, 2, -2);
+ test("abcdefghijklmnopqrst", 20, 0, "abcde", 1, 3, -3);
+ test("abcdefghijklmnopqrst", 20, 0, "abcde", 1, 4, -4);
+ test("abcdefghijklmnopqrst", 20, 0, "abcde", 1, 5, -4);
+ test("abcdefghijklmnopqrst", 20, 0, "abcde", 2, 0, 0);
+ test("abcdefghijklmnopqrst", 20, 0, "abcde", 2, 1, -1);
+ test("abcdefghijklmnopqrst", 20, 0, "abcde", 2, 2, -2);
+ test("abcdefghijklmnopqrst", 20, 0, "abcde", 2, 3, -3);
+ test("abcdefghijklmnopqrst", 20, 0, "abcde", 2, 4, -3);
+ test("abcdefghijklmnopqrst", 20, 0, "abcde", 4, 0, 0);
+ test("abcdefghijklmnopqrst", 20, 0, "abcde", 4, 1, -1);
+ test("abcdefghijklmnopqrst", 20, 0, "abcde", 4, 2, -1);
+ test("abcdefghijklmnopqrst", 20, 0, "abcde", 5, 0, 0);
+ test("abcdefghijklmnopqrst", 20, 0, "abcde", 5, 1, 0);
+ test("abcdefghijklmnopqrst", 20, 0, "abcde", 6, 0, 0);
+ test("abcdefghijklmnopqrst", 20, 0, "abcdefghij", 0, 0, 0);
+ test("abcdefghijklmnopqrst", 20, 0, "abcdefghij", 0, 1, -1);
+ test("abcdefghijklmnopqrst", 20, 0, "abcdefghij", 0, 5, -5);
+ test("abcdefghijklmnopqrst", 20, 0, "abcdefghij", 0, 9, -9);
+ test("abcdefghijklmnopqrst", 20, 0, "abcdefghij", 0, 10, -10);
+ test("abcdefghijklmnopqrst", 20, 0, "abcdefghij", 0, 11, -10);
+ test("abcdefghijklmnopqrst", 20, 0, "abcdefghij", 1, 0, 0);
+ test("abcdefghijklmnopqrst", 20, 0, "abcdefghij", 1, 1, -1);
+ test("abcdefghijklmnopqrst", 20, 0, "abcdefghij", 1, 4, -4);
+ test("abcdefghijklmnopqrst", 20, 0, "abcdefghij", 1, 8, -8);
+ test("abcdefghijklmnopqrst", 20, 0, "abcdefghij", 1, 9, -9);
+ test("abcdefghijklmnopqrst", 20, 0, "abcdefghij", 1, 10, -9);
+ test("abcdefghijklmnopqrst", 20, 0, "abcdefghij", 5, 0, 0);
+ test("abcdefghijklmnopqrst", 20, 0, "abcdefghij", 5, 1, -1);
+ test("abcdefghijklmnopqrst", 20, 0, "abcdefghij", 5, 2, -2);
+ test("abcdefghijklmnopqrst", 20, 0, "abcdefghij", 5, 4, -4);
+ test("abcdefghijklmnopqrst", 20, 0, "abcdefghij", 5, 5, -5);
+ test("abcdefghijklmnopqrst", 20, 0, "abcdefghij", 5, 6, -5);
+ test("abcdefghijklmnopqrst", 20, 0, "abcdefghij", 9, 0, 0);
+ test("abcdefghijklmnopqrst", 20, 0, "abcdefghij", 9, 1, -1);
+}
+
+void test53()
+{
+ test("abcdefghijklmnopqrst", 20, 0, "abcdefghij", 9, 2, -1);
+ test("abcdefghijklmnopqrst", 20, 0, "abcdefghij", 10, 0, 0);
+ test("abcdefghijklmnopqrst", 20, 0, "abcdefghij", 10, 1, 0);
+ test("abcdefghijklmnopqrst", 20, 0, "abcdefghij", 11, 0, 0);
+ test("abcdefghijklmnopqrst", 20, 0, "abcdefghijklmnopqrst", 0, 0, 0);
+ test("abcdefghijklmnopqrst", 20, 0, "abcdefghijklmnopqrst", 0, 1, -1);
+ test("abcdefghijklmnopqrst", 20, 0, "abcdefghijklmnopqrst", 0, 10, -10);
+ test("abcdefghijklmnopqrst", 20, 0, "abcdefghijklmnopqrst", 0, 19, -19);
+ test("abcdefghijklmnopqrst", 20, 0, "abcdefghijklmnopqrst", 0, 20, -20);
+ test("abcdefghijklmnopqrst", 20, 0, "abcdefghijklmnopqrst", 0, 21, -20);
+ test("abcdefghijklmnopqrst", 20, 0, "abcdefghijklmnopqrst", 1, 0, 0);
+ test("abcdefghijklmnopqrst", 20, 0, "abcdefghijklmnopqrst", 1, 1, -1);
+ test("abcdefghijklmnopqrst", 20, 0, "abcdefghijklmnopqrst", 1, 9, -9);
+ test("abcdefghijklmnopqrst", 20, 0, "abcdefghijklmnopqrst", 1, 18, -18);
+ test("abcdefghijklmnopqrst", 20, 0, "abcdefghijklmnopqrst", 1, 19, -19);
+ test("abcdefghijklmnopqrst", 20, 0, "abcdefghijklmnopqrst", 1, 20, -19);
+ test("abcdefghijklmnopqrst", 20, 0, "abcdefghijklmnopqrst", 10, 0, 0);
+ test("abcdefghijklmnopqrst", 20, 0, "abcdefghijklmnopqrst", 10, 1, -1);
+ test("abcdefghijklmnopqrst", 20, 0, "abcdefghijklmnopqrst", 10, 5, -5);
+ test("abcdefghijklmnopqrst", 20, 0, "abcdefghijklmnopqrst", 10, 9, -9);
+ test("abcdefghijklmnopqrst", 20, 0, "abcdefghijklmnopqrst", 10, 10, -10);
+ test("abcdefghijklmnopqrst", 20, 0, "abcdefghijklmnopqrst", 10, 11, -10);
+ test("abcdefghijklmnopqrst", 20, 0, "abcdefghijklmnopqrst", 19, 0, 0);
+ test("abcdefghijklmnopqrst", 20, 0, "abcdefghijklmnopqrst", 19, 1, -1);
+ test("abcdefghijklmnopqrst", 20, 0, "abcdefghijklmnopqrst", 19, 2, -1);
+ test("abcdefghijklmnopqrst", 20, 0, "abcdefghijklmnopqrst", 20, 0, 0);
+ test("abcdefghijklmnopqrst", 20, 0, "abcdefghijklmnopqrst", 20, 1, 0);
+ test("abcdefghijklmnopqrst", 20, 0, "abcdefghijklmnopqrst", 21, 0, 0);
+ test("abcdefghijklmnopqrst", 20, 1, "", 0, 0, 0);
+ test("abcdefghijklmnopqrst", 20, 1, "", 0, 1, 0);
+ test("abcdefghijklmnopqrst", 20, 1, "", 1, 0, 0);
+ test("abcdefghijklmnopqrst", 20, 1, "abcde", 0, 0, 0);
+ test("abcdefghijklmnopqrst", 20, 1, "abcde", 0, 1, -1);
+ test("abcdefghijklmnopqrst", 20, 1, "abcde", 0, 2, -2);
+ test("abcdefghijklmnopqrst", 20, 1, "abcde", 0, 4, -4);
+ test("abcdefghijklmnopqrst", 20, 1, "abcde", 0, 5, -5);
+ test("abcdefghijklmnopqrst", 20, 1, "abcde", 0, 6, -5);
+ test("abcdefghijklmnopqrst", 20, 1, "abcde", 1, 0, 0);
+ test("abcdefghijklmnopqrst", 20, 1, "abcde", 1, 1, -1);
+ test("abcdefghijklmnopqrst", 20, 1, "abcde", 1, 2, -2);
+ test("abcdefghijklmnopqrst", 20, 1, "abcde", 1, 3, -3);
+ test("abcdefghijklmnopqrst", 20, 1, "abcde", 1, 4, -4);
+ test("abcdefghijklmnopqrst", 20, 1, "abcde", 1, 5, -4);
+ test("abcdefghijklmnopqrst", 20, 1, "abcde", 2, 0, 0);
+ test("abcdefghijklmnopqrst", 20, 1, "abcde", 2, 1, -1);
+ test("abcdefghijklmnopqrst", 20, 1, "abcde", 2, 2, -2);
+ test("abcdefghijklmnopqrst", 20, 1, "abcde", 2, 3, -3);
+ test("abcdefghijklmnopqrst", 20, 1, "abcde", 2, 4, -3);
+ test("abcdefghijklmnopqrst", 20, 1, "abcde", 4, 0, 0);
+ test("abcdefghijklmnopqrst", 20, 1, "abcde", 4, 1, -1);
+ test("abcdefghijklmnopqrst", 20, 1, "abcde", 4, 2, -1);
+ test("abcdefghijklmnopqrst", 20, 1, "abcde", 5, 0, 0);
+ test("abcdefghijklmnopqrst", 20, 1, "abcde", 5, 1, 0);
+ test("abcdefghijklmnopqrst", 20, 1, "abcde", 6, 0, 0);
+ test("abcdefghijklmnopqrst", 20, 1, "abcdefghij", 0, 0, 0);
+ test("abcdefghijklmnopqrst", 20, 1, "abcdefghij", 0, 1, -1);
+ test("abcdefghijklmnopqrst", 20, 1, "abcdefghij", 0, 5, -5);
+ test("abcdefghijklmnopqrst", 20, 1, "abcdefghij", 0, 9, -9);
+ test("abcdefghijklmnopqrst", 20, 1, "abcdefghij", 0, 10, -10);
+ test("abcdefghijklmnopqrst", 20, 1, "abcdefghij", 0, 11, -10);
+ test("abcdefghijklmnopqrst", 20, 1, "abcdefghij", 1, 0, 0);
+ test("abcdefghijklmnopqrst", 20, 1, "abcdefghij", 1, 1, -1);
+ test("abcdefghijklmnopqrst", 20, 1, "abcdefghij", 1, 4, -4);
+ test("abcdefghijklmnopqrst", 20, 1, "abcdefghij", 1, 8, -8);
+ test("abcdefghijklmnopqrst", 20, 1, "abcdefghij", 1, 9, -9);
+ test("abcdefghijklmnopqrst", 20, 1, "abcdefghij", 1, 10, -9);
+ test("abcdefghijklmnopqrst", 20, 1, "abcdefghij", 5, 0, 0);
+ test("abcdefghijklmnopqrst", 20, 1, "abcdefghij", 5, 1, -1);
+ test("abcdefghijklmnopqrst", 20, 1, "abcdefghij", 5, 2, -2);
+ test("abcdefghijklmnopqrst", 20, 1, "abcdefghij", 5, 4, -4);
+ test("abcdefghijklmnopqrst", 20, 1, "abcdefghij", 5, 5, -5);
+ test("abcdefghijklmnopqrst", 20, 1, "abcdefghij", 5, 6, -5);
+ test("abcdefghijklmnopqrst", 20, 1, "abcdefghij", 9, 0, 0);
+ test("abcdefghijklmnopqrst", 20, 1, "abcdefghij", 9, 1, -1);
+ test("abcdefghijklmnopqrst", 20, 1, "abcdefghij", 9, 2, -1);
+ test("abcdefghijklmnopqrst", 20, 1, "abcdefghij", 10, 0, 0);
+ test("abcdefghijklmnopqrst", 20, 1, "abcdefghij", 10, 1, 0);
+ test("abcdefghijklmnopqrst", 20, 1, "abcdefghij", 11, 0, 0);
+ test("abcdefghijklmnopqrst", 20, 1, "abcdefghijklmnopqrst", 0, 0, 0);
+ test("abcdefghijklmnopqrst", 20, 1, "abcdefghijklmnopqrst", 0, 1, -1);
+ test("abcdefghijklmnopqrst", 20, 1, "abcdefghijklmnopqrst", 0, 10, -10);
+ test("abcdefghijklmnopqrst", 20, 1, "abcdefghijklmnopqrst", 0, 19, -19);
+ test("abcdefghijklmnopqrst", 20, 1, "abcdefghijklmnopqrst", 0, 20, -20);
+ test("abcdefghijklmnopqrst", 20, 1, "abcdefghijklmnopqrst", 0, 21, -20);
+ test("abcdefghijklmnopqrst", 20, 1, "abcdefghijklmnopqrst", 1, 0, 0);
+ test("abcdefghijklmnopqrst", 20, 1, "abcdefghijklmnopqrst", 1, 1, -1);
+ test("abcdefghijklmnopqrst", 20, 1, "abcdefghijklmnopqrst", 1, 9, -9);
+ test("abcdefghijklmnopqrst", 20, 1, "abcdefghijklmnopqrst", 1, 18, -18);
+ test("abcdefghijklmnopqrst", 20, 1, "abcdefghijklmnopqrst", 1, 19, -19);
+ test("abcdefghijklmnopqrst", 20, 1, "abcdefghijklmnopqrst", 1, 20, -19);
+ test("abcdefghijklmnopqrst", 20, 1, "abcdefghijklmnopqrst", 10, 0, 0);
+ test("abcdefghijklmnopqrst", 20, 1, "abcdefghijklmnopqrst", 10, 1, -1);
+ test("abcdefghijklmnopqrst", 20, 1, "abcdefghijklmnopqrst", 10, 5, -5);
+ test("abcdefghijklmnopqrst", 20, 1, "abcdefghijklmnopqrst", 10, 9, -9);
+ test("abcdefghijklmnopqrst", 20, 1, "abcdefghijklmnopqrst", 10, 10, -10);
+ test("abcdefghijklmnopqrst", 20, 1, "abcdefghijklmnopqrst", 10, 11, -10);
+ test("abcdefghijklmnopqrst", 20, 1, "abcdefghijklmnopqrst", 19, 0, 0);
+ test("abcdefghijklmnopqrst", 20, 1, "abcdefghijklmnopqrst", 19, 1, -1);
+ test("abcdefghijklmnopqrst", 20, 1, "abcdefghijklmnopqrst", 19, 2, -1);
+ test("abcdefghijklmnopqrst", 20, 1, "abcdefghijklmnopqrst", 20, 0, 0);
+}
+
+void test54()
+{
+ test("abcdefghijklmnopqrst", 20, 1, "abcdefghijklmnopqrst", 20, 1, 0);
+ test("abcdefghijklmnopqrst", 20, 1, "abcdefghijklmnopqrst", 21, 0, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "", 0, 0, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "", 0, 1, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "", 1, 0, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcde", 0, 0, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcde", 0, 1, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcde", 0, 2, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcde", 0, 4, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcde", 0, 5, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcde", 0, 6, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcde", 1, 0, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcde", 1, 1, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcde", 1, 2, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcde", 1, 3, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcde", 1, 4, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcde", 1, 5, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcde", 2, 0, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcde", 2, 1, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcde", 2, 2, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcde", 2, 3, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcde", 2, 4, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcde", 4, 0, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcde", 4, 1, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcde", 4, 2, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcde", 5, 0, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcde", 5, 1, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcde", 6, 0, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcdefghij", 0, 0, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcdefghij", 0, 1, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcdefghij", 0, 5, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcdefghij", 0, 9, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcdefghij", 0, 10, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcdefghij", 0, 11, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcdefghij", 1, 0, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcdefghij", 1, 1, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcdefghij", 1, 4, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcdefghij", 1, 8, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcdefghij", 1, 9, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcdefghij", 1, 10, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcdefghij", 5, 0, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcdefghij", 5, 1, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcdefghij", 5, 2, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcdefghij", 5, 4, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcdefghij", 5, 5, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcdefghij", 5, 6, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcdefghij", 9, 0, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcdefghij", 9, 1, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcdefghij", 9, 2, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcdefghij", 10, 0, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcdefghij", 10, 1, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcdefghij", 11, 0, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcdefghijklmnopqrst", 0, 0, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcdefghijklmnopqrst", 0, 1, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcdefghijklmnopqrst", 0, 10, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcdefghijklmnopqrst", 0, 19, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcdefghijklmnopqrst", 0, 20, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcdefghijklmnopqrst", 0, 21, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcdefghijklmnopqrst", 1, 0, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcdefghijklmnopqrst", 1, 1, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcdefghijklmnopqrst", 1, 9, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcdefghijklmnopqrst", 1, 18, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcdefghijklmnopqrst", 1, 19, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcdefghijklmnopqrst", 1, 20, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcdefghijklmnopqrst", 10, 0, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcdefghijklmnopqrst", 10, 1, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcdefghijklmnopqrst", 10, 5, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcdefghijklmnopqrst", 10, 9, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcdefghijklmnopqrst", 10, 10, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcdefghijklmnopqrst", 10, 11, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcdefghijklmnopqrst", 19, 0, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcdefghijklmnopqrst", 19, 1, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcdefghijklmnopqrst", 19, 2, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcdefghijklmnopqrst", 20, 0, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcdefghijklmnopqrst", 20, 1, 0);
+ test("abcdefghijklmnopqrst", 21, 0, "abcdefghijklmnopqrst", 21, 0, 0);
+}
+
+
+int main () {
+ test0();
+ test1();
+ test2();
+ test3();
+ test4();
+ test5();
+ test6();
+ test7();
+ test8();
+ test9();
+ test10();
+ test11();
+ test12();
+ test13();
+ test14();
+ test15();
+ test16();
+ test17();
+ test18();
+ test19();
+ test20();
+ test21();
+ test22();
+ test23();
+ test24();
+ test25();
+ test26();
+ test27();
+ test28();
+ test29();
+ test30();
+ test31();
+ test32();
+ test33();
+ test34();
+ test35();
+ test36();
+ test37();
+ test38();
+ test39();
+ test40();
+ test41();
+ test42();
+ test43();
+ test44();
+ test45();
+ test46();
+ test47();
+ test48();
+ test49();
+ test50();
+ test51();
+ test52();
+ test53();
+ test54();
+
+
+ {
+ test("abcde", 5, 1, "", 0, 0, 0);
+ test("abcde", 2, 4, "", 0, 0, 3);
+ test("abcde", 2, 4, "abcde", 3, 4, -2);
+ test("ABCde", 2, 4, "abcde", 2, 4, -1);
+ }
+
+ {
+ test(L"abcde", 5, 1, L"", 0, 0, 0);
+ test(L"abcde", 2, 4, L"", 0, 0, 3);
+ test(L"abcde", 2, 4, L"abcde", 3, 4, -2);
+ test(L"ABCde", 2, 4, L"abcde", 2, 4, -1);
+ }
+
+#if __cplusplus >= 201103L
+ {
+ test(u"abcde", 5, 1, u"", 0, 0, 0);
+ test(u"abcde", 2, 4, u"", 0, 0, 3);
+ test(u"abcde", 2, 4, u"abcde", 3, 4, -2);
+ test(u"ABCde", 2, 4, u"abcde", 2, 4, -1);
+ }
+
+ {
+ test(U"abcde", 5, 1, U"", 0, 0, 0);
+ test(U"abcde", 2, 4, U"", 0, 0, 3);
+ test(U"abcde", 2, 4, U"abcde", 3, 4, -2);
+ test(U"ABCde", 2, 4, U"abcde", 2, 4, -1);
+ }
+#endif
+
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::experimental::basic_string_view<char, constexpr_char_traits<char>> SV;
+ constexpr SV sv1 { "abcde", 5 };
+ static_assert ( sv1.compare(5, 1, "", 0, 0) == 0, "" );
+ static_assert ( sv1.compare(2, 4, "", 0, 0) == 1, "" );
+ static_assert ( sv1.compare(2, 4, "abcde", 3, 4) == -1, "" );
+ }
+#endif
+}
diff --git a/test/std/experimental/string.view/string.view.ops/compare.sv.pass.cpp b/test/std/experimental/string.view/string.view.ops/compare.sv.pass.cpp
new file mode 100644
index 000000000000..3f686697ba40
--- /dev/null
+++ b/test/std/experimental/string.view/string.view.ops/compare.sv.pass.cpp
@@ -0,0 +1,121 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+
+// <string_view>
+// constexpr int compare(basic_string_view str) const noexcept;
+
+#include <experimental/string_view>
+#include <cassert>
+
+#include "constexpr_char_traits.hpp"
+
+int sign ( int x ) { return x > 0 ? 1 : ( x < 0 ? -1 : 0 ); }
+
+template<typename CharT>
+void test1 ( std::experimental::basic_string_view<CharT> sv1,
+ std::experimental::basic_string_view<CharT> sv2, int expected ) {
+ assert ( sign( sv1.compare(sv2)) == sign(expected));
+}
+
+
+template<typename CharT>
+void test ( const CharT *s1, const CharT *s2, int expected ) {
+ typedef std::experimental::basic_string_view<CharT> string_view_t;
+
+ string_view_t sv1 ( s1 );
+ string_view_t sv2 ( s2 );
+ test1(sv1, sv2, expected);
+}
+
+int main () {
+
+ test("", "", 0);
+ test("", "abcde", -5);
+ test("", "abcdefghij", -10);
+ test("", "abcdefghijklmnopqrst", -20);
+ test("abcde", "", 5);
+ test("abcde", "abcde", 0);
+ test("abcde", "abcdefghij", -5);
+ test("abcde", "abcdefghijklmnopqrst", -15);
+ test("abcdefghij", "", 10);
+ test("abcdefghij", "abcde", 5);
+ test("abcdefghij", "abcdefghij", 0);
+ test("abcdefghij", "abcdefghijklmnopqrst", -10);
+ test("abcdefghijklmnopqrst", "", 20);
+ test("abcdefghijklmnopqrst", "abcde", 15);
+ test("abcdefghijklmnopqrst", "abcdefghij", 10);
+ test("abcdefghijklmnopqrst", "abcdefghijklmnopqrst", 0);
+
+ test(L"", L"", 0);
+ test(L"", L"abcde", -5);
+ test(L"", L"abcdefghij", -10);
+ test(L"", L"abcdefghijklmnopqrst", -20);
+ test(L"abcde", L"", 5);
+ test(L"abcde", L"abcde", 0);
+ test(L"abcde", L"abcdefghij", -5);
+ test(L"abcde", L"abcdefghijklmnopqrst", -15);
+ test(L"abcdefghij", L"", 10);
+ test(L"abcdefghij", L"abcde", 5);
+ test(L"abcdefghij", L"abcdefghij", 0);
+ test(L"abcdefghij", L"abcdefghijklmnopqrst", -10);
+ test(L"abcdefghijklmnopqrst", L"", 20);
+ test(L"abcdefghijklmnopqrst", L"abcde", 15);
+ test(L"abcdefghijklmnopqrst", L"abcdefghij", 10);
+ test(L"abcdefghijklmnopqrst", L"abcdefghijklmnopqrst", 0);
+
+#if __cplusplus >= 201103L
+ test(u"", u"", 0);
+ test(u"", u"abcde", -5);
+ test(u"", u"abcdefghij", -10);
+ test(u"", u"abcdefghijklmnopqrst", -20);
+ test(u"abcde", u"", 5);
+ test(u"abcde", u"abcde", 0);
+ test(u"abcde", u"abcdefghij", -5);
+ test(u"abcde", u"abcdefghijklmnopqrst", -15);
+ test(u"abcdefghij", u"", 10);
+ test(u"abcdefghij", u"abcde", 5);
+ test(u"abcdefghij", u"abcdefghij", 0);
+ test(u"abcdefghij", u"abcdefghijklmnopqrst", -10);
+ test(u"abcdefghijklmnopqrst", u"", 20);
+ test(u"abcdefghijklmnopqrst", u"abcde", 15);
+ test(u"abcdefghijklmnopqrst", u"abcdefghij", 10);
+ test(u"abcdefghijklmnopqrst", u"abcdefghijklmnopqrst", 0);
+
+ test(U"", U"", 0);
+ test(U"", U"abcde", -5);
+ test(U"", U"abcdefghij", -10);
+ test(U"", U"abcdefghijklmnopqrst", -20);
+ test(U"abcde", U"", 5);
+ test(U"abcde", U"abcde", 0);
+ test(U"abcde", U"abcdefghij", -5);
+ test(U"abcde", U"abcdefghijklmnopqrst", -15);
+ test(U"abcdefghij", U"", 10);
+ test(U"abcdefghij", U"abcde", 5);
+ test(U"abcdefghij", U"abcdefghij", 0);
+ test(U"abcdefghij", U"abcdefghijklmnopqrst", -10);
+ test(U"abcdefghijklmnopqrst", U"", 20);
+ test(U"abcdefghijklmnopqrst", U"abcde", 15);
+ test(U"abcdefghijklmnopqrst", U"abcdefghij", 10);
+ test(U"abcdefghijklmnopqrst", U"abcdefghijklmnopqrst", 0);
+#endif
+
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::experimental::basic_string_view<char, constexpr_char_traits<char>> SV;
+ constexpr SV sv1 { "abcde", 5 };
+ constexpr SV sv2 { "abcde", 5 };
+ constexpr SV sv3 { "edcba0", 6 };
+ static_assert ( sv1.compare(sv2) == 0, "" );
+ static_assert ( sv2.compare(sv1) == 0, "" );
+ static_assert ( sv3.compare(sv2) > 0, "" );
+ static_assert ( sv2.compare(sv3) < 0, "" );
+ }
+#endif
+}
diff --git a/test/std/experimental/string.view/string.view.ops/copy.pass.cpp b/test/std/experimental/string.view/string.view.ops/copy.pass.cpp
new file mode 100644
index 000000000000..96246d2732c7
--- /dev/null
+++ b/test/std/experimental/string.view/string.view.ops/copy.pass.cpp
@@ -0,0 +1,92 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+
+// <string_view>
+
+// size_type copy(charT* s, size_type n, size_type pos = 0) const;
+
+// Throws: out_of_range if pos > size().
+// Remarks: Let rlen be the smaller of n and size() - pos.
+// Requires: [s, s+rlen) is a valid range.
+// Effects: Equivalent to std::copy_n(begin() + pos, rlen, s).
+// Returns: rlen.
+
+
+#include <experimental/string_view>
+#include <cassert>
+
+template<typename CharT>
+void test1 ( std::experimental::basic_string_view<CharT> sv, size_t n, size_t pos ) {
+ const size_t rlen = std::min ( n, sv.size() - pos );
+
+ CharT *dest1 = new CharT [rlen + 1]; dest1[rlen] = 0;
+ CharT *dest2 = new CharT [rlen + 1]; dest2[rlen] = 0;
+
+ try {
+ sv.copy(dest1, n, pos);
+ std::copy_n(sv.begin() + pos, rlen, dest2);
+
+ for ( size_t i = 0; i <= rlen; ++i )
+ assert ( dest1[i] == dest2[i] );
+ }
+ catch ( const std::out_of_range & ) { assert ( pos > sv.size()); }
+ delete [] dest1;
+ delete [] dest2;
+}
+
+
+template<typename CharT>
+void test ( const CharT *s ) {
+ typedef std::experimental::basic_string_view<CharT> string_view_t;
+
+ string_view_t sv1 ( s );
+
+ test1(sv1, 0, 0);
+ test1(sv1, 1, 0);
+ test1(sv1, 20, 0);
+ test1(sv1, sv1.size(), 0);
+ test1(sv1, 20, string_view_t::npos);
+
+ test1(sv1, 0, 3);
+ test1(sv1, 2, 3);
+ test1(sv1, 100, 3);
+ test1(sv1, 100, string_view_t::npos);
+
+ test1(sv1, sv1.size(), string_view_t::npos);
+
+ test1(sv1, sv1.size() + 1, 0);
+ test1(sv1, sv1.size() + 1, 1);
+ test1(sv1, sv1.size() + 1, string_view_t::npos);
+
+}
+
+int main () {
+ test ( "ABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDE" );
+ test ( "ABCDE");
+ test ( "a" );
+ test ( "" );
+
+ test ( L"ABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDE" );
+ test ( L"ABCDE" );
+ test ( L"a" );
+ test ( L"" );
+
+#if __cplusplus >= 201103L
+ test ( u"ABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDE" );
+ test ( u"ABCDE" );
+ test ( u"a" );
+ test ( u"" );
+
+ test ( U"ABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDE" );
+ test ( U"ABCDE" );
+ test ( U"a" );
+ test ( U"" );
+#endif
+}
diff --git a/test/std/experimental/string.view/string.view.ops/substr.pass.cpp b/test/std/experimental/string.view/string.view.ops/substr.pass.cpp
new file mode 100644
index 000000000000..123646240f2e
--- /dev/null
+++ b/test/std/experimental/string.view/string.view.ops/substr.pass.cpp
@@ -0,0 +1,107 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+
+// <string_view>
+
+// constexpr basic_string_view substr(size_type pos = 0, size_type n = npos) const;
+
+// Throws: out_of_range if pos > size().
+// Effects: Determines the effective length rlen of the string to reference as the smaller of n and size() - pos.
+// Returns: basic_string_view(data()+pos, rlen).
+
+#include <experimental/string_view>
+#include <cassert>
+
+template<typename CharT>
+void test1 ( std::experimental::basic_string_view<CharT> sv, size_t n, size_t pos ) {
+ try {
+ std::experimental::basic_string_view<CharT> sv1 = sv.substr(pos, n);
+ const size_t rlen = std::min ( n, sv.size() - pos );
+ assert ( sv1.size() == rlen );
+ for ( size_t i = 0; i <= rlen; ++i )
+ assert ( sv[pos+i] == sv1[i] );
+ }
+ catch ( const std::out_of_range & ) { assert ( pos > sv.size()); }
+}
+
+
+template<typename CharT>
+void test ( const CharT *s ) {
+ typedef std::experimental::basic_string_view<CharT> string_view_t;
+
+ string_view_t sv1 ( s );
+
+ test1(sv1, 0, 0);
+ test1(sv1, 1, 0);
+ test1(sv1, 20, 0);
+ test1(sv1, sv1.size(), 0);
+
+ test1(sv1, 0, 3);
+ test1(sv1, 2, 3);
+ test1(sv1, 100, 3);
+
+ test1(sv1, 0, string_view_t::npos);
+ test1(sv1, 2, string_view_t::npos);
+ test1(sv1, sv1.size(), string_view_t::npos);
+
+ test1(sv1, sv1.size() + 1, 0);
+ test1(sv1, sv1.size() + 1, 1);
+ test1(sv1, sv1.size() + 1, string_view_t::npos);
+}
+
+int main () {
+ test ( "ABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDE" );
+ test ( "ABCDE");
+ test ( "a" );
+ test ( "" );
+
+ test ( L"ABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDE" );
+ test ( L"ABCDE" );
+ test ( L"a" );
+ test ( L"" );
+
+#if __cplusplus >= 201103L
+ test ( u"ABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDE" );
+ test ( u"ABCDE" );
+ test ( u"a" );
+ test ( u"" );
+
+ test ( U"ABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDE" );
+ test ( U"ABCDE" );
+ test ( U"a" );
+ test ( U"" );
+#endif
+
+#if _LIBCPP_STD_VER > 11
+ {
+ constexpr std::experimental::string_view sv1 { "ABCDE", 5 };
+
+ {
+ constexpr std::experimental::string_view sv2 = sv1.substr ( 0, 3 );
+ static_assert ( sv2.size() == 3, "" );
+ static_assert ( sv2[0] == 'A', "" );
+ static_assert ( sv2[1] == 'B', "" );
+ static_assert ( sv2[2] == 'C', "" );
+ }
+
+ {
+ constexpr std::experimental::string_view sv2 = sv1.substr ( 3, 0 );
+ static_assert ( sv2.size() == 0, "" );
+ }
+
+ {
+ constexpr std::experimental::string_view sv2 = sv1.substr ( 3, 3 );
+ static_assert ( sv2.size() == 2, "" );
+ static_assert ( sv2[0] == 'D', "" );
+ static_assert ( sv2[1] == 'E', "" );
+ }
+ }
+#endif
+}
diff --git a/test/std/experimental/string.view/string.view.ops/to_string.pass.cpp b/test/std/experimental/string.view/string.view.ops/to_string.pass.cpp
new file mode 100644
index 000000000000..a180ab257bf5
--- /dev/null
+++ b/test/std/experimental/string.view/string.view.ops/to_string.pass.cpp
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+
+// <string_view>
+
+// template<class Allocator>
+// explicit operator basic_string<_CharT, _Traits, Allocator> () const;
+// template<class _CharT, class _Traits = char_traits<_CharT>, class Allocator = allocator<_CharT> >
+// basic_string<_CharT, _Traits, Allocator> to_string (
+// basic_string_view<_CharT, _Traits> _sv, const Allocator& _a = Allocator()) const;
+
+#include <experimental/string_view>
+#include <cassert>
+#include "min_allocator.h"
+
+template<typename CharT>
+void test ( const CharT *s ) {
+ typedef std::basic_string<CharT> String ;
+ {
+ const std::experimental::basic_string_view<CharT> sv1 ( s );
+ String str1 = (String) sv1;
+
+ assert ( sv1.size() == str1.size ());
+ assert ( std::char_traits<CharT>::compare ( sv1.data(), str1.data(), sv1.size()) == 0 );
+
+#if __cplusplus >= 201103L
+ auto str2 = sv1.to_string(min_allocator<CharT>());
+ assert ( sv1.size() == str2.size ());
+ assert ( std::char_traits<CharT>::compare ( sv1.data(), str2.data(), sv1.size()) == 0 );
+#endif
+ }
+
+ {
+ const std::experimental::basic_string_view<CharT> sv1;
+ String str1 = (String) sv1;
+
+ assert ( sv1.size() == 0);
+ assert ( sv1.size() == str1.size ());
+
+#if __cplusplus >= 201103L
+ auto str2 = sv1.to_string(min_allocator<CharT>());
+ assert ( sv1.size() == str2.size ());
+#endif
+ }
+}
+
+int main () {
+ test ( "ABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDE" );
+ test ( "ABCDE");
+ test ( "a" );
+ test ( "" );
+
+ test ( L"ABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDE" );
+ test ( L"ABCDE" );
+ test ( L"a" );
+ test ( L"" );
+
+#if __cplusplus >= 201103L
+ test ( u"ABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDE" );
+ test ( u"ABCDE" );
+ test ( u"a" );
+ test ( u"" );
+
+ test ( U"ABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDE" );
+ test ( U"ABCDE" );
+ test ( U"a" );
+ test ( U"" );
+#endif
+}
diff --git a/test/std/experimental/string.view/string.view.synop/nothing_to_do.pass.cpp b/test/std/experimental/string.view/string.view.synop/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..c21f8a701685
--- /dev/null
+++ b/test/std/experimental/string.view/string.view.synop/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <experimental/string_view>
+
+int main () {}
diff --git a/test/std/experimental/string.view/string.view.template/nothing_to_do.pass.cpp b/test/std/experimental/string.view/string.view.template/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..c21f8a701685
--- /dev/null
+++ b/test/std/experimental/string.view/string.view.template/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <experimental/string_view>
+
+int main () {}
diff --git a/test/std/experimental/utilities/meta/meta.type.synop/includes.pass.cpp b/test/std/experimental/utilities/meta/meta.type.synop/includes.pass.cpp
new file mode 100644
index 000000000000..2c90dd641813
--- /dev/null
+++ b/test/std/experimental/utilities/meta/meta.type.synop/includes.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <experimental/type_traits>
+
+#include <experimental/type_traits>
+
+#if _LIBCPP_STD_VER > 11
+# ifndef _LIBCPP_TYPE_TRAITS
+# error "<experimental/type_traits> must include <type_traits>"
+# endif
+#endif
+
+int main()
+{
+}
diff --git a/test/std/experimental/utilities/meta/meta.type.synop/meta.rel.pass.cpp b/test/std/experimental/utilities/meta/meta.type.synop/meta.rel.pass.cpp
new file mode 100644
index 000000000000..96af4b676181
--- /dev/null
+++ b/test/std/experimental/utilities/meta/meta.type.synop/meta.rel.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <experimental/type_traits>
+
+#include <experimental/type_traits>
+
+#if _LIBCPP_STD_VER > 11
+
+namespace ex = std::experimental;
+
+struct base_type {};
+struct derived_type : base_type {};
+
+int main()
+{
+ {
+ typedef int T;
+ typedef int U;
+ static_assert(ex::is_same_v<T, U>, "");
+ static_assert(std::is_same<decltype(ex::is_same_v<T, U>), const bool>::value, "");
+ static_assert(ex::is_same_v<T, U> == std::is_same<T, U>::value, "");
+ }
+ {
+ typedef int T;
+ typedef long U;
+ static_assert(!ex::is_same_v<T, U>, "");
+ static_assert(ex::is_same_v<T, U> == std::is_same<T, U>::value, "");
+ }
+ {
+ typedef base_type T;
+ typedef derived_type U;
+ static_assert(ex::is_base_of_v<T, U>, "");
+ static_assert(std::is_same<decltype(ex::is_base_of_v<T, U>), const bool>::value, "");
+ static_assert(ex::is_base_of_v<T, U> == std::is_base_of<T, U>::value, "");
+ }
+ {
+ typedef int T;
+ typedef int U;
+ static_assert(!ex::is_base_of_v<T, U>, "");
+ static_assert(ex::is_base_of_v<T, U> == std::is_base_of<T, U>::value, "");
+ }
+ {
+ typedef int T;
+ typedef long U;
+ static_assert(ex::is_convertible_v<T, U>, "");
+ static_assert(std::is_same<decltype(ex::is_convertible_v<T, U>), const bool>::value, "");
+ static_assert(ex::is_convertible_v<T, U> == std::is_convertible<T, U>::value, "");
+ }
+ {
+ typedef void T;
+ typedef int U;
+ static_assert(!ex::is_convertible_v<T, U>, "");
+ static_assert(ex::is_convertible_v<T, U> == std::is_convertible<T, U>::value, "");
+ }
+}
+#else /* _LIBCPP_STD_VER <= 11 */
+int main() {}
+#endif /* _LIBCPP_STD_VER > 11 */
diff --git a/test/std/experimental/utilities/meta/meta.type.synop/meta.unary.cat.pass.cpp b/test/std/experimental/utilities/meta/meta.type.synop/meta.unary.cat.pass.cpp
new file mode 100644
index 000000000000..2d1e706f67d2
--- /dev/null
+++ b/test/std/experimental/utilities/meta/meta.type.synop/meta.unary.cat.pass.cpp
@@ -0,0 +1,181 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <experimental/type_traits>
+
+#include <experimental/type_traits>
+
+#if _LIBCPP_STD_VER > 11
+
+namespace ex = std::experimental;
+
+struct class_type {};
+enum enum_type {};
+union union_type {};
+
+int main()
+{
+ {
+ typedef void T;
+ static_assert(ex::is_void_v<T>, "");
+ static_assert(std::is_same<decltype(ex::is_void_v<T>), const bool>::value, "");
+ static_assert(ex::is_void_v<T> == std::is_void<T>::value, "");
+ }
+ {
+ typedef int T;
+ static_assert(!ex::is_void_v<T>, "");
+ static_assert(ex::is_void_v<T> == std::is_void<T>::value, "");
+ }
+ {
+ typedef decltype(nullptr) T;
+ static_assert(ex::is_null_pointer_v<T>, "");
+ static_assert(std::is_same<decltype(ex::is_null_pointer_v<T>), const bool>::value, "");
+ static_assert(ex::is_null_pointer_v<T> == std::is_null_pointer<T>::value, "");
+ }
+ {
+ typedef int T;
+ static_assert(!ex::is_null_pointer_v<T>, "");
+ static_assert(ex::is_null_pointer_v<T> == std::is_null_pointer<T>::value, "");
+ }
+ {
+ typedef int T;
+ static_assert(ex::is_integral_v<T>, "");
+ static_assert(std::is_same<decltype(ex::is_integral_v<T>), const bool>::value, "");
+ static_assert(ex::is_integral_v<T> == std::is_integral<T>::value, "");
+ }
+ {
+ typedef void T;
+ static_assert(!ex::is_integral_v<T>, "");
+ static_assert(ex::is_integral_v<T> == std::is_integral<T>::value, "");
+ }
+ {
+ typedef float T;
+ static_assert(ex::is_floating_point_v<T>, "");
+ static_assert(std::is_same<decltype(ex::is_floating_point_v<T>), const bool>::value, "");
+ static_assert(ex::is_floating_point_v<T> == std::is_floating_point<T>::value, "");
+ }
+ {
+ typedef int T;
+ static_assert(!ex::is_floating_point_v<T>, "");
+ static_assert(ex::is_floating_point_v<T> == std::is_floating_point<T>::value, "");
+ }
+ {
+ typedef int(T)[42];
+ static_assert(ex::is_array_v<T>, "");
+ static_assert(std::is_same<decltype(ex::is_array_v<T>), const bool>::value, "");
+ static_assert(ex::is_array_v<T> == std::is_array<T>::value, "");
+ }
+ {
+ typedef int T;
+ static_assert(!ex::is_array_v<T>, "");
+ static_assert(ex::is_array_v<T> == std::is_array<T>::value, "");
+ }
+ {
+ typedef void* T;
+ static_assert(ex::is_pointer_v<T>, "");
+ static_assert(std::is_same<decltype(ex::is_pointer_v<T>), const bool>::value, "");
+ static_assert(ex::is_pointer_v<T> == std::is_pointer<T>::value, "");
+ }
+ {
+ typedef int T;
+ static_assert(!ex::is_pointer_v<T>, "");
+ static_assert(ex::is_pointer_v<T> == std::is_pointer<T>::value, "");
+ }
+ {
+ typedef int & T;
+ static_assert(ex::is_lvalue_reference_v<T>, "");
+ static_assert(std::is_same<decltype(ex::is_lvalue_reference_v<T>), const bool>::value, "");
+ static_assert(ex::is_lvalue_reference_v<T> == std::is_lvalue_reference<T>::value, "");
+ }
+ {
+ typedef int T;
+ static_assert(!ex::is_lvalue_reference_v<T>, "");
+ static_assert(ex::is_lvalue_reference_v<T> == std::is_lvalue_reference<T>::value, "");
+ }
+ {
+ typedef int && T;
+ static_assert(ex::is_rvalue_reference_v<T>, "");
+ static_assert(std::is_same<decltype(ex::is_rvalue_reference_v<T>), const bool>::value, "");
+ static_assert(ex::is_rvalue_reference_v<T> == std::is_rvalue_reference<T>::value, "");
+ }
+ {
+ typedef int T;
+ static_assert(!ex::is_rvalue_reference_v<T>, "");
+ static_assert(ex::is_rvalue_reference_v<T> == std::is_rvalue_reference<T>::value, "");
+ }
+ {
+ typedef int class_type::*T;
+ static_assert(ex::is_member_object_pointer_v<T>, "");
+ static_assert(std::is_same<decltype(ex::is_member_object_pointer_v<T>), const bool>::value, "");
+ static_assert(ex::is_member_object_pointer_v<T> == std::is_member_object_pointer<T>::value, "");
+ }
+ {
+ typedef int T;
+ static_assert(!ex::is_member_object_pointer_v<T>, "");
+ static_assert(ex::is_member_object_pointer_v<T> == std::is_member_object_pointer<T>::value, "");
+ }
+ {
+ typedef void(class_type::*T)();
+ static_assert(ex::is_member_function_pointer_v<T>, "");
+ static_assert(std::is_same<decltype(ex::is_member_function_pointer_v<T>), const bool>::value, "");
+ static_assert(ex::is_member_function_pointer_v<T> == std::is_member_function_pointer<T>::value, "");
+ }
+ {
+ typedef int T;
+ static_assert(!ex::is_member_function_pointer_v<T>, "");
+ static_assert(ex::is_member_function_pointer_v<T> == std::is_member_function_pointer<T>::value, "");
+ }
+ {
+ typedef enum_type T;
+ static_assert(ex::is_enum_v<T>, "");
+ static_assert(std::is_same<decltype(ex::is_enum_v<T>), const bool>::value, "");
+ static_assert(ex::is_enum_v<T> == std::is_enum<T>::value, "");
+ }
+ {
+ typedef int T;
+ static_assert(!ex::is_enum_v<T>, "");
+ static_assert(ex::is_enum_v<T> == std::is_enum<T>::value, "");
+ }
+ {
+ typedef union_type T;
+ static_assert(ex::is_union_v<T>, "");
+ static_assert(std::is_same<decltype(ex::is_union_v<T>), const bool>::value, "");
+ static_assert(ex::is_union_v<T> == std::is_union<T>::value, "");
+ }
+ {
+ typedef int T;
+ static_assert(!ex::is_union_v<T>, "");
+ static_assert(ex::is_union_v<T> == std::is_union<T>::value, "");
+ }
+ {
+ typedef class_type T;
+ static_assert(ex::is_class_v<T>, "");
+ static_assert(std::is_same<decltype(ex::is_class_v<T>), const bool>::value, "");
+ static_assert(ex::is_class_v<T> == std::is_class<T>::value, "");
+ }
+ {
+ typedef int T;
+ static_assert(!ex::is_class_v<T>, "");
+ static_assert(ex::is_class_v<T> == std::is_class<T>::value, "");
+ }
+ {
+ typedef void(T)();
+ static_assert(ex::is_function_v<T>, "");
+ static_assert(std::is_same<decltype(ex::is_function_v<T>), const bool>::value, "");
+ static_assert(ex::is_function_v<T> == std::is_function<T>::value, "");
+ }
+ {
+ typedef int T;
+ static_assert(!ex::is_function_v<T>, "");
+ static_assert(ex::is_function_v<T> == std::is_function<T>::value, "");
+ }
+}
+#else /* _LIBCPP_STD_VER <= 11 */
+int main() {}
+#endif /* _LIBCPP_STD_VER > 11 */
diff --git a/test/std/experimental/utilities/meta/meta.type.synop/meta.unary.comp.pass.cpp b/test/std/experimental/utilities/meta/meta.type.synop/meta.unary.comp.pass.cpp
new file mode 100644
index 000000000000..814f450f4e07
--- /dev/null
+++ b/test/std/experimental/utilities/meta/meta.type.synop/meta.unary.comp.pass.cpp
@@ -0,0 +1,102 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <experimental/type_traits>
+
+#include <experimental/type_traits>
+
+#if _LIBCPP_STD_VER > 11
+
+namespace ex = std::experimental;
+
+struct class_type {};
+
+int main()
+{
+ {
+ typedef int & T;
+ static_assert(ex::is_reference_v<T>, "");
+ static_assert(std::is_same<decltype(ex::is_reference_v<T>), const bool>::value, "");
+ static_assert(ex::is_reference_v<T> == std::is_reference<T>::value, "");
+ }
+ {
+ typedef int T;
+ static_assert(!ex::is_reference_v<T>, "");
+ static_assert(ex::is_reference_v<T> == std::is_reference<T>::value, "");
+ }
+ {
+ typedef int T;
+ static_assert(ex::is_arithmetic_v<T>, "");
+ static_assert(std::is_same<decltype(ex::is_arithmetic_v<T>), const bool>::value, "");
+ static_assert(ex::is_arithmetic_v<T> == std::is_arithmetic<T>::value, "");
+ }
+ {
+ typedef void* T;
+ static_assert(!ex::is_arithmetic_v<T>, "");
+ static_assert(ex::is_arithmetic_v<T> == std::is_arithmetic<T>::value, "");
+ }
+ {
+ typedef int T;
+ static_assert(ex::is_fundamental_v<T>, "");
+ static_assert(std::is_same<decltype(ex::is_fundamental_v<T>), const bool>::value, "");
+ static_assert(ex::is_fundamental_v<T> == std::is_fundamental<T>::value, "");
+ }
+ {
+ typedef class_type T;
+ static_assert(!ex::is_fundamental_v<T>, "");
+ static_assert(ex::is_fundamental_v<T> == std::is_fundamental<T>::value, "");
+ }
+ {
+ typedef class_type T;
+ static_assert(ex::is_object_v<T>, "");
+ static_assert(std::is_same<decltype(ex::is_object_v<T>), const bool>::value, "");
+ static_assert(ex::is_object_v<T> == std::is_object<T>::value, "");
+ }
+ {
+ typedef void T;
+ static_assert(!ex::is_object_v<T>, "");
+ static_assert(ex::is_object_v<T> == std::is_object<T>::value, "");
+ }
+ {
+ typedef int T;
+ static_assert(ex::is_scalar_v<T>, "");
+ static_assert(std::is_same<decltype(ex::is_scalar_v<T>), const bool>::value, "");
+ static_assert(ex::is_scalar_v<T> == std::is_scalar<T>::value, "");
+ }
+ {
+ typedef void T;
+ static_assert(!ex::is_scalar_v<T>, "");
+ static_assert(ex::is_scalar_v<T> == std::is_scalar<T>::value, "");
+ }
+ {
+ typedef void* T;
+ static_assert(ex::is_compound_v<T>, "");
+ static_assert(std::is_same<decltype(ex::is_compound_v<T>), const bool>::value, "");
+ static_assert(ex::is_compound_v<T> == std::is_compound<T>::value, "");
+ }
+ {
+ typedef void T;
+ static_assert(!ex::is_compound_v<T>, "");
+ static_assert(ex::is_compound_v<T> == std::is_compound<T>::value, "");
+ }
+ {
+ typedef int class_type::*T;
+ static_assert(ex::is_member_pointer_v<T>, "");
+ static_assert(std::is_same<decltype(ex::is_member_pointer_v<T>), const bool>::value, "");
+ static_assert(ex::is_member_pointer_v<T> == std::is_member_pointer<T>::value, "");
+ }
+ {
+ typedef int T;
+ static_assert(!ex::is_member_pointer_v<T>, "");
+ static_assert(ex::is_member_pointer_v<T> == std::is_member_pointer<T>::value, "");
+ }
+}
+#else /* _LIBCPP_STD_VER <= 11 */
+int main() {}
+#endif /* _LIBCPP_STD_VER > 11 */
diff --git a/test/std/experimental/utilities/meta/meta.type.synop/meta.unary.prop.pass.cpp b/test/std/experimental/utilities/meta/meta.type.synop/meta.unary.prop.pass.cpp
new file mode 100644
index 000000000000..41cb27fced37
--- /dev/null
+++ b/test/std/experimental/utilities/meta/meta.type.synop/meta.unary.prop.pass.cpp
@@ -0,0 +1,489 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <experimental/type_traits>
+
+#include <experimental/type_traits>
+
+#if _LIBCPP_STD_VER > 11
+
+namespace ex = std::experimental;
+
+struct non_literal_type { non_literal_type() {} };
+struct empty_type {};
+
+struct polymorphic_type
+{
+ virtual void foo() {}
+};
+
+struct abstract_type
+{
+ virtual void foo() = 0;
+};
+
+struct final_type final {};
+
+struct virtual_dtor_type
+{
+ virtual ~virtual_dtor_type() {}
+};
+
+void type_properties_test()
+{
+ {
+ typedef const int T;
+ static_assert(ex::is_const_v<T>, "");
+ static_assert(std::is_same<decltype(ex::is_const_v<T>), const bool>::value, "");
+ static_assert(ex::is_const_v<T> == std::is_const<T>::value, "");
+ }
+ {
+ typedef int T;
+ static_assert(!ex::is_const_v<T>, "");
+ static_assert(ex::is_const_v<T> == std::is_const<T>::value, "");
+ }
+ {
+ typedef volatile int T;
+ static_assert(ex::is_volatile_v<T>, "");
+ static_assert(std::is_same<decltype(ex::is_volatile_v<T>), const bool>::value, "");
+ static_assert(ex::is_volatile_v<T> == std::is_volatile<T>::value, "");
+ }
+ {
+ typedef int T;
+ static_assert(!ex::is_volatile_v<T>, "");
+ static_assert(ex::is_volatile_v<T> == std::is_volatile<T>::value, "");
+ }
+ {
+ typedef int T;
+ static_assert(ex::is_trivial_v<T>, "");
+ static_assert(std::is_same<decltype(ex::is_trivial_v<T>), const bool>::value, "");
+ static_assert(ex::is_trivial_v<T> == std::is_trivial<T>::value, "");
+ }
+ {
+ typedef int & T;
+ static_assert(!ex::is_trivial_v<T>, "");
+ static_assert(ex::is_trivial_v<T> == std::is_trivial<T>::value, "");
+ }
+ {
+ typedef int T;
+ static_assert(ex::is_trivially_copyable_v<T>, "");
+ static_assert(std::is_same<decltype(ex::is_trivially_copyable_v<T>), const bool>::value, "");
+ static_assert(ex::is_trivially_copyable_v<T> == std::is_trivially_copyable<T>::value, "");
+ }
+ {
+ typedef int & T;
+ static_assert(!ex::is_trivially_copyable_v<T>, "");
+ static_assert(ex::is_trivially_copyable_v<T> == std::is_trivially_copyable<T>::value, "");
+ }
+ {
+ typedef int T;
+ static_assert(ex::is_standard_layout_v<T>, "");
+ static_assert(std::is_same<decltype(ex::is_standard_layout_v<T>), const bool>::value, "");
+ static_assert(ex::is_standard_layout_v<T> == std::is_standard_layout<T>::value, "");
+ }
+ {
+ typedef int & T;
+ static_assert(!ex::is_standard_layout_v<T>, "");
+ static_assert(ex::is_standard_layout_v<T> == std::is_standard_layout<T>::value, "");
+ }
+ {
+ typedef int T;
+ static_assert(ex::is_pod_v<T>, "");
+ static_assert(std::is_same<decltype(ex::is_pod_v<T>), const bool>::value, "");
+ static_assert(ex::is_pod_v<T> == std::is_pod<T>::value, "");
+ }
+ {
+ typedef int & T;
+ static_assert(!ex::is_pod_v<T>, "");
+ static_assert(ex::is_pod_v<T> == std::is_pod<T>::value, "");
+ }
+ {
+ typedef int T;
+ static_assert(ex::is_literal_type_v<T>, "");
+ static_assert(std::is_same<decltype(ex::is_literal_type_v<T>), const bool>::value, "");
+ static_assert(ex::is_literal_type_v<T> == std::is_literal_type<T>::value, "");
+ }
+ {
+ typedef non_literal_type T;
+ static_assert(!ex::is_literal_type_v<T>, "");
+ static_assert(ex::is_literal_type_v<T> == std::is_literal_type<T>::value, "");
+ }
+ {
+ typedef empty_type T;
+ static_assert(ex::is_empty_v<T>, "");
+ static_assert(std::is_same<decltype(ex::is_empty_v<T>), const bool>::value, "");
+ static_assert(ex::is_empty_v<T> == std::is_empty<T>::value, "");
+ }
+ {
+ typedef int T;
+ static_assert(!ex::is_empty_v<T>, "");
+ static_assert(ex::is_empty_v<T> == std::is_empty<T>::value, "");
+ }
+ {
+ typedef polymorphic_type T;
+ static_assert(ex::is_polymorphic_v<T>, "");
+ static_assert(std::is_same<decltype(ex::is_polymorphic_v<T>), const bool>::value, "");
+ static_assert(ex::is_polymorphic_v<T> == std::is_polymorphic<T>::value, "");
+ }
+ {
+ typedef int T;
+ static_assert(!ex::is_polymorphic_v<T>, "");
+ static_assert(ex::is_polymorphic_v<T> == std::is_polymorphic<T>::value, "");
+ }
+ {
+ typedef abstract_type T;
+ static_assert(ex::is_abstract_v<T>, "");
+ static_assert(std::is_same<decltype(ex::is_abstract_v<T>), const bool>::value, "");
+ static_assert(ex::is_abstract_v<T> == std::is_abstract<T>::value, "");
+ }
+ {
+ typedef int T;
+ static_assert(!ex::is_abstract_v<T>, "");
+ static_assert(ex::is_abstract_v<T> == std::is_abstract<T>::value, "");
+ }
+ {
+ typedef final_type T;
+ static_assert(ex::is_final_v<T>, "");
+ static_assert(std::is_same<decltype(ex::is_final_v<T>), const bool>::value, "");
+ static_assert(ex::is_final_v<T> == std::is_final<T>::value, "");
+ }
+ {
+ typedef int T;
+ static_assert(!ex::is_final_v<T>, "");
+ static_assert(ex::is_final_v<T> == std::is_final<T>::value, "");
+ }
+ {
+ typedef int T;
+ static_assert(ex::is_signed_v<T>, "");
+ static_assert(std::is_same<decltype(ex::is_signed_v<T>), const bool>::value, "");
+ static_assert(ex::is_signed_v<T> == std::is_signed<T>::value, "");
+ }
+ {
+ typedef unsigned T;
+ static_assert(!ex::is_signed_v<T>, "");
+ static_assert(ex::is_signed_v<T> == std::is_signed<T>::value, "");
+ }
+ {
+ typedef unsigned T;
+ static_assert(ex::is_unsigned_v<T>, "");
+ static_assert(std::is_same<decltype(ex::is_unsigned_v<T>), const bool>::value, "");
+ static_assert(ex::is_unsigned_v<T> == std::is_unsigned<T>::value, "");
+ }
+ {
+ typedef int T;
+ static_assert(!ex::is_unsigned_v<T>, "");
+ static_assert(ex::is_unsigned_v<T> == std::is_unsigned<T>::value, "");
+ }
+}
+
+void is_constructible_and_assignable_test()
+{
+ {
+ typedef int T;
+ static_assert(ex::is_constructible_v<T, int>, "");
+ static_assert(std::is_same<decltype(ex::is_constructible_v<T, int>), const bool>::value, "");
+ static_assert(ex::is_constructible_v<T, int> == std::is_constructible<T, int>::value, "");
+ }
+ {
+ typedef void T;
+ static_assert(!ex::is_constructible_v<T, int>, "");
+ static_assert(ex::is_constructible_v<T, int> == std::is_constructible<T, int>::value, "");
+ }
+ {
+ typedef int T;
+ static_assert(ex::is_default_constructible_v<T>, "");
+ static_assert(std::is_same<decltype(ex::is_default_constructible_v<T>), const bool>::value, "");
+ static_assert(ex::is_default_constructible_v<T> == std::is_default_constructible<T>::value, "");
+ }
+ {
+ typedef int & T;
+ static_assert(!ex::is_default_constructible_v<T>, "");
+ static_assert(ex::is_default_constructible_v<T> == std::is_default_constructible<T>::value, "");
+ }
+ {
+ typedef int T;
+ static_assert(ex::is_copy_constructible_v<T>, "");
+ static_assert(std::is_same<decltype(ex::is_copy_constructible_v<T>), const bool>::value, "");
+ static_assert(ex::is_copy_constructible_v<T> == std::is_copy_constructible<T>::value, "");
+ }
+ {
+ typedef void T;
+ static_assert(!ex::is_copy_constructible_v<T>, "");
+ static_assert(ex::is_copy_constructible_v<T> == std::is_copy_constructible<T>::value, "");
+ }
+ {
+ typedef int T;
+ static_assert(ex::is_move_constructible_v<T>, "");
+ static_assert(std::is_same<decltype(ex::is_move_constructible_v<T>), const bool>::value, "");
+ static_assert(ex::is_move_constructible_v<T> == std::is_move_constructible<T>::value, "");
+ }
+ {
+ typedef void T;
+ static_assert(!ex::is_move_constructible_v<T>, "");
+ static_assert(ex::is_move_constructible_v<T> == std::is_move_constructible<T>::value, "");
+ }
+ {
+ typedef int & T;
+ typedef int U;
+ static_assert(ex::is_assignable_v<T, U>, "");
+ static_assert(std::is_same<decltype(ex::is_assignable_v<T, U>), const bool>::value, "");
+ static_assert(ex::is_assignable_v<T, U> == std::is_assignable<T, U>::value, "");
+ }
+ {
+ typedef int & T;
+ typedef void U;
+ static_assert(!ex::is_assignable_v<T, U>, "");
+ static_assert(ex::is_assignable_v<T, U> == std::is_assignable<T, U>::value, "");
+ }
+ {
+ typedef int T;
+ static_assert(ex::is_copy_assignable_v<T>, "");
+ static_assert(std::is_same<decltype(ex::is_copy_assignable_v<T>), const bool>::value, "");
+ static_assert(ex::is_copy_assignable_v<T> == std::is_copy_assignable<T>::value, "");
+ }
+ {
+ typedef void T;
+ static_assert(!ex::is_copy_assignable_v<T>, "");
+ static_assert(ex::is_copy_assignable_v<T> == std::is_copy_assignable<T>::value, "");
+ }
+ {
+ typedef int T;
+ static_assert(ex::is_move_assignable_v<T>, "");
+ static_assert(std::is_same<decltype(ex::is_move_assignable_v<T>), const bool>::value, "");
+ static_assert(ex::is_move_assignable_v<T> == std::is_move_assignable<T>::value, "");
+ }
+ {
+ typedef void T;
+ static_assert(!ex::is_move_assignable_v<T>, "");
+ static_assert(ex::is_move_assignable_v<T> == std::is_move_assignable<T>::value, "");
+ }
+ {
+ typedef int T;
+ static_assert(ex::is_destructible_v<T>, "");
+ static_assert(std::is_same<decltype(ex::is_destructible_v<T>), const bool>::value, "");
+ static_assert(ex::is_destructible_v<T> == std::is_destructible<T>::value, "");
+ }
+ {
+ typedef void T;
+ static_assert(!ex::is_destructible_v<T>, "");
+ static_assert(ex::is_destructible_v<T> == std::is_destructible<T>::value, "");
+ }
+}
+
+void is_trivially_constructible_and_assignable_test()
+{
+ {
+ typedef int T;
+ static_assert(ex::is_trivially_constructible_v<T, int>, "");
+ static_assert(std::is_same<decltype(ex::is_trivially_constructible_v<T, int>), const bool>::value, "");
+ static_assert(ex::is_trivially_constructible_v<T, int> == std::is_constructible<T, int>::value, "");
+ }
+ {
+ typedef void T;
+ static_assert(!ex::is_trivially_constructible_v<T, int>, "");
+ static_assert(ex::is_trivially_constructible_v<T, int> == std::is_constructible<T, int>::value, "");
+ }
+ {
+ typedef int T;
+ static_assert(ex::is_trivially_default_constructible_v<T>, "");
+ static_assert(std::is_same<decltype(ex::is_trivially_default_constructible_v<T>), const bool>::value, "");
+ static_assert(ex::is_trivially_default_constructible_v<T> == std::is_default_constructible<T>::value, "");
+ }
+ {
+ typedef int & T;
+ static_assert(!ex::is_trivially_default_constructible_v<T>, "");
+ static_assert(ex::is_trivially_default_constructible_v<T> == std::is_default_constructible<T>::value, "");
+ }
+ {
+ typedef int T;
+ static_assert(ex::is_trivially_copy_constructible_v<T>, "");
+ static_assert(std::is_same<decltype(ex::is_trivially_copy_constructible_v<T>), const bool>::value, "");
+ static_assert(ex::is_trivially_copy_constructible_v<T> == std::is_copy_constructible<T>::value, "");
+ }
+ {
+ typedef void T;
+ static_assert(!ex::is_trivially_copy_constructible_v<T>, "");
+ static_assert(ex::is_trivially_copy_constructible_v<T> == std::is_copy_constructible<T>::value, "");
+ }
+ {
+ typedef int T;
+ static_assert(ex::is_trivially_move_constructible_v<T>, "");
+ static_assert(std::is_same<decltype(ex::is_trivially_move_constructible_v<T>), const bool>::value, "");
+ static_assert(ex::is_trivially_move_constructible_v<T> == std::is_move_constructible<T>::value, "");
+ }
+ {
+ typedef void T;
+ static_assert(!ex::is_trivially_move_constructible_v<T>, "");
+ static_assert(ex::is_trivially_move_constructible_v<T> == std::is_move_constructible<T>::value, "");
+ }
+ {
+ typedef int & T;
+ typedef int U;
+ static_assert(ex::is_trivially_assignable_v<T, U>, "");
+ static_assert(std::is_same<decltype(ex::is_trivially_assignable_v<T, U>), const bool>::value, "");
+ static_assert(ex::is_trivially_assignable_v<T, U> == std::is_assignable<T, U>::value, "");
+ }
+ {
+ typedef int & T;
+ typedef void U;
+ static_assert(!ex::is_trivially_assignable_v<T, U>, "");
+ static_assert(ex::is_trivially_assignable_v<T, U> == std::is_assignable<T, U>::value, "");
+ }
+ {
+ typedef int T;
+ static_assert(ex::is_trivially_copy_assignable_v<T>, "");
+ static_assert(std::is_same<decltype(ex::is_trivially_copy_assignable_v<T>), const bool>::value, "");
+ static_assert(ex::is_trivially_copy_assignable_v<T> == std::is_copy_assignable<T>::value, "");
+ }
+ {
+ typedef void T;
+ static_assert(!ex::is_trivially_copy_assignable_v<T>, "");
+ static_assert(ex::is_trivially_copy_assignable_v<T> == std::is_copy_assignable<T>::value, "");
+ }
+ {
+ typedef int T;
+ static_assert(ex::is_trivially_move_assignable_v<T>, "");
+ static_assert(std::is_same<decltype(ex::is_trivially_move_assignable_v<T>), const bool>::value, "");
+ static_assert(ex::is_trivially_move_assignable_v<T> == std::is_move_assignable<T>::value, "");
+ }
+ {
+ typedef void T;
+ static_assert(!ex::is_trivially_move_assignable_v<T>, "");
+ static_assert(ex::is_trivially_move_assignable_v<T> == std::is_move_assignable<T>::value, "");
+ }
+ {
+ typedef int T;
+ static_assert(ex::is_trivially_destructible_v<T>, "");
+ static_assert(std::is_same<decltype(ex::is_trivially_destructible_v<T>), const bool>::value, "");
+ static_assert(ex::is_trivially_destructible_v<T> == std::is_destructible<T>::value, "");
+ }
+ {
+ typedef void T;
+ static_assert(!ex::is_trivially_destructible_v<T>, "");
+ static_assert(ex::is_trivially_destructible_v<T> == std::is_destructible<T>::value, "");
+ }
+}
+
+
+
+void is_nothrow_constructible_and_assignable_test()
+{
+ {
+ typedef int T;
+ static_assert(ex::is_nothrow_constructible_v<T, int>, "");
+ static_assert(std::is_same<decltype(ex::is_nothrow_constructible_v<T, int>), const bool>::value, "");
+ static_assert(ex::is_nothrow_constructible_v<T, int> == std::is_constructible<T, int>::value, "");
+ }
+ {
+ typedef void T;
+ static_assert(!ex::is_nothrow_constructible_v<T, int>, "");
+ static_assert(ex::is_nothrow_constructible_v<T, int> == std::is_constructible<T, int>::value, "");
+ }
+ {
+ typedef int T;
+ static_assert(ex::is_nothrow_default_constructible_v<T>, "");
+ static_assert(std::is_same<decltype(ex::is_nothrow_default_constructible_v<T>), const bool>::value, "");
+ static_assert(ex::is_nothrow_default_constructible_v<T> == std::is_default_constructible<T>::value, "");
+ }
+ {
+ typedef int & T;
+ static_assert(!ex::is_nothrow_default_constructible_v<T>, "");
+ static_assert(ex::is_nothrow_default_constructible_v<T> == std::is_default_constructible<T>::value, "");
+ }
+ {
+ typedef int T;
+ static_assert(ex::is_nothrow_copy_constructible_v<T>, "");
+ static_assert(std::is_same<decltype(ex::is_nothrow_copy_constructible_v<T>), const bool>::value, "");
+ static_assert(ex::is_nothrow_copy_constructible_v<T> == std::is_copy_constructible<T>::value, "");
+ }
+ {
+ typedef void T;
+ static_assert(!ex::is_nothrow_copy_constructible_v<T>, "");
+ static_assert(ex::is_nothrow_copy_constructible_v<T> == std::is_copy_constructible<T>::value, "");
+ }
+ {
+ typedef int T;
+ static_assert(ex::is_nothrow_move_constructible_v<T>, "");
+ static_assert(std::is_same<decltype(ex::is_nothrow_move_constructible_v<T>), const bool>::value, "");
+ static_assert(ex::is_nothrow_move_constructible_v<T> == std::is_move_constructible<T>::value, "");
+ }
+ {
+ typedef void T;
+ static_assert(!ex::is_nothrow_move_constructible_v<T>, "");
+ static_assert(ex::is_nothrow_move_constructible_v<T> == std::is_move_constructible<T>::value, "");
+ }
+ {
+ typedef int & T;
+ typedef int U;
+ static_assert(ex::is_nothrow_assignable_v<T, U>, "");
+ static_assert(std::is_same<decltype(ex::is_nothrow_assignable_v<T, U>), const bool>::value, "");
+ static_assert(ex::is_nothrow_assignable_v<T, U> == std::is_assignable<T, U>::value, "");
+ }
+ {
+ typedef int & T;
+ typedef void U;
+ static_assert(!ex::is_nothrow_assignable_v<T, U>, "");
+ static_assert(ex::is_nothrow_assignable_v<T, U> == std::is_assignable<T, U>::value, "");
+ }
+ {
+ typedef int T;
+ static_assert(ex::is_nothrow_copy_assignable_v<T>, "");
+ static_assert(std::is_same<decltype(ex::is_nothrow_copy_assignable_v<T>), const bool>::value, "");
+ static_assert(ex::is_nothrow_copy_assignable_v<T> == std::is_copy_assignable<T>::value, "");
+ }
+ {
+ typedef void T;
+ static_assert(!ex::is_nothrow_copy_assignable_v<T>, "");
+ static_assert(ex::is_nothrow_copy_assignable_v<T> == std::is_copy_assignable<T>::value, "");
+ }
+ {
+ typedef int T;
+ static_assert(ex::is_nothrow_move_assignable_v<T>, "");
+ static_assert(std::is_same<decltype(ex::is_nothrow_move_assignable_v<T>), const bool>::value, "");
+ static_assert(ex::is_nothrow_move_assignable_v<T> == std::is_move_assignable<T>::value, "");
+ }
+ {
+ typedef void T;
+ static_assert(!ex::is_nothrow_move_assignable_v<T>, "");
+ static_assert(ex::is_nothrow_move_assignable_v<T> == std::is_move_assignable<T>::value, "");
+ }
+ {
+ typedef int T;
+ static_assert(ex::is_nothrow_destructible_v<T>, "");
+ static_assert(std::is_same<decltype(ex::is_nothrow_destructible_v<T>), const bool>::value, "");
+ static_assert(ex::is_nothrow_destructible_v<T> == std::is_destructible<T>::value, "");
+ }
+ {
+ typedef void T;
+ static_assert(!ex::is_nothrow_destructible_v<T>, "");
+ static_assert(ex::is_nothrow_destructible_v<T> == std::is_destructible<T>::value, "");
+ }
+}
+
+int main()
+{
+ type_properties_test();
+ is_constructible_and_assignable_test();
+ is_trivially_constructible_and_assignable_test();
+ is_nothrow_constructible_and_assignable_test();
+ {
+ typedef virtual_dtor_type T;
+ static_assert(ex::has_virtual_destructor_v<T>, "");
+ static_assert(std::is_same<decltype(ex::has_virtual_destructor_v<T>), const bool>::value, "");
+ static_assert(ex::has_virtual_destructor_v<T> == std::has_virtual_destructor<T>::value, "");
+ }
+ {
+ typedef int T;
+ static_assert(!ex::has_virtual_destructor_v<T>, "");
+ static_assert(ex::has_virtual_destructor_v<T> == std::has_virtual_destructor<T>::value, "");
+ }
+}
+#else /* _LIBCPP_STD_VER <= 11 */
+int main() {}
+#endif /* _LIBCPP_STD_VER > 11 */
diff --git a/test/std/experimental/utilities/meta/meta.type.synop/meta.unary.prop.query.pass.cpp b/test/std/experimental/utilities/meta/meta.type.synop/meta.unary.prop.query.pass.cpp
new file mode 100644
index 000000000000..aedd369e5ac8
--- /dev/null
+++ b/test/std/experimental/utilities/meta/meta.type.synop/meta.unary.prop.query.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <experimental/type_traits>
+
+#include <experimental/type_traits>
+
+#if _LIBCPP_STD_VER > 11
+
+namespace ex = std::experimental;
+
+int main()
+{
+ {
+ typedef char T;
+ static_assert(ex::alignment_of_v<T> == 1, "");
+ static_assert(std::is_same<decltype(ex::alignment_of_v<T>), const std::size_t>::value, "");
+ static_assert(ex::alignment_of_v<T> == std::alignment_of<T>::value, "");
+ }
+ {
+ typedef char(T)[1][1][1];
+ static_assert(ex::rank_v<T> == 3, "");
+ static_assert(std::is_same<decltype(ex::rank_v<T>), const std::size_t>::value, "");
+ static_assert(ex::rank_v<T> == std::rank<T>::value, "");
+ }
+ {
+ typedef void T;
+ static_assert(ex::rank_v<T> == 0, "");
+ static_assert(ex::rank_v<T> == std::rank<T>::value, "");
+ }
+ {
+ typedef char(T)[2][3][4];
+ static_assert(ex::extent_v<T> == 2, "");
+ static_assert(std::is_same<decltype(ex::extent_v<T>), const std::size_t>::value, "");
+ static_assert(ex::extent_v<T> == std::extent<T>::value, "");
+ }
+ {
+ typedef char(T)[2][3][4];
+ static_assert(ex::extent_v<T, 0> == 2, "");
+ static_assert(ex::extent_v<T, 0> == std::extent<T, 0>::value, "");
+ }
+ {
+ typedef char(T)[2][3][4];
+ static_assert(ex::extent_v<T, 1> == 3, "");
+ static_assert(ex::extent_v<T, 1> == std::extent<T, 1>::value, "");
+ }
+ {
+ typedef char(T)[2][3][4];
+ static_assert(ex::extent_v<T, 5> == 0, "");
+ static_assert(ex::extent_v<T, 5> == std::extent<T, 5>::value, "");
+ }
+ {
+ typedef void T;
+ static_assert(ex::extent_v<T, 0> == 0, "");
+ static_assert(ex::extent_v<T, 0> == std::extent<T, 0>::value, "");
+ }
+}
+#else /* _LIBCPP_STD_VER <= 11 */
+int main() {}
+#endif /* _LIBCPP_STD_VER > 11 */
diff --git a/test/std/experimental/utilities/meta/version.pass.cpp b/test/std/experimental/utilities/meta/version.pass.cpp
new file mode 100644
index 000000000000..593fb52a4c3b
--- /dev/null
+++ b/test/std/experimental/utilities/meta/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <experimental/type_traits>
+
+#include <experimental/type_traits>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/experimental/utilities/nothing_to_do.pass.cpp b/test/std/experimental/utilities/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..9a59227abdd9
--- /dev/null
+++ b/test/std/experimental/utilities/nothing_to_do.pass.cpp
@@ -0,0 +1,13 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/experimental/utilities/ratio/header.ratio.synop/includes.pass.cpp b/test/std/experimental/utilities/ratio/header.ratio.synop/includes.pass.cpp
new file mode 100644
index 000000000000..f19a8211cdac
--- /dev/null
+++ b/test/std/experimental/utilities/ratio/header.ratio.synop/includes.pass.cpp
@@ -0,0 +1,21 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11
+
+// <experimental/ratio>
+
+// Test that <ratio> is included.
+
+#include <experimental/ratio>
+
+int main()
+{
+ std::ratio<100> x;
+}
diff --git a/test/std/experimental/utilities/ratio/header.ratio.synop/ratio_equal_v.pass.cpp b/test/std/experimental/utilities/ratio/header.ratio.synop/ratio_equal_v.pass.cpp
new file mode 100644
index 000000000000..641e6ae22cc8
--- /dev/null
+++ b/test/std/experimental/utilities/ratio/header.ratio.synop/ratio_equal_v.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11
+
+// <experimental/ratio>
+
+// template <class R1, class R2> constexpr bool ratio_equal_v;
+
+#include <experimental/ratio>
+#include <type_traits>
+
+namespace ex = std::experimental;
+
+int main()
+{
+ {
+ typedef std::ratio<1, 1> R1;
+ typedef std::ratio<1, 1> R2;
+ static_assert(
+ ex::ratio_equal_v<R1, R2>, ""
+ );
+ static_assert(
+ ex::ratio_equal_v<R1, R2> == std::ratio_equal<R1, R2>::value, ""
+ );
+ static_assert(
+ std::is_same<decltype(ex::ratio_equal_v<R1, R2>), const bool>::value
+ , ""
+ );
+ }
+ {
+ typedef std::ratio<1, 1> R1;
+ typedef std::ratio<1, -1> R2;
+ static_assert(
+ !ex::ratio_equal_v<R1, R2>, ""
+ );
+ static_assert(
+ ex::ratio_equal_v<R1, R2> == std::ratio_equal<R1, R2>::value, ""
+ );
+ }
+}
diff --git a/test/std/experimental/utilities/ratio/header.ratio.synop/ratio_greater_equal_v.pass.cpp b/test/std/experimental/utilities/ratio/header.ratio.synop/ratio_greater_equal_v.pass.cpp
new file mode 100644
index 000000000000..3896d0ac64dc
--- /dev/null
+++ b/test/std/experimental/utilities/ratio/header.ratio.synop/ratio_greater_equal_v.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11
+
+// <experimental/ratio>
+
+// template <class R1, class R2> constexpr bool ratio_greater_equal_v;
+
+#include <experimental/ratio>
+#include <type_traits>
+
+namespace ex = std::experimental;
+
+int main()
+{
+ {
+ typedef std::ratio<1, 2> R1;
+ typedef std::ratio<1, 1> R2;
+ static_assert(
+ !ex::ratio_greater_equal_v<R1, R2>, ""
+ );
+ static_assert(
+ ex::ratio_greater_equal_v<R1, R2>
+ == std::ratio_greater_equal<R1, R2>::value, ""
+ );
+ static_assert(
+ std::is_same<
+ decltype(ex::ratio_greater_equal_v<R1, R2>), const bool>::value
+ , ""
+ );
+ }
+ {
+ typedef std::ratio<1, 1> R1;
+ typedef std::ratio<1, 1> R2;
+ static_assert(
+ ex::ratio_greater_equal_v<R1, R2>, ""
+ );
+ static_assert(
+ ex::ratio_greater_equal_v<R1, R2>
+ == std::ratio_greater_equal<R1, R2>::value, ""
+ );
+ }
+ {
+ typedef std::ratio<2, 1> R1;
+ typedef std::ratio<1, 1> R2;
+ static_assert(
+ ex::ratio_greater_equal_v<R1, R2>, ""
+ );
+ static_assert(
+ ex::ratio_greater_equal_v<R1, R2>
+ == std::ratio_greater_equal<R1, R2>::value, ""
+ );
+ }
+}
diff --git a/test/std/experimental/utilities/ratio/header.ratio.synop/ratio_greater_v.pass.cpp b/test/std/experimental/utilities/ratio/header.ratio.synop/ratio_greater_v.pass.cpp
new file mode 100644
index 000000000000..bdc54515f629
--- /dev/null
+++ b/test/std/experimental/utilities/ratio/header.ratio.synop/ratio_greater_v.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11
+
+// <experimental/ratio>
+
+// template <class R1, class R2> constexpr bool ratio_greater_v;
+
+#include <experimental/ratio>
+#include <type_traits>
+
+namespace ex = std::experimental;
+
+int main()
+{
+ {
+ typedef std::ratio<1, 2> R1;
+ typedef std::ratio<1, 1> R2;
+ static_assert(
+ !ex::ratio_greater_v<R1, R2>, ""
+ );
+ static_assert(
+ ex::ratio_greater_v<R1, R2> == std::ratio_greater<R1, R2>::value, ""
+ );
+ static_assert(
+ std::is_same<decltype(ex::ratio_greater_v<R1, R2>), const bool>::value
+ , ""
+ );
+ }
+ {
+ typedef std::ratio<1, 1> R1;
+ typedef std::ratio<1, 1> R2;
+ static_assert(
+ !ex::ratio_greater_v<R1, R2>, ""
+ );
+ static_assert(
+ ex::ratio_greater_v<R1, R2> == std::ratio_greater<R1, R2>::value, ""
+ );
+ }
+ {
+ typedef std::ratio<2, 1> R1;
+ typedef std::ratio<1, 1> R2;
+ static_assert(
+ ex::ratio_greater_v<R1, R2>, ""
+ );
+ static_assert(
+ ex::ratio_greater_v<R1, R2> == std::ratio_greater<R1, R2>::value, ""
+ );
+ }
+}
diff --git a/test/std/experimental/utilities/ratio/header.ratio.synop/ratio_less_equal_v.pass.cpp b/test/std/experimental/utilities/ratio/header.ratio.synop/ratio_less_equal_v.pass.cpp
new file mode 100644
index 000000000000..50f213b01339
--- /dev/null
+++ b/test/std/experimental/utilities/ratio/header.ratio.synop/ratio_less_equal_v.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11
+
+// <experimental/ratio>
+
+// template <class R1, class R2> constexpr bool ratio_less_equal_v;
+
+#include <experimental/ratio>
+#include <type_traits>
+
+namespace ex = std::experimental;
+
+int main()
+{
+ {
+ typedef std::ratio<1, 2> R1;
+ typedef std::ratio<1, 1> R2;
+ static_assert(
+ ex::ratio_less_equal_v<R1, R2>, ""
+ );
+ static_assert(
+ ex::ratio_less_equal_v<R1, R2> == std::ratio_less_equal<R1, R2>::value, ""
+ );
+ static_assert(
+ std::is_same<decltype(ex::ratio_less_equal_v<R1, R2>), const bool>::value
+ , ""
+ );
+ }
+ {
+ typedef std::ratio<1, 1> R1;
+ typedef std::ratio<1, 1> R2;
+ static_assert(
+ ex::ratio_less_equal_v<R1, R2>, ""
+ );
+ static_assert(
+ ex::ratio_less_equal_v<R1, R2> == std::ratio_less_equal<R1, R2>::value, ""
+ );
+ }
+ {
+ typedef std::ratio<2, 1> R1;
+ typedef std::ratio<1, 1> R2;
+ static_assert(
+ !ex::ratio_less_equal_v<R1, R2>, ""
+ );
+ static_assert(
+ ex::ratio_less_equal_v<R1, R2> == std::ratio_less_equal<R1, R2>::value, ""
+ );
+ }
+}
diff --git a/test/std/experimental/utilities/ratio/header.ratio.synop/ratio_less_v.pass.cpp b/test/std/experimental/utilities/ratio/header.ratio.synop/ratio_less_v.pass.cpp
new file mode 100644
index 000000000000..7a6d7738bd9d
--- /dev/null
+++ b/test/std/experimental/utilities/ratio/header.ratio.synop/ratio_less_v.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11
+
+// <experimental/ratio>
+
+// template <class R1, class R2> constexpr bool ratio_less_v;
+
+#include <experimental/ratio>
+#include <type_traits>
+
+namespace ex = std::experimental;
+
+int main()
+{
+ {
+ typedef std::ratio<1, 2> R1;
+ typedef std::ratio<1, 1> R2;
+ static_assert(
+ ex::ratio_less_v<R1, R2>, ""
+ );
+ static_assert(
+ ex::ratio_less_v<R1, R2> == std::ratio_less<R1, R2>::value, ""
+ );
+ static_assert(
+ std::is_same<decltype(ex::ratio_less_v<R1, R2>), const bool>::value
+ , ""
+ );
+ }
+ {
+ typedef std::ratio<1, 1> R1;
+ typedef std::ratio<1, 1> R2;
+ static_assert(
+ !ex::ratio_less_v<R1, R2>, ""
+ );
+ static_assert(
+ ex::ratio_less_v<R1, R2> == std::ratio_less<R1, R2>::value, ""
+ );
+ }
+ {
+ typedef std::ratio<2, 1> R1;
+ typedef std::ratio<1, 1> R2;
+ static_assert(
+ !ex::ratio_less_v<R1, R2>, ""
+ );
+ static_assert(
+ ex::ratio_less_v<R1, R2> == std::ratio_less<R1, R2>::value, ""
+ );
+ }
+}
diff --git a/test/std/experimental/utilities/ratio/header.ratio.synop/ratio_not_equal_v.pass.cpp b/test/std/experimental/utilities/ratio/header.ratio.synop/ratio_not_equal_v.pass.cpp
new file mode 100644
index 000000000000..b5296ff24ef1
--- /dev/null
+++ b/test/std/experimental/utilities/ratio/header.ratio.synop/ratio_not_equal_v.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11
+
+// <experimental/ratio>
+
+// template <class R1, class R2> constexpr bool ratio_not_equal_v;
+
+#include <experimental/ratio>
+#include <type_traits>
+
+namespace ex = std::experimental;
+
+int main()
+{
+ {
+ typedef std::ratio<1, 1> R1;
+ typedef std::ratio<1, -1> R2;
+ static_assert(
+ ex::ratio_not_equal_v<R1, R2>, ""
+ );
+ static_assert(
+ ex::ratio_not_equal_v<R1, R2> == std::ratio_not_equal<R1, R2>::value, ""
+ );
+ static_assert(
+ std::is_same<decltype(ex::ratio_not_equal_v<R1, R2>), const bool>::value
+ , ""
+ );
+ }
+ {
+ typedef std::ratio<1, 1> R1;
+ typedef std::ratio<1, 1> R2;
+ static_assert(
+ !ex::ratio_not_equal_v<R1, R2>, ""
+ );
+ static_assert(
+ ex::ratio_not_equal_v<R1, R2> == std::ratio_not_equal<R1, R2>::value, ""
+ );
+ }
+}
diff --git a/test/std/experimental/utilities/ratio/nothing_to_do.pass.cpp b/test/std/experimental/utilities/ratio/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..9a59227abdd9
--- /dev/null
+++ b/test/std/experimental/utilities/ratio/nothing_to_do.pass.cpp
@@ -0,0 +1,13 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/experimental/utilities/syserror/header.system_error.synop/includes.pass.cpp b/test/std/experimental/utilities/syserror/header.system_error.synop/includes.pass.cpp
new file mode 100644
index 000000000000..de813925f218
--- /dev/null
+++ b/test/std/experimental/utilities/syserror/header.system_error.synop/includes.pass.cpp
@@ -0,0 +1,21 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11
+
+// <experimental/system_error>
+
+#include <experimental/system_error>
+
+int main()
+{
+ // Check that <system_error> has been included
+ std::error_code ec;
+ ((void)ec);
+}
diff --git a/test/std/experimental/utilities/syserror/header.system_error.synop/is_error_code_enum_v.pass.cpp b/test/std/experimental/utilities/syserror/header.system_error.synop/is_error_code_enum_v.pass.cpp
new file mode 100644
index 000000000000..f944123ebc06
--- /dev/null
+++ b/test/std/experimental/utilities/syserror/header.system_error.synop/is_error_code_enum_v.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11
+
+// <experimental/system_error>
+
+// template <class T> constexpr bool is_error_code_enum_v;
+
+#include <experimental/system_error>
+#include <ios> /* for std::io_errc */
+
+namespace ex = std::experimental;
+
+int main() {
+ {
+ static_assert(ex::is_error_code_enum_v<std::io_errc>, "");
+
+ static_assert(ex::is_error_code_enum_v<std::io_errc> ==
+ std::is_error_code_enum <std::io_errc>::value, "");
+
+ static_assert(std::is_same<decltype(ex::is_error_code_enum_v<std::io_errc>),
+ const bool>::value, "");
+ }
+ {
+ static_assert(!ex::is_error_code_enum_v<int>, "");
+
+ static_assert(ex::is_error_code_enum_v<int> ==
+ std::is_error_code_enum <int>::value, "");
+ }
+}
diff --git a/test/std/experimental/utilities/syserror/header.system_error.synop/is_error_condition_enum.pass.cpp b/test/std/experimental/utilities/syserror/header.system_error.synop/is_error_condition_enum.pass.cpp
new file mode 100644
index 000000000000..ee8dc57aa9db
--- /dev/null
+++ b/test/std/experimental/utilities/syserror/header.system_error.synop/is_error_condition_enum.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11
+
+// <experimental/system_error>
+
+// template <class T> constexpr bool is_error_condition_enum_v;
+
+#include <experimental/system_error>
+#include <type_traits>
+namespace ex = std::experimental;
+
+int main() {
+ {
+ static_assert(ex::is_error_condition_enum_v<std::errc>, "");
+
+ static_assert(ex::is_error_condition_enum_v<std::errc> ==
+ std::is_error_condition_enum <std::errc>::value, "");
+
+ static_assert(
+ std::is_same<decltype(ex::is_error_condition_enum_v<std::errc>),
+ const bool>::value,
+ "");
+ }
+ {
+ static_assert(!ex::is_error_condition_enum_v<int>, "");
+
+ static_assert(ex::is_error_condition_enum_v<int> ==
+ std::is_error_condition_enum <int>::value, "");
+ }
+}
diff --git a/test/std/experimental/utilities/time/header.chrono.synop/includes.pass.cpp b/test/std/experimental/utilities/time/header.chrono.synop/includes.pass.cpp
new file mode 100644
index 000000000000..f6ad37f9ee3e
--- /dev/null
+++ b/test/std/experimental/utilities/time/header.chrono.synop/includes.pass.cpp
@@ -0,0 +1,19 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <experimental/chrono>
+
+#include <experimental/chrono>
+
+int main()
+{
+ // Check that <chrono> has been included.
+ std::chrono::seconds s;
+ ((void)s);
+}
diff --git a/test/std/experimental/utilities/time/header.chrono.synop/treat_as_floating_point_v.pass.cpp b/test/std/experimental/utilities/time/header.chrono.synop/treat_as_floating_point_v.pass.cpp
new file mode 100644
index 000000000000..9ac9a2ed1c83
--- /dev/null
+++ b/test/std/experimental/utilities/time/header.chrono.synop/treat_as_floating_point_v.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11
+
+// <experimental/chrono>
+
+// template <class Rep> constexpr bool treat_as_floating_point_v;
+
+#include <experimental/chrono>
+#include <type_traits>
+
+namespace ex = std::chrono::experimental;
+namespace cr = std::chrono;
+
+template <class T, bool Expect>
+void test()
+{
+ static_assert(
+ ex::treat_as_floating_point_v<T> == Expect, ""
+ );
+ static_assert(
+ ex::treat_as_floating_point_v<T> == cr::treat_as_floating_point<T>::value, ""
+ );
+}
+
+int main()
+{
+ {
+ static_assert(
+ std::is_same<
+ decltype(ex::treat_as_floating_point_v<float>), const bool
+ >::value, ""
+ );
+ }
+ test<int, false>();
+ test<unsigned, false>();
+ test<char, false>();
+ test<bool, false>();
+ test<float, true>();
+ test<double, true>();
+ test<long double, true>();
+}
diff --git a/test/std/experimental/utilities/tuple/header.tuple.synop/includes.pass.cpp b/test/std/experimental/utilities/tuple/header.tuple.synop/includes.pass.cpp
new file mode 100644
index 000000000000..d37557a7b172
--- /dev/null
+++ b/test/std/experimental/utilities/tuple/header.tuple.synop/includes.pass.cpp
@@ -0,0 +1,19 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11
+
+// <experimental/tuple>
+
+#include <experimental/tuple>
+
+int main()
+{
+ std::tuple<int> x(1);
+}
diff --git a/test/std/experimental/utilities/tuple/tuple.apply/arg_type.pass.cpp b/test/std/experimental/utilities/tuple/tuple.apply/arg_type.pass.cpp
new file mode 100644
index 000000000000..56dc3c6aaa25
--- /dev/null
+++ b/test/std/experimental/utilities/tuple/tuple.apply/arg_type.pass.cpp
@@ -0,0 +1,182 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11
+
+// <experimental/tuple>
+
+// template <class F, class T> constexpr decltype(auto) apply(F &&, T &&)
+
+// Test with different ref/ptr/cv qualified argument types.
+
+#include <experimental/tuple>
+#include <array>
+#include <utility>
+#include <cassert>
+
+namespace ex = std::experimental;
+
+int call_with_value(int x, int y) { return (x + y); }
+int call_with_ref(int & x, int & y) { return (x + y); }
+int call_with_const_ref(int const & x, int const & y) { return (x + y); }
+int call_with_rvalue_ref(int && x, int && y) { return (x + y); }
+int call_with_pointer(int * x, int * y) { return (*x + *y); }
+int call_with_const_pointer(int const* x, int const * y) { return (*x + *y); }
+
+
+template <class Tuple>
+void test_values()
+{
+ {
+ Tuple t{1, 2};
+ assert(3 == ex::apply(call_with_value, t));
+ }
+ {
+ Tuple t{2, 2};
+ assert(4 == ex::apply(call_with_ref, t));
+ }
+ {
+ Tuple t{2, 3};
+ assert(5 == ex::apply(call_with_const_ref, t));
+ }
+ {
+ Tuple t{3, 3};
+ assert(6 == ex::apply(call_with_rvalue_ref, static_cast<Tuple &&>(t)));
+ }
+ {
+ Tuple const t{4, 4};
+ assert(8 == ex::apply(call_with_value, t));
+ }
+ {
+ Tuple const t{4, 5};
+ assert(9 == ex::apply(call_with_const_ref, t));
+ }
+}
+
+template <class Tuple>
+void test_refs()
+{
+ int x = 0;
+ int y = 0;
+ {
+ x = 1; y = 2;
+ Tuple t{x, y};
+ assert(3 == ex::apply(call_with_value, t));
+ }
+ {
+ x = 2; y = 2;
+ Tuple t{x, y};
+ assert(4 == ex::apply(call_with_ref, t));
+ }
+ {
+ x = 2; y = 3;
+ Tuple t{x, y};
+ assert(5 == ex::apply(call_with_const_ref, t));
+ }
+ {
+ x = 3; y = 3;
+ Tuple const t{x, y};
+ assert(6 == ex::apply(call_with_value, t));
+ }
+ {
+ x = 3; y = 4;
+ Tuple const t{x, y};
+ assert(7 == ex::apply(call_with_const_ref, t));
+ }
+}
+
+template <class Tuple>
+void test_const_refs()
+{
+ int x = 0;
+ int y = 0;
+ {
+ x = 1; y = 2;
+ Tuple t{x, y};
+ assert(3 == ex::apply(call_with_value, t));
+ }
+ {
+ x = 2; y = 3;
+ Tuple t{x, y};
+ assert(5 == ex::apply(call_with_const_ref, t));
+ }
+ {
+ x = 3; y = 3;
+ Tuple const t{x, y};
+ assert(6 == ex::apply(call_with_value, t));
+ }
+ {
+ x = 3; y = 4;
+ Tuple const t{x, y};
+ assert(7 == ex::apply(call_with_const_ref, t));
+ }
+}
+
+
+template <class Tuple>
+void test_pointer()
+{
+ int x = 0;
+ int y = 0;
+ {
+ x = 2; y = 2;
+ Tuple t{&x, &y};
+ assert(4 == ex::apply(call_with_pointer, t));
+ }
+ {
+ x = 2; y = 3;
+ Tuple t{&x, &y};
+ assert(5 == ex::apply(call_with_const_pointer, t));
+ }
+ {
+ x = 3; y = 4;
+ Tuple const t{&x, &y};
+ assert(7 == ex::apply(call_with_const_pointer, t));
+ }
+}
+
+
+template <class Tuple>
+void test_const_pointer()
+{
+ int x = 0;
+ int y = 0;
+ {
+ x = 2; y = 3;
+ Tuple t{&x, &y};
+ assert(5 == ex::apply(call_with_const_pointer, t));
+ }
+ {
+ x = 3; y = 4;
+ Tuple const t{&x, &y};
+ assert(7 == ex::apply(call_with_const_pointer, t));
+ }
+}
+
+
+int main()
+{
+ test_values<std::tuple<int, int>>();
+ test_values<std::pair<int, int>>();
+ test_values<std::array<int, 2>>();
+
+ test_refs<std::tuple<int &, int &>>();
+ test_refs<std::pair<int &, int &>>();
+
+ test_const_refs<std::tuple<int const &, int const &>>();
+ test_const_refs<std::pair<int const &, int const &>>();
+
+ test_pointer<std::tuple<int *, int *>>();
+ test_pointer<std::pair<int *, int *>>();
+ test_pointer<std::array<int *, 2>>();
+
+ test_const_pointer<std::tuple<int const *, int const *>>();
+ test_const_pointer<std::pair<int const *, int const *>>();
+ test_const_pointer<std::array<int const *, 2>>();
+}
diff --git a/test/std/experimental/utilities/tuple/tuple.apply/constexpr_types.pass.cpp b/test/std/experimental/utilities/tuple/tuple.apply/constexpr_types.pass.cpp
new file mode 100644
index 000000000000..2d700486f26b
--- /dev/null
+++ b/test/std/experimental/utilities/tuple/tuple.apply/constexpr_types.pass.cpp
@@ -0,0 +1,123 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11
+
+// TODO(ericwf)
+// constexpr support temporarily reverted due to bug:
+// https://llvm.org/bugs/show_bug.cgi?id=23141
+// XFAIL: *
+
+// <experimental/tuple>
+
+// template <class F, class T> constexpr decltype(auto) apply(F &&, T &&)
+
+// Testing constexpr evaluation
+
+#include <experimental/tuple>
+#include <utility>
+#include <cassert>
+
+constexpr int f_int_0() { return 1; }
+constexpr int f_int_1(int x) { return x; }
+constexpr int f_int_2(int x, int y) { return (x + y); }
+
+struct A_int_0
+{
+ constexpr A_int_0() {}
+ constexpr int operator()() const { return 1; }
+};
+
+struct A_int_1
+{
+ constexpr A_int_1() {}
+ constexpr int operator()(int x) const { return x; }
+};
+
+struct A_int_2
+{
+ constexpr A_int_2() {}
+ constexpr int operator()(int x, int y) const { return (x + y); }
+};
+
+namespace ex = std::experimental;
+
+template <class Tuple>
+void test_0()
+{
+ // function
+ {
+ constexpr Tuple t{};
+ static_assert(1 == ex::apply(f_int_0, t), "");
+ }
+ // function pointer
+ {
+ constexpr Tuple t{};
+ constexpr auto fp = &f_int_0;
+ static_assert(1 == ex::apply(fp, t), "");
+ }
+ // functor
+ {
+ constexpr Tuple t{};
+ constexpr A_int_0 a;
+ static_assert(1 == ex::apply(a, t), "");
+ }
+}
+
+template <class Tuple>
+void test_1()
+{
+ // function
+ {
+ constexpr Tuple t{1};
+ static_assert(1 == ex::apply(f_int_1, t), "");
+ }
+ // function pointer
+ {
+ constexpr Tuple t{2};
+ constexpr int (*fp)(int) = f_int_1;
+ static_assert(2 == ex::apply(fp, t), "");
+ }
+ // functor
+ {
+ constexpr Tuple t{3};
+ constexpr A_int_1 fn;
+ static_assert(3 == ex::apply(fn, t), "");
+ }
+}
+
+template <class Tuple>
+void test_2()
+{
+ // function
+ {
+ constexpr Tuple t{1, 2};
+ static_assert(3 == ex::apply(f_int_2, t), "");
+ }
+ // function pointer
+ {
+ constexpr Tuple t{2, 3};
+ constexpr auto fp = &f_int_2;
+ static_assert(5 == ex::apply(fp, t), "");
+ }
+ // functor
+ {
+ constexpr Tuple t{3, 4};
+ constexpr A_int_2 a;
+ static_assert(7 == ex::apply(a, t), "");
+ }
+}
+
+int main()
+{
+ test_0<std::tuple<>>();
+ test_1<std::tuple<int>>();
+ test_2<std::tuple<int, int>>();
+ test_2<std::pair<int, int>>();
+}
diff --git a/test/std/experimental/utilities/tuple/tuple.apply/extended_types.pass.cpp b/test/std/experimental/utilities/tuple/tuple.apply/extended_types.pass.cpp
new file mode 100644
index 000000000000..322554925d3f
--- /dev/null
+++ b/test/std/experimental/utilities/tuple/tuple.apply/extended_types.pass.cpp
@@ -0,0 +1,423 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11
+
+// <experimental/tuple>
+
+// template <class F, class T> constexpr decltype(auto) apply(F &&, T &&)
+
+// Testing extended function types. The extented function types are those
+// named by INVOKE but that are not actual callable objects. These include
+// bullets 1-4 of invoke.
+
+#include <experimental/tuple>
+#include <array>
+#include <utility>
+#include <cassert>
+
+int count = 0;
+
+struct A_int_0
+{
+ A_int_0() : obj1(0){}
+ A_int_0(int x) : obj1(x) {}
+ int mem1() { return ++count; }
+ int mem2() const { return ++count; }
+ int const obj1;
+};
+
+struct A_int_1
+{
+ A_int_1() {}
+ A_int_1(int) {}
+ int mem1(int x) { return count += x; }
+ int mem2(int x) const { return count += x; }
+};
+
+struct A_int_2
+{
+ A_int_2() {}
+ A_int_2(int) {}
+ int mem1(int x, int y) { return count += (x + y); }
+ int mem2(int x, int y) const { return count += (x + y); }
+};
+
+template <class A>
+struct A_wrap
+{
+ A_wrap() {}
+ A_wrap(int x) : m_a(x) {}
+ A & operator*() { return m_a; }
+ A const & operator*() const { return m_a; }
+ A m_a;
+};
+
+typedef A_wrap<A_int_0> A_wrap_0;
+typedef A_wrap<A_int_1> A_wrap_1;
+typedef A_wrap<A_int_2> A_wrap_2;
+
+
+template <class A>
+struct A_base : public A
+{
+ A_base() : A() {}
+ A_base(int x) : A(x) {}
+};
+
+typedef A_base<A_int_0> A_base_0;
+typedef A_base<A_int_1> A_base_1;
+typedef A_base<A_int_2> A_base_2;
+
+namespace ex = std::experimental;
+
+template <
+ class Tuple, class ConstTuple
+ , class TuplePtr, class ConstTuplePtr
+ , class TupleWrap, class ConstTupleWrap
+ , class TupleBase, class ConstTupleBase
+ >
+void test_ext_int_0()
+{
+ count = 0;
+ typedef A_int_0 T;
+ typedef A_wrap_0 Wrap;
+ typedef A_base_0 Base;
+
+ typedef int(T::*mem1_t)();
+ mem1_t mem1 = &T::mem1;
+
+ typedef int(T::*mem2_t)() const;
+ mem2_t mem2 = &T::mem2;
+
+ typedef int const T::*obj1_t;
+ obj1_t obj1 = &T::obj1;
+
+ // member function w/ref
+ {
+ T a;
+ Tuple t{a};
+ assert(1 == ex::apply(mem1, t));
+ assert(count == 1);
+ }
+ count = 0;
+ // member function w/pointer
+ {
+ T a;
+ TuplePtr t{&a};
+ assert(1 == ex::apply(mem1, t));
+ assert(count == 1);
+ }
+ count = 0;
+ // member function w/base
+ {
+ Base a;
+ TupleBase t{a};
+ assert(1 == ex::apply(mem1, t));
+ assert(count == 1);
+ }
+ count = 0;
+ // member function w/wrap
+ {
+ Wrap a;
+ TupleWrap t{a};
+ assert(1 == ex::apply(mem1, t));
+ assert(count == 1);
+ }
+ count = 0;
+ // const member function w/ref
+ {
+ T const a;
+ ConstTuple t{a};
+ assert(1 == ex::apply(mem2, t));
+ assert(count == 1);
+ }
+ count = 0;
+ // const member function w/pointer
+ {
+ T const a;
+ ConstTuplePtr t{&a};
+ assert(1 == ex::apply(mem2, t));
+ assert(count == 1);
+ }
+ count = 0;
+ // const member function w/base
+ {
+ Base const a;
+ ConstTupleBase t{a};
+ assert(1 == ex::apply(mem2, t));
+ assert(count == 1);
+ }
+ count = 0;
+ // const member function w/wrapper
+ {
+ Wrap const a;
+ ConstTupleWrap t{a};
+ assert(1 == ex::apply(mem2, t));
+ assert(1 == count);
+ }
+ // member object w/ref
+ {
+ T a{42};
+ Tuple t{a};
+ assert(42 == ex::apply(obj1, t));
+ }
+ // member object w/pointer
+ {
+ T a{42};
+ TuplePtr t{&a};
+ assert(42 == ex::apply(obj1, t));
+ }
+ // member object w/base
+ {
+ Base a{42};
+ TupleBase t{a};
+ assert(42 == ex::apply(obj1, t));
+ }
+ // member object w/wrapper
+ {
+ Wrap a{42};
+ TupleWrap t{a};
+ assert(42 == ex::apply(obj1, t));
+ }
+}
+
+
+template <
+ class Tuple, class ConstTuple
+ , class TuplePtr, class ConstTuplePtr
+ , class TupleWrap, class ConstTupleWrap
+ , class TupleBase, class ConstTupleBase
+ >
+void test_ext_int_1()
+{
+ count = 0;
+ typedef A_int_1 T;
+ typedef A_wrap_1 Wrap;
+ typedef A_base_1 Base;
+
+ typedef int(T::*mem1_t)(int);
+ mem1_t mem1 = &T::mem1;
+
+ typedef int(T::*mem2_t)(int) const;
+ mem2_t mem2 = &T::mem2;
+
+ // member function w/ref
+ {
+ T a;
+ Tuple t{a, 2};
+ assert(2 == ex::apply(mem1, t));
+ assert(count == 2);
+ }
+ count = 0;
+ // member function w/pointer
+ {
+ T a;
+ TuplePtr t{&a, 3};
+ assert(3 == ex::apply(mem1, t));
+ assert(count == 3);
+ }
+ count = 0;
+ // member function w/base
+ {
+ Base a;
+ TupleBase t{a, 4};
+ assert(4 == ex::apply(mem1, t));
+ assert(count == 4);
+ }
+ count = 0;
+ // member function w/wrap
+ {
+ Wrap a;
+ TupleWrap t{a, 5};
+ assert(5 == ex::apply(mem1, t));
+ assert(count == 5);
+ }
+ count = 0;
+ // const member function w/ref
+ {
+ T const a;
+ ConstTuple t{a, 6};
+ assert(6 == ex::apply(mem2, t));
+ assert(count == 6);
+ }
+ count = 0;
+ // const member function w/pointer
+ {
+ T const a;
+ ConstTuplePtr t{&a, 7};
+ assert(7 == ex::apply(mem2, t));
+ assert(count == 7);
+ }
+ count = 0;
+ // const member function w/base
+ {
+ Base const a;
+ ConstTupleBase t{a, 8};
+ assert(8 == ex::apply(mem2, t));
+ assert(count == 8);
+ }
+ count = 0;
+ // const member function w/wrapper
+ {
+ Wrap const a;
+ ConstTupleWrap t{a, 9};
+ assert(9 == ex::apply(mem2, t));
+ assert(9 == count);
+ }
+}
+
+
+template <
+ class Tuple, class ConstTuple
+ , class TuplePtr, class ConstTuplePtr
+ , class TupleWrap, class ConstTupleWrap
+ , class TupleBase, class ConstTupleBase
+ >
+void test_ext_int_2()
+{
+ count = 0;
+ typedef A_int_2 T;
+ typedef A_wrap_2 Wrap;
+ typedef A_base_2 Base;
+
+ typedef int(T::*mem1_t)(int, int);
+ mem1_t mem1 = &T::mem1;
+
+ typedef int(T::*mem2_t)(int, int) const;
+ mem2_t mem2 = &T::mem2;
+
+ // member function w/ref
+ {
+ T a;
+ Tuple t{a, 1, 1};
+ assert(2 == ex::apply(mem1, t));
+ assert(count == 2);
+ }
+ count = 0;
+ // member function w/pointer
+ {
+ T a;
+ TuplePtr t{&a, 1, 2};
+ assert(3 == ex::apply(mem1, t));
+ assert(count == 3);
+ }
+ count = 0;
+ // member function w/base
+ {
+ Base a;
+ TupleBase t{a, 2, 2};
+ assert(4 == ex::apply(mem1, t));
+ assert(count == 4);
+ }
+ count = 0;
+ // member function w/wrap
+ {
+ Wrap a;
+ TupleWrap t{a, 2, 3};
+ assert(5 == ex::apply(mem1, t));
+ assert(count == 5);
+ }
+ count = 0;
+ // const member function w/ref
+ {
+ T const a;
+ ConstTuple t{a, 3, 3};
+ assert(6 == ex::apply(mem2, t));
+ assert(count == 6);
+ }
+ count = 0;
+ // const member function w/pointer
+ {
+ T const a;
+ ConstTuplePtr t{&a, 3, 4};
+ assert(7 == ex::apply(mem2, t));
+ assert(count == 7);
+ }
+ count = 0;
+ // const member function w/base
+ {
+ Base const a;
+ ConstTupleBase t{a, 4, 4};
+ assert(8 == ex::apply(mem2, t));
+ assert(count == 8);
+ }
+ count = 0;
+ // const member function w/wrapper
+ {
+ Wrap const a;
+ ConstTupleWrap t{a, 4, 5};
+ assert(9 == ex::apply(mem2, t));
+ assert(9 == count);
+ }
+}
+
+int main()
+{
+ {
+ test_ext_int_0<
+ std::tuple<A_int_0 &>, std::tuple<A_int_0 const &>
+ , std::tuple<A_int_0 *>, std::tuple<A_int_0 const *>
+ , std::tuple<A_wrap_0 &>, std::tuple<A_wrap_0 const &>
+ , std::tuple<A_base_0 &>, std::tuple<A_base_0 const &>
+ >();
+ test_ext_int_0<
+ std::tuple<A_int_0>, std::tuple<A_int_0 const>
+ , std::tuple<A_int_0 *>, std::tuple<A_int_0 const *>
+ , std::tuple<A_wrap_0>, std::tuple<A_wrap_0 const>
+ , std::tuple<A_base_0>, std::tuple<A_base_0 const>
+ >();
+ test_ext_int_0<
+ std::array<A_int_0, 1>, std::array<A_int_0 const, 1>
+ , std::array<A_int_0*, 1>, std::array<A_int_0 const*, 1>
+ , std::array<A_wrap_0, 1>, std::array<A_wrap_0 const, 1>
+ , std::array<A_base_0, 1>, std::array<A_base_0 const, 1>
+ >();
+ }
+ {
+ test_ext_int_1<
+ std::tuple<A_int_1 &, int>, std::tuple<A_int_1 const &, int>
+ , std::tuple<A_int_1 *, int>, std::tuple<A_int_1 const *, int>
+ , std::tuple<A_wrap_1 &, int>, std::tuple<A_wrap_1 const &, int>
+ , std::tuple<A_base_1 &, int>, std::tuple<A_base_1 const &, int>
+ >();
+ test_ext_int_1<
+ std::tuple<A_int_1, int>, std::tuple<A_int_1 const, int>
+ , std::tuple<A_int_1 *, int>, std::tuple<A_int_1 const *, int>
+ , std::tuple<A_wrap_1, int>, std::tuple<A_wrap_1 const, int>
+ , std::tuple<A_base_1, int>, std::tuple<A_base_1 const, int>
+ >();
+ test_ext_int_1<
+ std::pair<A_int_1 &, int>, std::pair<A_int_1 const &, int>
+ , std::pair<A_int_1 *, int>, std::pair<A_int_1 const *, int>
+ , std::pair<A_wrap_1 &, int>, std::pair<A_wrap_1 const &, int>
+ , std::pair<A_base_1 &, int>, std::pair<A_base_1 const &, int>
+ >();
+ test_ext_int_1<
+ std::pair<A_int_1, int>, std::pair<A_int_1 const, int>
+ , std::pair<A_int_1 *, int>, std::pair<A_int_1 const *, int>
+ , std::pair<A_wrap_1, int>, std::pair<A_wrap_1 const, int>
+ , std::pair<A_base_1, int>, std::pair<A_base_1 const, int>
+ >();
+ }
+ {
+ test_ext_int_2<
+ std::tuple<A_int_2 &, int, int>, std::tuple<A_int_2 const &, int, int>
+ , std::tuple<A_int_2 *, int, int>, std::tuple<A_int_2 const *, int, int>
+ , std::tuple<A_wrap_2 &, int, int>, std::tuple<A_wrap_2 const &, int, int>
+ , std::tuple<A_base_2 &, int, int>, std::tuple<A_base_2 const &, int, int>
+ >();
+ test_ext_int_2<
+ std::tuple<A_int_2, int, int>, std::tuple<A_int_2 const, int, int>
+ , std::tuple<A_int_2 *, int, int>, std::tuple<A_int_2 const *, int, int>
+ , std::tuple<A_wrap_2, int, int>, std::tuple<A_wrap_2 const, int, int>
+ , std::tuple<A_base_2, int, int>, std::tuple<A_base_2 const, int, int>
+ >();
+ }
+}
diff --git a/test/std/experimental/utilities/tuple/tuple.apply/large_arity.pass.cpp b/test/std/experimental/utilities/tuple/tuple.apply/large_arity.pass.cpp
new file mode 100644
index 000000000000..027258ad8d1d
--- /dev/null
+++ b/test/std/experimental/utilities/tuple/tuple.apply/large_arity.pass.cpp
@@ -0,0 +1,146 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11
+
+// <experimental/tuple>
+
+// template <class F, class T> constexpr decltype(auto) apply(F &&, T &&)
+
+// Stress testing large arities with tuple and array.
+
+#include <experimental/tuple>
+#include <array>
+#include <utility>
+#include <cassert>
+
+////////////////////////////////////////////////////////////////////////////////
+template <class T, std::size_t Dummy = 0>
+struct always_imp
+{
+ typedef T type;
+};
+
+template <class T, std::size_t Dummy = 0>
+using always_t = typename always_imp<T, Dummy>::type;
+
+////////////////////////////////////////////////////////////////////////////////
+template <class Tuple, class Idx>
+struct make_function;
+
+template <class Tp, std::size_t ...Idx>
+struct make_function<Tp, std::integer_sequence<std::size_t, Idx...>>
+{
+ using type = bool (*)(always_t<Tp, Idx>...);
+};
+
+template <class Tp, std::size_t Size>
+using make_function_t = typename make_function<Tp, std::make_index_sequence<Size>>::type;
+
+////////////////////////////////////////////////////////////////////////////////
+template <class Tp, class Idx>
+struct make_tuple_imp;
+
+////////////////////////////////////////////////////////////////////////////////
+template <class Tp, std::size_t ...Idx>
+struct make_tuple_imp<Tp, std::integer_sequence<std::size_t, Idx...>>
+{
+ using type = std::tuple<always_t<Tp, Idx>...>;
+};
+
+template <class Tp, std::size_t Size>
+using make_tuple_t = typename make_tuple_imp<Tp, std::make_index_sequence<Size>>::type;
+
+template <class ...Types>
+bool test_apply_fn(Types...) { return true; }
+
+namespace ex = std::experimental;
+
+template <std::size_t Size>
+void test_all()
+{
+
+ using A = std::array<int, Size>;
+ using ConstA = std::array<int const, Size>;
+
+ using Tuple = make_tuple_t<int, Size>;
+ using CTuple = make_tuple_t<const int, Size>;
+
+ using ValFn = make_function_t<int, Size>;
+ ValFn val_fn = &test_apply_fn;
+
+ using RefFn = make_function_t<int &, Size>;
+ RefFn ref_fn = &test_apply_fn;
+
+ using CRefFn = make_function_t<int const &, Size>;
+ CRefFn cref_fn = &test_apply_fn;
+
+ using RRefFn = make_function_t<int &&, Size>;
+ RRefFn rref_fn = &test_apply_fn;
+
+ {
+ A a{};
+ assert(ex::apply(val_fn, a));
+ assert(ex::apply(ref_fn, a));
+ assert(ex::apply(cref_fn, a));
+ assert(ex::apply(rref_fn, std::move(a)));
+ }
+ {
+ ConstA a{};
+ assert(ex::apply(val_fn, a));
+ assert(ex::apply(cref_fn, a));
+ }
+ {
+ Tuple a{};
+ assert(ex::apply(val_fn, a));
+ assert(ex::apply(ref_fn, a));
+ assert(ex::apply(cref_fn, a));
+ assert(ex::apply(rref_fn, std::move(a)));
+ }
+ {
+ CTuple a{};
+ assert(ex::apply(val_fn, a));
+ assert(ex::apply(cref_fn, a));
+ }
+
+}
+
+
+template <std::size_t Size>
+void test_one()
+{
+ using A = std::array<int, Size>;
+ using Tuple = make_tuple_t<int, Size>;
+
+ using ValFn = make_function_t<int, Size>;
+ ValFn val_fn = &test_apply_fn;
+
+ {
+ A a{};
+ assert(ex::apply(val_fn, a));
+ }
+ {
+ Tuple a{};
+ assert(ex::apply(val_fn, a));
+ }
+}
+
+int main()
+{
+ // Instantiate with 1-5 arguments.
+ test_all<1>();
+ test_all<2>();
+ test_all<3>();
+ test_all<4>();
+ test_all<5>();
+
+ // Stress test with 128.
+ test_one<128>();
+ //test_one<256>();
+}
diff --git a/test/std/experimental/utilities/tuple/tuple.apply/ref_qualifiers.pass.cpp b/test/std/experimental/utilities/tuple/tuple.apply/ref_qualifiers.pass.cpp
new file mode 100644
index 000000000000..3cf259f531c9
--- /dev/null
+++ b/test/std/experimental/utilities/tuple/tuple.apply/ref_qualifiers.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11
+
+// <experimental/tuple>
+
+// template <class F, class T> constexpr decltype(auto) apply(F &&, T &&)
+
+// Testing ref qualified functions
+
+#include <experimental/tuple>
+#include <cassert>
+
+struct func_obj
+{
+ constexpr func_obj() {}
+
+ constexpr int operator()() const & { return 1; }
+ constexpr int operator()() const && { return 2; }
+ constexpr int operator()() & { return 3; }
+ constexpr int operator()() && { return 4; }
+};
+
+namespace ex = std::experimental;
+
+int main()
+{
+// TODO(ericwf): Re-enable constexpr support
+/*
+ {
+ constexpr func_obj f;
+ constexpr std::tuple<> tp;
+
+ static_assert(1 == ex::apply(static_cast<func_obj const &>(f), tp), "");
+ static_assert(2 == ex::apply(static_cast<func_obj const &&>(f), tp), "");
+ }
+*/
+ {
+ func_obj f;
+ std::tuple<> tp;
+ assert(1 == ex::apply(static_cast<func_obj const &>(f), tp));
+ assert(2 == ex::apply(static_cast<func_obj const &&>(f), tp));
+ assert(3 == ex::apply(static_cast<func_obj &>(f), tp));
+ assert(4 == ex::apply(static_cast<func_obj &&>(f), tp));
+ }
+}
diff --git a/test/std/experimental/utilities/tuple/tuple.apply/return_type.pass.cpp b/test/std/experimental/utilities/tuple/tuple.apply/return_type.pass.cpp
new file mode 100644
index 000000000000..1ec38da5c043
--- /dev/null
+++ b/test/std/experimental/utilities/tuple/tuple.apply/return_type.pass.cpp
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11
+
+// <experimental/tuple>
+
+// template <class F, class T> constexpr decltype(auto) apply(F &&, T &&)
+
+// Test the return type deduction.
+
+#include <experimental/tuple>
+#include <cassert>
+
+static int my_int = 42;
+
+template <int N> struct index {};
+
+void f(index<0>) {}
+
+int f(index<1>) { return 0; }
+int const f(index<2>) { return 0; }
+int volatile f(index<3>) { return 0; }
+int const volatile f(index<4>) { return 0; }
+
+int & f(index<5>) { return static_cast<int &>(my_int); }
+int const & f(index<6>) { return static_cast<int const &>(my_int); }
+int volatile & f(index<7>) { return static_cast<int volatile &>(my_int); }
+int const volatile & f(index<8>) { return static_cast<int const volatile &>(my_int); }
+
+int && f(index<9>) { return static_cast<int &&>(my_int); }
+int const && f(index<10>) { return static_cast<int const &&>(my_int); }
+int volatile && f(index<11>) { return static_cast<int volatile &&>(my_int); }
+int const volatile && f(index<12>) { return static_cast<int const volatile &&>(my_int); }
+
+int * f(index<13>) { return static_cast<int *>(&my_int); }
+int const * f(index<14>) { return static_cast<int const *>(&my_int); }
+int volatile * f(index<15>) { return static_cast<int volatile *>(&my_int); }
+int const volatile * f(index<16>) { return static_cast<int const volatile *>(&my_int); }
+
+
+template <int Func, class Expect>
+void test()
+{
+ using F = decltype((f(index<Func>{})));
+ static_assert(std::is_same<F, Expect>::value, "");
+}
+
+namespace ex = std::experimental;
+
+int main()
+{
+ test<0, void>();
+ test<1, int>();
+ //test<2, int const>();
+ //test<3, int volatile>();
+ //test<4, int const volatile>();
+ test<5, int &>();
+ test<6, int const &>();
+ test<7, int volatile &>();
+ test<8, int const volatile &>();
+ test<9, int &&>();
+ test<10, int const &&>();
+ test<11, int volatile &&>();
+ test<12, int const volatile &&>();
+ test<13, int *>();
+ test<14, int const *>();
+ test<15, int volatile *>();
+ test<16, int const volatile *>();
+}
diff --git a/test/std/experimental/utilities/tuple/tuple.apply/types.pass.cpp b/test/std/experimental/utilities/tuple/tuple.apply/types.pass.cpp
new file mode 100644
index 000000000000..5d3d564c26fb
--- /dev/null
+++ b/test/std/experimental/utilities/tuple/tuple.apply/types.pass.cpp
@@ -0,0 +1,427 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11
+
+// <experimental/tuple>
+
+// template <class F, class T> constexpr decltype(auto) apply(F &&, T &&)
+
+// Test function types.
+
+#include <experimental/tuple>
+#include <array>
+#include <utility>
+#include <cassert>
+
+namespace ex = std::experimental;
+
+int count = 0;
+
+void f_void_0() { ++count; }
+void f_void_1(int i) { count += i; }
+void f_void_2(int x, int y) { count += (x + y); }
+void f_void_3(int x, int y, int z) { count += (x + y + z); }
+
+int f_int_0() { return ++count; }
+int f_int_1(int x) { return count += x; }
+int f_int_2(int x, int y) { return count += (x + y); }
+int f_int_3(int x, int y, int z) { return count += (x + y + z); }
+
+struct A_void_0
+{
+ A_void_0() {}
+ void operator()() { ++count; }
+ void operator()() const { ++count; ++count; }
+};
+
+struct A_void_1
+{
+ A_void_1() {}
+ void operator()(int x) { count += x; }
+ void operator()(int x) const { count += x + 1; }
+};
+
+struct A_void_2
+{
+ A_void_2() {}
+ void operator()(int x, int y) { count += (x + y); }
+ void operator()(int x, int y) const { count += (x + y) + 1; }
+};
+
+struct A_void_3
+{
+ A_void_3() {}
+ void operator()(int x, int y, int z) { count += (x + y + z); }
+ void operator()(int x, int y, int z) const { count += (x + y + z) + 1; }
+};
+
+
+struct A_int_0
+{
+ A_int_0() {}
+ int operator()() { return ++count; }
+ int operator()() const { ++count; return ++count; }
+};
+
+struct A_int_1
+{
+ A_int_1() {}
+ int operator()(int x) { return count += x; }
+ int operator()(int x) const { return count += (x + 1); }
+
+};
+
+struct A_int_2
+{
+ A_int_2() {}
+ int operator()(int x, int y) { return count += (x + y); }
+ int operator()(int x, int y) const { return count += (x + y + 1); }
+};
+
+struct A_int_3
+{
+ A_int_3() {}
+ int operator()(int x, int y, int z) { return count += (x + y + z); }
+ int operator()(int x, int y, int z) const { return count += (x + y + z + 1); }
+};
+
+
+template <class Tuple>
+void test_void_0()
+{
+ count = 0;
+ // function
+ {
+ Tuple t{};
+ ex::apply(f_void_0, t);
+ assert(count == 1);
+ }
+ count = 0;
+ // function pointer
+ {
+ Tuple t{};
+ auto fp = &f_void_0;
+ ex::apply(fp, t);
+ assert(count == 1);
+ }
+ count = 0;
+ // functor
+ {
+ Tuple t{};
+ A_void_0 a;
+ ex::apply(a, t);
+ assert(count == 1);
+ }
+ count = 0;
+ // const functor
+ {
+ Tuple t{};
+ A_void_0 const a;
+ ex::apply(a, t);
+ assert(count == 2);
+ }
+}
+
+template <class Tuple>
+void test_void_1()
+{
+ count = 0;
+ // function
+ {
+ Tuple t{1};
+ ex::apply(f_void_1, t);
+ assert(count == 1);
+ }
+ count = 0;
+ // function pointer
+ {
+ Tuple t{2};
+ void (*fp)(int) = f_void_1;
+ ex::apply(fp, t);
+ assert(count == 2);
+ }
+ count = 0;
+ // functor
+ {
+ Tuple t{3};
+ A_void_1 fn;
+ ex::apply(fn, t);
+ assert(count == 3);
+ }
+ count = 0;
+ // const functor
+ {
+ Tuple t{4};
+ A_void_1 const a;
+ ex::apply(a, t);
+ assert(count == 5);
+ }
+}
+
+template <class Tuple>
+void test_void_2()
+{
+ count = 0;
+ // function
+ {
+ Tuple t{1, 2};
+ ex::apply(f_void_2, t);
+ assert(count == 3);
+ }
+ count = 0;
+ // function pointer
+ {
+ Tuple t{2, 3};
+ auto fp = &f_void_2;
+ ex::apply(fp, t);
+ assert(count == 5);
+ }
+ count = 0;
+ // functor
+ {
+ Tuple t{3, 4};
+ A_void_2 a;
+ ex::apply(a, t);
+ assert(count == 7);
+ }
+ count = 0;
+ // const functor
+ {
+ Tuple t{4, 5};
+ A_void_2 const a;
+ ex::apply(a, t);
+ assert(count == 10);
+ }
+}
+
+template <class Tuple>
+void test_void_3()
+{
+ count = 0;
+ // function
+ {
+ Tuple t{1, 2, 3};
+ ex::apply(f_void_3, t);
+ assert(count == 6);
+ }
+ count = 0;
+ // function pointer
+ {
+ Tuple t{2, 3, 4};
+ auto fp = &f_void_3;
+ ex::apply(fp, t);
+ assert(count == 9);
+ }
+ count = 0;
+ // functor
+ {
+ Tuple t{3, 4, 5};
+ A_void_3 a;
+ ex::apply(a, t);
+ assert(count == 12);
+ }
+ count = 0;
+ // const functor
+ {
+ Tuple t{4, 5, 6};
+ A_void_3 const a;
+ ex::apply(a, t);
+ assert(count == 16);
+ }
+}
+
+
+
+template <class Tuple>
+void test_int_0()
+{
+ count = 0;
+ // function
+ {
+ Tuple t{};
+ assert(1 == ex::apply(f_int_0, t));
+ assert(count == 1);
+ }
+ count = 0;
+ // function pointer
+ {
+ Tuple t{};
+ auto fp = &f_int_0;
+ assert(1 == ex::apply(fp, t));
+ assert(count == 1);
+ }
+ count = 0;
+ // functor
+ {
+ Tuple t{};
+ A_int_0 a;
+ assert(1 == ex::apply(a, t));
+ assert(count == 1);
+ }
+ count = 0;
+ // const functor
+ {
+ Tuple t{};
+ A_int_0 const a;
+ assert(2 == ex::apply(a, t));
+ assert(count == 2);
+ }
+}
+
+template <class Tuple>
+void test_int_1()
+{
+ count = 0;
+ // function
+ {
+ Tuple t{1};
+ assert(1 == ex::apply(f_int_1, t));
+ assert(count == 1);
+ }
+ count = 0;
+ // function pointer
+ {
+ Tuple t{2};
+ int (*fp)(int) = f_int_1;
+ assert(2 == ex::apply(fp, t));
+ assert(count == 2);
+ }
+ count = 0;
+ // functor
+ {
+ Tuple t{3};
+ A_int_1 fn;
+ assert(3 == ex::apply(fn, t));
+ assert(count == 3);
+ }
+ count = 0;
+ // const functor
+ {
+ Tuple t{4};
+ A_int_1 const a;
+ assert(5 == ex::apply(a, t));
+ assert(count == 5);
+ }
+}
+
+template <class Tuple>
+void test_int_2()
+{
+ count = 0;
+ // function
+ {
+ Tuple t{1, 2};
+ assert(3 == ex::apply(f_int_2, t));
+ assert(count == 3);
+ }
+ count = 0;
+ // function pointer
+ {
+ Tuple t{2, 3};
+ auto fp = &f_int_2;
+ assert(5 == ex::apply(fp, t));
+ assert(count == 5);
+ }
+ count = 0;
+ // functor
+ {
+ Tuple t{3, 4};
+ A_int_2 a;
+ assert(7 == ex::apply(a, t));
+ assert(count == 7);
+ }
+ count = 0;
+ // const functor
+ {
+ Tuple t{4, 5};
+ A_int_2 const a;
+ assert(10 == ex::apply(a, t));
+ assert(count == 10);
+ }
+}
+
+template <class Tuple>
+void test_int_3()
+{
+ count = 0;
+ // function
+ {
+ Tuple t{1, 2, 3};
+ assert(6 == ex::apply(f_int_3, t));
+ assert(count == 6);
+ }
+ count = 0;
+ // function pointer
+ {
+ Tuple t{2, 3, 4};
+ auto fp = &f_int_3;
+ assert(9 == ex::apply(fp, t));
+ assert(count == 9);
+ }
+ count = 0;
+ // functor
+ {
+ Tuple t{3, 4, 5};
+ A_int_3 a;
+ assert(12 == ex::apply(a, t));
+ assert(count == 12);
+ }
+ count = 0;
+ // const functor
+ {
+ Tuple t{4, 5, 6};
+ A_int_3 const a;
+ assert(16 == ex::apply(a, t));
+ assert(count == 16);
+ }
+}
+
+template <class Tuple>
+void test_0()
+{
+ test_void_0<Tuple>();
+ test_int_0<Tuple>();
+}
+
+template <class Tuple>
+void test_1()
+{
+ test_void_1<Tuple>();
+ test_int_1<Tuple>();
+}
+
+template <class Tuple>
+void test_2()
+{
+ test_void_2<Tuple>();
+ test_int_2<Tuple>();
+}
+
+template <class Tuple>
+void test_3()
+{
+ test_void_3<Tuple>();
+ test_int_3<Tuple>();
+}
+
+int main()
+{
+ test_0<std::tuple<>>();
+
+ test_1<std::tuple<int>>();
+ test_1<std::array<int, 1>>();
+
+ test_2<std::tuple<int, int>>();
+ test_2<std::pair<int, int>>();
+ test_2<std::array<int, 2>>();
+
+ test_3<std::tuple<int, int, int>>();
+ test_3<std::array<int, 3>>();
+}
diff --git a/test/std/experimental/utilities/tuple/tuple_size_v.fail.cpp b/test/std/experimental/utilities/tuple/tuple_size_v.fail.cpp
new file mode 100644
index 000000000000..a25b18cf5386
--- /dev/null
+++ b/test/std/experimental/utilities/tuple/tuple_size_v.fail.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11
+
+// <experimental/tuple>
+
+// template <class T> constexpr size_t tuple_size_v = tuple_size<T>::value;
+
+// Test with reference
+
+#include <experimental/tuple>
+
+namespace ex = std::experimental;
+
+int main()
+{
+ auto x = ex::tuple_size_v<std::tuple<> &>;
+}
diff --git a/test/std/experimental/utilities/tuple/tuple_size_v.pass.cpp b/test/std/experimental/utilities/tuple/tuple_size_v.pass.cpp
new file mode 100644
index 000000000000..d7a5aa679fcd
--- /dev/null
+++ b/test/std/experimental/utilities/tuple/tuple_size_v.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11
+
+// <experimental/tuple>
+
+// template <class T> constexpr size_t tuple_size_v = tuple_size<T>::value;
+
+#include <experimental/tuple>
+#include <utility>
+#include <array>
+
+namespace ex = std::experimental;
+
+template <class Tuple, int Expect>
+void test()
+{
+ static_assert(ex::tuple_size_v<Tuple> == Expect, "");
+ static_assert(ex::tuple_size_v<Tuple> == std::tuple_size<Tuple>::value, "");
+ static_assert(ex::tuple_size_v<Tuple const> == std::tuple_size<Tuple>::value, "");
+ static_assert(ex::tuple_size_v<Tuple volatile> == std::tuple_size<Tuple>::value, "");
+ static_assert(ex::tuple_size_v<Tuple const volatile> == std::tuple_size<Tuple>::value, "");
+}
+
+int main()
+{
+ test<std::tuple<>, 0>();
+
+ test<std::tuple<int>, 1>();
+ test<std::array<int, 1>, 1>();
+
+ test<std::tuple<int, int>, 2>();
+ test<std::pair<int, int>, 2>();
+ test<std::array<int, 2>, 2>();
+
+ test<std::tuple<int, int, int>, 3>();
+ test<std::array<int, 3>, 3>();
+}
diff --git a/test/std/experimental/utilities/tuple/tuple_size_v_2.fail.cpp b/test/std/experimental/utilities/tuple/tuple_size_v_2.fail.cpp
new file mode 100644
index 000000000000..a95ac49ff452
--- /dev/null
+++ b/test/std/experimental/utilities/tuple/tuple_size_v_2.fail.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11
+
+// <experimental/tuple>
+
+// template <class T> constexpr size_t tuple_size_v = tuple_size<T>::value;
+
+// Test with non tuple type
+
+#include <experimental/tuple>
+
+namespace ex = std::experimental;
+
+int main()
+{
+ auto x = ex::tuple_size_v<int>;
+}
diff --git a/test/std/experimental/utilities/tuple/tuple_size_v_3.fail.cpp b/test/std/experimental/utilities/tuple/tuple_size_v_3.fail.cpp
new file mode 100644
index 000000000000..7c2f0cc236f6
--- /dev/null
+++ b/test/std/experimental/utilities/tuple/tuple_size_v_3.fail.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11
+
+// <experimental/tuple>
+
+// template <class T> constexpr size_t tuple_size_v = tuple_size<T>::value;
+
+// Test with pointer
+
+#include <experimental/tuple>
+
+namespace ex = std::experimental;
+
+int main()
+{
+ auto x = ex::tuple_size_v<std::tuple<>*>;
+}
diff --git a/test/std/experimental/utilities/utility/utility.erased.type/erased_type.pass.cpp b/test/std/experimental/utilities/utility/utility.erased.type/erased_type.pass.cpp
new file mode 100644
index 000000000000..51f9ab6bee18
--- /dev/null
+++ b/test/std/experimental/utilities/utility/utility.erased.type/erased_type.pass.cpp
@@ -0,0 +1,17 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <experimental/utility>
+
+#include <experimental/utility>
+
+int main()
+{
+ std::experimental::erased_type e;
+}
diff --git a/test/std/experimental/utilities/utility/utility.synop/includes.pass.cpp b/test/std/experimental/utilities/utility/utility.synop/includes.pass.cpp
new file mode 100644
index 000000000000..2583d4345406
--- /dev/null
+++ b/test/std/experimental/utilities/utility/utility.synop/includes.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <experimental/utility>
+
+#include <experimental/utility>
+
+#ifndef _LIBCPP_UTILITY
+# error "<experimental/utility> must include <utility>"
+#endif
+
+int main()
+{
+}
diff --git a/test/std/experimental/utilities/utility/version.pass.cpp b/test/std/experimental/utilities/utility/version.pass.cpp
new file mode 100644
index 000000000000..437712454ae5
--- /dev/null
+++ b/test/std/experimental/utilities/utility/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <experimental/utility>
+
+#include <experimental/utility>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/extensions/hash/specializations.fail.cpp b/test/std/extensions/hash/specializations.fail.cpp
new file mode 100644
index 000000000000..8eeffb5802e7
--- /dev/null
+++ b/test/std/extensions/hash/specializations.fail.cpp
@@ -0,0 +1,17 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <assert.h>
+#include <ext/hash_map>
+#include <string>
+
+int main()
+{
+ assert(__gnu_cxx::hash<std::string>()(std::string()) == 0); // error
+}
diff --git a/test/std/extensions/hash/specializations.pass.cpp b/test/std/extensions/hash/specializations.pass.cpp
new file mode 100644
index 000000000000..a222b1eb5c6d
--- /dev/null
+++ b/test/std/extensions/hash/specializations.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// NOTE: Undefined __DEPRECATED to prevent this test from failing with -Werror
+#undef __DEPRECATED
+#include <assert.h>
+#include <ext/hash_map>
+#include <string>
+
+int main()
+{
+ char str[] = "test";
+ assert(__gnu_cxx::hash<const char *>()("test") ==
+ std::hash<std::string>()("test"));
+ assert(__gnu_cxx::hash<char *>()(str) == std::hash<std::string>()("test"));
+ assert(__gnu_cxx::hash<char>()(42) == 42);
+ assert(__gnu_cxx::hash<signed char>()(42) == 42);
+ assert(__gnu_cxx::hash<unsigned char>()(42) == 42);
+ assert(__gnu_cxx::hash<short>()(42) == 42);
+ assert(__gnu_cxx::hash<unsigned short>()(42) == 42);
+ assert(__gnu_cxx::hash<int>()(42) == 42);
+ assert(__gnu_cxx::hash<unsigned int>()(42) == 42);
+ assert(__gnu_cxx::hash<long>()(42) == 42);
+ assert(__gnu_cxx::hash<unsigned long>()(42) == 42);
+}
diff --git a/test/std/extensions/hash_map/const_iterator.fail.cpp b/test/std/extensions/hash_map/const_iterator.fail.cpp
new file mode 100644
index 000000000000..e4c536e8f33a
--- /dev/null
+++ b/test/std/extensions/hash_map/const_iterator.fail.cpp
@@ -0,0 +1,18 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <ext/hash_map>
+
+int main()
+{
+ __gnu_cxx::hash_map<int, int> m;
+ m[1] = 1;
+ const __gnu_cxx::hash_map<int, int> &cm = m;
+ cm.find(1)->second = 2; // error
+}
diff --git a/test/std/extensions/nothing_to_do.pass.cpp b/test/std/extensions/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/extensions/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/input.output/file.streams/c.files/cinttypes.pass.cpp b/test/std/input.output/file.streams/c.files/cinttypes.pass.cpp
new file mode 100644
index 000000000000..4cb2c4c2f448
--- /dev/null
+++ b/test/std/input.output/file.streams/c.files/cinttypes.pass.cpp
@@ -0,0 +1,929 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test <cinttypes>
+
+#include <cinttypes>
+#include <type_traits>
+
+#ifndef INT8_MIN
+#error INT8_MIN not defined
+#endif
+
+#ifndef INT16_MIN
+#error INT16_MIN not defined
+#endif
+
+#ifndef INT32_MIN
+#error INT32_MIN not defined
+#endif
+
+#ifndef INT64_MIN
+#error INT64_MIN not defined
+#endif
+
+#ifndef INT8_MAX
+#error INT8_MAX not defined
+#endif
+
+#ifndef INT16_MAX
+#error INT16_MAX not defined
+#endif
+
+#ifndef INT32_MAX
+#error INT32_MAX not defined
+#endif
+
+#ifndef INT64_MAX
+#error INT64_MAX not defined
+#endif
+
+#ifndef UINT8_MAX
+#error UINT8_MAX not defined
+#endif
+
+#ifndef UINT16_MAX
+#error UINT16_MAX not defined
+#endif
+
+#ifndef UINT32_MAX
+#error UINT32_MAX not defined
+#endif
+
+#ifndef UINT64_MAX
+#error UINT64_MAX not defined
+#endif
+
+#ifndef INT_LEAST8_MIN
+#error INT_LEAST8_MIN not defined
+#endif
+
+#ifndef INT_LEAST16_MIN
+#error INT_LEAST16_MIN not defined
+#endif
+
+#ifndef INT_LEAST32_MIN
+#error INT_LEAST32_MIN not defined
+#endif
+
+#ifndef INT_LEAST64_MIN
+#error INT_LEAST64_MIN not defined
+#endif
+
+#ifndef INT_LEAST8_MAX
+#error INT_LEAST8_MAX not defined
+#endif
+
+#ifndef INT_LEAST16_MAX
+#error INT_LEAST16_MAX not defined
+#endif
+
+#ifndef INT_LEAST32_MAX
+#error INT_LEAST32_MAX not defined
+#endif
+
+#ifndef INT_LEAST64_MAX
+#error INT_LEAST64_MAX not defined
+#endif
+
+#ifndef UINT_LEAST8_MAX
+#error UINT_LEAST8_MAX not defined
+#endif
+
+#ifndef UINT_LEAST16_MAX
+#error UINT_LEAST16_MAX not defined
+#endif
+
+#ifndef UINT_LEAST32_MAX
+#error UINT_LEAST32_MAX not defined
+#endif
+
+#ifndef UINT_LEAST64_MAX
+#error UINT_LEAST64_MAX not defined
+#endif
+
+#ifndef INT_FAST8_MIN
+#error INT_FAST8_MIN not defined
+#endif
+
+#ifndef INT_FAST16_MIN
+#error INT_FAST16_MIN not defined
+#endif
+
+#ifndef INT_FAST32_MIN
+#error INT_FAST32_MIN not defined
+#endif
+
+#ifndef INT_FAST64_MIN
+#error INT_FAST64_MIN not defined
+#endif
+
+#ifndef INT_FAST8_MAX
+#error INT_FAST8_MAX not defined
+#endif
+
+#ifndef INT_FAST16_MAX
+#error INT_FAST16_MAX not defined
+#endif
+
+#ifndef INT_FAST32_MAX
+#error INT_FAST32_MAX not defined
+#endif
+
+#ifndef INT_FAST64_MAX
+#error INT_FAST64_MAX not defined
+#endif
+
+#ifndef UINT_FAST8_MAX
+#error UINT_FAST8_MAX not defined
+#endif
+
+#ifndef UINT_FAST16_MAX
+#error UINT_FAST16_MAX not defined
+#endif
+
+#ifndef UINT_FAST32_MAX
+#error UINT_FAST32_MAX not defined
+#endif
+
+#ifndef UINT_FAST64_MAX
+#error UINT_FAST64_MAX not defined
+#endif
+
+#ifndef INTPTR_MIN
+#error INTPTR_MIN not defined
+#endif
+
+#ifndef INTPTR_MAX
+#error INTPTR_MAX not defined
+#endif
+
+#ifndef UINTPTR_MAX
+#error UINTPTR_MAX not defined
+#endif
+
+#ifndef INTMAX_MIN
+#error INTMAX_MIN not defined
+#endif
+
+#ifndef INTMAX_MAX
+#error INTMAX_MAX not defined
+#endif
+
+#ifndef UINTMAX_MAX
+#error UINTMAX_MAX not defined
+#endif
+
+#ifndef PTRDIFF_MIN
+#error PTRDIFF_MIN not defined
+#endif
+
+#ifndef PTRDIFF_MAX
+#error PTRDIFF_MAX not defined
+#endif
+
+#ifndef SIG_ATOMIC_MIN
+#error SIG_ATOMIC_MIN not defined
+#endif
+
+#ifndef SIG_ATOMIC_MAX
+#error SIG_ATOMIC_MAX not defined
+#endif
+
+#ifndef SIZE_MAX
+#error SIZE_MAX not defined
+#endif
+
+#ifndef WCHAR_MIN
+#error WCHAR_MIN not defined
+#endif
+
+#ifndef WCHAR_MAX
+#error WCHAR_MAX not defined
+#endif
+
+#ifndef WINT_MIN
+#error WINT_MIN not defined
+#endif
+
+#ifndef WINT_MAX
+#error WINT_MAX not defined
+#endif
+
+#ifndef INT8_C
+#error INT8_C not defined
+#endif
+
+#ifndef INT16_C
+#error INT16_C not defined
+#endif
+
+#ifndef INT32_C
+#error INT32_C not defined
+#endif
+
+#ifndef INT64_C
+#error INT64_C not defined
+#endif
+
+#ifndef UINT8_C
+#error UINT8_C not defined
+#endif
+
+#ifndef UINT16_C
+#error UINT16_C not defined
+#endif
+
+#ifndef UINT32_C
+#error UINT32_C not defined
+#endif
+
+#ifndef UINT64_C
+#error UINT64_C not defined
+#endif
+
+#ifndef INTMAX_C
+#error INTMAX_C not defined
+#endif
+
+#ifndef UINTMAX_C
+#error UINTMAX_C not defined
+#endif
+
+#ifndef PRId8
+#error PRId8 not defined
+#endif
+
+#ifndef PRId16
+#error PRId16 not defined
+#endif
+
+#ifndef PRId32
+#error PRId32 not defined
+#endif
+
+#ifndef PRId64
+#error PRId64 not defined
+#endif
+
+#ifndef PRIdLEAST8
+#error PRIdLEAST8 not defined
+#endif
+
+#ifndef PRIdLEAST16
+#error PRIdLEAST16 not defined
+#endif
+
+#ifndef PRIdLEAST32
+#error PRIdLEAST32 not defined
+#endif
+
+#ifndef PRIdLEAST64
+#error PRIdLEAST64 not defined
+#endif
+
+#ifndef PRIdFAST8
+#error PRIdFAST8 not defined
+#endif
+
+#ifndef PRIdFAST16
+#error PRIdFAST16 not defined
+#endif
+
+#ifndef PRIdFAST32
+#error PRIdFAST32 not defined
+#endif
+
+#ifndef PRIdFAST64
+#error PRIdFAST64 not defined
+#endif
+
+#ifndef PRIdMAX
+#error PRIdMAX not defined
+#endif
+
+#ifndef PRIdPTR
+#error PRIdPTR not defined
+#endif
+
+#ifndef PRIi8
+#error PRIi8 not defined
+#endif
+
+#ifndef PRIi16
+#error PRIi16 not defined
+#endif
+
+#ifndef PRIi32
+#error PRIi32 not defined
+#endif
+
+#ifndef PRIi64
+#error PRIi64 not defined
+#endif
+
+#ifndef PRIiLEAST8
+#error PRIiLEAST8 not defined
+#endif
+
+#ifndef PRIiLEAST16
+#error PRIiLEAST16 not defined
+#endif
+
+#ifndef PRIiLEAST32
+#error PRIiLEAST32 not defined
+#endif
+
+#ifndef PRIiLEAST64
+#error PRIiLEAST64 not defined
+#endif
+
+#ifndef PRIiFAST8
+#error PRIiFAST8 not defined
+#endif
+
+#ifndef PRIiFAST16
+#error PRIiFAST16 not defined
+#endif
+
+#ifndef PRIiFAST32
+#error PRIiFAST32 not defined
+#endif
+
+#ifndef PRIiFAST64
+#error PRIiFAST64 not defined
+#endif
+
+#ifndef PRIiMAX
+#error PRIiMAX not defined
+#endif
+
+#ifndef PRIiPTR
+#error PRIiPTR not defined
+#endif
+
+#ifndef PRIo8
+#error PRIo8 not defined
+#endif
+
+#ifndef PRIo16
+#error PRIo16 not defined
+#endif
+
+#ifndef PRIo32
+#error PRIo32 not defined
+#endif
+
+#ifndef PRIo64
+#error PRIo64 not defined
+#endif
+
+#ifndef PRIoLEAST8
+#error PRIoLEAST8 not defined
+#endif
+
+#ifndef PRIoLEAST16
+#error PRIoLEAST16 not defined
+#endif
+
+#ifndef PRIoLEAST32
+#error PRIoLEAST32 not defined
+#endif
+
+#ifndef PRIoLEAST64
+#error PRIoLEAST64 not defined
+#endif
+
+#ifndef PRIoFAST8
+#error PRIoFAST8 not defined
+#endif
+
+#ifndef PRIoFAST16
+#error PRIoFAST16 not defined
+#endif
+
+#ifndef PRIoFAST32
+#error PRIoFAST32 not defined
+#endif
+
+#ifndef PRIoFAST64
+#error PRIoFAST64 not defined
+#endif
+
+#ifndef PRIoMAX
+#error PRIoMAX not defined
+#endif
+
+#ifndef PRIoPTR
+#error PRIoPTR not defined
+#endif
+
+#ifndef PRIu8
+#error PRIu8 not defined
+#endif
+
+#ifndef PRIu16
+#error PRIu16 not defined
+#endif
+
+#ifndef PRIu32
+#error PRIu32 not defined
+#endif
+
+#ifndef PRIu64
+#error PRIu64 not defined
+#endif
+
+#ifndef PRIuLEAST8
+#error PRIuLEAST8 not defined
+#endif
+
+#ifndef PRIuLEAST16
+#error PRIuLEAST16 not defined
+#endif
+
+#ifndef PRIuLEAST32
+#error PRIuLEAST32 not defined
+#endif
+
+#ifndef PRIuLEAST64
+#error PRIuLEAST64 not defined
+#endif
+
+#ifndef PRIuFAST8
+#error PRIuFAST8 not defined
+#endif
+
+#ifndef PRIuFAST16
+#error PRIuFAST16 not defined
+#endif
+
+#ifndef PRIuFAST32
+#error PRIuFAST32 not defined
+#endif
+
+#ifndef PRIuFAST64
+#error PRIuFAST64 not defined
+#endif
+
+#ifndef PRIuMAX
+#error PRIuMAX not defined
+#endif
+
+#ifndef PRIuPTR
+#error PRIuPTR not defined
+#endif
+
+#ifndef PRIx8
+#error PRIx8 not defined
+#endif
+
+#ifndef PRIx16
+#error PRIx16 not defined
+#endif
+
+#ifndef PRIx32
+#error PRIx32 not defined
+#endif
+
+#ifndef PRIx64
+#error PRIx64 not defined
+#endif
+
+#ifndef PRIxLEAST8
+#error PRIxLEAST8 not defined
+#endif
+
+#ifndef PRIxLEAST16
+#error PRIxLEAST16 not defined
+#endif
+
+#ifndef PRIxLEAST32
+#error PRIxLEAST32 not defined
+#endif
+
+#ifndef PRIxLEAST64
+#error PRIxLEAST64 not defined
+#endif
+
+#ifndef PRIxFAST8
+#error PRIxFAST8 not defined
+#endif
+
+#ifndef PRIxFAST16
+#error PRIxFAST16 not defined
+#endif
+
+#ifndef PRIxFAST32
+#error PRIxFAST32 not defined
+#endif
+
+#ifndef PRIxFAST64
+#error PRIxFAST64 not defined
+#endif
+
+#ifndef PRIxMAX
+#error PRIxMAX not defined
+#endif
+
+#ifndef PRIxPTR
+#error PRIxPTR not defined
+#endif
+
+#ifndef PRIX8
+#error PRIX8 not defined
+#endif
+
+#ifndef PRIX16
+#error PRIX16 not defined
+#endif
+
+#ifndef PRIX32
+#error PRIX32 not defined
+#endif
+
+#ifndef PRIX64
+#error PRIX64 not defined
+#endif
+
+#ifndef PRIXLEAST8
+#error PRIXLEAST8 not defined
+#endif
+
+#ifndef PRIXLEAST16
+#error PRIXLEAST16 not defined
+#endif
+
+#ifndef PRIXLEAST32
+#error PRIXLEAST32 not defined
+#endif
+
+#ifndef PRIXLEAST64
+#error PRIXLEAST64 not defined
+#endif
+
+#ifndef PRIXFAST8
+#error PRIXFAST8 not defined
+#endif
+
+#ifndef PRIXFAST16
+#error PRIXFAST16 not defined
+#endif
+
+#ifndef PRIXFAST32
+#error PRIXFAST32 not defined
+#endif
+
+#ifndef PRIXFAST64
+#error PRIXFAST64 not defined
+#endif
+
+#ifndef PRIXMAX
+#error PRIXMAX not defined
+#endif
+
+#ifndef PRIXPTR
+#error PRIXPTR not defined
+#endif
+
+#ifndef SCNd8
+#error SCNd8 not defined
+#endif
+
+#ifndef SCNd16
+#error SCNd16 not defined
+#endif
+
+#ifndef SCNd32
+#error SCNd32 not defined
+#endif
+
+#ifndef SCNd64
+#error SCNd64 not defined
+#endif
+
+#ifndef SCNdLEAST8
+#error SCNdLEAST8 not defined
+#endif
+
+#ifndef SCNdLEAST16
+#error SCNdLEAST16 not defined
+#endif
+
+#ifndef SCNdLEAST32
+#error SCNdLEAST32 not defined
+#endif
+
+#ifndef SCNdLEAST64
+#error SCNdLEAST64 not defined
+#endif
+
+#ifndef SCNdFAST8
+#error SCNdFAST8 not defined
+#endif
+
+#ifndef SCNdFAST16
+#error SCNdFAST16 not defined
+#endif
+
+#ifndef SCNdFAST32
+#error SCNdFAST32 not defined
+#endif
+
+#ifndef SCNdFAST64
+#error SCNdFAST64 not defined
+#endif
+
+#ifndef SCNdMAX
+#error SCNdMAX not defined
+#endif
+
+#ifndef SCNdPTR
+#error SCNdPTR not defined
+#endif
+
+#ifndef SCNi8
+#error SCNi8 not defined
+#endif
+
+#ifndef SCNi16
+#error SCNi16 not defined
+#endif
+
+#ifndef SCNi32
+#error SCNi32 not defined
+#endif
+
+#ifndef SCNi64
+#error SCNi64 not defined
+#endif
+
+#ifndef SCNiLEAST8
+#error SCNiLEAST8 not defined
+#endif
+
+#ifndef SCNiLEAST16
+#error SCNiLEAST16 not defined
+#endif
+
+#ifndef SCNiLEAST32
+#error SCNiLEAST32 not defined
+#endif
+
+#ifndef SCNiLEAST64
+#error SCNiLEAST64 not defined
+#endif
+
+#ifndef SCNiFAST8
+#error SCNiFAST8 not defined
+#endif
+
+#ifndef SCNiFAST16
+#error SCNiFAST16 not defined
+#endif
+
+#ifndef SCNiFAST32
+#error SCNiFAST32 not defined
+#endif
+
+#ifndef SCNiFAST64
+#error SCNiFAST64 not defined
+#endif
+
+#ifndef SCNiMAX
+#error SCNiMAX not defined
+#endif
+
+#ifndef SCNiPTR
+#error SCNiPTR not defined
+#endif
+
+#ifndef SCNo8
+#error SCNo8 not defined
+#endif
+
+#ifndef SCNo16
+#error SCNo16 not defined
+#endif
+
+#ifndef SCNo32
+#error SCNo32 not defined
+#endif
+
+#ifndef SCNo64
+#error SCNo64 not defined
+#endif
+
+#ifndef SCNoLEAST8
+#error SCNoLEAST8 not defined
+#endif
+
+#ifndef SCNoLEAST16
+#error SCNoLEAST16 not defined
+#endif
+
+#ifndef SCNoLEAST32
+#error SCNoLEAST32 not defined
+#endif
+
+#ifndef SCNoLEAST64
+#error SCNoLEAST64 not defined
+#endif
+
+#ifndef SCNoFAST8
+#error SCNoFAST8 not defined
+#endif
+
+#ifndef SCNoFAST16
+#error SCNoFAST16 not defined
+#endif
+
+#ifndef SCNoFAST32
+#error SCNoFAST32 not defined
+#endif
+
+#ifndef SCNoFAST64
+#error SCNoFAST64 not defined
+#endif
+
+#ifndef SCNoMAX
+#error SCNoMAX not defined
+#endif
+
+#ifndef SCNoPTR
+#error SCNoPTR not defined
+#endif
+
+#ifndef SCNu8
+#error SCNu8 not defined
+#endif
+
+#ifndef SCNu16
+#error SCNu16 not defined
+#endif
+
+#ifndef SCNu32
+#error SCNu32 not defined
+#endif
+
+#ifndef SCNu64
+#error SCNu64 not defined
+#endif
+
+#ifndef SCNuLEAST8
+#error SCNuLEAST8 not defined
+#endif
+
+#ifndef SCNuLEAST16
+#error SCNuLEAST16 not defined
+#endif
+
+#ifndef SCNuLEAST32
+#error SCNuLEAST32 not defined
+#endif
+
+#ifndef SCNuLEAST64
+#error SCNuLEAST64 not defined
+#endif
+
+#ifndef SCNuFAST8
+#error SCNuFAST8 not defined
+#endif
+
+#ifndef SCNuFAST16
+#error SCNuFAST16 not defined
+#endif
+
+#ifndef SCNuFAST32
+#error SCNuFAST32 not defined
+#endif
+
+#ifndef SCNuFAST64
+#error SCNuFAST64 not defined
+#endif
+
+#ifndef SCNuMAX
+#error SCNuMAX not defined
+#endif
+
+#ifndef SCNuPTR
+#error SCNuPTR not defined
+#endif
+
+#ifndef SCNx8
+#error SCNx8 not defined
+#endif
+
+#ifndef SCNx16
+#error SCNx16 not defined
+#endif
+
+#ifndef SCNx32
+#error SCNx32 not defined
+#endif
+
+#ifndef SCNx64
+#error SCNx64 not defined
+#endif
+
+#ifndef SCNxLEAST8
+#error SCNxLEAST8 not defined
+#endif
+
+#ifndef SCNxLEAST16
+#error SCNxLEAST16 not defined
+#endif
+
+#ifndef SCNxLEAST32
+#error SCNxLEAST32 not defined
+#endif
+
+#ifndef SCNxLEAST64
+#error SCNxLEAST64 not defined
+#endif
+
+#ifndef SCNxFAST8
+#error SCNxFAST8 not defined
+#endif
+
+#ifndef SCNxFAST16
+#error SCNxFAST16 not defined
+#endif
+
+#ifndef SCNxFAST32
+#error SCNxFAST32 not defined
+#endif
+
+#ifndef SCNxFAST64
+#error SCNxFAST64 not defined
+#endif
+
+#ifndef SCNxMAX
+#error SCNxMAX not defined
+#endif
+
+#ifndef SCNxPTR
+#error SCNxPTR not defined
+#endif
+
+int main()
+{
+ {
+ std::int8_t i1 = 0;
+ std::int16_t i2 = 0;
+ std::int32_t i3 = 0;
+ std::int64_t i4 = 0;
+ }
+ {
+ std::uint8_t i1 = 0;
+ std::uint16_t i2 = 0;
+ std::uint32_t i3 = 0;
+ std::uint64_t i4 = 0;
+ }
+ {
+ std::int_least8_t i1 = 0;
+ std::int_least16_t i2 = 0;
+ std::int_least32_t i3 = 0;
+ std::int_least64_t i4 = 0;
+ }
+ {
+ std::uint_least8_t i1 = 0;
+ std::uint_least16_t i2 = 0;
+ std::uint_least32_t i3 = 0;
+ std::uint_least64_t i4 = 0;
+ }
+ {
+ std::int_fast8_t i1 = 0;
+ std::int_fast16_t i2 = 0;
+ std::int_fast32_t i3 = 0;
+ std::int_fast64_t i4 = 0;
+ }
+ {
+ std::uint_fast8_t i1 = 0;
+ std::uint_fast16_t i2 = 0;
+ std::uint_fast32_t i3 = 0;
+ std::uint_fast64_t i4 = 0;
+ }
+ {
+ std::intptr_t i1 = 0;
+ std::uintptr_t i2 = 0;
+ std::intmax_t i3 = 0;
+ std::uintmax_t i4 = 0;
+ }
+ {
+ std::imaxdiv_t i1 = {0};
+ }
+ std::intmax_t i = 0;
+ static_assert((std::is_same<decltype(std::imaxabs(i)), std::intmax_t>::value), "");
+ static_assert((std::is_same<decltype(std::imaxdiv(i, i)), std::imaxdiv_t>::value), "");
+ static_assert((std::is_same<decltype(std::strtoimax("", (char**)0, 0)), std::intmax_t>::value), "");
+ static_assert((std::is_same<decltype(std::strtoumax("", (char**)0, 0)), std::uintmax_t>::value), "");
+ static_assert((std::is_same<decltype(std::wcstoimax(L"", (wchar_t**)0, 0)), std::intmax_t>::value), "");
+ static_assert((std::is_same<decltype(std::wcstoumax(L"", (wchar_t**)0, 0)), std::uintmax_t>::value), "");
+}
diff --git a/test/std/input.output/file.streams/c.files/cstdio.pass.cpp b/test/std/input.output/file.streams/c.files/cstdio.pass.cpp
new file mode 100644
index 000000000000..ec4ad8a3bbca
--- /dev/null
+++ b/test/std/input.output/file.streams/c.files/cstdio.pass.cpp
@@ -0,0 +1,148 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test <cstdio>
+
+#include <cstdio>
+#include <type_traits>
+
+#ifndef BUFSIZ
+#error BUFSIZ not defined
+#endif
+
+#ifndef EOF
+#error EOF not defined
+#endif
+
+#ifndef FILENAME_MAX
+#error FILENAME_MAX not defined
+#endif
+
+#ifndef FOPEN_MAX
+#error FOPEN_MAX not defined
+#endif
+
+#ifndef L_tmpnam
+#error L_tmpnam not defined
+#endif
+
+#ifndef NULL
+#error NULL not defined
+#endif
+
+#ifndef SEEK_CUR
+#error SEEK_CUR not defined
+#endif
+
+#ifndef SEEK_END
+#error SEEK_END not defined
+#endif
+
+#ifndef SEEK_SET
+#error SEEK_SET not defined
+#endif
+
+#ifndef TMP_MAX
+#error TMP_MAX not defined
+#endif
+
+#ifndef _IOFBF
+#error _IOFBF not defined
+#endif
+
+#ifndef _IOLBF
+#error _IOLBF not defined
+#endif
+
+#ifndef _IONBF
+#error _IONBF not defined
+#endif
+
+#ifndef stderr
+#error stderr not defined
+#endif
+
+#ifndef stdin
+#error stdin not defined
+#endif
+
+#ifndef stdout
+#error stdout not defined
+#endif
+
+#include <cstdarg>
+
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wformat-zero-length"
+
+int main()
+{
+ std::FILE* fp = 0;
+ std::fpos_t fpos = {0};
+ std::size_t s = 0;
+ char* cp = 0;
+ std::va_list va;
+ static_assert((std::is_same<decltype(std::fclose(fp)), int>::value), "");
+ static_assert((std::is_same<decltype(std::fflush(fp)), int>::value), "");
+ static_assert((std::is_same<decltype(std::setbuf(fp,cp)), void>::value), "");
+ static_assert((std::is_same<decltype(std::vfprintf(fp,"",va)), int>::value), "");
+ static_assert((std::is_same<decltype(std::fprintf(fp," ")), int>::value), "");
+ static_assert((std::is_same<decltype(std::fscanf(fp,"")), int>::value), "");
+ static_assert((std::is_same<decltype(std::snprintf(cp,0," ")), int>::value), "");
+ static_assert((std::is_same<decltype(std::sprintf(cp," ")), int>::value), "");
+ static_assert((std::is_same<decltype(std::sscanf("","")), int>::value), "");
+ static_assert((std::is_same<decltype(std::vfprintf(fp,"",va)), int>::value), "");
+ static_assert((std::is_same<decltype(std::vfscanf(fp,"",va)), int>::value), "");
+ static_assert((std::is_same<decltype(std::vsnprintf(cp,0," ",va)), int>::value), "");
+ static_assert((std::is_same<decltype(std::vsprintf(cp," ",va)), int>::value), "");
+ static_assert((std::is_same<decltype(std::vsscanf("","",va)), int>::value), "");
+ static_assert((std::is_same<decltype(std::fgetc(fp)), int>::value), "");
+ static_assert((std::is_same<decltype(std::fgets(cp,0,fp)), char*>::value), "");
+ static_assert((std::is_same<decltype(std::fputc(0,fp)), int>::value), "");
+ static_assert((std::is_same<decltype(std::fputs("",fp)), int>::value), "");
+ static_assert((std::is_same<decltype(std::getc(fp)), int>::value), "");
+ static_assert((std::is_same<decltype(std::putc(0,fp)), int>::value), "");
+ static_assert((std::is_same<decltype(std::ungetc(0,fp)), int>::value), "");
+ static_assert((std::is_same<decltype(std::fread((void*)0,0,0,fp)), std::size_t>::value), "");
+ static_assert((std::is_same<decltype(std::fwrite((const void*)0,0,0,fp)), std::size_t>::value), "");
+ static_assert((std::is_same<decltype(std::fgetpos(fp, &fpos)), int>::value), "");
+ static_assert((std::is_same<decltype(std::fseek(fp, 0,0)), int>::value), "");
+ static_assert((std::is_same<decltype(std::fsetpos(fp, &fpos)), int>::value), "");
+ static_assert((std::is_same<decltype(std::ftell(fp)), long>::value), "");
+ static_assert((std::is_same<decltype(std::rewind(fp)), void>::value), "");
+ static_assert((std::is_same<decltype(std::clearerr(fp)), void>::value), "");
+ static_assert((std::is_same<decltype(std::feof(fp)), int>::value), "");
+ static_assert((std::is_same<decltype(std::ferror(fp)), int>::value), "");
+ static_assert((std::is_same<decltype(std::perror("")), void>::value), "");
+
+#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
+ static_assert((std::is_same<decltype(std::fopen("", "")), std::FILE*>::value), "");
+ static_assert((std::is_same<decltype(std::freopen("", "", fp)), std::FILE*>::value), "");
+ static_assert((std::is_same<decltype(std::remove("")), int>::value), "");
+ static_assert((std::is_same<decltype(std::rename("","")), int>::value), "");
+ static_assert((std::is_same<decltype(std::tmpfile()), std::FILE*>::value), "");
+ static_assert((std::is_same<decltype(std::tmpnam(cp)), char*>::value), "");
+#endif
+
+#ifndef _LIBCPP_HAS_NO_STDIN
+ static_assert((std::is_same<decltype(std::getchar()), int>::value), "");
+#if _LIBCPP_STD_VER <= 11
+ static_assert((std::is_same<decltype(std::gets(cp)), char*>::value), "");
+#endif
+ static_assert((std::is_same<decltype(std::scanf(" ")), int>::value), "");
+ static_assert((std::is_same<decltype(std::vscanf("",va)), int>::value), "");
+#endif
+
+#ifndef _LIBCPP_HAS_NO_STDOUT
+ static_assert((std::is_same<decltype(std::printf(" ")), int>::value), "");
+ static_assert((std::is_same<decltype(std::putchar(0)), int>::value), "");
+ static_assert((std::is_same<decltype(std::puts("")), int>::value), "");
+ static_assert((std::is_same<decltype(std::vprintf(" ",va)), int>::value), "");
+#endif
+}
diff --git a/test/std/input.output/file.streams/c.files/gets.fail.cpp b/test/std/input.output/file.streams/c.files/gets.fail.cpp
new file mode 100644
index 000000000000..4250e23c11c2
--- /dev/null
+++ b/test/std/input.output/file.streams/c.files/gets.fail.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test <cstdio>
+
+// gets
+
+#include <cstdio>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ (void) std::gets((char *) NULL);
+#else
+#error
+#endif
+}
diff --git a/test/std/input.output/file.streams/c.files/no.global.filesystem.namespace/fopen.fail.cpp b/test/std/input.output/file.streams/c.files/no.global.filesystem.namespace/fopen.fail.cpp
new file mode 100644
index 000000000000..4d83296f086a
--- /dev/null
+++ b/test/std/input.output/file.streams/c.files/no.global.filesystem.namespace/fopen.fail.cpp
@@ -0,0 +1,15 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <cstdio>
+
+int main() {
+ // fopen is not available on systems without a global filesystem namespace.
+ std::fopen("", "");
+}
diff --git a/test/std/input.output/file.streams/c.files/no.global.filesystem.namespace/lit.local.cfg b/test/std/input.output/file.streams/c.files/no.global.filesystem.namespace/lit.local.cfg
new file mode 100644
index 000000000000..4ea670935591
--- /dev/null
+++ b/test/std/input.output/file.streams/c.files/no.global.filesystem.namespace/lit.local.cfg
@@ -0,0 +1,2 @@
+if 'libcpp-has-no-global-filesystem-namespace' not in config.available_features:
+ config.unsupported = True
diff --git a/test/std/input.output/file.streams/c.files/no.global.filesystem.namespace/rename.fail.cpp b/test/std/input.output/file.streams/c.files/no.global.filesystem.namespace/rename.fail.cpp
new file mode 100644
index 000000000000..deca9bf5b551
--- /dev/null
+++ b/test/std/input.output/file.streams/c.files/no.global.filesystem.namespace/rename.fail.cpp
@@ -0,0 +1,15 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <cstdio>
+
+int main() {
+ // rename is not available on systems without a global filesystem namespace.
+ std::rename("", "");
+}
diff --git a/test/std/input.output/file.streams/c.files/version_ccstdio.pass.cpp b/test/std/input.output/file.streams/c.files/version_ccstdio.pass.cpp
new file mode 100644
index 000000000000..0d7fc5605324
--- /dev/null
+++ b/test/std/input.output/file.streams/c.files/version_ccstdio.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <cstdio>
+
+#include <cstdio>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/input.output/file.streams/c.files/version_cinttypes.pass.cpp b/test/std/input.output/file.streams/c.files/version_cinttypes.pass.cpp
new file mode 100644
index 000000000000..bfd379e43493
--- /dev/null
+++ b/test/std/input.output/file.streams/c.files/version_cinttypes.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <cinttypes>
+
+#include <cinttypes>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/input.output/file.streams/fstreams/filebuf.assign/member_swap.pass.cpp b/test/std/input.output/file.streams/fstreams/filebuf.assign/member_swap.pass.cpp
new file mode 100644
index 000000000000..86844343ecdc
--- /dev/null
+++ b/test/std/input.output/file.streams/fstreams/filebuf.assign/member_swap.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_filebuf
+
+// void swap(basic_filebuf& rhs);
+
+#include <fstream>
+#include <cassert>
+#include "platform_support.h"
+
+int main()
+{
+ std::string temp = get_temp_file_name();
+ {
+ std::filebuf f;
+ assert(f.open(temp.c_str(), std::ios_base::out | std::ios_base::in
+ | std::ios_base::trunc) != 0);
+ assert(f.is_open());
+ assert(f.sputn("123", 3) == 3);
+ f.pubseekoff(1, std::ios_base::beg);
+ assert(f.sgetc() == '2');
+ std::filebuf f2;
+ f2.swap(f);
+ assert(!f.is_open());
+ assert(f2.is_open());
+ assert(f2.sgetc() == '2');
+ }
+ std::remove(temp.c_str());
+ {
+ std::wfilebuf f;
+ assert(f.open(temp.c_str(), std::ios_base::out | std::ios_base::in
+ | std::ios_base::trunc) != 0);
+ assert(f.is_open());
+ assert(f.sputn(L"123", 3) == 3);
+ f.pubseekoff(1, std::ios_base::beg);
+ assert(f.sgetc() == L'2');
+ std::wfilebuf f2;
+ f2.swap(f);
+ assert(!f.is_open());
+ assert(f2.is_open());
+ assert(f2.sgetc() == L'2');
+ }
+ std::remove(temp.c_str());
+}
diff --git a/test/std/input.output/file.streams/fstreams/filebuf.assign/move_assign.pass.cpp b/test/std/input.output/file.streams/fstreams/filebuf.assign/move_assign.pass.cpp
new file mode 100644
index 000000000000..a92ec872a54b
--- /dev/null
+++ b/test/std/input.output/file.streams/fstreams/filebuf.assign/move_assign.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_filebuf
+
+// basic_filebuf& operator=(basic_filebuf&& rhs);
+
+#include <fstream>
+#include <cassert>
+#include "platform_support.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ std::string temp = get_temp_file_name();
+ {
+ std::filebuf f;
+ assert(f.open(temp.c_str(), std::ios_base::out | std::ios_base::in
+ | std::ios_base::trunc) != 0);
+ assert(f.is_open());
+ assert(f.sputn("123", 3) == 3);
+ f.pubseekoff(1, std::ios_base::beg);
+ assert(f.sgetc() == '2');
+ std::filebuf f2;
+ f2 = move(f);
+ assert(!f.is_open());
+ assert(f2.is_open());
+ assert(f2.sgetc() == '2');
+ }
+ std::remove(temp.c_str());
+ {
+ std::wfilebuf f;
+ assert(f.open(temp.c_str(), std::ios_base::out | std::ios_base::in
+ | std::ios_base::trunc) != 0);
+ assert(f.is_open());
+ assert(f.sputn(L"123", 3) == 3);
+ f.pubseekoff(1, std::ios_base::beg);
+ assert(f.sgetc() == L'2');
+ std::wfilebuf f2;
+ f2 = move(f);
+ assert(!f.is_open());
+ assert(f2.is_open());
+ assert(f2.sgetc() == L'2');
+ }
+ std::remove(temp.c_str());
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/input.output/file.streams/fstreams/filebuf.assign/nonmember_swap.pass.cpp b/test/std/input.output/file.streams/fstreams/filebuf.assign/nonmember_swap.pass.cpp
new file mode 100644
index 000000000000..084d001031d8
--- /dev/null
+++ b/test/std/input.output/file.streams/fstreams/filebuf.assign/nonmember_swap.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_filebuf
+
+// template <class charT, class traits>
+// void
+// swap(basic_filebuf<charT, traits>& x, basic_filebuf<charT, traits>& y);
+
+#include <fstream>
+#include <cassert>
+#include "platform_support.h"
+
+int main()
+{
+ std::string temp = get_temp_file_name();
+ {
+ std::filebuf f;
+ assert(f.open(temp.c_str(), std::ios_base::out | std::ios_base::in
+ | std::ios_base::trunc) != 0);
+ assert(f.is_open());
+ assert(f.sputn("123", 3) == 3);
+ f.pubseekoff(1, std::ios_base::beg);
+ assert(f.sgetc() == '2');
+ std::filebuf f2;
+ swap(f2, f);
+ assert(!f.is_open());
+ assert(f2.is_open());
+ assert(f2.sgetc() == '2');
+ }
+ std::remove(temp.c_str());
+ {
+ std::wfilebuf f;
+ assert(f.open(temp.c_str(), std::ios_base::out | std::ios_base::in
+ | std::ios_base::trunc) != 0);
+ assert(f.is_open());
+ assert(f.sputn(L"123", 3) == 3);
+ f.pubseekoff(1, std::ios_base::beg);
+ assert(f.sgetc() == L'2');
+ std::wfilebuf f2;
+ swap(f2, f);
+ assert(!f.is_open());
+ assert(f2.is_open());
+ assert(f2.sgetc() == L'2');
+ }
+ std::remove(temp.c_str());
+}
diff --git a/test/std/input.output/file.streams/fstreams/filebuf.cons/default.pass.cpp b/test/std/input.output/file.streams/fstreams/filebuf.cons/default.pass.cpp
new file mode 100644
index 000000000000..f4fbbf69e69b
--- /dev/null
+++ b/test/std/input.output/file.streams/fstreams/filebuf.cons/default.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_filebuf
+
+// basic_filebuf();
+
+#include <fstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::filebuf f;
+ assert(!f.is_open());
+ }
+ {
+ std::wfilebuf f;
+ assert(!f.is_open());
+ }
+}
diff --git a/test/std/input.output/file.streams/fstreams/filebuf.cons/move.pass.cpp b/test/std/input.output/file.streams/fstreams/filebuf.cons/move.pass.cpp
new file mode 100644
index 000000000000..f13ee44700f3
--- /dev/null
+++ b/test/std/input.output/file.streams/fstreams/filebuf.cons/move.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_filebuf
+
+// basic_filebuf(basic_filebuf&& rhs);
+
+#include <fstream>
+#include <cassert>
+#include "platform_support.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ std::string temp = get_temp_file_name();
+ {
+ std::filebuf f;
+ assert(f.open(temp.c_str(), std::ios_base::out | std::ios_base::in
+ | std::ios_base::trunc) != 0);
+ assert(f.is_open());
+ assert(f.sputn("123", 3) == 3);
+ f.pubseekoff(1, std::ios_base::beg);
+ assert(f.sgetc() == '2');
+ std::filebuf f2(move(f));
+ assert(!f.is_open());
+ assert(f2.is_open());
+ assert(f2.sgetc() == '2');
+ }
+ std::remove(temp.c_str());
+ {
+ std::wfilebuf f;
+ assert(f.open(temp.c_str(), std::ios_base::out | std::ios_base::in
+ | std::ios_base::trunc) != 0);
+ assert(f.is_open());
+ assert(f.sputn(L"123", 3) == 3);
+ f.pubseekoff(1, std::ios_base::beg);
+ assert(f.sgetc() == L'2');
+ std::wfilebuf f2(move(f));
+ assert(!f.is_open());
+ assert(f2.is_open());
+ assert(f2.sgetc() == L'2');
+ }
+ std::remove(temp.c_str());
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/input.output/file.streams/fstreams/filebuf.members/open_pointer.pass.cpp b/test/std/input.output/file.streams/fstreams/filebuf.members/open_pointer.pass.cpp
new file mode 100644
index 000000000000..9d2d56782a3e
--- /dev/null
+++ b/test/std/input.output/file.streams/fstreams/filebuf.members/open_pointer.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// basic_filebuf<charT,traits>* open(const char* s, ios_base::openmode mode);
+
+#include <fstream>
+#include <cassert>
+#include "platform_support.h"
+
+int main()
+{
+ std::string temp = get_temp_file_name();
+ {
+ std::filebuf f;
+ assert(f.open(temp.c_str(), std::ios_base::out) != 0);
+ assert(f.is_open());
+ assert(f.sputn("123", 3) == 3);
+ }
+ {
+ std::filebuf f;
+ assert(f.open(temp.c_str(), std::ios_base::in) != 0);
+ assert(f.is_open());
+ assert(f.sbumpc() == '1');
+ assert(f.sbumpc() == '2');
+ assert(f.sbumpc() == '3');
+ }
+ std::remove(temp.c_str());
+ {
+ std::wfilebuf f;
+ assert(f.open(temp.c_str(), std::ios_base::out) != 0);
+ assert(f.is_open());
+ assert(f.sputn(L"123", 3) == 3);
+ }
+ {
+ std::wfilebuf f;
+ assert(f.open(temp.c_str(), std::ios_base::in) != 0);
+ assert(f.is_open());
+ assert(f.sbumpc() == L'1');
+ assert(f.sbumpc() == L'2');
+ assert(f.sbumpc() == L'3');
+ }
+ remove(temp.c_str());
+}
diff --git a/test/std/input.output/file.streams/fstreams/filebuf.virtuals/overflow.pass.cpp b/test/std/input.output/file.streams/fstreams/filebuf.virtuals/overflow.pass.cpp
new file mode 100644
index 000000000000..1da385698210
--- /dev/null
+++ b/test/std/input.output/file.streams/fstreams/filebuf.virtuals/overflow.pass.cpp
@@ -0,0 +1,142 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// int_type overflow(int_type c = traits::eof());
+
+// This test is not entirely portable
+
+#include <fstream>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+template <class CharT>
+struct test_buf
+ : public std::basic_filebuf<CharT>
+{
+ typedef std::basic_filebuf<CharT> base;
+ typedef typename base::char_type char_type;
+ typedef typename base::int_type int_type;
+ typedef typename base::traits_type traits_type;
+
+ char_type* pbase() const {return base::pbase();}
+ char_type* pptr() const {return base::pptr();}
+ char_type* epptr() const {return base::epptr();}
+ void gbump(int n) {base::gbump(n);}
+
+ virtual int_type overflow(int_type c = traits_type::eof()) {return base::overflow(c);}
+};
+
+int main()
+{
+ {
+ test_buf<char> f;
+ assert(f.open("overflow.dat", std::ios_base::out) != 0);
+ assert(f.is_open());
+ assert(f.pbase() == 0);
+ assert(f.pptr() == 0);
+ assert(f.epptr() == 0);
+ assert(f.overflow('a') == 'a');
+ assert(f.pbase() != 0);
+ assert(f.pptr() == f.pbase());
+ assert(f.epptr() - f.pbase() == 4095);
+ }
+ {
+ test_buf<char> f;
+ assert(f.open("overflow.dat", std::ios_base::in) != 0);
+ assert(f.is_open());
+ assert(f.sgetc() == 'a');
+ }
+ std::remove("overflow.dat");
+ {
+ test_buf<char> f;
+ f.pubsetbuf(0, 0);
+ assert(f.open("overflow.dat", std::ios_base::out) != 0);
+ assert(f.is_open());
+ assert(f.pbase() == 0);
+ assert(f.pptr() == 0);
+ assert(f.epptr() == 0);
+ assert(f.overflow('a') == 'a');
+ assert(f.pbase() == 0);
+ assert(f.pptr() == 0);
+ assert(f.epptr() == 0);
+ }
+ {
+ test_buf<char> f;
+ assert(f.open("overflow.dat", std::ios_base::in) != 0);
+ assert(f.is_open());
+ assert(f.sgetc() == 'a');
+ }
+ std::remove("overflow.dat");
+ {
+ test_buf<wchar_t> f;
+ assert(f.open("overflow.dat", std::ios_base::out) != 0);
+ assert(f.is_open());
+ assert(f.pbase() == 0);
+ assert(f.pptr() == 0);
+ assert(f.epptr() == 0);
+ assert(f.overflow(L'a') == L'a');
+ assert(f.pbase() != 0);
+ assert(f.pptr() == f.pbase());
+ assert(f.epptr() - f.pbase() == 4095);
+ }
+ {
+ test_buf<wchar_t> f;
+ assert(f.open("overflow.dat", std::ios_base::in) != 0);
+ assert(f.is_open());
+ assert(f.sgetc() == L'a');
+ }
+ std::remove("overflow.dat");
+ {
+ test_buf<wchar_t> f;
+ f.pubsetbuf(0, 0);
+ assert(f.open("overflow.dat", std::ios_base::out) != 0);
+ assert(f.is_open());
+ assert(f.pbase() == 0);
+ assert(f.pptr() == 0);
+ assert(f.epptr() == 0);
+ assert(f.overflow(L'a') == L'a');
+ assert(f.pbase() == 0);
+ assert(f.pptr() == 0);
+ assert(f.epptr() == 0);
+ }
+ {
+ test_buf<wchar_t> f;
+ assert(f.open("overflow.dat", std::ios_base::in) != 0);
+ assert(f.is_open());
+ assert(f.sgetc() == L'a');
+ }
+ std::remove("overflow.dat");
+ {
+ test_buf<wchar_t> f;
+ f.pubimbue(std::locale(LOCALE_en_US_UTF_8));
+ assert(f.open("overflow.dat", std::ios_base::out) != 0);
+ assert(f.sputc(0x4E51) == 0x4E51);
+ assert(f.sputc(0x4E52) == 0x4E52);
+ assert(f.sputc(0x4E53) == 0x4E53);
+ }
+ {
+ test_buf<char> f;
+ assert(f.open("overflow.dat", std::ios_base::in) != 0);
+ assert(f.is_open());
+ assert(f.sbumpc() == 0xE4);
+ assert(f.sbumpc() == 0xB9);
+ assert(f.sbumpc() == 0x91);
+ assert(f.sbumpc() == 0xE4);
+ assert(f.sbumpc() == 0xB9);
+ assert(f.sbumpc() == 0x92);
+ assert(f.sbumpc() == 0xE4);
+ assert(f.sbumpc() == 0xB9);
+ assert(f.sbumpc() == 0x93);
+ assert(f.sbumpc() == -1);
+ }
+ std::remove("overflow.dat");
+}
diff --git a/test/std/input.output/file.streams/fstreams/filebuf.virtuals/pbackfail.pass.cpp b/test/std/input.output/file.streams/fstreams/filebuf.virtuals/pbackfail.pass.cpp
new file mode 100644
index 000000000000..4419cb51a6dc
--- /dev/null
+++ b/test/std/input.output/file.streams/fstreams/filebuf.virtuals/pbackfail.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// int_type pbackfail(int_type c = traits::eof());
+
+// This test is not entirely portable
+
+#include <fstream>
+#include <cassert>
+
+template <class CharT>
+struct test_buf
+ : public std::basic_filebuf<CharT>
+{
+ typedef std::basic_filebuf<CharT> base;
+ typedef typename base::char_type char_type;
+ typedef typename base::int_type int_type;
+ typedef typename base::traits_type traits_type;
+
+ char_type* eback() const {return base::eback();}
+ char_type* gptr() const {return base::gptr();}
+ char_type* egptr() const {return base::egptr();}
+ void gbump(int n) {base::gbump(n);}
+
+ virtual int_type pbackfail(int_type c = traits_type::eof()) {return base::pbackfail(c);}
+};
+
+int main()
+{
+ {
+ test_buf<char> f;
+ assert(f.open("underflow.dat", std::ios_base::in) != 0);
+ assert(f.is_open());
+ assert(f.sbumpc() == '1');
+ assert(f.sgetc() == '2');
+ assert(f.pbackfail('a') == -1);
+ }
+ {
+ test_buf<char> f;
+ assert(f.open("underflow.dat", std::ios_base::in | std::ios_base::out) != 0);
+ assert(f.is_open());
+ assert(f.sbumpc() == '1');
+ assert(f.sgetc() == '2');
+ assert(f.pbackfail('a') == 'a');
+ assert(f.sbumpc() == 'a');
+ assert(f.sgetc() == '2');
+ }
+}
diff --git a/test/std/input.output/file.streams/fstreams/filebuf.virtuals/seekoff.pass.cpp b/test/std/input.output/file.streams/fstreams/filebuf.virtuals/seekoff.pass.cpp
new file mode 100644
index 000000000000..eb15facad5ba
--- /dev/null
+++ b/test/std/input.output/file.streams/fstreams/filebuf.virtuals/seekoff.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// pos_type seekoff(off_type off, ios_base::seekdir way,
+// ios_base::openmode which = ios_base::in | ios_base::out);
+// pos_type seekpos(pos_type sp,
+// ios_base::openmode which = ios_base::in | ios_base::out);
+
+// This test is not entirely portable
+
+#include <fstream>
+#include <cassert>
+
+int main()
+{
+ {
+ char buf[10];
+ typedef std::filebuf::pos_type pos_type;
+ std::filebuf f;
+ f.pubsetbuf(buf, sizeof(buf));
+ assert(f.open("seekoff.dat", std::ios_base::in | std::ios_base::out
+ | std::ios_base::trunc) != 0);
+ assert(f.is_open());
+ f.sputn("abcdefghijklmnopqrstuvwxyz", 26);
+ assert(buf[0] == 'v');
+ pos_type p = f.pubseekoff(-15, std::ios_base::cur);
+ assert(p == 11);
+ assert(f.sgetc() == 'l');
+ f.pubseekoff(0, std::ios_base::beg);
+ assert(f.sgetc() == 'a');
+ f.pubseekoff(-1, std::ios_base::end);
+ assert(f.sgetc() == 'z');
+ assert(f.pubseekpos(p) == p);
+ assert(f.sgetc() == 'l');
+ }
+ std::remove("seekoff.dat");
+ {
+ wchar_t buf[10];
+ typedef std::filebuf::pos_type pos_type;
+ std::wfilebuf f;
+ f.pubsetbuf(buf, sizeof(buf)/sizeof(buf[0]));
+ assert(f.open("seekoff.dat", std::ios_base::in | std::ios_base::out
+ | std::ios_base::trunc) != 0);
+ assert(f.is_open());
+ f.sputn(L"abcdefghijklmnopqrstuvwxyz", 26);
+ assert(buf[0] == L'v');
+ pos_type p = f.pubseekoff(-15, std::ios_base::cur);
+ assert(p == 11);
+ assert(f.sgetc() == L'l');
+ f.pubseekoff(0, std::ios_base::beg);
+ assert(f.sgetc() == L'a');
+ f.pubseekoff(-1, std::ios_base::end);
+ assert(f.sgetc() == L'z');
+ assert(f.pubseekpos(p) == p);
+ assert(f.sgetc() == L'l');
+ }
+ std::remove("seekoff.dat");
+}
diff --git a/test/std/input.output/file.streams/fstreams/filebuf.virtuals/underflow.dat b/test/std/input.output/file.streams/fstreams/filebuf.virtuals/underflow.dat
new file mode 100644
index 000000000000..e2e107ac61ac
--- /dev/null
+++ b/test/std/input.output/file.streams/fstreams/filebuf.virtuals/underflow.dat
@@ -0,0 +1 @@
+123456789 \ No newline at end of file
diff --git a/test/std/input.output/file.streams/fstreams/filebuf.virtuals/underflow.pass.cpp b/test/std/input.output/file.streams/fstreams/filebuf.virtuals/underflow.pass.cpp
new file mode 100644
index 000000000000..e34bc844bd28
--- /dev/null
+++ b/test/std/input.output/file.streams/fstreams/filebuf.virtuals/underflow.pass.cpp
@@ -0,0 +1,121 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// int_type underflow();
+
+// This test is not entirely portable
+
+#include <fstream>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+template <class CharT>
+struct test_buf
+ : public std::basic_filebuf<CharT>
+{
+ typedef std::basic_filebuf<CharT> base;
+ typedef typename base::char_type char_type;
+ typedef typename base::int_type int_type;
+
+ char_type* eback() const {return base::eback();}
+ char_type* gptr() const {return base::gptr();}
+ char_type* egptr() const {return base::egptr();}
+ void gbump(int n) {base::gbump(n);}
+
+ virtual int_type underflow() {return base::underflow();}
+};
+
+int main()
+{
+ {
+ test_buf<char> f;
+ assert(f.open("underflow.dat", std::ios_base::in) != 0);
+ assert(f.is_open());
+ assert(f.eback() == 0);
+ assert(f.gptr() == 0);
+ assert(f.egptr() == 0);
+ assert(f.underflow() == '1');
+ assert(f.eback() != 0);
+ assert(f.eback() == f.gptr());
+ assert(*f.gptr() == '1');
+ assert(f.egptr() - f.eback() == 9);
+ }
+ {
+ test_buf<char> f;
+ assert(f.open("underflow.dat", std::ios_base::in) != 0);
+ assert(f.pubsetbuf(0, 0));
+ assert(f.is_open());
+ assert(f.eback() == 0);
+ assert(f.gptr() == 0);
+ assert(f.egptr() == 0);
+ assert(f.underflow() == '1');
+ assert(f.eback() != 0);
+ assert(f.eback() == f.gptr());
+ assert(*f.gptr() == '1');
+ assert(f.egptr() - f.eback() == 8);
+ f.gbump(8);
+ assert(f.sgetc() == '9');
+ assert(f.eback()[0] == '5');
+ assert(f.eback()[1] == '6');
+ assert(f.eback()[2] == '7');
+ assert(f.eback()[3] == '8');
+ assert(f.gptr() - f.eback() == 4);
+ assert(*f.gptr() == '9');
+ assert(f.egptr() - f.gptr() == 1);
+ }
+ {
+ test_buf<wchar_t> f;
+ assert(f.open("underflow.dat", std::ios_base::in) != 0);
+ assert(f.is_open());
+ assert(f.eback() == 0);
+ assert(f.gptr() == 0);
+ assert(f.egptr() == 0);
+ assert(f.underflow() == L'1');
+ assert(f.eback() != 0);
+ assert(f.eback() == f.gptr());
+ assert(*f.gptr() == L'1');
+ assert(f.egptr() - f.eback() == 9);
+ }
+ {
+ test_buf<wchar_t> f;
+ assert(f.pubsetbuf(0, 0));
+ assert(f.open("underflow.dat", std::ios_base::in) != 0);
+ assert(f.is_open());
+ assert(f.eback() == 0);
+ assert(f.gptr() == 0);
+ assert(f.egptr() == 0);
+ assert(f.underflow() == L'1');
+ assert(f.eback() != 0);
+ assert(f.eback() == f.gptr());
+ assert(*f.gptr() == L'1');
+ assert(f.egptr() - f.eback() == 8);
+ f.gbump(8);
+ assert(f.sgetc() == L'9');
+ assert(f.eback()[0] == L'5');
+ assert(f.eback()[1] == L'6');
+ assert(f.eback()[2] == L'7');
+ assert(f.eback()[3] == L'8');
+ assert(f.gptr() - f.eback() == 4);
+ assert(*f.gptr() == L'9');
+ assert(f.egptr() - f.gptr() == 1);
+ }
+ {
+ test_buf<wchar_t> f;
+ f.pubimbue(std::locale(LOCALE_en_US_UTF_8));
+ assert(f.open("underflow_utf8.dat", std::ios_base::in) != 0);
+ assert(f.is_open());
+ assert(f.sbumpc() == 0x4E51);
+ assert(f.sbumpc() == 0x4E52);
+ assert(f.sbumpc() == 0x4E53);
+ assert(f.sbumpc() == -1);
+ }
+}
diff --git a/test/std/input.output/file.streams/fstreams/filebuf.virtuals/underflow_utf8.dat b/test/std/input.output/file.streams/fstreams/filebuf.virtuals/underflow_utf8.dat
new file mode 100644
index 000000000000..ee7063e1207c
--- /dev/null
+++ b/test/std/input.output/file.streams/fstreams/filebuf.virtuals/underflow_utf8.dat
@@ -0,0 +1 @@
+乑乒乓 \ No newline at end of file
diff --git a/test/std/input.output/file.streams/fstreams/filebuf/types.pass.cpp b/test/std/input.output/file.streams/fstreams/filebuf/types.pass.cpp
new file mode 100644
index 000000000000..5d77e0054b75
--- /dev/null
+++ b/test/std/input.output/file.streams/fstreams/filebuf/types.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_filebuf
+// : public basic_streambuf<charT, traits>
+// {
+// public:
+// typedef charT char_type;
+// typedef traits traits_type;
+// typedef typename traits_type::int_type int_type;
+// typedef typename traits_type::pos_type pos_type;
+// typedef typename traits_type::off_type off_type;
+
+#include <fstream>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_base_of<std::basic_streambuf<char>, std::basic_filebuf<char> >::value), "");
+ static_assert((std::is_same<std::basic_filebuf<char>::char_type, char>::value), "");
+ static_assert((std::is_same<std::basic_filebuf<char>::traits_type, std::char_traits<char> >::value), "");
+ static_assert((std::is_same<std::basic_filebuf<char>::int_type, std::char_traits<char>::int_type>::value), "");
+ static_assert((std::is_same<std::basic_filebuf<char>::pos_type, std::char_traits<char>::pos_type>::value), "");
+ static_assert((std::is_same<std::basic_filebuf<char>::off_type, std::char_traits<char>::off_type>::value), "");
+}
diff --git a/test/std/input.output/file.streams/fstreams/fstream.assign/member_swap.pass.cpp b/test/std/input.output/file.streams/fstreams/fstream.assign/member_swap.pass.cpp
new file mode 100644
index 000000000000..fcc86a13ffa1
--- /dev/null
+++ b/test/std/input.output/file.streams/fstreams/fstream.assign/member_swap.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_fstream
+
+// void swap(basic_fstream& rhs);
+
+#include <fstream>
+#include <cassert>
+#include "platform_support.h"
+
+int main()
+{
+ std::string temp1 = get_temp_file_name();
+ std::string temp2 = get_temp_file_name();
+ {
+ std::fstream fs1(temp1.c_str(), std::ios_base::in | std::ios_base::out
+ | std::ios_base::trunc);
+ std::fstream fs2(temp2.c_str(), std::ios_base::in | std::ios_base::out
+ | std::ios_base::trunc);
+ fs1 << 1 << ' ' << 2;
+ fs2 << 2 << ' ' << 1;
+ fs1.seekg(0);
+ fs1.swap(fs2);
+ fs1.seekg(0);
+ int i;
+ fs1 >> i;
+ assert(i == 2);
+ fs1 >> i;
+ assert(i == 1);
+ i = 0;
+ fs2 >> i;
+ assert(i == 1);
+ fs2 >> i;
+ assert(i == 2);
+ }
+ std::remove(temp1.c_str());
+ std::remove(temp2.c_str());
+ {
+ std::wfstream fs1(temp1.c_str(), std::ios_base::in | std::ios_base::out
+ | std::ios_base::trunc);
+ std::wfstream fs2(temp2.c_str(), std::ios_base::in | std::ios_base::out
+ | std::ios_base::trunc);
+ fs1 << 1 << ' ' << 2;
+ fs2 << 2 << ' ' << 1;
+ fs1.seekg(0);
+ fs1.swap(fs2);
+ fs1.seekg(0);
+ int i;
+ fs1 >> i;
+ assert(i == 2);
+ fs1 >> i;
+ assert(i == 1);
+ i = 0;
+ fs2 >> i;
+ assert(i == 1);
+ fs2 >> i;
+ assert(i == 2);
+ }
+ std::remove(temp1.c_str());
+ std::remove(temp2.c_str());
+}
diff --git a/test/std/input.output/file.streams/fstreams/fstream.assign/move_assign.pass.cpp b/test/std/input.output/file.streams/fstreams/fstream.assign/move_assign.pass.cpp
new file mode 100644
index 000000000000..b5157e90edcc
--- /dev/null
+++ b/test/std/input.output/file.streams/fstreams/fstream.assign/move_assign.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_fstream
+
+// basic_fstream& operator=(basic_fstream&& rhs);
+
+#include <fstream>
+#include <cassert>
+#include "platform_support.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ std::string temp = get_temp_file_name();
+ {
+ std::fstream fso(temp.c_str(), std::ios_base::in | std::ios_base::out
+ | std::ios_base::trunc);
+ std::fstream fs;
+ fs = move(fso);
+ double x = 0;
+ fs << 3.25;
+ fs.seekg(0);
+ fs >> x;
+ assert(x == 3.25);
+ }
+ std::remove(temp.c_str());
+ {
+ std::wfstream fso(temp.c_str(), std::ios_base::in | std::ios_base::out
+ | std::ios_base::trunc);
+ std::wfstream fs;
+ fs = move(fso);
+ double x = 0;
+ fs << 3.25;
+ fs.seekg(0);
+ fs >> x;
+ assert(x == 3.25);
+ }
+ std::remove(temp.c_str());
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/input.output/file.streams/fstreams/fstream.assign/nonmember_swap.pass.cpp b/test/std/input.output/file.streams/fstreams/fstream.assign/nonmember_swap.pass.cpp
new file mode 100644
index 000000000000..0a4f7240daa1
--- /dev/null
+++ b/test/std/input.output/file.streams/fstreams/fstream.assign/nonmember_swap.pass.cpp
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_fstream
+
+// template <class charT, class traits>
+// void swap(basic_fstream<charT, traits>& x, basic_fstream<charT, traits>& y);
+
+#include <fstream>
+#include <cassert>
+#include "platform_support.h"
+
+int main()
+{
+ std::string temp1 = get_temp_file_name();
+ std::string temp2 = get_temp_file_name();
+ {
+ std::fstream fs1(temp1.c_str(), std::ios_base::in | std::ios_base::out
+ | std::ios_base::trunc);
+ std::fstream fs2(temp2.c_str(), std::ios_base::in | std::ios_base::out
+ | std::ios_base::trunc);
+ fs1 << 1 << ' ' << 2;
+ fs2 << 2 << ' ' << 1;
+ fs1.seekg(0);
+ swap(fs1, fs2);
+ fs1.seekg(0);
+ int i;
+ fs1 >> i;
+ assert(i == 2);
+ fs1 >> i;
+ assert(i == 1);
+ i = 0;
+ fs2 >> i;
+ assert(i == 1);
+ fs2 >> i;
+ assert(i == 2);
+ }
+ std::remove(temp1.c_str());
+ std::remove(temp2.c_str());
+ {
+ std::wfstream fs1(temp1.c_str(), std::ios_base::in | std::ios_base::out
+ | std::ios_base::trunc);
+ std::wfstream fs2(temp2.c_str(), std::ios_base::in | std::ios_base::out
+ | std::ios_base::trunc);
+ fs1 << 1 << ' ' << 2;
+ fs2 << 2 << ' ' << 1;
+ fs1.seekg(0);
+ swap(fs1, fs2);
+ fs1.seekg(0);
+ int i;
+ fs1 >> i;
+ assert(i == 2);
+ fs1 >> i;
+ assert(i == 1);
+ i = 0;
+ fs2 >> i;
+ assert(i == 1);
+ fs2 >> i;
+ assert(i == 2);
+ }
+ std::remove(temp1.c_str());
+ std::remove(temp2.c_str());
+}
diff --git a/test/std/input.output/file.streams/fstreams/fstream.cons/default.pass.cpp b/test/std/input.output/file.streams/fstreams/fstream.cons/default.pass.cpp
new file mode 100644
index 000000000000..cfd5a031f0fc
--- /dev/null
+++ b/test/std/input.output/file.streams/fstreams/fstream.cons/default.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_fstream
+
+// basic_fstream();
+
+#include <fstream>
+#include <type_traits>
+
+int main()
+{
+ {
+ std::fstream fs;
+ }
+ {
+ std::wfstream fs;
+ }
+}
diff --git a/test/std/input.output/file.streams/fstreams/fstream.cons/move.pass.cpp b/test/std/input.output/file.streams/fstreams/fstream.cons/move.pass.cpp
new file mode 100644
index 000000000000..d2ae3028606c
--- /dev/null
+++ b/test/std/input.output/file.streams/fstreams/fstream.cons/move.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_fstream
+
+// basic_fstream(basic_fstream&& rhs);
+
+#include <fstream>
+#include <cassert>
+#include "platform_support.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ std::string temp = get_temp_file_name();
+ {
+ std::fstream fso(temp, std::ios_base::in | std::ios_base::out
+ | std::ios_base::trunc);
+ std::fstream fs = move(fso);
+ double x = 0;
+ fs << 3.25;
+ fs.seekg(0);
+ fs >> x;
+ assert(x == 3.25);
+ }
+ std::remove(temp.c_str());
+ {
+ std::wfstream fso(temp, std::ios_base::in | std::ios_base::out
+ | std::ios_base::trunc);
+ std::wfstream fs = move(fso);
+ double x = 0;
+ fs << 3.25;
+ fs.seekg(0);
+ fs >> x;
+ assert(x == 3.25);
+ }
+ std::remove(temp.c_str());
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/input.output/file.streams/fstreams/fstream.cons/pointer.pass.cpp b/test/std/input.output/file.streams/fstreams/fstream.cons/pointer.pass.cpp
new file mode 100644
index 000000000000..06a6b77943a6
--- /dev/null
+++ b/test/std/input.output/file.streams/fstreams/fstream.cons/pointer.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_fstream
+
+// explicit basic_fstream(const char* s, ios_base::openmode mode = ios_base::in | ios_base::out);
+
+#include <fstream>
+#include <cassert>
+#include "platform_support.h"
+
+int main()
+{
+ std::string temp = get_temp_file_name();
+ {
+ std::fstream fs(temp.c_str(), std::ios_base::in | std::ios_base::out
+ | std::ios_base::trunc);
+ double x = 0;
+ fs << 3.25;
+ fs.seekg(0);
+ fs >> x;
+ assert(x == 3.25);
+ }
+ std::remove(temp.c_str());
+ {
+ std::wfstream fs(temp.c_str(), std::ios_base::in | std::ios_base::out
+ | std::ios_base::trunc);
+ double x = 0;
+ fs << 3.25;
+ fs.seekg(0);
+ fs >> x;
+ assert(x == 3.25);
+ }
+ std::remove(temp.c_str());
+}
diff --git a/test/std/input.output/file.streams/fstreams/fstream.cons/string.pass.cpp b/test/std/input.output/file.streams/fstreams/fstream.cons/string.pass.cpp
new file mode 100644
index 000000000000..4b0819f8af49
--- /dev/null
+++ b/test/std/input.output/file.streams/fstreams/fstream.cons/string.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_fstream
+
+// explicit basic_fstream(const string& s, ios_base::openmode mode = ios_base::in|ios_base::out);
+
+#include <fstream>
+#include <cassert>
+#include "platform_support.h"
+
+int main()
+{
+ std::string temp = get_temp_file_name();
+ {
+ std::fstream fs(temp,
+ std::ios_base::in | std::ios_base::out
+ | std::ios_base::trunc);
+ double x = 0;
+ fs << 3.25;
+ fs.seekg(0);
+ fs >> x;
+ assert(x == 3.25);
+ }
+ std::remove(temp.c_str());
+ {
+ std::wfstream fs(temp,
+ std::ios_base::in | std::ios_base::out
+ | std::ios_base::trunc);
+ double x = 0;
+ fs << 3.25;
+ fs.seekg(0);
+ fs >> x;
+ assert(x == 3.25);
+ }
+ std::remove(temp.c_str());
+}
diff --git a/test/std/input.output/file.streams/fstreams/fstream.members/close.pass.cpp b/test/std/input.output/file.streams/fstreams/fstream.members/close.pass.cpp
new file mode 100644
index 000000000000..0e4bc7177b8f
--- /dev/null
+++ b/test/std/input.output/file.streams/fstreams/fstream.members/close.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_fstream
+
+// void close();
+
+#include <fstream>
+#include <cassert>
+#include "platform_support.h"
+
+int main()
+{
+ std::string temp = get_temp_file_name();
+ {
+ std::fstream fs;
+ assert(!fs.is_open());
+ fs.open(temp.c_str(), std::ios_base::out);
+ assert(fs.is_open());
+ fs.close();
+ assert(!fs.is_open());
+ }
+ std::remove(temp.c_str());
+ {
+ std::wfstream fs;
+ assert(!fs.is_open());
+ fs.open(temp.c_str(), std::ios_base::out);
+ assert(fs.is_open());
+ fs.close();
+ assert(!fs.is_open());
+ }
+ std::remove(temp.c_str());
+}
diff --git a/test/std/input.output/file.streams/fstreams/fstream.members/open_pointer.pass.cpp b/test/std/input.output/file.streams/fstreams/fstream.members/open_pointer.pass.cpp
new file mode 100644
index 000000000000..231bb82c7434
--- /dev/null
+++ b/test/std/input.output/file.streams/fstreams/fstream.members/open_pointer.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_fstream
+
+// void open(const char* s, ios_base::openmode mode = ios_base::in|ios_base::out);
+
+#include <fstream>
+#include <cassert>
+#include "platform_support.h"
+
+int main()
+{
+ std::string temp = get_temp_file_name();
+ {
+ std::fstream fs;
+ assert(!fs.is_open());
+ fs.open(temp.c_str(), std::ios_base::in | std::ios_base::out
+ | std::ios_base::trunc);
+ assert(fs.is_open());
+ double x = 0;
+ fs << 3.25;
+ fs.seekg(0);
+ fs >> x;
+ assert(x == 3.25);
+ }
+ std::remove(temp.c_str());
+ {
+ std::wfstream fs;
+ assert(!fs.is_open());
+ fs.open(temp.c_str(), std::ios_base::in | std::ios_base::out
+ | std::ios_base::trunc);
+ assert(fs.is_open());
+ double x = 0;
+ fs << 3.25;
+ fs.seekg(0);
+ fs >> x;
+ assert(x == 3.25);
+ }
+ std::remove(temp.c_str());
+}
diff --git a/test/std/input.output/file.streams/fstreams/fstream.members/open_string.pass.cpp b/test/std/input.output/file.streams/fstreams/fstream.members/open_string.pass.cpp
new file mode 100644
index 000000000000..182f12c47d1a
--- /dev/null
+++ b/test/std/input.output/file.streams/fstreams/fstream.members/open_string.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_fstream
+
+// void open(const string& s, ios_base::openmode mode = ios_base::in|ios_base::out);
+
+#include <fstream>
+#include <cassert>
+#include "platform_support.h"
+
+int main()
+{
+ std::string temp = get_temp_file_name();
+ {
+ std::fstream fs;
+ assert(!fs.is_open());
+ fs.open(temp, std::ios_base::in | std::ios_base::out
+ | std::ios_base::trunc);
+ assert(fs.is_open());
+ double x = 0;
+ fs << 3.25;
+ fs.seekg(0);
+ fs >> x;
+ assert(x == 3.25);
+ }
+ std::remove(temp.c_str());
+ {
+ std::wfstream fs;
+ assert(!fs.is_open());
+ fs.open(temp, std::ios_base::in | std::ios_base::out
+ | std::ios_base::trunc);
+ assert(fs.is_open());
+ double x = 0;
+ fs << 3.25;
+ fs.seekg(0);
+ fs >> x;
+ assert(x == 3.25);
+ }
+ std::remove(temp.c_str());
+}
diff --git a/test/std/input.output/file.streams/fstreams/fstream.members/rdbuf.pass.cpp b/test/std/input.output/file.streams/fstreams/fstream.members/rdbuf.pass.cpp
new file mode 100644
index 000000000000..d8398326910b
--- /dev/null
+++ b/test/std/input.output/file.streams/fstreams/fstream.members/rdbuf.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_fstream
+
+// basic_filebuf<charT,traits>* rdbuf() const;
+
+#include <fstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::fstream fs;
+ assert(fs.rdbuf());
+ }
+ {
+ std::wfstream fs;
+ assert(fs.rdbuf());
+ }
+}
diff --git a/test/std/input.output/file.streams/fstreams/fstream/types.pass.cpp b/test/std/input.output/file.streams/fstreams/fstream/types.pass.cpp
new file mode 100644
index 000000000000..6ced241f75fd
--- /dev/null
+++ b/test/std/input.output/file.streams/fstreams/fstream/types.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_fstream
+// : public basic_iostream<charT,traits>
+// {
+// public:
+// typedef charT char_type;
+// typedef traits traits_type;
+// typedef typename traits_type::int_type int_type;
+// typedef typename traits_type::pos_type pos_type;
+// typedef typename traits_type::off_type off_type;
+
+#include <fstream>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_base_of<std::basic_iostream<char>, std::basic_fstream<char> >::value), "");
+ static_assert((std::is_same<std::basic_fstream<char>::char_type, char>::value), "");
+ static_assert((std::is_same<std::basic_fstream<char>::traits_type, std::char_traits<char> >::value), "");
+ static_assert((std::is_same<std::basic_fstream<char>::int_type, std::char_traits<char>::int_type>::value), "");
+ static_assert((std::is_same<std::basic_fstream<char>::pos_type, std::char_traits<char>::pos_type>::value), "");
+ static_assert((std::is_same<std::basic_fstream<char>::off_type, std::char_traits<char>::off_type>::value), "");
+}
diff --git a/test/std/input.output/file.streams/fstreams/ifstream.assign/member_swap.pass.cpp b/test/std/input.output/file.streams/fstreams/ifstream.assign/member_swap.pass.cpp
new file mode 100644
index 000000000000..18443cedb8d9
--- /dev/null
+++ b/test/std/input.output/file.streams/fstreams/ifstream.assign/member_swap.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ifstream
+
+// void swap(basic_ifstream& rhs);
+
+#include <fstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::ifstream fs1("test.dat");
+ std::ifstream fs2("test2.dat");
+ fs1.swap(fs2);
+ double x = 0;
+ fs1 >> x;
+ assert(x == 4.5);
+ fs2 >> x;
+ assert(x == 3.25);
+ }
+ {
+ std::wifstream fs1("test.dat");
+ std::wifstream fs2("test2.dat");
+ fs1.swap(fs2);
+ double x = 0;
+ fs1 >> x;
+ assert(x == 4.5);
+ fs2 >> x;
+ assert(x == 3.25);
+ }
+}
diff --git a/test/std/input.output/file.streams/fstreams/ifstream.assign/move_assign.pass.cpp b/test/std/input.output/file.streams/fstreams/ifstream.assign/move_assign.pass.cpp
new file mode 100644
index 000000000000..9c2fcad33a3c
--- /dev/null
+++ b/test/std/input.output/file.streams/fstreams/ifstream.assign/move_assign.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ifstream
+
+// basic_ifstream& operator=(basic_ifstream&& rhs);
+
+#include <fstream>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::ifstream fso("test.dat");
+ std::ifstream fs;
+ fs = move(fso);
+ double x = 0;
+ fs >> x;
+ assert(x == 3.25);
+ }
+ {
+ std::wifstream fso("test.dat");
+ std::wifstream fs;
+ fs = move(fso);
+ double x = 0;
+ fs >> x;
+ assert(x == 3.25);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/input.output/file.streams/fstreams/ifstream.assign/nonmember_swap.pass.cpp b/test/std/input.output/file.streams/fstreams/ifstream.assign/nonmember_swap.pass.cpp
new file mode 100644
index 000000000000..5700720a0643
--- /dev/null
+++ b/test/std/input.output/file.streams/fstreams/ifstream.assign/nonmember_swap.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ifstream
+
+// template <class charT, class traits>
+// void swap(basic_ifstream<charT, traits>& x, basic_ifstream<charT, traits>& y);
+
+#include <fstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::ifstream fs1("test.dat");
+ std::ifstream fs2("test2.dat");
+ swap(fs1, fs2);
+ double x = 0;
+ fs1 >> x;
+ assert(x == 4.5);
+ fs2 >> x;
+ assert(x == 3.25);
+ }
+ {
+ std::wifstream fs1("test.dat");
+ std::wifstream fs2("test2.dat");
+ swap(fs1, fs2);
+ double x = 0;
+ fs1 >> x;
+ assert(x == 4.5);
+ fs2 >> x;
+ assert(x == 3.25);
+ }
+}
diff --git a/test/std/input.output/file.streams/fstreams/ifstream.assign/test.dat b/test/std/input.output/file.streams/fstreams/ifstream.assign/test.dat
new file mode 100644
index 000000000000..64064d34a8e3
--- /dev/null
+++ b/test/std/input.output/file.streams/fstreams/ifstream.assign/test.dat
@@ -0,0 +1 @@
+3.25 \ No newline at end of file
diff --git a/test/std/input.output/file.streams/fstreams/ifstream.assign/test2.dat b/test/std/input.output/file.streams/fstreams/ifstream.assign/test2.dat
new file mode 100644
index 000000000000..958d30d86d0e
--- /dev/null
+++ b/test/std/input.output/file.streams/fstreams/ifstream.assign/test2.dat
@@ -0,0 +1 @@
+4.5 \ No newline at end of file
diff --git a/test/std/input.output/file.streams/fstreams/ifstream.cons/default.pass.cpp b/test/std/input.output/file.streams/fstreams/ifstream.cons/default.pass.cpp
new file mode 100644
index 000000000000..41e6780e8072
--- /dev/null
+++ b/test/std/input.output/file.streams/fstreams/ifstream.cons/default.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ifstream
+
+// basic_ifstream();
+
+#include <fstream>
+#include <type_traits>
+
+int main()
+{
+ {
+ std::ifstream fs;
+ }
+ {
+ std::wifstream fs;
+ }
+}
diff --git a/test/std/input.output/file.streams/fstreams/ifstream.cons/move.pass.cpp b/test/std/input.output/file.streams/fstreams/ifstream.cons/move.pass.cpp
new file mode 100644
index 000000000000..aaac1212262d
--- /dev/null
+++ b/test/std/input.output/file.streams/fstreams/ifstream.cons/move.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ifstream
+
+// basic_ifstream(basic_ifstream&& rhs);
+
+#include <fstream>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::ifstream fso("test.dat");
+ std::ifstream fs = move(fso);
+ double x = 0;
+ fs >> x;
+ assert(x == 3.25);
+ }
+ {
+ std::wifstream fso("test.dat");
+ std::wifstream fs = move(fso);
+ double x = 0;
+ fs >> x;
+ assert(x == 3.25);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/input.output/file.streams/fstreams/ifstream.cons/pointer.pass.cpp b/test/std/input.output/file.streams/fstreams/ifstream.cons/pointer.pass.cpp
new file mode 100644
index 000000000000..f43df3c9f84a
--- /dev/null
+++ b/test/std/input.output/file.streams/fstreams/ifstream.cons/pointer.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ifstream
+
+// explicit basic_ifstream(const char* s, ios_base::openmode mode = ios_base::in);
+
+#include <fstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::ifstream fs("test.dat");
+ double x = 0;
+ fs >> x;
+ assert(x == 3.25);
+ }
+ {
+ std::ifstream fs("test.dat", std::ios_base::out);
+ double x = 0;
+ fs >> x;
+ assert(x == 3.25);
+ }
+ {
+ std::wifstream fs("test.dat");
+ double x = 0;
+ fs >> x;
+ assert(x == 3.25);
+ }
+ {
+ std::wifstream fs("test.dat", std::ios_base::out);
+ double x = 0;
+ fs >> x;
+ assert(x == 3.25);
+ }
+}
diff --git a/test/std/input.output/file.streams/fstreams/ifstream.cons/string.pass.cpp b/test/std/input.output/file.streams/fstreams/ifstream.cons/string.pass.cpp
new file mode 100644
index 000000000000..ad5fe5149df2
--- /dev/null
+++ b/test/std/input.output/file.streams/fstreams/ifstream.cons/string.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ifstream
+
+// explicit basic_ifstream(const string& s, ios_base::openmode mode = ios_base::in);
+
+#include <fstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::ifstream fs(std::string("test.dat"));
+ double x = 0;
+ fs >> x;
+ assert(x == 3.25);
+ }
+ {
+ std::ifstream fs(std::string("test.dat"), std::ios_base::out);
+ double x = 0;
+ fs >> x;
+ assert(x == 3.25);
+ }
+ {
+ std::wifstream fs(std::string("test.dat"));
+ double x = 0;
+ fs >> x;
+ assert(x == 3.25);
+ }
+ {
+ std::wifstream fs(std::string("test.dat"), std::ios_base::out);
+ double x = 0;
+ fs >> x;
+ assert(x == 3.25);
+ }
+}
diff --git a/test/std/input.output/file.streams/fstreams/ifstream.cons/test.dat b/test/std/input.output/file.streams/fstreams/ifstream.cons/test.dat
new file mode 100644
index 000000000000..64064d34a8e3
--- /dev/null
+++ b/test/std/input.output/file.streams/fstreams/ifstream.cons/test.dat
@@ -0,0 +1 @@
+3.25 \ No newline at end of file
diff --git a/test/std/input.output/file.streams/fstreams/ifstream.members/close.pass.cpp b/test/std/input.output/file.streams/fstreams/ifstream.members/close.pass.cpp
new file mode 100644
index 000000000000..3e3933240851
--- /dev/null
+++ b/test/std/input.output/file.streams/fstreams/ifstream.members/close.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ifstream
+
+// void close();
+
+#include <fstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::ifstream fs;
+ assert(!fs.is_open());
+ fs.open("test.dat");
+ assert(fs.is_open());
+ fs.close();
+ assert(!fs.is_open());
+ }
+ {
+ std::wifstream fs;
+ assert(!fs.is_open());
+ fs.open("test.dat");
+ assert(fs.is_open());
+ fs.close();
+ assert(!fs.is_open());
+ }
+}
diff --git a/test/std/input.output/file.streams/fstreams/ifstream.members/open_pointer.pass.cpp b/test/std/input.output/file.streams/fstreams/ifstream.members/open_pointer.pass.cpp
new file mode 100644
index 000000000000..47dc85fac605
--- /dev/null
+++ b/test/std/input.output/file.streams/fstreams/ifstream.members/open_pointer.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ifstream
+
+// void open(const char* s, ios_base::openmode mode = ios_base::in);
+
+#include <fstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::ifstream fs;
+ assert(!fs.is_open());
+ char c = 'a';
+ fs >> c;
+ assert(fs.fail());
+ assert(c == 'a');
+ fs.open("test.dat");
+ assert(fs.is_open());
+ fs >> c;
+ assert(c == 'r');
+ }
+ {
+ std::wifstream fs;
+ assert(!fs.is_open());
+ wchar_t c = L'a';
+ fs >> c;
+ assert(fs.fail());
+ assert(c == L'a');
+ fs.open("test.dat");
+ assert(fs.is_open());
+ fs >> c;
+ assert(c == L'r');
+ }
+}
diff --git a/test/std/input.output/file.streams/fstreams/ifstream.members/open_string.pass.cpp b/test/std/input.output/file.streams/fstreams/ifstream.members/open_string.pass.cpp
new file mode 100644
index 000000000000..619694e2736a
--- /dev/null
+++ b/test/std/input.output/file.streams/fstreams/ifstream.members/open_string.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ifstream
+
+// void open(const string& s, ios_base::openmode mode = ios_base::in);
+
+#include <fstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::ifstream fs;
+ assert(!fs.is_open());
+ char c = 'a';
+ fs >> c;
+ assert(fs.fail());
+ assert(c == 'a');
+ fs.open(std::string("test.dat"));
+ assert(fs.is_open());
+ fs >> c;
+ assert(c == 'r');
+ }
+ {
+ std::wifstream fs;
+ assert(!fs.is_open());
+ wchar_t c = L'a';
+ fs >> c;
+ assert(fs.fail());
+ assert(c == L'a');
+ fs.open(std::string("test.dat"));
+ assert(fs.is_open());
+ fs >> c;
+ assert(c == L'r');
+ }
+}
diff --git a/test/std/input.output/file.streams/fstreams/ifstream.members/rdbuf.pass.cpp b/test/std/input.output/file.streams/fstreams/ifstream.members/rdbuf.pass.cpp
new file mode 100644
index 000000000000..53fd294e71f2
--- /dev/null
+++ b/test/std/input.output/file.streams/fstreams/ifstream.members/rdbuf.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ifstream
+
+// basic_filebuf<charT,traits>* rdbuf() const;
+
+#include <fstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::ifstream fs("test.dat");
+ std::filebuf* fb = fs.rdbuf();
+ assert(fb->sgetc() == 'r');
+ }
+ {
+ std::wifstream fs("test.dat");
+ std::wfilebuf* fb = fs.rdbuf();
+ assert(fb->sgetc() == L'r');
+ }
+}
diff --git a/test/std/input.output/file.streams/fstreams/ifstream.members/test.dat b/test/std/input.output/file.streams/fstreams/ifstream.members/test.dat
new file mode 100644
index 000000000000..1d2f01491f78
--- /dev/null
+++ b/test/std/input.output/file.streams/fstreams/ifstream.members/test.dat
@@ -0,0 +1 @@
+r \ No newline at end of file
diff --git a/test/std/input.output/file.streams/fstreams/ifstream/types.pass.cpp b/test/std/input.output/file.streams/fstreams/ifstream/types.pass.cpp
new file mode 100644
index 000000000000..dd39eee1a174
--- /dev/null
+++ b/test/std/input.output/file.streams/fstreams/ifstream/types.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ifstream
+// : public basic_istream<charT,traits>
+// {
+// public:
+// typedef charT char_type;
+// typedef traits traits_type;
+// typedef typename traits_type::int_type int_type;
+// typedef typename traits_type::pos_type pos_type;
+// typedef typename traits_type::off_type off_type;
+
+#include <fstream>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_base_of<std::basic_istream<char>, std::basic_ifstream<char> >::value), "");
+ static_assert((std::is_same<std::basic_ifstream<char>::char_type, char>::value), "");
+ static_assert((std::is_same<std::basic_ifstream<char>::traits_type, std::char_traits<char> >::value), "");
+ static_assert((std::is_same<std::basic_ifstream<char>::int_type, std::char_traits<char>::int_type>::value), "");
+ static_assert((std::is_same<std::basic_ifstream<char>::pos_type, std::char_traits<char>::pos_type>::value), "");
+ static_assert((std::is_same<std::basic_ifstream<char>::off_type, std::char_traits<char>::off_type>::value), "");
+}
diff --git a/test/std/input.output/file.streams/fstreams/lit.local.cfg b/test/std/input.output/file.streams/fstreams/lit.local.cfg
new file mode 100644
index 000000000000..25ac02ba7c66
--- /dev/null
+++ b/test/std/input.output/file.streams/fstreams/lit.local.cfg
@@ -0,0 +1,2 @@
+if 'libcpp-has-no-global-filesystem-namespace' in config.available_features:
+ config.unsupported = True
diff --git a/test/std/input.output/file.streams/fstreams/ofstream.assign/member_swap.pass.cpp b/test/std/input.output/file.streams/fstreams/ofstream.assign/member_swap.pass.cpp
new file mode 100644
index 000000000000..519b84fb1abe
--- /dev/null
+++ b/test/std/input.output/file.streams/fstreams/ofstream.assign/member_swap.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ofstream
+
+// void swap(basic_ofstream& rhs);
+
+#include <fstream>
+#include <cassert>
+#include "platform_support.h"
+
+int main()
+{
+ std::string temp1 = get_temp_file_name();
+ std::string temp2 = get_temp_file_name();
+ {
+ std::ofstream fs1(temp1.c_str());
+ std::ofstream fs2(temp2.c_str());
+ fs1 << 3.25;
+ fs2 << 4.5;
+ fs1.swap(fs2);
+ fs1 << ' ' << 3.25;
+ fs2 << ' ' << 4.5;
+ }
+ {
+ std::ifstream fs(temp1.c_str());
+ double x = 0;
+ fs >> x;
+ assert(x == 3.25);
+ fs >> x;
+ assert(x == 4.5);
+ }
+ std::remove(temp1.c_str());
+ {
+ std::ifstream fs(temp2.c_str());
+ double x = 0;
+ fs >> x;
+ assert(x == 4.5);
+ fs >> x;
+ assert(x == 3.25);
+ }
+ std::remove(temp2.c_str());
+ {
+ std::wofstream fs1(temp1.c_str());
+ std::wofstream fs2(temp2.c_str());
+ fs1 << 3.25;
+ fs2 << 4.5;
+ fs1.swap(fs2);
+ fs1 << ' ' << 3.25;
+ fs2 << ' ' << 4.5;
+ }
+ {
+ std::wifstream fs(temp1.c_str());
+ double x = 0;
+ fs >> x;
+ assert(x == 3.25);
+ fs >> x;
+ assert(x == 4.5);
+ }
+ std::remove(temp1.c_str());
+ {
+ std::wifstream fs(temp2.c_str());
+ double x = 0;
+ fs >> x;
+ assert(x == 4.5);
+ fs >> x;
+ assert(x == 3.25);
+ }
+ std::remove(temp2.c_str());
+}
diff --git a/test/std/input.output/file.streams/fstreams/ofstream.assign/move_assign.pass.cpp b/test/std/input.output/file.streams/fstreams/ofstream.assign/move_assign.pass.cpp
new file mode 100644
index 000000000000..0f21eb81d078
--- /dev/null
+++ b/test/std/input.output/file.streams/fstreams/ofstream.assign/move_assign.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ofstream
+
+// basic_ofstream& operator=(basic_ofstream&& rhs);
+
+#include <fstream>
+#include <cassert>
+#include "platform_support.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ std::string temp = get_temp_file_name();
+ {
+ std::ofstream fso(temp.c_str());
+ std::ofstream fs;
+ fs = move(fso);
+ fs << 3.25;
+ }
+ {
+ std::ifstream fs(temp.c_str());
+ double x = 0;
+ fs >> x;
+ assert(x == 3.25);
+ }
+ std::remove(temp.c_str());
+ {
+ std::wofstream fso(temp.c_str());
+ std::wofstream fs;
+ fs = move(fso);
+ fs << 3.25;
+ }
+ {
+ std::wifstream fs(temp.c_str());
+ double x = 0;
+ fs >> x;
+ assert(x == 3.25);
+ }
+ std::remove(temp.c_str());
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/input.output/file.streams/fstreams/ofstream.assign/nonmember_swap.pass.cpp b/test/std/input.output/file.streams/fstreams/ofstream.assign/nonmember_swap.pass.cpp
new file mode 100644
index 000000000000..d58f5f256004
--- /dev/null
+++ b/test/std/input.output/file.streams/fstreams/ofstream.assign/nonmember_swap.pass.cpp
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ofstream
+
+// template <class charT, class traits>
+// void swap(basic_ofstream<charT, traits>& x, basic_ofstream<charT, traits>& y);
+
+#include <fstream>
+#include <cassert>
+#include "platform_support.h"
+
+int main()
+{
+ std::string temp1 = get_temp_file_name();
+ std::string temp2 = get_temp_file_name();
+ {
+ std::ofstream fs1(temp1.c_str());
+ std::ofstream fs2(temp2.c_str());
+ fs1 << 3.25;
+ fs2 << 4.5;
+ swap(fs1, fs2);
+ fs1 << ' ' << 3.25;
+ fs2 << ' ' << 4.5;
+ }
+ {
+ std::ifstream fs(temp1.c_str());
+ double x = 0;
+ fs >> x;
+ assert(x == 3.25);
+ fs >> x;
+ assert(x == 4.5);
+ }
+ std::remove(temp1.c_str());
+ {
+ std::ifstream fs(temp2.c_str());
+ double x = 0;
+ fs >> x;
+ assert(x == 4.5);
+ fs >> x;
+ assert(x == 3.25);
+ }
+ std::remove(temp2.c_str());
+ {
+ std::wofstream fs1(temp1.c_str());
+ std::wofstream fs2(temp2.c_str());
+ fs1 << 3.25;
+ fs2 << 4.5;
+ swap(fs1, fs2);
+ fs1 << ' ' << 3.25;
+ fs2 << ' ' << 4.5;
+ }
+ {
+ std::wifstream fs(temp1.c_str());
+ double x = 0;
+ fs >> x;
+ assert(x == 3.25);
+ fs >> x;
+ assert(x == 4.5);
+ }
+ std::remove(temp1.c_str());
+ {
+ std::wifstream fs(temp2.c_str());
+ double x = 0;
+ fs >> x;
+ assert(x == 4.5);
+ fs >> x;
+ assert(x == 3.25);
+ }
+ std::remove(temp2.c_str());
+}
diff --git a/test/std/input.output/file.streams/fstreams/ofstream.cons/default.pass.cpp b/test/std/input.output/file.streams/fstreams/ofstream.cons/default.pass.cpp
new file mode 100644
index 000000000000..f8308ab06bfb
--- /dev/null
+++ b/test/std/input.output/file.streams/fstreams/ofstream.cons/default.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ofstream
+
+// basic_ofstream();
+
+#include <fstream>
+#include <type_traits>
+
+int main()
+{
+ {
+ std::ofstream fs;
+ }
+ {
+ std::wofstream fs;
+ }
+}
diff --git a/test/std/input.output/file.streams/fstreams/ofstream.cons/move.pass.cpp b/test/std/input.output/file.streams/fstreams/ofstream.cons/move.pass.cpp
new file mode 100644
index 000000000000..8645358cbd4d
--- /dev/null
+++ b/test/std/input.output/file.streams/fstreams/ofstream.cons/move.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ofstream
+
+// basic_ofstream(basic_ofstream&& rhs);
+
+#include <fstream>
+#include <cassert>
+#include "platform_support.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ std::string temp = get_temp_file_name();
+ {
+ std::ofstream fso(temp.c_str());
+ std::ofstream fs = move(fso);
+ fs << 3.25;
+ }
+ {
+ std::ifstream fs(temp.c_str());
+ double x = 0;
+ fs >> x;
+ assert(x == 3.25);
+ }
+ std::remove(temp.c_str());
+ {
+ std::wofstream fso(temp.c_str());
+ std::wofstream fs = move(fso);
+ fs << 3.25;
+ }
+ {
+ std::wifstream fs(temp.c_str());
+ double x = 0;
+ fs >> x;
+ assert(x == 3.25);
+ }
+ std::remove(temp.c_str());
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/input.output/file.streams/fstreams/ofstream.cons/pointer.pass.cpp b/test/std/input.output/file.streams/fstreams/ofstream.cons/pointer.pass.cpp
new file mode 100644
index 000000000000..bd5832abeb59
--- /dev/null
+++ b/test/std/input.output/file.streams/fstreams/ofstream.cons/pointer.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ofstream
+
+// explicit basic_ofstream(const char* s, ios_base::openmode mode = ios_base::out);
+
+#include <fstream>
+#include <cassert>
+#include "platform_support.h"
+
+int main()
+{
+ std::string temp = get_temp_file_name();
+ {
+ std::ofstream fs(temp.c_str());
+ fs << 3.25;
+ }
+ {
+ std::ifstream fs(temp.c_str());
+ double x = 0;
+ fs >> x;
+ assert(x == 3.25);
+ }
+ std::remove(temp.c_str());
+ {
+ std::wofstream fs(temp.c_str());
+ fs << 3.25;
+ }
+ {
+ std::wifstream fs(temp.c_str());
+ double x = 0;
+ fs >> x;
+ assert(x == 3.25);
+ }
+ std::remove(temp.c_str());
+}
diff --git a/test/std/input.output/file.streams/fstreams/ofstream.cons/string.pass.cpp b/test/std/input.output/file.streams/fstreams/ofstream.cons/string.pass.cpp
new file mode 100644
index 000000000000..7112b17fb8be
--- /dev/null
+++ b/test/std/input.output/file.streams/fstreams/ofstream.cons/string.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ofstream
+
+// explicit basic_ofstream(const string& s, ios_base::openmode mode = ios_base::out);
+
+#include <fstream>
+#include <cassert>
+#include "platform_support.h"
+
+int main()
+{
+ std::string temp = get_temp_file_name();
+ {
+ std::ofstream fs(temp);
+ fs << 3.25;
+ }
+ {
+ std::ifstream fs(temp);
+ double x = 0;
+ fs >> x;
+ assert(x == 3.25);
+ }
+ std::remove(temp.c_str());
+ {
+ std::wofstream fs(temp);
+ fs << 3.25;
+ }
+ {
+ std::wifstream fs(temp);
+ double x = 0;
+ fs >> x;
+ assert(x == 3.25);
+ }
+ std::remove(temp.c_str());
+}
diff --git a/test/std/input.output/file.streams/fstreams/ofstream.members/close.pass.cpp b/test/std/input.output/file.streams/fstreams/ofstream.members/close.pass.cpp
new file mode 100644
index 000000000000..b8c358d8ece4
--- /dev/null
+++ b/test/std/input.output/file.streams/fstreams/ofstream.members/close.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ofstream
+
+// void close();
+
+#include <fstream>
+#include <cassert>
+#include "platform_support.h"
+
+int main()
+{
+ std::string temp = get_temp_file_name();
+ {
+ std::ofstream fs;
+ assert(!fs.is_open());
+ fs.open(temp.c_str());
+ assert(fs.is_open());
+ fs.close();
+ assert(!fs.is_open());
+ }
+ std::remove(temp.c_str());
+ {
+ std::wofstream fs;
+ assert(!fs.is_open());
+ fs.open(temp.c_str());
+ assert(fs.is_open());
+ fs.close();
+ assert(!fs.is_open());
+ }
+ std::remove(temp.c_str());
+}
diff --git a/test/std/input.output/file.streams/fstreams/ofstream.members/open_pointer.pass.cpp b/test/std/input.output/file.streams/fstreams/ofstream.members/open_pointer.pass.cpp
new file mode 100644
index 000000000000..e5cddc9e1642
--- /dev/null
+++ b/test/std/input.output/file.streams/fstreams/ofstream.members/open_pointer.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ofstream
+
+// void open(const char* s, ios_base::openmode mode = ios_base::out);
+
+#include <fstream>
+#include <cassert>
+#include "platform_support.h"
+
+int main()
+{
+ std::string temp = get_temp_file_name();
+ {
+ std::ofstream fs;
+ assert(!fs.is_open());
+ char c = 'a';
+ fs << c;
+ assert(fs.fail());
+ fs.open(temp.c_str());
+ assert(fs.is_open());
+ fs << c;
+ }
+ {
+ std::ifstream fs(temp.c_str());
+ char c = 0;
+ fs >> c;
+ assert(c == 'a');
+ }
+ std::remove(temp.c_str());
+ {
+ std::wofstream fs;
+ assert(!fs.is_open());
+ wchar_t c = L'a';
+ fs << c;
+ assert(fs.fail());
+ fs.open(temp.c_str());
+ assert(fs.is_open());
+ fs << c;
+ }
+ {
+ std::wifstream fs(temp.c_str());
+ wchar_t c = 0;
+ fs >> c;
+ assert(c == L'a');
+ }
+ std::remove(temp.c_str());
+}
diff --git a/test/std/input.output/file.streams/fstreams/ofstream.members/open_string.pass.cpp b/test/std/input.output/file.streams/fstreams/ofstream.members/open_string.pass.cpp
new file mode 100644
index 000000000000..d54aa1824ab9
--- /dev/null
+++ b/test/std/input.output/file.streams/fstreams/ofstream.members/open_string.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ofstream
+
+// void open(const string& s, ios_base::openmode mode = ios_base::out);
+
+#include <fstream>
+#include <cassert>
+#include "platform_support.h"
+
+int main()
+{
+ std::string temp = get_temp_file_name();
+ {
+ std::ofstream fs;
+ assert(!fs.is_open());
+ char c = 'a';
+ fs << c;
+ assert(fs.fail());
+ fs.open(temp);
+ assert(fs.is_open());
+ fs << c;
+ }
+ {
+ std::ifstream fs(temp.c_str());
+ char c = 0;
+ fs >> c;
+ assert(c == 'a');
+ }
+ std::remove(temp.c_str());
+ {
+ std::wofstream fs;
+ assert(!fs.is_open());
+ wchar_t c = L'a';
+ fs << c;
+ assert(fs.fail());
+ fs.open(temp);
+ assert(fs.is_open());
+ fs << c;
+ }
+ {
+ std::wifstream fs(temp.c_str());
+ wchar_t c = 0;
+ fs >> c;
+ assert(c == L'a');
+ }
+ std::remove(temp.c_str());
+}
diff --git a/test/std/input.output/file.streams/fstreams/ofstream.members/rdbuf.pass.cpp b/test/std/input.output/file.streams/fstreams/ofstream.members/rdbuf.pass.cpp
new file mode 100644
index 000000000000..d707e0a32ac4
--- /dev/null
+++ b/test/std/input.output/file.streams/fstreams/ofstream.members/rdbuf.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ofstream
+
+// basic_filebuf<charT,traits>* rdbuf() const;
+
+#include <fstream>
+#include <cassert>
+#include "platform_support.h"
+
+int main()
+{
+ std::string temp = get_temp_file_name();
+ {
+ std::ofstream fs(temp.c_str());
+ std::filebuf* fb = fs.rdbuf();
+ assert(fb->sputc('r') == 'r');
+ }
+ std::remove(temp.c_str());
+ {
+ std::wofstream fs(temp.c_str());
+ std::wfilebuf* fb = fs.rdbuf();
+ assert(fb->sputc(L'r') == L'r');
+ }
+ std::remove(temp.c_str());
+}
diff --git a/test/std/input.output/file.streams/fstreams/ofstream/types.pass.cpp b/test/std/input.output/file.streams/fstreams/ofstream/types.pass.cpp
new file mode 100644
index 000000000000..243994addcc4
--- /dev/null
+++ b/test/std/input.output/file.streams/fstreams/ofstream/types.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ofstream
+// : public basic_ostream<charT,traits>
+// {
+// public:
+// typedef charT char_type;
+// typedef traits traits_type;
+// typedef typename traits_type::int_type int_type;
+// typedef typename traits_type::pos_type pos_type;
+// typedef typename traits_type::off_type off_type;
+
+#include <fstream>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_base_of<std::basic_ostream<char>, std::basic_ofstream<char> >::value), "");
+ static_assert((std::is_same<std::basic_ofstream<char>::char_type, char>::value), "");
+ static_assert((std::is_same<std::basic_ofstream<char>::traits_type, std::char_traits<char> >::value), "");
+ static_assert((std::is_same<std::basic_ofstream<char>::int_type, std::char_traits<char>::int_type>::value), "");
+ static_assert((std::is_same<std::basic_ofstream<char>::pos_type, std::char_traits<char>::pos_type>::value), "");
+ static_assert((std::is_same<std::basic_ofstream<char>::off_type, std::char_traits<char>::off_type>::value), "");
+}
diff --git a/test/std/input.output/file.streams/fstreams/version.pass.cpp b/test/std/input.output/file.streams/fstreams/version.pass.cpp
new file mode 100644
index 000000000000..44b851416808
--- /dev/null
+++ b/test/std/input.output/file.streams/fstreams/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+#include <fstream>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/input.output/file.streams/nothing_to_do.pass.cpp b/test/std/input.output/file.streams/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/input.output/file.streams/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/input.output/input.output.general/nothing_to_do.pass.cpp b/test/std/input.output/input.output.general/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/input.output/input.output.general/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/input.output/iostream.format/ext.manip/get_money.pass.cpp b/test/std/input.output/iostream.format/ext.manip/get_money.pass.cpp
new file mode 100644
index 000000000000..1ea1d780c50f
--- /dev/null
+++ b/test/std/input.output/iostream.format/ext.manip/get_money.pass.cpp
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iomanip>
+
+// template <class moneyT> T7 get_money(moneyT& mon, bool intl = false);
+
+// REQUIRES: locale.en_US.UTF-8
+
+#include <iomanip>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+template <class CharT>
+struct testbuf
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_string<CharT> string_type;
+ typedef std::basic_streambuf<CharT> base;
+private:
+ string_type str_;
+public:
+
+ testbuf() {}
+ testbuf(const string_type& str)
+ : str_(str)
+ {
+ base::setg(const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data()) + str_.size());
+ }
+};
+
+int main()
+{
+ {
+ testbuf<char> sb(" -$1,234,567.89");
+ std::istream is(&sb);
+ is.imbue(std::locale(LOCALE_en_US_UTF_8));
+ long double x = 0;
+ is >> std::get_money(x, false);
+ assert(x == -123456789);
+ }
+ {
+ testbuf<char> sb(" -USD 1,234,567.89");
+ std::istream is(&sb);
+ is.imbue(std::locale(LOCALE_en_US_UTF_8));
+ long double x = 0;
+ is >> std::get_money(x, true);
+ assert(x == -123456789);
+ }
+ {
+ testbuf<wchar_t> sb(L" -$1,234,567.89");
+ std::wistream is(&sb);
+ is.imbue(std::locale(LOCALE_en_US_UTF_8));
+ long double x = 0;
+ is >> std::get_money(x, false);
+ assert(x == -123456789);
+ }
+ {
+ testbuf<wchar_t> sb(L" -USD 1,234,567.89");
+ std::wistream is(&sb);
+ is.imbue(std::locale(LOCALE_en_US_UTF_8));
+ long double x = 0;
+ is >> std::get_money(x, true);
+ assert(x == -123456789);
+ }
+}
diff --git a/test/std/input.output/iostream.format/ext.manip/get_time.pass.cpp b/test/std/input.output/iostream.format/ext.manip/get_time.pass.cpp
new file mode 100644
index 000000000000..17ff642dc46d
--- /dev/null
+++ b/test/std/input.output/iostream.format/ext.manip/get_time.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iomanip>
+
+// template <class charT> T9 get_time(struct tm* tmb, const charT* fmt);
+
+#include <iomanip>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+template <class CharT>
+struct testbuf
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_string<CharT> string_type;
+ typedef std::basic_streambuf<CharT> base;
+private:
+ string_type str_;
+public:
+
+ testbuf() {}
+ testbuf(const string_type& str)
+ : str_(str)
+ {
+ base::setg(const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data()) + str_.size());
+ }
+};
+
+int main()
+{
+ {
+ testbuf<char> sb(" Sat Dec 31 23:55:59 2061");
+ std::istream is(&sb);
+ is.imbue(std::locale(LOCALE_en_US_UTF_8));
+ std::tm t = {0};
+ is >> std::get_time(&t, "%a %b %d %H:%M:%S %Y");
+ assert(t.tm_sec == 59);
+ assert(t.tm_min == 55);
+ assert(t.tm_hour == 23);
+ assert(t.tm_mday == 31);
+ assert(t.tm_mon == 11);
+ assert(t.tm_year == 161);
+ assert(t.tm_wday == 6);
+ assert(is.eof());
+ assert(!is.fail());
+ }
+ {
+ testbuf<wchar_t> sb(L" Sat Dec 31 23:55:59 2061");
+ std::wistream is(&sb);
+ is.imbue(std::locale(LOCALE_en_US_UTF_8));
+ std::tm t = {0};
+ is >> std::get_time(&t, L"%a %b %d %H:%M:%S %Y");
+ assert(t.tm_sec == 59);
+ assert(t.tm_min == 55);
+ assert(t.tm_hour == 23);
+ assert(t.tm_mday == 31);
+ assert(t.tm_mon == 11);
+ assert(t.tm_year == 161);
+ assert(t.tm_wday == 6);
+ assert(is.eof());
+ assert(!is.fail());
+ }
+}
diff --git a/test/std/input.output/iostream.format/ext.manip/put_money.pass.cpp b/test/std/input.output/iostream.format/ext.manip/put_money.pass.cpp
new file mode 100644
index 000000000000..a00cf139be93
--- /dev/null
+++ b/test/std/input.output/iostream.format/ext.manip/put_money.pass.cpp
@@ -0,0 +1,91 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iomanip>
+
+// template <class charT, class moneyT> T8 put_money(const moneyT& mon, bool intl = false);
+
+// REQUIRES: locale.en_US.UTF-8
+
+#include <iomanip>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+template <class CharT>
+class testbuf
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_streambuf<CharT> base;
+ std::basic_string<CharT> str_;
+public:
+ testbuf()
+ {
+ }
+
+ std::basic_string<CharT> str() const
+ {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+ virtual typename base::int_type
+ overflow(typename base::int_type __c = base::traits_type::eof())
+ {
+ if (__c != base::traits_type::eof())
+ {
+ int n = str_.size();
+ str_.push_back(__c);
+ str_.resize(str_.capacity());
+ base::setp(const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data() + str_.size()));
+ base::pbump(n+1);
+ }
+ return __c;
+ }
+};
+
+int main()
+{
+ {
+ testbuf<char> sb;
+ std::ostream os(&sb);
+ os.imbue(std::locale(LOCALE_en_US_UTF_8));
+ showbase(os);
+ long double x = -123456789;
+ os << std::put_money(x, false);
+ assert(sb.str() == "-$1,234,567.89");
+ }
+ {
+ testbuf<char> sb;
+ std::ostream os(&sb);
+ os.imbue(std::locale(LOCALE_en_US_UTF_8));
+ showbase(os);
+ long double x = -123456789;
+ os << std::put_money(x, true);
+ assert(sb.str() == "-USD 1,234,567.89");
+ }
+ {
+ testbuf<wchar_t> sb;
+ std::wostream os(&sb);
+ os.imbue(std::locale(LOCALE_en_US_UTF_8));
+ showbase(os);
+ long double x = -123456789;
+ os << std::put_money(x, false);
+ assert(sb.str() == L"-$1,234,567.89");
+ }
+ {
+ testbuf<wchar_t> sb;
+ std::wostream os(&sb);
+ os.imbue(std::locale(LOCALE_en_US_UTF_8));
+ showbase(os);
+ long double x = -123456789;
+ os << std::put_money(x, true);
+ assert(sb.str() == L"-USD 1,234,567.89");
+ }
+}
diff --git a/test/std/input.output/iostream.format/ext.manip/put_time.pass.cpp b/test/std/input.output/iostream.format/ext.manip/put_time.pass.cpp
new file mode 100644
index 000000000000..52a98a1b5688
--- /dev/null
+++ b/test/std/input.output/iostream.format/ext.manip/put_time.pass.cpp
@@ -0,0 +1,84 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iomanip>
+
+// template <class charT> T10 put_time(const struct tm* tmb, const charT* fmt);
+
+#include <iomanip>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+template <class CharT>
+class testbuf
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_streambuf<CharT> base;
+ std::basic_string<CharT> str_;
+public:
+ testbuf()
+ {
+ }
+
+ std::basic_string<CharT> str() const
+ {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+ virtual typename base::int_type
+ overflow(typename base::int_type __c = base::traits_type::eof())
+ {
+ if (__c != base::traits_type::eof())
+ {
+ int n = str_.size();
+ str_.push_back(__c);
+ str_.resize(str_.capacity());
+ base::setp(const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data() + str_.size()));
+ base::pbump(n+1);
+ }
+ return __c;
+ }
+};
+
+int main()
+{
+ {
+ testbuf<char> sb;
+ std::ostream os(&sb);
+ os.imbue(std::locale(LOCALE_en_US_UTF_8));
+ std::tm t = {0};
+ t.tm_sec = 59;
+ t.tm_min = 55;
+ t.tm_hour = 23;
+ t.tm_mday = 31;
+ t.tm_mon = 11;
+ t.tm_year = 161;
+ t.tm_wday = 6;
+ t.tm_isdst = 0;
+ os << std::put_time(&t, "%a %b %d %H:%M:%S %Y");
+ assert(sb.str() == "Sat Dec 31 23:55:59 2061");
+ }
+ {
+ testbuf<wchar_t> sb;
+ std::wostream os(&sb);
+ os.imbue(std::locale(LOCALE_en_US_UTF_8));
+ std::tm t = {0};
+ t.tm_sec = 59;
+ t.tm_min = 55;
+ t.tm_hour = 23;
+ t.tm_mday = 31;
+ t.tm_mon = 11;
+ t.tm_year = 161;
+ t.tm_wday = 6;
+ os << std::put_time(&t, L"%a %b %d %H:%M:%S %Y");
+ assert(sb.str() == L"Sat Dec 31 23:55:59 2061");
+ }
+}
diff --git a/test/std/input.output/iostream.format/input.streams/iostreamclass/iostream.assign/member_swap.pass.cpp b/test/std/input.output/iostream.format/input.streams/iostreamclass/iostream.assign/member_swap.pass.cpp
new file mode 100644
index 000000000000..f4d425728b77
--- /dev/null
+++ b/test/std/input.output/iostream.format/input.streams/iostreamclass/iostream.assign/member_swap.pass.cpp
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_iostream;
+
+// void swap(basic_iostream& rhs);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+ : public std::basic_streambuf<CharT>
+{
+ testbuf() {}
+};
+
+template <class CharT>
+struct test_iostream
+ : public std::basic_iostream<CharT>
+{
+ typedef std::basic_iostream<CharT> base;
+ test_iostream(testbuf<CharT>* sb) : base(sb) {}
+
+ void swap(test_iostream& s) {base::swap(s);}
+};
+
+int main()
+{
+ {
+ testbuf<char> sb1;
+ testbuf<char> sb2;
+ test_iostream<char> is1(&sb1);
+ test_iostream<char> is2(&sb2);
+ is1.swap(is2);
+ assert(is1.rdbuf() == &sb1);
+ assert(is1.tie() == 0);
+ assert(is1.fill() == ' ');
+ assert(is1.rdstate() == is1.goodbit);
+ assert(is1.exceptions() == is1.goodbit);
+ assert(is1.flags() == (is1.skipws | is1.dec));
+ assert(is1.precision() == 6);
+ assert(is1.getloc().name() == "C");
+ assert(is2.rdbuf() == &sb2);
+ assert(is2.tie() == 0);
+ assert(is2.fill() == ' ');
+ assert(is2.rdstate() == is2.goodbit);
+ assert(is2.exceptions() == is2.goodbit);
+ assert(is2.flags() == (is2.skipws | is2.dec));
+ assert(is2.precision() == 6);
+ assert(is2.getloc().name() == "C");
+ }
+ {
+ testbuf<wchar_t> sb1;
+ testbuf<wchar_t> sb2;
+ test_iostream<wchar_t> is1(&sb1);
+ test_iostream<wchar_t> is2(&sb2);
+ is1.swap(is2);
+ assert(is1.rdbuf() == &sb1);
+ assert(is1.tie() == 0);
+ assert(is1.fill() == ' ');
+ assert(is1.rdstate() == is1.goodbit);
+ assert(is1.exceptions() == is1.goodbit);
+ assert(is1.flags() == (is1.skipws | is1.dec));
+ assert(is1.precision() == 6);
+ assert(is1.getloc().name() == "C");
+ assert(is2.rdbuf() == &sb2);
+ assert(is2.tie() == 0);
+ assert(is2.fill() == ' ');
+ assert(is2.rdstate() == is2.goodbit);
+ assert(is2.exceptions() == is2.goodbit);
+ assert(is2.flags() == (is2.skipws | is2.dec));
+ assert(is2.precision() == 6);
+ assert(is2.getloc().name() == "C");
+ }
+}
diff --git a/test/std/input.output/iostream.format/input.streams/iostreamclass/iostream.assign/move_assign.pass.cpp b/test/std/input.output/iostream.format/input.streams/iostreamclass/iostream.assign/move_assign.pass.cpp
new file mode 100644
index 000000000000..2032e935bfac
--- /dev/null
+++ b/test/std/input.output/iostream.format/input.streams/iostreamclass/iostream.assign/move_assign.pass.cpp
@@ -0,0 +1,92 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_iostream;
+
+// basic_iostream& operator=(basic_iostream&& rhs);
+
+#include <istream>
+#include <cassert>
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class CharT>
+struct testbuf
+ : public std::basic_streambuf<CharT>
+{
+ testbuf() {}
+};
+
+template <class CharT>
+struct test_iostream
+ : public std::basic_iostream<CharT>
+{
+ typedef std::basic_iostream<CharT> base;
+ test_iostream(testbuf<CharT>* sb) : base(sb) {}
+
+ test_iostream& operator=(test_iostream&& s)
+ {base::operator=(std::move(s)); return *this;}
+};
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ testbuf<char> sb1;
+ testbuf<char> sb2;
+ test_iostream<char> is1(&sb1);
+ test_iostream<char> is2(&sb2);
+ is2 = (std::move(is1));
+ assert(is1.rdbuf() == &sb1);
+ assert(is1.tie() == 0);
+ assert(is1.fill() == ' ');
+ assert(is1.rdstate() == is1.goodbit);
+ assert(is1.exceptions() == is1.goodbit);
+ assert(is1.flags() == (is1.skipws | is1.dec));
+ assert(is1.precision() == 6);
+ assert(is1.getloc().name() == "C");
+ assert(is2.rdbuf() == &sb2);
+ assert(is2.tie() == 0);
+ assert(is2.fill() == ' ');
+ assert(is2.rdstate() == is2.goodbit);
+ assert(is2.exceptions() == is2.goodbit);
+ assert(is2.flags() == (is2.skipws | is2.dec));
+ assert(is2.precision() == 6);
+ assert(is2.getloc().name() == "C");
+ }
+ {
+ testbuf<wchar_t> sb1;
+ testbuf<wchar_t> sb2;
+ test_iostream<wchar_t> is1(&sb1);
+ test_iostream<wchar_t> is2(&sb2);
+ is2 = (std::move(is1));
+ assert(is1.rdbuf() == &sb1);
+ assert(is1.tie() == 0);
+ assert(is1.fill() == ' ');
+ assert(is1.rdstate() == is1.goodbit);
+ assert(is1.exceptions() == is1.goodbit);
+ assert(is1.flags() == (is1.skipws | is1.dec));
+ assert(is1.precision() == 6);
+ assert(is1.getloc().name() == "C");
+ assert(is2.rdbuf() == &sb2);
+ assert(is2.tie() == 0);
+ assert(is2.fill() == ' ');
+ assert(is2.rdstate() == is2.goodbit);
+ assert(is2.exceptions() == is2.goodbit);
+ assert(is2.flags() == (is2.skipws | is2.dec));
+ assert(is2.precision() == 6);
+ assert(is2.getloc().name() == "C");
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/input.output/iostream.format/input.streams/iostreamclass/iostream.cons/move.pass.cpp b/test/std/input.output/iostream.format/input.streams/iostreamclass/iostream.cons/move.pass.cpp
new file mode 100644
index 000000000000..c0592e927c8f
--- /dev/null
+++ b/test/std/input.output/iostream.format/input.streams/iostreamclass/iostream.cons/move.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_iostream;
+
+// basic_iostream(basic_iostream&& rhs);
+
+#include <istream>
+#include <cassert>
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class CharT>
+struct testbuf
+ : public std::basic_streambuf<CharT>
+{
+ testbuf() {}
+};
+
+template <class CharT>
+struct test_iostream
+ : public std::basic_iostream<CharT>
+{
+ typedef std::basic_iostream<CharT> base;
+ test_iostream(testbuf<CharT>* sb) : base(sb) {}
+
+ test_iostream(test_iostream&& s)
+ : base(std::move(s)) {}
+};
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ testbuf<char> sb;
+ test_iostream<char> is1(&sb);
+ test_iostream<char> is(std::move(is1));
+ assert(is1.rdbuf() == &sb);
+ assert(is1.gcount() == 0);
+ assert(is.gcount() == 0);
+ assert(is.rdbuf() == 0);
+ assert(is.tie() == 0);
+ assert(is.fill() == ' ');
+ assert(is.rdstate() == is.goodbit);
+ assert(is.exceptions() == is.goodbit);
+ assert(is.flags() == (is.skipws | is.dec));
+ assert(is.precision() == 6);
+ assert(is.getloc().name() == "C");
+ }
+ {
+ testbuf<wchar_t> sb;
+ test_iostream<wchar_t> is1(&sb);
+ test_iostream<wchar_t> is(std::move(is1));
+ assert(is1.gcount() == 0);
+ assert(is.gcount() == 0);
+ assert(is1.rdbuf() == &sb);
+ assert(is.rdbuf() == 0);
+ assert(is.tie() == 0);
+ assert(is.fill() == L' ');
+ assert(is.rdstate() == is.goodbit);
+ assert(is.exceptions() == is.goodbit);
+ assert(is.flags() == (is.skipws | is.dec));
+ assert(is.precision() == 6);
+ assert(is.getloc().name() == "C");
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/input.output/iostream.format/input.streams/iostreamclass/iostream.cons/streambuf.pass.cpp b/test/std/input.output/iostream.format/input.streams/iostreamclass/iostream.cons/streambuf.pass.cpp
new file mode 100644
index 000000000000..dacc8d26d76e
--- /dev/null
+++ b/test/std/input.output/iostream.format/input.streams/iostreamclass/iostream.cons/streambuf.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_iostream;
+
+// explicit basic_iostream(basic_streambuf<charT,traits>* sb);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+ : public std::basic_streambuf<CharT>
+{
+ testbuf() {}
+};
+
+int main()
+{
+ {
+ testbuf<char> sb;
+ std::basic_iostream<char> is(&sb);
+ assert(is.rdbuf() == &sb);
+ assert(is.tie() == 0);
+ assert(is.fill() == ' ');
+ assert(is.rdstate() == is.goodbit);
+ assert(is.exceptions() == is.goodbit);
+ assert(is.flags() == (is.skipws | is.dec));
+ assert(is.precision() == 6);
+ assert(is.getloc().name() == "C");
+ assert(is.gcount() == 0);
+ }
+ {
+ testbuf<wchar_t> sb;
+ std::basic_iostream<wchar_t> is(&sb);
+ assert(is.rdbuf() == &sb);
+ assert(is.tie() == 0);
+ assert(is.fill() == L' ');
+ assert(is.rdstate() == is.goodbit);
+ assert(is.exceptions() == is.goodbit);
+ assert(is.flags() == (is.skipws | is.dec));
+ assert(is.precision() == 6);
+ assert(is.getloc().name() == "C");
+ assert(is.gcount() == 0);
+ }
+}
diff --git a/test/std/input.output/iostream.format/input.streams/iostreamclass/iostream.dest/nothing_to_do.pass.cpp b/test/std/input.output/iostream.format/input.streams/iostreamclass/iostream.dest/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/input.output/iostream.format/input.streams/iostreamclass/iostream.dest/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/input.output/iostream.format/input.streams/iostreamclass/types.pass.cpp b/test/std/input.output/iostream.format/input.streams/iostreamclass/types.pass.cpp
new file mode 100644
index 000000000000..6890f1cf7c17
--- /dev/null
+++ b/test/std/input.output/iostream.format/input.streams/iostreamclass/types.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_iostream :
+// public basic_istream<charT,traits>,
+// public basic_ostream<charT,traits>
+// {
+// public:
+// // types:
+// typedef charT char_type;
+// typedef traits traits_type;
+// typedef typename traits_type::int_type int_type;
+// typedef typename traits_type::pos_type pos_type;
+// typedef typename traits_type::off_type off_type;
+
+#include <istream>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_base_of<std::basic_istream<char>, std::basic_iostream<char> >::value), "");
+ static_assert((std::is_base_of<std::basic_ostream<char>, std::basic_iostream<char> >::value), "");
+ static_assert((std::is_same<std::basic_iostream<char>::char_type, char>::value), "");
+ static_assert((std::is_same<std::basic_iostream<char>::traits_type, std::char_traits<char> >::value), "");
+ static_assert((std::is_same<std::basic_iostream<char>::int_type, std::char_traits<char>::int_type>::value), "");
+ static_assert((std::is_same<std::basic_iostream<char>::pos_type, std::char_traits<char>::pos_type>::value), "");
+ static_assert((std::is_same<std::basic_iostream<char>::off_type, std::char_traits<char>::off_type>::value), "");
+}
diff --git a/test/std/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/bool.pass.cpp b/test/std/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/bool.pass.cpp
new file mode 100644
index 000000000000..beaebfe8566d
--- /dev/null
+++ b/test/std/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/bool.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_istream;
+
+// operator>>(bool& val);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_string<CharT> string_type;
+ typedef std::basic_streambuf<CharT> base;
+private:
+ string_type str_;
+public:
+
+ testbuf() {}
+ testbuf(const string_type& str)
+ : str_(str)
+ {
+ base::setg(const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data()) + str_.size());
+ }
+
+ CharT* eback() const {return base::eback();}
+ CharT* gptr() const {return base::gptr();}
+ CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+ {
+ std::istream is((std::streambuf*)0);
+ bool n = 0;
+ is >> n;
+ assert(is.fail());
+ }
+ {
+ testbuf<char> sb("0");
+ std::istream is(&sb);
+ bool n = true;
+ is >> n;
+ assert(n == false);
+ assert( is.eof());
+ assert(!is.fail());
+ }
+ {
+ testbuf<char> sb(" 1 ");
+ std::istream is(&sb);
+ bool n = 0;
+ is >> n;
+ assert(n == true);
+ assert(!is.eof());
+ assert(!is.fail());
+ }
+ {
+ testbuf<wchar_t> sb(L" 1 ");
+ std::wistream is(&sb);
+ bool n = 0;
+ is >> n;
+ assert(n == true);
+ assert(!is.eof());
+ assert(!is.fail());
+ }
+}
diff --git a/test/std/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/double.pass.cpp b/test/std/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/double.pass.cpp
new file mode 100644
index 000000000000..1c8716e86e47
--- /dev/null
+++ b/test/std/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/double.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_istream;
+
+// operator>>(double& val);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_string<CharT> string_type;
+ typedef std::basic_streambuf<CharT> base;
+private:
+ string_type str_;
+public:
+
+ testbuf() {}
+ testbuf(const string_type& str)
+ : str_(str)
+ {
+ base::setg(const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data()) + str_.size());
+ }
+
+ CharT* eback() const {return base::eback();}
+ CharT* gptr() const {return base::gptr();}
+ CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+ {
+ std::istream is((std::streambuf*)0);
+ double n = 0;
+ is >> n;
+ assert(is.fail());
+ }
+ {
+ testbuf<char> sb("0");
+ std::istream is(&sb);
+ double n = 10;
+ is >> n;
+ assert(n == 0);
+ assert( is.eof());
+ assert(!is.fail());
+ }
+ {
+ testbuf<char> sb(" 123 ");
+ std::istream is(&sb);
+ double n = 10;
+ is >> n;
+ assert(n == 123);
+ assert(!is.eof());
+ assert(!is.fail());
+ }
+ {
+ testbuf<wchar_t> sb(L" -123.5 ");
+ std::wistream is(&sb);
+ double n = 10;
+ is >> n;
+ assert(n == -123.5);
+ assert(!is.eof());
+ assert(!is.fail());
+ }
+}
diff --git a/test/std/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/float.pass.cpp b/test/std/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/float.pass.cpp
new file mode 100644
index 000000000000..f5ef23e654a1
--- /dev/null
+++ b/test/std/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/float.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_istream;
+
+// operator>>(float& val);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_string<CharT> string_type;
+ typedef std::basic_streambuf<CharT> base;
+private:
+ string_type str_;
+public:
+
+ testbuf() {}
+ testbuf(const string_type& str)
+ : str_(str)
+ {
+ base::setg(const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data()) + str_.size());
+ }
+
+ CharT* eback() const {return base::eback();}
+ CharT* gptr() const {return base::gptr();}
+ CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+ {
+ std::istream is((std::streambuf*)0);
+ float n = 0;
+ is >> n;
+ assert(is.fail());
+ }
+ {
+ testbuf<char> sb("0");
+ std::istream is(&sb);
+ float n = 10;
+ is >> n;
+ assert(n == 0);
+ assert( is.eof());
+ assert(!is.fail());
+ }
+ {
+ testbuf<char> sb(" 123 ");
+ std::istream is(&sb);
+ float n = 10;
+ is >> n;
+ assert(n == 123);
+ assert(!is.eof());
+ assert(!is.fail());
+ }
+ {
+ testbuf<wchar_t> sb(L" -123.5 ");
+ std::wistream is(&sb);
+ float n = 10;
+ is >> n;
+ assert(n == -123.5);
+ assert(!is.eof());
+ assert(!is.fail());
+ }
+}
diff --git a/test/std/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/int.pass.cpp b/test/std/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/int.pass.cpp
new file mode 100644
index 000000000000..25687db16f37
--- /dev/null
+++ b/test/std/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/int.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_istream;
+
+// operator>>(int& val);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_string<CharT> string_type;
+ typedef std::basic_streambuf<CharT> base;
+private:
+ string_type str_;
+public:
+
+ testbuf() {}
+ testbuf(const string_type& str)
+ : str_(str)
+ {
+ base::setg(const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data()) + str_.size());
+ }
+
+ CharT* eback() const {return base::eback();}
+ CharT* gptr() const {return base::gptr();}
+ CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+ {
+ std::istream is((std::streambuf*)0);
+ int n = 0;
+ is >> n;
+ assert(is.fail());
+ }
+ {
+ testbuf<char> sb("0");
+ std::istream is(&sb);
+ int n = 10;
+ is >> n;
+ assert(n == 0);
+ assert( is.eof());
+ assert(!is.fail());
+ }
+ {
+ testbuf<char> sb(" 123 ");
+ std::istream is(&sb);
+ int n = 10;
+ is >> n;
+ assert(n == 123);
+ assert(!is.eof());
+ assert(!is.fail());
+ }
+ {
+ testbuf<wchar_t> sb(L" -1234567890123456 ");
+ std::wistream is(&sb);
+ int n = 10;
+ is >> n;
+ assert(n == std::numeric_limits<int>::min());
+ assert(!is.eof());
+ assert( is.fail());
+ }
+}
diff --git a/test/std/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/long.pass.cpp b/test/std/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/long.pass.cpp
new file mode 100644
index 000000000000..4b4765452c68
--- /dev/null
+++ b/test/std/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/long.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_istream;
+
+// operator>>(long& val);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_string<CharT> string_type;
+ typedef std::basic_streambuf<CharT> base;
+private:
+ string_type str_;
+public:
+
+ testbuf() {}
+ testbuf(const string_type& str)
+ : str_(str)
+ {
+ base::setg(const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data()) + str_.size());
+ }
+
+ CharT* eback() const {return base::eback();}
+ CharT* gptr() const {return base::gptr();}
+ CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+ {
+ std::istream is((std::streambuf*)0);
+ long n = 0;
+ is >> n;
+ assert(is.fail());
+ }
+ {
+ testbuf<char> sb("0");
+ std::istream is(&sb);
+ long n = 10;
+ is >> n;
+ assert(n == 0);
+ assert( is.eof());
+ assert(!is.fail());
+ }
+ {
+ testbuf<char> sb(" 123 ");
+ std::istream is(&sb);
+ long n = 10;
+ is >> n;
+ assert(n == 123);
+ assert(!is.eof());
+ assert(!is.fail());
+ }
+ {
+ testbuf<wchar_t> sb(L" -123 ");
+ std::wistream is(&sb);
+ long n = 10;
+ is >> n;
+ assert(n == -123);
+ assert(!is.eof());
+ assert(!is.fail());
+ }
+}
diff --git a/test/std/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/long_double.pass.cpp b/test/std/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/long_double.pass.cpp
new file mode 100644
index 000000000000..cc70faed6c23
--- /dev/null
+++ b/test/std/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/long_double.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_istream;
+
+// operator>>(long double& val);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_string<CharT> string_type;
+ typedef std::basic_streambuf<CharT> base;
+private:
+ string_type str_;
+public:
+
+ testbuf() {}
+ testbuf(const string_type& str)
+ : str_(str)
+ {
+ base::setg(const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data()) + str_.size());
+ }
+
+ CharT* eback() const {return base::eback();}
+ CharT* gptr() const {return base::gptr();}
+ CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+ {
+ std::istream is((std::streambuf*)0);
+ long double n = 0;
+ is >> n;
+ assert(is.fail());
+ }
+ {
+ testbuf<char> sb("0");
+ std::istream is(&sb);
+ long double n = 10;
+ is >> n;
+ assert(n == 0);
+ assert( is.eof());
+ assert(!is.fail());
+ }
+ {
+ testbuf<char> sb(" 123 ");
+ std::istream is(&sb);
+ long double n = 10;
+ is >> n;
+ assert(n == 123);
+ assert(!is.eof());
+ assert(!is.fail());
+ }
+ {
+ testbuf<wchar_t> sb(L" -123.5 ");
+ std::wistream is(&sb);
+ long double n = 10;
+ is >> n;
+ assert(n == -123.5);
+ assert(!is.eof());
+ assert(!is.fail());
+ }
+}
diff --git a/test/std/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/long_long.pass.cpp b/test/std/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/long_long.pass.cpp
new file mode 100644
index 000000000000..c37e17516248
--- /dev/null
+++ b/test/std/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/long_long.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_istream;
+
+// operator>>(long long& val);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_string<CharT> string_type;
+ typedef std::basic_streambuf<CharT> base;
+private:
+ string_type str_;
+public:
+
+ testbuf() {}
+ testbuf(const string_type& str)
+ : str_(str)
+ {
+ base::setg(const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data()) + str_.size());
+ }
+
+ CharT* eback() const {return base::eback();}
+ CharT* gptr() const {return base::gptr();}
+ CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+ {
+ std::istream is((std::streambuf*)0);
+ long long n = 0;
+ is >> n;
+ assert(is.fail());
+ }
+ {
+ testbuf<char> sb("0");
+ std::istream is(&sb);
+ long long n = 10;
+ is >> n;
+ assert(n == 0);
+ assert( is.eof());
+ assert(!is.fail());
+ }
+ {
+ testbuf<char> sb(" 123 ");
+ std::istream is(&sb);
+ long long n = 10;
+ is >> n;
+ assert(n == 123);
+ assert(!is.eof());
+ assert(!is.fail());
+ }
+ {
+ testbuf<wchar_t> sb(L" -123 ");
+ std::wistream is(&sb);
+ long long n = 10;
+ is >> n;
+ assert(n == -123);
+ assert(!is.eof());
+ assert(!is.fail());
+ }
+}
diff --git a/test/std/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/pointer.pass.cpp b/test/std/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/pointer.pass.cpp
new file mode 100644
index 000000000000..52b35666424a
--- /dev/null
+++ b/test/std/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/pointer.pass.cpp
@@ -0,0 +1,97 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_istream;
+
+// operator>>(void*& val);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_string<CharT> string_type;
+ typedef std::basic_streambuf<CharT> base;
+private:
+ string_type str_;
+public:
+
+ testbuf() {}
+ testbuf(const string_type& str)
+ : str_(str)
+ {
+ base::setg(const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data()) + str_.size());
+ }
+
+ CharT* eback() const {return base::eback();}
+ CharT* gptr() const {return base::gptr();}
+ CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+ {
+ std::istream is((std::streambuf*)0);
+ void* n = 0;
+ is >> n;
+ assert(is.fail());
+ }
+ {
+ testbuf<char> sb("0");
+ std::istream is(&sb);
+ void* n = (void*)1;
+ is >> n;
+ assert(n == 0);
+ assert( is.eof());
+ assert(!is.fail());
+ }
+ {
+ testbuf<char> sb(" 1 ");
+ std::istream is(&sb);
+ void* n = 0;
+ is >> n;
+ assert(n == (void*)1);
+ assert(!is.eof());
+ assert(!is.fail());
+ }
+ {
+ testbuf<wchar_t> sb(L" 1 ");
+ std::wistream is(&sb);
+ void* n = 0;
+ is >> n;
+ assert(n == (void*)1);
+ assert(!is.eof());
+ assert(!is.fail());
+ }
+ {
+ testbuf<char> sb("12345678");
+ std::istream is(&sb);
+ void* n = 0;
+ is >> n;
+ assert(n == (void*)0x12345678);
+ assert( is.eof());
+ assert(!is.fail());
+ }
+ {
+ testbuf<wchar_t> sb(L"12345678");
+ std::wistream is(&sb);
+ void* n = 0;
+ is >> n;
+ assert(n == (void*)0x12345678);
+ assert( is.eof());
+ assert(!is.fail());
+ }
+}
diff --git a/test/std/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/short.pass.cpp b/test/std/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/short.pass.cpp
new file mode 100644
index 000000000000..62e44f542a64
--- /dev/null
+++ b/test/std/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/short.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_istream;
+
+// operator>>(short& val);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_string<CharT> string_type;
+ typedef std::basic_streambuf<CharT> base;
+private:
+ string_type str_;
+public:
+
+ testbuf() {}
+ testbuf(const string_type& str)
+ : str_(str)
+ {
+ base::setg(const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data()) + str_.size());
+ }
+
+ CharT* eback() const {return base::eback();}
+ CharT* gptr() const {return base::gptr();}
+ CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+ {
+ std::istream is((std::streambuf*)0);
+ short n = 0;
+ is >> n;
+ assert(is.fail());
+ }
+ {
+ testbuf<char> sb("0");
+ std::istream is(&sb);
+ short n = 10;
+ is >> n;
+ assert(n == 0);
+ assert( is.eof());
+ assert(!is.fail());
+ }
+ {
+ testbuf<char> sb(" 123 ");
+ std::istream is(&sb);
+ short n = 10;
+ is >> n;
+ assert(n == 123);
+ assert(!is.eof());
+ assert(!is.fail());
+ }
+ {
+ testbuf<wchar_t> sb(L" -1234567890 ");
+ std::wistream is(&sb);
+ short n = 10;
+ is >> n;
+ assert(n == std::numeric_limits<short>::min());
+ assert(!is.eof());
+ assert( is.fail());
+ }
+}
diff --git a/test/std/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/unsigned_int.pass.cpp b/test/std/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/unsigned_int.pass.cpp
new file mode 100644
index 000000000000..6f1091690da1
--- /dev/null
+++ b/test/std/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/unsigned_int.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_istream;
+
+// operator>>(unsigned int& val);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_string<CharT> string_type;
+ typedef std::basic_streambuf<CharT> base;
+private:
+ string_type str_;
+public:
+
+ testbuf() {}
+ testbuf(const string_type& str)
+ : str_(str)
+ {
+ base::setg(const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data()) + str_.size());
+ }
+
+ CharT* eback() const {return base::eback();}
+ CharT* gptr() const {return base::gptr();}
+ CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+ {
+ std::istream is((std::streambuf*)0);
+ unsigned int n = 0;
+ is >> n;
+ assert(is.fail());
+ }
+ {
+ testbuf<char> sb("0");
+ std::istream is(&sb);
+ unsigned int n = 10;
+ is >> n;
+ assert(n == 0);
+ assert( is.eof());
+ assert(!is.fail());
+ }
+ {
+ testbuf<char> sb(" 123 ");
+ std::istream is(&sb);
+ unsigned int n = 10;
+ is >> n;
+ assert(n == 123);
+ assert(!is.eof());
+ assert(!is.fail());
+ }
+ {
+ testbuf<wchar_t> sb(L" 123 ");
+ std::wistream is(&sb);
+ unsigned int n = 10;
+ is >> n;
+ assert(n == 123);
+ assert(!is.eof());
+ assert(!is.fail());
+ }
+}
diff --git a/test/std/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/unsigned_long.pass.cpp b/test/std/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/unsigned_long.pass.cpp
new file mode 100644
index 000000000000..eb8a7231ffca
--- /dev/null
+++ b/test/std/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/unsigned_long.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_istream;
+
+// operator>>(unsigned long& val);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_string<CharT> string_type;
+ typedef std::basic_streambuf<CharT> base;
+private:
+ string_type str_;
+public:
+
+ testbuf() {}
+ testbuf(const string_type& str)
+ : str_(str)
+ {
+ base::setg(const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data()) + str_.size());
+ }
+
+ CharT* eback() const {return base::eback();}
+ CharT* gptr() const {return base::gptr();}
+ CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+ {
+ std::istream is((std::streambuf*)0);
+ unsigned long n = 0;
+ is >> n;
+ assert(is.fail());
+ }
+ {
+ testbuf<char> sb("0");
+ std::istream is(&sb);
+ unsigned long n = 10;
+ is >> n;
+ assert(n == 0);
+ assert( is.eof());
+ assert(!is.fail());
+ }
+ {
+ testbuf<char> sb(" 123 ");
+ std::istream is(&sb);
+ unsigned long n = 10;
+ is >> n;
+ assert(n == 123);
+ assert(!is.eof());
+ assert(!is.fail());
+ }
+ {
+ testbuf<wchar_t> sb(L" 123 ");
+ std::wistream is(&sb);
+ unsigned long n = 10;
+ is >> n;
+ assert(n == 123);
+ assert(!is.eof());
+ assert(!is.fail());
+ }
+}
diff --git a/test/std/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/unsigned_long_long.pass.cpp b/test/std/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/unsigned_long_long.pass.cpp
new file mode 100644
index 000000000000..1db250ed463a
--- /dev/null
+++ b/test/std/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/unsigned_long_long.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_istream;
+
+// operator>>(unsigned long long& val);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_string<CharT> string_type;
+ typedef std::basic_streambuf<CharT> base;
+private:
+ string_type str_;
+public:
+
+ testbuf() {}
+ testbuf(const string_type& str)
+ : str_(str)
+ {
+ base::setg(const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data()) + str_.size());
+ }
+
+ CharT* eback() const {return base::eback();}
+ CharT* gptr() const {return base::gptr();}
+ CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+ {
+ std::istream is((std::streambuf*)0);
+ unsigned long long n = 0;
+ is >> n;
+ assert(is.fail());
+ }
+ {
+ testbuf<char> sb("0");
+ std::istream is(&sb);
+ unsigned long long n = 10;
+ is >> n;
+ assert(n == 0);
+ assert( is.eof());
+ assert(!is.fail());
+ }
+ {
+ testbuf<char> sb(" 123 ");
+ std::istream is(&sb);
+ unsigned long long n = 10;
+ is >> n;
+ assert(n == 123);
+ assert(!is.eof());
+ assert(!is.fail());
+ }
+ {
+ testbuf<wchar_t> sb(L" 123 ");
+ std::wistream is(&sb);
+ unsigned long long n = 10;
+ is >> n;
+ assert(n == 123);
+ assert(!is.eof());
+ assert(!is.fail());
+ }
+}
diff --git a/test/std/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/unsigned_short.pass.cpp b/test/std/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/unsigned_short.pass.cpp
new file mode 100644
index 000000000000..78fdc6638823
--- /dev/null
+++ b/test/std/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/unsigned_short.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_istream;
+
+// operator>>(unsigned short& val);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_string<CharT> string_type;
+ typedef std::basic_streambuf<CharT> base;
+private:
+ string_type str_;
+public:
+
+ testbuf() {}
+ testbuf(const string_type& str)
+ : str_(str)
+ {
+ base::setg(const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data()) + str_.size());
+ }
+
+ CharT* eback() const {return base::eback();}
+ CharT* gptr() const {return base::gptr();}
+ CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+ {
+ std::istream is((std::streambuf*)0);
+ unsigned short n = 0;
+ is >> n;
+ assert(is.fail());
+ }
+ {
+ testbuf<char> sb("0");
+ std::istream is(&sb);
+ unsigned short n = 10;
+ is >> n;
+ assert(n == 0);
+ assert( is.eof());
+ assert(!is.fail());
+ }
+ {
+ testbuf<char> sb(" 123 ");
+ std::istream is(&sb);
+ unsigned short n = 10;
+ is >> n;
+ assert(n == 123);
+ assert(!is.eof());
+ assert(!is.fail());
+ }
+ {
+ testbuf<wchar_t> sb(L" 123 ");
+ std::wistream is(&sb);
+ unsigned short n = 10;
+ is >> n;
+ assert(n == 123);
+ assert(!is.eof());
+ assert(!is.fail());
+ }
+}
diff --git a/test/std/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.reqmts/tested_elsewhere.pass.cpp b/test/std/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.reqmts/tested_elsewhere.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.reqmts/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/basic_ios.pass.cpp b/test/std/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/basic_ios.pass.cpp
new file mode 100644
index 000000000000..0d4516d55567
--- /dev/null
+++ b/test/std/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/basic_ios.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_istream;
+
+// basic_istream<charT,traits>& operator>>(basic_ios<charT,traits>&
+// (*pf)(basic_ios<charT,traits>&));
+
+#include <istream>
+#include <cassert>
+
+int f_called = 0;
+
+template <class CharT>
+std::basic_ios<CharT>&
+f(std::basic_ios<CharT>& is)
+{
+ ++f_called;
+ return is;
+}
+
+int main()
+{
+ {
+ std::istream is((std::streambuf*)0);
+ is >> f;
+ assert(f_called == 1);
+ }
+}
diff --git a/test/std/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/chart.pass.cpp b/test/std/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/chart.pass.cpp
new file mode 100644
index 000000000000..b5068220cffd
--- /dev/null
+++ b/test/std/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/chart.pass.cpp
@@ -0,0 +1,87 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template<class charT, class traits>
+// basic_istream<charT,traits>& operator>>(basic_istream<charT,traits>&& in, charT& c);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_string<CharT> string_type;
+ typedef std::basic_streambuf<CharT> base;
+private:
+ string_type str_;
+public:
+
+ testbuf() {}
+ testbuf(const string_type& str)
+ : str_(str)
+ {
+ base::setg(const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data()) + str_.size());
+ }
+
+ CharT* eback() const {return base::eback();}
+ CharT* gptr() const {return base::gptr();}
+ CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+ {
+ testbuf<char> sb(" ");
+ std::istream is(&sb);
+ char c = 'z';
+ is >> c;
+ assert( is.eof());
+ assert( is.fail());
+ assert(c == 'z');
+ }
+ {
+ testbuf<char> sb(" abcdefghijk ");
+ std::istream is(&sb);
+ char c;
+ is >> c;
+ assert(!is.eof());
+ assert(!is.fail());
+ assert(c == 'a');
+ is >> c;
+ assert(!is.eof());
+ assert(!is.fail());
+ assert(c == 'b');
+ is >> c;
+ assert(!is.eof());
+ assert(!is.fail());
+ assert(c == 'c');
+ }
+ {
+ testbuf<wchar_t> sb(L" abc");
+ std::wistream is(&sb);
+ wchar_t c;
+ is >> c;
+ assert(!is.eof());
+ assert(!is.fail());
+ assert(c == L'a');
+ is >> c;
+ assert(!is.eof());
+ assert(!is.fail());
+ assert(c == L'b');
+ is >> c;
+ assert(!is.eof());
+ assert(!is.fail());
+ assert(c == L'c');
+ }
+}
diff --git a/test/std/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/ios_base.pass.cpp b/test/std/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/ios_base.pass.cpp
new file mode 100644
index 000000000000..d4cb2bb13b2f
--- /dev/null
+++ b/test/std/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/ios_base.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_istream;
+
+// basic_istream<charT,traits>& operator>>(ios_base& (*pf)(ios_base&));
+
+#include <istream>
+#include <cassert>
+
+int f_called = 0;
+
+std::ios_base&
+f(std::ios_base& is)
+{
+ ++f_called;
+ return is;
+}
+
+int main()
+{
+ {
+ std::istream is((std::streambuf*)0);
+ is >> f;
+ assert(f_called == 1);
+ }
+}
diff --git a/test/std/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/istream.pass.cpp b/test/std/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/istream.pass.cpp
new file mode 100644
index 000000000000..4c3aef491ea6
--- /dev/null
+++ b/test/std/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/istream.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_istream;
+
+// basic_istream<charT,traits>& operator>>(basic_istream<charT,traits>&
+// (*pf)(basic_istream<charT,traits>&));
+
+#include <istream>
+#include <cassert>
+
+int f_called = 0;
+
+template <class CharT>
+std::basic_istream<CharT>&
+f(std::basic_istream<CharT>& is)
+{
+ ++f_called;
+ return is;
+}
+
+int main()
+{
+ {
+ std::istream is((std::streambuf*)0);
+ is >> f;
+ assert(f_called == 1);
+ }
+}
diff --git a/test/std/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/signed_char.pass.cpp b/test/std/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/signed_char.pass.cpp
new file mode 100644
index 000000000000..a02fe2c51a6d
--- /dev/null
+++ b/test/std/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/signed_char.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template<class traits>
+// basic_istream<char,traits>& operator>>(basic_istream<char,traits>&& in, signed char& c);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_string<CharT> string_type;
+ typedef std::basic_streambuf<CharT> base;
+private:
+ string_type str_;
+public:
+
+ testbuf() {}
+ testbuf(const string_type& str)
+ : str_(str)
+ {
+ base::setg(const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data()) + str_.size());
+ }
+
+ CharT* eback() const {return base::eback();}
+ CharT* gptr() const {return base::gptr();}
+ CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+ {
+ testbuf<char> sb(" ");
+ std::istream is(&sb);
+ signed char c = 'z';
+ is >> c;
+ assert( is.eof());
+ assert( is.fail());
+ assert(c == 'z');
+ }
+ {
+ testbuf<char> sb(" abcdefghijk ");
+ std::istream is(&sb);
+ signed char c;
+ is >> c;
+ assert(!is.eof());
+ assert(!is.fail());
+ assert(c == 'a');
+ is >> c;
+ assert(!is.eof());
+ assert(!is.fail());
+ assert(c == 'b');
+ is >> c;
+ assert(!is.eof());
+ assert(!is.fail());
+ assert(c == 'c');
+ }
+}
diff --git a/test/std/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/signed_char_pointer.pass.cpp b/test/std/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/signed_char_pointer.pass.cpp
new file mode 100644
index 000000000000..70f1c20108fc
--- /dev/null
+++ b/test/std/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/signed_char_pointer.pass.cpp
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template<class traits>
+// basic_istream<char,traits>& operator>>(basic_istream<char,traits>&& in, signed char* s);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_string<CharT> string_type;
+ typedef std::basic_streambuf<CharT> base;
+private:
+ string_type str_;
+public:
+
+ testbuf() {}
+ testbuf(const string_type& str)
+ : str_(str)
+ {
+ base::setg(const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data()) + str_.size());
+ }
+
+ CharT* eback() const {return base::eback();}
+ CharT* gptr() const {return base::gptr();}
+ CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+ {
+ testbuf<char> sb(" abcdefghijk ");
+ std::istream is(&sb);
+ signed char s[20];
+ is >> s;
+ assert(!is.eof());
+ assert(!is.fail());
+ assert(std::string((char*)s) == "abcdefghijk");
+ }
+ {
+ testbuf<char> sb(" abcdefghijk ");
+ std::istream is(&sb);
+ is.width(4);
+ signed char s[20];
+ is >> s;
+ assert(!is.eof());
+ assert(!is.fail());
+ assert(std::string((char*)s) == "abc");
+ assert(is.width() == 0);
+ }
+ {
+ testbuf<char> sb(" abcdefghijk");
+ std::istream is(&sb);
+ signed char s[20];
+ is >> s;
+ assert( is.eof());
+ assert(!is.fail());
+ assert(std::string((char*)s) == "abcdefghijk");
+ assert(is.width() == 0);
+ }
+ {
+ testbuf<char> sb(" abcdefghijk");
+ std::istream is(&sb);
+ signed char s[20];
+ is.width(1);
+ is >> s;
+ assert(!is.eof());
+ assert( is.fail());
+ assert(std::string((char*)s) == "");
+ assert(is.width() == 0);
+ }
+}
diff --git a/test/std/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/streambuf.pass.cpp b/test/std/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/streambuf.pass.cpp
new file mode 100644
index 000000000000..29ed68e9770c
--- /dev/null
+++ b/test/std/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/streambuf.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_istream;
+
+// basic_istream<charT,traits>& operator<<(basic_streambuf<charT,traits>* sb);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_streambuf<CharT> base;
+ std::basic_string<CharT> str_;
+public:
+ testbuf()
+ {
+ }
+ testbuf(const std::basic_string<CharT>& str)
+ : str_(str)
+ {
+ base::setg(const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data() + str_.size()));
+ }
+
+ std::basic_string<CharT> str() const
+ {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+ virtual typename base::int_type
+ overflow(typename base::int_type __c = base::traits_type::eof())
+ {
+ if (__c != base::traits_type::eof())
+ {
+ int n = str_.size();
+ str_.push_back(__c);
+ str_.resize(str_.capacity());
+ base::setp(const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data() + str_.size()));
+ base::pbump(n+1);
+ }
+ return __c;
+ }
+};
+
+int main()
+{
+ {
+ testbuf<char> sb("testing...");
+ std::istream is(&sb);
+ testbuf<char> sb2;
+ is >> &sb2;
+ assert(sb2.str() == "testing...");
+ assert(is.gcount() == 10);
+ }
+}
diff --git a/test/std/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/unsigned_char.pass.cpp b/test/std/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/unsigned_char.pass.cpp
new file mode 100644
index 000000000000..8f19cea7b882
--- /dev/null
+++ b/test/std/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/unsigned_char.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template<class traits>
+// basic_istream<char,traits>& operator>>(basic_istream<char,traits>&& in, unsigned char& c);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_string<CharT> string_type;
+ typedef std::basic_streambuf<CharT> base;
+private:
+ string_type str_;
+public:
+
+ testbuf() {}
+ testbuf(const string_type& str)
+ : str_(str)
+ {
+ base::setg(const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data()) + str_.size());
+ }
+
+ CharT* eback() const {return base::eback();}
+ CharT* gptr() const {return base::gptr();}
+ CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+ {
+ testbuf<char> sb(" ");
+ std::istream is(&sb);
+ unsigned char c = 'z';
+ is >> c;
+ assert( is.eof());
+ assert( is.fail());
+ assert(c == 'z');
+ }
+ {
+ testbuf<char> sb(" abcdefghijk ");
+ std::istream is(&sb);
+ unsigned char c;
+ is >> c;
+ assert(!is.eof());
+ assert(!is.fail());
+ assert(c == 'a');
+ is >> c;
+ assert(!is.eof());
+ assert(!is.fail());
+ assert(c == 'b');
+ is >> c;
+ assert(!is.eof());
+ assert(!is.fail());
+ assert(c == 'c');
+ }
+}
diff --git a/test/std/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/unsigned_char_pointer.pass.cpp b/test/std/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/unsigned_char_pointer.pass.cpp
new file mode 100644
index 000000000000..07fa5a79e8f2
--- /dev/null
+++ b/test/std/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/unsigned_char_pointer.pass.cpp
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template<class traits>
+// basic_istream<char,traits>& operator>>(basic_istream<char,traits>&& in, unsigned char* s);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_string<CharT> string_type;
+ typedef std::basic_streambuf<CharT> base;
+private:
+ string_type str_;
+public:
+
+ testbuf() {}
+ testbuf(const string_type& str)
+ : str_(str)
+ {
+ base::setg(const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data()) + str_.size());
+ }
+
+ CharT* eback() const {return base::eback();}
+ CharT* gptr() const {return base::gptr();}
+ CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+ {
+ testbuf<char> sb(" abcdefghijk ");
+ std::istream is(&sb);
+ unsigned char s[20];
+ is >> s;
+ assert(!is.eof());
+ assert(!is.fail());
+ assert(std::string((char*)s) == "abcdefghijk");
+ }
+ {
+ testbuf<char> sb(" abcdefghijk ");
+ std::istream is(&sb);
+ is.width(4);
+ unsigned char s[20];
+ is >> s;
+ assert(!is.eof());
+ assert(!is.fail());
+ assert(std::string((char*)s) == "abc");
+ assert(is.width() == 0);
+ }
+ {
+ testbuf<char> sb(" abcdefghijk");
+ std::istream is(&sb);
+ unsigned char s[20];
+ is >> s;
+ assert( is.eof());
+ assert(!is.fail());
+ assert(std::string((char*)s) == "abcdefghijk");
+ assert(is.width() == 0);
+ }
+ {
+ testbuf<char> sb(" abcdefghijk");
+ std::istream is(&sb);
+ unsigned char s[20];
+ is.width(1);
+ is >> s;
+ assert(!is.eof());
+ assert( is.fail());
+ assert(std::string((char*)s) == "");
+ assert(is.width() == 0);
+ }
+}
diff --git a/test/std/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/wchar_t_pointer.pass.cpp b/test/std/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/wchar_t_pointer.pass.cpp
new file mode 100644
index 000000000000..a00c7a1dda38
--- /dev/null
+++ b/test/std/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/wchar_t_pointer.pass.cpp
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template<class charT, class traits>
+// basic_istream<charT,traits>& operator>>(basic_istream<charT,traits>&& in, charT* s);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_string<CharT> string_type;
+ typedef std::basic_streambuf<CharT> base;
+private:
+ string_type str_;
+public:
+
+ testbuf() {}
+ testbuf(const string_type& str)
+ : str_(str)
+ {
+ base::setg(const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data()) + str_.size());
+ }
+
+ CharT* eback() const {return base::eback();}
+ CharT* gptr() const {return base::gptr();}
+ CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+ {
+ testbuf<char> sb(" abcdefghijk ");
+ std::istream is(&sb);
+ char s[20];
+ is >> s;
+ assert(!is.eof());
+ assert(!is.fail());
+ assert(std::string(s) == "abcdefghijk");
+ }
+ {
+ testbuf<wchar_t> sb(L" abcdefghijk ");
+ std::wistream is(&sb);
+ is.width(4);
+ wchar_t s[20];
+ is >> s;
+ assert(!is.eof());
+ assert(!is.fail());
+ assert(std::wstring(s) == L"abc");
+ assert(is.width() == 0);
+ }
+ {
+ testbuf<wchar_t> sb(L" abcdefghijk");
+ std::wistream is(&sb);
+ wchar_t s[20];
+ is >> s;
+ assert( is.eof());
+ assert(!is.fail());
+ assert(std::wstring(s) == L"abcdefghijk");
+ assert(is.width() == 0);
+ }
+ {
+ testbuf<char> sb(" abcdefghijk");
+ std::istream is(&sb);
+ char s[20];
+ is.width(1);
+ is >> s;
+ assert(!is.eof());
+ assert( is.fail());
+ assert(std::string(s) == "");
+ assert(is.width() == 0);
+ }
+}
diff --git a/test/std/input.output/iostream.format/input.streams/istream.formatted/nothing_to_do.pass.cpp b/test/std/input.output/iostream.format/input.streams/istream.formatted/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/input.output/iostream.format/input.streams/istream.formatted/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/input.output/iostream.format/input.streams/istream.manip/ws.pass.cpp b/test/std/input.output/iostream.format/input.streams/istream.manip/ws.pass.cpp
new file mode 100644
index 000000000000..3c8159a6d7cb
--- /dev/null
+++ b/test/std/input.output/iostream.format/input.streams/istream.manip/ws.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits>
+// basic_istream<charT,traits>&
+// ws(basic_istream<charT,traits>& is);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_string<CharT> string_type;
+ typedef std::basic_streambuf<CharT> base;
+private:
+ string_type str_;
+public:
+
+ testbuf() {}
+ testbuf(const string_type& str)
+ : str_(str)
+ {
+ base::setg(const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data()) + str_.size());
+ }
+
+ CharT* eback() const {return base::eback();}
+ CharT* gptr() const {return base::gptr();}
+ CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+ {
+ testbuf<char> sb(" 123");
+ std::istream is(&sb);
+ ws(is);
+ assert(is.good());
+ assert(is.peek() == '1');
+ }
+ {
+ testbuf<wchar_t> sb(L" 123");
+ std::wistream is(&sb);
+ ws(is);
+ assert(is.good());
+ assert(is.peek() == L'1');
+ }
+ {
+ testbuf<char> sb(" ");
+ std::istream is(&sb);
+ ws(is);
+ assert(!is.fail());
+ assert(is.eof());
+ ws(is);
+ assert(is.eof());
+ assert(is.fail());
+ }
+ {
+ testbuf<wchar_t> sb(L" ");
+ std::wistream is(&sb);
+ ws(is);
+ assert(!is.fail());
+ assert(is.eof());
+ ws(is);
+ assert(is.eof());
+ assert(is.fail());
+ }
+}
diff --git a/test/std/input.output/iostream.format/input.streams/istream.rvalue/rvalue.pass.cpp b/test/std/input.output/iostream.format/input.streams/istream.rvalue/rvalue.pass.cpp
new file mode 100644
index 000000000000..5b7664e3f55c
--- /dev/null
+++ b/test/std/input.output/iostream.format/input.streams/istream.rvalue/rvalue.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits, class T>
+// basic_istream<charT, traits>&
+// operator>>(basic_istream<charT, traits>&& is, T& x);
+
+#include <istream>
+#include <cassert>
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class CharT>
+struct testbuf
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_string<CharT> string_type;
+ typedef std::basic_streambuf<CharT> base;
+private:
+ string_type str_;
+public:
+
+ testbuf() {}
+ testbuf(const string_type& str)
+ : str_(str)
+ {
+ base::setg(const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data()) + str_.size());
+ }
+
+ CharT* eback() const {return base::eback();}
+ CharT* gptr() const {return base::gptr();}
+ CharT* egptr() const {return base::egptr();}
+};
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ testbuf<char> sb(" 123");
+ int i = 0;
+ std::istream(&sb) >> i;
+ assert(i == 123);
+ }
+ {
+ testbuf<wchar_t> sb(L" 123");
+ int i = 0;
+ std::wistream(&sb) >> i;
+ assert(i == 123);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/input.output/iostream.format/input.streams/istream.unformatted/get.pass.cpp b/test/std/input.output/iostream.format/input.streams/istream.unformatted/get.pass.cpp
new file mode 100644
index 000000000000..41a721d50f13
--- /dev/null
+++ b/test/std/input.output/iostream.format/input.streams/istream.unformatted/get.pass.cpp
@@ -0,0 +1,100 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// int_type get();
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_string<CharT> string_type;
+ typedef std::basic_streambuf<CharT> base;
+private:
+ string_type str_;
+public:
+
+ testbuf() {}
+ testbuf(const string_type& str)
+ : str_(str)
+ {
+ base::setg(const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data()) + str_.size());
+ }
+
+ CharT* eback() const {return base::eback();}
+ CharT* gptr() const {return base::gptr();}
+ CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+ {
+ testbuf<char> sb(" ");
+ std::istream is(&sb);
+ char c = is.get();
+ assert(!is.eof());
+ assert(!is.fail());
+ assert(c == ' ');
+ assert(is.gcount() == 1);
+ }
+ {
+ testbuf<char> sb(" abc");
+ std::istream is(&sb);
+ char c = is.get();
+ assert(!is.eof());
+ assert(!is.fail());
+ assert(c == ' ');
+ assert(is.gcount() == 1);
+ c = is.get();
+ assert(!is.eof());
+ assert(!is.fail());
+ assert(c == 'a');
+ assert(is.gcount() == 1);
+ c = is.get();
+ assert(!is.eof());
+ assert(!is.fail());
+ assert(c == 'b');
+ assert(is.gcount() == 1);
+ c = is.get();
+ assert(!is.eof());
+ assert(!is.fail());
+ assert(c == 'c');
+ assert(is.gcount() == 1);
+ }
+ {
+ testbuf<wchar_t> sb(L" abc");
+ std::wistream is(&sb);
+ wchar_t c = is.get();
+ assert(!is.eof());
+ assert(!is.fail());
+ assert(c == L' ');
+ assert(is.gcount() == 1);
+ c = is.get();
+ assert(!is.eof());
+ assert(!is.fail());
+ assert(c == L'a');
+ assert(is.gcount() == 1);
+ c = is.get();
+ assert(!is.eof());
+ assert(!is.fail());
+ assert(c == L'b');
+ assert(is.gcount() == 1);
+ c = is.get();
+ assert(!is.eof());
+ assert(!is.fail());
+ assert(c == L'c');
+ assert(is.gcount() == 1);
+ }
+}
diff --git a/test/std/input.output/iostream.format/input.streams/istream.unformatted/get_chart.pass.cpp b/test/std/input.output/iostream.format/input.streams/istream.unformatted/get_chart.pass.cpp
new file mode 100644
index 000000000000..cf06e343bcc2
--- /dev/null
+++ b/test/std/input.output/iostream.format/input.streams/istream.unformatted/get_chart.pass.cpp
@@ -0,0 +1,103 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// basic_istream<charT,traits>& get(char_type& c);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_string<CharT> string_type;
+ typedef std::basic_streambuf<CharT> base;
+private:
+ string_type str_;
+public:
+
+ testbuf() {}
+ testbuf(const string_type& str)
+ : str_(str)
+ {
+ base::setg(const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data()) + str_.size());
+ }
+
+ CharT* eback() const {return base::eback();}
+ CharT* gptr() const {return base::gptr();}
+ CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+ {
+ testbuf<char> sb(" ");
+ std::istream is(&sb);
+ char c;
+ is.get(c);
+ assert(!is.eof());
+ assert(!is.fail());
+ assert(c == ' ');
+ assert(is.gcount() == 1);
+ }
+ {
+ testbuf<char> sb(" abc");
+ std::istream is(&sb);
+ char c;
+ is.get(c);
+ assert(!is.eof());
+ assert(!is.fail());
+ assert(c == ' ');
+ assert(is.gcount() == 1);
+ is.get(c);
+ assert(!is.eof());
+ assert(!is.fail());
+ assert(c == 'a');
+ assert(is.gcount() == 1);
+ is.get(c);
+ assert(!is.eof());
+ assert(!is.fail());
+ assert(c == 'b');
+ assert(is.gcount() == 1);
+ is.get(c);
+ assert(!is.eof());
+ assert(!is.fail());
+ assert(c == 'c');
+ assert(is.gcount() == 1);
+ }
+ {
+ testbuf<wchar_t> sb(L" abc");
+ std::wistream is(&sb);
+ wchar_t c;
+ is.get(c);
+ assert(!is.eof());
+ assert(!is.fail());
+ assert(c == L' ');
+ assert(is.gcount() == 1);
+ is.get(c);
+ assert(!is.eof());
+ assert(!is.fail());
+ assert(c == L'a');
+ assert(is.gcount() == 1);
+ is.get(c);
+ assert(!is.eof());
+ assert(!is.fail());
+ assert(c == L'b');
+ assert(is.gcount() == 1);
+ is.get(c);
+ assert(!is.eof());
+ assert(!is.fail());
+ assert(c == L'c');
+ assert(is.gcount() == 1);
+ }
+}
diff --git a/test/std/input.output/iostream.format/input.streams/istream.unformatted/get_pointer_size.pass.cpp b/test/std/input.output/iostream.format/input.streams/istream.unformatted/get_pointer_size.pass.cpp
new file mode 100644
index 000000000000..1691a2d2de14
--- /dev/null
+++ b/test/std/input.output/iostream.format/input.streams/istream.unformatted/get_pointer_size.pass.cpp
@@ -0,0 +1,99 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// basic_istream<charT,traits>& get(char_type* s, streamsize n);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_string<CharT> string_type;
+ typedef std::basic_streambuf<CharT> base;
+private:
+ string_type str_;
+public:
+
+ testbuf() {}
+ testbuf(const string_type& str)
+ : str_(str)
+ {
+ base::setg(const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data()) + str_.size());
+ }
+
+ CharT* eback() const {return base::eback();}
+ CharT* gptr() const {return base::gptr();}
+ CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+ {
+ testbuf<char> sb(" \n \n ");
+ std::istream is(&sb);
+ char s[5];
+ is.get(s, 5);
+ assert(!is.eof());
+ assert(!is.fail());
+ assert(std::string(s) == " ");
+ assert(is.gcount() == 2);
+ is.get(s, 5);
+ assert(!is.eof());
+ assert( is.fail());
+ assert(std::string(s) == "");
+ assert(is.gcount() == 0);
+ is.clear();
+ assert(is.get() == '\n');
+ is.get(s, 5);
+ assert(!is.eof());
+ assert(!is.fail());
+ assert(std::string(s) == " ");
+ assert(is.gcount() == 4);
+ assert(is.get() == '\n');
+ is.get(s, 5);
+ assert( is.eof());
+ assert(!is.fail());
+ assert(std::string(s) == " ");
+ assert(is.gcount() == 1);
+ }
+ {
+ testbuf<wchar_t> sb(L" \n \n ");
+ std::wistream is(&sb);
+ wchar_t s[5];
+ is.get(s, 5);
+ assert(!is.eof());
+ assert(!is.fail());
+ assert(std::wstring(s) == L" ");
+ assert(is.gcount() == 2);
+ is.get(s, 5);
+ assert(!is.eof());
+ assert( is.fail());
+ assert(std::wstring(s) == L"");
+ assert(is.gcount() == 0);
+ is.clear();
+ assert(is.get() == L'\n');
+ is.get(s, 5);
+ assert(!is.eof());
+ assert(!is.fail());
+ assert(std::wstring(s) == L" ");
+ assert(is.gcount() == 4);
+ assert(is.get() == L'\n');
+ is.get(s, 5);
+ assert( is.eof());
+ assert(!is.fail());
+ assert(std::wstring(s) == L" ");
+ assert(is.gcount() == 1);
+ }
+}
diff --git a/test/std/input.output/iostream.format/input.streams/istream.unformatted/get_pointer_size_chart.pass.cpp b/test/std/input.output/iostream.format/input.streams/istream.unformatted/get_pointer_size_chart.pass.cpp
new file mode 100644
index 000000000000..c9389ec9dad5
--- /dev/null
+++ b/test/std/input.output/iostream.format/input.streams/istream.unformatted/get_pointer_size_chart.pass.cpp
@@ -0,0 +1,99 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// basic_istream<charT,traits>& get(char_type* s, streamsize n, char_type delim);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_string<CharT> string_type;
+ typedef std::basic_streambuf<CharT> base;
+private:
+ string_type str_;
+public:
+
+ testbuf() {}
+ testbuf(const string_type& str)
+ : str_(str)
+ {
+ base::setg(const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data()) + str_.size());
+ }
+
+ CharT* eback() const {return base::eback();}
+ CharT* gptr() const {return base::gptr();}
+ CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+ {
+ testbuf<char> sb(" * * ");
+ std::istream is(&sb);
+ char s[5];
+ is.get(s, 5, '*');
+ assert(!is.eof());
+ assert(!is.fail());
+ assert(std::string(s) == " ");
+ assert(is.gcount() == 2);
+ is.get(s, 5, '*');
+ assert(!is.eof());
+ assert( is.fail());
+ assert(std::string(s) == "");
+ assert(is.gcount() == 0);
+ is.clear();
+ assert(is.get() == '*');
+ is.get(s, 5, '*');
+ assert(!is.eof());
+ assert(!is.fail());
+ assert(std::string(s) == " ");
+ assert(is.gcount() == 4);
+ assert(is.get() == '*');
+ is.get(s, 5, '*');
+ assert( is.eof());
+ assert(!is.fail());
+ assert(std::string(s) == " ");
+ assert(is.gcount() == 1);
+ }
+ {
+ testbuf<wchar_t> sb(L" * * ");
+ std::wistream is(&sb);
+ wchar_t s[5];
+ is.get(s, 5, L'*');
+ assert(!is.eof());
+ assert(!is.fail());
+ assert(std::wstring(s) == L" ");
+ assert(is.gcount() == 2);
+ is.get(s, 5, L'*');
+ assert(!is.eof());
+ assert( is.fail());
+ assert(std::wstring(s) == L"");
+ assert(is.gcount() == 0);
+ is.clear();
+ assert(is.get() == L'*');
+ is.get(s, 5, L'*');
+ assert(!is.eof());
+ assert(!is.fail());
+ assert(std::wstring(s) == L" ");
+ assert(is.gcount() == 4);
+ assert(is.get() == L'*');
+ is.get(s, 5, L'*');
+ assert( is.eof());
+ assert(!is.fail());
+ assert(std::wstring(s) == L" ");
+ assert(is.gcount() == 1);
+ }
+}
diff --git a/test/std/input.output/iostream.format/input.streams/istream.unformatted/get_streambuf.pass.cpp b/test/std/input.output/iostream.format/input.streams/istream.unformatted/get_streambuf.pass.cpp
new file mode 100644
index 000000000000..7a55f847d734
--- /dev/null
+++ b/test/std/input.output/iostream.format/input.streams/istream.unformatted/get_streambuf.pass.cpp
@@ -0,0 +1,88 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// basic_istream<charT,traits>& get(basic_streambuf<char_type,traits>& sb);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_streambuf<CharT> base;
+ std::basic_string<CharT> str_;
+public:
+ testbuf()
+ {
+ }
+ testbuf(const std::basic_string<CharT>& str)
+ : str_(str)
+ {
+ base::setg(const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data() + str_.size()));
+ }
+
+ std::basic_string<CharT> str() const
+ {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+ virtual typename base::int_type
+ overflow(typename base::int_type __c = base::traits_type::eof())
+ {
+ if (__c != base::traits_type::eof())
+ {
+ int n = str_.size();
+ str_.push_back(__c);
+ str_.resize(str_.capacity());
+ base::setp(const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data() + str_.size()));
+ base::pbump(n+1);
+ }
+ return __c;
+ }
+};
+
+int main()
+{
+ {
+ testbuf<char> sb("testing\n...");
+ std::istream is(&sb);
+ testbuf<char> sb2;
+ is.get(sb2);
+ assert(sb2.str() == "testing");
+ assert(is.good());
+ assert(is.gcount() == 7);
+ assert(is.get() == '\n');
+ is.get(sb2);
+ assert(sb2.str() == "testing...");
+ assert(is.eof());
+ assert(!is.fail());
+ assert(is.gcount() == 3);
+ }
+ {
+ testbuf<wchar_t> sb(L"testing\n...");
+ std::wistream is(&sb);
+ testbuf<wchar_t> sb2;
+ is.get(sb2);
+ assert(sb2.str() == L"testing");
+ assert(is.good());
+ assert(is.gcount() == 7);
+ assert(is.get() == L'\n');
+ is.get(sb2);
+ assert(sb2.str() == L"testing...");
+ assert(is.eof());
+ assert(!is.fail());
+ assert(is.gcount() == 3);
+ }
+}
diff --git a/test/std/input.output/iostream.format/input.streams/istream.unformatted/get_streambuf_chart.pass.cpp b/test/std/input.output/iostream.format/input.streams/istream.unformatted/get_streambuf_chart.pass.cpp
new file mode 100644
index 000000000000..cbc007587d5e
--- /dev/null
+++ b/test/std/input.output/iostream.format/input.streams/istream.unformatted/get_streambuf_chart.pass.cpp
@@ -0,0 +1,89 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// basic_istream<charT,traits>& get(basic_streambuf<char_type,traits>& sb,
+// char_type delim);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_streambuf<CharT> base;
+ std::basic_string<CharT> str_;
+public:
+ testbuf()
+ {
+ }
+ testbuf(const std::basic_string<CharT>& str)
+ : str_(str)
+ {
+ base::setg(const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data() + str_.size()));
+ }
+
+ std::basic_string<CharT> str() const
+ {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+ virtual typename base::int_type
+ overflow(typename base::int_type __c = base::traits_type::eof())
+ {
+ if (__c != base::traits_type::eof())
+ {
+ int n = str_.size();
+ str_.push_back(__c);
+ str_.resize(str_.capacity());
+ base::setp(const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data() + str_.size()));
+ base::pbump(n+1);
+ }
+ return __c;
+ }
+};
+
+int main()
+{
+ {
+ testbuf<char> sb("testing*...");
+ std::istream is(&sb);
+ testbuf<char> sb2;
+ is.get(sb2, '*');
+ assert(sb2.str() == "testing");
+ assert(is.good());
+ assert(is.gcount() == 7);
+ assert(is.get() == '*');
+ is.get(sb2, '*');
+ assert(sb2.str() == "testing...");
+ assert(is.eof());
+ assert(!is.fail());
+ assert(is.gcount() == 3);
+ }
+ {
+ testbuf<wchar_t> sb(L"testing*...");
+ std::wistream is(&sb);
+ testbuf<wchar_t> sb2;
+ is.get(sb2, L'*');
+ assert(sb2.str() == L"testing");
+ assert(is.good());
+ assert(is.gcount() == 7);
+ assert(is.get() == L'*');
+ is.get(sb2, L'*');
+ assert(sb2.str() == L"testing...");
+ assert(is.eof());
+ assert(!is.fail());
+ assert(is.gcount() == 3);
+ }
+}
diff --git a/test/std/input.output/iostream.format/input.streams/istream.unformatted/getline_pointer_size.pass.cpp b/test/std/input.output/iostream.format/input.streams/istream.unformatted/getline_pointer_size.pass.cpp
new file mode 100644
index 000000000000..465824a659f2
--- /dev/null
+++ b/test/std/input.output/iostream.format/input.streams/istream.unformatted/getline_pointer_size.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// basic_istream<charT,traits>& getline(char_type* s, streamsize n);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_string<CharT> string_type;
+ typedef std::basic_streambuf<CharT> base;
+private:
+ string_type str_;
+public:
+
+ testbuf() {}
+ testbuf(const string_type& str)
+ : str_(str)
+ {
+ base::setg(const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data()) + str_.size());
+ }
+
+ CharT* eback() const {return base::eback();}
+ CharT* gptr() const {return base::gptr();}
+ CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+ {
+ testbuf<char> sb(" \n \n ");
+ std::istream is(&sb);
+ char s[5];
+ is.getline(s, 5);
+ assert(!is.eof());
+ assert(!is.fail());
+ assert(std::string(s) == " ");
+ assert(is.gcount() == 3);
+ is.getline(s, 5);
+ assert(!is.eof());
+ assert(!is.fail());
+ assert(std::string(s) == " ");
+ assert(is.gcount() == 5);
+ is.getline(s, 5);
+ assert( is.eof());
+ assert(!is.fail());
+ assert(std::string(s) == " ");
+ assert(is.gcount() == 1);
+ }
+ {
+ testbuf<wchar_t> sb(L" \n \n ");
+ std::wistream is(&sb);
+ wchar_t s[5];
+ is.getline(s, 5);
+ assert(!is.eof());
+ assert(!is.fail());
+ assert(std::wstring(s) == L" ");
+ assert(is.gcount() == 3);
+ is.getline(s, 5);
+ assert(!is.eof());
+ assert(!is.fail());
+ assert(std::wstring(s) == L" ");
+ assert(is.gcount() == 5);
+ is.getline(s, 5);
+ assert( is.eof());
+ assert(!is.fail());
+ assert(std::wstring(s) == L" ");
+ assert(is.gcount() == 1);
+ }
+}
diff --git a/test/std/input.output/iostream.format/input.streams/istream.unformatted/getline_pointer_size_chart.pass.cpp b/test/std/input.output/iostream.format/input.streams/istream.unformatted/getline_pointer_size_chart.pass.cpp
new file mode 100644
index 000000000000..7362959966a6
--- /dev/null
+++ b/test/std/input.output/iostream.format/input.streams/istream.unformatted/getline_pointer_size_chart.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// basic_istream<charT,traits>& getline(char_type* s, streamsize n, char_type delim);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_string<CharT> string_type;
+ typedef std::basic_streambuf<CharT> base;
+private:
+ string_type str_;
+public:
+
+ testbuf() {}
+ testbuf(const string_type& str)
+ : str_(str)
+ {
+ base::setg(const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data()) + str_.size());
+ }
+
+ CharT* eback() const {return base::eback();}
+ CharT* gptr() const {return base::gptr();}
+ CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+ {
+ testbuf<char> sb(" * * ");
+ std::istream is(&sb);
+ char s[5];
+ is.getline(s, 5, '*');
+ assert(!is.eof());
+ assert(!is.fail());
+ assert(std::string(s) == " ");
+ assert(is.gcount() == 3);
+ is.getline(s, 5, '*');
+ assert(!is.eof());
+ assert(!is.fail());
+ assert(std::string(s) == " ");
+ assert(is.gcount() == 5);
+ is.getline(s, 5, '*');
+ assert( is.eof());
+ assert(!is.fail());
+ assert(std::string(s) == " ");
+ assert(is.gcount() == 1);
+ }
+ {
+ testbuf<wchar_t> sb(L" * * ");
+ std::wistream is(&sb);
+ wchar_t s[5];
+ is.getline(s, 5, L'*');
+ assert(!is.eof());
+ assert(!is.fail());
+ assert(std::wstring(s) == L" ");
+ assert(is.gcount() == 3);
+ is.getline(s, 5, L'*');
+ assert(!is.eof());
+ assert(!is.fail());
+ assert(std::wstring(s) == L" ");
+ assert(is.gcount() == 5);
+ is.getline(s, 5, L'*');
+ assert( is.eof());
+ assert(!is.fail());
+ assert(std::wstring(s) == L" ");
+ assert(is.gcount() == 1);
+ }
+}
diff --git a/test/std/input.output/iostream.format/input.streams/istream.unformatted/ignore.pass.cpp b/test/std/input.output/iostream.format/input.streams/istream.unformatted/ignore.pass.cpp
new file mode 100644
index 000000000000..9510961a4c51
--- /dev/null
+++ b/test/std/input.output/iostream.format/input.streams/istream.unformatted/ignore.pass.cpp
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// basic_istream<charT,traits>&
+// ignore(streamsize n = 1, int_type delim = traits::eof());
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_string<CharT> string_type;
+ typedef std::basic_streambuf<CharT> base;
+private:
+ string_type str_;
+public:
+
+ testbuf() {}
+ testbuf(const string_type& str)
+ : str_(str)
+ {
+ base::setg(const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data()) + str_.size());
+ }
+
+ CharT* eback() const {return base::eback();}
+ CharT* gptr() const {return base::gptr();}
+ CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+ {
+ testbuf<char> sb(" 1\n2345\n6");
+ std::istream is(&sb);
+ is.ignore();
+ assert(!is.eof());
+ assert(!is.fail());
+ assert(is.gcount() == 1);
+ is.ignore(5, '\n');
+ assert(!is.eof());
+ assert(!is.fail());
+ assert(is.gcount() == 2);
+ is.ignore(15);
+ assert( is.eof());
+ assert(!is.fail());
+ assert(is.gcount() == 6);
+ }
+ {
+ testbuf<wchar_t> sb(L" 1\n2345\n6");
+ std::wistream is(&sb);
+ is.ignore();
+ assert(!is.eof());
+ assert(!is.fail());
+ assert(is.gcount() == 1);
+ is.ignore(5, '\n');
+ assert(!is.eof());
+ assert(!is.fail());
+ assert(is.gcount() == 2);
+ is.ignore(15);
+ assert( is.eof());
+ assert(!is.fail());
+ assert(is.gcount() == 6);
+ }
+}
diff --git a/test/std/input.output/iostream.format/input.streams/istream.unformatted/ignore_0xff.pass.cpp b/test/std/input.output/iostream.format/input.streams/istream.unformatted/ignore_0xff.pass.cpp
new file mode 100644
index 000000000000..ccc3545483e7
--- /dev/null
+++ b/test/std/input.output/iostream.format/input.streams/istream.unformatted/ignore_0xff.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// basic_istream<charT,traits>&
+// ignore(streamsize n = 1, int_type delim = traits::eof());
+
+// http://llvm.org/bugs/show_bug.cgi?id=16427
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ int bad=-1;
+ std::ostringstream os;
+ os << "aaaabbbb" << static_cast<char>(bad)
+ << "ccccdddd" << std::endl;
+ std::string s=os.str();
+
+ std::istringstream is(s);
+ const unsigned int ignoreLen=10;
+ size_t a=is.tellg();
+ is.ignore(ignoreLen);
+ size_t b=is.tellg();
+ assert((b-a)==ignoreLen);
+}
diff --git a/test/std/input.output/iostream.format/input.streams/istream.unformatted/peek.pass.cpp b/test/std/input.output/iostream.format/input.streams/istream.unformatted/peek.pass.cpp
new file mode 100644
index 000000000000..4264849a0917
--- /dev/null
+++ b/test/std/input.output/iostream.format/input.streams/istream.unformatted/peek.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// int_type peek();
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_string<CharT> string_type;
+ typedef std::basic_streambuf<CharT> base;
+private:
+ string_type str_;
+public:
+
+ testbuf() {}
+ testbuf(const string_type& str)
+ : str_(str)
+ {
+ base::setg(const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data()) + str_.size());
+ }
+
+ CharT* eback() const {return base::eback();}
+ CharT* gptr() const {return base::gptr();}
+ CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+ {
+ testbuf<char> sb(" 1\n2345\n6");
+ std::istream is(&sb);
+ assert(is.peek() == ' ');
+ assert(!is.eof());
+ assert(!is.fail());
+ assert(is.gcount() == 0);
+ is.get();
+ assert(is.peek() == '1');
+ assert(!is.eof());
+ assert(!is.fail());
+ assert(is.gcount() == 0);
+ }
+ {
+ testbuf<wchar_t> sb(L" 1\n2345\n6");
+ std::wistream is(&sb);
+ assert(is.peek() == L' ');
+ assert(!is.eof());
+ assert(!is.fail());
+ assert(is.gcount() == 0);
+ is.get();
+ assert(is.peek() == L'1');
+ assert(!is.eof());
+ assert(!is.fail());
+ assert(is.gcount() == 0);
+ }
+}
diff --git a/test/std/input.output/iostream.format/input.streams/istream.unformatted/putback.pass.cpp b/test/std/input.output/iostream.format/input.streams/istream.unformatted/putback.pass.cpp
new file mode 100644
index 000000000000..3564d710bc23
--- /dev/null
+++ b/test/std/input.output/iostream.format/input.streams/istream.unformatted/putback.pass.cpp
@@ -0,0 +1,89 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// basic_istream<charT,traits>& putback(char_type c);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_string<CharT> string_type;
+ typedef std::basic_streambuf<CharT> base;
+private:
+ string_type str_;
+public:
+
+ testbuf() {}
+ testbuf(const string_type& str)
+ : str_(str)
+ {
+ base::setg(const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data()) + str_.size());
+ }
+
+ CharT* eback() const {return base::eback();}
+ CharT* gptr() const {return base::gptr();}
+ CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+ {
+ testbuf<char> sb(" 123456789");
+ std::istream is(&sb);
+ is.get();
+ is.get();
+ is.get();
+ is.putback('a');
+ assert(is.bad());
+ assert(is.gcount() == 0);
+ is.clear();
+ is.putback('2');
+ assert(is.good());
+ assert(is.gcount() == 0);
+ is.putback('1');
+ assert(is.good());
+ assert(is.gcount() == 0);
+ is.putback(' ');
+ assert(is.good());
+ assert(is.gcount() == 0);
+ is.putback(' ');
+ assert(is.bad());
+ assert(is.gcount() == 0);
+ }
+ {
+ testbuf<wchar_t> sb(L" 123456789");
+ std::wistream is(&sb);
+ is.get();
+ is.get();
+ is.get();
+ is.putback(L'a');
+ assert(is.bad());
+ assert(is.gcount() == 0);
+ is.clear();
+ is.putback(L'2');
+ assert(is.good());
+ assert(is.gcount() == 0);
+ is.putback(L'1');
+ assert(is.good());
+ assert(is.gcount() == 0);
+ is.putback(L' ');
+ assert(is.good());
+ assert(is.gcount() == 0);
+ is.putback(L' ');
+ assert(is.bad());
+ assert(is.gcount() == 0);
+ }
+}
diff --git a/test/std/input.output/iostream.format/input.streams/istream.unformatted/read.pass.cpp b/test/std/input.output/iostream.format/input.streams/istream.unformatted/read.pass.cpp
new file mode 100644
index 000000000000..20e70cfbd5cd
--- /dev/null
+++ b/test/std/input.output/iostream.format/input.streams/istream.unformatted/read.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// basic_istream<charT,traits>& read(char_type* s, streamsize n);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_string<CharT> string_type;
+ typedef std::basic_streambuf<CharT> base;
+private:
+ string_type str_;
+public:
+
+ testbuf() {}
+ testbuf(const string_type& str)
+ : str_(str)
+ {
+ base::setg(const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data()) + str_.size());
+ }
+
+ CharT* eback() const {return base::eback();}
+ CharT* gptr() const {return base::gptr();}
+ CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+ {
+ testbuf<char> sb(" 123456789");
+ std::istream is(&sb);
+ char s[5];
+ is.read(s, 5);
+ assert(!is.eof());
+ assert(!is.fail());
+ assert(std::string(s, 5) == " 1234");
+ assert(is.gcount() == 5);
+ is.read(s, 5);
+ assert(!is.eof());
+ assert(!is.fail());
+ assert(std::string(s, 5) == "56789");
+ assert(is.gcount() == 5);
+ is.read(s, 5);
+ assert( is.eof());
+ assert( is.fail());
+ assert(is.gcount() == 0);
+ }
+ {
+ testbuf<wchar_t> sb(L" 123456789");
+ std::wistream is(&sb);
+ wchar_t s[5];
+ is.read(s, 5);
+ assert(!is.eof());
+ assert(!is.fail());
+ assert(std::wstring(s, 5) == L" 1234");
+ assert(is.gcount() == 5);
+ is.read(s, 5);
+ assert(!is.eof());
+ assert(!is.fail());
+ assert(std::wstring(s, 5) == L"56789");
+ assert(is.gcount() == 5);
+ is.read(s, 5);
+ assert( is.eof());
+ assert( is.fail());
+ assert(is.gcount() == 0);
+ }
+}
diff --git a/test/std/input.output/iostream.format/input.streams/istream.unformatted/readsome.pass.cpp b/test/std/input.output/iostream.format/input.streams/istream.unformatted/readsome.pass.cpp
new file mode 100644
index 000000000000..01eecb5d824b
--- /dev/null
+++ b/test/std/input.output/iostream.format/input.streams/istream.unformatted/readsome.pass.cpp
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// streamsize readsome(char_type* s, streamsize n);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_string<CharT> string_type;
+ typedef std::basic_streambuf<CharT> base;
+private:
+ string_type str_;
+public:
+
+ testbuf() {}
+ testbuf(const string_type& str)
+ : str_(str)
+ {
+ base::setg(const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data()) + str_.size());
+ }
+
+ CharT* eback() const {return base::eback();}
+ CharT* gptr() const {return base::gptr();}
+ CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+ {
+ testbuf<char> sb(" 1234567890");
+ std::istream is(&sb);
+ char s[5];
+ assert(is.readsome(s, 5) == 5);
+ assert(!is.eof());
+ assert(!is.fail());
+ assert(std::string(s, 5) == " 1234");
+ assert(is.gcount() == 5);
+ is.readsome(s, 5);
+ assert(!is.eof());
+ assert(!is.fail());
+ assert(std::string(s, 5) == "56789");
+ assert(is.gcount() == 5);
+ is.readsome(s, 5);
+ assert(!is.eof());
+ assert(!is.fail());
+ assert(is.gcount() == 1);
+ assert(std::string(s, 1) == "0");
+ assert(is.readsome(s, 5) == 0);
+ }
+ {
+ testbuf<wchar_t> sb(L" 1234567890");
+ std::wistream is(&sb);
+ wchar_t s[5];
+ assert(is.readsome(s, 5) == 5);
+ assert(!is.eof());
+ assert(!is.fail());
+ assert(std::wstring(s, 5) == L" 1234");
+ assert(is.gcount() == 5);
+ is.readsome(s, 5);
+ assert(!is.eof());
+ assert(!is.fail());
+ assert(std::wstring(s, 5) == L"56789");
+ assert(is.gcount() == 5);
+ is.readsome(s, 5);
+ assert(!is.eof());
+ assert(!is.fail());
+ assert(is.gcount() == 1);
+ assert(std::wstring(s, 1) == L"0");
+ assert(is.readsome(s, 5) == 0);
+ }
+}
diff --git a/test/std/input.output/iostream.format/input.streams/istream.unformatted/seekg.pass.cpp b/test/std/input.output/iostream.format/input.streams/istream.unformatted/seekg.pass.cpp
new file mode 100644
index 000000000000..e6f4e1e4c19e
--- /dev/null
+++ b/test/std/input.output/iostream.format/input.streams/istream.unformatted/seekg.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// basic_istream<charT,traits>& seekg(pos_type pos);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_string<CharT> string_type;
+ typedef std::basic_streambuf<CharT> base;
+private:
+ string_type str_;
+public:
+
+ testbuf() {}
+ testbuf(const string_type& str)
+ : str_(str)
+ {
+ base::setg(const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data()) + str_.size());
+ }
+
+ CharT* eback() const {return base::eback();}
+ CharT* gptr() const {return base::gptr();}
+ CharT* egptr() const {return base::egptr();}
+protected:
+ typename base::pos_type seekpos(typename base::pos_type sp,
+ std::ios_base::openmode which)
+ {
+ assert(which == std::ios_base::in);
+ return sp;
+ }
+};
+
+int main()
+{
+ {
+ testbuf<char> sb(" 123456789");
+ std::istream is(&sb);
+ is.seekg(5);
+ assert(is.good());
+ is.seekg(-1);
+ assert(is.fail());
+ }
+ {
+ testbuf<wchar_t> sb(L" 123456789");
+ std::wistream is(&sb);
+ is.seekg(5);
+ assert(is.good());
+ is.seekg(-1);
+ assert(is.fail());
+ }
+}
diff --git a/test/std/input.output/iostream.format/input.streams/istream.unformatted/seekg_off.pass.cpp b/test/std/input.output/iostream.format/input.streams/istream.unformatted/seekg_off.pass.cpp
new file mode 100644
index 000000000000..73f3da1c6bd1
--- /dev/null
+++ b/test/std/input.output/iostream.format/input.streams/istream.unformatted/seekg_off.pass.cpp
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// basic_istream<charT,traits>& seekg(off_type off, ios_base::seekdir dir);
+
+#include <istream>
+#include <cassert>
+
+int seekoff_called = 0;
+
+template <class CharT>
+struct testbuf
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_string<CharT> string_type;
+ typedef std::basic_streambuf<CharT> base;
+private:
+ string_type str_;
+public:
+
+ testbuf() {}
+ testbuf(const string_type& str)
+ : str_(str)
+ {
+ base::setg(const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data()) + str_.size());
+ }
+
+ CharT* eback() const {return base::eback();}
+ CharT* gptr() const {return base::gptr();}
+ CharT* egptr() const {return base::egptr();}
+protected:
+ typename base::pos_type seekoff(typename base::off_type off,
+ std::ios_base::seekdir way,
+ std::ios_base::openmode which)
+ {
+ assert(which == std::ios_base::in);
+ ++seekoff_called;
+ return off;
+ }
+};
+
+int main()
+{
+ {
+ testbuf<char> sb(" 123456789");
+ std::istream is(&sb);
+ is.seekg(5, std::ios_base::cur);
+ assert(is.good());
+ assert(seekoff_called == 1);
+ is.seekg(-1, std::ios_base::beg);
+ assert(is.fail());
+ assert(seekoff_called == 2);
+ }
+ {
+ testbuf<wchar_t> sb(L" 123456789");
+ std::wistream is(&sb);
+ is.seekg(5, std::ios_base::cur);
+ assert(is.good());
+ assert(seekoff_called == 3);
+ is.seekg(-1, std::ios_base::beg);
+ assert(is.fail());
+ assert(seekoff_called == 4);
+ }
+}
diff --git a/test/std/input.output/iostream.format/input.streams/istream.unformatted/sync.pass.cpp b/test/std/input.output/iostream.format/input.streams/istream.unformatted/sync.pass.cpp
new file mode 100644
index 000000000000..61db67cd5a5d
--- /dev/null
+++ b/test/std/input.output/iostream.format/input.streams/istream.unformatted/sync.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// int sync();
+
+#include <istream>
+#include <cassert>
+
+int sync_called = 0;
+
+template <class CharT>
+struct testbuf
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_string<CharT> string_type;
+ typedef std::basic_streambuf<CharT> base;
+private:
+ string_type str_;
+public:
+
+ testbuf() {}
+ testbuf(const string_type& str)
+ : str_(str)
+ {
+ base::setg(const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data()) + str_.size());
+ }
+
+ CharT* eback() const {return base::eback();}
+ CharT* gptr() const {return base::gptr();}
+ CharT* egptr() const {return base::egptr();}
+
+protected:
+ int sync()
+ {
+ ++sync_called;
+ return 5;
+ }
+};
+
+int main()
+{
+ {
+ testbuf<char> sb(" 123456789");
+ std::istream is(&sb);
+ assert(is.sync() == 0);
+ assert(sync_called == 1);
+ }
+ {
+ testbuf<wchar_t> sb(L" 123456789");
+ std::wistream is(&sb);
+ assert(is.sync() == 0);
+ assert(sync_called == 2);
+ }
+}
diff --git a/test/std/input.output/iostream.format/input.streams/istream.unformatted/tellg.pass.cpp b/test/std/input.output/iostream.format/input.streams/istream.unformatted/tellg.pass.cpp
new file mode 100644
index 000000000000..799b46b97dea
--- /dev/null
+++ b/test/std/input.output/iostream.format/input.streams/istream.unformatted/tellg.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// pos_type tellg();
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_string<CharT> string_type;
+ typedef std::basic_streambuf<CharT> base;
+private:
+ string_type str_;
+public:
+
+ testbuf() {}
+ testbuf(const string_type& str)
+ : str_(str)
+ {
+ base::setg(const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data()) + str_.size());
+ }
+
+ CharT* eback() const {return base::eback();}
+ CharT* gptr() const {return base::gptr();}
+ CharT* egptr() const {return base::egptr();}
+protected:
+ typename base::pos_type seekoff(typename base::off_type off,
+ std::ios_base::seekdir way,
+ std::ios_base::openmode which)
+ {
+ assert(off == 0);
+ assert(way == std::ios_base::cur);
+ assert(which == std::ios_base::in);
+ return 5;
+ }
+};
+
+int main()
+{
+ {
+ testbuf<char> sb(" 123456789");
+ std::istream is(&sb);
+ assert(is.tellg() == 5);
+ }
+ {
+ testbuf<wchar_t> sb(L" 123456789");
+ std::wistream is(&sb);
+ assert(is.tellg() == 5);
+ }
+}
diff --git a/test/std/input.output/iostream.format/input.streams/istream.unformatted/unget.pass.cpp b/test/std/input.output/iostream.format/input.streams/istream.unformatted/unget.pass.cpp
new file mode 100644
index 000000000000..adf0a6117c1d
--- /dev/null
+++ b/test/std/input.output/iostream.format/input.streams/istream.unformatted/unget.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// basic_istream<charT,traits>& unget();
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_string<CharT> string_type;
+ typedef std::basic_streambuf<CharT> base;
+private:
+ string_type str_;
+public:
+
+ testbuf() {}
+ testbuf(const string_type& str)
+ : str_(str)
+ {
+ base::setg(const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data()) + str_.size());
+ }
+
+ CharT* eback() const {return base::eback();}
+ CharT* gptr() const {return base::gptr();}
+ CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+ {
+ testbuf<char> sb(" 123456789");
+ std::istream is(&sb);
+ is.get();
+ is.get();
+ is.get();
+ is.unget();
+ assert(is.good());
+ assert(is.gcount() == 0);
+ is.unget();
+ assert(is.good());
+ assert(is.gcount() == 0);
+ is.unget();
+ assert(is.good());
+ assert(is.gcount() == 0);
+ is.unget();
+ assert(is.bad());
+ assert(is.gcount() == 0);
+ }
+ {
+ testbuf<wchar_t> sb(L" 123456789");
+ std::wistream is(&sb);
+ is.get();
+ is.get();
+ is.get();
+ is.unget();
+ assert(is.good());
+ assert(is.gcount() == 0);
+ is.unget();
+ assert(is.good());
+ assert(is.gcount() == 0);
+ is.unget();
+ assert(is.good());
+ assert(is.gcount() == 0);
+ is.unget();
+ assert(is.bad());
+ assert(is.gcount() == 0);
+ }
+}
diff --git a/test/std/input.output/iostream.format/input.streams/istream/istream.assign/member_swap.pass.cpp b/test/std/input.output/iostream.format/input.streams/istream/istream.assign/member_swap.pass.cpp
new file mode 100644
index 000000000000..a0734b8016b5
--- /dev/null
+++ b/test/std/input.output/iostream.format/input.streams/istream/istream.assign/member_swap.pass.cpp
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_istream;
+
+// void swap(basic_istream& rhs);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+ : public std::basic_streambuf<CharT>
+{
+ testbuf() {}
+};
+
+template <class CharT>
+struct test_istream
+ : public std::basic_istream<CharT>
+{
+ typedef std::basic_istream<CharT> base;
+ test_istream(testbuf<CharT>* sb) : base(sb) {}
+
+ void swap(test_istream& s) {base::swap(s);}
+};
+
+int main()
+{
+ {
+ testbuf<char> sb1;
+ testbuf<char> sb2;
+ test_istream<char> is1(&sb1);
+ test_istream<char> is2(&sb2);
+ is1.swap(is2);
+ assert(is1.rdbuf() == &sb1);
+ assert(is1.tie() == 0);
+ assert(is1.fill() == ' ');
+ assert(is1.rdstate() == is1.goodbit);
+ assert(is1.exceptions() == is1.goodbit);
+ assert(is1.flags() == (is1.skipws | is1.dec));
+ assert(is1.precision() == 6);
+ assert(is1.getloc().name() == "C");
+ assert(is2.rdbuf() == &sb2);
+ assert(is2.tie() == 0);
+ assert(is2.fill() == ' ');
+ assert(is2.rdstate() == is2.goodbit);
+ assert(is2.exceptions() == is2.goodbit);
+ assert(is2.flags() == (is2.skipws | is2.dec));
+ assert(is2.precision() == 6);
+ assert(is2.getloc().name() == "C");
+ }
+ {
+ testbuf<wchar_t> sb1;
+ testbuf<wchar_t> sb2;
+ test_istream<wchar_t> is1(&sb1);
+ test_istream<wchar_t> is2(&sb2);
+ is1.swap(is2);
+ assert(is1.rdbuf() == &sb1);
+ assert(is1.tie() == 0);
+ assert(is1.fill() == ' ');
+ assert(is1.rdstate() == is1.goodbit);
+ assert(is1.exceptions() == is1.goodbit);
+ assert(is1.flags() == (is1.skipws | is1.dec));
+ assert(is1.precision() == 6);
+ assert(is1.getloc().name() == "C");
+ assert(is2.rdbuf() == &sb2);
+ assert(is2.tie() == 0);
+ assert(is2.fill() == ' ');
+ assert(is2.rdstate() == is2.goodbit);
+ assert(is2.exceptions() == is2.goodbit);
+ assert(is2.flags() == (is2.skipws | is2.dec));
+ assert(is2.precision() == 6);
+ assert(is2.getloc().name() == "C");
+ }
+}
diff --git a/test/std/input.output/iostream.format/input.streams/istream/istream.assign/move_assign.pass.cpp b/test/std/input.output/iostream.format/input.streams/istream/istream.assign/move_assign.pass.cpp
new file mode 100644
index 000000000000..2876d76c1984
--- /dev/null
+++ b/test/std/input.output/iostream.format/input.streams/istream/istream.assign/move_assign.pass.cpp
@@ -0,0 +1,92 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_istream;
+
+// basic_istream& operator=(basic_istream&& rhs);
+
+#include <istream>
+#include <cassert>
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class CharT>
+struct testbuf
+ : public std::basic_streambuf<CharT>
+{
+ testbuf() {}
+};
+
+template <class CharT>
+struct test_istream
+ : public std::basic_istream<CharT>
+{
+ typedef std::basic_istream<CharT> base;
+ test_istream(testbuf<CharT>* sb) : base(sb) {}
+
+ test_istream& operator=(test_istream&& s)
+ {base::operator=(std::move(s)); return *this;}
+};
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ testbuf<char> sb1;
+ testbuf<char> sb2;
+ test_istream<char> is1(&sb1);
+ test_istream<char> is2(&sb2);
+ is2 = (std::move(is1));
+ assert(is1.rdbuf() == &sb1);
+ assert(is1.tie() == 0);
+ assert(is1.fill() == ' ');
+ assert(is1.rdstate() == is1.goodbit);
+ assert(is1.exceptions() == is1.goodbit);
+ assert(is1.flags() == (is1.skipws | is1.dec));
+ assert(is1.precision() == 6);
+ assert(is1.getloc().name() == "C");
+ assert(is2.rdbuf() == &sb2);
+ assert(is2.tie() == 0);
+ assert(is2.fill() == ' ');
+ assert(is2.rdstate() == is2.goodbit);
+ assert(is2.exceptions() == is2.goodbit);
+ assert(is2.flags() == (is2.skipws | is2.dec));
+ assert(is2.precision() == 6);
+ assert(is2.getloc().name() == "C");
+ }
+ {
+ testbuf<wchar_t> sb1;
+ testbuf<wchar_t> sb2;
+ test_istream<wchar_t> is1(&sb1);
+ test_istream<wchar_t> is2(&sb2);
+ is2 = (std::move(is1));
+ assert(is1.rdbuf() == &sb1);
+ assert(is1.tie() == 0);
+ assert(is1.fill() == ' ');
+ assert(is1.rdstate() == is1.goodbit);
+ assert(is1.exceptions() == is1.goodbit);
+ assert(is1.flags() == (is1.skipws | is1.dec));
+ assert(is1.precision() == 6);
+ assert(is1.getloc().name() == "C");
+ assert(is2.rdbuf() == &sb2);
+ assert(is2.tie() == 0);
+ assert(is2.fill() == ' ');
+ assert(is2.rdstate() == is2.goodbit);
+ assert(is2.exceptions() == is2.goodbit);
+ assert(is2.flags() == (is2.skipws | is2.dec));
+ assert(is2.precision() == 6);
+ assert(is2.getloc().name() == "C");
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/input.output/iostream.format/input.streams/istream/istream.cons/move.pass.cpp b/test/std/input.output/iostream.format/input.streams/istream/istream.cons/move.pass.cpp
new file mode 100644
index 000000000000..04cb9d3fb6ba
--- /dev/null
+++ b/test/std/input.output/iostream.format/input.streams/istream/istream.cons/move.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_istream;
+
+// basic_istream(basic_istream&& rhs);
+
+#include <istream>
+#include <cassert>
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class CharT>
+struct testbuf
+ : public std::basic_streambuf<CharT>
+{
+ testbuf() {}
+};
+
+template <class CharT>
+struct test_istream
+ : public std::basic_istream<CharT>
+{
+ typedef std::basic_istream<CharT> base;
+ test_istream(testbuf<CharT>* sb) : base(sb) {}
+
+ test_istream(test_istream&& s)
+ : base(std::move(s)) {}
+};
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ testbuf<char> sb;
+ test_istream<char> is1(&sb);
+ test_istream<char> is(std::move(is1));
+ assert(is1.rdbuf() == &sb);
+ assert(is1.gcount() == 0);
+ assert(is.gcount() == 0);
+ assert(is.rdbuf() == 0);
+ assert(is.tie() == 0);
+ assert(is.fill() == ' ');
+ assert(is.rdstate() == is.goodbit);
+ assert(is.exceptions() == is.goodbit);
+ assert(is.flags() == (is.skipws | is.dec));
+ assert(is.precision() == 6);
+ assert(is.getloc().name() == "C");
+ }
+ {
+ testbuf<wchar_t> sb;
+ test_istream<wchar_t> is1(&sb);
+ test_istream<wchar_t> is(std::move(is1));
+ assert(is1.gcount() == 0);
+ assert(is.gcount() == 0);
+ assert(is1.rdbuf() == &sb);
+ assert(is.rdbuf() == 0);
+ assert(is.tie() == 0);
+ assert(is.fill() == L' ');
+ assert(is.rdstate() == is.goodbit);
+ assert(is.exceptions() == is.goodbit);
+ assert(is.flags() == (is.skipws | is.dec));
+ assert(is.precision() == 6);
+ assert(is.getloc().name() == "C");
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/input.output/iostream.format/input.streams/istream/istream.cons/streambuf.pass.cpp b/test/std/input.output/iostream.format/input.streams/istream/istream.cons/streambuf.pass.cpp
new file mode 100644
index 000000000000..74ed57dae6bd
--- /dev/null
+++ b/test/std/input.output/iostream.format/input.streams/istream/istream.cons/streambuf.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_istream;
+
+// explicit basic_istream(basic_streambuf<charT,traits>* sb);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+ : public std::basic_streambuf<CharT>
+{
+ testbuf() {}
+};
+
+int main()
+{
+ {
+ testbuf<char> sb;
+ std::basic_istream<char> is(&sb);
+ assert(is.rdbuf() == &sb);
+ assert(is.tie() == 0);
+ assert(is.fill() == ' ');
+ assert(is.rdstate() == is.goodbit);
+ assert(is.exceptions() == is.goodbit);
+ assert(is.flags() == (is.skipws | is.dec));
+ assert(is.precision() == 6);
+ assert(is.getloc().name() == "C");
+ assert(is.gcount() == 0);
+ }
+ {
+ testbuf<wchar_t> sb;
+ std::basic_istream<wchar_t> is(&sb);
+ assert(is.rdbuf() == &sb);
+ assert(is.tie() == 0);
+ assert(is.fill() == L' ');
+ assert(is.rdstate() == is.goodbit);
+ assert(is.exceptions() == is.goodbit);
+ assert(is.flags() == (is.skipws | is.dec));
+ assert(is.precision() == 6);
+ assert(is.getloc().name() == "C");
+ assert(is.gcount() == 0);
+ }
+}
diff --git a/test/std/input.output/iostream.format/input.streams/istream/istream_sentry/ctor.pass.cpp b/test/std/input.output/iostream.format/input.streams/istream/istream_sentry/ctor.pass.cpp
new file mode 100644
index 000000000000..910b36931da3
--- /dev/null
+++ b/test/std/input.output/iostream.format/input.streams/istream/istream_sentry/ctor.pass.cpp
@@ -0,0 +1,128 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_istream::sentry;
+
+// explicit sentry(basic_istream<charT,traits>& is, bool noskipws = false);
+
+#include <istream>
+#include <cassert>
+
+int sync_called = 0;
+
+template <class CharT>
+struct testbuf
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_string<CharT> string_type;
+ typedef std::basic_streambuf<CharT> base;
+private:
+ string_type str_;
+public:
+
+ testbuf() {}
+ testbuf(const string_type& str)
+ : str_(str)
+ {
+ base::setg(const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data()) + str_.size());
+ }
+
+ CharT* eback() const {return base::eback();}
+ CharT* gptr() const {return base::gptr();}
+ CharT* egptr() const {return base::egptr();}
+protected:
+
+ int virtual sync()
+ {
+ ++sync_called;
+ return 1;
+ }
+};
+
+int main()
+{
+ {
+ std::istream is((testbuf<char>*)0);
+ std::istream::sentry sen(is, true);
+ assert(!(bool)sen);
+ assert(!is.good());
+ assert(is.gcount() == 0);
+ assert(sync_called == 0);
+ }
+ {
+ std::wistream is((testbuf<wchar_t>*)0);
+ std::wistream::sentry sen(is, true);
+ assert(!(bool)sen);
+ assert(!is.good());
+ assert(is.gcount() == 0);
+ assert(sync_called == 0);
+ }
+ {
+ testbuf<char> sb(" 123");
+ std::istream is(&sb);
+ std::istream::sentry sen(is, true);
+ assert((bool)sen);
+ assert(is.good());
+ assert(is.gcount() == 0);
+ assert(sync_called == 0);
+ assert(sb.gptr() == sb.eback());
+ }
+ {
+ testbuf<wchar_t> sb(L" 123");
+ std::wistream is(&sb);
+ std::wistream::sentry sen(is, true);
+ assert((bool)sen);
+ assert(is.good());
+ assert(is.gcount() == 0);
+ assert(sync_called == 0);
+ assert(sb.gptr() == sb.eback());
+ }
+ {
+ testbuf<char> sb(" 123");
+ std::istream is(&sb);
+ std::istream::sentry sen(is);
+ assert((bool)sen);
+ assert(is.good());
+ assert(sync_called == 0);
+ assert(sb.gptr() == sb.eback() + 3);
+ }
+ {
+ testbuf<wchar_t> sb(L" 123");
+ std::wistream is(&sb);
+ std::wistream::sentry sen(is);
+ assert((bool)sen);
+ assert(is.good());
+ assert(sync_called == 0);
+ assert(sb.gptr() == sb.eback() + 3);
+ }
+ {
+ testbuf<char> sb(" ");
+ std::istream is(&sb);
+ std::istream::sentry sen(is);
+ assert(!(bool)sen);
+ assert(is.fail());
+ assert(is.eof());
+ assert(sync_called == 0);
+ assert(sb.gptr() == sb.eback() + 6);
+ }
+ {
+ testbuf<char> sb(" ");
+ std::istream is(&sb);
+ std::istream::sentry sen(is, true);
+ assert((bool)sen);
+ assert(is.good());
+ assert(sync_called == 0);
+ assert(sb.gptr() == sb.eback());
+ }
+}
diff --git a/test/std/input.output/iostream.format/input.streams/istream/types.pass.cpp b/test/std/input.output/iostream.format/input.streams/istream/types.pass.cpp
new file mode 100644
index 000000000000..36cc2029db24
--- /dev/null
+++ b/test/std/input.output/iostream.format/input.streams/istream/types.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_istream
+// : virtual public basic_ios<charT,traits>
+// {
+// public:
+// // types (inherited from basic_ios (27.5.4)):
+// typedef charT char_type;
+// typedef traits traits_type;
+// typedef typename traits_type::int_type int_type;
+// typedef typename traits_type::pos_type pos_type;
+// typedef typename traits_type::off_type off_type;
+
+#include <istream>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_base_of<std::basic_ios<char>, std::basic_istream<char> >::value), "");
+ static_assert((std::is_same<std::basic_istream<char>::char_type, char>::value), "");
+ static_assert((std::is_same<std::basic_istream<char>::traits_type, std::char_traits<char> >::value), "");
+ static_assert((std::is_same<std::basic_istream<char>::int_type, std::char_traits<char>::int_type>::value), "");
+ static_assert((std::is_same<std::basic_istream<char>::pos_type, std::char_traits<char>::pos_type>::value), "");
+ static_assert((std::is_same<std::basic_istream<char>::off_type, std::char_traits<char>::off_type>::value), "");
+}
diff --git a/test/std/input.output/iostream.format/input.streams/version.pass.cpp b/test/std/input.output/iostream.format/input.streams/version.pass.cpp
new file mode 100644
index 000000000000..b03ef2aaa04e
--- /dev/null
+++ b/test/std/input.output/iostream.format/input.streams/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+#include <istream>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/input.output/iostream.format/nothing_to_do.pass.cpp b/test/std/input.output/iostream.format/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/input.output/iostream.format/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/input.output/iostream.format/output.streams/ostream.assign/member_swap.pass.cpp b/test/std/input.output/iostream.format/output.streams/ostream.assign/member_swap.pass.cpp
new file mode 100644
index 000000000000..8214d6c05b5b
--- /dev/null
+++ b/test/std/input.output/iostream.format/output.streams/ostream.assign/member_swap.pass.cpp
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ostream;
+
+// void swap(basic_ostream& rhs);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+ : public std::basic_streambuf<CharT>
+{
+ testbuf() {}
+};
+
+template <class CharT>
+struct test_ostream
+ : public std::basic_ostream<CharT>
+{
+ typedef std::basic_ostream<CharT> base;
+ test_ostream(testbuf<CharT>* sb) : base(sb) {}
+
+ void swap(test_ostream& s) {base::swap(s);}
+};
+
+int main()
+{
+ {
+ testbuf<char> sb1;
+ testbuf<char> sb2;
+ test_ostream<char> os1(&sb1);
+ test_ostream<char> os2(&sb2);
+ os1.swap(os2);
+ assert(os1.rdbuf() == &sb1);
+ assert(os1.tie() == 0);
+ assert(os1.fill() == ' ');
+ assert(os1.rdstate() == os1.goodbit);
+ assert(os1.exceptions() == os1.goodbit);
+ assert(os1.flags() == (os1.skipws | os1.dec));
+ assert(os1.precision() == 6);
+ assert(os1.getloc().name() == "C");
+ assert(os2.rdbuf() == &sb2);
+ assert(os2.tie() == 0);
+ assert(os2.fill() == ' ');
+ assert(os2.rdstate() == os2.goodbit);
+ assert(os2.exceptions() == os2.goodbit);
+ assert(os2.flags() == (os2.skipws | os2.dec));
+ assert(os2.precision() == 6);
+ assert(os2.getloc().name() == "C");
+ }
+ {
+ testbuf<wchar_t> sb1;
+ testbuf<wchar_t> sb2;
+ test_ostream<wchar_t> os1(&sb1);
+ test_ostream<wchar_t> os2(&sb2);
+ os1.swap(os2);
+ assert(os1.rdbuf() == &sb1);
+ assert(os1.tie() == 0);
+ assert(os1.fill() == ' ');
+ assert(os1.rdstate() == os1.goodbit);
+ assert(os1.exceptions() == os1.goodbit);
+ assert(os1.flags() == (os1.skipws | os1.dec));
+ assert(os1.precision() == 6);
+ assert(os1.getloc().name() == "C");
+ assert(os2.rdbuf() == &sb2);
+ assert(os2.tie() == 0);
+ assert(os2.fill() == ' ');
+ assert(os2.rdstate() == os2.goodbit);
+ assert(os2.exceptions() == os2.goodbit);
+ assert(os2.flags() == (os2.skipws | os2.dec));
+ assert(os2.precision() == 6);
+ assert(os2.getloc().name() == "C");
+ }
+}
diff --git a/test/std/input.output/iostream.format/output.streams/ostream.assign/move_assign.pass.cpp b/test/std/input.output/iostream.format/output.streams/ostream.assign/move_assign.pass.cpp
new file mode 100644
index 000000000000..40fe0795de53
--- /dev/null
+++ b/test/std/input.output/iostream.format/output.streams/ostream.assign/move_assign.pass.cpp
@@ -0,0 +1,92 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ostream;
+
+// basic_ostream& operator=(basic_ostream&& rhs);
+
+#include <ostream>
+#include <cassert>
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class CharT>
+struct testbuf
+ : public std::basic_streambuf<CharT>
+{
+ testbuf() {}
+};
+
+template <class CharT>
+struct test_ostream
+ : public std::basic_ostream<CharT>
+{
+ typedef std::basic_ostream<CharT> base;
+ test_ostream(testbuf<CharT>* sb) : base(sb) {}
+
+ test_ostream& operator=(test_ostream&& s)
+ {base::operator=(std::move(s)); return *this;}
+};
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ testbuf<char> sb1;
+ testbuf<char> sb2;
+ test_ostream<char> os1(&sb1);
+ test_ostream<char> os2(&sb2);
+ os2 = (std::move(os1));
+ assert(os1.rdbuf() == &sb1);
+ assert(os1.tie() == 0);
+ assert(os1.fill() == ' ');
+ assert(os1.rdstate() == os1.goodbit);
+ assert(os1.exceptions() == os1.goodbit);
+ assert(os1.flags() == (os1.skipws | os1.dec));
+ assert(os1.precision() == 6);
+ assert(os1.getloc().name() == "C");
+ assert(os2.rdbuf() == &sb2);
+ assert(os2.tie() == 0);
+ assert(os2.fill() == ' ');
+ assert(os2.rdstate() == os2.goodbit);
+ assert(os2.exceptions() == os2.goodbit);
+ assert(os2.flags() == (os2.skipws | os2.dec));
+ assert(os2.precision() == 6);
+ assert(os2.getloc().name() == "C");
+ }
+ {
+ testbuf<wchar_t> sb1;
+ testbuf<wchar_t> sb2;
+ test_ostream<wchar_t> os1(&sb1);
+ test_ostream<wchar_t> os2(&sb2);
+ os2 = (std::move(os1));
+ assert(os1.rdbuf() == &sb1);
+ assert(os1.tie() == 0);
+ assert(os1.fill() == ' ');
+ assert(os1.rdstate() == os1.goodbit);
+ assert(os1.exceptions() == os1.goodbit);
+ assert(os1.flags() == (os1.skipws | os1.dec));
+ assert(os1.precision() == 6);
+ assert(os1.getloc().name() == "C");
+ assert(os2.rdbuf() == &sb2);
+ assert(os2.tie() == 0);
+ assert(os2.fill() == ' ');
+ assert(os2.rdstate() == os2.goodbit);
+ assert(os2.exceptions() == os2.goodbit);
+ assert(os2.flags() == (os2.skipws | os2.dec));
+ assert(os2.precision() == 6);
+ assert(os2.getloc().name() == "C");
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/input.output/iostream.format/output.streams/ostream.cons/move.pass.cpp b/test/std/input.output/iostream.format/output.streams/ostream.cons/move.pass.cpp
new file mode 100644
index 000000000000..b3045b3232e6
--- /dev/null
+++ b/test/std/input.output/iostream.format/output.streams/ostream.cons/move.pass.cpp
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ostream;
+
+// basic_ostream(basic_ostream&& rhs);
+
+#include <ostream>
+#include <cassert>
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class CharT>
+struct testbuf
+ : public std::basic_streambuf<CharT>
+{
+ testbuf() {}
+};
+
+template <class CharT>
+struct test_ostream
+ : public std::basic_ostream<CharT>
+{
+ typedef std::basic_ostream<CharT> base;
+ test_ostream(testbuf<CharT>* sb) : base(sb) {}
+
+ test_ostream(test_ostream&& s)
+ : base(std::move(s)) {}
+};
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ testbuf<char> sb;
+ test_ostream<char> os1(&sb);
+ test_ostream<char> os(std::move(os1));
+ assert(os1.rdbuf() == &sb);
+ assert(os.rdbuf() == 0);
+ assert(os.tie() == 0);
+ assert(os.fill() == ' ');
+ assert(os.rdstate() == os.goodbit);
+ assert(os.exceptions() == os.goodbit);
+ assert(os.flags() == (os.skipws | os.dec));
+ assert(os.precision() == 6);
+ assert(os.getloc().name() == "C");
+ }
+ {
+ testbuf<wchar_t> sb;
+ test_ostream<wchar_t> os1(&sb);
+ test_ostream<wchar_t> os(std::move(os1));
+ assert(os1.rdbuf() == &sb);
+ assert(os.rdbuf() == 0);
+ assert(os.tie() == 0);
+ assert(os.fill() == L' ');
+ assert(os.rdstate() == os.goodbit);
+ assert(os.exceptions() == os.goodbit);
+ assert(os.flags() == (os.skipws | os.dec));
+ assert(os.precision() == 6);
+ assert(os.getloc().name() == "C");
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/input.output/iostream.format/output.streams/ostream.cons/streambuf.pass.cpp b/test/std/input.output/iostream.format/output.streams/ostream.cons/streambuf.pass.cpp
new file mode 100644
index 000000000000..7929e1845ec6
--- /dev/null
+++ b/test/std/input.output/iostream.format/output.streams/ostream.cons/streambuf.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ostream;
+
+// explicit basic_ostream(basic_streambuf<charT,traits>* sb);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+ : public std::basic_streambuf<CharT>
+{
+ testbuf() {}
+};
+
+int main()
+{
+ {
+ testbuf<char> sb;
+ std::basic_ostream<char> os(&sb);
+ assert(os.rdbuf() == &sb);
+ assert(os.tie() == 0);
+ assert(os.fill() == ' ');
+ assert(os.rdstate() == os.goodbit);
+ assert(os.exceptions() == os.goodbit);
+ assert(os.flags() == (os.skipws | os.dec));
+ assert(os.precision() == 6);
+ assert(os.getloc().name() == "C");
+ }
+ {
+ testbuf<wchar_t> sb;
+ std::basic_ostream<wchar_t> os(&sb);
+ assert(os.rdbuf() == &sb);
+ assert(os.tie() == 0);
+ assert(os.fill() == L' ');
+ assert(os.rdstate() == os.goodbit);
+ assert(os.exceptions() == os.goodbit);
+ assert(os.flags() == (os.skipws | os.dec));
+ assert(os.precision() == 6);
+ assert(os.getloc().name() == "C");
+ }
+}
diff --git a/test/std/input.output/iostream.format/output.streams/ostream.formatted/nothing_to_do.pass.cpp b/test/std/input.output/iostream.format/output.streams/ostream.formatted/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/input.output/iostream.format/output.streams/ostream.formatted/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.formatted.reqmts/tested_elsewhere.pass.cpp b/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.formatted.reqmts/tested_elsewhere.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.formatted.reqmts/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/bool.pass.cpp b/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/bool.pass.cpp
new file mode 100644
index 000000000000..13035b74436e
--- /dev/null
+++ b/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/bool.pass.cpp
@@ -0,0 +1,91 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ostream;
+
+// operator<<(bool val);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_streambuf<CharT> base;
+ std::basic_string<CharT> str_;
+public:
+ testbuf()
+ {
+ }
+
+ std::basic_string<CharT> str() const
+ {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+ virtual typename base::int_type
+ overflow(typename base::int_type __c = base::traits_type::eof())
+ {
+ if (__c != base::traits_type::eof())
+ {
+ int n = str_.size();
+ str_.push_back(__c);
+ str_.resize(str_.capacity());
+ base::setp(const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data() + str_.size()));
+ base::pbump(n+1);
+ }
+ return __c;
+ }
+};
+
+int main()
+{
+ {
+ std::ostream os((std::streambuf*)0);
+ bool b = false;
+ os << b;
+ assert(os.bad());
+ assert(os.fail());
+ }
+ {
+ testbuf<char> sb;
+ std::ostream os(&sb);
+ bool b = false;
+ os << b;
+ assert(sb.str() == "0");
+ }
+ {
+ testbuf<char> sb;
+ std::ostream os(&sb);
+ bool b = true;
+ os << b;
+ assert(sb.str() == "1");
+ }
+ {
+ testbuf<char> sb;
+ std::ostream os(&sb);
+ boolalpha(os);
+ bool b = true;
+ os << b;
+ assert(sb.str() == "true");
+ }
+ {
+ testbuf<char> sb;
+ std::ostream os(&sb);
+ boolalpha(os);
+ bool b = false;
+ os << b;
+ assert(sb.str() == "false");
+ }
+}
diff --git a/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/double.pass.cpp b/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/double.pass.cpp
new file mode 100644
index 000000000000..38ee37ff1892
--- /dev/null
+++ b/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/double.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ostream;
+
+// operator<<(double val);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_streambuf<CharT> base;
+ std::basic_string<CharT> str_;
+public:
+ testbuf()
+ {
+ }
+
+ std::basic_string<CharT> str() const
+ {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+ virtual typename base::int_type
+ overflow(typename base::int_type __c = base::traits_type::eof())
+ {
+ if (__c != base::traits_type::eof())
+ {
+ int n = str_.size();
+ str_.push_back(__c);
+ str_.resize(str_.capacity());
+ base::setp(const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data() + str_.size()));
+ base::pbump(n+1);
+ }
+ return __c;
+ }
+};
+
+int main()
+{
+ {
+ std::ostream os((std::streambuf*)0);
+ double n = 0;
+ os << n;
+ assert(os.bad());
+ assert(os.fail());
+ }
+ {
+ testbuf<char> sb;
+ std::ostream os(&sb);
+ double n = 0;
+ os << n;
+ assert(sb.str() == "0");
+ }
+ {
+ testbuf<char> sb;
+ std::ostream os(&sb);
+ double n = -10;
+ os << n;
+ assert(sb.str() == "-10");
+ }
+ {
+ testbuf<char> sb;
+ std::ostream os(&sb);
+ hex(os);
+ double n = -10.5;
+ os << n;
+ assert(sb.str() == "-10.5");
+ }
+}
diff --git a/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/float.pass.cpp b/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/float.pass.cpp
new file mode 100644
index 000000000000..1da0ac685fcb
--- /dev/null
+++ b/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/float.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ostream;
+
+// operator<<(float val);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_streambuf<CharT> base;
+ std::basic_string<CharT> str_;
+public:
+ testbuf()
+ {
+ }
+
+ std::basic_string<CharT> str() const
+ {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+ virtual typename base::int_type
+ overflow(typename base::int_type __c = base::traits_type::eof())
+ {
+ if (__c != base::traits_type::eof())
+ {
+ int n = str_.size();
+ str_.push_back(__c);
+ str_.resize(str_.capacity());
+ base::setp(const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data() + str_.size()));
+ base::pbump(n+1);
+ }
+ return __c;
+ }
+};
+
+int main()
+{
+ {
+ std::ostream os((std::streambuf*)0);
+ float n = 0;
+ os << n;
+ assert(os.bad());
+ assert(os.fail());
+ }
+ {
+ testbuf<char> sb;
+ std::ostream os(&sb);
+ float n = 0;
+ os << n;
+ assert(sb.str() == "0");
+ }
+ {
+ testbuf<char> sb;
+ std::ostream os(&sb);
+ float n = -10;
+ os << n;
+ assert(sb.str() == "-10");
+ }
+ {
+ testbuf<char> sb;
+ std::ostream os(&sb);
+ hex(os);
+ float n = -10.5;
+ os << n;
+ assert(sb.str() == "-10.5");
+ }
+}
diff --git a/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/int.pass.cpp b/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/int.pass.cpp
new file mode 100644
index 000000000000..efcb08a3da10
--- /dev/null
+++ b/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/int.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ostream;
+
+// operator<<(int val);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_streambuf<CharT> base;
+ std::basic_string<CharT> str_;
+public:
+ testbuf()
+ {
+ }
+
+ std::basic_string<CharT> str() const
+ {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+ virtual typename base::int_type
+ overflow(typename base::int_type __c = base::traits_type::eof())
+ {
+ if (__c != base::traits_type::eof())
+ {
+ int n = str_.size();
+ str_.push_back(__c);
+ str_.resize(str_.capacity());
+ base::setp(const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data() + str_.size()));
+ base::pbump(n+1);
+ }
+ return __c;
+ }
+};
+
+int main()
+{
+ {
+ std::ostream os((std::streambuf*)0);
+ int n = 0;
+ os << n;
+ assert(os.bad());
+ assert(os.fail());
+ }
+ {
+ testbuf<char> sb;
+ std::ostream os(&sb);
+ int n = 0;
+ os << n;
+ assert(sb.str() == "0");
+ }
+ {
+ testbuf<char> sb;
+ std::ostream os(&sb);
+ int n = -10;
+ os << n;
+ assert(sb.str() == "-10");
+ }
+ {
+ testbuf<char> sb;
+ std::ostream os(&sb);
+ hex(os);
+ int n = -10;
+ os << n;
+ assert(sb.str() == "fffffff6");
+ }
+}
diff --git a/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/long.pass.cpp b/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/long.pass.cpp
new file mode 100644
index 000000000000..6d617a453ebc
--- /dev/null
+++ b/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/long.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ostream;
+
+// operator<<(long val);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_streambuf<CharT> base;
+ std::basic_string<CharT> str_;
+public:
+ testbuf()
+ {
+ }
+
+ std::basic_string<CharT> str() const
+ {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+ virtual typename base::int_type
+ overflow(typename base::int_type __c = base::traits_type::eof())
+ {
+ if (__c != base::traits_type::eof())
+ {
+ int n = str_.size();
+ str_.push_back(__c);
+ str_.resize(str_.capacity());
+ base::setp(const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data() + str_.size()));
+ base::pbump(n+1);
+ }
+ return __c;
+ }
+};
+
+int main()
+{
+ {
+ std::ostream os((std::streambuf*)0);
+ long n = 0;
+ os << n;
+ assert(os.bad());
+ assert(os.fail());
+ }
+ {
+ testbuf<char> sb;
+ std::ostream os(&sb);
+ long n = 0;
+ os << n;
+ assert(sb.str() == "0");
+ }
+ {
+ testbuf<char> sb;
+ std::ostream os(&sb);
+ long n = -10;
+ os << n;
+ assert(sb.str() == "-10");
+ }
+ {
+ testbuf<char> sb;
+ std::ostream os(&sb);
+ hex(os);
+ long n = 0xfffffff6;
+ os << n;
+ assert(sb.str() == "fffffff6");
+ }
+}
diff --git a/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/long_double.pass.cpp b/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/long_double.pass.cpp
new file mode 100644
index 000000000000..20b20b2231a2
--- /dev/null
+++ b/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/long_double.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ostream;
+
+// operator<<(long double val);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_streambuf<CharT> base;
+ std::basic_string<CharT> str_;
+public:
+ testbuf()
+ {
+ }
+
+ std::basic_string<CharT> str() const
+ {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+ virtual typename base::int_type
+ overflow(typename base::int_type __c = base::traits_type::eof())
+ {
+ if (__c != base::traits_type::eof())
+ {
+ int n = str_.size();
+ str_.push_back(__c);
+ str_.resize(str_.capacity());
+ base::setp(const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data() + str_.size()));
+ base::pbump(n+1);
+ }
+ return __c;
+ }
+};
+
+int main()
+{
+ {
+ std::ostream os((std::streambuf*)0);
+ long double n = 0;
+ os << n;
+ assert(os.bad());
+ assert(os.fail());
+ }
+ {
+ testbuf<char> sb;
+ std::ostream os(&sb);
+ long double n = 0;
+ os << n;
+ assert(sb.str() == "0");
+ }
+ {
+ testbuf<char> sb;
+ std::ostream os(&sb);
+ long double n = -10;
+ os << n;
+ assert(sb.str() == "-10");
+ }
+ {
+ testbuf<char> sb;
+ std::ostream os(&sb);
+ hex(os);
+ long double n = -10.5;
+ os << n;
+ assert(sb.str() == "-10.5");
+ }
+}
diff --git a/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/long_long.pass.cpp b/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/long_long.pass.cpp
new file mode 100644
index 000000000000..dc77eb72192d
--- /dev/null
+++ b/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/long_long.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ostream;
+
+// operator<<(long long val);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_streambuf<CharT> base;
+ std::basic_string<CharT> str_;
+public:
+ testbuf()
+ {
+ }
+
+ std::basic_string<CharT> str() const
+ {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+ virtual typename base::int_type
+ overflow(typename base::int_type __c = base::traits_type::eof())
+ {
+ if (__c != base::traits_type::eof())
+ {
+ int n = str_.size();
+ str_.push_back(__c);
+ str_.resize(str_.capacity());
+ base::setp(const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data() + str_.size()));
+ base::pbump(n+1);
+ }
+ return __c;
+ }
+};
+
+int main()
+{
+ {
+ std::ostream os((std::streambuf*)0);
+ long long n = 0;
+ os << n;
+ assert(os.bad());
+ assert(os.fail());
+ }
+ {
+ testbuf<char> sb;
+ std::ostream os(&sb);
+ long long n = 0;
+ os << n;
+ assert(sb.str() == "0");
+ }
+ {
+ testbuf<char> sb;
+ std::ostream os(&sb);
+ long long n = -10;
+ os << n;
+ assert(sb.str() == "-10");
+ }
+ {
+ testbuf<char> sb;
+ std::ostream os(&sb);
+ hex(os);
+ long long n = -10;
+ os << n;
+ assert(sb.str() == "fffffffffffffff6");
+ }
+}
diff --git a/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/minus1.pass b/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/minus1.pass
new file mode 100644
index 000000000000..27b8cfd85c96
--- /dev/null
+++ b/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/minus1.pass
@@ -0,0 +1,84 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ostream;
+
+// operator<<( int16_t val);
+// operator<<(uint16_t val);
+// operator<<( int32_t val);
+// operator<<(uint32_t val);
+// operator<<( int64_t val);
+// operator<<(uint64_t val);
+
+// Testing to make sure that the max length values are correctly inserted
+
+#include <iostream>
+#include <sstream>
+#include <cassert>
+
+template <typename T>
+void test_octal(const char *expected)
+{
+ std::stringstream ss;
+ ss << std::oct << static_cast<T>(-1);
+
+ assert(ss.str() == expected);
+}
+
+template <typename T>
+void test_dec(const char *expected)
+{
+ std::stringstream ss;
+ ss << std::dec << static_cast<T>(-1);
+
+// std::cout << ss.str() << " " << expected << std::endl;
+ assert(ss.str() == expected);
+}
+
+template <typename T>
+void test_hex(const char *expected)
+{
+ std::stringstream ss;
+ ss << std::hex << static_cast<T>(-1);
+
+ std::string str = ss.str();
+ for (size_t i = 0; i < str.size(); ++i )
+ str[i] = std::toupper(str[i]);
+
+ assert(str == expected);
+}
+
+int main(int argc, char* argv[])
+{
+ test_octal<uint16_t>( "177777");
+ test_octal< int16_t>( "177777");
+ test_octal<uint32_t>( "37777777777");
+ test_octal< int32_t>( "37777777777");
+ test_octal<uint64_t>("1777777777777777777777");
+ test_octal< int64_t>("1777777777777777777777");
+
+ test_dec<uint16_t>( "65535");
+ test_dec< int16_t>( "-1");
+ test_dec<uint32_t>( "4294967295");
+ test_dec< int32_t>( "-1");
+ test_dec<uint64_t>("18446744073709551615");
+ test_dec< int64_t>( "-1");
+
+ test_hex<uint16_t>( "FFFF");
+ test_hex< int16_t>( "FFFF");
+ test_hex<uint32_t>( "FFFFFFFF");
+ test_hex< int32_t>( "FFFFFFFF");
+ test_hex<uint64_t>("FFFFFFFFFFFFFFFF");
+ test_hex< int64_t>("FFFFFFFFFFFFFFFF");
+
+ return 0;
+}
diff --git a/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/pointer.pass.cpp b/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/pointer.pass.cpp
new file mode 100644
index 000000000000..b74d99a34ec9
--- /dev/null
+++ b/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/pointer.pass.cpp
@@ -0,0 +1,91 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ostream;
+
+// operator<<(const void* val);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_streambuf<CharT> base;
+ std::basic_string<CharT> str_;
+public:
+ testbuf()
+ {
+ }
+
+ std::basic_string<CharT> str() const
+ {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+ virtual typename base::int_type
+ overflow(typename base::int_type __c = base::traits_type::eof())
+ {
+ if (__c != base::traits_type::eof())
+ {
+ int n = str_.size();
+ str_.push_back(__c);
+ str_.resize(str_.capacity());
+ base::setp(const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data() + str_.size()));
+ base::pbump(n+1);
+ }
+ return __c;
+ }
+};
+
+int main()
+{
+ {
+ std::ostream os((std::streambuf*)0);
+ const void* n = 0;
+ os << n;
+ assert(os.bad());
+ assert(os.fail());
+ }
+ {
+ testbuf<char> sb1;
+ std::ostream os1(&sb1);
+ int n1;
+ os1 << &n1;
+ assert(os1.good());
+ std::string s1(sb1.str());
+
+ testbuf<char> sb2;
+ std::ostream os2(&sb2);
+ int n2;
+ os2 << &n2;
+ assert(os2.good());
+ std::string s2(sb2.str());
+
+ // %p is implementation defined. Instead of validating the
+ // output, at least ensure that it does not generate an empty
+ // string. Also make sure that given two distinct addresses, the
+ // output of %p is different.
+ assert(!s1.empty());
+ assert(!s2.empty());
+ assert(s1 != s2);
+ }
+ {
+ testbuf<char> sb;
+ std::ostream os(&sb);
+ const void* n = &sb;
+ os << n;
+ assert(os.good());
+ }
+}
diff --git a/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/short.pass.cpp b/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/short.pass.cpp
new file mode 100644
index 000000000000..ebd349bcbb79
--- /dev/null
+++ b/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/short.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ostream;
+
+// operator<<(short val);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_streambuf<CharT> base;
+ std::basic_string<CharT> str_;
+public:
+ testbuf()
+ {
+ }
+
+ std::basic_string<CharT> str() const
+ {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+ virtual typename base::int_type
+ overflow(typename base::int_type __c = base::traits_type::eof())
+ {
+ if (__c != base::traits_type::eof())
+ {
+ int n = str_.size();
+ str_.push_back(__c);
+ str_.resize(str_.capacity());
+ base::setp(const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data() + str_.size()));
+ base::pbump(n+1);
+ }
+ return __c;
+ }
+};
+
+int main()
+{
+ {
+ std::ostream os((std::streambuf*)0);
+ short n = 0;
+ os << n;
+ assert(os.bad());
+ assert(os.fail());
+ }
+ {
+ testbuf<char> sb;
+ std::ostream os(&sb);
+ short n = 0;
+ os << n;
+ assert(sb.str() == "0");
+ }
+ {
+ testbuf<char> sb;
+ std::ostream os(&sb);
+ short n = -10;
+ os << n;
+ assert(sb.str() == "-10");
+ }
+ {
+ testbuf<char> sb;
+ std::ostream os(&sb);
+ hex(os);
+ short n = -10;
+ os << n;
+ assert(sb.str() == "fff6");
+ }
+}
diff --git a/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/unsigned_int.pass.cpp b/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/unsigned_int.pass.cpp
new file mode 100644
index 000000000000..ac60fa9c1979
--- /dev/null
+++ b/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/unsigned_int.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ostream;
+
+// operator<<(unsigned int val);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_streambuf<CharT> base;
+ std::basic_string<CharT> str_;
+public:
+ testbuf()
+ {
+ }
+
+ std::basic_string<CharT> str() const
+ {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+ virtual typename base::int_type
+ overflow(typename base::int_type __c = base::traits_type::eof())
+ {
+ if (__c != base::traits_type::eof())
+ {
+ int n = str_.size();
+ str_.push_back(__c);
+ str_.resize(str_.capacity());
+ base::setp(const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data() + str_.size()));
+ base::pbump(n+1);
+ }
+ return __c;
+ }
+};
+
+int main()
+{
+ {
+ std::ostream os((std::streambuf*)0);
+ unsigned int n = 0;
+ os << n;
+ assert(os.bad());
+ assert(os.fail());
+ }
+ {
+ testbuf<char> sb;
+ std::ostream os(&sb);
+ unsigned int n = 0;
+ os << n;
+ assert(sb.str() == "0");
+ }
+ {
+ testbuf<char> sb;
+ std::ostream os(&sb);
+ unsigned int n = 10;
+ os << n;
+ assert(sb.str() == "10");
+ }
+ {
+ testbuf<char> sb;
+ std::ostream os(&sb);
+ hex(os);
+ unsigned int n = 0xFFF6;
+ os << n;
+ assert(sb.str() == "fff6");
+ }
+}
diff --git a/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/unsigned_long.pass.cpp b/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/unsigned_long.pass.cpp
new file mode 100644
index 000000000000..b5a38017dce4
--- /dev/null
+++ b/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/unsigned_long.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ostream;
+
+// operator<<(unsigned long val);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_streambuf<CharT> base;
+ std::basic_string<CharT> str_;
+public:
+ testbuf()
+ {
+ }
+
+ std::basic_string<CharT> str() const
+ {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+ virtual typename base::int_type
+ overflow(typename base::int_type __c = base::traits_type::eof())
+ {
+ if (__c != base::traits_type::eof())
+ {
+ int n = str_.size();
+ str_.push_back(__c);
+ str_.resize(str_.capacity());
+ base::setp(const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data() + str_.size()));
+ base::pbump(n+1);
+ }
+ return __c;
+ }
+};
+
+int main()
+{
+ {
+ std::ostream os((std::streambuf*)0);
+ unsigned long n = 0;
+ os << n;
+ assert(os.bad());
+ assert(os.fail());
+ }
+ {
+ testbuf<char> sb;
+ std::ostream os(&sb);
+ unsigned long n = 0;
+ os << n;
+ assert(sb.str() == "0");
+ }
+ {
+ testbuf<char> sb;
+ std::ostream os(&sb);
+ unsigned long n = 10;
+ os << n;
+ assert(sb.str() == "10");
+ }
+ {
+ testbuf<char> sb;
+ std::ostream os(&sb);
+ hex(os);
+ unsigned long n = 0xfffffff6;
+ os << n;
+ assert(sb.str() == "fffffff6");
+ }
+}
diff --git a/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/unsigned_long_long.pass.cpp b/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/unsigned_long_long.pass.cpp
new file mode 100644
index 000000000000..25dc4d834975
--- /dev/null
+++ b/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/unsigned_long_long.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ostream;
+
+// operator<<(unsigned long long val);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_streambuf<CharT> base;
+ std::basic_string<CharT> str_;
+public:
+ testbuf()
+ {
+ }
+
+ std::basic_string<CharT> str() const
+ {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+ virtual typename base::int_type
+ overflow(typename base::int_type __c = base::traits_type::eof())
+ {
+ if (__c != base::traits_type::eof())
+ {
+ int n = str_.size();
+ str_.push_back(__c);
+ str_.resize(str_.capacity());
+ base::setp(const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data() + str_.size()));
+ base::pbump(n+1);
+ }
+ return __c;
+ }
+};
+
+int main()
+{
+ {
+ std::ostream os((std::streambuf*)0);
+ unsigned long long n = 0;
+ os << n;
+ assert(os.bad());
+ assert(os.fail());
+ }
+ {
+ testbuf<char> sb;
+ std::ostream os(&sb);
+ unsigned long long n = 0;
+ os << n;
+ assert(sb.str() == "0");
+ }
+ {
+ testbuf<char> sb;
+ std::ostream os(&sb);
+ unsigned long long n = 10;
+ os << n;
+ assert(sb.str() == "10");
+ }
+ {
+ testbuf<char> sb;
+ std::ostream os(&sb);
+ hex(os);
+ unsigned long long n = -10;
+ os << n;
+ assert(sb.str() == "fffffffffffffff6");
+ }
+}
diff --git a/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/unsigned_short.pass.cpp b/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/unsigned_short.pass.cpp
new file mode 100644
index 000000000000..7c28a8ee79c4
--- /dev/null
+++ b/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/unsigned_short.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ostream;
+
+// operator<<(unsigned short val);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_streambuf<CharT> base;
+ std::basic_string<CharT> str_;
+public:
+ testbuf()
+ {
+ }
+
+ std::basic_string<CharT> str() const
+ {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+ virtual typename base::int_type
+ overflow(typename base::int_type __c = base::traits_type::eof())
+ {
+ if (__c != base::traits_type::eof())
+ {
+ int n = str_.size();
+ str_.push_back(__c);
+ str_.resize(str_.capacity());
+ base::setp(const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data() + str_.size()));
+ base::pbump(n+1);
+ }
+ return __c;
+ }
+};
+
+int main()
+{
+ {
+ std::ostream os((std::streambuf*)0);
+ unsigned short n = 0;
+ os << n;
+ assert(os.bad());
+ assert(os.fail());
+ }
+ {
+ testbuf<char> sb;
+ std::ostream os(&sb);
+ unsigned short n = 0;
+ os << n;
+ assert(sb.str() == "0");
+ }
+ {
+ testbuf<char> sb;
+ std::ostream os(&sb);
+ unsigned short n = 10;
+ os << n;
+ assert(sb.str() == "10");
+ }
+ {
+ testbuf<char> sb;
+ std::ostream os(&sb);
+ hex(os);
+ unsigned short n = 0xFFF6;
+ os << n;
+ assert(sb.str() == "fff6");
+ }
+}
diff --git a/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/CharT.pass.cpp b/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/CharT.pass.cpp
new file mode 100644
index 000000000000..f74e2a4abd9e
--- /dev/null
+++ b/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/CharT.pass.cpp
@@ -0,0 +1,88 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ostream;
+
+// template<class charT, class traits>
+// basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>& out, charT c);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_streambuf<CharT> base;
+ std::basic_string<CharT> str_;
+public:
+ testbuf()
+ {
+ }
+
+ std::basic_string<CharT> str() const
+ {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+ virtual typename base::int_type
+ overflow(typename base::int_type __c = base::traits_type::eof())
+ {
+ if (__c != base::traits_type::eof())
+ {
+ int n = str_.size();
+ str_.push_back(__c);
+ str_.resize(str_.capacity());
+ base::setp(const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data() + str_.size()));
+ base::pbump(n+1);
+ }
+ return __c;
+ }
+};
+
+int main()
+{
+ {
+ std::wostream os((std::wstreambuf*)0);
+ wchar_t c = L'a';
+ os << c;
+ assert(os.bad());
+ assert(os.fail());
+ }
+ {
+ testbuf<wchar_t> sb;
+ std::wostream os(&sb);
+ wchar_t c = L'a';
+ os << c;
+ assert(sb.str() == L"a");
+ }
+ {
+ testbuf<wchar_t> sb;
+ std::wostream os(&sb);
+ os.width(5);
+ wchar_t c = L'a';
+ os << c;
+ assert(sb.str() == L" a");
+ assert(os.width() == 0);
+ }
+ {
+ testbuf<wchar_t> sb;
+ std::wostream os(&sb);
+ os.width(5);
+ left(os);
+ wchar_t c = L'a';
+ os << c;
+ assert(sb.str() == L"a ");
+ assert(os.width() == 0);
+ }
+}
diff --git a/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/CharT_pointer.pass.cpp b/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/CharT_pointer.pass.cpp
new file mode 100644
index 000000000000..2b78fa75aa30
--- /dev/null
+++ b/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/CharT_pointer.pass.cpp
@@ -0,0 +1,88 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ostream;
+
+// template<class charT, class traits>
+// basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>& out, const charT* s);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_streambuf<CharT> base;
+ std::basic_string<CharT> str_;
+public:
+ testbuf()
+ {
+ }
+
+ std::basic_string<CharT> str() const
+ {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+ virtual typename base::int_type
+ overflow(typename base::int_type __c = base::traits_type::eof())
+ {
+ if (__c != base::traits_type::eof())
+ {
+ int n = str_.size();
+ str_.push_back(__c);
+ str_.resize(str_.capacity());
+ base::setp(const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data() + str_.size()));
+ base::pbump(n+1);
+ }
+ return __c;
+ }
+};
+
+int main()
+{
+ {
+ std::wostream os((std::wstreambuf*)0);
+ const wchar_t* c = L"123";
+ os << c;
+ assert(os.bad());
+ assert(os.fail());
+ }
+ {
+ testbuf<wchar_t> sb;
+ std::wostream os(&sb);
+ const wchar_t* c = L"123";
+ os << c;
+ assert(sb.str() == L"123");
+ }
+ {
+ testbuf<wchar_t> sb;
+ std::wostream os(&sb);
+ os.width(5);
+ const wchar_t* c = L"123";
+ os << c;
+ assert(sb.str() == L" 123");
+ assert(os.width() == 0);
+ }
+ {
+ testbuf<wchar_t> sb;
+ std::wostream os(&sb);
+ os.width(5);
+ left(os);
+ const wchar_t* c = L"123";
+ os << c;
+ assert(sb.str() == L"123 ");
+ assert(os.width() == 0);
+ }
+}
diff --git a/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/char.pass.cpp b/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/char.pass.cpp
new file mode 100644
index 000000000000..253b524308c0
--- /dev/null
+++ b/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/char.pass.cpp
@@ -0,0 +1,88 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ostream;
+
+// template<class char, class traits>
+// basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>& out, char c);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_streambuf<CharT> base;
+ std::basic_string<CharT> str_;
+public:
+ testbuf()
+ {
+ }
+
+ std::basic_string<CharT> str() const
+ {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+ virtual typename base::int_type
+ overflow(typename base::int_type __c = base::traits_type::eof())
+ {
+ if (__c != base::traits_type::eof())
+ {
+ int n = str_.size();
+ str_.push_back(__c);
+ str_.resize(str_.capacity());
+ base::setp(const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data() + str_.size()));
+ base::pbump(n+1);
+ }
+ return __c;
+ }
+};
+
+int main()
+{
+ {
+ std::ostream os((std::streambuf*)0);
+ char c = 'a';
+ os << c;
+ assert(os.bad());
+ assert(os.fail());
+ }
+ {
+ testbuf<char> sb;
+ std::ostream os(&sb);
+ char c = 'a';
+ os << c;
+ assert(sb.str() == "a");
+ }
+ {
+ testbuf<char> sb;
+ std::ostream os(&sb);
+ os.width(5);
+ char c = 'a';
+ os << c;
+ assert(sb.str() == " a");
+ assert(os.width() == 0);
+ }
+ {
+ testbuf<char> sb;
+ std::ostream os(&sb);
+ os.width(5);
+ left(os);
+ char c = 'a';
+ os << c;
+ assert(sb.str() == "a ");
+ assert(os.width() == 0);
+ }
+}
diff --git a/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/char_pointer.pass.cpp b/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/char_pointer.pass.cpp
new file mode 100644
index 000000000000..c544554ae0e2
--- /dev/null
+++ b/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/char_pointer.pass.cpp
@@ -0,0 +1,88 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ostream;
+
+// template<class traits>
+// basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>& out, const char* s);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_streambuf<CharT> base;
+ std::basic_string<CharT> str_;
+public:
+ testbuf()
+ {
+ }
+
+ std::basic_string<CharT> str() const
+ {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+ virtual typename base::int_type
+ overflow(typename base::int_type __c = base::traits_type::eof())
+ {
+ if (__c != base::traits_type::eof())
+ {
+ int n = str_.size();
+ str_.push_back(__c);
+ str_.resize(str_.capacity());
+ base::setp(const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data() + str_.size()));
+ base::pbump(n+1);
+ }
+ return __c;
+ }
+};
+
+int main()
+{
+ {
+ std::ostream os((std::streambuf*)0);
+ const char* c = "123";
+ os << c;
+ assert(os.bad());
+ assert(os.fail());
+ }
+ {
+ testbuf<char> sb;
+ std::ostream os(&sb);
+ const char* c = "123";
+ os << c;
+ assert(sb.str() == "123");
+ }
+ {
+ testbuf<char> sb;
+ std::ostream os(&sb);
+ os.width(5);
+ const char* c = "123";
+ os << c;
+ assert(sb.str() == " 123");
+ assert(os.width() == 0);
+ }
+ {
+ testbuf<char> sb;
+ std::ostream os(&sb);
+ os.width(5);
+ left(os);
+ const char* c = "123";
+ os << c;
+ assert(sb.str() == "123 ");
+ assert(os.width() == 0);
+ }
+}
diff --git a/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/char_to_wide.pass.cpp b/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/char_to_wide.pass.cpp
new file mode 100644
index 000000000000..6449a13a6426
--- /dev/null
+++ b/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/char_to_wide.pass.cpp
@@ -0,0 +1,88 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ostream;
+
+// template<class charT, class traits>
+// basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>& out, char c);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_streambuf<CharT> base;
+ std::basic_string<CharT> str_;
+public:
+ testbuf()
+ {
+ }
+
+ std::basic_string<CharT> str() const
+ {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+ virtual typename base::int_type
+ overflow(typename base::int_type __c = base::traits_type::eof())
+ {
+ if (__c != base::traits_type::eof())
+ {
+ int n = str_.size();
+ str_.push_back(__c);
+ str_.resize(str_.capacity());
+ base::setp(const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data() + str_.size()));
+ base::pbump(n+1);
+ }
+ return __c;
+ }
+};
+
+int main()
+{
+ {
+ std::wostream os((std::wstreambuf*)0);
+ char c = 'a';
+ os << c;
+ assert(os.bad());
+ assert(os.fail());
+ }
+ {
+ testbuf<wchar_t> sb;
+ std::wostream os(&sb);
+ char c = 'a';
+ os << c;
+ assert(sb.str() == L"a");
+ }
+ {
+ testbuf<wchar_t> sb;
+ std::wostream os(&sb);
+ os.width(5);
+ char c = 'a';
+ os << c;
+ assert(sb.str() == L" a");
+ assert(os.width() == 0);
+ }
+ {
+ testbuf<wchar_t> sb;
+ std::wostream os(&sb);
+ os.width(5);
+ left(os);
+ char c = 'a';
+ os << c;
+ assert(sb.str() == L"a ");
+ assert(os.width() == 0);
+ }
+}
diff --git a/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/char_to_wide_pointer.pass.cpp b/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/char_to_wide_pointer.pass.cpp
new file mode 100644
index 000000000000..e679a5c48ba4
--- /dev/null
+++ b/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/char_to_wide_pointer.pass.cpp
@@ -0,0 +1,88 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ostream;
+
+// template<class charT, class traits>
+// basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>& out, const char* s);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_streambuf<CharT> base;
+ std::basic_string<CharT> str_;
+public:
+ testbuf()
+ {
+ }
+
+ std::basic_string<CharT> str() const
+ {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+ virtual typename base::int_type
+ overflow(typename base::int_type __c = base::traits_type::eof())
+ {
+ if (__c != base::traits_type::eof())
+ {
+ int n = str_.size();
+ str_.push_back(__c);
+ str_.resize(str_.capacity());
+ base::setp(const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data() + str_.size()));
+ base::pbump(n+1);
+ }
+ return __c;
+ }
+};
+
+int main()
+{
+ {
+ std::wostream os((std::wstreambuf*)0);
+ const char* c = "123";
+ os << c;
+ assert(os.bad());
+ assert(os.fail());
+ }
+ {
+ testbuf<wchar_t> sb;
+ std::wostream os(&sb);
+ const char* c = "123";
+ os << c;
+ assert(sb.str() == L"123");
+ }
+ {
+ testbuf<wchar_t> sb;
+ std::wostream os(&sb);
+ os.width(5);
+ const char* c = "123";
+ os << c;
+ assert(sb.str() == L" 123");
+ assert(os.width() == 0);
+ }
+ {
+ testbuf<wchar_t> sb;
+ std::wostream os(&sb);
+ os.width(5);
+ left(os);
+ const char* c = "123";
+ os << c;
+ assert(sb.str() == L"123 ");
+ assert(os.width() == 0);
+ }
+}
diff --git a/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/signed_char.pass.cpp b/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/signed_char.pass.cpp
new file mode 100644
index 000000000000..dc0ee4266c77
--- /dev/null
+++ b/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/signed_char.pass.cpp
@@ -0,0 +1,88 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ostream;
+
+// template<class char, class traits>
+// basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>& out, signed char c);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_streambuf<CharT> base;
+ std::basic_string<CharT> str_;
+public:
+ testbuf()
+ {
+ }
+
+ std::basic_string<CharT> str() const
+ {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+ virtual typename base::int_type
+ overflow(typename base::int_type __c = base::traits_type::eof())
+ {
+ if (__c != base::traits_type::eof())
+ {
+ int n = str_.size();
+ str_.push_back(__c);
+ str_.resize(str_.capacity());
+ base::setp(const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data() + str_.size()));
+ base::pbump(n+1);
+ }
+ return __c;
+ }
+};
+
+int main()
+{
+ {
+ std::ostream os((std::streambuf*)0);
+ signed char c = 'a';
+ os << c;
+ assert(os.bad());
+ assert(os.fail());
+ }
+ {
+ testbuf<char> sb;
+ std::ostream os(&sb);
+ signed char c = 'a';
+ os << c;
+ assert(sb.str() == "a");
+ }
+ {
+ testbuf<char> sb;
+ std::ostream os(&sb);
+ os.width(5);
+ signed char c = 'a';
+ os << c;
+ assert(sb.str() == " a");
+ assert(os.width() == 0);
+ }
+ {
+ testbuf<char> sb;
+ std::ostream os(&sb);
+ os.width(5);
+ left(os);
+ signed char c = 'a';
+ os << c;
+ assert(sb.str() == "a ");
+ assert(os.width() == 0);
+ }
+}
diff --git a/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/signed_char_pointer.pass.cpp b/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/signed_char_pointer.pass.cpp
new file mode 100644
index 000000000000..e465b94b6b93
--- /dev/null
+++ b/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/signed_char_pointer.pass.cpp
@@ -0,0 +1,88 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ostream;
+
+// template<class traits>
+// basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>& out, const signed char* s);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_streambuf<CharT> base;
+ std::basic_string<CharT> str_;
+public:
+ testbuf()
+ {
+ }
+
+ std::basic_string<CharT> str() const
+ {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+ virtual typename base::int_type
+ overflow(typename base::int_type __c = base::traits_type::eof())
+ {
+ if (__c != base::traits_type::eof())
+ {
+ int n = str_.size();
+ str_.push_back(__c);
+ str_.resize(str_.capacity());
+ base::setp(const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data() + str_.size()));
+ base::pbump(n+1);
+ }
+ return __c;
+ }
+};
+
+int main()
+{
+ {
+ std::ostream os((std::streambuf*)0);
+ const signed char* c = (const signed char*)"123";
+ os << c;
+ assert(os.bad());
+ assert(os.fail());
+ }
+ {
+ testbuf<char> sb;
+ std::ostream os(&sb);
+ const signed char* c = (const signed char*)"123";
+ os << c;
+ assert(sb.str() == "123");
+ }
+ {
+ testbuf<char> sb;
+ std::ostream os(&sb);
+ os.width(5);
+ const signed char* c = (const signed char*)"123";
+ os << c;
+ assert(sb.str() == " 123");
+ assert(os.width() == 0);
+ }
+ {
+ testbuf<char> sb;
+ std::ostream os(&sb);
+ os.width(5);
+ left(os);
+ const signed char* c = (const signed char*)"123";
+ os << c;
+ assert(sb.str() == "123 ");
+ assert(os.width() == 0);
+ }
+}
diff --git a/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/unsigned_char.pass.cpp b/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/unsigned_char.pass.cpp
new file mode 100644
index 000000000000..d818c5f358f2
--- /dev/null
+++ b/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/unsigned_char.pass.cpp
@@ -0,0 +1,88 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ostream;
+
+// template<class char, class traits>
+// basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>& out, unsigned char c);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_streambuf<CharT> base;
+ std::basic_string<CharT> str_;
+public:
+ testbuf()
+ {
+ }
+
+ std::basic_string<CharT> str() const
+ {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+ virtual typename base::int_type
+ overflow(typename base::int_type __c = base::traits_type::eof())
+ {
+ if (__c != base::traits_type::eof())
+ {
+ int n = str_.size();
+ str_.push_back(__c);
+ str_.resize(str_.capacity());
+ base::setp(const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data() + str_.size()));
+ base::pbump(n+1);
+ }
+ return __c;
+ }
+};
+
+int main()
+{
+ {
+ std::ostream os((std::streambuf*)0);
+ unsigned char c = 'a';
+ os << c;
+ assert(os.bad());
+ assert(os.fail());
+ }
+ {
+ testbuf<char> sb;
+ std::ostream os(&sb);
+ unsigned char c = 'a';
+ os << c;
+ assert(sb.str() == "a");
+ }
+ {
+ testbuf<char> sb;
+ std::ostream os(&sb);
+ os.width(5);
+ unsigned char c = 'a';
+ os << c;
+ assert(sb.str() == " a");
+ assert(os.width() == 0);
+ }
+ {
+ testbuf<char> sb;
+ std::ostream os(&sb);
+ os.width(5);
+ left(os);
+ unsigned char c = 'a';
+ os << c;
+ assert(sb.str() == "a ");
+ assert(os.width() == 0);
+ }
+}
diff --git a/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/unsigned_char_pointer.pass.cpp b/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/unsigned_char_pointer.pass.cpp
new file mode 100644
index 000000000000..3257f4a776ca
--- /dev/null
+++ b/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/unsigned_char_pointer.pass.cpp
@@ -0,0 +1,88 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ostream;
+
+// template<class traits>
+// basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>& out, const unsigned char* s);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_streambuf<CharT> base;
+ std::basic_string<CharT> str_;
+public:
+ testbuf()
+ {
+ }
+
+ std::basic_string<CharT> str() const
+ {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+ virtual typename base::int_type
+ overflow(typename base::int_type __c = base::traits_type::eof())
+ {
+ if (__c != base::traits_type::eof())
+ {
+ int n = str_.size();
+ str_.push_back(__c);
+ str_.resize(str_.capacity());
+ base::setp(const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data() + str_.size()));
+ base::pbump(n+1);
+ }
+ return __c;
+ }
+};
+
+int main()
+{
+ {
+ std::ostream os((std::streambuf*)0);
+ const unsigned char* c = (const unsigned char*)"123";
+ os << c;
+ assert(os.bad());
+ assert(os.fail());
+ }
+ {
+ testbuf<char> sb;
+ std::ostream os(&sb);
+ const unsigned char* c = (const unsigned char*)"123";
+ os << c;
+ assert(sb.str() == "123");
+ }
+ {
+ testbuf<char> sb;
+ std::ostream os(&sb);
+ os.width(5);
+ const unsigned char* c = (const unsigned char*)"123";
+ os << c;
+ assert(sb.str() == " 123");
+ assert(os.width() == 0);
+ }
+ {
+ testbuf<char> sb;
+ std::ostream os(&sb);
+ os.width(5);
+ left(os);
+ const unsigned char* c = (const unsigned char*)"123";
+ os << c;
+ assert(sb.str() == "123 ");
+ assert(os.width() == 0);
+ }
+}
diff --git a/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/basic_ios.pass.cpp b/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/basic_ios.pass.cpp
new file mode 100644
index 000000000000..e26466e13f6e
--- /dev/null
+++ b/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/basic_ios.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ostream;
+
+// basic_ostream<charT,traits>& operator<<(basic_ios<charT,traits>&
+// (*pf)(basic_ios<charT,traits>&));
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_streambuf<CharT> base;
+ std::basic_string<CharT> str_;
+public:
+ testbuf()
+ {
+ }
+
+ std::basic_string<CharT> str() const
+ {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+ virtual typename base::int_type
+ overflow(typename base::int_type __c = base::traits_type::eof())
+ {
+ if (__c != base::traits_type::eof())
+ {
+ int n = str_.size();
+ str_.push_back(__c);
+ str_.resize(str_.capacity());
+ base::setp(const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data() + str_.size()));
+ base::pbump(n+1);
+ }
+ return __c;
+ }
+};
+
+template <class CharT>
+std::basic_ios<CharT>&
+f(std::basic_ios<CharT>& os)
+{
+ std::uppercase(os);
+ return os;
+}
+
+int main()
+{
+ {
+ testbuf<char> sb;
+ std::ostream os(&sb);
+ assert(!(os.flags() & std::ios_base::uppercase));
+ os << f;
+ assert( (os.flags() & std::ios_base::uppercase));
+ }
+}
diff --git a/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/ios_base.pass.cpp b/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/ios_base.pass.cpp
new file mode 100644
index 000000000000..238a62108249
--- /dev/null
+++ b/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/ios_base.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ostream;
+
+// basic_ostream<charT,traits>& operator<<(ios_base& (*pf)(ios_base&));
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_streambuf<CharT> base;
+ std::basic_string<CharT> str_;
+public:
+ testbuf()
+ {
+ }
+
+ std::basic_string<CharT> str() const
+ {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+ virtual typename base::int_type
+ overflow(typename base::int_type __c = base::traits_type::eof())
+ {
+ if (__c != base::traits_type::eof())
+ {
+ int n = str_.size();
+ str_.push_back(__c);
+ str_.resize(str_.capacity());
+ base::setp(const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data() + str_.size()));
+ base::pbump(n+1);
+ }
+ return __c;
+ }
+};
+
+int main()
+{
+ {
+ testbuf<char> sb;
+ std::ostream os(&sb);
+ assert(!(os.flags() & std::ios_base::uppercase));
+ os << std::uppercase;
+ assert( (os.flags() & std::ios_base::uppercase));
+ }
+}
diff --git a/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/ostream.pass.cpp b/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/ostream.pass.cpp
new file mode 100644
index 000000000000..3ed400a705ca
--- /dev/null
+++ b/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/ostream.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ostream;
+
+// basic_ostream<charT,traits>& operator<<
+// (basic_ostream<charT,traits>& (*pf)(basic_ostream<charT,traits>&))
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_streambuf<CharT> base;
+ std::basic_string<CharT> str_;
+public:
+ testbuf()
+ {
+ }
+
+ std::basic_string<CharT> str() const
+ {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+ virtual typename base::int_type
+ overflow(typename base::int_type __c = base::traits_type::eof())
+ {
+ if (__c != base::traits_type::eof())
+ {
+ int n = str_.size();
+ str_.push_back(__c);
+ str_.resize(str_.capacity());
+ base::setp(const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data() + str_.size()));
+ base::pbump(n+1);
+ }
+ return __c;
+ }
+};
+
+template <class CharT>
+std::basic_ostream<CharT>&
+f(std::basic_ostream<CharT>& os)
+{
+ os << "testing...";
+ return os;
+}
+
+int main()
+{
+ {
+ testbuf<char> sb;
+ std::ostream os(&sb);
+ os << f;
+ assert(sb.str() == "testing...");
+ }
+}
diff --git a/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/streambuf.pass.cpp b/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/streambuf.pass.cpp
new file mode 100644
index 000000000000..1cb9413a7cc9
--- /dev/null
+++ b/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/streambuf.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ostream;
+
+// basic_ostream<charT,traits>& operator<<(basic_streambuf<charT,traits>* sb);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_streambuf<CharT> base;
+ std::basic_string<CharT> str_;
+public:
+ testbuf()
+ {
+ }
+ testbuf(const std::basic_string<CharT>& str)
+ : str_(str)
+ {
+ base::setg(const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data() + str_.size()));
+ }
+
+ std::basic_string<CharT> str() const
+ {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+ virtual typename base::int_type
+ overflow(typename base::int_type __c = base::traits_type::eof())
+ {
+ if (__c != base::traits_type::eof())
+ {
+ int n = str_.size();
+ str_.push_back(__c);
+ str_.resize(str_.capacity());
+ base::setp(const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data() + str_.size()));
+ base::pbump(n+1);
+ }
+ return __c;
+ }
+};
+
+int main()
+{
+ {
+ testbuf<char> sb;
+ std::ostream os(&sb);
+ testbuf<char> sb2("testing...");
+ assert(sb.str() == "");
+ os << &sb2;
+ assert(sb.str() == "testing...");
+ }
+}
diff --git a/test/std/input.output/iostream.format/output.streams/ostream.manip/endl.pass.cpp b/test/std/input.output/iostream.format/output.streams/ostream.manip/endl.pass.cpp
new file mode 100644
index 000000000000..d503544a97f2
--- /dev/null
+++ b/test/std/input.output/iostream.format/output.streams/ostream.manip/endl.pass.cpp
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ostream;
+
+// template <class charT, class traits>
+// basic_ostream<charT,traits>& endl(basic_ostream<charT,traits>& os);
+
+#include <ostream>
+#include <cassert>
+
+int sync_called = 0;
+
+template <class CharT>
+class testbuf
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_streambuf<CharT> base;
+ std::basic_string<CharT> str_;
+public:
+ testbuf()
+ {
+ }
+
+ std::basic_string<CharT> str() const
+ {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+ virtual typename base::int_type
+ overflow(typename base::int_type __c = base::traits_type::eof())
+ {
+ if (__c != base::traits_type::eof())
+ {
+ int n = str_.size();
+ str_.push_back(__c);
+ str_.resize(str_.capacity());
+ base::setp(const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data() + str_.size()));
+ base::pbump(n+1);
+ }
+ return __c;
+ }
+
+ virtual int
+ sync()
+ {
+ ++sync_called;
+ return 0;
+ }
+};
+
+int main()
+{
+ {
+ testbuf<char> sb;
+ std::ostream os(&sb);
+ endl(os);
+ assert(sb.str() == "\n");
+ assert(sync_called == 1);
+ assert(os.good());
+ }
+ {
+ testbuf<wchar_t> sb;
+ std::wostream os(&sb);
+ endl(os);
+ assert(sb.str() == L"\n");
+ assert(sync_called == 2);
+ assert(os.good());
+ }
+}
diff --git a/test/std/input.output/iostream.format/output.streams/ostream.manip/ends.pass.cpp b/test/std/input.output/iostream.format/output.streams/ostream.manip/ends.pass.cpp
new file mode 100644
index 000000000000..975b660b4770
--- /dev/null
+++ b/test/std/input.output/iostream.format/output.streams/ostream.manip/ends.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ostream;
+
+// template <class charT, class traits>
+// basic_ostream<charT,traits>& ends(basic_ostream<charT,traits>& os);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_streambuf<CharT> base;
+ std::basic_string<CharT> str_;
+public:
+ testbuf()
+ {
+ }
+
+ std::basic_string<CharT> str() const
+ {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+ virtual typename base::int_type
+ overflow(typename base::int_type __c = base::traits_type::eof())
+ {
+ if (__c != base::traits_type::eof())
+ {
+ int n = str_.size();
+ str_.push_back(__c);
+ str_.resize(str_.capacity());
+ base::setp(const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data() + str_.size()));
+ base::pbump(n+1);
+ }
+ return __c;
+ }
+};
+
+int main()
+{
+ {
+ testbuf<char> sb;
+ std::ostream os(&sb);
+ ends(os);
+ assert(sb.str().size() == 1);
+ assert(sb.str().back() == 0);
+ assert(os.good());
+ }
+ {
+ testbuf<wchar_t> sb;
+ std::wostream os(&sb);
+ ends(os);
+ assert(sb.str().size() == 1);
+ assert(sb.str().back() == 0);
+ assert(os.good());
+ }
+}
diff --git a/test/std/input.output/iostream.format/output.streams/ostream.manip/flush.pass.cpp b/test/std/input.output/iostream.format/output.streams/ostream.manip/flush.pass.cpp
new file mode 100644
index 000000000000..088826c3d5a9
--- /dev/null
+++ b/test/std/input.output/iostream.format/output.streams/ostream.manip/flush.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ostream;
+
+// template <class charT, class traits>
+// basic_ostream<charT,traits>& flush(basic_ostream<charT,traits>& os);
+
+#include <ostream>
+#include <cassert>
+
+int sync_called = 0;
+
+template <class CharT>
+class testbuf
+ : public std::basic_streambuf<CharT>
+{
+public:
+ testbuf()
+ {
+ }
+
+protected:
+
+ virtual int
+ sync()
+ {
+ ++sync_called;
+ return 0;
+ }
+};
+
+int main()
+{
+ {
+ testbuf<char> sb;
+ std::ostream os(&sb);
+ flush(os);
+ assert(sync_called == 1);
+ assert(os.good());
+ }
+ {
+ testbuf<wchar_t> sb;
+ std::wostream os(&sb);
+ flush(os);
+ assert(sync_called == 2);
+ assert(os.good());
+ }
+}
diff --git a/test/std/input.output/iostream.format/output.streams/ostream.rvalue/CharT_pointer.pass.cpp b/test/std/input.output/iostream.format/output.streams/ostream.rvalue/CharT_pointer.pass.cpp
new file mode 100644
index 000000000000..ec0e8e1e8c7a
--- /dev/null
+++ b/test/std/input.output/iostream.format/output.streams/ostream.rvalue/CharT_pointer.pass.cpp
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ostream;
+
+// template <class charT, class traits, class T>
+// basic_ostream<charT, traits>&
+// operator<<(basic_ostream<charT, traits>&& os, const T& x);
+
+#include <ostream>
+#include <cassert>
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class CharT>
+class testbuf
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_streambuf<CharT> base;
+ std::basic_string<CharT> str_;
+public:
+ testbuf()
+ {
+ }
+
+ std::basic_string<CharT> str() const
+ {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+ virtual typename base::int_type
+ overflow(typename base::int_type __c = base::traits_type::eof())
+ {
+ if (__c != base::traits_type::eof())
+ {
+ int n = str_.size();
+ str_.push_back(__c);
+ str_.resize(str_.capacity());
+ base::setp(const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data() + str_.size()));
+ base::pbump(n+1);
+ }
+ return __c;
+ }
+};
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ testbuf<char> sb;
+ std::ostream(&sb) << "testing...";
+ assert(sb.str() == "testing...");
+ }
+ {
+ testbuf<wchar_t> sb;
+ std::wostream(&sb) << L"123";
+ assert(sb.str() == L"123");
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/input.output/iostream.format/output.streams/ostream.seeks/seekp.pass.cpp b/test/std/input.output/iostream.format/output.streams/ostream.seeks/seekp.pass.cpp
new file mode 100644
index 000000000000..ec3fe48866c7
--- /dev/null
+++ b/test/std/input.output/iostream.format/output.streams/ostream.seeks/seekp.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ostream;
+
+// basic_ostream<charT,traits>& seekp(pos_type pos);
+
+#include <ostream>
+#include <cassert>
+
+int seekpos_called = 0;
+
+template <class CharT>
+struct testbuf
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_streambuf<CharT> base;
+ testbuf() {}
+
+protected:
+
+ typename base::pos_type
+ seekpos(typename base::pos_type sp, std::ios_base::openmode which)
+ {
+ ++seekpos_called;
+ assert(which == std::ios_base::out);
+ return sp;
+ }
+};
+
+int main()
+{
+ {
+ seekpos_called = 0;
+ std::ostream os((std::streambuf*)0);
+ assert(&os.seekp(5) == &os);
+ assert(seekpos_called == 0);
+ }
+ {
+ seekpos_called = 0;
+ testbuf<char> sb;
+ std::ostream os(&sb);
+ assert(&os.seekp(10) == &os);
+ assert(seekpos_called == 1);
+ assert(os.good());
+ assert(&os.seekp(-1) == &os);
+ assert(seekpos_called == 2);
+ assert(os.fail());
+ }
+ { // See https://llvm.org/bugs/show_bug.cgi?id=21361
+ seekpos_called = 0;
+ testbuf<char> sb;
+ std::ostream os(&sb);
+ os.setstate(std::ios_base::eofbit);
+ assert(&os.seekp(10) == &os);
+ assert(seekpos_called == 1);
+ assert(os.rdstate() == std::ios_base::eofbit);
+ }
+}
diff --git a/test/std/input.output/iostream.format/output.streams/ostream.seeks/seekp2.pass.cpp b/test/std/input.output/iostream.format/output.streams/ostream.seeks/seekp2.pass.cpp
new file mode 100644
index 000000000000..ebfd24af91d5
--- /dev/null
+++ b/test/std/input.output/iostream.format/output.streams/ostream.seeks/seekp2.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ostream;
+
+// basic_ostream<charT,traits>& seekp(off_type off, ios_base::seekdir dir);
+
+#include <ostream>
+#include <cassert>
+
+int seekoff_called = 0;
+
+template <class CharT>
+struct testbuf
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_streambuf<CharT> base;
+ testbuf() {}
+
+protected:
+
+ typename base::pos_type
+ seekoff(typename base::off_type off, std::ios_base::seekdir way,
+ std::ios_base::openmode which)
+ {
+ ++seekoff_called;
+ assert(way == std::ios_base::beg);
+ assert(which == std::ios_base::out);
+ return off;
+ }
+};
+
+int main()
+{
+ {
+ seekoff_called = 0;
+ std::ostream os((std::streambuf*)0);
+ assert(&os.seekp(5, std::ios_base::beg) == &os);
+ assert(seekoff_called == 0);
+ }
+ {
+ seekoff_called = 0;
+ testbuf<char> sb;
+ std::ostream os(&sb);
+ assert(&os.seekp(10, std::ios_base::beg) == &os);
+ assert(seekoff_called == 1);
+ assert(os.good());
+ assert(&os.seekp(-1, std::ios_base::beg) == &os);
+ assert(seekoff_called == 2);
+ assert(os.fail());
+ }
+ { // See https://llvm.org/bugs/show_bug.cgi?id=21361
+ seekoff_called = 0;
+ testbuf<char> sb;
+ std::ostream os(&sb);
+ os.setstate(std::ios_base::eofbit);
+ assert(&os.seekp(10, std::ios_base::beg) == &os);
+ assert(seekoff_called == 1);
+ assert(os.rdstate() == std::ios_base::eofbit);
+ }
+}
diff --git a/test/std/input.output/iostream.format/output.streams/ostream.seeks/tellp.pass.cpp b/test/std/input.output/iostream.format/output.streams/ostream.seeks/tellp.pass.cpp
new file mode 100644
index 000000000000..10a229d382b0
--- /dev/null
+++ b/test/std/input.output/iostream.format/output.streams/ostream.seeks/tellp.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ostream;
+
+// pos_type tellp();
+
+#include <ostream>
+#include <cassert>
+
+int seekoff_called = 0;
+
+template <class CharT>
+struct testbuf
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_streambuf<CharT> base;
+ testbuf() {}
+
+protected:
+
+ typename base::pos_type
+ seekoff(typename base::off_type off, std::ios_base::seekdir way, std::ios_base::openmode which)
+ {
+ assert(off == 0);
+ assert(way == std::ios_base::cur);
+ assert(which == std::ios_base::out);
+ ++seekoff_called;
+ return 10;
+ }
+};
+
+int main()
+{
+ {
+ std::ostream os((std::streambuf*)0);
+ assert(os.tellp() == -1);
+ }
+ {
+ testbuf<char> sb;
+ std::ostream os(&sb);
+ assert(os.tellp() == 10);
+ assert(seekoff_called == 1);
+ }
+}
diff --git a/test/std/input.output/iostream.format/output.streams/ostream.unformatted/flush.pass.cpp b/test/std/input.output/iostream.format/output.streams/ostream.unformatted/flush.pass.cpp
new file mode 100644
index 000000000000..97791f4c7a9c
--- /dev/null
+++ b/test/std/input.output/iostream.format/output.streams/ostream.unformatted/flush.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ostream;
+
+// basic_ostream& flush();
+
+#include <ostream>
+#include <cassert>
+
+int sync_called = 0;
+
+template <class CharT>
+class testbuf
+ : public std::basic_streambuf<CharT>
+{
+public:
+ testbuf()
+ {
+ }
+
+protected:
+
+ virtual int
+ sync()
+ {
+ if (sync_called++ == 1)
+ return -1;
+ return 0;
+ }
+};
+
+int main()
+{
+ {
+ testbuf<char> sb;
+ std::ostream os(&sb);
+ os.flush();
+ assert(os.good());
+ assert(sync_called == 1);
+ os.flush();
+ assert(os.bad());
+ assert(sync_called == 2);
+ }
+}
diff --git a/test/std/input.output/iostream.format/output.streams/ostream.unformatted/put.pass.cpp b/test/std/input.output/iostream.format/output.streams/ostream.unformatted/put.pass.cpp
new file mode 100644
index 000000000000..396bb093f9c7
--- /dev/null
+++ b/test/std/input.output/iostream.format/output.streams/ostream.unformatted/put.pass.cpp
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ostream;
+
+// basic_ostream<charT,traits>& put(char_type c);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_streambuf<CharT> base;
+ std::basic_string<CharT> str_;
+public:
+ testbuf()
+ {
+ }
+
+ std::basic_string<CharT> str() const
+ {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+ virtual typename base::int_type
+ overflow(typename base::int_type __c = base::traits_type::eof())
+ {
+ if (__c != base::traits_type::eof())
+ {
+ int n = str_.size();
+ str_.push_back(__c);
+ str_.resize(str_.capacity());
+ base::setp(const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data() + str_.size()));
+ base::pbump(n+1);
+ }
+ return __c;
+ }
+};
+
+int main()
+{
+ {
+ std::wostream os((std::wstreambuf*)0);
+ wchar_t c = L'a';
+ os.put(c);
+ assert(os.bad());
+ }
+ {
+ testbuf<wchar_t> sb;
+ std::wostream os(&sb);
+ wchar_t c = L'a';
+ os.put(c);
+ assert(sb.str() == L"a");
+ assert(os.good());
+ }
+ {
+ testbuf<char> sb;
+ std::ostream os(&sb);
+ char c = 'a';
+ os.put(c);
+ assert(sb.str() == "a");
+ assert(os.good());
+ }
+}
diff --git a/test/std/input.output/iostream.format/output.streams/ostream.unformatted/write.pass.cpp b/test/std/input.output/iostream.format/output.streams/ostream.unformatted/write.pass.cpp
new file mode 100644
index 000000000000..8dd4e4cf76a6
--- /dev/null
+++ b/test/std/input.output/iostream.format/output.streams/ostream.unformatted/write.pass.cpp
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ostream;
+
+// basic_ostream& write(const char_type* s, streamsize n);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_streambuf<CharT> base;
+ std::basic_string<CharT> str_;
+public:
+ testbuf()
+ {
+ }
+
+ std::basic_string<CharT> str() const
+ {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+ virtual typename base::int_type
+ overflow(typename base::int_type __c = base::traits_type::eof())
+ {
+ if (__c != base::traits_type::eof())
+ {
+ int n = str_.size();
+ str_.push_back(__c);
+ str_.resize(str_.capacity());
+ base::setp(const_cast<CharT*>(str_.data()),
+ const_cast<CharT*>(str_.data() + str_.size()));
+ base::pbump(n+1);
+ }
+ return __c;
+ }
+};
+
+int main()
+{
+ {
+ std::wostream os((std::wstreambuf*)0);
+ const wchar_t s[] = L"123456790";
+ os.write(s, sizeof(s)/sizeof(s[0])-1);
+ assert(os.bad());
+ }
+ {
+ testbuf<wchar_t> sb;
+ std::wostream os(&sb);
+ const wchar_t s[] = L"123456790";
+ os.write(s, sizeof(s)/sizeof(s[0])-1);
+ assert(os.good());
+ assert(sb.str() == s);
+ }
+ {
+ testbuf<char> sb;
+ std::ostream os(&sb);
+ const char s[] = "123456790";
+ os.write(s, sizeof(s)/sizeof(s[0])-1);
+ assert(sb.str() == s);
+ assert(os.good());
+ }
+}
diff --git a/test/std/input.output/iostream.format/output.streams/ostream/types.pass.cpp b/test/std/input.output/iostream.format/output.streams/ostream/types.pass.cpp
new file mode 100644
index 000000000000..41ce0346c48b
--- /dev/null
+++ b/test/std/input.output/iostream.format/output.streams/ostream/types.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ostream
+// : virtual public basic_ios<charT,traits>
+// {
+// public:
+// // types (inherited from basic_ios (27.5.4)):
+// typedef charT char_type;
+// typedef traits traits_type;
+// typedef typename traits_type::int_type int_type;
+// typedef typename traits_type::pos_type pos_type;
+// typedef typename traits_type::off_type off_type;
+
+#include <ostream>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_base_of<std::basic_ios<char>, std::basic_ostream<char> >::value), "");
+ static_assert((std::is_same<std::basic_ostream<char>::char_type, char>::value), "");
+ static_assert((std::is_same<std::basic_ostream<char>::traits_type, std::char_traits<char> >::value), "");
+ static_assert((std::is_same<std::basic_ostream<char>::int_type, std::char_traits<char>::int_type>::value), "");
+ static_assert((std::is_same<std::basic_ostream<char>::pos_type, std::char_traits<char>::pos_type>::value), "");
+ static_assert((std::is_same<std::basic_ostream<char>::off_type, std::char_traits<char>::off_type>::value), "");
+}
diff --git a/test/std/input.output/iostream.format/output.streams/ostream_sentry/construct.pass.cpp b/test/std/input.output/iostream.format/output.streams/ostream_sentry/construct.pass.cpp
new file mode 100644
index 000000000000..991fdfb35722
--- /dev/null
+++ b/test/std/input.output/iostream.format/output.streams/ostream_sentry/construct.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ostream::sentry;
+
+// explicit sentry(basic_ostream<charT,traits>& os);
+
+#include <ostream>
+#include <cassert>
+
+int sync_called = 0;
+
+template <class CharT>
+struct testbuf1
+ : public std::basic_streambuf<CharT>
+{
+ testbuf1() {}
+
+protected:
+
+ int virtual sync()
+ {
+ ++sync_called;
+ return 1;
+ }
+};
+
+int main()
+{
+ {
+ std::ostream os((std::streambuf*)0);
+ std::ostream::sentry s(os);
+ assert(!bool(s));
+ }
+ {
+ testbuf1<char> sb;
+ std::ostream os(&sb);
+ std::ostream::sentry s(os);
+ assert(bool(s));
+ }
+ {
+ testbuf1<char> sb;
+ std::ostream os(&sb);
+ testbuf1<char> sb2;
+ std::ostream os2(&sb2);
+ os.tie(&os2);
+ assert(sync_called == 0);
+ std::ostream::sentry s(os);
+ assert(bool(s));
+ assert(sync_called == 1);
+ }
+}
diff --git a/test/std/input.output/iostream.format/output.streams/ostream_sentry/destruct.pass.cpp b/test/std/input.output/iostream.format/output.streams/ostream_sentry/destruct.pass.cpp
new file mode 100644
index 000000000000..112928ca0ce6
--- /dev/null
+++ b/test/std/input.output/iostream.format/output.streams/ostream_sentry/destruct.pass.cpp
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ostream::sentry;
+
+// ~sentry();
+
+#include <ostream>
+#include <cassert>
+
+int sync_called = 0;
+
+template <class CharT>
+struct testbuf1
+ : public std::basic_streambuf<CharT>
+{
+ testbuf1() {}
+
+protected:
+
+ int virtual sync()
+ {
+ ++sync_called;
+ return 1;
+ }
+};
+
+int main()
+{
+ {
+ std::ostream os((std::streambuf*)0);
+ std::ostream::sentry s(os);
+ assert(!bool(s));
+ }
+ assert(sync_called == 0);
+ {
+ testbuf1<char> sb;
+ std::ostream os(&sb);
+ std::ostream::sentry s(os);
+ assert(bool(s));
+ }
+ assert(sync_called == 0);
+ {
+ testbuf1<char> sb;
+ std::ostream os(&sb);
+ std::ostream::sentry s(os);
+ assert(bool(s));
+ unitbuf(os);
+ }
+ assert(sync_called == 1);
+ {
+ testbuf1<char> sb;
+ std::ostream os(&sb);
+ try
+ {
+ std::ostream::sentry s(os);
+ assert(bool(s));
+ unitbuf(os);
+ throw 1;
+ }
+ catch (...)
+ {
+ }
+ assert(sync_called == 1);
+ }
+}
diff --git a/test/std/input.output/iostream.format/output.streams/version.pass.cpp b/test/std/input.output/iostream.format/output.streams/version.pass.cpp
new file mode 100644
index 000000000000..662b6987b3c8
--- /dev/null
+++ b/test/std/input.output/iostream.format/output.streams/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+#include <ostream>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/input.output/iostream.format/quoted.manip/quoted.pass.cpp b/test/std/input.output/iostream.format/quoted.manip/quoted.pass.cpp
new file mode 100644
index 000000000000..d09b3cae4f66
--- /dev/null
+++ b/test/std/input.output/iostream.format/quoted.manip/quoted.pass.cpp
@@ -0,0 +1,219 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iomanip>
+
+// quoted
+
+#include <iomanip>
+#include <sstream>
+#include <string>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+bool is_skipws ( const std::istream *is ) {
+ return ( is->flags() & std::ios_base::skipws ) != 0;
+ }
+
+
+bool is_skipws ( const std::wistream *is ) {
+ return ( is->flags() & std::ios_base::skipws ) != 0;
+ }
+
+void both_ways ( const char *p ) {
+ std::string str(p);
+ auto q = std::quoted(str);
+
+ std::stringstream ss;
+ bool skippingws = is_skipws ( &ss );
+ ss << q;
+ ss >> q;
+ }
+
+void round_trip ( const char *p ) {
+ std::stringstream ss;
+ bool skippingws = is_skipws ( &ss );
+ ss << std::quoted(p);
+ std::string s;
+ ss >> std::quoted(s);
+ assert ( s == p );
+ assert ( skippingws == is_skipws ( &ss ));
+ }
+
+void round_trip_ws ( const char *p ) {
+ std::stringstream ss;
+ std::noskipws ( ss );
+ bool skippingws = is_skipws ( &ss );
+ ss << std::quoted(p);
+ std::string s;
+ ss >> std::quoted(s);
+ assert ( s == p );
+ assert ( skippingws == is_skipws ( &ss ));
+ }
+
+void round_trip_d ( const char *p, char delim ) {
+ std::stringstream ss;
+ ss << std::quoted(p, delim);
+ std::string s;
+ ss >> std::quoted(s, delim);
+ assert ( s == p );
+ }
+
+void round_trip_e ( const char *p, char escape ) {
+ std::stringstream ss;
+ ss << std::quoted(p, '"', escape );
+ std::string s;
+ ss >> std::quoted(s, '"', escape );
+ assert ( s == p );
+ }
+
+
+
+std::string quote ( const char *p, char delim='"', char escape='\\' ) {
+ std::stringstream ss;
+ ss << std::quoted(p, delim, escape);
+ std::string s;
+ ss >> s; // no quote
+ return s;
+}
+
+std::string unquote ( const char *p, char delim='"', char escape='\\' ) {
+ std::stringstream ss;
+ ss << p;
+ std::string s;
+ ss >> std::quoted(s, delim, escape);
+ return s;
+}
+
+void test_padding () {
+ {
+ std::stringstream ss;
+ ss << std::left << std::setw(10) << std::setfill('!') << std::quoted("abc", '`');
+ assert ( ss.str() == "`abc`!!!!!" );
+ }
+
+ {
+ std::stringstream ss;
+ ss << std::right << std::setw(10) << std::setfill('!') << std::quoted("abc", '`');
+ assert ( ss.str() == "!!!!!`abc`" );
+ }
+}
+
+
+void round_trip ( const wchar_t *p ) {
+ std::wstringstream ss;
+ bool skippingws = is_skipws ( &ss );
+ ss << std::quoted(p);
+ std::wstring s;
+ ss >> std::quoted(s);
+ assert ( s == p );
+ assert ( skippingws == is_skipws ( &ss ));
+ }
+
+
+void round_trip_ws ( const wchar_t *p ) {
+ std::wstringstream ss;
+ std::noskipws ( ss );
+ bool skippingws = is_skipws ( &ss );
+ ss << std::quoted(p);
+ std::wstring s;
+ ss >> std::quoted(s);
+ assert ( s == p );
+ assert ( skippingws == is_skipws ( &ss ));
+ }
+
+void round_trip_d ( const wchar_t *p, wchar_t delim ) {
+ std::wstringstream ss;
+ ss << std::quoted(p, delim);
+ std::wstring s;
+ ss >> std::quoted(s, delim);
+ assert ( s == p );
+ }
+
+void round_trip_e ( const wchar_t *p, wchar_t escape ) {
+ std::wstringstream ss;
+ ss << std::quoted(p, wchar_t('"'), escape );
+ std::wstring s;
+ ss >> std::quoted(s, wchar_t('"'), escape );
+ assert ( s == p );
+ }
+
+
+std::wstring quote ( const wchar_t *p, wchar_t delim='"', wchar_t escape='\\' ) {
+ std::wstringstream ss;
+ ss << std::quoted(p, delim, escape);
+ std::wstring s;
+ ss >> s; // no quote
+ return s;
+}
+
+std::wstring unquote ( const wchar_t *p, wchar_t delim='"', wchar_t escape='\\' ) {
+ std::wstringstream ss;
+ ss << p;
+ std::wstring s;
+ ss >> std::quoted(s, delim, escape);
+ return s;
+}
+
+int main()
+{
+ both_ways ( "" ); // This is a compilation check
+
+ round_trip ( "" );
+ round_trip_ws ( "" );
+ round_trip_d ( "", 'q' );
+ round_trip_e ( "", 'q' );
+
+ round_trip ( L"" );
+ round_trip_ws ( L"" );
+ round_trip_d ( L"", 'q' );
+ round_trip_e ( L"", 'q' );
+
+ round_trip ( "Hi" );
+ round_trip_ws ( "Hi" );
+ round_trip_d ( "Hi", '!' );
+ round_trip_e ( "Hi", '!' );
+ assert ( quote ( "Hi", '!' ) == "!Hi!" );
+ assert ( quote ( "Hi!", '!' ) == R"(!Hi\!!)" );
+
+ round_trip ( L"Hi" );
+ round_trip_ws ( L"Hi" );
+ round_trip_d ( L"Hi", '!' );
+ round_trip_e ( L"Hi", '!' );
+ assert ( quote ( L"Hi", '!' ) == L"!Hi!" );
+ assert ( quote ( L"Hi!", '!' ) == LR"(!Hi\!!)" );
+
+ round_trip ( "Hi Mom" );
+ round_trip_ws ( "Hi Mom" );
+ round_trip ( L"Hi Mom" );
+ round_trip_ws ( L"Hi Mom" );
+
+ assert ( quote ( "" ) == "\"\"" );
+ assert ( quote ( L"" ) == L"\"\"" );
+ assert ( quote ( "a" ) == "\"a\"" );
+ assert ( quote ( L"a" ) == L"\"a\"" );
+
+// missing end quote - must not hang
+ assert ( unquote ( "\"abc" ) == "abc" );
+ assert ( unquote ( L"\"abc" ) == L"abc" );
+
+ assert ( unquote ( "abc" ) == "abc" ); // no delimiter
+ assert ( unquote ( L"abc" ) == L"abc" ); // no delimiter
+ assert ( unquote ( "abc def" ) == "abc" ); // no delimiter
+ assert ( unquote ( L"abc def" ) == L"abc" ); // no delimiter
+
+ assert ( unquote ( "" ) == "" ); // nothing there
+ assert ( unquote ( L"" ) == L"" ); // nothing there
+ test_padding ();
+ }
+
+#else
+int main() {}
+#endif
diff --git a/test/std/input.output/iostream.format/quoted.manip/quoted_char.fail.cpp b/test/std/input.output/iostream.format/quoted.manip/quoted_char.fail.cpp
new file mode 100644
index 000000000000..2f516f8fbc91
--- /dev/null
+++ b/test/std/input.output/iostream.format/quoted.manip/quoted_char.fail.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iomanip>
+
+// quoted
+
+#include <iomanip>
+#include <sstream>
+#include <string>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+void round_trip ( const char *p ) {
+ std::wstringstream ss;
+ ss << std::quoted(p);
+ std::string s;
+ ss >> std::quoted(s);
+ }
+
+
+
+int main()
+{
+ round_trip ( "Hi Mom" );
+}
+#else
+#error
+#endif
diff --git a/test/std/input.output/iostream.format/quoted.manip/quoted_traits.fail.cpp b/test/std/input.output/iostream.format/quoted.manip/quoted_traits.fail.cpp
new file mode 100644
index 000000000000..bdd362df19c9
--- /dev/null
+++ b/test/std/input.output/iostream.format/quoted.manip/quoted_traits.fail.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iomanip>
+
+// quoted
+
+#include <iomanip>
+#include <sstream>
+#include <string>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+template <class charT>
+struct test_traits
+{
+ typedef charT char_type;
+};
+
+void round_trip ( const char *p ) {
+ std::stringstream ss;
+ ss << std::quoted(p);
+ std::basic_string<char, test_traits<char>> s;
+ ss >> std::quoted(s);
+ }
+
+
+
+int main()
+{
+ round_trip ( "Hi Mom" );
+}
+#else
+#error
+#endif
diff --git a/test/std/input.output/iostream.format/std.manip/resetiosflags.pass.cpp b/test/std/input.output/iostream.format/std.manip/resetiosflags.pass.cpp
new file mode 100644
index 000000000000..6c01fc057da4
--- /dev/null
+++ b/test/std/input.output/iostream.format/std.manip/resetiosflags.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iomanip>
+
+// T1 resetiosflags(ios_base::fmtflags mask);
+
+#include <iomanip>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+ : public std::basic_streambuf<CharT>
+{
+ testbuf() {}
+};
+
+int main()
+{
+ {
+ testbuf<char> sb;
+ std::istream is(&sb);
+ assert(is.flags() & std::ios_base::skipws);
+ is >> std::resetiosflags(std::ios_base::skipws);
+ assert(!(is.flags() & std::ios_base::skipws));
+ }
+ {
+ testbuf<char> sb;
+ std::ostream os(&sb);
+ assert(os.flags() & std::ios_base::skipws);
+ os << std::resetiosflags(std::ios_base::skipws);
+ assert(!(os.flags() & std::ios_base::skipws));
+ }
+ {
+ testbuf<wchar_t> sb;
+ std::wistream is(&sb);
+ assert(is.flags() & std::ios_base::skipws);
+ is >> std::resetiosflags(std::ios_base::skipws);
+ assert(!(is.flags() & std::ios_base::skipws));
+ }
+ {
+ testbuf<wchar_t> sb;
+ std::wostream os(&sb);
+ assert(os.flags() & std::ios_base::skipws);
+ os << std::resetiosflags(std::ios_base::skipws);
+ assert(!(os.flags() & std::ios_base::skipws));
+ }
+}
diff --git a/test/std/input.output/iostream.format/std.manip/setbase.pass.cpp b/test/std/input.output/iostream.format/std.manip/setbase.pass.cpp
new file mode 100644
index 000000000000..e2776a5d1ab3
--- /dev/null
+++ b/test/std/input.output/iostream.format/std.manip/setbase.pass.cpp
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iomanip>
+
+// T3 setbase(int base);
+
+#include <iomanip>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+ : public std::basic_streambuf<CharT>
+{
+ testbuf() {}
+};
+
+int main()
+{
+ {
+ testbuf<char> sb;
+ std::istream is(&sb);
+ is >> std::setbase(8);
+ assert((is.flags() & std::ios_base::basefield) == std::ios_base::oct);
+ is >> std::setbase(10);
+ assert((is.flags() & std::ios_base::basefield) == std::ios_base::dec);
+ is >> std::setbase(16);
+ assert((is.flags() & std::ios_base::basefield) == std::ios_base::hex);
+ is >> std::setbase(15);
+ assert((is.flags() & std::ios_base::basefield) == 0);
+ }
+ {
+ testbuf<char> sb;
+ std::ostream os(&sb);
+ os << std::setbase(8);
+ assert((os.flags() & std::ios_base::basefield) == std::ios_base::oct);
+ os << std::setbase(10);
+ assert((os.flags() & std::ios_base::basefield) == std::ios_base::dec);
+ os << std::setbase(16);
+ assert((os.flags() & std::ios_base::basefield) == std::ios_base::hex);
+ os << std::setbase(15);
+ assert((os.flags() & std::ios_base::basefield) == 0);
+ }
+ {
+ testbuf<wchar_t> sb;
+ std::wistream is(&sb);
+ is >> std::setbase(8);
+ assert((is.flags() & std::ios_base::basefield) == std::ios_base::oct);
+ is >> std::setbase(10);
+ assert((is.flags() & std::ios_base::basefield) == std::ios_base::dec);
+ is >> std::setbase(16);
+ assert((is.flags() & std::ios_base::basefield) == std::ios_base::hex);
+ is >> std::setbase(15);
+ assert((is.flags() & std::ios_base::basefield) == 0);
+ }
+ {
+ testbuf<wchar_t> sb;
+ std::wostream os(&sb);
+ os << std::setbase(8);
+ assert((os.flags() & std::ios_base::basefield) == std::ios_base::oct);
+ os << std::setbase(10);
+ assert((os.flags() & std::ios_base::basefield) == std::ios_base::dec);
+ os << std::setbase(16);
+ assert((os.flags() & std::ios_base::basefield) == std::ios_base::hex);
+ os << std::setbase(15);
+ assert((os.flags() & std::ios_base::basefield) == 0);
+ }
+}
diff --git a/test/std/input.output/iostream.format/std.manip/setfill.pass.cpp b/test/std/input.output/iostream.format/std.manip/setfill.pass.cpp
new file mode 100644
index 000000000000..a4d923d70ade
--- /dev/null
+++ b/test/std/input.output/iostream.format/std.manip/setfill.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iomanip>
+
+// template<charT> T4 setfill(charT c);
+
+#include <iomanip>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+ : public std::basic_streambuf<CharT>
+{
+ testbuf() {}
+};
+
+int main()
+{
+ {
+ testbuf<char> sb;
+ std::ostream os(&sb);
+ os << std::setfill('*');
+ assert(os.fill() == '*');
+ }
+ {
+ testbuf<wchar_t> sb;
+ std::wostream os(&sb);
+ os << std::setfill(L'*');
+ assert(os.fill() == L'*');
+ }
+}
diff --git a/test/std/input.output/iostream.format/std.manip/setiosflags.pass.cpp b/test/std/input.output/iostream.format/std.manip/setiosflags.pass.cpp
new file mode 100644
index 000000000000..5aaf38444ab1
--- /dev/null
+++ b/test/std/input.output/iostream.format/std.manip/setiosflags.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iomanip>
+
+// T2 setiosflags (ios_base::fmtflags mask);
+
+#include <iomanip>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+ : public std::basic_streambuf<CharT>
+{
+ testbuf() {}
+};
+
+int main()
+{
+ {
+ testbuf<char> sb;
+ std::istream is(&sb);
+ assert(!(is.flags() & std::ios_base::oct));
+ is >> std::setiosflags(std::ios_base::oct);
+ assert(is.flags() & std::ios_base::oct);
+ }
+ {
+ testbuf<char> sb;
+ std::ostream os(&sb);
+ assert(!(os.flags() & std::ios_base::oct));
+ os << std::setiosflags(std::ios_base::oct);
+ assert(os.flags() & std::ios_base::oct);
+ }
+ {
+ testbuf<wchar_t> sb;
+ std::wistream is(&sb);
+ assert(!(is.flags() & std::ios_base::oct));
+ is >> std::setiosflags(std::ios_base::oct);
+ assert(is.flags() & std::ios_base::oct);
+ }
+ {
+ testbuf<wchar_t> sb;
+ std::wostream os(&sb);
+ assert(!(os.flags() & std::ios_base::oct));
+ os << std::setiosflags(std::ios_base::oct);
+ assert(os.flags() & std::ios_base::oct);
+ }
+}
diff --git a/test/std/input.output/iostream.format/std.manip/setprecision.pass.cpp b/test/std/input.output/iostream.format/std.manip/setprecision.pass.cpp
new file mode 100644
index 000000000000..0bea4b98623b
--- /dev/null
+++ b/test/std/input.output/iostream.format/std.manip/setprecision.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iomanip>
+
+// T5 setprecision(int n);
+
+#include <iomanip>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+ : public std::basic_streambuf<CharT>
+{
+ testbuf() {}
+};
+
+int main()
+{
+ {
+ testbuf<char> sb;
+ std::istream is(&sb);
+ is >> std::setprecision(10);
+ assert(is.precision() == 10);
+ }
+ {
+ testbuf<char> sb;
+ std::ostream os(&sb);
+ os << std::setprecision(10);
+ assert(os.precision() == 10);
+ }
+ {
+ testbuf<wchar_t> sb;
+ std::wistream is(&sb);
+ is >> std::setprecision(10);
+ assert(is.precision() == 10);
+ }
+ {
+ testbuf<wchar_t> sb;
+ std::wostream os(&sb);
+ os << std::setprecision(10);
+ assert(os.precision() == 10);
+ }
+}
diff --git a/test/std/input.output/iostream.format/std.manip/setw.pass.cpp b/test/std/input.output/iostream.format/std.manip/setw.pass.cpp
new file mode 100644
index 000000000000..9bd96984e5c9
--- /dev/null
+++ b/test/std/input.output/iostream.format/std.manip/setw.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iomanip>
+
+// T6 setw(int n);
+
+#include <iomanip>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+ : public std::basic_streambuf<CharT>
+{
+ testbuf() {}
+};
+
+int main()
+{
+ {
+ testbuf<char> sb;
+ std::istream is(&sb);
+ is >> std::setw(10);
+ assert(is.width() == 10);
+ }
+ {
+ testbuf<char> sb;
+ std::ostream os(&sb);
+ os << std::setw(10);
+ assert(os.width() == 10);
+ }
+ {
+ testbuf<wchar_t> sb;
+ std::wistream is(&sb);
+ is >> std::setw(10);
+ assert(is.width() == 10);
+ }
+ {
+ testbuf<wchar_t> sb;
+ std::wostream os(&sb);
+ os << std::setw(10);
+ assert(os.width() == 10);
+ }
+}
diff --git a/test/std/input.output/iostream.format/std.manip/version.pass.cpp b/test/std/input.output/iostream.format/std.manip/version.pass.cpp
new file mode 100644
index 000000000000..ca4fd3d463ee
--- /dev/null
+++ b/test/std/input.output/iostream.format/std.manip/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iomanip>
+
+#include <iomanip>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/input.output/iostream.forward/iosfwd.pass.cpp b/test/std/input.output/iostream.forward/iosfwd.pass.cpp
new file mode 100644
index 000000000000..7250c2adb279
--- /dev/null
+++ b/test/std/input.output/iostream.forward/iosfwd.pass.cpp
@@ -0,0 +1,142 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iosfwd>
+
+#include <iosfwd>
+#include <cwchar> // for mbstate_t
+
+int main()
+{
+ {
+ std::char_traits<char>* t1 = 0;
+ std::char_traits<wchar_t>* t2 = 0;
+ std::char_traits<unsigned short>* t3 = 0;
+ }
+ {
+ std::basic_ios<char>* t1 = 0;
+ std::basic_ios<wchar_t>* t2 = 0;
+ std::basic_ios<unsigned short>* t3 = 0;
+ }
+ {
+ std::basic_streambuf<char>* t1 = 0;
+ std::basic_streambuf<wchar_t>* t2 = 0;
+ std::basic_streambuf<unsigned short>* t3 = 0;
+ }
+ {
+ std::basic_istream<char>* t1 = 0;
+ std::basic_istream<wchar_t>* t2 = 0;
+ std::basic_istream<unsigned short>* t3 = 0;
+ }
+ {
+ std::basic_ostream<char>* t1 = 0;
+ std::basic_ostream<wchar_t>* t2 = 0;
+ std::basic_ostream<unsigned short>* t3 = 0;
+ }
+ {
+ std::basic_iostream<char>* t1 = 0;
+ std::basic_iostream<wchar_t>* t2 = 0;
+ std::basic_iostream<unsigned short>* t3 = 0;
+ }
+ {
+ std::basic_stringbuf<char>* t1 = 0;
+ std::basic_stringbuf<wchar_t>* t2 = 0;
+ std::basic_stringbuf<unsigned short>* t3 = 0;
+ }
+ {
+ std::basic_istringstream<char>* t1 = 0;
+ std::basic_istringstream<wchar_t>* t2 = 0;
+ std::basic_istringstream<unsigned short>* t3 = 0;
+ }
+ {
+ std::basic_ostringstream<char>* t1 = 0;
+ std::basic_ostringstream<wchar_t>* t2 = 0;
+ std::basic_ostringstream<unsigned short>* t3 = 0;
+ }
+ {
+ std::basic_stringstream<char>* t1 = 0;
+ std::basic_stringstream<wchar_t>* t2 = 0;
+ std::basic_stringstream<unsigned short>* t3 = 0;
+ }
+ {
+ std::basic_filebuf<char>* t1 = 0;
+ std::basic_filebuf<wchar_t>* t2 = 0;
+ std::basic_filebuf<unsigned short>* t3 = 0;
+ }
+ {
+ std::basic_ifstream<char>* t1 = 0;
+ std::basic_ifstream<wchar_t>* t2 = 0;
+ std::basic_ifstream<unsigned short>* t3 = 0;
+ }
+ {
+ std::basic_ofstream<char>* t1 = 0;
+ std::basic_ofstream<wchar_t>* t2 = 0;
+ std::basic_ofstream<unsigned short>* t3 = 0;
+ }
+ {
+ std::basic_fstream<char>* t1 = 0;
+ std::basic_fstream<wchar_t>* t2 = 0;
+ std::basic_fstream<unsigned short>* t3 = 0;
+ }
+ {
+ std::istreambuf_iterator<char>* t1 = 0;
+ std::istreambuf_iterator<wchar_t>* t2 = 0;
+ std::istreambuf_iterator<unsigned short>* t3 = 0;
+ }
+ {
+ std::ostreambuf_iterator<char>* t1 = 0;
+ std::ostreambuf_iterator<wchar_t>* t2 = 0;
+ std::ostreambuf_iterator<unsigned short>* t3 = 0;
+ }
+ {
+ std::ios* t1 = 0;
+ std::wios* t2 = 0;
+ }
+ {
+ std::streambuf* t1 = 0;
+ std::istream* t2 = 0;
+ std::ostream* t3 = 0;
+ std::iostream* t4 = 0;
+ }
+ {
+ std::stringbuf* t1 = 0;
+ std::istringstream* t2 = 0;
+ std::ostringstream* t3 = 0;
+ std::stringstream* t4 = 0;
+ }
+ {
+ std::filebuf* t1 = 0;
+ std::ifstream* t2 = 0;
+ std::ofstream* t3 = 0;
+ std::fstream* t4 = 0;
+ }
+ {
+ std::wstreambuf* t1 = 0;
+ std::wistream* t2 = 0;
+ std::wostream* t3 = 0;
+ std::wiostream* t4 = 0;
+ }
+ {
+ std::wstringbuf* t1 = 0;
+ std::wistringstream* t2 = 0;
+ std::wostringstream* t3 = 0;
+ std::wstringstream* t4 = 0;
+ }
+ {
+ std::wfilebuf* t1 = 0;
+ std::wifstream* t2 = 0;
+ std::wofstream* t3 = 0;
+ std::wfstream* t4 = 0;
+ }
+ {
+ std::fpos<std::mbstate_t>* t1 = 0;
+ std::streampos* t2 = 0;
+ std::wstreampos* t3 = 0;
+ }
+}
diff --git a/test/std/input.output/iostream.forward/version.pass.cpp b/test/std/input.output/iostream.forward/version.pass.cpp
new file mode 100644
index 000000000000..cf91332d5597
--- /dev/null
+++ b/test/std/input.output/iostream.forward/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iosfwd>
+
+#include <iosfwd>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/input.output/iostream.objects/narrow.stream.objects/cerr.pass.cpp b/test/std/input.output/iostream.objects/narrow.stream.objects/cerr.pass.cpp
new file mode 100644
index 000000000000..cdf53f86277d
--- /dev/null
+++ b/test/std/input.output/iostream.objects/narrow.stream.objects/cerr.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iostream>
+
+// istream cerr;
+
+#include <iostream>
+#include <cassert>
+
+int main()
+{
+#if 0
+ std::cerr << "Hello World!\n";
+#else
+#ifdef _LIBCPP_HAS_NO_STDOUT
+ assert(std::cerr.tie() == NULL);
+#else
+ assert(std::cerr.tie() == &std::cout);
+#endif
+ assert(std::cerr.flags() & std::ios_base::unitbuf);
+#endif // 0
+}
diff --git a/test/std/input.output/iostream.objects/narrow.stream.objects/cin.pass.cpp b/test/std/input.output/iostream.objects/narrow.stream.objects/cin.pass.cpp
new file mode 100644
index 000000000000..1ce04ffb1563
--- /dev/null
+++ b/test/std/input.output/iostream.objects/narrow.stream.objects/cin.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// XFAIL: libcpp-has-no-stdin
+
+// <iostream>
+
+// istream cin;
+
+#include <iostream>
+#include <cassert>
+
+int main()
+{
+#if 0
+ std::cout << "Hello World!\n";
+ int i;
+ std::cout << "Enter a number: ";
+ std::cin >> i;
+ std::cout << "The number is : " << i << '\n';
+#else // 0
+#ifdef _LIBCPP_HAS_NO_STDOUT
+ assert(std::cin.tie() == NULL);
+#else
+ assert(std::cin.tie() == &std::cout);
+#endif
+#endif
+}
diff --git a/test/std/input.output/iostream.objects/narrow.stream.objects/clog.pass.cpp b/test/std/input.output/iostream.objects/narrow.stream.objects/clog.pass.cpp
new file mode 100644
index 000000000000..3812b203ae04
--- /dev/null
+++ b/test/std/input.output/iostream.objects/narrow.stream.objects/clog.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iostream>
+
+// istream clog;
+
+#include <iostream>
+
+int main()
+{
+#if 0
+ std::clog << "Hello World!\n";
+#else
+ (void)std::clog;
+#endif
+}
diff --git a/test/std/input.output/iostream.objects/narrow.stream.objects/cout.pass.cpp b/test/std/input.output/iostream.objects/narrow.stream.objects/cout.pass.cpp
new file mode 100644
index 000000000000..e5887e1625d7
--- /dev/null
+++ b/test/std/input.output/iostream.objects/narrow.stream.objects/cout.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// XFAIL: libcpp-has-no-stdout
+
+// <iostream>
+
+// istream cout;
+
+#include <iostream>
+
+int main()
+{
+#if 0
+ std::cout << "Hello World!\n";
+ int i;
+ std::cout << "Enter a number: ";
+ std::cin >> i;
+ std::cout << "The number is : " << i << '\n';
+#else // 0
+ (void)std::cout;
+#endif
+}
diff --git a/test/std/input.output/iostream.objects/version.pass.cpp b/test/std/input.output/iostream.objects/version.pass.cpp
new file mode 100644
index 000000000000..09b3611f6df9
--- /dev/null
+++ b/test/std/input.output/iostream.objects/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iostream>
+
+#include <iostream>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/input.output/iostream.objects/wide.stream.objects/wcerr.pass.cpp b/test/std/input.output/iostream.objects/wide.stream.objects/wcerr.pass.cpp
new file mode 100644
index 000000000000..b050781671e6
--- /dev/null
+++ b/test/std/input.output/iostream.objects/wide.stream.objects/wcerr.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iostream>
+
+// istream wcerr;
+
+#include <iostream>
+#include <cassert>
+
+int main()
+{
+#if 0
+ std::wcerr << L"Hello World!\n";
+#else
+#ifdef _LIBCPP_HAS_NO_STDOUT
+ assert(std::wcerr.tie() == NULL);
+#else
+ assert(std::wcerr.tie() == &std::wcout);
+#endif
+ assert(std::wcerr.flags() & std::ios_base::unitbuf);
+#endif // 0
+}
diff --git a/test/std/input.output/iostream.objects/wide.stream.objects/wcin.pass.cpp b/test/std/input.output/iostream.objects/wide.stream.objects/wcin.pass.cpp
new file mode 100644
index 000000000000..6abd6afa81c4
--- /dev/null
+++ b/test/std/input.output/iostream.objects/wide.stream.objects/wcin.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// XFAIL: libcpp-has-no-stdin
+
+// <iostream>
+
+// istream wcin;
+
+#include <iostream>
+#include <cassert>
+
+int main()
+{
+#if 0
+ std::wcout << L"Hello World!\n";
+ int i;
+ std::wcout << L"Enter a number: ";
+ std::wcin >> i;
+ std::wcout << L"The number is : " << i << L'\n';
+#else // 0
+#ifdef _LIBCPP_HAS_NO_STDOUT
+ assert(std::wcin.tie() == NULL);
+#else
+ assert(std::wcin.tie() == &std::wcout);
+#endif
+#endif
+}
diff --git a/test/std/input.output/iostream.objects/wide.stream.objects/wclog.pass.cpp b/test/std/input.output/iostream.objects/wide.stream.objects/wclog.pass.cpp
new file mode 100644
index 000000000000..61ff5fb5089c
--- /dev/null
+++ b/test/std/input.output/iostream.objects/wide.stream.objects/wclog.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iostream>
+
+// istream wclog;
+
+#include <iostream>
+
+int main()
+{
+#if 0
+ std::wclog << L"Hello World!\n";
+#else
+ (void)std::wclog;
+#endif
+}
diff --git a/test/std/input.output/iostream.objects/wide.stream.objects/wcout.pass.cpp b/test/std/input.output/iostream.objects/wide.stream.objects/wcout.pass.cpp
new file mode 100644
index 000000000000..6543e0aa56a4
--- /dev/null
+++ b/test/std/input.output/iostream.objects/wide.stream.objects/wcout.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// XFAIL: libcpp-has-no-stdout
+
+// <iostream>
+
+// istream wcout;
+
+#include <iostream>
+
+int main()
+{
+#if 0
+ std::wcout << L"Hello World!\n";
+#else
+ (void)std::wcout;
+#endif
+}
diff --git a/test/std/input.output/iostreams.base/fpos/fpos.members/state.pass.cpp b/test/std/input.output/iostreams.base/fpos/fpos.members/state.pass.cpp
new file mode 100644
index 000000000000..1da6d4406c97
--- /dev/null
+++ b/test/std/input.output/iostreams.base/fpos/fpos.members/state.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class StateT> class fpos
+
+// void state(stateT s);
+
+#include <ios>
+#include <cassert>
+
+int main()
+{
+ std::fpos<int> f;
+ f.state(3);
+ assert(f.state() == 3);
+}
diff --git a/test/std/input.output/iostreams.base/fpos/fpos.operations/addition.pass.cpp b/test/std/input.output/iostreams.base/fpos/fpos.operations/addition.pass.cpp
new file mode 100644
index 000000000000..a602e3e94bef
--- /dev/null
+++ b/test/std/input.output/iostreams.base/fpos/fpos.operations/addition.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class StateT> class fpos
+
+// Addition
+
+#include <ios>
+#include <cassert>
+
+int main()
+{
+ typedef std::fpos<std::mbstate_t> P;
+ P p(5);
+ std::streamoff o(6);
+ P q = p + o;
+ assert(q == P(11));
+ p += o;
+ assert(p == q);
+}
diff --git a/test/std/input.output/iostreams.base/fpos/fpos.operations/ctor_int.pass.cpp b/test/std/input.output/iostreams.base/fpos/fpos.operations/ctor_int.pass.cpp
new file mode 100644
index 000000000000..1b939d86e598
--- /dev/null
+++ b/test/std/input.output/iostreams.base/fpos/fpos.operations/ctor_int.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class StateT> class fpos
+
+// fpos(int)
+
+#include <ios>
+#include <cassert>
+
+int main()
+{
+ typedef std::fpos<std::mbstate_t> P;
+ P p(5);
+ assert(p == P(5));
+}
diff --git a/test/std/input.output/iostreams.base/fpos/fpos.operations/difference.pass.cpp b/test/std/input.output/iostreams.base/fpos/fpos.operations/difference.pass.cpp
new file mode 100644
index 000000000000..47ce6870a3ba
--- /dev/null
+++ b/test/std/input.output/iostreams.base/fpos/fpos.operations/difference.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class StateT> class fpos
+
+// Subraction with fpos
+
+#include <ios>
+#include <cassert>
+
+int main()
+{
+ typedef std::fpos<std::mbstate_t> P;
+ P p(11);
+ P q(6);
+ std::streamoff o = p - q;
+ assert(o == 5);
+}
diff --git a/test/std/input.output/iostreams.base/fpos/fpos.operations/eq_int.pass.cpp b/test/std/input.output/iostreams.base/fpos/fpos.operations/eq_int.pass.cpp
new file mode 100644
index 000000000000..76f8fa12a414
--- /dev/null
+++ b/test/std/input.output/iostreams.base/fpos/fpos.operations/eq_int.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class StateT> class fpos
+
+// == and !=
+
+#include <ios>
+#include <cassert>
+
+int main()
+{
+ typedef std::fpos<std::mbstate_t> P;
+ P p(5);
+ P q(6);
+ assert(p == p);
+ assert(p != q);
+}
diff --git a/test/std/input.output/iostreams.base/fpos/fpos.operations/offset.pass.cpp b/test/std/input.output/iostreams.base/fpos/fpos.operations/offset.pass.cpp
new file mode 100644
index 000000000000..9c6ebd9f74e2
--- /dev/null
+++ b/test/std/input.output/iostreams.base/fpos/fpos.operations/offset.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class StateT> class fpos
+
+// converts to and from streamoff
+
+#include <ios>
+#include <cassert>
+
+int main()
+{
+ typedef std::fpos<std::mbstate_t> P;
+ P p(std::streamoff(7));
+ std::streamoff offset(p);
+ assert(offset == 7);
+}
diff --git a/test/std/input.output/iostreams.base/fpos/fpos.operations/streamsize.pass.cpp b/test/std/input.output/iostreams.base/fpos/fpos.operations/streamsize.pass.cpp
new file mode 100644
index 000000000000..eb738b492c89
--- /dev/null
+++ b/test/std/input.output/iostreams.base/fpos/fpos.operations/streamsize.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// streamsize and streamoff interconvert
+
+#include <ios>
+#include <cassert>
+
+int main()
+{
+ std::streamoff o(5);
+ std::streamsize sz(o);
+ assert(sz == 5);
+ std::streamoff o2(sz);
+ assert(o == o2);
+}
diff --git a/test/std/input.output/iostreams.base/fpos/fpos.operations/subtraction.pass.cpp b/test/std/input.output/iostreams.base/fpos/fpos.operations/subtraction.pass.cpp
new file mode 100644
index 000000000000..f9e6513e4a4e
--- /dev/null
+++ b/test/std/input.output/iostreams.base/fpos/fpos.operations/subtraction.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class StateT> class fpos
+
+// Subraction with offset
+
+#include <ios>
+#include <cassert>
+
+int main()
+{
+ typedef std::fpos<std::mbstate_t> P;
+ P p(11);
+ std::streamoff o(6);
+ P q = p - o;
+ assert(q == P(5));
+ p -= o;
+ assert(p == q);
+}
diff --git a/test/std/input.output/iostreams.base/fpos/nothing_to_do.pass.cpp b/test/std/input.output/iostreams.base/fpos/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/input.output/iostreams.base/fpos/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/input.output/iostreams.base/ios.base/fmtflags.state/flags.pass.cpp b/test/std/input.output/iostreams.base/ios.base/fmtflags.state/flags.pass.cpp
new file mode 100644
index 000000000000..958fcb53d89a
--- /dev/null
+++ b/test/std/input.output/iostreams.base/ios.base/fmtflags.state/flags.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// fmtflags flags() const;
+
+#include <ios>
+#include <cassert>
+
+class test
+ : public std::ios
+{
+public:
+ test()
+ {
+ init(0);
+ }
+};
+
+int main()
+{
+ const test t;
+ assert(t.flags() == (test::skipws | test::dec));
+}
diff --git a/test/std/input.output/iostreams.base/ios.base/fmtflags.state/flags_fmtflags.pass.cpp b/test/std/input.output/iostreams.base/ios.base/fmtflags.state/flags_fmtflags.pass.cpp
new file mode 100644
index 000000000000..36b5794983e2
--- /dev/null
+++ b/test/std/input.output/iostreams.base/ios.base/fmtflags.state/flags_fmtflags.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// fmtflags flags(fmtflags fmtfl);
+
+#include <ios>
+#include <cassert>
+
+class test
+ : public std::ios
+{
+public:
+ test()
+ {
+ init(0);
+ }
+};
+
+int main()
+{
+ test t;
+ assert(t.flags() == (test::skipws | test::dec));
+ test::fmtflags f = t.flags(test::hex | test::right);
+ assert(f == (test::skipws | test::dec));
+ assert(t.flags() == (test::hex | test::right));
+}
diff --git a/test/std/input.output/iostreams.base/ios.base/fmtflags.state/precision.pass.cpp b/test/std/input.output/iostreams.base/ios.base/fmtflags.state/precision.pass.cpp
new file mode 100644
index 000000000000..701e3de360d8
--- /dev/null
+++ b/test/std/input.output/iostreams.base/ios.base/fmtflags.state/precision.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// streamsize precision() const;
+
+#include <ios>
+#include <cassert>
+
+class test
+ : public std::ios
+{
+public:
+ test()
+ {
+ init(0);
+ }
+};
+
+int main()
+{
+ const test t;
+ assert(t.precision() == 6);
+}
diff --git a/test/std/input.output/iostreams.base/ios.base/fmtflags.state/precision_streamsize.pass.cpp b/test/std/input.output/iostreams.base/ios.base/fmtflags.state/precision_streamsize.pass.cpp
new file mode 100644
index 000000000000..e0d6484c8fd3
--- /dev/null
+++ b/test/std/input.output/iostreams.base/ios.base/fmtflags.state/precision_streamsize.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// streamsize precision(streamsize prec);
+
+#include <ios>
+#include <cassert>
+
+class test
+ : public std::ios
+{
+public:
+ test()
+ {
+ init(0);
+ }
+};
+
+int main()
+{
+ test t;
+ assert(t.precision() == 6);
+ std::streamsize p = t.precision(10);
+ assert(p == 6);
+ assert(t.precision() == 10);
+}
diff --git a/test/std/input.output/iostreams.base/ios.base/fmtflags.state/setf_fmtflags.pass.cpp b/test/std/input.output/iostreams.base/ios.base/fmtflags.state/setf_fmtflags.pass.cpp
new file mode 100644
index 000000000000..d9ec47b7907a
--- /dev/null
+++ b/test/std/input.output/iostreams.base/ios.base/fmtflags.state/setf_fmtflags.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// fmtflags setf(fmtflags fmtfl)
+
+#include <ios>
+#include <cassert>
+
+class test
+ : public std::ios
+{
+public:
+ test()
+ {
+ init(0);
+ }
+};
+
+int main()
+{
+ test t;
+ assert(t.flags() == (test::skipws | test::dec));
+ test::fmtflags f = t.setf(test::hex | test::right);
+ assert(f == (test::skipws | test::dec));
+ assert(t.flags() == (test::skipws | test::dec | test::hex | test::right));
+}
diff --git a/test/std/input.output/iostreams.base/ios.base/fmtflags.state/setf_fmtflags_mask.pass.cpp b/test/std/input.output/iostreams.base/ios.base/fmtflags.state/setf_fmtflags_mask.pass.cpp
new file mode 100644
index 000000000000..b201377027db
--- /dev/null
+++ b/test/std/input.output/iostreams.base/ios.base/fmtflags.state/setf_fmtflags_mask.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// fmtflags setf(fmtflags fmtfl, fmtflags mask);
+
+#include <ios>
+#include <cassert>
+
+class test
+ : public std::ios
+{
+public:
+ test()
+ {
+ init(0);
+ }
+};
+
+int main()
+{
+ test t;
+ assert(t.flags() == (test::skipws | test::dec));
+ test::fmtflags f = t.setf(test::hex | test::right, test::dec | test::right);
+ assert(f == (test::skipws | test::dec));
+ assert(t.flags() == (test::skipws | test::right));
+}
diff --git a/test/std/input.output/iostreams.base/ios.base/fmtflags.state/unsetf_mask.pass.cpp b/test/std/input.output/iostreams.base/ios.base/fmtflags.state/unsetf_mask.pass.cpp
new file mode 100644
index 000000000000..163fc54a1e81
--- /dev/null
+++ b/test/std/input.output/iostreams.base/ios.base/fmtflags.state/unsetf_mask.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// void unsetf(fmtflags mask);
+
+#include <ios>
+#include <cassert>
+
+class test
+ : public std::ios
+{
+public:
+ test()
+ {
+ init(0);
+ }
+};
+
+int main()
+{
+ test t;
+ assert(t.flags() == (test::skipws | test::dec));
+ t.unsetf(test::dec | test::right);
+ assert(t.flags() == test::skipws);
+}
diff --git a/test/std/input.output/iostreams.base/ios.base/fmtflags.state/width.pass.cpp b/test/std/input.output/iostreams.base/ios.base/fmtflags.state/width.pass.cpp
new file mode 100644
index 000000000000..287c89d296ee
--- /dev/null
+++ b/test/std/input.output/iostreams.base/ios.base/fmtflags.state/width.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// streamsize width() const;
+
+#include <ios>
+#include <cassert>
+
+class test
+ : public std::ios
+{
+public:
+ test()
+ {
+ init(0);
+ }
+};
+
+int main()
+{
+ const test t;
+ assert(t.width() == 0);
+}
diff --git a/test/std/input.output/iostreams.base/ios.base/fmtflags.state/width_streamsize.pass.cpp b/test/std/input.output/iostreams.base/ios.base/fmtflags.state/width_streamsize.pass.cpp
new file mode 100644
index 000000000000..6e532deddf05
--- /dev/null
+++ b/test/std/input.output/iostreams.base/ios.base/fmtflags.state/width_streamsize.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// streamsize width(streamsize wide);
+
+#include <ios>
+#include <cassert>
+
+class test
+ : public std::ios
+{
+public:
+ test()
+ {
+ init(0);
+ }
+};
+
+int main()
+{
+ test t;
+ assert(t.width() == 0);
+ std::streamsize w = t.width(4);
+ assert(w == 0);
+ assert(t.width() == 4);
+}
diff --git a/test/std/input.output/iostreams.base/ios.base/ios.base.callback/register_callback.pass.cpp b/test/std/input.output/iostreams.base/ios.base/ios.base.callback/register_callback.pass.cpp
new file mode 100644
index 000000000000..c0ed3150457c
--- /dev/null
+++ b/test/std/input.output/iostreams.base/ios.base/ios.base.callback/register_callback.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// void register_callback(event_callback fn, int index);
+
+#include <ios>
+#include <string>
+#include <locale>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+class test
+ : public std::ios
+{
+public:
+ test()
+ {
+ init(0);
+ }
+};
+
+int f1_called = 0;
+
+void f1(std::ios_base::event ev, std::ios_base& stream, int index)
+{
+ if (ev == std::ios_base::imbue_event)
+ {
+ assert(stream.getloc().name() == LOCALE_en_US_UTF_8);
+ assert(index == 4);
+ ++f1_called;
+ }
+}
+
+int main()
+{
+ test t;
+ std::ios_base& b = t;
+ b.register_callback(f1, 4);
+ b.register_callback(f1, 4);
+ b.register_callback(f1, 4);
+ std::locale l = b.imbue(std::locale(LOCALE_en_US_UTF_8));
+ assert(f1_called == 3);
+}
diff --git a/test/std/input.output/iostreams.base/ios.base/ios.base.cons/dtor.pass.cpp b/test/std/input.output/iostreams.base/ios.base/ios.base.cons/dtor.pass.cpp
new file mode 100644
index 000000000000..e6f334808c1b
--- /dev/null
+++ b/test/std/input.output/iostreams.base/ios.base/ios.base.cons/dtor.pass.cpp
@@ -0,0 +1,86 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// ~ios_base()
+
+#include <ios>
+#include <string>
+#include <locale>
+#include <cassert>
+
+class test
+ : public std::ios
+{
+public:
+ test()
+ {
+ init(0);
+ }
+};
+
+bool f1_called = false;
+bool f2_called = false;
+bool f3_called = false;
+
+void f1(std::ios_base::event ev, std::ios_base& stream, int index)
+{
+ if (ev == std::ios_base::erase_event)
+ {
+ assert(!f1_called);
+ assert( f2_called);
+ assert( f3_called);
+ assert(stream.getloc().name() == "C");
+ assert(index == 4);
+ f1_called = true;
+ }
+}
+
+void f2(std::ios_base::event ev, std::ios_base& stream, int index)
+{
+ if (ev == std::ios_base::erase_event)
+ {
+ assert(!f1_called);
+ assert(!f2_called);
+ assert( f3_called);
+ assert(stream.getloc().name() == "C");
+ assert(index == 5);
+ f2_called = true;
+ }
+}
+
+void f3(std::ios_base::event ev, std::ios_base& stream, int index)
+{
+ if (ev == std::ios_base::erase_event)
+ {
+ assert(!f1_called);
+ assert(!f2_called);
+ assert(!f3_called);
+ assert(stream.getloc().name() == "C");
+ assert(index == 6);
+ f3_called = true;
+ }
+}
+
+int main()
+{
+ {
+ test t;
+ std::ios_base& b = t;
+ b.register_callback(f1, 4);
+ b.register_callback(f2, 5);
+ b.register_callback(f3, 6);
+ }
+ assert(f1_called);
+ assert(f2_called);
+ assert(f3_called);
+}
diff --git a/test/std/input.output/iostreams.base/ios.base/ios.base.locales/getloc.pass.cpp b/test/std/input.output/iostreams.base/ios.base/ios.base.locales/getloc.pass.cpp
new file mode 100644
index 000000000000..8f265bc69884
--- /dev/null
+++ b/test/std/input.output/iostreams.base/ios.base/ios.base.locales/getloc.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// locale getloc() const;
+
+#include <ios>
+#include <string>
+#include <cassert>
+
+class test
+ : public std::ios
+{
+public:
+ test()
+ {
+ init(0);
+ }
+};
+
+int main()
+{
+ const test t;
+ assert(t.getloc().name() == std::string("C"));
+}
diff --git a/test/std/input.output/iostreams.base/ios.base/ios.base.locales/imbue.pass.cpp b/test/std/input.output/iostreams.base/ios.base/ios.base.locales/imbue.pass.cpp
new file mode 100644
index 000000000000..4e34c08ab083
--- /dev/null
+++ b/test/std/input.output/iostreams.base/ios.base/ios.base.locales/imbue.pass.cpp
@@ -0,0 +1,89 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// locale imbue(const locale& loc);
+
+#include <ios>
+#include <string>
+#include <locale>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+class test
+ : public std::ios
+{
+public:
+ test()
+ {
+ init(0);
+ }
+};
+
+bool f1_called = false;
+bool f2_called = false;
+bool f3_called = false;
+
+void f1(std::ios_base::event ev, std::ios_base& stream, int index)
+{
+ if (ev == std::ios_base::imbue_event)
+ {
+ assert(!f1_called);
+ assert( f2_called);
+ assert( f3_called);
+ assert(stream.getloc().name() == LOCALE_en_US_UTF_8);
+ assert(index == 4);
+ f1_called = true;
+ }
+}
+
+void f2(std::ios_base::event ev, std::ios_base& stream, int index)
+{
+ if (ev == std::ios_base::imbue_event)
+ {
+ assert(!f1_called);
+ assert(!f2_called);
+ assert( f3_called);
+ assert(stream.getloc().name() == LOCALE_en_US_UTF_8);
+ assert(index == 5);
+ f2_called = true;
+ }
+}
+
+void f3(std::ios_base::event ev, std::ios_base& stream, int index)
+{
+ if (ev == std::ios_base::imbue_event)
+ {
+ assert(!f1_called);
+ assert(!f2_called);
+ assert(!f3_called);
+ assert(stream.getloc().name() == LOCALE_en_US_UTF_8);
+ assert(index == 6);
+ f3_called = true;
+ }
+}
+
+int main()
+{
+ test t;
+ std::ios_base& b = t;
+ b.register_callback(f1, 4);
+ b.register_callback(f2, 5);
+ b.register_callback(f3, 6);
+ std::locale l = b.imbue(std::locale(LOCALE_en_US_UTF_8));
+ assert(l.name() == std::string("C"));
+ assert(b.getloc().name() == std::string(LOCALE_en_US_UTF_8));
+ assert(f1_called);
+ assert(f2_called);
+ assert(f3_called);
+}
diff --git a/test/std/input.output/iostreams.base/ios.base/ios.base.storage/iword.pass.cpp b/test/std/input.output/iostreams.base/ios.base/ios.base.storage/iword.pass.cpp
new file mode 100644
index 000000000000..1e2ee50632af
--- /dev/null
+++ b/test/std/input.output/iostreams.base/ios.base/ios.base.storage/iword.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// long& iword(int idx);
+
+#include <ios>
+#include <string>
+#include <cassert>
+
+class test
+ : public std::ios
+{
+public:
+ test()
+ {
+ init(0);
+ }
+};
+
+int main()
+{
+ test t;
+ std::ios_base& b = t;
+ for (int i = 0; i < 10000; ++i)
+ {
+ assert(b.iword(i) == 0);
+ b.iword(i) = i;
+ assert(b.iword(i) == i);
+ for (int j = 0; j <= i; ++j)
+ assert(b.iword(j) == j);
+ }
+}
diff --git a/test/std/input.output/iostreams.base/ios.base/ios.base.storage/pword.pass.cpp b/test/std/input.output/iostreams.base/ios.base/ios.base.storage/pword.pass.cpp
new file mode 100644
index 000000000000..5246ad8f644c
--- /dev/null
+++ b/test/std/input.output/iostreams.base/ios.base/ios.base.storage/pword.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// void*& pword(int idx);
+
+#include <ios>
+#include <string>
+#include <cassert>
+#include <cstdint>
+
+class test
+ : public std::ios
+{
+public:
+ test()
+ {
+ init(0);
+ }
+};
+
+int main()
+{
+ test t;
+ std::ios_base& b = t;
+ for (std::intptr_t i = 0; i < 10000; ++i)
+ {
+ assert(b.pword(i) == 0);
+ b.pword(i) = (void*)i;
+ assert(b.pword(i) == (void*)i);
+ for (std::intptr_t j = 0; j <= i; ++j)
+ assert(b.pword(j) == (void*)j);
+ }
+}
diff --git a/test/std/input.output/iostreams.base/ios.base/ios.base.storage/xalloc.pass.cpp b/test/std/input.output/iostreams.base/ios.base/ios.base.storage/xalloc.pass.cpp
new file mode 100644
index 000000000000..eb737b1a7dc1
--- /dev/null
+++ b/test/std/input.output/iostreams.base/ios.base/ios.base.storage/xalloc.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// static int xalloc();
+
+#include <ios>
+#include <cassert>
+
+int main()
+{
+ assert(std::ios_base::xalloc() == 0);
+ assert(std::ios_base::xalloc() == 1);
+ assert(std::ios_base::xalloc() == 2);
+ assert(std::ios_base::xalloc() == 3);
+ assert(std::ios_base::xalloc() == 4);
+}
diff --git a/test/std/input.output/iostreams.base/ios.base/ios.members.static/sync_with_stdio.pass.cpp b/test/std/input.output/iostreams.base/ios.base/ios.members.static/sync_with_stdio.pass.cpp
new file mode 100644
index 000000000000..5dc72b1edc0a
--- /dev/null
+++ b/test/std/input.output/iostreams.base/ios.base/ios.members.static/sync_with_stdio.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// bool sync_with_stdio(bool sync = true);
+
+#include <ios>
+#include <cassert>
+
+int main()
+{
+ assert( std::ios_base::sync_with_stdio(false));
+ assert(!std::ios_base::sync_with_stdio(false));
+ assert(!std::ios_base::sync_with_stdio(true));
+ assert( std::ios_base::sync_with_stdio(true));
+ assert( std::ios_base::sync_with_stdio());
+ assert( std::ios_base::sync_with_stdio(false));
+ assert(!std::ios_base::sync_with_stdio());
+ assert( std::ios_base::sync_with_stdio());
+}
diff --git a/test/std/input.output/iostreams.base/ios.base/ios.types/ios_Init/tested_elsewhere.pass.cpp b/test/std/input.output/iostreams.base/ios.base/ios.types/ios_Init/tested_elsewhere.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/input.output/iostreams.base/ios.base/ios.types/ios_Init/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/input.output/iostreams.base/ios.base/ios.types/ios_failure/ctor_char_pointer_error_code.pass.cpp b/test/std/input.output/iostreams.base/ios.base/ios.types/ios_failure/ctor_char_pointer_error_code.pass.cpp
new file mode 100644
index 000000000000..50f5fdad7442
--- /dev/null
+++ b/test/std/input.output/iostreams.base/ios.base/ios.types/ios_failure/ctor_char_pointer_error_code.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base::failure
+
+// explicit failure(const char* msg, const error_code& ec = io_errc::stream);
+
+#include <ios>
+#include <string>
+#include <cassert>
+
+int main()
+{
+ {
+ std::string what_arg("io test message");
+ std::ios_base::failure se(what_arg.c_str(), make_error_code(std::errc::is_a_directory));
+ assert(se.code() == std::make_error_code(std::errc::is_a_directory));
+ std::string what_message(se.what());
+ assert(what_message.find(what_arg) != std::string::npos);
+ assert(what_message.find("Is a directory") != std::string::npos);
+ }
+ {
+ std::string what_arg("io test message");
+ std::ios_base::failure se(what_arg.c_str());
+ assert(se.code() == std::make_error_code(std::io_errc::stream));
+ std::string what_message(se.what());
+ assert(what_message.find(what_arg) != std::string::npos);
+ assert(what_message.find(std::iostream_category().message(static_cast<int>
+ (std::io_errc::stream))) != std::string::npos);
+ }
+}
diff --git a/test/std/input.output/iostreams.base/ios.base/ios.types/ios_failure/ctor_string_error_code.pass.cpp b/test/std/input.output/iostreams.base/ios.base/ios.types/ios_failure/ctor_string_error_code.pass.cpp
new file mode 100644
index 000000000000..5c9abbe53793
--- /dev/null
+++ b/test/std/input.output/iostreams.base/ios.base/ios.types/ios_failure/ctor_string_error_code.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base::failure
+
+// explicit failure(const string& msg, const error_code& ec = io_errc::stream);
+
+#include <ios>
+#include <string>
+#include <cassert>
+
+int main()
+{
+ {
+ std::string what_arg("io test message");
+ std::ios_base::failure se(what_arg, make_error_code(std::errc::is_a_directory));
+ assert(se.code() == std::make_error_code(std::errc::is_a_directory));
+ std::string what_message(se.what());
+ assert(what_message.find(what_arg) != std::string::npos);
+ assert(what_message.find("Is a directory") != std::string::npos);
+ }
+ {
+ std::string what_arg("io test message");
+ std::ios_base::failure se(what_arg);
+ assert(se.code() == std::make_error_code(std::io_errc::stream));
+ std::string what_message(se.what());
+ assert(what_message.find(what_arg) != std::string::npos);
+ assert(what_message.find(std::iostream_category().message(static_cast<int>
+ (std::io_errc::stream))) != std::string::npos);
+ }
+}
diff --git a/test/std/input.output/iostreams.base/ios.base/ios.types/ios_fmtflags/fmtflags.pass.cpp b/test/std/input.output/iostreams.base/ios.base/ios.types/ios_fmtflags/fmtflags.pass.cpp
new file mode 100644
index 000000000000..9f374598ff7f
--- /dev/null
+++ b/test/std/input.output/iostreams.base/ios.base/ios.types/ios_fmtflags/fmtflags.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// static const fmtflags boolalpha;
+// static const fmtflags dec;
+// static const fmtflags fixed;
+// static const fmtflags hex;
+// static const fmtflags internal;
+// static const fmtflags left;
+// static const fmtflags oct;
+// static const fmtflags right;
+// static const fmtflags scientific;
+// static const fmtflags showbase;
+// static const fmtflags showpoint;
+// static const fmtflags showpos;
+// static const fmtflags skipws;
+// static const fmtflags unitbuf;
+// static const fmtflags uppercase;
+// static const fmtflags adjustfield = left | right | internal;
+// static const fmtflags basefield = dec | oct | hex;
+// static const fmtflags floatfield = scientific | fixed;
+
+#include <ios>
+#include <cassert>
+
+int main()
+{
+ assert(std::ios_base::boolalpha);
+ assert(std::ios_base::dec);
+ assert(std::ios_base::fixed);
+ assert(std::ios_base::hex);
+ assert(std::ios_base::internal);
+ assert(std::ios_base::left);
+ assert(std::ios_base::oct);
+ assert(std::ios_base::right);
+ assert(std::ios_base::scientific);
+ assert(std::ios_base::showbase);
+ assert(std::ios_base::showpoint);
+ assert(std::ios_base::showpos);
+ assert(std::ios_base::skipws);
+ assert(std::ios_base::unitbuf);
+ assert(std::ios_base::uppercase);
+
+ assert
+ (
+ ( std::ios_base::boolalpha
+ & std::ios_base::dec
+ & std::ios_base::fixed
+ & std::ios_base::hex
+ & std::ios_base::internal
+ & std::ios_base::left
+ & std::ios_base::oct
+ & std::ios_base::right
+ & std::ios_base::scientific
+ & std::ios_base::showbase
+ & std::ios_base::showpoint
+ & std::ios_base::showpos
+ & std::ios_base::skipws
+ & std::ios_base::unitbuf
+ & std::ios_base::uppercase) == 0
+ );
+
+ assert(std::ios_base::adjustfield == (std::ios_base::left
+ | std::ios_base::right
+ | std::ios_base::internal));
+ assert(std::ios_base::basefield == (std::ios_base::dec
+ | std::ios_base::oct
+ | std::ios_base::hex));
+ assert(std::ios_base::floatfield == (std::ios_base::scientific
+ | std::ios_base::fixed));
+}
diff --git a/test/std/input.output/iostreams.base/ios.base/ios.types/ios_iostate/iostate.pass.cpp b/test/std/input.output/iostreams.base/ios.base/ios.types/ios_iostate/iostate.pass.cpp
new file mode 100644
index 000000000000..55c02f38ce9f
--- /dev/null
+++ b/test/std/input.output/iostreams.base/ios.base/ios.types/ios_iostate/iostate.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// static const iostate badbit;
+// static const iostate eofbit;
+// static const iostate failbit;
+// static const iostate goodbit = 0;
+
+#include <ios>
+#include <cassert>
+
+int main()
+{
+ assert(std::ios_base::badbit);
+ assert(std::ios_base::eofbit);
+ assert(std::ios_base::failbit);
+
+ assert
+ (
+ ( std::ios_base::badbit
+ & std::ios_base::eofbit
+ & std::ios_base::failbit) == 0
+ );
+
+ assert(std::ios_base::goodbit == 0);
+}
diff --git a/test/std/input.output/iostreams.base/ios.base/ios.types/ios_openmode/openmode.pass.cpp b/test/std/input.output/iostreams.base/ios.base/ios.types/ios_openmode/openmode.pass.cpp
new file mode 100644
index 000000000000..238593feb304
--- /dev/null
+++ b/test/std/input.output/iostreams.base/ios.base/ios.types/ios_openmode/openmode.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// static const openmode app;
+// static const openmode ate;
+// static const openmode binary;
+// static const openmode in;
+// static const openmode out;
+// static const openmode trunc;
+
+#include <ios>
+#include <cassert>
+
+int main()
+{
+ assert(std::ios_base::app);
+ assert(std::ios_base::ate);
+ assert(std::ios_base::binary);
+ assert(std::ios_base::in);
+ assert(std::ios_base::out);
+ assert(std::ios_base::trunc);
+
+ assert
+ (
+ ( std::ios_base::app
+ & std::ios_base::ate
+ & std::ios_base::binary
+ & std::ios_base::in
+ & std::ios_base::out
+ & std::ios_base::trunc) == 0
+ );
+}
diff --git a/test/std/input.output/iostreams.base/ios.base/ios.types/ios_seekdir/seekdir.pass.cpp b/test/std/input.output/iostreams.base/ios.base/ios.types/ios_seekdir/seekdir.pass.cpp
new file mode 100644
index 000000000000..005fb61cc31d
--- /dev/null
+++ b/test/std/input.output/iostreams.base/ios.base/ios.types/ios_seekdir/seekdir.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// static const seekdir beg;
+// static const seekdir cur;
+// static const seekdir end;
+
+#include <ios>
+#include <cassert>
+
+int main()
+{
+ assert(std::ios_base::beg != std::ios_base::cur);
+ assert(std::ios_base::beg != std::ios_base::end);
+ assert(std::ios_base::cur != std::ios_base::end);
+}
diff --git a/test/std/input.output/iostreams.base/ios.base/ios.types/nothing_to_do.pass.cpp b/test/std/input.output/iostreams.base/ios.base/ios.types/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/input.output/iostreams.base/ios.base/ios.types/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/input.output/iostreams.base/ios.base/nothing_to_do.pass.cpp b/test/std/input.output/iostreams.base/ios.base/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..760bfcb26d2a
--- /dev/null
+++ b/test/std/input.output/iostreams.base/ios.base/nothing_to_do.pass.cpp
@@ -0,0 +1,16 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+#include <ios>
+
+int main()
+{
+}
diff --git a/test/std/input.output/iostreams.base/ios/basic.ios.cons/ctor_streambuf.pass.cpp b/test/std/input.output/iostreams.base/ios/basic.ios.cons/ctor_streambuf.pass.cpp
new file mode 100644
index 000000000000..d86059ea6f7d
--- /dev/null
+++ b/test/std/input.output/iostreams.base/ios/basic.ios.cons/ctor_streambuf.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class charT, class traits> class basic_ios
+
+// explicit basic_ios(basic_streambuf<charT,traits>* sb);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+int main()
+{
+ {
+ std::streambuf* sb = 0;
+ std::basic_ios<char> ios(sb);
+ assert(ios.rdbuf() == sb);
+ assert(ios.tie() == 0);
+ assert(ios.rdstate() == std::ios::badbit);
+ assert(ios.exceptions() == std::ios::goodbit);
+ assert(ios.flags() == (std::ios::skipws | std::ios::dec));
+ assert(ios.width() == 0);
+ assert(ios.precision() == 6);
+ assert(ios.fill() == ' ');
+ assert(ios.getloc() == std::locale());
+ }
+ {
+ std::streambuf* sb = (std::streambuf*)1;
+ std::basic_ios<char> ios(sb);
+ assert(ios.rdbuf() == sb);
+ assert(ios.tie() == 0);
+ assert(ios.rdstate() == std::ios::goodbit);
+ assert(ios.exceptions() == std::ios::goodbit);
+ assert(ios.flags() == (std::ios::skipws | std::ios::dec));
+ assert(ios.width() == 0);
+ assert(ios.precision() == 6);
+ assert(ios.fill() == ' ');
+ assert(ios.getloc() == std::locale());
+ }
+}
diff --git a/test/std/input.output/iostreams.base/ios/basic.ios.members/copyfmt.pass.cpp b/test/std/input.output/iostreams.base/ios/basic.ios.members/copyfmt.pass.cpp
new file mode 100644
index 000000000000..c46e2c054e8f
--- /dev/null
+++ b/test/std/input.output/iostreams.base/ios/basic.ios.members/copyfmt.pass.cpp
@@ -0,0 +1,190 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: locale.en_US.UTF-8
+// REQUIRES: locale.fr_FR.UTF-8
+
+// <ios>
+
+// template <class charT, class traits> class basic_ios
+
+// basic_ios& copyfmt(const basic_ios& rhs);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+struct testbuf
+ : public std::streambuf
+{
+};
+
+bool f1_called = false;
+bool f2_called = false;
+
+bool g1_called = false;
+bool g2_called = false;
+bool g3_called = false;
+
+void f1(std::ios_base::event ev, std::ios_base& stream, int index)
+{
+ if (ev == std::ios_base::erase_event)
+ {
+ assert(!f1_called);
+ assert( f2_called);
+ assert(!g1_called);
+ assert(!g2_called);
+ assert(!g3_called);
+ assert(stream.getloc().name() == LOCALE_en_US_UTF_8);
+ assert(index == 4);
+ f1_called = true;
+ }
+}
+
+void f2(std::ios_base::event ev, std::ios_base& stream, int index)
+{
+ if (ev == std::ios_base::erase_event)
+ {
+ assert(!f1_called);
+ assert(!f2_called);
+ assert(!g1_called);
+ assert(!g2_called);
+ assert(!g3_called);
+ assert(stream.getloc().name() == LOCALE_en_US_UTF_8);
+ assert(index == 5);
+ f2_called = true;
+ }
+}
+
+void g1(std::ios_base::event ev, std::ios_base& stream, int index)
+{
+ if (ev == std::ios_base::copyfmt_event)
+ {
+ assert( f1_called);
+ assert( f2_called);
+ assert(!g1_called);
+ assert( g2_called);
+ assert( g3_called);
+ assert(stream.getloc().name() == LOCALE_fr_FR_UTF_8);
+ assert(index == 7);
+ g1_called = true;
+ }
+}
+
+void g2(std::ios_base::event ev, std::ios_base& stream, int index)
+{
+ if (ev == std::ios_base::copyfmt_event)
+ {
+ assert( f1_called);
+ assert( f2_called);
+ assert(!g1_called);
+ assert(!g2_called);
+ assert( g3_called);
+ assert(stream.getloc().name() == LOCALE_fr_FR_UTF_8);
+ assert(index == 8);
+ g2_called = true;
+ }
+}
+
+void g3(std::ios_base::event ev, std::ios_base& stream, int index)
+{
+ if (ev == std::ios_base::copyfmt_event)
+ {
+ assert( f1_called);
+ assert( f2_called);
+ assert(!g1_called);
+ assert(!g2_called);
+ assert(!g3_called);
+ assert(stream.getloc().name() == LOCALE_fr_FR_UTF_8);
+ assert(index == 9);
+ g3_called = true;
+ }
+}
+
+int main()
+{
+ testbuf sb1;
+ std::ios ios1(&sb1);
+ ios1.flags(std::ios::boolalpha | std::ios::dec | std::ios::fixed);
+ ios1.precision(1);
+ ios1.width(11);
+ ios1.imbue(std::locale(LOCALE_en_US_UTF_8));
+ ios1.exceptions(std::ios::failbit);
+ ios1.setstate(std::ios::eofbit);
+ ios1.register_callback(f1, 4);
+ ios1.register_callback(f2, 5);
+ ios1.iword(0) = 1;
+ ios1.iword(1) = 2;
+ ios1.iword(2) = 3;
+ char c1, c2, c3;
+ ios1.pword(0) = &c1;
+ ios1.pword(1) = &c2;
+ ios1.pword(2) = &c3;
+ ios1.tie((std::ostream*)1);
+ ios1.fill('1');
+
+ testbuf sb2;
+ std::ios ios2(&sb2);
+ ios2.flags(std::ios::showpoint | std::ios::uppercase);
+ ios2.precision(2);
+ ios2.width(12);
+ ios2.imbue(std::locale(LOCALE_fr_FR_UTF_8));
+ ios2.exceptions(std::ios::eofbit);
+ ios2.setstate(std::ios::goodbit);
+ ios2.register_callback(g1, 7);
+ ios2.register_callback(g2, 8);
+ ios2.register_callback(g3, 9);
+ ios2.iword(0) = 4;
+ ios2.iword(1) = 5;
+ ios2.iword(2) = 6;
+ ios2.iword(3) = 7;
+ ios2.iword(4) = 8;
+ ios2.iword(5) = 9;
+ char d1, d2;
+ ios2.pword(0) = &d1;
+ ios2.pword(1) = &d2;
+ ios2.tie((std::ostream*)2);
+ ios2.fill('2');
+
+ ios1.copyfmt(ios1);
+ assert(!f1_called);
+
+ try
+ {
+ ios1.copyfmt(ios2);
+ assert(false);
+ }
+ catch (std::ios_base::failure&)
+ {
+ }
+ assert(ios1.rdstate() == std::ios::eofbit);
+ assert(ios1.rdbuf() == &sb1);
+ assert(ios1.flags() == (std::ios::showpoint | std::ios::uppercase));
+ assert(ios1.precision() == 2);
+ assert(ios1.width() == 12);
+ assert(ios1.getloc().name() == LOCALE_fr_FR_UTF_8);
+ assert(ios1.exceptions() == std::ios::eofbit);
+ assert(f1_called);
+ assert(f2_called);
+ assert(g1_called);
+ assert(g2_called);
+ assert(g3_called);
+ assert(ios1.iword(0) == 4);
+ assert(ios1.iword(1) == 5);
+ assert(ios1.iword(2) == 6);
+ assert(ios1.iword(3) == 7);
+ assert(ios1.iword(4) == 8);
+ assert(ios1.iword(5) == 9);
+ assert(ios1.pword(0) == &d1);
+ assert(ios1.pword(1) == &d2);
+ assert(ios1.tie() == (std::ostream*)2);
+ assert(ios1.fill() == '2');
+}
diff --git a/test/std/input.output/iostreams.base/ios/basic.ios.members/fill.pass.cpp b/test/std/input.output/iostreams.base/ios/basic.ios.members/fill.pass.cpp
new file mode 100644
index 000000000000..f5c5aa22b65b
--- /dev/null
+++ b/test/std/input.output/iostreams.base/ios/basic.ios.members/fill.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class charT, class traits> class basic_ios
+
+// char_type fill() const;
+
+#include <ios>
+#include <cassert>
+
+int main()
+{
+ const std::ios ios(0);
+ assert(ios.fill() == ' ');
+}
diff --git a/test/std/input.output/iostreams.base/ios/basic.ios.members/fill_char_type.pass.cpp b/test/std/input.output/iostreams.base/ios/basic.ios.members/fill_char_type.pass.cpp
new file mode 100644
index 000000000000..10dccca8583e
--- /dev/null
+++ b/test/std/input.output/iostreams.base/ios/basic.ios.members/fill_char_type.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class charT, class traits> class basic_ios
+
+// char_type fill(char_type fillch);
+
+#include <ios>
+#include <cassert>
+
+int main()
+{
+ std::ios ios(0);
+ assert(ios.fill() == ' ');
+ char c = ios.fill('*');
+ assert(c == ' ');
+ assert(ios.fill() == '*');
+}
diff --git a/test/std/input.output/iostreams.base/ios/basic.ios.members/imbue.pass.cpp b/test/std/input.output/iostreams.base/ios/basic.ios.members/imbue.pass.cpp
new file mode 100644
index 000000000000..6d4ce5f577f4
--- /dev/null
+++ b/test/std/input.output/iostreams.base/ios/basic.ios.members/imbue.pass.cpp
@@ -0,0 +1,101 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class charT, class traits> class basic_ios
+
+// locale imbue(const locale& loc);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+struct testbuf
+ : public std::streambuf
+{
+};
+
+bool f1_called = false;
+bool f2_called = false;
+bool f3_called = false;
+
+void f1(std::ios_base::event ev, std::ios_base& stream, int index)
+{
+ if (ev == std::ios_base::imbue_event)
+ {
+ assert(!f1_called);
+ assert( f2_called);
+ assert( f3_called);
+ assert(stream.getloc().name() == LOCALE_en_US_UTF_8);
+ assert(index == 4);
+ f1_called = true;
+ }
+}
+
+void f2(std::ios_base::event ev, std::ios_base& stream, int index)
+{
+ if (ev == std::ios_base::imbue_event)
+ {
+ assert(!f1_called);
+ assert(!f2_called);
+ assert( f3_called);
+ assert(stream.getloc().name() == LOCALE_en_US_UTF_8);
+ assert(index == 5);
+ f2_called = true;
+ }
+}
+
+void f3(std::ios_base::event ev, std::ios_base& stream, int index)
+{
+ if (ev == std::ios_base::imbue_event)
+ {
+ assert(!f1_called);
+ assert(!f2_called);
+ assert(!f3_called);
+ assert(stream.getloc().name() == LOCALE_en_US_UTF_8);
+ assert(index == 6);
+ f3_called = true;
+ }
+}
+
+int main()
+{
+ {
+ std::ios ios(0);
+ ios.register_callback(f1, 4);
+ ios.register_callback(f2, 5);
+ ios.register_callback(f3, 6);
+ std::locale l = ios.imbue(std::locale(LOCALE_en_US_UTF_8));
+ assert(l.name() == std::string("C"));
+ assert(ios.getloc().name() == std::string(LOCALE_en_US_UTF_8));
+ assert(f1_called);
+ assert(f2_called);
+ assert(f3_called);
+ }
+ f1_called = false;
+ f2_called = false;
+ f3_called = false;
+ {
+ testbuf sb;
+ std::ios ios(&sb);
+ ios.register_callback(f1, 4);
+ ios.register_callback(f2, 5);
+ ios.register_callback(f3, 6);
+ std::locale l = ios.imbue(std::locale(LOCALE_en_US_UTF_8));
+ assert(l.name() == std::string("C"));
+ assert(ios.getloc().name() == std::string(LOCALE_en_US_UTF_8));
+ assert(sb.getloc().name() == std::string(LOCALE_en_US_UTF_8));
+ assert(f1_called);
+ assert(f2_called);
+ assert(f3_called);
+ }
+}
diff --git a/test/std/input.output/iostreams.base/ios/basic.ios.members/move.pass.cpp b/test/std/input.output/iostreams.base/ios/basic.ios.members/move.pass.cpp
new file mode 100644
index 000000000000..509b836686c5
--- /dev/null
+++ b/test/std/input.output/iostreams.base/ios/basic.ios.members/move.pass.cpp
@@ -0,0 +1,140 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: locale.fr_FR.UTF-8
+
+// <ios>
+
+// template <class charT, class traits> class basic_ios
+
+// void move(basic_ios&& rhs);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+struct testbuf
+ : public std::streambuf
+{
+};
+
+struct testios
+ : public std::ios
+{
+ testios() {}
+ testios(std::streambuf* p) : std::ios(p) {}
+ void move(std::ios& x) {std::ios::move(x);}
+};
+
+bool f1_called = false;
+bool f2_called = false;
+
+bool g1_called = false;
+bool g2_called = false;
+bool g3_called = false;
+
+void f1(std::ios_base::event ev, std::ios_base& stream, int index)
+{
+ f1_called = true;
+}
+
+void f2(std::ios_base::event ev, std::ios_base& stream, int index)
+{
+ f2_called = true;
+}
+
+void g1(std::ios_base::event ev, std::ios_base& stream, int index)
+{
+ if (ev == std::ios_base::imbue_event)
+ {
+ assert(index == 7);
+ g1_called = true;
+ }
+}
+
+void g2(std::ios_base::event ev, std::ios_base& stream, int index)
+{
+ if (ev == std::ios_base::imbue_event)
+ {
+ assert(index == 8);
+ g2_called = true;
+ }
+}
+
+void g3(std::ios_base::event ev, std::ios_base& stream, int index)
+{
+ if (ev == std::ios_base::imbue_event)
+ {
+ assert(index == 9);
+ g3_called = true;
+ }
+}
+
+int main()
+{
+ testios ios1;
+ testbuf sb2;
+ std::ios ios2(&sb2);
+ ios2.flags(std::ios::showpoint | std::ios::uppercase);
+ ios2.precision(2);
+ ios2.width(12);
+ ios2.imbue(std::locale(LOCALE_fr_FR_UTF_8));
+ ios2.exceptions(std::ios::eofbit);
+ ios2.setstate(std::ios::goodbit);
+ ios2.register_callback(g1, 7);
+ ios2.register_callback(g2, 8);
+ ios2.register_callback(g3, 9);
+ ios2.iword(0) = 4;
+ ios2.iword(1) = 5;
+ ios2.iword(2) = 6;
+ ios2.iword(3) = 7;
+ ios2.iword(4) = 8;
+ ios2.iword(5) = 9;
+ char d1, d2;
+ ios2.pword(0) = &d1;
+ ios2.pword(1) = &d2;
+ ios2.tie((std::ostream*)2);
+ ios2.fill('2');
+
+ ios1.move(ios2);
+
+ assert(ios1.rdstate() == std::ios::goodbit);
+ assert(ios1.rdbuf() == 0);
+ assert(ios1.flags() == (std::ios::showpoint | std::ios::uppercase));
+ assert(ios1.precision() == 2);
+ assert(ios1.width() == 12);
+ assert(ios1.getloc().name() == LOCALE_fr_FR_UTF_8);
+ assert(ios1.exceptions() == std::ios::eofbit);
+ assert(!f1_called);
+ assert(!f2_called);
+ assert(!g1_called);
+ assert(!g2_called);
+ assert(!g3_called);
+ assert(ios1.iword(0) == 4);
+ assert(ios1.iword(1) == 5);
+ assert(ios1.iword(2) == 6);
+ assert(ios1.iword(3) == 7);
+ assert(ios1.iword(4) == 8);
+ assert(ios1.iword(5) == 9);
+ assert(ios1.pword(0) == &d1);
+ assert(ios1.pword(1) == &d2);
+ assert(ios1.tie() == (std::ostream*)2);
+ assert(ios1.fill() == '2');
+ ios1.imbue(std::locale("C"));
+ assert(!f1_called);
+ assert(!f2_called);
+ assert(g1_called);
+ assert(g2_called);
+ assert(g3_called);
+
+ assert(ios2.rdbuf() == &sb2);
+ assert(ios2.tie() == 0);
+}
diff --git a/test/std/input.output/iostreams.base/ios/basic.ios.members/narow.pass.cpp b/test/std/input.output/iostreams.base/ios/basic.ios.members/narow.pass.cpp
new file mode 100644
index 000000000000..bf865e68149d
--- /dev/null
+++ b/test/std/input.output/iostreams.base/ios/basic.ios.members/narow.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class charT, class traits> class basic_ios
+
+// char narrow(char_type c, char dfault) const;
+
+#include <ios>
+#include <cassert>
+
+int main()
+{
+ const std::ios ios(0);
+ assert(ios.narrow('c', '*') == 'c');
+ assert(ios.narrow('\xFE', '*') == '*');
+}
diff --git a/test/std/input.output/iostreams.base/ios/basic.ios.members/rdbuf.pass.cpp b/test/std/input.output/iostreams.base/ios/basic.ios.members/rdbuf.pass.cpp
new file mode 100644
index 000000000000..7be92e72b869
--- /dev/null
+++ b/test/std/input.output/iostreams.base/ios/basic.ios.members/rdbuf.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class charT, class traits> class basic_ios
+
+// basic_streambuf<charT,traits>* rdbuf() const;
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+int main()
+{
+ {
+ const std::ios ios(0);
+ assert(ios.rdbuf() == 0);
+ }
+ {
+ std::streambuf* sb = (std::streambuf*)1;
+ const std::ios ios(sb);
+ assert(ios.rdbuf() == sb);
+ }
+}
diff --git a/test/std/input.output/iostreams.base/ios/basic.ios.members/rdbuf_streambuf.pass.cpp b/test/std/input.output/iostreams.base/ios/basic.ios.members/rdbuf_streambuf.pass.cpp
new file mode 100644
index 000000000000..cc0b3f3f169b
--- /dev/null
+++ b/test/std/input.output/iostreams.base/ios/basic.ios.members/rdbuf_streambuf.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class charT, class traits> class basic_ios
+
+// basic_streambuf<charT,traits>* rdbuf(basic_streambuf<charT,traits>* sb);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+int main()
+{
+ std::ios ios(0);
+ assert(ios.rdbuf() == 0);
+ assert(!ios.good());
+ std::streambuf* sb = (std::streambuf*)1;
+ std::streambuf* sb2 = ios.rdbuf(sb);
+ assert(sb2 == 0);
+ assert(ios.rdbuf() == sb);
+ assert(ios.good());
+ sb2 = ios.rdbuf(0);
+ assert(sb2 == (std::streambuf*)1);
+ assert(ios.rdbuf() == 0);
+ assert(ios.bad());
+}
diff --git a/test/std/input.output/iostreams.base/ios/basic.ios.members/set_rdbuf.pass.cpp b/test/std/input.output/iostreams.base/ios/basic.ios.members/set_rdbuf.pass.cpp
new file mode 100644
index 000000000000..2d4beee37ec2
--- /dev/null
+++ b/test/std/input.output/iostreams.base/ios/basic.ios.members/set_rdbuf.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class charT, class traits> class basic_ios
+
+// void set_rdbuf(basic_streambuf<charT, traits>* sb);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf
+ : public std::streambuf
+{
+};
+
+struct testios
+ : public std::ios
+{
+ testios(std::streambuf* p) : std::ios(p) {}
+ void set_rdbuf(std::streambuf* x) {std::ios::set_rdbuf(x);}
+};
+
+int main()
+{
+ testbuf sb1;
+ testbuf sb2;
+ testios ios(&sb1);
+ try
+ {
+ ios.setstate(std::ios::badbit);
+ ios.exceptions(std::ios::badbit);
+ }
+ catch (...)
+ {
+ }
+ ios.set_rdbuf(&sb2);
+ assert(ios.rdbuf() == &sb2);
+ try
+ {
+ ios.setstate(std::ios::badbit);
+ ios.exceptions(std::ios::badbit);
+ }
+ catch (...)
+ {
+ }
+ ios.set_rdbuf(0);
+ assert(ios.rdbuf() == 0);
+}
diff --git a/test/std/input.output/iostreams.base/ios/basic.ios.members/swap.pass.cpp b/test/std/input.output/iostreams.base/ios/basic.ios.members/swap.pass.cpp
new file mode 100644
index 000000000000..e44f4b32512c
--- /dev/null
+++ b/test/std/input.output/iostreams.base/ios/basic.ios.members/swap.pass.cpp
@@ -0,0 +1,168 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: locale.en_US.UTF-8
+// REQUIRES: locale.fr_FR.UTF-8
+
+// <ios>
+
+// template <class charT, class traits> class basic_ios
+
+// void move(basic_ios&& rhs);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+struct testbuf
+ : public std::streambuf
+{
+};
+
+struct testios
+ : public std::ios
+{
+ testios(std::streambuf* p) : std::ios(p) {}
+ void swap(std::ios& x) {std::ios::swap(x);}
+};
+
+bool f1_called = false;
+bool f2_called = false;
+
+bool g1_called = false;
+bool g2_called = false;
+bool g3_called = false;
+
+void f1(std::ios_base::event ev, std::ios_base& stream, int index)
+{
+ assert(index == 4);
+ f1_called = true;
+}
+
+void f2(std::ios_base::event ev, std::ios_base& stream, int index)
+{
+ assert(index == 5);
+ f2_called = true;
+}
+
+void g1(std::ios_base::event ev, std::ios_base& stream, int index)
+{
+ assert(index == 7);
+ g1_called = true;
+}
+
+void g2(std::ios_base::event ev, std::ios_base& stream, int index)
+{
+ assert(index == 8);
+ g2_called = true;
+}
+
+void g3(std::ios_base::event ev, std::ios_base& stream, int index)
+{
+ assert(index == 9);
+ g3_called = true;
+}
+
+int main()
+{
+ testbuf sb1;
+ testios ios1(&sb1);
+ ios1.flags(std::ios::boolalpha | std::ios::dec | std::ios::fixed);
+ ios1.precision(1);
+ ios1.width(11);
+ ios1.imbue(std::locale(LOCALE_en_US_UTF_8));
+ ios1.exceptions(std::ios::failbit);
+ ios1.setstate(std::ios::eofbit);
+ ios1.register_callback(f1, 4);
+ ios1.register_callback(f2, 5);
+ ios1.iword(0) = 1;
+ ios1.iword(1) = 2;
+ ios1.iword(2) = 3;
+ char c1, c2, c3;
+ ios1.pword(0) = &c1;
+ ios1.pword(1) = &c2;
+ ios1.pword(2) = &c3;
+ ios1.tie((std::ostream*)1);
+ ios1.fill('1');
+
+ testbuf sb2;
+ testios ios2(&sb2);
+ ios2.flags(std::ios::showpoint | std::ios::uppercase);
+ ios2.precision(2);
+ ios2.width(12);
+ ios2.imbue(std::locale(LOCALE_fr_FR_UTF_8));
+ ios2.exceptions(std::ios::eofbit);
+ ios2.setstate(std::ios::goodbit);
+ ios2.register_callback(g1, 7);
+ ios2.register_callback(g2, 8);
+ ios2.register_callback(g3, 9);
+ ios2.iword(0) = 4;
+ ios2.iword(1) = 5;
+ ios2.iword(2) = 6;
+ ios2.iword(3) = 7;
+ ios2.iword(4) = 8;
+ ios2.iword(5) = 9;
+ char d1, d2;
+ ios2.pword(0) = &d1;
+ ios2.pword(1) = &d2;
+ ios2.tie((std::ostream*)2);
+ ios2.fill('2');
+
+ ios1.swap(ios2);
+
+ assert(ios1.rdstate() == std::ios::goodbit);
+ assert(ios1.rdbuf() == &sb1);
+ assert(ios1.flags() == (std::ios::showpoint | std::ios::uppercase));
+ assert(ios1.precision() == 2);
+ assert(ios1.width() == 12);
+ assert(ios1.getloc().name() == LOCALE_fr_FR_UTF_8);
+ assert(ios1.exceptions() == std::ios::eofbit);
+ assert(!f1_called);
+ assert(!f2_called);
+ assert(!g1_called);
+ assert(!g2_called);
+ assert(!g3_called);
+ assert(ios1.iword(0) == 4);
+ assert(ios1.iword(1) == 5);
+ assert(ios1.iword(2) == 6);
+ assert(ios1.iword(3) == 7);
+ assert(ios1.iword(4) == 8);
+ assert(ios1.iword(5) == 9);
+ assert(ios1.pword(0) == &d1);
+ assert(ios1.pword(1) == &d2);
+ assert(ios1.tie() == (std::ostream*)2);
+ assert(ios1.fill() == '2');
+ ios1.imbue(std::locale("C"));
+ assert(!f1_called);
+ assert(!f2_called);
+ assert(g1_called);
+ assert(g2_called);
+ assert(g3_called);
+
+ assert(ios2.rdstate() == std::ios::eofbit);
+ assert(ios2.rdbuf() == &sb2);
+ assert(ios2.flags() == (std::ios::boolalpha | std::ios::dec | std::ios::fixed));
+ assert(ios2.precision() == 1);
+ assert(ios2.width() == 11);
+ assert(ios2.getloc().name() == LOCALE_en_US_UTF_8);
+ assert(ios2.exceptions() == std::ios::failbit);
+ assert(ios2.iword(0) == 1);
+ assert(ios2.iword(1) == 2);
+ assert(ios2.iword(2) == 3);
+ assert(ios2.pword(0) == &c1);
+ assert(ios2.pword(1) == &c2);
+ assert(ios2.pword(2) == &c3);
+ assert(ios2.tie() == (std::ostream*)1);
+ assert(ios2.fill() == '1');
+ ios2.imbue(std::locale("C"));
+ assert(f1_called);
+ assert(f2_called);
+}
diff --git a/test/std/input.output/iostreams.base/ios/basic.ios.members/tie.pass.cpp b/test/std/input.output/iostreams.base/ios/basic.ios.members/tie.pass.cpp
new file mode 100644
index 000000000000..71eb238469c9
--- /dev/null
+++ b/test/std/input.output/iostreams.base/ios/basic.ios.members/tie.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class charT, class traits> class basic_ios
+
+// basic_ostream<charT,traits>* tie() const;
+
+#include <ios>
+#include <cassert>
+
+int main()
+{
+ const std::basic_ios<char> ios(0);
+ assert(ios.tie() == 0);
+}
diff --git a/test/std/input.output/iostreams.base/ios/basic.ios.members/tie_ostream.pass.cpp b/test/std/input.output/iostreams.base/ios/basic.ios.members/tie_ostream.pass.cpp
new file mode 100644
index 000000000000..acccbea2aa06
--- /dev/null
+++ b/test/std/input.output/iostreams.base/ios/basic.ios.members/tie_ostream.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class charT, class traits> class basic_ios
+
+// basic_ostream<charT,traits>* tie(basic_ostream<charT,traits>* tiestr);
+
+#include <ios>
+#include <cassert>
+
+int main()
+{
+ std::ios ios(0);
+ std::ostream* os = (std::ostream*)1;
+ std::ostream* r = ios.tie(os);
+ assert(r == 0);
+ assert(ios.tie() == os);
+}
diff --git a/test/std/input.output/iostreams.base/ios/basic.ios.members/widen.pass.cpp b/test/std/input.output/iostreams.base/ios/basic.ios.members/widen.pass.cpp
new file mode 100644
index 000000000000..68fdf6859899
--- /dev/null
+++ b/test/std/input.output/iostreams.base/ios/basic.ios.members/widen.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class charT, class traits> class basic_ios
+
+// char_type widen(char c) const;
+
+#include <ios>
+#include <cassert>
+
+int main()
+{
+ const std::ios ios(0);
+ assert(ios.widen('c') == 'c');
+}
diff --git a/test/std/input.output/iostreams.base/ios/iostate.flags/bad.pass.cpp b/test/std/input.output/iostreams.base/ios/iostate.flags/bad.pass.cpp
new file mode 100644
index 000000000000..1005df6ef258
--- /dev/null
+++ b/test/std/input.output/iostreams.base/ios/iostate.flags/bad.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class charT, class traits> class basic_ios
+
+// bool bad() const;
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+ {
+ std::ios ios(0);
+ assert(ios.bad());
+ ios.setstate(std::ios::eofbit);
+ assert(ios.bad());
+ }
+ {
+ testbuf sb;
+ std::ios ios(&sb);
+ assert(!ios.bad());
+ ios.setstate(std::ios::eofbit);
+ assert(!ios.bad());
+ ios.setstate(std::ios::failbit);
+ assert(!ios.bad());
+ ios.setstate(std::ios::badbit);
+ assert(ios.bad());
+ }
+}
diff --git a/test/std/input.output/iostreams.base/ios/iostate.flags/bool.pass.cpp b/test/std/input.output/iostreams.base/ios/iostate.flags/bool.pass.cpp
new file mode 100644
index 000000000000..0de889e549cc
--- /dev/null
+++ b/test/std/input.output/iostreams.base/ios/iostate.flags/bool.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class charT, class traits> class basic_ios
+
+// operator unspecified-bool-type() const;
+
+#include <ios>
+#include <cassert>
+
+int main()
+{
+ std::ios ios(0);
+ assert(static_cast<bool>(ios) == !ios.fail());
+ ios.setstate(std::ios::failbit);
+ assert(static_cast<bool>(ios) == !ios.fail());
+}
diff --git a/test/std/input.output/iostreams.base/ios/iostate.flags/clear.pass.cpp b/test/std/input.output/iostreams.base/ios/iostate.flags/clear.pass.cpp
new file mode 100644
index 000000000000..0c2e8f0860ce
--- /dev/null
+++ b/test/std/input.output/iostreams.base/ios/iostate.flags/clear.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class charT, class traits> class basic_ios
+
+// void clear(iostate state = goodbit);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+ {
+ std::ios ios(0);
+ ios.clear();
+ assert(ios.rdstate() == std::ios::badbit);
+ try
+ {
+ ios.exceptions(std::ios::badbit);
+ }
+ catch (...)
+ {
+ }
+ try
+ {
+ ios.clear();
+ assert(false);
+ }
+ catch (std::ios::failure&)
+ {
+ assert(ios.rdstate() == std::ios::badbit);
+ }
+ try
+ {
+ ios.clear(std::ios::eofbit);
+ assert(false);
+ }
+ catch (std::ios::failure&)
+ {
+ assert(ios.rdstate() == (std::ios::eofbit | std::ios::badbit));
+ }
+ }
+ {
+ testbuf sb;
+ std::ios ios(&sb);
+ ios.clear();
+ assert(ios.rdstate() == std::ios::goodbit);
+ ios.exceptions(std::ios::badbit);
+ ios.clear();
+ assert(ios.rdstate() == std::ios::goodbit);
+ ios.clear(std::ios::eofbit);
+ assert(ios.rdstate() == std::ios::eofbit);
+ }
+}
diff --git a/test/std/input.output/iostreams.base/ios/iostate.flags/eof.pass.cpp b/test/std/input.output/iostreams.base/ios/iostate.flags/eof.pass.cpp
new file mode 100644
index 000000000000..64d5a3018d15
--- /dev/null
+++ b/test/std/input.output/iostreams.base/ios/iostate.flags/eof.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class charT, class traits> class basic_ios
+
+// bool eof() const;
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+ {
+ std::ios ios(0);
+ assert(!ios.eof());
+ ios.setstate(std::ios::eofbit);
+ assert(ios.eof());
+ }
+ {
+ testbuf sb;
+ std::ios ios(&sb);
+ assert(!ios.eof());
+ ios.setstate(std::ios::eofbit);
+ assert(ios.eof());
+ }
+}
diff --git a/test/std/input.output/iostreams.base/ios/iostate.flags/exceptions.pass.cpp b/test/std/input.output/iostreams.base/ios/iostate.flags/exceptions.pass.cpp
new file mode 100644
index 000000000000..d5158a184683
--- /dev/null
+++ b/test/std/input.output/iostreams.base/ios/iostate.flags/exceptions.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class charT, class traits> class basic_ios
+
+// iostate exceptions() const;
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+ {
+ const std::ios ios(0);
+ assert(ios.exceptions() == std::ios::goodbit);
+ }
+ {
+ testbuf sb;
+ const std::ios ios(&sb);
+ assert(ios.exceptions() == std::ios::goodbit);
+ }
+}
diff --git a/test/std/input.output/iostreams.base/ios/iostate.flags/exceptions_iostate.pass.cpp b/test/std/input.output/iostreams.base/ios/iostate.flags/exceptions_iostate.pass.cpp
new file mode 100644
index 000000000000..a0013eabdac6
--- /dev/null
+++ b/test/std/input.output/iostreams.base/ios/iostate.flags/exceptions_iostate.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class charT, class traits> class basic_ios
+
+// iostate exceptions() const;
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+ {
+ std::ios ios(0);
+ assert(ios.exceptions() == std::ios::goodbit);
+ ios.exceptions(std::ios::eofbit);
+ assert(ios.exceptions() == std::ios::eofbit);
+ try
+ {
+ ios.exceptions(std::ios::badbit);
+ assert(false);
+ }
+ catch (std::ios::failure&)
+ {
+ }
+ assert(ios.exceptions() == std::ios::badbit);
+ }
+ {
+ testbuf sb;
+ std::ios ios(&sb);
+ assert(ios.exceptions() == std::ios::goodbit);
+ ios.exceptions(std::ios::eofbit);
+ assert(ios.exceptions() == std::ios::eofbit);
+ ios.exceptions(std::ios::badbit);
+ assert(ios.exceptions() == std::ios::badbit);
+ }
+}
diff --git a/test/std/input.output/iostreams.base/ios/iostate.flags/fail.pass.cpp b/test/std/input.output/iostreams.base/ios/iostate.flags/fail.pass.cpp
new file mode 100644
index 000000000000..fa9f765bfd59
--- /dev/null
+++ b/test/std/input.output/iostreams.base/ios/iostate.flags/fail.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class charT, class traits> class basic_ios
+
+// bool fail() const;
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+ {
+ std::ios ios(0);
+ assert(ios.fail());
+ ios.setstate(std::ios::eofbit);
+ assert(ios.fail());
+ }
+ {
+ testbuf sb;
+ std::ios ios(&sb);
+ assert(!ios.fail());
+ ios.setstate(std::ios::eofbit);
+ assert(!ios.fail());
+ ios.setstate(std::ios::badbit);
+ assert(ios.fail());
+ ios.setstate(std::ios::failbit);
+ assert(ios.fail());
+ }
+}
diff --git a/test/std/input.output/iostreams.base/ios/iostate.flags/good.pass.cpp b/test/std/input.output/iostreams.base/ios/iostate.flags/good.pass.cpp
new file mode 100644
index 000000000000..03f89506d6fd
--- /dev/null
+++ b/test/std/input.output/iostreams.base/ios/iostate.flags/good.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class charT, class traits> class basic_ios
+
+// bool good() const;
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+ {
+ std::ios ios(0);
+ assert(!ios.good());
+ }
+ {
+ testbuf sb;
+ std::ios ios(&sb);
+ assert(ios.good());
+ ios.setstate(std::ios::eofbit);
+ assert(!ios.good());
+ }
+}
diff --git a/test/std/input.output/iostreams.base/ios/iostate.flags/not.pass.cpp b/test/std/input.output/iostreams.base/ios/iostate.flags/not.pass.cpp
new file mode 100644
index 000000000000..ef534f6d0adf
--- /dev/null
+++ b/test/std/input.output/iostreams.base/ios/iostate.flags/not.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class charT, class traits> class basic_ios
+
+// bool operator!() const;
+
+#include <ios>
+#include <cassert>
+
+int main()
+{
+ std::ios ios(0);
+ assert(!ios == ios.fail());
+ ios.setstate(std::ios::failbit);
+ assert(!ios == ios.fail());
+}
diff --git a/test/std/input.output/iostreams.base/ios/iostate.flags/rdstate.pass.cpp b/test/std/input.output/iostreams.base/ios/iostate.flags/rdstate.pass.cpp
new file mode 100644
index 000000000000..d09e2a62ee3d
--- /dev/null
+++ b/test/std/input.output/iostreams.base/ios/iostate.flags/rdstate.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class charT, class traits> class basic_ios
+
+// iostate rdstate() const;
+
+#include <ios>
+#include <cassert>
+
+int main()
+{
+ std::ios ios(0);
+ assert(ios.rdstate() == std::ios::badbit);
+ ios.setstate(std::ios::failbit);
+ assert(ios.rdstate() == (std::ios::failbit | std::ios::badbit));
+}
diff --git a/test/std/input.output/iostreams.base/ios/iostate.flags/setstate.pass.cpp b/test/std/input.output/iostreams.base/ios/iostate.flags/setstate.pass.cpp
new file mode 100644
index 000000000000..b3c66c487e9f
--- /dev/null
+++ b/test/std/input.output/iostreams.base/ios/iostate.flags/setstate.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class charT, class traits> class basic_ios
+
+// void setstate(iostate state);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+ {
+ std::ios ios(0);
+ ios.setstate(std::ios::goodbit);
+ assert(ios.rdstate() == std::ios::badbit);
+ try
+ {
+ ios.exceptions(std::ios::badbit);
+ }
+ catch (...)
+ {
+ }
+ try
+ {
+ ios.setstate(std::ios::goodbit);
+ assert(false);
+ }
+ catch (std::ios::failure&)
+ {
+ assert(ios.rdstate() == std::ios::badbit);
+ }
+ try
+ {
+ ios.setstate(std::ios::eofbit);
+ assert(false);
+ }
+ catch (std::ios::failure&)
+ {
+ assert(ios.rdstate() == (std::ios::eofbit | std::ios::badbit));
+ }
+ }
+ {
+ testbuf sb;
+ std::ios ios(&sb);
+ ios.setstate(std::ios::goodbit);
+ assert(ios.rdstate() == std::ios::goodbit);
+ ios.setstate(std::ios::eofbit);
+ assert(ios.rdstate() == std::ios::eofbit);
+ ios.setstate(std::ios::failbit);
+ assert(ios.rdstate() == (std::ios::eofbit | std::ios::failbit));
+ }
+}
diff --git a/test/std/input.output/iostreams.base/ios/types.pass.cpp b/test/std/input.output/iostreams.base/ios/types.pass.cpp
new file mode 100644
index 000000000000..22e33f61f428
--- /dev/null
+++ b/test/std/input.output/iostreams.base/ios/types.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ios : public ios_base
+// {
+// public:
+// typedef charT char_type;
+// typedef typename traits::int_type int_type;
+// typedef typename traits::pos_type pos_type;
+// typedef typename traits::off_type off_type;
+// typedef traits traits_type;
+
+#include <ios>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_base_of<std::ios_base, std::basic_ios<char> >::value), "");
+ static_assert((std::is_same<std::basic_ios<char>::char_type, char>::value), "");
+ static_assert((std::is_same<std::basic_ios<char>::traits_type, std::char_traits<char> >::value), "");
+ static_assert((std::is_same<std::basic_ios<char>::int_type, std::char_traits<char>::int_type>::value), "");
+ static_assert((std::is_same<std::basic_ios<char>::pos_type, std::char_traits<char>::pos_type>::value), "");
+ static_assert((std::is_same<std::basic_ios<char>::off_type, std::char_traits<char>::off_type>::value), "");
+}
diff --git a/test/std/input.output/iostreams.base/std.ios.manip/adjustfield.manip/internal.pass.cpp b/test/std/input.output/iostreams.base/std.ios.manip/adjustfield.manip/internal.pass.cpp
new file mode 100644
index 000000000000..461c7774248e
--- /dev/null
+++ b/test/std/input.output/iostreams.base/std.ios.manip/adjustfield.manip/internal.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// ios_base& internal(ios_base& str);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+ testbuf sb;
+ std::ios ios(&sb);
+ std::ios_base& r = std::internal(ios);
+ assert(&r == &ios);
+ assert(ios.flags() & std::ios::internal);
+}
diff --git a/test/std/input.output/iostreams.base/std.ios.manip/adjustfield.manip/left.pass.cpp b/test/std/input.output/iostreams.base/std.ios.manip/adjustfield.manip/left.pass.cpp
new file mode 100644
index 000000000000..aa2ca6f27efd
--- /dev/null
+++ b/test/std/input.output/iostreams.base/std.ios.manip/adjustfield.manip/left.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// ios_base& left(ios_base& str);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+ testbuf sb;
+ std::ios ios(&sb);
+ std::ios_base& r = std::left(ios);
+ assert(&r == &ios);
+ assert(ios.flags() & std::ios::left);
+}
diff --git a/test/std/input.output/iostreams.base/std.ios.manip/adjustfield.manip/right.pass.cpp b/test/std/input.output/iostreams.base/std.ios.manip/adjustfield.manip/right.pass.cpp
new file mode 100644
index 000000000000..08056e8f353c
--- /dev/null
+++ b/test/std/input.output/iostreams.base/std.ios.manip/adjustfield.manip/right.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// ios_base& right(ios_base& str);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+ testbuf sb;
+ std::ios ios(&sb);
+ std::ios_base& r = std::right(ios);
+ assert(&r == &ios);
+ assert(ios.flags() & std::ios::right);
+}
diff --git a/test/std/input.output/iostreams.base/std.ios.manip/basefield.manip/dec.pass.cpp b/test/std/input.output/iostreams.base/std.ios.manip/basefield.manip/dec.pass.cpp
new file mode 100644
index 000000000000..cbe03bceb2bf
--- /dev/null
+++ b/test/std/input.output/iostreams.base/std.ios.manip/basefield.manip/dec.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// ios_base& dec(ios_base& str);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+ testbuf sb;
+ std::ios ios(&sb);
+ std::ios_base& r = std::dec(ios);
+ assert(&r == &ios);
+ assert(ios.flags() & std::ios::dec);
+}
diff --git a/test/std/input.output/iostreams.base/std.ios.manip/basefield.manip/hex.pass.cpp b/test/std/input.output/iostreams.base/std.ios.manip/basefield.manip/hex.pass.cpp
new file mode 100644
index 000000000000..281a59cdafd0
--- /dev/null
+++ b/test/std/input.output/iostreams.base/std.ios.manip/basefield.manip/hex.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// ios_base& hex(ios_base& str);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+ testbuf sb;
+ std::ios ios(&sb);
+ std::ios_base& r = std::hex(ios);
+ assert(&r == &ios);
+ assert(ios.flags() & std::ios::hex);
+}
diff --git a/test/std/input.output/iostreams.base/std.ios.manip/basefield.manip/oct.pass.cpp b/test/std/input.output/iostreams.base/std.ios.manip/basefield.manip/oct.pass.cpp
new file mode 100644
index 000000000000..5ebfea86f4f9
--- /dev/null
+++ b/test/std/input.output/iostreams.base/std.ios.manip/basefield.manip/oct.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// ios_base& oct(ios_base& str);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+ testbuf sb;
+ std::ios ios(&sb);
+ std::ios_base& r = std::oct(ios);
+ assert(&r == &ios);
+ assert(ios.flags() & std::ios::oct);
+}
diff --git a/test/std/input.output/iostreams.base/std.ios.manip/error.reporting/iostream_category.pass.cpp b/test/std/input.output/iostreams.base/std.ios.manip/error.reporting/iostream_category.pass.cpp
new file mode 100644
index 000000000000..a93c7b4c2fe6
--- /dev/null
+++ b/test/std/input.output/iostreams.base/std.ios.manip/error.reporting/iostream_category.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// const error_category& iostream_category();
+
+#include <ios>
+#include <cassert>
+#include <string>
+
+int main()
+{
+ const std::error_category& e_cat1 = std::iostream_category();
+ std::string m1 = e_cat1.name();
+ assert(m1 == "iostream");
+}
diff --git a/test/std/input.output/iostreams.base/std.ios.manip/error.reporting/make_error_code.pass.cpp b/test/std/input.output/iostreams.base/std.ios.manip/error.reporting/make_error_code.pass.cpp
new file mode 100644
index 000000000000..f764fa6fd797
--- /dev/null
+++ b/test/std/input.output/iostreams.base/std.ios.manip/error.reporting/make_error_code.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// error_code make_error_code(io_errc e);
+
+#include <ios>
+#include <cassert>
+
+int main()
+{
+ {
+ std::error_code ec = make_error_code(std::io_errc::stream);
+ assert(ec.value() == static_cast<int>(std::io_errc::stream));
+ assert(ec.category() == std::iostream_category());
+ }
+}
diff --git a/test/std/input.output/iostreams.base/std.ios.manip/error.reporting/make_error_condition.pass.cpp b/test/std/input.output/iostreams.base/std.ios.manip/error.reporting/make_error_condition.pass.cpp
new file mode 100644
index 000000000000..30931bae0bd2
--- /dev/null
+++ b/test/std/input.output/iostreams.base/std.ios.manip/error.reporting/make_error_condition.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// error_condition make_error_condition(io_errc e);
+
+#include <ios>
+#include <cassert>
+
+int main()
+{
+ {
+ const std::error_condition ec1 = std::make_error_condition(std::io_errc::stream);
+ assert(ec1.value() == static_cast<int>(std::io_errc::stream));
+ assert(ec1.category() == std::iostream_category());
+ }
+}
diff --git a/test/std/input.output/iostreams.base/std.ios.manip/floatfield.manip/defaultfloat.pass.cpp b/test/std/input.output/iostreams.base/std.ios.manip/floatfield.manip/defaultfloat.pass.cpp
new file mode 100644
index 000000000000..f202bc4c8812
--- /dev/null
+++ b/test/std/input.output/iostreams.base/std.ios.manip/floatfield.manip/defaultfloat.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// ios_base& defaultfloat(ios_base& str);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+ testbuf sb;
+ std::ios ios(&sb);
+ std::ios_base& r = std::defaultfloat(ios);
+ assert(&r == &ios);
+ assert(!(ios.flags() & std::ios::fixed));
+ assert(!(ios.flags() & std::ios::scientific));
+}
diff --git a/test/std/input.output/iostreams.base/std.ios.manip/floatfield.manip/fixed.pass.cpp b/test/std/input.output/iostreams.base/std.ios.manip/floatfield.manip/fixed.pass.cpp
new file mode 100644
index 000000000000..55bf2648f3ed
--- /dev/null
+++ b/test/std/input.output/iostreams.base/std.ios.manip/floatfield.manip/fixed.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// ios_base& fixed(ios_base& str);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+ testbuf sb;
+ std::ios ios(&sb);
+ std::ios_base& r = std::fixed(ios);
+ assert(&r == &ios);
+ assert(ios.flags() & std::ios::fixed);
+}
diff --git a/test/std/input.output/iostreams.base/std.ios.manip/floatfield.manip/hexfloat.pass.cpp b/test/std/input.output/iostreams.base/std.ios.manip/floatfield.manip/hexfloat.pass.cpp
new file mode 100644
index 000000000000..2920cca83d0e
--- /dev/null
+++ b/test/std/input.output/iostreams.base/std.ios.manip/floatfield.manip/hexfloat.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// ios_base& hexfloat(ios_base& str);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+ testbuf sb;
+ std::ios ios(&sb);
+ std::ios_base& r = std::hexfloat(ios);
+ assert(&r == &ios);
+ assert(ios.flags() & std::ios::fixed);
+ assert(ios.flags() & std::ios::scientific);
+}
diff --git a/test/std/input.output/iostreams.base/std.ios.manip/floatfield.manip/scientific.pass.cpp b/test/std/input.output/iostreams.base/std.ios.manip/floatfield.manip/scientific.pass.cpp
new file mode 100644
index 000000000000..53cfd8171f39
--- /dev/null
+++ b/test/std/input.output/iostreams.base/std.ios.manip/floatfield.manip/scientific.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// ios_base& scientific(ios_base& str);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+ testbuf sb;
+ std::ios ios(&sb);
+ std::ios_base& r = std::scientific(ios);
+ assert(&r == &ios);
+ assert(ios.flags() & std::ios::scientific);
+}
diff --git a/test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/boolalpha.pass.cpp b/test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/boolalpha.pass.cpp
new file mode 100644
index 000000000000..ca8cd93f05b1
--- /dev/null
+++ b/test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/boolalpha.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// ios_base& boolalpha(ios_base& str);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+ testbuf sb;
+ std::ios ios(&sb);
+ std::ios_base& r = std::boolalpha(ios);
+ assert(&r == &ios);
+ assert(ios.flags() & std::ios::boolalpha);
+}
diff --git a/test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noboolalpha.pass.cpp b/test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noboolalpha.pass.cpp
new file mode 100644
index 000000000000..ebc0aab67dbe
--- /dev/null
+++ b/test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noboolalpha.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// ios_base& noboolalpha(ios_base& str);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+ testbuf sb;
+ std::ios ios(&sb);
+ std::boolalpha(ios);
+ std::ios_base& r = std::noboolalpha(ios);
+ assert(&r == &ios);
+ assert(!(ios.flags() & std::ios::boolalpha));
+}
diff --git a/test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noshowbase.pass.cpp b/test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noshowbase.pass.cpp
new file mode 100644
index 000000000000..91608f0f5034
--- /dev/null
+++ b/test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noshowbase.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// ios_base& noshowbase(ios_base& str);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+ testbuf sb;
+ std::ios ios(&sb);
+ std::showbase(ios);
+ std::ios_base& r = std::noshowbase(ios);
+ assert(&r == &ios);
+ assert(!(ios.flags() & std::ios::showbase));
+}
diff --git a/test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noshowpoint.pass.cpp b/test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noshowpoint.pass.cpp
new file mode 100644
index 000000000000..6e26416c5cd1
--- /dev/null
+++ b/test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noshowpoint.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// ios_base& noshowpoint(ios_base& str);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+ testbuf sb;
+ std::ios ios(&sb);
+ std::showpoint(ios);
+ std::ios_base& r = std::noshowpoint(ios);
+ assert(&r == &ios);
+ assert(!(ios.flags() & std::ios::showpoint));
+}
diff --git a/test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noshowpos.pass.cpp b/test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noshowpos.pass.cpp
new file mode 100644
index 000000000000..5e6911c22b98
--- /dev/null
+++ b/test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noshowpos.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// ios_base& noshowpos(ios_base& str);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+ testbuf sb;
+ std::ios ios(&sb);
+ std::showpos(ios);
+ std::ios_base& r = std::noshowpos(ios);
+ assert(&r == &ios);
+ assert(!(ios.flags() & std::ios::showpos));
+}
diff --git a/test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noskipws.pass.cpp b/test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noskipws.pass.cpp
new file mode 100644
index 000000000000..e78f5f884cc4
--- /dev/null
+++ b/test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noskipws.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// ios_base& noskipws(ios_base& str);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+ testbuf sb;
+ std::ios ios(&sb);
+ std::skipws(ios);
+ std::ios_base& r = std::noskipws(ios);
+ assert(&r == &ios);
+ assert(!(ios.flags() & std::ios::skipws));
+}
diff --git a/test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/nounitbuf.pass.cpp b/test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/nounitbuf.pass.cpp
new file mode 100644
index 000000000000..5708038e5ed9
--- /dev/null
+++ b/test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/nounitbuf.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// ios_base& nounitbuf(ios_base& str);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+ testbuf sb;
+ std::ios ios(&sb);
+ std::unitbuf(ios);
+ std::ios_base& r = std::nounitbuf(ios);
+ assert(&r == &ios);
+ assert(!(ios.flags() & std::ios::unitbuf));
+}
diff --git a/test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/nouppercase.pass.cpp b/test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/nouppercase.pass.cpp
new file mode 100644
index 000000000000..76fac604b34d
--- /dev/null
+++ b/test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/nouppercase.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// ios_base& nouppercase(ios_base& str);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+ testbuf sb;
+ std::ios ios(&sb);
+ std::uppercase(ios);
+ std::ios_base& r = std::nouppercase(ios);
+ assert(&r == &ios);
+ assert(!(ios.flags() & std::ios::uppercase));
+}
diff --git a/test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/showbase.pass.cpp b/test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/showbase.pass.cpp
new file mode 100644
index 000000000000..ddf3a8550963
--- /dev/null
+++ b/test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/showbase.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// ios_base& showbase(ios_base& str);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+ testbuf sb;
+ std::ios ios(&sb);
+ std::ios_base& r = std::showbase(ios);
+ assert(&r == &ios);
+ assert(ios.flags() & std::ios::showbase);
+}
diff --git a/test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/showpoint.pass.cpp b/test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/showpoint.pass.cpp
new file mode 100644
index 000000000000..79ae3b6e27af
--- /dev/null
+++ b/test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/showpoint.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// ios_base& showpoint(ios_base& str);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+ testbuf sb;
+ std::ios ios(&sb);
+ std::ios_base& r = std::showpoint(ios);
+ assert(&r == &ios);
+ assert(ios.flags() & std::ios::showpoint);
+}
diff --git a/test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/showpos.pass.cpp b/test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/showpos.pass.cpp
new file mode 100644
index 000000000000..226542614c10
--- /dev/null
+++ b/test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/showpos.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// ios_base& showpos(ios_base& str);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+ testbuf sb;
+ std::ios ios(&sb);
+ std::ios_base& r = std::showpos(ios);
+ assert(&r == &ios);
+ assert(ios.flags() & std::ios::showpos);
+}
diff --git a/test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/skipws.pass.cpp b/test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/skipws.pass.cpp
new file mode 100644
index 000000000000..4ea3e448fe04
--- /dev/null
+++ b/test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/skipws.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// ios_base& skipws(ios_base& str);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+ testbuf sb;
+ std::ios ios(&sb);
+ std::ios_base& r = std::skipws(ios);
+ assert(&r == &ios);
+ assert(ios.flags() & std::ios::skipws);
+}
diff --git a/test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/unitbuf.pass.cpp b/test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/unitbuf.pass.cpp
new file mode 100644
index 000000000000..99a33c71c893
--- /dev/null
+++ b/test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/unitbuf.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// ios_base& unitbuf(ios_base& str);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+ testbuf sb;
+ std::ios ios(&sb);
+ std::ios_base& r = std::unitbuf(ios);
+ assert(&r == &ios);
+ assert(ios.flags() & std::ios::unitbuf);
+}
diff --git a/test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/uppercase.pass.cpp b/test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/uppercase.pass.cpp
new file mode 100644
index 000000000000..1a19e2aa6367
--- /dev/null
+++ b/test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/uppercase.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// ios_base& uppercase(ios_base& str);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+ testbuf sb;
+ std::ios ios(&sb);
+ std::ios_base& r = std::uppercase(ios);
+ assert(&r == &ios);
+ assert(ios.flags() & std::ios::uppercase);
+}
diff --git a/test/std/input.output/iostreams.base/std.ios.manip/nothing_to_do.pass.cpp b/test/std/input.output/iostreams.base/std.ios.manip/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/input.output/iostreams.base/std.ios.manip/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/input.output/iostreams.base/stream.types/streamoff.pass.cpp b/test/std/input.output/iostreams.base/stream.types/streamoff.pass.cpp
new file mode 100644
index 000000000000..0e9f1278ee0d
--- /dev/null
+++ b/test/std/input.output/iostreams.base/stream.types/streamoff.pass.cpp
@@ -0,0 +1,21 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// typedef OFF_T streamoff;
+
+#include <ios>
+#include <type_traits>
+
+int main()
+{
+ static_assert(std::is_integral<std::streamoff>::value, "");
+ static_assert(std::is_signed<std::streamoff>::value, "");
+}
diff --git a/test/std/input.output/iostreams.base/stream.types/streamsize.pass.cpp b/test/std/input.output/iostreams.base/stream.types/streamsize.pass.cpp
new file mode 100644
index 000000000000..438c51138ee3
--- /dev/null
+++ b/test/std/input.output/iostreams.base/stream.types/streamsize.pass.cpp
@@ -0,0 +1,21 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// typedef SZ_T streamsize;
+
+#include <ios>
+#include <type_traits>
+
+int main()
+{
+ static_assert(std::is_integral<std::streamsize>::value, "");
+ static_assert(std::is_signed<std::streamsize>::value, "");
+}
diff --git a/test/std/input.output/iostreams.base/version.pass.cpp b/test/std/input.output/iostreams.base/version.pass.cpp
new file mode 100644
index 000000000000..f56846d38b8d
--- /dev/null
+++ b/test/std/input.output/iostreams.base/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+#include <ios>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/input.output/iostreams.requirements/iostream.limits.imbue/tested_elsewhere.pass.cpp b/test/std/input.output/iostreams.requirements/iostream.limits.imbue/tested_elsewhere.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/input.output/iostreams.requirements/iostream.limits.imbue/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/input.output/iostreams.requirements/iostreams.limits.pos/nothing_to_do.pass.cpp b/test/std/input.output/iostreams.requirements/iostreams.limits.pos/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/input.output/iostreams.requirements/iostreams.limits.pos/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/input.output/iostreams.requirements/iostreams.threadsafety/nothing_to_do.pass.cpp b/test/std/input.output/iostreams.requirements/iostreams.threadsafety/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/input.output/iostreams.requirements/iostreams.threadsafety/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/input.output/iostreams.requirements/nothing_to_do.pass.cpp b/test/std/input.output/iostreams.requirements/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/input.output/iostreams.requirements/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/input.output/nothing_to_do.pass.cpp b/test/std/input.output/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/input.output/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/input.output/stream.buffers/streambuf.reqts/tested_elsewhere.pass.cpp b/test/std/input.output/stream.buffers/streambuf.reqts/tested_elsewhere.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/input.output/stream.buffers/streambuf.reqts/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/input.output/stream.buffers/streambuf/streambuf.cons/copy.fail.cpp b/test/std/input.output/stream.buffers/streambuf/streambuf.cons/copy.fail.cpp
new file mode 100644
index 000000000000..469c7449971e
--- /dev/null
+++ b/test/std/input.output/stream.buffers/streambuf/streambuf.cons/copy.fail.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// basic_streambuf(const basic_streambuf& rhs); // protected
+
+#include <streambuf>
+#include <cassert>
+
+std::streambuf get();
+
+int main()
+{
+ std::streambuf sb = get();
+}
diff --git a/test/std/input.output/stream.buffers/streambuf/streambuf.cons/copy.pass.cpp b/test/std/input.output/stream.buffers/streambuf/streambuf.cons/copy.pass.cpp
new file mode 100644
index 000000000000..c1e18392b6ce
--- /dev/null
+++ b/test/std/input.output/stream.buffers/streambuf/streambuf.cons/copy.pass.cpp
@@ -0,0 +1,84 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// basic_streambuf(const basic_streambuf& rhs);
+
+#include <streambuf>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+template <class CharT>
+struct test
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_streambuf<CharT> base;
+ test() {}
+
+ test(const test& t)
+ : std::basic_streambuf<CharT>(t)
+ {
+ assert(this->eback() == t.eback());
+ assert(this->gptr() == t.gptr());
+ assert(this->egptr() == t.egptr());
+ assert(this->pbase() == t.pbase());
+ assert(this->pptr() == t.pptr());
+ assert(this->epptr() == t.epptr());
+ assert(this->getloc() == t.getloc());
+ }
+
+ void setg(CharT* gbeg, CharT* gnext, CharT* gend)
+ {
+ base::setg(gbeg, gnext, gend);
+ }
+ void setp(CharT* pbeg, CharT* pend)
+ {
+ base::setp(pbeg, pend);
+ }
+};
+
+int main()
+{
+ {
+ test<char> t;
+ test<char> t2 = t;
+ }
+ {
+ test<wchar_t> t;
+ test<wchar_t> t2 = t;
+ }
+ {
+ char g1, g2, g3, p1, p3;
+ test<char> t;
+ t.setg(&g1, &g2, &g3);
+ t.setp(&p1, &p3);
+ test<char> t2 = t;
+ }
+ {
+ wchar_t g1, g2, g3, p1, p3;
+ test<wchar_t> t;
+ t.setg(&g1, &g2, &g3);
+ t.setp(&p1, &p3);
+ test<wchar_t> t2 = t;
+ }
+ std::locale::global(std::locale(LOCALE_en_US_UTF_8));
+ {
+ test<char> t;
+ test<char> t2 = t;
+ }
+ {
+ test<wchar_t> t;
+ test<wchar_t> t2 = t;
+ }
+}
diff --git a/test/std/input.output/stream.buffers/streambuf/streambuf.cons/default.fail.cpp b/test/std/input.output/stream.buffers/streambuf/streambuf.cons/default.fail.cpp
new file mode 100644
index 000000000000..7f57f3cf9304
--- /dev/null
+++ b/test/std/input.output/stream.buffers/streambuf/streambuf.cons/default.fail.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// basic_streambuf(); // is protected
+
+#include <streambuf>
+
+int main()
+{
+ std::basic_streambuf<char> sb;
+}
diff --git a/test/std/input.output/stream.buffers/streambuf/streambuf.cons/default.pass.cpp b/test/std/input.output/stream.buffers/streambuf/streambuf.cons/default.pass.cpp
new file mode 100644
index 000000000000..d8ca8aebc62b
--- /dev/null
+++ b/test/std/input.output/stream.buffers/streambuf/streambuf.cons/default.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// basic_streambuf();
+
+#include <streambuf>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+template <class CharT>
+struct test
+ : public std::basic_streambuf<CharT>
+{
+ test()
+ {
+ assert(this->eback() == 0);
+ assert(this->gptr() == 0);
+ assert(this->egptr() == 0);
+ assert(this->pbase() == 0);
+ assert(this->pptr() == 0);
+ assert(this->epptr() == 0);
+ }
+};
+
+int main()
+{
+ {
+ test<char> t;
+ assert(t.getloc().name() == "C");
+ }
+ {
+ test<wchar_t> t;
+ assert(t.getloc().name() == "C");
+ }
+ std::locale::global(std::locale(LOCALE_en_US_UTF_8));
+ {
+ test<char> t;
+ assert(t.getloc().name() == LOCALE_en_US_UTF_8);
+ }
+ {
+ test<wchar_t> t;
+ assert(t.getloc().name() == LOCALE_en_US_UTF_8);
+ }
+}
diff --git a/test/std/input.output/stream.buffers/streambuf/streambuf.members/nothing_to_do.pass.cpp b/test/std/input.output/stream.buffers/streambuf/streambuf.members/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/input.output/stream.buffers/streambuf/streambuf.members/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.buffer/pubseekoff.pass.cpp b/test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.buffer/pubseekoff.pass.cpp
new file mode 100644
index 000000000000..2c77f25c2e59
--- /dev/null
+++ b/test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.buffer/pubseekoff.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// pos_type pubseekoff(off_type off, ios_base::seekdir way,
+// ios_base::openmode which = ios_base::in | ios_base::out);
+
+#include <streambuf>
+#include <cassert>
+
+template <class CharT>
+struct test
+ : public std::basic_streambuf<CharT>
+{
+ test() {}
+};
+
+int main()
+{
+ {
+ test<char> t;
+ assert(t.pubseekoff(0, std::ios_base::beg) == -1);
+ assert(t.pubseekoff(0, std::ios_base::beg, std::ios_base::app) == -1);
+ }
+}
diff --git a/test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.buffer/pubseekpos.pass.cpp b/test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.buffer/pubseekpos.pass.cpp
new file mode 100644
index 000000000000..0b9ddff4106c
--- /dev/null
+++ b/test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.buffer/pubseekpos.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// pos_type pubseekpos(pos_type sp,
+// ios_base::openmode which = ios_base::in | ios_base::out;
+
+#include <streambuf>
+#include <cassert>
+
+template <class CharT>
+struct test
+ : public std::basic_streambuf<CharT>
+{
+ test() {}
+};
+
+int main()
+{
+ {
+ test<char> t;
+ assert(t.pubseekpos(0, std::ios_base::app) == -1);
+ }
+}
diff --git a/test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.buffer/pubsetbuf.pass.cpp b/test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.buffer/pubsetbuf.pass.cpp
new file mode 100644
index 000000000000..8cf62771e499
--- /dev/null
+++ b/test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.buffer/pubsetbuf.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// basic_streambuf* pubsetbuf(char_type* s, streamsize n);
+
+#include <streambuf>
+#include <cassert>
+
+template <class CharT>
+struct test
+ : public std::basic_streambuf<CharT>
+{
+ test() {}
+};
+
+int main()
+{
+ {
+ test<char> t;
+ assert(t.pubsetbuf(0, 0) == &t);
+ }
+}
diff --git a/test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.buffer/pubsync.pass.cpp b/test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.buffer/pubsync.pass.cpp
new file mode 100644
index 000000000000..cc1679071610
--- /dev/null
+++ b/test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.buffer/pubsync.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// int pubsync();
+
+#include <streambuf>
+#include <cassert>
+
+template <class CharT>
+struct test
+ : public std::basic_streambuf<CharT>
+{
+ test() {}
+};
+
+int main()
+{
+ {
+ test<char> t;
+ assert(t.pubsync() == 0);
+ }
+}
diff --git a/test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.locales/locales.pass.cpp b/test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.locales/locales.pass.cpp
new file mode 100644
index 000000000000..95dd2db75b6b
--- /dev/null
+++ b/test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.locales/locales.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: locale.en_US.UTF-8
+// REQUIRES: locale.fr_FR.UTF-8
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// locale pubimbue(const locale& loc);
+// locale getloc() const;
+
+#include <streambuf>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+template <class CharT>
+struct test
+ : public std::basic_streambuf<CharT>
+{
+ test() {}
+
+ void imbue(const std::locale&)
+ {
+ assert(this->getloc().name() == LOCALE_en_US_UTF_8);
+ }
+};
+
+int main()
+{
+ {
+ test<char> t;
+ assert(t.getloc().name() == "C");
+ }
+ std::locale::global(std::locale(LOCALE_en_US_UTF_8));
+ {
+ test<char> t;
+ assert(t.getloc().name() == LOCALE_en_US_UTF_8);
+ assert(t.pubimbue(std::locale(LOCALE_fr_FR_UTF_8)).name() ==
+ LOCALE_en_US_UTF_8);
+ assert(t.getloc().name() == LOCALE_fr_FR_UTF_8);
+ }
+}
diff --git a/test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/in_avail.pass.cpp b/test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/in_avail.pass.cpp
new file mode 100644
index 000000000000..200150639b91
--- /dev/null
+++ b/test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/in_avail.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// streamsize in_avail();
+
+#include <streambuf>
+#include <cassert>
+
+int showmanyc_called = 0;
+
+template <class CharT>
+struct test
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_streambuf<CharT> base;
+
+ test() {}
+
+ void setg(CharT* gbeg, CharT* gnext, CharT* gend)
+ {
+ base::setg(gbeg, gnext, gend);
+ }
+protected:
+ std::streamsize showmanyc()
+ {
+ ++showmanyc_called;
+ return 5;
+ }
+};
+
+int main()
+{
+ {
+ test<char> t;
+ assert(t.in_avail() == 5);
+ assert(showmanyc_called == 1);
+ char in[5];
+ t.setg(in, in+2, in+5);
+ assert(t.in_avail() == 3);
+ }
+}
diff --git a/test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/sbumpc.pass.cpp b/test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/sbumpc.pass.cpp
new file mode 100644
index 000000000000..ac6d0cc932ae
--- /dev/null
+++ b/test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/sbumpc.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// int_type sbumpc();
+
+#include <streambuf>
+#include <cassert>
+
+int uflow_called = 0;
+
+struct test
+ : public std::basic_streambuf<char>
+{
+ typedef std::basic_streambuf<char> base;
+
+ test() {}
+
+ void setg(char* gbeg, char* gnext, char* gend)
+ {
+ base::setg(gbeg, gnext, gend);
+ }
+
+protected:
+ int_type uflow()
+ {
+ ++uflow_called;
+ return 'a';
+ }
+};
+
+int main()
+{
+ {
+ test t;
+ assert(uflow_called == 0);
+ assert(t.sbumpc() == 'a');
+ assert(uflow_called == 1);
+ char in[] = "ABC";
+ t.setg(in, in, in+sizeof(in));
+ assert(t.sbumpc() == 'A');
+ assert(uflow_called == 1);
+ assert(t.sbumpc() == 'B');
+ assert(uflow_called == 1);
+ }
+}
diff --git a/test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/sgetc.pass.cpp b/test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/sgetc.pass.cpp
new file mode 100644
index 000000000000..c68930cfa84c
--- /dev/null
+++ b/test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/sgetc.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// int_type sgetc();
+
+#include <streambuf>
+#include <cassert>
+
+int underflow_called = 0;
+
+struct test
+ : public std::basic_streambuf<char>
+{
+ typedef std::basic_streambuf<char> base;
+
+ test() {}
+
+ void setg(char* gbeg, char* gnext, char* gend)
+ {
+ base::setg(gbeg, gnext, gend);
+ }
+
+protected:
+ int_type underflow()
+ {
+ ++underflow_called;
+ return 'a';
+ }
+};
+
+int main()
+{
+ {
+ test t;
+ assert(underflow_called == 0);
+ assert(t.sgetc() == 'a');
+ assert(underflow_called == 1);
+ char in[] = "ABC";
+ t.setg(in, in, in+sizeof(in));
+ assert(t.sgetc() == 'A');
+ assert(underflow_called == 1);
+ assert(t.sgetc() == 'A');
+ assert(underflow_called == 1);
+ }
+}
diff --git a/test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/sgetn.pass.cpp b/test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/sgetn.pass.cpp
new file mode 100644
index 000000000000..730cedeea76c
--- /dev/null
+++ b/test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/sgetn.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// streamsize sgetn(char_type* s, streamsize n);
+
+#include <streambuf>
+#include <cassert>
+
+int xsgetn_called = 0;
+
+struct test
+ : public std::basic_streambuf<char>
+{
+ test() {}
+
+protected:
+ std::streamsize xsgetn(char_type* s, std::streamsize n)
+ {
+ ++xsgetn_called;
+ return 10;
+ }
+};
+
+int main()
+{
+ test t;
+ assert(xsgetn_called == 0);
+ assert(t.sgetn(0, 0) == 10);
+ assert(xsgetn_called == 1);
+}
diff --git a/test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/snextc.pass.cpp b/test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/snextc.pass.cpp
new file mode 100644
index 000000000000..7f44245e26e3
--- /dev/null
+++ b/test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/snextc.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// int_type snextc();
+
+#include <streambuf>
+#include <cassert>
+
+int uflow_called = 0;
+
+struct test
+ : public std::basic_streambuf<char>
+{
+ typedef std::basic_streambuf<char> base;
+
+ test() {}
+
+ void setg(char* gbeg, char* gnext, char* gend)
+ {
+ base::setg(gbeg, gnext, gend);
+ }
+
+protected:
+ int_type uflow()
+ {
+ ++uflow_called;
+ return 'a';
+ }
+};
+
+int main()
+{
+ {
+ test t;
+ assert(uflow_called == 0);
+ assert(t.snextc() == -1);
+ assert(uflow_called == 1);
+ char in[] = "ABC";
+ t.setg(in, in, in+sizeof(in));
+ assert(t.snextc() == 'B');
+ assert(uflow_called == 1);
+ assert(t.snextc() == 'C');
+ assert(uflow_called == 1);
+ }
+}
diff --git a/test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.pback/sputbackc.pass.cpp b/test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.pback/sputbackc.pass.cpp
new file mode 100644
index 000000000000..34a2a2dda372
--- /dev/null
+++ b/test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.pback/sputbackc.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// int_type sputbackc(char_type c);
+
+#include <streambuf>
+#include <cassert>
+
+int pbackfail_called = 0;
+
+struct test
+ : public std::basic_streambuf<char>
+{
+ typedef std::basic_streambuf<char> base;
+
+ test() {}
+
+ void setg(char* gbeg, char* gnext, char* gend)
+ {
+ base::setg(gbeg, gnext, gend);
+ }
+
+protected:
+ int_type pbackfail(int_type c = traits_type::eof())
+ {
+ ++pbackfail_called;
+ return 'a';
+ }
+};
+
+int main()
+{
+ {
+ test t;
+ assert(pbackfail_called == 0);
+ assert(t.sputbackc('A') == 'a');
+ assert(pbackfail_called == 1);
+ char in[] = "ABC";
+ t.setg(in, in+1, in+sizeof(in));
+ assert(t.sputbackc('A') == 'A');
+ assert(pbackfail_called == 1);
+ assert(t.sputbackc('A') == 'a');
+ assert(pbackfail_called == 2);
+ }
+}
diff --git a/test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.pback/sungetc.pass.cpp b/test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.pback/sungetc.pass.cpp
new file mode 100644
index 000000000000..4c68fada07a8
--- /dev/null
+++ b/test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.pback/sungetc.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// int_type sungetc();
+
+#include <streambuf>
+#include <cassert>
+
+int pbackfail_called = 0;
+
+struct test
+ : public std::basic_streambuf<char>
+{
+ typedef std::basic_streambuf<char> base;
+
+ test() {}
+
+ void setg(char* gbeg, char* gnext, char* gend)
+ {
+ base::setg(gbeg, gnext, gend);
+ }
+
+protected:
+ int_type pbackfail(int_type c = traits_type::eof())
+ {
+ ++pbackfail_called;
+ return 'a';
+ }
+};
+
+int main()
+{
+ {
+ test t;
+ assert(pbackfail_called == 0);
+ assert(t.sungetc() == 'a');
+ assert(pbackfail_called == 1);
+ char in[] = "ABC";
+ t.setg(in, in+1, in+sizeof(in));
+ assert(t.sungetc() == 'A');
+ assert(pbackfail_called == 1);
+ assert(t.sungetc() == 'a');
+ assert(pbackfail_called == 2);
+ }
+}
diff --git a/test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.put/sputc.pass.cpp b/test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.put/sputc.pass.cpp
new file mode 100644
index 000000000000..b04b8b0acc91
--- /dev/null
+++ b/test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.put/sputc.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// int_type sputc(char_type c);
+
+#include <streambuf>
+#include <cassert>
+
+int overflow_called = 0;
+
+struct test
+ : public std::basic_streambuf<char>
+{
+ typedef std::basic_streambuf<char> base;
+
+ test() {}
+
+ void setg(char* gbeg, char* gnext, char* gend)
+ {
+ base::setg(gbeg, gnext, gend);
+ }
+ void setp(char* pbeg, char* pend)
+ {
+ base::setp(pbeg, pend);
+ }
+
+protected:
+ int_type overflow(int_type c = traits_type::eof())
+ {
+ ++overflow_called;
+ return 'a';
+ }
+};
+
+int main()
+{
+ {
+ test t;
+ assert(overflow_called == 0);
+ assert(t.sputc('A') == 'a');
+ assert(overflow_called == 1);
+ char out[3] = {0};
+ t.setp(out, out+sizeof(out));
+ assert(t.sputc('A') == 'A');
+ assert(overflow_called == 1);
+ assert(out[0] == 'A');
+ assert(t.sputc('B') == 'B');
+ assert(overflow_called == 1);
+ assert(out[0] == 'A');
+ assert(out[1] == 'B');
+ }
+}
diff --git a/test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.put/sputn.pass.cpp b/test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.put/sputn.pass.cpp
new file mode 100644
index 000000000000..e03e8e0cbda3
--- /dev/null
+++ b/test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.put/sputn.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// streamsize sputn(const char_type* s, streamsize n);
+
+#include <streambuf>
+#include <cassert>
+
+int xsputn_called = 0;
+
+struct test
+ : public std::basic_streambuf<char>
+{
+ test() {}
+
+protected:
+ std::streamsize xsputn(const char_type* s, std::streamsize n)
+ {
+ ++xsputn_called;
+ return 5;
+ }
+};
+
+int main()
+{
+ test t;
+ assert(xsputn_called == 0);
+ assert(t.sputn(0, 0) == 5);
+ assert(xsputn_called == 1);
+}
diff --git a/test/std/input.output/stream.buffers/streambuf/streambuf.protected/nothing_to_do.pass.cpp b/test/std/input.output/stream.buffers/streambuf/streambuf.protected/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/input.output/stream.buffers/streambuf/streambuf.protected/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.assign/assign.pass.cpp b/test/std/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.assign/assign.pass.cpp
new file mode 100644
index 000000000000..803198938f6e
--- /dev/null
+++ b/test/std/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.assign/assign.pass.cpp
@@ -0,0 +1,91 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// basic_streambuf& operator=(const basic_streambuf& rhs);
+
+#include <streambuf>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+template <class CharT>
+struct test
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_streambuf<CharT> base;
+ test() {}
+
+ test& operator=(const test& t)
+ {
+ base::operator=(t);
+ assert(this->eback() == t.eback());
+ assert(this->gptr() == t.gptr());
+ assert(this->egptr() == t.egptr());
+ assert(this->pbase() == t.pbase());
+ assert(this->pptr() == t.pptr());
+ assert(this->epptr() == t.epptr());
+ assert(this->getloc() == t.getloc());
+ return *this;
+ }
+
+ void setg(CharT* gbeg, CharT* gnext, CharT* gend)
+ {
+ base::setg(gbeg, gnext, gend);
+ }
+ void setp(CharT* pbeg, CharT* pend)
+ {
+ base::setp(pbeg, pend);
+ }
+};
+
+int main()
+{
+ {
+ test<char> t;
+ test<char> t2;
+ t2 = t;
+ }
+ {
+ test<wchar_t> t;
+ test<wchar_t> t2;
+ t2 = t;
+ }
+ {
+ char g1, g2, g3, p1, p3;
+ test<char> t;
+ t.setg(&g1, &g2, &g3);
+ t.setp(&p1, &p3);
+ test<char> t2;
+ t2 = t;
+ }
+ {
+ wchar_t g1, g2, g3, p1, p3;
+ test<wchar_t> t;
+ t.setg(&g1, &g2, &g3);
+ t.setp(&p1, &p3);
+ test<wchar_t> t2;
+ t2 = t;
+ }
+ std::locale::global(std::locale(LOCALE_en_US_UTF_8));
+ {
+ test<char> t;
+ test<char> t2;
+ t2 = t;
+ }
+ {
+ test<wchar_t> t;
+ test<wchar_t> t2;
+ t2 = t;
+ }
+}
diff --git a/test/std/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.assign/swap.pass.cpp b/test/std/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.assign/swap.pass.cpp
new file mode 100644
index 000000000000..7a23206b42de
--- /dev/null
+++ b/test/std/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.assign/swap.pass.cpp
@@ -0,0 +1,101 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// void swap(basic_streambuf& rhs);
+
+#include <streambuf>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+template <class CharT>
+struct test
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_streambuf<CharT> base;
+ test() {}
+
+ void swap(test& t)
+ {
+ test old_this(*this);
+ test old_that(t);
+ base::swap(t);
+ assert(this->eback() == old_that.eback());
+ assert(this->gptr() == old_that.gptr());
+ assert(this->egptr() == old_that.egptr());
+ assert(this->pbase() == old_that.pbase());
+ assert(this->pptr() == old_that.pptr());
+ assert(this->epptr() == old_that.epptr());
+ assert(this->getloc() == old_that.getloc());
+
+ assert(t.eback() == old_this.eback());
+ assert(t.gptr() == old_this.gptr());
+ assert(t.egptr() == old_this.egptr());
+ assert(t.pbase() == old_this.pbase());
+ assert(t.pptr() == old_this.pptr());
+ assert(t.epptr() == old_this.epptr());
+ assert(t.getloc() == old_this.getloc());
+ return *this;
+ }
+
+ void setg(CharT* gbeg, CharT* gnext, CharT* gend)
+ {
+ base::setg(gbeg, gnext, gend);
+ }
+ void setp(CharT* pbeg, CharT* pend)
+ {
+ base::setp(pbeg, pend);
+ }
+};
+
+int main()
+{
+ {
+ test<char> t;
+ test<char> t2;
+ swap(t2, t);
+ }
+ {
+ test<wchar_t> t;
+ test<wchar_t> t2;
+ swap(t2, t);
+ }
+ {
+ char g1, g2, g3, p1, p3;
+ test<char> t;
+ t.setg(&g1, &g2, &g3);
+ t.setp(&p1, &p3);
+ test<char> t2;
+ swap(t2, t);
+ }
+ {
+ wchar_t g1, g2, g3, p1, p3;
+ test<wchar_t> t;
+ t.setg(&g1, &g2, &g3);
+ t.setp(&p1, &p3);
+ test<wchar_t> t2;
+ swap(t2, t);
+ }
+ std::locale::global(std::locale(LOCALE_en_US_UTF_8));
+ {
+ test<char> t;
+ test<char> t2;
+ swap(t2, t);
+ }
+ {
+ test<wchar_t> t;
+ test<wchar_t> t2;
+ swap(t2, t);
+ }
+}
diff --git a/test/std/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.get.area/gbump.pass.cpp b/test/std/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.get.area/gbump.pass.cpp
new file mode 100644
index 000000000000..ce25a191914d
--- /dev/null
+++ b/test/std/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.get.area/gbump.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// void gbump(int n);
+
+#include <streambuf>
+#include <cassert>
+
+template <class CharT>
+struct test
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_streambuf<CharT> base;
+
+ test() {}
+
+ void setg(CharT* gbeg, CharT* gnext, CharT* gend)
+ {
+ base::setg(gbeg, gnext, gend);
+ }
+
+ void gbump(int n)
+ {
+ CharT* gbeg = base::eback();
+ CharT* gnext = base::gptr();
+ CharT* gend = base::egptr();
+ base::gbump(n);
+ assert(base::eback() == gbeg);
+ assert(base::gptr() == gnext+n);
+ assert(base::egptr() == gend);
+ }
+};
+
+int main()
+{
+ {
+ test<char> t;
+ char in[] = "ABCDE";
+ t.setg(in, in+1, in+sizeof(in)/sizeof(in[0]));
+ t.gbump(2);
+ }
+ {
+ test<wchar_t> t;
+ wchar_t in[] = L"ABCDE";
+ t.setg(in, in+1, in+sizeof(in)/sizeof(in[0]));
+ t.gbump(3);
+ }
+}
diff --git a/test/std/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.get.area/setg.pass.cpp b/test/std/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.get.area/setg.pass.cpp
new file mode 100644
index 000000000000..68dcf6eab8f1
--- /dev/null
+++ b/test/std/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.get.area/setg.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// void setg(char_type* gbeg, char_type* gnext, char_type* gend);
+
+#include <streambuf>
+#include <cassert>
+
+template <class CharT>
+struct test
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_streambuf<CharT> base;
+
+ test() {}
+
+ void setg(CharT* gbeg, CharT* gnext, CharT* gend)
+ {
+ base::setg(gbeg, gnext, gend);
+ assert(base::eback() == gbeg);
+ assert(base::gptr() == gnext);
+ assert(base::egptr() == gend);
+ }
+};
+
+int main()
+{
+ {
+ test<char> t;
+ char in[] = "ABC";
+ t.setg(in, in+1, in+sizeof(in)/sizeof(in[0]));
+ }
+ {
+ test<wchar_t> t;
+ wchar_t in[] = L"ABC";
+ t.setg(in, in+1, in+sizeof(in)/sizeof(in[0]));
+ }
+}
diff --git a/test/std/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.put.area/pbump.pass.cpp b/test/std/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.put.area/pbump.pass.cpp
new file mode 100644
index 000000000000..47ef939142ac
--- /dev/null
+++ b/test/std/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.put.area/pbump.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// void pbump(int n);
+
+#include <streambuf>
+#include <cassert>
+
+template <class CharT>
+struct test
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_streambuf<CharT> base;
+
+ test() {}
+
+ void setp(CharT* pbeg, CharT* pend)
+ {
+ base::setp(pbeg, pend);
+ }
+
+ void pbump(int n)
+ {
+ CharT* pbeg = base::pbase();
+ CharT* pnext = base::pptr();
+ CharT* pend = base::epptr();
+ base::pbump(n);
+ assert(base::pbase() == pbeg);
+ assert(base::pptr() == pnext+n);
+ assert(base::epptr() == pend);
+ }
+};
+
+int main()
+{
+ {
+ test<char> t;
+ char in[] = "ABCDE";
+ t.setp(in, in+sizeof(in)/sizeof(in[0]));
+ t.pbump(2);
+ t.pbump(1);
+ }
+ {
+ test<wchar_t> t;
+ wchar_t in[] = L"ABCDE";
+ t.setp(in, in+sizeof(in)/sizeof(in[0]));
+ t.pbump(3);
+ t.pbump(1);
+ }
+}
diff --git a/test/std/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.put.area/setp.pass.cpp b/test/std/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.put.area/setp.pass.cpp
new file mode 100644
index 000000000000..fa4133a475d5
--- /dev/null
+++ b/test/std/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.put.area/setp.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// void setp(char_type* pbeg, char_type* pend);
+
+#include <streambuf>
+#include <cassert>
+
+template <class CharT>
+struct test
+ : public std::basic_streambuf<CharT>
+{
+ typedef std::basic_streambuf<CharT> base;
+
+ test() {}
+
+ void setp(CharT* pbeg, CharT* pend)
+ {
+ base::setp(pbeg, pend);
+ assert(base::pbase() == pbeg);
+ assert(base::pptr() == pbeg);
+ assert(base::epptr() == pend);
+ }
+};
+
+int main()
+{
+ {
+ test<char> t;
+ char in[] = "ABC";
+ t.setp(in, in+sizeof(in)/sizeof(in[0]));
+ }
+ {
+ test<wchar_t> t;
+ wchar_t in[] = L"ABC";
+ t.setp(in, in+sizeof(in)/sizeof(in[0]));
+ }
+}
diff --git a/test/std/input.output/stream.buffers/streambuf/streambuf.virtuals/nothing_to_do.pass.cpp b/test/std/input.output/stream.buffers/streambuf/streambuf.virtuals/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/input.output/stream.buffers/streambuf/streambuf.virtuals/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.buffer/tested_elsewhere.pass.cpp b/test/std/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.buffer/tested_elsewhere.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.buffer/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.get/showmanyc.pass.cpp b/test/std/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.get/showmanyc.pass.cpp
new file mode 100644
index 000000000000..acaf1e8461e6
--- /dev/null
+++ b/test/std/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.get/showmanyc.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// streamsize showmanyc();
+
+#include <streambuf>
+#include <cassert>
+
+int showmanyc_called = 0;
+
+template <class CharT>
+struct test
+ : public std::basic_streambuf<CharT>
+{
+ test() {}
+};
+
+int main()
+{
+ test<char> t;
+ assert(t.in_avail() == 0);
+}
diff --git a/test/std/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.get/uflow.pass.cpp b/test/std/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.get/uflow.pass.cpp
new file mode 100644
index 000000000000..d25ae9b21bff
--- /dev/null
+++ b/test/std/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.get/uflow.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// int_type uflow();
+
+#include <streambuf>
+#include <cassert>
+
+int underflow_called = 0;
+
+struct test
+ : public std::basic_streambuf<char>
+{
+ test() {}
+
+};
+
+int main()
+{
+ test t;
+ assert(t.sgetc() == -1);
+}
diff --git a/test/std/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.get/underflow.pass.cpp b/test/std/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.get/underflow.pass.cpp
new file mode 100644
index 000000000000..1bdba0714f19
--- /dev/null
+++ b/test/std/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.get/underflow.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// int_type underflow();
+
+#include <streambuf>
+#include <cassert>
+
+struct test
+ : public std::basic_streambuf<char>
+{
+ test() {}
+};
+
+int main()
+{
+ test t;
+ assert(t.sgetc() == -1);
+}
diff --git a/test/std/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.get/xsgetn.pass.cpp b/test/std/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.get/xsgetn.pass.cpp
new file mode 100644
index 000000000000..b1f15427367f
--- /dev/null
+++ b/test/std/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.get/xsgetn.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// streamsize xsgetn(char_type* s, streamsize n);
+
+#include <streambuf>
+#include <cassert>
+
+struct test
+ : public std::basic_streambuf<char>
+{
+ typedef std::basic_streambuf<char> base;
+
+ test() {}
+
+ void setg(char* gbeg, char* gnext, char* gend)
+ {
+ base::setg(gbeg, gnext, gend);
+ }
+};
+
+int main()
+{
+ test t;
+ char input[7] = "123456";
+ t.setg(input, input, input+7);
+ char output[sizeof(input)] = {0};
+ assert(t.sgetn(output, 10) == 7);
+ assert(strcmp(input, output) == 0);
+}
diff --git a/test/std/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.locales/nothing_to_do.pass.cpp b/test/std/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.locales/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.locales/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.pback/pbackfail.pass.cpp b/test/std/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.pback/pbackfail.pass.cpp
new file mode 100644
index 000000000000..3a10d8a70ad7
--- /dev/null
+++ b/test/std/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.pback/pbackfail.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// int_type pbackfail(int_type c = traits::eof());
+
+#include <streambuf>
+#include <cassert>
+
+int pbackfail_called = 0;
+
+struct test
+ : public std::basic_streambuf<char>
+{
+ test() {}
+};
+
+int main()
+{
+ test t;
+ assert(t.sputbackc('A') == -1);
+}
diff --git a/test/std/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.put/overflow.pass.cpp b/test/std/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.put/overflow.pass.cpp
new file mode 100644
index 000000000000..dcdd45f5ff10
--- /dev/null
+++ b/test/std/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.put/overflow.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// int_type overflow(int_type c = traits::eof());
+
+#include <streambuf>
+#include <cassert>
+
+struct test
+ : public std::basic_streambuf<char>
+{
+ test() {}
+};
+
+int main()
+{
+ test t;
+ assert(t.sputc('A') == -1);
+}
diff --git a/test/std/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.put/xsputn.pass.cpp b/test/std/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.put/xsputn.pass.cpp
new file mode 100644
index 000000000000..93dc15401e9f
--- /dev/null
+++ b/test/std/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.put/xsputn.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// streamsize xsputn(const char_type* s, streamsize n);
+
+#include <streambuf>
+#include <cassert>
+
+struct test
+ : public std::basic_streambuf<char>
+{
+ typedef std::basic_streambuf<char> base;
+
+ test() {}
+
+ void setp(char* pbeg, char* pend)
+ {
+ base::setp(pbeg, pend);
+ }
+};
+
+int main()
+{
+ {
+ test t;
+ char in[] = "123456";
+ assert(t.sputn(in, sizeof(in)) == 0);
+ char out[sizeof(in)] = {0};
+ t.setp(out, out+sizeof(out));
+ assert(t.sputn(in, sizeof(in)) == sizeof(in));
+ assert(strcmp(in, out) == 0);
+ }
+}
diff --git a/test/std/input.output/stream.buffers/streambuf/types.pass.cpp b/test/std/input.output/stream.buffers/streambuf/types.pass.cpp
new file mode 100644
index 000000000000..919caee3655f
--- /dev/null
+++ b/test/std/input.output/stream.buffers/streambuf/types.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf
+// {
+// public:
+// // types:
+// typedef charT char_type;
+// typedef traits traits_type;
+// typedef typename traits_type::int_type int_type;
+// typedef typename traits_type::pos_type pos_type;
+// typedef typename traits_type::off_type off_type;
+
+#include <streambuf>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_same<std::streambuf::char_type, char>::value), "");
+ static_assert((std::is_same<std::streambuf::traits_type, std::char_traits<char> >::value), "");
+ static_assert((std::is_same<std::streambuf::int_type, std::char_traits<char>::int_type>::value), "");
+ static_assert((std::is_same<std::streambuf::pos_type, std::char_traits<char>::pos_type>::value), "");
+ static_assert((std::is_same<std::streambuf::off_type, std::char_traits<char>::off_type>::value), "");
+
+ static_assert((std::is_same<std::wstreambuf::char_type, wchar_t>::value), "");
+ static_assert((std::is_same<std::wstreambuf::traits_type, std::char_traits<wchar_t> >::value), "");
+ static_assert((std::is_same<std::wstreambuf::int_type, std::char_traits<wchar_t>::int_type>::value), "");
+ static_assert((std::is_same<std::wstreambuf::pos_type, std::char_traits<wchar_t>::pos_type>::value), "");
+ static_assert((std::is_same<std::wstreambuf::off_type, std::char_traits<wchar_t>::off_type>::value), "");
+}
diff --git a/test/std/input.output/stream.buffers/version.pass.cpp b/test/std/input.output/stream.buffers/version.pass.cpp
new file mode 100644
index 000000000000..c4b06be60187
--- /dev/null
+++ b/test/std/input.output/stream.buffers/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+#include <streambuf>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/input.output/string.streams/istringstream/istringstream.assign/member_swap.pass.cpp b/test/std/input.output/string.streams/istringstream/istringstream.assign/member_swap.pass.cpp
new file mode 100644
index 000000000000..fc5f2e7e920f
--- /dev/null
+++ b/test/std/input.output/string.streams/istringstream/istringstream.assign/member_swap.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_istringstream
+
+// void swap(basic_istringstream& rhs);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::istringstream ss0(" 123 456");
+ std::istringstream ss(" 789 321");
+ ss.swap(ss0);
+ assert(ss.rdbuf() != 0);
+ assert(ss.good());
+ assert(ss.str() == " 123 456");
+ int i = 0;
+ ss >> i;
+ assert(i == 123);
+ ss >> i;
+ assert(i == 456);
+ ss0 >> i;
+ assert(i == 789);
+ ss0 >> i;
+ assert(i == 321);
+ }
+ {
+ std::wistringstream ss0(L" 123 456");
+ std::wistringstream ss(L" 789 321");
+ ss.swap(ss0);
+ assert(ss.rdbuf() != 0);
+ assert(ss.good());
+ assert(ss.str() == L" 123 456");
+ int i = 0;
+ ss >> i;
+ assert(i == 123);
+ ss >> i;
+ assert(i == 456);
+ ss0 >> i;
+ assert(i == 789);
+ ss0 >> i;
+ assert(i == 321);
+ }
+}
diff --git a/test/std/input.output/string.streams/istringstream/istringstream.assign/move.pass.cpp b/test/std/input.output/string.streams/istringstream/istringstream.assign/move.pass.cpp
new file mode 100644
index 000000000000..e57ad55c9078
--- /dev/null
+++ b/test/std/input.output/string.streams/istringstream/istringstream.assign/move.pass.cpp
@@ -0,0 +1,86 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_istringstream
+
+// basic_istringstream& operator=(basic_istringstream&& rhs);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::istringstream ss0(" 123 456");
+ std::istringstream ss;
+ ss = std::move(ss0);
+ assert(ss.rdbuf() != 0);
+ assert(ss.good());
+ assert(ss.str() == " 123 456");
+ int i = 0;
+ ss >> i;
+ assert(i == 123);
+ ss >> i;
+ assert(i == 456);
+ }
+ {
+ std::istringstream s1("Aaaaa Bbbbb Cccccccccc Dddddddddddddddddd");
+ std::string s;
+ s1 >> s;
+
+ std::istringstream s2 = std::move(s1);
+ s2 >> s;
+ assert(s == "Bbbbb");
+
+ std::istringstream s3;
+ s3 = std::move(s2);
+ s3 >> s;
+ assert(s == "Cccccccccc");
+
+ s1 = std::move(s3);
+ s1 >> s;
+ assert(s == "Dddddddddddddddddd");
+ }
+ {
+ std::wistringstream ss0(L" 123 456");
+ std::wistringstream ss;
+ ss = std::move(ss0);
+ assert(ss.rdbuf() != 0);
+ assert(ss.good());
+ assert(ss.str() == L" 123 456");
+ int i = 0;
+ ss >> i;
+ assert(i == 123);
+ ss >> i;
+ assert(i == 456);
+ }
+ {
+ std::wistringstream s1(L"Aaaaa Bbbbb Cccccccccc Dddddddddddddddddd");
+ std::wstring s;
+ s1 >> s;
+
+ std::wistringstream s2 = std::move(s1);
+ s2 >> s;
+ assert(s == L"Bbbbb");
+
+ std::wistringstream s3;
+ s3 = std::move(s2);
+ s3 >> s;
+ assert(s == L"Cccccccccc");
+
+ s1 = std::move(s3);
+ s1 >> s;
+ assert(s == L"Dddddddddddddddddd");
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/input.output/string.streams/istringstream/istringstream.assign/nonmember_swap.pass.cpp b/test/std/input.output/string.streams/istringstream/istringstream.assign/nonmember_swap.pass.cpp
new file mode 100644
index 000000000000..d72cef16076f
--- /dev/null
+++ b/test/std/input.output/string.streams/istringstream/istringstream.assign/nonmember_swap.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_istringstream
+
+// template <class charT, class traits, class Allocator>
+// void
+// swap(basic_istringstream<charT, traits, Allocator>& x,
+// basic_istringstream<charT, traits, Allocator>& y);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::istringstream ss0(" 123 456");
+ std::istringstream ss(" 789 321");
+ swap(ss, ss0);
+ assert(ss.rdbuf() != 0);
+ assert(ss.good());
+ assert(ss.str() == " 123 456");
+ int i = 0;
+ ss >> i;
+ assert(i == 123);
+ ss >> i;
+ assert(i == 456);
+ ss0 >> i;
+ assert(i == 789);
+ ss0 >> i;
+ assert(i == 321);
+ }
+ {
+ std::wistringstream ss0(L" 123 456");
+ std::wistringstream ss(L" 789 321");
+ swap(ss, ss0);
+ assert(ss.rdbuf() != 0);
+ assert(ss.good());
+ assert(ss.str() == L" 123 456");
+ int i = 0;
+ ss >> i;
+ assert(i == 123);
+ ss >> i;
+ assert(i == 456);
+ ss0 >> i;
+ assert(i == 789);
+ ss0 >> i;
+ assert(i == 321);
+ }
+}
diff --git a/test/std/input.output/string.streams/istringstream/istringstream.cons/default.pass.cpp b/test/std/input.output/string.streams/istringstream/istringstream.cons/default.pass.cpp
new file mode 100644
index 000000000000..5d44a50a3f67
--- /dev/null
+++ b/test/std/input.output/string.streams/istringstream/istringstream.cons/default.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_istringstream
+
+// explicit basic_istringstream(ios_base::openmode which = ios_base::in);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::istringstream ss;
+ assert(ss.rdbuf() != 0);
+ assert(ss.good());
+ assert(ss.str() == "");
+ }
+ {
+ std::istringstream ss(std::ios_base::in);
+ assert(ss.rdbuf() != 0);
+ assert(ss.good());
+ assert(ss.str() == "");
+ }
+ {
+ std::wistringstream ss;
+ assert(ss.rdbuf() != 0);
+ assert(ss.good());
+ assert(ss.str() == L"");
+ }
+ {
+ std::wistringstream ss(std::ios_base::in);
+ assert(ss.rdbuf() != 0);
+ assert(ss.good());
+ assert(ss.str() == L"");
+ }
+}
diff --git a/test/std/input.output/string.streams/istringstream/istringstream.cons/move.pass.cpp b/test/std/input.output/string.streams/istringstream/istringstream.cons/move.pass.cpp
new file mode 100644
index 000000000000..adc46ab65f5e
--- /dev/null
+++ b/test/std/input.output/string.streams/istringstream/istringstream.cons/move.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_istringstream
+
+// basic_istringstream(basic_istringstream&& rhs);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::istringstream ss0(" 123 456");
+ std::istringstream ss(std::move(ss0));
+ assert(ss.rdbuf() != 0);
+ assert(ss.good());
+ assert(ss.str() == " 123 456");
+ int i = 0;
+ ss >> i;
+ assert(i == 123);
+ ss >> i;
+ assert(i == 456);
+ }
+ {
+ std::wistringstream ss0(L" 123 456");
+ std::wistringstream ss(std::move(ss0));
+ assert(ss.rdbuf() != 0);
+ assert(ss.good());
+ assert(ss.str() == L" 123 456");
+ int i = 0;
+ ss >> i;
+ assert(i == 123);
+ ss >> i;
+ assert(i == 456);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/input.output/string.streams/istringstream/istringstream.cons/string.pass.cpp b/test/std/input.output/string.streams/istringstream/istringstream.cons/string.pass.cpp
new file mode 100644
index 000000000000..977923639699
--- /dev/null
+++ b/test/std/input.output/string.streams/istringstream/istringstream.cons/string.pass.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_istringstream
+
+// explicit basic_istringstream(const basic_string<charT,traits,allocator>& str,
+// ios_base::openmode which = ios_base::in);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::istringstream ss(" 123 456");
+ assert(ss.rdbuf() != 0);
+ assert(ss.good());
+ assert(ss.str() == " 123 456");
+ int i = 0;
+ ss >> i;
+ assert(i == 123);
+ ss >> i;
+ assert(i == 456);
+ }
+ {
+ std::istringstream ss(" 123 456", std::ios_base::out);
+ assert(ss.rdbuf() != 0);
+ assert(ss.good());
+ assert(ss.str() == " 123 456");
+ int i = 0;
+ ss >> i;
+ assert(i == 123);
+ ss >> i;
+ assert(i == 456);
+ }
+ {
+ std::wistringstream ss(L" 123 456");
+ assert(ss.rdbuf() != 0);
+ assert(ss.good());
+ assert(ss.str() == L" 123 456");
+ int i = 0;
+ ss >> i;
+ assert(i == 123);
+ ss >> i;
+ assert(i == 456);
+ }
+ {
+ std::wistringstream ss(L" 123 456", std::ios_base::out);
+ assert(ss.rdbuf() != 0);
+ assert(ss.good());
+ assert(ss.str() == L" 123 456");
+ int i = 0;
+ ss >> i;
+ assert(i == 123);
+ ss >> i;
+ assert(i == 456);
+ }
+}
diff --git a/test/std/input.output/string.streams/istringstream/istringstream.members/str.pass.cpp b/test/std/input.output/string.streams/istringstream/istringstream.members/str.pass.cpp
new file mode 100644
index 000000000000..448a6f89b259
--- /dev/null
+++ b/test/std/input.output/string.streams/istringstream/istringstream.members/str.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_istringstream
+
+// void str(const basic_string<charT,traits,Allocator>& s);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::istringstream ss(" 123 456");
+ assert(ss.rdbuf() != 0);
+ assert(ss.good());
+ assert(ss.str() == " 123 456");
+ int i = 0;
+ ss >> i;
+ assert(i == 123);
+ ss >> i;
+ assert(i == 456);
+ ss.str(" 789");
+ ss.clear();
+ assert(ss.good());
+ assert(ss.str() == " 789");
+ ss >> i;
+ assert(i == 789);
+ }
+ {
+ std::wistringstream ss(L" 123 456");
+ assert(ss.rdbuf() != 0);
+ assert(ss.good());
+ assert(ss.str() == L" 123 456");
+ int i = 0;
+ ss >> i;
+ assert(i == 123);
+ ss >> i;
+ assert(i == 456);
+ ss.str(L" 789");
+ ss.clear();
+ assert(ss.good());
+ assert(ss.str() == L" 789");
+ ss >> i;
+ assert(i == 789);
+ }
+}
diff --git a/test/std/input.output/string.streams/istringstream/types.pass.cpp b/test/std/input.output/string.streams/istringstream/types.pass.cpp
new file mode 100644
index 000000000000..349bcae1a1c1
--- /dev/null
+++ b/test/std/input.output/string.streams/istringstream/types.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_istringstream
+// : public basic_istream<charT, traits>
+// {
+// public:
+// typedef charT char_type;
+// typedef traits traits_type;
+// typedef typename traits_type::int_type int_type;
+// typedef typename traits_type::pos_type pos_type;
+// typedef typename traits_type::off_type off_type;
+// typedef Allocator allocator_type;
+
+#include <sstream>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_base_of<std::basic_istream<char>, std::basic_istringstream<char> >::value), "");
+ static_assert((std::is_same<std::basic_istringstream<char>::char_type, char>::value), "");
+ static_assert((std::is_same<std::basic_istringstream<char>::traits_type, std::char_traits<char> >::value), "");
+ static_assert((std::is_same<std::basic_istringstream<char>::int_type, std::char_traits<char>::int_type>::value), "");
+ static_assert((std::is_same<std::basic_istringstream<char>::pos_type, std::char_traits<char>::pos_type>::value), "");
+ static_assert((std::is_same<std::basic_istringstream<char>::off_type, std::char_traits<char>::off_type>::value), "");
+ static_assert((std::is_same<std::basic_istringstream<char>::allocator_type, std::allocator<char> >::value), "");
+}
diff --git a/test/std/input.output/string.streams/ostringstream/ostringstream.assign/member_swap.pass.cpp b/test/std/input.output/string.streams/ostringstream/ostringstream.assign/member_swap.pass.cpp
new file mode 100644
index 000000000000..eff47452c58f
--- /dev/null
+++ b/test/std/input.output/string.streams/ostringstream/ostringstream.assign/member_swap.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_ostringstream
+
+// void swap(basic_ostringstream& rhs);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::ostringstream ss0(" 123 456");
+ std::ostringstream ss;
+ ss.swap(ss0);
+ assert(ss.rdbuf() != 0);
+ assert(ss.good());
+ assert(ss.str() == " 123 456");
+ int i = 234;
+ ss << i << ' ' << 567;;
+ assert(ss.str() == "234 5676");
+ ss0 << i << ' ' << 567;;
+ assert(ss0.str() == "234 567");
+ }
+ {
+ std::wostringstream ss0(L" 123 456");
+ std::wostringstream ss;
+ ss.swap(ss0);
+ assert(ss.rdbuf() != 0);
+ assert(ss.good());
+ assert(ss.str() == L" 123 456");
+ int i = 234;
+ ss << i << ' ' << 567;;
+ assert(ss.str() == L"234 5676");
+ ss0 << i << ' ' << 567;;
+ assert(ss0.str() == L"234 567");
+ }
+}
diff --git a/test/std/input.output/string.streams/ostringstream/ostringstream.assign/move.pass.cpp b/test/std/input.output/string.streams/ostringstream/ostringstream.assign/move.pass.cpp
new file mode 100644
index 000000000000..a6fb8ba69b2e
--- /dev/null
+++ b/test/std/input.output/string.streams/ostringstream/ostringstream.assign/move.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_ostringstream
+
+// basic_ostringstream& operator=(basic_ostringstream&& rhs);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::ostringstream ss0(" 123 456");
+ std::ostringstream ss;
+ ss = std::move(ss0);
+ assert(ss.rdbuf() != 0);
+ assert(ss.good());
+ assert(ss.str() == " 123 456");
+ int i = 234;
+ ss << i << ' ' << 567;;
+ assert(ss.str() == "234 5676");
+ }
+ {
+ std::wostringstream ss0(L" 123 456");
+ std::wostringstream ss;
+ ss = std::move(ss0);
+ assert(ss.rdbuf() != 0);
+ assert(ss.good());
+ assert(ss.str() == L" 123 456");
+ int i = 234;
+ ss << i << ' ' << 567;;
+ assert(ss.str() == L"234 5676");
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/input.output/string.streams/ostringstream/ostringstream.assign/nonmember_swap.pass.cpp b/test/std/input.output/string.streams/ostringstream/ostringstream.assign/nonmember_swap.pass.cpp
new file mode 100644
index 000000000000..3d7081d8e241
--- /dev/null
+++ b/test/std/input.output/string.streams/ostringstream/ostringstream.assign/nonmember_swap.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_ostringstream
+
+// void swap(basic_ostringstream& rhs);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::ostringstream ss0(" 123 456");
+ std::ostringstream ss;
+ swap(ss, ss0);
+ assert(ss.rdbuf() != 0);
+ assert(ss.good());
+ assert(ss.str() == " 123 456");
+ int i = 234;
+ ss << i << ' ' << 567;;
+ assert(ss.str() == "234 5676");
+ ss0 << i << ' ' << 567;;
+ assert(ss0.str() == "234 567");
+ }
+ {
+ std::wostringstream ss0(L" 123 456");
+ std::wostringstream ss;
+ swap(ss, ss0);
+ assert(ss.rdbuf() != 0);
+ assert(ss.good());
+ assert(ss.str() == L" 123 456");
+ int i = 234;
+ ss << i << ' ' << 567;;
+ assert(ss.str() == L"234 5676");
+ ss0 << i << ' ' << 567;;
+ assert(ss0.str() == L"234 567");
+ }
+}
diff --git a/test/std/input.output/string.streams/ostringstream/ostringstream.cons/default.pass.cpp b/test/std/input.output/string.streams/ostringstream/ostringstream.cons/default.pass.cpp
new file mode 100644
index 000000000000..dde1dc719238
--- /dev/null
+++ b/test/std/input.output/string.streams/ostringstream/ostringstream.cons/default.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_ostringstream
+
+// explicit basic_ostringstream(ios_base::openmode which = ios_base::in);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::ostringstream ss;
+ assert(ss.rdbuf() != 0);
+ assert(ss.good());
+ assert(ss.str() == "");
+ }
+ {
+ std::ostringstream ss(std::ios_base::out);
+ assert(ss.rdbuf() != 0);
+ assert(ss.good());
+ assert(ss.str() == "");
+ }
+ {
+ std::wostringstream ss;
+ assert(ss.rdbuf() != 0);
+ assert(ss.good());
+ assert(ss.str() == L"");
+ }
+ {
+ std::wostringstream ss(std::ios_base::out);
+ assert(ss.rdbuf() != 0);
+ assert(ss.good());
+ assert(ss.str() == L"");
+ }
+}
diff --git a/test/std/input.output/string.streams/ostringstream/ostringstream.cons/move.pass.cpp b/test/std/input.output/string.streams/ostringstream/ostringstream.cons/move.pass.cpp
new file mode 100644
index 000000000000..dc63b59fe39f
--- /dev/null
+++ b/test/std/input.output/string.streams/ostringstream/ostringstream.cons/move.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_ostringstream
+
+// basic_ostringstream(basic_ostringstream&& rhs);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::ostringstream ss0(" 123 456");
+ std::ostringstream ss(std::move(ss0));
+ assert(ss.rdbuf() != 0);
+ assert(ss.good());
+ assert(ss.str() == " 123 456");
+ int i = 234;
+ ss << i << ' ' << 567;;
+ assert(ss.str() == "234 5676");
+ }
+ {
+ std::wostringstream ss0(L" 123 456");
+ std::wostringstream ss(std::move(ss0));
+ assert(ss.rdbuf() != 0);
+ assert(ss.good());
+ assert(ss.str() == L" 123 456");
+ int i = 234;
+ ss << i << ' ' << 567;;
+ assert(ss.str() == L"234 5676");
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/input.output/string.streams/ostringstream/ostringstream.cons/string.pass.cpp b/test/std/input.output/string.streams/ostringstream/ostringstream.cons/string.pass.cpp
new file mode 100644
index 000000000000..89c91bdee05d
--- /dev/null
+++ b/test/std/input.output/string.streams/ostringstream/ostringstream.cons/string.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_ostringstream
+
+// explicit basic_ostringstream(const basic_string<charT,traits,allocator>& str,
+// ios_base::openmode which = ios_base::in);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::ostringstream ss(" 123 456");
+ assert(ss.rdbuf() != 0);
+ assert(ss.good());
+ assert(ss.str() == " 123 456");
+ int i = 234;
+ ss << i << ' ' << 567;;
+ assert(ss.str() == "234 5676");
+ }
+ {
+ std::ostringstream ss(" 123 456", std::ios_base::in);
+ assert(ss.rdbuf() != 0);
+ assert(ss.good());
+ assert(ss.str() == " 123 456");
+ int i = 234;
+ ss << i << ' ' << 567;;
+ assert(ss.str() == "234 5676");
+ }
+ {
+ std::wostringstream ss(L" 123 456");
+ assert(ss.rdbuf() != 0);
+ assert(ss.good());
+ assert(ss.str() == L" 123 456");
+ int i = 234;
+ ss << i << ' ' << 567;;
+ assert(ss.str() == L"234 5676");
+ }
+ {
+ std::wostringstream ss(L" 123 456", std::ios_base::in);
+ assert(ss.rdbuf() != 0);
+ assert(ss.good());
+ assert(ss.str() == L" 123 456");
+ int i = 234;
+ ss << i << ' ' << 567;;
+ assert(ss.str() == L"234 5676");
+ }
+}
diff --git a/test/std/input.output/string.streams/ostringstream/ostringstream.members/str.pass.cpp b/test/std/input.output/string.streams/ostringstream/ostringstream.members/str.pass.cpp
new file mode 100644
index 000000000000..ab277a2eeac7
--- /dev/null
+++ b/test/std/input.output/string.streams/ostringstream/ostringstream.members/str.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_ostringstream
+
+// void str(const basic_string<charT,traits,Allocator>& s);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::ostringstream ss(" 123 456");
+ assert(ss.rdbuf() != 0);
+ assert(ss.good());
+ assert(ss.str() == " 123 456");
+ int i = 0;
+ ss << i;
+ assert(ss.str() == "0123 456");
+ ss << 456;
+ assert(ss.str() == "0456 456");
+ ss.str(" 789");
+ assert(ss.str() == " 789");
+ ss << "abc";
+ assert(ss.str() == "abc9");
+ }
+ {
+ std::wostringstream ss(L" 123 456");
+ assert(ss.rdbuf() != 0);
+ assert(ss.good());
+ assert(ss.str() == L" 123 456");
+ int i = 0;
+ ss << i;
+ assert(ss.str() == L"0123 456");
+ ss << 456;
+ assert(ss.str() == L"0456 456");
+ ss.str(L" 789");
+ assert(ss.str() == L" 789");
+ ss << L"abc";
+ assert(ss.str() == L"abc9");
+ }
+}
diff --git a/test/std/input.output/string.streams/ostringstream/types.pass.cpp b/test/std/input.output/string.streams/ostringstream/types.pass.cpp
new file mode 100644
index 000000000000..c9cb763784ef
--- /dev/null
+++ b/test/std/input.output/string.streams/ostringstream/types.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_ostringstream
+// : public basic_ostream<charT, traits>
+// {
+// public:
+// typedef charT char_type;
+// typedef traits traits_type;
+// typedef typename traits_type::int_type int_type;
+// typedef typename traits_type::pos_type pos_type;
+// typedef typename traits_type::off_type off_type;
+// typedef Allocator allocator_type;
+
+#include <sstream>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_base_of<std::basic_ostream<char>, std::basic_ostringstream<char> >::value), "");
+ static_assert((std::is_same<std::basic_ostringstream<char>::char_type, char>::value), "");
+ static_assert((std::is_same<std::basic_ostringstream<char>::traits_type, std::char_traits<char> >::value), "");
+ static_assert((std::is_same<std::basic_ostringstream<char>::int_type, std::char_traits<char>::int_type>::value), "");
+ static_assert((std::is_same<std::basic_ostringstream<char>::pos_type, std::char_traits<char>::pos_type>::value), "");
+ static_assert((std::is_same<std::basic_ostringstream<char>::off_type, std::char_traits<char>::off_type>::value), "");
+ static_assert((std::is_same<std::basic_ostringstream<char>::allocator_type, std::allocator<char> >::value), "");
+}
diff --git a/test/std/input.output/string.streams/stringbuf/stringbuf.assign/member_swap.pass.cpp b/test/std/input.output/string.streams/stringbuf/stringbuf.assign/member_swap.pass.cpp
new file mode 100644
index 000000000000..eaca7245461f
--- /dev/null
+++ b/test/std/input.output/string.streams/stringbuf/stringbuf.assign/member_swap.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringbuf
+
+// void swap(basic_stringbuf& rhs);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::stringbuf buf1("testing");
+ std::stringbuf buf;
+ buf.swap(buf1);
+ assert(buf.str() == "testing");
+ assert(buf1.str() == "");
+ }
+ {
+ std::stringbuf buf1("testing", std::ios_base::in);
+ std::stringbuf buf;
+ buf.swap(buf1);
+ assert(buf.str() == "testing");
+ assert(buf1.str() == "");
+ }
+ {
+ std::stringbuf buf1("testing", std::ios_base::out);
+ std::stringbuf buf;
+ buf.swap(buf1);
+ assert(buf.str() == "testing");
+ assert(buf1.str() == "");
+ }
+ {
+ std::wstringbuf buf1(L"testing");
+ std::wstringbuf buf;
+ buf.swap(buf1);
+ assert(buf.str() == L"testing");
+ assert(buf1.str() == L"");
+ }
+ {
+ std::wstringbuf buf1(L"testing", std::ios_base::in);
+ std::wstringbuf buf;
+ buf.swap(buf1);
+ assert(buf.str() == L"testing");
+ assert(buf1.str() == L"");
+ }
+ {
+ std::wstringbuf buf1(L"testing", std::ios_base::out);
+ std::wstringbuf buf;
+ buf.swap(buf1);
+ assert(buf.str() == L"testing");
+ assert(buf1.str() == L"");
+ }
+}
diff --git a/test/std/input.output/string.streams/stringbuf/stringbuf.assign/move.pass.cpp b/test/std/input.output/string.streams/stringbuf/stringbuf.assign/move.pass.cpp
new file mode 100644
index 000000000000..716b6afa755a
--- /dev/null
+++ b/test/std/input.output/string.streams/stringbuf/stringbuf.assign/move.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringbuf
+
+// basic_stringbuf& operator=(basic_stringbuf&& rhs);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::stringbuf buf1("testing");
+ std::stringbuf buf;
+ buf = move(buf1);
+ assert(buf.str() == "testing");
+ }
+ {
+ std::stringbuf buf1("testing", std::ios_base::in);
+ std::stringbuf buf;
+ buf = move(buf1);
+ assert(buf.str() == "testing");
+ }
+ {
+ std::stringbuf buf1("testing", std::ios_base::out);
+ std::stringbuf buf;
+ buf = move(buf1);
+ assert(buf.str() == "testing");
+ }
+ {
+ std::wstringbuf buf1(L"testing");
+ std::wstringbuf buf;
+ buf = move(buf1);
+ assert(buf.str() == L"testing");
+ }
+ {
+ std::wstringbuf buf1(L"testing", std::ios_base::in);
+ std::wstringbuf buf;
+ buf = move(buf1);
+ assert(buf.str() == L"testing");
+ }
+ {
+ std::wstringbuf buf1(L"testing", std::ios_base::out);
+ std::wstringbuf buf;
+ buf = move(buf1);
+ assert(buf.str() == L"testing");
+ }
+}
diff --git a/test/std/input.output/string.streams/stringbuf/stringbuf.assign/nonmember_swap.pass.cpp b/test/std/input.output/string.streams/stringbuf/stringbuf.assign/nonmember_swap.pass.cpp
new file mode 100644
index 000000000000..dca637d39fab
--- /dev/null
+++ b/test/std/input.output/string.streams/stringbuf/stringbuf.assign/nonmember_swap.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringbuf
+
+// template <class charT, class traits, class Allocator>
+// void swap(basic_stringbuf<charT, traits, Allocator>& x,
+// basic_stringbuf<charT, traits, Allocator>& y);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::stringbuf buf1("testing");
+ std::stringbuf buf;
+ swap(buf, buf1);
+ assert(buf.str() == "testing");
+ assert(buf1.str() == "");
+ }
+ {
+ std::stringbuf buf1("testing", std::ios_base::in);
+ std::stringbuf buf;
+ swap(buf, buf1);
+ assert(buf.str() == "testing");
+ assert(buf1.str() == "");
+ }
+ {
+ std::stringbuf buf1("testing", std::ios_base::out);
+ std::stringbuf buf;
+ swap(buf, buf1);
+ assert(buf.str() == "testing");
+ assert(buf1.str() == "");
+ }
+ {
+ std::wstringbuf buf1(L"testing");
+ std::wstringbuf buf;
+ swap(buf, buf1);
+ assert(buf.str() == L"testing");
+ assert(buf1.str() == L"");
+ }
+ {
+ std::wstringbuf buf1(L"testing", std::ios_base::in);
+ std::wstringbuf buf;
+ swap(buf, buf1);
+ assert(buf.str() == L"testing");
+ assert(buf1.str() == L"");
+ }
+ {
+ std::wstringbuf buf1(L"testing", std::ios_base::out);
+ std::wstringbuf buf;
+ swap(buf, buf1);
+ assert(buf.str() == L"testing");
+ assert(buf1.str() == L"");
+ }
+}
diff --git a/test/std/input.output/string.streams/stringbuf/stringbuf.cons/default.pass.cpp b/test/std/input.output/string.streams/stringbuf/stringbuf.cons/default.pass.cpp
new file mode 100644
index 000000000000..28007c8edf45
--- /dev/null
+++ b/test/std/input.output/string.streams/stringbuf/stringbuf.cons/default.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringbuf
+
+// explicit basic_stringbuf(ios_base::openmode which = ios_base::in | ios_base::out);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::stringbuf buf;
+ assert(buf.str() == "");
+ }
+ {
+ std::wstringbuf buf;
+ assert(buf.str() == L"");
+ }
+}
diff --git a/test/std/input.output/string.streams/stringbuf/stringbuf.cons/move.pass.cpp b/test/std/input.output/string.streams/stringbuf/stringbuf.cons/move.pass.cpp
new file mode 100644
index 000000000000..14fd0caa5cb9
--- /dev/null
+++ b/test/std/input.output/string.streams/stringbuf/stringbuf.cons/move.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringbuf
+
+// basic_stringbuf(basic_stringbuf&& rhs);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::stringbuf buf1("testing");
+ std::stringbuf buf(move(buf1));
+ assert(buf.str() == "testing");
+ }
+ {
+ std::stringbuf buf1("testing", std::ios_base::in);
+ std::stringbuf buf(move(buf1));
+ assert(buf.str() == "testing");
+ }
+ {
+ std::stringbuf buf1("testing", std::ios_base::out);
+ std::stringbuf buf(move(buf1));
+ assert(buf.str() == "testing");
+ }
+ {
+ std::wstringbuf buf1(L"testing");
+ std::wstringbuf buf(move(buf1));
+ assert(buf.str() == L"testing");
+ }
+ {
+ std::wstringbuf buf1(L"testing", std::ios_base::in);
+ std::wstringbuf buf(move(buf1));
+ assert(buf.str() == L"testing");
+ }
+ {
+ std::wstringbuf buf1(L"testing", std::ios_base::out);
+ std::wstringbuf buf(move(buf1));
+ assert(buf.str() == L"testing");
+ }
+}
diff --git a/test/std/input.output/string.streams/stringbuf/stringbuf.cons/string.pass.cpp b/test/std/input.output/string.streams/stringbuf/stringbuf.cons/string.pass.cpp
new file mode 100644
index 000000000000..eae1b0b87653
--- /dev/null
+++ b/test/std/input.output/string.streams/stringbuf/stringbuf.cons/string.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringbuf
+
+// explicit basic_stringbuf(const basic_string<charT,traits,Allocator>& s,
+// ios_base::openmode which = ios_base::in | ios_base::out);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::stringbuf buf("testing");
+ assert(buf.str() == "testing");
+ }
+ {
+ std::stringbuf buf("testing", std::ios_base::in);
+ assert(buf.str() == "testing");
+ }
+ {
+ std::stringbuf buf("testing", std::ios_base::out);
+ assert(buf.str() == "testing");
+ }
+ {
+ std::wstringbuf buf(L"testing");
+ assert(buf.str() == L"testing");
+ }
+ {
+ std::wstringbuf buf(L"testing", std::ios_base::in);
+ assert(buf.str() == L"testing");
+ }
+ {
+ std::wstringbuf buf(L"testing", std::ios_base::out);
+ assert(buf.str() == L"testing");
+ }
+}
diff --git a/test/std/input.output/string.streams/stringbuf/stringbuf.members/str.pass.cpp b/test/std/input.output/string.streams/stringbuf/stringbuf.members/str.pass.cpp
new file mode 100644
index 000000000000..712e0edd27b5
--- /dev/null
+++ b/test/std/input.output/string.streams/stringbuf/stringbuf.members/str.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringbuf
+
+// void str(const basic_string<charT,traits,Allocator>& s);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::stringbuf buf("testing");
+ assert(buf.str() == "testing");
+ buf.str("another test");
+ assert(buf.str() == "another test");
+ }
+ {
+ std::wstringbuf buf(L"testing");
+ assert(buf.str() == L"testing");
+ buf.str(L"another test");
+ assert(buf.str() == L"another test");
+ }
+}
diff --git a/test/std/input.output/string.streams/stringbuf/stringbuf.virtuals/overflow.pass.cpp b/test/std/input.output/string.streams/stringbuf/stringbuf.virtuals/overflow.pass.cpp
new file mode 100644
index 000000000000..3abf9423a12e
--- /dev/null
+++ b/test/std/input.output/string.streams/stringbuf/stringbuf.virtuals/overflow.pass.cpp
@@ -0,0 +1,97 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringbuf
+
+// int_type overflow(int_type c = traits::eof());
+
+#include <sstream>
+#include <cassert>
+
+int overflow_called = 0;
+
+template <class CharT>
+struct testbuf
+ : public std::basic_stringbuf<CharT>
+{
+ typedef std::basic_stringbuf<CharT> base;
+ explicit testbuf(const std::basic_string<CharT>& str,
+ std::ios_base::openmode which = std::ios_base::in | std::ios_base::out)
+ : base(str, which) {}
+
+ typename base::int_type
+ overflow(typename base::int_type c = base::type_traits::eof())
+ {++overflow_called; return base::overflow(c);}
+
+ void pbump(int n) {base::pbump(n);}
+};
+
+int main()
+{
+ {
+ testbuf<char> sb("abc");
+ assert(sb.sputc('1') == '1');
+ assert(sb.str() == "1bc");
+ assert(sb.sputc('2') == '2');
+ assert(sb.str() == "12c");
+ assert(sb.sputc('3') == '3');
+ assert(sb.str() == "123");
+ assert(sb.sputc('4') == '4');
+ assert(sb.str() == "1234");
+ assert(sb.sputc('5') == '5');
+ assert(sb.str() == "12345");
+ assert(sb.sputc('6') == '6');
+ assert(sb.str() == "123456");
+ assert(sb.sputc('7') == '7');
+ assert(sb.str() == "1234567");
+ assert(sb.sputc('8') == '8');
+ assert(sb.str() == "12345678");
+ assert(sb.sputc('9') == '9');
+ assert(sb.str() == "123456789");
+ assert(sb.sputc('0') == '0');
+ assert(sb.str() == "1234567890");
+ assert(sb.sputc('1') == '1');
+ assert(sb.str() == "12345678901");
+ }
+ {
+ testbuf<wchar_t> sb(L"abc");
+ assert(sb.sputc(L'1') == L'1');
+ assert(sb.str() == L"1bc");
+ assert(sb.sputc(L'2') == L'2');
+ assert(sb.str() == L"12c");
+ assert(sb.sputc(L'3') == L'3');
+ assert(sb.str() == L"123");
+ assert(sb.sputc(L'4') == L'4');
+ assert(sb.str() == L"1234");
+ assert(sb.sputc(L'5') == L'5');
+ assert(sb.str() == L"12345");
+ assert(sb.sputc(L'6') == L'6');
+ assert(sb.str() == L"123456");
+ assert(sb.sputc(L'7') == L'7');
+ assert(sb.str() == L"1234567");
+ assert(sb.sputc(L'8') == L'8');
+ assert(sb.str() == L"12345678");
+ assert(sb.sputc(L'9') == L'9');
+ assert(sb.str() == L"123456789");
+ assert(sb.sputc(L'0') == L'0');
+ assert(sb.str() == L"1234567890");
+ assert(sb.sputc(L'1') == L'1');
+ assert(sb.str() == L"12345678901");
+ }
+ {
+ testbuf<char> sb("abc", std::ios_base::app | std::ios_base::out);
+ assert(sb.sputc('1') == '1');
+ assert(sb.str() == "abc1");
+ assert(sb.sputc('2') == '2');
+ assert(sb.str() == "abc12");
+ }
+}
diff --git a/test/std/input.output/string.streams/stringbuf/stringbuf.virtuals/pbackfail.pass.cpp b/test/std/input.output/string.streams/stringbuf/stringbuf.virtuals/pbackfail.pass.cpp
new file mode 100644
index 000000000000..4af0e63029a7
--- /dev/null
+++ b/test/std/input.output/string.streams/stringbuf/stringbuf.virtuals/pbackfail.pass.cpp
@@ -0,0 +1,92 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringbuf
+
+// int_type pbackfail(int_type c = traits::eof());
+
+#include <sstream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+ : public std::basic_stringbuf<CharT>
+{
+ typedef std::basic_stringbuf<CharT> base;
+ explicit testbuf(const std::basic_string<CharT>& str,
+ std::ios_base::openmode which = std::ios_base::in | std::ios_base::out)
+ : base(str, which) {}
+
+ typename base::int_type
+ pbackfail(typename base::int_type c = base::type_traits::eof())
+ {return base::pbackfail(c);}
+
+ void pbump(int n) {base::pbump(n);}
+};
+
+int main()
+{
+ {
+ testbuf<char> sb("123", std::ios_base::in);
+ assert(sb.sgetc() == '1');
+ assert(sb.snextc() == '2');
+ assert(sb.snextc() == '3');
+ assert(sb.sgetc() == '3');
+ assert(sb.snextc() == std::char_traits<char>::eof());
+ assert(sb.pbackfail('3') == '3');
+ assert(sb.pbackfail('3') == std::char_traits<char>::eof());
+ assert(sb.pbackfail('2') == '2');
+ assert(sb.pbackfail(std::char_traits<char>::eof()) != std::char_traits<char>::eof());
+ assert(sb.pbackfail(std::char_traits<char>::eof()) == std::char_traits<char>::eof());
+ assert(sb.str() == "123");
+ }
+ {
+ testbuf<char> sb("123");
+ assert(sb.sgetc() == '1');
+ assert(sb.snextc() == '2');
+ assert(sb.snextc() == '3');
+ assert(sb.sgetc() == '3');
+ assert(sb.snextc() == std::char_traits<char>::eof());
+ assert(sb.pbackfail('3') == '3');
+ assert(sb.pbackfail('3') == '3');
+ assert(sb.pbackfail(std::char_traits<char>::eof()) != std::char_traits<char>::eof());
+ assert(sb.pbackfail(std::char_traits<char>::eof()) == std::char_traits<char>::eof());
+ assert(sb.str() == "133");
+ }
+ {
+ testbuf<wchar_t> sb(L"123", std::ios_base::in);
+ assert(sb.sgetc() == L'1');
+ assert(sb.snextc() == L'2');
+ assert(sb.snextc() == L'3');
+ assert(sb.sgetc() == L'3');
+ assert(sb.snextc() == std::char_traits<wchar_t>::eof());
+ assert(sb.pbackfail(L'3') == L'3');
+ assert(sb.pbackfail(L'3') == std::char_traits<wchar_t>::eof());
+ assert(sb.pbackfail(L'2') == L'2');
+ assert(sb.pbackfail(std::char_traits<wchar_t>::eof()) != std::char_traits<wchar_t>::eof());
+ assert(sb.pbackfail(std::char_traits<wchar_t>::eof()) == std::char_traits<wchar_t>::eof());
+ assert(sb.str() == L"123");
+ }
+ {
+ testbuf<wchar_t> sb(L"123");
+ assert(sb.sgetc() == L'1');
+ assert(sb.snextc() == L'2');
+ assert(sb.snextc() == L'3');
+ assert(sb.sgetc() == L'3');
+ assert(sb.snextc() == std::char_traits<wchar_t>::eof());
+ assert(sb.pbackfail(L'3') == L'3');
+ assert(sb.pbackfail(L'3') == L'3');
+ assert(sb.pbackfail(std::char_traits<wchar_t>::eof()) != std::char_traits<wchar_t>::eof());
+ assert(sb.pbackfail(std::char_traits<wchar_t>::eof()) == std::char_traits<wchar_t>::eof());
+ assert(sb.str() == L"133");
+ }
+}
diff --git a/test/std/input.output/string.streams/stringbuf/stringbuf.virtuals/seekoff.pass.cpp b/test/std/input.output/string.streams/stringbuf/stringbuf.virtuals/seekoff.pass.cpp
new file mode 100644
index 000000000000..6d20db13189a
--- /dev/null
+++ b/test/std/input.output/string.streams/stringbuf/stringbuf.virtuals/seekoff.pass.cpp
@@ -0,0 +1,143 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringbuf
+
+// pos_type seekoff(off_type off, ios_base::seekdir way,
+// ios_base::openmode which = ios_base::in | ios_base::out);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::stringbuf sb("0123456789", std::ios_base::in);
+ assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::out) == -1);
+ assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::out) == -1);
+ assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::out) == -1);
+ assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::in | std::ios_base::out) == -1);
+ assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::in | std::ios_base::out) == -1);
+ assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::in | std::ios_base::out) == -1);
+ assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::in) == 3);
+ assert(sb.sgetc() == '3');
+ assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::in) == 6);
+ assert(sb.sgetc() == '6');
+ assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::in) == 7);
+ assert(sb.sgetc() == '7');
+ }
+ {
+ std::stringbuf sb("0123456789", std::ios_base::out);
+ assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::in) == -1);
+ assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::in) == -1);
+ assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::in) == -1);
+ assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::out | std::ios_base::in) == -1);
+ assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::out | std::ios_base::in) == -1);
+ assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::out | std::ios_base::in) == -1);
+ assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::out) == 3);
+ assert(sb.sputc('a') == 'a');
+ assert(sb.str() == "012a456789");
+ assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::out) == 7);
+ assert(sb.sputc('b') == 'b');
+ assert(sb.str() == "012a456b89");
+ assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::out) == 7);
+ assert(sb.sputc('c') == 'c');
+ assert(sb.str() == "012a456c89");
+ }
+ {
+ std::stringbuf sb("0123456789");
+ assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::in) == 3);
+ assert(sb.sgetc() == '3');
+ assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::in) == 6);
+ assert(sb.sgetc() == '6');
+ assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::in) == 7);
+ assert(sb.sgetc() == '7');
+ assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::out | std::ios_base::in) == 3);
+ assert(sb.sgetc() == '3');
+ assert(sb.sputc('a') == 'a');
+ assert(sb.str() == "012a456789");
+ assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::out | std::ios_base::in) == -1);
+ assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::out | std::ios_base::in) == 7);
+ assert(sb.sgetc() == '7');
+ assert(sb.sputc('c') == 'c');
+ assert(sb.str() == "012a456c89");
+ assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::out) == 3);
+ assert(sb.sputc('3') == '3');
+ assert(sb.str() == "0123456c89");
+ assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::out) == 7);
+ assert(sb.sputc('7') == '7');
+ assert(sb.str() == "0123456789");
+ assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::out) == 7);
+ assert(sb.sputc('c') == 'c');
+ assert(sb.str() == "0123456c89");
+ }
+ {
+ std::wstringbuf sb(L"0123456789", std::ios_base::in);
+ assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::out) == -1);
+ assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::out) == -1);
+ assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::out) == -1);
+ assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::in | std::ios_base::out) == -1);
+ assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::in | std::ios_base::out) == -1);
+ assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::in | std::ios_base::out) == -1);
+ assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::in) == 3);
+ assert(sb.sgetc() == L'3');
+ assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::in) == 6);
+ assert(sb.sgetc() == L'6');
+ assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::in) == 7);
+ assert(sb.sgetc() == L'7');
+ }
+ {
+ std::wstringbuf sb(L"0123456789", std::ios_base::out);
+ assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::in) == -1);
+ assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::in) == -1);
+ assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::in) == -1);
+ assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::out | std::ios_base::in) == -1);
+ assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::out | std::ios_base::in) == -1);
+ assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::out | std::ios_base::in) == -1);
+ assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::out) == 3);
+ assert(sb.sputc(L'a') == L'a');
+ assert(sb.str() == L"012a456789");
+ assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::out) == 7);
+ assert(sb.sputc(L'b') == L'b');
+ assert(sb.str() == L"012a456b89");
+ assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::out) == 7);
+ assert(sb.sputc(L'c') == L'c');
+ assert(sb.str() == L"012a456c89");
+ }
+ {
+ std::wstringbuf sb(L"0123456789");
+ assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::in) == 3);
+ assert(sb.sgetc() == L'3');
+ assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::in) == 6);
+ assert(sb.sgetc() == L'6');
+ assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::in) == 7);
+ assert(sb.sgetc() == L'7');
+ assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::out | std::ios_base::in) == 3);
+ assert(sb.sgetc() == L'3');
+ assert(sb.sputc(L'a') == L'a');
+ assert(sb.str() == L"012a456789");
+ assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::out | std::ios_base::in) == -1);
+ assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::out | std::ios_base::in) == 7);
+ assert(sb.sgetc() == L'7');
+ assert(sb.sputc(L'c') == L'c');
+ assert(sb.str() == L"012a456c89");
+ assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::out) == 3);
+ assert(sb.sputc(L'3') == L'3');
+ assert(sb.str() == L"0123456c89");
+ assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::out) == 7);
+ assert(sb.sputc(L'7') == L'7');
+ assert(sb.str() == L"0123456789");
+ assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::out) == 7);
+ assert(sb.sputc(L'c') == L'c');
+ assert(sb.str() == L"0123456c89");
+ }
+}
diff --git a/test/std/input.output/string.streams/stringbuf/stringbuf.virtuals/seekpos.pass.cpp b/test/std/input.output/string.streams/stringbuf/stringbuf.virtuals/seekpos.pass.cpp
new file mode 100644
index 000000000000..2b809a887a35
--- /dev/null
+++ b/test/std/input.output/string.streams/stringbuf/stringbuf.virtuals/seekpos.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringbuf
+
+// pos_type seekpos(pos_type sp,
+// ios_base::openmode which = ios_base::in | ios_base::out);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::stringbuf sb("0123456789", std::ios_base::in);
+ assert(sb.pubseekpos(3, std::ios_base::out) == -1);
+ assert(sb.pubseekpos(3, std::ios_base::in | std::ios_base::out) == -1);
+ assert(sb.pubseekpos(3, std::ios_base::in) == 3);
+ assert(sb.sgetc() == '3');
+ }
+ {
+ std::stringbuf sb("0123456789", std::ios_base::out);
+ assert(sb.pubseekpos(3, std::ios_base::in) == -1);
+ assert(sb.pubseekpos(3, std::ios_base::out | std::ios_base::in) == -1);
+ assert(sb.pubseekpos(3, std::ios_base::out) == 3);
+ assert(sb.sputc('a') == 'a');
+ assert(sb.str() == "012a456789");
+ }
+ {
+ std::stringbuf sb("0123456789");
+ assert(sb.pubseekpos(3, std::ios_base::in) == 3);
+ assert(sb.sgetc() == '3');
+ assert(sb.pubseekpos(3, std::ios_base::out | std::ios_base::in) == 3);
+ assert(sb.sgetc() == '3');
+ assert(sb.sputc('a') == 'a');
+ assert(sb.str() == "012a456789");
+ assert(sb.pubseekpos(3, std::ios_base::out) == 3);
+ assert(sb.sputc('3') == '3');
+ assert(sb.str() == "0123456789");
+ }
+ {
+ std::wstringbuf sb(L"0123456789", std::ios_base::in);
+ assert(sb.pubseekpos(3, std::ios_base::out) == -1);
+ assert(sb.pubseekpos(3, std::ios_base::in | std::ios_base::out) == -1);
+ assert(sb.pubseekpos(3, std::ios_base::in) == 3);
+ assert(sb.sgetc() == L'3');
+ }
+ {
+ std::wstringbuf sb(L"0123456789", std::ios_base::out);
+ assert(sb.pubseekpos(3, std::ios_base::in) == -1);
+ assert(sb.pubseekpos(3, std::ios_base::out | std::ios_base::in) == -1);
+ assert(sb.pubseekpos(3, std::ios_base::out) == 3);
+ assert(sb.sputc(L'a') == L'a');
+ assert(sb.str() == L"012a456789");
+ }
+ {
+ std::wstringbuf sb(L"0123456789");
+ assert(sb.pubseekpos(3, std::ios_base::in) == 3);
+ assert(sb.sgetc() == L'3');
+ assert(sb.pubseekpos(3, std::ios_base::out | std::ios_base::in) == 3);
+ assert(sb.sgetc() == L'3');
+ assert(sb.sputc(L'a') == L'a');
+ assert(sb.str() == L"012a456789");
+ assert(sb.pubseekpos(3, std::ios_base::out) == 3);
+ assert(sb.sputc(L'3') == L'3');
+ assert(sb.str() == L"0123456789");
+ }
+}
diff --git a/test/std/input.output/string.streams/stringbuf/stringbuf.virtuals/setbuf.pass.cpp b/test/std/input.output/string.streams/stringbuf/stringbuf.virtuals/setbuf.pass.cpp
new file mode 100644
index 000000000000..7130f5b8646f
--- /dev/null
+++ b/test/std/input.output/string.streams/stringbuf/stringbuf.virtuals/setbuf.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringbuf
+
+// basic_streambuf<charT,traits>* setbuf(charT* s, streamsize n);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::stringbuf sb("0123456789");
+ assert(sb.pubsetbuf(0, 0) == &sb);
+ assert(sb.str() == "0123456789");
+ }
+ {
+ std::wstringbuf sb(L"0123456789");
+ assert(sb.pubsetbuf(0, 0) == &sb);
+ assert(sb.str() == L"0123456789");
+ }
+}
diff --git a/test/std/input.output/string.streams/stringbuf/stringbuf.virtuals/underflow.pass.cpp b/test/std/input.output/string.streams/stringbuf/stringbuf.virtuals/underflow.pass.cpp
new file mode 100644
index 000000000000..3641af239d7d
--- /dev/null
+++ b/test/std/input.output/string.streams/stringbuf/stringbuf.virtuals/underflow.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringbuf
+
+// int_type underflow();
+
+#include <sstream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+ : public std::basic_stringbuf<CharT>
+{
+ typedef std::basic_stringbuf<CharT> base;
+ explicit testbuf(const std::basic_string<CharT>& str)
+ : base(str) {}
+
+ typename base::int_type underflow() {return base::underflow();}
+ void pbump(int n) {base::pbump(n);}
+};
+
+int main()
+{
+ {
+ testbuf<char> sb("123");
+ sb.pbump(3);
+ assert(sb.underflow() == '1');
+ assert(sb.underflow() == '1');
+ assert(sb.snextc() == '2');
+ assert(sb.underflow() == '2');
+ assert(sb.underflow() == '2');
+ assert(sb.snextc() == '3');
+ assert(sb.underflow() == '3');
+ assert(sb.underflow() == '3');
+ assert(sb.snextc() == std::char_traits<char>::eof());
+ assert(sb.underflow() == std::char_traits<char>::eof());
+ assert(sb.underflow() == std::char_traits<char>::eof());
+ sb.sputc('4');
+ assert(sb.underflow() == '4');
+ assert(sb.underflow() == '4');
+ }
+ {
+ testbuf<wchar_t> sb(L"123");
+ sb.pbump(3);
+ assert(sb.underflow() == L'1');
+ assert(sb.underflow() == L'1');
+ assert(sb.snextc() == L'2');
+ assert(sb.underflow() == L'2');
+ assert(sb.underflow() == L'2');
+ assert(sb.snextc() == L'3');
+ assert(sb.underflow() == L'3');
+ assert(sb.underflow() == L'3');
+ assert(sb.snextc() == std::char_traits<wchar_t>::eof());
+ assert(sb.underflow() == std::char_traits<wchar_t>::eof());
+ assert(sb.underflow() == std::char_traits<wchar_t>::eof());
+ sb.sputc(L'4');
+ assert(sb.underflow() == L'4');
+ assert(sb.underflow() == L'4');
+ }
+}
diff --git a/test/std/input.output/string.streams/stringbuf/types.pass.cpp b/test/std/input.output/string.streams/stringbuf/types.pass.cpp
new file mode 100644
index 000000000000..067a3a29e0f9
--- /dev/null
+++ b/test/std/input.output/string.streams/stringbuf/types.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringbuf
+// : public basic_streambuf<charT, traits>
+// {
+// public:
+// typedef charT char_type;
+// typedef traits traits_type;
+// typedef typename traits_type::int_type int_type;
+// typedef typename traits_type::pos_type pos_type;
+// typedef typename traits_type::off_type off_type;
+// typedef Allocator allocator_type;
+
+#include <sstream>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_base_of<std::basic_streambuf<char>, std::basic_stringbuf<char> >::value), "");
+ static_assert((std::is_same<std::basic_stringbuf<char>::char_type, char>::value), "");
+ static_assert((std::is_same<std::basic_stringbuf<char>::traits_type, std::char_traits<char> >::value), "");
+ static_assert((std::is_same<std::basic_stringbuf<char>::int_type, std::char_traits<char>::int_type>::value), "");
+ static_assert((std::is_same<std::basic_stringbuf<char>::pos_type, std::char_traits<char>::pos_type>::value), "");
+ static_assert((std::is_same<std::basic_stringbuf<char>::off_type, std::char_traits<char>::off_type>::value), "");
+ static_assert((std::is_same<std::basic_stringbuf<char>::allocator_type, std::allocator<char> >::value), "");
+}
diff --git a/test/std/input.output/string.streams/stringstream.cons/default.pass.cpp b/test/std/input.output/string.streams/stringstream.cons/default.pass.cpp
new file mode 100644
index 000000000000..b8905ade3408
--- /dev/null
+++ b/test/std/input.output/string.streams/stringstream.cons/default.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringstream
+
+// explicit basic_stringstream(ios_base::openmode which = ios_base::out|ios_base::in);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::stringstream ss;
+ assert(ss.rdbuf() != 0);
+ assert(ss.good());
+ assert(ss.str() == "");
+ }
+ {
+ std::stringstream ss(std::ios_base::in);
+ assert(ss.rdbuf() != 0);
+ assert(ss.good());
+ assert(ss.str() == "");
+ }
+ {
+ std::wstringstream ss;
+ assert(ss.rdbuf() != 0);
+ assert(ss.good());
+ assert(ss.str() == L"");
+ }
+ {
+ std::wstringstream ss(std::ios_base::in);
+ assert(ss.rdbuf() != 0);
+ assert(ss.good());
+ assert(ss.str() == L"");
+ }
+}
diff --git a/test/std/input.output/string.streams/stringstream.cons/move.pass.cpp b/test/std/input.output/string.streams/stringstream.cons/move.pass.cpp
new file mode 100644
index 000000000000..4ae3aa6e84db
--- /dev/null
+++ b/test/std/input.output/string.streams/stringstream.cons/move.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringstream
+
+// basic_stringstream(basic_stringstream&& rhs);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::stringstream ss0(" 123 456 ");
+ std::stringstream ss(std::move(ss0));
+ assert(ss.rdbuf() != 0);
+ assert(ss.good());
+ assert(ss.str() == " 123 456 ");
+ int i = 0;
+ ss >> i;
+ assert(i == 123);
+ ss >> i;
+ assert(i == 456);
+ ss << i << ' ' << 123;
+ assert(ss.str() == "456 1236 ");
+ }
+ {
+ std::wstringstream ss0(L" 123 456 ");
+ std::wstringstream ss(std::move(ss0));
+ assert(ss.rdbuf() != 0);
+ assert(ss.good());
+ assert(ss.str() == L" 123 456 ");
+ int i = 0;
+ ss >> i;
+ assert(i == 123);
+ ss >> i;
+ assert(i == 456);
+ ss << i << ' ' << 123;
+ assert(ss.str() == L"456 1236 ");
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/input.output/string.streams/stringstream.cons/move2.pass.cpp b/test/std/input.output/string.streams/stringstream.cons/move2.pass.cpp
new file mode 100644
index 000000000000..856cf3cbeafd
--- /dev/null
+++ b/test/std/input.output/string.streams/stringstream.cons/move2.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringstream
+
+// basic_stringstream(basic_stringstream&& rhs);
+
+#include <sstream>
+#include <vector>
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ std::vector<std::istringstream> vecis;
+ vecis.push_back(std::istringstream());
+ vecis.back().str("hub started at [00 6b 8b 45 69]");
+ vecis.push_back(std::istringstream());
+ vecis.back().str("hub started at [00 6b 8b 45 69]");
+ for (int n = 0; n < vecis.size(); n++)
+ {
+ assert(vecis[n].str().size() == 31);
+ vecis[n].seekg(0, std::ios_base::beg);
+ assert(vecis[n].str().size() == 31);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/input.output/string.streams/stringstream.cons/string.pass.cpp b/test/std/input.output/string.streams/stringstream.cons/string.pass.cpp
new file mode 100644
index 000000000000..3776f17f5304
--- /dev/null
+++ b/test/std/input.output/string.streams/stringstream.cons/string.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringstream
+
+// explicit basic_stringstream(const basic_string<charT,traits,Allocator>& str,
+// ios_base::openmode which = ios_base::out|ios_base::in);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::stringstream ss(" 123 456 ");
+ assert(ss.rdbuf() != 0);
+ assert(ss.good());
+ assert(ss.str() == " 123 456 ");
+ int i = 0;
+ ss >> i;
+ assert(i == 123);
+ ss >> i;
+ assert(i == 456);
+ ss << i << ' ' << 123;
+ assert(ss.str() == "456 1236 ");
+ }
+ {
+ std::wstringstream ss(L" 123 456 ");
+ assert(ss.rdbuf() != 0);
+ assert(ss.good());
+ assert(ss.str() == L" 123 456 ");
+ int i = 0;
+ ss >> i;
+ assert(i == 123);
+ ss >> i;
+ assert(i == 456);
+ ss << i << ' ' << 123;
+ assert(ss.str() == L"456 1236 ");
+ }
+}
diff --git a/test/std/input.output/string.streams/stringstream.cons/stringstream.assign/member_swap.pass.cpp b/test/std/input.output/string.streams/stringstream.cons/stringstream.assign/member_swap.pass.cpp
new file mode 100644
index 000000000000..95599dd254e9
--- /dev/null
+++ b/test/std/input.output/string.streams/stringstream.cons/stringstream.assign/member_swap.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringstream
+
+// void swap(basic_stringstream& rhs);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::stringstream ss0(" 123 456 ");
+ std::stringstream ss;
+ ss.swap(ss0);
+ assert(ss.rdbuf() != 0);
+ assert(ss.good());
+ assert(ss.str() == " 123 456 ");
+ int i = 0;
+ ss >> i;
+ assert(i == 123);
+ ss >> i;
+ assert(i == 456);
+ ss << i << ' ' << 123;
+ assert(ss.str() == "456 1236 ");
+ ss0 << i << ' ' << 123;
+ assert(ss0.str() == "456 123");
+ }
+ {
+ std::wstringstream ss0(L" 123 456 ");
+ std::wstringstream ss;
+ ss.swap(ss0);
+ assert(ss.rdbuf() != 0);
+ assert(ss.good());
+ assert(ss.str() == L" 123 456 ");
+ int i = 0;
+ ss >> i;
+ assert(i == 123);
+ ss >> i;
+ assert(i == 456);
+ ss << i << ' ' << 123;
+ assert(ss.str() == L"456 1236 ");
+ ss0 << i << ' ' << 123;
+ assert(ss0.str() == L"456 123");
+ }
+}
diff --git a/test/std/input.output/string.streams/stringstream.cons/stringstream.assign/move.pass.cpp b/test/std/input.output/string.streams/stringstream.cons/stringstream.assign/move.pass.cpp
new file mode 100644
index 000000000000..ccaf72d7e550
--- /dev/null
+++ b/test/std/input.output/string.streams/stringstream.cons/stringstream.assign/move.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringstream
+
+// basic_stringstream& operator=(basic_stringstream&& rhs);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::stringstream ss0(" 123 456 ");
+ std::stringstream ss;
+ ss = std::move(ss0);
+ assert(ss.rdbuf() != 0);
+ assert(ss.good());
+ assert(ss.str() == " 123 456 ");
+ int i = 0;
+ ss >> i;
+ assert(i == 123);
+ ss >> i;
+ assert(i == 456);
+ ss << i << ' ' << 123;
+ assert(ss.str() == "456 1236 ");
+ }
+ {
+ std::wstringstream ss0(L" 123 456 ");
+ std::wstringstream ss;
+ ss = std::move(ss0);
+ assert(ss.rdbuf() != 0);
+ assert(ss.good());
+ assert(ss.str() == L" 123 456 ");
+ int i = 0;
+ ss >> i;
+ assert(i == 123);
+ ss >> i;
+ assert(i == 456);
+ ss << i << ' ' << 123;
+ assert(ss.str() == L"456 1236 ");
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/input.output/string.streams/stringstream.cons/stringstream.assign/nonmember_swap.pass.cpp b/test/std/input.output/string.streams/stringstream.cons/stringstream.assign/nonmember_swap.pass.cpp
new file mode 100644
index 000000000000..3ec11cd9e307
--- /dev/null
+++ b/test/std/input.output/string.streams/stringstream.cons/stringstream.assign/nonmember_swap.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringstream
+
+// template <class charT, class traits, class Allocator>
+// void
+// swap(basic_stringstream<charT, traits, Allocator>& x,
+// basic_stringstream<charT, traits, Allocator>& y);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::stringstream ss0(" 123 456 ");
+ std::stringstream ss;
+ swap(ss, ss0);
+ assert(ss.rdbuf() != 0);
+ assert(ss.good());
+ assert(ss.str() == " 123 456 ");
+ int i = 0;
+ ss >> i;
+ assert(i == 123);
+ ss >> i;
+ assert(i == 456);
+ ss << i << ' ' << 123;
+ assert(ss.str() == "456 1236 ");
+ ss0 << i << ' ' << 123;
+ assert(ss0.str() == "456 123");
+ }
+ {
+ std::wstringstream ss0(L" 123 456 ");
+ std::wstringstream ss;
+ swap(ss, ss0);
+ assert(ss.rdbuf() != 0);
+ assert(ss.good());
+ assert(ss.str() == L" 123 456 ");
+ int i = 0;
+ ss >> i;
+ assert(i == 123);
+ ss >> i;
+ assert(i == 456);
+ ss << i << ' ' << 123;
+ assert(ss.str() == L"456 1236 ");
+ ss0 << i << ' ' << 123;
+ assert(ss0.str() == L"456 123");
+ }
+}
diff --git a/test/std/input.output/string.streams/stringstream.members/str.pass.cpp b/test/std/input.output/string.streams/stringstream.members/str.pass.cpp
new file mode 100644
index 000000000000..155a262e19f9
--- /dev/null
+++ b/test/std/input.output/string.streams/stringstream.members/str.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringstream
+
+// void str(const basic_string<charT,traits,Allocator>& str);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::stringstream ss(" 123 456 ");
+ assert(ss.rdbuf() != 0);
+ assert(ss.good());
+ assert(ss.str() == " 123 456 ");
+ int i = 0;
+ ss >> i;
+ assert(i == 123);
+ ss >> i;
+ assert(i == 456);
+ ss << i << ' ' << 123;
+ assert(ss.str() == "456 1236 ");
+ ss.str("5466 89 ");
+ ss >> i;
+ assert(i == 5466);
+ ss >> i;
+ assert(i == 89);
+ ss << i << ' ' << 321;
+ assert(ss.str() == "89 3219 ");
+ }
+ {
+ std::wstringstream ss(L" 123 456 ");
+ assert(ss.rdbuf() != 0);
+ assert(ss.good());
+ assert(ss.str() == L" 123 456 ");
+ int i = 0;
+ ss >> i;
+ assert(i == 123);
+ ss >> i;
+ assert(i == 456);
+ ss << i << ' ' << 123;
+ assert(ss.str() == L"456 1236 ");
+ ss.str(L"5466 89 ");
+ ss >> i;
+ assert(i == 5466);
+ ss >> i;
+ assert(i == 89);
+ ss << i << ' ' << 321;
+ assert(ss.str() == L"89 3219 ");
+ }
+}
diff --git a/test/std/input.output/string.streams/stringstream/types.pass.cpp b/test/std/input.output/string.streams/stringstream/types.pass.cpp
new file mode 100644
index 000000000000..a89daa144e9a
--- /dev/null
+++ b/test/std/input.output/string.streams/stringstream/types.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringstream
+// : public basic_iostream<charT, traits>
+// {
+// public:
+// typedef charT char_type;
+// typedef traits traits_type;
+// typedef typename traits_type::int_type int_type;
+// typedef typename traits_type::pos_type pos_type;
+// typedef typename traits_type::off_type off_type;
+// typedef Allocator allocator_type;
+
+#include <sstream>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_base_of<std::basic_iostream<char>, std::basic_stringstream<char> >::value), "");
+ static_assert((std::is_same<std::basic_stringstream<char>::char_type, char>::value), "");
+ static_assert((std::is_same<std::basic_stringstream<char>::traits_type, std::char_traits<char> >::value), "");
+ static_assert((std::is_same<std::basic_stringstream<char>::int_type, std::char_traits<char>::int_type>::value), "");
+ static_assert((std::is_same<std::basic_stringstream<char>::pos_type, std::char_traits<char>::pos_type>::value), "");
+ static_assert((std::is_same<std::basic_stringstream<char>::off_type, std::char_traits<char>::off_type>::value), "");
+ static_assert((std::is_same<std::basic_stringstream<char>::allocator_type, std::allocator<char> >::value), "");
+}
diff --git a/test/std/input.output/string.streams/version.pass.cpp b/test/std/input.output/string.streams/version.pass.cpp
new file mode 100644
index 000000000000..103897106d37
--- /dev/null
+++ b/test/std/input.output/string.streams/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+#include <sstream>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/iterators/iterator.container/data.pass.cpp b/test/std/iterators/iterator.container/data.pass.cpp
new file mode 100644
index 000000000000..3d1fa33358db
--- /dev/null
+++ b/test/std/iterators/iterator.container/data.pass.cpp
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+// template <class C> constexpr auto data(C& c) -> decltype(c.data()); // C++17
+// template <class C> constexpr auto data(const C& c) -> decltype(c.data()); // C++17
+// template <class T, size_t N> constexpr T* data(T (&array)[N]) noexcept; // C++17
+// template <class E> constexpr const E* data(initializer_list<E> il) noexcept; // C++17
+
+#if __cplusplus <= 201402L
+int main () {}
+#else
+
+#include <iterator>
+#include <cassert>
+#include <vector>
+#include <array>
+#include <initializer_list>
+
+template<typename C>
+void test_const_container( const C& c )
+{
+ assert ( std::data(c) == c.data());
+}
+
+template<typename T>
+void test_const_container( const std::initializer_list<T>& c )
+{
+ assert ( std::data(c) == c.begin());
+}
+
+template<typename C>
+void test_container( C& c )
+{
+ assert ( std::data(c) == c.data());
+}
+
+template<typename T>
+void test_container( std::initializer_list<T>& c)
+{
+ assert ( std::data(c) == c.begin());
+}
+
+template<typename T, size_t Sz>
+void test_const_array( const T (&array)[Sz] )
+{
+ assert ( std::data(array) == &array[0]);
+}
+
+int main()
+{
+ std::vector<int> v; v.push_back(1);
+ std::array<int, 1> a; a[0] = 3;
+ std::initializer_list<int> il = { 4 };
+
+ test_container ( v );
+ test_container ( a );
+ test_container ( il );
+
+ test_const_container ( v );
+ test_const_container ( a );
+ test_const_container ( il );
+
+ static constexpr int arrA [] { 1, 2, 3 };
+ test_const_array ( arrA );
+}
+
+#endif
diff --git a/test/std/iterators/iterator.container/empty.pass.cpp b/test/std/iterators/iterator.container/empty.pass.cpp
new file mode 100644
index 000000000000..f26cb98e1aed
--- /dev/null
+++ b/test/std/iterators/iterator.container/empty.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+// template <class C> constexpr auto empty(const C& c) -> decltype(c.empty()); // C++17
+// template <class T, size_t N> constexpr bool empty(const T (&array)[N]) noexcept; // C++17
+// template <class E> constexpr bool empty(initializer_list<E> il) noexcept; // C++17
+
+#if __cplusplus <= 201402L
+int main () {}
+#else
+
+#include <iterator>
+#include <cassert>
+#include <vector>
+#include <array>
+#include <list>
+#include <initializer_list>
+
+template<typename C>
+void test_const_container( const C& c )
+{
+ assert ( std::empty(c) == c.empty());
+}
+
+template<typename T>
+void test_const_container( const std::initializer_list<T>& c )
+{
+ assert ( std::empty(c) == (c.size() == 0));
+}
+
+template<typename C>
+void test_container( C& c )
+{
+ assert ( std::empty(c) == c.empty());
+}
+
+template<typename T>
+void test_container( std::initializer_list<T>& c )
+{
+ assert ( std::empty(c) == (c.size() == 0));
+}
+
+template<typename T, size_t Sz>
+void test_const_array( const T (&array)[Sz] )
+{
+ assert (!std::empty(array));
+}
+
+int main()
+{
+ std::vector<int> v; v.push_back(1);
+ std::list<int> l; l.push_back(2);
+ std::array<int, 1> a; a[0] = 3;
+ std::initializer_list<int> il = { 4 };
+
+ test_container ( v );
+ test_container ( l );
+ test_container ( a );
+ test_container ( il );
+
+ test_const_container ( v );
+ test_const_container ( l );
+ test_const_container ( a );
+ test_const_container ( il );
+
+ static constexpr int arrA [] { 1, 2, 3 };
+ test_const_array ( arrA );
+}
+
+#endif
diff --git a/test/std/iterators/iterator.container/size.pass.cpp b/test/std/iterators/iterator.container/size.pass.cpp
new file mode 100644
index 000000000000..705fb40e1926
--- /dev/null
+++ b/test/std/iterators/iterator.container/size.pass.cpp
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+// template <class C> constexpr auto size(const C& c) -> decltype(c.size()); // C++17
+// template <class T, size_t N> constexpr size_t size(const T (&array)[N]) noexcept; // C++17
+
+#if __cplusplus <= 201402L
+int main () {}
+#else
+
+#include <iterator>
+#include <cassert>
+#include <vector>
+#include <array>
+#include <list>
+#include <initializer_list>
+
+template<typename C>
+void test_const_container( const C& c )
+{
+ assert ( std::size(c) == c.size());
+}
+
+template<typename T>
+void test_const_container( const std::initializer_list<T>& c)
+{
+ assert ( std::size(c) == c.size());
+}
+
+template<typename C>
+void test_container( C& c)
+{
+ assert ( std::size(c) == c.size());
+}
+
+template<typename T>
+void test_container( std::initializer_list<T>& c )
+{
+ assert ( std::size(c) == c.size());
+}
+
+template<typename T, size_t Sz>
+void test_const_array( const T (&array)[Sz] )
+{
+ assert ( std::size(array) == Sz );
+}
+
+int main()
+{
+ std::vector<int> v; v.push_back(1);
+ std::list<int> l; l.push_back(2);
+ std::array<int, 1> a; a[0] = 3;
+ std::initializer_list<int> il = { 4 };
+
+ test_container ( v );
+ test_container ( l );
+ test_container ( a );
+ test_container ( il );
+
+ test_const_container ( v );
+ test_const_container ( l );
+ test_const_container ( a );
+ test_const_container ( il );
+
+ static constexpr int arrA [] { 1, 2, 3 };
+ test_const_array ( arrA );
+}
+
+#endif
diff --git a/test/std/iterators/iterator.primitives/iterator.basic/iterator.pass.cpp b/test/std/iterators/iterator.primitives/iterator.basic/iterator.pass.cpp
new file mode 100644
index 000000000000..26d5c8660282
--- /dev/null
+++ b/test/std/iterators/iterator.primitives/iterator.basic/iterator.pass.cpp
@@ -0,0 +1,82 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template<class Category, class T, class Distance = ptrdiff_t,
+// class Pointer = T*, class Reference = T&>
+// struct iterator
+// {
+// typedef T value_type;
+// typedef Distance difference_type;
+// typedef Pointer pointer;
+// typedef Reference reference;
+// typedef Category iterator_category;
+// };
+
+#include <iterator>
+#include <type_traits>
+
+struct A {};
+
+template <class T>
+void
+test2()
+{
+ typedef std::iterator<std::forward_iterator_tag, T> It;
+ static_assert((std::is_same<typename It::value_type, T>::value), "");
+ static_assert((std::is_same<typename It::difference_type, std::ptrdiff_t>::value), "");
+ static_assert((std::is_same<typename It::pointer, T*>::value), "");
+ static_assert((std::is_same<typename It::reference, T&>::value), "");
+ static_assert((std::is_same<typename It::iterator_category, std::forward_iterator_tag>::value), "");
+}
+
+template <class T>
+void
+test3()
+{
+ typedef std::iterator<std::bidirectional_iterator_tag, T, short> It;
+ static_assert((std::is_same<typename It::value_type, T>::value), "");
+ static_assert((std::is_same<typename It::difference_type, short>::value), "");
+ static_assert((std::is_same<typename It::pointer, T*>::value), "");
+ static_assert((std::is_same<typename It::reference, T&>::value), "");
+ static_assert((std::is_same<typename It::iterator_category, std::bidirectional_iterator_tag>::value), "");
+}
+
+template <class T>
+void
+test4()
+{
+ typedef std::iterator<std::random_access_iterator_tag, T, int, const T*> It;
+ static_assert((std::is_same<typename It::value_type, T>::value), "");
+ static_assert((std::is_same<typename It::difference_type, int>::value), "");
+ static_assert((std::is_same<typename It::pointer, const T*>::value), "");
+ static_assert((std::is_same<typename It::reference, T&>::value), "");
+ static_assert((std::is_same<typename It::iterator_category, std::random_access_iterator_tag>::value), "");
+}
+
+template <class T>
+void
+test5()
+{
+ typedef std::iterator<std::input_iterator_tag, T, long, const T*, const T&> It;
+ static_assert((std::is_same<typename It::value_type, T>::value), "");
+ static_assert((std::is_same<typename It::difference_type, long>::value), "");
+ static_assert((std::is_same<typename It::pointer, const T*>::value), "");
+ static_assert((std::is_same<typename It::reference, const T&>::value), "");
+ static_assert((std::is_same<typename It::iterator_category, std::input_iterator_tag>::value), "");
+}
+
+int main()
+{
+ test2<A>();
+ test3<A>();
+ test4<A>();
+ test5<A>();
+}
diff --git a/test/std/iterators/iterator.primitives/iterator.operations/advance.pass.cpp b/test/std/iterators/iterator.primitives/iterator.operations/advance.pass.cpp
new file mode 100644
index 000000000000..e395da299dc7
--- /dev/null
+++ b/test/std/iterators/iterator.primitives/iterator.operations/advance.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template <InputIterator Iter>
+// void advance(Iter& i, Iter::difference_type n);
+//
+// template <BidirectionalIterator Iter>
+// void advance(Iter& i, Iter::difference_type n);
+//
+// template <RandomAccessIterator Iter>
+// void advance(Iter& i, Iter::difference_type n);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It i, typename std::iterator_traits<It>::difference_type n, It x)
+{
+ std::advance(i, n);
+ assert(i == x);
+}
+
+int main()
+{
+ const char* s = "1234567890";
+ test(input_iterator<const char*>(s), 10, input_iterator<const char*>(s+10));
+ test(forward_iterator<const char*>(s), 10, forward_iterator<const char*>(s+10));
+ test(bidirectional_iterator<const char*>(s+5), 5, bidirectional_iterator<const char*>(s+10));
+ test(bidirectional_iterator<const char*>(s+5), -5, bidirectional_iterator<const char*>(s));
+ test(random_access_iterator<const char*>(s+5), 5, random_access_iterator<const char*>(s+10));
+ test(random_access_iterator<const char*>(s+5), -5, random_access_iterator<const char*>(s));
+ test(s+5, 5, s+10);
+ test(s+5, -5, s);
+}
diff --git a/test/std/iterators/iterator.primitives/iterator.operations/distance.pass.cpp b/test/std/iterators/iterator.primitives/iterator.operations/distance.pass.cpp
new file mode 100644
index 000000000000..7fef635838c3
--- /dev/null
+++ b/test/std/iterators/iterator.primitives/iterator.operations/distance.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template <InputIterator Iter>
+// Iter::difference_type
+// distance(Iter first, Iter last);
+//
+// template <RandomAccessIterator Iter>
+// Iter::difference_type
+// distance(Iter first, Iter last);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It first, It last, typename std::iterator_traits<It>::difference_type x)
+{
+ assert(std::distance(first, last) == x);
+}
+
+int main()
+{
+ const char* s = "1234567890";
+ test(input_iterator<const char*>(s), input_iterator<const char*>(s+10), 10);
+ test(forward_iterator<const char*>(s), forward_iterator<const char*>(s+10), 10);
+ test(bidirectional_iterator<const char*>(s), bidirectional_iterator<const char*>(s+10), 10);
+ test(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s+10), 10);
+ test(s, s+10, 10);
+}
diff --git a/test/std/iterators/iterator.primitives/iterator.operations/next.pass.cpp b/test/std/iterators/iterator.primitives/iterator.operations/next.pass.cpp
new file mode 100644
index 000000000000..f584110499b8
--- /dev/null
+++ b/test/std/iterators/iterator.primitives/iterator.operations/next.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template <InputIterator Iter>
+// Iter next(Iter x, Iter::difference_type n = 1);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It i, typename std::iterator_traits<It>::difference_type n, It x)
+{
+ assert(std::next(i, n) == x);
+}
+
+template <class It>
+void
+test(It i, It x)
+{
+ assert(std::next(i) == x);
+}
+
+int main()
+{
+ const char* s = "1234567890";
+ test(forward_iterator<const char*>(s), 10, forward_iterator<const char*>(s+10));
+ test(bidirectional_iterator<const char*>(s), 10, bidirectional_iterator<const char*>(s+10));
+ test(random_access_iterator<const char*>(s), 10, random_access_iterator<const char*>(s+10));
+ test(s, 10, s+10);
+
+ test(forward_iterator<const char*>(s), forward_iterator<const char*>(s+1));
+ test(bidirectional_iterator<const char*>(s), bidirectional_iterator<const char*>(s+1));
+ test(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s+1));
+ test(s, s+1);
+}
diff --git a/test/std/iterators/iterator.primitives/iterator.operations/prev.pass.cpp b/test/std/iterators/iterator.primitives/iterator.operations/prev.pass.cpp
new file mode 100644
index 000000000000..0641706c928b
--- /dev/null
+++ b/test/std/iterators/iterator.primitives/iterator.operations/prev.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template <BidirectionalIterator Iter>
+// Iter prev(Iter x, Iter::difference_type n = 1);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It i, typename std::iterator_traits<It>::difference_type n, It x)
+{
+ assert(std::prev(i, n) == x);
+}
+
+template <class It>
+void
+test(It i, It x)
+{
+ assert(std::prev(i) == x);
+}
+
+int main()
+{
+ const char* s = "1234567890";
+ test(bidirectional_iterator<const char*>(s+10), 10, bidirectional_iterator<const char*>(s));
+ test(random_access_iterator<const char*>(s+10), 10, random_access_iterator<const char*>(s));
+ test(s+10, 10, s);
+
+ test(bidirectional_iterator<const char*>(s+1), bidirectional_iterator<const char*>(s));
+ test(random_access_iterator<const char*>(s+1), random_access_iterator<const char*>(s));
+ test(s+1, s);
+}
diff --git a/test/std/iterators/iterator.primitives/iterator.traits/const_pointer.pass.cpp b/test/std/iterators/iterator.primitives/iterator.traits/const_pointer.pass.cpp
new file mode 100644
index 000000000000..f40754fd9daf
--- /dev/null
+++ b/test/std/iterators/iterator.primitives/iterator.traits/const_pointer.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template<class T>
+// struct iterator_traits<const T*>
+// {
+// typedef ptrdiff_t difference_type;
+// typedef T value_type;
+// typedef const T* pointer;
+// typedef const T& reference;
+// typedef random_access_iterator_tag iterator_category;
+// };
+
+#include <iterator>
+#include <type_traits>
+
+struct A {};
+
+int main()
+{
+ typedef std::iterator_traits<const A*> It;
+ static_assert((std::is_same<It::difference_type, std::ptrdiff_t>::value), "");
+ static_assert((std::is_same<It::value_type, A>::value), "");
+ static_assert((std::is_same<It::pointer, const A*>::value), "");
+ static_assert((std::is_same<It::reference, const A&>::value), "");
+ static_assert((std::is_same<It::iterator_category, std::random_access_iterator_tag>::value), "");
+}
diff --git a/test/std/iterators/iterator.primitives/iterator.traits/empty.pass.cpp b/test/std/iterators/iterator.primitives/iterator.traits/empty.pass.cpp
new file mode 100644
index 000000000000..e48e44b3777f
--- /dev/null
+++ b/test/std/iterators/iterator.primitives/iterator.traits/empty.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template<class NotAnIterator>
+// struct iterator_traits
+// {
+// };
+
+#include <iterator>
+
+struct not_an_iterator
+{
+};
+
+template <class _Tp>
+struct has_value_type
+{
+private:
+ struct two {char lx; char lxx;};
+ template <class _Up> static two test(...);
+ template <class _Up> static char test(typename _Up::value_type* = 0);
+public:
+ static const bool value = sizeof(test<_Tp>(0)) == 1;
+};
+
+int main()
+{
+ typedef std::iterator_traits<not_an_iterator> It;
+ static_assert(!(has_value_type<It>::value), "");
+}
diff --git a/test/std/iterators/iterator.primitives/iterator.traits/iterator.pass.cpp b/test/std/iterators/iterator.primitives/iterator.traits/iterator.pass.cpp
new file mode 100644
index 000000000000..38f7c0b6b833
--- /dev/null
+++ b/test/std/iterators/iterator.primitives/iterator.traits/iterator.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template<class Iter>
+// struct iterator_traits
+// {
+// typedef typename Iter::difference_type difference_type;
+// typedef typename Iter::value_type value_type;
+// typedef typename Iter::pointer pointer;
+// typedef typename Iter::reference reference;
+// typedef typename Iter::iterator_category iterator_category;
+// };
+
+#include <iterator>
+#include <type_traits>
+
+struct A {};
+
+struct test_iterator
+{
+ typedef int difference_type;
+ typedef A value_type;
+ typedef A* pointer;
+ typedef A& reference;
+ typedef std::forward_iterator_tag iterator_category;
+};
+
+int main()
+{
+ typedef std::iterator_traits<test_iterator> It;
+ static_assert((std::is_same<It::difference_type, int>::value), "");
+ static_assert((std::is_same<It::value_type, A>::value), "");
+ static_assert((std::is_same<It::pointer, A*>::value), "");
+ static_assert((std::is_same<It::iterator_category, std::forward_iterator_tag>::value), "");
+}
diff --git a/test/std/iterators/iterator.primitives/iterator.traits/pointer.pass.cpp b/test/std/iterators/iterator.primitives/iterator.traits/pointer.pass.cpp
new file mode 100644
index 000000000000..5a8fe60774ee
--- /dev/null
+++ b/test/std/iterators/iterator.primitives/iterator.traits/pointer.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template<class T>
+// struct iterator_traits<T*>
+// {
+// typedef ptrdiff_t difference_type;
+// typedef T value_type;
+// typedef T* pointer;
+// typedef T& reference;
+// typedef random_access_iterator_tag iterator_category;
+// };
+
+#include <iterator>
+#include <type_traits>
+
+struct A {};
+
+int main()
+{
+ typedef std::iterator_traits<A*> It;
+ static_assert((std::is_same<It::difference_type, std::ptrdiff_t>::value), "");
+ static_assert((std::is_same<It::value_type, A>::value), "");
+ static_assert((std::is_same<It::pointer, A*>::value), "");
+ static_assert((std::is_same<It::reference, A&>::value), "");
+ static_assert((std::is_same<It::iterator_category, std::random_access_iterator_tag>::value), "");
+}
diff --git a/test/std/iterators/iterator.primitives/nothing_to_do.pass.cpp b/test/std/iterators/iterator.primitives/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/iterators/iterator.primitives/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/iterators/iterator.primitives/std.iterator.tags/bidirectional_iterator_tag.pass.cpp b/test/std/iterators/iterator.primitives/std.iterator.tags/bidirectional_iterator_tag.pass.cpp
new file mode 100644
index 000000000000..0f368c3b765f
--- /dev/null
+++ b/test/std/iterators/iterator.primitives/std.iterator.tags/bidirectional_iterator_tag.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// struct bidirectional_iterator_tag : public forward_iterator_tag {};
+
+#include <iterator>
+#include <type_traits>
+
+int main()
+{
+ std::bidirectional_iterator_tag tag;
+ static_assert((std::is_base_of<std::forward_iterator_tag,
+ std::bidirectional_iterator_tag>::value), "");
+ static_assert((!std::is_base_of<std::output_iterator_tag,
+ std::bidirectional_iterator_tag>::value), "");
+}
diff --git a/test/std/iterators/iterator.primitives/std.iterator.tags/forward_iterator_tag.pass.cpp b/test/std/iterators/iterator.primitives/std.iterator.tags/forward_iterator_tag.pass.cpp
new file mode 100644
index 000000000000..0936595c85d6
--- /dev/null
+++ b/test/std/iterators/iterator.primitives/std.iterator.tags/forward_iterator_tag.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// struct forward_iterator_tag: public input_iterator_tag {};
+
+#include <iterator>
+#include <type_traits>
+
+int main()
+{
+ std::forward_iterator_tag tag;
+ static_assert((std::is_base_of<std::input_iterator_tag,
+ std::forward_iterator_tag>::value), "");
+ static_assert((!std::is_base_of<std::output_iterator_tag,
+ std::forward_iterator_tag>::value), "");
+}
diff --git a/test/std/iterators/iterator.primitives/std.iterator.tags/input_iterator_tag.pass.cpp b/test/std/iterators/iterator.primitives/std.iterator.tags/input_iterator_tag.pass.cpp
new file mode 100644
index 000000000000..afeac3e91cae
--- /dev/null
+++ b/test/std/iterators/iterator.primitives/std.iterator.tags/input_iterator_tag.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// struct input_iterator_tag {};
+
+#include <iterator>
+#include <type_traits>
+
+int main()
+{
+ std::input_iterator_tag tag;
+ static_assert((!std::is_base_of<std::output_iterator_tag,
+ std::input_iterator_tag>::value), "");
+}
diff --git a/test/std/iterators/iterator.primitives/std.iterator.tags/output_iterator_tag.pass.cpp b/test/std/iterators/iterator.primitives/std.iterator.tags/output_iterator_tag.pass.cpp
new file mode 100644
index 000000000000..7f7f66a98f4a
--- /dev/null
+++ b/test/std/iterators/iterator.primitives/std.iterator.tags/output_iterator_tag.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// struct output_iterator_tag {};
+
+#include <iterator>
+#include <type_traits>
+
+int main()
+{
+ std::output_iterator_tag tag;
+ static_assert((!std::is_base_of<std::input_iterator_tag,
+ std::output_iterator_tag>::value), "");
+}
diff --git a/test/std/iterators/iterator.primitives/std.iterator.tags/random_access_iterator_tag.pass.cpp b/test/std/iterators/iterator.primitives/std.iterator.tags/random_access_iterator_tag.pass.cpp
new file mode 100644
index 000000000000..04f830bc3109
--- /dev/null
+++ b/test/std/iterators/iterator.primitives/std.iterator.tags/random_access_iterator_tag.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// struct random_access_iterator_tag : public bidirectional_iterator_tag {};
+
+#include <iterator>
+#include <type_traits>
+
+int main()
+{
+ std::random_access_iterator_tag tag;
+ static_assert((std::is_base_of<std::bidirectional_iterator_tag,
+ std::random_access_iterator_tag>::value), "");
+ static_assert((!std::is_base_of<std::output_iterator_tag,
+ std::random_access_iterator_tag>::value), "");
+}
diff --git a/test/std/iterators/iterator.range/begin-end.pass.cpp b/test/std/iterators/iterator.range/begin-end.pass.cpp
new file mode 100644
index 000000000000..bd7e0aa90fbc
--- /dev/null
+++ b/test/std/iterators/iterator.range/begin-end.pass.cpp
@@ -0,0 +1,146 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+// template <class C> auto begin(C& c) -> decltype(c.begin());
+// template <class C> auto begin(const C& c) -> decltype(c.begin());
+// template <class C> auto end(C& c) -> decltype(c.end());
+// template <class C> auto end(const C& c) -> decltype(c.end());
+// template <class E> reverse_iterator<const E*> rbegin(initializer_list<E> il);
+// template <class E> reverse_iterator<const E*> rend(initializer_list<E> il);
+
+#if __cplusplus >= 201103L
+#include <iterator>
+#include <cassert>
+#include <vector>
+#include <array>
+#include <list>
+#include <initializer_list>
+
+template<typename C>
+void test_const_container( const C & c, typename C::value_type val ) {
+ assert ( std::begin(c) == c.begin());
+ assert (*std::begin(c) == val );
+ assert ( std::begin(c) != c.end());
+ assert ( std::end(c) == c.end());
+#if _LIBCPP_STD_VER > 11
+ assert ( std::cbegin(c) == c.cbegin());
+ assert ( std::cbegin(c) != c.cend());
+ assert ( std::cend(c) == c.cend());
+ assert ( std::rbegin(c) == c.rbegin());
+ assert ( std::rbegin(c) != c.rend());
+ assert ( std::rend(c) == c.rend());
+ assert ( std::crbegin(c) == c.crbegin());
+ assert ( std::crbegin(c) != c.crend());
+ assert ( std::crend(c) == c.crend());
+#endif
+ }
+
+template<typename T>
+void test_const_container( const std::initializer_list<T> & c, T val ) {
+ assert ( std::begin(c) == c.begin());
+ assert (*std::begin(c) == val );
+ assert ( std::begin(c) != c.end());
+ assert ( std::end(c) == c.end());
+#if _LIBCPP_STD_VER > 11
+// initializer_list doesn't have cbegin/cend/rbegin/rend
+// but std::cbegin(),etc work (b/c they're general fn templates)
+// assert ( std::cbegin(c) == c.cbegin());
+// assert ( std::cbegin(c) != c.cend());
+// assert ( std::cend(c) == c.cend());
+// assert ( std::rbegin(c) == c.rbegin());
+// assert ( std::rbegin(c) != c.rend());
+// assert ( std::rend(c) == c.rend());
+// assert ( std::crbegin(c) == c.crbegin());
+// assert ( std::crbegin(c) != c.crend());
+// assert ( std::crend(c) == c.crend());
+#endif
+ }
+
+template<typename C>
+void test_container( C & c, typename C::value_type val ) {
+ assert ( std::begin(c) == c.begin());
+ assert (*std::begin(c) == val );
+ assert ( std::begin(c) != c.end());
+ assert ( std::end(c) == c.end());
+#if _LIBCPP_STD_VER > 11
+ assert ( std::cbegin(c) == c.cbegin());
+ assert ( std::cbegin(c) != c.cend());
+ assert ( std::cend(c) == c.cend());
+ assert ( std::rbegin(c) == c.rbegin());
+ assert ( std::rbegin(c) != c.rend());
+ assert ( std::rend(c) == c.rend());
+ assert ( std::crbegin(c) == c.crbegin());
+ assert ( std::crbegin(c) != c.crend());
+ assert ( std::crend(c) == c.crend());
+#endif
+ }
+
+template<typename T>
+void test_container( std::initializer_list<T> & c, T val ) {
+ assert ( std::begin(c) == c.begin());
+ assert (*std::begin(c) == val );
+ assert ( std::begin(c) != c.end());
+ assert ( std::end(c) == c.end());
+#if _LIBCPP_STD_VER > 11
+// initializer_list doesn't have cbegin/cend/rbegin/rend
+// assert ( std::cbegin(c) == c.cbegin());
+// assert ( std::cbegin(c) != c.cend());
+// assert ( std::cend(c) == c.cend());
+// assert ( std::rbegin(c) == c.rbegin());
+// assert ( std::rbegin(c) != c.rend());
+// assert ( std::rend(c) == c.rend());
+// assert ( std::crbegin(c) == c.crbegin());
+// assert ( std::crbegin(c) != c.crend());
+// assert ( std::crend(c) == c.crend());
+#endif
+ }
+
+template<typename T, size_t Sz>
+void test_const_array( const T (&array)[Sz] ) {
+ assert ( std::begin(array) == array );
+ assert (*std::begin(array) == array[0] );
+ assert ( std::begin(array) != std::end(array));
+ assert ( std::end(array) == array + Sz);
+#if _LIBCPP_STD_VER > 11
+ assert ( std::cbegin(array) == array );
+ assert (*std::cbegin(array) == array[0] );
+ assert ( std::cbegin(array) != std::cend(array));
+ assert ( std::cend(array) == array + Sz);
+#endif
+ }
+
+int main(){
+ std::vector<int> v; v.push_back(1);
+ std::list<int> l; l.push_back(2);
+ std::array<int, 1> a; a[0] = 3;
+ std::initializer_list<int> il = { 4 };
+
+ test_container ( v, 1 );
+ test_container ( l, 2 );
+ test_container ( a, 3 );
+ test_container ( il, 4 );
+
+ test_const_container ( v, 1 );
+ test_const_container ( l, 2 );
+ test_const_container ( a, 3 );
+ test_const_container ( il, 4 );
+
+ static constexpr int arrA [] { 1, 2, 3 };
+ test_const_array ( arrA );
+#if _LIBCPP_STD_VER > 11
+ constexpr const int *b = std::cbegin(arrA);
+ constexpr const int *e = std::cend(arrA);
+ static_assert(e - b == 3, "");
+#endif
+}
+
+#else
+int main(){}
+#endif
diff --git a/test/std/iterators/iterator.requirements/bidirectional.iterators/nothing_to_do.pass.cpp b/test/std/iterators/iterator.requirements/bidirectional.iterators/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/iterators/iterator.requirements/bidirectional.iterators/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/iterators/iterator.requirements/forward.iterators/nothing_to_do.pass.cpp b/test/std/iterators/iterator.requirements/forward.iterators/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/iterators/iterator.requirements/forward.iterators/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/iterators/iterator.requirements/input.iterators/nothing_to_do.pass.cpp b/test/std/iterators/iterator.requirements/input.iterators/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/iterators/iterator.requirements/input.iterators/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/iterators/iterator.requirements/iterator.iterators/nothing_to_do.pass.cpp b/test/std/iterators/iterator.requirements/iterator.iterators/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/iterators/iterator.requirements/iterator.iterators/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/iterators/iterator.requirements/iterator.requirements.general/nothing_to_do.pass.cpp b/test/std/iterators/iterator.requirements/iterator.requirements.general/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/iterators/iterator.requirements/iterator.requirements.general/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/iterators/iterator.requirements/nothing_to_do.pass.cpp b/test/std/iterators/iterator.requirements/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/iterators/iterator.requirements/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/iterators/iterator.requirements/output.iterators/nothing_to_do.pass.cpp b/test/std/iterators/iterator.requirements/output.iterators/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/iterators/iterator.requirements/output.iterators/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/iterators/iterator.requirements/random.access.iterators/nothing_to_do.pass.cpp b/test/std/iterators/iterator.requirements/random.access.iterators/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/iterators/iterator.requirements/random.access.iterators/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/iterators/iterator.synopsis/nothing_to_do.pass.cpp b/test/std/iterators/iterator.synopsis/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/iterators/iterator.synopsis/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/iterators/iterators.general/gcc_workaround.pass.cpp b/test/std/iterators/iterators.general/gcc_workaround.pass.cpp
new file mode 100644
index 000000000000..6522bd3c7bcb
--- /dev/null
+++ b/test/std/iterators/iterators.general/gcc_workaround.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// Tests workaround for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64816.
+
+#include <string>
+
+void f(const std::string &s) { s.begin(); }
+
+#include <vector>
+
+void AppendTo(const std::vector<char> &v) { v.begin(); }
+
+int main() {}
diff --git a/test/std/iterators/iterators.general/nothing_to_do.pass.cpp b/test/std/iterators/iterators.general/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/iterators/iterators.general/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.cons/container.fail.cpp b/test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.cons/container.fail.cpp
new file mode 100644
index 000000000000..5dd49a6254e7
--- /dev/null
+++ b/test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.cons/container.fail.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// back_insert_iterator
+
+// explicit back_insert_iterator(Cont& x);
+
+// test for explicit
+
+#include <iterator>
+#include <vector>
+
+int main()
+{
+ std::back_insert_iterator<std::vector<int> > i = std::vector<int>();
+}
diff --git a/test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.cons/container.pass.cpp b/test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.cons/container.pass.cpp
new file mode 100644
index 000000000000..f280adb7351a
--- /dev/null
+++ b/test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.cons/container.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// back_insert_iterator
+
+// explicit back_insert_iterator(Cont& x);
+
+#include <iterator>
+#include <vector>
+#include "nasty_containers.hpp"
+
+template <class C>
+void
+test(C c)
+{
+ std::back_insert_iterator<C> i(c);
+}
+
+int main()
+{
+ test(std::vector<int>());
+ test(nasty_vector<int>());
+}
diff --git a/test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op++/post.pass.cpp b/test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op++/post.pass.cpp
new file mode 100644
index 000000000000..c6ff0473ffbc
--- /dev/null
+++ b/test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op++/post.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// back_insert_iterator
+
+// back_insert_iterator<Cont> operator++(int);
+
+#include <iterator>
+#include <vector>
+#include <cassert>
+#include "nasty_containers.hpp"
+
+template <class C>
+void
+test(C c)
+{
+ std::back_insert_iterator<C> i(c);
+ std::back_insert_iterator<C> r = i++;
+ r = 0;
+ assert(c.size() == 1);
+ assert(c.back() == 0);
+}
+
+int main()
+{
+ test(std::vector<int>());
+ test(nasty_vector<int>());
+}
diff --git a/test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op++/pre.pass.cpp b/test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op++/pre.pass.cpp
new file mode 100644
index 000000000000..2b9f245a05a0
--- /dev/null
+++ b/test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op++/pre.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// back_insert_iterator
+
+// back_insert_iterator<Cont>& operator++();
+
+#include <iterator>
+#include <vector>
+#include <cassert>
+#include "nasty_containers.hpp"
+
+template <class C>
+void
+test(C c)
+{
+ std::back_insert_iterator<C> i(c);
+ std::back_insert_iterator<C>& r = ++i;
+ assert(&r == &i);
+}
+
+int main()
+{
+ test(std::vector<int>());
+ test(nasty_vector<int>());
+}
diff --git a/test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op=/lv_value.pass.cpp b/test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op=/lv_value.pass.cpp
new file mode 100644
index 000000000000..d3d1fbbcb9de
--- /dev/null
+++ b/test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op=/lv_value.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// back_insert_iterator
+
+// requires CopyConstructible<Cont::value_type>
+// back_insert_iterator<Cont>&
+// operator=(const Cont::value_type& value);
+
+#include <iterator>
+#include <vector>
+#include <cassert>
+
+template <class C>
+void
+test(C c)
+{
+ const typename C::value_type v = typename C::value_type();
+ std::back_insert_iterator<C> i(c);
+ i = v;
+ assert(c.back() == v);
+}
+
+class Copyable
+{
+ int data_;
+public:
+ Copyable() : data_(0) {}
+ ~Copyable() {data_ = -1;}
+
+ friend bool operator==(const Copyable& x, const Copyable& y)
+ {return x.data_ == y.data_;}
+};
+
+int main()
+{
+ test(std::vector<Copyable>());
+}
diff --git a/test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op=/rv_value.pass.cpp b/test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op=/rv_value.pass.cpp
new file mode 100644
index 000000000000..a3c11f7881a9
--- /dev/null
+++ b/test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op=/rv_value.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// back_insert_iterator
+
+// requires CopyConstructible<Cont::value_type>
+// back_insert_iterator<Cont>&
+// operator=(Cont::value_type&& value);
+
+#include <iterator>
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+#include <vector>
+#include <memory>
+#include <cassert>
+
+template <class C>
+void
+test(C c)
+{
+ std::back_insert_iterator<C> i(c);
+ i = typename C::value_type();
+ assert(c.back() == typename C::value_type());
+}
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ test(std::vector<std::unique_ptr<int> >());
+#endif
+}
diff --git a/test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op_astrk/test.pass.cpp b/test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op_astrk/test.pass.cpp
new file mode 100644
index 000000000000..f50f309e6912
--- /dev/null
+++ b/test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op_astrk/test.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// back_insert_iterator
+
+// back_insert_iterator<Cont>& operator*();
+
+#include <iterator>
+#include <vector>
+#include <cassert>
+#include "nasty_containers.hpp"
+
+template <class C>
+void
+test(C c)
+{
+ std::back_insert_iterator<C> i(c);
+ std::back_insert_iterator<C>& r = *i;
+ assert(&r == &i);
+}
+
+int main()
+{
+ test(std::vector<int>());
+ test(nasty_vector<int>());
+}
diff --git a/test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.inserter/test.pass.cpp b/test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.inserter/test.pass.cpp
new file mode 100644
index 000000000000..30e41407e6a5
--- /dev/null
+++ b/test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.inserter/test.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template <BackInsertionContainer Cont>
+// back_insert_iterator<Cont>
+// back_inserter(Cont& x);
+
+#include <iterator>
+#include <vector>
+#include <cassert>
+#include "nasty_containers.hpp"
+
+template <class C>
+void
+test(C c)
+{
+ std::back_insert_iterator<C> i = std::back_inserter(c);
+ i = 0;
+ assert(c.size() == 1);
+ assert(c.back() == 0);
+}
+
+int main()
+{
+ test(std::vector<int>());
+ test(nasty_vector<int>());
+}
diff --git a/test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/nothing_to_do.pass.cpp b/test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/iterators/predef.iterators/insert.iterators/back.insert.iterator/types.pass.cpp b/test/std/iterators/predef.iterators/insert.iterators/back.insert.iterator/types.pass.cpp
new file mode 100644
index 000000000000..2611c9a4b0cc
--- /dev/null
+++ b/test/std/iterators/predef.iterators/insert.iterators/back.insert.iterator/types.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// back_insert_iterator
+
+// Test nested types and data member:
+
+// template <BackInsertionContainer Cont>
+// class back_insert_iterator {
+// protected:
+// Cont* container;
+// public:
+// typedef Cont container_type;
+// typedef void value_type;
+// typedef void difference_type;
+// typedef back_insert_iterator<Cont>& reference;
+// typedef void pointer;
+// };
+
+#include <iterator>
+#include <type_traits>
+#include <vector>
+
+template <class C>
+struct find_container
+ : private std::back_insert_iterator<C>
+{
+ explicit find_container(C& c) : std::back_insert_iterator<C>(c) {}
+ void test() {this->container = 0;}
+};
+
+template <class C>
+void
+test()
+{
+ typedef std::back_insert_iterator<C> R;
+ C c;
+ find_container<C> q(c);
+ q.test();
+ static_assert((std::is_same<typename R::container_type, C>::value), "");
+ static_assert((std::is_same<typename R::value_type, void>::value), "");
+ static_assert((std::is_same<typename R::difference_type, void>::value), "");
+ static_assert((std::is_same<typename R::reference, R&>::value), "");
+ static_assert((std::is_same<typename R::pointer, void>::value), "");
+ static_assert((std::is_same<typename R::iterator_category, std::output_iterator_tag>::value), "");
+}
+
+int main()
+{
+ test<std::vector<int> >();
+}
diff --git a/test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.cons/container.fail.cpp b/test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.cons/container.fail.cpp
new file mode 100644
index 000000000000..96d5d000d5bf
--- /dev/null
+++ b/test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.cons/container.fail.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// front_insert_iterator
+
+// explicit front_insert_iterator(Cont& x);
+
+// test for explicit
+
+#include <iterator>
+#include <list>
+
+int main()
+{
+ std::front_insert_iterator<std::list<int> > i = std::list<int>();
+}
diff --git a/test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.cons/container.pass.cpp b/test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.cons/container.pass.cpp
new file mode 100644
index 000000000000..1a148e613cba
--- /dev/null
+++ b/test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.cons/container.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// front_insert_iterator
+
+// explicit front_insert_iterator(Cont& x);
+
+#include <iterator>
+#include <list>
+#include "nasty_containers.hpp"
+
+template <class C>
+void
+test(C c)
+{
+ std::front_insert_iterator<C> i(c);
+}
+
+int main()
+{
+ test(std::list<int>());
+ test(nasty_list<int>());
+}
diff --git a/test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op++/post.pass.cpp b/test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op++/post.pass.cpp
new file mode 100644
index 000000000000..74892272e245
--- /dev/null
+++ b/test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op++/post.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// front_insert_iterator
+
+// front_insert_iterator<Cont> operator++(int);
+
+#include <iterator>
+#include <list>
+#include <cassert>
+#include "nasty_containers.hpp"
+
+template <class C>
+void
+test(C c)
+{
+ std::front_insert_iterator<C> i(c);
+ std::front_insert_iterator<C> r = i++;
+ r = 0;
+ assert(c.size() == 1);
+ assert(c.back() == 0);
+}
+
+int main()
+{
+ test(std::list<int>());
+ test(nasty_list<int>());
+}
diff --git a/test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op++/pre.pass.cpp b/test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op++/pre.pass.cpp
new file mode 100644
index 000000000000..e6d6c07604ef
--- /dev/null
+++ b/test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op++/pre.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// front_insert_iterator
+
+// front_insert_iterator<Cont>& operator++();
+
+#include <iterator>
+#include <list>
+#include <cassert>
+#include "nasty_containers.hpp"
+
+template <class C>
+void
+test(C c)
+{
+ std::front_insert_iterator<C> i(c);
+ std::front_insert_iterator<C>& r = ++i;
+ assert(&r == &i);
+}
+
+int main()
+{
+ test(std::list<int>());
+ test(nasty_list<int>());
+}
diff --git a/test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op=/lv_value.pass.cpp b/test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op=/lv_value.pass.cpp
new file mode 100644
index 000000000000..cdca9bf4becb
--- /dev/null
+++ b/test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op=/lv_value.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// front_insert_iterator
+
+// front_insert_iterator<Cont>&
+// operator=(const Cont::value_type& value);
+
+#include <iterator>
+#include <list>
+#include <cassert>
+#include "nasty_containers.hpp"
+
+template <class C>
+void
+test(C c)
+{
+ const typename C::value_type v = typename C::value_type();
+ std::front_insert_iterator<C> i(c);
+ i = v;
+ assert(c.front() == v);
+}
+
+class Copyable
+{
+ int data_;
+public:
+ Copyable() : data_(0) {}
+ ~Copyable() {data_ = -1;}
+
+ friend bool operator==(const Copyable& x, const Copyable& y)
+ {return x.data_ == y.data_;}
+};
+
+int main()
+{
+ test(std::list<Copyable>());
+ test(nasty_list<Copyable>());
+}
diff --git a/test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op=/rv_value.pass.cpp b/test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op=/rv_value.pass.cpp
new file mode 100644
index 000000000000..bd2bd44837ab
--- /dev/null
+++ b/test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op=/rv_value.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// front_insert_iterator
+
+// front_insert_iterator<Cont>&
+// operator=(Cont::value_type&& value);
+
+#include <iterator>
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+#include <list>
+#include <memory>
+#include <cassert>
+
+template <class C>
+void
+test(C c)
+{
+ std::front_insert_iterator<C> i(c);
+ i = typename C::value_type();
+ assert(c.front() == typename C::value_type());
+}
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ test(std::list<std::unique_ptr<int> >());
+#endif
+}
diff --git a/test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op_astrk/test.pass.cpp b/test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op_astrk/test.pass.cpp
new file mode 100644
index 000000000000..1ff49dde4512
--- /dev/null
+++ b/test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op_astrk/test.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// front_insert_iterator
+
+// front_insert_iterator<Cont>& operator*();
+
+#include <iterator>
+#include <list>
+#include <cassert>
+#include "nasty_containers.hpp"
+
+template <class C>
+void
+test(C c)
+{
+ std::front_insert_iterator<C> i(c);
+ std::front_insert_iterator<C>& r = *i;
+ assert(&r == &i);
+}
+
+int main()
+{
+ test(std::list<int>());
+ test(nasty_list<int>());
+}
diff --git a/test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.inserter/test.pass.cpp b/test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.inserter/test.pass.cpp
new file mode 100644
index 000000000000..c18f84baf5f4
--- /dev/null
+++ b/test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.inserter/test.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template <BackInsertionContainer Cont>
+// front_insert_iterator<Cont>
+// front_inserter(Cont& x);
+
+#include <iterator>
+#include <list>
+#include <cassert>
+#include "nasty_containers.hpp"
+
+template <class C>
+void
+test(C c)
+{
+ std::front_insert_iterator<C> i = std::front_inserter(c);
+ i = 0;
+ assert(c.size() == 1);
+ assert(c.front() == 0);
+}
+
+int main()
+{
+ test(std::list<int>());
+ test(nasty_list<int>());
+}
diff --git a/test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/nothing_to_do.pass.cpp b/test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/iterators/predef.iterators/insert.iterators/front.insert.iterator/types.pass.cpp b/test/std/iterators/predef.iterators/insert.iterators/front.insert.iterator/types.pass.cpp
new file mode 100644
index 000000000000..755133a91948
--- /dev/null
+++ b/test/std/iterators/predef.iterators/insert.iterators/front.insert.iterator/types.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// front_insert_iterator
+
+// Test nested types and data member:
+
+// template <class Container>
+// class front_insert_iterator {
+// protected:
+// Container* container;
+// public:
+// typedef Container container_type;
+// typedef void value_type;
+// typedef void difference_type;
+// typedef front_insert_iterator<Cont>& reference;
+// typedef void pointer;
+// typedef output_iterator_tag iterator_category;
+// };
+
+#include <iterator>
+#include <type_traits>
+#include <vector>
+
+template <class C>
+struct find_container
+ : private std::front_insert_iterator<C>
+{
+ explicit find_container(C& c) : std::front_insert_iterator<C>(c) {}
+ void test() {this->container = 0;}
+};
+
+template <class C>
+void
+test()
+{
+ typedef std::front_insert_iterator<C> R;
+ C c;
+ find_container<C> q(c);
+ q.test();
+ static_assert((std::is_same<typename R::container_type, C>::value), "");
+ static_assert((std::is_same<typename R::value_type, void>::value), "");
+ static_assert((std::is_same<typename R::difference_type, void>::value), "");
+ static_assert((std::is_same<typename R::reference, R&>::value), "");
+ static_assert((std::is_same<typename R::pointer, void>::value), "");
+ static_assert((std::is_same<typename R::iterator_category, std::output_iterator_tag>::value), "");
+}
+
+int main()
+{
+ test<std::vector<int> >();
+}
diff --git a/test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.cons/test.pass.cpp b/test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.cons/test.pass.cpp
new file mode 100644
index 000000000000..9f17240a72be
--- /dev/null
+++ b/test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.cons/test.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// insert_iterator
+
+// insert_iterator(Cont& x, Cont::iterator i);
+
+#include <iterator>
+#include <vector>
+#include "nasty_containers.hpp"
+
+template <class C>
+void
+test(C c)
+{
+ std::insert_iterator<C> i(c, c.begin());
+}
+
+int main()
+{
+ test(std::vector<int>());
+ test(nasty_vector<int>());
+}
diff --git a/test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op++/post.pass.cpp b/test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op++/post.pass.cpp
new file mode 100644
index 000000000000..7d81a7b721d1
--- /dev/null
+++ b/test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op++/post.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// insert_iterator
+
+// insert_iterator<Cont> operator++(int);
+
+#include <iterator>
+#include <vector>
+#include <cassert>
+#include "nasty_containers.hpp"
+
+template <class C>
+void
+test(C c)
+{
+ std::insert_iterator<C> i(c, c.end());
+ std::insert_iterator<C> r = i++;
+ r = 0;
+ assert(c.size() == 1);
+ assert(c.back() == 0);
+}
+
+int main()
+{
+ test(std::vector<int>());
+ test(nasty_vector<int>());
+}
diff --git a/test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op++/pre.pass.cpp b/test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op++/pre.pass.cpp
new file mode 100644
index 000000000000..08e6ced01c6f
--- /dev/null
+++ b/test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op++/pre.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// insert_iterator
+
+// insert_iterator<Cont>& operator++();
+
+#include <iterator>
+#include <vector>
+#include <cassert>
+#include "nasty_containers.hpp"
+
+template <class C>
+void
+test(C c)
+{
+ std::insert_iterator<C> i(c, c.end());
+ std::insert_iterator<C>& r = ++i;
+ assert(&r == &i);
+}
+
+int main()
+{
+ test(std::vector<int>());
+ test(nasty_vector<int>());
+}
diff --git a/test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op=/lv_value.pass.cpp b/test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op=/lv_value.pass.cpp
new file mode 100644
index 000000000000..01eb35efc673
--- /dev/null
+++ b/test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op=/lv_value.pass.cpp
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// insert_iterator
+
+// requires CopyConstructible<Cont::value_type>
+// insert_iterator<Cont>&
+// operator=(const Cont::value_type& value);
+
+#include <iterator>
+#include <vector>
+#include <cassert>
+#include "nasty_containers.hpp"
+
+template <class C>
+void
+test(C c1, typename C::difference_type j,
+ typename C::value_type x1, typename C::value_type x2,
+ typename C::value_type x3, const C& c2)
+{
+ std::insert_iterator<C> q(c1, c1.begin() + j);
+ q = x1;
+ q = x2;
+ q = x3;
+ assert(c1 == c2);
+}
+
+template <class C>
+void
+insert3at(C& c, typename C::iterator i,
+ typename C::value_type x1, typename C::value_type x2,
+ typename C::value_type x3)
+{
+ i = c.insert(i, x1);
+ i = c.insert(++i, x2);
+ c.insert(++i, x3);
+}
+
+int main()
+{
+ {
+ typedef std::vector<int> C;
+ C c1;
+ for (int i = 0; i < 3; ++i)
+ c1.push_back(i);
+ C c2 = c1;
+ insert3at(c2, c2.begin(), 'a', 'b', 'c');
+ test(c1, 0, 'a', 'b', 'c', c2);
+ c2 = c1;
+ insert3at(c2, c2.begin()+1, 'a', 'b', 'c');
+ test(c1, 1, 'a', 'b', 'c', c2);
+ c2 = c1;
+ insert3at(c2, c2.begin()+2, 'a', 'b', 'c');
+ test(c1, 2, 'a', 'b', 'c', c2);
+ c2 = c1;
+ insert3at(c2, c2.begin()+3, 'a', 'b', 'c');
+ test(c1, 3, 'a', 'b', 'c', c2);
+ }
+ {
+ typedef nasty_vector<int> C;
+ C c1;
+ for (int i = 0; i < 3; ++i)
+ c1.push_back(i);
+ C c2 = c1;
+ insert3at(c2, c2.begin(), 'a', 'b', 'c');
+ test(c1, 0, 'a', 'b', 'c', c2);
+ c2 = c1;
+ insert3at(c2, c2.begin()+1, 'a', 'b', 'c');
+ test(c1, 1, 'a', 'b', 'c', c2);
+ c2 = c1;
+ insert3at(c2, c2.begin()+2, 'a', 'b', 'c');
+ test(c1, 2, 'a', 'b', 'c', c2);
+ c2 = c1;
+ insert3at(c2, c2.begin()+3, 'a', 'b', 'c');
+ test(c1, 3, 'a', 'b', 'c', c2);
+ }
+}
diff --git a/test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op=/rv_value.pass.cpp b/test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op=/rv_value.pass.cpp
new file mode 100644
index 000000000000..f771688f1adc
--- /dev/null
+++ b/test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op=/rv_value.pass.cpp
@@ -0,0 +1,98 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// insert_iterator
+
+// requires CopyConstructible<Cont::value_type>
+// insert_iterator<Cont>&
+// operator=(const Cont::value_type& value);
+
+#include <iterator>
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#include <utility>
+#include <vector>
+#include <memory>
+#include <cassert>
+
+template <class C>
+void
+test(C c1, typename C::difference_type j,
+ typename C::value_type x1, typename C::value_type x2,
+ typename C::value_type x3, const C& c2)
+{
+ std::insert_iterator<C> q(c1, c1.begin() + j);
+ q = std::move(x1);
+ q = std::move(x2);
+ q = std::move(x3);
+ assert(c1 == c2);
+}
+
+template <class C>
+void
+insert3at(C& c, typename C::iterator i,
+ typename C::value_type x1, typename C::value_type x2,
+ typename C::value_type x3)
+{
+ i = c.insert(i, std::move(x1));
+ i = c.insert(++i, std::move(x2));
+ c.insert(++i, std::move(x3));
+}
+
+struct do_nothing
+{
+ void operator()(void*) const {}
+};
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::unique_ptr<int, do_nothing> Ptr;
+ typedef std::vector<Ptr> C;
+ C c1;
+ int x[6] = {0};
+ for (int i = 0; i < 3; ++i)
+ c1.push_back(Ptr(x+i));
+ C c2;
+ for (int i = 0; i < 3; ++i)
+ c2.push_back(Ptr(x+i));
+ insert3at(c2, c2.begin(), Ptr(x+3), Ptr(x+4), Ptr(x+5));
+ test(std::move(c1), 0, Ptr(x+3), Ptr(x+4), Ptr(x+5), c2);
+ c1.clear();
+ for (int i = 0; i < 3; ++i)
+ c1.push_back(Ptr(x+i));
+ c2.clear();
+ for (int i = 0; i < 3; ++i)
+ c2.push_back(Ptr(x+i));
+ insert3at(c2, c2.begin()+1, Ptr(x+3), Ptr(x+4), Ptr(x+5));
+ test(std::move(c1), 1, Ptr(x+3), Ptr(x+4), Ptr(x+5), c2);
+ c1.clear();
+ for (int i = 0; i < 3; ++i)
+ c1.push_back(Ptr(x+i));
+ c2.clear();
+ for (int i = 0; i < 3; ++i)
+ c2.push_back(Ptr(x+i));
+ insert3at(c2, c2.begin()+2, Ptr(x+3), Ptr(x+4), Ptr(x+5));
+ test(std::move(c1), 2, Ptr(x+3), Ptr(x+4), Ptr(x+5), c2);
+ c1.clear();
+ for (int i = 0; i < 3; ++i)
+ c1.push_back(Ptr(x+i));
+ c2.clear();
+ for (int i = 0; i < 3; ++i)
+ c2.push_back(Ptr(x+i));
+ insert3at(c2, c2.begin()+3, Ptr(x+3), Ptr(x+4), Ptr(x+5));
+ test(std::move(c1), 3, Ptr(x+3), Ptr(x+4), Ptr(x+5), c2);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op_astrk/test.pass.cpp b/test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op_astrk/test.pass.cpp
new file mode 100644
index 000000000000..1a926b5485cd
--- /dev/null
+++ b/test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op_astrk/test.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// insert_iterator
+
+// insert_iterator<Cont>& operator*();
+
+#include <iterator>
+#include <vector>
+#include <cassert>
+#include "nasty_containers.hpp"
+
+template <class C>
+void
+test(C c)
+{
+ std::insert_iterator<C> i(c, c.end());
+ std::insert_iterator<C>& r = *i;
+ assert(&r == &i);
+}
+
+int main()
+{
+ test(std::vector<int>());
+ test(nasty_vector<int>());
+}
diff --git a/test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/inserter/test.pass.cpp b/test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/inserter/test.pass.cpp
new file mode 100644
index 000000000000..43f28d09bcfa
--- /dev/null
+++ b/test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/inserter/test.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template <InsertionContainer Cont>
+// insert_iterator<Cont>
+// inserter(Cont& x, Cont::iterator i);
+
+#include <iterator>
+#include <vector>
+#include <cassert>
+#include "nasty_containers.hpp"
+
+template <class C>
+void
+test(C c)
+{
+ std::insert_iterator<C> i = std::inserter(c, c.end());
+ i = 0;
+ assert(c.size() == 1);
+ assert(c.back() == 0);
+}
+
+int main()
+{
+ test(std::vector<int>());
+ test(nasty_vector<int>());
+}
diff --git a/test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/nothing_to_do.pass.cpp b/test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/iterators/predef.iterators/insert.iterators/insert.iterator/types.pass.cpp b/test/std/iterators/predef.iterators/insert.iterators/insert.iterator/types.pass.cpp
new file mode 100644
index 000000000000..cf63df63e89b
--- /dev/null
+++ b/test/std/iterators/predef.iterators/insert.iterators/insert.iterator/types.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// insert_iterator
+
+// Test nested types and data members:
+
+// template <InsertionContainer Cont>
+// class insert_iterator {
+// protected:
+// Cont* container;
+// Cont::iterator iter;
+// public:
+// typedef Cont container_type;
+// typedef void value_type;
+// typedef void difference_type;
+// typedef insert_iterator<Cont>& reference;
+// typedef void pointer;
+// };
+
+#include <iterator>
+#include <type_traits>
+#include <vector>
+
+template <class C>
+struct find_members
+ : private std::insert_iterator<C>
+{
+ explicit find_members(C& c) : std::insert_iterator<C>(c, c.begin()) {}
+ void test()
+ {
+ this->container = 0;
+ (void)(this->iter == this->iter);
+ }
+};
+
+template <class C>
+void
+test()
+{
+ typedef std::insert_iterator<C> R;
+ C c;
+ find_members<C> q(c);
+ q.test();
+ static_assert((std::is_same<typename R::container_type, C>::value), "");
+ static_assert((std::is_same<typename R::value_type, void>::value), "");
+ static_assert((std::is_same<typename R::difference_type, void>::value), "");
+ static_assert((std::is_same<typename R::reference, R&>::value), "");
+ static_assert((std::is_same<typename R::pointer, void>::value), "");
+ static_assert((std::is_same<typename R::iterator_category, std::output_iterator_tag>::value), "");
+}
+
+int main()
+{
+ test<std::vector<int> >();
+}
diff --git a/test/std/iterators/predef.iterators/insert.iterators/nothing_to_do.pass.cpp b/test/std/iterators/predef.iterators/insert.iterators/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/iterators/predef.iterators/insert.iterators/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.nonmember/make_move_iterator.pass.cpp b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.nonmember/make_move_iterator.pass.cpp
new file mode 100644
index 000000000000..06834981ef38
--- /dev/null
+++ b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.nonmember/make_move_iterator.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// template <InputIterator Iter>
+// move_iterator<Iter>
+// make_move_iterator(const Iter& i);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It i)
+{
+ const std::move_iterator<It> r(i);
+ assert(std::make_move_iterator(i) == r);
+}
+
+int main()
+{
+ {
+ char s[] = "1234567890";
+ test(input_iterator<char*>(s+5));
+ test(forward_iterator<char*>(s+5));
+ test(bidirectional_iterator<char*>(s+5));
+ test(random_access_iterator<char*>(s+5));
+ test(s+5);
+ }
+ {
+ int a[] = {1,2,3,4};
+ std::make_move_iterator(a+4);
+ std::make_move_iterator(a); // test for LWG issue 2061
+ }
+}
diff --git a/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.nonmember/minus.pass.cpp b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.nonmember/minus.pass.cpp
new file mode 100644
index 000000000000..d52175c92296
--- /dev/null
+++ b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.nonmember/minus.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// template <RandomAccessIterator Iter1, RandomAccessIterator Iter2>
+// requires HasMinus<Iter1, Iter2>
+// auto
+// operator-(const move_iterator<Iter1>& x, const move_iterator<Iter2>& y)
+// -> decltype(x.base() - y.base());
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It l, It r, typename std::iterator_traits<It>::difference_type x)
+{
+ const std::move_iterator<It> r1(l);
+ const std::move_iterator<It> r2(r);
+ assert(r1 - r2 == x);
+}
+
+int main()
+{
+ char s[] = "1234567890";
+ test(random_access_iterator<char*>(s+5), random_access_iterator<char*>(s), 5);
+ test(s+5, s, 5);
+}
diff --git a/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.nonmember/plus.pass.cpp b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.nonmember/plus.pass.cpp
new file mode 100644
index 000000000000..e67ebfca3717
--- /dev/null
+++ b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.nonmember/plus.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// template <RandomAccessIterator Iter>
+// move_iterator<Iter>
+// operator+(Iter::difference_type n, const move_iterator<Iter>& x);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It i, typename std::iterator_traits<It>::difference_type n, It x)
+{
+ const std::move_iterator<It> r(i);
+ std::move_iterator<It> rr = n + r;
+ assert(rr.base() == x);
+}
+
+int main()
+{
+ char s[] = "1234567890";
+ test(random_access_iterator<char*>(s+5), 5, random_access_iterator<char*>(s+10));
+ test(s+5, 5, s+10);
+}
diff --git a/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.+/difference_type.pass.cpp b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.+/difference_type.pass.cpp
new file mode 100644
index 000000000000..e9a19f4932c5
--- /dev/null
+++ b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.+/difference_type.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// requires RandomAccessIterator<Iter>
+// move_iterator operator+(difference_type n) const;
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It i, typename std::iterator_traits<It>::difference_type n, It x)
+{
+ const std::move_iterator<It> r(i);
+ std::move_iterator<It> rr = r + n;
+ assert(rr.base() == x);
+}
+
+int main()
+{
+ const char* s = "1234567890";
+ test(random_access_iterator<const char*>(s+5), 5, random_access_iterator<const char*>(s+10));
+ test(s+5, 5, s+10);
+}
diff --git a/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.+=/difference_type.pass.cpp b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.+=/difference_type.pass.cpp
new file mode 100644
index 000000000000..5de1bccf877f
--- /dev/null
+++ b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.+=/difference_type.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// requires RandomAccessIterator<Iter>
+// move_iterator& operator+=(difference_type n);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It i, typename std::iterator_traits<It>::difference_type n, It x)
+{
+ std::move_iterator<It> r(i);
+ std::move_iterator<It>& rr = r += n;
+ assert(r.base() == x);
+ assert(&rr == &r);
+}
+
+int main()
+{
+ const char* s = "1234567890";
+ test(random_access_iterator<const char*>(s+5), 5, random_access_iterator<const char*>(s+10));
+ test(s+5, 5, s+10);
+}
diff --git a/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.-/difference_type.pass.cpp b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.-/difference_type.pass.cpp
new file mode 100644
index 000000000000..852f76a4a4d3
--- /dev/null
+++ b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.-/difference_type.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// requires RandomAccessIterator<Iter>
+// move_iterator operator-(difference_type n) const;
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It i, typename std::iterator_traits<It>::difference_type n, It x)
+{
+ const std::move_iterator<It> r(i);
+ std::move_iterator<It> rr = r - n;
+ assert(rr.base() == x);
+}
+
+int main()
+{
+ const char* s = "1234567890";
+ test(random_access_iterator<const char*>(s+5), 5, random_access_iterator<const char*>(s));
+ test(s+5, 5, s);
+}
diff --git a/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.-=/difference_type.pass.cpp b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.-=/difference_type.pass.cpp
new file mode 100644
index 000000000000..f8630736980d
--- /dev/null
+++ b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.-=/difference_type.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// requires RandomAccessIterator<Iter>
+// move_iterator& operator-=(difference_type n);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It i, typename std::iterator_traits<It>::difference_type n, It x)
+{
+ std::move_iterator<It> r(i);
+ std::move_iterator<It>& rr = r -= n;
+ assert(r.base() == x);
+ assert(&rr == &r);
+}
+
+int main()
+{
+ const char* s = "1234567890";
+ test(random_access_iterator<const char*>(s+5), 5, random_access_iterator<const char*>(s));
+ test(s+5, 5, s);
+}
diff --git a/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_eq.pass.cpp b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_eq.pass.cpp
new file mode 100644
index 000000000000..fb4f0fa1dc12
--- /dev/null
+++ b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_eq.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// template <InputIterator Iter1, InputIterator Iter2>
+// requires HasEqualTo<Iter1, Iter2>
+// bool
+// operator==(const move_iterator<Iter1>& x, const move_iterator<Iter2>& y);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It l, It r, bool x)
+{
+ const std::move_iterator<It> r1(l);
+ const std::move_iterator<It> r2(r);
+ assert((r1 == r2) == x);
+}
+
+int main()
+{
+ char s[] = "1234567890";
+ test(input_iterator<char*>(s), input_iterator<char*>(s), true);
+ test(input_iterator<char*>(s), input_iterator<char*>(s+1), false);
+ test(forward_iterator<char*>(s), forward_iterator<char*>(s), true);
+ test(forward_iterator<char*>(s), forward_iterator<char*>(s+1), false);
+ test(bidirectional_iterator<char*>(s), bidirectional_iterator<char*>(s), true);
+ test(bidirectional_iterator<char*>(s), bidirectional_iterator<char*>(s+1), false);
+ test(random_access_iterator<char*>(s), random_access_iterator<char*>(s), true);
+ test(random_access_iterator<char*>(s), random_access_iterator<char*>(s+1), false);
+ test(s, s, true);
+ test(s, s+1, false);
+}
diff --git a/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_gt.pass.cpp b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_gt.pass.cpp
new file mode 100644
index 000000000000..0edd2857c081
--- /dev/null
+++ b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_gt.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// template <RandomAccessIterator Iter1, RandomAccessIterator Iter2>
+// requires HasLess<Iter2, Iter1>
+// bool
+// operator>(const move_iterator<Iter1>& x, const move_iterator<Iter2>& y);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It l, It r, bool x)
+{
+ const std::move_iterator<It> r1(l);
+ const std::move_iterator<It> r2(r);
+ assert((r1 > r2) == x);
+}
+
+int main()
+{
+ char s[] = "1234567890";
+ test(random_access_iterator<char*>(s), random_access_iterator<char*>(s), false);
+ test(random_access_iterator<char*>(s), random_access_iterator<char*>(s+1), false);
+ test(random_access_iterator<char*>(s+1), random_access_iterator<char*>(s), true);
+ test(s, s, false);
+ test(s, s+1, false);
+ test(s+1, s, true);
+}
diff --git a/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_gte.pass.cpp b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_gte.pass.cpp
new file mode 100644
index 000000000000..cb9cdb9aeb4f
--- /dev/null
+++ b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_gte.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// template <RandomAccessIterator Iter1, RandomAccessIterator Iter2>
+// requires HasLess<Iter1, Iter2>
+// bool
+// operator>=(const move_iterator<Iter1>& x, const move_iterator<Iter2>& y);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It l, It r, bool x)
+{
+ const std::move_iterator<It> r1(l);
+ const std::move_iterator<It> r2(r);
+ assert((r1 >= r2) == x);
+}
+
+int main()
+{
+ char s[] = "1234567890";
+ test(random_access_iterator<char*>(s), random_access_iterator<char*>(s), true);
+ test(random_access_iterator<char*>(s), random_access_iterator<char*>(s+1), false);
+ test(random_access_iterator<char*>(s+1), random_access_iterator<char*>(s), true);
+ test(s, s, true);
+ test(s, s+1, false);
+ test(s+1, s, true);
+}
diff --git a/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_lt.pass.cpp b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_lt.pass.cpp
new file mode 100644
index 000000000000..e7979ddd746e
--- /dev/null
+++ b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_lt.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// template <RandomAccessIterator Iter1, RandomAccessIterator Iter2>
+// requires HasLess<Iter1, Iter2>
+// bool
+// operator<(const move_iterator<Iter1>& x, const move_iterator<Iter2>& y);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It l, It r, bool x)
+{
+ const std::move_iterator<It> r1(l);
+ const std::move_iterator<It> r2(r);
+ assert((r1 < r2) == x);
+}
+
+int main()
+{
+ char s[] = "1234567890";
+ test(random_access_iterator<char*>(s), random_access_iterator<char*>(s), false);
+ test(random_access_iterator<char*>(s), random_access_iterator<char*>(s+1), true);
+ test(random_access_iterator<char*>(s+1), random_access_iterator<char*>(s), false);
+ test(s, s, false);
+ test(s, s+1, true);
+ test(s+1, s, false);
+}
diff --git a/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_lte.pass.cpp b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_lte.pass.cpp
new file mode 100644
index 000000000000..97a7bfdee466
--- /dev/null
+++ b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_lte.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// template <RandomAccessIterator Iter1, RandomAccessIterator Iter2>
+// requires HasLess<Iter2, Iter1>
+// bool
+// operator<=(const move_iterator<Iter1>& x, const move_iterator<Iter2>& y);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It l, It r, bool x)
+{
+ const std::move_iterator<It> r1(l);
+ const std::move_iterator<It> r2(r);
+ assert((r1 <= r2) == x);
+}
+
+int main()
+{
+ char s[] = "1234567890";
+ test(random_access_iterator<char*>(s), random_access_iterator<char*>(s), true);
+ test(random_access_iterator<char*>(s), random_access_iterator<char*>(s+1), true);
+ test(random_access_iterator<char*>(s+1), random_access_iterator<char*>(s), false);
+ test(s, s, true);
+ test(s, s+1, true);
+ test(s+1, s, false);
+}
diff --git a/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_neq.pass.cpp b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_neq.pass.cpp
new file mode 100644
index 000000000000..9e4b9e37202c
--- /dev/null
+++ b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_neq.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// template <InputIterator Iter1, InputIterator Iter2>
+// requires HasEqualTo<Iter1, Iter2>
+// bool
+// operator!=(const move_iterator<Iter1>& x, const move_iterator<Iter2>& y);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It l, It r, bool x)
+{
+ const std::move_iterator<It> r1(l);
+ const std::move_iterator<It> r2(r);
+ assert((r1 != r2) == x);
+}
+
+int main()
+{
+ char s[] = "1234567890";
+ test(input_iterator<char*>(s), input_iterator<char*>(s), false);
+ test(input_iterator<char*>(s), input_iterator<char*>(s+1), true);
+ test(forward_iterator<char*>(s), forward_iterator<char*>(s), false);
+ test(forward_iterator<char*>(s), forward_iterator<char*>(s+1), true);
+ test(bidirectional_iterator<char*>(s), bidirectional_iterator<char*>(s), false);
+ test(bidirectional_iterator<char*>(s), bidirectional_iterator<char*>(s+1), true);
+ test(random_access_iterator<char*>(s), random_access_iterator<char*>(s), false);
+ test(random_access_iterator<char*>(s), random_access_iterator<char*>(s+1), true);
+ test(s, s, false);
+ test(s, s+1, true);
+}
diff --git a/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/convert.fail.cpp b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/convert.fail.cpp
new file mode 100644
index 000000000000..22d267af94d9
--- /dev/null
+++ b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/convert.fail.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// template <class U>
+// requires HasConstructor<Iter, const U&>
+// move_iterator(const move_iterator<U> &u);
+
+// test requires
+
+#include <iterator>
+
+template <class It, class U>
+void
+test(U u)
+{
+ std::move_iterator<U> r2(u);
+ std::move_iterator<It> r1 = r2;
+}
+
+struct base {};
+struct derived {};
+
+int main()
+{
+ derived d;
+
+ test<base*>(&d);
+}
diff --git a/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/convert.pass.cpp b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/convert.pass.cpp
new file mode 100644
index 000000000000..8c73a7d5c93c
--- /dev/null
+++ b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/convert.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// template <class U>
+// requires HasConstructor<Iter, const U&>
+// move_iterator(const move_iterator<U> &u);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It, class U>
+void
+test(U u)
+{
+ const std::move_iterator<U> r2(u);
+ std::move_iterator<It> r1 = r2;
+ assert(r1.base() == u);
+}
+
+struct Base {};
+struct Derived : Base {};
+
+int main()
+{
+ Derived d;
+
+ test<input_iterator<Base*> >(input_iterator<Derived*>(&d));
+ test<forward_iterator<Base*> >(forward_iterator<Derived*>(&d));
+ test<bidirectional_iterator<Base*> >(bidirectional_iterator<Derived*>(&d));
+ test<random_access_iterator<const Base*> >(random_access_iterator<Derived*>(&d));
+ test<Base*>(&d);
+}
diff --git a/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/default.pass.cpp b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/default.pass.cpp
new file mode 100644
index 000000000000..782cb6020326
--- /dev/null
+++ b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/default.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// move_iterator();
+
+#include <iterator>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test()
+{
+ std::move_iterator<It> r;
+}
+
+int main()
+{
+ test<input_iterator<char*> >();
+ test<forward_iterator<char*> >();
+ test<bidirectional_iterator<char*> >();
+ test<random_access_iterator<char*> >();
+ test<char*>();
+}
diff --git a/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/iter.fail.cpp b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/iter.fail.cpp
new file mode 100644
index 000000000000..188acff69edb
--- /dev/null
+++ b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/iter.fail.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// explicit move_iterator(Iter );
+
+// test explicit
+
+#include <iterator>
+
+template <class It>
+void
+test(It i)
+{
+ std::move_iterator<It> r = i;
+}
+
+int main()
+{
+ char s[] = "123";
+ test(s);
+}
diff --git a/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/iter.pass.cpp b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/iter.pass.cpp
new file mode 100644
index 000000000000..4a4a06018377
--- /dev/null
+++ b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/iter.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// explicit move_iterator(Iter i);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It i)
+{
+ std::move_iterator<It> r(i);
+ assert(r.base() == i);
+}
+
+int main()
+{
+ char s[] = "123";
+ test(input_iterator<char*>(s));
+ test(forward_iterator<char*>(s));
+ test(bidirectional_iterator<char*>(s));
+ test(random_access_iterator<char*>(s));
+ test(s);
+}
diff --git a/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.conv/tested_elsewhere.pass.cpp b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.conv/tested_elsewhere.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.conv/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.decr/post.pass.cpp b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.decr/post.pass.cpp
new file mode 100644
index 000000000000..26fab5be7931
--- /dev/null
+++ b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.decr/post.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// move_iterator operator--(int);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It i, It x)
+{
+ std::move_iterator<It> r(i);
+ std::move_iterator<It> rr = r--;
+ assert(r.base() == x);
+ assert(rr.base() == i);
+}
+
+int main()
+{
+ char s[] = "123";
+ test(bidirectional_iterator<char*>(s+1), bidirectional_iterator<char*>(s));
+ test(random_access_iterator<char*>(s+1), random_access_iterator<char*>(s));
+ test(s+1, s);
+}
diff --git a/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.decr/pre.pass.cpp b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.decr/pre.pass.cpp
new file mode 100644
index 000000000000..700b3b637749
--- /dev/null
+++ b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.decr/pre.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// move_iterator& operator--();
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It i, It x)
+{
+ std::move_iterator<It> r(i);
+ std::move_iterator<It>& rr = --r;
+ assert(r.base() == x);
+ assert(&rr == &r);
+}
+
+int main()
+{
+ char s[] = "123";
+ test(bidirectional_iterator<char*>(s+1), bidirectional_iterator<char*>(s));
+ test(random_access_iterator<char*>(s+1), random_access_iterator<char*>(s));
+ test(s+1, s);
+}
diff --git a/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.incr/post.pass.cpp b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.incr/post.pass.cpp
new file mode 100644
index 000000000000..e7c13b579622
--- /dev/null
+++ b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.incr/post.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// move_iterator operator++(int);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It i, It x)
+{
+ std::move_iterator<It> r(i);
+ std::move_iterator<It> rr = r++;
+ assert(r.base() == x);
+ assert(rr.base() == i);
+}
+
+int main()
+{
+ char s[] = "123";
+ test(input_iterator<char*>(s), input_iterator<char*>(s+1));
+ test(forward_iterator<char*>(s), forward_iterator<char*>(s+1));
+ test(bidirectional_iterator<char*>(s), bidirectional_iterator<char*>(s+1));
+ test(random_access_iterator<char*>(s), random_access_iterator<char*>(s+1));
+ test(s, s+1);
+}
diff --git a/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.incr/pre.pass.cpp b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.incr/pre.pass.cpp
new file mode 100644
index 000000000000..f27c737277d9
--- /dev/null
+++ b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.incr/pre.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// move_iterator& operator++();
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It i, It x)
+{
+ std::move_iterator<It> r(i);
+ std::move_iterator<It>& rr = ++r;
+ assert(r.base() == x);
+ assert(&rr == &r);
+}
+
+int main()
+{
+ char s[] = "123";
+ test(input_iterator<char*>(s), input_iterator<char*>(s+1));
+ test(forward_iterator<char*>(s), forward_iterator<char*>(s+1));
+ test(bidirectional_iterator<char*>(s), bidirectional_iterator<char*>(s+1));
+ test(random_access_iterator<char*>(s), random_access_iterator<char*>(s+1));
+ test(s, s+1);
+}
diff --git a/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.index/difference_type.pass.cpp b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.index/difference_type.pass.cpp
new file mode 100644
index 000000000000..8d507b822cd2
--- /dev/null
+++ b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.index/difference_type.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// requires RandomAccessIterator<Iter>
+// unspecified operator[](difference_type n) const;
+
+#include <iterator>
+#include <cassert>
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#include <memory>
+#endif
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It i, typename std::iterator_traits<It>::difference_type n,
+ typename std::iterator_traits<It>::value_type x)
+{
+ typedef typename std::iterator_traits<It>::value_type value_type;
+ const std::move_iterator<It> r(i);
+ value_type rr = r[n];
+ assert(rr == x);
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+struct do_nothing
+{
+ void operator()(void*) const {}
+};
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+ char s[] = "1234567890";
+ test(random_access_iterator<char*>(s+5), 4, '0');
+ test(s+5, 4, '0');
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ int i[5];
+ typedef std::unique_ptr<int, do_nothing> Ptr;
+ Ptr p[5];
+ for (unsigned j = 0; j < 5; ++j)
+ p[j].reset(i+j);
+ test(p, 3, Ptr(i+3));
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.ref/op_arrow.pass.cpp b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.ref/op_arrow.pass.cpp
new file mode 100644
index 000000000000..b0c00e3fbf86
--- /dev/null
+++ b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.ref/op_arrow.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// pointer operator->() const;
+
+#include <iterator>
+#include <cassert>
+
+template <class It>
+void
+test(It i)
+{
+ std::move_iterator<It> r(i);
+ assert(r.operator->() == i);
+}
+
+int main()
+{
+ char s[] = "123";
+ test(s);
+}
diff --git a/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.star/op_star.pass.cpp b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.star/op_star.pass.cpp
new file mode 100644
index 000000000000..6de708baa327
--- /dev/null
+++ b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.star/op_star.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// reference operator*() const;
+
+#include <iterator>
+#include <cassert>
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#include <memory>
+#endif
+
+class A
+{
+ int data_;
+public:
+ A() : data_(1) {}
+ ~A() {data_ = -1;}
+
+ friend bool operator==(const A& x, const A& y)
+ {return x.data_ == y.data_;}
+};
+
+template <class It>
+void
+test(It i, typename std::iterator_traits<It>::value_type x)
+{
+ std::move_iterator<It> r(i);
+ assert(*r == x);
+ typename std::iterator_traits<It>::value_type x2 = *r;
+ assert(x2 == x);
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+struct do_nothing
+{
+ void operator()(void*) const {}
+};
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+ A a;
+ test(&a, A());
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ int i;
+ std::unique_ptr<int, do_nothing> p(&i);
+ test(&p, std::unique_ptr<int, do_nothing>(&i));
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op=/move_iterator.fail.cpp b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op=/move_iterator.fail.cpp
new file mode 100644
index 000000000000..089cc29b2e94
--- /dev/null
+++ b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op=/move_iterator.fail.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// template <class U>
+// requires HasAssign<Iter, const U&>
+// move_iterator&
+// operator=(const move_iterator<U>& u);
+
+// test requires
+
+#include <iterator>
+
+template <class It, class U>
+void
+test(U u)
+{
+ const std::move_iterator<U> r2(u);
+ std::move_iterator<It> r1;
+ r1 = r2;
+}
+
+struct base {};
+struct derived {};
+
+int main()
+{
+ derived d;
+ test<base*>(&d);
+}
diff --git a/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op=/move_iterator.pass.cpp b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op=/move_iterator.pass.cpp
new file mode 100644
index 000000000000..449f7e809db4
--- /dev/null
+++ b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op=/move_iterator.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// template <class U>
+// requires HasAssign<Iter, const U&>
+// move_iterator&
+// operator=(const move_iterator<U>& u);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It, class U>
+void
+test(U u)
+{
+ const std::move_iterator<U> r2(u);
+ std::move_iterator<It> r1;
+ std::move_iterator<It>& rr = r1 = r2;
+ assert(r1.base() == u);
+ assert(&rr == &r1);
+}
+
+struct Base {};
+struct Derived : Base {};
+
+int main()
+{
+ Derived d;
+
+ test<input_iterator<Base*> >(input_iterator<Derived*>(&d));
+ test<forward_iterator<Base*> >(forward_iterator<Derived*>(&d));
+ test<bidirectional_iterator<Base*> >(bidirectional_iterator<Derived*>(&d));
+ test<random_access_iterator<const Base*> >(random_access_iterator<Derived*>(&d));
+ test<Base*>(&d);
+}
diff --git a/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/nothing_to_do.pass.cpp b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/iterators/predef.iterators/move.iterators/move.iter.requirements/nothing_to_do.pass.cpp b/test/std/iterators/predef.iterators/move.iterators/move.iter.requirements/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/iterators/predef.iterators/move.iterators/move.iter.requirements/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/iterators/predef.iterators/move.iterators/move.iterator/types.pass.cpp b/test/std/iterators/predef.iterators/move.iterators/move.iterator/types.pass.cpp
new file mode 100644
index 000000000000..9bdf7215e9ee
--- /dev/null
+++ b/test/std/iterators/predef.iterators/move.iterators/move.iterator/types.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// Test nested types:
+
+// template <InputIterator Iter>
+// class move_iterator {
+// public:
+// typedef Iter iterator_type;
+// typedef Iter::difference_type difference_type;
+// typedef Iterator pointer;
+// typedef Iter::value_type value_type;
+// typedef value_type&& reference;
+// };
+
+#include <iterator>
+#include <type_traits>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test()
+{
+ typedef std::move_iterator<It> R;
+ typedef std::iterator_traits<It> T;
+ static_assert((std::is_same<typename R::iterator_type, It>::value), "");
+ static_assert((std::is_same<typename R::difference_type, typename T::difference_type>::value), "");
+ static_assert((std::is_same<typename R::pointer, typename T::pointer>::value), "");
+ static_assert((std::is_same<typename R::value_type, typename T::value_type>::value), "");
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ static_assert((std::is_same<typename R::reference, typename R::value_type&&>::value), "");
+#else
+ static_assert((std::is_same<typename R::reference, typename T::reference>::value), "");
+#endif
+ static_assert((std::is_same<typename R::iterator_category, typename T::iterator_category>::value), "");
+}
+
+int main()
+{
+ test<input_iterator<char*> >();
+ test<forward_iterator<char*> >();
+ test<bidirectional_iterator<char*> >();
+ test<random_access_iterator<char*> >();
+ test<char*>();
+}
diff --git a/test/std/iterators/predef.iterators/move.iterators/nothing_to_do.pass.cpp b/test/std/iterators/predef.iterators/move.iterators/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/iterators/predef.iterators/move.iterators/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/iterators/predef.iterators/nothing_to_do.pass.cpp b/test/std/iterators/predef.iterators/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/iterators/predef.iterators/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/iterators/predef.iterators/reverse.iterators/nothing_to_do.pass.cpp b/test/std/iterators/predef.iterators/reverse.iterators/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/iterators/predef.iterators/reverse.iterators/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/nothing_to_do.pass.cpp b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/default.pass.cpp b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/default.pass.cpp
new file mode 100644
index 000000000000..72a767d17114
--- /dev/null
+++ b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/default.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// reverse_iterator();
+
+#include <iterator>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test()
+{
+ std::reverse_iterator<It> r;
+}
+
+int main()
+{
+ test<bidirectional_iterator<const char*> >();
+ test<random_access_iterator<char*> >();
+ test<char*>();
+ test<const char*>();
+}
diff --git a/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/iter.fail.cpp b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/iter.fail.cpp
new file mode 100644
index 000000000000..3f42f06ee08c
--- /dev/null
+++ b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/iter.fail.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// explicit reverse_iterator(Iter x);
+
+// test explicit
+
+#include <iterator>
+
+template <class It>
+void
+test(It i)
+{
+ std::reverse_iterator<It> r = i;
+}
+
+int main()
+{
+ const char s[] = "123";
+ test(s);
+}
diff --git a/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/iter.pass.cpp b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/iter.pass.cpp
new file mode 100644
index 000000000000..ea213c0dcf0d
--- /dev/null
+++ b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/iter.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// explicit reverse_iterator(Iter x);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It i)
+{
+ std::reverse_iterator<It> r(i);
+ assert(r.base() == i);
+}
+
+int main()
+{
+ const char s[] = "123";
+ test(bidirectional_iterator<const char*>(s));
+ test(random_access_iterator<const char*>(s));
+ test(s);
+}
diff --git a/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/reverse_iterator.fail.cpp b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/reverse_iterator.fail.cpp
new file mode 100644
index 000000000000..c0a9afecbd33
--- /dev/null
+++ b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/reverse_iterator.fail.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// template <class U>
+// requires HasConstructor<Iter, const U&>
+// reverse_iterator(const reverse_iterator<U> &u);
+
+// test requires
+
+#include <iterator>
+
+template <class It, class U>
+void
+test(U u)
+{
+ std::reverse_iterator<U> r2(u);
+ std::reverse_iterator<It> r1 = r2;
+}
+
+struct base {};
+struct derived {};
+
+int main()
+{
+ derived d;
+
+ test<base*>(&d);
+}
diff --git a/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/reverse_iterator.pass.cpp b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/reverse_iterator.pass.cpp
new file mode 100644
index 000000000000..280e7d59ae86
--- /dev/null
+++ b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/reverse_iterator.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// template <class U>
+// requires HasConstructor<Iter, const U&>
+// reverse_iterator(const reverse_iterator<U> &u);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It, class U>
+void
+test(U u)
+{
+ const std::reverse_iterator<U> r2(u);
+ std::reverse_iterator<It> r1 = r2;
+ assert(r1.base() == u);
+}
+
+struct Base {};
+struct Derived : Base {};
+
+int main()
+{
+ Derived d;
+
+ test<bidirectional_iterator<Base*> >(bidirectional_iterator<Derived*>(&d));
+ test<random_access_iterator<const Base*> >(random_access_iterator<Derived*>(&d));
+ test<Base*>(&d);
+}
diff --git a/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.conv/tested_elsewhere.pass.cpp b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.conv/tested_elsewhere.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.conv/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.make/make_reverse_iterator.pass.cpp b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.make/make_reverse_iterator.pass.cpp
new file mode 100644
index 000000000000..98b7331cd386
--- /dev/null
+++ b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.make/make_reverse_iterator.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// template <class Iterator> reverse_iterator<Iterator>
+// make_reverse_iterator(Iterator i);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+#if _LIBCPP_STD_VER > 11
+
+template <class It>
+void
+test(It i)
+{
+ const std::reverse_iterator<It> r = std::make_reverse_iterator(i);
+ assert(r.base() == i);
+}
+
+int main()
+{
+ const char* s = "1234567890";
+ random_access_iterator<const char*>b(s);
+ random_access_iterator<const char*>e(s+10);
+ while ( b != e )
+ test ( b++ );
+}
+#else
+int main () {}
+#endif
diff --git a/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op!=/test.pass.cpp b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op!=/test.pass.cpp
new file mode 100644
index 000000000000..29da57e3b5af
--- /dev/null
+++ b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op!=/test.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// template <BidirectionalIterator Iter1, BidirectionalIterator Iter2>
+// requires HasEqualTo<Iter1, Iter2>
+// bool
+// operator!=(const reverse_iterator<Iter1>& x, const reverse_iterator<Iter2>& y);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It l, It r, bool x)
+{
+ const std::reverse_iterator<It> r1(l);
+ const std::reverse_iterator<It> r2(r);
+ assert((r1 != r2) == x);
+}
+
+int main()
+{
+ const char* s = "1234567890";
+ test(bidirectional_iterator<const char*>(s), bidirectional_iterator<const char*>(s), false);
+ test(bidirectional_iterator<const char*>(s), bidirectional_iterator<const char*>(s+1), true);
+ test(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s), false);
+ test(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s+1), true);
+ test(s, s, false);
+ test(s, s+1, true);
+}
diff --git a/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op++/post.pass.cpp b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op++/post.pass.cpp
new file mode 100644
index 000000000000..bd936060c4d4
--- /dev/null
+++ b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op++/post.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// reverse_iterator operator++(int);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It i, It x)
+{
+ std::reverse_iterator<It> r(i);
+ std::reverse_iterator<It> rr = r++;
+ assert(r.base() == x);
+ assert(rr.base() == i);
+}
+
+int main()
+{
+ const char* s = "123";
+ test(bidirectional_iterator<const char*>(s+1), bidirectional_iterator<const char*>(s));
+ test(random_access_iterator<const char*>(s+1), random_access_iterator<const char*>(s));
+ test(s+1, s);
+}
diff --git a/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op++/pre.pass.cpp b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op++/pre.pass.cpp
new file mode 100644
index 000000000000..f68a612fae6b
--- /dev/null
+++ b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op++/pre.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// reverse_iterator& operator++();
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It i, It x)
+{
+ std::reverse_iterator<It> r(i);
+ std::reverse_iterator<It>& rr = ++r;
+ assert(r.base() == x);
+ assert(&rr == &r);
+}
+
+int main()
+{
+ const char* s = "123";
+ test(bidirectional_iterator<const char*>(s+1), bidirectional_iterator<const char*>(s));
+ test(random_access_iterator<const char*>(s+1), random_access_iterator<const char*>(s));
+ test(s+1, s);
+}
diff --git a/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op+/difference_type.pass.cpp b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op+/difference_type.pass.cpp
new file mode 100644
index 000000000000..39129d6b64d8
--- /dev/null
+++ b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op+/difference_type.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// requires RandomAccessIterator<Iter>
+// reverse_iterator operator+(difference_type n) const;
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It i, typename std::iterator_traits<It>::difference_type n, It x)
+{
+ const std::reverse_iterator<It> r(i);
+ std::reverse_iterator<It> rr = r + n;
+ assert(rr.base() == x);
+}
+
+int main()
+{
+ const char* s = "1234567890";
+ test(random_access_iterator<const char*>(s+5), 5, random_access_iterator<const char*>(s));
+ test(s+5, 5, s);
+}
diff --git a/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op+=/difference_type.pass.cpp b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op+=/difference_type.pass.cpp
new file mode 100644
index 000000000000..ac97aaf8c203
--- /dev/null
+++ b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op+=/difference_type.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// requires RandomAccessIterator<Iter>
+// reverse_iterator& operator+=(difference_type n);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It i, typename std::iterator_traits<It>::difference_type n, It x)
+{
+ std::reverse_iterator<It> r(i);
+ std::reverse_iterator<It>& rr = r += n;
+ assert(r.base() == x);
+ assert(&rr == &r);
+}
+
+int main()
+{
+ const char* s = "1234567890";
+ test(random_access_iterator<const char*>(s+5), 5, random_access_iterator<const char*>(s));
+ test(s+5, 5, s);
+}
diff --git a/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op--/post.pass.cpp b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op--/post.pass.cpp
new file mode 100644
index 000000000000..c3126e8c21ff
--- /dev/null
+++ b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op--/post.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// reverse_iterator operator--(int);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It i, It x)
+{
+ std::reverse_iterator<It> r(i);
+ std::reverse_iterator<It> rr = r--;
+ assert(r.base() == x);
+ assert(rr.base() == i);
+}
+
+int main()
+{
+ const char* s = "123";
+ test(bidirectional_iterator<const char*>(s+1), bidirectional_iterator<const char*>(s+2));
+ test(random_access_iterator<const char*>(s+1), random_access_iterator<const char*>(s+2));
+ test(s+1, s+2);
+}
diff --git a/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op--/pre.pass.cpp b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op--/pre.pass.cpp
new file mode 100644
index 000000000000..f9361cf9c72c
--- /dev/null
+++ b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op--/pre.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// reverse_iterator& operator--();
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It i, It x)
+{
+ std::reverse_iterator<It> r(i);
+ std::reverse_iterator<It>& rr = --r;
+ assert(r.base() == x);
+ assert(&rr == &r);
+}
+
+int main()
+{
+ const char* s = "123";
+ test(bidirectional_iterator<const char*>(s+1), bidirectional_iterator<const char*>(s+2));
+ test(random_access_iterator<const char*>(s+1), random_access_iterator<const char*>(s+2));
+ test(s+1, s+2);
+}
diff --git a/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op-/difference_type.pass.cpp b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op-/difference_type.pass.cpp
new file mode 100644
index 000000000000..79d477976fb7
--- /dev/null
+++ b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op-/difference_type.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// requires RandomAccessIterator<Iter>
+// reverse_iterator operator-(difference_type n) const;
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It i, typename std::iterator_traits<It>::difference_type n, It x)
+{
+ const std::reverse_iterator<It> r(i);
+ std::reverse_iterator<It> rr = r - n;
+ assert(rr.base() == x);
+}
+
+int main()
+{
+ const char* s = "1234567890";
+ test(random_access_iterator<const char*>(s+5), 5, random_access_iterator<const char*>(s+10));
+ test(s+5, 5, s+10);
+}
diff --git a/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op-=/difference_type.pass.cpp b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op-=/difference_type.pass.cpp
new file mode 100644
index 000000000000..93addf99dc61
--- /dev/null
+++ b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op-=/difference_type.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// requires RandomAccessIterator<Iter>
+// reverse_iterator& operator-=(difference_type n);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It i, typename std::iterator_traits<It>::difference_type n, It x)
+{
+ std::reverse_iterator<It> r(i);
+ std::reverse_iterator<It>& rr = r -= n;
+ assert(r.base() == x);
+ assert(&rr == &r);
+}
+
+int main()
+{
+ const char* s = "1234567890";
+ test(random_access_iterator<const char*>(s+5), 5, random_access_iterator<const char*>(s+10));
+ test(s+5, 5, s+10);
+}
diff --git a/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op.star/op_star.pass.cpp b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op.star/op_star.pass.cpp
new file mode 100644
index 000000000000..7a7759843eea
--- /dev/null
+++ b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op.star/op_star.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// reference operator*() const;
+
+// Be sure to respect LWG 198:
+// http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#198
+// LWG 198 was superseded by LWG 2360
+// http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2360
+
+#include <iterator>
+#include <cassert>
+
+class A
+{
+ int data_;
+public:
+ A() : data_(1) {}
+ ~A() {data_ = -1;}
+
+ friend bool operator==(const A& x, const A& y)
+ {return x.data_ == y.data_;}
+};
+
+template <class It>
+void
+test(It i, typename std::iterator_traits<It>::value_type x)
+{
+ std::reverse_iterator<It> r(i);
+ assert(*r == x);
+}
+
+int main()
+{
+ A a;
+ test(&a+1, A());
+}
diff --git a/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op=/reverse_iterator.fail.cpp b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op=/reverse_iterator.fail.cpp
new file mode 100644
index 000000000000..18f97801251d
--- /dev/null
+++ b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op=/reverse_iterator.fail.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// template <class U>
+// requires HasAssign<Iter, const U&>
+// reverse_iterator&
+// operator=(const reverse_iterator<U>& u);
+
+// test requires
+
+#include <iterator>
+
+template <class It, class U>
+void
+test(U u)
+{
+ const std::reverse_iterator<U> r2(u);
+ std::reverse_iterator<It> r1;
+ r1 = r2;
+}
+
+struct base {};
+struct derived {};
+
+int main()
+{
+ derived d;
+ test<base*>(&d);
+}
diff --git a/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op=/reverse_iterator.pass.cpp b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op=/reverse_iterator.pass.cpp
new file mode 100644
index 000000000000..92573f9a9242
--- /dev/null
+++ b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op=/reverse_iterator.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// template <class U>
+// requires HasAssign<Iter, const U&>
+// reverse_iterator&
+// operator=(const reverse_iterator<U>& u);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It, class U>
+void
+test(U u)
+{
+ const std::reverse_iterator<U> r2(u);
+ std::reverse_iterator<It> r1;
+ std::reverse_iterator<It>& rr = r1 = r2;
+ assert(r1.base() == u);
+ assert(&rr == &r1);
+}
+
+struct Base {};
+struct Derived : Base {};
+
+int main()
+{
+ Derived d;
+
+ test<bidirectional_iterator<Base*> >(bidirectional_iterator<Derived*>(&d));
+ test<random_access_iterator<const Base*> >(random_access_iterator<Derived*>(&d));
+ test<Base*>(&d);
+}
diff --git a/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op==/test.pass.cpp b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op==/test.pass.cpp
new file mode 100644
index 000000000000..3da4b951df1e
--- /dev/null
+++ b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op==/test.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// template <BidirectionalIterator Iter1, BidirectionalIterator Iter2>
+// requires HasEqualTo<Iter1, Iter2>
+// bool
+// operator==(const reverse_iterator<Iter1>& x, const reverse_iterator<Iter2>& y);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It l, It r, bool x)
+{
+ const std::reverse_iterator<It> r1(l);
+ const std::reverse_iterator<It> r2(r);
+ assert((r1 == r2) == x);
+}
+
+int main()
+{
+ const char* s = "1234567890";
+ test(bidirectional_iterator<const char*>(s), bidirectional_iterator<const char*>(s), true);
+ test(bidirectional_iterator<const char*>(s), bidirectional_iterator<const char*>(s+1), false);
+ test(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s), true);
+ test(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s+1), false);
+ test(s, s, true);
+ test(s, s+1, false);
+}
diff --git a/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opdiff/test.pass.cpp b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opdiff/test.pass.cpp
new file mode 100644
index 000000000000..437bb6f9f7ef
--- /dev/null
+++ b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opdiff/test.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// template <RandomAccessIterator Iter1, RandomAccessIterator Iter2>
+// requires HasMinus<Iter2, Iter1>
+// auto operator-(const reverse_iterator<Iter1>& x, const reverse_iterator<Iter2>& y)
+// -> decltype(y.base() - x.base());
+
+#include <iterator>
+#include <cstddef>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It1, class It2>
+void
+test(It1 l, It2 r, std::ptrdiff_t x)
+{
+ const std::reverse_iterator<It1> r1(l);
+ const std::reverse_iterator<It2> r2(r);
+ assert((r1 - r2) == x);
+}
+
+int main()
+{
+ char s[3] = {0};
+ test(random_access_iterator<const char*>(s), random_access_iterator<char*>(s), 0);
+ test(random_access_iterator<char*>(s), random_access_iterator<const char*>(s+1), 1);
+ test(random_access_iterator<const char*>(s+1), random_access_iterator<char*>(s), -1);
+ test(s, s, 0);
+ test(s, s+1, 1);
+ test(s+1, s, -1);
+}
diff --git a/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opgt/test.pass.cpp b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opgt/test.pass.cpp
new file mode 100644
index 000000000000..afbb334ebfd5
--- /dev/null
+++ b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opgt/test.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// template <RandomAccessIterator Iter1, RandomAccessIterator Iter2>
+// requires HasGreater<Iter1, Iter2>
+// bool
+// operator>(const reverse_iterator<Iter1>& x, const reverse_iterator<Iter2>& y);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It l, It r, bool x)
+{
+ const std::reverse_iterator<It> r1(l);
+ const std::reverse_iterator<It> r2(r);
+ assert((r1 > r2) == x);
+}
+
+int main()
+{
+ const char* s = "1234567890";
+ test(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s), false);
+ test(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s+1), true);
+ test(random_access_iterator<const char*>(s+1), random_access_iterator<const char*>(s), false);
+ test(s, s, false);
+ test(s, s+1, true);
+ test(s+1, s, false);
+}
diff --git a/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opgt=/test.pass.cpp b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opgt=/test.pass.cpp
new file mode 100644
index 000000000000..c6e79aff126f
--- /dev/null
+++ b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opgt=/test.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// template <RandomAccessIterator Iter1, RandomAccessIterator Iter2>
+// requires HasGreater<Iter1, Iter2>
+// bool
+// operator>=(const reverse_iterator<Iter1>& x, const reverse_iterator<Iter2>& y);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It l, It r, bool x)
+{
+ const std::reverse_iterator<It> r1(l);
+ const std::reverse_iterator<It> r2(r);
+ assert((r1 >= r2) == x);
+}
+
+int main()
+{
+ const char* s = "1234567890";
+ test(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s), true);
+ test(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s+1), true);
+ test(random_access_iterator<const char*>(s+1), random_access_iterator<const char*>(s), false);
+ test(s, s, true);
+ test(s, s+1, true);
+ test(s+1, s, false);
+}
diff --git a/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opindex/difference_type.pass.cpp b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opindex/difference_type.pass.cpp
new file mode 100644
index 000000000000..16f4a072855a
--- /dev/null
+++ b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opindex/difference_type.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// requires RandomAccessIterator<Iter>
+// unspecified operator[](difference_type n) const;
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It i, typename std::iterator_traits<It>::difference_type n,
+ typename std::iterator_traits<It>::value_type x)
+{
+ typedef typename std::iterator_traits<It>::value_type value_type;
+ const std::reverse_iterator<It> r(i);
+ value_type rr = r[n];
+ assert(rr == x);
+}
+
+int main()
+{
+ const char* s = "1234567890";
+ test(random_access_iterator<const char*>(s+5), 4, '1');
+ test(s+5, 4, '1');
+}
diff --git a/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.oplt/test.pass.cpp b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.oplt/test.pass.cpp
new file mode 100644
index 000000000000..2b389b853a5a
--- /dev/null
+++ b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.oplt/test.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// template <RandomAccessIterator Iter1, RandomAccessIterator Iter2>
+// requires HasGreater<Iter1, Iter2>
+// bool
+// operator<(const reverse_iterator<Iter1>& x, const reverse_iterator<Iter2>& y);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It l, It r, bool x)
+{
+ const std::reverse_iterator<It> r1(l);
+ const std::reverse_iterator<It> r2(r);
+ assert((r1 < r2) == x);
+}
+
+int main()
+{
+ const char* s = "1234567890";
+ test(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s), false);
+ test(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s+1), false);
+ test(random_access_iterator<const char*>(s+1), random_access_iterator<const char*>(s), true);
+ test(s, s, false);
+ test(s, s+1, false);
+ test(s+1, s, true);
+}
diff --git a/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.oplt=/test.pass.cpp b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.oplt=/test.pass.cpp
new file mode 100644
index 000000000000..6c4f05cdf656
--- /dev/null
+++ b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.oplt=/test.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// template <RandomAccessIterator Iter1, RandomAccessIterator Iter2>
+// requires HasGreater<Iter1, Iter2>
+// bool
+// operator<=(const reverse_iterator<Iter1>& x, const reverse_iterator<Iter2>& y);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It l, It r, bool x)
+{
+ const std::reverse_iterator<It> r1(l);
+ const std::reverse_iterator<It> r2(r);
+ assert((r1 <= r2) == x);
+}
+
+int main()
+{
+ const char* s = "1234567890";
+ test(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s), true);
+ test(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s+1), false);
+ test(random_access_iterator<const char*>(s+1), random_access_iterator<const char*>(s), true);
+ test(s, s, true);
+ test(s, s+1, false);
+ test(s+1, s, true);
+}
diff --git a/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opref/op_arrow.pass.cpp b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opref/op_arrow.pass.cpp
new file mode 100644
index 000000000000..efbdf1406c96
--- /dev/null
+++ b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opref/op_arrow.pass.cpp
@@ -0,0 +1,89 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// pointer operator->() const;
+
+// Be sure to respect LWG 198:
+// http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#198
+// LWG 198 was superseded by LWG 2360
+// http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2360
+
+
+#include <iterator>
+#include <list>
+#include <cassert>
+
+class A
+{
+ int data_;
+public:
+ A() : data_(1) {}
+ ~A() {data_ = -1;}
+
+ int get() const {return data_;}
+
+ friend bool operator==(const A& x, const A& y)
+ {return x.data_ == y.data_;}
+};
+
+template <class It>
+void
+test(It i, typename std::iterator_traits<It>::value_type x)
+{
+ std::reverse_iterator<It> r(i);
+ assert(r->get() == x.get());
+}
+
+class B
+{
+ int data_;
+public:
+ B(int d=1) : data_(d) {}
+ ~B() {data_ = -1;}
+
+ int get() const {return data_;}
+
+ friend bool operator==(const B& x, const B& y)
+ {return x.data_ == y.data_;}
+ const B *operator&() const { return nullptr; }
+ B *operator&() { return nullptr; }
+};
+
+int main()
+{
+ A a;
+ test(&a+1, A());
+
+ {
+ std::list<B> l;
+ l.push_back(B(0));
+ l.push_back(B(1));
+ l.push_back(B(2));
+
+ {
+ std::list<B>::const_iterator i = l.begin();
+ assert ( i->get() == 0 ); ++i;
+ assert ( i->get() == 1 ); ++i;
+ assert ( i->get() == 2 ); ++i;
+ assert ( i == l.end ());
+ }
+
+ {
+ std::list<B>::const_reverse_iterator ri = l.rbegin();
+ assert ( ri->get() == 2 ); ++ri;
+ assert ( ri->get() == 1 ); ++ri;
+ assert ( ri->get() == 0 ); ++ri;
+ assert ( ri == l.rend ());
+ }
+ }
+}
diff --git a/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opsum/difference_type.pass.cpp b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opsum/difference_type.pass.cpp
new file mode 100644
index 000000000000..74747cb1f0f7
--- /dev/null
+++ b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opsum/difference_type.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// template <RandomAccessIterator Iterator>
+// reverse_iterator<Iter>
+// operator+(Iter::difference_type n, const reverse_iterator<Iter>& x);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It i, typename std::iterator_traits<It>::difference_type n, It x)
+{
+ const std::reverse_iterator<It> r(i);
+ std::reverse_iterator<It> rr = n + r;
+ assert(rr.base() == x);
+}
+
+int main()
+{
+ const char* s = "1234567890";
+ test(random_access_iterator<const char*>(s+5), 5, random_access_iterator<const char*>(s));
+ test(s+5, 5, s);
+}
diff --git a/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.requirements/nothing_to_do.pass.cpp b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.requirements/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.requirements/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/iterators/predef.iterators/reverse.iterators/reverse.iterator/types.pass.cpp b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iterator/types.pass.cpp
new file mode 100644
index 000000000000..292a777876fb
--- /dev/null
+++ b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iterator/types.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// Test nested types and data member:
+
+// template <BidirectionalIterator Iter>
+// class reverse_iterator {
+// protected:
+// Iter current;
+// public:
+// iterator<typename iterator_traits<Iterator>::iterator_category,
+// typename iterator_traits<Iterator>::value_type,
+// typename iterator_traits<Iterator>::difference_type,
+// typename iterator_traits<Iterator>::pointer,
+// typename iterator_traits<Iterator>::reference> {
+// };
+
+#include <iterator>
+#include <type_traits>
+
+#include "test_iterators.h"
+
+template <class It>
+struct find_current
+ : private std::reverse_iterator<It>
+{
+ void test() {++(this->current);}
+};
+
+template <class It>
+void
+test()
+{
+ typedef std::reverse_iterator<It> R;
+ typedef std::iterator_traits<It> T;
+ find_current<It> q;
+ q.test();
+ static_assert((std::is_same<typename R::iterator_type, It>::value), "");
+ static_assert((std::is_same<typename R::value_type, typename T::value_type>::value), "");
+ static_assert((std::is_same<typename R::difference_type, typename T::difference_type>::value), "");
+ static_assert((std::is_same<typename R::reference, typename T::reference>::value), "");
+ static_assert((std::is_same<typename R::pointer, typename std::iterator_traits<It>::pointer>::value), "");
+ static_assert((std::is_same<typename R::iterator_category, typename T::iterator_category>::value), "");
+}
+
+int main()
+{
+ test<bidirectional_iterator<char*> >();
+ test<random_access_iterator<char*> >();
+ test<char*>();
+}
diff --git a/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/copy.pass.cpp b/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/copy.pass.cpp
new file mode 100644
index 000000000000..0d70c7fc9ed3
--- /dev/null
+++ b/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/copy.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// class istream_iterator
+
+// istream_iterator(const istream_iterator& x);
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::istream_iterator<int> io;
+ std::istream_iterator<int> i = io;
+ assert(i == std::istream_iterator<int>());
+ }
+ {
+ std::istringstream inf(" 1 23");
+ std::istream_iterator<int> io(inf);
+ std::istream_iterator<int> i = io;
+ assert(i != std::istream_iterator<int>());
+ int j = 0;
+ j = *i;
+ assert(j == 1);
+ }
+}
diff --git a/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/default.fail.cpp b/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/default.fail.cpp
new file mode 100644
index 000000000000..5e6cc5455998
--- /dev/null
+++ b/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/default.fail.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// class istream_iterator
+
+// constexpr istream_iterator();
+
+#include <iterator>
+#include <cassert>
+
+struct S { S(); }; // not constexpr
+
+int main()
+{
+#if __cplusplus >= 201103L
+ {
+ constexpr std::istream_iterator<S> it;
+ }
+#else
+#error "C++11 only test"
+#endif
+}
diff --git a/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/default.pass.cpp b/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/default.pass.cpp
new file mode 100644
index 000000000000..bea07ec2272e
--- /dev/null
+++ b/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/default.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// class istream_iterator
+
+// constexpr istream_iterator();
+
+#include <iterator>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::istream_iterator<int> T;
+ T it;
+ assert(it == T());
+#if __cplusplus >= 201103L
+ constexpr T it2;
+#endif
+ }
+
+}
diff --git a/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/istream.pass.cpp b/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/istream.pass.cpp
new file mode 100644
index 000000000000..12a6f90e8896
--- /dev/null
+++ b/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/istream.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// class istream_iterator
+
+// istream_iterator(istream_type& s);
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ std::istringstream inf(" 1 23");
+ std::istream_iterator<int> i(inf);
+ assert(i != std::istream_iterator<int>());
+ assert(inf.peek() == ' ');
+ assert(inf.good());
+ int j = 0;
+ inf >> j;
+ assert(j == 23);
+}
diff --git a/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.ops/arrow.pass.cpp b/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.ops/arrow.pass.cpp
new file mode 100644
index 000000000000..5c4ddcad32ea
--- /dev/null
+++ b/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.ops/arrow.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// class istream_iterator
+
+// const T* operator->() const;
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+struct A
+{
+ double d_;
+ int i_;
+};
+
+std::istream& operator>>(std::istream& is, A& a)
+{
+ return is >> a.d_ >> a.i_;
+}
+
+int main()
+{
+ std::istringstream inf("1.5 23 ");
+ std::istream_iterator<A> i(inf);
+ assert(i->d_ == 1.5);
+ assert(i->i_ == 23);
+}
diff --git a/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.ops/dereference.pass.cpp b/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.ops/dereference.pass.cpp
new file mode 100644
index 000000000000..e6f86d483369
--- /dev/null
+++ b/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.ops/dereference.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// class istream_iterator
+
+// const T& operator*() const;
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ std::istringstream inf(" 1 23");
+ std::istream_iterator<int> i(inf);
+ int j = 0;
+ j = *i;
+ assert(j == 1);
+ j = *i;
+ assert(j == 1);
+ ++i;
+ j = *i;
+ assert(j == 23);
+ j = *i;
+ assert(j == 23);
+}
diff --git a/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.ops/equal.pass.cpp b/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.ops/equal.pass.cpp
new file mode 100644
index 000000000000..0bee916d50c9
--- /dev/null
+++ b/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.ops/equal.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// class istream_iterator
+
+// template <class T, class charT, class traits, class Distance>
+// bool operator==(const istream_iterator<T,charT,traits,Distance> &x,
+// const istream_iterator<T,charT,traits,Distance> &y);
+//
+// template <class T, class charT, class traits, class Distance>
+// bool operator!=(const istream_iterator<T,charT,traits,Distance> &x,
+// const istream_iterator<T,charT,traits,Distance> &y);
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ std::istringstream inf1(" 1 23");
+ std::istringstream inf2(" 1 23");
+ std::istream_iterator<int> i1(inf1);
+ std::istream_iterator<int> i2(inf1);
+ std::istream_iterator<int> i3(inf2);
+ std::istream_iterator<int> i4;
+ std::istream_iterator<int> i5;
+ assert(i1 == i1);
+ assert(i1 == i2);
+ assert(i1 != i3);
+ assert(i1 != i4);
+ assert(i1 != i5);
+
+ assert(i2 == i2);
+ assert(i2 != i3);
+ assert(i2 != i4);
+ assert(i2 != i5);
+
+ assert(i3 == i3);
+ assert(i3 != i4);
+ assert(i3 != i5);
+
+ assert(i4 == i4);
+ assert(i4 == i5);
+}
diff --git a/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.ops/post_increment.pass.cpp b/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.ops/post_increment.pass.cpp
new file mode 100644
index 000000000000..f5c49e379184
--- /dev/null
+++ b/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.ops/post_increment.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// class istream_iterator
+
+// istream_iterator operator++(int);
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ std::istringstream inf(" 1 23");
+ std::istream_iterator<int> i(inf);
+ std::istream_iterator<int> icopy = i++;
+ assert(icopy == i);
+ int j = 0;
+ j = *i;
+ assert(j == 23);
+ j = 0;
+ j = *icopy;
+ assert(j == 1);
+}
diff --git a/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.ops/pre_increment.pass.cpp b/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.ops/pre_increment.pass.cpp
new file mode 100644
index 000000000000..87173f7dc182
--- /dev/null
+++ b/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.ops/pre_increment.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// class istream_iterator
+
+// istream_iterator& operator++();
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ std::istringstream inf(" 1 23");
+ std::istream_iterator<int> i(inf);
+ std::istream_iterator<int>& iref = ++i;
+ assert(&iref == &i);
+ int j = 0;
+ j = *i;
+ assert(j == 23);
+}
diff --git a/test/std/iterators/stream.iterators/istream.iterator/types.pass.cpp b/test/std/iterators/stream.iterators/istream.iterator/types.pass.cpp
new file mode 100644
index 000000000000..85a70a017976
--- /dev/null
+++ b/test/std/iterators/stream.iterators/istream.iterator/types.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template <class T, class charT = char, class traits = char_traits<charT>,
+// class Distance = ptrdiff_t>
+// class istream_iterator
+// : public iterator<input_iterator_tag, T, Distance, const T*, const T&>
+// {
+// public:
+// typedef charT char_type;
+// typedef traits traits_type;
+// typedef basic_istream<charT,traits> istream_type;
+// ...
+//
+// If T is a literal type, then the default constructor shall be a constexpr constructor.
+// If T is a literal type, then this constructor shall be a trivial copy constructor.
+// If T is a literal type, then this destructor shall be a trivial destructor.
+
+#include <iterator>
+#include <type_traits>
+#include <string>
+
+int main()
+{
+ typedef std::istream_iterator<double> I1;
+ static_assert((std::is_convertible<I1,
+ std::iterator<std::input_iterator_tag, double, std::ptrdiff_t,
+ const double*, const double&> >::value), "");
+ static_assert((std::is_same<I1::char_type, char>::value), "");
+ static_assert((std::is_same<I1::traits_type, std::char_traits<char> >::value), "");
+ static_assert((std::is_same<I1::istream_type, std::istream>::value), "");
+ static_assert( std::is_trivially_copy_constructible<I1>::value, "");
+ static_assert( std::is_trivially_destructible<I1>::value, "");
+
+ typedef std::istream_iterator<unsigned, wchar_t> I2;
+ static_assert((std::is_convertible<I2,
+ std::iterator<std::input_iterator_tag, unsigned, std::ptrdiff_t,
+ const unsigned*, const unsigned&> >::value), "");
+ static_assert((std::is_same<I2::char_type, wchar_t>::value), "");
+ static_assert((std::is_same<I2::traits_type, std::char_traits<wchar_t> >::value), "");
+ static_assert((std::is_same<I2::istream_type, std::wistream>::value), "");
+ static_assert( std::is_trivially_copy_constructible<I2>::value, "");
+ static_assert( std::is_trivially_destructible<I2>::value, "");
+
+ typedef std::istream_iterator<std::string> I3;
+ static_assert(!std::is_trivially_copy_constructible<I3>::value, "");
+ static_assert(!std::is_trivially_destructible<I3>::value, "");
+}
diff --git a/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator.cons/default.pass.cpp b/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator.cons/default.pass.cpp
new file mode 100644
index 000000000000..46ac390d931f
--- /dev/null
+++ b/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator.cons/default.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// istreambuf_iterator
+//
+// istreambuf_iterator() throw();
+//
+// All specializations of istreambuf_iterator shall have a trivial copy constructor,
+// a constexpr default constructor and a trivial destructor.
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::istreambuf_iterator<char> T;
+ T it;
+ assert(it == T());
+#if __cplusplus >= 201103L
+ constexpr T it2;
+#endif
+ }
+ {
+ typedef std::istreambuf_iterator<wchar_t> T;
+ T it;
+ assert(it == T());
+#if __cplusplus >= 201103L
+ constexpr T it2;
+#endif
+ }
+}
diff --git a/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator.cons/istream.pass.cpp b/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator.cons/istream.pass.cpp
new file mode 100644
index 000000000000..69e98265e2fe
--- /dev/null
+++ b/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator.cons/istream.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// istreambuf_iterator
+
+// istreambuf_iterator(basic_istream<charT,traits>& s) throw();
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::istringstream inf;
+ std::istreambuf_iterator<char> i(inf);
+ assert(i == std::istreambuf_iterator<char>());
+ }
+ {
+ std::istringstream inf("a");
+ std::istreambuf_iterator<char> i(inf);
+ assert(i != std::istreambuf_iterator<char>());
+ }
+ {
+ std::wistringstream inf;
+ std::istreambuf_iterator<wchar_t> i(inf);
+ assert(i == std::istreambuf_iterator<wchar_t>());
+ }
+ {
+ std::wistringstream inf(L"a");
+ std::istreambuf_iterator<wchar_t> i(inf);
+ assert(i != std::istreambuf_iterator<wchar_t>());
+ }
+}
diff --git a/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator.cons/proxy.pass.cpp b/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator.cons/proxy.pass.cpp
new file mode 100644
index 000000000000..f5a5fa0c643c
--- /dev/null
+++ b/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator.cons/proxy.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// istreambuf_iterator
+
+// istreambuf_iterator(const proxy& p) throw();
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::istringstream inf("abc");
+ std::istreambuf_iterator<char> j(inf);
+ std::istreambuf_iterator<char> i = j++;
+ assert(i != std::istreambuf_iterator<char>());
+ assert(*i == 'b');
+ }
+ {
+ std::wistringstream inf(L"abc");
+ std::istreambuf_iterator<wchar_t> j(inf);
+ std::istreambuf_iterator<wchar_t> i = j++;
+ assert(i != std::istreambuf_iterator<wchar_t>());
+ assert(*i == L'b');
+ }
+}
diff --git a/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator.cons/streambuf.pass.cpp b/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator.cons/streambuf.pass.cpp
new file mode 100644
index 000000000000..020b4f24bce5
--- /dev/null
+++ b/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator.cons/streambuf.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// istreambuf_iterator
+
+// istreambuf_iterator(basic_streambuf<charT,traits>* s) throw();
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::istreambuf_iterator<char> i(nullptr);
+ assert(i == std::istreambuf_iterator<char>());
+ }
+ {
+ std::istringstream inf;
+ std::istreambuf_iterator<char> i(inf.rdbuf());
+ assert(i == std::istreambuf_iterator<char>());
+ }
+ {
+ std::istringstream inf("a");
+ std::istreambuf_iterator<char> i(inf.rdbuf());
+ assert(i != std::istreambuf_iterator<char>());
+ }
+ {
+ std::istreambuf_iterator<wchar_t> i(nullptr);
+ assert(i == std::istreambuf_iterator<wchar_t>());
+ }
+ {
+ std::wistringstream inf;
+ std::istreambuf_iterator<wchar_t> i(inf.rdbuf());
+ assert(i == std::istreambuf_iterator<wchar_t>());
+ }
+ {
+ std::wistringstream inf(L"a");
+ std::istreambuf_iterator<wchar_t> i(inf.rdbuf());
+ assert(i != std::istreambuf_iterator<wchar_t>());
+ }
+}
diff --git a/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_equal/equal.pass.cpp b/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_equal/equal.pass.cpp
new file mode 100644
index 000000000000..2005d303fb3b
--- /dev/null
+++ b/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_equal/equal.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// istreambuf_iterator
+
+// bool equal(istreambuf_iterator<charT,traits>& b) const;
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::istringstream inf1("abc");
+ std::istringstream inf2("def");
+ std::istreambuf_iterator<char> i1(inf1);
+ std::istreambuf_iterator<char> i2(inf2);
+ std::istreambuf_iterator<char> i3;
+ std::istreambuf_iterator<char> i4;
+
+ assert( i1.equal(i1));
+ assert( i1.equal(i2));
+ assert(!i1.equal(i3));
+ assert(!i1.equal(i4));
+
+ assert( i2.equal(i1));
+ assert( i2.equal(i2));
+ assert(!i2.equal(i3));
+ assert(!i2.equal(i4));
+
+ assert(!i3.equal(i1));
+ assert(!i3.equal(i2));
+ assert( i3.equal(i3));
+ assert( i3.equal(i4));
+
+ assert(!i4.equal(i1));
+ assert(!i4.equal(i2));
+ assert( i4.equal(i3));
+ assert( i4.equal(i4));
+ }
+ {
+ std::wistringstream inf1(L"abc");
+ std::wistringstream inf2(L"def");
+ std::istreambuf_iterator<wchar_t> i1(inf1);
+ std::istreambuf_iterator<wchar_t> i2(inf2);
+ std::istreambuf_iterator<wchar_t> i3;
+ std::istreambuf_iterator<wchar_t> i4;
+
+ assert( i1.equal(i1));
+ assert( i1.equal(i2));
+ assert(!i1.equal(i3));
+ assert(!i1.equal(i4));
+
+ assert( i2.equal(i1));
+ assert( i2.equal(i2));
+ assert(!i2.equal(i3));
+ assert(!i2.equal(i4));
+
+ assert(!i3.equal(i1));
+ assert(!i3.equal(i2));
+ assert( i3.equal(i3));
+ assert( i3.equal(i4));
+
+ assert(!i4.equal(i1));
+ assert(!i4.equal(i2));
+ assert( i4.equal(i3));
+ assert( i4.equal(i4));
+ }
+}
diff --git a/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op!=/not_equal.pass.cpp b/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op!=/not_equal.pass.cpp
new file mode 100644
index 000000000000..5e8536423d8b
--- /dev/null
+++ b/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op!=/not_equal.pass.cpp
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// istreambuf_iterator
+
+// template <class charT, class traits>
+// bool operator!=(const istreambuf_iterator<charT,traits>& a,
+// const istreambuf_iterator<charT,traits>& b);
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::istringstream inf1("abc");
+ std::istringstream inf2("def");
+ std::istreambuf_iterator<char> i1(inf1);
+ std::istreambuf_iterator<char> i2(inf2);
+ std::istreambuf_iterator<char> i3;
+ std::istreambuf_iterator<char> i4;
+
+ assert(!(i1 != i1));
+ assert(!(i1 != i2));
+ assert( (i1 != i3));
+ assert( (i1 != i4));
+
+ assert(!(i2 != i1));
+ assert(!(i2 != i2));
+ assert( (i2 != i3));
+ assert( (i2 != i4));
+
+ assert( (i3 != i1));
+ assert( (i3 != i2));
+ assert(!(i3 != i3));
+ assert(!(i3 != i4));
+
+ assert( (i4 != i1));
+ assert( (i4 != i2));
+ assert(!(i4 != i3));
+ assert(!(i4 != i4));
+ }
+ {
+ std::wistringstream inf1(L"abc");
+ std::wistringstream inf2(L"def");
+ std::istreambuf_iterator<wchar_t> i1(inf1);
+ std::istreambuf_iterator<wchar_t> i2(inf2);
+ std::istreambuf_iterator<wchar_t> i3;
+ std::istreambuf_iterator<wchar_t> i4;
+
+ assert(!(i1 != i1));
+ assert(!(i1 != i2));
+ assert( (i1 != i3));
+ assert( (i1 != i4));
+
+ assert(!(i2 != i1));
+ assert(!(i2 != i2));
+ assert( (i2 != i3));
+ assert( (i2 != i4));
+
+ assert( (i3 != i1));
+ assert( (i3 != i2));
+ assert(!(i3 != i3));
+ assert(!(i3 != i4));
+
+ assert( (i4 != i1));
+ assert( (i4 != i2));
+ assert(!(i4 != i3));
+ assert(!(i4 != i4));
+ }
+}
diff --git a/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op++/dereference.pass.cpp b/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op++/dereference.pass.cpp
new file mode 100644
index 000000000000..19fb02fc46c6
--- /dev/null
+++ b/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op++/dereference.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// istreambuf_iterator
+
+// charT operator*() const
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::istringstream inf("abc");
+ std::istreambuf_iterator<char> i(inf);
+ assert(*i == 'a');
+ ++i;
+ assert(*i == 'b');
+ ++i;
+ assert(*i == 'c');
+ }
+ {
+ std::wistringstream inf(L"abc");
+ std::istreambuf_iterator<wchar_t> i(inf);
+ assert(*i == L'a');
+ ++i;
+ assert(*i == L'b');
+ ++i;
+ assert(*i == L'c');
+ }
+}
diff --git a/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op==/equal.pass.cpp b/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op==/equal.pass.cpp
new file mode 100644
index 000000000000..919576920ef5
--- /dev/null
+++ b/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op==/equal.pass.cpp
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// istreambuf_iterator
+
+// template <class charT, class traits>
+// bool operator==(const istreambuf_iterator<charT,traits>& a,
+// const istreambuf_iterator<charT,traits>& b);
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::istringstream inf1("abc");
+ std::istringstream inf2("def");
+ std::istreambuf_iterator<char> i1(inf1);
+ std::istreambuf_iterator<char> i2(inf2);
+ std::istreambuf_iterator<char> i3;
+ std::istreambuf_iterator<char> i4;
+
+ assert( (i1 == i1));
+ assert( (i1 == i2));
+ assert(!(i1 == i3));
+ assert(!(i1 == i4));
+
+ assert( (i2 == i1));
+ assert( (i2 == i2));
+ assert(!(i2 == i3));
+ assert(!(i2 == i4));
+
+ assert(!(i3 == i1));
+ assert(!(i3 == i2));
+ assert( (i3 == i3));
+ assert( (i3 == i4));
+
+ assert(!(i4 == i1));
+ assert(!(i4 == i2));
+ assert( (i4 == i3));
+ assert( (i4 == i4));
+ }
+ {
+ std::wistringstream inf1(L"abc");
+ std::wistringstream inf2(L"def");
+ std::istreambuf_iterator<wchar_t> i1(inf1);
+ std::istreambuf_iterator<wchar_t> i2(inf2);
+ std::istreambuf_iterator<wchar_t> i3;
+ std::istreambuf_iterator<wchar_t> i4;
+
+ assert( (i1 == i1));
+ assert( (i1 == i2));
+ assert(!(i1 == i3));
+ assert(!(i1 == i4));
+
+ assert( (i2 == i1));
+ assert( (i2 == i2));
+ assert(!(i2 == i3));
+ assert(!(i2 == i4));
+
+ assert(!(i3 == i1));
+ assert(!(i3 == i2));
+ assert( (i3 == i3));
+ assert( (i3 == i4));
+
+ assert(!(i4 == i1));
+ assert(!(i4 == i2));
+ assert( (i4 == i3));
+ assert( (i4 == i4));
+ }
+}
diff --git a/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op_astrk/arrow.pass.cpp b/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op_astrk/arrow.pass.cpp
new file mode 100644
index 000000000000..e3bf5e2bd84f
--- /dev/null
+++ b/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op_astrk/arrow.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// istreambuf_iterator
+
+// pointer operator->() const;
+
+#include <iostream>
+#include <sstream>
+#include <streambuf>
+
+typedef char C;
+int main ()
+{
+ std::istringstream s("filename");
+ std::istreambuf_iterator<char> i(s);
+
+ (*i).~C(); // This is well-formed...
+ i->~C(); // ... so this should be supported!
+}
diff --git a/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op_astrk/post_increment.pass.cpp b/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op_astrk/post_increment.pass.cpp
new file mode 100644
index 000000000000..2e4f52ce71bc
--- /dev/null
+++ b/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op_astrk/post_increment.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// istreambuf_iterator
+
+// proxy istreambuf_iterator<charT,traits>::operator++(int);
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::istringstream inf("abc");
+ std::istreambuf_iterator<char> i(inf);
+ assert(*i++ == 'a');
+ assert(*i++ == 'b');
+ assert(*i++ == 'c');
+ assert(i == std::istreambuf_iterator<char>());
+ }
+ {
+ std::wistringstream inf(L"abc");
+ std::istreambuf_iterator<wchar_t> i(inf);
+ assert(*i++ == L'a');
+ assert(*i++ == L'b');
+ assert(*i++ == L'c');
+ assert(i == std::istreambuf_iterator<wchar_t>());
+ }
+}
diff --git a/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op_astrk/pre_increment.pass.cpp b/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op_astrk/pre_increment.pass.cpp
new file mode 100644
index 000000000000..cb7960a0e4ec
--- /dev/null
+++ b/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op_astrk/pre_increment.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// istreambuf_iterator
+
+// istreambuf_iterator<charT,traits>&
+// istreambuf_iterator<charT,traits>::operator++();
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::istringstream inf("abc");
+ std::istreambuf_iterator<char> i(inf);
+ assert(*i == 'a');
+ assert(*++i == 'b');
+ assert(*++i == 'c');
+ assert(++i == std::istreambuf_iterator<char>());
+ }
+ {
+ std::wistringstream inf(L"abc");
+ std::istreambuf_iterator<wchar_t> i(inf);
+ assert(*i == L'a');
+ assert(*++i == L'b');
+ assert(*++i == L'c');
+ assert(++i == std::istreambuf_iterator<wchar_t>());
+ }
+}
diff --git a/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_proxy/proxy.pass.cpp b/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_proxy/proxy.pass.cpp
new file mode 100644
index 000000000000..acaf2f569b1f
--- /dev/null
+++ b/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_proxy/proxy.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template<class charT, class traits = char_traits<charT> >
+// class istreambuf_iterator
+// : public iterator<input_iterator_tag, charT,
+// typename traits::off_type, charT*,
+// charT>
+// {
+// public:
+// ...
+// proxy operator++(int);
+
+// class proxy
+// {
+// public:
+// charT operator*();
+// };
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::istringstream inf("abc");
+ std::istreambuf_iterator<char> i(inf);
+ assert(*i++ == 'a');
+ }
+ {
+ std::wistringstream inf(L"abc");
+ std::istreambuf_iterator<wchar_t> i(inf);
+ assert(*i++ == L'a');
+ }
+}
diff --git a/test/std/iterators/stream.iterators/istreambuf.iterator/types.pass.cpp b/test/std/iterators/stream.iterators/istreambuf.iterator/types.pass.cpp
new file mode 100644
index 000000000000..2ad927cf952c
--- /dev/null
+++ b/test/std/iterators/stream.iterators/istreambuf.iterator/types.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template<class charT, class traits = char_traits<charT> >
+// class istreambuf_iterator
+// : public iterator<input_iterator_tag, charT,
+// typename traits::off_type, unspecified,
+// charT>
+// {
+// public:
+// typedef charT char_type;
+// typedef traits traits_type;
+// typedef typename traits::int_type int_type;
+// typedef basic_streambuf<charT,traits> streambuf_type;
+// typedef basic_istream<charT,traits> istream_type;
+// ...
+//
+// All specializations of istreambuf_iterator shall have a trivial copy constructor,
+// a constexpr default constructor and a trivial destructor.
+
+#include <iterator>
+#include <string>
+#include <type_traits>
+
+int main()
+{
+ typedef std::istreambuf_iterator<char> I1;
+ static_assert((std::is_convertible<I1,
+ std::iterator<std::input_iterator_tag, char, std::char_traits<char>::off_type,
+ char*, char> >::value), "");
+ static_assert((std::is_same<I1::char_type, char>::value), "");
+ static_assert((std::is_same<I1::traits_type, std::char_traits<char> >::value), "");
+ static_assert((std::is_same<I1::int_type, I1::traits_type::int_type>::value), "");
+ static_assert((std::is_same<I1::streambuf_type, std::streambuf>::value), "");
+ static_assert((std::is_same<I1::istream_type, std::istream>::value), "");
+ static_assert((std::is_nothrow_default_constructible<I1>::value), "" );
+ static_assert((std::is_trivially_copy_constructible<I1>::value), "" );
+ static_assert((std::is_trivially_destructible<I1>::value), "" );
+
+ typedef std::istreambuf_iterator<wchar_t> I2;
+ static_assert((std::is_convertible<I2,
+ std::iterator<std::input_iterator_tag, wchar_t, std::char_traits<wchar_t>::off_type,
+ wchar_t*, wchar_t> >::value), "");
+ static_assert((std::is_same<I2::char_type, wchar_t>::value), "");
+ static_assert((std::is_same<I2::traits_type, std::char_traits<wchar_t> >::value), "");
+ static_assert((std::is_same<I2::int_type, I2::traits_type::int_type>::value), "");
+ static_assert((std::is_same<I2::streambuf_type, std::wstreambuf>::value), "");
+ static_assert((std::is_same<I2::istream_type, std::wistream>::value), "");
+ static_assert((std::is_nothrow_default_constructible<I2>::value), "" );
+ static_assert((std::is_trivially_copy_constructible<I2>::value), "" );
+ static_assert((std::is_trivially_destructible<I2>::value), "" );
+}
diff --git a/test/std/iterators/stream.iterators/iterator.range/begin_array.pass.cpp b/test/std/iterators/stream.iterators/iterator.range/begin_array.pass.cpp
new file mode 100644
index 000000000000..42c8c3dd93da
--- /dev/null
+++ b/test/std/iterators/stream.iterators/iterator.range/begin_array.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template <class T, size_t N> T* begin(T (&array)[N]);
+
+#include <iterator>
+#include <cassert>
+
+int main()
+{
+ int ia[] = {1, 2, 3};
+ int* i = std::begin(ia);
+ assert(*i == 1);
+ *i = 2;
+ assert(ia[0] == 2);
+}
diff --git a/test/std/iterators/stream.iterators/iterator.range/begin_const.pass.cpp b/test/std/iterators/stream.iterators/iterator.range/begin_const.pass.cpp
new file mode 100644
index 000000000000..7dca8b071e10
--- /dev/null
+++ b/test/std/iterators/stream.iterators/iterator.range/begin_const.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template <class C> auto begin(const C& c) -> decltype(c.begin());
+
+#include <vector>
+#include <cassert>
+
+int main()
+{
+ int ia[] = {1, 2, 3};
+ const std::vector<int> v(ia, ia + sizeof(ia)/sizeof(ia[0]));
+ std::vector<int>::const_iterator i = begin(v);
+ assert(*i == 1);
+}
diff --git a/test/std/iterators/stream.iterators/iterator.range/begin_non_const.pass.cpp b/test/std/iterators/stream.iterators/iterator.range/begin_non_const.pass.cpp
new file mode 100644
index 000000000000..de4c8b0f2471
--- /dev/null
+++ b/test/std/iterators/stream.iterators/iterator.range/begin_non_const.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template <class C> auto begin(C& c) -> decltype(c.begin());
+
+#include <vector>
+#include <cassert>
+
+int main()
+{
+ int ia[] = {1, 2, 3};
+ std::vector<int> v(ia, ia + sizeof(ia)/sizeof(ia[0]));
+ std::vector<int>::iterator i = begin(v);
+ assert(*i == 1);
+ *i = 2;
+ assert(*i == 2);
+}
diff --git a/test/std/iterators/stream.iterators/iterator.range/end_array.pass.cpp b/test/std/iterators/stream.iterators/iterator.range/end_array.pass.cpp
new file mode 100644
index 000000000000..628e5e901e6d
--- /dev/null
+++ b/test/std/iterators/stream.iterators/iterator.range/end_array.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template <class T, size_t N> T* end(T (&array)[N]);
+
+#include <iterator>
+#include <cassert>
+
+int main()
+{
+ int ia[] = {1, 2, 3};
+ int* i = std::begin(ia);
+ int* e = std::end(ia);
+ assert(e == ia + 3);
+ assert(e - i == 3);
+}
diff --git a/test/std/iterators/stream.iterators/iterator.range/end_const.pass.cpp b/test/std/iterators/stream.iterators/iterator.range/end_const.pass.cpp
new file mode 100644
index 000000000000..7fa26171f109
--- /dev/null
+++ b/test/std/iterators/stream.iterators/iterator.range/end_const.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template <class C> auto end(const C& c) -> decltype(c.end());
+
+#include <vector>
+#include <cassert>
+
+int main()
+{
+ int ia[] = {1, 2, 3};
+ const std::vector<int> v(ia, ia + sizeof(ia)/sizeof(ia[0]));
+ std::vector<int>::const_iterator i = end(v);
+ assert(i == v.cend());
+}
diff --git a/test/std/iterators/stream.iterators/iterator.range/end_non_const.pass.cpp b/test/std/iterators/stream.iterators/iterator.range/end_non_const.pass.cpp
new file mode 100644
index 000000000000..8c75433638fc
--- /dev/null
+++ b/test/std/iterators/stream.iterators/iterator.range/end_non_const.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template <class C> auto end(C& c) -> decltype(c.end());
+
+#include <vector>
+#include <cassert>
+
+int main()
+{
+ int ia[] = {1, 2, 3};
+ std::vector<int> v(ia, ia + sizeof(ia)/sizeof(ia[0]));
+ std::vector<int>::iterator i = end(v);
+ assert(i == v.end());
+}
diff --git a/test/std/iterators/stream.iterators/nothing_to_do.pass.cpp b/test/std/iterators/stream.iterators/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/iterators/stream.iterators/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.cons.des/copy.pass.cpp b/test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.cons.des/copy.pass.cpp
new file mode 100644
index 000000000000..88624581df9a
--- /dev/null
+++ b/test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.cons.des/copy.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// class ostream_iterator
+
+// ostream_iterator(const ostream_iterator& x);
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ std::ostringstream outf;
+ std::ostream_iterator<int> i(outf);
+ std::ostream_iterator<int> j = i;
+ assert(outf.good());
+}
diff --git a/test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.cons.des/ostream.pass.cpp b/test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.cons.des/ostream.pass.cpp
new file mode 100644
index 000000000000..321cfbdb82c8
--- /dev/null
+++ b/test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.cons.des/ostream.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// class ostream_iterator
+
+// ostream_iterator(ostream_type& s);
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ std::ostringstream outf;
+ std::ostream_iterator<int> i(outf);
+ assert(outf.good());
+}
diff --git a/test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.cons.des/ostream_delem.pass.cpp b/test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.cons.des/ostream_delem.pass.cpp
new file mode 100644
index 000000000000..8e5c771a4ab4
--- /dev/null
+++ b/test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.cons.des/ostream_delem.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// class ostream_iterator
+
+// ostream_iterator(ostream_type& s, const charT* delimiter);
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::ostringstream outf;
+ std::ostream_iterator<int> i(outf, ", ");
+ assert(outf.good());
+ }
+ {
+ std::wostringstream outf;
+ std::ostream_iterator<double, wchar_t> i(outf, L", ");
+ assert(outf.good());
+ }
+}
diff --git a/test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.ops/assign_t.pass.cpp b/test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.ops/assign_t.pass.cpp
new file mode 100644
index 000000000000..02ef571a06f9
--- /dev/null
+++ b/test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.ops/assign_t.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// class ostream_iterator
+
+// ostream_iterator& operator=(const T& value);
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::ostringstream outf;
+ std::ostream_iterator<int> i(outf);
+ i = 2.4;
+ assert(outf.str() == "2");
+ }
+ {
+ std::ostringstream outf;
+ std::ostream_iterator<int> i(outf, ", ");
+ i = 2.4;
+ assert(outf.str() == "2, ");
+ }
+ {
+ std::wostringstream outf;
+ std::ostream_iterator<int, wchar_t> i(outf);
+ i = 2.4;
+ assert(outf.str() == L"2");
+ }
+ {
+ std::wostringstream outf;
+ std::ostream_iterator<int, wchar_t> i(outf, L", ");
+ i = 2.4;
+ assert(outf.str() == L"2, ");
+ }
+}
diff --git a/test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.ops/dereference.pass.cpp b/test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.ops/dereference.pass.cpp
new file mode 100644
index 000000000000..322107528f4b
--- /dev/null
+++ b/test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.ops/dereference.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// class ostream_iterator
+
+// ostream_iterator& operator*() const;
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ std::ostringstream os;
+ std::ostream_iterator<int> i(os);
+ std::ostream_iterator<int>& iref = *i;
+ assert(&iref == &i);
+}
diff --git a/test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.ops/increment.pass.cpp b/test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.ops/increment.pass.cpp
new file mode 100644
index 000000000000..00b63e8da9b5
--- /dev/null
+++ b/test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.ops/increment.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// class ostream_iterator
+
+// ostream_iterator& operator++();
+// ostream_iterator& operator++(int);
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ std::ostringstream os;
+ std::ostream_iterator<int> i(os);
+ std::ostream_iterator<int>& iref1 = ++i;
+ assert(&iref1 == &i);
+ std::ostream_iterator<int>& iref2 = i++;
+ assert(&iref2 == &i);
+}
diff --git a/test/std/iterators/stream.iterators/ostream.iterator/types.pass.cpp b/test/std/iterators/stream.iterators/ostream.iterator/types.pass.cpp
new file mode 100644
index 000000000000..460da642bc6e
--- /dev/null
+++ b/test/std/iterators/stream.iterators/ostream.iterator/types.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template <class T, class charT = char, class traits = char_traits<charT>,
+// class Distance = ptrdiff_t>
+// class ostream_iterator
+// : public iterator<output_iterator_tag, void, void, void, void>
+// {
+// public:
+// typedef charT char_type;
+// typedef traits traits_type;
+// typedef basic_istream<charT,traits> istream_type;
+// ...
+
+#include <iterator>
+#include <type_traits>
+
+int main()
+{
+ typedef std::ostream_iterator<double> I1;
+ static_assert((std::is_convertible<I1,
+ std::iterator<std::output_iterator_tag, void, void, void, void> >::value), "");
+ static_assert((std::is_same<I1::char_type, char>::value), "");
+ static_assert((std::is_same<I1::traits_type, std::char_traits<char> >::value), "");
+ static_assert((std::is_same<I1::ostream_type, std::ostream>::value), "");
+ typedef std::ostream_iterator<unsigned, wchar_t> I2;
+ static_assert((std::is_convertible<I2,
+ std::iterator<std::output_iterator_tag, void, void, void, void> >::value), "");
+ static_assert((std::is_same<I2::char_type, wchar_t>::value), "");
+ static_assert((std::is_same<I2::traits_type, std::char_traits<wchar_t> >::value), "");
+ static_assert((std::is_same<I2::ostream_type, std::wostream>::value), "");
+}
diff --git a/test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.cons/ostream.pass.cpp b/test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.cons/ostream.pass.cpp
new file mode 100644
index 000000000000..c46cf4822292
--- /dev/null
+++ b/test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.cons/ostream.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// class ostreambuf_iterator
+
+// ostreambuf_iterator(ostream_type& s) throw();
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::ostringstream outf;
+ std::ostreambuf_iterator<char> i(outf);
+ assert(!i.failed());
+ }
+ {
+ std::wostringstream outf;
+ std::ostreambuf_iterator<wchar_t> i(outf);
+ assert(!i.failed());
+ }
+}
diff --git a/test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.cons/streambuf.pass.cpp b/test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.cons/streambuf.pass.cpp
new file mode 100644
index 000000000000..1576b7d481a9
--- /dev/null
+++ b/test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.cons/streambuf.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// class ostreambuf_iterator
+
+// ostreambuf_iterator(streambuf_type* s) throw();
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::ostringstream outf;
+ std::ostreambuf_iterator<char> i(outf.rdbuf());
+ assert(!i.failed());
+ }
+ {
+ std::wostringstream outf;
+ std::ostreambuf_iterator<wchar_t> i(outf.rdbuf());
+ assert(!i.failed());
+ }
+}
diff --git a/test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/assign_c.pass.cpp b/test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/assign_c.pass.cpp
new file mode 100644
index 000000000000..91d7b6927912
--- /dev/null
+++ b/test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/assign_c.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// class ostreambuf_iterator
+
+// ostreambuf_iterator<charT,traits>&
+// operator=(charT c);
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::ostringstream outf;
+ std::ostreambuf_iterator<char> i(outf);
+ i = 'a';
+ assert(outf.str() == "a");
+ i = 'b';
+ assert(outf.str() == "ab");
+ }
+ {
+ std::wostringstream outf;
+ std::ostreambuf_iterator<wchar_t> i(outf);
+ i = L'a';
+ assert(outf.str() == L"a");
+ i = L'b';
+ assert(outf.str() == L"ab");
+ }
+}
diff --git a/test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/deref.pass.cpp b/test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/deref.pass.cpp
new file mode 100644
index 000000000000..d08616410251
--- /dev/null
+++ b/test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/deref.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// class ostreambuf_iterator
+
+// ostreambuf_iterator<charT,traits>& operator*();
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::ostringstream outf;
+ std::ostreambuf_iterator<char> i(outf);
+ std::ostreambuf_iterator<char>& iref = *i;
+ assert(&iref == &i);
+ }
+ {
+ std::wostringstream outf;
+ std::ostreambuf_iterator<wchar_t> i(outf);
+ std::ostreambuf_iterator<wchar_t>& iref = *i;
+ assert(&iref == &i);
+ }
+}
diff --git a/test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/failed.pass.cpp b/test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/failed.pass.cpp
new file mode 100644
index 000000000000..9d93bad370d0
--- /dev/null
+++ b/test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/failed.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// class ostreambuf_iterator
+
+// bool failed() const throw();
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::ostreambuf_iterator<char> i(nullptr);
+ assert(i.failed());
+ }
+ {
+ std::ostreambuf_iterator<wchar_t> i(nullptr);
+ assert(i.failed());
+ }
+}
diff --git a/test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/increment.pass.cpp b/test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/increment.pass.cpp
new file mode 100644
index 000000000000..7461ce16347d
--- /dev/null
+++ b/test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/increment.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// class ostreambuf_iterator
+
+// ostreambuf_iterator<charT,traits>& operator++();
+// ostreambuf_iterator<charT,traits>& operator++(int);
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::ostringstream outf;
+ std::ostreambuf_iterator<char> i(outf);
+ std::ostreambuf_iterator<char>& iref = ++i;
+ assert(&iref == &i);
+ std::ostreambuf_iterator<char>& iref2 = i++;
+ assert(&iref2 == &i);
+ }
+ {
+ std::wostringstream outf;
+ std::ostreambuf_iterator<wchar_t> i(outf);
+ std::ostreambuf_iterator<wchar_t>& iref = ++i;
+ assert(&iref == &i);
+ std::ostreambuf_iterator<wchar_t>& iref2 = i++;
+ assert(&iref2 == &i);
+ }
+}
diff --git a/test/std/iterators/stream.iterators/ostreambuf.iterator/types.pass.cpp b/test/std/iterators/stream.iterators/ostreambuf.iterator/types.pass.cpp
new file mode 100644
index 000000000000..a699b2419830
--- /dev/null
+++ b/test/std/iterators/stream.iterators/ostreambuf.iterator/types.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template <class charT, class traits = char_traits<charT> >
+// class ostreambuf_iterator
+// : public iterator<output_iterator_tag, void, void, void, void>
+// {
+// public:
+// typedef charT char_type;
+// typedef traits traits_type;
+// typedef basic_streambuf<charT, traits> streambuf_type;
+// typedef basic_ostream<charT, traits> ostream_type;
+// ...
+
+#include <iterator>
+#include <string>
+#include <type_traits>
+
+int main()
+{
+ typedef std::ostreambuf_iterator<char> I1;
+ static_assert((std::is_convertible<I1,
+ std::iterator<std::output_iterator_tag, void, void, void, void> >::value), "");
+ static_assert((std::is_same<I1::char_type, char>::value), "");
+ static_assert((std::is_same<I1::traits_type, std::char_traits<char> >::value), "");
+ static_assert((std::is_same<I1::streambuf_type, std::streambuf>::value), "");
+ static_assert((std::is_same<I1::ostream_type, std::ostream>::value), "");
+
+ typedef std::ostreambuf_iterator<wchar_t> I2;
+ static_assert((std::is_convertible<I2,
+ std::iterator<std::output_iterator_tag, void, void, void, void> >::value), "");
+ static_assert((std::is_same<I2::char_type, wchar_t>::value), "");
+ static_assert((std::is_same<I2::traits_type, std::char_traits<wchar_t> >::value), "");
+ static_assert((std::is_same<I2::streambuf_type, std::wstreambuf>::value), "");
+ static_assert((std::is_same<I2::ostream_type, std::wostream>::value), "");
+}
diff --git a/test/std/iterators/version.pass.cpp b/test/std/iterators/version.pass.cpp
new file mode 100644
index 000000000000..dd097850388e
--- /dev/null
+++ b/test/std/iterators/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+#include <iterator>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/language.support/cstdint/cstdint.syn/cstdint.pass.cpp b/test/std/language.support/cstdint/cstdint.syn/cstdint.pass.cpp
new file mode 100644
index 000000000000..23cf8b66bcb1
--- /dev/null
+++ b/test/std/language.support/cstdint/cstdint.syn/cstdint.pass.cpp
@@ -0,0 +1,292 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test <cstdint>
+
+#include <cstdint>
+#include <cstddef>
+#include <cwchar>
+#include <csignal>
+#include <cwctype>
+#include <climits>
+#include <type_traits>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ // typedef std::int8_t
+ static_assert(sizeof(std::int8_t)*CHAR_BIT == 8,
+ "sizeof(std::int8_t)*CHAR_BIT == 8");
+ static_assert(std::is_signed<std::int8_t>::value,
+ "std::is_signed<std::int8_t>::value");
+ // typedef std::int16_t
+ static_assert(sizeof(std::int16_t)*CHAR_BIT == 16,
+ "sizeof(std::int16_t)*CHAR_BIT == 16");
+ static_assert(std::is_signed<std::int16_t>::value,
+ "std::is_signed<std::int16_t>::value");
+ // typedef std::int32_t
+ static_assert(sizeof(std::int32_t)*CHAR_BIT == 32,
+ "sizeof(std::int32_t)*CHAR_BIT == 32");
+ static_assert(std::is_signed<std::int32_t>::value,
+ "std::is_signed<std::int32_t>::value");
+ // typedef std::int64_t
+ static_assert(sizeof(std::int64_t)*CHAR_BIT == 64,
+ "sizeof(std::int64_t)*CHAR_BIT == 64");
+ static_assert(std::is_signed<std::int64_t>::value,
+ "std::is_signed<std::int64_t>::value");
+
+ // typedef std::uint8_t
+ static_assert(sizeof(std::uint8_t)*CHAR_BIT == 8,
+ "sizeof(std::uint8_t)*CHAR_BIT == 8");
+ static_assert(std::is_unsigned<std::uint8_t>::value,
+ "std::is_unsigned<std::uint8_t>::value");
+ // typedef std::uint16_t
+ static_assert(sizeof(std::uint16_t)*CHAR_BIT == 16,
+ "sizeof(std::uint16_t)*CHAR_BIT == 16");
+ static_assert(std::is_unsigned<std::uint16_t>::value,
+ "std::is_unsigned<std::uint16_t>::value");
+ // typedef std::uint32_t
+ static_assert(sizeof(std::uint32_t)*CHAR_BIT == 32,
+ "sizeof(std::uint32_t)*CHAR_BIT == 32");
+ static_assert(std::is_unsigned<std::uint32_t>::value,
+ "std::is_unsigned<std::uint32_t>::value");
+ // typedef std::uint64_t
+ static_assert(sizeof(std::uint64_t)*CHAR_BIT == 64,
+ "sizeof(std::uint64_t)*CHAR_BIT == 64");
+ static_assert(std::is_unsigned<std::uint64_t>::value,
+ "std::is_unsigned<std::uint64_t>::value");
+
+ // typedef std::int_least8_t
+ static_assert(sizeof(std::int_least8_t)*CHAR_BIT >= 8,
+ "sizeof(std::int_least8_t)*CHAR_BIT >= 8");
+ static_assert(std::is_signed<std::int_least8_t>::value,
+ "std::is_signed<std::int_least8_t>::value");
+ // typedef std::int_least16_t
+ static_assert(sizeof(std::int_least16_t)*CHAR_BIT >= 16,
+ "sizeof(std::int_least16_t)*CHAR_BIT >= 16");
+ static_assert(std::is_signed<std::int_least16_t>::value,
+ "std::is_signed<std::int_least16_t>::value");
+ // typedef std::int_least32_t
+ static_assert(sizeof(std::int_least32_t)*CHAR_BIT >= 32,
+ "sizeof(std::int_least32_t)*CHAR_BIT >= 32");
+ static_assert(std::is_signed<std::int_least32_t>::value,
+ "std::is_signed<std::int_least32_t>::value");
+ // typedef std::int_least64_t
+ static_assert(sizeof(std::int_least64_t)*CHAR_BIT >= 64,
+ "sizeof(std::int_least64_t)*CHAR_BIT >= 64");
+ static_assert(std::is_signed<std::int_least64_t>::value,
+ "std::is_signed<std::int_least64_t>::value");
+
+ // typedef std::uint_least8_t
+ static_assert(sizeof(std::uint_least8_t)*CHAR_BIT >= 8,
+ "sizeof(std::uint_least8_t)*CHAR_BIT >= 8");
+ static_assert(std::is_unsigned<std::uint_least8_t>::value,
+ "std::is_unsigned<std::uint_least8_t>::value");
+ // typedef std::uint_least16_t
+ static_assert(sizeof(std::uint_least16_t)*CHAR_BIT >= 16,
+ "sizeof(std::uint_least16_t)*CHAR_BIT >= 16");
+ static_assert(std::is_unsigned<std::uint_least16_t>::value,
+ "std::is_unsigned<std::uint_least16_t>::value");
+ // typedef std::uint_least32_t
+ static_assert(sizeof(std::uint_least32_t)*CHAR_BIT >= 32,
+ "sizeof(std::uint_least32_t)*CHAR_BIT >= 32");
+ static_assert(std::is_unsigned<std::uint_least32_t>::value,
+ "std::is_unsigned<std::uint_least32_t>::value");
+ // typedef std::uint_least64_t
+ static_assert(sizeof(std::uint_least64_t)*CHAR_BIT >= 64,
+ "sizeof(std::uint_least64_t)*CHAR_BIT >= 64");
+ static_assert(std::is_unsigned<std::uint_least64_t>::value,
+ "std::is_unsigned<std::uint_least64_t>::value");
+
+ // typedef std::int_fast8_t
+ static_assert(sizeof(std::int_fast8_t)*CHAR_BIT >= 8,
+ "sizeof(std::int_fast8_t)*CHAR_BIT >= 8");
+ static_assert(std::is_signed<std::int_fast8_t>::value,
+ "std::is_signed<std::int_fast8_t>::value");
+ // typedef std::int_fast16_t
+ static_assert(sizeof(std::int_fast16_t)*CHAR_BIT >= 16,
+ "sizeof(std::int_fast16_t)*CHAR_BIT >= 16");
+ static_assert(std::is_signed<std::int_fast16_t>::value,
+ "std::is_signed<std::int_fast16_t>::value");
+ // typedef std::int_fast32_t
+ static_assert(sizeof(std::int_fast32_t)*CHAR_BIT >= 32,
+ "sizeof(std::int_fast32_t)*CHAR_BIT >= 32");
+ static_assert(std::is_signed<std::int_fast32_t>::value,
+ "std::is_signed<std::int_fast32_t>::value");
+ // typedef std::int_fast64_t
+ static_assert(sizeof(std::int_fast64_t)*CHAR_BIT >= 64,
+ "sizeof(std::int_fast64_t)*CHAR_BIT >= 64");
+ static_assert(std::is_signed<std::int_fast64_t>::value,
+ "std::is_signed<std::int_fast64_t>::value");
+
+ // typedef std::uint_fast8_t
+ static_assert(sizeof(std::uint_fast8_t)*CHAR_BIT >= 8,
+ "sizeof(std::uint_fast8_t)*CHAR_BIT >= 8");
+ static_assert(std::is_unsigned<std::uint_fast8_t>::value,
+ "std::is_unsigned<std::uint_fast8_t>::value");
+ // typedef std::uint_fast16_t
+ static_assert(sizeof(std::uint_fast16_t)*CHAR_BIT >= 16,
+ "sizeof(std::uint_fast16_t)*CHAR_BIT >= 16");
+ static_assert(std::is_unsigned<std::uint_fast16_t>::value,
+ "std::is_unsigned<std::uint_fast16_t>::value");
+ // typedef std::uint_fast32_t
+ static_assert(sizeof(std::uint_fast32_t)*CHAR_BIT >= 32,
+ "sizeof(std::uint_fast32_t)*CHAR_BIT >= 32");
+ static_assert(std::is_unsigned<std::uint_fast32_t>::value,
+ "std::is_unsigned<std::uint_fast32_t>::value");
+ // typedef std::uint_fast64_t
+ static_assert(sizeof(std::uint_fast64_t)*CHAR_BIT >= 64,
+ "sizeof(std::uint_fast64_t)*CHAR_BIT >= 64");
+ static_assert(std::is_unsigned<std::uint_fast64_t>::value,
+ "std::is_unsigned<std::uint_fast64_t>::value");
+
+ // typedef std::intptr_t
+ static_assert(sizeof(std::intptr_t) >= sizeof(void*),
+ "sizeof(std::intptr_t) >= sizeof(void*)");
+ static_assert(std::is_signed<std::intptr_t>::value,
+ "std::is_signed<std::intptr_t>::value");
+ // typedef std::uintptr_t
+ static_assert(sizeof(std::uintptr_t) >= sizeof(void*),
+ "sizeof(std::uintptr_t) >= sizeof(void*)");
+ static_assert(std::is_unsigned<std::uintptr_t>::value,
+ "std::is_unsigned<std::uintptr_t>::value");
+
+ // typedef std::intmax_t
+ static_assert(sizeof(std::intmax_t) >= sizeof(long long),
+ "sizeof(std::intmax_t) >= sizeof(long long)");
+ static_assert(std::is_signed<std::intmax_t>::value,
+ "std::is_signed<std::intmax_t>::value");
+ // typedef std::uintmax_t
+ static_assert(sizeof(std::uintmax_t) >= sizeof(unsigned long long),
+ "sizeof(std::uintmax_t) >= sizeof(unsigned long long)");
+ static_assert(std::is_unsigned<std::uintmax_t>::value,
+ "std::is_unsigned<std::uintmax_t>::value");
+
+ // INTN_MIN
+ static_assert(INT8_MIN == -128, "INT8_MIN == -128");
+ static_assert(INT16_MIN == -32768, "INT16_MIN == -32768");
+ static_assert(INT32_MIN == -2147483648U, "INT32_MIN == -2147483648");
+ static_assert(INT64_MIN == -9223372036854775808ULL, "INT64_MIN == -9223372036854775808LL");
+
+ // INTN_MAX
+ static_assert(INT8_MAX == 127, "INT8_MAX == 127");
+ static_assert(INT16_MAX == 32767, "INT16_MAX == 32767");
+ static_assert(INT32_MAX == 2147483647, "INT32_MAX == 2147483647");
+ static_assert(INT64_MAX == 9223372036854775807LL, "INT64_MAX == 9223372036854775807LL");
+
+ // UINTN_MAX
+ static_assert(UINT8_MAX == 255, "UINT8_MAX == 255");
+ static_assert(UINT16_MAX == 65535, "UINT16_MAX == 65535");
+ static_assert(UINT32_MAX == 4294967295U, "UINT32_MAX == 4294967295");
+ static_assert(UINT64_MAX == 18446744073709551615ULL, "UINT64_MAX == 18446744073709551615ULL");
+
+ // INT_FASTN_MIN
+ static_assert(INT_FAST8_MIN <= -128, "INT_FAST8_MIN <= -128");
+ static_assert(INT_FAST16_MIN <= -32768, "INT_FAST16_MIN <= -32768");
+ static_assert(INT_FAST32_MIN <= -2147483648U, "INT_FAST32_MIN <= -2147483648");
+ static_assert(INT_FAST64_MIN <= -9223372036854775808ULL, "INT_FAST64_MIN <= -9223372036854775808LL");
+
+ // INT_FASTN_MAX
+ static_assert(INT_FAST8_MAX >= 127, "INT_FAST8_MAX >= 127");
+ static_assert(INT_FAST16_MAX >= 32767, "INT_FAST16_MAX >= 32767");
+ static_assert(INT_FAST32_MAX >= 2147483647, "INT_FAST32_MAX >= 2147483647");
+ static_assert(INT_FAST64_MAX >= 9223372036854775807LL, "INT_FAST64_MAX >= 9223372036854775807LL");
+
+ // UINT_FASTN_MAX
+ static_assert(UINT_FAST8_MAX >= 255, "UINT_FAST8_MAX >= 255");
+ static_assert(UINT_FAST16_MAX >= 65535, "UINT_FAST16_MAX >= 65535");
+ static_assert(UINT_FAST32_MAX >= 4294967295U, "UINT_FAST32_MAX >= 4294967295");
+ static_assert(UINT_FAST64_MAX >= 18446744073709551615ULL, "UINT_FAST64_MAX >= 18446744073709551615ULL");
+
+ // INTPTR_MIN
+ assert(INTPTR_MIN == std::numeric_limits<std::intptr_t>::min());
+
+ // INTPTR_MAX
+ assert(INTPTR_MAX == std::numeric_limits<std::intptr_t>::max());
+
+ // UINTPTR_MAX
+ assert(UINTPTR_MAX == std::numeric_limits<std::uintptr_t>::max());
+
+ // INTMAX_MIN
+ assert(INTMAX_MIN == std::numeric_limits<std::intmax_t>::min());
+
+ // INTMAX_MAX
+ assert(INTMAX_MAX == std::numeric_limits<std::intmax_t>::max());
+
+ // UINTMAX_MAX
+ assert(UINTMAX_MAX == std::numeric_limits<std::uintmax_t>::max());
+
+ // PTRDIFF_MIN
+ assert(PTRDIFF_MIN == std::numeric_limits<std::ptrdiff_t>::min());
+
+ // PTRDIFF_MAX
+ assert(PTRDIFF_MAX == std::numeric_limits<std::ptrdiff_t>::max());
+
+ // SIG_ATOMIC_MIN
+ assert(SIG_ATOMIC_MIN == std::numeric_limits<std::sig_atomic_t>::min());
+
+ // SIG_ATOMIC_MAX
+ assert(SIG_ATOMIC_MAX == std::numeric_limits<std::sig_atomic_t>::max());
+
+ // SIZE_MAX
+ assert(SIZE_MAX == std::numeric_limits<std::size_t>::max());
+
+ // WCHAR_MIN
+ assert(WCHAR_MIN == std::numeric_limits<wchar_t>::min());
+
+ // WCHAR_MAX
+ assert(WCHAR_MAX == std::numeric_limits<wchar_t>::max());
+
+ // WINT_MIN
+ assert(WINT_MIN == std::numeric_limits<std::wint_t>::min());
+
+ // WINT_MAX
+ assert(WINT_MAX == std::numeric_limits<std::wint_t>::max());
+
+#ifndef INT8_C
+#error INT8_C not defined
+#endif
+
+#ifndef INT16_C
+#error INT16_C not defined
+#endif
+
+#ifndef INT32_C
+#error INT32_C not defined
+#endif
+
+#ifndef INT64_C
+#error INT64_C not defined
+#endif
+
+#ifndef UINT8_C
+#error UINT8_C not defined
+#endif
+
+#ifndef UINT16_C
+#error UINT16_C not defined
+#endif
+
+#ifndef UINT32_C
+#error UINT32_C not defined
+#endif
+
+#ifndef UINT64_C
+#error UINT64_C not defined
+#endif
+
+#ifndef INTMAX_C
+#error INTMAX_C not defined
+#endif
+
+#ifndef UINTMAX_C
+#error UINTMAX_C not defined
+#endif
+}
diff --git a/test/std/language.support/cstdint/version.pass.cpp b/test/std/language.support/cstdint/version.pass.cpp
new file mode 100644
index 000000000000..4c9a43a62abc
--- /dev/null
+++ b/test/std/language.support/cstdint/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <cstdint>
+
+#include <cstdint>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/language.support/nothing_to_do.pass.cpp b/test/std/language.support/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/language.support/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/language.support/support.dynamic/alloc.errors/bad.alloc/bad_alloc.pass.cpp b/test/std/language.support/support.dynamic/alloc.errors/bad.alloc/bad_alloc.pass.cpp
new file mode 100644
index 000000000000..cf8d4af93802
--- /dev/null
+++ b/test/std/language.support/support.dynamic/alloc.errors/bad.alloc/bad_alloc.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test bad_alloc
+
+#include <new>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+ static_assert((std::is_base_of<std::exception, std::bad_alloc>::value),
+ "std::is_base_of<std::exception, std::bad_alloc>::value");
+ static_assert(std::is_polymorphic<std::bad_alloc>::value,
+ "std::is_polymorphic<std::bad_alloc>::value");
+ std::bad_alloc b;
+ std::bad_alloc b2 = b;
+ b2 = b;
+ const char* w = b2.what();
+ assert(w);
+}
diff --git a/test/std/language.support/support.dynamic/alloc.errors/new.badlength/bad_array_length.pass.cpp b/test/std/language.support/support.dynamic/alloc.errors/new.badlength/bad_array_length.pass.cpp
new file mode 100644
index 000000000000..7de503304556
--- /dev/null
+++ b/test/std/language.support/support.dynamic/alloc.errors/new.badlength/bad_array_length.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test bad_array_length
+
+#include <new>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+#if __LIBCPP_STD_VER > 11
+ static_assert((std::is_base_of<std::bad_alloc, std::bad_array_length>::value),
+ "std::is_base_of<std::bad_alloc, std::bad_array_length>::value");
+ static_assert(std::is_polymorphic<std::bad_array_length>::value,
+ "std::is_polymorphic<std::bad_array_length>::value");
+ std::bad_array_length b;
+ std::bad_array_length b2 = b;
+ b2 = b;
+ const char* w = b2.what();
+ assert(w);
+#endif
+}
diff --git a/test/std/language.support/support.dynamic/alloc.errors/new.badlength/bad_array_new_length.pass.cpp b/test/std/language.support/support.dynamic/alloc.errors/new.badlength/bad_array_new_length.pass.cpp
new file mode 100644
index 000000000000..50521c0005a5
--- /dev/null
+++ b/test/std/language.support/support.dynamic/alloc.errors/new.badlength/bad_array_new_length.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test bad_array_new_length
+
+#include <new>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+ static_assert((std::is_base_of<std::bad_alloc, std::bad_array_new_length>::value),
+ "std::is_base_of<std::bad_alloc, std::bad_array_new_length>::value");
+ static_assert(std::is_polymorphic<std::bad_array_new_length>::value,
+ "std::is_polymorphic<std::bad_array_new_length>::value");
+ std::bad_array_new_length b;
+ std::bad_array_new_length b2 = b;
+ b2 = b;
+ const char* w = b2.what();
+ assert(w);
+}
diff --git a/test/std/language.support/support.dynamic/alloc.errors/new.handler/new_handler.pass.cpp b/test/std/language.support/support.dynamic/alloc.errors/new.handler/new_handler.pass.cpp
new file mode 100644
index 000000000000..6b799a3e83d8
--- /dev/null
+++ b/test/std/language.support/support.dynamic/alloc.errors/new.handler/new_handler.pass.cpp
@@ -0,0 +1,19 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test new_handler
+
+#include <new>
+
+void f() {}
+
+int main()
+{
+ std::new_handler p = f;
+}
diff --git a/test/std/language.support/support.dynamic/alloc.errors/nothing_to_do.pass.cpp b/test/std/language.support/support.dynamic/alloc.errors/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/language.support/support.dynamic/alloc.errors/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/language.support/support.dynamic/alloc.errors/set.new.handler/get_new_handler.pass.cpp b/test/std/language.support/support.dynamic/alloc.errors/set.new.handler/get_new_handler.pass.cpp
new file mode 100644
index 000000000000..55a3edabfed8
--- /dev/null
+++ b/test/std/language.support/support.dynamic/alloc.errors/set.new.handler/get_new_handler.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test get_new_handler
+
+#include <new>
+#include <cassert>
+
+void f1() {}
+void f2() {}
+
+int main()
+{
+ assert(std::get_new_handler() == 0);
+ std::set_new_handler(f1);
+ assert(std::get_new_handler() == f1);
+ std::set_new_handler(f2);
+ assert(std::get_new_handler() == f2);
+}
diff --git a/test/std/language.support/support.dynamic/alloc.errors/set.new.handler/set_new_handler.pass.cpp b/test/std/language.support/support.dynamic/alloc.errors/set.new.handler/set_new_handler.pass.cpp
new file mode 100644
index 000000000000..349bf440e0dc
--- /dev/null
+++ b/test/std/language.support/support.dynamic/alloc.errors/set.new.handler/set_new_handler.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test set_new_handler
+
+#include <new>
+#include <cassert>
+
+void f1() {}
+void f2() {}
+
+int main()
+{
+ assert(std::set_new_handler(f1) == 0);
+ assert(std::set_new_handler(f2) == f1);
+}
diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array.pass.cpp
new file mode 100644
index 000000000000..5a87c0738784
--- /dev/null
+++ b/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test operator new[]
+// NOTE: asan and msan will not call the new handler.
+// UNSUPPORTED: sanitizer-new-delete
+
+
+#include <new>
+#include <cstddef>
+#include <cassert>
+#include <limits>
+
+int new_handler_called = 0;
+
+void new_handler()
+{
+ ++new_handler_called;
+ std::set_new_handler(0);
+}
+
+int A_constructed = 0;
+
+struct A
+{
+ A() {++A_constructed;}
+ ~A() {--A_constructed;}
+};
+
+int main()
+{
+ std::set_new_handler(new_handler);
+ try
+ {
+ void*volatile vp = operator new[] (std::numeric_limits<std::size_t>::max());
+ assert(false);
+ }
+ catch (std::bad_alloc&)
+ {
+ assert(new_handler_called == 1);
+ }
+ catch (...)
+ {
+ assert(false);
+ }
+ A* ap = new A[3];
+ assert(ap);
+ assert(A_constructed == 3);
+ delete [] ap;
+ assert(A_constructed == 0);
+}
diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow.pass.cpp
new file mode 100644
index 000000000000..b0db4a8e57e2
--- /dev/null
+++ b/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test operator new [] (nothrow)
+// NOTE: asan and msan will not call the new handler.
+// UNSUPPORTED: sanitizer-new-delete
+
+
+#include <new>
+#include <cstddef>
+#include <cassert>
+#include <limits>
+
+int new_handler_called = 0;
+
+void new_handler()
+{
+ ++new_handler_called;
+ std::set_new_handler(0);
+}
+
+int A_constructed = 0;
+
+struct A
+{
+ A() {++A_constructed;}
+ ~A() {--A_constructed;}
+};
+
+int main()
+{
+ std::set_new_handler(new_handler);
+ try
+ {
+ void*volatile vp = operator new [] (std::numeric_limits<std::size_t>::max(), std::nothrow);
+ assert(new_handler_called == 1);
+ assert(vp == 0);
+ }
+ catch (...)
+ {
+ assert(false);
+ }
+ A* ap = new(std::nothrow) A[3];
+ assert(ap);
+ assert(A_constructed == 3);
+ delete [] ap;
+ assert(A_constructed == 0);
+}
diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow_replace.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow_replace.pass.cpp
new file mode 100644
index 000000000000..105c7a93f210
--- /dev/null
+++ b/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow_replace.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test operator new [] nothrow by replacing only operator new
+
+// UNSUPPORTED: sanitizer-new-delete
+
+#include <new>
+#include <cstddef>
+#include <cstdlib>
+#include <cassert>
+#include <limits>
+
+int new_called = 0;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+ ++new_called;
+ return std::malloc(s);
+}
+
+void operator delete(void* p) throw()
+{
+ --new_called;
+ std::free(p);
+}
+
+volatile int A_constructed = 0;
+
+struct A
+{
+ A() {++A_constructed;}
+ ~A() {--A_constructed;}
+};
+
+int main()
+{
+ A* ap = new (std::nothrow) A[3];
+ assert(ap);
+ assert(A_constructed == 3);
+ assert(new_called);
+ delete [] ap;
+ assert(A_constructed == 0);
+ assert(!new_called);
+}
diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_replace.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_replace.pass.cpp
new file mode 100644
index 000000000000..92bd7b952dcb
--- /dev/null
+++ b/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_replace.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test operator new[] replacement by replacing only operator new
+
+// UNSUPPORTED: sanitizer-new-delete
+
+#include <new>
+#include <cstddef>
+#include <cstdlib>
+#include <cassert>
+#include <limits>
+
+volatile int new_called = 0;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+ ++new_called;
+ return std::malloc(s);
+}
+
+void operator delete(void* p) throw()
+{
+ --new_called;
+ std::free(p);
+}
+
+int A_constructed = 0;
+
+struct A
+{
+ A() {++A_constructed;}
+ ~A() {--A_constructed;}
+};
+
+int main()
+{
+ A* ap = new A[3];
+ assert(ap);
+ assert(A_constructed == 3);
+ assert(new_called == 1);
+ delete [] ap;
+ assert(A_constructed == 0);
+ assert(new_called == 0);
+}
diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array11.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array11.pass.cpp
new file mode 100644
index 000000000000..0f7840ca9ef8
--- /dev/null
+++ b/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array11.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test sized operator delete[] replacement.
+
+// Note that sized delete operator definitions below are simply ignored
+// when sized deallocation is not supported, e.g., prior to C++14.
+
+// UNSUPPORTED: c++14, c++1z
+// UNSUPPORTED: sanitizer-new-delete
+
+#include <new>
+#include <cstddef>
+#include <cstdlib>
+#include <cassert>
+
+int unsized_delete_called = 0;
+int unsized_delete_nothrow_called = 0;
+int sized_delete_called = 0;
+
+void operator delete[](void* p) throw()
+{
+ ++unsized_delete_called;
+ std::free(p);
+}
+
+void operator delete[](void* p, const std::nothrow_t&) throw()
+{
+ ++unsized_delete_nothrow_called;
+ std::free(p);
+}
+
+void operator delete[](void* p, std::size_t) throw()
+{
+ ++sized_delete_called;
+ std::free(p);
+}
+
+// NOTE: Use a class with a non-trivial destructor as the test type in order
+// to ensure the correct overload is called.
+// C++14 5.3.5 [expr.delete]p10
+// - If the type is complete and if, for the second alternative (delete array)
+// only, the operand is a pointer to a class type with a non-trivial
+// destructor or a (possibly multi-dimensional) array thereof, the function
+// with two parameters is selected.
+// - Otherwise, it is unspecified which of the two deallocation functions is
+// selected.
+struct A { ~A() {} };
+
+int main()
+{
+
+ A* x = new A[3];
+ assert(0 == unsized_delete_called);
+ assert(0 == unsized_delete_nothrow_called);
+ assert(0 == sized_delete_called);
+
+ delete [] x;
+ assert(1 == unsized_delete_called);
+ assert(0 == sized_delete_called);
+ assert(0 == unsized_delete_nothrow_called);
+}
diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array14.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array14.pass.cpp
new file mode 100644
index 000000000000..6447e29726c1
--- /dev/null
+++ b/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array14.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test sized operator delete[] replacement.
+
+// UNSUPPORTED: sanitizer-new-delete, c++98, c++03, c++11
+
+// TODO: Clang does not enable sized-deallocation in c++14 and behond by
+// default. It is only enabled when -fsized-deallocation is given.
+// (except clang-3.6 which temporarly enabled sized-deallocation)
+// XFAIL: clang-3.4, clang-3.5, clang-3.7
+// XFAIL: apple-clang
+
+// NOTE: GCC 4.9.1 does not support sized-deallocation in c++14. However
+// GCC 5.1 does.
+// XFAIL: gcc-4.7, gcc-4.8, gcc-4.9
+
+#include <new>
+#include <cstddef>
+#include <cstdlib>
+#include <cassert>
+
+int unsized_delete_called = 0;
+int unsized_delete_nothrow_called = 0;
+int sized_delete_called = 0;
+
+void operator delete[](void* p) throw()
+{
+ ++unsized_delete_called;
+ std::free(p);
+}
+
+void operator delete[](void* p, const std::nothrow_t&) throw()
+{
+ ++unsized_delete_nothrow_called;
+ std::free(p);
+}
+
+void operator delete[](void* p, std::size_t) throw()
+{
+ ++sized_delete_called;
+ std::free(p);
+}
+
+// NOTE: Use a class with a non-trivial destructor as the test type in order
+// to ensure the correct overload is called.
+// C++14 5.3.5 [expr.delete]p10
+// - If the type is complete and if, for the second alternative (delete array)
+// only, the operand is a pointer to a class type with a non-trivial
+// destructor or a (possibly multi-dimensional) array thereof, the function
+// with two parameters is selected.
+// - Otherwise, it is unspecified which of the two deallocation functions is
+// selected.
+struct A { ~A() {} };
+
+int main()
+{
+ A* x = new A[3];
+ assert(0 == unsized_delete_called);
+ assert(0 == unsized_delete_nothrow_called);
+ assert(0 == sized_delete_called);
+
+ delete [] x;
+ assert(0 == unsized_delete_called);
+ assert(0 == unsized_delete_nothrow_called);
+ assert(1 == sized_delete_called);
+}
diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array_calls_unsized_delete_array.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array_calls_unsized_delete_array.pass.cpp
new file mode 100644
index 000000000000..6d24aec35ef8
--- /dev/null
+++ b/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array_calls_unsized_delete_array.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test sized operator [] delete calls the unsized operator [] delete.
+// When sized operator delete [] is not available (ex C++11) then the unsized
+// operator delete [] is called directly.
+
+// UNSUPPORTED: sanitizer-new-delete
+
+#include <new>
+#include <cstddef>
+#include <cstdlib>
+#include <cassert>
+
+int delete_called = 0;
+int delete_nothrow_called = 0;
+
+void operator delete[](void* p) throw()
+{
+ ++delete_called;
+ std::free(p);
+}
+
+void operator delete[](void* p, const std::nothrow_t&) throw()
+{
+ ++delete_nothrow_called;
+ std::free(p);
+}
+
+// NOTE: Use a class with a non-trivial destructor as the test type in order
+// to ensure the correct overload is called.
+// C++14 5.3.5 [expr.delete]p10
+// - If the type is complete and if, for the second alternative (delete array)
+// only, the operand is a pointer to a class type with a non-trivial
+// destructor or a (possibly multi-dimensional) array thereof, the function
+// with two parameters is selected.
+// - Otherwise, it is unspecified which of the two deallocation functions is
+// selected.
+struct A { ~A() {} };
+
+int main()
+{
+ A* x = new A[3];
+ assert(0 == delete_called);
+ assert(0 == delete_nothrow_called);
+
+ delete [] x;
+ assert(1 == delete_called);
+ assert(0 == delete_nothrow_called);
+}
diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array_fsizeddeallocation.sh.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array_fsizeddeallocation.sh.cpp
new file mode 100644
index 000000000000..7dd510b4dac8
--- /dev/null
+++ b/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array_fsizeddeallocation.sh.cpp
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test sized operator delete[] replacement.
+
+// Note that sized delete operator definitions below are simply ignored
+// when sized deallocation is not supported, e.g., prior to C++14.
+
+// UNSUPPORTED: sanitizer-new-delete
+
+// NOTE: Only clang-3.7 and GCC 5.1 and greater support -fsized-deallocation.
+// REQUIRES: fsized-deallocation
+
+// RUN: %build -fsized-deallocation
+// RUN: %run
+
+#if !defined(__cpp_sized_deallocation)
+# error __cpp_sized_deallocation should be defined
+#endif
+
+#if !(__cpp_sized_deallocation >= 201309L)
+# error expected __cpp_sized_deallocation >= 201309L
+#endif
+
+#include <new>
+#include <cstddef>
+#include <cstdlib>
+#include <cassert>
+
+int unsized_delete_called = 0;
+int unsized_delete_nothrow_called = 0;
+int sized_delete_called = 0;
+
+void operator delete[](void* p) throw()
+{
+ ++unsized_delete_called;
+ std::free(p);
+}
+
+void operator delete[](void* p, const std::nothrow_t&) throw()
+{
+ ++unsized_delete_nothrow_called;
+ std::free(p);
+}
+
+void operator delete[](void* p, std::size_t) throw()
+{
+ ++sized_delete_called;
+ std::free(p);
+}
+
+// NOTE: Use a class with a non-trivial destructor as the test type in order
+// to ensure the correct overload is called.
+// C++14 5.3.5 [expr.delete]p10
+// - If the type is complete and if, for the second alternative (delete array)
+// only, the operand is a pointer to a class type with a non-trivial
+// destructor or a (possibly multi-dimensional) array thereof, the function
+// with two parameters is selected.
+// - Otherwise, it is unspecified which of the two deallocation functions is
+// selected.
+struct A { ~A() {} };
+
+int main()
+{
+ A* x = new A[3];
+ assert(0 == unsized_delete_called);
+ assert(0 == unsized_delete_nothrow_called);
+ assert(0 == sized_delete_called);
+
+ delete [] x;
+ assert(0 == unsized_delete_called);
+ assert(0 == unsized_delete_nothrow_called);
+ assert(1 == sized_delete_called);
+}
diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.dataraces/not_testable.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.dataraces/not_testable.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/language.support/support.dynamic/new.delete/new.delete.dataraces/not_testable.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.placement/new.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.placement/new.pass.cpp
new file mode 100644
index 000000000000..ad306e06cb78
--- /dev/null
+++ b/test/std/language.support/support.dynamic/new.delete/new.delete.placement/new.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test placement new
+
+#include <new>
+#include <cassert>
+
+int A_constructed = 0;
+
+struct A
+{
+ A() {++A_constructed;}
+ ~A() {--A_constructed;}
+};
+
+int main()
+{
+ char buf[sizeof(A)];
+
+ A* ap = new(buf) A;
+ assert((char*)ap == buf);
+ assert(A_constructed == 1);
+}
diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.placement/new_array.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.placement/new_array.pass.cpp
new file mode 100644
index 000000000000..1ab52ae4c8df
--- /dev/null
+++ b/test/std/language.support/support.dynamic/new.delete/new.delete.placement/new_array.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test placement new array
+
+#include <new>
+#include <cassert>
+
+int A_constructed = 0;
+
+struct A
+{
+ A() {++A_constructed;}
+ ~A() {--A_constructed;}
+};
+
+int main()
+{
+ char buf[3*sizeof(A)];
+
+ A* ap = new(buf) A[3];
+ assert((char*)ap == buf);
+ assert(A_constructed == 3);
+}
diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.single/new.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.single/new.pass.cpp
new file mode 100644
index 000000000000..58aa3f2d529c
--- /dev/null
+++ b/test/std/language.support/support.dynamic/new.delete/new.delete.single/new.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test operator new
+
+// asan and msan will not call the new handler.
+// UNSUPPORTED: sanitizer-new-delete
+
+#include <new>
+#include <cstddef>
+#include <cassert>
+#include <limits>
+
+int new_handler_called = 0;
+
+void new_handler()
+{
+ ++new_handler_called;
+ std::set_new_handler(0);
+}
+
+bool A_constructed = false;
+
+struct A
+{
+ A() {A_constructed = true;}
+ ~A() {A_constructed = false;}
+};
+
+int main()
+{
+ std::set_new_handler(new_handler);
+ try
+ {
+ void* vp = operator new (std::numeric_limits<std::size_t>::max());
+ assert(false);
+ }
+ catch (std::bad_alloc&)
+ {
+ assert(new_handler_called == 1);
+ }
+ catch (...)
+ {
+ assert(false);
+ }
+ A* ap = new A;
+ assert(ap);
+ assert(A_constructed);
+ delete ap;
+ assert(!A_constructed);
+}
diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow.pass.cpp
new file mode 100644
index 000000000000..8c095ad32db4
--- /dev/null
+++ b/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test operator new (nothrow)
+
+// asan and msan will not call the new handler.
+// UNSUPPORTED: sanitizer-new-delete
+
+#include <new>
+#include <cstddef>
+#include <cassert>
+#include <limits>
+
+int new_handler_called = 0;
+
+void new_handler()
+{
+ ++new_handler_called;
+ std::set_new_handler(0);
+}
+
+bool A_constructed = false;
+
+struct A
+{
+ A() {A_constructed = true;}
+ ~A() {A_constructed = false;}
+};
+
+int main()
+{
+ std::set_new_handler(new_handler);
+ try
+ {
+ void* vp = operator new (std::numeric_limits<std::size_t>::max(), std::nothrow);
+ assert(new_handler_called == 1);
+ assert(vp == 0);
+ }
+ catch (...)
+ {
+ assert(false);
+ }
+ A* ap = new(std::nothrow) A;
+ assert(ap);
+ assert(A_constructed);
+ delete ap;
+ assert(!A_constructed);
+}
diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow_replace.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow_replace.pass.cpp
new file mode 100644
index 000000000000..cd70f90948d2
--- /dev/null
+++ b/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow_replace.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test operator new nothrow by replacing only operator new
+
+// UNSUPPORTED: sanitizer-new-delete
+
+#include <new>
+#include <cstddef>
+#include <cstdlib>
+#include <cassert>
+#include <limits>
+
+int new_called = 0;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+ ++new_called;
+ return std::malloc(s);
+}
+
+void operator delete(void* p) throw()
+{
+ --new_called;
+ std::free(p);
+}
+
+bool A_constructed = false;
+
+struct A
+{
+ A() {A_constructed = true;}
+ ~A() {A_constructed = false;}
+};
+
+int main()
+{
+ A* ap = new (std::nothrow) A;
+ assert(ap);
+ assert(A_constructed);
+ assert(new_called);
+ delete ap;
+ assert(!A_constructed);
+ assert(!new_called);
+}
diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_replace.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_replace.pass.cpp
new file mode 100644
index 000000000000..0df3a93703d2
--- /dev/null
+++ b/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_replace.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test operator new replacement
+
+// UNSUPPORTED: sanitizer-new-delete
+
+#include <new>
+#include <cstddef>
+#include <cstdlib>
+#include <cassert>
+#include <limits>
+
+int new_called = 0;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+ ++new_called;
+ return std::malloc(s);
+}
+
+void operator delete(void* p) throw()
+{
+ --new_called;
+ std::free(p);
+}
+
+bool A_constructed = false;
+
+struct A
+{
+ A() {A_constructed = true;}
+ ~A() {A_constructed = false;}
+};
+
+int main()
+{
+ A* ap = new A;
+ assert(ap);
+ assert(A_constructed);
+ assert(new_called);
+ delete ap;
+ assert(!A_constructed);
+ assert(!new_called);
+}
diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete11.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete11.pass.cpp
new file mode 100644
index 000000000000..e4064e2ab510
--- /dev/null
+++ b/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete11.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test sized operator delete replacement.
+
+// Note that sized delete operator definitions below are simply ignored
+// when sized deallocation is not supported, e.g., prior to C++14.
+
+// UNSUPPORTED: c++14, c++1z
+// UNSUPPORTED: sanitizer-new-delete
+
+#include <new>
+#include <cstddef>
+#include <cstdlib>
+#include <cassert>
+
+int unsized_delete_called = 0;
+int unsized_delete_nothrow_called = 0;
+int sized_delete_called = 0;
+
+void operator delete(void* p) throw()
+{
+ ++unsized_delete_called;
+ std::free(p);
+}
+
+void operator delete(void* p, const std::nothrow_t&) throw()
+{
+ ++unsized_delete_nothrow_called;
+ std::free(p);
+}
+
+void operator delete(void* p, std::size_t) throw()
+{
+ ++sized_delete_called;
+ std::free(p);
+}
+
+int main()
+{
+ int *x = new int(42);
+ assert(0 == unsized_delete_called);
+ assert(0 == unsized_delete_nothrow_called);
+ assert(0 == sized_delete_called);
+
+ delete x;
+ assert(1 == unsized_delete_called);
+ assert(0 == sized_delete_called);
+ assert(0 == unsized_delete_nothrow_called);
+}
diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete14.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete14.pass.cpp
new file mode 100644
index 000000000000..3c7f54fef726
--- /dev/null
+++ b/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete14.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test sized operator delete replacement.
+
+// UNSUPPORTED: sanitizer-new-delete, c++98, c++03, c++11
+
+// TODO: Clang does not enable sized-deallocation in c++14 and behond by
+// default. It is only enabled when -fsized-deallocation is given.
+// (except clang-3.6 which temporarly enabled sized-deallocation)
+// XFAIL: clang-3.4, clang-3.5, clang-3.7
+// XFAIL: apple-clang
+
+// NOTE: GCC 4.9.1 does not support sized-deallocation in c++14. However
+// GCC 5.1 does.
+// XFAIL: gcc-4.7, gcc-4.8, gcc-4.9
+
+#include <new>
+#include <cstddef>
+#include <cstdlib>
+#include <cassert>
+
+int unsized_delete_called = 0;
+int unsized_delete_nothrow_called = 0;
+int sized_delete_called = 0;
+
+void operator delete(void* p) throw()
+{
+ ++unsized_delete_called;
+ std::free(p);
+}
+
+void operator delete(void* p, const std::nothrow_t&) throw()
+{
+ ++unsized_delete_nothrow_called;
+ std::free(p);
+}
+
+void operator delete(void* p, std::size_t) throw()
+{
+ ++sized_delete_called;
+ std::free(p);
+}
+
+int main()
+{
+ int *x = new int(42);
+ assert(0 == unsized_delete_called);
+ assert(0 == unsized_delete_nothrow_called);
+ assert(0 == sized_delete_called);
+
+ delete x;
+ assert(0 == unsized_delete_called);
+ assert(1 == sized_delete_called);
+ assert(0 == unsized_delete_nothrow_called);
+}
diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete_calls_unsized_delete.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete_calls_unsized_delete.pass.cpp
new file mode 100644
index 000000000000..5c4eba53d3e4
--- /dev/null
+++ b/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete_calls_unsized_delete.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test sized operator delete calls the unsized operator delete.
+// When sized operator delete is not available (ex C++11) then the unsized
+// operator delete is called directly.
+
+// UNSUPPORTED: sanitizer-new-delete
+
+#include <new>
+#include <cstddef>
+#include <cstdlib>
+#include <cassert>
+
+int delete_called = 0;
+int delete_nothrow_called = 0;
+
+void operator delete(void* p) throw()
+{
+ ++delete_called;
+ std::free(p);
+}
+
+void operator delete(void* p, const std::nothrow_t&) throw()
+{
+ ++delete_nothrow_called;
+ std::free(p);
+}
+
+int main()
+{
+ int *x = new int(42);
+ assert(0 == delete_called);
+ assert(0 == delete_nothrow_called);
+
+ delete x;
+ assert(1 == delete_called);
+ assert(0 == delete_nothrow_called);
+}
diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete_fsizeddeallocation.sh.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete_fsizeddeallocation.sh.cpp
new file mode 100644
index 000000000000..da43d4969174
--- /dev/null
+++ b/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete_fsizeddeallocation.sh.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test sized operator delete replacement.
+
+// Note that sized delete operator definitions below are simply ignored
+// when sized deallocation is not supported, e.g., prior to C++14.
+
+// UNSUPPORTED: sanitizer-new-delete
+
+// NOTE: Only clang-3.7 and GCC 5.1 and greater support -fsized-deallocation.
+// REQUIRES: fsized-deallocation
+
+// RUN: %build -fsized-deallocation
+// RUN: %run
+
+#if !defined(__cpp_sized_deallocation)
+# error __cpp_sized_deallocation should be defined
+#endif
+
+#if !(__cpp_sized_deallocation >= 201309L)
+# error expected __cpp_sized_deallocation >= 201309L
+#endif
+
+#include <new>
+#include <cstddef>
+#include <cstdlib>
+#include <cassert>
+
+int unsized_delete_called = 0;
+int unsized_delete_nothrow_called = 0;
+int sized_delete_called = 0;
+
+void operator delete(void* p) throw()
+{
+ ++unsized_delete_called;
+ std::free(p);
+}
+
+void operator delete(void* p, const std::nothrow_t&) throw()
+{
+ ++unsized_delete_nothrow_called;
+ std::free(p);
+}
+
+void operator delete(void* p, std::size_t) throw()
+{
+ ++sized_delete_called;
+ std::free(p);
+}
+
+int main()
+{
+ int *x = new int(42);
+ assert(0 == sized_delete_called);
+ assert(0 == unsized_delete_called);
+ assert(0 == unsized_delete_nothrow_called);
+
+ delete x;
+ assert(1 == sized_delete_called);
+ assert(0 == unsized_delete_called);
+ assert(0 == unsized_delete_nothrow_called);
+}
diff --git a/test/std/language.support/support.dynamic/new.delete/nothing_to_do.pass.cpp b/test/std/language.support/support.dynamic/new.delete/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/language.support/support.dynamic/new.delete/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/language.support/support.dynamic/version.pass.cpp b/test/std/language.support/support.dynamic/version.pass.cpp
new file mode 100644
index 000000000000..ba1ff518e51f
--- /dev/null
+++ b/test/std/language.support/support.dynamic/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <new>
+
+#include <new>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/language.support/support.exception/bad.exception/bad_exception.pass.cpp b/test/std/language.support/support.exception/bad.exception/bad_exception.pass.cpp
new file mode 100644
index 000000000000..3baddaa898d0
--- /dev/null
+++ b/test/std/language.support/support.exception/bad.exception/bad_exception.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test bad_exception
+
+#include <exception>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+ static_assert((std::is_base_of<std::exception, std::bad_exception>::value),
+ "std::is_base_of<std::exception, std::bad_exception>::value");
+ static_assert(std::is_polymorphic<std::bad_exception>::value,
+ "std::is_polymorphic<std::bad_exception>::value");
+ std::bad_exception b;
+ std::bad_exception b2 = b;
+ b2 = b;
+ const char* w = b2.what();
+ assert(w);
+}
diff --git a/test/std/language.support/support.exception/except.nested/assign.pass.cpp b/test/std/language.support/support.exception/except.nested/assign.pass.cpp
new file mode 100644
index 000000000000..cbe303c570d6
--- /dev/null
+++ b/test/std/language.support/support.exception/except.nested/assign.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <exception>
+
+// class nested_exception;
+
+// nested_exception& operator=(const nested_exception&) throw() = default;
+
+#include <exception>
+#include <cassert>
+
+class A
+{
+ int data_;
+public:
+ explicit A(int data) : data_(data) {}
+
+ friend bool operator==(const A& x, const A& y) {return x.data_ == y.data_;}
+};
+
+int main()
+{
+ {
+ std::nested_exception e0;
+ std::nested_exception e;
+ e = e0;
+ assert(e.nested_ptr() == nullptr);
+ }
+ {
+ try
+ {
+ throw A(2);
+ assert(false);
+ }
+ catch (const A&)
+ {
+ std::nested_exception e0;
+ std::nested_exception e;
+ e = e0;
+ assert(e.nested_ptr() != nullptr);
+ try
+ {
+ rethrow_exception(e.nested_ptr());
+ assert(false);
+ }
+ catch (const A& a)
+ {
+ assert(a == A(2));
+ }
+ }
+ }
+}
diff --git a/test/std/language.support/support.exception/except.nested/ctor_copy.pass.cpp b/test/std/language.support/support.exception/except.nested/ctor_copy.pass.cpp
new file mode 100644
index 000000000000..bfa13707a971
--- /dev/null
+++ b/test/std/language.support/support.exception/except.nested/ctor_copy.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <exception>
+
+// class nested_exception;
+
+// nested_exception(const nested_exception&) throw() = default;
+
+#include <exception>
+#include <cassert>
+
+class A
+{
+ int data_;
+public:
+ explicit A(int data) : data_(data) {}
+
+ friend bool operator==(const A& x, const A& y) {return x.data_ == y.data_;}
+};
+
+int main()
+{
+ {
+ std::nested_exception e0;
+ std::nested_exception e = e0;
+ assert(e.nested_ptr() == nullptr);
+ }
+ {
+ try
+ {
+ throw A(2);
+ assert(false);
+ }
+ catch (const A&)
+ {
+ std::nested_exception e0;
+ std::nested_exception e = e0;
+ assert(e.nested_ptr() != nullptr);
+ try
+ {
+ rethrow_exception(e.nested_ptr());
+ assert(false);
+ }
+ catch (const A& a)
+ {
+ assert(a == A(2));
+ }
+ }
+ }
+}
diff --git a/test/std/language.support/support.exception/except.nested/ctor_default.pass.cpp b/test/std/language.support/support.exception/except.nested/ctor_default.pass.cpp
new file mode 100644
index 000000000000..1422f770eca8
--- /dev/null
+++ b/test/std/language.support/support.exception/except.nested/ctor_default.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <exception>
+
+// class nested_exception;
+
+// nested_exception() throw();
+
+#include <exception>
+#include <cassert>
+
+class A
+{
+ int data_;
+public:
+ explicit A(int data) : data_(data) {}
+
+ friend bool operator==(const A& x, const A& y) {return x.data_ == y.data_;}
+};
+
+int main()
+{
+ {
+ std::nested_exception e;
+ assert(e.nested_ptr() == nullptr);
+ }
+ {
+ try
+ {
+ throw A(2);
+ assert(false);
+ }
+ catch (const A&)
+ {
+ std::nested_exception e;
+ assert(e.nested_ptr() != nullptr);
+ try
+ {
+ rethrow_exception(e.nested_ptr());
+ assert(false);
+ }
+ catch (const A& a)
+ {
+ assert(a == A(2));
+ }
+ }
+ }
+}
diff --git a/test/std/language.support/support.exception/except.nested/rethrow_if_nested.pass.cpp b/test/std/language.support/support.exception/except.nested/rethrow_if_nested.pass.cpp
new file mode 100644
index 000000000000..567ed579eb7b
--- /dev/null
+++ b/test/std/language.support/support.exception/except.nested/rethrow_if_nested.pass.cpp
@@ -0,0 +1,89 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <exception>
+
+// class nested_exception;
+
+// template <class E> void rethrow_if_nested(const E& e);
+
+#include <exception>
+#include <cstdlib>
+#include <cassert>
+
+class A
+{
+ int data_;
+public:
+ explicit A(int data) : data_(data) {}
+ virtual ~A() _NOEXCEPT {}
+
+ friend bool operator==(const A& x, const A& y) {return x.data_ == y.data_;}
+};
+
+class B
+ : public std::nested_exception,
+ public A
+{
+public:
+ explicit B(int data) : A(data) {}
+ B(const B& b) : A(b) {}
+};
+
+int main()
+{
+ {
+ try
+ {
+ A a(3);
+ std::rethrow_if_nested(a);
+ assert(true);
+ }
+ catch (...)
+ {
+ assert(false);
+ }
+ }
+ {
+ try
+ {
+ throw B(5);
+ }
+ catch (const B& b)
+ {
+ try
+ {
+ throw b;
+ }
+ catch (const A& a)
+ {
+ try
+ {
+ std::rethrow_if_nested(a);
+ assert(false);
+ }
+ catch (const B& b)
+ {
+ assert(b == B(5));
+ }
+ }
+ }
+ }
+ {
+ try
+ {
+ std::rethrow_if_nested(1);
+ assert(true);
+ }
+ catch (...)
+ {
+ assert(false);
+ }
+ }
+}
diff --git a/test/std/language.support/support.exception/except.nested/rethrow_nested.pass.cpp b/test/std/language.support/support.exception/except.nested/rethrow_nested.pass.cpp
new file mode 100644
index 000000000000..b07269061b4b
--- /dev/null
+++ b/test/std/language.support/support.exception/except.nested/rethrow_nested.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <exception>
+
+// class nested_exception;
+
+// void rethrow_nested [[noreturn]] () const;
+
+#include <exception>
+#include <cstdlib>
+#include <cassert>
+
+class A
+{
+ int data_;
+public:
+ explicit A(int data) : data_(data) {}
+
+ friend bool operator==(const A& x, const A& y) {return x.data_ == y.data_;}
+};
+
+void go_quietly()
+{
+ std::exit(0);
+}
+
+int main()
+{
+ {
+ try
+ {
+ throw A(2);
+ assert(false);
+ }
+ catch (const A&)
+ {
+ const std::nested_exception e;
+ assert(e.nested_ptr() != nullptr);
+ try
+ {
+ e.rethrow_nested();
+ assert(false);
+ }
+ catch (const A& a)
+ {
+ assert(a == A(2));
+ }
+ }
+ }
+ {
+ try
+ {
+ std::set_terminate(go_quietly);
+ const std::nested_exception e;
+ e.rethrow_nested();
+ assert(false);
+ }
+ catch (...)
+ {
+ assert(false);
+ }
+ }
+}
diff --git a/test/std/language.support/support.exception/except.nested/throw_with_nested.pass.cpp b/test/std/language.support/support.exception/except.nested/throw_with_nested.pass.cpp
new file mode 100644
index 000000000000..dad0df248076
--- /dev/null
+++ b/test/std/language.support/support.exception/except.nested/throw_with_nested.pass.cpp
@@ -0,0 +1,119 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <exception>
+
+// class nested_exception;
+
+// template<class T> void throw_with_nested [[noreturn]] (T&& t);
+
+#include <exception>
+#include <cstdlib>
+#include <cassert>
+
+class A
+{
+ int data_;
+public:
+ explicit A(int data) : data_(data) {}
+
+ friend bool operator==(const A& x, const A& y) {return x.data_ == y.data_;}
+};
+
+class B
+ : public std::nested_exception
+{
+ int data_;
+public:
+ explicit B(int data) : data_(data) {}
+
+ friend bool operator==(const B& x, const B& y) {return x.data_ == y.data_;}
+};
+
+#if __cplusplus > 201103L
+struct Final final {};
+#endif
+
+int main()
+{
+ {
+ try
+ {
+ A a(3);
+ std::throw_with_nested(a);
+ assert(false);
+ }
+ catch (const A& a)
+ {
+ assert(a == A(3));
+ }
+ }
+ {
+ try
+ {
+ A a(4);
+ std::throw_with_nested(a);
+ assert(false);
+ }
+ catch (const std::nested_exception& e)
+ {
+ assert(e.nested_ptr() == nullptr);
+ }
+ }
+ {
+ try
+ {
+ B b(5);
+ std::throw_with_nested(b);
+ assert(false);
+ }
+ catch (const B& b)
+ {
+ assert(b == B(5));
+ }
+ }
+ {
+ try
+ {
+ B b(6);
+ std::throw_with_nested(b);
+ assert(false);
+ }
+ catch (const std::nested_exception& e)
+ {
+ assert(e.nested_ptr() == nullptr);
+ const B& b = dynamic_cast<const B&>(e);
+ assert(b == B(6));
+ }
+ }
+ {
+ try
+ {
+ int i = 7;
+ std::throw_with_nested(i);
+ assert(false);
+ }
+ catch (int i)
+ {
+ assert(i == 7);
+ }
+ }
+#if __cplusplus > 201103L
+ {
+ try
+ {
+ std::throw_with_nested(Final());
+ assert(false);
+ }
+ catch (const Final &f)
+ {
+ }
+ }
+#endif
+}
diff --git a/test/std/language.support/support.exception/exception.terminate/nothing_to_do.pass.cpp b/test/std/language.support/support.exception/exception.terminate/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/language.support/support.exception/exception.terminate/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/language.support/support.exception/exception.terminate/set.terminate/get_terminate.pass.cpp b/test/std/language.support/support.exception/exception.terminate/set.terminate/get_terminate.pass.cpp
new file mode 100644
index 000000000000..82ae4aaa88d1
--- /dev/null
+++ b/test/std/language.support/support.exception/exception.terminate/set.terminate/get_terminate.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test get_terminate
+
+#include <exception>
+#include <cstdlib>
+#include <cassert>
+
+void f1() {}
+void f2() {}
+
+int main()
+{
+ std::set_terminate(f1);
+ assert(std::get_terminate() == f1);
+ std::set_terminate(f2);
+ assert(std::get_terminate() == f2);
+}
diff --git a/test/std/language.support/support.exception/exception.terminate/set.terminate/set_terminate.pass.cpp b/test/std/language.support/support.exception/exception.terminate/set.terminate/set_terminate.pass.cpp
new file mode 100644
index 000000000000..c4bff603ebb7
--- /dev/null
+++ b/test/std/language.support/support.exception/exception.terminate/set.terminate/set_terminate.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test set_terminate
+
+#include <exception>
+#include <cstdlib>
+#include <cassert>
+
+void f1() {}
+void f2() {}
+
+int main()
+{
+ std::set_terminate(f1);
+ assert(std::set_terminate(f2) == f1);
+}
diff --git a/test/std/language.support/support.exception/exception.terminate/terminate.handler/terminate_handler.pass.cpp b/test/std/language.support/support.exception/exception.terminate/terminate.handler/terminate_handler.pass.cpp
new file mode 100644
index 000000000000..232ce0a5a888
--- /dev/null
+++ b/test/std/language.support/support.exception/exception.terminate/terminate.handler/terminate_handler.pass.cpp
@@ -0,0 +1,19 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test terminate_handler
+
+#include <exception>
+
+void f() {}
+
+int main()
+{
+ std::terminate_handler p = f;
+}
diff --git a/test/std/language.support/support.exception/exception.terminate/terminate/terminate.pass.cpp b/test/std/language.support/support.exception/exception.terminate/terminate/terminate.pass.cpp
new file mode 100644
index 000000000000..3199d9b9ea90
--- /dev/null
+++ b/test/std/language.support/support.exception/exception.terminate/terminate/terminate.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test terminate
+
+#include <exception>
+#include <cstdlib>
+#include <cassert>
+
+void f1()
+{
+ std::exit(0);
+}
+
+int main()
+{
+ std::set_terminate(f1);
+ std::terminate();
+ assert(false);
+}
diff --git a/test/std/language.support/support.exception/exception/exception.pass.cpp b/test/std/language.support/support.exception/exception/exception.pass.cpp
new file mode 100644
index 000000000000..ad53b6ebfe5a
--- /dev/null
+++ b/test/std/language.support/support.exception/exception/exception.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test exception
+
+#include <exception>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+ static_assert(std::is_polymorphic<std::exception>::value,
+ "std::is_polymorphic<std::exception>::value");
+ std::exception b;
+ std::exception b2 = b;
+ b2 = b;
+ const char* w = b2.what();
+ assert(w);
+}
diff --git a/test/std/language.support/support.exception/propagation/current_exception.pass.cpp b/test/std/language.support/support.exception/propagation/current_exception.pass.cpp
new file mode 100644
index 000000000000..9ff0d6e2ce4d
--- /dev/null
+++ b/test/std/language.support/support.exception/propagation/current_exception.pass.cpp
@@ -0,0 +1,269 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <exception>
+
+// exception_ptr current_exception();
+
+#include <exception>
+#include <cassert>
+
+struct A
+{
+ static int constructed;
+
+ A() {++constructed;}
+ ~A() {--constructed;}
+ A(const A&) {++constructed;}
+};
+
+int A::constructed = 0;
+
+int main()
+{
+ {
+ std::exception_ptr p = std::current_exception();
+ assert(p == nullptr);
+ }
+ {
+ try
+ {
+ assert(A::constructed == 0);
+ throw A();
+ assert(false);
+ }
+ catch (...)
+ {
+ assert(A::constructed == 1);
+ }
+ assert(A::constructed == 0);
+ }
+ assert(A::constructed == 0);
+ {
+ std::exception_ptr p2;
+ try
+ {
+ assert(A::constructed == 0);
+ throw A();
+ assert(false);
+ }
+ catch (...)
+ {
+ std::exception_ptr p = std::current_exception();
+ assert(A::constructed == 1);
+ assert(p != nullptr);
+ p2 = std::current_exception();
+ assert(A::constructed == 1);
+ assert(p == p2);
+ }
+ assert(A::constructed == 1);
+ }
+ assert(A::constructed == 0);
+ {
+ std::exception_ptr p2;
+ try
+ {
+ assert(A::constructed == 0);
+ throw A();
+ assert(false);
+ }
+ catch (A& a)
+ {
+ std::exception_ptr p = std::current_exception();
+ assert(A::constructed == 1);
+ assert(p != nullptr);
+ p2 = std::current_exception();
+ assert(A::constructed == 1);
+ assert(p == p2);
+ }
+ assert(A::constructed == 1);
+ }
+ assert(A::constructed == 0);
+ {
+ std::exception_ptr p2;
+ try
+ {
+ assert(A::constructed == 0);
+ throw A();
+ assert(false);
+ }
+ catch (A a)
+ {
+ std::exception_ptr p = std::current_exception();
+ assert(A::constructed == 2);
+ assert(p != nullptr);
+ p2 = std::current_exception();
+ assert(A::constructed == 2);
+ assert(p == p2);
+ }
+ assert(A::constructed == 1);
+ }
+ assert(A::constructed == 0);
+ {
+ try
+ {
+ assert(A::constructed == 0);
+ throw A();
+ assert(false);
+ }
+ catch (...)
+ {
+ assert(A::constructed == 1);
+ try
+ {
+ assert(A::constructed == 1);
+ throw;
+ assert(false);
+ }
+ catch (...)
+ {
+ assert(A::constructed == 1);
+ }
+ assert(A::constructed == 1);
+ }
+ assert(A::constructed == 0);
+ }
+ assert(A::constructed == 0);
+ {
+ try
+ {
+ assert(A::constructed == 0);
+ throw A();
+ assert(false);
+ }
+ catch (...)
+ {
+ assert(A::constructed == 1);
+ try
+ {
+ std::exception_ptr p = std::current_exception();
+ assert(A::constructed == 1);
+ assert(p != nullptr);
+ throw;
+ assert(false);
+ }
+ catch (...)
+ {
+ assert(A::constructed == 1);
+ }
+ assert(A::constructed == 1);
+ }
+ assert(A::constructed == 0);
+ }
+ assert(A::constructed == 0);
+ {
+ try
+ {
+ assert(A::constructed == 0);
+ throw A();
+ assert(false);
+ }
+ catch (...)
+ {
+ assert(A::constructed == 1);
+ try
+ {
+ assert(A::constructed == 1);
+ throw;
+ assert(false);
+ }
+ catch (...)
+ {
+ std::exception_ptr p = std::current_exception();
+ assert(A::constructed == 1);
+ assert(p != nullptr);
+ }
+ assert(A::constructed == 1);
+ }
+ assert(A::constructed == 0);
+ }
+ assert(A::constructed == 0);
+ {
+ try
+ {
+ assert(A::constructed == 0);
+ throw A();
+ assert(false);
+ }
+ catch (...)
+ {
+ assert(A::constructed == 1);
+ try
+ {
+ assert(A::constructed == 1);
+ throw;
+ assert(false);
+ }
+ catch (...)
+ {
+ assert(A::constructed == 1);
+ }
+ std::exception_ptr p = std::current_exception();
+ assert(A::constructed == 1);
+ assert(p != nullptr);
+ }
+ assert(A::constructed == 0);
+ }
+ assert(A::constructed == 0);
+ {
+ try
+ {
+ assert(A::constructed == 0);
+ throw A();
+ assert(false);
+ }
+ catch (...)
+ {
+ assert(A::constructed == 1);
+ try
+ {
+ assert(A::constructed == 1);
+ throw;
+ assert(false);
+ }
+ catch (...)
+ {
+ assert(A::constructed == 1);
+ }
+ assert(A::constructed == 1);
+ }
+ std::exception_ptr p = std::current_exception();
+ assert(A::constructed == 0);
+ assert(p == nullptr);
+ }
+ assert(A::constructed == 0);
+ {
+ std::exception_ptr p;
+ try
+ {
+ assert(A::constructed == 0);
+ throw A();
+ assert(false);
+ }
+ catch (...)
+ {
+ assert(A::constructed == 1);
+ try
+ {
+ assert(A::constructed == 1);
+ throw;
+ assert(false);
+ }
+ catch (...)
+ {
+ p = std::current_exception();
+ assert(A::constructed == 1);
+ }
+ assert(A::constructed == 1);
+ }
+ assert(A::constructed == 1);
+ assert(p != nullptr);
+ }
+ assert(A::constructed == 0);
+}
diff --git a/test/std/language.support/support.exception/propagation/exception_ptr.pass.cpp b/test/std/language.support/support.exception/propagation/exception_ptr.pass.cpp
new file mode 100644
index 000000000000..3aa8dcf55bbc
--- /dev/null
+++ b/test/std/language.support/support.exception/propagation/exception_ptr.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <exception>
+
+// typedef unspecified exception_ptr;
+
+// exception_ptr shall satisfy the requirements of NullablePointer.
+
+#include <exception>
+#include <cassert>
+
+int main()
+{
+ std::exception_ptr p;
+ assert(p == nullptr);
+ std::exception_ptr p2 = p;
+ assert(nullptr == p);
+ assert(!p);
+ assert(p2 == p);
+ p2 = p;
+ assert(p2 == p);
+ assert(p2 == nullptr);
+ std::exception_ptr p3 = nullptr;
+ assert(p3 == nullptr);
+ p3 = nullptr;
+ assert(p3 == nullptr);
+}
diff --git a/test/std/language.support/support.exception/propagation/make_exception_ptr.pass.cpp b/test/std/language.support/support.exception/propagation/make_exception_ptr.pass.cpp
new file mode 100644
index 000000000000..89c9f85d3810
--- /dev/null
+++ b/test/std/language.support/support.exception/propagation/make_exception_ptr.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <exception>
+
+// template<class E> exception_ptr make_exception_ptr(E e);
+
+#include <exception>
+#include <cassert>
+
+struct A
+{
+ static int constructed;
+ int data_;
+
+ A(int data = 0) : data_(data) {++constructed;}
+ ~A() {--constructed;}
+ A(const A& a) : data_(a.data_) {++constructed;}
+};
+
+int A::constructed = 0;
+
+int main()
+{
+ {
+ std::exception_ptr p = std::make_exception_ptr(A(5));
+ try
+ {
+ std::rethrow_exception(p);
+ assert(false);
+ }
+ catch (const A& a)
+ {
+ assert(A::constructed == 1);
+ assert(p != nullptr);
+ p = nullptr;
+ assert(p == nullptr);
+ assert(a.data_ == 5);
+ assert(A::constructed == 1);
+ }
+ assert(A::constructed == 0);
+ }
+}
diff --git a/test/std/language.support/support.exception/propagation/rethrow_exception.pass.cpp b/test/std/language.support/support.exception/propagation/rethrow_exception.pass.cpp
new file mode 100644
index 000000000000..e47a5989d41c
--- /dev/null
+++ b/test/std/language.support/support.exception/propagation/rethrow_exception.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <exception>
+
+// void rethrow_exception [[noreturn]] (exception_ptr p);
+
+#include <exception>
+#include <cassert>
+
+struct A
+{
+ static int constructed;
+ int data_;
+
+ A(int data = 0) : data_(data) {++constructed;}
+ ~A() {--constructed;}
+ A(const A& a) : data_(a.data_) {++constructed;}
+};
+
+int A::constructed = 0;
+
+int main()
+{
+ {
+ std::exception_ptr p;
+ try
+ {
+ throw A(3);
+ }
+ catch (...)
+ {
+ p = std::current_exception();
+ }
+ try
+ {
+ std::rethrow_exception(p);
+ assert(false);
+ }
+ catch (const A& a)
+ {
+ assert(A::constructed == 1);
+ assert(p != nullptr);
+ p = nullptr;
+ assert(p == nullptr);
+ assert(a.data_ == 3);
+ assert(A::constructed == 1);
+ }
+ assert(A::constructed == 0);
+ }
+}
diff --git a/test/std/language.support/support.exception/uncaught/uncaught_exception.pass.cpp b/test/std/language.support/support.exception/uncaught/uncaught_exception.pass.cpp
new file mode 100644
index 000000000000..22d8d8e982ae
--- /dev/null
+++ b/test/std/language.support/support.exception/uncaught/uncaught_exception.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test uncaught_exception
+
+#include <exception>
+#include <cassert>
+
+struct A
+{
+ ~A()
+ {
+ assert(std::uncaught_exception());
+ }
+};
+
+struct B
+{
+ B()
+ {
+ // http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#475
+ assert(!std::uncaught_exception());
+ }
+};
+
+int main()
+{
+ try
+ {
+ A a;
+ assert(!std::uncaught_exception());
+ throw B();
+ }
+ catch (...)
+ {
+ assert(!std::uncaught_exception());
+ }
+ assert(!std::uncaught_exception());
+}
diff --git a/test/std/language.support/support.exception/uncaught/uncaught_exceptions.pass.cpp b/test/std/language.support/support.exception/uncaught/uncaught_exceptions.pass.cpp
new file mode 100644
index 000000000000..1adc904fd5d2
--- /dev/null
+++ b/test/std/language.support/support.exception/uncaught/uncaught_exceptions.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test uncaught_exceptions
+
+#include <exception>
+#include <cassert>
+
+struct A
+{
+ ~A()
+ {
+ assert(std::uncaught_exceptions() > 0);
+ }
+};
+
+struct B
+{
+ B()
+ {
+ // http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#475
+ assert(std::uncaught_exceptions() == 0);
+ }
+};
+
+int main()
+{
+ try
+ {
+ A a;
+ assert(std::uncaught_exceptions() == 0);
+ throw B();
+ }
+ catch (...)
+ {
+ assert(std::uncaught_exception() == 0);
+ }
+ assert(std::uncaught_exceptions() == 0);
+}
diff --git a/test/std/language.support/support.exception/version.pass.cpp b/test/std/language.support/support.exception/version.pass.cpp
new file mode 100644
index 000000000000..acdedbb31fe3
--- /dev/null
+++ b/test/std/language.support/support.exception/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <exception>
+
+#include <exception>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/language.support/support.general/nothing_to_do.pass.cpp b/test/std/language.support/support.general/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/language.support/support.general/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/language.support/support.initlist/support.initlist.access/access.pass.cpp b/test/std/language.support/support.initlist/support.initlist.access/access.pass.cpp
new file mode 100644
index 000000000000..2f0720639c66
--- /dev/null
+++ b/test/std/language.support/support.initlist/support.initlist.access/access.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// template<class E> class initializer_list;
+
+// const E* begin() const;
+// const E* end() const;
+// size_t size() const;
+
+#include <initializer_list>
+#include <cassert>
+
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+struct A
+{
+ A(std::initializer_list<int> il)
+ {
+ const int* b = il.begin();
+ const int* e = il.end();
+ assert(il.size() == 3);
+ assert(e - b == il.size());
+ assert(*b++ == 3);
+ assert(*b++ == 2);
+ assert(*b++ == 1);
+ }
+};
+
+#if _LIBCPP_STD_VER > 11
+struct B
+{
+ constexpr B(std::initializer_list<int> il)
+ {
+ const int* b = il.begin();
+ const int* e = il.end();
+ assert(il.size() == 3);
+ assert(e - b == il.size());
+ assert(*b++ == 3);
+ assert(*b++ == 2);
+ assert(*b++ == 1);
+ }
+};
+
+#endif // _LIBCPP_STD_VER > 11
+
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ A test1 = {3, 2, 1};
+#endif
+#if _LIBCPP_STD_VER > 11
+ constexpr B test2 = {3, 2, 1};
+#endif // _LIBCPP_STD_VER > 11
+}
diff --git a/test/std/language.support/support.initlist/support.initlist.cons/default.pass.cpp b/test/std/language.support/support.initlist/support.initlist.cons/default.pass.cpp
new file mode 100644
index 000000000000..7822a62206a1
--- /dev/null
+++ b/test/std/language.support/support.initlist/support.initlist.cons/default.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// template<class E> class initializer_list;
+
+// initializer_list();
+
+#include <initializer_list>
+#include <cassert>
+
+struct A {};
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ std::initializer_list<A> il;
+ assert(il.size() == 0);
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+#if _LIBCPP_STD_VER > 11
+ constexpr std::initializer_list<A> il2;
+ static_assert(il2.size() == 0, "");
+#endif // _LIBCPP_STD_VER > 11
+}
diff --git a/test/std/language.support/support.initlist/support.initlist.range/begin_end.pass.cpp b/test/std/language.support/support.initlist/support.initlist.range/begin_end.pass.cpp
new file mode 100644
index 000000000000..5fcd28f9156c
--- /dev/null
+++ b/test/std/language.support/support.initlist/support.initlist.range/begin_end.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <initializer_list>
+
+// template<class E> const E* begin(initializer_list<E> il);
+
+#include <initializer_list>
+#include <cassert>
+
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+struct A
+{
+ A(std::initializer_list<int> il)
+ {
+ const int* b = begin(il);
+ const int* e = end(il);
+ assert(il.size() == 3);
+ assert(e - b == il.size());
+ assert(*b++ == 3);
+ assert(*b++ == 2);
+ assert(*b++ == 1);
+ }
+};
+
+#if _LIBCPP_STD_VER > 11
+struct B
+{
+ constexpr B(std::initializer_list<int> il)
+ {
+ const int* b = begin(il);
+ const int* e = end(il);
+ assert(il.size() == 3);
+ assert(e - b == il.size());
+ assert(*b++ == 3);
+ assert(*b++ == 2);
+ assert(*b++ == 1);
+ }
+};
+
+#endif // _LIBCPP_STD_VER > 11
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ A test1 = {3, 2, 1};
+#endif
+#if _LIBCPP_STD_VER > 11
+ constexpr B test2 = {3, 2, 1};
+#endif // _LIBCPP_STD_VER > 11
+}
diff --git a/test/std/language.support/support.initlist/types.pass.cpp b/test/std/language.support/support.initlist/types.pass.cpp
new file mode 100644
index 000000000000..835830055ff4
--- /dev/null
+++ b/test/std/language.support/support.initlist/types.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// template<class E>
+// class initializer_list
+// {
+// public:
+// typedef E value_type;
+// typedef const E& reference;
+// typedef const E& const_reference;
+// typedef size_t size_type;
+//
+// typedef const E* iterator;
+// typedef const E* const_iterator;
+
+#include <initializer_list>
+#include <type_traits>
+
+struct A {};
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ static_assert((std::is_same<std::initializer_list<A>::value_type, A>::value), "");
+ static_assert((std::is_same<std::initializer_list<A>::reference, const A&>::value), "");
+ static_assert((std::is_same<std::initializer_list<A>::const_reference, const A&>::value), "");
+ static_assert((std::is_same<std::initializer_list<A>::size_type, std::size_t>::value), "");
+ static_assert((std::is_same<std::initializer_list<A>::iterator, const A*>::value), "");
+ static_assert((std::is_same<std::initializer_list<A>::const_iterator, const A*>::value), "");
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/language.support/support.initlist/version.pass.cpp b/test/std/language.support/support.initlist/version.pass.cpp
new file mode 100644
index 000000000000..f3f08cd1f864
--- /dev/null
+++ b/test/std/language.support/support.initlist/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <initializer_list>
+
+#include <initializer_list>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/language.support/support.limits/c.limits/cfloat.pass.cpp b/test/std/language.support/support.limits/c.limits/cfloat.pass.cpp
new file mode 100644
index 000000000000..5f63af68f701
--- /dev/null
+++ b/test/std/language.support/support.limits/c.limits/cfloat.pass.cpp
@@ -0,0 +1,140 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+ // test cfloat
+
+#include <cfloat>
+
+#ifndef FLT_ROUNDS
+#error FLT_ROUNDS not defined
+#endif
+
+#ifndef FLT_EVAL_METHOD
+#error FLT_EVAL_METHOD not defined
+#endif
+
+#ifndef FLT_RADIX
+#error FLT_RADIX not defined
+#endif
+
+#ifndef FLT_MANT_DIG
+#error FLT_MANT_DIG not defined
+#endif
+
+#ifndef DBL_MANT_DIG
+#error DBL_MANT_DIG not defined
+#endif
+
+#ifndef LDBL_MANT_DIG
+#error LDBL_MANT_DIG not defined
+#endif
+
+#ifndef DECIMAL_DIG
+#error DECIMAL_DIG not defined
+#endif
+
+#ifndef FLT_DIG
+#error FLT_DIG not defined
+#endif
+
+#ifndef DBL_DIG
+#error DBL_DIG not defined
+#endif
+
+#ifndef LDBL_DIG
+#error LDBL_DIG not defined
+#endif
+
+#ifndef FLT_MIN_EXP
+#error FLT_MIN_EXP not defined
+#endif
+
+#ifndef DBL_MIN_EXP
+#error DBL_MIN_EXP not defined
+#endif
+
+#ifndef LDBL_MIN_EXP
+#error LDBL_MIN_EXP not defined
+#endif
+
+#ifndef FLT_MIN_10_EXP
+#error FLT_MIN_10_EXP not defined
+#endif
+
+#ifndef DBL_MIN_10_EXP
+#error DBL_MIN_10_EXP not defined
+#endif
+
+#ifndef LDBL_MIN_10_EXP
+#error LDBL_MIN_10_EXP not defined
+#endif
+
+#ifndef FLT_MAX_EXP
+#error FLT_MAX_EXP not defined
+#endif
+
+#ifndef DBL_MAX_EXP
+#error DBL_MAX_EXP not defined
+#endif
+
+#ifndef LDBL_MAX_EXP
+#error LDBL_MAX_EXP not defined
+#endif
+
+#ifndef FLT_MAX_10_EXP
+#error FLT_MAX_10_EXP not defined
+#endif
+
+#ifndef DBL_MAX_10_EXP
+#error DBL_MAX_10_EXP not defined
+#endif
+
+#ifndef LDBL_MAX_10_EXP
+#error LDBL_MAX_10_EXP not defined
+#endif
+
+#ifndef FLT_MAX
+#error FLT_MAX not defined
+#endif
+
+#ifndef DBL_MAX
+#error DBL_MAX not defined
+#endif
+
+#ifndef LDBL_MAX
+#error LDBL_MAX not defined
+#endif
+
+#ifndef FLT_EPSILON
+#error FLT_EPSILON not defined
+#endif
+
+#ifndef DBL_EPSILON
+#error DBL_EPSILON not defined
+#endif
+
+#ifndef LDBL_EPSILON
+#error LDBL_EPSILON not defined
+#endif
+
+#ifndef FLT_MIN
+#error FLT_MIN not defined
+#endif
+
+#ifndef DBL_MIN
+#error DBL_MIN not defined
+#endif
+
+#ifndef LDBL_MIN
+#error LDBL_MIN not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/language.support/support.limits/c.limits/climits.pass.cpp b/test/std/language.support/support.limits/c.limits/climits.pass.cpp
new file mode 100644
index 000000000000..5e31b494bd1d
--- /dev/null
+++ b/test/std/language.support/support.limits/c.limits/climits.pass.cpp
@@ -0,0 +1,92 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+ // test climits
+
+#include <climits>
+
+#ifndef CHAR_BIT
+#error CHAR_BIT not defined
+#endif
+
+#ifndef SCHAR_MIN
+#error SCHAR_MIN not defined
+#endif
+
+#ifndef SCHAR_MAX
+#error SCHAR_MAX not defined
+#endif
+
+#ifndef UCHAR_MAX
+#error UCHAR_MAX not defined
+#endif
+
+#ifndef CHAR_MIN
+#error CHAR_MIN not defined
+#endif
+
+#ifndef CHAR_MAX
+#error CHAR_MAX not defined
+#endif
+
+#ifndef MB_LEN_MAX
+#error MB_LEN_MAX not defined
+#endif
+
+#ifndef SHRT_MIN
+#error SHRT_MIN not defined
+#endif
+
+#ifndef SHRT_MAX
+#error SHRT_MAX not defined
+#endif
+
+#ifndef USHRT_MAX
+#error USHRT_MAX not defined
+#endif
+
+#ifndef INT_MIN
+#error INT_MIN not defined
+#endif
+
+#ifndef INT_MAX
+#error INT_MAX not defined
+#endif
+
+#ifndef UINT_MAX
+#error UINT_MAX not defined
+#endif
+
+#ifndef LONG_MIN
+#error LONG_MIN not defined
+#endif
+
+#ifndef LONG_MAX
+#error LONG_MAX not defined
+#endif
+
+#ifndef ULONG_MAX
+#error ULONG_MAX not defined
+#endif
+
+#ifndef LLONG_MIN
+#error LLONG_MIN not defined
+#endif
+
+#ifndef LLONG_MAX
+#error LLONG_MAX not defined
+#endif
+
+#ifndef ULLONG_MAX
+#error ULLONG_MAX not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/language.support/support.limits/c.limits/version_cfloat.pass.cpp b/test/std/language.support/support.limits/c.limits/version_cfloat.pass.cpp
new file mode 100644
index 000000000000..19b463199cd6
--- /dev/null
+++ b/test/std/language.support/support.limits/c.limits/version_cfloat.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <cfloat>
+
+#include <cfloat>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/language.support/support.limits/c.limits/version_climits.pass.cpp b/test/std/language.support/support.limits/c.limits/version_climits.pass.cpp
new file mode 100644
index 000000000000..3fe07a5174b3
--- /dev/null
+++ b/test/std/language.support/support.limits/c.limits/version_climits.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <climits>
+
+#include <climits>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/language.support/support.limits/limits/denorm.style/check_values.pass.cpp b/test/std/language.support/support.limits/limits/denorm.style/check_values.pass.cpp
new file mode 100644
index 000000000000..c6731fcc8e92
--- /dev/null
+++ b/test/std/language.support/support.limits/limits/denorm.style/check_values.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// float_round_style
+
+#include <limits>
+
+typedef char one;
+struct two {one _[2];};
+
+one test(std::float_round_style);
+two test(int);
+
+int main()
+{
+ static_assert(std::round_indeterminate == -1,
+ "std::round_indeterminate == -1");
+ static_assert(std::round_toward_zero == 0,
+ "std::round_toward_zero == 0");
+ static_assert(std::round_to_nearest == 1,
+ "std::round_to_nearest == 1");
+ static_assert(std::round_toward_infinity == 2,
+ "std::round_toward_infinity == 2");
+ static_assert(std::round_toward_neg_infinity == 3,
+ "std::round_toward_neg_infinity == 3");
+ static_assert(sizeof(test(std::round_to_nearest)) == 1,
+ "sizeof(test(std::round_to_nearest)) == 1");
+ static_assert(sizeof(test(1)) == 2,
+ "sizeof(test(1)) == 2");
+}
diff --git a/test/std/language.support/support.limits/limits/is_specialized.pass.cpp b/test/std/language.support/support.limits/limits/is_specialized.pass.cpp
new file mode 100644
index 000000000000..ff5c1a2c0b8d
--- /dev/null
+++ b/test/std/language.support/support.limits/limits/is_specialized.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// Specializations shall be provided for each arithmetic type, both floating
+// point and integer, including bool. The member is_specialized shall be
+// true for all such specializations of numeric_limits.
+
+// Non-arithmetic standard types, such as complex<T> (26.3.2), shall not
+// have specializations.
+
+// From [numeric.limits]:
+
+// The value of each member of a specialization of numeric_limits on a cv
+// -qualified type cv T shall be equal to the value of the corresponding
+// member of the specialization on the unqualified type T.
+
+// More convenient to test it here.
+
+#include <limits>
+#include <complex>
+
+template <class T>
+void test()
+{
+ static_assert(std::numeric_limits<T>::is_specialized,
+ "std::numeric_limits<T>::is_specialized");
+ static_assert(std::numeric_limits<const T>::is_specialized,
+ "std::numeric_limits<const T>::is_specialized");
+ static_assert(std::numeric_limits<volatile T>::is_specialized,
+ "std::numeric_limits<volatile T>::is_specialized");
+ static_assert(std::numeric_limits<const volatile T>::is_specialized,
+ "std::numeric_limits<const volatile T>::is_specialized");
+}
+
+int main()
+{
+ test<bool>();
+ test<char>();
+ test<wchar_t>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<char16_t>();
+ test<char32_t>();
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<signed char>();
+ test<unsigned char>();
+ test<signed short>();
+ test<unsigned short>();
+ test<signed int>();
+ test<unsigned int>();
+ test<signed long>();
+ test<unsigned long>();
+ test<signed long long>();
+ test<unsigned long long>();
+#ifndef _LIBCPP_HAS_NO_INT128
+ test<__int128_t>();
+ test<__uint128_t>();
+#endif
+ test<float>();
+ test<double>();
+ test<long double>();
+ static_assert(!std::numeric_limits<std::complex<double> >::is_specialized,
+ "!std::numeric_limits<std::complex<double> >::is_specialized");
+}
diff --git a/test/std/language.support/support.limits/limits/numeric.limits.members/const_data_members.pass.cpp b/test/std/language.support/support.limits/limits/numeric.limits.members/const_data_members.pass.cpp
new file mode 100644
index 000000000000..bbead15da64f
--- /dev/null
+++ b/test/std/language.support/support.limits/limits/numeric.limits.members/const_data_members.pass.cpp
@@ -0,0 +1,199 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <limits>
+
+/*
+<limits>:
+ numeric_limits
+ is_specialized
+ digits
+ digits10
+ max_digits10
+ is_signed
+ is_integer
+ is_exact
+ radix
+ min_exponent
+ min_exponent10
+ max_exponent
+ max_exponent10
+ has_infinity
+ has_quiet_NaN
+ has_signaling_NaN
+ has_denorm
+ has_denorm_loss
+ is_iec559
+ is_bounded
+ is_modulo
+ traps
+ tinyness_before
+ round_style
+*/
+
+template <class _Tp>
+void test(const _Tp &) {}
+
+#define TEST_NUMERIC_LIMITS(type) \
+ test(std::numeric_limits<type>::is_specialized); \
+ test(std::numeric_limits<type>::digits); \
+ test(std::numeric_limits<type>::digits10); \
+ test(std::numeric_limits<type>::max_digits10); \
+ test(std::numeric_limits<type>::is_signed); \
+ test(std::numeric_limits<type>::is_integer); \
+ test(std::numeric_limits<type>::is_exact); \
+ test(std::numeric_limits<type>::radix); \
+ test(std::numeric_limits<type>::min_exponent); \
+ test(std::numeric_limits<type>::min_exponent10); \
+ test(std::numeric_limits<type>::max_exponent); \
+ test(std::numeric_limits<type>::max_exponent10); \
+ test(std::numeric_limits<type>::has_infinity); \
+ test(std::numeric_limits<type>::has_quiet_NaN); \
+ test(std::numeric_limits<type>::has_signaling_NaN); \
+ test(std::numeric_limits<type>::has_denorm); \
+ test(std::numeric_limits<type>::has_denorm_loss); \
+ test(std::numeric_limits<type>::is_iec559); \
+ test(std::numeric_limits<type>::is_bounded); \
+ test(std::numeric_limits<type>::is_modulo); \
+ test(std::numeric_limits<type>::traps); \
+ test(std::numeric_limits<type>::tinyness_before); \
+ test(std::numeric_limits<type>::round_style);
+
+struct other {};
+
+int main()
+{
+ // bool
+ TEST_NUMERIC_LIMITS(bool)
+ TEST_NUMERIC_LIMITS(const bool)
+ TEST_NUMERIC_LIMITS(volatile bool)
+ TEST_NUMERIC_LIMITS(const volatile bool)
+
+ // char
+ TEST_NUMERIC_LIMITS(char)
+ TEST_NUMERIC_LIMITS(const char)
+ TEST_NUMERIC_LIMITS(volatile char)
+ TEST_NUMERIC_LIMITS(const volatile char)
+
+ // signed char
+ TEST_NUMERIC_LIMITS(signed char)
+ TEST_NUMERIC_LIMITS(const signed char)
+ TEST_NUMERIC_LIMITS(volatile signed char)
+ TEST_NUMERIC_LIMITS(const volatile signed char)
+
+ // unsigned char
+ TEST_NUMERIC_LIMITS(unsigned char)
+ TEST_NUMERIC_LIMITS(const unsigned char)
+ TEST_NUMERIC_LIMITS(volatile unsigned char)
+ TEST_NUMERIC_LIMITS(const volatile unsigned char)
+
+ // wchar_t
+ TEST_NUMERIC_LIMITS(wchar_t)
+ TEST_NUMERIC_LIMITS(const wchar_t)
+ TEST_NUMERIC_LIMITS(volatile wchar_t)
+ TEST_NUMERIC_LIMITS(const volatile wchar_t)
+
+ // char16_t
+ TEST_NUMERIC_LIMITS(char16_t)
+ TEST_NUMERIC_LIMITS(const char16_t)
+ TEST_NUMERIC_LIMITS(volatile char16_t)
+ TEST_NUMERIC_LIMITS(const volatile char16_t)
+
+ // char32_t
+ TEST_NUMERIC_LIMITS(char32_t)
+ TEST_NUMERIC_LIMITS(const char32_t)
+ TEST_NUMERIC_LIMITS(volatile char32_t)
+ TEST_NUMERIC_LIMITS(const volatile char32_t)
+
+ // short
+ TEST_NUMERIC_LIMITS(short)
+ TEST_NUMERIC_LIMITS(const short)
+ TEST_NUMERIC_LIMITS(volatile short)
+ TEST_NUMERIC_LIMITS(const volatile short)
+
+ // int
+ TEST_NUMERIC_LIMITS(int)
+ TEST_NUMERIC_LIMITS(const int)
+ TEST_NUMERIC_LIMITS(volatile int)
+ TEST_NUMERIC_LIMITS(const volatile int)
+
+ // long
+ TEST_NUMERIC_LIMITS(long)
+ TEST_NUMERIC_LIMITS(const long)
+ TEST_NUMERIC_LIMITS(volatile long)
+ TEST_NUMERIC_LIMITS(const volatile long)
+
+#ifndef _LIBCPP_HAS_NO_INT128
+ TEST_NUMERIC_LIMITS(__int128_t)
+ TEST_NUMERIC_LIMITS(const __int128_t)
+ TEST_NUMERIC_LIMITS(volatile __int128_t)
+ TEST_NUMERIC_LIMITS(const volatile __int128_t)
+#endif
+
+ // long long
+ TEST_NUMERIC_LIMITS(long long)
+ TEST_NUMERIC_LIMITS(const long long)
+ TEST_NUMERIC_LIMITS(volatile long long)
+ TEST_NUMERIC_LIMITS(const volatile long long)
+
+ // unsigned short
+ TEST_NUMERIC_LIMITS(unsigned short)
+ TEST_NUMERIC_LIMITS(const unsigned short)
+ TEST_NUMERIC_LIMITS(volatile unsigned short)
+ TEST_NUMERIC_LIMITS(const volatile unsigned short)
+
+ // unsigned int
+ TEST_NUMERIC_LIMITS(unsigned int)
+ TEST_NUMERIC_LIMITS(const unsigned int)
+ TEST_NUMERIC_LIMITS(volatile unsigned int)
+ TEST_NUMERIC_LIMITS(const volatile unsigned int)
+
+ // unsigned long
+ TEST_NUMERIC_LIMITS(unsigned long)
+ TEST_NUMERIC_LIMITS(const unsigned long)
+ TEST_NUMERIC_LIMITS(volatile unsigned long)
+ TEST_NUMERIC_LIMITS(const volatile unsigned long)
+
+ // unsigned long long
+ TEST_NUMERIC_LIMITS(unsigned long long)
+ TEST_NUMERIC_LIMITS(const unsigned long long)
+ TEST_NUMERIC_LIMITS(volatile unsigned long long)
+ TEST_NUMERIC_LIMITS(const volatile unsigned long long)
+
+#ifndef _LIBCPP_HAS_NO_INT128
+ TEST_NUMERIC_LIMITS(__uint128_t)
+ TEST_NUMERIC_LIMITS(const __uint128_t)
+ TEST_NUMERIC_LIMITS(volatile __uint128_t)
+ TEST_NUMERIC_LIMITS(const volatile __uint128_t)
+#endif
+
+ // float
+ TEST_NUMERIC_LIMITS(float)
+ TEST_NUMERIC_LIMITS(const float)
+ TEST_NUMERIC_LIMITS(volatile float)
+ TEST_NUMERIC_LIMITS(const volatile float)
+
+ // double
+ TEST_NUMERIC_LIMITS(double)
+ TEST_NUMERIC_LIMITS(const double)
+ TEST_NUMERIC_LIMITS(volatile double)
+ TEST_NUMERIC_LIMITS(const volatile double)
+
+ // long double
+ TEST_NUMERIC_LIMITS(long double)
+ TEST_NUMERIC_LIMITS(const long double)
+ TEST_NUMERIC_LIMITS(volatile long double)
+ TEST_NUMERIC_LIMITS(const volatile long double)
+
+ // other
+ TEST_NUMERIC_LIMITS(other)
+ TEST_NUMERIC_LIMITS(const other)
+ TEST_NUMERIC_LIMITS(volatile other)
+ TEST_NUMERIC_LIMITS(const volatile other)
+}
diff --git a/test/std/language.support/support.limits/limits/numeric.limits.members/denorm_min.pass.cpp b/test/std/language.support/support.limits/limits/numeric.limits.members/denorm_min.pass.cpp
new file mode 100644
index 000000000000..a452d4e9949d
--- /dev/null
+++ b/test/std/language.support/support.limits/limits/numeric.limits.members/denorm_min.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// denorm_min()
+
+#include <limits>
+#include <cassert>
+
+template <class T>
+void
+test(T expected)
+{
+ assert(std::numeric_limits<T>::denorm_min() == expected);
+ assert(std::numeric_limits<const T>::denorm_min() == expected);
+ assert(std::numeric_limits<volatile T>::denorm_min() == expected);
+ assert(std::numeric_limits<const volatile T>::denorm_min() == expected);
+}
+
+int main()
+{
+ test<bool>(false);
+ test<char>(0);
+ test<signed char>(0);
+ test<unsigned char>(0);
+ test<wchar_t>(0);
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<char16_t>(0);
+ test<char32_t>(0);
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<short>(0);
+ test<unsigned short>(0);
+ test<int>(0);
+ test<unsigned int>(0);
+ test<long>(0);
+ test<unsigned long>(0);
+ test<long long>(0);
+ test<unsigned long long>(0);
+#ifndef _LIBCPP_HAS_NO_INT128
+ test<__int128_t>(0);
+ test<__uint128_t>(0);
+#endif
+ test<float>(__FLT_DENORM_MIN__);
+ test<double>(__DBL_DENORM_MIN__);
+ test<long double>(__LDBL_DENORM_MIN__);
+}
diff --git a/test/std/language.support/support.limits/limits/numeric.limits.members/digits.pass.cpp b/test/std/language.support/support.limits/limits/numeric.limits.members/digits.pass.cpp
new file mode 100644
index 000000000000..2dfea084b11d
--- /dev/null
+++ b/test/std/language.support/support.limits/limits/numeric.limits.members/digits.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// digits
+
+#include <limits>
+#include <cfloat>
+
+template <class T, int expected>
+void
+test()
+{
+ static_assert(std::numeric_limits<T>::digits == expected, "digits test 1");
+ static_assert(std::numeric_limits<const T>::digits == expected, "digits test 2");
+ static_assert(std::numeric_limits<volatile T>::digits == expected, "digits test 3");
+ static_assert(std::numeric_limits<const volatile T>::digits == expected, "digits test 4");
+}
+
+int main()
+{
+ test<bool, 1>();
+ test<char, std::numeric_limits<char>::is_signed ? 7 : 8>();
+ test<signed char, 7>();
+ test<unsigned char, 8>();
+ test<wchar_t, std::numeric_limits<wchar_t>::is_signed ? sizeof(wchar_t)*8-1 : sizeof(wchar_t)*8>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<char16_t, 16>();
+ test<char32_t, 32>();
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<short, 15>();
+ test<unsigned short, 16>();
+ test<int, 31>();
+ test<unsigned int, 32>();
+ test<long, sizeof(long) == 4 ? 31 : 63>();
+ test<unsigned long, sizeof(long) == 4 ? 32 : 64>();
+ test<long long, 63>();
+ test<unsigned long long, 64>();
+#ifndef _LIBCPP_HAS_NO_INT128
+ test<__int128_t, 127>();
+ test<__uint128_t, 128>();
+#endif
+ test<float, FLT_MANT_DIG>();
+ test<double, DBL_MANT_DIG>();
+ test<long double, LDBL_MANT_DIG>();
+}
diff --git a/test/std/language.support/support.limits/limits/numeric.limits.members/digits10.pass.cpp b/test/std/language.support/support.limits/limits/numeric.limits.members/digits10.pass.cpp
new file mode 100644
index 000000000000..2c5302cd6334
--- /dev/null
+++ b/test/std/language.support/support.limits/limits/numeric.limits.members/digits10.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// digits10
+
+#include <limits>
+#include <cfloat>
+
+template <class T, int expected>
+void
+test()
+{
+ static_assert(std::numeric_limits<T>::digits10 == expected, "digits10 test 1");
+ static_assert(std::numeric_limits<T>::is_bounded, "digits10 test 5");
+ static_assert(std::numeric_limits<const T>::digits10 == expected, "digits10 test 2");
+ static_assert(std::numeric_limits<const T>::is_bounded, "digits10 test 6");
+ static_assert(std::numeric_limits<volatile T>::digits10 == expected, "digits10 test 3");
+ static_assert(std::numeric_limits<volatile T>::is_bounded, "digits10 test 7");
+ static_assert(std::numeric_limits<const volatile T>::digits10 == expected, "digits10 test 4");
+ static_assert(std::numeric_limits<const volatile T>::is_bounded, "digits10 test 8");
+}
+
+int main()
+{
+ test<bool, 0>();
+ test<char, 2>();
+ test<signed char, 2>();
+ test<unsigned char, 2>();
+ test<wchar_t, 5*sizeof(wchar_t)/2-1>(); // 4 -> 9 and 2 -> 4
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<char16_t, 4>();
+ test<char32_t, 9>();
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<short, 4>();
+ test<unsigned short, 4>();
+ test<int, 9>();
+ test<unsigned int, 9>();
+ test<long, sizeof(long) == 4 ? 9 : 18>();
+ test<unsigned long, sizeof(long) == 4 ? 9 : 19>();
+ test<long long, 18>();
+ test<unsigned long long, 19>();
+#ifndef _LIBCPP_HAS_NO_INT128
+ test<__int128_t, 38>();
+ test<__uint128_t, 38>();
+#endif
+ test<float, FLT_DIG>();
+ test<double, DBL_DIG>();
+ test<long double, LDBL_DIG>();
+}
diff --git a/test/std/language.support/support.limits/limits/numeric.limits.members/epsilon.pass.cpp b/test/std/language.support/support.limits/limits/numeric.limits.members/epsilon.pass.cpp
new file mode 100644
index 000000000000..0cce4848187d
--- /dev/null
+++ b/test/std/language.support/support.limits/limits/numeric.limits.members/epsilon.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// epsilon()
+
+#include <limits>
+#include <cfloat>
+#include <cassert>
+
+template <class T>
+void
+test(T expected)
+{
+ assert(std::numeric_limits<T>::epsilon() == expected);
+ assert(std::numeric_limits<const T>::epsilon() == expected);
+ assert(std::numeric_limits<volatile T>::epsilon() == expected);
+ assert(std::numeric_limits<const volatile T>::epsilon() == expected);
+}
+
+int main()
+{
+ test<bool>(false);
+ test<char>(0);
+ test<signed char>(0);
+ test<unsigned char>(0);
+ test<wchar_t>(0);
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<char16_t>(0);
+ test<char32_t>(0);
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<short>(0);
+ test<unsigned short>(0);
+ test<int>(0);
+ test<unsigned int>(0);
+ test<long>(0);
+ test<unsigned long>(0);
+ test<long long>(0);
+ test<unsigned long long>(0);
+#ifndef _LIBCPP_HAS_NO_INT128
+ test<__int128_t>(0);
+ test<__uint128_t>(0);
+#endif
+ test<float>(FLT_EPSILON);
+ test<double>(DBL_EPSILON);
+ test<long double>(LDBL_EPSILON);
+}
diff --git a/test/std/language.support/support.limits/limits/numeric.limits.members/has_denorm.pass.cpp b/test/std/language.support/support.limits/limits/numeric.limits.members/has_denorm.pass.cpp
new file mode 100644
index 000000000000..e61802054d18
--- /dev/null
+++ b/test/std/language.support/support.limits/limits/numeric.limits.members/has_denorm.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// has_denorm
+
+#include <limits>
+
+template <class T, std::float_denorm_style expected>
+void
+test()
+{
+ static_assert(std::numeric_limits<T>::has_denorm == expected, "has_denorm test 1");
+ static_assert(std::numeric_limits<const T>::has_denorm == expected, "has_denorm test 2");
+ static_assert(std::numeric_limits<volatile T>::has_denorm == expected, "has_denorm test 3");
+ static_assert(std::numeric_limits<const volatile T>::has_denorm == expected, "has_denorm test 4");
+}
+
+int main()
+{
+ test<bool, std::denorm_absent>();
+ test<char, std::denorm_absent>();
+ test<signed char, std::denorm_absent>();
+ test<unsigned char, std::denorm_absent>();
+ test<wchar_t, std::denorm_absent>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<char16_t, std::denorm_absent>();
+ test<char32_t, std::denorm_absent>();
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<short, std::denorm_absent>();
+ test<unsigned short, std::denorm_absent>();
+ test<int, std::denorm_absent>();
+ test<unsigned int, std::denorm_absent>();
+ test<long, std::denorm_absent>();
+ test<unsigned long, std::denorm_absent>();
+ test<long long, std::denorm_absent>();
+ test<unsigned long long, std::denorm_absent>();
+#ifndef _LIBCPP_HAS_NO_INT128
+ test<__int128_t, std::denorm_absent>();
+ test<__uint128_t, std::denorm_absent>();
+#endif
+ test<float, std::denorm_present>();
+ test<double, std::denorm_present>();
+ test<long double, std::denorm_present>();
+}
diff --git a/test/std/language.support/support.limits/limits/numeric.limits.members/has_denorm_loss.pass.cpp b/test/std/language.support/support.limits/limits/numeric.limits.members/has_denorm_loss.pass.cpp
new file mode 100644
index 000000000000..660ecf5036d3
--- /dev/null
+++ b/test/std/language.support/support.limits/limits/numeric.limits.members/has_denorm_loss.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// has_denorm_loss
+
+#include <limits>
+
+template <class T, bool expected>
+void
+test()
+{
+ static_assert(std::numeric_limits<T>::has_denorm_loss == expected, "has_denorm_loss test 1");
+ static_assert(std::numeric_limits<const T>::has_denorm_loss == expected, "has_denorm_loss test 2");
+ static_assert(std::numeric_limits<volatile T>::has_denorm_loss == expected, "has_denorm_loss test 3");
+ static_assert(std::numeric_limits<const volatile T>::has_denorm_loss == expected, "has_denorm_loss test 4");
+}
+
+int main()
+{
+ test<bool, false>();
+ test<char, false>();
+ test<signed char, false>();
+ test<unsigned char, false>();
+ test<wchar_t, false>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<char16_t, false>();
+ test<char32_t, false>();
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<short, false>();
+ test<unsigned short, false>();
+ test<int, false>();
+ test<unsigned int, false>();
+ test<long, false>();
+ test<unsigned long, false>();
+ test<long long, false>();
+ test<unsigned long long, false>();
+#ifndef _LIBCPP_HAS_NO_INT128
+ test<__int128_t, false>();
+ test<__uint128_t, false>();
+#endif
+ test<float, false>();
+ test<double, false>();
+ test<long double, false>();
+}
diff --git a/test/std/language.support/support.limits/limits/numeric.limits.members/has_infinity.pass.cpp b/test/std/language.support/support.limits/limits/numeric.limits.members/has_infinity.pass.cpp
new file mode 100644
index 000000000000..f8ca2059d46a
--- /dev/null
+++ b/test/std/language.support/support.limits/limits/numeric.limits.members/has_infinity.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// has_infinity
+
+#include <limits>
+
+template <class T, bool expected>
+void
+test()
+{
+ static_assert(std::numeric_limits<T>::has_infinity == expected, "has_infinity test 1");
+ static_assert(std::numeric_limits<const T>::has_infinity == expected, "has_infinity test 2");
+ static_assert(std::numeric_limits<volatile T>::has_infinity == expected, "has_infinity test 3");
+ static_assert(std::numeric_limits<const volatile T>::has_infinity == expected, "has_infinity test 4");
+}
+
+int main()
+{
+ test<bool, false>();
+ test<char, false>();
+ test<signed char, false>();
+ test<unsigned char, false>();
+ test<wchar_t, false>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<char16_t, false>();
+ test<char32_t, false>();
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<short, false>();
+ test<unsigned short, false>();
+ test<int, false>();
+ test<unsigned int, false>();
+ test<long, false>();
+ test<unsigned long, false>();
+ test<long long, false>();
+ test<unsigned long long, false>();
+#ifndef _LIBCPP_HAS_NO_INT128
+ test<__int128_t, false>();
+ test<__uint128_t, false>();
+#endif
+ test<float, true>();
+ test<double, true>();
+ test<long double, true>();
+}
diff --git a/test/std/language.support/support.limits/limits/numeric.limits.members/has_quiet_NaN.pass.cpp b/test/std/language.support/support.limits/limits/numeric.limits.members/has_quiet_NaN.pass.cpp
new file mode 100644
index 000000000000..7592171695fb
--- /dev/null
+++ b/test/std/language.support/support.limits/limits/numeric.limits.members/has_quiet_NaN.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// has_quiet_NaN
+
+#include <limits>
+
+template <class T, bool expected>
+void
+test()
+{
+ static_assert(std::numeric_limits<T>::has_quiet_NaN == expected, "has_quiet_NaN test 1");
+ static_assert(std::numeric_limits<const T>::has_quiet_NaN == expected, "has_quiet_NaN test 2");
+ static_assert(std::numeric_limits<volatile T>::has_quiet_NaN == expected, "has_quiet_NaN test 3");
+ static_assert(std::numeric_limits<const volatile T>::has_quiet_NaN == expected, "has_quiet_NaN test 4");
+}
+
+int main()
+{
+ test<bool, false>();
+ test<char, false>();
+ test<signed char, false>();
+ test<unsigned char, false>();
+ test<wchar_t, false>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<char16_t, false>();
+ test<char32_t, false>();
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<short, false>();
+ test<unsigned short, false>();
+ test<int, false>();
+ test<unsigned int, false>();
+ test<long, false>();
+ test<unsigned long, false>();
+ test<long long, false>();
+ test<unsigned long long, false>();
+#ifndef _LIBCPP_HAS_NO_INT128
+ test<__int128_t, false>();
+ test<__uint128_t, false>();
+#endif
+ test<float, true>();
+ test<double, true>();
+ test<long double, true>();
+}
diff --git a/test/std/language.support/support.limits/limits/numeric.limits.members/has_signaling_NaN.pass.cpp b/test/std/language.support/support.limits/limits/numeric.limits.members/has_signaling_NaN.pass.cpp
new file mode 100644
index 000000000000..d68cd5d78878
--- /dev/null
+++ b/test/std/language.support/support.limits/limits/numeric.limits.members/has_signaling_NaN.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// has_signaling_NaN
+
+#include <limits>
+
+template <class T, bool expected>
+void
+test()
+{
+ static_assert(std::numeric_limits<T>::has_signaling_NaN == expected, "has_signaling_NaN test 1");
+ static_assert(std::numeric_limits<const T>::has_signaling_NaN == expected, "has_signaling_NaN test 2");
+ static_assert(std::numeric_limits<volatile T>::has_signaling_NaN == expected, "has_signaling_NaN test 3");
+ static_assert(std::numeric_limits<const volatile T>::has_signaling_NaN == expected, "has_signaling_NaN test 4");
+}
+
+int main()
+{
+ test<bool, false>();
+ test<char, false>();
+ test<signed char, false>();
+ test<unsigned char, false>();
+ test<wchar_t, false>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<char16_t, false>();
+ test<char32_t, false>();
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<short, false>();
+ test<unsigned short, false>();
+ test<int, false>();
+ test<unsigned int, false>();
+ test<long, false>();
+ test<unsigned long, false>();
+ test<long long, false>();
+ test<unsigned long long, false>();
+#ifndef _LIBCPP_HAS_NO_INT128
+ test<__int128_t, false>();
+ test<__uint128_t, false>();
+#endif
+ test<float, true>();
+ test<double, true>();
+ test<long double, true>();
+}
diff --git a/test/std/language.support/support.limits/limits/numeric.limits.members/infinity.pass.cpp b/test/std/language.support/support.limits/limits/numeric.limits.members/infinity.pass.cpp
new file mode 100644
index 000000000000..a2ccca333cc6
--- /dev/null
+++ b/test/std/language.support/support.limits/limits/numeric.limits.members/infinity.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// infinity()
+
+#include <limits>
+#include <cfloat>
+#include <cassert>
+
+template <class T>
+void
+test(T expected)
+{
+ assert(std::numeric_limits<T>::infinity() == expected);
+ assert(std::numeric_limits<const T>::infinity() == expected);
+ assert(std::numeric_limits<volatile T>::infinity() == expected);
+ assert(std::numeric_limits<const volatile T>::infinity() == expected);
+}
+
+extern float zero;
+
+int main()
+{
+ test<bool>(false);
+ test<char>(0);
+ test<signed char>(0);
+ test<unsigned char>(0);
+ test<wchar_t>(0);
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<char16_t>(0);
+ test<char32_t>(0);
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<short>(0);
+ test<unsigned short>(0);
+ test<int>(0);
+ test<unsigned int>(0);
+ test<long>(0);
+ test<unsigned long>(0);
+ test<long long>(0);
+ test<unsigned long long>(0);
+#ifndef _LIBCPP_HAS_NO_INT128
+ test<__int128_t>(0);
+ test<__uint128_t>(0);
+#endif
+ test<float>(1./zero);
+ test<double>(1./zero);
+ test<long double>(1./zero);
+}
+
+float zero = 0;
diff --git a/test/std/language.support/support.limits/limits/numeric.limits.members/is_bounded.pass.cpp b/test/std/language.support/support.limits/limits/numeric.limits.members/is_bounded.pass.cpp
new file mode 100644
index 000000000000..fa714d5d1506
--- /dev/null
+++ b/test/std/language.support/support.limits/limits/numeric.limits.members/is_bounded.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// is_bounded
+
+#include <limits>
+
+template <class T, bool expected>
+void
+test()
+{
+ static_assert(std::numeric_limits<T>::is_bounded == expected, "is_bounded test 1");
+ static_assert(std::numeric_limits<const T>::is_bounded == expected, "is_bounded test 2");
+ static_assert(std::numeric_limits<volatile T>::is_bounded == expected, "is_bounded test 3");
+ static_assert(std::numeric_limits<const volatile T>::is_bounded == expected, "is_bounded test 4");
+}
+
+int main()
+{
+ test<bool, true>();
+ test<char, true>();
+ test<signed char, true>();
+ test<unsigned char, true>();
+ test<wchar_t, true>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<char16_t, true>();
+ test<char32_t, true>();
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<short, true>();
+ test<unsigned short, true>();
+ test<int, true>();
+ test<unsigned int, true>();
+ test<long, true>();
+ test<unsigned long, true>();
+ test<long long, true>();
+ test<unsigned long long, true>();
+#ifndef _LIBCPP_HAS_NO_INT128
+ test<__int128_t, true>();
+ test<__uint128_t, true>();
+#endif
+ test<float, true>();
+ test<double, true>();
+ test<long double, true>();
+}
diff --git a/test/std/language.support/support.limits/limits/numeric.limits.members/is_exact.pass.cpp b/test/std/language.support/support.limits/limits/numeric.limits.members/is_exact.pass.cpp
new file mode 100644
index 000000000000..b96a0e7fc5f5
--- /dev/null
+++ b/test/std/language.support/support.limits/limits/numeric.limits.members/is_exact.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// is_exact
+
+#include <limits>
+
+template <class T, bool expected>
+void
+test()
+{
+ static_assert(std::numeric_limits<T>::is_exact == expected, "is_exact test 1");
+ static_assert(std::numeric_limits<const T>::is_exact == expected, "is_exact test 2");
+ static_assert(std::numeric_limits<volatile T>::is_exact == expected, "is_exact test 3");
+ static_assert(std::numeric_limits<const volatile T>::is_exact == expected, "is_exact test 4");
+}
+
+int main()
+{
+ test<bool, true>();
+ test<char, true>();
+ test<signed char, true>();
+ test<unsigned char, true>();
+ test<wchar_t, true>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<char16_t, true>();
+ test<char32_t, true>();
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<short, true>();
+ test<unsigned short, true>();
+ test<int, true>();
+ test<unsigned int, true>();
+ test<long, true>();
+ test<unsigned long, true>();
+ test<long long, true>();
+ test<unsigned long long, true>();
+#ifndef _LIBCPP_HAS_NO_INT128
+ test<__int128_t, true>();
+ test<__uint128_t, true>();
+#endif
+ test<float, false>();
+ test<double, false>();
+ test<long double, false>();
+}
diff --git a/test/std/language.support/support.limits/limits/numeric.limits.members/is_iec559.pass.cpp b/test/std/language.support/support.limits/limits/numeric.limits.members/is_iec559.pass.cpp
new file mode 100644
index 000000000000..4408714c1a1d
--- /dev/null
+++ b/test/std/language.support/support.limits/limits/numeric.limits.members/is_iec559.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// is_iec559
+
+#include <limits>
+
+template <class T, bool expected>
+void
+test()
+{
+ static_assert(std::numeric_limits<T>::is_iec559 == expected, "is_iec559 test 1");
+ static_assert(std::numeric_limits<const T>::is_iec559 == expected, "is_iec559 test 2");
+ static_assert(std::numeric_limits<volatile T>::is_iec559 == expected, "is_iec559 test 3");
+ static_assert(std::numeric_limits<const volatile T>::is_iec559 == expected, "is_iec559 test 4");
+}
+
+int main()
+{
+ test<bool, false>();
+ test<char, false>();
+ test<signed char, false>();
+ test<unsigned char, false>();
+ test<wchar_t, false>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<char16_t, false>();
+ test<char32_t, false>();
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<short, false>();
+ test<unsigned short, false>();
+ test<int, false>();
+ test<unsigned int, false>();
+ test<long, false>();
+ test<unsigned long, false>();
+ test<long long, false>();
+ test<unsigned long long, false>();
+#ifndef _LIBCPP_HAS_NO_INT128
+ test<__int128_t, false>();
+ test<__uint128_t, false>();
+#endif
+ test<float, true>();
+ test<double, true>();
+#if (defined(__ppc__) || defined(__ppc64__))
+ test<long double, false>();
+#else
+ test<long double, true>();
+#endif
+}
diff --git a/test/std/language.support/support.limits/limits/numeric.limits.members/is_integer.pass.cpp b/test/std/language.support/support.limits/limits/numeric.limits.members/is_integer.pass.cpp
new file mode 100644
index 000000000000..79bc5867ec63
--- /dev/null
+++ b/test/std/language.support/support.limits/limits/numeric.limits.members/is_integer.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// is_integer
+
+#include <limits>
+
+template <class T, bool expected>
+void
+test()
+{
+ static_assert(std::numeric_limits<T>::is_integer == expected, "is_integer test 1");
+ static_assert(std::numeric_limits<const T>::is_integer == expected, "is_integer test 2");
+ static_assert(std::numeric_limits<volatile T>::is_integer == expected, "is_integer test 3");
+ static_assert(std::numeric_limits<const volatile T>::is_integer == expected, "is_integer test 4");
+}
+
+int main()
+{
+ test<bool, true>();
+ test<char, true>();
+ test<signed char, true>();
+ test<unsigned char, true>();
+ test<wchar_t, true>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<char16_t, true>();
+ test<char32_t, true>();
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<short, true>();
+ test<unsigned short, true>();
+ test<int, true>();
+ test<unsigned int, true>();
+ test<long, true>();
+ test<unsigned long, true>();
+ test<long long, true>();
+ test<unsigned long long, true>();
+#ifndef _LIBCPP_HAS_NO_INT128
+ test<__int128_t, true>();
+ test<__uint128_t, true>();
+#endif
+ test<float, false>();
+ test<double, false>();
+ test<long double, false>();
+}
diff --git a/test/std/language.support/support.limits/limits/numeric.limits.members/is_modulo.pass.cpp b/test/std/language.support/support.limits/limits/numeric.limits.members/is_modulo.pass.cpp
new file mode 100644
index 000000000000..6a609963d04c
--- /dev/null
+++ b/test/std/language.support/support.limits/limits/numeric.limits.members/is_modulo.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// is_modulo
+
+#include <limits>
+
+template <class T, bool expected>
+void
+test()
+{
+ static_assert(std::numeric_limits<T>::is_modulo == expected, "is_modulo test 1");
+ static_assert(std::numeric_limits<const T>::is_modulo == expected, "is_modulo test 2");
+ static_assert(std::numeric_limits<volatile T>::is_modulo == expected, "is_modulo test 3");
+ static_assert(std::numeric_limits<const volatile T>::is_modulo == expected, "is_modulo test 4");
+}
+
+int main()
+{
+ test<bool, false>();
+// test<char, false>(); // don't know
+ test<signed char, false>();
+ test<unsigned char, true>();
+// test<wchar_t, false>(); // don't know
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<char16_t, true>();
+ test<char32_t, true>();
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<short, false>();
+ test<unsigned short, true>();
+ test<int, false>();
+ test<unsigned int, true>();
+ test<long, false>();
+ test<unsigned long, true>();
+ test<long long, false>();
+ test<unsigned long long, true>();
+#ifndef _LIBCPP_HAS_NO_INT128
+ test<__int128_t, false>();
+ test<__uint128_t, true>();
+#endif
+ test<float, false>();
+ test<double, false>();
+ test<long double, false>();
+}
diff --git a/test/std/language.support/support.limits/limits/numeric.limits.members/is_signed.pass.cpp b/test/std/language.support/support.limits/limits/numeric.limits.members/is_signed.pass.cpp
new file mode 100644
index 000000000000..28570fd22790
--- /dev/null
+++ b/test/std/language.support/support.limits/limits/numeric.limits.members/is_signed.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// is_signed
+
+#include <limits>
+
+template <class T, bool expected>
+void
+test()
+{
+ static_assert(std::numeric_limits<T>::is_signed == expected, "is_signed test 1");
+ static_assert(std::numeric_limits<const T>::is_signed == expected, "is_signed test 2");
+ static_assert(std::numeric_limits<volatile T>::is_signed == expected, "is_signed test 3");
+ static_assert(std::numeric_limits<const volatile T>::is_signed == expected, "is_signed test 4");
+}
+
+int main()
+{
+ test<bool, false>();
+ test<char, char(-1) < char(0)>();
+ test<signed char, true>();
+ test<unsigned char, false>();
+ test<wchar_t, wchar_t(-1) < wchar_t(0)>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<char16_t, false>();
+ test<char32_t, false>();
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<short, true>();
+ test<unsigned short, false>();
+ test<int, true>();
+ test<unsigned int, false>();
+ test<long, true>();
+ test<unsigned long, false>();
+ test<long long, true>();
+ test<unsigned long long, false>();
+#ifndef _LIBCPP_HAS_NO_INT128
+ test<__int128_t, true>();
+ test<__uint128_t, false>();
+#endif
+ test<float, true>();
+ test<double, true>();
+ test<long double, true>();
+}
diff --git a/test/std/language.support/support.limits/limits/numeric.limits.members/lowest.pass.cpp b/test/std/language.support/support.limits/limits/numeric.limits.members/lowest.pass.cpp
new file mode 100644
index 000000000000..21090aa9c4c1
--- /dev/null
+++ b/test/std/language.support/support.limits/limits/numeric.limits.members/lowest.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// lowest()
+
+#include <limits>
+#include <climits>
+#include <cwchar>
+#include <cfloat>
+#include <cassert>
+
+template <class T>
+void
+test(T expected)
+{
+ assert(std::numeric_limits<T>::lowest() == expected);
+ assert(std::numeric_limits<T>::is_bounded);
+ assert(std::numeric_limits<const T>::lowest() == expected);
+ assert(std::numeric_limits<const T>::is_bounded);
+ assert(std::numeric_limits<volatile T>::lowest() == expected);
+ assert(std::numeric_limits<volatile T>::is_bounded);
+ assert(std::numeric_limits<const volatile T>::lowest() == expected);
+ assert(std::numeric_limits<const volatile T>::is_bounded);
+}
+
+int main()
+{
+ test<bool>(false);
+ test<char>(CHAR_MIN);
+ test<signed char>(SCHAR_MIN);
+ test<unsigned char>(0);
+ test<wchar_t>(WCHAR_MIN);
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<char16_t>(0);
+ test<char32_t>(0);
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<short>(SHRT_MIN);
+ test<unsigned short>(0);
+ test<int>(INT_MIN);
+ test<unsigned int>(0);
+ test<long>(LONG_MIN);
+ test<unsigned long>(0);
+ test<long long>(LLONG_MIN);
+ test<unsigned long long>(0);
+#ifndef _LIBCPP_HAS_NO_INT128
+ test<__int128_t>(-__int128_t(__uint128_t(-1)/2) - 1);
+ test<__uint128_t>(0);
+#endif
+ test<float>(-FLT_MAX);
+ test<double>(-DBL_MAX);
+ test<long double>(-LDBL_MAX);
+}
diff --git a/test/std/language.support/support.limits/limits/numeric.limits.members/max.pass.cpp b/test/std/language.support/support.limits/limits/numeric.limits.members/max.pass.cpp
new file mode 100644
index 000000000000..7517aaa192c1
--- /dev/null
+++ b/test/std/language.support/support.limits/limits/numeric.limits.members/max.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// max()
+
+#include <limits>
+#include <climits>
+#include <cwchar>
+#include <cfloat>
+#include <cassert>
+
+template <class T>
+void
+test(T expected)
+{
+ assert(std::numeric_limits<T>::max() == expected);
+ assert(std::numeric_limits<T>::is_bounded);
+ assert(std::numeric_limits<const T>::max() == expected);
+ assert(std::numeric_limits<const T>::is_bounded);
+ assert(std::numeric_limits<volatile T>::max() == expected);
+ assert(std::numeric_limits<volatile T>::is_bounded);
+ assert(std::numeric_limits<const volatile T>::max() == expected);
+ assert(std::numeric_limits<const volatile T>::is_bounded);
+}
+
+int main()
+{
+ test<bool>(true);
+ test<char>(CHAR_MAX);
+ test<signed char>(SCHAR_MAX);
+ test<unsigned char>(UCHAR_MAX);
+ test<wchar_t>(WCHAR_MAX);
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<char16_t>(USHRT_MAX);
+ test<char32_t>(UINT_MAX);
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<short>(SHRT_MAX);
+ test<unsigned short>(USHRT_MAX);
+ test<int>(INT_MAX);
+ test<unsigned int>(UINT_MAX);
+ test<long>(LONG_MAX);
+ test<unsigned long>(ULONG_MAX);
+ test<long long>(LLONG_MAX);
+ test<unsigned long long>(ULLONG_MAX);
+#ifndef _LIBCPP_HAS_NO_INT128
+ test<__int128_t>(__int128_t(__uint128_t(-1)/2));
+ test<__uint128_t>(__uint128_t(-1));
+#endif
+ test<float>(FLT_MAX);
+ test<double>(DBL_MAX);
+ test<long double>(LDBL_MAX);
+}
diff --git a/test/std/language.support/support.limits/limits/numeric.limits.members/max_digits10.pass.cpp b/test/std/language.support/support.limits/limits/numeric.limits.members/max_digits10.pass.cpp
new file mode 100644
index 000000000000..de771ebe3b42
--- /dev/null
+++ b/test/std/language.support/support.limits/limits/numeric.limits.members/max_digits10.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// max_digits10
+
+#include <limits>
+#include <cfloat>
+
+template <class T, int expected>
+void
+test()
+{
+ static_assert(std::numeric_limits<T>::max_digits10 == expected, "max_digits10 test 1");
+ static_assert(std::numeric_limits<const T>::max_digits10 == expected, "max_digits10 test 2");
+ static_assert(std::numeric_limits<volatile T>::max_digits10 == expected, "max_digits10 test 3");
+ static_assert(std::numeric_limits<const volatile T>::max_digits10 == expected, "max_digits10 test 4");
+}
+
+int main()
+{
+ test<bool, 0>();
+ test<char, 0>();
+ test<signed char, 0>();
+ test<unsigned char, 0>();
+ test<wchar_t, 0>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<char16_t, 0>();
+ test<char32_t, 0>();
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<short, 0>();
+ test<unsigned short, 0>();
+ test<int, 0>();
+ test<unsigned int, 0>();
+ test<long, 0>();
+ test<unsigned long, 0>();
+ test<long long, 0>();
+ test<unsigned long long, 0>();
+#ifndef _LIBCPP_HAS_NO_INT128
+ test<__int128_t, 0>();
+ test<__uint128_t, 0>();
+#endif
+ test<float, 2+(FLT_MANT_DIG * 30103)/100000>();
+ test<double, 2+(DBL_MANT_DIG * 30103)/100000>();
+ test<long double, 2+(LDBL_MANT_DIG * 30103)/100000>();
+}
diff --git a/test/std/language.support/support.limits/limits/numeric.limits.members/max_exponent.pass.cpp b/test/std/language.support/support.limits/limits/numeric.limits.members/max_exponent.pass.cpp
new file mode 100644
index 000000000000..6b61f7ba4331
--- /dev/null
+++ b/test/std/language.support/support.limits/limits/numeric.limits.members/max_exponent.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// max_exponent
+
+#include <limits>
+#include <cfloat>
+
+template <class T, int expected>
+void
+test()
+{
+ static_assert(std::numeric_limits<T>::max_exponent == expected, "max_exponent test 1");
+ static_assert(std::numeric_limits<const T>::max_exponent == expected, "max_exponent test 2");
+ static_assert(std::numeric_limits<volatile T>::max_exponent == expected, "max_exponent test 3");
+ static_assert(std::numeric_limits<const volatile T>::max_exponent == expected, "max_exponent test 4");
+}
+
+int main()
+{
+ test<bool, 0>();
+ test<char, 0>();
+ test<signed char, 0>();
+ test<unsigned char, 0>();
+ test<wchar_t, 0>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<char16_t, 0>();
+ test<char32_t, 0>();
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<short, 0>();
+ test<unsigned short, 0>();
+ test<int, 0>();
+ test<unsigned int, 0>();
+ test<long, 0>();
+ test<unsigned long, 0>();
+ test<long long, 0>();
+ test<unsigned long long, 0>();
+#ifndef _LIBCPP_HAS_NO_INT128
+ test<__int128_t, 0>();
+ test<__uint128_t, 0>();
+#endif
+ test<float, FLT_MAX_EXP>();
+ test<double, DBL_MAX_EXP>();
+ test<long double, LDBL_MAX_EXP>();
+}
diff --git a/test/std/language.support/support.limits/limits/numeric.limits.members/max_exponent10.pass.cpp b/test/std/language.support/support.limits/limits/numeric.limits.members/max_exponent10.pass.cpp
new file mode 100644
index 000000000000..927585e9468b
--- /dev/null
+++ b/test/std/language.support/support.limits/limits/numeric.limits.members/max_exponent10.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// max_exponent10
+
+#include <limits>
+#include <cfloat>
+
+template <class T, int expected>
+void
+test()
+{
+ static_assert(std::numeric_limits<T>::max_exponent10 == expected, "max_exponent10 test 1");
+ static_assert(std::numeric_limits<const T>::max_exponent10 == expected, "max_exponent10 test 2");
+ static_assert(std::numeric_limits<volatile T>::max_exponent10 == expected, "max_exponent10 test 3");
+ static_assert(std::numeric_limits<const volatile T>::max_exponent10 == expected, "max_exponent10 test 4");
+}
+
+int main()
+{
+ test<bool, 0>();
+ test<char, 0>();
+ test<signed char, 0>();
+ test<unsigned char, 0>();
+ test<wchar_t, 0>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<char16_t, 0>();
+ test<char32_t, 0>();
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<short, 0>();
+ test<unsigned short, 0>();
+ test<int, 0>();
+ test<unsigned int, 0>();
+ test<long, 0>();
+ test<unsigned long, 0>();
+ test<long long, 0>();
+ test<unsigned long long, 0>();
+#ifndef _LIBCPP_HAS_NO_INT128
+ test<__int128_t, 0>();
+ test<__uint128_t, 0>();
+#endif
+ test<float, FLT_MAX_10_EXP>();
+ test<double, DBL_MAX_10_EXP>();
+ test<long double, LDBL_MAX_10_EXP>();
+}
diff --git a/test/std/language.support/support.limits/limits/numeric.limits.members/min.pass.cpp b/test/std/language.support/support.limits/limits/numeric.limits.members/min.pass.cpp
new file mode 100644
index 000000000000..e72fbba10512
--- /dev/null
+++ b/test/std/language.support/support.limits/limits/numeric.limits.members/min.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// min()
+
+#include <limits>
+#include <climits>
+#include <cwchar>
+#include <cfloat>
+#include <cassert>
+
+template <class T>
+void
+test(T expected)
+{
+ assert(std::numeric_limits<T>::min() == expected);
+ assert(std::numeric_limits<T>::is_bounded || !std::numeric_limits<T>::is_signed);
+ assert(std::numeric_limits<const T>::min() == expected);
+ assert(std::numeric_limits<const T>::is_bounded || !std::numeric_limits<const T>::is_signed);
+ assert(std::numeric_limits<volatile T>::min() == expected);
+ assert(std::numeric_limits<volatile T>::is_bounded || !std::numeric_limits<volatile T>::is_signed);
+ assert(std::numeric_limits<const volatile T>::min() == expected);
+ assert(std::numeric_limits<const volatile T>::is_bounded || !std::numeric_limits<const volatile T>::is_signed);
+}
+
+int main()
+{
+ test<bool>(false);
+ test<char>(CHAR_MIN);
+ test<signed char>(SCHAR_MIN);
+ test<unsigned char>(0);
+ test<wchar_t>(WCHAR_MIN);
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<char16_t>(0);
+ test<char32_t>(0);
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<short>(SHRT_MIN);
+ test<unsigned short>(0);
+ test<int>(INT_MIN);
+ test<unsigned int>(0);
+ test<long>(LONG_MIN);
+ test<unsigned long>(0);
+ test<long long>(LLONG_MIN);
+ test<unsigned long long>(0);
+#ifndef _LIBCPP_HAS_NO_INT128
+ test<__int128_t>(-__int128_t(__uint128_t(-1)/2) - 1);
+ test<__uint128_t>(0);
+#endif
+ test<float>(FLT_MIN);
+ test<double>(DBL_MIN);
+ test<long double>(LDBL_MIN);
+}
diff --git a/test/std/language.support/support.limits/limits/numeric.limits.members/min_exponent.pass.cpp b/test/std/language.support/support.limits/limits/numeric.limits.members/min_exponent.pass.cpp
new file mode 100644
index 000000000000..245e8441499d
--- /dev/null
+++ b/test/std/language.support/support.limits/limits/numeric.limits.members/min_exponent.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// min_exponent
+
+#include <limits>
+#include <cfloat>
+
+template <class T, int expected>
+void
+test()
+{
+ static_assert(std::numeric_limits<T>::min_exponent == expected, "min_exponent test 1");
+ static_assert(std::numeric_limits<const T>::min_exponent == expected, "min_exponent test 2");
+ static_assert(std::numeric_limits<volatile T>::min_exponent == expected, "min_exponent test 3");
+ static_assert(std::numeric_limits<const volatile T>::min_exponent == expected, "min_exponent test 4");
+}
+
+int main()
+{
+ test<bool, 0>();
+ test<char, 0>();
+ test<signed char, 0>();
+ test<unsigned char, 0>();
+ test<wchar_t, 0>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<char16_t, 0>();
+ test<char32_t, 0>();
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<short, 0>();
+ test<unsigned short, 0>();
+ test<int, 0>();
+ test<unsigned int, 0>();
+ test<long, 0>();
+ test<unsigned long, 0>();
+ test<long long, 0>();
+ test<unsigned long long, 0>();
+#ifndef _LIBCPP_HAS_NO_INT128
+ test<__int128_t, 0>();
+ test<__uint128_t, 0>();
+#endif
+ test<float, FLT_MIN_EXP>();
+ test<double, DBL_MIN_EXP>();
+ test<long double, LDBL_MIN_EXP>();
+}
diff --git a/test/std/language.support/support.limits/limits/numeric.limits.members/min_exponent10.pass.cpp b/test/std/language.support/support.limits/limits/numeric.limits.members/min_exponent10.pass.cpp
new file mode 100644
index 000000000000..b54d46fd52e8
--- /dev/null
+++ b/test/std/language.support/support.limits/limits/numeric.limits.members/min_exponent10.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// min_exponent10
+
+#include <limits>
+#include <cfloat>
+
+template <class T, int expected>
+void
+test()
+{
+ static_assert(std::numeric_limits<T>::min_exponent10 == expected, "min_exponent10 test 1");
+ static_assert(std::numeric_limits<const T>::min_exponent10 == expected, "min_exponent10 test 2");
+ static_assert(std::numeric_limits<volatile T>::min_exponent10 == expected, "min_exponent10 test 3");
+ static_assert(std::numeric_limits<const volatile T>::min_exponent10 == expected, "min_exponent10 test 4");
+}
+
+int main()
+{
+ test<bool, 0>();
+ test<char, 0>();
+ test<signed char, 0>();
+ test<unsigned char, 0>();
+ test<wchar_t, 0>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<char16_t, 0>();
+ test<char32_t, 0>();
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<short, 0>();
+ test<unsigned short, 0>();
+ test<int, 0>();
+ test<unsigned int, 0>();
+ test<long, 0>();
+ test<unsigned long, 0>();
+ test<long long, 0>();
+ test<unsigned long long, 0>();
+#ifndef _LIBCPP_HAS_NO_INT128
+ test<__int128_t, 0>();
+ test<__uint128_t, 0>();
+#endif
+ test<float, FLT_MIN_10_EXP>();
+ test<double, DBL_MIN_10_EXP>();
+ test<long double, LDBL_MIN_10_EXP>();
+}
diff --git a/test/std/language.support/support.limits/limits/numeric.limits.members/quiet_NaN.pass.cpp b/test/std/language.support/support.limits/limits/numeric.limits.members/quiet_NaN.pass.cpp
new file mode 100644
index 000000000000..97166f0c3209
--- /dev/null
+++ b/test/std/language.support/support.limits/limits/numeric.limits.members/quiet_NaN.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// quiet_NaN()
+
+#include <limits>
+#include <cmath>
+#include <type_traits>
+#include <cassert>
+
+template <class T>
+void
+test_imp(std::true_type)
+{
+ assert(std::isnan(std::numeric_limits<T>::quiet_NaN()));
+ assert(std::isnan(std::numeric_limits<const T>::quiet_NaN()));
+ assert(std::isnan(std::numeric_limits<volatile T>::quiet_NaN()));
+ assert(std::isnan(std::numeric_limits<const volatile T>::quiet_NaN()));
+}
+
+template <class T>
+void
+test_imp(std::false_type)
+{
+ assert(std::numeric_limits<T>::quiet_NaN() == T());
+ assert(std::numeric_limits<const T>::quiet_NaN() == T());
+ assert(std::numeric_limits<volatile T>::quiet_NaN() == T());
+ assert(std::numeric_limits<const volatile T>::quiet_NaN() == T());
+}
+
+template <class T>
+inline
+void
+test()
+{
+ test_imp<T>(std::is_floating_point<T>());
+}
+
+int main()
+{
+ test<bool>();
+ test<char>();
+ test<signed char>();
+ test<unsigned char>();
+ test<wchar_t>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<char16_t>();
+ test<char32_t>();
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<short>();
+ test<unsigned short>();
+ test<int>();
+ test<unsigned int>();
+ test<long>();
+ test<unsigned long>();
+ test<long long>();
+ test<unsigned long long>();
+#ifndef _LIBCPP_HAS_NO_INT128
+ test<__int128_t>();
+ test<__uint128_t>();
+#endif
+ test<float>();
+ test<double>();
+ test<long double>();
+}
diff --git a/test/std/language.support/support.limits/limits/numeric.limits.members/radix.pass.cpp b/test/std/language.support/support.limits/limits/numeric.limits.members/radix.pass.cpp
new file mode 100644
index 000000000000..98a2a53d192e
--- /dev/null
+++ b/test/std/language.support/support.limits/limits/numeric.limits.members/radix.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// radix
+
+#include <limits>
+#include <cfloat>
+
+template <class T, int expected>
+void
+test()
+{
+ static_assert(std::numeric_limits<T>::radix == expected, "radix test 1");
+ static_assert(std::numeric_limits<const T>::radix == expected, "radix test 2");
+ static_assert(std::numeric_limits<volatile T>::radix == expected, "radix test 3");
+ static_assert(std::numeric_limits<const volatile T>::radix == expected, "radix test 4");
+}
+
+int main()
+{
+ test<bool, 2>();
+ test<char, 2>();
+ test<signed char, 2>();
+ test<unsigned char, 2>();
+ test<wchar_t, 2>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<char16_t, 2>();
+ test<char32_t, 2>();
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<short, 2>();
+ test<unsigned short, 2>();
+ test<int, 2>();
+ test<unsigned int, 2>();
+ test<long, 2>();
+ test<unsigned long, 2>();
+ test<long long, 2>();
+ test<unsigned long long, 2>();
+#ifndef _LIBCPP_HAS_NO_INT128
+ test<__int128_t, 2>();
+ test<__uint128_t, 2>();
+#endif
+ test<float, FLT_RADIX>();
+ test<double, FLT_RADIX>();
+ test<long double, FLT_RADIX>();
+}
diff --git a/test/std/language.support/support.limits/limits/numeric.limits.members/round_error.pass.cpp b/test/std/language.support/support.limits/limits/numeric.limits.members/round_error.pass.cpp
new file mode 100644
index 000000000000..5da5c9513a86
--- /dev/null
+++ b/test/std/language.support/support.limits/limits/numeric.limits.members/round_error.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// round_error()
+
+#include <limits>
+#include <cfloat>
+#include <cassert>
+
+template <class T>
+void
+test(T expected)
+{
+ assert(std::numeric_limits<T>::round_error() == expected);
+ assert(std::numeric_limits<const T>::round_error() == expected);
+ assert(std::numeric_limits<volatile T>::round_error() == expected);
+ assert(std::numeric_limits<const volatile T>::round_error() == expected);
+}
+
+int main()
+{
+ test<bool>(false);
+ test<char>(0);
+ test<signed char>(0);
+ test<unsigned char>(0);
+ test<wchar_t>(0);
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<char16_t>(0);
+ test<char32_t>(0);
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<short>(0);
+ test<unsigned short>(0);
+ test<int>(0);
+ test<unsigned int>(0);
+ test<long>(0);
+ test<unsigned long>(0);
+ test<long long>(0);
+ test<unsigned long long>(0);
+#ifndef _LIBCPP_HAS_NO_INT128
+ test<__int128_t>(0);
+ test<__uint128_t>(0);
+#endif
+ test<float>(0.5);
+ test<double>(0.5);
+ test<long double>(0.5);
+}
diff --git a/test/std/language.support/support.limits/limits/numeric.limits.members/round_style.pass.cpp b/test/std/language.support/support.limits/limits/numeric.limits.members/round_style.pass.cpp
new file mode 100644
index 000000000000..645f6f7df76a
--- /dev/null
+++ b/test/std/language.support/support.limits/limits/numeric.limits.members/round_style.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// round_style
+
+#include <limits>
+
+template <class T, std::float_round_style expected>
+void
+test()
+{
+ static_assert(std::numeric_limits<T>::round_style == expected, "round_style test 1");
+ static_assert(std::numeric_limits<const T>::round_style == expected, "round_style test 2");
+ static_assert(std::numeric_limits<volatile T>::round_style == expected, "round_style test 3");
+ static_assert(std::numeric_limits<const volatile T>::round_style == expected, "round_style test 4");
+}
+
+int main()
+{
+ test<bool, std::round_toward_zero>();
+ test<char, std::round_toward_zero>();
+ test<signed char, std::round_toward_zero>();
+ test<unsigned char, std::round_toward_zero>();
+ test<wchar_t, std::round_toward_zero>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<char16_t, std::round_toward_zero>();
+ test<char32_t, std::round_toward_zero>();
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<short, std::round_toward_zero>();
+ test<unsigned short, std::round_toward_zero>();
+ test<int, std::round_toward_zero>();
+ test<unsigned int, std::round_toward_zero>();
+ test<long, std::round_toward_zero>();
+ test<unsigned long, std::round_toward_zero>();
+ test<long long, std::round_toward_zero>();
+ test<unsigned long long, std::round_toward_zero>();
+#ifndef _LIBCPP_HAS_NO_INT128
+ test<__int128_t, std::round_toward_zero>();
+ test<__uint128_t, std::round_toward_zero>();
+#endif
+ test<float, std::round_to_nearest>();
+ test<double, std::round_to_nearest>();
+ test<long double, std::round_to_nearest>();
+}
diff --git a/test/std/language.support/support.limits/limits/numeric.limits.members/signaling_NaN.pass.cpp b/test/std/language.support/support.limits/limits/numeric.limits.members/signaling_NaN.pass.cpp
new file mode 100644
index 000000000000..d9df999ddb70
--- /dev/null
+++ b/test/std/language.support/support.limits/limits/numeric.limits.members/signaling_NaN.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// signaling_NaN()
+
+#include <limits>
+#include <cmath>
+#include <type_traits>
+#include <cassert>
+
+template <class T>
+void
+test_imp(std::true_type)
+{
+ assert(std::isnan(std::numeric_limits<T>::signaling_NaN()));
+ assert(std::isnan(std::numeric_limits<const T>::signaling_NaN()));
+ assert(std::isnan(std::numeric_limits<volatile T>::signaling_NaN()));
+ assert(std::isnan(std::numeric_limits<const volatile T>::signaling_NaN()));
+}
+
+template <class T>
+void
+test_imp(std::false_type)
+{
+ assert(std::numeric_limits<T>::signaling_NaN() == T());
+ assert(std::numeric_limits<const T>::signaling_NaN() == T());
+ assert(std::numeric_limits<volatile T>::signaling_NaN() == T());
+ assert(std::numeric_limits<const volatile T>::signaling_NaN() == T());
+}
+
+template <class T>
+inline
+void
+test()
+{
+ test_imp<T>(std::is_floating_point<T>());
+}
+
+int main()
+{
+ test<bool>();
+ test<char>();
+ test<signed char>();
+ test<unsigned char>();
+ test<wchar_t>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<char16_t>();
+ test<char32_t>();
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<short>();
+ test<unsigned short>();
+ test<int>();
+ test<unsigned int>();
+ test<long>();
+ test<unsigned long>();
+ test<long long>();
+ test<unsigned long long>();
+#ifndef _LIBCPP_HAS_NO_INT128
+ test<__int128_t>();
+ test<__uint128_t>();
+#endif
+ test<float>();
+ test<double>();
+ test<long double>();
+}
diff --git a/test/std/language.support/support.limits/limits/numeric.limits.members/tinyness_before.pass.cpp b/test/std/language.support/support.limits/limits/numeric.limits.members/tinyness_before.pass.cpp
new file mode 100644
index 000000000000..9e2a8431a4e0
--- /dev/null
+++ b/test/std/language.support/support.limits/limits/numeric.limits.members/tinyness_before.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// tinyness_before
+
+#include <limits>
+
+template <class T, bool expected>
+void
+test()
+{
+ static_assert(std::numeric_limits<T>::tinyness_before == expected, "tinyness_before test 1");
+ static_assert(std::numeric_limits<const T>::tinyness_before == expected, "tinyness_before test 2");
+ static_assert(std::numeric_limits<volatile T>::tinyness_before == expected, "tinyness_before test 3");
+ static_assert(std::numeric_limits<const volatile T>::tinyness_before == expected, "tinyness_before test 4");
+}
+
+int main()
+{
+ test<bool, false>();
+ test<char, false>();
+ test<signed char, false>();
+ test<unsigned char, false>();
+ test<wchar_t, false>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<char16_t, false>();
+ test<char32_t, false>();
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<short, false>();
+ test<unsigned short, false>();
+ test<int, false>();
+ test<unsigned int, false>();
+ test<long, false>();
+ test<unsigned long, false>();
+ test<long long, false>();
+ test<unsigned long long, false>();
+#ifndef _LIBCPP_HAS_NO_INT128
+ test<__int128_t, false>();
+ test<__uint128_t, false>();
+#endif
+ test<float, false>();
+ test<double, false>();
+ test<long double, false>();
+}
diff --git a/test/std/language.support/support.limits/limits/numeric.limits.members/traps.pass.cpp b/test/std/language.support/support.limits/limits/numeric.limits.members/traps.pass.cpp
new file mode 100644
index 000000000000..af93e78c0e91
--- /dev/null
+++ b/test/std/language.support/support.limits/limits/numeric.limits.members/traps.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// traps
+
+#include <limits>
+
+#if defined(__i386__) || defined(__x86_64__) || defined(__pnacl__)
+static const bool integral_types_trap = true;
+#else
+static const bool integral_types_trap = false;
+#endif
+
+template <class T, bool expected>
+void
+test()
+{
+ static_assert(std::numeric_limits<T>::traps == expected, "traps test 1");
+ static_assert(std::numeric_limits<const T>::traps == expected, "traps test 2");
+ static_assert(std::numeric_limits<volatile T>::traps == expected, "traps test 3");
+ static_assert(std::numeric_limits<const volatile T>::traps == expected, "traps test 4");
+}
+
+int main()
+{
+ test<bool, false>();
+ test<char, integral_types_trap>();
+ test<signed char, integral_types_trap>();
+ test<unsigned char, integral_types_trap>();
+ test<wchar_t, integral_types_trap>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<char16_t, integral_types_trap>();
+ test<char32_t, integral_types_trap>();
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<short, integral_types_trap>();
+ test<unsigned short, integral_types_trap>();
+ test<int, integral_types_trap>();
+ test<unsigned int, integral_types_trap>();
+ test<long, integral_types_trap>();
+ test<unsigned long, integral_types_trap>();
+ test<long long, integral_types_trap>();
+ test<unsigned long long, integral_types_trap>();
+#ifndef _LIBCPP_HAS_NO_INT128
+ test<__int128_t, integral_types_trap>();
+ test<__uint128_t, integral_types_trap>();
+#endif
+ test<float, false>();
+ test<double, false>();
+ test<long double, false>();
+}
diff --git a/test/std/language.support/support.limits/limits/numeric.limits/default.pass.cpp b/test/std/language.support/support.limits/limits/numeric.limits/default.pass.cpp
new file mode 100644
index 000000000000..6cf5681d82ba
--- /dev/null
+++ b/test/std/language.support/support.limits/limits/numeric.limits/default.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// The default numeric_limits<T> template shall have all members, but with
+// 0 or false values.
+
+#include <limits>
+#include <cassert>
+
+struct A
+{
+ A(int i = 0) : data_(i) {}
+ int data_;
+};
+
+bool operator == (const A& x, const A& y) {return x.data_ == y.data_;}
+
+int main()
+{
+ static_assert(std::numeric_limits<A>::is_specialized == false,
+ "std::numeric_limits<A>::is_specialized == false");
+ assert(std::numeric_limits<A>::min() == A());
+ assert(std::numeric_limits<A>::max() == A());
+ assert(std::numeric_limits<A>::lowest() == A());
+ static_assert(std::numeric_limits<A>::digits == 0,
+ "std::numeric_limits<A>::digits == 0");
+ static_assert(std::numeric_limits<A>::digits10 == 0,
+ "std::numeric_limits<A>::digits10 == 0");
+ static_assert(std::numeric_limits<A>::max_digits10 == 0,
+ "std::numeric_limits<A>::max_digits10 == 0");
+ static_assert(std::numeric_limits<A>::is_signed == false,
+ "std::numeric_limits<A>::is_signed == false");
+ static_assert(std::numeric_limits<A>::is_integer == false,
+ "std::numeric_limits<A>::is_integer == false");
+ static_assert(std::numeric_limits<A>::is_exact == false,
+ "std::numeric_limits<A>::is_exact == false");
+ static_assert(std::numeric_limits<A>::radix == 0,
+ "std::numeric_limits<A>::radix == 0");
+ assert(std::numeric_limits<A>::epsilon() == A());
+ assert(std::numeric_limits<A>::round_error() == A());
+ static_assert(std::numeric_limits<A>::min_exponent == 0,
+ "std::numeric_limits<A>::min_exponent == 0");
+ static_assert(std::numeric_limits<A>::min_exponent10 == 0,
+ "std::numeric_limits<A>::min_exponent10 == 0");
+ static_assert(std::numeric_limits<A>::max_exponent == 0,
+ "std::numeric_limits<A>::max_exponent == 0");
+ static_assert(std::numeric_limits<A>::max_exponent10 == 0,
+ "std::numeric_limits<A>::max_exponent10 == 0");
+ static_assert(std::numeric_limits<A>::has_infinity == false,
+ "std::numeric_limits<A>::has_infinity == false");
+ static_assert(std::numeric_limits<A>::has_quiet_NaN == false,
+ "std::numeric_limits<A>::has_quiet_NaN == false");
+ static_assert(std::numeric_limits<A>::has_signaling_NaN == false,
+ "std::numeric_limits<A>::has_signaling_NaN == false");
+ static_assert(std::numeric_limits<A>::has_denorm == std::denorm_absent,
+ "std::numeric_limits<A>::has_denorm == std::denorm_absent");
+ static_assert(std::numeric_limits<A>::has_denorm_loss == false,
+ "std::numeric_limits<A>::has_denorm_loss == false");
+ assert(std::numeric_limits<A>::infinity() == A());
+ assert(std::numeric_limits<A>::quiet_NaN() == A());
+ assert(std::numeric_limits<A>::signaling_NaN() == A());
+ assert(std::numeric_limits<A>::denorm_min() == A());
+ static_assert(std::numeric_limits<A>::is_iec559 == false,
+ "std::numeric_limits<A>::is_iec559 == false");
+ static_assert(std::numeric_limits<A>::is_bounded == false,
+ "std::numeric_limits<A>::is_bounded == false");
+ static_assert(std::numeric_limits<A>::is_modulo == false,
+ "std::numeric_limits<A>::is_modulo == false");
+ static_assert(std::numeric_limits<A>::traps == false,
+ "std::numeric_limits<A>::traps == false");
+ static_assert(std::numeric_limits<A>::tinyness_before == false,
+ "std::numeric_limits<A>::tinyness_before == false");
+ static_assert(std::numeric_limits<A>::round_style == std::round_toward_zero,
+ "std::numeric_limits<A>::round_style == std::round_toward_zero");
+}
diff --git a/test/std/language.support/support.limits/limits/numeric.special/nothing_to_do.pass.cpp b/test/std/language.support/support.limits/limits/numeric.special/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/language.support/support.limits/limits/numeric.special/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/language.support/support.limits/limits/round.style/check_values.pass.cpp b/test/std/language.support/support.limits/limits/round.style/check_values.pass.cpp
new file mode 100644
index 000000000000..d6c70c4cf230
--- /dev/null
+++ b/test/std/language.support/support.limits/limits/round.style/check_values.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// float_denorm_style
+
+#include <limits>
+
+typedef char one;
+struct two {one _[2];};
+
+one test(std::float_denorm_style);
+two test(int);
+
+int main()
+{
+ static_assert(std::denorm_indeterminate == -1,
+ "std::denorm_indeterminate == -1");
+ static_assert(std::denorm_absent == 0,
+ "std::denorm_absent == 0");
+ static_assert(std::denorm_present == 1,
+ "std::denorm_present == 1");
+ static_assert(sizeof(test(std::denorm_present)) == 1,
+ "sizeof(test(std::denorm_present)) == 1");
+ static_assert(sizeof(test(1)) == 2,
+ "sizeof(test(1)) == 2");
+}
diff --git a/test/std/language.support/support.limits/limits/version.pass.cpp b/test/std/language.support/support.limits/limits/version.pass.cpp
new file mode 100644
index 000000000000..0cb3f6f52a4e
--- /dev/null
+++ b/test/std/language.support/support.limits/limits/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <limits>
+
+#include <limits>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/language.support/support.limits/nothing_to_do.pass.cpp b/test/std/language.support/support.limits/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/language.support/support.limits/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/language.support/support.rtti/bad.cast/bad_cast.pass.cpp b/test/std/language.support/support.rtti/bad.cast/bad_cast.pass.cpp
new file mode 100644
index 000000000000..448ffba2c2bd
--- /dev/null
+++ b/test/std/language.support/support.rtti/bad.cast/bad_cast.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test bad_cast
+
+#include <typeinfo>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+ static_assert((std::is_base_of<std::exception, std::bad_cast>::value),
+ "std::is_base_of<std::exception, std::bad_cast>::value");
+ static_assert(std::is_polymorphic<std::bad_cast>::value,
+ "std::is_polymorphic<std::bad_cast>::value");
+ std::bad_cast b;
+ std::bad_cast b2 = b;
+ b2 = b;
+ const char* w = b2.what();
+ assert(w);
+}
diff --git a/test/std/language.support/support.rtti/bad.typeid/bad_typeid.pass.cpp b/test/std/language.support/support.rtti/bad.typeid/bad_typeid.pass.cpp
new file mode 100644
index 000000000000..190aebe54970
--- /dev/null
+++ b/test/std/language.support/support.rtti/bad.typeid/bad_typeid.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test bad_typeid
+
+#include <typeinfo>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+ static_assert((std::is_base_of<std::exception, std::bad_typeid>::value),
+ "std::is_base_of<std::exception, std::bad_typeid>::value");
+ static_assert(std::is_polymorphic<std::bad_typeid>::value,
+ "std::is_polymorphic<std::bad_typeid>::value");
+ std::bad_typeid b;
+ std::bad_typeid b2 = b;
+ b2 = b;
+ const char* w = b2.what();
+ assert(w);
+}
diff --git a/test/std/language.support/support.rtti/type.info/type_info.pass.cpp b/test/std/language.support/support.rtti/type.info/type_info.pass.cpp
new file mode 100644
index 000000000000..2616865e6da9
--- /dev/null
+++ b/test/std/language.support/support.rtti/type.info/type_info.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test type_info
+
+#include <typeinfo>
+#include <cstring>
+#include <cassert>
+
+int main()
+{
+ const std::type_info& t1 = typeid(int);
+ const std::type_info& t2 = typeid(int);
+ assert(t1 == t2);
+ const std::type_info& t3 = typeid(short);
+ assert(t1 != t3);
+ assert(!t1.before(t2));
+ assert(strcmp(t1.name(), t2.name()) == 0);
+ assert(strcmp(t1.name(), t3.name()) != 0);
+}
diff --git a/test/std/language.support/support.rtti/type.info/type_info_hash.pass.cpp b/test/std/language.support/support.rtti/type.info/type_info_hash.pass.cpp
new file mode 100644
index 000000000000..c91a21ff2dae
--- /dev/null
+++ b/test/std/language.support/support.rtti/type.info/type_info_hash.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test type_info
+
+#include <typeinfo>
+#include <cstring>
+#include <cassert>
+
+int main()
+{
+ const std::type_info& t1 = typeid(int);
+ const std::type_info& t2 = typeid(int);
+ const std::type_info& t3 = typeid(short);
+ assert(t1.hash_code() == t2.hash_code());
+ assert(t1.hash_code() != t3.hash_code());
+}
diff --git a/test/std/language.support/support.rtti/version.pass.cpp b/test/std/language.support/support.rtti/version.pass.cpp
new file mode 100644
index 000000000000..0a9ece34f97e
--- /dev/null
+++ b/test/std/language.support/support.rtti/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <typeinfo>
+
+#include <typeinfo>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/language.support/support.runtime/csetjmp.pass.cpp b/test/std/language.support/support.runtime/csetjmp.pass.cpp
new file mode 100644
index 000000000000..dc034ce099e2
--- /dev/null
+++ b/test/std/language.support/support.runtime/csetjmp.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test <csetjmp>
+
+#include <csetjmp>
+#include <type_traits>
+
+#ifndef setjmp
+#error setjmp not defined
+#endif
+
+int main()
+{
+ std::jmp_buf jb;
+ static_assert((std::is_same<decltype(std::longjmp(jb, 0)), void>::value),
+ "std::is_same<decltype(std::longjmp(jb, 0)), void>::value");
+}
diff --git a/test/std/language.support/support.runtime/csignal.pass.cpp b/test/std/language.support/support.runtime/csignal.pass.cpp
new file mode 100644
index 000000000000..717347df7f00
--- /dev/null
+++ b/test/std/language.support/support.runtime/csignal.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test <csignal>
+
+#include <csignal>
+#include <type_traits>
+
+#ifndef SIG_DFL
+#error SIG_DFL not defined
+#endif
+
+#ifndef SIG_ERR
+#error SIG_ERR not defined
+#endif
+
+#ifndef SIG_IGN
+#error SIG_IGN not defined
+#endif
+
+#ifndef SIGABRT
+#error SIGABRT not defined
+#endif
+
+#ifndef SIGFPE
+#error SIGFPE not defined
+#endif
+
+#ifndef SIGILL
+#error SIGILL not defined
+#endif
+
+#ifndef SIGINT
+#error SIGINT not defined
+#endif
+
+#ifndef SIGSEGV
+#error SIGSEGV not defined
+#endif
+
+#ifndef SIGTERM
+#error SIGTERM not defined
+#endif
+
+int main()
+{
+ std::sig_atomic_t sig;
+ typedef void (*func)(int);
+ static_assert((std::is_same<decltype(std::signal(0, (func)0)), func>::value), "");
+ static_assert((std::is_same<decltype(std::raise(0)), int>::value), "");
+}
diff --git a/test/std/language.support/support.runtime/cstdarg.pass.cpp b/test/std/language.support/support.runtime/cstdarg.pass.cpp
new file mode 100644
index 000000000000..059ad2f4ff91
--- /dev/null
+++ b/test/std/language.support/support.runtime/cstdarg.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test <cstdarg>
+
+#include <cstdarg>
+
+#ifndef va_arg
+#error va_arg not defined
+#endif
+
+#if __cplusplus >= 201103L
+# ifndef va_copy
+# error va_copy is not defined when c++ >= 11
+# endif
+#endif
+
+#ifndef va_end
+#error va_end not defined
+#endif
+
+#ifndef va_start
+#error va_start not defined
+#endif
+
+int main()
+{
+ std::va_list va;
+}
diff --git a/test/std/language.support/support.runtime/cstdbool.pass.cpp b/test/std/language.support/support.runtime/cstdbool.pass.cpp
new file mode 100644
index 000000000000..f52c1556feb0
--- /dev/null
+++ b/test/std/language.support/support.runtime/cstdbool.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test <cstdbool>
+
+#include <cstdbool>
+
+#ifndef __bool_true_false_are_defined
+#error __bool_true_false_are_defined not defined
+#endif
+
+#ifdef bool
+#error bool should not be defined
+#endif
+
+#ifdef true
+#error true should not be defined
+#endif
+
+#ifdef false
+#error false should not be defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/language.support/support.runtime/cstdlib.pass.cpp b/test/std/language.support/support.runtime/cstdlib.pass.cpp
new file mode 100644
index 000000000000..073949122b01
--- /dev/null
+++ b/test/std/language.support/support.runtime/cstdlib.pass.cpp
@@ -0,0 +1,88 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test <cstdlib>
+
+#include <cstdlib>
+#include <type_traits>
+
+#ifndef EXIT_FAILURE
+#error EXIT_FAILURE not defined
+#endif
+
+#ifndef EXIT_SUCCESS
+#error EXIT_SUCCESS not defined
+#endif
+
+#ifndef MB_CUR_MAX
+#error MB_CUR_MAX not defined
+#endif
+
+#ifndef NULL
+#error NULL not defined
+#endif
+
+#ifndef RAND_MAX
+#error RAND_MAX not defined
+#endif
+
+int main()
+{
+ std::size_t s = 0;
+ std::div_t d;
+ std::ldiv_t ld;
+ std::lldiv_t lld;
+ char** endptr = 0;
+ static_assert((std::is_same<decltype(std::atof("")), double>::value), "");
+ static_assert((std::is_same<decltype(std::atoi("")), int>::value), "");
+ static_assert((std::is_same<decltype(std::atol("")), long>::value), "");
+ static_assert((std::is_same<decltype(std::atoll("")), long long>::value), "");
+ static_assert((std::is_same<decltype(std::getenv("")), char*>::value), "");
+ static_assert((std::is_same<decltype(std::strtod("", endptr)), double>::value), "");
+ static_assert((std::is_same<decltype(std::strtof("", endptr)), float>::value), "");
+ static_assert((std::is_same<decltype(std::strtold("", endptr)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::strtol("", endptr,0)), long>::value), "");
+ static_assert((std::is_same<decltype(std::strtoll("", endptr,0)), long long>::value), "");
+ static_assert((std::is_same<decltype(std::strtoul("", endptr,0)), unsigned long>::value), "");
+ static_assert((std::is_same<decltype(std::strtoull("", endptr,0)), unsigned long long>::value), "");
+ static_assert((std::is_same<decltype(std::rand()), int>::value), "");
+ static_assert((std::is_same<decltype(std::srand(0)), void>::value), "");
+ static_assert((std::is_same<decltype(std::calloc(0,0)), void*>::value), "");
+ static_assert((std::is_same<decltype(std::free(0)), void>::value), "");
+ static_assert((std::is_same<decltype(std::malloc(0)), void*>::value), "");
+ static_assert((std::is_same<decltype(std::realloc(0,0)), void*>::value), "");
+ static_assert((std::is_same<decltype(std::abort()), void>::value), "");
+ static_assert((std::is_same<decltype(std::atexit(0)), int>::value), "");
+ static_assert((std::is_same<decltype(std::exit(0)), void>::value), "");
+ static_assert((std::is_same<decltype(std::_Exit(0)), void>::value), "");
+ static_assert((std::is_same<decltype(std::getenv("")), char*>::value), "");
+ static_assert((std::is_same<decltype(std::system("")), int>::value), "");
+ static_assert((std::is_same<decltype(std::bsearch(0,0,0,0,0)), void*>::value), "");
+ static_assert((std::is_same<decltype(std::qsort(0,0,0,0)), void>::value), "");
+ static_assert((std::is_same<decltype(std::abs(0)), int>::value), "");
+ static_assert((std::is_same<decltype(std::abs((long)0)), long>::value), "");
+ static_assert((std::is_same<decltype(std::abs((long long)0)), long long>::value), "");
+ static_assert((std::is_same<decltype(std::labs((long)0)), long>::value), "");
+ static_assert((std::is_same<decltype(std::llabs((long long)0)), long long>::value), "");
+ static_assert((std::is_same<decltype(std::div(0,0)), std::div_t>::value), "");
+ static_assert((std::is_same<decltype(std::div(0L,0L)), std::ldiv_t>::value), "");
+ static_assert((std::is_same<decltype(std::div(0LL,0LL)), std::lldiv_t>::value), "");
+ static_assert((std::is_same<decltype(std::ldiv(0L,0L)), std::ldiv_t>::value), "");
+ static_assert((std::is_same<decltype(std::lldiv(0LL,0LL)), std::lldiv_t>::value), "");
+ wchar_t* pw = 0;
+ const wchar_t* pwc = 0;
+ char* pc = 0;
+#ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
+ static_assert((std::is_same<decltype(std::mblen("",0)), int>::value), "");
+ static_assert((std::is_same<decltype(std::mbtowc(pw,"",0)), int>::value), "");
+ static_assert((std::is_same<decltype(std::wctomb(pc,L' ')), int>::value), "");
+#endif
+ static_assert((std::is_same<decltype(std::mbstowcs(pw,"",0)), std::size_t>::value), "");
+ static_assert((std::is_same<decltype(std::wcstombs(pc,pwc,0)), std::size_t>::value), "");
+}
diff --git a/test/std/language.support/support.runtime/ctime.pass.cpp b/test/std/language.support/support.runtime/ctime.pass.cpp
new file mode 100644
index 000000000000..8c5d2811d8a9
--- /dev/null
+++ b/test/std/language.support/support.runtime/ctime.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test <ctime>
+
+#include <ctime>
+#include <type_traits>
+
+#ifndef NULL
+#error NULL not defined
+#endif
+
+#ifndef CLOCKS_PER_SEC
+#error CLOCKS_PER_SEC not defined
+#endif
+
+int main()
+{
+ std::clock_t c = 0;
+ std::size_t s = 0;
+ std::time_t t = 0;
+ std::tm tm = {0};
+ static_assert((std::is_same<decltype(std::clock()), std::clock_t>::value), "");
+ static_assert((std::is_same<decltype(std::difftime(t,t)), double>::value), "");
+ static_assert((std::is_same<decltype(std::mktime(&tm)), std::time_t>::value), "");
+ static_assert((std::is_same<decltype(std::time(&t)), std::time_t>::value), "");
+#ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
+ static_assert((std::is_same<decltype(std::asctime(&tm)), char*>::value), "");
+ static_assert((std::is_same<decltype(std::ctime(&t)), char*>::value), "");
+ static_assert((std::is_same<decltype(std::gmtime(&t)), std::tm*>::value), "");
+ static_assert((std::is_same<decltype(std::localtime(&t)), std::tm*>::value), "");
+#endif
+ char* c1 = 0;
+ const char* c2 = 0;
+ static_assert((std::is_same<decltype(std::strftime(c1,s,c2,&tm)), std::size_t>::value), "");
+}
diff --git a/test/std/language.support/support.runtime/version_csetjmp.pass.cpp b/test/std/language.support/support.runtime/version_csetjmp.pass.cpp
new file mode 100644
index 000000000000..7e37716d0145
--- /dev/null
+++ b/test/std/language.support/support.runtime/version_csetjmp.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <csetjmp>
+
+#include <csetjmp>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/language.support/support.runtime/version_csignal.pass.cpp b/test/std/language.support/support.runtime/version_csignal.pass.cpp
new file mode 100644
index 000000000000..be1045f1eb3b
--- /dev/null
+++ b/test/std/language.support/support.runtime/version_csignal.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <csignal>
+
+#include <csignal>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/language.support/support.runtime/version_cstdarg.pass.cpp b/test/std/language.support/support.runtime/version_cstdarg.pass.cpp
new file mode 100644
index 000000000000..f3ca9389b15d
--- /dev/null
+++ b/test/std/language.support/support.runtime/version_cstdarg.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <cstdarg>
+
+#include <cstdarg>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/language.support/support.runtime/version_cstdbool.pass.cpp b/test/std/language.support/support.runtime/version_cstdbool.pass.cpp
new file mode 100644
index 000000000000..0415227e58ea
--- /dev/null
+++ b/test/std/language.support/support.runtime/version_cstdbool.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <cstdbool>
+
+#include <cstdbool>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/language.support/support.runtime/version_cstdlib.pass.cpp b/test/std/language.support/support.runtime/version_cstdlib.pass.cpp
new file mode 100644
index 000000000000..db419524f578
--- /dev/null
+++ b/test/std/language.support/support.runtime/version_cstdlib.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <cstdlib>
+
+#include <cstdlib>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/language.support/support.runtime/version_ctime.pass.cpp b/test/std/language.support/support.runtime/version_ctime.pass.cpp
new file mode 100644
index 000000000000..ce0bf2cf1853
--- /dev/null
+++ b/test/std/language.support/support.runtime/version_ctime.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ctime>
+
+#include <ctime>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/language.support/support.start.term/quick_exit.pass.cpp b/test/std/language.support/support.start.term/quick_exit.pass.cpp
new file mode 100644
index 000000000000..bcfdbb75402e
--- /dev/null
+++ b/test/std/language.support/support.start.term/quick_exit.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+
+// test quick_exit and at_quick_exit
+
+#include <cstdlib>
+
+void f() {}
+
+int main()
+{
+#ifdef _LIBCPP_HAS_QUICK_EXIT
+ std::at_quick_exit(f);
+ std::quick_exit(0);
+#endif
+}
diff --git a/test/std/language.support/support.start.term/quick_exit_check1.fail.cpp b/test/std/language.support/support.start.term/quick_exit_check1.fail.cpp
new file mode 100644
index 000000000000..8b9729379163
--- /dev/null
+++ b/test/std/language.support/support.start.term/quick_exit_check1.fail.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+
+// test that referencing at_quick_exit when _LIBCPP_HAS_QUICK_EXIT is not defined
+// results in a compile error.
+
+#include <cstdlib>
+
+void f() {}
+
+int main()
+{
+#ifndef _LIBCPP_HAS_QUICK_EXIT
+ std::at_quick_exit(f);
+#else
+#error
+#endif
+}
diff --git a/test/std/language.support/support.start.term/quick_exit_check2.fail.cpp b/test/std/language.support/support.start.term/quick_exit_check2.fail.cpp
new file mode 100644
index 000000000000..395914136820
--- /dev/null
+++ b/test/std/language.support/support.start.term/quick_exit_check2.fail.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+
+// test that referencing quick_exit when _LIBCPP_HAS_QUICK_EXIT is not defined
+// results in a compile error.
+
+#include <cstdlib>
+
+void f() {}
+
+int main()
+{
+#ifndef _LIBCPP_HAS_QUICK_EXIT
+ std::quick_exit(0);
+#else
+#error
+#endif
+}
diff --git a/test/std/language.support/support.types/max_align_t.pass.cpp b/test/std/language.support/support.types/max_align_t.pass.cpp
new file mode 100644
index 000000000000..08a6c28a4c19
--- /dev/null
+++ b/test/std/language.support/support.types/max_align_t.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <cstddef>
+#include <type_traits>
+
+// max_align_t is a POD type whose alignment requirement is at least as
+// great as that of every scalar type
+
+#include <stdio.h>
+
+int main()
+{
+ static_assert(std::is_pod<std::max_align_t>::value,
+ "std::is_pod<std::max_align_t>::value");
+ static_assert((std::alignment_of<std::max_align_t>::value >=
+ std::alignment_of<long long>::value),
+ "std::alignment_of<std::max_align_t>::value >= "
+ "std::alignment_of<long long>::value");
+ static_assert(std::alignment_of<std::max_align_t>::value >=
+ std::alignment_of<long double>::value,
+ "std::alignment_of<std::max_align_t>::value >= "
+ "std::alignment_of<long double>::value");
+ static_assert(std::alignment_of<std::max_align_t>::value >=
+ std::alignment_of<void*>::value,
+ "std::alignment_of<std::max_align_t>::value >= "
+ "std::alignment_of<void*>::value");
+}
diff --git a/test/std/language.support/support.types/null.pass.cpp b/test/std/language.support/support.types/null.pass.cpp
new file mode 100644
index 000000000000..7e31a8525c00
--- /dev/null
+++ b/test/std/language.support/support.types/null.pass.cpp
@@ -0,0 +1,18 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <cstddef>
+
+#ifndef NULL
+#error NULL not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/language.support/support.types/nullptr_t.pass.cpp b/test/std/language.support/support.types/nullptr_t.pass.cpp
new file mode 100644
index 000000000000..4d7c8b0bc0a6
--- /dev/null
+++ b/test/std/language.support/support.types/nullptr_t.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <cstddef>
+#include <type_traits>
+#include <cassert>
+
+// typedef decltype(nullptr) nullptr_t;
+
+struct A
+{
+ A(std::nullptr_t) {}
+};
+
+template <class T>
+void test_conversions()
+{
+ {
+ T p = 0;
+ assert(p == nullptr);
+ }
+ {
+ T p = nullptr;
+ assert(p == nullptr);
+ assert(nullptr == p);
+ assert(!(p != nullptr));
+ assert(!(nullptr != p));
+ }
+}
+
+template <class T>
+void test_comparisons()
+{
+ T p = nullptr;
+ assert(p == nullptr);
+ assert(p <= nullptr);
+ assert(p >= nullptr);
+ assert(!(p != nullptr));
+ assert(!(p < nullptr));
+ assert(!(p > nullptr));
+ assert(nullptr == p);
+ assert(nullptr <= p);
+ assert(nullptr >= p);
+ assert(!(nullptr != p));
+ assert(!(nullptr < p));
+ assert(!(nullptr > p));
+}
+
+
+int main()
+{
+ static_assert(sizeof(std::nullptr_t) == sizeof(void*),
+ "sizeof(std::nullptr_t) == sizeof(void*)");
+
+ {
+ test_conversions<std::nullptr_t>();
+ test_conversions<void*>();
+ test_conversions<A*>();
+ test_conversions<void(*)()>();
+ test_conversions<void(A::*)()>();
+ test_conversions<int A::*>();
+ }
+ {
+ test_comparisons<std::nullptr_t>();
+ test_comparisons<void*>();
+ test_comparisons<A*>();
+ test_comparisons<void(*)()>();
+ }
+ {
+ bool b = nullptr;
+ assert(!b);
+ }
+}
diff --git a/test/std/language.support/support.types/nullptr_t_integral_cast.fail.cpp b/test/std/language.support/support.types/nullptr_t_integral_cast.fail.cpp
new file mode 100644
index 000000000000..92bd87943e12
--- /dev/null
+++ b/test/std/language.support/support.types/nullptr_t_integral_cast.fail.cpp
@@ -0,0 +1,17 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// typedef decltype(nullptr) nullptr_t;
+
+#include <cstddef>
+
+int main()
+{
+ std::ptrdiff_t i = static_cast<std::ptrdiff_t>(nullptr);
+}
diff --git a/test/std/language.support/support.types/nullptr_t_integral_cast.pass.cpp b/test/std/language.support/support.types/nullptr_t_integral_cast.pass.cpp
new file mode 100644
index 000000000000..34c7a93e41c5
--- /dev/null
+++ b/test/std/language.support/support.types/nullptr_t_integral_cast.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// NOTE: nullptr_t emulation cannot handle a reinterpret_cast to an
+// integral type
+// XFAIL: c++98, c++03
+
+// typedef decltype(nullptr) nullptr_t;
+
+
+#include <cstddef>
+#include <cassert>
+
+int main()
+{
+ std::ptrdiff_t i = reinterpret_cast<std::ptrdiff_t>(nullptr);
+ assert(i == 0);
+}
diff --git a/test/std/language.support/support.types/offsetof.pass.cpp b/test/std/language.support/support.types/offsetof.pass.cpp
new file mode 100644
index 000000000000..e36ac22974ff
--- /dev/null
+++ b/test/std/language.support/support.types/offsetof.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <cstddef>
+
+#ifndef offsetof
+#error offsetof not defined
+#endif
+
+struct A
+{
+ int x;
+};
+
+int main()
+{
+#if (__has_feature(cxx_noexcept))
+ static_assert(noexcept(offsetof(A, x)), "");
+#endif
+}
diff --git a/test/std/language.support/support.types/ptrdiff_t.pass.cpp b/test/std/language.support/support.types/ptrdiff_t.pass.cpp
new file mode 100644
index 000000000000..702ec720a913
--- /dev/null
+++ b/test/std/language.support/support.types/ptrdiff_t.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <cstddef>
+#include <type_traits>
+
+// ptrdiff_t should:
+
+// 1. be in namespace std.
+// 2. be the same sizeof as void*.
+// 3. be a signed integral.
+
+int main()
+{
+ static_assert(sizeof(std::ptrdiff_t) == sizeof(void*),
+ "sizeof(std::ptrdiff_t) == sizeof(void*)");
+ static_assert(std::is_signed<std::ptrdiff_t>::value,
+ "std::is_signed<std::ptrdiff_t>::value");
+ static_assert(std::is_integral<std::ptrdiff_t>::value,
+ "std::is_integral<std::ptrdiff_t>::value");
+}
diff --git a/test/std/language.support/support.types/size_t.pass.cpp b/test/std/language.support/support.types/size_t.pass.cpp
new file mode 100644
index 000000000000..bb3b0805b5ad
--- /dev/null
+++ b/test/std/language.support/support.types/size_t.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <cstddef>
+#include <type_traits>
+
+// size_t should:
+
+// 1. be in namespace std.
+// 2. be the same sizeof as void*.
+// 3. be an unsigned integral.
+
+int main()
+{
+ static_assert(sizeof(std::size_t) == sizeof(void*),
+ "sizeof(std::size_t) == sizeof(void*)");
+ static_assert(std::is_unsigned<std::size_t>::value,
+ "std::is_unsigned<std::size_t>::value");
+ static_assert(std::is_integral<std::size_t>::value,
+ "std::is_integral<std::size_t>::value");
+}
diff --git a/test/std/language.support/support.types/version.pass.cpp b/test/std/language.support/support.types/version.pass.cpp
new file mode 100644
index 000000000000..2ab7c188de1d
--- /dev/null
+++ b/test/std/language.support/support.types/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <cstddef>
+
+#include <cstddef>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/localization/c.locales/clocale.pass.cpp b/test/std/localization/c.locales/clocale.pass.cpp
new file mode 100644
index 000000000000..a90725bfa367
--- /dev/null
+++ b/test/std/localization/c.locales/clocale.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <clocale>
+
+#include <clocale>
+#include <type_traits>
+
+#ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
+
+#ifndef LC_ALL
+#error LC_ALL not defined
+#endif
+
+#ifndef LC_COLLATE
+#error LC_COLLATE not defined
+#endif
+
+#ifndef LC_CTYPE
+#error LC_CTYPE not defined
+#endif
+
+#ifndef LC_MONETARY
+#error LC_MONETARY not defined
+#endif
+
+#ifndef LC_NUMERIC
+#error LC_NUMERIC not defined
+#endif
+
+#ifndef LC_TIME
+#error LC_TIME not defined
+#endif
+
+#endif // !_LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
+
+#ifndef NULL
+#error NULL not defined
+#endif
+
+int main()
+{
+ std::lconv lc;
+#ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
+ static_assert((std::is_same<decltype(std::setlocale(0, "")), char*>::value), "");
+#endif
+ static_assert((std::is_same<decltype(std::localeconv()), std::lconv*>::value), "");
+}
diff --git a/test/std/localization/c.locales/version.pass.cpp b/test/std/localization/c.locales/version.pass.cpp
new file mode 100644
index 000000000000..0fce59e2b0b8
--- /dev/null
+++ b/test/std/localization/c.locales/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <clocale>
+
+#include <clocale>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/localization/locale.categories/__scan_keyword.pass.cpp b/test/std/localization/locale.categories/__scan_keyword.pass.cpp
new file mode 100644
index 000000000000..b33aab9a730a
--- /dev/null
+++ b/test/std/localization/locale.categories/__scan_keyword.pass.cpp
@@ -0,0 +1,118 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// Not a portable test
+
+// __scan_keyword
+// Scans [__b, __e) until a match is found in the basic_strings range
+// [__kb, __ke) or until it can be shown that there is no match in [__kb, __ke).
+// __b will be incremented (visibly), consuming CharT until a match is found
+// or proved to not exist. A keyword may be "", in which will match anything.
+// If one keyword is a prefix of another, and the next CharT in the input
+// might match another keyword, the algorithm will attempt to find the longest
+// matching keyword. If the longer matching keyword ends up not matching, then
+// no keyword match is found. If no keyword match is found, __ke is returned.
+// Else an iterator pointing to the matching keyword is found. If more than
+// one keyword matches, an iterator to the first matching keyword is returned.
+// If on exit __b == __e, eofbit is set in __err. If __case_sensitive is false,
+// __ct is used to force to lower case before comparing characters.
+// Examples:
+// Keywords: "a", "abb"
+// If the input is "a", the first keyword matches and eofbit is set.
+// If the input is "abc", no match is found and "ab" are consumed.
+//
+// template <class _InputIterator, class _ForwardIterator, class _Ctype>
+// _ForwardIterator
+// __scan_keyword(_InputIterator& __b, _InputIterator __e,
+// _ForwardIterator __kb, _ForwardIterator __ke,
+// const _Ctype& __ct, ios_base::iostate& __err,
+// bool __case_sensitive = true);
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+ const std::ctype<char>& ct = std::use_facet<std::ctype<char> >(std::locale::classic());
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ {
+ const char input[] = "a";
+ const char* in = input;
+ std::string keys[] = {"a", "abb"};
+ err = std::ios_base::goodbit;
+ std::string* k = std::__scan_keyword(in, input+sizeof(input)-1,
+ keys, keys+sizeof(keys)/sizeof(keys[0]),
+ ct, err);
+ assert(k - keys == 0);
+ assert(in == input+1);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const char input[] = "abc";
+ const char* in = input;
+ std::string keys[] = {"a", "abb"};
+ err = std::ios_base::goodbit;
+ std::string* k = std::__scan_keyword(in, input+sizeof(input)-1,
+ keys, keys+sizeof(keys)/sizeof(keys[0]),
+ ct, err);
+ assert(k - keys == 2);
+ assert(in == input+2);
+ assert(err == std::ios_base::failbit);
+ }
+ {
+ const char input[] = "abb";
+ const char* in = input;
+ std::string keys[] = {"a", "abb"};
+ err = std::ios_base::goodbit;
+ std::string* k = std::__scan_keyword(in, input+sizeof(input)-1,
+ keys, keys+sizeof(keys)/sizeof(keys[0]),
+ ct, err);
+ assert(k - keys == 1);
+ assert(in == input+3);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const char input[] = "Tue ";
+ const char* in = input;
+ std::string keys[] = {"Mon", "Monday", "Tue", "Tuesday"};
+ err = std::ios_base::goodbit;
+ std::string* k = std::__scan_keyword(in, input+sizeof(input)-1,
+ keys, keys+sizeof(keys)/sizeof(keys[0]),
+ ct, err);
+ assert(k - keys == 2);
+ assert(in == input+3);
+ assert(err == std::ios_base::goodbit);
+ }
+ {
+ const char input[] = "tue ";
+ const char* in = input;
+ std::string keys[] = {"Mon", "Monday", "Tue", "Tuesday"};
+ err = std::ios_base::goodbit;
+ std::string* k = std::__scan_keyword(in, input+sizeof(input)-1,
+ keys, keys+sizeof(keys)/sizeof(keys[0]),
+ ct, err);
+ assert(k - keys == 4);
+ assert(in == input+0);
+ assert(err == std::ios_base::failbit);
+ }
+ {
+ const char input[] = "tue ";
+ const char* in = input;
+ std::string keys[] = {"Mon", "Monday", "Tue", "Tuesday"};
+ err = std::ios_base::goodbit;
+ std::string* k = std::__scan_keyword(in, input+sizeof(input)-1,
+ keys, keys+sizeof(keys)/sizeof(keys[0]),
+ ct, err, false);
+ assert(k - keys == 2);
+ assert(in == input+3);
+ assert(err == std::ios_base::goodbit);
+ }
+}
diff --git a/test/std/localization/locale.categories/category.collate/locale.collate.byname/compare.pass.cpp b/test/std/localization/locale.categories/category.collate/locale.collate.byname/compare.pass.cpp
new file mode 100644
index 000000000000..69af9ac1b7bf
--- /dev/null
+++ b/test/std/localization/locale.categories/category.collate/locale.collate.byname/compare.pass.cpp
@@ -0,0 +1,87 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class collate_byname
+
+// int compare(const charT* low1, const charT* high1,
+// const charT* low2, const charT* high2) const;
+
+// I'm currently unable to confirm that collation based on named locales
+// has any difference from "C" collation. But I do believe I'm picking
+// up the OS's collation files.
+
+// TODO investigation needed.
+// Glibc seems to collate files differently from the way Apple's C library does
+// it.
+// XFAIL: linux-gnu
+
+#include <locale>
+#include <string>
+#include <cassert>
+
+#include <stdio.h>
+
+#include "platform_support.h" // locale name macros
+
+int main()
+{
+ {
+ std::locale l(LOCALE_en_US_UTF_8);
+ {
+ const std::collate<char>& f = std::use_facet<std::collate<char> >(l);
+ std::string s2("aaaaaaA");
+ std::string s3("BaaaaaA");
+ assert(f.compare(s2.data(), s2.data() + s2.size(),
+ s3.data(), s3.data() + s3.size()) == 1);
+ }
+ {
+ const std::collate<wchar_t>& f = std::use_facet<std::collate<wchar_t> >(l);
+ std::wstring s2(L"aaaaaaA");
+ std::wstring s3(L"BaaaaaA");
+ assert(f.compare(s2.data(), s2.data() + s2.size(),
+ s3.data(), s3.data() + s3.size()) == 1);
+ }
+ }
+ {
+ std::locale l("");
+ {
+ const std::collate<char>& f = std::use_facet<std::collate<char> >(l);
+ std::string s2("aaaaaaA");
+ std::string s3("BaaaaaA");
+ assert(f.compare(s2.data(), s2.data() + s2.size(),
+ s3.data(), s3.data() + s3.size()) == 1);
+ }
+ {
+ const std::collate<wchar_t>& f = std::use_facet<std::collate<wchar_t> >(l);
+ std::wstring s2(L"aaaaaaA");
+ std::wstring s3(L"BaaaaaA");
+ assert(f.compare(s2.data(), s2.data() + s2.size(),
+ s3.data(), s3.data() + s3.size()) == 1);
+ }
+ }
+ {
+ std::locale l("C");
+ {
+ const std::collate<char>& f = std::use_facet<std::collate<char> >(l);
+ std::string s2("aaaaaaA");
+ std::string s3("BaaaaaA");
+ assert(f.compare(s2.data(), s2.data() + s2.size(),
+ s3.data(), s3.data() + s3.size()) == 1);
+ }
+ {
+ const std::collate<wchar_t>& f = std::use_facet<std::collate<wchar_t> >(l);
+ std::wstring s2(L"aaaaaaA");
+ std::wstring s3(L"BaaaaaA");
+ assert(f.compare(s2.data(), s2.data() + s2.size(),
+ s3.data(), s3.data() + s3.size()) == 1);
+ }
+ }
+}
diff --git a/test/std/localization/locale.categories/category.collate/locale.collate.byname/hash.pass.cpp b/test/std/localization/locale.categories/category.collate/locale.collate.byname/hash.pass.cpp
new file mode 100644
index 000000000000..f8641cb1eb6c
--- /dev/null
+++ b/test/std/localization/locale.categories/category.collate/locale.collate.byname/hash.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class collate_byname
+
+// long hash(const charT* low, const charT* high) const;
+
+// This test is not portable
+
+#include <locale>
+#include <string>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+int main()
+{
+ std::locale l(LOCALE_en_US_UTF_8);
+ {
+ std::string x1("1234");
+ std::string x2("12345");
+ const std::collate<char>& f = std::use_facet<std::collate<char> >(l);
+ assert(f.hash(x1.data(), x1.data() + x1.size())
+ != f.hash(x2.data(), x2.data() + x2.size()));
+ }
+ {
+ std::wstring x1(L"1234");
+ std::wstring x2(L"12345");
+ const std::collate<wchar_t>& f = std::use_facet<std::collate<wchar_t> >(l);
+ assert(f.hash(x1.data(), x1.data() + x1.size())
+ != f.hash(x2.data(), x2.data() + x2.size()));
+ }
+}
diff --git a/test/std/localization/locale.categories/category.collate/locale.collate.byname/transform.pass.cpp b/test/std/localization/locale.categories/category.collate/locale.collate.byname/transform.pass.cpp
new file mode 100644
index 000000000000..897141235cf2
--- /dev/null
+++ b/test/std/localization/locale.categories/category.collate/locale.collate.byname/transform.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class collate_byname
+
+// string_type transform(const charT* low, const charT* high) const;
+
+// REQUIRES: locale.en_US.UTF-8
+
+#include <locale>
+#include <string>
+#include <cassert>
+
+#include <stdio.h>
+
+#include "platform_support.h" // locale name macros
+
+int main()
+{
+ // Ensure that the default locale is not C. If it is, the second tests will fail.
+ putenv(const_cast<char*>("LANG=" LOCALE_en_US_UTF_8));
+ {
+ std::locale l(LOCALE_en_US_UTF_8);
+ {
+ std::string x("1234");
+ const std::collate<char>& f = std::use_facet<std::collate<char> >(l);
+ assert(f.transform(x.data(), x.data() + x.size()) != x);
+ }
+ {
+ std::wstring x(L"1234");
+ const std::collate<wchar_t>& f = std::use_facet<std::collate<wchar_t> >(l);
+ assert(f.transform(x.data(), x.data() + x.size()) != x);
+ }
+ }
+ {
+ std::locale l("");
+ {
+ std::string x("1234");
+ const std::collate<char>& f = std::use_facet<std::collate<char> >(l);
+ assert(f.transform(x.data(), x.data() + x.size()) != x);
+ }
+ {
+ std::wstring x(L"1234");
+ const std::collate<wchar_t>& f = std::use_facet<std::collate<wchar_t> >(l);
+ assert(f.transform(x.data(), x.data() + x.size()) != x);
+ }
+ }
+ {
+ std::locale l("C");
+ {
+ std::string x("1234");
+ const std::collate<char>& f = std::use_facet<std::collate<char> >(l);
+ assert(f.transform(x.data(), x.data() + x.size()) == x);
+ }
+ {
+ std::wstring x(L"1234");
+ const std::collate<wchar_t>& f = std::use_facet<std::collate<wchar_t> >(l);
+ assert(f.transform(x.data(), x.data() + x.size()) == x);
+ }
+ }
+}
diff --git a/test/std/localization/locale.categories/category.collate/locale.collate.byname/types.pass.cpp b/test/std/localization/locale.categories/category.collate/locale.collate.byname/types.pass.cpp
new file mode 100644
index 000000000000..04974b244e4e
--- /dev/null
+++ b/test/std/localization/locale.categories/category.collate/locale.collate.byname/types.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT>
+// class collate_byname
+// : public collate<charT>
+// {
+// public:
+// typedef basic_string<charT> string_type;
+// explicit collate_byname(const char*, size_t refs = 0);
+// explicit collate_byname(const string&, size_t refs = 0);
+// protected:
+// ~collate_byname();
+// };
+
+#include <locale>
+#include <string>
+#include <cassert>
+
+#include <stdio.h>
+
+#include "platform_support.h" // locale name macros
+
+int main()
+{
+ std::locale l(LOCALE_en_US_UTF_8);
+ {
+ assert(std::has_facet<std::collate_byname<char> >(l));
+ assert(&std::use_facet<std::collate<char> >(l)
+ == &std::use_facet<std::collate_byname<char> >(l));
+ }
+ {
+ assert(std::has_facet<std::collate_byname<wchar_t> >(l));
+ assert(&std::use_facet<std::collate<wchar_t> >(l)
+ == &std::use_facet<std::collate_byname<wchar_t> >(l));
+ }
+}
diff --git a/test/std/localization/locale.categories/category.collate/locale.collate/ctor.pass.cpp b/test/std/localization/locale.categories/category.collate/locale.collate/ctor.pass.cpp
new file mode 100644
index 000000000000..8f7e2b5f8a82
--- /dev/null
+++ b/test/std/localization/locale.categories/category.collate/locale.collate/ctor.pass.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class collate;
+
+// explicit collate(size_t refs = 0);
+
+#include <locale>
+#include <type_traits>
+#include <cassert>
+
+template <class C>
+class my_facet
+ : public std::collate<C>
+{
+public:
+ static int count;
+
+ explicit my_facet(std::size_t refs = 0)
+ : std::collate<C>(refs) {++count;}
+
+ ~my_facet() {--count;}
+};
+
+template <class C> int my_facet<C>::count = 0;
+
+int main()
+{
+ {
+ std::locale l(std::locale::classic(), new my_facet<char>);
+ assert(my_facet<char>::count == 1);
+ }
+ assert(my_facet<char>::count == 0);
+ {
+ my_facet<char> f(1);
+ assert(my_facet<char>::count == 1);
+ {
+ std::locale l(std::locale::classic(), &f);
+ assert(my_facet<char>::count == 1);
+ }
+ assert(my_facet<char>::count == 1);
+ }
+ assert(my_facet<char>::count == 0);
+ {
+ std::locale l(std::locale::classic(), new my_facet<wchar_t>);
+ assert(my_facet<wchar_t>::count == 1);
+ }
+ assert(my_facet<wchar_t>::count == 0);
+ {
+ my_facet<wchar_t> f(1);
+ assert(my_facet<wchar_t>::count == 1);
+ {
+ std::locale l(std::locale::classic(), &f);
+ assert(my_facet<wchar_t>::count == 1);
+ }
+ assert(my_facet<wchar_t>::count == 1);
+ }
+ assert(my_facet<wchar_t>::count == 0);
+}
diff --git a/test/std/localization/locale.categories/category.collate/locale.collate/locale.collate.members/compare.pass.cpp b/test/std/localization/locale.categories/category.collate/locale.collate/locale.collate.members/compare.pass.cpp
new file mode 100644
index 000000000000..d2cf3a921b3b
--- /dev/null
+++ b/test/std/localization/locale.categories/category.collate/locale.collate/locale.collate.members/compare.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class collate;
+
+// int compare(const charT* low1, const charT* high1,
+// const charT* low2, const charT* high2) const;
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+ std::locale l = std::locale::classic();
+ {
+ const char ia[] = "1234";
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ const char ib[] = "123";
+ const std::collate<char>& f = std::use_facet<std::collate<char> >(l);
+ assert(f.compare(ia, ia+sa, ib, ib+2) == 1);
+ assert(f.compare(ib, ib+2, ia, ia+sa) == -1);
+ assert(f.compare(ia, ia+sa, ib, ib+3) == 1);
+ assert(f.compare(ib, ib+3, ia, ia+sa) == -1);
+ assert(f.compare(ia, ia+sa, ib+1, ib+3) == -1);
+ assert(f.compare(ib+1, ib+3, ia, ia+sa) == 1);
+ assert(f.compare(ia, ia+3, ib, ib+3) == 0);
+ }
+ {
+ const wchar_t ia[] = L"1234";
+ const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+ const wchar_t ib[] = L"123";
+ const std::collate<wchar_t>& f = std::use_facet<std::collate<wchar_t> >(l);
+ assert(f.compare(ia, ia+sa, ib, ib+2) == 1);
+ assert(f.compare(ib, ib+2, ia, ia+sa) == -1);
+ assert(f.compare(ia, ia+sa, ib, ib+3) == 1);
+ assert(f.compare(ib, ib+3, ia, ia+sa) == -1);
+ assert(f.compare(ia, ia+sa, ib+1, ib+3) == -1);
+ assert(f.compare(ib+1, ib+3, ia, ia+sa) == 1);
+ assert(f.compare(ia, ia+3, ib, ib+3) == 0);
+ }
+}
diff --git a/test/std/localization/locale.categories/category.collate/locale.collate/locale.collate.members/hash.pass.cpp b/test/std/localization/locale.categories/category.collate/locale.collate/locale.collate.members/hash.pass.cpp
new file mode 100644
index 000000000000..d8a9650e3be1
--- /dev/null
+++ b/test/std/localization/locale.categories/category.collate/locale.collate/locale.collate.members/hash.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class collate;
+
+// long hash(const charT* low, const charT* high) const;
+
+// This test is not portable
+
+#include <locale>
+#include <string>
+#include <cassert>
+
+int main()
+{
+ std::locale l = std::locale::classic();
+ {
+ std::string x1("1234");
+ std::string x2("12345");
+ const std::collate<char>& f = std::use_facet<std::collate<char> >(l);
+ assert(f.hash(x1.data(), x1.data() + x1.size())
+ != f.hash(x2.data(), x2.data() + x2.size()));
+ }
+ {
+ std::wstring x1(L"1234");
+ std::wstring x2(L"12345");
+ const std::collate<wchar_t>& f = std::use_facet<std::collate<wchar_t> >(l);
+ assert(f.hash(x1.data(), x1.data() + x1.size())
+ != f.hash(x2.data(), x2.data() + x2.size()));
+ }
+}
diff --git a/test/std/localization/locale.categories/category.collate/locale.collate/locale.collate.members/transform.pass.cpp b/test/std/localization/locale.categories/category.collate/locale.collate/locale.collate.members/transform.pass.cpp
new file mode 100644
index 000000000000..e78a3c74cdcd
--- /dev/null
+++ b/test/std/localization/locale.categories/category.collate/locale.collate/locale.collate.members/transform.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class collate;
+
+// string_type transform(const charT* low, const charT* high) const;
+
+#include <locale>
+#include <string>
+#include <cassert>
+
+int main()
+{
+ std::locale l = std::locale::classic();
+ {
+ std::string x("1234");
+ const std::collate<char>& f = std::use_facet<std::collate<char> >(l);
+ assert(f.transform(x.data(), x.data() + x.size()) == x);
+ }
+ {
+ std::wstring x(L"1234");
+ const std::collate<wchar_t>& f = std::use_facet<std::collate<wchar_t> >(l);
+ assert(f.transform(x.data(), x.data() + x.size()) == x);
+ }
+}
diff --git a/test/std/localization/locale.categories/category.collate/locale.collate/locale.collate.virtuals/tested_elsewhere.pass.cpp b/test/std/localization/locale.categories/category.collate/locale.collate/locale.collate.virtuals/tested_elsewhere.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/localization/locale.categories/category.collate/locale.collate/locale.collate.virtuals/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/localization/locale.categories/category.collate/locale.collate/types.pass.cpp b/test/std/localization/locale.categories/category.collate/locale.collate/types.pass.cpp
new file mode 100644
index 000000000000..13945f8ee7ce
--- /dev/null
+++ b/test/std/localization/locale.categories/category.collate/locale.collate/types.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT>
+// class collate
+// : public locale::facet {
+// public:
+// typedef charT char_type;
+// typedef basic_string<charT>string_type;
+//
+// static locale::id id;
+// };
+
+#include <locale>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+ std::locale l = std::locale::classic();
+ {
+ assert(std::has_facet<std::collate<char> >(l));
+ const std::collate<char>& f = std::use_facet<std::collate<char> >(l);
+ {
+ (void)std::collate<char>::id;
+ }
+ static_assert((std::is_same<std::collate<char>::char_type, char>::value), "");
+ static_assert((std::is_same<std::collate<char>::string_type, std::string>::value), "");
+ static_assert((std::is_base_of<std::locale::facet, std::collate<char> >::value), "");
+ }
+ {
+ assert(std::has_facet<std::collate<wchar_t> >(l));
+ const std::collate<wchar_t>& f = std::use_facet<std::collate<wchar_t> >(l);
+ {
+ (void)std::collate<wchar_t>::id;
+ }
+ static_assert((std::is_same<std::collate<wchar_t>::char_type, wchar_t>::value), "");
+ static_assert((std::is_same<std::collate<wchar_t>::string_type, std::wstring>::value), "");
+ static_assert((std::is_base_of<std::locale::facet, std::collate<wchar_t> >::value), "");
+ }
+}
diff --git a/test/std/localization/locale.categories/category.collate/nothing_to_do.pass.cpp b/test/std/localization/locale.categories/category.collate/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/localization/locale.categories/category.collate/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/localization/locale.categories/category.ctype/ctype_base.pass.cpp b/test/std/localization/locale.categories/category.ctype/ctype_base.pass.cpp
new file mode 100644
index 000000000000..044ba2b976cb
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/ctype_base.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This test uses new symbols that were not defined in the libc++ shipped on
+// darwin11 and darwin12:
+// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11
+// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12
+
+// <locale>
+
+// class ctype_base
+// {
+// public:
+// typedef T mask;
+//
+// // numeric values are for exposition only.
+// static const mask space = 1 << 0;
+// static const mask print = 1 << 1;
+// static const mask cntrl = 1 << 2;
+// static const mask upper = 1 << 3;
+// static const mask lower = 1 << 4;
+// static const mask alpha = 1 << 5;
+// static const mask digit = 1 << 6;
+// static const mask punct = 1 << 7;
+// static const mask xdigit = 1 << 8;
+// static const mask alnum = alpha | digit;
+// static const mask graph = alnum | punct;
+// };
+
+#include <locale>
+#include <cassert>
+
+template <class _Tp>
+void test(const _Tp &) {}
+
+int main()
+{
+ assert(std::ctype_base::space);
+ assert(std::ctype_base::print);
+ assert(std::ctype_base::cntrl);
+ assert(std::ctype_base::upper);
+ assert(std::ctype_base::lower);
+ assert(std::ctype_base::alpha);
+ assert(std::ctype_base::digit);
+ assert(std::ctype_base::punct);
+ assert(std::ctype_base::xdigit);
+ assert(
+ ( std::ctype_base::space
+ & std::ctype_base::print
+ & std::ctype_base::cntrl
+ & std::ctype_base::upper
+ & std::ctype_base::lower
+ & std::ctype_base::alpha
+ & std::ctype_base::digit
+ & std::ctype_base::punct
+ & std::ctype_base::xdigit) == 0);
+ assert(std::ctype_base::alnum == (std::ctype_base::alpha | std::ctype_base::digit));
+ assert(std::ctype_base::graph == (std::ctype_base::alnum | std::ctype_base::punct));
+
+ test(std::ctype_base::space);
+ test(std::ctype_base::print);
+ test(std::ctype_base::cntrl);
+ test(std::ctype_base::upper);
+ test(std::ctype_base::lower);
+ test(std::ctype_base::alpha);
+ test(std::ctype_base::digit);
+ test(std::ctype_base::punct);
+ test(std::ctype_base::xdigit);
+ test(std::ctype_base::blank);
+ test(std::ctype_base::alnum);
+ test(std::ctype_base::graph);
+}
diff --git a/test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.dtor/dtor.pass.cpp b/test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.dtor/dtor.pass.cpp
new file mode 100644
index 000000000000..9fcedddbd43b
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.dtor/dtor.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class ctype<char>
+
+// ~ctype();
+
+#include <locale>
+#include <cassert>
+
+#include "count_new.hpp"
+
+int main()
+{
+ {
+ std::locale l(std::locale::classic(), new std::ctype<char>);
+ assert(globalMemCounter.checkDeleteArrayCalledEq(0));
+ }
+ assert(globalMemCounter.checkDeleteArrayCalledEq(0));
+ {
+ std::ctype<char>::mask table[256];
+ std::locale l(std::locale::classic(), new std::ctype<char>(table));
+ assert(globalMemCounter.checkDeleteArrayCalledEq(0));
+ }
+ assert(globalMemCounter.checkDeleteArrayCalledEq(0));
+ {
+ std::locale l(std::locale::classic(),
+ new std::ctype<char>(new std::ctype<char>::mask[256], true));
+ assert(globalMemCounter.checkDeleteArrayCalledEq(0));
+ }
+ assert(globalMemCounter.checkDeleteArrayCalledEq(1));
+}
diff --git a/test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/ctor.pass.cpp b/test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/ctor.pass.cpp
new file mode 100644
index 000000000000..a1e15ba455f0
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/ctor.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class ctype;
+
+// explicit ctype(const mask* tbl = 0, bool del = false, size_t refs = 0);
+
+#include <locale>
+#include <cassert>
+
+class my_facet
+ : public std::ctype<char>
+{
+public:
+ static int count;
+
+ explicit my_facet(const mask* tbl = 0, bool del = false, std::size_t refs = 0)
+ : std::ctype<char>(tbl, del, refs) {++count;}
+
+ ~my_facet() {--count;}
+};
+
+int my_facet::count = 0;
+
+int main()
+{
+ {
+ std::locale l(std::locale::classic(), new my_facet);
+ assert(my_facet::count == 1);
+ }
+ assert(my_facet::count == 0);
+ {
+ my_facet f(0, false, 1);
+ assert(my_facet::count == 1);
+ {
+ std::locale l(std::locale::classic(), &f);
+ assert(my_facet::count == 1);
+ }
+ assert(my_facet::count == 1);
+ }
+ assert(my_facet::count == 0);
+}
diff --git a/test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/is_1.pass.cpp b/test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/is_1.pass.cpp
new file mode 100644
index 000000000000..945de76a7f5e
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/is_1.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class ctype<char>;
+
+// bool is(mask m, char c) const;
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+ std::locale l = std::locale::classic();
+ {
+ typedef std::ctype<char> F;
+ const F& f = std::use_facet<F>(l);
+
+ assert(f.is(F::space, ' '));
+ assert(!f.is(F::space, 'A'));
+
+ assert(f.is(F::print, ' '));
+ assert(!f.is(F::print, '\x07'));
+
+ assert(f.is(F::cntrl, '\x07'));
+ assert(!f.is(F::cntrl, ' '));
+
+ assert(f.is(F::upper, 'A'));
+ assert(!f.is(F::upper, 'a'));
+
+ assert(f.is(F::lower, 'a'));
+ assert(!f.is(F::lower, 'A'));
+
+ assert(f.is(F::alpha, 'a'));
+ assert(!f.is(F::alpha, '1'));
+
+ assert(f.is(F::digit, '1'));
+ assert(!f.is(F::digit, 'a'));
+
+ assert(f.is(F::punct, '.'));
+ assert(!f.is(F::punct, 'a'));
+
+ assert(f.is(F::xdigit, 'a'));
+ assert(!f.is(F::xdigit, 'g'));
+
+ assert(f.is(F::alnum, 'a'));
+ assert(!f.is(F::alnum, '.'));
+
+ assert(f.is(F::graph, '.'));
+ assert(!f.is(F::graph, '\x07'));
+ }
+}
diff --git a/test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/is_many.pass.cpp b/test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/is_many.pass.cpp
new file mode 100644
index 000000000000..74a4906fdf66
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/is_many.pass.cpp
@@ -0,0 +1,118 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class ctype<char>;
+
+// const char* is(const char* low, const char* high, mask* vec) const;
+
+#include <locale>
+#include <string>
+#include <vector>
+#include <cassert>
+
+#include <stdio.h>
+
+int main()
+{
+ std::locale l = std::locale::classic();
+ {
+ typedef std::ctype<char> F;
+ const F& f = std::use_facet<F>(l);
+ const std::string in(" A\x07.a1");
+ std::vector<F::mask> m(in.size());
+ const char* h = f.is(in.data(), in.data() + in.size(), m.data());
+ assert(h == in.data() + in.size());
+
+ // ' '
+ assert( (m[0] & F::space));
+ assert( (m[0] & F::print));
+ assert(!(m[0] & F::cntrl));
+ assert(!(m[0] & F::upper));
+ assert(!(m[0] & F::lower));
+ assert(!(m[0] & F::alpha));
+ assert(!(m[0] & F::digit));
+ assert(!(m[0] & F::punct));
+ assert(!(m[0] & F::xdigit));
+ assert( (m[0] & F::blank));
+ assert(!(m[0] & F::alnum));
+ assert(!(m[0] & F::graph));
+
+ // 'A'
+ assert(!(m[1] & F::space));
+ assert( (m[1] & F::print));
+ assert(!(m[1] & F::cntrl));
+ assert( (m[1] & F::upper));
+ assert(!(m[1] & F::lower));
+ assert( (m[1] & F::alpha));
+ assert(!(m[1] & F::digit));
+ assert(!(m[1] & F::punct));
+ assert( (m[1] & F::xdigit));
+ assert(!(m[1] & F::blank));
+ assert( (m[1] & F::alnum));
+ assert( (m[1] & F::graph));
+
+ // '\x07'
+ assert(!(m[2] & F::space));
+ assert(!(m[2] & F::print));
+ assert( (m[2] & F::cntrl));
+ assert(!(m[2] & F::upper));
+ assert(!(m[2] & F::lower));
+ assert(!(m[2] & F::alpha));
+ assert(!(m[2] & F::digit));
+ assert(!(m[2] & F::punct));
+ assert(!(m[2] & F::xdigit));
+ assert(!(m[2] & F::blank));
+ assert(!(m[2] & F::alnum));
+ assert(!(m[2] & F::graph));
+
+ // '.'
+ assert(!(m[3] & F::space));
+ assert( (m[3] & F::print));
+ assert(!(m[3] & F::cntrl));
+ assert(!(m[3] & F::upper));
+ assert(!(m[3] & F::lower));
+ assert(!(m[3] & F::alpha));
+ assert(!(m[3] & F::digit));
+ assert( (m[3] & F::punct));
+ assert(!(m[3] & F::xdigit));
+ assert(!(m[3] & F::blank));
+ assert(!(m[3] & F::alnum));
+ assert( (m[3] & F::graph));
+
+ // 'a'
+ assert(!(m[4] & F::space));
+ assert( (m[4] & F::print));
+ assert(!(m[4] & F::cntrl));
+ assert(!(m[4] & F::upper));
+ assert( (m[4] & F::lower));
+ assert( (m[4] & F::alpha));
+ assert(!(m[4] & F::digit));
+ assert(!(m[4] & F::punct));
+ assert( (m[4] & F::xdigit));
+ assert(!(m[4] & F::blank));
+ assert( (m[4] & F::alnum));
+ assert( (m[4] & F::graph));
+
+ // '1'
+ assert(!(m[5] & F::space));
+ assert( (m[5] & F::print));
+ assert(!(m[5] & F::cntrl));
+ assert(!(m[5] & F::upper));
+ assert(!(m[5] & F::lower));
+ assert(!(m[5] & F::alpha));
+ assert( (m[5] & F::digit));
+ assert(!(m[5] & F::punct));
+ assert( (m[5] & F::xdigit));
+ assert(!(m[5] & F::blank));
+ assert( (m[5] & F::alnum));
+ assert( (m[5] & F::graph));
+ }
+}
diff --git a/test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/narrow_1.pass.cpp b/test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/narrow_1.pass.cpp
new file mode 100644
index 000000000000..dedf6a7d3221
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/narrow_1.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class ctype<char>;
+
+// char narrow(char c, char dfault) const;
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+ std::locale l = std::locale::classic();
+ {
+ typedef std::ctype<char> F;
+ const F& f = std::use_facet<F>(l);
+
+ assert(f.narrow(' ', '*') == ' ');
+ assert(f.narrow('A', '*') == 'A');
+ assert(f.narrow('\x07', '*') == '\x07');
+ assert(f.narrow('.', '*') == '.');
+ assert(f.narrow('a', '*') == 'a');
+ assert(f.narrow('1', '*') == '1');
+ }
+}
diff --git a/test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/narrow_many.pass.cpp b/test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/narrow_many.pass.cpp
new file mode 100644
index 000000000000..4c5478afd605
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/narrow_many.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class ctype<char>;
+
+// const char* narrow(const char* low, const char*, char dfault, char* to) const;
+
+#include <locale>
+#include <string>
+#include <vector>
+#include <cassert>
+
+int main()
+{
+ std::locale l = std::locale::classic();
+ {
+ typedef std::ctype<char> F;
+ const F& f = std::use_facet<F>(l);
+ std::string in(" A\x07.a1");
+ std::vector<char> v(in.size());
+
+ assert(f.narrow(&in[0], in.data() + in.size(), '*', v.data()) == in.data() + in.size());
+ assert(v[0] == ' ');
+ assert(v[1] == 'A');
+ assert(v[2] == '\x07');
+ assert(v[3] == '.');
+ assert(v[4] == 'a');
+ assert(v[5] == '1');
+ }
+}
diff --git a/test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/scan_is.pass.cpp b/test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/scan_is.pass.cpp
new file mode 100644
index 000000000000..9777c9892096
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/scan_is.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class ctype<char>;
+
+// const char* scan_is(mask m, const char* low, const char* high) const;
+
+#include <locale>
+#include <string>
+#include <vector>
+#include <cassert>
+
+#include <stdio.h>
+
+int main()
+{
+ std::locale l = std::locale::classic();
+ {
+ typedef std::ctype<char> F;
+ const F& f = std::use_facet<F>(l);
+ const std::string in(" A\x07.a1");
+ std::vector<F::mask> m(in.size());
+ assert(f.scan_is(F::space, in.data(), in.data() + in.size()) - in.data() == 0);
+ assert(f.scan_is(F::print, in.data(), in.data() + in.size()) - in.data() == 0);
+ assert(f.scan_is(F::cntrl, in.data(), in.data() + in.size()) - in.data() == 2);
+ assert(f.scan_is(F::upper, in.data(), in.data() + in.size()) - in.data() == 1);
+ assert(f.scan_is(F::lower, in.data(), in.data() + in.size()) - in.data() == 4);
+ assert(f.scan_is(F::alpha, in.data(), in.data() + in.size()) - in.data() == 1);
+ assert(f.scan_is(F::digit, in.data(), in.data() + in.size()) - in.data() == 5);
+ assert(f.scan_is(F::punct, in.data(), in.data() + in.size()) - in.data() == 3);
+ assert(f.scan_is(F::xdigit, in.data(), in.data() + in.size()) - in.data() == 1);
+ assert(f.scan_is(F::blank, in.data(), in.data() + in.size()) - in.data() == 0);
+ assert(f.scan_is(F::alnum, in.data(), in.data() + in.size()) - in.data() == 1);
+ assert(f.scan_is(F::graph, in.data(), in.data() + in.size()) - in.data() == 1);
+ }
+}
diff --git a/test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/scan_not.pass.cpp b/test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/scan_not.pass.cpp
new file mode 100644
index 000000000000..b17662d0316a
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/scan_not.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class ctype<char>;
+
+// const char* scan_not(mask m, const char* low, const char* high) const;
+
+#include <locale>
+#include <string>
+#include <vector>
+#include <cassert>
+
+#include <stdio.h>
+
+int main()
+{
+ std::locale l = std::locale::classic();
+ {
+ typedef std::ctype<char> F;
+ const F& f = std::use_facet<F>(l);
+ const std::string in(" A\x07.a1");
+ std::vector<F::mask> m(in.size());
+ assert(f.scan_not(F::space, in.data(), in.data() + in.size()) - in.data() == 1);
+ assert(f.scan_not(F::print, in.data(), in.data() + in.size()) - in.data() == 2);
+ assert(f.scan_not(F::cntrl, in.data(), in.data() + in.size()) - in.data() == 0);
+ assert(f.scan_not(F::upper, in.data(), in.data() + in.size()) - in.data() == 0);
+ assert(f.scan_not(F::lower, in.data(), in.data() + in.size()) - in.data() == 0);
+ assert(f.scan_not(F::alpha, in.data(), in.data() + in.size()) - in.data() == 0);
+ assert(f.scan_not(F::digit, in.data(), in.data() + in.size()) - in.data() == 0);
+ assert(f.scan_not(F::punct, in.data(), in.data() + in.size()) - in.data() == 0);
+ assert(f.scan_not(F::xdigit, in.data(), in.data() + in.size()) - in.data() == 0);
+ assert(f.scan_not(F::blank, in.data(), in.data() + in.size()) - in.data() == 1);
+ assert(f.scan_not(F::alnum, in.data(), in.data() + in.size()) - in.data() == 0);
+ assert(f.scan_not(F::graph, in.data(), in.data() + in.size()) - in.data() == 0);
+ }
+}
diff --git a/test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/table.pass.cpp b/test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/table.pass.cpp
new file mode 100644
index 000000000000..f28f4f99b107
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/table.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class ctype<char>
+
+// const mask* table() const throw();
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+ typedef std::ctype<char> F;
+ {
+ std::locale l(std::locale::classic(), new std::ctype<char>);
+ const F& f = std::use_facet<F>(l);
+ assert(f.table() == f.classic_table());
+ }
+ {
+ std::ctype<char>::mask table[256];
+ std::locale l(std::locale::classic(), new std::ctype<char>(table));
+ const F& f = std::use_facet<F>(l);
+ assert(f.table() == table);
+ }
+}
diff --git a/test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/tolower_1.pass.cpp b/test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/tolower_1.pass.cpp
new file mode 100644
index 000000000000..1dfc95fe6b61
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/tolower_1.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class ctype<char>;
+
+// char tolower(char) const;
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+ std::locale l = std::locale::classic();
+ {
+ typedef std::ctype<char> F;
+ const F& f = std::use_facet<F>(l);
+
+ assert(f.tolower(' ') == ' ');
+ assert(f.tolower('A') == 'a');
+ assert(f.tolower('\x07') == '\x07');
+ assert(f.tolower('.') == '.');
+ assert(f.tolower('a') == 'a');
+ assert(f.tolower('1') == '1');
+ }
+}
diff --git a/test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/tolower_many.pass.cpp b/test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/tolower_many.pass.cpp
new file mode 100644
index 000000000000..22b27370e85f
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/tolower_many.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class ctype<char>;
+
+// const char* tolower(char* low, const char* high) const;
+
+#include <locale>
+#include <string>
+#include <cassert>
+
+int main()
+{
+ std::locale l = std::locale::classic();
+ {
+ typedef std::ctype<char> F;
+ const F& f = std::use_facet<F>(l);
+ std::string in(" A\x07.a1");
+
+ assert(f.tolower(&in[0], in.data() + in.size()) == in.data() + in.size());
+ assert(in[0] == ' ');
+ assert(in[1] == 'a');
+ assert(in[2] == '\x07');
+ assert(in[3] == '.');
+ assert(in[4] == 'a');
+ assert(in[5] == '1');
+ }
+}
diff --git a/test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/toupper_1.pass.cpp b/test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/toupper_1.pass.cpp
new file mode 100644
index 000000000000..2a714b1d5515
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/toupper_1.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class ctype<char>;
+
+// char toupper(char) const;
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+ std::locale l = std::locale::classic();
+ {
+ typedef std::ctype<char> F;
+ const F& f = std::use_facet<F>(l);
+
+ assert(f.toupper(' ') == ' ');
+ assert(f.toupper('A') == 'A');
+ assert(f.toupper('\x07') == '\x07');
+ assert(f.toupper('.') == '.');
+ assert(f.toupper('a') == 'A');
+ assert(f.toupper('1') == '1');
+ }
+}
diff --git a/test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/toupper_many.pass.cpp b/test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/toupper_many.pass.cpp
new file mode 100644
index 000000000000..8a842c8dfd62
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/toupper_many.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class ctype<char>;
+
+// const char* toupper(char* low, const char* high) const;
+
+#include <locale>
+#include <string>
+#include <cassert>
+
+int main()
+{
+ std::locale l = std::locale::classic();
+ {
+ typedef std::ctype<char> F;
+ const F& f = std::use_facet<F>(l);
+ std::string in(" A\x07.a1");
+
+ assert(f.toupper(&in[0], in.data() + in.size()) == in.data() + in.size());
+ assert(in[0] == ' ');
+ assert(in[1] == 'A');
+ assert(in[2] == '\x07');
+ assert(in[3] == '.');
+ assert(in[4] == 'A');
+ assert(in[5] == '1');
+ }
+}
diff --git a/test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/widen_1.pass.cpp b/test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/widen_1.pass.cpp
new file mode 100644
index 000000000000..5a65a561a91d
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/widen_1.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class ctype<char>;
+
+// char widen(char c) const;
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+ std::locale l = std::locale::classic();
+ {
+ typedef std::ctype<char> F;
+ const F& f = std::use_facet<F>(l);
+
+ assert(f.widen(' ') == ' ');
+ assert(f.widen('A') == 'A');
+ assert(f.widen('\x07') == '\x07');
+ assert(f.widen('.') == '.');
+ assert(f.widen('a') == 'a');
+ assert(f.widen('1') == '1');
+ }
+}
diff --git a/test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/widen_many.pass.cpp b/test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/widen_many.pass.cpp
new file mode 100644
index 000000000000..c86cc55ce180
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/widen_many.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class ctype<char>;
+
+// const char* widen(const char* low, const char* high, char* to) const;
+
+#include <locale>
+#include <string>
+#include <vector>
+#include <cassert>
+
+int main()
+{
+ std::locale l = std::locale::classic();
+ {
+ typedef std::ctype<char> F;
+ const F& f = std::use_facet<F>(l);
+ std::string in(" A\x07.a1");
+ std::vector<char> v(in.size());
+
+ assert(f.widen(&in[0], in.data() + in.size(), v.data()) == in.data() + in.size());
+ assert(v[0] == ' ');
+ assert(v[1] == 'A');
+ assert(v[2] == '\x07');
+ assert(v[3] == '.');
+ assert(v[4] == 'a');
+ assert(v[5] == '1');
+ }
+}
diff --git a/test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.statics/classic_table.pass.cpp b/test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.statics/classic_table.pass.cpp
new file mode 100644
index 000000000000..b5690e3c6b26
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.statics/classic_table.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class ctype<char>
+
+// static const mask* classic_table() throw();
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+ typedef std::ctype<char> F;
+ assert(F::classic_table() != 0);
+ assert(F::table_size >= 256);
+
+ typedef F::mask mask;
+ const mask *p = F::classic_table();
+ const mask defined = F::space | F::print | F::cntrl | F::upper | F::lower
+ | F::alpha | F::digit | F::punct | F::xdigit | F::blank;
+
+ for ( size_t i = 0; i < 128; ++i ) // values above 128 are not consistent
+ {
+ mask set = 0;
+
+ if ( i < 32 || i > 126 ) set |= F::cntrl;
+ if ( i >= 32 && i <= 126 ) set |= F::print;
+
+ if (( i >= 9 && i <= 13) || i == 32 ) set |= F::space;
+ if ( i == 9 || i == 32 ) set |= F::blank;
+
+ if ( i >= 'A' && i <= 'Z' ) set |= F::alpha;
+ if ( i >= 'a' && i <= 'z' ) set |= F::alpha;
+ if ( i >= 'A' && i <= 'Z' ) set |= F::upper;
+ if ( i >= 'a' && i <= 'z' ) set |= F::lower;
+
+ if ( i >= '0' && i <= '9' ) set |= F::digit;
+ if ( i >= '0' && i <= '9' ) set |= F::xdigit;
+ if ( i >= 'A' && i <= 'F' ) set |= F::xdigit;
+ if ( i >= 'a' && i <= 'f' ) set |= F::xdigit;
+
+ if ( i >= 33 && i <= 47 ) set |= F::punct; // ' ' .. '/'
+ if ( i >= 58 && i <= 64 ) set |= F::punct; // ':' .. '@'
+ if ( i >= 91 && i <= 96 ) set |= F::punct; // '[' .. '`'
+ if ( i >= 123 && i <= 126 ) set |= F::punct; // '{' .. '~' }
+
+ assert(( p[i] & set) == set); // all the right bits set
+ assert(((p[i] & ~set) & defined) == 0); // no extra ones
+ }
+
+}
diff --git a/test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.virtuals/tested_elsewhere.pass.cpp b/test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.virtuals/tested_elsewhere.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.virtuals/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/localization/locale.categories/category.ctype/facet.ctype.special/types.pass.cpp b/test/std/localization/locale.categories/category.ctype/facet.ctype.special/types.pass.cpp
new file mode 100644
index 000000000000..f58ec30ef061
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/facet.ctype.special/types.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <>
+// class ctype<char>
+// : public locale::facet,
+// public ctype_base
+// {
+// public:
+// typedef char char_type;
+// };
+
+#include <locale>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+ std::locale l = std::locale::classic();
+ {
+ assert(std::has_facet<std::ctype<char> >(l));
+ const std::ctype<char>& f = std::use_facet<std::ctype<char> >(l);
+ {
+ (void)std::ctype<char>::id;
+ }
+ static_assert((std::is_same<std::ctype<char>::char_type, char>::value), "");
+ static_assert((std::is_base_of<std::ctype_base, std::ctype<char> >::value), "");
+ static_assert((std::is_base_of<std::locale::facet, std::ctype<char> >::value), "");
+ }
+}
diff --git a/test/std/localization/locale.categories/category.ctype/locale.codecvt.byname/ctor_char.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.codecvt.byname/ctor_char.pass.cpp
new file mode 100644
index 000000000000..349577835ec6
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/locale.codecvt.byname/ctor_char.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt_byname<char, char, mbstate_t>
+
+// explicit codecvt_byname(const char* nm, size_t refs = 0);
+// explicit codecvt_byname(const string& nm, size_t refs = 0);
+
+#include <locale>
+#include <cassert>
+
+typedef std::codecvt_byname<char, char, std::mbstate_t> F;
+
+class my_facet
+ : public F
+{
+public:
+ static int count;
+
+ explicit my_facet(const char* nm, std::size_t refs = 0)
+ : F(nm, refs) {++count;}
+ explicit my_facet(const std::string& nm, std::size_t refs = 0)
+ : F(nm, refs) {++count;}
+
+ ~my_facet() {--count;}
+};
+
+int my_facet::count = 0;
+
+int main()
+{
+ {
+ std::locale l(std::locale::classic(), new my_facet("en_US"));
+ assert(my_facet::count == 1);
+ }
+ assert(my_facet::count == 0);
+ {
+ my_facet f("en_US", 1);
+ assert(my_facet::count == 1);
+ {
+ std::locale l(std::locale::classic(), &f);
+ assert(my_facet::count == 1);
+ }
+ assert(my_facet::count == 1);
+ }
+ assert(my_facet::count == 0);
+ {
+ std::locale l(std::locale::classic(), new my_facet(std::string("en_US")));
+ assert(my_facet::count == 1);
+ }
+ assert(my_facet::count == 0);
+ {
+ my_facet f(std::string("en_US"), 1);
+ assert(my_facet::count == 1);
+ {
+ std::locale l(std::locale::classic(), &f);
+ assert(my_facet::count == 1);
+ }
+ assert(my_facet::count == 1);
+ }
+ assert(my_facet::count == 0);
+}
diff --git a/test/std/localization/locale.categories/category.ctype/locale.codecvt.byname/ctor_char16_t.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.codecvt.byname/ctor_char16_t.pass.cpp
new file mode 100644
index 000000000000..0559896ba3fc
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/locale.codecvt.byname/ctor_char16_t.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt_byname<char16_t, char, mbstate_t>
+
+// explicit codecvt_byname(const char* nm, size_t refs = 0);
+// explicit codecvt_byname(const string& nm, size_t refs = 0);
+
+#include <locale>
+#include <cassert>
+
+typedef std::codecvt_byname<char16_t, char, std::mbstate_t> F;
+
+class my_facet
+ : public F
+{
+public:
+ static int count;
+
+ explicit my_facet(const char* nm, std::size_t refs = 0)
+ : F(nm, refs) {++count;}
+ explicit my_facet(const std::string& nm, std::size_t refs = 0)
+ : F(nm, refs) {++count;}
+
+ ~my_facet() {--count;}
+};
+
+int my_facet::count = 0;
+
+int main()
+{
+ {
+ std::locale l(std::locale::classic(), new my_facet("en_US"));
+ assert(my_facet::count == 1);
+ }
+ assert(my_facet::count == 0);
+ {
+ my_facet f("en_US", 1);
+ assert(my_facet::count == 1);
+ {
+ std::locale l(std::locale::classic(), &f);
+ assert(my_facet::count == 1);
+ }
+ assert(my_facet::count == 1);
+ }
+ assert(my_facet::count == 0);
+ {
+ std::locale l(std::locale::classic(), new my_facet(std::string("en_US")));
+ assert(my_facet::count == 1);
+ }
+ assert(my_facet::count == 0);
+ {
+ my_facet f(std::string("en_US"), 1);
+ assert(my_facet::count == 1);
+ {
+ std::locale l(std::locale::classic(), &f);
+ assert(my_facet::count == 1);
+ }
+ assert(my_facet::count == 1);
+ }
+ assert(my_facet::count == 0);
+}
diff --git a/test/std/localization/locale.categories/category.ctype/locale.codecvt.byname/ctor_char32_t.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.codecvt.byname/ctor_char32_t.pass.cpp
new file mode 100644
index 000000000000..8eda52defafe
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/locale.codecvt.byname/ctor_char32_t.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt_byname<char32_t, char, mbstate_t>
+
+// explicit codecvt_byname(const char* nm, size_t refs = 0);
+// explicit codecvt_byname(const string& nm, size_t refs = 0);
+
+#include <locale>
+#include <cassert>
+
+typedef std::codecvt_byname<char32_t, char, std::mbstate_t> F;
+
+class my_facet
+ : public F
+{
+public:
+ static int count;
+
+ explicit my_facet(const char* nm, std::size_t refs = 0)
+ : F(nm, refs) {++count;}
+ explicit my_facet(const std::string& nm, std::size_t refs = 0)
+ : F(nm, refs) {++count;}
+
+ ~my_facet() {--count;}
+};
+
+int my_facet::count = 0;
+
+int main()
+{
+ {
+ std::locale l(std::locale::classic(), new my_facet("en_US"));
+ assert(my_facet::count == 1);
+ }
+ assert(my_facet::count == 0);
+ {
+ my_facet f("en_US", 1);
+ assert(my_facet::count == 1);
+ {
+ std::locale l(std::locale::classic(), &f);
+ assert(my_facet::count == 1);
+ }
+ assert(my_facet::count == 1);
+ }
+ assert(my_facet::count == 0);
+ {
+ std::locale l(std::locale::classic(), new my_facet(std::string("en_US")));
+ assert(my_facet::count == 1);
+ }
+ assert(my_facet::count == 0);
+ {
+ my_facet f(std::string("en_US"), 1);
+ assert(my_facet::count == 1);
+ {
+ std::locale l(std::locale::classic(), &f);
+ assert(my_facet::count == 1);
+ }
+ assert(my_facet::count == 1);
+ }
+ assert(my_facet::count == 0);
+}
diff --git a/test/std/localization/locale.categories/category.ctype/locale.codecvt.byname/ctor_wchar_t.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.codecvt.byname/ctor_wchar_t.pass.cpp
new file mode 100644
index 000000000000..bc55f009e0a8
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/locale.codecvt.byname/ctor_wchar_t.pass.cpp
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt_byname<wchar_t, char, mbstate_t>
+
+// explicit codecvt_byname(const char* nm, size_t refs = 0);
+// explicit codecvt_byname(const string& nm, size_t refs = 0);
+
+#include <locale>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+typedef std::codecvt_byname<wchar_t, char, std::mbstate_t> F;
+
+class my_facet
+ : public F
+{
+public:
+ static int count;
+
+ explicit my_facet(const char* nm, std::size_t refs = 0)
+ : F(nm, refs) {++count;}
+ explicit my_facet(const std::string& nm, std::size_t refs = 0)
+ : F(nm, refs) {++count;}
+
+ ~my_facet() {--count;}
+};
+
+int my_facet::count = 0;
+
+int main()
+{
+ {
+ std::locale l(std::locale::classic(), new my_facet(LOCALE_en_US_UTF_8));
+ assert(my_facet::count == 1);
+ }
+ assert(my_facet::count == 0);
+ {
+ my_facet f(LOCALE_en_US_UTF_8, 1);
+ assert(my_facet::count == 1);
+ {
+ std::locale l(std::locale::classic(), &f);
+ assert(my_facet::count == 1);
+ }
+ assert(my_facet::count == 1);
+ }
+ assert(my_facet::count == 0);
+ {
+ std::locale l(std::locale::classic(), new my_facet(std::string(LOCALE_en_US_UTF_8)));
+ assert(my_facet::count == 1);
+ }
+ assert(my_facet::count == 0);
+ {
+ my_facet f(std::string(LOCALE_en_US_UTF_8), 1);
+ assert(my_facet::count == 1);
+ {
+ std::locale l(std::locale::classic(), &f);
+ assert(my_facet::count == 1);
+ }
+ assert(my_facet::count == 1);
+ }
+ assert(my_facet::count == 0);
+}
diff --git a/test/std/localization/locale.categories/category.ctype/locale.codecvt/codecvt_base.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.codecvt/codecvt_base.pass.cpp
new file mode 100644
index 000000000000..a2973b7f371c
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/locale.codecvt/codecvt_base.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class codecvt_base
+// {
+// public:
+// enum result {ok, partial, error, noconv};
+// };
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+ assert(std::codecvt_base::ok == 0);
+ assert(std::codecvt_base::partial == 1);
+ assert(std::codecvt_base::error == 2);
+ assert(std::codecvt_base::noconv == 3);
+}
diff --git a/test/std/localization/locale.categories/category.ctype/locale.codecvt/ctor_char.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.codecvt/ctor_char.pass.cpp
new file mode 100644
index 000000000000..121a815bfc09
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/locale.codecvt/ctor_char.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<char, char, mbstate_t>
+
+// explicit codecvt(size_t refs = 0);
+
+#include <locale>
+#include <cassert>
+
+typedef std::codecvt<char, char, std::mbstate_t> F;
+
+class my_facet
+ : public F
+{
+public:
+ static int count;
+
+ explicit my_facet(std::size_t refs = 0)
+ : F(refs) {++count;}
+
+ ~my_facet() {--count;}
+};
+
+int my_facet::count = 0;
+
+int main()
+{
+ {
+ std::locale l(std::locale::classic(), new my_facet);
+ assert(my_facet::count == 1);
+ }
+ assert(my_facet::count == 0);
+ {
+ my_facet f(1);
+ assert(my_facet::count == 1);
+ {
+ std::locale l(std::locale::classic(), &f);
+ assert(my_facet::count == 1);
+ }
+ assert(my_facet::count == 1);
+ }
+ assert(my_facet::count == 0);
+}
diff --git a/test/std/localization/locale.categories/category.ctype/locale.codecvt/ctor_char16_t.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.codecvt/ctor_char16_t.pass.cpp
new file mode 100644
index 000000000000..5a6cdee9fafd
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/locale.codecvt/ctor_char16_t.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<char16_t, char, mbstate_t>
+
+// explicit codecvt(size_t refs = 0);
+
+#include <locale>
+#include <cassert>
+
+//#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+
+typedef std::codecvt<char16_t, char, std::mbstate_t> F;
+
+class my_facet
+ : public F
+{
+public:
+ static int count;
+
+ explicit my_facet(std::size_t refs = 0)
+ : F(refs) {++count;}
+
+ ~my_facet() {--count;}
+};
+
+int my_facet::count = 0;
+
+//#endif
+
+int main()
+{
+//#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+ {
+ std::locale l(std::locale::classic(), new my_facet);
+ assert(my_facet::count == 1);
+ }
+ assert(my_facet::count == 0);
+ {
+ my_facet f(1);
+ assert(my_facet::count == 1);
+ {
+ std::locale l(std::locale::classic(), &f);
+ assert(my_facet::count == 1);
+ }
+ assert(my_facet::count == 1);
+ }
+ assert(my_facet::count == 0);
+//#endif
+}
diff --git a/test/std/localization/locale.categories/category.ctype/locale.codecvt/ctor_char32_t.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.codecvt/ctor_char32_t.pass.cpp
new file mode 100644
index 000000000000..fae0d7bb2242
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/locale.codecvt/ctor_char32_t.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<char32_t, char, mbstate_t>
+
+// explicit codecvt(size_t refs = 0);
+
+#include <locale>
+#include <cassert>
+
+//#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+
+typedef std::codecvt<char32_t, char, std::mbstate_t> F;
+
+class my_facet
+ : public F
+{
+public:
+ static int count;
+
+ explicit my_facet(std::size_t refs = 0)
+ : F(refs) {++count;}
+
+ ~my_facet() {--count;}
+};
+
+int my_facet::count = 0;
+
+//#endif
+
+int main()
+{
+//#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+ {
+ std::locale l(std::locale::classic(), new my_facet);
+ assert(my_facet::count == 1);
+ }
+ assert(my_facet::count == 0);
+ {
+ my_facet f(1);
+ assert(my_facet::count == 1);
+ {
+ std::locale l(std::locale::classic(), &f);
+ assert(my_facet::count == 1);
+ }
+ assert(my_facet::count == 1);
+ }
+ assert(my_facet::count == 0);
+//#endif
+}
diff --git a/test/std/localization/locale.categories/category.ctype/locale.codecvt/ctor_wchar_t.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.codecvt/ctor_wchar_t.pass.cpp
new file mode 100644
index 000000000000..4cd84f243469
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/locale.codecvt/ctor_wchar_t.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<wchar_t, char, mbstate_t>
+
+// explicit codecvt(size_t refs = 0);
+
+#include <locale>
+#include <cassert>
+
+typedef std::codecvt<wchar_t, char, std::mbstate_t> F;
+
+class my_facet
+ : public F
+{
+public:
+ static int count;
+
+ explicit my_facet(std::size_t refs = 0)
+ : F(refs) {++count;}
+
+ ~my_facet() {--count;}
+};
+
+int my_facet::count = 0;
+
+int main()
+{
+ {
+ std::locale l(std::locale::classic(), new my_facet);
+ assert(my_facet::count == 1);
+ }
+ assert(my_facet::count == 0);
+ {
+ my_facet f(1);
+ assert(my_facet::count == 1);
+ {
+ std::locale l(std::locale::classic(), &f);
+ assert(my_facet::count == 1);
+ }
+ assert(my_facet::count == 1);
+ }
+ assert(my_facet::count == 0);
+}
diff --git a/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_always_noconv.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_always_noconv.pass.cpp
new file mode 100644
index 000000000000..4a0f94f98836
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_always_noconv.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<char16_t, char, mbstate_t>
+
+// bool always_noconv() const throw();
+
+#include <locale>
+#include <cassert>
+
+typedef std::codecvt<char16_t, char, std::mbstate_t> F;
+
+int main()
+{
+ std::locale l = std::locale::classic();
+ const F& f = std::use_facet<F>(l);
+ assert(!f.always_noconv());
+}
diff --git a/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_encoding.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_encoding.pass.cpp
new file mode 100644
index 000000000000..d2a6ae3955e0
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_encoding.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<char16_t, char, mbstate_t>
+
+// int encoding() const throw();
+
+#include <locale>
+#include <cassert>
+
+typedef std::codecvt<char16_t, char, std::mbstate_t> F;
+
+int main()
+{
+ std::locale l = std::locale::classic();
+ const F& f = std::use_facet<F>(l);
+ assert(f.encoding() == 0);
+}
diff --git a/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_in.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_in.pass.cpp
new file mode 100644
index 000000000000..331f4ba222dd
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_in.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<char16_t, char, mbstate_t>
+
+// result in(stateT& state,
+// const externT* from, const externT* from_end, const externT*& from_next,
+// internT* to, internT* to_end, internT*& to_next) const;
+
+#include <locale>
+#include <string>
+#include <vector>
+#include <cassert>
+
+typedef std::codecvt<char16_t, char, std::mbstate_t> F;
+
+int main()
+{
+ std::locale l = std::locale::classic();
+ const char from[] = "some text";
+ F::intern_type to[9];
+ const F& f = std::use_facet<F>(l);
+ std::mbstate_t mbs = {0};
+ const char* from_next = 0;
+ F::intern_type* to_next = 0;
+ assert(f.in(mbs, from, from + 9, from_next,
+ to, to + 9, to_next) == F::ok);
+ assert(from_next - from == 9);
+ assert(to_next - to == 9);
+ for (unsigned i = 0; i < 9; ++i)
+ assert(to[i] == from[i]);
+}
diff --git a/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_length.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_length.pass.cpp
new file mode 100644
index 000000000000..34ab2178327e
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_length.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<char16_t, char, mbstate_t>
+
+// int length(stateT& state, const externT* from, const externT* from_end, size_t max) const;
+
+#include <locale>
+#include <cassert>
+
+typedef std::codecvt<char16_t, char, std::mbstate_t> F;
+
+int main()
+{
+ std::locale l = std::locale::classic();
+ const F& f = std::use_facet<F>(l);
+ std::mbstate_t mbs = {0};
+ const char from[] = "some text";
+ assert(f.length(mbs, from, from+10, 0) == 0);
+ assert(f.length(mbs, from, from+10, 8) == 8);
+ assert(f.length(mbs, from, from+10, 9) == 9);
+ assert(f.length(mbs, from, from+10, 10) == 10);
+ assert(f.length(mbs, from, from+10, 100) == 10);
+}
diff --git a/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_max_length.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_max_length.pass.cpp
new file mode 100644
index 000000000000..8abe10b82583
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_max_length.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<char16_t, char, mbstate_t>
+
+// int max_length() const throw();
+
+#include <locale>
+#include <cassert>
+
+typedef std::codecvt<char16_t, char, std::mbstate_t> F;
+
+int main()
+{
+ std::locale l = std::locale::classic();
+ const F& f = std::use_facet<F>(l);
+ assert(f.max_length() == 4);
+}
diff --git a/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_out.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_out.pass.cpp
new file mode 100644
index 000000000000..0f65f13242c2
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_out.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<char16_t, char, mbstate_t>
+
+// result out(stateT& state,
+// const internT* from, const internT* from_end, const internT*& from_next,
+// externT* to, externT* to_end, externT*& to_next) const;
+
+#include <locale>
+#include <string>
+#include <vector>
+#include <cassert>
+
+#include <stdio.h>
+
+typedef std::codecvt<char16_t, char, std::mbstate_t> F;
+
+int main()
+{
+ std::locale l = std::locale::classic();
+ const F& f = std::use_facet<F>(l);
+ {
+ F::intern_type from[9] = {'s', 'o', 'm', 'e', ' ', 't', 'e', 'x', 't'};
+ char to[9] = {0};
+ std::mbstate_t mbs = {0};
+ const F::intern_type* from_next = 0;
+ char* to_next = 0;
+ F::result r = f.out(mbs, from, from + 9, from_next,
+ to, to + 9, to_next);
+ assert(r == F::ok);
+ assert(from_next - from == 9);
+ assert(to_next - to == 9);
+ for (unsigned i = 0; i < 9; ++i)
+ assert(to[i] == from[i]);
+ }
+}
diff --git a/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_unshift.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_unshift.pass.cpp
new file mode 100644
index 000000000000..c21303070717
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_unshift.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<char16_t, char, mbstate_t>
+
+// result unshift(stateT& state,
+// externT* to, externT* to_end, externT*& to_next) const;
+
+#include <locale>
+#include <string>
+#include <vector>
+#include <cassert>
+
+typedef std::codecvt<char16_t, char, std::mbstate_t> F;
+
+int main()
+{
+ std::locale l = std::locale::classic();
+ std::vector<char> to(3);
+ const F& f = std::use_facet<F>(l);
+ std::mbstate_t mbs = {0};
+ char* to_next = 0;
+ assert(f.unshift(mbs, to.data(), to.data() + to.size(), to_next) == F::noconv);
+ assert(to_next == to.data());
+}
diff --git a/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_always_noconv.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_always_noconv.pass.cpp
new file mode 100644
index 000000000000..2270a308f54f
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_always_noconv.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<char32_t, char, mbstate_t>
+
+// bool always_noconv() const throw();
+
+#include <locale>
+#include <cassert>
+
+typedef std::codecvt<char32_t, char, std::mbstate_t> F;
+
+int main()
+{
+ std::locale l = std::locale::classic();
+ const F& f = std::use_facet<F>(l);
+ assert(!f.always_noconv());
+}
diff --git a/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_encoding.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_encoding.pass.cpp
new file mode 100644
index 000000000000..175470a67c58
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_encoding.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<char32_t, char, mbstate_t>
+
+// int encoding() const throw();
+
+#include <locale>
+#include <cassert>
+
+typedef std::codecvt<char32_t, char, std::mbstate_t> F;
+
+int main()
+{
+ std::locale l = std::locale::classic();
+ const F& f = std::use_facet<F>(l);
+ assert(f.encoding() == 0);
+}
diff --git a/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_in.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_in.pass.cpp
new file mode 100644
index 000000000000..8fb28f0a26ac
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_in.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<char32_t, char, mbstate_t>
+
+// result in(stateT& state,
+// const externT* from, const externT* from_end, const externT*& from_next,
+// internT* to, internT* to_end, internT*& to_next) const;
+
+#include <locale>
+#include <string>
+#include <vector>
+#include <cassert>
+
+typedef std::codecvt<char32_t, char, std::mbstate_t> F;
+
+int main()
+{
+ std::locale l = std::locale::classic();
+ const char from[] = "some text";
+ F::intern_type to[9];
+ const F& f = std::use_facet<F>(l);
+ std::mbstate_t mbs = {0};
+ const char* from_next = 0;
+ F::intern_type* to_next = 0;
+ assert(f.in(mbs, from, from + 9, from_next,
+ to, to + 9, to_next) == F::ok);
+ assert(from_next - from == 9);
+ assert(to_next - to == 9);
+ for (unsigned i = 0; i < 9; ++i)
+ assert(to[i] == from[i]);
+}
diff --git a/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_length.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_length.pass.cpp
new file mode 100644
index 000000000000..d8555d188566
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_length.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<char32_t, char, mbstate_t>
+
+// int length(stateT& state, const externT* from, const externT* from_end, size_t max) const;
+
+#include <locale>
+#include <cassert>
+
+typedef std::codecvt<char32_t, char, std::mbstate_t> F;
+
+int main()
+{
+ std::locale l = std::locale::classic();
+ const F& f = std::use_facet<F>(l);
+ std::mbstate_t mbs = {0};
+ const char from[] = "some text";
+ assert(f.length(mbs, from, from+10, 0) == 0);
+ assert(f.length(mbs, from, from+10, 8) == 8);
+ assert(f.length(mbs, from, from+10, 9) == 9);
+ assert(f.length(mbs, from, from+10, 10) == 10);
+ assert(f.length(mbs, from, from+10, 100) == 10);
+}
diff --git a/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_max_length.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_max_length.pass.cpp
new file mode 100644
index 000000000000..62b4919c5cfc
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_max_length.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<char32_t, char, mbstate_t>
+
+// int max_length() const throw();
+
+#include <locale>
+#include <cassert>
+
+typedef std::codecvt<char32_t, char, std::mbstate_t> F;
+
+int main()
+{
+ std::locale l = std::locale::classic();
+ const F& f = std::use_facet<F>(l);
+ assert(f.max_length() == 4);
+}
diff --git a/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_out.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_out.pass.cpp
new file mode 100644
index 000000000000..a1d11f748d9f
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_out.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<char32_t, char, mbstate_t>
+
+// result out(stateT& state,
+// const internT* from, const internT* from_end, const internT*& from_next,
+// externT* to, externT* to_end, externT*& to_next) const;
+
+#include <locale>
+#include <string>
+#include <vector>
+#include <cassert>
+
+#include <stdio.h>
+
+typedef std::codecvt<char32_t, char, std::mbstate_t> F;
+
+int main()
+{
+ std::locale l = std::locale::classic();
+ const F& f = std::use_facet<F>(l);
+ {
+ F::intern_type from[9] = {'s', 'o', 'm', 'e', ' ', 't', 'e', 'x', 't'};
+ char to[9] = {0};
+ std::mbstate_t mbs = {0};
+ const F::intern_type* from_next = 0;
+ char* to_next = 0;
+ F::result r = f.out(mbs, from, from + 9, from_next,
+ to, to + 9, to_next);
+ assert(r == F::ok);
+ assert(from_next - from == 9);
+ assert(to_next - to == 9);
+ for (unsigned i = 0; i < 9; ++i)
+ assert(to[i] == from[i]);
+ }
+}
diff --git a/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_unshift.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_unshift.pass.cpp
new file mode 100644
index 000000000000..1bd45e0370d9
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_unshift.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<char32_t, char, mbstate_t>
+
+// result unshift(stateT& state,
+// externT* to, externT* to_end, externT*& to_next) const;
+
+#include <locale>
+#include <string>
+#include <vector>
+#include <cassert>
+
+typedef std::codecvt<char32_t, char, std::mbstate_t> F;
+
+int main()
+{
+ std::locale l = std::locale::classic();
+ std::vector<char> to(3);
+ const F& f = std::use_facet<F>(l);
+ std::mbstate_t mbs = {0};
+ char* to_next = 0;
+ assert(f.unshift(mbs, to.data(), to.data() + to.size(), to_next) == F::noconv);
+ assert(to_next == to.data());
+}
diff --git a/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_always_noconv.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_always_noconv.pass.cpp
new file mode 100644
index 000000000000..71640490eadc
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_always_noconv.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<char, char, mbstate_t>
+
+// bool always_noconv() const throw();
+
+#include <locale>
+#include <cassert>
+
+typedef std::codecvt<char, char, std::mbstate_t> F;
+
+int main()
+{
+ std::locale l = std::locale::classic();
+ const F& f = std::use_facet<F>(l);
+ assert(f.always_noconv());
+}
diff --git a/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_encoding.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_encoding.pass.cpp
new file mode 100644
index 000000000000..79bc2bfa5e3b
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_encoding.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<char, char, mbstate_t>
+
+// int encoding() const throw();
+
+#include <locale>
+#include <cassert>
+
+typedef std::codecvt<char, char, std::mbstate_t> F;
+
+int main()
+{
+ std::locale l = std::locale::classic();
+ const F& f = std::use_facet<F>(l);
+ assert(f.encoding() == 1);
+}
diff --git a/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_in.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_in.pass.cpp
new file mode 100644
index 000000000000..4d2f6f260dfc
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_in.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<char, char, mbstate_t>
+
+// result in(stateT& state,
+// const externT* from, const externT* from_end, const externT*& from_next,
+// internT* to, internT* to_end, internT*& to_next) const;
+
+#include <locale>
+#include <string>
+#include <vector>
+#include <cassert>
+
+typedef std::codecvt<char, char, std::mbstate_t> F;
+
+int main()
+{
+ std::locale l = std::locale::classic();
+ const std::basic_string<F::intern_type> from("some text");
+ std::vector<char> to(from.size());
+ const F& f = std::use_facet<F>(l);
+ std::mbstate_t mbs = {0};
+ const char* from_next = 0;
+ char* to_next = 0;
+ assert(f.in(mbs, from.data(), from.data() + from.size(), from_next,
+ to.data(), to.data() + to.size(), to_next) == F::noconv);
+ assert(from_next == from.data());
+ assert(to_next == to.data());
+}
diff --git a/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_length.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_length.pass.cpp
new file mode 100644
index 000000000000..df33b182a07a
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_length.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<char, char, mbstate_t>
+
+// int length(stateT& state, const externT* from, const externT* from_end, size_t max) const;
+
+#include <locale>
+#include <cassert>
+
+typedef std::codecvt<char, char, std::mbstate_t> F;
+
+int main()
+{
+ std::locale l = std::locale::classic();
+ const F& f = std::use_facet<F>(l);
+ std::mbstate_t mbs = {0};
+ const char from[10]= {0};
+ assert(f.length(mbs, from, from+10, 0) == 0);
+ assert(f.length(mbs, from, from+10, 9) == 9);
+ assert(f.length(mbs, from, from+10, 10) == 10);
+ assert(f.length(mbs, from, from+10, 11) == 10);
+ assert(f.length(mbs, from, from+10, 100) == 10);
+}
diff --git a/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_max_length.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_max_length.pass.cpp
new file mode 100644
index 000000000000..626c65244570
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_max_length.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<char, char, mbstate_t>
+
+// int max_length() const throw();
+
+#include <locale>
+#include <cassert>
+
+typedef std::codecvt<char, char, std::mbstate_t> F;
+
+int main()
+{
+ std::locale l = std::locale::classic();
+ const F& f = std::use_facet<F>(l);
+ assert(f.max_length() == 1);
+}
diff --git a/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_out.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_out.pass.cpp
new file mode 100644
index 000000000000..de7f024fd467
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_out.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<char, char, mbstate_t>
+
+// result out(stateT& state,
+// const internT* from, const internT* from_end, const internT*& from_next,
+// externT* to, externT* to_end, externT*& to_next) const;
+
+#include <locale>
+#include <string>
+#include <vector>
+#include <cassert>
+
+typedef std::codecvt<char, char, std::mbstate_t> F;
+
+int main()
+{
+ std::locale l = std::locale::classic();
+ const std::basic_string<F::intern_type> from("some text");
+ std::vector<char> to(from.size());
+ const F& f = std::use_facet<F>(l);
+ std::mbstate_t mbs = {0};
+ const char* from_next = 0;
+ char* to_next = 0;
+ assert(f.out(mbs, from.data(), from.data() + from.size(), from_next,
+ to.data(), to.data() + to.size(), to_next) == F::noconv);
+ assert(from_next == from.data());
+ assert(to_next == to.data());
+}
diff --git a/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_unshift.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_unshift.pass.cpp
new file mode 100644
index 000000000000..830bc43e9ead
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_unshift.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<char, char, mbstate_t>
+
+// result unshift(stateT& state,
+// externT* to, externT* to_end, externT*& to_next) const;
+
+#include <locale>
+#include <string>
+#include <vector>
+#include <cassert>
+
+typedef std::codecvt<char, char, std::mbstate_t> F;
+
+int main()
+{
+ std::locale l = std::locale::classic();
+ std::vector<char> to(3);
+ const F& f = std::use_facet<F>(l);
+ std::mbstate_t mbs = {0};
+ char* to_next = 0;
+ assert(f.unshift(mbs, to.data(), to.data() + to.size(), to_next) == F::noconv);
+ assert(to_next == to.data());
+}
diff --git a/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/utf_sanity_check.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/utf_sanity_check.pass.cpp
new file mode 100644
index 000000000000..2505582c2613
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/utf_sanity_check.pass.cpp
@@ -0,0 +1,127 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<char32_t, char, mbstate_t>
+// template <> class codecvt<char16_t, char, mbstate_t>
+// template <> class codecvt<char32_t, char16_t, mbstate_t> // extension
+
+// sanity check
+
+#include <locale>
+#include <codecvt>
+#include <cassert>
+
+#include <stdio.h>
+
+int main()
+{
+ typedef std::codecvt<char32_t, char, std::mbstate_t> F32_8;
+ typedef std::codecvt<char16_t, char, std::mbstate_t> F16_8;
+ typedef std::codecvt_utf16<char32_t> F32_16;
+ std::locale l = std::locale(std::locale::classic(), new F32_16);
+ const F32_8& f32_8 = std::use_facet<F32_8>(std::locale::classic());
+ const F32_16& f32_16 = std::use_facet<F32_16>(l);
+ const F16_8& f16_8 = std::use_facet<F16_8>(std::locale::classic());
+ std::mbstate_t mbs = {0};
+ F32_8::intern_type* c32p;
+ F16_8::intern_type* c16p;
+ F32_8::extern_type* c8p;
+ const F32_8::intern_type* c_c32p;
+ const F16_8::intern_type* c_c16p;
+ const F32_8::extern_type* c_c8p;
+ F32_8::intern_type c32;
+ F16_8::intern_type c16[2];
+ char c16c[4];
+ char* c16cp;
+ F32_8::extern_type c8[4];
+ for (F32_8::intern_type c32x = 0; c32x < 0x110003; ++c32x)
+ {
+ if ((0xD800 <= c32x && c32x < 0xE000) || c32x >= 0x110000)
+ {
+ assert(f32_16.out(mbs, &c32x, &c32x+1, c_c32p, c16c+0, c16c+4, c16cp) == F32_8::error);
+ assert(f32_8.out(mbs, &c32x, &c32x+1, c_c32p, c8, c8+4, c8p) == F32_8::error);
+ }
+ else
+ {
+ assert(f32_16.out(mbs, &c32x, &c32x+1, c_c32p, c16c, c16c+4, c16cp) == F32_8::ok);
+ assert(c_c32p-&c32x == 1);
+ if (c32x < 0x10000)
+ assert(c16cp-c16c == 2);
+ else
+ assert(c16cp-c16c == 4);
+ for (int i = 0; i < (c16cp - c16c) / 2; ++i)
+ c16[i] = (unsigned char)c16c[2*i] << 8 | (unsigned char)c16c[2*i+1];
+ c_c16p = c16 + (c16cp - c16c) / 2;
+ assert(f16_8.out(mbs, c16, c_c16p, c_c16p, c8, c8+4, c8p) == F32_8::ok);
+ if (c32x < 0x10000)
+ assert(c_c16p-c16 == 1);
+ else
+ assert(c_c16p-c16 == 2);
+ if (c32x < 0x80)
+ assert(c8p-c8 == 1);
+ else if (c32x < 0x800)
+ assert(c8p-c8 == 2);
+ else if (c32x < 0x10000)
+ assert(c8p-c8 == 3);
+ else
+ assert(c8p-c8 == 4);
+ c_c8p = c8p;
+ assert(f32_8.in(mbs, c8, c_c8p, c_c8p, &c32, &c32+1, c32p) == F32_8::ok);
+ if (c32x < 0x80)
+ assert(c_c8p-c8 == 1);
+ else if (c32x < 0x800)
+ assert(c_c8p-c8 == 2);
+ else if (c32x < 0x10000)
+ assert(c_c8p-c8 == 3);
+ else
+ assert(c_c8p-c8 == 4);
+ assert(c32p-&c32 == 1);
+ assert(c32 == c32x);
+ assert(f32_8.out(mbs, &c32x, &c32x+1, c_c32p, c8, c8+4, c8p) == F32_8::ok);
+ assert(c_c32p-&c32x == 1);
+ if (c32x < 0x80)
+ assert(c8p-c8 == 1);
+ else if (c32x < 0x800)
+ assert(c8p-c8 == 2);
+ else if (c32x < 0x10000)
+ assert(c8p-c8 == 3);
+ else
+ assert(c8p-c8 == 4);
+ c_c8p = c8p;
+ assert(f16_8.in(mbs, c8, c_c8p, c_c8p, c16, c16+2, c16p) == F32_8::ok);
+ if (c32x < 0x80)
+ assert(c_c8p-c8 == 1);
+ else if (c32x < 0x800)
+ assert(c_c8p-c8 == 2);
+ else if (c32x < 0x10000)
+ assert(c_c8p-c8 == 3);
+ else
+ assert(c_c8p-c8 == 4);
+ if (c32x < 0x10000)
+ assert(c16p-c16 == 1);
+ else
+ assert(c16p-c16 == 2);
+ for (int i = 0; i < c16p-c16; ++i)
+ {
+ c16c[2*i] = static_cast<char>(c16[i] >> 8);
+ c16c[2*i+1] = static_cast<char>(c16[i]);
+ }
+ const char* c_c16cp = c16c + (c16p-c16)*2;
+ assert(f32_16.in(mbs, c16c, c_c16cp, c_c16cp, &c32, &c32+1, c32p) == F32_8::ok);
+ if (c32x < 0x10000)
+ assert(c_c16cp-c16c == 2);
+ else
+ assert(c_c16cp-c16c == 4);
+ assert(c32p-&c32 == 1);
+ assert(c32 == c32x);
+ }
+ }
+}
diff --git a/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_always_noconv.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_always_noconv.pass.cpp
new file mode 100644
index 000000000000..258998ff4eb3
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_always_noconv.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<wchar_t, char, mbstate_t>
+
+// bool always_noconv() const throw();
+
+#include <locale>
+#include <cassert>
+
+typedef std::codecvt<wchar_t, char, std::mbstate_t> F;
+
+int main()
+{
+ std::locale l = std::locale::classic();
+ const F& f = std::use_facet<F>(l);
+ assert(!f.always_noconv());
+}
diff --git a/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_encoding.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_encoding.pass.cpp
new file mode 100644
index 000000000000..b7604f33d630
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_encoding.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<wchar_t, char, mbstate_t>
+
+// int encoding() const throw();
+
+#include <locale>
+#include <cassert>
+
+typedef std::codecvt<wchar_t, char, std::mbstate_t> F;
+
+int main()
+{
+ std::locale l = std::locale::classic();
+ const F& f = std::use_facet<F>(l);
+ assert(f.encoding() == 1);
+}
diff --git a/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_in.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_in.pass.cpp
new file mode 100644
index 000000000000..e98097ba889c
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_in.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<wchar_t, char, mbstate_t>
+
+// result in(stateT& state,
+// const externT* from, const externT* from_end, const externT*& from_next,
+// internT* to, internT* to_end, internT*& to_next) const;
+
+#include <locale>
+#include <string>
+#include <vector>
+#include <cassert>
+
+typedef std::codecvt<wchar_t, char, std::mbstate_t> F;
+
+int main()
+{
+ std::locale l = std::locale::classic();
+ const std::basic_string<F::extern_type> from("some text");
+ const std::basic_string<F::intern_type> expected(from.begin(), from.end());
+ std::basic_string<F::intern_type> to(from.size(), F::intern_type());
+ const F& f = std::use_facet<F>(l);
+ std::mbstate_t mbs = {0};
+ const F::extern_type* from_next = 0;
+ F::intern_type* to_next = 0;
+ F::result r = f.in(mbs, from.data(), from.data() + from.size(), from_next,
+ &to[0], &to[0] + to.size(), to_next);
+ assert(r == F::ok);
+ assert(from_next - from.data() == from.size());
+ assert(to_next - to.data() == expected.size());
+ assert(to_next - to.data() == expected.size());
+ assert(to == expected);
+}
diff --git a/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_length.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_length.pass.cpp
new file mode 100644
index 000000000000..f97f2b4a324d
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_length.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<wchar_t, char, mbstate_t>
+
+// int length(stateT& state, const externT* from, const externT* from_end, size_t max) const;
+
+#include <locale>
+#include <cassert>
+
+typedef std::codecvt<wchar_t, char, std::mbstate_t> F;
+
+int main()
+{
+ std::locale l = std::locale::classic();
+ const F& f = std::use_facet<F>(l);
+ std::mbstate_t mbs = {0};
+ const char* from = "123467890";
+ assert(f.length(mbs, from, from+10, 0) == 0);
+ assert(f.length(mbs, from, from+10, 9) == 9);
+ assert(f.length(mbs, from, from+10, 10) == 10);
+ assert(f.length(mbs, from, from+10, 11) == 10);
+ assert(f.length(mbs, from, from+10, 100) == 10);
+}
diff --git a/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_max_length.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_max_length.pass.cpp
new file mode 100644
index 000000000000..38ce51455688
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_max_length.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<wchar_t, char, mbstate_t>
+
+// int max_length() const throw();
+
+#include <locale>
+#include <cassert>
+
+typedef std::codecvt<wchar_t, char, std::mbstate_t> F;
+
+int main()
+{
+ std::locale l = std::locale::classic();
+ const F& f = std::use_facet<F>(l);
+ assert(f.max_length() == 1);
+}
diff --git a/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_out.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_out.pass.cpp
new file mode 100644
index 000000000000..dce2d38c8279
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_out.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<wchar_t, char, mbstate_t>
+
+// result out(stateT& state,
+// const internT* from, const internT* from_end, const internT*& from_next,
+// externT* to, externT* to_end, externT*& to_next) const;
+
+#include <locale>
+#include <string>
+#include <vector>
+#include <cassert>
+
+typedef std::codecvt<wchar_t, char, std::mbstate_t> F;
+
+int main()
+{
+ std::locale l = std::locale::classic();
+ const F& f = std::use_facet<F>(l);
+ {
+ const std::basic_string<F::intern_type> from(L"some text");
+ std::vector<char> to(from.size()+1);
+ std::mbstate_t mbs = {0};
+ const F::intern_type* from_next = 0;
+ char* to_next = 0;
+ F::result r = f.out(mbs, from.data(), from.data() + from.size(), from_next,
+ to.data(), to.data() + to.size(), to_next);
+ assert(r == F::ok);
+ assert(from_next - from.data() == from.size());
+ assert(to_next - to.data() == from.size());
+ assert(to.data() == std::string("some text"));
+ }
+ {
+ std::basic_string<F::intern_type> from(L"some text");
+ from[4] = '\0';
+ std::vector<char> to(from.size()+1);
+ std::mbstate_t mbs = {0};
+ const F::intern_type* from_next = 0;
+ char* to_next = 0;
+ F::result r = f.out(mbs, from.data(), from.data() + from.size(), from_next,
+ to.data(), to.data() + to.size(), to_next);
+ assert(r == F::ok);
+ assert(from_next - from.data() == from.size());
+ assert(to_next - to.data() == from.size());
+ assert(memcmp(to.data(), "some\0text", from.size()) == 0);
+ }
+ {
+ std::basic_string<F::intern_type> from(L"some text");
+ std::vector<char> to(from.size()-1);
+ std::mbstate_t mbs = {0};
+ const F::intern_type* from_next = 0;
+ char* to_next = 0;
+ F::result r = f.out(mbs, from.data(), from.data() + from.size(), from_next,
+ to.data(), to.data() + to.size()-1, to_next);
+ assert(r == F::partial);
+ assert(from_next - from.data() == to.size()-1);
+ assert(to_next - to.data() == to.size()-1);
+ assert(to.data() == std::string("some te"));
+ }
+}
diff --git a/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_unshift.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_unshift.pass.cpp
new file mode 100644
index 000000000000..4d8895cf1a7e
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_unshift.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<wchar_t, char, mbstate_t>
+
+// result unshift(stateT& state,
+// externT* to, externT* to_end, externT*& to_next) const;
+
+// This is pretty much just an "are you breathing" test
+
+#include <locale>
+#include <string>
+#include <vector>
+#include <cassert>
+
+typedef std::codecvt<wchar_t, char, std::mbstate_t> F;
+
+int main()
+{
+ std::locale l = std::locale::classic();
+ std::vector<F::extern_type> to(3);
+ const F& f = std::use_facet<F>(l);
+ std::mbstate_t mbs = {0};
+ F::extern_type* to_next = 0;
+ assert(f.unshift(mbs, to.data(), to.data() + to.size(), to_next) == F::ok);
+ assert(to_next == to.data());
+}
diff --git a/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.virtuals/tested_elsewhere.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.virtuals/tested_elsewhere.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.virtuals/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/localization/locale.categories/category.ctype/locale.codecvt/types_char.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.codecvt/types_char.pass.cpp
new file mode 100644
index 000000000000..5e2c44ff971c
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/locale.codecvt/types_char.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <>
+// class codecvt<char, char, mbstate_t>
+// : public locale::facet,
+// public codecvt_base
+// {
+// public:
+// typedef char intern_type;
+// typedef char extern_type;
+// typedef mbstate_t state_type;
+// ...
+// };
+
+#include <locale>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+ typedef std::codecvt<char, char, std::mbstate_t> F;
+ static_assert((std::is_base_of<std::locale::facet, F>::value), "");
+ static_assert((std::is_base_of<std::codecvt_base, F>::value), "");
+ static_assert((std::is_same<F::intern_type, char>::value), "");
+ static_assert((std::is_same<F::extern_type, char>::value), "");
+ static_assert((std::is_same<F::state_type, std::mbstate_t>::value), "");
+ std::locale l = std::locale::classic();
+ assert(std::has_facet<F>(l));
+ const F& f = std::use_facet<F>(l);
+ (void)F::id;
+}
diff --git a/test/std/localization/locale.categories/category.ctype/locale.codecvt/types_char16_t.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.codecvt/types_char16_t.pass.cpp
new file mode 100644
index 000000000000..9d512bd9d130
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/locale.codecvt/types_char16_t.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <>
+// class codecvt<char16_t, char, mbstate_t>
+// : public locale::facet,
+// public codecvt_base
+// {
+// public:
+// typedef char16_t intern_type;
+// typedef char extern_type;
+// typedef mbstate_t state_type;
+// ...
+// };
+
+#include <locale>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+//#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+ typedef std::codecvt<char16_t, char, std::mbstate_t> F;
+ static_assert((std::is_base_of<std::locale::facet, F>::value), "");
+ static_assert((std::is_base_of<std::codecvt_base, F>::value), "");
+ static_assert((std::is_same<F::intern_type, char16_t>::value), "");
+ static_assert((std::is_same<F::extern_type, char>::value), "");
+ static_assert((std::is_same<F::state_type, std::mbstate_t>::value), "");
+ std::locale l = std::locale::classic();
+ assert(std::has_facet<F>(l));
+ const F& f = std::use_facet<F>(l);
+ (void)F::id;
+//#endif
+}
diff --git a/test/std/localization/locale.categories/category.ctype/locale.codecvt/types_char32_t.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.codecvt/types_char32_t.pass.cpp
new file mode 100644
index 000000000000..25f2b3d8df58
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/locale.codecvt/types_char32_t.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <>
+// class codecvt<char32_t, char, mbstate_t>
+// : public locale::facet,
+// public codecvt_base
+// {
+// public:
+// typedef char32_t intern_type;
+// typedef char extern_type;
+// typedef mbstate_t state_type;
+// ...
+// };
+
+#include <locale>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+//#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+ typedef std::codecvt<char32_t, char, std::mbstate_t> F;
+ static_assert((std::is_base_of<std::locale::facet, F>::value), "");
+ static_assert((std::is_base_of<std::codecvt_base, F>::value), "");
+ static_assert((std::is_same<F::intern_type, char32_t>::value), "");
+ static_assert((std::is_same<F::extern_type, char>::value), "");
+ static_assert((std::is_same<F::state_type, std::mbstate_t>::value), "");
+ std::locale l = std::locale::classic();
+ assert(std::has_facet<F>(l));
+ const F& f = std::use_facet<F>(l);
+ (void)F::id;
+//#endif
+}
diff --git a/test/std/localization/locale.categories/category.ctype/locale.codecvt/types_wchar_t.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.codecvt/types_wchar_t.pass.cpp
new file mode 100644
index 000000000000..8b6868ec60d3
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/locale.codecvt/types_wchar_t.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <>
+// class codecvt<wchar_t, char, mbstate_t>
+// : public locale::facet,
+// public codecvt_base
+// {
+// public:
+// typedef wchar_t intern_type;
+// typedef char extern_type;
+// typedef mbstate_t state_type;
+// ...
+// };
+
+#include <locale>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+ typedef std::codecvt<wchar_t, char, std::mbstate_t> F;
+ static_assert((std::is_base_of<std::locale::facet, F>::value), "");
+ static_assert((std::is_base_of<std::codecvt_base, F>::value), "");
+ static_assert((std::is_same<F::intern_type, wchar_t>::value), "");
+ static_assert((std::is_same<F::extern_type, char>::value), "");
+ static_assert((std::is_same<F::state_type, std::mbstate_t>::value), "");
+ std::locale l = std::locale::classic();
+ assert(std::has_facet<F>(l));
+ const F& f = std::use_facet<F>(l);
+ (void)F::id;
+}
diff --git a/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/is_1.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/is_1.pass.cpp
new file mode 100644
index 000000000000..509e52ab0e55
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/is_1.pass.cpp
@@ -0,0 +1,112 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class ctype_byname;
+
+// bool is(mask m, charT c) const;
+
+// REQUIRES: locale.en_US.UTF-8
+
+#include <locale>
+#include <type_traits>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+int main()
+{
+ {
+ std::locale l(LOCALE_en_US_UTF_8);
+ {
+ typedef std::ctype<wchar_t> F;
+ const F& f = std::use_facet<F>(l);
+
+ assert(f.is(F::space, L' '));
+ assert(!f.is(F::space, L'A'));
+
+ assert(f.is(F::print, L' '));
+ assert(!f.is(F::print, L'\x07'));
+
+ assert(f.is(F::cntrl, L'\x07'));
+ assert(!f.is(F::cntrl, L' '));
+
+ assert(f.is(F::upper, L'A'));
+ assert(!f.is(F::upper, L'a'));
+
+ assert(f.is(F::lower, L'a'));
+ assert(!f.is(F::lower, L'A'));
+
+ assert(f.is(F::alpha, L'a'));
+ assert(!f.is(F::alpha, L'1'));
+
+ assert(f.is(F::digit, L'1'));
+ assert(!f.is(F::digit, L'a'));
+
+ assert(f.is(F::punct, L'.'));
+ assert(!f.is(F::punct, L'a'));
+
+ assert(f.is(F::xdigit, L'a'));
+ assert(!f.is(F::xdigit, L'g'));
+
+ assert(f.is(F::alnum, L'a'));
+ assert(!f.is(F::alnum, L'.'));
+
+ assert(f.is(F::graph, L'.'));
+ assert(!f.is(F::graph, L'\x07'));
+
+ assert(f.is(F::alpha, L'\x00DA'));
+ assert(f.is(F::upper, L'\x00DA'));
+ }
+ }
+ {
+ std::locale l("C");
+ {
+ typedef std::ctype<wchar_t> F;
+ const F& f = std::use_facet<F>(l);
+
+ assert(f.is(F::space, L' '));
+ assert(!f.is(F::space, L'A'));
+
+ assert(f.is(F::print, L' '));
+ assert(!f.is(F::print, L'\x07'));
+
+ assert(f.is(F::cntrl, L'\x07'));
+ assert(!f.is(F::cntrl, L' '));
+
+ assert(f.is(F::upper, L'A'));
+ assert(!f.is(F::upper, L'a'));
+
+ assert(f.is(F::lower, L'a'));
+ assert(!f.is(F::lower, L'A'));
+
+ assert(f.is(F::alpha, L'a'));
+ assert(!f.is(F::alpha, L'1'));
+
+ assert(f.is(F::digit, L'1'));
+ assert(!f.is(F::digit, L'a'));
+
+ assert(f.is(F::punct, L'.'));
+ assert(!f.is(F::punct, L'a'));
+
+ assert(f.is(F::xdigit, L'a'));
+ assert(!f.is(F::xdigit, L'g'));
+
+ assert(f.is(F::alnum, L'a'));
+ assert(!f.is(F::alnum, L'.'));
+
+ assert(f.is(F::graph, L'.'));
+ assert(!f.is(F::graph, L'\x07'));
+
+ assert(!f.is(F::alpha, L'\x00DA'));
+ assert(!f.is(F::upper, L'\x00DA'));
+ }
+ }
+}
diff --git a/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/is_many.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/is_many.pass.cpp
new file mode 100644
index 000000000000..a993466ab5e7
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/is_many.pass.cpp
@@ -0,0 +1,247 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class ctype_byname;
+
+// const charT* do_is(const charT* low, const charT* high, mask* vec) const;
+
+// REQUIRES: locale.en_US.UTF-8
+
+#include <locale>
+#include <string>
+#include <vector>
+#include <cassert>
+
+#include <stdio.h>
+
+#include "platform_support.h" // locale name macros
+
+int main()
+{
+ {
+ std::locale l(LOCALE_en_US_UTF_8);
+ {
+ typedef std::ctype<wchar_t> F;
+ const F& f = std::use_facet<F>(l);
+ const std::wstring in(L"\x00DA A\x07.a1");
+ std::vector<F::mask> m(in.size());
+ const wchar_t* h = f.is(in.data(), in.data() + in.size(), m.data());
+ assert(h == in.data() + in.size());
+
+ // L'\x00DA'
+ assert(!(m[0] & F::space));
+ assert( (m[0] & F::print));
+ assert(!(m[0] & F::cntrl));
+ assert( (m[0] & F::upper));
+ assert(!(m[0] & F::lower));
+ assert( (m[0] & F::alpha));
+ assert(!(m[0] & F::digit));
+ assert(!(m[0] & F::punct));
+ assert(!(m[0] & F::xdigit));
+ assert(!(m[0] & F::blank));
+ assert( (m[0] & F::alnum));
+ assert( (m[0] & F::graph));
+
+ // L' '
+ assert( (m[1] & F::space));
+ assert( (m[1] & F::print));
+ assert(!(m[1] & F::cntrl));
+ assert(!(m[1] & F::upper));
+ assert(!(m[1] & F::lower));
+ assert(!(m[1] & F::alpha));
+ assert(!(m[1] & F::digit));
+ assert(!(m[1] & F::punct));
+ assert(!(m[1] & F::xdigit));
+ assert( (m[1] & F::blank));
+ assert(!(m[1] & F::alnum));
+ assert(!(m[1] & F::graph));
+
+ // L'A'
+ assert(!(m[2] & F::space));
+ assert( (m[2] & F::print));
+ assert(!(m[2] & F::cntrl));
+ assert( (m[2] & F::upper));
+ assert(!(m[2] & F::lower));
+ assert( (m[2] & F::alpha));
+ assert(!(m[2] & F::digit));
+ assert(!(m[2] & F::punct));
+ assert( (m[2] & F::xdigit));
+ assert(!(m[2] & F::blank));
+ assert( (m[2] & F::alnum));
+ assert( (m[2] & F::graph));
+
+ // L'\x07'
+ assert(!(m[3] & F::space));
+ assert(!(m[3] & F::print));
+ assert( (m[3] & F::cntrl));
+ assert(!(m[3] & F::upper));
+ assert(!(m[3] & F::lower));
+ assert(!(m[3] & F::alpha));
+ assert(!(m[3] & F::digit));
+ assert(!(m[3] & F::punct));
+ assert(!(m[3] & F::xdigit));
+ assert(!(m[3] & F::blank));
+ assert(!(m[3] & F::alnum));
+ assert(!(m[3] & F::graph));
+
+ // L'.'
+ assert(!(m[4] & F::space));
+ assert( (m[4] & F::print));
+ assert(!(m[4] & F::cntrl));
+ assert(!(m[4] & F::upper));
+ assert(!(m[4] & F::lower));
+ assert(!(m[4] & F::alpha));
+ assert(!(m[4] & F::digit));
+ assert( (m[4] & F::punct));
+ assert(!(m[4] & F::xdigit));
+ assert(!(m[4] & F::blank));
+ assert(!(m[4] & F::alnum));
+ assert( (m[4] & F::graph));
+
+ // L'a'
+ assert(!(m[5] & F::space));
+ assert( (m[5] & F::print));
+ assert(!(m[5] & F::cntrl));
+ assert(!(m[5] & F::upper));
+ assert( (m[5] & F::lower));
+ assert( (m[5] & F::alpha));
+ assert(!(m[5] & F::digit));
+ assert(!(m[5] & F::punct));
+ assert( (m[5] & F::xdigit));
+ assert(!(m[5] & F::blank));
+ assert( (m[5] & F::alnum));
+ assert( (m[5] & F::graph));
+
+ // L'1'
+ assert(!(m[6] & F::space));
+ assert( (m[6] & F::print));
+ assert(!(m[6] & F::cntrl));
+ assert(!(m[6] & F::upper));
+ assert(!(m[6] & F::lower));
+ assert(!(m[6] & F::alpha));
+ assert( (m[6] & F::digit));
+ assert(!(m[6] & F::punct));
+ assert( (m[6] & F::xdigit));
+ assert(!(m[6] & F::blank));
+ assert( (m[6] & F::alnum));
+ assert( (m[6] & F::graph));
+ }
+ }
+ {
+ std::locale l("C");
+ {
+ typedef std::ctype<wchar_t> F;
+ const F& f = std::use_facet<F>(l);
+ const std::wstring in(L"\x00DA A\x07.a1");
+ std::vector<F::mask> m(in.size());
+ const wchar_t* h = f.is(in.data(), in.data() + in.size(), m.data());
+ assert(h == in.data() + in.size());
+
+ // L'\x00DA'
+ assert(!(m[0] & F::space));
+ assert(!(m[0] & F::print));
+ assert(!(m[0] & F::cntrl));
+ assert(!(m[0] & F::upper));
+ assert(!(m[0] & F::lower));
+ assert(!(m[0] & F::alpha));
+ assert(!(m[0] & F::digit));
+ assert(!(m[0] & F::punct));
+ assert(!(m[0] & F::xdigit));
+ assert(!(m[0] & F::blank));
+ assert(!(m[0] & F::alnum));
+ assert(!(m[0] & F::graph));
+
+ // L' '
+ assert( (m[1] & F::space));
+ assert( (m[1] & F::print));
+ assert(!(m[1] & F::cntrl));
+ assert(!(m[1] & F::upper));
+ assert(!(m[1] & F::lower));
+ assert(!(m[1] & F::alpha));
+ assert(!(m[1] & F::digit));
+ assert(!(m[1] & F::punct));
+ assert(!(m[1] & F::xdigit));
+ assert( (m[1] & F::blank));
+ assert(!(m[1] & F::alnum));
+ assert(!(m[1] & F::graph));
+
+ // L'A'
+ assert(!(m[2] & F::space));
+ assert( (m[2] & F::print));
+ assert(!(m[2] & F::cntrl));
+ assert( (m[2] & F::upper));
+ assert(!(m[2] & F::lower));
+ assert( (m[2] & F::alpha));
+ assert(!(m[2] & F::digit));
+ assert(!(m[2] & F::punct));
+ assert( (m[2] & F::xdigit));
+ assert(!(m[2] & F::blank));
+ assert( (m[2] & F::alnum));
+ assert( (m[2] & F::graph));
+
+ // L'\x07'
+ assert(!(m[3] & F::space));
+ assert(!(m[3] & F::print));
+ assert( (m[3] & F::cntrl));
+ assert(!(m[3] & F::upper));
+ assert(!(m[3] & F::lower));
+ assert(!(m[3] & F::alpha));
+ assert(!(m[3] & F::digit));
+ assert(!(m[3] & F::punct));
+ assert(!(m[3] & F::xdigit));
+ assert(!(m[3] & F::blank));
+ assert(!(m[3] & F::alnum));
+ assert(!(m[3] & F::graph));
+
+ // L'.'
+ assert(!(m[4] & F::space));
+ assert( (m[4] & F::print));
+ assert(!(m[4] & F::cntrl));
+ assert(!(m[4] & F::upper));
+ assert(!(m[4] & F::lower));
+ assert(!(m[4] & F::alpha));
+ assert(!(m[4] & F::digit));
+ assert( (m[4] & F::punct));
+ assert(!(m[4] & F::xdigit));
+ assert(!(m[4] & F::blank));
+ assert(!(m[4] & F::alnum));
+ assert( (m[4] & F::graph));
+
+ // L'a'
+ assert(!(m[5] & F::space));
+ assert( (m[5] & F::print));
+ assert(!(m[5] & F::cntrl));
+ assert(!(m[5] & F::upper));
+ assert( (m[5] & F::lower));
+ assert( (m[5] & F::alpha));
+ assert(!(m[5] & F::digit));
+ assert(!(m[5] & F::punct));
+ assert( (m[5] & F::xdigit));
+ assert(!(m[5] & F::blank));
+ assert( (m[5] & F::alnum));
+ assert( (m[5] & F::graph));
+
+ // L'1'
+ assert(!(m[6] & F::space));
+ assert( (m[6] & F::print));
+ assert(!(m[6] & F::cntrl));
+ assert(!(m[6] & F::upper));
+ assert(!(m[6] & F::lower));
+ assert(!(m[6] & F::alpha));
+ assert( (m[6] & F::digit));
+ assert(!(m[6] & F::punct));
+ assert( (m[6] & F::xdigit));
+ assert(!(m[6] & F::blank));
+ assert( (m[6] & F::alnum));
+ assert( (m[6] & F::graph));
+ }
+ }
+}
diff --git a/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/mask.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/mask.pass.cpp
new file mode 100644
index 000000000000..a09072a98788
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/mask.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class ctype_byname;
+
+// bool is(mask m, charT c) const;
+
+#include <locale>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+ {
+ std::locale l("C");
+ {
+ typedef std::ctype<wchar_t> WF;
+ const WF& wf = std::use_facet<WF>(l);
+ typedef std::ctype<char> CF;
+ const CF& cf = std::use_facet<CF>(l);
+
+ // The ctype masks in Newlib don't form a proper bitmask because
+ // the mask is only 8 bits wide, and there are more than 8 mask
+ // kinds. This means that the mask for alpha is (_U | _L), which
+ // is tricky to match in the do_is implementation because in
+ // [22.4.1.1.2 2] the standard specifies that the match code behaves
+ // like (m & M) != 0, but following this exactly would give false
+ // positives for characters that are both 'upper' and 'alpha', but
+ // not 'lower', for example.
+ assert( wf.is(WF::upper, L'A'));
+ assert( cf.is(CF::upper, 'A'));
+ assert(!wf.is(WF::lower, L'A'));
+ assert(!cf.is(CF::lower, 'A'));
+ assert( wf.is(WF::alpha, L'A'));
+ assert( cf.is(CF::alpha, 'A'));
+
+ assert(!wf.is(WF::upper, L'a'));
+ assert(!cf.is(CF::upper, 'a'));
+ assert( wf.is(WF::lower, L'a'));
+ assert( cf.is(CF::lower, 'a'));
+ assert( wf.is(WF::alpha, L'a'));
+ assert( cf.is(CF::alpha, 'a'));
+ }
+ }
+}
diff --git a/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/narrow_1.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/narrow_1.pass.cpp
new file mode 100644
index 000000000000..904ced32313c
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/narrow_1.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: locale.en_US.UTF-8
+// REQUIRES: locale.fr_CA.ISO8859-1
+
+// <locale>
+
+// template <class charT> class ctype_byname;
+
+// char narrow(charT c, char dfault) const;
+
+#include <locale>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+int main()
+{
+ {
+ std::locale l(std::string(LOCALE_fr_CA_ISO8859_1));
+ {
+ typedef std::ctype<wchar_t> F;
+ const F& f = std::use_facet<F>(l);
+
+ assert(f.narrow(L' ', '*') == ' ');
+ assert(f.narrow(L'A', '*') == 'A');
+ assert(f.narrow(L'\x07', '*') == '\x07');
+ assert(f.narrow(L'.', '*') == '.');
+ assert(f.narrow(L'a', '*') == 'a');
+ assert(f.narrow(L'1', '*') == '1');
+ assert(f.narrow(L'\xDA', '*') == '\xDA');
+ }
+ }
+ {
+ std::locale l(LOCALE_en_US_UTF_8);
+ {
+ typedef std::ctype<wchar_t> F;
+ const F& f = std::use_facet<F>(l);
+
+ assert(f.narrow(L' ', '*') == ' ');
+ assert(f.narrow(L'A', '*') == 'A');
+ assert(f.narrow(L'\x07', '*') == '\x07');
+ assert(f.narrow(L'.', '*') == '.');
+ assert(f.narrow(L'a', '*') == 'a');
+ assert(f.narrow(L'1', '*') == '1');
+ assert(f.narrow(L'\xDA', '*') == '*');
+ }
+ }
+}
diff --git a/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/narrow_many.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/narrow_many.pass.cpp
new file mode 100644
index 000000000000..6f25b9cad927
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/narrow_many.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: locale.en_US.UTF-8
+// REQUIRES: locale.fr_CA.ISO8859-1
+
+// <locale>
+
+// template <class charT> class ctype_byname;
+
+// const charT* narrow(const charT* low, const charT*, char dfault, char* to) const;
+
+#include <locale>
+#include <string>
+#include <vector>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+int main()
+{
+ {
+ std::locale l(LOCALE_fr_CA_ISO8859_1);
+ {
+ typedef std::ctype<wchar_t> F;
+ const F& f = std::use_facet<F>(l);
+ std::wstring in(L" A\x07.a1\xDA");
+ std::vector<char> v(in.size());
+
+ assert(f.narrow(&in[0], in.data() + in.size(), '*', v.data()) == in.data() + in.size());
+ assert(v[0] == ' ');
+ assert(v[1] == 'A');
+ assert(v[2] == '\x07');
+ assert(v[3] == '.');
+ assert(v[4] == 'a');
+ assert(v[5] == '1');
+ assert(v[6] == '\xDA');
+ }
+ }
+ {
+ std::locale l(LOCALE_en_US_UTF_8);
+ {
+ typedef std::ctype<wchar_t> F;
+ const F& f = std::use_facet<F>(l);
+ std::wstring in(L" A\x07.a1\xDA");
+ std::vector<char> v(in.size());
+
+ assert(f.narrow(&in[0], in.data() + in.size(), '*', v.data()) == in.data() + in.size());
+ assert(v[0] == ' ');
+ assert(v[1] == 'A');
+ assert(v[2] == '\x07');
+ assert(v[3] == '.');
+ assert(v[4] == 'a');
+ assert(v[5] == '1');
+ assert(v[6] == '*');
+ }
+ }
+}
diff --git a/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/scan_is.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/scan_is.pass.cpp
new file mode 100644
index 000000000000..25b2c3e4ebd4
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/scan_is.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class ctype_byname;
+
+// const charT* scan_is(mask m, const charT* low, const charT* high) const;
+
+// REQUIRES: locale.en_US.UTF-8
+
+#include <locale>
+#include <string>
+#include <vector>
+#include <cassert>
+
+#include <stdio.h>
+
+#include "platform_support.h" // locale name macros
+
+int main()
+{
+ {
+ std::locale l(LOCALE_en_US_UTF_8);
+ {
+ typedef std::ctype<wchar_t> F;
+ const F& f = std::use_facet<F>(l);
+ const std::wstring in(L"\x00DA A\x07.a1");
+ std::vector<F::mask> m(in.size());
+ assert(f.scan_is(F::space, in.data(), in.data() + in.size()) - in.data() == 1);
+ assert(f.scan_is(F::print, in.data(), in.data() + in.size()) - in.data() == 0);
+ assert(f.scan_is(F::cntrl, in.data(), in.data() + in.size()) - in.data() == 3);
+ assert(f.scan_is(F::upper, in.data(), in.data() + in.size()) - in.data() == 0);
+ assert(f.scan_is(F::lower, in.data(), in.data() + in.size()) - in.data() == 5);
+ assert(f.scan_is(F::alpha, in.data(), in.data() + in.size()) - in.data() == 0);
+ assert(f.scan_is(F::digit, in.data(), in.data() + in.size()) - in.data() == 6);
+ assert(f.scan_is(F::punct, in.data(), in.data() + in.size()) - in.data() == 4);
+ assert(f.scan_is(F::xdigit, in.data(), in.data() + in.size()) - in.data() == 2);
+ assert(f.scan_is(F::blank, in.data(), in.data() + in.size()) - in.data() == 1);
+ assert(f.scan_is(F::alnum, in.data(), in.data() + in.size()) - in.data() == 0);
+ assert(f.scan_is(F::graph, in.data(), in.data() + in.size()) - in.data() == 0);
+ }
+ }
+ {
+ std::locale l("C");
+ {
+ typedef std::ctype<wchar_t> F;
+ const F& f = std::use_facet<F>(l);
+ const std::wstring in(L"\x00DA A\x07.a1");
+ std::vector<F::mask> m(in.size());
+ assert(f.scan_is(F::space, in.data(), in.data() + in.size()) - in.data() == 1);
+ assert(f.scan_is(F::print, in.data(), in.data() + in.size()) - in.data() == 1);
+ assert(f.scan_is(F::cntrl, in.data(), in.data() + in.size()) - in.data() == 3);
+ assert(f.scan_is(F::upper, in.data(), in.data() + in.size()) - in.data() == 2);
+ assert(f.scan_is(F::lower, in.data(), in.data() + in.size()) - in.data() == 5);
+ assert(f.scan_is(F::alpha, in.data(), in.data() + in.size()) - in.data() == 2);
+ assert(f.scan_is(F::digit, in.data(), in.data() + in.size()) - in.data() == 6);
+ assert(f.scan_is(F::punct, in.data(), in.data() + in.size()) - in.data() == 4);
+ assert(f.scan_is(F::xdigit, in.data(), in.data() + in.size()) - in.data() == 2);
+ assert(f.scan_is(F::blank, in.data(), in.data() + in.size()) - in.data() == 1);
+ assert(f.scan_is(F::alnum, in.data(), in.data() + in.size()) - in.data() == 2);
+ assert(f.scan_is(F::graph, in.data(), in.data() + in.size()) - in.data() == 2);
+ }
+ }
+}
diff --git a/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/scan_not.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/scan_not.pass.cpp
new file mode 100644
index 000000000000..270ae1f1595c
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/scan_not.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class ctype_byname;
+
+// const charT* scan_not(mask m, const charT* low, const charT* high) const;
+
+// REQUIRES: locale.en_US.UTF-8
+
+#include <locale>
+#include <string>
+#include <vector>
+#include <cassert>
+
+#include <stdio.h>
+
+#include "platform_support.h" // locale name macros
+
+int main()
+{
+ {
+ std::locale l(LOCALE_en_US_UTF_8);
+ {
+ typedef std::ctype<wchar_t> F;
+ const F& f = std::use_facet<F>(l);
+ const std::wstring in(L"\x00DA A\x07.a1");
+ std::vector<F::mask> m(in.size());
+ assert(f.scan_not(F::space, in.data(), in.data() + in.size()) - in.data() == 0);
+ assert(f.scan_not(F::print, in.data(), in.data() + in.size()) - in.data() == 3);
+ assert(f.scan_not(F::cntrl, in.data(), in.data() + in.size()) - in.data() == 0);
+ assert(f.scan_not(F::upper, in.data(), in.data() + in.size()) - in.data() == 1);
+ assert(f.scan_not(F::lower, in.data(), in.data() + in.size()) - in.data() == 0);
+ assert(f.scan_not(F::alpha, in.data(), in.data() + in.size()) - in.data() == 1);
+ assert(f.scan_not(F::digit, in.data(), in.data() + in.size()) - in.data() == 0);
+ assert(f.scan_not(F::punct, in.data(), in.data() + in.size()) - in.data() == 0);
+ assert(f.scan_not(F::xdigit, in.data(), in.data() + in.size()) - in.data() == 0);
+ assert(f.scan_not(F::blank, in.data(), in.data() + in.size()) - in.data() == 0);
+ assert(f.scan_not(F::alnum, in.data(), in.data() + in.size()) - in.data() == 1);
+ assert(f.scan_not(F::graph, in.data(), in.data() + in.size()) - in.data() == 1);
+ }
+ }
+ {
+ std::locale l("C");
+ {
+ typedef std::ctype<wchar_t> F;
+ const F& f = std::use_facet<F>(l);
+ const std::wstring in(L"\x00DA A\x07.a1");
+ std::vector<F::mask> m(in.size());
+ assert(f.scan_not(F::space, in.data(), in.data() + in.size()) - in.data() == 0);
+ assert(f.scan_not(F::print, in.data(), in.data() + in.size()) - in.data() == 0);
+ assert(f.scan_not(F::cntrl, in.data(), in.data() + in.size()) - in.data() == 0);
+ assert(f.scan_not(F::upper, in.data(), in.data() + in.size()) - in.data() == 0);
+ assert(f.scan_not(F::lower, in.data(), in.data() + in.size()) - in.data() == 0);
+ assert(f.scan_not(F::alpha, in.data(), in.data() + in.size()) - in.data() == 0);
+ assert(f.scan_not(F::digit, in.data(), in.data() + in.size()) - in.data() == 0);
+ assert(f.scan_not(F::punct, in.data(), in.data() + in.size()) - in.data() == 0);
+ assert(f.scan_not(F::xdigit, in.data(), in.data() + in.size()) - in.data() == 0);
+ assert(f.scan_not(F::blank, in.data(), in.data() + in.size()) - in.data() == 0);
+ assert(f.scan_not(F::alnum, in.data(), in.data() + in.size()) - in.data() == 0);
+ assert(f.scan_not(F::graph, in.data(), in.data() + in.size()) - in.data() == 0);
+ }
+ }
+}
diff --git a/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_1.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_1.pass.cpp
new file mode 100644
index 000000000000..c2eeea820ba0
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_1.pass.cpp
@@ -0,0 +1,91 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class ctype_byname;
+
+// charT tolower(charT) const;
+
+// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11
+// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12
+// XFAIL: linux
+
+#include <locale>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+int main()
+{
+ {
+ std::locale l(LOCALE_en_US_UTF_8);
+ {
+ typedef std::ctype<char> F;
+ const F& f = std::use_facet<F>(l);
+
+ assert(f.tolower(' ') == ' ');
+ assert(f.tolower('A') == 'a');
+ assert(f.tolower('\x07') == '\x07');
+ assert(f.tolower('.') == '.');
+ assert(f.tolower('a') == 'a');
+ assert(f.tolower('1') == '1');
+ assert(f.tolower('\xDA') == '\xFA');
+ assert(f.tolower('\xFA') == '\xFA');
+ }
+ }
+ {
+ std::locale l("C");
+ {
+ typedef std::ctype<char> F;
+ const F& f = std::use_facet<F>(l);
+
+ assert(f.tolower(' ') == ' ');
+ assert(f.tolower('A') == 'a');
+ assert(f.tolower('\x07') == '\x07');
+ assert(f.tolower('.') == '.');
+ assert(f.tolower('a') == 'a');
+ assert(f.tolower('1') == '1');
+ assert(f.tolower('\xDA') == '\xDA');
+ assert(f.tolower('\xFA') == '\xFA');
+ }
+ }
+ {
+ std::locale l(LOCALE_en_US_UTF_8);
+ {
+ typedef std::ctype<wchar_t> F;
+ const F& f = std::use_facet<F>(l);
+
+ assert(f.tolower(L' ') == L' ');
+ assert(f.tolower(L'A') == L'a');
+ assert(f.tolower(L'\x07') == L'\x07');
+ assert(f.tolower(L'.') == L'.');
+ assert(f.tolower(L'a') == L'a');
+ assert(f.tolower(L'1') == L'1');
+ assert(f.tolower(L'\xDA') == L'\xFA');
+ assert(f.tolower(L'\xFA') == L'\xFA');
+ }
+ }
+ {
+ std::locale l("C");
+ {
+ typedef std::ctype<wchar_t> F;
+ const F& f = std::use_facet<F>(l);
+
+ assert(f.tolower(L' ') == L' ');
+ assert(f.tolower(L'A') == L'a');
+ assert(f.tolower(L'\x07') == L'\x07');
+ assert(f.tolower(L'.') == L'.');
+ assert(f.tolower(L'a') == L'a');
+ assert(f.tolower(L'1') == L'1');
+ assert(f.tolower(L'\xDA') == L'\xDA');
+ assert(f.tolower(L'\xFA') == L'\xFA');
+ }
+ }
+}
diff --git a/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_many.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_many.pass.cpp
new file mode 100644
index 000000000000..b2577e323a2d
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_many.pass.cpp
@@ -0,0 +1,96 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class ctype_byname;
+
+// const charT* tolower(charT* low, const charT* high) const;
+
+// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11
+// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12
+// XFAIL: linux
+
+#include <locale>
+#include <string>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+int main()
+{
+ {
+ std::locale l(LOCALE_en_US_UTF_8);
+ {
+ typedef std::ctype<char> F;
+ const F& f = std::use_facet<F>(l);
+ std::string in("\xDA A\x07.a1");
+
+ assert(f.tolower(&in[0], in.data() + in.size()) == in.data() + in.size());
+ assert(in[0] == '\xFA');
+ assert(in[1] == ' ');
+ assert(in[2] == 'a');
+ assert(in[3] == '\x07');
+ assert(in[4] == '.');
+ assert(in[5] == 'a');
+ assert(in[6] == '1');
+ }
+ }
+ {
+ std::locale l("C");
+ {
+ typedef std::ctype<char> F;
+ const F& f = std::use_facet<F>(l);
+ std::string in("\xDA A\x07.a1");
+
+ assert(f.tolower(&in[0], in.data() + in.size()) == in.data() + in.size());
+ assert(in[0] == '\xDA');
+ assert(in[1] == ' ');
+ assert(in[2] == 'a');
+ assert(in[3] == '\x07');
+ assert(in[4] == '.');
+ assert(in[5] == 'a');
+ assert(in[6] == '1');
+ }
+ }
+ {
+ std::locale l(LOCALE_en_US_UTF_8);
+ {
+ typedef std::ctype<wchar_t> F;
+ const F& f = std::use_facet<F>(l);
+ std::wstring in(L"\xDA A\x07.a1");
+
+ assert(f.tolower(&in[0], in.data() + in.size()) == in.data() + in.size());
+ assert(in[0] == L'\xFA');
+ assert(in[1] == L' ');
+ assert(in[2] == L'a');
+ assert(in[3] == L'\x07');
+ assert(in[4] == L'.');
+ assert(in[5] == L'a');
+ assert(in[6] == L'1');
+ }
+ }
+ {
+ std::locale l("C");
+ {
+ typedef std::ctype<wchar_t> F;
+ const F& f = std::use_facet<F>(l);
+ std::wstring in(L"\xDA A\x07.a1");
+
+ assert(f.tolower(&in[0], in.data() + in.size()) == in.data() + in.size());
+ assert(in[0] == L'\xDA');
+ assert(in[1] == L' ');
+ assert(in[2] == L'a');
+ assert(in[3] == L'\x07');
+ assert(in[4] == L'.');
+ assert(in[5] == L'a');
+ assert(in[6] == L'1');
+ }
+ }
+}
diff --git a/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_1.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_1.pass.cpp
new file mode 100644
index 000000000000..8611293b84aa
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_1.pass.cpp
@@ -0,0 +1,91 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class ctype_byname;
+
+// charT toupper(charT) const;
+
+// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11
+// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12
+// XFAIL: linux
+
+#include <locale>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+int main()
+{
+ {
+ std::locale l(LOCALE_en_US_UTF_8);
+ {
+ typedef std::ctype<char> F;
+ const F& f = std::use_facet<F>(l);
+
+ assert(f.toupper(' ') == ' ');
+ assert(f.toupper('A') == 'A');
+ assert(f.toupper('\x07') == '\x07');
+ assert(f.toupper('.') == '.');
+ assert(f.toupper('a') == 'A');
+ assert(f.toupper('1') == '1');
+ assert(f.toupper('\xDA') == '\xDA');
+ assert(f.toupper('\xFA') == '\xDA');
+ }
+ }
+ {
+ std::locale l("C");
+ {
+ typedef std::ctype<char> F;
+ const F& f = std::use_facet<F>(l);
+
+ assert(f.toupper(' ') == ' ');
+ assert(f.toupper('A') == 'A');
+ assert(f.toupper('\x07') == '\x07');
+ assert(f.toupper('.') == '.');
+ assert(f.toupper('a') == 'A');
+ assert(f.toupper('1') == '1');
+ assert(f.toupper('\xDA') == '\xDA');
+ assert(f.toupper('\xFA') == '\xFA');
+ }
+ }
+ {
+ std::locale l(LOCALE_en_US_UTF_8);
+ {
+ typedef std::ctype<wchar_t> F;
+ const F& f = std::use_facet<F>(l);
+
+ assert(f.toupper(L' ') == L' ');
+ assert(f.toupper(L'A') == L'A');
+ assert(f.toupper(L'\x07') == L'\x07');
+ assert(f.toupper(L'.') == L'.');
+ assert(f.toupper(L'a') == L'A');
+ assert(f.toupper(L'1') == L'1');
+ assert(f.toupper(L'\xDA') == L'\xDA');
+ assert(f.toupper(L'\xFA') == L'\xDA');
+ }
+ }
+ {
+ std::locale l("C");
+ {
+ typedef std::ctype<wchar_t> F;
+ const F& f = std::use_facet<F>(l);
+
+ assert(f.toupper(L' ') == L' ');
+ assert(f.toupper(L'A') == L'A');
+ assert(f.toupper(L'\x07') == L'\x07');
+ assert(f.toupper(L'.') == L'.');
+ assert(f.toupper(L'a') == L'A');
+ assert(f.toupper(L'1') == L'1');
+ assert(f.toupper(L'\xDA') == L'\xDA');
+ assert(f.toupper(L'\xFA') == L'\xFA');
+ }
+ }
+}
diff --git a/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_many.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_many.pass.cpp
new file mode 100644
index 000000000000..d23a29273e2b
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_many.pass.cpp
@@ -0,0 +1,96 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class ctype_byname;
+
+// const charT* toupper(charT* low, const charT* high) const;
+
+// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11
+// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12
+// XFAIL: linux
+
+#include <locale>
+#include <string>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+int main()
+{
+ {
+ std::locale l(LOCALE_en_US_UTF_8);
+ {
+ typedef std::ctype<char> F;
+ const F& f = std::use_facet<F>(l);
+ std::string in("\xFA A\x07.a1");
+
+ assert(f.toupper(&in[0], in.data() + in.size()) == in.data() + in.size());
+ assert(in[0] == '\xDA');
+ assert(in[1] == ' ');
+ assert(in[2] == 'A');
+ assert(in[3] == '\x07');
+ assert(in[4] == '.');
+ assert(in[5] == 'A');
+ assert(in[6] == '1');
+ }
+ }
+ {
+ std::locale l("C");
+ {
+ typedef std::ctype<char> F;
+ const F& f = std::use_facet<F>(l);
+ std::string in("\xFA A\x07.a1");
+
+ assert(f.toupper(&in[0], in.data() + in.size()) == in.data() + in.size());
+ assert(in[0] == '\xFA');
+ assert(in[1] == ' ');
+ assert(in[2] == 'A');
+ assert(in[3] == '\x07');
+ assert(in[4] == '.');
+ assert(in[5] == 'A');
+ assert(in[6] == '1');
+ }
+ }
+ {
+ std::locale l(LOCALE_en_US_UTF_8);
+ {
+ typedef std::ctype<wchar_t> F;
+ const F& f = std::use_facet<F>(l);
+ std::wstring in(L"\xFA A\x07.a1");
+
+ assert(f.toupper(&in[0], in.data() + in.size()) == in.data() + in.size());
+ assert(in[0] == L'\xDA');
+ assert(in[1] == L' ');
+ assert(in[2] == L'A');
+ assert(in[3] == L'\x07');
+ assert(in[4] == L'.');
+ assert(in[5] == L'A');
+ assert(in[6] == L'1');
+ }
+ }
+ {
+ std::locale l("C");
+ {
+ typedef std::ctype<wchar_t> F;
+ const F& f = std::use_facet<F>(l);
+ std::wstring in(L"\xFA A\x07.a1");
+
+ assert(f.toupper(&in[0], in.data() + in.size()) == in.data() + in.size());
+ assert(in[0] == L'\xFA');
+ assert(in[1] == L' ');
+ assert(in[2] == L'A');
+ assert(in[3] == L'\x07');
+ assert(in[4] == L'.');
+ assert(in[5] == L'A');
+ assert(in[6] == L'1');
+ }
+ }
+}
diff --git a/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/types.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/types.pass.cpp
new file mode 100644
index 000000000000..03e8dfcef97f
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/types.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class CharT>
+// class ctype_byname
+// : public ctype<CharT>
+// {
+// public:
+// explicit ctype_byname(const char*, size_t = 0);
+// explicit ctype_byname(const string&, size_t = 0);
+//
+// protected:
+// ~ctype_byname();
+// };
+
+#include <locale>
+#include <type_traits>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+int main()
+{
+ {
+ std::locale l(LOCALE_en_US_UTF_8);
+ {
+ assert(std::has_facet<std::ctype_byname<char> >(l));
+ assert(&std::use_facet<std::ctype<char> >(l)
+ == &std::use_facet<std::ctype_byname<char> >(l));
+ }
+ {
+ assert(std::has_facet<std::ctype_byname<wchar_t> >(l));
+ assert(&std::use_facet<std::ctype<wchar_t> >(l)
+ == &std::use_facet<std::ctype_byname<wchar_t> >(l));
+ }
+ }
+ {
+ std::locale l("");
+ {
+ assert(std::has_facet<std::ctype_byname<char> >(l));
+ assert(&std::use_facet<std::ctype<char> >(l)
+ == &std::use_facet<std::ctype_byname<char> >(l));
+ }
+ {
+ assert(std::has_facet<std::ctype_byname<wchar_t> >(l));
+ assert(&std::use_facet<std::ctype<wchar_t> >(l)
+ == &std::use_facet<std::ctype_byname<wchar_t> >(l));
+ }
+ }
+ {
+ std::locale l("C");
+ {
+ assert(std::has_facet<std::ctype_byname<char> >(l));
+ assert(&std::use_facet<std::ctype<char> >(l)
+ == &std::use_facet<std::ctype_byname<char> >(l));
+ }
+ {
+ assert(std::has_facet<std::ctype_byname<wchar_t> >(l));
+ assert(&std::use_facet<std::ctype<wchar_t> >(l)
+ == &std::use_facet<std::ctype_byname<wchar_t> >(l));
+ }
+ }
+}
diff --git a/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/widen_1.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/widen_1.pass.cpp
new file mode 100644
index 000000000000..320e08db26e0
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/widen_1.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class ctype_byname;
+
+// charT widen(char c) const;
+
+// I doubt this test is portable
+
+// XFAIL: linux
+
+#include <locale>
+#include <cassert>
+#include <limits.h>
+
+#include "platform_support.h" // locale name macros
+
+int main()
+{
+ {
+ std::locale l(LOCALE_en_US_UTF_8);
+ {
+ typedef std::ctype<wchar_t> F;
+ const F& f = std::use_facet<F>(l);
+
+ assert(f.widen(' ') == L' ');
+ assert(f.widen('A') == L'A');
+ assert(f.widen('\x07') == L'\x07');
+ assert(f.widen('.') == L'.');
+ assert(f.widen('a') == L'a');
+ assert(f.widen('1') == L'1');
+ assert(f.widen(char(-5)) == wchar_t(-1));
+ }
+ }
+ {
+ std::locale l("C");
+ {
+ typedef std::ctype<wchar_t> F;
+ const F& f = std::use_facet<F>(l);
+
+ assert(f.widen(' ') == L' ');
+ assert(f.widen('A') == L'A');
+ assert(f.widen('\x07') == L'\x07');
+ assert(f.widen('.') == L'.');
+ assert(f.widen('a') == L'a');
+ assert(f.widen('1') == L'1');
+ assert(f.widen(char(-5)) == wchar_t(251));
+ }
+ }
+}
diff --git a/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/widen_many.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/widen_many.pass.cpp
new file mode 100644
index 000000000000..b46ae32237b7
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/widen_many.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class ctype_byname;
+
+// const char* widen(const char* low, const char* high, charT* to) const;
+
+// I doubt this test is portable
+
+// XFAIL: linux
+
+#include <locale>
+#include <string>
+#include <vector>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+int main()
+{
+ {
+ std::locale l(LOCALE_en_US_UTF_8);
+ {
+ typedef std::ctype<wchar_t> F;
+ const F& f = std::use_facet<F>(l);
+ std::string in(" A\x07.a1\x85");
+ std::vector<wchar_t> v(in.size());
+
+ assert(f.widen(&in[0], in.data() + in.size(), v.data()) == in.data() + in.size());
+ assert(v[0] == L' ');
+ assert(v[1] == L'A');
+ assert(v[2] == L'\x07');
+ assert(v[3] == L'.');
+ assert(v[4] == L'a');
+ assert(v[5] == L'1');
+ assert(v[6] == wchar_t(-1));
+ }
+ }
+ {
+ std::locale l("C");
+ {
+ typedef std::ctype<wchar_t> F;
+ const F& f = std::use_facet<F>(l);
+ std::string in(" A\x07.a1\x85");
+ std::vector<wchar_t> v(in.size());
+
+ assert(f.widen(&in[0], in.data() + in.size(), v.data()) == in.data() + in.size());
+ assert(v[0] == L' ');
+ assert(v[1] == L'A');
+ assert(v[2] == L'\x07');
+ assert(v[3] == L'.');
+ assert(v[4] == L'a');
+ assert(v[5] == L'1');
+ assert(v[6] == wchar_t(133));
+ }
+ }
+}
diff --git a/test/std/localization/locale.categories/category.ctype/locale.ctype/ctor.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.ctype/ctor.pass.cpp
new file mode 100644
index 000000000000..7eb3cc895b3f
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/locale.ctype/ctor.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class ctype;
+
+// explicit ctype(size_t refs = 0);
+
+#include <locale>
+#include <cassert>
+
+template <class C>
+class my_facet
+ : public std::ctype<C>
+{
+public:
+ static int count;
+
+ explicit my_facet(std::size_t refs = 0)
+ : std::ctype<C>(refs) {++count;}
+
+ ~my_facet() {--count;}
+};
+
+template <class C> int my_facet<C>::count = 0;
+
+int main()
+{
+ {
+ std::locale l(std::locale::classic(), new my_facet<wchar_t>);
+ assert(my_facet<wchar_t>::count == 1);
+ }
+ assert(my_facet<wchar_t>::count == 0);
+ {
+ my_facet<wchar_t> f(1);
+ assert(my_facet<wchar_t>::count == 1);
+ {
+ std::locale l(std::locale::classic(), &f);
+ assert(my_facet<wchar_t>::count == 1);
+ }
+ assert(my_facet<wchar_t>::count == 1);
+ }
+ assert(my_facet<wchar_t>::count == 0);
+}
diff --git a/test/std/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/is_1.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/is_1.pass.cpp
new file mode 100644
index 000000000000..fa82da96b5a9
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/is_1.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class ctype;
+
+// bool is(mask m, charT c) const;
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+ std::locale l = std::locale::classic();
+ {
+ typedef std::ctype<wchar_t> F;
+ const F& f = std::use_facet<F>(l);
+
+ assert(f.is(F::space, L' '));
+ assert(!f.is(F::space, L'A'));
+
+ assert(f.is(F::print, L' '));
+ assert(!f.is(F::print, L'\x07'));
+
+ assert(f.is(F::cntrl, L'\x07'));
+ assert(!f.is(F::cntrl, L' '));
+
+ assert(f.is(F::upper, L'A'));
+ assert(!f.is(F::upper, L'a'));
+
+ assert(f.is(F::lower, L'a'));
+ assert(!f.is(F::lower, L'A'));
+
+ assert(f.is(F::alpha, L'a'));
+ assert(!f.is(F::alpha, L'1'));
+
+ assert(f.is(F::digit, L'1'));
+ assert(!f.is(F::digit, L'a'));
+
+ assert(f.is(F::punct, L'.'));
+ assert(!f.is(F::punct, L'a'));
+
+ assert(f.is(F::xdigit, L'a'));
+ assert(!f.is(F::xdigit, L'g'));
+
+ assert(f.is(F::alnum, L'a'));
+ assert(!f.is(F::alnum, L'.'));
+
+ assert(f.is(F::graph, L'.'));
+ assert(!f.is(F::graph, L'\x07'));
+ }
+}
diff --git a/test/std/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/is_many.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/is_many.pass.cpp
new file mode 100644
index 000000000000..7084245d969a
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/is_many.pass.cpp
@@ -0,0 +1,118 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class ctype;
+
+// const charT* do_is(const charT* low, const charT* high, mask* vec) const;
+
+#include <locale>
+#include <string>
+#include <vector>
+#include <cassert>
+
+#include <stdio.h>
+
+int main()
+{
+ std::locale l = std::locale::classic();
+ {
+ typedef std::ctype<wchar_t> F;
+ const F& f = std::use_facet<F>(l);
+ const std::wstring in(L" A\x07.a1");
+ std::vector<F::mask> m(in.size());
+ const wchar_t* h = f.is(in.data(), in.data() + in.size(), m.data());
+ assert(h == in.data() + in.size());
+
+ // L' '
+ assert( (m[0] & F::space));
+ assert( (m[0] & F::print));
+ assert(!(m[0] & F::cntrl));
+ assert(!(m[0] & F::upper));
+ assert(!(m[0] & F::lower));
+ assert(!(m[0] & F::alpha));
+ assert(!(m[0] & F::digit));
+ assert(!(m[0] & F::punct));
+ assert(!(m[0] & F::xdigit));
+ assert( (m[0] & F::blank));
+ assert(!(m[0] & F::alnum));
+ assert(!(m[0] & F::graph));
+
+ // L'A'
+ assert(!(m[1] & F::space));
+ assert( (m[1] & F::print));
+ assert(!(m[1] & F::cntrl));
+ assert( (m[1] & F::upper));
+ assert(!(m[1] & F::lower));
+ assert( (m[1] & F::alpha));
+ assert(!(m[1] & F::digit));
+ assert(!(m[1] & F::punct));
+ assert( (m[1] & F::xdigit));
+ assert(!(m[1] & F::blank));
+ assert( (m[1] & F::alnum));
+ assert( (m[1] & F::graph));
+
+ // L'\x07'
+ assert(!(m[2] & F::space));
+ assert(!(m[2] & F::print));
+ assert( (m[2] & F::cntrl));
+ assert(!(m[2] & F::upper));
+ assert(!(m[2] & F::lower));
+ assert(!(m[2] & F::alpha));
+ assert(!(m[2] & F::digit));
+ assert(!(m[2] & F::punct));
+ assert(!(m[2] & F::xdigit));
+ assert(!(m[2] & F::blank));
+ assert(!(m[2] & F::alnum));
+ assert(!(m[2] & F::graph));
+
+ // L'.'
+ assert(!(m[3] & F::space));
+ assert( (m[3] & F::print));
+ assert(!(m[3] & F::cntrl));
+ assert(!(m[3] & F::upper));
+ assert(!(m[3] & F::lower));
+ assert(!(m[3] & F::alpha));
+ assert(!(m[3] & F::digit));
+ assert( (m[3] & F::punct));
+ assert(!(m[3] & F::xdigit));
+ assert(!(m[3] & F::blank));
+ assert(!(m[3] & F::alnum));
+ assert( (m[3] & F::graph));
+
+ // L'a'
+ assert(!(m[4] & F::space));
+ assert( (m[4] & F::print));
+ assert(!(m[4] & F::cntrl));
+ assert(!(m[4] & F::upper));
+ assert( (m[4] & F::lower));
+ assert( (m[4] & F::alpha));
+ assert(!(m[4] & F::digit));
+ assert(!(m[4] & F::punct));
+ assert( (m[4] & F::xdigit));
+ assert(!(m[4] & F::blank));
+ assert( (m[4] & F::alnum));
+ assert( (m[4] & F::graph));
+
+ // L'1'
+ assert(!(m[5] & F::space));
+ assert( (m[5] & F::print));
+ assert(!(m[5] & F::cntrl));
+ assert(!(m[5] & F::upper));
+ assert(!(m[5] & F::lower));
+ assert(!(m[5] & F::alpha));
+ assert( (m[5] & F::digit));
+ assert(!(m[5] & F::punct));
+ assert( (m[5] & F::xdigit));
+ assert(!(m[5] & F::blank));
+ assert( (m[5] & F::alnum));
+ assert( (m[5] & F::graph));
+ }
+}
diff --git a/test/std/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/narrow_1.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/narrow_1.pass.cpp
new file mode 100644
index 000000000000..ad8fb211705f
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/narrow_1.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class ctype;
+
+// char narrow(charT c, char dfault) const;
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+ std::locale l = std::locale::classic();
+ {
+ typedef std::ctype<wchar_t> F;
+ const F& f = std::use_facet<F>(l);
+
+ assert(f.narrow(L' ', '*') == ' ');
+ assert(f.narrow(L'A', '*') == 'A');
+ assert(f.narrow(L'\x07', '*') == '\x07');
+ assert(f.narrow(L'.', '*') == '.');
+ assert(f.narrow(L'a', '*') == 'a');
+ assert(f.narrow(L'1', '*') == '1');
+ }
+}
diff --git a/test/std/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/narrow_many.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/narrow_many.pass.cpp
new file mode 100644
index 000000000000..fcc6cfccd2ec
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/narrow_many.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class ctype;
+
+// const charT* narrow(const charT* low, const charT*, char dfault, char* to) const;
+
+#include <locale>
+#include <string>
+#include <vector>
+#include <cassert>
+
+int main()
+{
+ std::locale l = std::locale::classic();
+ {
+ typedef std::ctype<wchar_t> F;
+ const F& f = std::use_facet<F>(l);
+ std::wstring in(L" A\x07.a1");
+ std::vector<char> v(in.size());
+
+ assert(f.narrow(&in[0], in.data() + in.size(), '*', v.data()) == in.data() + in.size());
+ assert(v[0] == ' ');
+ assert(v[1] == 'A');
+ assert(v[2] == '\x07');
+ assert(v[3] == '.');
+ assert(v[4] == 'a');
+ assert(v[5] == '1');
+ }
+}
diff --git a/test/std/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/scan_is.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/scan_is.pass.cpp
new file mode 100644
index 000000000000..535c830789c6
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/scan_is.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class ctype;
+
+// const charT* scan_is(mask m, const charT* low, const charT* high) const;
+
+#include <locale>
+#include <string>
+#include <vector>
+#include <cassert>
+
+#include <stdio.h>
+
+int main()
+{
+ std::locale l = std::locale::classic();
+ {
+ typedef std::ctype<wchar_t> F;
+ const F& f = std::use_facet<F>(l);
+ const std::wstring in(L" A\x07.a1");
+ std::vector<F::mask> m(in.size());
+ assert(f.scan_is(F::space, in.data(), in.data() + in.size()) - in.data() == 0);
+ assert(f.scan_is(F::print, in.data(), in.data() + in.size()) - in.data() == 0);
+ assert(f.scan_is(F::cntrl, in.data(), in.data() + in.size()) - in.data() == 2);
+ assert(f.scan_is(F::upper, in.data(), in.data() + in.size()) - in.data() == 1);
+ assert(f.scan_is(F::lower, in.data(), in.data() + in.size()) - in.data() == 4);
+ assert(f.scan_is(F::alpha, in.data(), in.data() + in.size()) - in.data() == 1);
+ assert(f.scan_is(F::digit, in.data(), in.data() + in.size()) - in.data() == 5);
+ assert(f.scan_is(F::punct, in.data(), in.data() + in.size()) - in.data() == 3);
+ assert(f.scan_is(F::xdigit, in.data(), in.data() + in.size()) - in.data() == 1);
+ assert(f.scan_is(F::blank, in.data(), in.data() + in.size()) - in.data() == 0);
+ assert(f.scan_is(F::alnum, in.data(), in.data() + in.size()) - in.data() == 1);
+ assert(f.scan_is(F::graph, in.data(), in.data() + in.size()) - in.data() == 1);
+ }
+}
diff --git a/test/std/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/scan_not.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/scan_not.pass.cpp
new file mode 100644
index 000000000000..da21642b98ca
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/scan_not.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class ctype;
+
+// const charT* scan_not(mask m, const charT* low, const charT* high) const;
+
+#include <locale>
+#include <string>
+#include <vector>
+#include <cassert>
+
+#include <stdio.h>
+
+int main()
+{
+ std::locale l = std::locale::classic();
+ {
+ typedef std::ctype<wchar_t> F;
+ const F& f = std::use_facet<F>(l);
+ const std::wstring in(L" A\x07.a1");
+ std::vector<F::mask> m(in.size());
+ assert(f.scan_not(F::space, in.data(), in.data() + in.size()) - in.data() == 1);
+ assert(f.scan_not(F::print, in.data(), in.data() + in.size()) - in.data() == 2);
+ assert(f.scan_not(F::cntrl, in.data(), in.data() + in.size()) - in.data() == 0);
+ assert(f.scan_not(F::upper, in.data(), in.data() + in.size()) - in.data() == 0);
+ assert(f.scan_not(F::lower, in.data(), in.data() + in.size()) - in.data() == 0);
+ assert(f.scan_not(F::alpha, in.data(), in.data() + in.size()) - in.data() == 0);
+ assert(f.scan_not(F::digit, in.data(), in.data() + in.size()) - in.data() == 0);
+ assert(f.scan_not(F::punct, in.data(), in.data() + in.size()) - in.data() == 0);
+ assert(f.scan_not(F::xdigit, in.data(), in.data() + in.size()) - in.data() == 0);
+ assert(f.scan_not(F::blank, in.data(), in.data() + in.size()) - in.data() == 1);
+ assert(f.scan_not(F::alnum, in.data(), in.data() + in.size()) - in.data() == 0);
+ assert(f.scan_not(F::graph, in.data(), in.data() + in.size()) - in.data() == 0);
+ }
+}
diff --git a/test/std/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/tolower_1.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/tolower_1.pass.cpp
new file mode 100644
index 000000000000..6e75ba483237
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/tolower_1.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class ctype;
+
+// charT tolower(charT) const;
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+ std::locale l = std::locale::classic();
+ {
+ typedef std::ctype<wchar_t> F;
+ const F& f = std::use_facet<F>(l);
+
+ assert(f.tolower(L' ') == L' ');
+ assert(f.tolower(L'A') == L'a');
+ assert(f.tolower(L'\x07') == L'\x07');
+ assert(f.tolower(L'.') == L'.');
+ assert(f.tolower(L'a') == L'a');
+ assert(f.tolower(L'1') == L'1');
+ }
+}
diff --git a/test/std/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/tolower_many.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/tolower_many.pass.cpp
new file mode 100644
index 000000000000..68daf8d88a46
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/tolower_many.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class ctype;
+
+// const charT* tolower(charT* low, const charT* high) const;
+
+#include <locale>
+#include <string>
+#include <cassert>
+
+int main()
+{
+ std::locale l = std::locale::classic();
+ {
+ typedef std::ctype<wchar_t> F;
+ const F& f = std::use_facet<F>(l);
+ std::wstring in(L" A\x07.a1");
+
+ assert(f.tolower(&in[0], in.data() + in.size()) == in.data() + in.size());
+ assert(in[0] == L' ');
+ assert(in[1] == L'a');
+ assert(in[2] == L'\x07');
+ assert(in[3] == L'.');
+ assert(in[4] == L'a');
+ assert(in[5] == L'1');
+ }
+}
diff --git a/test/std/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/toupper_1.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/toupper_1.pass.cpp
new file mode 100644
index 000000000000..2a5acd17955d
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/toupper_1.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class ctype;
+
+// charT toupper(charT) const;
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+ std::locale l = std::locale::classic();
+ {
+ typedef std::ctype<wchar_t> F;
+ const F& f = std::use_facet<F>(l);
+
+ assert(f.toupper(L' ') == L' ');
+ assert(f.toupper(L'A') == L'A');
+ assert(f.toupper(L'\x07') == L'\x07');
+ assert(f.toupper(L'.') == L'.');
+ assert(f.toupper(L'a') == L'A');
+ assert(f.toupper(L'1') == L'1');
+ }
+}
diff --git a/test/std/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/toupper_many.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/toupper_many.pass.cpp
new file mode 100644
index 000000000000..f0a7ee3d21b6
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/toupper_many.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class ctype;
+
+// const charT* toupper(charT* low, const charT* high) const;
+
+#include <locale>
+#include <string>
+#include <cassert>
+
+int main()
+{
+ std::locale l = std::locale::classic();
+ {
+ typedef std::ctype<wchar_t> F;
+ const F& f = std::use_facet<F>(l);
+ std::wstring in(L" A\x07.a1");
+
+ assert(f.toupper(&in[0], in.data() + in.size()) == in.data() + in.size());
+ assert(in[0] == L' ');
+ assert(in[1] == L'A');
+ assert(in[2] == L'\x07');
+ assert(in[3] == L'.');
+ assert(in[4] == L'A');
+ assert(in[5] == L'1');
+ }
+}
diff --git a/test/std/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/widen_1.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/widen_1.pass.cpp
new file mode 100644
index 000000000000..2a8733c207d6
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/widen_1.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class ctype;
+
+// charT widen(char c) const;
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+ std::locale l = std::locale::classic();
+ {
+ typedef std::ctype<wchar_t> F;
+ const F& f = std::use_facet<F>(l);
+
+ assert(f.widen(' ') == L' ');
+ assert(f.widen('A') == L'A');
+ assert(f.widen('\x07') == L'\x07');
+ assert(f.widen('.') == L'.');
+ assert(f.widen('a') == L'a');
+ assert(f.widen('1') == L'1');
+ }
+}
diff --git a/test/std/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/widen_many.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/widen_many.pass.cpp
new file mode 100644
index 000000000000..1c656011a098
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/widen_many.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class ctype;
+
+// const char* widen(const char* low, const char* high, charT* to) const;
+
+#include <locale>
+#include <string>
+#include <vector>
+#include <cassert>
+
+int main()
+{
+ std::locale l = std::locale::classic();
+ {
+ typedef std::ctype<wchar_t> F;
+ const F& f = std::use_facet<F>(l);
+ std::string in(" A\x07.a1");
+ std::vector<wchar_t> v(in.size());
+
+ assert(f.widen(&in[0], in.data() + in.size(), v.data()) == in.data() + in.size());
+ assert(v[0] == L' ');
+ assert(v[1] == L'A');
+ assert(v[2] == L'\x07');
+ assert(v[3] == L'.');
+ assert(v[4] == L'a');
+ assert(v[5] == L'1');
+ }
+}
diff --git a/test/std/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.virtuals/tested_elsewhere.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.virtuals/tested_elsewhere.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.virtuals/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/localization/locale.categories/category.ctype/locale.ctype/types.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.ctype/types.pass.cpp
new file mode 100644
index 000000000000..7ad36afee669
--- /dev/null
+++ b/test/std/localization/locale.categories/category.ctype/locale.ctype/types.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class CharT>
+// class ctype
+// : public locale::facet,
+// public ctype_base
+// {
+// public:
+// typedef CharT char_type;
+// };
+
+#include <locale>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+ std::locale l = std::locale::classic();
+ {
+ assert(std::has_facet<std::ctype<wchar_t> >(l));
+ const std::ctype<wchar_t>& f = std::use_facet<std::ctype<wchar_t> >(l);
+ {
+ (void)std::ctype<wchar_t>::id;
+ }
+ static_assert((std::is_same<std::ctype<wchar_t>::char_type, wchar_t>::value), "");
+ static_assert((std::is_base_of<std::ctype_base, std::ctype<wchar_t> >::value), "");
+ static_assert((std::is_base_of<std::locale::facet, std::ctype<wchar_t> >::value), "");
+ }
+}
diff --git a/test/std/localization/locale.categories/category.messages/locale.messages.byname/nothing_to_do.pass.cpp b/test/std/localization/locale.categories/category.messages/locale.messages.byname/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/localization/locale.categories/category.messages/locale.messages.byname/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/localization/locale.categories/category.messages/locale.messages/ctor.pass.cpp b/test/std/localization/locale.categories/category.messages/locale.messages/ctor.pass.cpp
new file mode 100644
index 000000000000..e82878a310cf
--- /dev/null
+++ b/test/std/localization/locale.categories/category.messages/locale.messages/ctor.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class messages<charT>
+
+// explicit messages(size_t refs = 0);
+
+#include <locale>
+#include <cassert>
+
+typedef std::messages<char> F;
+
+class my_facet
+ : public F
+{
+public:
+ static int count;
+
+ explicit my_facet(std::size_t refs = 0)
+ : F(refs) {++count;}
+
+ ~my_facet() {--count;}
+};
+
+int my_facet::count = 0;
+
+int main()
+{
+ {
+ std::locale l(std::locale::classic(), new my_facet);
+ assert(my_facet::count == 1);
+ }
+ assert(my_facet::count == 0);
+ {
+ my_facet f(1);
+ assert(my_facet::count == 1);
+ {
+ std::locale l(std::locale::classic(), &f);
+ assert(my_facet::count == 1);
+ }
+ assert(my_facet::count == 1);
+ }
+ assert(my_facet::count == 0);
+}
diff --git a/test/std/localization/locale.categories/category.messages/locale.messages/locale.messages.members/not_testable.pass.cpp b/test/std/localization/locale.categories/category.messages/locale.messages/locale.messages.members/not_testable.pass.cpp
new file mode 100644
index 000000000000..6bed5383c058
--- /dev/null
+++ b/test/std/localization/locale.categories/category.messages/locale.messages/locale.messages.members/not_testable.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class messages<charT>
+
+// catalog open(const basic_string<char>& name, const locale&) const;
+
+#include <locale>
+#include <cassert>
+
+// As far as I can tell, the messages facet is untestable. I have a best
+// effort implementation in the hopes that in the future I will learn how
+// to test it.
+
+template <class CharT>
+class F
+ : public std::messages<CharT>
+{
+public:
+ explicit F(std::size_t refs = 0)
+ : std::messages<CharT>(refs) {}
+};
+
+int main()
+{
+}
diff --git a/test/std/localization/locale.categories/category.messages/locale.messages/locale.messages.virtuals/tested_elsewhere.pass.cpp b/test/std/localization/locale.categories/category.messages/locale.messages/locale.messages.virtuals/tested_elsewhere.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/localization/locale.categories/category.messages/locale.messages/locale.messages.virtuals/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/localization/locale.categories/category.messages/locale.messages/messages_base.pass.cpp b/test/std/localization/locale.categories/category.messages/locale.messages/messages_base.pass.cpp
new file mode 100644
index 000000000000..cf9b4c8992c0
--- /dev/null
+++ b/test/std/localization/locale.categories/category.messages/locale.messages/messages_base.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class messages_base
+// {
+// public:
+// typedef unspecified catalog;
+// };
+
+#include <locale>
+#include <type_traits>
+
+int main()
+{
+ std::messages_base mb;
+}
diff --git a/test/std/localization/locale.categories/category.messages/locale.messages/types.pass.cpp b/test/std/localization/locale.categories/category.messages/locale.messages/types.pass.cpp
new file mode 100644
index 000000000000..60e47b53767f
--- /dev/null
+++ b/test/std/localization/locale.categories/category.messages/locale.messages/types.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class _CharT>
+// class messages
+// : public locale::facet,
+// public messages_base
+// {
+// public:
+// typedef _CharT char_type;
+// typedef basic_string<_CharT> string_type;
+
+#include <locale>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_base_of<std::locale::facet, std::messages<char> >::value), "");
+ static_assert((std::is_base_of<std::messages_base, std::messages<char> >::value), "");
+ static_assert((std::is_base_of<std::locale::facet, std::messages<wchar_t> >::value), "");
+ static_assert((std::is_base_of<std::messages_base, std::messages<wchar_t> >::value), "");
+ static_assert((std::is_same<std::messages<char>::char_type, char>::value), "");
+ static_assert((std::is_same<std::messages<wchar_t>::char_type, wchar_t>::value), "");
+ static_assert((std::is_same<std::messages<char>::string_type, std::string>::value), "");
+ static_assert((std::is_same<std::messages<wchar_t>::string_type, std::wstring>::value), "");
+}
diff --git a/test/std/localization/locale.categories/category.messages/nothing_to_do.pass.cpp b/test/std/localization/locale.categories/category.messages/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/localization/locale.categories/category.messages/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/localization/locale.categories/category.monetary/locale.money.get/ctor.pass.cpp b/test/std/localization/locale.categories/category.monetary/locale.money.get/ctor.pass.cpp
new file mode 100644
index 000000000000..9052826a5228
--- /dev/null
+++ b/test/std/localization/locale.categories/category.monetary/locale.money.get/ctor.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class money_get<charT, InputIterator>
+
+// explicit money_get(size_t refs = 0);
+
+#include <locale>
+#include <cassert>
+
+typedef std::money_get<char, const char*> F;
+
+class my_facet
+ : public F
+{
+public:
+ static int count;
+
+ explicit my_facet(std::size_t refs = 0)
+ : F(refs) {++count;}
+
+ ~my_facet() {--count;}
+};
+
+int my_facet::count = 0;
+
+int main()
+{
+ {
+ std::locale l(std::locale::classic(), new my_facet);
+ assert(my_facet::count == 1);
+ }
+ assert(my_facet::count == 0);
+ {
+ my_facet f(1);
+ assert(my_facet::count == 1);
+ {
+ std::locale l(std::locale::classic(), &f);
+ assert(my_facet::count == 1);
+ }
+ assert(my_facet::count == 1);
+ }
+ assert(my_facet::count == 0);
+}
diff --git a/test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_en_US.pass.cpp b/test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_en_US.pass.cpp
new file mode 100644
index 000000000000..0f034fa4fdd3
--- /dev/null
+++ b/test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_en_US.pass.cpp
@@ -0,0 +1,723 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class money_get<charT, InputIterator>
+
+// iter_type get(iter_type b, iter_type e, bool intl, ios_base& iob,
+// ios_base::iostate& err, long double& v) const;
+
+// REQUIRES: locale.en_US.UTF-8
+
+#include <locale>
+#include <ios>
+#include <streambuf>
+#include <cassert>
+#include "test_iterators.h"
+
+#include "platform_support.h" // locale name macros
+
+typedef std::money_get<char, input_iterator<const char*> > Fn;
+
+class my_facet
+ : public Fn
+{
+public:
+ explicit my_facet(std::size_t refs = 0)
+ : Fn(refs) {}
+};
+
+typedef std::money_get<wchar_t, input_iterator<const wchar_t*> > Fw;
+
+class my_facetw
+ : public Fw
+{
+public:
+ explicit my_facetw(std::size_t refs = 0)
+ : Fw(refs) {}
+};
+
+int main()
+{
+ std::ios ios(0);
+ std::string loc_name(LOCALE_en_US_UTF_8);
+ ios.imbue(std::locale(ios.getloc(),
+ new std::moneypunct_byname<char, false>(loc_name)));
+ ios.imbue(std::locale(ios.getloc(),
+ new std::moneypunct_byname<char, true>(loc_name)));
+ ios.imbue(std::locale(ios.getloc(),
+ new std::moneypunct_byname<wchar_t, false>(loc_name)));
+ ios.imbue(std::locale(ios.getloc(),
+ new std::moneypunct_byname<wchar_t, true>(loc_name)));
+ {
+ const my_facet f(1);
+ // char, national
+ { // zero
+ std::string v = "0.00";
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 0);
+ }
+ { // negative one
+ std::string v = "-0.01";
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -1);
+ }
+ { // positive
+ std::string v = "1,234,567.89";
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 123456789);
+ }
+ { // negative
+ std::string v = "-1,234,567.89";
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -123456789);
+ }
+ { // negative
+ std::string v = "-1234567.89";
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -123456789);
+ }
+ { // zero, showbase
+ std::string v = "$0.00";
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 0);
+ }
+ { // zero, showbase
+ std::string v = "$0.00";
+ showbase(ios);
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 0);
+ noshowbase(ios);
+ }
+ { // negative one, showbase
+ std::string v = "-$0.01";
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -1);
+ }
+ { // negative one, showbase
+ std::string v = "-$0.01";
+ showbase(ios);
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -1);
+ noshowbase(ios);
+ }
+ { // positive, showbase
+ std::string v = "$1,234,567.89";
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 123456789);
+ }
+ { // positive, showbase
+ std::string v = "$1,234,567.89";
+ showbase(ios);
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 123456789);
+ noshowbase(ios);
+ }
+ { // negative, showbase
+ std::string v = "-$1,234,567.89";
+ showbase(ios);
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -123456789);
+ noshowbase(ios);
+ }
+ { // negative, showbase
+ std::string v = "-USD 1,234,567.89";
+ showbase(ios);
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + 1);
+ assert(err == std::ios_base::failbit);
+ noshowbase(ios);
+ }
+ { // negative, showbase
+ std::string v = "-USD 1,234,567.89";
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + 1);
+ assert(err == std::ios_base::failbit);
+ }
+ }
+ {
+ const my_facet f(1);
+ // char, international
+ { // zero
+ std::string v = "0.00";
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 0);
+ }
+ { // negative one
+ std::string v = "-0.01";
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -1);
+ }
+ { // positive
+ std::string v = "1,234,567.89";
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 123456789);
+ }
+ { // negative
+ std::string v = "-1,234,567.89";
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -123456789);
+ }
+ { // negative
+ std::string v = "-1234567.89";
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -123456789);
+ }
+ { // zero, showbase
+ std::string v = "USD 0.00";
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 0);
+ }
+ { // zero, showbase
+ std::string v = "USD 0.00";
+ showbase(ios);
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 0);
+ noshowbase(ios);
+ }
+ { // negative one, showbase
+ std::string v = "-USD 0.01";
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -1);
+ }
+ { // negative one, showbase
+ std::string v = "-USD 0.01";
+ showbase(ios);
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -1);
+ noshowbase(ios);
+ }
+ { // positive, showbase
+ std::string v = "USD 1,234,567.89";
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 123456789);
+ }
+ { // positive, showbase
+ std::string v = "USD 1,234,567.89";
+ showbase(ios);
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 123456789);
+ noshowbase(ios);
+ }
+ { // negative, showbase
+ std::string v = "-USD 1,234,567.89";
+ showbase(ios);
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -123456789);
+ noshowbase(ios);
+ }
+ { // negative, showbase
+ std::string v = "-$1,234,567.89";
+ showbase(ios);
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + 1);
+ assert(err == std::ios_base::failbit);
+ noshowbase(ios);
+ }
+ { // negative, showbase
+ std::string v = "-$1,234,567.89";
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + 1);
+ assert(err == std::ios_base::failbit);
+ }
+ }
+ {
+ const my_facetw f(1);
+ // wchar_t, national
+ { // zero
+ std::wstring v = L"0.00";
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 0);
+ }
+ { // negative one
+ std::wstring v = L"-0.01";
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -1);
+ }
+ { // positive
+ std::wstring v = L"1,234,567.89";
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 123456789);
+ }
+ { // negative
+ std::wstring v = L"-1,234,567.89";
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -123456789);
+ }
+ { // negative
+ std::wstring v = L"-1234567.89";
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -123456789);
+ }
+ { // zero, showbase
+ std::wstring v = L"$0.00";
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 0);
+ }
+ { // zero, showbase
+ std::wstring v = L"$0.00";
+ showbase(ios);
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 0);
+ noshowbase(ios);
+ }
+ { // negative one, showbase
+ std::wstring v = L"-$0.01";
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -1);
+ }
+ { // negative one, showbase
+ std::wstring v = L"-$0.01";
+ showbase(ios);
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -1);
+ noshowbase(ios);
+ }
+ { // positive, showbase
+ std::wstring v = L"$1,234,567.89";
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 123456789);
+ }
+ { // positive, showbase
+ std::wstring v = L"$1,234,567.89";
+ showbase(ios);
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 123456789);
+ noshowbase(ios);
+ }
+ { // negative, showbase
+ std::wstring v = L"-$1,234,567.89";
+ showbase(ios);
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -123456789);
+ noshowbase(ios);
+ }
+ { // negative, showbase
+ std::wstring v = L"-USD 1,234,567.89";
+ showbase(ios);
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + 1);
+ assert(err == std::ios_base::failbit);
+ noshowbase(ios);
+ }
+ { // negative, showbase
+ std::wstring v = L"-USD 1,234,567.89";
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + 1);
+ assert(err == std::ios_base::failbit);
+ }
+ }
+ {
+ const my_facetw f(1);
+ // wchar_t, international
+ { // zero
+ std::wstring v = L"0.00";
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 0);
+ }
+ { // negative one
+ std::wstring v = L"-0.01";
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -1);
+ }
+ { // positive
+ std::wstring v = L"1,234,567.89";
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 123456789);
+ }
+ { // negative
+ std::wstring v = L"-1,234,567.89";
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -123456789);
+ }
+ { // negative
+ std::wstring v = L"-1234567.89";
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -123456789);
+ }
+ { // zero, showbase
+ std::wstring v = L"USD 0.00";
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 0);
+ }
+ { // zero, showbase
+ std::wstring v = L"USD 0.00";
+ showbase(ios);
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 0);
+ noshowbase(ios);
+ }
+ { // negative one, showbase
+ std::wstring v = L"-USD 0.01";
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -1);
+ }
+ { // negative one, showbase
+ std::wstring v = L"-USD 0.01";
+ showbase(ios);
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -1);
+ noshowbase(ios);
+ }
+ { // positive, showbase
+ std::wstring v = L"USD 1,234,567.89";
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 123456789);
+ }
+ { // positive, showbase
+ std::wstring v = L"USD 1,234,567.89";
+ showbase(ios);
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 123456789);
+ noshowbase(ios);
+ }
+ { // negative, showbase
+ std::wstring v = L"-USD 1,234,567.89";
+ showbase(ios);
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -123456789);
+ noshowbase(ios);
+ }
+ { // negative, showbase
+ std::wstring v = L"-$1,234,567.89";
+ showbase(ios);
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + 1);
+ assert(err == std::ios_base::failbit);
+ noshowbase(ios);
+ }
+ { // negative, showbase
+ std::wstring v = L"-$1,234,567.89";
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + 1);
+ assert(err == std::ios_base::failbit);
+ }
+ }
+}
diff --git a/test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_fr_FR.pass.cpp b/test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_fr_FR.pass.cpp
new file mode 100644
index 000000000000..d7ce1033a8da
--- /dev/null
+++ b/test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_fr_FR.pass.cpp
@@ -0,0 +1,726 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// XFAIL: apple-darwin
+
+// REQUIRES: locale.fr_FR.UTF-8
+
+// <locale>
+
+// class money_get<charT, InputIterator>
+
+// iter_type get(iter_type b, iter_type e, bool intl, ios_base& iob,
+// ios_base::iostate& err, long double& v) const;
+
+#include <locale>
+#include <ios>
+#include <streambuf>
+#include <cassert>
+#include "test_iterators.h"
+
+#include "platform_support.h" // locale name macros
+
+typedef std::money_get<char, input_iterator<const char*> > Fn;
+
+class my_facet
+ : public Fn
+{
+public:
+ explicit my_facet(std::size_t refs = 0)
+ : Fn(refs) {}
+};
+
+typedef std::money_get<wchar_t, input_iterator<const wchar_t*> > Fw;
+
+class my_facetw
+ : public Fw
+{
+public:
+ explicit my_facetw(std::size_t refs = 0)
+ : Fw(refs) {}
+};
+
+int main()
+{
+ std::ios ios(0);
+ std::string loc_name(LOCALE_fr_FR_UTF_8);
+ ios.imbue(std::locale(ios.getloc(),
+ new std::moneypunct_byname<char, false>(loc_name)));
+ ios.imbue(std::locale(ios.getloc(),
+ new std::moneypunct_byname<char, true>(loc_name)));
+ ios.imbue(std::locale(ios.getloc(),
+ new std::moneypunct_byname<wchar_t, false>(loc_name)));
+ ios.imbue(std::locale(ios.getloc(),
+ new std::moneypunct_byname<wchar_t, true>(loc_name)));
+ {
+ const my_facet f(1);
+ // char, national
+ { // zero
+ std::string v = "0,00";
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 0);
+ }
+ { // negative one
+ std::string v = "-0,01";
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -1);
+ }
+ { // positive
+ std::string v = "1 234 567,89 ";
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 123456789);
+ }
+ { // negative
+ std::string v = "-1 234 567,89";
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -123456789);
+ }
+ { // negative
+ std::string v = "-1234567,89";
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -123456789);
+ }
+ { // zero, showbase
+ std::string v = "0,00 \u20ac"; // €
+ showbase(ios);
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 0);
+ }
+ { // zero, showbase
+ std::string v = "0,00 \u20ac"; // €
+ showbase(ios);
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 0);
+ }
+ { // negative one, showbase
+ std::string v = "-0,01 \u20ac";
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -1);
+ }
+ { // negative one, showbase
+ std::string v = "-0,01 \u20ac";
+ showbase(ios);
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -1);
+ }
+ { // positive, showbase
+ std::string v = "1 234 567,89 \u20ac";
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 123456789);
+ }
+ { // positive, showbase
+ std::string v = "1 234 567,89 \u20ac";
+ showbase(ios);
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 123456789);
+ noshowbase(ios);
+ }
+ { // negative, showbase
+ std::string v = "-1 234 567,89 \u20ac";
+ showbase(ios);
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -123456789);
+ noshowbase(ios);
+ }
+ { // negative, showbase
+ std::string v = "1 234 567,89 EUR -";
+ showbase(ios);
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + 13);
+ assert(err == std::ios_base::failbit);
+ noshowbase(ios);
+ }
+ { // negative, showbase
+ std::string v = "1 234 567,89 EUR -";
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + 13);
+ assert(err == std::ios_base::goodbit);
+ assert(ex == 123456789);
+ }
+ noshowbase(ios);
+ }
+ {
+ const my_facet f(1);
+ // char, international
+ { // zero
+ std::string v = "0,00";
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 0);
+ }
+ { // negative one
+ std::string v = "-0,01";
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -1);
+ }
+ { // positive
+ std::string v = "1 234 567,89 ";
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 123456789);
+ }
+ { // negative
+ std::string v = "-1 234 567,89";
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -123456789);
+ }
+ { // negative
+ std::string v = "-1234567,89";
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -123456789);
+ }
+ { // zero, showbase
+ std::string v = "0,00 EUR";
+ showbase(ios);
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 0);
+ }
+ { // zero, showbase
+ std::string v = "0,00 EUR";
+ showbase(ios);
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 0);
+ }
+ { // negative one, showbase
+ std::string v = "-0,01 EUR";
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -1);
+ }
+ { // negative one, showbase
+ std::string v = "-0,01 EUR";
+ showbase(ios);
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -1);
+ }
+ { // positive, showbase
+ std::string v = "1 234 567,89 EUR";
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 123456789);
+ }
+ { // positive, showbase
+ std::string v = "1 234 567,89 EUR";
+ showbase(ios);
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 123456789);
+ noshowbase(ios);
+ }
+ { // negative, showbase
+ std::string v = "-1 234 567,89 EUR";
+ showbase(ios);
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -123456789);
+ noshowbase(ios);
+ }
+ { // negative, showbase
+ std::string v = "1 234 567,89 Eu-";
+ showbase(ios);
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + 14);
+ assert(err == std::ios_base::failbit);
+ noshowbase(ios);
+ }
+ { // negative, showbase
+ std::string v = "1 234 567,89 Eu-";
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + 13);
+ assert(err == std::ios_base::goodbit);
+ assert(ex == 123456789);
+ }
+ }
+ {
+ const my_facetw f(1);
+ // wchar_t, national
+ { // zero
+ std::wstring v = L"0,00";
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 0);
+ }
+ { // negative one
+ std::wstring v = L"-0,01";
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -1);
+ }
+ { // positive
+ std::wstring v = L"1 234 567,89 ";
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 123456789);
+ }
+ { // negative
+ std::wstring v = L"-1 234 567,89";
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -123456789);
+ }
+ { // negative
+ std::wstring v = L"-1234567,89";
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -123456789);
+ }
+ { // zero, showbase
+ std::wstring v = L"0,00 \u20ac";
+ showbase(ios);
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 0);
+ }
+ { // zero, showbase
+ std::wstring v = L"0,00 \u20ac";
+ showbase(ios);
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 0);
+ }
+ { // negative one, showbase
+ std::wstring v = L"-0,01 \u20ac";
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -1);
+ }
+ { // negative one, showbase
+ std::wstring v = L"-0,01 \u20ac";
+ showbase(ios);
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -1);
+ }
+ { // positive, showbase
+ std::wstring v = L"1 234 567,89 \u20ac";
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 123456789);
+ }
+ { // positive, showbase
+ std::wstring v = L"1 234 567,89 \u20ac";
+ showbase(ios);
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 123456789);
+ noshowbase(ios);
+ }
+ { // negative, showbase
+ std::wstring v = L"-1 234 567,89 \u20ac";
+ showbase(ios);
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -123456789);
+ noshowbase(ios);
+ }
+ { // negative, showbase
+ std::wstring v = L"1 234 567,89 EUR -";
+ showbase(ios);
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + 13);
+ assert(err == std::ios_base::failbit);
+ noshowbase(ios);
+ }
+ { // negative, showbase
+ std::wstring v = L"1 234 567,89 EUR -";
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + 13);
+ assert(err == std::ios_base::goodbit);
+ assert(ex == 123456789);
+ }
+ }
+ {
+ const my_facetw f(1);
+ // wchar_t, international
+ { // zero
+ std::wstring v = L"0,00";
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 0);
+ }
+ { // negative one
+ std::wstring v = L"-0,01";
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -1);
+ }
+ { // positive
+ std::wstring v = L"1 234 567,89 ";
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 123456789);
+ }
+ { // negative
+ std::wstring v = L"-1 234 567,89";
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -123456789);
+ }
+ { // negative
+ std::wstring v = L"-1234567,89";
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -123456789);
+ }
+ { // zero, showbase
+ std::wstring v = L"0,00 EUR";
+ showbase(ios);
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 0);
+ }
+ { // zero, showbase
+ std::wstring v = L"0,00 EUR";
+ showbase(ios);
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 0);
+ }
+ { // negative one, showbase
+ std::wstring v = L"-0,01 EUR";
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -1);
+ }
+ { // negative one, showbase
+ std::wstring v = L"-0,01 EUR";
+ showbase(ios);
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -1);
+ }
+ { // positive, showbase
+ std::wstring v = L"1 234 567,89 EUR";
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 123456789);
+ }
+ { // positive, showbase
+ std::wstring v = L"1 234 567,89 EUR";
+ showbase(ios);
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 123456789);
+ noshowbase(ios);
+ }
+ { // negative, showbase
+ std::wstring v = L"-1 234 567,89 EUR";
+ showbase(ios);
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -123456789);
+ noshowbase(ios);
+ }
+ { // negative, showbase
+ std::wstring v = L"1 234 567,89 Eu-";
+ showbase(ios);
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + 14);
+ assert(err == std::ios_base::failbit);
+ noshowbase(ios);
+ }
+ { // negative, showbase
+ std::wstring v = L"1 234 567,89 Eu-";
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + 13);
+ assert(err == std::ios_base::goodbit);
+ assert(ex == 123456789);
+ }
+ }
+}
diff --git a/test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_ru_RU.pass.cpp b/test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_ru_RU.pass.cpp
new file mode 100644
index 000000000000..ec563fe4c7bc
--- /dev/null
+++ b/test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_ru_RU.pass.cpp
@@ -0,0 +1,735 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// XFAIL: apple-darwin
+
+// Failure related to GLIBC's use of U00A0 as mon_thousands_sep
+// and U002E as mon_decimal_point.
+// TODO: U00A0 should be investigated.
+// Possibly related to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=16006
+// XFAIL: linux
+
+// REQUIRES: locale.ru_RU.UTF-8
+
+// <locale>
+
+// class money_get<charT, InputIterator>
+
+// iter_type get(iter_type b, iter_type e, bool intl, ios_base& iob,
+// ios_base::iostate& err, long double& v) const;
+
+#include <locale>
+#include <ios>
+#include <streambuf>
+#include <cassert>
+#include "test_iterators.h"
+
+#include "platform_support.h" // locale name macros
+
+typedef std::money_get<char, input_iterator<const char*> > Fn;
+
+class my_facet
+ : public Fn
+{
+public:
+ explicit my_facet(std::size_t refs = 0)
+ : Fn(refs) {}
+};
+
+typedef std::money_get<wchar_t, input_iterator<const wchar_t*> > Fw;
+
+class my_facetw
+ : public Fw
+{
+public:
+ explicit my_facetw(std::size_t refs = 0)
+ : Fw(refs) {}
+};
+
+int main()
+{
+ std::ios ios(0);
+ std::string loc_name(LOCALE_ru_RU_UTF_8);
+ ios.imbue(std::locale(ios.getloc(),
+ new std::moneypunct_byname<char, false>(loc_name)));
+ ios.imbue(std::locale(ios.getloc(),
+ new std::moneypunct_byname<char, true>(loc_name)));
+ ios.imbue(std::locale(ios.getloc(),
+ new std::moneypunct_byname<wchar_t, false>(loc_name)));
+ ios.imbue(std::locale(ios.getloc(),
+ new std::moneypunct_byname<wchar_t, true>(loc_name)));
+ {
+ const my_facet f(1);
+ // char, national
+ { // zero
+ std::string v = "0,00 ";
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 0);
+ }
+ { // negative one
+ std::string v = "-0,01 ";
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -1);
+ }
+ { // positive
+ std::string v = "1 234 567,89 ";
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 123456789);
+ }
+ { // negative
+ std::string v = "-1 234 567,89 ";
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -123456789);
+ }
+ { // negative
+ std::string v = "-1234567,89 ";
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -123456789);
+ }
+ { // zero, showbase
+ std::string v = "0,00 \xD1\x80\xD1\x83\xD0\xB1"".";
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + 5);
+ assert(err == std::ios_base::goodbit);
+ assert(ex == 0);
+ }
+ { // zero, showbase
+ std::string v = "0,00 \xD1\x80\xD1\x83\xD0\xB1"".";
+ showbase(ios);
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 0);
+ noshowbase(ios);
+ }
+ { // negative one, showbase
+ std::string v = "-0,01 \xD1\x80\xD1\x83\xD0\xB1"".";
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + 6);
+ assert(err == std::ios_base::goodbit);
+ assert(ex == -1);
+ }
+ { // negative one, showbase
+ std::string v = "-0,01 \xD1\x80\xD1\x83\xD0\xB1"".";
+ showbase(ios);
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -1);
+ noshowbase(ios);
+ }
+ { // positive, showbase
+ std::string v = "1 234 567,89 \xD1\x80\xD1\x83\xD0\xB1"".";
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + 13);
+ assert(err == std::ios_base::goodbit);
+ assert(ex == 123456789);
+ }
+ { // positive, showbase
+ std::string v = "1 234 567,89 \xD1\x80\xD1\x83\xD0\xB1"".";
+ showbase(ios);
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 123456789);
+ noshowbase(ios);
+ }
+ { // negative, showbase
+ std::string v = "-1 234 567,89 \xD1\x80\xD1\x83\xD0\xB1"".";
+ showbase(ios);
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -123456789);
+ noshowbase(ios);
+ }
+ { // negative, showbase
+ std::string v = "-1 234 567,89 RUB ";
+ showbase(ios);
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + 14);
+ assert(err == std::ios_base::failbit);
+ noshowbase(ios);
+ }
+ { // negative, showbase
+ std::string v = "-1 234 567,89 RUB ";
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + 14);
+ assert(err == std::ios_base::goodbit);
+ assert(ex == -123456789);
+ }
+ }
+ {
+ const my_facet f(1);
+ // char, international
+ { // zero
+ std::string v = "0,00";
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 0);
+ }
+ { // negative one
+ std::string v = "-0,01 ";
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -1);
+ }
+ { // positive
+ std::string v = "1 234 567,89 ";
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 123456789);
+ }
+ { // negative
+ std::string v = "-1 234 567,89 ";
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -123456789);
+ }
+ { // negative
+ std::string v = "-1234567,89 ";
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -123456789);
+ }
+ { // zero, showbase
+ std::string v = "0,00 RUB ";
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + 5);
+ assert(err == std::ios_base::goodbit);
+ assert(ex == 0);
+ }
+ { // zero, showbase
+ std::string v = "0,00 RUB ";
+ showbase(ios);
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 0);
+ noshowbase(ios);
+ }
+ { // negative one, showbase
+ std::string v = "-0,01 RUB ";
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + 6);
+ assert(err == std::ios_base::goodbit);
+ assert(ex == -1);
+ }
+ { // negative one, showbase
+ std::string v = "-0,01 RUB ";
+ showbase(ios);
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -1);
+ noshowbase(ios);
+ }
+ { // positive, showbase
+ std::string v = "1 234 567,89 RUB ";
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + 13);
+ assert(err == std::ios_base::goodbit);
+ assert(ex == 123456789);
+ }
+ { // positive, showbase
+ std::string v = "1 234 567,89 RUB ";
+ showbase(ios);
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 123456789);
+ noshowbase(ios);
+ }
+ { // negative, showbase
+ std::string v = "-1 234 567,89 RUB ";
+ showbase(ios);
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -123456789);
+ noshowbase(ios);
+ }
+ { // negative, showbase
+ std::string v = "-1 234 567,89 \xD1\x80\xD1\x83\xD0\xB1"".";
+ showbase(ios);
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + 14);
+ assert(err == std::ios_base::failbit);
+ noshowbase(ios);
+ }
+ { // negative, showbase
+ std::string v = "-1 234 567,89 \xD1\x80\xD1\x83\xD0\xB1"".";
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + 14);
+ assert(err == std::ios_base::goodbit);
+ assert(ex == -123456789);
+ }
+ }
+ {
+ const my_facetw f(1);
+ // wchar_t, national
+ { // zero
+ std::wstring v = L"0,00";
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 0);
+ }
+ { // negative one
+ std::wstring v = L"-0,01 ";
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -1);
+ }
+ { // positive
+ std::wstring v = L"1 234 567,89 ";
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 123456789);
+ }
+ { // negative
+ std::wstring v = L"-1 234 567,89 ";
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -123456789);
+ }
+ { // negative
+ std::wstring v = L"-1234567,89 ";
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -123456789);
+ }
+ { // zero, showbase
+ std::wstring v = L"0,00 \x440\x443\x431"".";
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + 5);
+ assert(err == std::ios_base::goodbit);
+ assert(ex == 0);
+ }
+ { // zero, showbase
+ std::wstring v = L"0,00 \x440\x443\x431"".";
+ showbase(ios);
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 0);
+ noshowbase(ios);
+ }
+ { // negative one, showbase
+ std::wstring v = L"-0,01 \x440\x443\x431"".";
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + 6);
+ assert(err == std::ios_base::goodbit);
+ assert(ex == -1);
+ }
+ { // negative one, showbase
+ std::wstring v = L"-0,01 \x440\x443\x431"".";
+ showbase(ios);
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -1);
+ noshowbase(ios);
+ }
+ { // positive, showbase
+ std::wstring v = L"1 234 567,89 \x440\x443\x431"".";
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + 13);
+ assert(err == std::ios_base::goodbit);
+ assert(ex == 123456789);
+ }
+ { // positive, showbase
+ std::wstring v = L"1 234 567,89 \x440\x443\x431"".";
+ showbase(ios);
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 123456789);
+ noshowbase(ios);
+ }
+ { // negative, showbase
+ std::wstring v = L"-1 234 567,89 \x440\x443\x431"".";
+ showbase(ios);
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -123456789);
+ noshowbase(ios);
+ }
+ { // negative, showbase
+ std::wstring v = L"-1 234 567,89 RUB ";
+ showbase(ios);
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + 14);
+ assert(err == std::ios_base::failbit);
+ noshowbase(ios);
+ }
+ { // negative, showbase
+ std::wstring v = L"-1 234 567,89 RUB ";
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + 14);
+ assert(err == std::ios_base::goodbit);
+ assert(ex == -123456789);
+ }
+ }
+ {
+ const my_facetw f(1);
+ // wchar_t, international
+ { // zero
+ std::wstring v = L"0,00";
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 0);
+ }
+ { // negative one
+ std::wstring v = L"-0,01 ";
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -1);
+ }
+ { // positive
+ std::wstring v = L"1 234 567,89 ";
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 123456789);
+ }
+ { // negative
+ std::wstring v = L"-1 234 567,89 ";
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -123456789);
+ }
+ { // negative
+ std::wstring v = L"-1234567,89 ";
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -123456789);
+ }
+ { // zero, showbase
+ std::wstring v = L"0,00 RUB ";
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + 5);
+ assert(err == std::ios_base::goodbit);
+ assert(ex == 0);
+ }
+ { // zero, showbase
+ std::wstring v = L"0,00 RUB ";
+ showbase(ios);
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 0);
+ noshowbase(ios);
+ }
+ { // negative one, showbase
+ std::wstring v = L"-0,01 RUB ";
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + 6);
+ assert(err == std::ios_base::goodbit);
+ assert(ex == -1);
+ }
+ { // negative one, showbase
+ std::wstring v = L"-0,01 RUB ";
+ showbase(ios);
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -1);
+ noshowbase(ios);
+ }
+ { // positive, showbase
+ std::wstring v = L"1 234 567,89 RUB ";
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + 13);
+ assert(err == std::ios_base::goodbit);
+ assert(ex == 123456789);
+ }
+ { // positive, showbase
+ std::wstring v = L"1 234 567,89 RUB ";
+ showbase(ios);
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 123456789);
+ noshowbase(ios);
+ }
+ { // negative, showbase
+ std::wstring v = L"-1 234 567,89 RUB ";
+ showbase(ios);
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -123456789);
+ noshowbase(ios);
+ }
+ { // negative, showbase
+ std::wstring v = L"-1 234 567,89 \x440\x443\x431"".";
+ showbase(ios);
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + 14);
+ assert(err == std::ios_base::failbit);
+ noshowbase(ios);
+ }
+ { // negative, showbase
+ std::wstring v = L"-1 234 567,89 \x440\x443\x431"".";
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + 14);
+ assert(err == std::ios_base::goodbit);
+ assert(ex == -123456789);
+ }
+ }
+}
diff --git a/test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_zh_CN.pass.cpp b/test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_zh_CN.pass.cpp
new file mode 100644
index 000000000000..07a33f7663b6
--- /dev/null
+++ b/test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_zh_CN.pass.cpp
@@ -0,0 +1,726 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: locale.zh_CN.UTF-8
+
+// <locale>
+
+// class money_get<charT, InputIterator>
+
+// iter_type get(iter_type b, iter_type e, bool intl, ios_base& iob,
+// ios_base::iostate& err, long double& v) const;
+
+// TODO For zh_CN GLIBC puts the negative sign after the currency symbol.
+// XFAIL: linux-gnu
+
+#include <locale>
+#include <ios>
+#include <streambuf>
+#include <cassert>
+#include "test_iterators.h"
+
+#include "platform_support.h" // locale name macros
+
+typedef std::money_get<char, input_iterator<const char*> > Fn;
+
+class my_facet
+ : public Fn
+{
+public:
+ explicit my_facet(std::size_t refs = 0)
+ : Fn(refs) {}
+};
+
+typedef std::money_get<wchar_t, input_iterator<const wchar_t*> > Fw;
+
+class my_facetw
+ : public Fw
+{
+public:
+ explicit my_facetw(std::size_t refs = 0)
+ : Fw(refs) {}
+};
+
+int main()
+{
+ std::ios ios(0);
+ std::string loc_name(LOCALE_zh_CN_UTF_8);
+ ios.imbue(std::locale(ios.getloc(),
+ new std::moneypunct_byname<char, false>(loc_name)));
+ ios.imbue(std::locale(ios.getloc(),
+ new std::moneypunct_byname<char, true>(loc_name)));
+ ios.imbue(std::locale(ios.getloc(),
+ new std::moneypunct_byname<wchar_t, false>(loc_name)));
+ ios.imbue(std::locale(ios.getloc(),
+ new std::moneypunct_byname<wchar_t, true>(loc_name)));
+ {
+ const my_facet f(1);
+ // char, national
+ { // zero
+ std::string v = "0.00";
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 0);
+ }
+ { // negative one
+ std::string v = "-0.01";
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -1);
+ }
+ { // positive
+ std::string v = "1,234,567.89";
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 123456789);
+ }
+ { // negative
+ std::string v = "-1,234,567.89";
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -123456789);
+ }
+ { // negative
+ std::string v = "-1234567.89";
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -123456789);
+ }
+ { // zero, showbase
+ std::string v = "\xEF\xBF\xA5""0.00";
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 0);
+ }
+ { // zero, showbase
+ std::string v = "\xEF\xBF\xA5""0.00";
+ showbase(ios);
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 0);
+ noshowbase(ios);
+ }
+ { // negative one, showbase
+ std::string v = "\xEF\xBF\xA5""-0.01";
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -1);
+ }
+ { // negative one, showbase
+ std::string v = "\xEF\xBF\xA5""-0.01";
+ showbase(ios);
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -1);
+ noshowbase(ios);
+ }
+ { // positive, showbase
+ std::string v = "\xEF\xBF\xA5""1,234,567.89";
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 123456789);
+ }
+ { // positive, showbase
+ std::string v = "\xEF\xBF\xA5""1,234,567.89";
+ showbase(ios);
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 123456789);
+ noshowbase(ios);
+ }
+ { // negative, showbase
+ std::string v = "\xEF\xBF\xA5""-1,234,567.89";
+ showbase(ios);
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -123456789);
+ noshowbase(ios);
+ }
+ { // negative, showbase
+ std::string v = "CNY -1,234,567.89";
+ showbase(ios);
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + 0);
+ assert(err == std::ios_base::failbit);
+ noshowbase(ios);
+ }
+ { // negative, showbase
+ std::string v = "CNY -1,234,567.89";
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + 0);
+ assert(err == std::ios_base::failbit);
+ }
+ }
+ {
+ const my_facet f(1);
+ // char, international
+ { // zero
+ std::string v = "0.00";
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 0);
+ }
+ { // negative one
+ std::string v = "-0.01";
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -1);
+ }
+ { // positive
+ std::string v = "1,234,567.89";
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 123456789);
+ }
+ { // negative
+ std::string v = "-1,234,567.89";
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -123456789);
+ }
+ { // negative
+ std::string v = "-1234567.89";
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -123456789);
+ }
+ { // zero, showbase
+ std::string v = "CNY 0.00";
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 0);
+ }
+ { // zero, showbase
+ std::string v = "CNY 0.00";
+ showbase(ios);
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 0);
+ noshowbase(ios);
+ }
+ { // negative one, showbase
+ std::string v = "CNY -0.01";
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -1);
+ }
+ { // negative one, showbase
+ std::string v = "CNY -0.01";
+ showbase(ios);
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -1);
+ noshowbase(ios);
+ }
+ { // positive, showbase
+ std::string v = "CNY 1,234,567.89";
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 123456789);
+ }
+ { // positive, showbase
+ std::string v = "CNY 1,234,567.89";
+ showbase(ios);
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 123456789);
+ noshowbase(ios);
+ }
+ { // negative, showbase
+ std::string v = "CNY -1,234,567.89";
+ showbase(ios);
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -123456789);
+ noshowbase(ios);
+ }
+ { // negative, showbase
+ std::string v = "\xEF\xBF\xA5""-1,234,567.89";
+ showbase(ios);
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + 0);
+ assert(err == std::ios_base::failbit);
+ noshowbase(ios);
+ }
+ { // negative, showbase
+ std::string v = "\xEF\xBF\xA5""-1,234,567.89";
+ typedef input_iterator<const char*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + 0);
+ assert(err == std::ios_base::failbit);
+ }
+ }
+ {
+ const my_facetw f(1);
+ // wchar_t, national
+ { // zero
+ std::wstring v = L"0.00";
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 0);
+ }
+ { // negative one
+ std::wstring v = L"-0.01";
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -1);
+ }
+ { // positive
+ std::wstring v = L"1,234,567.89";
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 123456789);
+ }
+ { // negative
+ std::wstring v = L"-1,234,567.89";
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -123456789);
+ }
+ { // negative
+ std::wstring v = L"-1234567.89";
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -123456789);
+ }
+ { // zero, showbase
+ std::wstring v = L"\xFFE5""0.00";
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 0);
+ }
+ { // zero, showbase
+ std::wstring v = L"\xFFE5""0.00";
+ showbase(ios);
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 0);
+ noshowbase(ios);
+ }
+ { // negative one, showbase
+ std::wstring v = L"\xFFE5""-0.01";
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -1);
+ }
+ { // negative one, showbase
+ std::wstring v = L"\xFFE5""-0.01";
+ showbase(ios);
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -1);
+ noshowbase(ios);
+ }
+ { // positive, showbase
+ std::wstring v = L"\xFFE5""1,234,567.89";
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 123456789);
+ }
+ { // positive, showbase
+ std::wstring v = L"\xFFE5""1,234,567.89";
+ showbase(ios);
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 123456789);
+ noshowbase(ios);
+ }
+ { // negative, showbase
+ std::wstring v = L"\xFFE5""-1,234,567.89";
+ showbase(ios);
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -123456789);
+ noshowbase(ios);
+ }
+ { // negative, showbase
+ std::wstring v = L"CNY -1,234,567.89";
+ showbase(ios);
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + 0);
+ assert(err == std::ios_base::failbit);
+ noshowbase(ios);
+ }
+ { // negative, showbase
+ std::wstring v = L"CNY -1,234,567.89";
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + 0);
+ assert(err == std::ios_base::failbit);
+ }
+ }
+ {
+ const my_facetw f(1);
+ // wchar_t, international
+ { // zero
+ std::wstring v = L"0.00";
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 0);
+ }
+ { // negative one
+ std::wstring v = L"-0.01";
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -1);
+ }
+ { // positive
+ std::wstring v = L"1,234,567.89";
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 123456789);
+ }
+ { // negative
+ std::wstring v = L"-1,234,567.89";
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -123456789);
+ }
+ { // negative
+ std::wstring v = L"-1234567.89";
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -123456789);
+ }
+ { // zero, showbase
+ std::wstring v = L"CNY 0.00";
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 0);
+ }
+ { // zero, showbase
+ std::wstring v = L"CNY 0.00";
+ showbase(ios);
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 0);
+ noshowbase(ios);
+ }
+ { // negative one, showbase
+ std::wstring v = L"CNY -0.01";
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -1);
+ }
+ { // negative one, showbase
+ std::wstring v = L"CNY -0.01";
+ showbase(ios);
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -1);
+ noshowbase(ios);
+ }
+ { // positive, showbase
+ std::wstring v = L"CNY 1,234,567.89";
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 123456789);
+ }
+ { // positive, showbase
+ std::wstring v = L"CNY 1,234,567.89";
+ showbase(ios);
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == 123456789);
+ noshowbase(ios);
+ }
+ { // negative, showbase
+ std::wstring v = L"CNY -1,234,567.89";
+ showbase(ios);
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == -123456789);
+ noshowbase(ios);
+ }
+ { // negative, showbase
+ std::wstring v = L"\xFFE5""-1,234,567.89";
+ showbase(ios);
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + 0);
+ assert(err == std::ios_base::failbit);
+ noshowbase(ios);
+ }
+ { // negative, showbase
+ std::wstring v = L"\xFFE5""-1,234,567.89";
+ typedef input_iterator<const wchar_t*> I;
+ long double ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + 0);
+ assert(err == std::ios_base::failbit);
+ }
+ }
+}
diff --git a/test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_string_en_US.pass.cpp b/test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_string_en_US.pass.cpp
new file mode 100644
index 000000000000..b9099f4f84e3
--- /dev/null
+++ b/test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_string_en_US.pass.cpp
@@ -0,0 +1,731 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class money_get<charT, InputIterator>
+
+// iter_type get(iter_type b, iter_type e, bool intl, ios_base& iob,
+// ios_base::iostate& err, string_type& v) const;
+
+// REQUIRES: locale.en_US.UTF-8
+
+#include <locale>
+#include <ios>
+#include <streambuf>
+#include <cassert>
+#include "test_iterators.h"
+
+#include "platform_support.h" // locale name macros
+
+typedef std::money_get<char, input_iterator<const char*> > Fn;
+
+class my_facet
+ : public Fn
+{
+public:
+ explicit my_facet(std::size_t refs = 0)
+ : Fn(refs) {}
+};
+
+typedef std::money_get<wchar_t, input_iterator<const wchar_t*> > Fw;
+
+class my_facetw
+ : public Fw
+{
+public:
+ explicit my_facetw(std::size_t refs = 0)
+ : Fw(refs) {}
+};
+
+int main()
+{
+ std::ios ios(0);
+ std::string loc_name(LOCALE_en_US_UTF_8);
+ ios.imbue(std::locale(ios.getloc(),
+ new std::moneypunct_byname<char, false>(loc_name)));
+ ios.imbue(std::locale(ios.getloc(),
+ new std::moneypunct_byname<char, true>(loc_name)));
+ ios.imbue(std::locale(ios.getloc(),
+ new std::moneypunct_byname<wchar_t, false>(loc_name)));
+ ios.imbue(std::locale(ios.getloc(),
+ new std::moneypunct_byname<wchar_t, true>(loc_name)));
+ {
+ const my_facet f(1);
+ // char, national
+ { // zero
+ std::string v = "0.00";
+ typedef input_iterator<const char*> I;
+ std::string ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == "0");
+ }
+ { // negative one
+ std::string v = "-0.01";
+ typedef input_iterator<const char*> I;
+ std::string ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == "-1");
+ }
+ { // positive
+ std::string v = "1,234,567.89";
+ typedef input_iterator<const char*> I;
+ std::string ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == "123456789");
+ }
+ { // negative
+ std::string v = "-1,234,567.89";
+ typedef input_iterator<const char*> I;
+ std::string ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == "-123456789");
+ }
+ { // negative
+ std::string v = "-1234567.89";
+ typedef input_iterator<const char*> I;
+ std::string ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == "-123456789");
+ }
+ { // zero, showbase
+ std::string v = "$0.00";
+ typedef input_iterator<const char*> I;
+ std::string ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == "0");
+ }
+ { // zero, showbase
+ std::string v = "$0.00";
+ showbase(ios);
+ typedef input_iterator<const char*> I;
+ std::string ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == "0");
+ noshowbase(ios);
+ }
+ { // negative one, showbase
+ std::string v = "-$0.01";
+ typedef input_iterator<const char*> I;
+ std::string ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == "-1");
+ }
+ { // negative one, showbase
+ std::string v = "-$0.01";
+ showbase(ios);
+ typedef input_iterator<const char*> I;
+ std::string ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == "-1");
+ noshowbase(ios);
+ }
+ { // positive, showbase
+ std::string v = "$1,234,567.89";
+ typedef input_iterator<const char*> I;
+ std::string ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == "123456789");
+ }
+ { // positive, showbase
+ std::string v = "$1,234,567.89";
+ showbase(ios);
+ typedef input_iterator<const char*> I;
+ std::string ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == "123456789");
+ noshowbase(ios);
+ }
+ { // negative, showbase
+ std::string v = "-$1,234,567.89";
+ showbase(ios);
+ typedef input_iterator<const char*> I;
+ std::string ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == "-123456789");
+ noshowbase(ios);
+ }
+ { // negative, showbase
+ std::string v = "-USD 1,234,567.89";
+ showbase(ios);
+ typedef input_iterator<const char*> I;
+ std::string ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + 1);
+ assert(err == std::ios_base::failbit);
+ assert(ex == "");
+ noshowbase(ios);
+ }
+ { // negative, showbase
+ std::string v = "-USD 1,234,567.89";
+ typedef input_iterator<const char*> I;
+ std::string ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + 1);
+ assert(err == std::ios_base::failbit);
+ assert(ex == "");
+ }
+ }
+ {
+ const my_facet f(1);
+ // char, international
+ { // zero
+ std::string v = "0.00";
+ typedef input_iterator<const char*> I;
+ std::string ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == "0");
+ }
+ { // negative one
+ std::string v = "-0.01";
+ typedef input_iterator<const char*> I;
+ std::string ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == "-1");
+ }
+ { // positive
+ std::string v = "1,234,567.89";
+ typedef input_iterator<const char*> I;
+ std::string ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == "123456789");
+ }
+ { // negative
+ std::string v = "-1,234,567.89";
+ typedef input_iterator<const char*> I;
+ std::string ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == "-123456789");
+ }
+ { // negative
+ std::string v = "-1234567.89";
+ typedef input_iterator<const char*> I;
+ std::string ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == "-123456789");
+ }
+ { // zero, showbase
+ std::string v = "USD 0.00";
+ typedef input_iterator<const char*> I;
+ std::string ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == "0");
+ }
+ { // zero, showbase
+ std::string v = "USD 0.00";
+ showbase(ios);
+ typedef input_iterator<const char*> I;
+ std::string ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == "0");
+ noshowbase(ios);
+ }
+ { // negative one, showbase
+ std::string v = "-USD 0.01";
+ typedef input_iterator<const char*> I;
+ std::string ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == "-1");
+ }
+ { // negative one, showbase
+ std::string v = "-USD 0.01";
+ showbase(ios);
+ typedef input_iterator<const char*> I;
+ std::string ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == "-1");
+ noshowbase(ios);
+ }
+ { // positive, showbase
+ std::string v = "USD 1,234,567.89";
+ typedef input_iterator<const char*> I;
+ std::string ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == "123456789");
+ }
+ { // positive, showbase
+ std::string v = "USD 1,234,567.89";
+ showbase(ios);
+ typedef input_iterator<const char*> I;
+ std::string ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == "123456789");
+ noshowbase(ios);
+ }
+ { // negative, showbase
+ std::string v = "-USD 1,234,567.89";
+ showbase(ios);
+ typedef input_iterator<const char*> I;
+ std::string ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == "-123456789");
+ noshowbase(ios);
+ }
+ { // negative, showbase
+ std::string v = "-$1,234,567.89";
+ showbase(ios);
+ typedef input_iterator<const char*> I;
+ std::string ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + 1);
+ assert(err == std::ios_base::failbit);
+ assert(ex == "");
+ noshowbase(ios);
+ }
+ { // negative, showbase
+ std::string v = "-$1,234,567.89";
+ typedef input_iterator<const char*> I;
+ std::string ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + 1);
+ assert(err == std::ios_base::failbit);
+ assert(ex == "");
+ }
+ }
+ {
+ const my_facetw f(1);
+ // wchar_t, national
+ { // zero
+ std::wstring v = L"0.00";
+ typedef input_iterator<const wchar_t*> I;
+ std::wstring ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == L"0");
+ }
+ { // negative one
+ std::wstring v = L"-0.01";
+ typedef input_iterator<const wchar_t*> I;
+ std::wstring ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == L"-1");
+ }
+ { // positive
+ std::wstring v = L"1,234,567.89";
+ typedef input_iterator<const wchar_t*> I;
+ std::wstring ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == L"123456789");
+ }
+ { // negative
+ std::wstring v = L"-1,234,567.89";
+ typedef input_iterator<const wchar_t*> I;
+ std::wstring ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == L"-123456789");
+ }
+ { // negative
+ std::wstring v = L"-1234567.89";
+ typedef input_iterator<const wchar_t*> I;
+ std::wstring ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == L"-123456789");
+ }
+ { // zero, showbase
+ std::wstring v = L"$0.00";
+ typedef input_iterator<const wchar_t*> I;
+ std::wstring ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == L"0");
+ }
+ { // zero, showbase
+ std::wstring v = L"$0.00";
+ showbase(ios);
+ typedef input_iterator<const wchar_t*> I;
+ std::wstring ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == L"0");
+ noshowbase(ios);
+ }
+ { // negative one, showbase
+ std::wstring v = L"-$0.01";
+ typedef input_iterator<const wchar_t*> I;
+ std::wstring ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == L"-1");
+ }
+ { // negative one, showbase
+ std::wstring v = L"-$0.01";
+ showbase(ios);
+ typedef input_iterator<const wchar_t*> I;
+ std::wstring ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == L"-1");
+ noshowbase(ios);
+ }
+ { // positive, showbase
+ std::wstring v = L"$1,234,567.89";
+ typedef input_iterator<const wchar_t*> I;
+ std::wstring ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == L"123456789");
+ }
+ { // positive, showbase
+ std::wstring v = L"$1,234,567.89";
+ showbase(ios);
+ typedef input_iterator<const wchar_t*> I;
+ std::wstring ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == L"123456789");
+ noshowbase(ios);
+ }
+ { // negative, showbase
+ std::wstring v = L"-$1,234,567.89";
+ showbase(ios);
+ typedef input_iterator<const wchar_t*> I;
+ std::wstring ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == L"-123456789");
+ noshowbase(ios);
+ }
+ { // negative, showbase
+ std::wstring v = L"-USD 1,234,567.89";
+ showbase(ios);
+ typedef input_iterator<const wchar_t*> I;
+ std::wstring ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + 1);
+ assert(err == std::ios_base::failbit);
+ assert(ex == L"");
+ noshowbase(ios);
+ }
+ { // negative, showbase
+ std::wstring v = L"-USD 1,234,567.89";
+ typedef input_iterator<const wchar_t*> I;
+ std::wstring ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ false, ios, err, ex);
+ assert(iter.base() == v.data() + 1);
+ assert(err == std::ios_base::failbit);
+ assert(ex == L"");
+ }
+ }
+ {
+ const my_facetw f(1);
+ // wchar_t, international
+ { // zero
+ std::wstring v = L"0.00";
+ typedef input_iterator<const wchar_t*> I;
+ std::wstring ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == L"0");
+ }
+ { // negative one
+ std::wstring v = L"-0.01";
+ typedef input_iterator<const wchar_t*> I;
+ std::wstring ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == L"-1");
+ }
+ { // positive
+ std::wstring v = L"1,234,567.89";
+ typedef input_iterator<const wchar_t*> I;
+ std::wstring ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == L"123456789");
+ }
+ { // negative
+ std::wstring v = L"-1,234,567.89";
+ typedef input_iterator<const wchar_t*> I;
+ std::wstring ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == L"-123456789");
+ }
+ { // negative
+ std::wstring v = L"-1234567.89";
+ typedef input_iterator<const wchar_t*> I;
+ std::wstring ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == L"-123456789");
+ }
+ { // zero, showbase
+ std::wstring v = L"USD 0.00";
+ typedef input_iterator<const wchar_t*> I;
+ std::wstring ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == L"0");
+ }
+ { // zero, showbase
+ std::wstring v = L"USD 0.00";
+ showbase(ios);
+ typedef input_iterator<const wchar_t*> I;
+ std::wstring ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == L"0");
+ noshowbase(ios);
+ }
+ { // negative one, showbase
+ std::wstring v = L"-USD 0.01";
+ typedef input_iterator<const wchar_t*> I;
+ std::wstring ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == L"-1");
+ }
+ { // negative one, showbase
+ std::wstring v = L"-USD 0.01";
+ showbase(ios);
+ typedef input_iterator<const wchar_t*> I;
+ std::wstring ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == L"-1");
+ noshowbase(ios);
+ }
+ { // positive, showbase
+ std::wstring v = L"USD 1,234,567.89";
+ typedef input_iterator<const wchar_t*> I;
+ std::wstring ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == L"123456789");
+ }
+ { // positive, showbase
+ std::wstring v = L"USD 1,234,567.89";
+ showbase(ios);
+ typedef input_iterator<const wchar_t*> I;
+ std::wstring ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == L"123456789");
+ noshowbase(ios);
+ }
+ { // negative, showbase
+ std::wstring v = L"-USD 1,234,567.89";
+ showbase(ios);
+ typedef input_iterator<const wchar_t*> I;
+ std::wstring ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + v.size());
+ assert(err == std::ios_base::eofbit);
+ assert(ex == L"-123456789");
+ noshowbase(ios);
+ }
+ { // negative, showbase
+ std::wstring v = L"-$1,234,567.89";
+ showbase(ios);
+ typedef input_iterator<const wchar_t*> I;
+ std::wstring ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + 1);
+ assert(err == std::ios_base::failbit);
+ assert(ex == L"");
+ noshowbase(ios);
+ }
+ { // negative, showbase
+ std::wstring v = L"-$1,234,567.89";
+ typedef input_iterator<const wchar_t*> I;
+ std::wstring ex;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ I iter = f.get(I(v.data()), I(v.data() + v.size()),
+ true, ios, err, ex);
+ assert(iter.base() == v.data() + 1);
+ assert(err == std::ios_base::failbit);
+ assert(ex == L"");
+ }
+ }
+}
diff --git a/test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.virtuals/tested_elsewhere.pass.cpp b/test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.virtuals/tested_elsewhere.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.virtuals/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/localization/locale.categories/category.monetary/locale.money.get/types.pass.cpp b/test/std/localization/locale.categories/category.monetary/locale.money.get/types.pass.cpp
new file mode 100644
index 000000000000..2e4fb3242f8a
--- /dev/null
+++ b/test/std/localization/locale.categories/category.monetary/locale.money.get/types.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class CharT, class InputIterator = istreambuf_iterator<CharT> >
+// class money_get
+// : public locale::facet
+// {
+// public:
+// typedef CharT char_type;
+// typedef InputIterator iter_type;
+// typedef basic_string<char_type> string_type;
+
+#include <locale>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_base_of<std::locale::facet, std::money_get<char> >::value), "");
+ static_assert((std::is_base_of<std::locale::facet, std::money_get<wchar_t> >::value), "");
+ static_assert((std::is_same<std::money_get<char>::char_type, char>::value), "");
+ static_assert((std::is_same<std::money_get<wchar_t>::char_type, wchar_t>::value), "");
+ static_assert((std::is_same<std::money_get<char>::iter_type, std::istreambuf_iterator<char> >::value), "");
+ static_assert((std::is_same<std::money_get<wchar_t>::iter_type, std::istreambuf_iterator<wchar_t> >::value), "");
+ static_assert((std::is_same<std::money_get<char>::string_type, std::string>::value), "");
+ static_assert((std::is_same<std::money_get<wchar_t>::string_type, std::wstring>::value), "");
+}
diff --git a/test/std/localization/locale.categories/category.monetary/locale.money.put/ctor.pass.cpp b/test/std/localization/locale.categories/category.monetary/locale.money.put/ctor.pass.cpp
new file mode 100644
index 000000000000..d0a0007baabe
--- /dev/null
+++ b/test/std/localization/locale.categories/category.monetary/locale.money.put/ctor.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class money_put<charT, OutputIterator>
+
+// explicit money_put(size_t refs = 0);
+
+#include <locale>
+#include <cassert>
+
+typedef std::money_put<char, char*> F;
+
+class my_facet
+ : public F
+{
+public:
+ static int count;
+
+ explicit my_facet(std::size_t refs = 0)
+ : F(refs) {++count;}
+
+ ~my_facet() {--count;}
+};
+
+int my_facet::count = 0;
+
+int main()
+{
+ {
+ std::locale l(std::locale::classic(), new my_facet);
+ assert(my_facet::count == 1);
+ }
+ assert(my_facet::count == 0);
+ {
+ my_facet f(1);
+ assert(my_facet::count == 1);
+ {
+ std::locale l(std::locale::classic(), &f);
+ assert(my_facet::count == 1);
+ }
+ assert(my_facet::count == 1);
+ }
+ assert(my_facet::count == 0);
+}
diff --git a/test/std/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_en_US.pass.cpp b/test/std/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_en_US.pass.cpp
new file mode 100644
index 000000000000..db193eabccd9
--- /dev/null
+++ b/test/std/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_en_US.pass.cpp
@@ -0,0 +1,494 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class money_put<charT, OutputIterator>
+
+// iter_type put(iter_type s, bool intl, ios_base& f, char_type fill,
+// long double units) const;
+
+// REQUIRES: locale.en_US.UTF-8
+
+#include <locale>
+#include <ios>
+#include <streambuf>
+#include <cassert>
+#include "test_iterators.h"
+
+#include "platform_support.h" // locale name macros
+
+typedef std::money_put<char, output_iterator<char*> > Fn;
+
+class my_facet
+ : public Fn
+{
+public:
+ explicit my_facet(std::size_t refs = 0)
+ : Fn(refs) {}
+};
+
+typedef std::money_put<wchar_t, output_iterator<wchar_t*> > Fw;
+
+class my_facetw
+ : public Fw
+{
+public:
+ explicit my_facetw(std::size_t refs = 0)
+ : Fw(refs) {}
+};
+
+int main()
+{
+ std::ios ios(0);
+ std::string loc_name(LOCALE_en_US_UTF_8);
+ ios.imbue(std::locale(ios.getloc(),
+ new std::moneypunct_byname<char, false>(loc_name)));
+ ios.imbue(std::locale(ios.getloc(),
+ new std::moneypunct_byname<char, true>(loc_name)));
+ ios.imbue(std::locale(ios.getloc(),
+ new std::moneypunct_byname<wchar_t, false>(loc_name)));
+ ios.imbue(std::locale(ios.getloc(),
+ new std::moneypunct_byname<wchar_t, true>(loc_name)));
+{
+ const my_facet f(1);
+ // char, national
+ { // zero
+ long double v = 0;
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ false, ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.00");
+ }
+ { // negative one
+ long double v = -1;
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ false, ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.01");
+ }
+ { // positive
+ long double v = 123456789;
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ false, ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1,234,567.89");
+ }
+ { // negative
+ long double v = -123456789;
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ false, ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-1,234,567.89");
+ }
+ { // zero, showbase
+ long double v = 0;
+ showbase(ios);
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ false, ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "$0.00");
+ }
+ { // negative one, showbase
+ long double v = -1;
+ showbase(ios);
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ false, ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-$0.01");
+ }
+ { // positive, showbase
+ long double v = 123456789;
+ showbase(ios);
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ false, ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "$1,234,567.89");
+ }
+ { // negative, showbase
+ long double v = -123456789;
+ showbase(ios);
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ false, ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-$1,234,567.89");
+ }
+ { // negative, showbase, left
+ long double v = -123456789;
+ showbase(ios);
+ ios.width(20);
+ left(ios);
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ false, ios, ' ', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-$1,234,567.89 ");
+ assert(ios.width() == 0);
+ }
+ { // negative, showbase, internal
+ long double v = -123456789;
+ showbase(ios);
+ ios.width(20);
+ internal(ios);
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ false, ios, ' ', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-$ 1,234,567.89");
+ assert(ios.width() == 0);
+ }
+ { // negative, showbase, right
+ long double v = -123456789;
+ showbase(ios);
+ ios.width(20);
+ right(ios);
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ false, ios, ' ', v);
+ std::string ex(str, iter.base());
+ assert(ex == " -$1,234,567.89");
+ assert(ios.width() == 0);
+ }
+
+ // char, international
+ noshowbase(ios);
+ ios.unsetf(std::ios_base::adjustfield);
+ { // zero
+ long double v = 0;
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ true, ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.00");
+ }
+ { // negative one
+ long double v = -1;
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ true, ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.01");
+ }
+ { // positive
+ long double v = 123456789;
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ true, ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1,234,567.89");
+ }
+ { // negative
+ long double v = -123456789;
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ true, ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-1,234,567.89");
+ }
+ { // zero, showbase
+ long double v = 0;
+ showbase(ios);
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ true, ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "USD 0.00");
+ }
+ { // negative one, showbase
+ long double v = -1;
+ showbase(ios);
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ true, ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-USD 0.01");
+ }
+ { // positive, showbase
+ long double v = 123456789;
+ showbase(ios);
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ true, ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "USD 1,234,567.89");
+ }
+ { // negative, showbase
+ long double v = -123456789;
+ showbase(ios);
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ true, ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-USD 1,234,567.89");
+ }
+ { // negative, showbase, left
+ long double v = -123456789;
+ showbase(ios);
+ ios.width(20);
+ left(ios);
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ true, ios, ' ', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-USD 1,234,567.89 ");
+ assert(ios.width() == 0);
+ }
+ { // negative, showbase, internal
+ long double v = -123456789;
+ showbase(ios);
+ ios.width(20);
+ internal(ios);
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ true, ios, ' ', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-USD 1,234,567.89");
+ assert(ios.width() == 0);
+ }
+ { // negative, showbase, right
+ long double v = -123456789;
+ showbase(ios);
+ ios.width(20);
+ right(ios);
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ true, ios, ' ', v);
+ std::string ex(str, iter.base());
+ assert(ex == " -USD 1,234,567.89");
+ assert(ios.width() == 0);
+ }
+}
+{
+
+ const my_facetw f(1);
+ // wchar_t, national
+ noshowbase(ios);
+ ios.unsetf(std::ios_base::adjustfield);
+ { // zero
+ long double v = 0;
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ false, ios, '*', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"0.00");
+ }
+ { // negative one
+ long double v = -1;
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ false, ios, '*', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"-0.01");
+ }
+ { // positive
+ long double v = 123456789;
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ false, ios, '*', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"1,234,567.89");
+ }
+ { // negative
+ long double v = -123456789;
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ false, ios, '*', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"-1,234,567.89");
+ }
+ { // zero, showbase
+ long double v = 0;
+ showbase(ios);
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ false, ios, '*', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"$0.00");
+ }
+ { // negative one, showbase
+ long double v = -1;
+ showbase(ios);
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ false, ios, '*', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"-$0.01");
+ }
+ { // positive, showbase
+ long double v = 123456789;
+ showbase(ios);
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ false, ios, '*', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"$1,234,567.89");
+ }
+ { // negative, showbase
+ long double v = -123456789;
+ showbase(ios);
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ false, ios, '*', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"-$1,234,567.89");
+ }
+ { // negative, showbase, left
+ long double v = -123456789;
+ showbase(ios);
+ ios.width(20);
+ left(ios);
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ false, ios, ' ', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"-$1,234,567.89 ");
+ assert(ios.width() == 0);
+ }
+ { // negative, showbase, internal
+ long double v = -123456789;
+ showbase(ios);
+ ios.width(20);
+ internal(ios);
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ false, ios, ' ', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"-$ 1,234,567.89");
+ assert(ios.width() == 0);
+ }
+ { // negative, showbase, right
+ long double v = -123456789;
+ showbase(ios);
+ ios.width(20);
+ right(ios);
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ false, ios, ' ', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L" -$1,234,567.89");
+ assert(ios.width() == 0);
+ }
+
+ // wchar_t, international
+ noshowbase(ios);
+ ios.unsetf(std::ios_base::adjustfield);
+ { // zero
+ long double v = 0;
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ true, ios, '*', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"0.00");
+ }
+ { // negative one
+ long double v = -1;
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ true, ios, '*', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"-0.01");
+ }
+ { // positive
+ long double v = 123456789;
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ true, ios, '*', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"1,234,567.89");
+ }
+ { // negative
+ long double v = -123456789;
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ true, ios, '*', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"-1,234,567.89");
+ }
+ { // zero, showbase
+ long double v = 0;
+ showbase(ios);
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ true, ios, '*', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"USD 0.00");
+ }
+ { // negative one, showbase
+ long double v = -1;
+ showbase(ios);
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ true, ios, '*', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"-USD 0.01");
+ }
+ { // positive, showbase
+ long double v = 123456789;
+ showbase(ios);
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ true, ios, '*', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"USD 1,234,567.89");
+ }
+ { // negative, showbase
+ long double v = -123456789;
+ showbase(ios);
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ true, ios, '*', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"-USD 1,234,567.89");
+ }
+ { // negative, showbase, left
+ long double v = -123456789;
+ showbase(ios);
+ ios.width(20);
+ left(ios);
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ true, ios, ' ', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"-USD 1,234,567.89 ");
+ assert(ios.width() == 0);
+ }
+ { // negative, showbase, internal
+ long double v = -123456789;
+ showbase(ios);
+ ios.width(20);
+ internal(ios);
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ true, ios, ' ', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"-USD 1,234,567.89");
+ assert(ios.width() == 0);
+ }
+ { // negative, showbase, right
+ long double v = -123456789;
+ showbase(ios);
+ ios.width(20);
+ right(ios);
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ true, ios, ' ', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L" -USD 1,234,567.89");
+ assert(ios.width() == 0);
+ }
+}
+}
diff --git a/test/std/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_fr_FR.pass.cpp b/test/std/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_fr_FR.pass.cpp
new file mode 100644
index 000000000000..8b620bca376d
--- /dev/null
+++ b/test/std/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_fr_FR.pass.cpp
@@ -0,0 +1,495 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// XFAIL: apple-darwin
+
+// REQUIRES: locale.fr_FR.UTF-8
+
+// <locale>
+
+// class money_put<charT, OutputIterator>
+
+// iter_type put(iter_type s, bool intl, ios_base& f, char_type fill,
+// long double units) const;
+
+#include <locale>
+#include <ios>
+#include <streambuf>
+#include <cassert>
+#include "test_iterators.h"
+
+#include "platform_support.h" // locale name macros
+
+typedef std::money_put<char, output_iterator<char*> > Fn;
+
+class my_facet
+ : public Fn
+{
+public:
+ explicit my_facet(std::size_t refs = 0)
+ : Fn(refs) {}
+};
+
+typedef std::money_put<wchar_t, output_iterator<wchar_t*> > Fw;
+
+class my_facetw
+ : public Fw
+{
+public:
+ explicit my_facetw(std::size_t refs = 0)
+ : Fw(refs) {}
+};
+
+int main()
+{
+ std::ios ios(0);
+ std::string loc_name(LOCALE_fr_FR_UTF_8);
+ ios.imbue(std::locale(ios.getloc(),
+ new std::moneypunct_byname<char, false>(loc_name)));
+ ios.imbue(std::locale(ios.getloc(),
+ new std::moneypunct_byname<char, true>(loc_name)));
+ ios.imbue(std::locale(ios.getloc(),
+ new std::moneypunct_byname<wchar_t, false>(loc_name)));
+ ios.imbue(std::locale(ios.getloc(),
+ new std::moneypunct_byname<wchar_t, true>(loc_name)));
+{
+ const my_facet f(1);
+ // char, national
+ { // zero
+ long double v = 0;
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ false, ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0,00");
+ }
+ { // negative one
+ long double v = -1;
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ false, ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0,01");
+ }
+ { // positive
+ long double v = 123456789;
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ false, ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1 234 567,89");
+ }
+ { // negative
+ long double v = -123456789;
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ false, ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-1 234 567,89");
+ }
+ { // zero, showbase
+ long double v = 0;
+ showbase(ios);
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ false, ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0,00 \u20ac");
+ }
+ { // negative one, showbase
+ long double v = -1;
+ showbase(ios);
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ false, ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0,01 \u20ac");
+ }
+ { // positive, showbase
+ long double v = 123456789;
+ showbase(ios);
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ false, ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1 234 567,89 \u20ac");
+ }
+ { // negative, showbase
+ long double v = -123456789;
+ showbase(ios);
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ false, ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-1 234 567,89 \u20ac");
+ }
+ { // negative, showbase, left
+ long double v = -123456789;
+ showbase(ios);
+ ios.width(20);
+ left(ios);
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ false, ios, ' ', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-1 234 567,89 \u20ac ");
+ assert(ios.width() == 0);
+ }
+ { // negative, showbase, internal
+ long double v = -123456789;
+ showbase(ios);
+ ios.width(20);
+ internal(ios);
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ false, ios, ' ', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-1 234 567,89 \u20ac");
+ assert(ios.width() == 0);
+ }
+ { // negative, showbase, right
+ long double v = -123456789;
+ showbase(ios);
+ ios.width(20);
+ right(ios);
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ false, ios, ' ', v);
+ std::string ex(str, iter.base());
+ assert(ex == " -1 234 567,89 \u20ac");
+ assert(ios.width() == 0);
+ }
+
+ // char, international
+ noshowbase(ios);
+ ios.unsetf(std::ios_base::adjustfield);
+ { // zero
+ long double v = 0;
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ true, ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0,00");
+ }
+ { // negative one
+ long double v = -1;
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ true, ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0,01");
+ }
+ { // positive
+ long double v = 123456789;
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ true, ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1 234 567,89");
+ }
+ { // negative
+ long double v = -123456789;
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ true, ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-1 234 567,89");
+ }
+ { // zero, showbase
+ long double v = 0;
+ showbase(ios);
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ true, ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0,00 EUR");
+ }
+ { // negative one, showbase
+ long double v = -1;
+ showbase(ios);
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ true, ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0,01 EUR");
+ }
+ { // positive, showbase
+ long double v = 123456789;
+ showbase(ios);
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ true, ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1 234 567,89 EUR");
+ }
+ { // negative, showbase
+ long double v = -123456789;
+ showbase(ios);
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ true, ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-1 234 567,89 EUR");
+ }
+ { // negative, showbase, left
+ long double v = -123456789;
+ showbase(ios);
+ ios.width(20);
+ left(ios);
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ true, ios, ' ', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-1 234 567,89 EUR ");
+ assert(ios.width() == 0);
+ }
+ { // negative, showbase, internal
+ long double v = -123456789;
+ showbase(ios);
+ ios.width(20);
+ internal(ios);
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ true, ios, ' ', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-1 234 567,89 EUR");
+ assert(ios.width() == 0);
+ }
+ { // negative, showbase, right
+ long double v = -123456789;
+ showbase(ios);
+ ios.width(20);
+ right(ios);
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ true, ios, ' ', v);
+ std::string ex(str, iter.base());
+ assert(ex == " -1 234 567,89 EUR");
+ assert(ios.width() == 0);
+ }
+}
+{
+ const my_facetw f(1);
+ // wchar_t, national
+ noshowbase(ios);
+ ios.unsetf(std::ios_base::adjustfield);
+ { // zero
+ long double v = 0;
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ false, ios, '*', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"0,00");
+ }
+ { // negative one
+ long double v = -1;
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ false, ios, '*', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"-0,01");
+ }
+ { // positive
+ long double v = 123456789;
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ false, ios, '*', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"1 234 567,89");
+ }
+ { // negative
+ long double v = -123456789;
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ false, ios, '*', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"-1 234 567,89");
+ }
+ { // zero, showbase
+ long double v = 0;
+ showbase(ios);
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ false, ios, '*', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"0,00 \u20ac");
+ }
+ { // negative one, showbase
+ long double v = -1;
+ showbase(ios);
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ false, ios, '*', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"-0,01 \u20ac");
+ }
+ { // positive, showbase
+ long double v = 123456789;
+ showbase(ios);
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ false, ios, '*', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"1 234 567,89 \u20ac");
+ }
+ { // negative, showbase
+ long double v = -123456789;
+ showbase(ios);
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ false, ios, '*', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"-1 234 567,89 \u20ac");
+ }
+ { // negative, showbase, left
+ long double v = -123456789;
+ showbase(ios);
+ ios.width(20);
+ left(ios);
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ false, ios, ' ', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"-1 234 567,89 \u20ac ");
+ assert(ios.width() == 0);
+ }
+ { // negative, showbase, internal
+ long double v = -123456789;
+ showbase(ios);
+ ios.width(20);
+ internal(ios);
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ false, ios, ' ', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"-1 234 567,89 \u20ac");
+ assert(ios.width() == 0);
+ }
+ { // negative, showbase, right
+ long double v = -123456789;
+ showbase(ios);
+ ios.width(20);
+ right(ios);
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ false, ios, ' ', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L" -1 234 567,89 \u20ac");
+ assert(ios.width() == 0);
+ }
+
+ // wchar_t, international
+ noshowbase(ios);
+ ios.unsetf(std::ios_base::adjustfield);
+ { // zero
+ long double v = 0;
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ true, ios, '*', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"0,00");
+ }
+ { // negative one
+ long double v = -1;
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ true, ios, '*', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"-0,01");
+ }
+ { // positive
+ long double v = 123456789;
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ true, ios, '*', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"1 234 567,89");
+ }
+ { // negative
+ long double v = -123456789;
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ true, ios, '*', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"-1 234 567,89");
+ }
+ { // zero, showbase
+ long double v = 0;
+ showbase(ios);
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ true, ios, '*', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"0,00 EUR");
+ }
+ { // negative one, showbase
+ long double v = -1;
+ showbase(ios);
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ true, ios, '*', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"-0,01 EUR");
+ }
+ { // positive, showbase
+ long double v = 123456789;
+ showbase(ios);
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ true, ios, '*', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"1 234 567,89 EUR");
+ }
+ { // negative, showbase
+ long double v = -123456789;
+ showbase(ios);
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ true, ios, '*', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"-1 234 567,89 EUR");
+ }
+ { // negative, showbase, left
+ long double v = -123456789;
+ showbase(ios);
+ ios.width(20);
+ left(ios);
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ true, ios, ' ', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"-1 234 567,89 EUR ");
+ assert(ios.width() == 0);
+ }
+ { // negative, showbase, internal
+ long double v = -123456789;
+ showbase(ios);
+ ios.width(20);
+ internal(ios);
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ true, ios, ' ', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"-1 234 567,89 EUR");
+ assert(ios.width() == 0);
+ }
+ { // negative, showbase, right
+ long double v = -123456789;
+ showbase(ios);
+ ios.width(20);
+ right(ios);
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ true, ios, ' ', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L" -1 234 567,89 EUR");
+ assert(ios.width() == 0);
+ }
+}
+}
diff --git a/test/std/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_ru_RU.pass.cpp b/test/std/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_ru_RU.pass.cpp
new file mode 100644
index 000000000000..54bfcfb5c88d
--- /dev/null
+++ b/test/std/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_ru_RU.pass.cpp
@@ -0,0 +1,501 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// XFAIL: apple-darwin
+
+// Failure related to GLIBC's use of U00A0 as mon_thousands_sep
+// and U002E as mon_decimal_point.
+// TODO: U00A0 should be investigated.
+// Possibly related to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=16006
+// XFAIL: linux
+
+// REQUIRES: locale.ru_RU.UTF-8
+
+// <locale>
+
+// class money_put<charT, OutputIterator>
+
+// iter_type put(iter_type s, bool intl, ios_base& f, char_type fill,
+// long double units) const;
+
+#include <locale>
+#include <ios>
+#include <streambuf>
+#include <cassert>
+#include "test_iterators.h"
+
+#include "platform_support.h" // locale name macros
+
+typedef std::money_put<char, output_iterator<char*> > Fn;
+
+class my_facet
+ : public Fn
+{
+public:
+ explicit my_facet(std::size_t refs = 0)
+ : Fn(refs) {}
+};
+
+typedef std::money_put<wchar_t, output_iterator<wchar_t*> > Fw;
+
+class my_facetw
+ : public Fw
+{
+public:
+ explicit my_facetw(std::size_t refs = 0)
+ : Fw(refs) {}
+};
+
+int main()
+{
+ std::ios ios(0);
+ std::string loc_name(LOCALE_ru_RU_UTF_8);
+ ios.imbue(std::locale(ios.getloc(),
+ new std::moneypunct_byname<char, false>(loc_name)));
+ ios.imbue(std::locale(ios.getloc(),
+ new std::moneypunct_byname<char, true>(loc_name)));
+ ios.imbue(std::locale(ios.getloc(),
+ new std::moneypunct_byname<wchar_t, false>(loc_name)));
+ ios.imbue(std::locale(ios.getloc(),
+ new std::moneypunct_byname<wchar_t, true>(loc_name)));
+{
+ const my_facet f(1);
+ // char, national
+ { // zero
+ long double v = 0;
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ false, ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0,00 ");
+ }
+ { // negative one
+ long double v = -1;
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ false, ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0,01 ");
+ }
+ { // positive
+ long double v = 123456789;
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ false, ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1 234 567,89 ");
+ }
+ { // negative
+ long double v = -123456789;
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ false, ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-1 234 567,89 ");
+ }
+ { // zero, showbase
+ long double v = 0;
+ showbase(ios);
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ false, ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0,00 \xD1\x80\xD1\x83\xD0\xB1"".");
+ }
+ { // negative one, showbase
+ long double v = -1;
+ showbase(ios);
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ false, ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0,01 \xD1\x80\xD1\x83\xD0\xB1"".");
+ }
+ { // positive, showbase
+ long double v = 123456789;
+ showbase(ios);
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ false, ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1 234 567,89 \xD1\x80\xD1\x83\xD0\xB1"".");
+ }
+ { // negative, showbase
+ long double v = -123456789;
+ showbase(ios);
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ false, ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-1 234 567,89 \xD1\x80\xD1\x83\xD0\xB1"".");
+ }
+ { // negative, showbase, left
+ long double v = -123456789;
+ showbase(ios);
+ ios.width(20);
+ left(ios);
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ false, ios, ' ', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-1 234 567,89 \xD1\x80\xD1\x83\xD0\xB1"".");
+ assert(ios.width() == 0);
+ }
+ { // negative, showbase, internal
+ long double v = -123456789;
+ showbase(ios);
+ ios.width(20);
+ internal(ios);
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ false, ios, ' ', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-1 234 567,89 \xD1\x80\xD1\x83\xD0\xB1"".");
+ assert(ios.width() == 0);
+ }
+ { // negative, showbase, right
+ long double v = -123456789;
+ showbase(ios);
+ ios.width(20);
+ right(ios);
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ false, ios, ' ', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-1 234 567,89 \xD1\x80\xD1\x83\xD0\xB1"".");
+ assert(ios.width() == 0);
+ }
+
+ // char, international
+ noshowbase(ios);
+ ios.unsetf(std::ios_base::adjustfield);
+ { // zero
+ long double v = 0;
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ true, ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0,00 ");
+ }
+ { // negative one
+ long double v = -1;
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ true, ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0,01 ");
+ }
+ { // positive
+ long double v = 123456789;
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ true, ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1 234 567,89 ");
+ }
+ { // negative
+ long double v = -123456789;
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ true, ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-1 234 567,89 ");
+ }
+ { // zero, showbase
+ long double v = 0;
+ showbase(ios);
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ true, ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0,00 RUB ");
+ }
+ { // negative one, showbase
+ long double v = -1;
+ showbase(ios);
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ true, ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0,01 RUB ");
+ }
+ { // positive, showbase
+ long double v = 123456789;
+ showbase(ios);
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ true, ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1 234 567,89 RUB ");
+ }
+ { // negative, showbase
+ long double v = -123456789;
+ showbase(ios);
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ true, ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-1 234 567,89 RUB ");
+ }
+ { // negative, showbase, left
+ long double v = -123456789;
+ showbase(ios);
+ ios.width(20);
+ left(ios);
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ true, ios, ' ', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-1 234 567,89 RUB ");
+ assert(ios.width() == 0);
+ }
+ { // negative, showbase, internal
+ long double v = -123456789;
+ showbase(ios);
+ ios.width(20);
+ internal(ios);
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ true, ios, ' ', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-1 234 567,89 RUB ");
+ assert(ios.width() == 0);
+ }
+ { // negative, showbase, right
+ long double v = -123456789;
+ showbase(ios);
+ ios.width(20);
+ right(ios);
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ true, ios, ' ', v);
+ std::string ex(str, iter.base());
+ assert(ex == " -1 234 567,89 RUB ");
+ assert(ios.width() == 0);
+ }
+}
+{
+ const my_facetw f(1);
+ // wchar_t, national
+ noshowbase(ios);
+ ios.unsetf(std::ios_base::adjustfield);
+ { // zero
+ long double v = 0;
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ false, ios, '*', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"0,00 ");
+ }
+ { // negative one
+ long double v = -1;
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ false, ios, '*', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"-0,01 ");
+ }
+ { // positive
+ long double v = 123456789;
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ false, ios, '*', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"1 234 567,89 ");
+ }
+ { // negative
+ long double v = -123456789;
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ false, ios, '*', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"-1 234 567,89 ");
+ }
+ { // zero, showbase
+ long double v = 0;
+ showbase(ios);
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ false, ios, '*', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"0,00 \x440\x443\x431"".");
+ }
+ { // negative one, showbase
+ long double v = -1;
+ showbase(ios);
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ false, ios, '*', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"-0,01 \x440\x443\x431"".");
+ }
+ { // positive, showbase
+ long double v = 123456789;
+ showbase(ios);
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ false, ios, '*', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"1 234 567,89 \x440\x443\x431"".");
+ }
+ { // negative, showbase
+ long double v = -123456789;
+ showbase(ios);
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ false, ios, '*', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"-1 234 567,89 \x440\x443\x431"".");
+ }
+ { // negative, showbase, left
+ long double v = -123456789;
+ showbase(ios);
+ ios.width(20);
+ left(ios);
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ false, ios, ' ', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"-1 234 567,89 \x440\x443\x431"". ");
+ assert(ios.width() == 0);
+ }
+ { // negative, showbase, internal
+ long double v = -123456789;
+ showbase(ios);
+ ios.width(20);
+ internal(ios);
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ false, ios, ' ', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"-1 234 567,89 \x440\x443\x431"".");
+ assert(ios.width() == 0);
+ }
+ { // negative, showbase, right
+ long double v = -123456789;
+ showbase(ios);
+ ios.width(20);
+ right(ios);
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ false, ios, ' ', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L" -1 234 567,89 \x440\x443\x431"".");
+ assert(ios.width() == 0);
+ }
+
+ // wchar_t, international
+ noshowbase(ios);
+ ios.unsetf(std::ios_base::adjustfield);
+ { // zero
+ long double v = 0;
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ true, ios, '*', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"0,00 ");
+ }
+ { // negative one
+ long double v = -1;
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ true, ios, '*', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"-0,01 ");
+ }
+ { // positive
+ long double v = 123456789;
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ true, ios, '*', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"1 234 567,89 ");
+ }
+ { // negative
+ long double v = -123456789;
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ true, ios, '*', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"-1 234 567,89 ");
+ }
+ { // zero, showbase
+ long double v = 0;
+ showbase(ios);
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ true, ios, '*', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"0,00 RUB ");
+ }
+ { // negative one, showbase
+ long double v = -1;
+ showbase(ios);
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ true, ios, '*', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"-0,01 RUB ");
+ }
+ { // positive, showbase
+ long double v = 123456789;
+ showbase(ios);
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ true, ios, '*', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"1 234 567,89 RUB ");
+ }
+ { // negative, showbase
+ long double v = -123456789;
+ showbase(ios);
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ true, ios, '*', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"-1 234 567,89 RUB ");
+ }
+ { // negative, showbase, left
+ long double v = -123456789;
+ showbase(ios);
+ ios.width(20);
+ left(ios);
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ true, ios, ' ', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"-1 234 567,89 RUB ");
+ assert(ios.width() == 0);
+ }
+ { // negative, showbase, internal
+ long double v = -123456789;
+ showbase(ios);
+ ios.width(20);
+ internal(ios);
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ true, ios, ' ', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"-1 234 567,89 RUB ");
+ assert(ios.width() == 0);
+ }
+ { // negative, showbase, right
+ long double v = -123456789;
+ showbase(ios);
+ ios.width(20);
+ right(ios);
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ true, ios, ' ', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L" -1 234 567,89 RUB ");
+ assert(ios.width() == 0);
+ }
+}
+}
diff --git a/test/std/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_zh_CN.pass.cpp b/test/std/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_zh_CN.pass.cpp
new file mode 100644
index 000000000000..633e1885e711
--- /dev/null
+++ b/test/std/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_zh_CN.pass.cpp
@@ -0,0 +1,496 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: locale.zh_CN.UTF-8
+
+// <locale>
+
+// class money_put<charT, OutputIterator>
+
+// iter_type put(iter_type s, bool intl, ios_base& f, char_type fill,
+// long double units) const;
+
+// TODO For zh_CN GLIBC puts the negative sign after the currency symbol.
+// XFAIL: linux-gnu
+
+#include <locale>
+#include <ios>
+#include <streambuf>
+#include <cassert>
+#include "test_iterators.h"
+
+#include "platform_support.h" // locale name macros
+
+typedef std::money_put<char, output_iterator<char*> > Fn;
+
+class my_facet
+ : public Fn
+{
+public:
+ explicit my_facet(std::size_t refs = 0)
+ : Fn(refs) {}
+};
+
+typedef std::money_put<wchar_t, output_iterator<wchar_t*> > Fw;
+
+class my_facetw
+ : public Fw
+{
+public:
+ explicit my_facetw(std::size_t refs = 0)
+ : Fw(refs) {}
+};
+
+int main()
+{
+ std::ios ios(0);
+ std::string loc_name(LOCALE_zh_CN_UTF_8);
+ ios.imbue(std::locale(ios.getloc(),
+ new std::moneypunct_byname<char, false>(loc_name)));
+ ios.imbue(std::locale(ios.getloc(),
+ new std::moneypunct_byname<char, true>(loc_name)));
+ ios.imbue(std::locale(ios.getloc(),
+ new std::moneypunct_byname<wchar_t, false>(loc_name)));
+ ios.imbue(std::locale(ios.getloc(),
+ new std::moneypunct_byname<wchar_t, true>(loc_name)));
+{
+ const my_facet f(1);
+ // char, national
+ { // zero
+ long double v = 0;
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ false, ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.00");
+ }
+ { // negative one
+ long double v = -1;
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ false, ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.01");
+ }
+ { // positive
+ long double v = 123456789;
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ false, ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1,234,567.89");
+ }
+ { // negative
+ long double v = -123456789;
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ false, ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-1,234,567.89");
+ }
+ { // zero, showbase
+ long double v = 0;
+ showbase(ios);
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ false, ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "\xEF\xBF\xA5""0.00");
+ }
+ { // negative one, showbase
+ long double v = -1;
+ showbase(ios);
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ false, ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "\xEF\xBF\xA5""-0.01");
+ }
+ { // positive, showbase
+ long double v = 123456789;
+ showbase(ios);
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ false, ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "\xEF\xBF\xA5""1,234,567.89");
+ }
+ { // negative, showbase
+ long double v = -123456789;
+ showbase(ios);
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ false, ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "\xEF\xBF\xA5""-1,234,567.89");
+ }
+ { // negative, showbase, left
+ long double v = -123456789;
+ showbase(ios);
+ ios.width(20);
+ left(ios);
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ false, ios, ' ', v);
+ std::string ex(str, iter.base());
+ assert(ex == "\xEF\xBF\xA5""-1,234,567.89 ");
+ assert(ios.width() == 0);
+ }
+ { // negative, showbase, internal
+ long double v = -123456789;
+ showbase(ios);
+ ios.width(20);
+ internal(ios);
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ false, ios, ' ', v);
+ std::string ex(str, iter.base());
+ assert(ex == "\xEF\xBF\xA5""- 1,234,567.89");
+ assert(ios.width() == 0);
+ }
+ { // negative, showbase, right
+ long double v = -123456789;
+ showbase(ios);
+ ios.width(20);
+ right(ios);
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ false, ios, ' ', v);
+ std::string ex(str, iter.base());
+ assert(ex == " \xEF\xBF\xA5""-1,234,567.89");
+ assert(ios.width() == 0);
+ }
+
+ // char, international
+ noshowbase(ios);
+ ios.unsetf(std::ios_base::adjustfield);
+ { // zero
+ long double v = 0;
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ true, ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.00");
+ }
+ { // negative one
+ long double v = -1;
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ true, ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.01");
+ }
+ { // positive
+ long double v = 123456789;
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ true, ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1,234,567.89");
+ }
+ { // negative
+ long double v = -123456789;
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ true, ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-1,234,567.89");
+ }
+ { // zero, showbase
+ long double v = 0;
+ showbase(ios);
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ true, ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "CNY 0.00");
+ }
+ { // negative one, showbase
+ long double v = -1;
+ showbase(ios);
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ true, ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "CNY -0.01");
+ }
+ { // positive, showbase
+ long double v = 123456789;
+ showbase(ios);
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ true, ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "CNY 1,234,567.89");
+ }
+ { // negative, showbase
+ long double v = -123456789;
+ showbase(ios);
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ true, ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "CNY -1,234,567.89");
+ }
+ { // negative, showbase, left
+ long double v = -123456789;
+ showbase(ios);
+ ios.width(20);
+ left(ios);
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ true, ios, ' ', v);
+ std::string ex(str, iter.base());
+ assert(ex == "CNY -1,234,567.89 ");
+ assert(ios.width() == 0);
+ }
+ { // negative, showbase, internal
+ long double v = -123456789;
+ showbase(ios);
+ ios.width(20);
+ internal(ios);
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ true, ios, ' ', v);
+ std::string ex(str, iter.base());
+ assert(ex == "CNY - 1,234,567.89");
+ assert(ios.width() == 0);
+ }
+ { // negative, showbase, right
+ long double v = -123456789;
+ showbase(ios);
+ ios.width(20);
+ right(ios);
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ true, ios, ' ', v);
+ std::string ex(str, iter.base());
+ assert(ex == " CNY -1,234,567.89");
+ assert(ios.width() == 0);
+ }
+}
+{
+ const my_facetw f(1);
+ // wchar_t, national
+ noshowbase(ios);
+ ios.unsetf(std::ios_base::adjustfield);
+ { // zero
+ long double v = 0;
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ false, ios, '*', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"0.00");
+ }
+ { // negative one
+ long double v = -1;
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ false, ios, '*', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"-0.01");
+ }
+ { // positive
+ long double v = 123456789;
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ false, ios, '*', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"1,234,567.89");
+ }
+ { // negative
+ long double v = -123456789;
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ false, ios, '*', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"-1,234,567.89");
+ }
+ { // zero, showbase
+ long double v = 0;
+ showbase(ios);
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ false, ios, '*', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"\xFFE5""0.00");
+ }
+ { // negative one, showbase
+ long double v = -1;
+ showbase(ios);
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ false, ios, '*', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"\xFFE5""-0.01");
+ }
+ { // positive, showbase
+ long double v = 123456789;
+ showbase(ios);
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ false, ios, '*', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"\xFFE5""1,234,567.89");
+ }
+ { // negative, showbase
+ long double v = -123456789;
+ showbase(ios);
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ false, ios, '*', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"\xFFE5""-1,234,567.89");
+ }
+ { // negative, showbase, left
+ long double v = -123456789;
+ showbase(ios);
+ ios.width(20);
+ left(ios);
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ false, ios, ' ', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"\xFFE5""-1,234,567.89 ");
+ assert(ios.width() == 0);
+ }
+ { // negative, showbase, internal
+ long double v = -123456789;
+ showbase(ios);
+ ios.width(20);
+ internal(ios);
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ false, ios, ' ', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"\xFFE5""- 1,234,567.89");
+ assert(ios.width() == 0);
+ }
+ { // negative, showbase, right
+ long double v = -123456789;
+ showbase(ios);
+ ios.width(20);
+ right(ios);
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ false, ios, ' ', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L" \xFFE5""-1,234,567.89");
+ assert(ios.width() == 0);
+ }
+
+ // wchar_t, international
+ noshowbase(ios);
+ ios.unsetf(std::ios_base::adjustfield);
+ { // zero
+ long double v = 0;
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ true, ios, '*', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"0.00");
+ }
+ { // negative one
+ long double v = -1;
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ true, ios, '*', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"-0.01");
+ }
+ { // positive
+ long double v = 123456789;
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ true, ios, '*', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"1,234,567.89");
+ }
+ { // negative
+ long double v = -123456789;
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ true, ios, '*', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"-1,234,567.89");
+ }
+ { // zero, showbase
+ long double v = 0;
+ showbase(ios);
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ true, ios, '*', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"CNY 0.00");
+ }
+ { // negative one, showbase
+ long double v = -1;
+ showbase(ios);
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ true, ios, '*', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"CNY -0.01");
+ }
+ { // positive, showbase
+ long double v = 123456789;
+ showbase(ios);
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ true, ios, '*', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"CNY 1,234,567.89");
+ }
+ { // negative, showbase
+ long double v = -123456789;
+ showbase(ios);
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ true, ios, '*', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"CNY -1,234,567.89");
+ }
+ { // negative, showbase, left
+ long double v = -123456789;
+ showbase(ios);
+ ios.width(20);
+ left(ios);
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ true, ios, ' ', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"CNY -1,234,567.89 ");
+ assert(ios.width() == 0);
+ }
+ { // negative, showbase, internal
+ long double v = -123456789;
+ showbase(ios);
+ ios.width(20);
+ internal(ios);
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ true, ios, ' ', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"CNY - 1,234,567.89");
+ assert(ios.width() == 0);
+ }
+ { // negative, showbase, right
+ long double v = -123456789;
+ showbase(ios);
+ ios.width(20);
+ right(ios);
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ true, ios, ' ', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L" CNY -1,234,567.89");
+ assert(ios.width() == 0);
+ }
+}
+}
diff --git a/test/std/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_string_en_US.pass.cpp b/test/std/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_string_en_US.pass.cpp
new file mode 100644
index 000000000000..659f948d61c8
--- /dev/null
+++ b/test/std/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_string_en_US.pass.cpp
@@ -0,0 +1,494 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class money_put<charT, OutputIterator>
+
+// iter_type put(iter_type s, bool intl, ios_base& f, char_type fill,
+// const string_type& units) const;
+
+// REQUIRES: locale.en_US.UTF-8
+
+#include <locale>
+#include <ios>
+#include <streambuf>
+#include <cassert>
+#include "test_iterators.h"
+
+#include "platform_support.h" // locale name macros
+
+typedef std::money_put<char, output_iterator<char*> > Fn;
+
+class my_facet
+ : public Fn
+{
+public:
+ explicit my_facet(std::size_t refs = 0)
+ : Fn(refs) {}
+};
+
+typedef std::money_put<wchar_t, output_iterator<wchar_t*> > Fw;
+
+class my_facetw
+ : public Fw
+{
+public:
+ explicit my_facetw(std::size_t refs = 0)
+ : Fw(refs) {}
+};
+
+int main()
+{
+ std::ios ios(0);
+ std::string loc_name(LOCALE_en_US_UTF_8);
+ ios.imbue(std::locale(ios.getloc(),
+ new std::moneypunct_byname<char, false>(loc_name)));
+ ios.imbue(std::locale(ios.getloc(),
+ new std::moneypunct_byname<char, true>(loc_name)));
+ ios.imbue(std::locale(ios.getloc(),
+ new std::moneypunct_byname<wchar_t, false>(loc_name)));
+ ios.imbue(std::locale(ios.getloc(),
+ new std::moneypunct_byname<wchar_t, true>(loc_name)));
+{
+ const my_facet f(1);
+ // char, national
+ { // zero
+ std::string v = "0";
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ false, ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.00");
+ }
+ { // negative one
+ std::string v = "-1";
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ false, ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.01");
+ }
+ { // positive
+ std::string v = "123456789";
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ false, ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1,234,567.89");
+ }
+ { // negative
+ std::string v = "-123456789";
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ false, ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-1,234,567.89");
+ }
+ { // zero, showbase
+ std::string v = "0";
+ showbase(ios);
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ false, ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "$0.00");
+ }
+ { // negative one, showbase
+ std::string v = "-1";
+ showbase(ios);
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ false, ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-$0.01");
+ }
+ { // positive, showbase
+ std::string v = "123456789";
+ showbase(ios);
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ false, ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "$1,234,567.89");
+ }
+ { // negative, showbase
+ std::string v = "-123456789";
+ showbase(ios);
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ false, ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-$1,234,567.89");
+ }
+ { // negative, showbase, left
+ std::string v = "-123456789";
+ showbase(ios);
+ ios.width(20);
+ left(ios);
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ false, ios, ' ', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-$1,234,567.89 ");
+ assert(ios.width() == 0);
+ }
+ { // negative, showbase, internal
+ std::string v = "-123456789";
+ showbase(ios);
+ ios.width(20);
+ internal(ios);
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ false, ios, ' ', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-$ 1,234,567.89");
+ assert(ios.width() == 0);
+ }
+ { // negative, showbase, right
+ std::string v = "-123456789";
+ showbase(ios);
+ ios.width(20);
+ right(ios);
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ false, ios, ' ', v);
+ std::string ex(str, iter.base());
+ assert(ex == " -$1,234,567.89");
+ assert(ios.width() == 0);
+ }
+
+ // char, international
+ noshowbase(ios);
+ ios.unsetf(std::ios_base::adjustfield);
+ { // zero
+ std::string v = "0";
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ true, ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.00");
+ }
+ { // negative one
+ std::string v = "-1";
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ true, ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.01");
+ }
+ { // positive
+ std::string v = "123456789";
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ true, ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1,234,567.89");
+ }
+ { // negative
+ std::string v = "-123456789";
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ true, ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-1,234,567.89");
+ }
+ { // zero, showbase
+ std::string v = "0";
+ showbase(ios);
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ true, ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "USD 0.00");
+ }
+ { // negative one, showbase
+ std::string v = "-1";
+ showbase(ios);
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ true, ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-USD 0.01");
+ }
+ { // positive, showbase
+ std::string v = "123456789";
+ showbase(ios);
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ true, ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "USD 1,234,567.89");
+ }
+ { // negative, showbase
+ std::string v = "-123456789";
+ showbase(ios);
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ true, ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-USD 1,234,567.89");
+ }
+ { // negative, showbase, left
+ std::string v = "-123456789";
+ showbase(ios);
+ ios.width(20);
+ left(ios);
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ true, ios, ' ', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-USD 1,234,567.89 ");
+ assert(ios.width() == 0);
+ }
+ { // negative, showbase, internal
+ std::string v = "-123456789";
+ showbase(ios);
+ ios.width(20);
+ internal(ios);
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ true, ios, ' ', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-USD 1,234,567.89");
+ assert(ios.width() == 0);
+ }
+ { // negative, showbase, right
+ std::string v = "-123456789";
+ showbase(ios);
+ ios.width(20);
+ right(ios);
+ char str[100];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+ true, ios, ' ', v);
+ std::string ex(str, iter.base());
+ assert(ex == " -USD 1,234,567.89");
+ assert(ios.width() == 0);
+ }
+}
+{
+
+ const my_facetw f(1);
+ // wchar_t, national
+ noshowbase(ios);
+ ios.unsetf(std::ios_base::adjustfield);
+ { // zero
+ std::wstring v = L"0";
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ false, ios, '*', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"0.00");
+ }
+ { // negative one
+ std::wstring v = L"-1";
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ false, ios, '*', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"-0.01");
+ }
+ { // positive
+ std::wstring v = L"123456789";
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ false, ios, '*', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"1,234,567.89");
+ }
+ { // negative
+ std::wstring v = L"-123456789";
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ false, ios, '*', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"-1,234,567.89");
+ }
+ { // zero, showbase
+ std::wstring v = L"0";
+ showbase(ios);
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ false, ios, '*', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"$0.00");
+ }
+ { // negative one, showbase
+ std::wstring v = L"-1";
+ showbase(ios);
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ false, ios, '*', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"-$0.01");
+ }
+ { // positive, showbase
+ std::wstring v = L"123456789";
+ showbase(ios);
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ false, ios, '*', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"$1,234,567.89");
+ }
+ { // negative, showbase
+ std::wstring v = L"-123456789";
+ showbase(ios);
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ false, ios, '*', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"-$1,234,567.89");
+ }
+ { // negative, showbase, left
+ std::wstring v = L"-123456789";
+ showbase(ios);
+ ios.width(20);
+ left(ios);
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ false, ios, ' ', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"-$1,234,567.89 ");
+ assert(ios.width() == 0);
+ }
+ { // negative, showbase, internal
+ std::wstring v = L"-123456789";
+ showbase(ios);
+ ios.width(20);
+ internal(ios);
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ false, ios, ' ', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"-$ 1,234,567.89");
+ assert(ios.width() == 0);
+ }
+ { // negative, showbase, right
+ std::wstring v = L"-123456789";
+ showbase(ios);
+ ios.width(20);
+ right(ios);
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ false, ios, ' ', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L" -$1,234,567.89");
+ assert(ios.width() == 0);
+ }
+
+ // wchar_t, international
+ noshowbase(ios);
+ ios.unsetf(std::ios_base::adjustfield);
+ { // zero
+ std::wstring v = L"0";
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ true, ios, '*', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"0.00");
+ }
+ { // negative one
+ std::wstring v = L"-1";
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ true, ios, '*', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"-0.01");
+ }
+ { // positive
+ std::wstring v = L"123456789";
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ true, ios, '*', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"1,234,567.89");
+ }
+ { // negative
+ std::wstring v = L"-123456789";
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ true, ios, '*', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"-1,234,567.89");
+ }
+ { // zero, showbase
+ std::wstring v = L"0";
+ showbase(ios);
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ true, ios, '*', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"USD 0.00");
+ }
+ { // negative one, showbase
+ std::wstring v = L"-1";
+ showbase(ios);
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ true, ios, '*', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"-USD 0.01");
+ }
+ { // positive, showbase
+ std::wstring v = L"123456789";
+ showbase(ios);
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ true, ios, '*', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"USD 1,234,567.89");
+ }
+ { // negative, showbase
+ std::wstring v = L"-123456789";
+ showbase(ios);
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ true, ios, '*', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"-USD 1,234,567.89");
+ }
+ { // negative, showbase, left
+ std::wstring v = L"-123456789";
+ showbase(ios);
+ ios.width(20);
+ left(ios);
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ true, ios, ' ', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"-USD 1,234,567.89 ");
+ assert(ios.width() == 0);
+ }
+ { // negative, showbase, internal
+ std::wstring v = L"-123456789";
+ showbase(ios);
+ ios.width(20);
+ internal(ios);
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ true, ios, ' ', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L"-USD 1,234,567.89");
+ assert(ios.width() == 0);
+ }
+ { // negative, showbase, right
+ std::wstring v = L"-123456789";
+ showbase(ios);
+ ios.width(20);
+ right(ios);
+ wchar_t str[100];
+ output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+ true, ios, ' ', v);
+ std::wstring ex(str, iter.base());
+ assert(ex == L" -USD 1,234,567.89");
+ assert(ios.width() == 0);
+ }
+}
+}
diff --git a/test/std/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.virtuals/tested_elsewhere.pass.cpp b/test/std/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.virtuals/tested_elsewhere.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.virtuals/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/localization/locale.categories/category.monetary/locale.money.put/types.pass.cpp b/test/std/localization/locale.categories/category.monetary/locale.money.put/types.pass.cpp
new file mode 100644
index 000000000000..44ff1073d744
--- /dev/null
+++ b/test/std/localization/locale.categories/category.monetary/locale.money.put/types.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class CharT, class OutputIterator = ostreambuf_iterator<CharT> >
+// class money_put
+// : public locale::facet
+// {
+// public:
+// typedef CharT char_type;
+// typedef OutputIterator iter_type;
+// typedef basic_string<char_type> string_type;
+
+#include <locale>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_base_of<std::locale::facet, std::money_put<char> >::value), "");
+ static_assert((std::is_base_of<std::locale::facet, std::money_put<wchar_t> >::value), "");
+ static_assert((std::is_same<std::money_put<char>::char_type, char>::value), "");
+ static_assert((std::is_same<std::money_put<wchar_t>::char_type, wchar_t>::value), "");
+ static_assert((std::is_same<std::money_put<char>::iter_type, std::ostreambuf_iterator<char> >::value), "");
+ static_assert((std::is_same<std::money_put<wchar_t>::iter_type, std::ostreambuf_iterator<wchar_t> >::value), "");
+ static_assert((std::is_same<std::money_put<char>::string_type, std::string>::value), "");
+ static_assert((std::is_same<std::money_put<wchar_t>::string_type, std::wstring>::value), "");
+}
diff --git a/test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/curr_symbol.pass.cpp b/test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/curr_symbol.pass.cpp
new file mode 100644
index 000000000000..6d23d6361f85
--- /dev/null
+++ b/test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/curr_symbol.pass.cpp
@@ -0,0 +1,147 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// XFAIL: apple-darwin
+
+// REQUIRES: locale.en_US.UTF-8
+// REQUIRES: locale.fr_FR.UTF-8
+// REQUIRES: locale.ru_RU.UTF-8
+// REQUIRES: locale.zh_CN.UTF-8
+
+// <locale>
+
+// class moneypunct_byname<charT, International>
+
+// string_type curr_symbol() const;
+
+#include <locale>
+#include <limits>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+class Fnf
+ : public std::moneypunct_byname<char, false>
+{
+public:
+ explicit Fnf(const std::string& nm, std::size_t refs = 0)
+ : std::moneypunct_byname<char, false>(nm, refs) {}
+};
+
+class Fnt
+ : public std::moneypunct_byname<char, true>
+{
+public:
+ explicit Fnt(const std::string& nm, std::size_t refs = 0)
+ : std::moneypunct_byname<char, true>(nm, refs) {}
+};
+
+class Fwf
+ : public std::moneypunct_byname<wchar_t, false>
+{
+public:
+ explicit Fwf(const std::string& nm, std::size_t refs = 0)
+ : std::moneypunct_byname<wchar_t, false>(nm, refs) {}
+};
+
+class Fwt
+ : public std::moneypunct_byname<wchar_t, true>
+{
+public:
+ explicit Fwt(const std::string& nm, std::size_t refs = 0)
+ : std::moneypunct_byname<wchar_t, true>(nm, refs) {}
+};
+
+int main()
+{
+ {
+ Fnf f("C", 1);
+ assert(f.curr_symbol() == std::string());
+ }
+ {
+ Fnt f("C", 1);
+ assert(f.curr_symbol() == std::string());
+ }
+ {
+ Fwf f("C", 1);
+ assert(f.curr_symbol() == std::wstring());
+ }
+ {
+ Fwt f("C", 1);
+ assert(f.curr_symbol() == std::wstring());
+ }
+
+ {
+ Fnf f(LOCALE_en_US_UTF_8, 1);
+ assert(f.curr_symbol() == "$");
+ }
+ {
+ Fnt f(LOCALE_en_US_UTF_8, 1);
+ assert(f.curr_symbol() == "USD ");
+ }
+ {
+ Fwf f(LOCALE_en_US_UTF_8, 1);
+ assert(f.curr_symbol() == L"$");
+ }
+ {
+ Fwt f(LOCALE_en_US_UTF_8, 1);
+ assert(f.curr_symbol() == L"USD ");
+ }
+
+ {
+ Fnf f(LOCALE_fr_FR_UTF_8, 1);
+ assert(f.curr_symbol() == " \u20ac");
+ }
+ {
+ Fnt f(LOCALE_fr_FR_UTF_8, 1);
+ assert(f.curr_symbol() == " EUR");
+ }
+ {
+ Fwf f(LOCALE_fr_FR_UTF_8, 1);
+ assert(f.curr_symbol() == L" \u20ac");
+ }
+ {
+ Fwt f(LOCALE_fr_FR_UTF_8, 1);
+ assert(f.curr_symbol() == L" EUR");
+ }
+
+ {
+ Fnf f(LOCALE_ru_RU_UTF_8, 1);
+ assert(f.curr_symbol() == " \xD1\x80\xD1\x83\xD0\xB1");
+ }
+ {
+ Fnt f(LOCALE_ru_RU_UTF_8, 1);
+ assert(f.curr_symbol() == " RUB");
+ }
+ {
+ Fwf f(LOCALE_ru_RU_UTF_8, 1);
+ assert(f.curr_symbol() == L" \x440\x443\x431");
+ }
+ {
+ Fwt f(LOCALE_ru_RU_UTF_8, 1);
+ assert(f.curr_symbol() == L" RUB");
+ }
+
+ {
+ Fnf f(LOCALE_zh_CN_UTF_8, 1);
+ assert(f.curr_symbol() == "\xEF\xBF\xA5");
+ }
+ {
+ Fnt f(LOCALE_zh_CN_UTF_8, 1);
+ assert(f.curr_symbol() == "CNY ");
+ }
+ {
+ Fwf f(LOCALE_zh_CN_UTF_8, 1);
+ assert(f.curr_symbol() == L"\xFFE5");
+ }
+ {
+ Fwt f(LOCALE_zh_CN_UTF_8, 1);
+ assert(f.curr_symbol() == L"CNY ");
+ }
+}
diff --git a/test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/decimal_point.pass.cpp b/test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/decimal_point.pass.cpp
new file mode 100644
index 000000000000..8270377f3ab9
--- /dev/null
+++ b/test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/decimal_point.pass.cpp
@@ -0,0 +1,148 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: locale.en_US.UTF-8
+// REQUIRES: locale.fr_FR.UTF-8
+// REQUIRES: locale.ru_RU.UTF-8
+// REQUIRES: locale.zh_CN.UTF-8
+
+// Russia uses ',' for the decimal separator. GLIBC returns '.'
+// XFAIL: linux
+
+// <locale>
+
+// class moneypunct_byname<charT, International>
+
+// charT decimal_point() const;
+
+#include <locale>
+#include <limits>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+class Fnf
+ : public std::moneypunct_byname<char, false>
+{
+public:
+ explicit Fnf(const std::string& nm, std::size_t refs = 0)
+ : std::moneypunct_byname<char, false>(nm, refs) {}
+};
+
+class Fnt
+ : public std::moneypunct_byname<char, true>
+{
+public:
+ explicit Fnt(const std::string& nm, std::size_t refs = 0)
+ : std::moneypunct_byname<char, true>(nm, refs) {}
+};
+
+class Fwf
+ : public std::moneypunct_byname<wchar_t, false>
+{
+public:
+ explicit Fwf(const std::string& nm, std::size_t refs = 0)
+ : std::moneypunct_byname<wchar_t, false>(nm, refs) {}
+};
+
+class Fwt
+ : public std::moneypunct_byname<wchar_t, true>
+{
+public:
+ explicit Fwt(const std::string& nm, std::size_t refs = 0)
+ : std::moneypunct_byname<wchar_t, true>(nm, refs) {}
+};
+
+int main()
+{
+ {
+ Fnf f("C", 1);
+ assert(f.decimal_point() == std::numeric_limits<char>::max());
+ }
+ {
+ Fnt f("C", 1);
+ assert(f.decimal_point() == std::numeric_limits<char>::max());
+ }
+ {
+ Fwf f("C", 1);
+ assert(f.decimal_point() == std::numeric_limits<wchar_t>::max());
+ }
+ {
+ Fwt f("C", 1);
+ assert(f.decimal_point() == std::numeric_limits<wchar_t>::max());
+ }
+
+ {
+ Fnf f(LOCALE_en_US_UTF_8, 1);
+ assert(f.decimal_point() == '.');
+ }
+ {
+ Fnt f(LOCALE_en_US_UTF_8, 1);
+ assert(f.decimal_point() == '.');
+ }
+ {
+ Fwf f(LOCALE_en_US_UTF_8, 1);
+ assert(f.decimal_point() == L'.');
+ }
+ {
+ Fwt f(LOCALE_en_US_UTF_8, 1);
+ assert(f.decimal_point() == L'.');
+ }
+
+ {
+ Fnf f(LOCALE_fr_FR_UTF_8, 1);
+ assert(f.decimal_point() == ',');
+ }
+ {
+ Fnt f(LOCALE_fr_FR_UTF_8, 1);
+ assert(f.decimal_point() == ',');
+ }
+ {
+ Fwf f(LOCALE_fr_FR_UTF_8, 1);
+ assert(f.decimal_point() == L',');
+ }
+ {
+ Fwt f(LOCALE_fr_FR_UTF_8, 1);
+ assert(f.decimal_point() == L',');
+ }
+
+ {
+ Fnf f(LOCALE_ru_RU_UTF_8, 1);
+ assert(f.decimal_point() == ',');
+ }
+ {
+ Fnt f(LOCALE_ru_RU_UTF_8, 1);
+ assert(f.decimal_point() == ',');
+ }
+ {
+ Fwf f(LOCALE_ru_RU_UTF_8, 1);
+ assert(f.decimal_point() == L',');
+ }
+ {
+ Fwt f(LOCALE_ru_RU_UTF_8, 1);
+ assert(f.decimal_point() == L',');
+ }
+
+ {
+ Fnf f(LOCALE_zh_CN_UTF_8, 1);
+ assert(f.decimal_point() == '.');
+ }
+ {
+ Fnt f(LOCALE_zh_CN_UTF_8, 1);
+ assert(f.decimal_point() == '.');
+ }
+ {
+ Fwf f(LOCALE_zh_CN_UTF_8, 1);
+ assert(f.decimal_point() == L'.');
+ }
+ {
+ Fwt f(LOCALE_zh_CN_UTF_8, 1);
+ assert(f.decimal_point() == L'.');
+ }
+}
diff --git a/test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/frac_digits.pass.cpp b/test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/frac_digits.pass.cpp
new file mode 100644
index 000000000000..724dc1e5c9e7
--- /dev/null
+++ b/test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/frac_digits.pass.cpp
@@ -0,0 +1,145 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// REQUIRES: locale.en_US.UTF-8
+// REQUIRES: locale.fr_FR.UTF-8
+// REQUIRES: locale.ru_RU.UTF-8
+// REQUIRES: locale.zh_CN.UTF-8
+
+// class moneypunct_byname<charT, International>
+
+// int frac_digits() const;
+
+#include <locale>
+#include <limits>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+class Fnf
+ : public std::moneypunct_byname<char, false>
+{
+public:
+ explicit Fnf(const std::string& nm, std::size_t refs = 0)
+ : std::moneypunct_byname<char, false>(nm, refs) {}
+};
+
+class Fnt
+ : public std::moneypunct_byname<char, true>
+{
+public:
+ explicit Fnt(const std::string& nm, std::size_t refs = 0)
+ : std::moneypunct_byname<char, true>(nm, refs) {}
+};
+
+class Fwf
+ : public std::moneypunct_byname<wchar_t, false>
+{
+public:
+ explicit Fwf(const std::string& nm, std::size_t refs = 0)
+ : std::moneypunct_byname<wchar_t, false>(nm, refs) {}
+};
+
+class Fwt
+ : public std::moneypunct_byname<wchar_t, true>
+{
+public:
+ explicit Fwt(const std::string& nm, std::size_t refs = 0)
+ : std::moneypunct_byname<wchar_t, true>(nm, refs) {}
+};
+
+int main()
+{
+ {
+ Fnf f("C", 1);
+ assert(f.frac_digits() == 0);
+ }
+ {
+ Fnt f("C", 1);
+ assert(f.frac_digits() == 0);
+ }
+ {
+ Fwf f("C", 1);
+ assert(f.frac_digits() == 0);
+ }
+ {
+ Fwt f("C", 1);
+ assert(f.frac_digits() == 0);
+ }
+
+ {
+ Fnf f(LOCALE_en_US_UTF_8, 1);
+ assert(f.frac_digits() == 2);
+ }
+ {
+ Fnt f(LOCALE_en_US_UTF_8, 1);
+ assert(f.frac_digits() == 2);
+ }
+ {
+ Fwf f(LOCALE_en_US_UTF_8, 1);
+ assert(f.frac_digits() == 2);
+ }
+ {
+ Fwt f(LOCALE_en_US_UTF_8, 1);
+ assert(f.frac_digits() == 2);
+ }
+
+ {
+ Fnf f(LOCALE_fr_FR_UTF_8, 1);
+ assert(f.frac_digits() == 2);
+ }
+ {
+ Fnt f(LOCALE_fr_FR_UTF_8, 1);
+ assert(f.frac_digits() == 2);
+ }
+ {
+ Fwf f(LOCALE_fr_FR_UTF_8, 1);
+ assert(f.frac_digits() == 2);
+ }
+ {
+ Fwt f(LOCALE_fr_FR_UTF_8, 1);
+ assert(f.frac_digits() == 2);
+ }
+
+ {
+ Fnf f(LOCALE_ru_RU_UTF_8, 1);
+ assert(f.frac_digits() == 2);
+ }
+ {
+ Fnt f(LOCALE_ru_RU_UTF_8, 1);
+ assert(f.frac_digits() == 2);
+ }
+ {
+ Fwf f(LOCALE_ru_RU_UTF_8, 1);
+ assert(f.frac_digits() == 2);
+ }
+ {
+ Fwt f(LOCALE_ru_RU_UTF_8, 1);
+ assert(f.frac_digits() == 2);
+ }
+
+ {
+ Fnf f(LOCALE_zh_CN_UTF_8, 1);
+ assert(f.frac_digits() == 2);
+ }
+ {
+ Fnt f(LOCALE_zh_CN_UTF_8, 1);
+ assert(f.frac_digits() == 2);
+ }
+ {
+ Fwf f(LOCALE_zh_CN_UTF_8, 1);
+ assert(f.frac_digits() == 2);
+ }
+ {
+ Fwt f(LOCALE_zh_CN_UTF_8, 1);
+ assert(f.frac_digits() == 2);
+ }
+}
diff --git a/test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/grouping.pass.cpp b/test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/grouping.pass.cpp
new file mode 100644
index 000000000000..b0b9da0b6949
--- /dev/null
+++ b/test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/grouping.pass.cpp
@@ -0,0 +1,150 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// XFAIL: apple-darwin
+
+// REQUIRES: locale.en_US.UTF-8
+// REQUIRES: locale.fr_FR.UTF-8
+// REQUIRES: locale.ru_RU.UTF-8
+// REQUIRES: locale.zh_CN.UTF-8
+
+// <locale>
+
+// class moneypunct_byname<charT, International>
+
+// string grouping() const;
+
+#include <locale>
+#include <limits>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+class Fnf
+ : public std::moneypunct_byname<char, false>
+{
+public:
+ explicit Fnf(const std::string& nm, std::size_t refs = 0)
+ : std::moneypunct_byname<char, false>(nm, refs) {}
+};
+
+class Fnt
+ : public std::moneypunct_byname<char, true>
+{
+public:
+ explicit Fnt(const std::string& nm, std::size_t refs = 0)
+ : std::moneypunct_byname<char, true>(nm, refs) {}
+};
+
+class Fwf
+ : public std::moneypunct_byname<wchar_t, false>
+{
+public:
+ explicit Fwf(const std::string& nm, std::size_t refs = 0)
+ : std::moneypunct_byname<wchar_t, false>(nm, refs) {}
+};
+
+class Fwt
+ : public std::moneypunct_byname<wchar_t, true>
+{
+public:
+ explicit Fwt(const std::string& nm, std::size_t refs = 0)
+ : std::moneypunct_byname<wchar_t, true>(nm, refs) {}
+};
+
+int main()
+{
+ // Monetary grouping strings may be terminated with 0 or CHAR_MAX, defining
+ // how the grouping is repeated.
+ std::string s = std::string(1, CHAR_MAX);
+ {
+ Fnf f("C", 1);
+ assert(f.grouping() == s || f.grouping() == "");
+ }
+ {
+ Fnt f("C", 1);
+ assert(f.grouping() == s || f.grouping() == "");
+ }
+ {
+ Fwf f("C", 1);
+ assert(f.grouping() == s || f.grouping() == "");
+ }
+ {
+ Fwt f("C", 1);
+ assert(f.grouping() == s || f.grouping() == "");
+ }
+
+ {
+ Fnf f(LOCALE_en_US_UTF_8, 1);
+ assert(f.grouping() == "\3\3");
+ }
+ {
+ Fnt f(LOCALE_en_US_UTF_8, 1);
+ assert(f.grouping() == "\3\3");
+ }
+ {
+ Fwf f(LOCALE_en_US_UTF_8, 1);
+ assert(f.grouping() == "\3\3");
+ }
+ {
+ Fwt f(LOCALE_en_US_UTF_8, 1);
+ assert(f.grouping() == "\3\3");
+ }
+
+ {
+ Fnf f(LOCALE_fr_FR_UTF_8, 1);
+ assert(f.grouping() == "\3");
+ }
+ {
+ Fnt f(LOCALE_fr_FR_UTF_8, 1);
+ assert(f.grouping() == "\3");
+ }
+ {
+ Fwf f(LOCALE_fr_FR_UTF_8, 1);
+ assert(f.grouping() == "\3");
+ }
+ {
+ Fwt f(LOCALE_fr_FR_UTF_8, 1);
+ assert(f.grouping() == "\3");
+ }
+
+ {
+ Fnf f(LOCALE_ru_RU_UTF_8, 1);
+ assert(f.grouping() == "\3\3");
+ }
+ {
+ Fnt f(LOCALE_ru_RU_UTF_8, 1);
+ assert(f.grouping() == "\3\3");
+ }
+ {
+ Fwf f(LOCALE_ru_RU_UTF_8, 1);
+ assert(f.grouping() == "\3\3");
+ }
+ {
+ Fwt f(LOCALE_ru_RU_UTF_8, 1);
+ assert(f.grouping() == "\3\3");
+ }
+
+ {
+ Fnf f(LOCALE_zh_CN_UTF_8, 1);
+ assert(f.grouping() == "\3");
+ }
+ {
+ Fnt f(LOCALE_zh_CN_UTF_8, 1);
+ assert(f.grouping() == "\3");
+ }
+ {
+ Fwf f(LOCALE_zh_CN_UTF_8, 1);
+ assert(f.grouping() == "\3");
+ }
+ {
+ Fwt f(LOCALE_zh_CN_UTF_8, 1);
+ assert(f.grouping() == "\3");
+ }
+}
diff --git a/test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/neg_format.pass.cpp b/test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/neg_format.pass.cpp
new file mode 100644
index 000000000000..3fe9faf847f4
--- /dev/null
+++ b/test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/neg_format.pass.cpp
@@ -0,0 +1,227 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// XFAIL: apple-darwin
+
+// REQUIRES: locale.en_US.UTF-8
+// REQUIRES: locale.fr_FR.UTF-8
+// REQUIRES: locale.ru_RU.UTF-8
+// REQUIRES: locale.zh_CN.UTF-8
+
+// <locale>
+
+// class moneypunct_byname<charT, International>
+
+// pattern neg_format() const;
+
+#include <locale>
+#include <limits>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+class Fnf
+ : public std::moneypunct_byname<char, false>
+{
+public:
+ explicit Fnf(const std::string& nm, std::size_t refs = 0)
+ : std::moneypunct_byname<char, false>(nm, refs) {}
+};
+
+class Fnt
+ : public std::moneypunct_byname<char, true>
+{
+public:
+ explicit Fnt(const std::string& nm, std::size_t refs = 0)
+ : std::moneypunct_byname<char, true>(nm, refs) {}
+};
+
+class Fwf
+ : public std::moneypunct_byname<wchar_t, false>
+{
+public:
+ explicit Fwf(const std::string& nm, std::size_t refs = 0)
+ : std::moneypunct_byname<wchar_t, false>(nm, refs) {}
+};
+
+class Fwt
+ : public std::moneypunct_byname<wchar_t, true>
+{
+public:
+ explicit Fwt(const std::string& nm, std::size_t refs = 0)
+ : std::moneypunct_byname<wchar_t, true>(nm, refs) {}
+};
+
+int main()
+{
+ {
+ Fnf f("C", 1);
+ std::money_base::pattern p = f.neg_format();
+ assert(p.field[0] == std::money_base::symbol);
+ assert(p.field[1] == std::money_base::sign);
+ assert(p.field[2] == std::money_base::none);
+ assert(p.field[3] == std::money_base::value);
+ }
+ {
+ Fnt f("C", 1);
+ std::money_base::pattern p = f.neg_format();
+ assert(p.field[0] == std::money_base::symbol);
+ assert(p.field[1] == std::money_base::sign);
+ assert(p.field[2] == std::money_base::none);
+ assert(p.field[3] == std::money_base::value);
+ }
+ {
+ Fwf f("C", 1);
+ std::money_base::pattern p = f.neg_format();
+ assert(p.field[0] == std::money_base::symbol);
+ assert(p.field[1] == std::money_base::sign);
+ assert(p.field[2] == std::money_base::none);
+ assert(p.field[3] == std::money_base::value);
+ }
+ {
+ Fwt f("C", 1);
+ std::money_base::pattern p = f.neg_format();
+ assert(p.field[0] == std::money_base::symbol);
+ assert(p.field[1] == std::money_base::sign);
+ assert(p.field[2] == std::money_base::none);
+ assert(p.field[3] == std::money_base::value);
+ }
+
+ {
+ Fnf f(LOCALE_en_US_UTF_8, 1);
+ std::money_base::pattern p = f.neg_format();
+ assert(p.field[0] == std::money_base::sign);
+ assert(p.field[1] == std::money_base::symbol);
+ assert(p.field[2] == std::money_base::none);
+ assert(p.field[3] == std::money_base::value);
+ }
+ {
+ Fnt f(LOCALE_en_US_UTF_8, 1);
+ std::money_base::pattern p = f.neg_format();
+ assert(p.field[0] == std::money_base::sign);
+ assert(p.field[1] == std::money_base::symbol);
+ assert(p.field[2] == std::money_base::none);
+ assert(p.field[3] == std::money_base::value);
+ }
+ {
+ Fwf f(LOCALE_en_US_UTF_8, 1);
+ std::money_base::pattern p = f.neg_format();
+ assert(p.field[0] == std::money_base::sign);
+ assert(p.field[1] == std::money_base::symbol);
+ assert(p.field[2] == std::money_base::none);
+ assert(p.field[3] == std::money_base::value);
+ }
+ {
+ Fwt f(LOCALE_en_US_UTF_8, 1);
+ std::money_base::pattern p = f.neg_format();
+ assert(p.field[0] == std::money_base::sign);
+ assert(p.field[1] == std::money_base::symbol);
+ assert(p.field[2] == std::money_base::none);
+ assert(p.field[3] == std::money_base::value);
+ }
+
+ {
+ Fnf f(LOCALE_fr_FR_UTF_8, 1);
+ std::money_base::pattern p = f.neg_format();
+ assert(p.field[0] == std::money_base::sign);
+ assert(p.field[1] == std::money_base::value);
+ assert(p.field[2] == std::money_base::none);
+ assert(p.field[3] == std::money_base::symbol);
+ }
+ {
+ Fnt f(LOCALE_fr_FR_UTF_8, 1);
+ std::money_base::pattern p = f.neg_format();
+ assert(p.field[0] == std::money_base::sign);
+ assert(p.field[1] == std::money_base::value);
+ assert(p.field[2] == std::money_base::none);
+ assert(p.field[3] == std::money_base::symbol);
+ }
+ {
+ Fwf f(LOCALE_fr_FR_UTF_8, 1);
+ std::money_base::pattern p = f.neg_format();
+ assert(p.field[0] == std::money_base::sign);
+ assert(p.field[1] == std::money_base::value);
+ assert(p.field[2] == std::money_base::none);
+ assert(p.field[3] == std::money_base::symbol);
+ }
+ {
+ Fwt f(LOCALE_fr_FR_UTF_8, 1);
+ std::money_base::pattern p = f.neg_format();
+ assert(p.field[0] == std::money_base::sign);
+ assert(p.field[1] == std::money_base::value);
+ assert(p.field[2] == std::money_base::none);
+ assert(p.field[3] == std::money_base::symbol);
+ }
+
+ {
+ Fnf f(LOCALE_ru_RU_UTF_8, 1);
+ std::money_base::pattern p = f.neg_format();
+ assert(p.field[0] == std::money_base::sign);
+ assert(p.field[1] == std::money_base::value);
+ assert(p.field[2] == std::money_base::none);
+ assert(p.field[3] == std::money_base::symbol);
+ }
+ {
+ Fnt f(LOCALE_ru_RU_UTF_8, 1);
+ std::money_base::pattern p = f.neg_format();
+ assert(p.field[0] == std::money_base::sign);
+ assert(p.field[1] == std::money_base::value);
+ assert(p.field[2] == std::money_base::none);
+ assert(p.field[3] == std::money_base::symbol);
+ }
+ {
+ Fwf f(LOCALE_ru_RU_UTF_8, 1);
+ std::money_base::pattern p = f.neg_format();
+ assert(p.field[0] == std::money_base::sign);
+ assert(p.field[1] == std::money_base::value);
+ assert(p.field[2] == std::money_base::none);
+ assert(p.field[3] == std::money_base::symbol);
+ }
+ {
+ Fwt f(LOCALE_ru_RU_UTF_8, 1);
+ std::money_base::pattern p = f.neg_format();
+ assert(p.field[0] == std::money_base::sign);
+ assert(p.field[1] == std::money_base::value);
+ assert(p.field[2] == std::money_base::none);
+ assert(p.field[3] == std::money_base::symbol);
+ }
+
+ {
+ Fnf f(LOCALE_zh_CN_UTF_8, 1);
+ std::money_base::pattern p = f.neg_format();
+ assert(p.field[0] == std::money_base::symbol);
+ assert(p.field[1] == std::money_base::sign);
+ assert(p.field[2] == std::money_base::none);
+ assert(p.field[3] == std::money_base::value);
+ }
+ {
+ Fnt f(LOCALE_zh_CN_UTF_8, 1);
+ std::money_base::pattern p = f.neg_format();
+ assert(p.field[0] == std::money_base::sign);
+ assert(p.field[1] == std::money_base::symbol);
+ assert(p.field[2] == std::money_base::none);
+ assert(p.field[3] == std::money_base::value);
+ }
+ {
+ Fwf f(LOCALE_zh_CN_UTF_8, 1);
+ std::money_base::pattern p = f.neg_format();
+ assert(p.field[0] == std::money_base::symbol);
+ assert(p.field[1] == std::money_base::sign);
+ assert(p.field[2] == std::money_base::none);
+ assert(p.field[3] == std::money_base::value);
+ }
+ {
+ Fwt f(LOCALE_zh_CN_UTF_8, 1);
+ std::money_base::pattern p = f.neg_format();
+ assert(p.field[0] == std::money_base::sign);
+ assert(p.field[1] == std::money_base::symbol);
+ assert(p.field[2] == std::money_base::none);
+ assert(p.field[3] == std::money_base::value);
+ }
+}
diff --git a/test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/negative_sign.pass.cpp b/test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/negative_sign.pass.cpp
new file mode 100644
index 000000000000..66c8c64243e1
--- /dev/null
+++ b/test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/negative_sign.pass.cpp
@@ -0,0 +1,145 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: locale.en_US.UTF-8
+// REQUIRES: locale.fr_FR.UTF-8
+// REQUIRES: locale.ru_RU.UTF-8
+// REQUIRES: locale.zh_CN.UTF-8
+
+// <locale>
+
+// class moneypunct_byname<charT, International>
+
+// string_type negative_sign() const;
+
+#include <locale>
+#include <limits>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+class Fnf
+ : public std::moneypunct_byname<char, false>
+{
+public:
+ explicit Fnf(const std::string& nm, std::size_t refs = 0)
+ : std::moneypunct_byname<char, false>(nm, refs) {}
+};
+
+class Fnt
+ : public std::moneypunct_byname<char, true>
+{
+public:
+ explicit Fnt(const std::string& nm, std::size_t refs = 0)
+ : std::moneypunct_byname<char, true>(nm, refs) {}
+};
+
+class Fwf
+ : public std::moneypunct_byname<wchar_t, false>
+{
+public:
+ explicit Fwf(const std::string& nm, std::size_t refs = 0)
+ : std::moneypunct_byname<wchar_t, false>(nm, refs) {}
+};
+
+class Fwt
+ : public std::moneypunct_byname<wchar_t, true>
+{
+public:
+ explicit Fwt(const std::string& nm, std::size_t refs = 0)
+ : std::moneypunct_byname<wchar_t, true>(nm, refs) {}
+};
+
+int main()
+{
+ {
+ Fnf f("C", 1);
+ assert(f.negative_sign() == std::string());
+ }
+ {
+ Fnt f("C", 1);
+ assert(f.negative_sign() == std::string());
+ }
+ {
+ Fwf f("C", 1);
+ assert(f.negative_sign() == std::wstring());
+ }
+ {
+ Fwt f("C", 1);
+ assert(f.negative_sign() == std::wstring());
+ }
+
+ {
+ Fnf f(LOCALE_en_US_UTF_8, 1);
+ assert(f.negative_sign() == "-");
+ }
+ {
+ Fnt f(LOCALE_en_US_UTF_8, 1);
+ assert(f.negative_sign() == "-");
+ }
+ {
+ Fwf f(LOCALE_en_US_UTF_8, 1);
+ assert(f.negative_sign() == L"-");
+ }
+ {
+ Fwt f(LOCALE_en_US_UTF_8, 1);
+ assert(f.negative_sign() == L"-");
+ }
+
+ {
+ Fnf f(LOCALE_fr_FR_UTF_8, 1);
+ assert(f.negative_sign() == "-");
+ }
+ {
+ Fnt f(LOCALE_fr_FR_UTF_8, 1);
+ assert(f.negative_sign() == "-");
+ }
+ {
+ Fwf f(LOCALE_fr_FR_UTF_8, 1);
+ assert(f.negative_sign() == L"-");
+ }
+ {
+ Fwt f(LOCALE_fr_FR_UTF_8, 1);
+ assert(f.negative_sign() == L"-");
+ }
+
+ {
+ Fnf f(LOCALE_ru_RU_UTF_8, 1);
+ assert(f.negative_sign() == "-");
+ }
+ {
+ Fnt f(LOCALE_ru_RU_UTF_8, 1);
+ assert(f.negative_sign() == "-");
+ }
+ {
+ Fwf f(LOCALE_ru_RU_UTF_8, 1);
+ assert(f.negative_sign() == L"-");
+ }
+ {
+ Fwt f(LOCALE_ru_RU_UTF_8, 1);
+ assert(f.negative_sign() == L"-");
+ }
+
+ {
+ Fnf f(LOCALE_zh_CN_UTF_8, 1);
+ assert(f.negative_sign() == "-");
+ }
+ {
+ Fnt f(LOCALE_zh_CN_UTF_8, 1);
+ assert(f.negative_sign() == "-");
+ }
+ {
+ Fwf f(LOCALE_zh_CN_UTF_8, 1);
+ assert(f.negative_sign() == L"-");
+ }
+ {
+ Fwt f(LOCALE_zh_CN_UTF_8, 1);
+ assert(f.negative_sign() == L"-");
+ }
+}
diff --git a/test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/pos_format.pass.cpp b/test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/pos_format.pass.cpp
new file mode 100644
index 000000000000..7038ab16e100
--- /dev/null
+++ b/test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/pos_format.pass.cpp
@@ -0,0 +1,227 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// XFAIL: apple-darwin
+
+// REQUIRES: locale.en_US.UTF-8
+// REQUIRES: locale.fr_FR.UTF-8
+// REQUIRES: locale.ru_RU.UTF-8
+// REQUIRES: locale.zh_CN.UTF-8
+
+// <locale>
+
+// class moneypunct_byname<charT, International>
+
+// pattern pos_format() const;
+
+#include <locale>
+#include <limits>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+class Fnf
+ : public std::moneypunct_byname<char, false>
+{
+public:
+ explicit Fnf(const std::string& nm, std::size_t refs = 0)
+ : std::moneypunct_byname<char, false>(nm, refs) {}
+};
+
+class Fnt
+ : public std::moneypunct_byname<char, true>
+{
+public:
+ explicit Fnt(const std::string& nm, std::size_t refs = 0)
+ : std::moneypunct_byname<char, true>(nm, refs) {}
+};
+
+class Fwf
+ : public std::moneypunct_byname<wchar_t, false>
+{
+public:
+ explicit Fwf(const std::string& nm, std::size_t refs = 0)
+ : std::moneypunct_byname<wchar_t, false>(nm, refs) {}
+};
+
+class Fwt
+ : public std::moneypunct_byname<wchar_t, true>
+{
+public:
+ explicit Fwt(const std::string& nm, std::size_t refs = 0)
+ : std::moneypunct_byname<wchar_t, true>(nm, refs) {}
+};
+
+int main()
+{
+ {
+ Fnf f("C", 1);
+ std::money_base::pattern p = f.pos_format();
+ assert(p.field[0] == std::money_base::symbol);
+ assert(p.field[1] == std::money_base::sign);
+ assert(p.field[2] == std::money_base::none);
+ assert(p.field[3] == std::money_base::value);
+ }
+ {
+ Fnt f("C", 1);
+ std::money_base::pattern p = f.pos_format();
+ assert(p.field[0] == std::money_base::symbol);
+ assert(p.field[1] == std::money_base::sign);
+ assert(p.field[2] == std::money_base::none);
+ assert(p.field[3] == std::money_base::value);
+ }
+ {
+ Fwf f("C", 1);
+ std::money_base::pattern p = f.pos_format();
+ assert(p.field[0] == std::money_base::symbol);
+ assert(p.field[1] == std::money_base::sign);
+ assert(p.field[2] == std::money_base::none);
+ assert(p.field[3] == std::money_base::value);
+ }
+ {
+ Fwt f("C", 1);
+ std::money_base::pattern p = f.pos_format();
+ assert(p.field[0] == std::money_base::symbol);
+ assert(p.field[1] == std::money_base::sign);
+ assert(p.field[2] == std::money_base::none);
+ assert(p.field[3] == std::money_base::value);
+ }
+
+ {
+ Fnf f(LOCALE_en_US_UTF_8, 1);
+ std::money_base::pattern p = f.pos_format();
+ assert(p.field[0] == std::money_base::sign);
+ assert(p.field[1] == std::money_base::symbol);
+ assert(p.field[2] == std::money_base::none);
+ assert(p.field[3] == std::money_base::value);
+ }
+ {
+ Fnt f(LOCALE_en_US_UTF_8, 1);
+ std::money_base::pattern p = f.pos_format();
+ assert(p.field[0] == std::money_base::sign);
+ assert(p.field[1] == std::money_base::symbol);
+ assert(p.field[2] == std::money_base::none);
+ assert(p.field[3] == std::money_base::value);
+ }
+ {
+ Fwf f(LOCALE_en_US_UTF_8, 1);
+ std::money_base::pattern p = f.pos_format();
+ assert(p.field[0] == std::money_base::sign);
+ assert(p.field[1] == std::money_base::symbol);
+ assert(p.field[2] == std::money_base::none);
+ assert(p.field[3] == std::money_base::value);
+ }
+ {
+ Fwt f(LOCALE_en_US_UTF_8, 1);
+ std::money_base::pattern p = f.pos_format();
+ assert(p.field[0] == std::money_base::sign);
+ assert(p.field[1] == std::money_base::symbol);
+ assert(p.field[2] == std::money_base::none);
+ assert(p.field[3] == std::money_base::value);
+ }
+
+ {
+ Fnf f(LOCALE_fr_FR_UTF_8, 1);
+ std::money_base::pattern p = f.pos_format();
+ assert(p.field[0] == std::money_base::sign);
+ assert(p.field[1] == std::money_base::value);
+ assert(p.field[2] == std::money_base::none);
+ assert(p.field[3] == std::money_base::symbol);
+ }
+ {
+ Fnt f(LOCALE_fr_FR_UTF_8, 1);
+ std::money_base::pattern p = f.pos_format();
+ assert(p.field[0] == std::money_base::sign);
+ assert(p.field[1] == std::money_base::value);
+ assert(p.field[2] == std::money_base::none);
+ assert(p.field[3] == std::money_base::symbol);
+ }
+ {
+ Fwf f(LOCALE_fr_FR_UTF_8, 1);
+ std::money_base::pattern p = f.pos_format();
+ assert(p.field[0] == std::money_base::sign);
+ assert(p.field[1] == std::money_base::value);
+ assert(p.field[2] == std::money_base::none);
+ assert(p.field[3] == std::money_base::symbol);
+ }
+ {
+ Fwt f(LOCALE_fr_FR_UTF_8, 1);
+ std::money_base::pattern p = f.pos_format();
+ assert(p.field[0] == std::money_base::sign);
+ assert(p.field[1] == std::money_base::value);
+ assert(p.field[2] == std::money_base::none);
+ assert(p.field[3] == std::money_base::symbol);
+ }
+
+ {
+ Fnf f(LOCALE_ru_RU_UTF_8, 1);
+ std::money_base::pattern p = f.pos_format();
+ assert(p.field[0] == std::money_base::sign);
+ assert(p.field[1] == std::money_base::value);
+ assert(p.field[2] == std::money_base::none);
+ assert(p.field[3] == std::money_base::symbol);
+ }
+ {
+ Fnt f(LOCALE_ru_RU_UTF_8, 1);
+ std::money_base::pattern p = f.pos_format();
+ assert(p.field[0] == std::money_base::sign);
+ assert(p.field[1] == std::money_base::value);
+ assert(p.field[2] == std::money_base::none);
+ assert(p.field[3] == std::money_base::symbol);
+ }
+ {
+ Fwf f(LOCALE_ru_RU_UTF_8, 1);
+ std::money_base::pattern p = f.pos_format();
+ assert(p.field[0] == std::money_base::sign);
+ assert(p.field[1] == std::money_base::value);
+ assert(p.field[2] == std::money_base::none);
+ assert(p.field[3] == std::money_base::symbol);
+ }
+ {
+ Fwt f(LOCALE_ru_RU_UTF_8, 1);
+ std::money_base::pattern p = f.pos_format();
+ assert(p.field[0] == std::money_base::sign);
+ assert(p.field[1] == std::money_base::value);
+ assert(p.field[2] == std::money_base::none);
+ assert(p.field[3] == std::money_base::symbol);
+ }
+
+ {
+ Fnf f(LOCALE_zh_CN_UTF_8, 1);
+ std::money_base::pattern p = f.pos_format();
+ assert(p.field[0] == std::money_base::symbol);
+ assert(p.field[1] == std::money_base::sign);
+ assert(p.field[2] == std::money_base::none);
+ assert(p.field[3] == std::money_base::value);
+ }
+ {
+ Fnt f(LOCALE_zh_CN_UTF_8, 1);
+ std::money_base::pattern p = f.pos_format();
+ assert(p.field[0] == std::money_base::sign);
+ assert(p.field[1] == std::money_base::symbol);
+ assert(p.field[2] == std::money_base::none);
+ assert(p.field[3] == std::money_base::value);
+ }
+ {
+ Fwf f(LOCALE_zh_CN_UTF_8, 1);
+ std::money_base::pattern p = f.pos_format();
+ assert(p.field[0] == std::money_base::symbol);
+ assert(p.field[1] == std::money_base::sign);
+ assert(p.field[2] == std::money_base::none);
+ assert(p.field[3] == std::money_base::value);
+ }
+ {
+ Fwt f(LOCALE_zh_CN_UTF_8, 1);
+ std::money_base::pattern p = f.pos_format();
+ assert(p.field[0] == std::money_base::sign);
+ assert(p.field[1] == std::money_base::symbol);
+ assert(p.field[2] == std::money_base::none);
+ assert(p.field[3] == std::money_base::value);
+ }
+}
diff --git a/test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/positive_sign.pass.cpp b/test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/positive_sign.pass.cpp
new file mode 100644
index 000000000000..04cd173dd1ba
--- /dev/null
+++ b/test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/positive_sign.pass.cpp
@@ -0,0 +1,145 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: locale.en_US.UTF-8
+// REQUIRES: locale.fr_FR.UTF-8
+// REQUIRES: locale.ru_RU.UTF-8
+// REQUIRES: locale.zh_CN.UTF-8
+
+// <locale>
+
+// class moneypunct_byname<charT, International>
+
+// string_type positive_sign() const;
+
+#include <locale>
+#include <limits>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+class Fnf
+ : public std::moneypunct_byname<char, false>
+{
+public:
+ explicit Fnf(const std::string& nm, std::size_t refs = 0)
+ : std::moneypunct_byname<char, false>(nm, refs) {}
+};
+
+class Fnt
+ : public std::moneypunct_byname<char, true>
+{
+public:
+ explicit Fnt(const std::string& nm, std::size_t refs = 0)
+ : std::moneypunct_byname<char, true>(nm, refs) {}
+};
+
+class Fwf
+ : public std::moneypunct_byname<wchar_t, false>
+{
+public:
+ explicit Fwf(const std::string& nm, std::size_t refs = 0)
+ : std::moneypunct_byname<wchar_t, false>(nm, refs) {}
+};
+
+class Fwt
+ : public std::moneypunct_byname<wchar_t, true>
+{
+public:
+ explicit Fwt(const std::string& nm, std::size_t refs = 0)
+ : std::moneypunct_byname<wchar_t, true>(nm, refs) {}
+};
+
+int main()
+{
+ {
+ Fnf f("C", 1);
+ assert(f.positive_sign() == std::string());
+ }
+ {
+ Fnt f("C", 1);
+ assert(f.positive_sign() == std::string());
+ }
+ {
+ Fwf f("C", 1);
+ assert(f.positive_sign() == std::wstring());
+ }
+ {
+ Fwt f("C", 1);
+ assert(f.positive_sign() == std::wstring());
+ }
+
+ {
+ Fnf f(LOCALE_en_US_UTF_8, 1);
+ assert(f.positive_sign() == "");
+ }
+ {
+ Fnt f(LOCALE_en_US_UTF_8, 1);
+ assert(f.positive_sign() == "");
+ }
+ {
+ Fwf f(LOCALE_en_US_UTF_8, 1);
+ assert(f.positive_sign() == L"");
+ }
+ {
+ Fwt f(LOCALE_en_US_UTF_8, 1);
+ assert(f.positive_sign() == L"");
+ }
+
+ {
+ Fnf f(LOCALE_fr_FR_UTF_8, 1);
+ assert(f.positive_sign() == "");
+ }
+ {
+ Fnt f(LOCALE_fr_FR_UTF_8, 1);
+ assert(f.positive_sign() == "");
+ }
+ {
+ Fwf f(LOCALE_fr_FR_UTF_8, 1);
+ assert(f.positive_sign() == L"");
+ }
+ {
+ Fwt f(LOCALE_fr_FR_UTF_8, 1);
+ assert(f.positive_sign() == L"");
+ }
+
+ {
+ Fnf f(LOCALE_ru_RU_UTF_8, 1);
+ assert(f.positive_sign() == "");
+ }
+ {
+ Fnt f(LOCALE_ru_RU_UTF_8, 1);
+ assert(f.positive_sign() == "");
+ }
+ {
+ Fwf f(LOCALE_ru_RU_UTF_8, 1);
+ assert(f.positive_sign() == L"");
+ }
+ {
+ Fwt f(LOCALE_ru_RU_UTF_8, 1);
+ assert(f.positive_sign() == L"");
+ }
+
+ {
+ Fnf f(LOCALE_zh_CN_UTF_8, 1);
+ assert(f.positive_sign() == "");
+ }
+ {
+ Fnt f(LOCALE_zh_CN_UTF_8, 1);
+ assert(f.positive_sign() == "");
+ }
+ {
+ Fwf f(LOCALE_zh_CN_UTF_8, 1);
+ assert(f.positive_sign() == L"");
+ }
+ {
+ Fwt f(LOCALE_zh_CN_UTF_8, 1);
+ assert(f.positive_sign() == L"");
+ }
+}
diff --git a/test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/thousands_sep.pass.cpp b/test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/thousands_sep.pass.cpp
new file mode 100644
index 000000000000..a8782832de5c
--- /dev/null
+++ b/test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/thousands_sep.pass.cpp
@@ -0,0 +1,151 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: locale.en_US.UTF-8
+// REQUIRES: locale.fr_FR.UTF-8
+// REQUIRES: locale.ru_RU.UTF-8
+// REQUIRES: locale.zh_CN.UTF-8
+
+// <locale>
+
+// class moneypunct_byname<charT, International>
+
+// charT thousands_sep() const;
+
+// Failure related to GLIBC's use of U00A0 as mon_thousands_sep
+// and U002E as mon_decimal_point.
+// TODO: U00A0 should be investigated.
+// Possibly related to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=16006
+// XFAIL: linux-gnu
+
+#include <locale>
+#include <limits>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+class Fnf
+ : public std::moneypunct_byname<char, false>
+{
+public:
+ explicit Fnf(const std::string& nm, std::size_t refs = 0)
+ : std::moneypunct_byname<char, false>(nm, refs) {}
+};
+
+class Fnt
+ : public std::moneypunct_byname<char, true>
+{
+public:
+ explicit Fnt(const std::string& nm, std::size_t refs = 0)
+ : std::moneypunct_byname<char, true>(nm, refs) {}
+};
+
+class Fwf
+ : public std::moneypunct_byname<wchar_t, false>
+{
+public:
+ explicit Fwf(const std::string& nm, std::size_t refs = 0)
+ : std::moneypunct_byname<wchar_t, false>(nm, refs) {}
+};
+
+class Fwt
+ : public std::moneypunct_byname<wchar_t, true>
+{
+public:
+ explicit Fwt(const std::string& nm, std::size_t refs = 0)
+ : std::moneypunct_byname<wchar_t, true>(nm, refs) {}
+};
+
+int main()
+{
+ {
+ Fnf f("C", 1);
+ assert(f.thousands_sep() == std::numeric_limits<char>::max());
+ }
+ {
+ Fnt f("C", 1);
+ assert(f.thousands_sep() == std::numeric_limits<char>::max());
+ }
+ {
+ Fwf f("C", 1);
+ assert(f.thousands_sep() == std::numeric_limits<wchar_t>::max());
+ }
+ {
+ Fwt f("C", 1);
+ assert(f.thousands_sep() == std::numeric_limits<wchar_t>::max());
+ }
+
+ {
+ Fnf f(LOCALE_en_US_UTF_8, 1);
+ assert(f.thousands_sep() == ',');
+ }
+ {
+ Fnt f(LOCALE_en_US_UTF_8, 1);
+ assert(f.thousands_sep() == ',');
+ }
+ {
+ Fwf f(LOCALE_en_US_UTF_8, 1);
+ assert(f.thousands_sep() == L',');
+ }
+ {
+ Fwt f(LOCALE_en_US_UTF_8, 1);
+ assert(f.thousands_sep() == L',');
+ }
+
+ {
+ Fnf f(LOCALE_fr_FR_UTF_8, 1);
+ assert(f.thousands_sep() == ' ');
+ }
+ {
+ Fnt f(LOCALE_fr_FR_UTF_8, 1);
+ assert(f.thousands_sep() == ' ');
+ }
+ {
+ Fwf f(LOCALE_fr_FR_UTF_8, 1);
+ assert(f.thousands_sep() == L' ');
+ }
+ {
+ Fwt f(LOCALE_fr_FR_UTF_8, 1);
+ assert(f.thousands_sep() == L' ');
+ }
+
+ {
+ Fnf f(LOCALE_ru_RU_UTF_8, 1);
+ assert(f.thousands_sep() == ' ');
+ }
+ {
+ Fnt f(LOCALE_ru_RU_UTF_8, 1);
+ assert(f.thousands_sep() == ' ');
+ }
+ {
+ Fwf f(LOCALE_ru_RU_UTF_8, 1);
+ assert(f.thousands_sep() == L' ');
+ }
+ {
+ Fwt f(LOCALE_ru_RU_UTF_8, 1);
+ assert(f.thousands_sep() == L' ');
+ }
+
+ {
+ Fnf f(LOCALE_zh_CN_UTF_8, 1);
+ assert(f.thousands_sep() == ',');
+ }
+ {
+ Fnt f(LOCALE_zh_CN_UTF_8, 1);
+ assert(f.thousands_sep() == ',');
+ }
+ {
+ Fwf f(LOCALE_zh_CN_UTF_8, 1);
+ assert(f.thousands_sep() == L',');
+ }
+ {
+ Fwt f(LOCALE_zh_CN_UTF_8, 1);
+ assert(f.thousands_sep() == L',');
+ }
+}
diff --git a/test/std/localization/locale.categories/category.monetary/locale.moneypunct/ctor.pass.cpp b/test/std/localization/locale.categories/category.monetary/locale.moneypunct/ctor.pass.cpp
new file mode 100644
index 000000000000..798dbd08b614
--- /dev/null
+++ b/test/std/localization/locale.categories/category.monetary/locale.moneypunct/ctor.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class moneypunct<charT, International>
+
+// explicit moneypunct(size_t refs = 0);
+
+#include <locale>
+#include <cassert>
+
+typedef std::moneypunct<char> F;
+
+class my_facet
+ : public F
+{
+public:
+ static int count;
+
+ explicit my_facet(std::size_t refs = 0)
+ : F(refs) {++count;}
+
+ ~my_facet() {--count;}
+};
+
+int my_facet::count = 0;
+
+int main()
+{
+ {
+ std::locale l(std::locale::classic(), new my_facet);
+ assert(my_facet::count == 1);
+ }
+ assert(my_facet::count == 0);
+ {
+ my_facet f(1);
+ assert(my_facet::count == 1);
+ {
+ std::locale l(std::locale::classic(), &f);
+ assert(my_facet::count == 1);
+ }
+ assert(my_facet::count == 1);
+ }
+ assert(my_facet::count == 0);
+}
diff --git a/test/std/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/curr_symbol.pass.cpp b/test/std/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/curr_symbol.pass.cpp
new file mode 100644
index 000000000000..8dc4726e2e94
--- /dev/null
+++ b/test/std/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/curr_symbol.pass.cpp
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class moneypunct<charT, International>
+
+// string_type curr_symbol() const;
+
+// The C++ and C standards are silent.
+// POSIX standard is being followed (as a guideline).
+
+#include <locale>
+#include <limits>
+#include <cassert>
+
+typedef std::moneypunct<char> F;
+
+class Fnf
+ : public std::moneypunct<char, false>
+{
+public:
+ explicit Fnf(std::size_t refs = 0)
+ : std::moneypunct<char, false>(refs) {}
+};
+
+class Fnt
+ : public std::moneypunct<char, true>
+{
+public:
+ explicit Fnt(std::size_t refs = 0)
+ : std::moneypunct<char, true>(refs) {}
+};
+
+class Fwf
+ : public std::moneypunct<wchar_t, false>
+{
+public:
+ explicit Fwf(std::size_t refs = 0)
+ : std::moneypunct<wchar_t, false>(refs) {}
+};
+
+class Fwt
+ : public std::moneypunct<wchar_t, true>
+{
+public:
+ explicit Fwt(std::size_t refs = 0)
+ : std::moneypunct<wchar_t, true>(refs) {}
+};
+
+int main()
+{
+ {
+ Fnf f(1);
+ assert(f.curr_symbol() == std::string());
+ }
+ {
+ Fnt f(1);
+ assert(f.curr_symbol() == std::string());
+ }
+ {
+ Fwf f(1);
+ assert(f.curr_symbol() == std::wstring());
+ }
+ {
+ Fwt f(1);
+ assert(f.curr_symbol() == std::wstring());
+ }
+}
diff --git a/test/std/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/decimal_point.pass.cpp b/test/std/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/decimal_point.pass.cpp
new file mode 100644
index 000000000000..66262dc43846
--- /dev/null
+++ b/test/std/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/decimal_point.pass.cpp
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class moneypunct<charT, International>
+
+// charT decimal_point() const;
+
+// The C++ and C standards are silent.
+// POSIX standard is being followed (as a guideline).
+
+#include <locale>
+#include <limits>
+#include <cassert>
+
+typedef std::moneypunct<char> F;
+
+class Fnf
+ : public std::moneypunct<char, false>
+{
+public:
+ explicit Fnf(std::size_t refs = 0)
+ : std::moneypunct<char, false>(refs) {}
+};
+
+class Fnt
+ : public std::moneypunct<char, true>
+{
+public:
+ explicit Fnt(std::size_t refs = 0)
+ : std::moneypunct<char, true>(refs) {}
+};
+
+class Fwf
+ : public std::moneypunct<wchar_t, false>
+{
+public:
+ explicit Fwf(std::size_t refs = 0)
+ : std::moneypunct<wchar_t, false>(refs) {}
+};
+
+class Fwt
+ : public std::moneypunct<wchar_t, true>
+{
+public:
+ explicit Fwt(std::size_t refs = 0)
+ : std::moneypunct<wchar_t, true>(refs) {}
+};
+
+int main()
+{
+ {
+ Fnf f(1);
+ assert(f.decimal_point() == std::numeric_limits<char>::max());
+ }
+ {
+ Fnt f(1);
+ assert(f.decimal_point() == std::numeric_limits<char>::max());
+ }
+ {
+ Fwf f(1);
+ assert(f.decimal_point() == std::numeric_limits<wchar_t>::max());
+ }
+ {
+ Fwt f(1);
+ assert(f.decimal_point() == std::numeric_limits<wchar_t>::max());
+ }
+}
diff --git a/test/std/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/frac_digits.pass.cpp b/test/std/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/frac_digits.pass.cpp
new file mode 100644
index 000000000000..0622342ff8f0
--- /dev/null
+++ b/test/std/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/frac_digits.pass.cpp
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class moneypunct<charT, International>
+
+// int frac_digits() const;
+
+// The C++ and C standards are silent.
+// POSIX standard is being followed (as a guideline).
+
+#include <locale>
+#include <limits>
+#include <cassert>
+
+typedef std::moneypunct<char> F;
+
+class Fnf
+ : public std::moneypunct<char, false>
+{
+public:
+ explicit Fnf(std::size_t refs = 0)
+ : std::moneypunct<char, false>(refs) {}
+};
+
+class Fnt
+ : public std::moneypunct<char, true>
+{
+public:
+ explicit Fnt(std::size_t refs = 0)
+ : std::moneypunct<char, true>(refs) {}
+};
+
+class Fwf
+ : public std::moneypunct<wchar_t, false>
+{
+public:
+ explicit Fwf(std::size_t refs = 0)
+ : std::moneypunct<wchar_t, false>(refs) {}
+};
+
+class Fwt
+ : public std::moneypunct<wchar_t, true>
+{
+public:
+ explicit Fwt(std::size_t refs = 0)
+ : std::moneypunct<wchar_t, true>(refs) {}
+};
+
+int main()
+{
+ {
+ Fnf f(1);
+ assert(f.frac_digits() == 0);
+ }
+ {
+ Fnt f(1);
+ assert(f.frac_digits() == 0);
+ }
+ {
+ Fwf f(1);
+ assert(f.frac_digits() == 0);
+ }
+ {
+ Fwt f(1);
+ assert(f.frac_digits() == 0);
+ }
+}
diff --git a/test/std/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/grouping.pass.cpp b/test/std/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/grouping.pass.cpp
new file mode 100644
index 000000000000..fc857d6583a4
--- /dev/null
+++ b/test/std/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/grouping.pass.cpp
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class moneypunct<charT, International>
+
+// string grouping() const;
+
+// The C++ and C standards are silent.
+// POSIX standard is being followed (as a guideline).
+
+#include <locale>
+#include <limits>
+#include <cassert>
+
+typedef std::moneypunct<char> F;
+
+class Fnf
+ : public std::moneypunct<char, false>
+{
+public:
+ explicit Fnf(std::size_t refs = 0)
+ : std::moneypunct<char, false>(refs) {}
+};
+
+class Fnt
+ : public std::moneypunct<char, true>
+{
+public:
+ explicit Fnt(std::size_t refs = 0)
+ : std::moneypunct<char, true>(refs) {}
+};
+
+class Fwf
+ : public std::moneypunct<wchar_t, false>
+{
+public:
+ explicit Fwf(std::size_t refs = 0)
+ : std::moneypunct<wchar_t, false>(refs) {}
+};
+
+class Fwt
+ : public std::moneypunct<wchar_t, true>
+{
+public:
+ explicit Fwt(std::size_t refs = 0)
+ : std::moneypunct<wchar_t, true>(refs) {}
+};
+
+int main()
+{
+ {
+ Fnf f(1);
+ assert(f.grouping() == std::string());
+ }
+ {
+ Fnt f(1);
+ assert(f.grouping() == std::string());
+ }
+ {
+ Fwf f(1);
+ assert(f.grouping() == std::string());
+ }
+ {
+ Fwt f(1);
+ assert(f.grouping() == std::string());
+ }
+}
diff --git a/test/std/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/neg_format.pass.cpp b/test/std/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/neg_format.pass.cpp
new file mode 100644
index 000000000000..d1df09cdfe3e
--- /dev/null
+++ b/test/std/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/neg_format.pass.cpp
@@ -0,0 +1,88 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class moneypunct<charT, International>
+
+// pattern neg_format() const;
+
+#include <locale>
+#include <limits>
+#include <cassert>
+
+typedef std::moneypunct<char> F;
+
+class Fnf
+ : public std::moneypunct<char, false>
+{
+public:
+ explicit Fnf(std::size_t refs = 0)
+ : std::moneypunct<char, false>(refs) {}
+};
+
+class Fnt
+ : public std::moneypunct<char, true>
+{
+public:
+ explicit Fnt(std::size_t refs = 0)
+ : std::moneypunct<char, true>(refs) {}
+};
+
+class Fwf
+ : public std::moneypunct<wchar_t, false>
+{
+public:
+ explicit Fwf(std::size_t refs = 0)
+ : std::moneypunct<wchar_t, false>(refs) {}
+};
+
+class Fwt
+ : public std::moneypunct<wchar_t, true>
+{
+public:
+ explicit Fwt(std::size_t refs = 0)
+ : std::moneypunct<wchar_t, true>(refs) {}
+};
+
+int main()
+{
+ {
+ Fnf f(1);
+ std::money_base::pattern p = f.neg_format();
+ assert(p.field[0] == std::money_base::symbol);
+ assert(p.field[1] == std::money_base::sign);
+ assert(p.field[2] == std::money_base::none);
+ assert(p.field[3] == std::money_base::value);
+ }
+ {
+ Fnt f(1);
+ std::money_base::pattern p = f.neg_format();
+ assert(p.field[0] == std::money_base::symbol);
+ assert(p.field[1] == std::money_base::sign);
+ assert(p.field[2] == std::money_base::none);
+ assert(p.field[3] == std::money_base::value);
+ }
+ {
+ Fwf f(1);
+ std::money_base::pattern p = f.neg_format();
+ assert(p.field[0] == std::money_base::symbol);
+ assert(p.field[1] == std::money_base::sign);
+ assert(p.field[2] == std::money_base::none);
+ assert(p.field[3] == std::money_base::value);
+ }
+ {
+ Fwt f(1);
+ std::money_base::pattern p = f.neg_format();
+ assert(p.field[0] == std::money_base::symbol);
+ assert(p.field[1] == std::money_base::sign);
+ assert(p.field[2] == std::money_base::none);
+ assert(p.field[3] == std::money_base::value);
+ }
+}
diff --git a/test/std/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/negative_sign.pass.cpp b/test/std/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/negative_sign.pass.cpp
new file mode 100644
index 000000000000..df350d3537af
--- /dev/null
+++ b/test/std/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/negative_sign.pass.cpp
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class moneypunct<charT, International>
+
+// string_type negative_sign() const;
+
+// The C++ and C standards are silent.
+// On this one, commen sense is the guideline.
+// If customers complain, I'll endeavor to minimize customer complaints
+
+#include <locale>
+#include <limits>
+#include <cassert>
+
+typedef std::moneypunct<char> F;
+
+class Fnf
+ : public std::moneypunct<char, false>
+{
+public:
+ explicit Fnf(std::size_t refs = 0)
+ : std::moneypunct<char, false>(refs) {}
+};
+
+class Fnt
+ : public std::moneypunct<char, true>
+{
+public:
+ explicit Fnt(std::size_t refs = 0)
+ : std::moneypunct<char, true>(refs) {}
+};
+
+class Fwf
+ : public std::moneypunct<wchar_t, false>
+{
+public:
+ explicit Fwf(std::size_t refs = 0)
+ : std::moneypunct<wchar_t, false>(refs) {}
+};
+
+class Fwt
+ : public std::moneypunct<wchar_t, true>
+{
+public:
+ explicit Fwt(std::size_t refs = 0)
+ : std::moneypunct<wchar_t, true>(refs) {}
+};
+
+int main()
+{
+ {
+ Fnf f(1);
+ assert(f.negative_sign() == "-");
+ }
+ {
+ Fnt f(1);
+ assert(f.negative_sign() == "-");
+ }
+ {
+ Fwf f(1);
+ assert(f.negative_sign() == L"-");
+ }
+ {
+ Fwt f(1);
+ assert(f.negative_sign() == L"-");
+ }
+}
diff --git a/test/std/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/pos_format.pass.cpp b/test/std/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/pos_format.pass.cpp
new file mode 100644
index 000000000000..6e28154c5681
--- /dev/null
+++ b/test/std/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/pos_format.pass.cpp
@@ -0,0 +1,88 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class moneypunct<charT, International>
+
+// pattern pos_format() const;
+
+#include <locale>
+#include <limits>
+#include <cassert>
+
+typedef std::moneypunct<char> F;
+
+class Fnf
+ : public std::moneypunct<char, false>
+{
+public:
+ explicit Fnf(std::size_t refs = 0)
+ : std::moneypunct<char, false>(refs) {}
+};
+
+class Fnt
+ : public std::moneypunct<char, true>
+{
+public:
+ explicit Fnt(std::size_t refs = 0)
+ : std::moneypunct<char, true>(refs) {}
+};
+
+class Fwf
+ : public std::moneypunct<wchar_t, false>
+{
+public:
+ explicit Fwf(std::size_t refs = 0)
+ : std::moneypunct<wchar_t, false>(refs) {}
+};
+
+class Fwt
+ : public std::moneypunct<wchar_t, true>
+{
+public:
+ explicit Fwt(std::size_t refs = 0)
+ : std::moneypunct<wchar_t, true>(refs) {}
+};
+
+int main()
+{
+ {
+ Fnf f(1);
+ std::money_base::pattern p = f.pos_format();
+ assert(p.field[0] == std::money_base::symbol);
+ assert(p.field[1] == std::money_base::sign);
+ assert(p.field[2] == std::money_base::none);
+ assert(p.field[3] == std::money_base::value);
+ }
+ {
+ Fnt f(1);
+ std::money_base::pattern p = f.pos_format();
+ assert(p.field[0] == std::money_base::symbol);
+ assert(p.field[1] == std::money_base::sign);
+ assert(p.field[2] == std::money_base::none);
+ assert(p.field[3] == std::money_base::value);
+ }
+ {
+ Fwf f(1);
+ std::money_base::pattern p = f.pos_format();
+ assert(p.field[0] == std::money_base::symbol);
+ assert(p.field[1] == std::money_base::sign);
+ assert(p.field[2] == std::money_base::none);
+ assert(p.field[3] == std::money_base::value);
+ }
+ {
+ Fwt f(1);
+ std::money_base::pattern p = f.pos_format();
+ assert(p.field[0] == std::money_base::symbol);
+ assert(p.field[1] == std::money_base::sign);
+ assert(p.field[2] == std::money_base::none);
+ assert(p.field[3] == std::money_base::value);
+ }
+}
diff --git a/test/std/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/positive_sign.pass.cpp b/test/std/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/positive_sign.pass.cpp
new file mode 100644
index 000000000000..5ec8d9a54452
--- /dev/null
+++ b/test/std/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/positive_sign.pass.cpp
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class moneypunct<charT, International>
+
+// string_type positive_sign() const;
+
+// The C++ and C standards are silent.
+// POSIX standard is being followed (as a guideline).
+
+#include <locale>
+#include <limits>
+#include <cassert>
+
+typedef std::moneypunct<char> F;
+
+class Fnf
+ : public std::moneypunct<char, false>
+{
+public:
+ explicit Fnf(std::size_t refs = 0)
+ : std::moneypunct<char, false>(refs) {}
+};
+
+class Fnt
+ : public std::moneypunct<char, true>
+{
+public:
+ explicit Fnt(std::size_t refs = 0)
+ : std::moneypunct<char, true>(refs) {}
+};
+
+class Fwf
+ : public std::moneypunct<wchar_t, false>
+{
+public:
+ explicit Fwf(std::size_t refs = 0)
+ : std::moneypunct<wchar_t, false>(refs) {}
+};
+
+class Fwt
+ : public std::moneypunct<wchar_t, true>
+{
+public:
+ explicit Fwt(std::size_t refs = 0)
+ : std::moneypunct<wchar_t, true>(refs) {}
+};
+
+int main()
+{
+ {
+ Fnf f(1);
+ assert(f.positive_sign() == std::string());
+ }
+ {
+ Fnt f(1);
+ assert(f.positive_sign() == std::string());
+ }
+ {
+ Fwf f(1);
+ assert(f.positive_sign() == std::wstring());
+ }
+ {
+ Fwt f(1);
+ assert(f.positive_sign() == std::wstring());
+ }
+}
diff --git a/test/std/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/thousands_sep.pass.cpp b/test/std/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/thousands_sep.pass.cpp
new file mode 100644
index 000000000000..27db562ffdad
--- /dev/null
+++ b/test/std/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/thousands_sep.pass.cpp
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class moneypunct<charT, International>
+
+// charT thousands_sep() const;
+
+// The C++ and C standards are silent.
+// POSIX standard is being followed (as a guideline).
+
+#include <locale>
+#include <limits>
+#include <cassert>
+
+typedef std::moneypunct<char> F;
+
+class Fnf
+ : public std::moneypunct<char, false>
+{
+public:
+ explicit Fnf(std::size_t refs = 0)
+ : std::moneypunct<char, false>(refs) {}
+};
+
+class Fnt
+ : public std::moneypunct<char, true>
+{
+public:
+ explicit Fnt(std::size_t refs = 0)
+ : std::moneypunct<char, true>(refs) {}
+};
+
+class Fwf
+ : public std::moneypunct<wchar_t, false>
+{
+public:
+ explicit Fwf(std::size_t refs = 0)
+ : std::moneypunct<wchar_t, false>(refs) {}
+};
+
+class Fwt
+ : public std::moneypunct<wchar_t, true>
+{
+public:
+ explicit Fwt(std::size_t refs = 0)
+ : std::moneypunct<wchar_t, true>(refs) {}
+};
+
+int main()
+{
+ {
+ Fnf f(1);
+ assert(f.thousands_sep() == std::numeric_limits<char>::max());
+ }
+ {
+ Fnt f(1);
+ assert(f.thousands_sep() == std::numeric_limits<char>::max());
+ }
+ {
+ Fwf f(1);
+ assert(f.thousands_sep() == std::numeric_limits<wchar_t>::max());
+ }
+ {
+ Fwt f(1);
+ assert(f.thousands_sep() == std::numeric_limits<wchar_t>::max());
+ }
+}
diff --git a/test/std/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.virtuals/tested_elsewhere.pass.cpp b/test/std/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.virtuals/tested_elsewhere.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.virtuals/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/localization/locale.categories/category.monetary/locale.moneypunct/money_base.pass.cpp b/test/std/localization/locale.categories/category.monetary/locale.moneypunct/money_base.pass.cpp
new file mode 100644
index 000000000000..beabe0cae660
--- /dev/null
+++ b/test/std/localization/locale.categories/category.monetary/locale.moneypunct/money_base.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class money_base
+// {
+// public:
+// enum part {none, space, symbol, sign, value};
+// struct pattern {char field[4];};
+// };
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+ std::money_base mb;
+ assert(mb.none == 0);
+ assert(mb.space == 1);
+ assert(mb.symbol == 2);
+ assert(mb.sign == 3);
+ assert(mb.value == 4);
+ assert(sizeof(std::money_base::pattern) == 4);
+ std::money_base::pattern p;
+ p.field[0] = std::money_base::none;
+}
diff --git a/test/std/localization/locale.categories/category.monetary/locale.moneypunct/types.pass.cpp b/test/std/localization/locale.categories/category.monetary/locale.moneypunct/types.pass.cpp
new file mode 100644
index 000000000000..32e7249ab868
--- /dev/null
+++ b/test/std/localization/locale.categories/category.monetary/locale.moneypunct/types.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This test uses new symbols that were not defined in the libc++ shipped on
+// darwin11 and darwin12:
+// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11
+// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12
+
+// <locale>
+
+// template <class _CharT, bool _International = false>
+// class moneypunct
+// : public locale::facet,
+// public money_base
+// {
+// public:
+// typedef _CharT char_type;
+// typedef basic_string<char_type> string_type;
+// static const bool intl = International;
+
+#include <locale>
+#include <type_traits>
+
+template <class _Tp>
+void test(const _Tp &) {}
+
+int main()
+{
+ static_assert((std::is_base_of<std::locale::facet, std::moneypunct<char> >::value), "");
+ static_assert((std::is_base_of<std::locale::facet, std::moneypunct<wchar_t> >::value), "");
+ static_assert((std::is_base_of<std::money_base, std::moneypunct<char> >::value), "");
+ static_assert((std::is_base_of<std::money_base, std::moneypunct<wchar_t> >::value), "");
+ static_assert((std::is_same<std::moneypunct<char>::char_type, char>::value), "");
+ static_assert((std::is_same<std::moneypunct<wchar_t>::char_type, wchar_t>::value), "");
+ static_assert((std::is_same<std::moneypunct<char>::string_type, std::string>::value), "");
+ static_assert((std::is_same<std::moneypunct<wchar_t>::string_type, std::wstring>::value), "");
+
+ test(std::moneypunct<char, false>::intl);
+ test(std::moneypunct<char, true>::intl);
+ test(std::moneypunct<wchar_t, false>::intl);
+ test(std::moneypunct<wchar_t, true>::intl);
+}
diff --git a/test/std/localization/locale.categories/category.monetary/nothing_to_do.pass.cpp b/test/std/localization/locale.categories/category.monetary/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/localization/locale.categories/category.monetary/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/localization/locale.categories/category.numeric/locale.nm.put/ctor.pass.cpp b/test/std/localization/locale.categories/category.numeric/locale.nm.put/ctor.pass.cpp
new file mode 100644
index 000000000000..f801e6c5a5ac
--- /dev/null
+++ b/test/std/localization/locale.categories/category.numeric/locale.nm.put/ctor.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class num_put<charT, OutputIterator>
+
+// explicit num_put(size_t refs = 0);
+
+#include <locale>
+#include <cassert>
+
+typedef std::num_put<char, char*> F;
+
+class my_facet
+ : public F
+{
+public:
+ static int count;
+
+ explicit my_facet(std::size_t refs = 0)
+ : F(refs) {++count;}
+
+ ~my_facet() {--count;}
+};
+
+int my_facet::count = 0;
+
+int main()
+{
+ {
+ std::locale l(std::locale::classic(), new my_facet);
+ assert(my_facet::count == 1);
+ }
+ assert(my_facet::count == 0);
+ {
+ my_facet f(1);
+ assert(my_facet::count == 1);
+ {
+ std::locale l(std::locale::classic(), &f);
+ assert(my_facet::count == 1);
+ }
+ assert(my_facet::count == 1);
+ }
+ assert(my_facet::count == 0);
+}
diff --git a/test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_bool.pass.cpp b/test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_bool.pass.cpp
new file mode 100644
index 000000000000..4f6f0b47e4f3
--- /dev/null
+++ b/test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_bool.pass.cpp
@@ -0,0 +1,100 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class num_put<charT, OutputIterator>
+
+// iter_type put(iter_type s, ios_base& iob, char_type fill, bool v) const;
+
+#include <locale>
+#include <ios>
+#include <cassert>
+#include <streambuf>
+#include "test_iterators.h"
+
+typedef std::num_put<char, output_iterator<char*> > F;
+
+class my_facet
+ : public F
+{
+public:
+ explicit my_facet(std::size_t refs = 0)
+ : F(refs) {}
+};
+
+class my_numpunct
+ : public std::numpunct<char>
+{
+public:
+ my_numpunct() : std::numpunct<char>() {}
+
+protected:
+ virtual string_type do_truename() const {return "yes";}
+ virtual string_type do_falsename() const {return "no";}
+};
+
+int main()
+{
+ const my_facet f(1);
+ {
+ std::ios ios(0);
+ {
+ bool v = false;
+ char str[50];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0");
+ }
+ {
+ bool v = true;
+ char str[50];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1");
+ }
+ }
+ {
+ std::ios ios(0);
+ boolalpha(ios);
+ {
+ bool v = false;
+ char str[50];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "false");
+ }
+ {
+ bool v = true;
+ char str[50];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "true");
+ }
+ }
+ {
+ std::ios ios(0);
+ boolalpha(ios);
+ ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+ {
+ bool v = false;
+ char str[50];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "no");
+ }
+ {
+ bool v = true;
+ char str[50];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "yes");
+ }
+ }
+}
diff --git a/test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_double.pass.cpp b/test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_double.pass.cpp
new file mode 100644
index 000000000000..a54b37314e87
--- /dev/null
+++ b/test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_double.pass.cpp
@@ -0,0 +1,17887 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class num_put<charT, OutputIterator>
+
+// iter_type put(iter_type s, ios_base& iob, char_type fill, double v) const;
+
+#include <locale>
+#include <ios>
+#include <cassert>
+#include <streambuf>
+#include <cmath>
+#include "test_iterators.h"
+
+typedef std::num_put<char, output_iterator<char*> > F;
+
+class my_facet
+ : public F
+{
+public:
+ explicit my_facet(std::size_t refs = 0)
+ : F(refs) {}
+};
+
+class my_numpunct
+ : public std::numpunct<char>
+{
+public:
+ my_numpunct() : std::numpunct<char>() {}
+
+protected:
+ virtual char_type do_decimal_point() const {return ';';}
+ virtual char_type do_thousands_sep() const {return '_';}
+ virtual std::string do_grouping() const {return std::string("\1\2\3");}
+};
+
+void test1()
+{
+ char str[200];
+ output_iterator<char*> iter;
+ std::locale lc = std::locale::classic();
+ std::locale lg(lc, new my_numpunct);
+ const my_facet f(1);
+ {
+ double v = +0.;
+ std::ios ios(0);
+ // %g
+ {
+ ios.precision(0);
+ {
+ nouppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0************************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0************************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************0.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************0.");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************0;");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.**********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************+0.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+**********************0.");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;**********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************+0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+**********************0;");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ uppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0************************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0************************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************0.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************0.");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************0;");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.**********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************+0.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+**********************0.");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;**********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************+0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+**********************0;");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ }
+ ios.precision(1);
+ {
+ nouppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0************************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0************************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************0.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************0.");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************0;");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.**********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************+0.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+**********************0.");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;**********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************+0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+**********************0;");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ uppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0************************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0************************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************0.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************0.");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************0;");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.**********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************+0.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+**********************0.");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;**********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************+0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+**********************0;");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ }
+ ios.precision(6);
+ {
+ nouppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0************************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0************************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.00000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.00000******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************0.00000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************0.00000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;00000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;00000******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************0;00000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************0;00000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.00000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.00000*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************+0.00000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*****************0.00000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;00000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;00000*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************+0;00000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*****************0;00000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ uppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0************************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0************************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.00000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.00000******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************0.00000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************0.00000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;00000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;00000******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************0;00000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************0;00000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.00000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.00000*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************+0.00000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*****************0.00000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;00000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;00000*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************+0;00000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*****************0;00000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ }
+ ios.precision(16);
+ {
+ nouppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0************************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0************************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.000000000000000********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********0.000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********0.000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;000000000000000********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********0;000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********0;000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.000000000000000*******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******+0.000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*******0.000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;000000000000000*******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******+0;000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*******0;000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ uppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0************************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0************************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.000000000000000********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********0.000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********0.000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;000000000000000********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********0;000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********0;000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.000000000000000*******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******+0.000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*******0.000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;000000000000000*******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******+0;000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*******0;000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ }
+ ios.precision(60);
+ {
+ nouppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0************************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0************************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ uppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0************************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0************************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+void test2()
+{
+ char str[200];
+ output_iterator<char*> iter;
+ std::locale lc = std::locale::classic();
+ std::locale lg(lc, new my_numpunct);
+ const my_facet f(1);
+ {
+ double v = 1234567890.125;
+ std::ios ios(0);
+ // %g
+ {
+ ios.precision(0);
+ {
+ nouppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1e+09********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********************1e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********************1e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1e+09********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********************1e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********************1e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.e+09*******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************1.e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************1.e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;e+09*******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************1;e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************1;e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1e+09*******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************+1e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*******************1e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1e+09*******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************+1e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*******************1e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.e+09******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************+1.e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+******************1.e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;e+09******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************+1;e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+******************1;e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ uppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1E+09********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********************1E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********************1E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1E+09********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********************1E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********************1E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.E+09*******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************1.E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************1.E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;E+09*******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************1;E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************1;E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1E+09*******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************+1E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*******************1E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1E+09*******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************+1E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*******************1E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.E+09******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************+1.E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+******************1.E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;E+09******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************+1;E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+******************1;E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ }
+ ios.precision(1);
+ {
+ nouppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1e+09********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********************1e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********************1e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1e+09********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********************1e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********************1e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.e+09*******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************1.e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************1.e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;e+09*******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************1;e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************1;e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1e+09*******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************+1e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*******************1e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1e+09*******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************+1e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*******************1e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.e+09******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************+1.e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+******************1.e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;e+09******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************+1;e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+******************1;e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ uppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1E+09********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********************1E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********************1E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1E+09********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********************1E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********************1E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.E+09*******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************1.E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************1.E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;E+09*******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************1;E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************1;E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1E+09*******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************+1E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*******************1E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1E+09*******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************+1E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*******************1E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.E+09******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************+1.E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+******************1.E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;E+09******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************+1;E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+******************1;E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ }
+ ios.precision(6);
+ {
+ nouppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.23457e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.23457e+09**************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**************1.23457e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**************1.23457e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;23457e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;23457e+09**************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**************1;23457e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**************1;23457e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.23457e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.23457e+09**************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**************1.23457e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**************1.23457e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;23457e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;23457e+09**************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**************1;23457e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**************1;23457e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.23457e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.23457e+09*************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*************+1.23457e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*************1.23457e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;23457e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;23457e+09*************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*************+1;23457e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*************1;23457e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.23457e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.23457e+09*************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*************+1.23457e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*************1.23457e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;23457e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;23457e+09*************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*************+1;23457e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*************1;23457e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ uppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.23457E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.23457E+09**************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**************1.23457E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**************1.23457E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;23457E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;23457E+09**************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**************1;23457E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**************1;23457E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.23457E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.23457E+09**************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**************1.23457E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**************1.23457E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;23457E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;23457E+09**************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**************1;23457E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**************1;23457E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.23457E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.23457E+09*************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*************+1.23457E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*************1.23457E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;23457E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;23457E+09*************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*************+1;23457E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*************1;23457E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.23457E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.23457E+09*************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*************+1.23457E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*************1.23457E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;23457E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;23457E+09*************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*************+1;23457E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*************1;23457E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ }
+ ios.precision(16);
+ {
+ nouppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890.125");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890.125***********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********1234567890.125");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********1234567890.125");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0;125");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0;125*******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******1_234_567_89_0;125");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******1_234_567_89_0;125");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890.125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890.125000********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********1234567890.125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********1234567890.125000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0;125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0;125000****");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "****1_234_567_89_0;125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "****1_234_567_89_0;125000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890.125");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890.125**********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********+1234567890.125");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+**********1234567890.125");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0;125");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0;125******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******+1_234_567_89_0;125");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+******1_234_567_89_0;125");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890.125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890.125000*******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******+1234567890.125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*******1234567890.125000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0;125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0;125000***");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***+1_234_567_89_0;125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+***1_234_567_89_0;125000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ uppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890.125");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890.125***********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********1234567890.125");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********1234567890.125");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0;125");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0;125*******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******1_234_567_89_0;125");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******1_234_567_89_0;125");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890.125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890.125000********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********1234567890.125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********1234567890.125000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0;125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0;125000****");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "****1_234_567_89_0;125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "****1_234_567_89_0;125000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890.125");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890.125**********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********+1234567890.125");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+**********1234567890.125");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0;125");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0;125******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******+1_234_567_89_0;125");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+******1_234_567_89_0;125");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890.125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890.125000*******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******+1234567890.125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*******1234567890.125000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0;125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0;125000***");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***+1_234_567_89_0;125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+***1_234_567_89_0;125000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ }
+ ios.precision(60);
+ {
+ nouppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890.125");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890.125***********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********1234567890.125");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********1234567890.125");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0;125");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0;125*******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******1_234_567_89_0;125");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******1_234_567_89_0;125");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890.12500000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890.12500000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890.12500000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890.12500000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890.125");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890.125**********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********+1234567890.125");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+**********1234567890.125");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0;125");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0;125******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******+1_234_567_89_0;125");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+******1_234_567_89_0;125");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890.12500000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890.12500000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890.12500000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890.12500000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ uppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890.125");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890.125***********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********1234567890.125");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********1234567890.125");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0;125");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0;125*******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******1_234_567_89_0;125");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******1_234_567_89_0;125");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890.12500000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890.12500000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890.12500000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890.12500000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890.125");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890.125**********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********+1234567890.125");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+**********1234567890.125");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0;125");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0;125******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******+1_234_567_89_0;125");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+******1_234_567_89_0;125");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890.12500000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890.12500000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890.12500000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890.12500000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+void test3()
+{
+ char str[200];
+ output_iterator<char*> iter;
+ std::locale lc = std::locale::classic();
+ std::locale lg(lc, new my_numpunct);
+ const my_facet f(1);
+ {
+ double v = +0.;
+ std::ios ios(0);
+ fixed(ios);
+ // %f
+ {
+ ios.precision(0);
+ {
+ nouppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0************************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0************************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************0.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************0.");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************0;");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.**********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************+0.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+**********************0.");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;**********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************+0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+**********************0;");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ uppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0************************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0************************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************0.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************0.");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************0;");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.**********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************+0.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+**********************0.");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;**********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************+0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+**********************0;");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ }
+ ios.precision(1);
+ {
+ nouppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.0**********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************0.0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************0.0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;0**********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************0;0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************0;0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.0**********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************0.0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************0.0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;0**********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************0;0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************0;0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.0*********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********************+0.0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*********************0.0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;0*********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********************+0;0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*********************0;0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.0*********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********************+0.0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*********************0.0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;0*********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********************+0;0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*********************0;0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ uppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.0**********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************0.0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************0.0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;0**********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************0;0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************0;0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.0**********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************0.0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************0.0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;0**********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************0;0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************0;0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.0*********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********************+0.0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*********************0.0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;0*********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********************+0;0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*********************0;0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.0*********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********************+0.0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*********************0.0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;0*********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********************+0;0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*********************0;0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ }
+ ios.precision(6);
+ {
+ nouppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.000000*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************0.000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************0.000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;000000*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************0;000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************0;000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.000000*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************0.000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************0.000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;000000*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************0;000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************0;000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.000000****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "****************+0.000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+****************0.000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;000000****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "****************+0;000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+****************0;000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.000000****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "****************+0.000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+****************0.000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;000000****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "****************+0;000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+****************0;000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ uppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.000000*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************0.000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************0.000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;000000*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************0;000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************0;000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.000000*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************0.000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************0.000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;000000*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************0;000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************0;000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.000000****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "****************+0.000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+****************0.000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;000000****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "****************+0;000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+****************0;000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.000000****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "****************+0.000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+****************0.000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;000000****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "****************+0;000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+****************0;000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ }
+ ios.precision(16);
+ {
+ nouppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.0000000000000000*******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******0.0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******0.0000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;0000000000000000*******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******0;0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******0;0000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.0000000000000000*******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******0.0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******0.0000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;0000000000000000*******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******0;0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******0;0000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.0000000000000000******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******+0.0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+******0.0000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;0000000000000000******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******+0;0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+******0;0000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.0000000000000000******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******+0.0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+******0.0000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;0000000000000000******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******+0;0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+******0;0000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ uppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.0000000000000000*******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******0.0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******0.0000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;0000000000000000*******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******0;0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******0;0000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.0000000000000000*******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******0.0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******0.0000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;0000000000000000*******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******0;0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******0;0000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.0000000000000000******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******+0.0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+******0.0000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;0000000000000000******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******+0;0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+******0;0000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.0000000000000000******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******+0.0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+******0.0000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;0000000000000000******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******+0;0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+******0;0000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ }
+ ios.precision(60);
+ {
+ nouppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ uppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+void test4()
+{
+ char str[200];
+ output_iterator<char*> iter;
+ std::locale lc = std::locale::classic();
+ std::locale lg(lc, new my_numpunct);
+ const my_facet f(1);
+ {
+ double v = 1234567890.125;
+ std::ios ios(0);
+ fixed(ios);
+ // %f
+ {
+ ios.precision(0);
+ {
+ nouppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890***************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***************1234567890");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***************1234567890");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0***********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********1_234_567_89_0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********1_234_567_89_0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890.**************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**************1234567890.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**************1234567890.");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0;**********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********1_234_567_89_0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********1_234_567_89_0;");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890**************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**************+1234567890");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+**************1234567890");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0**********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********+1_234_567_89_0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+**********1_234_567_89_0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890.*************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*************+1234567890.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*************1234567890.");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0;*********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********+1_234_567_89_0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*********1_234_567_89_0;");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ uppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890***************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***************1234567890");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***************1234567890");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0***********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********1_234_567_89_0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********1_234_567_89_0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890.**************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**************1234567890.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**************1234567890.");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0;**********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********1_234_567_89_0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********1_234_567_89_0;");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890**************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**************+1234567890");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+**************1234567890");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0**********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********+1_234_567_89_0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+**********1_234_567_89_0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890.*************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*************+1234567890.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*************1234567890.");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0;*********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********+1_234_567_89_0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*********1_234_567_89_0;");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ }
+ ios.precision(1);
+ {
+ nouppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890.1");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890.1*************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*************1234567890.1");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*************1234567890.1");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0;1");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0;1*********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********1_234_567_89_0;1");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********1_234_567_89_0;1");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890.1");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890.1*************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*************1234567890.1");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*************1234567890.1");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0;1");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0;1*********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********1_234_567_89_0;1");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********1_234_567_89_0;1");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890.1");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890.1************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************+1234567890.1");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+************1234567890.1");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0;1");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0;1********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********+1_234_567_89_0;1");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+********1_234_567_89_0;1");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890.1");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890.1************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************+1234567890.1");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+************1234567890.1");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0;1");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0;1********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********+1_234_567_89_0;1");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+********1_234_567_89_0;1");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ uppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890.1");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890.1*************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*************1234567890.1");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*************1234567890.1");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0;1");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0;1*********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********1_234_567_89_0;1");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********1_234_567_89_0;1");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890.1");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890.1*************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*************1234567890.1");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*************1234567890.1");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0;1");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0;1*********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********1_234_567_89_0;1");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********1_234_567_89_0;1");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890.1");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890.1************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************+1234567890.1");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+************1234567890.1");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0;1");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0;1********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********+1_234_567_89_0;1");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+********1_234_567_89_0;1");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890.1");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890.1************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************+1234567890.1");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+************1234567890.1");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0;1");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0;1********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********+1_234_567_89_0;1");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+********1_234_567_89_0;1");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ }
+ ios.precision(6);
+ {
+ nouppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890.125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890.125000********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********1234567890.125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********1234567890.125000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0;125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0;125000****");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "****1_234_567_89_0;125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "****1_234_567_89_0;125000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890.125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890.125000********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********1234567890.125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********1234567890.125000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0;125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0;125000****");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "****1_234_567_89_0;125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "****1_234_567_89_0;125000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890.125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890.125000*******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******+1234567890.125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*******1234567890.125000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0;125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0;125000***");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***+1_234_567_89_0;125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+***1_234_567_89_0;125000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890.125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890.125000*******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******+1234567890.125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*******1234567890.125000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0;125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0;125000***");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***+1_234_567_89_0;125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+***1_234_567_89_0;125000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ uppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890.125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890.125000********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********1234567890.125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********1234567890.125000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0;125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0;125000****");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "****1_234_567_89_0;125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "****1_234_567_89_0;125000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890.125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890.125000********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********1234567890.125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********1234567890.125000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0;125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0;125000****");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "****1_234_567_89_0;125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "****1_234_567_89_0;125000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890.125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890.125000*******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******+1234567890.125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*******1234567890.125000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0;125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0;125000***");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***+1_234_567_89_0;125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+***1_234_567_89_0;125000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890.125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890.125000*******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******+1234567890.125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*******1234567890.125000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0;125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0;125000***");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***+1_234_567_89_0;125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+***1_234_567_89_0;125000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ }
+ ios.precision(16);
+ {}
+ ios.precision(60);
+ {}
+ }
+ }
+}
+
+void test5()
+{
+ char str[200];
+ output_iterator<char*> iter;
+ std::locale lc = std::locale::classic();
+ std::locale lg(lc, new my_numpunct);
+ const my_facet f(1);
+ {
+ double v = -0.;
+ std::ios ios(0);
+ scientific(ios);
+ // %e
+ {
+ ios.precision(0);
+ {
+ nouppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0e+00*******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************-0e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*******************0e+00");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0e+00*******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************-0e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*******************0e+00");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.e+00******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************-0.e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-******************0.e+00");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;e+00******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************-0;e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-******************0;e+00");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0e+00*******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************-0e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*******************0e+00");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0e+00*******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************-0e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*******************0e+00");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.e+00******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************-0.e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-******************0.e+00");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;e+00******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************-0;e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-******************0;e+00");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ uppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0E+00*******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************-0E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*******************0E+00");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0E+00*******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************-0E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*******************0E+00");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.E+00******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************-0.E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-******************0.E+00");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;E+00******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************-0;E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-******************0;E+00");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0E+00*******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************-0E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*******************0E+00");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0E+00*******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************-0E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*******************0E+00");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.E+00******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************-0.E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-******************0.E+00");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;E+00******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************-0;E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-******************0;E+00");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ }
+ ios.precision(1);
+ {
+ nouppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.0e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.0e+00*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0.0e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0.0e+00");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;0e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;0e+00*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0;0e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0;0e+00");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.0e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.0e+00*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0.0e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0.0e+00");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;0e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;0e+00*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0;0e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0;0e+00");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.0e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.0e+00*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0.0e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0.0e+00");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;0e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;0e+00*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0;0e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0;0e+00");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.0e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.0e+00*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0.0e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0.0e+00");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;0e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;0e+00*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0;0e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0;0e+00");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ uppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.0E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.0E+00*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0.0E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0.0E+00");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;0E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;0E+00*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0;0E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0;0E+00");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.0E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.0E+00*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0.0E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0.0E+00");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;0E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;0E+00*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0;0E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0;0E+00");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.0E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.0E+00*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0.0E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0.0E+00");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;0E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;0E+00*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0;0E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0;0E+00");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.0E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.0E+00*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0.0E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0.0E+00");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;0E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;0E+00*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0;0E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0;0E+00");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ }
+ ios.precision(6);
+ {
+ nouppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000e+00************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************-0.000000e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-************0.000000e+00");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000e+00************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************-0;000000e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-************0;000000e+00");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000e+00************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************-0.000000e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-************0.000000e+00");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000e+00************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************-0;000000e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-************0;000000e+00");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000e+00************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************-0.000000e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-************0.000000e+00");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000e+00************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************-0;000000e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-************0;000000e+00");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000e+00************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************-0.000000e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-************0.000000e+00");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000e+00************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************-0;000000e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-************0;000000e+00");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ uppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000E+00************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************-0.000000E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-************0.000000E+00");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000E+00************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************-0;000000E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-************0;000000E+00");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000E+00************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************-0.000000E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-************0.000000E+00");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000E+00************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************-0;000000E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-************0;000000E+00");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000E+00************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************-0.000000E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-************0.000000E+00");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000E+00************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************-0;000000E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-************0;000000E+00");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000E+00************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************-0.000000E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-************0.000000E+00");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000E+00************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************-0;000000E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-************0;000000E+00");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ }
+ ios.precision(16);
+ {
+ }
+ ios.precision(60);
+ {
+ }
+ }
+ }
+}
+
+void test6()
+{
+ char str[200];
+ output_iterator<char*> iter;
+ std::locale lc = std::locale::classic();
+ std::locale lg(lc, new my_numpunct);
+ const my_facet f(1);
+ {
+ double v = 1234567890.125;
+ std::ios ios(0);
+ scientific(ios);
+ // %e
+ {
+ ios.precision(0);
+ {
+ nouppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1e+09********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********************1e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********************1e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1e+09********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********************1e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********************1e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.e+09*******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************1.e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************1.e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;e+09*******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************1;e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************1;e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1e+09*******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************+1e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*******************1e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1e+09*******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************+1e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*******************1e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.e+09******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************+1.e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+******************1.e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;e+09******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************+1;e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+******************1;e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ uppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1E+09********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********************1E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********************1E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1E+09********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********************1E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********************1E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.E+09*******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************1.E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************1.E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;E+09*******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************1;E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************1;E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1E+09*******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************+1E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*******************1E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1E+09*******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************+1E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*******************1E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.E+09******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************+1.E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+******************1.E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;E+09******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************+1;E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+******************1;E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ }
+ ios.precision(1);
+ {
+ nouppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.2e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.2e+09******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************1.2e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************1.2e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;2e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;2e+09******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************1;2e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************1;2e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.2e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.2e+09******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************1.2e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************1.2e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;2e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;2e+09******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************1;2e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************1;2e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.2e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.2e+09*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************+1.2e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*****************1.2e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;2e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;2e+09*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************+1;2e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*****************1;2e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.2e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.2e+09*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************+1.2e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*****************1.2e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;2e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;2e+09*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************+1;2e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*****************1;2e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ uppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.2E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.2E+09******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************1.2E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************1.2E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;2E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;2E+09******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************1;2E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************1;2E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.2E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.2E+09******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************1.2E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************1.2E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;2E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;2E+09******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************1;2E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************1;2E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.2E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.2E+09*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************+1.2E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*****************1.2E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;2E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;2E+09*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************+1;2E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*****************1;2E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.2E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.2E+09*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************+1.2E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*****************1.2E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;2E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;2E+09*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************+1;2E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*****************1;2E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ }
+ ios.precision(6);
+ {
+ }
+ ios.precision(16);
+ {
+ }
+ ios.precision(60);
+ {
+ nouppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.234567890125000000000000000000000000000000000000000000000000e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.234567890125000000000000000000000000000000000000000000000000e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.234567890125000000000000000000000000000000000000000000000000e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.234567890125000000000000000000000000000000000000000000000000e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;234567890125000000000000000000000000000000000000000000000000e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;234567890125000000000000000000000000000000000000000000000000e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;234567890125000000000000000000000000000000000000000000000000e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;234567890125000000000000000000000000000000000000000000000000e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.234567890125000000000000000000000000000000000000000000000000e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.234567890125000000000000000000000000000000000000000000000000e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.234567890125000000000000000000000000000000000000000000000000e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.234567890125000000000000000000000000000000000000000000000000e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;234567890125000000000000000000000000000000000000000000000000e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;234567890125000000000000000000000000000000000000000000000000e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;234567890125000000000000000000000000000000000000000000000000e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;234567890125000000000000000000000000000000000000000000000000e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ uppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.234567890125000000000000000000000000000000000000000000000000E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.234567890125000000000000000000000000000000000000000000000000E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.234567890125000000000000000000000000000000000000000000000000E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.234567890125000000000000000000000000000000000000000000000000E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;234567890125000000000000000000000000000000000000000000000000E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;234567890125000000000000000000000000000000000000000000000000E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;234567890125000000000000000000000000000000000000000000000000E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;234567890125000000000000000000000000000000000000000000000000E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.234567890125000000000000000000000000000000000000000000000000E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.234567890125000000000000000000000000000000000000000000000000E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.234567890125000000000000000000000000000000000000000000000000E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.234567890125000000000000000000000000000000000000000000000000E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;234567890125000000000000000000000000000000000000000000000000E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;234567890125000000000000000000000000000000000000000000000000E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;234567890125000000000000000000000000000000000000000000000000E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;234567890125000000000000000000000000000000000000000000000000E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+void test7()
+{
+ char str[200];
+ output_iterator<char*> iter;
+ std::locale lc = std::locale::classic();
+ std::locale lg(lc, new my_numpunct);
+ const my_facet f(1);
+ {
+ double v = -0.;
+ std::ios ios(0);
+ hexfloat(ios);
+ // %a
+ {
+ ios.precision(0);
+ {
+ nouppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0p+0******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************-0x0p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-******************0x0p+0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0p+0******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************-0x0p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-******************0x0p+0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0.p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0.p+0*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0x0.p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0x0.p+0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0;p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0;p+0*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0x0;p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0x0;p+0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0p+0******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************-0x0p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-******************0x0p+0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0p+0******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************-0x0p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-******************0x0p+0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0.p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0.p+0*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0x0.p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0x0.p+0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0;p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0;p+0*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0x0;p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0x0;p+0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ uppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0P+0******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************-0X0P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-******************0X0P+0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0P+0******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************-0X0P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-******************0X0P+0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0.P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0.P+0*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0X0.P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0X0.P+0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0;P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0;P+0*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0X0;P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0X0;P+0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0P+0******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************-0X0P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-******************0X0P+0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0P+0******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************-0X0P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-******************0X0P+0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0.P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0.P+0*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0X0.P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0X0.P+0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0;P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0;P+0*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0X0;P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0X0;P+0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ }
+ ios.precision(1);
+ {
+ nouppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0p+0******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************-0x0p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-******************0x0p+0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0p+0******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************-0x0p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-******************0x0p+0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0.p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0.p+0*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0x0.p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0x0.p+0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0;p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0;p+0*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0x0;p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0x0;p+0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0p+0******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************-0x0p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-******************0x0p+0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0p+0******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************-0x0p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-******************0x0p+0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0.p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0.p+0*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0x0.p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0x0.p+0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0;p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0;p+0*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0x0;p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0x0;p+0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ uppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0P+0******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************-0X0P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-******************0X0P+0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0P+0******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************-0X0P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-******************0X0P+0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0.P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0.P+0*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0X0.P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0X0.P+0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0;P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0;P+0*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0X0;P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0X0;P+0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0P+0******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************-0X0P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-******************0X0P+0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0P+0******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************-0X0P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-******************0X0P+0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0.P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0.P+0*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0X0.P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0X0.P+0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0;P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0;P+0*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0X0;P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0X0;P+0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ }
+ ios.precision(6);
+ {
+ nouppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0p+0******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************-0x0p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-******************0x0p+0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0p+0******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************-0x0p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-******************0x0p+0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0.p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0.p+0*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0x0.p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0x0.p+0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0;p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0;p+0*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0x0;p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0x0;p+0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0p+0******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************-0x0p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-******************0x0p+0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0p+0******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************-0x0p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-******************0x0p+0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0.p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0.p+0*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0x0.p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0x0.p+0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0;p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0;p+0*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0x0;p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0x0;p+0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ uppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0P+0******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************-0X0P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-******************0X0P+0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0P+0******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************-0X0P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-******************0X0P+0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0.P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0.P+0*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0X0.P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0X0.P+0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0;P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0;P+0*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0X0;P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0X0;P+0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0P+0******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************-0X0P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-******************0X0P+0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0P+0******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************-0X0P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-******************0X0P+0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0.P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0.P+0*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0X0.P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0X0.P+0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0;P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0;P+0*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0X0;P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0X0;P+0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ }
+ ios.precision(16);
+ {
+ }
+ ios.precision(60);
+ {
+ }
+ }
+ }
+}
+
+void test8()
+{
+ char str[200];
+ output_iterator<char*> iter;
+ std::locale lc = std::locale::classic();
+ std::locale lg(lc, new my_numpunct);
+ const my_facet f(1);
+ {
+ double v = 1234567890.125;
+ std::ios ios(0);
+ hexfloat(ios);
+ // %a
+ {
+ ios.precision(0);
+ {
+ nouppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x1.26580b488p+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x1.26580b488p+30********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********0x1.26580b488p+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x********1.26580b488p+30");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x1;26580b488p+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x1;26580b488p+30********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********0x1;26580b488p+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x********1;26580b488p+30");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x1.26580b488p+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x1.26580b488p+30********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********0x1.26580b488p+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x********1.26580b488p+30");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x1;26580b488p+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x1;26580b488p+30********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********0x1;26580b488p+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x********1;26580b488p+30");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0x1.26580b488p+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0x1.26580b488p+30*******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******+0x1.26580b488p+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*******0x1.26580b488p+30");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0x1;26580b488p+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0x1;26580b488p+30*******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******+0x1;26580b488p+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*******0x1;26580b488p+30");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0x1.26580b488p+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0x1.26580b488p+30*******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******+0x1.26580b488p+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*******0x1.26580b488p+30");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0x1;26580b488p+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0x1;26580b488p+30*******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******+0x1;26580b488p+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*******0x1;26580b488p+30");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ uppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0X1.26580B488P+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0X1.26580B488P+30********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********0X1.26580B488P+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0X********1.26580B488P+30");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0X1;26580B488P+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0X1;26580B488P+30********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********0X1;26580B488P+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0X********1;26580B488P+30");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0X1.26580B488P+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0X1.26580B488P+30********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********0X1.26580B488P+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0X********1.26580B488P+30");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0X1;26580B488P+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0X1;26580B488P+30********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********0X1;26580B488P+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0X********1;26580B488P+30");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0X1.26580B488P+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0X1.26580B488P+30*******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******+0X1.26580B488P+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*******0X1.26580B488P+30");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0X1;26580B488P+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0X1;26580B488P+30*******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******+0X1;26580B488P+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*******0X1;26580B488P+30");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0X1.26580B488P+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0X1.26580B488P+30*******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******+0X1.26580B488P+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*******0X1.26580B488P+30");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0X1;26580B488P+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0X1;26580B488P+30*******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******+0X1;26580B488P+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*******0X1;26580B488P+30");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ }
+ ios.precision(1);
+ {
+ nouppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x1.26580b488p+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x1.26580b488p+30********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********0x1.26580b488p+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x********1.26580b488p+30");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x1;26580b488p+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x1;26580b488p+30********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********0x1;26580b488p+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x********1;26580b488p+30");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x1.26580b488p+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x1.26580b488p+30********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********0x1.26580b488p+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x********1.26580b488p+30");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x1;26580b488p+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x1;26580b488p+30********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********0x1;26580b488p+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x********1;26580b488p+30");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0x1.26580b488p+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0x1.26580b488p+30*******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******+0x1.26580b488p+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*******0x1.26580b488p+30");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0x1;26580b488p+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0x1;26580b488p+30*******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******+0x1;26580b488p+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*******0x1;26580b488p+30");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0x1.26580b488p+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0x1.26580b488p+30*******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******+0x1.26580b488p+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*******0x1.26580b488p+30");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0x1;26580b488p+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0x1;26580b488p+30*******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******+0x1;26580b488p+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*******0x1;26580b488p+30");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ uppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0X1.26580B488P+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0X1.26580B488P+30********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********0X1.26580B488P+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0X********1.26580B488P+30");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0X1;26580B488P+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0X1;26580B488P+30********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********0X1;26580B488P+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0X********1;26580B488P+30");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0X1.26580B488P+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0X1.26580B488P+30********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********0X1.26580B488P+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0X********1.26580B488P+30");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0X1;26580B488P+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0X1;26580B488P+30********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********0X1;26580B488P+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0X********1;26580B488P+30");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0X1.26580B488P+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0X1.26580B488P+30*******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******+0X1.26580B488P+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*******0X1.26580B488P+30");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0X1;26580B488P+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0X1;26580B488P+30*******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******+0X1;26580B488P+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*******0X1;26580B488P+30");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0X1.26580B488P+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0X1.26580B488P+30*******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******+0X1.26580B488P+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*******0X1.26580B488P+30");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0X1;26580B488P+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0X1;26580B488P+30*******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******+0X1;26580B488P+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*******0X1;26580B488P+30");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ }
+ ios.precision(6);
+ {
+ }
+ ios.precision(16);
+ {
+ }
+ ios.precision(60);
+ {
+ nouppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x1.26580b488p+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x1.26580b488p+30********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********0x1.26580b488p+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x********1.26580b488p+30");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x1;26580b488p+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x1;26580b488p+30********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********0x1;26580b488p+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x********1;26580b488p+30");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x1.26580b488p+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x1.26580b488p+30********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********0x1.26580b488p+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x********1.26580b488p+30");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x1;26580b488p+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x1;26580b488p+30********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********0x1;26580b488p+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x********1;26580b488p+30");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0x1.26580b488p+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0x1.26580b488p+30*******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******+0x1.26580b488p+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*******0x1.26580b488p+30");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0x1;26580b488p+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0x1;26580b488p+30*******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******+0x1;26580b488p+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*******0x1;26580b488p+30");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0x1.26580b488p+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0x1.26580b488p+30*******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******+0x1.26580b488p+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*******0x1.26580b488p+30");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0x1;26580b488p+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0x1;26580b488p+30*******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******+0x1;26580b488p+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*******0x1;26580b488p+30");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ uppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0X1.26580B488P+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0X1.26580B488P+30********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********0X1.26580B488P+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0X********1.26580B488P+30");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0X1;26580B488P+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0X1;26580B488P+30********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********0X1;26580B488P+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0X********1;26580B488P+30");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0X1.26580B488P+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0X1.26580B488P+30********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********0X1.26580B488P+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0X********1.26580B488P+30");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0X1;26580B488P+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0X1;26580B488P+30********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********0X1;26580B488P+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0X********1;26580B488P+30");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0X1.26580B488P+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0X1.26580B488P+30*******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******+0X1.26580B488P+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*******0X1.26580B488P+30");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0X1;26580B488P+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0X1;26580B488P+30*******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******+0X1;26580B488P+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*******0X1;26580B488P+30");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0X1.26580B488P+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0X1.26580B488P+30*******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******+0X1.26580B488P+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*******0X1.26580B488P+30");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0X1;26580B488P+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0X1;26580B488P+30*******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******+0X1;26580B488P+30");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*******0X1;26580B488P+30");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+int main()
+{
+ test1();
+ test2();
+ test3();
+ test4();
+ test5();
+ test6();
+ test7();
+ test8();
+}
diff --git a/test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long.pass.cpp b/test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long.pass.cpp
new file mode 100644
index 000000000000..4085f08c7420
--- /dev/null
+++ b/test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long.pass.cpp
@@ -0,0 +1,371 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class num_put<charT, OutputIterator>
+
+// iter_type put(iter_type s, ios_base& iob, char_type fill, long v) const;
+
+#include <locale>
+#include <ios>
+#include <cassert>
+#include <streambuf>
+#include "test_iterators.h"
+
+typedef std::num_put<char, output_iterator<char*> > F;
+
+class my_facet
+ : public F
+{
+public:
+ explicit my_facet(std::size_t refs = 0)
+ : F(refs) {}
+};
+
+class my_numpunct
+ : public std::numpunct<char>
+{
+public:
+ my_numpunct() : std::numpunct<char>() {}
+
+protected:
+ virtual char_type do_thousands_sep() const {return '_';}
+ virtual std::string do_grouping() const {return std::string("\1\2\3");}
+};
+
+int main()
+{
+ const my_facet f(1);
+ {
+ std::ios ios(0);
+ long v = 0;
+ char str[50];
+ std::ios_base::iostate err = ios.goodbit;
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0");
+ }
+ {
+ std::ios ios(0);
+ long v = 1;
+ char str[50];
+ std::ios_base::iostate err = ios.goodbit;
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1");
+ }
+ {
+ std::ios ios(0);
+ long v = -1;
+ char str[50];
+ std::ios_base::iostate err = ios.goodbit;
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-1");
+ }
+ {
+ std::ios ios(0);
+ long v = -1000;
+ char str[50];
+ std::ios_base::iostate err = ios.goodbit;
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-1000");
+ }
+ {
+ std::ios ios(0);
+ long v = 1000;
+ char str[50];
+ std::ios_base::iostate err = ios.goodbit;
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1000");
+ }
+ {
+ std::ios ios(0);
+ showpos(ios);
+ long v = 1000;
+ char str[50];
+ std::ios_base::iostate err = ios.goodbit;
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1000");
+ }
+ {
+ std::ios ios(0);
+ oct(ios);
+ long v = 1000;
+ char str[50];
+ std::ios_base::iostate err = ios.goodbit;
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1750");
+ }
+ {
+ std::ios ios(0);
+ oct(ios);
+ showbase(ios);
+ long v = 1000;
+ char str[50];
+ std::ios_base::iostate err = ios.goodbit;
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "01750");
+ }
+ {
+ std::ios ios(0);
+ hex(ios);
+ long v = 1000;
+ char str[50];
+ std::ios_base::iostate err = ios.goodbit;
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "3e8");
+ }
+ {
+ std::ios ios(0);
+ hex(ios);
+ showbase(ios);
+ long v = 1000;
+ char str[50];
+ std::ios_base::iostate err = ios.goodbit;
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x3e8");
+ }
+ {
+ std::ios ios(0);
+ hex(ios);
+ showbase(ios);
+ uppercase(ios);
+ long v = 1000;
+ char str[50];
+ std::ios_base::iostate err = ios.goodbit;
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0X3E8");
+ }
+ {
+ std::ios ios(0);
+ ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+ hex(ios);
+ showbase(ios);
+ uppercase(ios);
+ long v = 1000;
+ char str[50];
+ std::ios_base::iostate err = ios.goodbit;
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0X3E_8");
+ }
+ {
+ std::ios ios(0);
+ ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+ hex(ios);
+ showbase(ios);
+ long v = 2147483647;
+ char str[50];
+ std::ios_base::iostate err = ios.goodbit;
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x7f_fff_ff_f");
+ }
+ {
+ std::ios ios(0);
+ ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+ oct(ios);
+ long v = 0123467;
+ char str[50];
+ std::ios_base::iostate err = ios.goodbit;
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "123_46_7");
+ }
+ {
+ std::ios ios(0);
+ ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+ oct(ios);
+ showbase(ios);
+ long v = 0123467;
+ char str[50];
+ std::ios_base::iostate err = ios.goodbit;
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0_123_46_7");
+ }
+ {
+ std::ios ios(0);
+ ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+ oct(ios);
+ showbase(ios);
+ right(ios);
+ ios.width(15);
+ long v = 0123467;
+ char str[50];
+ std::ios_base::iostate err = ios.goodbit;
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****0_123_46_7");
+ }
+ {
+ std::ios ios(0);
+ ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+ oct(ios);
+ showbase(ios);
+ left(ios);
+ ios.width(15);
+ long v = 0123467;
+ char str[50];
+ std::ios_base::iostate err = ios.goodbit;
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0_123_46_7*****");
+ }
+ {
+ std::ios ios(0);
+ ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+ oct(ios);
+ showbase(ios);
+ internal(ios);
+ ios.width(15);
+ long v = 0123467;
+ char str[50];
+ std::ios_base::iostate err = ios.goodbit;
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****0_123_46_7");
+ assert(ios.width() == 0);
+ }
+ {
+ std::ios ios(0);
+ ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+ hex(ios);
+ showbase(ios);
+ right(ios);
+ ios.width(15);
+ long v = 2147483647;
+ char str[50];
+ std::ios_base::iostate err = ios.goodbit;
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**0x7f_fff_ff_f");
+ }
+ {
+ std::ios ios(0);
+ ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+ hex(ios);
+ showbase(ios);
+ left(ios);
+ ios.width(15);
+ long v = 2147483647;
+ char str[50];
+ std::ios_base::iostate err = ios.goodbit;
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x7f_fff_ff_f**");
+ }
+ {
+ std::ios ios(0);
+ ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+ hex(ios);
+ showbase(ios);
+ internal(ios);
+ ios.width(15);
+ long v = 2147483647;
+ char str[50];
+ std::ios_base::iostate err = ios.goodbit;
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x**7f_fff_ff_f");
+ assert(ios.width() == 0);
+ }
+ {
+ std::ios ios(0);
+ ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+ showpos(ios);
+ long v = 1000;
+ right(ios);
+ ios.width(10);
+ char str[50];
+ std::ios_base::iostate err = ios.goodbit;
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***+1_00_0");
+ assert(ios.width() == 0);
+ }
+ {
+ std::ios ios(0);
+ ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+ showpos(ios);
+ long v = 1000;
+ left(ios);
+ ios.width(10);
+ char str[50];
+ std::ios_base::iostate err = ios.goodbit;
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_00_0***");
+ assert(ios.width() == 0);
+ }
+ {
+ std::ios ios(0);
+ ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+ showpos(ios);
+ long v = 1000;
+ internal(ios);
+ ios.width(10);
+ char str[50];
+ std::ios_base::iostate err = ios.goodbit;
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+***1_00_0");
+ assert(ios.width() == 0);
+ }
+ {
+ std::ios ios(0);
+ ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+ long v = -1000;
+ right(ios);
+ showpos(ios);
+ ios.width(10);
+ char str[50];
+ std::ios_base::iostate err = ios.goodbit;
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***-1_00_0");
+ assert(ios.width() == 0);
+ }
+ {
+ std::ios ios(0);
+ ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+ long v = -1000;
+ left(ios);
+ ios.width(10);
+ char str[50];
+ std::ios_base::iostate err = ios.goodbit;
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-1_00_0***");
+ assert(ios.width() == 0);
+ }
+ {
+ std::ios ios(0);
+ ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+ long v = -1000;
+ internal(ios);
+ ios.width(10);
+ char str[50];
+ std::ios_base::iostate err = ios.goodbit;
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-***1_00_0");
+ assert(ios.width() == 0);
+ }
+}
diff --git a/test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long_double.pass.cpp b/test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long_double.pass.cpp
new file mode 100644
index 000000000000..935961257ef2
--- /dev/null
+++ b/test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long_double.pass.cpp
@@ -0,0 +1,26248 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class num_put<charT, OutputIterator>
+
+// iter_type put(iter_type s, ios_base& iob, char_type fill, long double v) const;
+
+// TODO GLIBC uses a different string for positive and negative NAN numbers.
+// XFAIL: linux-gnu
+
+#include <locale>
+#include <ios>
+#include <cassert>
+#include <streambuf>
+#include <cmath>
+#include "test_iterators.h"
+
+typedef std::num_put<char, output_iterator<char*> > F;
+
+class my_facet
+ : public F
+{
+public:
+ explicit my_facet(std::size_t refs = 0)
+ : F(refs) {}
+};
+
+class my_numpunct
+ : public std::numpunct<char>
+{
+public:
+ my_numpunct() : std::numpunct<char>() {}
+
+protected:
+ virtual char_type do_decimal_point() const {return ';';}
+ virtual char_type do_thousands_sep() const {return '_';}
+ virtual std::string do_grouping() const {return std::string("\1\2\3");}
+};
+
+void test1()
+{
+ char str[200];
+ output_iterator<char*> iter;
+ std::locale lc = std::locale::classic();
+ std::locale lg(lc, new my_numpunct);
+ const my_facet f(1);
+ {
+ long double v = +0.;
+ std::ios ios(0);
+ // %g
+ {
+ ios.precision(0);
+ {
+ nouppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0************************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0************************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************0.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************0.");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************0;");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.**********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************+0.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+**********************0.");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;**********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************+0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+**********************0;");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ uppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0************************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0************************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************0.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************0.");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************0;");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.**********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************+0.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+**********************0.");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;**********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************+0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+**********************0;");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ }
+ ios.precision(1);
+ {
+ nouppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0************************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0************************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************0.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************0.");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************0;");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.**********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************+0.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+**********************0.");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;**********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************+0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+**********************0;");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ uppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0************************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0************************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************0.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************0.");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************0;");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.**********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************+0.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+**********************0.");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;**********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************+0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+**********************0;");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ }
+ ios.precision(6);
+ {
+ nouppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0************************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0************************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.00000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.00000******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************0.00000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************0.00000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;00000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;00000******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************0;00000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************0;00000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.00000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.00000*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************+0.00000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*****************0.00000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;00000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;00000*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************+0;00000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*****************0;00000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ uppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0************************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0************************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.00000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.00000******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************0.00000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************0.00000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;00000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;00000******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************0;00000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************0;00000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.00000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.00000*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************+0.00000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*****************0.00000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;00000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;00000*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************+0;00000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*****************0;00000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ }
+ ios.precision(16);
+ {
+ nouppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0************************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0************************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.000000000000000********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********0.000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********0.000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;000000000000000********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********0;000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********0;000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.000000000000000*******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******+0.000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*******0.000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;000000000000000*******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******+0;000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*******0;000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ uppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0************************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0************************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.000000000000000********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********0.000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********0.000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;000000000000000********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********0;000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********0;000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.000000000000000*******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******+0.000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*******0.000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;000000000000000*******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******+0;000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*******0;000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ }
+ ios.precision(60);
+ {
+ nouppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0************************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0************************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ uppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0************************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0************************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+void test2()
+{
+ char str[200];
+ output_iterator<char*> iter;
+ std::locale lc = std::locale::classic();
+ std::locale lg(lc, new my_numpunct);
+ const my_facet f(1);
+ {
+ long double v = -0.;
+ std::ios ios(0);
+ // %g
+ {
+ ios.precision(0);
+ {
+ nouppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.**********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************-0.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-**********************0.");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;**********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************-0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-**********************0;");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.**********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************-0.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-**********************0.");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;**********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************-0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-**********************0;");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ uppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.**********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************-0.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-**********************0.");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;**********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************-0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-**********************0;");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.**********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************-0.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-**********************0.");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;**********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************-0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-**********************0;");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ }
+ ios.precision(1);
+ {
+ nouppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.**********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************-0.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-**********************0.");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;**********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************-0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-**********************0;");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.**********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************-0.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-**********************0.");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;**********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************-0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-**********************0;");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ uppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.**********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************-0.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-**********************0.");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;**********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************-0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-**********************0;");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.**********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************-0.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-**********************0.");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;**********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************-0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-**********************0;");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ }
+ ios.precision(6);
+ {
+ nouppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.00000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.00000*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0.00000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0.00000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;00000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;00000*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0;00000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0;00000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.00000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.00000*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0.00000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0.00000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;00000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;00000*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0;00000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0;00000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ uppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.00000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.00000*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0.00000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0.00000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;00000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;00000*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0;00000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0;00000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.00000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.00000*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0.00000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0.00000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;00000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;00000*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0;00000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0;00000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ }
+ ios.precision(16);
+ {
+ nouppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000000000000*******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******-0.000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*******0.000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000000000000*******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******-0;000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*******0;000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000000000000*******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******-0.000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*******0.000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000000000000*******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******-0;000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*******0;000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ uppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000000000000*******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******-0.000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*******0.000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000000000000*******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******-0;000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*******0;000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000000000000*******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******-0.000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*******0.000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000000000000*******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******-0;000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*******0;000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ }
+ ios.precision(60);
+ {
+ nouppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ uppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;00000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+void test3()
+{
+ char str[200];
+ output_iterator<char*> iter;
+ std::locale lc = std::locale::classic();
+ std::locale lg(lc, new my_numpunct);
+ const my_facet f(1);
+ {
+ long double v = 1234567890.125;
+ std::ios ios(0);
+ // %g
+ {
+ ios.precision(0);
+ {
+ nouppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1e+09********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********************1e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********************1e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1e+09********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********************1e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********************1e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.e+09*******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************1.e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************1.e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;e+09*******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************1;e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************1;e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1e+09*******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************+1e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*******************1e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1e+09*******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************+1e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*******************1e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.e+09******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************+1.e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+******************1.e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;e+09******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************+1;e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+******************1;e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ uppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1E+09********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********************1E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********************1E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1E+09********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********************1E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********************1E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.E+09*******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************1.E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************1.E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;E+09*******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************1;E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************1;E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1E+09*******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************+1E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*******************1E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1E+09*******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************+1E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*******************1E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.E+09******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************+1.E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+******************1.E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;E+09******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************+1;E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+******************1;E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ }
+ ios.precision(1);
+ {
+ nouppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1e+09********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********************1e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********************1e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1e+09********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********************1e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********************1e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.e+09*******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************1.e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************1.e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;e+09*******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************1;e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************1;e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1e+09*******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************+1e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*******************1e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1e+09*******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************+1e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*******************1e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.e+09******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************+1.e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+******************1.e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;e+09******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************+1;e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+******************1;e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ uppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1E+09********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********************1E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********************1E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1E+09********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********************1E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********************1E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.E+09*******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************1.E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************1.E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;E+09*******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************1;E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************1;E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1E+09*******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************+1E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*******************1E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1E+09*******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************+1E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*******************1E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.E+09******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************+1.E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+******************1.E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;E+09******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************+1;E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+******************1;E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ }
+ ios.precision(6);
+ {
+ nouppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.23457e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.23457e+09**************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**************1.23457e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**************1.23457e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;23457e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;23457e+09**************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**************1;23457e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**************1;23457e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.23457e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.23457e+09**************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**************1.23457e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**************1.23457e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;23457e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;23457e+09**************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**************1;23457e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**************1;23457e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.23457e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.23457e+09*************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*************+1.23457e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*************1.23457e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;23457e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;23457e+09*************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*************+1;23457e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*************1;23457e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.23457e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.23457e+09*************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*************+1.23457e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*************1.23457e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;23457e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;23457e+09*************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*************+1;23457e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*************1;23457e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ uppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.23457E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.23457E+09**************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**************1.23457E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**************1.23457E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;23457E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;23457E+09**************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**************1;23457E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**************1;23457E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.23457E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.23457E+09**************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**************1.23457E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**************1.23457E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;23457E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;23457E+09**************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**************1;23457E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**************1;23457E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.23457E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.23457E+09*************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*************+1.23457E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*************1.23457E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;23457E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;23457E+09*************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*************+1;23457E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*************1;23457E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.23457E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.23457E+09*************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*************+1.23457E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*************1.23457E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;23457E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;23457E+09*************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*************+1;23457E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*************1;23457E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ }
+ ios.precision(16);
+ {
+ nouppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890.125");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890.125***********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********1234567890.125");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********1234567890.125");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0;125");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0;125*******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******1_234_567_89_0;125");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******1_234_567_89_0;125");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890.125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890.125000********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********1234567890.125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********1234567890.125000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0;125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0;125000****");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "****1_234_567_89_0;125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "****1_234_567_89_0;125000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890.125");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890.125**********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********+1234567890.125");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+**********1234567890.125");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0;125");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0;125******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******+1_234_567_89_0;125");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+******1_234_567_89_0;125");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890.125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890.125000*******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******+1234567890.125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*******1234567890.125000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0;125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0;125000***");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***+1_234_567_89_0;125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+***1_234_567_89_0;125000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ uppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890.125");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890.125***********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********1234567890.125");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********1234567890.125");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0;125");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0;125*******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******1_234_567_89_0;125");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******1_234_567_89_0;125");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890.125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890.125000********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********1234567890.125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********1234567890.125000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0;125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0;125000****");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "****1_234_567_89_0;125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "****1_234_567_89_0;125000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890.125");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890.125**********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********+1234567890.125");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+**********1234567890.125");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0;125");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0;125******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******+1_234_567_89_0;125");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+******1_234_567_89_0;125");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890.125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890.125000*******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******+1234567890.125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*******1234567890.125000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0;125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0;125000***");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***+1_234_567_89_0;125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+***1_234_567_89_0;125000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ }
+ ios.precision(60);
+ {
+ nouppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890.125");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890.125***********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********1234567890.125");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********1234567890.125");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0;125");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0;125*******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******1_234_567_89_0;125");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******1_234_567_89_0;125");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890.12500000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890.12500000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890.12500000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890.12500000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890.125");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890.125**********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********+1234567890.125");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+**********1234567890.125");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0;125");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0;125******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******+1_234_567_89_0;125");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+******1_234_567_89_0;125");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890.12500000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890.12500000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890.12500000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890.12500000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ uppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890.125");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890.125***********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********1234567890.125");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********1234567890.125");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0;125");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0;125*******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******1_234_567_89_0;125");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******1_234_567_89_0;125");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890.12500000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890.12500000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890.12500000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890.12500000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890.125");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890.125**********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********+1234567890.125");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+**********1234567890.125");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0;125");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0;125******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******+1_234_567_89_0;125");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+******1_234_567_89_0;125");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890.12500000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890.12500000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890.12500000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890.12500000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+void test4()
+{
+ char str[200];
+ output_iterator<char*> iter;
+ std::locale lc = std::locale::classic();
+ std::locale lg(lc, new my_numpunct);
+ const my_facet f(1);
+ {
+ long double v = -INFINITY;
+ std::ios ios(0);
+ // %g
+ {
+ ios.precision(0);
+ {
+ nouppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-inf");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-inf*********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********************-inf");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*********************inf");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-inf");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-inf*********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********************-inf");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*********************inf");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-inf");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-inf*********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********************-inf");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*********************inf");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-inf");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-inf*********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********************-inf");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*********************inf");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-inf");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-inf*********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********************-inf");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*********************inf");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-inf");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-inf*********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********************-inf");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*********************inf");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-inf");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-inf*********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********************-inf");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*********************inf");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-inf");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-inf*********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********************-inf");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*********************inf");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ uppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-INF");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-INF*********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********************-INF");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*********************INF");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-INF");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-INF*********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********************-INF");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*********************INF");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-INF");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-INF*********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********************-INF");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*********************INF");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-INF");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-INF*********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********************-INF");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*********************INF");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-INF");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-INF*********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********************-INF");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*********************INF");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-INF");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-INF*********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********************-INF");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*********************INF");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-INF");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-INF*********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********************-INF");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*********************INF");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-INF");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-INF*********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********************-INF");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*********************INF");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ }
+ ios.precision(1);
+ {
+ nouppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-inf");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-inf*********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********************-inf");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*********************inf");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-inf");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-inf*********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********************-inf");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*********************inf");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-inf");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-inf*********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********************-inf");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*********************inf");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-inf");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-inf*********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********************-inf");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*********************inf");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-inf");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-inf*********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********************-inf");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*********************inf");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-inf");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-inf*********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********************-inf");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*********************inf");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-inf");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-inf*********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********************-inf");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*********************inf");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-inf");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-inf*********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********************-inf");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*********************inf");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ uppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-INF");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-INF*********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********************-INF");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*********************INF");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-INF");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-INF*********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********************-INF");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*********************INF");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-INF");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-INF*********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********************-INF");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*********************INF");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-INF");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-INF*********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********************-INF");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*********************INF");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-INF");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-INF*********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********************-INF");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*********************INF");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-INF");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-INF*********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********************-INF");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*********************INF");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-INF");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-INF*********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********************-INF");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*********************INF");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-INF");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-INF*********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********************-INF");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*********************INF");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ }
+ ios.precision(6);
+ {
+ nouppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-inf");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-inf*********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********************-inf");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*********************inf");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-inf");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-inf*********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********************-inf");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*********************inf");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-inf");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-inf*********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********************-inf");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*********************inf");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-inf");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-inf*********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********************-inf");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*********************inf");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-inf");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-inf*********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********************-inf");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*********************inf");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-inf");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-inf*********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********************-inf");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*********************inf");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-inf");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-inf*********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********************-inf");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*********************inf");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-inf");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-inf*********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********************-inf");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*********************inf");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ uppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-INF");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-INF*********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********************-INF");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*********************INF");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-INF");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-INF*********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********************-INF");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*********************INF");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-INF");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-INF*********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********************-INF");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*********************INF");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-INF");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-INF*********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********************-INF");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*********************INF");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-INF");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-INF*********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********************-INF");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*********************INF");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-INF");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-INF*********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********************-INF");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*********************INF");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-INF");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-INF*********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********************-INF");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*********************INF");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-INF");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-INF*********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********************-INF");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*********************INF");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ }
+ ios.precision(16);
+ {}
+ ios.precision(60);
+ {}
+ }
+ }
+}
+
+void test5()
+{
+ char str[200];
+ output_iterator<char*> iter;
+ std::locale lc = std::locale::classic();
+ std::locale lg(lc, new my_numpunct);
+ const my_facet f(1);
+ {
+ long double v = std::nan("");
+ std::ios ios(0);
+ // %g
+ {
+ ios.precision(0);
+ {
+ nouppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "nan");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "nan**********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************nan");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************nan");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "nan");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "nan**********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************nan");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************nan");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "nan");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "nan**********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************nan");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************nan");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "nan");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "nan**********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************nan");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************nan");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "nan");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "nan**********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************nan");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************nan");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "nan");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "nan**********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************nan");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************nan");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "nan");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "nan**********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************nan");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************nan");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "nan");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "nan**********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************nan");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************nan");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ uppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "NAN");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "NAN**********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************NAN");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************NAN");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "NAN");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "NAN**********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************NAN");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************NAN");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "NAN");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "NAN**********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************NAN");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************NAN");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "NAN");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "NAN**********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************NAN");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************NAN");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "NAN");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "NAN**********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************NAN");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************NAN");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "NAN");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "NAN**********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************NAN");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************NAN");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "NAN");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "NAN**********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************NAN");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************NAN");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "NAN");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "NAN**********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************NAN");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************NAN");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ }
+ ios.precision(1);
+ {}
+ ios.precision(6);
+ {}
+ ios.precision(16);
+ {}
+ ios.precision(60);
+ {}
+ }
+ }
+}
+
+void test6()
+{
+ char str[200];
+ output_iterator<char*> iter;
+ std::locale lc = std::locale::classic();
+ std::locale lg(lc, new my_numpunct);
+ const my_facet f(1);
+ {
+ long double v = +0.;
+ std::ios ios(0);
+ fixed(ios);
+ // %f
+ {
+ ios.precision(0);
+ {
+ nouppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0************************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0************************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************0.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************0.");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************0;");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.**********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************+0.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+**********************0.");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;**********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************+0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+**********************0;");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ uppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0************************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0************************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************************0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************0.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************0.");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************0;");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.**********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************+0.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+**********************0.");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;**********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************+0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+**********************0;");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ }
+ ios.precision(1);
+ {
+ nouppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.0**********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************0.0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************0.0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;0**********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************0;0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************0;0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.0**********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************0.0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************0.0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;0**********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************0;0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************0;0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.0*********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********************+0.0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*********************0.0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;0*********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********************+0;0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*********************0;0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.0*********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********************+0.0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*********************0.0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;0*********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********************+0;0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*********************0;0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ uppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.0**********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************0.0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************0.0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;0**********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************0;0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************0;0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.0**********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************0.0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************0.0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;0**********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************0;0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************0;0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.0*********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********************+0.0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*********************0.0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;0*********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********************+0;0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*********************0;0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.0*********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********************+0.0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*********************0.0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;0*********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********************+0;0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*********************0;0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ }
+ ios.precision(6);
+ {
+ nouppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.000000*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************0.000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************0.000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;000000*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************0;000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************0;000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.000000*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************0.000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************0.000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;000000*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************0;000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************0;000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.000000****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "****************+0.000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+****************0.000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;000000****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "****************+0;000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+****************0;000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.000000****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "****************+0.000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+****************0.000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;000000****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "****************+0;000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+****************0;000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ uppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.000000*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************0.000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************0.000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;000000*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************0;000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************0;000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.000000*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************0.000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************0.000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;000000*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************0;000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************0;000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.000000****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "****************+0.000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+****************0.000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;000000****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "****************+0;000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+****************0;000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.000000****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "****************+0.000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+****************0.000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;000000****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "****************+0;000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+****************0;000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ }
+ ios.precision(16);
+ {
+ nouppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.0000000000000000*******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******0.0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******0.0000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;0000000000000000*******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******0;0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******0;0000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.0000000000000000*******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******0.0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******0.0000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;0000000000000000*******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******0;0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******0;0000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.0000000000000000******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******+0.0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+******0.0000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;0000000000000000******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******+0;0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+******0;0000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.0000000000000000******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******+0.0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+******0.0000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;0000000000000000******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******+0;0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+******0;0000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ uppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.0000000000000000*******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******0.0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******0.0000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;0000000000000000*******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******0;0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******0;0000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.0000000000000000*******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******0.0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******0.0000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;0000000000000000*******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******0;0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******0;0000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.0000000000000000******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******+0.0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+******0.0000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;0000000000000000******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******+0;0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+******0;0000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.0000000000000000******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******+0.0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+******0.0000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;0000000000000000******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******+0;0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+******0;0000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ }
+ ios.precision(60);
+ {
+ nouppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ uppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+void test7()
+{
+ char str[200];
+ output_iterator<char*> iter;
+ std::locale lc = std::locale::classic();
+ std::locale lg(lc, new my_numpunct);
+ const my_facet f(1);
+ {
+ long double v = -0.;
+ std::ios ios(0);
+ fixed(ios);
+ // %f
+ {
+ ios.precision(0);
+ {
+ nouppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.**********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************-0.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-**********************0.");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;**********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************-0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-**********************0;");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.**********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************-0.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-**********************0.");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;**********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************-0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-**********************0;");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ uppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.**********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************-0.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-**********************0.");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;**********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************-0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-**********************0;");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0***********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********************-0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-***********************0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.**********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************-0.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-**********************0.");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;**********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********************-0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-**********************0;");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ }
+ ios.precision(1);
+ {
+ nouppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.0*********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********************-0.0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*********************0.0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;0*********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********************-0;0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*********************0;0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.0*********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********************-0.0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*********************0.0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;0*********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********************-0;0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*********************0;0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.0*********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********************-0.0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*********************0.0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;0*********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********************-0;0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*********************0;0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.0*********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********************-0.0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*********************0.0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;0*********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********************-0;0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*********************0;0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ uppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.0*********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********************-0.0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*********************0.0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;0*********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********************-0;0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*********************0;0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.0*********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********************-0.0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*********************0.0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;0*********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********************-0;0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*********************0;0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.0*********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********************-0.0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*********************0.0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;0*********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********************-0;0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*********************0;0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.0*********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********************-0.0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*********************0.0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;0*********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********************-0;0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*********************0;0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ }
+ ios.precision(6);
+ {
+ nouppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "****************-0.000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-****************0.000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "****************-0;000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-****************0;000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "****************-0.000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-****************0.000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "****************-0;000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-****************0;000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "****************-0.000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-****************0.000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "****************-0;000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-****************0;000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "****************-0.000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-****************0.000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "****************-0;000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-****************0;000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ uppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "****************-0.000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-****************0.000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "****************-0;000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-****************0;000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "****************-0.000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-****************0.000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "****************-0;000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-****************0;000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "****************-0.000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-****************0.000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "****************-0;000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-****************0;000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "****************-0.000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-****************0.000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "****************-0;000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-****************0;000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ }
+ ios.precision(16);
+ {
+ nouppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.0000000000000000******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******-0.0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-******0.0000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;0000000000000000******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******-0;0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-******0;0000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.0000000000000000******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******-0.0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-******0.0000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;0000000000000000******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******-0;0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-******0;0000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.0000000000000000******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******-0.0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-******0.0000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;0000000000000000******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******-0;0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-******0;0000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.0000000000000000******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******-0.0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-******0.0000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;0000000000000000******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******-0;0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-******0;0000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ uppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.0000000000000000******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******-0.0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-******0.0000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;0000000000000000******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******-0;0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-******0;0000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.0000000000000000******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******-0.0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-******0.0000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;0000000000000000******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******-0;0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-******0;0000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.0000000000000000******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******-0.0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-******0.0000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;0000000000000000******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******-0;0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-******0;0000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.0000000000000000******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******-0.0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-******0.0000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;0000000000000000******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******-0;0000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-******0;0000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ }
+ ios.precision(60);
+ {
+ nouppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ uppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+void test8()
+{
+ char str[200];
+ output_iterator<char*> iter;
+ std::locale lc = std::locale::classic();
+ std::locale lg(lc, new my_numpunct);
+ const my_facet f(1);
+ {
+ long double v = 1234567890.125;
+ std::ios ios(0);
+ fixed(ios);
+ // %f
+ {
+ ios.precision(0);
+ {
+ nouppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890***************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***************1234567890");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***************1234567890");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0***********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********1_234_567_89_0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********1_234_567_89_0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890.**************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**************1234567890.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**************1234567890.");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0;**********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********1_234_567_89_0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********1_234_567_89_0;");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890**************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**************+1234567890");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+**************1234567890");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0**********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********+1_234_567_89_0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+**********1_234_567_89_0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890.*************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*************+1234567890.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*************1234567890.");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0;*********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********+1_234_567_89_0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*********1_234_567_89_0;");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ uppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890***************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***************1234567890");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***************1234567890");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0***********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********1_234_567_89_0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***********1_234_567_89_0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890.**************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**************1234567890.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**************1234567890.");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0;**********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********1_234_567_89_0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********1_234_567_89_0;");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890**************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**************+1234567890");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+**************1234567890");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0**********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**********+1_234_567_89_0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+**********1_234_567_89_0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890.*************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*************+1234567890.");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*************1234567890.");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0;*********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********+1_234_567_89_0;");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*********1_234_567_89_0;");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ }
+ ios.precision(1);
+ {
+ nouppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890.1");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890.1*************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*************1234567890.1");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*************1234567890.1");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0;1");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0;1*********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********1_234_567_89_0;1");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********1_234_567_89_0;1");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890.1");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890.1*************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*************1234567890.1");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*************1234567890.1");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0;1");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0;1*********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********1_234_567_89_0;1");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********1_234_567_89_0;1");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890.1");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890.1************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************+1234567890.1");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+************1234567890.1");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0;1");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0;1********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********+1_234_567_89_0;1");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+********1_234_567_89_0;1");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890.1");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890.1************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************+1234567890.1");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+************1234567890.1");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0;1");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0;1********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********+1_234_567_89_0;1");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+********1_234_567_89_0;1");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ uppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890.1");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890.1*************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*************1234567890.1");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*************1234567890.1");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0;1");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0;1*********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********1_234_567_89_0;1");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********1_234_567_89_0;1");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890.1");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890.1*************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*************1234567890.1");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*************1234567890.1");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0;1");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0;1*********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********1_234_567_89_0;1");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********1_234_567_89_0;1");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890.1");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890.1************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************+1234567890.1");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+************1234567890.1");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0;1");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0;1********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********+1_234_567_89_0;1");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+********1_234_567_89_0;1");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890.1");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890.1************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************+1234567890.1");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+************1234567890.1");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0;1");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0;1********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********+1_234_567_89_0;1");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+********1_234_567_89_0;1");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ }
+ ios.precision(6);
+ {
+ nouppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890.125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890.125000********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********1234567890.125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********1234567890.125000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0;125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0;125000****");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "****1_234_567_89_0;125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "****1_234_567_89_0;125000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890.125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890.125000********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********1234567890.125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********1234567890.125000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0;125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0;125000****");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "****1_234_567_89_0;125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "****1_234_567_89_0;125000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890.125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890.125000*******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******+1234567890.125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*******1234567890.125000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0;125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0;125000***");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***+1_234_567_89_0;125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+***1_234_567_89_0;125000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890.125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890.125000*******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******+1234567890.125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*******1234567890.125000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0;125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0;125000***");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***+1_234_567_89_0;125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+***1_234_567_89_0;125000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ uppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890.125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890.125000********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********1234567890.125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********1234567890.125000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0;125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0;125000****");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "****1_234_567_89_0;125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "****1_234_567_89_0;125000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890.125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1234567890.125000********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********1234567890.125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********1234567890.125000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0;125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_234_567_89_0;125000****");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "****1_234_567_89_0;125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "****1_234_567_89_0;125000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890.125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890.125000*******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******+1234567890.125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*******1234567890.125000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0;125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0;125000***");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***+1_234_567_89_0;125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+***1_234_567_89_0;125000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890.125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1234567890.125000*******");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******+1234567890.125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*******1234567890.125000");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0;125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_234_567_89_0;125000***");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***+1_234_567_89_0;125000");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+***1_234_567_89_0;125000");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ }
+ ios.precision(16);
+ {}
+ ios.precision(60);
+ {}
+ }
+ }
+}
+
+void test9()
+{
+ char str[200];
+ output_iterator<char*> iter;
+ std::locale lc = std::locale::classic();
+ std::locale lg(lc, new my_numpunct);
+ const my_facet f(1);
+ {
+ long double v = -0.;
+ std::ios ios(0);
+ scientific(ios);
+ // %e
+ {
+ ios.precision(0);
+ {
+ nouppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0e+00*******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************-0e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*******************0e+00");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0e+00*******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************-0e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*******************0e+00");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.e+00******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************-0.e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-******************0.e+00");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;e+00******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************-0;e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-******************0;e+00");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0e+00*******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************-0e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*******************0e+00");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0e+00*******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************-0e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*******************0e+00");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.e+00******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************-0.e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-******************0.e+00");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;e+00******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************-0;e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-******************0;e+00");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ uppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0E+00*******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************-0E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*******************0E+00");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0E+00*******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************-0E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*******************0E+00");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.E+00******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************-0.E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-******************0.E+00");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;E+00******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************-0;E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-******************0;E+00");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0E+00*******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************-0E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*******************0E+00");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0E+00*******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************-0E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*******************0E+00");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.E+00******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************-0.E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-******************0.E+00");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;E+00******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************-0;E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-******************0;E+00");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ }
+ ios.precision(1);
+ {
+ nouppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.0e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.0e+00*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0.0e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0.0e+00");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;0e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;0e+00*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0;0e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0;0e+00");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.0e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.0e+00*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0.0e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0.0e+00");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;0e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;0e+00*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0;0e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0;0e+00");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.0e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.0e+00*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0.0e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0.0e+00");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;0e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;0e+00*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0;0e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0;0e+00");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.0e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.0e+00*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0.0e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0.0e+00");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;0e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;0e+00*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0;0e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0;0e+00");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ uppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.0E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.0E+00*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0.0E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0.0E+00");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;0E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;0E+00*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0;0E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0;0E+00");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.0E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.0E+00*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0.0E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0.0E+00");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;0E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;0E+00*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0;0E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0;0E+00");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.0E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.0E+00*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0.0E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0.0E+00");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;0E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;0E+00*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0;0E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0;0E+00");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.0E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.0E+00*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0.0E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0.0E+00");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;0E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;0E+00*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0;0E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0;0E+00");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ }
+ ios.precision(6);
+ {
+ nouppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000e+00************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************-0.000000e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-************0.000000e+00");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000e+00************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************-0;000000e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-************0;000000e+00");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000e+00************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************-0.000000e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-************0.000000e+00");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000e+00************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************-0;000000e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-************0;000000e+00");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000e+00************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************-0.000000e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-************0.000000e+00");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000e+00************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************-0;000000e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-************0;000000e+00");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000e+00************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************-0.000000e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-************0.000000e+00");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000e+00************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************-0;000000e+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-************0;000000e+00");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ uppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000E+00************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************-0.000000E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-************0.000000E+00");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000E+00************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************-0;000000E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-************0;000000E+00");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000E+00************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************-0.000000E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-************0.000000E+00");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000E+00************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************-0;000000E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-************0;000000E+00");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000E+00************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************-0.000000E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-************0.000000E+00");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000E+00************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************-0;000000E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-************0;000000E+00");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0.000000E+00************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************-0.000000E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-************0.000000E+00");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0;000000E+00************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "************-0;000000E+00");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-************0;000000E+00");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ }
+ ios.precision(16);
+ {
+ }
+ ios.precision(60);
+ {
+ }
+ }
+ }
+}
+
+void test10()
+{
+ char str[200];
+ output_iterator<char*> iter;
+ std::locale lc = std::locale::classic();
+ std::locale lg(lc, new my_numpunct);
+ const my_facet f(1);
+ {
+ long double v = 1234567890.125;
+ std::ios ios(0);
+ scientific(ios);
+ // %e
+ {
+ ios.precision(0);
+ {
+ nouppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1e+09********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********************1e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********************1e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1e+09********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********************1e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********************1e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.e+09*******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************1.e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************1.e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;e+09*******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************1;e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************1;e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1e+09*******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************+1e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*******************1e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1e+09*******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************+1e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*******************1e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.e+09******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************+1.e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+******************1.e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;e+09******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************+1;e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+******************1;e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ uppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1E+09********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********************1E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********************1E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1E+09********************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********************1E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********************1E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.E+09*******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************1.E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************1.E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;E+09*******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************1;E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************1;E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1E+09*******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************+1E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*******************1E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1E+09*******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*******************+1E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*******************1E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.E+09******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************+1.E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+******************1.E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;E+09******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************+1;E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+******************1;E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ }
+ ios.precision(1);
+ {
+ nouppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.2e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.2e+09******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************1.2e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************1.2e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;2e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;2e+09******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************1;2e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************1;2e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.2e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.2e+09******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************1.2e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************1.2e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;2e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;2e+09******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************1;2e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************1;2e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.2e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.2e+09*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************+1.2e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*****************1.2e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;2e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;2e+09*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************+1;2e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*****************1;2e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.2e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.2e+09*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************+1.2e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*****************1.2e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;2e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;2e+09*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************+1;2e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*****************1;2e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ uppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.2E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.2E+09******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************1.2E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************1.2E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;2E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;2E+09******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************1;2E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************1;2E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.2E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.2E+09******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************1.2E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************1.2E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;2E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;2E+09******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************1;2E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************1;2E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.2E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.2E+09*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************+1.2E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*****************1.2E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;2E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;2E+09*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************+1;2E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*****************1;2E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.2E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.2E+09*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************+1.2E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*****************1.2E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;2E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;2E+09*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************+1;2E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+*****************1;2E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ }
+ ios.precision(6);
+ {
+ }
+ ios.precision(16);
+ {
+ }
+ ios.precision(60);
+ {
+ nouppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.234567890125000000000000000000000000000000000000000000000000e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.234567890125000000000000000000000000000000000000000000000000e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.234567890125000000000000000000000000000000000000000000000000e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.234567890125000000000000000000000000000000000000000000000000e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;234567890125000000000000000000000000000000000000000000000000e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;234567890125000000000000000000000000000000000000000000000000e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;234567890125000000000000000000000000000000000000000000000000e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;234567890125000000000000000000000000000000000000000000000000e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.234567890125000000000000000000000000000000000000000000000000e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.234567890125000000000000000000000000000000000000000000000000e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.234567890125000000000000000000000000000000000000000000000000e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.234567890125000000000000000000000000000000000000000000000000e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;234567890125000000000000000000000000000000000000000000000000e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;234567890125000000000000000000000000000000000000000000000000e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;234567890125000000000000000000000000000000000000000000000000e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;234567890125000000000000000000000000000000000000000000000000e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000e+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000e+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ uppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.234567890125000000000000000000000000000000000000000000000000E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.234567890125000000000000000000000000000000000000000000000000E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.234567890125000000000000000000000000000000000000000000000000E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.234567890125000000000000000000000000000000000000000000000000E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;234567890125000000000000000000000000000000000000000000000000E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;234567890125000000000000000000000000000000000000000000000000E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;234567890125000000000000000000000000000000000000000000000000E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;234567890125000000000000000000000000000000000000000000000000E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.234567890125000000000000000000000000000000000000000000000000E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.234567890125000000000000000000000000000000000000000000000000E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.234567890125000000000000000000000000000000000000000000000000E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1.234567890125000000000000000000000000000000000000000000000000E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;234567890125000000000000000000000000000000000000000000000000E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;234567890125000000000000000000000000000000000000000000000000E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;234567890125000000000000000000000000000000000000000000000000E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1;234567890125000000000000000000000000000000000000000000000000E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000E+09");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000E+09");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+void test11()
+{
+ char str[200];
+ output_iterator<char*> iter;
+ std::locale lc = std::locale::classic();
+ std::locale lg(lc, new my_numpunct);
+ const my_facet f(1);
+ {
+ long double v = -0.;
+ std::ios ios(0);
+ hexfloat(ios);
+ // %a
+ {
+ ios.precision(0);
+ {
+ nouppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0p+0******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************-0x0p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-******************0x0p+0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0p+0******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************-0x0p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-******************0x0p+0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0.p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0.p+0*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0x0.p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0x0.p+0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0;p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0;p+0*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0x0;p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0x0;p+0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0p+0******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************-0x0p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-******************0x0p+0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0p+0******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************-0x0p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-******************0x0p+0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0.p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0.p+0*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0x0.p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0x0.p+0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0;p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0;p+0*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0x0;p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0x0;p+0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ uppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0P+0******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************-0X0P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-******************0X0P+0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0P+0******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************-0X0P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-******************0X0P+0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0.P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0.P+0*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0X0.P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0X0.P+0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0;P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0;P+0*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0X0;P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0X0;P+0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0P+0******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************-0X0P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-******************0X0P+0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0P+0******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************-0X0P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-******************0X0P+0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0.P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0.P+0*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0X0.P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0X0.P+0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0;P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0;P+0*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0X0;P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0X0;P+0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ }
+ ios.precision(1);
+ {
+ nouppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0p+0******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************-0x0p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-******************0x0p+0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0p+0******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************-0x0p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-******************0x0p+0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0.p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0.p+0*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0x0.p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0x0.p+0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0;p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0;p+0*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0x0;p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0x0;p+0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0p+0******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************-0x0p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-******************0x0p+0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0p+0******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************-0x0p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-******************0x0p+0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0.p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0.p+0*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0x0.p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0x0.p+0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0;p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0;p+0*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0x0;p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0x0;p+0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ uppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0P+0******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************-0X0P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-******************0X0P+0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0P+0******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************-0X0P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-******************0X0P+0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0.P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0.P+0*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0X0.P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0X0.P+0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0;P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0;P+0*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0X0;P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0X0;P+0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0P+0******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************-0X0P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-******************0X0P+0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0P+0******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************-0X0P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-******************0X0P+0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0.P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0.P+0*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0X0.P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0X0.P+0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0;P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0;P+0*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0X0;P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0X0;P+0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ }
+ ios.precision(6);
+ {
+ nouppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0p+0******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************-0x0p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-******************0x0p+0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0p+0******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************-0x0p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-******************0x0p+0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0.p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0.p+0*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0x0.p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0x0.p+0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0;p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0;p+0*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0x0;p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0x0;p+0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0p+0******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************-0x0p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-******************0x0p+0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0p+0******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************-0x0p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-******************0x0p+0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0.p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0.p+0*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0x0.p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0x0.p+0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0;p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0x0;p+0*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0x0;p+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0x0;p+0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ uppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0P+0******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************-0X0P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-******************0X0P+0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0P+0******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************-0X0P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-******************0X0P+0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0.P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0.P+0*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0X0.P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0X0.P+0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0;P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0;P+0*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0X0;P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0X0;P+0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0P+0******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************-0X0P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-******************0X0P+0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0P+0******************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "******************-0X0P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-******************0X0P+0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0.P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0.P+0*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0X0.P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0X0.P+0");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0;P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-0X0;P+0*****************");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****************-0X0;P+0");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-*****************0X0;P+0");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ }
+ ios.precision(16);
+ {
+ }
+ ios.precision(60);
+ {
+ }
+ }
+ }
+}
+
+void test12()
+{
+ char str[200];
+ output_iterator<char*> iter;
+ std::locale lc = std::locale::classic();
+ std::locale lg(lc, new my_numpunct);
+#ifdef __APPLE__
+// This test is failing on FreeBSD, possibly due to different representations
+// of the floating point numbers.
+ const my_facet f(1);
+ {
+ long double v = 1234567890.125;
+ std::ios ios(0);
+ hexfloat(ios);
+ // %a
+ {
+ ios.precision(0);
+ {
+ nouppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.width(0);
+ ios.imbue(lc);
+ {
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x9.32c05a44p+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x9.32c05a44p+27*********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********0x9.32c05a44p+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x*********9.32c05a44p+27");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x9;32c05a44p+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x9;32c05a44p+27*********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********0x9;32c05a44p+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x*********9;32c05a44p+27");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x9.32c05a44p+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x9.32c05a44p+27*********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********0x9.32c05a44p+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x*********9.32c05a44p+27");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x9;32c05a44p+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x9;32c05a44p+27*********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********0x9;32c05a44p+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x*********9;32c05a44p+27");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0x9.32c05a44p+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0x9.32c05a44p+27********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********+0x9.32c05a44p+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+********0x9.32c05a44p+27");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0x9;32c05a44p+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0x9;32c05a44p+27********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********+0x9;32c05a44p+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+********0x9;32c05a44p+27");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0x9.32c05a44p+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0x9.32c05a44p+27********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********+0x9.32c05a44p+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+********0x9.32c05a44p+27");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0x9;32c05a44p+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0x9;32c05a44p+27********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********+0x9;32c05a44p+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+********0x9;32c05a44p+27");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ uppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0X9.32C05A44P+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0X9.32C05A44P+27*********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********0X9.32C05A44P+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0X*********9.32C05A44P+27");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0X9;32C05A44P+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0X9;32C05A44P+27*********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********0X9;32C05A44P+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0X*********9;32C05A44P+27");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0X9.32C05A44P+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0X9.32C05A44P+27*********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********0X9.32C05A44P+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0X*********9.32C05A44P+27");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0X9;32C05A44P+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0X9;32C05A44P+27*********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********0X9;32C05A44P+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0X*********9;32C05A44P+27");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0X9.32C05A44P+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0X9.32C05A44P+27********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********+0X9.32C05A44P+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+********0X9.32C05A44P+27");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0X9;32C05A44P+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0X9;32C05A44P+27********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********+0X9;32C05A44P+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+********0X9;32C05A44P+27");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0X9.32C05A44P+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0X9.32C05A44P+27********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********+0X9.32C05A44P+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+********0X9.32C05A44P+27");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0X9;32C05A44P+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0X9;32C05A44P+27********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********+0X9;32C05A44P+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+********0X9;32C05A44P+27");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ }
+ ios.precision(1);
+ {
+ nouppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x9.32c05a44p+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x9.32c05a44p+27*********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********0x9.32c05a44p+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x*********9.32c05a44p+27");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x9;32c05a44p+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x9;32c05a44p+27*********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********0x9;32c05a44p+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x*********9;32c05a44p+27");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x9.32c05a44p+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x9.32c05a44p+27*********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********0x9.32c05a44p+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x*********9.32c05a44p+27");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x9;32c05a44p+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x9;32c05a44p+27*********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********0x9;32c05a44p+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x*********9;32c05a44p+27");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0x9.32c05a44p+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0x9.32c05a44p+27********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********+0x9.32c05a44p+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+********0x9.32c05a44p+27");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0x9;32c05a44p+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0x9;32c05a44p+27********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********+0x9;32c05a44p+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+********0x9;32c05a44p+27");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0x9.32c05a44p+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0x9.32c05a44p+27********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********+0x9.32c05a44p+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+********0x9.32c05a44p+27");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0x9;32c05a44p+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0x9;32c05a44p+27********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********+0x9;32c05a44p+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+********0x9;32c05a44p+27");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ uppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0X9.32C05A44P+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0X9.32C05A44P+27*********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********0X9.32C05A44P+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0X*********9.32C05A44P+27");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0X9;32C05A44P+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0X9;32C05A44P+27*********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********0X9;32C05A44P+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0X*********9;32C05A44P+27");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0X9.32C05A44P+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0X9.32C05A44P+27*********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********0X9.32C05A44P+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0X*********9.32C05A44P+27");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0X9;32C05A44P+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0X9;32C05A44P+27*********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********0X9;32C05A44P+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0X*********9;32C05A44P+27");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0X9.32C05A44P+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0X9.32C05A44P+27********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********+0X9.32C05A44P+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+********0X9.32C05A44P+27");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0X9;32C05A44P+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0X9;32C05A44P+27********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********+0X9;32C05A44P+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+********0X9;32C05A44P+27");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0X9.32C05A44P+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0X9.32C05A44P+27********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********+0X9.32C05A44P+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+********0X9.32C05A44P+27");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0X9;32C05A44P+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0X9;32C05A44P+27********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********+0X9;32C05A44P+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+********0X9;32C05A44P+27");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ }
+ ios.precision(6);
+ {
+ }
+ ios.precision(16);
+ {
+ }
+ ios.precision(60);
+ {
+ nouppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x9.32c05a44p+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x9.32c05a44p+27*********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********0x9.32c05a44p+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x*********9.32c05a44p+27");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x9;32c05a44p+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x9;32c05a44p+27*********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********0x9;32c05a44p+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x*********9;32c05a44p+27");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x9.32c05a44p+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x9.32c05a44p+27*********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********0x9.32c05a44p+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x*********9.32c05a44p+27");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x9;32c05a44p+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x9;32c05a44p+27*********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********0x9;32c05a44p+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x*********9;32c05a44p+27");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0x9.32c05a44p+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0x9.32c05a44p+27********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********+0x9.32c05a44p+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+********0x9.32c05a44p+27");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0x9;32c05a44p+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0x9;32c05a44p+27********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********+0x9;32c05a44p+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+********0x9;32c05a44p+27");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0x9.32c05a44p+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0x9.32c05a44p+27********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********+0x9.32c05a44p+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+********0x9.32c05a44p+27");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0x9;32c05a44p+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0x9;32c05a44p+27********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********+0x9;32c05a44p+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+********0x9;32c05a44p+27");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ uppercase(ios);
+ {
+ noshowpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0X9.32C05A44P+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0X9.32C05A44P+27*********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********0X9.32C05A44P+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0X*********9.32C05A44P+27");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0X9;32C05A44P+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0X9;32C05A44P+27*********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********0X9;32C05A44P+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0X*********9;32C05A44P+27");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0X9.32C05A44P+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0X9.32C05A44P+27*********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********0X9.32C05A44P+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0X*********9.32C05A44P+27");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0X9;32C05A44P+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0X9;32C05A44P+27*********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*********0X9;32C05A44P+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0X*********9;32C05A44P+27");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ showpos(ios);
+ {
+ noshowpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0X9.32C05A44P+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0X9.32C05A44P+27********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********+0X9.32C05A44P+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+********0X9.32C05A44P+27");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0X9;32C05A44P+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0X9;32C05A44P+27********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********+0X9;32C05A44P+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+********0X9;32C05A44P+27");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ showpoint(ios);
+ {
+ ios.imbue(lc);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0X9.32C05A44P+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0X9.32C05A44P+27********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********+0X9.32C05A44P+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+********0X9.32C05A44P+27");
+ assert(ios.width() == 0);
+ }
+ }
+ ios.imbue(lg);
+ {
+ ios.width(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0X9;32C05A44P+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ left(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+0X9;32C05A44P+27********");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ right(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "********+0X9;32C05A44P+27");
+ assert(ios.width() == 0);
+ }
+ ios.width(25);
+ internal(ios);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+********0X9;32C05A44P+27");
+ assert(ios.width() == 0);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+#endif
+}
+
+int main()
+{
+ test1();
+ test2();
+ test3();
+ test4();
+ test5();
+ test6();
+ test7();
+ test8();
+ test9();
+ test10();
+ test11();
+ test12();
+ char str[200];
+ output_iterator<char*> iter;
+ std::locale lc = std::locale::classic();
+ std::locale lg(lc, new my_numpunct);
+ const my_facet f(1);
+ {
+ long double v = -INFINITY;
+ }
+ {
+ long double v = std::nan("");
+ }
+
+ {
+ long double v = +0.;
+ }
+ {
+ long double v = -INFINITY;
+ }
+ {
+ long double v = std::nan("");
+ }
+ {
+ long double v = -INFINITY;
+ }
+ {
+ long double v = std::nan("");
+ }
+}
diff --git a/test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long_long.pass.cpp b/test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long_long.pass.cpp
new file mode 100644
index 000000000000..55f7d0f9fb91
--- /dev/null
+++ b/test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long_long.pass.cpp
@@ -0,0 +1,344 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class num_put<charT, OutputIterator>
+
+// iter_type put(iter_type s, ios_base& iob, char_type fill, long long v) const;
+
+#include <locale>
+#include <ios>
+#include <cassert>
+#include <streambuf>
+#include "test_iterators.h"
+
+typedef std::num_put<char, output_iterator<char*> > F;
+
+class my_facet
+ : public F
+{
+public:
+ explicit my_facet(std::size_t refs = 0)
+ : F(refs) {}
+};
+
+class my_numpunct
+ : public std::numpunct<char>
+{
+public:
+ my_numpunct() : std::numpunct<char>() {}
+
+protected:
+ virtual char_type do_thousands_sep() const {return '_';}
+ virtual std::string do_grouping() const {return std::string("\1\2\3");}
+};
+
+int main()
+{
+ const my_facet f(1);
+ {
+ std::ios ios(0);
+ long long v = 0;
+ char str[50];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0");
+ }
+ {
+ std::ios ios(0);
+ long long v = 1;
+ char str[50];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1");
+ }
+ {
+ std::ios ios(0);
+ long long v = -1;
+ char str[50];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-1");
+ }
+ {
+ std::ios ios(0);
+ long long v = -1000;
+ char str[50];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-1000");
+ }
+ {
+ std::ios ios(0);
+ long long v = 1000;
+ char str[50];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1000");
+ }
+ {
+ std::ios ios(0);
+ showpos(ios);
+ long long v = 1000;
+ char str[50];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1000");
+ }
+ {
+ std::ios ios(0);
+ oct(ios);
+ long long v = 1000;
+ char str[50];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1750");
+ }
+ {
+ std::ios ios(0);
+ oct(ios);
+ showbase(ios);
+ long long v = 1000;
+ char str[50];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "01750");
+ }
+ {
+ std::ios ios(0);
+ hex(ios);
+ long long v = 1000;
+ char str[50];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "3e8");
+ }
+ {
+ std::ios ios(0);
+ hex(ios);
+ showbase(ios);
+ long long v = 1000;
+ char str[50];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x3e8");
+ }
+ {
+ std::ios ios(0);
+ hex(ios);
+ showbase(ios);
+ uppercase(ios);
+ long long v = 1000;
+ char str[50];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0X3E8");
+ }
+ {
+ std::ios ios(0);
+ ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+ hex(ios);
+ showbase(ios);
+ uppercase(ios);
+ long long v = 1000;
+ char str[50];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0X3E_8");
+ }
+ {
+ std::ios ios(0);
+ ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+ hex(ios);
+ showbase(ios);
+ long long v = 2147483647;
+ char str[50];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x7f_fff_ff_f");
+ }
+ {
+ std::ios ios(0);
+ ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+ oct(ios);
+ long long v = 0123467;
+ char str[50];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "123_46_7");
+ }
+ {
+ std::ios ios(0);
+ ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+ oct(ios);
+ showbase(ios);
+ long long v = 0123467;
+ char str[50];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0_123_46_7");
+ }
+ {
+ std::ios ios(0);
+ ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+ oct(ios);
+ showbase(ios);
+ right(ios);
+ ios.width(15);
+ long long v = 0123467;
+ char str[50];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****0_123_46_7");
+ }
+ {
+ std::ios ios(0);
+ ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+ oct(ios);
+ showbase(ios);
+ left(ios);
+ ios.width(15);
+ long long v = 0123467;
+ char str[50];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0_123_46_7*****");
+ }
+ {
+ std::ios ios(0);
+ ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+ oct(ios);
+ showbase(ios);
+ internal(ios);
+ ios.width(15);
+ long long v = 0123467;
+ char str[50];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****0_123_46_7");
+ assert(ios.width() == 0);
+ }
+ {
+ std::ios ios(0);
+ ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+ hex(ios);
+ showbase(ios);
+ right(ios);
+ ios.width(15);
+ long long v = 2147483647;
+ char str[50];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**0x7f_fff_ff_f");
+ }
+ {
+ std::ios ios(0);
+ ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+ hex(ios);
+ showbase(ios);
+ left(ios);
+ ios.width(15);
+ long long v = 2147483647;
+ char str[50];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x7f_fff_ff_f**");
+ }
+ {
+ std::ios ios(0);
+ ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+ hex(ios);
+ showbase(ios);
+ internal(ios);
+ ios.width(15);
+ long long v = 2147483647;
+ char str[50];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x**7f_fff_ff_f");
+ assert(ios.width() == 0);
+ }
+ {
+ std::ios ios(0);
+ ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+ showpos(ios);
+ long long v = 1000;
+ right(ios);
+ ios.width(10);
+ char str[50];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***+1_00_0");
+ assert(ios.width() == 0);
+ }
+ {
+ std::ios ios(0);
+ ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+ showpos(ios);
+ long long v = 1000;
+ left(ios);
+ ios.width(10);
+ char str[50];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+1_00_0***");
+ assert(ios.width() == 0);
+ }
+ {
+ std::ios ios(0);
+ ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+ showpos(ios);
+ long long v = 1000;
+ internal(ios);
+ ios.width(10);
+ char str[50];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "+***1_00_0");
+ assert(ios.width() == 0);
+ }
+ {
+ std::ios ios(0);
+ ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+ long long v = -1000;
+ right(ios);
+ showpos(ios);
+ ios.width(10);
+ char str[50];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "***-1_00_0");
+ assert(ios.width() == 0);
+ }
+ {
+ std::ios ios(0);
+ ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+ long long v = -1000;
+ left(ios);
+ ios.width(10);
+ char str[50];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-1_00_0***");
+ assert(ios.width() == 0);
+ }
+ {
+ std::ios ios(0);
+ ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+ long long v = -1000;
+ internal(ios);
+ ios.width(10);
+ char str[50];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "-***1_00_0");
+ assert(ios.width() == 0);
+ }
+}
diff --git a/test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_pointer.pass.cpp b/test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_pointer.pass.cpp
new file mode 100644
index 000000000000..8edcfc415821
--- /dev/null
+++ b/test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_pointer.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class num_put<charT, OutputIterator>
+
+// iter_type put(iter_type s, ios_base& iob, char_type fill, void* v) const;
+
+#include <locale>
+#include <ios>
+#include <cassert>
+#include <streambuf>
+#include "test_iterators.h"
+
+typedef std::num_put<char, output_iterator<char*> > F;
+
+class my_facet
+ : public F
+{
+public:
+ explicit my_facet(std::size_t refs = 0)
+ : F(refs) {}
+};
+
+int main()
+{
+ const my_facet f(1);
+ {
+ std::ios ios(0);
+ void* v = 0;
+ char str[50];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x0" || ex == "(nil)");
+ }
+}
diff --git a/test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_unsigned_long.pass.cpp b/test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_unsigned_long.pass.cpp
new file mode 100644
index 000000000000..f7a577fb8a9e
--- /dev/null
+++ b/test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_unsigned_long.pass.cpp
@@ -0,0 +1,374 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class num_put<charT, OutputIterator>
+
+// iter_type put(iter_type s, ios_base& iob, char_type fill, unsigned long v) const;
+
+#include <locale>
+#include <ios>
+#include <cassert>
+#include <streambuf>
+#include "test_iterators.h"
+
+typedef std::num_put<char, output_iterator<char*> > F;
+
+class my_facet
+ : public F
+{
+public:
+ explicit my_facet(std::size_t refs = 0)
+ : F(refs) {}
+};
+
+class my_numpunct
+ : public std::numpunct<char>
+{
+public:
+ my_numpunct() : std::numpunct<char>() {}
+
+protected:
+ virtual char_type do_thousands_sep() const {return '_';}
+ virtual std::string do_grouping() const {return std::string("\1\2\3");}
+};
+
+int main()
+{
+ const my_facet f(1);
+ {
+ std::ios ios(0);
+ unsigned long v = 0;
+ char str[50];
+ std::ios_base::iostate err = ios.goodbit;
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0");
+ }
+ {
+ std::ios ios(0);
+ unsigned long v = 1;
+ char str[50];
+ std::ios_base::iostate err = ios.goodbit;
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1");
+ }
+ {
+ std::ios ios(0);
+ unsigned long v = -1;
+ char str[50];
+ std::ios_base::iostate err = ios.goodbit;
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == (sizeof(unsigned long) == 4 ? "4294967295" : "18446744073709551615"));
+ }
+ {
+ std::ios ios(0);
+ unsigned long v = -1000;
+ char str[50];
+ std::ios_base::iostate err = ios.goodbit;
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == (sizeof(unsigned long) == 4 ? "4294966296" : "18446744073709550616"));
+ }
+ {
+ std::ios ios(0);
+ unsigned long v = 1000;
+ char str[50];
+ std::ios_base::iostate err = ios.goodbit;
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1000");
+ }
+ {
+ std::ios ios(0);
+ showpos(ios);
+ unsigned long v = 1000;
+ char str[50];
+ std::ios_base::iostate err = ios.goodbit;
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1000");
+ }
+ {
+ std::ios ios(0);
+ oct(ios);
+ unsigned long v = 1000;
+ char str[50];
+ std::ios_base::iostate err = ios.goodbit;
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1750");
+ }
+ {
+ std::ios ios(0);
+ oct(ios);
+ showbase(ios);
+ unsigned long v = 1000;
+ char str[50];
+ std::ios_base::iostate err = ios.goodbit;
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "01750");
+ }
+ {
+ std::ios ios(0);
+ hex(ios);
+ unsigned long v = 1000;
+ char str[50];
+ std::ios_base::iostate err = ios.goodbit;
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "3e8");
+ }
+ {
+ std::ios ios(0);
+ hex(ios);
+ showbase(ios);
+ unsigned long v = 1000;
+ char str[50];
+ std::ios_base::iostate err = ios.goodbit;
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x3e8");
+ }
+ {
+ std::ios ios(0);
+ hex(ios);
+ showbase(ios);
+ uppercase(ios);
+ unsigned long v = 1000;
+ char str[50];
+ std::ios_base::iostate err = ios.goodbit;
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0X3E8");
+ }
+ {
+ std::ios ios(0);
+ ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+ hex(ios);
+ showbase(ios);
+ uppercase(ios);
+ unsigned long v = 1000;
+ char str[50];
+ std::ios_base::iostate err = ios.goodbit;
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0X3E_8");
+ }
+ {
+ std::ios ios(0);
+ ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+ hex(ios);
+ showbase(ios);
+ unsigned long v = 2147483647;
+ char str[50];
+ std::ios_base::iostate err = ios.goodbit;
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x7f_fff_ff_f");
+ }
+ {
+ std::ios ios(0);
+ ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+ oct(ios);
+ unsigned long v = 0123467;
+ char str[50];
+ std::ios_base::iostate err = ios.goodbit;
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "123_46_7");
+ }
+ {
+ std::ios ios(0);
+ ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+ oct(ios);
+ showbase(ios);
+ unsigned long v = 0123467;
+ char str[50];
+ std::ios_base::iostate err = ios.goodbit;
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0_123_46_7");
+ }
+ {
+ std::ios ios(0);
+ ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+ oct(ios);
+ showbase(ios);
+ right(ios);
+ ios.width(15);
+ unsigned long v = 0123467;
+ char str[50];
+ std::ios_base::iostate err = ios.goodbit;
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****0_123_46_7");
+ }
+ {
+ std::ios ios(0);
+ ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+ oct(ios);
+ showbase(ios);
+ left(ios);
+ ios.width(15);
+ unsigned long v = 0123467;
+ char str[50];
+ std::ios_base::iostate err = ios.goodbit;
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0_123_46_7*****");
+ }
+ {
+ std::ios ios(0);
+ ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+ oct(ios);
+ showbase(ios);
+ internal(ios);
+ ios.width(15);
+ unsigned long v = 0123467;
+ char str[50];
+ std::ios_base::iostate err = ios.goodbit;
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****0_123_46_7");
+ assert(ios.width() == 0);
+ }
+ {
+ std::ios ios(0);
+ ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+ hex(ios);
+ showbase(ios);
+ right(ios);
+ ios.width(15);
+ unsigned long v = 2147483647;
+ char str[50];
+ std::ios_base::iostate err = ios.goodbit;
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**0x7f_fff_ff_f");
+ }
+ {
+ std::ios ios(0);
+ ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+ hex(ios);
+ showbase(ios);
+ left(ios);
+ ios.width(15);
+ unsigned long v = 2147483647;
+ char str[50];
+ std::ios_base::iostate err = ios.goodbit;
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x7f_fff_ff_f**");
+ }
+ {
+ std::ios ios(0);
+ ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+ hex(ios);
+ showbase(ios);
+ internal(ios);
+ ios.width(15);
+ unsigned long v = 2147483647;
+ char str[50];
+ std::ios_base::iostate err = ios.goodbit;
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x**7f_fff_ff_f");
+ assert(ios.width() == 0);
+ }
+ {
+ std::ios ios(0);
+ ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+ showpos(ios);
+ unsigned long v = 1000;
+ right(ios);
+ ios.width(10);
+ char str[50];
+ std::ios_base::iostate err = ios.goodbit;
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "****1_00_0");
+ assert(ios.width() == 0);
+ }
+ {
+ std::ios ios(0);
+ ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+ showpos(ios);
+ unsigned long v = 1000;
+ left(ios);
+ ios.width(10);
+ char str[50];
+ std::ios_base::iostate err = ios.goodbit;
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_00_0****");
+ assert(ios.width() == 0);
+ }
+ {
+ std::ios ios(0);
+ ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+ showpos(ios);
+ unsigned long v = 1000;
+ internal(ios);
+ ios.width(10);
+ char str[50];
+ std::ios_base::iostate err = ios.goodbit;
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "****1_00_0");
+ assert(ios.width() == 0);
+ }
+ {
+ std::ios ios(0);
+ ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+ unsigned long v = -1000;
+ right(ios);
+ showpos(ios);
+ ios.width(10);
+ char str[50];
+ std::ios_base::iostate err = ios.goodbit;
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == (sizeof(unsigned long) == 4 ? "4_294_966_29_6"
+ : "18_446_744_073_709_550_61_6"));
+ assert(ios.width() == 0);
+ }
+ {
+ std::ios ios(0);
+ ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+ unsigned long v = -1000;
+ left(ios);
+ ios.width(10);
+ char str[50];
+ std::ios_base::iostate err = ios.goodbit;
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == (sizeof(unsigned long) == 4 ? "4_294_966_29_6"
+ : "18_446_744_073_709_550_61_6"));
+ assert(ios.width() == 0);
+ }
+ {
+ std::ios ios(0);
+ ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+ unsigned long v = -1000;
+ internal(ios);
+ ios.width(10);
+ char str[50];
+ std::ios_base::iostate err = ios.goodbit;
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == (sizeof(unsigned long) == 4 ? "4_294_966_29_6"
+ : "18_446_744_073_709_550_61_6"));
+ assert(ios.width() == 0);
+ }
+}
diff --git a/test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_unsigned_long_long.pass.cpp b/test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_unsigned_long_long.pass.cpp
new file mode 100644
index 000000000000..debbd5e0ee6c
--- /dev/null
+++ b/test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_unsigned_long_long.pass.cpp
@@ -0,0 +1,344 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class num_put<charT, OutputIterator>
+
+// iter_type put(iter_type s, ios_base& iob, char_type fill, unsigned long long v) const;
+
+#include <locale>
+#include <ios>
+#include <cassert>
+#include <streambuf>
+#include "test_iterators.h"
+
+typedef std::num_put<char, output_iterator<char*> > F;
+
+class my_facet
+ : public F
+{
+public:
+ explicit my_facet(std::size_t refs = 0)
+ : F(refs) {}
+};
+
+class my_numpunct
+ : public std::numpunct<char>
+{
+public:
+ my_numpunct() : std::numpunct<char>() {}
+
+protected:
+ virtual char_type do_thousands_sep() const {return '_';}
+ virtual std::string do_grouping() const {return std::string("\1\2\3");}
+};
+
+int main()
+{
+ const my_facet f(1);
+ {
+ std::ios ios(0);
+ unsigned long long v = 0;
+ char str[50];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0");
+ }
+ {
+ std::ios ios(0);
+ unsigned long long v = 1;
+ char str[50];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1");
+ }
+ {
+ std::ios ios(0);
+ unsigned long long v = -1;
+ char str[50];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == (sizeof(unsigned long long) == 4 ? "4294967295" : "18446744073709551615"));
+ }
+ {
+ std::ios ios(0);
+ unsigned long long v = -1000;
+ char str[50];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "18446744073709550616");
+ }
+ {
+ std::ios ios(0);
+ unsigned long long v = 1000;
+ char str[50];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1000");
+ }
+ {
+ std::ios ios(0);
+ showpos(ios);
+ unsigned long long v = 1000;
+ char str[50];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1000");
+ }
+ {
+ std::ios ios(0);
+ oct(ios);
+ unsigned long long v = 1000;
+ char str[50];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1750");
+ }
+ {
+ std::ios ios(0);
+ oct(ios);
+ showbase(ios);
+ unsigned long long v = 1000;
+ char str[50];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "01750");
+ }
+ {
+ std::ios ios(0);
+ hex(ios);
+ unsigned long long v = 1000;
+ char str[50];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "3e8");
+ }
+ {
+ std::ios ios(0);
+ hex(ios);
+ showbase(ios);
+ unsigned long long v = 1000;
+ char str[50];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x3e8");
+ }
+ {
+ std::ios ios(0);
+ hex(ios);
+ showbase(ios);
+ uppercase(ios);
+ unsigned long long v = 1000;
+ char str[50];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0X3E8");
+ }
+ {
+ std::ios ios(0);
+ ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+ hex(ios);
+ showbase(ios);
+ uppercase(ios);
+ unsigned long long v = 1000;
+ char str[50];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0X3E_8");
+ }
+ {
+ std::ios ios(0);
+ ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+ hex(ios);
+ showbase(ios);
+ unsigned long long v = 2147483647;
+ char str[50];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x7f_fff_ff_f");
+ }
+ {
+ std::ios ios(0);
+ ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+ oct(ios);
+ unsigned long long v = 0123467;
+ char str[50];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "123_46_7");
+ }
+ {
+ std::ios ios(0);
+ ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+ oct(ios);
+ showbase(ios);
+ unsigned long long v = 0123467;
+ char str[50];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0_123_46_7");
+ }
+ {
+ std::ios ios(0);
+ ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+ oct(ios);
+ showbase(ios);
+ right(ios);
+ ios.width(15);
+ unsigned long long v = 0123467;
+ char str[50];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****0_123_46_7");
+ }
+ {
+ std::ios ios(0);
+ ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+ oct(ios);
+ showbase(ios);
+ left(ios);
+ ios.width(15);
+ unsigned long long v = 0123467;
+ char str[50];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0_123_46_7*****");
+ }
+ {
+ std::ios ios(0);
+ ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+ oct(ios);
+ showbase(ios);
+ internal(ios);
+ ios.width(15);
+ unsigned long long v = 0123467;
+ char str[50];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "*****0_123_46_7");
+ assert(ios.width() == 0);
+ }
+ {
+ std::ios ios(0);
+ ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+ hex(ios);
+ showbase(ios);
+ right(ios);
+ ios.width(15);
+ unsigned long long v = 2147483647;
+ char str[50];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "**0x7f_fff_ff_f");
+ }
+ {
+ std::ios ios(0);
+ ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+ hex(ios);
+ showbase(ios);
+ left(ios);
+ ios.width(15);
+ unsigned long long v = 2147483647;
+ char str[50];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x7f_fff_ff_f**");
+ }
+ {
+ std::ios ios(0);
+ ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+ hex(ios);
+ showbase(ios);
+ internal(ios);
+ ios.width(15);
+ unsigned long long v = 2147483647;
+ char str[50];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "0x**7f_fff_ff_f");
+ assert(ios.width() == 0);
+ }
+ {
+ std::ios ios(0);
+ ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+ showpos(ios);
+ unsigned long long v = 1000;
+ right(ios);
+ ios.width(10);
+ char str[50];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "****1_00_0");
+ assert(ios.width() == 0);
+ }
+ {
+ std::ios ios(0);
+ ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+ showpos(ios);
+ unsigned long long v = 1000;
+ left(ios);
+ ios.width(10);
+ char str[50];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "1_00_0****");
+ assert(ios.width() == 0);
+ }
+ {
+ std::ios ios(0);
+ ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+ showpos(ios);
+ unsigned long long v = 1000;
+ internal(ios);
+ ios.width(10);
+ char str[50];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "****1_00_0");
+ assert(ios.width() == 0);
+ }
+ {
+ std::ios ios(0);
+ ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+ unsigned long long v = -1000;
+ right(ios);
+ showpos(ios);
+ ios.width(10);
+ char str[50];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "18_446_744_073_709_550_61_6");
+ assert(ios.width() == 0);
+ }
+ {
+ std::ios ios(0);
+ ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+ unsigned long long v = -1000;
+ left(ios);
+ ios.width(10);
+ char str[50];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "18_446_744_073_709_550_61_6");
+ assert(ios.width() == 0);
+ }
+ {
+ std::ios ios(0);
+ ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+ unsigned long long v = -1000;
+ internal(ios);
+ ios.width(10);
+ char str[50];
+ output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+ std::string ex(str, iter.base());
+ assert(ex == "18_446_744_073_709_550_61_6");
+ assert(ios.width() == 0);
+ }
+}
diff --git a/test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.virtuals/tested_elsewhere.pass.cpp b/test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.virtuals/tested_elsewhere.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.virtuals/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/localization/locale.categories/category.numeric/locale.nm.put/types.pass.cpp b/test/std/localization/locale.categories/category.numeric/locale.nm.put/types.pass.cpp
new file mode 100644
index 000000000000..f6f1e5c21a5a
--- /dev/null
+++ b/test/std/localization/locale.categories/category.numeric/locale.nm.put/types.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT, class OutputIterator = ostreambuf_iterator<charT> >
+// class num_put
+// : public locale::facet
+// {
+// public:
+// typedef charT char_type;
+// typedef OutputIterator iter_type;
+
+#include <locale>
+#include <iterator>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_base_of<std::locale::facet, std::num_put<char> >::value), "");
+ static_assert((std::is_base_of<std::locale::facet, std::num_put<wchar_t> >::value), "");
+ static_assert((std::is_same<std::num_put<char>::char_type, char>::value), "");
+ static_assert((std::is_same<std::num_put<wchar_t>::char_type, wchar_t>::value), "");
+ static_assert((std::is_same<std::num_put<char>::iter_type, std::ostreambuf_iterator<char> >::value), "");
+ static_assert((std::is_same<std::num_put<wchar_t>::iter_type, std::ostreambuf_iterator<wchar_t> >::value), "");
+}
diff --git a/test/std/localization/locale.categories/category.numeric/locale.num.get/ctor.pass.cpp b/test/std/localization/locale.categories/category.numeric/locale.num.get/ctor.pass.cpp
new file mode 100644
index 000000000000..71af9cdc7b62
--- /dev/null
+++ b/test/std/localization/locale.categories/category.numeric/locale.num.get/ctor.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class num_get<charT, InputIterator>
+
+// explicit num_get(size_t refs = 0);
+
+#include <locale>
+#include <cassert>
+
+typedef std::num_get<char, char*> F;
+
+class my_facet
+ : public F
+{
+public:
+ static int count;
+
+ explicit my_facet(std::size_t refs = 0)
+ : F(refs) {++count;}
+
+ ~my_facet() {--count;}
+};
+
+int my_facet::count = 0;
+
+int main()
+{
+ {
+ std::locale l(std::locale::classic(), new my_facet);
+ assert(my_facet::count == 1);
+ }
+ assert(my_facet::count == 0);
+ {
+ my_facet f(1);
+ assert(my_facet::count == 1);
+ {
+ std::locale l(std::locale::classic(), &f);
+ assert(my_facet::count == 1);
+ }
+ assert(my_facet::count == 1);
+ }
+ assert(my_facet::count == 0);
+}
diff --git a/test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_bool.pass.cpp b/test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_bool.pass.cpp
new file mode 100644
index 000000000000..f2cc2e7960db
--- /dev/null
+++ b/test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_bool.pass.cpp
@@ -0,0 +1,230 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class num_get<charT, InputIterator>
+
+// iter_type get(iter_type in, iter_type end, ios_base&,
+// ios_base::iostate& err, bool& v) const;
+
+#include <locale>
+#include <ios>
+#include <cassert>
+#include <streambuf>
+#include "test_iterators.h"
+
+typedef std::num_get<char, input_iterator<const char*> > F;
+
+class my_facet
+ : public F
+{
+public:
+ explicit my_facet(std::size_t refs = 0)
+ : F(refs) {}
+};
+
+class p1
+ : public std::numpunct<char>
+{
+public:
+ p1() : std::numpunct<char>() {}
+
+protected:
+ virtual string_type do_truename() const {return "a";}
+ virtual string_type do_falsename() const {return "abb";}
+};
+
+class p2
+ : public std::numpunct<char>
+{
+public:
+ p2() : std::numpunct<char>() {}
+
+protected:
+ virtual string_type do_truename() const {return "a";}
+ virtual string_type do_falsename() const {return "ab";}
+};
+
+int main()
+{
+ const my_facet f(1);
+ std::ios ios(0);
+ {
+ const char str[] = "1";
+ std::ios_base::iostate err = ios.goodbit;
+ bool b;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, b);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.goodbit);
+ assert(b == true);
+ }
+ {
+ const char str[] = "0";
+ std::ios_base::iostate err = ios.goodbit;
+ bool b;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, b);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.goodbit);
+ assert(b == false);
+ }
+ {
+ const char str[] = "12";
+ std::ios_base::iostate err = ios.goodbit;
+ bool b;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, b);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.failbit);
+ assert(b == true);
+ }
+ {
+ const char str[] = "*12";
+ std::ios_base::iostate err = ios.goodbit;
+ bool b;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, b);
+ assert(iter.base() == str+0);
+ assert(err == ios.failbit);
+ assert(b == false);
+ }
+ boolalpha(ios);
+ {
+ const char str[] = "1";
+ std::ios_base::iostate err = ios.goodbit;
+ bool b;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, b);
+ assert(iter.base() == str+0);
+ assert(err == ios.failbit);
+ assert(b == false);
+ }
+ {
+ const char str[] = "true";
+ std::ios_base::iostate err = ios.goodbit;
+ bool b;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, b);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.goodbit);
+ assert(b == true);
+ }
+ {
+ const char str[] = "false";
+ std::ios_base::iostate err = ios.goodbit;
+ bool b;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, b);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.goodbit);
+ assert(b == false);
+ }
+ ios.imbue(std::locale(ios.getloc(), new p1));
+ {
+ const char str[] = "a";
+ std::ios_base::iostate err = ios.goodbit;
+ bool b;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+1),
+ ios, err, b);
+ assert(iter.base() == str+1);
+ assert(err == ios.eofbit);
+ assert(b == true);
+ }
+ {
+ const char str[] = "abc";
+ std::ios_base::iostate err = ios.goodbit;
+ bool b;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+3),
+ ios, err, b);
+ assert(iter.base() == str+2);
+ assert(err == ios.failbit);
+ assert(b == false);
+ }
+ {
+ const char str[] = "acc";
+ std::ios_base::iostate err = ios.goodbit;
+ bool b;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+3),
+ ios, err, b);
+ assert(iter.base() == str+1);
+ assert(err == ios.goodbit);
+ assert(b == true);
+ }
+ ios.imbue(std::locale(ios.getloc(), new p2));
+ {
+ const char str[] = "a";
+ std::ios_base::iostate err = ios.goodbit;
+ bool b;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+1),
+ ios, err, b);
+ assert(iter.base() == str+1);
+ assert(err == ios.eofbit);
+ assert(b == true);
+ }
+ {
+ const char str[] = "ab";
+ std::ios_base::iostate err = ios.goodbit;
+ bool b;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+2),
+ ios, err, b);
+ assert(iter.base() == str+2);
+ assert(err == ios.eofbit);
+ assert(b == false);
+ }
+ {
+ const char str[] = "abc";
+ std::ios_base::iostate err = ios.goodbit;
+ bool b;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+3),
+ ios, err, b);
+ assert(iter.base() == str+2);
+ assert(err == ios.goodbit);
+ assert(b == false);
+ }
+ {
+ const char str[] = "ac";
+ std::ios_base::iostate err = ios.goodbit;
+ bool b;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+2),
+ ios, err, b);
+ assert(iter.base() == str+1);
+ assert(err == ios.goodbit);
+ assert(b == true);
+ }
+}
diff --git a/test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_double.pass.cpp b/test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_double.pass.cpp
new file mode 100644
index 000000000000..f5c7c1277c31
--- /dev/null
+++ b/test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_double.pass.cpp
@@ -0,0 +1,256 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11
+// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12
+
+// <locale>
+
+// class num_get<charT, InputIterator>
+
+// iter_type get(iter_type in, iter_type end, ios_base&,
+// ios_base::iostate& err, double& v) const;
+
+#include <locale>
+#include <ios>
+#include <cassert>
+#include <streambuf>
+#include <cmath>
+#include "test_iterators.h"
+#include "hexfloat.h"
+
+typedef std::num_get<char, input_iterator<const char*> > F;
+
+class my_facet
+ : public F
+{
+public:
+ explicit my_facet(std::size_t refs = 0)
+ : F(refs) {}
+};
+
+class my_numpunct
+ : public std::numpunct<char>
+{
+public:
+ my_numpunct() : std::numpunct<char>() {}
+
+protected:
+ virtual char_type do_decimal_point() const {return ';';}
+ virtual char_type do_thousands_sep() const {return '_';}
+ virtual std::string do_grouping() const {return std::string("\1\2\3");}
+};
+
+int main()
+{
+ const my_facet f(1);
+ std::ios ios(0);
+ double v = -1;
+ {
+ const char str[] = "123";
+ assert((ios.flags() & ios.basefield) == ios.dec);
+ assert(ios.getloc().name() == "C");
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.goodbit);
+ assert(v == 123);
+ }
+ {
+ const char str[] = "-123";
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.goodbit);
+ assert(v == -123);
+ }
+ {
+ const char str[] = "123.5";
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.goodbit);
+ assert(v == 123.5);
+ }
+ {
+ const char str[] = "125e-1";
+ hex(ios);
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.goodbit);
+ assert(v == 125e-1);
+ }
+ {
+ const char str[] = "0x125p-1";
+ hex(ios);
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.goodbit);
+ assert(v == hexfloat<double>(0x125, 0, -1));
+ }
+ {
+ const char str[] = "inf";
+ hex(ios);
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.goodbit);
+ assert(v == INFINITY);
+ }
+ {
+ const char str[] = "INF";
+ hex(ios);
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.goodbit);
+ assert(v == INFINITY);
+ }
+ {
+ const char str[] = "-inf";
+ hex(ios);
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.goodbit);
+ assert(v == -INFINITY);
+ }
+ {
+ const char str[] = "-INF";
+ hex(ios);
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.goodbit);
+ assert(v == -INFINITY);
+ }
+ {
+ const char str[] = "nan";
+ hex(ios);
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.goodbit);
+ assert(std::isnan(v));
+ }
+ {
+ const char str[] = "NAN";
+ hex(ios);
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.goodbit);
+ assert(std::isnan(v));
+ }
+ {
+ v = -1;
+ const char str[] = "123_456_78_9;125";
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+3);
+ assert(err == ios.goodbit);
+ assert(v == 123);
+ }
+ {
+ v = -1;
+ const char str[] = "2-";
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+1);
+ assert(err == ios.goodbit);
+ assert(v == 2);
+ }
+ ios.imbue(std::locale(std::locale(), new my_numpunct));
+ {
+ v = -1;
+ const char str[] = "123_456_78_9;125";
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.goodbit);
+ assert(v == 123456789.125);
+ }
+ {
+ v = -1;
+ const char str[] = "1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_"
+ "1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_"
+ "1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_"
+ "1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_"
+ "1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_"
+ "1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_"
+ "1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_"
+ "1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_"
+ "1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_"
+ "1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_"
+ "1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_";
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.failbit);
+ }
+ {
+ v = -1;
+ const char str[] = "3;14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651e+10";
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.goodbit);
+ assert(std::abs(v - 3.14159265358979e+10)/3.14159265358979e+10 < 1.e-8);
+ }
+}
diff --git a/test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_float.pass.cpp b/test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_float.pass.cpp
new file mode 100644
index 000000000000..9138894784ed
--- /dev/null
+++ b/test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_float.pass.cpp
@@ -0,0 +1,171 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class num_get<charT, InputIterator>
+
+// iter_type get(iter_type in, iter_type end, ios_base&,
+// ios_base::iostate& err, float& v) const;
+
+#include <locale>
+#include <ios>
+#include <cassert>
+#include <streambuf>
+#include <cmath>
+#include "test_iterators.h"
+#include "hexfloat.h"
+
+typedef std::num_get<char, input_iterator<const char*> > F;
+
+class my_facet
+ : public F
+{
+public:
+ explicit my_facet(std::size_t refs = 0)
+ : F(refs) {}
+};
+
+int main()
+{
+ const my_facet f(1);
+ std::ios ios(0);
+ float v = -1;
+ {
+ const char str[] = "123";
+ assert((ios.flags() & ios.basefield) == ios.dec);
+ assert(ios.getloc().name() == "C");
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.goodbit);
+ assert(v == 123);
+ }
+ {
+ const char str[] = "-123";
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.goodbit);
+ assert(v == -123);
+ }
+ {
+ const char str[] = "123.5";
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.goodbit);
+ assert(v == 123.5);
+ }
+ {
+ const char str[] = "125e-1";
+ hex(ios);
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.goodbit);
+ assert(v == 125e-1);
+ }
+ {
+ const char str[] = "0x125p-1";
+ hex(ios);
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.goodbit);
+ assert(v == hexfloat<float>(0x125, 0, -1));
+ }
+ {
+ const char str[] = "inf";
+ hex(ios);
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.goodbit);
+ assert(v == INFINITY);
+ }
+ {
+ const char str[] = "INF";
+ hex(ios);
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.goodbit);
+ assert(v == INFINITY);
+ }
+ {
+ const char str[] = "-inf";
+ hex(ios);
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.goodbit);
+ assert(v == -INFINITY);
+ }
+ {
+ const char str[] = "-INF";
+ hex(ios);
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.goodbit);
+ assert(v == -INFINITY);
+ }
+ {
+ const char str[] = "nan";
+ hex(ios);
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.goodbit);
+ assert(std::isnan(v));
+ }
+ {
+ const char str[] = "NAN";
+ hex(ios);
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.goodbit);
+ assert(std::isnan(v));
+ }
+}
diff --git a/test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_long.pass.cpp b/test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_long.pass.cpp
new file mode 100644
index 000000000000..d900c3764a1f
--- /dev/null
+++ b/test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_long.pass.cpp
@@ -0,0 +1,519 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class num_get<charT, InputIterator>
+
+// iter_type get(iter_type in, iter_type end, ios_base&,
+// ios_base::iostate& err, long& v) const;
+
+#include <locale>
+#include <ios>
+#include <cassert>
+#include <streambuf>
+#include "test_iterators.h"
+
+typedef std::num_get<char, input_iterator<const char*> > F;
+
+class my_facet
+ : public F
+{
+public:
+ explicit my_facet(std::size_t refs = 0)
+ : F(refs) {}
+};
+
+class my_numpunct
+ : public std::numpunct<char>
+{
+public:
+ my_numpunct() : std::numpunct<char>() {}
+
+protected:
+ virtual char_type do_thousands_sep() const {return '_';}
+ virtual std::string do_grouping() const {return std::string("\1\2\3");}
+};
+
+int main()
+{
+ const my_facet f(1);
+ std::ios ios(0);
+ long v = -1;
+ {
+ const char str[] = "123";
+ assert((ios.flags() & ios.basefield) == ios.dec);
+ assert(ios.getloc().name() == "C");
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+3);
+ assert(err == ios.goodbit);
+ assert(v == 123);
+ }
+ {
+ const char str[] = "-123";
+ assert((ios.flags() & ios.basefield) == ios.dec);
+ assert(ios.getloc().name() == "C");
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+4);
+ assert(err == ios.goodbit);
+ assert(v == -123);
+ }
+ {
+ const char str[] = "123";
+ oct(ios);
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+3);
+ assert(err == ios.goodbit);
+ assert(v == 83);
+ }
+ {
+ const char str[] = "123";
+ hex(ios);
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+3);
+ assert(err == ios.goodbit);
+ assert(v == 291);
+ }
+ {
+ const char str[] = "0x123";
+ hex(ios);
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.goodbit);
+ assert(v == 291);
+ }
+ {
+ const char str[] = "123";
+ ios.setf(0, ios.basefield);
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.goodbit);
+ assert(v == 123);
+ }
+ {
+ const char str[] = "0x123";
+ ios.setf(0, ios.basefield);
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.goodbit);
+ assert(v == 291);
+ }
+ {
+ const char str[] = "0123";
+ ios.setf(0, ios.basefield);
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.goodbit);
+ assert(v == 83);
+ }
+ {
+ const char str[] = "2-";
+ ios.setf(0, ios.basefield);
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+1);
+ assert(err == ios.goodbit);
+ assert(v == 2);
+ }
+ dec(ios);
+ ios.imbue(std::locale(std::locale(), new my_numpunct));
+ {
+ v = -1;
+ const char str[] = "123";
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.failbit);
+ assert(v == 123);
+ }
+ {
+ v = -1;
+ const char str[] = "+1";
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.goodbit);
+ assert(v == 1);
+ }
+ {
+ v = -1;
+ const char str[] = "+1_";
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.failbit);
+ assert(v == 1);
+ }
+ {
+ v = -1;
+ const char str[] = "+_1";
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.failbit);
+ assert(v == 1);
+ }
+ {
+ v = -1;
+ const char str[] = "_+1";
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.failbit);
+ assert(v == 1);
+ }
+ {
+ v = -1;
+ const char str[] = "+1__";
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.failbit);
+ assert(v == 1);
+ }
+ {
+ v = -1;
+ const char str[] = "+_1_";
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.failbit);
+ assert(v == 1);
+ }
+ {
+ v = -1;
+ const char str[] = "_+1_";
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.failbit);
+ assert(v == 1);
+ }
+ {
+ v = -1;
+ const char str[] = "+__1";
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.failbit);
+ assert(v == 1);
+ }
+ {
+ v = -1;
+ const char str[] = "_+_1";
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.failbit);
+ assert(v == 1);
+ }
+ {
+ v = -1;
+ const char str[] = "__+1";
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.failbit);
+ assert(v == 1);
+ }
+ {
+ v = -1;
+ const char str[] = "+1_2";
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.goodbit);
+ assert(v == 12);
+ }
+ {
+ v = -1;
+ const char str[] = "+12_";
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.failbit);
+ assert(v == 12);
+ }
+ {
+ v = -1;
+ const char str[] = "+_12";
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.failbit);
+ assert(v == 12);
+ }
+ {
+ v = -1;
+ const char str[] = "+1__2";
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.failbit);
+ assert(v == 12);
+ }
+ {
+ v = -1;
+ const char str[] = "+12_3";
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.goodbit);
+ assert(v == 123);
+ }
+ {
+ v = -1;
+ const char str[] = "+1_23";
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.failbit);
+ assert(v == 123);
+ }
+ {
+ v = -1;
+ const char str[] = "+1_23_4";
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.goodbit);
+ assert(v == 1234);
+ }
+ {
+ v = -1;
+ const char str[] = "+123_4";
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.failbit);
+ assert(v == 1234);
+ }
+ {
+ v = -1;
+ const char str[] = "+12_34";
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.failbit);
+ assert(v == 1234);
+ }
+ {
+ v = -1;
+ const char str[] = "+12_34_5";
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.goodbit);
+ assert(v == 12345);
+ }
+ {
+ v = -1;
+ const char str[] = "+123_45_6";
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.goodbit);
+ assert(v == 123456);
+ }
+ {
+ v = -1;
+ const char str[] = "+1_23_45_6";
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.failbit);
+ assert(v == 123456);
+ }
+ {
+ v = -1;
+ const char str[] = "+1_234_56_7";
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.goodbit);
+ assert(v == 1234567);
+ }
+ {
+ v = -1;
+ const char str[] = "+1_234_567_89_0";
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.goodbit);
+ assert(v == 1234567890);
+ }
+ {
+ v = -1;
+ const char str[] = "-1_234_567_89_0";
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.goodbit);
+ assert(v == -1234567890);
+ }
+ {
+ v = -1;
+ const char str[] = "1_234_567_89_0";
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.goodbit);
+ assert(v == 1234567890);
+ }
+ {
+ v = -1;
+ const char str[] = "1234_567_89_0";
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.failbit);
+ assert(v == 1234567890);
+ }
+ {
+ v = -1;
+ const char str[] = "1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_"
+ "1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_"
+ "1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_"
+ "1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_"
+ "1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_"
+ "1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_"
+ "1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_"
+ "1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_"
+ "1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_"
+ "1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_"
+ "1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_";
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.failbit);
+ assert(v == std::numeric_limits<long>::max());
+ }
+}
diff --git a/test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_long_double.pass.cpp b/test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_long_double.pass.cpp
new file mode 100644
index 000000000000..8e89ebc470cf
--- /dev/null
+++ b/test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_long_double.pass.cpp
@@ -0,0 +1,231 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class num_get<charT, InputIterator>
+
+// iter_type get(iter_type in, iter_type end, ios_base&,
+// ios_base::iostate& err, long double& v) const;
+
+#include <locale>
+#include <ios>
+#include <cassert>
+#include <streambuf>
+#include <cmath>
+#include "test_iterators.h"
+#include "hexfloat.h"
+
+typedef std::num_get<char, input_iterator<const char*> > F;
+
+class my_facet
+ : public F
+{
+public:
+ explicit my_facet(std::size_t refs = 0)
+ : F(refs) {}
+};
+
+int main()
+{
+ const my_facet f(1);
+ std::ios ios(0);
+ long double v = -1;
+ {
+ const char str[] = "123";
+ assert((ios.flags() & ios.basefield) == ios.dec);
+ assert(ios.getloc().name() == "C");
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.goodbit);
+ assert(v == 123);
+ }
+ {
+ const char str[] = "-123";
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.goodbit);
+ assert(v == -123);
+ }
+ {
+ const char str[] = "123.5";
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.goodbit);
+ assert(v == 123.5);
+ }
+ {
+ const char str[] = "125e-1";
+ hex(ios);
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.goodbit);
+ assert(v == 125e-1);
+ }
+ {
+ const char str[] = "0x125p-1";
+ hex(ios);
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.goodbit);
+ assert(v == hexfloat<long double>(0x125, 0, -1));
+ }
+ {
+ const char str[] = "inf";
+ hex(ios);
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.goodbit);
+ assert(v == INFINITY);
+ }
+ {
+ const char str[] = "INF";
+ hex(ios);
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.goodbit);
+ assert(v == INFINITY);
+ }
+ {
+ const char str[] = "-inf";
+ hex(ios);
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.goodbit);
+ assert(v == -INFINITY);
+ }
+ {
+ const char str[] = "-INF";
+ hex(ios);
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.goodbit);
+ assert(v == -INFINITY);
+ }
+ {
+ const char str[] = "nan";
+ hex(ios);
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.goodbit);
+ assert(std::isnan(v));
+ }
+ {
+ const char str[] = "NAN";
+ hex(ios);
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.goodbit);
+ assert(std::isnan(v));
+ }
+ {
+ const char str[] = "1.189731495357231765021264e+49321";
+ std::ios_base::iostate err = ios.goodbit;
+ v = 0;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.failbit);
+ assert(v == INFINITY);
+ }
+ {
+ const char str[] = "1.189731495357231765021264e+49329";
+ std::ios_base::iostate err = ios.goodbit;
+ v = 0;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.failbit);
+ assert(v == INFINITY);
+ }
+ {
+ const char str[] = "11.189731495357231765021264e+4932";
+ std::ios_base::iostate err = ios.goodbit;
+ v = 0;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.failbit);
+ assert(v == INFINITY);
+ }
+ {
+ const char str[] = "91.189731495357231765021264e+4932";
+ std::ios_base::iostate err = ios.goodbit;
+ v = 0;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.failbit);
+ assert(v == INFINITY);
+ }
+ {
+ const char str[] = "304888344611713860501504000000";
+ std::ios_base::iostate err = ios.goodbit;
+ v = 0;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err != ios.failbit);
+ assert(v == 304888344611713860501504000000.0L);
+ }
+}
diff --git a/test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_long_long.pass.cpp b/test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_long_long.pass.cpp
new file mode 100644
index 000000000000..fe00876251cb
--- /dev/null
+++ b/test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_long_long.pass.cpp
@@ -0,0 +1,105 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class num_get<charT, InputIterator>
+
+// iter_type get(iter_type in, iter_type end, ios_base&,
+// ios_base::iostate& err, long long& v) const;
+
+#include <locale>
+#include <ios>
+#include <cassert>
+#include <streambuf>
+#include "test_iterators.h"
+
+typedef std::num_get<char, input_iterator<const char*> > F;
+
+class my_facet
+ : public F
+{
+public:
+ explicit my_facet(std::size_t refs = 0)
+ : F(refs) {}
+};
+
+class my_numpunct
+ : public std::numpunct<char>
+{
+public:
+ my_numpunct() : std::numpunct<char>() {}
+
+protected:
+ virtual char_type do_thousands_sep() const {return '_';}
+ virtual std::string do_grouping() const {return std::string("\1\2\3");}
+};
+
+int main()
+{
+ const my_facet f(1);
+ std::ios ios(0);
+ long long v = -1;
+ {
+ const char str[] = "0";
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.goodbit);
+ assert(v == 0);
+ }
+ {
+ const char str[] = "1";
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.goodbit);
+ assert(v == 1);
+ }
+ {
+ const char str[] = "-1";
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.goodbit);
+ assert(v == -1);
+ }
+ hex(ios);
+ {
+ const char str[] = "0x7FFFFFFFFFFFFFFF";
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.goodbit);
+ assert(v == 0x7FFFFFFFFFFFFFFFLL);
+ }
+ {
+ const char str[] = "-0x8000000000000000";
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.goodbit);
+ assert(v == 0x8000000000000000LL);
+ }
+}
diff --git a/test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_pointer.pass.cpp b/test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_pointer.pass.cpp
new file mode 100644
index 000000000000..c290722f32d3
--- /dev/null
+++ b/test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_pointer.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class num_get<charT, InputIterator>
+
+// iter_type get(iter_type in, iter_type end, ios_base&,
+// ios_base::iostate& err, void*& v) const;
+
+#include <locale>
+#include <ios>
+#include <cassert>
+#include <streambuf>
+#include "test_iterators.h"
+
+typedef std::num_get<char, input_iterator<const char*> > F;
+
+class my_facet
+ : public F
+{
+public:
+ explicit my_facet(std::size_t refs = 0)
+ : F(refs) {}
+};
+
+int main()
+{
+ const my_facet f(1);
+ std::ios ios(0);
+ {
+ const char str[] = "0x0";
+ std::ios_base::iostate err = ios.goodbit;
+ void* p;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, p);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.goodbit);
+ assert(p == 0);
+ }
+ {
+ const char str[] = "0x73";
+ std::ios_base::iostate err = ios.goodbit;
+ void* p;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, p);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.goodbit);
+ assert(p == (void*)0x73);
+ }
+}
diff --git a/test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_unsigned_int.pass.cpp b/test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_unsigned_int.pass.cpp
new file mode 100644
index 000000000000..2d10569796c9
--- /dev/null
+++ b/test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_unsigned_int.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class num_get<charT, InputIterator>
+
+// iter_type get(iter_type in, iter_type end, ios_base&,
+// ios_base::iostate& err, unsigned int& v) const;
+
+#include <locale>
+#include <ios>
+#include <cassert>
+#include <streambuf>
+#include "test_iterators.h"
+
+typedef std::num_get<char, input_iterator<const char*> > F;
+
+class my_facet
+ : public F
+{
+public:
+ explicit my_facet(std::size_t refs = 0)
+ : F(refs) {}
+};
+
+class my_numpunct
+ : public std::numpunct<char>
+{
+public:
+ my_numpunct() : std::numpunct<char>() {}
+
+protected:
+ virtual char_type do_thousands_sep() const {return '_';}
+ virtual std::string do_grouping() const {return std::string("\1\2\3");}
+};
+
+int main()
+{
+ const my_facet f(1);
+ std::ios ios(0);
+ unsigned int v = -1;
+ {
+ const char str[] = "0";
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.goodbit);
+ assert(v == 0);
+ }
+ {
+ const char str[] = "1";
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.goodbit);
+ assert(v == 1);
+ }
+ hex(ios);
+ {
+ const char str[] = "0xFFFFFFFF";
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.goodbit);
+ assert(v == 0xFFFFFFFF);
+ }
+}
diff --git a/test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_unsigned_long.pass.cpp b/test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_unsigned_long.pass.cpp
new file mode 100644
index 000000000000..50f0ff5ee5da
--- /dev/null
+++ b/test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_unsigned_long.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class num_get<charT, InputIterator>
+
+// iter_type get(iter_type in, iter_type end, ios_base&,
+// ios_base::iostate& err, unsigned long& v) const;
+
+#include <locale>
+#include <ios>
+#include <cassert>
+#include <streambuf>
+#include "test_iterators.h"
+
+typedef std::num_get<char, input_iterator<const char*> > F;
+
+class my_facet
+ : public F
+{
+public:
+ explicit my_facet(std::size_t refs = 0)
+ : F(refs) {}
+};
+
+class my_numpunct
+ : public std::numpunct<char>
+{
+public:
+ my_numpunct() : std::numpunct<char>() {}
+
+protected:
+ virtual char_type do_thousands_sep() const {return '_';}
+ virtual std::string do_grouping() const {return std::string("\1\2\3");}
+};
+
+int main()
+{
+ const my_facet f(1);
+ std::ios ios(0);
+ unsigned long v = -1;
+ {
+ const char str[] = "0";
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.goodbit);
+ assert(v == 0);
+ }
+ {
+ const char str[] = "1";
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.goodbit);
+ assert(v == 1);
+ }
+ hex(ios);
+ {
+ const char str[] = "0xFFFFFFFF";
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.goodbit);
+ assert(v == 0xFFFFFFFF);
+ }
+}
diff --git a/test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_unsigned_long_long.pass.cpp b/test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_unsigned_long_long.pass.cpp
new file mode 100644
index 000000000000..31fbb2a2c819
--- /dev/null
+++ b/test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_unsigned_long_long.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class num_get<charT, InputIterator>
+
+// iter_type get(iter_type in, iter_type end, ios_base&,
+// ios_base::iostate& err, unsigned long long& v) const;
+
+#include <locale>
+#include <ios>
+#include <cassert>
+#include <streambuf>
+#include "test_iterators.h"
+
+typedef std::num_get<char, input_iterator<const char*> > F;
+
+class my_facet
+ : public F
+{
+public:
+ explicit my_facet(std::size_t refs = 0)
+ : F(refs) {}
+};
+
+class my_numpunct
+ : public std::numpunct<char>
+{
+public:
+ my_numpunct() : std::numpunct<char>() {}
+
+protected:
+ virtual char_type do_thousands_sep() const {return '_';}
+ virtual std::string do_grouping() const {return std::string("\1\2\3");}
+};
+
+int main()
+{
+ const my_facet f(1);
+ std::ios ios(0);
+ unsigned long long v = -1;
+ {
+ const char str[] = "0";
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.goodbit);
+ assert(v == 0);
+ }
+ {
+ const char str[] = "1";
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.goodbit);
+ assert(v == 1);
+ }
+ hex(ios);
+ {
+ const char str[] = "0xFFFFFFFFFFFFFFFF";
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.goodbit);
+ assert(v == 0xFFFFFFFFFFFFFFFFULL);
+ }
+}
diff --git a/test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_unsigned_short.pass.cpp b/test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_unsigned_short.pass.cpp
new file mode 100644
index 000000000000..822b83e0ff93
--- /dev/null
+++ b/test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_unsigned_short.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class num_get<charT, InputIterator>
+
+// iter_type get(iter_type in, iter_type end, ios_base&,
+// ios_base::iostate& err, unsigned short& v) const;
+
+#include <locale>
+#include <ios>
+#include <cassert>
+#include <streambuf>
+#include "test_iterators.h"
+
+typedef std::num_get<char, input_iterator<const char*> > F;
+
+class my_facet
+ : public F
+{
+public:
+ explicit my_facet(std::size_t refs = 0)
+ : F(refs) {}
+};
+
+class my_numpunct
+ : public std::numpunct<char>
+{
+public:
+ my_numpunct() : std::numpunct<char>() {}
+
+protected:
+ virtual char_type do_thousands_sep() const {return '_';}
+ virtual std::string do_grouping() const {return std::string("\1\2\3");}
+};
+
+int main()
+{
+ const my_facet f(1);
+ std::ios ios(0);
+ unsigned short v = -1;
+ {
+ const char str[] = "0";
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.goodbit);
+ assert(v == 0);
+ }
+ {
+ const char str[] = "1";
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.goodbit);
+ assert(v == 1);
+ }
+ hex(ios);
+ {
+ const char str[] = "0xFFFF";
+ std::ios_base::iostate err = ios.goodbit;
+ input_iterator<const char*> iter =
+ f.get(input_iterator<const char*>(str),
+ input_iterator<const char*>(str+sizeof(str)),
+ ios, err, v);
+ assert(iter.base() == str+sizeof(str)-1);
+ assert(err == ios.goodbit);
+ assert(v == 0xFFFF);
+ }
+}
diff --git a/test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/test_min_max.pass.cpp b/test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/test_min_max.pass.cpp
new file mode 100644
index 000000000000..e474eca2f5b2
--- /dev/null
+++ b/test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/test_min_max.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <limits>
+#include <sstream>
+#include <iostream>
+#include <cassert>
+#include <iostream>
+
+using namespace std;
+
+template<typename T>
+void check_limits()
+{
+ T minv = numeric_limits<T>::min();
+ T maxv = numeric_limits<T>::max();
+
+ ostringstream miniss, maxiss;
+ assert(miniss << minv);
+ assert(maxiss << maxv);
+ std::string mins = miniss.str();
+ std::string maxs = maxiss.str();
+
+ istringstream maxoss(maxs), minoss(mins);
+
+ T new_minv, new_maxv;
+ assert(maxoss >> new_maxv);
+ assert(minoss >> new_minv);
+
+ assert(new_minv == minv);
+ assert(new_maxv == maxv);
+
+ if(mins == "0")
+ mins = "-1";
+ else
+ mins[mins.size() - 1]++;
+
+ maxs[maxs.size() - 1]++;
+
+ istringstream maxoss2(maxs), minoss2(mins);
+
+ assert(! (maxoss2 >> new_maxv));
+ assert(! (minoss2 >> new_minv));
+}
+
+int main(void)
+{
+ check_limits<short>();
+ check_limits<unsigned short>();
+ check_limits<int>();
+ check_limits<unsigned int>();
+ check_limits<long>();
+ check_limits<unsigned long>();
+ check_limits<long long>();
+ check_limits<unsigned long long>();
+}
diff --git a/test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.virtuals/tested_elsewhere.pass.cpp b/test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.virtuals/tested_elsewhere.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.virtuals/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/localization/locale.categories/category.numeric/locale.num.get/types.pass.cpp b/test/std/localization/locale.categories/category.numeric/locale.num.get/types.pass.cpp
new file mode 100644
index 000000000000..b87b4b99b2f7
--- /dev/null
+++ b/test/std/localization/locale.categories/category.numeric/locale.num.get/types.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT, class InputIterator = istreambuf_iterator<charT> >
+// class num_get
+// : public locale::facet
+// {
+// public:
+// typedef charT char_type;
+// typedef InputIterator iter_type;
+
+#include <locale>
+#include <iterator>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_base_of<std::locale::facet, std::num_get<char> >::value), "");
+ static_assert((std::is_base_of<std::locale::facet, std::num_get<wchar_t> >::value), "");
+ static_assert((std::is_same<std::num_get<char>::char_type, char>::value), "");
+ static_assert((std::is_same<std::num_get<wchar_t>::char_type, wchar_t>::value), "");
+ static_assert((std::is_same<std::num_get<char>::iter_type, std::istreambuf_iterator<char> >::value), "");
+ static_assert((std::is_same<std::num_get<wchar_t>::iter_type, std::istreambuf_iterator<wchar_t> >::value), "");
+}
diff --git a/test/std/localization/locale.categories/category.numeric/nothing_to_do.pass.cpp b/test/std/localization/locale.categories/category.numeric/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/localization/locale.categories/category.numeric/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/localization/locale.categories/category.time/locale.time.get.byname/date_order.pass.cpp b/test/std/localization/locale.categories/category.time/locale.time.get.byname/date_order.pass.cpp
new file mode 100644
index 000000000000..963974d118bb
--- /dev/null
+++ b/test/std/localization/locale.categories/category.time/locale.time.get.byname/date_order.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: locale.en_US.UTF-8
+// REQUIRES: locale.fr_FR.UTF-8
+// REQUIRES: locale.ru_RU.UTF-8
+// REQUIRES: locale.zh_CN.UTF-8
+
+// <locale>
+
+// class time_get_byname<charT, InputIterator>
+
+// dateorder date_order() const;
+
+#include <locale>
+#include <cassert>
+#include "test_iterators.h"
+
+#include "platform_support.h" // locale name macros
+
+typedef std::time_get_byname<char, input_iterator<const char*> > F;
+
+class my_facet
+ : public F
+{
+public:
+ explicit my_facet(const std::string& nm, std::size_t refs = 0)
+ : F(nm, refs) {}
+};
+
+int main()
+{
+ {
+ const my_facet f(LOCALE_en_US_UTF_8, 1);
+ assert(f.date_order() == std::time_base::mdy);
+ }
+ {
+ const my_facet f(LOCALE_fr_FR_UTF_8, 1);
+ assert(f.date_order() == std::time_base::dmy);
+ }
+ {
+ const my_facet f(LOCALE_ru_RU_UTF_8, 1);
+ assert(f.date_order() == std::time_base::dmy);
+ }
+ {
+ const my_facet f(LOCALE_zh_CN_UTF_8, 1);
+ assert(f.date_order() == std::time_base::ymd);
+ }
+}
diff --git a/test/std/localization/locale.categories/category.time/locale.time.get.byname/date_order_wide.pass.cpp b/test/std/localization/locale.categories/category.time/locale.time.get.byname/date_order_wide.pass.cpp
new file mode 100644
index 000000000000..c44debf35abe
--- /dev/null
+++ b/test/std/localization/locale.categories/category.time/locale.time.get.byname/date_order_wide.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: locale.en_US.UTF-8
+// REQUIRES: locale.fr_FR.UTF-8
+// REQUIRES: locale.ru_RU.UTF-8
+// REQUIRES: locale.zh_CN.UTF-8
+
+// <locale>
+
+// class time_get_byname<charT, InputIterator>
+
+// dateorder date_order() const;
+
+#include <locale>
+#include <cassert>
+#include "test_iterators.h"
+
+#include "platform_support.h" // locale name macros
+
+typedef std::time_get_byname<wchar_t, input_iterator<const wchar_t*> > F;
+
+class my_facet
+ : public F
+{
+public:
+ explicit my_facet(const std::string& nm, std::size_t refs = 0)
+ : F(nm, refs) {}
+};
+
+int main()
+{
+ {
+ const my_facet f(LOCALE_en_US_UTF_8, 1);
+ assert(f.date_order() == std::time_base::mdy);
+ }
+ {
+ const my_facet f(LOCALE_fr_FR_UTF_8, 1);
+ assert(f.date_order() == std::time_base::dmy);
+ }
+ {
+ const my_facet f(LOCALE_ru_RU_UTF_8, 1);
+ assert(f.date_order() == std::time_base::dmy);
+ }
+ {
+ const my_facet f(LOCALE_zh_CN_UTF_8, 1);
+ assert(f.date_order() == std::time_base::ymd);
+ }
+}
diff --git a/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_date.pass.cpp b/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_date.pass.cpp
new file mode 100644
index 000000000000..9a06157ada59
--- /dev/null
+++ b/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_date.pass.cpp
@@ -0,0 +1,99 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: locale.en_US.UTF-8
+// REQUIRES: locale.fr_FR.UTF-8
+// REQUIRES: locale.ru_RU.UTF-8
+// REQUIRES: locale.zh_CN.UTF-8
+
+// GLIBC Expects "10/06/2009" for fr_FR as opposed to "10.06.2009"
+// GLIBC also failes on the zh_CN test.
+// XFAIL: linux
+
+// <locale>
+
+// class time_get_byname<charT, InputIterator>
+
+// iter_type
+// get_date(iter_type s, iter_type end, ios_base& str,
+// ios_base::iostate& err, tm* t) const;
+
+#include <locale>
+#include <cassert>
+#include "test_iterators.h"
+
+#include "platform_support.h" // locale name macros
+
+typedef input_iterator<const char*> I;
+
+typedef std::time_get_byname<char, I> F;
+
+class my_facet
+ : public F
+{
+public:
+ explicit my_facet(const std::string& nm, std::size_t refs = 0)
+ : F(nm, refs) {}
+};
+
+int main()
+{
+ std::ios ios(0);
+ std::ios_base::iostate err;
+ std::tm t;
+ {
+ const my_facet f(LOCALE_en_US_UTF_8, 1);
+ const char in[] = "06/10/2009";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_date(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+ assert(t.tm_mon == 5);
+ assert(t.tm_mday == 10);
+ assert(t.tm_year == 109);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const my_facet f(LOCALE_fr_FR_UTF_8, 1);
+ const char in[] = "10.06.2009";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_date(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+ assert(t.tm_mon == 5);
+ assert(t.tm_mday == 10);
+ assert(t.tm_year == 109);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const my_facet f(LOCALE_ru_RU_UTF_8, 1);
+ const char in[] = "10.06.2009";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_date(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+ assert(t.tm_mon == 5);
+ assert(t.tm_mday == 10);
+ assert(t.tm_year == 109);
+ assert(err == std::ios_base::eofbit);
+ }
+
+ {
+ const my_facet f(LOCALE_zh_CN_UTF_8, 1);
+ const char in[] = "2009/06/10";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_date(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+ assert(t.tm_mon == 5);
+ assert(t.tm_mday == 10);
+ assert(t.tm_year == 109);
+ assert(err == std::ios_base::eofbit);
+ }
+}
diff --git a/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_date_wide.pass.cpp b/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_date_wide.pass.cpp
new file mode 100644
index 000000000000..170f33ad9813
--- /dev/null
+++ b/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_date_wide.pass.cpp
@@ -0,0 +1,98 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: locale.en_US.UTF-8
+// REQUIRES: locale.fr_FR.UTF-8
+// REQUIRES: locale.ru_RU.UTF-8
+// REQUIRES: locale.zh_CN.UTF-8
+
+// GLIBC Expects "10/06/2009" for fr_FR as opposed to "10.06.2009"
+// GLIBC also failes on the zh_CN test.
+// XFAIL: linux
+
+// <locale>
+
+// class time_get_byname<charT, InputIterator>
+
+// iter_type
+// get_date(iter_type s, iter_type end, ios_base& str,
+// ios_base::iostate& err, tm* t) const;
+
+#include <locale>
+#include <cassert>
+#include "test_iterators.h"
+
+#include "platform_support.h" // locale name macros
+
+typedef input_iterator<const wchar_t*> I;
+
+typedef std::time_get_byname<wchar_t, I> F;
+
+class my_facet
+ : public F
+{
+public:
+ explicit my_facet(const std::string& nm, std::size_t refs = 0)
+ : F(nm, refs) {}
+};
+
+int main()
+{
+ std::ios ios(0);
+ std::ios_base::iostate err;
+ std::tm t;
+ {
+ const my_facet f(LOCALE_en_US_UTF_8, 1);
+ const wchar_t in[] = L"06/10/2009";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_date(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+ assert(t.tm_mon == 5);
+ assert(t.tm_mday == 10);
+ assert(t.tm_year == 109);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const my_facet f(LOCALE_fr_FR_UTF_8, 1);
+ const wchar_t in[] = L"10.06.2009";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_date(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+ assert(t.tm_mon == 5);
+ assert(t.tm_mday == 10);
+ assert(t.tm_year == 109);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const my_facet f(LOCALE_ru_RU_UTF_8, 1);
+ const wchar_t in[] = L"10.06.2009";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_date(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+ assert(t.tm_mon == 5);
+ assert(t.tm_mday == 10);
+ assert(t.tm_year == 109);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const my_facet f(LOCALE_zh_CN_UTF_8, 1);
+ const wchar_t in[] = L"2009/06/10";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_date(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+ assert(t.tm_mon == 5);
+ assert(t.tm_mday == 10);
+ assert(t.tm_year == 109);
+ assert(err == std::ios_base::eofbit);
+ }
+}
diff --git a/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_monthname.pass.cpp b/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_monthname.pass.cpp
new file mode 100644
index 000000000000..a442ae577b47
--- /dev/null
+++ b/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_monthname.pass.cpp
@@ -0,0 +1,92 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: locale.en_US.UTF-8
+// REQUIRES: locale.fr_FR.UTF-8
+// REQUIRES: locale.ru_RU.UTF-8
+// REQUIRES: locale.zh_CN.UTF-8
+
+// NOTE: debian and opensuse use old locale data for ru_RU.UTF-8 abreviated
+// months. This locale data was changed in glibc 2.14.
+// Debian uses glibc 2.13 as of 20/11/2014
+// OpenSuse uses glibc 2.19 with old locale data as of 20/11/2014
+// XFAIL: debian, opensuse
+
+// <locale>
+
+// class time_get_byname<charT, InputIterator>
+
+// iter_type
+// get_monthname(iter_type s, iter_type end, ios_base& str,
+// ios_base::iostate& err, tm* t) const;
+
+#include <locale>
+#include <cassert>
+#include "test_iterators.h"
+
+#include "platform_support.h" // locale name macros
+
+typedef input_iterator<const char*> I;
+
+typedef std::time_get_byname<char, I> F;
+
+class my_facet
+ : public F
+{
+public:
+ explicit my_facet(const std::string& nm, std::size_t refs = 0)
+ : F(nm, refs) {}
+};
+
+int main()
+{
+ std::ios ios(0);
+ std::ios_base::iostate err;
+ std::tm t;
+ {
+ const my_facet f(LOCALE_en_US_UTF_8, 1);
+ const char in[] = "June";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+ assert(t.tm_mon == 5);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const my_facet f(LOCALE_fr_FR_UTF_8, 1);
+ const char in[] = "juin";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+ assert(t.tm_mon == 5);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const my_facet f(LOCALE_ru_RU_UTF_8, 1);
+ const char in[] = "\xD0\xB8\xD1\x8E\xD0\xBD\xD1\x8F";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+ assert(t.tm_mon == 5);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const my_facet f(LOCALE_zh_CN_UTF_8, 1);
+ const char in[] = "\xE5\x85\xAD\xE6\x9C\x88";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+ assert(t.tm_mon == 5);
+ assert(err == std::ios_base::eofbit);
+ }
+}
diff --git a/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_monthname_wide.pass.cpp b/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_monthname_wide.pass.cpp
new file mode 100644
index 000000000000..631a500362da
--- /dev/null
+++ b/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_monthname_wide.pass.cpp
@@ -0,0 +1,101 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: locale.en_US.UTF-8
+// REQUIRES: locale.fr_FR.UTF-8
+// REQUIRES: locale.ru_RU.UTF-8
+// REQUIRES: locale.zh_CN.UTF-8
+
+// NOTE: debian and opensuse use bad locale data for ru_RU.UTF-8 abreviated
+// months. This locale data was fixed in glibc 2.14.
+// Debian uses glibc 2.13 as of 20/11/2014
+// OpenSuse uses glibc 2.19 with old locale data as of 20/11/2014
+// XFAIL: debian, opensuse
+
+// <locale>
+
+// class time_get_byname<charT, InputIterator>
+
+// iter_type
+// get_monthname(iter_type s, iter_type end, ios_base& str,
+// ios_base::iostate& err, tm* t) const;
+
+#include <locale>
+#include <cassert>
+#include "test_iterators.h"
+
+#include "platform_support.h" // locale name macros
+
+typedef input_iterator<const wchar_t*> I;
+
+typedef std::time_get_byname<wchar_t, I> F;
+
+class my_facet
+ : public F
+{
+public:
+ explicit my_facet(const std::string& nm, std::size_t refs = 0)
+ : F(nm, refs) {}
+};
+
+typedef std::time_put_byname<wchar_t, wchar_t*> F2;
+class my_facet2
+ : public F2
+{
+public:
+ explicit my_facet2(const std::string& nm, std::size_t refs = 0)
+ : F2(nm, refs) {}
+};
+
+int main()
+{
+ std::ios ios(0);
+ std::ios_base::iostate err;
+ std::tm t;
+ {
+ const my_facet f(LOCALE_en_US_UTF_8, 1);
+ const wchar_t in[] = L"June";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+ assert(t.tm_mon == 5);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const my_facet f(LOCALE_fr_FR_UTF_8, 1);
+ const wchar_t in[] = L"juin";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+ assert(t.tm_mon == 5);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const my_facet f(LOCALE_ru_RU_UTF_8, 1);
+ const wchar_t in[] = L"\x438\x44E\x43D\x44F";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+ assert(t.tm_mon == 5);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const my_facet f(LOCALE_zh_CN_UTF_8, 1);
+ const wchar_t in[] = L"\x516D\x6708";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+ assert(t.tm_mon == 5);
+ assert(err == std::ios_base::eofbit);
+ }
+}
diff --git a/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_one.pass.cpp b/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_one.pass.cpp
new file mode 100644
index 000000000000..72b63278d71d
--- /dev/null
+++ b/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_one.pass.cpp
@@ -0,0 +1,168 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: locale.en_US.UTF-8
+// REQUIRES: locale.fr_FR.UTF-8
+// REQUIRES: locale.ru_RU.UTF-8
+// REQUIRES: locale.zh_CN.UTF-8
+
+// <locale>
+
+// class time_get_byname<charT, InputIterator>
+
+// iter_type get(iter_type s, iter_type end, ios_base& f,
+// ios_base::iostate& err, tm *t, char format, char modifier = 0) const;
+
+// TODO: investigation needed
+// XFAIL: linux-gnu
+
+#include <locale>
+#include <cassert>
+#include "test_iterators.h"
+
+#include "platform_support.h" // locale name macros
+
+typedef input_iterator<const char*> I;
+
+typedef std::time_get_byname<char, I> F;
+
+class my_facet
+ : public F
+{
+public:
+ explicit my_facet(const std::string& nm, std::size_t refs = 0)
+ : F(nm, refs) {}
+};
+
+int main()
+{
+ std::ios ios(0);
+ std::ios_base::iostate err;
+ std::tm t;
+ {
+ const my_facet f(LOCALE_en_US_UTF_8, 1);
+ const char in[] = "Sat Dec 31 23:55:59 2061";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t, 'c');
+ assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+ assert(t.tm_sec == 59);
+ assert(t.tm_min == 55);
+ assert(t.tm_hour == 23);
+ assert(t.tm_mday == 31);
+ assert(t.tm_mon == 11);
+ assert(t.tm_year == 161);
+ assert(t.tm_wday == 6);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const my_facet f(LOCALE_en_US_UTF_8, 1);
+ const char in[] = "23:55:59";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t, 'X');
+ assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+ assert(t.tm_sec == 59);
+ assert(t.tm_min == 55);
+ assert(t.tm_hour == 23);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const my_facet f(LOCALE_fr_FR_UTF_8, 1);
+ const char in[] = "Sam 31 d""\xC3\xA9""c 23:55:59 2061";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t, 'c');
+ assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+ assert(t.tm_sec == 59);
+ assert(t.tm_min == 55);
+ assert(t.tm_hour == 23);
+ assert(t.tm_mday == 31);
+ assert(t.tm_mon == 11);
+ assert(t.tm_year == 161);
+ assert(t.tm_wday == 6);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const my_facet f(LOCALE_fr_FR_UTF_8, 1);
+ const char in[] = "23:55:59";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t, 'X');
+ assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+ assert(t.tm_sec == 59);
+ assert(t.tm_min == 55);
+ assert(t.tm_hour == 23);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const my_facet f(LOCALE_ru_RU_UTF_8, 1);
+ const char in[] = "\xD1\x81\xD1\x83\xD0\xB1\xD0\xB1"
+ "\xD0\xBE\xD1\x82\xD0\xB0"
+ ", 31 "
+ "\xD0\xB4\xD0\xB5\xD0\xBA\xD0\xB0"
+ "\xD0\xB1\xD1\x80\xD1\x8F"
+ " 2061 "
+ "\xD0\xB3"
+ ". 23:55:59";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t, 'c');
+ assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+ assert(t.tm_sec == 59);
+ assert(t.tm_min == 55);
+ assert(t.tm_hour == 23);
+ assert(t.tm_mday == 31);
+ assert(t.tm_mon == 11);
+ assert(t.tm_year == 161);
+ assert(t.tm_wday == 6);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const my_facet f(LOCALE_ru_RU_UTF_8, 1);
+ const char in[] = "23:55:59";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t, 'X');
+ assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+ assert(t.tm_sec == 59);
+ assert(t.tm_min == 55);
+ assert(t.tm_hour == 23);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const my_facet f(LOCALE_zh_CN_UTF_8, 1);
+ const char in[] = "\xE5\x85\xAD"
+ " 12/31 23:55:59 2061";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t, 'c');
+ assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+ assert(t.tm_sec == 59);
+ assert(t.tm_min == 55);
+ assert(t.tm_hour == 23);
+ assert(t.tm_mday == 31);
+ assert(t.tm_mon == 11);
+ assert(t.tm_year == 161);
+ assert(t.tm_wday == 6);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const my_facet f(LOCALE_zh_CN_UTF_8, 1);
+ const char in[] = "23""\xE6\x97\xB6""55""\xE5\x88\x86""59""\xE7\xA7\x92";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t, 'X');
+ assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+ assert(t.tm_sec == 59);
+ assert(t.tm_min == 55);
+ assert(t.tm_hour == 23);
+ assert(err == std::ios_base::eofbit);
+ }
+}
diff --git a/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_one_wide.pass.cpp b/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_one_wide.pass.cpp
new file mode 100644
index 000000000000..ae8bce22445a
--- /dev/null
+++ b/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_one_wide.pass.cpp
@@ -0,0 +1,170 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: locale.en_US.UTF-8
+// REQUIRES: locale.fr_FR.UTF-8
+// REQUIRES: locale.ru_RU.UTF-8
+// REQUIRES: locale.zh_CN.UTF-8
+
+// <locale>
+
+// class time_get_byname<charT, InputIterator>
+
+// iter_type get(iter_type s, iter_type end, ios_base& f,
+// ios_base::iostate& err, tm *t, char format, char modifier = 0) const;
+
+// TODO: investigation needed
+// XFAIL: linux-gnu
+
+#include <locale>
+#include <cassert>
+#include "test_iterators.h"
+
+#include "platform_support.h" // locale name macros
+
+typedef input_iterator<const wchar_t*> I;
+
+typedef std::time_get_byname<wchar_t, I> F;
+
+class my_facet
+ : public F
+{
+public:
+ explicit my_facet(const std::string& nm, std::size_t refs = 0)
+ : F(nm, refs) {}
+};
+
+int main()
+{
+ std::ios ios(0);
+ std::ios_base::iostate err;
+ std::tm t;
+ {
+ const my_facet f(LOCALE_en_US_UTF_8, 1);
+ const wchar_t in[] = L"Sat Dec 31 23:55:59 2061";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t, 'c');
+ assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+ assert(t.tm_sec == 59);
+ assert(t.tm_min == 55);
+ assert(t.tm_hour == 23);
+ assert(t.tm_mday == 31);
+ assert(t.tm_mon == 11);
+ assert(t.tm_year == 161);
+ assert(t.tm_wday == 6);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const my_facet f(LOCALE_en_US_UTF_8, 1);
+ const wchar_t in[] = L"23:55:59";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t, 'X');
+ assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+ assert(t.tm_sec == 59);
+ assert(t.tm_min == 55);
+ assert(t.tm_hour == 23);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const my_facet f(LOCALE_fr_FR_UTF_8, 1);
+ const wchar_t in[] = L"Sam 31 d""\xE9""c 23:55:59 2061";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t, 'c');
+ assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+ assert(t.tm_sec == 59);
+ assert(t.tm_min == 55);
+ assert(t.tm_hour == 23);
+ assert(t.tm_mday == 31);
+ assert(t.tm_mon == 11);
+ assert(t.tm_year == 161);
+ assert(t.tm_wday == 6);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const my_facet f(LOCALE_fr_FR_UTF_8, 1);
+ const wchar_t in[] = L"23:55:59";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t, 'X');
+ assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+ assert(t.tm_sec == 59);
+ assert(t.tm_min == 55);
+ assert(t.tm_hour == 23);
+ assert(err == std::ios_base::eofbit);
+ }
+#ifdef __APPLE__
+ {
+ const my_facet f("ru_RU", 1);
+ const wchar_t in[] = L"\x441\x443\x431\x431\x43E\x442\x430"
+ ", 31 "
+ "\x434\x435\x43A\x430\x431\x440\x44F"
+ " 2061 "
+ "\x433"
+ ". 23:55:59";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t, 'c');
+ assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+ assert(t.tm_sec == 59);
+ assert(t.tm_min == 55);
+ assert(t.tm_hour == 23);
+ assert(t.tm_mday == 31);
+ assert(t.tm_mon == 11);
+ assert(t.tm_year == 161);
+ assert(t.tm_wday == 6);
+ assert(err == std::ios_base::eofbit);
+ }
+#endif
+ {
+ const my_facet f(LOCALE_ru_RU_UTF_8, 1);
+ const wchar_t in[] = L"23:55:59";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t, 'X');
+ assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+ assert(t.tm_sec == 59);
+ assert(t.tm_min == 55);
+ assert(t.tm_hour == 23);
+ assert(err == std::ios_base::eofbit);
+ }
+#ifdef __APPLE__
+ {
+ const my_facet f("zh_CN", 1);
+ const wchar_t in[] = L"\x516D"
+ " 12/31 23:55:59 2061";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t, 'c');
+ assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+ assert(t.tm_sec == 59);
+ assert(t.tm_min == 55);
+ assert(t.tm_hour == 23);
+ assert(t.tm_mday == 31);
+ assert(t.tm_mon == 11);
+ assert(t.tm_year == 161);
+ assert(t.tm_wday == 6);
+ assert(err == std::ios_base::eofbit);
+ }
+#endif
+ {
+ const my_facet f(LOCALE_zh_CN_UTF_8, 1);
+ const wchar_t in[] = L"23""\x65F6""55""\x5206""59""\x79D2";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t, 'X');
+ assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+ assert(t.tm_sec == 59);
+ assert(t.tm_min == 55);
+ assert(t.tm_hour == 23);
+ assert(err == std::ios_base::eofbit);
+ }
+}
diff --git a/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_time.pass.cpp b/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_time.pass.cpp
new file mode 100644
index 000000000000..8cea95de80ea
--- /dev/null
+++ b/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_time.pass.cpp
@@ -0,0 +1,94 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: locale.en_US.UTF-8
+// REQUIRES: locale.fr_FR.UTF-8
+// REQUIRES: locale.ru_RU.UTF-8
+// REQUIRES: locale.zh_CN.UTF-8
+
+// <locale>
+
+// class time_get_byname<charT, InputIterator>
+
+// iter_type
+// get_time(iter_type s, iter_type end, ios_base& str,
+// ios_base::iostate& err, tm* t) const;
+
+#include <locale>
+#include <cassert>
+#include "test_iterators.h"
+
+#include "platform_support.h" // locale name macros
+
+typedef input_iterator<const char*> I;
+
+typedef std::time_get_byname<char, I> F;
+
+class my_facet
+ : public F
+{
+public:
+ explicit my_facet(const std::string& nm, std::size_t refs = 0)
+ : F(nm, refs) {}
+};
+
+int main()
+{
+ std::ios ios(0);
+ std::ios_base::iostate err;
+ std::tm t;
+ {
+ const my_facet f(LOCALE_en_US_UTF_8, 1);
+ const char in[] = "13:14:15";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_time(I(in), I(in+sizeof(in)-1), ios, err, &t);
+ assert(i.base() == in+sizeof(in)-1);
+ assert(t.tm_hour == 13);
+ assert(t.tm_min == 14);
+ assert(t.tm_sec == 15);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const my_facet f(LOCALE_fr_FR_UTF_8, 1);
+ const char in[] = "13:14:15";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_time(I(in), I(in+sizeof(in)-1), ios, err, &t);
+ assert(i.base() == in+sizeof(in)-1);
+ assert(t.tm_hour == 13);
+ assert(t.tm_min == 14);
+ assert(t.tm_sec == 15);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const my_facet f(LOCALE_ru_RU_UTF_8, 1);
+ const char in[] = "13:14:15";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_time(I(in), I(in+sizeof(in)-1), ios, err, &t);
+ assert(i.base() == in+sizeof(in)-1);
+ assert(t.tm_hour == 13);
+ assert(t.tm_min == 14);
+ assert(t.tm_sec == 15);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const my_facet f(LOCALE_zh_CN_UTF_8, 1);
+ const char in[] = "13:14:15";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_time(I(in), I(in+sizeof(in)-1), ios, err, &t);
+ assert(i.base() == in+sizeof(in)-1);
+ assert(t.tm_hour == 13);
+ assert(t.tm_min == 14);
+ assert(t.tm_sec == 15);
+ assert(err == std::ios_base::eofbit);
+ }
+}
diff --git a/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_time_wide.pass.cpp b/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_time_wide.pass.cpp
new file mode 100644
index 000000000000..452a3544033d
--- /dev/null
+++ b/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_time_wide.pass.cpp
@@ -0,0 +1,94 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: locale.en_US.UTF-8
+// REQUIRES: locale.fr_FR.UTF-8
+// REQUIRES: locale.ru_RU.UTF-8
+// REQUIRES: locale.zh_CN.UTF-8
+
+// <locale>
+
+// class time_get_byname<charT, InputIterator>
+
+// iter_type
+// get_time(iter_type s, iter_type end, ios_base& str,
+// ios_base::iostate& err, tm* t) const;
+
+#include <locale>
+#include <cassert>
+#include "test_iterators.h"
+
+#include "platform_support.h" // locale name macros
+
+typedef input_iterator<const wchar_t*> I;
+
+typedef std::time_get_byname<wchar_t, I> F;
+
+class my_facet
+ : public F
+{
+public:
+ explicit my_facet(const std::string& nm, std::size_t refs = 0)
+ : F(nm, refs) {}
+};
+
+int main()
+{
+ std::ios ios(0);
+ std::ios_base::iostate err;
+ std::tm t;
+ {
+ const my_facet f(LOCALE_en_US_UTF_8, 1);
+ const wchar_t in[] = L"13:14:15";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_time(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+ assert(t.tm_hour == 13);
+ assert(t.tm_min == 14);
+ assert(t.tm_sec == 15);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const my_facet f(LOCALE_fr_FR_UTF_8, 1);
+ const wchar_t in[] = L"13:14:15";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_time(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+ assert(t.tm_hour == 13);
+ assert(t.tm_min == 14);
+ assert(t.tm_sec == 15);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const my_facet f(LOCALE_ru_RU_UTF_8, 1);
+ const wchar_t in[] = L"13:14:15";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_time(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+ assert(t.tm_hour == 13);
+ assert(t.tm_min == 14);
+ assert(t.tm_sec == 15);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const my_facet f(LOCALE_zh_CN_UTF_8, 1);
+ const wchar_t in[] = L"13:14:15";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_time(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+ assert(t.tm_hour == 13);
+ assert(t.tm_min == 14);
+ assert(t.tm_sec == 15);
+ assert(err == std::ios_base::eofbit);
+ }
+}
diff --git a/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_weekday.pass.cpp b/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_weekday.pass.cpp
new file mode 100644
index 000000000000..09055add75a9
--- /dev/null
+++ b/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_weekday.pass.cpp
@@ -0,0 +1,91 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: locale.en_US.UTF-8
+// REQUIRES: locale.fr_FR.UTF-8
+// REQUIRES: locale.ru_RU.UTF-8
+// REQUIRES: locale.zh_CN.UTF-8
+
+// <locale>
+
+// class time_get_byname<charT, InputIterator>
+
+// iter_type
+// get_weekday(iter_type s, iter_type end, ios_base& str,
+// ios_base::iostate& err, tm* t) const;
+
+// TODO: investigation needed
+// XFAIL: linux-gnu
+
+#include <locale>
+#include <cassert>
+#include "test_iterators.h"
+
+#include "platform_support.h" // locale name macros
+
+typedef input_iterator<const char*> I;
+
+typedef std::time_get_byname<char, I> F;
+
+class my_facet
+ : public F
+{
+public:
+ explicit my_facet(const std::string& nm, std::size_t refs = 0)
+ : F(nm, refs) {}
+};
+
+int main()
+{
+ std::ios ios(0);
+ std::ios_base::iostate err;
+ std::tm t;
+ {
+ const my_facet f(LOCALE_en_US_UTF_8, 1);
+ const char in[] = "Monday";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+ assert(t.tm_wday == 1);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const my_facet f(LOCALE_fr_FR_UTF_8, 1);
+ const char in[] = "Lundi";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+ assert(t.tm_wday == 1);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const my_facet f(LOCALE_ru_RU_UTF_8, 1);
+ const char in[] = "\xD0\xBF\xD0\xBE\xD0\xBD\xD0\xB5"
+ "\xD0\xB4\xD0\xB5\xD0\xBB\xD1\x8C"
+ "\xD0\xBD\xD0\xB8\xD0\xBA";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+ assert(t.tm_wday == 1);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const my_facet f(LOCALE_zh_CN_UTF_8, 1);
+ const char in[] = "\xE6\x98\x9F\xE6\x9C\x9F\xE4\xB8\x80";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+ assert(t.tm_wday == 1);
+ assert(err == std::ios_base::eofbit);
+ }
+}
diff --git a/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_weekday_wide.pass.cpp b/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_weekday_wide.pass.cpp
new file mode 100644
index 000000000000..31135a349435
--- /dev/null
+++ b/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_weekday_wide.pass.cpp
@@ -0,0 +1,89 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: locale.en_US.UTF-8
+// REQUIRES: locale.fr_FR.UTF-8
+// REQUIRES: locale.ru_RU.UTF-8
+// REQUIRES: locale.zh_CN.UTF-8
+
+// <locale>
+
+// class time_get_byname<charT, InputIterator>
+
+// iter_type
+// get_weekday(iter_type s, iter_type end, ios_base& str,
+// ios_base::iostate& err, tm* t) const;
+
+// TODO: investigation needed
+// XFAIL: linux-gnu
+
+#include <locale>
+#include <cassert>
+#include "test_iterators.h"
+
+#include "platform_support.h" // locale name macros
+
+typedef input_iterator<const wchar_t*> I;
+
+typedef std::time_get_byname<wchar_t, I> F;
+
+class my_facet
+ : public F
+{
+public:
+ explicit my_facet(const std::string& nm, std::size_t refs = 0)
+ : F(nm, refs) {}
+};
+
+int main()
+{
+ std::ios ios(0);
+ std::ios_base::iostate err;
+ std::tm t;
+ {
+ const my_facet f(LOCALE_en_US_UTF_8, 1);
+ const wchar_t in[] = L"Monday";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+ assert(t.tm_wday == 1);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const my_facet f(LOCALE_fr_FR_UTF_8, 1);
+ const wchar_t in[] = L"Lundi";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+ assert(t.tm_wday == 1);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const my_facet f(LOCALE_ru_RU_UTF_8, 1);
+ const wchar_t in[] = L"\x43F\x43E\x43D\x435\x434\x435\x43B\x44C\x43D\x438\x43A";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+ assert(t.tm_wday == 1);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const my_facet f(LOCALE_zh_CN_UTF_8, 1);
+ const wchar_t in[] = L"\x661F\x671F\x4E00";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+ assert(t.tm_wday == 1);
+ assert(err == std::ios_base::eofbit);
+ }
+}
diff --git a/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_year.pass.cpp b/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_year.pass.cpp
new file mode 100644
index 000000000000..676e7fff87f4
--- /dev/null
+++ b/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_year.pass.cpp
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: locale.en_US.UTF-8
+// REQUIRES: locale.fr_FR.UTF-8
+// REQUIRES: locale.ru_RU.UTF-8
+// REQUIRES: locale.zh_CN.UTF-8
+
+// <locale>
+
+// class time_get_byname<charT, InputIterator>
+
+// iter_type get_year(iter_type s, iter_type end, ios_base& str,
+// ios_base::iostate& err, tm* t) const;
+
+#include <locale>
+#include <cassert>
+#include "test_iterators.h"
+
+#include "platform_support.h" // locale name macros
+
+typedef input_iterator<const char*> I;
+
+typedef std::time_get_byname<char, I> F;
+
+class my_facet
+ : public F
+{
+public:
+ explicit my_facet(const std::string& nm, std::size_t refs = 0)
+ : F(nm, refs) {}
+};
+
+int main()
+{
+ std::ios ios(0);
+ std::ios_base::iostate err;
+ std::tm t;
+ {
+ const my_facet f(LOCALE_en_US_UTF_8, 1);
+ const char in[] = "2009";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_year(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+ assert(t.tm_year == 109);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const my_facet f(LOCALE_fr_FR_UTF_8, 1);
+ const char in[] = "2009";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_year(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+ assert(t.tm_year == 109);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const my_facet f(LOCALE_ru_RU_UTF_8, 1);
+ const char in[] = "2009";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_year(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+ assert(t.tm_year == 109);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const my_facet f(LOCALE_zh_CN_UTF_8, 1);
+ const char in[] = "2009";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_year(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+ assert(t.tm_year == 109);
+ assert(err == std::ios_base::eofbit);
+ }
+}
diff --git a/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_year_wide.pass.cpp b/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_year_wide.pass.cpp
new file mode 100644
index 000000000000..1bdb8de601d4
--- /dev/null
+++ b/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_year_wide.pass.cpp
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: locale.en_US.UTF-8
+// REQUIRES: locale.fr_FR.UTF-8
+// REQUIRES: locale.ru_RU.UTF-8
+// REQUIRES: locale.zh_CN.UTF-8
+
+// <locale>
+
+// class time_get_byname<charT, InputIterator>
+
+// iter_type get_year(iter_type s, iter_type end, ios_base& str,
+// ios_base::iostate& err, tm* t) const;
+
+#include <locale>
+#include <cassert>
+#include "test_iterators.h"
+
+#include "platform_support.h" // locale name macros
+
+typedef input_iterator<const wchar_t*> I;
+
+typedef std::time_get_byname<wchar_t, I> F;
+
+class my_facet
+ : public F
+{
+public:
+ explicit my_facet(const std::string& nm, std::size_t refs = 0)
+ : F(nm, refs) {}
+};
+
+int main()
+{
+ std::ios ios(0);
+ std::ios_base::iostate err;
+ std::tm t;
+ {
+ const my_facet f(LOCALE_en_US_UTF_8, 1);
+ const wchar_t in[] = L"2009";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_year(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+ assert(t.tm_year == 109);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const my_facet f(LOCALE_fr_FR_UTF_8, 1);
+ const wchar_t in[] = L"2009";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_year(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+ assert(t.tm_year == 109);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const my_facet f(LOCALE_ru_RU_UTF_8, 1);
+ const wchar_t in[] = L"2009";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_year(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+ assert(t.tm_year == 109);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const my_facet f(LOCALE_zh_CN_UTF_8, 1);
+ const wchar_t in[] = L"2009";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_year(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+ assert(t.tm_year == 109);
+ assert(err == std::ios_base::eofbit);
+ }
+}
diff --git a/test/std/localization/locale.categories/category.time/locale.time.get/ctor.pass.cpp b/test/std/localization/locale.categories/category.time/locale.time.get/ctor.pass.cpp
new file mode 100644
index 000000000000..c6c4359e48c6
--- /dev/null
+++ b/test/std/localization/locale.categories/category.time/locale.time.get/ctor.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class time_get<charT, InputIterator>
+
+// explicit time_get(size_t refs = 0);
+
+#include <locale>
+#include <cassert>
+
+typedef std::time_get<char, const char*> F;
+
+class my_facet
+ : public F
+{
+public:
+ static int count;
+
+ explicit my_facet(std::size_t refs = 0)
+ : F(refs) {++count;}
+
+ ~my_facet() {--count;}
+};
+
+int my_facet::count = 0;
+
+int main()
+{
+ {
+ std::locale l(std::locale::classic(), new my_facet);
+ assert(my_facet::count == 1);
+ }
+ assert(my_facet::count == 0);
+ {
+ my_facet f(1);
+ assert(my_facet::count == 1);
+ {
+ std::locale l(std::locale::classic(), &f);
+ assert(my_facet::count == 1);
+ }
+ assert(my_facet::count == 1);
+ }
+ assert(my_facet::count == 0);
+}
diff --git a/test/std/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/date_order.pass.cpp b/test/std/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/date_order.pass.cpp
new file mode 100644
index 000000000000..264494ba6183
--- /dev/null
+++ b/test/std/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/date_order.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class time_get<charT, InputIterator>
+
+// dateorder date_order() const;
+
+#include <locale>
+#include <cassert>
+#include "test_iterators.h"
+
+typedef std::time_get<char, input_iterator<const char*> > F;
+
+class my_facet
+ : public F
+{
+public:
+ explicit my_facet(std::size_t refs = 0)
+ : F(refs) {}
+};
+
+int main()
+{
+ const my_facet f(1);
+ assert(f.date_order() == std::time_base::mdy);
+}
diff --git a/test/std/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_date.pass.cpp b/test/std/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_date.pass.cpp
new file mode 100644
index 000000000000..6b8bd73bed5b
--- /dev/null
+++ b/test/std/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_date.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class time_get<charT, InputIterator>
+
+// iter_type
+// get_date(iter_type s, iter_type end, ios_base& str,
+// ios_base::iostate& err, tm* t) const;
+
+#include <locale>
+#include <cassert>
+#include "test_iterators.h"
+
+typedef input_iterator<const char*> I;
+
+typedef std::time_get<char, I> F;
+
+class my_facet
+ : public F
+{
+public:
+ explicit my_facet(std::size_t refs = 0)
+ : F(refs) {}
+};
+
+int main()
+{
+ const my_facet f(1);
+ std::ios ios(0);
+ std::ios_base::iostate err;
+ std::tm t;
+ {
+ const char in[] = "5/5/5";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_date(I(in), I(in+sizeof(in)-1), ios, err, &t);
+ assert(i.base() == in+sizeof(in)-1);
+ assert(t.tm_mon == 4);
+ assert(t.tm_mday == 5);
+ assert(t.tm_year == 105);
+ assert(err == std::ios_base::eofbit);
+ }
+}
diff --git a/test/std/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_date_wide.pass.cpp b/test/std/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_date_wide.pass.cpp
new file mode 100644
index 000000000000..4c663a3bc698
--- /dev/null
+++ b/test/std/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_date_wide.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class time_get<charT, InputIterator>
+
+// iter_type
+// get_date(iter_type s, iter_type end, ios_base& str,
+// ios_base::iostate& err, tm* t) const;
+
+#include <locale>
+#include <cassert>
+#include "test_iterators.h"
+
+typedef input_iterator<const wchar_t*> I;
+
+typedef std::time_get<wchar_t, I> F;
+
+class my_facet
+ : public F
+{
+public:
+ explicit my_facet(std::size_t refs = 0)
+ : F(refs) {}
+};
+
+int main()
+{
+ const my_facet f(1);
+ std::ios ios(0);
+ std::ios_base::iostate err;
+ std::tm t;
+ {
+ const wchar_t in[] = L"5/5/5";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_date(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+ assert(t.tm_mon == 4);
+ assert(t.tm_mday == 5);
+ assert(t.tm_year == 105);
+ assert(err == std::ios_base::eofbit);
+ }
+}
diff --git a/test/std/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_many.pass.cpp b/test/std/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_many.pass.cpp
new file mode 100644
index 000000000000..39a10b48adaa
--- /dev/null
+++ b/test/std/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_many.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class time_get<charT, InputIterator>
+
+// iter_type
+// get(iter_type s, iter_type end, ios_base& f, ios_base::iostate& err, tm *t,
+// const char_type *fmt, const char_type *fmtend) const;
+
+#include <locale>
+#include <cassert>
+#include "test_iterators.h"
+
+typedef input_iterator<const char*> I;
+
+typedef std::time_get<char, I> F;
+
+class my_facet
+ : public F
+{
+public:
+ explicit my_facet(std::size_t refs = 0)
+ : F(refs) {}
+};
+
+int main()
+{
+ const my_facet f(1);
+ std::ios ios(0);
+ std::ios_base::iostate err;
+ std::tm t;
+ {
+ const char in[] = "2009 May 9, 10:27pm";
+ const char fmt[] = "%Y %b %d, %I:%M%p";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, fmt, fmt+sizeof(fmt)-1);
+ assert(i.base() == in+sizeof(in)-1);
+ assert(t.tm_year == 109);
+ assert(t.tm_mon == 4);
+ assert(t.tm_mday == 9);
+ assert(t.tm_hour == 22);
+ assert(t.tm_min == 27);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const char in[] = "10:27PM May 9, 2009";
+ const char fmt[] = "%I:%M%p %b %d, %Y";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, fmt, fmt+sizeof(fmt)-1);
+ assert(i.base() == in+sizeof(in)-1);
+ assert(t.tm_year == 109);
+ assert(t.tm_mon == 4);
+ assert(t.tm_mday == 9);
+ assert(t.tm_hour == 22);
+ assert(t.tm_min == 27);
+ assert(err == std::ios_base::eofbit);
+ }
+}
diff --git a/test/std/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_monthname.pass.cpp b/test/std/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_monthname.pass.cpp
new file mode 100644
index 000000000000..19e378ce8f57
--- /dev/null
+++ b/test/std/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_monthname.pass.cpp
@@ -0,0 +1,265 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class time_get<charT, InputIterator>
+
+// iter_type
+// get_monthname(iter_type s, iter_type end, ios_base& str,
+// ios_base::iostate& err, tm* t) const;
+
+#include <locale>
+#include <cassert>
+#include "test_iterators.h"
+
+typedef input_iterator<const char*> I;
+
+typedef std::time_get<char, I> F;
+
+class my_facet
+ : public F
+{
+public:
+ explicit my_facet(std::size_t refs = 0)
+ : F(refs) {}
+};
+
+int main()
+{
+ const my_facet f(1);
+ std::ios ios(0);
+ std::ios_base::iostate err;
+ std::tm t;
+ {
+ const char in[] = "Jan";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_monthname(I(in), I(in+sizeof(in)-1), ios, err, &t);
+ assert(i.base() == in+3);
+ assert(t.tm_mon == 0);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const char in[] = "Feb";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_monthname(I(in), I(in+sizeof(in)-1), ios, err, &t);
+ assert(i.base() == in+3);
+ assert(t.tm_mon == 1);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const char in[] = "Mar";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_monthname(I(in), I(in+sizeof(in)-1), ios, err, &t);
+ assert(i.base() == in+3);
+ assert(t.tm_mon == 2);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const char in[] = "Apr";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_monthname(I(in), I(in+sizeof(in)-1), ios, err, &t);
+ assert(i.base() == in+3);
+ assert(t.tm_mon == 3);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const char in[] = "May";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_monthname(I(in), I(in+sizeof(in)-1), ios, err, &t);
+ assert(i.base() == in+3);
+ assert(t.tm_mon == 4);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const char in[] = "Jun";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_monthname(I(in), I(in+sizeof(in)-1), ios, err, &t);
+ assert(i.base() == in+3);
+ assert(t.tm_mon == 5);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const char in[] = "Jul";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_monthname(I(in), I(in+sizeof(in)-1), ios, err, &t);
+ assert(i.base() == in+3);
+ assert(t.tm_mon == 6);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const char in[] = "Aug";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_monthname(I(in), I(in+sizeof(in)-1), ios, err, &t);
+ assert(i.base() == in+3);
+ assert(t.tm_mon == 7);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const char in[] = "Sep";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_monthname(I(in), I(in+sizeof(in)-1), ios, err, &t);
+ assert(i.base() == in+3);
+ assert(t.tm_mon == 8);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const char in[] = "Oct";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_monthname(I(in), I(in+sizeof(in)-1), ios, err, &t);
+ assert(i.base() == in+3);
+ assert(t.tm_mon == 9);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const char in[] = "Nov";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_monthname(I(in), I(in+sizeof(in)-1), ios, err, &t);
+ assert(i.base() == in+3);
+ assert(t.tm_mon == 10);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const char in[] = "Dec";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_monthname(I(in), I(in+sizeof(in)-1), ios, err, &t);
+ assert(i.base() == in+3);
+ assert(t.tm_mon == 11);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const char in[] = "January";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_monthname(I(in), I(in+sizeof(in)-1), ios, err, &t);
+ assert(i.base() == in+7);
+ assert(t.tm_mon == 0);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const char in[] = "February";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_monthname(I(in), I(in+sizeof(in)-1), ios, err, &t);
+ assert(i.base() == in+8);
+ assert(t.tm_mon == 1);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const char in[] = "March";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_monthname(I(in), I(in+sizeof(in)-1), ios, err, &t);
+ assert(i.base() == in+5);
+ assert(t.tm_mon == 2);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const char in[] = "April";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_monthname(I(in), I(in+sizeof(in)-1), ios, err, &t);
+ assert(i.base() == in+5);
+ assert(t.tm_mon == 3);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const char in[] = "May";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_monthname(I(in), I(in+sizeof(in)-1), ios, err, &t);
+ assert(i.base() == in+3);
+ assert(t.tm_mon == 4);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const char in[] = "June";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_monthname(I(in), I(in+sizeof(in)-1), ios, err, &t);
+ assert(i.base() == in+4);
+ assert(t.tm_mon == 5);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const char in[] = "July";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_monthname(I(in), I(in+sizeof(in)-1), ios, err, &t);
+ assert(i.base() == in+4);
+ assert(t.tm_mon == 6);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const char in[] = "August";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_monthname(I(in), I(in+sizeof(in)-1), ios, err, &t);
+ assert(i.base() == in+6);
+ assert(t.tm_mon == 7);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const char in[] = "September";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_monthname(I(in), I(in+sizeof(in)-1), ios, err, &t);
+ assert(i.base() == in+9);
+ assert(t.tm_mon == 8);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const char in[] = "October";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_monthname(I(in), I(in+sizeof(in)-1), ios, err, &t);
+ assert(i.base() == in+7);
+ assert(t.tm_mon == 9);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const char in[] = "November";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_monthname(I(in), I(in+sizeof(in)-1), ios, err, &t);
+ assert(i.base() == in+8);
+ assert(t.tm_mon == 10);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const char in[] = "December";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_monthname(I(in), I(in+sizeof(in)-1), ios, err, &t);
+ assert(i.base() == in+8);
+ assert(t.tm_mon == 11);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const char in[] = "Decemper";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_monthname(I(in), I(in+sizeof(in)-1), ios, err, &t);
+ assert(i.base() == in+5);
+ assert(t.tm_mon == 0);
+ assert(err == std::ios_base::failbit);
+ }
+}
diff --git a/test/std/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_monthname_wide.pass.cpp b/test/std/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_monthname_wide.pass.cpp
new file mode 100644
index 000000000000..1761a6d8c03f
--- /dev/null
+++ b/test/std/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_monthname_wide.pass.cpp
@@ -0,0 +1,265 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class time_get<charT, InputIterator>
+
+// iter_type
+// get_monthname(iter_type s, iter_type end, ios_base& str,
+// ios_base::iostate& err, tm* t) const;
+
+#include <locale>
+#include <cassert>
+#include "test_iterators.h"
+
+typedef input_iterator<const wchar_t*> I;
+
+typedef std::time_get<wchar_t, I> F;
+
+class my_facet
+ : public F
+{
+public:
+ explicit my_facet(std::size_t refs = 0)
+ : F(refs) {}
+};
+
+int main()
+{
+ const my_facet f(1);
+ std::ios ios(0);
+ std::ios_base::iostate err;
+ std::tm t;
+ {
+ const wchar_t in[] = L"Jan";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+3);
+ assert(t.tm_mon == 0);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const wchar_t in[] = L"Feb";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+3);
+ assert(t.tm_mon == 1);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const wchar_t in[] = L"Mar";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+3);
+ assert(t.tm_mon == 2);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const wchar_t in[] = L"Apr";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+3);
+ assert(t.tm_mon == 3);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const wchar_t in[] = L"May";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+3);
+ assert(t.tm_mon == 4);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const wchar_t in[] = L"Jun";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+3);
+ assert(t.tm_mon == 5);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const wchar_t in[] = L"Jul";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+3);
+ assert(t.tm_mon == 6);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const wchar_t in[] = L"Aug";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+3);
+ assert(t.tm_mon == 7);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const wchar_t in[] = L"Sep";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+3);
+ assert(t.tm_mon == 8);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const wchar_t in[] = L"Oct";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+3);
+ assert(t.tm_mon == 9);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const wchar_t in[] = L"Nov";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+3);
+ assert(t.tm_mon == 10);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const wchar_t in[] = L"Dec";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+3);
+ assert(t.tm_mon == 11);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const wchar_t in[] = L"January";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+7);
+ assert(t.tm_mon == 0);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const wchar_t in[] = L"February";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+8);
+ assert(t.tm_mon == 1);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const wchar_t in[] = L"March";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+5);
+ assert(t.tm_mon == 2);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const wchar_t in[] = L"April";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+5);
+ assert(t.tm_mon == 3);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const wchar_t in[] = L"May";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+3);
+ assert(t.tm_mon == 4);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const wchar_t in[] = L"June";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+4);
+ assert(t.tm_mon == 5);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const wchar_t in[] = L"July";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+4);
+ assert(t.tm_mon == 6);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const wchar_t in[] = L"August";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+6);
+ assert(t.tm_mon == 7);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const wchar_t in[] = L"September";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+9);
+ assert(t.tm_mon == 8);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const wchar_t in[] = L"October";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+7);
+ assert(t.tm_mon == 9);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const wchar_t in[] = L"November";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+8);
+ assert(t.tm_mon == 10);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const wchar_t in[] = L"December";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+8);
+ assert(t.tm_mon == 11);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const wchar_t in[] = L"Decemper";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+5);
+ assert(t.tm_mon == 0);
+ assert(err == std::ios_base::failbit);
+ }
+}
diff --git a/test/std/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_one.pass.cpp b/test/std/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_one.pass.cpp
new file mode 100644
index 000000000000..05182c288e4c
--- /dev/null
+++ b/test/std/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_one.pass.cpp
@@ -0,0 +1,305 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class time_get<charT, InputIterator>
+
+// iter_type get(iter_type s, iter_type end, ios_base& f,
+// ios_base::iostate& err, tm *t, char format, char modifier = 0) const;
+
+#include <locale>
+#include <cassert>
+#include "test_iterators.h"
+
+typedef input_iterator<const char*> I;
+
+typedef std::time_get<char, I> F;
+
+class my_facet
+ : public F
+{
+public:
+ explicit my_facet(std::size_t refs = 0)
+ : F(refs) {}
+};
+
+int main()
+{
+ const my_facet f(1);
+ std::ios ios(0);
+ std::ios_base::iostate err;
+ std::tm t;
+ {
+ const char in[] = "mon";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, 'a');
+ assert(i.base() == in+sizeof(in)-1);
+ assert(t.tm_wday == 1);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const char in[] = "wednesdaY";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, 'A');
+ assert(i.base() == in+sizeof(in)-1);
+ assert(t.tm_wday == 3);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const char in[] = "June";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, 'b');
+ assert(i.base() == in+sizeof(in)-1);
+ assert(t.tm_mon == 5);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const char in[] = "Jul";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, 'B');
+ assert(i.base() == in+sizeof(in)-1);
+ assert(t.tm_mon == 6);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const char in[] = "Thu Jun 6 09:49:10 2009";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, 'c');
+ assert(i.base() == in+sizeof(in)-1);
+ assert(t.tm_wday == 4);
+ assert(t.tm_mon == 5);
+ assert(t.tm_mday == 6);
+ assert(t.tm_hour == 9);
+ assert(t.tm_min == 49);
+ assert(t.tm_sec == 10);
+ assert(t.tm_year == 109);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const char in[] = "11";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, 'd');
+ assert(i.base() == in+sizeof(in)-1);
+ assert(t.tm_mday == 11);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const char in[] = "2/1/1";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, 'D');
+ assert(i.base() == in+sizeof(in)-1);
+ assert(t.tm_mon == 1);
+ assert(t.tm_mday == 1);
+ assert(t.tm_year == 101);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const char in[] = "11";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, 'e');
+ assert(i.base() == in+sizeof(in)-1);
+ assert(t.tm_mday == 11);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const char in[] = "June";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, 'h');
+ assert(i.base() == in+sizeof(in)-1);
+ assert(t.tm_mon == 5);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const char in[] = "19";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, 'H');
+ assert(i.base() == in+sizeof(in)-1);
+ assert(t.tm_hour == 19);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const char in[] = "12";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, 'm');
+ assert(i.base() == in+sizeof(in)-1);
+ assert(t.tm_mon == 11);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const char in[] = "59";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, 'M');
+ assert(i.base() == in+sizeof(in)-1);
+ assert(t.tm_min == 59);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const char in[] = "\t\n ";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, 'n');
+ assert(i.base() == in+sizeof(in)-1);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const char in[] = "09:49:10 PM";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, 'r');
+ assert(i.base() == in+sizeof(in)-1);
+ assert(t.tm_hour == 21);
+ assert(t.tm_min == 49);
+ assert(t.tm_sec == 10);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const char in[] = "09:49:10 AM";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, 'r');
+ assert(i.base() == in+sizeof(in)-1);
+ assert(t.tm_hour == 9);
+ assert(t.tm_min == 49);
+ assert(t.tm_sec == 10);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const char in[] = "12:49:10 AM";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, 'r');
+ assert(i.base() == in+sizeof(in)-1);
+ assert(t.tm_hour == 0);
+ assert(t.tm_min == 49);
+ assert(t.tm_sec == 10);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const char in[] = "12:49:10 PM";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, 'r');
+ assert(i.base() == in+sizeof(in)-1);
+ assert(t.tm_hour == 12);
+ assert(t.tm_min == 49);
+ assert(t.tm_sec == 10);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const char in[] = "09:49";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, 'R');
+ assert(i.base() == in+sizeof(in)-1);
+ assert(t.tm_hour == 9);
+ assert(t.tm_min == 49);
+ assert(t.tm_sec == 0);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const char in[] = "60";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, 'S');
+ assert(i.base() == in+sizeof(in)-1);
+ assert(t.tm_hour == 0);
+ assert(t.tm_min == 0);
+ assert(t.tm_sec == 60);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const char in[] = "\t\n ";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, 't');
+ assert(i.base() == in+sizeof(in)-1);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const char in[] = "21:49:10";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, 'T');
+ assert(i.base() == in+sizeof(in)-1);
+ assert(t.tm_hour == 21);
+ assert(t.tm_min == 49);
+ assert(t.tm_sec == 10);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const char in[] = "3";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, 'w');
+ assert(i.base() == in+sizeof(in)-1);
+ assert(t.tm_wday == 3);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const char in[] = "06/06/09";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, 'x');
+ assert(i.base() == in+sizeof(in)-1);
+ assert(t.tm_mon == 5);
+ assert(t.tm_mday == 6);
+ assert(t.tm_year == 109);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const char in[] = "21:49:10";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, 'X');
+ assert(i.base() == in+sizeof(in)-1);
+ assert(t.tm_hour == 21);
+ assert(t.tm_min == 49);
+ assert(t.tm_sec == 10);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const char in[] = "68";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, 'y');
+ assert(i.base() == in+sizeof(in)-1);
+ assert(t.tm_year == 168);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const char in[] = "68";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, 'Y');
+ assert(i.base() == in+sizeof(in)-1);
+ assert(t.tm_year == -1832);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const char in[] = "%";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, '%');
+ assert(i.base() == in+sizeof(in)-1);
+ assert(err == std::ios_base::eofbit);
+ }
+}
diff --git a/test/std/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_time.pass.cpp b/test/std/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_time.pass.cpp
new file mode 100644
index 000000000000..b8b05f6dc7ff
--- /dev/null
+++ b/test/std/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_time.pass.cpp
@@ -0,0 +1,117 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class time_get<charT, InputIterator>
+
+// iter_type
+// get_time(iter_type s, iter_type end, ios_base& str,
+// ios_base::iostate& err, tm* t) const;
+
+#include <locale>
+#include <cassert>
+#include "test_iterators.h"
+
+typedef input_iterator<const char*> I;
+
+typedef std::time_get<char, I> F;
+
+class my_facet
+ : public F
+{
+public:
+ explicit my_facet(std::size_t refs = 0)
+ : F(refs) {}
+};
+
+int main()
+{
+ const my_facet f(1);
+ std::ios ios(0);
+ std::ios_base::iostate err;
+ std::tm t;
+ {
+ const char in[] = "0:0:0";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_time(I(in), I(in+sizeof(in)-1), ios, err, &t);
+ assert(i.base() == in+sizeof(in)-1);
+ assert(t.tm_hour == 0);
+ assert(t.tm_min == 0);
+ assert(t.tm_sec == 0);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const char in[] = "23:59:60";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_time(I(in), I(in+sizeof(in)-1), ios, err, &t);
+ assert(i.base() == in+sizeof(in)-1);
+ assert(t.tm_hour == 23);
+ assert(t.tm_min == 59);
+ assert(t.tm_sec == 60);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const char in[] = "24:59:60";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_time(I(in), I(in+sizeof(in)-1), ios, err, &t);
+ assert(i.base() == in+2);
+ assert(t.tm_hour == 0);
+ assert(t.tm_min == 0);
+ assert(t.tm_sec == 0);
+ assert(err == std::ios_base::failbit);
+ }
+ {
+ const char in[] = "23:60:60";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_time(I(in), I(in+sizeof(in)-1), ios, err, &t);
+ assert(i.base() == in+5);
+// assert(t.tm_hour == 0);
+// assert(t.tm_min == 0);
+// assert(t.tm_sec == 0);
+ assert(err == std::ios_base::failbit);
+ }
+ {
+ const char in[] = "23:59:61";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_time(I(in), I(in+sizeof(in)-1), ios, err, &t);
+ assert(i.base() == in+8);
+// assert(t.tm_hour == 0);
+// assert(t.tm_min == 0);
+// assert(t.tm_sec == 0);
+ assert(err == (std::ios_base::failbit | std::ios_base::eofbit));
+ }
+ {
+ const char in[] = "2:43:221";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_time(I(in), I(in+sizeof(in)-1), ios, err, &t);
+ assert(i.base() == in+7);
+ assert(t.tm_hour == 2);
+ assert(t.tm_min == 43);
+ assert(t.tm_sec == 22);
+ assert(err == std::ios_base::goodbit);
+ }
+ {
+ const char in[] = "2.43:221";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_time(I(in), I(in+sizeof(in)-1), ios, err, &t);
+ assert(i.base() == in+1);
+// assert(t.tm_hour == 0);
+// assert(t.tm_min == 0);
+// assert(t.tm_sec == 0);
+ assert(err == std::ios_base::failbit);
+ }
+}
diff --git a/test/std/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_time_wide.pass.cpp b/test/std/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_time_wide.pass.cpp
new file mode 100644
index 000000000000..679d0584076a
--- /dev/null
+++ b/test/std/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_time_wide.pass.cpp
@@ -0,0 +1,117 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class time_get<charT, InputIterator>
+
+// iter_type
+// get_time(iter_type s, iter_type end, ios_base& str,
+// ios_base::iostate& err, tm* t) const;
+
+#include <locale>
+#include <cassert>
+#include "test_iterators.h"
+
+typedef input_iterator<const wchar_t*> I;
+
+typedef std::time_get<wchar_t, I> F;
+
+class my_facet
+ : public F
+{
+public:
+ explicit my_facet(std::size_t refs = 0)
+ : F(refs) {}
+};
+
+int main()
+{
+ const my_facet f(1);
+ std::ios ios(0);
+ std::ios_base::iostate err;
+ std::tm t;
+ {
+ const wchar_t in[] = L"0:0:0";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_time(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+ assert(t.tm_hour == 0);
+ assert(t.tm_min == 0);
+ assert(t.tm_sec == 0);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const wchar_t in[] = L"23:59:60";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_time(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+ assert(t.tm_hour == 23);
+ assert(t.tm_min == 59);
+ assert(t.tm_sec == 60);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const wchar_t in[] = L"24:59:60";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_time(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+2);
+ assert(t.tm_hour == 0);
+ assert(t.tm_min == 0);
+ assert(t.tm_sec == 0);
+ assert(err == std::ios_base::failbit);
+ }
+ {
+ const wchar_t in[] = L"23:60:60";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_time(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+5);
+// assert(t.tm_hour == 0);
+// assert(t.tm_min == 0);
+// assert(t.tm_sec == 0);
+ assert(err == std::ios_base::failbit);
+ }
+ {
+ const wchar_t in[] = L"23:59:61";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_time(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+8);
+// assert(t.tm_hour == 0);
+// assert(t.tm_min == 0);
+// assert(t.tm_sec == 0);
+ assert(err == (std::ios_base::failbit | std::ios_base::eofbit));
+ }
+ {
+ const wchar_t in[] = L"2:43:221";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_time(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+7);
+ assert(t.tm_hour == 2);
+ assert(t.tm_min == 43);
+ assert(t.tm_sec == 22);
+ assert(err == std::ios_base::goodbit);
+ }
+ {
+ const wchar_t in[] = L"2.43:221";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_time(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+1);
+// assert(t.tm_hour == 0);
+// assert(t.tm_min == 0);
+// assert(t.tm_sec == 0);
+ assert(err == std::ios_base::failbit);
+ }
+}
diff --git a/test/std/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_weekday.pass.cpp b/test/std/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_weekday.pass.cpp
new file mode 100644
index 000000000000..918a9026f30e
--- /dev/null
+++ b/test/std/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_weekday.pass.cpp
@@ -0,0 +1,220 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class time_get<charT, InputIterator>
+
+// iter_type
+// get_weekday(iter_type s, iter_type end, ios_base& str,
+// ios_base::iostate& err, tm* t) const;
+
+#include <locale>
+#include <cassert>
+#include "test_iterators.h"
+
+typedef input_iterator<const char*> I;
+
+typedef std::time_get<char, I> F;
+
+class my_facet
+ : public F
+{
+public:
+ explicit my_facet(std::size_t refs = 0)
+ : F(refs) {}
+};
+
+int main()
+{
+ const my_facet f(1);
+ std::ios ios(0);
+ std::ios_base::iostate err;
+ std::tm t;
+ {
+ const char in[] = "Sun";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_weekday(I(in), I(in+sizeof(in)-1), ios, err, &t);
+ assert(i.base() == in+3);
+ assert(t.tm_wday == 0);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const char in[] = "Suny";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_weekday(I(in), I(in+sizeof(in)-1), ios, err, &t);
+ assert(i.base() == in+3);
+ assert(t.tm_wday == 0);
+ assert(err == std::ios_base::goodbit);
+ }
+ {
+ const char in[] = "Sund";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_weekday(I(in), I(in+sizeof(in)-1), ios, err, &t);
+ assert(i.base() == in+4);
+ assert(t.tm_wday == 0);
+ assert(err == (std::ios_base::failbit | std::ios_base::eofbit));
+ }
+ {
+ const char in[] = "sun";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_weekday(I(in), I(in+sizeof(in)-1), ios, err, &t);
+ assert(i.base() == in+3);
+ assert(t.tm_wday == 0);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const char in[] = "sunday";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_weekday(I(in), I(in+sizeof(in)-1), ios, err, &t);
+ assert(i.base() == in+6);
+ assert(t.tm_wday == 0);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const char in[] = "Mon";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_weekday(I(in), I(in+sizeof(in)-1), ios, err, &t);
+ assert(i.base() == in+3);
+ assert(t.tm_wday == 1);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const char in[] = "Mony";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_weekday(I(in), I(in+sizeof(in)-1), ios, err, &t);
+ assert(i.base() == in+3);
+ assert(t.tm_wday == 1);
+ assert(err == std::ios_base::goodbit);
+ }
+ {
+ const char in[] = "Mond";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_weekday(I(in), I(in+sizeof(in)-1), ios, err, &t);
+ assert(i.base() == in+4);
+ assert(t.tm_wday == 0);
+ assert(err == (std::ios_base::failbit | std::ios_base::eofbit));
+ }
+ {
+ const char in[] = "mon";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_weekday(I(in), I(in+sizeof(in)-1), ios, err, &t);
+ assert(i.base() == in+3);
+ assert(t.tm_wday == 1);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const char in[] = "monday";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_weekday(I(in), I(in+sizeof(in)-1), ios, err, &t);
+ assert(i.base() == in+6);
+ assert(t.tm_wday == 1);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const char in[] = "Tue";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_weekday(I(in), I(in+sizeof(in)-1), ios, err, &t);
+ assert(i.base() == in+3);
+ assert(t.tm_wday == 2);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const char in[] = "Tuesday";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_weekday(I(in), I(in+sizeof(in)-1), ios, err, &t);
+ assert(i.base() == in+7);
+ assert(t.tm_wday == 2);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const char in[] = "Wed";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_weekday(I(in), I(in+sizeof(in)-1), ios, err, &t);
+ assert(i.base() == in+3);
+ assert(t.tm_wday == 3);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const char in[] = "Wednesday";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_weekday(I(in), I(in+sizeof(in)-1), ios, err, &t);
+ assert(i.base() == in+9);
+ assert(t.tm_wday == 3);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const char in[] = "Thu";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_weekday(I(in), I(in+sizeof(in)-1), ios, err, &t);
+ assert(i.base() == in+3);
+ assert(t.tm_wday == 4);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const char in[] = "Thursday";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_weekday(I(in), I(in+sizeof(in)-1), ios, err, &t);
+ assert(i.base() == in+8);
+ assert(t.tm_wday == 4);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const char in[] = "Fri";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_weekday(I(in), I(in+sizeof(in)-1), ios, err, &t);
+ assert(i.base() == in+3);
+ assert(t.tm_wday == 5);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const char in[] = "Friday";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_weekday(I(in), I(in+sizeof(in)-1), ios, err, &t);
+ assert(i.base() == in+6);
+ assert(t.tm_wday == 5);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const char in[] = "Sat";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_weekday(I(in), I(in+sizeof(in)-1), ios, err, &t);
+ assert(i.base() == in+3);
+ assert(t.tm_wday == 6);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const char in[] = "Saturday";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_weekday(I(in), I(in+sizeof(in)-1), ios, err, &t);
+ assert(i.base() == in+8);
+ assert(t.tm_wday == 6);
+ assert(err == std::ios_base::eofbit);
+ }
+}
diff --git a/test/std/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_weekday_wide.pass.cpp b/test/std/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_weekday_wide.pass.cpp
new file mode 100644
index 000000000000..5212eb12b1d7
--- /dev/null
+++ b/test/std/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_weekday_wide.pass.cpp
@@ -0,0 +1,220 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class time_get<charT, InputIterator>
+
+// iter_type
+// get_weekday(iter_type s, iter_type end, ios_base& str,
+// ios_base::iostate& err, tm* t) const;
+
+#include <locale>
+#include <cassert>
+#include "test_iterators.h"
+
+typedef input_iterator<const wchar_t*> I;
+
+typedef std::time_get<wchar_t, I> F;
+
+class my_facet
+ : public F
+{
+public:
+ explicit my_facet(std::size_t refs = 0)
+ : F(refs) {}
+};
+
+int main()
+{
+ const my_facet f(1);
+ std::ios ios(0);
+ std::ios_base::iostate err;
+ std::tm t;
+ {
+ const wchar_t in[] = L"Sun";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+3);
+ assert(t.tm_wday == 0);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const wchar_t in[] = L"Suny";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+3);
+ assert(t.tm_wday == 0);
+ assert(err == std::ios_base::goodbit);
+ }
+ {
+ const wchar_t in[] = L"Sund";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+4);
+ assert(t.tm_wday == 0);
+ assert(err == (std::ios_base::failbit | std::ios_base::eofbit));
+ }
+ {
+ const wchar_t in[] = L"sun";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+3);
+ assert(t.tm_wday == 0);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const wchar_t in[] = L"sunday";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+6);
+ assert(t.tm_wday == 0);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const wchar_t in[] = L"Mon";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+3);
+ assert(t.tm_wday == 1);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const wchar_t in[] = L"Mony";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+3);
+ assert(t.tm_wday == 1);
+ assert(err == std::ios_base::goodbit);
+ }
+ {
+ const wchar_t in[] = L"Mond";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+4);
+ assert(t.tm_wday == 0);
+ assert(err == (std::ios_base::failbit | std::ios_base::eofbit));
+ }
+ {
+ const wchar_t in[] = L"mon";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+3);
+ assert(t.tm_wday == 1);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const wchar_t in[] = L"monday";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+6);
+ assert(t.tm_wday == 1);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const wchar_t in[] = L"Tue";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+3);
+ assert(t.tm_wday == 2);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const wchar_t in[] = L"Tuesday";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+7);
+ assert(t.tm_wday == 2);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const wchar_t in[] = L"Wed";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+3);
+ assert(t.tm_wday == 3);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const wchar_t in[] = L"Wednesday";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+9);
+ assert(t.tm_wday == 3);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const wchar_t in[] = L"Thu";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+3);
+ assert(t.tm_wday == 4);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const wchar_t in[] = L"Thursday";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+8);
+ assert(t.tm_wday == 4);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const wchar_t in[] = L"Fri";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+3);
+ assert(t.tm_wday == 5);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const wchar_t in[] = L"Friday";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+6);
+ assert(t.tm_wday == 5);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const wchar_t in[] = L"Sat";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+3);
+ assert(t.tm_wday == 6);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const wchar_t in[] = L"Saturday";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+8);
+ assert(t.tm_wday == 6);
+ assert(err == std::ios_base::eofbit);
+ }
+}
diff --git a/test/std/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_year.pass.cpp b/test/std/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_year.pass.cpp
new file mode 100644
index 000000000000..6e5e04d25a5a
--- /dev/null
+++ b/test/std/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_year.pass.cpp
@@ -0,0 +1,138 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class time_get<charT, InputIterator>
+
+// iter_type get_year(iter_type s, iter_type end, ios_base& str,
+// ios_base::iostate& err, tm* t) const;
+
+#include <locale>
+#include <cassert>
+#include "test_iterators.h"
+
+typedef input_iterator<const char*> I;
+
+typedef std::time_get<char, I> F;
+
+class my_facet
+ : public F
+{
+public:
+ explicit my_facet(std::size_t refs = 0)
+ : F(refs) {}
+};
+
+int main()
+{
+ const my_facet f(1);
+ std::ios ios(0);
+ std::ios_base::iostate err;
+ std::tm t;
+ {
+ const char in[] = "0";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_year(I(in), I(in+sizeof(in)-1), ios, err, &t);
+ assert(i.base() == in+sizeof(in)-1);
+ assert(t.tm_year == 100);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const char in[] = "00";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_year(I(in), I(in+sizeof(in)-1), ios, err, &t);
+ assert(i.base() == in+sizeof(in)-1);
+ assert(t.tm_year == 100);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const char in[] = "1";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_year(I(in), I(in+sizeof(in)-1), ios, err, &t);
+ assert(i.base() == in+sizeof(in)-1);
+ assert(t.tm_year == 101);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const char in[] = "68";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_year(I(in), I(in+sizeof(in)-1), ios, err, &t);
+ assert(i.base() == in+sizeof(in)-1);
+ assert(t.tm_year == 168);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const char in[] = "69";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_year(I(in), I(in+sizeof(in)-1), ios, err, &t);
+ assert(i.base() == in+sizeof(in)-1);
+ assert(t.tm_year == 69);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const char in[] = "99";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_year(I(in), I(in+sizeof(in)-1), ios, err, &t);
+ assert(i.base() == in+sizeof(in)-1);
+ assert(t.tm_year == 99);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const char in[] = "100";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_year(I(in), I(in+sizeof(in)-1), ios, err, &t);
+ assert(i.base() == in+sizeof(in)-1);
+ assert(t.tm_year == -1800);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const char in[] = "1900";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_year(I(in), I(in+sizeof(in)-1), ios, err, &t);
+ assert(i.base() == in+sizeof(in)-1);
+ assert(t.tm_year == 0);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const char in[] = "1968";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_year(I(in), I(in+sizeof(in)-1), ios, err, &t);
+ assert(i.base() == in+sizeof(in)-1);
+ assert(t.tm_year == 68);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const char in[] = "2000";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_year(I(in), I(in+sizeof(in)-1), ios, err, &t);
+ assert(i.base() == in+sizeof(in)-1);
+ assert(t.tm_year == 100);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const char in[] = "2999c";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_year(I(in), I(in+sizeof(in)-1), ios, err, &t);
+ assert(i.base() == in+sizeof(in)-2);
+ assert(t.tm_year == 1099);
+ assert(err == std::ios_base::goodbit);
+ }
+}
diff --git a/test/std/localization/locale.categories/category.time/locale.time.get/locale.time.get.virtuals/tested_elsewhere.pass.cpp b/test/std/localization/locale.categories/category.time/locale.time.get/locale.time.get.virtuals/tested_elsewhere.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/localization/locale.categories/category.time/locale.time.get/locale.time.get.virtuals/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/localization/locale.categories/category.time/locale.time.get/time_base.pass.cpp b/test/std/localization/locale.categories/category.time/locale.time.get/time_base.pass.cpp
new file mode 100644
index 000000000000..28bc3aa89f9c
--- /dev/null
+++ b/test/std/localization/locale.categories/category.time/locale.time.get/time_base.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class time_base
+// {
+// public:
+// enum dateorder {no_order, dmy, mdy, ymd, ydm};
+// };
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+ std::time_base::dateorder d = std::time_base::no_order;
+ assert(std::time_base::no_order == 0);
+ assert(std::time_base::dmy == 1);
+ assert(std::time_base::mdy == 2);
+ assert(std::time_base::ymd == 3);
+ assert(std::time_base::ydm == 4);
+}
diff --git a/test/std/localization/locale.categories/category.time/locale.time.get/types.pass.cpp b/test/std/localization/locale.categories/category.time/locale.time.get/types.pass.cpp
new file mode 100644
index 000000000000..f434ea577955
--- /dev/null
+++ b/test/std/localization/locale.categories/category.time/locale.time.get/types.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class time_base
+// {
+// public:
+// enum dateorder {no_order, dmy, mdy, ymd, ydm};
+// };
+//
+// template <class charT, class InputIterator = istreambuf_iterator<charT> >
+// class time_get
+// : public locale::facet,
+// public time_base
+// {
+// public:
+// typedef charT char_type;
+// typedef InputIterator iter_type;
+
+#include <locale>
+#include <iterator>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_base_of<std::locale::facet, std::time_get<char> >::value), "");
+ static_assert((std::is_base_of<std::locale::facet, std::time_get<wchar_t> >::value), "");
+ static_assert((std::is_base_of<std::time_base, std::time_get<char> >::value), "");
+ static_assert((std::is_base_of<std::time_base, std::time_get<wchar_t> >::value), "");
+ static_assert((std::is_same<std::time_get<char>::char_type, char>::value), "");
+ static_assert((std::is_same<std::time_get<wchar_t>::char_type, wchar_t>::value), "");
+ static_assert((std::is_same<std::time_get<char>::iter_type, std::istreambuf_iterator<char> >::value), "");
+ static_assert((std::is_same<std::time_get<wchar_t>::iter_type, std::istreambuf_iterator<wchar_t> >::value), "");
+}
diff --git a/test/std/localization/locale.categories/category.time/locale.time.put.byname/put1.pass.cpp b/test/std/localization/locale.categories/category.time/locale.time.put.byname/put1.pass.cpp
new file mode 100644
index 000000000000..3e7538d6625b
--- /dev/null
+++ b/test/std/localization/locale.categories/category.time/locale.time.put.byname/put1.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: locale.en_US.UTF-8
+// REQUIRES: locale.fr_FR.UTF-8
+
+// <locale>
+
+// template <class CharT, class OutputIterator = ostreambuf_iterator<CharT> >
+// class time_put_byname
+// : public time_put<CharT, OutputIterator>
+// {
+// public:
+// explicit time_put_byname(const char* nm, size_t refs = 0);
+// explicit time_put_byname(const string& nm, size_t refs = 0);
+//
+// protected:
+// ~time_put_byname();
+// };
+
+// TODO: investigation needed
+// XFAIL: linux-gnu
+
+#include <locale>
+#include <cassert>
+#include "test_iterators.h"
+
+#include "platform_support.h" // locale name macros
+
+typedef std::time_put_byname<char, output_iterator<char*> > F;
+
+class my_facet
+ : public F
+{
+public:
+ explicit my_facet(const std::string& nm, std::size_t refs = 0)
+ : F(nm, refs) {}
+};
+
+int main()
+{
+ char str[200];
+ output_iterator<char*> iter;
+ tm t;
+ t.tm_sec = 6;
+ t.tm_min = 3;
+ t.tm_hour = 13;
+ t.tm_mday = 2;
+ t.tm_mon = 4;
+ t.tm_year = 109;
+ t.tm_wday = 6;
+ t.tm_yday = -1;
+ t.tm_isdst = 1;
+ std::ios ios(0);
+ {
+ const my_facet f(LOCALE_en_US_UTF_8, 1);
+ std::string pat("Today is %A which is abbreviated %a.");
+ iter = f.put(output_iterator<char*>(str), ios, '*', &t,
+ pat.data(), pat.data() + pat.size());
+ std::string ex(str, iter.base());
+ assert(ex == "Today is Saturday which is abbreviated Sat.");
+ }
+ {
+ const my_facet f(LOCALE_fr_FR_UTF_8, 1);
+ std::string pat("Today is %A which is abbreviated %a.");
+ iter = f.put(output_iterator<char*>(str), ios, '*', &t,
+ pat.data(), pat.data() + pat.size());
+ std::string ex(str, iter.base());
+ assert((ex == "Today is Samedi which is abbreviated Sam.")||
+ (ex == "Today is samedi which is abbreviated sam." ));
+ }
+}
diff --git a/test/std/localization/locale.categories/category.time/locale.time.put/ctor.pass.cpp b/test/std/localization/locale.categories/category.time/locale.time.put/ctor.pass.cpp
new file mode 100644
index 000000000000..c22980a69c5d
--- /dev/null
+++ b/test/std/localization/locale.categories/category.time/locale.time.put/ctor.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class time_put<charT, OutputIterator>
+
+// explicit time_put(size_t refs = 0);
+
+#include <locale>
+#include <cassert>
+
+typedef std::time_put<char, char*> F;
+
+class my_facet
+ : public F
+{
+public:
+ static int count;
+
+ explicit my_facet(std::size_t refs = 0)
+ : F(refs) {++count;}
+
+ ~my_facet() {--count;}
+};
+
+int my_facet::count = 0;
+
+int main()
+{
+ {
+ std::locale l(std::locale::classic(), new my_facet);
+ assert(my_facet::count == 1);
+ }
+ assert(my_facet::count == 0);
+ {
+ my_facet f(1);
+ assert(my_facet::count == 1);
+ {
+ std::locale l(std::locale::classic(), &f);
+ assert(my_facet::count == 1);
+ }
+ assert(my_facet::count == 1);
+ }
+ assert(my_facet::count == 0);
+}
diff --git a/test/std/localization/locale.categories/category.time/locale.time.put/locale.time.put.members/put1.pass.cpp b/test/std/localization/locale.categories/category.time/locale.time.put/locale.time.put.members/put1.pass.cpp
new file mode 100644
index 000000000000..93d59520677c
--- /dev/null
+++ b/test/std/localization/locale.categories/category.time/locale.time.put/locale.time.put.members/put1.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class time_put<charT, OutputIterator>
+
+// iter_type put(iter_type s, ios_base& str, char_type fill, const tm* t,
+// const charT* pattern, const charT* pat_end) const;
+
+#include <locale>
+#include <cassert>
+#include "test_iterators.h"
+
+typedef std::time_put<char, output_iterator<char*> > F;
+
+class my_facet
+ : public F
+{
+public:
+ explicit my_facet(std::size_t refs = 0)
+ : F(refs) {}
+};
+
+int main()
+{
+ const my_facet f(1);
+ char str[200];
+ output_iterator<char*> iter;
+ tm t;
+ t.tm_sec = 6;
+ t.tm_min = 3;
+ t.tm_hour = 13;
+ t.tm_mday = 2;
+ t.tm_mon = 4;
+ t.tm_year = 109;
+ t.tm_wday = 6;
+ t.tm_yday = -1;
+ t.tm_isdst = 1;
+ std::ios ios(0);
+ {
+ std::string pat("Today is %A which is abbreviated %a.");
+ iter = f.put(output_iterator<char*>(str), ios, '*', &t,
+ pat.data(), pat.data() + pat.size());
+ std::string ex(str, iter.base());
+ assert(ex == "Today is Saturday which is abbreviated Sat.");
+ }
+ {
+ std::string pat("The number of the month is %Om.");
+ iter = f.put(output_iterator<char*>(str), ios, '*', &t,
+ pat.data(), pat.data() + pat.size());
+ std::string ex(str, iter.base());
+ assert(ex == "The number of the month is 05.");
+ }
+}
diff --git a/test/std/localization/locale.categories/category.time/locale.time.put/locale.time.put.members/put2.pass.cpp b/test/std/localization/locale.categories/category.time/locale.time.put/locale.time.put.members/put2.pass.cpp
new file mode 100644
index 000000000000..d9e7f3cd5149
--- /dev/null
+++ b/test/std/localization/locale.categories/category.time/locale.time.put/locale.time.put.members/put2.pass.cpp
@@ -0,0 +1,332 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class time_put<charT, OutputIterator>
+
+// iter_type put(iter_type s, ios_base& str, char_type fill, const tm* t,
+// char format, char modifier = 0) const;
+
+#include <locale>
+#include <cassert>
+#include "test_iterators.h"
+
+typedef std::time_put<char, output_iterator<char*> > F;
+
+class my_facet
+ : public F
+{
+public:
+ explicit my_facet(std::size_t refs = 0)
+ : F(refs) {}
+};
+
+int main()
+{
+ const my_facet f(1);
+ char str[200];
+ output_iterator<char*> iter;
+ tm t = {};
+ t.tm_sec = 6;
+ t.tm_min = 3;
+ t.tm_hour = 13;
+ t.tm_mday = 2;
+ t.tm_mon = 4;
+ t.tm_year = 109;
+ t.tm_wday = 6;
+ t.tm_yday = 121;
+ t.tm_isdst = 1;
+ std::ios ios(0);
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'A');
+ std::string ex(str, iter.base());
+ assert(ex == "Saturday");
+ }
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'a');
+ std::string ex(str, iter.base());
+ assert(ex == "Sat");
+ }
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'B');
+ std::string ex(str, iter.base());
+ assert(ex == "May");
+ }
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'b');
+ std::string ex(str, iter.base());
+ assert(ex == "May");
+ }
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'C');
+ std::string ex(str, iter.base());
+ assert(ex == "20");
+ }
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'c');
+ std::string ex(str, iter.base());
+ assert(ex == "Sat May 2 13:03:06 2009");
+ }
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'D');
+ std::string ex(str, iter.base());
+ assert(ex == "05/02/09");
+ }
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'd');
+ std::string ex(str, iter.base());
+ assert(ex == "02");
+ }
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'c', 'E');
+ std::string ex(str, iter.base());
+ assert(ex == "Sat May 2 13:03:06 2009");
+ }
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'C', 'E');
+ std::string ex(str, iter.base());
+ assert(ex == "20");
+ }
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'x', 'E');
+ std::string ex(str, iter.base());
+ assert(ex == "05/02/09");
+ }
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'X', 'E');
+ std::string ex(str, iter.base());
+ assert(ex == "13:03:06");
+ }
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'y', 'E');
+ std::string ex(str, iter.base());
+ assert(ex == "09");
+ }
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'Y', 'E');
+ std::string ex(str, iter.base());
+ assert(ex == "2009");
+ }
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'd', 'O');
+ std::string ex(str, iter.base());
+ assert(ex == "02");
+ }
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'e', 'O');
+ std::string ex(str, iter.base());
+ assert(ex == " 2");
+ }
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'H', 'O');
+ std::string ex(str, iter.base());
+ assert(ex == "13");
+ }
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'I', 'O');
+ std::string ex(str, iter.base());
+ assert(ex == "01");
+ }
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'm', 'O');
+ std::string ex(str, iter.base());
+ assert(ex == "05");
+ }
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'M', 'O');
+ std::string ex(str, iter.base());
+ assert(ex == "03");
+ }
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'S', 'O');
+ std::string ex(str, iter.base());
+ assert(ex == "06");
+ }
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'u', 'O');
+ std::string ex(str, iter.base());
+ assert(ex == "6");
+ }
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'U', 'O');
+ std::string ex(str, iter.base());
+ assert(ex == "17");
+ }
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'V', 'O');
+ std::string ex(str, iter.base());
+ assert(ex == "18");
+ }
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'w', 'O');
+ std::string ex(str, iter.base());
+ assert(ex == "6");
+ }
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'W', 'O');
+ std::string ex(str, iter.base());
+ assert(ex == "17");
+ }
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'y', 'O');
+ std::string ex(str, iter.base());
+ assert(ex == "09");
+ }
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'e');
+ std::string ex(str, iter.base());
+ assert(ex == " 2");
+ }
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'F');
+ std::string ex(str, iter.base());
+ assert(ex == "2009-05-02");
+ }
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'G');
+ std::string ex(str, iter.base());
+ assert(ex == "2009");
+ }
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'g');
+ std::string ex(str, iter.base());
+ assert(ex == "09");
+ }
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'H');
+ std::string ex(str, iter.base());
+ assert(ex == "13");
+ }
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'h');
+ std::string ex(str, iter.base());
+ assert(ex == "May");
+ }
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'I');
+ std::string ex(str, iter.base());
+ assert(ex == "01");
+ }
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'j');
+ std::string ex(str, iter.base());
+ assert(ex == "122");
+ }
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'M');
+ std::string ex(str, iter.base());
+ assert(ex == "03");
+ }
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'm');
+ std::string ex(str, iter.base());
+ assert(ex == "05");
+ }
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'n');
+ std::string ex(str, iter.base());
+ assert(ex == "\n");
+ }
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'p');
+ std::string ex(str, iter.base());
+ assert(ex == "PM");
+ }
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'R');
+ std::string ex(str, iter.base());
+ assert(ex == "13:03");
+ }
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'r');
+ std::string ex(str, iter.base());
+ assert(ex == "01:03:06 PM");
+ }
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'S');
+ std::string ex(str, iter.base());
+ assert(ex == "06");
+ }
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'T');
+ std::string ex(str, iter.base());
+ assert(ex == "13:03:06");
+ }
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', &t, 't');
+ std::string ex(str, iter.base());
+ assert(ex == "\t");
+ }
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'U');
+ std::string ex(str, iter.base());
+ assert(ex == "17");
+ }
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'u');
+ std::string ex(str, iter.base());
+ assert(ex == "6");
+ }
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'V');
+ std::string ex(str, iter.base());
+ assert(ex == "18");
+ }
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'W');
+ std::string ex(str, iter.base());
+ assert(ex == "17");
+ }
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'w');
+ std::string ex(str, iter.base());
+ assert(ex == "6");
+ }
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'X');
+ std::string ex(str, iter.base());
+ assert(ex == "13:03:06");
+ }
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'x');
+ std::string ex(str, iter.base());
+ assert(ex == "05/02/09");
+ }
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'Y');
+ std::string ex(str, iter.base());
+ assert(ex == "2009");
+ }
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'y');
+ std::string ex(str, iter.base());
+ assert(ex == "09");
+ }
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'Z');
+ std::string ex(str, iter.base());
+// assert(ex == "EDT"); depends on time zone
+ }
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'z');
+ std::string ex(str, iter.base());
+// assert(ex == "-0400"); depends on time zone
+ }
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', &t, '+');
+ std::string ex(str, iter.base());
+// assert(ex == "Sat May 2 13:03:06 EDT 2009"); depends on time zone
+ }
+ {
+ iter = f.put(output_iterator<char*>(str), ios, '*', &t, '%');
+ std::string ex(str, iter.base());
+ assert(ex == "%");
+ }
+}
diff --git a/test/std/localization/locale.categories/category.time/locale.time.put/locale.time.put.virtuals/tested_elsewhere.pass.cpp b/test/std/localization/locale.categories/category.time/locale.time.put/locale.time.put.virtuals/tested_elsewhere.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/localization/locale.categories/category.time/locale.time.put/locale.time.put.virtuals/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/localization/locale.categories/category.time/locale.time.put/types.pass.cpp b/test/std/localization/locale.categories/category.time/locale.time.put/types.pass.cpp
new file mode 100644
index 000000000000..db9d3fbf4046
--- /dev/null
+++ b/test/std/localization/locale.categories/category.time/locale.time.put/types.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT, class OutputIterator = ostreambuf_iterator<charT> >
+// class time_put
+// : public locale::facet
+// {
+// public:
+// typedef charT char_type;
+// typedef OutputIterator iter_type;
+
+#include <locale>
+#include <iterator>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_base_of<std::locale::facet, std::time_put<char> >::value), "");
+ static_assert((std::is_base_of<std::locale::facet, std::time_put<wchar_t> >::value), "");
+ static_assert((std::is_same<std::time_put<char>::char_type, char>::value), "");
+ static_assert((std::is_same<std::time_put<wchar_t>::char_type, wchar_t>::value), "");
+ static_assert((std::is_same<std::time_put<char>::iter_type, std::ostreambuf_iterator<char> >::value), "");
+ static_assert((std::is_same<std::time_put<wchar_t>::iter_type, std::ostreambuf_iterator<wchar_t> >::value), "");
+}
diff --git a/test/std/localization/locale.categories/category.time/nothing_to_do.pass.cpp b/test/std/localization/locale.categories/category.time/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/localization/locale.categories/category.time/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/localization/locale.categories/facet.numpunct/locale.numpunct.byname/decimal_point.pass.cpp b/test/std/localization/locale.categories/facet.numpunct/locale.numpunct.byname/decimal_point.pass.cpp
new file mode 100644
index 000000000000..0617cdc52ca3
--- /dev/null
+++ b/test/std/localization/locale.categories/facet.numpunct/locale.numpunct.byname/decimal_point.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: locale.en_US.UTF-8
+// REQUIRES: locale.fr_FR.UTF-8
+
+// <locale>
+
+// template <class charT> class numpunct_byname;
+
+// char_type decimal_point() const;
+
+#include <locale>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+int main()
+{
+ {
+ std::locale l("C");
+ {
+ typedef char C;
+ const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
+ assert(np.decimal_point() == '.');
+ }
+ {
+ typedef wchar_t C;
+ const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
+ assert(np.decimal_point() == L'.');
+ }
+ }
+ {
+ std::locale l(LOCALE_en_US_UTF_8);
+ {
+ typedef char C;
+ const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
+ assert(np.decimal_point() == '.');
+ }
+ {
+ typedef wchar_t C;
+ const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
+ assert(np.decimal_point() == L'.');
+ }
+ }
+ {
+ std::locale l(LOCALE_fr_FR_UTF_8);
+ {
+ typedef char C;
+ const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
+ assert(np.decimal_point() == ',');
+ }
+ {
+ typedef wchar_t C;
+ const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
+ assert(np.decimal_point() == L',');
+ }
+ }
+}
diff --git a/test/std/localization/locale.categories/facet.numpunct/locale.numpunct.byname/grouping.pass.cpp b/test/std/localization/locale.categories/facet.numpunct/locale.numpunct.byname/grouping.pass.cpp
new file mode 100644
index 000000000000..d5112a9508b7
--- /dev/null
+++ b/test/std/localization/locale.categories/facet.numpunct/locale.numpunct.byname/grouping.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: locale.en_US.UTF-8
+// REQUIRES: locale.fr_FR.UTF-8
+
+// <locale>
+
+// template <class charT> class numpunct_byname;
+
+// string grouping() const;
+
+// TODO: investigation needed
+// XFAIL: linux-gnu
+
+#include <locale>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+int main()
+{
+ {
+ std::locale l("C");
+ {
+ typedef char C;
+ const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
+ assert(np.grouping() == "");
+ }
+ {
+ typedef wchar_t C;
+ const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
+ assert(np.grouping() == "");
+ }
+ }
+ {
+ std::locale l(LOCALE_en_US_UTF_8);
+ {
+ typedef char C;
+ const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
+ assert(np.grouping() == "\3\3");
+ }
+ {
+ typedef wchar_t C;
+ const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
+ assert(np.grouping() == "\3\3");
+ }
+ }
+ {
+ std::locale l(LOCALE_fr_FR_UTF_8);
+ {
+ typedef char C;
+ const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
+ assert(np.grouping() == "\x7F");
+ }
+ {
+ typedef wchar_t C;
+ const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
+ assert(np.grouping() == "\x7F");
+ }
+ }
+}
diff --git a/test/std/localization/locale.categories/facet.numpunct/locale.numpunct.byname/thousands_sep.pass.cpp b/test/std/localization/locale.categories/facet.numpunct/locale.numpunct.byname/thousands_sep.pass.cpp
new file mode 100644
index 000000000000..b1bd03ff7364
--- /dev/null
+++ b/test/std/localization/locale.categories/facet.numpunct/locale.numpunct.byname/thousands_sep.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: locale.en_US.UTF-8
+// REQUIRES: locale.fr_FR.UTF-8
+
+// <locale>
+
+// template <class charT> class numpunct_byname;
+
+// char_type thousands_sep() const;
+
+// TODO: investigation needed
+// XFAIL: linux-gnu
+
+#include <locale>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+int main()
+{
+ {
+ std::locale l("C");
+ {
+ typedef char C;
+ const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
+ assert(np.thousands_sep() == ',');
+ }
+ {
+ typedef wchar_t C;
+ const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
+ assert(np.thousands_sep() == L',');
+ }
+ }
+ {
+ std::locale l(LOCALE_en_US_UTF_8);
+ {
+ typedef char C;
+ const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
+ assert(np.thousands_sep() == ',');
+ }
+ {
+ typedef wchar_t C;
+ const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
+ assert(np.thousands_sep() == L',');
+ }
+ }
+ {
+ std::locale l(LOCALE_fr_FR_UTF_8);
+ {
+ typedef char C;
+ const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
+ assert(np.thousands_sep() == ',');
+ }
+ {
+ typedef wchar_t C;
+ const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
+ assert(np.thousands_sep() == L',');
+ }
+ }
+}
diff --git a/test/std/localization/locale.categories/facet.numpunct/locale.numpunct/ctor.pass.cpp b/test/std/localization/locale.categories/facet.numpunct/locale.numpunct/ctor.pass.cpp
new file mode 100644
index 000000000000..6ac459698a74
--- /dev/null
+++ b/test/std/localization/locale.categories/facet.numpunct/locale.numpunct/ctor.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class numpunct;
+
+// explicit numpunct(size_t refs = 0);
+
+#include <locale>
+#include <cassert>
+
+template <class C>
+class my_facet
+ : public std::numpunct<C>
+{
+public:
+ static int count;
+
+ explicit my_facet(std::size_t refs = 0)
+ : std::numpunct<C>(refs) {++count;}
+
+ ~my_facet() {--count;}
+};
+
+template <class C> int my_facet<C>::count = 0;
+
+int main()
+{
+ {
+ std::locale l(std::locale::classic(), new my_facet<char>);
+ assert(my_facet<char>::count == 1);
+ }
+ assert(my_facet<char>::count == 0);
+ {
+ my_facet<char> f(1);
+ assert(my_facet<char>::count == 1);
+ {
+ std::locale l(std::locale::classic(), &f);
+ assert(my_facet<char>::count == 1);
+ }
+ assert(my_facet<char>::count == 1);
+ }
+ assert(my_facet<char>::count == 0);
+ {
+ std::locale l(std::locale::classic(), new my_facet<wchar_t>);
+ assert(my_facet<wchar_t>::count == 1);
+ }
+ assert(my_facet<wchar_t>::count == 0);
+ {
+ my_facet<wchar_t> f(1);
+ assert(my_facet<wchar_t>::count == 1);
+ {
+ std::locale l(std::locale::classic(), &f);
+ assert(my_facet<wchar_t>::count == 1);
+ }
+ assert(my_facet<wchar_t>::count == 1);
+ }
+ assert(my_facet<wchar_t>::count == 0);
+}
diff --git a/test/std/localization/locale.categories/facet.numpunct/locale.numpunct/facet.numpunct.members/decimal_point.pass.cpp b/test/std/localization/locale.categories/facet.numpunct/locale.numpunct/facet.numpunct.members/decimal_point.pass.cpp
new file mode 100644
index 000000000000..c89e3f4ccb1b
--- /dev/null
+++ b/test/std/localization/locale.categories/facet.numpunct/locale.numpunct/facet.numpunct.members/decimal_point.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class numpunct;
+
+// char_type decimal_point() const;
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+ std::locale l = std::locale::classic();
+ {
+ typedef char C;
+ const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
+ assert(np.decimal_point() == '.');
+ }
+ {
+ typedef wchar_t C;
+ const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
+ assert(np.decimal_point() == L'.');
+ }
+}
diff --git a/test/std/localization/locale.categories/facet.numpunct/locale.numpunct/facet.numpunct.members/falsename.pass.cpp b/test/std/localization/locale.categories/facet.numpunct/locale.numpunct/facet.numpunct.members/falsename.pass.cpp
new file mode 100644
index 000000000000..b48005586a69
--- /dev/null
+++ b/test/std/localization/locale.categories/facet.numpunct/locale.numpunct/facet.numpunct.members/falsename.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class numpunct;
+
+// string_type falsename() const;
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+ std::locale l = std::locale::classic();
+ {
+ typedef char C;
+ const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
+ assert(np.falsename() == std::string("false"));
+ }
+ {
+ typedef wchar_t C;
+ const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
+ assert(np.falsename() == std::wstring(L"false"));
+ }
+}
diff --git a/test/std/localization/locale.categories/facet.numpunct/locale.numpunct/facet.numpunct.members/grouping.pass.cpp b/test/std/localization/locale.categories/facet.numpunct/locale.numpunct/facet.numpunct.members/grouping.pass.cpp
new file mode 100644
index 000000000000..f2935ba924f2
--- /dev/null
+++ b/test/std/localization/locale.categories/facet.numpunct/locale.numpunct/facet.numpunct.members/grouping.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class numpunct;
+
+// string grouping() const;
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+ std::locale l = std::locale::classic();
+ {
+ typedef char C;
+ const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
+ assert(np.grouping() == std::string());
+ }
+ {
+ typedef wchar_t C;
+ const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
+ assert(np.grouping() == std::string());
+ }
+}
diff --git a/test/std/localization/locale.categories/facet.numpunct/locale.numpunct/facet.numpunct.members/thousands_sep.pass.cpp b/test/std/localization/locale.categories/facet.numpunct/locale.numpunct/facet.numpunct.members/thousands_sep.pass.cpp
new file mode 100644
index 000000000000..19932d654dee
--- /dev/null
+++ b/test/std/localization/locale.categories/facet.numpunct/locale.numpunct/facet.numpunct.members/thousands_sep.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class numpunct;
+
+// char_type thousands_sep() const;
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+ std::locale l = std::locale::classic();
+ {
+ typedef char C;
+ const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
+ assert(np.thousands_sep() == ',');
+ }
+ {
+ typedef wchar_t C;
+ const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
+ assert(np.thousands_sep() == L',');
+ }
+}
diff --git a/test/std/localization/locale.categories/facet.numpunct/locale.numpunct/facet.numpunct.members/truename.pass.cpp b/test/std/localization/locale.categories/facet.numpunct/locale.numpunct/facet.numpunct.members/truename.pass.cpp
new file mode 100644
index 000000000000..aa426d0fb6e2
--- /dev/null
+++ b/test/std/localization/locale.categories/facet.numpunct/locale.numpunct/facet.numpunct.members/truename.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class numpunct;
+
+// string_type truename() const;
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+ std::locale l = std::locale::classic();
+ {
+ typedef char C;
+ const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
+ assert(np.truename() == std::string("true"));
+ }
+ {
+ typedef wchar_t C;
+ const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
+ assert(np.truename() == std::wstring(L"true"));
+ }
+}
diff --git a/test/std/localization/locale.categories/facet.numpunct/locale.numpunct/facet.numpunct.virtuals/tested_elsewhere.pass.cpp b/test/std/localization/locale.categories/facet.numpunct/locale.numpunct/facet.numpunct.virtuals/tested_elsewhere.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/localization/locale.categories/facet.numpunct/locale.numpunct/facet.numpunct.virtuals/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/localization/locale.categories/facet.numpunct/locale.numpunct/types.pass.cpp b/test/std/localization/locale.categories/facet.numpunct/locale.numpunct/types.pass.cpp
new file mode 100644
index 000000000000..bbdf3254de21
--- /dev/null
+++ b/test/std/localization/locale.categories/facet.numpunct/locale.numpunct/types.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT>
+// class numpunct
+// : public locale::facet
+// {
+// public:
+// typedef charT char_type;
+// typedef basic_string<charT> string_type;
+// static locale::id id;
+
+#include <locale>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+ std::locale l = std::locale::classic();
+ {
+ assert(std::has_facet<std::numpunct<char> >(l));
+ const std::numpunct<char>& f = std::use_facet<std::numpunct<char> >(l);
+ {
+ (void)std::numpunct<char>::id;
+ }
+ static_assert((std::is_same<std::numpunct<char>::char_type, char>::value), "");
+ static_assert((std::is_same<std::numpunct<char>::string_type, std::string>::value), "");
+ static_assert((std::is_base_of<std::locale::facet, std::numpunct<char> >::value), "");
+ }
+ {
+ assert(std::has_facet<std::numpunct<wchar_t> >(l));
+ const std::numpunct<wchar_t>& f = std::use_facet<std::numpunct<wchar_t> >(l);
+ {
+ (void)std::numpunct<wchar_t>::id;
+ }
+ static_assert((std::is_same<std::numpunct<wchar_t>::char_type, wchar_t>::value), "");
+ static_assert((std::is_same<std::numpunct<wchar_t>::string_type, std::wstring>::value), "");
+ static_assert((std::is_base_of<std::locale::facet, std::numpunct<wchar_t> >::value), "");
+ }
+}
diff --git a/test/std/localization/locale.categories/facet.numpunct/nothing_to_do.pass.cpp b/test/std/localization/locale.categories/facet.numpunct/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/localization/locale.categories/facet.numpunct/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/localization/locale.categories/facets.examples/nothing_to_do.pass.cpp b/test/std/localization/locale.categories/facets.examples/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/localization/locale.categories/facets.examples/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/localization/locale.stdcvt/codecvt_mode.pass.cpp b/test/std/localization/locale.stdcvt/codecvt_mode.pass.cpp
new file mode 100644
index 000000000000..ac35fb85256e
--- /dev/null
+++ b/test/std/localization/locale.stdcvt/codecvt_mode.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <codecvt>
+
+// enum codecvt_mode
+// {
+// consume_header = 4,
+// generate_header = 2,
+// little_endian = 1
+// };
+
+#include <codecvt>
+#include <cassert>
+
+int main()
+{
+ assert(std::consume_header == 4);
+ assert(std::generate_header == 2);
+ assert(std::little_endian == 1);
+ std::codecvt_mode e = std::consume_header;
+ assert(e == 4);
+}
diff --git a/test/std/localization/locale.stdcvt/codecvt_utf16.pass.cpp b/test/std/localization/locale.stdcvt/codecvt_utf16.pass.cpp
new file mode 100644
index 000000000000..a61a9c928d7d
--- /dev/null
+++ b/test/std/localization/locale.stdcvt/codecvt_utf16.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <codecvt>
+
+// template <class Elem, unsigned long Maxcode = 0x10ffff,
+// codecvt_mode Mode = (codecvt_mode)0>
+// class codecvt_utf16
+// : public codecvt<Elem, char, mbstate_t>
+// {
+// // unspecified
+// };
+
+// Not a portable test
+
+#include <codecvt>
+#include <cstdlib>
+#include <cassert>
+
+#include "count_new.hpp"
+
+int main()
+{
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ {
+ typedef std::codecvt_utf16<wchar_t> C;
+ C c;
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ }
+ {
+ typedef std::codecvt_utf16<wchar_t> C;
+ std::locale loc(std::locale::classic(), new C);
+ assert(globalMemCounter.checkOutstandingNewNotEq(0));
+ }
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+}
diff --git a/test/std/localization/locale.stdcvt/codecvt_utf16_always_noconv.pass.cpp b/test/std/localization/locale.stdcvt/codecvt_utf16_always_noconv.pass.cpp
new file mode 100644
index 000000000000..0b7d4cbf3b24
--- /dev/null
+++ b/test/std/localization/locale.stdcvt/codecvt_utf16_always_noconv.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <codecvt>
+
+// template <class Elem, unsigned long Maxcode = 0x10ffff,
+// codecvt_mode Mode = (codecvt_mode)0>
+// class codecvt_utf16
+// : public codecvt<Elem, char, mbstate_t>
+// {
+// // unspecified
+// };
+
+// bool always_noconv() const throw();
+
+#include <codecvt>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::codecvt_utf16<wchar_t> C;
+ C c;
+ bool r = c.always_noconv();
+ assert(r == false);
+ }
+ {
+ typedef std::codecvt_utf16<char16_t> C;
+ C c;
+ bool r = c.always_noconv();
+ assert(r == false);
+ }
+ {
+ typedef std::codecvt_utf16<char32_t> C;
+ C c;
+ bool r = c.always_noconv();
+ assert(r == false);
+ }
+}
diff --git a/test/std/localization/locale.stdcvt/codecvt_utf16_encoding.pass.cpp b/test/std/localization/locale.stdcvt/codecvt_utf16_encoding.pass.cpp
new file mode 100644
index 000000000000..2d12d985b297
--- /dev/null
+++ b/test/std/localization/locale.stdcvt/codecvt_utf16_encoding.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <codecvt>
+
+// template <class Elem, unsigned long Maxcode = 0x10ffff,
+// codecvt_mode Mode = (codecvt_mode)0>
+// class codecvt_utf16
+// : public codecvt<Elem, char, mbstate_t>
+// {
+// // unspecified
+// };
+
+// int encoding() const throw();
+
+#include <codecvt>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::codecvt_utf16<wchar_t> C;
+ C c;
+ int r = c.encoding();
+ assert(r == 0);
+ }
+ {
+ typedef std::codecvt_utf16<char16_t> C;
+ C c;
+ int r = c.encoding();
+ assert(r == 0);
+ }
+ {
+ typedef std::codecvt_utf16<char32_t> C;
+ C c;
+ int r = c.encoding();
+ assert(r == 0);
+ }
+}
diff --git a/test/std/localization/locale.stdcvt/codecvt_utf16_in.pass.cpp b/test/std/localization/locale.stdcvt/codecvt_utf16_in.pass.cpp
new file mode 100644
index 000000000000..4d710c1a9799
--- /dev/null
+++ b/test/std/localization/locale.stdcvt/codecvt_utf16_in.pass.cpp
@@ -0,0 +1,739 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <codecvt>
+
+// template <class Elem, unsigned long Maxcode = 0x10ffff,
+// codecvt_mode Mode = (codecvt_mode)0>
+// class codecvt_utf16
+// : public codecvt<Elem, char, mbstate_t>
+// {
+// // unspecified
+// };
+
+// result
+// in(stateT& state,
+// const externT* from, const externT* from_end, const externT*& from_next,
+// internT* to, internT* to_end, internT*& to_next) const;
+
+#include <codecvt>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::codecvt_utf16<wchar_t> C;
+ C c;
+ wchar_t w = 0;
+ char n[4] = {char(0xD8), char(0xC0), char(0xDC), char(0x03)};
+ wchar_t* wp = nullptr;
+ std::mbstate_t m;
+ const char* np = nullptr;
+ std::codecvt_base::result r = c.in(m, n, n+4, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+4);
+ assert(w == 0x40003);
+
+ n[0] = char(0x10);
+ n[1] = char(0x05);
+ r = c.in(m, n, n+2, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+2);
+ assert(w == 0x1005);
+
+ n[0] = char(0x04);
+ n[1] = char(0x53);
+ r = c.in(m, n, n+2, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+2);
+ assert(w == 0x453);
+
+ w = 0x56;
+ n[0] = char(0x00);
+ n[1] = char(0x56);
+ r = c.in(m, n, n+2, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+2);
+ assert(w == 0x56);
+ }
+ {
+ typedef std::codecvt_utf16<wchar_t, 0x1000> C;
+ C c;
+ wchar_t w = 0;
+ char n[4] = {char(0xD8), char(0xC0), char(0xDC), char(0x03)};
+ wchar_t* wp = nullptr;
+ std::mbstate_t m;
+ const char* np = nullptr;
+ std::codecvt_base::result r = c.in(m, n, n+4, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::error);
+ assert(wp == &w);
+ assert(np == n);
+ assert(w == 0);
+
+ n[0] = char(0x10);
+ n[1] = char(0x05);
+ r = c.in(m, n, n+2, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::error);
+ assert(wp == &w);
+ assert(np == n);
+ assert(w == 0);
+
+ n[0] = char(0x04);
+ n[1] = char(0x53);
+ r = c.in(m, n, n+2, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+2);
+ assert(w == 0x453);
+
+ w = 0x56;
+ n[0] = char(0x00);
+ n[1] = char(0x56);
+ r = c.in(m, n, n+2, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+2);
+ assert(w == 0x56);
+ }
+ {
+ typedef std::codecvt_utf16<wchar_t, 0x10ffff, std::consume_header> C;
+ C c;
+ wchar_t w = 0;
+ char n[6] = {char(0xFE), char(0xFF), char(0xD8), char(0xC0), char(0xDC), char(0x03)};
+ wchar_t* wp = nullptr;
+ std::mbstate_t m;
+ const char* np = nullptr;
+ std::codecvt_base::result r = c.in(m, n, n+6, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+6);
+ assert(w == 0x40003);
+
+ n[0] = char(0x10);
+ n[1] = char(0x05);
+ r = c.in(m, n, n+2, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+2);
+ assert(w == 0x1005);
+
+ n[0] = char(0x04);
+ n[1] = char(0x53);
+ r = c.in(m, n, n+2, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+2);
+ assert(w == 0x453);
+
+ w = 0x56;
+ n[0] = char(0x00);
+ n[1] = char(0x56);
+ r = c.in(m, n, n+2, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+2);
+ assert(w == 0x56);
+ }
+ {
+ typedef std::codecvt_utf16<wchar_t, 0x10ffff, std::little_endian> C;
+ C c;
+ wchar_t w = 0;
+ char n[4] = {char(0xC0), char(0xD8), char(0x03), char(0xDC)};
+ wchar_t* wp = nullptr;
+ std::mbstate_t m;
+ const char* np = nullptr;
+ std::codecvt_base::result r = c.in(m, n, n+4, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+4);
+ assert(w == 0x40003);
+
+ n[1] = char(0x10);
+ n[0] = char(0x05);
+ r = c.in(m, n, n+2, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+2);
+ assert(w == 0x1005);
+
+ n[1] = char(0x04);
+ n[0] = char(0x53);
+ r = c.in(m, n, n+2, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+2);
+ assert(w == 0x453);
+
+ w = 0x56;
+ n[1] = char(0x00);
+ n[0] = char(0x56);
+ r = c.in(m, n, n+2, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+2);
+ assert(w == 0x56);
+ }
+ {
+ typedef std::codecvt_utf16<wchar_t, 0x1000, std::little_endian> C;
+ C c;
+ wchar_t w = 0;
+ char n[4] = {char(0xC0), char(0xD8), char(0x03), char(0xDC)};
+ wchar_t* wp = nullptr;
+ std::mbstate_t m;
+ const char* np = nullptr;
+ std::codecvt_base::result r = c.in(m, n, n+4, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::error);
+ assert(wp == &w);
+ assert(np == n);
+ assert(w == 0);
+
+ n[1] = char(0x10);
+ n[0] = char(0x05);
+ r = c.in(m, n, n+2, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::error);
+ assert(wp == &w);
+ assert(np == n);
+ assert(w == 0);
+
+ n[1] = char(0x04);
+ n[0] = char(0x53);
+ r = c.in(m, n, n+2, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+2);
+ assert(w == 0x453);
+
+ w = 0x56;
+ n[1] = char(0x00);
+ n[0] = char(0x56);
+ r = c.in(m, n, n+2, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+2);
+ assert(w == 0x56);
+ }
+ {
+ typedef std::codecvt_utf16<wchar_t, 0x10ffff, std::codecvt_mode(
+ std::consume_header |
+ std::little_endian)> C;
+ C c;
+ wchar_t w = 0;
+ char n[6] = {char(0xFF), char(0xFE), char(0xC0), char(0xD8), char(0x03), char(0xDC)};
+ wchar_t* wp = nullptr;
+ std::mbstate_t m;
+ const char* np = nullptr;
+ std::codecvt_base::result r = c.in(m, n, n+6, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+6);
+ assert(w == 0x40003);
+
+ n[1] = char(0x10);
+ n[0] = char(0x05);
+ r = c.in(m, n, n+2, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+2);
+ assert(w == 0x1005);
+
+ n[1] = char(0x04);
+ n[0] = char(0x53);
+ r = c.in(m, n, n+2, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+2);
+ assert(w == 0x453);
+
+ w = 0x56;
+ n[1] = char(0x00);
+ n[0] = char(0x56);
+ r = c.in(m, n, n+2, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+2);
+ assert(w == 0x56);
+ }
+ {
+ typedef std::codecvt_utf16<char32_t> C;
+ C c;
+ char32_t w = 0;
+ char n[4] = {char(0xD8), char(0xC0), char(0xDC), char(0x03)};
+ char32_t* wp = nullptr;
+ std::mbstate_t m;
+ const char* np = nullptr;
+ std::codecvt_base::result r = c.in(m, n, n+4, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+4);
+ assert(w == 0x40003);
+
+ n[0] = char(0x10);
+ n[1] = char(0x05);
+ r = c.in(m, n, n+2, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+2);
+ assert(w == 0x1005);
+
+ n[0] = char(0x04);
+ n[1] = char(0x53);
+ r = c.in(m, n, n+2, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+2);
+ assert(w == 0x453);
+
+ w = 0x56;
+ n[0] = char(0x00);
+ n[1] = char(0x56);
+ r = c.in(m, n, n+2, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+2);
+ assert(w == 0x56);
+ }
+ {
+ typedef std::codecvt_utf16<char32_t, 0x1000> C;
+ C c;
+ char32_t w = 0;
+ char n[4] = {char(0xD8), char(0xC0), char(0xDC), char(0x03)};
+ char32_t* wp = nullptr;
+ std::mbstate_t m;
+ const char* np = nullptr;
+ std::codecvt_base::result r = c.in(m, n, n+4, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::error);
+ assert(wp == &w);
+ assert(np == n);
+ assert(w == 0);
+
+ n[0] = char(0x10);
+ n[1] = char(0x05);
+ r = c.in(m, n, n+2, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::error);
+ assert(wp == &w);
+ assert(np == n);
+ assert(w == 0);
+
+ n[0] = char(0x04);
+ n[1] = char(0x53);
+ r = c.in(m, n, n+2, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+2);
+ assert(w == 0x453);
+
+ w = 0x56;
+ n[0] = char(0x00);
+ n[1] = char(0x56);
+ r = c.in(m, n, n+2, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+2);
+ assert(w == 0x56);
+ }
+ {
+ typedef std::codecvt_utf16<char32_t, 0x10ffff, std::consume_header> C;
+ C c;
+ char32_t w = 0;
+ char n[6] = {char(0xFE), char(0xFF), char(0xD8), char(0xC0), char(0xDC), char(0x03)};
+ char32_t* wp = nullptr;
+ std::mbstate_t m;
+ const char* np = nullptr;
+ std::codecvt_base::result r = c.in(m, n, n+6, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+6);
+ assert(w == 0x40003);
+
+ n[0] = char(0x10);
+ n[1] = char(0x05);
+ r = c.in(m, n, n+2, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+2);
+ assert(w == 0x1005);
+
+ n[0] = char(0x04);
+ n[1] = char(0x53);
+ r = c.in(m, n, n+2, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+2);
+ assert(w == 0x453);
+
+ w = 0x56;
+ n[0] = char(0x00);
+ n[1] = char(0x56);
+ r = c.in(m, n, n+2, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+2);
+ assert(w == 0x56);
+ }
+ {
+ typedef std::codecvt_utf16<char32_t, 0x10ffff, std::little_endian> C;
+ C c;
+ char32_t w = 0;
+ char n[4] = {char(0xC0), char(0xD8), char(0x03), char(0xDC)};
+ char32_t* wp = nullptr;
+ std::mbstate_t m;
+ const char* np = nullptr;
+ std::codecvt_base::result r = c.in(m, n, n+4, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+4);
+ assert(w == 0x40003);
+
+ n[1] = char(0x10);
+ n[0] = char(0x05);
+ r = c.in(m, n, n+2, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+2);
+ assert(w == 0x1005);
+
+ n[1] = char(0x04);
+ n[0] = char(0x53);
+ r = c.in(m, n, n+2, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+2);
+ assert(w == 0x453);
+
+ w = 0x56;
+ n[1] = char(0x00);
+ n[0] = char(0x56);
+ r = c.in(m, n, n+2, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+2);
+ assert(w == 0x56);
+ }
+ {
+ typedef std::codecvt_utf16<char32_t, 0x1000, std::little_endian> C;
+ C c;
+ char32_t w = 0;
+ char n[4] = {char(0xC0), char(0xD8), char(0x03), char(0xDC)};
+ char32_t* wp = nullptr;
+ std::mbstate_t m;
+ const char* np = nullptr;
+ std::codecvt_base::result r = c.in(m, n, n+4, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::error);
+ assert(wp == &w);
+ assert(np == n);
+ assert(w == 0);
+
+ n[1] = char(0x10);
+ n[0] = char(0x05);
+ r = c.in(m, n, n+2, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::error);
+ assert(wp == &w);
+ assert(np == n);
+ assert(w == 0);
+
+ n[1] = char(0x04);
+ n[0] = char(0x53);
+ r = c.in(m, n, n+2, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+2);
+ assert(w == 0x453);
+
+ w = 0x56;
+ n[1] = char(0x00);
+ n[0] = char(0x56);
+ r = c.in(m, n, n+2, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+2);
+ assert(w == 0x56);
+ }
+ {
+ typedef std::codecvt_utf16<char32_t, 0x10ffff, std::codecvt_mode(
+ std::consume_header |
+ std::little_endian)> C;
+ C c;
+ char32_t w = 0;
+ char n[6] = {char(0xFF), char(0xFE), char(0xC0), char(0xD8), char(0x03), char(0xDC)};
+ char32_t* wp = nullptr;
+ std::mbstate_t m;
+ const char* np = nullptr;
+ std::codecvt_base::result r = c.in(m, n, n+6, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+6);
+ assert(w == 0x40003);
+
+ n[1] = char(0x10);
+ n[0] = char(0x05);
+ r = c.in(m, n, n+2, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+2);
+ assert(w == 0x1005);
+
+ n[1] = char(0x04);
+ n[0] = char(0x53);
+ r = c.in(m, n, n+2, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+2);
+ assert(w == 0x453);
+
+ w = 0x56;
+ n[1] = char(0x00);
+ n[0] = char(0x56);
+ r = c.in(m, n, n+2, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+2);
+ assert(w == 0x56);
+ }
+
+ {
+ typedef std::codecvt_utf16<char16_t> C;
+ C c;
+ char16_t w = 0;
+ char n[4] = {char(0xD8), char(0xC0), char(0xDC), char(0x03)};
+ char16_t* wp = nullptr;
+ std::mbstate_t m;
+ const char* np = nullptr;
+ std::codecvt_base::result r = c.in(m, n, n+4, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::error);
+ assert(wp == &w);
+ assert(np == n);
+ assert(w == 0);
+
+ n[0] = char(0x10);
+ n[1] = char(0x05);
+ r = c.in(m, n, n+2, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+2);
+ assert(w == 0x1005);
+
+ n[0] = char(0x04);
+ n[1] = char(0x53);
+ r = c.in(m, n, n+2, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+2);
+ assert(w == 0x453);
+
+ w = 0x56;
+ n[0] = char(0x00);
+ n[1] = char(0x56);
+ r = c.in(m, n, n+2, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+2);
+ assert(w == 0x56);
+ }
+ {
+ typedef std::codecvt_utf16<char16_t, 0x1000> C;
+ C c;
+ char16_t w = 0;
+ char n[4] = {char(0xD8), char(0xC0), char(0xDC), char(0x03)};
+ char16_t* wp = nullptr;
+ std::mbstate_t m;
+ const char* np = nullptr;
+ std::codecvt_base::result r = c.in(m, n, n+4, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::error);
+ assert(wp == &w);
+ assert(np == n);
+ assert(w == 0);
+
+ n[0] = char(0x10);
+ n[1] = char(0x05);
+ r = c.in(m, n, n+2, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::error);
+ assert(wp == &w);
+ assert(np == n);
+ assert(w == 0);
+
+ n[0] = char(0x04);
+ n[1] = char(0x53);
+ r = c.in(m, n, n+2, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+2);
+ assert(w == 0x453);
+
+ w = 0x56;
+ n[0] = char(0x00);
+ n[1] = char(0x56);
+ r = c.in(m, n, n+2, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+2);
+ assert(w == 0x56);
+ }
+ {
+ typedef std::codecvt_utf16<char16_t, 0x10ffff, std::consume_header> C;
+ C c;
+ char16_t w = 0;
+ char n[6] = {char(0xFE), char(0xFF), char(0xD8), char(0xC0), char(0xDC), char(0x03)};
+ char16_t* wp = nullptr;
+ std::mbstate_t m;
+ const char* np = nullptr;
+ std::codecvt_base::result r = c.in(m, n, n+6, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::error);
+ assert(wp == &w);
+ assert(np == n+2);
+ assert(w == 0);
+
+ n[0] = char(0x10);
+ n[1] = char(0x05);
+ r = c.in(m, n, n+2, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+2);
+ assert(w == 0x1005);
+
+ n[0] = char(0x04);
+ n[1] = char(0x53);
+ r = c.in(m, n, n+2, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+2);
+ assert(w == 0x453);
+
+ w = 0x56;
+ n[0] = char(0x00);
+ n[1] = char(0x56);
+ r = c.in(m, n, n+2, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+2);
+ assert(w == 0x56);
+ }
+ {
+ typedef std::codecvt_utf16<char16_t, 0x10ffff, std::little_endian> C;
+ C c;
+ char16_t w = 0;
+ char n[4] = {char(0xC0), char(0xD8), char(0x03), char(0xDC)};
+ char16_t* wp = nullptr;
+ std::mbstate_t m;
+ const char* np = nullptr;
+ std::codecvt_base::result r = c.in(m, n, n+4, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::error);
+ assert(wp == &w);
+ assert(np == n);
+ assert(w == 0);
+
+ n[1] = char(0x10);
+ n[0] = char(0x05);
+ r = c.in(m, n, n+2, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+2);
+ assert(w == 0x1005);
+
+ n[1] = char(0x04);
+ n[0] = char(0x53);
+ r = c.in(m, n, n+2, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+2);
+ assert(w == 0x453);
+
+ w = 0x56;
+ n[1] = char(0x00);
+ n[0] = char(0x56);
+ r = c.in(m, n, n+2, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+2);
+ assert(w == 0x56);
+ }
+ {
+ typedef std::codecvt_utf16<char16_t, 0x1000, std::little_endian> C;
+ C c;
+ char16_t w = 0;
+ char n[4] = {char(0xC0), char(0xD8), char(0x03), char(0xDC)};
+ char16_t* wp = nullptr;
+ std::mbstate_t m;
+ const char* np = nullptr;
+ std::codecvt_base::result r = c.in(m, n, n+4, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::error);
+ assert(wp == &w);
+ assert(np == n);
+ assert(w == 0);
+
+ n[1] = char(0x10);
+ n[0] = char(0x05);
+ r = c.in(m, n, n+2, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::error);
+ assert(wp == &w);
+ assert(np == n);
+ assert(w == 0);
+
+ n[1] = char(0x04);
+ n[0] = char(0x53);
+ r = c.in(m, n, n+2, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+2);
+ assert(w == 0x453);
+
+ w = 0x56;
+ n[1] = char(0x00);
+ n[0] = char(0x56);
+ r = c.in(m, n, n+2, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+2);
+ assert(w == 0x56);
+ }
+ {
+ typedef std::codecvt_utf16<char16_t, 0x10ffff, std::codecvt_mode(
+ std::consume_header |
+ std::little_endian)> C;
+ C c;
+ char16_t w = 0;
+ char n[6] = {char(0xFF), char(0xFE), char(0xC0), char(0xD8), char(0x03), char(0xDC)};
+ char16_t* wp = nullptr;
+ std::mbstate_t m;
+ const char* np = nullptr;
+ std::codecvt_base::result r = c.in(m, n, n+6, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::error);
+ assert(wp == &w);
+ assert(np == n+2);
+ assert(w == 0);
+
+ n[1] = char(0x10);
+ n[0] = char(0x05);
+ r = c.in(m, n, n+2, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+2);
+ assert(w == 0x1005);
+
+ n[1] = char(0x04);
+ n[0] = char(0x53);
+ r = c.in(m, n, n+2, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+2);
+ assert(w == 0x453);
+
+ w = 0x56;
+ n[1] = char(0x00);
+ n[0] = char(0x56);
+ r = c.in(m, n, n+2, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+2);
+ assert(w == 0x56);
+ }
+}
diff --git a/test/std/localization/locale.stdcvt/codecvt_utf16_length.pass.cpp b/test/std/localization/locale.stdcvt/codecvt_utf16_length.pass.cpp
new file mode 100644
index 000000000000..463a9fbac4d3
--- /dev/null
+++ b/test/std/localization/locale.stdcvt/codecvt_utf16_length.pass.cpp
@@ -0,0 +1,449 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <codecvt>
+
+// template <class Elem, unsigned long Maxcode = 0x10ffff,
+// codecvt_mode Mode = (codecvt_mode)0>
+// class codecvt_utf16
+// : public codecvt<Elem, char, mbstate_t>
+// {
+// // unspecified
+// };
+
+// int length(stateT& state, const externT* from, const externT* from_end,
+// size_t max) const;
+
+#include <codecvt>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::codecvt_utf16<wchar_t> C;
+ C c;
+ char n[4] = {char(0xD8), char(0xC0), char(0xDC), char(0x03)};
+ std::mbstate_t m;
+ int r = c.length(m, n, n+4, 2);
+ assert(r == 4);
+
+ n[0] = char(0x10);
+ n[1] = char(0x05);
+ r = c.length(m, n, n+2, 2);
+ assert(r == 2);
+
+ n[0] = char(0x04);
+ n[1] = char(0x53);
+ r = c.length(m, n, n+2, 2);
+ assert(r == 2);
+
+ n[0] = char(0x00);
+ n[1] = char(0x56);
+ r = c.length(m, n, n+2, 2);
+ assert(r == 2);
+ }
+ {
+ typedef std::codecvt_utf16<wchar_t, 0x1000> C;
+ C c;
+ char n[4] = {char(0xD8), char(0xC0), char(0xDC), char(0x03)};
+ std::mbstate_t m;
+ int r = c.length(m, n, n+4, 2);
+ assert(r == 0);
+
+ n[0] = char(0x10);
+ n[1] = char(0x05);
+ r = c.length(m, n, n+2, 2);
+ assert(r == 0);
+
+ n[0] = char(0x04);
+ n[1] = char(0x53);
+ r = c.length(m, n, n+2, 2);
+ assert(r == 2);
+
+ n[0] = char(0x00);
+ n[1] = char(0x56);
+ r = c.length(m, n, n+2, 2);
+ assert(r == 2);
+ }
+ {
+ typedef std::codecvt_utf16<wchar_t, 0x10ffff, std::consume_header> C;
+ C c;
+ char n[6] = {char(0xFE), char(0xFF), char(0xD8), char(0xC0), char(0xDC), char(0x03)};
+ std::mbstate_t m;
+ int r = c.length(m, n, n+6, 2);
+ assert(r == 6);
+
+ n[0] = char(0x10);
+ n[1] = char(0x05);
+ r = c.length(m, n, n+2, 2);
+ assert(r == 2);
+
+ n[0] = char(0x04);
+ n[1] = char(0x53);
+ r = c.length(m, n, n+2, 2);
+ assert(r == 2);
+
+ n[0] = char(0x00);
+ n[1] = char(0x56);
+ r = c.length(m, n, n+2, 2);
+ assert(r == 2);
+ }
+ {
+ typedef std::codecvt_utf16<wchar_t, 0x10ffff, std::little_endian> C;
+ C c;
+ char n[4] = {char(0xC0), char(0xD8), char(0x03), char(0xDC)};
+ std::mbstate_t m;
+ int r = c.length(m, n, n+4, 2);
+ assert(r == 4);
+
+ n[1] = char(0x10);
+ n[0] = char(0x05);
+ r = c.length(m, n, n+2, 2);
+ assert(r == 2);
+
+ n[1] = char(0x04);
+ n[0] = char(0x53);
+ r = c.length(m, n, n+2, 2);
+ assert(r == 2);
+
+ n[1] = char(0x00);
+ n[0] = char(0x56);
+ r = c.length(m, n, n+2, 2);
+ assert(r == 2);
+ }
+ {
+ typedef std::codecvt_utf16<wchar_t, 0x1000, std::little_endian> C;
+ C c;
+ char n[4] = {char(0xC0), char(0xD8), char(0x03), char(0xDC)};
+ std::mbstate_t m;
+ int r = c.length(m, n, n+4, 2);
+ assert(r == 0);
+
+ n[1] = char(0x10);
+ n[0] = char(0x05);
+ r = c.length(m, n, n+2, 2);
+ assert(r == 0);
+
+ n[1] = char(0x04);
+ n[0] = char(0x53);
+ r = c.length(m, n, n+2, 2);
+ assert(r == 2);
+
+ n[1] = char(0x00);
+ n[0] = char(0x56);
+ r = c.length(m, n, n+2, 2);
+ assert(r == 2);
+ }
+ {
+ typedef std::codecvt_utf16<wchar_t, 0x10ffff, std::codecvt_mode(
+ std::consume_header |
+ std::little_endian)> C;
+ C c;
+ char n[6] = {char(0xFF), char(0xFE), char(0xC0), char(0xD8), char(0x03), char(0xDC)};
+ std::mbstate_t m;
+ int r = c.length(m, n, n+6, 2);
+ assert(r == 6);
+
+ n[1] = char(0x10);
+ n[0] = char(0x05);
+ r = c.length(m, n, n+2, 2);
+ assert(r == 2);
+
+ n[1] = char(0x04);
+ n[0] = char(0x53);
+ r = c.length(m, n, n+2, 2);
+ assert(r == 2);
+
+ n[1] = char(0x00);
+ n[0] = char(0x56);
+ r = c.length(m, n, n+2, 2);
+ assert(r == 2);
+ }
+ {
+ typedef std::codecvt_utf16<char32_t> C;
+ C c;
+ char n[4] = {char(0xD8), char(0xC0), char(0xDC), char(0x03)};
+ std::mbstate_t m;
+ int r = c.length(m, n, n+4, 2);
+ assert(r == 4);
+
+ n[0] = char(0x10);
+ n[1] = char(0x05);
+ r = c.length(m, n, n+2, 2);
+ assert(r == 2);
+
+ n[0] = char(0x04);
+ n[1] = char(0x53);
+ r = c.length(m, n, n+2, 2);
+ assert(r == 2);
+
+ n[0] = char(0x00);
+ n[1] = char(0x56);
+ r = c.length(m, n, n+2, 2);
+ assert(r == 2);
+ }
+ {
+ typedef std::codecvt_utf16<char32_t, 0x1000> C;
+ C c;
+ char n[4] = {char(0xD8), char(0xC0), char(0xDC), char(0x03)};
+ std::mbstate_t m;
+ int r = c.length(m, n, n+4, 2);
+ assert(r == 0);
+
+ n[0] = char(0x10);
+ n[1] = char(0x05);
+ r = c.length(m, n, n+2, 2);
+ assert(r == 0);
+
+ n[0] = char(0x04);
+ n[1] = char(0x53);
+ r = c.length(m, n, n+2, 2);
+ assert(r == 2);
+
+ n[0] = char(0x00);
+ n[1] = char(0x56);
+ r = c.length(m, n, n+2, 2);
+ assert(r == 2);
+ }
+ {
+ typedef std::codecvt_utf16<char32_t, 0x10ffff, std::consume_header> C;
+ C c;
+ char n[6] = {char(0xFE), char(0xFF), char(0xD8), char(0xC0), char(0xDC), char(0x03)};
+ std::mbstate_t m;
+ int r = c.length(m, n, n+6, 2);
+ assert(r == 6);
+
+ n[0] = char(0x10);
+ n[1] = char(0x05);
+ r = c.length(m, n, n+2, 2);
+ assert(r == 2);
+
+ n[0] = char(0x04);
+ n[1] = char(0x53);
+ r = c.length(m, n, n+2, 2);
+ assert(r == 2);
+
+ n[0] = char(0x00);
+ n[1] = char(0x56);
+ r = c.length(m, n, n+2, 2);
+ assert(r == 2);
+ }
+ {
+ typedef std::codecvt_utf16<char32_t, 0x10ffff, std::little_endian> C;
+ C c;
+ char n[4] = {char(0xC0), char(0xD8), char(0x03), char(0xDC)};
+ std::mbstate_t m;
+ int r = c.length(m, n, n+4, 2);
+ assert(r == 4);
+
+ n[1] = char(0x10);
+ n[0] = char(0x05);
+ r = c.length(m, n, n+2, 2);
+ assert(r == 2);
+
+ n[1] = char(0x04);
+ n[0] = char(0x53);
+ r = c.length(m, n, n+2, 2);
+ assert(r == 2);
+
+ n[1] = char(0x00);
+ n[0] = char(0x56);
+ r = c.length(m, n, n+2, 2);
+ assert(r == 2);
+ }
+ {
+ typedef std::codecvt_utf16<char32_t, 0x1000, std::little_endian> C;
+ C c;
+ char n[4] = {char(0xC0), char(0xD8), char(0x03), char(0xDC)};
+ std::mbstate_t m;
+ int r = c.length(m, n, n+4, 2);
+ assert(r == 0);
+
+ n[1] = char(0x10);
+ n[0] = char(0x05);
+ r = c.length(m, n, n+2, 2);
+ assert(r == 0);
+
+ n[1] = char(0x04);
+ n[0] = char(0x53);
+ r = c.length(m, n, n+2, 2);
+ assert(r == 2);
+
+ n[1] = char(0x00);
+ n[0] = char(0x56);
+ r = c.length(m, n, n+2, 2);
+ assert(r == 2);
+ }
+ {
+ typedef std::codecvt_utf16<char32_t, 0x10ffff, std::codecvt_mode(
+ std::consume_header |
+ std::little_endian)> C;
+ C c;
+ char n[6] = {char(0xFF), char(0xFE), char(0xC0), char(0xD8), char(0x03), char(0xDC)};
+ std::mbstate_t m;
+ int r = c.length(m, n, n+6, 2);
+ assert(r == 6);
+
+ n[1] = char(0x10);
+ n[0] = char(0x05);
+ r = c.length(m, n, n+2, 2);
+ assert(r == 2);
+
+ n[1] = char(0x04);
+ n[0] = char(0x53);
+ r = c.length(m, n, n+2, 2);
+ assert(r == 2);
+
+ n[1] = char(0x00);
+ n[0] = char(0x56);
+ r = c.length(m, n, n+2, 2);
+ assert(r == 2);
+ }
+
+ {
+ typedef std::codecvt_utf16<char16_t> C;
+ C c;
+ char n[4] = {char(0xD8), char(0xC0), char(0xDC), char(0x03)};
+ std::mbstate_t m;
+ int r = c.length(m, n, n+4, 2);
+ assert(r == 0);
+
+ n[0] = char(0x10);
+ n[1] = char(0x05);
+ r = c.length(m, n, n+2, 2);
+ assert(r == 2);
+
+ n[0] = char(0x04);
+ n[1] = char(0x53);
+ r = c.length(m, n, n+2, 2);
+ assert(r == 2);
+
+ n[0] = char(0x00);
+ n[1] = char(0x56);
+ r = c.length(m, n, n+2, 2);
+ assert(r == 2);
+ }
+ {
+ typedef std::codecvt_utf16<char16_t, 0x1000> C;
+ C c;
+ char n[4] = {char(0xD8), char(0xC0), char(0xDC), char(0x03)};
+ std::mbstate_t m;
+ int r = c.length(m, n, n+4, 2);
+ assert(r == 0);
+
+ n[0] = char(0x10);
+ n[1] = char(0x05);
+ r = c.length(m, n, n+2, 2);
+ assert(r == 0);
+
+ n[0] = char(0x04);
+ n[1] = char(0x53);
+ r = c.length(m, n, n+2, 2);
+ assert(r == 2);
+
+ n[0] = char(0x00);
+ n[1] = char(0x56);
+ r = c.length(m, n, n+2, 2);
+ assert(r == 2);
+ }
+ {
+ typedef std::codecvt_utf16<char16_t, 0x10ffff, std::consume_header> C;
+ C c;
+ char n[6] = {char(0xFE), char(0xFF), char(0xD8), char(0xC0), char(0xDC), char(0x03)};
+ std::mbstate_t m;
+ int r = c.length(m, n, n+6, 2);
+ assert(r == 2);
+
+ n[0] = char(0x10);
+ n[1] = char(0x05);
+ r = c.length(m, n, n+2, 2);
+ assert(r == 2);
+
+ n[0] = char(0x04);
+ n[1] = char(0x53);
+ r = c.length(m, n, n+2, 2);
+ assert(r == 2);
+
+ n[0] = char(0x00);
+ n[1] = char(0x56);
+ r = c.length(m, n, n+2, 2);
+ assert(r == 2);
+ }
+ {
+ typedef std::codecvt_utf16<char16_t, 0x10ffff, std::little_endian> C;
+ C c;
+ char n[4] = {char(0xC0), char(0xD8), char(0x03), char(0xDC)};
+ std::mbstate_t m;
+ int r = c.length(m, n, n+4, 2);
+ assert(r == 0);
+
+ n[1] = char(0x10);
+ n[0] = char(0x05);
+ r = c.length(m, n, n+2, 2);
+ assert(r == 2);
+
+ n[1] = char(0x04);
+ n[0] = char(0x53);
+ r = c.length(m, n, n+2, 2);
+ assert(r == 2);
+
+ n[1] = char(0x00);
+ n[0] = char(0x56);
+ r = c.length(m, n, n+2, 2);
+ assert(r == 2);
+ }
+ {
+ typedef std::codecvt_utf16<char16_t, 0x1000, std::little_endian> C;
+ C c;
+ char n[4] = {char(0xC0), char(0xD8), char(0x03), char(0xDC)};
+ std::mbstate_t m;
+ int r = c.length(m, n, n+4, 2);
+ assert(r == 0);
+
+ n[1] = char(0x10);
+ n[0] = char(0x05);
+ r = c.length(m, n, n+2, 2);
+ assert(r == 0);
+
+ n[1] = char(0x04);
+ n[0] = char(0x53);
+ r = c.length(m, n, n+2, 2);
+ assert(r == 2);
+
+ n[1] = char(0x00);
+ n[0] = char(0x56);
+ r = c.length(m, n, n+2, 2);
+ assert(r == 2);
+ }
+ {
+ typedef std::codecvt_utf16<char16_t, 0x10ffff, std::codecvt_mode(
+ std::consume_header |
+ std::little_endian)> C;
+ C c;
+ char n[6] = {char(0xFF), char(0xFE), char(0xC0), char(0xD8), char(0x03), char(0xDC)};
+ std::mbstate_t m;
+ int r = c.length(m, n, n+6, 2);
+ assert(r == 2);
+
+ n[1] = char(0x10);
+ n[0] = char(0x05);
+ r = c.length(m, n, n+2, 2);
+ assert(r == 2);
+
+ n[1] = char(0x04);
+ n[0] = char(0x53);
+ r = c.length(m, n, n+2, 2);
+ assert(r == 2);
+
+ n[1] = char(0x00);
+ n[0] = char(0x56);
+ r = c.length(m, n, n+2, 2);
+ assert(r == 2);
+ }
+}
diff --git a/test/std/localization/locale.stdcvt/codecvt_utf16_max_length.pass.cpp b/test/std/localization/locale.stdcvt/codecvt_utf16_max_length.pass.cpp
new file mode 100644
index 000000000000..29bb58d563de
--- /dev/null
+++ b/test/std/localization/locale.stdcvt/codecvt_utf16_max_length.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <codecvt>
+
+// template <class Elem, unsigned long Maxcode = 0x10ffff,
+// codecvt_mode Mode = (codecvt_mode)0>
+// class codecvt_utf16
+// : public codecvt<Elem, char, mbstate_t>
+// {
+// // unspecified
+// };
+
+// int max_length() const throw();
+
+#include <codecvt>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::codecvt_utf16<wchar_t> C;
+ C c;
+ int r = c.max_length();
+ assert(r == 4);
+ }
+ {
+ typedef std::codecvt_utf16<wchar_t, 0xFFFFFFFF, std::consume_header> C;
+ C c;
+ int r = c.max_length();
+ assert(r == 6);
+ }
+ {
+ typedef std::codecvt_utf16<char16_t> C;
+ C c;
+ int r = c.max_length();
+ assert(r == 2);
+ }
+ {
+ typedef std::codecvt_utf16<char16_t, 0xFFFFFFFF, std::consume_header> C;
+ C c;
+ int r = c.max_length();
+ assert(r == 4);
+ }
+ {
+ typedef std::codecvt_utf16<char32_t> C;
+ C c;
+ int r = c.max_length();
+ assert(r == 4);
+ }
+ {
+ typedef std::codecvt_utf16<char32_t, 0xFFFFFFFF, std::consume_header> C;
+ C c;
+ int r = c.max_length();
+ assert(r == 6);
+ }
+}
diff --git a/test/std/localization/locale.stdcvt/codecvt_utf16_out.pass.cpp b/test/std/localization/locale.stdcvt/codecvt_utf16_out.pass.cpp
new file mode 100644
index 000000000000..2eb6978b0e0a
--- /dev/null
+++ b/test/std/localization/locale.stdcvt/codecvt_utf16_out.pass.cpp
@@ -0,0 +1,331 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <codecvt>
+
+// template <class Elem, unsigned long Maxcode = 0x10ffff,
+// codecvt_mode Mode = (codecvt_mode)0>
+// class codecvt_utf16
+// : public codecvt<Elem, char, mbstate_t>
+// {
+// // unspecified
+// };
+
+// result
+// out(stateT& state,
+// const internT* from, const internT* from_end, const internT*& from_next,
+// externT* to, externT* to_end, externT*& to_next) const;
+
+#include <codecvt>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::codecvt_utf16<wchar_t> C;
+ C c;
+ wchar_t w = 0x40003;
+ char n[4] = {0};
+ const wchar_t* wp = nullptr;
+ std::mbstate_t m;
+ char* np = nullptr;
+ std::codecvt_base::result r = c.out(m, &w, &w+1, wp, n, n+4, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+4);
+ assert(n[0] == char(0xD8));
+ assert(n[1] == char(0xC0));
+ assert(n[2] == char(0xDC));
+ assert(n[3] == char(0x03));
+
+ w = 0x1005;
+ r = c.out(m, &w, &w+1, wp, n, n+4, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+2);
+ assert(n[0] == char(0x10));
+ assert(n[1] == char(0x05));
+ assert(n[2] == char(0xDC));
+ assert(n[3] == char(0x03));
+
+ w = 0x453;
+ r = c.out(m, &w, &w+1, wp, n, n+4, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+2);
+ assert(n[0] == char(0x04));
+ assert(n[1] == char(0x53));
+ assert(n[2] == char(0xDC));
+ assert(n[3] == char(0x03));
+
+ w = 0x56;
+ r = c.out(m, &w, &w+1, wp, n, n+4, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+2);
+ assert(n[0] == char(0x00));
+ assert(n[1] == char(0x56));
+ assert(n[2] == char(0xDC));
+ assert(n[3] == char(0x03));
+ }
+ {
+ typedef std::codecvt_utf16<wchar_t, 0x1000> C;
+ C c;
+ wchar_t w = 0x40003;
+ char n[4] = {0};
+ const wchar_t* wp = nullptr;
+ std::mbstate_t m;
+ char* np = nullptr;
+ std::codecvt_base::result r = c.out(m, &w, &w+1, wp, n, n+4, np);
+ assert(r == std::codecvt_base::error);
+ assert(wp == &w);
+ assert(np == n);
+ assert(n[0] == char(0));
+ assert(n[1] == char(0));
+ assert(n[2] == char(0));
+ assert(n[3] == char(0));
+
+ w = 0x1005;
+ r = c.out(m, &w, &w+1, wp, n, n+4, np);
+ assert(r == std::codecvt_base::error);
+ assert(wp == &w);
+ assert(np == n);
+ assert(n[0] == char(0));
+ assert(n[1] == char(0));
+ assert(n[2] == char(0));
+ assert(n[3] == char(0));
+
+ w = 0x453;
+ r = c.out(m, &w, &w+1, wp, n, n+4, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+2);
+ assert(n[0] == char(0x04));
+ assert(n[1] == char(0x53));
+ assert(n[2] == char(0));
+ assert(n[3] == char(0));
+
+ w = 0x56;
+ r = c.out(m, &w, &w+1, wp, n, n+4, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+2);
+ assert(n[0] == char(0x00));
+ assert(n[1] == char(0x56));
+ assert(n[2] == char(0));
+ assert(n[3] == char(0));
+ }
+ {
+ typedef std::codecvt_utf16<wchar_t, 0x10ffff, std::generate_header> C;
+ C c;
+ wchar_t w = 0x40003;
+ char n[6] = {0};
+ const wchar_t* wp = nullptr;
+ std::mbstate_t m;
+ char* np = nullptr;
+ std::codecvt_base::result r = c.out(m, &w, &w+1, wp, n, n+6, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+6);
+ assert(n[0] == char(0xFE));
+ assert(n[1] == char(0xFF));
+ assert(n[2] == char(0xD8));
+ assert(n[3] == char(0xC0));
+ assert(n[4] == char(0xDC));
+ assert(n[5] == char(0x03));
+
+ w = 0x1005;
+ r = c.out(m, &w, &w+1, wp, n, n+6, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+4);
+ assert(n[0] == char(0xFE));
+ assert(n[1] == char(0xFF));
+ assert(n[2] == char(0x10));
+ assert(n[3] == char(0x05));
+ assert(n[4] == char(0xDC));
+ assert(n[5] == char(0x03));
+
+ w = 0x453;
+ r = c.out(m, &w, &w+1, wp, n, n+6, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+4);
+ assert(n[0] == char(0xFE));
+ assert(n[1] == char(0xFF));
+ assert(n[2] == char(0x04));
+ assert(n[3] == char(0x53));
+ assert(n[4] == char(0xDC));
+ assert(n[5] == char(0x03));
+
+ w = 0x56;
+ r = c.out(m, &w, &w+1, wp, n, n+6, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+4);
+ assert(n[0] == char(0xFE));
+ assert(n[1] == char(0xFF));
+ assert(n[2] == char(0x00));
+ assert(n[3] == char(0x56));
+ assert(n[4] == char(0xDC));
+ assert(n[5] == char(0x03));
+ }
+
+ {
+ typedef std::codecvt_utf16<wchar_t, 0x10FFFF, std::little_endian> C;
+ C c;
+ wchar_t w = 0x40003;
+ char n[4] = {0};
+ const wchar_t* wp = nullptr;
+ std::mbstate_t m;
+ char* np = nullptr;
+ std::codecvt_base::result r = c.out(m, &w, &w+1, wp, n, n+4, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+4);
+ assert(n[1] == char(0xD8));
+ assert(n[0] == char(0xC0));
+ assert(n[3] == char(0xDC));
+ assert(n[2] == char(0x03));
+
+ w = 0x1005;
+ r = c.out(m, &w, &w+1, wp, n, n+4, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+2);
+ assert(n[1] == char(0x10));
+ assert(n[0] == char(0x05));
+ assert(n[3] == char(0xDC));
+ assert(n[2] == char(0x03));
+
+ w = 0x453;
+ r = c.out(m, &w, &w+1, wp, n, n+4, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+2);
+ assert(n[1] == char(0x04));
+ assert(n[0] == char(0x53));
+ assert(n[3] == char(0xDC));
+ assert(n[2] == char(0x03));
+
+ w = 0x56;
+ r = c.out(m, &w, &w+1, wp, n, n+4, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+2);
+ assert(n[1] == char(0x00));
+ assert(n[0] == char(0x56));
+ assert(n[3] == char(0xDC));
+ assert(n[2] == char(0x03));
+ }
+ {
+ typedef std::codecvt_utf16<wchar_t, 0x1000, std::little_endian> C;
+ C c;
+ wchar_t w = 0x40003;
+ char n[4] = {0};
+ const wchar_t* wp = nullptr;
+ std::mbstate_t m;
+ char* np = nullptr;
+ std::codecvt_base::result r = c.out(m, &w, &w+1, wp, n, n+4, np);
+ assert(r == std::codecvt_base::error);
+ assert(wp == &w);
+ assert(np == n);
+ assert(n[1] == char(0));
+ assert(n[0] == char(0));
+ assert(n[3] == char(0));
+ assert(n[2] == char(0));
+
+ w = 0x1005;
+ r = c.out(m, &w, &w+1, wp, n, n+4, np);
+ assert(r == std::codecvt_base::error);
+ assert(wp == &w);
+ assert(np == n);
+ assert(n[1] == char(0));
+ assert(n[0] == char(0));
+ assert(n[3] == char(0));
+ assert(n[2] == char(0));
+
+ w = 0x453;
+ r = c.out(m, &w, &w+1, wp, n, n+4, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+2);
+ assert(n[1] == char(0x04));
+ assert(n[0] == char(0x53));
+ assert(n[3] == char(0));
+ assert(n[2] == char(0));
+
+ w = 0x56;
+ r = c.out(m, &w, &w+1, wp, n, n+4, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+2);
+ assert(n[1] == char(0x00));
+ assert(n[0] == char(0x56));
+ assert(n[3] == char(0));
+ assert(n[2] == char(0));
+ }
+ {
+ typedef std::codecvt_utf16<wchar_t, 0x10ffff, std::codecvt_mode(
+ std::generate_header |
+ std::little_endian)> C;
+ C c;
+ wchar_t w = 0x40003;
+ char n[6] = {0};
+ const wchar_t* wp = nullptr;
+ std::mbstate_t m;
+ char* np = nullptr;
+ std::codecvt_base::result r = c.out(m, &w, &w+1, wp, n, n+6, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+6);
+ assert(n[1] == char(0xFE));
+ assert(n[0] == char(0xFF));
+ assert(n[3] == char(0xD8));
+ assert(n[2] == char(0xC0));
+ assert(n[5] == char(0xDC));
+ assert(n[4] == char(0x03));
+
+ w = 0x1005;
+ r = c.out(m, &w, &w+1, wp, n, n+6, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+4);
+ assert(n[1] == char(0xFE));
+ assert(n[0] == char(0xFF));
+ assert(n[3] == char(0x10));
+ assert(n[2] == char(0x05));
+ assert(n[5] == char(0xDC));
+ assert(n[4] == char(0x03));
+
+ w = 0x453;
+ r = c.out(m, &w, &w+1, wp, n, n+6, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+4);
+ assert(n[1] == char(0xFE));
+ assert(n[0] == char(0xFF));
+ assert(n[3] == char(0x04));
+ assert(n[2] == char(0x53));
+ assert(n[5] == char(0xDC));
+ assert(n[4] == char(0x03));
+
+ w = 0x56;
+ r = c.out(m, &w, &w+1, wp, n, n+6, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+4);
+ assert(n[1] == char(0xFE));
+ assert(n[0] == char(0xFF));
+ assert(n[3] == char(0x00));
+ assert(n[2] == char(0x56));
+ assert(n[5] == char(0xDC));
+ assert(n[4] == char(0x03));
+ }
+}
diff --git a/test/std/localization/locale.stdcvt/codecvt_utf16_unshift.pass.cpp b/test/std/localization/locale.stdcvt/codecvt_utf16_unshift.pass.cpp
new file mode 100644
index 000000000000..463d2f9252c2
--- /dev/null
+++ b/test/std/localization/locale.stdcvt/codecvt_utf16_unshift.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <codecvt>
+
+// template <class Elem, unsigned long Maxcode = 0x10ffff,
+// codecvt_mode Mode = (codecvt_mode)0>
+// class codecvt_utf16
+// : public codecvt<Elem, char, mbstate_t>
+// {
+// // unspecified
+// };
+
+// result
+// unshift(stateT& state,
+// externT* to, externT* to_end, externT*& to_next) const;
+
+#include <codecvt>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::codecvt_utf16<wchar_t> C;
+ C c;
+ char n[4] = {0};
+ std::mbstate_t m;
+ char* np = nullptr;
+ std::codecvt_base::result r = c.unshift(m, n, n+4, np);
+ assert(r == std::codecvt_base::noconv);
+ }
+ {
+ typedef std::codecvt_utf16<char16_t> C;
+ C c;
+ char n[4] = {0};
+ std::mbstate_t m;
+ char* np = nullptr;
+ std::codecvt_base::result r = c.unshift(m, n, n+4, np);
+ assert(r == std::codecvt_base::noconv);
+ }
+ {
+ typedef std::codecvt_utf16<char32_t> C;
+ C c;
+ char n[4] = {0};
+ std::mbstate_t m;
+ char* np = nullptr;
+ std::codecvt_base::result r = c.unshift(m, n, n+4, np);
+ assert(r == std::codecvt_base::noconv);
+ }
+}
diff --git a/test/std/localization/locale.stdcvt/codecvt_utf8.pass.cpp b/test/std/localization/locale.stdcvt/codecvt_utf8.pass.cpp
new file mode 100644
index 000000000000..5fa0eaaf8eb5
--- /dev/null
+++ b/test/std/localization/locale.stdcvt/codecvt_utf8.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <codecvt>
+
+// template <class Elem, unsigned long Maxcode = 0x10ffff,
+// codecvt_mode Mode = (codecvt_mode)0>
+// class codecvt_utf8
+// : public codecvt<Elem, char, mbstate_t>
+// {
+// // unspecified
+// };
+
+// Not a portable test
+
+#include <codecvt>
+#include <cstdlib>
+#include <cassert>
+
+#include "count_new.hpp"
+
+int main()
+{
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ {
+ typedef std::codecvt_utf8<wchar_t> C;
+ C c;
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ }
+ {
+ typedef std::codecvt_utf8<wchar_t> C;
+ std::locale loc(std::locale::classic(), new C);
+ assert(globalMemCounter.checkOutstandingNewNotEq(0));
+ }
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+}
diff --git a/test/std/localization/locale.stdcvt/codecvt_utf8_always_noconv.pass.cpp b/test/std/localization/locale.stdcvt/codecvt_utf8_always_noconv.pass.cpp
new file mode 100644
index 000000000000..963c269fae2d
--- /dev/null
+++ b/test/std/localization/locale.stdcvt/codecvt_utf8_always_noconv.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <codecvt>
+
+// template <class Elem, unsigned long Maxcode = 0x10ffff,
+// codecvt_mode Mode = (codecvt_mode)0>
+// class codecvt_utf8
+// : public codecvt<Elem, char, mbstate_t>
+// {
+// // unspecified
+// };
+
+// bool always_noconv() const throw();
+
+#include <codecvt>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::codecvt_utf8<wchar_t> C;
+ C c;
+ bool r = c.always_noconv();
+ assert(r == false);
+ }
+ {
+ typedef std::codecvt_utf8<char16_t> C;
+ C c;
+ bool r = c.always_noconv();
+ assert(r == false);
+ }
+ {
+ typedef std::codecvt_utf8<char32_t> C;
+ C c;
+ bool r = c.always_noconv();
+ assert(r == false);
+ }
+}
diff --git a/test/std/localization/locale.stdcvt/codecvt_utf8_encoding.pass.cpp b/test/std/localization/locale.stdcvt/codecvt_utf8_encoding.pass.cpp
new file mode 100644
index 000000000000..b17752cb0662
--- /dev/null
+++ b/test/std/localization/locale.stdcvt/codecvt_utf8_encoding.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <codecvt>
+
+// template <class Elem, unsigned long Maxcode = 0x10ffff,
+// codecvt_mode Mode = (codecvt_mode)0>
+// class codecvt_utf8
+// : public codecvt<Elem, char, mbstate_t>
+// {
+// // unspecified
+// };
+
+// int encoding() const throw();
+
+#include <codecvt>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::codecvt_utf8<wchar_t> C;
+ C c;
+ int r = c.encoding();
+ assert(r == 0);
+ }
+ {
+ typedef std::codecvt_utf8<char16_t> C;
+ C c;
+ int r = c.encoding();
+ assert(r == 0);
+ }
+ {
+ typedef std::codecvt_utf8<char32_t> C;
+ C c;
+ int r = c.encoding();
+ assert(r == 0);
+ }
+}
diff --git a/test/std/localization/locale.stdcvt/codecvt_utf8_in.pass.cpp b/test/std/localization/locale.stdcvt/codecvt_utf8_in.pass.cpp
new file mode 100644
index 000000000000..382ea122641a
--- /dev/null
+++ b/test/std/localization/locale.stdcvt/codecvt_utf8_in.pass.cpp
@@ -0,0 +1,360 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <codecvt>
+
+// template <class Elem, unsigned long Maxcode = 0x10ffff,
+// codecvt_mode Mode = (codecvt_mode)0>
+// class codecvt_utf8
+// : public codecvt<Elem, char, mbstate_t>
+// {
+// // unspecified
+// };
+
+// result
+// in(stateT& state,
+// const externT* from, const externT* from_end, const externT*& from_next,
+// internT* to, internT* to_end, internT*& to_next) const;
+
+#include <codecvt>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::codecvt_utf8<wchar_t> C;
+ C c;
+ wchar_t w = 0;
+ char n[4] = {char(0xF1), char(0x80), char(0x80), char(0x83)};
+ wchar_t* wp = nullptr;
+ std::mbstate_t m;
+ const char* np = nullptr;
+ std::codecvt_base::result r = c.in(m, n, n+4, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+4);
+ assert(w == 0x40003);
+
+ n[0] = char(0xE1);
+ n[1] = char(0x80);
+ n[2] = char(0x85);
+ r = c.in(m, n, n+3, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+3);
+ assert(w == 0x1005);
+
+ n[0] = char(0xD1);
+ n[1] = char(0x93);
+ r = c.in(m, n, n+2, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+2);
+ assert(w == 0x453);
+
+ w = 0x56;
+ n[0] = char(0x56);
+ r = c.in(m, n, n+1, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+1);
+ assert(w == 0x56);
+ }
+ {
+ typedef std::codecvt_utf8<wchar_t, 0x1000> C;
+ C c;
+ wchar_t w = 0;
+ char n[4] = {char(0xF1), char(0x80), char(0x80), char(0x83)};
+ wchar_t* wp = nullptr;
+ std::mbstate_t m;
+ const char* np = nullptr;
+ std::codecvt_base::result r = c.in(m, n, n+4, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::error);
+ assert(wp == &w);
+ assert(np == n);
+ assert(w == 0);
+
+ n[0] = char(0xE1);
+ n[1] = char(0x80);
+ n[2] = char(0x85);
+ r = c.in(m, n, n+3, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::error);
+ assert(wp == &w);
+ assert(np == n);
+ assert(w == 0);
+
+ n[0] = char(0xD1);
+ n[1] = char(0x93);
+ r = c.in(m, n, n+2, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+2);
+ assert(w == 0x453);
+
+ w = 0x56;
+ n[0] = char(0x56);
+ r = c.in(m, n, n+1, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+1);
+ assert(w == 0x56);
+ }
+ {
+ typedef std::codecvt_utf8<wchar_t, 0xFFFFFFFF, std::consume_header> C;
+ C c;
+ wchar_t w = 0;
+ char n[7] = {char(0xEF), char(0xBB), char(0xBF), char(0xF1), char(0x80), char(0x80), char(0x83)};
+ wchar_t* wp = nullptr;
+ std::mbstate_t m;
+ const char* np = nullptr;
+ std::codecvt_base::result r = c.in(m, n, n+7, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+7);
+ assert(w == 0x40003);
+
+ n[0] = char(0xE1);
+ n[1] = char(0x80);
+ n[2] = char(0x85);
+ r = c.in(m, n, n+3, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+3);
+ assert(w == 0x1005);
+
+ n[0] = char(0xEF);
+ n[1] = char(0xBB);
+ n[2] = char(0xBF);
+ n[3] = char(0xD1);
+ n[4] = char(0x93);
+ r = c.in(m, n, n+5, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+5);
+ assert(w == 0x453);
+
+ w = 0x56;
+ n[0] = char(0x56);
+ r = c.in(m, n, n+1, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+1);
+ assert(w == 0x56);
+ }
+ {
+ typedef std::codecvt_utf8<char32_t> C;
+ C c;
+ char32_t w = 0;
+ char n[4] = {char(0xF1), char(0x80), char(0x80), char(0x83)};
+ char32_t* wp = nullptr;
+ std::mbstate_t m;
+ const char* np = nullptr;
+ std::codecvt_base::result r = c.in(m, n, n+4, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+4);
+ assert(w == 0x40003);
+
+ n[0] = char(0xE1);
+ n[1] = char(0x80);
+ n[2] = char(0x85);
+ r = c.in(m, n, n+3, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+3);
+ assert(w == 0x1005);
+
+ n[0] = char(0xD1);
+ n[1] = char(0x93);
+ r = c.in(m, n, n+2, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+2);
+ assert(w == 0x453);
+
+ w = 0x56;
+ n[0] = char(0x56);
+ r = c.in(m, n, n+1, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+1);
+ assert(w == 0x56);
+ }
+ {
+ typedef std::codecvt_utf8<char32_t, 0x1000> C;
+ C c;
+ char32_t w = 0;
+ char n[4] = {char(0xF1), char(0x80), char(0x80), char(0x83)};
+ char32_t* wp = nullptr;
+ std::mbstate_t m;
+ const char* np = nullptr;
+ std::codecvt_base::result r = c.in(m, n, n+4, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::error);
+ assert(wp == &w);
+ assert(np == n);
+ assert(w == 0);
+
+ n[0] = char(0xE1);
+ n[1] = char(0x80);
+ n[2] = char(0x85);
+ r = c.in(m, n, n+3, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::error);
+ assert(wp == &w);
+ assert(np == n);
+ assert(w == 0);
+
+ n[0] = char(0xD1);
+ n[1] = char(0x93);
+ r = c.in(m, n, n+2, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+2);
+ assert(w == 0x453);
+
+ w = 0x56;
+ n[0] = char(0x56);
+ r = c.in(m, n, n+1, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+1);
+ assert(w == 0x56);
+ }
+ {
+ typedef std::codecvt_utf8<char32_t, 0xFFFFFFFF, std::consume_header> C;
+ C c;
+ char32_t w = 0;
+ char n[7] = {char(0xEF), char(0xBB), char(0xBF), char(0xF1), char(0x80), char(0x80), char(0x83)};
+ char32_t* wp = nullptr;
+ std::mbstate_t m;
+ const char* np = nullptr;
+ std::codecvt_base::result r = c.in(m, n, n+7, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+7);
+ assert(w == 0x40003);
+
+ n[0] = char(0xE1);
+ n[1] = char(0x80);
+ n[2] = char(0x85);
+ r = c.in(m, n, n+3, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+3);
+ assert(w == 0x1005);
+
+ n[0] = char(0xEF);
+ n[1] = char(0xBB);
+ n[2] = char(0xBF);
+ n[3] = char(0xD1);
+ n[4] = char(0x93);
+ r = c.in(m, n, n+5, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+5);
+ assert(w == 0x453);
+
+ w = 0x56;
+ n[0] = char(0x56);
+ r = c.in(m, n, n+1, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+1);
+ assert(w == 0x56);
+ }
+ {
+ typedef std::codecvt_utf8<char16_t> C;
+ C c;
+ char16_t w = 0;
+ char n[3] = {char(0xE1), char(0x80), char(0x85)};
+ char16_t* wp = nullptr;
+ std::mbstate_t m;
+ const char* np = nullptr;
+ std::codecvt_base::result r = c.in(m, n, n+3, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+3);
+ assert(w == 0x1005);
+
+ n[0] = char(0xD1);
+ n[1] = char(0x93);
+ r = c.in(m, n, n+2, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+2);
+ assert(w == 0x453);
+
+ w = 0x56;
+ n[0] = char(0x56);
+ r = c.in(m, n, n+1, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+1);
+ assert(w == 0x56);
+ }
+ {
+ typedef std::codecvt_utf8<char16_t, 0x1000> C;
+ C c;
+ char16_t w = 0;
+ char n[3] = {char(0xE1), char(0x80), char(0x85)};
+ char16_t* wp = nullptr;
+ std::mbstate_t m;
+ const char* np = nullptr;
+ std::codecvt_base::result r = c.in(m, n, n+3, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::error);
+ assert(wp == &w);
+ assert(np == n);
+ assert(w == 0);
+
+ n[0] = char(0xD1);
+ n[1] = char(0x93);
+ r = c.in(m, n, n+2, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+2);
+ assert(w == 0x453);
+
+ w = 0x56;
+ n[0] = char(0x56);
+ r = c.in(m, n, n+1, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+1);
+ assert(w == 0x56);
+ }
+ {
+ typedef std::codecvt_utf8<char16_t, 0xFFFFFFFF, std::consume_header> C;
+ C c;
+ char16_t w = 0;
+ char n[6] = {char(0xEF), char(0xBB), char(0xBF), char(0xE1), char(0x80), char(0x85)};
+ char16_t* wp = nullptr;
+ std::mbstate_t m;
+ const char* np = nullptr;
+ std::codecvt_base::result r = c.in(m, n, n+6, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+6);
+ assert(w == 0x1005);
+
+ n[0] = char(0xD1);
+ n[1] = char(0x93);
+ r = c.in(m, n, n+2, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+2);
+ assert(w == 0x453);
+
+ w = 0x56;
+ n[0] = char(0x56);
+ r = c.in(m, n, n+1, np, &w, &w+1, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+1);
+ assert(w == 0x56);
+ }
+}
diff --git a/test/std/localization/locale.stdcvt/codecvt_utf8_length.pass.cpp b/test/std/localization/locale.stdcvt/codecvt_utf8_length.pass.cpp
new file mode 100644
index 000000000000..7239b4c8ffab
--- /dev/null
+++ b/test/std/localization/locale.stdcvt/codecvt_utf8_length.pass.cpp
@@ -0,0 +1,244 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <codecvt>
+
+// template <class Elem, unsigned long Maxcode = 0x10ffff,
+// codecvt_mode Mode = (codecvt_mode)0>
+// class codecvt_utf8
+// : public codecvt<Elem, char, mbstate_t>
+// {
+// // unspecified
+// };
+
+// int length(stateT& state, const externT* from, const externT* from_end,
+// size_t max) const;
+
+#include <codecvt>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::codecvt_utf8<wchar_t> C;
+ C c;
+ char n[4] = {char(0xF1), char(0x80), char(0x80), char(0x83)};
+ std::mbstate_t m;
+ int r = c.length(m, n, n+4, 1);
+ assert(r == 4);
+
+ n[0] = char(0xE1);
+ n[1] = char(0x80);
+ n[2] = char(0x85);
+ r = c.length(m, n, n+3, 2);
+ assert(r == 3);
+
+ n[0] = char(0xD1);
+ n[1] = char(0x93);
+ r = c.length(m, n, n+2, 3);
+ assert(r == 2);
+
+ n[0] = char(0x56);
+ r = c.length(m, n, n+1, 3);
+ assert(r == 1);
+ }
+ {
+ typedef std::codecvt_utf8<wchar_t, 0x1000> C;
+ C c;
+ char n[4] = {char(0xF1), char(0x80), char(0x80), char(0x83)};
+ std::mbstate_t m;
+ int r = c.length(m, n, n+4, 1);
+ assert(r == 0);
+
+ n[0] = char(0xE1);
+ n[1] = char(0x80);
+ n[2] = char(0x85);
+ r = c.length(m, n, n+3, 2);
+ assert(r == 0);
+
+ n[0] = char(0xD1);
+ n[1] = char(0x93);
+ r = c.length(m, n, n+2, 3);
+ assert(r == 2);
+
+ n[0] = char(0x56);
+ r = c.length(m, n, n+1, 3);
+ assert(r == 1);
+ }
+ {
+ typedef std::codecvt_utf8<wchar_t, 0xFFFFFFFF, std::consume_header> C;
+ C c;
+ char n[7] = {char(0xEF), char(0xBB), char(0xBF), char(0xF1), char(0x80), char(0x80), char(0x83)};
+ std::mbstate_t m;
+ int r = c.length(m, n, n+7, 1);
+ assert(r == 7);
+
+ n[0] = char(0xE1);
+ n[1] = char(0x80);
+ n[2] = char(0x85);
+ r = c.length(m, n, n+3, 2);
+ assert(r == 3);
+
+ n[0] = char(0xEF);
+ n[1] = char(0xBB);
+ n[2] = char(0xBF);
+ n[3] = char(0xD1);
+ n[4] = char(0x93);
+ r = c.length(m, n, n+5, 3);
+ assert(r == 5);
+
+ n[0] = char(0x56);
+ r = c.length(m, n, n+1, 3);
+ assert(r == 1);
+ }
+ {
+ typedef std::codecvt_utf8<char32_t> C;
+ C c;
+ char n[4] = {char(0xF1), char(0x80), char(0x80), char(0x83)};
+ std::mbstate_t m;
+ int r = c.length(m, n, n+4, 1);
+ assert(r == 4);
+
+ n[0] = char(0xE1);
+ n[1] = char(0x80);
+ n[2] = char(0x85);
+ r = c.length(m, n, n+3, 2);
+ assert(r == 3);
+
+ n[0] = char(0xD1);
+ n[1] = char(0x93);
+ r = c.length(m, n, n+2, 3);
+ assert(r == 2);
+
+ n[0] = char(0x56);
+ r = c.length(m, n, n+1, 3);
+ assert(r == 1);
+ }
+ {
+ typedef std::codecvt_utf8<char32_t, 0x1000> C;
+ C c;
+ char n[4] = {char(0xF1), char(0x80), char(0x80), char(0x83)};
+ std::mbstate_t m;
+ int r = c.length(m, n, n+4, 1);
+ assert(r == 0);
+
+ n[0] = char(0xE1);
+ n[1] = char(0x80);
+ n[2] = char(0x85);
+ r = c.length(m, n, n+3, 2);
+ assert(r == 0);
+
+ n[0] = char(0xD1);
+ n[1] = char(0x93);
+ r = c.length(m, n, n+2, 3);
+ assert(r == 2);
+
+ n[0] = char(0x56);
+ r = c.length(m, n, n+1, 3);
+ assert(r == 1);
+ }
+ {
+ typedef std::codecvt_utf8<char32_t, 0xFFFFFFFF, std::consume_header> C;
+ C c;
+ char n[7] = {char(0xEF), char(0xBB), char(0xBF), char(0xF1), char(0x80), char(0x80), char(0x83)};
+ std::mbstate_t m;
+ int r = c.length(m, n, n+7, 1);
+ assert(r == 7);
+
+ n[0] = char(0xE1);
+ n[1] = char(0x80);
+ n[2] = char(0x85);
+ r = c.length(m, n, n+3, 2);
+ assert(r == 3);
+
+ n[0] = char(0xEF);
+ n[1] = char(0xBB);
+ n[2] = char(0xBF);
+ n[3] = char(0xD1);
+ n[4] = char(0x93);
+ r = c.length(m, n, n+5, 3);
+ assert(r == 5);
+
+ n[0] = char(0x56);
+ r = c.length(m, n, n+1, 3);
+ assert(r == 1);
+ }
+ {
+ typedef std::codecvt_utf8<char16_t> C;
+ C c;
+ char n[4] = {char(0xF1), char(0x80), char(0x80), char(0x83)};
+ std::mbstate_t m;
+ int r = c.length(m, n, n+4, 1);
+ assert(r == 0);
+
+ n[0] = char(0xE1);
+ n[1] = char(0x80);
+ n[2] = char(0x85);
+ r = c.length(m, n, n+3, 2);
+ assert(r == 3);
+
+ n[0] = char(0xD1);
+ n[1] = char(0x93);
+ r = c.length(m, n, n+2, 3);
+ assert(r == 2);
+
+ n[0] = char(0x56);
+ r = c.length(m, n, n+1, 3);
+ assert(r == 1);
+ }
+ {
+ typedef std::codecvt_utf8<char16_t, 0x1000> C;
+ C c;
+ char n[4] = {char(0xF1), char(0x80), char(0x80), char(0x83)};
+ std::mbstate_t m;
+ int r = c.length(m, n, n+4, 1);
+ assert(r == 0);
+
+ n[0] = char(0xE1);
+ n[1] = char(0x80);
+ n[2] = char(0x85);
+ r = c.length(m, n, n+3, 2);
+ assert(r == 0);
+
+ n[0] = char(0xD1);
+ n[1] = char(0x93);
+ r = c.length(m, n, n+2, 3);
+ assert(r == 2);
+
+ n[0] = char(0x56);
+ r = c.length(m, n, n+1, 3);
+ assert(r == 1);
+ }
+ {
+ typedef std::codecvt_utf8<char16_t, 0xFFFFFFFF, std::consume_header> C;
+ C c;
+ char n[7] = {char(0xEF), char(0xBB), char(0xBF), char(0xF1), char(0x80), char(0x80), char(0x83)};
+ std::mbstate_t m;
+ int r = c.length(m, n, n+7, 1);
+ assert(r == 3);
+
+ n[0] = char(0xE1);
+ n[1] = char(0x80);
+ n[2] = char(0x85);
+ r = c.length(m, n, n+3, 2);
+ assert(r == 3);
+
+ n[0] = char(0xEF);
+ n[1] = char(0xBB);
+ n[2] = char(0xBF);
+ n[3] = char(0xD1);
+ n[4] = char(0x93);
+ r = c.length(m, n, n+5, 3);
+ assert(r == 5);
+
+ n[0] = char(0x56);
+ r = c.length(m, n, n+1, 3);
+ assert(r == 1);
+ }
+}
diff --git a/test/std/localization/locale.stdcvt/codecvt_utf8_max_length.pass.cpp b/test/std/localization/locale.stdcvt/codecvt_utf8_max_length.pass.cpp
new file mode 100644
index 000000000000..70e23f8f536c
--- /dev/null
+++ b/test/std/localization/locale.stdcvt/codecvt_utf8_max_length.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <codecvt>
+
+// template <class Elem, unsigned long Maxcode = 0x10ffff,
+// codecvt_mode Mode = (codecvt_mode)0>
+// class codecvt_utf8
+// : public codecvt<Elem, char, mbstate_t>
+// {
+// // unspecified
+// };
+
+// int max_length() const throw();
+
+#include <codecvt>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::codecvt_utf8<wchar_t> C;
+ C c;
+ int r = c.max_length();
+ assert(r == 4);
+ }
+ {
+ typedef std::codecvt_utf8<wchar_t, 0xFFFFFFFF, std::consume_header> C;
+ C c;
+ int r = c.max_length();
+ assert(r == 7);
+ }
+ {
+ typedef std::codecvt_utf8<char16_t> C;
+ C c;
+ int r = c.max_length();
+ assert(r == 3);
+ }
+ {
+ typedef std::codecvt_utf8<char16_t, 0xFFFFFFFF, std::consume_header> C;
+ C c;
+ int r = c.max_length();
+ assert(r == 6);
+ }
+ {
+ typedef std::codecvt_utf8<char32_t> C;
+ C c;
+ int r = c.max_length();
+ assert(r == 4);
+ }
+ {
+ typedef std::codecvt_utf8<char32_t, 0xFFFFFFFF, std::consume_header> C;
+ C c;
+ int r = c.max_length();
+ assert(r == 7);
+ }
+}
diff --git a/test/std/localization/locale.stdcvt/codecvt_utf8_out.pass.cpp b/test/std/localization/locale.stdcvt/codecvt_utf8_out.pass.cpp
new file mode 100644
index 000000000000..02cf7cf958e7
--- /dev/null
+++ b/test/std/localization/locale.stdcvt/codecvt_utf8_out.pass.cpp
@@ -0,0 +1,456 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <codecvt>
+
+// template <class Elem, unsigned long Maxcode = 0x10ffff,
+// codecvt_mode Mode = (codecvt_mode)0>
+// class codecvt_utf8
+// : public codecvt<Elem, char, mbstate_t>
+// {
+// // unspecified
+// };
+
+// result
+// out(stateT& state,
+// const internT* from, const internT* from_end, const internT*& from_next,
+// externT* to, externT* to_end, externT*& to_next) const;
+
+#include <codecvt>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::codecvt_utf8<wchar_t> C;
+ C c;
+ wchar_t w = 0x40003;
+ char n[4] = {0};
+ const wchar_t* wp = nullptr;
+ std::mbstate_t m;
+ char* np = nullptr;
+ std::codecvt_base::result r = c.out(m, &w, &w+1, wp, n, n+4, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+4);
+ assert(n[0] == char(0xF1));
+ assert(n[1] == char(0x80));
+ assert(n[2] == char(0x80));
+ assert(n[3] == char(0x83));
+
+ w = 0x1005;
+ r = c.out(m, &w, &w+1, wp, n, n+4, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+3);
+ assert(n[0] == char(0xE1));
+ assert(n[1] == char(0x80));
+ assert(n[2] == char(0x85));
+ assert(n[3] == char(0x83));
+
+ w = 0x453;
+ r = c.out(m, &w, &w+1, wp, n, n+4, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+2);
+ assert(n[0] == char(0xD1));
+ assert(n[1] == char(0x93));
+ assert(n[2] == char(0x85));
+ assert(n[3] == char(0x83));
+
+ w = 0x56;
+ r = c.out(m, &w, &w+1, wp, n, n+4, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+1);
+ assert(n[0] == char(0x56));
+ assert(n[1] == char(0x93));
+ assert(n[2] == char(0x85));
+ assert(n[3] == char(0x83));
+ }
+ {
+ typedef std::codecvt_utf8<wchar_t, 0x1000> C;
+ C c;
+ wchar_t w = 0x40003;
+ char n[4] = {0};
+ const wchar_t* wp = nullptr;
+ std::mbstate_t m;
+ char* np = nullptr;
+ std::codecvt_base::result r = c.out(m, &w, &w+1, wp, n, n+4, np);
+ assert(r == std::codecvt_base::error);
+ assert(wp == &w);
+ assert(np == n);
+ assert(n[0] == char(0));
+ assert(n[1] == char(0));
+ assert(n[2] == char(0));
+ assert(n[3] == char(0));
+
+ w = 0x1005;
+ r = c.out(m, &w, &w+1, wp, n, n+4, np);
+ assert(r == std::codecvt_base::error);
+ assert(wp == &w);
+ assert(np == n);
+ assert(n[0] == char(0));
+ assert(n[1] == char(0));
+ assert(n[2] == char(0));
+ assert(n[3] == char(0));
+
+ w = 0x453;
+ r = c.out(m, &w, &w+1, wp, n, n+4, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+2);
+ assert(n[0] == char(0xD1));
+ assert(n[1] == char(0x93));
+ assert(n[2] == char(0));
+ assert(n[3] == char(0));
+
+ w = 0x56;
+ r = c.out(m, &w, &w+1, wp, n, n+4, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+1);
+ assert(n[0] == char(0x56));
+ assert(n[1] == char(0x93));
+ assert(n[2] == char(0));
+ assert(n[3] == char(0));
+ }
+ {
+ typedef std::codecvt_utf8<wchar_t, 0xFFFFFFFF, std::generate_header> C;
+ C c;
+ wchar_t w = 0x40003;
+ char n[7] = {0};
+ const wchar_t* wp = nullptr;
+ std::mbstate_t m;
+ char* np = nullptr;
+ std::codecvt_base::result r = c.out(m, &w, &w+1, wp, n, n+7, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+7);
+ assert(n[0] == char(0xEF));
+ assert(n[1] == char(0xBB));
+ assert(n[2] == char(0xBF));
+ assert(n[3] == char(0xF1));
+ assert(n[4] == char(0x80));
+ assert(n[5] == char(0x80));
+ assert(n[6] == char(0x83));
+
+ w = 0x1005;
+ r = c.out(m, &w, &w+1, wp, n, n+7, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+6);
+ assert(n[0] == char(0xEF));
+ assert(n[1] == char(0xBB));
+ assert(n[2] == char(0xBF));
+ assert(n[3] == char(0xE1));
+ assert(n[4] == char(0x80));
+ assert(n[5] == char(0x85));
+ assert(n[6] == char(0x83));
+
+ w = 0x453;
+ r = c.out(m, &w, &w+1, wp, n, n+7, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+5);
+ assert(n[0] == char(0xEF));
+ assert(n[1] == char(0xBB));
+ assert(n[2] == char(0xBF));
+ assert(n[3] == char(0xD1));
+ assert(n[4] == char(0x93));
+ assert(n[5] == char(0x85));
+ assert(n[6] == char(0x83));
+
+ w = 0x56;
+ r = c.out(m, &w, &w+1, wp, n, n+7, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+4);
+ assert(n[0] == char(0xEF));
+ assert(n[1] == char(0xBB));
+ assert(n[2] == char(0xBF));
+ assert(n[3] == char(0x56));
+ assert(n[4] == char(0x93));
+ assert(n[5] == char(0x85));
+ assert(n[6] == char(0x83));
+ }
+ {
+ typedef std::codecvt_utf8<char32_t> C;
+ C c;
+ char32_t w = 0x40003;
+ char n[4] = {0};
+ const char32_t* wp = nullptr;
+ std::mbstate_t m;
+ char* np = nullptr;
+ std::codecvt_base::result r = c.out(m, &w, &w+1, wp, n, n+4, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+4);
+ assert(n[0] == char(0xF1));
+ assert(n[1] == char(0x80));
+ assert(n[2] == char(0x80));
+ assert(n[3] == char(0x83));
+
+ w = 0x1005;
+ r = c.out(m, &w, &w+1, wp, n, n+4, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+3);
+ assert(n[0] == char(0xE1));
+ assert(n[1] == char(0x80));
+ assert(n[2] == char(0x85));
+ assert(n[3] == char(0x83));
+
+ w = 0x453;
+ r = c.out(m, &w, &w+1, wp, n, n+4, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+2);
+ assert(n[0] == char(0xD1));
+ assert(n[1] == char(0x93));
+ assert(n[2] == char(0x85));
+ assert(n[3] == char(0x83));
+
+ w = 0x56;
+ r = c.out(m, &w, &w+1, wp, n, n+4, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+1);
+ assert(n[0] == char(0x56));
+ assert(n[1] == char(0x93));
+ assert(n[2] == char(0x85));
+ assert(n[3] == char(0x83));
+ }
+ {
+ typedef std::codecvt_utf8<char32_t, 0x1000> C;
+ C c;
+ char32_t w = 0x40003;
+ char n[4] = {0};
+ const char32_t* wp = nullptr;
+ std::mbstate_t m;
+ char* np = nullptr;
+ std::codecvt_base::result r = c.out(m, &w, &w+1, wp, n, n+4, np);
+ assert(r == std::codecvt_base::error);
+ assert(wp == &w);
+ assert(np == n);
+ assert(n[0] == char(0));
+ assert(n[1] == char(0));
+ assert(n[2] == char(0));
+ assert(n[3] == char(0));
+
+ w = 0x1005;
+ r = c.out(m, &w, &w+1, wp, n, n+4, np);
+ assert(r == std::codecvt_base::error);
+ assert(wp == &w);
+ assert(np == n);
+ assert(n[0] == char(0));
+ assert(n[1] == char(0));
+ assert(n[2] == char(0));
+ assert(n[3] == char(0));
+
+ w = 0x453;
+ r = c.out(m, &w, &w+1, wp, n, n+4, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+2);
+ assert(n[0] == char(0xD1));
+ assert(n[1] == char(0x93));
+ assert(n[2] == char(0));
+ assert(n[3] == char(0));
+
+ w = 0x56;
+ r = c.out(m, &w, &w+1, wp, n, n+4, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+1);
+ assert(n[0] == char(0x56));
+ assert(n[1] == char(0x93));
+ assert(n[2] == char(0));
+ assert(n[3] == char(0));
+ }
+ {
+ typedef std::codecvt_utf8<char32_t, 0xFFFFFFFF, std::generate_header> C;
+ C c;
+ char32_t w = 0x40003;
+ char n[7] = {0};
+ const char32_t* wp = nullptr;
+ std::mbstate_t m;
+ char* np = nullptr;
+ std::codecvt_base::result r = c.out(m, &w, &w+1, wp, n, n+7, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+7);
+ assert(n[0] == char(0xEF));
+ assert(n[1] == char(0xBB));
+ assert(n[2] == char(0xBF));
+ assert(n[3] == char(0xF1));
+ assert(n[4] == char(0x80));
+ assert(n[5] == char(0x80));
+ assert(n[6] == char(0x83));
+
+ w = 0x1005;
+ r = c.out(m, &w, &w+1, wp, n, n+7, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+6);
+ assert(n[0] == char(0xEF));
+ assert(n[1] == char(0xBB));
+ assert(n[2] == char(0xBF));
+ assert(n[3] == char(0xE1));
+ assert(n[4] == char(0x80));
+ assert(n[5] == char(0x85));
+ assert(n[6] == char(0x83));
+
+ w = 0x453;
+ r = c.out(m, &w, &w+1, wp, n, n+7, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+5);
+ assert(n[0] == char(0xEF));
+ assert(n[1] == char(0xBB));
+ assert(n[2] == char(0xBF));
+ assert(n[3] == char(0xD1));
+ assert(n[4] == char(0x93));
+ assert(n[5] == char(0x85));
+ assert(n[6] == char(0x83));
+
+ w = 0x56;
+ r = c.out(m, &w, &w+1, wp, n, n+7, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+4);
+ assert(n[0] == char(0xEF));
+ assert(n[1] == char(0xBB));
+ assert(n[2] == char(0xBF));
+ assert(n[3] == char(0x56));
+ assert(n[4] == char(0x93));
+ assert(n[5] == char(0x85));
+ assert(n[6] == char(0x83));
+ }
+ {
+ typedef std::codecvt_utf8<char16_t> C;
+ C c;
+ char16_t w = 0x1005;
+ char n[4] = {0};
+ const char16_t* wp = nullptr;
+ std::mbstate_t m;
+ char* np = nullptr;
+ std::codecvt_base::result r = c.out(m, &w, &w+1, wp, n, n+4, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+3);
+ assert(n[0] == char(0xE1));
+ assert(n[1] == char(0x80));
+ assert(n[2] == char(0x85));
+ assert(n[3] == char(0));
+
+ w = 0x453;
+ r = c.out(m, &w, &w+1, wp, n, n+4, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+2);
+ assert(n[0] == char(0xD1));
+ assert(n[1] == char(0x93));
+ assert(n[2] == char(0x85));
+ assert(n[3] == char(0));
+
+ w = 0x56;
+ r = c.out(m, &w, &w+1, wp, n, n+4, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+1);
+ assert(n[0] == char(0x56));
+ assert(n[1] == char(0x93));
+ assert(n[2] == char(0x85));
+ assert(n[3] == char(0));
+ }
+ {
+ typedef std::codecvt_utf8<char16_t, 0x1000> C;
+ C c;
+ char16_t w = 0x1005;
+ char n[4] = {0};
+ const char16_t* wp = nullptr;
+ std::mbstate_t m;
+ char* np = nullptr;
+ std::codecvt_base::result r = c.out(m, &w, &w+1, wp, n, n+4, np);
+ assert(r == std::codecvt_base::error);
+ assert(wp == &w);
+ assert(np == n);
+ assert(n[0] == char(0));
+ assert(n[1] == char(0));
+ assert(n[2] == char(0));
+ assert(n[3] == char(0));
+
+ w = 0x453;
+ r = c.out(m, &w, &w+1, wp, n, n+4, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+2);
+ assert(n[0] == char(0xD1));
+ assert(n[1] == char(0x93));
+ assert(n[2] == char(0));
+ assert(n[3] == char(0));
+
+ w = 0x56;
+ r = c.out(m, &w, &w+1, wp, n, n+4, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+1);
+ assert(n[0] == char(0x56));
+ assert(n[1] == char(0x93));
+ assert(n[2] == char(0));
+ assert(n[3] == char(0));
+ }
+ {
+ typedef std::codecvt_utf8<char16_t, 0xFFFFFFFF, std::generate_header> C;
+ C c;
+ char16_t w = 0x1005;
+ char n[7] = {0};
+ const char16_t* wp = nullptr;
+ std::mbstate_t m;
+ char* np = nullptr;
+ std::codecvt_base::result r = c.out(m, &w, &w+1, wp, n, n+7, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+6);
+ assert(n[0] == char(0xEF));
+ assert(n[1] == char(0xBB));
+ assert(n[2] == char(0xBF));
+ assert(n[3] == char(0xE1));
+ assert(n[4] == char(0x80));
+ assert(n[5] == char(0x85));
+ assert(n[6] == char(0));
+
+ w = 0x453;
+ r = c.out(m, &w, &w+1, wp, n, n+7, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+5);
+ assert(n[0] == char(0xEF));
+ assert(n[1] == char(0xBB));
+ assert(n[2] == char(0xBF));
+ assert(n[3] == char(0xD1));
+ assert(n[4] == char(0x93));
+ assert(n[5] == char(0x85));
+ assert(n[6] == char(0));
+
+ w = 0x56;
+ r = c.out(m, &w, &w+1, wp, n, n+7, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w+1);
+ assert(np == n+4);
+ assert(n[0] == char(0xEF));
+ assert(n[1] == char(0xBB));
+ assert(n[2] == char(0xBF));
+ assert(n[3] == char(0x56));
+ assert(n[4] == char(0x93));
+ assert(n[5] == char(0x85));
+ assert(n[6] == char(0));
+ }
+}
diff --git a/test/std/localization/locale.stdcvt/codecvt_utf8_unshift.pass.cpp b/test/std/localization/locale.stdcvt/codecvt_utf8_unshift.pass.cpp
new file mode 100644
index 000000000000..1f0c237d0b20
--- /dev/null
+++ b/test/std/localization/locale.stdcvt/codecvt_utf8_unshift.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <codecvt>
+
+// template <class Elem, unsigned long Maxcode = 0x10ffff,
+// codecvt_mode Mode = (codecvt_mode)0>
+// class codecvt_utf8
+// : public codecvt<Elem, char, mbstate_t>
+// {
+// // unspecified
+// };
+
+// result
+// unshift(stateT& state,
+// externT* to, externT* to_end, externT*& to_next) const;
+
+#include <codecvt>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::codecvt_utf8<wchar_t> C;
+ C c;
+ char n[4] = {0};
+ std::mbstate_t m;
+ char* np = nullptr;
+ std::codecvt_base::result r = c.unshift(m, n, n+4, np);
+ assert(r == std::codecvt_base::noconv);
+ }
+ {
+ typedef std::codecvt_utf8<char16_t> C;
+ C c;
+ char n[4] = {0};
+ std::mbstate_t m;
+ char* np = nullptr;
+ std::codecvt_base::result r = c.unshift(m, n, n+4, np);
+ assert(r == std::codecvt_base::noconv);
+ }
+ {
+ typedef std::codecvt_utf8<char32_t> C;
+ C c;
+ char n[4] = {0};
+ std::mbstate_t m;
+ char* np = nullptr;
+ std::codecvt_base::result r = c.unshift(m, n, n+4, np);
+ assert(r == std::codecvt_base::noconv);
+ }
+}
diff --git a/test/std/localization/locale.stdcvt/codecvt_utf8_utf16_always_noconv.pass.cpp b/test/std/localization/locale.stdcvt/codecvt_utf8_utf16_always_noconv.pass.cpp
new file mode 100644
index 000000000000..7690e6193e70
--- /dev/null
+++ b/test/std/localization/locale.stdcvt/codecvt_utf8_utf16_always_noconv.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <codecvt>
+
+// template <class Elem, unsigned long Maxcode = 0x10ffff,
+// codecvt_mode Mode = (codecvt_mode)0>
+// class codecvt_utf8_utf16
+// : public codecvt<Elem, char, mbstate_t>
+// {
+// // unspecified
+// };
+
+// bool always_noconv() const throw();
+
+#include <codecvt>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::codecvt_utf8_utf16<wchar_t> C;
+ C c;
+ bool r = c.always_noconv();
+ assert(r == false);
+ }
+ {
+ typedef std::codecvt_utf8_utf16<char16_t> C;
+ C c;
+ bool r = c.always_noconv();
+ assert(r == false);
+ }
+ {
+ typedef std::codecvt_utf8_utf16<char32_t> C;
+ C c;
+ bool r = c.always_noconv();
+ assert(r == false);
+ }
+}
diff --git a/test/std/localization/locale.stdcvt/codecvt_utf8_utf16_encoding.pass.cpp b/test/std/localization/locale.stdcvt/codecvt_utf8_utf16_encoding.pass.cpp
new file mode 100644
index 000000000000..bc178800f902
--- /dev/null
+++ b/test/std/localization/locale.stdcvt/codecvt_utf8_utf16_encoding.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <codecvt>
+
+// template <class Elem, unsigned long Maxcode = 0x10ffff,
+// codecvt_mode Mode = (codecvt_mode)0>
+// class codecvt_utf8_utf16
+// : public codecvt<Elem, char, mbstate_t>
+// {
+// // unspecified
+// };
+
+// int encoding() const throw();
+
+#include <codecvt>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::codecvt_utf8_utf16<wchar_t> C;
+ C c;
+ int r = c.encoding();
+ assert(r == 0);
+ }
+ {
+ typedef std::codecvt_utf8_utf16<char16_t> C;
+ C c;
+ int r = c.encoding();
+ assert(r == 0);
+ }
+ {
+ typedef std::codecvt_utf8_utf16<char32_t> C;
+ C c;
+ int r = c.encoding();
+ assert(r == 0);
+ }
+}
diff --git a/test/std/localization/locale.stdcvt/codecvt_utf8_utf16_in.pass.cpp b/test/std/localization/locale.stdcvt/codecvt_utf8_utf16_in.pass.cpp
new file mode 100644
index 000000000000..0cd941764aa0
--- /dev/null
+++ b/test/std/localization/locale.stdcvt/codecvt_utf8_utf16_in.pass.cpp
@@ -0,0 +1,372 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <codecvt>
+
+// template <class Elem, unsigned long Maxcode = 0x10ffff,
+// codecvt_mode Mode = (codecvt_mode)0>
+// class codecvt_utf8_utf16
+// : public codecvt<Elem, char, mbstate_t>
+// {
+// // unspecified
+// };
+
+// result
+// in(stateT& state,
+// const externT* from, const externT* from_end, const externT*& from_next,
+// internT* to, internT* to_end, internT*& to_next) const;
+
+#include <codecvt>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::codecvt_utf8_utf16<wchar_t> C;
+ C c;
+ wchar_t w[2] = {0};
+ char n[4] = {char(0xF1), char(0x80), char(0x80), char(0x83)};
+ wchar_t* wp = nullptr;
+ std::mbstate_t m;
+ const char* np = nullptr;
+ std::codecvt_base::result r = c.in(m, n, n+4, np, w, w+2, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w+2);
+ assert(np == n+4);
+ assert(w[0] == 0xD8C0);
+ assert(w[1] == 0xDC03);
+
+ n[0] = char(0xE1);
+ n[1] = char(0x80);
+ n[2] = char(0x85);
+ r = c.in(m, n, n+3, np, w, w+2, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w+1);
+ assert(np == n+3);
+ assert(w[0] == 0x1005);
+
+ n[0] = char(0xD1);
+ n[1] = char(0x93);
+ r = c.in(m, n, n+2, np, w, w+2, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w+1);
+ assert(np == n+2);
+ assert(w[0] == 0x0453);
+
+ n[0] = char(0x56);
+ r = c.in(m, n, n+1, np, w, w+2, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w+1);
+ assert(np == n+1);
+ assert(w[0] == 0x0056);
+ }
+ {
+ typedef std::codecvt_utf8_utf16<wchar_t, 0x1000> C;
+ C c;
+ wchar_t w[2] = {0};
+ char n[4] = {char(0xF1), char(0x80), char(0x80), char(0x83)};
+ wchar_t* wp = nullptr;
+ std::mbstate_t m;
+ const char* np = nullptr;
+ std::codecvt_base::result r = c.in(m, n, n+4, np, w, w+2, wp);
+ assert(r == std::codecvt_base::error);
+ assert(wp == w);
+ assert(np == n);
+
+ n[0] = char(0xE1);
+ n[1] = char(0x80);
+ n[2] = char(0x85);
+ r = c.in(m, n, n+3, np, w, w+2, wp);
+ assert(r == std::codecvt_base::error);
+ assert(wp == w);
+ assert(np == n);
+
+ n[0] = char(0xD1);
+ n[1] = char(0x93);
+ r = c.in(m, n, n+2, np, w, w+2, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w+1);
+ assert(np == n+2);
+ assert(w[0] == 0x0453);
+
+ n[0] = char(0x56);
+ r = c.in(m, n, n+1, np, w, w+2, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w+1);
+ assert(np == n+1);
+ assert(w[0] == 0x0056);
+ }
+ {
+ typedef std::codecvt_utf8_utf16<wchar_t, 0x10ffff, std::consume_header> C;
+ C c;
+ wchar_t w[2] = {0};
+ char n[7] = {char(0xEF), char(0xBB), char(0xBF), char(0xF1), char(0x80), char(0x80), char(0x83)};
+ wchar_t* wp = nullptr;
+ std::mbstate_t m;
+ const char* np = nullptr;
+ std::codecvt_base::result r = c.in(m, n, n+7, np, w, w+2, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w+2);
+ assert(np == n+7);
+ assert(w[0] == 0xD8C0);
+ assert(w[1] == 0xDC03);
+
+ n[0] = char(0xE1);
+ n[1] = char(0x80);
+ n[2] = char(0x85);
+ r = c.in(m, n, n+3, np, w, w+2, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w+1);
+ assert(np == n+3);
+ assert(w[0] == 0x1005);
+
+ n[0] = char(0xD1);
+ n[1] = char(0x93);
+ r = c.in(m, n, n+2, np, w, w+2, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w+1);
+ assert(np == n+2);
+ assert(w[0] == 0x0453);
+
+ n[0] = char(0x56);
+ r = c.in(m, n, n+1, np, w, w+2, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w+1);
+ assert(np == n+1);
+ assert(w[0] == 0x0056);
+ }
+ {
+ typedef std::codecvt_utf8_utf16<char32_t> C;
+ C c;
+ char32_t w[2] = {0};
+ char n[4] = {char(0xF1), char(0x80), char(0x80), char(0x83)};
+ char32_t* wp = nullptr;
+ std::mbstate_t m;
+ const char* np = nullptr;
+ std::codecvt_base::result r = c.in(m, n, n+4, np, w, w+2, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w+2);
+ assert(np == n+4);
+ assert(w[0] == 0xD8C0);
+ assert(w[1] == 0xDC03);
+
+ n[0] = char(0xE1);
+ n[1] = char(0x80);
+ n[2] = char(0x85);
+ r = c.in(m, n, n+3, np, w, w+2, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w+1);
+ assert(np == n+3);
+ assert(w[0] == 0x1005);
+
+ n[0] = char(0xD1);
+ n[1] = char(0x93);
+ r = c.in(m, n, n+2, np, w, w+2, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w+1);
+ assert(np == n+2);
+ assert(w[0] == 0x0453);
+
+ n[0] = char(0x56);
+ r = c.in(m, n, n+1, np, w, w+2, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w+1);
+ assert(np == n+1);
+ assert(w[0] == 0x0056);
+ }
+ {
+ typedef std::codecvt_utf8_utf16<char32_t, 0x1000> C;
+ C c;
+ char32_t w[2] = {0};
+ char n[4] = {char(0xF1), char(0x80), char(0x80), char(0x83)};
+ char32_t* wp = nullptr;
+ std::mbstate_t m;
+ const char* np = nullptr;
+ std::codecvt_base::result r = c.in(m, n, n+4, np, w, w+2, wp);
+ assert(r == std::codecvt_base::error);
+ assert(wp == w);
+ assert(np == n);
+
+ n[0] = char(0xE1);
+ n[1] = char(0x80);
+ n[2] = char(0x85);
+ r = c.in(m, n, n+3, np, w, w+2, wp);
+ assert(r == std::codecvt_base::error);
+ assert(wp == w);
+ assert(np == n);
+
+ n[0] = char(0xD1);
+ n[1] = char(0x93);
+ r = c.in(m, n, n+2, np, w, w+2, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w+1);
+ assert(np == n+2);
+ assert(w[0] == 0x0453);
+
+ n[0] = char(0x56);
+ r = c.in(m, n, n+1, np, w, w+2, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w+1);
+ assert(np == n+1);
+ assert(w[0] == 0x0056);
+ }
+ {
+ typedef std::codecvt_utf8_utf16<char32_t, 0x10ffff, std::consume_header> C;
+ C c;
+ char32_t w[2] = {0};
+ char n[7] = {char(0xEF), char(0xBB), char(0xBF), char(0xF1), char(0x80), char(0x80), char(0x83)};
+ char32_t* wp = nullptr;
+ std::mbstate_t m;
+ const char* np = nullptr;
+ std::codecvt_base::result r = c.in(m, n, n+7, np, w, w+2, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w+2);
+ assert(np == n+7);
+ assert(w[0] == 0xD8C0);
+ assert(w[1] == 0xDC03);
+
+ n[0] = char(0xE1);
+ n[1] = char(0x80);
+ n[2] = char(0x85);
+ r = c.in(m, n, n+3, np, w, w+2, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w+1);
+ assert(np == n+3);
+ assert(w[0] == 0x1005);
+
+ n[0] = char(0xD1);
+ n[1] = char(0x93);
+ r = c.in(m, n, n+2, np, w, w+2, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w+1);
+ assert(np == n+2);
+ assert(w[0] == 0x0453);
+
+ n[0] = char(0x56);
+ r = c.in(m, n, n+1, np, w, w+2, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w+1);
+ assert(np == n+1);
+ assert(w[0] == 0x0056);
+ }
+ {
+ typedef std::codecvt_utf8_utf16<char16_t> C;
+ C c;
+ char16_t w[2] = {0};
+ char n[4] = {char(0xF1), char(0x80), char(0x80), char(0x83)};
+ char16_t* wp = nullptr;
+ std::mbstate_t m;
+ const char* np = nullptr;
+ std::codecvt_base::result r = c.in(m, n, n+4, np, w, w+2, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w+2);
+ assert(np == n+4);
+ assert(w[0] == 0xD8C0);
+ assert(w[1] == 0xDC03);
+
+ n[0] = char(0xE1);
+ n[1] = char(0x80);
+ n[2] = char(0x85);
+ r = c.in(m, n, n+3, np, w, w+2, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w+1);
+ assert(np == n+3);
+ assert(w[0] == 0x1005);
+
+ n[0] = char(0xD1);
+ n[1] = char(0x93);
+ r = c.in(m, n, n+2, np, w, w+2, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w+1);
+ assert(np == n+2);
+ assert(w[0] == 0x0453);
+
+ n[0] = char(0x56);
+ r = c.in(m, n, n+1, np, w, w+2, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w+1);
+ assert(np == n+1);
+ assert(w[0] == 0x0056);
+ }
+ {
+ typedef std::codecvt_utf8_utf16<char16_t, 0x1000> C;
+ C c;
+ char16_t w[2] = {0};
+ char n[4] = {char(0xF1), char(0x80), char(0x80), char(0x83)};
+ char16_t* wp = nullptr;
+ std::mbstate_t m;
+ const char* np = nullptr;
+ std::codecvt_base::result r = c.in(m, n, n+4, np, w, w+2, wp);
+ assert(r == std::codecvt_base::error);
+ assert(wp == w);
+ assert(np == n);
+
+ n[0] = char(0xE1);
+ n[1] = char(0x80);
+ n[2] = char(0x85);
+ r = c.in(m, n, n+3, np, w, w+2, wp);
+ assert(r == std::codecvt_base::error);
+ assert(wp == w);
+ assert(np == n);
+
+ n[0] = char(0xD1);
+ n[1] = char(0x93);
+ r = c.in(m, n, n+2, np, w, w+2, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w+1);
+ assert(np == n+2);
+ assert(w[0] == 0x0453);
+
+ n[0] = char(0x56);
+ r = c.in(m, n, n+1, np, w, w+2, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w+1);
+ assert(np == n+1);
+ assert(w[0] == 0x0056);
+ }
+ {
+ typedef std::codecvt_utf8_utf16<char16_t, 0x10ffff, std::consume_header> C;
+ C c;
+ char16_t w[2] = {0};
+ char n[7] = {char(0xEF), char(0xBB), char(0xBF), char(0xF1), char(0x80), char(0x80), char(0x83)};
+ char16_t* wp = nullptr;
+ std::mbstate_t m;
+ const char* np = nullptr;
+ std::codecvt_base::result r = c.in(m, n, n+7, np, w, w+2, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w+2);
+ assert(np == n+7);
+ assert(w[0] == 0xD8C0);
+ assert(w[1] == 0xDC03);
+
+ n[0] = char(0xE1);
+ n[1] = char(0x80);
+ n[2] = char(0x85);
+ r = c.in(m, n, n+3, np, w, w+2, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w+1);
+ assert(np == n+3);
+ assert(w[0] == 0x1005);
+
+ n[0] = char(0xD1);
+ n[1] = char(0x93);
+ r = c.in(m, n, n+2, np, w, w+2, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w+1);
+ assert(np == n+2);
+ assert(w[0] == 0x0453);
+
+ n[0] = char(0x56);
+ r = c.in(m, n, n+1, np, w, w+2, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w+1);
+ assert(np == n+1);
+ assert(w[0] == 0x0056);
+ }
+}
diff --git a/test/std/localization/locale.stdcvt/codecvt_utf8_utf16_length.pass.cpp b/test/std/localization/locale.stdcvt/codecvt_utf8_utf16_length.pass.cpp
new file mode 100644
index 000000000000..8f5be81e6655
--- /dev/null
+++ b/test/std/localization/locale.stdcvt/codecvt_utf8_utf16_length.pass.cpp
@@ -0,0 +1,235 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <codecvt>
+
+// template <class Elem, unsigned long Maxcode = 0x10ffff,
+// codecvt_mode Mode = (codecvt_mode)0>
+// class codecvt_utf8_utf16
+// : public codecvt<Elem, char, mbstate_t>
+// {
+// // unspecified
+// };
+
+// int length(stateT& state, const externT* from, const externT* from_end,
+// size_t max) const;
+
+#include <codecvt>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::codecvt_utf8_utf16<wchar_t> C;
+ C c;
+ char n[4] = {char(0xF1), char(0x80), char(0x80), char(0x83)};
+ std::mbstate_t m;
+ int r = c.length(m, n, n+4, 2);
+ assert(r == 4);
+
+ n[0] = char(0xE1);
+ n[1] = char(0x80);
+ n[2] = char(0x85);
+ r = c.length(m, n, n+3, 2);
+ assert(r == 3);
+
+ n[0] = char(0xD1);
+ n[1] = char(0x93);
+ r = c.length(m, n, n+2, 2);
+ assert(r == 2);
+
+ n[0] = char(0x56);
+ r = c.length(m, n, n+1, 2);
+ assert(r == 1);
+ }
+ {
+ typedef std::codecvt_utf8_utf16<wchar_t, 0x1000> C;
+ C c;
+ char n[4] = {char(0xF1), char(0x80), char(0x80), char(0x83)};
+ std::mbstate_t m;
+ int r = c.length(m, n, n+4, 2);
+ assert(r == 0);
+
+ n[0] = char(0xE1);
+ n[1] = char(0x80);
+ n[2] = char(0x85);
+ r = c.length(m, n, n+3, 2);
+ assert(r == 0);
+
+ n[0] = char(0xD1);
+ n[1] = char(0x93);
+ r = c.length(m, n, n+2, 2);
+ assert(r == 2);
+
+ n[0] = char(0x56);
+ r = c.length(m, n, n+1, 2);
+ assert(r == 1);
+ }
+ {
+ typedef std::codecvt_utf8_utf16<wchar_t, 0x10ffff, std::consume_header> C;
+ C c;
+ char n[7] = {char(0xEF), char(0xBB), char(0xBF), char(0xF1), char(0x80), char(0x80), char(0x83)};
+ std::mbstate_t m;
+ int r = c.length(m, n, n+7, 2);
+ assert(r == 7);
+
+ n[0] = char(0xE1);
+ n[1] = char(0x80);
+ n[2] = char(0x85);
+ r = c.length(m, n, n+3, 2);
+ assert(r == 3);
+
+ n[0] = char(0xD1);
+ n[1] = char(0x93);
+ r = c.length(m, n, n+2, 2);
+ assert(r == 2);
+
+ n[0] = char(0x56);
+ r = c.length(m, n, n+1, 2);
+ assert(r == 1);
+ }
+ {
+ typedef std::codecvt_utf8_utf16<char32_t> C;
+ C c;
+ char n[4] = {char(0xF1), char(0x80), char(0x80), char(0x83)};
+ std::mbstate_t m;
+ int r = c.length(m, n, n+4, 2);
+ assert(r == 4);
+
+ n[0] = char(0xE1);
+ n[1] = char(0x80);
+ n[2] = char(0x85);
+ r = c.length(m, n, n+3, 2);
+ assert(r == 3);
+
+ n[0] = char(0xD1);
+ n[1] = char(0x93);
+ r = c.length(m, n, n+2, 2);
+ assert(r == 2);
+
+ n[0] = char(0x56);
+ r = c.length(m, n, n+1, 2);
+ assert(r == 1);
+ }
+ {
+ typedef std::codecvt_utf8_utf16<char32_t, 0x1000> C;
+ C c;
+ char n[4] = {char(0xF1), char(0x80), char(0x80), char(0x83)};
+ std::mbstate_t m;
+ int r = c.length(m, n, n+4, 2);
+ assert(r == 0);
+
+ n[0] = char(0xE1);
+ n[1] = char(0x80);
+ n[2] = char(0x85);
+ r = c.length(m, n, n+3, 2);
+ assert(r == 0);
+
+ n[0] = char(0xD1);
+ n[1] = char(0x93);
+ r = c.length(m, n, n+2, 2);
+ assert(r == 2);
+
+ n[0] = char(0x56);
+ r = c.length(m, n, n+1, 2);
+ assert(r == 1);
+ }
+ {
+ typedef std::codecvt_utf8_utf16<char32_t, 0x10ffff, std::consume_header> C;
+ C c;
+ char n[7] = {char(0xEF), char(0xBB), char(0xBF), char(0xF1), char(0x80), char(0x80), char(0x83)};
+ std::mbstate_t m;
+ int r = c.length(m, n, n+7, 2);
+ assert(r == 7);
+
+ n[0] = char(0xE1);
+ n[1] = char(0x80);
+ n[2] = char(0x85);
+ r = c.length(m, n, n+3, 2);
+ assert(r == 3);
+
+ n[0] = char(0xD1);
+ n[1] = char(0x93);
+ r = c.length(m, n, n+2, 2);
+ assert(r == 2);
+
+ n[0] = char(0x56);
+ r = c.length(m, n, n+1, 2);
+ assert(r == 1);
+ }
+ {
+ typedef std::codecvt_utf8_utf16<char16_t> C;
+ C c;
+ char n[4] = {char(0xF1), char(0x80), char(0x80), char(0x83)};
+ std::mbstate_t m;
+ int r = c.length(m, n, n+4, 2);
+ assert(r == 4);
+
+ n[0] = char(0xE1);
+ n[1] = char(0x80);
+ n[2] = char(0x85);
+ r = c.length(m, n, n+3, 2);
+ assert(r == 3);
+
+ n[0] = char(0xD1);
+ n[1] = char(0x93);
+ r = c.length(m, n, n+2, 2);
+ assert(r == 2);
+
+ n[0] = char(0x56);
+ r = c.length(m, n, n+1, 2);
+ assert(r == 1);
+ }
+ {
+ typedef std::codecvt_utf8_utf16<char16_t, 0x1000> C;
+ C c;
+ char n[4] = {char(0xF1), char(0x80), char(0x80), char(0x83)};
+ std::mbstate_t m;
+ int r = c.length(m, n, n+4, 2);
+ assert(r == 0);
+
+ n[0] = char(0xE1);
+ n[1] = char(0x80);
+ n[2] = char(0x85);
+ r = c.length(m, n, n+3, 2);
+ assert(r == 0);
+
+ n[0] = char(0xD1);
+ n[1] = char(0x93);
+ r = c.length(m, n, n+2, 2);
+ assert(r == 2);
+
+ n[0] = char(0x56);
+ r = c.length(m, n, n+1, 2);
+ assert(r == 1);
+ }
+ {
+ typedef std::codecvt_utf8_utf16<char16_t, 0x10ffff, std::consume_header> C;
+ C c;
+ char n[7] = {char(0xEF), char(0xBB), char(0xBF), char(0xF1), char(0x80), char(0x80), char(0x83)};
+ std::mbstate_t m;
+ int r = c.length(m, n, n+7, 2);
+ assert(r == 7);
+
+ n[0] = char(0xE1);
+ n[1] = char(0x80);
+ n[2] = char(0x85);
+ r = c.length(m, n, n+3, 2);
+ assert(r == 3);
+
+ n[0] = char(0xD1);
+ n[1] = char(0x93);
+ r = c.length(m, n, n+2, 2);
+ assert(r == 2);
+
+ n[0] = char(0x56);
+ r = c.length(m, n, n+1, 2);
+ assert(r == 1);
+ }
+}
diff --git a/test/std/localization/locale.stdcvt/codecvt_utf8_utf16_max_length.pass.cpp b/test/std/localization/locale.stdcvt/codecvt_utf8_utf16_max_length.pass.cpp
new file mode 100644
index 000000000000..ef4d0b82703d
--- /dev/null
+++ b/test/std/localization/locale.stdcvt/codecvt_utf8_utf16_max_length.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <codecvt>
+
+// template <class Elem, unsigned long Maxcode = 0x10ffff,
+// codecvt_mode Mode = (codecvt_mode)0>
+// class codecvt_utf8_utf16
+// : public codecvt<Elem, char, mbstate_t>
+// {
+// // unspecified
+// };
+
+// int max_length() const throw();
+
+#include <codecvt>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::codecvt_utf8_utf16<wchar_t> C;
+ C c;
+ int r = c.max_length();
+ assert(r == 4);
+ }
+ {
+ typedef std::codecvt_utf8_utf16<wchar_t, 0xFFFFFFFF, std::consume_header> C;
+ C c;
+ int r = c.max_length();
+ assert(r == 7);
+ }
+ {
+ typedef std::codecvt_utf8_utf16<char16_t> C;
+ C c;
+ int r = c.max_length();
+ assert(r == 4);
+ }
+ {
+ typedef std::codecvt_utf8_utf16<char16_t, 0xFFFFFFFF, std::consume_header> C;
+ C c;
+ int r = c.max_length();
+ assert(r == 7);
+ }
+ {
+ typedef std::codecvt_utf8_utf16<char32_t> C;
+ C c;
+ int r = c.max_length();
+ assert(r == 4);
+ }
+ {
+ typedef std::codecvt_utf8_utf16<char32_t, 0xFFFFFFFF, std::consume_header> C;
+ C c;
+ int r = c.max_length();
+ assert(r == 7);
+ }
+}
diff --git a/test/std/localization/locale.stdcvt/codecvt_utf8_utf16_out.pass.cpp b/test/std/localization/locale.stdcvt/codecvt_utf8_utf16_out.pass.cpp
new file mode 100644
index 000000000000..29c5342e4545
--- /dev/null
+++ b/test/std/localization/locale.stdcvt/codecvt_utf8_utf16_out.pass.cpp
@@ -0,0 +1,415 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <codecvt>
+
+// template <class Elem, unsigned long Maxcode = 0x10ffff,
+// codecvt_mode Mode = (codecvt_mode)0>
+// class codecvt_utf8_utf16
+// : public codecvt<Elem, char, mbstate_t>
+// {
+// // unspecified
+// };
+
+// result
+// out(stateT& state,
+// const internT* from, const internT* from_end, const internT*& from_next,
+// externT* to, externT* to_end, externT*& to_next) const;
+
+#include <codecvt>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::codecvt_utf8_utf16<wchar_t> C;
+ C c;
+ wchar_t w[2] = {0xD8C0, 0xDC03};
+ char n[4] = {0};
+ const wchar_t* wp = nullptr;
+ std::mbstate_t m;
+ char* np = nullptr;
+ std::codecvt_base::result r = c.out(m, w, w+2, wp, n, n+4, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w+2);
+ assert(np == n+4);
+ assert(n[0] == char(0xF1));
+ assert(n[1] == char(0x80));
+ assert(n[2] == char(0x80));
+ assert(n[3] == char(0x83));
+
+ w[0] = 0x1005;
+ r = c.out(m, w, w+1, wp, n, n+4, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w+1);
+ assert(np == n+3);
+ assert(n[0] == char(0xE1));
+ assert(n[1] == char(0x80));
+ assert(n[2] == char(0x85));
+
+ w[0] = 0x453;
+ r = c.out(m, w, w+1, wp, n, n+4, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w+1);
+ assert(np == n+2);
+ assert(n[0] == char(0xD1));
+ assert(n[1] == char(0x93));
+
+ w[0] = 0x56;
+ r = c.out(m, w, w+1, wp, n, n+4, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w+1);
+ assert(np == n+1);
+ assert(n[0] == char(0x56));
+ }
+ {
+ typedef std::codecvt_utf8_utf16<wchar_t, 0x1000> C;
+ C c;
+ wchar_t w[2] = {0xD8C0, 0xDC03};
+ char n[4] = {0};
+ const wchar_t* wp = nullptr;
+ std::mbstate_t m;
+ char* np = nullptr;
+ std::codecvt_base::result r = c.out(m, w, w+2, wp, n, n+4, np);
+ assert(r == std::codecvt_base::error);
+ assert(wp == w);
+ assert(np == n);
+
+ w[0] = 0x1005;
+ r = c.out(m, w, w+1, wp, n, n+4, np);
+ assert(r == std::codecvt_base::error);
+ assert(wp == w);
+ assert(np == n);
+
+ w[0] = 0x453;
+ r = c.out(m, w, w+1, wp, n, n+4, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w+1);
+ assert(np == n+2);
+ assert(n[0] == char(0xD1));
+ assert(n[1] == char(0x93));
+
+ w[0] = 0x56;
+ r = c.out(m, w, w+1, wp, n, n+4, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w+1);
+ assert(np == n+1);
+ assert(n[0] == char(0x56));
+ }
+ {
+ typedef std::codecvt_utf8_utf16<wchar_t, 0x10ffff, std::generate_header> C;
+ C c;
+ wchar_t w[2] = {0xD8C0, 0xDC03};
+ char n[7] = {0};
+ const wchar_t* wp = nullptr;
+ std::mbstate_t m;
+ char* np = nullptr;
+ std::codecvt_base::result r = c.out(m, w, w+2, wp, n, n+7, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w+2);
+ assert(np == n+7);
+ assert(n[0] == char(0xEF));
+ assert(n[1] == char(0xBB));
+ assert(n[2] == char(0xBF));
+ assert(n[3] == char(0xF1));
+ assert(n[4] == char(0x80));
+ assert(n[5] == char(0x80));
+ assert(n[6] == char(0x83));
+
+ w[0] = 0x1005;
+ r = c.out(m, w, w+1, wp, n, n+7, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w+1);
+ assert(np == n+6);
+ assert(n[0] == char(0xEF));
+ assert(n[1] == char(0xBB));
+ assert(n[2] == char(0xBF));
+ assert(n[3] == char(0xE1));
+ assert(n[4] == char(0x80));
+ assert(n[5] == char(0x85));
+
+ w[0] = 0x453;
+ r = c.out(m, w, w+1, wp, n, n+7, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w+1);
+ assert(np == n+5);
+ assert(n[0] == char(0xEF));
+ assert(n[1] == char(0xBB));
+ assert(n[2] == char(0xBF));
+ assert(n[3] == char(0xD1));
+ assert(n[4] == char(0x93));
+
+ w[0] = 0x56;
+ r = c.out(m, w, w+1, wp, n, n+7, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w+1);
+ assert(np == n+4);
+ assert(n[0] == char(0xEF));
+ assert(n[1] == char(0xBB));
+ assert(n[2] == char(0xBF));
+ assert(n[3] == char(0x56));
+ }
+ {
+ typedef std::codecvt_utf8_utf16<char32_t> C;
+ C c;
+ char32_t w[2] = {0xD8C0, 0xDC03};
+ char n[4] = {0};
+ const char32_t* wp = nullptr;
+ std::mbstate_t m;
+ char* np = nullptr;
+ std::codecvt_base::result r = c.out(m, w, w+2, wp, n, n+4, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w+2);
+ assert(np == n+4);
+ assert(n[0] == char(0xF1));
+ assert(n[1] == char(0x80));
+ assert(n[2] == char(0x80));
+ assert(n[3] == char(0x83));
+
+ w[0] = 0x1005;
+ r = c.out(m, w, w+1, wp, n, n+4, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w+1);
+ assert(np == n+3);
+ assert(n[0] == char(0xE1));
+ assert(n[1] == char(0x80));
+ assert(n[2] == char(0x85));
+
+ w[0] = 0x453;
+ r = c.out(m, w, w+1, wp, n, n+4, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w+1);
+ assert(np == n+2);
+ assert(n[0] == char(0xD1));
+ assert(n[1] == char(0x93));
+
+ w[0] = 0x56;
+ r = c.out(m, w, w+1, wp, n, n+4, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w+1);
+ assert(np == n+1);
+ assert(n[0] == char(0x56));
+ }
+ {
+ typedef std::codecvt_utf8_utf16<char32_t, 0x1000> C;
+ C c;
+ char32_t w[2] = {0xD8C0, 0xDC03};
+ char n[4] = {0};
+ const char32_t* wp = nullptr;
+ std::mbstate_t m;
+ char* np = nullptr;
+ std::codecvt_base::result r = c.out(m, w, w+2, wp, n, n+4, np);
+ assert(r == std::codecvt_base::error);
+ assert(wp == w);
+ assert(np == n);
+
+ w[0] = 0x1005;
+ r = c.out(m, w, w+1, wp, n, n+4, np);
+ assert(r == std::codecvt_base::error);
+ assert(wp == w);
+ assert(np == n);
+
+ w[0] = 0x453;
+ r = c.out(m, w, w+1, wp, n, n+4, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w+1);
+ assert(np == n+2);
+ assert(n[0] == char(0xD1));
+ assert(n[1] == char(0x93));
+
+ w[0] = 0x56;
+ r = c.out(m, w, w+1, wp, n, n+4, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w+1);
+ assert(np == n+1);
+ assert(n[0] == char(0x56));
+ }
+ {
+ typedef std::codecvt_utf8_utf16<char32_t, 0x10ffff, std::generate_header> C;
+ C c;
+ char32_t w[2] = {0xD8C0, 0xDC03};
+ char n[7] = {0};
+ const char32_t* wp = nullptr;
+ std::mbstate_t m;
+ char* np = nullptr;
+ std::codecvt_base::result r = c.out(m, w, w+2, wp, n, n+7, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w+2);
+ assert(np == n+7);
+ assert(n[0] == char(0xEF));
+ assert(n[1] == char(0xBB));
+ assert(n[2] == char(0xBF));
+ assert(n[3] == char(0xF1));
+ assert(n[4] == char(0x80));
+ assert(n[5] == char(0x80));
+ assert(n[6] == char(0x83));
+
+ w[0] = 0x1005;
+ r = c.out(m, w, w+1, wp, n, n+7, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w+1);
+ assert(np == n+6);
+ assert(n[0] == char(0xEF));
+ assert(n[1] == char(0xBB));
+ assert(n[2] == char(0xBF));
+ assert(n[3] == char(0xE1));
+ assert(n[4] == char(0x80));
+ assert(n[5] == char(0x85));
+
+ w[0] = 0x453;
+ r = c.out(m, w, w+1, wp, n, n+7, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w+1);
+ assert(np == n+5);
+ assert(n[0] == char(0xEF));
+ assert(n[1] == char(0xBB));
+ assert(n[2] == char(0xBF));
+ assert(n[3] == char(0xD1));
+ assert(n[4] == char(0x93));
+
+ w[0] = 0x56;
+ r = c.out(m, w, w+1, wp, n, n+7, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w+1);
+ assert(np == n+4);
+ assert(n[0] == char(0xEF));
+ assert(n[1] == char(0xBB));
+ assert(n[2] == char(0xBF));
+ assert(n[3] == char(0x56));
+ }
+
+ {
+ typedef std::codecvt_utf8_utf16<char16_t> C;
+ C c;
+ char16_t w[2] = {0xD8C0, 0xDC03};
+ char n[4] = {0};
+ const char16_t* wp = nullptr;
+ std::mbstate_t m;
+ char* np = nullptr;
+ std::codecvt_base::result r = c.out(m, w, w+2, wp, n, n+4, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w+2);
+ assert(np == n+4);
+ assert(n[0] == char(0xF1));
+ assert(n[1] == char(0x80));
+ assert(n[2] == char(0x80));
+ assert(n[3] == char(0x83));
+
+ w[0] = 0x1005;
+ r = c.out(m, w, w+1, wp, n, n+4, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w+1);
+ assert(np == n+3);
+ assert(n[0] == char(0xE1));
+ assert(n[1] == char(0x80));
+ assert(n[2] == char(0x85));
+
+ w[0] = 0x453;
+ r = c.out(m, w, w+1, wp, n, n+4, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w+1);
+ assert(np == n+2);
+ assert(n[0] == char(0xD1));
+ assert(n[1] == char(0x93));
+
+ w[0] = 0x56;
+ r = c.out(m, w, w+1, wp, n, n+4, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w+1);
+ assert(np == n+1);
+ assert(n[0] == char(0x56));
+ }
+ {
+ typedef std::codecvt_utf8_utf16<char16_t, 0x1000> C;
+ C c;
+ char16_t w[2] = {0xD8C0, 0xDC03};
+ char n[4] = {0};
+ const char16_t* wp = nullptr;
+ std::mbstate_t m;
+ char* np = nullptr;
+ std::codecvt_base::result r = c.out(m, w, w+2, wp, n, n+4, np);
+ assert(r == std::codecvt_base::error);
+ assert(wp == w);
+ assert(np == n);
+
+ w[0] = 0x1005;
+ r = c.out(m, w, w+1, wp, n, n+4, np);
+ assert(r == std::codecvt_base::error);
+ assert(wp == w);
+ assert(np == n);
+
+ w[0] = 0x453;
+ r = c.out(m, w, w+1, wp, n, n+4, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w+1);
+ assert(np == n+2);
+ assert(n[0] == char(0xD1));
+ assert(n[1] == char(0x93));
+
+ w[0] = 0x56;
+ r = c.out(m, w, w+1, wp, n, n+4, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w+1);
+ assert(np == n+1);
+ assert(n[0] == char(0x56));
+ }
+ {
+ typedef std::codecvt_utf8_utf16<char16_t, 0x10ffff, std::generate_header> C;
+ C c;
+ char16_t w[2] = {0xD8C0, 0xDC03};
+ char n[7] = {0};
+ const char16_t* wp = nullptr;
+ std::mbstate_t m;
+ char* np = nullptr;
+ std::codecvt_base::result r = c.out(m, w, w+2, wp, n, n+7, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w+2);
+ assert(np == n+7);
+ assert(n[0] == char(0xEF));
+ assert(n[1] == char(0xBB));
+ assert(n[2] == char(0xBF));
+ assert(n[3] == char(0xF1));
+ assert(n[4] == char(0x80));
+ assert(n[5] == char(0x80));
+ assert(n[6] == char(0x83));
+
+ w[0] = 0x1005;
+ r = c.out(m, w, w+1, wp, n, n+7, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w+1);
+ assert(np == n+6);
+ assert(n[0] == char(0xEF));
+ assert(n[1] == char(0xBB));
+ assert(n[2] == char(0xBF));
+ assert(n[3] == char(0xE1));
+ assert(n[4] == char(0x80));
+ assert(n[5] == char(0x85));
+
+ w[0] = 0x453;
+ r = c.out(m, w, w+1, wp, n, n+7, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w+1);
+ assert(np == n+5);
+ assert(n[0] == char(0xEF));
+ assert(n[1] == char(0xBB));
+ assert(n[2] == char(0xBF));
+ assert(n[3] == char(0xD1));
+ assert(n[4] == char(0x93));
+
+ w[0] = 0x56;
+ r = c.out(m, w, w+1, wp, n, n+7, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w+1);
+ assert(np == n+4);
+ assert(n[0] == char(0xEF));
+ assert(n[1] == char(0xBB));
+ assert(n[2] == char(0xBF));
+ assert(n[3] == char(0x56));
+ }
+}
diff --git a/test/std/localization/locale.stdcvt/codecvt_utf8_utf16_unshift.pass.cpp b/test/std/localization/locale.stdcvt/codecvt_utf8_utf16_unshift.pass.cpp
new file mode 100644
index 000000000000..2bcade01f4fc
--- /dev/null
+++ b/test/std/localization/locale.stdcvt/codecvt_utf8_utf16_unshift.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <codecvt>
+
+// template <class Elem, unsigned long Maxcode = 0x10ffff,
+// codecvt_mode Mode = (codecvt_mode)0>
+// class codecvt_utf8_utf16
+// : public codecvt<Elem, char, mbstate_t>
+// {
+// // unspecified
+// };
+
+// result
+// unshift(stateT& state,
+// externT* to, externT* to_end, externT*& to_next) const;
+
+#include <codecvt>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::codecvt_utf8_utf16<wchar_t> C;
+ C c;
+ char n[4] = {0};
+ std::mbstate_t m;
+ char* np = nullptr;
+ std::codecvt_base::result r = c.unshift(m, n, n+4, np);
+ assert(r == std::codecvt_base::noconv);
+ }
+ {
+ typedef std::codecvt_utf8_utf16<char16_t> C;
+ C c;
+ char n[4] = {0};
+ std::mbstate_t m;
+ char* np = nullptr;
+ std::codecvt_base::result r = c.unshift(m, n, n+4, np);
+ assert(r == std::codecvt_base::noconv);
+ }
+ {
+ typedef std::codecvt_utf8_utf16<char32_t> C;
+ C c;
+ char n[4] = {0};
+ std::mbstate_t m;
+ char* np = nullptr;
+ std::codecvt_base::result r = c.unshift(m, n, n+4, np);
+ assert(r == std::codecvt_base::noconv);
+ }
+}
diff --git a/test/std/localization/locale.stdcvt/version.pass.cpp b/test/std/localization/locale.stdcvt/version.pass.cpp
new file mode 100644
index 000000000000..3885380854cc
--- /dev/null
+++ b/test/std/localization/locale.stdcvt/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <codecvt>
+
+#include <codecvt>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/localization/locale.syn/nothing_to_do.pass.cpp b/test/std/localization/locale.syn/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/localization/locale.syn/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/localization/locales/locale.convenience/classification/isalnum.pass.cpp b/test/std/localization/locales/locale.convenience/classification/isalnum.pass.cpp
new file mode 100644
index 000000000000..376b33460383
--- /dev/null
+++ b/test/std/localization/locales/locale.convenience/classification/isalnum.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> bool isalnum (charT c, const locale& loc);
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+ std::locale l;
+ assert(!std::isalnum(' ', l));
+ assert(!std::isalnum('<', l));
+ assert(!std::isalnum('\x8', l));
+ assert( std::isalnum('A', l));
+ assert( std::isalnum('a', l));
+ assert( std::isalnum('z', l));
+ assert( std::isalnum('3', l));
+ assert(!std::isalnum('.', l));
+ assert( std::isalnum('f', l));
+ assert( std::isalnum('9', l));
+ assert(!std::isalnum('+', l));
+}
diff --git a/test/std/localization/locales/locale.convenience/classification/isalpha.pass.cpp b/test/std/localization/locales/locale.convenience/classification/isalpha.pass.cpp
new file mode 100644
index 000000000000..d1a0e6912277
--- /dev/null
+++ b/test/std/localization/locales/locale.convenience/classification/isalpha.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> bool isalpha (charT c, const locale& loc);
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+ std::locale l;
+ assert(!std::isalpha(' ', l));
+ assert(!std::isalpha('<', l));
+ assert(!std::isalpha('\x8', l));
+ assert( std::isalpha('A', l));
+ assert( std::isalpha('a', l));
+ assert( std::isalpha('z', l));
+ assert(!std::isalpha('3', l));
+ assert(!std::isalpha('.', l));
+ assert( std::isalpha('f', l));
+ assert(!std::isalpha('9', l));
+ assert(!std::isalpha('+', l));
+}
diff --git a/test/std/localization/locales/locale.convenience/classification/iscntrl.pass.cpp b/test/std/localization/locales/locale.convenience/classification/iscntrl.pass.cpp
new file mode 100644
index 000000000000..0bd45ac6bc4a
--- /dev/null
+++ b/test/std/localization/locales/locale.convenience/classification/iscntrl.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> bool iscntrl (charT c, const locale& loc);
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+ std::locale l;
+ assert(!std::iscntrl(' ', l));
+ assert(!std::iscntrl('<', l));
+ assert( std::iscntrl('\x8', l));
+ assert(!std::iscntrl('A', l));
+ assert(!std::iscntrl('a', l));
+ assert(!std::iscntrl('z', l));
+ assert(!std::iscntrl('3', l));
+ assert(!std::iscntrl('.', l));
+ assert(!std::iscntrl('f', l));
+ assert(!std::iscntrl('9', l));
+ assert(!std::iscntrl('+', l));
+}
diff --git a/test/std/localization/locales/locale.convenience/classification/isdigit.pass.cpp b/test/std/localization/locales/locale.convenience/classification/isdigit.pass.cpp
new file mode 100644
index 000000000000..bdc063286fcd
--- /dev/null
+++ b/test/std/localization/locales/locale.convenience/classification/isdigit.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> bool isdigit (charT c, const locale& loc);
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+ std::locale l;
+ assert(!std::isdigit(' ', l));
+ assert(!std::isdigit('<', l));
+ assert(!std::isdigit('\x8', l));
+ assert(!std::isdigit('A', l));
+ assert(!std::isdigit('a', l));
+ assert(!std::isdigit('z', l));
+ assert( std::isdigit('3', l));
+ assert(!std::isdigit('.', l));
+ assert(!std::isdigit('f', l));
+ assert( std::isdigit('9', l));
+ assert(!std::isdigit('+', l));
+}
diff --git a/test/std/localization/locales/locale.convenience/classification/isgraph.pass.cpp b/test/std/localization/locales/locale.convenience/classification/isgraph.pass.cpp
new file mode 100644
index 000000000000..b294aa537aa4
--- /dev/null
+++ b/test/std/localization/locales/locale.convenience/classification/isgraph.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> bool isgraph (charT c, const locale& loc);
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+ std::locale l;
+ assert(!std::isgraph(' ', l));
+ assert( std::isgraph('<', l));
+ assert(!std::isgraph('\x8', l));
+ assert( std::isgraph('A', l));
+ assert( std::isgraph('a', l));
+ assert( std::isgraph('z', l));
+ assert( std::isgraph('3', l));
+ assert( std::isgraph('.', l));
+ assert( std::isgraph('f', l));
+ assert( std::isgraph('9', l));
+ assert( std::isgraph('+', l));
+}
diff --git a/test/std/localization/locales/locale.convenience/classification/islower.pass.cpp b/test/std/localization/locales/locale.convenience/classification/islower.pass.cpp
new file mode 100644
index 000000000000..e131e50b37dc
--- /dev/null
+++ b/test/std/localization/locales/locale.convenience/classification/islower.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> bool islower (charT c, const locale& loc);
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+ std::locale l;
+ assert(!std::islower(' ', l));
+ assert(!std::islower('<', l));
+ assert(!std::islower('\x8', l));
+ assert(!std::islower('A', l));
+ assert( std::islower('a', l));
+ assert( std::islower('z', l));
+ assert(!std::islower('3', l));
+ assert(!std::islower('.', l));
+ assert( std::islower('f', l));
+ assert(!std::islower('9', l));
+ assert(!std::islower('+', l));
+}
diff --git a/test/std/localization/locales/locale.convenience/classification/isprint.pass.cpp b/test/std/localization/locales/locale.convenience/classification/isprint.pass.cpp
new file mode 100644
index 000000000000..a8c39fae9831
--- /dev/null
+++ b/test/std/localization/locales/locale.convenience/classification/isprint.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> bool isprint (charT c, const locale& loc);
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+ std::locale l;
+ assert( std::isprint(' ', l));
+ assert( std::isprint('<', l));
+ assert(!std::isprint('\x8', l));
+ assert( std::isprint('A', l));
+ assert( std::isprint('a', l));
+ assert( std::isprint('z', l));
+ assert( std::isprint('3', l));
+ assert( std::isprint('.', l));
+ assert( std::isprint('f', l));
+ assert( std::isprint('9', l));
+ assert( std::isprint('+', l));
+}
diff --git a/test/std/localization/locales/locale.convenience/classification/ispunct.pass.cpp b/test/std/localization/locales/locale.convenience/classification/ispunct.pass.cpp
new file mode 100644
index 000000000000..b606d3262be1
--- /dev/null
+++ b/test/std/localization/locales/locale.convenience/classification/ispunct.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> bool ispunct (charT c, const locale& loc);
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+ std::locale l;
+ assert(!std::ispunct(' ', l));
+ assert( std::ispunct('<', l));
+ assert(!std::ispunct('\x8', l));
+ assert(!std::ispunct('A', l));
+ assert(!std::ispunct('a', l));
+ assert(!std::ispunct('z', l));
+ assert(!std::ispunct('3', l));
+ assert( std::ispunct('.', l));
+ assert(!std::ispunct('f', l));
+ assert(!std::ispunct('9', l));
+ assert( std::ispunct('+', l));
+}
diff --git a/test/std/localization/locales/locale.convenience/classification/isspace.pass.cpp b/test/std/localization/locales/locale.convenience/classification/isspace.pass.cpp
new file mode 100644
index 000000000000..884b30338b9f
--- /dev/null
+++ b/test/std/localization/locales/locale.convenience/classification/isspace.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> bool isspace (charT c, const locale& loc);
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+ std::locale l;
+ assert( std::isspace(' ', l));
+ assert(!std::isspace('<', l));
+ assert(!std::isspace('\x8', l));
+ assert(!std::isspace('A', l));
+ assert(!std::isspace('a', l));
+ assert(!std::isspace('z', l));
+ assert(!std::isspace('3', l));
+ assert(!std::isspace('.', l));
+ assert(!std::isspace('f', l));
+ assert(!std::isspace('9', l));
+ assert(!std::isspace('+', l));
+}
diff --git a/test/std/localization/locales/locale.convenience/classification/isupper.pass.cpp b/test/std/localization/locales/locale.convenience/classification/isupper.pass.cpp
new file mode 100644
index 000000000000..8ce51bc70f3b
--- /dev/null
+++ b/test/std/localization/locales/locale.convenience/classification/isupper.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> bool isupper (charT c, const locale& loc);
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+ std::locale l;
+ assert(!std::isupper(' ', l));
+ assert(!std::isupper('<', l));
+ assert(!std::isupper('\x8', l));
+ assert( std::isupper('A', l));
+ assert(!std::isupper('a', l));
+ assert(!std::isupper('z', l));
+ assert(!std::isupper('3', l));
+ assert(!std::isupper('.', l));
+ assert(!std::isupper('f', l));
+ assert(!std::isupper('9', l));
+ assert(!std::isupper('+', l));
+}
diff --git a/test/std/localization/locales/locale.convenience/classification/isxdigit.pass.cpp b/test/std/localization/locales/locale.convenience/classification/isxdigit.pass.cpp
new file mode 100644
index 000000000000..34076955726c
--- /dev/null
+++ b/test/std/localization/locales/locale.convenience/classification/isxdigit.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> bool isxdigit (charT c, const locale& loc);
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+ std::locale l;
+ assert(!std::isxdigit(' ', l));
+ assert(!std::isxdigit('<', l));
+ assert(!std::isxdigit('\x8', l));
+ assert( std::isxdigit('A', l));
+ assert( std::isxdigit('a', l));
+ assert(!std::isxdigit('z', l));
+ assert( std::isxdigit('3', l));
+ assert(!std::isxdigit('.', l));
+ assert( std::isxdigit('f', l));
+ assert( std::isxdigit('9', l));
+ assert(!std::isxdigit('+', l));
+}
diff --git a/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/ctor.pass.cpp b/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/ctor.pass.cpp
new file mode 100644
index 000000000000..5f57df12f022
--- /dev/null
+++ b/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/ctor.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// wbuffer_convert<Codecvt, Elem, Tr>
+
+// wbuffer_convert(streambuf *bytebuf = 0, Codecvt *pcvt = new Codecvt,
+// state_type state = state_type());
+
+#include <locale>
+#include <codecvt>
+#include <sstream>
+#include <cassert>
+
+#include "count_new.hpp"
+
+int main()
+{
+ typedef std::wbuffer_convert<std::codecvt_utf8<wchar_t> > B;
+#if _LIBCPP_STD_VER > 11
+ static_assert(!std::is_convertible<std::streambuf*, B>::value, "");
+ static_assert( std::is_constructible<B, std::streambuf*>::value, "");
+#endif
+ {
+ B b;
+ assert(b.rdbuf() == nullptr);
+ assert(globalMemCounter.checkOutstandingNewNotEq(0));
+ }
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ {
+ std::stringstream s;
+ B b(s.rdbuf());
+ assert(b.rdbuf() == s.rdbuf());
+ assert(globalMemCounter.checkOutstandingNewNotEq(0));
+ }
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ {
+ std::stringstream s;
+ B b(s.rdbuf(), new std::codecvt_utf8<wchar_t>);
+ assert(b.rdbuf() == s.rdbuf());
+ assert(globalMemCounter.checkOutstandingNewNotEq(0));
+ }
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ {
+ std::stringstream s;
+ B b(s.rdbuf(), new std::codecvt_utf8<wchar_t>, std::mbstate_t());
+ assert(b.rdbuf() == s.rdbuf());
+ assert(globalMemCounter.checkOutstandingNewNotEq(0));
+ }
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+}
diff --git a/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/lit.local.cfg b/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/lit.local.cfg
new file mode 100644
index 000000000000..25ac02ba7c66
--- /dev/null
+++ b/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/lit.local.cfg
@@ -0,0 +1,2 @@
+if 'libcpp-has-no-global-filesystem-namespace' in config.available_features:
+ config.unsupported = True
diff --git a/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/overflow.pass.cpp b/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/overflow.pass.cpp
new file mode 100644
index 000000000000..24706b5a8e0a
--- /dev/null
+++ b/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/overflow.pass.cpp
@@ -0,0 +1,100 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// wbuffer_convert<Codecvt, Elem, Tr>
+
+// int_type overflow(int_type c = traits::eof());
+
+// This test is not entirely portable
+
+#include <locale>
+#include <codecvt>
+#include <fstream>
+#include <cassert>
+
+struct test_buf
+ : public std::wbuffer_convert<std::codecvt_utf8<wchar_t> >
+{
+ typedef std::wbuffer_convert<std::codecvt_utf8<wchar_t> > base;
+ typedef base::char_type char_type;
+ typedef base::int_type int_type;
+ typedef base::traits_type traits_type;
+
+ explicit test_buf(std::streambuf* sb) : base(sb) {}
+
+ char_type* pbase() const {return base::pbase();}
+ char_type* pptr() const {return base::pptr();}
+ char_type* epptr() const {return base::epptr();}
+ void gbump(int n) {base::gbump(n);}
+
+ virtual int_type overflow(int_type c = traits_type::eof()) {return base::overflow(c);}
+};
+
+int main()
+{
+ {
+ std::ofstream bs("overflow.dat");
+ test_buf f(bs.rdbuf());
+ assert(f.pbase() == 0);
+ assert(f.pptr() == 0);
+ assert(f.epptr() == 0);
+ assert(f.overflow(L'a') == L'a');
+ assert(f.pbase() != 0);
+ assert(f.pptr() == f.pbase());
+ assert(f.epptr() - f.pbase() == 4095);
+ }
+ {
+ std::ifstream bs("overflow.dat");
+ test_buf f(bs.rdbuf());
+ assert(f.sgetc() == L'a');
+ }
+ std::remove("overflow.dat");
+ {
+ std::ofstream bs("overflow.dat");
+ test_buf f(bs.rdbuf());
+ f.pubsetbuf(0, 0);
+ assert(f.pbase() == 0);
+ assert(f.pptr() == 0);
+ assert(f.epptr() == 0);
+ assert(f.overflow('a') == 'a');
+ assert(f.pbase() == 0);
+ assert(f.pptr() == 0);
+ assert(f.epptr() == 0);
+ }
+ {
+ std::ifstream bs("overflow.dat");
+ test_buf f(bs.rdbuf());
+ assert(f.sgetc() == L'a');
+ }
+ std::remove("overflow.dat");
+ {
+ std::ofstream bs("overflow.dat");
+ test_buf f(bs.rdbuf());
+ assert(f.sputc(0x4E51) == 0x4E51);
+ assert(f.sputc(0x4E52) == 0x4E52);
+ assert(f.sputc(0x4E53) == 0x4E53);
+ }
+ {
+ std::ifstream f("overflow.dat");
+ assert(f.is_open());
+ assert(f.get() == 0xE4);
+ assert(f.get() == 0xB9);
+ assert(f.get() == 0x91);
+ assert(f.get() == 0xE4);
+ assert(f.get() == 0xB9);
+ assert(f.get() == 0x92);
+ assert(f.get() == 0xE4);
+ assert(f.get() == 0xB9);
+ assert(f.get() == 0x93);
+ assert(f.get() == -1);
+ }
+ std::remove("overflow.dat");
+}
diff --git a/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/pbackfail.pass.cpp b/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/pbackfail.pass.cpp
new file mode 100644
index 000000000000..bcfb16e050ea
--- /dev/null
+++ b/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/pbackfail.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// wbuffer_convert<Codecvt, Elem, Tr>
+
+// int_type pbackfail(int_type c = traits::eof());
+
+// This test is not entirely portable
+
+#include <locale>
+#include <codecvt>
+#include <fstream>
+#include <cassert>
+
+struct test_buf
+ : public std::wbuffer_convert<std::codecvt_utf8<wchar_t> >
+{
+ typedef std::wbuffer_convert<std::codecvt_utf8<wchar_t> > base;
+ typedef base::char_type char_type;
+ typedef base::int_type int_type;
+ typedef base::traits_type traits_type;
+
+ explicit test_buf(std::streambuf* sb) : base(sb) {}
+
+ char_type* eback() const {return base::eback();}
+ char_type* gptr() const {return base::gptr();}
+ char_type* egptr() const {return base::egptr();}
+ void gbump(int n) {base::gbump(n);}
+
+ virtual int_type pbackfail(int_type c = traits_type::eof()) {return base::pbackfail(c);}
+};
+
+int main()
+{
+ {
+ std::ifstream bs("underflow.dat");
+ test_buf f(bs.rdbuf());
+ assert(f.sbumpc() == L'1');
+ assert(f.sgetc() == L'2');
+ assert(f.pbackfail(L'a') == test_buf::traits_type::eof());
+ }
+ {
+ std::fstream bs("underflow.dat");
+ test_buf f(bs.rdbuf());
+ assert(f.sbumpc() == L'1');
+ assert(f.sgetc() == L'2');
+ assert(f.pbackfail(L'a') == test_buf::traits_type::eof());
+ assert(f.sbumpc() == L'2');
+ assert(f.sgetc() == L'3');
+ }
+}
diff --git a/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/rdbuf.pass.cpp b/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/rdbuf.pass.cpp
new file mode 100644
index 000000000000..ffd813f86fe7
--- /dev/null
+++ b/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/rdbuf.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// wbuffer_convert<Codecvt, Elem, Tr>
+
+// streambuf *rdbuf(streambuf *bytebuf);
+
+#include <locale>
+#include <codecvt>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ typedef std::wbuffer_convert<std::codecvt_utf8<wchar_t> > B;
+ {
+ std::stringstream s;
+ B b;
+ assert(b.rdbuf() == nullptr);
+ b.rdbuf(s.rdbuf());
+ assert(b.rdbuf() == s.rdbuf());
+ }
+}
diff --git a/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/seekoff.pass.cpp b/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/seekoff.pass.cpp
new file mode 100644
index 000000000000..aa9d5e8a95e7
--- /dev/null
+++ b/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/seekoff.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// wbuffer_convert<Codecvt, Elem, Tr>
+
+// pos_type seekoff(off_type off, ios_base::seekdir way,
+// ios_base::openmode which = ios_base::in | ios_base::out);
+// pos_type seekpos(pos_type sp,
+// ios_base::openmode which = ios_base::in | ios_base::out);
+
+// This test is not entirely portable
+
+#include <locale>
+#include <codecvt>
+#include <fstream>
+#include <cassert>
+
+class test_codecvt
+ : public std::codecvt<wchar_t, char, std::mbstate_t>
+{
+ typedef std::codecvt<wchar_t, char, std::mbstate_t> base;
+public:
+ explicit test_codecvt(std::size_t refs = 0) : base(refs) {}
+ ~test_codecvt() {}
+};
+
+int main()
+{
+ {
+ wchar_t buf[10];
+ typedef std::wbuffer_convert<test_codecvt> test_buf;
+ typedef test_buf::pos_type pos_type;
+ std::fstream bs("seekoff.dat", std::ios::trunc | std::ios::in
+ | std::ios::out);
+ test_buf f(bs.rdbuf());
+ f.pubsetbuf(buf, sizeof(buf)/sizeof(buf[0]));
+ f.sputn(L"abcdefghijklmnopqrstuvwxyz", 26);
+ assert(buf[0] == L'v');
+ pos_type p = f.pubseekoff(-15, std::ios_base::cur);
+ assert(p == 11);
+ assert(f.sgetc() == L'l');
+ f.pubseekoff(0, std::ios_base::beg);
+ assert(f.sgetc() == L'a');
+ f.pubseekoff(-1, std::ios_base::end);
+ assert(f.sgetc() == L'z');
+ assert(f.pubseekpos(p) == p);
+ assert(f.sgetc() == L'l');
+ }
+ std::remove("seekoff.dat");
+}
diff --git a/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/state.pass.cpp b/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/state.pass.cpp
new file mode 100644
index 000000000000..6abf5cee328e
--- /dev/null
+++ b/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/state.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// wbuffer_convert<Codecvt, Elem, Tr>
+
+// state_type state() const;
+
+#include <locale>
+#include <codecvt>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ typedef std::wbuffer_convert<std::codecvt_utf8<wchar_t> > B;
+ {
+ B b;
+ std::mbstate_t s = b.state();
+ }
+}
diff --git a/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/test.pass.cpp b/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/test.pass.cpp
new file mode 100644
index 000000000000..189ec2bddc13
--- /dev/null
+++ b/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/test.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// wbuffer_convert<Codecvt, Elem, Tr>
+
+#include <fstream>
+#include <locale>
+#include <codecvt>
+#include <cassert>
+
+int main()
+{
+ {
+ std::ofstream bytestream("myfile.txt");
+ std::wbuffer_convert<std::codecvt_utf8<wchar_t> > mybuf(bytestream.rdbuf());
+ std::wostream mystr(&mybuf);
+ mystr << L"Hello" << std::endl;
+ }
+ {
+ std::ifstream bytestream("myfile.txt");
+ std::wbuffer_convert<std::codecvt_utf8<wchar_t> > mybuf(bytestream.rdbuf());
+ std::wistream mystr(&mybuf);
+ std::wstring ws;
+ mystr >> ws;
+ assert(ws == L"Hello");
+ }
+ std::remove("myfile.txt");
+}
diff --git a/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/underflow.dat b/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/underflow.dat
new file mode 100644
index 000000000000..e2e107ac61ac
--- /dev/null
+++ b/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/underflow.dat
@@ -0,0 +1 @@
+123456789 \ No newline at end of file
diff --git a/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/underflow.pass.cpp b/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/underflow.pass.cpp
new file mode 100644
index 000000000000..9c08a353fbde
--- /dev/null
+++ b/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/underflow.pass.cpp
@@ -0,0 +1,84 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// wbuffer_convert<Codecvt, Elem, Tr>
+
+// int_type underflow();
+
+// This test is not entirely portable
+
+#include <locale>
+#include <codecvt>
+#include <fstream>
+#include <cassert>
+
+struct test_buf
+ : public std::wbuffer_convert<std::codecvt_utf8<wchar_t> >
+{
+ typedef std::wbuffer_convert<std::codecvt_utf8<wchar_t> > base;
+ typedef base::char_type char_type;
+ typedef base::int_type int_type;
+ typedef base::traits_type traits_type;
+
+ explicit test_buf(std::streambuf* sb) : base(sb) {}
+
+ char_type* eback() const {return base::eback();}
+ char_type* gptr() const {return base::gptr();}
+ char_type* egptr() const {return base::egptr();}
+ void gbump(int n) {base::gbump(n);}
+
+ virtual int_type underflow() {return base::underflow();}
+};
+
+int main()
+{
+ {
+ std::ifstream bs("underflow.dat");
+ test_buf f(bs.rdbuf());
+ assert(f.eback() == 0);
+ assert(f.gptr() == 0);
+ assert(f.egptr() == 0);
+ assert(f.underflow() == L'1');
+ assert(f.eback() != 0);
+ assert(f.eback() == f.gptr());
+ assert(*f.gptr() == L'1');
+ assert(f.egptr() - f.eback() == 9);
+ }
+ {
+ std::ifstream bs("underflow.dat");
+ test_buf f(bs.rdbuf());
+ assert(f.eback() == 0);
+ assert(f.gptr() == 0);
+ assert(f.egptr() == 0);
+ assert(f.underflow() == L'1');
+ assert(f.eback() != 0);
+ assert(f.eback() == f.gptr());
+ assert(*f.gptr() == L'1');
+ assert(f.egptr() - f.eback() == 9);
+ f.gbump(8);
+ assert(f.sgetc() == L'9');
+ assert(f.eback()[0] == L'1');
+ assert(f.eback()[1] == L'2');
+ assert(f.eback()[2] == L'3');
+ assert(f.eback()[3] == L'4');
+ assert(f.gptr() - f.eback() == 8);
+ assert(*f.gptr() == L'9');
+ assert(f.egptr() - f.gptr() == 1);
+ }
+ {
+ std::ifstream bs("underflow_utf8.dat");
+ test_buf f(bs.rdbuf());
+ assert(f.sbumpc() == 0x4E51);
+ assert(f.sbumpc() == 0x4E52);
+ assert(f.sbumpc() == 0x4E53);
+ assert(f.sbumpc() == test_buf::traits_type::eof());
+ }
+}
diff --git a/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/underflow_utf8.dat b/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/underflow_utf8.dat
new file mode 100644
index 000000000000..ee7063e1207c
--- /dev/null
+++ b/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/underflow_utf8.dat
@@ -0,0 +1 @@
+乑乒乓 \ No newline at end of file
diff --git a/test/std/localization/locales/locale.convenience/conversions/conversions.character/tolower.pass.cpp b/test/std/localization/locales/locale.convenience/conversions/conversions.character/tolower.pass.cpp
new file mode 100644
index 000000000000..8c66ad14191e
--- /dev/null
+++ b/test/std/localization/locales/locale.convenience/conversions/conversions.character/tolower.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> charT tolower(charT c, const locale& loc);
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+ std::locale l;
+ assert(std::tolower(' ', l) == ' ');
+ assert(std::tolower('<', l) == '<');
+ assert(std::tolower('\x8', l) == '\x8');
+ assert(std::tolower('A', l) == 'a');
+ assert(std::tolower('a', l) == 'a');
+ assert(std::tolower('z', l) == 'z');
+ assert(std::tolower('3', l) == '3');
+ assert(std::tolower('.', l) == '.');
+ assert(std::tolower('f', l) == 'f');
+ assert(std::tolower('9', l) == '9');
+ assert(std::tolower('+', l) == '+');
+}
diff --git a/test/std/localization/locales/locale.convenience/conversions/conversions.character/toupper.pass.cpp b/test/std/localization/locales/locale.convenience/conversions/conversions.character/toupper.pass.cpp
new file mode 100644
index 000000000000..3299a3d00b2b
--- /dev/null
+++ b/test/std/localization/locales/locale.convenience/conversions/conversions.character/toupper.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> charT toupper(charT c, const locale& loc);
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+ std::locale l;
+ assert(std::toupper(' ', l) == ' ');
+ assert(std::toupper('<', l) == '<');
+ assert(std::toupper('\x8', l) == '\x8');
+ assert(std::toupper('A', l) == 'A');
+ assert(std::toupper('a', l) == 'A');
+ assert(std::toupper('z', l) == 'Z');
+ assert(std::toupper('3', l) == '3');
+ assert(std::toupper('.', l) == '.');
+ assert(std::toupper('f', l) == 'F');
+ assert(std::toupper('9', l) == '9');
+ assert(std::toupper('+', l) == '+');
+}
diff --git a/test/std/localization/locales/locale.convenience/conversions/conversions.string/converted.pass.cpp b/test/std/localization/locales/locale.convenience/conversions/conversions.string/converted.pass.cpp
new file mode 100644
index 000000000000..06df185757d2
--- /dev/null
+++ b/test/std/localization/locales/locale.convenience/conversions/conversions.string/converted.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// wstring_convert<Codecvt, Elem, Wide_alloc, Byte_alloc>
+
+// size_t converted() const;
+
+#include <locale>
+#include <codecvt>
+#include <cassert>
+
+int main()
+{
+ typedef std::codecvt_utf8<wchar_t> Codecvt;
+ typedef std::wstring_convert<Codecvt> Myconv;
+ Myconv myconv;
+ assert(myconv.converted() == 0);
+ std::string bs = myconv.to_bytes(L"\x40003");
+ assert(myconv.converted() == 1);
+ bs = myconv.to_bytes(L"\x40003\x65");
+ assert(myconv.converted() == 2);
+ std::wstring ws = myconv.from_bytes("\xF1\x80\x80\x83");
+ assert(myconv.converted() == 4);
+}
diff --git a/test/std/localization/locales/locale.convenience/conversions/conversions.string/ctor_codecvt.pass.cpp b/test/std/localization/locales/locale.convenience/conversions/conversions.string/ctor_codecvt.pass.cpp
new file mode 100644
index 000000000000..9099b5e38fcc
--- /dev/null
+++ b/test/std/localization/locales/locale.convenience/conversions/conversions.string/ctor_codecvt.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// wstring_convert<Codecvt, Elem, Wide_alloc, Byte_alloc>
+
+// wstring_convert(Codecvt* pcvt = new Codecvt);
+
+#include <locale>
+#include <codecvt>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::codecvt_utf8<wchar_t> Codecvt;
+ typedef std::wstring_convert<Codecvt> Myconv;
+ Myconv myconv;
+ assert(myconv.converted() == 0);
+ }
+ {
+ typedef std::codecvt_utf8<wchar_t> Codecvt;
+ typedef std::wstring_convert<Codecvt> Myconv;
+ Myconv myconv(new Codecvt);
+ assert(myconv.converted() == 0);
+#if _LIBCPP_STD_VER > 11
+ static_assert(!std::is_convertible<Codecvt*, Myconv>::value, "");
+ static_assert( std::is_constructible<Myconv, Codecvt*>::value, "");
+#endif
+ }
+}
diff --git a/test/std/localization/locales/locale.convenience/conversions/conversions.string/ctor_codecvt_state.pass.cpp b/test/std/localization/locales/locale.convenience/conversions/conversions.string/ctor_codecvt_state.pass.cpp
new file mode 100644
index 000000000000..7651f8ac3b37
--- /dev/null
+++ b/test/std/localization/locales/locale.convenience/conversions/conversions.string/ctor_codecvt_state.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// wstring_convert<Codecvt, Elem, Wide_alloc, Byte_alloc>
+
+// wstring_convert(Codecvt* pcvt, state_type state);
+
+#include <locale>
+#include <codecvt>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::codecvt_utf8<wchar_t> Codecvt;
+ typedef std::wstring_convert<Codecvt> Myconv;
+ Myconv myconv(new Codecvt, std::mbstate_t());
+ assert(myconv.converted() == 0);
+ }
+}
diff --git a/test/std/localization/locales/locale.convenience/conversions/conversions.string/ctor_err_string.pass.cpp b/test/std/localization/locales/locale.convenience/conversions/conversions.string/ctor_err_string.pass.cpp
new file mode 100644
index 000000000000..27a3da76270f
--- /dev/null
+++ b/test/std/localization/locales/locale.convenience/conversions/conversions.string/ctor_err_string.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// wstring_convert<Codecvt, Elem, Wide_alloc, Byte_alloc>
+
+// wstring_convert(const byte_string& byte_err,
+// const wide_string& wide_err = wide_string());
+
+#include <locale>
+#include <codecvt>
+#include <cassert>
+
+int main()
+{
+ typedef std::codecvt_utf8<wchar_t> Codecvt;
+ typedef std::wstring_convert<Codecvt> Myconv;
+#if _LIBCPP_STD_VER > 11
+ static_assert(!std::is_convertible<std::string, Myconv>::value, "");
+ static_assert( std::is_constructible<Myconv, std::string>::value, "");
+#endif
+ {
+ Myconv myconv;
+ try
+ {
+ myconv.to_bytes(L"\xDA83");
+ assert(false);
+ }
+ catch (const std::range_error&)
+ {
+ }
+ try
+ {
+ myconv.from_bytes('\xA5');
+ assert(false);
+ }
+ catch (const std::range_error&)
+ {
+ }
+ }
+ {
+ Myconv myconv("byte error");
+ std::string bs = myconv.to_bytes(L"\xDA83");
+ assert(bs == "byte error");
+ try
+ {
+ myconv.from_bytes('\xA5');
+ assert(false);
+ }
+ catch (const std::range_error&)
+ {
+ }
+ }
+ {
+ Myconv myconv("byte error", L"wide error");
+ std::string bs = myconv.to_bytes(L"\xDA83");
+ assert(bs == "byte error");
+ std::wstring ws = myconv.from_bytes('\xA5');
+ assert(ws == L"wide error");
+ }
+}
diff --git a/test/std/localization/locales/locale.convenience/conversions/conversions.string/from_bytes.pass.cpp b/test/std/localization/locales/locale.convenience/conversions/conversions.string/from_bytes.pass.cpp
new file mode 100644
index 000000000000..8705a5f3bced
--- /dev/null
+++ b/test/std/localization/locales/locale.convenience/conversions/conversions.string/from_bytes.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// wstring_convert<Codecvt, Elem, Wide_alloc, Byte_alloc>
+
+// wide_string from_bytes(char byte);
+// wide_string from_bytes(const char* ptr);
+// wide_string from_bytes(const byte_string& str);
+// wide_string from_bytes(const char* first, const char* last);
+
+#include <locale>
+#include <codecvt>
+#include <cassert>
+
+int main()
+{
+ {
+ std::wstring_convert<std::codecvt_utf8<wchar_t> > myconv;
+ std::string bs("\xF1\x80\x80\x83");
+ std::wstring ws = myconv.from_bytes('a');
+ assert(ws == L"a");
+ ws = myconv.from_bytes(bs.c_str());
+ assert(ws == L"\x40003");
+ ws = myconv.from_bytes(bs);
+ assert(ws == L"\x40003");
+ ws = myconv.from_bytes(bs.data(), bs.data() + bs.size());
+ assert(ws == L"\x40003");
+ ws = myconv.from_bytes("");
+ assert(ws.size() == 0);
+ }
+}
diff --git a/test/std/localization/locales/locale.convenience/conversions/conversions.string/state.pass.cpp b/test/std/localization/locales/locale.convenience/conversions/conversions.string/state.pass.cpp
new file mode 100644
index 000000000000..08dfa2558be1
--- /dev/null
+++ b/test/std/localization/locales/locale.convenience/conversions/conversions.string/state.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// wstring_convert<Codecvt, Elem, Wide_alloc, Byte_alloc>
+
+// state_type state() const;
+
+#include <locale>
+#include <codecvt>
+
+int main()
+{
+ typedef std::codecvt_utf8<wchar_t> Codecvt;
+ typedef std::wstring_convert<Codecvt> Myconv;
+ Myconv myconv;
+ std::mbstate_t s = myconv.state();
+}
diff --git a/test/std/localization/locales/locale.convenience/conversions/conversions.string/to_bytes.pass.cpp b/test/std/localization/locales/locale.convenience/conversions/conversions.string/to_bytes.pass.cpp
new file mode 100644
index 000000000000..7253a18a70b1
--- /dev/null
+++ b/test/std/localization/locales/locale.convenience/conversions/conversions.string/to_bytes.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// wstring_convert<Codecvt, Elem, Wide_alloc, Byte_alloc>
+
+// byte_string to_bytes(Elem wchar);
+// byte_string to_bytes(const Elem* wptr);
+// byte_string to_bytes(const wide_string& wstr);
+// byte_string to_bytes(const Elem* first, const Elem* last);
+
+#include <locale>
+#include <codecvt>
+#include <cassert>
+
+int main()
+{
+ {
+ std::wstring_convert<std::codecvt_utf8<wchar_t> > myconv;
+ std::wstring ws(1, L'\x40003');
+ std::string bs = myconv.to_bytes(ws[0]);
+ assert(bs == "\xF1\x80\x80\x83");
+ bs = myconv.to_bytes(ws.c_str());
+ assert(bs == "\xF1\x80\x80\x83");
+ bs = myconv.to_bytes(ws);
+ assert(bs == "\xF1\x80\x80\x83");
+ bs = myconv.to_bytes(ws.data(), ws.data() + ws.size());
+ assert(bs == "\xF1\x80\x80\x83");
+ bs = myconv.to_bytes(L"");
+ assert(bs.size() == 0);
+ }
+}
diff --git a/test/std/localization/locales/locale.convenience/conversions/conversions.string/types.pass.cpp b/test/std/localization/locales/locale.convenience/conversions/conversions.string/types.pass.cpp
new file mode 100644
index 000000000000..d46c858fd3cd
--- /dev/null
+++ b/test/std/localization/locales/locale.convenience/conversions/conversions.string/types.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template<class Codecvt, class Elem = wchar_t,
+// class Wide_alloc = allocator<Elem>,
+// class Byte_alloc = allocator<char>>
+// class wstring_convert
+// {
+// public:
+// typedef basic_string<char, char_traits<char>, Byte_alloc> byte_string;
+// typedef basic_string<Elem, char_traits<Elem>, Wide_alloc> wide_string;
+// typedef typename Codecvt::state_type state_type;
+// typedef typename wide_string::traits_type::int_type int_type;
+
+#include <locale>
+#include <codecvt>
+
+int main()
+{
+ {
+ typedef std::wstring_convert<std::codecvt_utf8<wchar_t> > myconv;
+ static_assert((std::is_same<myconv::byte_string, std::string>::value), "");
+ static_assert((std::is_same<myconv::wide_string, std::wstring>::value), "");
+ static_assert((std::is_same<myconv::state_type, std::mbstate_t>::value), "");
+ static_assert((std::is_same<myconv::int_type, std::char_traits<wchar_t>::int_type>::value), "");
+ }
+}
diff --git a/test/std/localization/locales/locale.convenience/conversions/nothing_to_do.pass.cpp b/test/std/localization/locales/locale.convenience/conversions/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/localization/locales/locale.convenience/conversions/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/localization/locales/locale.convenience/nothing_to_do.pass.cpp b/test/std/localization/locales/locale.convenience/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/localization/locales/locale.convenience/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/localization/locales/locale.global.templates/has_facet.pass.cpp b/test/std/localization/locales/locale.global.templates/has_facet.pass.cpp
new file mode 100644
index 000000000000..58767f059936
--- /dev/null
+++ b/test/std/localization/locales/locale.global.templates/has_facet.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class Facet> bool has_facet(const locale& loc) throw();
+
+#include <locale>
+#include <cassert>
+
+struct my_facet
+ : public std::locale::facet
+{
+ static std::locale::id id;
+};
+
+std::locale::id my_facet::id;
+
+int main()
+{
+ std::locale loc;
+ assert(std::has_facet<std::ctype<char> >(loc));
+ assert(!std::has_facet<my_facet>(loc));
+ std::locale loc2(loc, new my_facet);
+ assert(std::has_facet<my_facet>(loc2));
+}
diff --git a/test/std/localization/locales/locale.global.templates/use_facet.pass.cpp b/test/std/localization/locales/locale.global.templates/use_facet.pass.cpp
new file mode 100644
index 000000000000..a40a2d2d8833
--- /dev/null
+++ b/test/std/localization/locales/locale.global.templates/use_facet.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class Facet> const Facet& use_facet(const locale& loc);
+
+#include <locale>
+#include <cassert>
+
+int facet_count = 0;
+
+struct my_facet
+ : public std::locale::facet
+{
+ static std::locale::id id;
+
+ bool im_alive;
+
+ my_facet() : im_alive(true) {++facet_count;}
+ ~my_facet() {im_alive = false; --facet_count;}
+};
+
+std::locale::id my_facet::id;
+
+int main()
+{
+ try
+ {
+ const my_facet& f = std::use_facet<my_facet>(std::locale());
+ assert(false);
+ }
+ catch (std::bad_cast&)
+ {
+ }
+ const my_facet* fp = 0;
+ {
+ std::locale loc(std::locale(), new my_facet);
+ const my_facet& f = std::use_facet<my_facet>(loc);
+ assert(f.im_alive);
+ fp = &f;
+ assert(fp->im_alive);
+ assert(facet_count == 1);
+ }
+ assert(facet_count == 0);
+}
diff --git a/test/std/localization/locales/locale/locale.cons/assign.pass.cpp b/test/std/localization/locales/locale/locale.cons/assign.pass.cpp
new file mode 100644
index 000000000000..80afe1e46aad
--- /dev/null
+++ b/test/std/localization/locales/locale/locale.cons/assign.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: locale.ru_RU.UTF-8
+// UNSUPPORTED: sanitizer-new-delete
+
+// <locale>
+
+// const locale& operator=(const locale& other) throw();
+
+#include <locale>
+#include <cassert>
+#include <new>
+
+#include "platform_support.h" // locale name macros
+
+int new_called = 0;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+ ++new_called;
+ return std::malloc(s);
+}
+
+void operator delete(void* p) throw()
+{
+ --new_called;
+ std::free(p);
+}
+
+void check(const std::locale& loc)
+{
+ assert(std::has_facet<std::collate<char> >(loc));
+ assert(std::has_facet<std::collate<wchar_t> >(loc));
+
+ assert(std::has_facet<std::ctype<char> >(loc));
+ assert(std::has_facet<std::ctype<wchar_t> >(loc));
+ assert((std::has_facet<std::codecvt<char, char, std::mbstate_t> >(loc)));
+ assert((std::has_facet<std::codecvt<char16_t, char, std::mbstate_t> >(loc)));
+ assert((std::has_facet<std::codecvt<char32_t, char, std::mbstate_t> >(loc)));
+ assert((std::has_facet<std::codecvt<wchar_t, char, std::mbstate_t> >(loc)));
+
+ assert((std::has_facet<std::moneypunct<char> >(loc)));
+ assert((std::has_facet<std::moneypunct<wchar_t> >(loc)));
+ assert((std::has_facet<std::money_get<char> >(loc)));
+ assert((std::has_facet<std::money_get<wchar_t> >(loc)));
+ assert((std::has_facet<std::money_put<char> >(loc)));
+ assert((std::has_facet<std::money_put<wchar_t> >(loc)));
+
+ assert((std::has_facet<std::numpunct<char> >(loc)));
+ assert((std::has_facet<std::numpunct<wchar_t> >(loc)));
+ assert((std::has_facet<std::num_get<char> >(loc)));
+ assert((std::has_facet<std::num_get<wchar_t> >(loc)));
+ assert((std::has_facet<std::num_put<char> >(loc)));
+ assert((std::has_facet<std::num_put<wchar_t> >(loc)));
+
+ assert((std::has_facet<std::time_get<char> >(loc)));
+ assert((std::has_facet<std::time_get<wchar_t> >(loc)));
+ assert((std::has_facet<std::time_put<char> >(loc)));
+ assert((std::has_facet<std::time_put<wchar_t> >(loc)));
+
+ assert((std::has_facet<std::messages<char> >(loc)));
+ assert((std::has_facet<std::messages<wchar_t> >(loc)));
+}
+
+int main()
+{
+ {
+ std::locale loc(LOCALE_ru_RU_UTF_8);
+ std::locale loc2;
+ loc2 = loc;
+ assert(loc == loc2);
+ check(loc);
+ check(loc2);
+ }
+ assert(new_called == 0);
+}
diff --git a/test/std/localization/locales/locale/locale.cons/char_pointer.pass.cpp b/test/std/localization/locales/locale/locale.cons/char_pointer.pass.cpp
new file mode 100644
index 000000000000..3567bf56c55a
--- /dev/null
+++ b/test/std/localization/locales/locale/locale.cons/char_pointer.pass.cpp
@@ -0,0 +1,104 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: locale.ru_RU.UTF-8
+// REQUIRES: locale.zh_CN.UTF-8
+// UNSUPPORTED: sanitizer-new-delete
+
+// <locale>
+
+// explicit locale(const char* std_name);
+
+#include <locale>
+#include <new>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+int new_called = 0;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+ ++new_called;
+ return std::malloc(s);
+}
+
+void operator delete(void* p) throw()
+{
+ --new_called;
+ std::free(p);
+}
+
+void check(const std::locale& loc)
+{
+ assert(std::has_facet<std::collate<char> >(loc));
+ assert(std::has_facet<std::collate<wchar_t> >(loc));
+
+ assert(std::has_facet<std::ctype<char> >(loc));
+ assert(std::has_facet<std::ctype<wchar_t> >(loc));
+ assert((std::has_facet<std::codecvt<char, char, std::mbstate_t> >(loc)));
+ assert((std::has_facet<std::codecvt<char16_t, char, std::mbstate_t> >(loc)));
+ assert((std::has_facet<std::codecvt<char32_t, char, std::mbstate_t> >(loc)));
+ assert((std::has_facet<std::codecvt<wchar_t, char, std::mbstate_t> >(loc)));
+
+ assert((std::has_facet<std::moneypunct<char> >(loc)));
+ assert((std::has_facet<std::moneypunct<wchar_t> >(loc)));
+ assert((std::has_facet<std::money_get<char> >(loc)));
+ assert((std::has_facet<std::money_get<wchar_t> >(loc)));
+ assert((std::has_facet<std::money_put<char> >(loc)));
+ assert((std::has_facet<std::money_put<wchar_t> >(loc)));
+
+ assert((std::has_facet<std::numpunct<char> >(loc)));
+ assert((std::has_facet<std::numpunct<wchar_t> >(loc)));
+ assert((std::has_facet<std::num_get<char> >(loc)));
+ assert((std::has_facet<std::num_get<wchar_t> >(loc)));
+ assert((std::has_facet<std::num_put<char> >(loc)));
+ assert((std::has_facet<std::num_put<wchar_t> >(loc)));
+
+ assert((std::has_facet<std::time_get<char> >(loc)));
+ assert((std::has_facet<std::time_get<wchar_t> >(loc)));
+ assert((std::has_facet<std::time_put<char> >(loc)));
+ assert((std::has_facet<std::time_put<wchar_t> >(loc)));
+
+ assert((std::has_facet<std::messages<char> >(loc)));
+ assert((std::has_facet<std::messages<wchar_t> >(loc)));
+}
+
+int main()
+{
+ {
+ std::locale loc(LOCALE_ru_RU_UTF_8);
+ check(loc);
+ std::locale loc2(LOCALE_ru_RU_UTF_8);
+ check(loc2);
+ assert(loc == loc2);
+ std::locale loc3(LOCALE_zh_CN_UTF_8);
+ check(loc3);
+ assert(!(loc == loc3));
+ assert(loc != loc3);
+ try
+ {
+ std::locale((const char*)0);
+ assert(false);
+ }
+ catch (std::runtime_error&)
+ {
+ }
+ try
+ {
+ std::locale("spazbot");
+ assert(false);
+ }
+ catch (std::runtime_error&)
+ {
+ }
+ std::locale ok("");
+ }
+ assert(new_called == 0);
+}
diff --git a/test/std/localization/locales/locale/locale.cons/copy.pass.cpp b/test/std/localization/locales/locale/locale.cons/copy.pass.cpp
new file mode 100644
index 000000000000..0760cc46cdd8
--- /dev/null
+++ b/test/std/localization/locales/locale/locale.cons/copy.pass.cpp
@@ -0,0 +1,82 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: locale.fr_FR.UTF-8
+// UNSUPPORTED: sanitizer-new-delete
+
+// <locale>
+
+// locale(const locale& other) throw();
+
+#include <locale>
+#include <cassert>
+#include <new>
+
+#include "platform_support.h" // locale name macros
+
+int new_called = 0;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+ ++new_called;
+ return std::malloc(s);
+}
+
+void operator delete(void* p) throw()
+{
+ --new_called;
+ std::free(p);
+}
+
+void check(const std::locale& loc)
+{
+ assert(std::has_facet<std::collate<char> >(loc));
+ assert(std::has_facet<std::collate<wchar_t> >(loc));
+
+ assert(std::has_facet<std::ctype<char> >(loc));
+ assert(std::has_facet<std::ctype<wchar_t> >(loc));
+ assert((std::has_facet<std::codecvt<char, char, std::mbstate_t> >(loc)));
+ assert((std::has_facet<std::codecvt<char16_t, char, std::mbstate_t> >(loc)));
+ assert((std::has_facet<std::codecvt<char32_t, char, std::mbstate_t> >(loc)));
+ assert((std::has_facet<std::codecvt<wchar_t, char, std::mbstate_t> >(loc)));
+
+ assert((std::has_facet<std::moneypunct<char> >(loc)));
+ assert((std::has_facet<std::moneypunct<wchar_t> >(loc)));
+ assert((std::has_facet<std::money_get<char> >(loc)));
+ assert((std::has_facet<std::money_get<wchar_t> >(loc)));
+ assert((std::has_facet<std::money_put<char> >(loc)));
+ assert((std::has_facet<std::money_put<wchar_t> >(loc)));
+
+ assert((std::has_facet<std::numpunct<char> >(loc)));
+ assert((std::has_facet<std::numpunct<wchar_t> >(loc)));
+ assert((std::has_facet<std::num_get<char> >(loc)));
+ assert((std::has_facet<std::num_get<wchar_t> >(loc)));
+ assert((std::has_facet<std::num_put<char> >(loc)));
+ assert((std::has_facet<std::num_put<wchar_t> >(loc)));
+
+ assert((std::has_facet<std::time_get<char> >(loc)));
+ assert((std::has_facet<std::time_get<wchar_t> >(loc)));
+ assert((std::has_facet<std::time_put<char> >(loc)));
+ assert((std::has_facet<std::time_put<wchar_t> >(loc)));
+
+ assert((std::has_facet<std::messages<char> >(loc)));
+ assert((std::has_facet<std::messages<wchar_t> >(loc)));
+}
+
+int main()
+{
+ {
+ std::locale loc(LOCALE_fr_FR_UTF_8);
+ std::locale loc2 = loc;
+ assert(loc == loc2);
+ check(loc);
+ check(loc2);
+ }
+ assert(new_called == 0);
+}
diff --git a/test/std/localization/locales/locale/locale.cons/default.pass.cpp b/test/std/localization/locales/locale/locale.cons/default.pass.cpp
new file mode 100644
index 000000000000..1efc939f3c27
--- /dev/null
+++ b/test/std/localization/locales/locale/locale.cons/default.pass.cpp
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// locale() throw();
+
+#include <locale>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+#include "count_new.hpp"
+
+void check(const std::locale& loc)
+{
+ assert(std::has_facet<std::collate<char> >(loc));
+ assert(std::has_facet<std::collate<wchar_t> >(loc));
+
+ assert(std::has_facet<std::ctype<char> >(loc));
+ assert(std::has_facet<std::ctype<wchar_t> >(loc));
+ assert((std::has_facet<std::codecvt<char, char, std::mbstate_t> >(loc)));
+ assert((std::has_facet<std::codecvt<char16_t, char, std::mbstate_t> >(loc)));
+ assert((std::has_facet<std::codecvt<char32_t, char, std::mbstate_t> >(loc)));
+ assert((std::has_facet<std::codecvt<wchar_t, char, std::mbstate_t> >(loc)));
+
+ assert((std::has_facet<std::moneypunct<char> >(loc)));
+ assert((std::has_facet<std::moneypunct<wchar_t> >(loc)));
+ assert((std::has_facet<std::money_get<char> >(loc)));
+ assert((std::has_facet<std::money_get<wchar_t> >(loc)));
+ assert((std::has_facet<std::money_put<char> >(loc)));
+ assert((std::has_facet<std::money_put<wchar_t> >(loc)));
+
+ assert((std::has_facet<std::numpunct<char> >(loc)));
+ assert((std::has_facet<std::numpunct<wchar_t> >(loc)));
+ assert((std::has_facet<std::num_get<char> >(loc)));
+ assert((std::has_facet<std::num_get<wchar_t> >(loc)));
+ assert((std::has_facet<std::num_put<char> >(loc)));
+ assert((std::has_facet<std::num_put<wchar_t> >(loc)));
+
+ assert((std::has_facet<std::time_get<char> >(loc)));
+ assert((std::has_facet<std::time_get<wchar_t> >(loc)));
+ assert((std::has_facet<std::time_put<char> >(loc)));
+ assert((std::has_facet<std::time_put<wchar_t> >(loc)));
+
+ assert((std::has_facet<std::messages<char> >(loc)));
+ assert((std::has_facet<std::messages<wchar_t> >(loc)));
+}
+
+int main()
+{
+ int ok;
+ {
+ std::locale loc;
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ assert(loc.name() == "C");
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ check(loc);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ assert(std::locale::global(std::locale(LOCALE_en_US_UTF_8)) == loc);
+ ok = globalMemCounter.outstanding_new;
+ std::locale loc2;
+ assert(globalMemCounter.checkOutstandingNewEq(ok));
+ check(loc2);
+ assert(globalMemCounter.checkOutstandingNewEq(ok));
+ assert(loc2 == std::locale(LOCALE_en_US_UTF_8));
+ assert(globalMemCounter.checkOutstandingNewEq(ok));
+ }
+ assert(globalMemCounter.checkOutstandingNewEq(ok));
+}
diff --git a/test/std/localization/locales/locale/locale.cons/locale_char_pointer_cat.pass.cpp b/test/std/localization/locales/locale/locale.cons/locale_char_pointer_cat.pass.cpp
new file mode 100644
index 000000000000..2a9e20fcf98d
--- /dev/null
+++ b/test/std/localization/locales/locale/locale.cons/locale_char_pointer_cat.pass.cpp
@@ -0,0 +1,82 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: locale.en_US.UTF-8
+// REQUIRES: locale.ru_RU.UTF-8
+// UNSUPPORTED: sanitizer-new-delete
+
+// <locale>
+
+// locale(const locale& other, const char* std_name, category);
+
+#include <locale>
+#include <new>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+int new_called = 0;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+ ++new_called;
+ return std::malloc(s);
+}
+
+void operator delete(void* p) throw()
+{
+ --new_called;
+ std::free(p);
+}
+
+void check(const std::locale& loc)
+{
+ assert(std::has_facet<std::collate<char> >(loc));
+ assert(std::has_facet<std::collate<wchar_t> >(loc));
+
+ assert(std::has_facet<std::ctype<char> >(loc));
+ assert(std::has_facet<std::ctype<wchar_t> >(loc));
+ assert((std::has_facet<std::codecvt<char, char, std::mbstate_t> >(loc)));
+ assert((std::has_facet<std::codecvt<char16_t, char, std::mbstate_t> >(loc)));
+ assert((std::has_facet<std::codecvt<char32_t, char, std::mbstate_t> >(loc)));
+ assert((std::has_facet<std::codecvt<wchar_t, char, std::mbstate_t> >(loc)));
+
+ assert((std::has_facet<std::moneypunct<char> >(loc)));
+ assert((std::has_facet<std::moneypunct<wchar_t> >(loc)));
+ assert((std::has_facet<std::money_get<char> >(loc)));
+ assert((std::has_facet<std::money_get<wchar_t> >(loc)));
+ assert((std::has_facet<std::money_put<char> >(loc)));
+ assert((std::has_facet<std::money_put<wchar_t> >(loc)));
+
+ assert((std::has_facet<std::numpunct<char> >(loc)));
+ assert((std::has_facet<std::numpunct<wchar_t> >(loc)));
+ assert((std::has_facet<std::num_get<char> >(loc)));
+ assert((std::has_facet<std::num_get<wchar_t> >(loc)));
+ assert((std::has_facet<std::num_put<char> >(loc)));
+ assert((std::has_facet<std::num_put<wchar_t> >(loc)));
+
+ assert((std::has_facet<std::time_get<char> >(loc)));
+ assert((std::has_facet<std::time_get<wchar_t> >(loc)));
+ assert((std::has_facet<std::time_put<char> >(loc)));
+ assert((std::has_facet<std::time_put<wchar_t> >(loc)));
+
+ assert((std::has_facet<std::messages<char> >(loc)));
+ assert((std::has_facet<std::messages<wchar_t> >(loc)));
+}
+
+int main()
+{
+ {
+ std::locale loc(LOCALE_ru_RU_UTF_8);
+ check(loc);
+ std::locale loc2(loc, LOCALE_en_US_UTF_8, std::locale::monetary);
+ check(loc2);
+ }
+ assert(new_called == 0);
+}
diff --git a/test/std/localization/locales/locale/locale.cons/locale_facetptr.pass.cpp b/test/std/localization/locales/locale/locale.cons/locale_facetptr.pass.cpp
new file mode 100644
index 000000000000..fb6e39e5742f
--- /dev/null
+++ b/test/std/localization/locales/locale/locale.cons/locale_facetptr.pass.cpp
@@ -0,0 +1,106 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: locale.ru_RU.UTF-8
+// UNSUPPORTED: sanitizer-new-delete
+
+// <locale>
+
+// template <class Facet> locale(const locale& other, Facet* f);
+
+#include <locale>
+#include <new>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+int new_called = 0;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+ ++new_called;
+ return std::malloc(s);
+}
+
+void operator delete(void* p) throw()
+{
+ --new_called;
+ std::free(p);
+}
+
+void check(const std::locale& loc)
+{
+ assert(std::has_facet<std::collate<char> >(loc));
+ assert(std::has_facet<std::collate<wchar_t> >(loc));
+
+ assert(std::has_facet<std::ctype<char> >(loc));
+ assert(std::has_facet<std::ctype<wchar_t> >(loc));
+ assert((std::has_facet<std::codecvt<char, char, std::mbstate_t> >(loc)));
+ assert((std::has_facet<std::codecvt<char16_t, char, std::mbstate_t> >(loc)));
+ assert((std::has_facet<std::codecvt<char32_t, char, std::mbstate_t> >(loc)));
+ assert((std::has_facet<std::codecvt<wchar_t, char, std::mbstate_t> >(loc)));
+
+ assert((std::has_facet<std::moneypunct<char> >(loc)));
+ assert((std::has_facet<std::moneypunct<wchar_t> >(loc)));
+ assert((std::has_facet<std::money_get<char> >(loc)));
+ assert((std::has_facet<std::money_get<wchar_t> >(loc)));
+ assert((std::has_facet<std::money_put<char> >(loc)));
+ assert((std::has_facet<std::money_put<wchar_t> >(loc)));
+
+ assert((std::has_facet<std::numpunct<char> >(loc)));
+ assert((std::has_facet<std::numpunct<wchar_t> >(loc)));
+ assert((std::has_facet<std::num_get<char> >(loc)));
+ assert((std::has_facet<std::num_get<wchar_t> >(loc)));
+ assert((std::has_facet<std::num_put<char> >(loc)));
+ assert((std::has_facet<std::num_put<wchar_t> >(loc)));
+
+ assert((std::has_facet<std::time_get<char> >(loc)));
+ assert((std::has_facet<std::time_get<wchar_t> >(loc)));
+ assert((std::has_facet<std::time_put<char> >(loc)));
+ assert((std::has_facet<std::time_put<wchar_t> >(loc)));
+
+ assert((std::has_facet<std::messages<char> >(loc)));
+ assert((std::has_facet<std::messages<wchar_t> >(loc)));
+}
+
+struct my_facet
+ : public std::locale::facet
+{
+ int test() const {return 5;}
+
+ static std::locale::id id;
+};
+
+std::locale::id my_facet::id;
+
+int main()
+{
+{
+ {
+ std::locale loc(LOCALE_ru_RU_UTF_8);
+ check(loc);
+ std::locale loc2(loc, new my_facet);
+ check(loc2);
+ assert((std::has_facet<my_facet>(loc2)));
+ const my_facet& f = std::use_facet<my_facet>(loc2);
+ assert(f.test() == 5);
+ }
+ assert(new_called == 0);
+}
+{
+ {
+ std::locale loc;
+ check(loc);
+ std::locale loc2(loc, (std::ctype<char>*)0);
+ check(loc2);
+ assert(loc == loc2);
+ }
+ assert(new_called == 0);
+}
+}
diff --git a/test/std/localization/locales/locale/locale.cons/locale_locale_cat.pass.cpp b/test/std/localization/locales/locale/locale.cons/locale_locale_cat.pass.cpp
new file mode 100644
index 000000000000..fa87eb20e9af
--- /dev/null
+++ b/test/std/localization/locales/locale/locale.cons/locale_locale_cat.pass.cpp
@@ -0,0 +1,82 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: locale.en_US.UTF-8
+// REQUIRES: locale.ru_RU.UTF-8
+// UNSUPPORTED: sanitizer-new-delete
+
+// <locale>
+
+// locale(const locale& other, const locale& one, category cats);
+
+#include <locale>
+#include <new>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+int new_called = 0;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+ ++new_called;
+ return std::malloc(s);
+}
+
+void operator delete(void* p) throw()
+{
+ --new_called;
+ std::free(p);
+}
+
+void check(const std::locale& loc)
+{
+ assert(std::has_facet<std::collate<char> >(loc));
+ assert(std::has_facet<std::collate<wchar_t> >(loc));
+
+ assert(std::has_facet<std::ctype<char> >(loc));
+ assert(std::has_facet<std::ctype<wchar_t> >(loc));
+ assert((std::has_facet<std::codecvt<char, char, std::mbstate_t> >(loc)));
+ assert((std::has_facet<std::codecvt<char16_t, char, std::mbstate_t> >(loc)));
+ assert((std::has_facet<std::codecvt<char32_t, char, std::mbstate_t> >(loc)));
+ assert((std::has_facet<std::codecvt<wchar_t, char, std::mbstate_t> >(loc)));
+
+ assert((std::has_facet<std::moneypunct<char> >(loc)));
+ assert((std::has_facet<std::moneypunct<wchar_t> >(loc)));
+ assert((std::has_facet<std::money_get<char> >(loc)));
+ assert((std::has_facet<std::money_get<wchar_t> >(loc)));
+ assert((std::has_facet<std::money_put<char> >(loc)));
+ assert((std::has_facet<std::money_put<wchar_t> >(loc)));
+
+ assert((std::has_facet<std::numpunct<char> >(loc)));
+ assert((std::has_facet<std::numpunct<wchar_t> >(loc)));
+ assert((std::has_facet<std::num_get<char> >(loc)));
+ assert((std::has_facet<std::num_get<wchar_t> >(loc)));
+ assert((std::has_facet<std::num_put<char> >(loc)));
+ assert((std::has_facet<std::num_put<wchar_t> >(loc)));
+
+ assert((std::has_facet<std::time_get<char> >(loc)));
+ assert((std::has_facet<std::time_get<wchar_t> >(loc)));
+ assert((std::has_facet<std::time_put<char> >(loc)));
+ assert((std::has_facet<std::time_put<wchar_t> >(loc)));
+
+ assert((std::has_facet<std::messages<char> >(loc)));
+ assert((std::has_facet<std::messages<wchar_t> >(loc)));
+}
+
+int main()
+{
+ {
+ std::locale loc(LOCALE_ru_RU_UTF_8);
+ check(loc);
+ std::locale loc2(loc, std::locale(LOCALE_en_US_UTF_8), std::locale::monetary);
+ check(loc2);
+ }
+ assert(new_called == 0);
+}
diff --git a/test/std/localization/locales/locale/locale.cons/locale_string_cat.pass.cpp b/test/std/localization/locales/locale/locale.cons/locale_string_cat.pass.cpp
new file mode 100644
index 000000000000..d48a572a2afe
--- /dev/null
+++ b/test/std/localization/locales/locale/locale.cons/locale_string_cat.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: locale.ru_RU.UTF-8
+// UNSUPPORTED: sanitizer-new-delete
+
+// <locale>
+
+// locale(const locale& other, const string& std_name, category cat);
+
+#include <locale>
+#include <new>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+int new_called = 0;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+ ++new_called;
+ return std::malloc(s);
+}
+
+void operator delete(void* p) throw()
+{
+ --new_called;
+ std::free(p);
+}
+
+void check(const std::locale& loc)
+{
+ assert(std::has_facet<std::collate<char> >(loc));
+ assert(std::has_facet<std::collate<wchar_t> >(loc));
+
+ assert(std::has_facet<std::ctype<char> >(loc));
+ assert(std::has_facet<std::ctype<wchar_t> >(loc));
+ assert((std::has_facet<std::codecvt<char, char, std::mbstate_t> >(loc)));
+ assert((std::has_facet<std::codecvt<char16_t, char, std::mbstate_t> >(loc)));
+ assert((std::has_facet<std::codecvt<char32_t, char, std::mbstate_t> >(loc)));
+ assert((std::has_facet<std::codecvt<wchar_t, char, std::mbstate_t> >(loc)));
+
+ assert((std::has_facet<std::moneypunct<char> >(loc)));
+ assert((std::has_facet<std::moneypunct<wchar_t> >(loc)));
+ assert((std::has_facet<std::money_get<char> >(loc)));
+ assert((std::has_facet<std::money_get<wchar_t> >(loc)));
+ assert((std::has_facet<std::money_put<char> >(loc)));
+ assert((std::has_facet<std::money_put<wchar_t> >(loc)));
+
+ assert((std::has_facet<std::numpunct<char> >(loc)));
+ assert((std::has_facet<std::numpunct<wchar_t> >(loc)));
+ assert((std::has_facet<std::num_get<char> >(loc)));
+ assert((std::has_facet<std::num_get<wchar_t> >(loc)));
+ assert((std::has_facet<std::num_put<char> >(loc)));
+ assert((std::has_facet<std::num_put<wchar_t> >(loc)));
+
+ assert((std::has_facet<std::time_get<char> >(loc)));
+ assert((std::has_facet<std::time_get<wchar_t> >(loc)));
+ assert((std::has_facet<std::time_put<char> >(loc)));
+ assert((std::has_facet<std::time_put<wchar_t> >(loc)));
+
+ assert((std::has_facet<std::messages<char> >(loc)));
+ assert((std::has_facet<std::messages<wchar_t> >(loc)));
+}
+
+int main()
+{
+ {
+ std::locale loc(LOCALE_ru_RU_UTF_8);
+ check(loc);
+ std::locale loc2(loc, std::string(LOCALE_en_US_UTF_8), std::locale::monetary);
+ check(loc2);
+ }
+ assert(new_called == 0);
+}
diff --git a/test/std/localization/locales/locale/locale.cons/string.pass.cpp b/test/std/localization/locales/locale/locale.cons/string.pass.cpp
new file mode 100644
index 000000000000..c9f944196e73
--- /dev/null
+++ b/test/std/localization/locales/locale/locale.cons/string.pass.cpp
@@ -0,0 +1,87 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: locale.ru_RU.UTF-8
+// REQUIRES: locale.zh_CN.UTF-8
+// UNSUPPORTED: sanitizer-new-delete
+
+// <locale>
+
+// explicit locale(const string& std_name);
+
+#include <locale>
+#include <new>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+int new_called = 0;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+ ++new_called;
+ return std::malloc(s);
+}
+
+void operator delete(void* p) throw()
+{
+ --new_called;
+ std::free(p);
+}
+
+void check(const std::locale& loc)
+{
+ assert(std::has_facet<std::collate<char> >(loc));
+ assert(std::has_facet<std::collate<wchar_t> >(loc));
+
+ assert(std::has_facet<std::ctype<char> >(loc));
+ assert(std::has_facet<std::ctype<wchar_t> >(loc));
+ assert((std::has_facet<std::codecvt<char, char, std::mbstate_t> >(loc)));
+ assert((std::has_facet<std::codecvt<char16_t, char, std::mbstate_t> >(loc)));
+ assert((std::has_facet<std::codecvt<char32_t, char, std::mbstate_t> >(loc)));
+ assert((std::has_facet<std::codecvt<wchar_t, char, std::mbstate_t> >(loc)));
+
+ assert((std::has_facet<std::moneypunct<char> >(loc)));
+ assert((std::has_facet<std::moneypunct<wchar_t> >(loc)));
+ assert((std::has_facet<std::money_get<char> >(loc)));
+ assert((std::has_facet<std::money_get<wchar_t> >(loc)));
+ assert((std::has_facet<std::money_put<char> >(loc)));
+ assert((std::has_facet<std::money_put<wchar_t> >(loc)));
+
+ assert((std::has_facet<std::numpunct<char> >(loc)));
+ assert((std::has_facet<std::numpunct<wchar_t> >(loc)));
+ assert((std::has_facet<std::num_get<char> >(loc)));
+ assert((std::has_facet<std::num_get<wchar_t> >(loc)));
+ assert((std::has_facet<std::num_put<char> >(loc)));
+ assert((std::has_facet<std::num_put<wchar_t> >(loc)));
+
+ assert((std::has_facet<std::time_get<char> >(loc)));
+ assert((std::has_facet<std::time_get<wchar_t> >(loc)));
+ assert((std::has_facet<std::time_put<char> >(loc)));
+ assert((std::has_facet<std::time_put<wchar_t> >(loc)));
+
+ assert((std::has_facet<std::messages<char> >(loc)));
+ assert((std::has_facet<std::messages<wchar_t> >(loc)));
+}
+
+int main()
+{
+ {
+ std::locale loc(std::string(LOCALE_ru_RU_UTF_8));
+ check(loc);
+ std::locale loc2(std::string(LOCALE_ru_RU_UTF_8));
+ check(loc2);
+ assert(loc == loc2);
+ std::locale loc3(std::string(LOCALE_zh_CN_UTF_8));
+ check(loc3);
+ assert(!(loc == loc3));
+ assert(loc != loc3);
+ }
+ assert(new_called == 0);
+}
diff --git a/test/std/localization/locales/locale/locale.members/combine.pass.cpp b/test/std/localization/locales/locale/locale.members/combine.pass.cpp
new file mode 100644
index 000000000000..e956102c08fc
--- /dev/null
+++ b/test/std/localization/locales/locale/locale.members/combine.pass.cpp
@@ -0,0 +1,94 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class Facet> locale combine(const locale& other) const;
+
+#include <locale>
+#include <cassert>
+
+#include "count_new.hpp"
+
+void check(const std::locale& loc)
+{
+ assert(std::has_facet<std::collate<char> >(loc));
+ assert(std::has_facet<std::collate<wchar_t> >(loc));
+
+ assert(std::has_facet<std::ctype<char> >(loc));
+ assert(std::has_facet<std::ctype<wchar_t> >(loc));
+ assert((std::has_facet<std::codecvt<char, char, std::mbstate_t> >(loc)));
+ assert((std::has_facet<std::codecvt<char16_t, char, std::mbstate_t> >(loc)));
+ assert((std::has_facet<std::codecvt<char32_t, char, std::mbstate_t> >(loc)));
+ assert((std::has_facet<std::codecvt<wchar_t, char, std::mbstate_t> >(loc)));
+
+ assert((std::has_facet<std::moneypunct<char> >(loc)));
+ assert((std::has_facet<std::moneypunct<wchar_t> >(loc)));
+ assert((std::has_facet<std::money_get<char> >(loc)));
+ assert((std::has_facet<std::money_get<wchar_t> >(loc)));
+ assert((std::has_facet<std::money_put<char> >(loc)));
+ assert((std::has_facet<std::money_put<wchar_t> >(loc)));
+
+ assert((std::has_facet<std::numpunct<char> >(loc)));
+ assert((std::has_facet<std::numpunct<wchar_t> >(loc)));
+ assert((std::has_facet<std::num_get<char> >(loc)));
+ assert((std::has_facet<std::num_get<wchar_t> >(loc)));
+ assert((std::has_facet<std::num_put<char> >(loc)));
+ assert((std::has_facet<std::num_put<wchar_t> >(loc)));
+
+ assert((std::has_facet<std::time_get<char> >(loc)));
+ assert((std::has_facet<std::time_get<wchar_t> >(loc)));
+ assert((std::has_facet<std::time_put<char> >(loc)));
+ assert((std::has_facet<std::time_put<wchar_t> >(loc)));
+
+ assert((std::has_facet<std::messages<char> >(loc)));
+ assert((std::has_facet<std::messages<wchar_t> >(loc)));
+}
+
+struct my_facet
+ : public std::locale::facet
+{
+ int test() const {return 5;}
+
+ static std::locale::id id;
+};
+
+std::locale::id my_facet::id;
+
+int main()
+{
+{
+ {
+ std::locale loc;
+ std::locale loc2(loc, new my_facet);
+ std::locale loc3 = loc.combine<my_facet>(loc2);
+ check(loc3);
+ assert(loc3.name() == "*");
+ assert((std::has_facet<my_facet>(loc3)));
+ const my_facet& f = std::use_facet<my_facet>(loc3);
+ assert(f.test() == 5);
+ }
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+}
+{
+ {
+ std::locale loc;
+ std::locale loc2;
+ try
+ {
+ std::locale loc3 = loc.combine<my_facet>(loc2);
+ assert(false);
+ }
+ catch (std::runtime_error&)
+ {
+ }
+ }
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+}
+}
diff --git a/test/std/localization/locales/locale/locale.members/name.pass.cpp b/test/std/localization/locales/locale/locale.members/name.pass.cpp
new file mode 100644
index 000000000000..9d9b1423f334
--- /dev/null
+++ b/test/std/localization/locales/locale/locale.members/name.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// basic_string<char> name() const;
+
+#include <locale>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+int main()
+{
+ {
+ std::locale loc;
+ assert(loc.name() == "C");
+ }
+ {
+ std::locale loc(LOCALE_en_US_UTF_8);
+ assert(loc.name() == LOCALE_en_US_UTF_8);
+ }
+}
diff --git a/test/std/localization/locales/locale/locale.operators/compare.pass.cpp b/test/std/localization/locales/locale/locale.operators/compare.pass.cpp
new file mode 100644
index 000000000000..40740520d256
--- /dev/null
+++ b/test/std/localization/locales/locale/locale.operators/compare.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT, class Traits, class Allocator>
+// bool operator()(const basic_string<charT,Traits,Allocator>& s1,
+// const basic_string<charT,Traits,Allocator>& s2) const;
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+ {
+ std::locale l;
+ {
+ std::string s2("aaaaaaA");
+ std::string s3("BaaaaaA");
+ assert(l(s3, s2));
+ }
+ {
+ std::wstring s2(L"aaaaaaA");
+ std::wstring s3(L"BaaaaaA");
+ assert(l(s3, s2));
+ }
+ }
+}
diff --git a/test/std/localization/locales/locale/locale.operators/eq.pass.cpp b/test/std/localization/locales/locale/locale.operators/eq.pass.cpp
new file mode 100644
index 000000000000..ec118e07ff27
--- /dev/null
+++ b/test/std/localization/locales/locale/locale.operators/eq.pass.cpp
@@ -0,0 +1,84 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// basic_string<char> name() const;
+
+#include <locale>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+int main()
+{
+ std::locale cloc;
+ std::locale copy(cloc);
+ std::locale n1(LOCALE_en_US_UTF_8);
+ std::locale n2(LOCALE_en_US_UTF_8);
+ std::locale noname1 = n1.combine<std::ctype<char> >(cloc);
+ std::locale nonamec = noname1;
+ std::locale noname2 = n1.combine<std::ctype<char> >(cloc);
+
+ assert(cloc == cloc);
+ assert(cloc == copy);
+ assert(cloc != n1);
+ assert(cloc != n2);
+ assert(cloc != noname1);
+ assert(cloc != nonamec);
+ assert(cloc != noname2);
+
+ assert(copy == cloc);
+ assert(copy == copy);
+ assert(copy != n1);
+ assert(copy != n2);
+ assert(copy != noname1);
+ assert(copy != nonamec);
+ assert(copy != noname2);
+
+ assert(n1 != cloc);
+ assert(n1 != copy);
+ assert(n1 == n1);
+ assert(n1 == n2);
+ assert(n1 != noname1);
+ assert(n1 != nonamec);
+ assert(n1 != noname2);
+
+ assert(n2 != cloc);
+ assert(n2 != copy);
+ assert(n2 == n1);
+ assert(n2 == n2);
+ assert(n2 != noname1);
+ assert(n2 != nonamec);
+ assert(n2 != noname2);
+
+ assert(noname1 != cloc);
+ assert(noname1 != copy);
+ assert(noname1 != n1);
+ assert(noname1 != n2);
+ assert(noname1 == noname1);
+ assert(noname1 == nonamec);
+ assert(noname1 != noname2);
+
+ assert(nonamec != cloc);
+ assert(nonamec != copy);
+ assert(nonamec != n1);
+ assert(nonamec != n2);
+ assert(nonamec == noname1);
+ assert(nonamec == nonamec);
+ assert(nonamec != noname2);
+
+ assert(noname2 != cloc);
+ assert(noname2 != copy);
+ assert(noname2 != n1);
+ assert(noname2 != n2);
+ assert(noname2 != noname1);
+ assert(noname2 != nonamec);
+ assert(noname2 == noname2);
+}
diff --git a/test/std/localization/locales/locale/locale.statics/classic.pass.cpp b/test/std/localization/locales/locale/locale.statics/classic.pass.cpp
new file mode 100644
index 000000000000..078030ce45f9
--- /dev/null
+++ b/test/std/localization/locales/locale/locale.statics/classic.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// static const locale& classic();
+
+#include <locale>
+#include <cassert>
+
+void check(const std::locale& loc)
+{
+ assert(std::has_facet<std::collate<char> >(loc));
+ assert(std::has_facet<std::collate<wchar_t> >(loc));
+
+ assert(std::has_facet<std::ctype<char> >(loc));
+ assert(std::has_facet<std::ctype<wchar_t> >(loc));
+ assert((std::has_facet<std::codecvt<char, char, std::mbstate_t> >(loc)));
+ assert((std::has_facet<std::codecvt<char16_t, char, std::mbstate_t> >(loc)));
+ assert((std::has_facet<std::codecvt<char32_t, char, std::mbstate_t> >(loc)));
+ assert((std::has_facet<std::codecvt<wchar_t, char, std::mbstate_t> >(loc)));
+
+ assert((std::has_facet<std::moneypunct<char> >(loc)));
+ assert((std::has_facet<std::moneypunct<wchar_t> >(loc)));
+ assert((std::has_facet<std::money_get<char> >(loc)));
+ assert((std::has_facet<std::money_get<wchar_t> >(loc)));
+ assert((std::has_facet<std::money_put<char> >(loc)));
+ assert((std::has_facet<std::money_put<wchar_t> >(loc)));
+
+ assert((std::has_facet<std::numpunct<char> >(loc)));
+ assert((std::has_facet<std::numpunct<wchar_t> >(loc)));
+ assert((std::has_facet<std::num_get<char> >(loc)));
+ assert((std::has_facet<std::num_get<wchar_t> >(loc)));
+ assert((std::has_facet<std::num_put<char> >(loc)));
+ assert((std::has_facet<std::num_put<wchar_t> >(loc)));
+
+ assert((std::has_facet<std::time_get<char> >(loc)));
+ assert((std::has_facet<std::time_get<wchar_t> >(loc)));
+ assert((std::has_facet<std::time_put<char> >(loc)));
+ assert((std::has_facet<std::time_put<wchar_t> >(loc)));
+
+ assert((std::has_facet<std::messages<char> >(loc)));
+ assert((std::has_facet<std::messages<wchar_t> >(loc)));
+}
+
+int main()
+{
+ std::locale loc = std::locale::classic();
+ assert(loc.name() == "C");
+ assert(loc == std::locale("C"));
+ check(loc);
+ check(std::locale("C"));
+}
diff --git a/test/std/localization/locales/locale/locale.statics/global.pass.cpp b/test/std/localization/locales/locale/locale.statics/global.pass.cpp
new file mode 100644
index 000000000000..59a6bc6dd383
--- /dev/null
+++ b/test/std/localization/locales/locale/locale.statics/global.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// static const locale& classic();
+
+#include <locale>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+void check(const std::locale& loc)
+{
+ assert(std::has_facet<std::collate<char> >(loc));
+ assert(std::has_facet<std::collate<wchar_t> >(loc));
+
+ assert(std::has_facet<std::ctype<char> >(loc));
+ assert(std::has_facet<std::ctype<wchar_t> >(loc));
+ assert((std::has_facet<std::codecvt<char, char, std::mbstate_t> >(loc)));
+ assert((std::has_facet<std::codecvt<char16_t, char, std::mbstate_t> >(loc)));
+ assert((std::has_facet<std::codecvt<char32_t, char, std::mbstate_t> >(loc)));
+ assert((std::has_facet<std::codecvt<wchar_t, char, std::mbstate_t> >(loc)));
+
+ assert((std::has_facet<std::moneypunct<char> >(loc)));
+ assert((std::has_facet<std::moneypunct<wchar_t> >(loc)));
+ assert((std::has_facet<std::money_get<char> >(loc)));
+ assert((std::has_facet<std::money_get<wchar_t> >(loc)));
+ assert((std::has_facet<std::money_put<char> >(loc)));
+ assert((std::has_facet<std::money_put<wchar_t> >(loc)));
+
+ assert((std::has_facet<std::numpunct<char> >(loc)));
+ assert((std::has_facet<std::numpunct<wchar_t> >(loc)));
+ assert((std::has_facet<std::num_get<char> >(loc)));
+ assert((std::has_facet<std::num_get<wchar_t> >(loc)));
+ assert((std::has_facet<std::num_put<char> >(loc)));
+ assert((std::has_facet<std::num_put<wchar_t> >(loc)));
+
+ assert((std::has_facet<std::time_get<char> >(loc)));
+ assert((std::has_facet<std::time_get<wchar_t> >(loc)));
+ assert((std::has_facet<std::time_put<char> >(loc)));
+ assert((std::has_facet<std::time_put<wchar_t> >(loc)));
+
+ assert((std::has_facet<std::messages<char> >(loc)));
+ assert((std::has_facet<std::messages<wchar_t> >(loc)));
+}
+
+int main()
+{
+ std::locale loc;
+ assert(loc.name() == "C");
+ check(loc);
+ assert(std::locale::global(std::locale(LOCALE_en_US_UTF_8)) == loc);
+ std::locale loc2;
+ check(loc2);
+ assert(loc2 == std::locale(LOCALE_en_US_UTF_8));
+}
diff --git a/test/std/localization/locales/locale/locale.types/locale.category/category.pass.cpp b/test/std/localization/locales/locale/locale.types/locale.category/category.pass.cpp
new file mode 100644
index 000000000000..0087f1943b6e
--- /dev/null
+++ b/test/std/localization/locales/locale/locale.types/locale.category/category.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This test uses new symbols that were not defined in the libc++ shipped on
+// darwin11 and darwin12:
+// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11
+// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12
+
+// <locale>
+
+// typedef int category;
+
+#include <locale>
+#include <type_traits>
+#include <cassert>
+
+template <class _Tp>
+void test(const _Tp &) {}
+
+
+int main()
+{
+ static_assert((std::is_same<std::locale::category, int>::value), "");
+ assert(std::locale::none == 0);
+ assert(std::locale::collate);
+ assert(std::locale::ctype);
+ assert(std::locale::monetary);
+ assert(std::locale::numeric);
+ assert(std::locale::time);
+ assert(std::locale::messages);
+ assert((std::locale::collate
+ & std::locale::ctype
+ & std::locale::monetary
+ & std::locale::numeric
+ & std::locale::time
+ & std::locale::messages) == 0);
+ assert((std::locale::collate
+ | std::locale::ctype
+ | std::locale::monetary
+ | std::locale::numeric
+ | std::locale::time
+ | std::locale::messages)
+ == std::locale::all);
+
+ test(std::locale::none);
+ test(std::locale::collate);
+ test(std::locale::ctype);
+ test(std::locale::monetary);
+ test(std::locale::numeric);
+ test(std::locale::time);
+ test(std::locale::messages);
+ test(std::locale::all);
+}
diff --git a/test/std/localization/locales/locale/locale.types/locale.facet/facet.pass.cpp b/test/std/localization/locales/locale/locale.types/locale.facet/facet.pass.cpp
new file mode 100644
index 000000000000..4a7f77ad5d9a
--- /dev/null
+++ b/test/std/localization/locales/locale/locale.types/locale.facet/facet.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class locale::facet
+// {
+// protected:
+// explicit facet(size_t refs = 0);
+// virtual ~facet();
+// facet(const facet&) = delete;
+// void operator=(const facet&) = delete;
+// };
+
+// This test isn't portable
+
+#include <locale>
+#include <cassert>
+
+struct my_facet
+ : public std::locale::facet
+{
+ static int count;
+ my_facet(unsigned refs = 0)
+ : std::locale::facet(refs)
+ {++count;}
+
+ ~my_facet() {--count;}
+};
+
+int my_facet::count = 0;
+
+int main()
+{
+ my_facet* f = new my_facet;
+ f->__add_shared();
+ assert(my_facet::count == 1);
+ f->__release_shared();
+ assert(my_facet::count == 0);
+ f = new my_facet(1);
+ f->__add_shared();
+ assert(my_facet::count == 1);
+ f->__release_shared();
+ assert(my_facet::count == 1);
+ f->__release_shared();
+ assert(my_facet::count == 0);
+}
diff --git a/test/std/localization/locales/locale/locale.types/locale.id/id.pass.cpp b/test/std/localization/locales/locale/locale.types/locale.id/id.pass.cpp
new file mode 100644
index 000000000000..3233624d87b4
--- /dev/null
+++ b/test/std/localization/locales/locale/locale.types/locale.id/id.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class locale::id
+// {
+// public:
+// id();
+// void operator=(const id&) = delete;
+// id(const id&) = delete;
+// };
+
+// This test isn't portable
+
+#include <locale>
+#include <cassert>
+
+std::locale::id id0;
+std::locale::id id2;
+std::locale::id id1;
+
+int main()
+{
+ long id = id0.__get();
+ assert(id0.__get() == id+0);
+ assert(id0.__get() == id+0);
+ assert(id0.__get() == id+0);
+ assert(id1.__get() == id+1);
+ assert(id1.__get() == id+1);
+ assert(id1.__get() == id+1);
+ assert(id2.__get() == id+2);
+ assert(id2.__get() == id+2);
+ assert(id2.__get() == id+2);
+ assert(id0.__get() == id+0);
+ assert(id0.__get() == id+0);
+ assert(id0.__get() == id+0);
+ assert(id1.__get() == id+1);
+ assert(id1.__get() == id+1);
+ assert(id1.__get() == id+1);
+ assert(id2.__get() == id+2);
+ assert(id2.__get() == id+2);
+ assert(id2.__get() == id+2);
+}
diff --git a/test/std/localization/locales/locale/locale.types/nothing_to_do.pass.cpp b/test/std/localization/locales/locale/locale.types/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/localization/locales/locale/locale.types/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/localization/locales/locale/nothing_to_do.pass.cpp b/test/std/localization/locales/locale/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/localization/locales/locale/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/localization/locales/nothing_to_do.pass.cpp b/test/std/localization/locales/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/localization/locales/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/localization/localization.general/nothing_to_do.pass.cpp b/test/std/localization/localization.general/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/localization/localization.general/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/localization/version.pass.cpp b/test/std/localization/version.pass.cpp
new file mode 100644
index 000000000000..a64534c9f58b
--- /dev/null
+++ b/test/std/localization/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+#include <locale>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/nothing_to_do.pass.cpp b/test/std/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..9a59227abdd9
--- /dev/null
+++ b/test/std/nothing_to_do.pass.cpp
@@ -0,0 +1,13 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/numerics/c.math/cmath.pass.cpp b/test/std/numerics/c.math/cmath.pass.cpp
new file mode 100644
index 000000000000..0b0d86288737
--- /dev/null
+++ b/test/std/numerics/c.math/cmath.pass.cpp
@@ -0,0 +1,1485 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <cmath>
+
+// NOTE: isinf and isnan are tested separately because they are expected to fail
+// on linux. We don't want their expected failure to hide other failures in this file.
+
+#include <cmath>
+#include <type_traits>
+#include <cassert>
+
+#include "hexfloat.h"
+
+// convertible to int/float/double/etc
+template <class T, int N=0>
+struct Value {
+ operator T () { return T(N); }
+};
+
+// See PR21083
+// Ambiguous is a user-defined type that defines its own overloads of cmath
+// functions. When the std overloads are candidates too (by using or adl),
+// they should not interfere.
+struct Ambiguous : std::true_type { // ADL
+ operator float () { return 0.f; }
+ operator double () { return 0.; }
+};
+Ambiguous abs(Ambiguous){ return Ambiguous(); }
+Ambiguous acos(Ambiguous){ return Ambiguous(); }
+Ambiguous asin(Ambiguous){ return Ambiguous(); }
+Ambiguous atan(Ambiguous){ return Ambiguous(); }
+Ambiguous atan2(Ambiguous, Ambiguous){ return Ambiguous(); }
+Ambiguous ceil(Ambiguous){ return Ambiguous(); }
+Ambiguous cos(Ambiguous){ return Ambiguous(); }
+Ambiguous cosh(Ambiguous){ return Ambiguous(); }
+Ambiguous exp(Ambiguous){ return Ambiguous(); }
+Ambiguous fabs(Ambiguous){ return Ambiguous(); }
+Ambiguous floor(Ambiguous){ return Ambiguous(); }
+Ambiguous fmod(Ambiguous, Ambiguous){ return Ambiguous(); }
+Ambiguous frexp(Ambiguous, int*){ return Ambiguous(); }
+Ambiguous ldexp(Ambiguous, int){ return Ambiguous(); }
+Ambiguous log(Ambiguous){ return Ambiguous(); }
+Ambiguous log10(Ambiguous){ return Ambiguous(); }
+Ambiguous modf(Ambiguous, Ambiguous*){ return Ambiguous(); }
+Ambiguous pow(Ambiguous, Ambiguous){ return Ambiguous(); }
+Ambiguous sin(Ambiguous){ return Ambiguous(); }
+Ambiguous sinh(Ambiguous){ return Ambiguous(); }
+Ambiguous sqrt(Ambiguous){ return Ambiguous(); }
+Ambiguous tan(Ambiguous){ return Ambiguous(); }
+Ambiguous tanh(Ambiguous){ return Ambiguous(); }
+Ambiguous signbit(Ambiguous){ return Ambiguous(); }
+Ambiguous fpclassify(Ambiguous){ return Ambiguous(); }
+Ambiguous isfinite(Ambiguous){ return Ambiguous(); }
+Ambiguous isnormal(Ambiguous){ return Ambiguous(); }
+Ambiguous isgreater(Ambiguous, Ambiguous){ return Ambiguous(); }
+Ambiguous isgreaterequal(Ambiguous, Ambiguous){ return Ambiguous(); }
+Ambiguous isless(Ambiguous, Ambiguous){ return Ambiguous(); }
+Ambiguous islessequal(Ambiguous, Ambiguous){ return Ambiguous(); }
+Ambiguous islessgreater(Ambiguous, Ambiguous){ return Ambiguous(); }
+Ambiguous isunordered(Ambiguous, Ambiguous){ return Ambiguous(); }
+Ambiguous acosh(Ambiguous){ return Ambiguous(); }
+Ambiguous asinh(Ambiguous){ return Ambiguous(); }
+Ambiguous atanh(Ambiguous){ return Ambiguous(); }
+Ambiguous cbrt(Ambiguous){ return Ambiguous(); }
+Ambiguous copysign(Ambiguous, Ambiguous){ return Ambiguous(); }
+Ambiguous erf(Ambiguous){ return Ambiguous(); }
+Ambiguous erfc(Ambiguous){ return Ambiguous(); }
+Ambiguous exp2(Ambiguous){ return Ambiguous(); }
+Ambiguous expm1(Ambiguous){ return Ambiguous(); }
+Ambiguous fdim(Ambiguous, Ambiguous){ return Ambiguous(); }
+Ambiguous fma(Ambiguous, Ambiguous, Ambiguous){ return Ambiguous(); }
+Ambiguous fmax(Ambiguous, Ambiguous){ return Ambiguous(); }
+Ambiguous fmin(Ambiguous, Ambiguous){ return Ambiguous(); }
+Ambiguous hypot(Ambiguous, Ambiguous){ return Ambiguous(); }
+Ambiguous ilogb(Ambiguous){ return Ambiguous(); }
+Ambiguous lgamma(Ambiguous){ return Ambiguous(); }
+Ambiguous llrint(Ambiguous){ return Ambiguous(); }
+Ambiguous llround(Ambiguous){ return Ambiguous(); }
+Ambiguous log1p(Ambiguous){ return Ambiguous(); }
+Ambiguous log2(Ambiguous){ return Ambiguous(); }
+Ambiguous logb(Ambiguous){ return Ambiguous(); }
+Ambiguous lrint(Ambiguous){ return Ambiguous(); }
+Ambiguous lround(Ambiguous){ return Ambiguous(); }
+Ambiguous nearbyint(Ambiguous){ return Ambiguous(); }
+Ambiguous nextafter(Ambiguous, Ambiguous){ return Ambiguous(); }
+Ambiguous nexttoward(Ambiguous, Ambiguous){ return Ambiguous(); }
+Ambiguous remainder(Ambiguous, Ambiguous){ return Ambiguous(); }
+Ambiguous remquo(Ambiguous, Ambiguous, int*){ return Ambiguous(); }
+Ambiguous rint(Ambiguous){ return Ambiguous(); }
+Ambiguous round(Ambiguous){ return Ambiguous(); }
+Ambiguous scalbln(Ambiguous, Ambiguous){ return Ambiguous(); }
+Ambiguous scalbn(Ambiguous, Ambiguous){ return Ambiguous(); }
+Ambiguous tgamma(Ambiguous){ return Ambiguous(); }
+Ambiguous trunc(Ambiguous){ return Ambiguous(); }
+
+void test_abs()
+{
+ static_assert((std::is_same<decltype(std::abs((float)0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::abs((double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::abs((long double)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(abs(Ambiguous())), Ambiguous>::value), "");
+ assert(std::abs(-1.) == 1);
+}
+
+void test_acos()
+{
+ static_assert((std::is_same<decltype(std::acos((float)0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::acos((bool)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::acos((unsigned short)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::acos((int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::acos((unsigned int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::acos((long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::acos((unsigned long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::acos((long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::acos((unsigned long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::acos((double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::acos((long double)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::acosf(0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::acosl(0)), long double>::value), "");
+ static_assert((std::is_same<decltype(acos(Ambiguous())), Ambiguous>::value), "");
+ assert(std::acos(1) == 0);
+}
+
+void test_asin()
+{
+ static_assert((std::is_same<decltype(std::asin((float)0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::asin((bool)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::asin((unsigned short)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::asin((int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::asin((unsigned int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::asin((long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::asin((unsigned long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::asin((long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::asin((unsigned long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::asin((double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::asin((long double)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::asinf(0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::asinl(0)), long double>::value), "");
+ static_assert((std::is_same<decltype(asin(Ambiguous())), Ambiguous>::value), "");
+ assert(std::asin(0) == 0);
+}
+
+void test_atan()
+{
+ static_assert((std::is_same<decltype(std::atan((float)0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::atan((bool)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::atan((unsigned short)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::atan((int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::atan((unsigned int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::atan((long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::atan((unsigned long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::atan((long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::atan((unsigned long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::atan((double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::atan((long double)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::atanf(0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::atanl(0)), long double>::value), "");
+ static_assert((std::is_same<decltype(atan(Ambiguous())), Ambiguous>::value), "");
+ assert(std::atan(0) == 0);
+}
+
+void test_atan2()
+{
+ static_assert((std::is_same<decltype(std::atan2((float)0, (float)0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::atan2((bool)0, (float)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::atan2((unsigned short)0, (double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::atan2((int)0, (long double)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::atan2((float)0, (unsigned int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::atan2((double)0, (long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::atan2((long double)0, (unsigned long)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::atan2((int)0, (long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::atan2((int)0, (unsigned long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::atan2((double)0, (double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::atan2((long double)0, (long double)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::atan2((float)0, (double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::atan2((float)0, (long double)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::atan2((double)0, (long double)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::atan2f(0,0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::atan2l(0,0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::atan2((int)0, (int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(atan2(Ambiguous(), Ambiguous())), Ambiguous>::value), "");
+ assert(std::atan2(0,1) == 0);
+}
+
+void test_ceil()
+{
+ static_assert((std::is_same<decltype(std::ceil((float)0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::ceil((bool)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::ceil((unsigned short)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::ceil((int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::ceil((unsigned int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::ceil((long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::ceil((unsigned long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::ceil((long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::ceil((unsigned long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::ceil((double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::ceil((long double)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::ceilf(0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::ceill(0)), long double>::value), "");
+ static_assert((std::is_same<decltype(ceil(Ambiguous())), Ambiguous>::value), "");
+ assert(std::ceil(0) == 0);
+}
+
+void test_cos()
+{
+ static_assert((std::is_same<decltype(std::cos((float)0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::cos((bool)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::cos((unsigned short)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::cos((int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::cos((unsigned int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::cos((long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::cos((unsigned long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::cos((long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::cos((unsigned long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::cos((double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::cos((long double)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::cosf(0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::cosl(0)), long double>::value), "");
+ static_assert((std::is_same<decltype(cos(Ambiguous())), Ambiguous>::value), "");
+ assert(std::cos(0) == 1);
+}
+
+void test_cosh()
+{
+ static_assert((std::is_same<decltype(std::cosh((float)0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::cosh((bool)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::cosh((unsigned short)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::cosh((int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::cosh((unsigned int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::cosh((long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::cosh((unsigned long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::cosh((long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::cosh((unsigned long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::cosh((double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::cosh((long double)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::coshf(0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::coshl(0)), long double>::value), "");
+ static_assert((std::is_same<decltype(cosh(Ambiguous())), Ambiguous>::value), "");
+ assert(std::cosh(0) == 1);
+}
+
+void test_exp()
+{
+ static_assert((std::is_same<decltype(std::exp((float)0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::exp((bool)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::exp((unsigned short)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::exp((int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::exp((unsigned int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::exp((long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::exp((unsigned long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::exp((long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::exp((unsigned long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::exp((double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::exp((long double)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::expf(0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::expl(0)), long double>::value), "");
+ static_assert((std::is_same<decltype(exp(Ambiguous())), Ambiguous>::value), "");
+ assert(std::exp(0) == 1);
+}
+
+void test_fabs()
+{
+ static_assert((std::is_same<decltype(std::fabs((float)0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::fabs((bool)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::fabs((unsigned short)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::fabs((int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::fabs((unsigned int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::fabs((long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::fabs((unsigned long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::fabs((long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::fabs((unsigned long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::fabs((double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::fabs((long double)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::fabsf(0.0f)), float>::value), "");
+ static_assert((std::is_same<decltype(std::fabsl(0.0L)), long double>::value), "");
+ static_assert((std::is_same<decltype(fabs(Ambiguous())), Ambiguous>::value), "");
+ assert(std::fabs(-1) == 1);
+}
+
+void test_floor()
+{
+ static_assert((std::is_same<decltype(std::floor((float)0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::floor((bool)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::floor((unsigned short)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::floor((int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::floor((unsigned int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::floor((long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::floor((unsigned long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::floor((long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::floor((unsigned long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::floor((double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::floor((long double)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::floorf(0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::floorl(0)), long double>::value), "");
+ static_assert((std::is_same<decltype(floor(Ambiguous())), Ambiguous>::value), "");
+ assert(std::floor(1) == 1);
+}
+
+void test_fmod()
+{
+ static_assert((std::is_same<decltype(std::fmod((float)0, (float)0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::fmod((bool)0, (float)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::fmod((unsigned short)0, (double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::fmod((int)0, (long double)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::fmod((float)0, (unsigned int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::fmod((double)0, (long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::fmod((long double)0, (unsigned long)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::fmod((int)0, (long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::fmod((int)0, (unsigned long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::fmod((double)0, (double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::fmod((long double)0, (long double)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::fmod((float)0, (double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::fmod((float)0, (long double)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::fmod((double)0, (long double)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::fmodf(0,0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::fmodl(0,0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::fmod((int)0, (int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(fmod(Ambiguous(), Ambiguous())), Ambiguous>::value), "");
+ assert(std::fmod(1.5,1) == .5);
+}
+
+void test_frexp()
+{
+ int ip;
+ static_assert((std::is_same<decltype(std::frexp((float)0, &ip)), float>::value), "");
+ static_assert((std::is_same<decltype(std::frexp((bool)0, &ip)), double>::value), "");
+ static_assert((std::is_same<decltype(std::frexp((unsigned short)0, &ip)), double>::value), "");
+ static_assert((std::is_same<decltype(std::frexp((int)0, &ip)), double>::value), "");
+ static_assert((std::is_same<decltype(std::frexp((unsigned int)0, &ip)), double>::value), "");
+ static_assert((std::is_same<decltype(std::frexp((long)0, &ip)), double>::value), "");
+ static_assert((std::is_same<decltype(std::frexp((unsigned long)0, &ip)), double>::value), "");
+ static_assert((std::is_same<decltype(std::frexp((long long)0, &ip)), double>::value), "");
+ static_assert((std::is_same<decltype(std::frexp((unsigned long long)0, &ip)), double>::value), "");
+ static_assert((std::is_same<decltype(std::frexp((double)0, &ip)), double>::value), "");
+ static_assert((std::is_same<decltype(std::frexp((long double)0, &ip)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::frexpf(0, &ip)), float>::value), "");
+ static_assert((std::is_same<decltype(std::frexpl(0, &ip)), long double>::value), "");
+ static_assert((std::is_same<decltype(frexp(Ambiguous(), &ip)), Ambiguous>::value), "");
+ assert(std::frexp(0, &ip) == 0);
+}
+
+void test_ldexp()
+{
+ int ip = 1;
+ static_assert((std::is_same<decltype(std::ldexp((float)0, ip)), float>::value), "");
+ static_assert((std::is_same<decltype(std::ldexp((bool)0, ip)), double>::value), "");
+ static_assert((std::is_same<decltype(std::ldexp((unsigned short)0, ip)), double>::value), "");
+ static_assert((std::is_same<decltype(std::ldexp((int)0, ip)), double>::value), "");
+ static_assert((std::is_same<decltype(std::ldexp((unsigned int)0, ip)), double>::value), "");
+ static_assert((std::is_same<decltype(std::ldexp((long)0, ip)), double>::value), "");
+ static_assert((std::is_same<decltype(std::ldexp((unsigned long)0, ip)), double>::value), "");
+ static_assert((std::is_same<decltype(std::ldexp((long long)0, ip)), double>::value), "");
+ static_assert((std::is_same<decltype(std::ldexp((unsigned long long)0, ip)), double>::value), "");
+ static_assert((std::is_same<decltype(std::ldexp((double)0, ip)), double>::value), "");
+ static_assert((std::is_same<decltype(std::ldexp((long double)0, ip)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::ldexpf(0, ip)), float>::value), "");
+ static_assert((std::is_same<decltype(std::ldexpl(0, ip)), long double>::value), "");
+ static_assert((std::is_same<decltype(ldexp(Ambiguous(), ip)), Ambiguous>::value), "");
+ assert(std::ldexp(1, ip) == 2);
+}
+
+void test_log()
+{
+ static_assert((std::is_same<decltype(std::log((float)0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::log((bool)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::log((unsigned short)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::log((int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::log((unsigned int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::log((long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::log((unsigned long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::log((long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::log((unsigned long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::log((double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::log((long double)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::logf(0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::logl(0)), long double>::value), "");
+ static_assert((std::is_same<decltype(log(Ambiguous())), Ambiguous>::value), "");
+ assert(std::log(1) == 0);
+}
+
+void test_log10()
+{
+ static_assert((std::is_same<decltype(std::log10((float)0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::log10((bool)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::log10((unsigned short)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::log10((int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::log10((unsigned int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::log10((long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::log10((unsigned long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::log10((long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::log10((unsigned long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::log10((double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::log10((long double)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::log10f(0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::log10l(0)), long double>::value), "");
+ static_assert((std::is_same<decltype(log10(Ambiguous())), Ambiguous>::value), "");
+ assert(std::log10(1) == 0);
+}
+
+void test_modf()
+{
+ static_assert((std::is_same<decltype(std::modf((float)0, (float*)0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::modf((double)0, (double*)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::modf((long double)0, (long double*)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::modff(0, (float*)0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::modfl(0, (long double*)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(modf(Ambiguous(), (Ambiguous*)0)), Ambiguous>::value), "");
+ double i;
+ assert(std::modf(1., &i) == 0);
+}
+
+void test_pow()
+{
+ static_assert((std::is_same<decltype(std::pow((float)0, (float)0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::pow((bool)0, (float)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::pow((unsigned short)0, (double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::pow((int)0, (long double)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::pow((float)0, (unsigned int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::pow((double)0, (long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::pow((long double)0, (unsigned long)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::pow((int)0, (long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::pow((int)0, (unsigned long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::pow((double)0, (double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::pow((long double)0, (long double)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::pow((float)0, (double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::pow((float)0, (long double)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::pow((double)0, (long double)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::powf(0,0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::powl(0,0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::pow((int)0, (int)0)), double>::value), "");
+// static_assert((std::is_same<decltype(std::pow(Value<int>(), (int)0)), double>::value), "");
+// static_assert((std::is_same<decltype(std::pow(Value<long double>(), (float)0)), long double>::value), "");
+// static_assert((std::is_same<decltype(std::pow((float) 0, Value<float>())), float>::value), "");
+ static_assert((std::is_same<decltype(pow(Ambiguous(), Ambiguous())), Ambiguous>::value), "");
+ assert(std::pow(1,1) == 1);
+// assert(std::pow(Value<int,1>(), Value<float,1>()) == 1);
+// assert(std::pow(1.0f, Value<double,1>()) == 1);
+// assert(std::pow(1.0, Value<int,1>()) == 1);
+// assert(std::pow(Value<long double,1>(), 1LL) == 1);
+}
+
+void test_sin()
+{
+ static_assert((std::is_same<decltype(std::sin((float)0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::sin((bool)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::sin((unsigned short)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::sin((int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::sin((unsigned int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::sin((long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::sin((unsigned long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::sin((long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::sin((unsigned long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::sin((double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::sin((long double)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::sinf(0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::sinl(0)), long double>::value), "");
+ static_assert((std::is_same<decltype(sin(Ambiguous())), Ambiguous>::value), "");
+ assert(std::sin(0) == 0);
+}
+
+void test_sinh()
+{
+ static_assert((std::is_same<decltype(std::sinh((float)0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::sinh((bool)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::sinh((unsigned short)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::sinh((int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::sinh((unsigned int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::sinh((long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::sinh((unsigned long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::sinh((long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::sinh((unsigned long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::sinh((double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::sinh((long double)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::sinhf(0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::sinhl(0)), long double>::value), "");
+ static_assert((std::is_same<decltype(sinh(Ambiguous())), Ambiguous>::value), "");
+ assert(std::sinh(0) == 0);
+}
+
+void test_sqrt()
+{
+ static_assert((std::is_same<decltype(std::sqrt((float)0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::sqrt((bool)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::sqrt((unsigned short)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::sqrt((int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::sqrt((unsigned int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::sqrt((long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::sqrt((unsigned long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::sqrt((long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::sqrt((unsigned long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::sqrt((double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::sqrt((long double)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::sqrtf(0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::sqrtl(0)), long double>::value), "");
+ static_assert((std::is_same<decltype(sqrt(Ambiguous())), Ambiguous>::value), "");
+ assert(std::sqrt(4) == 2);
+}
+
+void test_tan()
+{
+ static_assert((std::is_same<decltype(std::tan((float)0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::tan((bool)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::tan((unsigned short)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::tan((int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::tan((unsigned int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::tan((long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::tan((unsigned long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::tan((long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::tan((unsigned long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::tan((double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::tan((long double)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::tanf(0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::tanl(0)), long double>::value), "");
+ static_assert((std::is_same<decltype(tan(Ambiguous())), Ambiguous>::value), "");
+ assert(std::tan(0) == 0);
+}
+
+void test_tanh()
+{
+ static_assert((std::is_same<decltype(std::tanh((float)0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::tanh((bool)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::tanh((unsigned short)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::tanh((int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::tanh((unsigned int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::tanh((long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::tanh((unsigned long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::tanh((long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::tanh((unsigned long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::tanh((double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::tanh((long double)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::tanhf(0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::tanhl(0)), long double>::value), "");
+ static_assert((std::is_same<decltype(tanh(Ambiguous())), Ambiguous>::value), "");
+ assert(std::tanh(0) == 0);
+}
+
+void test_signbit()
+{
+#ifdef signbit
+#error signbit defined
+#endif
+ static_assert((std::is_same<decltype(std::signbit((float)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(std::signbit((double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(std::signbit(0)), bool>::value), "");
+ static_assert((std::is_same<decltype(std::signbit((long double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(signbit(Ambiguous())), Ambiguous>::value), "");
+ assert(std::signbit(-1.0) == true);
+}
+
+void test_fpclassify()
+{
+#ifdef fpclassify
+#error fpclassify defined
+#endif
+ static_assert((std::is_same<decltype(std::fpclassify((float)0)), int>::value), "");
+ static_assert((std::is_same<decltype(std::fpclassify((double)0)), int>::value), "");
+ static_assert((std::is_same<decltype(std::fpclassify(0)), int>::value), "");
+ static_assert((std::is_same<decltype(std::fpclassify((long double)0)), int>::value), "");
+ static_assert((std::is_same<decltype(fpclassify(Ambiguous())), Ambiguous>::value), "");
+ assert(std::fpclassify(-1.0) == FP_NORMAL);
+}
+
+void test_isfinite()
+{
+#ifdef isfinite
+#error isfinite defined
+#endif
+ static_assert((std::is_same<decltype(std::isfinite((float)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(std::isfinite((double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(std::isfinite(0)), bool>::value), "");
+ static_assert((std::is_same<decltype(std::isfinite((long double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(isfinite(Ambiguous())), Ambiguous>::value), "");
+ assert(std::isfinite(-1.0) == true);
+}
+
+void test_isnormal()
+{
+#ifdef isnormal
+#error isnormal defined
+#endif
+ static_assert((std::is_same<decltype(std::isnormal((float)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(std::isnormal((double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(std::isnormal(0)), bool>::value), "");
+ static_assert((std::is_same<decltype(std::isnormal((long double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(isnormal(Ambiguous())), Ambiguous>::value), "");
+ assert(std::isnormal(-1.0) == true);
+}
+
+void test_isgreater()
+{
+#ifdef isgreater
+#error isgreater defined
+#endif
+ static_assert((std::is_same<decltype(std::isgreater((float)0, (float)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(std::isgreater((float)0, (double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(std::isgreater((float)0, (long double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(std::isgreater((double)0, (float)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(std::isgreater((double)0, (double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(std::isgreater(0, (double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(std::isgreater((double)0, (long double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(std::isgreater((long double)0, (float)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(std::isgreater((long double)0, (double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(std::isgreater((long double)0, (long double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(isgreater(Ambiguous(), Ambiguous())), Ambiguous>::value), "");
+ assert(std::isgreater(-1.0, 0.F) == false);
+}
+
+void test_isgreaterequal()
+{
+#ifdef isgreaterequal
+#error isgreaterequal defined
+#endif
+ static_assert((std::is_same<decltype(std::isgreaterequal((float)0, (float)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(std::isgreaterequal((float)0, (double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(std::isgreaterequal((float)0, (long double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(std::isgreaterequal((double)0, (float)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(std::isgreaterequal((double)0, (double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(std::isgreaterequal(0, (double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(std::isgreaterequal((double)0, (long double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(std::isgreaterequal((long double)0, (float)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(std::isgreaterequal((long double)0, (double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(std::isgreaterequal((long double)0, (long double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(isgreaterequal(Ambiguous(), Ambiguous())), Ambiguous>::value), "");
+ assert(std::isgreaterequal(-1.0, 0.F) == false);
+}
+
+void test_isless()
+{
+#ifdef isless
+#error isless defined
+#endif
+ static_assert((std::is_same<decltype(std::isless((float)0, (float)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(std::isless((float)0, (double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(std::isless((float)0, (long double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(std::isless((double)0, (float)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(std::isless((double)0, (double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(std::isless(0, (double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(std::isless((double)0, (long double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(std::isless((long double)0, (float)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(std::isless((long double)0, (double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(std::isless((long double)0, (long double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(isless(Ambiguous(), Ambiguous())), Ambiguous>::value), "");
+ assert(std::isless(-1.0, 0.F) == true);
+}
+
+void test_islessequal()
+{
+#ifdef islessequal
+#error islessequal defined
+#endif
+ static_assert((std::is_same<decltype(std::islessequal((float)0, (float)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(std::islessequal((float)0, (double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(std::islessequal((float)0, (long double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(std::islessequal((double)0, (float)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(std::islessequal((double)0, (double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(std::islessequal(0, (double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(std::islessequal((double)0, (long double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(std::islessequal((long double)0, (float)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(std::islessequal((long double)0, (double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(std::islessequal((long double)0, (long double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(islessequal(Ambiguous(), Ambiguous())), Ambiguous>::value), "");
+ assert(std::islessequal(-1.0, 0.F) == true);
+}
+
+void test_islessgreater()
+{
+#ifdef islessgreater
+#error islessgreater defined
+#endif
+ static_assert((std::is_same<decltype(std::islessgreater((float)0, (float)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(std::islessgreater((float)0, (double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(std::islessgreater((float)0, (long double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(std::islessgreater((double)0, (float)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(std::islessgreater((double)0, (double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(std::islessgreater(0, (double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(std::islessgreater((double)0, (long double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(std::islessgreater((long double)0, (float)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(std::islessgreater((long double)0, (double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(std::islessgreater((long double)0, (long double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(islessgreater(Ambiguous(), Ambiguous())), Ambiguous>::value), "");
+ assert(std::islessgreater(-1.0, 0.F) == true);
+}
+
+void test_isunordered()
+{
+#ifdef isunordered
+#error isunordered defined
+#endif
+ static_assert((std::is_same<decltype(std::isunordered((float)0, (float)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(std::isunordered((float)0, (double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(std::isunordered((float)0, (long double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(std::isunordered((double)0, (float)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(std::isunordered((double)0, (double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(std::isunordered(0, (double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(std::isunordered((double)0, (long double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(std::isunordered((long double)0, (float)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(std::isunordered((long double)0, (double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(std::isunordered((long double)0, (long double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(isunordered(Ambiguous(), Ambiguous())), Ambiguous>::value), "");
+ assert(std::isunordered(-1.0, 0.F) == false);
+}
+
+void test_acosh()
+{
+ static_assert((std::is_same<decltype(std::acosh((float)0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::acosh((bool)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::acosh((unsigned short)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::acosh((int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::acosh((unsigned int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::acosh((long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::acosh((unsigned long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::acosh((long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::acosh((unsigned long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::acosh((double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::acosh((long double)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::acoshf(0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::acoshl(0)), long double>::value), "");
+ static_assert((std::is_same<decltype(acosh(Ambiguous())), Ambiguous>::value), "");
+ assert(std::acosh(1) == 0);
+}
+
+void test_asinh()
+{
+ static_assert((std::is_same<decltype(std::asinh((float)0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::asinh((bool)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::asinh((unsigned short)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::asinh((int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::asinh((unsigned int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::asinh((long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::asinh((unsigned long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::asinh((long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::asinh((unsigned long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::asinh((double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::asinh((long double)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::asinhf(0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::asinhl(0)), long double>::value), "");
+ static_assert((std::is_same<decltype(asinh(Ambiguous())), Ambiguous>::value), "");
+ assert(std::asinh(0) == 0);
+}
+
+void test_atanh()
+{
+ static_assert((std::is_same<decltype(std::atanh((float)0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::atanh((bool)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::atanh((unsigned short)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::atanh((int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::atanh((unsigned int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::atanh((long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::atanh((unsigned long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::atanh((long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::atanh((unsigned long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::atanh((double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::atanh((long double)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::atanhf(0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::atanhl(0)), long double>::value), "");
+ static_assert((std::is_same<decltype(atanh(Ambiguous())), Ambiguous>::value), "");
+ assert(std::atanh(0) == 0);
+}
+
+void test_cbrt()
+{
+ static_assert((std::is_same<decltype(std::cbrt((float)0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::cbrt((bool)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::cbrt((unsigned short)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::cbrt((int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::cbrt((unsigned int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::cbrt((long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::cbrt((unsigned long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::cbrt((long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::cbrt((unsigned long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::cbrt((double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::cbrt((long double)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::cbrtf(0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::cbrtl(0)), long double>::value), "");
+ static_assert((std::is_same<decltype(cbrt(Ambiguous())), Ambiguous>::value), "");
+ assert(std::cbrt(1) == 1);
+}
+
+void test_copysign()
+{
+ static_assert((std::is_same<decltype(std::copysign((float)0, (float)0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::copysign((bool)0, (float)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::copysign((unsigned short)0, (double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::copysign((int)0, (long double)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::copysign((float)0, (unsigned int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::copysign((double)0, (long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::copysign((long double)0, (unsigned long)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::copysign((int)0, (long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::copysign((int)0, (unsigned long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::copysign((double)0, (double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::copysign((long double)0, (long double)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::copysign((float)0, (double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::copysign((float)0, (long double)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::copysign((double)0, (long double)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::copysignf(0,0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::copysignl(0,0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::copysign((int)0, (int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(copysign(Ambiguous(), Ambiguous())), Ambiguous>::value), "");
+ assert(std::copysign(1,1) == 1);
+}
+
+void test_erf()
+{
+ static_assert((std::is_same<decltype(std::erf((float)0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::erf((bool)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::erf((unsigned short)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::erf((int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::erf((unsigned int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::erf((long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::erf((unsigned long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::erf((long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::erf((unsigned long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::erf((double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::erf((long double)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::erff(0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::erfl(0)), long double>::value), "");
+ static_assert((std::is_same<decltype(erf(Ambiguous())), Ambiguous>::value), "");
+ assert(std::erf(0) == 0);
+}
+
+void test_erfc()
+{
+ static_assert((std::is_same<decltype(std::erfc((float)0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::erfc((bool)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::erfc((unsigned short)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::erfc((int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::erfc((unsigned int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::erfc((long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::erfc((unsigned long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::erfc((long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::erfc((unsigned long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::erfc((double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::erfc((long double)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::erfcf(0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::erfcl(0)), long double>::value), "");
+ static_assert((std::is_same<decltype(erfc(Ambiguous())), Ambiguous>::value), "");
+ assert(std::erfc(0) == 1);
+}
+
+void test_exp2()
+{
+ static_assert((std::is_same<decltype(std::exp2((float)0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::exp2((bool)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::exp2((unsigned short)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::exp2((int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::exp2((unsigned int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::exp2((long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::exp2((unsigned long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::exp2((long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::exp2((unsigned long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::exp2((double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::exp2((long double)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::exp2f(0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::exp2l(0)), long double>::value), "");
+ static_assert((std::is_same<decltype(exp2(Ambiguous())), Ambiguous>::value), "");
+ assert(std::exp2(1) == 2);
+}
+
+void test_expm1()
+{
+ static_assert((std::is_same<decltype(std::expm1((float)0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::expm1((bool)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::expm1((unsigned short)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::expm1((int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::expm1((unsigned int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::expm1((long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::expm1((unsigned long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::expm1((long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::expm1((unsigned long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::expm1((double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::expm1((long double)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::expm1f(0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::expm1l(0)), long double>::value), "");
+ static_assert((std::is_same<decltype(expm1(Ambiguous())), Ambiguous>::value), "");
+ assert(std::expm1(0) == 0);
+}
+
+void test_fdim()
+{
+ static_assert((std::is_same<decltype(std::fdim((float)0, (float)0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::fdim((bool)0, (float)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::fdim((unsigned short)0, (double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::fdim((int)0, (long double)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::fdim((float)0, (unsigned int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::fdim((double)0, (long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::fdim((long double)0, (unsigned long)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::fdim((int)0, (long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::fdim((int)0, (unsigned long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::fdim((double)0, (double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::fdim((long double)0, (long double)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::fdim((float)0, (double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::fdim((float)0, (long double)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::fdim((double)0, (long double)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::fdimf(0,0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::fdiml(0,0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::fdim((int)0, (int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(fdim(Ambiguous(), Ambiguous())), Ambiguous>::value), "");
+ assert(std::fdim(1,0) == 1);
+}
+
+void test_fma()
+{
+ static_assert((std::is_same<decltype(std::fma((bool)0, (float)0, (float)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::fma((char)0, (float)0, (float)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::fma((unsigned)0, (float)0, (float)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::fma((float)0, (int)0, (float)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::fma((float)0, (long)0, (float)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::fma((float)0, (float)0, (unsigned long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::fma((float)0, (float)0, (double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::fma((float)0, (float)0, (long double)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::fma((float)0, (float)0, (float)0)), float>::value), "");
+
+ static_assert((std::is_same<decltype(std::fma((bool)0, (double)0, (double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::fma((char)0, (double)0, (double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::fma((unsigned)0, (double)0, (double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::fma((double)0, (int)0, (double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::fma((double)0, (long)0, (double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::fma((double)0, (double)0, (unsigned long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::fma((double)0, (double)0, (float)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::fma((double)0, (double)0, (long double)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::fma((double)0, (double)0, (double)0)), double>::value), "");
+
+ static_assert((std::is_same<decltype(std::fma((bool)0, (long double)0, (long double)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::fma((char)0, (long double)0, (long double)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::fma((unsigned)0, (long double)0, (long double)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::fma((long double)0, (int)0, (long double)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::fma((long double)0, (long)0, (long double)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::fma((long double)0, (long double)0, (unsigned long long)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::fma((long double)0, (long double)0, (float)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::fma((double)0, (long double)0, (long double)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::fma((long double)0, (long double)0, (long double)0)), long double>::value), "");
+
+ static_assert((std::is_same<decltype(std::fmaf(0,0,0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::fmal(0,0,0)), long double>::value), "");
+ static_assert((std::is_same<decltype(fma(Ambiguous(), Ambiguous(), Ambiguous())), Ambiguous>::value), "");
+ assert(std::fma(1,1,1) == 2);
+}
+
+void test_fmax()
+{
+ static_assert((std::is_same<decltype(std::fmax((float)0, (float)0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::fmax((bool)0, (float)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::fmax((unsigned short)0, (double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::fmax((int)0, (long double)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::fmax((float)0, (unsigned int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::fmax((double)0, (long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::fmax((long double)0, (unsigned long)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::fmax((int)0, (long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::fmax((int)0, (unsigned long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::fmax((double)0, (double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::fmax((long double)0, (long double)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::fmax((float)0, (double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::fmax((float)0, (long double)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::fmax((double)0, (long double)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::fmaxf(0,0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::fmaxl(0,0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::fmax((int)0, (int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(fmax(Ambiguous(), Ambiguous())), Ambiguous>::value), "");
+ assert(std::fmax(1,0) == 1);
+}
+
+void test_fmin()
+{
+ static_assert((std::is_same<decltype(std::fmin((float)0, (float)0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::fmin((bool)0, (float)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::fmin((unsigned short)0, (double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::fmin((int)0, (long double)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::fmin((float)0, (unsigned int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::fmin((double)0, (long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::fmin((long double)0, (unsigned long)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::fmin((int)0, (long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::fmin((int)0, (unsigned long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::fmin((double)0, (double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::fmin((long double)0, (long double)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::fmin((float)0, (double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::fmin((float)0, (long double)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::fmin((double)0, (long double)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::fminf(0,0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::fminl(0,0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::fmin((int)0, (int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(fmin(Ambiguous(), Ambiguous())), Ambiguous>::value), "");
+ assert(std::fmin(1,0) == 0);
+}
+
+void test_hypot()
+{
+ static_assert((std::is_same<decltype(std::hypot((float)0, (float)0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::hypot((bool)0, (float)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::hypot((unsigned short)0, (double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::hypot((int)0, (long double)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::hypot((float)0, (unsigned int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::hypot((double)0, (long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::hypot((long double)0, (unsigned long)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::hypot((int)0, (long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::hypot((int)0, (unsigned long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::hypot((double)0, (double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::hypot((long double)0, (long double)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::hypot((float)0, (double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::hypot((float)0, (long double)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::hypot((double)0, (long double)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::hypotf(0,0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::hypotl(0,0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::hypot((int)0, (int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(hypot(Ambiguous(), Ambiguous())), Ambiguous>::value), "");
+ assert(std::hypot(3,4) == 5);
+}
+
+void test_ilogb()
+{
+ static_assert((std::is_same<decltype(std::ilogb((float)0)), int>::value), "");
+ static_assert((std::is_same<decltype(std::ilogb((bool)0)), int>::value), "");
+ static_assert((std::is_same<decltype(std::ilogb((unsigned short)0)), int>::value), "");
+ static_assert((std::is_same<decltype(std::ilogb((int)0)), int>::value), "");
+ static_assert((std::is_same<decltype(std::ilogb((unsigned int)0)), int>::value), "");
+ static_assert((std::is_same<decltype(std::ilogb((long)0)), int>::value), "");
+ static_assert((std::is_same<decltype(std::ilogb((unsigned long)0)), int>::value), "");
+ static_assert((std::is_same<decltype(std::ilogb((long long)0)), int>::value), "");
+ static_assert((std::is_same<decltype(std::ilogb((unsigned long long)0)), int>::value), "");
+ static_assert((std::is_same<decltype(std::ilogb((double)0)), int>::value), "");
+ static_assert((std::is_same<decltype(std::ilogb((long double)0)), int>::value), "");
+ static_assert((std::is_same<decltype(std::ilogbf(0)), int>::value), "");
+ static_assert((std::is_same<decltype(std::ilogbl(0)), int>::value), "");
+ static_assert((std::is_same<decltype(ilogb(Ambiguous())), Ambiguous>::value), "");
+ assert(std::ilogb(1) == 0);
+}
+
+void test_lgamma()
+{
+ static_assert((std::is_same<decltype(std::lgamma((float)0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::lgamma((bool)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::lgamma((unsigned short)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::lgamma((int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::lgamma((unsigned int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::lgamma((long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::lgamma((unsigned long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::lgamma((long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::lgamma((unsigned long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::lgamma((double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::lgamma((long double)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::lgammaf(0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::lgammal(0)), long double>::value), "");
+ static_assert((std::is_same<decltype(lgamma(Ambiguous())), Ambiguous>::value), "");
+ assert(std::lgamma(1) == 0);
+}
+
+void test_llrint()
+{
+ static_assert((std::is_same<decltype(std::llrint((float)0)), long long>::value), "");
+ static_assert((std::is_same<decltype(std::llrint((bool)0)), long long>::value), "");
+ static_assert((std::is_same<decltype(std::llrint((unsigned short)0)), long long>::value), "");
+ static_assert((std::is_same<decltype(std::llrint((int)0)), long long>::value), "");
+ static_assert((std::is_same<decltype(std::llrint((unsigned int)0)), long long>::value), "");
+ static_assert((std::is_same<decltype(std::llrint((long)0)), long long>::value), "");
+ static_assert((std::is_same<decltype(std::llrint((unsigned long)0)), long long>::value), "");
+ static_assert((std::is_same<decltype(std::llrint((long long)0)), long long>::value), "");
+ static_assert((std::is_same<decltype(std::llrint((unsigned long long)0)), long long>::value), "");
+ static_assert((std::is_same<decltype(std::llrint((double)0)), long long>::value), "");
+ static_assert((std::is_same<decltype(std::llrint((long double)0)), long long>::value), "");
+ static_assert((std::is_same<decltype(std::llrintf(0)), long long>::value), "");
+ static_assert((std::is_same<decltype(std::llrintl(0)), long long>::value), "");
+ static_assert((std::is_same<decltype(llrint(Ambiguous())), Ambiguous>::value), "");
+ assert(std::llrint(1) == 1LL);
+}
+
+void test_llround()
+{
+ static_assert((std::is_same<decltype(std::llround((float)0)), long long>::value), "");
+ static_assert((std::is_same<decltype(std::llround((bool)0)), long long>::value), "");
+ static_assert((std::is_same<decltype(std::llround((unsigned short)0)), long long>::value), "");
+ static_assert((std::is_same<decltype(std::llround((int)0)), long long>::value), "");
+ static_assert((std::is_same<decltype(std::llround((unsigned int)0)), long long>::value), "");
+ static_assert((std::is_same<decltype(std::llround((long)0)), long long>::value), "");
+ static_assert((std::is_same<decltype(std::llround((unsigned long)0)), long long>::value), "");
+ static_assert((std::is_same<decltype(std::llround((long long)0)), long long>::value), "");
+ static_assert((std::is_same<decltype(std::llround((unsigned long long)0)), long long>::value), "");
+ static_assert((std::is_same<decltype(std::llround((double)0)), long long>::value), "");
+ static_assert((std::is_same<decltype(std::llround((long double)0)), long long>::value), "");
+ static_assert((std::is_same<decltype(std::llroundf(0)), long long>::value), "");
+ static_assert((std::is_same<decltype(std::llroundl(0)), long long>::value), "");
+ static_assert((std::is_same<decltype(llround(Ambiguous())), Ambiguous>::value), "");
+ assert(std::llround(1) == 1LL);
+}
+
+void test_log1p()
+{
+ static_assert((std::is_same<decltype(std::log1p((float)0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::log1p((bool)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::log1p((unsigned short)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::log1p((int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::log1p((unsigned int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::log1p((long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::log1p((unsigned long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::log1p((long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::log1p((unsigned long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::log1p((double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::log1p((long double)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::log1pf(0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::log1pl(0)), long double>::value), "");
+ static_assert((std::is_same<decltype(log1p(Ambiguous())), Ambiguous>::value), "");
+ assert(std::log1p(0) == 0);
+}
+
+void test_log2()
+{
+ static_assert((std::is_same<decltype(std::log2((float)0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::log2((bool)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::log2((unsigned short)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::log2((int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::log2((unsigned int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::log2((long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::log2((unsigned long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::log2((long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::log2((unsigned long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::log2((double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::log2((long double)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::log2f(0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::log2l(0)), long double>::value), "");
+ static_assert((std::is_same<decltype(log2(Ambiguous())), Ambiguous>::value), "");
+ assert(std::log2(1) == 0);
+}
+
+void test_logb()
+{
+ static_assert((std::is_same<decltype(std::logb((float)0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::logb((bool)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::logb((unsigned short)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::logb((int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::logb((unsigned int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::logb((long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::logb((unsigned long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::logb((long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::logb((unsigned long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::logb((double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::logb((long double)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::logbf(0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::logbl(0)), long double>::value), "");
+ static_assert((std::is_same<decltype(logb(Ambiguous())), Ambiguous>::value), "");
+ assert(std::logb(1) == 0);
+}
+
+void test_lrint()
+{
+ static_assert((std::is_same<decltype(std::lrint((float)0)), long>::value), "");
+ static_assert((std::is_same<decltype(std::lrint((bool)0)), long>::value), "");
+ static_assert((std::is_same<decltype(std::lrint((unsigned short)0)), long>::value), "");
+ static_assert((std::is_same<decltype(std::lrint((int)0)), long>::value), "");
+ static_assert((std::is_same<decltype(std::lrint((unsigned int)0)), long>::value), "");
+ static_assert((std::is_same<decltype(std::lrint((long)0)), long>::value), "");
+ static_assert((std::is_same<decltype(std::lrint((unsigned long)0)), long>::value), "");
+ static_assert((std::is_same<decltype(std::lrint((long long)0)), long>::value), "");
+ static_assert((std::is_same<decltype(std::lrint((unsigned long long)0)), long>::value), "");
+ static_assert((std::is_same<decltype(std::lrint((double)0)), long>::value), "");
+ static_assert((std::is_same<decltype(std::lrint((long double)0)), long>::value), "");
+ static_assert((std::is_same<decltype(std::lrintf(0)), long>::value), "");
+ static_assert((std::is_same<decltype(std::lrintl(0)), long>::value), "");
+ static_assert((std::is_same<decltype(lrint(Ambiguous())), Ambiguous>::value), "");
+ assert(std::lrint(1) == 1L);
+}
+
+void test_lround()
+{
+ static_assert((std::is_same<decltype(std::lround((float)0)), long>::value), "");
+ static_assert((std::is_same<decltype(std::lround((bool)0)), long>::value), "");
+ static_assert((std::is_same<decltype(std::lround((unsigned short)0)), long>::value), "");
+ static_assert((std::is_same<decltype(std::lround((int)0)), long>::value), "");
+ static_assert((std::is_same<decltype(std::lround((unsigned int)0)), long>::value), "");
+ static_assert((std::is_same<decltype(std::lround((long)0)), long>::value), "");
+ static_assert((std::is_same<decltype(std::lround((unsigned long)0)), long>::value), "");
+ static_assert((std::is_same<decltype(std::lround((long long)0)), long>::value), "");
+ static_assert((std::is_same<decltype(std::lround((unsigned long long)0)), long>::value), "");
+ static_assert((std::is_same<decltype(std::lround((double)0)), long>::value), "");
+ static_assert((std::is_same<decltype(std::lround((long double)0)), long>::value), "");
+ static_assert((std::is_same<decltype(std::lroundf(0)), long>::value), "");
+ static_assert((std::is_same<decltype(std::lroundl(0)), long>::value), "");
+ static_assert((std::is_same<decltype(lround(Ambiguous())), Ambiguous>::value), "");
+ assert(std::lround(1) == 1L);
+}
+
+void test_nan()
+{
+ static_assert((std::is_same<decltype(std::nan("")), double>::value), "");
+ static_assert((std::is_same<decltype(std::nanf("")), float>::value), "");
+ static_assert((std::is_same<decltype(std::nanl("")), long double>::value), "");
+}
+
+void test_nearbyint()
+{
+ static_assert((std::is_same<decltype(std::nearbyint((float)0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::nearbyint((bool)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::nearbyint((unsigned short)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::nearbyint((int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::nearbyint((unsigned int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::nearbyint((long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::nearbyint((unsigned long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::nearbyint((long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::nearbyint((unsigned long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::nearbyint((double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::nearbyint((long double)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::nearbyintf(0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::nearbyintl(0)), long double>::value), "");
+ static_assert((std::is_same<decltype(nearbyint(Ambiguous())), Ambiguous>::value), "");
+ assert(std::nearbyint(1) == 1);
+}
+
+void test_nextafter()
+{
+ static_assert((std::is_same<decltype(std::nextafter((float)0, (float)0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::nextafter((bool)0, (float)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::nextafter((unsigned short)0, (double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::nextafter((int)0, (long double)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::nextafter((float)0, (unsigned int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::nextafter((double)0, (long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::nextafter((long double)0, (unsigned long)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::nextafter((int)0, (long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::nextafter((int)0, (unsigned long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::nextafter((double)0, (double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::nextafter((long double)0, (long double)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::nextafter((float)0, (double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::nextafter((float)0, (long double)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::nextafter((double)0, (long double)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::nextafterf(0,0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::nextafterl(0,0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::nextafter((int)0, (int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(nextafter(Ambiguous(), Ambiguous())), Ambiguous>::value), "");
+ assert(std::nextafter(0,1) == hexfloat<double>(0x1, 0, -1074));
+}
+
+void test_nexttoward()
+{
+ static_assert((std::is_same<decltype(std::nexttoward((float)0, (long double)0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::nexttoward((bool)0, (long double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::nexttoward((unsigned short)0, (long double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::nexttoward((int)0, (long double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::nexttoward((unsigned int)0, (long double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::nexttoward((long)0, (long double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::nexttoward((unsigned long)0, (long double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::nexttoward((long long)0, (long double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::nexttoward((unsigned long long)0, (long double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::nexttoward((double)0, (long double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::nexttoward((long double)0, (long double)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::nexttowardf(0, (long double)0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::nexttowardl(0, (long double)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(nexttoward(Ambiguous(), Ambiguous())), Ambiguous>::value), "");
+ assert(std::nexttoward(0, 1) == hexfloat<double>(0x1, 0, -1074));
+}
+
+void test_remainder()
+{
+ static_assert((std::is_same<decltype(std::remainder((float)0, (float)0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::remainder((bool)0, (float)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::remainder((unsigned short)0, (double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::remainder((int)0, (long double)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::remainder((float)0, (unsigned int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::remainder((double)0, (long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::remainder((long double)0, (unsigned long)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::remainder((int)0, (long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::remainder((int)0, (unsigned long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::remainder((double)0, (double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::remainder((long double)0, (long double)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::remainder((float)0, (double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::remainder((float)0, (long double)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::remainder((double)0, (long double)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::remainderf(0,0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::remainderl(0,0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::remainder((int)0, (int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(remainder(Ambiguous(), Ambiguous())), Ambiguous>::value), "");
+ assert(std::remainder(0.5,1) == 0.5);
+}
+
+void test_remquo()
+{
+ int ip;
+ static_assert((std::is_same<decltype(std::remquo((float)0, (float)0, &ip)), float>::value), "");
+ static_assert((std::is_same<decltype(std::remquo((bool)0, (float)0, &ip)), double>::value), "");
+ static_assert((std::is_same<decltype(std::remquo((unsigned short)0, (double)0, &ip)), double>::value), "");
+ static_assert((std::is_same<decltype(std::remquo((int)0, (long double)0, &ip)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::remquo((float)0, (unsigned int)0, &ip)), double>::value), "");
+ static_assert((std::is_same<decltype(std::remquo((double)0, (long)0, &ip)), double>::value), "");
+ static_assert((std::is_same<decltype(std::remquo((long double)0, (unsigned long)0, &ip)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::remquo((int)0, (long long)0, &ip)), double>::value), "");
+ static_assert((std::is_same<decltype(std::remquo((int)0, (unsigned long long)0, &ip)), double>::value), "");
+ static_assert((std::is_same<decltype(std::remquo((double)0, (double)0, &ip)), double>::value), "");
+ static_assert((std::is_same<decltype(std::remquo((long double)0, (long double)0, &ip)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::remquo((float)0, (double)0, &ip)), double>::value), "");
+ static_assert((std::is_same<decltype(std::remquo((float)0, (long double)0, &ip)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::remquo((double)0, (long double)0, &ip)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::remquof(0,0, &ip)), float>::value), "");
+ static_assert((std::is_same<decltype(std::remquol(0,0, &ip)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::remquo((int)0, (int)0, &ip)), double>::value), "");
+ static_assert((std::is_same<decltype(remquo(Ambiguous(), Ambiguous(), &ip)), Ambiguous>::value), "");
+ assert(std::remquo(0.5,1, &ip) == 0.5);
+}
+
+void test_rint()
+{
+ static_assert((std::is_same<decltype(std::rint((float)0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::rint((bool)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::rint((unsigned short)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::rint((int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::rint((unsigned int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::rint((long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::rint((unsigned long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::rint((long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::rint((unsigned long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::rint((double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::rint((long double)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::rintf(0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::rintl(0)), long double>::value), "");
+ static_assert((std::is_same<decltype(rint(Ambiguous())), Ambiguous>::value), "");
+ assert(std::rint(1) == 1);
+}
+
+void test_round()
+{
+ static_assert((std::is_same<decltype(std::round((float)0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::round((bool)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::round((unsigned short)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::round((int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::round((unsigned int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::round((long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::round((unsigned long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::round((long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::round((unsigned long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::round((double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::round((long double)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::roundf(0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::roundl(0)), long double>::value), "");
+ static_assert((std::is_same<decltype(round(Ambiguous())), Ambiguous>::value), "");
+ assert(std::round(1) == 1);
+}
+
+void test_scalbln()
+{
+ static_assert((std::is_same<decltype(std::scalbln((float)0, (long)0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::scalbln((bool)0, (long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::scalbln((unsigned short)0, (long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::scalbln((int)0, (long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::scalbln((unsigned int)0, (long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::scalbln((long)0, (long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::scalbln((unsigned long)0, (long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::scalbln((long long)0, (long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::scalbln((unsigned long long)0, (long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::scalbln((double)0, (long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::scalbln((long double)0, (long)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::scalblnf(0, (long)0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::scalblnl(0, (long)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(scalbln(Ambiguous(), Ambiguous())), Ambiguous>::value), "");
+ assert(std::scalbln(1, 1) == 2);
+}
+
+void test_scalbn()
+{
+ static_assert((std::is_same<decltype(std::scalbn((float)0, (int)0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::scalbn((bool)0, (int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::scalbn((unsigned short)0, (int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::scalbn((int)0, (int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::scalbn((unsigned int)0, (int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::scalbn((long)0, (int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::scalbn((unsigned long)0, (int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::scalbn((long long)0, (int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::scalbn((unsigned long long)0, (int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::scalbn((double)0, (int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::scalbn((long double)0, (int)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::scalbnf(0, (int)0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::scalbnl(0, (int)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(scalbn(Ambiguous(), Ambiguous())), Ambiguous>::value), "");
+ assert(std::scalbn(1, 1) == 2);
+}
+
+void test_tgamma()
+{
+ static_assert((std::is_same<decltype(std::tgamma((float)0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::tgamma((bool)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::tgamma((unsigned short)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::tgamma((int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::tgamma((unsigned int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::tgamma((long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::tgamma((unsigned long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::tgamma((long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::tgamma((unsigned long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::tgamma((double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::tgamma((long double)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::tgammaf(0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::tgammal(0)), long double>::value), "");
+ static_assert((std::is_same<decltype(tgamma(Ambiguous())), Ambiguous>::value), "");
+ assert(std::tgamma(1) == 1);
+}
+
+void test_trunc()
+{
+ static_assert((std::is_same<decltype(std::trunc((float)0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::trunc((bool)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::trunc((unsigned short)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::trunc((int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::trunc((unsigned int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::trunc((long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::trunc((unsigned long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::trunc((long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::trunc((unsigned long long)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::trunc((double)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::trunc((long double)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::truncf(0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::truncl(0)), long double>::value), "");
+ static_assert((std::is_same<decltype(trunc(Ambiguous())), Ambiguous>::value), "");
+ assert(std::trunc(1) == 1);
+}
+
+int main()
+{
+ test_abs();
+ test_acos();
+ test_asin();
+ test_atan();
+ test_atan2();
+ test_ceil();
+ test_cos();
+ test_cosh();
+ test_exp();
+ test_fabs();
+ test_floor();
+ test_fmod();
+ test_frexp();
+ test_ldexp();
+ test_log();
+ test_log10();
+ test_modf();
+ test_pow();
+ test_sin();
+ test_sinh();
+ test_sqrt();
+ test_tan();
+ test_tanh();
+ test_signbit();
+ test_fpclassify();
+ test_isfinite();
+ test_isnormal();
+ test_isgreater();
+ test_isgreaterequal();
+ test_isless();
+ test_islessequal();
+ test_islessgreater();
+ test_isunordered();
+ test_acosh();
+ test_asinh();
+ test_atanh();
+ test_cbrt();
+ test_copysign();
+ test_erf();
+ test_erfc();
+ test_exp2();
+ test_expm1();
+ test_fdim();
+ test_fma();
+ test_fmax();
+ test_fmin();
+ test_hypot();
+ test_ilogb();
+ test_lgamma();
+ test_llrint();
+ test_llround();
+ test_log1p();
+ test_log2();
+ test_logb();
+ test_lrint();
+ test_lround();
+ test_nan();
+ test_nearbyint();
+ test_nextafter();
+ test_nexttoward();
+ test_remainder();
+ test_remquo();
+ test_rint();
+ test_round();
+ test_scalbln();
+ test_scalbn();
+ test_tgamma();
+ test_trunc();
+}
diff --git a/test/std/numerics/c.math/cmath_isinf.pass.cpp b/test/std/numerics/c.math/cmath_isinf.pass.cpp
new file mode 100644
index 000000000000..6cde04d9bc86
--- /dev/null
+++ b/test/std/numerics/c.math/cmath_isinf.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <cmath>
+
+// isinf
+
+// XFAIL: linux
+
+#include <cmath>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+#ifdef isinf
+#error isinf defined
+#endif
+ static_assert((std::is_same<decltype(std::isinf((float)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(std::isinf((double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(std::isinf(0)), bool>::value), "");
+ static_assert((std::is_same<decltype(std::isinf((long double)0)), bool>::value), "");
+ assert(std::isinf(-1.0) == false);
+} \ No newline at end of file
diff --git a/test/std/numerics/c.math/cmath_isnan.pass.cpp b/test/std/numerics/c.math/cmath_isnan.pass.cpp
new file mode 100644
index 000000000000..7b33b9647052
--- /dev/null
+++ b/test/std/numerics/c.math/cmath_isnan.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <cmath>
+
+// isnan
+
+// XFAIL: linux
+
+#include <cmath>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+#ifdef isnan
+#error isnan defined
+#endif
+ static_assert((std::is_same<decltype(std::isnan((float)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(std::isnan((double)0)), bool>::value), "");
+ static_assert((std::is_same<decltype(std::isnan(0)), bool>::value), "");
+ static_assert((std::is_same<decltype(std::isnan((long double)0)), bool>::value), "");
+ assert(std::isnan(-1.0) == false);
+}
diff --git a/test/std/numerics/c.math/ctgmath.pass.cpp b/test/std/numerics/c.math/ctgmath.pass.cpp
new file mode 100644
index 000000000000..278217e04840
--- /dev/null
+++ b/test/std/numerics/c.math/ctgmath.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ctgmath>
+
+#include <ctgmath>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+ std::complex<double> cd;
+ double x = std::sin(0);
+}
diff --git a/test/std/numerics/c.math/tgmath_h.pass.cpp b/test/std/numerics/c.math/tgmath_h.pass.cpp
new file mode 100644
index 000000000000..23143c7140a6
--- /dev/null
+++ b/test/std/numerics/c.math/tgmath_h.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tgmath.h>
+
+#include <tgmath.h>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/numerics/c.math/version_cmath.pass.cpp b/test/std/numerics/c.math/version_cmath.pass.cpp
new file mode 100644
index 000000000000..1249a902e7af
--- /dev/null
+++ b/test/std/numerics/c.math/version_cmath.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <cmath>
+
+#include <cmath>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/numerics/cfenv/cfenv.syn/cfenv.pass.cpp b/test/std/numerics/cfenv/cfenv.syn/cfenv.pass.cpp
new file mode 100644
index 000000000000..fcf075a36e1a
--- /dev/null
+++ b/test/std/numerics/cfenv/cfenv.syn/cfenv.pass.cpp
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: newlib
+
+// <cfenv>
+
+#include <cfenv>
+#include <type_traits>
+
+#ifndef FE_DIVBYZERO
+#error FE_DIVBYZERO not defined
+#endif
+
+#ifndef FE_INEXACT
+#error FE_INEXACT not defined
+#endif
+
+#ifndef FE_INVALID
+#error FE_INVALID not defined
+#endif
+
+#ifndef FE_OVERFLOW
+#error FE_OVERFLOW not defined
+#endif
+
+#ifndef FE_UNDERFLOW
+#error FE_UNDERFLOW not defined
+#endif
+
+#ifndef FE_ALL_EXCEPT
+#error FE_ALL_EXCEPT not defined
+#endif
+
+#ifndef FE_DOWNWARD
+#error FE_DOWNWARD not defined
+#endif
+
+#ifndef FE_TONEAREST
+#error FE_TONEAREST not defined
+#endif
+
+#ifndef FE_TOWARDZERO
+#error FE_TOWARDZERO not defined
+#endif
+
+#ifndef FE_UPWARD
+#error FE_UPWARD not defined
+#endif
+
+#ifndef FE_DFL_ENV
+#error FE_DFL_ENV not defined
+#endif
+
+int main()
+{
+ std::fenv_t fenv;
+ std::fexcept_t fex;
+ static_assert((std::is_same<decltype(std::feclearexcept(0)), int>::value), "");
+ static_assert((std::is_same<decltype(std::fegetexceptflag(&fex, 0)), int>::value), "");
+ static_assert((std::is_same<decltype(std::feraiseexcept(0)), int>::value), "");
+ static_assert((std::is_same<decltype(std::fesetexceptflag(&fex, 0)), int>::value), "");
+ static_assert((std::is_same<decltype(std::fetestexcept(0)), int>::value), "");
+ static_assert((std::is_same<decltype(std::fegetround()), int>::value), "");
+ static_assert((std::is_same<decltype(std::fesetround(0)), int>::value), "");
+ static_assert((std::is_same<decltype(std::fegetenv(&fenv)), int>::value), "");
+ static_assert((std::is_same<decltype(std::feholdexcept(&fenv)), int>::value), "");
+ static_assert((std::is_same<decltype(std::fesetenv(&fenv)), int>::value), "");
+ static_assert((std::is_same<decltype(std::feupdateenv(&fenv)), int>::value), "");
+}
diff --git a/test/std/numerics/cfenv/version.pass.cpp b/test/std/numerics/cfenv/version.pass.cpp
new file mode 100644
index 000000000000..727d5bdf3994
--- /dev/null
+++ b/test/std/numerics/cfenv/version.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: newlib
+
+// <cfenv>
+
+#include <cfenv>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/numerics/complex.number/cases.h b/test/std/numerics/complex.number/cases.h
new file mode 100644
index 000000000000..cd6bd165a9d1
--- /dev/null
+++ b/test/std/numerics/complex.number/cases.h
@@ -0,0 +1,230 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// test cases
+
+#ifndef CASES_H
+#define CASES_H
+
+#include <complex>
+#include <cassert>
+
+std::complex<double> x[] =
+{
+ std::complex<double>( 1.e-6, 1.e-6),
+ std::complex<double>(-1.e-6, 1.e-6),
+ std::complex<double>(-1.e-6, -1.e-6),
+ std::complex<double>( 1.e-6, -1.e-6),
+
+ std::complex<double>( 1.e+6, 1.e-6),
+ std::complex<double>(-1.e+6, 1.e-6),
+ std::complex<double>(-1.e+6, -1.e-6),
+ std::complex<double>( 1.e+6, -1.e-6),
+
+ std::complex<double>( 1.e-6, 1.e+6),
+ std::complex<double>(-1.e-6, 1.e+6),
+ std::complex<double>(-1.e-6, -1.e+6),
+ std::complex<double>( 1.e-6, -1.e+6),
+
+ std::complex<double>( 1.e+6, 1.e+6),
+ std::complex<double>(-1.e+6, 1.e+6),
+ std::complex<double>(-1.e+6, -1.e+6),
+ std::complex<double>( 1.e+6, -1.e+6),
+
+ std::complex<double>(NAN, NAN),
+ std::complex<double>(-INFINITY, NAN),
+ std::complex<double>(-2, NAN),
+ std::complex<double>(-1, NAN),
+ std::complex<double>(-0.5, NAN),
+ std::complex<double>(-0., NAN),
+ std::complex<double>(+0., NAN),
+ std::complex<double>(0.5, NAN),
+ std::complex<double>(1, NAN),
+ std::complex<double>(2, NAN),
+ std::complex<double>(INFINITY, NAN),
+
+ std::complex<double>(NAN, -INFINITY),
+ std::complex<double>(-INFINITY, -INFINITY),
+ std::complex<double>(-2, -INFINITY),
+ std::complex<double>(-1, -INFINITY),
+ std::complex<double>(-0.5, -INFINITY),
+ std::complex<double>(-0., -INFINITY),
+ std::complex<double>(+0., -INFINITY),
+ std::complex<double>(0.5, -INFINITY),
+ std::complex<double>(1, -INFINITY),
+ std::complex<double>(2, -INFINITY),
+ std::complex<double>(INFINITY, -INFINITY),
+
+ std::complex<double>(NAN, -2),
+ std::complex<double>(-INFINITY, -2),
+ std::complex<double>(-2, -2),
+ std::complex<double>(-1, -2),
+ std::complex<double>(-0.5, -2),
+ std::complex<double>(-0., -2),
+ std::complex<double>(+0., -2),
+ std::complex<double>(0.5, -2),
+ std::complex<double>(1, -2),
+ std::complex<double>(2, -2),
+ std::complex<double>(INFINITY, -2),
+
+ std::complex<double>(NAN, -1),
+ std::complex<double>(-INFINITY, -1),
+ std::complex<double>(-2, -1),
+ std::complex<double>(-1, -1),
+ std::complex<double>(-0.5, -1),
+ std::complex<double>(-0., -1),
+ std::complex<double>(+0., -1),
+ std::complex<double>(0.5, -1),
+ std::complex<double>(1, -1),
+ std::complex<double>(2, -1),
+ std::complex<double>(INFINITY, -1),
+
+ std::complex<double>(NAN, -0.5),
+ std::complex<double>(-INFINITY, -0.5),
+ std::complex<double>(-2, -0.5),
+ std::complex<double>(-1, -0.5),
+ std::complex<double>(-0.5, -0.5),
+ std::complex<double>(-0., -0.5),
+ std::complex<double>(+0., -0.5),
+ std::complex<double>(0.5, -0.5),
+ std::complex<double>(1, -0.5),
+ std::complex<double>(2, -0.5),
+ std::complex<double>(INFINITY, -0.5),
+
+ std::complex<double>(NAN, -0.),
+ std::complex<double>(-INFINITY, -0.),
+ std::complex<double>(-2, -0.),
+ std::complex<double>(-1, -0.),
+ std::complex<double>(-0.5, -0.),
+ std::complex<double>(-0., -0.),
+ std::complex<double>(+0., -0.),
+ std::complex<double>(0.5, -0.),
+ std::complex<double>(1, -0.),
+ std::complex<double>(2, -0.),
+ std::complex<double>(INFINITY, -0.),
+
+ std::complex<double>(NAN, +0.),
+ std::complex<double>(-INFINITY, +0.),
+ std::complex<double>(-2, +0.),
+ std::complex<double>(-1, +0.),
+ std::complex<double>(-0.5, +0.),
+ std::complex<double>(-0., +0.),
+ std::complex<double>(+0., +0.),
+ std::complex<double>(0.5, +0.),
+ std::complex<double>(1, +0.),
+ std::complex<double>(2, +0.),
+ std::complex<double>(INFINITY, +0.),
+
+ std::complex<double>(NAN, 0.5),
+ std::complex<double>(-INFINITY, 0.5),
+ std::complex<double>(-2, 0.5),
+ std::complex<double>(-1, 0.5),
+ std::complex<double>(-0.5, 0.5),
+ std::complex<double>(-0., 0.5),
+ std::complex<double>(+0., 0.5),
+ std::complex<double>(0.5, 0.5),
+ std::complex<double>(1, 0.5),
+ std::complex<double>(2, 0.5),
+ std::complex<double>(INFINITY, 0.5),
+
+ std::complex<double>(NAN, 1),
+ std::complex<double>(-INFINITY, 1),
+ std::complex<double>(-2, 1),
+ std::complex<double>(-1, 1),
+ std::complex<double>(-0.5, 1),
+ std::complex<double>(-0., 1),
+ std::complex<double>(+0., 1),
+ std::complex<double>(0.5, 1),
+ std::complex<double>(1, 1),
+ std::complex<double>(2, 1),
+ std::complex<double>(INFINITY, 1),
+
+ std::complex<double>(NAN, 2),
+ std::complex<double>(-INFINITY, 2),
+ std::complex<double>(-2, 2),
+ std::complex<double>(-1, 2),
+ std::complex<double>(-0.5, 2),
+ std::complex<double>(-0., 2),
+ std::complex<double>(+0., 2),
+ std::complex<double>(0.5, 2),
+ std::complex<double>(1, 2),
+ std::complex<double>(2, 2),
+ std::complex<double>(INFINITY, 2),
+
+ std::complex<double>(NAN, INFINITY),
+ std::complex<double>(-INFINITY, INFINITY),
+ std::complex<double>(-2, INFINITY),
+ std::complex<double>(-1, INFINITY),
+ std::complex<double>(-0.5, INFINITY),
+ std::complex<double>(-0., INFINITY),
+ std::complex<double>(+0., INFINITY),
+ std::complex<double>(0.5, INFINITY),
+ std::complex<double>(1, INFINITY),
+ std::complex<double>(2, INFINITY),
+ std::complex<double>(INFINITY, INFINITY)
+};
+
+enum {zero, non_zero, inf, NaN, non_zero_nan};
+
+template <class T>
+int
+classify(const std::complex<T>& x)
+{
+ if (x == std::complex<T>())
+ return zero;
+ if (std::isinf(x.real()) || std::isinf(x.imag()))
+ return inf;
+ if (std::isnan(x.real()) && std::isnan(x.imag()))
+ return NaN;
+ if (std::isnan(x.real()))
+ {
+ if (x.imag() == T(0))
+ return NaN;
+ return non_zero_nan;
+ }
+ if (std::isnan(x.imag()))
+ {
+ if (x.real() == T(0))
+ return NaN;
+ return non_zero_nan;
+ }
+ return non_zero;
+}
+
+inline
+int
+classify(double x)
+{
+ if (x == 0)
+ return zero;
+ if (std::isinf(x))
+ return inf;
+ if (std::isnan(x))
+ return NaN;
+ return non_zero;
+}
+
+void is_about(float x, float y)
+{
+ assert(std::abs((x-y)/(x+y)) < 1.e-6);
+}
+
+void is_about(double x, double y)
+{
+ assert(std::abs((x-y)/(x+y)) < 1.e-14);
+}
+
+void is_about(long double x, long double y)
+{
+ assert(std::abs((x-y)/(x+y)) < 1.e-14);
+}
+
+#endif // CASES_H
diff --git a/test/std/numerics/complex.number/ccmplx/ccomplex.pass.cpp b/test/std/numerics/complex.number/ccmplx/ccomplex.pass.cpp
new file mode 100644
index 000000000000..21aaa669fd43
--- /dev/null
+++ b/test/std/numerics/complex.number/ccmplx/ccomplex.pass.cpp
@@ -0,0 +1,21 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ccomplex>
+
+#include <ccomplex>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+ std::complex<double> d;
+}
diff --git a/test/std/numerics/complex.number/cmplx.over/arg.pass.cpp b/test/std/numerics/complex.number/cmplx.over/arg.pass.cpp
new file mode 100644
index 000000000000..978c6255ac38
--- /dev/null
+++ b/test/std/numerics/complex.number/cmplx.over/arg.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<Arithmetic T>
+// T
+// arg(T x);
+
+#include <complex>
+#include <type_traits>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(T x, typename std::enable_if<std::is_integral<T>::value>::type* = 0)
+{
+ static_assert((std::is_same<decltype(std::arg(x)), double>::value), "");
+ assert(std::arg(x) == arg(std::complex<double>(x, 0)));
+}
+
+template <class T>
+void
+test(T x, typename std::enable_if<!std::is_integral<T>::value>::type* = 0)
+{
+ static_assert((std::is_same<decltype(std::arg(x)), T>::value), "");
+ assert(std::arg(x) == arg(std::complex<T>(x, 0)));
+}
+
+template <class T>
+void
+test()
+{
+ test<T>(0);
+ test<T>(1);
+ test<T>(10);
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+ test<int>();
+ test<unsigned>();
+ test<long long>();
+}
diff --git a/test/std/numerics/complex.number/cmplx.over/conj.pass.cpp b/test/std/numerics/complex.number/cmplx.over/conj.pass.cpp
new file mode 100644
index 000000000000..6adbf21ec26f
--- /dev/null
+++ b/test/std/numerics/complex.number/cmplx.over/conj.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T> complex<T> conj(const complex<T>&);
+// complex<long double> conj(long double);
+// complex<double> conj(double);
+// template<Integral T> complex<double> conj(T);
+// complex<float> conj(float);
+
+#include <complex>
+#include <type_traits>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(T x, typename std::enable_if<std::is_integral<T>::value>::type* = 0)
+{
+ static_assert((std::is_same<decltype(std::conj(x)), std::complex<double> >::value), "");
+ assert(std::conj(x) == conj(std::complex<double>(x, 0)));
+}
+
+template <class T>
+void
+test(T x, typename std::enable_if<std::is_floating_point<T>::value>::type* = 0)
+{
+ static_assert((std::is_same<decltype(std::conj(x)), std::complex<T> >::value), "");
+ assert(std::conj(x) == conj(std::complex<T>(x, 0)));
+}
+
+template <class T>
+void
+test(T x, typename std::enable_if<!std::is_integral<T>::value &&
+ !std::is_floating_point<T>::value>::type* = 0)
+{
+ static_assert((std::is_same<decltype(std::conj(x)), std::complex<T> >::value), "");
+ assert(std::conj(x) == conj(std::complex<T>(x, 0)));
+}
+
+template <class T>
+void
+test()
+{
+ test<T>(0);
+ test<T>(1);
+ test<T>(10);
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+ test<int>();
+ test<unsigned>();
+ test<long long>();
+}
diff --git a/test/std/numerics/complex.number/cmplx.over/imag.pass.cpp b/test/std/numerics/complex.number/cmplx.over/imag.pass.cpp
new file mode 100644
index 000000000000..30c95c3c88d9
--- /dev/null
+++ b/test/std/numerics/complex.number/cmplx.over/imag.pass.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<Arithmetic T>
+// T
+// imag(const T& x);
+
+#include <complex>
+#include <type_traits>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T, int x>
+void
+test(typename std::enable_if<std::is_integral<T>::value>::type* = 0)
+{
+ static_assert((std::is_same<decltype(std::imag(T(x))), double>::value), "");
+ assert(std::imag(x) == 0);
+#if _LIBCPP_STD_VER > 11
+ constexpr T val {x};
+ static_assert(std::imag(val) == 0, "");
+ constexpr std::complex<T> t{val, val};
+ static_assert(t.imag() == x, "" );
+#endif
+}
+
+template <class T, int x>
+void
+test(typename std::enable_if<!std::is_integral<T>::value>::type* = 0)
+{
+ static_assert((std::is_same<decltype(std::imag(T(x))), T>::value), "");
+ assert(std::imag(x) == 0);
+#if _LIBCPP_STD_VER > 11
+ constexpr T val {x};
+ static_assert(std::imag(val) == 0, "");
+ constexpr std::complex<T> t{val, val};
+ static_assert(t.imag() == x, "" );
+#endif
+}
+
+template <class T>
+void
+test()
+{
+ test<T, 0>();
+ test<T, 1>();
+ test<T, 10>();
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+ test<int>();
+ test<unsigned>();
+ test<long long>();
+}
diff --git a/test/std/numerics/complex.number/cmplx.over/norm.pass.cpp b/test/std/numerics/complex.number/cmplx.over/norm.pass.cpp
new file mode 100644
index 000000000000..badd5c0cc85f
--- /dev/null
+++ b/test/std/numerics/complex.number/cmplx.over/norm.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<Arithmetic T>
+// T
+// norm(T x);
+
+#include <complex>
+#include <type_traits>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(T x, typename std::enable_if<std::is_integral<T>::value>::type* = 0)
+{
+ static_assert((std::is_same<decltype(std::norm(x)), double>::value), "");
+ assert(std::norm(x) == norm(std::complex<double>(x, 0)));
+}
+
+template <class T>
+void
+test(T x, typename std::enable_if<!std::is_integral<T>::value>::type* = 0)
+{
+ static_assert((std::is_same<decltype(std::norm(x)), T>::value), "");
+ assert(std::norm(x) == norm(std::complex<T>(x, 0)));
+}
+
+template <class T>
+void
+test()
+{
+ test<T>(0);
+ test<T>(1);
+ test<T>(10);
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+ test<int>();
+ test<unsigned>();
+ test<long long>();
+}
diff --git a/test/std/numerics/complex.number/cmplx.over/pow.pass.cpp b/test/std/numerics/complex.number/cmplx.over/pow.pass.cpp
new file mode 100644
index 000000000000..3b1e9b34b35c
--- /dev/null
+++ b/test/std/numerics/complex.number/cmplx.over/pow.pass.cpp
@@ -0,0 +1,104 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<Arithmetic T, Arithmetic U>
+// complex<promote<T, U>::type>
+// pow(const T& x, const complex<U>& y);
+
+// template<Arithmetic T, Arithmetic U>
+// complex<promote<T, U>::type>
+// pow(const complex<T>& x, const U& y);
+
+// template<Arithmetic T, Arithmetic U>
+// complex<promote<T, U>::type>
+// pow(const complex<T>& x, const complex<U>& y);
+
+#include <complex>
+#include <type_traits>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+double
+promote(T, typename std::enable_if<std::is_integral<T>::value>::type* = 0);
+
+float promote(float);
+double promote(double);
+long double promote(long double);
+
+template <class T, class U>
+void
+test(T x, const std::complex<U>& y)
+{
+ typedef decltype(promote(x)+promote(real(y))) V;
+ static_assert((std::is_same<decltype(std::pow(x, y)), std::complex<V> >::value), "");
+ assert(std::pow(x, y) == pow(std::complex<V>(x, 0), std::complex<V>(y)));
+}
+
+template <class T, class U>
+void
+test(const std::complex<T>& x, U y)
+{
+ typedef decltype(promote(real(x))+promote(y)) V;
+ static_assert((std::is_same<decltype(std::pow(x, y)), std::complex<V> >::value), "");
+ assert(std::pow(x, y) == pow(std::complex<V>(x), std::complex<V>(y, 0)));
+}
+
+template <class T, class U>
+void
+test(const std::complex<T>& x, const std::complex<U>& y)
+{
+ typedef decltype(promote(real(x))+promote(real(y))) V;
+ static_assert((std::is_same<decltype(std::pow(x, y)), std::complex<V> >::value), "");
+ assert(std::pow(x, y) == pow(std::complex<V>(x), std::complex<V>(y)));
+}
+
+template <class T, class U>
+void
+test(typename std::enable_if<std::is_integral<T>::value>::type* = 0, typename std::enable_if<!std::is_integral<U>::value>::type* = 0)
+{
+ test(T(3), std::complex<U>(4, 5));
+ test(std::complex<U>(3, 4), T(5));
+}
+
+template <class T, class U>
+void
+test(typename std::enable_if<!std::is_integral<T>::value>::type* = 0, typename std::enable_if<!std::is_integral<U>::value>::type* = 0)
+{
+ test(T(3), std::complex<U>(4, 5));
+ test(std::complex<T>(3, 4), U(5));
+ test(std::complex<T>(3, 4), std::complex<U>(5, 6));
+}
+
+int main()
+{
+ test<int, float>();
+ test<int, double>();
+ test<int, long double>();
+
+ test<unsigned, float>();
+ test<unsigned, double>();
+ test<unsigned, long double>();
+
+ test<long long, float>();
+ test<long long, double>();
+ test<long long, long double>();
+
+ test<float, double>();
+ test<float, long double>();
+
+ test<double, float>();
+ test<double, long double>();
+
+ test<long double, float>();
+ test<long double, double>();
+}
diff --git a/test/std/numerics/complex.number/cmplx.over/proj.pass.cpp b/test/std/numerics/complex.number/cmplx.over/proj.pass.cpp
new file mode 100644
index 000000000000..60d6e7223e51
--- /dev/null
+++ b/test/std/numerics/complex.number/cmplx.over/proj.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T> complex<T> proj(const complex<T>&);
+// complex<long double> proj(long double);
+// complex<double> proj(double);
+// template<Integral T> complex<double> proj(T);
+// complex<float> proj(float);
+
+#include <complex>
+#include <type_traits>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(T x, typename std::enable_if<std::is_integral<T>::value>::type* = 0)
+{
+ static_assert((std::is_same<decltype(std::proj(x)), std::complex<double> >::value), "");
+ assert(std::proj(x) == proj(std::complex<double>(x, 0)));
+}
+
+template <class T>
+void
+test(T x, typename std::enable_if<std::is_floating_point<T>::value>::type* = 0)
+{
+ static_assert((std::is_same<decltype(std::proj(x)), std::complex<T> >::value), "");
+ assert(std::proj(x) == proj(std::complex<T>(x, 0)));
+}
+
+template <class T>
+void
+test(T x, typename std::enable_if<!std::is_integral<T>::value &&
+ !std::is_floating_point<T>::value>::type* = 0)
+{
+ static_assert((std::is_same<decltype(std::proj(x)), std::complex<T> >::value), "");
+ assert(std::proj(x) == proj(std::complex<T>(x, 0)));
+}
+
+template <class T>
+void
+test()
+{
+ test<T>(0);
+ test<T>(1);
+ test<T>(10);
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+ test<int>();
+ test<unsigned>();
+ test<long long>();
+}
diff --git a/test/std/numerics/complex.number/cmplx.over/real.pass.cpp b/test/std/numerics/complex.number/cmplx.over/real.pass.cpp
new file mode 100644
index 000000000000..a5a4a35b13ca
--- /dev/null
+++ b/test/std/numerics/complex.number/cmplx.over/real.pass.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<Arithmetic T>
+// T
+// real(const T& x);
+
+#include <complex>
+#include <type_traits>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T, int x>
+void
+test(typename std::enable_if<std::is_integral<T>::value>::type* = 0)
+{
+ static_assert((std::is_same<decltype(std::real(T(x))), double>::value), "");
+ assert(std::real(x) == x);
+#if _LIBCPP_STD_VER > 11
+ constexpr T val {x};
+ static_assert(std::real(val) == val, "");
+ constexpr std::complex<T> t{val, val};
+ static_assert(t.real() == x, "" );
+#endif
+}
+
+template <class T, int x>
+void
+test(typename std::enable_if<!std::is_integral<T>::value>::type* = 0)
+{
+ static_assert((std::is_same<decltype(std::real(T(x))), T>::value), "");
+ assert(std::real(x) == x);
+#if _LIBCPP_STD_VER > 11
+ constexpr T val {x};
+ static_assert(std::real(val) == val, "");
+ constexpr std::complex<T> t{val, val};
+ static_assert(t.real() == x, "" );
+#endif
+}
+
+template <class T>
+void
+test()
+{
+ test<T, 0>();
+ test<T, 1>();
+ test<T, 10>();
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+ test<int>();
+ test<unsigned>();
+ test<long long>();
+}
diff --git a/test/std/numerics/complex.number/complex.literals/literals.pass.cpp b/test/std/numerics/complex.number/complex.literals/literals.pass.cpp
new file mode 100644
index 000000000000..45b59914e7f8
--- /dev/null
+++ b/test/std/numerics/complex.number/complex.literals/literals.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+#include <complex>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ using namespace std::literals::complex_literals;
+
+// Make sure the types are right
+ static_assert ( std::is_same<decltype( 3.0il ), std::complex<long double>>::value, "" );
+ static_assert ( std::is_same<decltype( 3il ), std::complex<long double>>::value, "" );
+ static_assert ( std::is_same<decltype( 3.0i ), std::complex<double>>::value, "" );
+ static_assert ( std::is_same<decltype( 3i ), std::complex<double>>::value, "" );
+ static_assert ( std::is_same<decltype( 3.0if ), std::complex<float>>::value, "" );
+ static_assert ( std::is_same<decltype( 3if ), std::complex<float>>::value, "" );
+
+ {
+ std::complex<long double> c1 = 3.0il;
+ assert ( c1 == std::complex<long double>(0, 3.0));
+ auto c2 = 3il;
+ assert ( c1 == c2 );
+ }
+
+ {
+ std::complex<double> c1 = 3.0i;
+ assert ( c1 == std::complex<double>(0, 3.0));
+ auto c2 = 3i;
+ assert ( c1 == c2 );
+ }
+
+ {
+ std::complex<float> c1 = 3.0if;
+ assert ( c1 == std::complex<float>(0, 3.0));
+ auto c2 = 3if;
+ assert ( c1 == c2 );
+ }
+
+#endif
+}
diff --git a/test/std/numerics/complex.number/complex.literals/literals1.fail.cpp b/test/std/numerics/complex.number/complex.literals/literals1.fail.cpp
new file mode 100644
index 000000000000..0f31d595566c
--- /dev/null
+++ b/test/std/numerics/complex.number/complex.literals/literals1.fail.cpp
@@ -0,0 +1,20 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+#include <complex>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ std::complex<float> foo = 1.0if; // should fail w/conversion operator not found
+#else
+#error
+#endif
+}
diff --git a/test/std/numerics/complex.number/complex.literals/literals1.pass.cpp b/test/std/numerics/complex.number/complex.literals/literals1.pass.cpp
new file mode 100644
index 000000000000..46903bbd565d
--- /dev/null
+++ b/test/std/numerics/complex.number/complex.literals/literals1.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+#include <complex>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ using namespace std::literals;
+
+ {
+ std::complex<long double> c1 = 3.0il;
+ assert ( c1 == std::complex<long double>(0, 3.0));
+ auto c2 = 3il;
+ assert ( c1 == c2 );
+ }
+
+ {
+ std::complex<double> c1 = 3.0i;
+ assert ( c1 == std::complex<double>(0, 3.0));
+ auto c2 = 3i;
+ assert ( c1 == c2 );
+ }
+
+ {
+ std::complex<float> c1 = 3.0if;
+ assert ( c1 == std::complex<float>(0, 3.0));
+ auto c2 = 3if;
+ assert ( c1 == c2 );
+ }
+
+#endif
+}
diff --git a/test/std/numerics/complex.number/complex.literals/literals2.pass.cpp b/test/std/numerics/complex.number/complex.literals/literals2.pass.cpp
new file mode 100644
index 000000000000..8bd8acd981bc
--- /dev/null
+++ b/test/std/numerics/complex.number/complex.literals/literals2.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+#include <complex>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ using namespace std;
+
+ {
+ std::complex<long double> c1 = 3.0il;
+ assert ( c1 == std::complex<long double>(0, 3.0));
+ auto c2 = 3il;
+ assert ( c1 == c2 );
+ }
+
+ {
+ std::complex<double> c1 = 3.0i;
+ assert ( c1 == std::complex<double>(0, 3.0));
+ auto c2 = 3i;
+ assert ( c1 == c2 );
+ }
+
+ {
+ std::complex<float> c1 = 3.0if;
+ assert ( c1 == std::complex<float>(0, 3.0));
+ auto c2 = 3if;
+ assert ( c1 == c2 );
+ }
+
+#endif
+}
diff --git a/test/std/numerics/complex.number/complex.member.ops/assignment_complex.pass.cpp b/test/std/numerics/complex.number/complex.member.ops/assignment_complex.pass.cpp
new file mode 100644
index 000000000000..d39429427964
--- /dev/null
+++ b/test/std/numerics/complex.number/complex.member.ops/assignment_complex.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// complex& operator=(const complex&);
+// template<class X> complex& operator= (const complex<X>&);
+
+#include <complex>
+#include <cassert>
+
+template <class T, class X>
+void
+test()
+{
+ std::complex<T> c;
+ assert(c.real() == 0);
+ assert(c.imag() == 0);
+ std::complex<T> c2(1.5, 2.5);
+ c = c2;
+ assert(c.real() == 1.5);
+ assert(c.imag() == 2.5);
+ std::complex<X> c3(3.5, -4.5);
+ c = c3;
+ assert(c.real() == 3.5);
+ assert(c.imag() == -4.5);
+}
+
+int main()
+{
+ test<float, float>();
+ test<float, double>();
+ test<float, long double>();
+
+ test<double, float>();
+ test<double, double>();
+ test<double, long double>();
+
+ test<long double, float>();
+ test<long double, double>();
+ test<long double, long double>();
+}
diff --git a/test/std/numerics/complex.number/complex.member.ops/assignment_scalar.pass.cpp b/test/std/numerics/complex.number/complex.member.ops/assignment_scalar.pass.cpp
new file mode 100644
index 000000000000..87b78061e536
--- /dev/null
+++ b/test/std/numerics/complex.number/complex.member.ops/assignment_scalar.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// complex& operator= (const T&);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+ std::complex<T> c;
+ assert(c.real() == 0);
+ assert(c.imag() == 0);
+ c = 1.5;
+ assert(c.real() == 1.5);
+ assert(c.imag() == 0);
+ c = -1.5;
+ assert(c.real() == -1.5);
+ assert(c.imag() == 0);
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+}
diff --git a/test/std/numerics/complex.number/complex.member.ops/divide_equal_complex.pass.cpp b/test/std/numerics/complex.number/complex.member.ops/divide_equal_complex.pass.cpp
new file mode 100644
index 000000000000..cb285117b15d
--- /dev/null
+++ b/test/std/numerics/complex.number/complex.member.ops/divide_equal_complex.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// complex& operator/=(const complex& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+ std::complex<T> c(-4, 7.5);
+ const std::complex<T> c2(1.5, 2.5);
+ assert(c.real() == -4);
+ assert(c.imag() == 7.5);
+ c /= c2;
+ assert(c.real() == 1.5);
+ assert(c.imag() == 2.5);
+ c /= c2;
+ assert(c.real() == 1);
+ assert(c.imag() == 0);
+
+ std::complex<T> c3;
+
+ c3 = c;
+ std::complex<int> ic (1,1);
+ c3 /= ic;
+ assert(c3.real() == 0.5);
+ assert(c3.imag() == -0.5);
+
+ c3 = c;
+ std::complex<float> fc (1,1);
+ c3 /= fc;
+ assert(c3.real() == 0.5);
+ assert(c3.imag() == -0.5);
+
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+}
diff --git a/test/std/numerics/complex.number/complex.member.ops/divide_equal_scalar.pass.cpp b/test/std/numerics/complex.number/complex.member.ops/divide_equal_scalar.pass.cpp
new file mode 100644
index 000000000000..89907d13a45c
--- /dev/null
+++ b/test/std/numerics/complex.number/complex.member.ops/divide_equal_scalar.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// complex& operator/=(const T& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+ std::complex<T> c(1);
+ assert(c.real() == 1);
+ assert(c.imag() == 0);
+ c /= 0.5;
+ assert(c.real() == 2);
+ assert(c.imag() == 0);
+ c /= 0.5;
+ assert(c.real() == 4);
+ assert(c.imag() == 0);
+ c /= -0.5;
+ assert(c.real() == -8);
+ assert(c.imag() == 0);
+ c.imag(2);
+ c /= 0.5;
+ assert(c.real() == -16);
+ assert(c.imag() == 4);
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+}
diff --git a/test/std/numerics/complex.number/complex.member.ops/minus_equal_complex.pass.cpp b/test/std/numerics/complex.number/complex.member.ops/minus_equal_complex.pass.cpp
new file mode 100644
index 000000000000..67a1c7189a29
--- /dev/null
+++ b/test/std/numerics/complex.number/complex.member.ops/minus_equal_complex.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// complex& operator-=(const complex& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+ std::complex<T> c;
+ const std::complex<T> c2(1.5, 2.5);
+ assert(c.real() == 0);
+ assert(c.imag() == 0);
+ c -= c2;
+ assert(c.real() == -1.5);
+ assert(c.imag() == -2.5);
+ c -= c2;
+ assert(c.real() == -3);
+ assert(c.imag() == -5);
+
+ std::complex<T> c3;
+
+ c3 = c;
+ std::complex<int> ic (1,1);
+ c3 -= ic;
+ assert(c3.real() == -4);
+ assert(c3.imag() == -6);
+
+ c3 = c;
+ std::complex<float> fc (1,1);
+ c3 -= fc;
+ assert(c3.real() == -4);
+ assert(c3.imag() == -6);
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+}
diff --git a/test/std/numerics/complex.number/complex.member.ops/minus_equal_scalar.pass.cpp b/test/std/numerics/complex.number/complex.member.ops/minus_equal_scalar.pass.cpp
new file mode 100644
index 000000000000..ddec891b25aa
--- /dev/null
+++ b/test/std/numerics/complex.number/complex.member.ops/minus_equal_scalar.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// complex& operator-=(const T& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+ std::complex<T> c;
+ assert(c.real() == 0);
+ assert(c.imag() == 0);
+ c -= 1.5;
+ assert(c.real() == -1.5);
+ assert(c.imag() == 0);
+ c -= 1.5;
+ assert(c.real() == -3);
+ assert(c.imag() == 0);
+ c -= -1.5;
+ assert(c.real() == -1.5);
+ assert(c.imag() == 0);
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+}
diff --git a/test/std/numerics/complex.number/complex.member.ops/plus_equal_complex.pass.cpp b/test/std/numerics/complex.number/complex.member.ops/plus_equal_complex.pass.cpp
new file mode 100644
index 000000000000..8c16f4ced2cd
--- /dev/null
+++ b/test/std/numerics/complex.number/complex.member.ops/plus_equal_complex.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// complex& operator+=(const complex& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+ std::complex<T> c;
+ const std::complex<T> c2(1.5, 2.5);
+ assert(c.real() == 0);
+ assert(c.imag() == 0);
+ c += c2;
+ assert(c.real() == 1.5);
+ assert(c.imag() == 2.5);
+ c += c2;
+ assert(c.real() == 3);
+ assert(c.imag() == 5);
+
+ std::complex<T> c3;
+
+ c3 = c;
+ std::complex<int> ic (1,1);
+ c3 += ic;
+ assert(c3.real() == 4);
+ assert(c3.imag() == 6);
+
+ c3 = c;
+ std::complex<float> fc (1,1);
+ c3 += fc;
+ assert(c3.real() == 4);
+ assert(c3.imag() == 6);
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+}
diff --git a/test/std/numerics/complex.number/complex.member.ops/plus_equal_scalar.pass.cpp b/test/std/numerics/complex.number/complex.member.ops/plus_equal_scalar.pass.cpp
new file mode 100644
index 000000000000..4dd8066d1267
--- /dev/null
+++ b/test/std/numerics/complex.number/complex.member.ops/plus_equal_scalar.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// complex& operator+=(const T& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+ std::complex<T> c;
+ assert(c.real() == 0);
+ assert(c.imag() == 0);
+ c += 1.5;
+ assert(c.real() == 1.5);
+ assert(c.imag() == 0);
+ c += 1.5;
+ assert(c.real() == 3);
+ assert(c.imag() == 0);
+ c += -1.5;
+ assert(c.real() == 1.5);
+ assert(c.imag() == 0);
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+}
diff --git a/test/std/numerics/complex.number/complex.member.ops/times_equal_complex.pass.cpp b/test/std/numerics/complex.number/complex.member.ops/times_equal_complex.pass.cpp
new file mode 100644
index 000000000000..84d6e591306e
--- /dev/null
+++ b/test/std/numerics/complex.number/complex.member.ops/times_equal_complex.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// complex& operator*=(const complex& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+ std::complex<T> c(1);
+ const std::complex<T> c2(1.5, 2.5);
+ assert(c.real() == 1);
+ assert(c.imag() == 0);
+ c *= c2;
+ assert(c.real() == 1.5);
+ assert(c.imag() == 2.5);
+ c *= c2;
+ assert(c.real() == -4);
+ assert(c.imag() == 7.5);
+
+ std::complex<T> c3;
+
+ c3 = c;
+ std::complex<int> ic (1,1);
+ c3 *= ic;
+ assert(c3.real() == -11.5);
+ assert(c3.imag() == 3.5);
+
+ c3 = c;
+ std::complex<float> fc (1,1);
+ c3 *= fc;
+ assert(c3.real() == -11.5);
+ assert(c3.imag() == 3.5);
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+}
diff --git a/test/std/numerics/complex.number/complex.member.ops/times_equal_scalar.pass.cpp b/test/std/numerics/complex.number/complex.member.ops/times_equal_scalar.pass.cpp
new file mode 100644
index 000000000000..c94baa9b6235
--- /dev/null
+++ b/test/std/numerics/complex.number/complex.member.ops/times_equal_scalar.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// complex& operator*=(const T& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+ std::complex<T> c(1);
+ assert(c.real() == 1);
+ assert(c.imag() == 0);
+ c *= 1.5;
+ assert(c.real() == 1.5);
+ assert(c.imag() == 0);
+ c *= 1.5;
+ assert(c.real() == 2.25);
+ assert(c.imag() == 0);
+ c *= -1.5;
+ assert(c.real() == -3.375);
+ assert(c.imag() == 0);
+ c.imag(2);
+ c *= 1.5;
+ assert(c.real() == -5.0625);
+ assert(c.imag() == 3);
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+}
diff --git a/test/std/numerics/complex.number/complex.members/construct.pass.cpp b/test/std/numerics/complex.number/complex.members/construct.pass.cpp
new file mode 100644
index 000000000000..b4d870fad11e
--- /dev/null
+++ b/test/std/numerics/complex.number/complex.members/construct.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// constexpr complex(const T& re = T(), const T& im = T());
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+ {
+ const std::complex<T> c;
+ assert(c.real() == 0);
+ assert(c.imag() == 0);
+ }
+ {
+ const std::complex<T> c = 7.5;
+ assert(c.real() == 7.5);
+ assert(c.imag() == 0);
+ }
+ {
+ const std::complex<T> c(8.5);
+ assert(c.real() == 8.5);
+ assert(c.imag() == 0);
+ }
+ {
+ const std::complex<T> c(10.5, -9.5);
+ assert(c.real() == 10.5);
+ assert(c.imag() == -9.5);
+ }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+ {
+ constexpr std::complex<T> c;
+ static_assert(c.real() == 0, "");
+ static_assert(c.imag() == 0, "");
+ }
+ {
+ constexpr std::complex<T> c = 7.5;
+ static_assert(c.real() == 7.5, "");
+ static_assert(c.imag() == 0, "");
+ }
+ {
+ constexpr std::complex<T> c(8.5);
+ static_assert(c.real() == 8.5, "");
+ static_assert(c.imag() == 0, "");
+ }
+ {
+ constexpr std::complex<T> c(10.5, -9.5);
+ static_assert(c.real() == 10.5, "");
+ static_assert(c.imag() == -9.5, "");
+ }
+#endif
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+}
diff --git a/test/std/numerics/complex.number/complex.members/real_imag.pass.cpp b/test/std/numerics/complex.number/complex.members/real_imag.pass.cpp
new file mode 100644
index 000000000000..7ead855f5c76
--- /dev/null
+++ b/test/std/numerics/complex.number/complex.members/real_imag.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// void real(T val);
+// void imag(T val);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test_constexpr()
+{
+#if _LIBCPP_STD_VER > 11
+ constexpr std::complex<T> c1;
+ static_assert(c1.real() == 0, "");
+ static_assert(c1.imag() == 0, "");
+ constexpr std::complex<T> c2(3);
+ static_assert(c2.real() == 3, "");
+ static_assert(c2.imag() == 0, "");
+ constexpr std::complex<T> c3(3, 4);
+ static_assert(c3.real() == 3, "");
+ static_assert(c3.imag() == 4, "");
+#endif
+}
+
+template <class T>
+void
+test()
+{
+ std::complex<T> c;
+ assert(c.real() == 0);
+ assert(c.imag() == 0);
+ c.real(3.5);
+ assert(c.real() == 3.5);
+ assert(c.imag() == 0);
+ c.imag(4.5);
+ assert(c.real() == 3.5);
+ assert(c.imag() == 4.5);
+ c.real(-4.5);
+ assert(c.real() == -4.5);
+ assert(c.imag() == 4.5);
+ c.imag(-5.5);
+ assert(c.real() == -4.5);
+ assert(c.imag() == -5.5);
+
+ test_constexpr<T> ();
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+ test_constexpr<int> ();
+}
diff --git a/test/std/numerics/complex.number/complex.ops/complex_divide_complex.pass.cpp b/test/std/numerics/complex.number/complex.ops/complex_divide_complex.pass.cpp
new file mode 100644
index 000000000000..86119678aa70
--- /dev/null
+++ b/test/std/numerics/complex.number/complex.ops/complex_divide_complex.pass.cpp
@@ -0,0 +1,159 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// complex<T>
+// operator/(const complex<T>& lhs, const complex<T>& rhs);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const std::complex<T>& lhs, const std::complex<T>& rhs, std::complex<T> x)
+{
+ assert(lhs / rhs == x);
+}
+
+template <class T>
+void
+test()
+{
+ std::complex<T> lhs(-4.0, 7.5);
+ std::complex<T> rhs(1.5, 2.5);
+ std::complex<T> x(1.5, 2.5);
+ test(lhs, rhs, x);
+}
+
+void test_edges()
+{
+ const unsigned N = sizeof(x) / sizeof(x[0]);
+ for (unsigned i = 0; i < N; ++i)
+ {
+ for (unsigned j = 0; j < N; ++j)
+ {
+ std::complex<double> r = x[i] / x[j];
+ switch (classify(x[i]))
+ {
+ case zero:
+ switch (classify(x[j]))
+ {
+ case zero:
+ assert(classify(r) == NaN);
+ break;
+ case non_zero:
+ assert(classify(r) == zero);
+ break;
+ case inf:
+ assert(classify(r) == zero);
+ break;
+ case NaN:
+ assert(classify(r) == NaN);
+ break;
+ case non_zero_nan:
+ assert(classify(r) == NaN);
+ break;
+ }
+ break;
+ case non_zero:
+ switch (classify(x[j]))
+ {
+ case zero:
+ assert(classify(r) == inf);
+ break;
+ case non_zero:
+ assert(classify(r) == non_zero);
+ break;
+ case inf:
+ assert(classify(r) == zero);
+ break;
+ case NaN:
+ assert(classify(r) == NaN);
+ break;
+ case non_zero_nan:
+ assert(classify(r) == NaN);
+ break;
+ }
+ break;
+ case inf:
+ switch (classify(x[j]))
+ {
+ case zero:
+ assert(classify(r) == inf);
+ break;
+ case non_zero:
+ assert(classify(r) == inf);
+ break;
+ case inf:
+ assert(classify(r) == NaN);
+ break;
+ case NaN:
+ assert(classify(r) == NaN);
+ break;
+ case non_zero_nan:
+ assert(classify(r) == NaN);
+ break;
+ }
+ break;
+ case NaN:
+ switch (classify(x[j]))
+ {
+ case zero:
+ assert(classify(r) == NaN);
+ break;
+ case non_zero:
+ assert(classify(r) == NaN);
+ break;
+ case inf:
+ assert(classify(r) == NaN);
+ break;
+ case NaN:
+ assert(classify(r) == NaN);
+ break;
+ case non_zero_nan:
+ assert(classify(r) == NaN);
+ break;
+ }
+ break;
+ case non_zero_nan:
+ switch (classify(x[j]))
+ {
+ case zero:
+ assert(classify(r) == inf);
+ break;
+ case non_zero:
+ assert(classify(r) == NaN);
+ break;
+ case inf:
+ assert(classify(r) == NaN);
+ break;
+ case NaN:
+ assert(classify(r) == NaN);
+ break;
+ case non_zero_nan:
+ assert(classify(r) == NaN);
+ break;
+ }
+ break;
+ }
+ }
+ }
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+ test_edges();
+}
diff --git a/test/std/numerics/complex.number/complex.ops/complex_divide_scalar.pass.cpp b/test/std/numerics/complex.number/complex.ops/complex_divide_scalar.pass.cpp
new file mode 100644
index 000000000000..b23b381cb59d
--- /dev/null
+++ b/test/std/numerics/complex.number/complex.ops/complex_divide_scalar.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// complex<T>
+// operator/(const complex<T>& lhs, const T& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test(const std::complex<T>& lhs, const T& rhs, std::complex<T> x)
+{
+ assert(lhs / rhs == x);
+}
+
+template <class T>
+void
+test()
+{
+ std::complex<T> lhs(-4.0, 7.5);
+ T rhs(2);
+ std::complex<T> x(-2, 3.75);
+ test(lhs, rhs, x);
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+}
diff --git a/test/std/numerics/complex.number/complex.ops/complex_equals_complex.pass.cpp b/test/std/numerics/complex.number/complex.ops/complex_equals_complex.pass.cpp
new file mode 100644
index 000000000000..970f021f8e63
--- /dev/null
+++ b/test/std/numerics/complex.number/complex.ops/complex_equals_complex.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// bool
+// operator==(const complex<T>& lhs, const complex<T>& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test_constexpr()
+{
+#if _LIBCPP_STD_VER > 11
+ {
+ constexpr std::complex<T> lhs(1.5, 2.5);
+ constexpr std::complex<T> rhs(1.5, -2.5);
+ static_assert( !(lhs == rhs), "");
+ }
+ {
+ constexpr std::complex<T> lhs(1.5, 2.5);
+ constexpr std::complex<T> rhs(1.5, 2.5);
+ static_assert(lhs == rhs, "");
+ }
+#endif
+}
+
+template <class T>
+void
+test()
+{
+ {
+ std::complex<T> lhs(1.5, 2.5);
+ std::complex<T> rhs(1.5, -2.5);
+ assert( !(lhs == rhs));
+ }
+ {
+ std::complex<T> lhs(1.5, 2.5);
+ std::complex<T> rhs(1.5, 2.5);
+ assert(lhs == rhs);
+ }
+ test_constexpr<T> ();
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+// test_constexpr<int> ();
+}
diff --git a/test/std/numerics/complex.number/complex.ops/complex_equals_scalar.pass.cpp b/test/std/numerics/complex.number/complex.ops/complex_equals_scalar.pass.cpp
new file mode 100644
index 000000000000..3c8b772bcaa5
--- /dev/null
+++ b/test/std/numerics/complex.number/complex.ops/complex_equals_scalar.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// bool
+// operator==(const complex<T>& lhs, const T& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test_constexpr()
+{
+#if _LIBCPP_STD_VER > 11
+ {
+ constexpr std::complex<T> lhs(1.5, 2.5);
+ constexpr T rhs(-2.5);
+ static_assert(!(lhs == rhs), "");
+ }
+ {
+ constexpr std::complex<T> lhs(1.5, 0);
+ constexpr T rhs(-2.5);
+ static_assert(!(lhs == rhs), "");
+ }
+ {
+ constexpr std::complex<T> lhs(1.5, 2.5);
+ constexpr T rhs(1.5);
+ static_assert(!(lhs == rhs), "");
+ }
+ {
+ constexpr std::complex<T> lhs(1.5, 0);
+ constexpr T rhs(1.5);
+ static_assert( (lhs == rhs), "");
+ }
+#endif
+}
+
+template <class T>
+void
+test()
+{
+ {
+ std::complex<T> lhs(1.5, 2.5);
+ T rhs(-2.5);
+ assert(!(lhs == rhs));
+ }
+ {
+ std::complex<T> lhs(1.5, 0);
+ T rhs(-2.5);
+ assert(!(lhs == rhs));
+ }
+ {
+ std::complex<T> lhs(1.5, 2.5);
+ T rhs(1.5);
+ assert(!(lhs == rhs));
+ }
+ {
+ std::complex<T> lhs(1.5, 0);
+ T rhs(1.5);
+ assert( (lhs == rhs));
+ }
+
+ test_constexpr<T> ();
+ }
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+// test_constexpr<int> ();
+}
diff --git a/test/std/numerics/complex.number/complex.ops/complex_minus_complex.pass.cpp b/test/std/numerics/complex.number/complex.ops/complex_minus_complex.pass.cpp
new file mode 100644
index 000000000000..b2cddd26d8b5
--- /dev/null
+++ b/test/std/numerics/complex.number/complex.ops/complex_minus_complex.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// complex<T>
+// operator-(const complex<T>& lhs, const complex<T>& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test(const std::complex<T>& lhs, const std::complex<T>& rhs, std::complex<T> x)
+{
+ assert(lhs - rhs == x);
+}
+
+template <class T>
+void
+test()
+{
+ {
+ std::complex<T> lhs(1.5, 2.5);
+ std::complex<T> rhs(3.5, 4.5);
+ std::complex<T> x(-2.0, -2.0);
+ test(lhs, rhs, x);
+ }
+ {
+ std::complex<T> lhs(1.5, -2.5);
+ std::complex<T> rhs(-3.5, 4.5);
+ std::complex<T> x(5.0, -7.0);
+ test(lhs, rhs, x);
+ }
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+}
diff --git a/test/std/numerics/complex.number/complex.ops/complex_minus_scalar.pass.cpp b/test/std/numerics/complex.number/complex.ops/complex_minus_scalar.pass.cpp
new file mode 100644
index 000000000000..b630679fc985
--- /dev/null
+++ b/test/std/numerics/complex.number/complex.ops/complex_minus_scalar.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// complex<T>
+// operator-(const complex<T>& lhs, const T& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test(const std::complex<T>& lhs, const T& rhs, std::complex<T> x)
+{
+ assert(lhs - rhs == x);
+}
+
+template <class T>
+void
+test()
+{
+ {
+ std::complex<T> lhs(1.5, 2.5);
+ T rhs(3.5);
+ std::complex<T> x(-2.0, 2.5);
+ test(lhs, rhs, x);
+ }
+ {
+ std::complex<T> lhs(1.5, -2.5);
+ T rhs(-3.5);
+ std::complex<T> x(5.0, -2.5);
+ test(lhs, rhs, x);
+ }
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+}
diff --git a/test/std/numerics/complex.number/complex.ops/complex_not_equals_complex.pass.cpp b/test/std/numerics/complex.number/complex.ops/complex_not_equals_complex.pass.cpp
new file mode 100644
index 000000000000..ee138c1ecbcd
--- /dev/null
+++ b/test/std/numerics/complex.number/complex.ops/complex_not_equals_complex.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// bool
+// operator!=(const complex<T>& lhs, const complex<T>& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test_constexpr()
+{
+#if _LIBCPP_STD_VER > 11
+ {
+ constexpr std::complex<T> lhs(1.5, 2.5);
+ constexpr std::complex<T> rhs(1.5, -2.5);
+ static_assert(lhs != rhs, "");
+ }
+ {
+ constexpr std::complex<T> lhs(1.5, 2.5);
+ constexpr std::complex<T> rhs(1.5, 2.5);
+ static_assert(!(lhs != rhs), "" );
+ }
+#endif
+}
+
+
+template <class T>
+void
+test()
+{
+ {
+ std::complex<T> lhs(1.5, 2.5);
+ std::complex<T> rhs(1.5, -2.5);
+ assert(lhs != rhs);
+ }
+ {
+ std::complex<T> lhs(1.5, 2.5);
+ std::complex<T> rhs(1.5, 2.5);
+ assert(!(lhs != rhs));
+ }
+
+ test_constexpr<T> ();
+ }
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+// test_constexpr<int> ();
+}
diff --git a/test/std/numerics/complex.number/complex.ops/complex_not_equals_scalar.pass.cpp b/test/std/numerics/complex.number/complex.ops/complex_not_equals_scalar.pass.cpp
new file mode 100644
index 000000000000..efb1c0e872db
--- /dev/null
+++ b/test/std/numerics/complex.number/complex.ops/complex_not_equals_scalar.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// bool
+// operator!=(const complex<T>& lhs, const T& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test_constexpr()
+{
+#if _LIBCPP_STD_VER > 11
+ {
+ constexpr std::complex<T> lhs(1.5, 2.5);
+ constexpr T rhs(-2.5);
+ static_assert(lhs != rhs, "");
+ }
+ {
+ constexpr std::complex<T> lhs(1.5, 0);
+ constexpr T rhs(-2.5);
+ static_assert(lhs != rhs, "");
+ }
+ {
+ constexpr std::complex<T> lhs(1.5, 2.5);
+ constexpr T rhs(1.5);
+ static_assert(lhs != rhs, "");
+ }
+ {
+ constexpr std::complex<T> lhs(1.5, 0);
+ constexpr T rhs(1.5);
+ static_assert( !(lhs != rhs), "");
+ }
+#endif
+}
+
+template <class T>
+void
+test()
+{
+ {
+ std::complex<T> lhs(1.5, 2.5);
+ T rhs(-2.5);
+ assert(lhs != rhs);
+ }
+ {
+ std::complex<T> lhs(1.5, 0);
+ T rhs(-2.5);
+ assert(lhs != rhs);
+ }
+ {
+ std::complex<T> lhs(1.5, 2.5);
+ T rhs(1.5);
+ assert(lhs != rhs);
+ }
+ {
+ std::complex<T> lhs(1.5, 0);
+ T rhs(1.5);
+ assert( !(lhs != rhs));
+ }
+
+ test_constexpr<T> ();
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+// test_constexpr<int> ();
+ }
diff --git a/test/std/numerics/complex.number/complex.ops/complex_plus_complex.pass.cpp b/test/std/numerics/complex.number/complex.ops/complex_plus_complex.pass.cpp
new file mode 100644
index 000000000000..02ed8684ea92
--- /dev/null
+++ b/test/std/numerics/complex.number/complex.ops/complex_plus_complex.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// complex<T>
+// operator+(const complex<T>& lhs, const complex<T>& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test(const std::complex<T>& lhs, const std::complex<T>& rhs, std::complex<T> x)
+{
+ assert(lhs + rhs == x);
+}
+
+template <class T>
+void
+test()
+{
+ {
+ std::complex<T> lhs(1.5, 2.5);
+ std::complex<T> rhs(3.5, 4.5);
+ std::complex<T> x(5.0, 7.0);
+ test(lhs, rhs, x);
+ }
+ {
+ std::complex<T> lhs(1.5, -2.5);
+ std::complex<T> rhs(-3.5, 4.5);
+ std::complex<T> x(-2.0, 2.0);
+ test(lhs, rhs, x);
+ }
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+}
diff --git a/test/std/numerics/complex.number/complex.ops/complex_plus_scalar.pass.cpp b/test/std/numerics/complex.number/complex.ops/complex_plus_scalar.pass.cpp
new file mode 100644
index 000000000000..eeec83fb09ad
--- /dev/null
+++ b/test/std/numerics/complex.number/complex.ops/complex_plus_scalar.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// complex<T>
+// operator+(const complex<T>& lhs, const T& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test(const std::complex<T>& lhs, const T& rhs, std::complex<T> x)
+{
+ assert(lhs + rhs == x);
+}
+
+template <class T>
+void
+test()
+{
+ {
+ std::complex<T> lhs(1.5, 2.5);
+ T rhs(3.5);
+ std::complex<T> x(5.0, 2.5);
+ test(lhs, rhs, x);
+ }
+ {
+ std::complex<T> lhs(1.5, -2.5);
+ T rhs(-3.5);
+ std::complex<T> x(-2.0, -2.5);
+ test(lhs, rhs, x);
+ }
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+}
diff --git a/test/std/numerics/complex.number/complex.ops/complex_times_complex.pass.cpp b/test/std/numerics/complex.number/complex.ops/complex_times_complex.pass.cpp
new file mode 100644
index 000000000000..565eaa5657cd
--- /dev/null
+++ b/test/std/numerics/complex.number/complex.ops/complex_times_complex.pass.cpp
@@ -0,0 +1,161 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// complex<T>
+// operator*(const complex<T>& lhs, const complex<T>& rhs);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const std::complex<T>& lhs, const std::complex<T>& rhs, std::complex<T> x)
+{
+ assert(lhs * rhs == x);
+}
+
+template <class T>
+void
+test()
+{
+ std::complex<T> lhs(1.5, 2.5);
+ std::complex<T> rhs(1.5, 2.5);
+ std::complex<T> x(-4.0, 7.5);
+ test(lhs, rhs, x);
+}
+
+// test edges
+
+void test_edges()
+{
+ const unsigned N = sizeof(x) / sizeof(x[0]);
+ for (unsigned i = 0; i < N; ++i)
+ {
+ for (unsigned j = 0; j < N; ++j)
+ {
+ std::complex<double> r = x[i] * x[j];
+ switch (classify(x[i]))
+ {
+ case zero:
+ switch (classify(x[j]))
+ {
+ case zero:
+ assert(classify(r) == zero);
+ break;
+ case non_zero:
+ assert(classify(r) == zero);
+ break;
+ case inf:
+ assert(classify(r) == NaN);
+ break;
+ case NaN:
+ assert(classify(r) == NaN);
+ break;
+ case non_zero_nan:
+ assert(classify(r) == NaN);
+ break;
+ }
+ break;
+ case non_zero:
+ switch (classify(x[j]))
+ {
+ case zero:
+ assert(classify(r) == zero);
+ break;
+ case non_zero:
+ assert(classify(r) == non_zero);
+ break;
+ case inf:
+ assert(classify(r) == inf);
+ break;
+ case NaN:
+ assert(classify(r) == NaN);
+ break;
+ case non_zero_nan:
+ assert(classify(r) == NaN);
+ break;
+ }
+ break;
+ case inf:
+ switch (classify(x[j]))
+ {
+ case zero:
+ assert(classify(r) == NaN);
+ break;
+ case non_zero:
+ assert(classify(r) == inf);
+ break;
+ case inf:
+ assert(classify(r) == inf);
+ break;
+ case NaN:
+ assert(classify(r) == NaN);
+ break;
+ case non_zero_nan:
+ assert(classify(r) == inf);
+ break;
+ }
+ break;
+ case NaN:
+ switch (classify(x[j]))
+ {
+ case zero:
+ assert(classify(r) == NaN);
+ break;
+ case non_zero:
+ assert(classify(r) == NaN);
+ break;
+ case inf:
+ assert(classify(r) == NaN);
+ break;
+ case NaN:
+ assert(classify(r) == NaN);
+ break;
+ case non_zero_nan:
+ assert(classify(r) == NaN);
+ break;
+ }
+ break;
+ case non_zero_nan:
+ switch (classify(x[j]))
+ {
+ case zero:
+ assert(classify(r) == NaN);
+ break;
+ case non_zero:
+ assert(classify(r) == NaN);
+ break;
+ case inf:
+ assert(classify(r) == inf);
+ break;
+ case NaN:
+ assert(classify(r) == NaN);
+ break;
+ case non_zero_nan:
+ assert(classify(r) == NaN);
+ break;
+ }
+ break;
+ }
+ }
+ }
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+ test_edges();
+}
diff --git a/test/std/numerics/complex.number/complex.ops/complex_times_scalar.pass.cpp b/test/std/numerics/complex.number/complex.ops/complex_times_scalar.pass.cpp
new file mode 100644
index 000000000000..0e829a4caa68
--- /dev/null
+++ b/test/std/numerics/complex.number/complex.ops/complex_times_scalar.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// complex<T>
+// operator*(const complex<T>& lhs, const T& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test(const std::complex<T>& lhs, const T& rhs, std::complex<T> x)
+{
+ assert(lhs * rhs == x);
+}
+
+template <class T>
+void
+test()
+{
+ std::complex<T> lhs(1.5, 2.5);
+ T rhs(1.5);
+ std::complex<T> x(2.25, 3.75);
+ test(lhs, rhs, x);
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+}
diff --git a/test/std/numerics/complex.number/complex.ops/scalar_divide_complex.pass.cpp b/test/std/numerics/complex.number/complex.ops/scalar_divide_complex.pass.cpp
new file mode 100644
index 000000000000..e16f02ea6db9
--- /dev/null
+++ b/test/std/numerics/complex.number/complex.ops/scalar_divide_complex.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// complex<T>
+// operator/(const T& lhs, const complex<T>& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test(const T& lhs, const std::complex<T>& rhs, std::complex<T> x)
+{
+ assert(lhs / rhs == x);
+}
+
+template <class T>
+void
+test()
+{
+ T lhs(-8.5);
+ std::complex<T> rhs(1.5, 2.5);
+ std::complex<T> x(-1.5, 2.5);
+ test(lhs, rhs, x);
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+}
diff --git a/test/std/numerics/complex.number/complex.ops/scalar_equals_complex.pass.cpp b/test/std/numerics/complex.number/complex.ops/scalar_equals_complex.pass.cpp
new file mode 100644
index 000000000000..0cd903541fe3
--- /dev/null
+++ b/test/std/numerics/complex.number/complex.ops/scalar_equals_complex.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// bool
+// operator==(const T& lhs, const complex<T>& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test_constexpr()
+{
+#if _LIBCPP_STD_VER > 11
+ {
+ constexpr T lhs(-2.5);
+ constexpr std::complex<T> rhs(1.5, 2.5);
+ static_assert(!(lhs == rhs), "");
+ }
+ {
+ constexpr T lhs(-2.5);
+ constexpr std::complex<T> rhs(1.5, 0);
+ static_assert(!(lhs == rhs), "");
+ }
+ {
+ constexpr T lhs(1.5);
+ constexpr std::complex<T> rhs(1.5, 2.5);
+ static_assert(!(lhs == rhs), "");
+ }
+ {
+ constexpr T lhs(1.5);
+ constexpr std::complex<T> rhs(1.5, 0);
+ static_assert(lhs == rhs, "");
+ }
+#endif
+}
+
+template <class T>
+void
+test()
+{
+ {
+ T lhs(-2.5);
+ std::complex<T> rhs(1.5, 2.5);
+ assert(!(lhs == rhs));
+ }
+ {
+ T lhs(-2.5);
+ std::complex<T> rhs(1.5, 0);
+ assert(!(lhs == rhs));
+ }
+ {
+ T lhs(1.5);
+ std::complex<T> rhs(1.5, 2.5);
+ assert(!(lhs == rhs));
+ }
+ {
+ T lhs(1.5);
+ std::complex<T> rhs(1.5, 0);
+ assert(lhs == rhs);
+ }
+
+ test_constexpr<T> ();
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+// test_constexpr<int>();
+}
diff --git a/test/std/numerics/complex.number/complex.ops/scalar_minus_complex.pass.cpp b/test/std/numerics/complex.number/complex.ops/scalar_minus_complex.pass.cpp
new file mode 100644
index 000000000000..35a3749118e9
--- /dev/null
+++ b/test/std/numerics/complex.number/complex.ops/scalar_minus_complex.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// complex<T>
+// operator-(const T& lhs, const complex<T>& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test(const T& lhs, const std::complex<T>& rhs, std::complex<T> x)
+{
+ assert(lhs - rhs == x);
+}
+
+template <class T>
+void
+test()
+{
+ {
+ T lhs(1.5);
+ std::complex<T> rhs(3.5, 4.5);
+ std::complex<T> x(-2.0, -4.5);
+ test(lhs, rhs, x);
+ }
+ {
+ T lhs(1.5);
+ std::complex<T> rhs(-3.5, 4.5);
+ std::complex<T> x(5.0, -4.5);
+ test(lhs, rhs, x);
+ }
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+}
diff --git a/test/std/numerics/complex.number/complex.ops/scalar_not_equals_complex.pass.cpp b/test/std/numerics/complex.number/complex.ops/scalar_not_equals_complex.pass.cpp
new file mode 100644
index 000000000000..7d6003cb891b
--- /dev/null
+++ b/test/std/numerics/complex.number/complex.ops/scalar_not_equals_complex.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// bool
+// operator!=(const T& lhs, const complex<T>& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test_constexpr()
+{
+#if _LIBCPP_STD_VER > 11
+ {
+ constexpr T lhs(-2.5);
+ constexpr std::complex<T> rhs(1.5, 2.5);
+ static_assert (lhs != rhs, "");
+ }
+ {
+ constexpr T lhs(-2.5);
+ constexpr std::complex<T> rhs(1.5, 0);
+ static_assert (lhs != rhs, "");
+ }
+ {
+ constexpr T lhs(1.5);
+ constexpr std::complex<T> rhs(1.5, 2.5);
+ static_assert (lhs != rhs, "");
+ }
+ {
+ constexpr T lhs(1.5);
+ constexpr std::complex<T> rhs(1.5, 0);
+ static_assert (!(lhs != rhs), "");
+ }
+#endif
+}
+
+template <class T>
+void
+test()
+{
+ {
+ T lhs(-2.5);
+ std::complex<T> rhs(1.5, 2.5);
+ assert (lhs != rhs);
+ }
+ {
+ T lhs(-2.5);
+ std::complex<T> rhs(1.5, 0);
+ assert (lhs != rhs);
+ }
+ {
+ T lhs(1.5);
+ std::complex<T> rhs(1.5, 2.5);
+ assert (lhs != rhs);
+ }
+ {
+ T lhs(1.5);
+ std::complex<T> rhs(1.5, 0);
+ assert (!(lhs != rhs));
+ }
+
+ test_constexpr<T> ();
+ }
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+// test_constexpr<int>();
+}
diff --git a/test/std/numerics/complex.number/complex.ops/scalar_plus_complex.pass.cpp b/test/std/numerics/complex.number/complex.ops/scalar_plus_complex.pass.cpp
new file mode 100644
index 000000000000..ec0de5a7f960
--- /dev/null
+++ b/test/std/numerics/complex.number/complex.ops/scalar_plus_complex.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// complex<T>
+// operator+(const T& lhs, const complex<T>& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test(const T& lhs, const std::complex<T>& rhs, std::complex<T> x)
+{
+ assert(lhs + rhs == x);
+}
+
+template <class T>
+void
+test()
+{
+ {
+ T lhs(1.5);
+ std::complex<T> rhs(3.5, 4.5);
+ std::complex<T> x(5.0, 4.5);
+ test(lhs, rhs, x);
+ }
+ {
+ T lhs(1.5);
+ std::complex<T> rhs(-3.5, 4.5);
+ std::complex<T> x(-2.0, 4.5);
+ test(lhs, rhs, x);
+ }
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+}
diff --git a/test/std/numerics/complex.number/complex.ops/scalar_times_complex.pass.cpp b/test/std/numerics/complex.number/complex.ops/scalar_times_complex.pass.cpp
new file mode 100644
index 000000000000..ebff8b23ba6c
--- /dev/null
+++ b/test/std/numerics/complex.number/complex.ops/scalar_times_complex.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// complex<T>
+// operator*(const T& lhs, const complex<T>& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test(const T& lhs, const std::complex<T>& rhs, std::complex<T> x)
+{
+ assert(lhs * rhs == x);
+}
+
+template <class T>
+void
+test()
+{
+ T lhs(1.5);
+ std::complex<T> rhs(1.5, 2.5);
+ std::complex<T> x(2.25, 3.75);
+ test(lhs, rhs, x);
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+}
diff --git a/test/std/numerics/complex.number/complex.ops/stream_input.pass.cpp b/test/std/numerics/complex.number/complex.ops/stream_input.pass.cpp
new file mode 100644
index 000000000000..24644e307799
--- /dev/null
+++ b/test/std/numerics/complex.number/complex.ops/stream_input.pass.cpp
@@ -0,0 +1,99 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T, class charT, class traits>
+// basic_istream<charT, traits>&
+// operator>>(basic_istream<charT, traits>& is, complex<T>& x);
+
+#include <complex>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::istringstream is("5");
+ std::complex<double> c;
+ is >> c;
+ assert(c == std::complex<double>(5, 0));
+ assert(is.eof());
+ }
+ {
+ std::istringstream is(" 5 ");
+ std::complex<double> c;
+ is >> c;
+ assert(c == std::complex<double>(5, 0));
+ assert(is.good());
+ }
+ {
+ std::istringstream is(" 5, ");
+ std::complex<double> c;
+ is >> c;
+ assert(c == std::complex<double>(5, 0));
+ assert(is.good());
+ }
+ {
+ std::istringstream is(" , 5, ");
+ std::complex<double> c;
+ is >> c;
+ assert(c == std::complex<double>(0, 0));
+ assert(is.fail());
+ }
+ {
+ std::istringstream is("5.5 ");
+ std::complex<double> c;
+ is >> c;
+ assert(c == std::complex<double>(5.5, 0));
+ assert(is.good());
+ }
+ {
+ std::istringstream is(" ( 5.5 ) ");
+ std::complex<double> c;
+ is >> c;
+ assert(c == std::complex<double>(5.5, 0));
+ assert(is.good());
+ }
+ {
+ std::istringstream is(" 5.5)");
+ std::complex<double> c;
+ is >> c;
+ assert(c == std::complex<double>(5.5, 0));
+ assert(is.good());
+ }
+ {
+ std::istringstream is("(5.5 ");
+ std::complex<double> c;
+ is >> c;
+ assert(c == std::complex<double>(0, 0));
+ assert(is.fail());
+ }
+ {
+ std::istringstream is("(5.5,");
+ std::complex<double> c;
+ is >> c;
+ assert(c == std::complex<double>(0, 0));
+ assert(is.fail());
+ }
+ {
+ std::istringstream is("( -5.5 , -6.5 )");
+ std::complex<double> c;
+ is >> c;
+ assert(c == std::complex<double>(-5.5, -6.5));
+ assert(!is.eof());
+ }
+ {
+ std::istringstream is("(-5.5,-6.5)");
+ std::complex<double> c;
+ is >> c;
+ assert(c == std::complex<double>(-5.5, -6.5));
+ assert(!is.eof());
+ }
+}
diff --git a/test/std/numerics/complex.number/complex.ops/stream_output.pass.cpp b/test/std/numerics/complex.number/complex.ops/stream_output.pass.cpp
new file mode 100644
index 000000000000..edb381cf60ab
--- /dev/null
+++ b/test/std/numerics/complex.number/complex.ops/stream_output.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T, class charT, class traits>
+// basic_ostream<charT, traits>&
+// operator<<(basic_ostream<charT, traits>& o, const complex<T>& x);
+
+#include <complex>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ std::complex<double> c(1, 2);
+ std::ostringstream os;
+ os << c;
+ assert(os.str() == "(1,2)");
+}
diff --git a/test/std/numerics/complex.number/complex.ops/unary_minus.pass.cpp b/test/std/numerics/complex.number/complex.ops/unary_minus.pass.cpp
new file mode 100644
index 000000000000..6a3a201ceaa8
--- /dev/null
+++ b/test/std/numerics/complex.number/complex.ops/unary_minus.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// complex<T>
+// operator-(const complex<T>& lhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+ std::complex<T> z(1.5, 2.5);
+ assert(z.real() == 1.5);
+ assert(z.imag() == 2.5);
+ std::complex<T> c = -z;
+ assert(c.real() == -1.5);
+ assert(c.imag() == -2.5);
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+}
diff --git a/test/std/numerics/complex.number/complex.ops/unary_plus.pass.cpp b/test/std/numerics/complex.number/complex.ops/unary_plus.pass.cpp
new file mode 100644
index 000000000000..5edaad29e682
--- /dev/null
+++ b/test/std/numerics/complex.number/complex.ops/unary_plus.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// complex<T>
+// operator+(const complex<T>&);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+ std::complex<T> z(1.5, 2.5);
+ assert(z.real() == 1.5);
+ assert(z.imag() == 2.5);
+ std::complex<T> c = +z;
+ assert(c.real() == 1.5);
+ assert(c.imag() == 2.5);
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+}
diff --git a/test/std/numerics/complex.number/complex.special/double_float_explicit.pass.cpp b/test/std/numerics/complex.number/complex.special/double_float_explicit.pass.cpp
new file mode 100644
index 000000000000..e8d07ce287d0
--- /dev/null
+++ b/test/std/numerics/complex.number/complex.special/double_float_explicit.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<> class complex<double>
+// {
+// public:
+// constexpr complex(const complex<float>&);
+// };
+
+#include <complex>
+#include <cassert>
+
+int main()
+{
+ {
+ const std::complex<float> cd(2.5, 3.5);
+ std::complex<double> cf(cd);
+ assert(cf.real() == cd.real());
+ assert(cf.imag() == cd.imag());
+ }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+ {
+ constexpr std::complex<float> cd(2.5, 3.5);
+ constexpr std::complex<double> cf(cd);
+ static_assert(cf.real() == cd.real(), "");
+ static_assert(cf.imag() == cd.imag(), "");
+ }
+#endif
+}
diff --git a/test/std/numerics/complex.number/complex.special/double_float_implicit.pass.cpp b/test/std/numerics/complex.number/complex.special/double_float_implicit.pass.cpp
new file mode 100644
index 000000000000..298aaa3a7a8a
--- /dev/null
+++ b/test/std/numerics/complex.number/complex.special/double_float_implicit.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<> class complex<double>
+// {
+// public:
+// constexpr complex(const complex<float>&);
+// };
+
+#include <complex>
+#include <cassert>
+
+int main()
+{
+ {
+ const std::complex<float> cd(2.5, 3.5);
+ std::complex<double> cf = cd;
+ assert(cf.real() == cd.real());
+ assert(cf.imag() == cd.imag());
+ }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+ {
+ constexpr std::complex<float> cd(2.5, 3.5);
+ constexpr std::complex<double> cf = cd;
+ static_assert(cf.real() == cd.real(), "");
+ static_assert(cf.imag() == cd.imag(), "");
+ }
+#endif
+}
diff --git a/test/std/numerics/complex.number/complex.special/double_long_double_explicit.pass.cpp b/test/std/numerics/complex.number/complex.special/double_long_double_explicit.pass.cpp
new file mode 100644
index 000000000000..6ff74a2cdef3
--- /dev/null
+++ b/test/std/numerics/complex.number/complex.special/double_long_double_explicit.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<> class complex<double>
+// {
+// public:
+// explicit constexpr complex(const complex<long double>&);
+// };
+
+#include <complex>
+#include <cassert>
+
+int main()
+{
+ {
+ const std::complex<long double> cd(2.5, 3.5);
+ std::complex<double> cf(cd);
+ assert(cf.real() == cd.real());
+ assert(cf.imag() == cd.imag());
+ }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+ {
+ constexpr std::complex<long double> cd(2.5, 3.5);
+ constexpr std::complex<double> cf(cd);
+ static_assert(cf.real() == cd.real(), "");
+ static_assert(cf.imag() == cd.imag(), "");
+ }
+#endif
+}
diff --git a/test/std/numerics/complex.number/complex.special/double_long_double_implicit.fail.cpp b/test/std/numerics/complex.number/complex.special/double_long_double_implicit.fail.cpp
new file mode 100644
index 000000000000..3866f6e33e71
--- /dev/null
+++ b/test/std/numerics/complex.number/complex.special/double_long_double_implicit.fail.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<> class complex<double>
+// {
+// public:
+// explicit constexpr complex(const complex<long double>&);
+// };
+
+#include <complex>
+#include <cassert>
+
+int main()
+{
+ const std::complex<long double> cd(2.5, 3.5);
+ std::complex<double> cf = cd;
+ assert(cf.real() == cd.real());
+ assert(cf.imag() == cd.imag());
+}
diff --git a/test/std/numerics/complex.number/complex.special/float_double_explicit.pass.cpp b/test/std/numerics/complex.number/complex.special/float_double_explicit.pass.cpp
new file mode 100644
index 000000000000..77ca9d7f2aac
--- /dev/null
+++ b/test/std/numerics/complex.number/complex.special/float_double_explicit.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<> class complex<float>
+// {
+// public:
+// explicit constexpr complex(const complex<double>&);
+// };
+
+#include <complex>
+#include <cassert>
+
+int main()
+{
+ {
+ const std::complex<double> cd(2.5, 3.5);
+ std::complex<float> cf(cd);
+ assert(cf.real() == cd.real());
+ assert(cf.imag() == cd.imag());
+ }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+ {
+ constexpr std::complex<double> cd(2.5, 3.5);
+ constexpr std::complex<float> cf(cd);
+ static_assert(cf.real() == cd.real(), "");
+ static_assert(cf.imag() == cd.imag(), "");
+ }
+#endif
+}
diff --git a/test/std/numerics/complex.number/complex.special/float_double_implicit.fail.cpp b/test/std/numerics/complex.number/complex.special/float_double_implicit.fail.cpp
new file mode 100644
index 000000000000..d1519753285d
--- /dev/null
+++ b/test/std/numerics/complex.number/complex.special/float_double_implicit.fail.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<> class complex<float>
+// {
+// public:
+// explicit constexpr complex(const complex<double>&);
+// };
+
+#include <complex>
+#include <cassert>
+
+int main()
+{
+ const std::complex<double> cd(2.5, 3.5);
+ std::complex<float> cf = cd;
+ assert(cf.real() == cd.real());
+ assert(cf.imag() == cd.imag());
+}
diff --git a/test/std/numerics/complex.number/complex.special/float_long_double_explicit.pass.cpp b/test/std/numerics/complex.number/complex.special/float_long_double_explicit.pass.cpp
new file mode 100644
index 000000000000..4fb11b4ca27c
--- /dev/null
+++ b/test/std/numerics/complex.number/complex.special/float_long_double_explicit.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<> class complex<float>
+// {
+// public:
+// explicit constexpr complex(const complex<long double>&);
+// };
+
+#include <complex>
+#include <cassert>
+
+int main()
+{
+ {
+ const std::complex<long double> cd(2.5, 3.5);
+ std::complex<float> cf(cd);
+ assert(cf.real() == cd.real());
+ assert(cf.imag() == cd.imag());
+ }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+ {
+ constexpr std::complex<long double> cd(2.5, 3.5);
+ constexpr std::complex<float> cf(cd);
+ static_assert(cf.real() == cd.real(), "");
+ static_assert(cf.imag() == cd.imag(), "");
+ }
+#endif
+}
diff --git a/test/std/numerics/complex.number/complex.special/float_long_double_implicit.fail.cpp b/test/std/numerics/complex.number/complex.special/float_long_double_implicit.fail.cpp
new file mode 100644
index 000000000000..9401febee5d6
--- /dev/null
+++ b/test/std/numerics/complex.number/complex.special/float_long_double_implicit.fail.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<> class complex<float>
+// {
+// public:
+// explicit constexpr complex(const complex<long double>&);
+// };
+
+#include <complex>
+#include <cassert>
+
+int main()
+{
+ const std::complex<long double> cd(2.5, 3.5);
+ std::complex<float> cf = cd;
+ assert(cf.real() == cd.real());
+ assert(cf.imag() == cd.imag());
+}
diff --git a/test/std/numerics/complex.number/complex.special/long_double_double_explicit.pass.cpp b/test/std/numerics/complex.number/complex.special/long_double_double_explicit.pass.cpp
new file mode 100644
index 000000000000..dd10c808b90a
--- /dev/null
+++ b/test/std/numerics/complex.number/complex.special/long_double_double_explicit.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<> class complex<long double>
+// {
+// public:
+// constexpr complex(const complex<double>&);
+// };
+
+#include <complex>
+#include <cassert>
+
+int main()
+{
+ {
+ const std::complex<double> cd(2.5, 3.5);
+ std::complex<long double> cf(cd);
+ assert(cf.real() == cd.real());
+ assert(cf.imag() == cd.imag());
+ }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+ {
+ constexpr std::complex<double> cd(2.5, 3.5);
+ constexpr std::complex<long double> cf(cd);
+ static_assert(cf.real() == cd.real(), "");
+ static_assert(cf.imag() == cd.imag(), "");
+ }
+#endif
+}
diff --git a/test/std/numerics/complex.number/complex.special/long_double_double_implicit.pass.cpp b/test/std/numerics/complex.number/complex.special/long_double_double_implicit.pass.cpp
new file mode 100644
index 000000000000..aab539407d0f
--- /dev/null
+++ b/test/std/numerics/complex.number/complex.special/long_double_double_implicit.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<> class complex<long double>
+// {
+// public:
+// constexpr complex(const complex<double>&);
+// };
+
+#include <complex>
+#include <cassert>
+
+int main()
+{
+ {
+ const std::complex<double> cd(2.5, 3.5);
+ std::complex<long double> cf = cd;
+ assert(cf.real() == cd.real());
+ assert(cf.imag() == cd.imag());
+ }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+ {
+ constexpr std::complex<double> cd(2.5, 3.5);
+ constexpr std::complex<long double> cf = cd;
+ static_assert(cf.real() == cd.real(), "");
+ static_assert(cf.imag() == cd.imag(), "");
+ }
+#endif
+}
diff --git a/test/std/numerics/complex.number/complex.special/long_double_float_explicit.pass.cpp b/test/std/numerics/complex.number/complex.special/long_double_float_explicit.pass.cpp
new file mode 100644
index 000000000000..a5f5101c4dc8
--- /dev/null
+++ b/test/std/numerics/complex.number/complex.special/long_double_float_explicit.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<> class complex<long double>
+// {
+// public:
+// constexpr complex(const complex<float>&);
+// };
+
+#include <complex>
+#include <cassert>
+
+int main()
+{
+ {
+ const std::complex<float> cd(2.5, 3.5);
+ std::complex<long double> cf(cd);
+ assert(cf.real() == cd.real());
+ assert(cf.imag() == cd.imag());
+ }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+ {
+ constexpr std::complex<float> cd(2.5, 3.5);
+ constexpr std::complex<long double> cf(cd);
+ static_assert(cf.real() == cd.real(), "");
+ static_assert(cf.imag() == cd.imag(), "");
+ }
+#endif
+}
diff --git a/test/std/numerics/complex.number/complex.special/long_double_float_implicit.pass.cpp b/test/std/numerics/complex.number/complex.special/long_double_float_implicit.pass.cpp
new file mode 100644
index 000000000000..25b93823f6ed
--- /dev/null
+++ b/test/std/numerics/complex.number/complex.special/long_double_float_implicit.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<> class complex<long double>
+// {
+// public:
+// constexpr complex(const complex<float>&);
+// };
+
+#include <complex>
+#include <cassert>
+
+int main()
+{
+ {
+ const std::complex<float> cd(2.5, 3.5);
+ std::complex<long double> cf = cd;
+ assert(cf.real() == cd.real());
+ assert(cf.imag() == cd.imag());
+ }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+ {
+ constexpr std::complex<float> cd(2.5, 3.5);
+ constexpr std::complex<long double> cf = cd;
+ static_assert(cf.real() == cd.real(), "");
+ static_assert(cf.imag() == cd.imag(), "");
+ }
+#endif
+}
diff --git a/test/std/numerics/complex.number/complex.synopsis/nothing_to_do.pass.cpp b/test/std/numerics/complex.number/complex.synopsis/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/numerics/complex.number/complex.synopsis/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/numerics/complex.number/complex.transcendentals/acos.pass.cpp b/test/std/numerics/complex.number/complex.transcendentals/acos.pass.cpp
new file mode 100644
index 000000000000..f8ee306d7544
--- /dev/null
+++ b/test/std/numerics/complex.number/complex.transcendentals/acos.pass.cpp
@@ -0,0 +1,140 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// complex<T>
+// acos(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const std::complex<T>& c, std::complex<T> x)
+{
+ assert(acos(c) == x);
+}
+
+template <class T>
+void
+test()
+{
+ test(std::complex<T>(INFINITY, 1), std::complex<T>(0, -INFINITY));
+}
+
+void test_edges()
+{
+ typedef std::complex<double> C;
+ const double pi = std::atan2(+0., -0.);
+ const unsigned N = sizeof(x) / sizeof(x[0]);
+ for (unsigned i = 0; i < N; ++i)
+ {
+ std::complex<double> r = acos(x[i]);
+ if (x[i].real() == 0 && x[i].imag() == 0)
+ {
+ is_about(r.real(), pi/2);
+ assert(r.imag() == 0);
+ assert(std::signbit(x[i].imag()) != std::signbit(r.imag()));
+ }
+ else if (x[i].real() == 0 && std::isnan(x[i].imag()))
+ {
+ is_about(r.real(), pi/2);
+ assert(std::isnan(r.imag()));
+ }
+ else if (std::isfinite(x[i].real()) && std::isinf(x[i].imag()))
+ {
+ is_about(r.real(), pi/2);
+ assert(std::isinf(r.imag()));
+ assert(std::signbit(x[i].imag()) != std::signbit(r.imag()));
+ }
+ else if (std::isfinite(x[i].real()) && x[i].real() != 0 && std::isnan(x[i].imag()))
+ {
+ assert(std::isnan(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ else if (std::isinf(x[i].real()) && x[i].real() < 0 && std::isfinite(x[i].imag()))
+ {
+ is_about(r.real(), pi);
+ assert(std::isinf(r.imag()));
+ assert(std::signbit(x[i].imag()) != std::signbit(r.imag()));
+ }
+ else if (std::isinf(x[i].real()) && x[i].real() > 0 && std::isfinite(x[i].imag()))
+ {
+ assert(r.real() == 0);
+ assert(!std::signbit(r.real()));
+ assert(std::isinf(r.imag()));
+ assert(std::signbit(x[i].imag()) != std::signbit(r.imag()));
+ }
+ else if (std::isinf(x[i].real()) && x[i].real() < 0 && std::isinf(x[i].imag()))
+ {
+ is_about(r.real(), 0.75 * pi);
+ assert(std::isinf(r.imag()));
+ assert(std::signbit(x[i].imag()) != std::signbit(r.imag()));
+ }
+ else if (std::isinf(x[i].real()) && x[i].real() > 0 && std::isinf(x[i].imag()))
+ {
+ is_about(r.real(), 0.25 * pi);
+ assert(std::isinf(r.imag()));
+ assert(std::signbit(x[i].imag()) != std::signbit(r.imag()));
+ }
+ else if (std::isinf(x[i].real()) && std::isnan(x[i].imag()))
+ {
+ assert(std::isnan(r.real()));
+ assert(std::isinf(r.imag()));
+ }
+ else if (std::isnan(x[i].real()) && std::isfinite(x[i].imag()))
+ {
+ assert(std::isnan(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ else if (std::isnan(x[i].real()) && std::isinf(x[i].imag()))
+ {
+ assert(std::isnan(r.real()));
+ assert(std::isinf(r.imag()));
+ assert(std::signbit(x[i].imag()) != std::signbit(r.imag()));
+ }
+ else if (std::isnan(x[i].real()) && std::isnan(x[i].imag()))
+ {
+ assert(std::isnan(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ else if (!std::signbit(x[i].real()) && !std::signbit(x[i].imag()))
+ {
+ assert(!std::signbit(r.real()));
+ assert( std::signbit(r.imag()));
+ }
+ else if (std::signbit(x[i].real()) && !std::signbit(x[i].imag()))
+ {
+ assert(!std::signbit(r.real()));
+ assert( std::signbit(r.imag()));
+ }
+ else if (std::signbit(x[i].real()) && std::signbit(x[i].imag()))
+ {
+ assert(!std::signbit(r.real()));
+ assert(!std::signbit(r.imag()));
+ }
+ else if (!std::signbit(x[i].real()) && std::signbit(x[i].imag()))
+ {
+ assert(!std::signbit(r.real()));
+ assert(!std::signbit(r.imag()));
+ }
+ }
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+ test_edges();
+}
diff --git a/test/std/numerics/complex.number/complex.transcendentals/acosh.pass.cpp b/test/std/numerics/complex.number/complex.transcendentals/acosh.pass.cpp
new file mode 100644
index 000000000000..88a5c798424d
--- /dev/null
+++ b/test/std/numerics/complex.number/complex.transcendentals/acosh.pass.cpp
@@ -0,0 +1,142 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// complex<T>
+// acosh(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const std::complex<T>& c, std::complex<T> x)
+{
+ assert(acosh(c) == x);
+}
+
+template <class T>
+void
+test()
+{
+ test(std::complex<T>(INFINITY, 1), std::complex<T>(INFINITY, 0));
+}
+
+void test_edges()
+{
+ typedef std::complex<double> C;
+ const double pi = std::atan2(+0., -0.);
+ const unsigned N = sizeof(x) / sizeof(x[0]);
+ for (unsigned i = 0; i < N; ++i)
+ {
+ std::complex<double> r = acosh(x[i]);
+ if (x[i].real() == 0 && x[i].imag() == 0)
+ {
+ assert(!std::signbit(r.real()));
+ if (std::signbit(x[i].imag()))
+ is_about(r.imag(), -pi/2);
+ else
+ is_about(r.imag(), pi/2);
+ }
+ else if (x[i].real() == 1 && x[i].imag() == 0)
+ {
+ assert(r.real() == 0);
+ assert(!std::signbit(r.real()));
+ assert(r.imag() == 0);
+ assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+ }
+ else if (std::isfinite(x[i].real()) && std::isinf(x[i].imag()))
+ {
+ assert(std::isinf(r.real()));
+ assert(r.real() > 0);
+ if (std::signbit(x[i].imag()))
+ is_about(r.imag(), -pi/2);
+ else
+ is_about(r.imag(), pi/2);
+ }
+ else if (std::isfinite(x[i].real()) && std::isnan(x[i].imag()))
+ {
+ assert(std::isnan(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ else if (std::isinf(x[i].real()) && x[i].real() < 0 && std::isfinite(x[i].imag()))
+ {
+ assert(std::isinf(r.real()));
+ assert(r.real() > 0);
+ if (std::signbit(x[i].imag()))
+ is_about(r.imag(), -pi);
+ else
+ is_about(r.imag(), pi);
+ }
+ else if (std::isinf(x[i].real()) && x[i].real() > 0 && std::isfinite(x[i].imag()))
+ {
+ assert(std::isinf(r.real()));
+ assert(r.real() > 0);
+ assert(r.imag() == 0);
+ assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+ }
+ else if (std::isinf(x[i].real()) && x[i].real() < 0 && std::isinf(x[i].imag()))
+ {
+ assert(std::isinf(r.real()));
+ assert(r.real() > 0);
+ if (std::signbit(x[i].imag()))
+ is_about(r.imag(), -0.75 * pi);
+ else
+ is_about(r.imag(), 0.75 * pi);
+ }
+ else if (std::isinf(x[i].real()) && x[i].real() > 0 && std::isinf(x[i].imag()))
+ {
+ assert(std::isinf(r.real()));
+ assert(r.real() > 0);
+ if (std::signbit(x[i].imag()))
+ is_about(r.imag(), -0.25 * pi);
+ else
+ is_about(r.imag(), 0.25 * pi);
+ }
+ else if (std::isinf(x[i].real()) && std::isnan(x[i].imag()))
+ {
+ assert(std::isinf(r.real()));
+ assert(r.real() > 0);
+ assert(std::isnan(r.imag()));
+ }
+ else if (std::isnan(x[i].real()) && std::isfinite(x[i].imag()))
+ {
+ assert(std::isnan(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ else if (std::isnan(x[i].real()) && std::isinf(x[i].imag()))
+ {
+ assert(std::isinf(r.real()));
+ assert(r.real() > 0);
+ assert(std::isnan(r.imag()));
+ }
+ else if (std::isnan(x[i].real()) && std::isnan(x[i].imag()))
+ {
+ assert(std::isnan(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ else
+ {
+ assert(!std::signbit(r.real()));
+ assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+ }
+ }
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+ test_edges();
+}
diff --git a/test/std/numerics/complex.number/complex.transcendentals/asin.pass.cpp b/test/std/numerics/complex.number/complex.transcendentals/asin.pass.cpp
new file mode 100644
index 000000000000..c743be6488c6
--- /dev/null
+++ b/test/std/numerics/complex.number/complex.transcendentals/asin.pass.cpp
@@ -0,0 +1,120 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// complex<T>
+// asin(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const std::complex<T>& c, std::complex<T> x)
+{
+ assert(asin(c) == x);
+}
+
+template <class T>
+void
+test()
+{
+ test(std::complex<T>(0, 0), std::complex<T>(0, 0));
+}
+
+void test_edges()
+{
+ typedef std::complex<double> C;
+ const double pi = std::atan2(+0., -0.);
+ const unsigned N = sizeof(x) / sizeof(x[0]);
+ for (unsigned i = 0; i < N; ++i)
+ {
+ std::complex<double> r = asin(x[i]);
+ if (x[i].real() == 0 && x[i].imag() == 0)
+ {
+ assert(std::signbit(r.real()) == std::signbit(x[i].real()));
+ assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+ }
+ else if (std::isfinite(x[i].real()) && std::isinf(x[i].imag()))
+ {
+ assert(r.real() == 0);
+ assert(std::signbit(x[i].real()) == std::signbit(r.real()));
+ assert(std::isinf(r.imag()));
+ assert(std::signbit(x[i].imag()) == std::signbit(r.imag()));
+ }
+ else if ( x[i].real() == 0 && std::isnan(x[i].imag()))
+ {
+ assert(r.real() == 0);
+ assert(std::signbit(x[i].real()) == std::signbit(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ else if (std::isfinite(x[i].real()) && std::isnan(x[i].imag()))
+ {
+ assert(std::isnan(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ else if (std::isinf(x[i].real()) && std::isfinite(x[i].imag()))
+ {
+ if (x[i].real() > 0)
+ is_about(r.real(), pi/2);
+ else
+ is_about(r.real(), - pi/2);
+ assert(std::isinf(r.imag()));
+ assert(std::signbit(x[i].imag()) == std::signbit(r.imag()));
+ }
+ else if (std::isinf(x[i].real()) && std::isinf(x[i].imag()))
+ {
+ if (std::signbit(x[i].real()))
+ is_about(r.real(), -pi/4);
+ else
+ is_about(r.real(), pi/4);
+ assert(std::isinf(r.imag()));
+ assert(std::signbit(x[i].imag()) == std::signbit(r.imag()));
+ }
+ else if (std::isinf(x[i].real()) && std::isnan(x[i].imag()))
+ {
+ assert(std::isnan(r.real()));
+ assert(std::isinf(r.imag()));
+ assert(std::signbit(x[i].real()) != std::signbit(r.imag()));
+ }
+ else if (std::isnan(x[i].real()) && std::isfinite(x[i].imag()))
+ {
+ assert(std::isnan(r.real()));
+ assert(std::isnan(r.imag()));
+ assert(std::signbit(x[i].imag()) == std::signbit(r.imag()));
+ }
+ else if (std::isnan(x[i].real()) && std::isinf(x[i].imag()))
+ {
+ assert(std::isnan(r.real()));
+ assert(std::isinf(r.imag()));
+ }
+ else if (std::isnan(x[i].real()) && std::isnan(x[i].imag()))
+ {
+ assert(std::isnan(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ else
+ {
+ assert(std::signbit(r.real()) == std::signbit(x[i].real()));
+ assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+ }
+ }
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+ test_edges();
+}
diff --git a/test/std/numerics/complex.number/complex.transcendentals/asinh.pass.cpp b/test/std/numerics/complex.number/complex.transcendentals/asinh.pass.cpp
new file mode 100644
index 000000000000..027bc6a98a99
--- /dev/null
+++ b/test/std/numerics/complex.number/complex.transcendentals/asinh.pass.cpp
@@ -0,0 +1,119 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// complex<T>
+// asinh(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const std::complex<T>& c, std::complex<T> x)
+{
+ assert(asinh(c) == x);
+}
+
+template <class T>
+void
+test()
+{
+ test(std::complex<T>(0, 0), std::complex<T>(0, 0));
+}
+
+void test_edges()
+{
+ typedef std::complex<double> C;
+ const double pi = std::atan2(+0., -0.);
+ const unsigned N = sizeof(x) / sizeof(x[0]);
+ for (unsigned i = 0; i < N; ++i)
+ {
+ std::complex<double> r = asinh(x[i]);
+ if (x[i].real() == 0 && x[i].imag() == 0)
+ {
+ assert(std::signbit(r.real()) == std::signbit(x[i].real()));
+ assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+ }
+ else if (std::isfinite(x[i].real()) && std::isinf(x[i].imag()))
+ {
+ assert(std::isinf(r.real()));
+ assert(std::signbit(x[i].real()) == std::signbit(r.real()));
+ if (std::signbit(x[i].imag()))
+ is_about(r.imag(), -pi/2);
+ else
+ is_about(r.imag(), pi/2);
+ }
+ else if (std::isfinite(x[i].real()) && std::isnan(x[i].imag()))
+ {
+ assert(std::isnan(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ else if (std::isinf(x[i].real()) && std::isfinite(x[i].imag()))
+ {
+ assert(std::isinf(r.real()));
+ assert(std::signbit(x[i].real()) == std::signbit(r.real()));
+ assert(r.imag() == 0);
+ assert(std::signbit(x[i].imag()) == std::signbit(r.imag()));
+ }
+ else if (std::isinf(x[i].real()) && std::isinf(x[i].imag()))
+ {
+ assert(std::isinf(r.real()));
+ assert(std::signbit(x[i].real()) == std::signbit(r.real()));
+ if (std::signbit(x[i].imag()))
+ is_about(r.imag(), -pi/4);
+ else
+ is_about(r.imag(), pi/4);
+ }
+ else if (std::isinf(x[i].real()) && std::isnan(x[i].imag()))
+ {
+ assert(std::isinf(r.real()));
+ assert(std::signbit(x[i].real()) == std::signbit(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ else if (std::isnan(x[i].real()) && x[i].imag() == 0)
+ {
+ assert(std::isnan(r.real()));
+ assert(r.imag() == 0);
+ assert(std::signbit(x[i].imag()) == std::signbit(r.imag()));
+ }
+ else if (std::isnan(x[i].real()) && std::isfinite(x[i].imag()))
+ {
+ assert(std::isnan(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ else if (std::isnan(x[i].real()) && std::isinf(x[i].imag()))
+ {
+ assert(std::isinf(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ else if (std::isnan(x[i].real()) && std::isnan(x[i].imag()))
+ {
+ assert(std::isnan(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ else
+ {
+ assert(std::signbit(r.real()) == std::signbit(x[i].real()));
+ assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+ }
+ }
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+ test_edges();
+}
diff --git a/test/std/numerics/complex.number/complex.transcendentals/atan.pass.cpp b/test/std/numerics/complex.number/complex.transcendentals/atan.pass.cpp
new file mode 100644
index 000000000000..69bc95240141
--- /dev/null
+++ b/test/std/numerics/complex.number/complex.transcendentals/atan.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// complex<T>
+// atan(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const std::complex<T>& c, std::complex<T> x)
+{
+ assert(atan(c) == x);
+}
+
+template <class T>
+void
+test()
+{
+ test(std::complex<T>(0, 0), std::complex<T>(0, 0));
+}
+
+void test_edges()
+{
+ typedef std::complex<double> C;
+ const unsigned N = sizeof(x) / sizeof(x[0]);
+ for (unsigned i = 0; i < N; ++i)
+ {
+ std::complex<double> r = atan(x[i]);
+ std::complex<double> t1(-imag(x[i]), real(x[i]));
+ std::complex<double> t2 = atanh(t1);
+ std::complex<double> z(imag(t2), -real(t2));
+ if (std::isnan(real(r)))
+ assert(std::isnan(real(z)));
+ else
+ {
+ assert(real(r) == real(z));
+ assert(std::signbit(real(r)) == std::signbit(real(z)));
+ }
+ if (std::isnan(imag(r)))
+ assert(std::isnan(imag(z)));
+ else
+ {
+ assert(imag(r) == imag(z));
+ assert(std::signbit(imag(r)) == std::signbit(imag(z)));
+ }
+ }
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+ test_edges();
+}
diff --git a/test/std/numerics/complex.number/complex.transcendentals/atanh.pass.cpp b/test/std/numerics/complex.number/complex.transcendentals/atanh.pass.cpp
new file mode 100644
index 000000000000..b821109b751b
--- /dev/null
+++ b/test/std/numerics/complex.number/complex.transcendentals/atanh.pass.cpp
@@ -0,0 +1,132 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// complex<T>
+// atanh(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const std::complex<T>& c, std::complex<T> x)
+{
+ assert(atanh(c) == x);
+}
+
+template <class T>
+void
+test()
+{
+ test(std::complex<T>(0, 0), std::complex<T>(0, 0));
+}
+
+void test_edges()
+{
+ typedef std::complex<double> C;
+ const double pi = std::atan2(+0., -0.);
+ const unsigned N = sizeof(x) / sizeof(x[0]);
+ for (unsigned i = 0; i < N; ++i)
+ {
+ std::complex<double> r = atanh(x[i]);
+ if (x[i].real() == 0 && x[i].imag() == 0)
+ {
+ assert(std::signbit(r.real()) == std::signbit(x[i].real()));
+ assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+ }
+ else if ( x[i].real() == 0 && std::isnan(x[i].imag()))
+ {
+ assert(r.real() == 0);
+ assert(std::signbit(x[i].real()) == std::signbit(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ else if (std::abs(x[i].real()) == 1 && x[i].imag() == 0)
+ {
+ assert(std::isinf(r.real()));
+ assert(std::signbit(x[i].real()) == std::signbit(r.real()));
+ assert(r.imag() == 0);
+ assert(std::signbit(x[i].imag()) == std::signbit(r.imag()));
+ }
+ else if (std::isfinite(x[i].real()) && std::isinf(x[i].imag()))
+ {
+ assert(r.real() == 0);
+ assert(std::signbit(x[i].real()) == std::signbit(r.real()));
+ if (x[i].imag() > 0)
+ is_about(r.imag(), pi/2);
+ else
+ is_about(r.imag(), -pi/2);
+ }
+ else if (std::isfinite(x[i].real()) && std::isnan(x[i].imag()))
+ {
+ assert(std::isnan(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ else if (std::isinf(x[i].real()) && std::isfinite(x[i].imag()))
+ {
+ assert(r.real() == 0);
+ assert(std::signbit(x[i].real()) == std::signbit(r.real()));
+ if (std::signbit(x[i].imag()))
+ is_about(r.imag(), -pi/2);
+ else
+ is_about(r.imag(), pi/2);
+ }
+ else if (std::isinf(x[i].real()) && std::isinf(x[i].imag()))
+ {
+ assert(r.real() == 0);
+ assert(std::signbit(x[i].real()) == std::signbit(r.real()));
+ if (std::signbit(x[i].imag()))
+ is_about(r.imag(), -pi/2);
+ else
+ is_about(r.imag(), pi/2);
+ }
+ else if (std::isinf(x[i].real()) && std::isnan(x[i].imag()))
+ {
+ assert(r.real() == 0);
+ assert(std::signbit(x[i].real()) == std::signbit(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ else if (std::isnan(x[i].real()) && std::isfinite(x[i].imag()))
+ {
+ assert(std::isnan(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ else if (std::isnan(x[i].real()) && std::isinf(x[i].imag()))
+ {
+ assert(r.real() == 0);
+ assert(std::signbit(x[i].real()) == std::signbit(r.real()));
+ if (std::signbit(x[i].imag()))
+ is_about(r.imag(), -pi/2);
+ else
+ is_about(r.imag(), pi/2);
+ }
+ else if (std::isnan(x[i].real()) && std::isnan(x[i].imag()))
+ {
+ assert(std::isnan(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ else
+ {
+ assert(std::signbit(r.real()) == std::signbit(x[i].real()));
+ assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+ }
+ }
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+ test_edges();
+}
diff --git a/test/std/numerics/complex.number/complex.transcendentals/cos.pass.cpp b/test/std/numerics/complex.number/complex.transcendentals/cos.pass.cpp
new file mode 100644
index 000000000000..f25c967cb1a7
--- /dev/null
+++ b/test/std/numerics/complex.number/complex.transcendentals/cos.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// complex<T>
+// cos(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const std::complex<T>& c, std::complex<T> x)
+{
+ assert(cos(c) == x);
+}
+
+template <class T>
+void
+test()
+{
+ test(std::complex<T>(0, 0), std::complex<T>(1, 0));
+}
+
+void test_edges()
+{
+ typedef std::complex<double> C;
+ const double pi = std::atan2(+0., -0.);
+ const unsigned N = sizeof(x) / sizeof(x[0]);
+ for (unsigned i = 0; i < N; ++i)
+ {
+ std::complex<double> r = cos(x[i]);
+ std::complex<double> t1(-imag(x[i]), real(x[i]));
+ std::complex<double> z = cosh(t1);
+ if (std::isnan(real(r)))
+ assert(std::isnan(real(z)));
+ else
+ {
+ assert(real(r) == real(z));
+ assert(std::signbit(real(r)) == std::signbit(real(z)));
+ }
+ if (std::isnan(imag(r)))
+ assert(std::isnan(imag(z)));
+ else
+ {
+ assert(imag(r) == imag(z));
+ assert(std::signbit(imag(r)) == std::signbit(imag(z)));
+ }
+ }
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+ test_edges();
+}
diff --git a/test/std/numerics/complex.number/complex.transcendentals/cosh.pass.cpp b/test/std/numerics/complex.number/complex.transcendentals/cosh.pass.cpp
new file mode 100644
index 000000000000..acf4746389c8
--- /dev/null
+++ b/test/std/numerics/complex.number/complex.transcendentals/cosh.pass.cpp
@@ -0,0 +1,118 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// complex<T>
+// cosh(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const std::complex<T>& c, std::complex<T> x)
+{
+ assert(cosh(c) == x);
+}
+
+template <class T>
+void
+test()
+{
+ test(std::complex<T>(0, 0), std::complex<T>(1, 0));
+}
+
+void test_edges()
+{
+ typedef std::complex<double> C;
+ const double pi = std::atan2(+0., -0.);
+ const unsigned N = sizeof(x) / sizeof(x[0]);
+ for (unsigned i = 0; i < N; ++i)
+ {
+ std::complex<double> r = cosh(x[i]);
+ if (x[i].real() == 0 && x[i].imag() == 0)
+ {
+ assert(r.real() == 1);
+ assert(r.imag() == 0);
+ assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+ }
+ else if (x[i].real() == 0 && std::isinf(x[i].imag()))
+ {
+ assert(std::isnan(r.real()));
+ assert(r.imag() == 0);
+ }
+ else if (x[i].real() == 0 && std::isnan(x[i].imag()))
+ {
+ assert(std::isnan(r.real()));
+ assert(r.imag() == 0);
+ }
+ else if (std::isfinite(x[i].real()) && std::isinf(x[i].imag()))
+ {
+ assert(std::isnan(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ else if (std::isfinite(x[i].real()) && std::isnan(x[i].imag()))
+ {
+ assert(std::isnan(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ else if (std::isinf(x[i].real()) && x[i].imag() == 0)
+ {
+ assert(std::isinf(r.real()));
+ assert(!std::signbit(r.real()));
+ assert(r.imag() == 0);
+ assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+ }
+ else if (std::isinf(x[i].real()) && std::isfinite(x[i].imag()))
+ {
+ assert(std::isinf(r.real()));
+ assert(std::signbit(r.real()) == std::signbit(cos(x[i].imag())));
+ assert(std::isinf(r.imag()));
+ assert(std::signbit(r.imag()) == std::signbit(x[i].real() * sin(x[i].imag())));
+ }
+ else if (std::isinf(x[i].real()) && std::isinf(x[i].imag()))
+ {
+ assert(std::isinf(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ else if (std::isinf(x[i].real()) && std::isnan(x[i].imag()))
+ {
+ assert(std::isinf(r.real()));
+ assert(r.real() > 0);
+ assert(std::isnan(r.imag()));
+ }
+ else if (std::isnan(x[i].real()) && x[i].imag() == 0)
+ {
+ assert(std::isnan(r.real()));
+ assert(r.imag() == 0);
+ }
+ else if (std::isnan(x[i].real()) && std::isfinite(x[i].imag()))
+ {
+ assert(std::isnan(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ else if (std::isnan(x[i].real()) && std::isnan(x[i].imag()))
+ {
+ assert(std::isnan(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ }
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+ test_edges();
+}
diff --git a/test/std/numerics/complex.number/complex.transcendentals/exp.pass.cpp b/test/std/numerics/complex.number/complex.transcendentals/exp.pass.cpp
new file mode 100644
index 000000000000..e8b507572f1b
--- /dev/null
+++ b/test/std/numerics/complex.number/complex.transcendentals/exp.pass.cpp
@@ -0,0 +1,114 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// complex<T>
+// exp(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const std::complex<T>& c, std::complex<T> x)
+{
+ assert(exp(c) == x);
+}
+
+template <class T>
+void
+test()
+{
+ test(std::complex<T>(0, 0), std::complex<T>(1, 0));
+}
+
+void test_edges()
+{
+ const unsigned N = sizeof(x) / sizeof(x[0]);
+ for (unsigned i = 0; i < N; ++i)
+ {
+ std::complex<double> r = exp(x[i]);
+ if (x[i].real() == 0 && x[i].imag() == 0)
+ {
+ assert(r.real() == 1.0);
+ assert(r.imag() == 0);
+ assert(std::signbit(x[i].imag()) == std::signbit(r.imag()));
+ }
+ else if (std::isfinite(x[i].real()) && std::isinf(x[i].imag()))
+ {
+ assert(std::isnan(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ else if (std::isfinite(x[i].real()) && std::isnan(x[i].imag()))
+ {
+ assert(std::isnan(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ else if (std::isinf(x[i].real()) && x[i].real() > 0 && x[i].imag() == 0)
+ {
+ assert(std::isinf(r.real()));
+ assert(r.real() > 0);
+ assert(r.imag() == 0);
+ assert(std::signbit(x[i].imag()) == std::signbit(r.imag()));
+ }
+ else if (std::isinf(x[i].real()) && x[i].real() < 0 && std::isinf(x[i].imag()))
+ {
+ assert(r.real() == 0);
+ assert(r.imag() == 0);
+ }
+ else if (std::isinf(x[i].real()) && x[i].real() > 0 && std::isinf(x[i].imag()))
+ {
+ assert(std::isinf(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ else if (std::isinf(x[i].real()) && x[i].real() < 0 && std::isnan(x[i].imag()))
+ {
+ assert(r.real() == 0);
+ assert(r.imag() == 0);
+ }
+ else if (std::isinf(x[i].real()) && x[i].real() > 0 && std::isnan(x[i].imag()))
+ {
+ assert(std::isinf(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ else if (std::isnan(x[i].real()) && x[i].imag() == 0)
+ {
+ assert(std::isnan(r.real()));
+ assert(r.imag() == 0);
+ assert(std::signbit(x[i].imag()) == std::signbit(r.imag()));
+ }
+ else if (std::isnan(x[i].real()) && x[i].imag() != 0)
+ {
+ assert(std::isnan(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ else if (std::isnan(x[i].real()) && std::isnan(x[i].imag()))
+ {
+ assert(std::isnan(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ else if (std::isfinite(x[i].imag()) && std::abs(x[i].imag()) <= 1)
+ {
+ assert(!std::signbit(r.real()));
+ assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+ }
+ }
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+ test_edges();
+}
diff --git a/test/std/numerics/complex.number/complex.transcendentals/log.pass.cpp b/test/std/numerics/complex.number/complex.transcendentals/log.pass.cpp
new file mode 100644
index 000000000000..800b92474bf0
--- /dev/null
+++ b/test/std/numerics/complex.number/complex.transcendentals/log.pass.cpp
@@ -0,0 +1,131 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// complex<T>
+// log(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const std::complex<T>& c, std::complex<T> x)
+{
+ assert(log(c) == x);
+}
+
+template <class T>
+void
+test()
+{
+ test(std::complex<T>(0, 0), std::complex<T>(-INFINITY, 0));
+}
+
+void test_edges()
+{
+ const double pi = std::atan2(+0., -0.);
+ const unsigned N = sizeof(x) / sizeof(x[0]);
+ for (unsigned i = 0; i < N; ++i)
+ {
+ std::complex<double> r = log(x[i]);
+ if (x[i].real() == 0 && x[i].imag() == 0)
+ {
+ if (std::signbit(x[i].real()))
+ {
+ assert(std::isinf(r.real()));
+ assert(r.real() < 0);
+ if (std::signbit(x[i].imag()))
+ is_about(r.imag(), -pi);
+ else
+ is_about(r.imag(), pi);
+ }
+ else
+ {
+ assert(std::isinf(r.real()));
+ assert(r.real() < 0);
+ assert(r.imag() == 0);
+ assert(std::signbit(x[i].imag()) == std::signbit(r.imag()));
+ }
+ }
+ else if (std::isfinite(x[i].real()) && std::isinf(x[i].imag()))
+ {
+ assert(std::isinf(r.real()));
+ assert(r.real() > 0);
+ if (x[i].imag() > 0)
+ is_about(r.imag(), pi/2);
+ else
+ is_about(r.imag(), -pi/2);
+ }
+ else if (std::isfinite(x[i].real()) && std::isnan(x[i].imag()))
+ {
+ assert(std::isnan(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ else if (std::isinf(x[i].real()) && x[i].real() < 0 && std::isfinite(x[i].imag()))
+ {
+ assert(std::isinf(r.real()) && r.real() > 0);
+ if (r.imag() > 0)
+ is_about(r.imag(), pi);
+ else
+ is_about(r.imag(), -pi);
+ }
+ else if (std::isinf(x[i].real()) && x[i].real() > 0 && std::isfinite(x[i].imag()))
+ {
+ assert(std::isinf(r.real()) && r.real() > 0);
+ assert(r.imag() == 0);
+ assert(std::signbit(x[i].imag()) == std::signbit(r.imag()));
+ }
+ else if (x[i].real() == 1 && x[i].imag() == 0)
+ {
+ assert(r.real() == 0);
+ assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+ }
+ else if (x[i].real() == 0 && x[i].imag() == 1)
+ {
+ assert(r.real() == 0);
+ is_about(r.imag(), pi/2);
+ }
+ else if (x[i].real() == -1 && x[i].imag() == 0)
+ {
+ assert(r.real() == 0);
+ if (std::signbit(x[i].imag()))
+ is_about(r.imag(), -pi);
+ else
+ is_about(r.imag(), pi);
+ }
+ else if (x[i].real() == 0 && x[i].imag() == -1)
+ {
+ assert(r.real() == 0);
+ is_about(r.imag(), -pi/2);
+ }
+ else if (std::isfinite(x[i].real()) && std::isfinite(x[i].imag()) && abs(x[i]) < 1)
+ {
+ assert( std::signbit(r.real()));
+ assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+ }
+ else if (std::isfinite(x[i].real()) && std::isfinite(x[i].imag()) && abs(x[i]) > 1)
+ {
+ assert(!std::signbit(r.real()));
+ assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+ }
+ }
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+ test_edges();
+}
diff --git a/test/std/numerics/complex.number/complex.transcendentals/log10.pass.cpp b/test/std/numerics/complex.number/complex.transcendentals/log10.pass.cpp
new file mode 100644
index 000000000000..ba03ebf8ad28
--- /dev/null
+++ b/test/std/numerics/complex.number/complex.transcendentals/log10.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// complex<T>
+// log10(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const std::complex<T>& c, std::complex<T> x)
+{
+ assert(log10(c) == x);
+}
+
+template <class T>
+void
+test()
+{
+ test(std::complex<T>(0, 0), std::complex<T>(-INFINITY, 0));
+}
+
+void test_edges()
+{
+ const double pi = std::atan2(+0., -0.);
+ const unsigned N = sizeof(x) / sizeof(x[0]);
+ for (unsigned i = 0; i < N; ++i)
+ {
+ std::complex<double> r = log10(x[i]);
+ std::complex<double> z = log(x[i])/std::log(10);
+ if (std::isnan(real(r)))
+ assert(std::isnan(real(z)));
+ else
+ {
+ assert(real(r) == real(z));
+ assert(std::signbit(real(r)) == std::signbit(real(z)));
+ }
+ if (std::isnan(imag(r)))
+ assert(std::isnan(imag(z)));
+ else
+ {
+ assert(imag(r) == imag(z));
+ assert(std::signbit(imag(r)) == std::signbit(imag(z)));
+ }
+ }
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+ test_edges();
+}
diff --git a/test/std/numerics/complex.number/complex.transcendentals/pow_complex_complex.pass.cpp b/test/std/numerics/complex.number/complex.transcendentals/pow_complex_complex.pass.cpp
new file mode 100644
index 000000000000..258193d257a8
--- /dev/null
+++ b/test/std/numerics/complex.number/complex.transcendentals/pow_complex_complex.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// complex<T>
+// pow(const complex<T>& x, const complex<T>& y);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const std::complex<T>& a, const std::complex<T>& b, std::complex<T> x)
+{
+ std::complex<T> c = pow(a, b);
+ is_about(real(c), real(x));
+ is_about(imag(c), imag(x));
+}
+
+template <class T>
+void
+test()
+{
+ test(std::complex<T>(2, 3), std::complex<T>(2, 0), std::complex<T>(-5, 12));
+}
+
+void test_edges()
+{
+ const double pi = std::atan2(+0., -0.);
+ const unsigned N = sizeof(x) / sizeof(x[0]);
+ for (unsigned i = 0; i < N; ++i)
+ {
+ for (unsigned j = 0; j < N; ++j)
+ {
+ std::complex<double> r = pow(x[i], x[j]);
+ std::complex<double> z = exp(x[j] * log(x[i]));
+ if (std::isnan(real(r)))
+ assert(std::isnan(real(z)));
+ else
+ {
+ assert(real(r) == real(z));
+ assert(std::signbit(real(r)) == std::signbit(real(z)));
+ }
+ if (std::isnan(imag(r)))
+ assert(std::isnan(imag(z)));
+ else
+ {
+ assert(imag(r) == imag(z));
+ assert(std::signbit(imag(r)) == std::signbit(imag(z)));
+ }
+ }
+ }
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+ test_edges();
+}
diff --git a/test/std/numerics/complex.number/complex.transcendentals/pow_complex_scalar.pass.cpp b/test/std/numerics/complex.number/complex.transcendentals/pow_complex_scalar.pass.cpp
new file mode 100644
index 000000000000..03bd10d465d1
--- /dev/null
+++ b/test/std/numerics/complex.number/complex.transcendentals/pow_complex_scalar.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// complex<T>
+// pow(const complex<T>& x, const T& y);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const std::complex<T>& a, const T& b, std::complex<T> x)
+{
+ std::complex<T> c = pow(a, b);
+ is_about(real(c), real(x));
+ is_about(imag(c), imag(x));
+}
+
+template <class T>
+void
+test()
+{
+ test(std::complex<T>(2, 3), T(2), std::complex<T>(-5, 12));
+}
+
+void test_edges()
+{
+ const double pi = std::atan2(+0., -0.);
+ const unsigned N = sizeof(x) / sizeof(x[0]);
+ for (unsigned i = 0; i < N; ++i)
+ {
+ for (unsigned j = 0; j < N; ++j)
+ {
+ std::complex<double> r = pow(x[i], real(x[j]));
+ std::complex<double> z = exp(std::complex<double>(real(x[j])) * log(x[i]));
+ if (std::isnan(real(r)))
+ assert(std::isnan(real(z)));
+ else
+ {
+ assert(real(r) == real(z));
+ }
+ if (std::isnan(imag(r)))
+ assert(std::isnan(imag(z)));
+ else
+ {
+ assert(imag(r) == imag(z));
+ }
+ }
+ }
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+ test_edges();
+}
diff --git a/test/std/numerics/complex.number/complex.transcendentals/pow_scalar_complex.pass.cpp b/test/std/numerics/complex.number/complex.transcendentals/pow_scalar_complex.pass.cpp
new file mode 100644
index 000000000000..a48498cea92c
--- /dev/null
+++ b/test/std/numerics/complex.number/complex.transcendentals/pow_scalar_complex.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// complex<T>
+// pow(const T& x, const complex<T>& y);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const T& a, const std::complex<T>& b, std::complex<T> x)
+{
+ std::complex<T> c = pow(a, b);
+ is_about(real(c), real(x));
+ assert(std::abs(imag(c)) < 1.e-6);
+}
+
+template <class T>
+void
+test()
+{
+ test(T(2), std::complex<T>(2), std::complex<T>(4));
+}
+
+void test_edges()
+{
+ const double pi = std::atan2(+0., -0.);
+ const unsigned N = sizeof(x) / sizeof(x[0]);
+ for (unsigned i = 0; i < N; ++i)
+ {
+ for (unsigned j = 0; j < N; ++j)
+ {
+ std::complex<double> r = pow(real(x[i]), x[j]);
+ std::complex<double> z = exp(x[j] * log(std::complex<double>(real(x[i]))));
+ if (std::isnan(real(r)))
+ assert(std::isnan(real(z)));
+ else
+ {
+ assert(real(r) == real(z));
+ }
+ if (std::isnan(imag(r)))
+ assert(std::isnan(imag(z)));
+ else
+ {
+ assert(imag(r) == imag(z));
+ }
+ }
+ }
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+ test_edges();
+}
diff --git a/test/std/numerics/complex.number/complex.transcendentals/sin.pass.cpp b/test/std/numerics/complex.number/complex.transcendentals/sin.pass.cpp
new file mode 100644
index 000000000000..068222a27373
--- /dev/null
+++ b/test/std/numerics/complex.number/complex.transcendentals/sin.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// complex<T>
+// sin(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const std::complex<T>& c, std::complex<T> x)
+{
+ assert(sin(c) == x);
+}
+
+template <class T>
+void
+test()
+{
+ test(std::complex<T>(0, 0), std::complex<T>(0, 0));
+}
+
+void test_edges()
+{
+ typedef std::complex<double> C;
+ const double pi = std::atan2(+0., -0.);
+ const unsigned N = sizeof(x) / sizeof(x[0]);
+ for (unsigned i = 0; i < N; ++i)
+ {
+ std::complex<double> r = sin(x[i]);
+ std::complex<double> t1(-imag(x[i]), real(x[i]));
+ std::complex<double> t2 = sinh(t1);
+ std::complex<double> z(imag(t2), -real(t2));
+ if (std::isnan(real(r)))
+ assert(std::isnan(real(z)));
+ else
+ {
+ assert(real(r) == real(z));
+ assert(std::signbit(real(r)) == std::signbit(real(z)));
+ }
+ if (std::isnan(imag(r)))
+ assert(std::isnan(imag(z)));
+ else
+ {
+ assert(imag(r) == imag(z));
+ assert(std::signbit(imag(r)) == std::signbit(imag(z)));
+ }
+ }
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+ test_edges();
+}
diff --git a/test/std/numerics/complex.number/complex.transcendentals/sinh.pass.cpp b/test/std/numerics/complex.number/complex.transcendentals/sinh.pass.cpp
new file mode 100644
index 000000000000..dcd30e48dff5
--- /dev/null
+++ b/test/std/numerics/complex.number/complex.transcendentals/sinh.pass.cpp
@@ -0,0 +1,119 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// complex<T>
+// sinh(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const std::complex<T>& c, std::complex<T> x)
+{
+ assert(sinh(c) == x);
+}
+
+template <class T>
+void
+test()
+{
+ test(std::complex<T>(0, 0), std::complex<T>(0, 0));
+}
+
+void test_edges()
+{
+ typedef std::complex<double> C;
+ const double pi = std::atan2(+0., -0.);
+ const unsigned N = sizeof(x) / sizeof(x[0]);
+ for (unsigned i = 0; i < N; ++i)
+ {
+ std::complex<double> r = sinh(x[i]);
+ if (x[i].real() == 0 && x[i].imag() == 0)
+ {
+ assert(r.real() == 0);
+ assert(std::signbit(r.real()) == std::signbit(x[i].real()));
+ assert(r.imag() == 0);
+ assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+ }
+ else if (x[i].real() == 0 && std::isinf(x[i].imag()))
+ {
+ assert(r.real() == 0);
+ assert(std::isnan(r.imag()));
+ }
+ else if (std::isfinite(x[i].real()) && std::isinf(x[i].imag()))
+ {
+ assert(std::isnan(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ else if (x[i].real() == 0 && std::isnan(x[i].imag()))
+ {
+ assert(r.real() == 0);
+ assert(std::isnan(r.imag()));
+ }
+ else if (std::isfinite(x[i].real()) && std::isnan(x[i].imag()))
+ {
+ assert(std::isnan(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ else if (std::isinf(x[i].real()) && x[i].imag() == 0)
+ {
+ assert(std::isinf(r.real()));
+ assert(std::signbit(r.real()) == std::signbit(x[i].real()));
+ assert(r.imag() == 0);
+ assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+ }
+ else if (std::isinf(x[i].real()) && std::isfinite(x[i].imag()))
+ {
+ assert(std::isinf(r.real()));
+ assert(std::signbit(r.real()) == std::signbit(x[i].real() * cos(x[i].imag())));
+ assert(std::isinf(r.imag()));
+ assert(std::signbit(r.imag()) == std::signbit(sin(x[i].imag())));
+ }
+ else if (std::isinf(x[i].real()) && std::isinf(x[i].imag()))
+ {
+ assert(std::isinf(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ else if (std::isinf(x[i].real()) && std::isnan(x[i].imag()))
+ {
+ assert(std::isinf(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ else if (std::isnan(x[i].real()) && x[i].imag() == 0)
+ {
+ assert(std::isnan(r.real()));
+ assert(r.imag() == 0);
+ assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+ }
+ else if (std::isnan(x[i].real()) && std::isfinite(x[i].imag()))
+ {
+ assert(std::isnan(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ else if (std::isnan(x[i].real()) && std::isnan(x[i].imag()))
+ {
+ assert(std::isnan(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ }
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+ test_edges();
+}
diff --git a/test/std/numerics/complex.number/complex.transcendentals/sqrt.pass.cpp b/test/std/numerics/complex.number/complex.transcendentals/sqrt.pass.cpp
new file mode 100644
index 000000000000..69309d2b9ab1
--- /dev/null
+++ b/test/std/numerics/complex.number/complex.transcendentals/sqrt.pass.cpp
@@ -0,0 +1,109 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// complex<T>
+// sqrt(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const std::complex<T>& c, std::complex<T> x)
+{
+ std::complex<T> a = sqrt(c);
+ is_about(real(a), real(x));
+ assert(std::abs(imag(c)) < 1.e-6);
+}
+
+template <class T>
+void
+test()
+{
+ test(std::complex<T>(64, 0), std::complex<T>(8, 0));
+}
+
+void test_edges()
+{
+ const unsigned N = sizeof(x) / sizeof(x[0]);
+ for (unsigned i = 0; i < N; ++i)
+ {
+ std::complex<double> r = sqrt(x[i]);
+ if (x[i].real() == 0 && x[i].imag() == 0)
+ {
+ assert(!std::signbit(r.real()));
+ assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+ }
+ else if (std::isinf(x[i].imag()))
+ {
+ assert(std::isinf(r.real()));
+ assert(r.real() > 0);
+ assert(std::isinf(r.imag()));
+ assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+ }
+ else if (std::isfinite(x[i].real()) && std::isnan(x[i].imag()))
+ {
+ assert(std::isnan(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ else if (std::isinf(x[i].real()) && x[i].real() < 0 && std::isfinite(x[i].imag()))
+ {
+ assert(r.real() == 0);
+ assert(!std::signbit(r.real()));
+ assert(std::isinf(r.imag()));
+ assert(std::signbit(x[i].imag()) == std::signbit(r.imag()));
+ }
+ else if (std::isinf(x[i].real()) && x[i].real() > 0 && std::isfinite(x[i].imag()))
+ {
+ assert(std::isinf(r.real()));
+ assert(r.real() > 0);
+ assert(r.imag() == 0);
+ assert(std::signbit(x[i].imag()) == std::signbit(r.imag()));
+ }
+ else if (std::isinf(x[i].real()) && x[i].real() < 0 && std::isnan(x[i].imag()))
+ {
+ assert(std::isnan(r.real()));
+ assert(std::isinf(r.imag()));
+ }
+ else if (std::isinf(x[i].real()) && x[i].real() > 0 && std::isnan(x[i].imag()))
+ {
+ assert(std::isinf(r.real()));
+ assert(r.real() > 0);
+ assert(std::isnan(r.imag()));
+ }
+ else if (std::isnan(x[i].real()) && (std::isfinite(x[i].imag()) || std::isnan(x[i].imag())))
+ {
+ assert(std::isnan(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ else if (std::signbit(x[i].imag()))
+ {
+ assert(!std::signbit(r.real()));
+ assert(std::signbit(r.imag()));
+ }
+ else
+ {
+ assert(!std::signbit(r.real()));
+ assert(!std::signbit(r.imag()));
+ }
+ }
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+ test_edges();
+}
diff --git a/test/std/numerics/complex.number/complex.transcendentals/tan.pass.cpp b/test/std/numerics/complex.number/complex.transcendentals/tan.pass.cpp
new file mode 100644
index 000000000000..881427600686
--- /dev/null
+++ b/test/std/numerics/complex.number/complex.transcendentals/tan.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// complex<T>
+// tan(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const std::complex<T>& c, std::complex<T> x)
+{
+ assert(tan(c) == x);
+}
+
+template <class T>
+void
+test()
+{
+ test(std::complex<T>(0, 0), std::complex<T>(0, 0));
+ test(std::complex<T>(10000, -10000), std::complex<T>(0, -1));
+}
+
+void test_edges()
+{
+ typedef std::complex<double> C;
+ const double pi = std::atan2(+0., -0.);
+ const unsigned N = sizeof(x) / sizeof(x[0]);
+ for (unsigned i = 0; i < N; ++i)
+ {
+ std::complex<double> r = tan(x[i]);
+ std::complex<double> t1(-imag(x[i]), real(x[i]));
+ std::complex<double> t2 = tanh(t1);
+ std::complex<double> z(imag(t2), -real(t2));
+ if (std::isnan(real(r)))
+ assert(std::isnan(real(z)));
+ else
+ {
+ assert(real(r) == real(z));
+ assert(std::signbit(real(r)) == std::signbit(real(z)));
+ }
+ if (std::isnan(imag(r)))
+ assert(std::isnan(imag(z)));
+ else
+ {
+ assert(imag(r) == imag(z));
+ assert(std::signbit(imag(r)) == std::signbit(imag(z)));
+ }
+ }
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+ test_edges();
+}
diff --git a/test/std/numerics/complex.number/complex.transcendentals/tanh.pass.cpp b/test/std/numerics/complex.number/complex.transcendentals/tanh.pass.cpp
new file mode 100644
index 000000000000..907c0e64dba9
--- /dev/null
+++ b/test/std/numerics/complex.number/complex.transcendentals/tanh.pass.cpp
@@ -0,0 +1,101 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// complex<T>
+// tanh(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const std::complex<T>& c, std::complex<T> x)
+{
+ assert(tanh(c) == x);
+}
+
+template <class T>
+void
+test()
+{
+ test(std::complex<T>(0, 0), std::complex<T>(0, 0));
+}
+
+void test_edges()
+{
+ typedef std::complex<double> C;
+ const double pi = std::atan2(+0., -0.);
+ const unsigned N = sizeof(x) / sizeof(x[0]);
+ for (unsigned i = 0; i < N; ++i)
+ {
+ std::complex<double> r = tanh(x[i]);
+ if (x[i].real() == 0 && x[i].imag() == 0)
+ {
+ assert(r.real() == 0);
+ assert(std::signbit(r.real()) == std::signbit(x[i].real()));
+ assert(r.imag() == 0);
+ assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+ }
+ else if (std::isfinite(x[i].real()) && std::isinf(x[i].imag()))
+ {
+ assert(std::isnan(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ else if (std::isfinite(x[i].real()) && std::isnan(x[i].imag()))
+ {
+ assert(std::isnan(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ else if (std::isinf(x[i].real()) && std::isfinite(x[i].imag()))
+ {
+ assert(r.real() == 1);
+ assert(r.imag() == 0);
+ assert(std::signbit(r.imag()) == std::signbit(sin(2*x[i].imag())));
+ }
+ else if (std::isinf(x[i].real()) && std::isinf(x[i].imag()))
+ {
+ assert(r.real() == 1);
+ assert(r.imag() == 0);
+ }
+ else if (std::isinf(x[i].real()) && std::isnan(x[i].imag()))
+ {
+ assert(r.real() == 1);
+ assert(r.imag() == 0);
+ }
+ else if (std::isnan(x[i].real()) && x[i].imag() == 0)
+ {
+ assert(std::isnan(r.real()));
+ assert(r.imag() == 0);
+ assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+ }
+ else if (std::isnan(x[i].real()) && std::isfinite(x[i].imag()))
+ {
+ assert(std::isnan(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ else if (std::isnan(x[i].real()) && std::isnan(x[i].imag()))
+ {
+ assert(std::isnan(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ }
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+ test_edges();
+}
diff --git a/test/std/numerics/complex.number/complex.value.ops/abs.pass.cpp b/test/std/numerics/complex.number/complex.value.ops/abs.pass.cpp
new file mode 100644
index 000000000000..5d841d6ee9f1
--- /dev/null
+++ b/test/std/numerics/complex.number/complex.value.ops/abs.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// T
+// abs(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test()
+{
+ std::complex<T> z(3, 4);
+ assert(abs(z) == 5);
+}
+
+void test_edges()
+{
+ const unsigned N = sizeof(x) / sizeof(x[0]);
+ for (unsigned i = 0; i < N; ++i)
+ {
+ double r = abs(x[i]);
+ switch (classify(x[i]))
+ {
+ case zero:
+ assert(r == 0);
+ assert(!std::signbit(r));
+ break;
+ case non_zero:
+ assert(std::isfinite(r) && r > 0);
+ break;
+ case inf:
+ assert(std::isinf(r) && r > 0);
+ break;
+ case NaN:
+ assert(std::isnan(r));
+ break;
+ case non_zero_nan:
+ assert(std::isnan(r));
+ break;
+ }
+ }
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+ test_edges();
+}
diff --git a/test/std/numerics/complex.number/complex.value.ops/arg.pass.cpp b/test/std/numerics/complex.number/complex.value.ops/arg.pass.cpp
new file mode 100644
index 000000000000..a7da456b979c
--- /dev/null
+++ b/test/std/numerics/complex.number/complex.value.ops/arg.pass.cpp
@@ -0,0 +1,135 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// T
+// arg(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test()
+{
+ std::complex<T> z(1, 0);
+ assert(arg(z) == 0);
+}
+
+void test_edges()
+{
+ const double pi = std::atan2(+0., -0.);
+ const unsigned N = sizeof(x) / sizeof(x[0]);
+ for (unsigned i = 0; i < N; ++i)
+ {
+ double r = arg(x[i]);
+ if (std::isnan(x[i].real()) || std::isnan(x[i].imag()))
+ assert(std::isnan(r));
+ else
+ {
+ switch (classify(x[i]))
+ {
+ case zero:
+ if (std::signbit(x[i].real()))
+ {
+ if (std::signbit(x[i].imag()))
+ is_about(r, -pi);
+ else
+ is_about(r, pi);
+ }
+ else
+ {
+ assert(std::signbit(x[i].imag()) == std::signbit(r));
+ }
+ break;
+ case non_zero:
+ if (x[i].real() == 0)
+ {
+ if (x[i].imag() < 0)
+ is_about(r, -pi/2);
+ else
+ is_about(r, pi/2);
+ }
+ else if (x[i].imag() == 0)
+ {
+ if (x[i].real() < 0)
+ {
+ if (std::signbit(x[i].imag()))
+ is_about(r, -pi);
+ else
+ is_about(r, pi);
+ }
+ else
+ {
+ assert(r == 0);
+ assert(std::signbit(x[i].imag()) == std::signbit(r));
+ }
+ }
+ else if (x[i].imag() > 0)
+ assert(r > 0);
+ else
+ assert(r < 0);
+ break;
+ case inf:
+ if (std::isinf(x[i].real()) && std::isinf(x[i].imag()))
+ {
+ if (x[i].real() < 0)
+ {
+ if (x[i].imag() > 0)
+ is_about(r, 0.75 * pi);
+ else
+ is_about(r, -0.75 * pi);
+ }
+ else
+ {
+ if (x[i].imag() > 0)
+ is_about(r, 0.25 * pi);
+ else
+ is_about(r, -0.25 * pi);
+ }
+ }
+ else if (std::isinf(x[i].real()))
+ {
+ if (x[i].real() < 0)
+ {
+ if (std::signbit(x[i].imag()))
+ is_about(r, -pi);
+ else
+ is_about(r, pi);
+ }
+ else
+ {
+ assert(r == 0);
+ assert(std::signbit(r) == std::signbit(x[i].imag()));
+ }
+ }
+ else
+ {
+ if (x[i].imag() < 0)
+ is_about(r, -pi/2);
+ else
+ is_about(r, pi/2);
+ }
+ break;
+ }
+ }
+ }
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+ test_edges();
+}
diff --git a/test/std/numerics/complex.number/complex.value.ops/conj.pass.cpp b/test/std/numerics/complex.number/complex.value.ops/conj.pass.cpp
new file mode 100644
index 000000000000..71f276d8d470
--- /dev/null
+++ b/test/std/numerics/complex.number/complex.value.ops/conj.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// complex<T>
+// conj(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test(const std::complex<T>& z, std::complex<T> x)
+{
+ assert(conj(z) == x);
+}
+
+template <class T>
+void
+test()
+{
+ test(std::complex<T>(1, 2), std::complex<T>(1, -2));
+ test(std::complex<T>(-1, 2), std::complex<T>(-1, -2));
+ test(std::complex<T>(1, -2), std::complex<T>(1, 2));
+ test(std::complex<T>(-1, -2), std::complex<T>(-1, 2));
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+}
diff --git a/test/std/numerics/complex.number/complex.value.ops/imag.pass.cpp b/test/std/numerics/complex.number/complex.value.ops/imag.pass.cpp
new file mode 100644
index 000000000000..fa7b7339a6d4
--- /dev/null
+++ b/test/std/numerics/complex.number/complex.value.ops/imag.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// T
+// imag(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+ std::complex<T> z(1.5, 2.5);
+ assert(imag(z) == 2.5);
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+}
diff --git a/test/std/numerics/complex.number/complex.value.ops/norm.pass.cpp b/test/std/numerics/complex.number/complex.value.ops/norm.pass.cpp
new file mode 100644
index 000000000000..48f774e8e1c9
--- /dev/null
+++ b/test/std/numerics/complex.number/complex.value.ops/norm.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// T
+// norm(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test()
+{
+ std::complex<T> z(3, 4);
+ assert(norm(z) == 25);
+}
+
+void test_edges()
+{
+ const unsigned N = sizeof(x) / sizeof(x[0]);
+ for (unsigned i = 0; i < N; ++i)
+ {
+ double r = norm(x[i]);
+ switch (classify(x[i]))
+ {
+ case zero:
+ assert(r == 0);
+ assert(!std::signbit(r));
+ break;
+ case non_zero:
+ assert(std::isfinite(r) && r > 0);
+ break;
+ case inf:
+ assert(std::isinf(r) && r > 0);
+ break;
+ case NaN:
+ assert(std::isnan(r));
+ break;
+ case non_zero_nan:
+ assert(std::isnan(r));
+ break;
+ }
+ }
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+ test_edges();
+}
diff --git a/test/std/numerics/complex.number/complex.value.ops/polar.pass.cpp b/test/std/numerics/complex.number/complex.value.ops/polar.pass.cpp
new file mode 100644
index 000000000000..a8747bd7c83b
--- /dev/null
+++ b/test/std/numerics/complex.number/complex.value.ops/polar.pass.cpp
@@ -0,0 +1,112 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// complex<T>
+// polar(const T& rho, const T& theta = 0);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const T& rho, std::complex<T> x)
+{
+ assert(std::polar(rho) == x);
+}
+
+template <class T>
+void
+test(const T& rho, const T& theta, std::complex<T> x)
+{
+ assert(std::polar(rho, theta) == x);
+}
+
+template <class T>
+void
+test()
+{
+ test(T(0), std::complex<T>(0, 0));
+ test(T(1), std::complex<T>(1, 0));
+ test(T(100), std::complex<T>(100, 0));
+ test(T(0), T(0), std::complex<T>(0, 0));
+ test(T(1), T(0), std::complex<T>(1, 0));
+ test(T(100), T(0), std::complex<T>(100, 0));
+}
+
+void test_edges()
+{
+ const unsigned N = sizeof(x) / sizeof(x[0]);
+ for (unsigned i = 0; i < N; ++i)
+ {
+ double r = real(x[i]);
+ double theta = imag(x[i]);
+ std::complex<double> z = std::polar(r, theta);
+ switch (classify(r))
+ {
+ case zero:
+ if (std::signbit(r) || classify(theta) == inf || classify(theta) == NaN)
+ {
+ int c = classify(z);
+ assert(c == NaN || c == non_zero_nan);
+ }
+ else
+ {
+ assert(z == std::complex<double>());
+ }
+ break;
+ case non_zero:
+ if (std::signbit(r) || classify(theta) == inf || classify(theta) == NaN)
+ {
+ int c = classify(z);
+ assert(c == NaN || c == non_zero_nan);
+ }
+ else
+ {
+ is_about(std::abs(z), r);
+ }
+ break;
+ case inf:
+ if (r < 0)
+ {
+ int c = classify(z);
+ assert(c == NaN || c == non_zero_nan);
+ }
+ else
+ {
+ assert(classify(z) == inf);
+ if (classify(theta) != NaN && classify(theta) != inf)
+ {
+ assert(classify(real(z)) != NaN);
+ assert(classify(imag(z)) != NaN);
+ }
+ }
+ break;
+ case NaN:
+ case non_zero_nan:
+ {
+ int c = classify(z);
+ assert(c == NaN || c == non_zero_nan);
+ }
+ break;
+ }
+ }
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+ test_edges();
+}
diff --git a/test/std/numerics/complex.number/complex.value.ops/proj.pass.cpp b/test/std/numerics/complex.number/complex.value.ops/proj.pass.cpp
new file mode 100644
index 000000000000..10bf7f8576f6
--- /dev/null
+++ b/test/std/numerics/complex.number/complex.value.ops/proj.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// complex<T>
+// proj(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const std::complex<T>& z, std::complex<T> x)
+{
+ assert(proj(z) == x);
+}
+
+template <class T>
+void
+test()
+{
+ test(std::complex<T>(1, 2), std::complex<T>(1, 2));
+ test(std::complex<T>(-1, 2), std::complex<T>(-1, 2));
+ test(std::complex<T>(1, -2), std::complex<T>(1, -2));
+ test(std::complex<T>(-1, -2), std::complex<T>(-1, -2));
+}
+
+void test_edges()
+{
+ const unsigned N = sizeof(x) / sizeof(x[0]);
+ for (unsigned i = 0; i < N; ++i)
+ {
+ std::complex<double> r = proj(x[i]);
+ switch (classify(x[i]))
+ {
+ case zero:
+ case non_zero:
+ assert(r == x[i]);
+ assert(std::signbit(real(r)) == std::signbit(real(x[i])));
+ assert(std::signbit(imag(r)) == std::signbit(imag(x[i])));
+ break;
+ case inf:
+ assert(std::isinf(real(r)) && real(r) > 0);
+ assert(imag(r) == 0);
+ assert(std::signbit(imag(r)) == std::signbit(imag(x[i])));
+ break;
+ case NaN:
+ case non_zero_nan:
+ assert(classify(r) == classify(x[i]));
+ break;
+ }
+ }
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+ test_edges();
+}
diff --git a/test/std/numerics/complex.number/complex.value.ops/real.pass.cpp b/test/std/numerics/complex.number/complex.value.ops/real.pass.cpp
new file mode 100644
index 000000000000..fbb51f080640
--- /dev/null
+++ b/test/std/numerics/complex.number/complex.value.ops/real.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// T
+// real(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+ std::complex<T> z(1.5, 2.5);
+ assert(real(z) == 1.5);
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+}
diff --git a/test/std/numerics/complex.number/complex/types.pass.cpp b/test/std/numerics/complex.number/complex/types.pass.cpp
new file mode 100644
index 000000000000..4da9a2a90295
--- /dev/null
+++ b/test/std/numerics/complex.number/complex/types.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// class complex
+// {
+// public:
+// typedef T value_type;
+// ...
+// };
+
+#include <complex>
+#include <type_traits>
+
+template <class T>
+void
+test()
+{
+ typedef std::complex<T> C;
+ static_assert((std::is_same<typename C::value_type, T>::value), "");
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+}
diff --git a/test/std/numerics/complex.number/layout.pass.cpp b/test/std/numerics/complex.number/layout.pass.cpp
new file mode 100644
index 000000000000..a9f356d4a40a
--- /dev/null
+++ b/test/std/numerics/complex.number/layout.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+ std::complex<T> z;
+ T* a = (T*)&z;
+ assert(0 == z.real());
+ assert(0 == z.imag());
+ assert(a[0] == z.real());
+ assert(a[1] == z.imag());
+ a[0] = 5;
+ a[1] = 6;
+ assert(a[0] == z.real());
+ assert(a[1] == z.imag());
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+}
diff --git a/test/std/numerics/complex.number/version.pass.cpp b/test/std/numerics/complex.number/version.pass.cpp
new file mode 100644
index 000000000000..316cfec739a9
--- /dev/null
+++ b/test/std/numerics/complex.number/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+#include <complex>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/numerics/nothing_to_do.pass.cpp b/test/std/numerics/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/numerics/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/numerics/numarray/class.gslice/gslice.access/tested_elsewhere.pass.cpp b/test/std/numerics/numarray/class.gslice/gslice.access/tested_elsewhere.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/numerics/numarray/class.gslice/gslice.access/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/numerics/numarray/class.gslice/gslice.cons/default.pass.cpp b/test/std/numerics/numarray/class.gslice/gslice.cons/default.pass.cpp
new file mode 100644
index 000000000000..29cc34f0767a
--- /dev/null
+++ b/test/std/numerics/numarray/class.gslice/gslice.cons/default.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// class glice;
+
+// gslice();
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ std::gslice gs;
+ assert(gs.start() == 0);
+ assert(gs.size().size() == 0);
+ assert(gs.stride().size() == 0);
+}
diff --git a/test/std/numerics/numarray/class.gslice/gslice.cons/start_size_stride.pass.cpp b/test/std/numerics/numarray/class.gslice/gslice.cons/start_size_stride.pass.cpp
new file mode 100644
index 000000000000..931c0d3c7bfe
--- /dev/null
+++ b/test/std/numerics/numarray/class.gslice/gslice.cons/start_size_stride.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// class glice;
+
+// gslice(size_t start, const valarray<size_t>& size,
+// const valarray<size_t>& stride);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ std::size_t a1[] = {1, 2, 3};
+ std::size_t a2[] = {4, 5, 6};
+ std::valarray<std::size_t> size(a1, sizeof(a1)/sizeof(a1[0]));
+ std::valarray<std::size_t> stride(a2, sizeof(a2)/sizeof(a2[0]));
+ std::gslice gs(7, size, stride);
+ assert(gs.start() == 7);
+ std::valarray<std::size_t> r = gs.size();
+ assert(r.size() == 3);
+ assert(r[0] == 1);
+ assert(r[1] == 2);
+ assert(r[2] == 3);
+ r = gs.stride();
+ assert(r.size() == 3);
+ assert(r[0] == 4);
+ assert(r[1] == 5);
+ assert(r[2] == 6);
+}
diff --git a/test/std/numerics/numarray/class.gslice/nothing_to_do.pass.cpp b/test/std/numerics/numarray/class.gslice/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/numerics/numarray/class.gslice/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/numerics/numarray/class.slice/cons.slice/default.pass.cpp b/test/std/numerics/numarray/class.slice/cons.slice/default.pass.cpp
new file mode 100644
index 000000000000..d0a6cc0d28dd
--- /dev/null
+++ b/test/std/numerics/numarray/class.slice/cons.slice/default.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// class slice;
+
+// slice();
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ std::slice s;
+ assert(s.start() == 0);
+ assert(s.size() == 0);
+ assert(s.stride() == 0);
+}
diff --git a/test/std/numerics/numarray/class.slice/cons.slice/start_size_stride.pass.cpp b/test/std/numerics/numarray/class.slice/cons.slice/start_size_stride.pass.cpp
new file mode 100644
index 000000000000..84f7ed6a18e1
--- /dev/null
+++ b/test/std/numerics/numarray/class.slice/cons.slice/start_size_stride.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// class slice;
+
+// slice(size_t start, size_t size, size_t stride);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ std::slice s(1, 3, 2);
+ assert(s.start() == 1);
+ assert(s.size() == 3);
+ assert(s.stride() == 2);
+}
diff --git a/test/std/numerics/numarray/class.slice/nothing_to_do.pass.cpp b/test/std/numerics/numarray/class.slice/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/numerics/numarray/class.slice/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/numerics/numarray/class.slice/slice.access/tested_elsewhere.pass.cpp b/test/std/numerics/numarray/class.slice/slice.access/tested_elsewhere.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/numerics/numarray/class.slice/slice.access/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/numerics/numarray/template.gslice.array/default.fail.cpp b/test/std/numerics/numarray/template.gslice.array/default.fail.cpp
new file mode 100644
index 000000000000..d691cbe08a41
--- /dev/null
+++ b/test/std/numerics/numarray/template.gslice.array/default.fail.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class gslice_array
+
+// gslice_array() = delete;
+
+#include <valarray>
+#include <type_traits>
+
+int main()
+{
+ std::gslice_array<int> gs;
+}
diff --git a/test/std/numerics/numarray/template.gslice.array/gslice.array.assign/gslice_array.pass.cpp b/test/std/numerics/numarray/template.gslice.array/gslice.array.assign/gslice_array.pass.cpp
new file mode 100644
index 000000000000..d26a7b36cade
--- /dev/null
+++ b/test/std/numerics/numarray/template.gslice.array/gslice.array.assign/gslice_array.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class gslice_array
+
+// const gslice_array& operator=(const gslice_array& ga) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a1[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
+ 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+ 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+ 36, 37, 38, 39, 40};
+ int a2[] = { -0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11,
+ -12, -13, -14, -15, -16, -17, -18, -19, -20, -21, -22, -23,
+ -24, -25, -26, -27, -28, -29, -30, -31, -32, -33, -34, -35,
+ -36, -37};
+ std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+ const std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+ std::size_t sz[] = {2, 4, 3};
+ std::size_t st[] = {19, 4, 1};
+ typedef std::valarray<std::size_t> sizes;
+ typedef std::valarray<std::size_t> strides;
+ v1[std::gslice(3, sizes(sz, sizeof(sz)/sizeof(sz[0])),
+ strides(st, sizeof(st)/sizeof(st[0])))]
+ = v2[std::gslice(3, sizes(sz, sizeof(sz)/sizeof(sz[0])),
+ strides(st, sizeof(st)/sizeof(st[0])))];
+ assert(v1.size() == 41);
+ assert(v1[ 0] == 0);
+ assert(v1[ 1] == 1);
+ assert(v1[ 2] == 2);
+ assert(v1[ 3] == -3);
+ assert(v1[ 4] == -4);
+ assert(v1[ 5] == -5);
+ assert(v1[ 6] == 6);
+ assert(v1[ 7] == -7);
+ assert(v1[ 8] == -8);
+ assert(v1[ 9] == -9);
+ assert(v1[10] == 10);
+ assert(v1[11] == -11);
+ assert(v1[12] == -12);
+ assert(v1[13] == -13);
+ assert(v1[14] == 14);
+ assert(v1[15] == -15);
+ assert(v1[16] == -16);
+ assert(v1[17] == -17);
+ assert(v1[18] == 18);
+ assert(v1[19] == 19);
+ assert(v1[20] == 20);
+ assert(v1[21] == 21);
+ assert(v1[22] == -22);
+ assert(v1[23] == -23);
+ assert(v1[24] == -24);
+ assert(v1[25] == 25);
+ assert(v1[26] == -26);
+ assert(v1[27] == -27);
+ assert(v1[28] == -28);
+ assert(v1[29] == 29);
+ assert(v1[30] == -30);
+ assert(v1[31] == -31);
+ assert(v1[32] == -32);
+ assert(v1[33] == 33);
+ assert(v1[34] == -34);
+ assert(v1[35] == -35);
+ assert(v1[36] == -36);
+ assert(v1[37] == 37);
+ assert(v1[38] == 38);
+ assert(v1[39] == 39);
+ assert(v1[40] == 40);
+}
diff --git a/test/std/numerics/numarray/template.gslice.array/gslice.array.assign/valarray.pass.cpp b/test/std/numerics/numarray/template.gslice.array/gslice.array.assign/valarray.pass.cpp
new file mode 100644
index 000000000000..2f960c12d6b0
--- /dev/null
+++ b/test/std/numerics/numarray/template.gslice.array/gslice.array.assign/valarray.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class gslice_array
+
+// void operator=(const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a1[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
+ 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+ 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+ 36, 37, 38, 39, 40};
+ int a2[] = { -0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11,
+ -12, -13, -14, -15, -16, -17, -18, -19, -20, -21, -22, -23};
+ std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+ std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+ std::size_t sz[] = {2, 4, 3};
+ std::size_t st[] = {19, 4, 1};
+ typedef std::valarray<std::size_t> sizes;
+ typedef std::valarray<std::size_t> strides;
+ v1[std::gslice(3, sizes(sz, sizeof(sz)/sizeof(sz[0])),
+ strides(st, sizeof(st)/sizeof(st[0])))] = v2;
+ assert(v1.size() == 41);
+ assert(v1[ 0] == 0);
+ assert(v1[ 1] == 1);
+ assert(v1[ 2] == 2);
+ assert(v1[ 3] == 0);
+ assert(v1[ 4] == -1);
+ assert(v1[ 5] == -2);
+ assert(v1[ 6] == 6);
+ assert(v1[ 7] == -3);
+ assert(v1[ 8] == -4);
+ assert(v1[ 9] == -5);
+ assert(v1[10] == 10);
+ assert(v1[11] == -6);
+ assert(v1[12] == -7);
+ assert(v1[13] == -8);
+ assert(v1[14] == 14);
+ assert(v1[15] == -9);
+ assert(v1[16] == -10);
+ assert(v1[17] == -11);
+ assert(v1[18] == 18);
+ assert(v1[19] == 19);
+ assert(v1[20] == 20);
+ assert(v1[21] == 21);
+ assert(v1[22] == -12);
+ assert(v1[23] == -13);
+ assert(v1[24] == -14);
+ assert(v1[25] == 25);
+ assert(v1[26] == -15);
+ assert(v1[27] == -16);
+ assert(v1[28] == -17);
+ assert(v1[29] == 29);
+ assert(v1[30] == -18);
+ assert(v1[31] == -19);
+ assert(v1[32] == -20);
+ assert(v1[33] == 33);
+ assert(v1[34] == -21);
+ assert(v1[35] == -22);
+ assert(v1[36] == -23);
+ assert(v1[37] == 37);
+ assert(v1[38] == 38);
+ assert(v1[39] == 39);
+ assert(v1[40] == 40);
+}
diff --git a/test/std/numerics/numarray/template.gslice.array/gslice.array.comp.assign/addition.pass.cpp b/test/std/numerics/numarray/template.gslice.array/gslice.array.comp.assign/addition.pass.cpp
new file mode 100644
index 000000000000..bd2ad7074c10
--- /dev/null
+++ b/test/std/numerics/numarray/template.gslice.array/gslice.array.comp.assign/addition.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class gslice_array
+
+// void operator+= (const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a1[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
+ 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+ 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+ 36, 37, 38, 39, 40};
+ int a2[] = { -0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11,
+ -12, -13, -14, -15, -16, -17, -18, -19, -20, -21, -22, -23};
+ std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+ std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+ std::size_t sz[] = {2, 4, 3};
+ std::size_t st[] = {19, 4, 1};
+ typedef std::valarray<std::size_t> sizes;
+ typedef std::valarray<std::size_t> strides;
+ v1[std::gslice(3, sizes(sz, sizeof(sz)/sizeof(sz[0])),
+ strides(st, sizeof(st)/sizeof(st[0])))] += v2;
+ assert(v1.size() == 41);
+ assert(v1[ 0] == 0);
+ assert(v1[ 1] == 1);
+ assert(v1[ 2] == 2);
+ assert(v1[ 3] == 3);
+ assert(v1[ 4] == 3);
+ assert(v1[ 5] == 3);
+ assert(v1[ 6] == 6);
+ assert(v1[ 7] == 4);
+ assert(v1[ 8] == 4);
+ assert(v1[ 9] == 4);
+ assert(v1[10] == 10);
+ assert(v1[11] == 5);
+ assert(v1[12] == 5);
+ assert(v1[13] == 5);
+ assert(v1[14] == 14);
+ assert(v1[15] == 6);
+ assert(v1[16] == 6);
+ assert(v1[17] == 6);
+ assert(v1[18] == 18);
+ assert(v1[19] == 19);
+ assert(v1[20] == 20);
+ assert(v1[21] == 21);
+ assert(v1[22] == 10);
+ assert(v1[23] == 10);
+ assert(v1[24] == 10);
+ assert(v1[25] == 25);
+ assert(v1[26] == 11);
+ assert(v1[27] == 11);
+ assert(v1[28] == 11);
+ assert(v1[29] == 29);
+ assert(v1[30] == 12);
+ assert(v1[31] == 12);
+ assert(v1[32] == 12);
+ assert(v1[33] == 33);
+ assert(v1[34] == 13);
+ assert(v1[35] == 13);
+ assert(v1[36] == 13);
+ assert(v1[37] == 37);
+ assert(v1[38] == 38);
+ assert(v1[39] == 39);
+ assert(v1[40] == 40);
+}
diff --git a/test/std/numerics/numarray/template.gslice.array/gslice.array.comp.assign/and.pass.cpp b/test/std/numerics/numarray/template.gslice.array/gslice.array.comp.assign/and.pass.cpp
new file mode 100644
index 000000000000..6875c5ea700b
--- /dev/null
+++ b/test/std/numerics/numarray/template.gslice.array/gslice.array.comp.assign/and.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class gslice_array
+
+// void operator&= (const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a1[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
+ 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+ 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+ 36, 37, 38, 39, 40};
+ int a2[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
+ 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24};
+ std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+ std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+ std::size_t sz[] = {2, 4, 3};
+ std::size_t st[] = {19, 4, 1};
+ typedef std::valarray<std::size_t> sizes;
+ typedef std::valarray<std::size_t> strides;
+ v1[std::gslice(3, sizes(sz, sizeof(sz)/sizeof(sz[0])),
+ strides(st, sizeof(st)/sizeof(st[0])))] &= v2;
+ assert(v1.size() == 41);
+ assert(v1[ 0] == 0);
+ assert(v1[ 1] == 1);
+ assert(v1[ 2] == 2);
+ assert(v1[ 3] == 1);
+ assert(v1[ 4] == 0);
+ assert(v1[ 5] == 1);
+ assert(v1[ 6] == 6);
+ assert(v1[ 7] == 4);
+ assert(v1[ 8] == 0);
+ assert(v1[ 9] == 0);
+ assert(v1[10] == 10);
+ assert(v1[11] == 3);
+ assert(v1[12] == 8);
+ assert(v1[13] == 9);
+ assert(v1[14] == 14);
+ assert(v1[15] == 10);
+ assert(v1[16] == 0);
+ assert(v1[17] == 0);
+ assert(v1[18] == 18);
+ assert(v1[19] == 19);
+ assert(v1[20] == 20);
+ assert(v1[21] == 21);
+ assert(v1[22] == 4);
+ assert(v1[23] == 6);
+ assert(v1[24] == 8);
+ assert(v1[25] == 25);
+ assert(v1[26] == 16);
+ assert(v1[27] == 17);
+ assert(v1[28] == 16);
+ assert(v1[29] == 29);
+ assert(v1[30] == 18);
+ assert(v1[31] == 20);
+ assert(v1[32] == 0);
+ assert(v1[33] == 33);
+ assert(v1[34] == 2);
+ assert(v1[35] == 3);
+ assert(v1[36] == 0);
+ assert(v1[37] == 37);
+ assert(v1[38] == 38);
+ assert(v1[39] == 39);
+ assert(v1[40] == 40);
+}
diff --git a/test/std/numerics/numarray/template.gslice.array/gslice.array.comp.assign/divide.pass.cpp b/test/std/numerics/numarray/template.gslice.array/gslice.array.comp.assign/divide.pass.cpp
new file mode 100644
index 000000000000..33a00328f34d
--- /dev/null
+++ b/test/std/numerics/numarray/template.gslice.array/gslice.array.comp.assign/divide.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class gslice_array
+
+// void operator/= (const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a1[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
+ 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+ 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+ 36, 37, 38, 39, 40};
+ int a2[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
+ 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24};
+ std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+ std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+ std::size_t sz[] = {2, 4, 3};
+ std::size_t st[] = {19, 4, 1};
+ typedef std::valarray<std::size_t> sizes;
+ typedef std::valarray<std::size_t> strides;
+ v1[std::gslice(3, sizes(sz, sizeof(sz)/sizeof(sz[0])),
+ strides(st, sizeof(st)/sizeof(st[0])))] /= v2;
+ assert(v1.size() == 41);
+ assert(v1[ 0] == 0);
+ assert(v1[ 1] == 1);
+ assert(v1[ 2] == 2);
+ assert(v1[ 3] == 3);
+ assert(v1[ 4] == 2);
+ assert(v1[ 5] == 1);
+ assert(v1[ 6] == 6);
+ assert(v1[ 7] == 1);
+ assert(v1[ 8] == 1);
+ assert(v1[ 9] == 1);
+ assert(v1[10] == 10);
+ assert(v1[11] == 1);
+ assert(v1[12] == 1);
+ assert(v1[13] == 1);
+ assert(v1[14] == 14);
+ assert(v1[15] == 1);
+ assert(v1[16] == 1);
+ assert(v1[17] == 1);
+ assert(v1[18] == 18);
+ assert(v1[19] == 19);
+ assert(v1[20] == 20);
+ assert(v1[21] == 21);
+ assert(v1[22] == 1);
+ assert(v1[23] == 1);
+ assert(v1[24] == 1);
+ assert(v1[25] == 25);
+ assert(v1[26] == 1);
+ assert(v1[27] == 1);
+ assert(v1[28] == 1);
+ assert(v1[29] == 29);
+ assert(v1[30] == 1);
+ assert(v1[31] == 1);
+ assert(v1[32] == 1);
+ assert(v1[33] == 33);
+ assert(v1[34] == 1);
+ assert(v1[35] == 1);
+ assert(v1[36] == 1);
+ assert(v1[37] == 37);
+ assert(v1[38] == 38);
+ assert(v1[39] == 39);
+ assert(v1[40] == 40);
+}
diff --git a/test/std/numerics/numarray/template.gslice.array/gslice.array.comp.assign/modulo.pass.cpp b/test/std/numerics/numarray/template.gslice.array/gslice.array.comp.assign/modulo.pass.cpp
new file mode 100644
index 000000000000..addc43da09e0
--- /dev/null
+++ b/test/std/numerics/numarray/template.gslice.array/gslice.array.comp.assign/modulo.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class gslice_array
+
+// void operator%= (const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a1[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
+ 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+ 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+ 36, 37, 38, 39, 40};
+ int a2[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
+ 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24};
+ std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+ std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+ std::size_t sz[] = {2, 4, 3};
+ std::size_t st[] = {19, 4, 1};
+ typedef std::valarray<std::size_t> sizes;
+ typedef std::valarray<std::size_t> strides;
+ v1[std::gslice(3, sizes(sz, sizeof(sz)/sizeof(sz[0])),
+ strides(st, sizeof(st)/sizeof(st[0])))] %= v2;
+ assert(v1.size() == 41);
+ assert(v1[ 0] == 0);
+ assert(v1[ 1] == 1);
+ assert(v1[ 2] == 2);
+ assert(v1[ 3] == 0);
+ assert(v1[ 4] == 0);
+ assert(v1[ 5] == 2);
+ assert(v1[ 6] == 6);
+ assert(v1[ 7] == 3);
+ assert(v1[ 8] == 3);
+ assert(v1[ 9] == 3);
+ assert(v1[10] == 10);
+ assert(v1[11] == 4);
+ assert(v1[12] == 4);
+ assert(v1[13] == 4);
+ assert(v1[14] == 14);
+ assert(v1[15] == 5);
+ assert(v1[16] == 5);
+ assert(v1[17] == 5);
+ assert(v1[18] == 18);
+ assert(v1[19] == 19);
+ assert(v1[20] == 20);
+ assert(v1[21] == 21);
+ assert(v1[22] == 9);
+ assert(v1[23] == 9);
+ assert(v1[24] == 9);
+ assert(v1[25] == 25);
+ assert(v1[26] == 10);
+ assert(v1[27] == 10);
+ assert(v1[28] == 10);
+ assert(v1[29] == 29);
+ assert(v1[30] == 11);
+ assert(v1[31] == 11);
+ assert(v1[32] == 11);
+ assert(v1[33] == 33);
+ assert(v1[34] == 12);
+ assert(v1[35] == 12);
+ assert(v1[36] == 12);
+ assert(v1[37] == 37);
+ assert(v1[38] == 38);
+ assert(v1[39] == 39);
+ assert(v1[40] == 40);
+}
diff --git a/test/std/numerics/numarray/template.gslice.array/gslice.array.comp.assign/multiply.pass.cpp b/test/std/numerics/numarray/template.gslice.array/gslice.array.comp.assign/multiply.pass.cpp
new file mode 100644
index 000000000000..37555fdfa300
--- /dev/null
+++ b/test/std/numerics/numarray/template.gslice.array/gslice.array.comp.assign/multiply.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class gslice_array
+
+// void operator*= (const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a1[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
+ 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+ 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+ 36, 37, 38, 39, 40};
+ int a2[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
+ 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24};
+ std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+ std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+ std::size_t sz[] = {2, 4, 3};
+ std::size_t st[] = {19, 4, 1};
+ typedef std::valarray<std::size_t> sizes;
+ typedef std::valarray<std::size_t> strides;
+ v1[std::gslice(3, sizes(sz, sizeof(sz)/sizeof(sz[0])),
+ strides(st, sizeof(st)/sizeof(st[0])))] *= v2;
+ assert(v1.size() == 41);
+ assert(v1[ 0] == 0);
+ assert(v1[ 1] == 1);
+ assert(v1[ 2] == 2);
+ assert(v1[ 3] == 3);
+ assert(v1[ 4] == 8);
+ assert(v1[ 5] == 15);
+ assert(v1[ 6] == 6);
+ assert(v1[ 7] == 28);
+ assert(v1[ 8] == 40);
+ assert(v1[ 9] == 54);
+ assert(v1[10] == 10);
+ assert(v1[11] == 77);
+ assert(v1[12] == 96);
+ assert(v1[13] == 117);
+ assert(v1[14] == 14);
+ assert(v1[15] == 150);
+ assert(v1[16] == 176);
+ assert(v1[17] == 204);
+ assert(v1[18] == 18);
+ assert(v1[19] == 19);
+ assert(v1[20] == 20);
+ assert(v1[21] == 21);
+ assert(v1[22] == 286);
+ assert(v1[23] == 322);
+ assert(v1[24] == 360);
+ assert(v1[25] == 25);
+ assert(v1[26] == 416);
+ assert(v1[27] == 459);
+ assert(v1[28] == 504);
+ assert(v1[29] == 29);
+ assert(v1[30] == 570);
+ assert(v1[31] == 620);
+ assert(v1[32] == 672);
+ assert(v1[33] == 33);
+ assert(v1[34] == 748);
+ assert(v1[35] == 805);
+ assert(v1[36] == 864);
+ assert(v1[37] == 37);
+ assert(v1[38] == 38);
+ assert(v1[39] == 39);
+ assert(v1[40] == 40);
+}
diff --git a/test/std/numerics/numarray/template.gslice.array/gslice.array.comp.assign/or.pass.cpp b/test/std/numerics/numarray/template.gslice.array/gslice.array.comp.assign/or.pass.cpp
new file mode 100644
index 000000000000..24e96e821a88
--- /dev/null
+++ b/test/std/numerics/numarray/template.gslice.array/gslice.array.comp.assign/or.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class gslice_array
+
+// void operator|= (const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a1[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
+ 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+ 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+ 36, 37, 38, 39, 40};
+ int a2[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
+ 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24};
+ std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+ std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+ std::size_t sz[] = {2, 4, 3};
+ std::size_t st[] = {19, 4, 1};
+ typedef std::valarray<std::size_t> sizes;
+ typedef std::valarray<std::size_t> strides;
+ v1[std::gslice(3, sizes(sz, sizeof(sz)/sizeof(sz[0])),
+ strides(st, sizeof(st)/sizeof(st[0])))] |= v2;
+ assert(v1.size() == 41);
+ assert(v1[ 0] == 0);
+ assert(v1[ 1] == 1);
+ assert(v1[ 2] == 2);
+ assert(v1[ 3] == 3);
+ assert(v1[ 4] == 6);
+ assert(v1[ 5] == 7);
+ assert(v1[ 6] == 6);
+ assert(v1[ 7] == 7);
+ assert(v1[ 8] == 13);
+ assert(v1[ 9] == 15);
+ assert(v1[10] == 10);
+ assert(v1[11] == 15);
+ assert(v1[12] == 12);
+ assert(v1[13] == 13);
+ assert(v1[14] == 14);
+ assert(v1[15] == 15);
+ assert(v1[16] == 27);
+ assert(v1[17] == 29);
+ assert(v1[18] == 18);
+ assert(v1[19] == 19);
+ assert(v1[20] == 20);
+ assert(v1[21] == 21);
+ assert(v1[22] == 31);
+ assert(v1[23] == 31);
+ assert(v1[24] == 31);
+ assert(v1[25] == 25);
+ assert(v1[26] == 26);
+ assert(v1[27] == 27);
+ assert(v1[28] == 30);
+ assert(v1[29] == 29);
+ assert(v1[30] == 31);
+ assert(v1[31] == 31);
+ assert(v1[32] == 53);
+ assert(v1[33] == 33);
+ assert(v1[34] == 54);
+ assert(v1[35] == 55);
+ assert(v1[36] == 60);
+ assert(v1[37] == 37);
+ assert(v1[38] == 38);
+ assert(v1[39] == 39);
+ assert(v1[40] == 40);
+}
diff --git a/test/std/numerics/numarray/template.gslice.array/gslice.array.comp.assign/shift_left.pass.cpp b/test/std/numerics/numarray/template.gslice.array/gslice.array.comp.assign/shift_left.pass.cpp
new file mode 100644
index 000000000000..ddaf4f7ca5b8
--- /dev/null
+++ b/test/std/numerics/numarray/template.gslice.array/gslice.array.comp.assign/shift_left.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class gslice_array
+
+// void operator<<= (const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a1[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
+ 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+ 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+ 36, 37, 38, 39, 40};
+ int a2[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
+ 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24};
+ std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+ std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+ std::size_t sz[] = {2, 4, 3};
+ std::size_t st[] = {19, 4, 1};
+ typedef std::valarray<std::size_t> sizes;
+ typedef std::valarray<std::size_t> strides;
+ v1[std::gslice(3, sizes(sz, sizeof(sz)/sizeof(sz[0])),
+ strides(st, sizeof(st)/sizeof(st[0])))] <<= v2;
+ assert(v1.size() == 41);
+ assert(v1[ 0] == 0);
+ assert(v1[ 1] == 1);
+ assert(v1[ 2] == 2);
+ assert(v1[ 3] == 6);
+ assert(v1[ 4] == 16);
+ assert(v1[ 5] == 40);
+ assert(v1[ 6] == 6);
+ assert(v1[ 7] == 112);
+ assert(v1[ 8] == 256);
+ assert(v1[ 9] == 576);
+ assert(v1[10] == 10);
+ assert(v1[11] == 1408);
+ assert(v1[12] == 3072);
+ assert(v1[13] == 6656);
+ assert(v1[14] == 14);
+ assert(v1[15] == 15360);
+ assert(v1[16] == 32768);
+ assert(v1[17] == 69632);
+ assert(v1[18] == 18);
+ assert(v1[19] == 19);
+ assert(v1[20] == 20);
+ assert(v1[21] == 21);
+ assert(v1[22] == 180224);
+ assert(v1[23] == 376832);
+ assert(v1[24] == 786432);
+ assert(v1[25] == 25);
+ assert(v1[26] == 1703936);
+ assert(v1[27] == 3538944);
+ assert(v1[28] == 7340032);
+ assert(v1[29] == 29);
+ assert(v1[30] == 15728640);
+ assert(v1[31] == 32505856);
+ assert(v1[32] == 67108864);
+ assert(v1[33] == 33);
+ assert(v1[34] == 142606336);
+ assert(v1[35] == 293601280);
+ assert(v1[36] == 603979776);
+ assert(v1[37] == 37);
+ assert(v1[38] == 38);
+ assert(v1[39] == 39);
+ assert(v1[40] == 40);
+}
diff --git a/test/std/numerics/numarray/template.gslice.array/gslice.array.comp.assign/shift_right.pass.cpp b/test/std/numerics/numarray/template.gslice.array/gslice.array.comp.assign/shift_right.pass.cpp
new file mode 100644
index 000000000000..4c06a29e51e6
--- /dev/null
+++ b/test/std/numerics/numarray/template.gslice.array/gslice.array.comp.assign/shift_right.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class gslice_array
+
+// void operator>>= (const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a1[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
+ 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+ 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+ 36, 37, 38, 39, 40};
+ int a2[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
+ 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24};
+ std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+ std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+ std::size_t sz[] = {2, 4, 3};
+ std::size_t st[] = {19, 4, 1};
+ typedef std::valarray<std::size_t> sizes;
+ typedef std::valarray<std::size_t> strides;
+ v1[std::gslice(3, sizes(sz, sizeof(sz)/sizeof(sz[0])),
+ strides(st, sizeof(st)/sizeof(st[0])))] >>= v2;
+ assert(v1.size() == 41);
+ assert(v1[ 0] == 0);
+ assert(v1[ 1] == 1);
+ assert(v1[ 2] == 2);
+ assert(v1[ 3] == 1);
+ assert(v1[ 4] == 1);
+ assert(v1[ 5] == 0);
+ assert(v1[ 6] == 6);
+ assert(v1[ 7] == 0);
+ assert(v1[ 8] == 0);
+ assert(v1[ 9] == 0);
+ assert(v1[10] == 10);
+ assert(v1[11] == 0);
+ assert(v1[12] == 0);
+ assert(v1[13] == 0);
+ assert(v1[14] == 14);
+ assert(v1[15] == 0);
+ assert(v1[16] == 0);
+ assert(v1[17] == 0);
+ assert(v1[18] == 18);
+ assert(v1[19] == 19);
+ assert(v1[20] == 20);
+ assert(v1[21] == 21);
+ assert(v1[22] == 0);
+ assert(v1[23] == 0);
+ assert(v1[24] == 0);
+ assert(v1[25] == 25);
+ assert(v1[26] == 0);
+ assert(v1[27] == 0);
+ assert(v1[28] == 0);
+ assert(v1[29] == 29);
+ assert(v1[30] == 0);
+ assert(v1[31] == 0);
+ assert(v1[32] == 0);
+ assert(v1[33] == 33);
+ assert(v1[34] == 0);
+ assert(v1[35] == 0);
+ assert(v1[36] == 0);
+ assert(v1[37] == 37);
+ assert(v1[38] == 38);
+ assert(v1[39] == 39);
+ assert(v1[40] == 40);
+}
diff --git a/test/std/numerics/numarray/template.gslice.array/gslice.array.comp.assign/subtraction.pass.cpp b/test/std/numerics/numarray/template.gslice.array/gslice.array.comp.assign/subtraction.pass.cpp
new file mode 100644
index 000000000000..3feda53aef1d
--- /dev/null
+++ b/test/std/numerics/numarray/template.gslice.array/gslice.array.comp.assign/subtraction.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class gslice_array
+
+// void operator-= (const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a1[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
+ 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+ 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+ 36, 37, 38, 39, 40};
+ int a2[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
+ 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24};
+ std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+ std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+ std::size_t sz[] = {2, 4, 3};
+ std::size_t st[] = {19, 4, 1};
+ typedef std::valarray<std::size_t> sizes;
+ typedef std::valarray<std::size_t> strides;
+ v1[std::gslice(3, sizes(sz, sizeof(sz)/sizeof(sz[0])),
+ strides(st, sizeof(st)/sizeof(st[0])))] -= v2;
+ assert(v1.size() == 41);
+ assert(v1[ 0] == 0);
+ assert(v1[ 1] == 1);
+ assert(v1[ 2] == 2);
+ assert(v1[ 3] == 2);
+ assert(v1[ 4] == 2);
+ assert(v1[ 5] == 2);
+ assert(v1[ 6] == 6);
+ assert(v1[ 7] == 3);
+ assert(v1[ 8] == 3);
+ assert(v1[ 9] == 3);
+ assert(v1[10] == 10);
+ assert(v1[11] == 4);
+ assert(v1[12] == 4);
+ assert(v1[13] == 4);
+ assert(v1[14] == 14);
+ assert(v1[15] == 5);
+ assert(v1[16] == 5);
+ assert(v1[17] == 5);
+ assert(v1[18] == 18);
+ assert(v1[19] == 19);
+ assert(v1[20] == 20);
+ assert(v1[21] == 21);
+ assert(v1[22] == 9);
+ assert(v1[23] == 9);
+ assert(v1[24] == 9);
+ assert(v1[25] == 25);
+ assert(v1[26] == 10);
+ assert(v1[27] == 10);
+ assert(v1[28] == 10);
+ assert(v1[29] == 29);
+ assert(v1[30] == 11);
+ assert(v1[31] == 11);
+ assert(v1[32] == 11);
+ assert(v1[33] == 33);
+ assert(v1[34] == 12);
+ assert(v1[35] == 12);
+ assert(v1[36] == 12);
+ assert(v1[37] == 37);
+ assert(v1[38] == 38);
+ assert(v1[39] == 39);
+ assert(v1[40] == 40);
+}
diff --git a/test/std/numerics/numarray/template.gslice.array/gslice.array.comp.assign/xor.pass.cpp b/test/std/numerics/numarray/template.gslice.array/gslice.array.comp.assign/xor.pass.cpp
new file mode 100644
index 000000000000..125935169e22
--- /dev/null
+++ b/test/std/numerics/numarray/template.gslice.array/gslice.array.comp.assign/xor.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class gslice_array
+
+// void operator^= (const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a1[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
+ 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+ 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+ 36, 37, 38, 39, 40};
+ int a2[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
+ 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24};
+ std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+ std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+ std::size_t sz[] = {2, 4, 3};
+ std::size_t st[] = {19, 4, 1};
+ typedef std::valarray<std::size_t> sizes;
+ typedef std::valarray<std::size_t> strides;
+ v1[std::gslice(3, sizes(sz, sizeof(sz)/sizeof(sz[0])),
+ strides(st, sizeof(st)/sizeof(st[0])))] ^= v2;
+ assert(v1.size() == 41);
+ assert(v1[ 0] == 0);
+ assert(v1[ 1] == 1);
+ assert(v1[ 2] == 2);
+ assert(v1[ 3] == 2);
+ assert(v1[ 4] == 6);
+ assert(v1[ 5] == 6);
+ assert(v1[ 6] == 6);
+ assert(v1[ 7] == 3);
+ assert(v1[ 8] == 13);
+ assert(v1[ 9] == 15);
+ assert(v1[10] == 10);
+ assert(v1[11] == 12);
+ assert(v1[12] == 4);
+ assert(v1[13] == 4);
+ assert(v1[14] == 14);
+ assert(v1[15] == 5);
+ assert(v1[16] == 27);
+ assert(v1[17] == 29);
+ assert(v1[18] == 18);
+ assert(v1[19] == 19);
+ assert(v1[20] == 20);
+ assert(v1[21] == 21);
+ assert(v1[22] == 27);
+ assert(v1[23] == 25);
+ assert(v1[24] == 23);
+ assert(v1[25] == 25);
+ assert(v1[26] == 10);
+ assert(v1[27] == 10);
+ assert(v1[28] == 14);
+ assert(v1[29] == 29);
+ assert(v1[30] == 13);
+ assert(v1[31] == 11);
+ assert(v1[32] == 53);
+ assert(v1[33] == 33);
+ assert(v1[34] == 52);
+ assert(v1[35] == 52);
+ assert(v1[36] == 60);
+ assert(v1[37] == 37);
+ assert(v1[38] == 38);
+ assert(v1[39] == 39);
+ assert(v1[40] == 40);
+}
diff --git a/test/std/numerics/numarray/template.gslice.array/gslice.array.fill/assign_value.pass.cpp b/test/std/numerics/numarray/template.gslice.array/gslice.array.fill/assign_value.pass.cpp
new file mode 100644
index 000000000000..5c5591aa1093
--- /dev/null
+++ b/test/std/numerics/numarray/template.gslice.array/gslice.array.fill/assign_value.pass.cpp
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class gslice_array
+
+// void operator=(const value_type& x) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a1[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
+ 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+ 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+ 36, 37, 38, 39, 40};
+ std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+ std::size_t sz[] = {2, 4, 3};
+ std::size_t st[] = {19, 4, 1};
+ typedef std::valarray<std::size_t> sizes;
+ typedef std::valarray<std::size_t> strides;
+ v1[std::gslice(3, sizes(sz, sizeof(sz)/sizeof(sz[0])),
+ strides(st, sizeof(st)/sizeof(st[0])))] = 51;
+ assert(v1.size() == 41);
+ assert(v1[ 0] == 0);
+ assert(v1[ 1] == 1);
+ assert(v1[ 2] == 2);
+ assert(v1[ 3] == 51);
+ assert(v1[ 4] == 51);
+ assert(v1[ 5] == 51);
+ assert(v1[ 6] == 6);
+ assert(v1[ 7] == 51);
+ assert(v1[ 8] == 51);
+ assert(v1[ 9] == 51);
+ assert(v1[10] == 10);
+ assert(v1[11] == 51);
+ assert(v1[12] == 51);
+ assert(v1[13] == 51);
+ assert(v1[14] == 14);
+ assert(v1[15] == 51);
+ assert(v1[16] == 51);
+ assert(v1[17] == 51);
+ assert(v1[18] == 18);
+ assert(v1[19] == 19);
+ assert(v1[20] == 20);
+ assert(v1[21] == 21);
+ assert(v1[22] == 51);
+ assert(v1[23] == 51);
+ assert(v1[24] == 51);
+ assert(v1[25] == 25);
+ assert(v1[26] == 51);
+ assert(v1[27] == 51);
+ assert(v1[28] == 51);
+ assert(v1[29] == 29);
+ assert(v1[30] == 51);
+ assert(v1[31] == 51);
+ assert(v1[32] == 51);
+ assert(v1[33] == 33);
+ assert(v1[34] == 51);
+ assert(v1[35] == 51);
+ assert(v1[36] == 51);
+ assert(v1[37] == 37);
+ assert(v1[38] == 38);
+ assert(v1[39] == 39);
+ assert(v1[40] == 40);
+}
diff --git a/test/std/numerics/numarray/template.gslice.array/types.pass.cpp b/test/std/numerics/numarray/template.gslice.array/types.pass.cpp
new file mode 100644
index 000000000000..005d907b41c0
--- /dev/null
+++ b/test/std/numerics/numarray/template.gslice.array/types.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T>
+// class gslice_array
+// {
+// public:
+// typedef T value_type;
+
+#include <valarray>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_same<std::gslice_array<int>::value_type, int>::value), "");
+}
diff --git a/test/std/numerics/numarray/template.indirect.array/default.fail.cpp b/test/std/numerics/numarray/template.indirect.array/default.fail.cpp
new file mode 100644
index 000000000000..2f5e5d832835
--- /dev/null
+++ b/test/std/numerics/numarray/template.indirect.array/default.fail.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class indirect_array
+
+// indirect_array() = delete;
+
+#include <valarray>
+#include <type_traits>
+
+int main()
+{
+ std::indirect_array<int> ia;
+}
diff --git a/test/std/numerics/numarray/template.indirect.array/indirect.array.assign/indirect_array.pass.cpp b/test/std/numerics/numarray/template.indirect.array/indirect.array.assign/indirect_array.pass.cpp
new file mode 100644
index 000000000000..9c7c816ce218
--- /dev/null
+++ b/test/std/numerics/numarray/template.indirect.array/indirect.array.assign/indirect_array.pass.cpp
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class indirect_array
+
+// const indirect_array& operator=(const indirect_array& ia) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a1[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
+ 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+ 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+ 36, 37, 38, 39, 40};
+ const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+ int a2[] = { -0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11,
+ -12, -13, -14, -15, -16, -17, -18, -19, -20, -21, -22, -23,
+ -24, -25, -26, -27, -28, -29, -30, -31, -32, -33, -34, -35,
+ -36, -37};
+ const std::size_t N2 = sizeof(a2)/sizeof(a2[0]);
+ std::size_t s[] = { 3, 4, 5, 7, 8, 9, 11, 12, 13, 15, 16, 17,
+ 22, 23, 24, 26, 27, 28, 30, 31, 32, 34, 35, 36};
+ const std::size_t S = sizeof(s)/sizeof(s[0]);
+ std::valarray<int> v1(a1, N1);
+ const std::valarray<int> v2(a2, N2);
+ std::valarray<std::size_t> ia(s, S);
+ v1[ia] = v2[ia];
+ assert(v1.size() == 41);
+ assert(v1[ 0] == 0);
+ assert(v1[ 1] == 1);
+ assert(v1[ 2] == 2);
+ assert(v1[ 3] == -3);
+ assert(v1[ 4] == -4);
+ assert(v1[ 5] == -5);
+ assert(v1[ 6] == 6);
+ assert(v1[ 7] == -7);
+ assert(v1[ 8] == -8);
+ assert(v1[ 9] == -9);
+ assert(v1[10] == 10);
+ assert(v1[11] == -11);
+ assert(v1[12] == -12);
+ assert(v1[13] == -13);
+ assert(v1[14] == 14);
+ assert(v1[15] == -15);
+ assert(v1[16] == -16);
+ assert(v1[17] == -17);
+ assert(v1[18] == 18);
+ assert(v1[19] == 19);
+ assert(v1[20] == 20);
+ assert(v1[21] == 21);
+ assert(v1[22] == -22);
+ assert(v1[23] == -23);
+ assert(v1[24] == -24);
+ assert(v1[25] == 25);
+ assert(v1[26] == -26);
+ assert(v1[27] == -27);
+ assert(v1[28] == -28);
+ assert(v1[29] == 29);
+ assert(v1[30] == -30);
+ assert(v1[31] == -31);
+ assert(v1[32] == -32);
+ assert(v1[33] == 33);
+ assert(v1[34] == -34);
+ assert(v1[35] == -35);
+ assert(v1[36] == -36);
+ assert(v1[37] == 37);
+ assert(v1[38] == 38);
+ assert(v1[39] == 39);
+ assert(v1[40] == 40);
+}
diff --git a/test/std/numerics/numarray/template.indirect.array/indirect.array.assign/valarray.pass.cpp b/test/std/numerics/numarray/template.indirect.array/indirect.array.assign/valarray.pass.cpp
new file mode 100644
index 000000000000..ad934aabcccb
--- /dev/null
+++ b/test/std/numerics/numarray/template.indirect.array/indirect.array.assign/valarray.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class indirect_array
+
+// void operator=(const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a1[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
+ 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+ 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+ 36, 37, 38, 39, 40};
+ const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+ int a2[] = { -0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11,
+ -12, -13, -14, -15, -16, -17, -18, -19, -20, -21, -22, -23};
+ const std::size_t N2 = sizeof(a2)/sizeof(a2[0]);
+ std::size_t s[N2] = { 3, 4, 5, 7, 8, 9, 11, 12, 13, 15, 16, 17,
+ 22, 23, 24, 26, 27, 28, 30, 31, 32, 34, 35, 36};
+ std::valarray<int> v1(a1, N1);
+ std::valarray<int> v2(a2, N2);
+ std::valarray<std::size_t> ia(s, N2);
+ v1[ia] = v2;
+ assert(v1.size() == 41);
+ assert(v1[ 0] == 0);
+ assert(v1[ 1] == 1);
+ assert(v1[ 2] == 2);
+ assert(v1[ 3] == 0);
+ assert(v1[ 4] == -1);
+ assert(v1[ 5] == -2);
+ assert(v1[ 6] == 6);
+ assert(v1[ 7] == -3);
+ assert(v1[ 8] == -4);
+ assert(v1[ 9] == -5);
+ assert(v1[10] == 10);
+ assert(v1[11] == -6);
+ assert(v1[12] == -7);
+ assert(v1[13] == -8);
+ assert(v1[14] == 14);
+ assert(v1[15] == -9);
+ assert(v1[16] == -10);
+ assert(v1[17] == -11);
+ assert(v1[18] == 18);
+ assert(v1[19] == 19);
+ assert(v1[20] == 20);
+ assert(v1[21] == 21);
+ assert(v1[22] == -12);
+ assert(v1[23] == -13);
+ assert(v1[24] == -14);
+ assert(v1[25] == 25);
+ assert(v1[26] == -15);
+ assert(v1[27] == -16);
+ assert(v1[28] == -17);
+ assert(v1[29] == 29);
+ assert(v1[30] == -18);
+ assert(v1[31] == -19);
+ assert(v1[32] == -20);
+ assert(v1[33] == 33);
+ assert(v1[34] == -21);
+ assert(v1[35] == -22);
+ assert(v1[36] == -23);
+ assert(v1[37] == 37);
+ assert(v1[38] == 38);
+ assert(v1[39] == 39);
+ assert(v1[40] == 40);
+}
diff --git a/test/std/numerics/numarray/template.indirect.array/indirect.array.comp.assign/addition.pass.cpp b/test/std/numerics/numarray/template.indirect.array/indirect.array.comp.assign/addition.pass.cpp
new file mode 100644
index 000000000000..fa966d1b58bb
--- /dev/null
+++ b/test/std/numerics/numarray/template.indirect.array/indirect.array.comp.assign/addition.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class indirect_array
+
+// void operator+=(const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a1[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
+ 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+ 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+ 36, 37, 38, 39, 40};
+ const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+ int a2[] = { -0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11,
+ -12, -13, -14, -15, -16, -17, -18, -19, -20, -21, -22, -23};
+ const std::size_t N2 = sizeof(a2)/sizeof(a2[0]);
+ std::size_t s[N2] = { 3, 4, 5, 7, 8, 9, 11, 12, 13, 15, 16, 17,
+ 22, 23, 24, 26, 27, 28, 30, 31, 32, 34, 35, 36};
+ std::valarray<int> v1(a1, N1);
+ std::valarray<int> v2(a2, N2);
+ std::valarray<std::size_t> ia(s, N2);
+ v1[ia] += v2;
+ assert(v1.size() == 41);
+ assert(v1[ 0] == 0);
+ assert(v1[ 1] == 1);
+ assert(v1[ 2] == 2);
+ assert(v1[ 3] == 3);
+ assert(v1[ 4] == 3);
+ assert(v1[ 5] == 3);
+ assert(v1[ 6] == 6);
+ assert(v1[ 7] == 4);
+ assert(v1[ 8] == 4);
+ assert(v1[ 9] == 4);
+ assert(v1[10] == 10);
+ assert(v1[11] == 5);
+ assert(v1[12] == 5);
+ assert(v1[13] == 5);
+ assert(v1[14] == 14);
+ assert(v1[15] == 6);
+ assert(v1[16] == 6);
+ assert(v1[17] == 6);
+ assert(v1[18] == 18);
+ assert(v1[19] == 19);
+ assert(v1[20] == 20);
+ assert(v1[21] == 21);
+ assert(v1[22] == 10);
+ assert(v1[23] == 10);
+ assert(v1[24] == 10);
+ assert(v1[25] == 25);
+ assert(v1[26] == 11);
+ assert(v1[27] == 11);
+ assert(v1[28] == 11);
+ assert(v1[29] == 29);
+ assert(v1[30] == 12);
+ assert(v1[31] == 12);
+ assert(v1[32] == 12);
+ assert(v1[33] == 33);
+ assert(v1[34] == 13);
+ assert(v1[35] == 13);
+ assert(v1[36] == 13);
+ assert(v1[37] == 37);
+ assert(v1[38] == 38);
+ assert(v1[39] == 39);
+ assert(v1[40] == 40);
+}
diff --git a/test/std/numerics/numarray/template.indirect.array/indirect.array.comp.assign/and.pass.cpp b/test/std/numerics/numarray/template.indirect.array/indirect.array.comp.assign/and.pass.cpp
new file mode 100644
index 000000000000..60f055276745
--- /dev/null
+++ b/test/std/numerics/numarray/template.indirect.array/indirect.array.comp.assign/and.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class indirect_array
+
+// void operator&=(const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a1[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
+ 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+ 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+ 36, 37, 38, 39, 40};
+ const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+ int a2[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
+ 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24};
+ const std::size_t N2 = sizeof(a2)/sizeof(a2[0]);
+ std::size_t s[N2] = { 3, 4, 5, 7, 8, 9, 11, 12, 13, 15, 16, 17,
+ 22, 23, 24, 26, 27, 28, 30, 31, 32, 34, 35, 36};
+ std::valarray<int> v1(a1, N1);
+ std::valarray<int> v2(a2, N2);
+ std::valarray<std::size_t> ia(s, N2);
+ v1[ia] &= v2;
+ assert(v1.size() == 41);
+ assert(v1[ 0] == 0);
+ assert(v1[ 1] == 1);
+ assert(v1[ 2] == 2);
+ assert(v1[ 3] == 1);
+ assert(v1[ 4] == 0);
+ assert(v1[ 5] == 1);
+ assert(v1[ 6] == 6);
+ assert(v1[ 7] == 4);
+ assert(v1[ 8] == 0);
+ assert(v1[ 9] == 0);
+ assert(v1[10] == 10);
+ assert(v1[11] == 3);
+ assert(v1[12] == 8);
+ assert(v1[13] == 9);
+ assert(v1[14] == 14);
+ assert(v1[15] == 10);
+ assert(v1[16] == 0);
+ assert(v1[17] == 0);
+ assert(v1[18] == 18);
+ assert(v1[19] == 19);
+ assert(v1[20] == 20);
+ assert(v1[21] == 21);
+ assert(v1[22] == 4);
+ assert(v1[23] == 6);
+ assert(v1[24] == 8);
+ assert(v1[25] == 25);
+ assert(v1[26] == 16);
+ assert(v1[27] == 17);
+ assert(v1[28] == 16);
+ assert(v1[29] == 29);
+ assert(v1[30] == 18);
+ assert(v1[31] == 20);
+ assert(v1[32] == 0);
+ assert(v1[33] == 33);
+ assert(v1[34] == 2);
+ assert(v1[35] == 3);
+ assert(v1[36] == 0);
+ assert(v1[37] == 37);
+ assert(v1[38] == 38);
+ assert(v1[39] == 39);
+ assert(v1[40] == 40);
+}
diff --git a/test/std/numerics/numarray/template.indirect.array/indirect.array.comp.assign/divide.pass.cpp b/test/std/numerics/numarray/template.indirect.array/indirect.array.comp.assign/divide.pass.cpp
new file mode 100644
index 000000000000..11b5d83fe142
--- /dev/null
+++ b/test/std/numerics/numarray/template.indirect.array/indirect.array.comp.assign/divide.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class indirect_array
+
+// void operator/=(const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a1[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
+ 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+ 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+ 36, 37, 38, 39, 40};
+ const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+ int a2[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
+ 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24};
+ const std::size_t N2 = sizeof(a2)/sizeof(a2[0]);
+ std::size_t s[N2] = { 3, 4, 5, 7, 8, 9, 11, 12, 13, 15, 16, 17,
+ 22, 23, 24, 26, 27, 28, 30, 31, 32, 34, 35, 36};
+ std::valarray<int> v1(a1, N1);
+ std::valarray<int> v2(a2, N2);
+ std::valarray<std::size_t> ia(s, N2);
+ v1[ia] /= v2;
+ assert(v1.size() == 41);
+ assert(v1[ 0] == 0);
+ assert(v1[ 1] == 1);
+ assert(v1[ 2] == 2);
+ assert(v1[ 3] == 3);
+ assert(v1[ 4] == 2);
+ assert(v1[ 5] == 1);
+ assert(v1[ 6] == 6);
+ assert(v1[ 7] == 1);
+ assert(v1[ 8] == 1);
+ assert(v1[ 9] == 1);
+ assert(v1[10] == 10);
+ assert(v1[11] == 1);
+ assert(v1[12] == 1);
+ assert(v1[13] == 1);
+ assert(v1[14] == 14);
+ assert(v1[15] == 1);
+ assert(v1[16] == 1);
+ assert(v1[17] == 1);
+ assert(v1[18] == 18);
+ assert(v1[19] == 19);
+ assert(v1[20] == 20);
+ assert(v1[21] == 21);
+ assert(v1[22] == 1);
+ assert(v1[23] == 1);
+ assert(v1[24] == 1);
+ assert(v1[25] == 25);
+ assert(v1[26] == 1);
+ assert(v1[27] == 1);
+ assert(v1[28] == 1);
+ assert(v1[29] == 29);
+ assert(v1[30] == 1);
+ assert(v1[31] == 1);
+ assert(v1[32] == 1);
+ assert(v1[33] == 33);
+ assert(v1[34] == 1);
+ assert(v1[35] == 1);
+ assert(v1[36] == 1);
+ assert(v1[37] == 37);
+ assert(v1[38] == 38);
+ assert(v1[39] == 39);
+ assert(v1[40] == 40);
+}
diff --git a/test/std/numerics/numarray/template.indirect.array/indirect.array.comp.assign/modulo.pass.cpp b/test/std/numerics/numarray/template.indirect.array/indirect.array.comp.assign/modulo.pass.cpp
new file mode 100644
index 000000000000..4c63684ecb7f
--- /dev/null
+++ b/test/std/numerics/numarray/template.indirect.array/indirect.array.comp.assign/modulo.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class indirect_array
+
+// void operator%=(const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a1[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
+ 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+ 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+ 36, 37, 38, 39, 40};
+ const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+ int a2[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
+ 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24};
+ const std::size_t N2 = sizeof(a2)/sizeof(a2[0]);
+ std::size_t s[N2] = { 3, 4, 5, 7, 8, 9, 11, 12, 13, 15, 16, 17,
+ 22, 23, 24, 26, 27, 28, 30, 31, 32, 34, 35, 36};
+ std::valarray<int> v1(a1, N1);
+ std::valarray<int> v2(a2, N2);
+ std::valarray<std::size_t> ia(s, N2);
+ v1[ia] %= v2;
+ assert(v1.size() == 41);
+ assert(v1[ 0] == 0);
+ assert(v1[ 1] == 1);
+ assert(v1[ 2] == 2);
+ assert(v1[ 3] == 0);
+ assert(v1[ 4] == 0);
+ assert(v1[ 5] == 2);
+ assert(v1[ 6] == 6);
+ assert(v1[ 7] == 3);
+ assert(v1[ 8] == 3);
+ assert(v1[ 9] == 3);
+ assert(v1[10] == 10);
+ assert(v1[11] == 4);
+ assert(v1[12] == 4);
+ assert(v1[13] == 4);
+ assert(v1[14] == 14);
+ assert(v1[15] == 5);
+ assert(v1[16] == 5);
+ assert(v1[17] == 5);
+ assert(v1[18] == 18);
+ assert(v1[19] == 19);
+ assert(v1[20] == 20);
+ assert(v1[21] == 21);
+ assert(v1[22] == 9);
+ assert(v1[23] == 9);
+ assert(v1[24] == 9);
+ assert(v1[25] == 25);
+ assert(v1[26] == 10);
+ assert(v1[27] == 10);
+ assert(v1[28] == 10);
+ assert(v1[29] == 29);
+ assert(v1[30] == 11);
+ assert(v1[31] == 11);
+ assert(v1[32] == 11);
+ assert(v1[33] == 33);
+ assert(v1[34] == 12);
+ assert(v1[35] == 12);
+ assert(v1[36] == 12);
+ assert(v1[37] == 37);
+ assert(v1[38] == 38);
+ assert(v1[39] == 39);
+ assert(v1[40] == 40);
+}
diff --git a/test/std/numerics/numarray/template.indirect.array/indirect.array.comp.assign/multiply.pass.cpp b/test/std/numerics/numarray/template.indirect.array/indirect.array.comp.assign/multiply.pass.cpp
new file mode 100644
index 000000000000..e477353107a7
--- /dev/null
+++ b/test/std/numerics/numarray/template.indirect.array/indirect.array.comp.assign/multiply.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class indirect_array
+
+// void operator*=(const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a1[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
+ 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+ 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+ 36, 37, 38, 39, 40};
+ const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+ int a2[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
+ 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24};
+ const std::size_t N2 = sizeof(a2)/sizeof(a2[0]);
+ std::size_t s[N2] = { 3, 4, 5, 7, 8, 9, 11, 12, 13, 15, 16, 17,
+ 22, 23, 24, 26, 27, 28, 30, 31, 32, 34, 35, 36};
+ std::valarray<int> v1(a1, N1);
+ std::valarray<int> v2(a2, N2);
+ std::valarray<std::size_t> ia(s, N2);
+ v1[ia] *= v2;
+ assert(v1.size() == 41);
+ assert(v1[ 0] == 0);
+ assert(v1[ 1] == 1);
+ assert(v1[ 2] == 2);
+ assert(v1[ 3] == 3);
+ assert(v1[ 4] == 8);
+ assert(v1[ 5] == 15);
+ assert(v1[ 6] == 6);
+ assert(v1[ 7] == 28);
+ assert(v1[ 8] == 40);
+ assert(v1[ 9] == 54);
+ assert(v1[10] == 10);
+ assert(v1[11] == 77);
+ assert(v1[12] == 96);
+ assert(v1[13] == 117);
+ assert(v1[14] == 14);
+ assert(v1[15] == 150);
+ assert(v1[16] == 176);
+ assert(v1[17] == 204);
+ assert(v1[18] == 18);
+ assert(v1[19] == 19);
+ assert(v1[20] == 20);
+ assert(v1[21] == 21);
+ assert(v1[22] == 286);
+ assert(v1[23] == 322);
+ assert(v1[24] == 360);
+ assert(v1[25] == 25);
+ assert(v1[26] == 416);
+ assert(v1[27] == 459);
+ assert(v1[28] == 504);
+ assert(v1[29] == 29);
+ assert(v1[30] == 570);
+ assert(v1[31] == 620);
+ assert(v1[32] == 672);
+ assert(v1[33] == 33);
+ assert(v1[34] == 748);
+ assert(v1[35] == 805);
+ assert(v1[36] == 864);
+ assert(v1[37] == 37);
+ assert(v1[38] == 38);
+ assert(v1[39] == 39);
+ assert(v1[40] == 40);
+}
diff --git a/test/std/numerics/numarray/template.indirect.array/indirect.array.comp.assign/or.pass.cpp b/test/std/numerics/numarray/template.indirect.array/indirect.array.comp.assign/or.pass.cpp
new file mode 100644
index 000000000000..b74ce8621eb3
--- /dev/null
+++ b/test/std/numerics/numarray/template.indirect.array/indirect.array.comp.assign/or.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class indirect_array
+
+// void operator|=(const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a1[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
+ 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+ 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+ 36, 37, 38, 39, 40};
+ const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+ int a2[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
+ 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24};
+ const std::size_t N2 = sizeof(a2)/sizeof(a2[0]);
+ std::size_t s[N2] = { 3, 4, 5, 7, 8, 9, 11, 12, 13, 15, 16, 17,
+ 22, 23, 24, 26, 27, 28, 30, 31, 32, 34, 35, 36};
+ std::valarray<int> v1(a1, N1);
+ std::valarray<int> v2(a2, N2);
+ std::valarray<std::size_t> ia(s, N2);
+ v1[ia] |= v2;
+ assert(v1.size() == 41);
+ assert(v1[ 0] == 0);
+ assert(v1[ 1] == 1);
+ assert(v1[ 2] == 2);
+ assert(v1[ 3] == 3);
+ assert(v1[ 4] == 6);
+ assert(v1[ 5] == 7);
+ assert(v1[ 6] == 6);
+ assert(v1[ 7] == 7);
+ assert(v1[ 8] == 13);
+ assert(v1[ 9] == 15);
+ assert(v1[10] == 10);
+ assert(v1[11] == 15);
+ assert(v1[12] == 12);
+ assert(v1[13] == 13);
+ assert(v1[14] == 14);
+ assert(v1[15] == 15);
+ assert(v1[16] == 27);
+ assert(v1[17] == 29);
+ assert(v1[18] == 18);
+ assert(v1[19] == 19);
+ assert(v1[20] == 20);
+ assert(v1[21] == 21);
+ assert(v1[22] == 31);
+ assert(v1[23] == 31);
+ assert(v1[24] == 31);
+ assert(v1[25] == 25);
+ assert(v1[26] == 26);
+ assert(v1[27] == 27);
+ assert(v1[28] == 30);
+ assert(v1[29] == 29);
+ assert(v1[30] == 31);
+ assert(v1[31] == 31);
+ assert(v1[32] == 53);
+ assert(v1[33] == 33);
+ assert(v1[34] == 54);
+ assert(v1[35] == 55);
+ assert(v1[36] == 60);
+ assert(v1[37] == 37);
+ assert(v1[38] == 38);
+ assert(v1[39] == 39);
+ assert(v1[40] == 40);
+}
diff --git a/test/std/numerics/numarray/template.indirect.array/indirect.array.comp.assign/shift_left.pass.cpp b/test/std/numerics/numarray/template.indirect.array/indirect.array.comp.assign/shift_left.pass.cpp
new file mode 100644
index 000000000000..e23f14299c9d
--- /dev/null
+++ b/test/std/numerics/numarray/template.indirect.array/indirect.array.comp.assign/shift_left.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class indirect_array
+
+// void operator<<=(const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a1[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
+ 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+ 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+ 36, 37, 38, 39, 40};
+ const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+ int a2[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
+ 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24};
+ const std::size_t N2 = sizeof(a2)/sizeof(a2[0]);
+ std::size_t s[N2] = { 3, 4, 5, 7, 8, 9, 11, 12, 13, 15, 16, 17,
+ 22, 23, 24, 26, 27, 28, 30, 31, 32, 34, 35, 36};
+ std::valarray<int> v1(a1, N1);
+ std::valarray<int> v2(a2, N2);
+ std::valarray<std::size_t> ia(s, N2);
+ v1[ia] <<= v2;
+ assert(v1.size() == 41);
+ assert(v1[ 0] == 0);
+ assert(v1[ 1] == 1);
+ assert(v1[ 2] == 2);
+ assert(v1[ 3] == 6);
+ assert(v1[ 4] == 16);
+ assert(v1[ 5] == 40);
+ assert(v1[ 6] == 6);
+ assert(v1[ 7] == 112);
+ assert(v1[ 8] == 256);
+ assert(v1[ 9] == 576);
+ assert(v1[10] == 10);
+ assert(v1[11] == 1408);
+ assert(v1[12] == 3072);
+ assert(v1[13] == 6656);
+ assert(v1[14] == 14);
+ assert(v1[15] == 15360);
+ assert(v1[16] == 32768);
+ assert(v1[17] == 69632);
+ assert(v1[18] == 18);
+ assert(v1[19] == 19);
+ assert(v1[20] == 20);
+ assert(v1[21] == 21);
+ assert(v1[22] == 180224);
+ assert(v1[23] == 376832);
+ assert(v1[24] == 786432);
+ assert(v1[25] == 25);
+ assert(v1[26] == 1703936);
+ assert(v1[27] == 3538944);
+ assert(v1[28] == 7340032);
+ assert(v1[29] == 29);
+ assert(v1[30] == 15728640);
+ assert(v1[31] == 32505856);
+ assert(v1[32] == 67108864);
+ assert(v1[33] == 33);
+ assert(v1[34] == 142606336);
+ assert(v1[35] == 293601280);
+ assert(v1[36] == 603979776);
+ assert(v1[37] == 37);
+ assert(v1[38] == 38);
+ assert(v1[39] == 39);
+ assert(v1[40] == 40);
+}
diff --git a/test/std/numerics/numarray/template.indirect.array/indirect.array.comp.assign/shift_right.pass.cpp b/test/std/numerics/numarray/template.indirect.array/indirect.array.comp.assign/shift_right.pass.cpp
new file mode 100644
index 000000000000..33db33f0c5fa
--- /dev/null
+++ b/test/std/numerics/numarray/template.indirect.array/indirect.array.comp.assign/shift_right.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class indirect_array
+
+// void operator>>=(const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a1[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
+ 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+ 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+ 36, 37, 38, 39, 40};
+ const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+ int a2[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
+ 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24};
+ const std::size_t N2 = sizeof(a2)/sizeof(a2[0]);
+ std::size_t s[N2] = { 3, 4, 5, 7, 8, 9, 11, 12, 13, 15, 16, 17,
+ 22, 23, 24, 26, 27, 28, 30, 31, 32, 34, 35, 36};
+ std::valarray<int> v1(a1, N1);
+ std::valarray<int> v2(a2, N2);
+ std::valarray<std::size_t> ia(s, N2);
+ v1[ia] >>= v2;
+ assert(v1.size() == 41);
+ assert(v1[ 0] == 0);
+ assert(v1[ 1] == 1);
+ assert(v1[ 2] == 2);
+ assert(v1[ 3] == 1);
+ assert(v1[ 4] == 1);
+ assert(v1[ 5] == 0);
+ assert(v1[ 6] == 6);
+ assert(v1[ 7] == 0);
+ assert(v1[ 8] == 0);
+ assert(v1[ 9] == 0);
+ assert(v1[10] == 10);
+ assert(v1[11] == 0);
+ assert(v1[12] == 0);
+ assert(v1[13] == 0);
+ assert(v1[14] == 14);
+ assert(v1[15] == 0);
+ assert(v1[16] == 0);
+ assert(v1[17] == 0);
+ assert(v1[18] == 18);
+ assert(v1[19] == 19);
+ assert(v1[20] == 20);
+ assert(v1[21] == 21);
+ assert(v1[22] == 0);
+ assert(v1[23] == 0);
+ assert(v1[24] == 0);
+ assert(v1[25] == 25);
+ assert(v1[26] == 0);
+ assert(v1[27] == 0);
+ assert(v1[28] == 0);
+ assert(v1[29] == 29);
+ assert(v1[30] == 0);
+ assert(v1[31] == 0);
+ assert(v1[32] == 0);
+ assert(v1[33] == 33);
+ assert(v1[34] == 0);
+ assert(v1[35] == 0);
+ assert(v1[36] == 0);
+ assert(v1[37] == 37);
+ assert(v1[38] == 38);
+ assert(v1[39] == 39);
+ assert(v1[40] == 40);
+}
diff --git a/test/std/numerics/numarray/template.indirect.array/indirect.array.comp.assign/subtraction.pass.cpp b/test/std/numerics/numarray/template.indirect.array/indirect.array.comp.assign/subtraction.pass.cpp
new file mode 100644
index 000000000000..dd2d35f99204
--- /dev/null
+++ b/test/std/numerics/numarray/template.indirect.array/indirect.array.comp.assign/subtraction.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class indirect_array
+
+// void operator-=(const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a1[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
+ 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+ 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+ 36, 37, 38, 39, 40};
+ const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+ int a2[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
+ 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24};
+ const std::size_t N2 = sizeof(a2)/sizeof(a2[0]);
+ std::size_t s[N2] = { 3, 4, 5, 7, 8, 9, 11, 12, 13, 15, 16, 17,
+ 22, 23, 24, 26, 27, 28, 30, 31, 32, 34, 35, 36};
+ std::valarray<int> v1(a1, N1);
+ std::valarray<int> v2(a2, N2);
+ std::valarray<std::size_t> ia(s, N2);
+ v1[ia] -= v2;
+ assert(v1.size() == 41);
+ assert(v1[ 0] == 0);
+ assert(v1[ 1] == 1);
+ assert(v1[ 2] == 2);
+ assert(v1[ 3] == 2);
+ assert(v1[ 4] == 2);
+ assert(v1[ 5] == 2);
+ assert(v1[ 6] == 6);
+ assert(v1[ 7] == 3);
+ assert(v1[ 8] == 3);
+ assert(v1[ 9] == 3);
+ assert(v1[10] == 10);
+ assert(v1[11] == 4);
+ assert(v1[12] == 4);
+ assert(v1[13] == 4);
+ assert(v1[14] == 14);
+ assert(v1[15] == 5);
+ assert(v1[16] == 5);
+ assert(v1[17] == 5);
+ assert(v1[18] == 18);
+ assert(v1[19] == 19);
+ assert(v1[20] == 20);
+ assert(v1[21] == 21);
+ assert(v1[22] == 9);
+ assert(v1[23] == 9);
+ assert(v1[24] == 9);
+ assert(v1[25] == 25);
+ assert(v1[26] == 10);
+ assert(v1[27] == 10);
+ assert(v1[28] == 10);
+ assert(v1[29] == 29);
+ assert(v1[30] == 11);
+ assert(v1[31] == 11);
+ assert(v1[32] == 11);
+ assert(v1[33] == 33);
+ assert(v1[34] == 12);
+ assert(v1[35] == 12);
+ assert(v1[36] == 12);
+ assert(v1[37] == 37);
+ assert(v1[38] == 38);
+ assert(v1[39] == 39);
+ assert(v1[40] == 40);
+}
diff --git a/test/std/numerics/numarray/template.indirect.array/indirect.array.comp.assign/xor.pass.cpp b/test/std/numerics/numarray/template.indirect.array/indirect.array.comp.assign/xor.pass.cpp
new file mode 100644
index 000000000000..f2c3427b9291
--- /dev/null
+++ b/test/std/numerics/numarray/template.indirect.array/indirect.array.comp.assign/xor.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class indirect_array
+
+// void operator^=(const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a1[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
+ 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+ 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+ 36, 37, 38, 39, 40};
+ const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+ int a2[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
+ 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24};
+ const std::size_t N2 = sizeof(a2)/sizeof(a2[0]);
+ std::size_t s[N2] = { 3, 4, 5, 7, 8, 9, 11, 12, 13, 15, 16, 17,
+ 22, 23, 24, 26, 27, 28, 30, 31, 32, 34, 35, 36};
+ std::valarray<int> v1(a1, N1);
+ std::valarray<int> v2(a2, N2);
+ std::valarray<std::size_t> ia(s, N2);
+ v1[ia] ^= v2;
+ assert(v1.size() == 41);
+ assert(v1[ 0] == 0);
+ assert(v1[ 1] == 1);
+ assert(v1[ 2] == 2);
+ assert(v1[ 3] == 2);
+ assert(v1[ 4] == 6);
+ assert(v1[ 5] == 6);
+ assert(v1[ 6] == 6);
+ assert(v1[ 7] == 3);
+ assert(v1[ 8] == 13);
+ assert(v1[ 9] == 15);
+ assert(v1[10] == 10);
+ assert(v1[11] == 12);
+ assert(v1[12] == 4);
+ assert(v1[13] == 4);
+ assert(v1[14] == 14);
+ assert(v1[15] == 5);
+ assert(v1[16] == 27);
+ assert(v1[17] == 29);
+ assert(v1[18] == 18);
+ assert(v1[19] == 19);
+ assert(v1[20] == 20);
+ assert(v1[21] == 21);
+ assert(v1[22] == 27);
+ assert(v1[23] == 25);
+ assert(v1[24] == 23);
+ assert(v1[25] == 25);
+ assert(v1[26] == 10);
+ assert(v1[27] == 10);
+ assert(v1[28] == 14);
+ assert(v1[29] == 29);
+ assert(v1[30] == 13);
+ assert(v1[31] == 11);
+ assert(v1[32] == 53);
+ assert(v1[33] == 33);
+ assert(v1[34] == 52);
+ assert(v1[35] == 52);
+ assert(v1[36] == 60);
+ assert(v1[37] == 37);
+ assert(v1[38] == 38);
+ assert(v1[39] == 39);
+ assert(v1[40] == 40);
+}
diff --git a/test/std/numerics/numarray/template.indirect.array/indirect.array.fill/assign_value.pass.cpp b/test/std/numerics/numarray/template.indirect.array/indirect.array.fill/assign_value.pass.cpp
new file mode 100644
index 000000000000..de2bb43441c1
--- /dev/null
+++ b/test/std/numerics/numarray/template.indirect.array/indirect.array.fill/assign_value.pass.cpp
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class indirect_array
+
+// void operator=(const value_type& x) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a1[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
+ 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+ 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+ 36, 37, 38, 39, 40};
+ const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+ std::size_t s[] = { 3, 4, 5, 7, 8, 9, 11, 12, 13, 15, 16, 17,
+ 22, 23, 24, 26, 27, 28, 30, 31, 32, 34, 35, 36};
+ const std::size_t S = sizeof(s)/sizeof(s[0]);
+ std::valarray<int> v1(a1, N1);
+ std::valarray<std::size_t> ia(s, S);
+ v1[ia] = 51;
+ assert(v1.size() == 41);
+ assert(v1[ 0] == 0);
+ assert(v1[ 1] == 1);
+ assert(v1[ 2] == 2);
+ assert(v1[ 3] == 51);
+ assert(v1[ 4] == 51);
+ assert(v1[ 5] == 51);
+ assert(v1[ 6] == 6);
+ assert(v1[ 7] == 51);
+ assert(v1[ 8] == 51);
+ assert(v1[ 9] == 51);
+ assert(v1[10] == 10);
+ assert(v1[11] == 51);
+ assert(v1[12] == 51);
+ assert(v1[13] == 51);
+ assert(v1[14] == 14);
+ assert(v1[15] == 51);
+ assert(v1[16] == 51);
+ assert(v1[17] == 51);
+ assert(v1[18] == 18);
+ assert(v1[19] == 19);
+ assert(v1[20] == 20);
+ assert(v1[21] == 21);
+ assert(v1[22] == 51);
+ assert(v1[23] == 51);
+ assert(v1[24] == 51);
+ assert(v1[25] == 25);
+ assert(v1[26] == 51);
+ assert(v1[27] == 51);
+ assert(v1[28] == 51);
+ assert(v1[29] == 29);
+ assert(v1[30] == 51);
+ assert(v1[31] == 51);
+ assert(v1[32] == 51);
+ assert(v1[33] == 33);
+ assert(v1[34] == 51);
+ assert(v1[35] == 51);
+ assert(v1[36] == 51);
+ assert(v1[37] == 37);
+ assert(v1[38] == 38);
+ assert(v1[39] == 39);
+ assert(v1[40] == 40);
+}
diff --git a/test/std/numerics/numarray/template.indirect.array/types.pass.cpp b/test/std/numerics/numarray/template.indirect.array/types.pass.cpp
new file mode 100644
index 000000000000..fe118ea329a3
--- /dev/null
+++ b/test/std/numerics/numarray/template.indirect.array/types.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T>
+// class indirect_array
+// {
+// public:
+// typedef T value_type;
+
+#include <valarray>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_same<std::indirect_array<int>::value_type, int>::value), "");
+}
diff --git a/test/std/numerics/numarray/template.mask.array/default.fail.cpp b/test/std/numerics/numarray/template.mask.array/default.fail.cpp
new file mode 100644
index 000000000000..97476c65c195
--- /dev/null
+++ b/test/std/numerics/numarray/template.mask.array/default.fail.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class mask_array
+
+// mask_array() = delete;
+
+#include <valarray>
+#include <type_traits>
+
+int main()
+{
+ std::mask_array<int> s;
+}
diff --git a/test/std/numerics/numarray/template.mask.array/mask.array.assign/mask_array.pass.cpp b/test/std/numerics/numarray/template.mask.array/mask.array.assign/mask_array.pass.cpp
new file mode 100644
index 000000000000..29cb787d009e
--- /dev/null
+++ b/test/std/numerics/numarray/template.mask.array/mask.array.assign/mask_array.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class mask_array
+
+// void mask_array& operator=(const mask_array& ma) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+ const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+ bool b1[N1] = {true, false, false, true, true, false,
+ false, true, false, false, false, true};
+ int a2[] = {-1, -2, -3, -4, -5, -6, -7, -8};
+ const std::size_t N2 = sizeof(a2)/sizeof(a2[0]);
+ bool b2[N2] = {true, false, true, true,
+ false, false, true, true};
+ std::valarray<int> v1(a1, N1);
+ const std::valarray<int> v2(a2, N2);
+ std::valarray<bool> vb1(b1, N1);
+ std::valarray<bool> vb2(b2, N2);
+ v1[vb1] = v2[vb2];
+ assert(v1.size() == 16);
+ assert(v1[ 0] == -1);
+ assert(v1[ 1] == 1);
+ assert(v1[ 2] == 2);
+ assert(v1[ 3] == -3);
+ assert(v1[ 4] == -4);
+ assert(v1[ 5] == 5);
+ assert(v1[ 6] == 6);
+ assert(v1[ 7] == -7);
+ assert(v1[ 8] == 8);
+ assert(v1[ 9] == 9);
+ assert(v1[10] == 10);
+ assert(v1[11] == -8);
+ assert(v1[12] == 12);
+ assert(v1[13] == 13);
+ assert(v1[14] == 14);
+ assert(v1[15] == 15);
+ }
+ // Test return value of assignment
+ {
+ int a1[] = {0, 1, 2};
+ int a2[] = {3, 4, 5};
+ bool b1[] = {true, false, true};
+ std::valarray<int> v1(a1, 3);
+ std::valarray<int> v2(a2, 3);
+ std::valarray<bool> const vb1(b1, 3);
+ std::mask_array<int> m1 = v1[vb1];
+ std::mask_array<int> const m2 = v2[vb1];
+ std::mask_array<int> const & r = (m1 = m2);
+ assert(&r == &m1);
+ }
+}
diff --git a/test/std/numerics/numarray/template.mask.array/mask.array.assign/valarray.pass.cpp b/test/std/numerics/numarray/template.mask.array/mask.array.assign/valarray.pass.cpp
new file mode 100644
index 000000000000..63949e2449b8
--- /dev/null
+++ b/test/std/numerics/numarray/template.mask.array/mask.array.assign/valarray.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class mask_array
+
+// void operator=(const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+ const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+ int a2[] = {1, 2, 3, 4, 5};
+ const std::size_t N2 = sizeof(a2)/sizeof(a2[0]);
+ bool b[N1] = {true, false, false, true, true, false,
+ false, true, false, false, false, true};
+ std::valarray<int> v1(a1, N1);
+ std::valarray<int> v2(a2, N2);
+ assert(N2 == std::count(b, b+N1, true));
+ std::valarray<bool> vb(b, N1);
+ v1[vb] = v2;
+ assert(v1.size() == 16);
+ assert(v1[ 0] == 1);
+ assert(v1[ 1] == 1);
+ assert(v1[ 2] == 2);
+ assert(v1[ 3] == 2);
+ assert(v1[ 4] == 3);
+ assert(v1[ 5] == 5);
+ assert(v1[ 6] == 6);
+ assert(v1[ 7] == 4);
+ assert(v1[ 8] == 8);
+ assert(v1[ 9] == 9);
+ assert(v1[10] == 10);
+ assert(v1[11] == 5);
+ assert(v1[12] == 12);
+ assert(v1[13] == 13);
+ assert(v1[14] == 14);
+ assert(v1[15] == 15);
+}
diff --git a/test/std/numerics/numarray/template.mask.array/mask.array.comp.assign/addition.pass.cpp b/test/std/numerics/numarray/template.mask.array/mask.array.comp.assign/addition.pass.cpp
new file mode 100644
index 000000000000..984762943c63
--- /dev/null
+++ b/test/std/numerics/numarray/template.mask.array/mask.array.comp.assign/addition.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class mask_array
+
+// void operator+=(const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+ const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+ int a2[] = {1, 2, 3, 4, 5};
+ const std::size_t N2 = sizeof(a2)/sizeof(a2[0]);
+ bool b[N1] = {true, false, false, true, true, false,
+ false, true, false, false, false, true};
+ std::valarray<int> v1(a1, N1);
+ std::valarray<int> v2(a2, N2);
+ assert(N2 == std::count(b, b+N1, true));
+ std::valarray<bool> vb(b, N1);
+ v1[vb] += v2;
+ assert(v1.size() == 16);
+ assert(v1[ 0] == 1);
+ assert(v1[ 1] == 1);
+ assert(v1[ 2] == 2);
+ assert(v1[ 3] == 5);
+ assert(v1[ 4] == 7);
+ assert(v1[ 5] == 5);
+ assert(v1[ 6] == 6);
+ assert(v1[ 7] == 11);
+ assert(v1[ 8] == 8);
+ assert(v1[ 9] == 9);
+ assert(v1[10] == 10);
+ assert(v1[11] == 16);
+ assert(v1[12] == 12);
+ assert(v1[13] == 13);
+ assert(v1[14] == 14);
+ assert(v1[15] == 15);
+}
diff --git a/test/std/numerics/numarray/template.mask.array/mask.array.comp.assign/and.pass.cpp b/test/std/numerics/numarray/template.mask.array/mask.array.comp.assign/and.pass.cpp
new file mode 100644
index 000000000000..7e110b13af21
--- /dev/null
+++ b/test/std/numerics/numarray/template.mask.array/mask.array.comp.assign/and.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class mask_array
+
+// void operator&=(const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+ const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+ int a2[] = {1, 2, 3, 4, 5};
+ const std::size_t N2 = sizeof(a2)/sizeof(a2[0]);
+ bool b[N1] = {true, false, false, true, true, false,
+ false, true, false, false, false, true};
+ std::valarray<int> v1(a1, N1);
+ std::valarray<int> v2(a2, N2);
+ assert(N2 == std::count(b, b+N1, true));
+ std::valarray<bool> vb(b, N1);
+ v1[vb] &= v2;
+ assert(v1.size() == 16);
+ assert(v1[ 0] == 0);
+ assert(v1[ 1] == 1);
+ assert(v1[ 2] == 2);
+ assert(v1[ 3] == 2);
+ assert(v1[ 4] == 0);
+ assert(v1[ 5] == 5);
+ assert(v1[ 6] == 6);
+ assert(v1[ 7] == 4);
+ assert(v1[ 8] == 8);
+ assert(v1[ 9] == 9);
+ assert(v1[10] == 10);
+ assert(v1[11] == 1);
+ assert(v1[12] == 12);
+ assert(v1[13] == 13);
+ assert(v1[14] == 14);
+ assert(v1[15] == 15);
+}
diff --git a/test/std/numerics/numarray/template.mask.array/mask.array.comp.assign/divide.pass.cpp b/test/std/numerics/numarray/template.mask.array/mask.array.comp.assign/divide.pass.cpp
new file mode 100644
index 000000000000..9fe243875ce5
--- /dev/null
+++ b/test/std/numerics/numarray/template.mask.array/mask.array.comp.assign/divide.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class mask_array
+
+// void operator/=(const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+ const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+ int a2[] = {1, 2, 3, 4, 5};
+ const std::size_t N2 = sizeof(a2)/sizeof(a2[0]);
+ bool b[N1] = {true, false, false, true, true, false,
+ false, true, false, false, false, true};
+ std::valarray<int> v1(a1, N1);
+ std::valarray<int> v2(a2, N2);
+ assert(N2 == std::count(b, b+N1, true));
+ std::valarray<bool> vb(b, N1);
+ v1[vb] /= v2;
+ assert(v1.size() == 16);
+ assert(v1[ 0] == 0);
+ assert(v1[ 1] == 1);
+ assert(v1[ 2] == 2);
+ assert(v1[ 3] == 1);
+ assert(v1[ 4] == 1);
+ assert(v1[ 5] == 5);
+ assert(v1[ 6] == 6);
+ assert(v1[ 7] == 1);
+ assert(v1[ 8] == 8);
+ assert(v1[ 9] == 9);
+ assert(v1[10] == 10);
+ assert(v1[11] == 2);
+ assert(v1[12] == 12);
+ assert(v1[13] == 13);
+ assert(v1[14] == 14);
+ assert(v1[15] == 15);
+}
diff --git a/test/std/numerics/numarray/template.mask.array/mask.array.comp.assign/modulo.pass.cpp b/test/std/numerics/numarray/template.mask.array/mask.array.comp.assign/modulo.pass.cpp
new file mode 100644
index 000000000000..bd0ee0836fb8
--- /dev/null
+++ b/test/std/numerics/numarray/template.mask.array/mask.array.comp.assign/modulo.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class mask_array
+
+// void operator%=(const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+ const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+ int a2[] = {1, 2, 3, 4, 5};
+ const std::size_t N2 = sizeof(a2)/sizeof(a2[0]);
+ bool b[N1] = {true, false, false, true, true, false,
+ false, true, false, false, false, true};
+ std::valarray<int> v1(a1, N1);
+ std::valarray<int> v2(a2, N2);
+ assert(N2 == std::count(b, b+N1, true));
+ std::valarray<bool> vb(b, N1);
+ v1[vb] %= v2;
+ assert(v1.size() == 16);
+ assert(v1[ 0] == 0);
+ assert(v1[ 1] == 1);
+ assert(v1[ 2] == 2);
+ assert(v1[ 3] == 1);
+ assert(v1[ 4] == 1);
+ assert(v1[ 5] == 5);
+ assert(v1[ 6] == 6);
+ assert(v1[ 7] == 3);
+ assert(v1[ 8] == 8);
+ assert(v1[ 9] == 9);
+ assert(v1[10] == 10);
+ assert(v1[11] == 1);
+ assert(v1[12] == 12);
+ assert(v1[13] == 13);
+ assert(v1[14] == 14);
+ assert(v1[15] == 15);
+}
diff --git a/test/std/numerics/numarray/template.mask.array/mask.array.comp.assign/multiply.pass.cpp b/test/std/numerics/numarray/template.mask.array/mask.array.comp.assign/multiply.pass.cpp
new file mode 100644
index 000000000000..13efefc375f2
--- /dev/null
+++ b/test/std/numerics/numarray/template.mask.array/mask.array.comp.assign/multiply.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class mask_array
+
+// void operator*=(const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+ const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+ int a2[] = {1, 2, 3, 4, 5};
+ const std::size_t N2 = sizeof(a2)/sizeof(a2[0]);
+ bool b[N1] = {true, false, false, true, true, false,
+ false, true, false, false, false, true};
+ std::valarray<int> v1(a1, N1);
+ std::valarray<int> v2(a2, N2);
+ assert(N2 == std::count(b, b+N1, true));
+ std::valarray<bool> vb(b, N1);
+ v1[vb] *= v2;
+ assert(v1.size() == 16);
+ assert(v1[ 0] == 0);
+ assert(v1[ 1] == 1);
+ assert(v1[ 2] == 2);
+ assert(v1[ 3] == 6);
+ assert(v1[ 4] == 12);
+ assert(v1[ 5] == 5);
+ assert(v1[ 6] == 6);
+ assert(v1[ 7] == 28);
+ assert(v1[ 8] == 8);
+ assert(v1[ 9] == 9);
+ assert(v1[10] == 10);
+ assert(v1[11] == 55);
+ assert(v1[12] == 12);
+ assert(v1[13] == 13);
+ assert(v1[14] == 14);
+ assert(v1[15] == 15);
+}
diff --git a/test/std/numerics/numarray/template.mask.array/mask.array.comp.assign/or.pass.cpp b/test/std/numerics/numarray/template.mask.array/mask.array.comp.assign/or.pass.cpp
new file mode 100644
index 000000000000..9b06879a8a17
--- /dev/null
+++ b/test/std/numerics/numarray/template.mask.array/mask.array.comp.assign/or.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class mask_array
+
+// void operator|=(const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+ const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+ int a2[] = {1, 2, 3, 4, 5};
+ const std::size_t N2 = sizeof(a2)/sizeof(a2[0]);
+ bool b[N1] = {true, false, false, true, true, false,
+ false, true, false, false, false, true};
+ std::valarray<int> v1(a1, N1);
+ std::valarray<int> v2(a2, N2);
+ assert(N2 == std::count(b, b+N1, true));
+ std::valarray<bool> vb(b, N1);
+ v1[vb] |= v2;
+ assert(v1.size() == 16);
+ assert(v1[ 0] == 1);
+ assert(v1[ 1] == 1);
+ assert(v1[ 2] == 2);
+ assert(v1[ 3] == 3);
+ assert(v1[ 4] == 7);
+ assert(v1[ 5] == 5);
+ assert(v1[ 6] == 6);
+ assert(v1[ 7] == 7);
+ assert(v1[ 8] == 8);
+ assert(v1[ 9] == 9);
+ assert(v1[10] == 10);
+ assert(v1[11] == 15);
+ assert(v1[12] == 12);
+ assert(v1[13] == 13);
+ assert(v1[14] == 14);
+ assert(v1[15] == 15);
+}
diff --git a/test/std/numerics/numarray/template.mask.array/mask.array.comp.assign/shift_left.pass.cpp b/test/std/numerics/numarray/template.mask.array/mask.array.comp.assign/shift_left.pass.cpp
new file mode 100644
index 000000000000..9c1f92a3e807
--- /dev/null
+++ b/test/std/numerics/numarray/template.mask.array/mask.array.comp.assign/shift_left.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class mask_array
+
+// void operator<<=(const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+ const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+ int a2[] = {1, 2, 3, 4, 5};
+ const std::size_t N2 = sizeof(a2)/sizeof(a2[0]);
+ bool b[N1] = {true, false, false, true, true, false,
+ false, true, false, false, false, true};
+ std::valarray<int> v1(a1, N1);
+ std::valarray<int> v2(a2, N2);
+ assert(N2 == std::count(b, b+N1, true));
+ std::valarray<bool> vb(b, N1);
+ v1[vb] <<= v2;
+ assert(v1.size() == 16);
+ assert(v1[ 0] == 0);
+ assert(v1[ 1] == 1);
+ assert(v1[ 2] == 2);
+ assert(v1[ 3] == 12);
+ assert(v1[ 4] == 32);
+ assert(v1[ 5] == 5);
+ assert(v1[ 6] == 6);
+ assert(v1[ 7] == 112);
+ assert(v1[ 8] == 8);
+ assert(v1[ 9] == 9);
+ assert(v1[10] == 10);
+ assert(v1[11] == 352);
+ assert(v1[12] == 12);
+ assert(v1[13] == 13);
+ assert(v1[14] == 14);
+ assert(v1[15] == 15);
+}
diff --git a/test/std/numerics/numarray/template.mask.array/mask.array.comp.assign/shift_right.pass.cpp b/test/std/numerics/numarray/template.mask.array/mask.array.comp.assign/shift_right.pass.cpp
new file mode 100644
index 000000000000..438d3427d430
--- /dev/null
+++ b/test/std/numerics/numarray/template.mask.array/mask.array.comp.assign/shift_right.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class mask_array
+
+// void operator>>=(const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+ const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+ int a2[] = {1, 2, 3, 4, 5};
+ const std::size_t N2 = sizeof(a2)/sizeof(a2[0]);
+ bool b[N1] = {true, false, false, true, true, false,
+ false, true, false, false, false, true};
+ std::valarray<int> v1(a1, N1);
+ std::valarray<int> v2(a2, N2);
+ assert(N2 == std::count(b, b+N1, true));
+ std::valarray<bool> vb(b, N1);
+ v1[vb] >>= v2;
+ assert(v1.size() == 16);
+ assert(v1[ 0] == 0);
+ assert(v1[ 1] == 1);
+ assert(v1[ 2] == 2);
+ assert(v1[ 3] == 0);
+ assert(v1[ 4] == 0);
+ assert(v1[ 5] == 5);
+ assert(v1[ 6] == 6);
+ assert(v1[ 7] == 0);
+ assert(v1[ 8] == 8);
+ assert(v1[ 9] == 9);
+ assert(v1[10] == 10);
+ assert(v1[11] == 0);
+ assert(v1[12] == 12);
+ assert(v1[13] == 13);
+ assert(v1[14] == 14);
+ assert(v1[15] == 15);
+}
diff --git a/test/std/numerics/numarray/template.mask.array/mask.array.comp.assign/subtraction.pass.cpp b/test/std/numerics/numarray/template.mask.array/mask.array.comp.assign/subtraction.pass.cpp
new file mode 100644
index 000000000000..16e387dc6d78
--- /dev/null
+++ b/test/std/numerics/numarray/template.mask.array/mask.array.comp.assign/subtraction.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class mask_array
+
+// void operator-=(const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+ const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+ int a2[] = {1, 2, 3, 4, 5};
+ const std::size_t N2 = sizeof(a2)/sizeof(a2[0]);
+ bool b[N1] = {true, false, false, true, true, false,
+ false, true, false, false, false, true};
+ std::valarray<int> v1(a1, N1);
+ std::valarray<int> v2(a2, N2);
+ assert(N2 == std::count(b, b+N1, true));
+ std::valarray<bool> vb(b, N1);
+ v1[vb] -= v2;
+ assert(v1.size() == 16);
+ assert(v1[ 0] == -1);
+ assert(v1[ 1] == 1);
+ assert(v1[ 2] == 2);
+ assert(v1[ 3] == 1);
+ assert(v1[ 4] == 1);
+ assert(v1[ 5] == 5);
+ assert(v1[ 6] == 6);
+ assert(v1[ 7] == 3);
+ assert(v1[ 8] == 8);
+ assert(v1[ 9] == 9);
+ assert(v1[10] == 10);
+ assert(v1[11] == 6);
+ assert(v1[12] == 12);
+ assert(v1[13] == 13);
+ assert(v1[14] == 14);
+ assert(v1[15] == 15);
+}
diff --git a/test/std/numerics/numarray/template.mask.array/mask.array.comp.assign/xor.pass.cpp b/test/std/numerics/numarray/template.mask.array/mask.array.comp.assign/xor.pass.cpp
new file mode 100644
index 000000000000..ae3c2383d4d0
--- /dev/null
+++ b/test/std/numerics/numarray/template.mask.array/mask.array.comp.assign/xor.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class mask_array
+
+// void operator^=(const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+ const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+ int a2[] = {1, 2, 3, 4, 5};
+ const std::size_t N2 = sizeof(a2)/sizeof(a2[0]);
+ bool b[N1] = {true, false, false, true, true, false,
+ false, true, false, false, false, true};
+ std::valarray<int> v1(a1, N1);
+ std::valarray<int> v2(a2, N2);
+ assert(N2 == std::count(b, b+N1, true));
+ std::valarray<bool> vb(b, N1);
+ v1[vb] ^= v2;
+ assert(v1.size() == 16);
+ assert(v1[ 0] == 1);
+ assert(v1[ 1] == 1);
+ assert(v1[ 2] == 2);
+ assert(v1[ 3] == 1);
+ assert(v1[ 4] == 7);
+ assert(v1[ 5] == 5);
+ assert(v1[ 6] == 6);
+ assert(v1[ 7] == 3);
+ assert(v1[ 8] == 8);
+ assert(v1[ 9] == 9);
+ assert(v1[10] == 10);
+ assert(v1[11] == 14);
+ assert(v1[12] == 12);
+ assert(v1[13] == 13);
+ assert(v1[14] == 14);
+ assert(v1[15] == 15);
+}
diff --git a/test/std/numerics/numarray/template.mask.array/mask.array.fill/assign_value.pass.cpp b/test/std/numerics/numarray/template.mask.array/mask.array.fill/assign_value.pass.cpp
new file mode 100644
index 000000000000..c37916b0b7dc
--- /dev/null
+++ b/test/std/numerics/numarray/template.mask.array/mask.array.fill/assign_value.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class mask_array
+
+// void operator=(const value_type& x) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+ const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+ bool b[N1] = {true, false, false, true, true, false,
+ false, true, false, false, false, true};
+ std::valarray<int> v1(a1, N1);
+ std::valarray<bool> vb(b, N1);
+ v1[vb] = -5;
+ assert(v1.size() == 16);
+ assert(v1[ 0] == -5);
+ assert(v1[ 1] == 1);
+ assert(v1[ 2] == 2);
+ assert(v1[ 3] == -5);
+ assert(v1[ 4] == -5);
+ assert(v1[ 5] == 5);
+ assert(v1[ 6] == 6);
+ assert(v1[ 7] == -5);
+ assert(v1[ 8] == 8);
+ assert(v1[ 9] == 9);
+ assert(v1[10] == 10);
+ assert(v1[11] == -5);
+ assert(v1[12] == 12);
+ assert(v1[13] == 13);
+ assert(v1[14] == 14);
+ assert(v1[15] == 15);
+}
diff --git a/test/std/numerics/numarray/template.mask.array/types.pass.cpp b/test/std/numerics/numarray/template.mask.array/types.pass.cpp
new file mode 100644
index 000000000000..c984c3feaa16
--- /dev/null
+++ b/test/std/numerics/numarray/template.mask.array/types.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T>
+// class mask_array
+// {
+// public:
+// typedef T value_type;
+
+#include <valarray>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_same<std::mask_array<int>::value_type, int>::value), "");
+}
diff --git a/test/std/numerics/numarray/template.slice.array/default.fail.cpp b/test/std/numerics/numarray/template.slice.array/default.fail.cpp
new file mode 100644
index 000000000000..3b522f0e12cb
--- /dev/null
+++ b/test/std/numerics/numarray/template.slice.array/default.fail.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class slice_array
+
+// slice_array() = delete;
+
+#include <valarray>
+#include <type_traits>
+
+int main()
+{
+ std::slice_array<int> s;
+}
diff --git a/test/std/numerics/numarray/template.slice.array/slice.arr.assign/slice_array.pass.cpp b/test/std/numerics/numarray/template.slice.array/slice.arr.assign/slice_array.pass.cpp
new file mode 100644
index 000000000000..72275e01e1be
--- /dev/null
+++ b/test/std/numerics/numarray/template.slice.array/slice.arr.assign/slice_array.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class slice_array
+
+// const slice_array& operator=(const slice_array& sa) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+ int a2[] = {-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12};
+ std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+ const std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+ v1[std::slice(1, 5, 3)] = v2[std::slice(2, 5, 2)];
+ assert(v1.size() == 16);
+ assert(v1[ 0] == 0);
+ assert(v1[ 1] == -3);
+ assert(v1[ 2] == 2);
+ assert(v1[ 3] == 3);
+ assert(v1[ 4] == -5);
+ assert(v1[ 5] == 5);
+ assert(v1[ 6] == 6);
+ assert(v1[ 7] == -7);
+ assert(v1[ 8] == 8);
+ assert(v1[ 9] == 9);
+ assert(v1[10] == -9);
+ assert(v1[11] == 11);
+ assert(v1[12] == 12);
+ assert(v1[13] == -11);
+ assert(v1[14] == 14);
+ assert(v1[15] == 15);
+ }
+ // Test return value of assignment.
+ {
+ int a1[] = {0, 1, 2};
+ int a2[] = {3, 4, 3};
+ std::valarray<int> v1(a1, 3);
+ std::slice_array<int> s1 = v1[std::slice(1, 1, 1)];
+ std::slice_array<int> s2 = v1[std::slice(0, 1, 1)];
+ std::slice_array<int> const & s3 = (s1 = s2);
+ assert(&s1 == &s3);
+ }
+}
diff --git a/test/std/numerics/numarray/template.slice.array/slice.arr.assign/valarray.pass.cpp b/test/std/numerics/numarray/template.slice.array/slice.arr.assign/valarray.pass.cpp
new file mode 100644
index 000000000000..d3857863f91d
--- /dev/null
+++ b/test/std/numerics/numarray/template.slice.array/slice.arr.assign/valarray.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class slice_array
+
+// void operator=(const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+ int a2[] = {-1, -2, -3, -4, -5};
+ std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+ std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+ v1[std::slice(1, 5, 3)] = v2;
+ assert(v1.size() == 16);
+ assert(v1[ 0] == 0);
+ assert(v1[ 1] == -1);
+ assert(v1[ 2] == 2);
+ assert(v1[ 3] == 3);
+ assert(v1[ 4] == -2);
+ assert(v1[ 5] == 5);
+ assert(v1[ 6] == 6);
+ assert(v1[ 7] == -3);
+ assert(v1[ 8] == 8);
+ assert(v1[ 9] == 9);
+ assert(v1[10] == -4);
+ assert(v1[11] == 11);
+ assert(v1[12] == 12);
+ assert(v1[13] == -5);
+ assert(v1[14] == 14);
+ assert(v1[15] == 15);
+}
diff --git a/test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/addition.pass.cpp b/test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/addition.pass.cpp
new file mode 100644
index 000000000000..8b5bf75d414a
--- /dev/null
+++ b/test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/addition.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class slice_array
+
+// void operator+= (const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+ int a2[] = {-1, -2, -3, -4, -5};
+ std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+ std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+ v1[std::slice(1, 5, 3)] += v2;
+ assert(v1.size() == 16);
+ assert(v1[ 0] == 0);
+ assert(v1[ 1] == 0);
+ assert(v1[ 2] == 2);
+ assert(v1[ 3] == 3);
+ assert(v1[ 4] == 2);
+ assert(v1[ 5] == 5);
+ assert(v1[ 6] == 6);
+ assert(v1[ 7] == 4);
+ assert(v1[ 8] == 8);
+ assert(v1[ 9] == 9);
+ assert(v1[10] == 6);
+ assert(v1[11] == 11);
+ assert(v1[12] == 12);
+ assert(v1[13] == 8);
+ assert(v1[14] == 14);
+ assert(v1[15] == 15);
+}
diff --git a/test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/and.pass.cpp b/test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/and.pass.cpp
new file mode 100644
index 000000000000..dbcae84771bc
--- /dev/null
+++ b/test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/and.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class slice_array
+
+// void operator&= (const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+ int a2[] = {1, 2, 3, 4, 5};
+ std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+ std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+ v1[std::slice(1, 5, 3)] &= v2;
+ assert(v1.size() == 16);
+ assert(v1[ 0] == 0);
+ assert(v1[ 1] == 1);
+ assert(v1[ 2] == 2);
+ assert(v1[ 3] == 3);
+ assert(v1[ 4] == 0);
+ assert(v1[ 5] == 5);
+ assert(v1[ 6] == 6);
+ assert(v1[ 7] == 3);
+ assert(v1[ 8] == 8);
+ assert(v1[ 9] == 9);
+ assert(v1[10] == 0);
+ assert(v1[11] == 11);
+ assert(v1[12] == 12);
+ assert(v1[13] == 5);
+ assert(v1[14] == 14);
+ assert(v1[15] == 15);
+}
diff --git a/test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/divide.pass.cpp b/test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/divide.pass.cpp
new file mode 100644
index 000000000000..71785015ba3b
--- /dev/null
+++ b/test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/divide.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class slice_array
+
+// void operator/= (const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+ int a2[] = {-1, -2, -3, -4, -5};
+ std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+ std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+ v1[std::slice(1, 5, 3)] /= v2;
+ assert(v1.size() == 16);
+ assert(v1[ 0] == 0);
+ assert(v1[ 1] == -1);
+ assert(v1[ 2] == 2);
+ assert(v1[ 3] == 3);
+ assert(v1[ 4] == -2);
+ assert(v1[ 5] == 5);
+ assert(v1[ 6] == 6);
+ assert(v1[ 7] == -2);
+ assert(v1[ 8] == 8);
+ assert(v1[ 9] == 9);
+ assert(v1[10] == -2);
+ assert(v1[11] == 11);
+ assert(v1[12] == 12);
+ assert(v1[13] == -2);
+ assert(v1[14] == 14);
+ assert(v1[15] == 15);
+}
diff --git a/test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/modulo.pass.cpp b/test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/modulo.pass.cpp
new file mode 100644
index 000000000000..e08fb51a8c26
--- /dev/null
+++ b/test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/modulo.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class slice_array
+
+// void operator%= (const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+ int a2[] = {-1, -2, -3, -4, -5};
+ std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+ std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+ v1[std::slice(1, 5, 3)] %= v2;
+ assert(v1.size() == 16);
+ assert(v1[ 0] == 0);
+ assert(v1[ 1] == 0);
+ assert(v1[ 2] == 2);
+ assert(v1[ 3] == 3);
+ assert(v1[ 4] == 0);
+ assert(v1[ 5] == 5);
+ assert(v1[ 6] == 6);
+ assert(v1[ 7] == 1);
+ assert(v1[ 8] == 8);
+ assert(v1[ 9] == 9);
+ assert(v1[10] == 2);
+ assert(v1[11] == 11);
+ assert(v1[12] == 12);
+ assert(v1[13] == 3);
+ assert(v1[14] == 14);
+ assert(v1[15] == 15);
+}
diff --git a/test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/multiply.pass.cpp b/test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/multiply.pass.cpp
new file mode 100644
index 000000000000..257c03164209
--- /dev/null
+++ b/test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/multiply.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class slice_array
+
+// void operator*= (const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+ int a2[] = {-1, -2, -3, -4, -5};
+ std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+ std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+ v1[std::slice(1, 5, 3)] *= v2;
+ assert(v1.size() == 16);
+ assert(v1[ 0] == 0);
+ assert(v1[ 1] == -1);
+ assert(v1[ 2] == 2);
+ assert(v1[ 3] == 3);
+ assert(v1[ 4] == -8);
+ assert(v1[ 5] == 5);
+ assert(v1[ 6] == 6);
+ assert(v1[ 7] == -21);
+ assert(v1[ 8] == 8);
+ assert(v1[ 9] == 9);
+ assert(v1[10] == -40);
+ assert(v1[11] == 11);
+ assert(v1[12] == 12);
+ assert(v1[13] == -65);
+ assert(v1[14] == 14);
+ assert(v1[15] == 15);
+}
diff --git a/test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/or.pass.cpp b/test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/or.pass.cpp
new file mode 100644
index 000000000000..0826708a36f3
--- /dev/null
+++ b/test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/or.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class slice_array
+
+// void operator|= (const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+ int a2[] = {1, 2, 3, 4, 5};
+ std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+ std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+ v1[std::slice(1, 5, 3)] |= v2;
+ assert(v1.size() == 16);
+ assert(v1[ 0] == 0);
+ assert(v1[ 1] == 1);
+ assert(v1[ 2] == 2);
+ assert(v1[ 3] == 3);
+ assert(v1[ 4] == 6);
+ assert(v1[ 5] == 5);
+ assert(v1[ 6] == 6);
+ assert(v1[ 7] == 7);
+ assert(v1[ 8] == 8);
+ assert(v1[ 9] == 9);
+ assert(v1[10] == 14);
+ assert(v1[11] == 11);
+ assert(v1[12] == 12);
+ assert(v1[13] == 13);
+ assert(v1[14] == 14);
+ assert(v1[15] == 15);
+}
diff --git a/test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/shift_left.pass.cpp b/test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/shift_left.pass.cpp
new file mode 100644
index 000000000000..84360d8c9405
--- /dev/null
+++ b/test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/shift_left.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class slice_array
+
+// void operator<<=(const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+ int a2[] = {1, 2, 3, 4, 5};
+ std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+ std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+ v1[std::slice(1, 5, 3)] <<= v2;
+ assert(v1.size() == 16);
+ assert(v1[ 0] == 0);
+ assert(v1[ 1] == 2);
+ assert(v1[ 2] == 2);
+ assert(v1[ 3] == 3);
+ assert(v1[ 4] == 16);
+ assert(v1[ 5] == 5);
+ assert(v1[ 6] == 6);
+ assert(v1[ 7] == 56);
+ assert(v1[ 8] == 8);
+ assert(v1[ 9] == 9);
+ assert(v1[10] == 160);
+ assert(v1[11] == 11);
+ assert(v1[12] == 12);
+ assert(v1[13] == 416);
+ assert(v1[14] == 14);
+ assert(v1[15] == 15);
+}
diff --git a/test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/shift_right.pass.cpp b/test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/shift_right.pass.cpp
new file mode 100644
index 000000000000..c39cd53e9167
--- /dev/null
+++ b/test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/shift_right.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class slice_array
+
+// void operator>>=(const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+ int a2[] = {1, 2, 3, 4, 5};
+ std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+ std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+ v1[std::slice(1, 5, 3)] >>= v2;
+ assert(v1.size() == 16);
+ assert(v1[ 0] == 0);
+ assert(v1[ 1] == 0);
+ assert(v1[ 2] == 2);
+ assert(v1[ 3] == 3);
+ assert(v1[ 4] == 1);
+ assert(v1[ 5] == 5);
+ assert(v1[ 6] == 6);
+ assert(v1[ 7] == 0);
+ assert(v1[ 8] == 8);
+ assert(v1[ 9] == 9);
+ assert(v1[10] == 0);
+ assert(v1[11] == 11);
+ assert(v1[12] == 12);
+ assert(v1[13] == 0);
+ assert(v1[14] == 14);
+ assert(v1[15] == 15);
+}
diff --git a/test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/subtraction.pass.cpp b/test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/subtraction.pass.cpp
new file mode 100644
index 000000000000..e6419fb2cd1e
--- /dev/null
+++ b/test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/subtraction.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class slice_array
+
+// void operator-= (const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+ int a2[] = {-1, -2, -3, -4, -5};
+ std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+ std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+ v1[std::slice(1, 5, 3)] -= v2;
+ assert(v1.size() == 16);
+ assert(v1[ 0] == 0);
+ assert(v1[ 1] == 2);
+ assert(v1[ 2] == 2);
+ assert(v1[ 3] == 3);
+ assert(v1[ 4] == 6);
+ assert(v1[ 5] == 5);
+ assert(v1[ 6] == 6);
+ assert(v1[ 7] == 10);
+ assert(v1[ 8] == 8);
+ assert(v1[ 9] == 9);
+ assert(v1[10] == 14);
+ assert(v1[11] == 11);
+ assert(v1[12] == 12);
+ assert(v1[13] == 18);
+ assert(v1[14] == 14);
+ assert(v1[15] == 15);
+}
diff --git a/test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/xor.pass.cpp b/test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/xor.pass.cpp
new file mode 100644
index 000000000000..294106ed75a6
--- /dev/null
+++ b/test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/xor.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class slice_array
+
+// void operator^= (const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+ int a2[] = {1, 2, 3, 4, 5};
+ std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+ std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+ v1[std::slice(1, 5, 3)] ^= v2;
+ assert(v1.size() == 16);
+ assert(v1[ 0] == 0);
+ assert(v1[ 1] == 0);
+ assert(v1[ 2] == 2);
+ assert(v1[ 3] == 3);
+ assert(v1[ 4] == 6);
+ assert(v1[ 5] == 5);
+ assert(v1[ 6] == 6);
+ assert(v1[ 7] == 4);
+ assert(v1[ 8] == 8);
+ assert(v1[ 9] == 9);
+ assert(v1[10] == 14);
+ assert(v1[11] == 11);
+ assert(v1[12] == 12);
+ assert(v1[13] == 8);
+ assert(v1[14] == 14);
+ assert(v1[15] == 15);
+}
diff --git a/test/std/numerics/numarray/template.slice.array/slice.arr.fill/assign_value.pass.cpp b/test/std/numerics/numarray/template.slice.array/slice.arr.fill/assign_value.pass.cpp
new file mode 100644
index 000000000000..4f7af4baf6f5
--- /dev/null
+++ b/test/std/numerics/numarray/template.slice.array/slice.arr.fill/assign_value.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class slice_array
+
+// void operator=(const value_type& x) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+ std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+ v1[std::slice(1, 5, 3)] = 20;
+ assert(v1.size() == 16);
+ assert(v1[ 0] == 0);
+ assert(v1[ 1] == 20);
+ assert(v1[ 2] == 2);
+ assert(v1[ 3] == 3);
+ assert(v1[ 4] == 20);
+ assert(v1[ 5] == 5);
+ assert(v1[ 6] == 6);
+ assert(v1[ 7] == 20);
+ assert(v1[ 8] == 8);
+ assert(v1[ 9] == 9);
+ assert(v1[10] == 20);
+ assert(v1[11] == 11);
+ assert(v1[12] == 12);
+ assert(v1[13] == 20);
+ assert(v1[14] == 14);
+ assert(v1[15] == 15);
+}
diff --git a/test/std/numerics/numarray/template.slice.array/types.pass.cpp b/test/std/numerics/numarray/template.slice.array/types.pass.cpp
new file mode 100644
index 000000000000..8c40b154f4dc
--- /dev/null
+++ b/test/std/numerics/numarray/template.slice.array/types.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T>
+// class slice_array
+// {
+// public:
+// typedef T value_type;
+
+#include <valarray>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_same<std::slice_array<int>::value_type, int>::value), "");
+}
diff --git a/test/std/numerics/numarray/template.valarray/types.pass.cpp b/test/std/numerics/numarray/template.valarray/types.pass.cpp
new file mode 100644
index 000000000000..71421e543ffa
--- /dev/null
+++ b/test/std/numerics/numarray/template.valarray/types.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T>
+// class valarray
+// {
+// public:
+// typedef T value_type;
+// ...
+
+#include <valarray>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_same<std::valarray<int>::value_type, int>::value), "");
+ static_assert((std::is_same<std::valarray<double>::value_type, double>::value), "");
+}
diff --git a/test/std/numerics/numarray/template.valarray/valarray.access/access.pass.cpp b/test/std/numerics/numarray/template.valarray/valarray.access/access.pass.cpp
new file mode 100644
index 000000000000..7bf164aafc20
--- /dev/null
+++ b/test/std/numerics/numarray/template.valarray/valarray.access/access.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// value_type& operator[](size_t i);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a[] = {5, 4, 3, 2, 1};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::valarray<T> v(a, N);
+ for (int i = 0; i < N; ++i)
+ {
+ assert(v[i] == a[i]);
+ v[i] = i;
+ assert(v[i] == i);
+ }
+ }
+}
diff --git a/test/std/numerics/numarray/template.valarray/valarray.access/const_access.pass.cpp b/test/std/numerics/numarray/template.valarray/valarray.access/const_access.pass.cpp
new file mode 100644
index 000000000000..b9736eedd73b
--- /dev/null
+++ b/test/std/numerics/numarray/template.valarray/valarray.access/const_access.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// const value_type& operator[](size_t i) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a[] = {5, 4, 3, 2, 1};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ const std::valarray<T> v(a, N);
+ for (int i = 0; i < N; ++i)
+ {
+ assert(v[i] == a[i]);
+ }
+ }
+}
diff --git a/test/std/numerics/numarray/template.valarray/valarray.assign/copy_assign.pass.cpp b/test/std/numerics/numarray/template.valarray/valarray.assign/copy_assign.pass.cpp
new file mode 100644
index 000000000000..2fc42ada85be
--- /dev/null
+++ b/test/std/numerics/numarray/template.valarray/valarray.assign/copy_assign.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator=(const valarray& v);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a[] = {1, 2, 3, 4, 5};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::valarray<T> v(a, N);
+ std::valarray<T> v2;
+ v2 = v;
+ assert(v2.size() == v.size());
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == v[i]);
+ }
+ {
+ typedef double T;
+ T a[] = {1, 2.5, 3, 4.25, 5};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::valarray<T> v(a, N);
+ std::valarray<T> v2;
+ v2 = v;
+ assert(v2.size() == v.size());
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == v[i]);
+ }
+ {
+ typedef std::valarray<double> T;
+ T a[] = {T(1), T(2), T(3), T(4), T(5)};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::valarray<T> v(a, N);
+ std::valarray<T> v2(a, N-2);
+ v2 = v;
+ assert(v2.size() == v.size());
+ for (int i = 0; i < N; ++i)
+ {
+ assert(v2[i].size() == v[i].size());
+ for (int j = 0; j < v[i].size(); ++j)
+ assert(v2[i][j] == v[i][j]);
+ }
+ }
+}
diff --git a/test/std/numerics/numarray/template.valarray/valarray.assign/gslice_array_assign.pass.cpp b/test/std/numerics/numarray/template.valarray/valarray.assign/gslice_array_assign.pass.cpp
new file mode 100644
index 000000000000..dff523f19e68
--- /dev/null
+++ b/test/std/numerics/numarray/template.valarray/valarray.assign/gslice_array_assign.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator=(const gslice_array<value_type>& ga);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
+ 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+ 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+ 36, 37, 38, 39, 40};
+ std::valarray<int> v1(a, sizeof(a)/sizeof(a[0]));
+ std::size_t sz[] = {2, 4, 3};
+ std::size_t st[] = {19, 4, 1};
+ typedef std::valarray<std::size_t> sizes;
+ typedef std::valarray<std::size_t> strides;
+ std::valarray<int> v(24);
+ v = v1[std::gslice(3, sizes(sz, sizeof(sz)/sizeof(sz[0])),
+ strides(st, sizeof(st)/sizeof(st[0])))];
+ assert(v.size() == 24);
+ assert(v[ 0] == 3);
+ assert(v[ 1] == 4);
+ assert(v[ 2] == 5);
+ assert(v[ 3] == 7);
+ assert(v[ 4] == 8);
+ assert(v[ 5] == 9);
+ assert(v[ 6] == 11);
+ assert(v[ 7] == 12);
+ assert(v[ 8] == 13);
+ assert(v[ 9] == 15);
+ assert(v[10] == 16);
+ assert(v[11] == 17);
+ assert(v[12] == 22);
+ assert(v[13] == 23);
+ assert(v[14] == 24);
+ assert(v[15] == 26);
+ assert(v[16] == 27);
+ assert(v[17] == 28);
+ assert(v[18] == 30);
+ assert(v[19] == 31);
+ assert(v[20] == 32);
+ assert(v[21] == 34);
+ assert(v[22] == 35);
+ assert(v[23] == 36);
+}
diff --git a/test/std/numerics/numarray/template.valarray/valarray.assign/indirect_array_assign.pass.cpp b/test/std/numerics/numarray/template.valarray/valarray.assign/indirect_array_assign.pass.cpp
new file mode 100644
index 000000000000..6e8069cc2fad
--- /dev/null
+++ b/test/std/numerics/numarray/template.valarray/valarray.assign/indirect_array_assign.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator=(const indirect_array<value_type>& ia);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
+ 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+ 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+ 36, 37, 38, 39, 40};
+ const std::size_t N1 = sizeof(a)/sizeof(a[0]);
+ std::size_t s[] = { 3, 4, 5, 7, 8, 9, 11, 12, 13, 15, 16, 17,
+ 22, 23, 24, 26, 27, 28, 30, 31, 32, 34, 35, 36};
+ const std::size_t S = sizeof(s)/sizeof(s[0]);
+ std::valarray<int> v1(a, N1);
+ std::valarray<std::size_t> ia(s, S);
+ std::valarray<int> v(24);
+ v = v1[ia];
+ assert(v.size() == 24);
+ assert(v[ 0] == 3);
+ assert(v[ 1] == 4);
+ assert(v[ 2] == 5);
+ assert(v[ 3] == 7);
+ assert(v[ 4] == 8);
+ assert(v[ 5] == 9);
+ assert(v[ 6] == 11);
+ assert(v[ 7] == 12);
+ assert(v[ 8] == 13);
+ assert(v[ 9] == 15);
+ assert(v[10] == 16);
+ assert(v[11] == 17);
+ assert(v[12] == 22);
+ assert(v[13] == 23);
+ assert(v[14] == 24);
+ assert(v[15] == 26);
+ assert(v[16] == 27);
+ assert(v[17] == 28);
+ assert(v[18] == 30);
+ assert(v[19] == 31);
+ assert(v[20] == 32);
+ assert(v[21] == 34);
+ assert(v[22] == 35);
+ assert(v[23] == 36);
+}
diff --git a/test/std/numerics/numarray/template.valarray/valarray.assign/initializer_list_assign.pass.cpp b/test/std/numerics/numarray/template.valarray/valarray.assign/initializer_list_assign.pass.cpp
new file mode 100644
index 000000000000..571f56acd575
--- /dev/null
+++ b/test/std/numerics/numarray/template.valarray/valarray.assign/initializer_list_assign.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator=(initializer_list<value_type> il);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef int T;
+ T a[] = {1, 2, 3, 4, 5};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::valarray<T> v2;
+ v2 = {1, 2, 3, 4, 5};
+ assert(v2.size() == N);
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == a[i]);
+ }
+ {
+ typedef double T;
+ T a[] = {1, 2.5, 3, 4.25, 5};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::valarray<T> v2;
+ v2 = {1, 2.5, 3, 4.25, 5};
+ assert(v2.size() == N);
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == a[i]);
+ }
+ {
+ typedef std::valarray<double> T;
+ T a[] = {T(1), T(2), T(3), T(4), T(5)};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::valarray<T> v2(a, N-2);
+ v2 = {T(1), T(2), T(3), T(4), T(5)};
+ assert(v2.size() == N);
+ for (int i = 0; i < N; ++i)
+ {
+ assert(v2[i].size() == a[i].size());
+ for (int j = 0; j < a[i].size(); ++j)
+ assert(v2[i][j] == a[i][j]);
+ }
+ }
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/numerics/numarray/template.valarray/valarray.assign/mask_array_assign.pass.cpp b/test/std/numerics/numarray/template.valarray/valarray.assign/mask_array_assign.pass.cpp
new file mode 100644
index 000000000000..a52c9d9d6726
--- /dev/null
+++ b/test/std/numerics/numarray/template.valarray/valarray.assign/mask_array_assign.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator=(const mask_array<value_type>& ma);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+ const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+ bool b[N1] = {true, false, false, true, true, false,
+ false, true, false, false, false, true};
+ std::valarray<int> v1(a1, N1);
+ std::valarray<bool> vb(b, N1);
+ std::valarray<int> v2(5);
+ v2 = v1[vb];
+ assert(v2.size() == 5);
+ assert(v2[ 0] == 0);
+ assert(v2[ 1] == 3);
+ assert(v2[ 2] == 4);
+ assert(v2[ 3] == 7);
+ assert(v2[ 4] == 11);
+}
diff --git a/test/std/numerics/numarray/template.valarray/valarray.assign/move_assign.pass.cpp b/test/std/numerics/numarray/template.valarray/valarray.assign/move_assign.pass.cpp
new file mode 100644
index 000000000000..d4f750652e28
--- /dev/null
+++ b/test/std/numerics/numarray/template.valarray/valarray.assign/move_assign.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator=(valarray&& v);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef int T;
+ T a[] = {1, 2, 3, 4, 5};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::valarray<T> v(a, N);
+ std::valarray<T> v2;
+ v2 = std::move(v);
+ assert(v2.size() == N);
+ assert(v.size() == 0);
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == a[i]);
+ }
+ {
+ typedef double T;
+ T a[] = {1, 2.5, 3, 4.25, 5};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::valarray<T> v(a, N);
+ std::valarray<T> v2;
+ v2 = std::move(v);
+ assert(v2.size() == N);
+ assert(v.size() == 0);
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == a[i]);
+ }
+ {
+ typedef std::valarray<double> T;
+ T a[] = {T(1), T(2), T(3), T(4), T(5)};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::valarray<T> v(a, N);
+ std::valarray<T> v2(a, N-2);
+ v2 = std::move(v);
+ assert(v2.size() == N);
+ assert(v.size() == 0);
+ for (int i = 0; i < N; ++i)
+ {
+ assert(v2[i].size() == a[i].size());
+ for (int j = 0; j < a[i].size(); ++j)
+ assert(v2[i][j] == a[i][j]);
+ }
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/numerics/numarray/template.valarray/valarray.assign/slice_array_assign.pass.cpp b/test/std/numerics/numarray/template.valarray/valarray.assign/slice_array_assign.pass.cpp
new file mode 100644
index 000000000000..9a7517aa1f44
--- /dev/null
+++ b/test/std/numerics/numarray/template.valarray/valarray.assign/slice_array_assign.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator=(const slice_array<value_type>& sa);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+ std::valarray<int> v1(a, sizeof(a)/sizeof(a[0]));
+ std::valarray<int> v(5);
+ v = v1[std::slice(1, 5, 3)];
+ assert(v.size() == 5);
+ assert(v[0] == 1);
+ assert(v[1] == 4);
+ assert(v[2] == 7);
+ assert(v[3] == 10);
+ assert(v[4] == 13);
+}
diff --git a/test/std/numerics/numarray/template.valarray/valarray.assign/value_assign.pass.cpp b/test/std/numerics/numarray/template.valarray/valarray.assign/value_assign.pass.cpp
new file mode 100644
index 000000000000..b9d67f86a212
--- /dev/null
+++ b/test/std/numerics/numarray/template.valarray/valarray.assign/value_assign.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator=(const value_type& x);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a[] = {1, 2, 3, 4, 5};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::valarray<T> v(a, N);
+ v = 7;
+ assert(v.size() == N);
+ for (int i = 0; i < v.size(); ++i)
+ assert(v[i] == 7);
+ }
+}
diff --git a/test/std/numerics/numarray/template.valarray/valarray.cassign/and_valarray.pass.cpp b/test/std/numerics/numarray/template.valarray/valarray.cassign/and_valarray.pass.cpp
new file mode 100644
index 000000000000..5b1c1b9911b4
--- /dev/null
+++ b/test/std/numerics/numarray/template.valarray/valarray.cassign/and_valarray.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator&=(const valarray& v);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5};
+ T a2[] = {6, 7, 8, 9, 10};
+ T a3[] = {0, 2, 0, 0, 0};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2(a2, N);
+ std::valarray<T> v3(a3, N);
+ v1 &= v2;
+ assert(v1.size() == v2.size());
+ assert(v1.size() == v3.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v1[i] == v3[i]);
+ }
+}
diff --git a/test/std/numerics/numarray/template.valarray/valarray.cassign/and_value.pass.cpp b/test/std/numerics/numarray/template.valarray/valarray.cassign/and_value.pass.cpp
new file mode 100644
index 000000000000..2106a13e2c35
--- /dev/null
+++ b/test/std/numerics/numarray/template.valarray/valarray.cassign/and_value.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator&=(const value_type& x);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = { 1, 2, 3, 4, 5};
+ T a2[] = { 1, 2, 3, 0, 1};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2(a2, N);
+ v1 &= 3;
+ assert(v1.size() == v2.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v1[i] == v2[i]);
+ }
+}
diff --git a/test/std/numerics/numarray/template.valarray/valarray.cassign/divide_valarray.pass.cpp b/test/std/numerics/numarray/template.valarray/valarray.cassign/divide_valarray.pass.cpp
new file mode 100644
index 000000000000..3992d0aa43da
--- /dev/null
+++ b/test/std/numerics/numarray/template.valarray/valarray.cassign/divide_valarray.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator/=(const valarray& v);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5};
+ T a2[] = {6, 7, 8, 9, 10};
+ T a3[] = {6, 14, 24, 36, 50};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2(a2, N);
+ std::valarray<T> v3(a3, N);
+ v3 /= v2;
+ assert(v1.size() == v2.size());
+ assert(v1.size() == v3.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v1[i] == v3[i]);
+ }
+}
diff --git a/test/std/numerics/numarray/template.valarray/valarray.cassign/divide_value.pass.cpp b/test/std/numerics/numarray/template.valarray/valarray.cassign/divide_value.pass.cpp
new file mode 100644
index 000000000000..7bd1cc84df6c
--- /dev/null
+++ b/test/std/numerics/numarray/template.valarray/valarray.cassign/divide_value.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator/=(const value_type& x);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5};
+ T a2[] = {6, 12, 18, 24, 30};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2(a2, N);
+ v2 /= 6;
+ assert(v1.size() == v2.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v1[i] == v2[i]);
+ }
+}
diff --git a/test/std/numerics/numarray/template.valarray/valarray.cassign/minus_valarray.pass.cpp b/test/std/numerics/numarray/template.valarray/valarray.cassign/minus_valarray.pass.cpp
new file mode 100644
index 000000000000..e3d308abacc1
--- /dev/null
+++ b/test/std/numerics/numarray/template.valarray/valarray.cassign/minus_valarray.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator-=(const valarray& v);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5};
+ T a2[] = {6, 7, 8, 9, 10};
+ T a3[] = {7, 9, 11, 13, 15};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2(a2, N);
+ std::valarray<T> v3(a3, N);
+ v3 -= v2;
+ assert(v1.size() == v2.size());
+ assert(v1.size() == v3.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v1[i] == v3[i]);
+ }
+}
diff --git a/test/std/numerics/numarray/template.valarray/valarray.cassign/minus_value.pass.cpp b/test/std/numerics/numarray/template.valarray/valarray.cassign/minus_value.pass.cpp
new file mode 100644
index 000000000000..27ea8c2c0366
--- /dev/null
+++ b/test/std/numerics/numarray/template.valarray/valarray.cassign/minus_value.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator-=(const value_type& x);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = { 1, 2, 3, 4, 5};
+ T a2[] = {-2, -1, 0, 1, 2};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2(a2, N);
+ v1 -= 3;
+ assert(v1.size() == v2.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v1[i] == v2[i]);
+ }
+}
diff --git a/test/std/numerics/numarray/template.valarray/valarray.cassign/modulo_valarray.pass.cpp b/test/std/numerics/numarray/template.valarray/valarray.cassign/modulo_valarray.pass.cpp
new file mode 100644
index 000000000000..1754a5575eb5
--- /dev/null
+++ b/test/std/numerics/numarray/template.valarray/valarray.cassign/modulo_valarray.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator%=(const valarray& v);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5};
+ T a2[] = {6, 7, 8, 9, 10};
+ T a3[] = {0, 1, 2, 1, 0};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2(a2, N);
+ std::valarray<T> v3(a3, N);
+ v2 %= v1;
+ assert(v1.size() == v2.size());
+ assert(v1.size() == v3.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v2[i] == v3[i]);
+ }
+}
diff --git a/test/std/numerics/numarray/template.valarray/valarray.cassign/modulo_value.pass.cpp b/test/std/numerics/numarray/template.valarray/valarray.cassign/modulo_value.pass.cpp
new file mode 100644
index 000000000000..794a0b629268
--- /dev/null
+++ b/test/std/numerics/numarray/template.valarray/valarray.cassign/modulo_value.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator%=(const value_type& x);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5};
+ T a2[] = {1, 2, 0, 1, 2};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2(a2, N);
+ v1 %= 3;
+ assert(v1.size() == v2.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v1[i] == v2[i]);
+ }
+}
diff --git a/test/std/numerics/numarray/template.valarray/valarray.cassign/or_valarray.pass.cpp b/test/std/numerics/numarray/template.valarray/valarray.cassign/or_valarray.pass.cpp
new file mode 100644
index 000000000000..0d70b4e715da
--- /dev/null
+++ b/test/std/numerics/numarray/template.valarray/valarray.cassign/or_valarray.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator|=(const valarray& v);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5};
+ T a2[] = {6, 7, 8, 9, 10};
+ T a3[] = {7, 7, 11, 13, 15};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2(a2, N);
+ std::valarray<T> v3(a3, N);
+ v1 |= v2;
+ assert(v1.size() == v2.size());
+ assert(v1.size() == v3.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v1[i] == v3[i]);
+ }
+}
diff --git a/test/std/numerics/numarray/template.valarray/valarray.cassign/or_value.pass.cpp b/test/std/numerics/numarray/template.valarray/valarray.cassign/or_value.pass.cpp
new file mode 100644
index 000000000000..4030907ff3e7
--- /dev/null
+++ b/test/std/numerics/numarray/template.valarray/valarray.cassign/or_value.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator|=(const value_type& x);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = { 1, 2, 3, 4, 5};
+ T a2[] = { 3, 3, 3, 7, 7};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2(a2, N);
+ v1 |= 3;
+ assert(v1.size() == v2.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v1[i] == v2[i]);
+ }
+}
diff --git a/test/std/numerics/numarray/template.valarray/valarray.cassign/plus_valarray.pass.cpp b/test/std/numerics/numarray/template.valarray/valarray.cassign/plus_valarray.pass.cpp
new file mode 100644
index 000000000000..fdf999c2a044
--- /dev/null
+++ b/test/std/numerics/numarray/template.valarray/valarray.cassign/plus_valarray.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator+=(const valarray& v);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5};
+ T a2[] = {6, 7, 8, 9, 10};
+ T a3[] = {7, 9, 11, 13, 15};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2(a2, N);
+ std::valarray<T> v3(a3, N);
+ v1 += v2;
+ assert(v1.size() == v2.size());
+ assert(v1.size() == v3.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v1[i] == v3[i]);
+ }
+}
diff --git a/test/std/numerics/numarray/template.valarray/valarray.cassign/plus_value.pass.cpp b/test/std/numerics/numarray/template.valarray/valarray.cassign/plus_value.pass.cpp
new file mode 100644
index 000000000000..23d6d9d05229
--- /dev/null
+++ b/test/std/numerics/numarray/template.valarray/valarray.cassign/plus_value.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator+=(const value_type& x);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5};
+ T a2[] = {4, 5, 6, 7, 8};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2(a2, N);
+ v1 += 3;
+ assert(v1.size() == v2.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v1[i] == v2[i]);
+ }
+}
diff --git a/test/std/numerics/numarray/template.valarray/valarray.cassign/shift_left_valarray.pass.cpp b/test/std/numerics/numarray/template.valarray/valarray.cassign/shift_left_valarray.pass.cpp
new file mode 100644
index 000000000000..ad44e3887eca
--- /dev/null
+++ b/test/std/numerics/numarray/template.valarray/valarray.cassign/shift_left_valarray.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator<<=(const valarray& v);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = { 1, 2, 3, 4, 5};
+ T a2[] = { 6, 7, 8, 9, 10};
+ T a3[] = {64, 256, 768, 2048, 5120};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2(a2, N);
+ std::valarray<T> v3(a3, N);
+ v1 <<= v2;
+ assert(v1.size() == v2.size());
+ assert(v1.size() == v3.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v1[i] == v3[i]);
+ }
+}
diff --git a/test/std/numerics/numarray/template.valarray/valarray.cassign/shift_left_value.pass.cpp b/test/std/numerics/numarray/template.valarray/valarray.cassign/shift_left_value.pass.cpp
new file mode 100644
index 000000000000..366407a95c6f
--- /dev/null
+++ b/test/std/numerics/numarray/template.valarray/valarray.cassign/shift_left_value.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator<<=(const value_type& x);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = { 1, 2, 3, 4, 5};
+ T a2[] = { 8, 16, 24, 32, 40};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2(a2, N);
+ v1 <<= 3;
+ assert(v1.size() == v2.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v1[i] == v2[i]);
+ }
+}
diff --git a/test/std/numerics/numarray/template.valarray/valarray.cassign/shift_right_valarray.pass.cpp b/test/std/numerics/numarray/template.valarray/valarray.cassign/shift_right_valarray.pass.cpp
new file mode 100644
index 000000000000..f7df16b843ca
--- /dev/null
+++ b/test/std/numerics/numarray/template.valarray/valarray.cassign/shift_right_valarray.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator>>=(const valarray& v);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = { 1, 2, 3, 4, 5};
+ T a2[] = { 6, 7, 8, 9, 10};
+ T a3[] = {64, 256, 768, 2048, 5120};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2(a2, N);
+ std::valarray<T> v3(a3, N);
+ v3 >>= v2;
+ assert(v1.size() == v2.size());
+ assert(v1.size() == v3.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v1[i] == v3[i]);
+ }
+}
diff --git a/test/std/numerics/numarray/template.valarray/valarray.cassign/shift_right_value.pass.cpp b/test/std/numerics/numarray/template.valarray/valarray.cassign/shift_right_value.pass.cpp
new file mode 100644
index 000000000000..7c568b14cbea
--- /dev/null
+++ b/test/std/numerics/numarray/template.valarray/valarray.cassign/shift_right_value.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator>>=(const value_type& x);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = { 1, 2, 3, 4, 5};
+ T a2[] = { 8, 16, 24, 32, 40};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2(a2, N);
+ v2 >>= 3;
+ assert(v1.size() == v2.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v1[i] == v2[i]);
+ }
+}
diff --git a/test/std/numerics/numarray/template.valarray/valarray.cassign/times_valarray.pass.cpp b/test/std/numerics/numarray/template.valarray/valarray.cassign/times_valarray.pass.cpp
new file mode 100644
index 000000000000..d3cf1eb88641
--- /dev/null
+++ b/test/std/numerics/numarray/template.valarray/valarray.cassign/times_valarray.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator*=(const valarray& v);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5};
+ T a2[] = {6, 7, 8, 9, 10};
+ T a3[] = {6, 14, 24, 36, 50};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2(a2, N);
+ std::valarray<T> v3(a3, N);
+ v1 *= v2;
+ assert(v1.size() == v2.size());
+ assert(v1.size() == v3.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v1[i] == v3[i]);
+ }
+}
diff --git a/test/std/numerics/numarray/template.valarray/valarray.cassign/times_value.pass.cpp b/test/std/numerics/numarray/template.valarray/valarray.cassign/times_value.pass.cpp
new file mode 100644
index 000000000000..aea9806bc0d0
--- /dev/null
+++ b/test/std/numerics/numarray/template.valarray/valarray.cassign/times_value.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator*=(const value_type& x);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5};
+ T a2[] = {6, 12, 18, 24, 30};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2(a2, N);
+ v1 *= 6;
+ assert(v1.size() == v2.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v1[i] == v2[i]);
+ }
+}
diff --git a/test/std/numerics/numarray/template.valarray/valarray.cassign/xor_valarray.pass.cpp b/test/std/numerics/numarray/template.valarray/valarray.cassign/xor_valarray.pass.cpp
new file mode 100644
index 000000000000..a10bd7e0a000
--- /dev/null
+++ b/test/std/numerics/numarray/template.valarray/valarray.cassign/xor_valarray.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator^=(const valarray& v);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5};
+ T a2[] = {6, 7, 8, 9, 10};
+ T a3[] = {7, 5, 11, 13, 15};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2(a2, N);
+ std::valarray<T> v3(a3, N);
+ v1 ^= v2;
+ assert(v1.size() == v2.size());
+ assert(v1.size() == v3.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v1[i] == v3[i]);
+ }
+}
diff --git a/test/std/numerics/numarray/template.valarray/valarray.cassign/xor_value.pass.cpp b/test/std/numerics/numarray/template.valarray/valarray.cassign/xor_value.pass.cpp
new file mode 100644
index 000000000000..327952f7b3aa
--- /dev/null
+++ b/test/std/numerics/numarray/template.valarray/valarray.cassign/xor_value.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator^=(const value_type& x);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = { 1, 2, 3, 4, 5};
+ T a2[] = { 2, 1, 0, 7, 6};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2(a2, N);
+ v1 ^= 3;
+ assert(v1.size() == v2.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v1[i] == v2[i]);
+ }
+}
diff --git a/test/std/numerics/numarray/template.valarray/valarray.cons/copy.pass.cpp b/test/std/numerics/numarray/template.valarray/valarray.cons/copy.pass.cpp
new file mode 100644
index 000000000000..04ac2cdf1b90
--- /dev/null
+++ b/test/std/numerics/numarray/template.valarray/valarray.cons/copy.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray(const valarray<value_type>& v);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a[] = {1, 2, 3, 4, 5};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::valarray<T> v(a, N);
+ std::valarray<T> v2 = v;
+ assert(v2.size() == v.size());
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == v[i]);
+ }
+ {
+ typedef double T;
+ T a[] = {1, 2.5, 3, 4.25, 5};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::valarray<T> v(a, N);
+ std::valarray<T> v2 = v;
+ assert(v2.size() == v.size());
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == v[i]);
+ }
+ {
+ typedef std::valarray<double> T;
+ T a[] = {T(1), T(2), T(3), T(4), T(5)};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::valarray<T> v(a, N);
+ std::valarray<T> v2 = v;
+ assert(v2.size() == v.size());
+ for (int i = 0; i < N; ++i)
+ {
+ assert(v2[i].size() == v[i].size());
+ for (int j = 0; j < v[i].size(); ++j)
+ assert(v2[i][j] == v[i][j]);
+ }
+ }
+}
diff --git a/test/std/numerics/numarray/template.valarray/valarray.cons/default.pass.cpp b/test/std/numerics/numarray/template.valarray/valarray.cons/default.pass.cpp
new file mode 100644
index 000000000000..f46e0bf28cf8
--- /dev/null
+++ b/test/std/numerics/numarray/template.valarray/valarray.cons/default.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray();
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ std::valarray<int> v;
+ assert(v.size() == 0);
+ }
+ {
+ std::valarray<float> v;
+ assert(v.size() == 0);
+ }
+ {
+ std::valarray<double> v;
+ assert(v.size() == 0);
+ }
+ {
+ std::valarray<std::valarray<double> > v;
+ assert(v.size() == 0);
+ }
+}
diff --git a/test/std/numerics/numarray/template.valarray/valarray.cons/gslice_array.pass.cpp b/test/std/numerics/numarray/template.valarray/valarray.cons/gslice_array.pass.cpp
new file mode 100644
index 000000000000..56601dc92531
--- /dev/null
+++ b/test/std/numerics/numarray/template.valarray/valarray.cons/gslice_array.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray(const gslice_array<value_type>& sa);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
+ 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+ 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+ 36, 37, 38, 39, 40};
+ std::valarray<int> v1(a, sizeof(a)/sizeof(a[0]));
+ std::size_t sz[] = {2, 4, 3};
+ std::size_t st[] = {19, 4, 1};
+ typedef std::valarray<std::size_t> sizes;
+ typedef std::valarray<std::size_t> strides;
+ std::valarray<int> v(v1[std::gslice(3, sizes(sz, sizeof(sz)/sizeof(sz[0])),
+ strides(st, sizeof(st)/sizeof(st[0])))]);
+ assert(v.size() == 24);
+ assert(v[ 0] == 3);
+ assert(v[ 1] == 4);
+ assert(v[ 2] == 5);
+ assert(v[ 3] == 7);
+ assert(v[ 4] == 8);
+ assert(v[ 5] == 9);
+ assert(v[ 6] == 11);
+ assert(v[ 7] == 12);
+ assert(v[ 8] == 13);
+ assert(v[ 9] == 15);
+ assert(v[10] == 16);
+ assert(v[11] == 17);
+ assert(v[12] == 22);
+ assert(v[13] == 23);
+ assert(v[14] == 24);
+ assert(v[15] == 26);
+ assert(v[16] == 27);
+ assert(v[17] == 28);
+ assert(v[18] == 30);
+ assert(v[19] == 31);
+ assert(v[20] == 32);
+ assert(v[21] == 34);
+ assert(v[22] == 35);
+ assert(v[23] == 36);
+}
diff --git a/test/std/numerics/numarray/template.valarray/valarray.cons/indirect_array.pass.cpp b/test/std/numerics/numarray/template.valarray/valarray.cons/indirect_array.pass.cpp
new file mode 100644
index 000000000000..dbca1f9c7661
--- /dev/null
+++ b/test/std/numerics/numarray/template.valarray/valarray.cons/indirect_array.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray(const indirect_array<value_type>& ia);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
+ 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+ 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+ 36, 37, 38, 39, 40};
+ const std::size_t N1 = sizeof(a)/sizeof(a[0]);
+ std::size_t s[] = { 3, 4, 5, 7, 8, 9, 11, 12, 13, 15, 16, 17,
+ 22, 23, 24, 26, 27, 28, 30, 31, 32, 34, 35, 36};
+ const std::size_t S = sizeof(s)/sizeof(s[0]);
+ std::valarray<int> v1(a, N1);
+ std::valarray<std::size_t> ia(s, S);
+ std::valarray<int> v(v1[ia]);
+ assert(v.size() == 24);
+ assert(v[ 0] == 3);
+ assert(v[ 1] == 4);
+ assert(v[ 2] == 5);
+ assert(v[ 3] == 7);
+ assert(v[ 4] == 8);
+ assert(v[ 5] == 9);
+ assert(v[ 6] == 11);
+ assert(v[ 7] == 12);
+ assert(v[ 8] == 13);
+ assert(v[ 9] == 15);
+ assert(v[10] == 16);
+ assert(v[11] == 17);
+ assert(v[12] == 22);
+ assert(v[13] == 23);
+ assert(v[14] == 24);
+ assert(v[15] == 26);
+ assert(v[16] == 27);
+ assert(v[17] == 28);
+ assert(v[18] == 30);
+ assert(v[19] == 31);
+ assert(v[20] == 32);
+ assert(v[21] == 34);
+ assert(v[22] == 35);
+ assert(v[23] == 36);
+}
diff --git a/test/std/numerics/numarray/template.valarray/valarray.cons/initializer_list.pass.cpp b/test/std/numerics/numarray/template.valarray/valarray.cons/initializer_list.pass.cpp
new file mode 100644
index 000000000000..1ab460f1b9d5
--- /dev/null
+++ b/test/std/numerics/numarray/template.valarray/valarray.cons/initializer_list.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray(initializer_list<value_type>);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef int T;
+ T a[] = {1, 2, 3, 4, 5};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::valarray<T> v = {1, 2, 3, 4, 5};
+ assert(v.size() == N);
+ for (int i = 0; i < N; ++i)
+ assert(v[i] == a[i]);
+ }
+ {
+ typedef double T;
+ T a[] = {1, 2, 3, 4, 5};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::valarray<T> v = {1, 2, 3, 4, 5};
+ assert(v.size() == N);
+ for (int i = 0; i < N; ++i)
+ assert(v[i] == a[i]);
+ }
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/numerics/numarray/template.valarray/valarray.cons/mask_array.pass.cpp b/test/std/numerics/numarray/template.valarray/valarray.cons/mask_array.pass.cpp
new file mode 100644
index 000000000000..be4f7403945e
--- /dev/null
+++ b/test/std/numerics/numarray/template.valarray/valarray.cons/mask_array.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray(const mask_array<value_type>& ma);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+ const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+ bool b[N1] = {true, false, false, true, true, false,
+ false, true, false, false, false, true};
+ std::valarray<int> v1(a1, N1);
+ std::valarray<bool> vb(b, N1);
+ std::valarray<int> v2(v1[vb]);
+ assert(v2.size() == 5);
+ assert(v2[ 0] == 0);
+ assert(v2[ 1] == 3);
+ assert(v2[ 2] == 4);
+ assert(v2[ 3] == 7);
+ assert(v2[ 4] == 11);
+}
diff --git a/test/std/numerics/numarray/template.valarray/valarray.cons/move.pass.cpp b/test/std/numerics/numarray/template.valarray/valarray.cons/move.pass.cpp
new file mode 100644
index 000000000000..6ac8773fa4e2
--- /dev/null
+++ b/test/std/numerics/numarray/template.valarray/valarray.cons/move.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray(const valarray<value_type>& v);
+
+#include <valarray>
+#include <utility>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef int T;
+ T a[] = {1, 2, 3, 4, 5};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::valarray<T> v(a, N);
+ std::valarray<T> v2 = std::move(v);
+ assert(v2.size() == N);
+ assert(v.size() == 0);
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == a[i]);
+ }
+ {
+ typedef double T;
+ T a[] = {1, 2.5, 3, 4.25, 5};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::valarray<T> v(a, N);
+ std::valarray<T> v2 = std::move(v);
+ assert(v2.size() == N);
+ assert(v.size() == 0);
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == a[i]);
+ }
+ {
+ typedef std::valarray<double> T;
+ T a[] = {T(1), T(2), T(3), T(4), T(5)};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::valarray<T> v(a, N);
+ std::valarray<T> v2 = std::move(v);
+ assert(v2.size() == N);
+ assert(v.size() == 0);
+ for (int i = 0; i < N; ++i)
+ {
+ assert(v2[i].size() == a[i].size());
+ for (int j = 0; j < v2[i].size(); ++j)
+ assert(v2[i][j] == a[i][j]);
+ }
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/numerics/numarray/template.valarray/valarray.cons/pointer_size.pass.cpp b/test/std/numerics/numarray/template.valarray/valarray.cons/pointer_size.pass.cpp
new file mode 100644
index 000000000000..3d3649ee40ac
--- /dev/null
+++ b/test/std/numerics/numarray/template.valarray/valarray.cons/pointer_size.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray(const value_type* p, size_t n);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a[] = {1, 2, 3, 4, 5};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::valarray<T> v(a, N);
+ assert(v.size() == N);
+ for (int i = 0; i < N; ++i)
+ assert(v[i] == a[i]);
+ }
+ {
+ typedef double T;
+ T a[] = {1, 2.5, 3, 4.25, 5};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::valarray<T> v(a, N);
+ assert(v.size() == N);
+ for (int i = 0; i < N; ++i)
+ assert(v[i] == a[i]);
+ }
+ {
+ typedef std::valarray<double> T;
+ T a[] = {T(1), T(2), T(3), T(4), T(5)};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::valarray<T> v(a, N);
+ assert(v.size() == N);
+ for (int i = 0; i < N; ++i)
+ {
+ assert(v[i].size() == a[i].size());
+ for (int j = 0; j < v[i].size(); ++j)
+ assert(v[i][j] == a[i][j]);
+ }
+ }
+}
diff --git a/test/std/numerics/numarray/template.valarray/valarray.cons/size.pass.cpp b/test/std/numerics/numarray/template.valarray/valarray.cons/size.pass.cpp
new file mode 100644
index 000000000000..359073eb3ae9
--- /dev/null
+++ b/test/std/numerics/numarray/template.valarray/valarray.cons/size.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// explicit valarray(size_t);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ std::valarray<int> v(100);
+ assert(v.size() == 100);
+ for (int i = 0; i < 100; ++i)
+ assert(v[i] == 0);
+ }
+ {
+ std::valarray<double> v(100);
+ assert(v.size() == 100);
+ for (int i = 0; i < 100; ++i)
+ assert(v[i] == 0);
+ }
+ {
+ std::valarray<std::valarray<double> > v(100);
+ assert(v.size() == 100);
+ for (int i = 0; i < 100; ++i)
+ assert(v[i].size() == 0);
+ }
+}
diff --git a/test/std/numerics/numarray/template.valarray/valarray.cons/slice_array.pass.cpp b/test/std/numerics/numarray/template.valarray/valarray.cons/slice_array.pass.cpp
new file mode 100644
index 000000000000..b676414140c1
--- /dev/null
+++ b/test/std/numerics/numarray/template.valarray/valarray.cons/slice_array.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray(const slice_array<value_type>& sa);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+ std::valarray<int> v1(a, sizeof(a)/sizeof(a[0]));
+ std::valarray<int> v(v1[std::slice(1, 5, 3)]);
+ assert(v.size() == 5);
+ assert(v[0] == 1);
+ assert(v[1] == 4);
+ assert(v[2] == 7);
+ assert(v[3] == 10);
+ assert(v[4] == 13);
+}
diff --git a/test/std/numerics/numarray/template.valarray/valarray.cons/value_size.pass.cpp b/test/std/numerics/numarray/template.valarray/valarray.cons/value_size.pass.cpp
new file mode 100644
index 000000000000..336c898b548d
--- /dev/null
+++ b/test/std/numerics/numarray/template.valarray/valarray.cons/value_size.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray(const value_type& x, size_t n);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ std::valarray<int> v(5, 100);
+ assert(v.size() == 100);
+ for (int i = 0; i < 100; ++i)
+ assert(v[i] == 5);
+ }
+ {
+ std::valarray<double> v(2.5, 100);
+ assert(v.size() == 100);
+ for (int i = 0; i < 100; ++i)
+ assert(v[i] == 2.5);
+ }
+ {
+ std::valarray<std::valarray<double> > v(std::valarray<double>(10), 100);
+ assert(v.size() == 100);
+ for (int i = 0; i < 100; ++i)
+ assert(v[i].size() == 10);
+ }
+}
diff --git a/test/std/numerics/numarray/template.valarray/valarray.members/apply_cref.pass.cpp b/test/std/numerics/numarray/template.valarray/valarray.members/apply_cref.pass.cpp
new file mode 100644
index 000000000000..919a3a5e4997
--- /dev/null
+++ b/test/std/numerics/numarray/template.valarray/valarray.members/apply_cref.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray apply(value_type f(const value_type&)) const;
+
+#include <valarray>
+#include <cassert>
+
+typedef int T;
+
+T f(const T& t) {return t + 5;}
+
+int main()
+{
+ {
+ T a1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+ T a2[] = {6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+ const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N1);
+ std::valarray<T> v2 = v1.apply(f);
+ assert(v2.size() == N1);
+ for (unsigned i = 0; i < N1; ++i)
+ assert(v2[i] == a2[i]);
+ }
+ {
+ const unsigned N1 = 0;
+ std::valarray<T> v1;
+ std::valarray<T> v2 = v1.apply(f);
+ assert(v2.size() == N1);
+ }
+ {
+ T a1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+ T a2[] = {7, 9, 11, 13, 15, 17, 19, 21, 23, 25};
+ const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N1);
+ std::valarray<T> v2 = (v1+v1).apply(f);
+ assert(v2.size() == N1);
+ for (unsigned i = 0; i < N1; ++i)
+ assert(v2[i] == a2[i]);
+ }
+}
diff --git a/test/std/numerics/numarray/template.valarray/valarray.members/apply_value.pass.cpp b/test/std/numerics/numarray/template.valarray/valarray.members/apply_value.pass.cpp
new file mode 100644
index 000000000000..dc7a1a100a21
--- /dev/null
+++ b/test/std/numerics/numarray/template.valarray/valarray.members/apply_value.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray apply(value_type f(value_type)) const;
+
+#include <valarray>
+#include <cassert>
+
+typedef int T;
+
+T f(T t) {return t + 5;}
+
+int main()
+{
+ {
+ T a1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+ T a2[] = {6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+ const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N1);
+ std::valarray<T> v2 = v1.apply(f);
+ assert(v2.size() == N1);
+ for (unsigned i = 0; i < N1; ++i)
+ assert(v2[i] == a2[i]);
+ }
+ {
+ const unsigned N1 = 0;
+ std::valarray<T> v1;
+ std::valarray<T> v2 = v1.apply(f);
+ assert(v2.size() == N1);
+ }
+ {
+ T a1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+ T a2[] = {7, 9, 11, 13, 15, 17, 19, 21, 23, 25};
+ const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N1);
+ std::valarray<T> v2 = (v1+v1).apply(f);
+ assert(v2.size() == N1);
+ for (unsigned i = 0; i < N1; ++i)
+ assert(v2[i] == a2[i]);
+ }
+}
diff --git a/test/std/numerics/numarray/template.valarray/valarray.members/cshift.pass.cpp b/test/std/numerics/numarray/template.valarray/valarray.members/cshift.pass.cpp
new file mode 100644
index 000000000000..601a6df8d5e5
--- /dev/null
+++ b/test/std/numerics/numarray/template.valarray/valarray.members/cshift.pass.cpp
@@ -0,0 +1,127 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray cshift(int i) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+ T a2[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+ const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N1);
+ std::valarray<T> v2 = v1.cshift(0);
+ assert(v2.size() == N1);
+ for (unsigned i = 0; i < N1; ++i)
+ assert(v2[i] == a2[i]);
+ }
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+ T a2[] = {4, 5, 6, 7, 8, 9, 10, 1, 2, 3};
+ const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N1);
+ std::valarray<T> v2 = v1.cshift(3);
+ assert(v2.size() == N1);
+ for (unsigned i = 0; i < N1; ++i)
+ assert(v2[i] == a2[i]);
+ }
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+ T a2[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+ const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N1);
+ std::valarray<T> v2 = v1.cshift(10);
+ assert(v2.size() == N1);
+ for (unsigned i = 0; i < N1; ++i)
+ assert(v2[i] == a2[i]);
+ }
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+ T a2[] = {8, 9, 10, 1, 2, 3, 4, 5, 6, 7};
+ const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N1);
+ std::valarray<T> v2 = v1.cshift(17);
+ assert(v2.size() == N1);
+ for (unsigned i = 0; i < N1; ++i)
+ assert(v2[i] == a2[i]);
+ }
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+ T a2[] = {8, 9, 10, 1, 2, 3, 4, 5, 6, 7};
+ const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N1);
+ std::valarray<T> v2 = v1.cshift(-3);
+ assert(v2.size() == N1);
+ for (unsigned i = 0; i < N1; ++i)
+ assert(v2[i] == a2[i]);
+ }
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+ T a2[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+ const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N1);
+ std::valarray<T> v2 = v1.cshift(-10);
+ assert(v2.size() == N1);
+ for (unsigned i = 0; i < N1; ++i)
+ assert(v2[i] == a2[i]);
+ }
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+ T a2[] = {4, 5, 6, 7, 8, 9, 10, 1, 2, 3};
+ const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N1);
+ std::valarray<T> v2 = v1.cshift(-17);
+ assert(v2.size() == N1);
+ for (unsigned i = 0; i < N1; ++i)
+ assert(v2[i] == a2[i]);
+ }
+ {
+ typedef int T;
+ const unsigned N1 = 0;
+ std::valarray<T> v1;
+ std::valarray<T> v2 = v1.cshift(-17);
+ assert(v2.size() == N1);
+ }
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+ T a2[] = {8, 10, 12, 14, 16, 18, 20, 2, 4, 6};
+ const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N1);
+ std::valarray<T> v2 = (v1 + v1).cshift(3);
+ assert(v2.size() == N1);
+ for (unsigned i = 0; i < N1; ++i)
+ assert(v2[i] == a2[i]);
+ }
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+ T a2[] = {16, 18, 20, 2, 4, 6, 8, 10, 12, 14};
+ const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N1);
+ std::valarray<T> v2 = (v1 + v1).cshift(-3);
+ assert(v2.size() == N1);
+ for (unsigned i = 0; i < N1; ++i)
+ assert(v2[i] == a2[i]);
+ }
+}
diff --git a/test/std/numerics/numarray/template.valarray/valarray.members/max.pass.cpp b/test/std/numerics/numarray/template.valarray/valarray.members/max.pass.cpp
new file mode 100644
index 000000000000..697d4cd19ed6
--- /dev/null
+++ b/test/std/numerics/numarray/template.valarray/valarray.members/max.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// value_type max() const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef double T;
+ T a1[] = {1.5, 2.5, -3, 4, -5.5};
+ const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N1);
+ assert(v1.max() == 4.0);
+ }
+ {
+ typedef double T;
+ std::valarray<T> v1;
+ v1.max();
+ }
+ {
+ typedef double T;
+ T a1[] = {1.5, 2.5, -3, 4, -5.5};
+ const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N1);
+ assert((2*v1).max() == 8.0);
+ }
+}
diff --git a/test/std/numerics/numarray/template.valarray/valarray.members/min.pass.cpp b/test/std/numerics/numarray/template.valarray/valarray.members/min.pass.cpp
new file mode 100644
index 000000000000..dac59343715a
--- /dev/null
+++ b/test/std/numerics/numarray/template.valarray/valarray.members/min.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// value_type min() const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef double T;
+ T a1[] = {1.5, 2.5, -3, 4, 5.5};
+ const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N1);
+ assert(v1.min() == -3.0);
+ }
+ {
+ typedef double T;
+ std::valarray<T> v1;
+ v1.min();
+ }
+ {
+ typedef double T;
+ T a1[] = {1.5, 2.5, -3, 4, 5.5};
+ const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N1);
+ assert((2*v1).min() == -6.0);
+ }
+}
diff --git a/test/std/numerics/numarray/template.valarray/valarray.members/resize.pass.cpp b/test/std/numerics/numarray/template.valarray/valarray.members/resize.pass.cpp
new file mode 100644
index 000000000000..176d958aab92
--- /dev/null
+++ b/test/std/numerics/numarray/template.valarray/valarray.members/resize.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// void resize(size_t n, value_type x = value_type());
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5};
+ const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N1);
+ v1.resize(8);
+ assert(v1.size() == 8);
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v1[i] == 0);
+ v1.resize(0);
+ assert(v1.size() == 0);
+ v1.resize(80);
+ assert(v1.size() == 80);
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v1[i] == 0);
+ v1.resize(40);
+ assert(v1.size() == 40);
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v1[i] == 0);
+ }
+}
diff --git a/test/std/numerics/numarray/template.valarray/valarray.members/shift.pass.cpp b/test/std/numerics/numarray/template.valarray/valarray.members/shift.pass.cpp
new file mode 100644
index 000000000000..9a617a91a417
--- /dev/null
+++ b/test/std/numerics/numarray/template.valarray/valarray.members/shift.pass.cpp
@@ -0,0 +1,127 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray shift(int i) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+ T a2[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+ const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N1);
+ std::valarray<T> v2 = v1.shift(0);
+ assert(v2.size() == N1);
+ for (unsigned i = 0; i < N1; ++i)
+ assert(v2[i] == a2[i]);
+ }
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+ T a2[] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 0};
+ const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N1);
+ std::valarray<T> v2 = v1.shift(1);
+ assert(v2.size() == N1);
+ for (unsigned i = 0; i < N1; ++i)
+ assert(v2[i] == a2[i]);
+ }
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+ T a2[] = {10, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N1);
+ std::valarray<T> v2 = v1.shift(9);
+ assert(v2.size() == N1);
+ for (unsigned i = 0; i < N1; ++i)
+ assert(v2[i] == a2[i]);
+ }
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+ T a2[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N1);
+ std::valarray<T> v2 = v1.shift(90);
+ assert(v2.size() == N1);
+ for (unsigned i = 0; i < N1; ++i)
+ assert(v2[i] == a2[i]);
+ }
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+ T a2[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N1);
+ std::valarray<T> v2 = v1.shift(-1);
+ assert(v2.size() == N1);
+ for (unsigned i = 0; i < N1; ++i)
+ assert(v2[i] == a2[i]);
+ }
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+ T a2[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
+ const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N1);
+ std::valarray<T> v2 = v1.shift(-9);
+ assert(v2.size() == N1);
+ for (unsigned i = 0; i < N1; ++i)
+ assert(v2[i] == a2[i]);
+ }
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+ T a2[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N1);
+ std::valarray<T> v2 = v1.shift(-90);
+ assert(v2.size() == N1);
+ for (unsigned i = 0; i < N1; ++i)
+ assert(v2[i] == a2[i]);
+ }
+ {
+ typedef int T;
+ const unsigned N1 = 0;
+ std::valarray<T> v1;
+ std::valarray<T> v2 = v1.shift(-90);
+ assert(v2.size() == N1);
+ }
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+ T a2[] = {8, 10, 12, 14, 16, 18, 20, 0, 0, 0};
+ const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N1);
+ std::valarray<T> v2 = (v1 + v1).shift(3);
+ assert(v2.size() == N1);
+ for (unsigned i = 0; i < N1; ++i)
+ assert(v2[i] == a2[i]);
+ }
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+ T a2[] = {0, 0, 0, 2, 4, 6, 8, 10, 12, 14};
+ const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N1);
+ std::valarray<T> v2 = (v1 + v1).shift(-3);
+ assert(v2.size() == N1);
+ for (unsigned i = 0; i < N1; ++i)
+ assert(v2[i] == a2[i]);
+ }
+}
diff --git a/test/std/numerics/numarray/template.valarray/valarray.members/size.pass.cpp b/test/std/numerics/numarray/template.valarray/valarray.members/size.pass.cpp
new file mode 100644
index 000000000000..0aae5b8de7fa
--- /dev/null
+++ b/test/std/numerics/numarray/template.valarray/valarray.members/size.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// size_t size() const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5};
+ const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N1);
+ assert(v1.size() == N1);
+ }
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5};
+ const unsigned N1 = 0;
+ std::valarray<T> v1(a1, N1);
+ assert(v1.size() == N1);
+ }
+ {
+ typedef int T;
+ const unsigned N1 = 0;
+ std::valarray<T> v1;
+ assert(v1.size() == N1);
+ }
+}
diff --git a/test/std/numerics/numarray/template.valarray/valarray.members/sum.pass.cpp b/test/std/numerics/numarray/template.valarray/valarray.members/sum.pass.cpp
new file mode 100644
index 000000000000..189f03d25cf4
--- /dev/null
+++ b/test/std/numerics/numarray/template.valarray/valarray.members/sum.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// value_type sum() const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef double T;
+ T a1[] = {1.5, 2.5, 3, 4, 5.5};
+ const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N1);
+ assert(v1.sum() == 16.5);
+ }
+}
diff --git a/test/std/numerics/numarray/template.valarray/valarray.members/swap.pass.cpp b/test/std/numerics/numarray/template.valarray/valarray.members/swap.pass.cpp
new file mode 100644
index 000000000000..a90a80936376
--- /dev/null
+++ b/test/std/numerics/numarray/template.valarray/valarray.members/swap.pass.cpp
@@ -0,0 +1,89 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// void swap(valarray& v);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5};
+ T a2[] = {6, 7, 8, 9, 10, 11, 12};
+ const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+ const unsigned N2 = sizeof(a2)/sizeof(a2[0]);
+ std::valarray<T> v1(a1, N1);
+ std::valarray<T> v2(a2, N2);
+ std::valarray<T> v1_save = v1;
+ std::valarray<T> v2_save = v2;
+ v1.swap(v2);
+ assert(v1.size() == v2_save.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v1[i] == v2_save[i]);
+ assert(v2.size() == v1_save.size());
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == v1_save[i]);
+ }
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5};
+ const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+ const unsigned N2 = 0;
+ std::valarray<T> v1(a1, N1);
+ std::valarray<T> v2;
+ std::valarray<T> v1_save = v1;
+ std::valarray<T> v2_save = v2;
+ v1.swap(v2);
+ assert(v1.size() == v2_save.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v1[i] == v2_save[i]);
+ assert(v2.size() == v1_save.size());
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == v1_save[i]);
+ }
+ {
+ typedef int T;
+ T a2[] = {6, 7, 8, 9, 10, 11, 12};
+ const unsigned N1 = 0;
+ const unsigned N2 = sizeof(a2)/sizeof(a2[0]);
+ std::valarray<T> v1;
+ std::valarray<T> v2(a2, N2);
+ std::valarray<T> v1_save = v1;
+ std::valarray<T> v2_save = v2;
+ v1.swap(v2);
+ assert(v1.size() == v2_save.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v1[i] == v2_save[i]);
+ assert(v2.size() == v1_save.size());
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == v1_save[i]);
+ }
+ {
+ typedef int T;
+ const unsigned N1 = 0;
+ const unsigned N2 = 0;
+ std::valarray<T> v1;
+ std::valarray<T> v2;
+ std::valarray<T> v1_save = v1;
+ std::valarray<T> v2_save = v2;
+ v1.swap(v2);
+ assert(v1.size() == v2_save.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v1[i] == v2_save[i]);
+ assert(v2.size() == v1_save.size());
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == v1_save[i]);
+ }
+}
diff --git a/test/std/numerics/numarray/template.valarray/valarray.sub/gslice_const.pass.cpp b/test/std/numerics/numarray/template.valarray/valarray.sub/gslice_const.pass.cpp
new file mode 100644
index 000000000000..7bbd48c34538
--- /dev/null
+++ b/test/std/numerics/numarray/template.valarray/valarray.sub/gslice_const.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// gslice_array<value_type> operator[](const gslice& gs);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a1[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
+ 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+ 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+ 36, 37, 38, 39, 40};
+ int a2[] = { -0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11,
+ -12, -13, -14, -15, -16, -17, -18, -19, -20, -21, -22, -23};
+ std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+ std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+ std::size_t sz[] = {2, 4, 3};
+ std::size_t st[] = {19, 4, 1};
+ typedef std::valarray<std::size_t> sizes;
+ typedef std::valarray<std::size_t> strides;
+ v1[std::gslice(3, sizes(sz, sizeof(sz)/sizeof(sz[0])),
+ strides(st, sizeof(st)/sizeof(st[0])))] = v2;
+ assert(v1.size() == 41);
+ assert(v1[ 0] == 0);
+ assert(v1[ 1] == 1);
+ assert(v1[ 2] == 2);
+ assert(v1[ 3] == 0);
+ assert(v1[ 4] == -1);
+ assert(v1[ 5] == -2);
+ assert(v1[ 6] == 6);
+ assert(v1[ 7] == -3);
+ assert(v1[ 8] == -4);
+ assert(v1[ 9] == -5);
+ assert(v1[10] == 10);
+ assert(v1[11] == -6);
+ assert(v1[12] == -7);
+ assert(v1[13] == -8);
+ assert(v1[14] == 14);
+ assert(v1[15] == -9);
+ assert(v1[16] == -10);
+ assert(v1[17] == -11);
+ assert(v1[18] == 18);
+ assert(v1[19] == 19);
+ assert(v1[20] == 20);
+ assert(v1[21] == 21);
+ assert(v1[22] == -12);
+ assert(v1[23] == -13);
+ assert(v1[24] == -14);
+ assert(v1[25] == 25);
+ assert(v1[26] == -15);
+ assert(v1[27] == -16);
+ assert(v1[28] == -17);
+ assert(v1[29] == 29);
+ assert(v1[30] == -18);
+ assert(v1[31] == -19);
+ assert(v1[32] == -20);
+ assert(v1[33] == 33);
+ assert(v1[34] == -21);
+ assert(v1[35] == -22);
+ assert(v1[36] == -23);
+ assert(v1[37] == 37);
+ assert(v1[38] == 38);
+ assert(v1[39] == 39);
+ assert(v1[40] == 40);
+}
diff --git a/test/std/numerics/numarray/template.valarray/valarray.sub/gslice_non_const.pass.cpp b/test/std/numerics/numarray/template.valarray/valarray.sub/gslice_non_const.pass.cpp
new file mode 100644
index 000000000000..282dcf1f6db9
--- /dev/null
+++ b/test/std/numerics/numarray/template.valarray/valarray.sub/gslice_non_const.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray operator[](const gslice& gs) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
+ 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+ 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+ 36, 37, 38, 39, 40};
+ std::valarray<int> v1(a, sizeof(a)/sizeof(a[0]));
+ std::size_t sz[] = {2, 4, 3};
+ std::size_t st[] = {19, 4, 1};
+ typedef std::valarray<std::size_t> sizes;
+ typedef std::valarray<std::size_t> strides;
+ std::valarray<int> v(v1[std::gslice(3, sizes(sz, sizeof(sz)/sizeof(sz[0])),
+ strides(st, sizeof(st)/sizeof(st[0])))]);
+ assert(v.size() == 24);
+ assert(v[ 0] == 3);
+ assert(v[ 1] == 4);
+ assert(v[ 2] == 5);
+ assert(v[ 3] == 7);
+ assert(v[ 4] == 8);
+ assert(v[ 5] == 9);
+ assert(v[ 6] == 11);
+ assert(v[ 7] == 12);
+ assert(v[ 8] == 13);
+ assert(v[ 9] == 15);
+ assert(v[10] == 16);
+ assert(v[11] == 17);
+ assert(v[12] == 22);
+ assert(v[13] == 23);
+ assert(v[14] == 24);
+ assert(v[15] == 26);
+ assert(v[16] == 27);
+ assert(v[17] == 28);
+ assert(v[18] == 30);
+ assert(v[19] == 31);
+ assert(v[20] == 32);
+ assert(v[21] == 34);
+ assert(v[22] == 35);
+ assert(v[23] == 36);
+}
diff --git a/test/std/numerics/numarray/template.valarray/valarray.sub/indirect_array_const.pass.cpp b/test/std/numerics/numarray/template.valarray/valarray.sub/indirect_array_const.pass.cpp
new file mode 100644
index 000000000000..1bc4fb929007
--- /dev/null
+++ b/test/std/numerics/numarray/template.valarray/valarray.sub/indirect_array_const.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray operator[](const valarray<size_t>& vs) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
+ 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+ 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+ 36, 37, 38, 39, 40};
+ const std::size_t N1 = sizeof(a)/sizeof(a[0]);
+ std::size_t s[] = { 3, 4, 5, 7, 8, 9, 11, 12, 13, 15, 16, 17,
+ 22, 23, 24, 26, 27, 28, 30, 31, 32, 34, 35, 36};
+ const std::size_t S = sizeof(s)/sizeof(s[0]);
+ const std::valarray<int> v1(a, N1);
+ std::valarray<std::size_t> ia(s, S);
+ std::valarray<int> v = v1[ia];
+ assert(v.size() == 24);
+ assert(v[ 0] == 3);
+ assert(v[ 1] == 4);
+ assert(v[ 2] == 5);
+ assert(v[ 3] == 7);
+ assert(v[ 4] == 8);
+ assert(v[ 5] == 9);
+ assert(v[ 6] == 11);
+ assert(v[ 7] == 12);
+ assert(v[ 8] == 13);
+ assert(v[ 9] == 15);
+ assert(v[10] == 16);
+ assert(v[11] == 17);
+ assert(v[12] == 22);
+ assert(v[13] == 23);
+ assert(v[14] == 24);
+ assert(v[15] == 26);
+ assert(v[16] == 27);
+ assert(v[17] == 28);
+ assert(v[18] == 30);
+ assert(v[19] == 31);
+ assert(v[20] == 32);
+ assert(v[21] == 34);
+ assert(v[22] == 35);
+ assert(v[23] == 36);
+}
diff --git a/test/std/numerics/numarray/template.valarray/valarray.sub/indirect_array_non_const.pass.cpp b/test/std/numerics/numarray/template.valarray/valarray.sub/indirect_array_non_const.pass.cpp
new file mode 100644
index 000000000000..d0b7438172ee
--- /dev/null
+++ b/test/std/numerics/numarray/template.valarray/valarray.sub/indirect_array_non_const.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// indirect_array<value_type> operator[](const valarray<size_t>& vs);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
+ 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+ 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+ 36, 37, 38, 39, 40};
+ const std::size_t N1 = sizeof(a)/sizeof(a[0]);
+ std::size_t s[] = { 3, 4, 5, 7, 8, 9, 11, 12, 13, 15, 16, 17,
+ 22, 23, 24, 26, 27, 28, 30, 31, 32, 34, 35, 36};
+ const std::size_t S = sizeof(s)/sizeof(s[0]);
+ std::valarray<int> v1(a, N1);
+ std::valarray<std::size_t> ia(s, S);
+ std::valarray<int> v(24);
+ v = v1[ia];
+ assert(v.size() == 24);
+ assert(v[ 0] == 3);
+ assert(v[ 1] == 4);
+ assert(v[ 2] == 5);
+ assert(v[ 3] == 7);
+ assert(v[ 4] == 8);
+ assert(v[ 5] == 9);
+ assert(v[ 6] == 11);
+ assert(v[ 7] == 12);
+ assert(v[ 8] == 13);
+ assert(v[ 9] == 15);
+ assert(v[10] == 16);
+ assert(v[11] == 17);
+ assert(v[12] == 22);
+ assert(v[13] == 23);
+ assert(v[14] == 24);
+ assert(v[15] == 26);
+ assert(v[16] == 27);
+ assert(v[17] == 28);
+ assert(v[18] == 30);
+ assert(v[19] == 31);
+ assert(v[20] == 32);
+ assert(v[21] == 34);
+ assert(v[22] == 35);
+ assert(v[23] == 36);
+}
diff --git a/test/std/numerics/numarray/template.valarray/valarray.sub/slice_const.pass.cpp b/test/std/numerics/numarray/template.valarray/valarray.sub/slice_const.pass.cpp
new file mode 100644
index 000000000000..7f8191035e7a
--- /dev/null
+++ b/test/std/numerics/numarray/template.valarray/valarray.sub/slice_const.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray operator[](slice s) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+ std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+ std::valarray<int> v2 = v1[std::slice(1, 5, 3)];
+ assert(v2.size() == 5);
+ assert(v2[0] == 1);
+ assert(v2[1] == 4);
+ assert(v2[2] == 7);
+ assert(v2[3] == 10);
+ assert(v2[4] == 13);
+}
diff --git a/test/std/numerics/numarray/template.valarray/valarray.sub/slice_non_const.pass.cpp b/test/std/numerics/numarray/template.valarray/valarray.sub/slice_non_const.pass.cpp
new file mode 100644
index 000000000000..6bf9b430ec84
--- /dev/null
+++ b/test/std/numerics/numarray/template.valarray/valarray.sub/slice_non_const.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// slice_array<value_type> operator[](slice s);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+ int a2[] = {-1, -2, -3, -4, -5};
+ std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+ std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+ v1[std::slice(1, 5, 3)] = v2;
+ assert(v1.size() == 16);
+ assert(v1[ 0] == 0);
+ assert(v1[ 1] == -1);
+ assert(v1[ 2] == 2);
+ assert(v1[ 3] == 3);
+ assert(v1[ 4] == -2);
+ assert(v1[ 5] == 5);
+ assert(v1[ 6] == 6);
+ assert(v1[ 7] == -3);
+ assert(v1[ 8] == 8);
+ assert(v1[ 9] == 9);
+ assert(v1[10] == -4);
+ assert(v1[11] == 11);
+ assert(v1[12] == 12);
+ assert(v1[13] == -5);
+ assert(v1[14] == 14);
+ assert(v1[15] == 15);
+}
diff --git a/test/std/numerics/numarray/template.valarray/valarray.sub/valarray_bool_const.pass.cpp b/test/std/numerics/numarray/template.valarray/valarray.sub/valarray_bool_const.pass.cpp
new file mode 100644
index 000000000000..10bdd82e5536
--- /dev/null
+++ b/test/std/numerics/numarray/template.valarray/valarray.sub/valarray_bool_const.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray operator[](const valarray<bool>& vb) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+ const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+ bool b[N1] = {true, false, false, true, true, false,
+ false, true, false, false, false, true};
+ std::valarray<int> v1(a1, N1);
+ std::valarray<bool> vb(b, N1);
+ std::valarray<int> v2(v1[vb]);
+ assert(v2.size() == 5);
+ assert(v2[ 0] == 0);
+ assert(v2[ 1] == 3);
+ assert(v2[ 2] == 4);
+ assert(v2[ 3] == 7);
+ assert(v2[ 4] == 11);
+}
diff --git a/test/std/numerics/numarray/template.valarray/valarray.sub/valarray_bool_non_const.pass.cpp b/test/std/numerics/numarray/template.valarray/valarray.sub/valarray_bool_non_const.pass.cpp
new file mode 100644
index 000000000000..cecf9502293d
--- /dev/null
+++ b/test/std/numerics/numarray/template.valarray/valarray.sub/valarray_bool_non_const.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// mask_array<value_type> operator[](const valarray<bool>& vb);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+ const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+ bool b[N1] = {true, false, false, true, true, false,
+ false, true, false, false, false, true};
+ std::valarray<int> v1(a1, N1);
+ std::valarray<bool> vb(b, N1);
+ std::valarray<int> v2(5);
+ v2 = v1[vb];
+ assert(v2.size() == 5);
+ assert(v2[ 0] == 0);
+ assert(v2[ 1] == 3);
+ assert(v2[ 2] == 4);
+ assert(v2[ 3] == 7);
+ assert(v2[ 4] == 11);
+}
diff --git a/test/std/numerics/numarray/template.valarray/valarray.unary/bit_not.pass.cpp b/test/std/numerics/numarray/template.valarray/valarray.unary/bit_not.pass.cpp
new file mode 100644
index 000000000000..c1d240cb6798
--- /dev/null
+++ b/test/std/numerics/numarray/template.valarray/valarray.unary/bit_not.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray operator~() const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a[] = {1, 2, 3, 4, 5};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::valarray<T> v(a, N);
+ std::valarray<T> v2 = ~v;
+ assert(v2.size() == v.size());
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == ~v[i]);
+ }
+ {
+ typedef std::valarray<int> T;
+ T a[] = {T(1), T(2), T(3), T(4), T(5)};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::valarray<T> v(a, N);
+ std::valarray<T> v2 = ~v;
+ assert(v2.size() == v.size());
+ for (int i = 0; i < N; ++i)
+ {
+ assert(v2[i].size() == v[i].size());
+ for (int j = 0; j < v[i].size(); ++j)
+ assert(v2[i][j] == ~v[i][j]);
+ }
+ }
+ {
+ typedef int T;
+ T a[] = {1, 2, 3, 4, 5};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::valarray<T> v(a, N);
+ std::valarray<T> v2 = ~(v + v);
+ assert(v2.size() == v.size());
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == ~(2*v[i]));
+ }
+}
diff --git a/test/std/numerics/numarray/template.valarray/valarray.unary/negate.pass.cpp b/test/std/numerics/numarray/template.valarray/valarray.unary/negate.pass.cpp
new file mode 100644
index 000000000000..25674bb44d92
--- /dev/null
+++ b/test/std/numerics/numarray/template.valarray/valarray.unary/negate.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray operator-() const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a[] = {1, 2, 3, 4, 5};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::valarray<T> v(a, N);
+ std::valarray<T> v2 = -v;
+ assert(v2.size() == v.size());
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == -v[i]);
+ }
+ {
+ typedef double T;
+ T a[] = {1, 2.5, 3, 4.25, 5};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::valarray<T> v(a, N);
+ std::valarray<T> v2 = -v;
+ assert(v2.size() == v.size());
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == -v[i]);
+ }
+ {
+ typedef std::valarray<double> T;
+ T a[] = {T(1), T(2), T(3), T(4), T(5)};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::valarray<T> v(a, N);
+ std::valarray<T> v2 = -v;
+ assert(v2.size() == v.size());
+ for (int i = 0; i < N; ++i)
+ {
+ assert(v2[i].size() == v[i].size());
+ for (int j = 0; j < v[i].size(); ++j)
+ assert(v2[i][j] == -v[i][j]);
+ }
+ }
+ {
+ typedef double T;
+ T a[] = {1, 2.5, 3, 4.25, 5};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::valarray<T> v(a, N);
+ std::valarray<T> v2 = -(v + v);
+ assert(v2.size() == v.size());
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == -2*v[i]);
+ }
+}
diff --git a/test/std/numerics/numarray/template.valarray/valarray.unary/not.pass.cpp b/test/std/numerics/numarray/template.valarray/valarray.unary/not.pass.cpp
new file mode 100644
index 000000000000..0b792c68fb94
--- /dev/null
+++ b/test/std/numerics/numarray/template.valarray/valarray.unary/not.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray<bool> operator!() const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a[] = {1, 2, 3, 4, 5};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::valarray<T> v(a, N);
+ std::valarray<bool> v2 = !v;
+ assert(v2.size() == v.size());
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == !v[i]);
+ }
+ {
+ typedef double T;
+ T a[] = {1, 2.5, 3, 4.25, 5};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::valarray<T> v(a, N);
+ std::valarray<bool> v2 = !(v + v);
+ assert(v2.size() == v.size());
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == !2*v[i]);
+ }
+}
diff --git a/test/std/numerics/numarray/template.valarray/valarray.unary/plus.pass.cpp b/test/std/numerics/numarray/template.valarray/valarray.unary/plus.pass.cpp
new file mode 100644
index 000000000000..4bcdaf095ff5
--- /dev/null
+++ b/test/std/numerics/numarray/template.valarray/valarray.unary/plus.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray operator+() const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a[] = {1, 2, 3, 4, 5};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::valarray<T> v(a, N);
+ std::valarray<T> v2 = +v;
+ assert(v2.size() == v.size());
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == +v[i]);
+ }
+ {
+ typedef double T;
+ T a[] = {1, 2.5, 3, 4.25, 5};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::valarray<T> v(a, N);
+ std::valarray<T> v2 = +v;
+ assert(v2.size() == v.size());
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == +v[i]);
+ }
+ {
+ typedef std::valarray<double> T;
+ T a[] = {T(1), T(2), T(3), T(4), T(5)};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::valarray<T> v(a, N);
+ std::valarray<T> v2 = +v;
+ assert(v2.size() == v.size());
+ for (int i = 0; i < N; ++i)
+ {
+ assert(v2[i].size() == v[i].size());
+ for (int j = 0; j < v[i].size(); ++j)
+ assert(v2[i][j] == +v[i][j]);
+ }
+ }
+ {
+ typedef double T;
+ T a[] = {1, 2.5, 3, 4.25, 5};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::valarray<T> v(a, N);
+ std::valarray<T> v2 = +(v + v);
+ assert(v2.size() == v.size());
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == +2*v[i]);
+ }
+}
diff --git a/test/std/numerics/numarray/valarray.nonmembers/nothing_to_do.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/numerics/numarray/valarray.nonmembers/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/and_valarray_valarray.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/and_valarray_valarray.pass.cpp
new file mode 100644
index 000000000000..9214e61fb4da
--- /dev/null
+++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/and_valarray_valarray.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator&(const valarray<T>& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5};
+ T a2[] = {6, 7, 8, 9, 10};
+ T a3[] = {0, 2, 0, 0, 0};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2(a2, N);
+ std::valarray<T> v3 = v1 & v2;
+ assert(v1.size() == v2.size());
+ assert(v1.size() == v3.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v3[i] == a3[i]);
+ }
+}
diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/and_valarray_value.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/and_valarray_value.pass.cpp
new file mode 100644
index 000000000000..0976a88dcb81
--- /dev/null
+++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/and_valarray_value.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator&(const valarray<T>& x, const T& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = { 1, 2, 3, 4, 5};
+ T a2[] = { 1, 2, 3, 0, 1};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2 = v1 & 3;
+ assert(v1.size() == v2.size());
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == a2[i]);
+ }
+}
diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/and_value_valarray.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/and_value_valarray.pass.cpp
new file mode 100644
index 000000000000..e3dd180b2181
--- /dev/null
+++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/and_value_valarray.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator&(const T& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = { 1, 2, 3, 4, 5};
+ T a2[] = { 1, 2, 3, 0, 1};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2 = 3 & v1;
+ assert(v1.size() == v2.size());
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == a2[i]);
+ }
+}
diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/divide_valarray_valarray.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/divide_valarray_valarray.pass.cpp
new file mode 100644
index 000000000000..ff250afd2a1a
--- /dev/null
+++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/divide_valarray_valarray.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator/(const valarray<T>& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {6, 14, 24, 36, 50};
+ T a2[] = {6, 7, 8, 9, 10};
+ T a3[] = {1, 2, 3, 4, 5};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2(a2, N);
+ std::valarray<T> v3 = v1 / v2;
+ assert(v1.size() == v2.size());
+ assert(v1.size() == v3.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v3[i] == a3[i]);
+ }
+}
diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/divide_valarray_value.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/divide_valarray_value.pass.cpp
new file mode 100644
index 000000000000..ffbebab1e1ae
--- /dev/null
+++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/divide_valarray_value.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator/(const valarray<T>& x, const T& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {6, 12, 18, 24, 30};
+ T a2[] = {1, 2, 3, 4, 5};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2 = v1 / 6;
+ assert(v1.size() == v2.size());
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == a2[i]);
+ }
+}
diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/divide_value_valarray.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/divide_value_valarray.pass.cpp
new file mode 100644
index 000000000000..1a7f2f07c83a
--- /dev/null
+++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/divide_value_valarray.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator/(const T& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5};
+ T a2[] = {3, 1, 1, 0, 0};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2 = 3 / v1;
+ assert(v1.size() == v2.size());
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == a2[i]);
+ }
+}
diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/minus_valarray_valarray.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/minus_valarray_valarray.pass.cpp
new file mode 100644
index 000000000000..1f0354e8ac63
--- /dev/null
+++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/minus_valarray_valarray.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator-(const valarray<T>& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {7, 9, 11, 13, 15};
+ T a2[] = {6, 7, 8, 9, 10};
+ T a3[] = {1, 2, 3, 4, 5};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2(a2, N);
+ std::valarray<T> v3 = v1 - v2;
+ assert(v1.size() == v2.size());
+ assert(v1.size() == v3.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v3[i] == a3[i]);
+ }
+}
diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/minus_valarray_value.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/minus_valarray_value.pass.cpp
new file mode 100644
index 000000000000..382cab8eae6e
--- /dev/null
+++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/minus_valarray_value.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator-(const valarray<T>& x, const T& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = { 1, 2, 3, 4, 5};
+ T a2[] = {-2, -1, 0, 1, 2};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2 = v1 - 3;
+ assert(v1.size() == v2.size());
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == a2[i]);
+ }
+}
diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/minus_value_valarray.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/minus_value_valarray.pass.cpp
new file mode 100644
index 000000000000..7f00aba84884
--- /dev/null
+++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/minus_value_valarray.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator-(const T& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = { 1, 2, 3, 4, 5};
+ T a2[] = { 2, 1, 0, -1, -2};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2 = 3 - v1;
+ assert(v1.size() == v2.size());
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == a2[i]);
+ }
+}
diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/modulo_valarray_valarray.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/modulo_valarray_valarray.pass.cpp
new file mode 100644
index 000000000000..0a9cf3884c08
--- /dev/null
+++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/modulo_valarray_valarray.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator%(const valarray<T>& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {6, 7, 8, 9, 10};
+ T a2[] = {1, 2, 3, 4, 5};
+ T a3[] = {0, 1, 2, 1, 0};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2(a2, N);
+ std::valarray<T> v3 = v1 % v2;
+ assert(v1.size() == v2.size());
+ assert(v1.size() == v3.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v3[i] == a3[i]);
+ }
+}
diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/modulo_valarray_value.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/modulo_valarray_value.pass.cpp
new file mode 100644
index 000000000000..12c4c2453702
--- /dev/null
+++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/modulo_valarray_value.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator%(const valarray<T>& x, const T& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5};
+ T a2[] = {1, 2, 0, 1, 2};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2 = v1 % 3;
+ assert(v1.size() == v2.size());
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == a2[i]);
+ }
+}
diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/modulo_value_valarray.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/modulo_value_valarray.pass.cpp
new file mode 100644
index 000000000000..1d73887217e1
--- /dev/null
+++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/modulo_value_valarray.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator%(const T& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5};
+ T a2[] = {0, 1, 0, 3, 3};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2 = 3 % v1;
+ assert(v1.size() == v2.size());
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == a2[i]);
+ }
+}
diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/or_valarray_valarray.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/or_valarray_valarray.pass.cpp
new file mode 100644
index 000000000000..a23ea4f58b8c
--- /dev/null
+++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/or_valarray_valarray.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator|(const valarray<T>& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5};
+ T a2[] = {6, 7, 8, 9, 10};
+ T a3[] = {7, 7, 11, 13, 15};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2(a2, N);
+ std::valarray<T> v3 = v1 | v2;
+ assert(v1.size() == v2.size());
+ assert(v1.size() == v3.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v3[i] == a3[i]);
+ }
+}
diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/or_valarray_value.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/or_valarray_value.pass.cpp
new file mode 100644
index 000000000000..f617c27ae7fc
--- /dev/null
+++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/or_valarray_value.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator|(const valarray<T>& x, const T& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = { 1, 2, 3, 4, 5};
+ T a2[] = { 3, 3, 3, 7, 7};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2 = v1 | 3;
+ assert(v1.size() == v2.size());
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == a2[i]);
+ }
+}
diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/or_value_valarray.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/or_value_valarray.pass.cpp
new file mode 100644
index 000000000000..8903f438aaf1
--- /dev/null
+++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/or_value_valarray.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator|(const T& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = { 1, 2, 3, 4, 5};
+ T a2[] = { 3, 3, 3, 7, 7};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2 = 3 | v1;
+ assert(v1.size() == v2.size());
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == a2[i]);
+ }
+}
diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/plus_valarray_valarray.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/plus_valarray_valarray.pass.cpp
new file mode 100644
index 000000000000..1167772aff6a
--- /dev/null
+++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/plus_valarray_valarray.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator+(const valarray<T>& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5};
+ T a2[] = {6, 7, 8, 9, 10};
+ T a3[] = {7, 9, 11, 13, 15};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2(a2, N);
+ std::valarray<T> v3 = v1 + v2;
+ assert(v1.size() == v2.size());
+ assert(v1.size() == v3.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v3[i] == a3[i]);
+ }
+}
diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/plus_valarray_value.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/plus_valarray_value.pass.cpp
new file mode 100644
index 000000000000..b1b4e6931c0c
--- /dev/null
+++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/plus_valarray_value.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator+(const valarray<T>& x, const T& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5};
+ T a2[] = {4, 5, 6, 7, 8};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2 = v1 + 3;
+ assert(v1.size() == v2.size());
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == a2[i]);
+ }
+}
diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/plus_value_valarray.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/plus_value_valarray.pass.cpp
new file mode 100644
index 000000000000..df22853488e9
--- /dev/null
+++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/plus_value_valarray.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator+(const T& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5};
+ T a2[] = {4, 5, 6, 7, 8};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2 = 3 + v1;
+ assert(v1.size() == v2.size());
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == a2[i]);
+ }
+}
diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/shift_left_valarray_valarray.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/shift_left_valarray_valarray.pass.cpp
new file mode 100644
index 000000000000..42a7c419a3a3
--- /dev/null
+++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/shift_left_valarray_valarray.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator<<(const valarray<T>& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = { 1, 2, 3, 4, 5};
+ T a2[] = { 6, 7, 8, 9, 10};
+ T a3[] = {64, 256, 768, 2048, 5120};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2(a2, N);
+ std::valarray<T> v3 = v1 << v2;
+ assert(v1.size() == v2.size());
+ assert(v1.size() == v3.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v3[i] == a3[i]);
+ }
+}
diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/shift_left_valarray_value.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/shift_left_valarray_value.pass.cpp
new file mode 100644
index 000000000000..753ba38f357f
--- /dev/null
+++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/shift_left_valarray_value.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator<<(const valarray<T>& x, const T& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = { 1, 2, 3, 4, 5};
+ T a2[] = { 8, 16, 24, 32, 40};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2 = v1 << 3;
+ assert(v1.size() == v2.size());
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == a2[i]);
+ }
+}
diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/shift_left_value_valarray.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/shift_left_value_valarray.pass.cpp
new file mode 100644
index 000000000000..640ce1a47b32
--- /dev/null
+++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/shift_left_value_valarray.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator<<(const T& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = { 1, 2, 3, 4, 5};
+ T a2[] = { 6, 12, 24, 48, 96};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2 = 3 << v1;
+ assert(v1.size() == v2.size());
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == a2[i]);
+ }
+}
diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/shift_right_valarray_valarray.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/shift_right_valarray_valarray.pass.cpp
new file mode 100644
index 000000000000..8e6358d62060
--- /dev/null
+++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/shift_right_valarray_valarray.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator>>(const valarray<T>& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {64, 256, 768, 2048, 5120};
+ T a2[] = { 6, 7, 8, 9, 10};
+ T a3[] = { 1, 2, 3, 4, 5};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2(a2, N);
+ std::valarray<T> v3 = v1 >> v2;
+ assert(v1.size() == v2.size());
+ assert(v1.size() == v3.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v3[i] == a3[i]);
+ }
+}
diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/shift_right_valarray_value.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/shift_right_valarray_value.pass.cpp
new file mode 100644
index 000000000000..0c0ba54463e1
--- /dev/null
+++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/shift_right_valarray_value.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator>>(const valarray<T>& x, const T& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = { 8, 16, 24, 32, 40};
+ T a2[] = { 1, 2, 3, 4, 5};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2 = v1 >> 3;
+ assert(v1.size() == v2.size());
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == a2[i]);
+ }
+}
diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/shift_right_value_valarray.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/shift_right_value_valarray.pass.cpp
new file mode 100644
index 000000000000..ad5418af0267
--- /dev/null
+++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/shift_right_value_valarray.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator>>(const T& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = { 1, 2, 3, 4, 5};
+ T a2[] = {20, 10, 5, 2, 1};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2 = 40 >> v1;
+ assert(v1.size() == v2.size());
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == a2[i]);
+ }
+}
diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/times_valarray_valarray.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/times_valarray_valarray.pass.cpp
new file mode 100644
index 000000000000..69a3bffc3e77
--- /dev/null
+++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/times_valarray_valarray.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator*(const valarray<T>& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5};
+ T a2[] = {6, 7, 8, 9, 10};
+ T a3[] = {6, 14, 24, 36, 50};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2(a2, N);
+ std::valarray<T> v3 = v1 * v2;
+ assert(v1.size() == v2.size());
+ assert(v1.size() == v3.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v3[i] == a3[i]);
+ }
+}
diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/times_valarray_value.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/times_valarray_value.pass.cpp
new file mode 100644
index 000000000000..c4fb410de768
--- /dev/null
+++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/times_valarray_value.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator+(const valarray<T>& x, const T& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5};
+ T a2[] = {6, 12, 18, 24, 30};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2 = v1 * 6;
+ assert(v1.size() == v2.size());
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == a2[i]);
+ }
+}
diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/times_value_valarray.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/times_value_valarray.pass.cpp
new file mode 100644
index 000000000000..f5d877783ded
--- /dev/null
+++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/times_value_valarray.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator*(const T& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5};
+ T a2[] = {6, 12, 18, 24, 30};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2 = 6 * v1;
+ assert(v1.size() == v2.size());
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == a2[i]);
+ }
+}
diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/xor_valarray_valarray.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/xor_valarray_valarray.pass.cpp
new file mode 100644
index 000000000000..71b505b0cbe8
--- /dev/null
+++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/xor_valarray_valarray.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator^(const valarray<T>& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5};
+ T a2[] = {6, 7, 8, 9, 10};
+ T a3[] = {7, 5, 11, 13, 15};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2(a2, N);
+ std::valarray<T> v3 = v1 ^ v2;
+ assert(v1.size() == v2.size());
+ assert(v1.size() == v3.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v3[i] == a3[i]);
+ }
+}
diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/xor_valarray_value.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/xor_valarray_value.pass.cpp
new file mode 100644
index 000000000000..8dbe6843cd24
--- /dev/null
+++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/xor_valarray_value.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator^(const valarray<T>& x, const T& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = { 1, 2, 3, 4, 5};
+ T a2[] = { 2, 1, 0, 7, 6};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2 = v1 ^ 3;
+ assert(v1.size() == v2.size());
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == a2[i]);
+ }
+}
diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/xor_value_valarray.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/xor_value_valarray.pass.cpp
new file mode 100644
index 000000000000..face0635dfb4
--- /dev/null
+++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/xor_value_valarray.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator^(const T& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = { 1, 2, 3, 4, 5};
+ T a2[] = { 2, 1, 0, 7, 6};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2 = 3 ^ v1;
+ assert(v1.size() == v2.size());
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == a2[i]);
+ }
+}
diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/and_valarray_valarray.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/and_valarray_valarray.pass.cpp
new file mode 100644
index 000000000000..af2a1b3ed792
--- /dev/null
+++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/and_valarray_valarray.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<bool>
+// operator&&(const valarray<T>& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 0};
+ T a2[] = {6, 7, 0, 9, 10};
+ bool a3[] = {true, true, false, true, false};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2(a2, N);
+ std::valarray<bool> v3 = v1 && v2;
+ assert(v1.size() == v2.size());
+ assert(v1.size() == v3.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v3[i] == a3[i]);
+ }
+}
diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/and_valarray_value.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/and_valarray_value.pass.cpp
new file mode 100644
index 000000000000..f34fe9642574
--- /dev/null
+++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/and_valarray_value.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<bool>
+// operator&&(const valarray<T>& x, const T& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 0};
+ bool a3[] = {true, true, true, true, false};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<bool> v3 = v1 && 5;
+ assert(v1.size() == v3.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v3[i] == a3[i]);
+ }
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 0};
+ bool a3[] = {false, false, false, false, false};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<bool> v3 = v1 && 0;
+ assert(v1.size() == v3.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v3[i] == a3[i]);
+ }
+}
diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/and_value_valarray.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/and_value_valarray.pass.cpp
new file mode 100644
index 000000000000..c323d13ff42d
--- /dev/null
+++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/and_value_valarray.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<bool>
+// operator&&(const T& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a2[] = {1, 2, 3, 4, 0};
+ bool a3[] = {true, true, true, true, false};
+ const unsigned N = sizeof(a2)/sizeof(a2[0]);
+ std::valarray<T> v2(a2, N);
+ std::valarray<bool> v3 = 5 && v2;
+ assert(v2.size() == v3.size());
+ for (int i = 0; i < v3.size(); ++i)
+ assert(v3[i] == a3[i]);
+ }
+ {
+ typedef int T;
+ T a2[] = {1, 2, 3, 4, 0};
+ bool a3[] = {false, false, false, false, false};
+ const unsigned N = sizeof(a2)/sizeof(a2[0]);
+ std::valarray<T> v2(a2, N);
+ std::valarray<bool> v3 = 0 && v2;
+ assert(v2.size() == v3.size());
+ for (int i = 0; i < v3.size(); ++i)
+ assert(v3[i] == a3[i]);
+ }
+}
diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/equal_valarray_valarray.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/equal_valarray_valarray.pass.cpp
new file mode 100644
index 000000000000..6222e91595dd
--- /dev/null
+++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/equal_valarray_valarray.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<bool>
+// operator==(const valarray<T>& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 0, 4, 10};
+ T a2[] = {6, 7, 0, 9, 10};
+ bool a3[] = {false, false, true, false, true};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2(a2, N);
+ std::valarray<bool> v3 = v1 == v2;
+ assert(v1.size() == v2.size());
+ assert(v1.size() == v3.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v3[i] == a3[i]);
+ }
+}
diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/equal_valarray_value.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/equal_valarray_value.pass.cpp
new file mode 100644
index 000000000000..dca65055b2a0
--- /dev/null
+++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/equal_valarray_value.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<bool>
+// operator==(const valarray<T>& x, const T& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 0};
+ bool a3[] = {false, true, false, false, false};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<bool> v3 = v1 == 2;
+ assert(v1.size() == v3.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v3[i] == a3[i]);
+ }
+}
diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/equal_value_valarray.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/equal_value_valarray.pass.cpp
new file mode 100644
index 000000000000..532219e2e858
--- /dev/null
+++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/equal_value_valarray.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<bool>
+// operator==(const T& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a2[] = {1, 2, 3, 4, 0};
+ bool a3[] = {false, true, false, false, false};
+ const unsigned N = sizeof(a2)/sizeof(a2[0]);
+ std::valarray<T> v2(a2, N);
+ std::valarray<bool> v3 = 2 == v2;
+ assert(v2.size() == v3.size());
+ for (int i = 0; i < v3.size(); ++i)
+ assert(v3[i] == a3[i]);
+ }
+}
diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_equal_valarray_valarray.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_equal_valarray_valarray.pass.cpp
new file mode 100644
index 000000000000..75e62693baef
--- /dev/null
+++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_equal_valarray_valarray.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<bool>
+// operator>=(const valarray<T>& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 0, 4, 10};
+ T a2[] = {6, 7, 0, 2, 1};
+ bool a3[] = {false, false, true, true, true};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2(a2, N);
+ std::valarray<bool> v3 = v1 >= v2;
+ assert(v1.size() == v2.size());
+ assert(v1.size() == v3.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v3[i] == a3[i]);
+ }
+}
diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_equal_valarray_value.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_equal_valarray_value.pass.cpp
new file mode 100644
index 000000000000..020706dfa2ef
--- /dev/null
+++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_equal_valarray_value.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<bool>
+// operator>=(const valarray<T>& x, const T& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 0};
+ bool a3[] = {false, true, true, true, false};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<bool> v3 = v1 >= 2;
+ assert(v1.size() == v3.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v3[i] == a3[i]);
+ }
+}
diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_equal_value_valarray.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_equal_value_valarray.pass.cpp
new file mode 100644
index 000000000000..faf2003adb7f
--- /dev/null
+++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_equal_value_valarray.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<bool>
+// operator>=(const T& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a2[] = {1, 2, 3, 4, 0};
+ bool a3[] = {true, true, false, false, true};
+ const unsigned N = sizeof(a2)/sizeof(a2[0]);
+ std::valarray<T> v2(a2, N);
+ std::valarray<bool> v3 = 2 >= v2;
+ assert(v2.size() == v3.size());
+ for (int i = 0; i < v3.size(); ++i)
+ assert(v3[i] == a3[i]);
+ }
+}
diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_valarray_valarray.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_valarray_valarray.pass.cpp
new file mode 100644
index 000000000000..3276085f37dc
--- /dev/null
+++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_valarray_valarray.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<bool>
+// operator>(const valarray<T>& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 0, 4, 10};
+ T a2[] = {6, 7, 0, 2, 1};
+ bool a3[] = {false, false, false, true, true};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2(a2, N);
+ std::valarray<bool> v3 = v1 > v2;
+ assert(v1.size() == v2.size());
+ assert(v1.size() == v3.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v3[i] == a3[i]);
+ }
+}
diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_valarray_value.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_valarray_value.pass.cpp
new file mode 100644
index 000000000000..1ab774cdfb48
--- /dev/null
+++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_valarray_value.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<bool>
+// operator>(const valarray<T>& x, const T& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 0};
+ bool a3[] = {false, false, true, true, false};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<bool> v3 = v1 > 2;
+ assert(v1.size() == v3.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v3[i] == a3[i]);
+ }
+}
diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_value_valarray.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_value_valarray.pass.cpp
new file mode 100644
index 000000000000..c5012d6fc0e5
--- /dev/null
+++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_value_valarray.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<bool>
+// operator>(const T& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a2[] = {1, 2, 3, 4, 0};
+ bool a3[] = {true, false, false, false, true};
+ const unsigned N = sizeof(a2)/sizeof(a2[0]);
+ std::valarray<T> v2(a2, N);
+ std::valarray<bool> v3 = 2 > v2;
+ assert(v2.size() == v3.size());
+ for (int i = 0; i < v3.size(); ++i)
+ assert(v3[i] == a3[i]);
+ }
+}
diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/less_equal_valarray_valarray.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/less_equal_valarray_valarray.pass.cpp
new file mode 100644
index 000000000000..ceb6658833eb
--- /dev/null
+++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/less_equal_valarray_valarray.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<bool>
+// operator<=(const valarray<T>& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 0, 4, 10};
+ T a2[] = {6, 7, 0, 2, 1};
+ bool a3[] = {true, true, true, false, false};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2(a2, N);
+ std::valarray<bool> v3 = v1 <= v2;
+ assert(v1.size() == v2.size());
+ assert(v1.size() == v3.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v3[i] == a3[i]);
+ }
+}
diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/less_equal_valarray_value.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/less_equal_valarray_value.pass.cpp
new file mode 100644
index 000000000000..4a391a3f3799
--- /dev/null
+++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/less_equal_valarray_value.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<bool>
+// operator<=(const valarray<T>& x, const T& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 0};
+ bool a3[] = {true, true, false, false, true};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<bool> v3 = v1 <= 2;
+ assert(v1.size() == v3.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v3[i] == a3[i]);
+ }
+}
diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/less_equal_value_valarray.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/less_equal_value_valarray.pass.cpp
new file mode 100644
index 000000000000..cf34e18b92c0
--- /dev/null
+++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/less_equal_value_valarray.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<bool>
+// operator<=(const T& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a2[] = {1, 2, 3, 4, 0};
+ bool a3[] = {false, true, true, true, false};
+ const unsigned N = sizeof(a2)/sizeof(a2[0]);
+ std::valarray<T> v2(a2, N);
+ std::valarray<bool> v3 = 2 <= v2;
+ assert(v2.size() == v3.size());
+ for (int i = 0; i < v3.size(); ++i)
+ assert(v3[i] == a3[i]);
+ }
+}
diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/less_valarray_valarray.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/less_valarray_valarray.pass.cpp
new file mode 100644
index 000000000000..0fa99488b791
--- /dev/null
+++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/less_valarray_valarray.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<bool>
+// operator<(const valarray<T>& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 0, 4, 10};
+ T a2[] = {6, 7, 0, 2, 1};
+ bool a3[] = {true, true, false, false, false};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2(a2, N);
+ std::valarray<bool> v3 = v1 < v2;
+ assert(v1.size() == v2.size());
+ assert(v1.size() == v3.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v3[i] == a3[i]);
+ }
+}
diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/less_valarray_value.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/less_valarray_value.pass.cpp
new file mode 100644
index 000000000000..7a47c900a8f8
--- /dev/null
+++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/less_valarray_value.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<bool>
+// operator<(const valarray<T>& x, const T& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 0};
+ bool a3[] = {true, false, false, false, true};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<bool> v3 = v1 < 2;
+ assert(v1.size() == v3.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v3[i] == a3[i]);
+ }
+}
diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/less_value_valarray.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/less_value_valarray.pass.cpp
new file mode 100644
index 000000000000..4d6cbadcc8b5
--- /dev/null
+++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/less_value_valarray.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<bool>
+// operator<(const T& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a2[] = {1, 2, 3, 4, 0};
+ bool a3[] = {false, false, true, true, false};
+ const unsigned N = sizeof(a2)/sizeof(a2[0]);
+ std::valarray<T> v2(a2, N);
+ std::valarray<bool> v3 = 2 < v2;
+ assert(v2.size() == v3.size());
+ for (int i = 0; i < v3.size(); ++i)
+ assert(v3[i] == a3[i]);
+ }
+}
diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/not_equal_valarray_valarray.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/not_equal_valarray_valarray.pass.cpp
new file mode 100644
index 000000000000..c9675a9ce3e7
--- /dev/null
+++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/not_equal_valarray_valarray.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<bool>
+// operator!=(const valarray<T>& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 0, 4, 10};
+ T a2[] = {6, 7, 0, 9, 10};
+ bool a3[] = {true, true, false, true, false};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2(a2, N);
+ std::valarray<bool> v3 = v1 != v2;
+ assert(v1.size() == v2.size());
+ assert(v1.size() == v3.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v3[i] == a3[i]);
+ }
+}
diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/not_equal_valarray_value.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/not_equal_valarray_value.pass.cpp
new file mode 100644
index 000000000000..9daa7289b715
--- /dev/null
+++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/not_equal_valarray_value.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<bool>
+// operator!=(const valarray<T>& x, const T& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 0};
+ bool a3[] = {true, false, true, true, true};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<bool> v3 = v1 != 2;
+ assert(v1.size() == v3.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v3[i] == a3[i]);
+ }
+}
diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/not_equal_value_valarray.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/not_equal_value_valarray.pass.cpp
new file mode 100644
index 000000000000..37439aabcb28
--- /dev/null
+++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/not_equal_value_valarray.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<bool>
+// operator!=(const T& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a2[] = {1, 2, 3, 4, 0};
+ bool a3[] = {true, false, true, true, true};
+ const unsigned N = sizeof(a2)/sizeof(a2[0]);
+ std::valarray<T> v2(a2, N);
+ std::valarray<bool> v3 = 2 != v2;
+ assert(v2.size() == v3.size());
+ for (int i = 0; i < v3.size(); ++i)
+ assert(v3[i] == a3[i]);
+ }
+}
diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/or_valarray_valarray.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/or_valarray_valarray.pass.cpp
new file mode 100644
index 000000000000..9a2f84e8f7da
--- /dev/null
+++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/or_valarray_valarray.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<bool>
+// operator||(const valarray<T>& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 0, 4, 0};
+ T a2[] = {6, 7, 0, 9, 10};
+ bool a3[] = {true, true, false, true, true};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2(a2, N);
+ std::valarray<bool> v3 = v1 || v2;
+ assert(v1.size() == v2.size());
+ assert(v1.size() == v3.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v3[i] == a3[i]);
+ }
+}
diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/or_valarray_value.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/or_valarray_value.pass.cpp
new file mode 100644
index 000000000000..789df5badf04
--- /dev/null
+++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/or_valarray_value.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<bool>
+// operator||(const valarray<T>& x, const T& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 0};
+ bool a3[] = {true, true, true, true, true};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<bool> v3 = v1 || 5;
+ assert(v1.size() == v3.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v3[i] == a3[i]);
+ }
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 0};
+ bool a3[] = {true, true, true, true, false};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<bool> v3 = v1 || 0;
+ assert(v1.size() == v3.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v3[i] == a3[i]);
+ }
+}
diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/or_value_valarray.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/or_value_valarray.pass.cpp
new file mode 100644
index 000000000000..d66905960274
--- /dev/null
+++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/or_value_valarray.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<bool>
+// operator||(const T& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a2[] = {1, 2, 3, 4, 0};
+ bool a3[] = {true, true, true, true, true};
+ const unsigned N = sizeof(a2)/sizeof(a2[0]);
+ std::valarray<T> v2(a2, N);
+ std::valarray<bool> v3 = 5 || v2;
+ assert(v2.size() == v3.size());
+ for (int i = 0; i < v3.size(); ++i)
+ assert(v3[i] == a3[i]);
+ }
+ {
+ typedef int T;
+ T a2[] = {1, 2, 3, 4, 0};
+ bool a3[] = {true, true, true, true, false};
+ const unsigned N = sizeof(a2)/sizeof(a2[0]);
+ std::valarray<T> v2(a2, N);
+ std::valarray<bool> v3 = 0 || v2;
+ assert(v2.size() == v3.size());
+ for (int i = 0; i < v3.size(); ++i)
+ assert(v3[i] == a3[i]);
+ }
+}
diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.special/swap.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.special/swap.pass.cpp
new file mode 100644
index 000000000000..84f73945c401
--- /dev/null
+++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.special/swap.pass.cpp
@@ -0,0 +1,91 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// void
+// swap(valarray<T>& x, valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5};
+ T a2[] = {6, 7, 8, 9, 10, 11, 12};
+ const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+ const unsigned N2 = sizeof(a2)/sizeof(a2[0]);
+ std::valarray<T> v1(a1, N1);
+ std::valarray<T> v2(a2, N2);
+ std::valarray<T> v1_save = v1;
+ std::valarray<T> v2_save = v2;
+ swap(v1, v2);
+ assert(v1.size() == v2_save.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v1[i] == v2_save[i]);
+ assert(v2.size() == v1_save.size());
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == v1_save[i]);
+ }
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5};
+ const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+ const unsigned N2 = 0;
+ std::valarray<T> v1(a1, N1);
+ std::valarray<T> v2;
+ std::valarray<T> v1_save = v1;
+ std::valarray<T> v2_save = v2;
+ swap(v1, v2);
+ assert(v1.size() == v2_save.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v1[i] == v2_save[i]);
+ assert(v2.size() == v1_save.size());
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == v1_save[i]);
+ }
+ {
+ typedef int T;
+ T a2[] = {6, 7, 8, 9, 10, 11, 12};
+ const unsigned N1 = 0;
+ const unsigned N2 = sizeof(a2)/sizeof(a2[0]);
+ std::valarray<T> v1;
+ std::valarray<T> v2(a2, N2);
+ std::valarray<T> v1_save = v1;
+ std::valarray<T> v2_save = v2;
+ swap(v1, v2);
+ assert(v1.size() == v2_save.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v1[i] == v2_save[i]);
+ assert(v2.size() == v1_save.size());
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == v1_save[i]);
+ }
+ {
+ typedef int T;
+ const unsigned N1 = 0;
+ const unsigned N2 = 0;
+ std::valarray<T> v1;
+ std::valarray<T> v2;
+ std::valarray<T> v1_save = v1;
+ std::valarray<T> v2_save = v2;
+ swap(v1, v2);
+ assert(v1.size() == v2_save.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v1[i] == v2_save[i]);
+ assert(v2.size() == v1_save.size());
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == v1_save[i]);
+ }
+}
diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/abs_valarray.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/abs_valarray.pass.cpp
new file mode 100644
index 000000000000..7d112a61140e
--- /dev/null
+++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/abs_valarray.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<T>
+// abs(const valarray<T>& x);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef double T;
+ T a1[] = {1.5, -2.5, 3.4, -4.5, -5.0};
+ T a3[] = {1.5, 2.5, 3.4, 4.5, 5.0};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v3 = abs(v1);
+ assert(v3.size() == v1.size());
+ for (int i = 0; i < v3.size(); ++i)
+ assert(v3[i] == a3[i]);
+ }
+}
diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/acos_valarray.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/acos_valarray.pass.cpp
new file mode 100644
index 000000000000..ef2451d76457
--- /dev/null
+++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/acos_valarray.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<T>
+// acos(const valarray<T>& x);
+
+#include <valarray>
+#include <cassert>
+#include <sstream>
+
+bool is_about(double x, double y, int p)
+{
+ std::ostringstream o;
+ o.precision(p);
+ scientific(o);
+ o << x;
+ std::string a = o.str();
+ o.str("");
+ o << y;
+ return a == o.str();
+}
+
+int main()
+{
+ {
+ typedef double T;
+ T a1[] = {-.9, -.5, 0., .5, .75};
+ T a3[] = {2.6905658417935308e+00,
+ 2.0943951023931957e+00,
+ 1.5707963267948966e+00,
+ 1.0471975511965976e+00,
+ 7.2273424781341566e-01};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v3 = acos(v1);
+ assert(v3.size() == v1.size());
+ for (int i = 0; i < v3.size(); ++i)
+ assert(is_about(v3[i], a3[i], 10));
+ }
+}
diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/asin_valarray.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/asin_valarray.pass.cpp
new file mode 100644
index 000000000000..11c7c68d664a
--- /dev/null
+++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/asin_valarray.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<T>
+// asin(const valarray<T>& x);
+
+#include <valarray>
+#include <cassert>
+#include <sstream>
+
+bool is_about(double x, double y, int p)
+{
+ std::ostringstream o;
+ o.precision(p);
+ scientific(o);
+ o << x;
+ std::string a = o.str();
+ o.str("");
+ o << y;
+ return a == o.str();
+}
+
+int main()
+{
+ {
+ typedef double T;
+ T a1[] = {-.9, -.5, 0., .5, .75};
+ T a3[] = {-1.1197695149986342e+00,
+ -5.2359877559829882e-01,
+ 0.0000000000000000e+00,
+ 5.2359877559829882e-01,
+ 8.4806207898148100e-01};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v3 = asin(v1);
+ assert(v3.size() == v1.size());
+ for (int i = 0; i < v3.size(); ++i)
+ assert(is_about(v3[i], a3[i], 10));
+ }
+}
diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/atan2_valarray_valarray.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/atan2_valarray_valarray.pass.cpp
new file mode 100644
index 000000000000..b860413805b8
--- /dev/null
+++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/atan2_valarray_valarray.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<T>
+// atan2(const valarray<T>& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+#include <sstream>
+
+bool is_about(double x, double y, int p)
+{
+ std::ostringstream o;
+ o.precision(p);
+ scientific(o);
+ o << x;
+ std::string a = o.str();
+ o.str("");
+ o << y;
+ return a == o.str();
+}
+
+int main()
+{
+ {
+ typedef double T;
+ T a1[] = {-.9, -.5, 0., .5, .75};
+ T a2[] = {-.8, .25, 0.375, -.5, .75};
+ T a3[] = {-2.2974386674766221e+00,
+ -1.1071487177940904e+00,
+ 0.0000000000000000e+00,
+ 2.3561944901923448e+00,
+ 7.8539816339744828e-01};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2(a2, N);
+ std::valarray<T> v3 = atan2(v1, v2);
+ assert(v3.size() == v1.size());
+ for (int i = 0; i < v3.size(); ++i)
+ assert(is_about(v3[i], a3[i], 10));
+ }
+}
diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/atan2_valarray_value.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/atan2_valarray_value.pass.cpp
new file mode 100644
index 000000000000..94ffebf79d8d
--- /dev/null
+++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/atan2_valarray_value.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<T>
+// atan2(const valarray<T>& x, const T& y);
+
+#include <valarray>
+#include <cassert>
+#include <sstream>
+
+bool is_about(double x, double y, int p)
+{
+ std::ostringstream o;
+ o.precision(p);
+ scientific(o);
+ o << x;
+ std::string a = o.str();
+ o.str("");
+ o << y;
+ return a == o.str();
+}
+
+int main()
+{
+ {
+ typedef double T;
+ T a1[] = {-.9, -.5, 0., .5, .75};
+ T a3[] = {-8.7605805059819342e-01,
+ -5.8800260354756750e-01,
+ 0.0000000000000000e+00,
+ 5.8800260354756750e-01,
+ 7.8539816339744828e-01};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v3 = atan2(v1, .75);
+ assert(v3.size() == v1.size());
+ for (int i = 0; i < v3.size(); ++i)
+ assert(is_about(v3[i], a3[i], 10));
+ }
+}
diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/atan2_value_valarray.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/atan2_value_valarray.pass.cpp
new file mode 100644
index 000000000000..360e70ee7cdd
--- /dev/null
+++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/atan2_value_valarray.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<T>
+// atan2(const T& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+#include <sstream>
+
+bool is_about(double x, double y, int p)
+{
+ std::ostringstream o;
+ o.precision(p);
+ scientific(o);
+ o << x;
+ std::string a = o.str();
+ o.str("");
+ o << y;
+ return a == o.str();
+}
+
+int main()
+{
+ {
+ typedef double T;
+ T a1[] = {-.9, -.5, 0., .5, .75};
+ T a3[] = {2.4468543773930902e+00,
+ 2.1587989303424640e+00,
+ 1.5707963267948966e+00,
+ 9.8279372324732905e-01,
+ 7.8539816339744828e-01};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v3 = atan2(.75, v1);
+ assert(v3.size() == v1.size());
+ for (int i = 0; i < v3.size(); ++i)
+ assert(is_about(v3[i], a3[i], 10));
+ }
+}
diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/atan_valarray.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/atan_valarray.pass.cpp
new file mode 100644
index 000000000000..e66118b1d6de
--- /dev/null
+++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/atan_valarray.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<T>
+// atan(const valarray<T>& x);
+
+#include <valarray>
+#include <cassert>
+#include <sstream>
+
+bool is_about(double x, double y, int p)
+{
+ std::ostringstream o;
+ o.precision(p);
+ scientific(o);
+ o << x;
+ std::string a = o.str();
+ o.str("");
+ o << y;
+ return a == o.str();
+}
+
+int main()
+{
+ {
+ typedef double T;
+ T a1[] = {-.9, -.5, 0., .5, .75};
+ T a3[] = {-7.3281510178650666e-01,
+ -4.6364760900080615e-01,
+ 0.0000000000000000e+00,
+ 4.6364760900080615e-01,
+ 6.4350110879328437e-01};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v3 = atan(v1);
+ assert(v3.size() == v1.size());
+ for (int i = 0; i < v3.size(); ++i)
+ assert(is_about(v3[i], a3[i], 10));
+ }
+}
diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/cos_valarray.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/cos_valarray.pass.cpp
new file mode 100644
index 000000000000..baeb0d067008
--- /dev/null
+++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/cos_valarray.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<T>
+// cos(const valarray<T>& x);
+
+#include <valarray>
+#include <cassert>
+#include <sstream>
+
+bool is_about(double x, double y, int p)
+{
+ std::ostringstream o;
+ o.precision(p);
+ scientific(o);
+ o << x;
+ std::string a = o.str();
+ o.str("");
+ o << y;
+ return a == o.str();
+}
+
+int main()
+{
+ {
+ typedef double T;
+ T a1[] = {-.9, -.5, 0., .5, .75};
+ T a3[] = {6.2160996827066450e-01,
+ 8.7758256189037276e-01,
+ 1.0000000000000000e+00,
+ 8.7758256189037276e-01,
+ 7.3168886887382090e-01};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v3 = cos(v1);
+ assert(v3.size() == v1.size());
+ for (int i = 0; i < v3.size(); ++i)
+ assert(is_about(v3[i], a3[i], 10));
+ }
+}
diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/cosh_valarray.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/cosh_valarray.pass.cpp
new file mode 100644
index 000000000000..02a547a54404
--- /dev/null
+++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/cosh_valarray.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<T>
+// cosh(const valarray<T>& x);
+
+#include <valarray>
+#include <cassert>
+#include <sstream>
+
+bool is_about(double x, double y, int p)
+{
+ std::ostringstream o;
+ o.precision(p);
+ scientific(o);
+ o << x;
+ std::string a = o.str();
+ o.str("");
+ o << y;
+ return a == o.str();
+}
+
+int main()
+{
+ {
+ typedef double T;
+ T a1[] = {-.9, -.5, 0., .5, .75};
+ T a3[] = {1.4330863854487743e+00,
+ 1.1276259652063807e+00,
+ 1.0000000000000000e+00,
+ 1.1276259652063807e+00,
+ 1.2946832846768448e+00};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v3 = cosh(v1);
+ assert(v3.size() == v1.size());
+ for (int i = 0; i < v3.size(); ++i)
+ assert(is_about(v3[i], a3[i], 10));
+ }
+}
diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/exp_valarray.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/exp_valarray.pass.cpp
new file mode 100644
index 000000000000..dce9c5546f78
--- /dev/null
+++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/exp_valarray.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<T>
+// exp(const valarray<T>& x);
+
+#include <valarray>
+#include <cassert>
+#include <sstream>
+
+bool is_about(double x, double y, int p)
+{
+ std::ostringstream o;
+ o.precision(p);
+ scientific(o);
+ o << x;
+ std::string a = o.str();
+ o.str("");
+ o << y;
+ return a == o.str();
+}
+
+int main()
+{
+ {
+ typedef double T;
+ T a1[] = {-.9, -.5, 0., .5, .75};
+ T a3[] = {4.0656965974059911e-01,
+ 6.0653065971263342e-01,
+ 1.0000000000000000e+00,
+ 1.6487212707001282e+00,
+ 2.1170000166126748e+00};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v3 = exp(v1);
+ assert(v3.size() == v1.size());
+ for (int i = 0; i < v3.size(); ++i)
+ assert(is_about(v3[i], a3[i], 10));
+ }
+}
diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/log10_valarray.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/log10_valarray.pass.cpp
new file mode 100644
index 000000000000..2b9908198476
--- /dev/null
+++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/log10_valarray.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<T>
+// log10(const valarray<T>& x);
+
+#include <valarray>
+#include <cassert>
+#include <sstream>
+
+bool is_about(double x, double y, int p)
+{
+ std::ostringstream o;
+ o.precision(p);
+ scientific(o);
+ o << x;
+ std::string a = o.str();
+ o.str("");
+ o << y;
+ return a == o.str();
+}
+
+int main()
+{
+ {
+ typedef double T;
+ T a1[] = {.5, .75, 1, 3, 7};
+ T a3[] = {-3.0102999566398120e-01,
+ -1.2493873660829995e-01,
+ 0.0000000000000000e+00,
+ 4.7712125471966244e-01,
+ 8.4509804001425681e-01};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v3 = log10(v1);
+ assert(v3.size() == v1.size());
+ for (int i = 0; i < v3.size(); ++i)
+ assert(is_about(v3[i], a3[i], 10));
+ }
+}
diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/log_valarray.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/log_valarray.pass.cpp
new file mode 100644
index 000000000000..2c51cd6ed405
--- /dev/null
+++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/log_valarray.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<T>
+// log(const valarray<T>& x);
+
+#include <valarray>
+#include <cassert>
+#include <sstream>
+
+bool is_about(double x, double y, int p)
+{
+ std::ostringstream o;
+ o.precision(p);
+ scientific(o);
+ o << x;
+ std::string a = o.str();
+ o.str("");
+ o << y;
+ return a == o.str();
+}
+
+int main()
+{
+ {
+ typedef double T;
+ T a1[] = {.5, .75, 1, 3, 7};
+ T a3[] = {-6.9314718055994529e-01,
+ -2.8768207245178090e-01,
+ 0.0000000000000000e+00,
+ 1.0986122886681098e+00,
+ 1.9459101490553132e+00};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v3 = log(v1);
+ assert(v3.size() == v1.size());
+ for (int i = 0; i < v3.size(); ++i)
+ assert(is_about(v3[i], a3[i], 10));
+ }
+}
diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/pow_valarray_valarray.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/pow_valarray_valarray.pass.cpp
new file mode 100644
index 000000000000..37ca74292aad
--- /dev/null
+++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/pow_valarray_valarray.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<T>
+// pow(const valarray<T>& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+#include <sstream>
+
+bool is_about(double x, double y, int p)
+{
+ std::ostringstream o;
+ o.precision(p);
+ scientific(o);
+ o << x;
+ std::string a = o.str();
+ o.str("");
+ o << y;
+ return a == o.str();
+}
+
+int main()
+{
+ {
+ typedef double T;
+ T a1[] = {.9, .5, 0., .5, .75};
+ T a2[] = {-.8, .25, 0.375, -.5, .75};
+ T a3[] = {1.0879426248455297e+00,
+ 8.4089641525371450e-01,
+ 0.0000000000000000e+00,
+ 1.4142135623730949e+00,
+ 8.0592744886765644e-01};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2(a2, N);
+ std::valarray<T> v3 = pow(v1, v2);
+ assert(v3.size() == v1.size());
+ for (int i = 0; i < v3.size(); ++i)
+ assert(is_about(v3[i], a3[i], 10));
+ }
+}
diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/pow_valarray_value.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/pow_valarray_value.pass.cpp
new file mode 100644
index 000000000000..290ddc6f63da
--- /dev/null
+++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/pow_valarray_value.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<T>
+// pow(const valarray<T>& x, const T& y);
+
+#include <valarray>
+#include <cassert>
+#include <sstream>
+
+bool is_about(double x, double y, int p)
+{
+ std::ostringstream o;
+ o.precision(p);
+ scientific(o);
+ o << x;
+ std::string a = o.str();
+ o.str("");
+ o << y;
+ return a == o.str();
+}
+
+int main()
+{
+ {
+ typedef double T;
+ T a1[] = {.9, .5, 0., .5, .75};
+ T a3[] = {8.1000000000000005e-01,
+ 2.5000000000000000e-01,
+ 0.0000000000000000e+00,
+ 2.5000000000000000e-01,
+ 5.6250000000000000e-01};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v3 = pow(v1, 2.0);
+ assert(v3.size() == v1.size());
+ for (int i = 0; i < v3.size(); ++i)
+ assert(is_about(v3[i], a3[i], 10));
+ }
+}
diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/pow_value_valarray.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/pow_value_valarray.pass.cpp
new file mode 100644
index 000000000000..f52990b4be7d
--- /dev/null
+++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/pow_value_valarray.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<T>
+// pow(const T& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+#include <sstream>
+
+bool is_about(double x, double y, int p)
+{
+ std::ostringstream o;
+ o.precision(p);
+ scientific(o);
+ o << x;
+ std::string a = o.str();
+ o.str("");
+ o << y;
+ return a == o.str();
+}
+
+int main()
+{
+ {
+ typedef double T;
+ T a1[] = {.9, .5, 0., .5, .75};
+ T a3[] = {1.8660659830736148e+00,
+ 1.4142135623730951e+00,
+ 1.0000000000000000e+00,
+ 1.4142135623730951e+00,
+ 1.6817928305074290e+00};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v3 = pow(2.0, v1);
+ assert(v3.size() == v1.size());
+ for (int i = 0; i < v3.size(); ++i)
+ assert(is_about(v3[i], a3[i], 10));
+ }
+}
diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/sin_valarray.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/sin_valarray.pass.cpp
new file mode 100644
index 000000000000..f05bd058fd72
--- /dev/null
+++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/sin_valarray.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<T>
+// sin(const valarray<T>& x);
+
+#include <valarray>
+#include <cassert>
+#include <sstream>
+
+bool is_about(double x, double y, int p)
+{
+ std::ostringstream o;
+ o.precision(p);
+ scientific(o);
+ o << x;
+ std::string a = o.str();
+ o.str("");
+ o << y;
+ return a == o.str();
+}
+
+int main()
+{
+ {
+ typedef double T;
+ T a1[] = {-.9, -.5, 0., .5, .75};
+ T a3[] = {-7.8332690962748330e-01,
+ -4.7942553860420301e-01,
+ 0.0000000000000000e+00,
+ 4.7942553860420301e-01,
+ 6.8163876002333423e-01};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v3 = sin(v1);
+ assert(v3.size() == v1.size());
+ for (int i = 0; i < v3.size(); ++i)
+ assert(is_about(v3[i], a3[i], 10));
+ }
+}
diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/sinh_valarray.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/sinh_valarray.pass.cpp
new file mode 100644
index 000000000000..73dca833bf24
--- /dev/null
+++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/sinh_valarray.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<T>
+// sinh(const valarray<T>& x);
+
+#include <valarray>
+#include <cassert>
+#include <sstream>
+
+bool is_about(double x, double y, int p)
+{
+ std::ostringstream o;
+ o.precision(p);
+ scientific(o);
+ o << x;
+ std::string a = o.str();
+ o.str("");
+ o << y;
+ return a == o.str();
+}
+
+int main()
+{
+ {
+ typedef double T;
+ T a1[] = {-.9, -.5, 0., .5, .75};
+ T a3[] = {-1.0265167257081753e+00,
+ -5.2109530549374738e-01,
+ 0.0000000000000000e+00,
+ 5.2109530549374738e-01,
+ 8.2231673193582999e-01};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v3 = sinh(v1);
+ assert(v3.size() == v1.size());
+ for (int i = 0; i < v3.size(); ++i)
+ assert(is_about(v3[i], a3[i], 10));
+ }
+}
diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/sqrt_valarray.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/sqrt_valarray.pass.cpp
new file mode 100644
index 000000000000..193dcd21fd1e
--- /dev/null
+++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/sqrt_valarray.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<T>
+// sqrt(const valarray<T>& x);
+
+#include <valarray>
+#include <cassert>
+#include <sstream>
+
+bool is_about(double x, double y, int p)
+{
+ std::ostringstream o;
+ o.precision(p);
+ scientific(o);
+ o << x;
+ std::string a = o.str();
+ o.str("");
+ o << y;
+ return a == o.str();
+}
+
+int main()
+{
+ {
+ typedef double T;
+ T a1[] = {.5, .75, 1, 3, 7};
+ T a3[] = {7.0710678118654757e-01,
+ 8.6602540378443860e-01,
+ 1.0000000000000000e+00,
+ 1.7320508075688772e+00,
+ 2.6457513110645907e+00};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v3 = sqrt(v1);
+ assert(v3.size() == v1.size());
+ for (int i = 0; i < v3.size(); ++i)
+ assert(is_about(v3[i], a3[i], 10));
+ }
+}
diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/tan_valarray.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/tan_valarray.pass.cpp
new file mode 100644
index 000000000000..021dbc4d7754
--- /dev/null
+++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/tan_valarray.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<T>
+// tan(const valarray<T>& x);
+
+#include <valarray>
+#include <cassert>
+#include <sstream>
+
+bool is_about(double x, double y, int p)
+{
+ std::ostringstream o;
+ o.precision(p);
+ scientific(o);
+ o << x;
+ std::string a = o.str();
+ o.str("");
+ o << y;
+ return a == o.str();
+}
+
+int main()
+{
+ {
+ typedef double T;
+ T a1[] = {-.9, -.5, 0., .5, .75};
+ T a3[] = {-1.2601582175503390e+00,
+ -5.4630248984379048e-01,
+ 0.0000000000000000e+00,
+ 5.4630248984379048e-01,
+ 9.3159645994407259e-01};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v3 = tan(v1);
+ assert(v3.size() == v1.size());
+ for (int i = 0; i < v3.size(); ++i)
+ assert(is_about(v3[i], a3[i], 10));
+ }
+}
diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/tanh_valarray.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/tanh_valarray.pass.cpp
new file mode 100644
index 000000000000..4cc58c321af1
--- /dev/null
+++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/tanh_valarray.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<T>
+// tanh(const valarray<T>& x);
+
+#include <valarray>
+#include <cassert>
+#include <sstream>
+
+bool is_about(double x, double y, int p)
+{
+ std::ostringstream o;
+ o.precision(p);
+ scientific(o);
+ o << x;
+ std::string a = o.str();
+ o.str("");
+ o << y;
+ return a == o.str();
+}
+
+int main()
+{
+ {
+ typedef double T;
+ T a1[] = {-.9, -.5, 0., .5, .75};
+ T a3[] = {-7.1629787019902447e-01,
+ -4.6211715726000974e-01,
+ 0.0000000000000000e+00,
+ 4.6211715726000974e-01,
+ 6.3514895238728730e-01};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v3 = tanh(v1);
+ assert(v3.size() == v1.size());
+ for (int i = 0; i < v3.size(); ++i)
+ assert(is_about(v3[i], a3[i], 10));
+ }
+}
diff --git a/test/std/numerics/numarray/valarray.range/begin_const.pass.cpp b/test/std/numerics/numarray/valarray.range/begin_const.pass.cpp
new file mode 100644
index 000000000000..873c4847e8d2
--- /dev/null
+++ b/test/std/numerics/numarray/valarray.range/begin_const.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template <class T>
+// unspecified1
+// begin(const valarray<T>& v);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a[] = {1, 2, 3, 4, 5};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ const std::valarray<T> v(a, N);
+ assert(v[0] == 1);
+ }
+}
diff --git a/test/std/numerics/numarray/valarray.range/begin_non_const.pass.cpp b/test/std/numerics/numarray/valarray.range/begin_non_const.pass.cpp
new file mode 100644
index 000000000000..0a39d009fd9b
--- /dev/null
+++ b/test/std/numerics/numarray/valarray.range/begin_non_const.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template <class T>
+// unspecified1
+// begin(valarray<T>& v);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a[] = {1, 2, 3, 4, 5};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::valarray<T> v(a, N);
+ *begin(v) = 10;
+ assert(v[0] == 10);
+ }
+}
diff --git a/test/std/numerics/numarray/valarray.range/end_const.pass.cpp b/test/std/numerics/numarray/valarray.range/end_const.pass.cpp
new file mode 100644
index 000000000000..7363508943bb
--- /dev/null
+++ b/test/std/numerics/numarray/valarray.range/end_const.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template <class T>
+// unspecified1
+// end(const valarray<T>& v);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a[] = {1, 2, 3, 4, 5};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ const std::valarray<T> v(a, N);
+ assert(v[v.size()-1] == 5);
+ assert(end(v) - begin(v) == v.size());
+ }
+}
diff --git a/test/std/numerics/numarray/valarray.range/end_non_const.pass.cpp b/test/std/numerics/numarray/valarray.range/end_non_const.pass.cpp
new file mode 100644
index 000000000000..f095f5cc35ee
--- /dev/null
+++ b/test/std/numerics/numarray/valarray.range/end_non_const.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template <class T>
+// unspecified1
+// end(valarray<T>& v);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a[] = {1, 2, 3, 4, 5};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::valarray<T> v(a, N);
+ *(end(v) - 1) = 10;
+ assert(v[v.size()-1] == 10);
+ assert(end(v) - begin(v) == v.size());
+ }
+}
diff --git a/test/std/numerics/numarray/valarray.syn/nothing_to_do.pass.cpp b/test/std/numerics/numarray/valarray.syn/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/numerics/numarray/valarray.syn/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/numerics/numarray/version.pass.cpp b/test/std/numerics/numarray/version.pass.cpp
new file mode 100644
index 000000000000..85457d4329ec
--- /dev/null
+++ b/test/std/numerics/numarray/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+#include <valarray>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/numerics/numeric.ops/accumulate/accumulate.pass.cpp b/test/std/numerics/numeric.ops/accumulate/accumulate.pass.cpp
new file mode 100644
index 000000000000..aae97ef41175
--- /dev/null
+++ b/test/std/numerics/numeric.ops/accumulate/accumulate.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <numeric>
+
+// template <InputIterator Iter, MoveConstructible T>
+// requires HasPlus<T, Iter::reference>
+// && HasAssign<T, HasPlus<T, Iter::reference>::result_type>
+// T
+// accumulate(Iter first, Iter last, T init);
+
+#include <numeric>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter, class T>
+void
+test(Iter first, Iter last, T init, T x)
+{
+ assert(std::accumulate(first, last, init) == x);
+}
+
+template <class Iter>
+void
+test()
+{
+ int ia[] = {1, 2, 3, 4, 5, 6};
+ unsigned sa = sizeof(ia) / sizeof(ia[0]);
+ test(Iter(ia), Iter(ia), 0, 0);
+ test(Iter(ia), Iter(ia), 10, 10);
+ test(Iter(ia), Iter(ia+1), 0, 1);
+ test(Iter(ia), Iter(ia+1), 10, 11);
+ test(Iter(ia), Iter(ia+2), 0, 3);
+ test(Iter(ia), Iter(ia+2), 10, 13);
+ test(Iter(ia), Iter(ia+sa), 0, 21);
+ test(Iter(ia), Iter(ia+sa), 10, 31);
+}
+
+int main()
+{
+ test<input_iterator<const int*> >();
+ test<forward_iterator<const int*> >();
+ test<bidirectional_iterator<const int*> >();
+ test<random_access_iterator<const int*> >();
+ test<const int*>();
+}
diff --git a/test/std/numerics/numeric.ops/accumulate/accumulate_op.pass.cpp b/test/std/numerics/numeric.ops/accumulate/accumulate_op.pass.cpp
new file mode 100644
index 000000000000..19a872868bf6
--- /dev/null
+++ b/test/std/numerics/numeric.ops/accumulate/accumulate_op.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <numeric>
+
+// template <InputIterator Iter, MoveConstructible T,
+// Callable<auto, const T&, Iter::reference> BinaryOperation>
+// requires HasAssign<T, BinaryOperation::result_type>
+// && CopyConstructible<BinaryOperation>
+// T
+// accumulate(Iter first, Iter last, T init, BinaryOperation binary_op);
+
+#include <numeric>
+#include <functional>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter, class T>
+void
+test(Iter first, Iter last, T init, T x)
+{
+ assert(std::accumulate(first, last, init, std::multiplies<T>()) == x);
+}
+
+template <class Iter>
+void
+test()
+{
+ int ia[] = {1, 2, 3, 4, 5, 6};
+ unsigned sa = sizeof(ia) / sizeof(ia[0]);
+ test(Iter(ia), Iter(ia), 1, 1);
+ test(Iter(ia), Iter(ia), 10, 10);
+ test(Iter(ia), Iter(ia+1), 1, 1);
+ test(Iter(ia), Iter(ia+1), 10, 10);
+ test(Iter(ia), Iter(ia+2), 1, 2);
+ test(Iter(ia), Iter(ia+2), 10, 20);
+ test(Iter(ia), Iter(ia+sa), 1, 720);
+ test(Iter(ia), Iter(ia+sa), 10, 7200);
+}
+
+int main()
+{
+ test<input_iterator<const int*> >();
+ test<forward_iterator<const int*> >();
+ test<bidirectional_iterator<const int*> >();
+ test<random_access_iterator<const int*> >();
+ test<const int*>();
+}
diff --git a/test/std/numerics/numeric.ops/adjacent.difference/adjacent_difference.pass.cpp b/test/std/numerics/numeric.ops/adjacent.difference/adjacent_difference.pass.cpp
new file mode 100644
index 000000000000..46741e1e41b7
--- /dev/null
+++ b/test/std/numerics/numeric.ops/adjacent.difference/adjacent_difference.pass.cpp
@@ -0,0 +1,115 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <numeric>
+
+// template <InputIterator InIter,
+// OutputIterator<auto, const InIter::value_type&> OutIter>
+// requires HasMinus<InIter::value_type, InIter::value_type>
+// && Constructible<InIter::value_type, InIter::reference>
+// && OutputIterator<OutIter,
+// HasMinus<InIter::value_type, InIter::value_type>::result_type>
+// && MoveAssignable<InIter::value_type>
+// OutIter
+// adjacent_difference(InIter first, InIter last, OutIter result);
+
+#include <numeric>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class InIter, class OutIter>
+void
+test()
+{
+ int ia[] = {15, 10, 6, 3, 1};
+ int ir[] = {15, -5, -4, -3, -2};
+ const unsigned s = sizeof(ia) / sizeof(ia[0]);
+ int ib[s] = {0};
+ OutIter r = std::adjacent_difference(InIter(ia), InIter(ia+s), OutIter(ib));
+ assert(base(r) == ib + s);
+ for (unsigned i = 0; i < s; ++i)
+ assert(ib[i] == ir[i]);
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+class Y;
+
+class X
+{
+ int i_;
+
+ X& operator=(const X&);
+public:
+ explicit X(int i) : i_(i) {}
+ X(const X& x) : i_(x.i_) {}
+ X& operator=(X&& x)
+ {
+ i_ = x.i_;
+ x.i_ = -1;
+ return *this;
+ }
+
+ friend X operator-(const X& x, const X& y) {return X(x.i_ - y.i_);}
+
+ friend class Y;
+};
+
+class Y
+{
+ int i_;
+
+ Y& operator=(const Y&);
+public:
+ explicit Y(int i) : i_(i) {}
+ Y(const Y& y) : i_(y.i_) {}
+ void operator=(const X& x) {i_ = x.i_;}
+};
+
+#endif
+
+int main()
+{
+ test<input_iterator<const int*>, output_iterator<int*> >();
+ test<input_iterator<const int*>, forward_iterator<int*> >();
+ test<input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<input_iterator<const int*>, random_access_iterator<int*> >();
+ test<input_iterator<const int*>, int*>();
+
+ test<forward_iterator<const int*>, output_iterator<int*> >();
+ test<forward_iterator<const int*>, forward_iterator<int*> >();
+ test<forward_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<forward_iterator<const int*>, random_access_iterator<int*> >();
+ test<forward_iterator<const int*>, int*>();
+
+ test<bidirectional_iterator<const int*>, output_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, forward_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, int*>();
+
+ test<random_access_iterator<const int*>, output_iterator<int*> >();
+ test<random_access_iterator<const int*>, forward_iterator<int*> >();
+ test<random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, random_access_iterator<int*> >();
+ test<random_access_iterator<const int*>, int*>();
+
+ test<const int*, output_iterator<int*> >();
+ test<const int*, forward_iterator<int*> >();
+ test<const int*, bidirectional_iterator<int*> >();
+ test<const int*, random_access_iterator<int*> >();
+ test<const int*, int*>();
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ X x[3] = {X(1), X(2), X(3)};
+ Y y[3] = {Y(1), Y(2), Y(3)};
+ std::adjacent_difference(x, x+3, y);
+#endif
+}
diff --git a/test/std/numerics/numeric.ops/adjacent.difference/adjacent_difference_op.pass.cpp b/test/std/numerics/numeric.ops/adjacent.difference/adjacent_difference_op.pass.cpp
new file mode 100644
index 000000000000..fb0bbdc2836d
--- /dev/null
+++ b/test/std/numerics/numeric.ops/adjacent.difference/adjacent_difference_op.pass.cpp
@@ -0,0 +1,118 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <numeric>
+
+// template <InputIterator InIter,
+// OutputIterator<auto, const InIter::value_type&> OutIter,
+// Callable<auto, const InIter::value_type&, const InIter::value_type&> BinaryOperation>
+// requires Constructible<InIter::value_type, InIter::reference>
+// && OutputIterator<OutIter, BinaryOperation::result_type>
+// && MoveAssignable<InIter::value_type>
+// && CopyConstructible<BinaryOperation>
+// OutIter
+// adjacent_difference(InIter first, InIter last, OutIter result, BinaryOperation binary_op);
+
+#include <numeric>
+#include <functional>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class InIter, class OutIter>
+void
+test()
+{
+ int ia[] = {15, 10, 6, 3, 1};
+ int ir[] = {15, 25, 16, 9, 4};
+ const unsigned s = sizeof(ia) / sizeof(ia[0]);
+ int ib[s] = {0};
+ OutIter r = std::adjacent_difference(InIter(ia), InIter(ia+s), OutIter(ib),
+ std::plus<int>());
+ assert(base(r) == ib + s);
+ for (unsigned i = 0; i < s; ++i)
+ assert(ib[i] == ir[i]);
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+class Y;
+
+class X
+{
+ int i_;
+
+ X& operator=(const X&);
+public:
+ explicit X(int i) : i_(i) {}
+ X(const X& x) : i_(x.i_) {}
+ X& operator=(X&& x)
+ {
+ i_ = x.i_;
+ x.i_ = -1;
+ return *this;
+ }
+
+ friend X operator-(const X& x, const X& y) {return X(x.i_ - y.i_);}
+
+ friend class Y;
+};
+
+class Y
+{
+ int i_;
+
+ Y& operator=(const Y&);
+public:
+ explicit Y(int i) : i_(i) {}
+ Y(const Y& y) : i_(y.i_) {}
+ void operator=(const X& x) {i_ = x.i_;}
+};
+
+#endif
+
+
+int main()
+{
+ test<input_iterator<const int*>, output_iterator<int*> >();
+ test<input_iterator<const int*>, forward_iterator<int*> >();
+ test<input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<input_iterator<const int*>, random_access_iterator<int*> >();
+ test<input_iterator<const int*>, int*>();
+
+ test<forward_iterator<const int*>, output_iterator<int*> >();
+ test<forward_iterator<const int*>, forward_iterator<int*> >();
+ test<forward_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<forward_iterator<const int*>, random_access_iterator<int*> >();
+ test<forward_iterator<const int*>, int*>();
+
+ test<bidirectional_iterator<const int*>, output_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, forward_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, int*>();
+
+ test<random_access_iterator<const int*>, output_iterator<int*> >();
+ test<random_access_iterator<const int*>, forward_iterator<int*> >();
+ test<random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, random_access_iterator<int*> >();
+ test<random_access_iterator<const int*>, int*>();
+
+ test<const int*, output_iterator<int*> >();
+ test<const int*, forward_iterator<int*> >();
+ test<const int*, bidirectional_iterator<int*> >();
+ test<const int*, random_access_iterator<int*> >();
+ test<const int*, int*>();
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ X x[3] = {X(1), X(2), X(3)};
+ Y y[3] = {Y(1), Y(2), Y(3)};
+ std::adjacent_difference(x, x+3, y, std::minus<X>());
+#endif
+}
diff --git a/test/std/numerics/numeric.ops/inner.product/inner_product.pass.cpp b/test/std/numerics/numeric.ops/inner.product/inner_product.pass.cpp
new file mode 100644
index 000000000000..68a8c49b82ba
--- /dev/null
+++ b/test/std/numerics/numeric.ops/inner.product/inner_product.pass.cpp
@@ -0,0 +1,82 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <numeric>
+
+// template <InputIterator Iter1, InputIterator Iter2, MoveConstructible T>
+// requires HasMultiply<Iter1::reference, Iter2::reference>
+// && HasPlus<T, HasMultiply<Iter1::reference, Iter2::reference>::result_type>
+// && HasAssign<T,
+// HasPlus<T,
+// HasMultiply<Iter1::reference,
+// Iter2::reference>::result_type>::result_type>
+// T
+// inner_product(Iter1 first1, Iter1 last1, Iter2 first2, T init);
+
+#include <numeric>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter1, class Iter2, class T>
+void
+test(Iter1 first1, Iter1 last1, Iter2 first2, T init, T x)
+{
+ assert(std::inner_product(first1, last1, first2, init) == x);
+}
+
+template <class Iter1, class Iter2>
+void
+test()
+{
+ int a[] = {1, 2, 3, 4, 5, 6};
+ int b[] = {6, 5, 4, 3, 2, 1};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ test(Iter1(a), Iter1(a), Iter2(b), 0, 0);
+ test(Iter1(a), Iter1(a), Iter2(b), 10, 10);
+ test(Iter1(a), Iter1(a+1), Iter2(b), 0, 6);
+ test(Iter1(a), Iter1(a+1), Iter2(b), 10, 16);
+ test(Iter1(a), Iter1(a+2), Iter2(b), 0, 16);
+ test(Iter1(a), Iter1(a+2), Iter2(b), 10, 26);
+ test(Iter1(a), Iter1(a+sa), Iter2(b), 0, 56);
+ test(Iter1(a), Iter1(a+sa), Iter2(b), 10, 66);
+}
+
+int main()
+{
+ test<input_iterator<const int*>, input_iterator<const int*> >();
+ test<input_iterator<const int*>, forward_iterator<const int*> >();
+ test<input_iterator<const int*>, bidirectional_iterator<const int*> >();
+ test<input_iterator<const int*>, random_access_iterator<const int*> >();
+ test<input_iterator<const int*>, const int*>();
+
+ test<forward_iterator<const int*>, input_iterator<const int*> >();
+ test<forward_iterator<const int*>, forward_iterator<const int*> >();
+ test<forward_iterator<const int*>, bidirectional_iterator<const int*> >();
+ test<forward_iterator<const int*>, random_access_iterator<const int*> >();
+ test<forward_iterator<const int*>, const int*>();
+
+ test<bidirectional_iterator<const int*>, input_iterator<const int*> >();
+ test<bidirectional_iterator<const int*>, forward_iterator<const int*> >();
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*> >();
+ test<bidirectional_iterator<const int*>, random_access_iterator<const int*> >();
+ test<bidirectional_iterator<const int*>, const int*>();
+
+ test<random_access_iterator<const int*>, input_iterator<const int*> >();
+ test<random_access_iterator<const int*>, forward_iterator<const int*> >();
+ test<random_access_iterator<const int*>, bidirectional_iterator<const int*> >();
+ test<random_access_iterator<const int*>, random_access_iterator<const int*> >();
+ test<random_access_iterator<const int*>, const int*>();
+
+ test<const int*, input_iterator<const int*> >();
+ test<const int*, forward_iterator<const int*> >();
+ test<const int*, bidirectional_iterator<const int*> >();
+ test<const int*, random_access_iterator<const int*> >();
+ test<const int*, const int*>();
+}
diff --git a/test/std/numerics/numeric.ops/inner.product/inner_product_comp.pass.cpp b/test/std/numerics/numeric.ops/inner.product/inner_product_comp.pass.cpp
new file mode 100644
index 000000000000..31dbbd0bec50
--- /dev/null
+++ b/test/std/numerics/numeric.ops/inner.product/inner_product_comp.pass.cpp
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <numeric>
+
+// template <InputIterator Iter1, InputIterator Iter2, MoveConstructible T,
+// class BinaryOperation1,
+// Callable<auto, Iter1::reference, Iter2::reference> BinaryOperation2>
+// requires Callable<BinaryOperation1, const T&, BinaryOperation2::result_type>
+// && HasAssign<T, BinaryOperation1::result_type>
+// && CopyConstructible<BinaryOperation1>
+// && CopyConstructible<BinaryOperation2>
+// T
+// inner_product(Iter1 first1, Iter1 last1, Iter2 first2,
+// T init, BinaryOperation1 binary_op1, BinaryOperation2 binary_op2);
+
+#include <numeric>
+#include <functional>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter1, class Iter2, class T>
+void
+test(Iter1 first1, Iter1 last1, Iter2 first2, T init, T x)
+{
+ assert(std::inner_product(first1, last1, first2, init,
+ std::multiplies<int>(), std::plus<int>()) == x);
+}
+
+template <class Iter1, class Iter2>
+void
+test()
+{
+ int a[] = {1, 2, 3, 4, 5, 6};
+ int b[] = {6, 5, 4, 3, 2, 1};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ test(Iter1(a), Iter1(a), Iter2(b), 1, 1);
+ test(Iter1(a), Iter1(a), Iter2(b), 10, 10);
+ test(Iter1(a), Iter1(a+1), Iter2(b), 1, 7);
+ test(Iter1(a), Iter1(a+1), Iter2(b), 10, 70);
+ test(Iter1(a), Iter1(a+2), Iter2(b), 1, 49);
+ test(Iter1(a), Iter1(a+2), Iter2(b), 10, 490);
+ test(Iter1(a), Iter1(a+sa), Iter2(b), 1, 117649);
+ test(Iter1(a), Iter1(a+sa), Iter2(b), 10, 1176490);
+}
+
+int main()
+{
+ test<input_iterator<const int*>, input_iterator<const int*> >();
+ test<input_iterator<const int*>, forward_iterator<const int*> >();
+ test<input_iterator<const int*>, bidirectional_iterator<const int*> >();
+ test<input_iterator<const int*>, random_access_iterator<const int*> >();
+ test<input_iterator<const int*>, const int*>();
+
+ test<forward_iterator<const int*>, input_iterator<const int*> >();
+ test<forward_iterator<const int*>, forward_iterator<const int*> >();
+ test<forward_iterator<const int*>, bidirectional_iterator<const int*> >();
+ test<forward_iterator<const int*>, random_access_iterator<const int*> >();
+ test<forward_iterator<const int*>, const int*>();
+
+ test<bidirectional_iterator<const int*>, input_iterator<const int*> >();
+ test<bidirectional_iterator<const int*>, forward_iterator<const int*> >();
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*> >();
+ test<bidirectional_iterator<const int*>, random_access_iterator<const int*> >();
+ test<bidirectional_iterator<const int*>, const int*>();
+
+ test<random_access_iterator<const int*>, input_iterator<const int*> >();
+ test<random_access_iterator<const int*>, forward_iterator<const int*> >();
+ test<random_access_iterator<const int*>, bidirectional_iterator<const int*> >();
+ test<random_access_iterator<const int*>, random_access_iterator<const int*> >();
+ test<random_access_iterator<const int*>, const int*>();
+
+ test<const int*, input_iterator<const int*> >();
+ test<const int*, forward_iterator<const int*> >();
+ test<const int*, bidirectional_iterator<const int*> >();
+ test<const int*, random_access_iterator<const int*> >();
+ test<const int*, const int*>();
+}
diff --git a/test/std/numerics/numeric.ops/numeric.iota/iota.pass.cpp b/test/std/numerics/numeric.ops/numeric.iota/iota.pass.cpp
new file mode 100644
index 000000000000..eb7c8373ad58
--- /dev/null
+++ b/test/std/numerics/numeric.ops/numeric.iota/iota.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <numeric>
+
+// template <class ForwardIterator, class T>
+// void iota(ForwardIterator first, ForwardIterator last, T value);
+
+#include <numeric>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class InIter>
+void
+test()
+{
+ int ia[] = {1, 2, 3, 4, 5};
+ int ir[] = {5, 6, 7, 8, 9};
+ const unsigned s = sizeof(ia) / sizeof(ia[0]);
+ std::iota(InIter(ia), InIter(ia+s), 5);
+ for (unsigned i = 0; i < s; ++i)
+ assert(ia[i] == ir[i]);
+}
+
+int main()
+{
+ test<forward_iterator<int*> >();
+ test<bidirectional_iterator<int*> >();
+ test<random_access_iterator<int*> >();
+ test<int*>();
+}
diff --git a/test/std/numerics/numeric.ops/partial.sum/partial_sum.pass.cpp b/test/std/numerics/numeric.ops/partial.sum/partial_sum.pass.cpp
new file mode 100644
index 000000000000..cb468e019bb1
--- /dev/null
+++ b/test/std/numerics/numeric.ops/partial.sum/partial_sum.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <numeric>
+
+// template <InputIterator InIter, OutputIterator<auto, const InIter::value_type&> OutIter>
+// requires HasPlus<InIter::value_type, InIter::reference>
+// && HasAssign<InIter::value_type,
+// HasPlus<InIter::value_type, InIter::reference>::result_type>
+// && Constructible<InIter::value_type, InIter::reference>
+// OutIter
+// partial_sum(InIter first, InIter last, OutIter result);
+
+#include <numeric>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class InIter, class OutIter>
+void
+test()
+{
+ int ia[] = {1, 2, 3, 4, 5};
+ int ir[] = {1, 3, 6, 10, 15};
+ const unsigned s = sizeof(ia) / sizeof(ia[0]);
+ int ib[s] = {0};
+ OutIter r = std::partial_sum(InIter(ia), InIter(ia+s), OutIter(ib));
+ assert(base(r) == ib + s);
+ for (unsigned i = 0; i < s; ++i)
+ assert(ib[i] == ir[i]);
+}
+
+int main()
+{
+ test<input_iterator<const int*>, output_iterator<int*> >();
+ test<input_iterator<const int*>, forward_iterator<int*> >();
+ test<input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<input_iterator<const int*>, random_access_iterator<int*> >();
+ test<input_iterator<const int*>, int*>();
+
+ test<forward_iterator<const int*>, output_iterator<int*> >();
+ test<forward_iterator<const int*>, forward_iterator<int*> >();
+ test<forward_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<forward_iterator<const int*>, random_access_iterator<int*> >();
+ test<forward_iterator<const int*>, int*>();
+
+ test<bidirectional_iterator<const int*>, output_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, forward_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, int*>();
+
+ test<random_access_iterator<const int*>, output_iterator<int*> >();
+ test<random_access_iterator<const int*>, forward_iterator<int*> >();
+ test<random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, random_access_iterator<int*> >();
+ test<random_access_iterator<const int*>, int*>();
+
+ test<const int*, output_iterator<int*> >();
+ test<const int*, forward_iterator<int*> >();
+ test<const int*, bidirectional_iterator<int*> >();
+ test<const int*, random_access_iterator<int*> >();
+ test<const int*, int*>();
+}
diff --git a/test/std/numerics/numeric.ops/partial.sum/partial_sum_op.pass.cpp b/test/std/numerics/numeric.ops/partial.sum/partial_sum_op.pass.cpp
new file mode 100644
index 000000000000..d8f2a93e41ce
--- /dev/null
+++ b/test/std/numerics/numeric.ops/partial.sum/partial_sum_op.pass.cpp
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <numeric>
+
+// template<InputIterator InIter,
+// OutputIterator<auto, const InIter::value_type&> OutIter,
+// Callable<auto, const InIter::value_type&, InIter::reference> BinaryOperation>
+// requires HasAssign<InIter::value_type, BinaryOperation::result_type>
+// && Constructible<InIter::value_type, InIter::reference>
+// && CopyConstructible<BinaryOperation>
+// OutIter
+// partial_sum(InIter first, InIter last, OutIter result, BinaryOperation binary_op);
+
+#include <numeric>
+#include <functional>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class InIter, class OutIter>
+void
+test()
+{
+ int ia[] = {1, 2, 3, 4, 5};
+ int ir[] = {1, -1, -4, -8, -13};
+ const unsigned s = sizeof(ia) / sizeof(ia[0]);
+ int ib[s] = {0};
+ OutIter r = std::partial_sum(InIter(ia), InIter(ia+s), OutIter(ib), std::minus<int>());
+ assert(base(r) == ib + s);
+ for (unsigned i = 0; i < s; ++i)
+ assert(ib[i] == ir[i]);
+}
+
+int main()
+{
+ test<input_iterator<const int*>, output_iterator<int*> >();
+ test<input_iterator<const int*>, forward_iterator<int*> >();
+ test<input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<input_iterator<const int*>, random_access_iterator<int*> >();
+ test<input_iterator<const int*>, int*>();
+
+ test<forward_iterator<const int*>, output_iterator<int*> >();
+ test<forward_iterator<const int*>, forward_iterator<int*> >();
+ test<forward_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<forward_iterator<const int*>, random_access_iterator<int*> >();
+ test<forward_iterator<const int*>, int*>();
+
+ test<bidirectional_iterator<const int*>, output_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, forward_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, int*>();
+
+ test<random_access_iterator<const int*>, output_iterator<int*> >();
+ test<random_access_iterator<const int*>, forward_iterator<int*> >();
+ test<random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, random_access_iterator<int*> >();
+ test<random_access_iterator<const int*>, int*>();
+
+ test<const int*, output_iterator<int*> >();
+ test<const int*, forward_iterator<int*> >();
+ test<const int*, bidirectional_iterator<int*> >();
+ test<const int*, random_access_iterator<int*> >();
+ test<const int*, int*>();
+}
diff --git a/test/std/numerics/numeric.ops/version.pass.cpp b/test/std/numerics/numeric.ops/version.pass.cpp
new file mode 100644
index 000000000000..fb6e0a1063ce
--- /dev/null
+++ b/test/std/numerics/numeric.ops/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <numeric>
+
+#include <numeric>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/numerics/numeric.requirements/nothing_to_do.pass.cpp b/test/std/numerics/numeric.requirements/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/numerics/numeric.requirements/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/numerics/numerics.general/nothing_to_do.pass.cpp b/test/std/numerics/numerics.general/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/numerics/numerics.general/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/numerics/rand/nothing_to_do.pass.cpp b/test/std/numerics/rand/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/numerics/rand/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/numerics/rand/rand.adapt/nothing_to_do.pass.cpp b/test/std/numerics/rand/rand.adapt/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/numerics/rand/rand.adapt/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/numerics/rand/rand.adapt/rand.adapt.disc/assign.pass.cpp b/test/std/numerics/rand/rand.adapt/rand.adapt.disc/assign.pass.cpp
new file mode 100644
index 000000000000..18c8947af6ee
--- /dev/null
+++ b/test/std/numerics/rand/rand.adapt/rand.adapt.disc/assign.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t p, size_t r>
+// class discard_block_engine
+
+// discard_block_engine& operator=(const discard_block_engine&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::ranlux24 E;
+ E e1(2);
+ e1();
+ E e2(5);
+ e2 = e1;
+ assert(e1 == e2);
+ assert(e1() == e2());
+ E::result_type k = e1();
+ assert(e1 != e2);
+ assert(e2() == k);
+ assert(e1 == e2);
+}
+
+void
+test2()
+{
+ typedef std::ranlux48 E;
+ E e1(3);
+ e1();
+ E e2(5);
+ e2 = e1;
+ assert(e1 == e2);
+ assert(e1() == e2());
+ E::result_type k = e1();
+ assert(e1 != e2);
+ assert(e2() == k);
+ assert(e1 == e2);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
diff --git a/test/std/numerics/rand/rand.adapt/rand.adapt.disc/copy.pass.cpp b/test/std/numerics/rand/rand.adapt/rand.adapt.disc/copy.pass.cpp
new file mode 100644
index 000000000000..d6c64fa37dcc
--- /dev/null
+++ b/test/std/numerics/rand/rand.adapt/rand.adapt.disc/copy.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t p, size_t r>
+// class discard_block_engine
+
+// discard_block_engine(const discard_block_engine&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::ranlux24 E;
+ E e1;
+ e1();
+ E e2 = e1;
+ assert(e1 == e2);
+ assert(e1() == e2());
+ E::result_type k = e1();
+ assert(e1 != e2);
+ assert(e2() == k);
+ assert(e1 == e2);
+}
+
+void
+test2()
+{
+ typedef std::ranlux48 E;
+ E e1;
+ e1();
+ E e2 = e1;
+ assert(e1 == e2);
+ assert(e1() == e2());
+ E::result_type k = e1();
+ assert(e1 != e2);
+ assert(e2() == k);
+ assert(e1 == e2);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
diff --git a/test/std/numerics/rand/rand.adapt/rand.adapt.disc/ctor_engine_copy.pass.cpp b/test/std/numerics/rand/rand.adapt/rand.adapt.disc/ctor_engine_copy.pass.cpp
new file mode 100644
index 000000000000..d6b8b33ad01b
--- /dev/null
+++ b/test/std/numerics/rand/rand.adapt/rand.adapt.disc/ctor_engine_copy.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t p, size_t r>
+// class discard_block_engine
+
+// explicit discard_block_engine(const Engine& e);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::ranlux24_base Engine;
+ typedef std::ranlux24 Adaptor;
+ Engine e;
+ Adaptor a(e);
+ assert(a.base() == e);
+ }
+}
diff --git a/test/std/numerics/rand/rand.adapt/rand.adapt.disc/ctor_engine_move.pass.cpp b/test/std/numerics/rand/rand.adapt/rand.adapt.disc/ctor_engine_move.pass.cpp
new file mode 100644
index 000000000000..1e8e2fe6fbbe
--- /dev/null
+++ b/test/std/numerics/rand/rand.adapt/rand.adapt.disc/ctor_engine_move.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t p, size_t r>
+// class discard_block_engine
+
+// explicit discard_block_engine(const Engine& e);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::ranlux24_base Engine;
+ typedef std::ranlux24 Adaptor;
+ Engine e;
+ Engine e0 = e;
+ Adaptor a(std::move(e0));
+ assert(a.base() == e);
+ }
+}
diff --git a/test/std/numerics/rand/rand.adapt/rand.adapt.disc/ctor_result_type.pass.cpp b/test/std/numerics/rand/rand.adapt/rand.adapt.disc/ctor_result_type.pass.cpp
new file mode 100644
index 000000000000..dba254f1a73e
--- /dev/null
+++ b/test/std/numerics/rand/rand.adapt/rand.adapt.disc/ctor_result_type.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t p, size_t r>
+// class discard_block_engine
+
+// explicit discard_block_engine(result_type s = default_seed);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+void
+test1()
+{
+ const char* a = "15136306 8587749 2346244 16479026 15515802 9510553 "
+ "16090340 14501685 13839944 10789678 11581259 9590790 5840316 5953700 "
+ "13398366 8134459 16629731 6851902 15583892 1317475 4231148 9092691 "
+ "5707268 2355175 0 0";
+ std::ranlux24 e1(0);
+ std::ostringstream os;
+ os << e1;
+ assert(os.str() == a);
+}
+
+void
+test2()
+{
+ const char* a = "10880375256626 126660097854724 33643165434010 "
+ "78293780235492 179418984296008 96783156950859 238199764491708 "
+ "34339434557790 155299155394531 29014415493780 209265474179052 "
+ "263777435457028 0 0";
+ std::ranlux48 e1(0);
+ std::ostringstream os;
+ os << e1;
+ assert(os.str() == a);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
diff --git a/test/std/numerics/rand/rand.adapt/rand.adapt.disc/ctor_sseq.pass.cpp b/test/std/numerics/rand/rand.adapt/rand.adapt.disc/ctor_sseq.pass.cpp
new file mode 100644
index 000000000000..b64d4b31682b
--- /dev/null
+++ b/test/std/numerics/rand/rand.adapt/rand.adapt.disc/ctor_sseq.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t p, size_t r>
+// class discard_block_engine
+
+// template<class Sseq> explicit discard_block_engine(Sseq& q);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+void
+test1()
+{
+ const char* a = "13604817 711567 9760686 13278398 3323440 175548 5553651 "
+ "3028863 10748297 2216688 275779 14778841 14438394 9483441 4229545 "
+ "14657301 12636508 15978210 1653340 1718567 9272421 14302862 7940348 "
+ "889045 0 0";
+ unsigned as[] = {3, 5, 7};
+ std::seed_seq sseq(as, as+3);
+ std::ranlux24 e1(sseq);
+ std::ostringstream os;
+ os << e1;
+ assert(os.str() == a);
+}
+
+void
+test2()
+{
+ const char* a = "241408498702289 172342669275054 191026374555184 "
+ "61020585639411 231929771458953 142769679250755 198672786411514 "
+ "183712717244841 227473912549724 62843577252444 68782400568421 "
+ "159248704678140 0 0";
+ unsigned as[] = {3, 5, 7};
+ std::seed_seq sseq(as, as+3);
+ std::ranlux48 e1(sseq);
+ std::ostringstream os;
+ os << e1;
+ assert(os.str() == a);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
diff --git a/test/std/numerics/rand/rand.adapt/rand.adapt.disc/default.pass.cpp b/test/std/numerics/rand/rand.adapt/rand.adapt.disc/default.pass.cpp
new file mode 100644
index 000000000000..ffdaebc17142
--- /dev/null
+++ b/test/std/numerics/rand/rand.adapt/rand.adapt.disc/default.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t p, size_t r>
+// class discard_block_engine
+
+// explicit discard_block_engine();
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ std::ranlux24 e1;
+ std::ranlux24 e2(std::ranlux24_base::default_seed);
+ assert(e1 == e2);
+ assert(e1() == 15039276);
+}
+
+void
+test2()
+{
+ std::ranlux48 e1;
+ std::ranlux48 e2(std::ranlux48_base::default_seed);
+ assert(e1 == e2);
+ assert(e1() == 23459059301164ull);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
diff --git a/test/std/numerics/rand/rand.adapt/rand.adapt.disc/discard.pass.cpp b/test/std/numerics/rand/rand.adapt/rand.adapt.disc/discard.pass.cpp
new file mode 100644
index 000000000000..2dada0d6345f
--- /dev/null
+++ b/test/std/numerics/rand/rand.adapt/rand.adapt.disc/discard.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t p, size_t r>
+// class discard_block_engine
+
+// void discard(unsigned long long z);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ std::ranlux24 e1;
+ std::ranlux24 e2 = e1;
+ assert(e1 == e2);
+ e1.discard(3);
+ assert(e1 != e2);
+ e2();
+ e2();
+ e2();
+ assert(e1 == e2);
+}
+
+void
+test2()
+{
+ std::ranlux48 e1;
+ std::ranlux48 e2 = e1;
+ assert(e1 == e2);
+ e1.discard(3);
+ assert(e1 != e2);
+ e2();
+ e2();
+ e2();
+ assert(e1 == e2);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
diff --git a/test/std/numerics/rand/rand.adapt/rand.adapt.disc/eval.pass.cpp b/test/std/numerics/rand/rand.adapt/rand.adapt.disc/eval.pass.cpp
new file mode 100644
index 000000000000..f819d6a97699
--- /dev/null
+++ b/test/std/numerics/rand/rand.adapt/rand.adapt.disc/eval.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t p, size_t r>
+// class discard_block_engine
+
+// result_type operator()();
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ std::ranlux24 e;
+ assert(e() == 15039276u);
+ assert(e() == 16323925u);
+ assert(e() == 14283486u);
+}
+
+void
+test2()
+{
+ std::ranlux48 e;
+ assert(e() == 23459059301164ull);
+ assert(e() == 28639057539807ull);
+ assert(e() == 276846226770426ull);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
diff --git a/test/std/numerics/rand/rand.adapt/rand.adapt.disc/io.pass.cpp b/test/std/numerics/rand/rand.adapt/rand.adapt.disc/io.pass.cpp
new file mode 100644
index 000000000000..4b742f06a5eb
--- /dev/null
+++ b/test/std/numerics/rand/rand.adapt/rand.adapt.disc/io.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t p, size_t r>
+// class discard_block_engine
+
+// template <class charT, class traits,
+// class Engine, size_t p, size_t r>
+// basic_ostream<charT, traits>&
+// operator<<(basic_ostream<charT, traits>& os,
+// const discard_block_engine<Engine, p, r>& x);
+//
+// template <class charT, class traits,
+// class Engine, size_t p, size_t r>
+// basic_istream<charT, traits>&
+// operator>>(basic_istream<charT, traits>& is,
+// discard_block_engine<Engine, p, r>& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::ranlux24 E;
+ E e1;
+ e1.discard(100);
+ std::ostringstream os;
+ os << e1;
+ std::istringstream is(os.str());
+ E e2;
+ is >> e2;
+ assert(e1 == e2);
+}
+
+void
+test2()
+{
+ typedef std::ranlux48 E;
+ E e1;
+ e1.discard(100);
+ std::ostringstream os;
+ os << e1;
+ std::istringstream is(os.str());
+ E e2;
+ is >> e2;
+ assert(e1 == e2);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
diff --git a/test/std/numerics/rand/rand.adapt/rand.adapt.disc/result_type.pass.cpp b/test/std/numerics/rand/rand.adapt/rand.adapt.disc/result_type.pass.cpp
new file mode 100644
index 000000000000..2634aba3823b
--- /dev/null
+++ b/test/std/numerics/rand/rand.adapt/rand.adapt.disc/result_type.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t p, size_t r>
+// class discard_block_engine
+// {
+// public:
+// // types
+// typedef typename Engine::result_type result_type;
+
+#include <random>
+#include <type_traits>
+
+void
+test1()
+{
+ static_assert((std::is_same<
+ std::ranlux24::result_type,
+ std::uint_fast32_t>::value), "");
+}
+
+void
+test2()
+{
+ static_assert((std::is_same<
+ std::ranlux48::result_type,
+ std::uint_fast64_t>::value), "");
+}
+
+int main()
+{
+ test1();
+ test2();
+}
diff --git a/test/std/numerics/rand/rand.adapt/rand.adapt.disc/seed_result_type.pass.cpp b/test/std/numerics/rand/rand.adapt/rand.adapt.disc/seed_result_type.pass.cpp
new file mode 100644
index 000000000000..6a5ff14f77ab
--- /dev/null
+++ b/test/std/numerics/rand/rand.adapt/rand.adapt.disc/seed_result_type.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t p, size_t r>
+// class discard_block_engine
+
+// void seed(result_type s = default_seed);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ for (int s = 0; s < 20; ++s)
+ {
+ typedef std::ranlux24 E;
+ E e1(s);
+ E e2;
+ e2.seed(s);
+ assert(e1 == e2);
+ }
+}
+
+void
+test2()
+{
+ for (int s = 0; s < 20; ++s)
+ {
+ typedef std::ranlux48 E;
+ E e1(s);
+ E e2;
+ e2.seed(s);
+ assert(e1 == e2);
+ }
+}
+
+int main()
+{
+ test1();
+ test2();
+}
diff --git a/test/std/numerics/rand/rand.adapt/rand.adapt.disc/seed_sseq.pass.cpp b/test/std/numerics/rand/rand.adapt/rand.adapt.disc/seed_sseq.pass.cpp
new file mode 100644
index 000000000000..0da09a379e6f
--- /dev/null
+++ b/test/std/numerics/rand/rand.adapt/rand.adapt.disc/seed_sseq.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t p, size_t r>
+// class discard_block_engine
+
+// template<class Sseq> void seed(Sseq& q);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ unsigned a[] = {3, 5, 7};
+ std::seed_seq sseq(a, a+3);
+ std::ranlux24 e1;
+ std::ranlux24 e2(sseq);
+ assert(e1 != e2);
+ e1.seed(sseq);
+ assert(e1 == e2);
+}
+
+void
+test2()
+{
+ unsigned a[] = {3, 5, 7};
+ std::seed_seq sseq(a, a+3);
+ std::ranlux48 e1;
+ std::ranlux48 e2(sseq);
+ assert(e1 != e2);
+ e1.seed(sseq);
+ assert(e1 == e2);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
diff --git a/test/std/numerics/rand/rand.adapt/rand.adapt.disc/values.pass.cpp b/test/std/numerics/rand/rand.adapt/rand.adapt.disc/values.pass.cpp
new file mode 100644
index 000000000000..53e4c29affc4
--- /dev/null
+++ b/test/std/numerics/rand/rand.adapt/rand.adapt.disc/values.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t p, size_t r>
+// class discard_block_engine
+// {
+// public:
+// // types
+// typedef typename Engine::result_type result_type;
+//
+// // engine characteristics
+// static constexpr size_t block_size = p;
+// static constexpr size_t used_block = r;
+// static constexpr result_type min() { return Engine::min(); }
+// static constexpr result_type max() { return Engine::max(); }
+
+#include <random>
+#include <type_traits>
+#include <cassert>
+
+template <class _Tp>
+void where(const _Tp &) {}
+
+void
+test1()
+{
+ typedef std::ranlux24 E;
+ static_assert((E::block_size == 223), "");
+ static_assert((E::used_block == 23), "");
+ /*static_*/assert((E::min() == 0)/*, ""*/);
+ /*static_*/assert((E::max() == 0xFFFFFF)/*, ""*/);
+ where(E::block_size);
+ where(E::used_block);
+}
+
+void
+test2()
+{
+ typedef std::ranlux48 E;
+ static_assert((E::block_size == 389), "");
+ static_assert((E::used_block == 11), "");
+ /*static_*/assert((E::min() == 0)/*, ""*/);
+ /*static_*/assert((E::max() == 0xFFFFFFFFFFFFull)/*, ""*/);
+ where(E::block_size);
+ where(E::used_block);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
diff --git a/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/assign.pass.cpp b/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/assign.pass.cpp
new file mode 100644
index 000000000000..e4cd4f7396be
--- /dev/null
+++ b/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/assign.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t w, class UIntType>
+// class independent_bits_engine
+
+// independent_bits_engine& operator=(const independent_bits_engine&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::independent_bits_engine<std::ranlux24, 32, unsigned> E;
+ E e1(2);
+ e1();
+ E e2(5);
+ e2 = e1;
+ assert(e1 == e2);
+ assert(e1() == e2());
+ E::result_type k = e1();
+ assert(e1 != e2);
+ assert(e2() == k);
+ assert(e1 == e2);
+}
+
+void
+test2()
+{
+ typedef std::independent_bits_engine<std::ranlux48, 64, unsigned long long> E;
+ E e1(3);
+ e1();
+ E e2(5);
+ e2 = e1;
+ assert(e1 == e2);
+ assert(e1() == e2());
+ E::result_type k = e1();
+ assert(e1 != e2);
+ assert(e2() == k);
+ assert(e1 == e2);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
diff --git a/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/copy.pass.cpp b/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/copy.pass.cpp
new file mode 100644
index 000000000000..e3e497ec8c6e
--- /dev/null
+++ b/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/copy.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t w, class UIntType>
+// class independent_bits_engine
+
+// independent_bits_engine(const independent_bits_engine&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::independent_bits_engine<std::ranlux24, 32, unsigned> E;
+ E e1;
+ e1();
+ E e2 = e1;
+ assert(e1 == e2);
+ assert(e1() == e2());
+ E::result_type k = e1();
+ assert(e1 != e2);
+ assert(e2() == k);
+ assert(e1 == e2);
+}
+
+void
+test2()
+{
+ typedef std::independent_bits_engine<std::ranlux48, 64, unsigned long long> E;
+ E e1;
+ e1();
+ E e2 = e1;
+ assert(e1 == e2);
+ assert(e1() == e2());
+ E::result_type k = e1();
+ assert(e1 != e2);
+ assert(e2() == k);
+ assert(e1 == e2);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
diff --git a/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/ctor_engine_copy.pass.cpp b/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/ctor_engine_copy.pass.cpp
new file mode 100644
index 000000000000..193f5c33ec11
--- /dev/null
+++ b/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/ctor_engine_copy.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t w, class UIntType>
+// class independent_bits_engine
+
+// explicit independent_bits_engine(const Engine& e);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::mt19937 Engine;
+ typedef std::independent_bits_engine<Engine, 24, unsigned> Adaptor;
+ Engine e;
+ Adaptor a(e);
+ assert(a.base() == e);
+ }
+}
diff --git a/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/ctor_engine_move.pass.cpp b/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/ctor_engine_move.pass.cpp
new file mode 100644
index 000000000000..60a661d398f6
--- /dev/null
+++ b/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/ctor_engine_move.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t w, class UIntType>
+// class independent_bits_engine
+
+// explicit independent_bits_engine(const Engine& e);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::mt19937 Engine;
+ typedef std::independent_bits_engine<Engine, 24, unsigned> Adaptor;
+ Engine e;
+ Engine e0 = e;
+ Adaptor a(std::move(e0));
+ assert(a.base() == e);
+ }
+}
diff --git a/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/ctor_result_type.pass.cpp b/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/ctor_result_type.pass.cpp
new file mode 100644
index 000000000000..8e8d3091a4e3
--- /dev/null
+++ b/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/ctor_result_type.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t w, class UIntType>
+// class independent_bits_engine
+
+// explicit independent_bits_engine(result_type s = default_seed);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+void
+test1()
+{
+ const char* a = "15136306 8587749 2346244 16479026 15515802 9510553 "
+ "16090340 14501685 13839944 10789678 11581259 9590790 5840316 5953700 "
+ "13398366 8134459 16629731 6851902 15583892 1317475 4231148 9092691 "
+ "5707268 2355175 0 0";
+ std::independent_bits_engine<std::ranlux24, 32, unsigned> e1(0);
+ std::ostringstream os;
+ os << e1;
+ assert(os.str() == a);
+}
+
+void
+test2()
+{
+ const char* a = "10880375256626 126660097854724 33643165434010 "
+ "78293780235492 179418984296008 96783156950859 238199764491708 "
+ "34339434557790 155299155394531 29014415493780 209265474179052 "
+ "263777435457028 0 0";
+ std::independent_bits_engine<std::ranlux48, 64, unsigned long long> e1(0);
+ std::ostringstream os;
+ os << e1;
+ assert(os.str() == a);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
diff --git a/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/ctor_sseq.pass.cpp b/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/ctor_sseq.pass.cpp
new file mode 100644
index 000000000000..7965f4397f5a
--- /dev/null
+++ b/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/ctor_sseq.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t w, class UIntType>
+// class independent_bits_engine
+
+// template<class Sseq> explicit independent_bits_engine(Sseq& q);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+void
+test1()
+{
+ const char* a = "13604817 711567 9760686 13278398 3323440 175548 5553651 "
+ "3028863 10748297 2216688 275779 14778841 14438394 9483441 4229545 "
+ "14657301 12636508 15978210 1653340 1718567 9272421 14302862 7940348 "
+ "889045 0 0";
+ unsigned as[] = {3, 5, 7};
+ std::seed_seq sseq(as, as+3);
+ std::independent_bits_engine<std::ranlux24, 32, unsigned> e1(sseq);
+ std::ostringstream os;
+ os << e1;
+ assert(os.str() == a);
+}
+
+void
+test2()
+{
+ const char* a = "241408498702289 172342669275054 191026374555184 "
+ "61020585639411 231929771458953 142769679250755 198672786411514 "
+ "183712717244841 227473912549724 62843577252444 68782400568421 "
+ "159248704678140 0 0";
+ unsigned as[] = {3, 5, 7};
+ std::seed_seq sseq(as, as+3);
+ std::independent_bits_engine<std::ranlux48, 64, unsigned long long> e1(sseq);
+ std::ostringstream os;
+ os << e1;
+ assert(os.str() == a);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
diff --git a/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/default.pass.cpp b/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/default.pass.cpp
new file mode 100644
index 000000000000..ccb6f379d50c
--- /dev/null
+++ b/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/default.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t w, class UIntType>
+// class independent_bits_engine
+
+// explicit independent_bits_engine();
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ std::independent_bits_engine<std::ranlux24, 32, unsigned> e1;
+ std::independent_bits_engine<std::ranlux24, 32, unsigned> e2(std::ranlux24_base::default_seed);
+ assert(e1 == e2);
+ assert(e1() == 2066486613);
+}
+
+void
+test2()
+{
+ std::independent_bits_engine<std::ranlux48, 64, unsigned long long> e1;
+ std::independent_bits_engine<std::ranlux48, 64, unsigned long long> e2(std::ranlux48_base::default_seed);
+ assert(e1 == e2);
+ assert(e1() == 18223106896348967647ull);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
diff --git a/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/discard.pass.cpp b/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/discard.pass.cpp
new file mode 100644
index 000000000000..2a356a1c80db
--- /dev/null
+++ b/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/discard.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t w, class UIntType>
+// class independent_bits_engine
+
+// void discard(unsigned long long z);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ std::independent_bits_engine<std::ranlux24, 32, unsigned> e1;
+ std::independent_bits_engine<std::ranlux24, 32, unsigned> e2 = e1;
+ assert(e1 == e2);
+ e1.discard(3);
+ assert(e1 != e2);
+ e2();
+ e2();
+ e2();
+ assert(e1 == e2);
+}
+
+void
+test2()
+{
+ std::independent_bits_engine<std::ranlux48, 64, unsigned long long> e1;
+ std::independent_bits_engine<std::ranlux48, 64, unsigned long long> e2 = e1;
+ assert(e1 == e2);
+ e1.discard(3);
+ assert(e1 != e2);
+ e2();
+ e2();
+ e2();
+ assert(e1 == e2);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
diff --git a/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/eval.pass.cpp b/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/eval.pass.cpp
new file mode 100644
index 000000000000..1c2b2a80c59b
--- /dev/null
+++ b/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/eval.pass.cpp
@@ -0,0 +1,141 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t w, class UIntType>
+// class independent_bits_engine
+
+// result_type operator()();
+
+#include <random>
+#include <cassert>
+
+template <class UIntType, UIntType Min, UIntType Max>
+class rand1
+{
+public:
+ // types
+ typedef UIntType result_type;
+
+private:
+ result_type x_;
+
+ static_assert(Min < Max, "rand1 invalid parameters");
+public:
+
+#ifdef _LIBCPP_HAS_NO_CONSTEXPR
+ // Workaround for lack of constexpr in C++03
+ static const result_type _Min = Min;
+ static const result_type _Max = Max;
+#endif
+
+ static _LIBCPP_CONSTEXPR result_type min() {return Min;}
+ static _LIBCPP_CONSTEXPR result_type max() {return Max;}
+
+ explicit rand1(result_type sd = Min) : x_(sd)
+ {
+ if (x_ > Max)
+ x_ = Max;
+ }
+
+ result_type operator()()
+ {
+ result_type r = x_;
+ if (x_ < Max)
+ ++x_;
+ else
+ x_ = Min;
+ return r;
+ }
+};
+
+void
+test1()
+{
+ typedef std::independent_bits_engine<rand1<unsigned, 0, 10>, 16, unsigned> E;
+
+ E e;
+ assert(e() == 6958);
+}
+
+void
+test2()
+{
+ typedef std::independent_bits_engine<rand1<unsigned, 0, 100>, 16, unsigned> E;
+
+ E e;
+ assert(e() == 66);
+}
+
+void
+test3()
+{
+ typedef std::independent_bits_engine<rand1<unsigned, 0, 0xFFFFFFFF>, 32, unsigned> E;
+
+ E e(5);
+ assert(e() == 5);
+}
+
+void
+test4()
+{
+ typedef std::independent_bits_engine<rand1<unsigned, 0, 0xFFFFFFFF>, 7, unsigned> E;
+
+ E e(129);
+ assert(e() == 1);
+}
+
+void
+test5()
+{
+ typedef std::independent_bits_engine<rand1<unsigned, 2, 3>, 1, unsigned> E;
+
+ E e(6);
+ assert(e() == 1);
+}
+
+void
+test6()
+{
+ typedef std::independent_bits_engine<rand1<unsigned, 2, 3>, 11, unsigned> E;
+
+ E e(6);
+ assert(e() == 1365);
+}
+
+void
+test7()
+{
+ typedef std::independent_bits_engine<rand1<unsigned, 2, 3>, 32, unsigned> E;
+
+ E e(6);
+ assert(e() == 2863311530u);
+}
+
+void
+test8()
+{
+ typedef std::independent_bits_engine<std::mt19937, 64, unsigned long long> E;
+
+ E e(6);
+ assert(e() == 16470362623952407241ull);
+}
+
+int main()
+{
+ test1();
+ test2();
+ test3();
+ test4();
+ test5();
+ test6();
+ test7();
+ test8();
+}
diff --git a/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/io.pass.cpp b/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/io.pass.cpp
new file mode 100644
index 000000000000..9bcf06488247
--- /dev/null
+++ b/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/io.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t w, class UIntType>
+// class independent_bits_engine
+
+// template <class charT, class traits,
+// class Engine, size_t w, class UIntType>
+// basic_ostream<charT, traits>&
+// operator<<(basic_ostream<charT, traits>& os,
+// const independent_bits_engine<Engine, w, UIntType>& x);
+//
+// template <class charT, class traits,
+// class Engine, size_t w, class UIntType>
+// basic_istream<charT, traits>&
+// operator>>(basic_istream<charT, traits>& is,
+// independent_bits_engine<Engine, w, UIntType>& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::independent_bits_engine<std::ranlux24, 32, unsigned> E;
+ E e1;
+ e1.discard(100);
+ std::ostringstream os;
+ os << e1;
+ std::istringstream is(os.str());
+ E e2;
+ is >> e2;
+ assert(e1 == e2);
+}
+
+void
+test2()
+{
+ typedef std::independent_bits_engine<std::ranlux48, 64, unsigned long long> E;
+ E e1;
+ e1.discard(100);
+ std::ostringstream os;
+ os << e1;
+ std::istringstream is(os.str());
+ E e2;
+ is >> e2;
+ assert(e1 == e2);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
diff --git a/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/result_type.pass.cpp b/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/result_type.pass.cpp
new file mode 100644
index 000000000000..78040ad987d1
--- /dev/null
+++ b/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/result_type.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t w, class UIntType>
+// class independent_bits_engine
+// {
+// public:
+// // types
+// typedef UIntType result_type;
+
+#include <random>
+#include <type_traits>
+
+template <class UIntType, UIntType Min, UIntType Max>
+class rand1
+{
+public:
+ // types
+ typedef UIntType result_type;
+
+private:
+ result_type x_;
+
+ static_assert(Min < Max, "rand1 invalid parameters");
+public:
+
+#ifdef _LIBCPP_HAS_NO_CONSTEXPR
+ // Workaround for lack of constexpr in C++03
+ static const result_type _Min = Min;
+ static const result_type _Max = Max;
+#endif
+
+ static _LIBCPP_CONSTEXPR result_type min() {return Min;}
+ static _LIBCPP_CONSTEXPR result_type max() {return Max;}
+
+ explicit rand1(result_type sd = Min) : x_(sd)
+ {
+ if (x_ < Min)
+ x_ = Min;
+ if (x_ > Max)
+ x_ = Max;
+ }
+
+ result_type operator()()
+ {
+ result_type r = x_;
+ if (x_ < Max)
+ ++x_;
+ else
+ x_ = Min;
+ return r;
+ }
+};
+
+void
+test1()
+{
+ static_assert((std::is_same<
+ std::independent_bits_engine<rand1<unsigned long, 0, 10>, 16, unsigned>::result_type,
+ unsigned>::value), "");
+}
+
+void
+test2()
+{
+ static_assert((std::is_same<
+ std::independent_bits_engine<rand1<unsigned long, 0, 10>, 16, unsigned long long>::result_type,
+ unsigned long long>::value), "");
+}
+
+int main()
+{
+ test1();
+ test2();
+}
diff --git a/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/seed_result_type.pass.cpp b/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/seed_result_type.pass.cpp
new file mode 100644
index 000000000000..e8c24ca5fee9
--- /dev/null
+++ b/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/seed_result_type.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t w, class UIntType>
+// class independent_bits_engine
+
+// void seed(result_type s = default_seed);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ for (int s = 0; s < 20; ++s)
+ {
+ typedef std::independent_bits_engine<std::ranlux24, 32, unsigned> E;
+ E e1(s);
+ E e2;
+ e2.seed(s);
+ assert(e1 == e2);
+ }
+}
+
+void
+test2()
+{
+ for (int s = 0; s < 20; ++s)
+ {
+ typedef std::independent_bits_engine<std::ranlux48, 64, unsigned long long> E;
+ E e1(s);
+ E e2;
+ e2.seed(s);
+ assert(e1 == e2);
+ }
+}
+
+int main()
+{
+ test1();
+ test2();
+}
diff --git a/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/seed_sseq.pass.cpp b/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/seed_sseq.pass.cpp
new file mode 100644
index 000000000000..ec83fff7f83b
--- /dev/null
+++ b/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/seed_sseq.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t w, class UIntType>
+// class independent_bits_engine
+
+// template<class Sseq> void seed(Sseq& q);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ unsigned a[] = {3, 5, 7};
+ std::seed_seq sseq(a, a+3);
+ std::independent_bits_engine<std::ranlux24, 32, unsigned> e1;
+ std::independent_bits_engine<std::ranlux24, 32, unsigned> e2(sseq);
+ assert(e1 != e2);
+ e1.seed(sseq);
+ assert(e1 == e2);
+}
+
+void
+test2()
+{
+ unsigned a[] = {3, 5, 7};
+ std::seed_seq sseq(a, a+3);
+ std::independent_bits_engine<std::ranlux48, 64, unsigned long long> e1;
+ std::independent_bits_engine<std::ranlux48, 64, unsigned long long> e2(sseq);
+ assert(e1 != e2);
+ e1.seed(sseq);
+ assert(e1 == e2);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
diff --git a/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/values.pass.cpp b/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/values.pass.cpp
new file mode 100644
index 000000000000..20ca7d5510bf
--- /dev/null
+++ b/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/values.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t w, class UIntType>
+// class independent_bits_engine
+// {
+// public:
+// // types
+// typedef UIntType result_type;
+//
+// // engine characteristics
+// static constexpr result_type min() { return 0; }
+// static constexpr result_type max() { return 2^w - 1; }
+
+#include <random>
+#include <type_traits>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::independent_bits_engine<std::ranlux24, 32, unsigned> E;
+ /*static_*/assert((E::min() == 0)/*, ""*/);
+ /*static_*/assert((E::max() == 0xFFFFFFFF)/*, ""*/);
+}
+
+void
+test2()
+{
+ typedef std::independent_bits_engine<std::ranlux48, 64, unsigned long long> E;
+ /*static_*/assert((E::min() == 0)/*, ""*/);
+ /*static_*/assert((E::max() == 0xFFFFFFFFFFFFFFFFull)/*, ""*/);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
diff --git a/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/assign.pass.cpp b/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/assign.pass.cpp
new file mode 100644
index 000000000000..dae8c7c919af
--- /dev/null
+++ b/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/assign.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t k>
+// class shuffle_order_engine
+
+// shuffle_order_engine& operator=(const shuffle_order_engine&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::knuth_b E;
+ E e1(2);
+ e1();
+ E e2(5);
+ e2 = e1;
+ assert(e1 == e2);
+ assert(e1() == e2());
+ E::result_type k = e1();
+ assert(e1 != e2);
+ assert(e2() == k);
+ assert(e1 == e2);
+}
+
+int main()
+{
+ test1();
+}
diff --git a/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/copy.pass.cpp b/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/copy.pass.cpp
new file mode 100644
index 000000000000..c9e9893dee4b
--- /dev/null
+++ b/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/copy.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t k>
+// class shuffle_order_engine
+
+// shuffle_order_engine(const shuffle_order_engine&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::knuth_b E;
+ E e1;
+ e1();
+ E e2 = e1;
+ assert(e1 == e2);
+ assert(e1() == e2());
+ E::result_type k = e1();
+ assert(e1 != e2);
+ assert(e2() == k);
+ assert(e1 == e2);
+}
+
+int main()
+{
+ test1();
+}
diff --git a/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/ctor_engine_copy.pass.cpp b/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/ctor_engine_copy.pass.cpp
new file mode 100644
index 000000000000..a20c494f334c
--- /dev/null
+++ b/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/ctor_engine_copy.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t k>
+// class shuffle_order_engine
+
+// explicit shuffle_order_engine(const Engine& e);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::minstd_rand0 Engine;
+ typedef std::knuth_b Adaptor;
+ Engine e;
+ Adaptor a(e);
+ for (unsigned k = 0; k <= Adaptor::table_size; ++k)
+ e();
+ assert(a.base() == e);
+ }
+}
diff --git a/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/ctor_engine_move.pass.cpp b/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/ctor_engine_move.pass.cpp
new file mode 100644
index 000000000000..9811787821d9
--- /dev/null
+++ b/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/ctor_engine_move.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t k>
+// class shuffle_order_engine
+
+// explicit shuffle_order_engine(const Engine& e);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::minstd_rand0 Engine;
+ typedef std::knuth_b Adaptor;
+ Engine e;
+ Engine e0 = e;
+ Adaptor a(std::move(e0));
+ for (unsigned k = 0; k <= Adaptor::table_size; ++k)
+ e();
+ assert(a.base() == e);
+ }
+}
diff --git a/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/ctor_result_type.pass.cpp b/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/ctor_result_type.pass.cpp
new file mode 100644
index 000000000000..320249497289
--- /dev/null
+++ b/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/ctor_result_type.pass.cpp
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t k>
+// class shuffle_order_engine
+
+// explicit shuffle_order_engine(result_type s = default_seed);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+void
+test1()
+{
+ const char* a = "1771550148 168070 677268843 1194115201 1259501992 "
+ "703671065 407145426 1010275440 1693606898 1702877348 745024267 "
+ "1793193459 416963415 664975744 742430420 1148079870 637806795 "
+ "1527921388 165317290 1791337459 1435426120 375508442 1863429808 "
+ "1910758855 653618747 991426424 578291095 1974930990 1157900898 "
+ "343583572 25567821 221638147 1335692731 1341167826 1019292670 "
+ "774852571 606325389 700907908 1211405961 1955012967 1403137269 "
+ "1010152376 1772753897 486628401 1145807831 1106352968 1560917450 "
+ "679350398 1819071734 1561434646 781928982 1427964481 1669276942 "
+ "811199786 1608612146 1272705739 1428231253 1857946652 2097152784 "
+ "197742477 1300609030 99924397 97128425 349867255 408729299 1860625187 "
+ "2018133942 1420442476 1948474080 1025729457 1583749330 15184745 "
+ "1806938869 1655319056 296727307 638820415 1383963552 880037807 "
+ "1075545360 1321008721 1507631161 597371974 544717293 340756290 "
+ "1899563128 1465595994 634440068 777915521 545718511 2135841687 "
+ "1902073804 712854586 135760289 1095544109 285050585 1956649285 "
+ "987446484 259432572 891434194 1488577086 330596852 801096775 "
+ "1458514382 1872871416 1682074633 1153627723 1538775345 51662594 "
+ "709823970 739804705 2114844452 1188863267 1037076781 1172179215 "
+ "1948572574 533634468 902793804 1283497773 273836696 315894151 "
+ "653420473 1954002600 1601768276 64415940 306945492 577163950 "
+ "210874151 813838307 857078006 1737226413 376658679 1868110244 "
+ "1117951768 1080937173 1746896638 1842856729 1883887269 2141922362 "
+ "1020763473 1872318475 978729834 1935067665 1189895487 1205729145 "
+ "1034046923 1788963337 188263312 898072753 1393688555 1119406056 "
+ "1900835472 1375045132 1312008157 559007303 2142269543 413383599 "
+ "628550348 573639243 1100665718 464587168 65992084 1027393936 "
+ "1641360472 1918007189 69800406 609352380 35938117 569027612 902394793 "
+ "1019770837 221470752 669768613 1839284764 1979413630 1335703733 "
+ "1526078440 1403144959 1139398206 753967943 1785700701 1187714882 "
+ "1063522909 1123137582 192083544 680202567 1109090588 327456556 "
+ "1709233078 191596027 1076438936 1306955024 1530346852 127901445 "
+ "8455468 377129974 1199230721 1336700752 1103107597 703058228 "
+ "844612202 530372344 1910850558 47387421 1871435357 1168551137 "
+ "1101007744 1918050856 803711675 309982095 73743043 301259382 "
+ "1647477295 1644236294 859823662 638826571 1487427444 335916581 "
+ "15468904 140348241 895842081 410006250 1847504174 536600445 "
+ "1359845362 1400027760 288242141 1910039802 1453396858 1761991428 "
+ "2137921913 357210187 1414819544 1933136424 943782705 841706193 "
+ "1081202962 1919045067 333546776 988345562 337850989 314809455 "
+ "1750287624 853099962 1450233962 142805884 1399258689 247367726 "
+ "2128513937 1151147433 654730608 351121428 12778440 18876380 "
+ "1575222551 587014441 411835569 380613902 1771550148";
+ std::knuth_b e1(10);
+ std::ostringstream os;
+ os << e1;
+ assert(os.str() == a);
+}
+
+int main()
+{
+ test1();
+}
diff --git a/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/ctor_sseq.pass.cpp b/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/ctor_sseq.pass.cpp
new file mode 100644
index 000000000000..a08df07b3a87
--- /dev/null
+++ b/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/ctor_sseq.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t k>
+// class shuffle_order_engine
+
+// template<class Sseq> explicit shuffle_order_engine(Sseq& q);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+void
+test1()
+{
+ const char* a = "1894661934 884942216 1899568837 1561547157 525417712 "
+ "242729120 1476874187 1208468883 1983666902 1953485886 1507290666 "
+ "1317123450 632390874 696850315 1734917114 218976032 1690682513 "
+ "1944862534 456017951 2072049961 1348874775 1700965693 828093387 "
+ "2071522749 1077957279 1055942061 413360419 238964088 475007126 "
+ "1248050783 1516729632 1044035134 9617501 580065782 1737324341 "
+ "2022534575 219953662 941840747 415472792 1381878747 200458524 "
+ "1852054372 1849850586 1318041283 1026024576 101363422 660501483 "
+ "705453438 298717379 1873705814 673416290 868766340 614560427 "
+ "1668238166 532360730 969915708 1972423626 1966307090 97417947 "
+ "920896215 588041576 495024338 522400288 1068491480 878048146 "
+ "1995051285 17282737 560668414 2143274709 127339385 1299331283 "
+ "99667038 66663006 1566161755 773555006 272986904 1065825536 "
+ "1168683925 1185292013 1144552919 1489883454 811887358 279732868 "
+ "628609193 1562647158 1833265343 1742736292 639398211 357562689 "
+ "896869717 501615326 1775469607 1032409784 43371928 955037563 "
+ "1023543663 1354331571 1071539244 562210166 138213162 1518791327 "
+ "1335204647 1727874626 2114964448 1058152392 1055171537 348065433 "
+ "190278003 399246038 1389247438 1639480282 382424917 2144508195 "
+ "1531185764 1342593547 1359065400 1176108308 1412845568 968776497 "
+ "5573525 1332437854 323541262 329396230 2097079291 1110029273 "
+ "1071549822 739994612 1011644107 1074473050 478563727 894301674 "
+ "290189565 280656618 1121689914 1630931232 579945916 1870220126 "
+ "71516543 1535179528 1893792038 1107650479 1893348357 93154853 "
+ "138035708 683805596 1535656875 1326628479 1469623399 1751042846 "
+ "661214234 1947241260 1780560187 690441964 1403944207 1687457460 "
+ "1428487938 1877084153 1618585041 1383427538 461185097 869443256 "
+ "1254069404 1739961370 1245924391 138197640 1257913073 1915996843 "
+ "641653536 1755587965 1889101622 1732723706 2009073422 1611621773 "
+ "315899200 738279016 94909546 1711873548 1620302377 181922632 "
+ "1704446343 1345319468 2076463060 357902023 157605314 1025175647 "
+ "865799248 138769064 124418006 1591838311 675218651 1096276609 "
+ "1858759850 732186041 769493777 735387805 894450150 638142050 "
+ "720101232 1671055379 636619387 898507955 118193981 63865192 "
+ "1787942091 204050966 2100684950 1580797970 1951284753 1020070334 "
+ "960149537 1041144801 823914651 558983501 1742229329 708805658 "
+ "804904097 1023665826 1260041465 1180659188 590074436 301564006 "
+ "324841922 714752380 1967212989 290476911 815113546 815183409 "
+ "1989370850 1182975807 870784323 171062356 1711897606 2024645183 "
+ "1333203966 314683764 1785282634 603713754 1904315050 1874254109 "
+ "1298675767 1967311508 1946285744 753588304 1847558969 1457540010 "
+ "528986741 97857407 1864449494 1868752281 1171249392 1353422942 "
+ "832597170 457192338 335135800 1925268166 1845956613 296546482 "
+ "1894661934";
+ unsigned as[] = {3, 5, 7};
+ std::seed_seq sseq(as, as+3);
+ std::knuth_b e1(sseq);
+ std::ostringstream os;
+ os << e1;
+ assert(os.str() == a);
+}
+
+int main()
+{
+ test1();
+}
diff --git a/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/default.pass.cpp b/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/default.pass.cpp
new file mode 100644
index 000000000000..7b4bc582095f
--- /dev/null
+++ b/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/default.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t k>
+// class shuffle_order_engine
+
+// explicit shuffle_order_engine();
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ std::knuth_b e1;
+ std::knuth_b e2(std::minstd_rand0::default_seed);
+ assert(e1 == e2);
+ assert(e1() == 152607844u);
+}
+
+int main()
+{
+ test1();
+}
diff --git a/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/discard.pass.cpp b/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/discard.pass.cpp
new file mode 100644
index 000000000000..6e04e26c7e55
--- /dev/null
+++ b/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/discard.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t k>
+// class shuffle_order_engine
+
+// void discard(unsigned long long z);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ std::knuth_b e1;
+ std::knuth_b e2 = e1;
+ assert(e1 == e2);
+ e1.discard(3);
+ assert(e1 != e2);
+ e2();
+ e2();
+ e2();
+ assert(e1 == e2);
+}
+
+int main()
+{
+ test1();
+}
diff --git a/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/eval.pass.cpp b/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/eval.pass.cpp
new file mode 100644
index 000000000000..c218c17dde69
--- /dev/null
+++ b/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/eval.pass.cpp
@@ -0,0 +1,93 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t k>
+// class shuffle_order_engine
+
+// result_type operator()();
+
+#include <random>
+#include <cassert>
+
+template <class UIntType, UIntType Min, UIntType Max>
+class rand1
+{
+public:
+ // types
+ typedef UIntType result_type;
+
+private:
+ result_type x_;
+
+ static_assert(Min < Max, "rand1 invalid parameters");
+public:
+
+#ifdef _LIBCPP_HAS_NO_CONSTEXPR
+ // Workaround for lack of constexpr in C++03
+ static const result_type _Min = Min;
+ static const result_type _Max = Max;
+#endif
+
+ static _LIBCPP_CONSTEXPR result_type min() {return Min;}
+ static _LIBCPP_CONSTEXPR result_type max() {return Max;}
+
+ explicit rand1(result_type sd = Min) : x_(sd)
+ {
+ if (x_ > Max)
+ x_ = Max;
+ }
+
+ result_type operator()()
+ {
+ result_type r = x_;
+ if (x_ < Max)
+ ++x_;
+ else
+ x_ = Min;
+ return r;
+ }
+};
+
+void
+test1()
+{
+ typedef std::knuth_b E;
+
+ E e;
+ assert(e() == 152607844u);
+}
+
+void
+test2()
+{
+ typedef rand1<unsigned long long, 0, 0xFFFFFFFFFFFFFFFFull> E0;
+ typedef std::shuffle_order_engine<E0, 101> E;
+ E e;
+ e.discard(400);
+ assert(e() == 501);
+}
+
+void
+test3()
+{
+ typedef rand1<unsigned long long, 0, 0xFFFFFFFFFFFFFFFFull> E0;
+ typedef std::shuffle_order_engine<E0, 100> E;
+ E e;
+ e.discard(400);
+ assert(e() == 500);
+}
+
+int main()
+{
+ test1();
+ test2();
+ test3();
+}
diff --git a/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/io.pass.cpp b/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/io.pass.cpp
new file mode 100644
index 000000000000..6c8fdb998bfd
--- /dev/null
+++ b/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/io.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t k>
+// class shuffle_order_engine
+
+// template <class charT, class traits,
+// class Engine, size_t k>
+// basic_ostream<charT, traits>&
+// operator<<(basic_ostream<charT, traits>& os,
+// const shuffle_order_engine<Engine, k>& x);
+//
+// template <class charT, class traits,
+// class Engine, size_t k>
+// basic_istream<charT, traits>&
+// operator>>(basic_istream<charT, traits>& is,
+// shuffle_order_engine<Engine, k>& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::knuth_b E;
+ E e1;
+ e1.discard(100);
+ std::ostringstream os;
+ os << e1;
+ std::istringstream is(os.str());
+ E e2;
+ is >> e2;
+ assert(e1 == e2);
+}
+
+int main()
+{
+ test1();
+}
diff --git a/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/result_type.pass.cpp b/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/result_type.pass.cpp
new file mode 100644
index 000000000000..3271d933cb27
--- /dev/null
+++ b/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/result_type.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t k>
+// class shuffle_order_engine
+// {
+// public:
+// // types
+// typedef typename Engine::result_type result_type;
+
+#include <random>
+#include <type_traits>
+
+template <class UIntType, UIntType Min, UIntType Max>
+class rand1
+{
+public:
+ // types
+ typedef UIntType result_type;
+
+private:
+ result_type x_;
+
+ static_assert(Min < Max, "rand1 invalid parameters");
+public:
+
+#ifdef _LIBCPP_HAS_NO_CONSTEXPR
+ // Workaround for lack of constexpr in C++03
+ static const result_type _Min = Min;
+ static const result_type _Max = Max;
+#endif
+
+ static _LIBCPP_CONSTEXPR result_type min() {return Min;}
+ static _LIBCPP_CONSTEXPR result_type max() {return Max;}
+
+ explicit rand1(result_type sd = Min) : x_(sd)
+ {
+ if (x_ < Min)
+ x_ = Min;
+ if (x_ > Max)
+ x_ = Max;
+ }
+
+ result_type operator()()
+ {
+ result_type r = x_;
+ if (x_ < Max)
+ ++x_;
+ else
+ x_ = Min;
+ return r;
+ }
+};
+
+void
+test1()
+{
+ static_assert((std::is_same<
+ std::shuffle_order_engine<rand1<unsigned long, 0, 10>, 16>::result_type,
+ unsigned long>::value), "");
+}
+
+void
+test2()
+{
+ static_assert((std::is_same<
+ std::shuffle_order_engine<rand1<unsigned long long, 0, 10>, 16>::result_type,
+ unsigned long long>::value), "");
+}
+
+int main()
+{
+ test1();
+ test2();
+}
diff --git a/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/seed_result_type.pass.cpp b/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/seed_result_type.pass.cpp
new file mode 100644
index 000000000000..57ded845e1ee
--- /dev/null
+++ b/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/seed_result_type.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t k>
+// class shuffle_order_engine
+
+// void seed(result_type s = default_seed);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ for (int s = 0; s < 20; ++s)
+ {
+ typedef std::knuth_b E;
+ E e1(s);
+ E e2;
+ e2.seed(s);
+ assert(e1 == e2);
+ }
+}
+
+int main()
+{
+ test1();
+}
diff --git a/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/seed_sseq.pass.cpp b/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/seed_sseq.pass.cpp
new file mode 100644
index 000000000000..4b4b099bce41
--- /dev/null
+++ b/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/seed_sseq.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t k>
+// class shuffle_order_engine
+
+// template<class Sseq> void seed(Sseq& q);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ unsigned a[] = {3, 5, 7};
+ std::seed_seq sseq(a, a+3);
+ std::knuth_b e1;
+ std::knuth_b e2(sseq);
+ assert(e1 != e2);
+ e1.seed(sseq);
+ assert(e1 == e2);
+}
+
+int main()
+{
+ test1();
+}
diff --git a/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/values.pass.cpp b/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/values.pass.cpp
new file mode 100644
index 000000000000..eb42d644d301
--- /dev/null
+++ b/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/values.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t k>
+// class shuffle_order_engine
+// {
+// public:
+// // types
+// typedef typename Engine::result_type result_type;
+//
+// // engine characteristics
+// static constexpr size_t table_size = k;
+// static constexpr result_type min() { return Engine::min; }
+// static constexpr result_type max() { return Engine::max; }
+
+#include <random>
+#include <type_traits>
+#include <cassert>
+
+template <class _Tp>
+void where(const _Tp &) {}
+
+void
+test1()
+{
+ typedef std::knuth_b E;
+ static_assert(E::table_size == 256, "");
+ /*static_*/assert((E::min() == 1)/*, ""*/);
+ /*static_*/assert((E::max() == 2147483646)/*, ""*/);
+ where(E::table_size);
+}
+
+int main()
+{
+ test1();
+}
diff --git a/test/std/numerics/rand/rand.device/ctor.pass.cpp b/test/std/numerics/rand/rand.device/ctor.pass.cpp
new file mode 100644
index 000000000000..97f46b26aa27
--- /dev/null
+++ b/test/std/numerics/rand/rand.device/ctor.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class random_device;
+
+// explicit random_device(const string& token = implementation-defined);
+
+// For the following ctors, the standard states: "The semantics and default
+// value of the token parameter are implementation-defined". Implementations
+// therefore aren't required to accept any string, but the default shouldn't
+// throw.
+
+#include <random>
+#include <cassert>
+#include <unistd.h>
+
+bool is_valid_random_device(const std::string &token) {
+#if defined(_LIBCPP_USING_DEV_RANDOM)
+ // Not an exhaustive list: they're the only tokens that are tested below.
+ return token == "/dev/urandom" || token == "/dev/random";
+#else
+ return token == "/dev/urandom";
+#endif
+}
+
+void check_random_device_valid(const std::string &token) {
+ std::random_device r(token);
+}
+
+void check_random_device_invalid(const std::string &token) {
+ try {
+ std::random_device r(token);
+ assert(false);
+ } catch (const std::system_error &e) {
+ }
+}
+
+int main() {
+ { std::random_device r; }
+
+ {
+ int ec;
+ ec = close(STDIN_FILENO);
+ assert(!ec);
+ ec = close(STDOUT_FILENO);
+ assert(!ec);
+ ec = close(STDERR_FILENO);
+ assert(!ec);
+ std::random_device r;
+ }
+
+ {
+ std::string token = "wrong file";
+ if (is_valid_random_device(token))
+ check_random_device_valid(token);
+ else
+ check_random_device_invalid(token);
+ }
+
+ {
+ std::string token = "/dev/urandom";
+ if (is_valid_random_device(token))
+ check_random_device_valid(token);
+ else
+ check_random_device_invalid(token);
+ }
+
+ {
+ std::string token = "/dev/random";
+ if (is_valid_random_device(token))
+ check_random_device_valid(token);
+ else
+ check_random_device_invalid(token);
+ }
+}
diff --git a/test/std/numerics/rand/rand.device/entropy.pass.cpp b/test/std/numerics/rand/rand.device/entropy.pass.cpp
new file mode 100644
index 000000000000..f01e5653391f
--- /dev/null
+++ b/test/std/numerics/rand/rand.device/entropy.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class random_device;
+
+// double entropy() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ std::random_device r;
+ double e = r.entropy();
+}
diff --git a/test/std/numerics/rand/rand.device/eval.pass.cpp b/test/std/numerics/rand/rand.device/eval.pass.cpp
new file mode 100644
index 000000000000..72aff076a5df
--- /dev/null
+++ b/test/std/numerics/rand/rand.device/eval.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class random_device;
+
+// result_type operator()();
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ std::random_device r;
+ std::random_device::result_type e = r();
+ }
+
+ try
+ {
+ std::random_device r("/dev/null");
+ r();
+ assert(false);
+ }
+ catch (const std::system_error& e)
+ {
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/nothing_to_do.pass.cpp b/test/std/numerics/rand/rand.dis/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.bern/nothing_to_do.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.bern/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.bern/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/assign.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/assign.pass.cpp
new file mode 100644
index 000000000000..e55c1579c4cb
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/assign.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class bernoulli_distribution
+
+// bernoulli_distribution& operator=(const bernoulli_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::bernoulli_distribution D;
+ D d1(0.75);
+ D d2;
+ assert(d1 != d2);
+ d2 = d1;
+ assert(d1 == d2);
+}
+
+int main()
+{
+ test1();
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/copy.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/copy.pass.cpp
new file mode 100644
index 000000000000..c64f925b4c6b
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/copy.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class bernoulli_distribution
+
+// bernoulli_distribution(const bernoulli_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::bernoulli_distribution D;
+ D d1(0.75);
+ D d2 = d1;
+ assert(d1 == d2);
+}
+
+int main()
+{
+ test1();
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/ctor_double.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/ctor_double.pass.cpp
new file mode 100644
index 000000000000..5d511fcc6739
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/ctor_double.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class bernoulli_distribution
+
+// explicit bernoulli_distribution(double p = 0.5);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::bernoulli_distribution D;
+ D d;
+ assert(d.p() == 0.5);
+ }
+ {
+ typedef std::bernoulli_distribution D;
+ D d(0);
+ assert(d.p() == 0);
+ }
+ {
+ typedef std::bernoulli_distribution D;
+ D d(0.75);
+ assert(d.p() == 0.75);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/ctor_param.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/ctor_param.pass.cpp
new file mode 100644
index 000000000000..a143b5a68f4c
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/ctor_param.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class bernoulli_distribution
+
+// explicit bernoulli_distribution(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::bernoulli_distribution D;
+ typedef D::param_type P;
+ P p(0.25);
+ D d(p);
+ assert(d.p() == 0.25);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/eq.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/eq.pass.cpp
new file mode 100644
index 000000000000..b77c12eed22e
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/eq.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class bernoulli_distribution
+
+// bool operator=(const bernoulli_distribution& x,
+// const bernoulli_distribution& y);
+// bool operator!(const bernoulli_distribution& x,
+// const bernoulli_distribution& y);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::bernoulli_distribution D;
+ D d1(.25);
+ D d2(.25);
+ assert(d1 == d2);
+ }
+ {
+ typedef std::bernoulli_distribution D;
+ D d1(.28);
+ D d2(.25);
+ assert(d1 != d2);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/eval.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/eval.pass.cpp
new file mode 100644
index 000000000000..f071e8507478
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/eval.pass.cpp
@@ -0,0 +1,103 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class bernoulli_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g);
+
+#include <random>
+#include <numeric>
+#include <vector>
+#include <cassert>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+ return x * x;
+}
+
+int main()
+{
+ {
+ typedef std::bernoulli_distribution D;
+ typedef std::minstd_rand G;
+ G g;
+ D d(.75);
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ u.push_back(d(g));
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = d.p();
+ double x_var = d.p()*(1-d.p());
+ double x_skew = (1 - 2 * d.p())/std::sqrt(x_var);
+ double x_kurtosis = (6 * sqr(d.p()) - 6 * d.p() + 1)/x_var;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.02);
+ }
+ {
+ typedef std::bernoulli_distribution D;
+ typedef std::minstd_rand G;
+ G g;
+ D d(.25);
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ u.push_back(d(g));
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = d.p();
+ double x_var = d.p()*(1-d.p());
+ double x_skew = (1 - 2 * d.p())/std::sqrt(x_var);
+ double x_kurtosis = (6 * sqr(d.p()) - 6 * d.p() + 1)/x_var;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.02);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/eval_param.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/eval_param.pass.cpp
new file mode 100644
index 000000000000..e03fb57f380c
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/eval_param.pass.cpp
@@ -0,0 +1,107 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class bernoulli_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g, const param_type& parm);
+
+#include <random>
+#include <numeric>
+#include <vector>
+#include <cassert>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+ return x * x;
+}
+
+int main()
+{
+ {
+ typedef std::bernoulli_distribution D;
+ typedef D::param_type P;
+ typedef std::minstd_rand G;
+ G g;
+ D d(.75);
+ P p(.25);
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ u.push_back(d(g, p));
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = p.p();
+ double x_var = p.p()*(1-p.p());
+ double x_skew = (1 - 2 * p.p())/std::sqrt(x_var);
+ double x_kurtosis = (6 * sqr(p.p()) - 6 * p.p() + 1)/x_var;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.02);
+ }
+ {
+ typedef std::bernoulli_distribution D;
+ typedef D::param_type P;
+ typedef std::minstd_rand G;
+ G g;
+ D d(.25);
+ P p(.75);
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ u.push_back(d(g, p));
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = p.p();
+ double x_var = p.p()*(1-p.p());
+ double x_skew = (1 - 2 * p.p())/std::sqrt(x_var);
+ double x_kurtosis = (6 * sqr(p.p()) - 6 * p.p() + 1)/x_var;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.02);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/get_param.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/get_param.pass.cpp
new file mode 100644
index 000000000000..1b4eae90b6a3
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/get_param.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class bernoulli_distribution
+
+// param_type param() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::bernoulli_distribution D;
+ typedef D::param_type P;
+ P p(.125);
+ D d(p);
+ assert(d.param() == p);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/io.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/io.pass.cpp
new file mode 100644
index 000000000000..5f57145e1311
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/io.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class bernoulli_distribution
+
+// template <class charT, class traits>
+// basic_ostream<charT, traits>&
+// operator<<(basic_ostream<charT, traits>& os,
+// const bernoulli_distribution& x);
+//
+// template <class charT, class traits>
+// basic_istream<charT, traits>&
+// operator>>(basic_istream<charT, traits>& is,
+// bernoulli_distribution& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::bernoulli_distribution D;
+ D d1(.25);
+ std::ostringstream os;
+ os << d1;
+ std::istringstream is(os.str());
+ D d2;
+ is >> d2;
+ assert(d1 == d2);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/max.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/max.pass.cpp
new file mode 100644
index 000000000000..8e669bbda34a
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/max.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class bernoulli_distribution
+
+// result_type max() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::bernoulli_distribution D;
+ D d(.25);
+ assert(d.max() == true);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/min.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/min.pass.cpp
new file mode 100644
index 000000000000..296ad1474ecf
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/min.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class bernoulli_distribution
+
+// result_type min() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::bernoulli_distribution D;
+ D d(.5);
+ assert(d.min() == false);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/param_assign.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/param_assign.pass.cpp
new file mode 100644
index 000000000000..a24dd0dfc930
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/param_assign.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class bernoulli_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::bernoulli_distribution D;
+ typedef D::param_type param_type;
+ param_type p0(.7);
+ param_type p;
+ p = p0;
+ assert(p.p() == .7);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/param_copy.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/param_copy.pass.cpp
new file mode 100644
index 000000000000..6c4eaeee4da9
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/param_copy.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class bernoulli_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::bernoulli_distribution D;
+ typedef D::param_type param_type;
+ param_type p0(.125);
+ param_type p = p0;
+ assert(p.p() == .125);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/param_ctor.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/param_ctor.pass.cpp
new file mode 100644
index 000000000000..c43f44721a60
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/param_ctor.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class bernoulli_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::bernoulli_distribution D;
+ typedef D::param_type param_type;
+ param_type p;
+ assert(p.p() == 0.5);
+ }
+ {
+ typedef std::bernoulli_distribution D;
+ typedef D::param_type param_type;
+ param_type p(0.25);
+ assert(p.p() == 0.25);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/param_eq.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/param_eq.pass.cpp
new file mode 100644
index 000000000000..ee5dfe867b7e
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/param_eq.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class bernoulli_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::bernoulli_distribution D;
+ typedef D::param_type param_type;
+ param_type p1(0.75);
+ param_type p2(0.75);
+ assert(p1 == p2);
+ }
+ {
+ typedef std::bernoulli_distribution D;
+ typedef D::param_type param_type;
+ param_type p1(0.75);
+ param_type p2(0.5);
+ assert(p1 != p2);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/param_types.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/param_types.pass.cpp
new file mode 100644
index 000000000000..5a3b90332120
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/param_types.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class bernoulli_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::bernoulli_distribution D;
+ typedef D::param_type param_type;
+ typedef param_type::distribution_type distribution_type;
+ static_assert((std::is_same<D, distribution_type>::value), "");
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/set_param.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/set_param.pass.cpp
new file mode 100644
index 000000000000..9869ac6fc39c
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/set_param.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class bernoulli_distribution
+
+// void param(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::bernoulli_distribution D;
+ typedef D::param_type P;
+ P p(0.25);
+ D d(0.75);
+ d.param(p);
+ assert(d.param() == p);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/types.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/types.pass.cpp
new file mode 100644
index 000000000000..4b6c4be1a240
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/types.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class bernoulli_distribution
+// {
+// typedef bool result_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::bernoulli_distribution D;
+ typedef D::result_type result_type;
+ static_assert((std::is_same<result_type, bool>::value), "");
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/assign.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/assign.pass.cpp
new file mode 100644
index 000000000000..82473d2883b4
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/assign.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class binomial_distribution
+
+// binomial_distribution& operator=(const binomial_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::binomial_distribution<> D;
+ D d1(2, 0.75);
+ D d2;
+ assert(d1 != d2);
+ d2 = d1;
+ assert(d1 == d2);
+}
+
+int main()
+{
+ test1();
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/copy.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/copy.pass.cpp
new file mode 100644
index 000000000000..715494886787
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/copy.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class binomial_distribution
+
+// binomial_distribution(const binomial_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::binomial_distribution<> D;
+ D d1(2, 0.75);
+ D d2 = d1;
+ assert(d1 == d2);
+}
+
+int main()
+{
+ test1();
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/ctor_int_double.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/ctor_int_double.pass.cpp
new file mode 100644
index 000000000000..5a3a22eeebdd
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/ctor_int_double.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class binomial_distribution
+
+// explicit binomial_distribution(IntType t = 1, double p = 0.5);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::binomial_distribution<> D;
+ D d;
+ assert(d.t() == 1);
+ assert(d.p() == 0.5);
+ }
+ {
+ typedef std::binomial_distribution<> D;
+ D d(3);
+ assert(d.t() == 3);
+ assert(d.p() == 0.5);
+ }
+ {
+ typedef std::binomial_distribution<> D;
+ D d(3, 0.75);
+ assert(d.t() == 3);
+ assert(d.p() == 0.75);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/ctor_param.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/ctor_param.pass.cpp
new file mode 100644
index 000000000000..cfb98f2985e1
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/ctor_param.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class binomial_distribution
+
+// explicit binomial_distribution(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::binomial_distribution<> D;
+ typedef D::param_type P;
+ P p(5, 0.25);
+ D d(p);
+ assert(d.t() == 5);
+ assert(d.p() == 0.25);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/eq.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/eq.pass.cpp
new file mode 100644
index 000000000000..738bdc80e934
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/eq.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class binomial_distribution
+
+// bool operator=(const binomial_distribution& x,
+// const binomial_distribution& y);
+// bool operator!(const binomial_distribution& x,
+// const binomial_distribution& y);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::binomial_distribution<> D;
+ D d1(3, .25);
+ D d2(3, .25);
+ assert(d1 == d2);
+ }
+ {
+ typedef std::binomial_distribution<> D;
+ D d1(3, .28);
+ D d2(3, .25);
+ assert(d1 != d2);
+ }
+ {
+ typedef std::binomial_distribution<> D;
+ D d1(3, .25);
+ D d2(4, .25);
+ assert(d1 != d2);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/eval.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/eval.pass.cpp
new file mode 100644
index 000000000000..43c6b546bdb2
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/eval.pass.cpp
@@ -0,0 +1,475 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// REQUIRES: long_tests
+
+// <random>
+
+// template<class IntType = int>
+// class binomial_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g);
+
+#include <random>
+#include <numeric>
+#include <vector>
+#include <cassert>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+ return x * x;
+}
+
+int main()
+{
+ {
+ typedef std::binomial_distribution<> D;
+ typedef std::mt19937_64 G;
+ G g;
+ D d(5, .75);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v <= d.max());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = d.t() * d.p();
+ double x_var = x_mean*(1-d.p());
+ double x_skew = (1-2*d.p()) / std::sqrt(x_var);
+ double x_kurtosis = (1-6*d.p()*(1-d.p())) / x_var;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.04);
+ }
+ {
+ typedef std::binomial_distribution<> D;
+ typedef std::mt19937 G;
+ G g;
+ D d(30, .03125);
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v <= d.max());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = d.t() * d.p();
+ double x_var = x_mean*(1-d.p());
+ double x_skew = (1-2*d.p()) / std::sqrt(x_var);
+ double x_kurtosis = (1-6*d.p()*(1-d.p())) / x_var;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ {
+ typedef std::binomial_distribution<> D;
+ typedef std::mt19937 G;
+ G g;
+ D d(40, .25);
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v <= d.max());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = d.t() * d.p();
+ double x_var = x_mean*(1-d.p());
+ double x_skew = (1-2*d.p()) / std::sqrt(x_var);
+ double x_kurtosis = (1-6*d.p()*(1-d.p())) / x_var;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.03);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.3);
+ }
+ {
+ typedef std::binomial_distribution<> D;
+ typedef std::mt19937 G;
+ G g;
+ D d(40, 0);
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v <= d.max());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ // In this case:
+ // skew computes to 0./0. == nan
+ // kurtosis computes to 0./0. == nan
+ // x_skew == inf
+ // x_kurtosis == inf
+ // These tests are commented out because UBSan warns about division by 0
+// skew /= u.size() * dev * var;
+// kurtosis /= u.size() * var * var;
+// kurtosis -= 3;
+ double x_mean = d.t() * d.p();
+ double x_var = x_mean*(1-d.p());
+// double x_skew = (1-2*d.p()) / std::sqrt(x_var);
+// double x_kurtosis = (1-6*d.p()*(1-d.p())) / x_var;
+ assert(mean == x_mean);
+ assert(var == x_var);
+// assert(skew == x_skew);
+// assert(kurtosis == x_kurtosis);
+ }
+ {
+ typedef std::binomial_distribution<> D;
+ typedef std::mt19937 G;
+ G g;
+ D d(40, 1);
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v <= d.max());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ // In this case:
+ // skew computes to 0./0. == nan
+ // kurtosis computes to 0./0. == nan
+ // x_skew == -inf
+ // x_kurtosis == inf
+ // These tests are commented out because UBSan warns about division by 0
+// skew /= u.size() * dev * var;
+// kurtosis /= u.size() * var * var;
+// kurtosis -= 3;
+ double x_mean = d.t() * d.p();
+ double x_var = x_mean*(1-d.p());
+// double x_skew = (1-2*d.p()) / std::sqrt(x_var);
+// double x_kurtosis = (1-6*d.p()*(1-d.p())) / x_var;
+ assert(mean == x_mean);
+ assert(var == x_var);
+// assert(skew == x_skew);
+// assert(kurtosis == x_kurtosis);
+ }
+ {
+ typedef std::binomial_distribution<> D;
+ typedef std::mt19937 G;
+ G g;
+ D d(400, 0.5);
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v <= d.max());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = d.t() * d.p();
+ double x_var = x_mean*(1-d.p());
+ double x_skew = (1-2*d.p()) / std::sqrt(x_var);
+ double x_kurtosis = (1-6*d.p()*(1-d.p())) / x_var;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs(skew - x_skew) < 0.01);
+ assert(std::abs(kurtosis - x_kurtosis) < 0.01);
+ }
+ {
+ typedef std::binomial_distribution<> D;
+ typedef std::mt19937 G;
+ G g;
+ D d(1, 0.5);
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v <= d.max());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = d.t() * d.p();
+ double x_var = x_mean*(1-d.p());
+ double x_skew = (1-2*d.p()) / std::sqrt(x_var);
+ double x_kurtosis = (1-6*d.p()*(1-d.p())) / x_var;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs(skew - x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ {
+ const int N = 100000;
+ std::mt19937 gen1;
+ std::mt19937 gen2;
+
+ std::binomial_distribution<> dist1(5, 0.1);
+ std::binomial_distribution<unsigned> dist2(5, 0.1);
+
+ for(int i = 0; i < N; ++i)
+ assert(dist1(gen1) == dist2(gen2));
+ }
+ {
+ typedef std::binomial_distribution<> D;
+ typedef std::mt19937 G;
+ G g;
+ D d(0, 0.005);
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v <= d.max());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ // In this case:
+ // skew computes to 0./0. == nan
+ // kurtosis computes to 0./0. == nan
+ // x_skew == inf
+ // x_kurtosis == inf
+ // These tests are commented out because UBSan warns about division by 0
+// skew /= u.size() * dev * var;
+// kurtosis /= u.size() * var * var;
+// kurtosis -= 3;
+ double x_mean = d.t() * d.p();
+ double x_var = x_mean*(1-d.p());
+// double x_skew = (1-2*d.p()) / std::sqrt(x_var);
+// double x_kurtosis = (1-6*d.p()*(1-d.p())) / x_var;
+ assert(mean == x_mean);
+ assert(var == x_var);
+// assert(skew == x_skew);
+// assert(kurtosis == x_kurtosis);
+ }
+ {
+ typedef std::binomial_distribution<> D;
+ typedef std::mt19937 G;
+ G g;
+ D d(0, 0);
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v <= d.max());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ // In this case:
+ // skew computes to 0./0. == nan
+ // kurtosis computes to 0./0. == nan
+ // x_skew == inf
+ // x_kurtosis == inf
+ // These tests are commented out because UBSan warns about division by 0
+// skew /= u.size() * dev * var;
+// kurtosis /= u.size() * var * var;
+// kurtosis -= 3;
+ double x_mean = d.t() * d.p();
+ double x_var = x_mean*(1-d.p());
+// double x_skew = (1-2*d.p()) / std::sqrt(x_var);
+// double x_kurtosis = (1-6*d.p()*(1-d.p())) / x_var;
+ assert(mean == x_mean);
+ assert(var == x_var);
+// assert(skew == x_skew);
+// assert(kurtosis == x_kurtosis);
+ }
+ {
+ typedef std::binomial_distribution<> D;
+ typedef std::mt19937 G;
+ G g;
+ D d(0, 1);
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v <= d.max());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ // In this case:
+ // skew computes to 0./0. == nan
+ // kurtosis computes to 0./0. == nan
+ // x_skew == -inf
+ // x_kurtosis == inf
+ // These tests are commented out because UBSan warns about division by 0
+// skew /= u.size() * dev * var;
+// kurtosis /= u.size() * var * var;
+// kurtosis -= 3;
+ double x_mean = d.t() * d.p();
+ double x_var = x_mean*(1-d.p());
+// double x_skew = (1-2*d.p()) / std::sqrt(x_var);
+// double x_kurtosis = (1-6*d.p()*(1-d.p())) / x_var;
+ assert(mean == x_mean);
+ assert(var == x_var);
+// assert(skew == x_skew);
+// assert(kurtosis == x_kurtosis);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/eval_param.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/eval_param.pass.cpp
new file mode 100644
index 000000000000..1aa66ed57ad1
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/eval_param.pass.cpp
@@ -0,0 +1,160 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// REQUIRES: long_tests
+
+// <random>
+
+// template<class IntType = int>
+// class binomial_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g, const param_type& parm);
+
+#include <random>
+#include <numeric>
+#include <vector>
+#include <cassert>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+ return x * x;
+}
+
+int main()
+{
+ {
+ typedef std::binomial_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937_64 G;
+ G g;
+ D d(16, .75);
+ P p(5, .75);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, p);
+ assert(0 <= v && v <= p.t());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = p.t() * p.p();
+ double x_var = x_mean*(1-p.p());
+ double x_skew = (1-2*p.p()) / std::sqrt(x_var);
+ double x_kurtosis = (1-6*p.p()*(1-p.p())) / x_var;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.04);
+ }
+ {
+ typedef std::binomial_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(16, .75);
+ P p(30, .03125);
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, p);
+ assert(0 <= v && v <= p.t());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = p.t() * p.p();
+ double x_var = x_mean*(1-p.p());
+ double x_skew = (1-2*p.p()) / std::sqrt(x_var);
+ double x_kurtosis = (1-6*p.p()*(1-p.p())) / x_var;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ {
+ typedef std::binomial_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(16, .75);
+ P p(40, .25);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, p);
+ assert(0 <= v && v <= p.t());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = p.t() * p.p();
+ double x_var = x_mean*(1-p.p());
+ double x_skew = (1-2*p.p()) / std::sqrt(x_var);
+ double x_kurtosis = (1-6*p.p()*(1-p.p())) / x_var;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.04);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.3);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/get_param.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/get_param.pass.cpp
new file mode 100644
index 000000000000..88c8424b0934
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/get_param.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class binomial_distribution
+
+// param_type param() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::binomial_distribution<> D;
+ typedef D::param_type P;
+ P p(5, .125);
+ D d(p);
+ assert(d.param() == p);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/io.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/io.pass.cpp
new file mode 100644
index 000000000000..1276454b597b
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/io.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class binomial_distribution
+
+// template <class charT, class traits>
+// basic_ostream<charT, traits>&
+// operator<<(basic_ostream<charT, traits>& os,
+// const binomial_distribution& x);
+//
+// template <class charT, class traits>
+// basic_istream<charT, traits>&
+// operator>>(basic_istream<charT, traits>& is,
+// binomial_distribution& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::binomial_distribution<> D;
+ D d1(7, .25);
+ std::ostringstream os;
+ os << d1;
+ std::istringstream is(os.str());
+ D d2;
+ is >> d2;
+ assert(d1 == d2);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/max.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/max.pass.cpp
new file mode 100644
index 000000000000..9c88faabe60b
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/max.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class binomial_distribution
+
+// result_type max() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::binomial_distribution<> D;
+ D d(4, .25);
+ assert(d.max() == 4);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/min.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/min.pass.cpp
new file mode 100644
index 000000000000..678a34b2f54b
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/min.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class binomial_distribution
+
+// result_type min() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::binomial_distribution<> D;
+ D d(4, .5);
+ assert(d.min() == 0);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/param_assign.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/param_assign.pass.cpp
new file mode 100644
index 000000000000..553f8ad82689
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/param_assign.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class binomial_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::binomial_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p0(6, .7);
+ param_type p;
+ p = p0;
+ assert(p.t() == 6);
+ assert(p.p() == .7);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/param_copy.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/param_copy.pass.cpp
new file mode 100644
index 000000000000..a9770efa282f
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/param_copy.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class binomial_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::binomial_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p0(10, .125);
+ param_type p = p0;
+ assert(p.t() == 10);
+ assert(p.p() == .125);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/param_ctor.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/param_ctor.pass.cpp
new file mode 100644
index 000000000000..cadf84a89044
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/param_ctor.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class binomial_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::binomial_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p;
+ assert(p.t() == 1);
+ assert(p.p() == 0.5);
+ }
+ {
+ typedef std::binomial_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p(10);
+ assert(p.t() == 10);
+ assert(p.p() == 0.5);
+ }
+ {
+ typedef std::binomial_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p(10, 0.25);
+ assert(p.t() == 10);
+ assert(p.p() == 0.25);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/param_eq.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/param_eq.pass.cpp
new file mode 100644
index 000000000000..3c2c1faa5c1b
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/param_eq.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class binomial_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::binomial_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p1(3, 0.75);
+ param_type p2(3, 0.75);
+ assert(p1 == p2);
+ }
+ {
+ typedef std::binomial_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p1(3, 0.75);
+ param_type p2(3, 0.5);
+ assert(p1 != p2);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/param_types.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/param_types.pass.cpp
new file mode 100644
index 000000000000..6c745611cd44
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/param_types.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class binomial_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::binomial_distribution<> D;
+ typedef D::param_type param_type;
+ typedef param_type::distribution_type distribution_type;
+ static_assert((std::is_same<D, distribution_type>::value), "");
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/set_param.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/set_param.pass.cpp
new file mode 100644
index 000000000000..612f5e2def02
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/set_param.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class binomial_distribution
+
+// void param(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::binomial_distribution<> D;
+ typedef D::param_type P;
+ P p(10, 0.25);
+ D d(8, 0.75);
+ d.param(p);
+ assert(d.param() == p);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/types.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/types.pass.cpp
new file mode 100644
index 000000000000..0e71aa019e7e
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/types.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class binomial_distribution
+// {
+// typedef bool result_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::binomial_distribution<> D;
+ typedef D::result_type result_type;
+ static_assert((std::is_same<result_type, int>::value), "");
+ }
+ {
+ typedef std::binomial_distribution<long> D;
+ typedef D::result_type result_type;
+ static_assert((std::is_same<result_type, long>::value), "");
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/assign.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/assign.pass.cpp
new file mode 100644
index 000000000000..f71b37482ca7
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/assign.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class geometric_distribution
+
+// geometric_distribution& operator=(const geometric_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::geometric_distribution<> D;
+ D d1(0.75);
+ D d2;
+ assert(d1 != d2);
+ d2 = d1;
+ assert(d1 == d2);
+}
+
+int main()
+{
+ test1();
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/copy.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/copy.pass.cpp
new file mode 100644
index 000000000000..00f3d04aefdb
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/copy.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class geometric_distribution
+
+// geometric_distribution(const geometric_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::geometric_distribution<> D;
+ D d1(0.75);
+ D d2 = d1;
+ assert(d1 == d2);
+}
+
+int main()
+{
+ test1();
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/ctor_double.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/ctor_double.pass.cpp
new file mode 100644
index 000000000000..461542896ecf
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/ctor_double.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class geometric_distribution
+
+// explicit geometric_distribution(double p = 0.5);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::geometric_distribution<> D;
+ D d;
+ assert(d.p() == 0.5);
+ }
+ {
+ typedef std::geometric_distribution<> D;
+ D d(0.75);
+ assert(d.p() == 0.75);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/ctor_param.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/ctor_param.pass.cpp
new file mode 100644
index 000000000000..5cf93eb4646f
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/ctor_param.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class geometric_distribution
+
+// explicit geometric_distribution(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::geometric_distribution<> D;
+ typedef D::param_type P;
+ P p(0.25);
+ D d(p);
+ assert(d.p() == 0.25);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/eq.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/eq.pass.cpp
new file mode 100644
index 000000000000..38d423bb5f76
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/eq.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class geometric_distribution
+
+// bool operator=(const geometric_distribution& x,
+// const geometric_distribution& y);
+// bool operator!(const geometric_distribution& x,
+// const geometric_distribution& y);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::geometric_distribution<> D;
+ D d1(.25);
+ D d2(.25);
+ assert(d1 == d2);
+ }
+ {
+ typedef std::geometric_distribution<> D;
+ D d1(.28);
+ D d2(.25);
+ assert(d1 != d2);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/eval.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/eval.pass.cpp
new file mode 100644
index 000000000000..a8ef221e3b67
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/eval.pass.cpp
@@ -0,0 +1,274 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// REQUIRES: long_tests
+
+// <random>
+
+// template<class IntType = int>
+// class geometric_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g);
+
+#include <random>
+#include <numeric>
+#include <vector>
+#include <cassert>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+ return x * x;
+}
+
+int main()
+{
+ {
+ typedef std::geometric_distribution<> D;
+ typedef std::mt19937 G;
+ G g;
+ D d(.03125);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v <= d.max());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = (1 - d.p()) / d.p();
+ double x_var = x_mean / d.p();
+ double x_skew = (2 - d.p()) / std::sqrt((1 - d.p()));
+ double x_kurtosis = 6 + sqr(d.p()) / (1 - d.p());
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ {
+ typedef std::geometric_distribution<> D;
+ typedef std::mt19937 G;
+ G g;
+ D d(0.05);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v <= d.max());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = (1 - d.p()) / d.p();
+ double x_var = x_mean / d.p();
+ double x_skew = (2 - d.p()) / std::sqrt((1 - d.p()));
+ double x_kurtosis = 6 + sqr(d.p()) / (1 - d.p());
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.03);
+ }
+ {
+ typedef std::geometric_distribution<> D;
+ typedef std::minstd_rand G;
+ G g;
+ D d(.25);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v <= d.max());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = (1 - d.p()) / d.p();
+ double x_var = x_mean / d.p();
+ double x_skew = (2 - d.p()) / std::sqrt((1 - d.p()));
+ double x_kurtosis = 6 + sqr(d.p()) / (1 - d.p());
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.02);
+ }
+ {
+ typedef std::geometric_distribution<> D;
+ typedef std::mt19937 G;
+ G g;
+ D d(0.5);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v <= d.max());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = (1 - d.p()) / d.p();
+ double x_var = x_mean / d.p();
+ double x_skew = (2 - d.p()) / std::sqrt((1 - d.p()));
+ double x_kurtosis = 6 + sqr(d.p()) / (1 - d.p());
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.02);
+ }
+ {
+ typedef std::geometric_distribution<> D;
+ typedef std::mt19937 G;
+ G g;
+ D d(0.75);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v <= d.max());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = (1 - d.p()) / d.p();
+ double x_var = x_mean / d.p();
+ double x_skew = (2 - d.p()) / std::sqrt((1 - d.p()));
+ double x_kurtosis = 6 + sqr(d.p()) / (1 - d.p());
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.02);
+ }
+ {
+ typedef std::geometric_distribution<> D;
+ typedef std::mt19937 G;
+ G g;
+ D d(0.96875);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v <= d.max());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = (1 - d.p()) / d.p();
+ double x_var = x_mean / d.p();
+ double x_skew = (2 - d.p()) / std::sqrt((1 - d.p()));
+ double x_kurtosis = 6 + sqr(d.p()) / (1 - d.p());
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.02);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/eval_param.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/eval_param.pass.cpp
new file mode 100644
index 000000000000..91dea8aa1337
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/eval_param.pass.cpp
@@ -0,0 +1,160 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// REQUIRES: long_tests
+
+// <random>
+
+// template<class IntType = int>
+// class geometric_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g, const param_type& parm);
+
+#include <random>
+#include <numeric>
+#include <vector>
+#include <cassert>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+ return x * x;
+}
+
+int main()
+{
+ {
+ typedef std::geometric_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(.75);
+ P p(.03125);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, p);
+ assert(d.min() <= v && v <= d.max());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = (1 - p.p()) / p.p();
+ double x_var = x_mean / p.p();
+ double x_skew = (2 - p.p()) / std::sqrt((1 - p.p()));
+ double x_kurtosis = 6 + sqr(p.p()) / (1 - p.p());
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ {
+ typedef std::geometric_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(.75);
+ P p(.25);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, p);
+ assert(d.min() <= v && v <= d.max());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = (1 - p.p()) / p.p();
+ double x_var = x_mean / p.p();
+ double x_skew = (2 - p.p()) / std::sqrt((1 - p.p()));
+ double x_kurtosis = 6 + sqr(p.p()) / (1 - p.p());
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.03);
+ }
+ {
+ typedef std::geometric_distribution<> D;
+ typedef D::param_type P;
+ typedef std::minstd_rand G;
+ G g;
+ D d(.5);
+ P p(.75);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, p);
+ assert(d.min() <= v && v <= d.max());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = (1 - p.p()) / p.p();
+ double x_var = x_mean / p.p();
+ double x_skew = (2 - p.p()) / std::sqrt((1 - p.p()));
+ double x_kurtosis = 6 + sqr(p.p()) / (1 - p.p());
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.02);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/get_param.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/get_param.pass.cpp
new file mode 100644
index 000000000000..00797a119968
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/get_param.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class geometric_distribution
+
+// param_type param() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::geometric_distribution<> D;
+ typedef D::param_type P;
+ P p(.125);
+ D d(p);
+ assert(d.param() == p);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/io.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/io.pass.cpp
new file mode 100644
index 000000000000..3e3752af7b13
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/io.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class geometric_distribution
+
+// template <class charT, class traits>
+// basic_ostream<charT, traits>&
+// operator<<(basic_ostream<charT, traits>& os,
+// const geometric_distribution& x);
+//
+// template <class charT, class traits>
+// basic_istream<charT, traits>&
+// operator>>(basic_istream<charT, traits>& is,
+// geometric_distribution& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::geometric_distribution<> D;
+ D d1(.25);
+ std::ostringstream os;
+ os << d1;
+ std::istringstream is(os.str());
+ D d2;
+ is >> d2;
+ assert(d1 == d2);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/max.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/max.pass.cpp
new file mode 100644
index 000000000000..b381bc438ad8
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/max.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class geometric_distribution
+
+// result_type max() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::geometric_distribution<> D;
+ D d(.25);
+ assert(d.max() == std::numeric_limits<int>::max());
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/min.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/min.pass.cpp
new file mode 100644
index 000000000000..56b75a7f8666
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/min.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class geometric_distribution
+
+// result_type min() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::geometric_distribution<> D;
+ D d(.5);
+ assert(d.min() == 0);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/param_assign.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/param_assign.pass.cpp
new file mode 100644
index 000000000000..98b84d59ab4d
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/param_assign.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class geometric_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::geometric_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p0(.7);
+ param_type p;
+ p = p0;
+ assert(p.p() == .7);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/param_copy.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/param_copy.pass.cpp
new file mode 100644
index 000000000000..4397aecfb39c
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/param_copy.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class geometric_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::geometric_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p0(.125);
+ param_type p = p0;
+ assert(p.p() == .125);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/param_ctor.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/param_ctor.pass.cpp
new file mode 100644
index 000000000000..c78525fea303
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/param_ctor.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class geometric_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::geometric_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p;
+ assert(p.p() == 0.5);
+ }
+ {
+ typedef std::geometric_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p(0.25);
+ assert(p.p() == 0.25);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/param_eq.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/param_eq.pass.cpp
new file mode 100644
index 000000000000..374f2b0b8e97
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/param_eq.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class geometric_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::geometric_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p1(0.75);
+ param_type p2(0.75);
+ assert(p1 == p2);
+ }
+ {
+ typedef std::geometric_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p1(0.75);
+ param_type p2(0.5);
+ assert(p1 != p2);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/param_types.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/param_types.pass.cpp
new file mode 100644
index 000000000000..33a4c6fff6ca
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/param_types.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class geometric_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::geometric_distribution<> D;
+ typedef D::param_type param_type;
+ typedef param_type::distribution_type distribution_type;
+ static_assert((std::is_same<D, distribution_type>::value), "");
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/set_param.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/set_param.pass.cpp
new file mode 100644
index 000000000000..e8aee01fbea8
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/set_param.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class geometric_distribution
+
+// void param(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::geometric_distribution<> D;
+ typedef D::param_type P;
+ P p(0.25);
+ D d(0.75);
+ d.param(p);
+ assert(d.param() == p);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/types.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/types.pass.cpp
new file mode 100644
index 000000000000..367e3f9871ef
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/types.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class geometric_distribution
+// {
+// typedef bool result_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::geometric_distribution<> D;
+ typedef D::result_type result_type;
+ static_assert((std::is_same<result_type, int>::value), "");
+ }
+ {
+ typedef std::geometric_distribution<long> D;
+ typedef D::result_type result_type;
+ static_assert((std::is_same<result_type, long>::value), "");
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/assign.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/assign.pass.cpp
new file mode 100644
index 000000000000..f62c52eca851
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/assign.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class negative_binomial_distribution
+
+// negative_binomial_distribution& operator=(const negative_binomial_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::negative_binomial_distribution<> D;
+ D d1(2, 0.75);
+ D d2;
+ assert(d1 != d2);
+ d2 = d1;
+ assert(d1 == d2);
+}
+
+int main()
+{
+ test1();
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/copy.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/copy.pass.cpp
new file mode 100644
index 000000000000..37c003d353e3
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/copy.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class negative_binomial_distribution
+
+// negative_binomial_distribution(const negative_binomial_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::negative_binomial_distribution<> D;
+ D d1(2, 0.75);
+ D d2 = d1;
+ assert(d1 == d2);
+}
+
+int main()
+{
+ test1();
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/ctor_int_double.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/ctor_int_double.pass.cpp
new file mode 100644
index 000000000000..babf1d464a40
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/ctor_int_double.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class negative_binomial_distribution
+
+// explicit negative_binomial_distribution(IntType t = 1, double p = 0.5);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::negative_binomial_distribution<> D;
+ D d;
+ assert(d.k() == 1);
+ assert(d.p() == 0.5);
+ }
+ {
+ typedef std::negative_binomial_distribution<> D;
+ D d(3);
+ assert(d.k() == 3);
+ assert(d.p() == 0.5);
+ }
+ {
+ typedef std::negative_binomial_distribution<> D;
+ D d(3, 0.75);
+ assert(d.k() == 3);
+ assert(d.p() == 0.75);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/ctor_param.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/ctor_param.pass.cpp
new file mode 100644
index 000000000000..109a47e87183
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/ctor_param.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class negative_binomial_distribution
+
+// explicit negative_binomial_distribution(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::negative_binomial_distribution<> D;
+ typedef D::param_type P;
+ P p(5, 0.25);
+ D d(p);
+ assert(d.k() == 5);
+ assert(d.p() == 0.25);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/eq.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/eq.pass.cpp
new file mode 100644
index 000000000000..0bf34eed6db9
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/eq.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class negative_binomial_distribution
+
+// bool operator=(const negative_binomial_distribution& x,
+// const negative_binomial_distribution& y);
+// bool operator!(const negative_binomial_distribution& x,
+// const negative_binomial_distribution& y);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::negative_binomial_distribution<> D;
+ D d1(3, .25);
+ D d2(3, .25);
+ assert(d1 == d2);
+ }
+ {
+ typedef std::negative_binomial_distribution<> D;
+ D d1(3, .28);
+ D d2(3, .25);
+ assert(d1 != d2);
+ }
+ {
+ typedef std::negative_binomial_distribution<> D;
+ D d1(3, .25);
+ D d2(4, .25);
+ assert(d1 != d2);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/eval.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/eval.pass.cpp
new file mode 100644
index 000000000000..853161e9f9b7
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/eval.pass.cpp
@@ -0,0 +1,272 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// REQUIRES: long_tests
+
+// <random>
+
+// template<class IntType = int>
+// class negative_binomial_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g);
+
+#include <random>
+#include <numeric>
+#include <vector>
+#include <cassert>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+ return x * x;
+}
+
+int main()
+{
+ {
+ typedef std::negative_binomial_distribution<> D;
+ typedef std::minstd_rand G;
+ G g;
+ D d(5, .25);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v <= d.max());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = d.k() * (1 - d.p()) / d.p();
+ double x_var = x_mean / d.p();
+ double x_skew = (2 - d.p()) / std::sqrt(d.k() * (1 - d.p()));
+ double x_kurtosis = 6. / d.k() + sqr(d.p()) / (d.k() * (1 - d.p()));
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.02);
+ }
+ {
+ typedef std::negative_binomial_distribution<> D;
+ typedef std::mt19937 G;
+ G g;
+ D d(30, .03125);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v <= d.max());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = d.k() * (1 - d.p()) / d.p();
+ double x_var = x_mean / d.p();
+ double x_skew = (2 - d.p()) / std::sqrt(d.k() * (1 - d.p()));
+ double x_kurtosis = 6. / d.k() + sqr(d.p()) / (d.k() * (1 - d.p()));
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ {
+ typedef std::negative_binomial_distribution<> D;
+ typedef std::mt19937 G;
+ G g;
+ D d(40, .25);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v <= d.max());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = d.k() * (1 - d.p()) / d.p();
+ double x_var = x_mean / d.p();
+ double x_skew = (2 - d.p()) / std::sqrt(d.k() * (1 - d.p()));
+ double x_kurtosis = 6. / d.k() + sqr(d.p()) / (d.k() * (1 - d.p()));
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.03);
+ }
+ {
+ typedef std::negative_binomial_distribution<> D;
+ typedef std::mt19937 G;
+ G g;
+ D d(40, 1);
+ const int N = 1000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v <= d.max());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = d.k() * (1 - d.p()) / d.p();
+ double x_var = x_mean / d.p();
+ double x_skew = (2 - d.p()) / std::sqrt(d.k() * (1 - d.p()));
+ double x_kurtosis = 6. / d.k() + sqr(d.p()) / (d.k() * (1 - d.p()));
+ assert(mean == x_mean);
+ assert(var == x_var);
+ }
+ {
+ typedef std::negative_binomial_distribution<> D;
+ typedef std::mt19937 G;
+ G g;
+ D d(400, 0.5);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v <= d.max());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = d.k() * (1 - d.p()) / d.p();
+ double x_var = x_mean / d.p();
+ double x_skew = (2 - d.p()) / std::sqrt(d.k() * (1 - d.p()));
+ double x_kurtosis = 6. / d.k() + sqr(d.p()) / (d.k() * (1 - d.p()));
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.04);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.05);
+ }
+ {
+ typedef std::negative_binomial_distribution<> D;
+ typedef std::mt19937 G;
+ G g;
+ D d(1, 0.05);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v <= d.max());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = d.k() * (1 - d.p()) / d.p();
+ double x_var = x_mean / d.p();
+ double x_skew = (2 - d.p()) / std::sqrt(d.k() * (1 - d.p()));
+ double x_kurtosis = 6. / d.k() + sqr(d.p()) / (d.k() * (1 - d.p()));
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.03);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/eval_param.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/eval_param.pass.cpp
new file mode 100644
index 000000000000..f2f2a07879e2
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/eval_param.pass.cpp
@@ -0,0 +1,160 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// REQUIRES: long_tests
+
+// <random>
+
+// template<class IntType = int>
+// class negative_binomial_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g, const param_type& parm);
+
+#include <random>
+#include <numeric>
+#include <vector>
+#include <cassert>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+ return x * x;
+}
+
+int main()
+{
+ {
+ typedef std::negative_binomial_distribution<> D;
+ typedef D::param_type P;
+ typedef std::minstd_rand G;
+ G g;
+ D d(16, .75);
+ P p(5, .75);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, p);
+ assert(d.min() <= v && v <= d.max());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = p.k() * (1 - p.p()) / p.p();
+ double x_var = x_mean / p.p();
+ double x_skew = (2 - p.p()) / std::sqrt(p.k() * (1 - p.p()));
+ double x_kurtosis = 6. / p.k() + sqr(p.p()) / (p.k() * (1 - p.p()));
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ {
+ typedef std::negative_binomial_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(16, .75);
+ P p(30, .03125);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, p);
+ assert(d.min() <= v && v <= d.max());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = p.k() * (1 - p.p()) / p.p();
+ double x_var = x_mean / p.p();
+ double x_skew = (2 - p.p()) / std::sqrt(p.k() * (1 - p.p()));
+ double x_kurtosis = 6. / p.k() + sqr(p.p()) / (p.k() * (1 - p.p()));
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ {
+ typedef std::negative_binomial_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(16, .75);
+ P p(40, .25);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, p);
+ assert(d.min() <= v && v <= d.max());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = p.k() * (1 - p.p()) / p.p();
+ double x_var = x_mean / p.p();
+ double x_skew = (2 - p.p()) / std::sqrt(p.k() * (1 - p.p()));
+ double x_kurtosis = 6. / p.k() + sqr(p.p()) / (p.k() * (1 - p.p()));
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.03);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/get_param.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/get_param.pass.cpp
new file mode 100644
index 000000000000..65f4a978cb05
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/get_param.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class negative_binomial_distribution
+
+// param_type param() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::negative_binomial_distribution<> D;
+ typedef D::param_type P;
+ P p(5, .125);
+ D d(p);
+ assert(d.param() == p);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/io.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/io.pass.cpp
new file mode 100644
index 000000000000..da5e8af616ec
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/io.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class negative_binomial_distribution
+
+// template <class charT, class traits>
+// basic_ostream<charT, traits>&
+// operator<<(basic_ostream<charT, traits>& os,
+// const negative_binomial_distribution& x);
+//
+// template <class charT, class traits>
+// basic_istream<charT, traits>&
+// operator>>(basic_istream<charT, traits>& is,
+// negative_binomial_distribution& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::negative_binomial_distribution<> D;
+ D d1(7, .25);
+ std::ostringstream os;
+ os << d1;
+ std::istringstream is(os.str());
+ D d2;
+ is >> d2;
+ assert(d1 == d2);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/max.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/max.pass.cpp
new file mode 100644
index 000000000000..2fe7184e6ec9
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/max.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class negative_binomial_distribution
+
+// result_type max() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::negative_binomial_distribution<> D;
+ D d(4, .25);
+ assert(d.max() == std::numeric_limits<int>::max());
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/min.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/min.pass.cpp
new file mode 100644
index 000000000000..15bec5a7dc6a
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/min.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class negative_binomial_distribution
+
+// result_type min() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::negative_binomial_distribution<> D;
+ D d(4, .5);
+ assert(d.min() == 0);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_assign.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_assign.pass.cpp
new file mode 100644
index 000000000000..dc4d35c700ae
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_assign.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class negative_binomial_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::negative_binomial_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p0(6, .7);
+ param_type p;
+ p = p0;
+ assert(p.k() == 6);
+ assert(p.p() == .7);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_copy.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_copy.pass.cpp
new file mode 100644
index 000000000000..ec5af5b85030
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_copy.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class negative_binomial_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::negative_binomial_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p0(10, .125);
+ param_type p = p0;
+ assert(p.k() == 10);
+ assert(p.p() == .125);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_ctor.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_ctor.pass.cpp
new file mode 100644
index 000000000000..6d713ce71b23
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_ctor.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class negative_binomial_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::negative_binomial_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p;
+ assert(p.k() == 1);
+ assert(p.p() == 0.5);
+ }
+ {
+ typedef std::negative_binomial_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p(10);
+ assert(p.k() == 10);
+ assert(p.p() == 0.5);
+ }
+ {
+ typedef std::negative_binomial_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p(10, 0.25);
+ assert(p.k() == 10);
+ assert(p.p() == 0.25);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_eq.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_eq.pass.cpp
new file mode 100644
index 000000000000..b0f81cdfa7a0
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_eq.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class negative_binomial_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::negative_binomial_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p1(3, 0.75);
+ param_type p2(3, 0.75);
+ assert(p1 == p2);
+ }
+ {
+ typedef std::negative_binomial_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p1(3, 0.75);
+ param_type p2(3, 0.5);
+ assert(p1 != p2);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_types.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_types.pass.cpp
new file mode 100644
index 000000000000..282ca190c232
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_types.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class negative_binomial_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::negative_binomial_distribution<> D;
+ typedef D::param_type param_type;
+ typedef param_type::distribution_type distribution_type;
+ static_assert((std::is_same<D, distribution_type>::value), "");
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/set_param.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/set_param.pass.cpp
new file mode 100644
index 000000000000..05c204f5c649
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/set_param.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class negative_binomial_distribution
+
+// void param(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::negative_binomial_distribution<> D;
+ typedef D::param_type P;
+ P p(10, 0.25);
+ D d(8, 0.75);
+ d.param(p);
+ assert(d.param() == p);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/types.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/types.pass.cpp
new file mode 100644
index 000000000000..149f5075236d
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/types.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class negative_binomial_distribution
+// {
+// typedef bool result_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::negative_binomial_distribution<> D;
+ typedef D::result_type result_type;
+ static_assert((std::is_same<result_type, int>::value), "");
+ }
+ {
+ typedef std::negative_binomial_distribution<long> D;
+ typedef D::result_type result_type;
+ static_assert((std::is_same<result_type, long>::value), "");
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/nothing_to_do.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/assign.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/assign.pass.cpp
new file mode 100644
index 000000000000..3003e0db94d1
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/assign.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class cauchy_distribution
+
+// cauchy_distribution& operator=(const cauchy_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::cauchy_distribution<> D;
+ D d1(.5, 2);
+ D d2;
+ assert(d1 != d2);
+ d2 = d1;
+ assert(d1 == d2);
+}
+
+int main()
+{
+ test1();
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/copy.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/copy.pass.cpp
new file mode 100644
index 000000000000..032191493e54
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/copy.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class cauchy_distribution
+
+// cauchy_distribution(const cauchy_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::cauchy_distribution<> D;
+ D d1(.5, 1.75);
+ D d2 = d1;
+ assert(d1 == d2);
+}
+
+int main()
+{
+ test1();
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/ctor_double_double.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/ctor_double_double.pass.cpp
new file mode 100644
index 000000000000..a0406b026b96
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/ctor_double_double.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class cauchy_distribution
+
+// explicit cauchy_distribution(result_type a = 0, result_type b = 1);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::cauchy_distribution<> D;
+ D d;
+ assert(d.a() == 0);
+ assert(d.b() == 1);
+ }
+ {
+ typedef std::cauchy_distribution<> D;
+ D d(14.5);
+ assert(d.a() == 14.5);
+ assert(d.b() == 1);
+ }
+ {
+ typedef std::cauchy_distribution<> D;
+ D d(14.5, 5.25);
+ assert(d.a() == 14.5);
+ assert(d.b() == 5.25);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/ctor_param.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/ctor_param.pass.cpp
new file mode 100644
index 000000000000..0973b60a7248
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/ctor_param.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class cauchy_distribution
+
+// explicit cauchy_distribution(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::cauchy_distribution<> D;
+ typedef D::param_type P;
+ P p(0.25, 10);
+ D d(p);
+ assert(d.a() == 0.25);
+ assert(d.b() == 10);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/eq.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/eq.pass.cpp
new file mode 100644
index 000000000000..005e141b46c0
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/eq.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class cauchy_distribution
+
+// bool operator=(const cauchy_distribution& x,
+// const cauchy_distribution& y);
+// bool operator!(const cauchy_distribution& x,
+// const cauchy_distribution& y);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::cauchy_distribution<> D;
+ D d1(2.5, 4);
+ D d2(2.5, 4);
+ assert(d1 == d2);
+ }
+ {
+ typedef std::cauchy_distribution<> D;
+ D d1(2.5, 4);
+ D d2(2.5, 4.5);
+ assert(d1 != d2);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/eval.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/eval.pass.cpp
new file mode 100644
index 000000000000..d70d8f072c39
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/eval.pass.cpp
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// REQUIRES: long_tests
+
+// <random>
+
+// template<class RealType = double>
+// class cauchy_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g);
+
+#include <random>
+#include <cassert>
+#include <vector>
+#include <algorithm>
+
+double
+f(double x, double a, double b)
+{
+ return 1/3.1415926535897932 * std::atan((x - a)/b) + .5;
+}
+
+int main()
+{
+ {
+ typedef std::cauchy_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ const double a = 10;
+ const double b = .5;
+ D d(a, b);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ u.push_back(d(g));
+ std::sort(u.begin(), u.end());
+ for (int i = 0; i < N; ++i)
+ assert(std::abs(f(u[i], a, b) - double(i)/N) < .001);
+ }
+ {
+ typedef std::cauchy_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ const double a = -1.5;
+ const double b = 1;
+ D d(a, b);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ u.push_back(d(g));
+ std::sort(u.begin(), u.end());
+ for (int i = 0; i < N; ++i)
+ assert(std::abs(f(u[i], a, b) - double(i)/N) < .001);
+ }
+ {
+ typedef std::cauchy_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ const double a = .5;
+ const double b = 2;
+ D d(a, b);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ u.push_back(d(g));
+ std::sort(u.begin(), u.end());
+ for (int i = 0; i < N; ++i)
+ assert(std::abs(f(u[i], a, b) - double(i)/N) < .001);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/eval_param.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/eval_param.pass.cpp
new file mode 100644
index 000000000000..318c29e7694e
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/eval_param.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// REQUIRES: long_tests
+
+// <random>
+
+// template<class RealType = double>
+// class cauchy_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g, const param_type& parm);
+
+#include <random>
+#include <cassert>
+#include <vector>
+#include <algorithm>
+
+double
+f(double x, double a, double b)
+{
+ return 1/3.1415926535897932 * std::atan((x - a)/b) + .5;
+}
+
+int main()
+{
+ {
+ typedef std::cauchy_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ const double a = 10;
+ const double b = .5;
+ D d;
+ P p(a, b);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ u.push_back(d(g, p));
+ std::sort(u.begin(), u.end());
+ for (int i = 0; i < N; ++i)
+ assert(std::abs(f(u[i], a, b) - double(i)/N) < .001);
+ }
+ {
+ typedef std::cauchy_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ const double a = -1.5;
+ const double b = 1;
+ D d;
+ P p(a, b);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ u.push_back(d(g, p));
+ std::sort(u.begin(), u.end());
+ for (int i = 0; i < N; ++i)
+ assert(std::abs(f(u[i], a, b) - double(i)/N) < .001);
+ }
+ {
+ typedef std::cauchy_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ const double a = .5;
+ const double b = 2;
+ D d;
+ P p(a, b);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ u.push_back(d(g, p));
+ std::sort(u.begin(), u.end());
+ for (int i = 0; i < N; ++i)
+ assert(std::abs(f(u[i], a, b) - double(i)/N) < .001);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/get_param.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/get_param.pass.cpp
new file mode 100644
index 000000000000..0e2d6b049f67
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/get_param.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class cauchy_distribution
+
+// param_type param() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::cauchy_distribution<> D;
+ typedef D::param_type P;
+ P p(.125, .5);
+ D d(p);
+ assert(d.param() == p);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/io.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/io.pass.cpp
new file mode 100644
index 000000000000..ca53792c6af8
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/io.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class cauchy_distribution
+
+// template <class CharT, class Traits, class RealType>
+// basic_ostream<CharT, Traits>&
+// operator<<(basic_ostream<CharT, Traits>& os,
+// const cauchy_distribution<RealType>& x);
+
+// template <class CharT, class Traits, class RealType>
+// basic_istream<CharT, Traits>&
+// operator>>(basic_istream<CharT, Traits>& is,
+// cauchy_distribution<RealType>& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::cauchy_distribution<> D;
+ D d1(7.5, 5.5);
+ std::ostringstream os;
+ os << d1;
+ std::istringstream is(os.str());
+ D d2;
+ is >> d2;
+ assert(d1 == d2);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/max.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/max.pass.cpp
new file mode 100644
index 000000000000..263c1773a8f0
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/max.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class cauchy_distribution
+
+// result_type max() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::cauchy_distribution<> D;
+ D d(5, .25);
+ D::result_type m = d.max();
+ assert(m == INFINITY);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/min.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/min.pass.cpp
new file mode 100644
index 000000000000..0d52179ae7e3
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/min.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class cauchy_distribution
+
+// result_type min() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::cauchy_distribution<> D;
+ D d(.5, .5);
+ assert(d.min() == -INFINITY);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/param_assign.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/param_assign.pass.cpp
new file mode 100644
index 000000000000..f8e0852834d3
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/param_assign.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class cauchy_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::cauchy_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p0(.75, 6);
+ param_type p;
+ p = p0;
+ assert(p.a() == .75);
+ assert(p.b() == 6);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/param_copy.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/param_copy.pass.cpp
new file mode 100644
index 000000000000..28ef06827757
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/param_copy.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class cauchy_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::cauchy_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p0(10, .125);
+ param_type p = p0;
+ assert(p.a() == 10);
+ assert(p.b() == .125);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/param_ctor.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/param_ctor.pass.cpp
new file mode 100644
index 000000000000..8ae5137aa3af
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/param_ctor.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class cauchy_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::cauchy_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p;
+ assert(p.a() == 0);
+ assert(p.b() == 1);
+ }
+ {
+ typedef std::cauchy_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p(10);
+ assert(p.a() == 10);
+ assert(p.b() == 1);
+ }
+ {
+ typedef std::cauchy_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p(10, 5);
+ assert(p.a() == 10);
+ assert(p.b() == 5);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/param_eq.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/param_eq.pass.cpp
new file mode 100644
index 000000000000..6210321fb343
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/param_eq.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class cauchy_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::cauchy_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p1(0.75, .5);
+ param_type p2(0.75, .5);
+ assert(p1 == p2);
+ }
+ {
+ typedef std::cauchy_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p1(0.75, .5);
+ param_type p2(0.5, .5);
+ assert(p1 != p2);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/param_types.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/param_types.pass.cpp
new file mode 100644
index 000000000000..56b1f6f91501
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/param_types.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class cauchy_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::cauchy_distribution<> D;
+ typedef D::param_type param_type;
+ typedef param_type::distribution_type distribution_type;
+ static_assert((std::is_same<D, distribution_type>::value), "");
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/set_param.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/set_param.pass.cpp
new file mode 100644
index 000000000000..201ec60b00e3
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/set_param.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class cauchy_distribution;
+
+// void param(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::cauchy_distribution<> D;
+ typedef D::param_type P;
+ P p(0.25, 5.5);
+ D d(0.75, 4);
+ d.param(p);
+ assert(d.param() == p);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/types.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/types.pass.cpp
new file mode 100644
index 000000000000..919a7b1b65b2
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/types.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class cauchy_distribution
+// {
+// public:
+// // types
+// typedef RealType result_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::cauchy_distribution<> D;
+ typedef D::result_type result_type;
+ static_assert((std::is_same<result_type, double>::value), "");
+ }
+ {
+ typedef std::cauchy_distribution<float> D;
+ typedef D::result_type result_type;
+ static_assert((std::is_same<result_type, float>::value), "");
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/assign.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/assign.pass.cpp
new file mode 100644
index 000000000000..0c3a0aed2df8
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/assign.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class chi_squared_distribution
+
+// chi_squared_distribution& operator=(const chi_squared_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::chi_squared_distribution<> D;
+ D d1(20.75);
+ D d2;
+ assert(d1 != d2);
+ d2 = d1;
+ assert(d1 == d2);
+}
+
+int main()
+{
+ test1();
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/copy.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/copy.pass.cpp
new file mode 100644
index 000000000000..9496184d4333
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/copy.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class chi_squared_distribution
+
+// chi_squared_distribution(const chi_squared_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::chi_squared_distribution<> D;
+ D d1(21.75);
+ D d2 = d1;
+ assert(d1 == d2);
+}
+
+int main()
+{
+ test1();
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/ctor_double.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/ctor_double.pass.cpp
new file mode 100644
index 000000000000..27401d91e10c
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/ctor_double.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class chi_squared_distribution
+
+// explicit chi_squared_distribution(result_type alpha = 0, result_type beta = 1);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::chi_squared_distribution<> D;
+ D d;
+ assert(d.n() == 1);
+ }
+ {
+ typedef std::chi_squared_distribution<> D;
+ D d(14.5);
+ assert(d.n() == 14.5);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/ctor_param.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/ctor_param.pass.cpp
new file mode 100644
index 000000000000..afd5aa91c7cd
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/ctor_param.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class chi_squared_distribution
+
+// explicit chi_squared_distribution(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::chi_squared_distribution<> D;
+ typedef D::param_type P;
+ P p(0.25);
+ D d(p);
+ assert(d.n() == 0.25);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/eq.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/eq.pass.cpp
new file mode 100644
index 000000000000..88630b0cf521
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/eq.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class chi_squared_distribution
+
+// bool operator=(const chi_squared_distribution& x,
+// const chi_squared_distribution& y);
+// bool operator!(const chi_squared_distribution& x,
+// const chi_squared_distribution& y);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::chi_squared_distribution<> D;
+ D d1(2.5);
+ D d2(2.5);
+ assert(d1 == d2);
+ }
+ {
+ typedef std::chi_squared_distribution<> D;
+ D d1(4);
+ D d2(4.5);
+ assert(d1 != d2);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/eval.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/eval.pass.cpp
new file mode 100644
index 000000000000..6fbdd93f8ffd
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/eval.pass.cpp
@@ -0,0 +1,154 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// REQUIRES: long_tests
+
+// <random>
+
+// template<class RealType = double>
+// class chi_squared_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g);
+
+#include <random>
+#include <cassert>
+#include <vector>
+#include <numeric>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+ return x * x;
+}
+
+int main()
+{
+ {
+ typedef std::chi_squared_distribution<> D;
+ typedef D::param_type P;
+ typedef std::minstd_rand G;
+ G g;
+ D d(0.5);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() < v);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = d.n();
+ double x_var = 2 * d.n();
+ double x_skew = std::sqrt(8 / d.n());
+ double x_kurtosis = 12 / d.n();
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ {
+ typedef std::chi_squared_distribution<> D;
+ typedef D::param_type P;
+ typedef std::minstd_rand G;
+ G g;
+ D d(1);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() < v);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = d.n();
+ double x_var = 2 * d.n();
+ double x_skew = std::sqrt(8 / d.n());
+ double x_kurtosis = 12 / d.n();
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ {
+ typedef std::chi_squared_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(2);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() < v);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = d.n();
+ double x_var = 2 * d.n();
+ double x_skew = std::sqrt(8 / d.n());
+ double x_kurtosis = 12 / d.n();
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/eval_param.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/eval_param.pass.cpp
new file mode 100644
index 000000000000..548848d19f3e
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/eval_param.pass.cpp
@@ -0,0 +1,157 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// REQUIRES: long_tests
+
+// <random>
+
+// template<class RealType = double>
+// class chi_squared_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g, const param_type& parm);
+
+#include <random>
+#include <cassert>
+#include <vector>
+#include <numeric>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+ return x * x;
+}
+
+int main()
+{
+ {
+ typedef std::chi_squared_distribution<> D;
+ typedef D::param_type P;
+ typedef std::minstd_rand G;
+ G g;
+ D d(0.5);
+ P p(1);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, p);
+ assert(d.min() < v);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = p.n();
+ double x_var = 2 * p.n();
+ double x_skew = std::sqrt(8 / p.n());
+ double x_kurtosis = 12 / p.n();
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ {
+ typedef std::chi_squared_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(1);
+ P p(2);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, p);
+ assert(d.min() < v);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = p.n();
+ double x_var = 2 * p.n();
+ double x_skew = std::sqrt(8 / p.n());
+ double x_kurtosis = 12 / p.n();
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ {
+ typedef std::chi_squared_distribution<> D;
+ typedef D::param_type P;
+ typedef std::minstd_rand G;
+ G g;
+ D d(2);
+ P p(.5);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, p);
+ assert(d.min() < v);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = p.n();
+ double x_var = 2 * p.n();
+ double x_skew = std::sqrt(8 / p.n());
+ double x_kurtosis = 12 / p.n();
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/get_param.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/get_param.pass.cpp
new file mode 100644
index 000000000000..f12a0519bfca
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/get_param.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class chi_squared_distribution
+
+// param_type param() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::chi_squared_distribution<> D;
+ typedef D::param_type P;
+ P p(.125);
+ D d(p);
+ assert(d.param() == p);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/io.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/io.pass.cpp
new file mode 100644
index 000000000000..de16fa1e1eb7
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/io.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class chi_squared_distribution
+
+// template <class CharT, class Traits, class RealType>
+// basic_ostream<CharT, Traits>&
+// operator<<(basic_ostream<CharT, Traits>& os,
+// const chi_squared_distribution<RealType>& x);
+
+// template <class CharT, class Traits, class RealType>
+// basic_istream<CharT, Traits>&
+// operator>>(basic_istream<CharT, Traits>& is,
+// chi_squared_distribution<RealType>& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::chi_squared_distribution<> D;
+ D d1(7);
+ std::ostringstream os;
+ os << d1;
+ std::istringstream is(os.str());
+ D d2;
+ is >> d2;
+ assert(d1 == d2);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/max.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/max.pass.cpp
new file mode 100644
index 000000000000..adf4f96ebec0
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/max.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class chi_squared_distribution
+
+// result_type max() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::chi_squared_distribution<> D;
+ D d(5);
+ D::result_type m = d.max();
+ assert(m == INFINITY);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/min.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/min.pass.cpp
new file mode 100644
index 000000000000..4e51590bbce6
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/min.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class chi_squared_distribution
+
+// result_type min() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::chi_squared_distribution<> D;
+ D d(.5);
+ assert(d.min() == 0);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/param_assign.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/param_assign.pass.cpp
new file mode 100644
index 000000000000..85730f619187
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/param_assign.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class chi_squared_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::chi_squared_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p0(.75);
+ param_type p;
+ p = p0;
+ assert(p.n() == .75);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/param_copy.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/param_copy.pass.cpp
new file mode 100644
index 000000000000..3ddb02b72713
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/param_copy.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class chi_squared_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::chi_squared_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p0(10);
+ param_type p = p0;
+ assert(p.n() == 10);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/param_ctor.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/param_ctor.pass.cpp
new file mode 100644
index 000000000000..34d8651156b6
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/param_ctor.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class chi_squared_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::chi_squared_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p;
+ assert(p.n() == 1);
+ }
+ {
+ typedef std::chi_squared_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p(10);
+ assert(p.n() == 10);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/param_eq.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/param_eq.pass.cpp
new file mode 100644
index 000000000000..cb738ea858a3
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/param_eq.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class chi_squared_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::chi_squared_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p1(0.75);
+ param_type p2(0.75);
+ assert(p1 == p2);
+ }
+ {
+ typedef std::chi_squared_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p1(0.75);
+ param_type p2(0.5);
+ assert(p1 != p2);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/param_types.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/param_types.pass.cpp
new file mode 100644
index 000000000000..257016b3c332
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/param_types.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class chi_squared_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::chi_squared_distribution<> D;
+ typedef D::param_type param_type;
+ typedef param_type::distribution_type distribution_type;
+ static_assert((std::is_same<D, distribution_type>::value), "");
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/set_param.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/set_param.pass.cpp
new file mode 100644
index 000000000000..a8d4e52b8bb7
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/set_param.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class chi_squared_distribution;
+
+// void param(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::chi_squared_distribution<> D;
+ typedef D::param_type P;
+ P p(0.25);
+ D d(0.75);
+ d.param(p);
+ assert(d.param() == p);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/types.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/types.pass.cpp
new file mode 100644
index 000000000000..614da1979ee5
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/types.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class chi_squared_distribution
+// {
+// public:
+// // types
+// typedef RealType result_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::chi_squared_distribution<> D;
+ typedef D::result_type result_type;
+ static_assert((std::is_same<result_type, double>::value), "");
+ }
+ {
+ typedef std::chi_squared_distribution<float> D;
+ typedef D::result_type result_type;
+ static_assert((std::is_same<result_type, float>::value), "");
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/assign.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/assign.pass.cpp
new file mode 100644
index 000000000000..f5294bdc54b1
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/assign.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class fisher_f_distribution
+
+// fisher_f_distribution& operator=(const fisher_f_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::fisher_f_distribution<> D;
+ D d1(20, 0.75);
+ D d2;
+ assert(d1 != d2);
+ d2 = d1;
+ assert(d1 == d2);
+}
+
+int main()
+{
+ test1();
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/copy.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/copy.pass.cpp
new file mode 100644
index 000000000000..047d5133583c
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/copy.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class fisher_f_distribution
+
+// fisher_f_distribution(const fisher_f_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::fisher_f_distribution<> D;
+ D d1(20, 1.75);
+ D d2 = d1;
+ assert(d1 == d2);
+}
+
+int main()
+{
+ test1();
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/ctor_double_double.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/ctor_double_double.pass.cpp
new file mode 100644
index 000000000000..1dd628b625aa
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/ctor_double_double.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class fisher_f_distribution
+
+// explicit fisher_f_distribution(result_type alpha = 0, result_type beta = 1);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::fisher_f_distribution<> D;
+ D d;
+ assert(d.m() == 1);
+ assert(d.n() == 1);
+ }
+ {
+ typedef std::fisher_f_distribution<> D;
+ D d(14.5);
+ assert(d.m() == 14.5);
+ assert(d.n() == 1);
+ }
+ {
+ typedef std::fisher_f_distribution<> D;
+ D d(14.5, 5.25);
+ assert(d.m() == 14.5);
+ assert(d.n() == 5.25);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/ctor_param.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/ctor_param.pass.cpp
new file mode 100644
index 000000000000..83a81cf4068b
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/ctor_param.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class fisher_f_distribution
+
+// explicit fisher_f_distribution(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::fisher_f_distribution<> D;
+ typedef D::param_type P;
+ P p(0.25, 10);
+ D d(p);
+ assert(d.m() == 0.25);
+ assert(d.n() == 10);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/eq.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/eq.pass.cpp
new file mode 100644
index 000000000000..405c906cbdc3
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/eq.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class fisher_f_distribution
+
+// bool operator=(const fisher_f_distribution& x,
+// const fisher_f_distribution& y);
+// bool operator!(const fisher_f_distribution& x,
+// const fisher_f_distribution& y);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::fisher_f_distribution<> D;
+ D d1(2.5, 4);
+ D d2(2.5, 4);
+ assert(d1 == d2);
+ }
+ {
+ typedef std::fisher_f_distribution<> D;
+ D d1(2.5, 4);
+ D d2(2.5, 4.5);
+ assert(d1 != d2);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/eval.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/eval.pass.cpp
new file mode 100644
index 000000000000..091bbb9bb452
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/eval.pass.cpp
@@ -0,0 +1,106 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// REQUIRES: long_tests
+
+// <random>
+
+// template<class RealType = double>
+// class fisher_f_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g);
+
+#include <random>
+#include <cassert>
+#include <vector>
+#include <algorithm>
+#include <cmath>
+
+double fac(double x)
+{
+ double r = 1;
+ for (; x > 1; --x)
+ r *= x;
+ return r;
+}
+
+double
+I(double x, unsigned a, unsigned b)
+{
+ double r = 0;
+ for (int j = a; j <= a+b-1; ++j)
+ r += fac(a+b-1)/(fac(j) * fac(a + b - 1 - j)) * std::pow(x, j) *
+ std::pow(1-x, a+b-1-j);
+ return r;
+}
+
+double
+f(double x, double m, double n)
+{
+ return I(m * x / (m*x + n), static_cast<unsigned>(m/2), static_cast<unsigned>(n/2));
+}
+
+int main()
+{
+ // Purposefully only testing even integral values of m and n (for now)
+ {
+ typedef std::fisher_f_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(2, 4);
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(v >= 0);
+ u.push_back(v);
+ }
+ std::sort(u.begin(), u.end());
+ for (int i = 0; i < N; ++i)
+ assert(std::abs(f(u[i], d.m(), d.n()) - double(i)/N) < .01);
+ }
+ {
+ typedef std::fisher_f_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(4, 2);
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(v >= 0);
+ u.push_back(v);
+ }
+ std::sort(u.begin(), u.end());
+ for (int i = 0; i < N; ++i)
+ assert(std::abs(f(u[i], d.m(), d.n()) - double(i)/N) < .01);
+ }
+ {
+ typedef std::fisher_f_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(18, 20);
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(v >= 0);
+ u.push_back(v);
+ }
+ std::sort(u.begin(), u.end());
+ for (int i = 0; i < N; ++i)
+ assert(std::abs(f(u[i], d.m(), d.n()) - double(i)/N) < .01);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/eval_param.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/eval_param.pass.cpp
new file mode 100644
index 000000000000..774137154e09
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/eval_param.pass.cpp
@@ -0,0 +1,109 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// REQUIRES: long_tests
+
+// <random>
+
+// template<class RealType = double>
+// class fisher_f_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g, const param_type& parm);
+
+#include <random>
+#include <cassert>
+#include <vector>
+#include <algorithm>
+#include <cmath>
+
+double fac(double x)
+{
+ double r = 1;
+ for (; x > 1; --x)
+ r *= x;
+ return r;
+}
+
+double
+I(double x, unsigned a, unsigned b)
+{
+ double r = 0;
+ for (int j = a; j <= a+b-1; ++j)
+ r += fac(a+b-1)/(fac(j) * fac(a + b - 1 - j)) * std::pow(x, j) *
+ std::pow(1-x, a+b-1-j);
+ return r;
+}
+
+double
+f(double x, double m, double n)
+{
+ return I(m * x / (m*x + n), static_cast<unsigned>(m/2), static_cast<unsigned>(n/2));
+}
+
+int main()
+{
+ // Purposefully only testing even integral values of m and n (for now)
+ {
+ typedef std::fisher_f_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(2, 4);
+ P p(4, 2);
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, p);
+ assert(v >= 0);
+ u.push_back(v);
+ }
+ std::sort(u.begin(), u.end());
+ for (int i = 0; i < N; ++i)
+ assert(std::abs(f(u[i], p.m(), p.n()) - double(i)/N) < .01);
+ }
+ {
+ typedef std::fisher_f_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(4, 2);
+ P p(6, 8);
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, p);
+ assert(v >= 0);
+ u.push_back(v);
+ }
+ std::sort(u.begin(), u.end());
+ for (int i = 0; i < N; ++i)
+ assert(std::abs(f(u[i], p.m(), p.n()) - double(i)/N) < .01);
+ }
+ {
+ typedef std::fisher_f_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(18, 20);
+ P p(16, 14);
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, p);
+ assert(v >= 0);
+ u.push_back(v);
+ }
+ std::sort(u.begin(), u.end());
+ for (int i = 0; i < N; ++i)
+ assert(std::abs(f(u[i], p.m(), p.n()) - double(i)/N) < .01);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/get_param.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/get_param.pass.cpp
new file mode 100644
index 000000000000..572df9bed67e
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/get_param.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class fisher_f_distribution
+
+// param_type param() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::fisher_f_distribution<> D;
+ typedef D::param_type P;
+ P p(.125, .5);
+ D d(p);
+ assert(d.param() == p);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/io.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/io.pass.cpp
new file mode 100644
index 000000000000..8872a274b2ec
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/io.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class fisher_f_distribution
+
+// template <class CharT, class Traits, class RealType>
+// basic_ostream<CharT, Traits>&
+// operator<<(basic_ostream<CharT, Traits>& os,
+// const fisher_f_distribution<RealType>& x);
+
+// template <class CharT, class Traits, class RealType>
+// basic_istream<CharT, Traits>&
+// operator>>(basic_istream<CharT, Traits>& is,
+// fisher_f_distribution<RealType>& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::fisher_f_distribution<> D;
+ D d1(7, 5);
+ std::ostringstream os;
+ os << d1;
+ std::istringstream is(os.str());
+ D d2;
+ is >> d2;
+ assert(d1 == d2);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/max.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/max.pass.cpp
new file mode 100644
index 000000000000..dfdbd5d7df8d
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/max.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class fisher_f_distribution
+
+// result_type max() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::fisher_f_distribution<> D;
+ D d(5, .25);
+ D::result_type m = d.max();
+ assert(m == INFINITY);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/min.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/min.pass.cpp
new file mode 100644
index 000000000000..bd4c5d1a6fcf
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/min.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class fisher_f_distribution
+
+// result_type min() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::fisher_f_distribution<> D;
+ D d(.5, .5);
+ assert(d.min() == 0);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/param_assign.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/param_assign.pass.cpp
new file mode 100644
index 000000000000..ea44645e66f9
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/param_assign.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class fisher_f_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::fisher_f_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p0(.75, 6);
+ param_type p;
+ p = p0;
+ assert(p.m() == .75);
+ assert(p.n() == 6);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/param_copy.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/param_copy.pass.cpp
new file mode 100644
index 000000000000..d6ce53ae136c
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/param_copy.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class fisher_f_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::fisher_f_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p0(10, .125);
+ param_type p = p0;
+ assert(p.m() == 10);
+ assert(p.n() == .125);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/param_ctor.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/param_ctor.pass.cpp
new file mode 100644
index 000000000000..1ab9138eb2fb
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/param_ctor.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class fisher_f_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::fisher_f_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p;
+ assert(p.m() == 1);
+ assert(p.n() == 1);
+ }
+ {
+ typedef std::fisher_f_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p(10);
+ assert(p.m() == 10);
+ assert(p.n() == 1);
+ }
+ {
+ typedef std::fisher_f_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p(10, 5);
+ assert(p.m() == 10);
+ assert(p.n() == 5);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/param_eq.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/param_eq.pass.cpp
new file mode 100644
index 000000000000..16eea408a8cf
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/param_eq.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class fisher_f_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::fisher_f_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p1(0.75, .5);
+ param_type p2(0.75, .5);
+ assert(p1 == p2);
+ }
+ {
+ typedef std::fisher_f_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p1(0.75, .5);
+ param_type p2(0.5, .5);
+ assert(p1 != p2);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/param_types.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/param_types.pass.cpp
new file mode 100644
index 000000000000..8391eedd23ac
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/param_types.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class fisher_f_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::fisher_f_distribution<> D;
+ typedef D::param_type param_type;
+ typedef param_type::distribution_type distribution_type;
+ static_assert((std::is_same<D, distribution_type>::value), "");
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/set_param.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/set_param.pass.cpp
new file mode 100644
index 000000000000..a7a1af662bfc
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/set_param.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class fisher_f_distribution;
+
+// void param(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::fisher_f_distribution<> D;
+ typedef D::param_type P;
+ P p(0.25, 5.5);
+ D d(0.75, 4);
+ d.param(p);
+ assert(d.param() == p);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/types.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/types.pass.cpp
new file mode 100644
index 000000000000..b765725d1c58
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/types.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class fisher_f_distribution
+// {
+// public:
+// // types
+// typedef RealType result_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::fisher_f_distribution<> D;
+ typedef D::result_type result_type;
+ static_assert((std::is_same<result_type, double>::value), "");
+ }
+ {
+ typedef std::fisher_f_distribution<float> D;
+ typedef D::result_type result_type;
+ static_assert((std::is_same<result_type, float>::value), "");
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/assign.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/assign.pass.cpp
new file mode 100644
index 000000000000..4da6451d9bfc
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/assign.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class lognormal_distribution
+
+// lognormal_distribution& operator=(const lognormal_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::lognormal_distribution<> D;
+ D d1(20, 0.75);
+ D d2;
+ assert(d1 != d2);
+ d2 = d1;
+ assert(d1 == d2);
+}
+
+int main()
+{
+ test1();
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/copy.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/copy.pass.cpp
new file mode 100644
index 000000000000..777f4a1ac9d5
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/copy.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class lognormal_distribution
+
+// lognormal_distribution(const lognormal_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::lognormal_distribution<> D;
+ D d1(20, 1.75);
+ D d2 = d1;
+ assert(d1 == d2);
+}
+
+int main()
+{
+ test1();
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/ctor_double_double.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/ctor_double_double.pass.cpp
new file mode 100644
index 000000000000..39d53393dd29
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/ctor_double_double.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class lognormal_distribution
+
+// explicit lognormal_distribution(result_type mean = 0, result_type stddev = 1);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::lognormal_distribution<> D;
+ D d;
+ assert(d.m() == 0);
+ assert(d.s() == 1);
+ }
+ {
+ typedef std::lognormal_distribution<> D;
+ D d(14.5);
+ assert(d.m() == 14.5);
+ assert(d.s() == 1);
+ }
+ {
+ typedef std::lognormal_distribution<> D;
+ D d(14.5, 5.25);
+ assert(d.m() == 14.5);
+ assert(d.s() == 5.25);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/ctor_param.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/ctor_param.pass.cpp
new file mode 100644
index 000000000000..f16567788066
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/ctor_param.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class lognormal_distribution
+
+// explicit lognormal_distribution(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::lognormal_distribution<> D;
+ typedef D::param_type P;
+ P p(0.25, 10);
+ D d(p);
+ assert(d.m() == 0.25);
+ assert(d.s() == 10);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/eq.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/eq.pass.cpp
new file mode 100644
index 000000000000..5fee0fd4ce17
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/eq.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class lognormal_distribution
+
+// bool operator=(const lognormal_distribution& x,
+// const lognormal_distribution& y);
+// bool operator!(const lognormal_distribution& x,
+// const lognormal_distribution& y);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::lognormal_distribution<> D;
+ D d1(2.5, 4);
+ D d2(2.5, 4);
+ assert(d1 == d2);
+ }
+ {
+ typedef std::lognormal_distribution<> D;
+ D d1(2.5, 4);
+ D d2(2.5, 4.5);
+ assert(d1 != d2);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/eval.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/eval.pass.cpp
new file mode 100644
index 000000000000..9b111cced8a8
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/eval.pass.cpp
@@ -0,0 +1,244 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// REQUIRES: long_tests
+
+// <random>
+
+// template<class RealType = double>
+// class lognormal_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g);
+
+#include <random>
+#include <cassert>
+#include <vector>
+#include <numeric>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+ return x * x;
+}
+
+int main()
+{
+ {
+ typedef std::lognormal_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(-1./8192, 0.015625);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(v > 0);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = std::exp(d.m() + sqr(d.s())/2);
+ double x_var = (std::exp(sqr(d.s())) - 1) * std::exp(2*d.m() + sqr(d.s()));
+ double x_skew = (std::exp(sqr(d.s())) + 2) *
+ std::sqrt((std::exp(sqr(d.s())) - 1));
+ double x_kurtosis = std::exp(4*sqr(d.s())) + 2*std::exp(3*sqr(d.s())) +
+ 3*std::exp(2*sqr(d.s())) - 6;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.05);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.25);
+ }
+ {
+ typedef std::lognormal_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(-1./32, 0.25);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(v > 0);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = std::exp(d.m() + sqr(d.s())/2);
+ double x_var = (std::exp(sqr(d.s())) - 1) * std::exp(2*d.m() + sqr(d.s()));
+ double x_skew = (std::exp(sqr(d.s())) + 2) *
+ std::sqrt((std::exp(sqr(d.s())) - 1));
+ double x_kurtosis = std::exp(4*sqr(d.s())) + 2*std::exp(3*sqr(d.s())) +
+ 3*std::exp(2*sqr(d.s())) - 6;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.03);
+ }
+ {
+ typedef std::lognormal_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(-1./8, 0.5);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(v > 0);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = std::exp(d.m() + sqr(d.s())/2);
+ double x_var = (std::exp(sqr(d.s())) - 1) * std::exp(2*d.m() + sqr(d.s()));
+ double x_skew = (std::exp(sqr(d.s())) + 2) *
+ std::sqrt((std::exp(sqr(d.s())) - 1));
+ double x_kurtosis = std::exp(4*sqr(d.s())) + 2*std::exp(3*sqr(d.s())) +
+ 3*std::exp(2*sqr(d.s())) - 6;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.02);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.05);
+ }
+ {
+ typedef std::lognormal_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d;
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(v > 0);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = std::exp(d.m() + sqr(d.s())/2);
+ double x_var = (std::exp(sqr(d.s())) - 1) * std::exp(2*d.m() + sqr(d.s()));
+ double x_skew = (std::exp(sqr(d.s())) + 2) *
+ std::sqrt((std::exp(sqr(d.s())) - 1));
+ double x_kurtosis = std::exp(4*sqr(d.s())) + 2*std::exp(3*sqr(d.s())) +
+ 3*std::exp(2*sqr(d.s())) - 6;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.02);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.08);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.4);
+ }
+ {
+ typedef std::lognormal_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(-0.78125, 1.25);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(v > 0);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = std::exp(d.m() + sqr(d.s())/2);
+ double x_var = (std::exp(sqr(d.s())) - 1) * std::exp(2*d.m() + sqr(d.s()));
+ double x_skew = (std::exp(sqr(d.s())) + 2) *
+ std::sqrt((std::exp(sqr(d.s())) - 1));
+ double x_kurtosis = std::exp(4*sqr(d.s())) + 2*std::exp(3*sqr(d.s())) +
+ 3*std::exp(2*sqr(d.s())) - 6;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.04);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.2);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.7);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/eval_param.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/eval_param.pass.cpp
new file mode 100644
index 000000000000..283403ea1a0d
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/eval_param.pass.cpp
@@ -0,0 +1,250 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// REQUIRES: long_tests
+
+// <random>
+
+// template<class RealType = double>
+// class lognormal_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g, const param_type& parm);
+
+#include <random>
+#include <cassert>
+#include <vector>
+#include <numeric>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+ return x * x;
+}
+
+int main()
+{
+
+ {
+ typedef std::lognormal_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d;
+ P p(-1./8192, 0.015625);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, p);
+ assert(v > 0);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = std::exp(p.m() + sqr(p.s())/2);
+ double x_var = (std::exp(sqr(p.s())) - 1) * std::exp(2*p.m() + sqr(p.s()));
+ double x_skew = (std::exp(sqr(p.s())) + 2) *
+ std::sqrt((std::exp(sqr(p.s())) - 1));
+ double x_kurtosis = std::exp(4*sqr(p.s())) + 2*std::exp(3*sqr(p.s())) +
+ 3*std::exp(2*sqr(p.s())) - 6;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.05);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.25);
+ }
+ {
+ typedef std::lognormal_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d;
+ P p(-1./32, 0.25);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, p);
+ assert(v > 0);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = std::exp(p.m() + sqr(p.s())/2);
+ double x_var = (std::exp(sqr(p.s())) - 1) * std::exp(2*p.m() + sqr(p.s()));
+ double x_skew = (std::exp(sqr(p.s())) + 2) *
+ std::sqrt((std::exp(sqr(p.s())) - 1));
+ double x_kurtosis = std::exp(4*sqr(p.s())) + 2*std::exp(3*sqr(p.s())) +
+ 3*std::exp(2*sqr(p.s())) - 6;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.03);
+ }
+ {
+ typedef std::lognormal_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d;
+ P p(-1./8, 0.5);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, p);
+ assert(v > 0);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = std::exp(p.m() + sqr(p.s())/2);
+ double x_var = (std::exp(sqr(p.s())) - 1) * std::exp(2*p.m() + sqr(p.s()));
+ double x_skew = (std::exp(sqr(p.s())) + 2) *
+ std::sqrt((std::exp(sqr(p.s())) - 1));
+ double x_kurtosis = std::exp(4*sqr(p.s())) + 2*std::exp(3*sqr(p.s())) +
+ 3*std::exp(2*sqr(p.s())) - 6;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.02);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.05);
+ }
+ {
+ typedef std::lognormal_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(3, 4);
+ P p;
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, p);
+ assert(v > 0);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = std::exp(p.m() + sqr(p.s())/2);
+ double x_var = (std::exp(sqr(p.s())) - 1) * std::exp(2*p.m() + sqr(p.s()));
+ double x_skew = (std::exp(sqr(p.s())) + 2) *
+ std::sqrt((std::exp(sqr(p.s())) - 1));
+ double x_kurtosis = std::exp(4*sqr(p.s())) + 2*std::exp(3*sqr(p.s())) +
+ 3*std::exp(2*sqr(p.s())) - 6;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.02);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.08);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.4);
+ }
+ {
+ typedef std::lognormal_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d;
+ P p(-0.78125, 1.25);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, p);
+ assert(v > 0);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = std::exp(p.m() + sqr(p.s())/2);
+ double x_var = (std::exp(sqr(p.s())) - 1) * std::exp(2*p.m() + sqr(p.s()));
+ double x_skew = (std::exp(sqr(p.s())) + 2) *
+ std::sqrt((std::exp(sqr(p.s())) - 1));
+ double x_kurtosis = std::exp(4*sqr(p.s())) + 2*std::exp(3*sqr(p.s())) +
+ 3*std::exp(2*sqr(p.s())) - 6;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.04);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.2);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.7);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/get_param.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/get_param.pass.cpp
new file mode 100644
index 000000000000..348ca6cfd7e6
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/get_param.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class lognormal_distribution
+
+// param_type param() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::lognormal_distribution<> D;
+ typedef D::param_type P;
+ P p(.125, .5);
+ D d(p);
+ assert(d.param() == p);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/io.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/io.pass.cpp
new file mode 100644
index 000000000000..4af0f2eafed8
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/io.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class lognormal_distribution
+
+// template <class CharT, class Traits, class RealType>
+// basic_ostream<CharT, Traits>&
+// operator<<(basic_ostream<CharT, Traits>& os,
+// const lognormal_distribution<RealType>& x);
+
+// template <class CharT, class Traits, class RealType>
+// basic_istream<CharT, Traits>&
+// operator>>(basic_istream<CharT, Traits>& is,
+// lognormal_distribution<RealType>& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::lognormal_distribution<> D;
+ D d1(7, 5);
+ std::ostringstream os;
+ os << d1;
+ std::istringstream is(os.str());
+ D d2;
+ is >> d2;
+ assert(d1 == d2);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/max.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/max.pass.cpp
new file mode 100644
index 000000000000..7ebfc43a3217
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/max.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class lognormal_distribution
+
+// result_type max() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::lognormal_distribution<> D;
+ D d(5, .25);
+ D::result_type m = d.max();
+ assert(m == INFINITY);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/min.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/min.pass.cpp
new file mode 100644
index 000000000000..6af4df777ec3
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/min.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class lognormal_distribution
+
+// result_type min() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::lognormal_distribution<> D;
+ D d(.5, .5);
+ assert(d.min() == 0);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_assign.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_assign.pass.cpp
new file mode 100644
index 000000000000..b23c770f5aae
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_assign.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class lognormal_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::lognormal_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p0(.75, 6);
+ param_type p;
+ p = p0;
+ assert(p.m() == .75);
+ assert(p.s() == 6);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_copy.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_copy.pass.cpp
new file mode 100644
index 000000000000..32ecc68da3c8
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_copy.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class lognormal_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::lognormal_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p0(10, .125);
+ param_type p = p0;
+ assert(p.m() == 10);
+ assert(p.s() == .125);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_ctor.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_ctor.pass.cpp
new file mode 100644
index 000000000000..2f109e3f57af
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_ctor.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class lognormal_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::lognormal_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p;
+ assert(p.m() == 0);
+ assert(p.s() == 1);
+ }
+ {
+ typedef std::lognormal_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p(10);
+ assert(p.m() == 10);
+ assert(p.s() == 1);
+ }
+ {
+ typedef std::lognormal_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p(10, 5);
+ assert(p.m() == 10);
+ assert(p.s() == 5);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_eq.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_eq.pass.cpp
new file mode 100644
index 000000000000..2f4293a737d6
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_eq.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class lognormal_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::lognormal_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p1(0.75, .5);
+ param_type p2(0.75, .5);
+ assert(p1 == p2);
+ }
+ {
+ typedef std::lognormal_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p1(0.75, .5);
+ param_type p2(0.5, .5);
+ assert(p1 != p2);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_types.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_types.pass.cpp
new file mode 100644
index 000000000000..6e53b269ee8a
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_types.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class lognormal_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::lognormal_distribution<> D;
+ typedef D::param_type param_type;
+ typedef param_type::distribution_type distribution_type;
+ static_assert((std::is_same<D, distribution_type>::value), "");
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/set_param.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/set_param.pass.cpp
new file mode 100644
index 000000000000..09c183f51048
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/set_param.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class lognormal_distribution;
+
+// void param(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::lognormal_distribution<> D;
+ typedef D::param_type P;
+ P p(0.25, 5.5);
+ D d(0.75, 4);
+ d.param(p);
+ assert(d.param() == p);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/types.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/types.pass.cpp
new file mode 100644
index 000000000000..1a07000d5197
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/types.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class lognormal_distribution
+// {
+// public:
+// // types
+// typedef RealType result_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::lognormal_distribution<> D;
+ typedef D::result_type result_type;
+ static_assert((std::is_same<result_type, double>::value), "");
+ }
+ {
+ typedef std::lognormal_distribution<float> D;
+ typedef D::result_type result_type;
+ static_assert((std::is_same<result_type, float>::value), "");
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/assign.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/assign.pass.cpp
new file mode 100644
index 000000000000..a7b2f71abb17
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/assign.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class normal_distribution
+
+// normal_distribution& operator=(const normal_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::normal_distribution<> D;
+ D d1(20, 0.75);
+ D d2;
+ assert(d1 != d2);
+ d2 = d1;
+ assert(d1 == d2);
+}
+
+int main()
+{
+ test1();
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/copy.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/copy.pass.cpp
new file mode 100644
index 000000000000..63f5be3c1c3a
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/copy.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class normal_distribution
+
+// normal_distribution(const normal_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::normal_distribution<> D;
+ D d1(20, 1.75);
+ D d2 = d1;
+ assert(d1 == d2);
+}
+
+int main()
+{
+ test1();
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/ctor_double_double.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/ctor_double_double.pass.cpp
new file mode 100644
index 000000000000..24a45f757ee6
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/ctor_double_double.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class normal_distribution
+
+// explicit normal_distribution(result_type mean = 0, result_type stddev = 1);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::normal_distribution<> D;
+ D d;
+ assert(d.mean() == 0);
+ assert(d.stddev() == 1);
+ }
+ {
+ typedef std::normal_distribution<> D;
+ D d(14.5);
+ assert(d.mean() == 14.5);
+ assert(d.stddev() == 1);
+ }
+ {
+ typedef std::normal_distribution<> D;
+ D d(14.5, 5.25);
+ assert(d.mean() == 14.5);
+ assert(d.stddev() == 5.25);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/ctor_param.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/ctor_param.pass.cpp
new file mode 100644
index 000000000000..11c7fbd6e89e
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/ctor_param.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class normal_distribution
+
+// explicit normal_distribution(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::normal_distribution<> D;
+ typedef D::param_type P;
+ P p(0.25, 10);
+ D d(p);
+ assert(d.mean() == 0.25);
+ assert(d.stddev() == 10);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/eq.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/eq.pass.cpp
new file mode 100644
index 000000000000..b6bd3d3166f1
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/eq.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class normal_distribution
+
+// bool operator=(const normal_distribution& x,
+// const normal_distribution& y);
+// bool operator!(const normal_distribution& x,
+// const normal_distribution& y);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::normal_distribution<> D;
+ D d1(2.5, 4);
+ D d2(2.5, 4);
+ assert(d1 == d2);
+ }
+ {
+ typedef std::normal_distribution<> D;
+ D d1(2.5, 4);
+ D d2(2.5, 4.5);
+ assert(d1 != d2);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/eval.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/eval.pass.cpp
new file mode 100644
index 000000000000..95d0272dbc32
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/eval.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// REQUIRES: long_tests
+
+// <random>
+
+// template<class RealType = double>
+// class normal_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g);
+
+#include <random>
+#include <cassert>
+#include <vector>
+#include <numeric>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+ return x * x;
+}
+
+int main()
+{
+ {
+ typedef std::normal_distribution<> D;
+ typedef D::param_type P;
+ typedef std::minstd_rand G;
+ G g;
+ D d(5, 4);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ u.push_back(d(g));
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = d.mean();
+ double x_var = sqr(d.stddev());
+ double x_skew = 0;
+ double x_kurtosis = 0;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs(skew - x_skew) < 0.01);
+ assert(std::abs(kurtosis - x_kurtosis) < 0.01);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/eval_param.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/eval_param.pass.cpp
new file mode 100644
index 000000000000..20c3a44f13e1
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/eval_param.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// REQUIRES: long_tests
+
+// <random>
+
+// template<class RealType = double>
+// class normal_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g, const param_type& parm);
+
+#include <random>
+#include <cassert>
+#include <vector>
+#include <numeric>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+ return x * x;
+}
+
+int main()
+{
+ {
+ typedef std::normal_distribution<> D;
+ typedef D::param_type P;
+ typedef std::minstd_rand G;
+ G g;
+ D d(5, 4);
+ P p(50, .5);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ u.push_back(d(g, p));
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = p.mean();
+ double x_var = sqr(p.stddev());
+ double x_skew = 0;
+ double x_kurtosis = 0;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs(skew - x_skew) < 0.01);
+ assert(std::abs(kurtosis - x_kurtosis) < 0.01);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/get_param.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/get_param.pass.cpp
new file mode 100644
index 000000000000..8b5d4328c9e3
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/get_param.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class normal_distribution
+
+// param_type param() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::normal_distribution<> D;
+ typedef D::param_type P;
+ P p(.125, .5);
+ D d(p);
+ assert(d.param() == p);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/io.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/io.pass.cpp
new file mode 100644
index 000000000000..6d79433490ad
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/io.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class normal_distribution
+
+// template <class CharT, class Traits, class RealType>
+// basic_ostream<CharT, Traits>&
+// operator<<(basic_ostream<CharT, Traits>& os,
+// const normal_distribution<RealType>& x);
+
+// template <class CharT, class Traits, class RealType>
+// basic_istream<CharT, Traits>&
+// operator>>(basic_istream<CharT, Traits>& is,
+// normal_distribution<RealType>& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::normal_distribution<> D;
+ D d1(7, 5);
+ std::ostringstream os;
+ os << d1;
+ std::istringstream is(os.str());
+ D d2;
+ is >> d2;
+ assert(d1 == d2);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/max.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/max.pass.cpp
new file mode 100644
index 000000000000..3825704f5be6
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/max.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class normal_distribution
+
+// result_type max() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::normal_distribution<> D;
+ D d(5, .25);
+ D::result_type m = d.max();
+ assert(m == INFINITY);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/min.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/min.pass.cpp
new file mode 100644
index 000000000000..9ba754d37fcb
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/min.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class normal_distribution
+
+// result_type min() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::normal_distribution<> D;
+ D d(.5, .5);
+ assert(d.min() == -INFINITY);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/param_assign.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/param_assign.pass.cpp
new file mode 100644
index 000000000000..2f7329b478e8
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/param_assign.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class normal_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::normal_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p0(.75, 6);
+ param_type p;
+ p = p0;
+ assert(p.mean() == .75);
+ assert(p.stddev() == 6);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/param_copy.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/param_copy.pass.cpp
new file mode 100644
index 000000000000..bddf0023f84e
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/param_copy.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class normal_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::normal_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p0(10, .125);
+ param_type p = p0;
+ assert(p.mean() == 10);
+ assert(p.stddev() == .125);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/param_ctor.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/param_ctor.pass.cpp
new file mode 100644
index 000000000000..a1add140c930
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/param_ctor.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class normal_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::normal_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p;
+ assert(p.mean() == 0);
+ assert(p.stddev() == 1);
+ }
+ {
+ typedef std::normal_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p(10);
+ assert(p.mean() == 10);
+ assert(p.stddev() == 1);
+ }
+ {
+ typedef std::normal_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p(10, 5);
+ assert(p.mean() == 10);
+ assert(p.stddev() == 5);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/param_eq.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/param_eq.pass.cpp
new file mode 100644
index 000000000000..cf2093808804
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/param_eq.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class normal_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::normal_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p1(0.75, .5);
+ param_type p2(0.75, .5);
+ assert(p1 == p2);
+ }
+ {
+ typedef std::normal_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p1(0.75, .5);
+ param_type p2(0.5, .5);
+ assert(p1 != p2);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/param_types.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/param_types.pass.cpp
new file mode 100644
index 000000000000..8d9b97e74fc3
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/param_types.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class normal_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::normal_distribution<> D;
+ typedef D::param_type param_type;
+ typedef param_type::distribution_type distribution_type;
+ static_assert((std::is_same<D, distribution_type>::value), "");
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/set_param.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/set_param.pass.cpp
new file mode 100644
index 000000000000..bb01bb1c009e
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/set_param.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class normal_distribution;
+
+// void param(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::normal_distribution<> D;
+ typedef D::param_type P;
+ P p(0.25, 5.5);
+ D d(0.75, 4);
+ d.param(p);
+ assert(d.param() == p);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/types.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/types.pass.cpp
new file mode 100644
index 000000000000..771685a8c352
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/types.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class normal_distribution
+// {
+// public:
+// // types
+// typedef RealType result_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::normal_distribution<> D;
+ typedef D::result_type result_type;
+ static_assert((std::is_same<result_type, double>::value), "");
+ }
+ {
+ typedef std::normal_distribution<float> D;
+ typedef D::result_type result_type;
+ static_assert((std::is_same<result_type, float>::value), "");
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/assign.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/assign.pass.cpp
new file mode 100644
index 000000000000..80c0a19783b5
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/assign.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class student_t_distribution
+
+// student_t_distribution& operator=(const student_t_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::student_t_distribution<> D;
+ D d1(20.75);
+ D d2;
+ assert(d1 != d2);
+ d2 = d1;
+ assert(d1 == d2);
+}
+
+int main()
+{
+ test1();
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/copy.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/copy.pass.cpp
new file mode 100644
index 000000000000..032cf77e8645
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/copy.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class student_t_distribution
+
+// student_t_distribution(const student_t_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::student_t_distribution<> D;
+ D d1(21.75);
+ D d2 = d1;
+ assert(d1 == d2);
+}
+
+int main()
+{
+ test1();
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/ctor_double.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/ctor_double.pass.cpp
new file mode 100644
index 000000000000..7dfb97fb09c1
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/ctor_double.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class student_t_distribution
+
+// explicit student_t_distribution(result_type alpha = 0, result_type beta = 1);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::student_t_distribution<> D;
+ D d;
+ assert(d.n() == 1);
+ }
+ {
+ typedef std::student_t_distribution<> D;
+ D d(14.5);
+ assert(d.n() == 14.5);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/ctor_param.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/ctor_param.pass.cpp
new file mode 100644
index 000000000000..57dedea87ed8
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/ctor_param.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class student_t_distribution
+
+// explicit student_t_distribution(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::student_t_distribution<> D;
+ typedef D::param_type P;
+ P p(0.25);
+ D d(p);
+ assert(d.n() == 0.25);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/eq.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/eq.pass.cpp
new file mode 100644
index 000000000000..73e8340439ce
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/eq.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class student_t_distribution
+
+// bool operator=(const student_t_distribution& x,
+// const student_t_distribution& y);
+// bool operator!(const student_t_distribution& x,
+// const student_t_distribution& y);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::student_t_distribution<> D;
+ D d1(2.5);
+ D d2(2.5);
+ assert(d1 == d2);
+ }
+ {
+ typedef std::student_t_distribution<> D;
+ D d1(4);
+ D d2(4.5);
+ assert(d1 != d2);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/eval.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/eval.pass.cpp
new file mode 100644
index 000000000000..ef6b37e9f9cc
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/eval.pass.cpp
@@ -0,0 +1,142 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// REQUIRES: long_tests
+
+// <random>
+
+// template<class RealType = double>
+// class student_t_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g);
+
+#include <random>
+#include <cassert>
+#include <vector>
+#include <numeric>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+ return x * x;
+}
+
+int main()
+{
+ {
+ typedef std::student_t_distribution<> D;
+ typedef D::param_type P;
+ typedef std::minstd_rand G;
+ G g;
+ D d(5.5);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ u.push_back(d(g));
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = 0;
+ double x_var = d.n() / (d.n() - 2);
+ double x_skew = 0;
+ double x_kurtosis = 6 / (d.n() - 4);
+ assert(std::abs(mean - x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs(skew - x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.2);
+ }
+ {
+ typedef std::student_t_distribution<> D;
+ typedef D::param_type P;
+ typedef std::minstd_rand G;
+ G g;
+ D d(10);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ u.push_back(d(g));
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = 0;
+ double x_var = d.n() / (d.n() - 2);
+ double x_skew = 0;
+ double x_kurtosis = 6 / (d.n() - 4);
+ assert(std::abs(mean - x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs(skew - x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.04);
+ }
+ {
+ typedef std::student_t_distribution<> D;
+ typedef D::param_type P;
+ typedef std::minstd_rand G;
+ G g;
+ D d(100);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ u.push_back(d(g));
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = 0;
+ double x_var = d.n() / (d.n() - 2);
+ double x_skew = 0;
+ double x_kurtosis = 6 / (d.n() - 4);
+ assert(std::abs(mean - x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs(skew - x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.02);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/eval_param.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/eval_param.pass.cpp
new file mode 100644
index 000000000000..70bc29e3ad13
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/eval_param.pass.cpp
@@ -0,0 +1,145 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// REQUIRES: long_tests
+
+// <random>
+
+// template<class RealType = double>
+// class student_t_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g, const param_type& parm);
+
+#include <random>
+#include <cassert>
+#include <vector>
+#include <numeric>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+ return x * x;
+}
+
+int main()
+{
+ {
+ typedef std::student_t_distribution<> D;
+ typedef D::param_type P;
+ typedef std::minstd_rand G;
+ G g;
+ D d;
+ P p(5.5);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ u.push_back(d(g, p));
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = 0;
+ double x_var = p.n() / (p.n() - 2);
+ double x_skew = 0;
+ double x_kurtosis = 6 / (p.n() - 4);
+ assert(std::abs(mean - x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs(skew - x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.2);
+ }
+ {
+ typedef std::student_t_distribution<> D;
+ typedef D::param_type P;
+ typedef std::minstd_rand G;
+ G g;
+ D d;
+ P p(10);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ u.push_back(d(g, p));
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = 0;
+ double x_var = p.n() / (p.n() - 2);
+ double x_skew = 0;
+ double x_kurtosis = 6 / (p.n() - 4);
+ assert(std::abs(mean - x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs(skew - x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.04);
+ }
+ {
+ typedef std::student_t_distribution<> D;
+ typedef D::param_type P;
+ typedef std::minstd_rand G;
+ G g;
+ D d;
+ P p(100);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ u.push_back(d(g, p));
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = 0;
+ double x_var = p.n() / (p.n() - 2);
+ double x_skew = 0;
+ double x_kurtosis = 6 / (p.n() - 4);
+ assert(std::abs(mean - x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs(skew - x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.02);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/get_param.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/get_param.pass.cpp
new file mode 100644
index 000000000000..a702a9fc5a01
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/get_param.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class student_t_distribution
+
+// param_type param() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::student_t_distribution<> D;
+ typedef D::param_type P;
+ P p(.125);
+ D d(p);
+ assert(d.param() == p);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/io.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/io.pass.cpp
new file mode 100644
index 000000000000..d3ca6ee28c73
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/io.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class student_t_distribution
+
+// template <class CharT, class Traits, class RealType>
+// basic_ostream<CharT, Traits>&
+// operator<<(basic_ostream<CharT, Traits>& os,
+// const student_t_distribution<RealType>& x);
+
+// template <class CharT, class Traits, class RealType>
+// basic_istream<CharT, Traits>&
+// operator>>(basic_istream<CharT, Traits>& is,
+// student_t_distribution<RealType>& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::student_t_distribution<> D;
+ D d1(7);
+ std::ostringstream os;
+ os << d1;
+ std::istringstream is(os.str());
+ D d2;
+ is >> d2;
+ assert(d1 == d2);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/max.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/max.pass.cpp
new file mode 100644
index 000000000000..aab361eaa3c3
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/max.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class student_t_distribution
+
+// result_type max() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::student_t_distribution<> D;
+ D d(5);
+ D::result_type m = d.max();
+ assert(m == INFINITY);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/min.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/min.pass.cpp
new file mode 100644
index 000000000000..a615f8efea90
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/min.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class student_t_distribution
+
+// result_type min() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::student_t_distribution<> D;
+ D d(.5);
+ assert(d.min() == -INFINITY);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/param_assign.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/param_assign.pass.cpp
new file mode 100644
index 000000000000..e900c2566777
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/param_assign.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class student_t_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::student_t_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p0(.75);
+ param_type p;
+ p = p0;
+ assert(p.n() == .75);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/param_copy.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/param_copy.pass.cpp
new file mode 100644
index 000000000000..9ce6a916275c
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/param_copy.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class student_t_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::student_t_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p0(10);
+ param_type p = p0;
+ assert(p.n() == 10);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/param_ctor.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/param_ctor.pass.cpp
new file mode 100644
index 000000000000..c9d0e131da0b
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/param_ctor.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class student_t_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::student_t_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p;
+ assert(p.n() == 1);
+ }
+ {
+ typedef std::student_t_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p(10);
+ assert(p.n() == 10);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/param_eq.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/param_eq.pass.cpp
new file mode 100644
index 000000000000..83634b2e3e93
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/param_eq.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class student_t_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::student_t_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p1(0.75);
+ param_type p2(0.75);
+ assert(p1 == p2);
+ }
+ {
+ typedef std::student_t_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p1(0.75);
+ param_type p2(0.5);
+ assert(p1 != p2);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/param_types.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/param_types.pass.cpp
new file mode 100644
index 000000000000..6cdd5c403e8d
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/param_types.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class student_t_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::student_t_distribution<> D;
+ typedef D::param_type param_type;
+ typedef param_type::distribution_type distribution_type;
+ static_assert((std::is_same<D, distribution_type>::value), "");
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/set_param.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/set_param.pass.cpp
new file mode 100644
index 000000000000..681d335a537f
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/set_param.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class student_t_distribution;
+
+// void param(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::student_t_distribution<> D;
+ typedef D::param_type P;
+ P p(0.25);
+ D d(0.75);
+ d.param(p);
+ assert(d.param() == p);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/types.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/types.pass.cpp
new file mode 100644
index 000000000000..9a25ce2d6181
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/types.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class student_t_distribution
+// {
+// public:
+// // types
+// typedef RealType result_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::student_t_distribution<> D;
+ typedef D::result_type result_type;
+ static_assert((std::is_same<result_type, double>::value), "");
+ }
+ {
+ typedef std::student_t_distribution<float> D;
+ typedef D::result_type result_type;
+ static_assert((std::is_same<result_type, float>::value), "");
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/nothing_to_do.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/assign.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/assign.pass.cpp
new file mode 100644
index 000000000000..c2a11a15b505
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/assign.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class exponential_distribution
+
+// exponential_distribution& operator=(const exponential_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::exponential_distribution<> D;
+ D d1(0.75);
+ D d2;
+ assert(d1 != d2);
+ d2 = d1;
+ assert(d1 == d2);
+}
+
+int main()
+{
+ test1();
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/copy.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/copy.pass.cpp
new file mode 100644
index 000000000000..81ae8e012614
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/copy.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class exponential_distribution
+
+// exponential_distribution(const exponential_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::exponential_distribution<> D;
+ D d1(1.75);
+ D d2 = d1;
+ assert(d1 == d2);
+}
+
+int main()
+{
+ test1();
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/ctor_double.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/ctor_double.pass.cpp
new file mode 100644
index 000000000000..92205a8abed1
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/ctor_double.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class exponential_distribution
+
+// explicit exponential_distribution(RealType lambda = 1.0);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::exponential_distribution<> D;
+ D d;
+ assert(d.lambda() == 1);
+ }
+ {
+ typedef std::exponential_distribution<> D;
+ D d(3.5);
+ assert(d.lambda() == 3.5);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/ctor_param.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/ctor_param.pass.cpp
new file mode 100644
index 000000000000..cd9782bf4370
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/ctor_param.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class exponential_distribution
+
+// explicit exponential_distribution(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::exponential_distribution<> D;
+ typedef D::param_type P;
+ P p(0.25);
+ D d(p);
+ assert(d.lambda() == 0.25);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/eq.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/eq.pass.cpp
new file mode 100644
index 000000000000..e31a14d0d0b8
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/eq.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class exponential_distribution
+
+// bool operator=(const exponential_distribution& x,
+// const exponential_distribution& y);
+// bool operator!(const exponential_distribution& x,
+// const exponential_distribution& y);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::exponential_distribution<> D;
+ D d1(.25);
+ D d2(.25);
+ assert(d1 == d2);
+ }
+ {
+ typedef std::exponential_distribution<> D;
+ D d1(.28);
+ D d2(.25);
+ assert(d1 != d2);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/eval.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/eval.pass.cpp
new file mode 100644
index 000000000000..b2fe52676e7e
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/eval.pass.cpp
@@ -0,0 +1,154 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// REQUIRES: long_tests
+
+// <random>
+
+// template<class RealType = double>
+// class exponential_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g);
+
+#include <random>
+#include <cassert>
+#include <vector>
+#include <numeric>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+ return x * x;
+}
+
+int main()
+{
+ {
+ typedef std::exponential_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(.75);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() < v);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = 1/d.lambda();
+ double x_var = 1/sqr(d.lambda());
+ double x_skew = 2;
+ double x_kurtosis = 6;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ {
+ typedef std::exponential_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(1);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() < v);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = 1/d.lambda();
+ double x_var = 1/sqr(d.lambda());
+ double x_skew = 2;
+ double x_kurtosis = 6;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ {
+ typedef std::exponential_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(10);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() < v);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = 1/d.lambda();
+ double x_var = 1/sqr(d.lambda());
+ double x_skew = 2;
+ double x_kurtosis = 6;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/eval_param.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/eval_param.pass.cpp
new file mode 100644
index 000000000000..9879e63a33e9
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/eval_param.pass.cpp
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// REQUIRES: long_tests
+
+// <random>
+
+// template<class RealType = double>
+// class exponential_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g, const param_type& parm);
+
+#include <random>
+#include <cassert>
+#include <vector>
+#include <numeric>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+ return x * x;
+}
+
+int main()
+{
+ {
+ typedef std::exponential_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(.75);
+ P p(2);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, p);
+ assert(d.min() < v);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = 1/p.lambda();
+ double x_var = 1/sqr(p.lambda());
+ double x_skew = 2;
+ double x_kurtosis = 6;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/get_param.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/get_param.pass.cpp
new file mode 100644
index 000000000000..f5bd8107e4b3
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/get_param.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class exponential_distribution
+
+// param_type param() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::exponential_distribution<> D;
+ typedef D::param_type P;
+ P p(.125);
+ D d(p);
+ assert(d.param() == p);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/io.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/io.pass.cpp
new file mode 100644
index 000000000000..eaedc8770efd
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/io.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class exponential_distribution
+
+// template <class CharT, class Traits, class RealType>
+// basic_ostream<CharT, Traits>&
+// operator<<(basic_ostream<CharT, Traits>& os,
+// const exponential_distribution<RealType>& x);
+
+// template <class CharT, class Traits, class RealType>
+// basic_istream<CharT, Traits>&
+// operator>>(basic_istream<CharT, Traits>& is,
+// exponential_distribution<RealType>& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::exponential_distribution<> D;
+ D d1(7);
+ std::ostringstream os;
+ os << d1;
+ std::istringstream is(os.str());
+ D d2;
+ is >> d2;
+ assert(d1 == d2);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/max.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/max.pass.cpp
new file mode 100644
index 000000000000..204cd7c0c97b
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/max.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class exponential_distribution
+
+// result_type max() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::exponential_distribution<> D;
+ D d(.25);
+ D::result_type m = d.max();
+ assert(m == std::numeric_limits<D::result_type>::infinity());
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/min.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/min.pass.cpp
new file mode 100644
index 000000000000..60af4bc81a99
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/min.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class exponential_distribution
+
+// result_type min() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::exponential_distribution<> D;
+ D d(.5);
+ assert(d.min() == 0);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/param_assign.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/param_assign.pass.cpp
new file mode 100644
index 000000000000..1f5352192bd1
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/param_assign.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class exponential_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::exponential_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p0(.7);
+ param_type p;
+ p = p0;
+ assert(p.lambda() == .7);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/param_copy.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/param_copy.pass.cpp
new file mode 100644
index 000000000000..360bd5daa60d
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/param_copy.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class exponential_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::exponential_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p0(.125);
+ param_type p = p0;
+ assert(p.lambda() == .125);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/param_ctor.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/param_ctor.pass.cpp
new file mode 100644
index 000000000000..7d74c7fccd1c
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/param_ctor.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class exponential_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::exponential_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p;
+ assert(p.lambda() == 1);
+ }
+ {
+ typedef std::exponential_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p(10);
+ assert(p.lambda() == 10);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/param_eq.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/param_eq.pass.cpp
new file mode 100644
index 000000000000..416d18cab930
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/param_eq.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class exponential_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::exponential_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p1(0.75);
+ param_type p2(0.75);
+ assert(p1 == p2);
+ }
+ {
+ typedef std::exponential_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p1(0.75);
+ param_type p2(0.5);
+ assert(p1 != p2);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/param_types.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/param_types.pass.cpp
new file mode 100644
index 000000000000..3d7371165e5b
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/param_types.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class exponential_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::exponential_distribution<> D;
+ typedef D::param_type param_type;
+ typedef param_type::distribution_type distribution_type;
+ static_assert((std::is_same<D, distribution_type>::value), "");
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/set_param.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/set_param.pass.cpp
new file mode 100644
index 000000000000..6c295aa1b07e
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/set_param.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class exponential_distribution;
+
+// void param(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::exponential_distribution<> D;
+ typedef D::param_type P;
+ P p(0.25);
+ D d(0.75);
+ d.param(p);
+ assert(d.param() == p);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/types.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/types.pass.cpp
new file mode 100644
index 000000000000..3d444e631db9
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/types.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class exponential_distribution
+// {
+// public:
+// // types
+// typedef RealType result_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::exponential_distribution<> D;
+ typedef D::result_type result_type;
+ static_assert((std::is_same<result_type, double>::value), "");
+ }
+ {
+ typedef std::exponential_distribution<float> D;
+ typedef D::result_type result_type;
+ static_assert((std::is_same<result_type, float>::value), "");
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/assign.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/assign.pass.cpp
new file mode 100644
index 000000000000..ff7cff45e994
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/assign.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class extreme_value_distribution
+
+// extreme_value_distribution& operator=(const extreme_value_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::extreme_value_distribution<> D;
+ D d1(.5, 2);
+ D d2;
+ assert(d1 != d2);
+ d2 = d1;
+ assert(d1 == d2);
+}
+
+int main()
+{
+ test1();
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/copy.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/copy.pass.cpp
new file mode 100644
index 000000000000..303779768c21
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/copy.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class extreme_value_distribution
+
+// extreme_value_distribution(const extreme_value_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::extreme_value_distribution<> D;
+ D d1(.5, 1.75);
+ D d2 = d1;
+ assert(d1 == d2);
+}
+
+int main()
+{
+ test1();
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/ctor_double_double.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/ctor_double_double.pass.cpp
new file mode 100644
index 000000000000..f5068d98dc68
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/ctor_double_double.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class extreme_value_distribution
+
+// explicit extreme_value_distribution(result_type a = 0, result_type b = 1);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::extreme_value_distribution<> D;
+ D d;
+ assert(d.a() == 0);
+ assert(d.b() == 1);
+ }
+ {
+ typedef std::extreme_value_distribution<> D;
+ D d(14.5);
+ assert(d.a() == 14.5);
+ assert(d.b() == 1);
+ }
+ {
+ typedef std::extreme_value_distribution<> D;
+ D d(14.5, 5.25);
+ assert(d.a() == 14.5);
+ assert(d.b() == 5.25);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/ctor_param.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/ctor_param.pass.cpp
new file mode 100644
index 000000000000..cac06699e417
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/ctor_param.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class extreme_value_distribution
+
+// explicit extreme_value_distribution(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::extreme_value_distribution<> D;
+ typedef D::param_type P;
+ P p(0.25, 10);
+ D d(p);
+ assert(d.a() == 0.25);
+ assert(d.b() == 10);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/eq.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/eq.pass.cpp
new file mode 100644
index 000000000000..6280df4f54a3
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/eq.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class extreme_value_distribution
+
+// bool operator=(const extreme_value_distribution& x,
+// const extreme_value_distribution& y);
+// bool operator!(const extreme_value_distribution& x,
+// const extreme_value_distribution& y);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::extreme_value_distribution<> D;
+ D d1(2.5, 4);
+ D d2(2.5, 4);
+ assert(d1 == d2);
+ }
+ {
+ typedef std::extreme_value_distribution<> D;
+ D d1(2.5, 4);
+ D d2(2.5, 4.5);
+ assert(d1 != d2);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/eval.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/eval.pass.cpp
new file mode 100644
index 000000000000..6390acef8941
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/eval.pass.cpp
@@ -0,0 +1,190 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// REQUIRES: long_tests
+
+// <random>
+
+// template<class RealType = double>
+// class extreme_value_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g);
+
+#include <random>
+#include <cassert>
+#include <vector>
+#include <numeric>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+ return x * x;
+}
+
+int main()
+{
+ {
+ typedef std::extreme_value_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(0.5, 2);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = d.a() + d.b() * 0.577215665;
+ double x_var = sqr(d.b()) * 1.644934067;
+ double x_skew = 1.139547;
+ double x_kurtosis = 12./5;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ {
+ typedef std::extreme_value_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(1, 2);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = d.a() + d.b() * 0.577215665;
+ double x_var = sqr(d.b()) * 1.644934067;
+ double x_skew = 1.139547;
+ double x_kurtosis = 12./5;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ {
+ typedef std::extreme_value_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(1.5, 3);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = d.a() + d.b() * 0.577215665;
+ double x_var = sqr(d.b()) * 1.644934067;
+ double x_skew = 1.139547;
+ double x_kurtosis = 12./5;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ {
+ typedef std::extreme_value_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(3, 4);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = d.a() + d.b() * 0.577215665;
+ double x_var = sqr(d.b()) * 1.644934067;
+ double x_skew = 1.139547;
+ double x_kurtosis = 12./5;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/eval_param.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/eval_param.pass.cpp
new file mode 100644
index 000000000000..6152cce8f4f8
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/eval_param.pass.cpp
@@ -0,0 +1,194 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// REQUIRES: long_tests
+
+// <random>
+
+// template<class RealType = double>
+// class extreme_value_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g, const param_type& parm);
+
+#include <random>
+#include <cassert>
+#include <vector>
+#include <numeric>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+ return x * x;
+}
+
+int main()
+{
+ {
+ typedef std::extreme_value_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(-0.5, 1);
+ P p(0.5, 2);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, p);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = p.a() + p.b() * 0.577215665;
+ double x_var = sqr(p.b()) * 1.644934067;
+ double x_skew = 1.139547;
+ double x_kurtosis = 12./5;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ {
+ typedef std::extreme_value_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(-0.5, 1);
+ P p(1, 2);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, p);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = p.a() + p.b() * 0.577215665;
+ double x_var = sqr(p.b()) * 1.644934067;
+ double x_skew = 1.139547;
+ double x_kurtosis = 12./5;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ {
+ typedef std::extreme_value_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(-0.5, 1);
+ P p(1.5, 3);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, p);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = p.a() + p.b() * 0.577215665;
+ double x_var = sqr(p.b()) * 1.644934067;
+ double x_skew = 1.139547;
+ double x_kurtosis = 12./5;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ {
+ typedef std::extreme_value_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(-0.5, 1);
+ P p(3, 4);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, p);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = p.a() + p.b() * 0.577215665;
+ double x_var = sqr(p.b()) * 1.644934067;
+ double x_skew = 1.139547;
+ double x_kurtosis = 12./5;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/get_param.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/get_param.pass.cpp
new file mode 100644
index 000000000000..1855d5f73b2b
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/get_param.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class extreme_value_distribution
+
+// param_type param() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::extreme_value_distribution<> D;
+ typedef D::param_type P;
+ P p(.125, .5);
+ D d(p);
+ assert(d.param() == p);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/io.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/io.pass.cpp
new file mode 100644
index 000000000000..0beaf429301b
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/io.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class extreme_value_distribution
+
+// template <class CharT, class Traits, class RealType>
+// basic_ostream<CharT, Traits>&
+// operator<<(basic_ostream<CharT, Traits>& os,
+// const extreme_value_distribution<RealType>& x);
+
+// template <class CharT, class Traits, class RealType>
+// basic_istream<CharT, Traits>&
+// operator>>(basic_istream<CharT, Traits>& is,
+// extreme_value_distribution<RealType>& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::extreme_value_distribution<> D;
+ D d1(7.5, 5.5);
+ std::ostringstream os;
+ os << d1;
+ std::istringstream is(os.str());
+ D d2;
+ is >> d2;
+ assert(d1 == d2);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/max.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/max.pass.cpp
new file mode 100644
index 000000000000..ca89e355b2fe
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/max.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class extreme_value_distribution
+
+// result_type max() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::extreme_value_distribution<> D;
+ D d(5, .25);
+ D::result_type m = d.max();
+ assert(m == INFINITY);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/min.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/min.pass.cpp
new file mode 100644
index 000000000000..1f98a5b17390
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/min.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class extreme_value_distribution
+
+// result_type min() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::extreme_value_distribution<> D;
+ D d(.5, .5);
+ assert(d.min() == -INFINITY);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/param_assign.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/param_assign.pass.cpp
new file mode 100644
index 000000000000..44f587f625b5
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/param_assign.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class extreme_value_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::extreme_value_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p0(.75, 6);
+ param_type p;
+ p = p0;
+ assert(p.a() == .75);
+ assert(p.b() == 6);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/param_copy.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/param_copy.pass.cpp
new file mode 100644
index 000000000000..6675bab61589
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/param_copy.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class extreme_value_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::extreme_value_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p0(10, .125);
+ param_type p = p0;
+ assert(p.a() == 10);
+ assert(p.b() == .125);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/param_ctor.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/param_ctor.pass.cpp
new file mode 100644
index 000000000000..3fe3d49c334d
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/param_ctor.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class extreme_value_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::extreme_value_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p;
+ assert(p.a() == 0);
+ assert(p.b() == 1);
+ }
+ {
+ typedef std::extreme_value_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p(10);
+ assert(p.a() == 10);
+ assert(p.b() == 1);
+ }
+ {
+ typedef std::extreme_value_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p(10, 5);
+ assert(p.a() == 10);
+ assert(p.b() == 5);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/param_eq.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/param_eq.pass.cpp
new file mode 100644
index 000000000000..3b55d569f5f4
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/param_eq.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class extreme_value_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::extreme_value_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p1(0.75, .5);
+ param_type p2(0.75, .5);
+ assert(p1 == p2);
+ }
+ {
+ typedef std::extreme_value_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p1(0.75, .5);
+ param_type p2(0.5, .5);
+ assert(p1 != p2);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/param_types.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/param_types.pass.cpp
new file mode 100644
index 000000000000..d6ffb5f0c10d
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/param_types.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class extreme_value_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::extreme_value_distribution<> D;
+ typedef D::param_type param_type;
+ typedef param_type::distribution_type distribution_type;
+ static_assert((std::is_same<D, distribution_type>::value), "");
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/set_param.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/set_param.pass.cpp
new file mode 100644
index 000000000000..dcf0b1659bea
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/set_param.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class extreme_value_distribution;
+
+// void param(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::extreme_value_distribution<> D;
+ typedef D::param_type P;
+ P p(0.25, 5.5);
+ D d(0.75, 4);
+ d.param(p);
+ assert(d.param() == p);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/types.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/types.pass.cpp
new file mode 100644
index 000000000000..44dd1816c1a6
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/types.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class extreme_value_distribution
+// {
+// public:
+// // types
+// typedef RealType result_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::extreme_value_distribution<> D;
+ typedef D::result_type result_type;
+ static_assert((std::is_same<result_type, double>::value), "");
+ }
+ {
+ typedef std::extreme_value_distribution<float> D;
+ typedef D::result_type result_type;
+ static_assert((std::is_same<result_type, float>::value), "");
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/assign.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/assign.pass.cpp
new file mode 100644
index 000000000000..671f4b1cde44
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/assign.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class gamma_distribution
+
+// gamma_distribution& operator=(const gamma_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::gamma_distribution<> D;
+ D d1(20, 0.75);
+ D d2;
+ assert(d1 != d2);
+ d2 = d1;
+ assert(d1 == d2);
+}
+
+int main()
+{
+ test1();
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/copy.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/copy.pass.cpp
new file mode 100644
index 000000000000..876ecb27f8b1
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/copy.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class gamma_distribution
+
+// gamma_distribution(const gamma_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::gamma_distribution<> D;
+ D d1(20, 1.75);
+ D d2 = d1;
+ assert(d1 == d2);
+}
+
+int main()
+{
+ test1();
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/ctor_double_double.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/ctor_double_double.pass.cpp
new file mode 100644
index 000000000000..5bc4bbaea893
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/ctor_double_double.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class gamma_distribution
+
+// explicit gamma_distribution(result_type alpha = 0, result_type beta = 1);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::gamma_distribution<> D;
+ D d;
+ assert(d.alpha() == 1);
+ assert(d.beta() == 1);
+ }
+ {
+ typedef std::gamma_distribution<> D;
+ D d(14.5);
+ assert(d.alpha() == 14.5);
+ assert(d.beta() == 1);
+ }
+ {
+ typedef std::gamma_distribution<> D;
+ D d(14.5, 5.25);
+ assert(d.alpha() == 14.5);
+ assert(d.beta() == 5.25);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/ctor_param.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/ctor_param.pass.cpp
new file mode 100644
index 000000000000..35de51b1c4b0
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/ctor_param.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class gamma_distribution
+
+// explicit gamma_distribution(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::gamma_distribution<> D;
+ typedef D::param_type P;
+ P p(0.25, 10);
+ D d(p);
+ assert(d.alpha() == 0.25);
+ assert(d.beta() == 10);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/eq.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/eq.pass.cpp
new file mode 100644
index 000000000000..48331a609ce4
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/eq.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class gamma_distribution
+
+// bool operator=(const gamma_distribution& x,
+// const gamma_distribution& y);
+// bool operator!(const gamma_distribution& x,
+// const gamma_distribution& y);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::gamma_distribution<> D;
+ D d1(2.5, 4);
+ D d2(2.5, 4);
+ assert(d1 == d2);
+ }
+ {
+ typedef std::gamma_distribution<> D;
+ D d1(2.5, 4);
+ D d2(2.5, 4.5);
+ assert(d1 != d2);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/eval.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/eval.pass.cpp
new file mode 100644
index 000000000000..7c26cc8a1c47
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/eval.pass.cpp
@@ -0,0 +1,154 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// REQUIRES: long_tests
+
+// <random>
+
+// template<class RealType = double>
+// class gamma_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g);
+
+#include <random>
+#include <cassert>
+#include <vector>
+#include <numeric>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+ return x * x;
+}
+
+int main()
+{
+ {
+ typedef std::gamma_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(0.5, 2);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() < v);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = d.alpha() * d.beta();
+ double x_var = d.alpha() * sqr(d.beta());
+ double x_skew = 2 / std::sqrt(d.alpha());
+ double x_kurtosis = 6 / d.alpha();
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ {
+ typedef std::gamma_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(1, .5);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() < v);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = d.alpha() * d.beta();
+ double x_var = d.alpha() * sqr(d.beta());
+ double x_skew = 2 / std::sqrt(d.alpha());
+ double x_kurtosis = 6 / d.alpha();
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ {
+ typedef std::gamma_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(2, 3);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() < v);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = d.alpha() * d.beta();
+ double x_var = d.alpha() * sqr(d.beta());
+ double x_skew = 2 / std::sqrt(d.alpha());
+ double x_kurtosis = 6 / d.alpha();
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/eval_param.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/eval_param.pass.cpp
new file mode 100644
index 000000000000..8ed39df819d7
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/eval_param.pass.cpp
@@ -0,0 +1,157 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// REQUIRES: long_tests
+
+// <random>
+
+// template<class RealType = double>
+// class gamma_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g, const param_type& parm);
+
+#include <random>
+#include <cassert>
+#include <vector>
+#include <numeric>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+ return x * x;
+}
+
+int main()
+{
+ {
+ typedef std::gamma_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(0.5, 2);
+ P p(1, .5);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, p);
+ assert(d.min() < v);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = p.alpha() * p.beta();
+ double x_var = p.alpha() * sqr(p.beta());
+ double x_skew = 2 / std::sqrt(p.alpha());
+ double x_kurtosis = 6 / p.alpha();
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ {
+ typedef std::gamma_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(1, .5);
+ P p(2, 3);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, p);
+ assert(d.min() < v);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = p.alpha() * p.beta();
+ double x_var = p.alpha() * sqr(p.beta());
+ double x_skew = 2 / std::sqrt(p.alpha());
+ double x_kurtosis = 6 / p.alpha();
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ {
+ typedef std::gamma_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(2, 3);
+ P p(.5, 2);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, p);
+ assert(d.min() < v);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = p.alpha() * p.beta();
+ double x_var = p.alpha() * sqr(p.beta());
+ double x_skew = 2 / std::sqrt(p.alpha());
+ double x_kurtosis = 6 / p.alpha();
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/get_param.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/get_param.pass.cpp
new file mode 100644
index 000000000000..0aad32c64697
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/get_param.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class gamma_distribution
+
+// param_type param() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::gamma_distribution<> D;
+ typedef D::param_type P;
+ P p(.125, .5);
+ D d(p);
+ assert(d.param() == p);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/io.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/io.pass.cpp
new file mode 100644
index 000000000000..a2a288adf595
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/io.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class gamma_distribution
+
+// template <class CharT, class Traits, class RealType>
+// basic_ostream<CharT, Traits>&
+// operator<<(basic_ostream<CharT, Traits>& os,
+// const gamma_distribution<RealType>& x);
+
+// template <class CharT, class Traits, class RealType>
+// basic_istream<CharT, Traits>&
+// operator>>(basic_istream<CharT, Traits>& is,
+// gamma_distribution<RealType>& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::gamma_distribution<> D;
+ D d1(7, 5);
+ std::ostringstream os;
+ os << d1;
+ std::istringstream is(os.str());
+ D d2;
+ is >> d2;
+ assert(d1 == d2);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/max.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/max.pass.cpp
new file mode 100644
index 000000000000..9ec51932a5d5
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/max.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class gamma_distribution
+
+// result_type max() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::gamma_distribution<> D;
+ D d(5, .25);
+ D::result_type m = d.max();
+ assert(m == INFINITY);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/min.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/min.pass.cpp
new file mode 100644
index 000000000000..a918c147900f
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/min.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class gamma_distribution
+
+// result_type min() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::gamma_distribution<> D;
+ D d(.5, .5);
+ assert(d.min() == 0);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/param_assign.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/param_assign.pass.cpp
new file mode 100644
index 000000000000..31f346ed5d65
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/param_assign.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class gamma_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::gamma_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p0(.75, 6);
+ param_type p;
+ p = p0;
+ assert(p.alpha() == .75);
+ assert(p.beta() == 6);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/param_copy.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/param_copy.pass.cpp
new file mode 100644
index 000000000000..c96cbcd2ead7
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/param_copy.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class gamma_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::gamma_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p0(10, .125);
+ param_type p = p0;
+ assert(p.alpha() == 10);
+ assert(p.beta() == .125);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/param_ctor.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/param_ctor.pass.cpp
new file mode 100644
index 000000000000..c0e34f0b56e9
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/param_ctor.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class gamma_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::gamma_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p;
+ assert(p.alpha() == 1);
+ assert(p.beta() == 1);
+ }
+ {
+ typedef std::gamma_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p(10);
+ assert(p.alpha() == 10);
+ assert(p.beta() == 1);
+ }
+ {
+ typedef std::gamma_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p(10, 5);
+ assert(p.alpha() == 10);
+ assert(p.beta() == 5);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/param_eq.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/param_eq.pass.cpp
new file mode 100644
index 000000000000..2fe9c2d71fac
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/param_eq.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class gamma_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::gamma_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p1(0.75, .5);
+ param_type p2(0.75, .5);
+ assert(p1 == p2);
+ }
+ {
+ typedef std::gamma_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p1(0.75, .5);
+ param_type p2(0.5, .5);
+ assert(p1 != p2);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/param_types.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/param_types.pass.cpp
new file mode 100644
index 000000000000..51e8eb123e6c
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/param_types.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class gamma_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::gamma_distribution<> D;
+ typedef D::param_type param_type;
+ typedef param_type::distribution_type distribution_type;
+ static_assert((std::is_same<D, distribution_type>::value), "");
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/set_param.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/set_param.pass.cpp
new file mode 100644
index 000000000000..7e226299014d
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/set_param.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class gamma_distribution;
+
+// void param(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::gamma_distribution<> D;
+ typedef D::param_type P;
+ P p(0.25, 5.5);
+ D d(0.75, 4);
+ d.param(p);
+ assert(d.param() == p);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/types.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/types.pass.cpp
new file mode 100644
index 000000000000..65459e00f3ef
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/types.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class gamma_distribution
+// {
+// public:
+// // types
+// typedef RealType result_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::gamma_distribution<> D;
+ typedef D::result_type result_type;
+ static_assert((std::is_same<result_type, double>::value), "");
+ }
+ {
+ typedef std::gamma_distribution<float> D;
+ typedef D::result_type result_type;
+ static_assert((std::is_same<result_type, float>::value), "");
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/assign.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/assign.pass.cpp
new file mode 100644
index 000000000000..5f145552511c
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/assign.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class poisson_distribution
+
+// poisson_distribution& operator=(const poisson_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::poisson_distribution<> D;
+ D d1(0.75);
+ D d2;
+ assert(d1 != d2);
+ d2 = d1;
+ assert(d1 == d2);
+}
+
+int main()
+{
+ test1();
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/copy.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/copy.pass.cpp
new file mode 100644
index 000000000000..8abf7ffbd536
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/copy.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class poisson_distribution
+
+// poisson_distribution(const poisson_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::poisson_distribution<> D;
+ D d1(1.75);
+ D d2 = d1;
+ assert(d1 == d2);
+}
+
+int main()
+{
+ test1();
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/ctor_double.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/ctor_double.pass.cpp
new file mode 100644
index 000000000000..0cc82cac5065
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/ctor_double.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class poisson_distribution
+
+// explicit poisson_distribution(RealType lambda = 1.0);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::poisson_distribution<> D;
+ D d;
+ assert(d.mean() == 1);
+ }
+ {
+ typedef std::poisson_distribution<> D;
+ D d(3.5);
+ assert(d.mean() == 3.5);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/ctor_param.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/ctor_param.pass.cpp
new file mode 100644
index 000000000000..a24d7550b7d7
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/ctor_param.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class poisson_distribution
+
+// explicit poisson_distribution(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::poisson_distribution<> D;
+ typedef D::param_type P;
+ P p(0.25);
+ D d(p);
+ assert(d.mean() == 0.25);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/eq.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/eq.pass.cpp
new file mode 100644
index 000000000000..7bea12ec6cb1
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/eq.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class poisson_distribution
+
+// bool operator=(const poisson_distribution& x,
+// const poisson_distribution& y);
+// bool operator!(const poisson_distribution& x,
+// const poisson_distribution& y);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::poisson_distribution<> D;
+ D d1(.25);
+ D d2(.25);
+ assert(d1 == d2);
+ }
+ {
+ typedef std::poisson_distribution<> D;
+ D d1(.28);
+ D d2(.25);
+ assert(d1 != d2);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/eval.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/eval.pass.cpp
new file mode 100644
index 000000000000..f5598978bf0a
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/eval.pass.cpp
@@ -0,0 +1,151 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// REQUIRES: long_tests
+
+// <random>
+
+// template<class IntType = int>
+// class poisson_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g);
+
+#include <random>
+#include <cassert>
+#include <vector>
+#include <numeric>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+ return x * x;
+}
+
+int main()
+{
+ {
+ typedef std::poisson_distribution<> D;
+ typedef std::minstd_rand G;
+ G g;
+ D d(2);
+ const int N = 100000;
+ std::vector<double> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v <= d.max());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = d.mean();
+ double x_var = d.mean();
+ double x_skew = 1 / std::sqrt(x_var);
+ double x_kurtosis = 1 / x_var;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.03);
+ }
+ {
+ typedef std::poisson_distribution<> D;
+ typedef std::minstd_rand G;
+ G g;
+ D d(0.75);
+ const int N = 100000;
+ std::vector<double> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v <= d.max());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = d.mean();
+ double x_var = d.mean();
+ double x_skew = 1 / std::sqrt(x_var);
+ double x_kurtosis = 1 / x_var;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.04);
+ }
+ {
+ typedef std::poisson_distribution<> D;
+ typedef std::mt19937 G;
+ G g;
+ D d(20);
+ const int N = 1000000;
+ std::vector<double> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v <= d.max());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = d.mean();
+ double x_var = d.mean();
+ double x_skew = 1 / std::sqrt(x_var);
+ double x_kurtosis = 1 / x_var;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/eval_param.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/eval_param.pass.cpp
new file mode 100644
index 000000000000..c3bbdeb0ed6c
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/eval_param.pass.cpp
@@ -0,0 +1,157 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// REQUIRES: long_tests
+
+// <random>
+
+// template<class IntType = int>
+// class poisson_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g, const param_type& parm);
+
+#include <random>
+#include <cassert>
+#include <vector>
+#include <numeric>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+ return x * x;
+}
+
+int main()
+{
+ {
+ typedef std::poisson_distribution<> D;
+ typedef D::param_type P;
+ typedef std::minstd_rand G;
+ G g;
+ D d(.75);
+ P p(2);
+ const int N = 100000;
+ std::vector<double> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, p);
+ assert(d.min() <= v && v <= d.max());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = p.mean();
+ double x_var = p.mean();
+ double x_skew = 1 / std::sqrt(x_var);
+ double x_kurtosis = 1 / x_var;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.03);
+ }
+ {
+ typedef std::poisson_distribution<> D;
+ typedef D::param_type P;
+ typedef std::minstd_rand G;
+ G g;
+ D d(2);
+ P p(.75);
+ const int N = 100000;
+ std::vector<double> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, p);
+ assert(d.min() <= v && v <= d.max());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = p.mean();
+ double x_var = p.mean();
+ double x_skew = 1 / std::sqrt(x_var);
+ double x_kurtosis = 1 / x_var;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.04);
+ }
+ {
+ typedef std::poisson_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(2);
+ P p(20);
+ const int N = 1000000;
+ std::vector<double> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, p);
+ assert(d.min() <= v && v <= d.max());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = p.mean();
+ double x_var = p.mean();
+ double x_skew = 1 / std::sqrt(x_var);
+ double x_kurtosis = 1 / x_var;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/get_param.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/get_param.pass.cpp
new file mode 100644
index 000000000000..3f5f36769836
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/get_param.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class poisson_distribution
+
+// param_type param() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::poisson_distribution<> D;
+ typedef D::param_type P;
+ P p(.125);
+ D d(p);
+ assert(d.param() == p);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/io.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/io.pass.cpp
new file mode 100644
index 000000000000..63805591bab4
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/io.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class poisson_distribution
+
+// template <class CharT, class Traits, class IntType>
+// basic_ostream<CharT, Traits>&
+// operator<<(basic_ostream<CharT, Traits>& os,
+// const poisson_distribution<RealType>& x);
+
+// template <class CharT, class Traits, class IntType>
+// basic_istream<CharT, Traits>&
+// operator>>(basic_istream<CharT, Traits>& is,
+// poisson_distribution<RealType>& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::poisson_distribution<> D;
+ D d1(7);
+ std::ostringstream os;
+ os << d1;
+ std::istringstream is(os.str());
+ D d2;
+ is >> d2;
+ assert(d1 == d2);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/max.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/max.pass.cpp
new file mode 100644
index 000000000000..2dffab3d15fc
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/max.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class poisson_distribution
+
+// result_type max() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::poisson_distribution<> D;
+ D d(.25);
+ D::result_type m = d.max();
+ assert(m == std::numeric_limits<int>::max());
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/min.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/min.pass.cpp
new file mode 100644
index 000000000000..607d49b0e8bc
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/min.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class poisson_distribution
+
+// result_type min() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::poisson_distribution<> D;
+ D d(.5);
+ assert(d.min() == 0);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/param_assign.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/param_assign.pass.cpp
new file mode 100644
index 000000000000..1c31ea34a07c
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/param_assign.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class poisson_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::poisson_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p0(.7);
+ param_type p;
+ p = p0;
+ assert(p.mean() == .7);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/param_copy.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/param_copy.pass.cpp
new file mode 100644
index 000000000000..19c05136e3f4
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/param_copy.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class poisson_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::poisson_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p0(.125);
+ param_type p = p0;
+ assert(p.mean() == .125);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/param_ctor.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/param_ctor.pass.cpp
new file mode 100644
index 000000000000..081e3a2d5551
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/param_ctor.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class poisson_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::poisson_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p;
+ assert(p.mean() == 1);
+ }
+ {
+ typedef std::poisson_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p(10);
+ assert(p.mean() == 10);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/param_eq.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/param_eq.pass.cpp
new file mode 100644
index 000000000000..cbee35845063
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/param_eq.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class poisson_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::poisson_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p1(0.75);
+ param_type p2(0.75);
+ assert(p1 == p2);
+ }
+ {
+ typedef std::poisson_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p1(0.75);
+ param_type p2(0.5);
+ assert(p1 != p2);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/param_types.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/param_types.pass.cpp
new file mode 100644
index 000000000000..c3136e048e03
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/param_types.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class poisson_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::poisson_distribution<> D;
+ typedef D::param_type param_type;
+ typedef param_type::distribution_type distribution_type;
+ static_assert((std::is_same<D, distribution_type>::value), "");
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/set_param.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/set_param.pass.cpp
new file mode 100644
index 000000000000..86fe1f422a3a
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/set_param.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class poisson_distribution;
+
+// void param(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::poisson_distribution<> D;
+ typedef D::param_type P;
+ P p(0.25);
+ D d(0.75);
+ d.param(p);
+ assert(d.param() == p);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/types.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/types.pass.cpp
new file mode 100644
index 000000000000..05e8b112e5b3
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/types.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class poisson_distribution
+// {
+// public:
+// // types
+// typedef RealType result_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::poisson_distribution<> D;
+ typedef D::result_type result_type;
+ static_assert((std::is_same<result_type, int>::value), "");
+ }
+ {
+ typedef std::poisson_distribution<unsigned long long> D;
+ typedef D::result_type result_type;
+ static_assert((std::is_same<result_type, unsigned long long>::value), "");
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/assign.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/assign.pass.cpp
new file mode 100644
index 000000000000..31a2c4ad6899
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/assign.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class weibull_distribution
+
+// weibull_distribution& operator=(const weibull_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::weibull_distribution<> D;
+ D d1(20, 0.75);
+ D d2;
+ assert(d1 != d2);
+ d2 = d1;
+ assert(d1 == d2);
+}
+
+int main()
+{
+ test1();
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/copy.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/copy.pass.cpp
new file mode 100644
index 000000000000..68ef4dfea51b
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/copy.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class weibull_distribution
+
+// weibull_distribution(const weibull_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::weibull_distribution<> D;
+ D d1(20, 1.75);
+ D d2 = d1;
+ assert(d1 == d2);
+}
+
+int main()
+{
+ test1();
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/ctor_double_double.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/ctor_double_double.pass.cpp
new file mode 100644
index 000000000000..34c6705641c4
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/ctor_double_double.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class weibull_distribution
+
+// explicit weibull_distribution(result_type a = 0, result_type b = 1);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::weibull_distribution<> D;
+ D d;
+ assert(d.a() == 1);
+ assert(d.b() == 1);
+ }
+ {
+ typedef std::weibull_distribution<> D;
+ D d(14.5);
+ assert(d.a() == 14.5);
+ assert(d.b() == 1);
+ }
+ {
+ typedef std::weibull_distribution<> D;
+ D d(14.5, 5.25);
+ assert(d.a() == 14.5);
+ assert(d.b() == 5.25);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/ctor_param.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/ctor_param.pass.cpp
new file mode 100644
index 000000000000..5db4f1da7ef9
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/ctor_param.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class weibull_distribution
+
+// explicit weibull_distribution(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::weibull_distribution<> D;
+ typedef D::param_type P;
+ P p(0.25, 10);
+ D d(p);
+ assert(d.a() == 0.25);
+ assert(d.b() == 10);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/eq.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/eq.pass.cpp
new file mode 100644
index 000000000000..4c681c18b2f4
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/eq.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class weibull_distribution
+
+// bool operator=(const weibull_distribution& x,
+// const weibull_distribution& y);
+// bool operator!(const weibull_distribution& x,
+// const weibull_distribution& y);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::weibull_distribution<> D;
+ D d1(2.5, 4);
+ D d2(2.5, 4);
+ assert(d1 == d2);
+ }
+ {
+ typedef std::weibull_distribution<> D;
+ D d1(2.5, 4);
+ D d2(2.5, 4.5);
+ assert(d1 != d2);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/eval.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/eval.pass.cpp
new file mode 100644
index 000000000000..e414932dc870
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/eval.pass.cpp
@@ -0,0 +1,166 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// REQUIRES: long_tests
+
+// <random>
+
+// template<class RealType = double>
+// class weibull_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g);
+
+#include <random>
+#include <cassert>
+#include <vector>
+#include <numeric>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+ return x * x;
+}
+
+int main()
+{
+ {
+ typedef std::weibull_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(0.5, 2);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = d.b() * std::tgamma(1 + 1/d.a());
+ double x_var = sqr(d.b()) * std::tgamma(1 + 2/d.a()) - sqr(x_mean);
+ double x_skew = (sqr(d.b())*d.b() * std::tgamma(1 + 3/d.a()) -
+ 3*x_mean*x_var - sqr(x_mean)*x_mean) /
+ (std::sqrt(x_var)*x_var);
+ double x_kurtosis = (sqr(sqr(d.b())) * std::tgamma(1 + 4/d.a()) -
+ 4*x_skew*x_var*sqrt(x_var)*x_mean -
+ 6*sqr(x_mean)*x_var - sqr(sqr(x_mean))) / sqr(x_var) - 3;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.03);
+ }
+ {
+ typedef std::weibull_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(1, .5);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = d.b() * std::tgamma(1 + 1/d.a());
+ double x_var = sqr(d.b()) * std::tgamma(1 + 2/d.a()) - sqr(x_mean);
+ double x_skew = (sqr(d.b())*d.b() * std::tgamma(1 + 3/d.a()) -
+ 3*x_mean*x_var - sqr(x_mean)*x_mean) /
+ (std::sqrt(x_var)*x_var);
+ double x_kurtosis = (sqr(sqr(d.b())) * std::tgamma(1 + 4/d.a()) -
+ 4*x_skew*x_var*sqrt(x_var)*x_mean -
+ 6*sqr(x_mean)*x_var - sqr(sqr(x_mean))) / sqr(x_var) - 3;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ {
+ typedef std::weibull_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(2, 3);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = d.b() * std::tgamma(1 + 1/d.a());
+ double x_var = sqr(d.b()) * std::tgamma(1 + 2/d.a()) - sqr(x_mean);
+ double x_skew = (sqr(d.b())*d.b() * std::tgamma(1 + 3/d.a()) -
+ 3*x_mean*x_var - sqr(x_mean)*x_mean) /
+ (std::sqrt(x_var)*x_var);
+ double x_kurtosis = (sqr(sqr(d.b())) * std::tgamma(1 + 4/d.a()) -
+ 4*x_skew*x_var*sqrt(x_var)*x_mean -
+ 6*sqr(x_mean)*x_var - sqr(sqr(x_mean))) / sqr(x_var) - 3;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.03);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/eval_param.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/eval_param.pass.cpp
new file mode 100644
index 000000000000..6da705eb26c7
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/eval_param.pass.cpp
@@ -0,0 +1,169 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// REQUIRES: long_tests
+
+// <random>
+
+// template<class RealType = double>
+// class weibull_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g, const param_type& parm);
+
+#include <random>
+#include <cassert>
+#include <vector>
+#include <numeric>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+ return x * x;
+}
+
+int main()
+{
+ {
+ typedef std::weibull_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(0.5, 2);
+ P p(1, .5);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, p);
+ assert(d.min() <= v);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = p.b() * std::tgamma(1 + 1/p.a());
+ double x_var = sqr(p.b()) * std::tgamma(1 + 2/p.a()) - sqr(x_mean);
+ double x_skew = (sqr(p.b())*p.b() * std::tgamma(1 + 3/p.a()) -
+ 3*x_mean*x_var - sqr(x_mean)*x_mean) /
+ (std::sqrt(x_var)*x_var);
+ double x_kurtosis = (sqr(sqr(p.b())) * std::tgamma(1 + 4/p.a()) -
+ 4*x_skew*x_var*sqrt(x_var)*x_mean -
+ 6*sqr(x_mean)*x_var - sqr(sqr(x_mean))) / sqr(x_var) - 3;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ {
+ typedef std::weibull_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(1, .5);
+ P p(2, 3);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, p);
+ assert(d.min() <= v);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = p.b() * std::tgamma(1 + 1/p.a());
+ double x_var = sqr(p.b()) * std::tgamma(1 + 2/p.a()) - sqr(x_mean);
+ double x_skew = (sqr(p.b())*p.b() * std::tgamma(1 + 3/p.a()) -
+ 3*x_mean*x_var - sqr(x_mean)*x_mean) /
+ (std::sqrt(x_var)*x_var);
+ double x_kurtosis = (sqr(sqr(p.b())) * std::tgamma(1 + 4/p.a()) -
+ 4*x_skew*x_var*sqrt(x_var)*x_mean -
+ 6*sqr(x_mean)*x_var - sqr(sqr(x_mean))) / sqr(x_var) - 3;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.03);
+ }
+ {
+ typedef std::weibull_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(2, 3);
+ P p(.5, 2);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, p);
+ assert(d.min() <= v);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = p.b() * std::tgamma(1 + 1/p.a());
+ double x_var = sqr(p.b()) * std::tgamma(1 + 2/p.a()) - sqr(x_mean);
+ double x_skew = (sqr(p.b())*p.b() * std::tgamma(1 + 3/p.a()) -
+ 3*x_mean*x_var - sqr(x_mean)*x_mean) /
+ (std::sqrt(x_var)*x_var);
+ double x_kurtosis = (sqr(sqr(p.b())) * std::tgamma(1 + 4/p.a()) -
+ 4*x_skew*x_var*sqrt(x_var)*x_mean -
+ 6*sqr(x_mean)*x_var - sqr(sqr(x_mean))) / sqr(x_var) - 3;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.03);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/get_param.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/get_param.pass.cpp
new file mode 100644
index 000000000000..5047a93e663e
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/get_param.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class weibull_distribution
+
+// param_type param() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::weibull_distribution<> D;
+ typedef D::param_type P;
+ P p(.125, .5);
+ D d(p);
+ assert(d.param() == p);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/io.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/io.pass.cpp
new file mode 100644
index 000000000000..73b9aedbacf6
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/io.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class weibull_distribution
+
+// template <class CharT, class Traits, class RealType>
+// basic_ostream<CharT, Traits>&
+// operator<<(basic_ostream<CharT, Traits>& os,
+// const weibull_distribution<RealType>& x);
+
+// template <class CharT, class Traits, class RealType>
+// basic_istream<CharT, Traits>&
+// operator>>(basic_istream<CharT, Traits>& is,
+// weibull_distribution<RealType>& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::weibull_distribution<> D;
+ D d1(7, 5);
+ std::ostringstream os;
+ os << d1;
+ std::istringstream is(os.str());
+ D d2;
+ is >> d2;
+ assert(d1 == d2);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/max.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/max.pass.cpp
new file mode 100644
index 000000000000..d3a44b305aa6
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/max.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class weibull_distribution
+
+// result_type max() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::weibull_distribution<> D;
+ D d(5, .25);
+ D::result_type m = d.max();
+ assert(m == INFINITY);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/min.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/min.pass.cpp
new file mode 100644
index 000000000000..fee46ab51ea8
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/min.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class weibull_distribution
+
+// result_type min() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::weibull_distribution<> D;
+ D d(.5, .5);
+ assert(d.min() == 0);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/param_assign.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/param_assign.pass.cpp
new file mode 100644
index 000000000000..2d978cda24b6
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/param_assign.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class weibull_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::weibull_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p0(.75, 6);
+ param_type p;
+ p = p0;
+ assert(p.a() == .75);
+ assert(p.b() == 6);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/param_copy.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/param_copy.pass.cpp
new file mode 100644
index 000000000000..815a2c732674
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/param_copy.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class weibull_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::weibull_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p0(10, .125);
+ param_type p = p0;
+ assert(p.a() == 10);
+ assert(p.b() == .125);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/param_ctor.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/param_ctor.pass.cpp
new file mode 100644
index 000000000000..3f9e29f8d7c5
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/param_ctor.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class weibull_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::weibull_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p;
+ assert(p.a() == 1);
+ assert(p.b() == 1);
+ }
+ {
+ typedef std::weibull_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p(10);
+ assert(p.a() == 10);
+ assert(p.b() == 1);
+ }
+ {
+ typedef std::weibull_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p(10, 5);
+ assert(p.a() == 10);
+ assert(p.b() == 5);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/param_eq.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/param_eq.pass.cpp
new file mode 100644
index 000000000000..b94e6c19b474
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/param_eq.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class weibull_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::weibull_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p1(0.75, .5);
+ param_type p2(0.75, .5);
+ assert(p1 == p2);
+ }
+ {
+ typedef std::weibull_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p1(0.75, .5);
+ param_type p2(0.5, .5);
+ assert(p1 != p2);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/param_types.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/param_types.pass.cpp
new file mode 100644
index 000000000000..102f68d4774e
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/param_types.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class weibull_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::weibull_distribution<> D;
+ typedef D::param_type param_type;
+ typedef param_type::distribution_type distribution_type;
+ static_assert((std::is_same<D, distribution_type>::value), "");
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/set_param.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/set_param.pass.cpp
new file mode 100644
index 000000000000..b200e43c5e08
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/set_param.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class weibull_distribution;
+
+// void param(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::weibull_distribution<> D;
+ typedef D::param_type P;
+ P p(0.25, 5.5);
+ D d(0.75, 4);
+ d.param(p);
+ assert(d.param() == p);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/types.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/types.pass.cpp
new file mode 100644
index 000000000000..6f82c70473ea
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/types.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class weibull_distribution
+// {
+// public:
+// // types
+// typedef RealType result_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::weibull_distribution<> D;
+ typedef D::result_type result_type;
+ static_assert((std::is_same<result_type, double>::value), "");
+ }
+ {
+ typedef std::weibull_distribution<float> D;
+ typedef D::result_type result_type;
+ static_assert((std::is_same<result_type, float>::value), "");
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.samp/nothing_to_do.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.samp/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.samp/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/assign.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/assign.pass.cpp
new file mode 100644
index 000000000000..aee3f74f26c8
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/assign.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class discrete_distribution
+
+// discrete_distribution& operator=(const discrete_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::discrete_distribution<> D;
+ double p[] = {2, 4, 1, 8};
+ D d1(p, p+4);
+ D d2;
+ assert(d1 != d2);
+ d2 = d1;
+ assert(d1 == d2);
+}
+
+int main()
+{
+ test1();
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/copy.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/copy.pass.cpp
new file mode 100644
index 000000000000..b133ac708da1
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/copy.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class discrete_distribution
+
+// discrete_distribution(const discrete_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::discrete_distribution<> D;
+ double p[] = {2, 4, 1, 8};
+ D d1(p, p+4);
+ D d2 = d1;
+ assert(d1 == d2);
+}
+
+int main()
+{
+ test1();
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/ctor_default.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/ctor_default.pass.cpp
new file mode 100644
index 000000000000..3c1ed6a186e1
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/ctor_default.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class discrete_distribution
+
+// discrete_distribution();
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::discrete_distribution<> D;
+ D d;
+ std::vector<double> p = d.probabilities();
+ assert(p.size() == 1);
+ assert(p[0] == 1);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/ctor_func.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/ctor_func.pass.cpp
new file mode 100644
index 000000000000..34af69382c18
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/ctor_func.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class discrete_distribution
+
+// template<class UnaryOperation>
+// discrete_distribution(size_t nw, double xmin, double xmax,
+// UnaryOperation fw);
+
+#include <random>
+#include <cassert>
+
+double fw(double x)
+{
+ return x+1;
+}
+
+int main()
+{
+ {
+ typedef std::discrete_distribution<> D;
+ D d(0, 0, 1, fw);
+ std::vector<double> p = d.probabilities();
+ assert(p.size() == 1);
+ assert(p[0] == 1);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ D d(1, 0, 1, fw);
+ std::vector<double> p = d.probabilities();
+ assert(p.size() == 1);
+ assert(p[0] == 1);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ D d(2, 0.5, 1.5, fw);
+ std::vector<double> p = d.probabilities();
+ assert(p.size() == 2);
+ assert(p[0] == .4375);
+ assert(p[1] == .5625);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ D d(4, 0, 2, fw);
+ std::vector<double> p = d.probabilities();
+ assert(p.size() == 4);
+ assert(p[0] == .15625);
+ assert(p[1] == .21875);
+ assert(p[2] == .28125);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/ctor_init.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/ctor_init.pass.cpp
new file mode 100644
index 000000000000..bc4494b9848e
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/ctor_init.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class discrete_distribution
+
+// discrete_distribution(initializer_list<double> wl);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::discrete_distribution<> D;
+ D d = {};
+ std::vector<double> p = d.probabilities();
+ assert(p.size() == 1);
+ assert(p[0] == 1);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ D d = {10};
+ std::vector<double> p = d.probabilities();
+ assert(p.size() == 1);
+ assert(p[0] == 1);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ D d = {10, 30};
+ std::vector<double> p = d.probabilities();
+ assert(p.size() == 2);
+ assert(p[0] == 0.25);
+ assert(p[1] == 0.75);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ D d = {30, 10};
+ std::vector<double> p = d.probabilities();
+ assert(p.size() == 2);
+ assert(p[0] == 0.75);
+ assert(p[1] == 0.25);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ D d = {30, 0, 10};
+ std::vector<double> p = d.probabilities();
+ assert(p.size() == 3);
+ assert(p[0] == 0.75);
+ assert(p[1] == 0);
+ assert(p[2] == 0.25);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ D d = {0, 30, 10};
+ std::vector<double> p = d.probabilities();
+ assert(p.size() == 3);
+ assert(p[0] == 0);
+ assert(p[1] == 0.75);
+ assert(p[2] == 0.25);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ D d = {0, 0, 10};
+ std::vector<double> p = d.probabilities();
+ assert(p.size() == 3);
+ assert(p[0] == 0);
+ assert(p[1] == 0);
+ assert(p[2] == 1);
+ }
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/ctor_iterator.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/ctor_iterator.pass.cpp
new file mode 100644
index 000000000000..65e14eeed2a9
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/ctor_iterator.pass.cpp
@@ -0,0 +1,87 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class discrete_distribution
+
+// template<class InputIterator>
+// discrete_distribution(InputIterator firstW, InputIterator lastW);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::discrete_distribution<> D;
+ double p0[] = {1};
+ D d(p0, p0);
+ std::vector<double> p = d.probabilities();
+ assert(p.size() == 1);
+ assert(p[0] == 1);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ double p0[] = {10};
+ D d(p0, p0+1);
+ std::vector<double> p = d.probabilities();
+ assert(p.size() == 1);
+ assert(p[0] == 1);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ double p0[] = {10, 30};
+ D d(p0, p0+2);
+ std::vector<double> p = d.probabilities();
+ assert(p.size() == 2);
+ assert(p[0] == 0.25);
+ assert(p[1] == 0.75);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ double p0[] = {30, 10};
+ D d(p0, p0+2);
+ std::vector<double> p = d.probabilities();
+ assert(p.size() == 2);
+ assert(p[0] == 0.75);
+ assert(p[1] == 0.25);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ double p0[] = {30, 0, 10};
+ D d(p0, p0+3);
+ std::vector<double> p = d.probabilities();
+ assert(p.size() == 3);
+ assert(p[0] == 0.75);
+ assert(p[1] == 0);
+ assert(p[2] == 0.25);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ double p0[] = {0, 30, 10};
+ D d(p0, p0+3);
+ std::vector<double> p = d.probabilities();
+ assert(p.size() == 3);
+ assert(p[0] == 0);
+ assert(p[1] == 0.75);
+ assert(p[2] == 0.25);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ double p0[] = {0, 0, 10};
+ D d(p0, p0+3);
+ std::vector<double> p = d.probabilities();
+ assert(p.size() == 3);
+ assert(p[0] == 0);
+ assert(p[1] == 0);
+ assert(p[2] == 1);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/ctor_param.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/ctor_param.pass.cpp
new file mode 100644
index 000000000000..c12fe45db92b
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/ctor_param.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class discrete_distribution
+
+// explicit discrete_distribution(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::discrete_distribution<> D;
+ typedef D::param_type P;
+ double p0[] = {10, 30};
+ P pa(p0, p0+2);
+ D d(pa);
+ std::vector<double> p = d.probabilities();
+ assert(p.size() == 2);
+ assert(p[0] == 0.25);
+ assert(p[1] == 0.75);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/eq.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/eq.pass.cpp
new file mode 100644
index 000000000000..bad06987b0ca
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/eq.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class discrete_distribution
+
+// bool operator=(const discrete_distribution& x,
+// const discrete_distribution& y);
+// bool operator!(const discrete_distribution& x,
+// const discrete_distribution& y);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::discrete_distribution<> D;
+ D d1;
+ D d2;
+ assert(d1 == d2);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ double p0[] = {1};
+ D d1(p0, p0+1);
+ D d2;
+ assert(d1 == d2);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ double p0[] = {10, 30};
+ D d1(p0, p0+2);
+ D d2;
+ assert(d1 != d2);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/eval.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/eval.pass.cpp
new file mode 100644
index 000000000000..55080b252028
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/eval.pass.cpp
@@ -0,0 +1,279 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// REQUIRES: long_tests
+
+// <random>
+
+// template<class IntType = int>
+// class discrete_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g);
+
+#include <random>
+#include <vector>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::discrete_distribution<> D;
+ typedef std::minstd_rand G;
+ G g;
+ D d;
+ const int N = 100;
+ std::vector<D::result_type> u(d.max()+1);
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v <= d.max());
+ u[v]++;
+ }
+ std::vector<double> prob = d.probabilities();
+ for (int i = 0; i <= d.max(); ++i)
+ assert((double)u[i]/N == prob[i]);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ typedef std::minstd_rand G;
+ G g;
+ double p0[] = {.3};
+ D d(p0, p0+1);
+ const int N = 100;
+ std::vector<D::result_type> u(d.max()+1);
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v <= d.max());
+ u[v]++;
+ }
+ std::vector<double> prob = d.probabilities();
+ for (int i = 0; i <= d.max(); ++i)
+ assert((double)u[i]/N == prob[i]);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ typedef std::minstd_rand G;
+ G g;
+ double p0[] = {.75, .25};
+ D d(p0, p0+2);
+ const int N = 1000000;
+ std::vector<D::result_type> u(d.max()+1);
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v <= d.max());
+ u[v]++;
+ }
+ std::vector<double> prob = d.probabilities();
+ for (int i = 0; i <= d.max(); ++i)
+ assert(std::abs((double)u[i]/N - prob[i]) / prob[i] < 0.001);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ typedef std::minstd_rand G;
+ G g;
+ double p0[] = {0, 1};
+ D d(p0, p0+2);
+ const int N = 1000000;
+ std::vector<D::result_type> u(d.max()+1);
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v <= d.max());
+ u[v]++;
+ }
+ std::vector<double> prob = d.probabilities();
+ assert((double)u[0]/N == prob[0]);
+ assert((double)u[1]/N == prob[1]);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ typedef std::minstd_rand G;
+ G g;
+ double p0[] = {1, 0};
+ D d(p0, p0+2);
+ const int N = 1000000;
+ std::vector<D::result_type> u(d.max()+1);
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v <= d.max());
+ u[v]++;
+ }
+ std::vector<double> prob = d.probabilities();
+ assert((double)u[0]/N == prob[0]);
+ assert((double)u[1]/N == prob[1]);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ typedef std::minstd_rand G;
+ G g;
+ double p0[] = {.3, .1, .6};
+ D d(p0, p0+3);
+ const int N = 10000000;
+ std::vector<D::result_type> u(d.max()+1);
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v <= d.max());
+ u[v]++;
+ }
+ std::vector<double> prob = d.probabilities();
+ for (int i = 0; i <= d.max(); ++i)
+ assert(std::abs((double)u[i]/N - prob[i]) / prob[i] < 0.001);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ typedef std::minstd_rand G;
+ G g;
+ double p0[] = {0, 25, 75};
+ D d(p0, p0+3);
+ const int N = 1000000;
+ std::vector<D::result_type> u(d.max()+1);
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v <= d.max());
+ u[v]++;
+ }
+ std::vector<double> prob = d.probabilities();
+ for (int i = 0; i <= d.max(); ++i)
+ if (prob[i] != 0)
+ assert(std::abs((double)u[i]/N - prob[i]) / prob[i] < 0.001);
+ else
+ assert(u[i] == 0);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ typedef std::minstd_rand G;
+ G g;
+ double p0[] = {25, 0, 75};
+ D d(p0, p0+3);
+ const int N = 1000000;
+ std::vector<D::result_type> u(d.max()+1);
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v <= d.max());
+ u[v]++;
+ }
+ std::vector<double> prob = d.probabilities();
+ for (int i = 0; i <= d.max(); ++i)
+ if (prob[i] != 0)
+ assert(std::abs((double)u[i]/N - prob[i]) / prob[i] < 0.001);
+ else
+ assert(u[i] == 0);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ typedef std::minstd_rand G;
+ G g;
+ double p0[] = {25, 75, 0};
+ D d(p0, p0+3);
+ const int N = 1000000;
+ std::vector<D::result_type> u(d.max()+1);
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v <= d.max());
+ u[v]++;
+ }
+ std::vector<double> prob = d.probabilities();
+ for (int i = 0; i <= d.max(); ++i)
+ if (prob[i] != 0)
+ assert(std::abs((double)u[i]/N - prob[i]) / prob[i] < 0.001);
+ else
+ assert(u[i] == 0);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ typedef std::minstd_rand G;
+ G g;
+ double p0[] = {0, 0, 1};
+ D d(p0, p0+3);
+ const int N = 100;
+ std::vector<D::result_type> u(d.max()+1);
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v <= d.max());
+ u[v]++;
+ }
+ std::vector<double> prob = d.probabilities();
+ for (int i = 0; i <= d.max(); ++i)
+ if (prob[i] != 0)
+ assert(std::abs((double)u[i]/N - prob[i]) / prob[i] < 0.001);
+ else
+ assert(u[i] == 0);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ typedef std::minstd_rand G;
+ G g;
+ double p0[] = {0, 1, 0};
+ D d(p0, p0+3);
+ const int N = 100;
+ std::vector<D::result_type> u(d.max()+1);
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v <= d.max());
+ u[v]++;
+ }
+ std::vector<double> prob = d.probabilities();
+ for (int i = 0; i <= d.max(); ++i)
+ if (prob[i] != 0)
+ assert(std::abs((double)u[i]/N - prob[i]) / prob[i] < 0.001);
+ else
+ assert(u[i] == 0);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ typedef std::minstd_rand G;
+ G g;
+ double p0[] = {1, 0, 0};
+ D d(p0, p0+3);
+ const int N = 100;
+ std::vector<D::result_type> u(d.max()+1);
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v <= d.max());
+ u[v]++;
+ }
+ std::vector<double> prob = d.probabilities();
+ for (int i = 0; i <= d.max(); ++i)
+ if (prob[i] != 0)
+ assert(std::abs((double)u[i]/N - prob[i]) / prob[i] < 0.001);
+ else
+ assert(u[i] == 0);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ typedef std::minstd_rand G;
+ G g;
+ double p0[] = {33, 0, 0, 67};
+ D d(p0, p0+3);
+ const int N = 1000000;
+ std::vector<D::result_type> u(d.max()+1);
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v <= d.max());
+ u[v]++;
+ }
+ std::vector<double> prob = d.probabilities();
+ for (int i = 0; i <= d.max(); ++i)
+ if (prob[i] != 0)
+ assert(std::abs((double)u[i]/N - prob[i]) / prob[i] < 0.001);
+ else
+ assert(u[i] == 0);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/eval_param.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/eval_param.pass.cpp
new file mode 100644
index 000000000000..8d8a22424091
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/eval_param.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// REQUIRES: long_tests
+
+// <random>
+
+// template<class IntType = int>
+// class discrete_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g, const param_type& parm);
+
+#include <random>
+#include <vector>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::discrete_distribution<> D;
+ typedef D::param_type P;
+ typedef std::minstd_rand G;
+ G g;
+ D d;
+ double p0[] = {.3, .1, .6};
+ P p(p0, p0+3);
+ const int N = 10000000;
+ std::vector<D::result_type> u(3);
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, p);
+ assert(0 <= v && v <= 2);
+ u[v]++;
+ }
+ std::vector<double> prob = p.probabilities();
+ for (int i = 0; i <= 2; ++i)
+ assert(std::abs((double)u[i]/N - prob[i]) / prob[i] < 0.001);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/get_param.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/get_param.pass.cpp
new file mode 100644
index 000000000000..4970c5aae404
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/get_param.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class discrete_distribution
+
+// param_type param() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::discrete_distribution<> D;
+ typedef D::param_type P;
+ double p0[] = {.3, .1, .6};
+ P p(p0, p0+3);
+ D d(p);
+ assert(d.param() == p);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/io.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/io.pass.cpp
new file mode 100644
index 000000000000..92499501659d
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/io.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class discrete_distribution
+
+// template <class charT, class traits>
+// basic_ostream<charT, traits>&
+// operator<<(basic_ostream<charT, traits>& os,
+// const discrete_distribution& x);
+//
+// template <class charT, class traits>
+// basic_istream<charT, traits>&
+// operator>>(basic_istream<charT, traits>& is,
+// discrete_distribution& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::discrete_distribution<> D;
+ double p0[] = {.3, .1, .6};
+ D d1(p0, p0+3);
+ std::ostringstream os;
+ os << d1;
+ std::istringstream is(os.str());
+ D d2;
+ is >> d2;
+ assert(d1 == d2);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/max.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/max.pass.cpp
new file mode 100644
index 000000000000..b1d1acdab503
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/max.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class discrete_distribution
+
+// result_type max() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::discrete_distribution<> D;
+ double p0[] = {.3, .1, .6};
+ D d(p0, p0+3);
+ assert(d.max() == 2);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ double p0[] = {.3, .1, .6, .2};
+ D d(p0, p0+4);
+ assert(d.max() == 3);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/min.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/min.pass.cpp
new file mode 100644
index 000000000000..ab9383238140
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/min.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class discrete_distribution
+
+// result_type min() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::discrete_distribution<> D;
+ double p0[] = {.3, .1, .6};
+ D d(p0, p0+3);
+ assert(d.min() == 0);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_assign.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_assign.pass.cpp
new file mode 100644
index 000000000000..ea57852b62cd
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_assign.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class discrete_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::discrete_distribution<> D;
+ typedef D::param_type param_type;
+ double d0[] = {.3, .1, .6};
+ param_type p0(d0, d0+3);
+ param_type p;
+ p = p0;
+ assert(p == p0);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_copy.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_copy.pass.cpp
new file mode 100644
index 000000000000..b65ebb0d8c73
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_copy.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class discrete_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::discrete_distribution<> D;
+ typedef D::param_type param_type;
+ double d0[] = {.3, .1, .6};
+ param_type p0(d0, d0+3);
+ param_type p = p0;
+ assert(p == p0);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_ctor_default.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_ctor_default.pass.cpp
new file mode 100644
index 000000000000..1071305f4db7
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_ctor_default.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class discrete_distribution
+
+// param_type(initializer_list<double> wl);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::discrete_distribution<> D;
+ typedef D::param_type P;
+ P pa = {1};
+ std::vector<double> p = pa.probabilities();
+ assert(p.size() == 1);
+ assert(p[0] == 1);
+ }
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_ctor_func.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_ctor_func.pass.cpp
new file mode 100644
index 000000000000..6d43b2234fc2
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_ctor_func.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class discrete_distribution
+
+// template<class UnaryOperation>
+// param_type(size_t nw, double xmin, double xmax,
+// UnaryOperation fw);
+
+#include <random>
+#include <cassert>
+
+double fw(double x)
+{
+ return x+1;
+}
+
+int main()
+{
+ {
+ typedef std::discrete_distribution<> D;
+ typedef D::param_type P;
+ P pa(0, 0, 1, fw);
+ std::vector<double> p = pa.probabilities();
+ assert(p.size() == 1);
+ assert(p[0] == 1);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ typedef D::param_type P;
+ P pa(1, 0, 1, fw);
+ std::vector<double> p = pa.probabilities();
+ assert(p.size() == 1);
+ assert(p[0] == 1);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ typedef D::param_type P;
+ P pa(2, 0.5, 1.5, fw);
+ std::vector<double> p = pa.probabilities();
+ assert(p.size() == 2);
+ assert(p[0] == .4375);
+ assert(p[1] == .5625);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ typedef D::param_type P;
+ P pa(4, 0, 2, fw);
+ std::vector<double> p = pa.probabilities();
+ assert(p.size() == 4);
+ assert(p[0] == .15625);
+ assert(p[1] == .21875);
+ assert(p[2] == .28125);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_ctor_init.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_ctor_init.pass.cpp
new file mode 100644
index 000000000000..79d8a0b71a92
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_ctor_init.pass.cpp
@@ -0,0 +1,88 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class discrete_distribution
+
+// param_type(initializer_list<double> wl);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::discrete_distribution<> D;
+ typedef D::param_type P;
+ P pa = {};
+ std::vector<double> p = pa.probabilities();
+ assert(p.size() == 1);
+ assert(p[0] == 1);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ typedef D::param_type P;
+ P pa = {10};
+ std::vector<double> p = pa.probabilities();
+ assert(p.size() == 1);
+ assert(p[0] == 1);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ typedef D::param_type P;
+ P pa = {10, 30};
+ std::vector<double> p = pa.probabilities();
+ assert(p.size() == 2);
+ assert(p[0] == 0.25);
+ assert(p[1] == 0.75);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ typedef D::param_type P;
+ P pa = {30, 10};
+ std::vector<double> p = pa.probabilities();
+ assert(p.size() == 2);
+ assert(p[0] == 0.75);
+ assert(p[1] == 0.25);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ typedef D::param_type P;
+ P pa = {30, 0, 10};
+ std::vector<double> p = pa.probabilities();
+ assert(p.size() == 3);
+ assert(p[0] == 0.75);
+ assert(p[1] == 0);
+ assert(p[2] == 0.25);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ typedef D::param_type P;
+ P pa = {0, 30, 10};
+ std::vector<double> p = pa.probabilities();
+ assert(p.size() == 3);
+ assert(p[0] == 0);
+ assert(p[1] == 0.75);
+ assert(p[2] == 0.25);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ typedef D::param_type P;
+ P pa = {0, 0, 10};
+ std::vector<double> p = pa.probabilities();
+ assert(p.size() == 3);
+ assert(p[0] == 0);
+ assert(p[1] == 0);
+ assert(p[2] == 1);
+ }
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_ctor_iterator.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_ctor_iterator.pass.cpp
new file mode 100644
index 000000000000..7ef646707c14
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_ctor_iterator.pass.cpp
@@ -0,0 +1,94 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class discrete_distribution
+
+// template<class InputIterator>
+// param_type(InputIterator firstW, InputIterator lastW);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::discrete_distribution<> D;
+ typedef D::param_type P;
+ double p0[] = {1};
+ P pa(p0, p0);
+ std::vector<double> p = pa.probabilities();
+ assert(p.size() == 1);
+ assert(p[0] == 1);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ typedef D::param_type P;
+ double p0[] = {10};
+ P pa(p0, p0+1);
+ std::vector<double> p = pa.probabilities();
+ assert(p.size() == 1);
+ assert(p[0] == 1);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ typedef D::param_type P;
+ double p0[] = {10, 30};
+ P pa(p0, p0+2);
+ std::vector<double> p = pa.probabilities();
+ assert(p.size() == 2);
+ assert(p[0] == 0.25);
+ assert(p[1] == 0.75);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ typedef D::param_type P;
+ double p0[] = {30, 10};
+ P pa(p0, p0+2);
+ std::vector<double> p = pa.probabilities();
+ assert(p.size() == 2);
+ assert(p[0] == 0.75);
+ assert(p[1] == 0.25);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ typedef D::param_type P;
+ double p0[] = {30, 0, 10};
+ P pa(p0, p0+3);
+ std::vector<double> p = pa.probabilities();
+ assert(p.size() == 3);
+ assert(p[0] == 0.75);
+ assert(p[1] == 0);
+ assert(p[2] == 0.25);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ typedef D::param_type P;
+ double p0[] = {0, 30, 10};
+ P pa(p0, p0+3);
+ std::vector<double> p = pa.probabilities();
+ assert(p.size() == 3);
+ assert(p[0] == 0);
+ assert(p[1] == 0.75);
+ assert(p[2] == 0.25);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ typedef D::param_type P;
+ double p0[] = {0, 0, 10};
+ P pa(p0, p0+3);
+ std::vector<double> p = pa.probabilities();
+ assert(p.size() == 3);
+ assert(p[0] == 0);
+ assert(p[1] == 0);
+ assert(p[2] == 1);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_eq.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_eq.pass.cpp
new file mode 100644
index 000000000000..6ec2c2aad4b1
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_eq.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class discrete_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::discrete_distribution<> D;
+ typedef D::param_type param_type;
+ double p0[] = {30, 10};
+ param_type p1(p0, p0+2);
+ param_type p2(p0, p0+2);
+ assert(p1 == p2);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ typedef D::param_type param_type;
+ double p0[] = {30, 10};
+ param_type p1(p0, p0+2);
+ param_type p2;
+ assert(p1 != p2);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_types.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_types.pass.cpp
new file mode 100644
index 000000000000..086b7600feb0
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_types.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class discrete_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::discrete_distribution<> D;
+ typedef D::param_type param_type;
+ typedef param_type::distribution_type distribution_type;
+ static_assert((std::is_same<D, distribution_type>::value), "");
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/set_param.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/set_param.pass.cpp
new file mode 100644
index 000000000000..bc433ec75644
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/set_param.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class discrete_distribution
+
+// void param(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::discrete_distribution<> D;
+ typedef D::param_type P;
+ double d0[] = {.3, .1, .6};
+ P p(d0, d0+3);
+ D d;
+ d.param(p);
+ assert(d.param() == p);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/types.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/types.pass.cpp
new file mode 100644
index 000000000000..af73008ff418
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/types.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class discrete_distribution
+// {
+// typedef bool result_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::discrete_distribution<> D;
+ typedef D::result_type result_type;
+ static_assert((std::is_same<result_type, int>::value), "");
+ }
+ {
+ typedef std::discrete_distribution<long> D;
+ typedef D::result_type result_type;
+ static_assert((std::is_same<result_type, long>::value), "");
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/assign.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/assign.pass.cpp
new file mode 100644
index 000000000000..e5c994445d44
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/assign.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_constant_distribution
+
+// piecewise_constant_distribution& operator=(const piecewise_constant_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::piecewise_constant_distribution<> D;
+ double p[] = {2, 4, 1, 8};
+ double b[] = {2, 4, 5, 8, 9};
+ D d1(b, b+5, p);
+ D d2;
+ assert(d1 != d2);
+ d2 = d1;
+ assert(d1 == d2);
+}
+
+int main()
+{
+ test1();
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/copy.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/copy.pass.cpp
new file mode 100644
index 000000000000..a3eb1f4a5038
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/copy.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_constant_distribution
+
+// piecewise_constant_distribution(const piecewise_constant_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::piecewise_constant_distribution<> D;
+ double p[] = {2, 4, 1, 8};
+ double b[] = {2, 4, 5, 8, 9};
+ D d1(b, b+5, p);
+ D d2 = d1;
+ assert(d1 == d2);
+}
+
+int main()
+{
+ test1();
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_default.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_default.pass.cpp
new file mode 100644
index 000000000000..d4f339fe7f3b
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_default.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_constant_distribution
+
+// piecewise_constant_distribution(initializer_list<double> wl);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ D d;
+ std::vector<double> iv = d.intervals();
+ assert(iv.size() == 2);
+ assert(iv[0] == 0);
+ assert(iv[1] == 1);
+ std::vector<double> dn = d.densities();
+ assert(dn.size() == 1);
+ assert(dn[0] == 1);
+ }
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_func.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_func.pass.cpp
new file mode 100644
index 000000000000..74fa23442687
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_func.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_constant_distribution
+
+// template<class UnaryOperation>
+// piecewise_constant_distribution(size_t nw, result_type xmin,
+// result_type xmax, UnaryOperation fw);
+
+#include <random>
+#include <cassert>
+
+double fw(double x)
+{
+ return 2*x;
+}
+
+int main()
+{
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ D d(0, 0, 1, fw);
+ std::vector<double> iv = d.intervals();
+ assert(iv.size() == 2);
+ assert(iv[0] == 0);
+ assert(iv[1] == 1);
+ std::vector<double> dn = d.densities();
+ assert(dn.size() == 1);
+ assert(dn[0] == 1);
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ D d(1, 10, 12, fw);
+ std::vector<double> iv = d.intervals();
+ assert(iv.size() == 2);
+ assert(iv[0] == 10);
+ assert(iv[1] == 12);
+ std::vector<double> dn = d.densities();
+ assert(dn.size() == 1);
+ assert(dn[0] == 0.5);
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ D d(2, 6, 14, fw);
+ std::vector<double> iv = d.intervals();
+ assert(iv.size() == 3);
+ assert(iv[0] == 6);
+ assert(iv[1] == 10);
+ assert(iv[2] == 14);
+ std::vector<double> dn = d.densities();
+ assert(dn.size() == 2);
+ assert(dn[0] == 0.1);
+ assert(dn[1] == 0.15);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_init_func.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_init_func.pass.cpp
new file mode 100644
index 000000000000..5708e45093cb
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_init_func.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_constant_distribution
+
+// piecewise_constant_distribution(initializer_list<result_type> bl,
+// UnaryOperation fw);
+
+#include <iostream>
+
+#include <random>
+#include <cassert>
+
+double f(double x)
+{
+ return x*2;
+}
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ D d({}, f);
+ std::vector<double> iv = d.intervals();
+ assert(iv.size() == 2);
+ assert(iv[0] == 0);
+ assert(iv[1] == 1);
+ std::vector<double> dn = d.densities();
+ assert(dn.size() == 1);
+ assert(dn[0] == 1);
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ D d({12}, f);
+ std::vector<double> iv = d.intervals();
+ assert(iv.size() == 2);
+ assert(iv[0] == 0);
+ assert(iv[1] == 1);
+ std::vector<double> dn = d.densities();
+ assert(dn.size() == 1);
+ assert(dn[0] == 1);
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ D d({12, 14}, f);
+ std::vector<double> iv = d.intervals();
+ assert(iv.size() == 2);
+ assert(iv[0] == 12);
+ assert(iv[1] == 14);
+ std::vector<double> dn = d.densities();
+ assert(dn.size() == 1);
+ assert(dn[0] == 0.5);
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ D d({5.5, 7.5, 11.5}, f);
+ std::vector<double> iv = d.intervals();
+ assert(iv.size() == 3);
+ assert(iv[0] == 5.5);
+ assert(iv[1] == 7.5);
+ assert(iv[2] == 11.5);
+ std::vector<double> dn = d.densities();
+ assert(dn.size() == 2);
+ assert(dn[0] == 0.203125);
+ assert(dn[1] == 0.1484375);
+ }
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_iterator.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_iterator.pass.cpp
new file mode 100644
index 000000000000..d994b0a802b1
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_iterator.pass.cpp
@@ -0,0 +1,96 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_constant_distribution
+
+// template<class InputIterator>
+// piecewise_constant_distribution(InputIteratorB firstB,
+// InputIteratorB lastB,
+// InputIteratorW firstW);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ double b[] = {10};
+ double p[] = {12};
+ D d(b, b, p);
+ std::vector<double> iv = d.intervals();
+ assert(iv.size() == 2);
+ assert(iv[0] == 0);
+ assert(iv[1] == 1);
+ std::vector<double> dn = d.densities();
+ assert(dn.size() == 1);
+ assert(dn[0] == 1);
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ double b[] = {10};
+ double p[] = {12};
+ D d(b, b+1, p);
+ std::vector<double> iv = d.intervals();
+ assert(iv.size() == 2);
+ assert(iv[0] == 0);
+ assert(iv[1] == 1);
+ std::vector<double> dn = d.densities();
+ assert(dn.size() == 1);
+ assert(dn[0] == 1);
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ double b[] = {10, 15};
+ double p[] = {12};
+ D d(b, b+2, p);
+ std::vector<double> iv = d.intervals();
+ assert(iv.size() == 2);
+ assert(iv[0] == 10);
+ assert(iv[1] == 15);
+ std::vector<double> dn = d.densities();
+ assert(dn.size() == 1);
+ assert(dn[0] == 1/5.);
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ double b[] = {10, 15, 16};
+ double p[] = {.25, .75};
+ D d(b, b+3, p);
+ std::vector<double> iv = d.intervals();
+ assert(iv.size() == 3);
+ assert(iv[0] == 10);
+ assert(iv[1] == 15);
+ assert(iv[2] == 16);
+ std::vector<double> dn = d.densities();
+ assert(dn.size() == 2);
+ assert(dn[0] == .25/5.);
+ assert(dn[1] == .75);
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 62.5, 12.5};
+ D d(b, b+4, p);
+ std::vector<double> iv = d.intervals();
+ assert(iv.size() == 4);
+ assert(iv[0] == 10);
+ assert(iv[1] == 14);
+ assert(iv[2] == 16);
+ assert(iv[3] == 17);
+ std::vector<double> dn = d.densities();
+ assert(dn.size() == 3);
+ assert(dn[0] == .0625);
+ assert(dn[1] == .3125);
+ assert(dn[2] == .125);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_param.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_param.pass.cpp
new file mode 100644
index 000000000000..0ccdba6b964d
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_param.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_constant_distribution
+
+// explicit piecewise_constant_distribution(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef D::param_type P;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 62.5, 12.5};
+ P pa(b, b+4, p);
+ D d(pa);
+ std::vector<double> iv = d.intervals();
+ assert(iv.size() == 4);
+ assert(iv[0] == 10);
+ assert(iv[1] == 14);
+ assert(iv[2] == 16);
+ assert(iv[3] == 17);
+ std::vector<double> dn = d.densities();
+ assert(dn.size() == 3);
+ assert(dn[0] == .0625);
+ assert(dn[1] == .3125);
+ assert(dn[2] == .125);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/eq.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/eq.pass.cpp
new file mode 100644
index 000000000000..2ef9d7b6e0f3
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/eq.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_constant_distribution
+
+// bool operator=(const piecewise_constant_distribution& x,
+// const piecewise_constant_distribution& y);
+// bool operator!(const piecewise_constant_distribution& x,
+// const piecewise_constant_distribution& y);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ D d1;
+ D d2;
+ assert(d1 == d2);
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 62.5, 12.5};
+ D d1(b, b+4, p);
+ D d2(b, b+4, p);
+ assert(d1 == d2);
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 62.5, 12.5};
+ D d1(b, b+4, p);
+ D d2;
+ assert(d1 != d2);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/eval.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/eval.pass.cpp
new file mode 100644
index 000000000000..5d14b3612b2e
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/eval.pass.cpp
@@ -0,0 +1,695 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// REQUIRES: long_tests
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_constant_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g);
+
+#include <random>
+#include <vector>
+#include <iterator>
+#include <numeric>
+#include <cassert>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+ return x*x;
+}
+
+int main()
+{
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef std::mt19937_64 G;
+ G g;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 62.5, 12.5};
+ const size_t Np = sizeof(p) / sizeof(p[0]);
+ D d(b, b+Np+1, p);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v < d.max());
+ u.push_back(v);
+ }
+ std::vector<double> prob(std::begin(p), std::end(p));
+ double s = std::accumulate(prob.begin(), prob.end(), 0.0);
+ for (int i = 0; i < prob.size(); ++i)
+ prob[i] /= s;
+ std::sort(u.begin(), u.end());
+ for (int i = 0; i < Np; ++i)
+ {
+ typedef std::vector<D::result_type>::iterator I;
+ I lb = std::lower_bound(u.begin(), u.end(), b[i]);
+ I ub = std::lower_bound(u.begin(), u.end(), b[i+1]);
+ const size_t Ni = ub - lb;
+ if (prob[i] == 0)
+ assert(Ni == 0);
+ else
+ {
+ assert(std::abs((double)Ni/N - prob[i]) / prob[i] < .01);
+ double mean = std::accumulate(lb, ub, 0.0) / Ni;
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (I j = lb; j != ub; ++j)
+ {
+ double d = (*j - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= Ni;
+ double dev = std::sqrt(var);
+ skew /= Ni * dev * var;
+ kurtosis /= Ni * var * var;
+ kurtosis -= 3;
+ double x_mean = (b[i+1] + b[i]) / 2;
+ double x_var = sqr(b[i+1] - b[i]) / 12;
+ double x_skew = 0;
+ double x_kurtosis = -6./5;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs(skew - x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ }
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef std::mt19937_64 G;
+ G g;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {0, 62.5, 12.5};
+ const size_t Np = sizeof(p) / sizeof(p[0]);
+ D d(b, b+Np+1, p);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v < d.max());
+ u.push_back(v);
+ }
+ std::vector<double> prob(std::begin(p), std::end(p));
+ double s = std::accumulate(prob.begin(), prob.end(), 0.0);
+ for (int i = 0; i < prob.size(); ++i)
+ prob[i] /= s;
+ std::sort(u.begin(), u.end());
+ for (int i = 0; i < Np; ++i)
+ {
+ typedef std::vector<D::result_type>::iterator I;
+ I lb = std::lower_bound(u.begin(), u.end(), b[i]);
+ I ub = std::lower_bound(u.begin(), u.end(), b[i+1]);
+ const size_t Ni = ub - lb;
+ if (prob[i] == 0)
+ assert(Ni == 0);
+ else
+ {
+ assert(std::abs((double)Ni/N - prob[i]) / prob[i] < .01);
+ double mean = std::accumulate(lb, ub, 0.0) / Ni;
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (I j = lb; j != ub; ++j)
+ {
+ double d = (*j - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= Ni;
+ double dev = std::sqrt(var);
+ skew /= Ni * dev * var;
+ kurtosis /= Ni * var * var;
+ kurtosis -= 3;
+ double x_mean = (b[i+1] + b[i]) / 2;
+ double x_var = sqr(b[i+1] - b[i]) / 12;
+ double x_skew = 0;
+ double x_kurtosis = -6./5;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs(skew - x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ }
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef std::mt19937_64 G;
+ G g;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 0, 12.5};
+ const size_t Np = sizeof(p) / sizeof(p[0]);
+ D d(b, b+Np+1, p);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v < d.max());
+ u.push_back(v);
+ }
+ std::vector<double> prob(std::begin(p), std::end(p));
+ double s = std::accumulate(prob.begin(), prob.end(), 0.0);
+ for (int i = 0; i < prob.size(); ++i)
+ prob[i] /= s;
+ std::sort(u.begin(), u.end());
+ for (int i = 0; i < Np; ++i)
+ {
+ typedef std::vector<D::result_type>::iterator I;
+ I lb = std::lower_bound(u.begin(), u.end(), b[i]);
+ I ub = std::lower_bound(u.begin(), u.end(), b[i+1]);
+ const size_t Ni = ub - lb;
+ if (prob[i] == 0)
+ assert(Ni == 0);
+ else
+ {
+ assert(std::abs((double)Ni/N - prob[i]) / prob[i] < .01);
+ double mean = std::accumulate(lb, ub, 0.0) / Ni;
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (I j = lb; j != ub; ++j)
+ {
+ double d = (*j - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= Ni;
+ double dev = std::sqrt(var);
+ skew /= Ni * dev * var;
+ kurtosis /= Ni * var * var;
+ kurtosis -= 3;
+ double x_mean = (b[i+1] + b[i]) / 2;
+ double x_var = sqr(b[i+1] - b[i]) / 12;
+ double x_skew = 0;
+ double x_kurtosis = -6./5;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs(skew - x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ }
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef std::mt19937_64 G;
+ G g;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 62.5, 0};
+ const size_t Np = sizeof(p) / sizeof(p[0]);
+ D d(b, b+Np+1, p);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v < d.max());
+ u.push_back(v);
+ }
+ std::vector<double> prob(std::begin(p), std::end(p));
+ double s = std::accumulate(prob.begin(), prob.end(), 0.0);
+ for (int i = 0; i < prob.size(); ++i)
+ prob[i] /= s;
+ std::sort(u.begin(), u.end());
+ for (int i = 0; i < Np; ++i)
+ {
+ typedef std::vector<D::result_type>::iterator I;
+ I lb = std::lower_bound(u.begin(), u.end(), b[i]);
+ I ub = std::lower_bound(u.begin(), u.end(), b[i+1]);
+ const size_t Ni = ub - lb;
+ if (prob[i] == 0)
+ assert(Ni == 0);
+ else
+ {
+ assert(std::abs((double)Ni/N - prob[i]) / prob[i] < .01);
+ double mean = std::accumulate(lb, ub, 0.0) / Ni;
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (I j = lb; j != ub; ++j)
+ {
+ double d = (*j - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= Ni;
+ double dev = std::sqrt(var);
+ skew /= Ni * dev * var;
+ kurtosis /= Ni * var * var;
+ kurtosis -= 3;
+ double x_mean = (b[i+1] + b[i]) / 2;
+ double x_var = sqr(b[i+1] - b[i]) / 12;
+ double x_skew = 0;
+ double x_kurtosis = -6./5;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs(skew - x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ }
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef std::mt19937_64 G;
+ G g;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 0, 0};
+ const size_t Np = sizeof(p) / sizeof(p[0]);
+ D d(b, b+Np+1, p);
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v < d.max());
+ u.push_back(v);
+ }
+ std::vector<double> prob(std::begin(p), std::end(p));
+ double s = std::accumulate(prob.begin(), prob.end(), 0.0);
+ for (int i = 0; i < prob.size(); ++i)
+ prob[i] /= s;
+ std::sort(u.begin(), u.end());
+ for (int i = 0; i < Np; ++i)
+ {
+ typedef std::vector<D::result_type>::iterator I;
+ I lb = std::lower_bound(u.begin(), u.end(), b[i]);
+ I ub = std::lower_bound(u.begin(), u.end(), b[i+1]);
+ const size_t Ni = ub - lb;
+ if (prob[i] == 0)
+ assert(Ni == 0);
+ else
+ {
+ assert(std::abs((double)Ni/N - prob[i]) / prob[i] < .01);
+ double mean = std::accumulate(lb, ub, 0.0) / Ni;
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (I j = lb; j != ub; ++j)
+ {
+ double d = (*j - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= Ni;
+ double dev = std::sqrt(var);
+ skew /= Ni * dev * var;
+ kurtosis /= Ni * var * var;
+ kurtosis -= 3;
+ double x_mean = (b[i+1] + b[i]) / 2;
+ double x_var = sqr(b[i+1] - b[i]) / 12;
+ double x_skew = 0;
+ double x_kurtosis = -6./5;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs(skew - x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ }
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef std::mt19937_64 G;
+ G g;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {0, 25, 0};
+ const size_t Np = sizeof(p) / sizeof(p[0]);
+ D d(b, b+Np+1, p);
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v < d.max());
+ u.push_back(v);
+ }
+ std::vector<double> prob(std::begin(p), std::end(p));
+ double s = std::accumulate(prob.begin(), prob.end(), 0.0);
+ for (int i = 0; i < prob.size(); ++i)
+ prob[i] /= s;
+ std::sort(u.begin(), u.end());
+ for (int i = 0; i < Np; ++i)
+ {
+ typedef std::vector<D::result_type>::iterator I;
+ I lb = std::lower_bound(u.begin(), u.end(), b[i]);
+ I ub = std::lower_bound(u.begin(), u.end(), b[i+1]);
+ const size_t Ni = ub - lb;
+ if (prob[i] == 0)
+ assert(Ni == 0);
+ else
+ {
+ assert(std::abs((double)Ni/N - prob[i]) / prob[i] < .01);
+ double mean = std::accumulate(lb, ub, 0.0) / Ni;
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (I j = lb; j != ub; ++j)
+ {
+ double d = (*j - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= Ni;
+ double dev = std::sqrt(var);
+ skew /= Ni * dev * var;
+ kurtosis /= Ni * var * var;
+ kurtosis -= 3;
+ double x_mean = (b[i+1] + b[i]) / 2;
+ double x_var = sqr(b[i+1] - b[i]) / 12;
+ double x_skew = 0;
+ double x_kurtosis = -6./5;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs(skew - x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ }
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef std::mt19937_64 G;
+ G g;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {0, 0, 1};
+ const size_t Np = sizeof(p) / sizeof(p[0]);
+ D d(b, b+Np+1, p);
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v < d.max());
+ u.push_back(v);
+ }
+ std::vector<double> prob(std::begin(p), std::end(p));
+ double s = std::accumulate(prob.begin(), prob.end(), 0.0);
+ for (int i = 0; i < prob.size(); ++i)
+ prob[i] /= s;
+ std::sort(u.begin(), u.end());
+ for (int i = 0; i < Np; ++i)
+ {
+ typedef std::vector<D::result_type>::iterator I;
+ I lb = std::lower_bound(u.begin(), u.end(), b[i]);
+ I ub = std::lower_bound(u.begin(), u.end(), b[i+1]);
+ const size_t Ni = ub - lb;
+ if (prob[i] == 0)
+ assert(Ni == 0);
+ else
+ {
+ assert(std::abs((double)Ni/N - prob[i]) / prob[i] < .01);
+ double mean = std::accumulate(lb, ub, 0.0) / Ni;
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (I j = lb; j != ub; ++j)
+ {
+ double d = (*j - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= Ni;
+ double dev = std::sqrt(var);
+ skew /= Ni * dev * var;
+ kurtosis /= Ni * var * var;
+ kurtosis -= 3;
+ double x_mean = (b[i+1] + b[i]) / 2;
+ double x_var = sqr(b[i+1] - b[i]) / 12;
+ double x_skew = 0;
+ double x_kurtosis = -6./5;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs(skew - x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ }
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef std::mt19937_64 G;
+ G g;
+ double b[] = {10, 14, 16};
+ double p[] = {75, 25};
+ const size_t Np = sizeof(p) / sizeof(p[0]);
+ D d(b, b+Np+1, p);
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v < d.max());
+ u.push_back(v);
+ }
+ std::vector<double> prob(std::begin(p), std::end(p));
+ double s = std::accumulate(prob.begin(), prob.end(), 0.0);
+ for (int i = 0; i < prob.size(); ++i)
+ prob[i] /= s;
+ std::sort(u.begin(), u.end());
+ for (int i = 0; i < Np; ++i)
+ {
+ typedef std::vector<D::result_type>::iterator I;
+ I lb = std::lower_bound(u.begin(), u.end(), b[i]);
+ I ub = std::lower_bound(u.begin(), u.end(), b[i+1]);
+ const size_t Ni = ub - lb;
+ if (prob[i] == 0)
+ assert(Ni == 0);
+ else
+ {
+ assert(std::abs((double)Ni/N - prob[i]) / prob[i] < .01);
+ double mean = std::accumulate(lb, ub, 0.0) / Ni;
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (I j = lb; j != ub; ++j)
+ {
+ double d = (*j - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= Ni;
+ double dev = std::sqrt(var);
+ skew /= Ni * dev * var;
+ kurtosis /= Ni * var * var;
+ kurtosis -= 3;
+ double x_mean = (b[i+1] + b[i]) / 2;
+ double x_var = sqr(b[i+1] - b[i]) / 12;
+ double x_skew = 0;
+ double x_kurtosis = -6./5;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs(skew - x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ }
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef std::mt19937_64 G;
+ G g;
+ double b[] = {10, 14, 16};
+ double p[] = {0, 25};
+ const size_t Np = sizeof(p) / sizeof(p[0]);
+ D d(b, b+Np+1, p);
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v < d.max());
+ u.push_back(v);
+ }
+ std::vector<double> prob(std::begin(p), std::end(p));
+ double s = std::accumulate(prob.begin(), prob.end(), 0.0);
+ for (int i = 0; i < prob.size(); ++i)
+ prob[i] /= s;
+ std::sort(u.begin(), u.end());
+ for (int i = 0; i < Np; ++i)
+ {
+ typedef std::vector<D::result_type>::iterator I;
+ I lb = std::lower_bound(u.begin(), u.end(), b[i]);
+ I ub = std::lower_bound(u.begin(), u.end(), b[i+1]);
+ const size_t Ni = ub - lb;
+ if (prob[i] == 0)
+ assert(Ni == 0);
+ else
+ {
+ assert(std::abs((double)Ni/N - prob[i]) / prob[i] < .01);
+ double mean = std::accumulate(lb, ub, 0.0) / Ni;
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (I j = lb; j != ub; ++j)
+ {
+ double d = (*j - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= Ni;
+ double dev = std::sqrt(var);
+ skew /= Ni * dev * var;
+ kurtosis /= Ni * var * var;
+ kurtosis -= 3;
+ double x_mean = (b[i+1] + b[i]) / 2;
+ double x_var = sqr(b[i+1] - b[i]) / 12;
+ double x_skew = 0;
+ double x_kurtosis = -6./5;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs(skew - x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ }
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef std::mt19937_64 G;
+ G g;
+ double b[] = {10, 14, 16};
+ double p[] = {1, 0};
+ const size_t Np = sizeof(p) / sizeof(p[0]);
+ D d(b, b+Np+1, p);
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v < d.max());
+ u.push_back(v);
+ }
+ std::vector<double> prob(std::begin(p), std::end(p));
+ double s = std::accumulate(prob.begin(), prob.end(), 0.0);
+ for (int i = 0; i < prob.size(); ++i)
+ prob[i] /= s;
+ std::sort(u.begin(), u.end());
+ for (int i = 0; i < Np; ++i)
+ {
+ typedef std::vector<D::result_type>::iterator I;
+ I lb = std::lower_bound(u.begin(), u.end(), b[i]);
+ I ub = std::lower_bound(u.begin(), u.end(), b[i+1]);
+ const size_t Ni = ub - lb;
+ if (prob[i] == 0)
+ assert(Ni == 0);
+ else
+ {
+ assert(std::abs((double)Ni/N - prob[i]) / prob[i] < .01);
+ double mean = std::accumulate(lb, ub, 0.0) / Ni;
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (I j = lb; j != ub; ++j)
+ {
+ double d = (*j - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= Ni;
+ double dev = std::sqrt(var);
+ skew /= Ni * dev * var;
+ kurtosis /= Ni * var * var;
+ kurtosis -= 3;
+ double x_mean = (b[i+1] + b[i]) / 2;
+ double x_var = sqr(b[i+1] - b[i]) / 12;
+ double x_skew = 0;
+ double x_kurtosis = -6./5;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs(skew - x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ }
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef std::mt19937_64 G;
+ G g;
+ double b[] = {10, 14};
+ double p[] = {1};
+ const size_t Np = sizeof(p) / sizeof(p[0]);
+ D d(b, b+Np+1, p);
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v < d.max());
+ u.push_back(v);
+ }
+ std::vector<double> prob(std::begin(p), std::end(p));
+ double s = std::accumulate(prob.begin(), prob.end(), 0.0);
+ for (int i = 0; i < prob.size(); ++i)
+ prob[i] /= s;
+ std::sort(u.begin(), u.end());
+ for (int i = 0; i < Np; ++i)
+ {
+ typedef std::vector<D::result_type>::iterator I;
+ I lb = std::lower_bound(u.begin(), u.end(), b[i]);
+ I ub = std::lower_bound(u.begin(), u.end(), b[i+1]);
+ const size_t Ni = ub - lb;
+ if (prob[i] == 0)
+ assert(Ni == 0);
+ else
+ {
+ assert(std::abs((double)Ni/N - prob[i]) / prob[i] < .01);
+ double mean = std::accumulate(lb, ub, 0.0) / Ni;
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (I j = lb; j != ub; ++j)
+ {
+ double d = (*j - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= Ni;
+ double dev = std::sqrt(var);
+ skew /= Ni * dev * var;
+ kurtosis /= Ni * var * var;
+ kurtosis -= 3;
+ double x_mean = (b[i+1] + b[i]) / 2;
+ double x_var = sqr(b[i+1] - b[i]) / 12;
+ double x_skew = 0;
+ double x_kurtosis = -6./5;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs(skew - x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ }
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/eval_param.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/eval_param.pass.cpp
new file mode 100644
index 000000000000..6850115875bb
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/eval_param.pass.cpp
@@ -0,0 +1,97 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// REQUIRES: long_tests
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_constant_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g, const param_type& parm);
+
+#include <random>
+#include <vector>
+#include <iterator>
+#include <numeric>
+#include <cassert>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+ return x*x;
+}
+
+int main()
+{
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937_64 G;
+ G g;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 62.5, 12.5};
+ const size_t Np = sizeof(p) / sizeof(p[0]);
+ D d;
+ P pa(b, b+Np+1, p);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, pa);
+ assert(10 <= v && v < 17);
+ u.push_back(v);
+ }
+ std::vector<double> prob(std::begin(p), std::end(p));
+ double s = std::accumulate(prob.begin(), prob.end(), 0.0);
+ for (int i = 0; i < prob.size(); ++i)
+ prob[i] /= s;
+ std::sort(u.begin(), u.end());
+ for (int i = 0; i < Np; ++i)
+ {
+ typedef std::vector<D::result_type>::iterator I;
+ I lb = std::lower_bound(u.begin(), u.end(), b[i]);
+ I ub = std::lower_bound(u.begin(), u.end(), b[i+1]);
+ const size_t Ni = ub - lb;
+ if (prob[i] == 0)
+ assert(Ni == 0);
+ else
+ {
+ assert(std::abs((double)Ni/N - prob[i]) / prob[i] < .01);
+ double mean = std::accumulate(lb, ub, 0.0) / Ni;
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (I j = lb; j != ub; ++j)
+ {
+ double d = (*j - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= Ni;
+ double dev = std::sqrt(var);
+ skew /= Ni * dev * var;
+ kurtosis /= Ni * var * var;
+ kurtosis -= 3;
+ double x_mean = (b[i+1] + b[i]) / 2;
+ double x_var = sqr(b[i+1] - b[i]) / 12;
+ double x_skew = 0;
+ double x_kurtosis = -6./5;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs(skew - x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ }
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/get_param.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/get_param.pass.cpp
new file mode 100644
index 000000000000..fdda4e8f0d6b
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/get_param.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_constant_distribution
+
+// param_type param() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef D::param_type P;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 62.5, 12.5};
+ const size_t Np = sizeof(p) / sizeof(p[0]);
+ P pa(b, b+Np+1, p);
+ D d(pa);
+ assert(d.param() == pa);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/io.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/io.pass.cpp
new file mode 100644
index 000000000000..9af776d549a6
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/io.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_constant_distribution
+
+// template <class charT, class traits>
+// basic_ostream<charT, traits>&
+// operator<<(basic_ostream<charT, traits>& os,
+// const piecewise_constant_distribution& x);
+//
+// template <class charT, class traits>
+// basic_istream<charT, traits>&
+// operator>>(basic_istream<charT, traits>& is,
+// piecewise_constant_distribution& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 62.5, 12.5};
+ const size_t Np = sizeof(p) / sizeof(p[0]);
+ D d1(b, b+Np+1, p);
+ std::ostringstream os;
+ os << d1;
+ std::istringstream is(os.str());
+ D d2;
+ is >> d2;
+ assert(d1 == d2);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/max.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/max.pass.cpp
new file mode 100644
index 000000000000..772c36ed73e3
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/max.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_constant_distribution
+
+// result_type max() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 62.5, 12.5};
+ const size_t Np = sizeof(p) / sizeof(p[0]);
+ D d(b, b+Np+1, p);
+ assert(d.max() == 17);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/min.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/min.pass.cpp
new file mode 100644
index 000000000000..66618ba95d73
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/min.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_constant_distribution
+
+// result_type min() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 62.5, 12.5};
+ const size_t Np = sizeof(p) / sizeof(p[0]);
+ D d(b, b+Np+1, p);
+ assert(d.min() == 10);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_assign.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_assign.pass.cpp
new file mode 100644
index 000000000000..4d3a503584ee
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_assign.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_constant_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef D::param_type P;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 62.5, 12.5};
+ const size_t Np = sizeof(p) / sizeof(p[0]);
+ P p0(b, b+Np+1, p);
+ P p1;
+ p1 = p0;
+ assert(p1 == p0);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_copy.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_copy.pass.cpp
new file mode 100644
index 000000000000..de63a54edfbe
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_copy.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_constant_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef D::param_type P;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 62.5, 12.5};
+ const size_t Np = sizeof(p) / sizeof(p[0]);
+ P p0(b, b+Np+1, p);
+ P p1 = p0;
+ assert(p1 == p0);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_ctor_default.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_ctor_default.pass.cpp
new file mode 100644
index 000000000000..fd84d46713c0
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_ctor_default.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_constant_distribution
+
+// param_type();
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef D::param_type P;
+ P pa;
+ std::vector<double> iv = pa.intervals();
+ assert(iv.size() == 2);
+ assert(iv[0] == 0);
+ assert(iv[1] == 1);
+ std::vector<double> dn = pa.densities();
+ assert(dn.size() == 1);
+ assert(dn[0] == 1);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_ctor_func.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_ctor_func.pass.cpp
new file mode 100644
index 000000000000..98e3006f3e32
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_ctor_func.pass.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_constant_distribution
+
+// template<class UnaryOperation>
+// param_type(size_t nw, double xmin, double xmax,
+// UnaryOperation fw);
+
+#include <random>
+#include <cassert>
+
+double fw(double x)
+{
+ return 2*x;
+}
+
+int main()
+{
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef D::param_type P;
+ P pa(0, 0, 1, fw);
+ std::vector<double> iv = pa.intervals();
+ assert(iv.size() == 2);
+ assert(iv[0] == 0);
+ assert(iv[1] == 1);
+ std::vector<double> dn = pa.densities();
+ assert(dn.size() == 1);
+ assert(dn[0] == 1);
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef D::param_type P;
+ P pa(1, 10, 12, fw);
+ std::vector<double> iv = pa.intervals();
+ assert(iv.size() == 2);
+ assert(iv[0] == 10);
+ assert(iv[1] == 12);
+ std::vector<double> dn = pa.densities();
+ assert(dn.size() == 1);
+ assert(dn[0] == 0.5);
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef D::param_type P;
+ P pa(2, 6, 14, fw);
+ std::vector<double> iv = pa.intervals();
+ assert(iv.size() == 3);
+ assert(iv[0] == 6);
+ assert(iv[1] == 10);
+ assert(iv[2] == 14);
+ std::vector<double> dn = pa.densities();
+ assert(dn.size() == 2);
+ assert(dn[0] == 0.1);
+ assert(dn[1] == 0.15);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_ctor_init_func.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_ctor_init_func.pass.cpp
new file mode 100644
index 000000000000..fa6530979ed8
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_ctor_init_func.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_constant_distribution
+
+// param_type(initializer_list<result_type> bl, UnaryOperation fw);
+
+#include <random>
+#include <cassert>
+
+double f(double x)
+{
+ return x*2;
+}
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef D::param_type P;
+ P pa({}, f);
+ std::vector<double> iv = pa.intervals();
+ assert(iv.size() == 2);
+ assert(iv[0] == 0);
+ assert(iv[1] == 1);
+ std::vector<double> dn = pa.densities();
+ assert(dn.size() == 1);
+ assert(dn[0] == 1);
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef D::param_type P;
+ P pa({12}, f);
+ std::vector<double> iv = pa.intervals();
+ assert(iv.size() == 2);
+ assert(iv[0] == 0);
+ assert(iv[1] == 1);
+ std::vector<double> dn = pa.densities();
+ assert(dn.size() == 1);
+ assert(dn[0] == 1);
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef D::param_type P;
+ P pa({12, 14}, f);
+ std::vector<double> iv = pa.intervals();
+ assert(iv.size() == 2);
+ assert(iv[0] == 12);
+ assert(iv[1] == 14);
+ std::vector<double> dn = pa.densities();
+ assert(dn.size() == 1);
+ assert(dn[0] == 0.5);
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef D::param_type P;
+ P pa({5.5, 7.5, 11.5}, f);
+ std::vector<double> iv = pa.intervals();
+ assert(iv.size() == 3);
+ assert(iv[0] == 5.5);
+ assert(iv[1] == 7.5);
+ assert(iv[2] == 11.5);
+ std::vector<double> dn = pa.densities();
+ assert(dn.size() == 2);
+ assert(dn[0] == 0.203125);
+ assert(dn[1] == 0.1484375);
+ }
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_ctor_iterator.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_ctor_iterator.pass.cpp
new file mode 100644
index 000000000000..98d467c07e23
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_ctor_iterator.pass.cpp
@@ -0,0 +1,100 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_constant_distribution
+
+// template<class InputIterator>
+// param_type(InputIteratorB firstB, InputIteratorB lastB,
+// InputIteratorW firstW);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef D::param_type P;
+ double b[] = {10};
+ double p[] = {12};
+ P pa(b, b, p);
+ std::vector<double> iv = pa.intervals();
+ assert(iv.size() == 2);
+ assert(iv[0] == 0);
+ assert(iv[1] == 1);
+ std::vector<double> dn = pa.densities();
+ assert(dn.size() == 1);
+ assert(dn[0] == 1);
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef D::param_type P;
+ double b[] = {10};
+ double p[] = {12};
+ P pa(b, b+1, p);
+ std::vector<double> iv = pa.intervals();
+ assert(iv.size() == 2);
+ assert(iv[0] == 0);
+ assert(iv[1] == 1);
+ std::vector<double> dn = pa.densities();
+ assert(dn.size() == 1);
+ assert(dn[0] == 1);
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef D::param_type P;
+ double b[] = {10, 15};
+ double p[] = {12};
+ P pa(b, b+2, p);
+ std::vector<double> iv = pa.intervals();
+ assert(iv.size() == 2);
+ assert(iv[0] == 10);
+ assert(iv[1] == 15);
+ std::vector<double> dn = pa.densities();
+ assert(dn.size() == 1);
+ assert(dn[0] == 1/5.);
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef D::param_type P;
+ double b[] = {10, 15, 16};
+ double p[] = {.25, .75};
+ P pa(b, b+3, p);
+ std::vector<double> iv = pa.intervals();
+ assert(iv.size() == 3);
+ assert(iv[0] == 10);
+ assert(iv[1] == 15);
+ assert(iv[2] == 16);
+ std::vector<double> dn = pa.densities();
+ assert(dn.size() == 2);
+ assert(dn[0] == .25/5.);
+ assert(dn[1] == .75);
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef D::param_type P;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 62.5, 12.5};
+ P pa(b, b+4, p);
+ std::vector<double> iv = pa.intervals();
+ assert(iv.size() == 4);
+ assert(iv[0] == 10);
+ assert(iv[1] == 14);
+ assert(iv[2] == 16);
+ assert(iv[3] == 17);
+ std::vector<double> dn = pa.densities();
+ assert(dn.size() == 3);
+ assert(dn[0] == .0625);
+ assert(dn[1] == .3125);
+ assert(dn[2] == .125);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_eq.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_eq.pass.cpp
new file mode 100644
index 000000000000..9cc554e604af
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_eq.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_constant_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef D::param_type P;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 62.5, 12.5};
+ P p1(b, b+4, p);
+ P p2(b, b+4, p);
+ assert(p1 == p2);
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef D::param_type P;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 62.5, 12.5};
+ P p1(b, b+3, p);
+ P p2(b, b+4, p);
+ assert(p1 != p2);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_types.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_types.pass.cpp
new file mode 100644
index 000000000000..e039df36c98a
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_types.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_constant_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef D::param_type param_type;
+ typedef param_type::distribution_type distribution_type;
+ static_assert((std::is_same<D, distribution_type>::value), "");
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/set_param.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/set_param.pass.cpp
new file mode 100644
index 000000000000..1a3fedb0940f
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/set_param.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_constant_distribution
+
+// void param(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef D::param_type P;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 62.5, 12.5};
+ P pa(b, b+4, p);
+ D d;
+ d.param(pa);
+ assert(d.param() == pa);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/types.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/types.pass.cpp
new file mode 100644
index 000000000000..760325979738
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/types.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_constant_distribution
+// {
+// typedef bool result_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef D::result_type result_type;
+ static_assert((std::is_same<result_type, double>::value), "");
+ }
+ {
+ typedef std::piecewise_constant_distribution<float> D;
+ typedef D::result_type result_type;
+ static_assert((std::is_same<result_type, float>::value), "");
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/assign.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/assign.pass.cpp
new file mode 100644
index 000000000000..0ba7dcb59198
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/assign.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_linear_distribution
+
+// piecewise_linear_distribution& operator=(const piecewise_linear_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::piecewise_linear_distribution<> D;
+ double p[] = {2, 4, 1, 8, 3};
+ double b[] = {2, 4, 5, 8, 9};
+ D d1(b, b+5, p);
+ D d2;
+ assert(d1 != d2);
+ d2 = d1;
+ assert(d1 == d2);
+}
+
+int main()
+{
+ test1();
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/copy.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/copy.pass.cpp
new file mode 100644
index 000000000000..536b139dda61
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/copy.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_linear_distribution
+
+// piecewise_linear_distribution(const piecewise_linear_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::piecewise_linear_distribution<> D;
+ double p[] = {2, 4, 1, 8, 2};
+ double b[] = {2, 4, 5, 8, 9};
+ D d1(b, b+5, p);
+ D d2 = d1;
+ assert(d1 == d2);
+}
+
+int main()
+{
+ test1();
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/ctor_default.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/ctor_default.pass.cpp
new file mode 100644
index 000000000000..745bd6b97ec8
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/ctor_default.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_linear_distribution
+
+// piecewise_linear_distribution(initializer_list<double> wl);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ D d;
+ std::vector<double> iv = d.intervals();
+ assert(iv.size() == 2);
+ assert(iv[0] == 0);
+ assert(iv[1] == 1);
+ std::vector<double> dn = d.densities();
+ assert(dn.size() == 2);
+ assert(dn[0] == 1);
+ assert(dn[1] == 1);
+ }
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/ctor_func.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/ctor_func.pass.cpp
new file mode 100644
index 000000000000..3ebaf77f7564
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/ctor_func.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_linear_distribution
+
+// template<class UnaryOperation>
+// piecewise_linear_distribution(size_t nw, result_type xmin,
+// result_type xmax, UnaryOperation fw);
+
+#include <iostream>
+
+#include <random>
+#include <cassert>
+
+double fw(double x)
+{
+ return 2*x;
+}
+
+int main()
+{
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ D d(0, 0, 1, fw);
+ std::vector<double> iv = d.intervals();
+ assert(iv.size() == 2);
+ assert(iv[0] == 0);
+ assert(iv[1] == 1);
+ std::vector<double> dn = d.densities();
+ assert(dn.size() == 2);
+ assert(dn[0] == 0);
+ assert(dn[1] == 2);
+ }
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ D d(1, 10, 12, fw);
+ std::vector<double> iv = d.intervals();
+ assert(iv.size() == 2);
+ assert(iv[0] == 10);
+ assert(iv[1] == 12);
+ std::vector<double> dn = d.densities();
+ assert(dn.size() == 2);
+ assert(dn[0] == 20./44);
+ assert(dn[1] == 24./44);
+ }
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ D d(2, 6, 14, fw);
+ std::vector<double> iv = d.intervals();
+ assert(iv.size() == 3);
+ assert(iv[0] == 6);
+ assert(iv[1] == 10);
+ assert(iv[2] == 14);
+ std::vector<double> dn = d.densities();
+ assert(dn.size() == 3);
+ assert(dn[0] == 0.075);
+ assert(dn[1] == 0.125);
+ assert(dn[2] == 0.175);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/ctor_init_func.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/ctor_init_func.pass.cpp
new file mode 100644
index 000000000000..44c76f0cf6cb
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/ctor_init_func.pass.cpp
@@ -0,0 +1,82 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_linear_distribution
+
+// piecewise_linear_distribution(initializer_list<result_type> bl,
+// UnaryOperation fw);
+
+#include <iostream>
+
+#include <random>
+#include <cassert>
+
+double f(double x)
+{
+ return x*2;
+}
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ D d({}, f);
+ std::vector<double> iv = d.intervals();
+ assert(iv.size() == 2);
+ assert(iv[0] == 0);
+ assert(iv[1] == 1);
+ std::vector<double> dn = d.densities();
+ assert(dn.size() == 2);
+ assert(dn[0] == 1);
+ assert(dn[1] == 1);
+ }
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ D d({12}, f);
+ std::vector<double> iv = d.intervals();
+ assert(iv.size() == 2);
+ assert(iv[0] == 0);
+ assert(iv[1] == 1);
+ std::vector<double> dn = d.densities();
+ assert(dn.size() == 2);
+ assert(dn[0] == 1);
+ assert(dn[1] == 1);
+ }
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ D d({10, 12}, f);
+ std::vector<double> iv = d.intervals();
+ assert(iv.size() == 2);
+ assert(iv[0] == 10);
+ assert(iv[1] == 12);
+ std::vector<double> dn = d.densities();
+ assert(dn.size() == 2);
+ assert(dn[0] == 20./44);
+ assert(dn[1] == 24./44);
+ }
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ D d({6, 10, 14}, f);
+ std::vector<double> iv = d.intervals();
+ assert(iv.size() == 3);
+ assert(iv[0] == 6);
+ assert(iv[1] == 10);
+ assert(iv[2] == 14);
+ std::vector<double> dn = d.densities();
+ assert(dn.size() == 3);
+ assert(dn[0] == 0.075);
+ assert(dn[1] == 0.125);
+ assert(dn[2] == 0.175);
+ }
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/ctor_iterator.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/ctor_iterator.pass.cpp
new file mode 100644
index 000000000000..5fce58bbd978
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/ctor_iterator.pass.cpp
@@ -0,0 +1,101 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_linear_distribution
+
+// template<class InputIterator>
+// piecewise_linear_distribution(InputIteratorB firstB,
+// InputIteratorB lastB,
+// InputIteratorW firstW);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ double b[] = {10};
+ double p[] = {12};
+ D d(b, b, p);
+ std::vector<double> iv = d.intervals();
+ assert(iv.size() == 2);
+ assert(iv[0] == 0);
+ assert(iv[1] == 1);
+ std::vector<double> dn = d.densities();
+ assert(dn.size() == 2);
+ assert(dn[0] == 1);
+ assert(dn[1] == 1);
+ }
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ double b[] = {10};
+ double p[] = {12};
+ D d(b, b+1, p);
+ std::vector<double> iv = d.intervals();
+ assert(iv.size() == 2);
+ assert(iv[0] == 0);
+ assert(iv[1] == 1);
+ std::vector<double> dn = d.densities();
+ assert(dn.size() == 2);
+ assert(dn[0] == 1);
+ assert(dn[1] == 1);
+ }
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ double b[] = {10, 15};
+ double p[] = {20, 20};
+ D d(b, b+2, p);
+ std::vector<double> iv = d.intervals();
+ assert(iv.size() == 2);
+ assert(iv[0] == 10);
+ assert(iv[1] == 15);
+ std::vector<double> dn = d.densities();
+ assert(dn.size() == 2);
+ assert(dn[0] == 1/5.);
+ assert(dn[1] == 1/5.);
+ }
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ double b[] = {10, 15, 16};
+ double p[] = {.25, .75, .25};
+ D d(b, b+3, p);
+ std::vector<double> iv = d.intervals();
+ assert(iv.size() == 3);
+ assert(iv[0] == 10);
+ assert(iv[1] == 15);
+ assert(iv[2] == 16);
+ std::vector<double> dn = d.densities();
+ assert(dn.size() == 3);
+ assert(dn[0] == .25/3);
+ assert(dn[1] == .75/3);
+ assert(dn[2] == .25/3);
+ }
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {0, 1, 1, 0};
+ D d(b, b+4, p);
+ std::vector<double> iv = d.intervals();
+ assert(iv.size() == 4);
+ assert(iv[0] == 10);
+ assert(iv[1] == 14);
+ assert(iv[2] == 16);
+ assert(iv[3] == 17);
+ std::vector<double> dn = d.densities();
+ assert(dn.size() == 4);
+ assert(dn[0] == 0);
+ assert(dn[1] == 1/4.5);
+ assert(dn[2] == 1/4.5);
+ assert(dn[3] == 0);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/ctor_param.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/ctor_param.pass.cpp
new file mode 100644
index 000000000000..7dc47b4a3a2e
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/ctor_param.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_linear_distribution
+
+// explicit piecewise_linear_distribution(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ typedef D::param_type P;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 62.5, 12.5, 0};
+ P pa(b, b+4, p);
+ D d(pa);
+ std::vector<double> iv = d.intervals();
+ assert(iv.size() == 4);
+ assert(iv[0] == 10);
+ assert(iv[1] == 14);
+ assert(iv[2] == 16);
+ assert(iv[3] == 17);
+ std::vector<double> dn = d.densities();
+ assert(dn.size() == 4);
+ assert(dn[0] == 25/256.25);
+ assert(dn[1] == 62.5/256.25);
+ assert(dn[2] == 12.5/256.25);
+ assert(dn[3] == 0);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/eq.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/eq.pass.cpp
new file mode 100644
index 000000000000..766989c58899
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/eq.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_linear_distribution
+
+// bool operator=(const piecewise_linear_distribution& x,
+// const piecewise_linear_distribution& y);
+// bool operator!(const piecewise_linear_distribution& x,
+// const piecewise_linear_distribution& y);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ D d1;
+ D d2;
+ assert(d1 == d2);
+ }
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 62.5, 12.5, 1};
+ D d1(b, b+4, p);
+ D d2(b, b+4, p);
+ assert(d1 == d2);
+ }
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 62.5, 12.5, 0};
+ D d1(b, b+4, p);
+ D d2;
+ assert(d1 != d2);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/eval.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/eval.pass.cpp
new file mode 100644
index 000000000000..af75fce512e4
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/eval.pass.cpp
@@ -0,0 +1,343 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// REQUIRES: long_tests
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_linear_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g);
+
+#include <iostream>
+
+#include <random>
+#include <vector>
+#include <iterator>
+#include <numeric>
+#include <cassert>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+ return x*x;
+}
+
+double
+f(double x, double a, double m, double b, double c)
+{
+ return a + m*(sqr(x) - sqr(b))/2 + c*(x-b);
+}
+
+int main()
+{
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937_64 G;
+ G g;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {0, 1, 1, 0};
+ const size_t Np = sizeof(p) / sizeof(p[0]) - 1;
+ D d(b, b+Np+1, p);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v < d.max());
+ u.push_back(v);
+ }
+ std::sort(u.begin(), u.end());
+ int kp = -1;
+ double a;
+ double m;
+ double bk;
+ double c;
+ std::vector<double> areas(Np);
+ double S = 0;
+ for (int i = 0; i < areas.size(); ++i)
+ {
+ areas[i] = (p[i]+p[i+1])*(b[i+1]-b[i])/2;
+ S += areas[i];
+ }
+ for (int i = 0; i < areas.size(); ++i)
+ areas[i] /= S;
+ for (int i = 0; i < Np+1; ++i)
+ p[i] /= S;
+ for (int i = 0; i < N; ++i)
+ {
+ int k = std::lower_bound(b, b+Np+1, u[i]) - b - 1;
+ if (k != kp)
+ {
+ a = 0;
+ for (int j = 0; j < k; ++j)
+ a += areas[j];
+ m = (p[k+1] - p[k]) / (b[k+1] - b[k]);
+ bk = b[k];
+ c = (b[k+1]*p[k] - b[k]*p[k+1]) / (b[k+1] - b[k]);
+ kp = k;
+ }
+ assert(std::abs(f(u[i], a, m, bk, c) - double(i)/N) < .001);
+ }
+ }
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937_64 G;
+ G g;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {0, 0, 1, 0};
+ const size_t Np = sizeof(p) / sizeof(p[0]) - 1;
+ D d(b, b+Np+1, p);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v < d.max());
+ u.push_back(v);
+ }
+ std::sort(u.begin(), u.end());
+ int kp = -1;
+ double a;
+ double m;
+ double bk;
+ double c;
+ std::vector<double> areas(Np);
+ double S = 0;
+ for (int i = 0; i < areas.size(); ++i)
+ {
+ areas[i] = (p[i]+p[i+1])*(b[i+1]-b[i])/2;
+ S += areas[i];
+ }
+ for (int i = 0; i < areas.size(); ++i)
+ areas[i] /= S;
+ for (int i = 0; i < Np+1; ++i)
+ p[i] /= S;
+ for (int i = 0; i < N; ++i)
+ {
+ int k = std::lower_bound(b, b+Np+1, u[i]) - b - 1;
+ if (k != kp)
+ {
+ a = 0;
+ for (int j = 0; j < k; ++j)
+ a += areas[j];
+ m = (p[k+1] - p[k]) / (b[k+1] - b[k]);
+ bk = b[k];
+ c = (b[k+1]*p[k] - b[k]*p[k+1]) / (b[k+1] - b[k]);
+ kp = k;
+ }
+ assert(std::abs(f(u[i], a, m, bk, c) - double(i)/N) < .001);
+ }
+ }
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937_64 G;
+ G g;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {1, 0, 0, 0};
+ const size_t Np = sizeof(p) / sizeof(p[0]) - 1;
+ D d(b, b+Np+1, p);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v < d.max());
+ u.push_back(v);
+ }
+ std::sort(u.begin(), u.end());
+ int kp = -1;
+ double a;
+ double m;
+ double bk;
+ double c;
+ std::vector<double> areas(Np);
+ double S = 0;
+ for (int i = 0; i < areas.size(); ++i)
+ {
+ areas[i] = (p[i]+p[i+1])*(b[i+1]-b[i])/2;
+ S += areas[i];
+ }
+ for (int i = 0; i < areas.size(); ++i)
+ areas[i] /= S;
+ for (int i = 0; i < Np+1; ++i)
+ p[i] /= S;
+ for (int i = 0; i < N; ++i)
+ {
+ int k = std::lower_bound(b, b+Np+1, u[i]) - b - 1;
+ if (k != kp)
+ {
+ a = 0;
+ for (int j = 0; j < k; ++j)
+ a += areas[j];
+ m = (p[k+1] - p[k]) / (b[k+1] - b[k]);
+ bk = b[k];
+ c = (b[k+1]*p[k] - b[k]*p[k+1]) / (b[k+1] - b[k]);
+ kp = k;
+ }
+ assert(std::abs(f(u[i], a, m, bk, c) - double(i)/N) < .001);
+ }
+ }
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937_64 G;
+ G g;
+ double b[] = {10, 14, 16};
+ double p[] = {0, 1, 0};
+ const size_t Np = sizeof(p) / sizeof(p[0]) - 1;
+ D d(b, b+Np+1, p);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v < d.max());
+ u.push_back(v);
+ }
+ std::sort(u.begin(), u.end());
+ int kp = -1;
+ double a;
+ double m;
+ double bk;
+ double c;
+ std::vector<double> areas(Np);
+ double S = 0;
+ for (int i = 0; i < areas.size(); ++i)
+ {
+ areas[i] = (p[i]+p[i+1])*(b[i+1]-b[i])/2;
+ S += areas[i];
+ }
+ for (int i = 0; i < areas.size(); ++i)
+ areas[i] /= S;
+ for (int i = 0; i < Np+1; ++i)
+ p[i] /= S;
+ for (int i = 0; i < N; ++i)
+ {
+ int k = std::lower_bound(b, b+Np+1, u[i]) - b - 1;
+ if (k != kp)
+ {
+ a = 0;
+ for (int j = 0; j < k; ++j)
+ a += areas[j];
+ m = (p[k+1] - p[k]) / (b[k+1] - b[k]);
+ bk = b[k];
+ c = (b[k+1]*p[k] - b[k]*p[k+1]) / (b[k+1] - b[k]);
+ kp = k;
+ }
+ assert(std::abs(f(u[i], a, m, bk, c) - double(i)/N) < .001);
+ }
+ }
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937_64 G;
+ G g;
+ double b[] = {10, 14};
+ double p[] = {1, 1};
+ const size_t Np = sizeof(p) / sizeof(p[0]) - 1;
+ D d(b, b+Np+1, p);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v < d.max());
+ u.push_back(v);
+ }
+ std::sort(u.begin(), u.end());
+ int kp = -1;
+ double a;
+ double m;
+ double bk;
+ double c;
+ std::vector<double> areas(Np);
+ double S = 0;
+ for (int i = 0; i < areas.size(); ++i)
+ {
+ areas[i] = (p[i]+p[i+1])*(b[i+1]-b[i])/2;
+ S += areas[i];
+ }
+ for (int i = 0; i < areas.size(); ++i)
+ areas[i] /= S;
+ for (int i = 0; i < Np+1; ++i)
+ p[i] /= S;
+ for (int i = 0; i < N; ++i)
+ {
+ int k = std::lower_bound(b, b+Np+1, u[i]) - b - 1;
+ if (k != kp)
+ {
+ a = 0;
+ for (int j = 0; j < k; ++j)
+ a += areas[j];
+ m = (p[k+1] - p[k]) / (b[k+1] - b[k]);
+ bk = b[k];
+ c = (b[k+1]*p[k] - b[k]*p[k+1]) / (b[k+1] - b[k]);
+ kp = k;
+ }
+ assert(std::abs(f(u[i], a, m, bk, c) - double(i)/N) < .001);
+ }
+ }
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937_64 G;
+ G g;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 62.5, 12.5, 0};
+ const size_t Np = sizeof(p) / sizeof(p[0]) - 1;
+ D d(b, b+Np+1, p);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v < d.max());
+ u.push_back(v);
+ }
+ std::sort(u.begin(), u.end());
+ int kp = -1;
+ double a;
+ double m;
+ double bk;
+ double c;
+ std::vector<double> areas(Np);
+ double S = 0;
+ for (int i = 0; i < areas.size(); ++i)
+ {
+ areas[i] = (p[i]+p[i+1])*(b[i+1]-b[i])/2;
+ S += areas[i];
+ }
+ for (int i = 0; i < areas.size(); ++i)
+ areas[i] /= S;
+ for (int i = 0; i < Np+1; ++i)
+ p[i] /= S;
+ for (int i = 0; i < N; ++i)
+ {
+ int k = std::lower_bound(b, b+Np+1, u[i]) - b - 1;
+ if (k != kp)
+ {
+ a = 0;
+ for (int j = 0; j < k; ++j)
+ a += areas[j];
+ m = (p[k+1] - p[k]) / (b[k+1] - b[k]);
+ bk = b[k];
+ c = (b[k+1]*p[k] - b[k]*p[k+1]) / (b[k+1] - b[k]);
+ kp = k;
+ }
+ assert(std::abs(f(u[i], a, m, bk, c) - double(i)/N) < .001);
+ }
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/eval_param.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/eval_param.pass.cpp
new file mode 100644
index 000000000000..fe704228e788
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/eval_param.pass.cpp
@@ -0,0 +1,92 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// REQUIRES: long_tests
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_linear_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g, const param_type& parm);
+
+#include <random>
+#include <vector>
+#include <iterator>
+#include <numeric>
+#include <cassert>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+ return x*x;
+}
+
+double
+f(double x, double a, double m, double b, double c)
+{
+ return a + m*(sqr(x) - sqr(b))/2 + c*(x-b);
+}
+
+int main()
+{
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937_64 G;
+ G g;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 62.5, 12.5, 0};
+ const size_t Np = sizeof(p) / sizeof(p[0]) - 1;
+ D d;
+ P pa(b, b+Np+1, p);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, pa);
+ assert(10 <= v && v < 17);
+ u.push_back(v);
+ }
+ std::sort(u.begin(), u.end());
+ int kp = -1;
+ double a;
+ double m;
+ double bk;
+ double c;
+ std::vector<double> areas(Np);
+ double S = 0;
+ for (int i = 0; i < areas.size(); ++i)
+ {
+ areas[i] = (p[i]+p[i+1])*(b[i+1]-b[i])/2;
+ S += areas[i];
+ }
+ for (int i = 0; i < areas.size(); ++i)
+ areas[i] /= S;
+ for (int i = 0; i < Np+1; ++i)
+ p[i] /= S;
+ for (int i = 0; i < N; ++i)
+ {
+ int k = std::lower_bound(b, b+Np+1, u[i]) - b - 1;
+ if (k != kp)
+ {
+ a = 0;
+ for (int j = 0; j < k; ++j)
+ a += areas[j];
+ m = (p[k+1] - p[k]) / (b[k+1] - b[k]);
+ bk = b[k];
+ c = (b[k+1]*p[k] - b[k]*p[k+1]) / (b[k+1] - b[k]);
+ kp = k;
+ }
+ assert(std::abs(f(u[i], a, m, bk, c) - double(i)/N) < .001);
+ }
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/get_param.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/get_param.pass.cpp
new file mode 100644
index 000000000000..57a8ca5589c3
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/get_param.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_linear_distribution
+
+// param_type param() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ typedef D::param_type P;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 62.5, 12.5, 10};
+ const size_t Np = sizeof(p) / sizeof(p[0]);
+ P pa(b, b+Np, p);
+ D d(pa);
+ assert(d.param() == pa);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/io.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/io.pass.cpp
new file mode 100644
index 000000000000..1be2791fa47a
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/io.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_linear_distribution
+
+// template <class charT, class traits>
+// basic_ostream<charT, traits>&
+// operator<<(basic_ostream<charT, traits>& os,
+// const piecewise_linear_distribution& x);
+//
+// template <class charT, class traits>
+// basic_istream<charT, traits>&
+// operator>>(basic_istream<charT, traits>& is,
+// piecewise_linear_distribution& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 62.5, 12.5, 25};
+ const size_t Np = sizeof(p) / sizeof(p[0]);
+ D d1(b, b+Np, p);
+ std::ostringstream os;
+ os << d1;
+ std::istringstream is(os.str());
+ D d2;
+ is >> d2;
+ assert(d1 == d2);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/max.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/max.pass.cpp
new file mode 100644
index 000000000000..3dc12b692535
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/max.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_linear_distribution
+
+// result_type max() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 62.5, 12.5, 5};
+ const size_t Np = sizeof(p) / sizeof(p[0]);
+ D d(b, b+Np, p);
+ assert(d.max() == 17);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/min.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/min.pass.cpp
new file mode 100644
index 000000000000..4d4a7603a018
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/min.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_linear_distribution
+
+// result_type min() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 62.5, 12.5, 0};
+ const size_t Np = sizeof(p) / sizeof(p[0]);
+ D d(b, b+Np, p);
+ assert(d.min() == 10);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_assign.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_assign.pass.cpp
new file mode 100644
index 000000000000..055b2f58e792
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_assign.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_linear_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ typedef D::param_type P;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 62.5, 12.5, 2};
+ const size_t Np = sizeof(p) / sizeof(p[0]);
+ P p0(b, b+Np, p);
+ P p1;
+ p1 = p0;
+ assert(p1 == p0);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_copy.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_copy.pass.cpp
new file mode 100644
index 000000000000..87d94940a870
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_copy.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_linear_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ typedef D::param_type P;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 62.5, 12.5, 5};
+ const size_t Np = sizeof(p) / sizeof(p[0]);
+ P p0(b, b+Np, p);
+ P p1 = p0;
+ assert(p1 == p0);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_ctor_default.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_ctor_default.pass.cpp
new file mode 100644
index 000000000000..0bdf2c337d27
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_ctor_default.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_linear_distribution
+
+// param_type();
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ typedef D::param_type P;
+ P pa;
+ std::vector<double> iv = pa.intervals();
+ assert(iv.size() == 2);
+ assert(iv[0] == 0);
+ assert(iv[1] == 1);
+ std::vector<double> dn = pa.densities();
+ assert(dn.size() == 2);
+ assert(dn[0] == 1);
+ assert(dn[1] == 1);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_ctor_func.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_ctor_func.pass.cpp
new file mode 100644
index 000000000000..27e93ab6171b
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_ctor_func.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_linear_distribution
+
+// template<class UnaryOperation>
+// param_type(size_t nw, double xmin, double xmax,
+// UnaryOperation fw);
+
+#include <random>
+#include <cassert>
+
+double fw(double x)
+{
+ return 2*x;
+}
+
+int main()
+{
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ typedef D::param_type P;
+ P pa(0, 0, 1, fw);
+ std::vector<double> iv = pa.intervals();
+ assert(iv.size() == 2);
+ assert(iv[0] == 0);
+ assert(iv[1] == 1);
+ std::vector<double> dn = pa.densities();
+ assert(dn.size() == 2);
+ assert(dn[0] == 0);
+ assert(dn[1] == 2);
+ }
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ typedef D::param_type P;
+ P pa(1, 10, 12, fw);
+ std::vector<double> iv = pa.intervals();
+ assert(iv.size() == 2);
+ assert(iv[0] == 10);
+ assert(iv[1] == 12);
+ std::vector<double> dn = pa.densities();
+ assert(dn.size() == 2);
+ assert(dn[0] == 20./44);
+ assert(dn[1] == 24./44);
+ }
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ typedef D::param_type P;
+ P pa(2, 6, 14, fw);
+ std::vector<double> iv = pa.intervals();
+ assert(iv.size() == 3);
+ assert(iv[0] == 6);
+ assert(iv[1] == 10);
+ assert(iv[2] == 14);
+ std::vector<double> dn = pa.densities();
+ assert(dn.size() == 3);
+ assert(dn[0] == 0.075);
+ assert(dn[1] == 0.125);
+ assert(dn[2] == 0.175);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_ctor_init_func.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_ctor_init_func.pass.cpp
new file mode 100644
index 000000000000..cfa416434a29
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_ctor_init_func.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_linear_distribution
+
+// param_type(initializer_list<result_type> bl, UnaryOperation fw);
+
+#include <random>
+#include <cassert>
+
+double f(double x)
+{
+ return x*2;
+}
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ typedef D::param_type P;
+ P pa({}, f);
+ std::vector<double> iv = pa.intervals();
+ assert(iv.size() == 2);
+ assert(iv[0] == 0);
+ assert(iv[1] == 1);
+ std::vector<double> dn = pa.densities();
+ assert(dn.size() == 2);
+ assert(dn[0] == 1);
+ assert(dn[1] == 1);
+ }
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ typedef D::param_type P;
+ P pa({12}, f);
+ std::vector<double> iv = pa.intervals();
+ assert(iv.size() == 2);
+ assert(iv[0] == 0);
+ assert(iv[1] == 1);
+ std::vector<double> dn = pa.densities();
+ assert(dn.size() == 2);
+ assert(dn[0] == 1);
+ assert(dn[1] == 1);
+ }
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ typedef D::param_type P;
+ P pa({10, 12}, f);
+ std::vector<double> iv = pa.intervals();
+ assert(iv.size() == 2);
+ assert(iv[0] == 10);
+ assert(iv[1] == 12);
+ std::vector<double> dn = pa.densities();
+ assert(dn.size() == 2);
+ assert(dn[0] == 20./44);
+ assert(dn[1] == 24./44);
+ }
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ typedef D::param_type P;
+ P pa({6, 10, 14}, f);
+ std::vector<double> iv = pa.intervals();
+ assert(iv.size() == 3);
+ assert(iv[0] == 6);
+ assert(iv[1] == 10);
+ assert(iv[2] == 14);
+ std::vector<double> dn = pa.densities();
+ assert(dn.size() == 3);
+ assert(dn[0] == 0.075);
+ assert(dn[1] == 0.125);
+ assert(dn[2] == 0.175);
+ }
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_ctor_iterator.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_ctor_iterator.pass.cpp
new file mode 100644
index 000000000000..117a5ef93bb0
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_ctor_iterator.pass.cpp
@@ -0,0 +1,105 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_linear_distribution
+
+// template<class InputIterator>
+// param_type(InputIteratorB firstB, InputIteratorB lastB,
+// InputIteratorW firstW);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ typedef D::param_type P;
+ double b[] = {10};
+ double p[] = {12};
+ P pa(b, b, p);
+ std::vector<double> iv = pa.intervals();
+ assert(iv.size() == 2);
+ assert(iv[0] == 0);
+ assert(iv[1] == 1);
+ std::vector<double> dn = pa.densities();
+ assert(dn.size() == 2);
+ assert(dn[0] == 1);
+ assert(dn[1] == 1);
+ }
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ typedef D::param_type P;
+ double b[] = {10};
+ double p[] = {12};
+ P pa(b, b+1, p);
+ std::vector<double> iv = pa.intervals();
+ assert(iv.size() == 2);
+ assert(iv[0] == 0);
+ assert(iv[1] == 1);
+ std::vector<double> dn = pa.densities();
+ assert(dn.size() == 2);
+ assert(dn[0] == 1);
+ assert(dn[1] == 1);
+ }
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ typedef D::param_type P;
+ double b[] = {10, 15};
+ double p[] = {12, 12};
+ P pa(b, b+2, p);
+ std::vector<double> iv = pa.intervals();
+ assert(iv.size() == 2);
+ assert(iv[0] == 10);
+ assert(iv[1] == 15);
+ std::vector<double> dn = pa.densities();
+ assert(dn.size() == 2);
+ assert(dn[0] == 1/5.);
+ assert(dn[1] == 1/5.);
+ }
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ typedef D::param_type P;
+ double b[] = {10, 15, 16};
+ double p[] = {.25, .75, .25};
+ P pa(b, b+3, p);
+ std::vector<double> iv = pa.intervals();
+ assert(iv.size() == 3);
+ assert(iv[0] == 10);
+ assert(iv[1] == 15);
+ assert(iv[2] == 16);
+ std::vector<double> dn = pa.densities();
+ assert(dn.size() == 3);
+ assert(dn[0] == .25/3);
+ assert(dn[1] == .75/3);
+ assert(dn[2] == .25/3);
+ }
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ typedef D::param_type P;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {0, 1, 1, 0};
+ P pa(b, b+4, p);
+ std::vector<double> iv = pa.intervals();
+ assert(iv.size() == 4);
+ assert(iv[0] == 10);
+ assert(iv[1] == 14);
+ assert(iv[2] == 16);
+ assert(iv[3] == 17);
+ std::vector<double> dn = pa.densities();
+ assert(dn.size() == 4);
+ assert(dn[0] == 0);
+ assert(dn[1] == 1/4.5);
+ assert(dn[2] == 1/4.5);
+ assert(dn[3] == 0);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_eq.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_eq.pass.cpp
new file mode 100644
index 000000000000..1adffc8ca868
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_eq.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_linear_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ typedef D::param_type P;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 62.5, 12.5, 0};
+ P p1(b, b+4, p);
+ P p2(b, b+4, p);
+ assert(p1 == p2);
+ }
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ typedef D::param_type P;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 62.5, 12.5, 0};
+ P p1(b, b+3, p);
+ P p2(b, b+4, p);
+ assert(p1 != p2);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_types.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_types.pass.cpp
new file mode 100644
index 000000000000..cea1e3dffd31
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_types.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_linear_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ typedef D::param_type param_type;
+ typedef param_type::distribution_type distribution_type;
+ static_assert((std::is_same<D, distribution_type>::value), "");
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/set_param.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/set_param.pass.cpp
new file mode 100644
index 000000000000..e85a2f0ce4c2
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/set_param.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_linear_distribution
+
+// void param(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ typedef D::param_type P;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 62.5, 12.5, 0};
+ P pa(b, b+4, p);
+ D d;
+ d.param(pa);
+ assert(d.param() == pa);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/types.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/types.pass.cpp
new file mode 100644
index 000000000000..a34212987878
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/types.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_linear_distribution
+// {
+// typedef bool result_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::piecewise_linear_distribution<> D;
+ typedef D::result_type result_type;
+ static_assert((std::is_same<result_type, double>::value), "");
+ }
+ {
+ typedef std::piecewise_linear_distribution<float> D;
+ typedef D::result_type result_type;
+ static_assert((std::is_same<result_type, float>::value), "");
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.uni/nothing_to_do.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.uni/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.uni/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/assign.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/assign.pass.cpp
new file mode 100644
index 000000000000..0e04ea455e7e
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/assign.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class _IntType = int>
+// class uniform_int_distribution
+
+// uniform_int_distribution& operator=(const uniform_int_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::uniform_int_distribution<long> D;
+ D d1(2, 5);
+ D d2;
+ assert(d1 != d2);
+ d2 = d1;
+ assert(d1 == d2);
+}
+
+int main()
+{
+ test1();
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/copy.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/copy.pass.cpp
new file mode 100644
index 000000000000..c09830c6277a
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/copy.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class _IntType = int>
+// class uniform_int_distribution
+
+// uniform_int_distribution(const uniform_int_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::uniform_int_distribution<long> D;
+ D d1(2, 5);
+ D d2 = d1;
+ assert(d1 == d2);
+}
+
+int main()
+{
+ test1();
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/ctor_int_int.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/ctor_int_int.pass.cpp
new file mode 100644
index 000000000000..68f2ec0975a9
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/ctor_int_int.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class _IntType = int>
+// class uniform_int_distribution
+
+// explicit uniform_int_distribution(IntType a = 0,
+// IntType b = numeric_limits<IntType>::max());
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::uniform_int_distribution<> D;
+ D d;
+ assert(d.a() == 0);
+ assert(d.b() == std::numeric_limits<int>::max());
+ }
+ {
+ typedef std::uniform_int_distribution<> D;
+ D d(-6);
+ assert(d.a() == -6);
+ assert(d.b() == std::numeric_limits<int>::max());
+ }
+ {
+ typedef std::uniform_int_distribution<> D;
+ D d(-6, 106);
+ assert(d.a() == -6);
+ assert(d.b() == 106);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/ctor_param.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/ctor_param.pass.cpp
new file mode 100644
index 000000000000..cc3e86a42bd6
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/ctor_param.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class _IntType = int>
+// class uniform_int_distribution
+
+// explicit uniform_int_distribution(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::uniform_int_distribution<> D;
+ typedef D::param_type P;
+ P p(3, 8);
+ D d(p);
+ assert(d.a() == 3);
+ assert(d.b() == 8);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/eq.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/eq.pass.cpp
new file mode 100644
index 000000000000..b7a5cffbe564
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/eq.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class _IntType = int>
+// class uniform_int_distribution
+
+// bool operator=(const uniform_int_distribution& x,
+// const uniform_int_distribution& y);
+// bool operator!(const uniform_int_distribution& x,
+// const uniform_int_distribution& y);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::uniform_int_distribution<> D;
+ D d1(3, 8);
+ D d2(3, 8);
+ assert(d1 == d2);
+ }
+ {
+ typedef std::uniform_int_distribution<> D;
+ D d1(3, 8);
+ D d2(3, 9);
+ assert(d1 != d2);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/eval.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/eval.pass.cpp
new file mode 100644
index 000000000000..66693a8da55b
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/eval.pass.cpp
@@ -0,0 +1,455 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// REQUIRES: long_tests
+
+// <random>
+
+// template<class _IntType = int>
+// class uniform_int_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g);
+
+#include <random>
+#include <cassert>
+#include <vector>
+#include <numeric>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+ return x * x;
+}
+
+int main()
+{
+ {
+ typedef std::uniform_int_distribution<> D;
+ typedef std::minstd_rand0 G;
+ G g;
+ D d;
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.a() <= v && v <= d.b());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = ((double)d.a() + d.b()) / 2;
+ double x_var = (sqr((double)d.b() - d.a() + 1) - 1) / 12;
+ double x_skew = 0;
+ double x_kurtosis = -6. * (sqr((double)d.b() - d.a() + 1) + 1) /
+ (5. * (sqr((double)d.b() - d.a() + 1) - 1));
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs(skew - x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ {
+ typedef std::uniform_int_distribution<> D;
+ typedef std::minstd_rand G;
+ G g;
+ D d;
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.a() <= v && v <= d.b());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = ((double)d.a() + d.b()) / 2;
+ double x_var = (sqr((double)d.b() - d.a() + 1) - 1) / 12;
+ double x_skew = 0;
+ double x_kurtosis = -6. * (sqr((double)d.b() - d.a() + 1) + 1) /
+ (5. * (sqr((double)d.b() - d.a() + 1) - 1));
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs(skew - x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ {
+ typedef std::uniform_int_distribution<> D;
+ typedef std::mt19937 G;
+ G g;
+ D d;
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.a() <= v && v <= d.b());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = ((double)d.a() + d.b()) / 2;
+ double x_var = (sqr((double)d.b() - d.a() + 1) - 1) / 12;
+ double x_skew = 0;
+ double x_kurtosis = -6. * (sqr((double)d.b() - d.a() + 1) + 1) /
+ (5. * (sqr((double)d.b() - d.a() + 1) - 1));
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs(skew - x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ {
+ typedef std::uniform_int_distribution<> D;
+ typedef std::mt19937_64 G;
+ G g;
+ D d;
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.a() <= v && v <= d.b());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = ((double)d.a() + d.b()) / 2;
+ double x_var = (sqr((double)d.b() - d.a() + 1) - 1) / 12;
+ double x_skew = 0;
+ double x_kurtosis = -6. * (sqr((double)d.b() - d.a() + 1) + 1) /
+ (5. * (sqr((double)d.b() - d.a() + 1) - 1));
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs(skew - x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ {
+ typedef std::uniform_int_distribution<> D;
+ typedef std::ranlux24_base G;
+ G g;
+ D d;
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.a() <= v && v <= d.b());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = ((double)d.a() + d.b()) / 2;
+ double x_var = (sqr((double)d.b() - d.a() + 1) - 1) / 12;
+ double x_skew = 0;
+ double x_kurtosis = -6. * (sqr((double)d.b() - d.a() + 1) + 1) /
+ (5. * (sqr((double)d.b() - d.a() + 1) - 1));
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs(skew - x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ {
+ typedef std::uniform_int_distribution<> D;
+ typedef std::ranlux48_base G;
+ G g;
+ D d;
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.a() <= v && v <= d.b());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = ((double)d.a() + d.b()) / 2;
+ double x_var = (sqr((double)d.b() - d.a() + 1) - 1) / 12;
+ double x_skew = 0;
+ double x_kurtosis = -6. * (sqr((double)d.b() - d.a() + 1) + 1) /
+ (5. * (sqr((double)d.b() - d.a() + 1) - 1));
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs(skew - x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ {
+ typedef std::uniform_int_distribution<> D;
+ typedef std::ranlux24 G;
+ G g;
+ D d;
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.a() <= v && v <= d.b());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = ((double)d.a() + d.b()) / 2;
+ double x_var = (sqr((double)d.b() - d.a() + 1) - 1) / 12;
+ double x_skew = 0;
+ double x_kurtosis = -6. * (sqr((double)d.b() - d.a() + 1) + 1) /
+ (5. * (sqr((double)d.b() - d.a() + 1) - 1));
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs(skew - x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ {
+ typedef std::uniform_int_distribution<> D;
+ typedef std::ranlux48 G;
+ G g;
+ D d;
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.a() <= v && v <= d.b());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = ((double)d.a() + d.b()) / 2;
+ double x_var = (sqr((double)d.b() - d.a() + 1) - 1) / 12;
+ double x_skew = 0;
+ double x_kurtosis = -6. * (sqr((double)d.b() - d.a() + 1) + 1) /
+ (5. * (sqr((double)d.b() - d.a() + 1) - 1));
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs(skew - x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ {
+ typedef std::uniform_int_distribution<> D;
+ typedef std::knuth_b G;
+ G g;
+ D d;
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.a() <= v && v <= d.b());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = ((double)d.a() + d.b()) / 2;
+ double x_var = (sqr((double)d.b() - d.a() + 1) - 1) / 12;
+ double x_skew = 0;
+ double x_kurtosis = -6. * (sqr((double)d.b() - d.a() + 1) + 1) /
+ (5. * (sqr((double)d.b() - d.a() + 1) - 1));
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs(skew - x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ {
+ typedef std::uniform_int_distribution<> D;
+ typedef std::minstd_rand0 G;
+ G g;
+ D d(-6, 106);
+ for (int i = 0; i < 10000; ++i)
+ {
+ int u = d(g);
+ assert(-6 <= u && u <= 106);
+ }
+ }
+ {
+ typedef std::uniform_int_distribution<> D;
+ typedef std::minstd_rand G;
+ G g;
+ D d(5, 100);
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.a() <= v && v <= d.b());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = ((double)d.a() + d.b()) / 2;
+ double x_var = (sqr((double)d.b() - d.a() + 1) - 1) / 12;
+ double x_skew = 0;
+ double x_kurtosis = -6. * (sqr((double)d.b() - d.a() + 1) + 1) /
+ (5. * (sqr((double)d.b() - d.a() + 1) - 1));
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs(skew - x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/eval_param.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/eval_param.pass.cpp
new file mode 100644
index 000000000000..d83d48cac1e3
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/eval_param.pass.cpp
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class _IntType = int>
+// class uniform_int_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g, const param_type& parm);
+
+#include <random>
+#include <cassert>
+#include <vector>
+#include <numeric>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+ return x * x;
+}
+
+int main()
+{
+ {
+ typedef std::uniform_int_distribution<> D;
+ typedef std::minstd_rand G;
+ typedef D::param_type P;
+ G g;
+ D d(5, 100);
+ P p(-10, 20);
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, p);
+ assert(p.a() <= v && v <= p.b());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = ((double)p.a() + p.b()) / 2;
+ double x_var = (sqr((double)p.b() - p.a() + 1) - 1) / 12;
+ double x_skew = 0;
+ double x_kurtosis = -6. * (sqr((double)p.b() - p.a() + 1) + 1) /
+ (5. * (sqr((double)p.b() - p.a() + 1) - 1));
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs(skew - x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/get_param.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/get_param.pass.cpp
new file mode 100644
index 000000000000..ab8fa6c98363
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/get_param.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class _IntType = int>
+// class uniform_int_distribution
+
+// param_type param() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::uniform_int_distribution<> D;
+ typedef D::param_type P;
+ P p(3, 8);
+ D d(p);
+ assert(d.param() == p);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/io.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/io.pass.cpp
new file mode 100644
index 000000000000..0220a5aa9570
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/io.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class _IntType = int>
+// class uniform_int_distribution
+
+// template <class charT, class traits>
+// basic_ostream<charT, traits>&
+// operator<<(basic_ostream<charT, traits>& os,
+// const uniform_int_distribution& x);
+//
+// template <class charT, class traits>
+// basic_istream<charT, traits>&
+// operator>>(basic_istream<charT, traits>& is,
+// uniform_int_distribution& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::uniform_int_distribution<> D;
+ D d1(3, 8);
+ std::ostringstream os;
+ os << d1;
+ std::istringstream is(os.str());
+ D d2;
+ is >> d2;
+ assert(d1 == d2);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/max.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/max.pass.cpp
new file mode 100644
index 000000000000..c0a262f8a88c
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/max.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class _IntType = int>
+// class uniform_int_distribution
+
+// result_type max() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::uniform_int_distribution<> D;
+ D d(3, 8);
+ assert(d.max() == 8);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/min.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/min.pass.cpp
new file mode 100644
index 000000000000..3a0d3b2d94be
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/min.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class _IntType = int>
+// class uniform_int_distribution
+
+// result_type min() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::uniform_int_distribution<> D;
+ D d(3, 8);
+ assert(d.min() == 3);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_assign.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_assign.pass.cpp
new file mode 100644
index 000000000000..09c56097142d
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_assign.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class _IntType = int>
+// class uniform_int_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::uniform_int_distribution<long> D;
+ typedef D::param_type param_type;
+ param_type p0(5, 10);
+ param_type p;
+ p = p0;
+ assert(p.a() == 5);
+ assert(p.b() == 10);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_copy.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_copy.pass.cpp
new file mode 100644
index 000000000000..1f01e9858c34
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_copy.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class _IntType = int>
+// class uniform_int_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::uniform_int_distribution<long> D;
+ typedef D::param_type param_type;
+ param_type p0(5, 10);
+ param_type p = p0;
+ assert(p.a() == 5);
+ assert(p.b() == 10);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_ctor.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_ctor.pass.cpp
new file mode 100644
index 000000000000..eba933c01911
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_ctor.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class _IntType = int>
+// class uniform_int_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::uniform_int_distribution<long> D;
+ typedef D::param_type param_type;
+ param_type p;
+ assert(p.a() == 0);
+ assert(p.b() == std::numeric_limits<long>::max());
+ }
+ {
+ typedef std::uniform_int_distribution<long> D;
+ typedef D::param_type param_type;
+ param_type p(5);
+ assert(p.a() == 5);
+ assert(p.b() == std::numeric_limits<long>::max());
+ }
+ {
+ typedef std::uniform_int_distribution<long> D;
+ typedef D::param_type param_type;
+ param_type p(5, 10);
+ assert(p.a() == 5);
+ assert(p.b() == 10);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_eq.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_eq.pass.cpp
new file mode 100644
index 000000000000..5831f96b6b36
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_eq.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class _IntType = int>
+// class uniform_int_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::uniform_int_distribution<long> D;
+ typedef D::param_type param_type;
+ param_type p1(5, 10);
+ param_type p2(5, 10);
+ assert(p1 == p2);
+ }
+ {
+ typedef std::uniform_int_distribution<long> D;
+ typedef D::param_type param_type;
+ param_type p1(5, 10);
+ param_type p2(6, 10);
+ assert(p1 != p2);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_types.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_types.pass.cpp
new file mode 100644
index 000000000000..4022cfb6102b
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_types.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class _IntType = int>
+// class uniform_int_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::uniform_int_distribution<long> D;
+ typedef D::param_type param_type;
+ typedef param_type::distribution_type distribution_type;
+ static_assert((std::is_same<D, distribution_type>::value), "");
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/set_param.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/set_param.pass.cpp
new file mode 100644
index 000000000000..823837ba68e9
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/set_param.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class _IntType = int>
+// class uniform_int_distribution
+
+// void param(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::uniform_int_distribution<> D;
+ typedef D::param_type P;
+ P p(3, 8);
+ D d(6, 7);
+ d.param(p);
+ assert(d.param() == p);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/types.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/types.pass.cpp
new file mode 100644
index 000000000000..65c01d037885
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/types.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class _IntType = int>
+// class uniform_int_distribution
+// {
+// typedef IntType result_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::uniform_int_distribution<long> D;
+ typedef D::result_type result_type;
+ static_assert((std::is_same<result_type, long>::value), "");
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/assign.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/assign.pass.cpp
new file mode 100644
index 000000000000..9651a2f0596b
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/assign.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class uniform_real_distribution
+
+// uniform_real_distribution& operator=(const uniform_real_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::uniform_real_distribution<float> D;
+ D d1(2, 5);
+ D d2;
+ assert(d1 != d2);
+ d2 = d1;
+ assert(d1 == d2);
+}
+
+int main()
+{
+ test1();
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/copy.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/copy.pass.cpp
new file mode 100644
index 000000000000..073c3a851570
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/copy.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class uniform_real_distribution
+
+// uniform_real_distribution(const uniform_real_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::uniform_real_distribution<float> D;
+ D d1(2, 5);
+ D d2 = d1;
+ assert(d1 == d2);
+}
+
+int main()
+{
+ test1();
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/ctor_int_int.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/ctor_int_int.pass.cpp
new file mode 100644
index 000000000000..03abc5362108
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/ctor_int_int.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class uniform_real_distribution
+
+// explicit uniform_real_distribution(RealType a = 0,
+// RealType b = 1);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::uniform_real_distribution<> D;
+ D d;
+ assert(d.a() == 0);
+ assert(d.b() == 1);
+ }
+ {
+ typedef std::uniform_real_distribution<> D;
+ D d(-6);
+ assert(d.a() == -6);
+ assert(d.b() == 1);
+ }
+ {
+ typedef std::uniform_real_distribution<> D;
+ D d(-6, 106);
+ assert(d.a() == -6);
+ assert(d.b() == 106);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/ctor_param.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/ctor_param.pass.cpp
new file mode 100644
index 000000000000..a6f4aff93d81
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/ctor_param.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class uniform_real_distribution
+
+// explicit uniform_real_distribution(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::uniform_real_distribution<> D;
+ typedef D::param_type P;
+ P p(3.5, 8);
+ D d(p);
+ assert(d.a() == 3.5);
+ assert(d.b() == 8);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/eq.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/eq.pass.cpp
new file mode 100644
index 000000000000..5fcba4346dc1
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/eq.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class uniform_real_distribution
+
+// bool operator=(const uniform_real_distribution& x,
+// const uniform_real_distribution& y);
+// bool operator!(const uniform_real_distribution& x,
+// const uniform_real_distribution& y);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::uniform_real_distribution<> D;
+ D d1(3, 8);
+ D d2(3, 8);
+ assert(d1 == d2);
+ }
+ {
+ typedef std::uniform_real_distribution<> D;
+ D d1(3, 8);
+ D d2(3, 8.1);
+ assert(d1 != d2);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/eval.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/eval.pass.cpp
new file mode 100644
index 000000000000..2663b2683bb4
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/eval.pass.cpp
@@ -0,0 +1,474 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// REQUIRES: long_tests
+
+// <random>
+
+// template<class RealType = double>
+// class uniform_real_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g);
+
+#include <random>
+#include <cassert>
+#include <vector>
+#include <numeric>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+ return x * x;
+}
+
+int main()
+{
+ {
+ typedef std::uniform_real_distribution<> D;
+ typedef std::minstd_rand0 G;
+ G g;
+ D d;
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.a() <= v && v < d.b());
+ u.push_back(v);
+ }
+ D::result_type mean = std::accumulate(u.begin(), u.end(),
+ D::result_type(0)) / u.size();
+ D::result_type var = 0;
+ D::result_type skew = 0;
+ D::result_type kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ D::result_type d = (u[i] - mean);
+ D::result_type d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ D::result_type dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ D::result_type x_mean = (d.a() + d.b()) / 2;
+ D::result_type x_var = sqr(d.b() - d.a()) / 12;
+ D::result_type x_skew = 0;
+ D::result_type x_kurtosis = -6./5;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs(skew - x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ {
+ typedef std::uniform_real_distribution<> D;
+ typedef std::minstd_rand G;
+ G g;
+ D d;
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.a() <= v && v < d.b());
+ u.push_back(v);
+ }
+ D::result_type mean = std::accumulate(u.begin(), u.end(),
+ D::result_type(0)) / u.size();
+ D::result_type var = 0;
+ D::result_type skew = 0;
+ D::result_type kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ D::result_type d = (u[i] - mean);
+ D::result_type d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ D::result_type dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ D::result_type x_mean = (d.a() + d.b()) / 2;
+ D::result_type x_var = sqr(d.b() - d.a()) / 12;
+ D::result_type x_skew = 0;
+ D::result_type x_kurtosis = -6./5;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs(skew - x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ {
+ typedef std::uniform_real_distribution<> D;
+ typedef std::mt19937 G;
+ G g;
+ D d;
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.a() <= v && v < d.b());
+ u.push_back(v);
+ }
+ D::result_type mean = std::accumulate(u.begin(), u.end(),
+ D::result_type(0)) / u.size();
+ D::result_type var = 0;
+ D::result_type skew = 0;
+ D::result_type kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ D::result_type d = (u[i] - mean);
+ D::result_type d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ D::result_type dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ D::result_type x_mean = (d.a() + d.b()) / 2;
+ D::result_type x_var = sqr(d.b() - d.a()) / 12;
+ D::result_type x_skew = 0;
+ D::result_type x_kurtosis = -6./5;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs(skew - x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ {
+ typedef std::uniform_real_distribution<> D;
+ typedef std::mt19937_64 G;
+ G g;
+ D d;
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.a() <= v && v < d.b());
+ u.push_back(v);
+ }
+ D::result_type mean = std::accumulate(u.begin(), u.end(),
+ D::result_type(0)) / u.size();
+ D::result_type var = 0;
+ D::result_type skew = 0;
+ D::result_type kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ D::result_type d = (u[i] - mean);
+ D::result_type d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ D::result_type dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ D::result_type x_mean = (d.a() + d.b()) / 2;
+ D::result_type x_var = sqr(d.b() - d.a()) / 12;
+ D::result_type x_skew = 0;
+ D::result_type x_kurtosis = -6./5;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs(skew - x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ {
+ typedef std::uniform_real_distribution<> D;
+ typedef std::ranlux24_base G;
+ G g;
+ D d;
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.a() <= v && v < d.b());
+ u.push_back(v);
+ }
+ D::result_type mean = std::accumulate(u.begin(), u.end(),
+ D::result_type(0)) / u.size();
+ D::result_type var = 0;
+ D::result_type skew = 0;
+ D::result_type kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ D::result_type d = (u[i] - mean);
+ D::result_type d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ D::result_type dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ D::result_type x_mean = (d.a() + d.b()) / 2;
+ D::result_type x_var = sqr(d.b() - d.a()) / 12;
+ D::result_type x_skew = 0;
+ D::result_type x_kurtosis = -6./5;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs(skew - x_skew) < 0.02);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ {
+ typedef std::uniform_real_distribution<> D;
+ typedef std::ranlux48_base G;
+ G g;
+ D d;
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.a() <= v && v < d.b());
+ u.push_back(v);
+ }
+ D::result_type mean = std::accumulate(u.begin(), u.end(),
+ D::result_type(0)) / u.size();
+ D::result_type var = 0;
+ D::result_type skew = 0;
+ D::result_type kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ D::result_type d = (u[i] - mean);
+ D::result_type d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ D::result_type dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ D::result_type x_mean = (d.a() + d.b()) / 2;
+ D::result_type x_var = sqr(d.b() - d.a()) / 12;
+ D::result_type x_skew = 0;
+ D::result_type x_kurtosis = -6./5;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs(skew - x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ {
+ typedef std::uniform_real_distribution<> D;
+ typedef std::ranlux24 G;
+ G g;
+ D d;
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.a() <= v && v < d.b());
+ u.push_back(v);
+ }
+ D::result_type mean = std::accumulate(u.begin(), u.end(),
+ D::result_type(0)) / u.size();
+ D::result_type var = 0;
+ D::result_type skew = 0;
+ D::result_type kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ D::result_type d = (u[i] - mean);
+ D::result_type d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ D::result_type dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ D::result_type x_mean = (d.a() + d.b()) / 2;
+ D::result_type x_var = sqr(d.b() - d.a()) / 12;
+ D::result_type x_skew = 0;
+ D::result_type x_kurtosis = -6./5;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs(skew - x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ {
+ typedef std::uniform_real_distribution<> D;
+ typedef std::ranlux48 G;
+ G g;
+ D d;
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.a() <= v && v < d.b());
+ u.push_back(v);
+ }
+ D::result_type mean = std::accumulate(u.begin(), u.end(),
+ D::result_type(0)) / u.size();
+ D::result_type var = 0;
+ D::result_type skew = 0;
+ D::result_type kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ D::result_type d = (u[i] - mean);
+ D::result_type d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ D::result_type dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ D::result_type x_mean = (d.a() + d.b()) / 2;
+ D::result_type x_var = sqr(d.b() - d.a()) / 12;
+ D::result_type x_skew = 0;
+ D::result_type x_kurtosis = -6./5;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs(skew - x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ {
+ typedef std::uniform_real_distribution<> D;
+ typedef std::knuth_b G;
+ G g;
+ D d;
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.a() <= v && v < d.b());
+ u.push_back(v);
+ }
+ D::result_type mean = std::accumulate(u.begin(), u.end(),
+ D::result_type(0)) / u.size();
+ D::result_type var = 0;
+ D::result_type skew = 0;
+ D::result_type kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ D::result_type d = (u[i] - mean);
+ D::result_type d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ D::result_type dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ D::result_type x_mean = (d.a() + d.b()) / 2;
+ D::result_type x_var = sqr(d.b() - d.a()) / 12;
+ D::result_type x_skew = 0;
+ D::result_type x_kurtosis = -6./5;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs(skew - x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ {
+ typedef std::uniform_real_distribution<> D;
+ typedef std::minstd_rand G;
+ G g;
+ D d(-1, 1);
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.a() <= v && v < d.b());
+ u.push_back(v);
+ }
+ D::result_type mean = std::accumulate(u.begin(), u.end(),
+ D::result_type(0)) / u.size();
+ D::result_type var = 0;
+ D::result_type skew = 0;
+ D::result_type kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ D::result_type d = (u[i] - mean);
+ D::result_type d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ D::result_type dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ D::result_type x_mean = (d.a() + d.b()) / 2;
+ D::result_type x_var = sqr(d.b() - d.a()) / 12;
+ D::result_type x_skew = 0;
+ D::result_type x_kurtosis = -6./5;
+ assert(std::abs(mean - x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs(skew - x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ {
+ typedef std::uniform_real_distribution<> D;
+ typedef std::minstd_rand G;
+ G g;
+ D d(5.5, 25);
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.a() <= v && v < d.b());
+ u.push_back(v);
+ }
+ D::result_type mean = std::accumulate(u.begin(), u.end(),
+ D::result_type(0)) / u.size();
+ D::result_type var = 0;
+ D::result_type skew = 0;
+ D::result_type kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ D::result_type d = (u[i] - mean);
+ D::result_type d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ D::result_type dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ D::result_type x_mean = (d.a() + d.b()) / 2;
+ D::result_type x_var = sqr(d.b() - d.a()) / 12;
+ D::result_type x_skew = 0;
+ D::result_type x_kurtosis = -6./5;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs(skew - x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/eval_param.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/eval_param.pass.cpp
new file mode 100644
index 000000000000..b5803f401465
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/eval_param.pass.cpp
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class uniform_real_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g, const param_type& parm);
+
+#include <random>
+#include <cassert>
+#include <vector>
+#include <numeric>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+ return x * x;
+}
+
+int main()
+{
+ {
+ typedef std::uniform_real_distribution<> D;
+ typedef std::minstd_rand G;
+ typedef D::param_type P;
+ G g;
+ D d(5.5, 25);
+ P p(-10, 20);
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, p);
+ assert(p.a() <= v && v < p.b());
+ u.push_back(v);
+ }
+ D::result_type mean = std::accumulate(u.begin(), u.end(),
+ D::result_type(0)) / u.size();
+ D::result_type var = 0;
+ D::result_type skew = 0;
+ D::result_type kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ D::result_type d = (u[i] - mean);
+ D::result_type d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ D::result_type dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ D::result_type x_mean = (p.a() + p.b()) / 2;
+ D::result_type x_var = sqr(p.b() - p.a()) / 12;
+ D::result_type x_skew = 0;
+ D::result_type x_kurtosis = -6./5;
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs(skew - x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/get_param.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/get_param.pass.cpp
new file mode 100644
index 000000000000..0496d853e329
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/get_param.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class uniform_real_distribution
+
+// param_type param() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::uniform_real_distribution<> D;
+ typedef D::param_type P;
+ P p(3, 8);
+ D d(p);
+ assert(d.param() == p);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/io.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/io.pass.cpp
new file mode 100644
index 000000000000..17ff93889308
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/io.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class uniform_real_distribution
+
+// template <class charT, class traits>
+// basic_ostream<charT, traits>&
+// operator<<(basic_ostream<charT, traits>& os,
+// const uniform_real_distribution& x);
+//
+// template <class charT, class traits>
+// basic_istream<charT, traits>&
+// operator>>(basic_istream<charT, traits>& is,
+// uniform_real_distribution& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::uniform_real_distribution<> D;
+ D d1(3, 8);
+ std::ostringstream os;
+ os << d1;
+ std::istringstream is(os.str());
+ D d2;
+ is >> d2;
+ assert(d1 == d2);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/max.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/max.pass.cpp
new file mode 100644
index 000000000000..6baa6d81a83c
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/max.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class uniform_real_distribution
+
+// result_type max() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::uniform_real_distribution<> D;
+ D d(3, 8);
+ assert(d.max() == 8);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/min.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/min.pass.cpp
new file mode 100644
index 000000000000..3974258c54df
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/min.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class uniform_real_distribution
+
+// result_type min() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::uniform_real_distribution<> D;
+ D d(3, 8);
+ assert(d.min() == 3);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/param_assign.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/param_assign.pass.cpp
new file mode 100644
index 000000000000..07497fef5316
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/param_assign.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class uniform_real_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::uniform_real_distribution<float> D;
+ typedef D::param_type param_type;
+ param_type p0(5, 10);
+ param_type p;
+ p = p0;
+ assert(p.a() == 5);
+ assert(p.b() == 10);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/param_copy.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/param_copy.pass.cpp
new file mode 100644
index 000000000000..d64df7dacb6b
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/param_copy.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class uniform_real_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::uniform_real_distribution<float> D;
+ typedef D::param_type param_type;
+ param_type p0(5, 10);
+ param_type p = p0;
+ assert(p.a() == 5);
+ assert(p.b() == 10);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/param_ctor.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/param_ctor.pass.cpp
new file mode 100644
index 000000000000..8f21ebfbdbb3
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/param_ctor.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class uniform_real_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::uniform_real_distribution<float> D;
+ typedef D::param_type param_type;
+ param_type p;
+ assert(p.a() == 0);
+ assert(p.b() == 1);
+ }
+ {
+ typedef std::uniform_real_distribution<float> D;
+ typedef D::param_type param_type;
+ param_type p(5);
+ assert(p.a() == 5);
+ assert(p.b() == 1);
+ }
+ {
+ typedef std::uniform_real_distribution<float> D;
+ typedef D::param_type param_type;
+ param_type p(5, 10);
+ assert(p.a() == 5);
+ assert(p.b() == 10);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/param_eq.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/param_eq.pass.cpp
new file mode 100644
index 000000000000..62df68ca628e
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/param_eq.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class uniform_real_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::uniform_real_distribution<float> D;
+ typedef D::param_type param_type;
+ param_type p1(5, 10);
+ param_type p2(5, 10);
+ assert(p1 == p2);
+ }
+ {
+ typedef std::uniform_real_distribution<float> D;
+ typedef D::param_type param_type;
+ param_type p1(5, 10);
+ param_type p2(6, 10);
+ assert(p1 != p2);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/param_types.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/param_types.pass.cpp
new file mode 100644
index 000000000000..27c0998be258
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/param_types.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class uniform_real_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::uniform_real_distribution<float> D;
+ typedef D::param_type param_type;
+ typedef param_type::distribution_type distribution_type;
+ static_assert((std::is_same<D, distribution_type>::value), "");
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/set_param.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/set_param.pass.cpp
new file mode 100644
index 000000000000..1ff121def104
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/set_param.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class uniform_real_distribution
+
+// void param(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::uniform_real_distribution<> D;
+ typedef D::param_type P;
+ P p(3, 8);
+ D d(6, 7);
+ d.param(p);
+ assert(d.param() == p);
+ }
+}
diff --git a/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/types.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/types.pass.cpp
new file mode 100644
index 000000000000..b0e792fdd624
--- /dev/null
+++ b/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/types.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class uniform_real_distribution
+// {
+// typedef IntType result_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::uniform_real_distribution<float> D;
+ typedef D::result_type result_type;
+ static_assert((std::is_same<result_type, float>::value), "");
+ }
+}
diff --git a/test/std/numerics/rand/rand.eng/nothing_to_do.pass.cpp b/test/std/numerics/rand/rand.eng/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/numerics/rand/rand.eng/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/numerics/rand/rand.eng/rand.eng.lcong/assign.pass.cpp b/test/std/numerics/rand/rand.eng/rand.eng.lcong/assign.pass.cpp
new file mode 100644
index 000000000000..8c09f4fd0109
--- /dev/null
+++ b/test/std/numerics/rand/rand.eng/rand.eng.lcong/assign.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template <class UIntType, UIntType a, UIntType c, UIntType m>
+// class linear_congruential_engine;
+
+// linear_congruential_engine& operator=(const linear_congruential_engine&);
+
+#include <random>
+#include <cassert>
+
+template <class T, T a, T c, T m>
+void
+test1()
+{
+ typedef std::linear_congruential_engine<T, a, c, m> E;
+ E e1;
+ E e2;
+ assert(e1 == e2);
+ e1();
+ e2 = e1;
+ assert(e1 == e2);
+}
+
+template <class T>
+void
+test()
+{
+ test1<T, 0, 0, 0>();
+ test1<T, 0, 1, 2>();
+ test1<T, 1, 1, 2>();
+ const T M(~0);
+ test1<T, 0, 0, M>();
+ test1<T, 0, M-2, M>();
+ test1<T, 0, M-1, M>();
+ test1<T, M-2, 0, M>();
+ test1<T, M-2, M-2, M>();
+ test1<T, M-2, M-1, M>();
+ test1<T, M-1, 0, M>();
+ test1<T, M-1, M-2, M>();
+ test1<T, M-1, M-1, M>();
+}
+
+int main()
+{
+ test<unsigned short>();
+ test<unsigned int>();
+ test<unsigned long>();
+ test<unsigned long long>();
+}
diff --git a/test/std/numerics/rand/rand.eng/rand.eng.lcong/copy.pass.cpp b/test/std/numerics/rand/rand.eng/rand.eng.lcong/copy.pass.cpp
new file mode 100644
index 000000000000..4b2b20da13ab
--- /dev/null
+++ b/test/std/numerics/rand/rand.eng/rand.eng.lcong/copy.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template <class UIntType, UIntType a, UIntType c, UIntType m>
+// class linear_congruential_engine;
+
+// linear_congruential_engine(const linear_congruential_engine&);
+
+#include <random>
+#include <cassert>
+
+template <class T, T a, T c, T m>
+void
+test1()
+{
+ typedef std::linear_congruential_engine<T, a, c, m> E;
+ E e1;
+ E e2 = e1;
+ assert(e1 == e2);
+ e1();
+ e2();
+ assert(e1 == e2);
+}
+
+template <class T>
+void
+test()
+{
+ test1<T, 0, 0, 0>();
+ test1<T, 0, 1, 2>();
+ test1<T, 1, 1, 2>();
+ const T M(~0);
+ test1<T, 0, 0, M>();
+ test1<T, 0, M-2, M>();
+ test1<T, 0, M-1, M>();
+ test1<T, M-2, 0, M>();
+ test1<T, M-2, M-2, M>();
+ test1<T, M-2, M-1, M>();
+ test1<T, M-1, 0, M>();
+ test1<T, M-1, M-2, M>();
+ test1<T, M-1, M-1, M>();
+}
+
+int main()
+{
+ test<unsigned short>();
+ test<unsigned int>();
+ test<unsigned long>();
+ test<unsigned long long>();
+}
diff --git a/test/std/numerics/rand/rand.eng/rand.eng.lcong/ctor_result_type.pass.cpp b/test/std/numerics/rand/rand.eng/rand.eng.lcong/ctor_result_type.pass.cpp
new file mode 100644
index 000000000000..311b7cd8f9b9
--- /dev/null
+++ b/test/std/numerics/rand/rand.eng/rand.eng.lcong/ctor_result_type.pass.cpp
@@ -0,0 +1,154 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template <class UIntType, UIntType a, UIntType c, UIntType m>
+// class linear_congruential_engine;
+
+// explicit linear_congruential_engine(result_type s = default_seed);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+template <class T>
+void
+test1()
+{
+ // c % m != 0 && s % m != 0
+ {
+ typedef std::linear_congruential_engine<T, 2, 3, 7> E;
+ E e(5);
+ std::ostringstream os;
+ os << e;
+ assert(os.str() == "5");
+ }
+ {
+ typedef std::linear_congruential_engine<T, 2, 3, 0> E;
+ E e(5);
+ std::ostringstream os;
+ os << e;
+ assert(os.str() == "5");
+ }
+ {
+ typedef std::linear_congruential_engine<T, 2, 3, 4> E;
+ E e(5);
+ std::ostringstream os;
+ os << e;
+ assert(os.str() == "1");
+ }
+}
+
+template <class T>
+void
+test2()
+{
+ // c % m != 0 && s % m == 0
+ {
+ typedef std::linear_congruential_engine<T, 2, 3, 7> E;
+ E e(7);
+ std::ostringstream os;
+ os << e;
+ assert(os.str() == "0");
+ }
+ {
+ typedef std::linear_congruential_engine<T, 2, 3, 0> E;
+ E e(0);
+ std::ostringstream os;
+ os << e;
+ assert(os.str() == "0");
+ }
+ {
+ typedef std::linear_congruential_engine<T, 2, 3, 4> E;
+ E e(4);
+ std::ostringstream os;
+ os << e;
+ assert(os.str() == "0");
+ }
+}
+
+template <class T>
+void
+test3()
+{
+ // c % m == 0 && s % m != 0
+ {
+ typedef std::linear_congruential_engine<T, 2, 0, 7> E;
+ E e(3);
+ std::ostringstream os;
+ os << e;
+ assert(os.str() == "3");
+ }
+ {
+ typedef std::linear_congruential_engine<T, 2, 0, 0> E;
+ E e(5);
+ std::ostringstream os;
+ os << e;
+ assert(os.str() == "5");
+ }
+ {
+ typedef std::linear_congruential_engine<T, 2, 0, 4> E;
+ E e(7);
+ std::ostringstream os;
+ os << e;
+ assert(os.str() == "3");
+ }
+}
+
+template <class T>
+void
+test4()
+{
+ // c % m == 0 && s % m == 0
+ {
+ typedef std::linear_congruential_engine<T, 2, 0, 7> E;
+ E e(7);
+ std::ostringstream os;
+ os << e;
+ assert(os.str() == "1");
+ }
+ {
+ typedef std::linear_congruential_engine<T, 2, 0, 0> E;
+ E e(0);
+ std::ostringstream os;
+ os << e;
+ assert(os.str() == "1");
+ }
+ {
+ typedef std::linear_congruential_engine<T, 2, 0, 4> E;
+ E e(8);
+ std::ostringstream os;
+ os << e;
+ assert(os.str() == "1");
+ }
+}
+
+int main()
+{
+ test1<unsigned short>();
+ test1<unsigned int>();
+ test1<unsigned long>();
+ test1<unsigned long long>();
+
+ test2<unsigned short>();
+ test2<unsigned int>();
+ test2<unsigned long>();
+ test2<unsigned long long>();
+
+ test3<unsigned short>();
+ test3<unsigned int>();
+ test3<unsigned long>();
+ test3<unsigned long long>();
+
+ test4<unsigned short>();
+ test4<unsigned int>();
+ test4<unsigned long>();
+ test4<unsigned long long>();
+}
diff --git a/test/std/numerics/rand/rand.eng/rand.eng.lcong/ctor_sseq.pass.cpp b/test/std/numerics/rand/rand.eng/rand.eng.lcong/ctor_sseq.pass.cpp
new file mode 100644
index 000000000000..db7118f4a631
--- /dev/null
+++ b/test/std/numerics/rand/rand.eng/rand.eng.lcong/ctor_sseq.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template <class UIntType, UIntType a, UIntType c, UIntType m>
+// class linear_congruential_engine;
+
+// template<class Sseq> explicit linear_congruential_engine(Sseq& q);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ unsigned a[] = {3, 5, 7};
+ std::seed_seq sseq(a, a+3);
+ std::linear_congruential_engine<unsigned, 5, 7, 11> e1(sseq);
+ std::linear_congruential_engine<unsigned, 5, 7, 11> e2(4);
+ assert(e1 == e2);
+ }
+}
diff --git a/test/std/numerics/rand/rand.eng/rand.eng.lcong/default.pass.cpp b/test/std/numerics/rand/rand.eng/rand.eng.lcong/default.pass.cpp
new file mode 100644
index 000000000000..6c4a7f434f12
--- /dev/null
+++ b/test/std/numerics/rand/rand.eng/rand.eng.lcong/default.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template <class UIntType, UIntType a, UIntType c, UIntType m>
+// class linear_congruential_engine;
+
+// linear_congruential_engine();
+
+#include <random>
+#include <cassert>
+
+template <class T, T a, T c, T m>
+void
+test1()
+{
+ typedef std::linear_congruential_engine<T, a, c, m> LCE;
+ typedef typename LCE::result_type result_type;
+ LCE e1;
+ LCE e2;
+ e2.seed();
+ assert(e1 == e2);
+}
+
+template <class T>
+void
+test()
+{
+ test1<T, 0, 0, 0>();
+ test1<T, 0, 1, 2>();
+ test1<T, 1, 1, 2>();
+ const T M(~0);
+ test1<T, 0, 0, M>();
+ test1<T, 0, M-2, M>();
+ test1<T, 0, M-1, M>();
+ test1<T, M-2, 0, M>();
+ test1<T, M-2, M-2, M>();
+ test1<T, M-2, M-1, M>();
+ test1<T, M-1, 0, M>();
+ test1<T, M-1, M-2, M>();
+ test1<T, M-1, M-1, M>();
+}
+
+int main()
+{
+ test<unsigned short>();
+ test<unsigned int>();
+ test<unsigned long>();
+ test<unsigned long long>();
+}
diff --git a/test/std/numerics/rand/rand.eng/rand.eng.lcong/discard.pass.cpp b/test/std/numerics/rand/rand.eng/rand.eng.lcong/discard.pass.cpp
new file mode 100644
index 000000000000..9e3372a8c2b4
--- /dev/null
+++ b/test/std/numerics/rand/rand.eng/rand.eng.lcong/discard.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template <class UIntType, UIntType a, UIntType c, UIntType m>
+// class linear_congruential_engine;
+
+// void discard(unsigned long long z);
+
+#include <random>
+#include <cassert>
+
+template <class T>
+void
+rand0()
+{
+ typedef std::linear_congruential_engine<T, 16807, 0, 2147483647> E;
+ E e;
+ e.discard(9999);
+ assert(e() == 1043618065);
+}
+
+template <class T>
+void
+rand()
+{
+ typedef std::linear_congruential_engine<T, 48271, 0, 2147483647> E;
+ E e;
+ e.discard(9999);
+ assert(e() == 399268537);
+}
+
+template <class T>
+void
+other()
+{
+ typedef std::linear_congruential_engine<T, 48271, 123465789, 2147483647> E;
+ E e1;
+ E e2;
+ assert(e1 == e2);
+ e1.discard(1);
+ assert(e1 != e2);
+ e2();
+ assert(e1 == e2);
+ e1.discard(3);
+ assert(e1 != e2);
+ e2();
+ e2();
+ e2();
+ assert(e1 == e2);
+}
+
+int main()
+{
+ rand0<unsigned int>();
+ rand0<unsigned long>();
+ rand0<unsigned long long>();
+
+ rand<unsigned int>();
+ rand<unsigned long>();
+ rand<unsigned long long>();
+
+ other<unsigned int>();
+ other<unsigned long>();
+ other<unsigned long long>();
+}
diff --git a/test/std/numerics/rand/rand.eng/rand.eng.lcong/eval.pass.cpp b/test/std/numerics/rand/rand.eng/rand.eng.lcong/eval.pass.cpp
new file mode 100644
index 000000000000..6d0057d598a8
--- /dev/null
+++ b/test/std/numerics/rand/rand.eng/rand.eng.lcong/eval.pass.cpp
@@ -0,0 +1,87 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template <class UIntType, UIntType a, UIntType c, UIntType m>
+// class linear_congruential_engine;
+
+// result_type operator()();
+
+#include <random>
+#include <cassert>
+
+template <class T>
+void
+randu()
+{
+ typedef std::linear_congruential_engine<T, 65539, 0, 2147483648u> E;
+ E e(1);
+ assert(e() == 65539);
+ assert(e() == 393225);
+ assert(e() == 1769499);
+ assert(e() == 7077969);
+ assert(e() == 26542323);
+ assert(e() == 95552217);
+ assert(e() == 334432395);
+ assert(e() == 1146624417);
+ assert(e() == 1722371299);
+ assert(e() == 14608041);
+ assert(e() == 1766175739);
+ assert(e() == 1875647473);
+}
+
+template <class T>
+void
+minstd()
+{
+ typedef std::linear_congruential_engine<T, 16807, 0, 2147483647> E;
+ E e(1);
+ assert(e() == 16807);
+ assert(e() == 282475249);
+ assert(e() == 1622650073);
+ assert(e() == 984943658);
+ assert(e() == 1144108930);
+ assert(e() == 470211272);
+ assert(e() == 101027544);
+ assert(e() == 1457850878);
+ assert(e() == 1458777923);
+ assert(e() == 2007237709);
+ assert(e() == 823564440);
+ assert(e() == 1115438165);
+}
+
+template <class T>
+void
+Haldir()
+{
+ typedef std::linear_congruential_engine<T, 16807, 78125, 2147483647> E;
+ E e(207560540);
+ assert(e() == 956631177);
+ assert(e() == 2037688522);
+ assert(e() == 1509348670);
+ assert(e() == 1546336451);
+ assert(e() == 429714088);
+ assert(e() == 217250280);
+}
+
+int main()
+{
+ randu<unsigned int>();
+ randu<unsigned long>();
+ randu<unsigned long long>();
+
+ minstd<unsigned int>();
+ minstd<unsigned long>();
+ minstd<unsigned long long>();
+
+ Haldir<unsigned int>();
+ Haldir<unsigned long>();
+ Haldir<unsigned long long>();
+}
diff --git a/test/std/numerics/rand/rand.eng/rand.eng.lcong/io.pass.cpp b/test/std/numerics/rand/rand.eng/rand.eng.lcong/io.pass.cpp
new file mode 100644
index 000000000000..28ebdf23d0cb
--- /dev/null
+++ b/test/std/numerics/rand/rand.eng/rand.eng.lcong/io.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template <class UIntType, UIntType a, UIntType c, UIntType m>
+// class linear_congruential_engine;
+
+// template <class charT, class traits,
+// class UIntType, UIntType a, UIntType c, UIntType m>
+// basic_ostream<charT, traits>&
+// operator<<(basic_ostream<charT, traits>& os,
+// const linear_congruential_engine<UIntType, a, c, m>& x);
+//
+// template <class charT, class traits,
+// class UIntType, UIntType a, UIntType c, UIntType m>
+// basic_istream<charT, traits>&
+// operator>>(basic_istream<charT, traits>& is,
+// linear_congruential_engine<UIntType, a, c, m>& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::linear_congruential_engine<unsigned, 48271, 0, 2147483647> E;
+ E e1;
+ e1.discard(100);
+ std::ostringstream os;
+ os << e1;
+ std::istringstream is(os.str());
+ E e2;
+ is >> e2;
+ assert(e1 == e2);
+ }
+}
diff --git a/test/std/numerics/rand/rand.eng/rand.eng.lcong/result_type.pass.cpp b/test/std/numerics/rand/rand.eng/rand.eng.lcong/result_type.pass.cpp
new file mode 100644
index 000000000000..d261f1d93ab1
--- /dev/null
+++ b/test/std/numerics/rand/rand.eng/rand.eng.lcong/result_type.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template <class UIntType, UIntType a, UIntType c, UIntType m>
+// class linear_congruential_engine
+// {
+// public:
+// // types
+// typedef UIntType result_type;
+
+#include <random>
+#include <type_traits>
+
+template <class T>
+void
+test()
+{
+ static_assert((std::is_same<
+ typename std::linear_congruential_engine<T, 0, 0, 0>::result_type,
+ T>::value), "");
+}
+
+int main()
+{
+ test<unsigned short>();
+ test<unsigned int>();
+ test<unsigned long>();
+ test<unsigned long long>();
+}
diff --git a/test/std/numerics/rand/rand.eng/rand.eng.lcong/seed_result_type.pass.cpp b/test/std/numerics/rand/rand.eng/rand.eng.lcong/seed_result_type.pass.cpp
new file mode 100644
index 000000000000..1afbe75efa58
--- /dev/null
+++ b/test/std/numerics/rand/rand.eng/rand.eng.lcong/seed_result_type.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template <class UIntType, UIntType a, UIntType c, UIntType m>
+// class linear_congruential_engine;
+
+// void seed(result_type s = default_seed);
+
+#include <random>
+#include <cassert>
+
+template <class T>
+void
+test1()
+{
+ for (int s = 0; s < 20; ++s)
+ {
+ typedef std::linear_congruential_engine<T, 2, 3, 7> E;
+ E e1(s);
+ E e2;
+ e2.seed(s);
+ assert(e1 == e2);
+ }
+}
+
+int main()
+{
+ test1<unsigned short>();
+ test1<unsigned int>();
+ test1<unsigned long>();
+ test1<unsigned long long>();
+}
diff --git a/test/std/numerics/rand/rand.eng/rand.eng.lcong/seed_sseq.pass.cpp b/test/std/numerics/rand/rand.eng/rand.eng.lcong/seed_sseq.pass.cpp
new file mode 100644
index 000000000000..ca2793c7f9a7
--- /dev/null
+++ b/test/std/numerics/rand/rand.eng/rand.eng.lcong/seed_sseq.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template <class UIntType, UIntType a, UIntType c, UIntType m>
+// class linear_congruential_engine;
+
+// template<class Sseq> void seed(Sseq& q);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ unsigned a[] = {3, 5, 7};
+ std::seed_seq sseq(a, a+3);
+ std::linear_congruential_engine<unsigned, 5, 7, 11> e1;
+ std::linear_congruential_engine<unsigned, 5, 7, 11> e2(4);
+ assert(e1 != e2);
+ e1.seed(sseq);
+ assert(e1 == e2);
+ }
+ {
+ unsigned a[] = {3, 5, 7, 9, 11};
+ std::seed_seq sseq(a, a+5);
+ typedef std::linear_congruential_engine<unsigned long long, 1, 1, 0x200000001ULL> E;
+ E e1(4309005589);
+ E e2(sseq);
+ assert(e1 == e2);
+ }
+}
diff --git a/test/std/numerics/rand/rand.eng/rand.eng.lcong/values.pass.cpp b/test/std/numerics/rand/rand.eng/rand.eng.lcong/values.pass.cpp
new file mode 100644
index 000000000000..857a478a5579
--- /dev/null
+++ b/test/std/numerics/rand/rand.eng/rand.eng.lcong/values.pass.cpp
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template <class UIntType, UIntType a, UIntType c, UIntType m>
+// class linear_congruential_engine
+// {
+// public:
+// engine characteristics
+// static constexpr result_type multiplier = a;
+// static constexpr result_type increment = c;
+// static constexpr result_type modulus = m;
+// static constexpr result_type min() { return c == 0u ? 1u: 0u;}
+// static constexpr result_type max() { return m - 1u;}
+// static constexpr result_type default_seed = 1u;
+
+#include <random>
+#include <type_traits>
+#include <cassert>
+
+template <class _Tp>
+void where(const _Tp &) {}
+
+template <class T, T a, T c, T m>
+void
+test1()
+{
+ typedef std::linear_congruential_engine<T, a, c, m> LCE;
+ typedef typename LCE::result_type result_type;
+ static_assert((LCE::multiplier == a), "");
+ static_assert((LCE::increment == c), "");
+ static_assert((LCE::modulus == m), "");
+ /*static_*/assert((LCE::min() == (c == 0u ? 1u: 0u))/*, ""*/);
+ /*static_*/assert((LCE::max() == result_type(m - 1u))/*, ""*/);
+ static_assert((LCE::default_seed == 1), "");
+ where(LCE::multiplier);
+ where(LCE::increment);
+ where(LCE::modulus);
+ where(LCE::default_seed);
+}
+
+template <class T>
+void
+test()
+{
+ test1<T, 0, 0, 0>();
+ test1<T, 0, 1, 2>();
+ test1<T, 1, 1, 2>();
+ const T M(~0);
+ test1<T, 0, 0, M>();
+ test1<T, 0, M-2, M>();
+ test1<T, 0, M-1, M>();
+ test1<T, M-2, 0, M>();
+ test1<T, M-2, M-2, M>();
+ test1<T, M-2, M-1, M>();
+ test1<T, M-1, 0, M>();
+ test1<T, M-1, M-2, M>();
+ test1<T, M-1, M-1, M>();
+}
+
+int main()
+{
+ test<unsigned short>();
+ test<unsigned int>();
+ test<unsigned long>();
+ test<unsigned long long>();
+}
diff --git a/test/std/numerics/rand/rand.eng/rand.eng.mers/assign.pass.cpp b/test/std/numerics/rand/rand.eng/rand.eng.mers/assign.pass.cpp
new file mode 100644
index 000000000000..fda5b88de26e
--- /dev/null
+++ b/test/std/numerics/rand/rand.eng/rand.eng.mers/assign.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template <class UIntType, size_t w, size_t n, size_t m, size_t r,
+// UIntType a, size_t u, UIntType d, size_t s,
+// UIntType b, size_t t, UIntType c, size_t l, UIntType f>
+// class mersenne_twister_engine;
+
+// mersenne_twister_engine& operator=(const mersenne_twister_engine&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::mt19937 E;
+ E e1(2);
+ e1();
+ E e2(5);
+ e2 = e1;
+ assert(e1 == e2);
+ assert(e1() == e2());
+ E::result_type k = e1();
+ assert(e1 != e2);
+ assert(e2() == k);
+ assert(e1 == e2);
+}
+
+void
+test2()
+{
+ typedef std::mt19937_64 E;
+ E e1(3);
+ e1();
+ E e2(5);
+ e2 = e1;
+ assert(e1 == e2);
+ assert(e1() == e2());
+ E::result_type k = e1();
+ assert(e1 != e2);
+ assert(e2() == k);
+ assert(e1 == e2);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
diff --git a/test/std/numerics/rand/rand.eng/rand.eng.mers/copy.pass.cpp b/test/std/numerics/rand/rand.eng/rand.eng.mers/copy.pass.cpp
new file mode 100644
index 000000000000..57c015ccce1d
--- /dev/null
+++ b/test/std/numerics/rand/rand.eng/rand.eng.mers/copy.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template <class UIntType, size_t w, size_t n, size_t m, size_t r,
+// UIntType a, size_t u, UIntType d, size_t s,
+// UIntType b, size_t t, UIntType c, size_t l, UIntType f>
+// class mersenne_twister_engine;
+
+// mersenne_twister_engine(const mersenne_twister_engine&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::mt19937 E;
+ E e1;
+ e1();
+ E e2 = e1;
+ assert(e1 == e2);
+ assert(e1() == e2());
+ E::result_type k = e1();
+ assert(e1 != e2);
+ assert(e2() == k);
+ assert(e1 == e2);
+}
+
+void
+test2()
+{
+ typedef std::mt19937_64 E;
+ E e1;
+ e1();
+ E e2(e1);
+ assert(e1 == e2);
+ assert(e1() == e2());
+ E::result_type k = e1();
+ assert(e1 != e2);
+ assert(e2() == k);
+ assert(e1 == e2);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
diff --git a/test/std/numerics/rand/rand.eng/rand.eng.mers/ctor_result_type.pass.cpp b/test/std/numerics/rand/rand.eng/rand.eng.mers/ctor_result_type.pass.cpp
new file mode 100644
index 000000000000..6920aaca558c
--- /dev/null
+++ b/test/std/numerics/rand/rand.eng/rand.eng.mers/ctor_result_type.pass.cpp
@@ -0,0 +1,245 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template <class UIntType, size_t w, size_t n, size_t m, size_t r,
+// UIntType a, size_t u, UIntType d, size_t s,
+// UIntType b, size_t t, UIntType c, size_t l, UIntType f>
+// class mersenne_twister_engine;
+
+// explicit mersenne_twister_engine(result_type s = default_seed);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+void
+test1()
+{
+ const char* a = "0 1 1812433255 1900727105 1208447044 2481403966 4042607538 337614300 "
+ "3232553940 1018809052 3202401494 1775180719 3192392114 594215549 184016991 "
+ "829906058 610491522 3879932251 3139825610 297902587 4075895579 2943625357 "
+ "3530655617 1423771745 2135928312 2891506774 1066338622 135451537 933040465 "
+ "2759011858 2273819758 3545703099 2516396728 1272276355 3172048492 "
+ "3267256201 2332199830 1975469449 392443598 1132453229 2900699076 "
+ "1998300999 3847713992 512669506 1227792182 1629110240 112303347 2142631694 "
+ "3647635483 1715036585 2508091258 1355887243 1884998310 3906360088 "
+ "952450269 3647883368 3962623343 3077504981 2023096077 3791588343 "
+ "3937487744 3455116780 1218485897 1374508007 2815569918 1367263917 "
+ "472908318 2263147545 1461547499 4126813079 2383504810 64750479 2963140275 "
+ "1709368606 4143643781 835933993 1881494649 674663333 2076403047 858036109 "
+ "1667579889 1706666497 607785554 1995775149 1941986352 3448871082 "
+ "2109910019 1474883361 1623095288 1831376534 2612738285 81681830 2204289242 "
+ "1365038485 251164610 4268495337 1805601714 1262528768 1442526919 "
+ "1675006593 965627108 646339161 499795587 840887574 380522518 3023789847 "
+ "1457635507 1947093157 2600365344 2729853143 1550618999 1390905853 "
+ "3021294812 882647559 838872117 1663880796 4222103589 2754172275 3844026123 "
+ "3199260319 4176064873 3591027019 2690294242 2978135515 3172796441 "
+ "3263669796 1451257057 1427035359 4174826006 2171992010 1537002090 "
+ "3122405306 4162452508 3271954368 3794310005 3240514581 1270412086 "
+ "3030475836 2281945856 2644171349 3109139423 4253563838 1289926431 "
+ "1396919653 733220100 2753316645 1196225013 3699575255 3569440056 "
+ "2675979228 2624079148 3463113149 863430286 623703199 2113837653 2656425919 "
+ "175981357 4271478366 4238022735 1665483419 86880610 2963435083 1830392943 "
+ "847801865 3237296945 332143967 3973606945 2671879697 2236330279 2360127810 "
+ "3283955434 203240344 4048139172 13189264 2263058814 247241371 1566765783 "
+ "3084408095 3719371299 1958375251 1985924622 1712739232 1861691451 "
+ "2644502937 2337807839 784993770 2962208780 2190810177 1523122731 "
+ "714888527 578678761 3698481324 1801168075 534650483 3390213921 3923356461 "
+ "3586009066 2059432114 52511333 1969897376 3630122061 524661135 3513619765 "
+ "563070233 501359785 477489274 658768624 938973567 1548584683 1345287459 "
+ "2488691004 3441144905 3849305094 2430000078 855172178 614463281 2092744749 "
+ "176381493 1655802051 2273888101 2474494847 3471978030 2138918303 575352373 "
+ "1658230985 1675972553 2946663114 915579339 284981499 53939948 3022598146 "
+ "1861218535 3403620774 4203516930 2360471119 3134536268 1383448498 "
+ "1307602316 3847663247 3027225131 3597251613 3186237127 725127595 "
+ "1928526954 1843386923 3560410503 54688266 1791983849 2519860352 4256389699 "
+ "2328812602 486464275 3578698363 301279829 1303654791 4181868765 971794070 "
+ "1933885487 3996807464 2144053754 4079903755 3775774765 3481760044 "
+ "1212862354 1067356423 3764189132 1609862325 2209601551 2565747501 "
+ "161962392 4045451782 2605574664 2520953090 3490240017 1082791980 44474324 "
+ "101811128 4268650669 4171338684 772375154 3920460306 2319139534 599033750 "
+ "2950874441 3373922995 1496848525 4095253594 1271943484 1498723121 "
+ "3097453329 3698082465 281869581 3148270661 3591477288 747441437 2809508504 "
+ "3896107498 303747862 2368081624 1844217645 886825352 287949781 1444561207 "
+ "2512101757 2062331723 741720931 1383797313 3876746355 2041045348 "
+ "2627599118 1124169970 200524822 3484820454 55883666 1135054804 669498692 "
+ "2677215504 3097911127 1509628615 617580381 2229022193 85601568 3243896546 "
+ "3715672328 912168347 2359163500 1180347564 4243175048 2092067103 880183327 "
+ "4000664709 2045044777 3500474644 1515175520 1862207123 186628841 "
+ "3337252925 708933575 4015964629 3136815297 3314919747 2891909013 "
+ "3316567785 3944275369 3608506218 2884839110 3054055598 2707439927 "
+ "1381111877 3275487281 4292456216 2639563270 3327301876 3576924628 "
+ "721056309 2002808140 748967365 52380958 2200261692 763456477 1708381337 "
+ "2038446433 2682979402 1526413779 2211263302 3879771969 75966584 3645059271 "
+ "2985763524 4085690255 82390958 1883631385 1647521260 1598026998 3038041577 "
+ "2501913134 3279302868 1738888524 805035483 756399074 3863810982 1097797270 "
+ "1505792529 898904527 583561003 717152376 3333867738 1099456544 1663473545 "
+ "1242141229 3828627682 1966201676 1713552361 3852160017 1584965284 21695908 "
+ "1013262144 145341901 3995441263 3462066219 2239637848 1214086163 "
+ "2428868268 1650037305 1545513388 1621198806 4232947817 1823092073 "
+ "256414624 1745018809 1357102386 2055139770 3280958307 2482431613 "
+ "1664870585 859130423 4097751123 3079768369 2470211009 2984880786 "
+ "2808568948 2877071923 1984903163 302768457 1866396789 869566317 3746415787 "
+ "4169433075 3025005404 3980733379 3539207278 3953071536 876960847 "
+ "2548872156 800507464 1865466907 1273317878 3754712872 1757188269 "
+ "3229950355 3731640200 2283390608 2204990292 411873449 447423849 1852437802 "
+ "472825525 3044219944 2913114194 1859709265 4053786194 574820536 2104496732 "
+ "865469814 2438352724 4208743605 4215067542 1364015250 4139974345 "
+ "3838747005 1818502786 2914274940 1402365828 1751123528 2302578077 "
+ "2463168652 1968705496 1730700144 3023943273 1139096844 2658667767 "
+ "2063547264 705791165 1444775274 2415454225 1575664730 921044163 648101324 "
+ "1212387162 4191962054 1787702169 1888718041 1518218010 3398792842 "
+ "4079359729 149721439 750400353 2661036076 3802767886 520152586 951852508 "
+ "2939585975 1375969109 385733137 3523607459 1902438415 4250996086 "
+ "2712727066 484493674 3932107461 1428488210 1764242548 3424801055 "
+ "4004904451 2226862072 2393366939 3609584727 3614444319 317349896 "
+ "3826527525 204023804 981902443 3356042039 3051207045 1869902661 561831895 "
+ "3706675415 1527687593 1227610446 2596341042 3191717368 3269246891 "
+ "557877074 4062070629 3052520266 3772487029 400039836 3195205275 4085394797 "
+ "1655557239 1345770144 2864727192 449281238 73189507 528365765 2727400656 "
+ "247880434 2408277395 777039183 2210179398 1088433648 2124356402 1555630141 "
+ "604790219 195012151 3312518356 923728373 3999251660 3313059535 3478133921 "
+ "3395026960 383464614 3425869222 2446885186 4032184426 157195416 3158909476 "
+ "1663750443 2046427584 1658453076 1784483001 3146546889 1238739785 "
+ "2297306523 3472330897 2953326031 2421672215 1221694592 1588568605 "
+ "2546987845 3375168573 2137961649 3056565164 330165219 235900365 1000384800 "
+ "2697255904 579122283 3050664825 73426122 1232986102 2940571064 3076486824 "
+ "1708182873 2796363264 292154131 4280019913 1102652157 1185393592 "
+ "1494991690 4270076389 2384840717 425785147 2385321880 317514772 3926962743 "
+ "392176856 3465421709 1878853468 122662664 2958252160 1858961315 2244939588 "
+ "2361884409 2860936803 683833250 3291277128 1686857206 1112632275 "
+ "1200680507 3342928196 2677058150 939442136 3407104669 2906783932 "
+ "3668048733 2030009470 1910839172 1234925283 3575831445 123595418 "
+ "2362440495 3048484911 1796872496";
+ std::mt19937 e1(0);
+ std::ostringstream os;
+ os << e1;
+ assert(os.str() == a);
+}
+
+void
+test2()
+{
+ const char* a = "0 1 6364136223846793007 13885033948157127961 "
+ "15324573939901584278 12737837167382305846 15195339788985155882 "
+ "6554113247712070460 17235932740818599105 13007415075556305955 "
+ "6585479514541334743 8274505865835507625 1718218088692873364 "
+ "10390651247454232081 12911994993614796389 3986900029987203370 "
+ "6673827651897561714 4426752746717694792 7419158062930293690 "
+ "5800047417539173618 15710773105226458059 16164512590413496893 "
+ "3438015953120274172 3483801391287623267 293704481016263807 "
+ "11580856846363212652 3489109114147636336 3391036861618673611 "
+ "8265793309278544843 7557898467821912223 11008748280761875940 "
+ "15929443707841919885 8545695347411085846 10810459396490399532 "
+ "12233244910455127352 15556950738631379285 16711543556686614082 "
+ "12362193084052127890 16520645558585805174 5163125267185202360 "
+ "405552980610370477 17567412011316060306 18195950784827697319 "
+ "7893142112162906367 11294475722810961618 7284845498332539581 "
+ "8406882439401998138 4375387785957411470 9627875716250684710 "
+ "8860968026642934661 9743109216691708518 152611520104818631 "
+ "5897430410700879663 5351672954305365323 16325991383734641720 "
+ "9695181037355459478 15420132328343498044 17772146581546890572 "
+ "12095930435311226909 3066005052193896110 11579395203346116306 "
+ "9168946227698330317 18318927644793076250 16096433325093805476 "
+ "14945900876820434843 16826760579960858105 17664119339058295604 "
+ "17844797344364136942 1071414400549507565 16688779616725465582 "
+ "3684635020921274863 12774052823168116810 17270284502989966576 "
+ "1081012692742984704 4377021575203177546 18341292555997099853 "
+ "13297939683513494274 15065725504474304333 10796297883750572804 "
+ "15233335271871291997 8767977593699151062 3360856014170688284 "
+ "7828232912764786750 15167717223619970150 9622174963375022357 "
+ "18262792478991268448 1196631425707106493 5368342740538672272 "
+ "10381091599850241237 12108437846306626340 6150860188928778248 "
+ "3342980288459577584 12715439159457051276 17996971042887275859 "
+ "9749679821487730542 17763727344608586331 16024467606290078168 "
+ "7763401887585513696 4448278918811662063 16947956613780322662 "
+ "15144807360840708645 3878082612940188435 10709780449699561405 "
+ "1649555943517500922 3206645931693769562 12562913950237146427 "
+ "237213339742767727 12987800257476421358 1653669854585203688 "
+ "3485900643226898485 13961759114404652223 5243794832751327611 "
+ "10337687908642742498 16946139522050041809 16716562961992396380 "
+ "4275124606042261542 4055100795824867618 6424268654905981295 "
+ "3424516503413156556 2670380025813203539 10750762735193959951 "
+ "8790031149370411970 4021216986392972993 12076090355041998696 "
+ "14407920322903159838 10653597737935867030 15483225617438352002 "
+ "2497775263858626604 12295882369431088188 14256043521530136935 "
+ "2687322778627883798 3419797801078863201 8786888481486602641 "
+ "445698423634900693 9597067954623467255 7101345576557603992 "
+ "1498579197046783597 10403325187679734962 2464586980321053562 "
+ "2022012026329844477 10802281218030350853 6628929099856200904 "
+ "6828177972863192803 8589868113309334601 5245595233272009016 "
+ "5335692004673212054 4515133017699498525 15966447436053813932 "
+ "15199779177078162007 4190689609934804313 13003438276435994683 "
+ "8406046831313066396 10564320513686955057 12668913223662201488 "
+ "13130110932487580228 1030848205404711145 17684061609212954769 "
+ "12942207438298787911 10731611242140874687 5165052527778107352 "
+ "16323046249518133445 17119162873327029615 5754858052433703070 "
+ "3864761150247579030 9945988334920003074 11409854727071782565 "
+ "5000838138362434817 15526574143469400487 18094554078711846524 "
+ "5576294272011007484 3478525338408894755 11392694223389544658 "
+ "4692963068671452476 4459301637730340710 9699395817392066460 "
+ "14644636990626292085 18065377773424192622 5217202490849387226 "
+ "16175595974171756081 2109372019589047677 1624752883142646445 "
+ "13462209973053735966 12082930933973802402 1568864426788967895 "
+ "17047994306870001795 10556833209957537593 955604103878351641 "
+ "9062985603395234592 9757612676622840969 1767246562613391916 "
+ "9752598821733361274 7499745701633625047 7824811626141302622 "
+ "15819064077972391284 5660565551854829485 17645390577243129343 "
+ "7343780801046581776 2233358068547689666 8716657172695403744 "
+ "9129027798969787220 334709674395230649 2063182499026924878 "
+ "13089071159640936832 1765917316143960741 17552378408917656269 "
+ "3917018959478722819 15626740210483166037 1645962609209923821 "
+ "12277169606472643961 14545894350924442736 11485249378718653961 "
+ "9205208816702766530 10967561305613932827 3105992977398681914 "
+ "2125140299311648264 11619505070220308543 5030167448920096401 "
+ "4248170446421798953 16184577688118775567 9240607582885304823 "
+ "11838996733938359277 415426114101983968 14340734742548675134 "
+ "4124085748228276376 17686494750190224280 9472996569628985376 "
+ "1207013222233148636 3031046462562068367 45068538181330439 "
+ "8678647417835301152 10693327126492781235 3058899219097846020 "
+ "18377730418355022492 10269941972656742364 15986476992758938864 "
+ "14575856764093007010 14749682846448398393 1042926396621439263 "
+ "12184905641567868001 3518848236485931862 6718580865438347534 "
+ "6319395993260741012 2855168874111910691 2482146419106261786 "
+ "17290238774162848390 8071397865265268054 15873003794708011585 "
+ "14422764926380465297 14140979091525022882 3573480287238168646 "
+ "1525896111244666696 7537826952717918371 10482908122538761078 "
+ "17003233041653857 9473838740924911883 8438240966750123668 "
+ "10697754962581554225 15048771265786776312 9067877678399943713 "
+ "3399555692325948067 6150260207049997483 7165140289246675175 "
+ "14816202987105583988 4753550992948864498 10549400354582510015 "
+ "13212062554023586370 1585477630313819722 476999696494664205 "
+ "3208739183359199317 16011681780347380478 8149150693959772807 "
+ "803412833228911773 2360961455092949929 1517204230639934662 "
+ "13863717544358808032 16792122738584967930 12742474971940259289 "
+ "1859755681395355028 1540431035241590810 3883807554140904361 "
+ "16189061625447625933 12376367376041900879 8006563585771266211 "
+ "2682617767291542421 8593924529704142157 9070391845133329273 "
+ "3557484410564396342 9301398051805853085 12632514768298643219 "
+ "227653509634201118 7247795074312488552 4939136716843120792 "
+ "6533591052147596041 1308401457054431629 17488144120120152559 "
+ "14075631579093810083 4015705597302725704 6833920126528811473 "
+ "5095302940809114298 8312250184258072842 15770605014574863643 "
+ "14091690436120485477 15763282477731738396 16394237160547425954 "
+ "5066318118328746621 13140493775100916989 6371148952471982853 "
+ "15150289760867914983 4931341382074091848 12635920082410445322 "
+ "8498109357807439006 14836776625250834986";
+ std::mt19937_64 e1(0);
+ std::ostringstream os;
+ os << e1;
+ assert(os.str() == a);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
diff --git a/test/std/numerics/rand/rand.eng/rand.eng.mers/ctor_sseq.pass.cpp b/test/std/numerics/rand/rand.eng/rand.eng.mers/ctor_sseq.pass.cpp
new file mode 100644
index 000000000000..45bc493afb58
--- /dev/null
+++ b/test/std/numerics/rand/rand.eng/rand.eng.mers/ctor_sseq.pass.cpp
@@ -0,0 +1,309 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template <class UIntType, size_t w, size_t n, size_t m, size_t r,
+// UIntType a, size_t u, UIntType d, size_t s,
+// UIntType b, size_t t, UIntType c, size_t l, UIntType f>
+// class mersenne_twister_engine;
+
+// template<class Sseq> explicit mersenne_twister_engine(Sseq& q);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+void
+test1()
+{
+ const char* a = "358595400 4166558815 2016177162 3414480257 "
+ "4027494649 3722317195 1190532340 3212207148 "
+ "3537847251 389019999 1098708832 3277907415 "
+ "1946784350 3608286140 2091419822 2227407035 "
+ "2229110723 1825348377 1276269279 314337202 "
+ "3182935337 1313150029 3118776508 3707918501 "
+ "1900972958 4054820954 3973178248 906260237 "
+ "1403942218 3139931556 2807126524 3940936448 "
+ "1316345796 631296613 2268418920 2914000794 "
+ "3760588399 3226216036 880155129 4183611084 "
+ "211541083 3755352858 1331383234 3036493096 "
+ "937478630 2092170412 777784402 93392729 "
+ "3644029210 1681392086 2427001226 3143870332 "
+ "3703581502 2017505388 1706274541 1049329728 "
+ "2452031492 3437261233 2581204087 1700889875 "
+ "1652573881 2127047692 3778506964 1960741508 "
+ "2739602360 3395905609 2123355622 3041272975 "
+ "784200748 3558951522 1002787860 4063320888 "
+ "1587315560 4042698976 659183308 3082256417 "
+ "2808969567 2361418535 3468698782 750700970 "
+ "2991209851 3581521382 962022878 2518967363 "
+ "1476525873 3865977235 2128790058 2380326689 "
+ "1396773405 312559410 1370621899 1154499924 "
+ "2963101919 2182689761 2071851902 1661288848 "
+ "2411351341 1362764020 1289894483 1951662807 "
+ "701821506 552267185 2356648449 3949188503 "
+ "1748307081 87795201 3718396254 4112205936 "
+ "2819888864 73923733 2800033151 839258139 "
+ "3801779069 3105962436 2111266436 1772784466 "
+ "3692264298 4148810953 3147390749 3537518553 "
+ "1695044978 1430225842 1252346204 3465285434 "
+ "3970017763 2920658411 2805151132 290569815 "
+ "3802301355 1493420394 1943029276 1667143611 "
+ "1049665988 1710824905 220168517 3997946231 "
+ "1014582791 4244598752 1147604069 2533886627 "
+ "598679964 761521020 431779255 3745982038 "
+ "768658283 3598262505 1765664789 279538641 "
+ "715144305 2371628432 2655860083 1759010423 "
+ "3568452003 1910107098 2801429529 3924547532 "
+ "3862672436 3933725740 1764550618 130893617 "
+ "1460692387 4135312761 2075529299 2880227367 "
+ "944557368 4166665482 2627749235 3732013815 "
+ "1595900818 1553312393 3529311831 3531462424 "
+ "2431328342 4075369692 1609967709 3704537555 "
+ "2067297464 397140475 920618678 2840795964 "
+ "4202512837 1286017648 7035910 1057207826 "
+ "2325188262 191593698 3697383848 3029712831 "
+ "2073681914 163454681 1329637200 290077398 "
+ "287239431 4205081522 1233889024 167173087 "
+ "3267660257 3406068803 2382354609 1680046927 "
+ "125183503 3559536309 3208900974 2912148541 "
+ "2882879316 1937001086 2919729069 892928802 "
+ "4141691387 2507406586 855548593 3418647837 "
+ "4035646154 2410275591 248715645 3180757482 "
+ "1880770722 362912336 2964920095 2319904154 "
+ "1493655850 4240733030 1834485846 1696040454 "
+ "3329457927 1865824694 847759208 1587231623 "
+ "3757294772 1161601118 3630323833 3007722125 "
+ "3726418007 2124238171 1205345 172659797 "
+ "3040354211 885213338 1857049013 447922412 "
+ "719906299 1370059380 1922204800 3960090489 "
+ "1658822644 1529626863 1565927273 3537718771 "
+ "2733237258 2180221377 921910745 2144937687 "
+ "1727603895 1315635304 4023867791 2401834107 "
+ "808854185 2408824497 343935326 185237544 "
+ "746732759 2641236122 4283215329 743609415 "
+ "1134726665 3892851319 1302851263 3473445597 "
+ "1326817414 2702766508 1943179285 4025685468 "
+ "932896770 199392138 2787362875 3450501893 "
+ "3351567147 2461286528 2227605848 2993751114 "
+ "3988215720 1320573368 2866560199 4153194990 "
+ "3007120042 3260751955 3171763740 2111121243 "
+ "3962825228 102681859 3368179132 802089147 "
+ "4029273561 424939445 4178414761 2592125109 "
+ "1960801088 2967746406 310701990 2364200202 "
+ "1320507009 3474372480 784693947 2952246664 "
+ "1891935330 2048385105 3530082191 3238151038 "
+ "3293189141 1316053288 2087004409 740799958 "
+ "1187748554 3607767334 1190185990 1408429481 "
+ "657134359 221834425 3907725865 1068016389 "
+ "1402423875 2598612116 2046886300 2345022518 "
+ "1196081924 357783981 4013683598 463491626 "
+ "3269206482 3332444286 886491955 2257342866 "
+ "475911113 833576299 2893727564 2866985145 "
+ "1413365115 2995166393 1486060436 161205225 "
+ "3181728373 3056027137 2040371876 2182305146 "
+ "3028448628 2214316977 1266227021 876938740 "
+ "276477469 752158077 2182179045 1381698878 "
+ "3424557652 666674427 968327842 2534296575 "
+ "265105940 961112540 2641188117 2319139814 "
+ "1750453329 3450138343 678025317 1477566458 "
+ "3773796420 2933993832 3326042905 4084805260 "
+ "444182455 255333481 785163068 2321290820 "
+ "2893603234 3005520266 541104079 1383277090 "
+ "2770755666 3764627833 583371929 2864949033 "
+ "1487681116 1811788361 240329486 3094213377 "
+ "958509875 2564379085 1636995945 2070894127 "
+ "2139004232 1747850055 3841512327 3325011872 "
+ "1161622604 639182193 3533652535 4022667522 "
+ "761048999 3337743670 254221568 2784956233 "
+ "2990252814 4207922787 275707208 261819597 "
+ "2071467265 4034945770 1999813410 3038921100 "
+ "2200194573 1328217451 2440612380 3862293692 "
+ "2733976812 2750523058 2920082515 3809044908 "
+ "4285231753 3131963297 3481602724 1396460739 "
+ "2011767965 2481047764 2958452120 3044188618 "
+ "2217236658 3448605566 757716104 1818279145 "
+ "2641228144 1312649639 1194087684 3845229729 "
+ "1747658356 874418803 1956637337 268670179 "
+ "2083040240 2577671381 3375334655 2587828868 "
+ "1383012799 3583445685 2594576715 3282337104 "
+ "4257972751 3440488071 3129180313 1830891395 "
+ "1594931092 2680778339 3984026324 1102770400 "
+ "2315820258 1263467048 1133254110 2400676748 "
+ "2251795328 1036154092 3313541051 2277356560 "
+ "1477696003 1417117088 3968537402 1404882202 "
+ "2011058180 4114080985 1727459502 4100235708 "
+ "2334509310 2829432554 377936301 1519324520 "
+ "3252826644 1193335837 1929125820 2165344238 "
+ "4160556243 223340988 670907625 1485396519 "
+ "936389509 3813712964 2706450987 3132506320 "
+ "875886515 557088991 2854916639 2955496008 "
+ "2881696287 265169077 3239923698 3649366121 "
+ "4072165960 1233904959 225406526 1767368993 "
+ "1894882500 2296582180 339255168 83200939 "
+ "2958376148 4100205346 1991250823 3806183082 "
+ "2691709980 2642354997 3024056146 1681065839 "
+ "3438299684 1638853652 362567001 2307868899 "
+ "988801086 1342833399 2303298376 1500039911 "
+ "765489391 4080464497 4155444368 980472018 "
+ "2026981853 3460406995 391970367 667377014 "
+ "4177754853 2657468948 3560690175 3030464357 "
+ "2948380657 1208800977 2316451404 4001932203 "
+ "1977856863 4265848271 3116200050 3037586215 "
+ "1335232764 930230766 1026089249 2482219415 "
+ "2613853154 1854543497 2909555107 3862874043 "
+ "2609355500 907364682 383900687 358164223 "
+ "232347546 2536276737 3118482806 1254103998 "
+ "2357334077 1204777304 1996643329 4046232717 "
+ "2570520290 3173323380 1201411457 2361883023 "
+ "806087062 2984143714 2355127569 864220085 "
+ "1787696713 1182652984 4200065581 100722519 "
+ "2380458669 2429592313 2618338302 1236529564 "
+ "1747130196 3711661325 1114068102 510380433 "
+ "93703089 2277774664 3220741441 1577998569 "
+ "2816701900 4206763045 2495239107 4080390459 "
+ "1307072677 20360728 1468385549 96049834 "
+ "3630657447 2809517346 3396111678 3043831060 "
+ "673178359 4256729562 1755211210 1969834535 "
+ "498315110 3717726302 1544859987 2239930949 "
+ "1595372585 294525219 3961637067 3591840665 "
+ "3324896933 2300077772 721255886 4197934760 "
+ "1468866696 2184812884 628246683 3385113037 "
+ "3041166140 3948531843 1176600829 228286131 "
+ "2447397608 712235937 3332826819 2676980703 "
+ "4019468871 1952389952 1202638254 3625447051";
+ unsigned as[] = {3, 5, 7};
+ std::seed_seq sseq(as, as+3);
+ std::mt19937 e1(sseq);
+ std::ostringstream os;
+ os << e1;
+ assert(os.str() == a);
+}
+
+void
+test2()
+{
+ const char* a = "17895233847644109640 14665081038668852234 15987230621890949369 "
+ "13796324649827964148 1670828176732799955 14078505147839608672 "
+ "15497470967856861790 9566640372296747182 7839811585250789315 "
+ "1350068003782415071 5639936432479386921 15925388701147119804 "
+ "17415323390466493342 3892358083553387400 13485903346102334794 "
+ "16926193162581531132 2711398308226914244 12515538113016451944 "
+ "13856492368211347055 17968472785843263993 16129117710261673051 "
+ "13041638543181171650 8985803498136324582 401118717516975186 "
+ "7221524024767248666 13502820261231663498 8665119664667372350 "
+ "4506836866186850029 14762924585995667460 7305266389803732087 "
+ "9135600275824854713 8421320656548229332 14585303533697565624 "
+ "13062167967956981222 15285580395823625260 17451830328116466708 "
+ "17363259891080004456 13238190509560321740 10142215382802200927 "
+ "3224236118694175902 15382517208605932923 10818882444738383326 "
+ "16604245792882032433 10223425285179753002 1342432445403828765 "
+ "4958539418185107403 9374581143772158175 7135181273441366910 "
+ "5853026900476841261 8382327930174454355 2371969498930803266 "
+ "16961635468480846337 377077518789053577 17661790013255465310 "
+ "317500018453124832 3604586262706855295 13340007089026272125 "
+ "7614051306438090372 17819007364113857386 15193526497275633437 "
+ "6142773218979108210 14883287611587512668 12544132362002344419 "
+ "1247987855434921372 6414191755211735979 7160327288923375132 "
+ "7347937017206972868 17171048313531629893 18230412825496997383 "
+ "10882960195884354661 3270707876715241884 16088870345045208503 "
+ "15454419782166694763 1200609322828949525 10186066554418904177 "
+ "7554892242763986291 8203847521335919011 16855803304338943001 "
+ "16895223408596071476 562183806034700250 17761033068687156643 "
+ "12370482348384718931 17895691979506634040 16028877286272943475 "
+ "6671425930002400146 15167515621662197335 17503579548680921174 "
+ "15910867647138768989 1705705354110203064 12201125760909412022 "
+ "5523403744441352645 4540673037752294406 822888669354888870 "
+ "13012517529113958824 702032511346794490 1245872939048413008 "
+ "18060687614291143943 718002942670251776 14628954120078526945 "
+ "7215746609592654001 15288092036204733967 12507582747898016110 "
+ "8319356319569362772 3835100005166188461 10769229288786702843 "
+ "14682980657311687345 10352054841727718090 13661249361946024317 "
+ "1558696616315734178 9963912474249467679 18213809676410642730 "
+ "7284438284457478230 8013656044128665351 6817107912809760616 "
+ "4989038816564331700 12918068165960947833 9123533477086273623 "
+ "741568181450204257 3801962339733348259 1923812112542486965 "
+ "5884360231397942779 17008459141377852544 6569697353326895092 "
+ "15194386425456240489 9363979514988323850 9212437218544795097 "
+ "5650610605870621879 10315798944006232463 10345822437227504297 "
+ "795589193815296350 11344022765750598871 3193778122705907169 "
+ "16719669104430190089 14918335244853046975 11608293761910939782 "
+ "17290187430985633813 856382712722415618 14819792788008454203 "
+ "10571145147196955435 12858063129221173592 5671819431516788648 "
+ "17837836658827607239 14004823010100183722 9067196699747632668 "
+ "441015230260308492 3444946658209715644 1825101023084664281 "
+ "11133092574473850025 12746373758552339264 10154162549097295782 "
+ "14922316177042921089 12679802872389794491 8797747037480461410 "
+ "13907752811248535439 5652405835046458389 3181711594575177977 "
+ "15495242712294857418 6049158560807439366 952771601159099159 "
+ "4587095466254740009 11160954054611782211 10071795025240457628 "
+ "1536670498623767300 1990681379653546894 14312739227381277138 "
+ "9695213786215402291 3580182943401628617 12313607438786545484 "
+ "12864141705426648443 692371170805382036 13125536612285239925 "
+ "9372929234002877092 9510419002221032820 3766423210161674061 "
+ "3230494342413727261 5934351496112072933 2863344864469097044 "
+ "10884720908958139042 4127946927340597780 9960629658622711061 "
+ "14818231351611083857 6346099615454582885 12601407558879514692 "
+ "17544105005554819865 1096648950913019831 9969868157190185788 "
+ "12908611252828823970 5941129863397152719 16168953427117105234 "
+ "12304862402025196697 7781571759256122972 13289545261301048078 "
+ "11013924305579914035 8894422550580466537 7506958826675805512 "
+ "14280817252893250439 2745266616282182732 17277225453205013047 "
+ "14335499905842065319 11961295941780577536 18072890757248426766 "
+ "1124506606842606920 17329960125355005185 13052066741624159010 "
+ "5704650516221677069 16588425097127709212 11813406583737887980 "
+ "16359723311775411283 13451679937172566665 5997753207634594468 "
+ "10656019008205694109 13074690560123889048 14811648124990806194 "
+ "7809449463531558024 5637787273252434288 16515135932856030468 "
+ "3755600163640125044 1153929634172103321 11071014283313196016 "
+ "11114640359080035583 15390782025450330559 14097530518721927499 "
+ "14776783751481098767 7863618667181998233 11513855295425132436 "
+ "4736362806980864724 5426549653049482466 10310828122060887518 "
+ "4450247941008370560 9781171949844602811 6086471549040450051 "
+ "6033923116291003194 17669843285681524740 17610378273478865070 "
+ "12152320288002263294 6525449125788834221 5125338396312613396 "
+ "9300082688721166268 959242243476884691 6379729471368150249 "
+ "16379772457647614853 13454012201619761707 2392678998182524851 "
+ "12693758700673471007 1138892516507202079 15673908144065302514 "
+ "5299581449349386824 7590792025124859454 9863745357571267780 "
+ "357345312340746112 17610247870912740564 16347431861769737095 "
+ "11348828299228888092 7220122803951857490 7038822841708464676 "
+ "9912221445023094105 5767425533670320190 6442622362743049032 "
+ "17525461567869579503 4211095256108567696 14862334876401617373 "
+ "2866362449624104511 11413742225973279461 13015745308569358847 "
+ "5191760666536228849 17188167935010684492 18321678815621002079 "
+ "13046333455321624690 3995310719038261500 10661051209947341089 "
+ "7965203671238327266 16590917686161852835 3897101637344795372 "
+ "1538303624766151695 10893225639252940698 5386335660311332214 "
+ "5174479122000384061 17378437193516866561 13629320139302700770 "
+ "10144210341964027265 12816799659000064406 3711797003976467729 "
+ "5079455890584507977 432599929275804205 10435019529328454317 "
+ "5310854040535477246 15941464006450157396 2192067269367387270 "
+ "9782967689631091633 6777452250210540865 18067909703113078220 "
+ "17525143578810667971 87448662189824165 412530897284614413 "
+ "12066785122245373863 13073154860645125438 18282514257379582711 "
+ "8460374908111578570 15967512883067334502 9620430172798103891 "
+ "1264976185047610409 15426838192579528907 9878758812321441445 "
+ "18029992505662864846 9383699886128308360 14538949787806484635 "
+ "16958815135940772668 980481467951972605 3059030058898313960 "
+ "11497544574740915907 8385450996898478663 15571176518627282350";
+ unsigned as[] = {3, 5, 7};
+ std::seed_seq sseq(as, as+3);
+ std::mt19937_64 e1(sseq);
+ std::ostringstream os;
+ os << e1;
+ assert(os.str() == a);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
diff --git a/test/std/numerics/rand/rand.eng/rand.eng.mers/default.pass.cpp b/test/std/numerics/rand/rand.eng/rand.eng.mers/default.pass.cpp
new file mode 100644
index 000000000000..d92ffd807da0
--- /dev/null
+++ b/test/std/numerics/rand/rand.eng/rand.eng.mers/default.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template <class UIntType, size_t w, size_t n, size_t m, size_t r,
+// UIntType a, size_t u, UIntType d, size_t s,
+// UIntType b, size_t t, UIntType c, size_t l, UIntType f>
+// class mersenne_twister_engine;
+
+// explicit mersenne_twister_engine();
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+void
+test1()
+{
+ std::mt19937 e1;
+ std::mt19937 e2(std::mt19937::default_seed);
+ assert(e1 == e2);
+ assert(e1() == 3499211612u);
+}
+
+void
+test2()
+{
+ std::mt19937_64 e1;
+ std::mt19937_64 e2(std::mt19937_64::default_seed);
+ assert(e1 == e2);
+ assert(e1() == 14514284786278117030ull);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
diff --git a/test/std/numerics/rand/rand.eng/rand.eng.mers/discard.pass.cpp b/test/std/numerics/rand/rand.eng/rand.eng.mers/discard.pass.cpp
new file mode 100644
index 000000000000..d20d661d5891
--- /dev/null
+++ b/test/std/numerics/rand/rand.eng/rand.eng.mers/discard.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template <class UIntType, size_t w, size_t n, size_t m, size_t r,
+// UIntType a, size_t u, UIntType d, size_t s,
+// UIntType b, size_t t, UIntType c, size_t l, UIntType f>
+// class mersenne_twister_engine;
+
+// void discard(unsigned long long z);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+void
+test1()
+{
+ std::mt19937 e1;
+ std::mt19937 e2 = e1;
+ assert(e1 == e2);
+ e1.discard(3);
+ assert(e1 != e2);
+ e2();
+ e2();
+ e2();
+ assert(e1 == e2);
+}
+
+void
+test2()
+{
+ std::mt19937_64 e1;
+ std::mt19937_64 e2 = e1;
+ assert(e1 == e2);
+ e1.discard(3);
+ assert(e1 != e2);
+ e2();
+ e2();
+ e2();
+ assert(e1 == e2);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
diff --git a/test/std/numerics/rand/rand.eng/rand.eng.mers/eval.pass.cpp b/test/std/numerics/rand/rand.eng/rand.eng.mers/eval.pass.cpp
new file mode 100644
index 000000000000..0b17a8577067
--- /dev/null
+++ b/test/std/numerics/rand/rand.eng/rand.eng.mers/eval.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template <class UIntType, size_t w, size_t n, size_t m, size_t r,
+// UIntType a, size_t u, UIntType d, size_t s,
+// UIntType b, size_t t, UIntType c, size_t l, UIntType f>
+// class mersenne_twister_engine;
+
+// result_type operator()();
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+void
+test1()
+{
+ std::mt19937 e;
+ assert(e() == 3499211612u);
+ assert(e() == 581869302u);
+ assert(e() == 3890346734u);
+}
+
+void
+test2()
+{
+ std::mt19937_64 e;
+ assert(e() == 14514284786278117030ull);
+ assert(e() == 4620546740167642908ull);
+ assert(e() == 13109570281517897720ull);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
diff --git a/test/std/numerics/rand/rand.eng/rand.eng.mers/io.pass.cpp b/test/std/numerics/rand/rand.eng/rand.eng.mers/io.pass.cpp
new file mode 100644
index 000000000000..28e00ec1eb88
--- /dev/null
+++ b/test/std/numerics/rand/rand.eng/rand.eng.mers/io.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template <class UIntType, size_t w, size_t n, size_t m, size_t r,
+// UIntType a, size_t u, UIntType d, size_t s,
+// UIntType b, size_t t, UIntType c, size_t l, UIntType f>
+// class mersenne_twister_engine;
+
+// template <class charT, class traits,
+// class UIntType, size_t w, size_t n, size_t m, size_t r,
+// UIntType a, size_t u, UIntType d, size_t s,
+// UIntType b, size_t t, UIntType c, size_t l, UIntType f>
+// basic_ostream<charT, traits>&
+// operator<<(basic_ostream<charT, traits>& os,
+// const mersenne_twister_engine<UIntType, w, n, m, r, a, u, d, s, b, t, c, l, f>& x);
+//
+// template <class charT, class traits,
+// class UIntType, size_t w, size_t n, size_t m, size_t r,
+// UIntType a, size_t u, UIntType d, size_t s,
+// UIntType b, size_t t, UIntType c, size_t l, UIntType f>
+// basic_ostream<charT, traits>&
+// operator>>(basic_istream<charT, traits>& is,
+// mersenne_twister_engine<UIntType, w, n, m, r, a, u, d, s, b, t, c, l, f>& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::mt19937 E;
+ E e1;
+ e1.discard(100);
+ std::ostringstream os;
+ os << e1;
+ std::istringstream is(os.str());
+ E e2;
+ is >> e2;
+ assert(e1 == e2);
+}
+
+void
+test2()
+{
+ typedef std::mt19937_64 E;
+ E e1;
+ e1.discard(100);
+ std::ostringstream os;
+ os << e1;
+ std::istringstream is(os.str());
+ E e2;
+ is >> e2;
+ assert(e1 == e2);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
diff --git a/test/std/numerics/rand/rand.eng/rand.eng.mers/result_type.pass.cpp b/test/std/numerics/rand/rand.eng/rand.eng.mers/result_type.pass.cpp
new file mode 100644
index 000000000000..26f3e1563295
--- /dev/null
+++ b/test/std/numerics/rand/rand.eng/rand.eng.mers/result_type.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template <class UIntType, size_t w, size_t n, size_t m, size_t r,
+// UIntType a, size_t u, UIntType d, size_t s,
+// UIntType b, size_t t, UIntType c, size_t l, UIntType f>
+// class mersenne_twister_engine
+// {
+// public:
+// // types
+// typedef UIntType result_type;
+
+#include <random>
+#include <type_traits>
+
+void
+test1()
+{
+ static_assert((std::is_same<
+ std::mt19937::result_type,
+ std::uint_fast32_t>::value), "");
+}
+
+void
+test2()
+{
+ static_assert((std::is_same<
+ std::mt19937_64::result_type,
+ std::uint_fast64_t>::value), "");
+}
+
+int main()
+{
+ test1();
+ test2();
+}
diff --git a/test/std/numerics/rand/rand.eng/rand.eng.mers/seed_result_type.pass.cpp b/test/std/numerics/rand/rand.eng/rand.eng.mers/seed_result_type.pass.cpp
new file mode 100644
index 000000000000..6f93e5beb9b5
--- /dev/null
+++ b/test/std/numerics/rand/rand.eng/rand.eng.mers/seed_result_type.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template <class UIntType, size_t w, size_t n, size_t m, size_t r,
+// UIntType a, size_t u, UIntType d, size_t s,
+// UIntType b, size_t t, UIntType c, size_t l, UIntType f>
+// class mersenne_twister_engine;
+
+// void seed(result_type s = default_seed);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ for (int s = 0; s < 20; ++s)
+ {
+ typedef std::mt19937 E;
+ E e1(s);
+ E e2;
+ e2.seed(s);
+ assert(e1 == e2);
+ }
+}
+
+void
+test2()
+{
+ for (int s = 0; s < 20; ++s)
+ {
+ typedef std::mt19937_64 E;
+ E e1(s);
+ E e2;
+ e2.seed(s);
+ assert(e1 == e2);
+ }
+}
+
+int main()
+{
+ test1();
+ test2();
+}
diff --git a/test/std/numerics/rand/rand.eng/rand.eng.mers/seed_sseq.pass.cpp b/test/std/numerics/rand/rand.eng/rand.eng.mers/seed_sseq.pass.cpp
new file mode 100644
index 000000000000..33292a041af4
--- /dev/null
+++ b/test/std/numerics/rand/rand.eng/rand.eng.mers/seed_sseq.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template <class UIntType, size_t w, size_t n, size_t m, size_t r,
+// UIntType a, size_t u, UIntType d, size_t s,
+// UIntType b, size_t t, UIntType c, size_t l, UIntType f>
+// class mersenne_twister_engine;
+
+// template<class Sseq> void seed(Sseq& q);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ unsigned a[] = {3, 5, 7};
+ std::seed_seq sseq(a, a+3);
+ std::mt19937 e1;
+ std::mt19937 e2(sseq);
+ assert(e1 != e2);
+ e1.seed(sseq);
+ assert(e1 == e2);
+}
+
+void
+test2()
+{
+ unsigned a[] = {3, 5, 7};
+ std::seed_seq sseq(a, a+3);
+ std::mt19937_64 e1;
+ std::mt19937_64 e2(sseq);
+ assert(e1 != e2);
+ e1.seed(sseq);
+ assert(e1 == e2);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
diff --git a/test/std/numerics/rand/rand.eng/rand.eng.mers/values.pass.cpp b/test/std/numerics/rand/rand.eng/rand.eng.mers/values.pass.cpp
new file mode 100644
index 000000000000..331d3c51119f
--- /dev/null
+++ b/test/std/numerics/rand/rand.eng/rand.eng.mers/values.pass.cpp
@@ -0,0 +1,122 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template <class UIntType, size_t w, size_t n, size_t m, size_t r,
+// UIntType a, size_t u, UIntType d, size_t s,
+// UIntType b, size_t t, UIntType c, size_t l, UIntType f>
+// class mersenne_twister_engine
+// {
+// public:
+// // types
+// typedef UIntType result_type;
+//
+// // engine characteristics
+// static constexpr size_t word_size = w;
+// static constexpr size_t state_size = n;
+// static constexpr size_t shift_size = m;
+// static constexpr size_t mask_bits = r;
+// static constexpr result_type xor_mask = a;
+// static constexpr size_t tempering_u = u;
+// static constexpr result_type tempering_d = d;
+// static constexpr size_t tempering_s = s;
+// static constexpr result_type tempering_b = b;
+// static constexpr size_t tempering_t = t;
+// static constexpr result_type tempering_c = c;
+// static constexpr size_t tempering_l = l;
+// static constexpr result_type initialization_multiplier = f;
+// static constexpr result_type min () { return 0; }
+// static constexpr result_type max() { return 2^w - 1; }
+// static constexpr result_type default_seed = 5489u;
+
+#include <random>
+#include <type_traits>
+#include <cassert>
+
+template <class _Tp>
+void where(const _Tp &) {}
+
+void
+test1()
+{
+ typedef std::mt19937 E;
+ static_assert((E::word_size == 32), "");
+ static_assert((E::state_size == 624), "");
+ static_assert((E::shift_size == 397), "");
+ static_assert((E::mask_bits == 31), "");
+ static_assert((E::xor_mask == 0x9908b0df), "");
+ static_assert((E::tempering_u == 11), "");
+ static_assert((E::tempering_d == 0xffffffff), "");
+ static_assert((E::tempering_s == 7), "");
+ static_assert((E::tempering_b == 0x9d2c5680), "");
+ static_assert((E::tempering_t == 15), "");
+ static_assert((E::tempering_c == 0xefc60000), "");
+ static_assert((E::tempering_l == 18), "");
+ static_assert((E::initialization_multiplier == 1812433253), "");
+ /*static_*/assert((E::min() == 0)/*, ""*/);
+ /*static_*/assert((E::max() == 0xFFFFFFFF)/*, ""*/);
+ static_assert((E::default_seed == 5489u), "");
+ where(E::word_size);
+ where(E::state_size);
+ where(E::shift_size);
+ where(E::mask_bits);
+ where(E::xor_mask);
+ where(E::tempering_u);
+ where(E::tempering_d);
+ where(E::tempering_s);
+ where(E::tempering_b);
+ where(E::tempering_t);
+ where(E::tempering_c);
+ where(E::tempering_l);
+ where(E::initialization_multiplier);
+ where(E::default_seed);
+}
+
+void
+test2()
+{
+ typedef std::mt19937_64 E;
+ static_assert((E::word_size == 64), "");
+ static_assert((E::state_size == 312), "");
+ static_assert((E::shift_size == 156), "");
+ static_assert((E::mask_bits == 31), "");
+ static_assert((E::xor_mask == 0xb5026f5aa96619e9ull), "");
+ static_assert((E::tempering_u == 29), "");
+ static_assert((E::tempering_d == 0x5555555555555555ull), "");
+ static_assert((E::tempering_s == 17), "");
+ static_assert((E::tempering_b == 0x71d67fffeda60000ull), "");
+ static_assert((E::tempering_t == 37), "");
+ static_assert((E::tempering_c == 0xfff7eee000000000ull), "");
+ static_assert((E::tempering_l == 43), "");
+ static_assert((E::initialization_multiplier == 6364136223846793005ull), "");
+ /*static_*/assert((E::min() == 0)/*, ""*/);
+ /*static_*/assert((E::max() == 0xFFFFFFFFFFFFFFFFull)/*, ""*/);
+ static_assert((E::default_seed == 5489u), "");
+ where(E::word_size);
+ where(E::state_size);
+ where(E::shift_size);
+ where(E::mask_bits);
+ where(E::xor_mask);
+ where(E::tempering_u);
+ where(E::tempering_d);
+ where(E::tempering_s);
+ where(E::tempering_b);
+ where(E::tempering_t);
+ where(E::tempering_c);
+ where(E::tempering_l);
+ where(E::initialization_multiplier);
+ where(E::default_seed);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
diff --git a/test/std/numerics/rand/rand.eng/rand.eng.sub/assign.pass.cpp b/test/std/numerics/rand/rand.eng/rand.eng.sub/assign.pass.cpp
new file mode 100644
index 000000000000..305d43ad4a22
--- /dev/null
+++ b/test/std/numerics/rand/rand.eng/rand.eng.sub/assign.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class UIntType, size_t w, size_t s, size_t r>
+// class subtract_with_carry_engine;
+
+// subtract_with_carry_engine& operator=(const subtract_with_carry_engine&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::ranlux24_base E;
+ E e1(2);
+ e1();
+ E e2(5);
+ e2 = e1;
+ assert(e1 == e2);
+ assert(e1() == e2());
+ E::result_type k = e1();
+ assert(e1 != e2);
+ assert(e2() == k);
+ assert(e1 == e2);
+}
+
+void
+test2()
+{
+ typedef std::ranlux48_base E;
+ E e1(3);
+ e1();
+ E e2(5);
+ e2 = e1;
+ assert(e1 == e2);
+ assert(e1() == e2());
+ E::result_type k = e1();
+ assert(e1 != e2);
+ assert(e2() == k);
+ assert(e1 == e2);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
diff --git a/test/std/numerics/rand/rand.eng/rand.eng.sub/copy.pass.cpp b/test/std/numerics/rand/rand.eng/rand.eng.sub/copy.pass.cpp
new file mode 100644
index 000000000000..27f88165bcf5
--- /dev/null
+++ b/test/std/numerics/rand/rand.eng/rand.eng.sub/copy.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class UIntType, size_t w, size_t s, size_t r>
+// class subtract_with_carry_engine;
+
+// subtract_with_carry_engine(const subtract_with_carry_engine&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::ranlux24_base E;
+ E e1;
+ e1();
+ E e2 = e1;
+ assert(e1 == e2);
+ assert(e1() == e2());
+ E::result_type k = e1();
+ assert(e1 != e2);
+ assert(e2() == k);
+ assert(e1 == e2);
+}
+
+void
+test2()
+{
+ typedef std::ranlux48_base E;
+ E e1;
+ e1();
+ E e2(e1);
+ assert(e1 == e2);
+ assert(e1() == e2());
+ E::result_type k = e1();
+ assert(e1 != e2);
+ assert(e2() == k);
+ assert(e1 == e2);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
diff --git a/test/std/numerics/rand/rand.eng/rand.eng.sub/ctor_result_type.pass.cpp b/test/std/numerics/rand/rand.eng/rand.eng.sub/ctor_result_type.pass.cpp
new file mode 100644
index 000000000000..429298dfcd88
--- /dev/null
+++ b/test/std/numerics/rand/rand.eng/rand.eng.sub/ctor_result_type.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class UIntType, size_t w, size_t s, size_t r>
+// class subtract_with_carry_engine;
+
+// explicit subtract_with_carry_engine(result_type s = default_seed);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+void
+test1()
+{
+ const char* a = "15136306 8587749 2346244 16479026 15515802 9510553 "
+ "16090340 14501685 13839944 10789678 11581259 9590790 5840316 5953700 "
+ "13398366 8134459 16629731 6851902 15583892 1317475 4231148 9092691 "
+ "5707268 2355175 0";
+ std::ranlux24_base e1(0);
+ std::ostringstream os;
+ os << e1;
+ assert(os.str() == a);
+}
+
+void
+test2()
+{
+ const char* a = "10880375256626 126660097854724 33643165434010 "
+ "78293780235492 179418984296008 96783156950859 238199764491708 "
+ "34339434557790 155299155394531 29014415493780 209265474179052 "
+ "263777435457028 0";
+ std::ranlux48_base e1(0);
+ std::ostringstream os;
+ os << e1;
+ assert(os.str() == a);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
diff --git a/test/std/numerics/rand/rand.eng/rand.eng.sub/ctor_sseq.pass.cpp b/test/std/numerics/rand/rand.eng/rand.eng.sub/ctor_sseq.pass.cpp
new file mode 100644
index 000000000000..893f6dc34a4b
--- /dev/null
+++ b/test/std/numerics/rand/rand.eng/rand.eng.sub/ctor_sseq.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class UIntType, size_t w, size_t s, size_t r>
+// class subtract_with_carry_engine;
+
+// template<class Sseq> explicit subtract_with_carry_engine(Sseq& q);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+void
+test1()
+{
+ const char* a = "13604817 711567 9760686 13278398 3323440 175548 5553651 "
+ "3028863 10748297 2216688 275779 14778841 14438394 9483441 4229545 "
+ "14657301 12636508 15978210 1653340 1718567 9272421 14302862 7940348 "
+ "889045 0";
+ unsigned as[] = {3, 5, 7};
+ std::seed_seq sseq(as, as+3);
+ std::ranlux24_base e1(sseq);
+ std::ostringstream os;
+ os << e1;
+ assert(os.str() == a);
+}
+
+void
+test2()
+{
+ const char* a = "241408498702289 172342669275054 191026374555184 "
+ "61020585639411 231929771458953 142769679250755 198672786411514 "
+ "183712717244841 227473912549724 62843577252444 68782400568421 "
+ "159248704678140 0";
+ unsigned as[] = {3, 5, 7};
+ std::seed_seq sseq(as, as+3);
+ std::ranlux48_base e1(sseq);
+ std::ostringstream os;
+ os << e1;
+ assert(os.str() == a);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
diff --git a/test/std/numerics/rand/rand.eng/rand.eng.sub/default.pass.cpp b/test/std/numerics/rand/rand.eng/rand.eng.sub/default.pass.cpp
new file mode 100644
index 000000000000..56e8759d1e60
--- /dev/null
+++ b/test/std/numerics/rand/rand.eng/rand.eng.sub/default.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class UIntType, size_t w, size_t s, size_t r>
+// class subtract_with_carry_engine;
+
+// explicit subtract_with_carry_engine();
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ std::ranlux24_base e1;
+ std::ranlux24_base e2(std::ranlux24_base::default_seed);
+ assert(e1 == e2);
+ assert(e1() == 15039276);
+}
+
+void
+test2()
+{
+ std::ranlux48_base e1;
+ std::ranlux48_base e2(std::ranlux48_base::default_seed);
+ assert(e1 == e2);
+ assert(e1() == 23459059301164ull);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
diff --git a/test/std/numerics/rand/rand.eng/rand.eng.sub/discard.pass.cpp b/test/std/numerics/rand/rand.eng/rand.eng.sub/discard.pass.cpp
new file mode 100644
index 000000000000..4ba93819ee43
--- /dev/null
+++ b/test/std/numerics/rand/rand.eng/rand.eng.sub/discard.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class UIntType, size_t w, size_t s, size_t r>
+// class subtract_with_carry_engine;
+
+// void discard(unsigned long long z);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ std::ranlux24_base e1;
+ std::ranlux24_base e2 = e1;
+ assert(e1 == e2);
+ e1.discard(3);
+ assert(e1 != e2);
+ e2();
+ e2();
+ e2();
+ assert(e1 == e2);
+}
+
+void
+test2()
+{
+ std::ranlux48_base e1;
+ std::ranlux48_base e2 = e1;
+ assert(e1 == e2);
+ e1.discard(3);
+ assert(e1 != e2);
+ e2();
+ e2();
+ e2();
+ assert(e1 == e2);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
diff --git a/test/std/numerics/rand/rand.eng/rand.eng.sub/eval.pass.cpp b/test/std/numerics/rand/rand.eng/rand.eng.sub/eval.pass.cpp
new file mode 100644
index 000000000000..44829944be73
--- /dev/null
+++ b/test/std/numerics/rand/rand.eng/rand.eng.sub/eval.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class UIntType, size_t w, size_t s, size_t r>
+// class subtract_with_carry_engine;
+
+// result_type operator()();
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ std::ranlux24_base e;
+ assert(e() == 15039276u);
+ assert(e() == 16323925u);
+ assert(e() == 14283486u);
+}
+
+void
+test2()
+{
+ std::ranlux48_base e;
+ assert(e() == 23459059301164ull);
+ assert(e() == 28639057539807ull);
+ assert(e() == 276846226770426ull);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
diff --git a/test/std/numerics/rand/rand.eng/rand.eng.sub/io.pass.cpp b/test/std/numerics/rand/rand.eng/rand.eng.sub/io.pass.cpp
new file mode 100644
index 000000000000..834f5f69c777
--- /dev/null
+++ b/test/std/numerics/rand/rand.eng/rand.eng.sub/io.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class UIntType, size_t w, size_t s, size_t r>
+// class subtract_with_carry_engine;
+
+// template <class charT, class traits,
+// class UIntType, size_t w, size_t s, size_t r>
+// basic_ostream<charT, traits>&
+// operator<<(basic_ostream<charT, traits>& os,
+// const subtract_with_carry_engine<UIntType, w, s, r>& x);
+//
+// template <class charT, class traits,
+// class UIntType, size_t w, size_t s, size_t r>
+// basic_istream<charT, traits>&
+// operator>>(basic_istream<charT, traits>& is,
+// subtract_with_carry_engine<UIntType, w, s, r>& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::ranlux24_base E;
+ E e1;
+ e1.discard(100);
+ std::ostringstream os;
+ os << e1;
+ std::istringstream is(os.str());
+ E e2;
+ is >> e2;
+ assert(e1 == e2);
+}
+
+void
+test2()
+{
+ typedef std::ranlux48_base E;
+ E e1;
+ e1.discard(100);
+ std::ostringstream os;
+ os << e1;
+ std::istringstream is(os.str());
+ E e2;
+ is >> e2;
+ assert(e1 == e2);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
diff --git a/test/std/numerics/rand/rand.eng/rand.eng.sub/result_type.pass.cpp b/test/std/numerics/rand/rand.eng/rand.eng.sub/result_type.pass.cpp
new file mode 100644
index 000000000000..6af195b49923
--- /dev/null
+++ b/test/std/numerics/rand/rand.eng/rand.eng.sub/result_type.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class UIntType, size_t w, size_t s, size_t r>
+// class subtract_with_carry_engine
+// {
+// public:
+// // types
+// typedef UIntType result_type;
+
+#include <random>
+#include <type_traits>
+
+void
+test1()
+{
+ static_assert((std::is_same<
+ std::ranlux24_base::result_type,
+ std::uint_fast32_t>::value), "");
+}
+
+void
+test2()
+{
+ static_assert((std::is_same<
+ std::ranlux48_base::result_type,
+ std::uint_fast64_t>::value), "");
+}
+
+int main()
+{
+ test1();
+ test2();
+}
diff --git a/test/std/numerics/rand/rand.eng/rand.eng.sub/seed_result_type.pass.cpp b/test/std/numerics/rand/rand.eng/rand.eng.sub/seed_result_type.pass.cpp
new file mode 100644
index 000000000000..fa6e741da920
--- /dev/null
+++ b/test/std/numerics/rand/rand.eng/rand.eng.sub/seed_result_type.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class UIntType, size_t w, size_t s, size_t r>
+// class subtract_with_carry_engine;
+
+// void seed(result_type s = default_seed);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ for (int s = 0; s < 20; ++s)
+ {
+ typedef std::ranlux24_base E;
+ E e1(s);
+ E e2;
+ e2.seed(s);
+ assert(e1 == e2);
+ }
+}
+
+void
+test2()
+{
+ for (int s = 0; s < 20; ++s)
+ {
+ typedef std::ranlux48_base E;
+ E e1(s);
+ E e2;
+ e2.seed(s);
+ assert(e1 == e2);
+ }
+}
+
+int main()
+{
+ test1();
+ test2();
+}
diff --git a/test/std/numerics/rand/rand.eng/rand.eng.sub/seed_sseq.pass.cpp b/test/std/numerics/rand/rand.eng/rand.eng.sub/seed_sseq.pass.cpp
new file mode 100644
index 000000000000..347077278e61
--- /dev/null
+++ b/test/std/numerics/rand/rand.eng/rand.eng.sub/seed_sseq.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class UIntType, size_t w, size_t s, size_t r>
+// class subtract_with_carry_engine;
+
+// template<class Sseq> void seed(Sseq& q);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ unsigned a[] = {3, 5, 7};
+ std::seed_seq sseq(a, a+3);
+ std::ranlux24_base e1;
+ std::ranlux24_base e2(sseq);
+ assert(e1 != e2);
+ e1.seed(sseq);
+ assert(e1 == e2);
+}
+
+void
+test2()
+{
+ unsigned a[] = {3, 5, 7};
+ std::seed_seq sseq(a, a+3);
+ std::ranlux48_base e1;
+ std::ranlux48_base e2(sseq);
+ assert(e1 != e2);
+ e1.seed(sseq);
+ assert(e1 == e2);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
diff --git a/test/std/numerics/rand/rand.eng/rand.eng.sub/values.pass.cpp b/test/std/numerics/rand/rand.eng/rand.eng.sub/values.pass.cpp
new file mode 100644
index 000000000000..75716a43deae
--- /dev/null
+++ b/test/std/numerics/rand/rand.eng/rand.eng.sub/values.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class UIntType, size_t w, size_t s, size_t r>
+// class subtract_with_carry_engine
+// {
+// public:
+// // types
+// typedef UIntType result_type;
+//
+// // engine characteristics
+// static constexpr size_t word_size = w;
+// static constexpr size_t short_lag = s;
+// static constexpr size_t long_lag = r;
+// static constexpr result_type min() { return 0; }
+// static constexpr result_type max() { return m-1; }
+// static constexpr result_type default_seed = 19780503u;
+
+#include <random>
+#include <type_traits>
+#include <cassert>
+
+template <class _Tp>
+void where(const _Tp &) {}
+
+void
+test1()
+{
+ typedef std::ranlux24_base E;
+ static_assert((E::word_size == 24), "");
+ static_assert((E::short_lag == 10), "");
+ static_assert((E::long_lag == 24), "");
+ /*static_*/assert((E::min() == 0)/*, ""*/);
+ /*static_*/assert((E::max() == 0xFFFFFF)/*, ""*/);
+ static_assert((E::default_seed == 19780503u), "");
+ where(E::word_size);
+ where(E::short_lag);
+ where(E::long_lag);
+ where(E::default_seed);
+}
+
+void
+test2()
+{
+ typedef std::ranlux48_base E;
+ static_assert((E::word_size == 48), "");
+ static_assert((E::short_lag == 5), "");
+ static_assert((E::long_lag == 12), "");
+ /*static_*/assert((E::min() == 0)/*, ""*/);
+ /*static_*/assert((E::max() == 0xFFFFFFFFFFFFull)/*, ""*/);
+ static_assert((E::default_seed == 19780503u), "");
+ where(E::word_size);
+ where(E::short_lag);
+ where(E::long_lag);
+ where(E::default_seed);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
diff --git a/test/std/numerics/rand/rand.predef/default_random_engine.pass.cpp b/test/std/numerics/rand/rand.predef/default_random_engine.pass.cpp
new file mode 100644
index 000000000000..426586007c1a
--- /dev/null
+++ b/test/std/numerics/rand/rand.predef/default_random_engine.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// typedef minstd_rand0 default_random_engine;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ std::default_random_engine e;
+ e.discard(9999);
+ assert(e() == 399268537u);
+}
diff --git a/test/std/numerics/rand/rand.predef/knuth_b.pass.cpp b/test/std/numerics/rand/rand.predef/knuth_b.pass.cpp
new file mode 100644
index 000000000000..69627d79e907
--- /dev/null
+++ b/test/std/numerics/rand/rand.predef/knuth_b.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// typedef shuffle_order_engine<minstd_rand0, 256> knuth_b;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ std::knuth_b e;
+ e.discard(9999);
+ assert(e() == 1112339016u);
+}
diff --git a/test/std/numerics/rand/rand.predef/minstd_rand.pass.cpp b/test/std/numerics/rand/rand.predef/minstd_rand.pass.cpp
new file mode 100644
index 000000000000..891e5cce6d85
--- /dev/null
+++ b/test/std/numerics/rand/rand.predef/minstd_rand.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// typedef linear_congruential_engine<uint_fast32_t, 48271, 0, 2147483647>
+// minstd_rand;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ std::minstd_rand e;
+ e.discard(9999);
+ assert(e() == 399268537u);
+}
diff --git a/test/std/numerics/rand/rand.predef/minstd_rand0.pass.cpp b/test/std/numerics/rand/rand.predef/minstd_rand0.pass.cpp
new file mode 100644
index 000000000000..63848cf95065
--- /dev/null
+++ b/test/std/numerics/rand/rand.predef/minstd_rand0.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// typedef linear_congruential_engine<uint_fast32_t, 16807, 0, 2147483647>
+// minstd_rand0;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ std::minstd_rand0 e;
+ e.discard(9999);
+ assert(e() == 1043618065u);
+}
diff --git a/test/std/numerics/rand/rand.predef/mt19937.pass.cpp b/test/std/numerics/rand/rand.predef/mt19937.pass.cpp
new file mode 100644
index 000000000000..e3a79364a1f5
--- /dev/null
+++ b/test/std/numerics/rand/rand.predef/mt19937.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// typedef mersenne_twister_engine<uint_fast32_t, 32, 624, 397, 31,
+// 0x9908b0df,
+// 11, 0xffffffff,
+// 7, 0x9d2c5680,
+// 15, 0xefc60000,
+// 18, 1812433253> mt19937;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ std::mt19937 e;
+ e.discard(9999);
+ assert(e() == 4123659995u);
+}
diff --git a/test/std/numerics/rand/rand.predef/mt19937_64.pass.cpp b/test/std/numerics/rand/rand.predef/mt19937_64.pass.cpp
new file mode 100644
index 000000000000..67896d2260f4
--- /dev/null
+++ b/test/std/numerics/rand/rand.predef/mt19937_64.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// typedef mersenne_twister_engine<uint_fast64_t, 64, 312, 156, 31,
+// 0xb5026f5aa96619e9,
+// 29, 0x5555555555555555,
+// 17, 0x71d67fffeda60000,
+// 37, 0xfff7eee000000000,
+// 43, 6364136223846793005> mt19937_64;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ std::mt19937_64 e;
+ e.discard(9999);
+ assert(e() == 9981545732273789042ull);
+}
diff --git a/test/std/numerics/rand/rand.predef/ranlux24.pass.cpp b/test/std/numerics/rand/rand.predef/ranlux24.pass.cpp
new file mode 100644
index 000000000000..529586af9f42
--- /dev/null
+++ b/test/std/numerics/rand/rand.predef/ranlux24.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// typedef discard_block_engine<ranlux24_base, 223, 23> ranlux24;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ std::ranlux24 e;
+ e.discard(9999);
+ assert(e() == 9901578u);
+}
diff --git a/test/std/numerics/rand/rand.predef/ranlux24_base.pass.cpp b/test/std/numerics/rand/rand.predef/ranlux24_base.pass.cpp
new file mode 100644
index 000000000000..f7311469dcbf
--- /dev/null
+++ b/test/std/numerics/rand/rand.predef/ranlux24_base.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// typedef subtract_with_carry_engine<uint_fast32_t, 24, 10, 24> ranlux24_base;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ std::ranlux24_base e;
+ e.discard(9999);
+ assert(e() == 7937952u);
+}
diff --git a/test/std/numerics/rand/rand.predef/ranlux48.pass.cpp b/test/std/numerics/rand/rand.predef/ranlux48.pass.cpp
new file mode 100644
index 000000000000..f15dfd5493e2
--- /dev/null
+++ b/test/std/numerics/rand/rand.predef/ranlux48.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// typedef discard_block_engine<ranlux48_base, 389, 11> ranlux48;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ std::ranlux48 e;
+ e.discard(9999);
+ assert(e() == 249142670248501ull);
+}
diff --git a/test/std/numerics/rand/rand.predef/ranlux48_base.pass.cpp b/test/std/numerics/rand/rand.predef/ranlux48_base.pass.cpp
new file mode 100644
index 000000000000..4c3df3e1dce8
--- /dev/null
+++ b/test/std/numerics/rand/rand.predef/ranlux48_base.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// typedef subtract_with_carry_engine<uint_fast64_t, 48, 5, 12> ranlux48_base;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ std::ranlux48_base e;
+ e.discard(9999);
+ assert(e() == 61839128582725ull);
+}
diff --git a/test/std/numerics/rand/rand.req/nothing_to_do.pass.cpp b/test/std/numerics/rand/rand.req/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/numerics/rand/rand.req/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/numerics/rand/rand.req/rand.req.adapt/nothing_to_do.pass.cpp b/test/std/numerics/rand/rand.req/rand.req.adapt/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/numerics/rand/rand.req/rand.req.adapt/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/numerics/rand/rand.req/rand.req.dst/nothing_to_do.pass.cpp b/test/std/numerics/rand/rand.req/rand.req.dst/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/numerics/rand/rand.req/rand.req.dst/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/numerics/rand/rand.req/rand.req.eng/nothing_to_do.pass.cpp b/test/std/numerics/rand/rand.req/rand.req.eng/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/numerics/rand/rand.req/rand.req.eng/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/numerics/rand/rand.req/rand.req.genl/nothing_to_do.pass.cpp b/test/std/numerics/rand/rand.req/rand.req.genl/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/numerics/rand/rand.req/rand.req.genl/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/numerics/rand/rand.req/rand.req.seedseq/nothing_to_do.pass.cpp b/test/std/numerics/rand/rand.req/rand.req.seedseq/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/numerics/rand/rand.req/rand.req.seedseq/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/numerics/rand/rand.req/rand.req.urng/nothing_to_do.pass.cpp b/test/std/numerics/rand/rand.req/rand.req.urng/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/numerics/rand/rand.req/rand.req.urng/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/numerics/rand/rand.synopsis/version.pass.cpp b/test/std/numerics/rand/rand.synopsis/version.pass.cpp
new file mode 100644
index 000000000000..eae6c493e919
--- /dev/null
+++ b/test/std/numerics/rand/rand.synopsis/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+#include <random>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/numerics/rand/rand.util/nothing_to_do.pass.cpp b/test/std/numerics/rand/rand.util/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/numerics/rand/rand.util/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/numerics/rand/rand.util/rand.util.canonical/generate_canonical.pass.cpp b/test/std/numerics/rand/rand.util/rand.util.canonical/generate_canonical.pass.cpp
new file mode 100644
index 000000000000..7433e28e4935
--- /dev/null
+++ b/test/std/numerics/rand/rand.util/rand.util.canonical/generate_canonical.pass.cpp
@@ -0,0 +1,100 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType, size_t bits, class URNG>
+// RealType generate_canonical(URNG& g);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::minstd_rand0 E;
+ typedef float F;
+ E r;
+ F f = std::generate_canonical<F, 0>(r);
+ assert(f == (16807 - E::min()) / (E::max() - E::min() + F(1)));
+ }
+ {
+ typedef std::minstd_rand0 E;
+ typedef float F;
+ E r;
+ F f = std::generate_canonical<F, 1>(r);
+ assert(f == (16807 - E::min()) / (E::max() - E::min() + F(1)));
+ }
+ {
+ typedef std::minstd_rand0 E;
+ typedef float F;
+ E r;
+ F f = std::generate_canonical<F, std::numeric_limits<F>::digits - 1>(r);
+ assert(f == (16807 - E::min()) / (E::max() - E::min() + F(1)));
+ }
+ {
+ typedef std::minstd_rand0 E;
+ typedef float F;
+ E r;
+ F f = std::generate_canonical<F, std::numeric_limits<F>::digits>(r);
+ assert(f == (16807 - E::min()) / (E::max() - E::min() + F(1)));
+ }
+ {
+ typedef std::minstd_rand0 E;
+ typedef float F;
+ E r;
+ F f = std::generate_canonical<F, std::numeric_limits<F>::digits + 1>(r);
+ assert(f == (16807 - E::min()) / (E::max() - E::min() + F(1)));
+ }
+
+ {
+ typedef std::minstd_rand0 E;
+ typedef double F;
+ E r;
+ F f = std::generate_canonical<F, 0>(r);
+ assert(f == (16807 - E::min()) / (E::max() - E::min() + F(1)));
+ }
+ {
+ typedef std::minstd_rand0 E;
+ typedef double F;
+ E r;
+ F f = std::generate_canonical<F, 1>(r);
+ assert(f == (16807 - E::min()) / (E::max() - E::min() + F(1)));
+ }
+ {
+ typedef std::minstd_rand0 E;
+ typedef double F;
+ E r;
+ F f = std::generate_canonical<F, std::numeric_limits<F>::digits - 1>(r);
+ assert(f ==
+ (16807 - E::min() +
+ (282475249 - E::min()) * (E::max() - E::min() + F(1))) /
+ ((E::max() - E::min() + F(1)) * (E::max() - E::min() + F(1))));
+ }
+ {
+ typedef std::minstd_rand0 E;
+ typedef double F;
+ E r;
+ F f = std::generate_canonical<F, std::numeric_limits<F>::digits>(r);
+ assert(f ==
+ (16807 - E::min() +
+ (282475249 - E::min()) * (E::max() - E::min() + F(1))) /
+ ((E::max() - E::min() + F(1)) * (E::max() - E::min() + F(1))));
+ }
+ {
+ typedef std::minstd_rand0 E;
+ typedef double F;
+ E r;
+ F f = std::generate_canonical<F, std::numeric_limits<F>::digits + 1>(r);
+ assert(f ==
+ (16807 - E::min() +
+ (282475249 - E::min()) * (E::max() - E::min() + F(1))) /
+ ((E::max() - E::min() + F(1)) * (E::max() - E::min() + F(1))));
+ }
+}
diff --git a/test/std/numerics/rand/rand.util/rand.util.seedseq/assign.fail.cpp b/test/std/numerics/rand/rand.util/rand.util.seedseq/assign.fail.cpp
new file mode 100644
index 000000000000..6b5d75042d3b
--- /dev/null
+++ b/test/std/numerics/rand/rand.util/rand.util.seedseq/assign.fail.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class seed_seq;
+
+// seed_seq();
+
+#include <random>
+
+int main()
+{
+ std::seed_seq s0;
+ std::seed_seq s;
+ s = s0;
+}
diff --git a/test/std/numerics/rand/rand.util/rand.util.seedseq/copy.fail.cpp b/test/std/numerics/rand/rand.util/rand.util.seedseq/copy.fail.cpp
new file mode 100644
index 000000000000..cf260fcc01e8
--- /dev/null
+++ b/test/std/numerics/rand/rand.util/rand.util.seedseq/copy.fail.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class seed_seq;
+
+// seed_seq();
+
+#include <random>
+
+int main()
+{
+ std::seed_seq s0;
+ std::seed_seq s(s0);
+}
diff --git a/test/std/numerics/rand/rand.util/rand.util.seedseq/default.pass.cpp b/test/std/numerics/rand/rand.util/rand.util.seedseq/default.pass.cpp
new file mode 100644
index 000000000000..bf4210aa9950
--- /dev/null
+++ b/test/std/numerics/rand/rand.util/rand.util.seedseq/default.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class seed_seq;
+
+// seed_seq();
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ std::seed_seq s;
+ assert(s.size() == 0);
+}
diff --git a/test/std/numerics/rand/rand.util/rand.util.seedseq/generate.pass.cpp b/test/std/numerics/rand/rand.util/rand.util.seedseq/generate.pass.cpp
new file mode 100644
index 000000000000..9712f61d681c
--- /dev/null
+++ b/test/std/numerics/rand/rand.util/rand.util.seedseq/generate.pass.cpp
@@ -0,0 +1,805 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class seed_seq;
+
+// template<class RandomAccessIterator>
+// void generate(RandomAccessIterator begin, RandomAccessIterator end);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ // These numbers generated from a slightly altered version of dSFMT
+ // http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/SFMT/index.html
+ unsigned a[] =
+ {
+ 509928861u,
+ 482551238u,
+ 141770655u,
+ 3445468037u,
+ 1614807826u,
+ 3110698871u,
+ 809182926u,
+ 2644632325u,
+ 3885131857u,
+ 1278630374u,
+ 3648975313u,
+ 1217833759u,
+ 1509686260u,
+ 2817190507u,
+ 134525747u,
+ 250267852u,
+ 2559105345u,
+ 2416641579u,
+ 426100435u,
+ 486929906u,
+ 241178241u,
+ 3531539379u,
+ 704692991u,
+ 3001633456u,
+ 3990516671u,
+ 2619782509u,
+ 588842726u,
+ 2871949673u,
+ 621390331u,
+ 2304055997u,
+ 3809702625u,
+ 2471383485u,
+ 1630735687u,
+ 2167939898u,
+ 2070992669u,
+ 2826890739u,
+ 1714346061u,
+ 1912761420u,
+ 539780511u,
+ 716119356u,
+ 1342493369u,
+ 1216009367u,
+ 2864243850u,
+ 36288867u,
+ 2981095630u,
+ 2480586007u,
+ 1287539180u,
+ 1804977887u,
+ 2219960896u,
+ 297158412u,
+ 2839013626u,
+ 1971706101u,
+ 3588181149u,
+ 1387242816u,
+ 3713499635u,
+ 3408234160u,
+ 3179393218u,
+ 1359207226u,
+ 3119279997u,
+ 2777679329u,
+ 125221793u,
+ 902631799u,
+ 949389096u,
+ 3415339313u,
+ 4117407143u,
+ 3119227103u,
+ 1787026946u,
+ 3917387257u,
+ 3936044384u,
+ 2242085379u,
+ 1140709958u,
+ 2523265662u,
+ 3627073995u,
+ 3604398568u,
+ 1427913954u,
+ 2465898599u,
+ 3825653050u,
+ 2090876078u,
+ 232270946u,
+ 3116274782u,
+ 1252172657u,
+ 3197497894u,
+ 3983224490u,
+ 1939344836u,
+ 4158531887u,
+ 88050086u,
+ 2343094701u,
+ 1067025562u,
+ 3321491106u,
+ 3772162169u,
+ 909332669u,
+ 1671671873u,
+ 755193996u,
+ 978524521u,
+ 2164582730u,
+ 1757783103u,
+ 3411415001u,
+ 850017018u,
+ 3068762300u,
+ 555996984u,
+ 2404040146u,
+ 3397007611u,
+ 237680219u,
+ 245818821u,
+ 177824968u,
+ 3220945682u,
+ 304446762u,
+ 2267298065u,
+ 1878973555u,
+ 3050739800u,
+ 535731508u,
+ 1160102565u,
+ 4109066907u,
+ 984269821u,
+ 3681788896u,
+ 60254699u,
+ 3890962421u,
+ 2991673698u,
+ 3982271427u,
+ 3514243671u,
+ 1234870914u,
+ 2069958363u,
+ 3867828422u,
+ 1847469687u,
+ 503598128u,
+ 967934988u,
+ 289386211u,
+ 393279961u,
+ 835485527u,
+ 3708682854u,
+ 965218590u,
+ 4020339834u,
+ 2159101708u,
+ 2575134771u,
+ 376656690u,
+ 3499375240u,
+ 3105954900u,
+ 2786692328u,
+ 3458480699u,
+ 1207173847u,
+ 2051152535u,
+ 2738812911u,
+ 2954646330u,
+ 2774866710u,
+ 2162149150u,
+ 3993372257u,
+ 2868120585u,
+ 3086420190u,
+ 3791115537u,
+ 3226697711u,
+ 1818303409u,
+ 4206013897u,
+ 1245186807u,
+ 1680347447u,
+ 684800149u,
+ 2372078492u,
+ 2566952562u,
+ 3310947940u,
+ 3885964747u,
+ 3270357885u,
+ 2098965232u,
+ 609044652u,
+ 434910954u,
+ 93043847u,
+ 805217072u,
+ 883298424u,
+ 3850995479u,
+ 1840717689u,
+ 124278163u,
+ 4250050101u,
+ 2337070911u,
+ 2576763405u,
+ 2518189119u,
+ 3059082421u,
+ 1532107996u,
+ 2920167825u,
+ 2726963926u,
+ 3951524890u,
+ 1272835728u,
+ 1039392592u,
+ 1237920408u,
+ 1996153268u,
+ 647883626u,
+ 4064365193u,
+ 355588474u,
+ 3625797533u,
+ 1209959194u,
+ 503163662u,
+ 530295589u,
+ 1668578780u,
+ 969028048u,
+ 2489337768u,
+ 841218738u,
+ 14126306u,
+ 1854884627u,
+ 3617055808u,
+ 202224793u,
+ 1744552899u,
+ 1559016256u,
+ 3455976027u,
+ 1064269942u,
+ 2990703287u,
+ 1169718685u,
+ 1411804743u,
+ 290849805u,
+ 756035681u,
+ 1505272475u,
+ 1426658932u,
+ 16045749u,
+ 3900455443u,
+ 108521850u,
+ 1009491914u,
+ 3928801938u,
+ 1022079325u,
+ 3076867150u,
+ 4268343543u,
+ 2886814247u,
+ 2005055376u,
+ 1649037732u,
+ 1954533894u,
+ 3779223482u,
+ 1093746989u,
+ 2376482601u,
+ 3561720470u,
+ 1870836501u,
+ 651953759u,
+ 1504660027u,
+ 2097900540u,
+ 2252668945u,
+ 2469849023u,
+ 1986217648u,
+ 2026387757u,
+ 131611273u,
+ 1467981299u,
+ 3440588252u,
+ 1916199579u,
+ 959039804u,
+ 2895114746u,
+ 3292235117u,
+ 649379239u,
+ 28649189u,
+ 3121113086u,
+ 3829761771u,
+ 1675837301u,
+ 1636154723u,
+ 3737794169u,
+ 4082428060u,
+ 1904712095u,
+ 2483810990u,
+ 979972563u,
+ 1269082707u,
+ 370986843u,
+ 1233170438u,
+ 3008501783u,
+ 3905837878u,
+ 1566704758u,
+ 2380919351u,
+ 159980022u,
+ 1334100319u,
+ 2492554074u,
+ 137995234u,
+ 2318192908u,
+ 2608964837u,
+ 1061756617u,
+ 2760140790u,
+ 4069446576u,
+ 1995030350u,
+ 1037005594u,
+ 3489306635u,
+ 1588786838u,
+ 513304862u,
+ 3305490303u,
+ 2264317975u,
+ 3441620307u,
+ 4116970950u,
+ 3121104936u,
+ 1889858928u,
+ 2336693483u,
+ 3906421686u,
+ 2112501080u,
+ 2916376262u,
+ 2244436629u,
+ 663123276u,
+ 774309763u,
+ 258379821u,
+ 3845948150u,
+ 3747409682u,
+ 275936617u,
+ 563064995u,
+ 4049677403u,
+ 2099547498u,
+ 699768412u,
+ 1193153383u,
+ 4289059706u,
+ 3228950241u,
+ 1258043728u,
+ 1334659727u,
+ 3780523664u,
+ 1150773584u,
+ 2509712235u,
+ 2088544320u,
+ 1610096547u,
+ 3486280247u,
+ 1737969289u,
+ 1530372860u,
+ 2563496419u,
+ 2535243890u,
+ 998106254u,
+ 816066803u,
+ 1138534811u,
+ 1405672211u,
+ 2094652173u,
+ 1516292650u,
+ 2618233360u,
+ 3603340340u,
+ 247950637u,
+ 119238855u,
+ 1858201484u,
+ 3459729922u,
+ 157759693u,
+ 8278624u,
+ 3223944237u,
+ 3937209237u,
+ 3820737454u,
+ 839194830u,
+ 2385155004u,
+ 3872251779u,
+ 1375779033u,
+ 2333521764u,
+ 4025446588u,
+ 3839106064u,
+ 374878047u,
+ 1312756310u,
+ 1661068116u,
+ 1321601295u,
+ 4254646350u,
+ 3813168945u,
+ 134103711u,
+ 1535586498u,
+ 82369644u,
+ 411323516u,
+ 761969086u,
+ 819179215u,
+ 582595825u,
+ 3212591411u,
+ 665647256u,
+ 2372804634u,
+ 2378814089u,
+ 801724318u,
+ 658137482u,
+ 2084329677u,
+ 2512952888u,
+ 1573871611u,
+ 570440739u,
+ 3791634131u,
+ 1754412850u,
+ 406040873u,
+ 2576963615u,
+ 535767962u,
+ 1405150444u,
+ 3050488583u,
+ 3870648463u,
+ 2201665400u,
+ 178518008u,
+ 1050761986u,
+ 1635790851u,
+ 2757604743u,
+ 1194306620u,
+ 3895813535u,
+ 259506203u,
+ 1836108753u,
+ 555242075u,
+ 2574778399u,
+ 777988603u,
+ 2306149504u,
+ 2810362568u,
+ 402408487u,
+ 2163697780u,
+ 1982851065u,
+ 153191404u,
+ 1346605886u,
+ 197579289u,
+ 3847665347u,
+ 2437615293u,
+ 819252195u,
+ 3379927756u,
+ 1375088563u,
+ 2650550959u,
+ 2949512074u,
+ 3616578300u,
+ 1616680753u,
+ 1943918335u,
+ 2372676669u,
+ 599487215u,
+ 2422499758u,
+ 3164569986u,
+ 594265585u,
+ 667867933u,
+ 2382753501u,
+ 1213715652u,
+ 1470661916u,
+ 566771851u,
+ 463440918u,
+ 3056034602u,
+ 4101174909u,
+ 130576467u,
+ 2390765932u,
+ 1878895359u,
+ 2047260663u,
+ 3236801323u,
+ 1417182786u,
+ 2650291174u,
+ 541535507u,
+ 2050658788u,
+ 1497955566u,
+ 2322165653u,
+ 2177087336u,
+ 1286897331u,
+ 1168276780u,
+ 2296212785u,
+ 865258239u,
+ 1996766009u,
+ 2012854679u,
+ 1601388981u,
+ 2613134235u,
+ 1657591526u,
+ 2928355430u,
+ 3608354462u,
+ 744304148u,
+ 4205438799u,
+ 3436255438u,
+ 2852837451u,
+ 3546154475u,
+ 2198801660u,
+ 2941229067u,
+ 1725744406u,
+ 1576016233u,
+ 326273484u,
+ 3350602572u,
+ 2525026956u,
+ 529269391u,
+ 742537386u,
+ 966948684u,
+ 4207482684u,
+ 1647708147u,
+ 772473614u,
+ 4100132656u,
+ 2071821864u,
+ 1304991378u,
+ 2104686786u,
+ 494532571u,
+ 1596637043u,
+ 3530310572u,
+ 3844404338u,
+ 311529967u,
+ 2146085784u,
+ 1023590767u,
+ 3264294551u,
+ 1868912500u,
+ 1616049700u,
+ 4044971489u,
+ 226083499u,
+ 2644402452u,
+ 671262u,
+ 3856282165u,
+ 2788249556u,
+ 2975877350u,
+ 3022011519u,
+ 482463024u,
+ 3197313892u,
+ 2458947070u,
+ 213085732u,
+ 3423982376u,
+ 1127434251u,
+ 3003351323u,
+ 3859782824u,
+ 1452447943u,
+ 1377205388u,
+ 294467710u,
+ 4017757977u,
+ 4176004933u,
+ 1973840971u,
+ 1057204069u,
+ 2631053578u,
+ 1518315828u,
+ 1733084351u,
+ 2897935365u,
+ 371135589u,
+ 2166429075u,
+ 1316999184u,
+ 917942378u,
+ 4234919037u,
+ 3994887147u,
+ 202839671u,
+ 2611806597u,
+ 1763402132u,
+ 2528354843u,
+ 2928374144u,
+ 4287461088u,
+ 3374274817u,
+ 2515840515u,
+ 1174711579u,
+ 1526125414u,
+ 1328334421u,
+ 1467789564u,
+ 746112865u,
+ 2522923249u,
+ 2846786366u,
+ 785624778u,
+ 3640382502u,
+ 699425627u,
+ 2333340032u,
+ 879149811u,
+ 1012137370u,
+ 3671295088u,
+ 1115225691u,
+ 2008076767u,
+ 3224593008u,
+ 409074767u,
+ 3405081375u,
+ 1732184447u,
+ 4131742042u,
+ 2887579728u,
+ 411122719u,
+ 49575303u,
+ 2452487329u,
+ 132404436u,
+ 2634269867u,
+ 628865612u,
+ 2089064207u,
+ 3493619675u,
+ 573570698u,
+ 2803401952u,
+ 1846326706u,
+ 2776480783u,
+ 3202282367u,
+ 161406647u,
+ 555882857u,
+ 3002347158u,
+ 3646590134u,
+ 3970439001u,
+ 3593229755u,
+ 589030935u,
+ 1156189491u,
+ 4233262968u,
+ 1884160487u,
+ 1538393768u,
+ 2259575756u,
+ 1419917258u,
+ 658738179u,
+ 2762821193u,
+ 3753817926u,
+ 760570680u,
+ 900223123u,
+ 3199204483u,
+ 3152387802u,
+ 3518662321u,
+ 1138026800u,
+ 4166103824u,
+ 4256962887u,
+ 3860671603u,
+ 2476911454u,
+ 336216996u,
+ 708885235u,
+ 725397672u,
+ 1803116762u,
+ 2785555576u,
+ 101740015u,
+ 4078718445u,
+ 1955237214u,
+ 9650972u,
+ 449296169u,
+ 584729435u,
+ 3295180521u,
+ 589654348u,
+ 4256205129u,
+ 3872811168u,
+ 1159848257u,
+ 3914402308u,
+ 739056677u,
+ 2654817235u,
+ 2975781832u,
+ 2945335776u,
+ 2792662538u,
+ 4124362519u,
+ 1578034244u,
+ 347127450u,
+ 818851140u,
+ 2127100315u,
+ 2486499071u,
+ 4198130806u,
+ 1869105609u,
+ 1961961717u,
+ 1651285423u,
+ 376774848u,
+ 2681263019u,
+ 1185959234u,
+ 1674813864u,
+ 32812913u,
+ 3511671436u,
+ 3250344299u,
+ 2961919237u,
+ 722029715u,
+ 3677835234u,
+ 3534013806u,
+ 2896926420u,
+ 2405611392u,
+ 1523923100u,
+ 538451356u,
+ 2872548905u,
+ 3122230170u,
+ 337087364u,
+ 2659340735u,
+ 3849128055u,
+ 556114376u,
+ 1997152544u,
+ 3761450839u,
+ 3143779940u,
+ 3256759779u,
+ 2844565122u,
+ 228442897u,
+ 3589092287u,
+ 786119294u,
+ 4089515771u,
+ 3720982051u,
+ 1236422652u,
+ 2002271241u,
+ 98809947u,
+ 1925281885u,
+ 3856119646u,
+ 3522402037u,
+ 2119723860u,
+ 3500067577u,
+ 3688915105u,
+ 443441159u,
+ 1795715271u,
+ 2772968214u,
+ 921416086u,
+ 4274010930u,
+ 3123194886u,
+ 4156595625u,
+ 2153773382u,
+ 1880645824u,
+ 1783695477u,
+ 2639075904u,
+ 2369609874u,
+ 2020298024u,
+ 3035677150u,
+ 20152938u,
+ 3700162244u,
+ 2301383878u,
+ 704787941u,
+ 1912605772u,
+ 801557569u,
+ 3080244537u,
+ 2116665331u,
+ 2452111071u,
+ 3506260614u,
+ 862540580u,
+ 1275699972u,
+ 66210903u,
+ 106773917u,
+ 3693457478u,
+ 2402783622u,
+ 1239121180u,
+ 676003037u,
+ 2603048829u,
+ 1725001637u,
+ 1220274379u,
+ 24507488u,
+ 903764486u,
+ 4189545897u,
+ 1702746631u,
+ 3218068652u,
+ 3306659191u,
+ 790973134u,
+ 1265526960u,
+ 3431804268u,
+ 3325211765u,
+ 3605213000u,
+ 2877687268u,
+ 2252987926u,
+ 2380945092u,
+ 858624424u,
+ 1002964636u,
+ 1862801950u,
+ 1624111941u,
+ 2506763607u,
+ 760658520u,
+ 2734479345u,
+ 3411969548u,
+ 771362694u,
+ 3655222003u,
+ 2713412965u,
+ 2617767046u,
+ 1779451182u,
+ 3696950253u,
+ 1494085808u,
+ 1423735456u,
+ 800705781u,
+ 3797847307u,
+ 3518984231u,
+ 196474988u,
+ 1813335502u,
+ 2243046583u,
+ 2578707704u,
+ 2592488572u,
+ 4085007200u,
+ 3609770110u,
+ 2731535571u,
+ 3190540952u,
+ 1865257805u,
+ 1804143221u,
+ 3166875197u,
+ 1184225570u,
+ 2013135819u,
+ 3678444101u,
+ 2569887572u,
+ 3559018477u,
+ 3823772506u,
+ 1537738480u,
+ 713705243u,
+ 792081862u,
+ 1581340885u,
+ 3140030205u,
+ 3435723625u,
+ 3093218524u,
+ 3683643763u,
+ 753869336u,
+ 590258834u,
+ 608176704u,
+ 180732483u,
+ 31365344u,
+ 29753898u,
+ 2899243456u,
+ 1020423361u,
+ 152655309u,
+ 3809554076u,
+ 2069071231u,
+ 4000441303u,
+ 3046501174u,
+ 1897816893u,
+ 1610689080u,
+ 2580357110u,
+ 255270539u,
+ 3363490012u,
+ 3711397066u,
+ 3983751767u,
+ 1725231855u,
+ 172296475u,
+ 2179003295u,
+ 660196982u,
+ 526538193u,
+ 2137670317u,
+ 2219075701u,
+ 1987239722u,
+ 856404486u,
+ 2976933454u,
+ 3678014122u,
+ 2713682703u,
+ 3329090001u,
+ 2248358519u,
+ 3254616418u,
+ 1747030903u,
+ 1620566606u,
+ 880370315u,
+ 2337236788u,
+ 2883145755u
+ };
+ const int n = 768;
+ unsigned b[n] = {0};
+ unsigned v[] = {3, 5, 7};
+ const int size = sizeof(v)/sizeof(v[0]);
+ std::seed_seq s(v, v + size);
+ s.generate(b, b + n);
+ for (int i = 0; i < n; ++i)
+ assert(a[i] == b[i]);
+ }
+}
diff --git a/test/std/numerics/rand/rand.util/rand.util.seedseq/initializer_list.pass.cpp b/test/std/numerics/rand/rand.util/rand.util.seedseq/initializer_list.pass.cpp
new file mode 100644
index 000000000000..d4ee9c14d528
--- /dev/null
+++ b/test/std/numerics/rand/rand.util/rand.util.seedseq/initializer_list.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class seed_seq;
+
+// template<class T>
+// seed_seq(initializer_list<T> il);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ std::seed_seq s= {5, 4, 3, 2, 1};
+ assert(s.size() == 5);
+ unsigned b[5] = {0};
+ s.param(b);
+ assert(b[0] == 5);
+ assert(b[1] == 4);
+ assert(b[2] == 3);
+ assert(b[3] == 2);
+ assert(b[4] == 1);
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/numerics/rand/rand.util/rand.util.seedseq/iterator.pass.cpp b/test/std/numerics/rand/rand.util/rand.util.seedseq/iterator.pass.cpp
new file mode 100644
index 000000000000..2214dca8aea8
--- /dev/null
+++ b/test/std/numerics/rand/rand.util/rand.util.seedseq/iterator.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class seed_seq;
+
+// template<class InputIterator>
+// seed_seq(InputIterator begin, InputIterator end);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ unsigned a[5] = {5, 4, 3, 2, 1};
+ std::seed_seq s(a, a+5);
+ assert(s.size() == 5);
+ unsigned b[5] = {0};
+ s.param(b);
+ assert(b[0] == 5);
+ assert(b[1] == 4);
+ assert(b[2] == 3);
+ assert(b[3] == 2);
+ assert(b[4] == 1);
+}
diff --git a/test/std/numerics/rand/rand.util/rand.util.seedseq/types.pass.cpp b/test/std/numerics/rand/rand.util/rand.util.seedseq/types.pass.cpp
new file mode 100644
index 000000000000..430d9b781d2b
--- /dev/null
+++ b/test/std/numerics/rand/rand.util/rand.util.seedseq/types.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class seed_seq
+// {
+// public:
+// // types
+// typedef uint_least32_t result_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_same<std::seed_seq::result_type, std::uint_least32_t>::value), "");
+}
diff --git a/test/std/re/nothing_to_do.pass.cpp b/test/std/re/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/re/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/re/re.alg/nothing_to_do.pass.cpp b/test/std/re/re.alg/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/re/re.alg/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/re/re.alg/re.alg.match/awk.pass.cpp b/test/std/re/re.alg/re.alg.match/awk.pass.cpp
new file mode 100644
index 000000000000..e4b2f3ec5014
--- /dev/null
+++ b/test/std/re/re.alg/re.alg.match/awk.pass.cpp
@@ -0,0 +1,1390 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class BidirectionalIterator, class Allocator, class charT,
+// class traits>
+// bool regex_match(BidirectionalIterator first, BidirectionalIterator last,
+// match_results<BidirectionalIterator, Allocator>& m,
+// const basic_regex<charT, traits>& e,
+// regex_constants::match_flag_type flags
+// = regex_constants::match_default);
+
+#include <regex>
+#include <cassert>
+#include "test_iterators.h"
+
+#include "platform_support.h" // locale name macros
+
+int main()
+{
+/* {
+ std::cmatch m;
+ const char s[] = "a";
+ assert(std::regex_match(s, m, std::regex("a", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.empty());
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+1);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "a");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ab";
+ assert(std::regex_match(s, m, std::regex("ab", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+2);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "ab");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ab";
+ assert(!std::regex_match(s, m, std::regex("ba", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ assert(m.empty());
+ }
+ {
+ std::cmatch m;
+ const char s[] = "aab";
+ assert(!std::regex_match(s, m, std::regex("ab", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "aab";
+ assert(!std::regex_match(s, m, std::regex("ab", std::regex_constants::awk),
+ std::regex_constants::match_continuous));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcd";
+ assert(!std::regex_match(s, m, std::regex("bc", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbc";
+ assert(std::regex_match(s, m, std::regex("ab*c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ababc";
+ assert(std::regex_match(s, m, std::regex("(ab)*c", std::regex_constants::awk)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+5);
+ assert(m.length(0) == 5);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 2);
+ assert(m.position(1) == 2);
+ assert(m.str(1) == "ab");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcdefghijk";
+ assert(!std::regex_match(s, m, std::regex("cd((e)fg)hi",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abc";
+ assert(std::regex_match(s, m, std::regex("^abc", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcd";
+ assert(!std::regex_match(s, m, std::regex("^abc", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "aabc";
+ assert(!std::regex_match(s, m, std::regex("^abc", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abc";
+ assert(std::regex_match(s, m, std::regex("abc$", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "efabc";
+ assert(!std::regex_match(s, m, std::regex("abc$", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "efabcg";
+ assert(!std::regex_match(s, m, std::regex("abc$", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abc";
+ assert(std::regex_match(s, m, std::regex("a.c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "acc";
+ assert(std::regex_match(s, m, std::regex("a.c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "acc";
+ assert(std::regex_match(s, m, std::regex("a.c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcdef";
+ assert(std::regex_match(s, m, std::regex("(.*).*", std::regex_constants::awk)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+6);
+ assert(m.length(0) == 6);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 6);
+ assert(m.position(1) == 0);
+ assert(m.str(1) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "bc";
+ assert(!std::regex_match(s, m, std::regex("(a*)*", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbc";
+ assert(!std::regex_match(s, m, std::regex("ab{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbc";
+ assert(std::regex_match(s, m, std::regex("ab{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbbc";
+ assert(std::regex_match(s, m, std::regex("ab{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbbbc";
+ assert(std::regex_match(s, m, std::regex("ab{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefc";
+ assert(!std::regex_match(s, m, std::regex("ab{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbbbbc";
+ assert(!std::regex_match(s, m, std::regex("ab{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adec";
+ assert(!std::regex_match(s, m, std::regex("a.{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefc";
+ assert(std::regex_match(s, m, std::regex("a.{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefgc";
+ assert(std::regex_match(s, m, std::regex("a.{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefghc";
+ assert(std::regex_match(s, m, std::regex("a.{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefghic";
+ assert(!std::regex_match(s, m, std::regex("a.{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "tournament";
+ assert(std::regex_match(s, m, std::regex("tour|to|tournament",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "tournamenttotour";
+ assert(std::regex_match(s, m, std::regex("(tour|to|tournament)+",
+ std::regex_constants::awk | std::regex_constants::nosubs)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ttotour";
+ assert(std::regex_match(s, m, std::regex("(tour|to|t)+",
+ std::regex_constants::awk)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 4);
+ assert(m.position(1) == 3);
+ assert(m.str(1) == "tour");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "-ab,ab-";
+ assert(!std::regex_match(s, m, std::regex("-(.*),\1-", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "-ab,ab-";
+ assert(std::regex_match(s, m, std::regex("-.*,.*-", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "a";
+ assert(std::regex_match(s, m, std::regex("^[a]$",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "a");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "a";
+ assert(std::regex_match(s, m, std::regex("^[ab]$",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "a");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "c";
+ assert(std::regex_match(s, m, std::regex("^[a-f]$",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "g";
+ assert(!std::regex_match(s, m, std::regex("^[a-f]$",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "Iraqi";
+ assert(!std::regex_match(s, m, std::regex("q[^u]",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "Iraq";
+ assert(!std::regex_match(s, m, std::regex("q[^u]",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AmB";
+ assert(std::regex_match(s, m, std::regex("A[[:lower:]]B",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AMB";
+ assert(!std::regex_match(s, m, std::regex("A[[:lower:]]B",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AMB";
+ assert(std::regex_match(s, m, std::regex("A[^[:lower:]]B",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AmB";
+ assert(!std::regex_match(s, m, std::regex("A[^[:lower:]]B",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "A5B";
+ assert(!std::regex_match(s, m, std::regex("A[^[:lower:]0-9]B",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "A?B";
+ assert(std::regex_match(s, m, std::regex("A[^[:lower:]0-9]B",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "-";
+ assert(std::regex_match(s, m, std::regex("[a[.hyphen.]z]",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "z";
+ assert(std::regex_match(s, m, std::regex("[a[.hyphen.]z]",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "m";
+ assert(!std::regex_match(s, m, std::regex("[a[.hyphen.]z]",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ std::locale::global(std::locale(LOCALE_cs_CZ_ISO8859_2));
+*/ {
+ std::cmatch m;
+ const char s[] = "m";
+ /* assert(std::regex_match(s, m,*/ std::regex("[a[=M=]z]"/*,
+ std::regex_constants::awk*/);//));
+/* assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+*/ }
+/* {
+ std::cmatch m;
+ const char s[] = "Ch";
+ assert(std::regex_match(s, m, std::regex("[a[.ch.]z]",
+ std::regex_constants::awk | std::regex_constants::icase)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ std::locale::global(std::locale("C"));
+ {
+ std::cmatch m;
+ const char s[] = "m";
+ assert(!std::regex_match(s, m, std::regex("[a[=M=]z]",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "01a45cef9";
+ assert(!std::regex_match(s, m, std::regex("[ace1-9]*",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "01a45cef9";
+ assert(!std::regex_match(s, m, std::regex("[ace1-9]+",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ const char r[] = "^[-+]?[0-9]+[CF]$";
+ std::ptrdiff_t sr = std::char_traits<char>::length(r);
+ typedef forward_iterator<const char*> FI;
+ typedef bidirectional_iterator<const char*> BI;
+ std::regex regex(FI(r), FI(r+sr), std::regex_constants::awk);
+ std::match_results<BI> m;
+ const char s[] = "-40C";
+ std::ptrdiff_t ss = std::char_traits<char>::length(s);
+ assert(std::regex_match(BI(s), BI(s+ss), m, regex));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == BI(s));
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "\n\n\n";
+ assert(std::regex_match(s, m, std::regex("[\\n]+",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<char>::length(s));
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"a";
+ assert(std::regex_match(s, m, std::wregex(L"a", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.empty());
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+1);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"a");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ab";
+ assert(std::regex_match(s, m, std::wregex(L"ab", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+2);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"ab");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ab";
+ assert(!std::regex_match(s, m, std::wregex(L"ba", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ assert(m.empty());
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"aab";
+ assert(!std::regex_match(s, m, std::wregex(L"ab", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"aab";
+ assert(!std::regex_match(s, m, std::wregex(L"ab", std::regex_constants::awk),
+ std::regex_constants::match_continuous));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcd";
+ assert(!std::regex_match(s, m, std::wregex(L"bc", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbc";
+ assert(std::regex_match(s, m, std::wregex(L"ab*c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ababc";
+ assert(std::regex_match(s, m, std::wregex(L"(ab)*c", std::regex_constants::awk)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+5);
+ assert(m.length(0) == 5);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 2);
+ assert(m.position(1) == 2);
+ assert(m.str(1) == L"ab");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcdefghijk";
+ assert(!std::regex_match(s, m, std::wregex(L"cd((e)fg)hi",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abc";
+ assert(std::regex_match(s, m, std::wregex(L"^abc", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcd";
+ assert(!std::regex_match(s, m, std::wregex(L"^abc", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"aabc";
+ assert(!std::regex_match(s, m, std::wregex(L"^abc", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abc";
+ assert(std::regex_match(s, m, std::wregex(L"abc$", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"efabc";
+ assert(!std::regex_match(s, m, std::wregex(L"abc$", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"efabcg";
+ assert(!std::regex_match(s, m, std::wregex(L"abc$", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abc";
+ assert(std::regex_match(s, m, std::wregex(L"a.c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"acc";
+ assert(std::regex_match(s, m, std::wregex(L"a.c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"acc";
+ assert(std::regex_match(s, m, std::wregex(L"a.c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcdef";
+ assert(std::regex_match(s, m, std::wregex(L"(.*).*", std::regex_constants::awk)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+6);
+ assert(m.length(0) == 6);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 6);
+ assert(m.position(1) == 0);
+ assert(m.str(1) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"bc";
+ assert(!std::regex_match(s, m, std::wregex(L"(a*)*", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbc";
+ assert(!std::regex_match(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbc";
+ assert(std::regex_match(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbbc";
+ assert(std::regex_match(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbbbc";
+ assert(std::regex_match(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefc";
+ assert(!std::regex_match(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbbbbc";
+ assert(!std::regex_match(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adec";
+ assert(!std::regex_match(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefc";
+ assert(std::regex_match(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefgc";
+ assert(std::regex_match(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefghc";
+ assert(std::regex_match(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefghic";
+ assert(!std::regex_match(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"tournament";
+ assert(std::regex_match(s, m, std::wregex(L"tour|to|tournament",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"tournamenttotour";
+ assert(std::regex_match(s, m, std::wregex(L"(tour|to|tournament)+",
+ std::regex_constants::awk | std::regex_constants::nosubs)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ttotour";
+ assert(std::regex_match(s, m, std::wregex(L"(tour|to|t)+",
+ std::regex_constants::awk)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 4);
+ assert(m.position(1) == 3);
+ assert(m.str(1) == L"tour");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"-ab,ab-";
+ assert(!std::regex_match(s, m, std::wregex(L"-(.*),\1-", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"-ab,ab-";
+ assert(std::regex_match(s, m, std::wregex(L"-.*,.*-", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"a";
+ assert(std::regex_match(s, m, std::wregex(L"^[a]$",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"a");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"a";
+ assert(std::regex_match(s, m, std::wregex(L"^[ab]$",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"a");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"c";
+ assert(std::regex_match(s, m, std::wregex(L"^[a-f]$",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"g";
+ assert(!std::regex_match(s, m, std::wregex(L"^[a-f]$",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"Iraqi";
+ assert(!std::regex_match(s, m, std::wregex(L"q[^u]",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"Iraq";
+ assert(!std::regex_match(s, m, std::wregex(L"q[^u]",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AmB";
+ assert(std::regex_match(s, m, std::wregex(L"A[[:lower:]]B",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AMB";
+ assert(!std::regex_match(s, m, std::wregex(L"A[[:lower:]]B",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AMB";
+ assert(std::regex_match(s, m, std::wregex(L"A[^[:lower:]]B",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AmB";
+ assert(!std::regex_match(s, m, std::wregex(L"A[^[:lower:]]B",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"A5B";
+ assert(!std::regex_match(s, m, std::wregex(L"A[^[:lower:]0-9]B",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"A?B";
+ assert(std::regex_match(s, m, std::wregex(L"A[^[:lower:]0-9]B",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"-";
+ assert(std::regex_match(s, m, std::wregex(L"[a[.hyphen.]z]",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"z";
+ assert(std::regex_match(s, m, std::wregex(L"[a[.hyphen.]z]",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(!std::regex_match(s, m, std::wregex(L"[a[.hyphen.]z]",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ std::locale::global(std::locale(LOCALE_cs_CZ_ISO8859_2));
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(std::regex_match(s, m, std::wregex(L"[a[=M=]z]",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"Ch";
+ assert(std::regex_match(s, m, std::wregex(L"[a[.ch.]z]",
+ std::regex_constants::awk | std::regex_constants::icase)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ std::locale::global(std::locale("C"));
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(!std::regex_match(s, m, std::wregex(L"[a[=M=]z]",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"01a45cef9";
+ assert(!std::regex_match(s, m, std::wregex(L"[ace1-9]*",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"01a45cef9";
+ assert(!std::regex_match(s, m, std::wregex(L"[ace1-9]+",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ const wchar_t r[] = L"^[-+]?[0-9]+[CF]$";
+ std::ptrdiff_t sr = std::char_traits<wchar_t>::length(r);
+ typedef forward_iterator<const wchar_t*> FI;
+ typedef bidirectional_iterator<const wchar_t*> BI;
+ std::wregex regex(FI(r), FI(r+sr), std::regex_constants::awk);
+ std::match_results<BI> m;
+ const wchar_t s[] = L"-40C";
+ std::ptrdiff_t ss = std::char_traits<wchar_t>::length(s);
+ assert(std::regex_match(BI(s), BI(s+ss), m, regex));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == BI(s));
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"\n\n\n";
+ assert(std::regex_match(s, m, std::wregex(L"[\\n]+",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<wchar_t>::length(s));
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+*/}
diff --git a/test/std/re/re.alg/re.alg.match/basic.fail.cpp b/test/std/re/re.alg/re.alg.match/basic.fail.cpp
new file mode 100644
index 000000000000..82f8e3b7ee89
--- /dev/null
+++ b/test/std/re/re.alg/re.alg.match/basic.fail.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class ST, class SA, class Allocator, class charT, class traits>
+// bool regex_match(const basic_string<charT, ST, SA>&&,
+// match_results<
+// typename basic_string<charT, ST, SA>::const_iterator,
+// Allocator>&,
+// const basic_regex<charT, traits>&,
+// regex_constants::match_flag_type =
+// regex_constants::match_default) = delete;
+
+#if __cplusplus <= 201402L
+#error
+#else
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ std::smatch m;
+ std::regex re{"*"};
+ std::regex_match(std::string("abcde"), m, re);
+ }
+}
+#endif
diff --git a/test/std/re/re.alg/re.alg.match/basic.pass.cpp b/test/std/re/re.alg/re.alg.match/basic.pass.cpp
new file mode 100644
index 000000000000..2ddc07a2000f
--- /dev/null
+++ b/test/std/re/re.alg/re.alg.match/basic.pass.cpp
@@ -0,0 +1,1367 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: locale.cs_CZ.ISO8859-2
+
+// <regex>
+
+// template <class BidirectionalIterator, class Allocator, class charT, class traits>
+// bool
+// regex_match(BidirectionalIterator first, BidirectionalIterator last,
+// match_results<BidirectionalIterator, Allocator>& m,
+// const basic_regex<charT, traits>& e,
+// regex_constants::match_flag_type flags = regex_constants::match_default);
+
+// TODO: investigation needed
+// XFAIL: linux-gnu
+
+#include <regex>
+#include <cassert>
+#include "test_iterators.h"
+
+#include "platform_support.h" // locale name macros
+
+int main()
+{
+ {
+ std::cmatch m;
+ assert(!std::regex_match("a", m, std::regex()));
+ assert(m.size() == 0);
+ assert(m.empty());
+ }
+ {
+ std::cmatch m;
+ const char s[] = "a";
+ assert(std::regex_match(s, m, std::regex("a", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.empty());
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+1);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "a");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ab";
+ assert(std::regex_match(s, m, std::regex("ab", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+2);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "ab");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ab";
+ assert(!std::regex_match(s, m, std::regex("ba", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ assert(m.empty());
+ }
+ {
+ std::cmatch m;
+ const char s[] = "aab";
+ assert(!std::regex_match(s, m, std::regex("ab", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "aab";
+ assert(!std::regex_match(s, m, std::regex("ab", std::regex_constants::basic),
+ std::regex_constants::match_continuous));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcd";
+ assert(!std::regex_match(s, m, std::regex("bc", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbc";
+ assert(std::regex_match(s, m, std::regex("ab*c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ababc";
+ assert(std::regex_match(s, m, std::regex("\\(ab\\)*c", std::regex_constants::basic)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+5);
+ assert(m.length(0) == 5);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 2);
+ assert(m.position(1) == 2);
+ assert(m.str(1) == "ab");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcdefghijk";
+ assert(!std::regex_match(s, m, std::regex("cd\\(\\(e\\)fg\\)hi",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abc";
+ assert(std::regex_match(s, m, std::regex("^abc", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcd";
+ assert(!std::regex_match(s, m, std::regex("^abc", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "aabc";
+ assert(!std::regex_match(s, m, std::regex("^abc", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abc";
+ assert(std::regex_match(s, m, std::regex("abc$", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "efabc";
+ assert(!std::regex_match(s, m, std::regex("abc$", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "efabcg";
+ assert(!std::regex_match(s, m, std::regex("abc$", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abc";
+ assert(std::regex_match(s, m, std::regex("a.c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "acc";
+ assert(std::regex_match(s, m, std::regex("a.c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "acc";
+ assert(std::regex_match(s, m, std::regex("a.c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcdef";
+ assert(std::regex_match(s, m, std::regex("\\(.*\\).*", std::regex_constants::basic)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+6);
+ assert(m.length(0) == 6);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 6);
+ assert(m.position(1) == 0);
+ assert(m.str(1) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "bc";
+ assert(!std::regex_match(s, m, std::regex("\\(a*\\)*", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbc";
+ assert(!std::regex_match(s, m, std::regex("ab\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbc";
+ assert(std::regex_match(s, m, std::regex("ab\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == sizeof(s)-1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbbc";
+ assert(std::regex_match(s, m, std::regex("ab\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == sizeof(s)-1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbbbc";
+ assert(std::regex_match(s, m, std::regex("ab\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == sizeof(s)-1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefc";
+ assert(!std::regex_match(s, m, std::regex("ab\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbbbbc";
+ assert(!std::regex_match(s, m, std::regex("ab\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adec";
+ assert(!std::regex_match(s, m, std::regex("a.\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefc";
+ assert(std::regex_match(s, m, std::regex("a.\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == sizeof(s)-1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefgc";
+ assert(std::regex_match(s, m, std::regex("a.\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == sizeof(s)-1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefghc";
+ assert(std::regex_match(s, m, std::regex("a.\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == sizeof(s)-1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefghic";
+ assert(!std::regex_match(s, m, std::regex("a.\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "-ab,ab-";
+ assert(std::regex_match(s, m, std::regex("-\\(.*\\),\\1-", std::regex_constants::basic)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 2);
+ assert(m.position(1) == 1);
+ assert(m.str(1) == "ab");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ababbabb";
+ assert(std::regex_match(s, m, std::regex("^\\(ab*\\)*\\1$", std::regex_constants::basic)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 3);
+ assert(m.position(1) == 2);
+ assert(m.str(1) == "abb");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ababbab";
+ assert(!std::regex_match(s, m, std::regex("^\\(ab*\\)*\\1$", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "aBAbbAbB";
+ assert(std::regex_match(s, m, std::regex("^\\(Ab*\\)*\\1$",
+ std::regex_constants::basic | std::regex_constants::icase)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 3);
+ assert(m.position(1) == 2);
+ assert(m.str(1) == "Abb");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "aBAbbAbB";
+ assert(!std::regex_match(s, m, std::regex("^\\(Ab*\\)*\\1$",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "a";
+ assert(std::regex_match(s, m, std::regex("^[a]$",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "a");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "a";
+ assert(std::regex_match(s, m, std::regex("^[ab]$",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "a");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "c";
+ assert(std::regex_match(s, m, std::regex("^[a-f]$",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "g";
+ assert(!std::regex_match(s, m, std::regex("^[a-f]$",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "Iraqi";
+ assert(!std::regex_match(s, m, std::regex("q[^u]",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "Iraq";
+ assert(!std::regex_match(s, m, std::regex("q[^u]",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AmB";
+ assert(std::regex_match(s, m, std::regex("A[[:lower:]]B",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AMB";
+ assert(!std::regex_match(s, m, std::regex("A[[:lower:]]B",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AMB";
+ assert(std::regex_match(s, m, std::regex("A[^[:lower:]]B",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AmB";
+ assert(!std::regex_match(s, m, std::regex("A[^[:lower:]]B",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "A5B";
+ assert(!std::regex_match(s, m, std::regex("A[^[:lower:]0-9]B",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "A?B";
+ assert(std::regex_match(s, m, std::regex("A[^[:lower:]0-9]B",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "-";
+ assert(std::regex_match(s, m, std::regex("[a[.hyphen.]z]",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "z";
+ assert(std::regex_match(s, m, std::regex("[a[.hyphen.]z]",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "m";
+ assert(!std::regex_match(s, m, std::regex("[a[.hyphen.]z]",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ std::locale::global(std::locale(LOCALE_cs_CZ_ISO8859_2));
+ {
+ std::cmatch m;
+ const char s[] = "m";
+ assert(std::regex_match(s, m, std::regex("[a[=M=]z]",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "Ch";
+ assert(std::regex_match(s, m, std::regex("[a[.ch.]z]",
+ std::regex_constants::basic | std::regex_constants::icase)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ std::locale::global(std::locale("C"));
+ {
+ std::cmatch m;
+ const char s[] = "m";
+ assert(!std::regex_match(s, m, std::regex("[a[=M=]z]",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "01a45cef9";
+ assert(!std::regex_match(s, m, std::regex("[ace1-9]*",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "01a45cef9";
+ assert(!std::regex_match(s, m, std::regex("[ace1-9]\\{1,\\}",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ const char r[] = "^[-+]\\{0,1\\}[0-9]\\{1,\\}[CF]$";
+ std::ptrdiff_t sr = std::char_traits<char>::length(r);
+ typedef forward_iterator<const char*> FI;
+ typedef bidirectional_iterator<const char*> BI;
+ std::regex regex(FI(r), FI(r+sr), std::regex_constants::basic);
+ std::match_results<BI> m;
+ const char s[] = "-40C";
+ std::ptrdiff_t ss = std::char_traits<char>::length(s);
+ assert(std::regex_match(BI(s), BI(s+ss), m, regex));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == BI(s));
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+
+ {
+ std::wcmatch m;
+ assert(!std::regex_match(L"a", m, std::wregex()));
+ assert(m.size() == 0);
+ assert(m.empty());
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"a";
+ assert(std::regex_match(s, m, std::wregex(L"a", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.empty());
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+1);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"a");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ab";
+ assert(std::regex_match(s, m, std::wregex(L"ab", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+2);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"ab");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ab";
+ assert(!std::regex_match(s, m, std::wregex(L"ba", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ assert(m.empty());
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"aab";
+ assert(!std::regex_match(s, m, std::wregex(L"ab", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"aab";
+ assert(!std::regex_match(s, m, std::wregex(L"ab", std::regex_constants::basic),
+ std::regex_constants::match_continuous));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcd";
+ assert(!std::regex_match(s, m, std::wregex(L"bc", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbc";
+ assert(std::regex_match(s, m, std::wregex(L"ab*c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ababc";
+ assert(std::regex_match(s, m, std::wregex(L"\\(ab\\)*c", std::regex_constants::basic)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+5);
+ assert(m.length(0) == 5);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 2);
+ assert(m.position(1) == 2);
+ assert(m.str(1) == L"ab");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcdefghijk";
+ assert(!std::regex_match(s, m, std::wregex(L"cd\\(\\(e\\)fg\\)hi",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abc";
+ assert(std::regex_match(s, m, std::wregex(L"^abc", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcd";
+ assert(!std::regex_match(s, m, std::wregex(L"^abc", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"aabc";
+ assert(!std::regex_match(s, m, std::wregex(L"^abc", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abc";
+ assert(std::regex_match(s, m, std::wregex(L"abc$", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"efabc";
+ assert(!std::regex_match(s, m, std::wregex(L"abc$", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"efabcg";
+ assert(!std::regex_match(s, m, std::wregex(L"abc$", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abc";
+ assert(std::regex_match(s, m, std::wregex(L"a.c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"acc";
+ assert(std::regex_match(s, m, std::wregex(L"a.c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"acc";
+ assert(std::regex_match(s, m, std::wregex(L"a.c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcdef";
+ assert(std::regex_match(s, m, std::wregex(L"\\(.*\\).*", std::regex_constants::basic)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+6);
+ assert(m.length(0) == 6);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 6);
+ assert(m.position(1) == 0);
+ assert(m.str(1) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"bc";
+ assert(!std::regex_match(s, m, std::wregex(L"\\(a*\\)*", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbc";
+ assert(!std::regex_match(s, m, std::wregex(L"ab\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbc";
+ assert(std::regex_match(s, m, std::wregex(L"ab\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbbc";
+ assert(std::regex_match(s, m, std::wregex(L"ab\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbbbc";
+ assert(std::regex_match(s, m, std::wregex(L"ab\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefc";
+ assert(!std::regex_match(s, m, std::wregex(L"ab\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbbbbc";
+ assert(!std::regex_match(s, m, std::wregex(L"ab\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adec";
+ assert(!std::regex_match(s, m, std::wregex(L"a.\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefc";
+ assert(std::regex_match(s, m, std::wregex(L"a.\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefgc";
+ assert(std::regex_match(s, m, std::wregex(L"a.\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefghc";
+ assert(std::regex_match(s, m, std::wregex(L"a.\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefghic";
+ assert(!std::regex_match(s, m, std::wregex(L"a.\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"-ab,ab-";
+ assert(std::regex_match(s, m, std::wregex(L"-\\(.*\\),\\1-", std::regex_constants::basic)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 2);
+ assert(m.position(1) == 1);
+ assert(m.str(1) == L"ab");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ababbabb";
+ assert(std::regex_match(s, m, std::wregex(L"^\\(ab*\\)*\\1$", std::regex_constants::basic)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 3);
+ assert(m.position(1) == 2);
+ assert(m.str(1) == L"abb");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ababbab";
+ assert(!std::regex_match(s, m, std::wregex(L"^\\(ab*\\)*\\1$", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"aBAbbAbB";
+ assert(std::regex_match(s, m, std::wregex(L"^\\(Ab*\\)*\\1$",
+ std::regex_constants::basic | std::regex_constants::icase)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 3);
+ assert(m.position(1) == 2);
+ assert(m.str(1) == L"Abb");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"aBAbbAbB";
+ assert(!std::regex_match(s, m, std::wregex(L"^\\(Ab*\\)*\\1$",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"a";
+ assert(std::regex_match(s, m, std::wregex(L"^[a]$",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"a");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"a";
+ assert(std::regex_match(s, m, std::wregex(L"^[ab]$",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"a");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"c";
+ assert(std::regex_match(s, m, std::wregex(L"^[a-f]$",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"g";
+ assert(!std::regex_match(s, m, std::wregex(L"^[a-f]$",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"Iraqi";
+ assert(!std::regex_match(s, m, std::wregex(L"q[^u]",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"Iraq";
+ assert(!std::regex_match(s, m, std::wregex(L"q[^u]",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AmB";
+ assert(std::regex_match(s, m, std::wregex(L"A[[:lower:]]B",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AMB";
+ assert(!std::regex_match(s, m, std::wregex(L"A[[:lower:]]B",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AMB";
+ assert(std::regex_match(s, m, std::wregex(L"A[^[:lower:]]B",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AmB";
+ assert(!std::regex_match(s, m, std::wregex(L"A[^[:lower:]]B",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"A5B";
+ assert(!std::regex_match(s, m, std::wregex(L"A[^[:lower:]0-9]B",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"A?B";
+ assert(std::regex_match(s, m, std::wregex(L"A[^[:lower:]0-9]B",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"-";
+ assert(std::regex_match(s, m, std::wregex(L"[a[.hyphen.]z]",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"z";
+ assert(std::regex_match(s, m, std::wregex(L"[a[.hyphen.]z]",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(!std::regex_match(s, m, std::wregex(L"[a[.hyphen.]z]",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ std::locale::global(std::locale(LOCALE_cs_CZ_ISO8859_2));
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(std::regex_match(s, m, std::wregex(L"[a[=M=]z]",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"Ch";
+ assert(std::regex_match(s, m, std::wregex(L"[a[.ch.]z]",
+ std::regex_constants::basic | std::regex_constants::icase)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ std::locale::global(std::locale("C"));
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(!std::regex_match(s, m, std::wregex(L"[a[=M=]z]",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"01a45cef9";
+ assert(!std::regex_match(s, m, std::wregex(L"[ace1-9]*",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"01a45cef9";
+ assert(!std::regex_match(s, m, std::wregex(L"[ace1-9]\\{1,\\}",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ const wchar_t r[] = L"^[-+]\\{0,1\\}[0-9]\\{1,\\}[CF]$";
+ std::ptrdiff_t sr = std::char_traits<wchar_t>::length(r);
+ typedef forward_iterator<const wchar_t*> FI;
+ typedef bidirectional_iterator<const wchar_t*> BI;
+ std::wregex regex(FI(r), FI(r+sr), std::regex_constants::basic);
+ std::match_results<BI> m;
+ const wchar_t s[] = L"-40C";
+ std::ptrdiff_t ss = std::char_traits<wchar_t>::length(s);
+ assert(std::regex_match(BI(s), BI(s+ss), m, regex));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == BI(s));
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+}
diff --git a/test/std/re/re.alg/re.alg.match/ecma.pass.cpp b/test/std/re/re.alg/re.alg.match/ecma.pass.cpp
new file mode 100644
index 000000000000..785a61c47f11
--- /dev/null
+++ b/test/std/re/re.alg/re.alg.match/ecma.pass.cpp
@@ -0,0 +1,1349 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: locale.cs_CZ.ISO8859-2
+
+// <regex>
+
+// template <class BidirectionalIterator, class Allocator, class charT, class traits>
+// bool
+// regex_match(BidirectionalIterator first, BidirectionalIterator last,
+// match_results<BidirectionalIterator, Allocator>& m,
+// const basic_regex<charT, traits>& e,
+// regex_constants::match_flag_type flags = regex_constants::match_default);
+
+// TODO: investigation needed
+// XFAIL: linux-gnu
+
+#include <regex>
+#include <cassert>
+#include "test_iterators.h"
+
+#include "platform_support.h" // locale name macros
+
+int main()
+{
+ {
+ std::cmatch m;
+ const char s[] = "a";
+ assert(std::regex_match(s, m, std::regex("a")));
+ assert(m.size() == 1);
+ assert(!m.empty());
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+1);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "a");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ab";
+ assert(std::regex_match(s, m, std::regex("ab")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+2);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "ab");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ab";
+ assert(!std::regex_match(s, m, std::regex("ba")));
+ assert(m.size() == 0);
+ assert(m.empty());
+ }
+ {
+ std::cmatch m;
+ const char s[] = "aab";
+ assert(!std::regex_match(s, m, std::regex("ab")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "aab";
+ assert(!std::regex_match(s, m, std::regex("ab"),
+ std::regex_constants::match_continuous));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcd";
+ assert(!std::regex_match(s, m, std::regex("bc")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbc";
+ assert(std::regex_match(s, m, std::regex("ab*c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ababc";
+ assert(std::regex_match(s, m, std::regex("(ab)*c")));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+5);
+ assert(m.length(0) == 5);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 2);
+ assert(m.position(1) == 2);
+ assert(m.str(1) == "ab");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcdefghijk";
+ assert(!std::regex_match(s, m, std::regex("cd((e)fg)hi")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abc";
+ assert(std::regex_match(s, m, std::regex("^abc")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcd";
+ assert(!std::regex_match(s, m, std::regex("^abc")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "aabc";
+ assert(!std::regex_match(s, m, std::regex("^abc")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abc";
+ assert(std::regex_match(s, m, std::regex("abc$")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "efabc";
+ assert(!std::regex_match(s, m, std::regex("abc$")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "efabcg";
+ assert(!std::regex_match(s, m, std::regex("abc$")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abc";
+ assert(std::regex_match(s, m, std::regex("a.c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "acc";
+ assert(std::regex_match(s, m, std::regex("a.c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "acc";
+ assert(std::regex_match(s, m, std::regex("a.c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcdef";
+ assert(std::regex_match(s, m, std::regex("(.*).*")));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+6);
+ assert(m.length(0) == 6);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 6);
+ assert(m.position(1) == 0);
+ assert(m.str(1) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "bc";
+ assert(!std::regex_match(s, m, std::regex("(a*)*")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbc";
+ assert(!std::regex_match(s, m, std::regex("ab{3,5}c")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbc";
+ assert(std::regex_match(s, m, std::regex("ab{3,5}c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbbc";
+ assert(std::regex_match(s, m, std::regex("ab{3,5}c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbbbc";
+ assert(std::regex_match(s, m, std::regex("ab{3,5}c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefc";
+ assert(!std::regex_match(s, m, std::regex("ab{3,5}c")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbbbbc";
+ assert(!std::regex_match(s, m, std::regex("ab{3,5}c")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adec";
+ assert(!std::regex_match(s, m, std::regex("a.{3,5}c")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefc";
+ assert(std::regex_match(s, m, std::regex("a.{3,5}c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefgc";
+ assert(std::regex_match(s, m, std::regex("a.{3,5}c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefghc";
+ assert(std::regex_match(s, m, std::regex("a.{3,5}c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefghic";
+ assert(!std::regex_match(s, m, std::regex("a.{3,5}c")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "tournament";
+ assert(!std::regex_match(s, m, std::regex("tour|to|tournament")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "tournamenttotour";
+ assert(!std::regex_match(s, m, std::regex("(tour|to|tournament)+",
+ std::regex_constants::nosubs)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ttotour";
+ assert(std::regex_match(s, m, std::regex("(tour|to|t)+")));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 4);
+ assert(m.position(1) == 3);
+ assert(m.str(1) == "tour");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "-ab,ab-";
+ assert(!std::regex_match(s, m, std::regex("-(.*),\1-")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "-ab,ab-";
+ assert(std::regex_match(s, m, std::regex("-.*,.*-")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "a";
+ assert(std::regex_match(s, m, std::regex("^[a]$")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "a");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "a";
+ assert(std::regex_match(s, m, std::regex("^[ab]$")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "a");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "c";
+ assert(std::regex_match(s, m, std::regex("^[a-f]$")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "g";
+ assert(!std::regex_match(s, m, std::regex("^[a-f]$")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "Iraqi";
+ assert(!std::regex_match(s, m, std::regex("q[^u]")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "Iraq";
+ assert(!std::regex_match(s, m, std::regex("q[^u]")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AmB";
+ assert(std::regex_match(s, m, std::regex("A[[:lower:]]B")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AMB";
+ assert(!std::regex_match(s, m, std::regex("A[[:lower:]]B")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AMB";
+ assert(std::regex_match(s, m, std::regex("A[^[:lower:]]B")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AmB";
+ assert(!std::regex_match(s, m, std::regex("A[^[:lower:]]B")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "A5B";
+ assert(!std::regex_match(s, m, std::regex("A[^[:lower:]0-9]B")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "A?B";
+ assert(std::regex_match(s, m, std::regex("A[^[:lower:]0-9]B")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "-";
+ assert(std::regex_match(s, m, std::regex("[a[.hyphen.]z]")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "z";
+ assert(std::regex_match(s, m, std::regex("[a[.hyphen.]z]")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "m";
+ assert(!std::regex_match(s, m, std::regex("[a[.hyphen.]z]")));
+ assert(m.size() == 0);
+ }
+ std::locale::global(std::locale(LOCALE_cs_CZ_ISO8859_2));
+ {
+ std::cmatch m;
+ const char s[] = "m";
+ assert(std::regex_match(s, m, std::regex("[a[=M=]z]")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "Ch";
+ assert(std::regex_match(s, m, std::regex("[a[.ch.]z]",
+ std::regex_constants::icase)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "foobar";
+ assert(std::regex_match(s, m, std::regex("[^\\0]*")));
+ assert(m.size() == 1);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "foo\0bar";
+ assert(std::regex_match(s, s+7, m, std::regex("[abfor\\0]*")));
+ assert(m.size() == 1);
+ }
+ std::locale::global(std::locale("C"));
+ {
+ std::cmatch m;
+ const char s[] = "m";
+ assert(!std::regex_match(s, m, std::regex("[a[=M=]z]")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "01a45cef9";
+ assert(!std::regex_match(s, m, std::regex("[ace1-9]*")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "01a45cef9";
+ assert(!std::regex_match(s, m, std::regex("[ace1-9]+")));
+ assert(m.size() == 0);
+ }
+ {
+ const char r[] = "^[-+]?[0-9]+[CF]$";
+ std::ptrdiff_t sr = std::char_traits<char>::length(r);
+ typedef forward_iterator<const char*> FI;
+ typedef bidirectional_iterator<const char*> BI;
+ std::regex regex(FI(r), FI(r+sr));
+ std::match_results<BI> m;
+ const char s[] = "-40C";
+ std::ptrdiff_t ss = std::char_traits<char>::length(s);
+ assert(std::regex_match(BI(s), BI(s+ss), m, regex));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == BI(s));
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "Jeff Jeffs ";
+ assert(!std::regex_match(s, m, std::regex("Jeff(?=s\\b)")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "Jeffs Jeff";
+ assert(!std::regex_match(s, m, std::regex("Jeff(?!s\\b)")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "5%k";
+ assert(std::regex_match(s, m, std::regex("\\d[\\W]k")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<char>::length(s));
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"a";
+ assert(std::regex_match(s, m, std::wregex(L"a")));
+ assert(m.size() == 1);
+ assert(!m.empty());
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+1);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"a");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ab";
+ assert(std::regex_match(s, m, std::wregex(L"ab")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+2);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"ab");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ab";
+ assert(!std::regex_match(s, m, std::wregex(L"ba")));
+ assert(m.size() == 0);
+ assert(m.empty());
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"aab";
+ assert(!std::regex_match(s, m, std::wregex(L"ab")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"aab";
+ assert(!std::regex_match(s, m, std::wregex(L"ab"),
+ std::regex_constants::match_continuous));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcd";
+ assert(!std::regex_match(s, m, std::wregex(L"bc")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbc";
+ assert(std::regex_match(s, m, std::wregex(L"ab*c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ababc";
+ assert(std::regex_match(s, m, std::wregex(L"(ab)*c")));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+5);
+ assert(m.length(0) == 5);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 2);
+ assert(m.position(1) == 2);
+ assert(m.str(1) == L"ab");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcdefghijk";
+ assert(!std::regex_match(s, m, std::wregex(L"cd((e)fg)hi")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abc";
+ assert(std::regex_match(s, m, std::wregex(L"^abc")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcd";
+ assert(!std::regex_match(s, m, std::wregex(L"^abc")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"aabc";
+ assert(!std::regex_match(s, m, std::wregex(L"^abc")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abc";
+ assert(std::regex_match(s, m, std::wregex(L"abc$")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"efabc";
+ assert(!std::regex_match(s, m, std::wregex(L"abc$")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"efabcg";
+ assert(!std::regex_match(s, m, std::wregex(L"abc$")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abc";
+ assert(std::regex_match(s, m, std::wregex(L"a.c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"acc";
+ assert(std::regex_match(s, m, std::wregex(L"a.c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"acc";
+ assert(std::regex_match(s, m, std::wregex(L"a.c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcdef";
+ assert(std::regex_match(s, m, std::wregex(L"(.*).*")));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+6);
+ assert(m.length(0) == 6);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 6);
+ assert(m.position(1) == 0);
+ assert(m.str(1) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"bc";
+ assert(!std::regex_match(s, m, std::wregex(L"(a*)*")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbc";
+ assert(!std::regex_match(s, m, std::wregex(L"ab{3,5}c")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbc";
+ assert(std::regex_match(s, m, std::wregex(L"ab{3,5}c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbbc";
+ assert(std::regex_match(s, m, std::wregex(L"ab{3,5}c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbbbc";
+ assert(std::regex_match(s, m, std::wregex(L"ab{3,5}c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefc";
+ assert(!std::regex_match(s, m, std::wregex(L"ab{3,5}c")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbbbbc";
+ assert(!std::regex_match(s, m, std::wregex(L"ab{3,5}c")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adec";
+ assert(!std::regex_match(s, m, std::wregex(L"a.{3,5}c")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefc";
+ assert(std::regex_match(s, m, std::wregex(L"a.{3,5}c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefgc";
+ assert(std::regex_match(s, m, std::wregex(L"a.{3,5}c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefghc";
+ assert(std::regex_match(s, m, std::wregex(L"a.{3,5}c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefghic";
+ assert(!std::regex_match(s, m, std::wregex(L"a.{3,5}c")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"tournament";
+ assert(!std::regex_match(s, m, std::wregex(L"tour|to|tournament")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"tournamenttotour";
+ assert(!std::regex_match(s, m, std::wregex(L"(tour|to|tournament)+",
+ std::regex_constants::nosubs)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ttotour";
+ assert(std::regex_match(s, m, std::wregex(L"(tour|to|t)+")));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 4);
+ assert(m.position(1) == 3);
+ assert(m.str(1) == L"tour");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"-ab,ab-";
+ assert(!std::regex_match(s, m, std::wregex(L"-(.*),\1-")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"-ab,ab-";
+ assert(std::regex_match(s, m, std::wregex(L"-.*,.*-")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"a";
+ assert(std::regex_match(s, m, std::wregex(L"^[a]$")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"a");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"a";
+ assert(std::regex_match(s, m, std::wregex(L"^[ab]$")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"a");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"c";
+ assert(std::regex_match(s, m, std::wregex(L"^[a-f]$")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"g";
+ assert(!std::regex_match(s, m, std::wregex(L"^[a-f]$")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"Iraqi";
+ assert(!std::regex_match(s, m, std::wregex(L"q[^u]")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"Iraq";
+ assert(!std::regex_match(s, m, std::wregex(L"q[^u]")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AmB";
+ assert(std::regex_match(s, m, std::wregex(L"A[[:lower:]]B")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AMB";
+ assert(!std::regex_match(s, m, std::wregex(L"A[[:lower:]]B")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AMB";
+ assert(std::regex_match(s, m, std::wregex(L"A[^[:lower:]]B")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AmB";
+ assert(!std::regex_match(s, m, std::wregex(L"A[^[:lower:]]B")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"A5B";
+ assert(!std::regex_match(s, m, std::wregex(L"A[^[:lower:]0-9]B")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"A?B";
+ assert(std::regex_match(s, m, std::wregex(L"A[^[:lower:]0-9]B")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"-";
+ assert(std::regex_match(s, m, std::wregex(L"[a[.hyphen.]z]")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"z";
+ assert(std::regex_match(s, m, std::wregex(L"[a[.hyphen.]z]")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(!std::regex_match(s, m, std::wregex(L"[a[.hyphen.]z]")));
+ assert(m.size() == 0);
+ }
+ std::locale::global(std::locale(LOCALE_cs_CZ_ISO8859_2));
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(std::regex_match(s, m, std::wregex(L"[a[=M=]z]")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"Ch";
+ assert(std::regex_match(s, m, std::wregex(L"[a[.ch.]z]",
+ std::regex_constants::icase)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ std::locale::global(std::locale("C"));
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(!std::regex_match(s, m, std::wregex(L"[a[=M=]z]")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"01a45cef9";
+ assert(!std::regex_match(s, m, std::wregex(L"[ace1-9]*")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"01a45cef9";
+ assert(!std::regex_match(s, m, std::wregex(L"[ace1-9]+")));
+ assert(m.size() == 0);
+ }
+ {
+ const wchar_t r[] = L"^[-+]?[0-9]+[CF]$";
+ std::ptrdiff_t sr = std::char_traits<wchar_t>::length(r);
+ typedef forward_iterator<const wchar_t*> FI;
+ typedef bidirectional_iterator<const wchar_t*> BI;
+ std::wregex regex(FI(r), FI(r+sr));
+ std::match_results<BI> m;
+ const wchar_t s[] = L"-40C";
+ std::ptrdiff_t ss = std::char_traits<wchar_t>::length(s);
+ assert(std::regex_match(BI(s), BI(s+ss), m, regex));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == BI(s));
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"Jeff Jeffs ";
+ assert(!std::regex_match(s, m, std::wregex(L"Jeff(?=s\\b)")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"Jeffs Jeff";
+ assert(!std::regex_match(s, m, std::wregex(L"Jeff(?!s\\b)")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"5%k";
+ assert(std::regex_match(s, m, std::wregex(L"\\d[\\W]k")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<wchar_t>::length(s));
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+}
diff --git a/test/std/re/re.alg/re.alg.match/egrep.pass.cpp b/test/std/re/re.alg/re.alg.match/egrep.pass.cpp
new file mode 100644
index 000000000000..dd2e6038dc31
--- /dev/null
+++ b/test/std/re/re.alg/re.alg.match/egrep.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class BidirectionalIterator, class Allocator, class charT, class traits>
+// bool
+// regex_match(BidirectionalIterator first, BidirectionalIterator last,
+// match_results<BidirectionalIterator, Allocator>& m,
+// const basic_regex<charT, traits>& e,
+// regex_constants::match_flag_type flags = regex_constants::match_default);
+
+#include <regex>
+#include <cassert>
+
+#include "test_iterators.h"
+
+int main()
+{
+ {
+ std::cmatch m;
+ const char s[] = "tournament";
+ assert(std::regex_match(s, m, std::regex("tour\nto\ntournament",
+ std::regex_constants::egrep)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<char>::length(s));
+ assert(m.length(0) == 10);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "tournament");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ment";
+ assert(!std::regex_match(s, m, std::regex("tour\n\ntournament",
+ std::regex_constants::egrep)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "tournament";
+ assert(std::regex_match(s, m, std::regex("(tour|to|tournament)+\ntourna",
+ std::regex_constants::egrep)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<char>::length(s));
+ assert(m.length(0) == 10);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "tournament");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "tourna";
+ assert(std::regex_match(s, m, std::regex("(tour|to|tournament)+\ntourna",
+ std::regex_constants::egrep)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<char>::length(s));
+ assert(m.length(0) == 6);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "tourna");
+ }
+}
diff --git a/test/std/re/re.alg/re.alg.match/extended.pass.cpp b/test/std/re/re.alg/re.alg.match/extended.pass.cpp
new file mode 100644
index 000000000000..9ca31d1814a6
--- /dev/null
+++ b/test/std/re/re.alg/re.alg.match/extended.pass.cpp
@@ -0,0 +1,1363 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: locale.cs_CZ.ISO8859-2
+
+// <regex>
+
+// template <class BidirectionalIterator, class Allocator, class charT, class traits>
+// bool
+// regex_match(BidirectionalIterator first, BidirectionalIterator last,
+// match_results<BidirectionalIterator, Allocator>& m,
+// const basic_regex<charT, traits>& e,
+// regex_constants::match_flag_type flags = regex_constants::match_default);
+
+// TODO: investigation needed
+// XFAIL: linux-gnu
+
+#include <regex>
+#include <cassert>
+#include "test_iterators.h"
+
+#include "platform_support.h" // locale name macros
+
+int main()
+{
+ {
+ std::cmatch m;
+ const char s[] = "a";
+ assert(std::regex_match(s, m, std::regex("a", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.empty());
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+1);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "a");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ab";
+ assert(std::regex_match(s, m, std::regex("ab", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+2);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "ab");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ab";
+ assert(!std::regex_match(s, m, std::regex("ba", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ assert(m.empty());
+ }
+ {
+ std::cmatch m;
+ const char s[] = "aab";
+ assert(!std::regex_match(s, m, std::regex("ab", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "aab";
+ assert(!std::regex_match(s, m, std::regex("ab", std::regex_constants::extended),
+ std::regex_constants::match_continuous));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcd";
+ assert(!std::regex_match(s, m, std::regex("bc", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbc";
+ assert(std::regex_match(s, m, std::regex("ab*c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ababc";
+ assert(std::regex_match(s, m, std::regex("(ab)*c", std::regex_constants::extended)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+5);
+ assert(m.length(0) == 5);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 2);
+ assert(m.position(1) == 2);
+ assert(m.str(1) == "ab");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcdefghijk";
+ assert(!std::regex_match(s, m, std::regex("cd((e)fg)hi",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abc";
+ assert(std::regex_match(s, m, std::regex("^abc", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcd";
+ assert(!std::regex_match(s, m, std::regex("^abc", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "aabc";
+ assert(!std::regex_match(s, m, std::regex("^abc", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abc";
+ assert(std::regex_match(s, m, std::regex("abc$", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "efabc";
+ assert(!std::regex_match(s, m, std::regex("abc$", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "efabcg";
+ assert(!std::regex_match(s, m, std::regex("abc$", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abc";
+ assert(std::regex_match(s, m, std::regex("a.c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "acc";
+ assert(std::regex_match(s, m, std::regex("a.c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "acc";
+ assert(std::regex_match(s, m, std::regex("a.c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcdef";
+ assert(std::regex_match(s, m, std::regex("(.*).*", std::regex_constants::extended)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+6);
+ assert(m.length(0) == 6);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 6);
+ assert(m.position(1) == 0);
+ assert(m.str(1) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "bc";
+ assert(!std::regex_match(s, m, std::regex("(a*)*", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbc";
+ assert(!std::regex_match(s, m, std::regex("ab{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbc";
+ assert(std::regex_match(s, m, std::regex("ab{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbbc";
+ assert(std::regex_match(s, m, std::regex("ab{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbbbc";
+ assert(std::regex_match(s, m, std::regex("ab{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefc";
+ assert(!std::regex_match(s, m, std::regex("ab{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbbbbc";
+ assert(!std::regex_match(s, m, std::regex("ab{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adec";
+ assert(!std::regex_match(s, m, std::regex("a.{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefc";
+ assert(std::regex_match(s, m, std::regex("a.{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefgc";
+ assert(std::regex_match(s, m, std::regex("a.{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefghc";
+ assert(std::regex_match(s, m, std::regex("a.{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefghic";
+ assert(!std::regex_match(s, m, std::regex("a.{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "tournament";
+ assert(std::regex_match(s, m, std::regex("tour|to|tournament",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "tournamenttotour";
+ assert(std::regex_match(s, m, std::regex("(tour|to|tournament)+",
+ std::regex_constants::extended | std::regex_constants::nosubs)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ttotour";
+ assert(std::regex_match(s, m, std::regex("(tour|to|t)+",
+ std::regex_constants::extended)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 4);
+ assert(m.position(1) == 3);
+ assert(m.str(1) == "tour");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "-ab,ab-";
+ assert(!std::regex_match(s, m, std::regex("-(.*),\1-", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "-ab,ab-";
+ assert(std::regex_match(s, m, std::regex("-.*,.*-", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "a";
+ assert(std::regex_match(s, m, std::regex("^[a]$",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "a");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "a";
+ assert(std::regex_match(s, m, std::regex("^[ab]$",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "a");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "c";
+ assert(std::regex_match(s, m, std::regex("^[a-f]$",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "g";
+ assert(!std::regex_match(s, m, std::regex("^[a-f]$",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "Iraqi";
+ assert(!std::regex_match(s, m, std::regex("q[^u]",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "Iraq";
+ assert(!std::regex_match(s, m, std::regex("q[^u]",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AmB";
+ assert(std::regex_match(s, m, std::regex("A[[:lower:]]B",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AMB";
+ assert(!std::regex_match(s, m, std::regex("A[[:lower:]]B",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AMB";
+ assert(std::regex_match(s, m, std::regex("A[^[:lower:]]B",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AmB";
+ assert(!std::regex_match(s, m, std::regex("A[^[:lower:]]B",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "A5B";
+ assert(!std::regex_match(s, m, std::regex("A[^[:lower:]0-9]B",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "A?B";
+ assert(std::regex_match(s, m, std::regex("A[^[:lower:]0-9]B",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "-";
+ assert(std::regex_match(s, m, std::regex("[a[.hyphen.]z]",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "z";
+ assert(std::regex_match(s, m, std::regex("[a[.hyphen.]z]",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "m";
+ assert(!std::regex_match(s, m, std::regex("[a[.hyphen.]z]",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ std::locale::global(std::locale(LOCALE_cs_CZ_ISO8859_2));
+ {
+ std::cmatch m;
+ const char s[] = "m";
+ assert(std::regex_match(s, m, std::regex("[a[=M=]z]",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "Ch";
+ assert(std::regex_match(s, m, std::regex("[a[.ch.]z]",
+ std::regex_constants::extended | std::regex_constants::icase)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ std::locale::global(std::locale("C"));
+ {
+ std::cmatch m;
+ const char s[] = "m";
+ assert(!std::regex_match(s, m, std::regex("[a[=M=]z]",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "01a45cef9";
+ assert(!std::regex_match(s, m, std::regex("[ace1-9]*",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "01a45cef9";
+ assert(!std::regex_match(s, m, std::regex("[ace1-9]+",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ const char r[] = "^[-+]?[0-9]+[CF]$";
+ std::ptrdiff_t sr = std::char_traits<char>::length(r);
+ typedef forward_iterator<const char*> FI;
+ typedef bidirectional_iterator<const char*> BI;
+ std::regex regex(FI(r), FI(r+sr), std::regex_constants::extended);
+ std::match_results<BI> m;
+ const char s[] = "-40C";
+ std::ptrdiff_t ss = std::char_traits<char>::length(s);
+ assert(std::regex_match(BI(s), BI(s+ss), m, regex));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == BI(s));
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"a";
+ assert(std::regex_match(s, m, std::wregex(L"a", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.empty());
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+1);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"a");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ab";
+ assert(std::regex_match(s, m, std::wregex(L"ab", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+2);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"ab");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ab";
+ assert(!std::regex_match(s, m, std::wregex(L"ba", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ assert(m.empty());
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"aab";
+ assert(!std::regex_match(s, m, std::wregex(L"ab", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"aab";
+ assert(!std::regex_match(s, m, std::wregex(L"ab", std::regex_constants::extended),
+ std::regex_constants::match_continuous));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcd";
+ assert(!std::regex_match(s, m, std::wregex(L"bc", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbc";
+ assert(std::regex_match(s, m, std::wregex(L"ab*c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ababc";
+ assert(std::regex_match(s, m, std::wregex(L"(ab)*c", std::regex_constants::extended)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+5);
+ assert(m.length(0) == 5);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 2);
+ assert(m.position(1) == 2);
+ assert(m.str(1) == L"ab");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcdefghijk";
+ assert(!std::regex_match(s, m, std::wregex(L"cd((e)fg)hi",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abc";
+ assert(std::regex_match(s, m, std::wregex(L"^abc", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcd";
+ assert(!std::regex_match(s, m, std::wregex(L"^abc", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"aabc";
+ assert(!std::regex_match(s, m, std::wregex(L"^abc", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abc";
+ assert(std::regex_match(s, m, std::wregex(L"abc$", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"efabc";
+ assert(!std::regex_match(s, m, std::wregex(L"abc$", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"efabcg";
+ assert(!std::regex_match(s, m, std::wregex(L"abc$", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abc";
+ assert(std::regex_match(s, m, std::wregex(L"a.c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"acc";
+ assert(std::regex_match(s, m, std::wregex(L"a.c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"acc";
+ assert(std::regex_match(s, m, std::wregex(L"a.c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcdef";
+ assert(std::regex_match(s, m, std::wregex(L"(.*).*", std::regex_constants::extended)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+6);
+ assert(m.length(0) == 6);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 6);
+ assert(m.position(1) == 0);
+ assert(m.str(1) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"bc";
+ assert(!std::regex_match(s, m, std::wregex(L"(a*)*", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbc";
+ assert(!std::regex_match(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbc";
+ assert(std::regex_match(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbbc";
+ assert(std::regex_match(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbbbc";
+ assert(std::regex_match(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefc";
+ assert(!std::regex_match(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbbbbc";
+ assert(!std::regex_match(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adec";
+ assert(!std::regex_match(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefc";
+ assert(std::regex_match(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefgc";
+ assert(std::regex_match(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefghc";
+ assert(std::regex_match(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefghic";
+ assert(!std::regex_match(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"tournament";
+ assert(std::regex_match(s, m, std::wregex(L"tour|to|tournament",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"tournamenttotour";
+ assert(std::regex_match(s, m, std::wregex(L"(tour|to|tournament)+",
+ std::regex_constants::extended | std::regex_constants::nosubs)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ttotour";
+ assert(std::regex_match(s, m, std::wregex(L"(tour|to|t)+",
+ std::regex_constants::extended)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 4);
+ assert(m.position(1) == 3);
+ assert(m.str(1) == L"tour");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"-ab,ab-";
+ assert(!std::regex_match(s, m, std::wregex(L"-(.*),\1-", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"-ab,ab-";
+ assert(std::regex_match(s, m, std::wregex(L"-.*,.*-", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"a";
+ assert(std::regex_match(s, m, std::wregex(L"^[a]$",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"a");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"a";
+ assert(std::regex_match(s, m, std::wregex(L"^[ab]$",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"a");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"c";
+ assert(std::regex_match(s, m, std::wregex(L"^[a-f]$",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"g";
+ assert(!std::regex_match(s, m, std::wregex(L"^[a-f]$",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"Iraqi";
+ assert(!std::regex_match(s, m, std::wregex(L"q[^u]",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"Iraq";
+ assert(!std::regex_match(s, m, std::wregex(L"q[^u]",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AmB";
+ assert(std::regex_match(s, m, std::wregex(L"A[[:lower:]]B",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AMB";
+ assert(!std::regex_match(s, m, std::wregex(L"A[[:lower:]]B",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AMB";
+ assert(std::regex_match(s, m, std::wregex(L"A[^[:lower:]]B",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AmB";
+ assert(!std::regex_match(s, m, std::wregex(L"A[^[:lower:]]B",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"A5B";
+ assert(!std::regex_match(s, m, std::wregex(L"A[^[:lower:]0-9]B",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"A?B";
+ assert(std::regex_match(s, m, std::wregex(L"A[^[:lower:]0-9]B",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"-";
+ assert(std::regex_match(s, m, std::wregex(L"[a[.hyphen.]z]",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"z";
+ assert(std::regex_match(s, m, std::wregex(L"[a[.hyphen.]z]",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(!std::regex_match(s, m, std::wregex(L"[a[.hyphen.]z]",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ std::locale::global(std::locale(LOCALE_cs_CZ_ISO8859_2));
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(std::regex_match(s, m, std::wregex(L"[a[=M=]z]",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"Ch";
+ assert(std::regex_match(s, m, std::wregex(L"[a[.ch.]z]",
+ std::regex_constants::extended | std::regex_constants::icase)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ std::locale::global(std::locale("C"));
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(!std::regex_match(s, m, std::wregex(L"[a[=M=]z]",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"01a45cef9";
+ assert(!std::regex_match(s, m, std::wregex(L"[ace1-9]*",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"01a45cef9";
+ assert(!std::regex_match(s, m, std::wregex(L"[ace1-9]+",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ const wchar_t r[] = L"^[-+]?[0-9]+[CF]$";
+ std::ptrdiff_t sr = std::char_traits<wchar_t>::length(r);
+ typedef forward_iterator<const wchar_t*> FI;
+ typedef bidirectional_iterator<const wchar_t*> BI;
+ std::wregex regex(FI(r), FI(r+sr), std::regex_constants::extended);
+ std::match_results<BI> m;
+ const wchar_t s[] = L"-40C";
+ std::ptrdiff_t ss = std::char_traits<wchar_t>::length(s);
+ assert(std::regex_match(BI(s), BI(s+ss), m, regex));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == BI(s));
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+}
diff --git a/test/std/re/re.alg/re.alg.match/grep.pass.cpp b/test/std/re/re.alg/re.alg.match/grep.pass.cpp
new file mode 100644
index 000000000000..2dc0966d6b8d
--- /dev/null
+++ b/test/std/re/re.alg/re.alg.match/grep.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class BidirectionalIterator, class Allocator, class charT, class traits>
+// bool
+// regex_match(BidirectionalIterator first, BidirectionalIterator last,
+// match_results<BidirectionalIterator, Allocator>& m,
+// const basic_regex<charT, traits>& e,
+// regex_constants::match_flag_type flags = regex_constants::match_default);
+
+#include <regex>
+#include <cassert>
+
+#include "test_iterators.h"
+
+int main()
+{
+ {
+ std::cmatch m;
+ const char s[] = "tournament";
+ assert(std::regex_match(s, m, std::regex("tour\nto\ntournament",
+ std::regex_constants::grep)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<char>::length(s));
+ assert(m.length(0) == 10);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "tournament");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ment";
+ assert(!std::regex_match(s, m, std::regex("tour\n\ntournament",
+ std::regex_constants::grep)));
+ assert(m.size() == 0);
+ }
+}
diff --git a/test/std/re/re.alg/re.alg.match/lookahead_capture.pass.cpp b/test/std/re/re.alg/re.alg.match/lookahead_capture.pass.cpp
new file mode 100644
index 000000000000..949739b992cb
--- /dev/null
+++ b/test/std/re/re.alg/re.alg.match/lookahead_capture.pass.cpp
@@ -0,0 +1,98 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class BidirectionalIterator, class Allocator, class charT, class traits>
+// bool
+// regex_match(BidirectionalIterator first, BidirectionalIterator last,
+// match_results<BidirectionalIterator, Allocator>& m,
+// const basic_regex<charT, traits>& e,
+// regex_constants::match_flag_type flags = regex_constants::match_default);
+
+// std::regex in ECMAScript mode should not ignore capture groups inside lookahead assertions.
+// For example, matching /(?=(a))(a)/ to "a" should yield two captures: \1 = "a", \2 = "a"
+
+#include <regex>
+#include <cassert>
+
+#include "test_iterators.h"
+
+int main()
+{
+ {
+ std::regex re("^(?=(.))a$");
+ assert(re.mark_count() == 1);
+
+ std::string s("a");
+ std::smatch m;
+ assert(std::regex_match(s, m, re));
+ assert(m.size() == 2);
+ assert(m[0] == "a");
+ assert(m[1] == "a");
+ }
+
+ {
+ std::regex re("^(a)(?=(.))(b)$");
+ assert(re.mark_count() == 3);
+
+ std::string s("ab");
+ std::smatch m;
+ assert(std::regex_match(s, m, re));
+ assert(m.size() == 4);
+ assert(m[0] == "ab");
+ assert(m[1] == "a");
+ assert(m[2] == "b");
+ assert(m[3] == "b");
+ }
+
+ {
+ std::regex re("^(.)(?=(.)(?=.(.)))(...)$");
+ assert(re.mark_count() == 4);
+
+ std::string s("abcd");
+ std::smatch m;
+ assert(std::regex_match(s, m, re));
+ assert(m.size() == 5);
+ assert(m[0] == "abcd");
+ assert(m[1] == "a");
+ assert(m[2] == "b");
+ assert(m[3] == "d");
+ assert(m[4] == "bcd");
+ }
+
+ {
+ std::regex re("^(a)(?!([^b]))(.c)$");
+ assert(re.mark_count() == 3);
+
+ std::string s("abc");
+ std::smatch m;
+ assert(std::regex_match(s, m, re));
+ assert(m.size() == 4);
+ assert(m[0] == "abc");
+ assert(m[1] == "a");
+ assert(m[2] == "");
+ assert(m[3] == "bc");
+ }
+
+ {
+ std::regex re("^(?!((b)))(?=(.))(?!(abc)).b$");
+ assert(re.mark_count() == 4);
+
+ std::string s("ab");
+ std::smatch m;
+ assert(std::regex_match(s, m, re));
+ assert(m.size() == 5);
+ assert(m[0] == "ab");
+ assert(m[1] == "");
+ assert(m[2] == "");
+ assert(m[3] == "a");
+ assert(m[4] == "");
+ }
+}
diff --git a/test/std/re/re.alg/re.alg.match/parse_curly_brackets.pass.cpp b/test/std/re/re.alg/re.alg.match/parse_curly_brackets.pass.cpp
new file mode 100644
index 000000000000..0b4c6948140e
--- /dev/null
+++ b/test/std/re/re.alg/re.alg.match/parse_curly_brackets.pass.cpp
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class BidirectionalIterator, class Allocator, class charT, class traits>
+// bool
+// regex_match(BidirectionalIterator first, BidirectionalIterator last,
+// match_results<BidirectionalIterator, Allocator>& m,
+// const basic_regex<charT, traits>& e,
+// regex_constants::match_flag_type flags = regex_constants::match_default);
+
+// http://llvm.org/bugs/show_bug.cgi?id=16135
+
+#include <string>
+#include <regex>
+#include <cassert>
+
+void
+test1()
+{
+ std::string re("\\{a\\}");
+ std::string target("{a}");
+ std::regex regex(re);
+ std::smatch smatch;
+ assert((std::regex_match(target, smatch, regex)));
+}
+
+void
+test2()
+{
+ std::string re("\\{a\\}");
+ std::string target("{a}");
+ std::regex regex(re, std::regex::extended);
+ std::smatch smatch;
+ assert((std::regex_match(target, smatch, regex)));
+}
+
+void
+test3()
+{
+ std::string re("\\{a\\}");
+ std::string target("{a}");
+ std::regex regex(re, std::regex::awk);
+ std::smatch smatch;
+ assert((std::regex_match(target, smatch, regex)));
+}
+
+void
+test4()
+{
+ std::string re("\\{a\\}");
+ std::string target("{a}");
+ std::regex regex(re, std::regex::egrep);
+ std::smatch smatch;
+ assert((std::regex_match(target, smatch, regex)));
+}
+
+int
+main()
+{
+ test1();
+ test2();
+ test3();
+ test4();
+}
diff --git a/test/std/re/re.alg/re.alg.replace/test1.pass.cpp b/test/std/re/re.alg/re.alg.replace/test1.pass.cpp
new file mode 100644
index 000000000000..9fd84fdc1f6e
--- /dev/null
+++ b/test/std/re/re.alg/re.alg.replace/test1.pass.cpp
@@ -0,0 +1,107 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class OutputIterator, class BidirectionalIterator,
+// class traits, class charT, class ST, class SA>
+// OutputIterator
+// regex_replace(OutputIterator out,
+// BidirectionalIterator first, BidirectionalIterator last,
+// const basic_regex<charT, traits>& e,
+// const basic_string<charT, ST, SA>& fmt,
+// regex_constants::match_flag_type flags =
+// regex_constants::match_default);
+
+#include <regex>
+#include <cassert>
+
+#include "test_iterators.h"
+
+int main()
+{
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ typedef output_iterator<char*> Out;
+ typedef bidirectional_iterator<const char*> Bi;
+ char buf[100] = {0};
+ Out r = std::regex_replace(Out(buf), Bi(std::begin(phone_book)),
+ Bi(std::end(phone_book)-1), phone_numbers,
+ std::string("123-$&"));
+ assert(r.base() == buf+40);
+ assert(buf == std::string("123-555-1234, 123-555-2345, 123-555-3456"));
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ typedef output_iterator<char*> Out;
+ typedef bidirectional_iterator<const char*> Bi;
+ char buf[100] = {0};
+ Out r = std::regex_replace(Out(buf), Bi(std::begin(phone_book)),
+ Bi(std::end(phone_book)-1), phone_numbers,
+ std::string("123-$&"),
+ std::regex_constants::format_sed);
+ assert(r.base() == buf+43);
+ assert(buf == std::string("123-$555-1234, 123-$555-2345, 123-$555-3456"));
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ typedef output_iterator<char*> Out;
+ typedef bidirectional_iterator<const char*> Bi;
+ char buf[100] = {0};
+ Out r = std::regex_replace(Out(buf), Bi(std::begin(phone_book)),
+ Bi(std::end(phone_book)-1), phone_numbers,
+ std::string("123-&"),
+ std::regex_constants::format_sed);
+ assert(r.base() == buf+40);
+ assert(buf == std::string("123-555-1234, 123-555-2345, 123-555-3456"));
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ typedef output_iterator<char*> Out;
+ typedef bidirectional_iterator<const char*> Bi;
+ char buf[100] = {0};
+ Out r = std::regex_replace(Out(buf), Bi(std::begin(phone_book)),
+ Bi(std::end(phone_book)-1), phone_numbers,
+ std::string("123-$&"),
+ std::regex_constants::format_no_copy);
+ assert(r.base() == buf+36);
+ assert(buf == std::string("123-555-1234123-555-2345123-555-3456"));
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ typedef output_iterator<char*> Out;
+ typedef bidirectional_iterator<const char*> Bi;
+ char buf[100] = {0};
+ Out r = std::regex_replace(Out(buf), Bi(std::begin(phone_book)),
+ Bi(std::end(phone_book)-1), phone_numbers,
+ std::string("123-$&"),
+ std::regex_constants::format_first_only);
+ assert(r.base() == buf+32);
+ assert(buf == std::string("123-555-1234, 555-2345, 555-3456"));
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ typedef output_iterator<char*> Out;
+ typedef bidirectional_iterator<const char*> Bi;
+ char buf[100] = {0};
+ Out r = std::regex_replace(Out(buf), Bi(std::begin(phone_book)),
+ Bi(std::end(phone_book)-1), phone_numbers,
+ std::string("123-$&"),
+ std::regex_constants::format_first_only |
+ std::regex_constants::format_no_copy);
+ assert(r.base() == buf+12);
+ assert(buf == std::string("123-555-1234"));
+ }
+}
diff --git a/test/std/re/re.alg/re.alg.replace/test2.pass.cpp b/test/std/re/re.alg/re.alg.replace/test2.pass.cpp
new file mode 100644
index 000000000000..63a4ed56933d
--- /dev/null
+++ b/test/std/re/re.alg/re.alg.replace/test2.pass.cpp
@@ -0,0 +1,107 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class OutputIterator, class BidirectionalIterator,
+// class traits, class charT, class ST, class SA>
+// OutputIterator
+// regex_replace(OutputIterator out,
+// BidirectionalIterator first, BidirectionalIterator last,
+// const basic_regex<charT, traits>& e,
+// const charT* fmt,
+// regex_constants::match_flag_type flags =
+// regex_constants::match_default);
+
+#include <regex>
+#include <cassert>
+
+#include "test_iterators.h"
+
+int main()
+{
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ typedef output_iterator<char*> Out;
+ typedef bidirectional_iterator<const char*> Bi;
+ char buf[100] = {0};
+ Out r = std::regex_replace(Out(buf), Bi(std::begin(phone_book)),
+ Bi(std::end(phone_book)-1), phone_numbers,
+ "123-$&");
+ assert(r.base() == buf+40);
+ assert(buf == std::string("123-555-1234, 123-555-2345, 123-555-3456"));
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ typedef output_iterator<char*> Out;
+ typedef bidirectional_iterator<const char*> Bi;
+ char buf[100] = {0};
+ Out r = std::regex_replace(Out(buf), Bi(std::begin(phone_book)),
+ Bi(std::end(phone_book)-1), phone_numbers,
+ "123-$&",
+ std::regex_constants::format_sed);
+ assert(r.base() == buf+43);
+ assert(buf == std::string("123-$555-1234, 123-$555-2345, 123-$555-3456"));
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ typedef output_iterator<char*> Out;
+ typedef bidirectional_iterator<const char*> Bi;
+ char buf[100] = {0};
+ Out r = std::regex_replace(Out(buf), Bi(std::begin(phone_book)),
+ Bi(std::end(phone_book)-1), phone_numbers,
+ "123-&",
+ std::regex_constants::format_sed);
+ assert(r.base() == buf+40);
+ assert(buf == std::string("123-555-1234, 123-555-2345, 123-555-3456"));
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ typedef output_iterator<char*> Out;
+ typedef bidirectional_iterator<const char*> Bi;
+ char buf[100] = {0};
+ Out r = std::regex_replace(Out(buf), Bi(std::begin(phone_book)),
+ Bi(std::end(phone_book)-1), phone_numbers,
+ "123-$&",
+ std::regex_constants::format_no_copy);
+ assert(r.base() == buf+36);
+ assert(buf == std::string("123-555-1234123-555-2345123-555-3456"));
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ typedef output_iterator<char*> Out;
+ typedef bidirectional_iterator<const char*> Bi;
+ char buf[100] = {0};
+ Out r = std::regex_replace(Out(buf), Bi(std::begin(phone_book)),
+ Bi(std::end(phone_book)-1), phone_numbers,
+ "123-$&",
+ std::regex_constants::format_first_only);
+ assert(r.base() == buf+32);
+ assert(buf == std::string("123-555-1234, 555-2345, 555-3456"));
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ typedef output_iterator<char*> Out;
+ typedef bidirectional_iterator<const char*> Bi;
+ char buf[100] = {0};
+ Out r = std::regex_replace(Out(buf), Bi(std::begin(phone_book)),
+ Bi(std::end(phone_book)-1), phone_numbers,
+ "123-$&",
+ std::regex_constants::format_first_only |
+ std::regex_constants::format_no_copy);
+ assert(r.base() == buf+12);
+ assert(buf == std::string("123-555-1234"));
+ }
+}
diff --git a/test/std/re/re.alg/re.alg.replace/test3.pass.cpp b/test/std/re/re.alg/re.alg.replace/test3.pass.cpp
new file mode 100644
index 000000000000..d1167860646f
--- /dev/null
+++ b/test/std/re/re.alg/re.alg.replace/test3.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class traits, class charT, class ST, class SA, class FST, class FSA>>
+// basic_string<charT, ST, SA>
+// regex_replace(const basic_string<charT, ST, SA>& s,
+// const basic_regex<charT, traits>& e,
+// const basic_string<charT, FST, FSA>& fmt,
+// regex_constants::match_flag_type flags =
+// regex_constants::match_default);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ std::string phone_book("555-1234, 555-2345, 555-3456");
+ std::string r = std::regex_replace(phone_book, phone_numbers,
+ std::string("123-$&"));
+ assert(r == "123-555-1234, 123-555-2345, 123-555-3456");
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ std::string phone_book("555-1234, 555-2345, 555-3456");
+ std::string r = std::regex_replace(phone_book, phone_numbers,
+ std::string("123-$&"),
+ std::regex_constants::format_sed);
+ assert(r == "123-$555-1234, 123-$555-2345, 123-$555-3456");
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ std::string phone_book("555-1234, 555-2345, 555-3456");
+ std::string r = std::regex_replace(phone_book, phone_numbers,
+ std::string("123-&"),
+ std::regex_constants::format_sed);
+ assert(r == "123-555-1234, 123-555-2345, 123-555-3456");
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ std::string phone_book("555-1234, 555-2345, 555-3456");
+ std::string r = std::regex_replace(phone_book, phone_numbers,
+ std::string("123-$&"),
+ std::regex_constants::format_no_copy);
+ assert(r == "123-555-1234123-555-2345123-555-3456");
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ std::string phone_book("555-1234, 555-2345, 555-3456");
+ std::string r = std::regex_replace(phone_book, phone_numbers,
+ std::string("123-$&"),
+ std::regex_constants::format_first_only);
+ assert(r == "123-555-1234, 555-2345, 555-3456");
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ std::string phone_book("555-1234, 555-2345, 555-3456");
+ std::string r = std::regex_replace(phone_book, phone_numbers,
+ std::string("123-$&"),
+ std::regex_constants::format_first_only |
+ std::regex_constants::format_no_copy);
+ assert(r == "123-555-1234");
+ }
+}
diff --git a/test/std/re/re.alg/re.alg.replace/test4.pass.cpp b/test/std/re/re.alg/re.alg.replace/test4.pass.cpp
new file mode 100644
index 000000000000..fba1bc19546a
--- /dev/null
+++ b/test/std/re/re.alg/re.alg.replace/test4.pass.cpp
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class traits, class charT, class ST, class SA>
+// basic_string<charT, ST, SA>
+// regex_replace(const basic_string<charT, ST, SA>& s,
+// const basic_regex<charT, traits>& e, const charT* fmt,
+// regex_constants::match_flag_type flags =
+// regex_constants::match_default);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ std::string phone_book("555-1234, 555-2345, 555-3456");
+ std::string r = std::regex_replace(phone_book, phone_numbers,
+ "123-$&");
+ assert(r == "123-555-1234, 123-555-2345, 123-555-3456");
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ std::string phone_book("555-1234, 555-2345, 555-3456");
+ std::string r = std::regex_replace(phone_book, phone_numbers,
+ "123-$&",
+ std::regex_constants::format_sed);
+ assert(r == "123-$555-1234, 123-$555-2345, 123-$555-3456");
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ std::string phone_book("555-1234, 555-2345, 555-3456");
+ std::string r = std::regex_replace(phone_book, phone_numbers,
+ "123-&",
+ std::regex_constants::format_sed);
+ assert(r == "123-555-1234, 123-555-2345, 123-555-3456");
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ std::string phone_book("555-1234, 555-2345, 555-3456");
+ std::string r = std::regex_replace(phone_book, phone_numbers,
+ "123-$&",
+ std::regex_constants::format_no_copy);
+ assert(r == "123-555-1234123-555-2345123-555-3456");
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ std::string phone_book("555-1234, 555-2345, 555-3456");
+ std::string r = std::regex_replace(phone_book, phone_numbers,
+ "123-$&",
+ std::regex_constants::format_first_only);
+ assert(r == "123-555-1234, 555-2345, 555-3456");
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ std::string phone_book("555-1234, 555-2345, 555-3456");
+ std::string r = std::regex_replace(phone_book, phone_numbers,
+ "123-$&",
+ std::regex_constants::format_first_only |
+ std::regex_constants::format_no_copy);
+ assert(r == "123-555-1234");
+ }
+}
diff --git a/test/std/re/re.alg/re.alg.replace/test5.pass.cpp b/test/std/re/re.alg/re.alg.replace/test5.pass.cpp
new file mode 100644
index 000000000000..7190e41d5228
--- /dev/null
+++ b/test/std/re/re.alg/re.alg.replace/test5.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class traits, class charT, class ST, class SA>
+// basic_string<charT>
+// regex_replace(const charT* s,
+// const basic_regex<charT, traits>& e,
+// const basic_string<charT, ST, SA>& fmt,
+// regex_constants::match_flag_type flags =
+// regex_constants::match_default);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ std::string r = std::regex_replace(phone_book, phone_numbers,
+ std::string("123-$&"));
+ assert(r == "123-555-1234, 123-555-2345, 123-555-3456");
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ std::string r = std::regex_replace(phone_book, phone_numbers,
+ std::string("123-$&"),
+ std::regex_constants::format_sed);
+ assert(r == "123-$555-1234, 123-$555-2345, 123-$555-3456");
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ std::string r = std::regex_replace(phone_book, phone_numbers,
+ std::string("123-&"),
+ std::regex_constants::format_sed);
+ assert(r == "123-555-1234, 123-555-2345, 123-555-3456");
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ std::string r = std::regex_replace(phone_book, phone_numbers,
+ std::string("123-$&"),
+ std::regex_constants::format_no_copy);
+ assert(r == "123-555-1234123-555-2345123-555-3456");
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ std::string r = std::regex_replace(phone_book, phone_numbers,
+ std::string("123-$&"),
+ std::regex_constants::format_first_only);
+ assert(r == "123-555-1234, 555-2345, 555-3456");
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ std::string r = std::regex_replace(phone_book, phone_numbers,
+ std::string("123-$&"),
+ std::regex_constants::format_first_only |
+ std::regex_constants::format_no_copy);
+ assert(r == "123-555-1234");
+ }
+}
diff --git a/test/std/re/re.alg/re.alg.replace/test6.pass.cpp b/test/std/re/re.alg/re.alg.replace/test6.pass.cpp
new file mode 100644
index 000000000000..b01780077303
--- /dev/null
+++ b/test/std/re/re.alg/re.alg.replace/test6.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class traits, class charT>
+// basic_string<charT>
+// regex_replace(const charT* s,
+// const basic_regex<charT, traits>& e,
+// const charT* fmt,
+// regex_constants::match_flag_type flags =
+// regex_constants::match_default);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ std::string r = std::regex_replace(phone_book, phone_numbers,
+ "123-$&");
+ assert(r == "123-555-1234, 123-555-2345, 123-555-3456");
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ std::string r = std::regex_replace(phone_book, phone_numbers,
+ "123-$&",
+ std::regex_constants::format_sed);
+ assert(r == "123-$555-1234, 123-$555-2345, 123-$555-3456");
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ std::string r = std::regex_replace(phone_book, phone_numbers,
+ "123-&",
+ std::regex_constants::format_sed);
+ assert(r == "123-555-1234, 123-555-2345, 123-555-3456");
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ std::string r = std::regex_replace(phone_book, phone_numbers,
+ "123-$&",
+ std::regex_constants::format_no_copy);
+ assert(r == "123-555-1234123-555-2345123-555-3456");
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ std::string r = std::regex_replace(phone_book, phone_numbers,
+ "123-$&",
+ std::regex_constants::format_first_only);
+ assert(r == "123-555-1234, 555-2345, 555-3456");
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ std::string r = std::regex_replace(phone_book, phone_numbers,
+ "123-$&",
+ std::regex_constants::format_first_only |
+ std::regex_constants::format_no_copy);
+ assert(r == "123-555-1234");
+ }
+}
diff --git a/test/std/re/re.alg/re.alg.search/awk.pass.cpp b/test/std/re/re.alg/re.alg.search/awk.pass.cpp
new file mode 100644
index 000000000000..7fc1b3fcc233
--- /dev/null
+++ b/test/std/re/re.alg/re.alg.search/awk.pass.cpp
@@ -0,0 +1,1574 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: locale.cs_CZ.ISO8859-2
+
+// <regex>
+
+// template <class BidirectionalIterator, class Allocator, class charT, class traits>
+// bool
+// regex_search(BidirectionalIterator first, BidirectionalIterator last,
+// match_results<BidirectionalIterator, Allocator>& m,
+// const basic_regex<charT, traits>& e,
+// regex_constants::match_flag_type flags = regex_constants::match_default);
+
+// TODO: investigation needed
+// XFAIL: linux-gnu
+
+#include <regex>
+#include <cassert>
+#include "test_iterators.h"
+
+#include "platform_support.h" // locale name macros
+
+int main()
+{
+ {
+ std::cmatch m;
+ const char s[] = "a";
+ assert(std::regex_search(s, m, std::regex("a", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.empty());
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+1);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "a");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ab";
+ assert(std::regex_search(s, m, std::regex("ab", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+2);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "ab");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ab";
+ assert(!std::regex_search(s, m, std::regex("ba", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ assert(m.empty());
+ }
+ {
+ std::cmatch m;
+ const char s[] = "aab";
+ assert(std::regex_search(s, m, std::regex("ab", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 1);
+ assert(m.str(0) == "ab");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "aab";
+ assert(!std::regex_search(s, m, std::regex("ab", std::regex_constants::awk),
+ std::regex_constants::match_continuous));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcd";
+ assert(std::regex_search(s, m, std::regex("bc", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 1);
+ assert(m.str(0) == "bc");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbc";
+ assert(std::regex_search(s, m, std::regex("ab*c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ababc";
+ assert(std::regex_search(s, m, std::regex("(ab)*c", std::regex_constants::awk)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+5);
+ assert(m.length(0) == 5);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 2);
+ assert(m.position(1) == 2);
+ assert(m.str(1) == "ab");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcdefghijk";
+ assert(std::regex_search(s, m, std::regex("cd((e)fg)hi",
+ std::regex_constants::awk)));
+ assert(m.size() == 3);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+std::regex_traits<char>::length(s));
+ assert(m.length(0) == 7);
+ assert(m.position(0) == 2);
+ assert(m.str(0) == "cdefghi");
+ assert(m.length(1) == 3);
+ assert(m.position(1) == 4);
+ assert(m.str(1) == "efg");
+ assert(m.length(2) == 1);
+ assert(m.position(2) == 4);
+ assert(m.str(2) == "e");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abc";
+ assert(std::regex_search(s, m, std::regex("^abc", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcd";
+ assert(std::regex_search(s, m, std::regex("^abc", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "abc");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "aabc";
+ assert(!std::regex_search(s, m, std::regex("^abc", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abc";
+ assert(std::regex_search(s, m, std::regex("abc$", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "efabc";
+ assert(std::regex_search(s, m, std::regex("abc$", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+5);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 2);
+ assert(m.str(0) == s+2);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "efabcg";
+ assert(!std::regex_search(s, m, std::regex("abc$", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abc";
+ assert(std::regex_search(s, m, std::regex("a.c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "acc";
+ assert(std::regex_search(s, m, std::regex("a.c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "acc";
+ assert(std::regex_search(s, m, std::regex("a.c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcdef";
+ assert(std::regex_search(s, m, std::regex("(.*).*", std::regex_constants::awk)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+6);
+ assert(m.length(0) == 6);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 6);
+ assert(m.position(1) == 0);
+ assert(m.str(1) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "bc";
+ assert(std::regex_search(s, m, std::regex("(a*)*", std::regex_constants::awk)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+2);
+ assert(m.length(0) == 0);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "");
+ assert(m.length(1) == 0);
+ assert(m.position(1) == 0);
+ assert(m.str(1) == "");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbc";
+ assert(!std::regex_search(s, m, std::regex("ab{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbc";
+ assert(std::regex_search(s, m, std::regex("ab{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbbc";
+ assert(std::regex_search(s, m, std::regex("ab{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbbbc";
+ assert(std::regex_search(s, m, std::regex("ab{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefc";
+ assert(!std::regex_search(s, m, std::regex("ab{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbbbbc";
+ assert(!std::regex_search(s, m, std::regex("ab{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adec";
+ assert(!std::regex_search(s, m, std::regex("a.{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefc";
+ assert(std::regex_search(s, m, std::regex("a.{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefgc";
+ assert(std::regex_search(s, m, std::regex("a.{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefghc";
+ assert(std::regex_search(s, m, std::regex("a.{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefghic";
+ assert(!std::regex_search(s, m, std::regex("a.{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "tournament";
+ assert(std::regex_search(s, m, std::regex("tour|to|tournament",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "tournamenttotour";
+ assert(std::regex_search(s, m, std::regex("(tour|to|tournament)+",
+ std::regex_constants::awk | std::regex_constants::nosubs)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ttotour";
+ assert(std::regex_search(s, m, std::regex("(tour|to|t)+",
+ std::regex_constants::awk)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 4);
+ assert(m.position(1) == 3);
+ assert(m.str(1) == "tour");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "-ab,ab-";
+ assert(!std::regex_search(s, m, std::regex("-(.*),\1-", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "-ab,ab-";
+ assert(std::regex_search(s, m, std::regex("-.*,.*-", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "a";
+ assert(std::regex_search(s, m, std::regex("^[a]$",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "a");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "a";
+ assert(std::regex_search(s, m, std::regex("^[ab]$",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "a");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "c";
+ assert(std::regex_search(s, m, std::regex("^[a-f]$",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "g";
+ assert(!std::regex_search(s, m, std::regex("^[a-f]$",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "Iraqi";
+ assert(std::regex_search(s, m, std::regex("q[^u]",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 3);
+ assert(m.str(0) == "qi");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "Iraq";
+ assert(!std::regex_search(s, m, std::regex("q[^u]",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AmB";
+ assert(std::regex_search(s, m, std::regex("A[[:lower:]]B",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AMB";
+ assert(!std::regex_search(s, m, std::regex("A[[:lower:]]B",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AMB";
+ assert(std::regex_search(s, m, std::regex("A[^[:lower:]]B",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AmB";
+ assert(!std::regex_search(s, m, std::regex("A[^[:lower:]]B",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "A5B";
+ assert(!std::regex_search(s, m, std::regex("A[^[:lower:]0-9]B",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "A?B";
+ assert(std::regex_search(s, m, std::regex("A[^[:lower:]0-9]B",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "-";
+ assert(std::regex_search(s, m, std::regex("[a[.hyphen.]z]",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "z";
+ assert(std::regex_search(s, m, std::regex("[a[.hyphen.]z]",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "m";
+ assert(!std::regex_search(s, m, std::regex("[a[.hyphen.]z]",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ std::locale::global(std::locale(LOCALE_cs_CZ_ISO8859_2));
+ {
+ std::cmatch m;
+ const char s[] = "m";
+ assert(std::regex_search(s, m, std::regex("[a[=M=]z]",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "Ch";
+ assert(std::regex_search(s, m, std::regex("[a[.ch.]z]",
+ std::regex_constants::awk | std::regex_constants::icase)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ std::locale::global(std::locale("C"));
+ {
+ std::cmatch m;
+ const char s[] = "m";
+ assert(!std::regex_search(s, m, std::regex("[a[=M=]z]",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "01a45cef9";
+ assert(std::regex_search(s, m, std::regex("[ace1-9]*",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<char>::length(s));
+ assert(m.length(0) == 0);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "01a45cef9";
+ assert(std::regex_search(s, m, std::regex("[ace1-9]+",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<char>::length(s));
+ assert(m.length(0) == 6);
+ assert(m.position(0) == 1);
+ assert(m.str(0) == "1a45ce");
+ }
+ {
+ const char r[] = "^[-+]?[0-9]+[CF]$";
+ std::ptrdiff_t sr = std::char_traits<char>::length(r);
+ typedef forward_iterator<const char*> FI;
+ typedef bidirectional_iterator<const char*> BI;
+ std::regex regex(FI(r), FI(r+sr), std::regex_constants::awk);
+ std::match_results<BI> m;
+ const char s[] = "-40C";
+ std::ptrdiff_t ss = std::char_traits<char>::length(s);
+ assert(std::regex_search(BI(s), BI(s+ss), m, regex));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == BI(s));
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "\n\n\n";
+ assert(std::regex_search(s, m, std::regex("[\\n]+",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<char>::length(s));
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"a";
+ assert(std::regex_search(s, m, std::wregex(L"a", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.empty());
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+1);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"a");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ab";
+ assert(std::regex_search(s, m, std::wregex(L"ab", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+2);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"ab");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ab";
+ assert(!std::regex_search(s, m, std::wregex(L"ba", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ assert(m.empty());
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"aab";
+ assert(std::regex_search(s, m, std::wregex(L"ab", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 1);
+ assert(m.str(0) == L"ab");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"aab";
+ assert(!std::regex_search(s, m, std::wregex(L"ab", std::regex_constants::awk),
+ std::regex_constants::match_continuous));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcd";
+ assert(std::regex_search(s, m, std::wregex(L"bc", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 1);
+ assert(m.str(0) == L"bc");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbc";
+ assert(std::regex_search(s, m, std::wregex(L"ab*c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ababc";
+ assert(std::regex_search(s, m, std::wregex(L"(ab)*c", std::regex_constants::awk)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+5);
+ assert(m.length(0) == 5);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 2);
+ assert(m.position(1) == 2);
+ assert(m.str(1) == L"ab");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcdefghijk";
+ assert(std::regex_search(s, m, std::wregex(L"cd((e)fg)hi",
+ std::regex_constants::awk)));
+ assert(m.size() == 3);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+std::regex_traits<wchar_t>::length(s));
+ assert(m.length(0) == 7);
+ assert(m.position(0) == 2);
+ assert(m.str(0) == L"cdefghi");
+ assert(m.length(1) == 3);
+ assert(m.position(1) == 4);
+ assert(m.str(1) == L"efg");
+ assert(m.length(2) == 1);
+ assert(m.position(2) == 4);
+ assert(m.str(2) == L"e");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abc";
+ assert(std::regex_search(s, m, std::wregex(L"^abc", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcd";
+ assert(std::regex_search(s, m, std::wregex(L"^abc", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"abc");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"aabc";
+ assert(!std::regex_search(s, m, std::wregex(L"^abc", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abc";
+ assert(std::regex_search(s, m, std::wregex(L"abc$", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"efabc";
+ assert(std::regex_search(s, m, std::wregex(L"abc$", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+5);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 2);
+ assert(m.str(0) == s+2);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"efabcg";
+ assert(!std::regex_search(s, m, std::wregex(L"abc$", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abc";
+ assert(std::regex_search(s, m, std::wregex(L"a.c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"acc";
+ assert(std::regex_search(s, m, std::wregex(L"a.c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"acc";
+ assert(std::regex_search(s, m, std::wregex(L"a.c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcdef";
+ assert(std::regex_search(s, m, std::wregex(L"(.*).*", std::regex_constants::awk)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+6);
+ assert(m.length(0) == 6);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 6);
+ assert(m.position(1) == 0);
+ assert(m.str(1) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"bc";
+ assert(std::regex_search(s, m, std::wregex(L"(a*)*", std::regex_constants::awk)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+2);
+ assert(m.length(0) == 0);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"");
+ assert(m.length(1) == 0);
+ assert(m.position(1) == 0);
+ assert(m.str(1) == L"");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbc";
+ assert(!std::regex_search(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbc";
+ assert(std::regex_search(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbbc";
+ assert(std::regex_search(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbbbc";
+ assert(std::regex_search(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefc";
+ assert(!std::regex_search(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbbbbc";
+ assert(!std::regex_search(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adec";
+ assert(!std::regex_search(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefc";
+ assert(std::regex_search(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefgc";
+ assert(std::regex_search(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefghc";
+ assert(std::regex_search(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefghic";
+ assert(!std::regex_search(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"tournament";
+ assert(std::regex_search(s, m, std::wregex(L"tour|to|tournament",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"tournamenttotour";
+ assert(std::regex_search(s, m, std::wregex(L"(tour|to|tournament)+",
+ std::regex_constants::awk | std::regex_constants::nosubs)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ttotour";
+ assert(std::regex_search(s, m, std::wregex(L"(tour|to|t)+",
+ std::regex_constants::awk)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 4);
+ assert(m.position(1) == 3);
+ assert(m.str(1) == L"tour");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"-ab,ab-";
+ assert(!std::regex_search(s, m, std::wregex(L"-(.*),\1-", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"-ab,ab-";
+ assert(std::regex_search(s, m, std::wregex(L"-.*,.*-", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"a";
+ assert(std::regex_search(s, m, std::wregex(L"^[a]$",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"a");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"a";
+ assert(std::regex_search(s, m, std::wregex(L"^[ab]$",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"a");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"c";
+ assert(std::regex_search(s, m, std::wregex(L"^[a-f]$",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"g";
+ assert(!std::regex_search(s, m, std::wregex(L"^[a-f]$",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"Iraqi";
+ assert(std::regex_search(s, m, std::wregex(L"q[^u]",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 3);
+ assert(m.str(0) == L"qi");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"Iraq";
+ assert(!std::regex_search(s, m, std::wregex(L"q[^u]",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AmB";
+ assert(std::regex_search(s, m, std::wregex(L"A[[:lower:]]B",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AMB";
+ assert(!std::regex_search(s, m, std::wregex(L"A[[:lower:]]B",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AMB";
+ assert(std::regex_search(s, m, std::wregex(L"A[^[:lower:]]B",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AmB";
+ assert(!std::regex_search(s, m, std::wregex(L"A[^[:lower:]]B",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"A5B";
+ assert(!std::regex_search(s, m, std::wregex(L"A[^[:lower:]0-9]B",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"A?B";
+ assert(std::regex_search(s, m, std::wregex(L"A[^[:lower:]0-9]B",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"-";
+ assert(std::regex_search(s, m, std::wregex(L"[a[.hyphen.]z]",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"z";
+ assert(std::regex_search(s, m, std::wregex(L"[a[.hyphen.]z]",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(!std::regex_search(s, m, std::wregex(L"[a[.hyphen.]z]",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ std::locale::global(std::locale(LOCALE_cs_CZ_ISO8859_2));
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(std::regex_search(s, m, std::wregex(L"[a[=M=]z]",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"Ch";
+ assert(std::regex_search(s, m, std::wregex(L"[a[.ch.]z]",
+ std::regex_constants::awk | std::regex_constants::icase)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ std::locale::global(std::locale("C"));
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(!std::regex_search(s, m, std::wregex(L"[a[=M=]z]",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"01a45cef9";
+ assert(std::regex_search(s, m, std::wregex(L"[ace1-9]*",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<wchar_t>::length(s));
+ assert(m.length(0) == 0);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"01a45cef9";
+ assert(std::regex_search(s, m, std::wregex(L"[ace1-9]+",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<wchar_t>::length(s));
+ assert(m.length(0) == 6);
+ assert(m.position(0) == 1);
+ assert(m.str(0) == L"1a45ce");
+ }
+ {
+ const wchar_t r[] = L"^[-+]?[0-9]+[CF]$";
+ std::ptrdiff_t sr = std::char_traits<wchar_t>::length(r);
+ typedef forward_iterator<const wchar_t*> FI;
+ typedef bidirectional_iterator<const wchar_t*> BI;
+ std::wregex regex(FI(r), FI(r+sr), std::regex_constants::awk);
+ std::match_results<BI> m;
+ const wchar_t s[] = L"-40C";
+ std::ptrdiff_t ss = std::char_traits<wchar_t>::length(s);
+ assert(std::regex_search(BI(s), BI(s+ss), m, regex));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == BI(s));
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"\n\n\n";
+ assert(std::regex_search(s, m, std::wregex(L"[\\n]+",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<wchar_t>::length(s));
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+}
diff --git a/test/std/re/re.alg/re.alg.search/backup.pass.cpp b/test/std/re/re.alg/re.alg.search/backup.pass.cpp
new file mode 100644
index 000000000000..7da58608705b
--- /dev/null
+++ b/test/std/re/re.alg/re.alg.search/backup.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class BidirectionalIterator, class Allocator, class charT, class traits>
+// bool
+// regex_search(BidirectionalIterator first, BidirectionalIterator last,
+// match_results<BidirectionalIterator, Allocator>& m,
+// const basic_regex<charT, traits>& e,
+// regex_constants::match_flag_type flags = regex_constants::match_default);
+
+#include <regex>
+#include <string>
+#include <list>
+#include <cassert>
+
+int main()
+{
+ // This regex_iterator uses regex_search(__wrap_iter<_Iter> __first, ...)
+ // Test for http://llvm.org/bugs/show_bug.cgi?id=16240 fixed in r185273.
+ {
+ std::string s("aaaa a");
+ std::regex re("\\ba");
+ std::sregex_iterator it(s.begin(), s.end(), re);
+ std::sregex_iterator end = std::sregex_iterator();
+
+ assert(it->position(0) == 0);
+ assert(it->length(0) == 1);
+
+ ++it;
+ assert(it->position(0) == 5);
+ assert(it->length(0) == 1);
+
+ ++it;
+ assert(it == end);
+ }
+
+ // This regex_iterator uses regex_search(_BidirectionalIterator __first, ...)
+ {
+ std::string s("aaaa a");
+ std::list<char> l(s.begin(), s.end());
+ std::regex re("\\ba");
+ std::regex_iterator<std::list<char>::iterator> it(l.begin(), l.end(), re);
+ std::regex_iterator<std::list<char>::iterator> end = std::regex_iterator<std::list<char>::iterator>();
+
+ assert(it->position(0) == 0);
+ assert(it->length(0) == 1);
+
+ ++it;
+ assert(it->position(0) == 5);
+ assert(it->length(0) == 1);
+
+ ++it;
+ assert(it == end);
+ }
+}
diff --git a/test/std/re/re.alg/re.alg.search/basic.fail.cpp b/test/std/re/re.alg/re.alg.search/basic.fail.cpp
new file mode 100644
index 000000000000..9ab6a21ad9dc
--- /dev/null
+++ b/test/std/re/re.alg/re.alg.search/basic.fail.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class ST, class SA, class Allocator, class charT, class traits>
+// bool regex_search(const basic_string<charT, ST, SA>&&,
+// match_results<
+// typename basic_string<charT, ST, SA>::const_iterator,
+// Allocator>&,
+// const basic_regex<charT, traits>&,
+// regex_constants::match_flag_type =
+// regex_constants::match_default) = delete;
+
+#if __cplusplus <= 201402L
+#error
+#else
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ std::smatch m;
+ std::regex re{"*"};
+ std::regex_search(std::string("abcde"), m, re);
+ }
+}
+#endif
diff --git a/test/std/re/re.alg/re.alg.search/basic.pass.cpp b/test/std/re/re.alg/re.alg.search/basic.pass.cpp
new file mode 100644
index 000000000000..bdfcd9cc9bcd
--- /dev/null
+++ b/test/std/re/re.alg/re.alg.search/basic.pass.cpp
@@ -0,0 +1,1547 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: locale.cs_CZ.ISO8859-2
+
+// <regex>
+
+// template <class BidirectionalIterator, class Allocator, class charT, class traits>
+// bool
+// regex_search(BidirectionalIterator first, BidirectionalIterator last,
+// match_results<BidirectionalIterator, Allocator>& m,
+// const basic_regex<charT, traits>& e,
+// regex_constants::match_flag_type flags = regex_constants::match_default);
+
+// TODO: investigation needed
+// XFAIL: linux-gnu
+
+#include <regex>
+#include <cassert>
+#include "test_iterators.h"
+
+#include "platform_support.h" // locale name macros
+
+int main()
+{
+ {
+ std::cmatch m;
+ assert(!std::regex_search("a", m, std::regex()));
+ assert(m.size() == 0);
+ assert(m.empty());
+ }
+ {
+ std::cmatch m;
+ const char s[] = "a";
+ assert(std::regex_search(s, m, std::regex("a", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.empty());
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+1);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "a");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ab";
+ assert(std::regex_search(s, m, std::regex("ab", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+2);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "ab");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ab";
+ assert(!std::regex_search(s, m, std::regex("ba", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ assert(m.empty());
+ }
+ {
+ std::cmatch m;
+ const char s[] = "aab";
+ assert(std::regex_search(s, m, std::regex("ab", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 1);
+ assert(m.str(0) == "ab");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "aab";
+ assert(!std::regex_search(s, m, std::regex("ab", std::regex_constants::basic),
+ std::regex_constants::match_continuous));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcd";
+ assert(std::regex_search(s, m, std::regex("bc", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 1);
+ assert(m.str(0) == "bc");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbc";
+ assert(std::regex_search(s, m, std::regex("ab*c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ababc";
+ assert(std::regex_search(s, m, std::regex("\\(ab\\)*c", std::regex_constants::basic)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+5);
+ assert(m.length(0) == 5);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 2);
+ assert(m.position(1) == 2);
+ assert(m.str(1) == "ab");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcdefghijk";
+ assert(std::regex_search(s, m, std::regex("cd\\(\\(e\\)fg\\)hi",
+ std::regex_constants::basic)));
+ assert(m.size() == 3);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+std::regex_traits<char>::length(s));
+ assert(m.length(0) == 7);
+ assert(m.position(0) == 2);
+ assert(m.str(0) == "cdefghi");
+ assert(m.length(1) == 3);
+ assert(m.position(1) == 4);
+ assert(m.str(1) == "efg");
+ assert(m.length(2) == 1);
+ assert(m.position(2) == 4);
+ assert(m.str(2) == "e");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abc";
+ assert(std::regex_search(s, m, std::regex("^abc", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcd";
+ assert(std::regex_search(s, m, std::regex("^abc", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "abc");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "aabc";
+ assert(!std::regex_search(s, m, std::regex("^abc", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abc";
+ assert(std::regex_search(s, m, std::regex("abc$", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "efabc";
+ assert(std::regex_search(s, m, std::regex("abc$", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+5);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 2);
+ assert(m.str(0) == s+2);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "efabcg";
+ assert(!std::regex_search(s, m, std::regex("abc$", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abc";
+ assert(std::regex_search(s, m, std::regex("a.c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "acc";
+ assert(std::regex_search(s, m, std::regex("a.c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "acc";
+ assert(std::regex_search(s, m, std::regex("a.c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcdef";
+ assert(std::regex_search(s, m, std::regex("\\(.*\\).*", std::regex_constants::basic)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+6);
+ assert(m.length(0) == 6);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 6);
+ assert(m.position(1) == 0);
+ assert(m.str(1) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "bc";
+ assert(std::regex_search(s, m, std::regex("\\(a*\\)*", std::regex_constants::basic)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+2);
+ assert(m.length(0) == 0);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "");
+ assert(m.length(1) == 0);
+ assert(m.position(1) == 0);
+ assert(m.str(1) == "");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbc";
+ assert(!std::regex_search(s, m, std::regex("ab\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbc";
+ assert(std::regex_search(s, m, std::regex("ab\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == sizeof(s)-1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbbc";
+ assert(std::regex_search(s, m, std::regex("ab\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == sizeof(s)-1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbbbc";
+ assert(std::regex_search(s, m, std::regex("ab\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == sizeof(s)-1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefc";
+ assert(!std::regex_search(s, m, std::regex("ab\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbbbbc";
+ assert(!std::regex_search(s, m, std::regex("ab\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adec";
+ assert(!std::regex_search(s, m, std::regex("a.\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefc";
+ assert(std::regex_search(s, m, std::regex("a.\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == sizeof(s)-1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefgc";
+ assert(std::regex_search(s, m, std::regex("a.\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == sizeof(s)-1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefghc";
+ assert(std::regex_search(s, m, std::regex("a.\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == sizeof(s)-1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefghic";
+ assert(!std::regex_search(s, m, std::regex("a.\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "-ab,ab-";
+ assert(std::regex_search(s, m, std::regex("-\\(.*\\),\\1-", std::regex_constants::basic)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 2);
+ assert(m.position(1) == 1);
+ assert(m.str(1) == "ab");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ababbabb";
+ assert(std::regex_search(s, m, std::regex("^\\(ab*\\)*\\1$", std::regex_constants::basic)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 3);
+ assert(m.position(1) == 2);
+ assert(m.str(1) == "abb");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ababbab";
+ assert(!std::regex_search(s, m, std::regex("^\\(ab*\\)*\\1$", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "aBAbbAbB";
+ assert(std::regex_search(s, m, std::regex("^\\(Ab*\\)*\\1$",
+ std::regex_constants::basic | std::regex_constants::icase)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 3);
+ assert(m.position(1) == 2);
+ assert(m.str(1) == "Abb");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "aBAbbAbB";
+ assert(!std::regex_search(s, m, std::regex("^\\(Ab*\\)*\\1$",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "a";
+ assert(std::regex_search(s, m, std::regex("^[a]$",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "a");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "a";
+ assert(std::regex_search(s, m, std::regex("^[ab]$",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "a");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "c";
+ assert(std::regex_search(s, m, std::regex("^[a-f]$",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "g";
+ assert(!std::regex_search(s, m, std::regex("^[a-f]$",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "Iraqi";
+ assert(std::regex_search(s, m, std::regex("q[^u]",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 3);
+ assert(m.str(0) == "qi");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "Iraq";
+ assert(!std::regex_search(s, m, std::regex("q[^u]",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AmB";
+ assert(std::regex_search(s, m, std::regex("A[[:lower:]]B",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AMB";
+ assert(!std::regex_search(s, m, std::regex("A[[:lower:]]B",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AMB";
+ assert(std::regex_search(s, m, std::regex("A[^[:lower:]]B",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AmB";
+ assert(!std::regex_search(s, m, std::regex("A[^[:lower:]]B",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "A5B";
+ assert(!std::regex_search(s, m, std::regex("A[^[:lower:]0-9]B",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "A?B";
+ assert(std::regex_search(s, m, std::regex("A[^[:lower:]0-9]B",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "-";
+ assert(std::regex_search(s, m, std::regex("[a[.hyphen.]z]",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "z";
+ assert(std::regex_search(s, m, std::regex("[a[.hyphen.]z]",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "m";
+ assert(!std::regex_search(s, m, std::regex("[a[.hyphen.]z]",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ std::locale::global(std::locale(LOCALE_cs_CZ_ISO8859_2));
+ {
+ std::cmatch m;
+ const char s[] = "m";
+ assert(std::regex_search(s, m, std::regex("[a[=M=]z]",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "Ch";
+ assert(std::regex_search(s, m, std::regex("[a[.ch.]z]",
+ std::regex_constants::basic | std::regex_constants::icase)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ std::locale::global(std::locale("C"));
+ {
+ std::cmatch m;
+ const char s[] = "m";
+ assert(!std::regex_search(s, m, std::regex("[a[=M=]z]",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "01a45cef9";
+ assert(std::regex_search(s, m, std::regex("[ace1-9]*",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<char>::length(s));
+ assert(m.length(0) == 0);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "01a45cef9";
+ assert(std::regex_search(s, m, std::regex("[ace1-9]\\{1,\\}",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<char>::length(s));
+ assert(m.length(0) == 6);
+ assert(m.position(0) == 1);
+ assert(m.str(0) == "1a45ce");
+ }
+ {
+ const char r[] = "^[-+]\\{0,1\\}[0-9]\\{1,\\}[CF]$";
+ std::ptrdiff_t sr = std::char_traits<char>::length(r);
+ typedef forward_iterator<const char*> FI;
+ typedef bidirectional_iterator<const char*> BI;
+ std::regex regex(FI(r), FI(r+sr), std::regex_constants::basic);
+ std::match_results<BI> m;
+ const char s[] = "-40C";
+ std::ptrdiff_t ss = std::char_traits<char>::length(s);
+ assert(std::regex_search(BI(s), BI(s+ss), m, regex));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == BI(s));
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+
+ {
+ std::wcmatch m;
+ assert(!std::regex_search(L"a", m, std::wregex()));
+ assert(m.size() == 0);
+ assert(m.empty());
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"a";
+ assert(std::regex_search(s, m, std::wregex(L"a", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.empty());
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+1);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"a");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ab";
+ assert(std::regex_search(s, m, std::wregex(L"ab", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+2);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"ab");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ab";
+ assert(!std::regex_search(s, m, std::wregex(L"ba", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ assert(m.empty());
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"aab";
+ assert(std::regex_search(s, m, std::wregex(L"ab", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 1);
+ assert(m.str(0) == L"ab");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"aab";
+ assert(!std::regex_search(s, m, std::wregex(L"ab", std::regex_constants::basic),
+ std::regex_constants::match_continuous));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcd";
+ assert(std::regex_search(s, m, std::wregex(L"bc", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 1);
+ assert(m.str(0) == L"bc");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbc";
+ assert(std::regex_search(s, m, std::wregex(L"ab*c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ababc";
+ assert(std::regex_search(s, m, std::wregex(L"\\(ab\\)*c", std::regex_constants::basic)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+5);
+ assert(m.length(0) == 5);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 2);
+ assert(m.position(1) == 2);
+ assert(m.str(1) == L"ab");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcdefghijk";
+ assert(std::regex_search(s, m, std::wregex(L"cd\\(\\(e\\)fg\\)hi",
+ std::regex_constants::basic)));
+ assert(m.size() == 3);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+std::regex_traits<wchar_t>::length(s));
+ assert(m.length(0) == 7);
+ assert(m.position(0) == 2);
+ assert(m.str(0) == L"cdefghi");
+ assert(m.length(1) == 3);
+ assert(m.position(1) == 4);
+ assert(m.str(1) == L"efg");
+ assert(m.length(2) == 1);
+ assert(m.position(2) == 4);
+ assert(m.str(2) == L"e");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abc";
+ assert(std::regex_search(s, m, std::wregex(L"^abc", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcd";
+ assert(std::regex_search(s, m, std::wregex(L"^abc", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"abc");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"aabc";
+ assert(!std::regex_search(s, m, std::wregex(L"^abc", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abc";
+ assert(std::regex_search(s, m, std::wregex(L"abc$", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"efabc";
+ assert(std::regex_search(s, m, std::wregex(L"abc$", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+5);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 2);
+ assert(m.str(0) == s+2);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"efabcg";
+ assert(!std::regex_search(s, m, std::wregex(L"abc$", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abc";
+ assert(std::regex_search(s, m, std::wregex(L"a.c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"acc";
+ assert(std::regex_search(s, m, std::wregex(L"a.c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"acc";
+ assert(std::regex_search(s, m, std::wregex(L"a.c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcdef";
+ assert(std::regex_search(s, m, std::wregex(L"\\(.*\\).*", std::regex_constants::basic)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+6);
+ assert(m.length(0) == 6);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 6);
+ assert(m.position(1) == 0);
+ assert(m.str(1) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"bc";
+ assert(std::regex_search(s, m, std::wregex(L"\\(a*\\)*", std::regex_constants::basic)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+2);
+ assert(m.length(0) == 0);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"");
+ assert(m.length(1) == 0);
+ assert(m.position(1) == 0);
+ assert(m.str(1) == L"");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbc";
+ assert(!std::regex_search(s, m, std::wregex(L"ab\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbc";
+ assert(std::regex_search(s, m, std::wregex(L"ab\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbbc";
+ assert(std::regex_search(s, m, std::wregex(L"ab\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbbbc";
+ assert(std::regex_search(s, m, std::wregex(L"ab\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefc";
+ assert(!std::regex_search(s, m, std::wregex(L"ab\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbbbbc";
+ assert(!std::regex_search(s, m, std::wregex(L"ab\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adec";
+ assert(!std::regex_search(s, m, std::wregex(L"a.\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefc";
+ assert(std::regex_search(s, m, std::wregex(L"a.\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefgc";
+ assert(std::regex_search(s, m, std::wregex(L"a.\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefghc";
+ assert(std::regex_search(s, m, std::wregex(L"a.\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefghic";
+ assert(!std::regex_search(s, m, std::wregex(L"a.\\{3,5\\}c", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"-ab,ab-";
+ assert(std::regex_search(s, m, std::wregex(L"-\\(.*\\),\\1-", std::regex_constants::basic)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 2);
+ assert(m.position(1) == 1);
+ assert(m.str(1) == L"ab");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ababbabb";
+ assert(std::regex_search(s, m, std::wregex(L"^\\(ab*\\)*\\1$", std::regex_constants::basic)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 3);
+ assert(m.position(1) == 2);
+ assert(m.str(1) == L"abb");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ababbab";
+ assert(!std::regex_search(s, m, std::wregex(L"^\\(ab*\\)*\\1$", std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"aBAbbAbB";
+ assert(std::regex_search(s, m, std::wregex(L"^\\(Ab*\\)*\\1$",
+ std::regex_constants::basic | std::regex_constants::icase)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 3);
+ assert(m.position(1) == 2);
+ assert(m.str(1) == L"Abb");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"aBAbbAbB";
+ assert(!std::regex_search(s, m, std::wregex(L"^\\(Ab*\\)*\\1$",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"a";
+ assert(std::regex_search(s, m, std::wregex(L"^[a]$",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"a");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"a";
+ assert(std::regex_search(s, m, std::wregex(L"^[ab]$",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"a");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"c";
+ assert(std::regex_search(s, m, std::wregex(L"^[a-f]$",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"g";
+ assert(!std::regex_search(s, m, std::wregex(L"^[a-f]$",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"Iraqi";
+ assert(std::regex_search(s, m, std::wregex(L"q[^u]",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 3);
+ assert(m.str(0) == L"qi");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"Iraq";
+ assert(!std::regex_search(s, m, std::wregex(L"q[^u]",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AmB";
+ assert(std::regex_search(s, m, std::wregex(L"A[[:lower:]]B",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AMB";
+ assert(!std::regex_search(s, m, std::wregex(L"A[[:lower:]]B",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AMB";
+ assert(std::regex_search(s, m, std::wregex(L"A[^[:lower:]]B",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AmB";
+ assert(!std::regex_search(s, m, std::wregex(L"A[^[:lower:]]B",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"A5B";
+ assert(!std::regex_search(s, m, std::wregex(L"A[^[:lower:]0-9]B",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"A?B";
+ assert(std::regex_search(s, m, std::wregex(L"A[^[:lower:]0-9]B",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"-";
+ assert(std::regex_search(s, m, std::wregex(L"[a[.hyphen.]z]",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"z";
+ assert(std::regex_search(s, m, std::wregex(L"[a[.hyphen.]z]",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(!std::regex_search(s, m, std::wregex(L"[a[.hyphen.]z]",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ std::locale::global(std::locale(LOCALE_cs_CZ_ISO8859_2));
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(std::regex_search(s, m, std::wregex(L"[a[=M=]z]",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"Ch";
+ assert(std::regex_search(s, m, std::wregex(L"[a[.ch.]z]",
+ std::regex_constants::basic | std::regex_constants::icase)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ std::locale::global(std::locale("C"));
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(!std::regex_search(s, m, std::wregex(L"[a[=M=]z]",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"01a45cef9";
+ assert(std::regex_search(s, m, std::wregex(L"[ace1-9]*",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<wchar_t>::length(s));
+ assert(m.length(0) == 0);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"01a45cef9";
+ assert(std::regex_search(s, m, std::wregex(L"[ace1-9]\\{1,\\}",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<wchar_t>::length(s));
+ assert(m.length(0) == 6);
+ assert(m.position(0) == 1);
+ assert(m.str(0) == L"1a45ce");
+ }
+ {
+ const wchar_t r[] = L"^[-+]\\{0,1\\}[0-9]\\{1,\\}[CF]$";
+ std::ptrdiff_t sr = std::char_traits<wchar_t>::length(r);
+ typedef forward_iterator<const wchar_t*> FI;
+ typedef bidirectional_iterator<const wchar_t*> BI;
+ std::wregex regex(FI(r), FI(r+sr), std::regex_constants::basic);
+ std::match_results<BI> m;
+ const wchar_t s[] = L"-40C";
+ std::ptrdiff_t ss = std::char_traits<wchar_t>::length(s);
+ assert(std::regex_search(BI(s), BI(s+ss), m, regex));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == BI(s));
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+}
diff --git a/test/std/re/re.alg/re.alg.search/ecma.pass.cpp b/test/std/re/re.alg/re.alg.search/ecma.pass.cpp
new file mode 100644
index 000000000000..fb9fc26a281a
--- /dev/null
+++ b/test/std/re/re.alg/re.alg.search/ecma.pass.cpp
@@ -0,0 +1,1589 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: locale.cs_CZ.ISO8859-2
+
+// <regex>
+
+// template <class BidirectionalIterator, class Allocator, class charT, class traits>
+// bool
+// regex_search(BidirectionalIterator first, BidirectionalIterator last,
+// match_results<BidirectionalIterator, Allocator>& m,
+// const basic_regex<charT, traits>& e,
+// regex_constants::match_flag_type flags = regex_constants::match_default);
+
+// TODO: investigation needed
+// XFAIL: linux-gnu
+
+#include <regex>
+#include <cassert>
+#include "test_iterators.h"
+
+#include "platform_support.h" // locale name macros
+
+int main()
+{
+ {
+ std::cmatch m;
+ const char s[] = "a";
+ assert(std::regex_search(s, m, std::regex("a")));
+ assert(m.size() == 1);
+ assert(!m.empty());
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+1);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "a");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ab";
+ assert(std::regex_search(s, m, std::regex("ab")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+2);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "ab");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ab";
+ assert(!std::regex_search(s, m, std::regex("ba")));
+ assert(m.size() == 0);
+ assert(m.empty());
+ }
+ {
+ std::cmatch m;
+ const char s[] = "aab";
+ assert(std::regex_search(s, m, std::regex("ab")));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 1);
+ assert(m.str(0) == "ab");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "aab";
+ assert(!std::regex_search(s, m, std::regex("ab"),
+ std::regex_constants::match_continuous));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcd";
+ assert(std::regex_search(s, m, std::regex("bc")));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 1);
+ assert(m.str(0) == "bc");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbc";
+ assert(std::regex_search(s, m, std::regex("ab*c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ababc";
+ assert(std::regex_search(s, m, std::regex("(ab)*c")));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+5);
+ assert(m.length(0) == 5);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 2);
+ assert(m.position(1) == 2);
+ assert(m.str(1) == "ab");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcdefghijk";
+ assert(std::regex_search(s, m, std::regex("cd((e)fg)hi")));
+ assert(m.size() == 3);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+std::regex_traits<char>::length(s));
+ assert(m.length(0) == 7);
+ assert(m.position(0) == 2);
+ assert(m.str(0) == "cdefghi");
+ assert(m.length(1) == 3);
+ assert(m.position(1) == 4);
+ assert(m.str(1) == "efg");
+ assert(m.length(2) == 1);
+ assert(m.position(2) == 4);
+ assert(m.str(2) == "e");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abc";
+ assert(std::regex_search(s, m, std::regex("^abc")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcd";
+ assert(std::regex_search(s, m, std::regex("^abc")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "abc");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "aabc";
+ assert(!std::regex_search(s, m, std::regex("^abc")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abc";
+ assert(std::regex_search(s, m, std::regex("abc$")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "efabc";
+ assert(std::regex_search(s, m, std::regex("abc$")));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+5);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 2);
+ assert(m.str(0) == s+2);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "efabcg";
+ assert(!std::regex_search(s, m, std::regex("abc$")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abc";
+ assert(std::regex_search(s, m, std::regex("a.c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "acc";
+ assert(std::regex_search(s, m, std::regex("a.c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "acc";
+ assert(std::regex_search(s, m, std::regex("a.c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcdef";
+ assert(std::regex_search(s, m, std::regex("(.*).*")));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+6);
+ assert(m.length(0) == 6);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 6);
+ assert(m.position(1) == 0);
+ assert(m.str(1) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "bc";
+ assert(std::regex_search(s, m, std::regex("(a*)*")));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+2);
+ assert(m.length(0) == 0);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "");
+ assert(m.length(1) == 0);
+ assert(m.position(1) == 0);
+ assert(m.str(1) == "");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbc";
+ assert(!std::regex_search(s, m, std::regex("ab{3,5}c")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbc";
+ assert(std::regex_search(s, m, std::regex("ab{3,5}c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbbc";
+ assert(std::regex_search(s, m, std::regex("ab{3,5}c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbbbc";
+ assert(std::regex_search(s, m, std::regex("ab{3,5}c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefc";
+ assert(!std::regex_search(s, m, std::regex("ab{3,5}c")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbbbbc";
+ assert(!std::regex_search(s, m, std::regex("ab{3,5}c")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adec";
+ assert(!std::regex_search(s, m, std::regex("a.{3,5}c")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefc";
+ assert(std::regex_search(s, m, std::regex("a.{3,5}c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefgc";
+ assert(std::regex_search(s, m, std::regex("a.{3,5}c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefghc";
+ assert(std::regex_search(s, m, std::regex("a.{3,5}c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefghic";
+ assert(!std::regex_search(s, m, std::regex("a.{3,5}c")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "tournament";
+ assert(std::regex_search(s, m, std::regex("tour|to|tournament")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<char>::length(s));
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "tour");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "tournamenttotour";
+ assert(std::regex_search(s, m, std::regex("(tour|to|tournament)+",
+ std::regex_constants::nosubs)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<char>::length(s));
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "tour");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ttotour";
+ assert(std::regex_search(s, m, std::regex("(tour|to|t)+")));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 4);
+ assert(m.position(1) == 3);
+ assert(m.str(1) == "tour");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "-ab,ab-";
+ assert(!std::regex_search(s, m, std::regex("-(.*),\1-")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "-ab,ab-";
+ assert(std::regex_search(s, m, std::regex("-.*,.*-")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "a";
+ assert(std::regex_search(s, m, std::regex("^[a]$")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "a");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "a";
+ assert(std::regex_search(s, m, std::regex("^[ab]$")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "a");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "c";
+ assert(std::regex_search(s, m, std::regex("^[a-f]$")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "g";
+ assert(!std::regex_search(s, m, std::regex("^[a-f]$")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "Iraqi";
+ assert(std::regex_search(s, m, std::regex("q[^u]")));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 3);
+ assert(m.str(0) == "qi");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "Iraq";
+ assert(!std::regex_search(s, m, std::regex("q[^u]")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AmB";
+ assert(std::regex_search(s, m, std::regex("A[[:lower:]]B")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AMB";
+ assert(!std::regex_search(s, m, std::regex("A[[:lower:]]B")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AMB";
+ assert(std::regex_search(s, m, std::regex("A[^[:lower:]]B")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AmB";
+ assert(!std::regex_search(s, m, std::regex("A[^[:lower:]]B")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "A5B";
+ assert(!std::regex_search(s, m, std::regex("A[^[:lower:]0-9]B")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "A?B";
+ assert(std::regex_search(s, m, std::regex("A[^[:lower:]0-9]B")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "-";
+ assert(std::regex_search(s, m, std::regex("[a[.hyphen.]z]")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "z";
+ assert(std::regex_search(s, m, std::regex("[a[.hyphen.]z]")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "m";
+ assert(!std::regex_search(s, m, std::regex("[a[.hyphen.]z]")));
+ assert(m.size() == 0);
+ }
+ std::locale::global(std::locale(LOCALE_cs_CZ_ISO8859_2));
+ {
+ std::cmatch m;
+ const char s[] = "m";
+ assert(std::regex_search(s, m, std::regex("[a[=M=]z]")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "Ch";
+ assert(std::regex_search(s, m, std::regex("[a[.ch.]z]",
+ std::regex_constants::icase)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ std::locale::global(std::locale("C"));
+ {
+ std::cmatch m;
+ const char s[] = "m";
+ assert(!std::regex_search(s, m, std::regex("[a[=M=]z]")));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "01a45cef9";
+ assert(std::regex_search(s, m, std::regex("[ace1-9]*")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<char>::length(s));
+ assert(m.length(0) == 0);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "01a45cef9";
+ assert(std::regex_search(s, m, std::regex("[ace1-9]+")));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<char>::length(s));
+ assert(m.length(0) == 6);
+ assert(m.position(0) == 1);
+ assert(m.str(0) == "1a45ce");
+ }
+ {
+ const char r[] = "^[-+]?[0-9]+[CF]$";
+ std::ptrdiff_t sr = std::char_traits<char>::length(r);
+ typedef forward_iterator<const char*> FI;
+ typedef bidirectional_iterator<const char*> BI;
+ std::regex regex(FI(r), FI(r+sr));
+ std::match_results<BI> m;
+ const char s[] = "-40C";
+ std::ptrdiff_t ss = std::char_traits<char>::length(s);
+ assert(std::regex_search(BI(s), BI(s+ss), m, regex));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == BI(s));
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "Jeff Jeffs ";
+ assert(std::regex_search(s, m, std::regex("Jeff(?=s\\b)")));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<char>::length(s));
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 5);
+ assert(m.str(0) == "Jeff");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "Jeffs Jeff";
+ assert(std::regex_search(s, m, std::regex("Jeff(?!s\\b)")));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<char>::length(s));
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 6);
+ assert(m.str(0) == "Jeff");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "5%k";
+ assert(std::regex_search(s, m, std::regex("\\d[\\W]k")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<char>::length(s));
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"a";
+ assert(std::regex_search(s, m, std::wregex(L"a")));
+ assert(m.size() == 1);
+ assert(!m.empty());
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+1);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"a");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ab";
+ assert(std::regex_search(s, m, std::wregex(L"ab")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+2);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"ab");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ab";
+ assert(!std::regex_search(s, m, std::wregex(L"ba")));
+ assert(m.size() == 0);
+ assert(m.empty());
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"aab";
+ assert(std::regex_search(s, m, std::wregex(L"ab")));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 1);
+ assert(m.str(0) == L"ab");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"aab";
+ assert(!std::regex_search(s, m, std::wregex(L"ab"),
+ std::regex_constants::match_continuous));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcd";
+ assert(std::regex_search(s, m, std::wregex(L"bc")));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 1);
+ assert(m.str(0) == L"bc");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbc";
+ assert(std::regex_search(s, m, std::wregex(L"ab*c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ababc";
+ assert(std::regex_search(s, m, std::wregex(L"(ab)*c")));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+5);
+ assert(m.length(0) == 5);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 2);
+ assert(m.position(1) == 2);
+ assert(m.str(1) == L"ab");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcdefghijk";
+ assert(std::regex_search(s, m, std::wregex(L"cd((e)fg)hi")));
+ assert(m.size() == 3);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+std::regex_traits<wchar_t>::length(s));
+ assert(m.length(0) == 7);
+ assert(m.position(0) == 2);
+ assert(m.str(0) == L"cdefghi");
+ assert(m.length(1) == 3);
+ assert(m.position(1) == 4);
+ assert(m.str(1) == L"efg");
+ assert(m.length(2) == 1);
+ assert(m.position(2) == 4);
+ assert(m.str(2) == L"e");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abc";
+ assert(std::regex_search(s, m, std::wregex(L"^abc")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcd";
+ assert(std::regex_search(s, m, std::wregex(L"^abc")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"abc");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"aabc";
+ assert(!std::regex_search(s, m, std::wregex(L"^abc")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abc";
+ assert(std::regex_search(s, m, std::wregex(L"abc$")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"efabc";
+ assert(std::regex_search(s, m, std::wregex(L"abc$")));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+5);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 2);
+ assert(m.str(0) == s+2);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"efabcg";
+ assert(!std::regex_search(s, m, std::wregex(L"abc$")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abc";
+ assert(std::regex_search(s, m, std::wregex(L"a.c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"acc";
+ assert(std::regex_search(s, m, std::wregex(L"a.c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"acc";
+ assert(std::regex_search(s, m, std::wregex(L"a.c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcdef";
+ assert(std::regex_search(s, m, std::wregex(L"(.*).*")));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+6);
+ assert(m.length(0) == 6);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 6);
+ assert(m.position(1) == 0);
+ assert(m.str(1) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"bc";
+ assert(std::regex_search(s, m, std::wregex(L"(a*)*")));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+2);
+ assert(m.length(0) == 0);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"");
+ assert(m.length(1) == 0);
+ assert(m.position(1) == 0);
+ assert(m.str(1) == L"");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbc";
+ assert(!std::regex_search(s, m, std::wregex(L"ab{3,5}c")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbc";
+ assert(std::regex_search(s, m, std::wregex(L"ab{3,5}c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbbc";
+ assert(std::regex_search(s, m, std::wregex(L"ab{3,5}c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbbbc";
+ assert(std::regex_search(s, m, std::wregex(L"ab{3,5}c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefc";
+ assert(!std::regex_search(s, m, std::wregex(L"ab{3,5}c")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbbbbc";
+ assert(!std::regex_search(s, m, std::wregex(L"ab{3,5}c")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adec";
+ assert(!std::regex_search(s, m, std::wregex(L"a.{3,5}c")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefc";
+ assert(std::regex_search(s, m, std::wregex(L"a.{3,5}c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefgc";
+ assert(std::regex_search(s, m, std::wregex(L"a.{3,5}c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefghc";
+ assert(std::regex_search(s, m, std::wregex(L"a.{3,5}c")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefghic";
+ assert(!std::regex_search(s, m, std::wregex(L"a.{3,5}c")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"tournament";
+ assert(std::regex_search(s, m, std::wregex(L"tour|to|tournament")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<wchar_t>::length(s));
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"tour");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"tournamenttotour";
+ assert(std::regex_search(s, m, std::wregex(L"(tour|to|tournament)+",
+ std::regex_constants::nosubs)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<wchar_t>::length(s));
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"tour");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ttotour";
+ assert(std::regex_search(s, m, std::wregex(L"(tour|to|t)+")));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 4);
+ assert(m.position(1) == 3);
+ assert(m.str(1) == L"tour");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"-ab,ab-";
+ assert(!std::regex_search(s, m, std::wregex(L"-(.*),\1-")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"-ab,ab-";
+ assert(std::regex_search(s, m, std::wregex(L"-.*,.*-")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"a";
+ assert(std::regex_search(s, m, std::wregex(L"^[a]$")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"a");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"a";
+ assert(std::regex_search(s, m, std::wregex(L"^[ab]$")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"a");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"c";
+ assert(std::regex_search(s, m, std::wregex(L"^[a-f]$")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"g";
+ assert(!std::regex_search(s, m, std::wregex(L"^[a-f]$")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"Iraqi";
+ assert(std::regex_search(s, m, std::wregex(L"q[^u]")));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 3);
+ assert(m.str(0) == L"qi");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"Iraq";
+ assert(!std::regex_search(s, m, std::wregex(L"q[^u]")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AmB";
+ assert(std::regex_search(s, m, std::wregex(L"A[[:lower:]]B")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AMB";
+ assert(!std::regex_search(s, m, std::wregex(L"A[[:lower:]]B")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AMB";
+ assert(std::regex_search(s, m, std::wregex(L"A[^[:lower:]]B")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AmB";
+ assert(!std::regex_search(s, m, std::wregex(L"A[^[:lower:]]B")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"A5B";
+ assert(!std::regex_search(s, m, std::wregex(L"A[^[:lower:]0-9]B")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"A?B";
+ assert(std::regex_search(s, m, std::wregex(L"A[^[:lower:]0-9]B")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"-";
+ assert(std::regex_search(s, m, std::wregex(L"[a[.hyphen.]z]")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"z";
+ assert(std::regex_search(s, m, std::wregex(L"[a[.hyphen.]z]")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(!std::regex_search(s, m, std::wregex(L"[a[.hyphen.]z]")));
+ assert(m.size() == 0);
+ }
+ std::locale::global(std::locale(LOCALE_cs_CZ_ISO8859_2));
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(std::regex_search(s, m, std::wregex(L"[a[=M=]z]")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"Ch";
+ assert(std::regex_search(s, m, std::wregex(L"[a[.ch.]z]",
+ std::regex_constants::icase)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ std::locale::global(std::locale("C"));
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(!std::regex_search(s, m, std::wregex(L"[a[=M=]z]")));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"01a45cef9";
+ assert(std::regex_search(s, m, std::wregex(L"[ace1-9]*")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<wchar_t>::length(s));
+ assert(m.length(0) == 0);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"01a45cef9";
+ assert(std::regex_search(s, m, std::wregex(L"[ace1-9]+")));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<wchar_t>::length(s));
+ assert(m.length(0) == 6);
+ assert(m.position(0) == 1);
+ assert(m.str(0) == L"1a45ce");
+ }
+ {
+ const wchar_t r[] = L"^[-+]?[0-9]+[CF]$";
+ std::ptrdiff_t sr = std::char_traits<wchar_t>::length(r);
+ typedef forward_iterator<const wchar_t*> FI;
+ typedef bidirectional_iterator<const wchar_t*> BI;
+ std::wregex regex(FI(r), FI(r+sr));
+ std::match_results<BI> m;
+ const wchar_t s[] = L"-40C";
+ std::ptrdiff_t ss = std::char_traits<wchar_t>::length(s);
+ assert(std::regex_search(BI(s), BI(s+ss), m, regex));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == BI(s));
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"Jeff Jeffs ";
+ assert(std::regex_search(s, m, std::wregex(L"Jeff(?=s\\b)")));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<wchar_t>::length(s));
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 5);
+ assert(m.str(0) == L"Jeff");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"Jeffs Jeff";
+ assert(std::regex_search(s, m, std::wregex(L"Jeff(?!s\\b)")));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<wchar_t>::length(s));
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 6);
+ assert(m.str(0) == L"Jeff");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"5%k";
+ assert(std::regex_search(s, m, std::wregex(L"\\d[\\W]k")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<wchar_t>::length(s));
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+}
diff --git a/test/std/re/re.alg/re.alg.search/egrep.pass.cpp b/test/std/re/re.alg/re.alg.search/egrep.pass.cpp
new file mode 100644
index 000000000000..1dffed44f227
--- /dev/null
+++ b/test/std/re/re.alg/re.alg.search/egrep.pass.cpp
@@ -0,0 +1,90 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class BidirectionalIterator, class Allocator, class charT, class traits>
+// bool
+// regex_search(BidirectionalIterator first, BidirectionalIterator last,
+// match_results<BidirectionalIterator, Allocator>& m,
+// const basic_regex<charT, traits>& e,
+// regex_constants::match_flag_type flags = regex_constants::match_default);
+
+#include <regex>
+#include <cassert>
+
+#include "test_iterators.h"
+
+int main()
+{
+ {
+ std::cmatch m;
+ const char s[] = "tournament";
+ assert(std::regex_search(s, m, std::regex("tour\nto\ntournament",
+ std::regex_constants::egrep)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<char>::length(s));
+ assert(m.length(0) == 10);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "tournament");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ment";
+ assert(std::regex_search(s, m, std::regex("tour\n\ntournament",
+ std::regex_constants::egrep)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<char>::length(s));
+ assert(m.length(0) == 0);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "tournament";
+ assert(std::regex_search(s, m, std::regex("(tour|to|tournament)+\ntourna",
+ std::regex_constants::egrep)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<char>::length(s));
+ assert(m.length(0) == 10);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "tournament");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "tourna";
+ assert(std::regex_search(s, m, std::regex("(tour|to|tournament)+\ntourna",
+ std::regex_constants::egrep)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<char>::length(s));
+ assert(m.length(0) == 6);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "tourna");
+ }
+}
diff --git a/test/std/re/re.alg/re.alg.search/extended.pass.cpp b/test/std/re/re.alg/re.alg.search/extended.pass.cpp
new file mode 100644
index 000000000000..81eef2f9e4b9
--- /dev/null
+++ b/test/std/re/re.alg/re.alg.search/extended.pass.cpp
@@ -0,0 +1,1543 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: locale.cs_CZ.ISO8859-2
+
+// <regex>
+
+// template <class BidirectionalIterator, class Allocator, class charT, class traits>
+// bool
+// regex_search(BidirectionalIterator first, BidirectionalIterator last,
+// match_results<BidirectionalIterator, Allocator>& m,
+// const basic_regex<charT, traits>& e,
+// regex_constants::match_flag_type flags = regex_constants::match_default);
+
+// TODO: investigation needed
+// XFAIL: linux-gnu
+
+#include <regex>
+#include <cassert>
+#include "test_iterators.h"
+
+#include "platform_support.h" // locale name macros
+
+int main()
+{
+ {
+ std::cmatch m;
+ const char s[] = "a";
+ assert(std::regex_search(s, m, std::regex("a", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.empty());
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+1);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "a");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ab";
+ assert(std::regex_search(s, m, std::regex("ab", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+2);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "ab");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ab";
+ assert(!std::regex_search(s, m, std::regex("ba", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ assert(m.empty());
+ }
+ {
+ std::cmatch m;
+ const char s[] = "aab";
+ assert(std::regex_search(s, m, std::regex("ab", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 1);
+ assert(m.str(0) == "ab");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "aab";
+ assert(!std::regex_search(s, m, std::regex("ab", std::regex_constants::extended),
+ std::regex_constants::match_continuous));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcd";
+ assert(std::regex_search(s, m, std::regex("bc", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 1);
+ assert(m.str(0) == "bc");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbc";
+ assert(std::regex_search(s, m, std::regex("ab*c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ababc";
+ assert(std::regex_search(s, m, std::regex("(ab)*c", std::regex_constants::extended)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+5);
+ assert(m.length(0) == 5);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 2);
+ assert(m.position(1) == 2);
+ assert(m.str(1) == "ab");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcdefghijk";
+ assert(std::regex_search(s, m, std::regex("cd((e)fg)hi",
+ std::regex_constants::extended)));
+ assert(m.size() == 3);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+std::regex_traits<char>::length(s));
+ assert(m.length(0) == 7);
+ assert(m.position(0) == 2);
+ assert(m.str(0) == "cdefghi");
+ assert(m.length(1) == 3);
+ assert(m.position(1) == 4);
+ assert(m.str(1) == "efg");
+ assert(m.length(2) == 1);
+ assert(m.position(2) == 4);
+ assert(m.str(2) == "e");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abc";
+ assert(std::regex_search(s, m, std::regex("^abc", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcd";
+ assert(std::regex_search(s, m, std::regex("^abc", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "abc");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "aabc";
+ assert(!std::regex_search(s, m, std::regex("^abc", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abc";
+ assert(std::regex_search(s, m, std::regex("abc$", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "efabc";
+ assert(std::regex_search(s, m, std::regex("abc$", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+5);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 2);
+ assert(m.str(0) == s+2);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "efabcg";
+ assert(!std::regex_search(s, m, std::regex("abc$", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abc";
+ assert(std::regex_search(s, m, std::regex("a.c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "acc";
+ assert(std::regex_search(s, m, std::regex("a.c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "acc";
+ assert(std::regex_search(s, m, std::regex("a.c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abcdef";
+ assert(std::regex_search(s, m, std::regex("(.*).*", std::regex_constants::extended)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+6);
+ assert(m.length(0) == 6);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 6);
+ assert(m.position(1) == 0);
+ assert(m.str(1) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "bc";
+ assert(std::regex_search(s, m, std::regex("(a*)*", std::regex_constants::extended)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+2);
+ assert(m.length(0) == 0);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "");
+ assert(m.length(1) == 0);
+ assert(m.position(1) == 0);
+ assert(m.str(1) == "");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbc";
+ assert(!std::regex_search(s, m, std::regex("ab{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbc";
+ assert(std::regex_search(s, m, std::regex("ab{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbbc";
+ assert(std::regex_search(s, m, std::regex("ab{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbbbc";
+ assert(std::regex_search(s, m, std::regex("ab{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefc";
+ assert(!std::regex_search(s, m, std::regex("ab{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "abbbbbbc";
+ assert(!std::regex_search(s, m, std::regex("ab{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adec";
+ assert(!std::regex_search(s, m, std::regex("a.{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefc";
+ assert(std::regex_search(s, m, std::regex("a.{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefgc";
+ assert(std::regex_search(s, m, std::regex("a.{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefghc";
+ assert(std::regex_search(s, m, std::regex("a.{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "adefghic";
+ assert(!std::regex_search(s, m, std::regex("a.{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "tournament";
+ assert(std::regex_search(s, m, std::regex("tour|to|tournament",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "tournamenttotour";
+ assert(std::regex_search(s, m, std::regex("(tour|to|tournament)+",
+ std::regex_constants::extended | std::regex_constants::nosubs)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ttotour";
+ assert(std::regex_search(s, m, std::regex("(tour|to|t)+",
+ std::regex_constants::extended)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 4);
+ assert(m.position(1) == 3);
+ assert(m.str(1) == "tour");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "-ab,ab-";
+ assert(!std::regex_search(s, m, std::regex("-(.*),\1-", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "-ab,ab-";
+ assert(std::regex_search(s, m, std::regex("-.*,.*-", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "a";
+ assert(std::regex_search(s, m, std::regex("^[a]$",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "a");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "a";
+ assert(std::regex_search(s, m, std::regex("^[ab]$",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "a");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "c";
+ assert(std::regex_search(s, m, std::regex("^[a-f]$",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "g";
+ assert(!std::regex_search(s, m, std::regex("^[a-f]$",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "Iraqi";
+ assert(std::regex_search(s, m, std::regex("q[^u]",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 3);
+ assert(m.str(0) == "qi");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "Iraq";
+ assert(!std::regex_search(s, m, std::regex("q[^u]",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AmB";
+ assert(std::regex_search(s, m, std::regex("A[[:lower:]]B",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AMB";
+ assert(!std::regex_search(s, m, std::regex("A[[:lower:]]B",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AMB";
+ assert(std::regex_search(s, m, std::regex("A[^[:lower:]]B",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "AmB";
+ assert(!std::regex_search(s, m, std::regex("A[^[:lower:]]B",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "A5B";
+ assert(!std::regex_search(s, m, std::regex("A[^[:lower:]0-9]B",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "A?B";
+ assert(std::regex_search(s, m, std::regex("A[^[:lower:]0-9]B",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "-";
+ assert(std::regex_search(s, m, std::regex("[a[.hyphen.]z]",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "z";
+ assert(std::regex_search(s, m, std::regex("[a[.hyphen.]z]",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "m";
+ assert(!std::regex_search(s, m, std::regex("[a[.hyphen.]z]",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ std::locale::global(std::locale(LOCALE_cs_CZ_ISO8859_2));
+ {
+ std::cmatch m;
+ const char s[] = "m";
+ assert(std::regex_search(s, m, std::regex("[a[=M=]z]",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "Ch";
+ assert(std::regex_search(s, m, std::regex("[a[.ch.]z]",
+ std::regex_constants::extended | std::regex_constants::icase)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ std::locale::global(std::locale("C"));
+ {
+ std::cmatch m;
+ const char s[] = "m";
+ assert(!std::regex_search(s, m, std::regex("[a[=M=]z]",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "01a45cef9";
+ assert(std::regex_search(s, m, std::regex("[ace1-9]*",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<char>::length(s));
+ assert(m.length(0) == 0);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "01a45cef9";
+ assert(std::regex_search(s, m, std::regex("[ace1-9]+",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<char>::length(s));
+ assert(m.length(0) == 6);
+ assert(m.position(0) == 1);
+ assert(m.str(0) == "1a45ce");
+ }
+ {
+ const char r[] = "^[-+]?[0-9]+[CF]$";
+ std::ptrdiff_t sr = std::char_traits<char>::length(r);
+ typedef forward_iterator<const char*> FI;
+ typedef bidirectional_iterator<const char*> BI;
+ std::regex regex(FI(r), FI(r+sr), std::regex_constants::extended);
+ std::match_results<BI> m;
+ const char s[] = "-40C";
+ std::ptrdiff_t ss = std::char_traits<char>::length(s);
+ assert(std::regex_search(BI(s), BI(s+ss), m, regex));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == BI(s));
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"a";
+ assert(std::regex_search(s, m, std::wregex(L"a", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.empty());
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+1);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"a");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ab";
+ assert(std::regex_search(s, m, std::wregex(L"ab", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+2);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"ab");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ab";
+ assert(!std::regex_search(s, m, std::wregex(L"ba", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ assert(m.empty());
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"aab";
+ assert(std::regex_search(s, m, std::wregex(L"ab", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 1);
+ assert(m.str(0) == L"ab");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"aab";
+ assert(!std::regex_search(s, m, std::wregex(L"ab", std::regex_constants::extended),
+ std::regex_constants::match_continuous));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcd";
+ assert(std::regex_search(s, m, std::wregex(L"bc", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 1);
+ assert(m.str(0) == L"bc");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbc";
+ assert(std::regex_search(s, m, std::wregex(L"ab*c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ababc";
+ assert(std::regex_search(s, m, std::wregex(L"(ab)*c", std::regex_constants::extended)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+5);
+ assert(m.length(0) == 5);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 2);
+ assert(m.position(1) == 2);
+ assert(m.str(1) == L"ab");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcdefghijk";
+ assert(std::regex_search(s, m, std::wregex(L"cd((e)fg)hi",
+ std::regex_constants::extended)));
+ assert(m.size() == 3);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+std::regex_traits<wchar_t>::length(s));
+ assert(m.length(0) == 7);
+ assert(m.position(0) == 2);
+ assert(m.str(0) == L"cdefghi");
+ assert(m.length(1) == 3);
+ assert(m.position(1) == 4);
+ assert(m.str(1) == L"efg");
+ assert(m.length(2) == 1);
+ assert(m.position(2) == 4);
+ assert(m.str(2) == L"e");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abc";
+ assert(std::regex_search(s, m, std::wregex(L"^abc", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcd";
+ assert(std::regex_search(s, m, std::wregex(L"^abc", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+4);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"abc");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"aabc";
+ assert(!std::regex_search(s, m, std::wregex(L"^abc", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abc";
+ assert(std::regex_search(s, m, std::wregex(L"abc$", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"efabc";
+ assert(std::regex_search(s, m, std::wregex(L"abc$", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+5);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 2);
+ assert(m.str(0) == s+2);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"efabcg";
+ assert(!std::regex_search(s, m, std::wregex(L"abc$", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abc";
+ assert(std::regex_search(s, m, std::wregex(L"a.c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"acc";
+ assert(std::regex_search(s, m, std::wregex(L"a.c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"acc";
+ assert(std::regex_search(s, m, std::wregex(L"a.c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+3);
+ assert(m.length(0) == 3);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abcdef";
+ assert(std::regex_search(s, m, std::wregex(L"(.*).*", std::regex_constants::extended)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+6);
+ assert(m.length(0) == 6);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 6);
+ assert(m.position(1) == 0);
+ assert(m.str(1) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"bc";
+ assert(std::regex_search(s, m, std::wregex(L"(a*)*", std::regex_constants::extended)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s+2);
+ assert(m.length(0) == 0);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"");
+ assert(m.length(1) == 0);
+ assert(m.position(1) == 0);
+ assert(m.str(1) == L"");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbc";
+ assert(!std::regex_search(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbc";
+ assert(std::regex_search(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbbc";
+ assert(std::regex_search(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbbbc";
+ assert(std::regex_search(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefc";
+ assert(!std::regex_search(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"abbbbbbc";
+ assert(!std::regex_search(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adec";
+ assert(!std::regex_search(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefc";
+ assert(std::regex_search(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefgc";
+ assert(std::regex_search(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefghc";
+ assert(std::regex_search(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"adefghic";
+ assert(!std::regex_search(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"tournament";
+ assert(std::regex_search(s, m, std::wregex(L"tour|to|tournament",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"tournamenttotour";
+ assert(std::regex_search(s, m, std::wregex(L"(tour|to|tournament)+",
+ std::regex_constants::extended | std::regex_constants::nosubs)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"ttotour";
+ assert(std::regex_search(s, m, std::wregex(L"(tour|to|t)+",
+ std::regex_constants::extended)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 4);
+ assert(m.position(1) == 3);
+ assert(m.str(1) == L"tour");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"-ab,ab-";
+ assert(!std::regex_search(s, m, std::wregex(L"-(.*),\1-", std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"-ab,ab-";
+ assert(std::regex_search(s, m, std::wregex(L"-.*,.*-", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"a";
+ assert(std::regex_search(s, m, std::wregex(L"^[a]$",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"a");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"a";
+ assert(std::regex_search(s, m, std::wregex(L"^[ab]$",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"a");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"c";
+ assert(std::regex_search(s, m, std::wregex(L"^[a-f]$",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 1);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"g";
+ assert(!std::regex_search(s, m, std::wregex(L"^[a-f]$",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"Iraqi";
+ assert(std::regex_search(s, m, std::wregex(L"q[^u]",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 2);
+ assert(m.position(0) == 3);
+ assert(m.str(0) == L"qi");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"Iraq";
+ assert(!std::regex_search(s, m, std::wregex(L"q[^u]",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AmB";
+ assert(std::regex_search(s, m, std::wregex(L"A[[:lower:]]B",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AMB";
+ assert(!std::regex_search(s, m, std::wregex(L"A[[:lower:]]B",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AMB";
+ assert(std::regex_search(s, m, std::wregex(L"A[^[:lower:]]B",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"AmB";
+ assert(!std::regex_search(s, m, std::wregex(L"A[^[:lower:]]B",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"A5B";
+ assert(!std::regex_search(s, m, std::wregex(L"A[^[:lower:]0-9]B",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"A?B";
+ assert(std::regex_search(s, m, std::wregex(L"A[^[:lower:]0-9]B",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"-";
+ assert(std::regex_search(s, m, std::wregex(L"[a[.hyphen.]z]",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"z";
+ assert(std::regex_search(s, m, std::wregex(L"[a[.hyphen.]z]",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(!std::regex_search(s, m, std::wregex(L"[a[.hyphen.]z]",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ std::locale::global(std::locale(LOCALE_cs_CZ_ISO8859_2));
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(std::regex_search(s, m, std::wregex(L"[a[=M=]z]",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"Ch";
+ assert(std::regex_search(s, m, std::wregex(L"[a[.ch.]z]",
+ std::regex_constants::extended | std::regex_constants::icase)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ std::locale::global(std::locale("C"));
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(!std::regex_search(s, m, std::wregex(L"[a[=M=]z]",
+ std::regex_constants::extended)));
+ assert(m.size() == 0);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"01a45cef9";
+ assert(std::regex_search(s, m, std::wregex(L"[ace1-9]*",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<wchar_t>::length(s));
+ assert(m.length(0) == 0);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"01a45cef9";
+ assert(std::regex_search(s, m, std::wregex(L"[ace1-9]+",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<wchar_t>::length(s));
+ assert(m.length(0) == 6);
+ assert(m.position(0) == 1);
+ assert(m.str(0) == L"1a45ce");
+ }
+ {
+ const wchar_t r[] = L"^[-+]?[0-9]+[CF]$";
+ std::ptrdiff_t sr = std::char_traits<wchar_t>::length(r);
+ typedef forward_iterator<const wchar_t*> FI;
+ typedef bidirectional_iterator<const wchar_t*> BI;
+ std::wregex regex(FI(r), FI(r+sr), std::regex_constants::extended);
+ std::match_results<BI> m;
+ const wchar_t s[] = L"-40C";
+ std::ptrdiff_t ss = std::char_traits<wchar_t>::length(s);
+ assert(std::regex_search(BI(s), BI(s+ss), m, regex));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == BI(s));
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == 4);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+}
diff --git a/test/std/re/re.alg/re.alg.search/grep.pass.cpp b/test/std/re/re.alg/re.alg.search/grep.pass.cpp
new file mode 100644
index 000000000000..113243ecd349
--- /dev/null
+++ b/test/std/re/re.alg/re.alg.search/grep.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class BidirectionalIterator, class Allocator, class charT, class traits>
+// bool
+// regex_search(BidirectionalIterator first, BidirectionalIterator last,
+// match_results<BidirectionalIterator, Allocator>& m,
+// const basic_regex<charT, traits>& e,
+// regex_constants::match_flag_type flags = regex_constants::match_default);
+
+#include <regex>
+#include <cassert>
+
+#include "test_iterators.h"
+
+int main()
+{
+ {
+ std::cmatch m;
+ const char s[] = "tournament";
+ assert(std::regex_search(s, m, std::regex("tour\nto\ntournament",
+ std::regex_constants::grep)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<char>::length(s));
+ assert(m.length(0) == 10);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "tournament");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ment";
+ assert(std::regex_search(s, m, std::regex("tour\n\ntournament",
+ std::regex_constants::grep)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<char>::length(s));
+ assert(m.length(0) == 0);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "");
+ }
+}
diff --git a/test/std/re/re.alg/re.alg.search/lookahead.pass.cpp b/test/std/re/re.alg/re.alg.search/lookahead.pass.cpp
new file mode 100644
index 000000000000..9f5f9540165a
--- /dev/null
+++ b/test/std/re/re.alg/re.alg.search/lookahead.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class BidirectionalIterator, class Allocator, class charT, class traits>
+// bool
+// regex_search(BidirectionalIterator first, BidirectionalIterator last,
+// match_results<BidirectionalIterator, Allocator>& m,
+// const basic_regex<charT, traits>& e,
+// regex_constants::match_flag_type flags = regex_constants::match_default);
+
+// http://llvm.org/bugs/show_bug.cgi?id=11118
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ assert(!std::regex_search("ab", std::regex("(?=^)b")));
+ assert(!std::regex_search("ab", std::regex("a(?=^)b")));
+}
diff --git a/test/std/re/re.alg/re.alg.search/no_update_pos.pass.cpp b/test/std/re/re.alg/re.alg.search/no_update_pos.pass.cpp
new file mode 100644
index 000000000000..ef9cec5f736e
--- /dev/null
+++ b/test/std/re/re.alg/re.alg.search/no_update_pos.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class BidirectionalIterator, class Allocator, class charT, class traits>
+// bool
+// regex_search(BidirectionalIterator first, BidirectionalIterator last,
+// match_results<BidirectionalIterator, Allocator>& m,
+// const basic_regex<charT, traits>& e,
+// regex_constants::match_flag_type flags = regex_constants::match_default);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ // Iterating over /^a/ should yield one instance at the beginning
+ // of the text.
+
+ const char *text = "aaa\naa";
+ std::regex re("^a");
+ std::cregex_iterator it(text, text+6, re);
+ std::cregex_iterator end = std::cregex_iterator();
+
+ assert(it->str() == "a");
+ assert(it->position(0) == 0);
+ assert(it->length(0) == 1);
+
+ ++it;
+ assert(it == end);
+}
diff --git a/test/std/re/re.alg/re.except/nothing_to_do.pass.cpp b/test/std/re/re.alg/re.except/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/re/re.alg/re.except/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/re/re.badexp/regex_error.pass.cpp b/test/std/re/re.badexp/regex_error.pass.cpp
new file mode 100644
index 000000000000..02fecbda2d95
--- /dev/null
+++ b/test/std/re/re.badexp/regex_error.pass.cpp
@@ -0,0 +1,96 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class regex_error
+// : public runtime_error
+// {
+// public:
+// explicit regex_error(regex_constants::error_type ecode);
+// regex_constants::error_type code() const;
+// };
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ std::regex_error e(std::regex_constants::error_collate);
+ assert(e.code() == std::regex_constants::error_collate);
+ assert(e.what() == std::string("The expression contained an invalid collating element name."));
+ }
+ {
+ std::regex_error e(std::regex_constants::error_ctype);
+ assert(e.code() == std::regex_constants::error_ctype);
+ assert(e.what() == std::string("The expression contained an invalid character class name."));
+ }
+ {
+ std::regex_error e(std::regex_constants::error_escape);
+ assert(e.code() == std::regex_constants::error_escape);
+ assert(e.what() == std::string("The expression contained an invalid escaped character, or a "
+ "trailing escape."));
+ }
+ {
+ std::regex_error e(std::regex_constants::error_backref);
+ assert(e.code() == std::regex_constants::error_backref);
+ assert(e.what() == std::string("The expression contained an invalid back reference."));
+ }
+ {
+ std::regex_error e(std::regex_constants::error_brack);
+ assert(e.code() == std::regex_constants::error_brack);
+ assert(e.what() == std::string("The expression contained mismatched [ and ]."));
+ }
+ {
+ std::regex_error e(std::regex_constants::error_paren);
+ assert(e.code() == std::regex_constants::error_paren);
+ assert(e.what() == std::string("The expression contained mismatched ( and )."));
+ }
+ {
+ std::regex_error e(std::regex_constants::error_brace);
+ assert(e.code() == std::regex_constants::error_brace);
+ assert(e.what() == std::string("The expression contained mismatched { and }."));
+ }
+ {
+ std::regex_error e(std::regex_constants::error_badbrace);
+ assert(e.code() == std::regex_constants::error_badbrace);
+ assert(e.what() == std::string("The expression contained an invalid range in a {} expression."));
+ }
+ {
+ std::regex_error e(std::regex_constants::error_range);
+ assert(e.code() == std::regex_constants::error_range);
+ assert(e.what() == std::string("The expression contained an invalid character range, "
+ "such as [b-a] in most encodings."));
+ }
+ {
+ std::regex_error e(std::regex_constants::error_space);
+ assert(e.code() == std::regex_constants::error_space);
+ assert(e.what() == std::string("There was insufficient memory to convert the expression into "
+ "a finite state machine."));
+ }
+ {
+ std::regex_error e(std::regex_constants::error_badrepeat);
+ assert(e.code() == std::regex_constants::error_badrepeat);
+ assert(e.what() == std::string("One of *?+{ was not preceded by a valid regular expression."));
+ }
+ {
+ std::regex_error e(std::regex_constants::error_complexity);
+ assert(e.code() == std::regex_constants::error_complexity);
+ assert(e.what() == std::string("The complexity of an attempted match against a regular "
+ "expression exceeded a pre-set level."));
+ }
+ {
+ std::regex_error e(std::regex_constants::error_stack);
+ assert(e.code() == std::regex_constants::error_stack);
+ assert(e.what() == std::string("There was insufficient memory to determine whether the regular "
+ "expression could match the specified character sequence."));
+ }
+}
diff --git a/test/std/re/re.const/nothing_to_do.pass.cpp b/test/std/re/re.const/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..9a59227abdd9
--- /dev/null
+++ b/test/std/re/re.const/nothing_to_do.pass.cpp
@@ -0,0 +1,13 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/re/re.const/re.err/error_type.pass.cpp b/test/std/re/re.const/re.err/error_type.pass.cpp
new file mode 100644
index 000000000000..150855beb0a4
--- /dev/null
+++ b/test/std/re/re.const/re.err/error_type.pass.cpp
@@ -0,0 +1,143 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// namespace regex_constants
+// {
+//
+// enum error_type
+// {
+// error_collate = unspecified,
+// error_ctype = unspecified,
+// error_escape = unspecified,
+// error_backref = unspecified,
+// error_brack = unspecified,
+// error_paren = unspecified,
+// error_brace = unspecified,
+// error_badbrace = unspecified,
+// error_range = unspecified,
+// error_space = unspecified,
+// error_badrepeat = unspecified,
+// error_complexity = unspecified,
+// error_stack = unspecified
+// };
+//
+// }
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ assert(std::regex_constants::error_collate != 0);
+ assert(std::regex_constants::error_ctype != 0);
+ assert(std::regex_constants::error_escape != 0);
+ assert(std::regex_constants::error_backref != 0);
+ assert(std::regex_constants::error_brack != 0);
+ assert(std::regex_constants::error_paren != 0);
+ assert(std::regex_constants::error_brace != 0);
+ assert(std::regex_constants::error_badbrace != 0);
+ assert(std::regex_constants::error_range != 0);
+ assert(std::regex_constants::error_space != 0);
+ assert(std::regex_constants::error_badrepeat != 0);
+ assert(std::regex_constants::error_complexity != 0);
+ assert(std::regex_constants::error_stack != 0);
+
+ assert(std::regex_constants::error_collate != std::regex_constants::error_ctype);
+ assert(std::regex_constants::error_collate != std::regex_constants::error_escape);
+ assert(std::regex_constants::error_collate != std::regex_constants::error_backref);
+ assert(std::regex_constants::error_collate != std::regex_constants::error_brack);
+ assert(std::regex_constants::error_collate != std::regex_constants::error_paren);
+ assert(std::regex_constants::error_collate != std::regex_constants::error_brace);
+ assert(std::regex_constants::error_collate != std::regex_constants::error_badbrace);
+ assert(std::regex_constants::error_collate != std::regex_constants::error_range);
+ assert(std::regex_constants::error_collate != std::regex_constants::error_space);
+ assert(std::regex_constants::error_collate != std::regex_constants::error_badrepeat);
+ assert(std::regex_constants::error_collate != std::regex_constants::error_complexity);
+ assert(std::regex_constants::error_collate != std::regex_constants::error_stack);
+
+ assert(std::regex_constants::error_ctype != std::regex_constants::error_escape);
+ assert(std::regex_constants::error_ctype != std::regex_constants::error_backref);
+ assert(std::regex_constants::error_ctype != std::regex_constants::error_brack);
+ assert(std::regex_constants::error_ctype != std::regex_constants::error_paren);
+ assert(std::regex_constants::error_ctype != std::regex_constants::error_brace);
+ assert(std::regex_constants::error_ctype != std::regex_constants::error_badbrace);
+ assert(std::regex_constants::error_ctype != std::regex_constants::error_range);
+ assert(std::regex_constants::error_ctype != std::regex_constants::error_space);
+ assert(std::regex_constants::error_ctype != std::regex_constants::error_badrepeat);
+ assert(std::regex_constants::error_ctype != std::regex_constants::error_complexity);
+ assert(std::regex_constants::error_ctype != std::regex_constants::error_stack);
+
+ assert(std::regex_constants::error_escape != std::regex_constants::error_backref);
+ assert(std::regex_constants::error_escape != std::regex_constants::error_brack);
+ assert(std::regex_constants::error_escape != std::regex_constants::error_paren);
+ assert(std::regex_constants::error_escape != std::regex_constants::error_brace);
+ assert(std::regex_constants::error_escape != std::regex_constants::error_badbrace);
+ assert(std::regex_constants::error_escape != std::regex_constants::error_range);
+ assert(std::regex_constants::error_escape != std::regex_constants::error_space);
+ assert(std::regex_constants::error_escape != std::regex_constants::error_badrepeat);
+ assert(std::regex_constants::error_escape != std::regex_constants::error_complexity);
+ assert(std::regex_constants::error_escape != std::regex_constants::error_stack);
+
+ assert(std::regex_constants::error_backref != std::regex_constants::error_brack);
+ assert(std::regex_constants::error_backref != std::regex_constants::error_paren);
+ assert(std::regex_constants::error_backref != std::regex_constants::error_brace);
+ assert(std::regex_constants::error_backref != std::regex_constants::error_badbrace);
+ assert(std::regex_constants::error_backref != std::regex_constants::error_range);
+ assert(std::regex_constants::error_backref != std::regex_constants::error_space);
+ assert(std::regex_constants::error_backref != std::regex_constants::error_badrepeat);
+ assert(std::regex_constants::error_backref != std::regex_constants::error_complexity);
+ assert(std::regex_constants::error_backref != std::regex_constants::error_stack);
+
+ assert(std::regex_constants::error_brack != std::regex_constants::error_paren);
+ assert(std::regex_constants::error_brack != std::regex_constants::error_brace);
+ assert(std::regex_constants::error_brack != std::regex_constants::error_badbrace);
+ assert(std::regex_constants::error_brack != std::regex_constants::error_range);
+ assert(std::regex_constants::error_brack != std::regex_constants::error_space);
+ assert(std::regex_constants::error_brack != std::regex_constants::error_badrepeat);
+ assert(std::regex_constants::error_brack != std::regex_constants::error_complexity);
+ assert(std::regex_constants::error_brack != std::regex_constants::error_stack);
+
+ assert(std::regex_constants::error_paren != std::regex_constants::error_brace);
+ assert(std::regex_constants::error_paren != std::regex_constants::error_badbrace);
+ assert(std::regex_constants::error_paren != std::regex_constants::error_range);
+ assert(std::regex_constants::error_paren != std::regex_constants::error_space);
+ assert(std::regex_constants::error_paren != std::regex_constants::error_badrepeat);
+ assert(std::regex_constants::error_paren != std::regex_constants::error_complexity);
+ assert(std::regex_constants::error_paren != std::regex_constants::error_stack);
+
+ assert(std::regex_constants::error_brace != std::regex_constants::error_badbrace);
+ assert(std::regex_constants::error_brace != std::regex_constants::error_range);
+ assert(std::regex_constants::error_brace != std::regex_constants::error_space);
+ assert(std::regex_constants::error_brace != std::regex_constants::error_badrepeat);
+ assert(std::regex_constants::error_brace != std::regex_constants::error_complexity);
+ assert(std::regex_constants::error_brace != std::regex_constants::error_stack);
+
+ assert(std::regex_constants::error_badbrace != std::regex_constants::error_range);
+ assert(std::regex_constants::error_badbrace != std::regex_constants::error_space);
+ assert(std::regex_constants::error_badbrace != std::regex_constants::error_badrepeat);
+ assert(std::regex_constants::error_badbrace != std::regex_constants::error_complexity);
+ assert(std::regex_constants::error_badbrace != std::regex_constants::error_stack);
+
+ assert(std::regex_constants::error_range != std::regex_constants::error_space);
+ assert(std::regex_constants::error_range != std::regex_constants::error_badrepeat);
+ assert(std::regex_constants::error_range != std::regex_constants::error_complexity);
+ assert(std::regex_constants::error_range != std::regex_constants::error_stack);
+
+ assert(std::regex_constants::error_space != std::regex_constants::error_badrepeat);
+ assert(std::regex_constants::error_space != std::regex_constants::error_complexity);
+ assert(std::regex_constants::error_space != std::regex_constants::error_stack);
+
+ assert(std::regex_constants::error_badrepeat != std::regex_constants::error_complexity);
+ assert(std::regex_constants::error_badrepeat != std::regex_constants::error_stack);
+
+ assert(std::regex_constants::error_complexity != std::regex_constants::error_stack);
+}
diff --git a/test/std/re/re.const/re.matchflag/match_flag_type.pass.cpp b/test/std/re/re.const/re.matchflag/match_flag_type.pass.cpp
new file mode 100644
index 000000000000..b48703c7579f
--- /dev/null
+++ b/test/std/re/re.const/re.matchflag/match_flag_type.pass.cpp
@@ -0,0 +1,128 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// namespace regex_constants
+// {
+//
+// emum match_flag_type // bitmask type
+// {
+// match_default = 0,
+// match_not_bol = unspecified,
+// match_not_eol = unspecified,
+// match_not_bow = unspecified,
+// match_not_eow = unspecified,
+// match_any = unspecified,
+// match_not_null = unspecified,
+// match_continuous = unspecified,
+// match_prev_avail = unspecified,
+// format_default = 0,
+// format_sed = unspecified,
+// format_no_copy = unspecified,
+// format_first_only = unspecified
+// };
+//
+// }
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ assert(std::regex_constants::match_default == 0);
+ assert(std::regex_constants::match_not_bol != 0);
+ assert(std::regex_constants::match_not_eol != 0);
+ assert(std::regex_constants::match_not_bow != 0);
+ assert(std::regex_constants::match_not_eow != 0);
+ assert(std::regex_constants::match_any != 0);
+ assert(std::regex_constants::match_not_null != 0);
+ assert(std::regex_constants::match_continuous != 0);
+ assert(std::regex_constants::match_prev_avail != 0);
+ assert(std::regex_constants::format_default == 0);
+ assert(std::regex_constants::format_sed != 0);
+ assert(std::regex_constants::format_no_copy != 0);
+ assert(std::regex_constants::format_first_only != 0);
+
+ assert((std::regex_constants::match_not_bol & std::regex_constants::match_not_eol) == 0);
+ assert((std::regex_constants::match_not_bol & std::regex_constants::match_not_bow) == 0);
+ assert((std::regex_constants::match_not_bol & std::regex_constants::match_not_eow) == 0);
+ assert((std::regex_constants::match_not_bol & std::regex_constants::match_any) == 0);
+ assert((std::regex_constants::match_not_bol & std::regex_constants::match_not_null) == 0);
+ assert((std::regex_constants::match_not_bol & std::regex_constants::match_continuous) == 0);
+ assert((std::regex_constants::match_not_bol & std::regex_constants::match_prev_avail) == 0);
+ assert((std::regex_constants::match_not_bol & std::regex_constants::format_sed) == 0);
+ assert((std::regex_constants::match_not_bol & std::regex_constants::format_no_copy) == 0);
+ assert((std::regex_constants::match_not_bol & std::regex_constants::format_first_only) == 0);
+
+ assert((std::regex_constants::match_not_eol & std::regex_constants::match_not_bow) == 0);
+ assert((std::regex_constants::match_not_eol & std::regex_constants::match_not_eow) == 0);
+ assert((std::regex_constants::match_not_eol & std::regex_constants::match_any) == 0);
+ assert((std::regex_constants::match_not_eol & std::regex_constants::match_not_null) == 0);
+ assert((std::regex_constants::match_not_eol & std::regex_constants::match_continuous) == 0);
+ assert((std::regex_constants::match_not_eol & std::regex_constants::match_prev_avail) == 0);
+ assert((std::regex_constants::match_not_eol & std::regex_constants::format_sed) == 0);
+ assert((std::regex_constants::match_not_eol & std::regex_constants::format_no_copy) == 0);
+ assert((std::regex_constants::match_not_eol & std::regex_constants::format_first_only) == 0);
+
+ assert((std::regex_constants::match_not_bow & std::regex_constants::match_not_eow) == 0);
+ assert((std::regex_constants::match_not_bow & std::regex_constants::match_any) == 0);
+ assert((std::regex_constants::match_not_bow & std::regex_constants::match_not_null) == 0);
+ assert((std::regex_constants::match_not_bow & std::regex_constants::match_continuous) == 0);
+ assert((std::regex_constants::match_not_bow & std::regex_constants::match_prev_avail) == 0);
+ assert((std::regex_constants::match_not_bow & std::regex_constants::format_sed) == 0);
+ assert((std::regex_constants::match_not_bow & std::regex_constants::format_no_copy) == 0);
+ assert((std::regex_constants::match_not_bow & std::regex_constants::format_first_only) == 0);
+
+ assert((std::regex_constants::match_not_eow & std::regex_constants::match_any) == 0);
+ assert((std::regex_constants::match_not_eow & std::regex_constants::match_not_null) == 0);
+ assert((std::regex_constants::match_not_eow & std::regex_constants::match_continuous) == 0);
+ assert((std::regex_constants::match_not_eow & std::regex_constants::match_prev_avail) == 0);
+ assert((std::regex_constants::match_not_eow & std::regex_constants::format_sed) == 0);
+ assert((std::regex_constants::match_not_eow & std::regex_constants::format_no_copy) == 0);
+ assert((std::regex_constants::match_not_eow & std::regex_constants::format_first_only) == 0);
+
+ assert((std::regex_constants::match_any & std::regex_constants::match_not_null) == 0);
+ assert((std::regex_constants::match_any & std::regex_constants::match_continuous) == 0);
+ assert((std::regex_constants::match_any & std::regex_constants::match_prev_avail) == 0);
+ assert((std::regex_constants::match_any & std::regex_constants::format_sed) == 0);
+ assert((std::regex_constants::match_any & std::regex_constants::format_no_copy) == 0);
+ assert((std::regex_constants::match_any & std::regex_constants::format_first_only) == 0);
+
+ assert((std::regex_constants::match_not_null & std::regex_constants::match_continuous) == 0);
+ assert((std::regex_constants::match_not_null & std::regex_constants::match_prev_avail) == 0);
+ assert((std::regex_constants::match_not_null & std::regex_constants::format_sed) == 0);
+ assert((std::regex_constants::match_not_null & std::regex_constants::format_no_copy) == 0);
+ assert((std::regex_constants::match_not_null & std::regex_constants::format_first_only) == 0);
+
+ assert((std::regex_constants::match_continuous & std::regex_constants::match_prev_avail) == 0);
+ assert((std::regex_constants::match_continuous & std::regex_constants::format_sed) == 0);
+ assert((std::regex_constants::match_continuous & std::regex_constants::format_no_copy) == 0);
+ assert((std::regex_constants::match_continuous & std::regex_constants::format_first_only) == 0);
+
+ assert((std::regex_constants::match_prev_avail & std::regex_constants::format_sed) == 0);
+ assert((std::regex_constants::match_prev_avail & std::regex_constants::format_no_copy) == 0);
+ assert((std::regex_constants::match_prev_avail & std::regex_constants::format_first_only) == 0);
+
+ assert((std::regex_constants::format_sed & std::regex_constants::format_no_copy) == 0);
+ assert((std::regex_constants::format_sed & std::regex_constants::format_first_only) == 0);
+
+ assert((std::regex_constants::format_no_copy & std::regex_constants::format_first_only) == 0);
+
+ std::regex_constants::match_flag_type e1 = std::regex_constants::match_not_bol;
+ std::regex_constants::match_flag_type e2 = std::regex_constants::match_not_eol;
+ e1 = ~e1;
+ e1 = e1 & e2;
+ e1 = e1 | e2;
+ e1 = e1 ^ e2;
+ e1 &= e2;
+ e1 |= e2;
+ e1 ^= e2;
+}
diff --git a/test/std/re/re.const/re.matchflag/match_not_bol.pass.cpp b/test/std/re/re.const/re.matchflag/match_not_bol.pass.cpp
new file mode 100644
index 000000000000..41ac0cee0d6a
--- /dev/null
+++ b/test/std/re/re.const/re.matchflag/match_not_bol.pass.cpp
@@ -0,0 +1,50 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// match_not_bol:
+// The first character in the sequence [first,last) shall be treated as
+// though it is not at the beginning of a line, so the character ^ in the
+// regular expression shall not match [first,first).
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ std::string target = "foo";
+ std::regex re("^foo");
+ assert( std::regex_match(target, re));
+ assert(!std::regex_match(target, re, std::regex_constants::match_not_bol));
+ }
+
+ {
+ std::string target = "foo";
+ std::regex re("foo");
+ assert( std::regex_match(target, re));
+ assert( std::regex_match(target, re, std::regex_constants::match_not_bol));
+ }
+
+ {
+ std::string target = "fooby";
+ std::regex re("^foo");
+ assert( std::regex_search(target, re));
+ assert(!std::regex_search(target, re, std::regex_constants::match_not_bol));
+ }
+
+ {
+ std::string target = "fooby";
+ std::regex re("foo");
+ assert( std::regex_search(target, re));
+ assert( std::regex_search(target, re, std::regex_constants::match_not_bol));
+ }
+}
diff --git a/test/std/re/re.const/re.matchflag/match_not_eol.pass.cpp b/test/std/re/re.const/re.matchflag/match_not_eol.pass.cpp
new file mode 100644
index 000000000000..594c9fb98453
--- /dev/null
+++ b/test/std/re/re.const/re.matchflag/match_not_eol.pass.cpp
@@ -0,0 +1,50 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// match_not_eol:
+// The last character in the sequence [first,last) shall be treated as
+// though it is not at the end of a line, so the character "$" in
+// the regular expression shall not match [last,last).
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ std::string target = "foo";
+ std::regex re("foo$");
+ assert( std::regex_match(target, re));
+ assert(!std::regex_match(target, re, std::regex_constants::match_not_eol));
+ }
+
+ {
+ std::string target = "foo";
+ std::regex re("foo");
+ assert( std::regex_match(target, re));
+ assert( std::regex_match(target, re, std::regex_constants::match_not_eol));
+ }
+
+ {
+ std::string target = "refoo";
+ std::regex re("foo$");
+ assert( std::regex_search(target, re));
+ assert(!std::regex_search(target, re, std::regex_constants::match_not_eol));
+ }
+
+ {
+ std::string target = "refoo";
+ std::regex re("foo");
+ assert( std::regex_search(target, re));
+ assert( std::regex_search(target, re, std::regex_constants::match_not_eol));
+ }
+}
diff --git a/test/std/re/re.const/re.synopt/syntax_option_type.pass.cpp b/test/std/re/re.const/re.synopt/syntax_option_type.pass.cpp
new file mode 100644
index 000000000000..1c4f824448a6
--- /dev/null
+++ b/test/std/re/re.const/re.synopt/syntax_option_type.pass.cpp
@@ -0,0 +1,114 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// namespace regex_constants
+// {
+//
+// emum syntax_option_type // bitmask type
+// {
+// icase = unspecified,
+// nosubs = unspecified,
+// optimize = unspecified,
+// collate = unspecified,
+// ECMAScript = unspecified,
+// basic = unspecified,
+// extended = unspecified,
+// awk = unspecified,
+// grep = unspecified,
+// egrep = unspecified
+// };
+//
+// }
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ assert(std::regex_constants::icase != 0);
+ assert(std::regex_constants::nosubs != 0);
+ assert(std::regex_constants::optimize != 0);
+ assert(std::regex_constants::collate != 0);
+ assert(std::regex_constants::ECMAScript == 0);
+ assert(std::regex_constants::basic != 0);
+ assert(std::regex_constants::extended != 0);
+ assert(std::regex_constants::awk != 0);
+ assert(std::regex_constants::grep != 0);
+ assert(std::regex_constants::egrep != 0);
+
+ assert((std::regex_constants::icase & std::regex_constants::nosubs) == 0);
+ assert((std::regex_constants::icase & std::regex_constants::optimize) == 0);
+ assert((std::regex_constants::icase & std::regex_constants::collate) == 0);
+ assert((std::regex_constants::icase & std::regex_constants::ECMAScript) == 0);
+ assert((std::regex_constants::icase & std::regex_constants::basic) == 0);
+ assert((std::regex_constants::icase & std::regex_constants::extended) == 0);
+ assert((std::regex_constants::icase & std::regex_constants::awk) == 0);
+ assert((std::regex_constants::icase & std::regex_constants::grep) == 0);
+ assert((std::regex_constants::icase & std::regex_constants::egrep) == 0);
+
+ assert((std::regex_constants::nosubs & std::regex_constants::optimize) == 0);
+ assert((std::regex_constants::nosubs & std::regex_constants::collate) == 0);
+ assert((std::regex_constants::nosubs & std::regex_constants::ECMAScript) == 0);
+ assert((std::regex_constants::nosubs & std::regex_constants::basic) == 0);
+ assert((std::regex_constants::nosubs & std::regex_constants::extended) == 0);
+ assert((std::regex_constants::nosubs & std::regex_constants::awk) == 0);
+ assert((std::regex_constants::nosubs & std::regex_constants::grep) == 0);
+ assert((std::regex_constants::nosubs & std::regex_constants::egrep) == 0);
+
+ assert((std::regex_constants::optimize & std::regex_constants::collate) == 0);
+ assert((std::regex_constants::optimize & std::regex_constants::ECMAScript) == 0);
+ assert((std::regex_constants::optimize & std::regex_constants::basic) == 0);
+ assert((std::regex_constants::optimize & std::regex_constants::extended) == 0);
+ assert((std::regex_constants::optimize & std::regex_constants::awk) == 0);
+ assert((std::regex_constants::optimize & std::regex_constants::grep) == 0);
+ assert((std::regex_constants::optimize & std::regex_constants::egrep) == 0);
+
+ assert((std::regex_constants::collate & std::regex_constants::ECMAScript) == 0);
+ assert((std::regex_constants::collate & std::regex_constants::basic) == 0);
+ assert((std::regex_constants::collate & std::regex_constants::extended) == 0);
+ assert((std::regex_constants::collate & std::regex_constants::awk) == 0);
+ assert((std::regex_constants::collate & std::regex_constants::grep) == 0);
+ assert((std::regex_constants::collate & std::regex_constants::egrep) == 0);
+
+ assert((std::regex_constants::ECMAScript & std::regex_constants::basic) == 0);
+ assert((std::regex_constants::ECMAScript & std::regex_constants::extended) == 0);
+ assert((std::regex_constants::ECMAScript & std::regex_constants::awk) == 0);
+ assert((std::regex_constants::ECMAScript & std::regex_constants::grep) == 0);
+ assert((std::regex_constants::ECMAScript & std::regex_constants::egrep) == 0);
+
+ assert((std::regex_constants::basic & std::regex_constants::extended) == 0);
+ assert((std::regex_constants::basic & std::regex_constants::awk) == 0);
+ assert((std::regex_constants::basic & std::regex_constants::grep) == 0);
+ assert((std::regex_constants::basic & std::regex_constants::egrep) == 0);
+
+ assert((std::regex_constants::extended & std::regex_constants::awk) == 0);
+ assert((std::regex_constants::extended & std::regex_constants::grep) == 0);
+ assert((std::regex_constants::extended & std::regex_constants::egrep) == 0);
+
+ assert((std::regex_constants::awk & std::regex_constants::grep) == 0);
+ assert((std::regex_constants::awk & std::regex_constants::egrep) == 0);
+
+ assert((std::regex_constants::grep & std::regex_constants::egrep) == 0);
+
+ assert((std::regex_constants::icase | std::regex_constants::nosubs) != 0);
+ assert((std::regex_constants::icase ^ std::regex_constants::nosubs) != 0);
+
+ std::regex_constants::syntax_option_type e1 = std::regex_constants::icase;
+ std::regex_constants::syntax_option_type e2 = std::regex_constants::nosubs;
+ e1 = ~e1;
+ e1 = e1 & e2;
+ e1 = e1 | e2;
+ e1 = e1 ^ e2;
+ e1 &= e2;
+ e1 |= e2;
+ e1 ^= e2;
+}
diff --git a/test/std/re/re.def/defns.regex.collating.element/nothing_to_do.pass.cpp b/test/std/re/re.def/defns.regex.collating.element/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..9a59227abdd9
--- /dev/null
+++ b/test/std/re/re.def/defns.regex.collating.element/nothing_to_do.pass.cpp
@@ -0,0 +1,13 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/re/re.def/defns.regex.finite.state.machine/nothing_to_do.pass.cpp b/test/std/re/re.def/defns.regex.finite.state.machine/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..9a59227abdd9
--- /dev/null
+++ b/test/std/re/re.def/defns.regex.finite.state.machine/nothing_to_do.pass.cpp
@@ -0,0 +1,13 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/re/re.def/defns.regex.format.specifier/nothing_to_do.pass.cpp b/test/std/re/re.def/defns.regex.format.specifier/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..9a59227abdd9
--- /dev/null
+++ b/test/std/re/re.def/defns.regex.format.specifier/nothing_to_do.pass.cpp
@@ -0,0 +1,13 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/re/re.def/defns.regex.matched/nothing_to_do.pass.cpp b/test/std/re/re.def/defns.regex.matched/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..9a59227abdd9
--- /dev/null
+++ b/test/std/re/re.def/defns.regex.matched/nothing_to_do.pass.cpp
@@ -0,0 +1,13 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/re/re.def/defns.regex.primary.equivalence.class/nothing_to_do.pass.cpp b/test/std/re/re.def/defns.regex.primary.equivalence.class/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..9a59227abdd9
--- /dev/null
+++ b/test/std/re/re.def/defns.regex.primary.equivalence.class/nothing_to_do.pass.cpp
@@ -0,0 +1,13 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/re/re.def/defns.regex.regular.expression/nothing_to_do.pass.cpp b/test/std/re/re.def/defns.regex.regular.expression/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..9a59227abdd9
--- /dev/null
+++ b/test/std/re/re.def/defns.regex.regular.expression/nothing_to_do.pass.cpp
@@ -0,0 +1,13 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/re/re.def/defns.regex.subexpression/nothing_to_do.pass.cpp b/test/std/re/re.def/defns.regex.subexpression/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..9a59227abdd9
--- /dev/null
+++ b/test/std/re/re.def/defns.regex.subexpression/nothing_to_do.pass.cpp
@@ -0,0 +1,13 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/re/re.def/nothing_to_do.pass.cpp b/test/std/re/re.def/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..9a59227abdd9
--- /dev/null
+++ b/test/std/re/re.def/nothing_to_do.pass.cpp
@@ -0,0 +1,13 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/re/re.general/nothing_to_do.pass.cpp b/test/std/re/re.general/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..9a59227abdd9
--- /dev/null
+++ b/test/std/re/re.general/nothing_to_do.pass.cpp
@@ -0,0 +1,13 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/re/re.grammar/nothing_to_do.pass.cpp b/test/std/re/re.grammar/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/re/re.grammar/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/re/re.iter/nothing_to_do.pass.cpp b/test/std/re/re.iter/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/re/re.iter/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/re/re.iter/re.regiter/re.regiter.cnstr/cnstr.fail.cpp b/test/std/re/re.iter/re.regiter/re.regiter.cnstr/cnstr.fail.cpp
new file mode 100644
index 000000000000..208de0e43cec
--- /dev/null
+++ b/test/std/re/re.iter/re.regiter/re.regiter.cnstr/cnstr.fail.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class regex_iterator<BidirectionalIterator, charT, traits>
+
+// regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
+// const regex_type&& re,
+// int submatch = 0,
+// regex_constants::match_flag_type m =
+// regex_constants::match_default) = delete;
+
+#if __cplusplus <= 201402L
+#error
+#else
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ std::cregex_iterator i(
+ std::begin(phone_book), std::end(phone_book),
+ std::regex("\\d{3}-\\d{4}"));
+ }
+}
+#endif
diff --git a/test/std/re/re.iter/re.regiter/re.regiter.cnstr/cnstr.pass.cpp b/test/std/re/re.iter/re.regiter/re.regiter.cnstr/cnstr.pass.cpp
new file mode 100644
index 000000000000..c9fc7a3cd1cc
--- /dev/null
+++ b/test/std/re/re.iter/re.regiter/re.regiter.cnstr/cnstr.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class regex_iterator<BidirectionalIterator, charT, traits>
+
+// regex_iterator(BidirectionalIterator a, BidirectionalIterator b,
+// const regex_type& re,
+// regex_constants::match_flag_type m = regex_constants::match_default);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ std::cregex_iterator i(std::begin(phone_book), std::end(phone_book), phone_numbers);
+ assert(i != std::cregex_iterator());
+ assert(i->size() == 1);
+ assert(i->position() == 0);
+ assert(i->str() == "555-1234");
+ ++i;
+ assert(i != std::cregex_iterator());
+ assert(i->size() == 1);
+ assert(i->position() == 10);
+ assert(i->str() == "555-2345");
+ ++i;
+ assert(i != std::cregex_iterator());
+ assert(i->size() == 1);
+ assert(i->position() == 20);
+ assert(i->str() == "555-3456");
+ ++i;
+ assert(i == std::cregex_iterator());
+ }
+}
diff --git a/test/std/re/re.iter/re.regiter/re.regiter.cnstr/default.pass.cpp b/test/std/re/re.iter/re.regiter/re.regiter.cnstr/default.pass.cpp
new file mode 100644
index 000000000000..9d4766dc876f
--- /dev/null
+++ b/test/std/re/re.iter/re.regiter/re.regiter.cnstr/default.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class regex_iterator<BidirectionalIterator, charT, traits>
+
+// regex_iterator();
+
+#include <regex>
+#include <cassert>
+
+template <class CharT>
+void
+test()
+{
+ typedef std::regex_iterator<const CharT*> I;
+ I i1;
+ assert(i1 == I());
+}
+
+int main()
+{
+ test<char>();
+ test<wchar_t>();
+}
diff --git a/test/std/re/re.iter/re.regiter/re.regiter.comp/tested_elsewhere.pass.cpp b/test/std/re/re.iter/re.regiter/re.regiter.comp/tested_elsewhere.pass.cpp
new file mode 100644
index 000000000000..16d1fa9904be
--- /dev/null
+++ b/test/std/re/re.iter/re.regiter/re.regiter.comp/tested_elsewhere.pass.cpp
@@ -0,0 +1,19 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class regex_iterator<BidirectionalIterator, charT, traits>
+
+// bool operator==(const regex_iterator& right) const;
+// bool operator!=(const regex_iterator& right) const;
+
+int main()
+{
+}
diff --git a/test/std/re/re.iter/re.regiter/re.regiter.deref/deref.pass.cpp b/test/std/re/re.iter/re.regiter/re.regiter.deref/deref.pass.cpp
new file mode 100644
index 000000000000..e4933fe16f8e
--- /dev/null
+++ b/test/std/re/re.iter/re.regiter/re.regiter.deref/deref.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class regex_iterator<BidirectionalIterator, charT, traits>
+
+// const value_type& operator*() const;
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ std::cregex_iterator i(std::begin(phone_book), std::end(phone_book), phone_numbers);
+ assert(i != std::cregex_iterator());
+ assert((*i).size() == 1);
+ assert((*i).position() == 0);
+ assert((*i).str() == "555-1234");
+ ++i;
+ assert(i != std::cregex_iterator());
+ assert((*i).size() == 1);
+ assert((*i).position() == 10);
+ assert((*i).str() == "555-2345");
+ ++i;
+ assert(i != std::cregex_iterator());
+ assert((*i).size() == 1);
+ assert((*i).position() == 20);
+ assert((*i).str() == "555-3456");
+ ++i;
+ assert(i == std::cregex_iterator());
+ }
+}
diff --git a/test/std/re/re.iter/re.regiter/re.regiter.incr/post.pass.cpp b/test/std/re/re.iter/re.regiter/re.regiter.incr/post.pass.cpp
new file mode 100644
index 000000000000..3ec0d6c0c3b4
--- /dev/null
+++ b/test/std/re/re.iter/re.regiter/re.regiter.incr/post.pass.cpp
@@ -0,0 +1,97 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class regex_iterator<BidirectionalIterator, charT, traits>
+
+// regex_iterator operator++(int);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ std::cregex_iterator i(std::begin(phone_book), std::end(phone_book), phone_numbers);
+ std::cregex_iterator i2 = i;
+ assert(i != std::cregex_iterator());
+ assert(i2!= std::cregex_iterator());
+ assert((*i).size() == 1);
+ assert((*i).position() == 0);
+ assert((*i).str() == "555-1234");
+ assert((*i2).size() == 1);
+ assert((*i2).position() == 0);
+ assert((*i2).str() == "555-1234");
+ i++;
+ assert(i != std::cregex_iterator());
+ assert(i2!= std::cregex_iterator());
+ assert((*i).size() == 1);
+ assert((*i).position() == 10);
+ assert((*i).str() == "555-2345");
+ assert((*i2).size() == 1);
+ assert((*i2).position() == 0);
+ assert((*i2).str() == "555-1234");
+ i++;
+ assert(i != std::cregex_iterator());
+ assert(i2!= std::cregex_iterator());
+ assert((*i).size() == 1);
+ assert((*i).position() == 20);
+ assert((*i).str() == "555-3456");
+ assert((*i2).size() == 1);
+ assert((*i2).position() == 0);
+ assert((*i2).str() == "555-1234");
+ i++;
+ assert(i == std::cregex_iterator());
+ assert(i2!= std::cregex_iterator());
+ assert((*i2).size() == 1);
+ assert((*i2).position() == 0);
+ assert((*i2).str() == "555-1234");
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "555-1234, 555-2345, 555-3456";
+ std::cregex_iterator i(std::begin(phone_book), std::end(phone_book), phone_numbers);
+ std::cregex_iterator i2 = i;
+ assert(i != std::cregex_iterator());
+ assert(i2!= std::cregex_iterator());
+ assert((*i).size() == 1);
+ assert((*i).position() == 0);
+ assert((*i).str() == "555-1234");
+ assert((*i2).size() == 1);
+ assert((*i2).position() == 0);
+ assert((*i2).str() == "555-1234");
+ ++i;
+ assert(i != std::cregex_iterator());
+ assert(i2!= std::cregex_iterator());
+ assert((*i).size() == 1);
+ assert((*i).position() == 10);
+ assert((*i).str() == "555-2345");
+ assert((*i2).size() == 1);
+ assert((*i2).position() == 0);
+ assert((*i2).str() == "555-1234");
+ ++i;
+ assert(i != std::cregex_iterator());
+ assert(i2!= std::cregex_iterator());
+ assert((*i).size() == 1);
+ assert((*i).position() == 20);
+ assert((*i).str() == "555-3456");
+ assert((*i2).size() == 1);
+ assert((*i2).position() == 0);
+ assert((*i2).str() == "555-1234");
+ ++i;
+ assert(i == std::cregex_iterator());
+ assert(i2!= std::cregex_iterator());
+ assert((*i2).size() == 1);
+ assert((*i2).position() == 0);
+ assert((*i2).str() == "555-1234");
+ }
+}
diff --git a/test/std/re/re.iter/re.regiter/types.pass.cpp b/test/std/re/re.iter/re.regiter/types.pass.cpp
new file mode 100644
index 000000000000..db1d3eb958bf
--- /dev/null
+++ b/test/std/re/re.iter/re.regiter/types.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class BidirectionalIterator,
+// class charT = typename iterator_traits< BidirectionalIterator>::value_type,
+// class traits = regex_traits<charT>>
+// class regex_iterator
+// {
+// public:
+// typedef basic_regex<charT, traits> regex_type;
+// typedef match_results<BidirectionalIterator> value_type;
+// typedef ptrdiff_t difference_type;
+// typedef const value_type* pointer;
+// typedef const value_type& reference;
+// typedef forward_iterator_tag iterator_category;
+
+#include <regex>
+#include <type_traits>
+
+template <class CharT>
+void
+test()
+{
+ typedef std::regex_iterator<const CharT*> I;
+ static_assert((std::is_same<typename I::regex_type, std::basic_regex<CharT> >::value), "");
+ static_assert((std::is_same<typename I::value_type, std::match_results<const CharT*> >::value), "");
+ static_assert((std::is_same<typename I::difference_type, std::ptrdiff_t>::value), "");
+ static_assert((std::is_same<typename I::pointer, const std::match_results<const CharT*>*>::value), "");
+ static_assert((std::is_same<typename I::reference, const std::match_results<const CharT*>&>::value), "");
+ static_assert((std::is_same<typename I::iterator_category, std::forward_iterator_tag>::value), "");
+}
+
+int main()
+{
+ test<char>();
+ test<wchar_t>();
+}
diff --git a/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/array.fail.cpp b/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/array.fail.cpp
new file mode 100644
index 000000000000..6753b0ad506b
--- /dev/null
+++ b/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/array.fail.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class regex_iterator<BidirectionalIterator, charT, traits>
+
+// template <size_t N>
+// regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
+// const regex_type&& re,
+// const int (&submatches)[N],
+// regex_constants::match_flag_type m =
+// regex_constants::match_default);
+
+#if __cplusplus <= 201402L
+#error
+#else
+
+#include <regex>
+#include <vector>
+#include <cassert>
+
+int main()
+{
+ {
+ std::regex phone_numbers("\\d{3}-(\\d{4})");
+ const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
+ const int indices[] = {-1, 0, 1};
+ std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
+ std::regex("\\d{3}-\\d{4}"), indices);
+ }
+}
+#endif
diff --git a/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/array.pass.cpp b/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/array.pass.cpp
new file mode 100644
index 000000000000..a51b8274bdd8
--- /dev/null
+++ b/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/array.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class regex_token_iterator<BidirectionalIterator, charT, traits>
+
+// template <size_t N>
+// regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
+// const regex_type& re,
+// const int (&submatches)[N],
+// regex_constants::match_flag_type m =
+// regex_constants::match_default);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ std::regex phone_numbers("\\d{3}-(\\d{4})");
+ const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
+ const int indices[] = {-1, 0, 1};
+ std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
+ phone_numbers, indices);
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "start ");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "555-1234");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "1234");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == ", ");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "555-2345");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "2345");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == ", ");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "555-3456");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "3456");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == " end");
+ ++i;
+ assert(i == std::cregex_token_iterator());
+ }
+}
diff --git a/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/default.pass.cpp b/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/default.pass.cpp
new file mode 100644
index 000000000000..382815e0c1cc
--- /dev/null
+++ b/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/default.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class regex_token_iterator<BidirectionalIterator, charT, traits>
+
+// regex_token_iterator();
+
+#include <regex>
+#include <cassert>
+
+template <class CharT>
+void
+test()
+{
+ typedef std::regex_token_iterator<const CharT*> I;
+ I i1;
+ assert(i1 == I());
+}
+
+int main()
+{
+ test<char>();
+ test<wchar_t>();
+}
diff --git a/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/init.fail.cpp b/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/init.fail.cpp
new file mode 100644
index 000000000000..e58183682ea4
--- /dev/null
+++ b/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/init.fail.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class regex_iterator<BidirectionalIterator, charT, traits>
+
+// regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
+// const regex_type&& re,
+// initializer_list<int> submatches,
+// regex_constants::match_flag_type m =
+// regex_constants::match_default);
+
+#if __cplusplus <= 201402L
+#error
+#else
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ std::regex phone_numbers("\\d{3}-(\\d{4})");
+ const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
+ std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
+ std::regex("\\d{3}-\\d{4}"), {-1, 0, 1});
+ }
+}
+#endif
diff --git a/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/init.pass.cpp b/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/init.pass.cpp
new file mode 100644
index 000000000000..b40d7eb9224d
--- /dev/null
+++ b/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/init.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class regex_token_iterator<BidirectionalIterator, charT, traits>
+
+// regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
+// const regex_type& re,
+// initializer_list<int> submatches,
+// regex_constants::match_flag_type m =
+// regex_constants::match_default);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ std::regex phone_numbers("\\d{3}-(\\d{4})");
+ const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
+ std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
+ phone_numbers, {-1, 0, 1});
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "start ");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "555-1234");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "1234");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == ", ");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "555-2345");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "2345");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == ", ");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "555-3456");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "3456");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == " end");
+ ++i;
+ assert(i == std::cregex_token_iterator());
+ }
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/int.fail.cpp b/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/int.fail.cpp
new file mode 100644
index 000000000000..d0a100a1afcc
--- /dev/null
+++ b/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/int.fail.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class regex_iterator<BidirectionalIterator, charT, traits>
+
+// regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
+// const regex_type&& re, int submatch = 0,
+// regex_constants::match_flag_type m =
+// regex_constants::match_default);
+
+#if __cplusplus <= 201402L
+#error
+#else
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
+ std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
+ std::regex("\\d{3}-\\d{4}"), -1);
+ }
+}
+#endif
diff --git a/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/int.pass.cpp b/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/int.pass.cpp
new file mode 100644
index 000000000000..d8111363c176
--- /dev/null
+++ b/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/int.pass.cpp
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class regex_token_iterator<BidirectionalIterator, charT, traits>
+
+// regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
+// const regex_type& re, int submatch = 0,
+// regex_constants::match_flag_type m =
+// regex_constants::match_default);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
+ std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
+ phone_numbers, -1);
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "start ");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == ", ");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == ", ");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == " end");
+ ++i;
+ assert(i == std::cregex_token_iterator());
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
+ std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
+ phone_numbers);
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "555-1234");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "555-2345");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "555-3456");
+ ++i;
+ assert(i == std::cregex_token_iterator());
+ }
+ {
+ std::regex phone_numbers("\\d{3}-(\\d{4})");
+ const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
+ std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
+ phone_numbers, 1);
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "1234");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "2345");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "3456");
+ ++i;
+ assert(i == std::cregex_token_iterator());
+ }
+}
diff --git a/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/vector.fail.cpp b/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/vector.fail.cpp
new file mode 100644
index 000000000000..94d8f9667d2c
--- /dev/null
+++ b/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/vector.fail.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class regex_iterator<BidirectionalIterator, charT, traits>
+
+// template <std::size_t N>
+// regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
+// const regex_type&& re,
+// const std::vector<int>& submatches,
+// regex_constants::match_flag_type m =
+// regex_constants::match_default);
+
+#if __cplusplus <= 201402L
+#error
+#else
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ std::regex phone_numbers("\\d{3}-(\\d{4})");
+ const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
+ std::vector<int> v;
+ v.push_back(-1);
+ v.push_back(-1);
+ std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
+ std::regex("\\d{3}-\\d{4}"), v);
+ }
+}
+#endif
diff --git a/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/vector.pass.cpp b/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/vector.pass.cpp
new file mode 100644
index 000000000000..b04f5804509f
--- /dev/null
+++ b/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/vector.pass.cpp
@@ -0,0 +1,128 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class regex_token_iterator<BidirectionalIterator, charT, traits>
+
+// regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
+// const regex_type& re,
+// const std::vector<int>& submatches,
+// regex_constants::match_flag_type m =
+// regex_constants::match_default);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ std::regex phone_numbers("\\d{3}-(\\d{4})");
+ const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
+ std::vector<int> v;
+ v.push_back(-1);
+ v.push_back(-1);
+ std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
+ phone_numbers, v);
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "start ");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "start ");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == ", ");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == ", ");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == ", ");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == ", ");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == " end");
+ ++i;
+ assert(i == std::cregex_token_iterator());
+ }
+ {
+ std::regex phone_numbers("\\d{3}-(\\d{4})");
+ const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
+ std::vector<int> v;
+ v.push_back(-1);
+ v.push_back(0);
+ std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
+ phone_numbers, v);
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "start ");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "555-1234");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == ", ");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "555-2345");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == ", ");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "555-3456");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == " end");
+ ++i;
+ assert(i == std::cregex_token_iterator());
+ }
+ {
+ std::regex phone_numbers("\\d{3}-(\\d{4})");
+ const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
+ std::vector<int> v;
+ v.push_back(-1);
+ v.push_back(0);
+ v.push_back(1);
+ std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
+ phone_numbers, v);
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "start ");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "555-1234");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "1234");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == ", ");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "555-2345");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "2345");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == ", ");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "555-3456");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "3456");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == " end");
+ ++i;
+ assert(i == std::cregex_token_iterator());
+ }
+}
diff --git a/test/std/re/re.iter/re.tokiter/re.tokiter.comp/equal.pass.cpp b/test/std/re/re.iter/re.tokiter/re.tokiter.comp/equal.pass.cpp
new file mode 100644
index 000000000000..d6399f1148b4
--- /dev/null
+++ b/test/std/re/re.iter/re.tokiter/re.tokiter.comp/equal.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class regex_token_iterator<BidirectionalIterator, charT, traits>
+
+// bool operator==(const regex_token_iterator& right) const;
+// bool operator!=(const regex_token_iterator& right) const;
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
+ std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
+ phone_numbers, -1);
+ assert(i != std::cregex_token_iterator());
+ assert(!(i == std::cregex_token_iterator()));
+ std::cregex_token_iterator i2 = i;
+ assert(i2 == i);
+ assert(!(i2 != i));
+ ++i;
+ assert(!(i2 == i));
+ assert(i2 != i);
+ }
+}
diff --git a/test/std/re/re.iter/re.tokiter/re.tokiter.deref/deref.pass.cpp b/test/std/re/re.iter/re.tokiter/re.tokiter.deref/deref.pass.cpp
new file mode 100644
index 000000000000..b096e3c08275
--- /dev/null
+++ b/test/std/re/re.iter/re.tokiter/re.tokiter.deref/deref.pass.cpp
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class regex_token_iterator<BidirectionalIterator, charT, traits>
+
+// const value_type& operator*() const;
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
+ std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
+ phone_numbers, -1);
+ assert(i != std::cregex_token_iterator());
+ assert((*i).str() == "start ");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert((*i).str() == ", ");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert((*i).str() == ", ");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert((*i).str() == " end");
+ ++i;
+ assert(i == std::cregex_token_iterator());
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
+ std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
+ phone_numbers);
+ assert(i != std::cregex_token_iterator());
+ assert((*i).str() == "555-1234");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert((*i).str() == "555-2345");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert((*i).str() == "555-3456");
+ ++i;
+ assert(i == std::cregex_token_iterator());
+ }
+ {
+ std::regex phone_numbers("\\d{3}-(\\d{4})");
+ const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
+ std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
+ phone_numbers, 1);
+ assert(i != std::cregex_token_iterator());
+ assert((*i).str() == "1234");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert((*i).str() == "2345");
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert((*i).str() == "3456");
+ ++i;
+ assert(i == std::cregex_token_iterator());
+ }
+}
diff --git a/test/std/re/re.iter/re.tokiter/re.tokiter.incr/post.pass.cpp b/test/std/re/re.iter/re.tokiter/re.tokiter.incr/post.pass.cpp
new file mode 100644
index 000000000000..727ab7af9376
--- /dev/null
+++ b/test/std/re/re.iter/re.tokiter/re.tokiter.incr/post.pass.cpp
@@ -0,0 +1,135 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class regex_token_iterator<BidirectionalIterator, charT, traits>
+
+// regex_token_iterator& operator++(int);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
+ std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
+ phone_numbers, -1);
+ std::cregex_token_iterator i2 = i;
+ std::cregex_token_iterator i3;
+ assert(i != std::cregex_token_iterator());
+ assert(i2 != std::cregex_token_iterator());
+ assert(i->str() == "start ");
+ assert(i2->str() == "start ");
+ i3 = i++;
+ assert(i != std::cregex_token_iterator());
+ assert(i2 != std::cregex_token_iterator());
+ assert(i3 != std::cregex_token_iterator());
+ assert(i->str() == ", ");
+ assert(i2->str() == "start ");
+ assert(i3->str() == "start ");
+ i3 = i++;
+ assert(i != std::cregex_token_iterator());
+ assert(i2 != std::cregex_token_iterator());
+ assert(i3 != std::cregex_token_iterator());
+ assert(i->str() == ", ");
+ assert(i2->str() == "start ");
+ assert(i3->str() == ", ");
+ i3 = i++;
+ assert(i != std::cregex_token_iterator());
+ assert(i2 != std::cregex_token_iterator());
+ assert(i3 != std::cregex_token_iterator());
+ assert(i->str() == " end");
+ assert(i2->str() == "start ");
+ assert(i3->str() == ", ");
+ i3 = i++;
+ assert(i == std::cregex_token_iterator());
+ assert(i2 != std::cregex_token_iterator());
+ assert(i3 != std::cregex_token_iterator());
+ assert(i2->str() == "start ");
+ assert(i3->str() == " end");
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
+ std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
+ phone_numbers, -1);
+ std::cregex_token_iterator i2 = i;
+ std::cregex_token_iterator i3;
+ assert(i != std::cregex_token_iterator());
+ assert(i2 != std::cregex_token_iterator());
+ assert(i->str() == "start ");
+ assert(i2->str() == "start ");
+ i3 = i;
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i2 != std::cregex_token_iterator());
+ assert(i3 != std::cregex_token_iterator());
+ assert(i->str() == ", ");
+ assert(i2->str() == "start ");
+ assert(i3->str() == "start ");
+ i3 = i;
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i2 != std::cregex_token_iterator());
+ assert(i3 != std::cregex_token_iterator());
+ assert(i->str() == ", ");
+ assert(i2->str() == "start ");
+ assert(i3->str() == ", ");
+ i3 = i;
+ ++i;
+ assert(i != std::cregex_token_iterator());
+ assert(i2 != std::cregex_token_iterator());
+ assert(i3 != std::cregex_token_iterator());
+ assert(i->str() == " end");
+ assert(i2->str() == "start ");
+ assert(i3->str() == ", ");
+ i3 = i;
+ ++i;
+ assert(i == std::cregex_token_iterator());
+ assert(i2 != std::cregex_token_iterator());
+ assert(i3 != std::cregex_token_iterator());
+ assert(i2->str() == "start ");
+ assert(i3->str() == " end");
+ }
+ {
+ std::regex phone_numbers("\\d{3}-\\d{4}");
+ const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
+ std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
+ phone_numbers);
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "555-1234");
+ i++;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "555-2345");
+ i++;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "555-3456");
+ i++;
+ assert(i == std::cregex_token_iterator());
+ }
+ {
+ std::regex phone_numbers("\\d{3}-(\\d{4})");
+ const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
+ std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
+ phone_numbers, 1);
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "1234");
+ i++;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "2345");
+ i++;
+ assert(i != std::cregex_token_iterator());
+ assert(i->str() == "3456");
+ i++;
+ assert(i == std::cregex_token_iterator());
+ }
+}
diff --git a/test/std/re/re.iter/re.tokiter/types.pass.cpp b/test/std/re/re.iter/re.tokiter/types.pass.cpp
new file mode 100644
index 000000000000..89287bdd1d00
--- /dev/null
+++ b/test/std/re/re.iter/re.tokiter/types.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class BidirectionalIterator,
+// class charT = typename iterator_traits< BidirectionalIterator>::value_type,
+// class traits = regex_traits<charT>>
+// class regex_token_iterator
+// {
+// public:
+// typedef basic_regex<charT, traits> regex_type;
+// typedef sub_match<BidirectionalIterator> value_type;
+// typedef ptrdiff_t difference_type;
+// typedef const value_type* pointer;
+// typedef const value_type& reference;
+// typedef forward_iterator_tag iterator_category;
+
+#include <regex>
+#include <type_traits>
+
+template <class CharT>
+void
+test()
+{
+ typedef std::regex_token_iterator<const CharT*> I;
+ static_assert((std::is_same<typename I::regex_type, std::basic_regex<CharT> >::value), "");
+ static_assert((std::is_same<typename I::value_type, std::sub_match<const CharT*> >::value), "");
+ static_assert((std::is_same<typename I::difference_type, std::ptrdiff_t>::value), "");
+ static_assert((std::is_same<typename I::pointer, const std::sub_match<const CharT*>*>::value), "");
+ static_assert((std::is_same<typename I::reference, const std::sub_match<const CharT*>&>::value), "");
+ static_assert((std::is_same<typename I::iterator_category, std::forward_iterator_tag>::value), "");
+}
+
+int main()
+{
+ test<char>();
+ test<wchar_t>();
+}
diff --git a/test/std/re/re.regex/re.regex.assign/assign.il.pass.cpp b/test/std/re/re.regex/re.regex.assign/assign.il.pass.cpp
new file mode 100644
index 000000000000..96cadf166001
--- /dev/null
+++ b/test/std/re/re.regex/re.regex.assign/assign.il.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT, class traits = regex_traits<charT>> class basic_regex;
+
+// basic_regex&
+// assign(initializer_list<charT> il,
+// flag_type f = regex_constants::ECMAScript);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ std::regex r2;
+ r2.assign({'(', 'a', '(', '[', 'b', 'c', ']', ')', ')'});
+ assert(r2.flags() == std::regex::ECMAScript);
+ assert(r2.mark_count() == 2);
+
+ r2.assign({'(', 'a', '(', '[', 'b', 'c', ']', ')', ')'}, std::regex::extended);
+ assert(r2.flags() == std::regex::extended);
+ assert(r2.mark_count() == 2);
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/re/re.regex/re.regex.assign/assign.pass.cpp b/test/std/re/re.regex/re.regex.assign/assign.pass.cpp
new file mode 100644
index 000000000000..8bf98268c493
--- /dev/null
+++ b/test/std/re/re.regex/re.regex.assign/assign.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT, class traits = regex_traits<charT>> class basic_regex;
+
+// basic_regex& assign(const basic_regex& that);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ std::regex r1("(a([bc]))");
+ std::regex r2;
+ r2.assign(r1);
+ assert(r2.flags() == std::regex::ECMAScript);
+ assert(r2.mark_count() == 2);
+ assert(std::regex_search("ab", r2));
+
+ bool caught = false;
+ try { r2.assign("(def", std::regex::extended); }
+ catch(std::regex_error &) { caught = true; }
+ assert(caught);
+ assert(r2.flags() == std::regex::ECMAScript);
+ assert(r2.mark_count() == 2);
+ assert(std::regex_search("ab", r2));
+}
diff --git a/test/std/re/re.regex/re.regex.assign/assign_iter_iter_flag.pass.cpp b/test/std/re/re.regex/re.regex.assign/assign_iter_iter_flag.pass.cpp
new file mode 100644
index 000000000000..529a64a239a0
--- /dev/null
+++ b/test/std/re/re.regex/re.regex.assign/assign_iter_iter_flag.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT, class traits = regex_traits<charT>> class basic_regex;
+
+// template <class InputIterator>
+// basic_regex&
+// assign(InputIterator first, InputIterator last,
+// flag_type f = regex_constants::ECMAScript);
+
+#include <regex>
+#include <cassert>
+
+#include "test_iterators.h"
+
+int main()
+{
+ typedef input_iterator<std::string::const_iterator> I;
+ typedef forward_iterator<std::string::const_iterator> F;
+ std::string s4("(a([bc]))");
+ std::regex r2;
+
+ r2.assign(I(s4.begin()), I(s4.end()));
+ assert(r2.flags() == std::regex::ECMAScript);
+ assert(r2.mark_count() == 2);
+
+ r2.assign(I(s4.begin()), I(s4.end()), std::regex::extended);
+ assert(r2.flags() == std::regex::extended);
+ assert(r2.mark_count() == 2);
+
+ r2.assign(F(s4.begin()), F(s4.end()));
+ assert(r2.flags() == std::regex::ECMAScript);
+ assert(r2.mark_count() == 2);
+
+ r2.assign(F(s4.begin()), F(s4.end()), std::regex::extended);
+ assert(r2.flags() == std::regex::extended);
+ assert(r2.mark_count() == 2);
+}
diff --git a/test/std/re/re.regex/re.regex.assign/assign_ptr_flag.pass.cpp b/test/std/re/re.regex/re.regex.assign/assign_ptr_flag.pass.cpp
new file mode 100644
index 000000000000..dd39dee13ffb
--- /dev/null
+++ b/test/std/re/re.regex/re.regex.assign/assign_ptr_flag.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT, class traits = regex_traits<charT>> class basic_regex;
+
+// basic_regex& assign(const charT* ptr, flag_type f = regex_constants::ECMAScript);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ std::regex r2;
+ r2.assign("(a([bc]))");
+ assert(r2.flags() == std::regex::ECMAScript);
+ assert(r2.mark_count() == 2);
+
+ r2.assign("(a([bc]))", std::regex::extended);
+ assert(r2.flags() == std::regex::extended);
+ assert(r2.mark_count() == 2);
+}
diff --git a/test/std/re/re.regex/re.regex.assign/assign_ptr_size_flag.pass.cpp b/test/std/re/re.regex/re.regex.assign/assign_ptr_size_flag.pass.cpp
new file mode 100644
index 000000000000..679cd9df17fc
--- /dev/null
+++ b/test/std/re/re.regex/re.regex.assign/assign_ptr_size_flag.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT, class traits = regex_traits<charT>> class basic_regex;
+
+// basic_regex& assign(const charT* ptr, size_t len, flag_type f);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ std::regex r2;
+ r2.assign("(a([bc]))", 9, std::regex::extended);
+ assert(r2.flags() == std::regex::extended);
+ assert(r2.mark_count() == 2);
+}
diff --git a/test/std/re/re.regex/re.regex.assign/assign_string_flag.pass.cpp b/test/std/re/re.regex/re.regex.assign/assign_string_flag.pass.cpp
new file mode 100644
index 000000000000..46f984da04db
--- /dev/null
+++ b/test/std/re/re.regex/re.regex.assign/assign_string_flag.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT, class traits = regex_traits<charT>> class basic_regex;
+
+// template <class string_traits, class A>
+// basic_regex& assign(const basic_string<charT, string_traits, A>& s,
+// flag_type f = regex_constants::ECMAScript);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ std::regex r2;
+ r2.assign(std::string("(a([bc]))"));
+ assert(r2.flags() == std::regex::ECMAScript);
+ assert(r2.mark_count() == 2);
+
+ r2.assign(std::string("(a([bc]))"), std::regex::extended);
+ assert(r2.flags() == std::regex::extended);
+ assert(r2.mark_count() == 2);
+}
diff --git a/test/std/re/re.regex/re.regex.assign/copy.pass.cpp b/test/std/re/re.regex/re.regex.assign/copy.pass.cpp
new file mode 100644
index 000000000000..2a616ff012c1
--- /dev/null
+++ b/test/std/re/re.regex/re.regex.assign/copy.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT, class traits = regex_traits<charT>> class basic_regex;
+
+// basic_regex& operator=(const basic_regex& e);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ std::regex r1("(a([bc]))");
+ std::regex r2;
+ r2 = r1;
+ assert(r2.flags() == std::regex::ECMAScript);
+ assert(r2.mark_count() == 2);
+}
diff --git a/test/std/re/re.regex/re.regex.assign/il.pass.cpp b/test/std/re/re.regex/re.regex.assign/il.pass.cpp
new file mode 100644
index 000000000000..a9d8ada4ff0e
--- /dev/null
+++ b/test/std/re/re.regex/re.regex.assign/il.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT, class traits = regex_traits<charT>> class basic_regex;
+
+// basic_regex& operator=(initializer_list<charT> il);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ std::regex r2;
+ r2 = {'(', 'a', '(', '[', 'b', 'c', ']', ')', ')'};
+ assert(r2.flags() == std::regex::ECMAScript);
+ assert(r2.mark_count() == 2);
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/re/re.regex/re.regex.assign/ptr.pass.cpp b/test/std/re/re.regex/re.regex.assign/ptr.pass.cpp
new file mode 100644
index 000000000000..4c42f822a1e5
--- /dev/null
+++ b/test/std/re/re.regex/re.regex.assign/ptr.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT, class traits = regex_traits<charT>> class basic_regex;
+
+// basic_regex& operator=(const charT* ptr);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ std::regex r2;
+ r2 = "(a([bc]))";
+ assert(r2.flags() == std::regex::ECMAScript);
+ assert(r2.mark_count() == 2);
+}
diff --git a/test/std/re/re.regex/re.regex.assign/string.pass.cpp b/test/std/re/re.regex/re.regex.assign/string.pass.cpp
new file mode 100644
index 000000000000..7f09e5364ac4
--- /dev/null
+++ b/test/std/re/re.regex/re.regex.assign/string.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT, class traits = regex_traits<charT>> class basic_regex;
+
+// template <class ST, class SA>
+// basic_regex& operator=(const basic_string<charT, ST, SA>& p);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ std::regex r2;
+ r2 = std::string("(a([bc]))");
+ assert(r2.flags() == std::regex::ECMAScript);
+ assert(r2.mark_count() == 2);
+}
diff --git a/test/std/re/re.regex/re.regex.const/constants.pass.cpp b/test/std/re/re.regex/re.regex.const/constants.pass.cpp
new file mode 100644
index 000000000000..85297b91f433
--- /dev/null
+++ b/test/std/re/re.regex/re.regex.const/constants.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT, class traits = regex_traits<charT>>
+// class basic_regex
+// {
+// public:
+// // constants:
+// static constexpr regex_constants::syntax_option_type icase = regex_constants::icase;
+// static constexpr regex_constants::syntax_option_type nosubs = regex_constants::nosubs;
+// static constexpr regex_constants::syntax_option_type optimize = regex_constants::optimize;
+// static constexpr regex_constants::syntax_option_type collate = regex_constants::collate;
+// static constexpr regex_constants::syntax_option_type ECMAScript = regex_constants::ECMAScript;
+// static constexpr regex_constants::syntax_option_type basic = regex_constants::basic;
+// static constexpr regex_constants::syntax_option_type extended = regex_constants::extended;
+// static constexpr regex_constants::syntax_option_type awk = regex_constants::awk;
+// static constexpr regex_constants::syntax_option_type grep = regex_constants::grep;
+// static constexpr regex_constants::syntax_option_type egrep = regex_constants::egrep;
+
+#include <regex>
+#include <type_traits>
+
+template <class _Tp>
+void where(const _Tp &) {}
+
+template <class CharT>
+void
+test()
+{
+ typedef std::basic_regex<CharT> BR;
+ static_assert((BR::icase == std::regex_constants::icase), "");
+ static_assert((BR::nosubs == std::regex_constants::nosubs), "");
+ static_assert((BR::optimize == std::regex_constants::optimize), "");
+ static_assert((BR::collate == std::regex_constants::collate), "");
+ static_assert((BR::ECMAScript == std::regex_constants::ECMAScript), "");
+ static_assert((BR::basic == std::regex_constants::basic), "");
+ static_assert((BR::extended == std::regex_constants::extended), "");
+ static_assert((BR::awk == std::regex_constants::awk), "");
+ static_assert((BR::grep == std::regex_constants::grep), "");
+ static_assert((BR::egrep == std::regex_constants::egrep), "");
+ where(BR::icase);
+ where(BR::nosubs);
+ where(BR::optimize);
+ where(BR::collate);
+ where(BR::ECMAScript);
+ where(BR::basic);
+ where(BR::extended);
+ where(BR::awk);
+ where(BR::grep);
+ where(BR::egrep);
+}
+
+int main()
+{
+ test<char>();
+ test<wchar_t>();
+}
diff --git a/test/std/re/re.regex/re.regex.construct/awk_oct.pass.cpp b/test/std/re/re.regex/re.regex.construct/awk_oct.pass.cpp
new file mode 100644
index 000000000000..4b7e5e629294
--- /dev/null
+++ b/test/std/re/re.regex/re.regex.construct/awk_oct.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT, class traits = regex_traits<charT>> class basic_regex;
+
+// template <class ST, class SA>
+// basic_regex(const basic_string<charT, ST, SA>& s);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ using std::regex_constants::awk;
+
+ assert(std::regex_match("\4", std::regex("\\4", awk)));
+ assert(std::regex_match("\41", std::regex("\\41", awk)));
+ assert(std::regex_match("\141", std::regex("\\141", awk)));
+ assert(std::regex_match("\1411", std::regex("\\1411", awk)));
+}
diff --git a/test/std/re/re.regex/re.regex.construct/bad_escape.pass.cpp b/test/std/re/re.regex/re.regex.construct/bad_escape.pass.cpp
new file mode 100644
index 000000000000..9455527412bb
--- /dev/null
+++ b/test/std/re/re.regex/re.regex.construct/bad_escape.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT, class traits = regex_traits<charT>> class basic_regex;
+
+// template <class ST, class SA>
+// basic_regex(const basic_string<charT, ST, SA>& s);
+
+#include <regex>
+#include <cassert>
+
+static bool error_escape_thrown(const char *pat)
+{
+ bool result = false;
+ try {
+ std::regex re(pat);
+ } catch (std::regex_error &ex) {
+ result = (ex.code() == std::regex_constants::error_escape);
+ }
+ return result;
+}
+
+int main()
+{
+ assert(error_escape_thrown("[\\a]"));
+ assert(error_escape_thrown("\\a"));
+
+ assert(error_escape_thrown("[\\e]"));
+ assert(error_escape_thrown("\\e"));
+
+ assert(error_escape_thrown("[\\c:]"));
+ assert(error_escape_thrown("\\c:"));
+ assert(error_escape_thrown("\\c"));
+ assert(!error_escape_thrown("[\\cA]"));
+ assert(!error_escape_thrown("\\cA"));
+
+}
diff --git a/test/std/re/re.regex/re.regex.construct/copy.pass.cpp b/test/std/re/re.regex/re.regex.construct/copy.pass.cpp
new file mode 100644
index 000000000000..c2788f0fa2c6
--- /dev/null
+++ b/test/std/re/re.regex/re.regex.construct/copy.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT, class traits = regex_traits<charT>> class basic_regex;
+
+// basic_regex(const basic_regex& e);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ std::regex r1("(a([bc]))");
+ std::regex r2 = r1;
+ assert(r2.flags() == std::regex::ECMAScript);
+ assert(r2.mark_count() == 2);
+}
diff --git a/test/std/re/re.regex/re.regex.construct/default.pass.cpp b/test/std/re/re.regex/re.regex.construct/default.pass.cpp
new file mode 100644
index 000000000000..d959c1ec5820
--- /dev/null
+++ b/test/std/re/re.regex/re.regex.construct/default.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT, class traits = regex_traits<charT>> class basic_regex;
+
+// basic_regex();
+
+#include <regex>
+#include <cassert>
+
+template <class CharT>
+void
+test()
+{
+ std::basic_regex<CharT> r;
+ assert(r.flags() == 0);
+ assert(r.mark_count() == 0);
+}
+
+int main()
+{
+ test<char>();
+ test<wchar_t>();
+}
diff --git a/test/std/re/re.regex/re.regex.construct/il_flg.pass.cpp b/test/std/re/re.regex/re.regex.construct/il_flg.pass.cpp
new file mode 100644
index 000000000000..70d28df370d1
--- /dev/null
+++ b/test/std/re/re.regex/re.regex.construct/il_flg.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT, class traits = regex_traits<charT>> class basic_regex;
+
+// basic_regex(initializer_list<charT> il,
+// flag_type f = regex_constants::ECMAScript);
+
+#include <regex>
+#include <cassert>
+
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+void
+test(std::initializer_list<char> il, std::regex_constants::syntax_option_type f, unsigned mc)
+{
+ std::basic_regex<char> r(il, f);
+ assert(r.flags() == f);
+ assert(r.mark_count() == mc);
+}
+
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ std::string s1("\\(a\\)");
+ std::string s2("\\(a[bc]\\)");
+ std::string s3("\\(a\\([bc]\\)\\)");
+ std::string s4("(a([bc]))");
+
+ test({'\\', '(', 'a', '\\', ')'}, std::regex_constants::basic, 1);
+ test({'\\', '(', 'a', '[', 'b', 'c', ']', '\\', ')'}, std::regex_constants::basic, 1);
+ test({'\\', '(', 'a', '\\', '(', '[', 'b', 'c', ']', '\\', ')', '\\', ')'}, std::regex_constants::basic, 2);
+ test({'(', 'a', '(', '[', 'b', 'c', ']', ')', ')'}, std::regex_constants::basic, 0);
+
+ test({'\\', '(', 'a', '\\', ')'}, std::regex_constants::extended, 0);
+ test({'\\', '(', 'a', '[', 'b', 'c', ']', '\\', ')'}, std::regex_constants::extended, 0);
+ test({'\\', '(', 'a', '\\', '(', '[', 'b', 'c', ']', '\\', ')', '\\', ')'}, std::regex_constants::extended, 0);
+ test({'(', 'a', '(', '[', 'b', 'c', ']', ')', ')'}, std::regex_constants::extended, 2);
+
+ test({'\\', '(', 'a', '\\', ')'}, std::regex_constants::ECMAScript, 0);
+ test({'\\', '(', 'a', '[', 'b', 'c', ']', '\\', ')'}, std::regex_constants::ECMAScript, 0);
+ test({'\\', '(', 'a', '\\', '(', '[', 'b', 'c', ']', '\\', ')', '\\', ')'}, std::regex_constants::ECMAScript, 0);
+ test({'(', 'a', '(', '[', 'b', 'c', ']', ')', ')'}, std::regex_constants::ECMAScript, 2);
+
+ test({'\\', '(', 'a', '\\', ')'}, std::regex_constants::awk, 0);
+ test({'\\', '(', 'a', '[', 'b', 'c', ']', '\\', ')'}, std::regex_constants::awk, 0);
+ test({'\\', '(', 'a', '\\', '(', '[', 'b', 'c', ']', '\\', ')', '\\', ')'}, std::regex_constants::awk, 0);
+ test({'(', 'a', '(', '[', 'b', 'c', ']', ')', ')'}, std::regex_constants::awk, 2);
+
+ test({'\\', '(', 'a', '\\', ')'}, std::regex_constants::grep, 1);
+ test({'\\', '(', 'a', '[', 'b', 'c', ']', '\\', ')'}, std::regex_constants::grep, 1);
+ test({'\\', '(', 'a', '\\', '(', '[', 'b', 'c', ']', '\\', ')', '\\', ')'}, std::regex_constants::grep, 2);
+ test({'(', 'a', '(', '[', 'b', 'c', ']', ')', ')'}, std::regex_constants::grep, 0);
+
+ test({'\\', '(', 'a', '\\', ')'}, std::regex_constants::egrep, 0);
+ test({'\\', '(', 'a', '[', 'b', 'c', ']', '\\', ')'}, std::regex_constants::egrep, 0);
+ test({'\\', '(', 'a', '\\', '(', '[', 'b', 'c', ']', '\\', ')', '\\', ')'}, std::regex_constants::egrep, 0);
+ test({'(', 'a', '(', '[', 'b', 'c', ']', ')', ')'}, std::regex_constants::egrep, 2);
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/re/re.regex/re.regex.construct/iter_iter.pass.cpp b/test/std/re/re.regex/re.regex.construct/iter_iter.pass.cpp
new file mode 100644
index 000000000000..a38e16234191
--- /dev/null
+++ b/test/std/re/re.regex/re.regex.construct/iter_iter.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT, class traits = regex_traits<charT>> class basic_regex;
+
+// template <class ForwardIterator>
+// basic_regex(ForwardIterator first, ForwardIterator last);
+
+#include <regex>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter>
+void
+test(Iter first, Iter last, unsigned mc)
+{
+ std::basic_regex<typename std::iterator_traits<Iter>::value_type> r(first, last);
+ assert(r.flags() == std::regex_constants::ECMAScript);
+ assert(r.mark_count() == mc);
+}
+
+int main()
+{
+ typedef forward_iterator<std::string::const_iterator> F;
+ std::string s1("\\(a\\)");
+ std::string s2("\\(a[bc]\\)");
+ std::string s3("\\(a\\([bc]\\)\\)");
+ std::string s4("(a([bc]))");
+
+ test(F(s1.begin()), F(s1.end()), 0);
+ test(F(s2.begin()), F(s2.end()), 0);
+ test(F(s3.begin()), F(s3.end()), 0);
+ test(F(s4.begin()), F(s4.end()), 2);
+}
diff --git a/test/std/re/re.regex/re.regex.construct/iter_iter_flg.pass.cpp b/test/std/re/re.regex/re.regex.construct/iter_iter_flg.pass.cpp
new file mode 100644
index 000000000000..c4c440e6d246
--- /dev/null
+++ b/test/std/re/re.regex/re.regex.construct/iter_iter_flg.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT, class traits = regex_traits<charT>> class basic_regex;
+
+// template <class ForwardIterator>
+// basic_regex(ForwardIterator first, ForwardIterator last,
+// flag_type f = regex_constants::ECMAScript);
+
+#include <regex>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter>
+void
+test(Iter first, Iter last, std::regex_constants::syntax_option_type f, unsigned mc)
+{
+ std::basic_regex<typename std::iterator_traits<Iter>::value_type> r(first, last, f);
+ assert(r.flags() == f);
+ assert(r.mark_count() == mc);
+}
+
+int main()
+{
+ typedef forward_iterator<std::string::const_iterator> F;
+ std::string s1("\\(a\\)");
+ std::string s2("\\(a[bc]\\)");
+ std::string s3("\\(a\\([bc]\\)\\)");
+ std::string s4("(a([bc]))");
+
+ test(F(s1.begin()), F(s1.end()), std::regex_constants::basic, 1);
+ test(F(s2.begin()), F(s2.end()), std::regex_constants::basic, 1);
+ test(F(s3.begin()), F(s3.end()), std::regex_constants::basic, 2);
+ test(F(s4.begin()), F(s4.end()), std::regex_constants::basic, 0);
+
+ test(F(s1.begin()), F(s1.end()), std::regex_constants::extended, 0);
+ test(F(s2.begin()), F(s2.end()), std::regex_constants::extended, 0);
+ test(F(s3.begin()), F(s3.end()), std::regex_constants::extended, 0);
+ test(F(s4.begin()), F(s4.end()), std::regex_constants::extended, 2);
+
+ test(F(s1.begin()), F(s1.end()), std::regex_constants::ECMAScript, 0);
+ test(F(s2.begin()), F(s2.end()), std::regex_constants::ECMAScript, 0);
+ test(F(s3.begin()), F(s3.end()), std::regex_constants::ECMAScript, 0);
+ test(F(s4.begin()), F(s4.end()), std::regex_constants::ECMAScript, 2);
+
+ test(F(s1.begin()), F(s1.end()), std::regex_constants::awk, 0);
+ test(F(s2.begin()), F(s2.end()), std::regex_constants::awk, 0);
+ test(F(s3.begin()), F(s3.end()), std::regex_constants::awk, 0);
+ test(F(s4.begin()), F(s4.end()), std::regex_constants::awk, 2);
+
+ test(F(s1.begin()), F(s1.end()), std::regex_constants::grep, 1);
+ test(F(s2.begin()), F(s2.end()), std::regex_constants::grep, 1);
+ test(F(s3.begin()), F(s3.end()), std::regex_constants::grep, 2);
+ test(F(s4.begin()), F(s4.end()), std::regex_constants::grep, 0);
+
+ test(F(s1.begin()), F(s1.end()), std::regex_constants::egrep, 0);
+ test(F(s2.begin()), F(s2.end()), std::regex_constants::egrep, 0);
+ test(F(s3.begin()), F(s3.end()), std::regex_constants::egrep, 0);
+ test(F(s4.begin()), F(s4.end()), std::regex_constants::egrep, 2);
+}
diff --git a/test/std/re/re.regex/re.regex.construct/ptr.pass.cpp b/test/std/re/re.regex/re.regex.construct/ptr.pass.cpp
new file mode 100644
index 000000000000..b99b58b469cf
--- /dev/null
+++ b/test/std/re/re.regex/re.regex.construct/ptr.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT, class traits = regex_traits<charT>> class basic_regex;
+
+// basic_regex(const charT* p);
+
+#include <regex>
+#include <cassert>
+
+template <class CharT>
+void
+test(const CharT* p, unsigned mc)
+{
+ std::basic_regex<CharT> r(p);
+ assert(r.flags() == std::regex_constants::ECMAScript);
+ assert(r.mark_count() == mc);
+}
+
+int main()
+{
+ test("\\(a\\)", 0);
+ test("\\(a[bc]\\)", 0);
+ test("\\(a\\([bc]\\)\\)", 0);
+ test("(a([bc]))", 2);
+}
diff --git a/test/std/re/re.regex/re.regex.construct/ptr_flg.pass.cpp b/test/std/re/re.regex/re.regex.construct/ptr_flg.pass.cpp
new file mode 100644
index 000000000000..138e20efbf65
--- /dev/null
+++ b/test/std/re/re.regex/re.regex.construct/ptr_flg.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT, class traits = regex_traits<charT>> class basic_regex;
+
+// basic_regex(const charT* p, flag_type f = regex_constants::ECMAScript);
+
+#include <regex>
+#include <cassert>
+
+template <class CharT>
+void
+test(const CharT* p, std::regex_constants::syntax_option_type f, unsigned mc)
+{
+ std::basic_regex<CharT> r(p, f);
+ assert(r.flags() == f);
+ assert(r.mark_count() == mc);
+}
+
+int main()
+{
+ test("\\(a\\)", std::regex_constants::basic, 1);
+ test("\\(a[bc]\\)", std::regex_constants::basic, 1);
+ test("\\(a\\([bc]\\)\\)", std::regex_constants::basic, 2);
+ test("(a([bc]))", std::regex_constants::basic, 0);
+
+ test("\\(a\\)", std::regex_constants::extended, 0);
+ test("\\(a[bc]\\)", std::regex_constants::extended, 0);
+ test("\\(a\\([bc]\\)\\)", std::regex_constants::extended, 0);
+ test("(a([bc]))", std::regex_constants::extended, 2);
+
+ test("\\(a\\)", std::regex_constants::ECMAScript, 0);
+ test("\\(a[bc]\\)", std::regex_constants::ECMAScript, 0);
+ test("\\(a\\([bc]\\)\\)", std::regex_constants::ECMAScript, 0);
+ test("(a([bc]))", std::regex_constants::ECMAScript, 2);
+
+ test("\\(a\\)", std::regex_constants::awk, 0);
+ test("\\(a[bc]\\)", std::regex_constants::awk, 0);
+ test("\\(a\\([bc]\\)\\)", std::regex_constants::awk, 0);
+ test("(a([bc]))", std::regex_constants::awk, 2);
+
+ test("\\(a\\)", std::regex_constants::grep, 1);
+ test("\\(a[bc]\\)", std::regex_constants::grep, 1);
+ test("\\(a\\([bc]\\)\\)", std::regex_constants::grep, 2);
+ test("(a([bc]))", std::regex_constants::grep, 0);
+
+ test("\\(a\\)", std::regex_constants::egrep, 0);
+ test("\\(a[bc]\\)", std::regex_constants::egrep, 0);
+ test("\\(a\\([bc]\\)\\)", std::regex_constants::egrep, 0);
+ test("(a([bc]))", std::regex_constants::egrep, 2);
+}
diff --git a/test/std/re/re.regex/re.regex.construct/ptr_size_flg.pass.cpp b/test/std/re/re.regex/re.regex.construct/ptr_size_flg.pass.cpp
new file mode 100644
index 000000000000..d623a15936f4
--- /dev/null
+++ b/test/std/re/re.regex/re.regex.construct/ptr_size_flg.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT, class traits = regex_traits<charT>> class basic_regex;
+
+// basic_regex(const charT* p, size_t len, flag_type f);
+
+#include <regex>
+#include <cassert>
+
+template <class CharT>
+void
+test(const CharT* p, std::size_t len, std::regex_constants::syntax_option_type f,
+ unsigned mc)
+{
+ std::basic_regex<CharT> r(p, len, f);
+ assert(r.flags() == f);
+ assert(r.mark_count() == mc);
+}
+
+int main()
+{
+ test("\\(a\\)", 5, std::regex_constants::basic, 1);
+ test("\\(a[bc]\\)", 9, std::regex_constants::basic, 1);
+ test("\\(a\\([bc]\\)\\)", 13, std::regex_constants::basic, 2);
+ test("(a([bc]))", 9, std::regex_constants::basic, 0);
+
+ test("\\(a\\)", 5, std::regex_constants::extended, 0);
+ test("\\(a[bc]\\)", 9, std::regex_constants::extended, 0);
+ test("\\(a\\([bc]\\)\\)", 13, std::regex_constants::extended, 0);
+ test("(a([bc]))", 9, std::regex_constants::extended, 2);
+
+ test("\\(a\\)", 5, std::regex_constants::ECMAScript, 0);
+ test("\\(a[bc]\\)", 9, std::regex_constants::ECMAScript, 0);
+ test("\\(a\\([bc]\\)\\)", 13, std::regex_constants::ECMAScript, 0);
+ test("(a([bc]))", 9, std::regex_constants::ECMAScript, 2);
+
+ test("\\(a\\)", 5, std::regex_constants::awk, 0);
+ test("\\(a[bc]\\)", 9, std::regex_constants::awk, 0);
+ test("\\(a\\([bc]\\)\\)", 13, std::regex_constants::awk, 0);
+ test("(a([bc]))", 9, std::regex_constants::awk, 2);
+
+ test("\\(a\\)", 5, std::regex_constants::grep, 1);
+ test("\\(a[bc]\\)", 9, std::regex_constants::grep, 1);
+ test("\\(a\\([bc]\\)\\)", 13, std::regex_constants::grep, 2);
+ test("(a([bc]))", 9, std::regex_constants::grep, 0);
+
+ test("\\(a\\)", 5, std::regex_constants::egrep, 0);
+ test("\\(a[bc]\\)", 9, std::regex_constants::egrep, 0);
+ test("\\(a\\([bc]\\)\\)", 13, std::regex_constants::egrep, 0);
+ test("(a([bc]))", 9, std::regex_constants::egrep, 2);
+}
diff --git a/test/std/re/re.regex/re.regex.construct/string.pass.cpp b/test/std/re/re.regex/re.regex.construct/string.pass.cpp
new file mode 100644
index 000000000000..b58b8e03cd20
--- /dev/null
+++ b/test/std/re/re.regex/re.regex.construct/string.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT, class traits = regex_traits<charT>> class basic_regex;
+
+// template <class ST, class SA>
+// basic_regex(const basic_string<charT, ST, SA>& s);
+
+#include <regex>
+#include <cassert>
+
+template <class String>
+void
+test(const String& p, unsigned mc)
+{
+ std::basic_regex<typename String::value_type> r(p);
+ assert(r.flags() == std::regex_constants::ECMAScript);
+ assert(r.mark_count() == mc);
+}
+
+int main()
+{
+ test(std::string("\\(a\\)"), 0);
+ test(std::string("\\(a[bc]\\)"), 0);
+ test(std::string("\\(a\\([bc]\\)\\)"), 0);
+ test(std::string("(a([bc]))"), 2);
+}
diff --git a/test/std/re/re.regex/re.regex.construct/string_flg.pass.cpp b/test/std/re/re.regex/re.regex.construct/string_flg.pass.cpp
new file mode 100644
index 000000000000..768de568e229
--- /dev/null
+++ b/test/std/re/re.regex/re.regex.construct/string_flg.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT, class traits = regex_traits<charT>> class basic_regex;
+
+// template <class ST, class SA>
+// basic_regex(const basic_string<charT, ST, SA>& s,
+// flag_type f = regex_constants::ECMAScript);
+
+#include <regex>
+#include <cassert>
+
+template <class String>
+void
+test(const String& p, std::regex_constants::syntax_option_type f, unsigned mc)
+{
+ std::basic_regex<typename String::value_type> r(p, f);
+ assert(r.flags() == f);
+ assert(r.mark_count() == mc);
+}
+
+int main()
+{
+ test(std::string("\\(a\\)"), std::regex_constants::basic, 1);
+ test(std::string("\\(a[bc]\\)"), std::regex_constants::basic, 1);
+ test(std::string("\\(a\\([bc]\\)\\)"), std::regex_constants::basic, 2);
+ test(std::string("(a([bc]))"), std::regex_constants::basic, 0);
+
+ test(std::string("\\(a\\)"), std::regex_constants::extended, 0);
+ test(std::string("\\(a[bc]\\)"), std::regex_constants::extended, 0);
+ test(std::string("\\(a\\([bc]\\)\\)"), std::regex_constants::extended, 0);
+ test(std::string("(a([bc]))"), std::regex_constants::extended, 2);
+
+ test(std::string("\\(a\\)"), std::regex_constants::ECMAScript, 0);
+ test(std::string("\\(a[bc]\\)"), std::regex_constants::ECMAScript, 0);
+ test(std::string("\\(a\\([bc]\\)\\)"), std::regex_constants::ECMAScript, 0);
+ test(std::string("(a([bc]))"), std::regex_constants::ECMAScript, 2);
+
+ test(std::string("\\(a\\)"), std::regex_constants::awk, 0);
+ test(std::string("\\(a[bc]\\)"), std::regex_constants::awk, 0);
+ test(std::string("\\(a\\([bc]\\)\\)"), std::regex_constants::awk, 0);
+ test(std::string("(a([bc]))"), std::regex_constants::awk, 2);
+
+ test(std::string("\\(a\\)"), std::regex_constants::grep, 1);
+ test(std::string("\\(a[bc]\\)"), std::regex_constants::grep, 1);
+ test(std::string("\\(a\\([bc]\\)\\)"), std::regex_constants::grep, 2);
+ test(std::string("(a([bc]))"), std::regex_constants::grep, 0);
+
+ test(std::string("\\(a\\)"), std::regex_constants::egrep, 0);
+ test(std::string("\\(a[bc]\\)"), std::regex_constants::egrep, 0);
+ test(std::string("\\(a\\([bc]\\)\\)"), std::regex_constants::egrep, 0);
+ test(std::string("(a([bc]))"), std::regex_constants::egrep, 2);
+}
diff --git a/test/std/re/re.regex/re.regex.locale/imbue.pass.cpp b/test/std/re/re.regex/re.regex.locale/imbue.pass.cpp
new file mode 100644
index 000000000000..be0b26dc5c2c
--- /dev/null
+++ b/test/std/re/re.regex/re.regex.locale/imbue.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT, class traits = regex_traits<charT>> class basic_regex;
+
+// locale_type imbue(locale_type loc);
+
+#include <regex>
+#include <locale>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+int main()
+{
+ std::regex r;
+ std::locale loc = r.imbue(std::locale(LOCALE_en_US_UTF_8));
+ assert(loc.name() == "C");
+ assert(r.getloc().name() == LOCALE_en_US_UTF_8);
+ loc = r.imbue(std::locale("C"));
+ assert(loc.name() == LOCALE_en_US_UTF_8);
+ assert(r.getloc().name() == "C");
+}
diff --git a/test/std/re/re.regex/re.regex.nonmemb/nothing_to_do.pass.cpp b/test/std/re/re.regex/re.regex.nonmemb/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/re/re.regex/re.regex.nonmemb/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/re/re.regex/re.regex.nonmemb/re.regex.nmswap/swap.pass.cpp b/test/std/re/re.regex/re.regex.nonmemb/re.regex.nmswap/swap.pass.cpp
new file mode 100644
index 000000000000..9d3c481686e7
--- /dev/null
+++ b/test/std/re/re.regex/re.regex.nonmemb/re.regex.nmswap/swap.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT, class traits = regex_traits<charT>> class basic_regex;
+
+// template <class charT, class traits>
+// void swap(basic_regex<charT, traits>& lhs, basic_regex<charT, traits>& rhs);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ std::regex r1("(a([bc]))");
+ std::regex r2;
+ swap(r2, r1);
+ assert(r1.flags() == std::regex::ECMAScript);
+ assert(r1.mark_count() == 0);
+ assert(r2.flags() == std::regex::ECMAScript);
+ assert(r2.mark_count() == 2);
+}
diff --git a/test/std/re/re.regex/re.regex.operations/tested_elsewhere.pass.cpp b/test/std/re/re.regex/re.regex.operations/tested_elsewhere.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/re/re.regex/re.regex.operations/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/re/re.regex/re.regex.swap/swap.pass.cpp b/test/std/re/re.regex/re.regex.swap/swap.pass.cpp
new file mode 100644
index 000000000000..cda8ef3541a2
--- /dev/null
+++ b/test/std/re/re.regex/re.regex.swap/swap.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT, class traits = regex_traits<charT>> class basic_regex;
+
+// void swap(basic_regex& e);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ std::regex r1("(a([bc]))");
+ std::regex r2;
+ r2.swap(r1);
+ assert(r1.flags() == std::regex::ECMAScript);
+ assert(r1.mark_count() == 0);
+ assert(r2.flags() == std::regex::ECMAScript);
+ assert(r2.mark_count() == 2);
+}
diff --git a/test/std/re/re.regex/types.pass.cpp b/test/std/re/re.regex/types.pass.cpp
new file mode 100644
index 000000000000..02011ac56ebb
--- /dev/null
+++ b/test/std/re/re.regex/types.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT, class traits = regex_traits<charT>>
+// class basic_regex
+// {
+// public:
+// // types:
+// typedef charT value_type;
+// typedef regex_constants::syntax_option_type flag_type;
+// typedef typename traits::locale_type locale_type;
+
+#include <regex>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_same<std::basic_regex<char>::value_type, char>::value), "");
+ static_assert((std::is_same<std::basic_regex<char>::flag_type,
+ std::regex_constants::syntax_option_type>::value), "");
+ static_assert((std::is_same<std::basic_regex<char>::locale_type, std::locale>::value), "");
+
+ static_assert((std::is_same<std::basic_regex<wchar_t>::value_type, wchar_t>::value), "");
+ static_assert((std::is_same<std::basic_regex<wchar_t>::flag_type,
+ std::regex_constants::syntax_option_type>::value), "");
+ static_assert((std::is_same<std::basic_regex<wchar_t>::locale_type, std::locale>::value), "");
+}
diff --git a/test/std/re/re.req/nothing_to_do.pass.cpp b/test/std/re/re.req/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..9a59227abdd9
--- /dev/null
+++ b/test/std/re/re.req/nothing_to_do.pass.cpp
@@ -0,0 +1,13 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/re/re.results/re.results.acc/begin_end.pass.cpp b/test/std/re/re.results/re.results.acc/begin_end.pass.cpp
new file mode 100644
index 000000000000..80c06f299bd7
--- /dev/null
+++ b/test/std/re/re.results/re.results.acc/begin_end.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class match_results<BidirectionalIterator, Allocator>
+
+// const_iterator begin() const;
+// const_iterator end() const;
+
+#include <regex>
+#include <cassert>
+
+void
+test()
+{
+ std::match_results<const char*> m;
+ const char s[] = "abcdefghijk";
+ assert(std::regex_search(s, m, std::regex("cd((e)fg)hi")));
+
+ std::match_results<const char*>::const_iterator i = m.begin();
+ std::match_results<const char*>::const_iterator e = m.end();
+
+ assert(e - i == m.size());
+ for (int j = 0; i != e; ++i, ++j)
+ assert(*i == m[j]);
+}
+
+int main()
+{
+ test();
+}
diff --git a/test/std/re/re.results/re.results.acc/cbegin_cend.pass.cpp b/test/std/re/re.results/re.results.acc/cbegin_cend.pass.cpp
new file mode 100644
index 000000000000..a983c8afc81a
--- /dev/null
+++ b/test/std/re/re.results/re.results.acc/cbegin_cend.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class match_results<BidirectionalIterator, Allocator>
+
+// const_iterator cbegin() const;
+// const_iterator cend() const;
+
+#include <regex>
+#include <cassert>
+
+void
+test()
+{
+ std::match_results<const char*> m;
+ const char s[] = "abcdefghijk";
+ assert(std::regex_search(s, m, std::regex("cd((e)fg)hi")));
+
+ std::match_results<const char*>::const_iterator i = m.cbegin();
+ std::match_results<const char*>::const_iterator e = m.cend();
+
+ assert(e - i == m.size());
+ for (int j = 0; i != e; ++i, ++j)
+ assert(*i == m[j]);
+}
+
+int main()
+{
+ test();
+}
diff --git a/test/std/re/re.results/re.results.acc/index.pass.cpp b/test/std/re/re.results/re.results.acc/index.pass.cpp
new file mode 100644
index 000000000000..79d4b9a23788
--- /dev/null
+++ b/test/std/re/re.results/re.results.acc/index.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class match_results<BidirectionalIterator, Allocator>
+
+// const_reference operator[](size_type n) const;
+
+#include <regex>
+#include <cassert>
+
+void
+test(std::regex_constants::syntax_option_type syntax)
+{
+ std::match_results<const char*> m;
+ const char s[] = "abcdefghijk";
+ assert(std::regex_search(s, m, std::regex("cd((e)fg)hi|(z)", syntax)));
+
+ assert(m.size() == 4);
+
+ assert(m[0].first == s+2);
+ assert(m[0].second == s+9);
+ assert(m[0].matched == true);
+
+ assert(m[1].first == s+4);
+ assert(m[1].second == s+7);
+ assert(m[1].matched == true);
+
+ assert(m[2].first == s+4);
+ assert(m[2].second == s+5);
+ assert(m[2].matched == true);
+
+ assert(m[3].first == s+11);
+ assert(m[3].second == s+11);
+ assert(m[3].matched == false);
+
+ assert(m[4].first == s+11);
+ assert(m[4].second == s+11);
+ assert(m[4].matched == false);
+}
+
+int main()
+{
+ test(std::regex_constants::ECMAScript);
+ test(std::regex_constants::extended);
+}
diff --git a/test/std/re/re.results/re.results.acc/length.pass.cpp b/test/std/re/re.results/re.results.acc/length.pass.cpp
new file mode 100644
index 000000000000..91020851a308
--- /dev/null
+++ b/test/std/re/re.results/re.results.acc/length.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class match_results<BidirectionalIterator, Allocator>
+
+// difference_type length(size_type sub = 0) const;
+
+#include <regex>
+#include <cassert>
+
+void
+test()
+{
+ std::match_results<const char*> m;
+ const char s[] = "abcdefghijk";
+ assert(std::regex_search(s, m, std::regex("cd((e)fg)hi")));
+ assert(m.length() == m[0].length());
+ assert(m.length(0) == m[0].length());
+ assert(m.length(1) == m[1].length());
+ assert(m.length(2) == m[2].length());
+ assert(m.length(3) == m[3].length());
+ assert(m.length(4) == m[4].length());
+}
+
+int main()
+{
+ test();
+}
diff --git a/test/std/re/re.results/re.results.acc/position.pass.cpp b/test/std/re/re.results/re.results.acc/position.pass.cpp
new file mode 100644
index 000000000000..2698e2d91693
--- /dev/null
+++ b/test/std/re/re.results/re.results.acc/position.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class match_results<BidirectionalIterator, Allocator>
+
+// difference_type position(size_type sub = 0) const;
+
+#include <regex>
+#include <cassert>
+
+void
+test()
+{
+ std::match_results<const char*> m;
+ const char s[] = "abcdefghijk";
+ assert(std::regex_search(s, m, std::regex("cd((e)fg)hi")));
+ assert(m.position() == std::distance(s, m[0].first));
+ assert(m.position(0) == std::distance(s, m[0].first));
+ assert(m.position(1) == std::distance(s, m[1].first));
+ assert(m.position(2) == std::distance(s, m[2].first));
+ assert(m.position(3) == std::distance(s, m[3].first));
+ assert(m.position(4) == std::distance(s, m[4].first));
+}
+
+int main()
+{
+ test();
+}
diff --git a/test/std/re/re.results/re.results.acc/prefix.pass.cpp b/test/std/re/re.results/re.results.acc/prefix.pass.cpp
new file mode 100644
index 000000000000..58cdabc24df8
--- /dev/null
+++ b/test/std/re/re.results/re.results.acc/prefix.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class match_results<BidirectionalIterator, Allocator>
+
+// const_reference prefix() const;
+
+#include <regex>
+#include <cassert>
+
+void
+test()
+{
+ std::match_results<const char*> m;
+ const char s[] = "abcdefghijk";
+ assert(std::regex_search(s, m, std::regex("cd((e)fg)hi")));
+
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == s+2);
+ assert(m.prefix().matched == true);
+}
+
+int main()
+{
+ test();
+}
diff --git a/test/std/re/re.results/re.results.acc/str.pass.cpp b/test/std/re/re.results/re.results.acc/str.pass.cpp
new file mode 100644
index 000000000000..2ebfeabb2078
--- /dev/null
+++ b/test/std/re/re.results/re.results.acc/str.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class match_results<BidirectionalIterator, Allocator>
+
+// string_type str(size_type sub = 0) const;
+
+#include <regex>
+#include <cassert>
+
+void
+test()
+{
+ std::match_results<const char*> m;
+ const char s[] = "abcdefghijk";
+ assert(std::regex_search(s, m, std::regex("cd((e)fg)hi")));
+ assert(m.str() == std::string(m[0]));
+ assert(m.str(0) == std::string(m[0]));
+ assert(m.str(1) == std::string(m[1]));
+ assert(m.str(2) == std::string(m[2]));
+ assert(m.str(3) == std::string(m[3]));
+ assert(m.str(4) == std::string(m[4]));
+}
+
+int main()
+{
+ test();
+}
diff --git a/test/std/re/re.results/re.results.acc/suffix.pass.cpp b/test/std/re/re.results/re.results.acc/suffix.pass.cpp
new file mode 100644
index 000000000000..b842ea861e43
--- /dev/null
+++ b/test/std/re/re.results/re.results.acc/suffix.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class match_results<BidirectionalIterator, Allocator>
+
+// const_reference suffix() const;
+
+#include <regex>
+#include <cassert>
+
+void
+test()
+{
+ std::match_results<const char*> m;
+ const char s[] = "abcdefghijk";
+ assert(std::regex_search(s, m, std::regex("cd((e)fg)hi")));
+
+ assert(m.suffix().first == s+9);
+ assert(m.suffix().second == s+11);
+ assert(m.suffix().matched == true);
+}
+
+int main()
+{
+ test();
+}
diff --git a/test/std/re/re.results/re.results.all/get_allocator.pass.cpp b/test/std/re/re.results/re.results.all/get_allocator.pass.cpp
new file mode 100644
index 000000000000..04367953ad29
--- /dev/null
+++ b/test/std/re/re.results/re.results.all/get_allocator.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class match_results<BidirectionalIterator, Allocator>
+
+// allocator_type get_allocator() const;
+
+#include <regex>
+#include <cassert>
+
+#include "test_allocator.h"
+
+template <class CharT, class Allocator>
+void
+test(const Allocator& a)
+{
+ std::match_results<const CharT*, Allocator> m(a);
+ assert(m.size() == 0);
+ assert(m.str() == std::basic_string<CharT>());
+ assert(m.get_allocator() == a);
+}
+
+int main()
+{
+ test<char>(test_allocator<std::sub_match<const char*> >(3));
+ test<wchar_t>(test_allocator<std::sub_match<const wchar_t*> >(3));
+}
diff --git a/test/std/re/re.results/re.results.const/allocator.pass.cpp b/test/std/re/re.results/re.results.const/allocator.pass.cpp
new file mode 100644
index 000000000000..a24c669f657d
--- /dev/null
+++ b/test/std/re/re.results/re.results.const/allocator.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class match_results<BidirectionalIterator, Allocator>
+
+// match_results(const Allocator& a = Allocator());
+
+#include <regex>
+#include <cassert>
+
+#include "test_allocator.h"
+
+template <class CharT, class Allocator>
+void
+test(const Allocator& a)
+{
+ std::match_results<const CharT*, Allocator> m(a);
+ assert(m.size() == 0);
+ assert(m.str() == std::basic_string<CharT>());
+ assert(m.get_allocator() == a);
+}
+
+int main()
+{
+ test<char>(test_allocator<std::sub_match<const char*> >(3));
+ test<wchar_t>(test_allocator<std::sub_match<const wchar_t*> >(3));
+}
diff --git a/test/std/re/re.results/re.results.const/default.pass.cpp b/test/std/re/re.results/re.results.const/default.pass.cpp
new file mode 100644
index 000000000000..e10fbfd76cf0
--- /dev/null
+++ b/test/std/re/re.results/re.results.const/default.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class match_results<BidirectionalIterator, Allocator>
+
+// match_results(const Allocator& a = Allocator());
+
+#include <regex>
+#include <cassert>
+
+template <class CharT>
+void
+test()
+{
+ std::match_results<const CharT*> m;
+ assert(m.size() == 0);
+ assert(m.str() == std::basic_string<CharT>());
+ assert(m.get_allocator() == std::allocator<std::sub_match<const CharT*> >());
+}
+
+int main()
+{
+ test<char>();
+ test<wchar_t>();
+}
diff --git a/test/std/re/re.results/re.results.form/form1.pass.cpp b/test/std/re/re.results/re.results.form/form1.pass.cpp
new file mode 100644
index 000000000000..9701c60ba77c
--- /dev/null
+++ b/test/std/re/re.results/re.results.form/form1.pass.cpp
@@ -0,0 +1,103 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class match_results<BidirectionalIterator, Allocator>
+
+// template <class OutputIter>
+// OutputIter
+// format(OutputIter out, const char_type* fmt_first, const char_type* fmt_last,
+// regex_constants::match_flag_type flags = regex_constants::format_default) const;
+
+#include <regex>
+#include <cassert>
+
+#include "test_iterators.h"
+
+int main()
+{
+ {
+ std::match_results<const char*> m;
+ const char s[] = "abcdefghijk";
+ assert(std::regex_search(s, m, std::regex("cd((e)fg)hi")));
+
+ char out[100] = {0};
+ const char fmt[] = "prefix: $`, match: $&, suffix: $', m[1]: $1, m[2]: $2";
+ char* r = m.format(output_iterator<char*>(out),
+ fmt, fmt + std::char_traits<char>::length(fmt)).base();
+ assert(r == out + 58);
+ assert(std::string(out) == "prefix: ab, match: cdefghi, suffix: jk, m[1]: efg, m[2]: e");
+ }
+ {
+ std::match_results<const char*> m;
+ const char s[] = "abcdefghijk";
+ assert(std::regex_search(s, m, std::regex("cd((e)fg)hi")));
+
+ char out[100] = {0};
+ const char fmt[] = "prefix: $`, match: $&, suffix: $', m[1]: $1, m[2]: $2";
+ char* r = m.format(output_iterator<char*>(out),
+ fmt, fmt + std::char_traits<char>::length(fmt),
+ std::regex_constants::format_sed).base();
+ assert(r == out + 59);
+ assert(std::string(out) == "prefix: $`, match: $cdefghi, suffix: $', m[1]: $1, m[2]: $2");
+ }
+ {
+ std::match_results<const char*> m;
+ const char s[] = "abcdefghijk";
+ assert(std::regex_search(s, m, std::regex("cd((e)fg)hi")));
+
+ char out[100] = {0};
+ const char fmt[] = "match: &, m[1]: \\1, m[2]: \\2";
+ char* r = m.format(output_iterator<char*>(out),
+ fmt, fmt + std::char_traits<char>::length(fmt),
+ std::regex_constants::format_sed).base();
+ assert(r == out + 34);
+ assert(std::string(out) == "match: cdefghi, m[1]: efg, m[2]: e");
+ }
+
+ {
+ std::match_results<const wchar_t*> m;
+ const wchar_t s[] = L"abcdefghijk";
+ assert(std::regex_search(s, m, std::wregex(L"cd((e)fg)hi")));
+
+ wchar_t out[100] = {0};
+ const wchar_t fmt[] = L"prefix: $`, match: $&, suffix: $', m[1]: $1, m[2]: $2";
+ wchar_t* r = m.format(output_iterator<wchar_t*>(out),
+ fmt, fmt + std::char_traits<wchar_t>::length(fmt)).base();
+ assert(r == out + 58);
+ assert(std::wstring(out) == L"prefix: ab, match: cdefghi, suffix: jk, m[1]: efg, m[2]: e");
+ }
+ {
+ std::match_results<const wchar_t*> m;
+ const wchar_t s[] = L"abcdefghijk";
+ assert(std::regex_search(s, m, std::wregex(L"cd((e)fg)hi")));
+
+ wchar_t out[100] = {0};
+ const wchar_t fmt[] = L"prefix: $`, match: $&, suffix: $', m[1]: $1, m[2]: $2";
+ wchar_t* r = m.format(output_iterator<wchar_t*>(out),
+ fmt, fmt + std::char_traits<wchar_t>::length(fmt),
+ std::regex_constants::format_sed).base();
+ assert(r == out + 59);
+ assert(std::wstring(out) == L"prefix: $`, match: $cdefghi, suffix: $', m[1]: $1, m[2]: $2");
+ }
+ {
+ std::match_results<const wchar_t*> m;
+ const wchar_t s[] = L"abcdefghijk";
+ assert(std::regex_search(s, m, std::wregex(L"cd((e)fg)hi")));
+
+ wchar_t out[100] = {0};
+ const wchar_t fmt[] = L"match: &, m[1]: \\1, m[2]: \\2";
+ wchar_t* r = m.format(output_iterator<wchar_t*>(out),
+ fmt, fmt + std::char_traits<wchar_t>::length(fmt),
+ std::regex_constants::format_sed).base();
+ assert(r == out + 34);
+ assert(std::wstring(out) == L"match: cdefghi, m[1]: efg, m[2]: e");
+ }
+}
diff --git a/test/std/re/re.results/re.results.form/form2.pass.cpp b/test/std/re/re.results/re.results.form/form2.pass.cpp
new file mode 100644
index 000000000000..b18b7fb9f555
--- /dev/null
+++ b/test/std/re/re.results/re.results.form/form2.pass.cpp
@@ -0,0 +1,102 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class match_results<BidirectionalIterator, Allocator>
+
+// template <class OutputIter, class ST, class SA>
+// OutputIter
+// format(OutputIter out, const basic_string<char_type, ST, SA>& fmt,
+// regex_constants::match_flag_type flags = regex_constants::format_default) const;
+
+#include <iostream>
+
+#include <regex>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "test_allocator.h"
+
+int main()
+{
+ typedef std::basic_string<char, std::char_traits<char>, test_allocator<char> > nstr;
+ typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, test_allocator<wchar_t> > wstr;
+ {
+ std::match_results<const char*> m;
+ const char s[] = "abcdefghijk";
+ assert(std::regex_search(s, m, std::regex("cd((e)fg)hi")));
+
+ char out[100] = {0};
+ nstr fmt("prefix: $`, match: $&, suffix: $', m[1]: $1, m[2]: $2");
+ char* r = m.format(output_iterator<char*>(out), fmt).base();
+ assert(r == out + 58);
+ assert(std::string(out) == "prefix: ab, match: cdefghi, suffix: jk, m[1]: efg, m[2]: e");
+ }
+ {
+ std::match_results<const char*> m;
+ const char s[] = "abcdefghijk";
+ assert(std::regex_search(s, m, std::regex("cd((e)fg)hi")));
+
+ char out[100] = {0};
+ nstr fmt("prefix: $`, match: $&, suffix: $', m[1]: $1, m[2]: $2");
+ char* r = m.format(output_iterator<char*>(out),
+ fmt, std::regex_constants::format_sed).base();
+ assert(r == out + 59);
+ assert(std::string(out) == "prefix: $`, match: $cdefghi, suffix: $', m[1]: $1, m[2]: $2");
+ }
+ {
+ std::match_results<const char*> m;
+ const char s[] = "abcdefghijk";
+ assert(std::regex_search(s, m, std::regex("cd((e)fg)hi")));
+
+ char out[100] = {0};
+ nstr fmt("match: &, m[1]: \\1, m[2]: \\2");
+ char* r = m.format(output_iterator<char*>(out),
+ fmt, std::regex_constants::format_sed).base();
+ assert(r == out + 34);
+ assert(std::string(out) == "match: cdefghi, m[1]: efg, m[2]: e");
+ }
+
+ {
+ std::match_results<const wchar_t*> m;
+ const wchar_t s[] = L"abcdefghijk";
+ assert(std::regex_search(s, m, std::wregex(L"cd((e)fg)hi")));
+
+ wchar_t out[100] = {0};
+ wstr fmt(L"prefix: $`, match: $&, suffix: $', m[1]: $1, m[2]: $2");
+ wchar_t* r = m.format(output_iterator<wchar_t*>(out), fmt).base();
+ assert(r == out + 58);
+ assert(std::wstring(out) == L"prefix: ab, match: cdefghi, suffix: jk, m[1]: efg, m[2]: e");
+ }
+ {
+ std::match_results<const wchar_t*> m;
+ const wchar_t s[] = L"abcdefghijk";
+ assert(std::regex_search(s, m, std::wregex(L"cd((e)fg)hi")));
+
+ wchar_t out[100] = {0};
+ wstr fmt(L"prefix: $`, match: $&, suffix: $', m[1]: $1, m[2]: $2");
+ wchar_t* r = m.format(output_iterator<wchar_t*>(out),
+ fmt, std::regex_constants::format_sed).base();
+ assert(r == out + 59);
+ assert(std::wstring(out) == L"prefix: $`, match: $cdefghi, suffix: $', m[1]: $1, m[2]: $2");
+ }
+ {
+ std::match_results<const wchar_t*> m;
+ const wchar_t s[] = L"abcdefghijk";
+ assert(std::regex_search(s, m, std::wregex(L"cd((e)fg)hi")));
+
+ wchar_t out[100] = {0};
+ wstr fmt(L"match: &, m[1]: \\1, m[2]: \\2");
+ wchar_t* r = m.format(output_iterator<wchar_t*>(out),
+ fmt, std::regex_constants::format_sed).base();
+ assert(r == out + 34);
+ assert(std::wstring(out) == L"match: cdefghi, m[1]: efg, m[2]: e");
+ }
+}
diff --git a/test/std/re/re.results/re.results.form/form3.pass.cpp b/test/std/re/re.results/re.results.form/form3.pass.cpp
new file mode 100644
index 000000000000..27f2388adce0
--- /dev/null
+++ b/test/std/re/re.results/re.results.form/form3.pass.cpp
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class match_results<BidirectionalIterator, Allocator>
+
+// template <class ST, class SA>
+// basic_string<char_type, ST, SA>
+// format(const basic_string<char_type, ST, SA>& fmt,
+// regex_constants::match_flag_type flags = regex_constants::format_default) const;
+
+#include <iostream>
+
+#include <regex>
+#include <cassert>
+
+#include "test_allocator.h"
+
+int main()
+{
+ typedef std::basic_string<char, std::char_traits<char>, test_allocator<char> > nstr;
+ typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, test_allocator<wchar_t> > wstr;
+ {
+ std::match_results<const char*> m;
+ const char s[] = "abcdefghijk";
+ assert(std::regex_search(s, m, std::regex("cd((e)fg)hi")));
+
+ nstr fmt("prefix: $`, match: $&, suffix: $', m[1]: $1, m[2]: $2");
+ nstr out = m.format(fmt);
+ assert(out == "prefix: ab, match: cdefghi, suffix: jk, m[1]: efg, m[2]: e");
+ }
+ {
+ std::match_results<const char*> m;
+ const char s[] = "abcdefghijk";
+ assert(std::regex_search(s, m, std::regex("cd((e)fg)hi")));
+
+ nstr fmt("prefix: $`, match: $&, suffix: $', m[1]: $1, m[2]: $2");
+ nstr out = m.format(fmt, std::regex_constants::format_sed);
+ assert(out == "prefix: $`, match: $cdefghi, suffix: $', m[1]: $1, m[2]: $2");
+ }
+ {
+ std::match_results<const char*> m;
+ const char s[] = "abcdefghijk";
+ assert(std::regex_search(s, m, std::regex("cd((e)fg)hi")));
+
+ nstr fmt("match: &, m[1]: \\1, m[2]: \\2");
+ nstr out = m.format(fmt, std::regex_constants::format_sed);
+ assert(out == "match: cdefghi, m[1]: efg, m[2]: e");
+ }
+
+ {
+ std::match_results<const wchar_t*> m;
+ const wchar_t s[] = L"abcdefghijk";
+ assert(std::regex_search(s, m, std::wregex(L"cd((e)fg)hi")));
+
+ wstr fmt(L"prefix: $`, match: $&, suffix: $', m[1]: $1, m[2]: $2");
+ wstr out = m.format(fmt);
+ assert(out == L"prefix: ab, match: cdefghi, suffix: jk, m[1]: efg, m[2]: e");
+ }
+ {
+ std::match_results<const wchar_t*> m;
+ const wchar_t s[] = L"abcdefghijk";
+ assert(std::regex_search(s, m, std::wregex(L"cd((e)fg)hi")));
+
+ wstr fmt(L"prefix: $`, match: $&, suffix: $', m[1]: $1, m[2]: $2");
+ wstr out = m.format(fmt, std::regex_constants::format_sed);
+ assert(out == L"prefix: $`, match: $cdefghi, suffix: $', m[1]: $1, m[2]: $2");
+ }
+ {
+ std::match_results<const wchar_t*> m;
+ const wchar_t s[] = L"abcdefghijk";
+ assert(std::regex_search(s, m, std::wregex(L"cd((e)fg)hi")));
+
+ wstr fmt(L"match: &, m[1]: \\1, m[2]: \\2");
+ wstr out = m.format(fmt, std::regex_constants::format_sed);
+ assert(out == L"match: cdefghi, m[1]: efg, m[2]: e");
+ }
+}
diff --git a/test/std/re/re.results/re.results.form/form4.pass.cpp b/test/std/re/re.results/re.results.form/form4.pass.cpp
new file mode 100644
index 000000000000..1d44c32f6a8b
--- /dev/null
+++ b/test/std/re/re.results/re.results.form/form4.pass.cpp
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class match_results<BidirectionalIterator, Allocator>
+
+// string_type
+// format(const char_type* fmt,
+// regex_constants::match_flag_type flags = regex_constants::format_default) const;
+
+#include <iostream>
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ std::match_results<const char*> m;
+ const char s[] = "abcdefghijk";
+ assert(std::regex_search(s, m, std::regex("cd((e)fg)hi")));
+
+ const char fmt[] = "prefix: $`, match: $&, suffix: $', m[1]: $1, m[2]: $2";
+ std::string out = m.format(fmt);
+ assert(out == "prefix: ab, match: cdefghi, suffix: jk, m[1]: efg, m[2]: e");
+ }
+ {
+ std::match_results<const char*> m;
+ const char s[] = "abcdefghijk";
+ assert(std::regex_search(s, m, std::regex("cd((e)fg)hi")));
+
+ const char fmt[] = "prefix: $`, match: $&, suffix: $', m[1]: $1, m[2]: $2";
+ std::string out = m.format(fmt, std::regex_constants::format_sed);
+ assert(out == "prefix: $`, match: $cdefghi, suffix: $', m[1]: $1, m[2]: $2");
+ }
+ {
+ std::match_results<const char*> m;
+ const char s[] = "abcdefghijk";
+ assert(std::regex_search(s, m, std::regex("cd((e)fg)hi")));
+
+ const char fmt[] = "match: &, m[1]: \\1, m[2]: \\2";
+ std::string out = m.format(fmt, std::regex_constants::format_sed);
+ assert(out == "match: cdefghi, m[1]: efg, m[2]: e");
+ }
+
+ {
+ std::match_results<const wchar_t*> m;
+ const wchar_t s[] = L"abcdefghijk";
+ assert(std::regex_search(s, m, std::wregex(L"cd((e)fg)hi")));
+
+ const wchar_t fmt[] = L"prefix: $`, match: $&, suffix: $', m[1]: $1, m[2]: $2";
+ std::wstring out = m.format(fmt);
+ assert(out == L"prefix: ab, match: cdefghi, suffix: jk, m[1]: efg, m[2]: e");
+ }
+ {
+ std::match_results<const wchar_t*> m;
+ const wchar_t s[] = L"abcdefghijk";
+ assert(std::regex_search(s, m, std::wregex(L"cd((e)fg)hi")));
+
+ const wchar_t fmt[] = L"prefix: $`, match: $&, suffix: $', m[1]: $1, m[2]: $2";
+ std::wstring out = m.format(fmt, std::regex_constants::format_sed);
+ assert(out == L"prefix: $`, match: $cdefghi, suffix: $', m[1]: $1, m[2]: $2");
+ }
+ {
+ std::match_results<const wchar_t*> m;
+ const wchar_t s[] = L"abcdefghijk";
+ assert(std::regex_search(s, m, std::wregex(L"cd((e)fg)hi")));
+
+ const wchar_t fmt[] = L"match: &, m[1]: \\1, m[2]: \\2";
+ std::wstring out = m.format(fmt, std::regex_constants::format_sed);
+ assert(out == L"match: cdefghi, m[1]: efg, m[2]: e");
+ }
+}
diff --git a/test/std/re/re.results/re.results.nonmember/equal.pass.cpp b/test/std/re/re.results/re.results.nonmember/equal.pass.cpp
new file mode 100644
index 000000000000..7902b8e642e4
--- /dev/null
+++ b/test/std/re/re.results/re.results.nonmember/equal.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class match_results<BidirectionalIterator, Allocator>
+
+// template <class BidirectionalIterator, class Allocator>
+// bool
+// operator==(const match_results<BidirectionalIterator, Allocator>& m1,
+// const match_results<BidirectionalIterator, Allocator>& m2);
+
+// template <class BidirectionalIterator, class Allocator>
+// bool
+// operator!=(const match_results<BidirectionalIterator, Allocator>& m1,
+// const match_results<BidirectionalIterator, Allocator>& m2);
+
+#include <regex>
+#include <cassert>
+
+void
+test()
+{
+ std::match_results<const char*> m1;
+ const char s[] = "abcdefghijk";
+ assert(std::regex_search(s, m1, std::regex("cd((e)fg)hi")));
+ std::match_results<const char*> m2;
+
+ assert(m1 == m1);
+ assert(m1 != m2);
+
+ m2 = m1;
+
+ assert(m1 == m2);
+}
+
+int main()
+{
+ test();
+}
diff --git a/test/std/re/re.results/re.results.size/empty.pass.cpp b/test/std/re/re.results/re.results.size/empty.pass.cpp
new file mode 100644
index 000000000000..6634d92830dc
--- /dev/null
+++ b/test/std/re/re.results/re.results.size/empty.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class match_results<BidirectionalIterator, Allocator>
+
+// size_type size() const;
+// bool empty() const;
+
+#include <regex>
+#include <cassert>
+
+template <class CharT>
+void
+test()
+{
+ std::match_results<const CharT*> m;
+ assert(m.empty());
+ assert(m.size() == 0);
+ const char s[] = "abcdefghijk";
+ assert(std::regex_search(s, m, std::regex("cd((e)fg)hi")));
+ assert(!m.empty());
+ assert(m.size() == 3);
+}
+
+int main()
+{
+ test<char>();
+}
diff --git a/test/std/re/re.results/re.results.size/max_size.pass.cpp b/test/std/re/re.results/re.results.size/max_size.pass.cpp
new file mode 100644
index 000000000000..0b31409275bf
--- /dev/null
+++ b/test/std/re/re.results/re.results.size/max_size.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class match_results<BidirectionalIterator, Allocator>
+
+// size_type max_size() const;
+
+#include <regex>
+#include <cassert>
+
+template <class CharT>
+void
+test()
+{
+ std::match_results<const CharT*> m;
+ assert(m.max_size() > 0);
+}
+
+int main()
+{
+ test<char>();
+ test<wchar_t>();
+}
diff --git a/test/std/re/re.results/re.results.state/ready.pass.cpp b/test/std/re/re.results/re.results.state/ready.pass.cpp
new file mode 100644
index 000000000000..8f586c3f32d6
--- /dev/null
+++ b/test/std/re/re.results/re.results.state/ready.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class match_results<BidirectionalIterator, Allocator>
+
+// bool ready() const;
+
+#include <regex>
+#include <cassert>
+
+void
+test1()
+{
+ std::match_results<const char*> m;
+ const char s[] = "abcdefghijk";
+ assert(m.ready() == false);
+ std::regex_search(s, m, std::regex("cd((e)fg)hi"));
+ assert(m.ready() == true);
+}
+
+void
+test2()
+{
+ std::match_results<const char*> m;
+ const char s[] = "abcdefghijk";
+ assert(m.ready() == false);
+ std::regex_search(s, m, std::regex("z"));
+ assert(m.ready() == true);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
diff --git a/test/std/re/re.results/re.results.swap/member_swap.pass.cpp b/test/std/re/re.results/re.results.swap/member_swap.pass.cpp
new file mode 100644
index 000000000000..09b85c0ff5d2
--- /dev/null
+++ b/test/std/re/re.results/re.results.swap/member_swap.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class match_results<BidirectionalIterator, Allocator>
+
+// void swap(match_results& that);
+
+#include <regex>
+#include <cassert>
+
+void
+test()
+{
+ std::match_results<const char*> m1;
+ const char s[] = "abcdefghijk";
+ assert(std::regex_search(s, m1, std::regex("cd((e)fg)hi")));
+ std::match_results<const char*> m2;
+
+ std::match_results<const char*> m1_save = m1;
+ std::match_results<const char*> m2_save = m2;
+
+ m1.swap(m2);
+
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+}
+
+int main()
+{
+ test();
+}
diff --git a/test/std/re/re.results/re.results.swap/non_member_swap.pass.cpp b/test/std/re/re.results/re.results.swap/non_member_swap.pass.cpp
new file mode 100644
index 000000000000..3f5e34df44c5
--- /dev/null
+++ b/test/std/re/re.results/re.results.swap/non_member_swap.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class match_results<BidirectionalIterator, Allocator>
+
+// template <class BidirectionalIterator, class Allocator>
+// void swap(match_results<BidirectionalIterator, Allocator>& m1,
+// match_results<BidirectionalIterator, Allocator>& m2);
+
+#include <regex>
+#include <cassert>
+
+void
+test()
+{
+ std::match_results<const char*> m1;
+ const char s[] = "abcdefghijk";
+ assert(std::regex_search(s, m1, std::regex("cd((e)fg)hi")));
+ std::match_results<const char*> m2;
+
+ std::match_results<const char*> m1_save = m1;
+ std::match_results<const char*> m2_save = m2;
+
+ swap(m1, m2);
+
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+}
+
+int main()
+{
+ test();
+}
diff --git a/test/std/re/re.results/types.pass.cpp b/test/std/re/re.results/types.pass.cpp
new file mode 100644
index 000000000000..4d553837efe8
--- /dev/null
+++ b/test/std/re/re.results/types.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class BidirectionalIterator,
+// class Allocator = allocator<sub_match<BidirectionalIterator>>>
+// class match_results
+// {
+// public:
+// typedef sub_match<BidirectionalIterator> value_type;
+// typedef const value_type& const_reference;
+// typedef const_reference reference;
+// typedef /implementation-defined/ const_iterator;
+// typedef const_iterator iterator;
+// typedef typename iterator_traits<BidirectionalIterator>::difference_type difference_type;
+// typedef typename allocator_traits<Allocator>::size_type size_type;
+// typedef Allocator allocator_type;
+// typedef typename iterator_traits<BidirectionalIterator>::value_type char_type;
+// typedef basic_string<char_type> string_type;
+
+#include <regex>
+#include <type_traits>
+
+template <class CharT>
+void
+test()
+{
+ typedef std::match_results<CharT*> MR;
+ static_assert((std::is_same<typename MR::value_type, std::sub_match<CharT*> >::value), "");
+ static_assert((std::is_same<typename MR::const_reference, const std::sub_match<CharT*>& >::value), "");
+ static_assert((std::is_same<typename MR::reference, std::sub_match<CharT*>& >::value), "");
+ static_assert((!std::is_same<typename MR::const_iterator, void>::value), "");
+ static_assert((std::is_same<typename MR::difference_type, std::ptrdiff_t>::value), "");
+ static_assert((std::is_same<typename MR::size_type, std::size_t>::value), "");
+ static_assert((std::is_same<typename MR::allocator_type, std::allocator<std::sub_match<CharT*> > >::value), "");
+ static_assert((std::is_same<typename MR::char_type, CharT>::value), "");
+ static_assert((std::is_same<typename MR::string_type, std::basic_string<CharT> >::value), "");
+}
+
+int main()
+{
+ test<char>();
+ test<wchar_t>();
+}
diff --git a/test/std/re/re.submatch/re.submatch.members/compare_string_type.pass.cpp b/test/std/re/re.submatch/re.submatch.members/compare_string_type.pass.cpp
new file mode 100644
index 000000000000..c14d5bcdefae
--- /dev/null
+++ b/test/std/re/re.submatch/re.submatch.members/compare_string_type.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class BidirectionalIterator> class sub_match;
+
+// int compare(const string_type& s) const;
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef char CharT;
+ typedef std::sub_match<const CharT*> SM;
+ typedef SM::string_type string;
+ SM sm = SM();
+ SM sm2 = SM();
+ assert(sm.compare(string()) == 0);
+ const CharT s[] = {'1', '2', '3', 0};
+ sm.first = s;
+ sm.second = s + 3;
+ sm.matched = true;
+ assert(sm.compare(string()) > 0);
+ assert(sm.compare(string("123")) == 0);
+ }
+ {
+ typedef wchar_t CharT;
+ typedef std::sub_match<const CharT*> SM;
+ typedef SM::string_type string;
+ SM sm = SM();
+ SM sm2 = SM();
+ assert(sm.compare(string()) == 0);
+ const CharT s[] = {'1', '2', '3', 0};
+ sm.first = s;
+ sm.second = s + 3;
+ sm.matched = true;
+ assert(sm.compare(string()) > 0);
+ assert(sm.compare(string(L"123")) == 0);
+ }
+}
diff --git a/test/std/re/re.submatch/re.submatch.members/compare_sub_match.pass.cpp b/test/std/re/re.submatch/re.submatch.members/compare_sub_match.pass.cpp
new file mode 100644
index 000000000000..0874742f1c9a
--- /dev/null
+++ b/test/std/re/re.submatch/re.submatch.members/compare_sub_match.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class BidirectionalIterator> class sub_match;
+
+// int compare(const sub_match& s) const;
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef char CharT;
+ typedef std::sub_match<const CharT*> SM;
+ SM sm = SM();
+ SM sm2 = SM();
+ assert(sm.compare(sm2) == 0);
+ const CharT s[] = {'1', '2', '3', 0};
+ sm.first = s;
+ sm.second = s + 3;
+ sm.matched = true;
+ assert(sm.compare(sm2) > 0);
+ sm2.first = s;
+ sm2.second = s + 3;
+ sm2.matched = true;
+ assert(sm.compare(sm2) == 0);
+ }
+ {
+ typedef wchar_t CharT;
+ typedef std::sub_match<const CharT*> SM;
+ SM sm = SM();
+ SM sm2 = SM();
+ assert(sm.compare(sm2) == 0);
+ const CharT s[] = {'1', '2', '3', 0};
+ sm.first = s;
+ sm.second = s + 3;
+ sm.matched = true;
+ assert(sm.compare(sm2) > 0);
+ sm2.first = s;
+ sm2.second = s + 3;
+ sm2.matched = true;
+ assert(sm.compare(sm2) == 0);
+ }
+}
diff --git a/test/std/re/re.submatch/re.submatch.members/compare_value_type_ptr.pass.cpp b/test/std/re/re.submatch/re.submatch.members/compare_value_type_ptr.pass.cpp
new file mode 100644
index 000000000000..48c05ca91d05
--- /dev/null
+++ b/test/std/re/re.submatch/re.submatch.members/compare_value_type_ptr.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class BidirectionalIterator> class sub_match;
+
+// int compare(const value_type* s) const;
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef char CharT;
+ typedef std::sub_match<const CharT*> SM;
+ SM sm = SM();
+ SM sm2 = SM();
+ assert(sm.compare("") == 0);
+ const CharT s[] = {'1', '2', '3', 0};
+ sm.first = s;
+ sm.second = s + 3;
+ sm.matched = true;
+ assert(sm.compare("") > 0);
+ assert(sm.compare("123") == 0);
+ }
+ {
+ typedef wchar_t CharT;
+ typedef std::sub_match<const CharT*> SM;
+ SM sm = SM();
+ SM sm2 = SM();
+ assert(sm.compare(L"") == 0);
+ const CharT s[] = {'1', '2', '3', 0};
+ sm.first = s;
+ sm.second = s + 3;
+ sm.matched = true;
+ assert(sm.compare(L"") > 0);
+ assert(sm.compare(L"123") == 0);
+ }
+}
diff --git a/test/std/re/re.submatch/re.submatch.members/default.pass.cpp b/test/std/re/re.submatch/re.submatch.members/default.pass.cpp
new file mode 100644
index 000000000000..451466af83cd
--- /dev/null
+++ b/test/std/re/re.submatch/re.submatch.members/default.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class BidirectionalIterator> class sub_match;
+
+// constexpr sub_match();
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef char CharT;
+ typedef std::sub_match<const CharT*> SM;
+ SM sm;
+ assert(sm.matched == false);
+ }
+ {
+ typedef wchar_t CharT;
+ typedef std::sub_match<const CharT*> SM;
+ SM sm;
+ assert(sm.matched == false);
+ }
+}
diff --git a/test/std/re/re.submatch/re.submatch.members/length.pass.cpp b/test/std/re/re.submatch/re.submatch.members/length.pass.cpp
new file mode 100644
index 000000000000..4874c0d05921
--- /dev/null
+++ b/test/std/re/re.submatch/re.submatch.members/length.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class BidirectionalIterator> class sub_match;
+
+// difference_type length() const;
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef char CharT;
+ typedef std::sub_match<const CharT*> SM;
+ SM sm = SM();
+ assert(sm.length() == 0);
+ const CharT s[] = {'1', '2', '3', 0};
+ sm.first = s;
+ sm.second = s + 3;
+ sm.matched = true;
+ assert(sm.length() == 3);
+ }
+ {
+ typedef wchar_t CharT;
+ typedef std::sub_match<const CharT*> SM;
+ SM sm = SM();
+ assert(sm.length() == 0);
+ const CharT s[] = {'1', '2', '3', 0};
+ sm.first = s;
+ sm.second = s + 3;
+ sm.matched = true;
+ assert(sm.length() == 3);
+ }
+}
diff --git a/test/std/re/re.submatch/re.submatch.members/operator_string.pass.cpp b/test/std/re/re.submatch/re.submatch.members/operator_string.pass.cpp
new file mode 100644
index 000000000000..dd856a56d0b0
--- /dev/null
+++ b/test/std/re/re.submatch/re.submatch.members/operator_string.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class BidirectionalIterator> class sub_match;
+
+// operator string_type() const;
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef char CharT;
+ typedef std::sub_match<const CharT*> SM;
+ SM sm = SM();
+ SM::string_type str = sm;
+ assert(str.empty());
+ const CharT s[] = {'1', '2', '3', 0};
+ sm.first = s;
+ sm.second = s + 3;
+ sm.matched = true;
+ str = sm;
+ assert(str == std::string("123"));
+ }
+ {
+ typedef wchar_t CharT;
+ typedef std::sub_match<const CharT*> SM;
+ SM sm = SM();
+ SM::string_type str = sm;
+ assert(str.empty());
+ const CharT s[] = {'1', '2', '3', 0};
+ sm.first = s;
+ sm.second = s + 3;
+ sm.matched = true;
+ str = sm;
+ assert(str == std::wstring(L"123"));
+ }
+}
diff --git a/test/std/re/re.submatch/re.submatch.members/str.pass.cpp b/test/std/re/re.submatch/re.submatch.members/str.pass.cpp
new file mode 100644
index 000000000000..ca5fd7d78ac7
--- /dev/null
+++ b/test/std/re/re.submatch/re.submatch.members/str.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class BidirectionalIterator> class sub_match;
+
+// string_type str() const;
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef char CharT;
+ typedef std::sub_match<const CharT*> SM;
+ SM sm = SM();
+ SM::string_type str = sm.str();
+ assert(str.empty());
+ const CharT s[] = {'1', '2', '3', 0};
+ sm.first = s;
+ sm.second = s + 3;
+ sm.matched = true;
+ str = sm.str();
+ assert(str == std::string("123"));
+ }
+ {
+ typedef wchar_t CharT;
+ typedef std::sub_match<const CharT*> SM;
+ SM sm = SM();
+ SM::string_type str = sm.str();
+ assert(str.empty());
+ const CharT s[] = {'1', '2', '3', 0};
+ sm.first = s;
+ sm.second = s + 3;
+ sm.matched = true;
+ str = sm.str();
+ assert(str == std::wstring(L"123"));
+ }
+}
diff --git a/test/std/re/re.submatch/re.submatch.op/compare.pass.cpp b/test/std/re/re.submatch/re.submatch.op/compare.pass.cpp
new file mode 100644
index 000000000000..36376aa0563c
--- /dev/null
+++ b/test/std/re/re.submatch/re.submatch.op/compare.pass.cpp
@@ -0,0 +1,287 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class BidirectionalIterator> class sub_match;
+
+// template <class BiIter>
+// bool
+// operator==(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
+//
+// template <class BiIter>
+// bool
+// operator!=(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
+//
+// template <class BiIter>
+// bool
+// operator<(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
+//
+// template <class BiIter>
+// bool
+// operator<=(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
+//
+// template <class BiIter>
+// bool
+// operator>=(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
+//
+// template <class BiIter>
+// bool
+// operator>(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
+//
+// template <class BiIter, class ST, class SA>
+// bool
+// operator==(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs,
+// const sub_match<BiIter>& rhs);
+//
+// template <class BiIter, class ST, class SA>
+// bool
+// operator!=(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs,
+// const sub_match<BiIter>& rhs);
+//
+// template <class BiIter, class ST, class SA>
+// bool
+// operator<(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs,
+// const sub_match<BiIter>& rhs);
+//
+// template <class BiIter, class ST, class SA>
+// bool
+// operator>(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs,
+// const sub_match<BiIter>& rhs);
+//
+// template <class BiIter, class ST, class SA>
+// bool operator>=(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs,
+// const sub_match<BiIter>& rhs);
+//
+// template <class BiIter, class ST, class SA>
+// bool
+// operator<=(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs,
+// const sub_match<BiIter>& rhs);
+//
+// template <class BiIter, class ST, class SA>
+// bool
+// operator==(const sub_match<BiIter>& lhs,
+// const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);
+//
+// template <class BiIter, class ST, class SA>
+// bool
+// operator!=(const sub_match<BiIter>& lhs,
+// const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);
+//
+// template <class BiIter, class ST, class SA>
+// bool
+// operator<(const sub_match<BiIter>& lhs,
+// const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);
+//
+// template <class BiIter, class ST, class SA>
+// bool operator>(const sub_match<BiIter>& lhs,
+// const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);
+//
+// template <class BiIter, class ST, class SA>
+// bool
+// operator>=(const sub_match<BiIter>& lhs,
+// const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);
+//
+// template <class BiIter, class ST, class SA>
+// bool
+// operator<=(const sub_match<BiIter>& lhs,
+// const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);
+//
+// template <class BiIter>
+// bool
+// operator==(typename iterator_traits<BiIter>::value_type const* lhs,
+// const sub_match<BiIter>& rhs);
+//
+// template <class BiIter>
+// bool
+// operator!=(typename iterator_traits<BiIter>::value_type const* lhs,
+// const sub_match<BiIter>& rhs);
+//
+// template <class BiIter>
+// bool
+// operator<(typename iterator_traits<BiIter>::value_type const* lhs,
+// const sub_match<BiIter>& rhs);
+//
+// template <class BiIter>
+// bool
+// operator>(typename iterator_traits<BiIter>::value_type const* lhs,
+// const sub_match<BiIter>& rhs);
+//
+// template <class BiIter>
+// bool
+// operator>=(typename iterator_traits<BiIter>::value_type const* lhs,
+// const sub_match<BiIter>& rhs);
+//
+// template <class BiIter>
+// bool
+// operator<=(typename iterator_traits<BiIter>::value_type const* lhs,
+// const sub_match<BiIter>& rhs);
+//
+// template <class BiIter>
+// bool
+// operator==(const sub_match<BiIter>& lhs,
+// typename iterator_traits<BiIter>::value_type const* rhs);
+//
+// template <class BiIter>
+// bool
+// operator!=(const sub_match<BiIter>& lhs,
+// typename iterator_traits<BiIter>::value_type const* rhs);
+//
+// template <class BiIter>
+// bool
+// operator<(const sub_match<BiIter>& lhs,
+// typename iterator_traits<BiIter>::value_type const* rhs);
+//
+// template <class BiIter>
+// bool
+// operator>(const sub_match<BiIter>& lhs,
+// typename iterator_traits<BiIter>::value_type const* rhs);
+//
+// template <class BiIter>
+// bool
+// operator>=(const sub_match<BiIter>& lhs,
+// typename iterator_traits<BiIter>::value_type const* rhs);
+//
+// template <class BiIter>
+// bool
+// operator<=(const sub_match<BiIter>& lhs,
+// typename iterator_traits<BiIter>::value_type const* rhs);
+//
+// template <class BiIter>
+// bool
+// operator==(typename iterator_traits<BiIter>::value_type const& lhs,
+// const sub_match<BiIter>& rhs);
+//
+// template <class BiIter>
+// bool
+// operator!=(typename iterator_traits<BiIter>::value_type const& lhs,
+// const sub_match<BiIter>& rhs);
+//
+// template <class BiIter>
+// bool
+// operator<(typename iterator_traits<BiIter>::value_type const& lhs,
+// const sub_match<BiIter>& rhs);
+//
+// template <class BiIter>
+// bool
+// operator>(typename iterator_traits<BiIter>::value_type const& lhs,
+// const sub_match<BiIter>& rhs);
+//
+// template <class BiIter>
+// bool
+// operator>=(typename iterator_traits<BiIter>::value_type const& lhs,
+// const sub_match<BiIter>& rhs);
+//
+// template <class BiIter>
+// bool
+// operator<=(typename iterator_traits<BiIter>::value_type const& lhs,
+// const sub_match<BiIter>& rhs);
+//
+// template <class BiIter>
+// bool
+// operator==(const sub_match<BiIter>& lhs,
+// typename iterator_traits<BiIter>::value_type const& rhs);
+//
+// template <class BiIter>
+// bool
+// operator!=(const sub_match<BiIter>& lhs,
+// typename iterator_traits<BiIter>::value_type const& rhs);
+//
+// template <class BiIter>
+// bool
+// operator<(const sub_match<BiIter>& lhs,
+// typename iterator_traits<BiIter>::value_type const& rhs);
+//
+// template <class BiIter>
+// bool
+// operator>(const sub_match<BiIter>& lhs,
+// typename iterator_traits<BiIter>::value_type const& rhs);
+//
+// template <class BiIter>
+// bool
+// operator>=(const sub_match<BiIter>& lhs,
+// typename iterator_traits<BiIter>::value_type const& rhs);
+//
+// template <class BiIter>
+// bool
+// operator<=(const sub_match<BiIter>& lhs,
+// typename iterator_traits<BiIter>::value_type const& rhs);
+
+#include <regex>
+#include <cassert>
+
+template <class CharT>
+void
+test(const std::basic_string<CharT>& x, const std::basic_string<CharT>& y, bool doCStrTests = true)
+{
+ typedef std::basic_string<CharT> string;
+ typedef std::sub_match<typename string::const_iterator> sub_match;
+ sub_match sm1;
+ sm1.first = x.begin();
+ sm1.second = x.end();
+ sm1.matched = true;
+ sub_match sm2;
+ sm2.first = y.begin();
+ sm2.second = y.end();
+ sm2.matched = true;
+ assert((sm1 == sm2) == (x == y));
+ assert((sm1 != sm2) == (x != y));
+ assert((sm1 < sm2) == (x < y));
+ assert((sm1 > sm2) == (x > y));
+ assert((sm1 <= sm2) == (x <= y));
+ assert((sm1 >= sm2) == (x >= y));
+ assert((x == sm2) == (x == y));
+ assert((x != sm2) == (x != y));
+ assert((x < sm2) == (x < y));
+ assert((x > sm2) == (x > y));
+ assert((x <= sm2) == (x <= y));
+ assert((x >= sm2) == (x >= y));
+ assert((sm1 == y) == (x == y));
+ assert((sm1 != y) == (x != y));
+ assert((sm1 < y) == (x < y));
+ assert((sm1 > y) == (x > y));
+ assert((sm1 <= y) == (x <= y));
+ assert((sm1 >= y) == (x >= y));
+ if (doCStrTests) {
+ assert((x.c_str() == sm2) == (x == y));
+ assert((x.c_str() != sm2) == (x != y));
+ assert((x.c_str() < sm2) == (x < y));
+ assert((x.c_str() > sm2) == (x > y));
+ assert((x.c_str() <= sm2) == (x <= y));
+ assert((x.c_str() >= sm2) == (x >= y));
+ assert((sm1 == y.c_str()) == (x == y));
+ assert((sm1 != y.c_str()) == (x != y));
+ assert((sm1 < y.c_str()) == (x < y));
+ assert((sm1 > y.c_str()) == (x > y));
+ assert((sm1 <= y.c_str()) == (x <= y));
+ assert((sm1 >= y.c_str()) == (x >= y));
+ }
+ assert((x[0] == sm2) == (string(1, x[0]) == y));
+ assert((x[0] != sm2) == (string(1, x[0]) != y));
+ assert((x[0] < sm2) == (string(1, x[0]) < y));
+ assert((x[0] > sm2) == (string(1, x[0]) > y));
+ assert((x[0] <= sm2) == (string(1, x[0]) <= y));
+ assert((x[0] >= sm2) == (string(1, x[0]) >= y));
+ assert((sm1 == y[0]) == (x == string(1, y[0])));
+ assert((sm1 != y[0]) == (x != string(1, y[0])));
+ assert((sm1 < y[0]) == (x < string(1, y[0])));
+ assert((sm1 > y[0]) == (x > string(1, y[0])));
+ assert((sm1 <= y[0]) == (x <= string(1, y[0])));
+ assert((sm1 >= y[0]) == (x >= string(1, y[0])));
+}
+
+int main()
+{
+ test(std::string("123"), std::string("123"));
+ test(std::string("1234"), std::string("123"));
+ test(std::wstring(L"123"), std::wstring(L"123"));
+ test(std::wstring(L"1234"), std::wstring(L"123"));
+ test(std::string("123\00056", 6), std::string("123\00056", 6), false);
+ test(std::wstring(L"123\00056", 6), std::wstring(L"123\00056", 6), false);
+}
diff --git a/test/std/re/re.submatch/re.submatch.op/stream.pass.cpp b/test/std/re/re.submatch/re.submatch.op/stream.pass.cpp
new file mode 100644
index 000000000000..050bb062e710
--- /dev/null
+++ b/test/std/re/re.submatch/re.submatch.op/stream.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class BidirectionalIterator> class sub_match;
+
+// template <class charT, class ST, class BiIter>
+// basic_ostream<charT, ST>&
+// operator<<(basic_ostream<charT, ST>& os, const sub_match<BiIter>& m);
+
+#include <regex>
+#include <sstream>
+#include <cassert>
+
+template <class CharT>
+void
+test(const std::basic_string<CharT>& s)
+{
+ typedef std::basic_string<CharT> string;
+ typedef std::sub_match<typename string::const_iterator> SM;
+ typedef std::basic_ostringstream<CharT> ostringstream;
+ SM sm;
+ sm.first = s.begin();
+ sm.second = s.end();
+ sm.matched = true;
+ ostringstream os;
+ os << sm;
+ assert(os.str() == s);
+}
+
+int main()
+{
+ test(std::string("123"));
+ test(std::wstring(L"123"));
+}
diff --git a/test/std/re/re.submatch/types.pass.cpp b/test/std/re/re.submatch/types.pass.cpp
new file mode 100644
index 000000000000..47c79149a8d3
--- /dev/null
+++ b/test/std/re/re.submatch/types.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class BidirectionalIterator>
+// class sub_match
+// : public pair<BidirectionalIterator, BidirectionalIterator>
+// {
+// public:
+// typedef BidirectionalIterator iterator;
+// typedef typename iterator_traits<iterator>::value_type value_type;
+// typedef typename iterator_traits<iterator>::difference_type difference_type;
+// typedef basic_string<value_type> string_type;
+//
+// bool matched;
+// ...
+// };
+
+#include <regex>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::sub_match<char*> SM;
+ static_assert((std::is_same<SM::iterator, char*>::value), "");
+ static_assert((std::is_same<SM::value_type, char>::value), "");
+ static_assert((std::is_same<SM::difference_type, std::ptrdiff_t>::value), "");
+ static_assert((std::is_same<SM::string_type, std::string>::value), "");
+ static_assert((std::is_convertible<SM*, std::pair<char*, char*>*>::value), "");
+
+ SM sm;
+ sm.first = nullptr;
+ sm.second = nullptr;
+ sm.matched = false;
+ }
+ {
+ typedef std::sub_match<wchar_t*> SM;
+ static_assert((std::is_same<SM::iterator, wchar_t*>::value), "");
+ static_assert((std::is_same<SM::value_type, wchar_t>::value), "");
+ static_assert((std::is_same<SM::difference_type, std::ptrdiff_t>::value), "");
+ static_assert((std::is_same<SM::string_type, std::wstring>::value), "");
+ static_assert((std::is_convertible<SM*, std::pair<wchar_t*, wchar_t*>*>::value), "");
+
+ SM sm;
+ sm.first = nullptr;
+ sm.second = nullptr;
+ sm.matched = false;
+ }
+ {
+ static_assert((std::is_same<std::csub_match, std::sub_match<const char*> >::value), "");
+ static_assert((std::is_same<std::wcsub_match, std::sub_match<const wchar_t*> >::value), "");
+ static_assert((std::is_same<std::ssub_match, std::sub_match<std::string::const_iterator> >::value), "");
+ static_assert((std::is_same<std::wssub_match, std::sub_match<std::wstring::const_iterator> >::value), "");
+ }
+}
diff --git a/test/std/re/re.syn/cmatch.pass.cpp b/test/std/re/re.syn/cmatch.pass.cpp
new file mode 100644
index 000000000000..1364b7873ea5
--- /dev/null
+++ b/test/std/re/re.syn/cmatch.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// typedef match_results<const char*> cmatch;
+
+#include <regex>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_same<std::match_results<const char*>, std::cmatch>::value), "");
+}
diff --git a/test/std/re/re.syn/cregex_iterator.pass.cpp b/test/std/re/re.syn/cregex_iterator.pass.cpp
new file mode 100644
index 000000000000..7b6ac133f5ac
--- /dev/null
+++ b/test/std/re/re.syn/cregex_iterator.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// typedef regex_iterator<const char*> cregex_iterator;
+
+#include <regex>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_same<std::regex_iterator<const char*>, std::cregex_iterator>::value), "");
+}
diff --git a/test/std/re/re.syn/cregex_token_iterator.pass.cpp b/test/std/re/re.syn/cregex_token_iterator.pass.cpp
new file mode 100644
index 000000000000..36ee9b66ea9d
--- /dev/null
+++ b/test/std/re/re.syn/cregex_token_iterator.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// typedef regex_token_iterator<const char*> cregex_token_iterator;
+
+#include <regex>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_same<std::regex_token_iterator<const char*>, std::cregex_token_iterator>::value), "");
+}
diff --git a/test/std/re/re.syn/csub_match.pass.cpp b/test/std/re/re.syn/csub_match.pass.cpp
new file mode 100644
index 000000000000..e0de67b4feb7
--- /dev/null
+++ b/test/std/re/re.syn/csub_match.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// typedef sub_match<const char*> csub_match;
+
+#include <regex>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_same<std::sub_match<const char*>, std::csub_match>::value), "");
+}
diff --git a/test/std/re/re.syn/regex.pass.cpp b/test/std/re/re.syn/regex.pass.cpp
new file mode 100644
index 000000000000..a208442b966c
--- /dev/null
+++ b/test/std/re/re.syn/regex.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// typedef basic_regex<char> regex;
+
+#include <regex>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_same<std::basic_regex<char>, std::regex>::value), "");
+}
diff --git a/test/std/re/re.syn/smatch.pass.cpp b/test/std/re/re.syn/smatch.pass.cpp
new file mode 100644
index 000000000000..87323538968e
--- /dev/null
+++ b/test/std/re/re.syn/smatch.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// typedef match_results<string::const_iterator> smatch;
+
+#include <regex>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_same<std::match_results<std::string::const_iterator>, std::smatch>::value), "");
+}
diff --git a/test/std/re/re.syn/sregex_iterator.pass.cpp b/test/std/re/re.syn/sregex_iterator.pass.cpp
new file mode 100644
index 000000000000..7acd96194b0e
--- /dev/null
+++ b/test/std/re/re.syn/sregex_iterator.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// typedef regex_iterator<string::const_iterator> sregex_iterator;
+
+#include <regex>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_same<std::regex_iterator<std::string::const_iterator>, std::sregex_iterator>::value), "");
+}
diff --git a/test/std/re/re.syn/sregex_token_iterator.pass.cpp b/test/std/re/re.syn/sregex_token_iterator.pass.cpp
new file mode 100644
index 000000000000..185fd627b4fb
--- /dev/null
+++ b/test/std/re/re.syn/sregex_token_iterator.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// typedef regex_token_iterator<string::const_iterator> sregex_token_iterator;
+
+#include <regex>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_same<std::regex_token_iterator<std::string::const_iterator>, std::sregex_token_iterator>::value), "");
+}
diff --git a/test/std/re/re.syn/ssub_match.pass.cpp b/test/std/re/re.syn/ssub_match.pass.cpp
new file mode 100644
index 000000000000..b378339664c0
--- /dev/null
+++ b/test/std/re/re.syn/ssub_match.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// typedef sub_match<string::const_iterator> ssub_match;
+
+#include <regex>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_same<std::sub_match<std::string::const_iterator>, std::ssub_match>::value), "");
+}
diff --git a/test/std/re/re.syn/wcmatch.pass.cpp b/test/std/re/re.syn/wcmatch.pass.cpp
new file mode 100644
index 000000000000..3ca8ed51eabc
--- /dev/null
+++ b/test/std/re/re.syn/wcmatch.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// typedef match_results<const wchar_t*> wcmatch;
+
+#include <regex>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_same<std::match_results<const wchar_t*>, std::wcmatch>::value), "");
+}
diff --git a/test/std/re/re.syn/wcregex_iterator.pass.cpp b/test/std/re/re.syn/wcregex_iterator.pass.cpp
new file mode 100644
index 000000000000..99469ecf82b0
--- /dev/null
+++ b/test/std/re/re.syn/wcregex_iterator.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// typedef regex_iterator<const wchar_t*> wcregex_iterator;
+
+#include <regex>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_same<std::regex_iterator<const wchar_t*>, std::wcregex_iterator>::value), "");
+}
diff --git a/test/std/re/re.syn/wcregex_token_iterator.pass.cpp b/test/std/re/re.syn/wcregex_token_iterator.pass.cpp
new file mode 100644
index 000000000000..f16911f2985a
--- /dev/null
+++ b/test/std/re/re.syn/wcregex_token_iterator.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// typedef regex_token_iterator<const wchar_t*> wcregex_token_iterator;
+
+#include <regex>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_same<std::regex_token_iterator<const wchar_t*>, std::wcregex_token_iterator>::value), "");
+}
diff --git a/test/std/re/re.syn/wcsub_match.pass.cpp b/test/std/re/re.syn/wcsub_match.pass.cpp
new file mode 100644
index 000000000000..7e8c872b6033
--- /dev/null
+++ b/test/std/re/re.syn/wcsub_match.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// typedef sub_match<const wchar_t*> wcsub_match;
+
+#include <regex>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_same<std::sub_match<const wchar_t*>, std::wcsub_match>::value), "");
+}
diff --git a/test/std/re/re.syn/wregex.pass.cpp b/test/std/re/re.syn/wregex.pass.cpp
new file mode 100644
index 000000000000..635eac0176cc
--- /dev/null
+++ b/test/std/re/re.syn/wregex.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// typedef basic_regex<wchar_t> wregex;
+
+#include <regex>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_same<std::basic_regex<wchar_t>, std::wregex>::value), "");
+}
diff --git a/test/std/re/re.syn/wsmatch.pass.cpp b/test/std/re/re.syn/wsmatch.pass.cpp
new file mode 100644
index 000000000000..092c7d16d7a7
--- /dev/null
+++ b/test/std/re/re.syn/wsmatch.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// typedef match_results<wstring::const_iterator> wsmatch;
+
+#include <regex>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_same<std::match_results<std::wstring::const_iterator>, std::wsmatch>::value), "");
+}
diff --git a/test/std/re/re.syn/wsregex_iterator.pass.cpp b/test/std/re/re.syn/wsregex_iterator.pass.cpp
new file mode 100644
index 000000000000..0052716e46d8
--- /dev/null
+++ b/test/std/re/re.syn/wsregex_iterator.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// typedef regex_iterator<wstring::const_iterator> wsregex_iterator;
+
+#include <regex>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_same<std::regex_iterator<std::wstring::const_iterator>, std::wsregex_iterator>::value), "");
+}
diff --git a/test/std/re/re.syn/wsregex_token_iterator.pass.cpp b/test/std/re/re.syn/wsregex_token_iterator.pass.cpp
new file mode 100644
index 000000000000..dc71991eb9b1
--- /dev/null
+++ b/test/std/re/re.syn/wsregex_token_iterator.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator;
+
+#include <regex>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_same<std::regex_token_iterator<std::wstring::const_iterator>, std::wsregex_token_iterator>::value), "");
+}
diff --git a/test/std/re/re.syn/wssub_match.pass.cpp b/test/std/re/re.syn/wssub_match.pass.cpp
new file mode 100644
index 000000000000..2360a15513db
--- /dev/null
+++ b/test/std/re/re.syn/wssub_match.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// typedef sub_match<wstring::const_iterator> wssub_match;
+
+#include <regex>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_same<std::sub_match<std::wstring::const_iterator>, std::wssub_match>::value), "");
+}
diff --git a/test/std/re/re.traits/default.pass.cpp b/test/std/re/re.traits/default.pass.cpp
new file mode 100644
index 000000000000..c9a97e025ac5
--- /dev/null
+++ b/test/std/re/re.traits/default.pass.cpp
@@ -0,0 +1,37 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT> struct regex_traits;
+
+// regex_traits();
+
+#include <regex>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+int main()
+{
+ {
+ std::regex_traits<char> t1;
+ assert(t1.getloc().name() == "C");
+ std::regex_traits<wchar_t> t2;
+ assert(t2.getloc().name() == "C");
+ }
+ {
+ std::locale::global(std::locale(LOCALE_en_US_UTF_8));
+ std::regex_traits<char> t1;
+ assert(t1.getloc().name() == LOCALE_en_US_UTF_8);
+ std::regex_traits<wchar_t> t2;
+ assert(t2.getloc().name() == LOCALE_en_US_UTF_8);
+ }
+}
diff --git a/test/std/re/re.traits/getloc.pass.cpp b/test/std/re/re.traits/getloc.pass.cpp
new file mode 100644
index 000000000000..27ab6cd86545
--- /dev/null
+++ b/test/std/re/re.traits/getloc.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT> struct regex_traits;
+
+// locale_type getloc()const;
+
+#include <regex>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+int main()
+{
+ {
+ std::regex_traits<char> t1;
+ assert(t1.getloc().name() == "C");
+ std::regex_traits<wchar_t> t2;
+ assert(t2.getloc().name() == "C");
+ }
+ {
+ std::locale::global(std::locale(LOCALE_en_US_UTF_8));
+ std::regex_traits<char> t1;
+ assert(t1.getloc().name() == LOCALE_en_US_UTF_8);
+ std::regex_traits<wchar_t> t2;
+ assert(t2.getloc().name() == LOCALE_en_US_UTF_8);
+ }
+}
diff --git a/test/std/re/re.traits/imbue.pass.cpp b/test/std/re/re.traits/imbue.pass.cpp
new file mode 100644
index 000000000000..11eca41de37a
--- /dev/null
+++ b/test/std/re/re.traits/imbue.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT> struct regex_traits;
+
+// locale_type imbue(locale_type l);
+
+#include <regex>
+#include <locale>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+int main()
+{
+ {
+ std::regex_traits<char> t;
+ std::locale loc = t.imbue(std::locale(LOCALE_en_US_UTF_8));
+ assert(loc.name() == "C");
+ assert(t.getloc().name() == LOCALE_en_US_UTF_8);
+ }
+}
diff --git a/test/std/re/re.traits/isctype.pass.cpp b/test/std/re/re.traits/isctype.pass.cpp
new file mode 100644
index 000000000000..ad69f05ae75e
--- /dev/null
+++ b/test/std/re/re.traits/isctype.pass.cpp
@@ -0,0 +1,279 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT> struct regex_traits;
+
+// bool isctype(charT c, char_class_type f) const;
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ std::regex_traits<char> t;
+
+ std::string s("w");
+ assert( t.isctype('_', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype('a', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype('Z', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype('5', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(' ', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('-', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('@', t.lookup_classname(s.begin(), s.end())));
+
+ s = "alnum";
+ assert(!t.isctype('_', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype('a', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype('Z', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype('5', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(' ', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('-', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('@', t.lookup_classname(s.begin(), s.end())));
+
+ s = "alpha";
+ assert(!t.isctype('_', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype('a', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype('Z', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('5', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(' ', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('-', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('@', t.lookup_classname(s.begin(), s.end())));
+
+ s = "blank";
+ assert(!t.isctype('_', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('a', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('Z', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('5', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(' ', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('-', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('@', t.lookup_classname(s.begin(), s.end())));
+
+ s = "cntrl";
+ assert( t.isctype('\n', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('_', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('a', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('Z', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('5', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(' ', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('-', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('@', t.lookup_classname(s.begin(), s.end())));
+
+ s = "digit";
+ assert(!t.isctype('\n', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('_', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('a', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('Z', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype('5', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(' ', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('-', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('@', t.lookup_classname(s.begin(), s.end())));
+
+ s = "graph";
+ assert(!t.isctype('\n', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype('_', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype('a', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype('Z', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype('5', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(' ', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype('-', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype('@', t.lookup_classname(s.begin(), s.end())));
+
+ s = "lower";
+ assert(!t.isctype('\n', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('_', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype('a', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('Z', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('5', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(' ', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('-', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('@', t.lookup_classname(s.begin(), s.end())));
+
+ s = "print";
+ assert(!t.isctype('\n', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype('_', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype('a', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype('Z', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype('5', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(' ', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype('-', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype('@', t.lookup_classname(s.begin(), s.end())));
+
+ s = "punct";
+ assert(!t.isctype('\n', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype('_', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('a', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('Z', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('5', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(' ', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype('-', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype('@', t.lookup_classname(s.begin(), s.end())));
+
+ s = "space";
+ assert( t.isctype('\n', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('_', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('a', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('Z', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('5', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(' ', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('-', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('@', t.lookup_classname(s.begin(), s.end())));
+
+ s = "upper";
+ assert(!t.isctype('\n', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('_', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('a', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype('Z', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('5', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(' ', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('-', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('@', t.lookup_classname(s.begin(), s.end())));
+
+ s = "xdigit";
+ assert(!t.isctype('\n', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('_', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype('a', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('Z', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype('5', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(' ', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('-', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('@', t.lookup_classname(s.begin(), s.end())));
+ }
+ {
+ std::regex_traits<wchar_t> t;
+
+ std::wstring s(L"w");
+ assert( t.isctype(L'_', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L'a', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L'Z', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L'5', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L' ', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'-', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'@', t.lookup_classname(s.begin(), s.end())));
+
+ s = L"alnum";
+ assert(!t.isctype(L'_', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L'a', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L'Z', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L'5', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L' ', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'-', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'@', t.lookup_classname(s.begin(), s.end())));
+
+ s = L"alpha";
+ assert(!t.isctype(L'_', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L'a', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L'Z', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'5', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L' ', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'-', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'@', t.lookup_classname(s.begin(), s.end())));
+
+ s = L"blank";
+ assert(!t.isctype(L'_', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'a', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'Z', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'5', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L' ', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'-', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'@', t.lookup_classname(s.begin(), s.end())));
+
+ s = L"cntrl";
+ assert( t.isctype(L'\n', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'_', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'a', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'Z', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'5', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L' ', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'-', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'@', t.lookup_classname(s.begin(), s.end())));
+
+ s = L"digit";
+ assert(!t.isctype(L'\n', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'_', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'a', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'Z', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L'5', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L' ', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'-', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'@', t.lookup_classname(s.begin(), s.end())));
+
+ s = L"graph";
+ assert(!t.isctype(L'\n', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L'_', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L'a', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L'Z', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L'5', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L' ', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L'-', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L'@', t.lookup_classname(s.begin(), s.end())));
+
+ s = L"lower";
+ assert(!t.isctype(L'\n', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'_', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L'a', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'Z', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'5', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L' ', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'-', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'@', t.lookup_classname(s.begin(), s.end())));
+
+ s = L"print";
+ assert(!t.isctype(L'\n', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L'_', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L'a', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L'Z', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L'5', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L' ', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L'-', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L'@', t.lookup_classname(s.begin(), s.end())));
+
+ s = L"punct";
+ assert(!t.isctype(L'\n', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L'_', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'a', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'Z', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'5', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L' ', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L'-', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L'@', t.lookup_classname(s.begin(), s.end())));
+
+ s = L"space";
+ assert( t.isctype(L'\n', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'_', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'a', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'Z', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'5', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L' ', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'-', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'@', t.lookup_classname(s.begin(), s.end())));
+
+ s = L"upper";
+ assert(!t.isctype(L'\n', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'_', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'a', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L'Z', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'5', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L' ', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'-', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'@', t.lookup_classname(s.begin(), s.end())));
+
+ s = L"xdigit";
+ assert(!t.isctype(L'\n', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'_', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L'a', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'Z', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L'5', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L' ', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'-', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'@', t.lookup_classname(s.begin(), s.end())));
+ }
+}
diff --git a/test/std/re/re.traits/length.pass.cpp b/test/std/re/re.traits/length.pass.cpp
new file mode 100644
index 000000000000..473c233c531e
--- /dev/null
+++ b/test/std/re/re.traits/length.pass.cpp
@@ -0,0 +1,31 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT> struct regex_traits;
+
+// static std::size_t length(const char_type* p);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ assert(std::regex_traits<char>::length("") == 0);
+ assert(std::regex_traits<char>::length("1") == 1);
+ assert(std::regex_traits<char>::length("12") == 2);
+ assert(std::regex_traits<char>::length("123") == 3);
+
+ assert(std::regex_traits<wchar_t>::length(L"") == 0);
+ assert(std::regex_traits<wchar_t>::length(L"1") == 1);
+ assert(std::regex_traits<wchar_t>::length(L"12") == 2);
+ assert(std::regex_traits<wchar_t>::length(L"123") == 3);
+}
diff --git a/test/std/re/re.traits/lookup_classname.pass.cpp b/test/std/re/re.traits/lookup_classname.pass.cpp
new file mode 100644
index 000000000000..0b1b18eb5077
--- /dev/null
+++ b/test/std/re/re.traits/lookup_classname.pass.cpp
@@ -0,0 +1,211 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT> struct regex_traits;
+
+// template <class ForwardIterator>
+// char_class_type
+// lookup_classname(ForwardIterator first, ForwardIterator last,
+// bool icase = false) const;
+
+#include <regex>
+#include <cassert>
+#include "test_iterators.h"
+
+template <class char_type>
+void
+test(const char_type* A,
+ typename std::regex_traits<char_type>::char_class_type expected,
+ bool icase = false)
+{
+ std::regex_traits<char_type> t;
+ typedef forward_iterator<const char_type*> F;
+ assert(t.lookup_classname(F(A), F(A + t.length(A)), icase) == expected);
+}
+
+int main()
+{
+ test("d", std::ctype_base::digit);
+ test("D", std::ctype_base::digit);
+ test("d", std::ctype_base::digit, true);
+ test("D", std::ctype_base::digit, true);
+
+ test("w", std::regex_traits<char>::__regex_word | std::ctype_base::alnum
+ | std::ctype_base::upper | std::ctype_base::lower);
+ test("W", std::regex_traits<char>::__regex_word | std::ctype_base::alnum
+ | std::ctype_base::upper | std::ctype_base::lower);
+ test("w", std::regex_traits<char>::__regex_word | std::ctype_base::alnum
+ | std::ctype_base::upper | std::ctype_base::lower, true);
+ test("W", std::regex_traits<char>::__regex_word | std::ctype_base::alnum
+ | std::ctype_base::upper | std::ctype_base::lower, true);
+
+ test("s", std::ctype_base::space);
+ test("S", std::ctype_base::space);
+ test("s", std::ctype_base::space, true);
+ test("S", std::ctype_base::space, true);
+
+ test("alnum", std::ctype_base::alnum);
+ test("AlNum", std::ctype_base::alnum);
+ test("alnum", std::ctype_base::alnum, true);
+ test("AlNum", std::ctype_base::alnum, true);
+
+ test("alpha", std::ctype_base::alpha);
+ test("Alpha", std::ctype_base::alpha);
+ test("alpha", std::ctype_base::alpha, true);
+ test("Alpha", std::ctype_base::alpha, true);
+
+ test("blank", std::ctype_base::blank);
+ test("Blank", std::ctype_base::blank);
+ test("blank", std::ctype_base::blank, true);
+ test("Blank", std::ctype_base::blank, true);
+
+ test("cntrl", std::ctype_base::cntrl);
+ test("Cntrl", std::ctype_base::cntrl);
+ test("cntrl", std::ctype_base::cntrl, true);
+ test("Cntrl", std::ctype_base::cntrl, true);
+
+ test("digit", std::ctype_base::digit);
+ test("Digit", std::ctype_base::digit);
+ test("digit", std::ctype_base::digit, true);
+ test("Digit", std::ctype_base::digit, true);
+
+ test("digit", std::ctype_base::digit);
+ test("DIGIT", std::ctype_base::digit);
+ test("digit", std::ctype_base::digit, true);
+ test("Digit", std::ctype_base::digit, true);
+
+ test("graph", std::ctype_base::graph);
+ test("GRAPH", std::ctype_base::graph);
+ test("graph", std::ctype_base::graph, true);
+ test("Graph", std::ctype_base::graph, true);
+
+ test("lower", std::ctype_base::lower);
+ test("LOWER", std::ctype_base::lower);
+ test("lower", std::ctype_base::lower | std::ctype_base::alpha, true);
+ test("Lower", std::ctype_base::lower | std::ctype_base::alpha, true);
+
+ test("print", std::ctype_base::print);
+ test("PRINT", std::ctype_base::print);
+ test("print", std::ctype_base::print, true);
+ test("Print", std::ctype_base::print, true);
+
+ test("punct", std::ctype_base::punct);
+ test("PUNCT", std::ctype_base::punct);
+ test("punct", std::ctype_base::punct, true);
+ test("Punct", std::ctype_base::punct, true);
+
+ test("space", std::ctype_base::space);
+ test("SPACE", std::ctype_base::space);
+ test("space", std::ctype_base::space, true);
+ test("Space", std::ctype_base::space, true);
+
+ test("upper", std::ctype_base::upper);
+ test("UPPER", std::ctype_base::upper);
+ test("upper", std::ctype_base::upper | std::ctype_base::alpha, true);
+ test("Upper", std::ctype_base::upper | std::ctype_base::alpha, true);
+
+ test("xdigit", std::ctype_base::xdigit);
+ test("XDIGIT", std::ctype_base::xdigit);
+ test("xdigit", std::ctype_base::xdigit, true);
+ test("Xdigit", std::ctype_base::xdigit, true);
+
+ test("dig", std::ctype_base::mask());
+ test("", std::ctype_base::mask());
+ test("digits", std::ctype_base::mask());
+
+ test(L"d", std::ctype_base::digit);
+ test(L"D", std::ctype_base::digit);
+ test(L"d", std::ctype_base::digit, true);
+ test(L"D", std::ctype_base::digit, true);
+
+ test(L"w", std::regex_traits<wchar_t>::__regex_word | std::ctype_base::alnum
+ | std::ctype_base::upper | std::ctype_base::lower);
+ test(L"W", std::regex_traits<wchar_t>::__regex_word | std::ctype_base::alnum
+ | std::ctype_base::upper | std::ctype_base::lower);
+ test(L"w", std::regex_traits<wchar_t>::__regex_word | std::ctype_base::alnum
+ | std::ctype_base::upper | std::ctype_base::lower, true);
+ test(L"W", std::regex_traits<wchar_t>::__regex_word | std::ctype_base::alnum
+ | std::ctype_base::upper | std::ctype_base::lower, true);
+
+ test(L"s", std::ctype_base::space);
+ test(L"S", std::ctype_base::space);
+ test(L"s", std::ctype_base::space, true);
+ test(L"S", std::ctype_base::space, true);
+
+ test(L"alnum", std::ctype_base::alnum);
+ test(L"AlNum", std::ctype_base::alnum);
+ test(L"alnum", std::ctype_base::alnum, true);
+ test(L"AlNum", std::ctype_base::alnum, true);
+
+ test(L"alpha", std::ctype_base::alpha);
+ test(L"Alpha", std::ctype_base::alpha);
+ test(L"alpha", std::ctype_base::alpha, true);
+ test(L"Alpha", std::ctype_base::alpha, true);
+
+ test(L"blank", std::ctype_base::blank);
+ test(L"Blank", std::ctype_base::blank);
+ test(L"blank", std::ctype_base::blank, true);
+ test(L"Blank", std::ctype_base::blank, true);
+
+ test(L"cntrl", std::ctype_base::cntrl);
+ test(L"Cntrl", std::ctype_base::cntrl);
+ test(L"cntrl", std::ctype_base::cntrl, true);
+ test(L"Cntrl", std::ctype_base::cntrl, true);
+
+ test(L"digit", std::ctype_base::digit);
+ test(L"Digit", std::ctype_base::digit);
+ test(L"digit", std::ctype_base::digit, true);
+ test(L"Digit", std::ctype_base::digit, true);
+
+ test(L"digit", std::ctype_base::digit);
+ test(L"DIGIT", std::ctype_base::digit);
+ test(L"digit", std::ctype_base::digit, true);
+ test(L"Digit", std::ctype_base::digit, true);
+
+ test(L"graph", std::ctype_base::graph);
+ test(L"GRAPH", std::ctype_base::graph);
+ test(L"graph", std::ctype_base::graph, true);
+ test(L"Graph", std::ctype_base::graph, true);
+
+ test(L"lower", std::ctype_base::lower);
+ test(L"LOWER", std::ctype_base::lower);
+ test(L"lower", std::ctype_base::lower | std::ctype_base::alpha, true);
+ test(L"Lower", std::ctype_base::lower | std::ctype_base::alpha, true);
+
+ test(L"print", std::ctype_base::print);
+ test(L"PRINT", std::ctype_base::print);
+ test(L"print", std::ctype_base::print, true);
+ test(L"Print", std::ctype_base::print, true);
+
+ test(L"punct", std::ctype_base::punct);
+ test(L"PUNCT", std::ctype_base::punct);
+ test(L"punct", std::ctype_base::punct, true);
+ test(L"Punct", std::ctype_base::punct, true);
+
+ test(L"space", std::ctype_base::space);
+ test(L"SPACE", std::ctype_base::space);
+ test(L"space", std::ctype_base::space, true);
+ test(L"Space", std::ctype_base::space, true);
+
+ test(L"upper", std::ctype_base::upper);
+ test(L"UPPER", std::ctype_base::upper);
+ test(L"upper", std::ctype_base::upper | std::ctype_base::alpha, true);
+ test(L"Upper", std::ctype_base::upper | std::ctype_base::alpha, true);
+
+ test(L"xdigit", std::ctype_base::xdigit);
+ test(L"XDIGIT", std::ctype_base::xdigit);
+ test(L"xdigit", std::ctype_base::xdigit, true);
+ test(L"Xdigit", std::ctype_base::xdigit, true);
+
+ test(L"dig", std::ctype_base::mask());
+ test(L"", std::ctype_base::mask());
+ test(L"digits", std::ctype_base::mask());
+}
diff --git a/test/std/re/re.traits/lookup_collatename.pass.cpp b/test/std/re/re.traits/lookup_collatename.pass.cpp
new file mode 100644
index 000000000000..a7cd5f071561
--- /dev/null
+++ b/test/std/re/re.traits/lookup_collatename.pass.cpp
@@ -0,0 +1,192 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: locale.cs_CZ.ISO8859-2
+
+// <regex>
+
+// template <class charT> struct regex_traits;
+
+// template <class ForwardIterator>
+// string_type
+// lookup_collatename(ForwardIterator first, ForwardIterator last) const;
+
+// TODO: investigation needed
+// XFAIL: linux-gnu
+
+#include <regex>
+#include <iterator>
+#include <cassert>
+#include "test_iterators.h"
+
+#include "platform_support.h" // locale name macros
+
+template <class char_type>
+void
+test(const char_type* A, const std::basic_string<char_type>& expected)
+{
+ std::regex_traits<char_type> t;
+ typedef forward_iterator<const char_type*> F;
+ assert(t.lookup_collatename(F(A), F(A + t.length(A))) == expected);
+}
+
+int main()
+{
+ test("NUL", std::string("\x00", 1));
+ test("alert", std::string("\x07"));
+ test("backspace", std::string("\x08"));
+ test("tab", std::string("\x09"));
+ test("carriage-return", std::string("\x0D"));
+ test("newline", std::string("\x0A"));
+ test("vertical-tab", std::string("\x0B"));
+ test("form-feed", std::string("\x0C"));
+ test("space", std::string(" "));
+ test("exclamation-mark", std::string("!"));
+ test("quotation-mark", std::string("\""));
+ test("number-sign", std::string("#"));
+ test("dollar-sign", std::string("$"));
+ test("percent-sign", std::string("%"));
+ test("ampersand", std::string("&"));
+ test("apostrophe", std::string("\'"));
+ test("left-parenthesis", std::string("("));
+ test("right-parenthesis", std::string(")"));
+ test("asterisk", std::string("*"));
+ test("plus-sign", std::string("+"));
+ test("comma", std::string(","));
+ test("hyphen-minus", std::string("-"));
+ test("hyphen", std::string("-"));
+ test("full-stop", std::string("."));
+ test("period", std::string("."));
+ test("slash", std::string("/"));
+ test("solidus", std::string("/"));
+ test("zero", std::string("0"));
+ test("one", std::string("1"));
+ test("two", std::string("2"));
+ test("three", std::string("3"));
+ test("four", std::string("4"));
+ test("five", std::string("5"));
+ test("six", std::string("6"));
+ test("seven", std::string("7"));
+ test("eight", std::string("8"));
+ test("nine", std::string("9"));
+ test("colon", std::string(":"));
+ test("semicolon", std::string(";"));
+ test("less-than-sign", std::string("<"));
+ test("equals-sign", std::string("="));
+ test("greater-than-sign", std::string(">"));
+ test("question-mark", std::string("?"));
+ test("commercial-at", std::string("@"));
+ for (char c = 'A'; c <= 'Z'; ++c)
+ {
+ const char a[2] = {c};
+ test(a, std::string(a));
+ }
+ test("left-square-bracket", std::string("["));
+ test("backslash", std::string("\\"));
+ test("reverse-solidus", std::string("\\"));
+ test("right-square-bracket", std::string("]"));
+ test("circumflex-accent", std::string("^"));
+ test("circumflex", std::string("^"));
+ test("low-line", std::string("_"));
+ test("underscore", std::string("_"));
+ test("grave-accent", std::string("`"));
+ for (char c = 'a'; c <= 'z'; ++c)
+ {
+ const char a[2] = {c};
+ test(a, std::string(a));
+ }
+ test("left-brace", std::string("{"));
+ test("left-curly-bracket", std::string("{"));
+ test("vertical-line", std::string("|"));
+ test("right-brace", std::string("}"));
+ test("right-curly-bracket", std::string("}"));
+ test("tilde", std::string("~"));
+
+ test("tild", std::string(""));
+ test("ch", std::string(""));
+ std::locale::global(std::locale(LOCALE_cs_CZ_ISO8859_2));
+ test("ch", std::string("ch"));
+ std::locale::global(std::locale("C"));
+
+ test(L"NUL", std::wstring(L"\x00", 1));
+ test(L"alert", std::wstring(L"\x07"));
+ test(L"backspace", std::wstring(L"\x08"));
+ test(L"tab", std::wstring(L"\x09"));
+ test(L"carriage-return", std::wstring(L"\x0D"));
+ test(L"newline", std::wstring(L"\x0A"));
+ test(L"vertical-tab", std::wstring(L"\x0B"));
+ test(L"form-feed", std::wstring(L"\x0C"));
+ test(L"space", std::wstring(L" "));
+ test(L"exclamation-mark", std::wstring(L"!"));
+ test(L"quotation-mark", std::wstring(L"\""));
+ test(L"number-sign", std::wstring(L"#"));
+ test(L"dollar-sign", std::wstring(L"$"));
+ test(L"percent-sign", std::wstring(L"%"));
+ test(L"ampersand", std::wstring(L"&"));
+ test(L"apostrophe", std::wstring(L"\'"));
+ test(L"left-parenthesis", std::wstring(L"("));
+ test(L"right-parenthesis", std::wstring(L")"));
+ test(L"asterisk", std::wstring(L"*"));
+ test(L"plus-sign", std::wstring(L"+"));
+ test(L"comma", std::wstring(L","));
+ test(L"hyphen-minus", std::wstring(L"-"));
+ test(L"hyphen", std::wstring(L"-"));
+ test(L"full-stop", std::wstring(L"."));
+ test(L"period", std::wstring(L"."));
+ test(L"slash", std::wstring(L"/"));
+ test(L"solidus", std::wstring(L"/"));
+ test(L"zero", std::wstring(L"0"));
+ test(L"one", std::wstring(L"1"));
+ test(L"two", std::wstring(L"2"));
+ test(L"three", std::wstring(L"3"));
+ test(L"four", std::wstring(L"4"));
+ test(L"five", std::wstring(L"5"));
+ test(L"six", std::wstring(L"6"));
+ test(L"seven", std::wstring(L"7"));
+ test(L"eight", std::wstring(L"8"));
+ test(L"nine", std::wstring(L"9"));
+ test(L"colon", std::wstring(L":"));
+ test(L"semicolon", std::wstring(L";"));
+ test(L"less-than-sign", std::wstring(L"<"));
+ test(L"equals-sign", std::wstring(L"="));
+ test(L"greater-than-sign", std::wstring(L">"));
+ test(L"question-mark", std::wstring(L"?"));
+ test(L"commercial-at", std::wstring(L"@"));
+ for (wchar_t c = L'A'; c <= L'Z'; ++c)
+ {
+ const wchar_t a[2] = {c};
+ test(a, std::wstring(a));
+ }
+ test(L"left-square-bracket", std::wstring(L"["));
+ test(L"backslash", std::wstring(L"\\"));
+ test(L"reverse-solidus", std::wstring(L"\\"));
+ test(L"right-square-bracket", std::wstring(L"]"));
+ test(L"circumflex-accent", std::wstring(L"^"));
+ test(L"circumflex", std::wstring(L"^"));
+ test(L"low-line", std::wstring(L"_"));
+ test(L"underscore", std::wstring(L"_"));
+ test(L"grave-accent", std::wstring(L"`"));
+ for (wchar_t c = L'a'; c <= L'z'; ++c)
+ {
+ const wchar_t a[2] = {c};
+ test(a, std::wstring(a));
+ }
+ test(L"left-brace", std::wstring(L"{"));
+ test(L"left-curly-bracket", std::wstring(L"{"));
+ test(L"vertical-line", std::wstring(L"|"));
+ test(L"right-brace", std::wstring(L"}"));
+ test(L"right-curly-bracket", std::wstring(L"}"));
+ test(L"tilde", std::wstring(L"~"));
+
+ test(L"tild", std::wstring(L""));
+ test(L"ch", std::wstring(L""));
+ std::locale::global(std::locale(LOCALE_cs_CZ_ISO8859_2));
+ test(L"ch", std::wstring(L"ch"));
+ std::locale::global(std::locale("C"));
+}
diff --git a/test/std/re/re.traits/transform.pass.cpp b/test/std/re/re.traits/transform.pass.cpp
new file mode 100644
index 000000000000..85235e045d88
--- /dev/null
+++ b/test/std/re/re.traits/transform.pass.cpp
@@ -0,0 +1,46 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: locale.cs_CZ.ISO8859-2
+
+// <regex>
+
+// template <class charT> struct regex_traits;
+
+// template <class ForwardIterator>
+// string_type transform(ForwardIterator first, ForwardIterator last) const;
+
+#include <regex>
+#include <cassert>
+#include "test_iterators.h"
+
+#include "platform_support.h" // locale name macros
+
+int main()
+{
+ {
+ std::regex_traits<char> t;
+ const char a[] = "a";
+ const char B[] = "B";
+ typedef forward_iterator<const char*> F;
+ assert(t.transform(F(a), F(a+1)) > t.transform(F(B), F(B+1)));
+ t.imbue(std::locale(LOCALE_cs_CZ_ISO8859_2));
+ assert(t.transform(F(a), F(a+1)) < t.transform(F(B), F(B+1)));
+ }
+ {
+ std::regex_traits<wchar_t> t;
+ const wchar_t a[] = L"a";
+ const wchar_t B[] = L"B";
+ typedef forward_iterator<const wchar_t*> F;
+ assert(t.transform(F(a), F(a+1)) > t.transform(F(B), F(B+1)));
+ t.imbue(std::locale(LOCALE_cs_CZ_ISO8859_2));
+ assert(t.transform(F(a), F(a+1)) < t.transform(F(B), F(B+1)));
+ }
+}
diff --git a/test/std/re/re.traits/transform_primary.pass.cpp b/test/std/re/re.traits/transform_primary.pass.cpp
new file mode 100644
index 000000000000..438cd75452bb
--- /dev/null
+++ b/test/std/re/re.traits/transform_primary.pass.cpp
@@ -0,0 +1,51 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: locale.cs_CZ.ISO8859-2
+
+// <regex>
+
+// template <class charT> struct regex_traits;
+
+// template <class ForwardIterator>
+// string_type
+// transform_primary(ForwardIterator first, ForwardIterator last) const;
+
+#include <regex>
+#include <cassert>
+#include "test_iterators.h"
+
+#include "platform_support.h" // locale name macros
+
+int main()
+{
+ {
+ std::regex_traits<char> t;
+ const char A[] = "A";
+ const char Aacute[] = "\xC1";
+ typedef forward_iterator<const char*> F;
+ assert(t.transform_primary(F(A), F(A+1)) !=
+ t.transform_primary(F(Aacute), F(Aacute+1)));
+ t.imbue(std::locale(LOCALE_cs_CZ_ISO8859_2));
+ assert(t.transform_primary(F(A), F(A+1)) ==
+ t.transform_primary(F(Aacute), F(Aacute+1)));
+ }
+ {
+ std::regex_traits<wchar_t> t;
+ const wchar_t A[] = L"A";
+ const wchar_t Aacute[] = L"\xC1";
+ typedef forward_iterator<const wchar_t*> F;
+ assert(t.transform_primary(F(A), F(A+1)) !=
+ t.transform_primary(F(Aacute), F(Aacute+1)));
+ t.imbue(std::locale(LOCALE_cs_CZ_ISO8859_2));
+ assert(t.transform_primary(F(A), F(A+1)) ==
+ t.transform_primary(F(Aacute), F(Aacute+1)));
+ }
+}
diff --git a/test/std/re/re.traits/translate.pass.cpp b/test/std/re/re.traits/translate.pass.cpp
new file mode 100644
index 000000000000..c3523387c56b
--- /dev/null
+++ b/test/std/re/re.traits/translate.pass.cpp
@@ -0,0 +1,34 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT> struct regex_traits;
+
+// charT translate(charT c) const;
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ std::regex_traits<char> t;
+ assert(t.translate('a') == 'a');
+ assert(t.translate('B') == 'B');
+ assert(t.translate('c') == 'c');
+ }
+ {
+ std::regex_traits<wchar_t> t;
+ assert(t.translate(L'a') == L'a');
+ assert(t.translate(L'B') == L'B');
+ assert(t.translate(L'c') == L'c');
+ }
+}
diff --git a/test/std/re/re.traits/translate_nocase.pass.cpp b/test/std/re/re.traits/translate_nocase.pass.cpp
new file mode 100644
index 000000000000..f9fa38ddf26a
--- /dev/null
+++ b/test/std/re/re.traits/translate_nocase.pass.cpp
@@ -0,0 +1,72 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT> struct regex_traits;
+
+// charT translate_nocase(charT c) const;
+
+// REQUIRES: locale.en_US.UTF-8
+
+// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11
+// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12
+
+// TODO: investigation needed
+// XFAIL: linux-gnu
+
+#include <regex>
+#include <cassert>
+
+#include "platform_support.h"
+
+int main()
+{
+ {
+ std::regex_traits<char> t;
+ assert(t.translate_nocase(' ') == ' ');
+ assert(t.translate_nocase('A') == 'a');
+ assert(t.translate_nocase('\x07') == '\x07');
+ assert(t.translate_nocase('.') == '.');
+ assert(t.translate_nocase('a') == 'a');
+ assert(t.translate_nocase('1') == '1');
+ assert(t.translate_nocase('\xDA') == '\xDA');
+ assert(t.translate_nocase('\xFA') == '\xFA');
+ t.imbue(std::locale(LOCALE_en_US_UTF_8));
+ assert(t.translate_nocase(' ') == ' ');
+ assert(t.translate_nocase('A') == 'a');
+ assert(t.translate_nocase('\x07') == '\x07');
+ assert(t.translate_nocase('.') == '.');
+ assert(t.translate_nocase('a') == 'a');
+ assert(t.translate_nocase('1') == '1');
+ assert(t.translate_nocase('\xDA') == '\xFA');
+ assert(t.translate_nocase('\xFA') == '\xFA');
+ }
+ {
+ std::regex_traits<wchar_t> t;
+ assert(t.translate_nocase(L' ') == L' ');
+ assert(t.translate_nocase(L'A') == L'a');
+ assert(t.translate_nocase(L'\x07') == L'\x07');
+ assert(t.translate_nocase(L'.') == L'.');
+ assert(t.translate_nocase(L'a') == L'a');
+ assert(t.translate_nocase(L'1') == L'1');
+ assert(t.translate_nocase(L'\xDA') == L'\xDA');
+ assert(t.translate_nocase(L'\xFA') == L'\xFA');
+ t.imbue(std::locale(LOCALE_en_US_UTF_8));
+ assert(t.translate_nocase(L' ') == L' ');
+ assert(t.translate_nocase(L'A') == L'a');
+ assert(t.translate_nocase(L'\x07') == L'\x07');
+ assert(t.translate_nocase(L'.') == L'.');
+ assert(t.translate_nocase(L'a') == L'a');
+ assert(t.translate_nocase(L'1') == L'1');
+ assert(t.translate_nocase(L'\xDA') == L'\xFA');
+ assert(t.translate_nocase(L'\xFA') == L'\xFA');
+ }
+}
diff --git a/test/std/re/re.traits/types.pass.cpp b/test/std/re/re.traits/types.pass.cpp
new file mode 100644
index 000000000000..50586a1f29f3
--- /dev/null
+++ b/test/std/re/re.traits/types.pass.cpp
@@ -0,0 +1,32 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT>
+// struct regex_traits
+// {
+// public:
+// typedef charT char_type;
+// typedef basic_string<char_type> string_type;
+// typedef locale locale_type;
+
+#include <regex>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_same<std::regex_traits<char>::char_type, char>::value), "");
+ static_assert((std::is_same<std::regex_traits<char>::string_type, std::string>::value), "");
+ static_assert((std::is_same<std::regex_traits<char>::locale_type, std::locale>::value), "");
+ static_assert((std::is_same<std::regex_traits<wchar_t>::char_type, wchar_t>::value), "");
+ static_assert((std::is_same<std::regex_traits<wchar_t>::string_type, std::wstring>::value), "");
+ static_assert((std::is_same<std::regex_traits<wchar_t>::locale_type, std::locale>::value), "");
+}
diff --git a/test/std/re/re.traits/value.pass.cpp b/test/std/re/re.traits/value.pass.cpp
new file mode 100644
index 000000000000..349a29cc6bc1
--- /dev/null
+++ b/test/std/re/re.traits/value.pass.cpp
@@ -0,0 +1,125 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT> struct regex_traits;
+
+// int value(charT ch, int radix) const;
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ {
+ std::regex_traits<char> t;
+
+ for (char c = 0; c < '0'; ++c)
+ {
+ assert(t.value(c, 8) == -1);
+ assert(t.value(c, 10) == -1);
+ assert(t.value(c, 16) == -1);
+ }
+ for (char c = '0'; c < '8'; ++c)
+ {
+ assert(t.value(c, 8) == c - '0');
+ assert(t.value(c, 10) == c - '0');
+ assert(t.value(c, 16) == c - '0');
+ }
+ for (char c = '8'; c < ':'; ++c)
+ {
+ assert(t.value(c, 8) == -1);
+ assert(t.value(c, 10) == c - '0');
+ assert(t.value(c, 16) == c - '0');
+ }
+ for (char c = ':'; c < 'A'; ++c)
+ {
+ assert(t.value(c, 8) == -1);
+ assert(t.value(c, 10) == -1);
+ assert(t.value(c, 16) == -1);
+ }
+ for (char c = 'A'; c < 'G'; ++c)
+ {
+ assert(t.value(c, 8) == -1);
+ assert(t.value(c, 10) == -1);
+ assert(t.value(c, 16) == c - 'A' +10);
+ }
+ for (char c = 'G'; c < 'a'; ++c)
+ {
+ assert(t.value(c, 8) == -1);
+ assert(t.value(c, 10) == -1);
+ assert(t.value(c, 16) == -1);
+ }
+ for (char c = 'a'; c < 'g'; ++c)
+ {
+ assert(t.value(c, 8) == -1);
+ assert(t.value(c, 10) == -1);
+ assert(t.value(c, 16) == c - 'a' +10);
+ }
+ for (int c = 'g'; c < 256; ++c)
+ {
+ assert(t.value(char(c), 8) == -1);
+ assert(t.value(char(c), 10) == -1);
+ assert(t.value(char(c), 16) == -1);
+ }
+ }
+ {
+ std::regex_traits<wchar_t> t;
+
+ for (wchar_t c = 0; c < '0'; ++c)
+ {
+ assert(t.value(c, 8) == -1);
+ assert(t.value(c, 10) == -1);
+ assert(t.value(c, 16) == -1);
+ }
+ for (wchar_t c = '0'; c < '8'; ++c)
+ {
+ assert(t.value(c, 8) == c - '0');
+ assert(t.value(c, 10) == c - '0');
+ assert(t.value(c, 16) == c - '0');
+ }
+ for (wchar_t c = '8'; c < ':'; ++c)
+ {
+ assert(t.value(c, 8) == -1);
+ assert(t.value(c, 10) == c - '0');
+ assert(t.value(c, 16) == c - '0');
+ }
+ for (wchar_t c = ':'; c < 'A'; ++c)
+ {
+ assert(t.value(c, 8) == -1);
+ assert(t.value(c, 10) == -1);
+ assert(t.value(c, 16) == -1);
+ }
+ for (wchar_t c = 'A'; c < 'G'; ++c)
+ {
+ assert(t.value(c, 8) == -1);
+ assert(t.value(c, 10) == -1);
+ assert(t.value(c, 16) == c - 'A' +10);
+ }
+ for (wchar_t c = 'G'; c < 'a'; ++c)
+ {
+ assert(t.value(c, 8) == -1);
+ assert(t.value(c, 10) == -1);
+ assert(t.value(c, 16) == -1);
+ }
+ for (wchar_t c = 'a'; c < 'g'; ++c)
+ {
+ assert(t.value(c, 8) == -1);
+ assert(t.value(c, 10) == -1);
+ assert(t.value(c, 16) == c - 'a' +10);
+ }
+ for (int c = 'g'; c < 0xFFFF; ++c)
+ {
+ assert(t.value(c, 8) == -1);
+ assert(t.value(c, 10) == -1);
+ assert(t.value(c, 16) == -1);
+ }
+ }
+}
diff --git a/test/std/strings/basic.string.hash/strings.pass.cpp b/test/std/strings/basic.string.hash/strings.pass.cpp
new file mode 100644
index 000000000000..5fc32c06a701
--- /dev/null
+++ b/test/std/strings/basic.string.hash/strings.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template <class T>
+// struct hash
+// : public unary_function<T, size_t>
+// {
+// size_t operator()(T val) const;
+// };
+
+// Not very portable
+
+#include <string>
+#include <cassert>
+#include <type_traits>
+
+template <class T>
+void
+test()
+{
+ typedef std::hash<T> H;
+ static_assert((std::is_same<typename H::argument_type, T>::value), "" );
+ static_assert((std::is_same<typename H::result_type, std::size_t>::value), "" );
+ H h;
+ std::string g1 = "1234567890";
+ std::string g2 = "1234567891";
+ T s1(g1.begin(), g1.end());
+ T s2(g2.begin(), g2.end());
+ assert(h(s1) != h(s2));
+}
+
+int main()
+{
+ test<std::string>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<std::u16string>();
+ test<std::u32string>();
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<std::wstring>();
+}
diff --git a/test/std/strings/basic.string.literals/literal.pass.cpp b/test/std/strings/basic.string.literals/literal.pass.cpp
new file mode 100644
index 000000000000..dbb5f681395b
--- /dev/null
+++ b/test/std/strings/basic.string.literals/literal.pass.cpp
@@ -0,0 +1,47 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+#include <string>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ using namespace std::literals::string_literals;
+
+ static_assert ( std::is_same<decltype( "Hi"s), std::string>::value, "" );
+ static_assert ( std::is_same<decltype( u8"Hi"s), std::string>::value, "" );
+ static_assert ( std::is_same<decltype( L"Hi"s), std::wstring>::value, "" );
+ static_assert ( std::is_same<decltype( u"Hi"s), std::u16string>::value, "" );
+ static_assert ( std::is_same<decltype( U"Hi"s), std::u32string>::value, "" );
+
+ std::string foo;
+ std::wstring Lfoo;
+ std::u16string ufoo;
+ std::u32string Ufoo;
+
+ foo = ""s; assert( foo.size() == 0);
+ foo = u8""s; assert( foo.size() == 0);
+ Lfoo = L""s; assert(Lfoo.size() == 0);
+ ufoo = u""s; assert(ufoo.size() == 0);
+ Ufoo = U""s; assert(Ufoo.size() == 0);
+
+ foo = " "s; assert( foo.size() == 1);
+ foo = u8" "s; assert( foo.size() == 1);
+ Lfoo = L" "s; assert(Lfoo.size() == 1);
+ ufoo = u" "s; assert(ufoo.size() == 1);
+ Ufoo = U" "s; assert(Ufoo.size() == 1);
+
+ foo = "ABC"s; assert( foo == "ABC"); assert( foo == std::string ( "ABC"));
+ foo = u8"ABC"s; assert( foo == u8"ABC"); assert( foo == std::string (u8"ABC"));
+ Lfoo = L"ABC"s; assert(Lfoo == L"ABC"); assert(Lfoo == std::wstring ( L"ABC"));
+ ufoo = u"ABC"s; assert(ufoo == u"ABC"); assert(ufoo == std::u16string( u"ABC"));
+ Ufoo = U"ABC"s; assert(Ufoo == U"ABC"); assert(Ufoo == std::u32string( U"ABC"));
+#endif
+}
diff --git a/test/std/strings/basic.string.literals/literal1.fail.cpp b/test/std/strings/basic.string.literals/literal1.fail.cpp
new file mode 100644
index 000000000000..6ba0b30d458d
--- /dev/null
+++ b/test/std/strings/basic.string.literals/literal1.fail.cpp
@@ -0,0 +1,22 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+#include <string>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ using std::string;
+
+ string foo = ""s; // should fail w/conversion operator not found
+#else
+#error
+#endif
+}
diff --git a/test/std/strings/basic.string.literals/literal1.pass.cpp b/test/std/strings/basic.string.literals/literal1.pass.cpp
new file mode 100644
index 000000000000..f5143746b0bb
--- /dev/null
+++ b/test/std/strings/basic.string.literals/literal1.pass.cpp
@@ -0,0 +1,20 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+#include <string>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ using namespace std::literals;
+
+ std::string foo = ""s;
+#endif
+}
diff --git a/test/std/strings/basic.string.literals/literal2.fail.cpp b/test/std/strings/basic.string.literals/literal2.fail.cpp
new file mode 100644
index 000000000000..68f1d254e327
--- /dev/null
+++ b/test/std/strings/basic.string.literals/literal2.fail.cpp
@@ -0,0 +1,20 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+#include <string>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ std::string foo = ""s; // should fail w/conversion operator not found
+#else
+#error
+#endif
+}
diff --git a/test/std/strings/basic.string.literals/literal2.pass.cpp b/test/std/strings/basic.string.literals/literal2.pass.cpp
new file mode 100644
index 000000000000..86d28e60e52b
--- /dev/null
+++ b/test/std/strings/basic.string.literals/literal2.pass.cpp
@@ -0,0 +1,20 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+#include <string>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ using namespace std::literals::string_literals;
+
+ std::string foo = ""s;
+#endif
+}
diff --git a/test/std/strings/basic.string.literals/literal3.pass.cpp b/test/std/strings/basic.string.literals/literal3.pass.cpp
new file mode 100644
index 000000000000..98e3e40e058c
--- /dev/null
+++ b/test/std/strings/basic.string.literals/literal3.pass.cpp
@@ -0,0 +1,20 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+#include <string>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ using namespace std;
+
+ string foo = ""s;
+#endif
+}
diff --git a/test/std/strings/basic.string/input_iterator.h b/test/std/strings/basic.string/input_iterator.h
new file mode 100644
index 000000000000..fa6bb80a1499
--- /dev/null
+++ b/test/std/strings/basic.string/input_iterator.h
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef INPUT_ITERATOR_H
+#define INPUT_ITERATOR_H
+
+#include <iterator>
+
+template <class It>
+class input_iterator
+{
+ It it_;
+public:
+ typedef typename std::input_iterator_tag iterator_category;
+ typedef typename std::iterator_traits<It>::value_type value_type;
+ typedef typename std::iterator_traits<It>::difference_type difference_type;
+ typedef It pointer;
+ typedef typename std::iterator_traits<It>::reference reference;
+
+ input_iterator() : it_() {}
+ explicit input_iterator(It it) : it_(it) {}
+
+ reference operator*() const {return *it_;}
+ pointer operator->() const {return it_;}
+
+ input_iterator& operator++() {++it_; return *this;}
+ input_iterator operator++(int) {input_iterator tmp(*this); ++(*this); return tmp;}
+
+ friend bool operator==(const input_iterator& x, const input_iterator& y)
+ {return x.it_ == y.it_;}
+ friend bool operator!=(const input_iterator& x, const input_iterator& y)
+ {return !(x == y);}
+};
+
+#endif // INPUT_ITERATOR_H
diff --git a/test/std/strings/basic.string/string.access/at.pass.cpp b/test/std/strings/basic.string/string.access/at.pass.cpp
new file mode 100644
index 000000000000..8fada8fb1eea
--- /dev/null
+++ b/test/std/strings/basic.string/string.access/at.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// const_reference at(size_type pos) const;
+// reference at(size_type pos);
+
+#include <string>
+#include <stdexcept>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s, typename S::size_type pos)
+{
+ try
+ {
+ const S& cs = s;
+ assert(s.at(pos) == s[pos]);
+ assert(cs.at(pos) == cs[pos]);
+ assert(pos < cs.size());
+ }
+ catch (std::out_of_range&)
+ {
+ assert(pos >= s.size());
+ }
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test(S(), 0);
+ test(S("123"), 0);
+ test(S("123"), 1);
+ test(S("123"), 2);
+ test(S("123"), 3);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S(), 0);
+ test(S("123"), 0);
+ test(S("123"), 1);
+ test(S("123"), 2);
+ test(S("123"), 3);
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.access/back.pass.cpp b/test/std/strings/basic.string/string.access/back.pass.cpp
new file mode 100644
index 000000000000..e91521441b80
--- /dev/null
+++ b/test/std/strings/basic.string/string.access/back.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// const charT& back() const;
+// charT& back();
+
+#ifdef _LIBCPP_DEBUG
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s)
+{
+ const S& cs = s;
+ assert(&cs.back() == &cs[cs.size()-1]);
+ assert(&s.back() == &s[cs.size()-1]);
+ s.back() = typename S::value_type('z');
+ assert(s.back() == typename S::value_type('z'));
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test(S("1"));
+ test(S("1234567890123456789012345678901234567890"));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S("1"));
+ test(S("1234567890123456789012345678901234567890"));
+ }
+#endif
+#ifdef _LIBCPP_DEBUG
+ {
+ std::string s;
+ char c = s.back();
+ assert(false);
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.access/db_back.pass.cpp b/test/std/strings/basic.string/string.access/db_back.pass.cpp
new file mode 100644
index 000000000000..2b31fabc7c70
--- /dev/null
+++ b/test/std/strings/basic.string/string.access/db_back.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// Call back() on empty container.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <string>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::string S;
+ S s(1, '\0');
+ assert(s.back() == 0);
+ s.clear();
+ assert(s.back() == 0);
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ S s(1, '\0');
+ assert(s.back() == 0);
+ s.clear();
+ assert(s.back() == 0);
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/strings/basic.string/string.access/db_cback.pass.cpp b/test/std/strings/basic.string/string.access/db_cback.pass.cpp
new file mode 100644
index 000000000000..7feb4239f07a
--- /dev/null
+++ b/test/std/strings/basic.string/string.access/db_cback.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// Call back() on empty const container.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <string>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::string S;
+ const S s;
+ assert(s.back() == 0);
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ const S s;
+ assert(s.back() == 0);
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/strings/basic.string/string.access/db_cfront.pass.cpp b/test/std/strings/basic.string/string.access/db_cfront.pass.cpp
new file mode 100644
index 000000000000..9f7785b85cda
--- /dev/null
+++ b/test/std/strings/basic.string/string.access/db_cfront.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// Call front() on empty const container.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <string>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::string S;
+ const S s;
+ assert(s.front() == 0);
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ const S s;
+ assert(s.front() == 0);
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/strings/basic.string/string.access/db_cindex.pass.cpp b/test/std/strings/basic.string/string.access/db_cindex.pass.cpp
new file mode 100644
index 000000000000..6294200104ba
--- /dev/null
+++ b/test/std/strings/basic.string/string.access/db_cindex.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// Index const string out of bounds.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <string>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::string S;
+ const S s;
+ assert(s[0] == 0);
+ assert(s[1] == 0);
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ const S s;
+ assert(s[0] == 0);
+ assert(s[1] == 0);
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/strings/basic.string/string.access/db_front.pass.cpp b/test/std/strings/basic.string/string.access/db_front.pass.cpp
new file mode 100644
index 000000000000..ff675bc5c217
--- /dev/null
+++ b/test/std/strings/basic.string/string.access/db_front.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// Call front() on empty container.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <string>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::string S;
+ S s(1, '\0');
+ assert(s.front() == 0);
+ s.clear();
+ assert(s.front() == 0);
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ S s(1, '\0');
+ assert(s.front() == 0);
+ s.clear();
+ assert(s.front() == 0);
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/strings/basic.string/string.access/db_index.pass.cpp b/test/std/strings/basic.string/string.access/db_index.pass.cpp
new file mode 100644
index 000000000000..b20e20188023
--- /dev/null
+++ b/test/std/strings/basic.string/string.access/db_index.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// Index string out of bounds.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <string>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::string S;
+ S s;
+ assert(s[0] == 0);
+ assert(s[1] == 0);
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ S s;
+ assert(s[0] == 0);
+ assert(s[1] == 0);
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/strings/basic.string/string.access/front.pass.cpp b/test/std/strings/basic.string/string.access/front.pass.cpp
new file mode 100644
index 000000000000..ed80916f16f0
--- /dev/null
+++ b/test/std/strings/basic.string/string.access/front.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// const charT& front() const;
+// charT& front();
+
+#ifdef _LIBCPP_DEBUG
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s)
+{
+ const S& cs = s;
+ assert(&cs.front() == &cs[0]);
+ assert(&s.front() == &s[0]);
+ s.front() = typename S::value_type('z');
+ assert(s.front() == typename S::value_type('z'));
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test(S("1"));
+ test(S("1234567890123456789012345678901234567890"));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S("1"));
+ test(S("1234567890123456789012345678901234567890"));
+ }
+#endif
+#ifdef _LIBCPP_DEBUG
+ {
+ std::string s;
+ char c = s.front();
+ assert(false);
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.access/index.pass.cpp b/test/std/strings/basic.string/string.access/index.pass.cpp
new file mode 100644
index 000000000000..cd3162385160
--- /dev/null
+++ b/test/std/strings/basic.string/string.access/index.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// const_reference operator[](size_type pos) const;
+// reference operator[](size_type pos);
+
+#ifdef _LIBCPP_DEBUG
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::string S;
+ S s("0123456789");
+ const S& cs = s;
+ for (S::size_type i = 0; i < cs.size(); ++i)
+ {
+ assert(s[i] == '0' + i);
+ assert(cs[i] == s[i]);
+ }
+ assert(cs[cs.size()] == '\0');
+ const S s2 = S();
+ assert(s2[0] == '\0');
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ S s("0123456789");
+ const S& cs = s;
+ for (S::size_type i = 0; i < cs.size(); ++i)
+ {
+ assert(s[i] == '0' + i);
+ assert(cs[i] == s[i]);
+ }
+ assert(cs[cs.size()] == '\0');
+ const S s2 = S();
+ assert(s2[0] == '\0');
+ }
+#endif
+#ifdef _LIBCPP_DEBUG
+ {
+ std::string s;
+ char c = s[0];
+ assert(c == '\0');
+ c = s[1];
+ assert(false);
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.capacity/capacity.pass.cpp b/test/std/strings/basic.string/string.capacity/capacity.pass.cpp
new file mode 100644
index 000000000000..bae762155527
--- /dev/null
+++ b/test/std/strings/basic.string/string.capacity/capacity.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type capacity() const;
+
+#include <string>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s)
+{
+ S::allocator_type::throw_after = 0;
+ try
+ {
+ while (s.size() < s.capacity())
+ s.push_back(typename S::value_type());
+ assert(s.size() == s.capacity());
+ }
+ catch (...)
+ {
+ assert(false);
+ }
+ S::allocator_type::throw_after = INT_MAX;
+}
+
+int main()
+{
+ {
+ typedef std::basic_string<char, std::char_traits<char>, test_allocator<char> > S;
+ S s;
+ test(s);
+ s.assign(10, 'a');
+ s.erase(5);
+ test(s);
+ s.assign(100, 'a');
+ s.erase(50);
+ test(s);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ S s;
+ assert(s.capacity() > 0);
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.capacity/clear.pass.cpp b/test/std/strings/basic.string/string.capacity/clear.pass.cpp
new file mode 100644
index 000000000000..b73af7599344
--- /dev/null
+++ b/test/std/strings/basic.string/string.capacity/clear.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// void clear();
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s)
+{
+ s.clear();
+ assert(s.size() == 0);
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ S s;
+ test(s);
+
+ s.assign(10, 'a');
+ s.erase(5);
+ test(s);
+
+ s.assign(100, 'a');
+ s.erase(50);
+ test(s);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ S s;
+ test(s);
+
+ s.assign(10, 'a');
+ s.erase(5);
+ test(s);
+
+ s.assign(100, 'a');
+ s.erase(50);
+ test(s);
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.capacity/empty.pass.cpp b/test/std/strings/basic.string/string.capacity/empty.pass.cpp
new file mode 100644
index 000000000000..ac65f5144858
--- /dev/null
+++ b/test/std/strings/basic.string/string.capacity/empty.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// bool empty() const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& s)
+{
+ assert(s.empty() == (s.size() == 0));
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test(S());
+ test(S("123"));
+ test(S("12345678901234567890123456789012345678901234567890"));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S());
+ test(S("123"));
+ test(S("12345678901234567890123456789012345678901234567890"));
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.capacity/length.pass.cpp b/test/std/strings/basic.string/string.capacity/length.pass.cpp
new file mode 100644
index 000000000000..d3ae1aaee036
--- /dev/null
+++ b/test/std/strings/basic.string/string.capacity/length.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type length() const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& s)
+{
+ assert(s.length() == s.size());
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test(S());
+ test(S("123"));
+ test(S("12345678901234567890123456789012345678901234567890"));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S());
+ test(S("123"));
+ test(S("12345678901234567890123456789012345678901234567890"));
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.capacity/max_size.pass.cpp b/test/std/strings/basic.string/string.capacity/max_size.pass.cpp
new file mode 100644
index 000000000000..e4ff556d9e3f
--- /dev/null
+++ b/test/std/strings/basic.string/string.capacity/max_size.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type max_size() const;
+
+// NOTE: asan and msan will fail for one of two reasons
+// 1. If allocator_may_return_null=0 then they will fail because the allocation
+// returns null.
+// 2. If allocator_may_return_null=1 then they will fail because the allocation
+// is too large to succeed.
+// UNSUPPORTED: sanitizer-new-delete
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test1(const S& s)
+{
+ S s2(s);
+ const size_t sz = s2.max_size() - 1;
+ try { s2.resize(sz, 'x'); }
+ catch ( const std::bad_alloc & ) { return ; }
+ assert ( s2.size() == sz );
+}
+
+template <class S>
+void
+test2(const S& s)
+{
+ S s2(s);
+ const size_t sz = s2.max_size();
+ try { s2.resize(sz, 'x'); }
+ catch ( const std::bad_alloc & ) { return ; }
+ assert ( s.size() == sz );
+}
+
+template <class S>
+void
+test(const S& s)
+{
+ assert(s.max_size() >= s.size());
+ test1(s);
+ test2(s);
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test(S());
+ test(S("123"));
+ test(S("12345678901234567890123456789012345678901234567890"));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S());
+ test(S("123"));
+ test(S("12345678901234567890123456789012345678901234567890"));
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.capacity/over_max_size.pass.cpp b/test/std/strings/basic.string/string.capacity/over_max_size.pass.cpp
new file mode 100644
index 000000000000..bbadb9ccc5a8
--- /dev/null
+++ b/test/std/strings/basic.string/string.capacity/over_max_size.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type max_size() const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& s)
+{
+ assert(s.max_size() >= s.size());
+ S s2(s);
+ const size_t sz = s2.max_size() + 1;
+ try { s2.resize(sz, 'x'); }
+ catch ( const std::length_error & ) { return ; }
+ assert ( false );
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test(S());
+ test(S("123"));
+ test(S("12345678901234567890123456789012345678901234567890"));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S());
+ test(S("123"));
+ test(S("12345678901234567890123456789012345678901234567890"));
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.capacity/reserve.pass.cpp b/test/std/strings/basic.string/string.capacity/reserve.pass.cpp
new file mode 100644
index 000000000000..a155825be752
--- /dev/null
+++ b/test/std/strings/basic.string/string.capacity/reserve.pass.cpp
@@ -0,0 +1,117 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// void reserve(size_type res_arg=0);
+
+#include <string>
+#include <stdexcept>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s)
+{
+ typename S::size_type old_cap = s.capacity();
+ S s0 = s;
+ s.reserve();
+ assert(s.__invariants());
+ assert(s == s0);
+ assert(s.capacity() <= old_cap);
+ assert(s.capacity() >= s.size());
+}
+
+template <class S>
+void
+test(S s, typename S::size_type res_arg)
+{
+ typename S::size_type old_cap = s.capacity();
+ S s0 = s;
+ try
+ {
+ s.reserve(res_arg);
+ assert(res_arg <= s.max_size());
+ assert(s == s0);
+ assert(s.capacity() >= res_arg);
+ assert(s.capacity() >= s.size());
+ }
+ catch (std::length_error&)
+ {
+ assert(res_arg > s.max_size());
+ }
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ {
+ S s;
+ test(s);
+
+ s.assign(10, 'a');
+ s.erase(5);
+ test(s);
+
+ s.assign(100, 'a');
+ s.erase(50);
+ test(s);
+ }
+ {
+ S s;
+ test(s, 5);
+ test(s, 10);
+ test(s, 50);
+ }
+ {
+ S s(100, 'a');
+ s.erase(50);
+ test(s, 5);
+ test(s, 10);
+ test(s, 50);
+ test(s, 100);
+ test(s, S::npos);
+ }
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ {
+ S s;
+ test(s);
+
+ s.assign(10, 'a');
+ s.erase(5);
+ test(s);
+
+ s.assign(100, 'a');
+ s.erase(50);
+ test(s);
+ }
+ {
+ S s;
+ test(s, 5);
+ test(s, 10);
+ test(s, 50);
+ }
+ {
+ S s(100, 'a');
+ s.erase(50);
+ test(s, 5);
+ test(s, 10);
+ test(s, 50);
+ test(s, 100);
+ test(s, S::npos);
+ }
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.capacity/resize_size.pass.cpp b/test/std/strings/basic.string/string.capacity/resize_size.pass.cpp
new file mode 100644
index 000000000000..14fe209fd59a
--- /dev/null
+++ b/test/std/strings/basic.string/string.capacity/resize_size.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// void resize(size_type n);
+
+#include <string>
+#include <stdexcept>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s, typename S::size_type n, S expected)
+{
+ try
+ {
+ s.resize(n);
+ assert(s.__invariants());
+ assert(n <= s.max_size());
+ assert(s == expected);
+ }
+ catch (std::length_error&)
+ {
+ assert(n > s.max_size());
+ }
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test(S(), 0, S());
+ test(S(), 1, S(1, '\0'));
+ test(S(), 10, S(10, '\0'));
+ test(S(), 100, S(100, '\0'));
+ test(S("12345"), 0, S());
+ test(S("12345"), 2, S("12"));
+ test(S("12345"), 5, S("12345"));
+ test(S("12345"), 15, S("12345\0\0\0\0\0\0\0\0\0\0", 15));
+ test(S("12345678901234567890123456789012345678901234567890"), 0, S());
+ test(S("12345678901234567890123456789012345678901234567890"), 10,
+ S("1234567890"));
+ test(S("12345678901234567890123456789012345678901234567890"), 50,
+ S("12345678901234567890123456789012345678901234567890"));
+ test(S("12345678901234567890123456789012345678901234567890"), 60,
+ S("12345678901234567890123456789012345678901234567890\0\0\0\0\0\0\0\0\0\0", 60));
+ test(S(), S::npos, S("not going to happen"));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S(), 0, S());
+ test(S(), 1, S(1, '\0'));
+ test(S(), 10, S(10, '\0'));
+ test(S(), 100, S(100, '\0'));
+ test(S("12345"), 0, S());
+ test(S("12345"), 2, S("12"));
+ test(S("12345"), 5, S("12345"));
+ test(S("12345"), 15, S("12345\0\0\0\0\0\0\0\0\0\0", 15));
+ test(S("12345678901234567890123456789012345678901234567890"), 0, S());
+ test(S("12345678901234567890123456789012345678901234567890"), 10,
+ S("1234567890"));
+ test(S("12345678901234567890123456789012345678901234567890"), 50,
+ S("12345678901234567890123456789012345678901234567890"));
+ test(S("12345678901234567890123456789012345678901234567890"), 60,
+ S("12345678901234567890123456789012345678901234567890\0\0\0\0\0\0\0\0\0\0", 60));
+ test(S(), S::npos, S("not going to happen"));
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.capacity/resize_size_char.pass.cpp b/test/std/strings/basic.string/string.capacity/resize_size_char.pass.cpp
new file mode 100644
index 000000000000..f293df971f21
--- /dev/null
+++ b/test/std/strings/basic.string/string.capacity/resize_size_char.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// void resize(size_type n, charT c);
+
+#include <string>
+#include <stdexcept>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s, typename S::size_type n, typename S::value_type c, S expected)
+{
+ try
+ {
+ s.resize(n, c);
+ assert(s.__invariants());
+ assert(n <= s.max_size());
+ assert(s == expected);
+ }
+ catch (std::length_error&)
+ {
+ assert(n > s.max_size());
+ }
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test(S(), 0, 'a', S());
+ test(S(), 1, 'a', S("a"));
+ test(S(), 10, 'a', S(10, 'a'));
+ test(S(), 100, 'a', S(100, 'a'));
+ test(S("12345"), 0, 'a', S());
+ test(S("12345"), 2, 'a', S("12"));
+ test(S("12345"), 5, 'a', S("12345"));
+ test(S("12345"), 15, 'a', S("12345aaaaaaaaaa"));
+ test(S("12345678901234567890123456789012345678901234567890"), 0, 'a', S());
+ test(S("12345678901234567890123456789012345678901234567890"), 10, 'a',
+ S("1234567890"));
+ test(S("12345678901234567890123456789012345678901234567890"), 50, 'a',
+ S("12345678901234567890123456789012345678901234567890"));
+ test(S("12345678901234567890123456789012345678901234567890"), 60, 'a',
+ S("12345678901234567890123456789012345678901234567890aaaaaaaaaa"));
+ test(S(), S::npos, 'a', S("not going to happen"));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S(), 0, 'a', S());
+ test(S(), 1, 'a', S("a"));
+ test(S(), 10, 'a', S(10, 'a'));
+ test(S(), 100, 'a', S(100, 'a'));
+ test(S("12345"), 0, 'a', S());
+ test(S("12345"), 2, 'a', S("12"));
+ test(S("12345"), 5, 'a', S("12345"));
+ test(S("12345"), 15, 'a', S("12345aaaaaaaaaa"));
+ test(S("12345678901234567890123456789012345678901234567890"), 0, 'a', S());
+ test(S("12345678901234567890123456789012345678901234567890"), 10, 'a',
+ S("1234567890"));
+ test(S("12345678901234567890123456789012345678901234567890"), 50, 'a',
+ S("12345678901234567890123456789012345678901234567890"));
+ test(S("12345678901234567890123456789012345678901234567890"), 60, 'a',
+ S("12345678901234567890123456789012345678901234567890aaaaaaaaaa"));
+ test(S(), S::npos, 'a', S("not going to happen"));
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.capacity/shrink_to_fit.pass.cpp b/test/std/strings/basic.string/string.capacity/shrink_to_fit.pass.cpp
new file mode 100644
index 000000000000..aacbffd098f0
--- /dev/null
+++ b/test/std/strings/basic.string/string.capacity/shrink_to_fit.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// void shrink_to_fit();
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s)
+{
+ typename S::size_type old_cap = s.capacity();
+ S s0 = s;
+ s.shrink_to_fit();
+ assert(s.__invariants());
+ assert(s == s0);
+ assert(s.capacity() <= old_cap);
+ assert(s.capacity() >= s.size());
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ S s;
+ test(s);
+
+ s.assign(10, 'a');
+ s.erase(5);
+ test(s);
+
+ s.assign(100, 'a');
+ s.erase(50);
+ test(s);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ S s;
+ test(s);
+
+ s.assign(10, 'a');
+ s.erase(5);
+ test(s);
+
+ s.assign(100, 'a');
+ s.erase(50);
+ test(s);
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.capacity/size.pass.cpp b/test/std/strings/basic.string/string.capacity/size.pass.cpp
new file mode 100644
index 000000000000..21b475a8113f
--- /dev/null
+++ b/test/std/strings/basic.string/string.capacity/size.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type size() const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& s, typename S::size_type c)
+{
+ assert(s.size() == c);
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test(S(), 0);
+ test(S("123"), 3);
+ test(S("12345678901234567890123456789012345678901234567890"), 50);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S(), 0);
+ test(S("123"), 3);
+ test(S("12345678901234567890123456789012345678901234567890"), 50);
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.cons/alloc.pass.cpp b/test/std/strings/basic.string/string.cons/alloc.pass.cpp
new file mode 100644
index 000000000000..1c4f2044834e
--- /dev/null
+++ b/test/std/strings/basic.string/string.cons/alloc.pass.cpp
@@ -0,0 +1,95 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// explicit basic_string(const Allocator& a = Allocator());
+
+#include <string>
+#include <cassert>
+
+#include "test_macros.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+template <class S>
+void
+test()
+{
+ {
+#if TEST_STD_VER > 14
+ static_assert((noexcept(S{})), "" );
+#elif TEST_STD_VER >= 11
+ static_assert((noexcept(S()) == noexcept(typename S::allocator_type())), "" );
+#endif
+ S s;
+ assert(s.__invariants());
+ assert(s.data());
+ assert(s.size() == 0);
+ assert(s.capacity() >= s.size());
+ assert(s.get_allocator() == typename S::allocator_type());
+ }
+ {
+#if TEST_STD_VER > 14
+ static_assert((noexcept(S{typename S::allocator_type{}})), "" );
+#elif TEST_STD_VER >= 11
+ static_assert((noexcept(S(typename S::allocator_type())) == std::is_nothrow_copy_constructible<typename S::allocator_type>::value), "" );
+#endif
+ S s(typename S::allocator_type(5));
+ assert(s.__invariants());
+ assert(s.data());
+ assert(s.size() == 0);
+ assert(s.capacity() >= s.size());
+ assert(s.get_allocator() == typename S::allocator_type(5));
+ }
+}
+
+#if TEST_STD_VER >= 11
+
+template <class S>
+void
+test2()
+{
+ {
+#if TEST_STD_VER > 14
+ static_assert((noexcept(S{})), "" );
+#elif TEST_STD_VER >= 11
+ static_assert((noexcept(S()) == noexcept(typename S::allocator_type())), "" );
+#endif
+ S s;
+ assert(s.__invariants());
+ assert(s.data());
+ assert(s.size() == 0);
+ assert(s.capacity() >= s.size());
+ assert(s.get_allocator() == typename S::allocator_type());
+ }
+ {
+#if TEST_STD_VER > 14
+ static_assert((noexcept(S{typename S::allocator_type{}})), "" );
+#elif TEST_STD_VER >= 11
+ static_assert((noexcept(S(typename S::allocator_type())) == std::is_nothrow_copy_constructible<typename S::allocator_type>::value), "" );
+#endif
+ S s(typename S::allocator_type{});
+ assert(s.__invariants());
+ assert(s.data());
+ assert(s.size() == 0);
+ assert(s.capacity() >= s.size());
+ assert(s.get_allocator() == typename S::allocator_type());
+ }
+}
+
+#endif
+
+int main()
+{
+ test<std::basic_string<char, std::char_traits<char>, test_allocator<char> > >();
+#if TEST_STD_VER >= 11
+ test2<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
+#endif
+}
diff --git a/test/std/strings/basic.string/string.cons/char_assignment.pass.cpp b/test/std/strings/basic.string/string.cons/char_assignment.pass.cpp
new file mode 100644
index 000000000000..1c582bc51637
--- /dev/null
+++ b/test/std/strings/basic.string/string.cons/char_assignment.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string<charT,traits,Allocator>& operator=(charT c);
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s1, typename S::value_type s2)
+{
+ typedef typename S::traits_type T;
+ s1 = s2;
+ assert(s1.__invariants());
+ assert(s1.size() == 1);
+ assert(T::eq(s1[0], s2));
+ assert(s1.capacity() >= s1.size());
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test(S(), 'a');
+ test(S("1"), 'a');
+ test(S("123456789"), 'a');
+ test(S("1234567890123456789012345678901234567890123456789012345678901234567890"), 'a');
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S(), 'a');
+ test(S("1"), 'a');
+ test(S("123456789"), 'a');
+ test(S("1234567890123456789012345678901234567890123456789012345678901234567890"), 'a');
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.cons/copy.pass.cpp b/test/std/strings/basic.string/string.cons/copy.pass.cpp
new file mode 100644
index 000000000000..9c9fc3230668
--- /dev/null
+++ b/test/std/strings/basic.string/string.cons/copy.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string(const basic_string<charT,traits,Allocator>& str);
+
+#include <string>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s1)
+{
+ S s2 = s1;
+ assert(s2.__invariants());
+ assert(s2 == s1);
+ assert(s2.capacity() >= s2.size());
+ assert(s2.get_allocator() == s1.get_allocator());
+}
+
+int main()
+{
+ {
+ typedef test_allocator<char> A;
+ typedef std::basic_string<char, std::char_traits<char>, A> S;
+ test(S(A(3)));
+ test(S("1", A(5)));
+ test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef min_allocator<char> A;
+ typedef std::basic_string<char, std::char_traits<char>, A> S;
+ test(S(A{}));
+ test(S("1", A()));
+ test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()));
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.cons/copy_alloc.pass.cpp b/test/std/strings/basic.string/string.cons/copy_alloc.pass.cpp
new file mode 100644
index 000000000000..cf8021019a2e
--- /dev/null
+++ b/test/std/strings/basic.string/string.cons/copy_alloc.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string(const basic_string& str, const Allocator& alloc);
+
+#include <string>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s1, const typename S::allocator_type& a)
+{
+ S s2(s1, a);
+ assert(s2.__invariants());
+ assert(s2 == s1);
+ assert(s2.capacity() >= s2.size());
+ assert(s2.get_allocator() == a);
+}
+
+int main()
+{
+ {
+ typedef test_allocator<char> A;
+ typedef std::basic_string<char, std::char_traits<char>, A> S;
+ test(S(), A(3));
+ test(S("1"), A(5));
+ test(S("1234567890123456789012345678901234567890123456789012345678901234567890"), A(7));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef min_allocator<char> A;
+ typedef std::basic_string<char, std::char_traits<char>, A> S;
+ test(S(), A());
+ test(S("1"), A());
+ test(S("1234567890123456789012345678901234567890123456789012345678901234567890"), A());
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.cons/copy_assignment.pass.cpp b/test/std/strings/basic.string/string.cons/copy_assignment.pass.cpp
new file mode 100644
index 000000000000..ccb6c599974b
--- /dev/null
+++ b/test/std/strings/basic.string/string.cons/copy_assignment.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string<charT,traits,Allocator>&
+// operator=(const basic_string<charT,traits,Allocator>& str);
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s1, const S& s2)
+{
+ s1 = s2;
+ assert(s1.__invariants());
+ assert(s1 == s2);
+ assert(s1.capacity() >= s1.size());
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test(S(), S());
+ test(S("1"), S());
+ test(S(), S("1"));
+ test(S("1"), S("2"));
+ test(S("1"), S("2"));
+
+ test(S(),
+ S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
+ test(S("123456789"),
+ S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
+ test(S("1234567890123456789012345678901234567890123456789012345678901234567890"),
+ S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
+ test(S("1234567890123456789012345678901234567890123456789012345678901234567890"
+ "1234567890123456789012345678901234567890123456789012345678901234567890"),
+ S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S(), S());
+ test(S("1"), S());
+ test(S(), S("1"));
+ test(S("1"), S("2"));
+ test(S("1"), S("2"));
+
+ test(S(),
+ S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
+ test(S("123456789"),
+ S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
+ test(S("1234567890123456789012345678901234567890123456789012345678901234567890"),
+ S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
+ test(S("1234567890123456789012345678901234567890123456789012345678901234567890"
+ "1234567890123456789012345678901234567890123456789012345678901234567890"),
+ S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.cons/default_noexcept.pass.cpp b/test/std/strings/basic.string/string.cons/default_noexcept.pass.cpp
new file mode 100644
index 000000000000..af117103d827
--- /dev/null
+++ b/test/std/strings/basic.string/string.cons/default_noexcept.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string()
+// noexcept(is_nothrow_default_constructible<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <string>
+#include <cassert>
+
+#include "test_macros.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_alloc
+{
+ typedef T value_type;
+ some_alloc(const some_alloc&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::string C;
+ static_assert(std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::basic_string<char, std::char_traits<char>, test_allocator<char>> C;
+ static_assert(std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::basic_string<char, std::char_traits<char>, some_alloc<char>> C;
+ static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.cons/dtor_noexcept.pass.cpp b/test/std/strings/basic.string/string.cons/dtor_noexcept.pass.cpp
new file mode 100644
index 000000000000..b3cc127fbc46
--- /dev/null
+++ b/test/std/strings/basic.string/string.cons/dtor_noexcept.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// ~basic_string() // implied noexcept;
+
+#include <string>
+#include <cassert>
+
+#include "test_allocator.h"
+
+#if __has_feature(cxx_noexcept)
+
+template <class T>
+struct some_alloc
+{
+ typedef T value_type;
+ some_alloc(const some_alloc&);
+ ~some_alloc() noexcept(false);
+};
+
+#endif
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::string C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::basic_string<char, std::char_traits<char>, test_allocator<char>> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::basic_string<char, std::char_traits<char>, some_alloc<char>> C;
+ static_assert(!std::is_nothrow_destructible<C>::value, "");
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.cons/initializer_list.pass.cpp b/test/std/strings/basic.string/string.cons/initializer_list.pass.cpp
new file mode 100644
index 000000000000..d6ff8504e9da
--- /dev/null
+++ b/test/std/strings/basic.string/string.cons/initializer_list.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string(initializer_list<charT> il, const Allocator& a = Allocator());
+
+#include <string>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ std::string s = {'a', 'b', 'c'};
+ assert(s == "abc");
+ }
+ {
+ std::wstring s;
+ s = {L'a', L'b', L'c'};
+ assert(s == L"abc");
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ S s = {'a', 'b', 'c'};
+ assert(s == "abc");
+ }
+ {
+ typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, min_allocator<wchar_t>> S;
+ S s;
+ s = {L'a', L'b', L'c'};
+ assert(s == L"abc");
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/strings/basic.string/string.cons/initializer_list_assignment.pass.cpp b/test/std/strings/basic.string/string.cons/initializer_list_assignment.pass.cpp
new file mode 100644
index 000000000000..753076895359
--- /dev/null
+++ b/test/std/strings/basic.string/string.cons/initializer_list_assignment.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string& operator=(initializer_list<charT> il);
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ std::string s;
+ s = {'a', 'b', 'c'};
+ assert(s == "abc");
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ S s;
+ s = {'a', 'b', 'c'};
+ assert(s == "abc");
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/strings/basic.string/string.cons/iter_alloc.pass.cpp b/test/std/strings/basic.string/string.cons/iter_alloc.pass.cpp
new file mode 100644
index 000000000000..664cb80b10fe
--- /dev/null
+++ b/test/std/strings/basic.string/string.cons/iter_alloc.pass.cpp
@@ -0,0 +1,119 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class InputIterator>
+// basic_string(InputIterator begin, InputIterator end,
+// const Allocator& a = Allocator());
+
+#include <string>
+#include <iterator>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "../input_iterator.h"
+#include "min_allocator.h"
+
+template <class It>
+void
+test(It first, It last)
+{
+ typedef typename std::iterator_traits<It>::value_type charT;
+ typedef std::basic_string<charT, std::char_traits<charT>, test_allocator<charT> > S;
+ typedef typename S::traits_type T;
+ typedef typename S::allocator_type A;
+ S s2(first, last);
+ assert(s2.__invariants());
+ assert(s2.size() == std::distance(first, last));
+ unsigned i = 0;
+ for (It it = first; it != last; ++it, ++i)
+ assert(s2[i] == *it);
+ assert(s2.get_allocator() == A());
+ assert(s2.capacity() >= s2.size());
+}
+
+template <class It, class A>
+void
+test(It first, It last, const A& a)
+{
+ typedef typename std::iterator_traits<It>::value_type charT;
+ typedef std::basic_string<charT, std::char_traits<charT>, A> S;
+ typedef typename S::traits_type T;
+ S s2(first, last, a);
+ assert(s2.__invariants());
+ assert(s2.size() == std::distance(first, last));
+ unsigned i = 0;
+ for (It it = first; it != last; ++it, ++i)
+ assert(s2[i] == *it);
+ assert(s2.get_allocator() == a);
+ assert(s2.capacity() >= s2.size());
+}
+
+int main()
+{
+ {
+ typedef test_allocator<char> A;
+ const char* s = "12345678901234567890123456789012345678901234567890";
+
+ test(s, s);
+ test(s, s, A(2));
+
+ test(s, s+1);
+ test(s, s+1, A(2));
+
+ test(s, s+10);
+ test(s, s+10, A(2));
+
+ test(s, s+50);
+ test(s, s+50, A(2));
+
+ test(input_iterator<const char*>(s), input_iterator<const char*>(s));
+ test(input_iterator<const char*>(s), input_iterator<const char*>(s), A(2));
+
+ test(input_iterator<const char*>(s), input_iterator<const char*>(s+1));
+ test(input_iterator<const char*>(s), input_iterator<const char*>(s+1), A(2));
+
+ test(input_iterator<const char*>(s), input_iterator<const char*>(s+10));
+ test(input_iterator<const char*>(s), input_iterator<const char*>(s+10), A(2));
+
+ test(input_iterator<const char*>(s), input_iterator<const char*>(s+50));
+ test(input_iterator<const char*>(s), input_iterator<const char*>(s+50), A(2));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef min_allocator<char> A;
+ const char* s = "12345678901234567890123456789012345678901234567890";
+
+ test(s, s);
+ test(s, s, A());
+
+ test(s, s+1);
+ test(s, s+1, A());
+
+ test(s, s+10);
+ test(s, s+10, A());
+
+ test(s, s+50);
+ test(s, s+50, A());
+
+ test(input_iterator<const char*>(s), input_iterator<const char*>(s));
+ test(input_iterator<const char*>(s), input_iterator<const char*>(s), A());
+
+ test(input_iterator<const char*>(s), input_iterator<const char*>(s+1));
+ test(input_iterator<const char*>(s), input_iterator<const char*>(s+1), A());
+
+ test(input_iterator<const char*>(s), input_iterator<const char*>(s+10));
+ test(input_iterator<const char*>(s), input_iterator<const char*>(s+10), A());
+
+ test(input_iterator<const char*>(s), input_iterator<const char*>(s+50));
+ test(input_iterator<const char*>(s), input_iterator<const char*>(s+50), A());
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.cons/move.pass.cpp b/test/std/strings/basic.string/string.cons/move.pass.cpp
new file mode 100644
index 000000000000..b94f189ecb46
--- /dev/null
+++ b/test/std/strings/basic.string/string.cons/move.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string(basic_string<charT,traits,Allocator>&& str);
+
+#include <string>
+#include <cassert>
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s0)
+{
+ S s1 = s0;
+ S s2 = std::move(s0);
+ assert(s2.__invariants());
+ assert(s0.__invariants());
+ assert(s2 == s1);
+ assert(s2.capacity() >= s2.size());
+ assert(s2.get_allocator() == s1.get_allocator());
+}
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef test_allocator<char> A;
+ typedef std::basic_string<char, std::char_traits<char>, A> S;
+ test(S(A(3)));
+ test(S("1", A(5)));
+ test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef min_allocator<char> A;
+ typedef std::basic_string<char, std::char_traits<char>, A> S;
+ test(S(A{}));
+ test(S("1", A()));
+ test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()));
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/strings/basic.string/string.cons/move_alloc.pass.cpp b/test/std/strings/basic.string/string.cons/move_alloc.pass.cpp
new file mode 100644
index 000000000000..a232a46bd9fb
--- /dev/null
+++ b/test/std/strings/basic.string/string.cons/move_alloc.pass.cpp
@@ -0,0 +1,89 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string(basic_string&& str, const Allocator& alloc);
+
+#include <string>
+#include <cassert>
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+#include "test_macros.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+
+template <class S>
+void
+test(S s0, const typename S::allocator_type& a)
+{
+ S s1 = s0;
+ S s2(std::move(s0), a);
+ assert(s2.__invariants());
+ assert(s0.__invariants());
+ assert(s2 == s1);
+ assert(s2.capacity() >= s2.size());
+ assert(s2.get_allocator() == a);
+}
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+// #if _LIBCPP_STD_VER <= 14
+// _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);
+// #else
+// _NOEXCEPT;
+// #endif
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef test_allocator<char> A;
+ typedef std::basic_string<char, std::char_traits<char>, A> S;
+#if TEST_STD_VER > 14
+ static_assert((noexcept(S{})), "" );
+#elif TEST_STD_VER >= 11
+ static_assert((noexcept(S()) == std::is_nothrow_move_constructible<A>::value), "" );
+#endif
+ test(S(), A(3));
+ test(S("1"), A(5));
+ test(S("1234567890123456789012345678901234567890123456789012345678901234567890"), A(7));
+ }
+
+ int alloc_count = test_alloc_base::alloc_count;
+ {
+ typedef test_allocator<char> A;
+ typedef std::basic_string<char, std::char_traits<char>, A> S;
+#if TEST_STD_VER > 14
+ static_assert((noexcept(S{})), "" );
+#elif TEST_STD_VER >= 11
+ static_assert((noexcept(S()) == std::is_nothrow_move_constructible<A>::value), "" );
+#endif
+ S s1 ( "Twas brillig, and the slivy toves did gyre and gymbal in the wabe" );
+ S s2 (std::move(s1), A(1));
+ }
+ assert ( test_alloc_base::alloc_count == alloc_count );
+
+#if TEST_STD_VER >= 11
+ {
+ typedef min_allocator<char> A;
+ typedef std::basic_string<char, std::char_traits<char>, A> S;
+#if TEST_STD_VER > 14
+ static_assert((noexcept(S{})), "" );
+#elif TEST_STD_VER >= 11
+ static_assert((noexcept(S()) == std::is_nothrow_move_constructible<A>::value), "" );
+#endif
+ test(S(), A());
+ test(S("1"), A());
+ test(S("1234567890123456789012345678901234567890123456789012345678901234567890"), A());
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/strings/basic.string/string.cons/move_assign_noexcept.pass.cpp b/test/std/strings/basic.string/string.cons/move_assign_noexcept.pass.cpp
new file mode 100644
index 000000000000..32c9514a9154
--- /dev/null
+++ b/test/std/strings/basic.string/string.cons/move_assign_noexcept.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string& operator=(basic_string&& c)
+// noexcept(
+// allocator_type::propagate_on_container_move_assignment::value &&
+// is_nothrow_move_assignable<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <string>
+#include <cassert>
+
+#include "test_allocator.h"
+
+template <class T>
+struct some_alloc
+{
+ typedef T value_type;
+ some_alloc(const some_alloc&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::string C;
+ static_assert(std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::basic_string<char, std::char_traits<char>, test_allocator<char>> C;
+ static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::basic_string<char, std::char_traits<char>, some_alloc<char>> C;
+ static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.cons/move_assignment.pass.cpp b/test/std/strings/basic.string/string.cons/move_assignment.pass.cpp
new file mode 100644
index 000000000000..5bc1c8a9153f
--- /dev/null
+++ b/test/std/strings/basic.string/string.cons/move_assignment.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string<charT,traits,Allocator>&
+// operator=(basic_string<charT,traits,Allocator>&& str);
+
+#include <string>
+#include <cassert>
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s1, S s2)
+{
+ S s0 = s2;
+ s1 = std::move(s2);
+ assert(s1.__invariants());
+ assert(s2.__invariants());
+ assert(s1 == s0);
+ assert(s1.capacity() >= s1.size());
+}
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::string S;
+ test(S(), S());
+ test(S("1"), S());
+ test(S(), S("1"));
+ test(S("1"), S("2"));
+ test(S("1"), S("2"));
+
+ test(S(),
+ S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
+ test(S("123456789"),
+ S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
+ test(S("1234567890123456789012345678901234567890123456789012345678901234567890"),
+ S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
+ test(S("1234567890123456789012345678901234567890123456789012345678901234567890"
+ "1234567890123456789012345678901234567890123456789012345678901234567890"),
+ S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S(), S());
+ test(S("1"), S());
+ test(S(), S("1"));
+ test(S("1"), S("2"));
+ test(S("1"), S("2"));
+
+ test(S(),
+ S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
+ test(S("123456789"),
+ S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
+ test(S("1234567890123456789012345678901234567890123456789012345678901234567890"),
+ S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
+ test(S("1234567890123456789012345678901234567890123456789012345678901234567890"
+ "1234567890123456789012345678901234567890123456789012345678901234567890"),
+ S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/strings/basic.string/string.cons/move_noexcept.pass.cpp b/test/std/strings/basic.string/string.cons/move_noexcept.pass.cpp
new file mode 100644
index 000000000000..b287a940cc82
--- /dev/null
+++ b/test/std/strings/basic.string/string.cons/move_noexcept.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string(basic_string&&)
+// noexcept(is_nothrow_move_constructible<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <string>
+#include <cassert>
+
+#include "test_macros.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_alloc
+{
+ typedef T value_type;
+ some_alloc(const some_alloc&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::string C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::basic_string<char, std::char_traits<char>, test_allocator<char>> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::basic_string<char, std::char_traits<char>, some_alloc<char>> C;
+#if TEST_STD_VER <= 14
+ static_assert(!std::is_nothrow_move_constructible<C>::value, "");
+#else
+ static_assert( std::is_nothrow_move_constructible<C>::value, "");
+#endif
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.cons/pointer_alloc.pass.cpp b/test/std/strings/basic.string/string.cons/pointer_alloc.pass.cpp
new file mode 100644
index 000000000000..f6e9e00e590f
--- /dev/null
+++ b/test/std/strings/basic.string/string.cons/pointer_alloc.pass.cpp
@@ -0,0 +1,89 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string(const charT* s, const Allocator& a = Allocator());
+
+#include <string>
+#include <stdexcept>
+#include <algorithm>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+template <class charT>
+void
+test(const charT* s)
+{
+ typedef std::basic_string<charT, std::char_traits<charT>, test_allocator<charT> > S;
+ typedef typename S::traits_type T;
+ typedef typename S::allocator_type A;
+ unsigned n = T::length(s);
+ S s2(s);
+ assert(s2.__invariants());
+ assert(s2.size() == n);
+ assert(T::compare(s2.data(), s, n) == 0);
+ assert(s2.get_allocator() == A());
+ assert(s2.capacity() >= s2.size());
+}
+
+template <class charT, class A>
+void
+test(const charT* s, const A& a)
+{
+ typedef std::basic_string<charT, std::char_traits<charT>, A> S;
+ typedef typename S::traits_type T;
+ unsigned n = T::length(s);
+ S s2(s, a);
+ assert(s2.__invariants());
+ assert(s2.size() == n);
+ assert(T::compare(s2.data(), s, n) == 0);
+ assert(s2.get_allocator() == a);
+ assert(s2.capacity() >= s2.size());
+}
+
+int main()
+{
+ {
+ typedef test_allocator<char> A;
+ typedef std::basic_string<char, std::char_traits<char>, A> S;
+
+ test("");
+ test("", A(2));
+
+ test("1");
+ test("1", A(2));
+
+ test("1234567980");
+ test("1234567980", A(2));
+
+ test("123456798012345679801234567980123456798012345679801234567980");
+ test("123456798012345679801234567980123456798012345679801234567980", A(2));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef min_allocator<char> A;
+ typedef std::basic_string<char, std::char_traits<char>, A> S;
+
+ test("");
+ test("", A());
+
+ test("1");
+ test("1", A());
+
+ test("1234567980");
+ test("1234567980", A());
+
+ test("123456798012345679801234567980123456798012345679801234567980");
+ test("123456798012345679801234567980123456798012345679801234567980", A());
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.cons/pointer_assignment.pass.cpp b/test/std/strings/basic.string/string.cons/pointer_assignment.pass.cpp
new file mode 100644
index 000000000000..c691613379a2
--- /dev/null
+++ b/test/std/strings/basic.string/string.cons/pointer_assignment.pass.cpp
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string<charT,traits,Allocator>&
+// operator=(const charT* s);
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s1, const typename S::value_type* s2)
+{
+ typedef typename S::traits_type T;
+ s1 = s2;
+ assert(s1.__invariants());
+ assert(s1.size() == T::length(s2));
+ assert(T::compare(s1.data(), s2, s1.size()) == 0);
+ assert(s1.capacity() >= s1.size());
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test(S(), "");
+ test(S("1"), "");
+ test(S(), "1");
+ test(S("1"), "2");
+ test(S("1"), "2");
+
+ test(S(),
+ "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz");
+ test(S("123456789"),
+ "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz");
+ test(S("1234567890123456789012345678901234567890123456789012345678901234567890"),
+ "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz");
+ test(S("1234567890123456789012345678901234567890123456789012345678901234567890"
+ "1234567890123456789012345678901234567890123456789012345678901234567890"),
+ "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz");
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S(), "");
+ test(S("1"), "");
+ test(S(), "1");
+ test(S("1"), "2");
+ test(S("1"), "2");
+
+ test(S(),
+ "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz");
+ test(S("123456789"),
+ "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz");
+ test(S("1234567890123456789012345678901234567890123456789012345678901234567890"),
+ "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz");
+ test(S("1234567890123456789012345678901234567890123456789012345678901234567890"
+ "1234567890123456789012345678901234567890123456789012345678901234567890"),
+ "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz");
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.cons/pointer_size_alloc.pass.cpp b/test/std/strings/basic.string/string.cons/pointer_size_alloc.pass.cpp
new file mode 100644
index 000000000000..f1f107af20bb
--- /dev/null
+++ b/test/std/strings/basic.string/string.cons/pointer_size_alloc.pass.cpp
@@ -0,0 +1,87 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string(const charT* s, size_type n, const Allocator& a = Allocator());
+
+#include <string>
+#include <stdexcept>
+#include <algorithm>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+template <class charT>
+void
+test(const charT* s, unsigned n)
+{
+ typedef std::basic_string<charT, std::char_traits<charT>, test_allocator<charT> > S;
+ typedef typename S::traits_type T;
+ typedef typename S::allocator_type A;
+ S s2(s, n);
+ assert(s2.__invariants());
+ assert(s2.size() == n);
+ assert(T::compare(s2.data(), s, n) == 0);
+ assert(s2.get_allocator() == A());
+ assert(s2.capacity() >= s2.size());
+}
+
+template <class charT, class A>
+void
+test(const charT* s, unsigned n, const A& a)
+{
+ typedef std::basic_string<charT, std::char_traits<charT>, A> S;
+ typedef typename S::traits_type T;
+ S s2(s, n, a);
+ assert(s2.__invariants());
+ assert(s2.size() == n);
+ assert(T::compare(s2.data(), s, n) == 0);
+ assert(s2.get_allocator() == a);
+ assert(s2.capacity() >= s2.size());
+}
+
+int main()
+{
+ {
+ typedef test_allocator<char> A;
+ typedef std::basic_string<char, std::char_traits<char>, A> S;
+
+ test("", 0);
+ test("", 0, A(2));
+
+ test("1", 1);
+ test("1", 1, A(2));
+
+ test("1234567980", 10);
+ test("1234567980", 10, A(2));
+
+ test("123456798012345679801234567980123456798012345679801234567980", 60);
+ test("123456798012345679801234567980123456798012345679801234567980", 60, A(2));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef min_allocator<char> A;
+ typedef std::basic_string<char, std::char_traits<char>, A> S;
+
+ test("", 0);
+ test("", 0, A());
+
+ test("1", 1);
+ test("1", 1, A());
+
+ test("1234567980", 10);
+ test("1234567980", 10, A());
+
+ test("123456798012345679801234567980123456798012345679801234567980", 60);
+ test("123456798012345679801234567980123456798012345679801234567980", 60, A());
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.cons/size_char_alloc.pass.cpp b/test/std/strings/basic.string/string.cons/size_char_alloc.pass.cpp
new file mode 100644
index 000000000000..4dfe9063a23e
--- /dev/null
+++ b/test/std/strings/basic.string/string.cons/size_char_alloc.pass.cpp
@@ -0,0 +1,128 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string(size_type n, charT c, const Allocator& a = Allocator());
+
+#include <string>
+#include <stdexcept>
+#include <algorithm>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+template <class charT>
+void
+test(unsigned n, charT c)
+{
+ typedef std::basic_string<charT, std::char_traits<charT>, test_allocator<charT> > S;
+ typedef typename S::traits_type T;
+ typedef typename S::allocator_type A;
+ S s2(n, c);
+ assert(s2.__invariants());
+ assert(s2.size() == n);
+ for (unsigned i = 0; i < n; ++i)
+ assert(s2[i] == c);
+ assert(s2.get_allocator() == A());
+ assert(s2.capacity() >= s2.size());
+}
+
+template <class charT, class A>
+void
+test(unsigned n, charT c, const A& a)
+{
+ typedef std::basic_string<charT, std::char_traits<charT>, A> S;
+ typedef typename S::traits_type T;
+ S s2(n, c, a);
+ assert(s2.__invariants());
+ assert(s2.size() == n);
+ for (unsigned i = 0; i < n; ++i)
+ assert(s2[i] == c);
+ assert(s2.get_allocator() == a);
+ assert(s2.capacity() >= s2.size());
+}
+
+template <class Tp>
+void
+test(Tp n, Tp c)
+{
+ typedef char charT;
+ typedef std::basic_string<charT, std::char_traits<charT>, test_allocator<charT> > S;
+ typedef typename S::traits_type T;
+ typedef typename S::allocator_type A;
+ S s2(n, c);
+ assert(s2.__invariants());
+ assert(s2.size() == n);
+ for (unsigned i = 0; i < n; ++i)
+ assert(s2[i] == c);
+ assert(s2.get_allocator() == A());
+ assert(s2.capacity() >= s2.size());
+}
+
+template <class Tp, class A>
+void
+test(Tp n, Tp c, const A& a)
+{
+ typedef char charT;
+ typedef std::basic_string<charT, std::char_traits<charT>, A> S;
+ typedef typename S::traits_type T;
+ S s2(n, c, a);
+ assert(s2.__invariants());
+ assert(s2.size() == n);
+ for (unsigned i = 0; i < n; ++i)
+ assert(s2[i] == c);
+ assert(s2.get_allocator() == a);
+ assert(s2.capacity() >= s2.size());
+}
+
+int main()
+{
+ {
+ typedef test_allocator<char> A;
+ typedef std::basic_string<char, std::char_traits<char>, A> S;
+
+ test(0, 'a');
+ test(0, 'a', A(2));
+
+ test(1, 'a');
+ test(1, 'a', A(2));
+
+ test(10, 'a');
+ test(10, 'a', A(2));
+
+ test(100, 'a');
+ test(100, 'a', A(2));
+
+ test(100, 65);
+ test(100, 65, A(3));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef min_allocator<char> A;
+ typedef std::basic_string<char, std::char_traits<char>, A> S;
+
+ test(0, 'a');
+ test(0, 'a', A());
+
+ test(1, 'a');
+ test(1, 'a', A());
+
+ test(10, 'a');
+ test(10, 'a', A());
+
+ test(100, 'a');
+ test(100, 'a', A());
+
+ test(100, 65);
+ test(100, 65, A());
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.cons/substr.pass.cpp b/test/std/strings/basic.string/string.cons/substr.pass.cpp
new file mode 100644
index 000000000000..2a9bf2ac88bb
--- /dev/null
+++ b/test/std/strings/basic.string/string.cons/substr.pass.cpp
@@ -0,0 +1,173 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string(const basic_string<charT,traits,Allocator>& str,
+// size_type pos, size_type n = npos,
+// const Allocator& a = Allocator());
+
+#include <string>
+#include <stdexcept>
+#include <algorithm>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S str, unsigned pos)
+{
+ typedef typename S::traits_type T;
+ typedef typename S::allocator_type A;
+ try
+ {
+ S s2(str, pos);
+ assert(s2.__invariants());
+ assert(pos <= str.size());
+ unsigned rlen = str.size() - pos;
+ assert(s2.size() == rlen);
+ assert(T::compare(s2.data(), str.data() + pos, rlen) == 0);
+ assert(s2.get_allocator() == A());
+ assert(s2.capacity() >= s2.size());
+ }
+ catch (std::out_of_range&)
+ {
+ assert(pos > str.size());
+ }
+}
+
+template <class S>
+void
+test(S str, unsigned pos, unsigned n)
+{
+ typedef typename S::traits_type T;
+ typedef typename S::allocator_type A;
+ try
+ {
+ S s2(str, pos, n);
+ assert(s2.__invariants());
+ assert(pos <= str.size());
+ unsigned rlen = std::min<unsigned>(str.size() - pos, n);
+ assert(s2.size() == rlen);
+ assert(T::compare(s2.data(), str.data() + pos, rlen) == 0);
+ assert(s2.get_allocator() == A());
+ assert(s2.capacity() >= s2.size());
+ }
+ catch (std::out_of_range&)
+ {
+ assert(pos > str.size());
+ }
+}
+
+template <class S>
+void
+test(S str, unsigned pos, unsigned n, const typename S::allocator_type& a)
+{
+ typedef typename S::traits_type T;
+ typedef typename S::allocator_type A;
+ try
+ {
+ S s2(str, pos, n, a);
+ assert(s2.__invariants());
+ assert(pos <= str.size());
+ unsigned rlen = std::min<unsigned>(str.size() - pos, n);
+ assert(s2.size() == rlen);
+ assert(T::compare(s2.data(), str.data() + pos, rlen) == 0);
+ assert(s2.get_allocator() == a);
+ assert(s2.capacity() >= s2.size());
+ }
+ catch (std::out_of_range&)
+ {
+ assert(pos > str.size());
+ }
+}
+
+int main()
+{
+ {
+ typedef test_allocator<char> A;
+ typedef std::basic_string<char, std::char_traits<char>, A> S;
+
+ test(S(A(3)), 0);
+ test(S(A(3)), 1);
+ test(S("1", A(5)), 0);
+ test(S("1", A(5)), 1);
+ test(S("1", A(5)), 2);
+ test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)), 0);
+ test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)), 5);
+ test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)), 50);
+ test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)), 500);
+
+ test(S(A(3)), 0, 0);
+ test(S(A(3)), 0, 1);
+ test(S(A(3)), 1, 0);
+ test(S(A(3)), 1, 1);
+ test(S(A(3)), 1, 2);
+ test(S("1", A(5)), 0, 0);
+ test(S("1", A(5)), 0, 1);
+ test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)), 50, 0);
+ test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)), 50, 1);
+ test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)), 50, 10);
+ test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)), 50, 100);
+
+ test(S(A(3)), 0, 0, A(4));
+ test(S(A(3)), 0, 1, A(4));
+ test(S(A(3)), 1, 0, A(4));
+ test(S(A(3)), 1, 1, A(4));
+ test(S(A(3)), 1, 2, A(4));
+ test(S("1", A(5)), 0, 0, A(6));
+ test(S("1", A(5)), 0, 1, A(6));
+ test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)), 50, 0, A(8));
+ test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)), 50, 1, A(8));
+ test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)), 50, 10, A(8));
+ test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)), 50, 100, A(8));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef min_allocator<char> A;
+ typedef std::basic_string<char, std::char_traits<char>, A> S;
+
+ test(S(A()), 0);
+ test(S(A()), 1);
+ test(S("1", A()), 0);
+ test(S("1", A()), 1);
+ test(S("1", A()), 2);
+ test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()), 0);
+ test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()), 5);
+ test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()), 50);
+ test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()), 500);
+
+ test(S(A()), 0, 0);
+ test(S(A()), 0, 1);
+ test(S(A()), 1, 0);
+ test(S(A()), 1, 1);
+ test(S(A()), 1, 2);
+ test(S("1", A()), 0, 0);
+ test(S("1", A()), 0, 1);
+ test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()), 50, 0);
+ test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()), 50, 1);
+ test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()), 50, 10);
+ test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()), 50, 100);
+
+ test(S(A()), 0, 0, A());
+ test(S(A()), 0, 1, A());
+ test(S(A()), 1, 0, A());
+ test(S(A()), 1, 1, A());
+ test(S(A()), 1, 2, A());
+ test(S("1", A()), 0, 0, A());
+ test(S("1", A()), 0, 1, A());
+ test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()), 50, 0, A());
+ test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()), 50, 1, A());
+ test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()), 50, 10, A());
+ test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()), 50, 100, A());
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.iterators/begin.pass.cpp b/test/std/strings/basic.string/string.iterators/begin.pass.cpp
new file mode 100644
index 000000000000..55f2eb30f80a
--- /dev/null
+++ b/test/std/strings/basic.string/string.iterators/begin.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// iterator begin();
+// const_iterator begin() const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s)
+{
+ const S& cs = s;
+ typename S::iterator b = s.begin();
+ typename S::const_iterator cb = cs.begin();
+ if (!s.empty())
+ {
+ assert(*b == s[0]);
+ }
+ assert(b == cb);
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test(S());
+ test(S("123"));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S());
+ test(S("123"));
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.iterators/cbegin.pass.cpp b/test/std/strings/basic.string/string.iterators/cbegin.pass.cpp
new file mode 100644
index 000000000000..d0c6ddbb9508
--- /dev/null
+++ b/test/std/strings/basic.string/string.iterators/cbegin.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// const_iterator cbegin() const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& s)
+{
+ typename S::const_iterator cb = s.cbegin();
+ if (!s.empty())
+ {
+ assert(*cb == s[0]);
+ }
+ assert(cb == s.begin());
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test(S());
+ test(S("123"));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S());
+ test(S("123"));
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.iterators/cend.pass.cpp b/test/std/strings/basic.string/string.iterators/cend.pass.cpp
new file mode 100644
index 000000000000..6b86d263245b
--- /dev/null
+++ b/test/std/strings/basic.string/string.iterators/cend.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// const_iterator cend() const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& s)
+{
+ typename S::const_iterator ce = s.cend();
+ assert(ce == s.end());
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test(S());
+ test(S("123"));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S());
+ test(S("123"));
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.iterators/crbegin.pass.cpp b/test/std/strings/basic.string/string.iterators/crbegin.pass.cpp
new file mode 100644
index 000000000000..6f29f433f314
--- /dev/null
+++ b/test/std/strings/basic.string/string.iterators/crbegin.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// const_reverse_iterator crbegin() const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& s)
+{
+ typename S::const_reverse_iterator cb = s.crbegin();
+ if (!s.empty())
+ {
+ assert(*cb == s.back());
+ }
+ assert(cb == s.rbegin());
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test(S());
+ test(S("123"));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S());
+ test(S("123"));
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.iterators/crend.pass.cpp b/test/std/strings/basic.string/string.iterators/crend.pass.cpp
new file mode 100644
index 000000000000..1fb422c080ac
--- /dev/null
+++ b/test/std/strings/basic.string/string.iterators/crend.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// const_reverse_iterator crend() const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& s)
+{
+ typename S::const_reverse_iterator ce = s.crend();
+ assert(ce == s.rend());
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test(S());
+ test(S("123"));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S());
+ test(S("123"));
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.iterators/db_iterators_2.pass.cpp b/test/std/strings/basic.string/string.iterators/db_iterators_2.pass.cpp
new file mode 100644
index 000000000000..6cac1875ce81
--- /dev/null
+++ b/test/std/strings/basic.string/string.iterators/db_iterators_2.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// Compare iterators from different containers with <.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <string>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::string S;
+ S s1;
+ S s2;
+ bool b = s1.begin() < s2.begin();
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ S s1;
+ S s2;
+ bool b = s1.begin() < s2.begin();
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/strings/basic.string/string.iterators/db_iterators_3.pass.cpp b/test/std/strings/basic.string/string.iterators/db_iterators_3.pass.cpp
new file mode 100644
index 000000000000..d90387e3a46d
--- /dev/null
+++ b/test/std/strings/basic.string/string.iterators/db_iterators_3.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// Subtract iterators from different containers with <.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <string>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::string S;
+ S s1;
+ S s2;
+ int i = s1.begin() - s2.begin();
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ S s1;
+ S s2;
+ int i = s1.begin() - s2.begin();
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/strings/basic.string/string.iterators/db_iterators_4.pass.cpp b/test/std/strings/basic.string/string.iterators/db_iterators_4.pass.cpp
new file mode 100644
index 000000000000..c4a2d0a4baf6
--- /dev/null
+++ b/test/std/strings/basic.string/string.iterators/db_iterators_4.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// Index iterator out of bounds.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <string>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::string C;
+ C c(1, '\0');
+ C::iterator i = c.begin();
+ assert(i[0] == 0);
+ assert(i[1] == 0);
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> C;
+ C c(1, '\0');
+ C::iterator i = c.begin();
+ assert(i[0] == 0);
+ assert(i[1] == 0);
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/strings/basic.string/string.iterators/db_iterators_5.pass.cpp b/test/std/strings/basic.string/string.iterators/db_iterators_5.pass.cpp
new file mode 100644
index 000000000000..ce44cb1ba5b4
--- /dev/null
+++ b/test/std/strings/basic.string/string.iterators/db_iterators_5.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// Add to iterator out of bounds.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <string>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::string C;
+ C c(1, '\0');
+ C::iterator i = c.begin();
+ i += 1;
+ assert(i == c.end());
+ i = c.begin();
+ i += 2;
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> C;
+ C c(1, '\0');
+ C::iterator i = c.begin();
+ i += 1;
+ assert(i == c.end());
+ i = c.begin();
+ i += 2;
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/strings/basic.string/string.iterators/db_iterators_6.pass.cpp b/test/std/strings/basic.string/string.iterators/db_iterators_6.pass.cpp
new file mode 100644
index 000000000000..8fab8babc613
--- /dev/null
+++ b/test/std/strings/basic.string/string.iterators/db_iterators_6.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// Decrement iterator prior to begin.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <string>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::string C;
+ C c(1, '\0');
+ C::iterator i = c.end();
+ --i;
+ assert(i == c.begin());
+ --i;
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> C;
+ C c(1, '\0');
+ C::iterator i = c.end();
+ --i;
+ assert(i == c.begin());
+ --i;
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/strings/basic.string/string.iterators/db_iterators_7.pass.cpp b/test/std/strings/basic.string/string.iterators/db_iterators_7.pass.cpp
new file mode 100644
index 000000000000..d1cac07e222b
--- /dev/null
+++ b/test/std/strings/basic.string/string.iterators/db_iterators_7.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// Increment iterator past end.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <string>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::string C;
+ C c(1, '\0');
+ C::iterator i = c.begin();
+ ++i;
+ assert(i == c.end());
+ ++i;
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> C;
+ C c(1, '\0');
+ C::iterator i = c.begin();
+ ++i;
+ assert(i == c.end());
+ ++i;
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/strings/basic.string/string.iterators/db_iterators_8.pass.cpp b/test/std/strings/basic.string/string.iterators/db_iterators_8.pass.cpp
new file mode 100644
index 000000000000..914c77d48c5c
--- /dev/null
+++ b/test/std/strings/basic.string/string.iterators/db_iterators_8.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// Dereference non-dereferenceable iterator.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <string>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::string C;
+ C c(1, '\0');
+ C::iterator i = c.end();
+ char j = *i;
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> C;
+ C c(1, '\0');
+ C::iterator i = c.end();
+ char j = *i;
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/strings/basic.string/string.iterators/end.pass.cpp b/test/std/strings/basic.string/string.iterators/end.pass.cpp
new file mode 100644
index 000000000000..02180bbd73de
--- /dev/null
+++ b/test/std/strings/basic.string/string.iterators/end.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// iterator end();
+// const_iterator end() const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s)
+{
+ const S& cs = s;
+ typename S::iterator e = s.end();
+ typename S::const_iterator ce = cs.end();
+ if (s.empty())
+ {
+ assert(e == s.begin());
+ assert(ce == cs.begin());
+ }
+ assert(e - s.begin() == s.size());
+ assert(ce - cs.begin() == cs.size());
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test(S());
+ test(S("123"));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S());
+ test(S("123"));
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.iterators/iterators.pass.cpp b/test/std/strings/basic.string/string.iterators/iterators.pass.cpp
new file mode 100644
index 000000000000..386cededa53f
--- /dev/null
+++ b/test/std/strings/basic.string/string.iterators/iterators.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// iterator begin();
+// iterator end();
+// const_iterator begin() const;
+// const_iterator end() const;
+// const_iterator cbegin() const;
+// const_iterator cend() const;
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ { // N3644 testing
+ typedef std::string C;
+ C::iterator ii1{}, ii2{};
+ C::iterator ii4 = ii1;
+ C::const_iterator cii{};
+ assert ( ii1 == ii2 );
+ assert ( ii1 == ii4 );
+ assert ( ii1 == cii );
+ assert ( !(ii1 != ii2 ));
+ assert ( !(ii1 != cii ));
+ }
+
+ { // N3644 testing
+ typedef std::wstring C;
+ C::iterator ii1{}, ii2{};
+ C::iterator ii4 = ii1;
+ C::const_iterator cii{};
+ assert ( ii1 == ii2 );
+ assert ( ii1 == ii4 );
+ assert ( ii1 == cii );
+ assert ( !(ii1 != ii2 ));
+ assert ( !(ii1 != cii ));
+ }
+
+ { // N3644 testing
+ typedef std::u16string C;
+ C::iterator ii1{}, ii2{};
+ C::iterator ii4 = ii1;
+ C::const_iterator cii{};
+ assert ( ii1 == ii2 );
+ assert ( ii1 == ii4 );
+ assert ( ii1 == cii );
+ assert ( !(ii1 != ii2 ));
+ assert ( !(ii1 != cii ));
+ }
+
+ { // N3644 testing
+ typedef std::u32string C;
+ C::iterator ii1{}, ii2{};
+ C::iterator ii4 = ii1;
+ C::const_iterator cii{};
+ assert ( ii1 == ii2 );
+ assert ( ii1 == ii4 );
+ assert ( ii1 == cii );
+ assert ( !(ii1 != ii2 ));
+ assert ( !(ii1 != cii ));
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.iterators/rbegin.pass.cpp b/test/std/strings/basic.string/string.iterators/rbegin.pass.cpp
new file mode 100644
index 000000000000..0111ad113638
--- /dev/null
+++ b/test/std/strings/basic.string/string.iterators/rbegin.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// reverse_iterator rbegin();
+// const_reverse_iterator rbegin() const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s)
+{
+ const S& cs = s;
+ typename S::reverse_iterator b = s.rbegin();
+ typename S::const_reverse_iterator cb = cs.rbegin();
+ if (!s.empty())
+ {
+ assert(*b == s.back());
+ }
+ assert(b == cb);
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test(S());
+ test(S("123"));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S());
+ test(S("123"));
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.iterators/rend.pass.cpp b/test/std/strings/basic.string/string.iterators/rend.pass.cpp
new file mode 100644
index 000000000000..750173dc342e
--- /dev/null
+++ b/test/std/strings/basic.string/string.iterators/rend.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// reverse_iterator rend();
+// const_reverse_iterator rend() const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s)
+{
+ const S& cs = s;
+ typename S::reverse_iterator e = s.rend();
+ typename S::const_reverse_iterator ce = cs.rend();
+ if (s.empty())
+ {
+ assert(e == s.rbegin());
+ assert(ce == cs.rbegin());
+ }
+ assert(e - s.rbegin() == s.size());
+ assert(ce - cs.rbegin() == cs.size());
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test(S());
+ test(S("123"));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S());
+ test(S("123"));
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.modifiers/nothing_to_do.pass.cpp b/test/std/strings/basic.string/string.modifiers/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/strings/basic.string/string.modifiers/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/strings/basic.string/string.modifiers/string_append/initializer_list.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_append/initializer_list.pass.cpp
new file mode 100644
index 000000000000..fb28e498c321
--- /dev/null
+++ b/test/std/strings/basic.string/string.modifiers/string_append/initializer_list.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string& append(initializer_list<charT> il);
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ std::string s("123");
+ s.append({'a', 'b', 'c'});
+ assert(s == "123abc");
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ S s("123");
+ s.append({'a', 'b', 'c'});
+ assert(s == "123abc");
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/strings/basic.string/string.modifiers/string_append/iterator.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_append/iterator.pass.cpp
new file mode 100644
index 000000000000..3bf2afa25521
--- /dev/null
+++ b/test/std/strings/basic.string/string.modifiers/string_append/iterator.pass.cpp
@@ -0,0 +1,150 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class InputIterator>
+// basic_string& append(InputIterator first, InputIterator last);
+
+#include <string>
+#include <cassert>
+
+#include "../../input_iterator.h"
+#include "min_allocator.h"
+
+template <class S, class It>
+void
+test(S s, It first, It last, S expected)
+{
+ s.append(first, last);
+ assert(s.__invariants());
+ assert(s == expected);
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ const char* s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
+ test(S(), s, s, S());
+ test(S(), s, s+1, S("A"));
+ test(S(), s, s+10, S("ABCDEFGHIJ"));
+ test(S(), s, s+52, S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+ test(S("12345"), s, s, S("12345"));
+ test(S("12345"), s, s+1, S("12345A"));
+ test(S("12345"), s, s+10, S("12345ABCDEFGHIJ"));
+ test(S("12345"), s, s+52, S("12345ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+ test(S("1234567890"), s, s, S("1234567890"));
+ test(S("1234567890"), s, s+1, S("1234567890A"));
+ test(S("1234567890"), s, s+10, S("1234567890ABCDEFGHIJ"));
+ test(S("1234567890"), s, s+52, S("1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+ test(S("12345678901234567890"), s, s, S("12345678901234567890"));
+ test(S("12345678901234567890"), s, s+1, S("12345678901234567890""A"));
+ test(S("12345678901234567890"), s, s+10, S("12345678901234567890""ABCDEFGHIJ"));
+ test(S("12345678901234567890"), s, s+52,
+ S("12345678901234567890""ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+ test(S(), input_iterator<const char*>(s), input_iterator<const char*>(s), S());
+ test(S(), input_iterator<const char*>(s), input_iterator<const char*>(s+1), S("A"));
+ test(S(), input_iterator<const char*>(s), input_iterator<const char*>(s+10),
+ S("ABCDEFGHIJ"));
+ test(S(), input_iterator<const char*>(s), input_iterator<const char*>(s+52),
+ S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+ test(S("12345"), input_iterator<const char*>(s), input_iterator<const char*>(s),
+ S("12345"));
+ test(S("12345"), input_iterator<const char*>(s), input_iterator<const char*>(s+1),
+ S("12345A"));
+ test(S("12345"), input_iterator<const char*>(s), input_iterator<const char*>(s+10),
+ S("12345ABCDEFGHIJ"));
+ test(S("12345"), input_iterator<const char*>(s), input_iterator<const char*>(s+52),
+ S("12345ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+ test(S("1234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s),
+ S("1234567890"));
+ test(S("1234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+1),
+ S("1234567890A"));
+ test(S("1234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+10),
+ S("1234567890ABCDEFGHIJ"));
+ test(S("1234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+52),
+ S("1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+ test(S("12345678901234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s),
+ S("12345678901234567890"));
+ test(S("12345678901234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+1),
+ S("12345678901234567890""A"));
+ test(S("12345678901234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+10),
+ S("12345678901234567890""ABCDEFGHIJ"));
+ test(S("12345678901234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+52),
+ S("12345678901234567890""ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ const char* s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
+ test(S(), s, s, S());
+ test(S(), s, s+1, S("A"));
+ test(S(), s, s+10, S("ABCDEFGHIJ"));
+ test(S(), s, s+52, S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+ test(S("12345"), s, s, S("12345"));
+ test(S("12345"), s, s+1, S("12345A"));
+ test(S("12345"), s, s+10, S("12345ABCDEFGHIJ"));
+ test(S("12345"), s, s+52, S("12345ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+ test(S("1234567890"), s, s, S("1234567890"));
+ test(S("1234567890"), s, s+1, S("1234567890A"));
+ test(S("1234567890"), s, s+10, S("1234567890ABCDEFGHIJ"));
+ test(S("1234567890"), s, s+52, S("1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+ test(S("12345678901234567890"), s, s, S("12345678901234567890"));
+ test(S("12345678901234567890"), s, s+1, S("12345678901234567890""A"));
+ test(S("12345678901234567890"), s, s+10, S("12345678901234567890""ABCDEFGHIJ"));
+ test(S("12345678901234567890"), s, s+52,
+ S("12345678901234567890""ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+ test(S(), input_iterator<const char*>(s), input_iterator<const char*>(s), S());
+ test(S(), input_iterator<const char*>(s), input_iterator<const char*>(s+1), S("A"));
+ test(S(), input_iterator<const char*>(s), input_iterator<const char*>(s+10),
+ S("ABCDEFGHIJ"));
+ test(S(), input_iterator<const char*>(s), input_iterator<const char*>(s+52),
+ S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+ test(S("12345"), input_iterator<const char*>(s), input_iterator<const char*>(s),
+ S("12345"));
+ test(S("12345"), input_iterator<const char*>(s), input_iterator<const char*>(s+1),
+ S("12345A"));
+ test(S("12345"), input_iterator<const char*>(s), input_iterator<const char*>(s+10),
+ S("12345ABCDEFGHIJ"));
+ test(S("12345"), input_iterator<const char*>(s), input_iterator<const char*>(s+52),
+ S("12345ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+ test(S("1234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s),
+ S("1234567890"));
+ test(S("1234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+1),
+ S("1234567890A"));
+ test(S("1234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+10),
+ S("1234567890ABCDEFGHIJ"));
+ test(S("1234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+52),
+ S("1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+ test(S("12345678901234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s),
+ S("12345678901234567890"));
+ test(S("12345678901234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+1),
+ S("12345678901234567890""A"));
+ test(S("12345678901234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+10),
+ S("12345678901234567890""ABCDEFGHIJ"));
+ test(S("12345678901234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+52),
+ S("12345678901234567890""ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.modifiers/string_append/pointer.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_append/pointer.pass.cpp
new file mode 100644
index 000000000000..5ae15f0a0a4a
--- /dev/null
+++ b/test/std/strings/basic.string/string.modifiers/string_append/pointer.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string<charT,traits,Allocator>& append(const charT* s);
+
+#include <string>
+#include <stdexcept>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s, const typename S::value_type* str, S expected)
+{
+ s.append(str);
+ assert(s.__invariants());
+ assert(s == expected);
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test(S(), "", S());
+ test(S(), "12345", S("12345"));
+ test(S(), "12345678901234567890", S("12345678901234567890"));
+
+ test(S("12345"), "", S("12345"));
+ test(S("12345"), "12345", S("1234512345"));
+ test(S("12345"), "1234567890", S("123451234567890"));
+
+ test(S("12345678901234567890"), "", S("12345678901234567890"));
+ test(S("12345678901234567890"), "12345", S("1234567890123456789012345"));
+ test(S("12345678901234567890"), "12345678901234567890",
+ S("1234567890123456789012345678901234567890"));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S(), "", S());
+ test(S(), "12345", S("12345"));
+ test(S(), "12345678901234567890", S("12345678901234567890"));
+
+ test(S("12345"), "", S("12345"));
+ test(S("12345"), "12345", S("1234512345"));
+ test(S("12345"), "1234567890", S("123451234567890"));
+
+ test(S("12345678901234567890"), "", S("12345678901234567890"));
+ test(S("12345678901234567890"), "12345", S("1234567890123456789012345"));
+ test(S("12345678901234567890"), "12345678901234567890",
+ S("1234567890123456789012345678901234567890"));
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.modifiers/string_append/pointer_size.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_append/pointer_size.pass.cpp
new file mode 100644
index 000000000000..5a9e8e2b814b
--- /dev/null
+++ b/test/std/strings/basic.string/string.modifiers/string_append/pointer_size.pass.cpp
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string<charT,traits,Allocator>&
+// append(const charT* s, size_type n);
+
+#include <string>
+#include <stdexcept>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s, const typename S::value_type* str, typename S::size_type n, S expected)
+{
+ s.append(str, n);
+ assert(s.__invariants());
+ assert(s == expected);
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test(S(), "", 0, S());
+ test(S(), "12345", 3, S("123"));
+ test(S(), "12345", 4, S("1234"));
+ test(S(), "12345678901234567890", 0, S());
+ test(S(), "12345678901234567890", 1, S("1"));
+ test(S(), "12345678901234567890", 3, S("123"));
+ test(S(), "12345678901234567890", 20, S("12345678901234567890"));
+
+ test(S("12345"), "", 0, S("12345"));
+ test(S("12345"), "12345", 5, S("1234512345"));
+ test(S("12345"), "1234567890", 10, S("123451234567890"));
+
+ test(S("12345678901234567890"), "", 0, S("12345678901234567890"));
+ test(S("12345678901234567890"), "12345", 5, S("1234567890123456789012345"));
+ test(S("12345678901234567890"), "12345678901234567890", 20,
+ S("1234567890123456789012345678901234567890"));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S(), "", 0, S());
+ test(S(), "12345", 3, S("123"));
+ test(S(), "12345", 4, S("1234"));
+ test(S(), "12345678901234567890", 0, S());
+ test(S(), "12345678901234567890", 1, S("1"));
+ test(S(), "12345678901234567890", 3, S("123"));
+ test(S(), "12345678901234567890", 20, S("12345678901234567890"));
+
+ test(S("12345"), "", 0, S("12345"));
+ test(S("12345"), "12345", 5, S("1234512345"));
+ test(S("12345"), "1234567890", 10, S("123451234567890"));
+
+ test(S("12345678901234567890"), "", 0, S("12345678901234567890"));
+ test(S("12345678901234567890"), "12345", 5, S("1234567890123456789012345"));
+ test(S("12345678901234567890"), "12345678901234567890", 20,
+ S("1234567890123456789012345678901234567890"));
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.modifiers/string_append/push_back.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_append/push_back.pass.cpp
new file mode 100644
index 000000000000..b0a2eb5e5cbd
--- /dev/null
+++ b/test/std/strings/basic.string/string.modifiers/string_append/push_back.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// void push_back(charT c)
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s, typename S::value_type c, S expected)
+{
+ s.push_back(c);
+ assert(s.__invariants());
+ assert(s == expected);
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test(S(), 'a', S(1, 'a'));
+ test(S("12345"), 'a', S("12345a"));
+ test(S("12345678901234567890"), 'a', S("12345678901234567890a"));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S(), 'a', S(1, 'a'));
+ test(S("12345"), 'a', S("12345a"));
+ test(S("12345678901234567890"), 'a', S("12345678901234567890a"));
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.modifiers/string_append/size_char.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_append/size_char.pass.cpp
new file mode 100644
index 000000000000..00e6ae375cce
--- /dev/null
+++ b/test/std/strings/basic.string/string.modifiers/string_append/size_char.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string<charT,traits,Allocator>&
+// append(size_type n, charT c);
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s, typename S::size_type n, typename S::value_type c, S expected)
+{
+ s.append(n, c);
+ assert(s.__invariants());
+ assert(s == expected);
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test(S(), 0, 'a', S());
+ test(S(), 1, 'a', S(1, 'a'));
+ test(S(), 10, 'a', S(10, 'a'));
+ test(S(), 100, 'a', S(100, 'a'));
+
+ test(S("12345"), 0, 'a', S("12345"));
+ test(S("12345"), 1, 'a', S("12345a"));
+ test(S("12345"), 10, 'a', S("12345aaaaaaaaaa"));
+
+ test(S("12345678901234567890"), 0, 'a', S("12345678901234567890"));
+ test(S("12345678901234567890"), 1, 'a', S("12345678901234567890a"));
+ test(S("12345678901234567890"), 10, 'a', S("12345678901234567890aaaaaaaaaa"));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S(), 0, 'a', S());
+ test(S(), 1, 'a', S(1, 'a'));
+ test(S(), 10, 'a', S(10, 'a'));
+ test(S(), 100, 'a', S(100, 'a'));
+
+ test(S("12345"), 0, 'a', S("12345"));
+ test(S("12345"), 1, 'a', S("12345a"));
+ test(S("12345"), 10, 'a', S("12345aaaaaaaaaa"));
+
+ test(S("12345678901234567890"), 0, 'a', S("12345678901234567890"));
+ test(S("12345678901234567890"), 1, 'a', S("12345678901234567890a"));
+ test(S("12345678901234567890"), 10, 'a', S("12345678901234567890aaaaaaaaaa"));
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.modifiers/string_append/string.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_append/string.pass.cpp
new file mode 100644
index 000000000000..31f174b4f305
--- /dev/null
+++ b/test/std/strings/basic.string/string.modifiers/string_append/string.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string<charT,traits,Allocator>&
+// append(const basic_string<charT,traits>& str);
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s, S str, S expected)
+{
+ s.append(str);
+ assert(s.__invariants());
+ assert(s == expected);
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test(S(), S(), S());
+ test(S(), S("12345"), S("12345"));
+ test(S(), S("1234567890"), S("1234567890"));
+ test(S(), S("12345678901234567890"), S("12345678901234567890"));
+
+ test(S("12345"), S(), S("12345"));
+ test(S("12345"), S("12345"), S("1234512345"));
+ test(S("12345"), S("1234567890"), S("123451234567890"));
+ test(S("12345"), S("12345678901234567890"), S("1234512345678901234567890"));
+
+ test(S("1234567890"), S(), S("1234567890"));
+ test(S("1234567890"), S("12345"), S("123456789012345"));
+ test(S("1234567890"), S("1234567890"), S("12345678901234567890"));
+ test(S("1234567890"), S("12345678901234567890"), S("123456789012345678901234567890"));
+
+ test(S("12345678901234567890"), S(), S("12345678901234567890"));
+ test(S("12345678901234567890"), S("12345"), S("1234567890123456789012345"));
+ test(S("12345678901234567890"), S("1234567890"), S("123456789012345678901234567890"));
+ test(S("12345678901234567890"), S("12345678901234567890"),
+ S("1234567890123456789012345678901234567890"));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S(), S(), S());
+ test(S(), S("12345"), S("12345"));
+ test(S(), S("1234567890"), S("1234567890"));
+ test(S(), S("12345678901234567890"), S("12345678901234567890"));
+
+ test(S("12345"), S(), S("12345"));
+ test(S("12345"), S("12345"), S("1234512345"));
+ test(S("12345"), S("1234567890"), S("123451234567890"));
+ test(S("12345"), S("12345678901234567890"), S("1234512345678901234567890"));
+
+ test(S("1234567890"), S(), S("1234567890"));
+ test(S("1234567890"), S("12345"), S("123456789012345"));
+ test(S("1234567890"), S("1234567890"), S("12345678901234567890"));
+ test(S("1234567890"), S("12345678901234567890"), S("123456789012345678901234567890"));
+
+ test(S("12345678901234567890"), S(), S("12345678901234567890"));
+ test(S("12345678901234567890"), S("12345"), S("1234567890123456789012345"));
+ test(S("12345678901234567890"), S("1234567890"), S("123456789012345678901234567890"));
+ test(S("12345678901234567890"), S("12345678901234567890"),
+ S("1234567890123456789012345678901234567890"));
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.modifiers/string_append/string_size_size.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_append/string_size_size.pass.cpp
new file mode 100644
index 000000000000..e8f54f475240
--- /dev/null
+++ b/test/std/strings/basic.string/string.modifiers/string_append/string_size_size.pass.cpp
@@ -0,0 +1,118 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string<charT,traits,Allocator>&
+// append(const basic_string<charT,traits>& str, size_type pos, size_type n = npos);
+// the "= npos" was added for C++14
+
+#include <string>
+#include <stdexcept>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s, S str, typename S::size_type pos, typename S::size_type n, S expected)
+{
+ try
+ {
+ s.append(str, pos, n);
+ assert(s.__invariants());
+ assert(pos <= str.size());
+ assert(s == expected);
+ }
+ catch (std::out_of_range&)
+ {
+ assert(pos > str.size());
+ }
+}
+
+template <class S>
+void
+test_npos(S s, S str, typename S::size_type pos, S expected)
+{
+ try
+ {
+ s.append(str, pos);
+ assert(s.__invariants());
+ assert(pos <= str.size());
+ assert(s == expected);
+ }
+ catch (std::out_of_range&)
+ {
+ assert(pos > str.size());
+ }
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test(S(), S(), 0, 0, S());
+ test(S(), S(), 1, 0, S());
+ test(S(), S("12345"), 0, 3, S("123"));
+ test(S(), S("12345"), 1, 4, S("2345"));
+ test(S(), S("12345"), 3, 15, S("45"));
+ test(S(), S("12345"), 5, 15, S(""));
+ test(S(), S("12345"), 6, 15, S("not happening"));
+ test(S(), S("12345678901234567890"), 0, 0, S());
+ test(S(), S("12345678901234567890"), 1, 1, S("2"));
+ test(S(), S("12345678901234567890"), 2, 3, S("345"));
+ test(S(), S("12345678901234567890"), 12, 13, S("34567890"));
+ test(S(), S("12345678901234567890"), 21, 13, S("not happening"));
+
+ test(S("12345"), S(), 0, 0, S("12345"));
+ test(S("12345"), S("12345"), 2, 2, S("1234534"));
+ test(S("12345"), S("1234567890"), 0, 100, S("123451234567890"));
+
+ test(S("12345678901234567890"), S(), 0, 0, S("12345678901234567890"));
+ test(S("12345678901234567890"), S("12345"), 1, 3, S("12345678901234567890234"));
+ test(S("12345678901234567890"), S("12345678901234567890"), 5, 10,
+ S("123456789012345678906789012345"));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S(), S(), 0, 0, S());
+ test(S(), S(), 1, 0, S());
+ test(S(), S("12345"), 0, 3, S("123"));
+ test(S(), S("12345"), 1, 4, S("2345"));
+ test(S(), S("12345"), 3, 15, S("45"));
+ test(S(), S("12345"), 5, 15, S(""));
+ test(S(), S("12345"), 6, 15, S("not happening"));
+ test(S(), S("12345678901234567890"), 0, 0, S());
+ test(S(), S("12345678901234567890"), 1, 1, S("2"));
+ test(S(), S("12345678901234567890"), 2, 3, S("345"));
+ test(S(), S("12345678901234567890"), 12, 13, S("34567890"));
+ test(S(), S("12345678901234567890"), 21, 13, S("not happening"));
+
+ test(S("12345"), S(), 0, 0, S("12345"));
+ test(S("12345"), S("12345"), 2, 2, S("1234534"));
+ test(S("12345"), S("1234567890"), 0, 100, S("123451234567890"));
+
+ test(S("12345678901234567890"), S(), 0, 0, S("12345678901234567890"));
+ test(S("12345678901234567890"), S("12345"), 1, 3, S("12345678901234567890234"));
+ test(S("12345678901234567890"), S("12345678901234567890"), 5, 10,
+ S("123456789012345678906789012345"));
+ }
+#endif
+ {
+ typedef std::string S;
+ test_npos(S(), S(), 0, S());
+ test_npos(S(), S(), 1, S());
+ test_npos(S(), S("12345"), 0, S("12345"));
+ test_npos(S(), S("12345"), 1, S("2345"));
+ test_npos(S(), S("12345"), 3, S("45"));
+ test_npos(S(), S("12345"), 5, S(""));
+ test_npos(S(), S("12345"), 6, S("not happening"));
+ }
+}
diff --git a/test/std/strings/basic.string/string.modifiers/string_assign/initializer_list.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_assign/initializer_list.pass.cpp
new file mode 100644
index 000000000000..2dae10745965
--- /dev/null
+++ b/test/std/strings/basic.string/string.modifiers/string_assign/initializer_list.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string& assign(initializer_list<charT> il);
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ std::string s("123");
+ s.assign({'a', 'b', 'c'});
+ assert(s == "abc");
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ S s("123");
+ s.assign({'a', 'b', 'c'});
+ assert(s == "abc");
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/strings/basic.string/string.modifiers/string_assign/iterator.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_assign/iterator.pass.cpp
new file mode 100644
index 000000000000..83b5dd14b3f6
--- /dev/null
+++ b/test/std/strings/basic.string/string.modifiers/string_assign/iterator.pass.cpp
@@ -0,0 +1,150 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class InputIterator>
+// basic_string& assign(InputIterator first, InputIterator last);
+
+#include <string>
+#include <cassert>
+
+#include "../../input_iterator.h"
+#include "min_allocator.h"
+
+template <class S, class It>
+void
+test(S s, It first, It last, S expected)
+{
+ s.assign(first, last);
+ assert(s.__invariants());
+ assert(s == expected);
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ const char* s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
+ test(S(), s, s, S());
+ test(S(), s, s+1, S("A"));
+ test(S(), s, s+10, S("ABCDEFGHIJ"));
+ test(S(), s, s+52, S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+ test(S("12345"), s, s, S());
+ test(S("12345"), s, s+1, S("A"));
+ test(S("12345"), s, s+10, S("ABCDEFGHIJ"));
+ test(S("12345"), s, s+52, S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+ test(S("1234567890"), s, s, S());
+ test(S("1234567890"), s, s+1, S("A"));
+ test(S("1234567890"), s, s+10, S("ABCDEFGHIJ"));
+ test(S("1234567890"), s, s+52, S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+ test(S("12345678901234567890"), s, s, S());
+ test(S("12345678901234567890"), s, s+1, S("A"));
+ test(S("12345678901234567890"), s, s+10, S("ABCDEFGHIJ"));
+ test(S("12345678901234567890"), s, s+52,
+ S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+ test(S(), input_iterator<const char*>(s), input_iterator<const char*>(s), S());
+ test(S(), input_iterator<const char*>(s), input_iterator<const char*>(s+1), S("A"));
+ test(S(), input_iterator<const char*>(s), input_iterator<const char*>(s+10),
+ S("ABCDEFGHIJ"));
+ test(S(), input_iterator<const char*>(s), input_iterator<const char*>(s+52),
+ S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+ test(S("12345"), input_iterator<const char*>(s), input_iterator<const char*>(s),
+ S());
+ test(S("12345"), input_iterator<const char*>(s), input_iterator<const char*>(s+1),
+ S("A"));
+ test(S("12345"), input_iterator<const char*>(s), input_iterator<const char*>(s+10),
+ S("ABCDEFGHIJ"));
+ test(S("12345"), input_iterator<const char*>(s), input_iterator<const char*>(s+52),
+ S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+ test(S("1234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s),
+ S());
+ test(S("1234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+1),
+ S("A"));
+ test(S("1234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+10),
+ S("ABCDEFGHIJ"));
+ test(S("1234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+52),
+ S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+ test(S("12345678901234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s),
+ S());
+ test(S("12345678901234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+1),
+ S("A"));
+ test(S("12345678901234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+10),
+ S("ABCDEFGHIJ"));
+ test(S("12345678901234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+52),
+ S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ const char* s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
+ test(S(), s, s, S());
+ test(S(), s, s+1, S("A"));
+ test(S(), s, s+10, S("ABCDEFGHIJ"));
+ test(S(), s, s+52, S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+ test(S("12345"), s, s, S());
+ test(S("12345"), s, s+1, S("A"));
+ test(S("12345"), s, s+10, S("ABCDEFGHIJ"));
+ test(S("12345"), s, s+52, S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+ test(S("1234567890"), s, s, S());
+ test(S("1234567890"), s, s+1, S("A"));
+ test(S("1234567890"), s, s+10, S("ABCDEFGHIJ"));
+ test(S("1234567890"), s, s+52, S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+ test(S("12345678901234567890"), s, s, S());
+ test(S("12345678901234567890"), s, s+1, S("A"));
+ test(S("12345678901234567890"), s, s+10, S("ABCDEFGHIJ"));
+ test(S("12345678901234567890"), s, s+52,
+ S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+ test(S(), input_iterator<const char*>(s), input_iterator<const char*>(s), S());
+ test(S(), input_iterator<const char*>(s), input_iterator<const char*>(s+1), S("A"));
+ test(S(), input_iterator<const char*>(s), input_iterator<const char*>(s+10),
+ S("ABCDEFGHIJ"));
+ test(S(), input_iterator<const char*>(s), input_iterator<const char*>(s+52),
+ S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+ test(S("12345"), input_iterator<const char*>(s), input_iterator<const char*>(s),
+ S());
+ test(S("12345"), input_iterator<const char*>(s), input_iterator<const char*>(s+1),
+ S("A"));
+ test(S("12345"), input_iterator<const char*>(s), input_iterator<const char*>(s+10),
+ S("ABCDEFGHIJ"));
+ test(S("12345"), input_iterator<const char*>(s), input_iterator<const char*>(s+52),
+ S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+ test(S("1234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s),
+ S());
+ test(S("1234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+1),
+ S("A"));
+ test(S("1234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+10),
+ S("ABCDEFGHIJ"));
+ test(S("1234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+52),
+ S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+ test(S("12345678901234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s),
+ S());
+ test(S("12345678901234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+1),
+ S("A"));
+ test(S("12345678901234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+10),
+ S("ABCDEFGHIJ"));
+ test(S("12345678901234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+52),
+ S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.modifiers/string_assign/pointer.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_assign/pointer.pass.cpp
new file mode 100644
index 000000000000..adf24ac49877
--- /dev/null
+++ b/test/std/strings/basic.string/string.modifiers/string_assign/pointer.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string<charT,traits,Allocator>& assign(const charT* s);
+
+#include <string>
+#include <stdexcept>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s, const typename S::value_type* str, S expected)
+{
+ s.assign(str);
+ assert(s.__invariants());
+ assert(s == expected);
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test(S(), "", S());
+ test(S(), "12345", S("12345"));
+ test(S(), "12345678901234567890", S("12345678901234567890"));
+
+ test(S("12345"), "", S());
+ test(S("12345"), "12345", S("12345"));
+ test(S("12345"), "1234567890", S("1234567890"));
+
+ test(S("12345678901234567890"), "", S());
+ test(S("12345678901234567890"), "12345", S("12345"));
+ test(S("12345678901234567890"), "12345678901234567890",
+ S("12345678901234567890"));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S(), "", S());
+ test(S(), "12345", S("12345"));
+ test(S(), "12345678901234567890", S("12345678901234567890"));
+
+ test(S("12345"), "", S());
+ test(S("12345"), "12345", S("12345"));
+ test(S("12345"), "1234567890", S("1234567890"));
+
+ test(S("12345678901234567890"), "", S());
+ test(S("12345678901234567890"), "12345", S("12345"));
+ test(S("12345678901234567890"), "12345678901234567890",
+ S("12345678901234567890"));
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.modifiers/string_assign/pointer_size.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_assign/pointer_size.pass.cpp
new file mode 100644
index 000000000000..476fe963de73
--- /dev/null
+++ b/test/std/strings/basic.string/string.modifiers/string_assign/pointer_size.pass.cpp
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string<charT,traits,Allocator>&
+// assign(const charT* s, size_type n);
+
+#include <string>
+#include <stdexcept>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s, const typename S::value_type* str, typename S::size_type n, S expected)
+{
+ s.assign(str, n);
+ assert(s.__invariants());
+ assert(s == expected);
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test(S(), "", 0, S());
+ test(S(), "12345", 3, S("123"));
+ test(S(), "12345", 4, S("1234"));
+ test(S(), "12345678901234567890", 0, S());
+ test(S(), "12345678901234567890", 1, S("1"));
+ test(S(), "12345678901234567890", 3, S("123"));
+ test(S(), "12345678901234567890", 20, S("12345678901234567890"));
+
+ test(S("12345"), "", 0, S());
+ test(S("12345"), "12345", 5, S("12345"));
+ test(S("12345"), "1234567890", 10, S("1234567890"));
+
+ test(S("12345678901234567890"), "", 0, S());
+ test(S("12345678901234567890"), "12345", 5, S("12345"));
+ test(S("12345678901234567890"), "12345678901234567890", 20,
+ S("12345678901234567890"));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S(), "", 0, S());
+ test(S(), "12345", 3, S("123"));
+ test(S(), "12345", 4, S("1234"));
+ test(S(), "12345678901234567890", 0, S());
+ test(S(), "12345678901234567890", 1, S("1"));
+ test(S(), "12345678901234567890", 3, S("123"));
+ test(S(), "12345678901234567890", 20, S("12345678901234567890"));
+
+ test(S("12345"), "", 0, S());
+ test(S("12345"), "12345", 5, S("12345"));
+ test(S("12345"), "1234567890", 10, S("1234567890"));
+
+ test(S("12345678901234567890"), "", 0, S());
+ test(S("12345678901234567890"), "12345", 5, S("12345"));
+ test(S("12345678901234567890"), "12345678901234567890", 20,
+ S("12345678901234567890"));
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.modifiers/string_assign/rv_string.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_assign/rv_string.pass.cpp
new file mode 100644
index 000000000000..4273860f41ad
--- /dev/null
+++ b/test/std/strings/basic.string/string.modifiers/string_assign/rv_string.pass.cpp
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string<charT,traits,Allocator>&
+// assign(basic_string<charT,traits>&& str);
+
+#include <string>
+#include <utility>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s, S str, S expected)
+{
+ s.assign(std::move(str));
+ assert(s.__invariants());
+ assert(s == expected);
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test(S(), S(), S());
+ test(S(), S("12345"), S("12345"));
+ test(S(), S("1234567890"), S("1234567890"));
+ test(S(), S("12345678901234567890"), S("12345678901234567890"));
+
+ test(S("12345"), S(), S());
+ test(S("12345"), S("12345"), S("12345"));
+ test(S("12345"), S("1234567890"), S("1234567890"));
+ test(S("12345"), S("12345678901234567890"), S("12345678901234567890"));
+
+ test(S("1234567890"), S(), S());
+ test(S("1234567890"), S("12345"), S("12345"));
+ test(S("1234567890"), S("1234567890"), S("1234567890"));
+ test(S("1234567890"), S("12345678901234567890"), S("12345678901234567890"));
+
+ test(S("12345678901234567890"), S(), S());
+ test(S("12345678901234567890"), S("12345"), S("12345"));
+ test(S("12345678901234567890"), S("1234567890"), S("1234567890"));
+ test(S("12345678901234567890"), S("12345678901234567890"),
+ S("12345678901234567890"));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S(), S(), S());
+ test(S(), S("12345"), S("12345"));
+ test(S(), S("1234567890"), S("1234567890"));
+ test(S(), S("12345678901234567890"), S("12345678901234567890"));
+
+ test(S("12345"), S(), S());
+ test(S("12345"), S("12345"), S("12345"));
+ test(S("12345"), S("1234567890"), S("1234567890"));
+ test(S("12345"), S("12345678901234567890"), S("12345678901234567890"));
+
+ test(S("1234567890"), S(), S());
+ test(S("1234567890"), S("12345"), S("12345"));
+ test(S("1234567890"), S("1234567890"), S("1234567890"));
+ test(S("1234567890"), S("12345678901234567890"), S("12345678901234567890"));
+
+ test(S("12345678901234567890"), S(), S());
+ test(S("12345678901234567890"), S("12345"), S("12345"));
+ test(S("12345678901234567890"), S("1234567890"), S("1234567890"));
+ test(S("12345678901234567890"), S("12345678901234567890"),
+ S("12345678901234567890"));
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.modifiers/string_assign/size_char.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_assign/size_char.pass.cpp
new file mode 100644
index 000000000000..a8f747091c6d
--- /dev/null
+++ b/test/std/strings/basic.string/string.modifiers/string_assign/size_char.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string<charT,traits,Allocator>&
+// assign(size_type n, charT c);
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s, typename S::size_type n, typename S::value_type c, S expected)
+{
+ s.assign(n, c);
+ assert(s.__invariants());
+ assert(s == expected);
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test(S(), 0, 'a', S());
+ test(S(), 1, 'a', S(1, 'a'));
+ test(S(), 10, 'a', S(10, 'a'));
+ test(S(), 100, 'a', S(100, 'a'));
+
+ test(S("12345"), 0, 'a', S());
+ test(S("12345"), 1, 'a', S(1, 'a'));
+ test(S("12345"), 10, 'a', S(10, 'a'));
+
+ test(S("12345678901234567890"), 0, 'a', S());
+ test(S("12345678901234567890"), 1, 'a', S(1, 'a'));
+ test(S("12345678901234567890"), 10, 'a', S(10, 'a'));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S(), 0, 'a', S());
+ test(S(), 1, 'a', S(1, 'a'));
+ test(S(), 10, 'a', S(10, 'a'));
+ test(S(), 100, 'a', S(100, 'a'));
+
+ test(S("12345"), 0, 'a', S());
+ test(S("12345"), 1, 'a', S(1, 'a'));
+ test(S("12345"), 10, 'a', S(10, 'a'));
+
+ test(S("12345678901234567890"), 0, 'a', S());
+ test(S("12345678901234567890"), 1, 'a', S(1, 'a'));
+ test(S("12345678901234567890"), 10, 'a', S(10, 'a'));
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.modifiers/string_assign/string.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_assign/string.pass.cpp
new file mode 100644
index 000000000000..d7ddb77b8e0f
--- /dev/null
+++ b/test/std/strings/basic.string/string.modifiers/string_assign/string.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string<charT,traits,Allocator>&
+// assign(const basic_string<charT,traits>& str);
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s, S str, S expected)
+{
+ s.assign(str);
+ assert(s.__invariants());
+ assert(s == expected);
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test(S(), S(), S());
+ test(S(), S("12345"), S("12345"));
+ test(S(), S("1234567890"), S("1234567890"));
+ test(S(), S("12345678901234567890"), S("12345678901234567890"));
+
+ test(S("12345"), S(), S());
+ test(S("12345"), S("12345"), S("12345"));
+ test(S("12345"), S("1234567890"), S("1234567890"));
+ test(S("12345"), S("12345678901234567890"), S("12345678901234567890"));
+
+ test(S("1234567890"), S(), S());
+ test(S("1234567890"), S("12345"), S("12345"));
+ test(S("1234567890"), S("1234567890"), S("1234567890"));
+ test(S("1234567890"), S("12345678901234567890"), S("12345678901234567890"));
+
+ test(S("12345678901234567890"), S(), S());
+ test(S("12345678901234567890"), S("12345"), S("12345"));
+ test(S("12345678901234567890"), S("1234567890"), S("1234567890"));
+ test(S("12345678901234567890"), S("12345678901234567890"),
+ S("12345678901234567890"));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S(), S(), S());
+ test(S(), S("12345"), S("12345"));
+ test(S(), S("1234567890"), S("1234567890"));
+ test(S(), S("12345678901234567890"), S("12345678901234567890"));
+
+ test(S("12345"), S(), S());
+ test(S("12345"), S("12345"), S("12345"));
+ test(S("12345"), S("1234567890"), S("1234567890"));
+ test(S("12345"), S("12345678901234567890"), S("12345678901234567890"));
+
+ test(S("1234567890"), S(), S());
+ test(S("1234567890"), S("12345"), S("12345"));
+ test(S("1234567890"), S("1234567890"), S("1234567890"));
+ test(S("1234567890"), S("12345678901234567890"), S("12345678901234567890"));
+
+ test(S("12345678901234567890"), S(), S());
+ test(S("12345678901234567890"), S("12345"), S("12345"));
+ test(S("12345678901234567890"), S("1234567890"), S("1234567890"));
+ test(S("12345678901234567890"), S("12345678901234567890"),
+ S("12345678901234567890"));
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.modifiers/string_assign/string_size_size.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_assign/string_size_size.pass.cpp
new file mode 100644
index 000000000000..5f5983e76c94
--- /dev/null
+++ b/test/std/strings/basic.string/string.modifiers/string_assign/string_size_size.pass.cpp
@@ -0,0 +1,118 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string<charT,traits,Allocator>&
+// assign(const basic_string<charT,traits>& str, size_type pos, size_type n=npos);
+// the =npos was added for C++14
+
+#include <string>
+#include <stdexcept>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s, S str, typename S::size_type pos, typename S::size_type n, S expected)
+{
+ try
+ {
+ s.assign(str, pos, n);
+ assert(s.__invariants());
+ assert(pos <= str.size());
+ assert(s == expected);
+ }
+ catch (std::out_of_range&)
+ {
+ assert(pos > str.size());
+ }
+}
+
+template <class S>
+void
+test_npos(S s, S str, typename S::size_type pos, S expected)
+{
+ try
+ {
+ s.assign(str, pos);
+ assert(s.__invariants());
+ assert(pos <= str.size());
+ assert(s == expected);
+ }
+ catch (std::out_of_range&)
+ {
+ assert(pos > str.size());
+ }
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test(S(), S(), 0, 0, S());
+ test(S(), S(), 1, 0, S());
+ test(S(), S("12345"), 0, 3, S("123"));
+ test(S(), S("12345"), 1, 4, S("2345"));
+ test(S(), S("12345"), 3, 15, S("45"));
+ test(S(), S("12345"), 5, 15, S(""));
+ test(S(), S("12345"), 6, 15, S("not happening"));
+ test(S(), S("12345678901234567890"), 0, 0, S());
+ test(S(), S("12345678901234567890"), 1, 1, S("2"));
+ test(S(), S("12345678901234567890"), 2, 3, S("345"));
+ test(S(), S("12345678901234567890"), 12, 13, S("34567890"));
+ test(S(), S("12345678901234567890"), 21, 13, S("not happening"));
+
+ test(S("12345"), S(), 0, 0, S());
+ test(S("12345"), S("12345"), 2, 2, S("34"));
+ test(S("12345"), S("1234567890"), 0, 100, S("1234567890"));
+
+ test(S("12345678901234567890"), S(), 0, 0, S());
+ test(S("12345678901234567890"), S("12345"), 1, 3, S("234"));
+ test(S("12345678901234567890"), S("12345678901234567890"), 5, 10,
+ S("6789012345"));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S(), S(), 0, 0, S());
+ test(S(), S(), 1, 0, S());
+ test(S(), S("12345"), 0, 3, S("123"));
+ test(S(), S("12345"), 1, 4, S("2345"));
+ test(S(), S("12345"), 3, 15, S("45"));
+ test(S(), S("12345"), 5, 15, S(""));
+ test(S(), S("12345"), 6, 15, S("not happening"));
+ test(S(), S("12345678901234567890"), 0, 0, S());
+ test(S(), S("12345678901234567890"), 1, 1, S("2"));
+ test(S(), S("12345678901234567890"), 2, 3, S("345"));
+ test(S(), S("12345678901234567890"), 12, 13, S("34567890"));
+ test(S(), S("12345678901234567890"), 21, 13, S("not happening"));
+
+ test(S("12345"), S(), 0, 0, S());
+ test(S("12345"), S("12345"), 2, 2, S("34"));
+ test(S("12345"), S("1234567890"), 0, 100, S("1234567890"));
+
+ test(S("12345678901234567890"), S(), 0, 0, S());
+ test(S("12345678901234567890"), S("12345"), 1, 3, S("234"));
+ test(S("12345678901234567890"), S("12345678901234567890"), 5, 10,
+ S("6789012345"));
+ }
+#endif
+ {
+ typedef std::string S;
+ test_npos(S(), S(), 0, S());
+ test_npos(S(), S(), 1, S());
+ test_npos(S(), S("12345"), 0, S("12345"));
+ test_npos(S(), S("12345"), 1, S("2345"));
+ test_npos(S(), S("12345"), 3, S("45"));
+ test_npos(S(), S("12345"), 5, S(""));
+ test_npos(S(), S("12345"), 6, S("not happening"));
+ }
+}
diff --git a/test/std/strings/basic.string/string.modifiers/string_copy/copy.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_copy/copy.pass.cpp
new file mode 100644
index 000000000000..33801352816f
--- /dev/null
+++ b/test/std/strings/basic.string/string.modifiers/string_copy/copy.pass.cpp
@@ -0,0 +1,170 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type copy(charT* s, size_type n, size_type pos = 0) const;
+
+#include <string>
+#include <stdexcept>
+#include <algorithm>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S str, typename S::value_type* s, typename S::size_type n,
+ typename S::size_type pos)
+{
+ try
+ {
+ const S& cs = str;
+ typename S::size_type r = cs.copy(s, n, pos);
+ assert(pos <= cs.size());
+ typename S::size_type rlen = std::min(n, cs.size() - pos);
+ assert(r == rlen);
+ for (r = 0; r < rlen; ++r)
+ assert(S::traits_type::eq(cs[pos+r], s[r]));
+ }
+ catch (std::out_of_range&)
+ {
+ assert(pos > str.size());
+ }
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ char s[50];
+ test(S(""), s, 0, 0);
+ test(S(""), s, 0, 1);
+ test(S(""), s, 1, 0);
+ test(S("abcde"), s, 0, 0);
+ test(S("abcde"), s, 0, 1);
+ test(S("abcde"), s, 0, 2);
+ test(S("abcde"), s, 0, 4);
+ test(S("abcde"), s, 0, 5);
+ test(S("abcde"), s, 0, 6);
+ test(S("abcde"), s, 1, 0);
+ test(S("abcde"), s, 1, 1);
+ test(S("abcde"), s, 1, 2);
+ test(S("abcde"), s, 1, 4);
+ test(S("abcde"), s, 1, 5);
+ test(S("abcde"), s, 2, 0);
+ test(S("abcde"), s, 2, 1);
+ test(S("abcde"), s, 2, 2);
+ test(S("abcde"), s, 2, 4);
+ test(S("abcde"), s, 4, 0);
+ test(S("abcde"), s, 4, 1);
+ test(S("abcde"), s, 4, 2);
+ test(S("abcde"), s, 5, 0);
+ test(S("abcde"), s, 5, 1);
+ test(S("abcde"), s, 6, 0);
+ test(S("abcdefghijklmnopqrst"), s, 0, 0);
+ test(S("abcdefghijklmnopqrst"), s, 0, 1);
+ test(S("abcdefghijklmnopqrst"), s, 0, 2);
+ test(S("abcdefghijklmnopqrst"), s, 0, 10);
+ test(S("abcdefghijklmnopqrst"), s, 0, 19);
+ test(S("abcdefghijklmnopqrst"), s, 0, 20);
+ test(S("abcdefghijklmnopqrst"), s, 0, 21);
+ test(S("abcdefghijklmnopqrst"), s, 1, 0);
+ test(S("abcdefghijklmnopqrst"), s, 1, 1);
+ test(S("abcdefghijklmnopqrst"), s, 1, 2);
+ test(S("abcdefghijklmnopqrst"), s, 1, 9);
+ test(S("abcdefghijklmnopqrst"), s, 1, 18);
+ test(S("abcdefghijklmnopqrst"), s, 1, 19);
+ test(S("abcdefghijklmnopqrst"), s, 1, 20);
+ test(S("abcdefghijklmnopqrst"), s, 2, 0);
+ test(S("abcdefghijklmnopqrst"), s, 2, 1);
+ test(S("abcdefghijklmnopqrst"), s, 2, 2);
+ test(S("abcdefghijklmnopqrst"), s, 2, 9);
+ test(S("abcdefghijklmnopqrst"), s, 2, 17);
+ test(S("abcdefghijklmnopqrst"), s, 2, 18);
+ test(S("abcdefghijklmnopqrst"), s, 2, 19);
+ test(S("abcdefghijklmnopqrst"), s, 10, 0);
+ test(S("abcdefghijklmnopqrst"), s, 10, 1);
+ test(S("abcdefghijklmnopqrst"), s, 10, 2);
+ test(S("abcdefghijklmnopqrst"), s, 10, 5);
+ test(S("abcdefghijklmnopqrst"), s, 10, 9);
+ test(S("abcdefghijklmnopqrst"), s, 10, 10);
+ test(S("abcdefghijklmnopqrst"), s, 10, 11);
+ test(S("abcdefghijklmnopqrst"), s, 19, 0);
+ test(S("abcdefghijklmnopqrst"), s, 19, 1);
+ test(S("abcdefghijklmnopqrst"), s, 19, 2);
+ test(S("abcdefghijklmnopqrst"), s, 20, 0);
+ test(S("abcdefghijklmnopqrst"), s, 20, 1);
+ test(S("abcdefghijklmnopqrst"), s, 21, 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ char s[50];
+ test(S(""), s, 0, 0);
+ test(S(""), s, 0, 1);
+ test(S(""), s, 1, 0);
+ test(S("abcde"), s, 0, 0);
+ test(S("abcde"), s, 0, 1);
+ test(S("abcde"), s, 0, 2);
+ test(S("abcde"), s, 0, 4);
+ test(S("abcde"), s, 0, 5);
+ test(S("abcde"), s, 0, 6);
+ test(S("abcde"), s, 1, 0);
+ test(S("abcde"), s, 1, 1);
+ test(S("abcde"), s, 1, 2);
+ test(S("abcde"), s, 1, 4);
+ test(S("abcde"), s, 1, 5);
+ test(S("abcde"), s, 2, 0);
+ test(S("abcde"), s, 2, 1);
+ test(S("abcde"), s, 2, 2);
+ test(S("abcde"), s, 2, 4);
+ test(S("abcde"), s, 4, 0);
+ test(S("abcde"), s, 4, 1);
+ test(S("abcde"), s, 4, 2);
+ test(S("abcde"), s, 5, 0);
+ test(S("abcde"), s, 5, 1);
+ test(S("abcde"), s, 6, 0);
+ test(S("abcdefghijklmnopqrst"), s, 0, 0);
+ test(S("abcdefghijklmnopqrst"), s, 0, 1);
+ test(S("abcdefghijklmnopqrst"), s, 0, 2);
+ test(S("abcdefghijklmnopqrst"), s, 0, 10);
+ test(S("abcdefghijklmnopqrst"), s, 0, 19);
+ test(S("abcdefghijklmnopqrst"), s, 0, 20);
+ test(S("abcdefghijklmnopqrst"), s, 0, 21);
+ test(S("abcdefghijklmnopqrst"), s, 1, 0);
+ test(S("abcdefghijklmnopqrst"), s, 1, 1);
+ test(S("abcdefghijklmnopqrst"), s, 1, 2);
+ test(S("abcdefghijklmnopqrst"), s, 1, 9);
+ test(S("abcdefghijklmnopqrst"), s, 1, 18);
+ test(S("abcdefghijklmnopqrst"), s, 1, 19);
+ test(S("abcdefghijklmnopqrst"), s, 1, 20);
+ test(S("abcdefghijklmnopqrst"), s, 2, 0);
+ test(S("abcdefghijklmnopqrst"), s, 2, 1);
+ test(S("abcdefghijklmnopqrst"), s, 2, 2);
+ test(S("abcdefghijklmnopqrst"), s, 2, 9);
+ test(S("abcdefghijklmnopqrst"), s, 2, 17);
+ test(S("abcdefghijklmnopqrst"), s, 2, 18);
+ test(S("abcdefghijklmnopqrst"), s, 2, 19);
+ test(S("abcdefghijklmnopqrst"), s, 10, 0);
+ test(S("abcdefghijklmnopqrst"), s, 10, 1);
+ test(S("abcdefghijklmnopqrst"), s, 10, 2);
+ test(S("abcdefghijklmnopqrst"), s, 10, 5);
+ test(S("abcdefghijklmnopqrst"), s, 10, 9);
+ test(S("abcdefghijklmnopqrst"), s, 10, 10);
+ test(S("abcdefghijklmnopqrst"), s, 10, 11);
+ test(S("abcdefghijklmnopqrst"), s, 19, 0);
+ test(S("abcdefghijklmnopqrst"), s, 19, 1);
+ test(S("abcdefghijklmnopqrst"), s, 19, 2);
+ test(S("abcdefghijklmnopqrst"), s, 20, 0);
+ test(S("abcdefghijklmnopqrst"), s, 20, 1);
+ test(S("abcdefghijklmnopqrst"), s, 21, 0);
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.modifiers/string_erase/erase_iter_db1.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_erase/erase_iter_db1.pass.cpp
new file mode 100644
index 000000000000..6c2929d7f1d3
--- /dev/null
+++ b/test/std/strings/basic.string/string.modifiers/string_erase/erase_iter_db1.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// Call erase(const_iterator position) with end()
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <string>
+#include <cassert>
+#include <cstdlib>
+#include <exception>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::string l1("123");
+ std::string::const_iterator i = l1.end();
+ l1.erase(i);
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ S l1("123");
+ S::const_iterator i = l1.end();
+ l1.erase(i);
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/strings/basic.string/string.modifiers/string_erase/erase_iter_db2.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_erase/erase_iter_db2.pass.cpp
new file mode 100644
index 000000000000..d20fcd4623b7
--- /dev/null
+++ b/test/std/strings/basic.string/string.modifiers/string_erase/erase_iter_db2.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// Call erase(const_iterator position) with iterator from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <string>
+#include <cassert>
+#include <cstdlib>
+#include <exception>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::string l1("123");
+ std::string l2("123");
+ std::string::const_iterator i = l2.begin();
+ l1.erase(i);
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ S l1("123");
+ S l2("123");
+ S::const_iterator i = l2.begin();
+ l1.erase(i);
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/strings/basic.string/string.modifiers/string_erase/erase_iter_iter_db1.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_erase/erase_iter_iter_db1.pass.cpp
new file mode 100644
index 000000000000..5015241ad63e
--- /dev/null
+++ b/test/std/strings/basic.string/string.modifiers/string_erase/erase_iter_iter_db1.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// Call erase(const_iterator first, const_iterator last); with first iterator from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <string>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::string l1("123");
+ std::string l2("123");
+ std::string::iterator i = l1.erase(l2.cbegin(), l1.cbegin()+1);
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ S l1("123");
+ S l2("123");
+ S::iterator i = l1.erase(l2.cbegin(), l1.cbegin()+1);
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/strings/basic.string/string.modifiers/string_erase/erase_iter_iter_db2.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_erase/erase_iter_iter_db2.pass.cpp
new file mode 100644
index 000000000000..6a23bf88ca5c
--- /dev/null
+++ b/test/std/strings/basic.string/string.modifiers/string_erase/erase_iter_iter_db2.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// Call erase(const_iterator first, const_iterator last); with second iterator from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <string>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::string l1("123");
+ std::string l2("123");
+ std::string::iterator i = l1.erase(l1.cbegin(), l2.cbegin()+1);
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ S l1("123");
+ S l2("123");
+ S::iterator i = l1.erase(l1.cbegin(), l2.cbegin()+1);
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/strings/basic.string/string.modifiers/string_erase/erase_iter_iter_db3.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_erase/erase_iter_iter_db3.pass.cpp
new file mode 100644
index 000000000000..a8443818aea5
--- /dev/null
+++ b/test/std/strings/basic.string/string.modifiers/string_erase/erase_iter_iter_db3.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// Call erase(const_iterator first, const_iterator last); with both iterators from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <string>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::string l1("123");
+ std::string l2("123");
+ std::string::iterator i = l1.erase(l2.cbegin(), l2.cbegin()+1);
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ S l1("123");
+ S l2("123");
+ S::iterator i = l1.erase(l2.cbegin(), l2.cbegin()+1);
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/strings/basic.string/string.modifiers/string_erase/erase_iter_iter_db4.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_erase/erase_iter_iter_db4.pass.cpp
new file mode 100644
index 000000000000..0549e816b44c
--- /dev/null
+++ b/test/std/strings/basic.string/string.modifiers/string_erase/erase_iter_iter_db4.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// Call erase(const_iterator first, const_iterator last); with a bad range
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <string>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::string l1("123");
+ std::string::iterator i = l1.erase(l1.cbegin()+1, l1.cbegin());
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ S l1("123");
+ S::iterator i = l1.erase(l1.cbegin()+1, l1.cbegin());
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/std/strings/basic.string/string.modifiers/string_erase/iter.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_erase/iter.pass.cpp
new file mode 100644
index 000000000000..c44db71ae3b0
--- /dev/null
+++ b/test/std/strings/basic.string/string.modifiers/string_erase/iter.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// iterator erase(const_iterator p);
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s, typename S::difference_type pos, S expected)
+{
+ typename S::const_iterator p = s.begin() + pos;
+ typename S::iterator i = s.erase(p);
+ assert(s.__invariants());
+ assert(s == expected);
+ assert(i - s.begin() == pos);
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test(S("abcde"), 0, S("bcde"));
+ test(S("abcde"), 1, S("acde"));
+ test(S("abcde"), 2, S("abde"));
+ test(S("abcde"), 4, S("abcd"));
+ test(S("abcdefghij"), 0, S("bcdefghij"));
+ test(S("abcdefghij"), 1, S("acdefghij"));
+ test(S("abcdefghij"), 5, S("abcdeghij"));
+ test(S("abcdefghij"), 9, S("abcdefghi"));
+ test(S("abcdefghijklmnopqrst"), 0, S("bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, S("acdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, S("abcdefghijlmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, S("abcdefghijklmnopqrs"));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S("abcde"), 0, S("bcde"));
+ test(S("abcde"), 1, S("acde"));
+ test(S("abcde"), 2, S("abde"));
+ test(S("abcde"), 4, S("abcd"));
+ test(S("abcdefghij"), 0, S("bcdefghij"));
+ test(S("abcdefghij"), 1, S("acdefghij"));
+ test(S("abcdefghij"), 5, S("abcdeghij"));
+ test(S("abcdefghij"), 9, S("abcdefghi"));
+ test(S("abcdefghijklmnopqrst"), 0, S("bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, S("acdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, S("abcdefghijlmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, S("abcdefghijklmnopqrs"));
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.modifiers/string_erase/iter_iter.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_erase/iter_iter.pass.cpp
new file mode 100644
index 000000000000..dbe6d7ba0e73
--- /dev/null
+++ b/test/std/strings/basic.string/string.modifiers/string_erase/iter_iter.pass.cpp
@@ -0,0 +1,149 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// iterator erase(const_iterator first, const_iterator last);
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s, typename S::difference_type pos, typename S::difference_type n, S expected)
+{
+ typename S::const_iterator first = s.cbegin() + pos;
+ typename S::const_iterator last = s.cbegin() + pos + n;
+ typename S::iterator i = s.erase(first, last);
+ assert(s.__invariants());
+ assert(s == expected);
+ assert(i - s.begin() == pos);
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test(S(""), 0, 0, S(""));
+ test(S("abcde"), 0, 0, S("abcde"));
+ test(S("abcde"), 0, 1, S("bcde"));
+ test(S("abcde"), 0, 2, S("cde"));
+ test(S("abcde"), 0, 4, S("e"));
+ test(S("abcde"), 0, 5, S(""));
+ test(S("abcde"), 1, 0, S("abcde"));
+ test(S("abcde"), 1, 1, S("acde"));
+ test(S("abcde"), 1, 2, S("ade"));
+ test(S("abcde"), 1, 3, S("ae"));
+ test(S("abcde"), 1, 4, S("a"));
+ test(S("abcde"), 2, 0, S("abcde"));
+ test(S("abcde"), 2, 1, S("abde"));
+ test(S("abcde"), 2, 2, S("abe"));
+ test(S("abcde"), 2, 3, S("ab"));
+ test(S("abcde"), 4, 0, S("abcde"));
+ test(S("abcde"), 4, 1, S("abcd"));
+ test(S("abcde"), 5, 0, S("abcde"));
+ test(S("abcdefghij"), 0, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 0, 1, S("bcdefghij"));
+ test(S("abcdefghij"), 0, 5, S("fghij"));
+ test(S("abcdefghij"), 0, 9, S("j"));
+ test(S("abcdefghij"), 0, 10, S(""));
+ test(S("abcdefghij"), 1, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 1, 1, S("acdefghij"));
+ test(S("abcdefghij"), 1, 4, S("afghij"));
+ test(S("abcdefghij"), 1, 8, S("aj"));
+ test(S("abcdefghij"), 1, 9, S("a"));
+ test(S("abcdefghij"), 5, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 5, 1, S("abcdeghij"));
+ test(S("abcdefghij"), 5, 2, S("abcdehij"));
+ test(S("abcdefghij"), 5, 4, S("abcdej"));
+ test(S("abcdefghij"), 5, 5, S("abcde"));
+ test(S("abcdefghij"), 9, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 9, 1, S("abcdefghi"));
+ test(S("abcdefghij"), 10, 0, S("abcdefghij"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("t"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S(""));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("acdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("aklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("at"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("a"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijlmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijpqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijt"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrs"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S(""), 0, 0, S(""));
+ test(S("abcde"), 0, 0, S("abcde"));
+ test(S("abcde"), 0, 1, S("bcde"));
+ test(S("abcde"), 0, 2, S("cde"));
+ test(S("abcde"), 0, 4, S("e"));
+ test(S("abcde"), 0, 5, S(""));
+ test(S("abcde"), 1, 0, S("abcde"));
+ test(S("abcde"), 1, 1, S("acde"));
+ test(S("abcde"), 1, 2, S("ade"));
+ test(S("abcde"), 1, 3, S("ae"));
+ test(S("abcde"), 1, 4, S("a"));
+ test(S("abcde"), 2, 0, S("abcde"));
+ test(S("abcde"), 2, 1, S("abde"));
+ test(S("abcde"), 2, 2, S("abe"));
+ test(S("abcde"), 2, 3, S("ab"));
+ test(S("abcde"), 4, 0, S("abcde"));
+ test(S("abcde"), 4, 1, S("abcd"));
+ test(S("abcde"), 5, 0, S("abcde"));
+ test(S("abcdefghij"), 0, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 0, 1, S("bcdefghij"));
+ test(S("abcdefghij"), 0, 5, S("fghij"));
+ test(S("abcdefghij"), 0, 9, S("j"));
+ test(S("abcdefghij"), 0, 10, S(""));
+ test(S("abcdefghij"), 1, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 1, 1, S("acdefghij"));
+ test(S("abcdefghij"), 1, 4, S("afghij"));
+ test(S("abcdefghij"), 1, 8, S("aj"));
+ test(S("abcdefghij"), 1, 9, S("a"));
+ test(S("abcdefghij"), 5, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 5, 1, S("abcdeghij"));
+ test(S("abcdefghij"), 5, 2, S("abcdehij"));
+ test(S("abcdefghij"), 5, 4, S("abcdej"));
+ test(S("abcdefghij"), 5, 5, S("abcde"));
+ test(S("abcdefghij"), 9, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 9, 1, S("abcdefghi"));
+ test(S("abcdefghij"), 10, 0, S("abcdefghij"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("t"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S(""));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("acdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("aklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("at"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("a"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijlmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijpqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijt"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrs"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"));
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.modifiers/string_erase/pop_back.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_erase/pop_back.pass.cpp
new file mode 100644
index 000000000000..790ce40b0a00
--- /dev/null
+++ b/test/std/strings/basic.string/string.modifiers/string_erase/pop_back.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// void pop_back();
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s, S expected)
+{
+ s.pop_back();
+ assert(s.__invariants());
+ assert(s == expected);
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test(S("abcde"), S("abcd"));
+ test(S("abcdefghij"), S("abcdefghi"));
+ test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrs"));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S("abcde"), S("abcd"));
+ test(S("abcdefghij"), S("abcdefghi"));
+ test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrs"));
+ }
+#endif
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::string s;
+ s.pop_back();
+ assert(false);
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.modifiers/string_erase/size_size.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_erase/size_size.pass.cpp
new file mode 100644
index 000000000000..bc9ec1cf8255
--- /dev/null
+++ b/test/std/strings/basic.string/string.modifiers/string_erase/size_size.pass.cpp
@@ -0,0 +1,280 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string<charT,traits,Allocator>&
+// erase(size_type pos = 0, size_type n = npos);
+
+#include <string>
+#include <stdexcept>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s, typename S::size_type pos, typename S::size_type n, S expected)
+{
+ typename S::size_type old_size = s.size();
+ S s0 = s;
+ try
+ {
+ s.erase(pos, n);
+ assert(s.__invariants());
+ assert(pos <= old_size);
+ assert(s == expected);
+ }
+ catch (std::out_of_range&)
+ {
+ assert(pos > old_size);
+ assert(s == s0);
+ }
+}
+
+template <class S>
+void
+test(S s, typename S::size_type pos, S expected)
+{
+ typename S::size_type old_size = s.size();
+ S s0 = s;
+ try
+ {
+ s.erase(pos);
+ assert(s.__invariants());
+ assert(pos <= old_size);
+ assert(s == expected);
+ }
+ catch (std::out_of_range&)
+ {
+ assert(pos > old_size);
+ assert(s == s0);
+ }
+}
+
+template <class S>
+void
+test(S s, S expected)
+{
+ s.erase();
+ assert(s.__invariants());
+ assert(s == expected);
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test(S(""), 0, 0, S(""));
+ test(S(""), 0, 1, S(""));
+ test(S(""), 1, 0, S("can't happen"));
+ test(S("abcde"), 0, 0, S("abcde"));
+ test(S("abcde"), 0, 1, S("bcde"));
+ test(S("abcde"), 0, 2, S("cde"));
+ test(S("abcde"), 0, 4, S("e"));
+ test(S("abcde"), 0, 5, S(""));
+ test(S("abcde"), 0, 6, S(""));
+ test(S("abcde"), 1, 0, S("abcde"));
+ test(S("abcde"), 1, 1, S("acde"));
+ test(S("abcde"), 1, 2, S("ade"));
+ test(S("abcde"), 1, 3, S("ae"));
+ test(S("abcde"), 1, 4, S("a"));
+ test(S("abcde"), 1, 5, S("a"));
+ test(S("abcde"), 2, 0, S("abcde"));
+ test(S("abcde"), 2, 1, S("abde"));
+ test(S("abcde"), 2, 2, S("abe"));
+ test(S("abcde"), 2, 3, S("ab"));
+ test(S("abcde"), 2, 4, S("ab"));
+ test(S("abcde"), 4, 0, S("abcde"));
+ test(S("abcde"), 4, 1, S("abcd"));
+ test(S("abcde"), 4, 2, S("abcd"));
+ test(S("abcde"), 5, 0, S("abcde"));
+ test(S("abcde"), 5, 1, S("abcde"));
+ test(S("abcde"), 6, 0, S("can't happen"));
+ test(S("abcdefghij"), 0, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 0, 1, S("bcdefghij"));
+ test(S("abcdefghij"), 0, 5, S("fghij"));
+ test(S("abcdefghij"), 0, 9, S("j"));
+ test(S("abcdefghij"), 0, 10, S(""));
+ test(S("abcdefghij"), 0, 11, S(""));
+ test(S("abcdefghij"), 1, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 1, 1, S("acdefghij"));
+ test(S("abcdefghij"), 1, 4, S("afghij"));
+ test(S("abcdefghij"), 1, 8, S("aj"));
+ test(S("abcdefghij"), 1, 9, S("a"));
+ test(S("abcdefghij"), 1, 10, S("a"));
+ test(S("abcdefghij"), 5, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 5, 1, S("abcdeghij"));
+ test(S("abcdefghij"), 5, 2, S("abcdehij"));
+ test(S("abcdefghij"), 5, 4, S("abcdej"));
+ test(S("abcdefghij"), 5, 5, S("abcde"));
+ test(S("abcdefghij"), 5, 6, S("abcde"));
+ test(S("abcdefghij"), 9, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 9, 1, S("abcdefghi"));
+ test(S("abcdefghij"), 9, 2, S("abcdefghi"));
+ test(S("abcdefghij"), 10, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 10, 1, S("abcdefghij"));
+ test(S("abcdefghij"), 11, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("t"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S(""));
+ test(S("abcdefghijklmnopqrst"), 0, 21, S(""));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("acdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("aklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("at"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("a"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("a"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijlmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijpqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijt"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrs"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrs"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("can't happen"));
+
+ test(S(""), 0, S(""));
+ test(S(""), 1, S("can't happen"));
+ test(S("abcde"), 0, S(""));
+ test(S("abcde"), 1, S("a"));
+ test(S("abcde"), 2, S("ab"));
+ test(S("abcde"), 4, S("abcd"));
+ test(S("abcde"), 5, S("abcde"));
+ test(S("abcde"), 6, S("can't happen"));
+ test(S("abcdefghij"), 0, S(""));
+ test(S("abcdefghij"), 1, S("a"));
+ test(S("abcdefghij"), 5, S("abcde"));
+ test(S("abcdefghij"), 9, S("abcdefghi"));
+ test(S("abcdefghij"), 10, S("abcdefghij"));
+ test(S("abcdefghij"), 11, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 0, S(""));
+ test(S("abcdefghijklmnopqrst"), 1, S("a"));
+ test(S("abcdefghijklmnopqrst"), 10, S("abcdefghij"));
+ test(S("abcdefghijklmnopqrst"), 19, S("abcdefghijklmnopqrs"));
+ test(S("abcdefghijklmnopqrst"), 20, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 21, S("can't happen"));
+
+ test(S(""), S(""));
+ test(S("abcde"), S(""));
+ test(S("abcdefghij"), S(""));
+ test(S("abcdefghijklmnopqrst"), S(""));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S(""), 0, 0, S(""));
+ test(S(""), 0, 1, S(""));
+ test(S(""), 1, 0, S("can't happen"));
+ test(S("abcde"), 0, 0, S("abcde"));
+ test(S("abcde"), 0, 1, S("bcde"));
+ test(S("abcde"), 0, 2, S("cde"));
+ test(S("abcde"), 0, 4, S("e"));
+ test(S("abcde"), 0, 5, S(""));
+ test(S("abcde"), 0, 6, S(""));
+ test(S("abcde"), 1, 0, S("abcde"));
+ test(S("abcde"), 1, 1, S("acde"));
+ test(S("abcde"), 1, 2, S("ade"));
+ test(S("abcde"), 1, 3, S("ae"));
+ test(S("abcde"), 1, 4, S("a"));
+ test(S("abcde"), 1, 5, S("a"));
+ test(S("abcde"), 2, 0, S("abcde"));
+ test(S("abcde"), 2, 1, S("abde"));
+ test(S("abcde"), 2, 2, S("abe"));
+ test(S("abcde"), 2, 3, S("ab"));
+ test(S("abcde"), 2, 4, S("ab"));
+ test(S("abcde"), 4, 0, S("abcde"));
+ test(S("abcde"), 4, 1, S("abcd"));
+ test(S("abcde"), 4, 2, S("abcd"));
+ test(S("abcde"), 5, 0, S("abcde"));
+ test(S("abcde"), 5, 1, S("abcde"));
+ test(S("abcde"), 6, 0, S("can't happen"));
+ test(S("abcdefghij"), 0, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 0, 1, S("bcdefghij"));
+ test(S("abcdefghij"), 0, 5, S("fghij"));
+ test(S("abcdefghij"), 0, 9, S("j"));
+ test(S("abcdefghij"), 0, 10, S(""));
+ test(S("abcdefghij"), 0, 11, S(""));
+ test(S("abcdefghij"), 1, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 1, 1, S("acdefghij"));
+ test(S("abcdefghij"), 1, 4, S("afghij"));
+ test(S("abcdefghij"), 1, 8, S("aj"));
+ test(S("abcdefghij"), 1, 9, S("a"));
+ test(S("abcdefghij"), 1, 10, S("a"));
+ test(S("abcdefghij"), 5, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 5, 1, S("abcdeghij"));
+ test(S("abcdefghij"), 5, 2, S("abcdehij"));
+ test(S("abcdefghij"), 5, 4, S("abcdej"));
+ test(S("abcdefghij"), 5, 5, S("abcde"));
+ test(S("abcdefghij"), 5, 6, S("abcde"));
+ test(S("abcdefghij"), 9, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 9, 1, S("abcdefghi"));
+ test(S("abcdefghij"), 9, 2, S("abcdefghi"));
+ test(S("abcdefghij"), 10, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 10, 1, S("abcdefghij"));
+ test(S("abcdefghij"), 11, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("t"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S(""));
+ test(S("abcdefghijklmnopqrst"), 0, 21, S(""));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("acdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("aklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("at"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("a"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("a"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijlmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijpqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijt"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrs"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrs"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("can't happen"));
+
+ test(S(""), 0, S(""));
+ test(S(""), 1, S("can't happen"));
+ test(S("abcde"), 0, S(""));
+ test(S("abcde"), 1, S("a"));
+ test(S("abcde"), 2, S("ab"));
+ test(S("abcde"), 4, S("abcd"));
+ test(S("abcde"), 5, S("abcde"));
+ test(S("abcde"), 6, S("can't happen"));
+ test(S("abcdefghij"), 0, S(""));
+ test(S("abcdefghij"), 1, S("a"));
+ test(S("abcdefghij"), 5, S("abcde"));
+ test(S("abcdefghij"), 9, S("abcdefghi"));
+ test(S("abcdefghij"), 10, S("abcdefghij"));
+ test(S("abcdefghij"), 11, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 0, S(""));
+ test(S("abcdefghijklmnopqrst"), 1, S("a"));
+ test(S("abcdefghijklmnopqrst"), 10, S("abcdefghij"));
+ test(S("abcdefghijklmnopqrst"), 19, S("abcdefghijklmnopqrs"));
+ test(S("abcdefghijklmnopqrst"), 20, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 21, S("can't happen"));
+
+ test(S(""), S(""));
+ test(S("abcde"), S(""));
+ test(S("abcdefghij"), S(""));
+ test(S("abcdefghijklmnopqrst"), S(""));
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.modifiers/string_insert/iter_char.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_insert/iter_char.pass.cpp
new file mode 100644
index 000000000000..b9e5fa8bc064
--- /dev/null
+++ b/test/std/strings/basic.string/string.modifiers/string_insert/iter_char.pass.cpp
@@ -0,0 +1,88 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// iterator insert(const_iterator p, charT c);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <string>
+#include <stdexcept>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S& s, typename S::const_iterator p, typename S::value_type c, S expected)
+{
+ bool sufficient_cap = s.size() < s.capacity();
+ typename S::difference_type pos = p - s.begin();
+ typename S::iterator i = s.insert(p, c);
+ assert(s.__invariants());
+ assert(s == expected);
+ assert(i - s.begin() == pos);
+ assert(*i == c);
+ if (sufficient_cap)
+ assert(i == p);
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ S s;
+ test(s, s.begin(), '1', S("1"));
+ test(s, s.begin(), 'a', S("a1"));
+ test(s, s.end(), 'b', S("a1b"));
+ test(s, s.end()-1, 'c', S("a1cb"));
+ test(s, s.end()-2, 'd', S("a1dcb"));
+ test(s, s.end()-3, '2', S("a12dcb"));
+ test(s, s.end()-4, '3', S("a132dcb"));
+ test(s, s.end()-5, '4', S("a1432dcb"));
+ test(s, s.begin()+1, '5', S("a51432dcb"));
+ test(s, s.begin()+2, '6', S("a561432dcb"));
+ test(s, s.begin()+3, '7', S("a5671432dcb"));
+ test(s, s.begin()+4, 'A', S("a567A1432dcb"));
+ test(s, s.begin()+5, 'B', S("a567AB1432dcb"));
+ test(s, s.begin()+6, 'C', S("a567ABC1432dcb"));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ S s;
+ test(s, s.begin(), '1', S("1"));
+ test(s, s.begin(), 'a', S("a1"));
+ test(s, s.end(), 'b', S("a1b"));
+ test(s, s.end()-1, 'c', S("a1cb"));
+ test(s, s.end()-2, 'd', S("a1dcb"));
+ test(s, s.end()-3, '2', S("a12dcb"));
+ test(s, s.end()-4, '3', S("a132dcb"));
+ test(s, s.end()-5, '4', S("a1432dcb"));
+ test(s, s.begin()+1, '5', S("a51432dcb"));
+ test(s, s.begin()+2, '6', S("a561432dcb"));
+ test(s, s.begin()+3, '7', S("a5671432dcb"));
+ test(s, s.begin()+4, 'A', S("a567A1432dcb"));
+ test(s, s.begin()+5, 'B', S("a567AB1432dcb"));
+ test(s, s.begin()+6, 'C', S("a567ABC1432dcb"));
+ }
+#endif
+#if _LIBCPP_DEBUG >= 1
+ {
+ typedef std::string S;
+ S s;
+ S s2;
+ s.insert(s2.begin(), '1');
+ assert(false);
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.modifiers/string_insert/iter_initializer_list.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_insert/iter_initializer_list.pass.cpp
new file mode 100644
index 000000000000..e091662eae06
--- /dev/null
+++ b/test/std/strings/basic.string/string.modifiers/string_insert/iter_initializer_list.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// iterator insert(const_iterator p, initializer_list<charT> il);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ std::string s("123456");
+ std::string::iterator i = s.insert(s.begin() + 3, {'a', 'b', 'c'});
+ assert(i - s.begin() == 3);
+ assert(s == "123abc456");
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ S s("123456");
+ S::iterator i = s.insert(s.begin() + 3, {'a', 'b', 'c'});
+ assert(i - s.begin() == 3);
+ assert(s == "123abc456");
+ }
+#endif
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::string s;
+ std::string s2;
+ s.insert(s2.begin(), {'a', 'b', 'c'});
+ assert(false);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/strings/basic.string/string.modifiers/string_insert/iter_iter_iter.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_insert/iter_iter_iter.pass.cpp
new file mode 100644
index 000000000000..38353dd2f4e4
--- /dev/null
+++ b/test/std/strings/basic.string/string.modifiers/string_insert/iter_iter_iter.pass.cpp
@@ -0,0 +1,140 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class InputIterator>
+// iterator insert(const_iterator p, InputIterator first, InputIterator last);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <string>
+#include <cassert>
+
+#include "../../input_iterator.h"
+#include "min_allocator.h"
+
+template <class S, class It>
+void
+test(S s, typename S::difference_type pos, It first, It last, S expected)
+{
+ typename S::const_iterator p = s.cbegin() + pos;
+ typename S::iterator i = s.insert(p, first, last);
+ assert(s.__invariants());
+ assert(i - s.begin() == pos);
+ assert(s == expected);
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ const char* s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
+ test(S(), 0, s, s, S());
+ test(S(), 0, s, s+1, S("A"));
+ test(S(), 0, s, s+10, S("ABCDEFGHIJ"));
+ test(S(), 0, s, s+52, S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+ test(S("12345"), 0, s, s, S("12345"));
+ test(S("12345"), 1, s, s+1, S("1A2345"));
+ test(S("12345"), 4, s, s+10, S("1234ABCDEFGHIJ5"));
+ test(S("12345"), 5, s, s+52, S("12345ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+ test(S("1234567890"), 0, s, s, S("1234567890"));
+ test(S("1234567890"), 1, s, s+1, S("1A234567890"));
+ test(S("1234567890"), 10, s, s+10, S("1234567890ABCDEFGHIJ"));
+ test(S("1234567890"), 8, s, s+52, S("12345678ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz90"));
+
+ test(S("12345678901234567890"), 3, s, s, S("12345678901234567890"));
+ test(S("12345678901234567890"), 3, s, s+1, S("123A45678901234567890"));
+ test(S("12345678901234567890"), 15, s, s+10, S("123456789012345ABCDEFGHIJ67890"));
+ test(S("12345678901234567890"), 20, s, s+52,
+ S("12345678901234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+ test(S(), 0, input_iterator<const char*>(s), input_iterator<const char*>(s), S());
+ test(S(), 0, input_iterator<const char*>(s), input_iterator<const char*>(s+1), S("A"));
+ test(S(), 0, input_iterator<const char*>(s), input_iterator<const char*>(s+10), S("ABCDEFGHIJ"));
+ test(S(), 0, input_iterator<const char*>(s), input_iterator<const char*>(s+52), S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+ test(S("12345"), 0, input_iterator<const char*>(s), input_iterator<const char*>(s), S("12345"));
+ test(S("12345"), 1, input_iterator<const char*>(s), input_iterator<const char*>(s+1), S("1A2345"));
+ test(S("12345"), 4, input_iterator<const char*>(s), input_iterator<const char*>(s+10), S("1234ABCDEFGHIJ5"));
+ test(S("12345"), 5, input_iterator<const char*>(s), input_iterator<const char*>(s+52), S("12345ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+ test(S("1234567890"), 0, input_iterator<const char*>(s), input_iterator<const char*>(s), S("1234567890"));
+ test(S("1234567890"), 1, input_iterator<const char*>(s), input_iterator<const char*>(s+1), S("1A234567890"));
+ test(S("1234567890"), 10, input_iterator<const char*>(s), input_iterator<const char*>(s+10), S("1234567890ABCDEFGHIJ"));
+ test(S("1234567890"), 8, input_iterator<const char*>(s), input_iterator<const char*>(s+52), S("12345678ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz90"));
+
+ test(S("12345678901234567890"), 3, input_iterator<const char*>(s), input_iterator<const char*>(s), S("12345678901234567890"));
+ test(S("12345678901234567890"), 3, input_iterator<const char*>(s), input_iterator<const char*>(s+1), S("123A45678901234567890"));
+ test(S("12345678901234567890"), 15, input_iterator<const char*>(s), input_iterator<const char*>(s+10), S("123456789012345ABCDEFGHIJ67890"));
+ test(S("12345678901234567890"), 20, input_iterator<const char*>(s), input_iterator<const char*>(s+52),
+ S("12345678901234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ const char* s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
+ test(S(), 0, s, s, S());
+ test(S(), 0, s, s+1, S("A"));
+ test(S(), 0, s, s+10, S("ABCDEFGHIJ"));
+ test(S(), 0, s, s+52, S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+ test(S("12345"), 0, s, s, S("12345"));
+ test(S("12345"), 1, s, s+1, S("1A2345"));
+ test(S("12345"), 4, s, s+10, S("1234ABCDEFGHIJ5"));
+ test(S("12345"), 5, s, s+52, S("12345ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+ test(S("1234567890"), 0, s, s, S("1234567890"));
+ test(S("1234567890"), 1, s, s+1, S("1A234567890"));
+ test(S("1234567890"), 10, s, s+10, S("1234567890ABCDEFGHIJ"));
+ test(S("1234567890"), 8, s, s+52, S("12345678ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz90"));
+
+ test(S("12345678901234567890"), 3, s, s, S("12345678901234567890"));
+ test(S("12345678901234567890"), 3, s, s+1, S("123A45678901234567890"));
+ test(S("12345678901234567890"), 15, s, s+10, S("123456789012345ABCDEFGHIJ67890"));
+ test(S("12345678901234567890"), 20, s, s+52,
+ S("12345678901234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+ test(S(), 0, input_iterator<const char*>(s), input_iterator<const char*>(s), S());
+ test(S(), 0, input_iterator<const char*>(s), input_iterator<const char*>(s+1), S("A"));
+ test(S(), 0, input_iterator<const char*>(s), input_iterator<const char*>(s+10), S("ABCDEFGHIJ"));
+ test(S(), 0, input_iterator<const char*>(s), input_iterator<const char*>(s+52), S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+ test(S("12345"), 0, input_iterator<const char*>(s), input_iterator<const char*>(s), S("12345"));
+ test(S("12345"), 1, input_iterator<const char*>(s), input_iterator<const char*>(s+1), S("1A2345"));
+ test(S("12345"), 4, input_iterator<const char*>(s), input_iterator<const char*>(s+10), S("1234ABCDEFGHIJ5"));
+ test(S("12345"), 5, input_iterator<const char*>(s), input_iterator<const char*>(s+52), S("12345ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+ test(S("1234567890"), 0, input_iterator<const char*>(s), input_iterator<const char*>(s), S("1234567890"));
+ test(S("1234567890"), 1, input_iterator<const char*>(s), input_iterator<const char*>(s+1), S("1A234567890"));
+ test(S("1234567890"), 10, input_iterator<const char*>(s), input_iterator<const char*>(s+10), S("1234567890ABCDEFGHIJ"));
+ test(S("1234567890"), 8, input_iterator<const char*>(s), input_iterator<const char*>(s+52), S("12345678ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz90"));
+
+ test(S("12345678901234567890"), 3, input_iterator<const char*>(s), input_iterator<const char*>(s), S("12345678901234567890"));
+ test(S("12345678901234567890"), 3, input_iterator<const char*>(s), input_iterator<const char*>(s+1), S("123A45678901234567890"));
+ test(S("12345678901234567890"), 15, input_iterator<const char*>(s), input_iterator<const char*>(s+10), S("123456789012345ABCDEFGHIJ67890"));
+ test(S("12345678901234567890"), 20, input_iterator<const char*>(s), input_iterator<const char*>(s+52),
+ S("12345678901234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+ }
+#endif
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::string v;
+ std::string v2;
+ char a[] = "123";
+ const int N = sizeof(a)/sizeof(a[0]);
+ std::string::iterator i = v.insert(v2.cbegin() + 10, a, a+N);
+ assert(false);
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.modifiers/string_insert/iter_size_char.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_insert/iter_size_char.pass.cpp
new file mode 100644
index 000000000000..739c89404c1d
--- /dev/null
+++ b/test/std/strings/basic.string/string.modifiers/string_insert/iter_size_char.pass.cpp
@@ -0,0 +1,181 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// iterator insert(const_iterator p, size_type n, charT c);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s, typename S::difference_type pos, typename S::size_type n,
+ typename S::value_type c, S expected)
+{
+ typename S::const_iterator p = s.cbegin() + pos;
+ typename S::iterator i = s.insert(p, n, c);
+ assert(s.__invariants());
+ assert(i - s.begin() == pos);
+ assert(s == expected);
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test(S(""), 0, 0, '1', S(""));
+ test(S(""), 0, 5, '1', S("11111"));
+ test(S(""), 0, 10, '1', S("1111111111"));
+ test(S(""), 0, 20, '1', S("11111111111111111111"));
+ test(S("abcde"), 0, 0, '1', S("abcde"));
+ test(S("abcde"), 0, 5, '1', S("11111abcde"));
+ test(S("abcde"), 0, 10, '1', S("1111111111abcde"));
+ test(S("abcde"), 0, 20, '1', S("11111111111111111111abcde"));
+ test(S("abcde"), 1, 0, '1', S("abcde"));
+ test(S("abcde"), 1, 5, '1', S("a11111bcde"));
+ test(S("abcde"), 1, 10, '1', S("a1111111111bcde"));
+ test(S("abcde"), 1, 20, '1', S("a11111111111111111111bcde"));
+ test(S("abcde"), 2, 0, '1', S("abcde"));
+ test(S("abcde"), 2, 5, '1', S("ab11111cde"));
+ test(S("abcde"), 2, 10, '1', S("ab1111111111cde"));
+ test(S("abcde"), 2, 20, '1', S("ab11111111111111111111cde"));
+ test(S("abcde"), 4, 0, '1', S("abcde"));
+ test(S("abcde"), 4, 5, '1', S("abcd11111e"));
+ test(S("abcde"), 4, 10, '1', S("abcd1111111111e"));
+ test(S("abcde"), 4, 20, '1', S("abcd11111111111111111111e"));
+ test(S("abcde"), 5, 0, '1', S("abcde"));
+ test(S("abcde"), 5, 5, '1', S("abcde11111"));
+ test(S("abcde"), 5, 10, '1', S("abcde1111111111"));
+ test(S("abcde"), 5, 20, '1', S("abcde11111111111111111111"));
+ test(S("abcdefghij"), 0, 0, '1', S("abcdefghij"));
+ test(S("abcdefghij"), 0, 5, '1', S("11111abcdefghij"));
+ test(S("abcdefghij"), 0, 10, '1', S("1111111111abcdefghij"));
+ test(S("abcdefghij"), 0, 20, '1', S("11111111111111111111abcdefghij"));
+ test(S("abcdefghij"), 1, 0, '1', S("abcdefghij"));
+ test(S("abcdefghij"), 1, 5, '1', S("a11111bcdefghij"));
+ test(S("abcdefghij"), 1, 10, '1', S("a1111111111bcdefghij"));
+ test(S("abcdefghij"), 1, 20, '1', S("a11111111111111111111bcdefghij"));
+ test(S("abcdefghij"), 5, 0, '1', S("abcdefghij"));
+ test(S("abcdefghij"), 5, 5, '1', S("abcde11111fghij"));
+ test(S("abcdefghij"), 5, 10, '1', S("abcde1111111111fghij"));
+ test(S("abcdefghij"), 5, 20, '1', S("abcde11111111111111111111fghij"));
+ test(S("abcdefghij"), 9, 0, '1', S("abcdefghij"));
+ test(S("abcdefghij"), 9, 5, '1', S("abcdefghi11111j"));
+ test(S("abcdefghij"), 9, 10, '1', S("abcdefghi1111111111j"));
+ test(S("abcdefghij"), 9, 20, '1', S("abcdefghi11111111111111111111j"));
+ test(S("abcdefghij"), 10, 0, '1', S("abcdefghij"));
+ test(S("abcdefghij"), 10, 5, '1', S("abcdefghij11111"));
+ test(S("abcdefghij"), 10, 10, '1', S("abcdefghij1111111111"));
+ test(S("abcdefghij"), 10, 20, '1', S("abcdefghij11111111111111111111"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, '1', S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 5, '1', S("11111abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, '1', S("1111111111abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, '1', S("11111111111111111111abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, '1', S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 5, '1', S("a11111bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 10, '1', S("a1111111111bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, '1', S("a11111111111111111111bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, '1', S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, '1', S("abcdefghij11111klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, '1', S("abcdefghij1111111111klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 20, '1', S("abcdefghij11111111111111111111klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, '1', S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, 5, '1', S("abcdefghijklmnopqrs11111t"));
+ test(S("abcdefghijklmnopqrst"), 19, 10, '1', S("abcdefghijklmnopqrs1111111111t"));
+ test(S("abcdefghijklmnopqrst"), 19, 20, '1', S("abcdefghijklmnopqrs11111111111111111111t"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, '1', S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, 5, '1', S("abcdefghijklmnopqrst11111"));
+ test(S("abcdefghijklmnopqrst"), 20, 10, '1', S("abcdefghijklmnopqrst1111111111"));
+ test(S("abcdefghijklmnopqrst"), 20, 20, '1', S("abcdefghijklmnopqrst11111111111111111111"));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S(""), 0, 0, '1', S(""));
+ test(S(""), 0, 5, '1', S("11111"));
+ test(S(""), 0, 10, '1', S("1111111111"));
+ test(S(""), 0, 20, '1', S("11111111111111111111"));
+ test(S("abcde"), 0, 0, '1', S("abcde"));
+ test(S("abcde"), 0, 5, '1', S("11111abcde"));
+ test(S("abcde"), 0, 10, '1', S("1111111111abcde"));
+ test(S("abcde"), 0, 20, '1', S("11111111111111111111abcde"));
+ test(S("abcde"), 1, 0, '1', S("abcde"));
+ test(S("abcde"), 1, 5, '1', S("a11111bcde"));
+ test(S("abcde"), 1, 10, '1', S("a1111111111bcde"));
+ test(S("abcde"), 1, 20, '1', S("a11111111111111111111bcde"));
+ test(S("abcde"), 2, 0, '1', S("abcde"));
+ test(S("abcde"), 2, 5, '1', S("ab11111cde"));
+ test(S("abcde"), 2, 10, '1', S("ab1111111111cde"));
+ test(S("abcde"), 2, 20, '1', S("ab11111111111111111111cde"));
+ test(S("abcde"), 4, 0, '1', S("abcde"));
+ test(S("abcde"), 4, 5, '1', S("abcd11111e"));
+ test(S("abcde"), 4, 10, '1', S("abcd1111111111e"));
+ test(S("abcde"), 4, 20, '1', S("abcd11111111111111111111e"));
+ test(S("abcde"), 5, 0, '1', S("abcde"));
+ test(S("abcde"), 5, 5, '1', S("abcde11111"));
+ test(S("abcde"), 5, 10, '1', S("abcde1111111111"));
+ test(S("abcde"), 5, 20, '1', S("abcde11111111111111111111"));
+ test(S("abcdefghij"), 0, 0, '1', S("abcdefghij"));
+ test(S("abcdefghij"), 0, 5, '1', S("11111abcdefghij"));
+ test(S("abcdefghij"), 0, 10, '1', S("1111111111abcdefghij"));
+ test(S("abcdefghij"), 0, 20, '1', S("11111111111111111111abcdefghij"));
+ test(S("abcdefghij"), 1, 0, '1', S("abcdefghij"));
+ test(S("abcdefghij"), 1, 5, '1', S("a11111bcdefghij"));
+ test(S("abcdefghij"), 1, 10, '1', S("a1111111111bcdefghij"));
+ test(S("abcdefghij"), 1, 20, '1', S("a11111111111111111111bcdefghij"));
+ test(S("abcdefghij"), 5, 0, '1', S("abcdefghij"));
+ test(S("abcdefghij"), 5, 5, '1', S("abcde11111fghij"));
+ test(S("abcdefghij"), 5, 10, '1', S("abcde1111111111fghij"));
+ test(S("abcdefghij"), 5, 20, '1', S("abcde11111111111111111111fghij"));
+ test(S("abcdefghij"), 9, 0, '1', S("abcdefghij"));
+ test(S("abcdefghij"), 9, 5, '1', S("abcdefghi11111j"));
+ test(S("abcdefghij"), 9, 10, '1', S("abcdefghi1111111111j"));
+ test(S("abcdefghij"), 9, 20, '1', S("abcdefghi11111111111111111111j"));
+ test(S("abcdefghij"), 10, 0, '1', S("abcdefghij"));
+ test(S("abcdefghij"), 10, 5, '1', S("abcdefghij11111"));
+ test(S("abcdefghij"), 10, 10, '1', S("abcdefghij1111111111"));
+ test(S("abcdefghij"), 10, 20, '1', S("abcdefghij11111111111111111111"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, '1', S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 5, '1', S("11111abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, '1', S("1111111111abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, '1', S("11111111111111111111abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, '1', S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 5, '1', S("a11111bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 10, '1', S("a1111111111bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, '1', S("a11111111111111111111bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, '1', S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, '1', S("abcdefghij11111klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, '1', S("abcdefghij1111111111klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 20, '1', S("abcdefghij11111111111111111111klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, '1', S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, 5, '1', S("abcdefghijklmnopqrs11111t"));
+ test(S("abcdefghijklmnopqrst"), 19, 10, '1', S("abcdefghijklmnopqrs1111111111t"));
+ test(S("abcdefghijklmnopqrst"), 19, 20, '1', S("abcdefghijklmnopqrs11111111111111111111t"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, '1', S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, 5, '1', S("abcdefghijklmnopqrst11111"));
+ test(S("abcdefghijklmnopqrst"), 20, 10, '1', S("abcdefghijklmnopqrst1111111111"));
+ test(S("abcdefghijklmnopqrst"), 20, 20, '1', S("abcdefghijklmnopqrst11111111111111111111"));
+ }
+#endif
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::string s;
+ std::string s2;
+ s.insert(s2.begin(), 1, 'a');
+ assert(false);
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.modifiers/string_insert/size_pointer.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_insert/size_pointer.pass.cpp
new file mode 100644
index 000000000000..734dd8dffb78
--- /dev/null
+++ b/test/std/strings/basic.string/string.modifiers/string_insert/size_pointer.pass.cpp
@@ -0,0 +1,211 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string<charT,traits,Allocator>&
+// insert(size_type pos, const charT* s);
+
+#include <string>
+#include <stdexcept>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s, typename S::size_type pos, const typename S::value_type* str, S expected)
+{
+ typename S::size_type old_size = s.size();
+ S s0 = s;
+ try
+ {
+ s.insert(pos, str);
+ assert(s.__invariants());
+ assert(pos <= old_size);
+ assert(s == expected);
+ }
+ catch (std::out_of_range&)
+ {
+ assert(pos > old_size);
+ assert(s == s0);
+ }
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test(S(""), 0, "", S(""));
+ test(S(""), 0, "12345", S("12345"));
+ test(S(""), 0, "1234567890", S("1234567890"));
+ test(S(""), 0, "12345678901234567890", S("12345678901234567890"));
+ test(S(""), 1, "", S("can't happen"));
+ test(S(""), 1, "12345", S("can't happen"));
+ test(S(""), 1, "1234567890", S("can't happen"));
+ test(S(""), 1, "12345678901234567890", S("can't happen"));
+ test(S("abcde"), 0, "", S("abcde"));
+ test(S("abcde"), 0, "12345", S("12345abcde"));
+ test(S("abcde"), 0, "1234567890", S("1234567890abcde"));
+ test(S("abcde"), 0, "12345678901234567890", S("12345678901234567890abcde"));
+ test(S("abcde"), 1, "", S("abcde"));
+ test(S("abcde"), 1, "12345", S("a12345bcde"));
+ test(S("abcde"), 1, "1234567890", S("a1234567890bcde"));
+ test(S("abcde"), 1, "12345678901234567890", S("a12345678901234567890bcde"));
+ test(S("abcde"), 2, "", S("abcde"));
+ test(S("abcde"), 2, "12345", S("ab12345cde"));
+ test(S("abcde"), 2, "1234567890", S("ab1234567890cde"));
+ test(S("abcde"), 2, "12345678901234567890", S("ab12345678901234567890cde"));
+ test(S("abcde"), 4, "", S("abcde"));
+ test(S("abcde"), 4, "12345", S("abcd12345e"));
+ test(S("abcde"), 4, "1234567890", S("abcd1234567890e"));
+ test(S("abcde"), 4, "12345678901234567890", S("abcd12345678901234567890e"));
+ test(S("abcde"), 5, "", S("abcde"));
+ test(S("abcde"), 5, "12345", S("abcde12345"));
+ test(S("abcde"), 5, "1234567890", S("abcde1234567890"));
+ test(S("abcde"), 5, "12345678901234567890", S("abcde12345678901234567890"));
+ test(S("abcde"), 6, "", S("can't happen"));
+ test(S("abcde"), 6, "12345", S("can't happen"));
+ test(S("abcde"), 6, "1234567890", S("can't happen"));
+ test(S("abcde"), 6, "12345678901234567890", S("can't happen"));
+ test(S("abcdefghij"), 0, "", S("abcdefghij"));
+ test(S("abcdefghij"), 0, "12345", S("12345abcdefghij"));
+ test(S("abcdefghij"), 0, "1234567890", S("1234567890abcdefghij"));
+ test(S("abcdefghij"), 0, "12345678901234567890", S("12345678901234567890abcdefghij"));
+ test(S("abcdefghij"), 1, "", S("abcdefghij"));
+ test(S("abcdefghij"), 1, "12345", S("a12345bcdefghij"));
+ test(S("abcdefghij"), 1, "1234567890", S("a1234567890bcdefghij"));
+ test(S("abcdefghij"), 1, "12345678901234567890", S("a12345678901234567890bcdefghij"));
+ test(S("abcdefghij"), 5, "", S("abcdefghij"));
+ test(S("abcdefghij"), 5, "12345", S("abcde12345fghij"));
+ test(S("abcdefghij"), 5, "1234567890", S("abcde1234567890fghij"));
+ test(S("abcdefghij"), 5, "12345678901234567890", S("abcde12345678901234567890fghij"));
+ test(S("abcdefghij"), 9, "", S("abcdefghij"));
+ test(S("abcdefghij"), 9, "12345", S("abcdefghi12345j"));
+ test(S("abcdefghij"), 9, "1234567890", S("abcdefghi1234567890j"));
+ test(S("abcdefghij"), 9, "12345678901234567890", S("abcdefghi12345678901234567890j"));
+ test(S("abcdefghij"), 10, "", S("abcdefghij"));
+ test(S("abcdefghij"), 10, "12345", S("abcdefghij12345"));
+ test(S("abcdefghij"), 10, "1234567890", S("abcdefghij1234567890"));
+ test(S("abcdefghij"), 10, "12345678901234567890", S("abcdefghij12345678901234567890"));
+ test(S("abcdefghij"), 11, "", S("can't happen"));
+ test(S("abcdefghij"), 11, "12345", S("can't happen"));
+ test(S("abcdefghij"), 11, "1234567890", S("can't happen"));
+ test(S("abcdefghij"), 11, "12345678901234567890", S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 0, "", S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, "12345", S("12345abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, "1234567890", S("1234567890abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, "12345678901234567890", S("12345678901234567890abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, "", S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, "12345", S("a12345bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, "1234567890", S("a1234567890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, "12345678901234567890", S("a12345678901234567890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, "", S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, "12345", S("abcdefghij12345klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, "1234567890", S("abcdefghij1234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, "12345678901234567890", S("abcdefghij12345678901234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, "", S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, "12345", S("abcdefghijklmnopqrs12345t"));
+ test(S("abcdefghijklmnopqrst"), 19, "1234567890", S("abcdefghijklmnopqrs1234567890t"));
+ test(S("abcdefghijklmnopqrst"), 19, "12345678901234567890", S("abcdefghijklmnopqrs12345678901234567890t"));
+ test(S("abcdefghijklmnopqrst"), 20, "", S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, "12345", S("abcdefghijklmnopqrst12345"));
+ test(S("abcdefghijklmnopqrst"), 20, "1234567890", S("abcdefghijklmnopqrst1234567890"));
+ test(S("abcdefghijklmnopqrst"), 20, "12345678901234567890", S("abcdefghijklmnopqrst12345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 21, "", S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, "12345", S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, "1234567890", S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, "12345678901234567890", S("can't happen"));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S(""), 0, "", S(""));
+ test(S(""), 0, "12345", S("12345"));
+ test(S(""), 0, "1234567890", S("1234567890"));
+ test(S(""), 0, "12345678901234567890", S("12345678901234567890"));
+ test(S(""), 1, "", S("can't happen"));
+ test(S(""), 1, "12345", S("can't happen"));
+ test(S(""), 1, "1234567890", S("can't happen"));
+ test(S(""), 1, "12345678901234567890", S("can't happen"));
+ test(S("abcde"), 0, "", S("abcde"));
+ test(S("abcde"), 0, "12345", S("12345abcde"));
+ test(S("abcde"), 0, "1234567890", S("1234567890abcde"));
+ test(S("abcde"), 0, "12345678901234567890", S("12345678901234567890abcde"));
+ test(S("abcde"), 1, "", S("abcde"));
+ test(S("abcde"), 1, "12345", S("a12345bcde"));
+ test(S("abcde"), 1, "1234567890", S("a1234567890bcde"));
+ test(S("abcde"), 1, "12345678901234567890", S("a12345678901234567890bcde"));
+ test(S("abcde"), 2, "", S("abcde"));
+ test(S("abcde"), 2, "12345", S("ab12345cde"));
+ test(S("abcde"), 2, "1234567890", S("ab1234567890cde"));
+ test(S("abcde"), 2, "12345678901234567890", S("ab12345678901234567890cde"));
+ test(S("abcde"), 4, "", S("abcde"));
+ test(S("abcde"), 4, "12345", S("abcd12345e"));
+ test(S("abcde"), 4, "1234567890", S("abcd1234567890e"));
+ test(S("abcde"), 4, "12345678901234567890", S("abcd12345678901234567890e"));
+ test(S("abcde"), 5, "", S("abcde"));
+ test(S("abcde"), 5, "12345", S("abcde12345"));
+ test(S("abcde"), 5, "1234567890", S("abcde1234567890"));
+ test(S("abcde"), 5, "12345678901234567890", S("abcde12345678901234567890"));
+ test(S("abcde"), 6, "", S("can't happen"));
+ test(S("abcde"), 6, "12345", S("can't happen"));
+ test(S("abcde"), 6, "1234567890", S("can't happen"));
+ test(S("abcde"), 6, "12345678901234567890", S("can't happen"));
+ test(S("abcdefghij"), 0, "", S("abcdefghij"));
+ test(S("abcdefghij"), 0, "12345", S("12345abcdefghij"));
+ test(S("abcdefghij"), 0, "1234567890", S("1234567890abcdefghij"));
+ test(S("abcdefghij"), 0, "12345678901234567890", S("12345678901234567890abcdefghij"));
+ test(S("abcdefghij"), 1, "", S("abcdefghij"));
+ test(S("abcdefghij"), 1, "12345", S("a12345bcdefghij"));
+ test(S("abcdefghij"), 1, "1234567890", S("a1234567890bcdefghij"));
+ test(S("abcdefghij"), 1, "12345678901234567890", S("a12345678901234567890bcdefghij"));
+ test(S("abcdefghij"), 5, "", S("abcdefghij"));
+ test(S("abcdefghij"), 5, "12345", S("abcde12345fghij"));
+ test(S("abcdefghij"), 5, "1234567890", S("abcde1234567890fghij"));
+ test(S("abcdefghij"), 5, "12345678901234567890", S("abcde12345678901234567890fghij"));
+ test(S("abcdefghij"), 9, "", S("abcdefghij"));
+ test(S("abcdefghij"), 9, "12345", S("abcdefghi12345j"));
+ test(S("abcdefghij"), 9, "1234567890", S("abcdefghi1234567890j"));
+ test(S("abcdefghij"), 9, "12345678901234567890", S("abcdefghi12345678901234567890j"));
+ test(S("abcdefghij"), 10, "", S("abcdefghij"));
+ test(S("abcdefghij"), 10, "12345", S("abcdefghij12345"));
+ test(S("abcdefghij"), 10, "1234567890", S("abcdefghij1234567890"));
+ test(S("abcdefghij"), 10, "12345678901234567890", S("abcdefghij12345678901234567890"));
+ test(S("abcdefghij"), 11, "", S("can't happen"));
+ test(S("abcdefghij"), 11, "12345", S("can't happen"));
+ test(S("abcdefghij"), 11, "1234567890", S("can't happen"));
+ test(S("abcdefghij"), 11, "12345678901234567890", S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 0, "", S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, "12345", S("12345abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, "1234567890", S("1234567890abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, "12345678901234567890", S("12345678901234567890abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, "", S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, "12345", S("a12345bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, "1234567890", S("a1234567890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, "12345678901234567890", S("a12345678901234567890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, "", S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, "12345", S("abcdefghij12345klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, "1234567890", S("abcdefghij1234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, "12345678901234567890", S("abcdefghij12345678901234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, "", S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, "12345", S("abcdefghijklmnopqrs12345t"));
+ test(S("abcdefghijklmnopqrst"), 19, "1234567890", S("abcdefghijklmnopqrs1234567890t"));
+ test(S("abcdefghijklmnopqrst"), 19, "12345678901234567890", S("abcdefghijklmnopqrs12345678901234567890t"));
+ test(S("abcdefghijklmnopqrst"), 20, "", S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, "12345", S("abcdefghijklmnopqrst12345"));
+ test(S("abcdefghijklmnopqrst"), 20, "1234567890", S("abcdefghijklmnopqrst1234567890"));
+ test(S("abcdefghijklmnopqrst"), 20, "12345678901234567890", S("abcdefghijklmnopqrst12345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 21, "", S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, "12345", S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, "1234567890", S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, "12345678901234567890", S("can't happen"));
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.modifiers/string_insert/size_pointer_size.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_insert/size_pointer_size.pass.cpp
new file mode 100644
index 000000000000..29b00ec55b9f
--- /dev/null
+++ b/test/std/strings/basic.string/string.modifiers/string_insert/size_pointer_size.pass.cpp
@@ -0,0 +1,692 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string<charT,traits,Allocator>&
+// insert(size_type pos, const charT* s, size_type n);
+
+#include <string>
+#include <stdexcept>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s, typename S::size_type pos, const typename S::value_type* str,
+ typename S::size_type n, S expected)
+{
+ typename S::size_type old_size = s.size();
+ S s0 = s;
+ try
+ {
+ s.insert(pos, str, n);
+ assert(s.__invariants());
+ assert(pos <= old_size);
+ assert(s == expected);
+ }
+ catch (std::out_of_range&)
+ {
+ assert(pos > old_size);
+ assert(s == s0);
+ }
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test(S(""), 0, "", 0, S(""));
+ test(S(""), 0, "12345", 0, S(""));
+ test(S(""), 0, "12345", 1, S("1"));
+ test(S(""), 0, "12345", 2, S("12"));
+ test(S(""), 0, "12345", 4, S("1234"));
+ test(S(""), 0, "12345", 5, S("12345"));
+ test(S(""), 0, "1234567890", 0, S(""));
+ test(S(""), 0, "1234567890", 1, S("1"));
+ test(S(""), 0, "1234567890", 5, S("12345"));
+ test(S(""), 0, "1234567890", 9, S("123456789"));
+ test(S(""), 0, "1234567890", 10, S("1234567890"));
+ test(S(""), 0, "12345678901234567890", 0, S(""));
+ test(S(""), 0, "12345678901234567890", 1, S("1"));
+ test(S(""), 0, "12345678901234567890", 10, S("1234567890"));
+ test(S(""), 0, "12345678901234567890", 19, S("1234567890123456789"));
+ test(S(""), 0, "12345678901234567890", 20, S("12345678901234567890"));
+ test(S(""), 1, "", 0, S("can't happen"));
+ test(S(""), 1, "12345", 0, S("can't happen"));
+ test(S(""), 1, "12345", 1, S("can't happen"));
+ test(S(""), 1, "12345", 2, S("can't happen"));
+ test(S(""), 1, "12345", 4, S("can't happen"));
+ test(S(""), 1, "12345", 5, S("can't happen"));
+ test(S(""), 1, "1234567890", 0, S("can't happen"));
+ test(S(""), 1, "1234567890", 1, S("can't happen"));
+ test(S(""), 1, "1234567890", 5, S("can't happen"));
+ test(S(""), 1, "1234567890", 9, S("can't happen"));
+ test(S(""), 1, "1234567890", 10, S("can't happen"));
+ test(S(""), 1, "12345678901234567890", 0, S("can't happen"));
+ test(S(""), 1, "12345678901234567890", 1, S("can't happen"));
+ test(S(""), 1, "12345678901234567890", 10, S("can't happen"));
+ test(S(""), 1, "12345678901234567890", 19, S("can't happen"));
+ test(S(""), 1, "12345678901234567890", 20, S("can't happen"));
+ test(S("abcde"), 0, "", 0, S("abcde"));
+ test(S("abcde"), 0, "12345", 0, S("abcde"));
+ test(S("abcde"), 0, "12345", 1, S("1abcde"));
+ test(S("abcde"), 0, "12345", 2, S("12abcde"));
+ test(S("abcde"), 0, "12345", 4, S("1234abcde"));
+ test(S("abcde"), 0, "12345", 5, S("12345abcde"));
+ test(S("abcde"), 0, "1234567890", 0, S("abcde"));
+ test(S("abcde"), 0, "1234567890", 1, S("1abcde"));
+ test(S("abcde"), 0, "1234567890", 5, S("12345abcde"));
+ test(S("abcde"), 0, "1234567890", 9, S("123456789abcde"));
+ test(S("abcde"), 0, "1234567890", 10, S("1234567890abcde"));
+ test(S("abcde"), 0, "12345678901234567890", 0, S("abcde"));
+ test(S("abcde"), 0, "12345678901234567890", 1, S("1abcde"));
+ test(S("abcde"), 0, "12345678901234567890", 10, S("1234567890abcde"));
+ test(S("abcde"), 0, "12345678901234567890", 19, S("1234567890123456789abcde"));
+ test(S("abcde"), 0, "12345678901234567890", 20, S("12345678901234567890abcde"));
+ test(S("abcde"), 1, "", 0, S("abcde"));
+ test(S("abcde"), 1, "12345", 0, S("abcde"));
+ test(S("abcde"), 1, "12345", 1, S("a1bcde"));
+ test(S("abcde"), 1, "12345", 2, S("a12bcde"));
+ test(S("abcde"), 1, "12345", 4, S("a1234bcde"));
+ test(S("abcde"), 1, "12345", 5, S("a12345bcde"));
+ test(S("abcde"), 1, "1234567890", 0, S("abcde"));
+ test(S("abcde"), 1, "1234567890", 1, S("a1bcde"));
+ test(S("abcde"), 1, "1234567890", 5, S("a12345bcde"));
+ test(S("abcde"), 1, "1234567890", 9, S("a123456789bcde"));
+ test(S("abcde"), 1, "1234567890", 10, S("a1234567890bcde"));
+ test(S("abcde"), 1, "12345678901234567890", 0, S("abcde"));
+ test(S("abcde"), 1, "12345678901234567890", 1, S("a1bcde"));
+ test(S("abcde"), 1, "12345678901234567890", 10, S("a1234567890bcde"));
+ test(S("abcde"), 1, "12345678901234567890", 19, S("a1234567890123456789bcde"));
+ test(S("abcde"), 1, "12345678901234567890", 20, S("a12345678901234567890bcde"));
+ test(S("abcde"), 2, "", 0, S("abcde"));
+ test(S("abcde"), 2, "12345", 0, S("abcde"));
+ test(S("abcde"), 2, "12345", 1, S("ab1cde"));
+ test(S("abcde"), 2, "12345", 2, S("ab12cde"));
+ test(S("abcde"), 2, "12345", 4, S("ab1234cde"));
+ test(S("abcde"), 2, "12345", 5, S("ab12345cde"));
+ test(S("abcde"), 2, "1234567890", 0, S("abcde"));
+ test(S("abcde"), 2, "1234567890", 1, S("ab1cde"));
+ test(S("abcde"), 2, "1234567890", 5, S("ab12345cde"));
+ test(S("abcde"), 2, "1234567890", 9, S("ab123456789cde"));
+ test(S("abcde"), 2, "1234567890", 10, S("ab1234567890cde"));
+ test(S("abcde"), 2, "12345678901234567890", 0, S("abcde"));
+ test(S("abcde"), 2, "12345678901234567890", 1, S("ab1cde"));
+ test(S("abcde"), 2, "12345678901234567890", 10, S("ab1234567890cde"));
+ test(S("abcde"), 2, "12345678901234567890", 19, S("ab1234567890123456789cde"));
+ test(S("abcde"), 2, "12345678901234567890", 20, S("ab12345678901234567890cde"));
+ test(S("abcde"), 4, "", 0, S("abcde"));
+ test(S("abcde"), 4, "12345", 0, S("abcde"));
+ test(S("abcde"), 4, "12345", 1, S("abcd1e"));
+ test(S("abcde"), 4, "12345", 2, S("abcd12e"));
+ test(S("abcde"), 4, "12345", 4, S("abcd1234e"));
+ test(S("abcde"), 4, "12345", 5, S("abcd12345e"));
+ test(S("abcde"), 4, "1234567890", 0, S("abcde"));
+ test(S("abcde"), 4, "1234567890", 1, S("abcd1e"));
+ test(S("abcde"), 4, "1234567890", 5, S("abcd12345e"));
+ test(S("abcde"), 4, "1234567890", 9, S("abcd123456789e"));
+ test(S("abcde"), 4, "1234567890", 10, S("abcd1234567890e"));
+ test(S("abcde"), 4, "12345678901234567890", 0, S("abcde"));
+ test(S("abcde"), 4, "12345678901234567890", 1, S("abcd1e"));
+ test(S("abcde"), 4, "12345678901234567890", 10, S("abcd1234567890e"));
+ test(S("abcde"), 4, "12345678901234567890", 19, S("abcd1234567890123456789e"));
+ test(S("abcde"), 4, "12345678901234567890", 20, S("abcd12345678901234567890e"));
+ test(S("abcde"), 5, "", 0, S("abcde"));
+ test(S("abcde"), 5, "12345", 0, S("abcde"));
+ test(S("abcde"), 5, "12345", 1, S("abcde1"));
+ test(S("abcde"), 5, "12345", 2, S("abcde12"));
+ test(S("abcde"), 5, "12345", 4, S("abcde1234"));
+ test(S("abcde"), 5, "12345", 5, S("abcde12345"));
+ test(S("abcde"), 5, "1234567890", 0, S("abcde"));
+ test(S("abcde"), 5, "1234567890", 1, S("abcde1"));
+ test(S("abcde"), 5, "1234567890", 5, S("abcde12345"));
+ test(S("abcde"), 5, "1234567890", 9, S("abcde123456789"));
+ test(S("abcde"), 5, "1234567890", 10, S("abcde1234567890"));
+ test(S("abcde"), 5, "12345678901234567890", 0, S("abcde"));
+ test(S("abcde"), 5, "12345678901234567890", 1, S("abcde1"));
+ test(S("abcde"), 5, "12345678901234567890", 10, S("abcde1234567890"));
+ test(S("abcde"), 5, "12345678901234567890", 19, S("abcde1234567890123456789"));
+ test(S("abcde"), 5, "12345678901234567890", 20, S("abcde12345678901234567890"));
+ test(S("abcde"), 6, "", 0, S("can't happen"));
+ test(S("abcde"), 6, "12345", 0, S("can't happen"));
+ test(S("abcde"), 6, "12345", 1, S("can't happen"));
+ test(S("abcde"), 6, "12345", 2, S("can't happen"));
+ test(S("abcde"), 6, "12345", 4, S("can't happen"));
+ test(S("abcde"), 6, "12345", 5, S("can't happen"));
+ test(S("abcde"), 6, "1234567890", 0, S("can't happen"));
+ test(S("abcde"), 6, "1234567890", 1, S("can't happen"));
+ test(S("abcde"), 6, "1234567890", 5, S("can't happen"));
+ test(S("abcde"), 6, "1234567890", 9, S("can't happen"));
+ test(S("abcde"), 6, "1234567890", 10, S("can't happen"));
+ test(S("abcde"), 6, "12345678901234567890", 0, S("can't happen"));
+ test(S("abcde"), 6, "12345678901234567890", 1, S("can't happen"));
+ test(S("abcde"), 6, "12345678901234567890", 10, S("can't happen"));
+ test(S("abcde"), 6, "12345678901234567890", 19, S("can't happen"));
+ test(S("abcde"), 6, "12345678901234567890", 20, S("can't happen"));
+ test(S("abcdefghij"), 0, "", 0, S("abcdefghij"));
+ test(S("abcdefghij"), 0, "12345", 0, S("abcdefghij"));
+ test(S("abcdefghij"), 0, "12345", 1, S("1abcdefghij"));
+ test(S("abcdefghij"), 0, "12345", 2, S("12abcdefghij"));
+ test(S("abcdefghij"), 0, "12345", 4, S("1234abcdefghij"));
+ test(S("abcdefghij"), 0, "12345", 5, S("12345abcdefghij"));
+ test(S("abcdefghij"), 0, "1234567890", 0, S("abcdefghij"));
+ test(S("abcdefghij"), 0, "1234567890", 1, S("1abcdefghij"));
+ test(S("abcdefghij"), 0, "1234567890", 5, S("12345abcdefghij"));
+ test(S("abcdefghij"), 0, "1234567890", 9, S("123456789abcdefghij"));
+ test(S("abcdefghij"), 0, "1234567890", 10, S("1234567890abcdefghij"));
+ test(S("abcdefghij"), 0, "12345678901234567890", 0, S("abcdefghij"));
+ test(S("abcdefghij"), 0, "12345678901234567890", 1, S("1abcdefghij"));
+ test(S("abcdefghij"), 0, "12345678901234567890", 10, S("1234567890abcdefghij"));
+ test(S("abcdefghij"), 0, "12345678901234567890", 19, S("1234567890123456789abcdefghij"));
+ test(S("abcdefghij"), 0, "12345678901234567890", 20, S("12345678901234567890abcdefghij"));
+ test(S("abcdefghij"), 1, "", 0, S("abcdefghij"));
+ test(S("abcdefghij"), 1, "12345", 0, S("abcdefghij"));
+ test(S("abcdefghij"), 1, "12345", 1, S("a1bcdefghij"));
+ test(S("abcdefghij"), 1, "12345", 2, S("a12bcdefghij"));
+ test(S("abcdefghij"), 1, "12345", 4, S("a1234bcdefghij"));
+ test(S("abcdefghij"), 1, "12345", 5, S("a12345bcdefghij"));
+ test(S("abcdefghij"), 1, "1234567890", 0, S("abcdefghij"));
+ test(S("abcdefghij"), 1, "1234567890", 1, S("a1bcdefghij"));
+ test(S("abcdefghij"), 1, "1234567890", 5, S("a12345bcdefghij"));
+ test(S("abcdefghij"), 1, "1234567890", 9, S("a123456789bcdefghij"));
+ test(S("abcdefghij"), 1, "1234567890", 10, S("a1234567890bcdefghij"));
+ test(S("abcdefghij"), 1, "12345678901234567890", 0, S("abcdefghij"));
+ test(S("abcdefghij"), 1, "12345678901234567890", 1, S("a1bcdefghij"));
+ test(S("abcdefghij"), 1, "12345678901234567890", 10, S("a1234567890bcdefghij"));
+ test(S("abcdefghij"), 1, "12345678901234567890", 19, S("a1234567890123456789bcdefghij"));
+ test(S("abcdefghij"), 1, "12345678901234567890", 20, S("a12345678901234567890bcdefghij"));
+ test(S("abcdefghij"), 5, "", 0, S("abcdefghij"));
+ test(S("abcdefghij"), 5, "12345", 0, S("abcdefghij"));
+ test(S("abcdefghij"), 5, "12345", 1, S("abcde1fghij"));
+ test(S("abcdefghij"), 5, "12345", 2, S("abcde12fghij"));
+ test(S("abcdefghij"), 5, "12345", 4, S("abcde1234fghij"));
+ test(S("abcdefghij"), 5, "12345", 5, S("abcde12345fghij"));
+ test(S("abcdefghij"), 5, "1234567890", 0, S("abcdefghij"));
+ test(S("abcdefghij"), 5, "1234567890", 1, S("abcde1fghij"));
+ test(S("abcdefghij"), 5, "1234567890", 5, S("abcde12345fghij"));
+ test(S("abcdefghij"), 5, "1234567890", 9, S("abcde123456789fghij"));
+ test(S("abcdefghij"), 5, "1234567890", 10, S("abcde1234567890fghij"));
+ test(S("abcdefghij"), 5, "12345678901234567890", 0, S("abcdefghij"));
+ test(S("abcdefghij"), 5, "12345678901234567890", 1, S("abcde1fghij"));
+ test(S("abcdefghij"), 5, "12345678901234567890", 10, S("abcde1234567890fghij"));
+ test(S("abcdefghij"), 5, "12345678901234567890", 19, S("abcde1234567890123456789fghij"));
+ test(S("abcdefghij"), 5, "12345678901234567890", 20, S("abcde12345678901234567890fghij"));
+ test(S("abcdefghij"), 9, "", 0, S("abcdefghij"));
+ test(S("abcdefghij"), 9, "12345", 0, S("abcdefghij"));
+ test(S("abcdefghij"), 9, "12345", 1, S("abcdefghi1j"));
+ test(S("abcdefghij"), 9, "12345", 2, S("abcdefghi12j"));
+ test(S("abcdefghij"), 9, "12345", 4, S("abcdefghi1234j"));
+ test(S("abcdefghij"), 9, "12345", 5, S("abcdefghi12345j"));
+ test(S("abcdefghij"), 9, "1234567890", 0, S("abcdefghij"));
+ test(S("abcdefghij"), 9, "1234567890", 1, S("abcdefghi1j"));
+ test(S("abcdefghij"), 9, "1234567890", 5, S("abcdefghi12345j"));
+ test(S("abcdefghij"), 9, "1234567890", 9, S("abcdefghi123456789j"));
+ test(S("abcdefghij"), 9, "1234567890", 10, S("abcdefghi1234567890j"));
+ test(S("abcdefghij"), 9, "12345678901234567890", 0, S("abcdefghij"));
+ test(S("abcdefghij"), 9, "12345678901234567890", 1, S("abcdefghi1j"));
+ test(S("abcdefghij"), 9, "12345678901234567890", 10, S("abcdefghi1234567890j"));
+ test(S("abcdefghij"), 9, "12345678901234567890", 19, S("abcdefghi1234567890123456789j"));
+ test(S("abcdefghij"), 9, "12345678901234567890", 20, S("abcdefghi12345678901234567890j"));
+ test(S("abcdefghij"), 10, "", 0, S("abcdefghij"));
+ test(S("abcdefghij"), 10, "12345", 0, S("abcdefghij"));
+ test(S("abcdefghij"), 10, "12345", 1, S("abcdefghij1"));
+ test(S("abcdefghij"), 10, "12345", 2, S("abcdefghij12"));
+ test(S("abcdefghij"), 10, "12345", 4, S("abcdefghij1234"));
+ test(S("abcdefghij"), 10, "12345", 5, S("abcdefghij12345"));
+ test(S("abcdefghij"), 10, "1234567890", 0, S("abcdefghij"));
+ test(S("abcdefghij"), 10, "1234567890", 1, S("abcdefghij1"));
+ test(S("abcdefghij"), 10, "1234567890", 5, S("abcdefghij12345"));
+ test(S("abcdefghij"), 10, "1234567890", 9, S("abcdefghij123456789"));
+ test(S("abcdefghij"), 10, "1234567890", 10, S("abcdefghij1234567890"));
+ test(S("abcdefghij"), 10, "12345678901234567890", 0, S("abcdefghij"));
+ test(S("abcdefghij"), 10, "12345678901234567890", 1, S("abcdefghij1"));
+ test(S("abcdefghij"), 10, "12345678901234567890", 10, S("abcdefghij1234567890"));
+ test(S("abcdefghij"), 10, "12345678901234567890", 19, S("abcdefghij1234567890123456789"));
+ test(S("abcdefghij"), 10, "12345678901234567890", 20, S("abcdefghij12345678901234567890"));
+ test(S("abcdefghij"), 11, "", 0, S("can't happen"));
+ test(S("abcdefghij"), 11, "12345", 0, S("can't happen"));
+ test(S("abcdefghij"), 11, "12345", 1, S("can't happen"));
+ test(S("abcdefghij"), 11, "12345", 2, S("can't happen"));
+ test(S("abcdefghij"), 11, "12345", 4, S("can't happen"));
+ test(S("abcdefghij"), 11, "12345", 5, S("can't happen"));
+ test(S("abcdefghij"), 11, "1234567890", 0, S("can't happen"));
+ test(S("abcdefghij"), 11, "1234567890", 1, S("can't happen"));
+ test(S("abcdefghij"), 11, "1234567890", 5, S("can't happen"));
+ test(S("abcdefghij"), 11, "1234567890", 9, S("can't happen"));
+ test(S("abcdefghij"), 11, "1234567890", 10, S("can't happen"));
+ test(S("abcdefghij"), 11, "12345678901234567890", 0, S("can't happen"));
+ test(S("abcdefghij"), 11, "12345678901234567890", 1, S("can't happen"));
+ test(S("abcdefghij"), 11, "12345678901234567890", 10, S("can't happen"));
+ test(S("abcdefghij"), 11, "12345678901234567890", 19, S("can't happen"));
+ test(S("abcdefghij"), 11, "12345678901234567890", 20, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 0, "", 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, "12345", 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, "12345", 1, S("1abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, "12345", 2, S("12abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, "12345", 4, S("1234abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, "12345", 5, S("12345abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, "1234567890", 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, "1234567890", 1, S("1abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, "1234567890", 5, S("12345abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, "1234567890", 9, S("123456789abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, "1234567890", 10, S("1234567890abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, "12345678901234567890", 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, "12345678901234567890", 1, S("1abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, "12345678901234567890", 10, S("1234567890abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, "12345678901234567890", 19, S("1234567890123456789abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, "12345678901234567890", 20, S("12345678901234567890abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, "", 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, "12345", 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, "12345", 1, S("a1bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, "12345", 2, S("a12bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, "12345", 4, S("a1234bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, "12345", 5, S("a12345bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, "1234567890", 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, "1234567890", 1, S("a1bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, "1234567890", 5, S("a12345bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, "1234567890", 9, S("a123456789bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, "1234567890", 10, S("a1234567890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, "12345678901234567890", 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, "12345678901234567890", 1, S("a1bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, "12345678901234567890", 10, S("a1234567890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, "12345678901234567890", 19, S("a1234567890123456789bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, "12345678901234567890", 20, S("a12345678901234567890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, "", 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, "12345", 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, "12345", 1, S("abcdefghij1klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, "12345", 2, S("abcdefghij12klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, "12345", 4, S("abcdefghij1234klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, "12345", 5, S("abcdefghij12345klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, "1234567890", 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, "1234567890", 1, S("abcdefghij1klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, "1234567890", 5, S("abcdefghij12345klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, "1234567890", 9, S("abcdefghij123456789klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, "1234567890", 10, S("abcdefghij1234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, "12345678901234567890", 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, "12345678901234567890", 1, S("abcdefghij1klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, "12345678901234567890", 10, S("abcdefghij1234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, "12345678901234567890", 19, S("abcdefghij1234567890123456789klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, "12345678901234567890", 20, S("abcdefghij12345678901234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, "", 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, "12345", 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, "12345", 1, S("abcdefghijklmnopqrs1t"));
+ test(S("abcdefghijklmnopqrst"), 19, "12345", 2, S("abcdefghijklmnopqrs12t"));
+ test(S("abcdefghijklmnopqrst"), 19, "12345", 4, S("abcdefghijklmnopqrs1234t"));
+ test(S("abcdefghijklmnopqrst"), 19, "12345", 5, S("abcdefghijklmnopqrs12345t"));
+ test(S("abcdefghijklmnopqrst"), 19, "1234567890", 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, "1234567890", 1, S("abcdefghijklmnopqrs1t"));
+ test(S("abcdefghijklmnopqrst"), 19, "1234567890", 5, S("abcdefghijklmnopqrs12345t"));
+ test(S("abcdefghijklmnopqrst"), 19, "1234567890", 9, S("abcdefghijklmnopqrs123456789t"));
+ test(S("abcdefghijklmnopqrst"), 19, "1234567890", 10, S("abcdefghijklmnopqrs1234567890t"));
+ test(S("abcdefghijklmnopqrst"), 19, "12345678901234567890", 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, "12345678901234567890", 1, S("abcdefghijklmnopqrs1t"));
+ test(S("abcdefghijklmnopqrst"), 19, "12345678901234567890", 10, S("abcdefghijklmnopqrs1234567890t"));
+ test(S("abcdefghijklmnopqrst"), 19, "12345678901234567890", 19, S("abcdefghijklmnopqrs1234567890123456789t"));
+ test(S("abcdefghijklmnopqrst"), 19, "12345678901234567890", 20, S("abcdefghijklmnopqrs12345678901234567890t"));
+ test(S("abcdefghijklmnopqrst"), 20, "", 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, "12345", 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, "12345", 1, S("abcdefghijklmnopqrst1"));
+ test(S("abcdefghijklmnopqrst"), 20, "12345", 2, S("abcdefghijklmnopqrst12"));
+ test(S("abcdefghijklmnopqrst"), 20, "12345", 4, S("abcdefghijklmnopqrst1234"));
+ test(S("abcdefghijklmnopqrst"), 20, "12345", 5, S("abcdefghijklmnopqrst12345"));
+ test(S("abcdefghijklmnopqrst"), 20, "1234567890", 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, "1234567890", 1, S("abcdefghijklmnopqrst1"));
+ test(S("abcdefghijklmnopqrst"), 20, "1234567890", 5, S("abcdefghijklmnopqrst12345"));
+ test(S("abcdefghijklmnopqrst"), 20, "1234567890", 9, S("abcdefghijklmnopqrst123456789"));
+ test(S("abcdefghijklmnopqrst"), 20, "1234567890", 10, S("abcdefghijklmnopqrst1234567890"));
+ test(S("abcdefghijklmnopqrst"), 20, "12345678901234567890", 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, "12345678901234567890", 1, S("abcdefghijklmnopqrst1"));
+ test(S("abcdefghijklmnopqrst"), 20, "12345678901234567890", 10, S("abcdefghijklmnopqrst1234567890"));
+ test(S("abcdefghijklmnopqrst"), 20, "12345678901234567890", 19, S("abcdefghijklmnopqrst1234567890123456789"));
+ test(S("abcdefghijklmnopqrst"), 20, "12345678901234567890", 20, S("abcdefghijklmnopqrst12345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 21, "", 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, "12345", 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, "12345", 1, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, "12345", 2, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, "12345", 4, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, "12345", 5, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, "1234567890", 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, "1234567890", 1, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, "1234567890", 5, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, "1234567890", 9, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, "1234567890", 10, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, "12345678901234567890", 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, "12345678901234567890", 1, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, "12345678901234567890", 10, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, "12345678901234567890", 19, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, "12345678901234567890", 20, S("can't happen"));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S(""), 0, "", 0, S(""));
+ test(S(""), 0, "12345", 0, S(""));
+ test(S(""), 0, "12345", 1, S("1"));
+ test(S(""), 0, "12345", 2, S("12"));
+ test(S(""), 0, "12345", 4, S("1234"));
+ test(S(""), 0, "12345", 5, S("12345"));
+ test(S(""), 0, "1234567890", 0, S(""));
+ test(S(""), 0, "1234567890", 1, S("1"));
+ test(S(""), 0, "1234567890", 5, S("12345"));
+ test(S(""), 0, "1234567890", 9, S("123456789"));
+ test(S(""), 0, "1234567890", 10, S("1234567890"));
+ test(S(""), 0, "12345678901234567890", 0, S(""));
+ test(S(""), 0, "12345678901234567890", 1, S("1"));
+ test(S(""), 0, "12345678901234567890", 10, S("1234567890"));
+ test(S(""), 0, "12345678901234567890", 19, S("1234567890123456789"));
+ test(S(""), 0, "12345678901234567890", 20, S("12345678901234567890"));
+ test(S(""), 1, "", 0, S("can't happen"));
+ test(S(""), 1, "12345", 0, S("can't happen"));
+ test(S(""), 1, "12345", 1, S("can't happen"));
+ test(S(""), 1, "12345", 2, S("can't happen"));
+ test(S(""), 1, "12345", 4, S("can't happen"));
+ test(S(""), 1, "12345", 5, S("can't happen"));
+ test(S(""), 1, "1234567890", 0, S("can't happen"));
+ test(S(""), 1, "1234567890", 1, S("can't happen"));
+ test(S(""), 1, "1234567890", 5, S("can't happen"));
+ test(S(""), 1, "1234567890", 9, S("can't happen"));
+ test(S(""), 1, "1234567890", 10, S("can't happen"));
+ test(S(""), 1, "12345678901234567890", 0, S("can't happen"));
+ test(S(""), 1, "12345678901234567890", 1, S("can't happen"));
+ test(S(""), 1, "12345678901234567890", 10, S("can't happen"));
+ test(S(""), 1, "12345678901234567890", 19, S("can't happen"));
+ test(S(""), 1, "12345678901234567890", 20, S("can't happen"));
+ test(S("abcde"), 0, "", 0, S("abcde"));
+ test(S("abcde"), 0, "12345", 0, S("abcde"));
+ test(S("abcde"), 0, "12345", 1, S("1abcde"));
+ test(S("abcde"), 0, "12345", 2, S("12abcde"));
+ test(S("abcde"), 0, "12345", 4, S("1234abcde"));
+ test(S("abcde"), 0, "12345", 5, S("12345abcde"));
+ test(S("abcde"), 0, "1234567890", 0, S("abcde"));
+ test(S("abcde"), 0, "1234567890", 1, S("1abcde"));
+ test(S("abcde"), 0, "1234567890", 5, S("12345abcde"));
+ test(S("abcde"), 0, "1234567890", 9, S("123456789abcde"));
+ test(S("abcde"), 0, "1234567890", 10, S("1234567890abcde"));
+ test(S("abcde"), 0, "12345678901234567890", 0, S("abcde"));
+ test(S("abcde"), 0, "12345678901234567890", 1, S("1abcde"));
+ test(S("abcde"), 0, "12345678901234567890", 10, S("1234567890abcde"));
+ test(S("abcde"), 0, "12345678901234567890", 19, S("1234567890123456789abcde"));
+ test(S("abcde"), 0, "12345678901234567890", 20, S("12345678901234567890abcde"));
+ test(S("abcde"), 1, "", 0, S("abcde"));
+ test(S("abcde"), 1, "12345", 0, S("abcde"));
+ test(S("abcde"), 1, "12345", 1, S("a1bcde"));
+ test(S("abcde"), 1, "12345", 2, S("a12bcde"));
+ test(S("abcde"), 1, "12345", 4, S("a1234bcde"));
+ test(S("abcde"), 1, "12345", 5, S("a12345bcde"));
+ test(S("abcde"), 1, "1234567890", 0, S("abcde"));
+ test(S("abcde"), 1, "1234567890", 1, S("a1bcde"));
+ test(S("abcde"), 1, "1234567890", 5, S("a12345bcde"));
+ test(S("abcde"), 1, "1234567890", 9, S("a123456789bcde"));
+ test(S("abcde"), 1, "1234567890", 10, S("a1234567890bcde"));
+ test(S("abcde"), 1, "12345678901234567890", 0, S("abcde"));
+ test(S("abcde"), 1, "12345678901234567890", 1, S("a1bcde"));
+ test(S("abcde"), 1, "12345678901234567890", 10, S("a1234567890bcde"));
+ test(S("abcde"), 1, "12345678901234567890", 19, S("a1234567890123456789bcde"));
+ test(S("abcde"), 1, "12345678901234567890", 20, S("a12345678901234567890bcde"));
+ test(S("abcde"), 2, "", 0, S("abcde"));
+ test(S("abcde"), 2, "12345", 0, S("abcde"));
+ test(S("abcde"), 2, "12345", 1, S("ab1cde"));
+ test(S("abcde"), 2, "12345", 2, S("ab12cde"));
+ test(S("abcde"), 2, "12345", 4, S("ab1234cde"));
+ test(S("abcde"), 2, "12345", 5, S("ab12345cde"));
+ test(S("abcde"), 2, "1234567890", 0, S("abcde"));
+ test(S("abcde"), 2, "1234567890", 1, S("ab1cde"));
+ test(S("abcde"), 2, "1234567890", 5, S("ab12345cde"));
+ test(S("abcde"), 2, "1234567890", 9, S("ab123456789cde"));
+ test(S("abcde"), 2, "1234567890", 10, S("ab1234567890cde"));
+ test(S("abcde"), 2, "12345678901234567890", 0, S("abcde"));
+ test(S("abcde"), 2, "12345678901234567890", 1, S("ab1cde"));
+ test(S("abcde"), 2, "12345678901234567890", 10, S("ab1234567890cde"));
+ test(S("abcde"), 2, "12345678901234567890", 19, S("ab1234567890123456789cde"));
+ test(S("abcde"), 2, "12345678901234567890", 20, S("ab12345678901234567890cde"));
+ test(S("abcde"), 4, "", 0, S("abcde"));
+ test(S("abcde"), 4, "12345", 0, S("abcde"));
+ test(S("abcde"), 4, "12345", 1, S("abcd1e"));
+ test(S("abcde"), 4, "12345", 2, S("abcd12e"));
+ test(S("abcde"), 4, "12345", 4, S("abcd1234e"));
+ test(S("abcde"), 4, "12345", 5, S("abcd12345e"));
+ test(S("abcde"), 4, "1234567890", 0, S("abcde"));
+ test(S("abcde"), 4, "1234567890", 1, S("abcd1e"));
+ test(S("abcde"), 4, "1234567890", 5, S("abcd12345e"));
+ test(S("abcde"), 4, "1234567890", 9, S("abcd123456789e"));
+ test(S("abcde"), 4, "1234567890", 10, S("abcd1234567890e"));
+ test(S("abcde"), 4, "12345678901234567890", 0, S("abcde"));
+ test(S("abcde"), 4, "12345678901234567890", 1, S("abcd1e"));
+ test(S("abcde"), 4, "12345678901234567890", 10, S("abcd1234567890e"));
+ test(S("abcde"), 4, "12345678901234567890", 19, S("abcd1234567890123456789e"));
+ test(S("abcde"), 4, "12345678901234567890", 20, S("abcd12345678901234567890e"));
+ test(S("abcde"), 5, "", 0, S("abcde"));
+ test(S("abcde"), 5, "12345", 0, S("abcde"));
+ test(S("abcde"), 5, "12345", 1, S("abcde1"));
+ test(S("abcde"), 5, "12345", 2, S("abcde12"));
+ test(S("abcde"), 5, "12345", 4, S("abcde1234"));
+ test(S("abcde"), 5, "12345", 5, S("abcde12345"));
+ test(S("abcde"), 5, "1234567890", 0, S("abcde"));
+ test(S("abcde"), 5, "1234567890", 1, S("abcde1"));
+ test(S("abcde"), 5, "1234567890", 5, S("abcde12345"));
+ test(S("abcde"), 5, "1234567890", 9, S("abcde123456789"));
+ test(S("abcde"), 5, "1234567890", 10, S("abcde1234567890"));
+ test(S("abcde"), 5, "12345678901234567890", 0, S("abcde"));
+ test(S("abcde"), 5, "12345678901234567890", 1, S("abcde1"));
+ test(S("abcde"), 5, "12345678901234567890", 10, S("abcde1234567890"));
+ test(S("abcde"), 5, "12345678901234567890", 19, S("abcde1234567890123456789"));
+ test(S("abcde"), 5, "12345678901234567890", 20, S("abcde12345678901234567890"));
+ test(S("abcde"), 6, "", 0, S("can't happen"));
+ test(S("abcde"), 6, "12345", 0, S("can't happen"));
+ test(S("abcde"), 6, "12345", 1, S("can't happen"));
+ test(S("abcde"), 6, "12345", 2, S("can't happen"));
+ test(S("abcde"), 6, "12345", 4, S("can't happen"));
+ test(S("abcde"), 6, "12345", 5, S("can't happen"));
+ test(S("abcde"), 6, "1234567890", 0, S("can't happen"));
+ test(S("abcde"), 6, "1234567890", 1, S("can't happen"));
+ test(S("abcde"), 6, "1234567890", 5, S("can't happen"));
+ test(S("abcde"), 6, "1234567890", 9, S("can't happen"));
+ test(S("abcde"), 6, "1234567890", 10, S("can't happen"));
+ test(S("abcde"), 6, "12345678901234567890", 0, S("can't happen"));
+ test(S("abcde"), 6, "12345678901234567890", 1, S("can't happen"));
+ test(S("abcde"), 6, "12345678901234567890", 10, S("can't happen"));
+ test(S("abcde"), 6, "12345678901234567890", 19, S("can't happen"));
+ test(S("abcde"), 6, "12345678901234567890", 20, S("can't happen"));
+ test(S("abcdefghij"), 0, "", 0, S("abcdefghij"));
+ test(S("abcdefghij"), 0, "12345", 0, S("abcdefghij"));
+ test(S("abcdefghij"), 0, "12345", 1, S("1abcdefghij"));
+ test(S("abcdefghij"), 0, "12345", 2, S("12abcdefghij"));
+ test(S("abcdefghij"), 0, "12345", 4, S("1234abcdefghij"));
+ test(S("abcdefghij"), 0, "12345", 5, S("12345abcdefghij"));
+ test(S("abcdefghij"), 0, "1234567890", 0, S("abcdefghij"));
+ test(S("abcdefghij"), 0, "1234567890", 1, S("1abcdefghij"));
+ test(S("abcdefghij"), 0, "1234567890", 5, S("12345abcdefghij"));
+ test(S("abcdefghij"), 0, "1234567890", 9, S("123456789abcdefghij"));
+ test(S("abcdefghij"), 0, "1234567890", 10, S("1234567890abcdefghij"));
+ test(S("abcdefghij"), 0, "12345678901234567890", 0, S("abcdefghij"));
+ test(S("abcdefghij"), 0, "12345678901234567890", 1, S("1abcdefghij"));
+ test(S("abcdefghij"), 0, "12345678901234567890", 10, S("1234567890abcdefghij"));
+ test(S("abcdefghij"), 0, "12345678901234567890", 19, S("1234567890123456789abcdefghij"));
+ test(S("abcdefghij"), 0, "12345678901234567890", 20, S("12345678901234567890abcdefghij"));
+ test(S("abcdefghij"), 1, "", 0, S("abcdefghij"));
+ test(S("abcdefghij"), 1, "12345", 0, S("abcdefghij"));
+ test(S("abcdefghij"), 1, "12345", 1, S("a1bcdefghij"));
+ test(S("abcdefghij"), 1, "12345", 2, S("a12bcdefghij"));
+ test(S("abcdefghij"), 1, "12345", 4, S("a1234bcdefghij"));
+ test(S("abcdefghij"), 1, "12345", 5, S("a12345bcdefghij"));
+ test(S("abcdefghij"), 1, "1234567890", 0, S("abcdefghij"));
+ test(S("abcdefghij"), 1, "1234567890", 1, S("a1bcdefghij"));
+ test(S("abcdefghij"), 1, "1234567890", 5, S("a12345bcdefghij"));
+ test(S("abcdefghij"), 1, "1234567890", 9, S("a123456789bcdefghij"));
+ test(S("abcdefghij"), 1, "1234567890", 10, S("a1234567890bcdefghij"));
+ test(S("abcdefghij"), 1, "12345678901234567890", 0, S("abcdefghij"));
+ test(S("abcdefghij"), 1, "12345678901234567890", 1, S("a1bcdefghij"));
+ test(S("abcdefghij"), 1, "12345678901234567890", 10, S("a1234567890bcdefghij"));
+ test(S("abcdefghij"), 1, "12345678901234567890", 19, S("a1234567890123456789bcdefghij"));
+ test(S("abcdefghij"), 1, "12345678901234567890", 20, S("a12345678901234567890bcdefghij"));
+ test(S("abcdefghij"), 5, "", 0, S("abcdefghij"));
+ test(S("abcdefghij"), 5, "12345", 0, S("abcdefghij"));
+ test(S("abcdefghij"), 5, "12345", 1, S("abcde1fghij"));
+ test(S("abcdefghij"), 5, "12345", 2, S("abcde12fghij"));
+ test(S("abcdefghij"), 5, "12345", 4, S("abcde1234fghij"));
+ test(S("abcdefghij"), 5, "12345", 5, S("abcde12345fghij"));
+ test(S("abcdefghij"), 5, "1234567890", 0, S("abcdefghij"));
+ test(S("abcdefghij"), 5, "1234567890", 1, S("abcde1fghij"));
+ test(S("abcdefghij"), 5, "1234567890", 5, S("abcde12345fghij"));
+ test(S("abcdefghij"), 5, "1234567890", 9, S("abcde123456789fghij"));
+ test(S("abcdefghij"), 5, "1234567890", 10, S("abcde1234567890fghij"));
+ test(S("abcdefghij"), 5, "12345678901234567890", 0, S("abcdefghij"));
+ test(S("abcdefghij"), 5, "12345678901234567890", 1, S("abcde1fghij"));
+ test(S("abcdefghij"), 5, "12345678901234567890", 10, S("abcde1234567890fghij"));
+ test(S("abcdefghij"), 5, "12345678901234567890", 19, S("abcde1234567890123456789fghij"));
+ test(S("abcdefghij"), 5, "12345678901234567890", 20, S("abcde12345678901234567890fghij"));
+ test(S("abcdefghij"), 9, "", 0, S("abcdefghij"));
+ test(S("abcdefghij"), 9, "12345", 0, S("abcdefghij"));
+ test(S("abcdefghij"), 9, "12345", 1, S("abcdefghi1j"));
+ test(S("abcdefghij"), 9, "12345", 2, S("abcdefghi12j"));
+ test(S("abcdefghij"), 9, "12345", 4, S("abcdefghi1234j"));
+ test(S("abcdefghij"), 9, "12345", 5, S("abcdefghi12345j"));
+ test(S("abcdefghij"), 9, "1234567890", 0, S("abcdefghij"));
+ test(S("abcdefghij"), 9, "1234567890", 1, S("abcdefghi1j"));
+ test(S("abcdefghij"), 9, "1234567890", 5, S("abcdefghi12345j"));
+ test(S("abcdefghij"), 9, "1234567890", 9, S("abcdefghi123456789j"));
+ test(S("abcdefghij"), 9, "1234567890", 10, S("abcdefghi1234567890j"));
+ test(S("abcdefghij"), 9, "12345678901234567890", 0, S("abcdefghij"));
+ test(S("abcdefghij"), 9, "12345678901234567890", 1, S("abcdefghi1j"));
+ test(S("abcdefghij"), 9, "12345678901234567890", 10, S("abcdefghi1234567890j"));
+ test(S("abcdefghij"), 9, "12345678901234567890", 19, S("abcdefghi1234567890123456789j"));
+ test(S("abcdefghij"), 9, "12345678901234567890", 20, S("abcdefghi12345678901234567890j"));
+ test(S("abcdefghij"), 10, "", 0, S("abcdefghij"));
+ test(S("abcdefghij"), 10, "12345", 0, S("abcdefghij"));
+ test(S("abcdefghij"), 10, "12345", 1, S("abcdefghij1"));
+ test(S("abcdefghij"), 10, "12345", 2, S("abcdefghij12"));
+ test(S("abcdefghij"), 10, "12345", 4, S("abcdefghij1234"));
+ test(S("abcdefghij"), 10, "12345", 5, S("abcdefghij12345"));
+ test(S("abcdefghij"), 10, "1234567890", 0, S("abcdefghij"));
+ test(S("abcdefghij"), 10, "1234567890", 1, S("abcdefghij1"));
+ test(S("abcdefghij"), 10, "1234567890", 5, S("abcdefghij12345"));
+ test(S("abcdefghij"), 10, "1234567890", 9, S("abcdefghij123456789"));
+ test(S("abcdefghij"), 10, "1234567890", 10, S("abcdefghij1234567890"));
+ test(S("abcdefghij"), 10, "12345678901234567890", 0, S("abcdefghij"));
+ test(S("abcdefghij"), 10, "12345678901234567890", 1, S("abcdefghij1"));
+ test(S("abcdefghij"), 10, "12345678901234567890", 10, S("abcdefghij1234567890"));
+ test(S("abcdefghij"), 10, "12345678901234567890", 19, S("abcdefghij1234567890123456789"));
+ test(S("abcdefghij"), 10, "12345678901234567890", 20, S("abcdefghij12345678901234567890"));
+ test(S("abcdefghij"), 11, "", 0, S("can't happen"));
+ test(S("abcdefghij"), 11, "12345", 0, S("can't happen"));
+ test(S("abcdefghij"), 11, "12345", 1, S("can't happen"));
+ test(S("abcdefghij"), 11, "12345", 2, S("can't happen"));
+ test(S("abcdefghij"), 11, "12345", 4, S("can't happen"));
+ test(S("abcdefghij"), 11, "12345", 5, S("can't happen"));
+ test(S("abcdefghij"), 11, "1234567890", 0, S("can't happen"));
+ test(S("abcdefghij"), 11, "1234567890", 1, S("can't happen"));
+ test(S("abcdefghij"), 11, "1234567890", 5, S("can't happen"));
+ test(S("abcdefghij"), 11, "1234567890", 9, S("can't happen"));
+ test(S("abcdefghij"), 11, "1234567890", 10, S("can't happen"));
+ test(S("abcdefghij"), 11, "12345678901234567890", 0, S("can't happen"));
+ test(S("abcdefghij"), 11, "12345678901234567890", 1, S("can't happen"));
+ test(S("abcdefghij"), 11, "12345678901234567890", 10, S("can't happen"));
+ test(S("abcdefghij"), 11, "12345678901234567890", 19, S("can't happen"));
+ test(S("abcdefghij"), 11, "12345678901234567890", 20, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 0, "", 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, "12345", 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, "12345", 1, S("1abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, "12345", 2, S("12abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, "12345", 4, S("1234abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, "12345", 5, S("12345abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, "1234567890", 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, "1234567890", 1, S("1abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, "1234567890", 5, S("12345abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, "1234567890", 9, S("123456789abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, "1234567890", 10, S("1234567890abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, "12345678901234567890", 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, "12345678901234567890", 1, S("1abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, "12345678901234567890", 10, S("1234567890abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, "12345678901234567890", 19, S("1234567890123456789abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, "12345678901234567890", 20, S("12345678901234567890abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, "", 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, "12345", 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, "12345", 1, S("a1bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, "12345", 2, S("a12bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, "12345", 4, S("a1234bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, "12345", 5, S("a12345bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, "1234567890", 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, "1234567890", 1, S("a1bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, "1234567890", 5, S("a12345bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, "1234567890", 9, S("a123456789bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, "1234567890", 10, S("a1234567890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, "12345678901234567890", 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, "12345678901234567890", 1, S("a1bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, "12345678901234567890", 10, S("a1234567890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, "12345678901234567890", 19, S("a1234567890123456789bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, "12345678901234567890", 20, S("a12345678901234567890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, "", 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, "12345", 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, "12345", 1, S("abcdefghij1klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, "12345", 2, S("abcdefghij12klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, "12345", 4, S("abcdefghij1234klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, "12345", 5, S("abcdefghij12345klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, "1234567890", 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, "1234567890", 1, S("abcdefghij1klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, "1234567890", 5, S("abcdefghij12345klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, "1234567890", 9, S("abcdefghij123456789klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, "1234567890", 10, S("abcdefghij1234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, "12345678901234567890", 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, "12345678901234567890", 1, S("abcdefghij1klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, "12345678901234567890", 10, S("abcdefghij1234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, "12345678901234567890", 19, S("abcdefghij1234567890123456789klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, "12345678901234567890", 20, S("abcdefghij12345678901234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, "", 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, "12345", 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, "12345", 1, S("abcdefghijklmnopqrs1t"));
+ test(S("abcdefghijklmnopqrst"), 19, "12345", 2, S("abcdefghijklmnopqrs12t"));
+ test(S("abcdefghijklmnopqrst"), 19, "12345", 4, S("abcdefghijklmnopqrs1234t"));
+ test(S("abcdefghijklmnopqrst"), 19, "12345", 5, S("abcdefghijklmnopqrs12345t"));
+ test(S("abcdefghijklmnopqrst"), 19, "1234567890", 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, "1234567890", 1, S("abcdefghijklmnopqrs1t"));
+ test(S("abcdefghijklmnopqrst"), 19, "1234567890", 5, S("abcdefghijklmnopqrs12345t"));
+ test(S("abcdefghijklmnopqrst"), 19, "1234567890", 9, S("abcdefghijklmnopqrs123456789t"));
+ test(S("abcdefghijklmnopqrst"), 19, "1234567890", 10, S("abcdefghijklmnopqrs1234567890t"));
+ test(S("abcdefghijklmnopqrst"), 19, "12345678901234567890", 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, "12345678901234567890", 1, S("abcdefghijklmnopqrs1t"));
+ test(S("abcdefghijklmnopqrst"), 19, "12345678901234567890", 10, S("abcdefghijklmnopqrs1234567890t"));
+ test(S("abcdefghijklmnopqrst"), 19, "12345678901234567890", 19, S("abcdefghijklmnopqrs1234567890123456789t"));
+ test(S("abcdefghijklmnopqrst"), 19, "12345678901234567890", 20, S("abcdefghijklmnopqrs12345678901234567890t"));
+ test(S("abcdefghijklmnopqrst"), 20, "", 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, "12345", 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, "12345", 1, S("abcdefghijklmnopqrst1"));
+ test(S("abcdefghijklmnopqrst"), 20, "12345", 2, S("abcdefghijklmnopqrst12"));
+ test(S("abcdefghijklmnopqrst"), 20, "12345", 4, S("abcdefghijklmnopqrst1234"));
+ test(S("abcdefghijklmnopqrst"), 20, "12345", 5, S("abcdefghijklmnopqrst12345"));
+ test(S("abcdefghijklmnopqrst"), 20, "1234567890", 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, "1234567890", 1, S("abcdefghijklmnopqrst1"));
+ test(S("abcdefghijklmnopqrst"), 20, "1234567890", 5, S("abcdefghijklmnopqrst12345"));
+ test(S("abcdefghijklmnopqrst"), 20, "1234567890", 9, S("abcdefghijklmnopqrst123456789"));
+ test(S("abcdefghijklmnopqrst"), 20, "1234567890", 10, S("abcdefghijklmnopqrst1234567890"));
+ test(S("abcdefghijklmnopqrst"), 20, "12345678901234567890", 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, "12345678901234567890", 1, S("abcdefghijklmnopqrst1"));
+ test(S("abcdefghijklmnopqrst"), 20, "12345678901234567890", 10, S("abcdefghijklmnopqrst1234567890"));
+ test(S("abcdefghijklmnopqrst"), 20, "12345678901234567890", 19, S("abcdefghijklmnopqrst1234567890123456789"));
+ test(S("abcdefghijklmnopqrst"), 20, "12345678901234567890", 20, S("abcdefghijklmnopqrst12345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 21, "", 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, "12345", 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, "12345", 1, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, "12345", 2, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, "12345", 4, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, "12345", 5, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, "1234567890", 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, "1234567890", 1, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, "1234567890", 5, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, "1234567890", 9, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, "1234567890", 10, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, "12345678901234567890", 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, "12345678901234567890", 1, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, "12345678901234567890", 10, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, "12345678901234567890", 19, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, "12345678901234567890", 20, S("can't happen"));
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.modifiers/string_insert/size_size_char.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_insert/size_size_char.pass.cpp
new file mode 100644
index 000000000000..fd85696704cd
--- /dev/null
+++ b/test/std/strings/basic.string/string.modifiers/string_insert/size_size_char.pass.cpp
@@ -0,0 +1,212 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string<charT,traits,Allocator>&
+// insert(size_type pos, size_type n, charT c);
+
+#include <string>
+#include <stdexcept>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s, typename S::size_type pos, typename S::size_type n,
+ typename S::value_type str, S expected)
+{
+ typename S::size_type old_size = s.size();
+ S s0 = s;
+ try
+ {
+ s.insert(pos, n, str);
+ assert(s.__invariants());
+ assert(pos <= old_size);
+ assert(s == expected);
+ }
+ catch (std::out_of_range&)
+ {
+ assert(pos > old_size);
+ assert(s == s0);
+ }
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test(S(""), 0, 0, '1', S(""));
+ test(S(""), 0, 5, '1', S("11111"));
+ test(S(""), 0, 10, '1', S("1111111111"));
+ test(S(""), 0, 20, '1', S("11111111111111111111"));
+ test(S(""), 1, 0, '1', S("can't happen"));
+ test(S(""), 1, 5, '1', S("can't happen"));
+ test(S(""), 1, 10, '1', S("can't happen"));
+ test(S(""), 1, 20, '1', S("can't happen"));
+ test(S("abcde"), 0, 0, '1', S("abcde"));
+ test(S("abcde"), 0, 5, '1', S("11111abcde"));
+ test(S("abcde"), 0, 10, '1', S("1111111111abcde"));
+ test(S("abcde"), 0, 20, '1', S("11111111111111111111abcde"));
+ test(S("abcde"), 1, 0, '1', S("abcde"));
+ test(S("abcde"), 1, 5, '1', S("a11111bcde"));
+ test(S("abcde"), 1, 10, '1', S("a1111111111bcde"));
+ test(S("abcde"), 1, 20, '1', S("a11111111111111111111bcde"));
+ test(S("abcde"), 2, 0, '1', S("abcde"));
+ test(S("abcde"), 2, 5, '1', S("ab11111cde"));
+ test(S("abcde"), 2, 10, '1', S("ab1111111111cde"));
+ test(S("abcde"), 2, 20, '1', S("ab11111111111111111111cde"));
+ test(S("abcde"), 4, 0, '1', S("abcde"));
+ test(S("abcde"), 4, 5, '1', S("abcd11111e"));
+ test(S("abcde"), 4, 10, '1', S("abcd1111111111e"));
+ test(S("abcde"), 4, 20, '1', S("abcd11111111111111111111e"));
+ test(S("abcde"), 5, 0, '1', S("abcde"));
+ test(S("abcde"), 5, 5, '1', S("abcde11111"));
+ test(S("abcde"), 5, 10, '1', S("abcde1111111111"));
+ test(S("abcde"), 5, 20, '1', S("abcde11111111111111111111"));
+ test(S("abcde"), 6, 0, '1', S("can't happen"));
+ test(S("abcde"), 6, 5, '1', S("can't happen"));
+ test(S("abcde"), 6, 10, '1', S("can't happen"));
+ test(S("abcde"), 6, 20, '1', S("can't happen"));
+ test(S("abcdefghij"), 0, 0, '1', S("abcdefghij"));
+ test(S("abcdefghij"), 0, 5, '1', S("11111abcdefghij"));
+ test(S("abcdefghij"), 0, 10, '1', S("1111111111abcdefghij"));
+ test(S("abcdefghij"), 0, 20, '1', S("11111111111111111111abcdefghij"));
+ test(S("abcdefghij"), 1, 0, '1', S("abcdefghij"));
+ test(S("abcdefghij"), 1, 5, '1', S("a11111bcdefghij"));
+ test(S("abcdefghij"), 1, 10, '1', S("a1111111111bcdefghij"));
+ test(S("abcdefghij"), 1, 20, '1', S("a11111111111111111111bcdefghij"));
+ test(S("abcdefghij"), 5, 0, '1', S("abcdefghij"));
+ test(S("abcdefghij"), 5, 5, '1', S("abcde11111fghij"));
+ test(S("abcdefghij"), 5, 10, '1', S("abcde1111111111fghij"));
+ test(S("abcdefghij"), 5, 20, '1', S("abcde11111111111111111111fghij"));
+ test(S("abcdefghij"), 9, 0, '1', S("abcdefghij"));
+ test(S("abcdefghij"), 9, 5, '1', S("abcdefghi11111j"));
+ test(S("abcdefghij"), 9, 10, '1', S("abcdefghi1111111111j"));
+ test(S("abcdefghij"), 9, 20, '1', S("abcdefghi11111111111111111111j"));
+ test(S("abcdefghij"), 10, 0, '1', S("abcdefghij"));
+ test(S("abcdefghij"), 10, 5, '1', S("abcdefghij11111"));
+ test(S("abcdefghij"), 10, 10, '1', S("abcdefghij1111111111"));
+ test(S("abcdefghij"), 10, 20, '1', S("abcdefghij11111111111111111111"));
+ test(S("abcdefghij"), 11, 0, '1', S("can't happen"));
+ test(S("abcdefghij"), 11, 5, '1', S("can't happen"));
+ test(S("abcdefghij"), 11, 10, '1', S("can't happen"));
+ test(S("abcdefghij"), 11, 20, '1', S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, '1', S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 5, '1', S("11111abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, '1', S("1111111111abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, '1', S("11111111111111111111abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, '1', S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 5, '1', S("a11111bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 10, '1', S("a1111111111bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, '1', S("a11111111111111111111bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, '1', S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, '1', S("abcdefghij11111klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, '1', S("abcdefghij1111111111klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 20, '1', S("abcdefghij11111111111111111111klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, '1', S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, 5, '1', S("abcdefghijklmnopqrs11111t"));
+ test(S("abcdefghijklmnopqrst"), 19, 10, '1', S("abcdefghijklmnopqrs1111111111t"));
+ test(S("abcdefghijklmnopqrst"), 19, 20, '1', S("abcdefghijklmnopqrs11111111111111111111t"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, '1', S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, 5, '1', S("abcdefghijklmnopqrst11111"));
+ test(S("abcdefghijklmnopqrst"), 20, 10, '1', S("abcdefghijklmnopqrst1111111111"));
+ test(S("abcdefghijklmnopqrst"), 20, 20, '1', S("abcdefghijklmnopqrst11111111111111111111"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, '1', S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 5, '1', S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 10, '1', S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 20, '1', S("can't happen"));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S(""), 0, 0, '1', S(""));
+ test(S(""), 0, 5, '1', S("11111"));
+ test(S(""), 0, 10, '1', S("1111111111"));
+ test(S(""), 0, 20, '1', S("11111111111111111111"));
+ test(S(""), 1, 0, '1', S("can't happen"));
+ test(S(""), 1, 5, '1', S("can't happen"));
+ test(S(""), 1, 10, '1', S("can't happen"));
+ test(S(""), 1, 20, '1', S("can't happen"));
+ test(S("abcde"), 0, 0, '1', S("abcde"));
+ test(S("abcde"), 0, 5, '1', S("11111abcde"));
+ test(S("abcde"), 0, 10, '1', S("1111111111abcde"));
+ test(S("abcde"), 0, 20, '1', S("11111111111111111111abcde"));
+ test(S("abcde"), 1, 0, '1', S("abcde"));
+ test(S("abcde"), 1, 5, '1', S("a11111bcde"));
+ test(S("abcde"), 1, 10, '1', S("a1111111111bcde"));
+ test(S("abcde"), 1, 20, '1', S("a11111111111111111111bcde"));
+ test(S("abcde"), 2, 0, '1', S("abcde"));
+ test(S("abcde"), 2, 5, '1', S("ab11111cde"));
+ test(S("abcde"), 2, 10, '1', S("ab1111111111cde"));
+ test(S("abcde"), 2, 20, '1', S("ab11111111111111111111cde"));
+ test(S("abcde"), 4, 0, '1', S("abcde"));
+ test(S("abcde"), 4, 5, '1', S("abcd11111e"));
+ test(S("abcde"), 4, 10, '1', S("abcd1111111111e"));
+ test(S("abcde"), 4, 20, '1', S("abcd11111111111111111111e"));
+ test(S("abcde"), 5, 0, '1', S("abcde"));
+ test(S("abcde"), 5, 5, '1', S("abcde11111"));
+ test(S("abcde"), 5, 10, '1', S("abcde1111111111"));
+ test(S("abcde"), 5, 20, '1', S("abcde11111111111111111111"));
+ test(S("abcde"), 6, 0, '1', S("can't happen"));
+ test(S("abcde"), 6, 5, '1', S("can't happen"));
+ test(S("abcde"), 6, 10, '1', S("can't happen"));
+ test(S("abcde"), 6, 20, '1', S("can't happen"));
+ test(S("abcdefghij"), 0, 0, '1', S("abcdefghij"));
+ test(S("abcdefghij"), 0, 5, '1', S("11111abcdefghij"));
+ test(S("abcdefghij"), 0, 10, '1', S("1111111111abcdefghij"));
+ test(S("abcdefghij"), 0, 20, '1', S("11111111111111111111abcdefghij"));
+ test(S("abcdefghij"), 1, 0, '1', S("abcdefghij"));
+ test(S("abcdefghij"), 1, 5, '1', S("a11111bcdefghij"));
+ test(S("abcdefghij"), 1, 10, '1', S("a1111111111bcdefghij"));
+ test(S("abcdefghij"), 1, 20, '1', S("a11111111111111111111bcdefghij"));
+ test(S("abcdefghij"), 5, 0, '1', S("abcdefghij"));
+ test(S("abcdefghij"), 5, 5, '1', S("abcde11111fghij"));
+ test(S("abcdefghij"), 5, 10, '1', S("abcde1111111111fghij"));
+ test(S("abcdefghij"), 5, 20, '1', S("abcde11111111111111111111fghij"));
+ test(S("abcdefghij"), 9, 0, '1', S("abcdefghij"));
+ test(S("abcdefghij"), 9, 5, '1', S("abcdefghi11111j"));
+ test(S("abcdefghij"), 9, 10, '1', S("abcdefghi1111111111j"));
+ test(S("abcdefghij"), 9, 20, '1', S("abcdefghi11111111111111111111j"));
+ test(S("abcdefghij"), 10, 0, '1', S("abcdefghij"));
+ test(S("abcdefghij"), 10, 5, '1', S("abcdefghij11111"));
+ test(S("abcdefghij"), 10, 10, '1', S("abcdefghij1111111111"));
+ test(S("abcdefghij"), 10, 20, '1', S("abcdefghij11111111111111111111"));
+ test(S("abcdefghij"), 11, 0, '1', S("can't happen"));
+ test(S("abcdefghij"), 11, 5, '1', S("can't happen"));
+ test(S("abcdefghij"), 11, 10, '1', S("can't happen"));
+ test(S("abcdefghij"), 11, 20, '1', S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, '1', S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 5, '1', S("11111abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, '1', S("1111111111abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, '1', S("11111111111111111111abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, '1', S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 5, '1', S("a11111bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 10, '1', S("a1111111111bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, '1', S("a11111111111111111111bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, '1', S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, '1', S("abcdefghij11111klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, '1', S("abcdefghij1111111111klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 20, '1', S("abcdefghij11111111111111111111klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, '1', S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, 5, '1', S("abcdefghijklmnopqrs11111t"));
+ test(S("abcdefghijklmnopqrst"), 19, 10, '1', S("abcdefghijklmnopqrs1111111111t"));
+ test(S("abcdefghijklmnopqrst"), 19, 20, '1', S("abcdefghijklmnopqrs11111111111111111111t"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, '1', S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, 5, '1', S("abcdefghijklmnopqrst11111"));
+ test(S("abcdefghijklmnopqrst"), 20, 10, '1', S("abcdefghijklmnopqrst1111111111"));
+ test(S("abcdefghijklmnopqrst"), 20, 20, '1', S("abcdefghijklmnopqrst11111111111111111111"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, '1', S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 5, '1', S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 10, '1', S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 20, '1', S("can't happen"));
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.modifiers/string_insert/size_string.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_insert/size_string.pass.cpp
new file mode 100644
index 000000000000..8c18941cf46a
--- /dev/null
+++ b/test/std/strings/basic.string/string.modifiers/string_insert/size_string.pass.cpp
@@ -0,0 +1,211 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string<charT,traits,Allocator>&
+// insert(size_type pos1, const basic_string& str);
+
+#include <string>
+#include <stdexcept>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s, typename S::size_type pos, S str, S expected)
+{
+ typename S::size_type old_size = s.size();
+ S s0 = s;
+ try
+ {
+ s.insert(pos, str);
+ assert(s.__invariants());
+ assert(pos <= old_size);
+ assert(s == expected);
+ }
+ catch (std::out_of_range&)
+ {
+ assert(pos > old_size);
+ assert(s == s0);
+ }
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test(S(""), 0, S(""), S(""));
+ test(S(""), 0, S("12345"), S("12345"));
+ test(S(""), 0, S("1234567890"), S("1234567890"));
+ test(S(""), 0, S("12345678901234567890"), S("12345678901234567890"));
+ test(S(""), 1, S(""), S("can't happen"));
+ test(S(""), 1, S("12345"), S("can't happen"));
+ test(S(""), 1, S("1234567890"), S("can't happen"));
+ test(S(""), 1, S("12345678901234567890"), S("can't happen"));
+ test(S("abcde"), 0, S(""), S("abcde"));
+ test(S("abcde"), 0, S("12345"), S("12345abcde"));
+ test(S("abcde"), 0, S("1234567890"), S("1234567890abcde"));
+ test(S("abcde"), 0, S("12345678901234567890"), S("12345678901234567890abcde"));
+ test(S("abcde"), 1, S(""), S("abcde"));
+ test(S("abcde"), 1, S("12345"), S("a12345bcde"));
+ test(S("abcde"), 1, S("1234567890"), S("a1234567890bcde"));
+ test(S("abcde"), 1, S("12345678901234567890"), S("a12345678901234567890bcde"));
+ test(S("abcde"), 2, S(""), S("abcde"));
+ test(S("abcde"), 2, S("12345"), S("ab12345cde"));
+ test(S("abcde"), 2, S("1234567890"), S("ab1234567890cde"));
+ test(S("abcde"), 2, S("12345678901234567890"), S("ab12345678901234567890cde"));
+ test(S("abcde"), 4, S(""), S("abcde"));
+ test(S("abcde"), 4, S("12345"), S("abcd12345e"));
+ test(S("abcde"), 4, S("1234567890"), S("abcd1234567890e"));
+ test(S("abcde"), 4, S("12345678901234567890"), S("abcd12345678901234567890e"));
+ test(S("abcde"), 5, S(""), S("abcde"));
+ test(S("abcde"), 5, S("12345"), S("abcde12345"));
+ test(S("abcde"), 5, S("1234567890"), S("abcde1234567890"));
+ test(S("abcde"), 5, S("12345678901234567890"), S("abcde12345678901234567890"));
+ test(S("abcde"), 6, S(""), S("can't happen"));
+ test(S("abcde"), 6, S("12345"), S("can't happen"));
+ test(S("abcde"), 6, S("1234567890"), S("can't happen"));
+ test(S("abcde"), 6, S("12345678901234567890"), S("can't happen"));
+ test(S("abcdefghij"), 0, S(""), S("abcdefghij"));
+ test(S("abcdefghij"), 0, S("12345"), S("12345abcdefghij"));
+ test(S("abcdefghij"), 0, S("1234567890"), S("1234567890abcdefghij"));
+ test(S("abcdefghij"), 0, S("12345678901234567890"), S("12345678901234567890abcdefghij"));
+ test(S("abcdefghij"), 1, S(""), S("abcdefghij"));
+ test(S("abcdefghij"), 1, S("12345"), S("a12345bcdefghij"));
+ test(S("abcdefghij"), 1, S("1234567890"), S("a1234567890bcdefghij"));
+ test(S("abcdefghij"), 1, S("12345678901234567890"), S("a12345678901234567890bcdefghij"));
+ test(S("abcdefghij"), 5, S(""), S("abcdefghij"));
+ test(S("abcdefghij"), 5, S("12345"), S("abcde12345fghij"));
+ test(S("abcdefghij"), 5, S("1234567890"), S("abcde1234567890fghij"));
+ test(S("abcdefghij"), 5, S("12345678901234567890"), S("abcde12345678901234567890fghij"));
+ test(S("abcdefghij"), 9, S(""), S("abcdefghij"));
+ test(S("abcdefghij"), 9, S("12345"), S("abcdefghi12345j"));
+ test(S("abcdefghij"), 9, S("1234567890"), S("abcdefghi1234567890j"));
+ test(S("abcdefghij"), 9, S("12345678901234567890"), S("abcdefghi12345678901234567890j"));
+ test(S("abcdefghij"), 10, S(""), S("abcdefghij"));
+ test(S("abcdefghij"), 10, S("12345"), S("abcdefghij12345"));
+ test(S("abcdefghij"), 10, S("1234567890"), S("abcdefghij1234567890"));
+ test(S("abcdefghij"), 10, S("12345678901234567890"), S("abcdefghij12345678901234567890"));
+ test(S("abcdefghij"), 11, S(""), S("can't happen"));
+ test(S("abcdefghij"), 11, S("12345"), S("can't happen"));
+ test(S("abcdefghij"), 11, S("1234567890"), S("can't happen"));
+ test(S("abcdefghij"), 11, S("12345678901234567890"), S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 0, S(""), S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, S("12345"), S("12345abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), S("1234567890abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), S("12345678901234567890abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, S(""), S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, S("12345"), S("a12345bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), S("a1234567890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), S("a12345678901234567890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, S(""), S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, S("12345"), S("abcdefghij12345klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), S("abcdefghij1234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), S("abcdefghij12345678901234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, S(""), S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, S("12345"), S("abcdefghijklmnopqrs12345t"));
+ test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), S("abcdefghijklmnopqrs1234567890t"));
+ test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), S("abcdefghijklmnopqrs12345678901234567890t"));
+ test(S("abcdefghijklmnopqrst"), 20, S(""), S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, S("12345"), S("abcdefghijklmnopqrst12345"));
+ test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
+ test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 21, S(""), S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, S("12345"), S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), S("can't happen"));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S(""), 0, S(""), S(""));
+ test(S(""), 0, S("12345"), S("12345"));
+ test(S(""), 0, S("1234567890"), S("1234567890"));
+ test(S(""), 0, S("12345678901234567890"), S("12345678901234567890"));
+ test(S(""), 1, S(""), S("can't happen"));
+ test(S(""), 1, S("12345"), S("can't happen"));
+ test(S(""), 1, S("1234567890"), S("can't happen"));
+ test(S(""), 1, S("12345678901234567890"), S("can't happen"));
+ test(S("abcde"), 0, S(""), S("abcde"));
+ test(S("abcde"), 0, S("12345"), S("12345abcde"));
+ test(S("abcde"), 0, S("1234567890"), S("1234567890abcde"));
+ test(S("abcde"), 0, S("12345678901234567890"), S("12345678901234567890abcde"));
+ test(S("abcde"), 1, S(""), S("abcde"));
+ test(S("abcde"), 1, S("12345"), S("a12345bcde"));
+ test(S("abcde"), 1, S("1234567890"), S("a1234567890bcde"));
+ test(S("abcde"), 1, S("12345678901234567890"), S("a12345678901234567890bcde"));
+ test(S("abcde"), 2, S(""), S("abcde"));
+ test(S("abcde"), 2, S("12345"), S("ab12345cde"));
+ test(S("abcde"), 2, S("1234567890"), S("ab1234567890cde"));
+ test(S("abcde"), 2, S("12345678901234567890"), S("ab12345678901234567890cde"));
+ test(S("abcde"), 4, S(""), S("abcde"));
+ test(S("abcde"), 4, S("12345"), S("abcd12345e"));
+ test(S("abcde"), 4, S("1234567890"), S("abcd1234567890e"));
+ test(S("abcde"), 4, S("12345678901234567890"), S("abcd12345678901234567890e"));
+ test(S("abcde"), 5, S(""), S("abcde"));
+ test(S("abcde"), 5, S("12345"), S("abcde12345"));
+ test(S("abcde"), 5, S("1234567890"), S("abcde1234567890"));
+ test(S("abcde"), 5, S("12345678901234567890"), S("abcde12345678901234567890"));
+ test(S("abcde"), 6, S(""), S("can't happen"));
+ test(S("abcde"), 6, S("12345"), S("can't happen"));
+ test(S("abcde"), 6, S("1234567890"), S("can't happen"));
+ test(S("abcde"), 6, S("12345678901234567890"), S("can't happen"));
+ test(S("abcdefghij"), 0, S(""), S("abcdefghij"));
+ test(S("abcdefghij"), 0, S("12345"), S("12345abcdefghij"));
+ test(S("abcdefghij"), 0, S("1234567890"), S("1234567890abcdefghij"));
+ test(S("abcdefghij"), 0, S("12345678901234567890"), S("12345678901234567890abcdefghij"));
+ test(S("abcdefghij"), 1, S(""), S("abcdefghij"));
+ test(S("abcdefghij"), 1, S("12345"), S("a12345bcdefghij"));
+ test(S("abcdefghij"), 1, S("1234567890"), S("a1234567890bcdefghij"));
+ test(S("abcdefghij"), 1, S("12345678901234567890"), S("a12345678901234567890bcdefghij"));
+ test(S("abcdefghij"), 5, S(""), S("abcdefghij"));
+ test(S("abcdefghij"), 5, S("12345"), S("abcde12345fghij"));
+ test(S("abcdefghij"), 5, S("1234567890"), S("abcde1234567890fghij"));
+ test(S("abcdefghij"), 5, S("12345678901234567890"), S("abcde12345678901234567890fghij"));
+ test(S("abcdefghij"), 9, S(""), S("abcdefghij"));
+ test(S("abcdefghij"), 9, S("12345"), S("abcdefghi12345j"));
+ test(S("abcdefghij"), 9, S("1234567890"), S("abcdefghi1234567890j"));
+ test(S("abcdefghij"), 9, S("12345678901234567890"), S("abcdefghi12345678901234567890j"));
+ test(S("abcdefghij"), 10, S(""), S("abcdefghij"));
+ test(S("abcdefghij"), 10, S("12345"), S("abcdefghij12345"));
+ test(S("abcdefghij"), 10, S("1234567890"), S("abcdefghij1234567890"));
+ test(S("abcdefghij"), 10, S("12345678901234567890"), S("abcdefghij12345678901234567890"));
+ test(S("abcdefghij"), 11, S(""), S("can't happen"));
+ test(S("abcdefghij"), 11, S("12345"), S("can't happen"));
+ test(S("abcdefghij"), 11, S("1234567890"), S("can't happen"));
+ test(S("abcdefghij"), 11, S("12345678901234567890"), S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 0, S(""), S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, S("12345"), S("12345abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), S("1234567890abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), S("12345678901234567890abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, S(""), S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, S("12345"), S("a12345bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), S("a1234567890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), S("a12345678901234567890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, S(""), S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, S("12345"), S("abcdefghij12345klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), S("abcdefghij1234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), S("abcdefghij12345678901234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, S(""), S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, S("12345"), S("abcdefghijklmnopqrs12345t"));
+ test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), S("abcdefghijklmnopqrs1234567890t"));
+ test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), S("abcdefghijklmnopqrs12345678901234567890t"));
+ test(S("abcdefghijklmnopqrst"), 20, S(""), S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, S("12345"), S("abcdefghijklmnopqrst12345"));
+ test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
+ test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 21, S(""), S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, S("12345"), S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), S("can't happen"));
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.modifiers/string_insert/size_string_size_size.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_insert/size_string_size_size.pass.cpp
new file mode 100644
index 000000000000..51c9e72fc56f
--- /dev/null
+++ b/test/std/strings/basic.string/string.modifiers/string_insert/size_string_size_size.pass.cpp
@@ -0,0 +1,1784 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string<charT,traits,Allocator>&
+// insert(size_type pos1, const basic_string<charT,traits,Allocator>& str,
+// size_type pos2, size_type n=npos);
+// the "=npos" was added in C++14
+
+#include <string>
+#include <stdexcept>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s, typename S::size_type pos1, S str, typename S::size_type pos2,
+ typename S::size_type n, S expected)
+{
+ typename S::size_type old_size = s.size();
+ S s0 = s;
+ try
+ {
+ s.insert(pos1, str, pos2, n);
+ assert(s.__invariants());
+ assert(pos1 <= old_size && pos2 <= str.size());
+ assert(s == expected);
+ }
+ catch (std::out_of_range&)
+ {
+ assert(pos1 > old_size || pos2 > str.size());
+ assert(s == s0);
+ }
+}
+
+template <class S>
+void
+test_npos(S s, typename S::size_type pos1, S str, typename S::size_type pos2, S expected)
+{
+ typename S::size_type old_size = s.size();
+ S s0 = s;
+ try
+ {
+ s.insert(pos1, str, pos2);
+ assert(s.__invariants());
+ assert(pos1 <= old_size && pos2 <= str.size());
+ assert(s == expected);
+ }
+ catch (std::out_of_range&)
+ {
+ assert(pos1 > old_size || pos2 > str.size());
+ assert(s == s0);
+ }
+}
+
+
+template <class S>
+void test0()
+{
+ test(S(""), 0, S(""), 0, 0, S(""));
+ test(S(""), 0, S(""), 0, 1, S(""));
+ test(S(""), 0, S(""), 1, 0, S("can't happen"));
+ test(S(""), 0, S("12345"), 0, 0, S(""));
+ test(S(""), 0, S("12345"), 0, 1, S("1"));
+ test(S(""), 0, S("12345"), 0, 2, S("12"));
+ test(S(""), 0, S("12345"), 0, 4, S("1234"));
+ test(S(""), 0, S("12345"), 0, 5, S("12345"));
+ test(S(""), 0, S("12345"), 0, 6, S("12345"));
+ test(S(""), 0, S("12345"), 1, 0, S(""));
+ test(S(""), 0, S("12345"), 1, 1, S("2"));
+ test(S(""), 0, S("12345"), 1, 2, S("23"));
+ test(S(""), 0, S("12345"), 1, 3, S("234"));
+ test(S(""), 0, S("12345"), 1, 4, S("2345"));
+ test(S(""), 0, S("12345"), 1, 5, S("2345"));
+ test(S(""), 0, S("12345"), 2, 0, S(""));
+ test(S(""), 0, S("12345"), 2, 1, S("3"));
+ test(S(""), 0, S("12345"), 2, 2, S("34"));
+ test(S(""), 0, S("12345"), 2, 3, S("345"));
+ test(S(""), 0, S("12345"), 2, 4, S("345"));
+ test(S(""), 0, S("12345"), 4, 0, S(""));
+ test(S(""), 0, S("12345"), 4, 1, S("5"));
+ test(S(""), 0, S("12345"), 4, 2, S("5"));
+ test(S(""), 0, S("12345"), 5, 0, S(""));
+ test(S(""), 0, S("12345"), 5, 1, S(""));
+ test(S(""), 0, S("12345"), 6, 0, S("can't happen"));
+ test(S(""), 0, S("1234567890"), 0, 0, S(""));
+ test(S(""), 0, S("1234567890"), 0, 1, S("1"));
+ test(S(""), 0, S("1234567890"), 0, 5, S("12345"));
+ test(S(""), 0, S("1234567890"), 0, 9, S("123456789"));
+ test(S(""), 0, S("1234567890"), 0, 10, S("1234567890"));
+ test(S(""), 0, S("1234567890"), 0, 11, S("1234567890"));
+ test(S(""), 0, S("1234567890"), 1, 0, S(""));
+ test(S(""), 0, S("1234567890"), 1, 1, S("2"));
+ test(S(""), 0, S("1234567890"), 1, 4, S("2345"));
+ test(S(""), 0, S("1234567890"), 1, 8, S("23456789"));
+ test(S(""), 0, S("1234567890"), 1, 9, S("234567890"));
+ test(S(""), 0, S("1234567890"), 1, 10, S("234567890"));
+ test(S(""), 0, S("1234567890"), 5, 0, S(""));
+ test(S(""), 0, S("1234567890"), 5, 1, S("6"));
+ test(S(""), 0, S("1234567890"), 5, 2, S("67"));
+ test(S(""), 0, S("1234567890"), 5, 4, S("6789"));
+ test(S(""), 0, S("1234567890"), 5, 5, S("67890"));
+ test(S(""), 0, S("1234567890"), 5, 6, S("67890"));
+ test(S(""), 0, S("1234567890"), 9, 0, S(""));
+ test(S(""), 0, S("1234567890"), 9, 1, S("0"));
+ test(S(""), 0, S("1234567890"), 9, 2, S("0"));
+ test(S(""), 0, S("1234567890"), 10, 0, S(""));
+ test(S(""), 0, S("1234567890"), 10, 1, S(""));
+ test(S(""), 0, S("1234567890"), 11, 0, S("can't happen"));
+}
+
+template <class S>
+void test1()
+{
+ test(S(""), 0, S("12345678901234567890"), 0, 0, S(""));
+ test(S(""), 0, S("12345678901234567890"), 0, 1, S("1"));
+ test(S(""), 0, S("12345678901234567890"), 0, 10, S("1234567890"));
+ test(S(""), 0, S("12345678901234567890"), 0, 19, S("1234567890123456789"));
+ test(S(""), 0, S("12345678901234567890"), 0, 20, S("12345678901234567890"));
+ test(S(""), 0, S("12345678901234567890"), 0, 21, S("12345678901234567890"));
+ test(S(""), 0, S("12345678901234567890"), 1, 0, S(""));
+ test(S(""), 0, S("12345678901234567890"), 1, 1, S("2"));
+ test(S(""), 0, S("12345678901234567890"), 1, 9, S("234567890"));
+ test(S(""), 0, S("12345678901234567890"), 1, 18, S("234567890123456789"));
+ test(S(""), 0, S("12345678901234567890"), 1, 19, S("2345678901234567890"));
+ test(S(""), 0, S("12345678901234567890"), 1, 20, S("2345678901234567890"));
+ test(S(""), 0, S("12345678901234567890"), 10, 0, S(""));
+ test(S(""), 0, S("12345678901234567890"), 10, 1, S("1"));
+ test(S(""), 0, S("12345678901234567890"), 10, 5, S("12345"));
+ test(S(""), 0, S("12345678901234567890"), 10, 9, S("123456789"));
+ test(S(""), 0, S("12345678901234567890"), 10, 10, S("1234567890"));
+ test(S(""), 0, S("12345678901234567890"), 10, 11, S("1234567890"));
+ test(S(""), 0, S("12345678901234567890"), 19, 0, S(""));
+ test(S(""), 0, S("12345678901234567890"), 19, 1, S("0"));
+ test(S(""), 0, S("12345678901234567890"), 19, 2, S("0"));
+ test(S(""), 0, S("12345678901234567890"), 20, 0, S(""));
+ test(S(""), 0, S("12345678901234567890"), 20, 1, S(""));
+ test(S(""), 0, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S(""), 1, S(""), 0, 0, S("can't happen"));
+ test(S(""), 1, S(""), 0, 1, S("can't happen"));
+ test(S(""), 1, S(""), 1, 0, S("can't happen"));
+ test(S(""), 1, S("12345"), 0, 0, S("can't happen"));
+ test(S(""), 1, S("12345"), 0, 1, S("can't happen"));
+ test(S(""), 1, S("12345"), 0, 2, S("can't happen"));
+ test(S(""), 1, S("12345"), 0, 4, S("can't happen"));
+ test(S(""), 1, S("12345"), 0, 5, S("can't happen"));
+ test(S(""), 1, S("12345"), 0, 6, S("can't happen"));
+ test(S(""), 1, S("12345"), 1, 0, S("can't happen"));
+ test(S(""), 1, S("12345"), 1, 1, S("can't happen"));
+ test(S(""), 1, S("12345"), 1, 2, S("can't happen"));
+ test(S(""), 1, S("12345"), 1, 3, S("can't happen"));
+ test(S(""), 1, S("12345"), 1, 4, S("can't happen"));
+ test(S(""), 1, S("12345"), 1, 5, S("can't happen"));
+ test(S(""), 1, S("12345"), 2, 0, S("can't happen"));
+ test(S(""), 1, S("12345"), 2, 1, S("can't happen"));
+ test(S(""), 1, S("12345"), 2, 2, S("can't happen"));
+ test(S(""), 1, S("12345"), 2, 3, S("can't happen"));
+ test(S(""), 1, S("12345"), 2, 4, S("can't happen"));
+ test(S(""), 1, S("12345"), 4, 0, S("can't happen"));
+ test(S(""), 1, S("12345"), 4, 1, S("can't happen"));
+ test(S(""), 1, S("12345"), 4, 2, S("can't happen"));
+ test(S(""), 1, S("12345"), 5, 0, S("can't happen"));
+ test(S(""), 1, S("12345"), 5, 1, S("can't happen"));
+ test(S(""), 1, S("12345"), 6, 0, S("can't happen"));
+}
+
+template <class S>
+void test2()
+{
+ test(S(""), 1, S("1234567890"), 0, 0, S("can't happen"));
+ test(S(""), 1, S("1234567890"), 0, 1, S("can't happen"));
+ test(S(""), 1, S("1234567890"), 0, 5, S("can't happen"));
+ test(S(""), 1, S("1234567890"), 0, 9, S("can't happen"));
+ test(S(""), 1, S("1234567890"), 0, 10, S("can't happen"));
+ test(S(""), 1, S("1234567890"), 0, 11, S("can't happen"));
+ test(S(""), 1, S("1234567890"), 1, 0, S("can't happen"));
+ test(S(""), 1, S("1234567890"), 1, 1, S("can't happen"));
+ test(S(""), 1, S("1234567890"), 1, 4, S("can't happen"));
+ test(S(""), 1, S("1234567890"), 1, 8, S("can't happen"));
+ test(S(""), 1, S("1234567890"), 1, 9, S("can't happen"));
+ test(S(""), 1, S("1234567890"), 1, 10, S("can't happen"));
+ test(S(""), 1, S("1234567890"), 5, 0, S("can't happen"));
+ test(S(""), 1, S("1234567890"), 5, 1, S("can't happen"));
+ test(S(""), 1, S("1234567890"), 5, 2, S("can't happen"));
+ test(S(""), 1, S("1234567890"), 5, 4, S("can't happen"));
+ test(S(""), 1, S("1234567890"), 5, 5, S("can't happen"));
+ test(S(""), 1, S("1234567890"), 5, 6, S("can't happen"));
+ test(S(""), 1, S("1234567890"), 9, 0, S("can't happen"));
+ test(S(""), 1, S("1234567890"), 9, 1, S("can't happen"));
+ test(S(""), 1, S("1234567890"), 9, 2, S("can't happen"));
+ test(S(""), 1, S("1234567890"), 10, 0, S("can't happen"));
+ test(S(""), 1, S("1234567890"), 10, 1, S("can't happen"));
+ test(S(""), 1, S("1234567890"), 11, 0, S("can't happen"));
+ test(S(""), 1, S("12345678901234567890"), 0, 0, S("can't happen"));
+ test(S(""), 1, S("12345678901234567890"), 0, 1, S("can't happen"));
+ test(S(""), 1, S("12345678901234567890"), 0, 10, S("can't happen"));
+ test(S(""), 1, S("12345678901234567890"), 0, 19, S("can't happen"));
+ test(S(""), 1, S("12345678901234567890"), 0, 20, S("can't happen"));
+ test(S(""), 1, S("12345678901234567890"), 0, 21, S("can't happen"));
+ test(S(""), 1, S("12345678901234567890"), 1, 0, S("can't happen"));
+ test(S(""), 1, S("12345678901234567890"), 1, 1, S("can't happen"));
+ test(S(""), 1, S("12345678901234567890"), 1, 9, S("can't happen"));
+ test(S(""), 1, S("12345678901234567890"), 1, 18, S("can't happen"));
+ test(S(""), 1, S("12345678901234567890"), 1, 19, S("can't happen"));
+ test(S(""), 1, S("12345678901234567890"), 1, 20, S("can't happen"));
+ test(S(""), 1, S("12345678901234567890"), 10, 0, S("can't happen"));
+ test(S(""), 1, S("12345678901234567890"), 10, 1, S("can't happen"));
+ test(S(""), 1, S("12345678901234567890"), 10, 5, S("can't happen"));
+ test(S(""), 1, S("12345678901234567890"), 10, 9, S("can't happen"));
+ test(S(""), 1, S("12345678901234567890"), 10, 10, S("can't happen"));
+ test(S(""), 1, S("12345678901234567890"), 10, 11, S("can't happen"));
+ test(S(""), 1, S("12345678901234567890"), 19, 0, S("can't happen"));
+ test(S(""), 1, S("12345678901234567890"), 19, 1, S("can't happen"));
+ test(S(""), 1, S("12345678901234567890"), 19, 2, S("can't happen"));
+ test(S(""), 1, S("12345678901234567890"), 20, 0, S("can't happen"));
+ test(S(""), 1, S("12345678901234567890"), 20, 1, S("can't happen"));
+ test(S(""), 1, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcde"), 0, S(""), 0, 0, S("abcde"));
+ test(S("abcde"), 0, S(""), 0, 1, S("abcde"));
+}
+
+template <class S>
+void test3()
+{
+ test(S("abcde"), 0, S(""), 1, 0, S("can't happen"));
+ test(S("abcde"), 0, S("12345"), 0, 0, S("abcde"));
+ test(S("abcde"), 0, S("12345"), 0, 1, S("1abcde"));
+ test(S("abcde"), 0, S("12345"), 0, 2, S("12abcde"));
+ test(S("abcde"), 0, S("12345"), 0, 4, S("1234abcde"));
+ test(S("abcde"), 0, S("12345"), 0, 5, S("12345abcde"));
+ test(S("abcde"), 0, S("12345"), 0, 6, S("12345abcde"));
+ test(S("abcde"), 0, S("12345"), 1, 0, S("abcde"));
+ test(S("abcde"), 0, S("12345"), 1, 1, S("2abcde"));
+ test(S("abcde"), 0, S("12345"), 1, 2, S("23abcde"));
+ test(S("abcde"), 0, S("12345"), 1, 3, S("234abcde"));
+ test(S("abcde"), 0, S("12345"), 1, 4, S("2345abcde"));
+ test(S("abcde"), 0, S("12345"), 1, 5, S("2345abcde"));
+ test(S("abcde"), 0, S("12345"), 2, 0, S("abcde"));
+ test(S("abcde"), 0, S("12345"), 2, 1, S("3abcde"));
+ test(S("abcde"), 0, S("12345"), 2, 2, S("34abcde"));
+ test(S("abcde"), 0, S("12345"), 2, 3, S("345abcde"));
+ test(S("abcde"), 0, S("12345"), 2, 4, S("345abcde"));
+ test(S("abcde"), 0, S("12345"), 4, 0, S("abcde"));
+ test(S("abcde"), 0, S("12345"), 4, 1, S("5abcde"));
+ test(S("abcde"), 0, S("12345"), 4, 2, S("5abcde"));
+ test(S("abcde"), 0, S("12345"), 5, 0, S("abcde"));
+ test(S("abcde"), 0, S("12345"), 5, 1, S("abcde"));
+ test(S("abcde"), 0, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcde"), 0, S("1234567890"), 0, 0, S("abcde"));
+ test(S("abcde"), 0, S("1234567890"), 0, 1, S("1abcde"));
+ test(S("abcde"), 0, S("1234567890"), 0, 5, S("12345abcde"));
+ test(S("abcde"), 0, S("1234567890"), 0, 9, S("123456789abcde"));
+ test(S("abcde"), 0, S("1234567890"), 0, 10, S("1234567890abcde"));
+ test(S("abcde"), 0, S("1234567890"), 0, 11, S("1234567890abcde"));
+ test(S("abcde"), 0, S("1234567890"), 1, 0, S("abcde"));
+ test(S("abcde"), 0, S("1234567890"), 1, 1, S("2abcde"));
+ test(S("abcde"), 0, S("1234567890"), 1, 4, S("2345abcde"));
+ test(S("abcde"), 0, S("1234567890"), 1, 8, S("23456789abcde"));
+ test(S("abcde"), 0, S("1234567890"), 1, 9, S("234567890abcde"));
+ test(S("abcde"), 0, S("1234567890"), 1, 10, S("234567890abcde"));
+ test(S("abcde"), 0, S("1234567890"), 5, 0, S("abcde"));
+ test(S("abcde"), 0, S("1234567890"), 5, 1, S("6abcde"));
+ test(S("abcde"), 0, S("1234567890"), 5, 2, S("67abcde"));
+ test(S("abcde"), 0, S("1234567890"), 5, 4, S("6789abcde"));
+ test(S("abcde"), 0, S("1234567890"), 5, 5, S("67890abcde"));
+ test(S("abcde"), 0, S("1234567890"), 5, 6, S("67890abcde"));
+ test(S("abcde"), 0, S("1234567890"), 9, 0, S("abcde"));
+ test(S("abcde"), 0, S("1234567890"), 9, 1, S("0abcde"));
+ test(S("abcde"), 0, S("1234567890"), 9, 2, S("0abcde"));
+ test(S("abcde"), 0, S("1234567890"), 10, 0, S("abcde"));
+ test(S("abcde"), 0, S("1234567890"), 10, 1, S("abcde"));
+ test(S("abcde"), 0, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcde"), 0, S("12345678901234567890"), 0, 0, S("abcde"));
+ test(S("abcde"), 0, S("12345678901234567890"), 0, 1, S("1abcde"));
+}
+
+template <class S>
+void test4()
+{
+ test(S("abcde"), 0, S("12345678901234567890"), 0, 10, S("1234567890abcde"));
+ test(S("abcde"), 0, S("12345678901234567890"), 0, 19, S("1234567890123456789abcde"));
+ test(S("abcde"), 0, S("12345678901234567890"), 0, 20, S("12345678901234567890abcde"));
+ test(S("abcde"), 0, S("12345678901234567890"), 0, 21, S("12345678901234567890abcde"));
+ test(S("abcde"), 0, S("12345678901234567890"), 1, 0, S("abcde"));
+ test(S("abcde"), 0, S("12345678901234567890"), 1, 1, S("2abcde"));
+ test(S("abcde"), 0, S("12345678901234567890"), 1, 9, S("234567890abcde"));
+ test(S("abcde"), 0, S("12345678901234567890"), 1, 18, S("234567890123456789abcde"));
+ test(S("abcde"), 0, S("12345678901234567890"), 1, 19, S("2345678901234567890abcde"));
+ test(S("abcde"), 0, S("12345678901234567890"), 1, 20, S("2345678901234567890abcde"));
+ test(S("abcde"), 0, S("12345678901234567890"), 10, 0, S("abcde"));
+ test(S("abcde"), 0, S("12345678901234567890"), 10, 1, S("1abcde"));
+ test(S("abcde"), 0, S("12345678901234567890"), 10, 5, S("12345abcde"));
+ test(S("abcde"), 0, S("12345678901234567890"), 10, 9, S("123456789abcde"));
+ test(S("abcde"), 0, S("12345678901234567890"), 10, 10, S("1234567890abcde"));
+ test(S("abcde"), 0, S("12345678901234567890"), 10, 11, S("1234567890abcde"));
+ test(S("abcde"), 0, S("12345678901234567890"), 19, 0, S("abcde"));
+ test(S("abcde"), 0, S("12345678901234567890"), 19, 1, S("0abcde"));
+ test(S("abcde"), 0, S("12345678901234567890"), 19, 2, S("0abcde"));
+ test(S("abcde"), 0, S("12345678901234567890"), 20, 0, S("abcde"));
+ test(S("abcde"), 0, S("12345678901234567890"), 20, 1, S("abcde"));
+ test(S("abcde"), 0, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcde"), 1, S(""), 0, 0, S("abcde"));
+ test(S("abcde"), 1, S(""), 0, 1, S("abcde"));
+ test(S("abcde"), 1, S(""), 1, 0, S("can't happen"));
+ test(S("abcde"), 1, S("12345"), 0, 0, S("abcde"));
+ test(S("abcde"), 1, S("12345"), 0, 1, S("a1bcde"));
+ test(S("abcde"), 1, S("12345"), 0, 2, S("a12bcde"));
+ test(S("abcde"), 1, S("12345"), 0, 4, S("a1234bcde"));
+ test(S("abcde"), 1, S("12345"), 0, 5, S("a12345bcde"));
+ test(S("abcde"), 1, S("12345"), 0, 6, S("a12345bcde"));
+ test(S("abcde"), 1, S("12345"), 1, 0, S("abcde"));
+ test(S("abcde"), 1, S("12345"), 1, 1, S("a2bcde"));
+ test(S("abcde"), 1, S("12345"), 1, 2, S("a23bcde"));
+ test(S("abcde"), 1, S("12345"), 1, 3, S("a234bcde"));
+ test(S("abcde"), 1, S("12345"), 1, 4, S("a2345bcde"));
+ test(S("abcde"), 1, S("12345"), 1, 5, S("a2345bcde"));
+ test(S("abcde"), 1, S("12345"), 2, 0, S("abcde"));
+ test(S("abcde"), 1, S("12345"), 2, 1, S("a3bcde"));
+ test(S("abcde"), 1, S("12345"), 2, 2, S("a34bcde"));
+ test(S("abcde"), 1, S("12345"), 2, 3, S("a345bcde"));
+ test(S("abcde"), 1, S("12345"), 2, 4, S("a345bcde"));
+ test(S("abcde"), 1, S("12345"), 4, 0, S("abcde"));
+ test(S("abcde"), 1, S("12345"), 4, 1, S("a5bcde"));
+ test(S("abcde"), 1, S("12345"), 4, 2, S("a5bcde"));
+ test(S("abcde"), 1, S("12345"), 5, 0, S("abcde"));
+ test(S("abcde"), 1, S("12345"), 5, 1, S("abcde"));
+ test(S("abcde"), 1, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcde"), 1, S("1234567890"), 0, 0, S("abcde"));
+ test(S("abcde"), 1, S("1234567890"), 0, 1, S("a1bcde"));
+}
+
+template <class S>
+void test5()
+{
+ test(S("abcde"), 1, S("1234567890"), 0, 5, S("a12345bcde"));
+ test(S("abcde"), 1, S("1234567890"), 0, 9, S("a123456789bcde"));
+ test(S("abcde"), 1, S("1234567890"), 0, 10, S("a1234567890bcde"));
+ test(S("abcde"), 1, S("1234567890"), 0, 11, S("a1234567890bcde"));
+ test(S("abcde"), 1, S("1234567890"), 1, 0, S("abcde"));
+ test(S("abcde"), 1, S("1234567890"), 1, 1, S("a2bcde"));
+ test(S("abcde"), 1, S("1234567890"), 1, 4, S("a2345bcde"));
+ test(S("abcde"), 1, S("1234567890"), 1, 8, S("a23456789bcde"));
+ test(S("abcde"), 1, S("1234567890"), 1, 9, S("a234567890bcde"));
+ test(S("abcde"), 1, S("1234567890"), 1, 10, S("a234567890bcde"));
+ test(S("abcde"), 1, S("1234567890"), 5, 0, S("abcde"));
+ test(S("abcde"), 1, S("1234567890"), 5, 1, S("a6bcde"));
+ test(S("abcde"), 1, S("1234567890"), 5, 2, S("a67bcde"));
+ test(S("abcde"), 1, S("1234567890"), 5, 4, S("a6789bcde"));
+ test(S("abcde"), 1, S("1234567890"), 5, 5, S("a67890bcde"));
+ test(S("abcde"), 1, S("1234567890"), 5, 6, S("a67890bcde"));
+ test(S("abcde"), 1, S("1234567890"), 9, 0, S("abcde"));
+ test(S("abcde"), 1, S("1234567890"), 9, 1, S("a0bcde"));
+ test(S("abcde"), 1, S("1234567890"), 9, 2, S("a0bcde"));
+ test(S("abcde"), 1, S("1234567890"), 10, 0, S("abcde"));
+ test(S("abcde"), 1, S("1234567890"), 10, 1, S("abcde"));
+ test(S("abcde"), 1, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcde"), 1, S("12345678901234567890"), 0, 0, S("abcde"));
+ test(S("abcde"), 1, S("12345678901234567890"), 0, 1, S("a1bcde"));
+ test(S("abcde"), 1, S("12345678901234567890"), 0, 10, S("a1234567890bcde"));
+ test(S("abcde"), 1, S("12345678901234567890"), 0, 19, S("a1234567890123456789bcde"));
+ test(S("abcde"), 1, S("12345678901234567890"), 0, 20, S("a12345678901234567890bcde"));
+ test(S("abcde"), 1, S("12345678901234567890"), 0, 21, S("a12345678901234567890bcde"));
+ test(S("abcde"), 1, S("12345678901234567890"), 1, 0, S("abcde"));
+ test(S("abcde"), 1, S("12345678901234567890"), 1, 1, S("a2bcde"));
+ test(S("abcde"), 1, S("12345678901234567890"), 1, 9, S("a234567890bcde"));
+ test(S("abcde"), 1, S("12345678901234567890"), 1, 18, S("a234567890123456789bcde"));
+ test(S("abcde"), 1, S("12345678901234567890"), 1, 19, S("a2345678901234567890bcde"));
+ test(S("abcde"), 1, S("12345678901234567890"), 1, 20, S("a2345678901234567890bcde"));
+ test(S("abcde"), 1, S("12345678901234567890"), 10, 0, S("abcde"));
+ test(S("abcde"), 1, S("12345678901234567890"), 10, 1, S("a1bcde"));
+ test(S("abcde"), 1, S("12345678901234567890"), 10, 5, S("a12345bcde"));
+ test(S("abcde"), 1, S("12345678901234567890"), 10, 9, S("a123456789bcde"));
+ test(S("abcde"), 1, S("12345678901234567890"), 10, 10, S("a1234567890bcde"));
+ test(S("abcde"), 1, S("12345678901234567890"), 10, 11, S("a1234567890bcde"));
+ test(S("abcde"), 1, S("12345678901234567890"), 19, 0, S("abcde"));
+ test(S("abcde"), 1, S("12345678901234567890"), 19, 1, S("a0bcde"));
+ test(S("abcde"), 1, S("12345678901234567890"), 19, 2, S("a0bcde"));
+ test(S("abcde"), 1, S("12345678901234567890"), 20, 0, S("abcde"));
+ test(S("abcde"), 1, S("12345678901234567890"), 20, 1, S("abcde"));
+ test(S("abcde"), 1, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcde"), 2, S(""), 0, 0, S("abcde"));
+ test(S("abcde"), 2, S(""), 0, 1, S("abcde"));
+ test(S("abcde"), 2, S(""), 1, 0, S("can't happen"));
+ test(S("abcde"), 2, S("12345"), 0, 0, S("abcde"));
+}
+
+template <class S>
+void test6()
+{
+ test(S("abcde"), 2, S("12345"), 0, 1, S("ab1cde"));
+ test(S("abcde"), 2, S("12345"), 0, 2, S("ab12cde"));
+ test(S("abcde"), 2, S("12345"), 0, 4, S("ab1234cde"));
+ test(S("abcde"), 2, S("12345"), 0, 5, S("ab12345cde"));
+ test(S("abcde"), 2, S("12345"), 0, 6, S("ab12345cde"));
+ test(S("abcde"), 2, S("12345"), 1, 0, S("abcde"));
+ test(S("abcde"), 2, S("12345"), 1, 1, S("ab2cde"));
+ test(S("abcde"), 2, S("12345"), 1, 2, S("ab23cde"));
+ test(S("abcde"), 2, S("12345"), 1, 3, S("ab234cde"));
+ test(S("abcde"), 2, S("12345"), 1, 4, S("ab2345cde"));
+ test(S("abcde"), 2, S("12345"), 1, 5, S("ab2345cde"));
+ test(S("abcde"), 2, S("12345"), 2, 0, S("abcde"));
+ test(S("abcde"), 2, S("12345"), 2, 1, S("ab3cde"));
+ test(S("abcde"), 2, S("12345"), 2, 2, S("ab34cde"));
+ test(S("abcde"), 2, S("12345"), 2, 3, S("ab345cde"));
+ test(S("abcde"), 2, S("12345"), 2, 4, S("ab345cde"));
+ test(S("abcde"), 2, S("12345"), 4, 0, S("abcde"));
+ test(S("abcde"), 2, S("12345"), 4, 1, S("ab5cde"));
+ test(S("abcde"), 2, S("12345"), 4, 2, S("ab5cde"));
+ test(S("abcde"), 2, S("12345"), 5, 0, S("abcde"));
+ test(S("abcde"), 2, S("12345"), 5, 1, S("abcde"));
+ test(S("abcde"), 2, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcde"), 2, S("1234567890"), 0, 0, S("abcde"));
+ test(S("abcde"), 2, S("1234567890"), 0, 1, S("ab1cde"));
+ test(S("abcde"), 2, S("1234567890"), 0, 5, S("ab12345cde"));
+ test(S("abcde"), 2, S("1234567890"), 0, 9, S("ab123456789cde"));
+ test(S("abcde"), 2, S("1234567890"), 0, 10, S("ab1234567890cde"));
+ test(S("abcde"), 2, S("1234567890"), 0, 11, S("ab1234567890cde"));
+ test(S("abcde"), 2, S("1234567890"), 1, 0, S("abcde"));
+ test(S("abcde"), 2, S("1234567890"), 1, 1, S("ab2cde"));
+ test(S("abcde"), 2, S("1234567890"), 1, 4, S("ab2345cde"));
+ test(S("abcde"), 2, S("1234567890"), 1, 8, S("ab23456789cde"));
+ test(S("abcde"), 2, S("1234567890"), 1, 9, S("ab234567890cde"));
+ test(S("abcde"), 2, S("1234567890"), 1, 10, S("ab234567890cde"));
+ test(S("abcde"), 2, S("1234567890"), 5, 0, S("abcde"));
+ test(S("abcde"), 2, S("1234567890"), 5, 1, S("ab6cde"));
+ test(S("abcde"), 2, S("1234567890"), 5, 2, S("ab67cde"));
+ test(S("abcde"), 2, S("1234567890"), 5, 4, S("ab6789cde"));
+ test(S("abcde"), 2, S("1234567890"), 5, 5, S("ab67890cde"));
+ test(S("abcde"), 2, S("1234567890"), 5, 6, S("ab67890cde"));
+ test(S("abcde"), 2, S("1234567890"), 9, 0, S("abcde"));
+ test(S("abcde"), 2, S("1234567890"), 9, 1, S("ab0cde"));
+ test(S("abcde"), 2, S("1234567890"), 9, 2, S("ab0cde"));
+ test(S("abcde"), 2, S("1234567890"), 10, 0, S("abcde"));
+ test(S("abcde"), 2, S("1234567890"), 10, 1, S("abcde"));
+ test(S("abcde"), 2, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcde"), 2, S("12345678901234567890"), 0, 0, S("abcde"));
+ test(S("abcde"), 2, S("12345678901234567890"), 0, 1, S("ab1cde"));
+ test(S("abcde"), 2, S("12345678901234567890"), 0, 10, S("ab1234567890cde"));
+ test(S("abcde"), 2, S("12345678901234567890"), 0, 19, S("ab1234567890123456789cde"));
+}
+
+template <class S>
+void test7()
+{
+ test(S("abcde"), 2, S("12345678901234567890"), 0, 20, S("ab12345678901234567890cde"));
+ test(S("abcde"), 2, S("12345678901234567890"), 0, 21, S("ab12345678901234567890cde"));
+ test(S("abcde"), 2, S("12345678901234567890"), 1, 0, S("abcde"));
+ test(S("abcde"), 2, S("12345678901234567890"), 1, 1, S("ab2cde"));
+ test(S("abcde"), 2, S("12345678901234567890"), 1, 9, S("ab234567890cde"));
+ test(S("abcde"), 2, S("12345678901234567890"), 1, 18, S("ab234567890123456789cde"));
+ test(S("abcde"), 2, S("12345678901234567890"), 1, 19, S("ab2345678901234567890cde"));
+ test(S("abcde"), 2, S("12345678901234567890"), 1, 20, S("ab2345678901234567890cde"));
+ test(S("abcde"), 2, S("12345678901234567890"), 10, 0, S("abcde"));
+ test(S("abcde"), 2, S("12345678901234567890"), 10, 1, S("ab1cde"));
+ test(S("abcde"), 2, S("12345678901234567890"), 10, 5, S("ab12345cde"));
+ test(S("abcde"), 2, S("12345678901234567890"), 10, 9, S("ab123456789cde"));
+ test(S("abcde"), 2, S("12345678901234567890"), 10, 10, S("ab1234567890cde"));
+ test(S("abcde"), 2, S("12345678901234567890"), 10, 11, S("ab1234567890cde"));
+ test(S("abcde"), 2, S("12345678901234567890"), 19, 0, S("abcde"));
+ test(S("abcde"), 2, S("12345678901234567890"), 19, 1, S("ab0cde"));
+ test(S("abcde"), 2, S("12345678901234567890"), 19, 2, S("ab0cde"));
+ test(S("abcde"), 2, S("12345678901234567890"), 20, 0, S("abcde"));
+ test(S("abcde"), 2, S("12345678901234567890"), 20, 1, S("abcde"));
+ test(S("abcde"), 2, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcde"), 4, S(""), 0, 0, S("abcde"));
+ test(S("abcde"), 4, S(""), 0, 1, S("abcde"));
+ test(S("abcde"), 4, S(""), 1, 0, S("can't happen"));
+ test(S("abcde"), 4, S("12345"), 0, 0, S("abcde"));
+ test(S("abcde"), 4, S("12345"), 0, 1, S("abcd1e"));
+ test(S("abcde"), 4, S("12345"), 0, 2, S("abcd12e"));
+ test(S("abcde"), 4, S("12345"), 0, 4, S("abcd1234e"));
+ test(S("abcde"), 4, S("12345"), 0, 5, S("abcd12345e"));
+ test(S("abcde"), 4, S("12345"), 0, 6, S("abcd12345e"));
+ test(S("abcde"), 4, S("12345"), 1, 0, S("abcde"));
+ test(S("abcde"), 4, S("12345"), 1, 1, S("abcd2e"));
+ test(S("abcde"), 4, S("12345"), 1, 2, S("abcd23e"));
+ test(S("abcde"), 4, S("12345"), 1, 3, S("abcd234e"));
+ test(S("abcde"), 4, S("12345"), 1, 4, S("abcd2345e"));
+ test(S("abcde"), 4, S("12345"), 1, 5, S("abcd2345e"));
+ test(S("abcde"), 4, S("12345"), 2, 0, S("abcde"));
+ test(S("abcde"), 4, S("12345"), 2, 1, S("abcd3e"));
+ test(S("abcde"), 4, S("12345"), 2, 2, S("abcd34e"));
+ test(S("abcde"), 4, S("12345"), 2, 3, S("abcd345e"));
+ test(S("abcde"), 4, S("12345"), 2, 4, S("abcd345e"));
+ test(S("abcde"), 4, S("12345"), 4, 0, S("abcde"));
+ test(S("abcde"), 4, S("12345"), 4, 1, S("abcd5e"));
+ test(S("abcde"), 4, S("12345"), 4, 2, S("abcd5e"));
+ test(S("abcde"), 4, S("12345"), 5, 0, S("abcde"));
+ test(S("abcde"), 4, S("12345"), 5, 1, S("abcde"));
+ test(S("abcde"), 4, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcde"), 4, S("1234567890"), 0, 0, S("abcde"));
+ test(S("abcde"), 4, S("1234567890"), 0, 1, S("abcd1e"));
+ test(S("abcde"), 4, S("1234567890"), 0, 5, S("abcd12345e"));
+ test(S("abcde"), 4, S("1234567890"), 0, 9, S("abcd123456789e"));
+}
+
+template <class S>
+void test8()
+{
+ test(S("abcde"), 4, S("1234567890"), 0, 10, S("abcd1234567890e"));
+ test(S("abcde"), 4, S("1234567890"), 0, 11, S("abcd1234567890e"));
+ test(S("abcde"), 4, S("1234567890"), 1, 0, S("abcde"));
+ test(S("abcde"), 4, S("1234567890"), 1, 1, S("abcd2e"));
+ test(S("abcde"), 4, S("1234567890"), 1, 4, S("abcd2345e"));
+ test(S("abcde"), 4, S("1234567890"), 1, 8, S("abcd23456789e"));
+ test(S("abcde"), 4, S("1234567890"), 1, 9, S("abcd234567890e"));
+ test(S("abcde"), 4, S("1234567890"), 1, 10, S("abcd234567890e"));
+ test(S("abcde"), 4, S("1234567890"), 5, 0, S("abcde"));
+ test(S("abcde"), 4, S("1234567890"), 5, 1, S("abcd6e"));
+ test(S("abcde"), 4, S("1234567890"), 5, 2, S("abcd67e"));
+ test(S("abcde"), 4, S("1234567890"), 5, 4, S("abcd6789e"));
+ test(S("abcde"), 4, S("1234567890"), 5, 5, S("abcd67890e"));
+ test(S("abcde"), 4, S("1234567890"), 5, 6, S("abcd67890e"));
+ test(S("abcde"), 4, S("1234567890"), 9, 0, S("abcde"));
+ test(S("abcde"), 4, S("1234567890"), 9, 1, S("abcd0e"));
+ test(S("abcde"), 4, S("1234567890"), 9, 2, S("abcd0e"));
+ test(S("abcde"), 4, S("1234567890"), 10, 0, S("abcde"));
+ test(S("abcde"), 4, S("1234567890"), 10, 1, S("abcde"));
+ test(S("abcde"), 4, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcde"), 4, S("12345678901234567890"), 0, 0, S("abcde"));
+ test(S("abcde"), 4, S("12345678901234567890"), 0, 1, S("abcd1e"));
+ test(S("abcde"), 4, S("12345678901234567890"), 0, 10, S("abcd1234567890e"));
+ test(S("abcde"), 4, S("12345678901234567890"), 0, 19, S("abcd1234567890123456789e"));
+ test(S("abcde"), 4, S("12345678901234567890"), 0, 20, S("abcd12345678901234567890e"));
+ test(S("abcde"), 4, S("12345678901234567890"), 0, 21, S("abcd12345678901234567890e"));
+ test(S("abcde"), 4, S("12345678901234567890"), 1, 0, S("abcde"));
+ test(S("abcde"), 4, S("12345678901234567890"), 1, 1, S("abcd2e"));
+ test(S("abcde"), 4, S("12345678901234567890"), 1, 9, S("abcd234567890e"));
+ test(S("abcde"), 4, S("12345678901234567890"), 1, 18, S("abcd234567890123456789e"));
+ test(S("abcde"), 4, S("12345678901234567890"), 1, 19, S("abcd2345678901234567890e"));
+ test(S("abcde"), 4, S("12345678901234567890"), 1, 20, S("abcd2345678901234567890e"));
+ test(S("abcde"), 4, S("12345678901234567890"), 10, 0, S("abcde"));
+ test(S("abcde"), 4, S("12345678901234567890"), 10, 1, S("abcd1e"));
+ test(S("abcde"), 4, S("12345678901234567890"), 10, 5, S("abcd12345e"));
+ test(S("abcde"), 4, S("12345678901234567890"), 10, 9, S("abcd123456789e"));
+ test(S("abcde"), 4, S("12345678901234567890"), 10, 10, S("abcd1234567890e"));
+ test(S("abcde"), 4, S("12345678901234567890"), 10, 11, S("abcd1234567890e"));
+ test(S("abcde"), 4, S("12345678901234567890"), 19, 0, S("abcde"));
+ test(S("abcde"), 4, S("12345678901234567890"), 19, 1, S("abcd0e"));
+ test(S("abcde"), 4, S("12345678901234567890"), 19, 2, S("abcd0e"));
+ test(S("abcde"), 4, S("12345678901234567890"), 20, 0, S("abcde"));
+ test(S("abcde"), 4, S("12345678901234567890"), 20, 1, S("abcde"));
+ test(S("abcde"), 4, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcde"), 5, S(""), 0, 0, S("abcde"));
+ test(S("abcde"), 5, S(""), 0, 1, S("abcde"));
+ test(S("abcde"), 5, S(""), 1, 0, S("can't happen"));
+ test(S("abcde"), 5, S("12345"), 0, 0, S("abcde"));
+ test(S("abcde"), 5, S("12345"), 0, 1, S("abcde1"));
+ test(S("abcde"), 5, S("12345"), 0, 2, S("abcde12"));
+}
+
+template <class S>
+void test9()
+{
+ test(S("abcde"), 5, S("12345"), 0, 4, S("abcde1234"));
+ test(S("abcde"), 5, S("12345"), 0, 5, S("abcde12345"));
+ test(S("abcde"), 5, S("12345"), 0, 6, S("abcde12345"));
+ test(S("abcde"), 5, S("12345"), 1, 0, S("abcde"));
+ test(S("abcde"), 5, S("12345"), 1, 1, S("abcde2"));
+ test(S("abcde"), 5, S("12345"), 1, 2, S("abcde23"));
+ test(S("abcde"), 5, S("12345"), 1, 3, S("abcde234"));
+ test(S("abcde"), 5, S("12345"), 1, 4, S("abcde2345"));
+ test(S("abcde"), 5, S("12345"), 1, 5, S("abcde2345"));
+ test(S("abcde"), 5, S("12345"), 2, 0, S("abcde"));
+ test(S("abcde"), 5, S("12345"), 2, 1, S("abcde3"));
+ test(S("abcde"), 5, S("12345"), 2, 2, S("abcde34"));
+ test(S("abcde"), 5, S("12345"), 2, 3, S("abcde345"));
+ test(S("abcde"), 5, S("12345"), 2, 4, S("abcde345"));
+ test(S("abcde"), 5, S("12345"), 4, 0, S("abcde"));
+ test(S("abcde"), 5, S("12345"), 4, 1, S("abcde5"));
+ test(S("abcde"), 5, S("12345"), 4, 2, S("abcde5"));
+ test(S("abcde"), 5, S("12345"), 5, 0, S("abcde"));
+ test(S("abcde"), 5, S("12345"), 5, 1, S("abcde"));
+ test(S("abcde"), 5, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcde"), 5, S("1234567890"), 0, 0, S("abcde"));
+ test(S("abcde"), 5, S("1234567890"), 0, 1, S("abcde1"));
+ test(S("abcde"), 5, S("1234567890"), 0, 5, S("abcde12345"));
+ test(S("abcde"), 5, S("1234567890"), 0, 9, S("abcde123456789"));
+ test(S("abcde"), 5, S("1234567890"), 0, 10, S("abcde1234567890"));
+ test(S("abcde"), 5, S("1234567890"), 0, 11, S("abcde1234567890"));
+ test(S("abcde"), 5, S("1234567890"), 1, 0, S("abcde"));
+ test(S("abcde"), 5, S("1234567890"), 1, 1, S("abcde2"));
+ test(S("abcde"), 5, S("1234567890"), 1, 4, S("abcde2345"));
+ test(S("abcde"), 5, S("1234567890"), 1, 8, S("abcde23456789"));
+ test(S("abcde"), 5, S("1234567890"), 1, 9, S("abcde234567890"));
+ test(S("abcde"), 5, S("1234567890"), 1, 10, S("abcde234567890"));
+ test(S("abcde"), 5, S("1234567890"), 5, 0, S("abcde"));
+ test(S("abcde"), 5, S("1234567890"), 5, 1, S("abcde6"));
+ test(S("abcde"), 5, S("1234567890"), 5, 2, S("abcde67"));
+ test(S("abcde"), 5, S("1234567890"), 5, 4, S("abcde6789"));
+ test(S("abcde"), 5, S("1234567890"), 5, 5, S("abcde67890"));
+ test(S("abcde"), 5, S("1234567890"), 5, 6, S("abcde67890"));
+ test(S("abcde"), 5, S("1234567890"), 9, 0, S("abcde"));
+ test(S("abcde"), 5, S("1234567890"), 9, 1, S("abcde0"));
+ test(S("abcde"), 5, S("1234567890"), 9, 2, S("abcde0"));
+ test(S("abcde"), 5, S("1234567890"), 10, 0, S("abcde"));
+ test(S("abcde"), 5, S("1234567890"), 10, 1, S("abcde"));
+ test(S("abcde"), 5, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcde"), 5, S("12345678901234567890"), 0, 0, S("abcde"));
+ test(S("abcde"), 5, S("12345678901234567890"), 0, 1, S("abcde1"));
+ test(S("abcde"), 5, S("12345678901234567890"), 0, 10, S("abcde1234567890"));
+ test(S("abcde"), 5, S("12345678901234567890"), 0, 19, S("abcde1234567890123456789"));
+ test(S("abcde"), 5, S("12345678901234567890"), 0, 20, S("abcde12345678901234567890"));
+ test(S("abcde"), 5, S("12345678901234567890"), 0, 21, S("abcde12345678901234567890"));
+}
+
+template <class S>
+void test10()
+{
+ test(S("abcde"), 5, S("12345678901234567890"), 1, 0, S("abcde"));
+ test(S("abcde"), 5, S("12345678901234567890"), 1, 1, S("abcde2"));
+ test(S("abcde"), 5, S("12345678901234567890"), 1, 9, S("abcde234567890"));
+ test(S("abcde"), 5, S("12345678901234567890"), 1, 18, S("abcde234567890123456789"));
+ test(S("abcde"), 5, S("12345678901234567890"), 1, 19, S("abcde2345678901234567890"));
+ test(S("abcde"), 5, S("12345678901234567890"), 1, 20, S("abcde2345678901234567890"));
+ test(S("abcde"), 5, S("12345678901234567890"), 10, 0, S("abcde"));
+ test(S("abcde"), 5, S("12345678901234567890"), 10, 1, S("abcde1"));
+ test(S("abcde"), 5, S("12345678901234567890"), 10, 5, S("abcde12345"));
+ test(S("abcde"), 5, S("12345678901234567890"), 10, 9, S("abcde123456789"));
+ test(S("abcde"), 5, S("12345678901234567890"), 10, 10, S("abcde1234567890"));
+ test(S("abcde"), 5, S("12345678901234567890"), 10, 11, S("abcde1234567890"));
+ test(S("abcde"), 5, S("12345678901234567890"), 19, 0, S("abcde"));
+ test(S("abcde"), 5, S("12345678901234567890"), 19, 1, S("abcde0"));
+ test(S("abcde"), 5, S("12345678901234567890"), 19, 2, S("abcde0"));
+ test(S("abcde"), 5, S("12345678901234567890"), 20, 0, S("abcde"));
+ test(S("abcde"), 5, S("12345678901234567890"), 20, 1, S("abcde"));
+ test(S("abcde"), 5, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcde"), 6, S(""), 0, 0, S("can't happen"));
+ test(S("abcde"), 6, S(""), 0, 1, S("can't happen"));
+ test(S("abcde"), 6, S(""), 1, 0, S("can't happen"));
+ test(S("abcde"), 6, S("12345"), 0, 0, S("can't happen"));
+ test(S("abcde"), 6, S("12345"), 0, 1, S("can't happen"));
+ test(S("abcde"), 6, S("12345"), 0, 2, S("can't happen"));
+ test(S("abcde"), 6, S("12345"), 0, 4, S("can't happen"));
+ test(S("abcde"), 6, S("12345"), 0, 5, S("can't happen"));
+ test(S("abcde"), 6, S("12345"), 0, 6, S("can't happen"));
+ test(S("abcde"), 6, S("12345"), 1, 0, S("can't happen"));
+ test(S("abcde"), 6, S("12345"), 1, 1, S("can't happen"));
+ test(S("abcde"), 6, S("12345"), 1, 2, S("can't happen"));
+ test(S("abcde"), 6, S("12345"), 1, 3, S("can't happen"));
+ test(S("abcde"), 6, S("12345"), 1, 4, S("can't happen"));
+ test(S("abcde"), 6, S("12345"), 1, 5, S("can't happen"));
+ test(S("abcde"), 6, S("12345"), 2, 0, S("can't happen"));
+ test(S("abcde"), 6, S("12345"), 2, 1, S("can't happen"));
+ test(S("abcde"), 6, S("12345"), 2, 2, S("can't happen"));
+ test(S("abcde"), 6, S("12345"), 2, 3, S("can't happen"));
+ test(S("abcde"), 6, S("12345"), 2, 4, S("can't happen"));
+ test(S("abcde"), 6, S("12345"), 4, 0, S("can't happen"));
+ test(S("abcde"), 6, S("12345"), 4, 1, S("can't happen"));
+ test(S("abcde"), 6, S("12345"), 4, 2, S("can't happen"));
+ test(S("abcde"), 6, S("12345"), 5, 0, S("can't happen"));
+ test(S("abcde"), 6, S("12345"), 5, 1, S("can't happen"));
+ test(S("abcde"), 6, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcde"), 6, S("1234567890"), 0, 0, S("can't happen"));
+ test(S("abcde"), 6, S("1234567890"), 0, 1, S("can't happen"));
+ test(S("abcde"), 6, S("1234567890"), 0, 5, S("can't happen"));
+ test(S("abcde"), 6, S("1234567890"), 0, 9, S("can't happen"));
+ test(S("abcde"), 6, S("1234567890"), 0, 10, S("can't happen"));
+ test(S("abcde"), 6, S("1234567890"), 0, 11, S("can't happen"));
+}
+
+template <class S>
+void test11()
+{
+ test(S("abcde"), 6, S("1234567890"), 1, 0, S("can't happen"));
+ test(S("abcde"), 6, S("1234567890"), 1, 1, S("can't happen"));
+ test(S("abcde"), 6, S("1234567890"), 1, 4, S("can't happen"));
+ test(S("abcde"), 6, S("1234567890"), 1, 8, S("can't happen"));
+ test(S("abcde"), 6, S("1234567890"), 1, 9, S("can't happen"));
+ test(S("abcde"), 6, S("1234567890"), 1, 10, S("can't happen"));
+ test(S("abcde"), 6, S("1234567890"), 5, 0, S("can't happen"));
+ test(S("abcde"), 6, S("1234567890"), 5, 1, S("can't happen"));
+ test(S("abcde"), 6, S("1234567890"), 5, 2, S("can't happen"));
+ test(S("abcde"), 6, S("1234567890"), 5, 4, S("can't happen"));
+ test(S("abcde"), 6, S("1234567890"), 5, 5, S("can't happen"));
+ test(S("abcde"), 6, S("1234567890"), 5, 6, S("can't happen"));
+ test(S("abcde"), 6, S("1234567890"), 9, 0, S("can't happen"));
+ test(S("abcde"), 6, S("1234567890"), 9, 1, S("can't happen"));
+ test(S("abcde"), 6, S("1234567890"), 9, 2, S("can't happen"));
+ test(S("abcde"), 6, S("1234567890"), 10, 0, S("can't happen"));
+ test(S("abcde"), 6, S("1234567890"), 10, 1, S("can't happen"));
+ test(S("abcde"), 6, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcde"), 6, S("12345678901234567890"), 0, 0, S("can't happen"));
+ test(S("abcde"), 6, S("12345678901234567890"), 0, 1, S("can't happen"));
+ test(S("abcde"), 6, S("12345678901234567890"), 0, 10, S("can't happen"));
+ test(S("abcde"), 6, S("12345678901234567890"), 0, 19, S("can't happen"));
+ test(S("abcde"), 6, S("12345678901234567890"), 0, 20, S("can't happen"));
+ test(S("abcde"), 6, S("12345678901234567890"), 0, 21, S("can't happen"));
+ test(S("abcde"), 6, S("12345678901234567890"), 1, 0, S("can't happen"));
+ test(S("abcde"), 6, S("12345678901234567890"), 1, 1, S("can't happen"));
+ test(S("abcde"), 6, S("12345678901234567890"), 1, 9, S("can't happen"));
+ test(S("abcde"), 6, S("12345678901234567890"), 1, 18, S("can't happen"));
+ test(S("abcde"), 6, S("12345678901234567890"), 1, 19, S("can't happen"));
+ test(S("abcde"), 6, S("12345678901234567890"), 1, 20, S("can't happen"));
+ test(S("abcde"), 6, S("12345678901234567890"), 10, 0, S("can't happen"));
+ test(S("abcde"), 6, S("12345678901234567890"), 10, 1, S("can't happen"));
+ test(S("abcde"), 6, S("12345678901234567890"), 10, 5, S("can't happen"));
+ test(S("abcde"), 6, S("12345678901234567890"), 10, 9, S("can't happen"));
+ test(S("abcde"), 6, S("12345678901234567890"), 10, 10, S("can't happen"));
+ test(S("abcde"), 6, S("12345678901234567890"), 10, 11, S("can't happen"));
+ test(S("abcde"), 6, S("12345678901234567890"), 19, 0, S("can't happen"));
+ test(S("abcde"), 6, S("12345678901234567890"), 19, 1, S("can't happen"));
+ test(S("abcde"), 6, S("12345678901234567890"), 19, 2, S("can't happen"));
+ test(S("abcde"), 6, S("12345678901234567890"), 20, 0, S("can't happen"));
+ test(S("abcde"), 6, S("12345678901234567890"), 20, 1, S("can't happen"));
+ test(S("abcde"), 6, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcdefghij"), 0, S(""), 0, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 0, S(""), 0, 1, S("abcdefghij"));
+ test(S("abcdefghij"), 0, S(""), 1, 0, S("can't happen"));
+ test(S("abcdefghij"), 0, S("12345"), 0, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 0, S("12345"), 0, 1, S("1abcdefghij"));
+ test(S("abcdefghij"), 0, S("12345"), 0, 2, S("12abcdefghij"));
+ test(S("abcdefghij"), 0, S("12345"), 0, 4, S("1234abcdefghij"));
+ test(S("abcdefghij"), 0, S("12345"), 0, 5, S("12345abcdefghij"));
+}
+
+template <class S>
+void test12()
+{
+ test(S("abcdefghij"), 0, S("12345"), 0, 6, S("12345abcdefghij"));
+ test(S("abcdefghij"), 0, S("12345"), 1, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 0, S("12345"), 1, 1, S("2abcdefghij"));
+ test(S("abcdefghij"), 0, S("12345"), 1, 2, S("23abcdefghij"));
+ test(S("abcdefghij"), 0, S("12345"), 1, 3, S("234abcdefghij"));
+ test(S("abcdefghij"), 0, S("12345"), 1, 4, S("2345abcdefghij"));
+ test(S("abcdefghij"), 0, S("12345"), 1, 5, S("2345abcdefghij"));
+ test(S("abcdefghij"), 0, S("12345"), 2, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 0, S("12345"), 2, 1, S("3abcdefghij"));
+ test(S("abcdefghij"), 0, S("12345"), 2, 2, S("34abcdefghij"));
+ test(S("abcdefghij"), 0, S("12345"), 2, 3, S("345abcdefghij"));
+ test(S("abcdefghij"), 0, S("12345"), 2, 4, S("345abcdefghij"));
+ test(S("abcdefghij"), 0, S("12345"), 4, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 0, S("12345"), 4, 1, S("5abcdefghij"));
+ test(S("abcdefghij"), 0, S("12345"), 4, 2, S("5abcdefghij"));
+ test(S("abcdefghij"), 0, S("12345"), 5, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 0, S("12345"), 5, 1, S("abcdefghij"));
+ test(S("abcdefghij"), 0, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcdefghij"), 0, S("1234567890"), 0, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 0, S("1234567890"), 0, 1, S("1abcdefghij"));
+ test(S("abcdefghij"), 0, S("1234567890"), 0, 5, S("12345abcdefghij"));
+ test(S("abcdefghij"), 0, S("1234567890"), 0, 9, S("123456789abcdefghij"));
+ test(S("abcdefghij"), 0, S("1234567890"), 0, 10, S("1234567890abcdefghij"));
+ test(S("abcdefghij"), 0, S("1234567890"), 0, 11, S("1234567890abcdefghij"));
+ test(S("abcdefghij"), 0, S("1234567890"), 1, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 0, S("1234567890"), 1, 1, S("2abcdefghij"));
+ test(S("abcdefghij"), 0, S("1234567890"), 1, 4, S("2345abcdefghij"));
+ test(S("abcdefghij"), 0, S("1234567890"), 1, 8, S("23456789abcdefghij"));
+ test(S("abcdefghij"), 0, S("1234567890"), 1, 9, S("234567890abcdefghij"));
+ test(S("abcdefghij"), 0, S("1234567890"), 1, 10, S("234567890abcdefghij"));
+ test(S("abcdefghij"), 0, S("1234567890"), 5, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 0, S("1234567890"), 5, 1, S("6abcdefghij"));
+ test(S("abcdefghij"), 0, S("1234567890"), 5, 2, S("67abcdefghij"));
+ test(S("abcdefghij"), 0, S("1234567890"), 5, 4, S("6789abcdefghij"));
+ test(S("abcdefghij"), 0, S("1234567890"), 5, 5, S("67890abcdefghij"));
+ test(S("abcdefghij"), 0, S("1234567890"), 5, 6, S("67890abcdefghij"));
+ test(S("abcdefghij"), 0, S("1234567890"), 9, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 0, S("1234567890"), 9, 1, S("0abcdefghij"));
+ test(S("abcdefghij"), 0, S("1234567890"), 9, 2, S("0abcdefghij"));
+ test(S("abcdefghij"), 0, S("1234567890"), 10, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 0, S("1234567890"), 10, 1, S("abcdefghij"));
+ test(S("abcdefghij"), 0, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcdefghij"), 0, S("12345678901234567890"), 0, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 0, S("12345678901234567890"), 0, 1, S("1abcdefghij"));
+ test(S("abcdefghij"), 0, S("12345678901234567890"), 0, 10, S("1234567890abcdefghij"));
+ test(S("abcdefghij"), 0, S("12345678901234567890"), 0, 19, S("1234567890123456789abcdefghij"));
+ test(S("abcdefghij"), 0, S("12345678901234567890"), 0, 20, S("12345678901234567890abcdefghij"));
+ test(S("abcdefghij"), 0, S("12345678901234567890"), 0, 21, S("12345678901234567890abcdefghij"));
+ test(S("abcdefghij"), 0, S("12345678901234567890"), 1, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 0, S("12345678901234567890"), 1, 1, S("2abcdefghij"));
+}
+
+template <class S>
+void test13()
+{
+ test(S("abcdefghij"), 0, S("12345678901234567890"), 1, 9, S("234567890abcdefghij"));
+ test(S("abcdefghij"), 0, S("12345678901234567890"), 1, 18, S("234567890123456789abcdefghij"));
+ test(S("abcdefghij"), 0, S("12345678901234567890"), 1, 19, S("2345678901234567890abcdefghij"));
+ test(S("abcdefghij"), 0, S("12345678901234567890"), 1, 20, S("2345678901234567890abcdefghij"));
+ test(S("abcdefghij"), 0, S("12345678901234567890"), 10, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 0, S("12345678901234567890"), 10, 1, S("1abcdefghij"));
+ test(S("abcdefghij"), 0, S("12345678901234567890"), 10, 5, S("12345abcdefghij"));
+ test(S("abcdefghij"), 0, S("12345678901234567890"), 10, 9, S("123456789abcdefghij"));
+ test(S("abcdefghij"), 0, S("12345678901234567890"), 10, 10, S("1234567890abcdefghij"));
+ test(S("abcdefghij"), 0, S("12345678901234567890"), 10, 11, S("1234567890abcdefghij"));
+ test(S("abcdefghij"), 0, S("12345678901234567890"), 19, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 0, S("12345678901234567890"), 19, 1, S("0abcdefghij"));
+ test(S("abcdefghij"), 0, S("12345678901234567890"), 19, 2, S("0abcdefghij"));
+ test(S("abcdefghij"), 0, S("12345678901234567890"), 20, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 0, S("12345678901234567890"), 20, 1, S("abcdefghij"));
+ test(S("abcdefghij"), 0, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcdefghij"), 1, S(""), 0, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 1, S(""), 0, 1, S("abcdefghij"));
+ test(S("abcdefghij"), 1, S(""), 1, 0, S("can't happen"));
+ test(S("abcdefghij"), 1, S("12345"), 0, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 1, S("12345"), 0, 1, S("a1bcdefghij"));
+ test(S("abcdefghij"), 1, S("12345"), 0, 2, S("a12bcdefghij"));
+ test(S("abcdefghij"), 1, S("12345"), 0, 4, S("a1234bcdefghij"));
+ test(S("abcdefghij"), 1, S("12345"), 0, 5, S("a12345bcdefghij"));
+ test(S("abcdefghij"), 1, S("12345"), 0, 6, S("a12345bcdefghij"));
+ test(S("abcdefghij"), 1, S("12345"), 1, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 1, S("12345"), 1, 1, S("a2bcdefghij"));
+ test(S("abcdefghij"), 1, S("12345"), 1, 2, S("a23bcdefghij"));
+ test(S("abcdefghij"), 1, S("12345"), 1, 3, S("a234bcdefghij"));
+ test(S("abcdefghij"), 1, S("12345"), 1, 4, S("a2345bcdefghij"));
+ test(S("abcdefghij"), 1, S("12345"), 1, 5, S("a2345bcdefghij"));
+ test(S("abcdefghij"), 1, S("12345"), 2, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 1, S("12345"), 2, 1, S("a3bcdefghij"));
+ test(S("abcdefghij"), 1, S("12345"), 2, 2, S("a34bcdefghij"));
+ test(S("abcdefghij"), 1, S("12345"), 2, 3, S("a345bcdefghij"));
+ test(S("abcdefghij"), 1, S("12345"), 2, 4, S("a345bcdefghij"));
+ test(S("abcdefghij"), 1, S("12345"), 4, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 1, S("12345"), 4, 1, S("a5bcdefghij"));
+ test(S("abcdefghij"), 1, S("12345"), 4, 2, S("a5bcdefghij"));
+ test(S("abcdefghij"), 1, S("12345"), 5, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 1, S("12345"), 5, 1, S("abcdefghij"));
+ test(S("abcdefghij"), 1, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcdefghij"), 1, S("1234567890"), 0, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 1, S("1234567890"), 0, 1, S("a1bcdefghij"));
+ test(S("abcdefghij"), 1, S("1234567890"), 0, 5, S("a12345bcdefghij"));
+ test(S("abcdefghij"), 1, S("1234567890"), 0, 9, S("a123456789bcdefghij"));
+ test(S("abcdefghij"), 1, S("1234567890"), 0, 10, S("a1234567890bcdefghij"));
+ test(S("abcdefghij"), 1, S("1234567890"), 0, 11, S("a1234567890bcdefghij"));
+ test(S("abcdefghij"), 1, S("1234567890"), 1, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 1, S("1234567890"), 1, 1, S("a2bcdefghij"));
+}
+
+template <class S>
+void test14()
+{
+ test(S("abcdefghij"), 1, S("1234567890"), 1, 4, S("a2345bcdefghij"));
+ test(S("abcdefghij"), 1, S("1234567890"), 1, 8, S("a23456789bcdefghij"));
+ test(S("abcdefghij"), 1, S("1234567890"), 1, 9, S("a234567890bcdefghij"));
+ test(S("abcdefghij"), 1, S("1234567890"), 1, 10, S("a234567890bcdefghij"));
+ test(S("abcdefghij"), 1, S("1234567890"), 5, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 1, S("1234567890"), 5, 1, S("a6bcdefghij"));
+ test(S("abcdefghij"), 1, S("1234567890"), 5, 2, S("a67bcdefghij"));
+ test(S("abcdefghij"), 1, S("1234567890"), 5, 4, S("a6789bcdefghij"));
+ test(S("abcdefghij"), 1, S("1234567890"), 5, 5, S("a67890bcdefghij"));
+ test(S("abcdefghij"), 1, S("1234567890"), 5, 6, S("a67890bcdefghij"));
+ test(S("abcdefghij"), 1, S("1234567890"), 9, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 1, S("1234567890"), 9, 1, S("a0bcdefghij"));
+ test(S("abcdefghij"), 1, S("1234567890"), 9, 2, S("a0bcdefghij"));
+ test(S("abcdefghij"), 1, S("1234567890"), 10, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 1, S("1234567890"), 10, 1, S("abcdefghij"));
+ test(S("abcdefghij"), 1, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcdefghij"), 1, S("12345678901234567890"), 0, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 1, S("12345678901234567890"), 0, 1, S("a1bcdefghij"));
+ test(S("abcdefghij"), 1, S("12345678901234567890"), 0, 10, S("a1234567890bcdefghij"));
+ test(S("abcdefghij"), 1, S("12345678901234567890"), 0, 19, S("a1234567890123456789bcdefghij"));
+ test(S("abcdefghij"), 1, S("12345678901234567890"), 0, 20, S("a12345678901234567890bcdefghij"));
+ test(S("abcdefghij"), 1, S("12345678901234567890"), 0, 21, S("a12345678901234567890bcdefghij"));
+ test(S("abcdefghij"), 1, S("12345678901234567890"), 1, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 1, S("12345678901234567890"), 1, 1, S("a2bcdefghij"));
+ test(S("abcdefghij"), 1, S("12345678901234567890"), 1, 9, S("a234567890bcdefghij"));
+ test(S("abcdefghij"), 1, S("12345678901234567890"), 1, 18, S("a234567890123456789bcdefghij"));
+ test(S("abcdefghij"), 1, S("12345678901234567890"), 1, 19, S("a2345678901234567890bcdefghij"));
+ test(S("abcdefghij"), 1, S("12345678901234567890"), 1, 20, S("a2345678901234567890bcdefghij"));
+ test(S("abcdefghij"), 1, S("12345678901234567890"), 10, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 1, S("12345678901234567890"), 10, 1, S("a1bcdefghij"));
+ test(S("abcdefghij"), 1, S("12345678901234567890"), 10, 5, S("a12345bcdefghij"));
+ test(S("abcdefghij"), 1, S("12345678901234567890"), 10, 9, S("a123456789bcdefghij"));
+ test(S("abcdefghij"), 1, S("12345678901234567890"), 10, 10, S("a1234567890bcdefghij"));
+ test(S("abcdefghij"), 1, S("12345678901234567890"), 10, 11, S("a1234567890bcdefghij"));
+ test(S("abcdefghij"), 1, S("12345678901234567890"), 19, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 1, S("12345678901234567890"), 19, 1, S("a0bcdefghij"));
+ test(S("abcdefghij"), 1, S("12345678901234567890"), 19, 2, S("a0bcdefghij"));
+ test(S("abcdefghij"), 1, S("12345678901234567890"), 20, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 1, S("12345678901234567890"), 20, 1, S("abcdefghij"));
+ test(S("abcdefghij"), 1, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcdefghij"), 5, S(""), 0, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 5, S(""), 0, 1, S("abcdefghij"));
+ test(S("abcdefghij"), 5, S(""), 1, 0, S("can't happen"));
+ test(S("abcdefghij"), 5, S("12345"), 0, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 5, S("12345"), 0, 1, S("abcde1fghij"));
+ test(S("abcdefghij"), 5, S("12345"), 0, 2, S("abcde12fghij"));
+ test(S("abcdefghij"), 5, S("12345"), 0, 4, S("abcde1234fghij"));
+ test(S("abcdefghij"), 5, S("12345"), 0, 5, S("abcde12345fghij"));
+ test(S("abcdefghij"), 5, S("12345"), 0, 6, S("abcde12345fghij"));
+ test(S("abcdefghij"), 5, S("12345"), 1, 0, S("abcdefghij"));
+}
+
+template <class S>
+void test15()
+{
+ test(S("abcdefghij"), 5, S("12345"), 1, 1, S("abcde2fghij"));
+ test(S("abcdefghij"), 5, S("12345"), 1, 2, S("abcde23fghij"));
+ test(S("abcdefghij"), 5, S("12345"), 1, 3, S("abcde234fghij"));
+ test(S("abcdefghij"), 5, S("12345"), 1, 4, S("abcde2345fghij"));
+ test(S("abcdefghij"), 5, S("12345"), 1, 5, S("abcde2345fghij"));
+ test(S("abcdefghij"), 5, S("12345"), 2, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 5, S("12345"), 2, 1, S("abcde3fghij"));
+ test(S("abcdefghij"), 5, S("12345"), 2, 2, S("abcde34fghij"));
+ test(S("abcdefghij"), 5, S("12345"), 2, 3, S("abcde345fghij"));
+ test(S("abcdefghij"), 5, S("12345"), 2, 4, S("abcde345fghij"));
+ test(S("abcdefghij"), 5, S("12345"), 4, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 5, S("12345"), 4, 1, S("abcde5fghij"));
+ test(S("abcdefghij"), 5, S("12345"), 4, 2, S("abcde5fghij"));
+ test(S("abcdefghij"), 5, S("12345"), 5, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 5, S("12345"), 5, 1, S("abcdefghij"));
+ test(S("abcdefghij"), 5, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcdefghij"), 5, S("1234567890"), 0, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 5, S("1234567890"), 0, 1, S("abcde1fghij"));
+ test(S("abcdefghij"), 5, S("1234567890"), 0, 5, S("abcde12345fghij"));
+ test(S("abcdefghij"), 5, S("1234567890"), 0, 9, S("abcde123456789fghij"));
+ test(S("abcdefghij"), 5, S("1234567890"), 0, 10, S("abcde1234567890fghij"));
+ test(S("abcdefghij"), 5, S("1234567890"), 0, 11, S("abcde1234567890fghij"));
+ test(S("abcdefghij"), 5, S("1234567890"), 1, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 5, S("1234567890"), 1, 1, S("abcde2fghij"));
+ test(S("abcdefghij"), 5, S("1234567890"), 1, 4, S("abcde2345fghij"));
+ test(S("abcdefghij"), 5, S("1234567890"), 1, 8, S("abcde23456789fghij"));
+ test(S("abcdefghij"), 5, S("1234567890"), 1, 9, S("abcde234567890fghij"));
+ test(S("abcdefghij"), 5, S("1234567890"), 1, 10, S("abcde234567890fghij"));
+ test(S("abcdefghij"), 5, S("1234567890"), 5, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 5, S("1234567890"), 5, 1, S("abcde6fghij"));
+ test(S("abcdefghij"), 5, S("1234567890"), 5, 2, S("abcde67fghij"));
+ test(S("abcdefghij"), 5, S("1234567890"), 5, 4, S("abcde6789fghij"));
+ test(S("abcdefghij"), 5, S("1234567890"), 5, 5, S("abcde67890fghij"));
+ test(S("abcdefghij"), 5, S("1234567890"), 5, 6, S("abcde67890fghij"));
+ test(S("abcdefghij"), 5, S("1234567890"), 9, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 5, S("1234567890"), 9, 1, S("abcde0fghij"));
+ test(S("abcdefghij"), 5, S("1234567890"), 9, 2, S("abcde0fghij"));
+ test(S("abcdefghij"), 5, S("1234567890"), 10, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 5, S("1234567890"), 10, 1, S("abcdefghij"));
+ test(S("abcdefghij"), 5, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcdefghij"), 5, S("12345678901234567890"), 0, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 5, S("12345678901234567890"), 0, 1, S("abcde1fghij"));
+ test(S("abcdefghij"), 5, S("12345678901234567890"), 0, 10, S("abcde1234567890fghij"));
+ test(S("abcdefghij"), 5, S("12345678901234567890"), 0, 19, S("abcde1234567890123456789fghij"));
+ test(S("abcdefghij"), 5, S("12345678901234567890"), 0, 20, S("abcde12345678901234567890fghij"));
+ test(S("abcdefghij"), 5, S("12345678901234567890"), 0, 21, S("abcde12345678901234567890fghij"));
+ test(S("abcdefghij"), 5, S("12345678901234567890"), 1, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 5, S("12345678901234567890"), 1, 1, S("abcde2fghij"));
+ test(S("abcdefghij"), 5, S("12345678901234567890"), 1, 9, S("abcde234567890fghij"));
+ test(S("abcdefghij"), 5, S("12345678901234567890"), 1, 18, S("abcde234567890123456789fghij"));
+}
+
+template <class S>
+void test16()
+{
+ test(S("abcdefghij"), 5, S("12345678901234567890"), 1, 19, S("abcde2345678901234567890fghij"));
+ test(S("abcdefghij"), 5, S("12345678901234567890"), 1, 20, S("abcde2345678901234567890fghij"));
+ test(S("abcdefghij"), 5, S("12345678901234567890"), 10, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 5, S("12345678901234567890"), 10, 1, S("abcde1fghij"));
+ test(S("abcdefghij"), 5, S("12345678901234567890"), 10, 5, S("abcde12345fghij"));
+ test(S("abcdefghij"), 5, S("12345678901234567890"), 10, 9, S("abcde123456789fghij"));
+ test(S("abcdefghij"), 5, S("12345678901234567890"), 10, 10, S("abcde1234567890fghij"));
+ test(S("abcdefghij"), 5, S("12345678901234567890"), 10, 11, S("abcde1234567890fghij"));
+ test(S("abcdefghij"), 5, S("12345678901234567890"), 19, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 5, S("12345678901234567890"), 19, 1, S("abcde0fghij"));
+ test(S("abcdefghij"), 5, S("12345678901234567890"), 19, 2, S("abcde0fghij"));
+ test(S("abcdefghij"), 5, S("12345678901234567890"), 20, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 5, S("12345678901234567890"), 20, 1, S("abcdefghij"));
+ test(S("abcdefghij"), 5, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcdefghij"), 9, S(""), 0, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 9, S(""), 0, 1, S("abcdefghij"));
+ test(S("abcdefghij"), 9, S(""), 1, 0, S("can't happen"));
+ test(S("abcdefghij"), 9, S("12345"), 0, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 9, S("12345"), 0, 1, S("abcdefghi1j"));
+ test(S("abcdefghij"), 9, S("12345"), 0, 2, S("abcdefghi12j"));
+ test(S("abcdefghij"), 9, S("12345"), 0, 4, S("abcdefghi1234j"));
+ test(S("abcdefghij"), 9, S("12345"), 0, 5, S("abcdefghi12345j"));
+ test(S("abcdefghij"), 9, S("12345"), 0, 6, S("abcdefghi12345j"));
+ test(S("abcdefghij"), 9, S("12345"), 1, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 9, S("12345"), 1, 1, S("abcdefghi2j"));
+ test(S("abcdefghij"), 9, S("12345"), 1, 2, S("abcdefghi23j"));
+ test(S("abcdefghij"), 9, S("12345"), 1, 3, S("abcdefghi234j"));
+ test(S("abcdefghij"), 9, S("12345"), 1, 4, S("abcdefghi2345j"));
+ test(S("abcdefghij"), 9, S("12345"), 1, 5, S("abcdefghi2345j"));
+ test(S("abcdefghij"), 9, S("12345"), 2, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 9, S("12345"), 2, 1, S("abcdefghi3j"));
+ test(S("abcdefghij"), 9, S("12345"), 2, 2, S("abcdefghi34j"));
+ test(S("abcdefghij"), 9, S("12345"), 2, 3, S("abcdefghi345j"));
+ test(S("abcdefghij"), 9, S("12345"), 2, 4, S("abcdefghi345j"));
+ test(S("abcdefghij"), 9, S("12345"), 4, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 9, S("12345"), 4, 1, S("abcdefghi5j"));
+ test(S("abcdefghij"), 9, S("12345"), 4, 2, S("abcdefghi5j"));
+ test(S("abcdefghij"), 9, S("12345"), 5, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 9, S("12345"), 5, 1, S("abcdefghij"));
+ test(S("abcdefghij"), 9, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcdefghij"), 9, S("1234567890"), 0, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 9, S("1234567890"), 0, 1, S("abcdefghi1j"));
+ test(S("abcdefghij"), 9, S("1234567890"), 0, 5, S("abcdefghi12345j"));
+ test(S("abcdefghij"), 9, S("1234567890"), 0, 9, S("abcdefghi123456789j"));
+ test(S("abcdefghij"), 9, S("1234567890"), 0, 10, S("abcdefghi1234567890j"));
+ test(S("abcdefghij"), 9, S("1234567890"), 0, 11, S("abcdefghi1234567890j"));
+ test(S("abcdefghij"), 9, S("1234567890"), 1, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 9, S("1234567890"), 1, 1, S("abcdefghi2j"));
+ test(S("abcdefghij"), 9, S("1234567890"), 1, 4, S("abcdefghi2345j"));
+ test(S("abcdefghij"), 9, S("1234567890"), 1, 8, S("abcdefghi23456789j"));
+}
+
+template <class S>
+void test17()
+{
+ test(S("abcdefghij"), 9, S("1234567890"), 1, 9, S("abcdefghi234567890j"));
+ test(S("abcdefghij"), 9, S("1234567890"), 1, 10, S("abcdefghi234567890j"));
+ test(S("abcdefghij"), 9, S("1234567890"), 5, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 9, S("1234567890"), 5, 1, S("abcdefghi6j"));
+ test(S("abcdefghij"), 9, S("1234567890"), 5, 2, S("abcdefghi67j"));
+ test(S("abcdefghij"), 9, S("1234567890"), 5, 4, S("abcdefghi6789j"));
+ test(S("abcdefghij"), 9, S("1234567890"), 5, 5, S("abcdefghi67890j"));
+ test(S("abcdefghij"), 9, S("1234567890"), 5, 6, S("abcdefghi67890j"));
+ test(S("abcdefghij"), 9, S("1234567890"), 9, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 9, S("1234567890"), 9, 1, S("abcdefghi0j"));
+ test(S("abcdefghij"), 9, S("1234567890"), 9, 2, S("abcdefghi0j"));
+ test(S("abcdefghij"), 9, S("1234567890"), 10, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 9, S("1234567890"), 10, 1, S("abcdefghij"));
+ test(S("abcdefghij"), 9, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcdefghij"), 9, S("12345678901234567890"), 0, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 9, S("12345678901234567890"), 0, 1, S("abcdefghi1j"));
+ test(S("abcdefghij"), 9, S("12345678901234567890"), 0, 10, S("abcdefghi1234567890j"));
+ test(S("abcdefghij"), 9, S("12345678901234567890"), 0, 19, S("abcdefghi1234567890123456789j"));
+ test(S("abcdefghij"), 9, S("12345678901234567890"), 0, 20, S("abcdefghi12345678901234567890j"));
+ test(S("abcdefghij"), 9, S("12345678901234567890"), 0, 21, S("abcdefghi12345678901234567890j"));
+ test(S("abcdefghij"), 9, S("12345678901234567890"), 1, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 9, S("12345678901234567890"), 1, 1, S("abcdefghi2j"));
+ test(S("abcdefghij"), 9, S("12345678901234567890"), 1, 9, S("abcdefghi234567890j"));
+ test(S("abcdefghij"), 9, S("12345678901234567890"), 1, 18, S("abcdefghi234567890123456789j"));
+ test(S("abcdefghij"), 9, S("12345678901234567890"), 1, 19, S("abcdefghi2345678901234567890j"));
+ test(S("abcdefghij"), 9, S("12345678901234567890"), 1, 20, S("abcdefghi2345678901234567890j"));
+ test(S("abcdefghij"), 9, S("12345678901234567890"), 10, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 9, S("12345678901234567890"), 10, 1, S("abcdefghi1j"));
+ test(S("abcdefghij"), 9, S("12345678901234567890"), 10, 5, S("abcdefghi12345j"));
+ test(S("abcdefghij"), 9, S("12345678901234567890"), 10, 9, S("abcdefghi123456789j"));
+ test(S("abcdefghij"), 9, S("12345678901234567890"), 10, 10, S("abcdefghi1234567890j"));
+ test(S("abcdefghij"), 9, S("12345678901234567890"), 10, 11, S("abcdefghi1234567890j"));
+ test(S("abcdefghij"), 9, S("12345678901234567890"), 19, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 9, S("12345678901234567890"), 19, 1, S("abcdefghi0j"));
+ test(S("abcdefghij"), 9, S("12345678901234567890"), 19, 2, S("abcdefghi0j"));
+ test(S("abcdefghij"), 9, S("12345678901234567890"), 20, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 9, S("12345678901234567890"), 20, 1, S("abcdefghij"));
+ test(S("abcdefghij"), 9, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcdefghij"), 10, S(""), 0, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 10, S(""), 0, 1, S("abcdefghij"));
+ test(S("abcdefghij"), 10, S(""), 1, 0, S("can't happen"));
+ test(S("abcdefghij"), 10, S("12345"), 0, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 10, S("12345"), 0, 1, S("abcdefghij1"));
+ test(S("abcdefghij"), 10, S("12345"), 0, 2, S("abcdefghij12"));
+ test(S("abcdefghij"), 10, S("12345"), 0, 4, S("abcdefghij1234"));
+ test(S("abcdefghij"), 10, S("12345"), 0, 5, S("abcdefghij12345"));
+ test(S("abcdefghij"), 10, S("12345"), 0, 6, S("abcdefghij12345"));
+ test(S("abcdefghij"), 10, S("12345"), 1, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 10, S("12345"), 1, 1, S("abcdefghij2"));
+ test(S("abcdefghij"), 10, S("12345"), 1, 2, S("abcdefghij23"));
+}
+
+template <class S>
+void test18()
+{
+ test(S("abcdefghij"), 10, S("12345"), 1, 3, S("abcdefghij234"));
+ test(S("abcdefghij"), 10, S("12345"), 1, 4, S("abcdefghij2345"));
+ test(S("abcdefghij"), 10, S("12345"), 1, 5, S("abcdefghij2345"));
+ test(S("abcdefghij"), 10, S("12345"), 2, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 10, S("12345"), 2, 1, S("abcdefghij3"));
+ test(S("abcdefghij"), 10, S("12345"), 2, 2, S("abcdefghij34"));
+ test(S("abcdefghij"), 10, S("12345"), 2, 3, S("abcdefghij345"));
+ test(S("abcdefghij"), 10, S("12345"), 2, 4, S("abcdefghij345"));
+ test(S("abcdefghij"), 10, S("12345"), 4, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 10, S("12345"), 4, 1, S("abcdefghij5"));
+ test(S("abcdefghij"), 10, S("12345"), 4, 2, S("abcdefghij5"));
+ test(S("abcdefghij"), 10, S("12345"), 5, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 10, S("12345"), 5, 1, S("abcdefghij"));
+ test(S("abcdefghij"), 10, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcdefghij"), 10, S("1234567890"), 0, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 10, S("1234567890"), 0, 1, S("abcdefghij1"));
+ test(S("abcdefghij"), 10, S("1234567890"), 0, 5, S("abcdefghij12345"));
+ test(S("abcdefghij"), 10, S("1234567890"), 0, 9, S("abcdefghij123456789"));
+ test(S("abcdefghij"), 10, S("1234567890"), 0, 10, S("abcdefghij1234567890"));
+ test(S("abcdefghij"), 10, S("1234567890"), 0, 11, S("abcdefghij1234567890"));
+ test(S("abcdefghij"), 10, S("1234567890"), 1, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 10, S("1234567890"), 1, 1, S("abcdefghij2"));
+ test(S("abcdefghij"), 10, S("1234567890"), 1, 4, S("abcdefghij2345"));
+ test(S("abcdefghij"), 10, S("1234567890"), 1, 8, S("abcdefghij23456789"));
+ test(S("abcdefghij"), 10, S("1234567890"), 1, 9, S("abcdefghij234567890"));
+ test(S("abcdefghij"), 10, S("1234567890"), 1, 10, S("abcdefghij234567890"));
+ test(S("abcdefghij"), 10, S("1234567890"), 5, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 10, S("1234567890"), 5, 1, S("abcdefghij6"));
+ test(S("abcdefghij"), 10, S("1234567890"), 5, 2, S("abcdefghij67"));
+ test(S("abcdefghij"), 10, S("1234567890"), 5, 4, S("abcdefghij6789"));
+ test(S("abcdefghij"), 10, S("1234567890"), 5, 5, S("abcdefghij67890"));
+ test(S("abcdefghij"), 10, S("1234567890"), 5, 6, S("abcdefghij67890"));
+ test(S("abcdefghij"), 10, S("1234567890"), 9, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 10, S("1234567890"), 9, 1, S("abcdefghij0"));
+ test(S("abcdefghij"), 10, S("1234567890"), 9, 2, S("abcdefghij0"));
+ test(S("abcdefghij"), 10, S("1234567890"), 10, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 10, S("1234567890"), 10, 1, S("abcdefghij"));
+ test(S("abcdefghij"), 10, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcdefghij"), 10, S("12345678901234567890"), 0, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 10, S("12345678901234567890"), 0, 1, S("abcdefghij1"));
+ test(S("abcdefghij"), 10, S("12345678901234567890"), 0, 10, S("abcdefghij1234567890"));
+ test(S("abcdefghij"), 10, S("12345678901234567890"), 0, 19, S("abcdefghij1234567890123456789"));
+ test(S("abcdefghij"), 10, S("12345678901234567890"), 0, 20, S("abcdefghij12345678901234567890"));
+ test(S("abcdefghij"), 10, S("12345678901234567890"), 0, 21, S("abcdefghij12345678901234567890"));
+ test(S("abcdefghij"), 10, S("12345678901234567890"), 1, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 10, S("12345678901234567890"), 1, 1, S("abcdefghij2"));
+ test(S("abcdefghij"), 10, S("12345678901234567890"), 1, 9, S("abcdefghij234567890"));
+ test(S("abcdefghij"), 10, S("12345678901234567890"), 1, 18, S("abcdefghij234567890123456789"));
+ test(S("abcdefghij"), 10, S("12345678901234567890"), 1, 19, S("abcdefghij2345678901234567890"));
+ test(S("abcdefghij"), 10, S("12345678901234567890"), 1, 20, S("abcdefghij2345678901234567890"));
+}
+
+template <class S>
+void test19()
+{
+ test(S("abcdefghij"), 10, S("12345678901234567890"), 10, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 10, S("12345678901234567890"), 10, 1, S("abcdefghij1"));
+ test(S("abcdefghij"), 10, S("12345678901234567890"), 10, 5, S("abcdefghij12345"));
+ test(S("abcdefghij"), 10, S("12345678901234567890"), 10, 9, S("abcdefghij123456789"));
+ test(S("abcdefghij"), 10, S("12345678901234567890"), 10, 10, S("abcdefghij1234567890"));
+ test(S("abcdefghij"), 10, S("12345678901234567890"), 10, 11, S("abcdefghij1234567890"));
+ test(S("abcdefghij"), 10, S("12345678901234567890"), 19, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 10, S("12345678901234567890"), 19, 1, S("abcdefghij0"));
+ test(S("abcdefghij"), 10, S("12345678901234567890"), 19, 2, S("abcdefghij0"));
+ test(S("abcdefghij"), 10, S("12345678901234567890"), 20, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 10, S("12345678901234567890"), 20, 1, S("abcdefghij"));
+ test(S("abcdefghij"), 10, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcdefghij"), 11, S(""), 0, 0, S("can't happen"));
+ test(S("abcdefghij"), 11, S(""), 0, 1, S("can't happen"));
+ test(S("abcdefghij"), 11, S(""), 1, 0, S("can't happen"));
+ test(S("abcdefghij"), 11, S("12345"), 0, 0, S("can't happen"));
+ test(S("abcdefghij"), 11, S("12345"), 0, 1, S("can't happen"));
+ test(S("abcdefghij"), 11, S("12345"), 0, 2, S("can't happen"));
+ test(S("abcdefghij"), 11, S("12345"), 0, 4, S("can't happen"));
+ test(S("abcdefghij"), 11, S("12345"), 0, 5, S("can't happen"));
+ test(S("abcdefghij"), 11, S("12345"), 0, 6, S("can't happen"));
+ test(S("abcdefghij"), 11, S("12345"), 1, 0, S("can't happen"));
+ test(S("abcdefghij"), 11, S("12345"), 1, 1, S("can't happen"));
+ test(S("abcdefghij"), 11, S("12345"), 1, 2, S("can't happen"));
+ test(S("abcdefghij"), 11, S("12345"), 1, 3, S("can't happen"));
+ test(S("abcdefghij"), 11, S("12345"), 1, 4, S("can't happen"));
+ test(S("abcdefghij"), 11, S("12345"), 1, 5, S("can't happen"));
+ test(S("abcdefghij"), 11, S("12345"), 2, 0, S("can't happen"));
+ test(S("abcdefghij"), 11, S("12345"), 2, 1, S("can't happen"));
+ test(S("abcdefghij"), 11, S("12345"), 2, 2, S("can't happen"));
+ test(S("abcdefghij"), 11, S("12345"), 2, 3, S("can't happen"));
+ test(S("abcdefghij"), 11, S("12345"), 2, 4, S("can't happen"));
+ test(S("abcdefghij"), 11, S("12345"), 4, 0, S("can't happen"));
+ test(S("abcdefghij"), 11, S("12345"), 4, 1, S("can't happen"));
+ test(S("abcdefghij"), 11, S("12345"), 4, 2, S("can't happen"));
+ test(S("abcdefghij"), 11, S("12345"), 5, 0, S("can't happen"));
+ test(S("abcdefghij"), 11, S("12345"), 5, 1, S("can't happen"));
+ test(S("abcdefghij"), 11, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcdefghij"), 11, S("1234567890"), 0, 0, S("can't happen"));
+ test(S("abcdefghij"), 11, S("1234567890"), 0, 1, S("can't happen"));
+ test(S("abcdefghij"), 11, S("1234567890"), 0, 5, S("can't happen"));
+ test(S("abcdefghij"), 11, S("1234567890"), 0, 9, S("can't happen"));
+ test(S("abcdefghij"), 11, S("1234567890"), 0, 10, S("can't happen"));
+ test(S("abcdefghij"), 11, S("1234567890"), 0, 11, S("can't happen"));
+ test(S("abcdefghij"), 11, S("1234567890"), 1, 0, S("can't happen"));
+ test(S("abcdefghij"), 11, S("1234567890"), 1, 1, S("can't happen"));
+ test(S("abcdefghij"), 11, S("1234567890"), 1, 4, S("can't happen"));
+ test(S("abcdefghij"), 11, S("1234567890"), 1, 8, S("can't happen"));
+ test(S("abcdefghij"), 11, S("1234567890"), 1, 9, S("can't happen"));
+ test(S("abcdefghij"), 11, S("1234567890"), 1, 10, S("can't happen"));
+}
+
+template <class S>
+void test20()
+{
+ test(S("abcdefghij"), 11, S("1234567890"), 5, 0, S("can't happen"));
+ test(S("abcdefghij"), 11, S("1234567890"), 5, 1, S("can't happen"));
+ test(S("abcdefghij"), 11, S("1234567890"), 5, 2, S("can't happen"));
+ test(S("abcdefghij"), 11, S("1234567890"), 5, 4, S("can't happen"));
+ test(S("abcdefghij"), 11, S("1234567890"), 5, 5, S("can't happen"));
+ test(S("abcdefghij"), 11, S("1234567890"), 5, 6, S("can't happen"));
+ test(S("abcdefghij"), 11, S("1234567890"), 9, 0, S("can't happen"));
+ test(S("abcdefghij"), 11, S("1234567890"), 9, 1, S("can't happen"));
+ test(S("abcdefghij"), 11, S("1234567890"), 9, 2, S("can't happen"));
+ test(S("abcdefghij"), 11, S("1234567890"), 10, 0, S("can't happen"));
+ test(S("abcdefghij"), 11, S("1234567890"), 10, 1, S("can't happen"));
+ test(S("abcdefghij"), 11, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcdefghij"), 11, S("12345678901234567890"), 0, 0, S("can't happen"));
+ test(S("abcdefghij"), 11, S("12345678901234567890"), 0, 1, S("can't happen"));
+ test(S("abcdefghij"), 11, S("12345678901234567890"), 0, 10, S("can't happen"));
+ test(S("abcdefghij"), 11, S("12345678901234567890"), 0, 19, S("can't happen"));
+ test(S("abcdefghij"), 11, S("12345678901234567890"), 0, 20, S("can't happen"));
+ test(S("abcdefghij"), 11, S("12345678901234567890"), 0, 21, S("can't happen"));
+ test(S("abcdefghij"), 11, S("12345678901234567890"), 1, 0, S("can't happen"));
+ test(S("abcdefghij"), 11, S("12345678901234567890"), 1, 1, S("can't happen"));
+ test(S("abcdefghij"), 11, S("12345678901234567890"), 1, 9, S("can't happen"));
+ test(S("abcdefghij"), 11, S("12345678901234567890"), 1, 18, S("can't happen"));
+ test(S("abcdefghij"), 11, S("12345678901234567890"), 1, 19, S("can't happen"));
+ test(S("abcdefghij"), 11, S("12345678901234567890"), 1, 20, S("can't happen"));
+ test(S("abcdefghij"), 11, S("12345678901234567890"), 10, 0, S("can't happen"));
+ test(S("abcdefghij"), 11, S("12345678901234567890"), 10, 1, S("can't happen"));
+ test(S("abcdefghij"), 11, S("12345678901234567890"), 10, 5, S("can't happen"));
+ test(S("abcdefghij"), 11, S("12345678901234567890"), 10, 9, S("can't happen"));
+ test(S("abcdefghij"), 11, S("12345678901234567890"), 10, 10, S("can't happen"));
+ test(S("abcdefghij"), 11, S("12345678901234567890"), 10, 11, S("can't happen"));
+ test(S("abcdefghij"), 11, S("12345678901234567890"), 19, 0, S("can't happen"));
+ test(S("abcdefghij"), 11, S("12345678901234567890"), 19, 1, S("can't happen"));
+ test(S("abcdefghij"), 11, S("12345678901234567890"), 19, 2, S("can't happen"));
+ test(S("abcdefghij"), 11, S("12345678901234567890"), 20, 0, S("can't happen"));
+ test(S("abcdefghij"), 11, S("12345678901234567890"), 20, 1, S("can't happen"));
+ test(S("abcdefghij"), 11, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 0, S(""), 0, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, S(""), 0, 1, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, S(""), 1, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 0, S("12345"), 0, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, S("12345"), 0, 1, S("1abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, S("12345"), 0, 2, S("12abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, S("12345"), 0, 4, S("1234abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, S("12345"), 0, 5, S("12345abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, S("12345"), 0, 6, S("12345abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, S("12345"), 1, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, S("12345"), 1, 1, S("2abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, S("12345"), 1, 2, S("23abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, S("12345"), 1, 3, S("234abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, S("12345"), 1, 4, S("2345abcdefghijklmnopqrst"));
+}
+
+template <class S>
+void test21()
+{
+ test(S("abcdefghijklmnopqrst"), 0, S("12345"), 1, 5, S("2345abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, S("12345"), 2, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, S("12345"), 2, 1, S("3abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, S("12345"), 2, 2, S("34abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, S("12345"), 2, 3, S("345abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, S("12345"), 2, 4, S("345abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, S("12345"), 4, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, S("12345"), 4, 1, S("5abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, S("12345"), 4, 2, S("5abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, S("12345"), 5, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, S("12345"), 5, 1, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 0, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 0, 1, S("1abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 0, 5, S("12345abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 0, 9, S("123456789abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 0, 10, S("1234567890abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 0, 11, S("1234567890abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 1, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 1, 1, S("2abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 1, 4, S("2345abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 1, 8, S("23456789abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 1, 9, S("234567890abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 1, 10, S("234567890abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 5, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 5, 1, S("6abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 5, 2, S("67abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 5, 4, S("6789abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 5, 5, S("67890abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 5, 6, S("67890abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 9, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 9, 1, S("0abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 9, 2, S("0abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 10, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 10, 1, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 0, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 0, 1, S("1abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 0, 10, S("1234567890abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 0, 19, S("1234567890123456789abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 0, 20, S("12345678901234567890abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 0, 21, S("12345678901234567890abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 1, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 1, 1, S("2abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 1, 9, S("234567890abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 1, 18, S("234567890123456789abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 1, 19, S("2345678901234567890abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 1, 20, S("2345678901234567890abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 10, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 10, 1, S("1abcdefghijklmnopqrst"));
+}
+
+template <class S>
+void test22()
+{
+ test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 10, 5, S("12345abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 10, 9, S("123456789abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 10, 10, S("1234567890abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 10, 11, S("1234567890abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 19, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 19, 1, S("0abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 19, 2, S("0abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 20, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 20, 1, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 1, S(""), 0, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, S(""), 0, 1, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, S(""), 1, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 1, S("12345"), 0, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, S("12345"), 0, 1, S("a1bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, S("12345"), 0, 2, S("a12bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, S("12345"), 0, 4, S("a1234bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, S("12345"), 0, 5, S("a12345bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, S("12345"), 0, 6, S("a12345bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, S("12345"), 1, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, S("12345"), 1, 1, S("a2bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, S("12345"), 1, 2, S("a23bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, S("12345"), 1, 3, S("a234bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, S("12345"), 1, 4, S("a2345bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, S("12345"), 1, 5, S("a2345bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, S("12345"), 2, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, S("12345"), 2, 1, S("a3bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, S("12345"), 2, 2, S("a34bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, S("12345"), 2, 3, S("a345bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, S("12345"), 2, 4, S("a345bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, S("12345"), 4, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, S("12345"), 4, 1, S("a5bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, S("12345"), 4, 2, S("a5bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, S("12345"), 5, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, S("12345"), 5, 1, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 0, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 0, 1, S("a1bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 0, 5, S("a12345bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 0, 9, S("a123456789bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 0, 10, S("a1234567890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 0, 11, S("a1234567890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 1, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 1, 1, S("a2bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 1, 4, S("a2345bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 1, 8, S("a23456789bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 1, 9, S("a234567890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 1, 10, S("a234567890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 5, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 5, 1, S("a6bcdefghijklmnopqrst"));
+}
+
+template <class S>
+void test23()
+{
+ test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 5, 2, S("a67bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 5, 4, S("a6789bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 5, 5, S("a67890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 5, 6, S("a67890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 9, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 9, 1, S("a0bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 9, 2, S("a0bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 10, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 10, 1, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 0, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 0, 1, S("a1bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 0, 10, S("a1234567890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 0, 19, S("a1234567890123456789bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 0, 20, S("a12345678901234567890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 0, 21, S("a12345678901234567890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 1, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 1, 1, S("a2bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 1, 9, S("a234567890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 1, 18, S("a234567890123456789bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 1, 19, S("a2345678901234567890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 1, 20, S("a2345678901234567890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 10, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 10, 1, S("a1bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 10, 5, S("a12345bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 10, 9, S("a123456789bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 10, 10, S("a1234567890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 10, 11, S("a1234567890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 19, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 19, 1, S("a0bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 19, 2, S("a0bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 20, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 20, 1, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 10, S(""), 0, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, S(""), 0, 1, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, S(""), 1, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 10, S("12345"), 0, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, S("12345"), 0, 1, S("abcdefghij1klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, S("12345"), 0, 2, S("abcdefghij12klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, S("12345"), 0, 4, S("abcdefghij1234klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, S("12345"), 0, 5, S("abcdefghij12345klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, S("12345"), 0, 6, S("abcdefghij12345klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, S("12345"), 1, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, S("12345"), 1, 1, S("abcdefghij2klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, S("12345"), 1, 2, S("abcdefghij23klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, S("12345"), 1, 3, S("abcdefghij234klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, S("12345"), 1, 4, S("abcdefghij2345klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, S("12345"), 1, 5, S("abcdefghij2345klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, S("12345"), 2, 0, S("abcdefghijklmnopqrst"));
+}
+
+template <class S>
+void test24()
+{
+ test(S("abcdefghijklmnopqrst"), 10, S("12345"), 2, 1, S("abcdefghij3klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, S("12345"), 2, 2, S("abcdefghij34klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, S("12345"), 2, 3, S("abcdefghij345klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, S("12345"), 2, 4, S("abcdefghij345klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, S("12345"), 4, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, S("12345"), 4, 1, S("abcdefghij5klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, S("12345"), 4, 2, S("abcdefghij5klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, S("12345"), 5, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, S("12345"), 5, 1, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 0, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 0, 1, S("abcdefghij1klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 0, 5, S("abcdefghij12345klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 0, 9, S("abcdefghij123456789klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 0, 10, S("abcdefghij1234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 0, 11, S("abcdefghij1234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 1, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 1, 1, S("abcdefghij2klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 1, 4, S("abcdefghij2345klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 1, 8, S("abcdefghij23456789klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 1, 9, S("abcdefghij234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 1, 10, S("abcdefghij234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 5, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 5, 1, S("abcdefghij6klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 5, 2, S("abcdefghij67klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 5, 4, S("abcdefghij6789klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 5, 5, S("abcdefghij67890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 5, 6, S("abcdefghij67890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 9, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 9, 1, S("abcdefghij0klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 9, 2, S("abcdefghij0klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 10, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 10, 1, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 0, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 0, 1, S("abcdefghij1klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 0, 10, S("abcdefghij1234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 0, 19, S("abcdefghij1234567890123456789klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 0, 20, S("abcdefghij12345678901234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 0, 21, S("abcdefghij12345678901234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 1, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 1, 1, S("abcdefghij2klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 1, 9, S("abcdefghij234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 1, 18, S("abcdefghij234567890123456789klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 1, 19, S("abcdefghij2345678901234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 1, 20, S("abcdefghij2345678901234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 10, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 10, 1, S("abcdefghij1klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 10, 5, S("abcdefghij12345klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 10, 9, S("abcdefghij123456789klmnopqrst"));
+}
+
+template <class S>
+void test25()
+{
+ test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 10, 10, S("abcdefghij1234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 10, 11, S("abcdefghij1234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 19, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 19, 1, S("abcdefghij0klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 19, 2, S("abcdefghij0klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 20, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 20, 1, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 19, S(""), 0, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, S(""), 0, 1, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, S(""), 1, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 19, S("12345"), 0, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, S("12345"), 0, 1, S("abcdefghijklmnopqrs1t"));
+ test(S("abcdefghijklmnopqrst"), 19, S("12345"), 0, 2, S("abcdefghijklmnopqrs12t"));
+ test(S("abcdefghijklmnopqrst"), 19, S("12345"), 0, 4, S("abcdefghijklmnopqrs1234t"));
+ test(S("abcdefghijklmnopqrst"), 19, S("12345"), 0, 5, S("abcdefghijklmnopqrs12345t"));
+ test(S("abcdefghijklmnopqrst"), 19, S("12345"), 0, 6, S("abcdefghijklmnopqrs12345t"));
+ test(S("abcdefghijklmnopqrst"), 19, S("12345"), 1, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, S("12345"), 1, 1, S("abcdefghijklmnopqrs2t"));
+ test(S("abcdefghijklmnopqrst"), 19, S("12345"), 1, 2, S("abcdefghijklmnopqrs23t"));
+ test(S("abcdefghijklmnopqrst"), 19, S("12345"), 1, 3, S("abcdefghijklmnopqrs234t"));
+ test(S("abcdefghijklmnopqrst"), 19, S("12345"), 1, 4, S("abcdefghijklmnopqrs2345t"));
+ test(S("abcdefghijklmnopqrst"), 19, S("12345"), 1, 5, S("abcdefghijklmnopqrs2345t"));
+ test(S("abcdefghijklmnopqrst"), 19, S("12345"), 2, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, S("12345"), 2, 1, S("abcdefghijklmnopqrs3t"));
+ test(S("abcdefghijklmnopqrst"), 19, S("12345"), 2, 2, S("abcdefghijklmnopqrs34t"));
+ test(S("abcdefghijklmnopqrst"), 19, S("12345"), 2, 3, S("abcdefghijklmnopqrs345t"));
+ test(S("abcdefghijklmnopqrst"), 19, S("12345"), 2, 4, S("abcdefghijklmnopqrs345t"));
+ test(S("abcdefghijklmnopqrst"), 19, S("12345"), 4, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, S("12345"), 4, 1, S("abcdefghijklmnopqrs5t"));
+ test(S("abcdefghijklmnopqrst"), 19, S("12345"), 4, 2, S("abcdefghijklmnopqrs5t"));
+ test(S("abcdefghijklmnopqrst"), 19, S("12345"), 5, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, S("12345"), 5, 1, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 0, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 0, 1, S("abcdefghijklmnopqrs1t"));
+ test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 0, 5, S("abcdefghijklmnopqrs12345t"));
+ test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 0, 9, S("abcdefghijklmnopqrs123456789t"));
+ test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 0, 10, S("abcdefghijklmnopqrs1234567890t"));
+ test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 0, 11, S("abcdefghijklmnopqrs1234567890t"));
+ test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 1, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 1, 1, S("abcdefghijklmnopqrs2t"));
+ test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 1, 4, S("abcdefghijklmnopqrs2345t"));
+ test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 1, 8, S("abcdefghijklmnopqrs23456789t"));
+ test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 1, 9, S("abcdefghijklmnopqrs234567890t"));
+ test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 1, 10, S("abcdefghijklmnopqrs234567890t"));
+ test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 5, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 5, 1, S("abcdefghijklmnopqrs6t"));
+ test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 5, 2, S("abcdefghijklmnopqrs67t"));
+ test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 5, 4, S("abcdefghijklmnopqrs6789t"));
+}
+
+template <class S>
+void test26()
+{
+ test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 5, 5, S("abcdefghijklmnopqrs67890t"));
+ test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 5, 6, S("abcdefghijklmnopqrs67890t"));
+ test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 9, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 9, 1, S("abcdefghijklmnopqrs0t"));
+ test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 9, 2, S("abcdefghijklmnopqrs0t"));
+ test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 10, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 10, 1, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 0, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 0, 1, S("abcdefghijklmnopqrs1t"));
+ test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 0, 10, S("abcdefghijklmnopqrs1234567890t"));
+ test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 0, 19, S("abcdefghijklmnopqrs1234567890123456789t"));
+ test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 0, 20, S("abcdefghijklmnopqrs12345678901234567890t"));
+ test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 0, 21, S("abcdefghijklmnopqrs12345678901234567890t"));
+ test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 1, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 1, 1, S("abcdefghijklmnopqrs2t"));
+ test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 1, 9, S("abcdefghijklmnopqrs234567890t"));
+ test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 1, 18, S("abcdefghijklmnopqrs234567890123456789t"));
+ test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 1, 19, S("abcdefghijklmnopqrs2345678901234567890t"));
+ test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 1, 20, S("abcdefghijklmnopqrs2345678901234567890t"));
+ test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 10, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 10, 1, S("abcdefghijklmnopqrs1t"));
+ test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 10, 5, S("abcdefghijklmnopqrs12345t"));
+ test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 10, 9, S("abcdefghijklmnopqrs123456789t"));
+ test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 10, 10, S("abcdefghijklmnopqrs1234567890t"));
+ test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 10, 11, S("abcdefghijklmnopqrs1234567890t"));
+ test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 19, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 19, 1, S("abcdefghijklmnopqrs0t"));
+ test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 19, 2, S("abcdefghijklmnopqrs0t"));
+ test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 20, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 20, 1, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 20, S(""), 0, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, S(""), 0, 1, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, S(""), 1, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 20, S("12345"), 0, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, S("12345"), 0, 1, S("abcdefghijklmnopqrst1"));
+ test(S("abcdefghijklmnopqrst"), 20, S("12345"), 0, 2, S("abcdefghijklmnopqrst12"));
+ test(S("abcdefghijklmnopqrst"), 20, S("12345"), 0, 4, S("abcdefghijklmnopqrst1234"));
+ test(S("abcdefghijklmnopqrst"), 20, S("12345"), 0, 5, S("abcdefghijklmnopqrst12345"));
+ test(S("abcdefghijklmnopqrst"), 20, S("12345"), 0, 6, S("abcdefghijklmnopqrst12345"));
+ test(S("abcdefghijklmnopqrst"), 20, S("12345"), 1, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, S("12345"), 1, 1, S("abcdefghijklmnopqrst2"));
+ test(S("abcdefghijklmnopqrst"), 20, S("12345"), 1, 2, S("abcdefghijklmnopqrst23"));
+ test(S("abcdefghijklmnopqrst"), 20, S("12345"), 1, 3, S("abcdefghijklmnopqrst234"));
+ test(S("abcdefghijklmnopqrst"), 20, S("12345"), 1, 4, S("abcdefghijklmnopqrst2345"));
+ test(S("abcdefghijklmnopqrst"), 20, S("12345"), 1, 5, S("abcdefghijklmnopqrst2345"));
+ test(S("abcdefghijklmnopqrst"), 20, S("12345"), 2, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, S("12345"), 2, 1, S("abcdefghijklmnopqrst3"));
+ test(S("abcdefghijklmnopqrst"), 20, S("12345"), 2, 2, S("abcdefghijklmnopqrst34"));
+}
+
+template <class S>
+void test27()
+{
+ test(S("abcdefghijklmnopqrst"), 20, S("12345"), 2, 3, S("abcdefghijklmnopqrst345"));
+ test(S("abcdefghijklmnopqrst"), 20, S("12345"), 2, 4, S("abcdefghijklmnopqrst345"));
+ test(S("abcdefghijklmnopqrst"), 20, S("12345"), 4, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, S("12345"), 4, 1, S("abcdefghijklmnopqrst5"));
+ test(S("abcdefghijklmnopqrst"), 20, S("12345"), 4, 2, S("abcdefghijklmnopqrst5"));
+ test(S("abcdefghijklmnopqrst"), 20, S("12345"), 5, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, S("12345"), 5, 1, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 0, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 0, 1, S("abcdefghijklmnopqrst1"));
+ test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 0, 5, S("abcdefghijklmnopqrst12345"));
+ test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 0, 9, S("abcdefghijklmnopqrst123456789"));
+ test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 0, 10, S("abcdefghijklmnopqrst1234567890"));
+ test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 0, 11, S("abcdefghijklmnopqrst1234567890"));
+ test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 1, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 1, 1, S("abcdefghijklmnopqrst2"));
+ test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 1, 4, S("abcdefghijklmnopqrst2345"));
+ test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 1, 8, S("abcdefghijklmnopqrst23456789"));
+ test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 1, 9, S("abcdefghijklmnopqrst234567890"));
+ test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 1, 10, S("abcdefghijklmnopqrst234567890"));
+ test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 5, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 5, 1, S("abcdefghijklmnopqrst6"));
+ test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 5, 2, S("abcdefghijklmnopqrst67"));
+ test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 5, 4, S("abcdefghijklmnopqrst6789"));
+ test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 5, 5, S("abcdefghijklmnopqrst67890"));
+ test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 5, 6, S("abcdefghijklmnopqrst67890"));
+ test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 9, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 9, 1, S("abcdefghijklmnopqrst0"));
+ test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 9, 2, S("abcdefghijklmnopqrst0"));
+ test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 10, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 10, 1, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 0, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 0, 1, S("abcdefghijklmnopqrst1"));
+ test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 0, 10, S("abcdefghijklmnopqrst1234567890"));
+ test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 0, 19, S("abcdefghijklmnopqrst1234567890123456789"));
+ test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 0, 20, S("abcdefghijklmnopqrst12345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 0, 21, S("abcdefghijklmnopqrst12345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 1, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 1, 1, S("abcdefghijklmnopqrst2"));
+ test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 1, 9, S("abcdefghijklmnopqrst234567890"));
+ test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 1, 18, S("abcdefghijklmnopqrst234567890123456789"));
+ test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 1, 19, S("abcdefghijklmnopqrst2345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 1, 20, S("abcdefghijklmnopqrst2345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 10, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 10, 1, S("abcdefghijklmnopqrst1"));
+ test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 10, 5, S("abcdefghijklmnopqrst12345"));
+ test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 10, 9, S("abcdefghijklmnopqrst123456789"));
+ test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 10, 10, S("abcdefghijklmnopqrst1234567890"));
+ test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 10, 11, S("abcdefghijklmnopqrst1234567890"));
+}
+
+template <class S>
+void test28()
+{
+ test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 19, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 19, 1, S("abcdefghijklmnopqrst0"));
+ test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 19, 2, S("abcdefghijklmnopqrst0"));
+ test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 20, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 20, 1, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, S(""), 0, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, S(""), 0, 1, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, S(""), 1, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, S("12345"), 0, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, S("12345"), 0, 1, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, S("12345"), 0, 2, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, S("12345"), 0, 4, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, S("12345"), 0, 5, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, S("12345"), 0, 6, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, S("12345"), 1, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, S("12345"), 1, 1, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, S("12345"), 1, 2, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, S("12345"), 1, 3, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, S("12345"), 1, 4, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, S("12345"), 1, 5, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, S("12345"), 2, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, S("12345"), 2, 1, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, S("12345"), 2, 2, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, S("12345"), 2, 3, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, S("12345"), 2, 4, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, S("12345"), 4, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, S("12345"), 4, 1, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, S("12345"), 4, 2, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, S("12345"), 5, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, S("12345"), 5, 1, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 0, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 0, 1, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 0, 5, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 0, 9, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 0, 10, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 0, 11, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 1, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 1, 1, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 1, 4, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 1, 8, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 1, 9, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 1, 10, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 5, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 5, 1, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 5, 2, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 5, 4, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 5, 5, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 5, 6, S("can't happen"));
+}
+
+template <class S>
+void test29()
+{
+ test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 9, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 9, 1, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 9, 2, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 10, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 10, 1, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 0, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 0, 1, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 0, 10, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 0, 19, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 0, 20, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 0, 21, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 1, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 1, 1, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 1, 9, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 1, 18, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 1, 19, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 1, 20, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 10, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 10, 1, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 10, 5, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 10, 9, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 10, 10, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 10, 11, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 19, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 19, 1, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 19, 2, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 20, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 20, 1, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 21, 0, S("can't happen"));
+}
+
+template <class S>
+void test30()
+{
+ test_npos(S(""), 0, S("12345678901234567890"), 0, S("12345678901234567890"));
+ test_npos(S(""), 0, S("12345678901234567890"), 1, S( "2345678901234567890"));
+ test_npos(S(""), 0, S("12345678901234567890"), 2, S( "345678901234567890"));
+ test_npos(S(""), 0, S("12345678901234567890"), 3, S( "45678901234567890"));
+ test_npos(S(""), 0, S("12345678901234567890"), 5, S( "678901234567890"));
+ test_npos(S(""), 0, S("12345678901234567890"), 10, S( "1234567890"));
+ test_npos(S(""), 0, S("12345678901234567890"), 21, S("can't happen"));
+ test_npos(S("abcdefghijklmnopqrst"), 10, S("12345"), 0, S("abcdefghij12345klmnopqrst"));
+ test_npos(S("abcdefghijklmnopqrst"), 10, S("12345"), 1, S("abcdefghij2345klmnopqrst"));
+ test_npos(S("abcdefghijklmnopqrst"), 10, S("12345"), 3, S("abcdefghij45klmnopqrst"));
+ test_npos(S("abcdefghijklmnopqrst"), 10, S("12345"), 5, S("abcdefghijklmnopqrst"));
+ test_npos(S("abcdefghijklmnopqrst"), 10, S("12345"), 6, S("can't happen"));
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test0<S>();
+ test1<S>();
+ test2<S>();
+ test3<S>();
+ test4<S>();
+ test5<S>();
+ test6<S>();
+ test7<S>();
+ test8<S>();
+ test9<S>();
+ test10<S>();
+ test11<S>();
+ test12<S>();
+ test13<S>();
+ test14<S>();
+ test15<S>();
+ test16<S>();
+ test17<S>();
+ test18<S>();
+ test19<S>();
+ test20<S>();
+ test21<S>();
+ test22<S>();
+ test23<S>();
+ test24<S>();
+ test25<S>();
+ test26<S>();
+ test27<S>();
+ test28<S>();
+ test29<S>();
+ test30<S>();
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test0<S>();
+ test1<S>();
+ test2<S>();
+ test3<S>();
+ test4<S>();
+ test5<S>();
+ test6<S>();
+ test7<S>();
+ test8<S>();
+ test9<S>();
+ test10<S>();
+ test11<S>();
+ test12<S>();
+ test13<S>();
+ test14<S>();
+ test15<S>();
+ test16<S>();
+ test17<S>();
+ test18<S>();
+ test19<S>();
+ test20<S>();
+ test21<S>();
+ test22<S>();
+ test23<S>();
+ test24<S>();
+ test25<S>();
+ test26<S>();
+ test27<S>();
+ test28<S>();
+ test29<S>();
+ test30<S>();
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.modifiers/string_op_plus_equal/char.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_op_plus_equal/char.pass.cpp
new file mode 100644
index 000000000000..7384ae7f1d3c
--- /dev/null
+++ b/test/std/strings/basic.string/string.modifiers/string_op_plus_equal/char.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string<charT,traits,Allocator>& operator+=(charT c);
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s, typename S::value_type str, S expected)
+{
+ s += str;
+ assert(s.__invariants());
+ assert(s == expected);
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test(S(), 'a', S("a"));
+ test(S("12345"), 'a', S("12345a"));
+ test(S("1234567890"), 'a', S("1234567890a"));
+ test(S("12345678901234567890"), 'a', S("12345678901234567890a"));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S(), 'a', S("a"));
+ test(S("12345"), 'a', S("12345a"));
+ test(S("1234567890"), 'a', S("1234567890a"));
+ test(S("12345678901234567890"), 'a', S("12345678901234567890a"));
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.modifiers/string_op_plus_equal/initializer_list.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_op_plus_equal/initializer_list.pass.cpp
new file mode 100644
index 000000000000..c291028998df
--- /dev/null
+++ b/test/std/strings/basic.string/string.modifiers/string_op_plus_equal/initializer_list.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string& operator+=(initializer_list<charT> il);
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ std::string s("123");
+ s += {'a', 'b', 'c'};
+ assert(s == "123abc");
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ S s("123");
+ s += {'a', 'b', 'c'};
+ assert(s == "123abc");
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/strings/basic.string/string.modifiers/string_op_plus_equal/pointer.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_op_plus_equal/pointer.pass.cpp
new file mode 100644
index 000000000000..77b20d1bc080
--- /dev/null
+++ b/test/std/strings/basic.string/string.modifiers/string_op_plus_equal/pointer.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string<charT,traits,Allocator>& operator+=(const charT* s);
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s, const typename S::value_type* str, S expected)
+{
+ s += str;
+ assert(s.__invariants());
+ assert(s == expected);
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test(S(), "", S());
+ test(S(), "12345", S("12345"));
+ test(S(), "1234567890", S("1234567890"));
+ test(S(), "12345678901234567890", S("12345678901234567890"));
+
+ test(S("12345"), "", S("12345"));
+ test(S("12345"), "12345", S("1234512345"));
+ test(S("12345"), "1234567890", S("123451234567890"));
+ test(S("12345"), "12345678901234567890", S("1234512345678901234567890"));
+
+ test(S("1234567890"), "", S("1234567890"));
+ test(S("1234567890"), "12345", S("123456789012345"));
+ test(S("1234567890"), "1234567890", S("12345678901234567890"));
+ test(S("1234567890"), "12345678901234567890", S("123456789012345678901234567890"));
+
+ test(S("12345678901234567890"), "", S("12345678901234567890"));
+ test(S("12345678901234567890"), "12345", S("1234567890123456789012345"));
+ test(S("12345678901234567890"), "1234567890", S("123456789012345678901234567890"));
+ test(S("12345678901234567890"), "12345678901234567890",
+ S("1234567890123456789012345678901234567890"));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S(), "", S());
+ test(S(), "12345", S("12345"));
+ test(S(), "1234567890", S("1234567890"));
+ test(S(), "12345678901234567890", S("12345678901234567890"));
+
+ test(S("12345"), "", S("12345"));
+ test(S("12345"), "12345", S("1234512345"));
+ test(S("12345"), "1234567890", S("123451234567890"));
+ test(S("12345"), "12345678901234567890", S("1234512345678901234567890"));
+
+ test(S("1234567890"), "", S("1234567890"));
+ test(S("1234567890"), "12345", S("123456789012345"));
+ test(S("1234567890"), "1234567890", S("12345678901234567890"));
+ test(S("1234567890"), "12345678901234567890", S("123456789012345678901234567890"));
+
+ test(S("12345678901234567890"), "", S("12345678901234567890"));
+ test(S("12345678901234567890"), "12345", S("1234567890123456789012345"));
+ test(S("12345678901234567890"), "1234567890", S("123456789012345678901234567890"));
+ test(S("12345678901234567890"), "12345678901234567890",
+ S("1234567890123456789012345678901234567890"));
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.modifiers/string_op_plus_equal/string.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_op_plus_equal/string.pass.cpp
new file mode 100644
index 000000000000..33649792521c
--- /dev/null
+++ b/test/std/strings/basic.string/string.modifiers/string_op_plus_equal/string.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string<charT,traits,Allocator>&
+// operator+=(const basic_string<charT,traits,Allocator>& str);
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s, S str, S expected)
+{
+ s += str;
+ assert(s.__invariants());
+ assert(s == expected);
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test(S(), S(), S());
+ test(S(), S("12345"), S("12345"));
+ test(S(), S("1234567890"), S("1234567890"));
+ test(S(), S("12345678901234567890"), S("12345678901234567890"));
+
+ test(S("12345"), S(), S("12345"));
+ test(S("12345"), S("12345"), S("1234512345"));
+ test(S("12345"), S("1234567890"), S("123451234567890"));
+ test(S("12345"), S("12345678901234567890"), S("1234512345678901234567890"));
+
+ test(S("1234567890"), S(), S("1234567890"));
+ test(S("1234567890"), S("12345"), S("123456789012345"));
+ test(S("1234567890"), S("1234567890"), S("12345678901234567890"));
+ test(S("1234567890"), S("12345678901234567890"), S("123456789012345678901234567890"));
+
+ test(S("12345678901234567890"), S(), S("12345678901234567890"));
+ test(S("12345678901234567890"), S("12345"), S("1234567890123456789012345"));
+ test(S("12345678901234567890"), S("1234567890"), S("123456789012345678901234567890"));
+ test(S("12345678901234567890"), S("12345678901234567890"),
+ S("1234567890123456789012345678901234567890"));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S(), S(), S());
+ test(S(), S("12345"), S("12345"));
+ test(S(), S("1234567890"), S("1234567890"));
+ test(S(), S("12345678901234567890"), S("12345678901234567890"));
+
+ test(S("12345"), S(), S("12345"));
+ test(S("12345"), S("12345"), S("1234512345"));
+ test(S("12345"), S("1234567890"), S("123451234567890"));
+ test(S("12345"), S("12345678901234567890"), S("1234512345678901234567890"));
+
+ test(S("1234567890"), S(), S("1234567890"));
+ test(S("1234567890"), S("12345"), S("123456789012345"));
+ test(S("1234567890"), S("1234567890"), S("12345678901234567890"));
+ test(S("1234567890"), S("12345678901234567890"), S("123456789012345678901234567890"));
+
+ test(S("12345678901234567890"), S(), S("12345678901234567890"));
+ test(S("12345678901234567890"), S("12345"), S("1234567890123456789012345"));
+ test(S("12345678901234567890"), S("1234567890"), S("123456789012345678901234567890"));
+ test(S("12345678901234567890"), S("12345678901234567890"),
+ S("1234567890123456789012345678901234567890"));
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_initializer_list.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_initializer_list.pass.cpp
new file mode 100644
index 000000000000..20455b258c0a
--- /dev/null
+++ b/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_initializer_list.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string& replace(const_iterator i1, const_iterator i2, initializer_list<charT> il);
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ std::string s("123def456");
+ s.replace(s.cbegin() + 3, s.cbegin() + 6, {'a', 'b', 'c'});
+ assert(s == "123abc456");
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ S s("123def456");
+ s.replace(s.cbegin() + 3, s.cbegin() + 6, {'a', 'b', 'c'});
+ assert(s == "123abc456");
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_iter_iter.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_iter_iter.pass.cpp
new file mode 100644
index 000000000000..9295c5bde9fa
--- /dev/null
+++ b/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_iter_iter.pass.cpp
@@ -0,0 +1,976 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class InputIterator>
+// basic_string&
+// replace(const_iterator i1, const_iterator i2, InputIterator j1, InputIterator j2);
+
+#include <string>
+#include <iterator>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S, class It>
+void
+test(S s, typename S::size_type pos1, typename S::size_type n1, It f, It l, S expected)
+{
+ typename S::size_type old_size = s.size();
+ typename S::const_iterator first = s.begin() + pos1;
+ typename S::const_iterator last = s.begin() + pos1 + n1;
+ typename S::size_type xlen = last - first;
+ s.replace(first, last, f, l);
+ assert(s.__invariants());
+ assert(s == expected);
+ typename S::size_type rlen = std::distance(f, l);
+ assert(s.size() == old_size - xlen + rlen);
+}
+
+const char* str = "12345678901234567890";
+
+template <class S>
+void test0()
+{
+ test(S(""), 0, 0, str, str+0, S(""));
+ test(S(""), 0, 0, str, str+0, S(""));
+ test(S(""), 0, 0, str, str+1, S("1"));
+ test(S(""), 0, 0, str, str+2, S("12"));
+ test(S(""), 0, 0, str, str+4, S("1234"));
+ test(S(""), 0, 0, str, str+5, S("12345"));
+ test(S(""), 0, 0, str, str+0, S(""));
+ test(S(""), 0, 0, str, str+1, S("1"));
+ test(S(""), 0, 0, str, str+5, S("12345"));
+ test(S(""), 0, 0, str, str+9, S("123456789"));
+ test(S(""), 0, 0, str, str+10, S("1234567890"));
+ test(S(""), 0, 0, str, str+0, S(""));
+ test(S(""), 0, 0, str, str+1, S("1"));
+ test(S(""), 0, 0, str, str+10, S("1234567890"));
+ test(S(""), 0, 0, str, str+19, S("1234567890123456789"));
+ test(S(""), 0, 0, str, str+20, S("12345678901234567890"));
+ test(S("abcde"), 0, 0, str, str+0, S("abcde"));
+ test(S("abcde"), 0, 0, str, str+0, S("abcde"));
+ test(S("abcde"), 0, 0, str, str+1, S("1abcde"));
+ test(S("abcde"), 0, 0, str, str+2, S("12abcde"));
+ test(S("abcde"), 0, 0, str, str+4, S("1234abcde"));
+ test(S("abcde"), 0, 0, str, str+5, S("12345abcde"));
+ test(S("abcde"), 0, 0, str, str+0, S("abcde"));
+ test(S("abcde"), 0, 0, str, str+1, S("1abcde"));
+ test(S("abcde"), 0, 0, str, str+5, S("12345abcde"));
+ test(S("abcde"), 0, 0, str, str+9, S("123456789abcde"));
+ test(S("abcde"), 0, 0, str, str+10, S("1234567890abcde"));
+ test(S("abcde"), 0, 0, str, str+0, S("abcde"));
+ test(S("abcde"), 0, 0, str, str+1, S("1abcde"));
+ test(S("abcde"), 0, 0, str, str+10, S("1234567890abcde"));
+ test(S("abcde"), 0, 0, str, str+19, S("1234567890123456789abcde"));
+ test(S("abcde"), 0, 0, str, str+20, S("12345678901234567890abcde"));
+ test(S("abcde"), 0, 1, str, str+0, S("bcde"));
+ test(S("abcde"), 0, 1, str, str+0, S("bcde"));
+ test(S("abcde"), 0, 1, str, str+1, S("1bcde"));
+ test(S("abcde"), 0, 1, str, str+2, S("12bcde"));
+ test(S("abcde"), 0, 1, str, str+4, S("1234bcde"));
+ test(S("abcde"), 0, 1, str, str+5, S("12345bcde"));
+ test(S("abcde"), 0, 1, str, str+0, S("bcde"));
+ test(S("abcde"), 0, 1, str, str+1, S("1bcde"));
+ test(S("abcde"), 0, 1, str, str+5, S("12345bcde"));
+ test(S("abcde"), 0, 1, str, str+9, S("123456789bcde"));
+ test(S("abcde"), 0, 1, str, str+10, S("1234567890bcde"));
+ test(S("abcde"), 0, 1, str, str+0, S("bcde"));
+ test(S("abcde"), 0, 1, str, str+1, S("1bcde"));
+ test(S("abcde"), 0, 1, str, str+10, S("1234567890bcde"));
+ test(S("abcde"), 0, 1, str, str+19, S("1234567890123456789bcde"));
+ test(S("abcde"), 0, 1, str, str+20, S("12345678901234567890bcde"));
+ test(S("abcde"), 0, 2, str, str+0, S("cde"));
+ test(S("abcde"), 0, 2, str, str+0, S("cde"));
+ test(S("abcde"), 0, 2, str, str+1, S("1cde"));
+ test(S("abcde"), 0, 2, str, str+2, S("12cde"));
+ test(S("abcde"), 0, 2, str, str+4, S("1234cde"));
+ test(S("abcde"), 0, 2, str, str+5, S("12345cde"));
+ test(S("abcde"), 0, 2, str, str+0, S("cde"));
+ test(S("abcde"), 0, 2, str, str+1, S("1cde"));
+ test(S("abcde"), 0, 2, str, str+5, S("12345cde"));
+ test(S("abcde"), 0, 2, str, str+9, S("123456789cde"));
+ test(S("abcde"), 0, 2, str, str+10, S("1234567890cde"));
+ test(S("abcde"), 0, 2, str, str+0, S("cde"));
+ test(S("abcde"), 0, 2, str, str+1, S("1cde"));
+ test(S("abcde"), 0, 2, str, str+10, S("1234567890cde"));
+ test(S("abcde"), 0, 2, str, str+19, S("1234567890123456789cde"));
+ test(S("abcde"), 0, 2, str, str+20, S("12345678901234567890cde"));
+ test(S("abcde"), 0, 4, str, str+0, S("e"));
+ test(S("abcde"), 0, 4, str, str+0, S("e"));
+ test(S("abcde"), 0, 4, str, str+1, S("1e"));
+ test(S("abcde"), 0, 4, str, str+2, S("12e"));
+ test(S("abcde"), 0, 4, str, str+4, S("1234e"));
+ test(S("abcde"), 0, 4, str, str+5, S("12345e"));
+ test(S("abcde"), 0, 4, str, str+0, S("e"));
+ test(S("abcde"), 0, 4, str, str+1, S("1e"));
+ test(S("abcde"), 0, 4, str, str+5, S("12345e"));
+ test(S("abcde"), 0, 4, str, str+9, S("123456789e"));
+ test(S("abcde"), 0, 4, str, str+10, S("1234567890e"));
+ test(S("abcde"), 0, 4, str, str+0, S("e"));
+ test(S("abcde"), 0, 4, str, str+1, S("1e"));
+ test(S("abcde"), 0, 4, str, str+10, S("1234567890e"));
+ test(S("abcde"), 0, 4, str, str+19, S("1234567890123456789e"));
+ test(S("abcde"), 0, 4, str, str+20, S("12345678901234567890e"));
+ test(S("abcde"), 0, 5, str, str+0, S(""));
+ test(S("abcde"), 0, 5, str, str+0, S(""));
+ test(S("abcde"), 0, 5, str, str+1, S("1"));
+ test(S("abcde"), 0, 5, str, str+2, S("12"));
+ test(S("abcde"), 0, 5, str, str+4, S("1234"));
+ test(S("abcde"), 0, 5, str, str+5, S("12345"));
+ test(S("abcde"), 0, 5, str, str+0, S(""));
+ test(S("abcde"), 0, 5, str, str+1, S("1"));
+ test(S("abcde"), 0, 5, str, str+5, S("12345"));
+ test(S("abcde"), 0, 5, str, str+9, S("123456789"));
+ test(S("abcde"), 0, 5, str, str+10, S("1234567890"));
+ test(S("abcde"), 0, 5, str, str+0, S(""));
+ test(S("abcde"), 0, 5, str, str+1, S("1"));
+ test(S("abcde"), 0, 5, str, str+10, S("1234567890"));
+ test(S("abcde"), 0, 5, str, str+19, S("1234567890123456789"));
+ test(S("abcde"), 0, 5, str, str+20, S("12345678901234567890"));
+ test(S("abcde"), 1, 0, str, str+0, S("abcde"));
+ test(S("abcde"), 1, 0, str, str+0, S("abcde"));
+ test(S("abcde"), 1, 0, str, str+1, S("a1bcde"));
+ test(S("abcde"), 1, 0, str, str+2, S("a12bcde"));
+}
+
+template <class S>
+void test1()
+{
+ test(S("abcde"), 1, 0, str, str+4, S("a1234bcde"));
+ test(S("abcde"), 1, 0, str, str+5, S("a12345bcde"));
+ test(S("abcde"), 1, 0, str, str+0, S("abcde"));
+ test(S("abcde"), 1, 0, str, str+1, S("a1bcde"));
+ test(S("abcde"), 1, 0, str, str+5, S("a12345bcde"));
+ test(S("abcde"), 1, 0, str, str+9, S("a123456789bcde"));
+ test(S("abcde"), 1, 0, str, str+10, S("a1234567890bcde"));
+ test(S("abcde"), 1, 0, str, str+0, S("abcde"));
+ test(S("abcde"), 1, 0, str, str+1, S("a1bcde"));
+ test(S("abcde"), 1, 0, str, str+10, S("a1234567890bcde"));
+ test(S("abcde"), 1, 0, str, str+19, S("a1234567890123456789bcde"));
+ test(S("abcde"), 1, 0, str, str+20, S("a12345678901234567890bcde"));
+ test(S("abcde"), 1, 1, str, str+0, S("acde"));
+ test(S("abcde"), 1, 1, str, str+0, S("acde"));
+ test(S("abcde"), 1, 1, str, str+1, S("a1cde"));
+ test(S("abcde"), 1, 1, str, str+2, S("a12cde"));
+ test(S("abcde"), 1, 1, str, str+4, S("a1234cde"));
+ test(S("abcde"), 1, 1, str, str+5, S("a12345cde"));
+ test(S("abcde"), 1, 1, str, str+0, S("acde"));
+ test(S("abcde"), 1, 1, str, str+1, S("a1cde"));
+ test(S("abcde"), 1, 1, str, str+5, S("a12345cde"));
+ test(S("abcde"), 1, 1, str, str+9, S("a123456789cde"));
+ test(S("abcde"), 1, 1, str, str+10, S("a1234567890cde"));
+ test(S("abcde"), 1, 1, str, str+0, S("acde"));
+ test(S("abcde"), 1, 1, str, str+1, S("a1cde"));
+ test(S("abcde"), 1, 1, str, str+10, S("a1234567890cde"));
+ test(S("abcde"), 1, 1, str, str+19, S("a1234567890123456789cde"));
+ test(S("abcde"), 1, 1, str, str+20, S("a12345678901234567890cde"));
+ test(S("abcde"), 1, 2, str, str+0, S("ade"));
+ test(S("abcde"), 1, 2, str, str+0, S("ade"));
+ test(S("abcde"), 1, 2, str, str+1, S("a1de"));
+ test(S("abcde"), 1, 2, str, str+2, S("a12de"));
+ test(S("abcde"), 1, 2, str, str+4, S("a1234de"));
+ test(S("abcde"), 1, 2, str, str+5, S("a12345de"));
+ test(S("abcde"), 1, 2, str, str+0, S("ade"));
+ test(S("abcde"), 1, 2, str, str+1, S("a1de"));
+ test(S("abcde"), 1, 2, str, str+5, S("a12345de"));
+ test(S("abcde"), 1, 2, str, str+9, S("a123456789de"));
+ test(S("abcde"), 1, 2, str, str+10, S("a1234567890de"));
+ test(S("abcde"), 1, 2, str, str+0, S("ade"));
+ test(S("abcde"), 1, 2, str, str+1, S("a1de"));
+ test(S("abcde"), 1, 2, str, str+10, S("a1234567890de"));
+ test(S("abcde"), 1, 2, str, str+19, S("a1234567890123456789de"));
+ test(S("abcde"), 1, 2, str, str+20, S("a12345678901234567890de"));
+ test(S("abcde"), 1, 3, str, str+0, S("ae"));
+ test(S("abcde"), 1, 3, str, str+0, S("ae"));
+ test(S("abcde"), 1, 3, str, str+1, S("a1e"));
+ test(S("abcde"), 1, 3, str, str+2, S("a12e"));
+ test(S("abcde"), 1, 3, str, str+4, S("a1234e"));
+ test(S("abcde"), 1, 3, str, str+5, S("a12345e"));
+ test(S("abcde"), 1, 3, str, str+0, S("ae"));
+ test(S("abcde"), 1, 3, str, str+1, S("a1e"));
+ test(S("abcde"), 1, 3, str, str+5, S("a12345e"));
+ test(S("abcde"), 1, 3, str, str+9, S("a123456789e"));
+ test(S("abcde"), 1, 3, str, str+10, S("a1234567890e"));
+ test(S("abcde"), 1, 3, str, str+0, S("ae"));
+ test(S("abcde"), 1, 3, str, str+1, S("a1e"));
+ test(S("abcde"), 1, 3, str, str+10, S("a1234567890e"));
+ test(S("abcde"), 1, 3, str, str+19, S("a1234567890123456789e"));
+ test(S("abcde"), 1, 3, str, str+20, S("a12345678901234567890e"));
+ test(S("abcde"), 1, 4, str, str+0, S("a"));
+ test(S("abcde"), 1, 4, str, str+0, S("a"));
+ test(S("abcde"), 1, 4, str, str+1, S("a1"));
+ test(S("abcde"), 1, 4, str, str+2, S("a12"));
+ test(S("abcde"), 1, 4, str, str+4, S("a1234"));
+ test(S("abcde"), 1, 4, str, str+5, S("a12345"));
+ test(S("abcde"), 1, 4, str, str+0, S("a"));
+ test(S("abcde"), 1, 4, str, str+1, S("a1"));
+ test(S("abcde"), 1, 4, str, str+5, S("a12345"));
+ test(S("abcde"), 1, 4, str, str+9, S("a123456789"));
+ test(S("abcde"), 1, 4, str, str+10, S("a1234567890"));
+ test(S("abcde"), 1, 4, str, str+0, S("a"));
+ test(S("abcde"), 1, 4, str, str+1, S("a1"));
+ test(S("abcde"), 1, 4, str, str+10, S("a1234567890"));
+ test(S("abcde"), 1, 4, str, str+19, S("a1234567890123456789"));
+ test(S("abcde"), 1, 4, str, str+20, S("a12345678901234567890"));
+ test(S("abcde"), 2, 0, str, str+0, S("abcde"));
+ test(S("abcde"), 2, 0, str, str+0, S("abcde"));
+ test(S("abcde"), 2, 0, str, str+1, S("ab1cde"));
+ test(S("abcde"), 2, 0, str, str+2, S("ab12cde"));
+ test(S("abcde"), 2, 0, str, str+4, S("ab1234cde"));
+ test(S("abcde"), 2, 0, str, str+5, S("ab12345cde"));
+ test(S("abcde"), 2, 0, str, str+0, S("abcde"));
+ test(S("abcde"), 2, 0, str, str+1, S("ab1cde"));
+ test(S("abcde"), 2, 0, str, str+5, S("ab12345cde"));
+ test(S("abcde"), 2, 0, str, str+9, S("ab123456789cde"));
+ test(S("abcde"), 2, 0, str, str+10, S("ab1234567890cde"));
+ test(S("abcde"), 2, 0, str, str+0, S("abcde"));
+ test(S("abcde"), 2, 0, str, str+1, S("ab1cde"));
+ test(S("abcde"), 2, 0, str, str+10, S("ab1234567890cde"));
+ test(S("abcde"), 2, 0, str, str+19, S("ab1234567890123456789cde"));
+ test(S("abcde"), 2, 0, str, str+20, S("ab12345678901234567890cde"));
+ test(S("abcde"), 2, 1, str, str+0, S("abde"));
+ test(S("abcde"), 2, 1, str, str+0, S("abde"));
+ test(S("abcde"), 2, 1, str, str+1, S("ab1de"));
+ test(S("abcde"), 2, 1, str, str+2, S("ab12de"));
+ test(S("abcde"), 2, 1, str, str+4, S("ab1234de"));
+ test(S("abcde"), 2, 1, str, str+5, S("ab12345de"));
+ test(S("abcde"), 2, 1, str, str+0, S("abde"));
+ test(S("abcde"), 2, 1, str, str+1, S("ab1de"));
+}
+
+template <class S>
+void test2()
+{
+ test(S("abcde"), 2, 1, str, str+5, S("ab12345de"));
+ test(S("abcde"), 2, 1, str, str+9, S("ab123456789de"));
+ test(S("abcde"), 2, 1, str, str+10, S("ab1234567890de"));
+ test(S("abcde"), 2, 1, str, str+0, S("abde"));
+ test(S("abcde"), 2, 1, str, str+1, S("ab1de"));
+ test(S("abcde"), 2, 1, str, str+10, S("ab1234567890de"));
+ test(S("abcde"), 2, 1, str, str+19, S("ab1234567890123456789de"));
+ test(S("abcde"), 2, 1, str, str+20, S("ab12345678901234567890de"));
+ test(S("abcde"), 2, 2, str, str+0, S("abe"));
+ test(S("abcde"), 2, 2, str, str+0, S("abe"));
+ test(S("abcde"), 2, 2, str, str+1, S("ab1e"));
+ test(S("abcde"), 2, 2, str, str+2, S("ab12e"));
+ test(S("abcde"), 2, 2, str, str+4, S("ab1234e"));
+ test(S("abcde"), 2, 2, str, str+5, S("ab12345e"));
+ test(S("abcde"), 2, 2, str, str+0, S("abe"));
+ test(S("abcde"), 2, 2, str, str+1, S("ab1e"));
+ test(S("abcde"), 2, 2, str, str+5, S("ab12345e"));
+ test(S("abcde"), 2, 2, str, str+9, S("ab123456789e"));
+ test(S("abcde"), 2, 2, str, str+10, S("ab1234567890e"));
+ test(S("abcde"), 2, 2, str, str+0, S("abe"));
+ test(S("abcde"), 2, 2, str, str+1, S("ab1e"));
+ test(S("abcde"), 2, 2, str, str+10, S("ab1234567890e"));
+ test(S("abcde"), 2, 2, str, str+19, S("ab1234567890123456789e"));
+ test(S("abcde"), 2, 2, str, str+20, S("ab12345678901234567890e"));
+ test(S("abcde"), 2, 3, str, str+0, S("ab"));
+ test(S("abcde"), 2, 3, str, str+0, S("ab"));
+ test(S("abcde"), 2, 3, str, str+1, S("ab1"));
+ test(S("abcde"), 2, 3, str, str+2, S("ab12"));
+ test(S("abcde"), 2, 3, str, str+4, S("ab1234"));
+ test(S("abcde"), 2, 3, str, str+5, S("ab12345"));
+ test(S("abcde"), 2, 3, str, str+0, S("ab"));
+ test(S("abcde"), 2, 3, str, str+1, S("ab1"));
+ test(S("abcde"), 2, 3, str, str+5, S("ab12345"));
+ test(S("abcde"), 2, 3, str, str+9, S("ab123456789"));
+ test(S("abcde"), 2, 3, str, str+10, S("ab1234567890"));
+ test(S("abcde"), 2, 3, str, str+0, S("ab"));
+ test(S("abcde"), 2, 3, str, str+1, S("ab1"));
+ test(S("abcde"), 2, 3, str, str+10, S("ab1234567890"));
+ test(S("abcde"), 2, 3, str, str+19, S("ab1234567890123456789"));
+ test(S("abcde"), 2, 3, str, str+20, S("ab12345678901234567890"));
+ test(S("abcde"), 4, 0, str, str+0, S("abcde"));
+ test(S("abcde"), 4, 0, str, str+0, S("abcde"));
+ test(S("abcde"), 4, 0, str, str+1, S("abcd1e"));
+ test(S("abcde"), 4, 0, str, str+2, S("abcd12e"));
+ test(S("abcde"), 4, 0, str, str+4, S("abcd1234e"));
+ test(S("abcde"), 4, 0, str, str+5, S("abcd12345e"));
+ test(S("abcde"), 4, 0, str, str+0, S("abcde"));
+ test(S("abcde"), 4, 0, str, str+1, S("abcd1e"));
+ test(S("abcde"), 4, 0, str, str+5, S("abcd12345e"));
+ test(S("abcde"), 4, 0, str, str+9, S("abcd123456789e"));
+ test(S("abcde"), 4, 0, str, str+10, S("abcd1234567890e"));
+ test(S("abcde"), 4, 0, str, str+0, S("abcde"));
+ test(S("abcde"), 4, 0, str, str+1, S("abcd1e"));
+ test(S("abcde"), 4, 0, str, str+10, S("abcd1234567890e"));
+ test(S("abcde"), 4, 0, str, str+19, S("abcd1234567890123456789e"));
+ test(S("abcde"), 4, 0, str, str+20, S("abcd12345678901234567890e"));
+ test(S("abcde"), 4, 1, str, str+0, S("abcd"));
+ test(S("abcde"), 4, 1, str, str+0, S("abcd"));
+ test(S("abcde"), 4, 1, str, str+1, S("abcd1"));
+ test(S("abcde"), 4, 1, str, str+2, S("abcd12"));
+ test(S("abcde"), 4, 1, str, str+4, S("abcd1234"));
+ test(S("abcde"), 4, 1, str, str+5, S("abcd12345"));
+ test(S("abcde"), 4, 1, str, str+0, S("abcd"));
+ test(S("abcde"), 4, 1, str, str+1, S("abcd1"));
+ test(S("abcde"), 4, 1, str, str+5, S("abcd12345"));
+ test(S("abcde"), 4, 1, str, str+9, S("abcd123456789"));
+ test(S("abcde"), 4, 1, str, str+10, S("abcd1234567890"));
+ test(S("abcde"), 4, 1, str, str+0, S("abcd"));
+ test(S("abcde"), 4, 1, str, str+1, S("abcd1"));
+ test(S("abcde"), 4, 1, str, str+10, S("abcd1234567890"));
+ test(S("abcde"), 4, 1, str, str+19, S("abcd1234567890123456789"));
+ test(S("abcde"), 4, 1, str, str+20, S("abcd12345678901234567890"));
+ test(S("abcde"), 5, 0, str, str+0, S("abcde"));
+ test(S("abcde"), 5, 0, str, str+0, S("abcde"));
+ test(S("abcde"), 5, 0, str, str+1, S("abcde1"));
+ test(S("abcde"), 5, 0, str, str+2, S("abcde12"));
+ test(S("abcde"), 5, 0, str, str+4, S("abcde1234"));
+ test(S("abcde"), 5, 0, str, str+5, S("abcde12345"));
+ test(S("abcde"), 5, 0, str, str+0, S("abcde"));
+ test(S("abcde"), 5, 0, str, str+1, S("abcde1"));
+ test(S("abcde"), 5, 0, str, str+5, S("abcde12345"));
+ test(S("abcde"), 5, 0, str, str+9, S("abcde123456789"));
+ test(S("abcde"), 5, 0, str, str+10, S("abcde1234567890"));
+ test(S("abcde"), 5, 0, str, str+0, S("abcde"));
+ test(S("abcde"), 5, 0, str, str+1, S("abcde1"));
+ test(S("abcde"), 5, 0, str, str+10, S("abcde1234567890"));
+ test(S("abcde"), 5, 0, str, str+19, S("abcde1234567890123456789"));
+ test(S("abcde"), 5, 0, str, str+20, S("abcde12345678901234567890"));
+ test(S("abcdefghij"), 0, 0, str, str+0, S("abcdefghij"));
+ test(S("abcdefghij"), 0, 0, str, str+0, S("abcdefghij"));
+ test(S("abcdefghij"), 0, 0, str, str+1, S("1abcdefghij"));
+ test(S("abcdefghij"), 0, 0, str, str+2, S("12abcdefghij"));
+ test(S("abcdefghij"), 0, 0, str, str+4, S("1234abcdefghij"));
+ test(S("abcdefghij"), 0, 0, str, str+5, S("12345abcdefghij"));
+ test(S("abcdefghij"), 0, 0, str, str+0, S("abcdefghij"));
+ test(S("abcdefghij"), 0, 0, str, str+1, S("1abcdefghij"));
+ test(S("abcdefghij"), 0, 0, str, str+5, S("12345abcdefghij"));
+ test(S("abcdefghij"), 0, 0, str, str+9, S("123456789abcdefghij"));
+ test(S("abcdefghij"), 0, 0, str, str+10, S("1234567890abcdefghij"));
+ test(S("abcdefghij"), 0, 0, str, str+0, S("abcdefghij"));
+}
+
+template <class S>
+void test3()
+{
+ test(S("abcdefghij"), 0, 0, str, str+1, S("1abcdefghij"));
+ test(S("abcdefghij"), 0, 0, str, str+10, S("1234567890abcdefghij"));
+ test(S("abcdefghij"), 0, 0, str, str+19, S("1234567890123456789abcdefghij"));
+ test(S("abcdefghij"), 0, 0, str, str+20, S("12345678901234567890abcdefghij"));
+ test(S("abcdefghij"), 0, 1, str, str+0, S("bcdefghij"));
+ test(S("abcdefghij"), 0, 1, str, str+0, S("bcdefghij"));
+ test(S("abcdefghij"), 0, 1, str, str+1, S("1bcdefghij"));
+ test(S("abcdefghij"), 0, 1, str, str+2, S("12bcdefghij"));
+ test(S("abcdefghij"), 0, 1, str, str+4, S("1234bcdefghij"));
+ test(S("abcdefghij"), 0, 1, str, str+5, S("12345bcdefghij"));
+ test(S("abcdefghij"), 0, 1, str, str+0, S("bcdefghij"));
+ test(S("abcdefghij"), 0, 1, str, str+1, S("1bcdefghij"));
+ test(S("abcdefghij"), 0, 1, str, str+5, S("12345bcdefghij"));
+ test(S("abcdefghij"), 0, 1, str, str+9, S("123456789bcdefghij"));
+ test(S("abcdefghij"), 0, 1, str, str+10, S("1234567890bcdefghij"));
+ test(S("abcdefghij"), 0, 1, str, str+0, S("bcdefghij"));
+ test(S("abcdefghij"), 0, 1, str, str+1, S("1bcdefghij"));
+ test(S("abcdefghij"), 0, 1, str, str+10, S("1234567890bcdefghij"));
+ test(S("abcdefghij"), 0, 1, str, str+19, S("1234567890123456789bcdefghij"));
+ test(S("abcdefghij"), 0, 1, str, str+20, S("12345678901234567890bcdefghij"));
+ test(S("abcdefghij"), 0, 5, str, str+0, S("fghij"));
+ test(S("abcdefghij"), 0, 5, str, str+0, S("fghij"));
+ test(S("abcdefghij"), 0, 5, str, str+1, S("1fghij"));
+ test(S("abcdefghij"), 0, 5, str, str+2, S("12fghij"));
+ test(S("abcdefghij"), 0, 5, str, str+4, S("1234fghij"));
+ test(S("abcdefghij"), 0, 5, str, str+5, S("12345fghij"));
+ test(S("abcdefghij"), 0, 5, str, str+0, S("fghij"));
+ test(S("abcdefghij"), 0, 5, str, str+1, S("1fghij"));
+ test(S("abcdefghij"), 0, 5, str, str+5, S("12345fghij"));
+ test(S("abcdefghij"), 0, 5, str, str+9, S("123456789fghij"));
+ test(S("abcdefghij"), 0, 5, str, str+10, S("1234567890fghij"));
+ test(S("abcdefghij"), 0, 5, str, str+0, S("fghij"));
+ test(S("abcdefghij"), 0, 5, str, str+1, S("1fghij"));
+ test(S("abcdefghij"), 0, 5, str, str+10, S("1234567890fghij"));
+ test(S("abcdefghij"), 0, 5, str, str+19, S("1234567890123456789fghij"));
+ test(S("abcdefghij"), 0, 5, str, str+20, S("12345678901234567890fghij"));
+ test(S("abcdefghij"), 0, 9, str, str+0, S("j"));
+ test(S("abcdefghij"), 0, 9, str, str+0, S("j"));
+ test(S("abcdefghij"), 0, 9, str, str+1, S("1j"));
+ test(S("abcdefghij"), 0, 9, str, str+2, S("12j"));
+ test(S("abcdefghij"), 0, 9, str, str+4, S("1234j"));
+ test(S("abcdefghij"), 0, 9, str, str+5, S("12345j"));
+ test(S("abcdefghij"), 0, 9, str, str+0, S("j"));
+ test(S("abcdefghij"), 0, 9, str, str+1, S("1j"));
+ test(S("abcdefghij"), 0, 9, str, str+5, S("12345j"));
+ test(S("abcdefghij"), 0, 9, str, str+9, S("123456789j"));
+ test(S("abcdefghij"), 0, 9, str, str+10, S("1234567890j"));
+ test(S("abcdefghij"), 0, 9, str, str+0, S("j"));
+ test(S("abcdefghij"), 0, 9, str, str+1, S("1j"));
+ test(S("abcdefghij"), 0, 9, str, str+10, S("1234567890j"));
+ test(S("abcdefghij"), 0, 9, str, str+19, S("1234567890123456789j"));
+ test(S("abcdefghij"), 0, 9, str, str+20, S("12345678901234567890j"));
+ test(S("abcdefghij"), 0, 10, str, str+0, S(""));
+ test(S("abcdefghij"), 0, 10, str, str+0, S(""));
+ test(S("abcdefghij"), 0, 10, str, str+1, S("1"));
+ test(S("abcdefghij"), 0, 10, str, str+2, S("12"));
+ test(S("abcdefghij"), 0, 10, str, str+4, S("1234"));
+ test(S("abcdefghij"), 0, 10, str, str+5, S("12345"));
+ test(S("abcdefghij"), 0, 10, str, str+0, S(""));
+ test(S("abcdefghij"), 0, 10, str, str+1, S("1"));
+ test(S("abcdefghij"), 0, 10, str, str+5, S("12345"));
+ test(S("abcdefghij"), 0, 10, str, str+9, S("123456789"));
+ test(S("abcdefghij"), 0, 10, str, str+10, S("1234567890"));
+ test(S("abcdefghij"), 0, 10, str, str+0, S(""));
+ test(S("abcdefghij"), 0, 10, str, str+1, S("1"));
+ test(S("abcdefghij"), 0, 10, str, str+10, S("1234567890"));
+ test(S("abcdefghij"), 0, 10, str, str+19, S("1234567890123456789"));
+ test(S("abcdefghij"), 0, 10, str, str+20, S("12345678901234567890"));
+ test(S("abcdefghij"), 1, 0, str, str+0, S("abcdefghij"));
+ test(S("abcdefghij"), 1, 0, str, str+0, S("abcdefghij"));
+ test(S("abcdefghij"), 1, 0, str, str+1, S("a1bcdefghij"));
+ test(S("abcdefghij"), 1, 0, str, str+2, S("a12bcdefghij"));
+ test(S("abcdefghij"), 1, 0, str, str+4, S("a1234bcdefghij"));
+ test(S("abcdefghij"), 1, 0, str, str+5, S("a12345bcdefghij"));
+ test(S("abcdefghij"), 1, 0, str, str+0, S("abcdefghij"));
+ test(S("abcdefghij"), 1, 0, str, str+1, S("a1bcdefghij"));
+ test(S("abcdefghij"), 1, 0, str, str+5, S("a12345bcdefghij"));
+ test(S("abcdefghij"), 1, 0, str, str+9, S("a123456789bcdefghij"));
+ test(S("abcdefghij"), 1, 0, str, str+10, S("a1234567890bcdefghij"));
+ test(S("abcdefghij"), 1, 0, str, str+0, S("abcdefghij"));
+ test(S("abcdefghij"), 1, 0, str, str+1, S("a1bcdefghij"));
+ test(S("abcdefghij"), 1, 0, str, str+10, S("a1234567890bcdefghij"));
+ test(S("abcdefghij"), 1, 0, str, str+19, S("a1234567890123456789bcdefghij"));
+ test(S("abcdefghij"), 1, 0, str, str+20, S("a12345678901234567890bcdefghij"));
+ test(S("abcdefghij"), 1, 1, str, str+0, S("acdefghij"));
+ test(S("abcdefghij"), 1, 1, str, str+0, S("acdefghij"));
+ test(S("abcdefghij"), 1, 1, str, str+1, S("a1cdefghij"));
+ test(S("abcdefghij"), 1, 1, str, str+2, S("a12cdefghij"));
+ test(S("abcdefghij"), 1, 1, str, str+4, S("a1234cdefghij"));
+ test(S("abcdefghij"), 1, 1, str, str+5, S("a12345cdefghij"));
+ test(S("abcdefghij"), 1, 1, str, str+0, S("acdefghij"));
+ test(S("abcdefghij"), 1, 1, str, str+1, S("a1cdefghij"));
+ test(S("abcdefghij"), 1, 1, str, str+5, S("a12345cdefghij"));
+ test(S("abcdefghij"), 1, 1, str, str+9, S("a123456789cdefghij"));
+ test(S("abcdefghij"), 1, 1, str, str+10, S("a1234567890cdefghij"));
+ test(S("abcdefghij"), 1, 1, str, str+0, S("acdefghij"));
+ test(S("abcdefghij"), 1, 1, str, str+1, S("a1cdefghij"));
+ test(S("abcdefghij"), 1, 1, str, str+10, S("a1234567890cdefghij"));
+ test(S("abcdefghij"), 1, 1, str, str+19, S("a1234567890123456789cdefghij"));
+ test(S("abcdefghij"), 1, 1, str, str+20, S("a12345678901234567890cdefghij"));
+}
+
+template <class S>
+void test4()
+{
+ test(S("abcdefghij"), 1, 4, str, str+0, S("afghij"));
+ test(S("abcdefghij"), 1, 4, str, str+0, S("afghij"));
+ test(S("abcdefghij"), 1, 4, str, str+1, S("a1fghij"));
+ test(S("abcdefghij"), 1, 4, str, str+2, S("a12fghij"));
+ test(S("abcdefghij"), 1, 4, str, str+4, S("a1234fghij"));
+ test(S("abcdefghij"), 1, 4, str, str+5, S("a12345fghij"));
+ test(S("abcdefghij"), 1, 4, str, str+0, S("afghij"));
+ test(S("abcdefghij"), 1, 4, str, str+1, S("a1fghij"));
+ test(S("abcdefghij"), 1, 4, str, str+5, S("a12345fghij"));
+ test(S("abcdefghij"), 1, 4, str, str+9, S("a123456789fghij"));
+ test(S("abcdefghij"), 1, 4, str, str+10, S("a1234567890fghij"));
+ test(S("abcdefghij"), 1, 4, str, str+0, S("afghij"));
+ test(S("abcdefghij"), 1, 4, str, str+1, S("a1fghij"));
+ test(S("abcdefghij"), 1, 4, str, str+10, S("a1234567890fghij"));
+ test(S("abcdefghij"), 1, 4, str, str+19, S("a1234567890123456789fghij"));
+ test(S("abcdefghij"), 1, 4, str, str+20, S("a12345678901234567890fghij"));
+ test(S("abcdefghij"), 1, 8, str, str+0, S("aj"));
+ test(S("abcdefghij"), 1, 8, str, str+0, S("aj"));
+ test(S("abcdefghij"), 1, 8, str, str+1, S("a1j"));
+ test(S("abcdefghij"), 1, 8, str, str+2, S("a12j"));
+ test(S("abcdefghij"), 1, 8, str, str+4, S("a1234j"));
+ test(S("abcdefghij"), 1, 8, str, str+5, S("a12345j"));
+ test(S("abcdefghij"), 1, 8, str, str+0, S("aj"));
+ test(S("abcdefghij"), 1, 8, str, str+1, S("a1j"));
+ test(S("abcdefghij"), 1, 8, str, str+5, S("a12345j"));
+ test(S("abcdefghij"), 1, 8, str, str+9, S("a123456789j"));
+ test(S("abcdefghij"), 1, 8, str, str+10, S("a1234567890j"));
+ test(S("abcdefghij"), 1, 8, str, str+0, S("aj"));
+ test(S("abcdefghij"), 1, 8, str, str+1, S("a1j"));
+ test(S("abcdefghij"), 1, 8, str, str+10, S("a1234567890j"));
+ test(S("abcdefghij"), 1, 8, str, str+19, S("a1234567890123456789j"));
+ test(S("abcdefghij"), 1, 8, str, str+20, S("a12345678901234567890j"));
+ test(S("abcdefghij"), 1, 9, str, str+0, S("a"));
+ test(S("abcdefghij"), 1, 9, str, str+0, S("a"));
+ test(S("abcdefghij"), 1, 9, str, str+1, S("a1"));
+ test(S("abcdefghij"), 1, 9, str, str+2, S("a12"));
+ test(S("abcdefghij"), 1, 9, str, str+4, S("a1234"));
+ test(S("abcdefghij"), 1, 9, str, str+5, S("a12345"));
+ test(S("abcdefghij"), 1, 9, str, str+0, S("a"));
+ test(S("abcdefghij"), 1, 9, str, str+1, S("a1"));
+ test(S("abcdefghij"), 1, 9, str, str+5, S("a12345"));
+ test(S("abcdefghij"), 1, 9, str, str+9, S("a123456789"));
+ test(S("abcdefghij"), 1, 9, str, str+10, S("a1234567890"));
+ test(S("abcdefghij"), 1, 9, str, str+0, S("a"));
+ test(S("abcdefghij"), 1, 9, str, str+1, S("a1"));
+ test(S("abcdefghij"), 1, 9, str, str+10, S("a1234567890"));
+ test(S("abcdefghij"), 1, 9, str, str+19, S("a1234567890123456789"));
+ test(S("abcdefghij"), 1, 9, str, str+20, S("a12345678901234567890"));
+ test(S("abcdefghij"), 5, 0, str, str+0, S("abcdefghij"));
+ test(S("abcdefghij"), 5, 0, str, str+0, S("abcdefghij"));
+ test(S("abcdefghij"), 5, 0, str, str+1, S("abcde1fghij"));
+ test(S("abcdefghij"), 5, 0, str, str+2, S("abcde12fghij"));
+ test(S("abcdefghij"), 5, 0, str, str+4, S("abcde1234fghij"));
+ test(S("abcdefghij"), 5, 0, str, str+5, S("abcde12345fghij"));
+ test(S("abcdefghij"), 5, 0, str, str+0, S("abcdefghij"));
+ test(S("abcdefghij"), 5, 0, str, str+1, S("abcde1fghij"));
+ test(S("abcdefghij"), 5, 0, str, str+5, S("abcde12345fghij"));
+ test(S("abcdefghij"), 5, 0, str, str+9, S("abcde123456789fghij"));
+ test(S("abcdefghij"), 5, 0, str, str+10, S("abcde1234567890fghij"));
+ test(S("abcdefghij"), 5, 0, str, str+0, S("abcdefghij"));
+ test(S("abcdefghij"), 5, 0, str, str+1, S("abcde1fghij"));
+ test(S("abcdefghij"), 5, 0, str, str+10, S("abcde1234567890fghij"));
+ test(S("abcdefghij"), 5, 0, str, str+19, S("abcde1234567890123456789fghij"));
+ test(S("abcdefghij"), 5, 0, str, str+20, S("abcde12345678901234567890fghij"));
+ test(S("abcdefghij"), 5, 1, str, str+0, S("abcdeghij"));
+ test(S("abcdefghij"), 5, 1, str, str+0, S("abcdeghij"));
+ test(S("abcdefghij"), 5, 1, str, str+1, S("abcde1ghij"));
+ test(S("abcdefghij"), 5, 1, str, str+2, S("abcde12ghij"));
+ test(S("abcdefghij"), 5, 1, str, str+4, S("abcde1234ghij"));
+ test(S("abcdefghij"), 5, 1, str, str+5, S("abcde12345ghij"));
+ test(S("abcdefghij"), 5, 1, str, str+0, S("abcdeghij"));
+ test(S("abcdefghij"), 5, 1, str, str+1, S("abcde1ghij"));
+ test(S("abcdefghij"), 5, 1, str, str+5, S("abcde12345ghij"));
+ test(S("abcdefghij"), 5, 1, str, str+9, S("abcde123456789ghij"));
+ test(S("abcdefghij"), 5, 1, str, str+10, S("abcde1234567890ghij"));
+ test(S("abcdefghij"), 5, 1, str, str+0, S("abcdeghij"));
+ test(S("abcdefghij"), 5, 1, str, str+1, S("abcde1ghij"));
+ test(S("abcdefghij"), 5, 1, str, str+10, S("abcde1234567890ghij"));
+ test(S("abcdefghij"), 5, 1, str, str+19, S("abcde1234567890123456789ghij"));
+ test(S("abcdefghij"), 5, 1, str, str+20, S("abcde12345678901234567890ghij"));
+ test(S("abcdefghij"), 5, 2, str, str+0, S("abcdehij"));
+ test(S("abcdefghij"), 5, 2, str, str+0, S("abcdehij"));
+ test(S("abcdefghij"), 5, 2, str, str+1, S("abcde1hij"));
+ test(S("abcdefghij"), 5, 2, str, str+2, S("abcde12hij"));
+ test(S("abcdefghij"), 5, 2, str, str+4, S("abcde1234hij"));
+ test(S("abcdefghij"), 5, 2, str, str+5, S("abcde12345hij"));
+ test(S("abcdefghij"), 5, 2, str, str+0, S("abcdehij"));
+ test(S("abcdefghij"), 5, 2, str, str+1, S("abcde1hij"));
+ test(S("abcdefghij"), 5, 2, str, str+5, S("abcde12345hij"));
+ test(S("abcdefghij"), 5, 2, str, str+9, S("abcde123456789hij"));
+ test(S("abcdefghij"), 5, 2, str, str+10, S("abcde1234567890hij"));
+ test(S("abcdefghij"), 5, 2, str, str+0, S("abcdehij"));
+ test(S("abcdefghij"), 5, 2, str, str+1, S("abcde1hij"));
+ test(S("abcdefghij"), 5, 2, str, str+10, S("abcde1234567890hij"));
+ test(S("abcdefghij"), 5, 2, str, str+19, S("abcde1234567890123456789hij"));
+ test(S("abcdefghij"), 5, 2, str, str+20, S("abcde12345678901234567890hij"));
+ test(S("abcdefghij"), 5, 4, str, str+0, S("abcdej"));
+ test(S("abcdefghij"), 5, 4, str, str+0, S("abcdej"));
+ test(S("abcdefghij"), 5, 4, str, str+1, S("abcde1j"));
+ test(S("abcdefghij"), 5, 4, str, str+2, S("abcde12j"));
+}
+
+template <class S>
+void test5()
+{
+ test(S("abcdefghij"), 5, 4, str, str+4, S("abcde1234j"));
+ test(S("abcdefghij"), 5, 4, str, str+5, S("abcde12345j"));
+ test(S("abcdefghij"), 5, 4, str, str+0, S("abcdej"));
+ test(S("abcdefghij"), 5, 4, str, str+1, S("abcde1j"));
+ test(S("abcdefghij"), 5, 4, str, str+5, S("abcde12345j"));
+ test(S("abcdefghij"), 5, 4, str, str+9, S("abcde123456789j"));
+ test(S("abcdefghij"), 5, 4, str, str+10, S("abcde1234567890j"));
+ test(S("abcdefghij"), 5, 4, str, str+0, S("abcdej"));
+ test(S("abcdefghij"), 5, 4, str, str+1, S("abcde1j"));
+ test(S("abcdefghij"), 5, 4, str, str+10, S("abcde1234567890j"));
+ test(S("abcdefghij"), 5, 4, str, str+19, S("abcde1234567890123456789j"));
+ test(S("abcdefghij"), 5, 4, str, str+20, S("abcde12345678901234567890j"));
+ test(S("abcdefghij"), 5, 5, str, str+0, S("abcde"));
+ test(S("abcdefghij"), 5, 5, str, str+0, S("abcde"));
+ test(S("abcdefghij"), 5, 5, str, str+1, S("abcde1"));
+ test(S("abcdefghij"), 5, 5, str, str+2, S("abcde12"));
+ test(S("abcdefghij"), 5, 5, str, str+4, S("abcde1234"));
+ test(S("abcdefghij"), 5, 5, str, str+5, S("abcde12345"));
+ test(S("abcdefghij"), 5, 5, str, str+0, S("abcde"));
+ test(S("abcdefghij"), 5, 5, str, str+1, S("abcde1"));
+ test(S("abcdefghij"), 5, 5, str, str+5, S("abcde12345"));
+ test(S("abcdefghij"), 5, 5, str, str+9, S("abcde123456789"));
+ test(S("abcdefghij"), 5, 5, str, str+10, S("abcde1234567890"));
+ test(S("abcdefghij"), 5, 5, str, str+0, S("abcde"));
+ test(S("abcdefghij"), 5, 5, str, str+1, S("abcde1"));
+ test(S("abcdefghij"), 5, 5, str, str+10, S("abcde1234567890"));
+ test(S("abcdefghij"), 5, 5, str, str+19, S("abcde1234567890123456789"));
+ test(S("abcdefghij"), 5, 5, str, str+20, S("abcde12345678901234567890"));
+ test(S("abcdefghij"), 9, 0, str, str+0, S("abcdefghij"));
+ test(S("abcdefghij"), 9, 0, str, str+0, S("abcdefghij"));
+ test(S("abcdefghij"), 9, 0, str, str+1, S("abcdefghi1j"));
+ test(S("abcdefghij"), 9, 0, str, str+2, S("abcdefghi12j"));
+ test(S("abcdefghij"), 9, 0, str, str+4, S("abcdefghi1234j"));
+ test(S("abcdefghij"), 9, 0, str, str+5, S("abcdefghi12345j"));
+ test(S("abcdefghij"), 9, 0, str, str+0, S("abcdefghij"));
+ test(S("abcdefghij"), 9, 0, str, str+1, S("abcdefghi1j"));
+ test(S("abcdefghij"), 9, 0, str, str+5, S("abcdefghi12345j"));
+ test(S("abcdefghij"), 9, 0, str, str+9, S("abcdefghi123456789j"));
+ test(S("abcdefghij"), 9, 0, str, str+10, S("abcdefghi1234567890j"));
+ test(S("abcdefghij"), 9, 0, str, str+0, S("abcdefghij"));
+ test(S("abcdefghij"), 9, 0, str, str+1, S("abcdefghi1j"));
+ test(S("abcdefghij"), 9, 0, str, str+10, S("abcdefghi1234567890j"));
+ test(S("abcdefghij"), 9, 0, str, str+19, S("abcdefghi1234567890123456789j"));
+ test(S("abcdefghij"), 9, 0, str, str+20, S("abcdefghi12345678901234567890j"));
+ test(S("abcdefghij"), 9, 1, str, str+0, S("abcdefghi"));
+ test(S("abcdefghij"), 9, 1, str, str+0, S("abcdefghi"));
+ test(S("abcdefghij"), 9, 1, str, str+1, S("abcdefghi1"));
+ test(S("abcdefghij"), 9, 1, str, str+2, S("abcdefghi12"));
+ test(S("abcdefghij"), 9, 1, str, str+4, S("abcdefghi1234"));
+ test(S("abcdefghij"), 9, 1, str, str+5, S("abcdefghi12345"));
+ test(S("abcdefghij"), 9, 1, str, str+0, S("abcdefghi"));
+ test(S("abcdefghij"), 9, 1, str, str+1, S("abcdefghi1"));
+ test(S("abcdefghij"), 9, 1, str, str+5, S("abcdefghi12345"));
+ test(S("abcdefghij"), 9, 1, str, str+9, S("abcdefghi123456789"));
+ test(S("abcdefghij"), 9, 1, str, str+10, S("abcdefghi1234567890"));
+ test(S("abcdefghij"), 9, 1, str, str+0, S("abcdefghi"));
+ test(S("abcdefghij"), 9, 1, str, str+1, S("abcdefghi1"));
+ test(S("abcdefghij"), 9, 1, str, str+10, S("abcdefghi1234567890"));
+ test(S("abcdefghij"), 9, 1, str, str+19, S("abcdefghi1234567890123456789"));
+ test(S("abcdefghij"), 9, 1, str, str+20, S("abcdefghi12345678901234567890"));
+ test(S("abcdefghij"), 10, 0, str, str+0, S("abcdefghij"));
+ test(S("abcdefghij"), 10, 0, str, str+0, S("abcdefghij"));
+ test(S("abcdefghij"), 10, 0, str, str+1, S("abcdefghij1"));
+ test(S("abcdefghij"), 10, 0, str, str+2, S("abcdefghij12"));
+ test(S("abcdefghij"), 10, 0, str, str+4, S("abcdefghij1234"));
+ test(S("abcdefghij"), 10, 0, str, str+5, S("abcdefghij12345"));
+ test(S("abcdefghij"), 10, 0, str, str+0, S("abcdefghij"));
+ test(S("abcdefghij"), 10, 0, str, str+1, S("abcdefghij1"));
+ test(S("abcdefghij"), 10, 0, str, str+5, S("abcdefghij12345"));
+ test(S("abcdefghij"), 10, 0, str, str+9, S("abcdefghij123456789"));
+ test(S("abcdefghij"), 10, 0, str, str+10, S("abcdefghij1234567890"));
+ test(S("abcdefghij"), 10, 0, str, str+0, S("abcdefghij"));
+ test(S("abcdefghij"), 10, 0, str, str+1, S("abcdefghij1"));
+ test(S("abcdefghij"), 10, 0, str, str+10, S("abcdefghij1234567890"));
+ test(S("abcdefghij"), 10, 0, str, str+19, S("abcdefghij1234567890123456789"));
+ test(S("abcdefghij"), 10, 0, str, str+20, S("abcdefghij12345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, str, str+0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, str, str+0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, str, str+1, S("1abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, str, str+2, S("12abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, str, str+4, S("1234abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, str, str+5, S("12345abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, str, str+0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, str, str+1, S("1abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, str, str+5, S("12345abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, str, str+9, S("123456789abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, str, str+10, S("1234567890abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, str, str+0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, str, str+1, S("1abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, str, str+10, S("1234567890abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, str, str+19, S("1234567890123456789abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, str, str+20, S("12345678901234567890abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, str, str+0, S("bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, str, str+0, S("bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, str, str+1, S("1bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, str, str+2, S("12bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, str, str+4, S("1234bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, str, str+5, S("12345bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, str, str+0, S("bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, str, str+1, S("1bcdefghijklmnopqrst"));
+}
+
+template <class S>
+void test6()
+{
+ test(S("abcdefghijklmnopqrst"), 0, 1, str, str+5, S("12345bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, str, str+9, S("123456789bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, str, str+10, S("1234567890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, str, str+0, S("bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, str, str+1, S("1bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, str, str+10, S("1234567890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, str, str+19, S("1234567890123456789bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, str, str+20, S("12345678901234567890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, str, str+0, S("klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, str, str+0, S("klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, str, str+1, S("1klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, str, str+2, S("12klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, str, str+4, S("1234klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, str, str+5, S("12345klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, str, str+0, S("klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, str, str+1, S("1klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, str, str+5, S("12345klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, str, str+9, S("123456789klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, str, str+10, S("1234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, str, str+0, S("klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, str, str+1, S("1klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, str, str+10, S("1234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, str, str+19, S("1234567890123456789klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, str, str+20, S("12345678901234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, str, str+0, S("t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, str, str+0, S("t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, str, str+1, S("1t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, str, str+2, S("12t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, str, str+4, S("1234t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, str, str+5, S("12345t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, str, str+0, S("t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, str, str+1, S("1t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, str, str+5, S("12345t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, str, str+9, S("123456789t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, str, str+10, S("1234567890t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, str, str+0, S("t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, str, str+1, S("1t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, str, str+10, S("1234567890t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, str, str+19, S("1234567890123456789t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, str, str+20, S("12345678901234567890t"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, str, str+0, S(""));
+ test(S("abcdefghijklmnopqrst"), 0, 20, str, str+0, S(""));
+ test(S("abcdefghijklmnopqrst"), 0, 20, str, str+1, S("1"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, str, str+2, S("12"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, str, str+4, S("1234"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, str, str+5, S("12345"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, str, str+0, S(""));
+ test(S("abcdefghijklmnopqrst"), 0, 20, str, str+1, S("1"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, str, str+5, S("12345"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, str, str+9, S("123456789"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, str, str+10, S("1234567890"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, str, str+0, S(""));
+ test(S("abcdefghijklmnopqrst"), 0, 20, str, str+1, S("1"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, str, str+10, S("1234567890"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, str, str+19, S("1234567890123456789"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, str, str+20, S("12345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, str, str+0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, str, str+0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, str, str+1, S("a1bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, str, str+2, S("a12bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, str, str+4, S("a1234bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, str, str+5, S("a12345bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, str, str+0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, str, str+1, S("a1bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, str, str+5, S("a12345bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, str, str+9, S("a123456789bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, str, str+10, S("a1234567890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, str, str+0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, str, str+1, S("a1bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, str, str+10, S("a1234567890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, str, str+19, S("a1234567890123456789bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, str, str+20, S("a12345678901234567890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, str, str+0, S("acdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, str, str+0, S("acdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, str, str+1, S("a1cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, str, str+2, S("a12cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, str, str+4, S("a1234cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, str, str+5, S("a12345cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, str, str+0, S("acdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, str, str+1, S("a1cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, str, str+5, S("a12345cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, str, str+9, S("a123456789cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, str, str+10, S("a1234567890cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, str, str+0, S("acdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, str, str+1, S("a1cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, str, str+10, S("a1234567890cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, str, str+19, S("a1234567890123456789cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, str, str+20, S("a12345678901234567890cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, str, str+0, S("aklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, str, str+0, S("aklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, str, str+1, S("a1klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, str, str+2, S("a12klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, str, str+4, S("a1234klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, str, str+5, S("a12345klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, str, str+0, S("aklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, str, str+1, S("a1klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, str, str+5, S("a12345klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, str, str+9, S("a123456789klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, str, str+10, S("a1234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, str, str+0, S("aklmnopqrst"));
+}
+
+template <class S>
+void test7()
+{
+ test(S("abcdefghijklmnopqrst"), 1, 9, str, str+1, S("a1klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, str, str+10, S("a1234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, str, str+19, S("a1234567890123456789klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, str, str+20, S("a12345678901234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, str, str+0, S("at"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, str, str+0, S("at"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, str, str+1, S("a1t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, str, str+2, S("a12t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, str, str+4, S("a1234t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, str, str+5, S("a12345t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, str, str+0, S("at"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, str, str+1, S("a1t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, str, str+5, S("a12345t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, str, str+9, S("a123456789t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, str, str+10, S("a1234567890t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, str, str+0, S("at"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, str, str+1, S("a1t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, str, str+10, S("a1234567890t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, str, str+19, S("a1234567890123456789t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, str, str+20, S("a12345678901234567890t"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, str, str+0, S("a"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, str, str+0, S("a"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, str, str+1, S("a1"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, str, str+2, S("a12"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, str, str+4, S("a1234"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, str, str+5, S("a12345"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, str, str+0, S("a"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, str, str+1, S("a1"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, str, str+5, S("a12345"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, str, str+9, S("a123456789"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, str, str+10, S("a1234567890"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, str, str+0, S("a"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, str, str+1, S("a1"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, str, str+10, S("a1234567890"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, str, str+19, S("a1234567890123456789"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, str, str+20, S("a12345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, str, str+0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, str, str+0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, str, str+1, S("abcdefghij1klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, str, str+2, S("abcdefghij12klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, str, str+4, S("abcdefghij1234klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, str, str+5, S("abcdefghij12345klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, str, str+0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, str, str+1, S("abcdefghij1klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, str, str+5, S("abcdefghij12345klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, str, str+9, S("abcdefghij123456789klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, str, str+10, S("abcdefghij1234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, str, str+0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, str, str+1, S("abcdefghij1klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, str, str+10, S("abcdefghij1234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, str, str+19, S("abcdefghij1234567890123456789klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, str, str+20, S("abcdefghij12345678901234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, str, str+0, S("abcdefghijlmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, str, str+0, S("abcdefghijlmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, str, str+1, S("abcdefghij1lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, str, str+2, S("abcdefghij12lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, str, str+4, S("abcdefghij1234lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, str, str+5, S("abcdefghij12345lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, str, str+0, S("abcdefghijlmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, str, str+1, S("abcdefghij1lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, str, str+5, S("abcdefghij12345lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, str, str+9, S("abcdefghij123456789lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, str, str+10, S("abcdefghij1234567890lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, str, str+0, S("abcdefghijlmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, str, str+1, S("abcdefghij1lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, str, str+10, S("abcdefghij1234567890lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, str, str+19, S("abcdefghij1234567890123456789lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, str, str+20, S("abcdefghij12345678901234567890lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, str, str+0, S("abcdefghijpqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, str, str+0, S("abcdefghijpqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, str, str+1, S("abcdefghij1pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, str, str+2, S("abcdefghij12pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, str, str+4, S("abcdefghij1234pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, str, str+5, S("abcdefghij12345pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, str, str+0, S("abcdefghijpqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, str, str+1, S("abcdefghij1pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, str, str+5, S("abcdefghij12345pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, str, str+9, S("abcdefghij123456789pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, str, str+10, S("abcdefghij1234567890pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, str, str+0, S("abcdefghijpqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, str, str+1, S("abcdefghij1pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, str, str+10, S("abcdefghij1234567890pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, str, str+19, S("abcdefghij1234567890123456789pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, str, str+20, S("abcdefghij12345678901234567890pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, str, str+0, S("abcdefghijt"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, str, str+0, S("abcdefghijt"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, str, str+1, S("abcdefghij1t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, str, str+2, S("abcdefghij12t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, str, str+4, S("abcdefghij1234t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, str, str+5, S("abcdefghij12345t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, str, str+0, S("abcdefghijt"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, str, str+1, S("abcdefghij1t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, str, str+5, S("abcdefghij12345t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, str, str+9, S("abcdefghij123456789t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, str, str+10, S("abcdefghij1234567890t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, str, str+0, S("abcdefghijt"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, str, str+1, S("abcdefghij1t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, str, str+10, S("abcdefghij1234567890t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, str, str+19, S("abcdefghij1234567890123456789t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, str, str+20, S("abcdefghij12345678901234567890t"));
+}
+
+template <class S>
+void test8()
+{
+ test(S("abcdefghijklmnopqrst"), 10, 10, str, str+0, S("abcdefghij"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, str, str+0, S("abcdefghij"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, str, str+1, S("abcdefghij1"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, str, str+2, S("abcdefghij12"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, str, str+4, S("abcdefghij1234"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, str, str+5, S("abcdefghij12345"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, str, str+0, S("abcdefghij"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, str, str+1, S("abcdefghij1"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, str, str+5, S("abcdefghij12345"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, str, str+9, S("abcdefghij123456789"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, str, str+10, S("abcdefghij1234567890"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, str, str+0, S("abcdefghij"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, str, str+1, S("abcdefghij1"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, str, str+10, S("abcdefghij1234567890"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, str, str+19, S("abcdefghij1234567890123456789"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, str, str+20, S("abcdefghij12345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, str, str+0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, str, str+0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, str, str+1, S("abcdefghijklmnopqrs1t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, str, str+2, S("abcdefghijklmnopqrs12t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, str, str+4, S("abcdefghijklmnopqrs1234t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, str, str+5, S("abcdefghijklmnopqrs12345t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, str, str+0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, str, str+1, S("abcdefghijklmnopqrs1t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, str, str+5, S("abcdefghijklmnopqrs12345t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, str, str+9, S("abcdefghijklmnopqrs123456789t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, str, str+10, S("abcdefghijklmnopqrs1234567890t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, str, str+0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, str, str+1, S("abcdefghijklmnopqrs1t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, str, str+10, S("abcdefghijklmnopqrs1234567890t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, str, str+19, S("abcdefghijklmnopqrs1234567890123456789t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, str, str+20, S("abcdefghijklmnopqrs12345678901234567890t"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, str, str+0, S("abcdefghijklmnopqrs"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, str, str+0, S("abcdefghijklmnopqrs"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, str, str+1, S("abcdefghijklmnopqrs1"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, str, str+2, S("abcdefghijklmnopqrs12"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, str, str+4, S("abcdefghijklmnopqrs1234"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, str, str+5, S("abcdefghijklmnopqrs12345"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, str, str+0, S("abcdefghijklmnopqrs"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, str, str+1, S("abcdefghijklmnopqrs1"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, str, str+5, S("abcdefghijklmnopqrs12345"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, str, str+9, S("abcdefghijklmnopqrs123456789"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, str, str+10, S("abcdefghijklmnopqrs1234567890"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, str, str+0, S("abcdefghijklmnopqrs"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, str, str+1, S("abcdefghijklmnopqrs1"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, str, str+10, S("abcdefghijklmnopqrs1234567890"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, str, str+19, S("abcdefghijklmnopqrs1234567890123456789"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, str, str+20, S("abcdefghijklmnopqrs12345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, str, str+0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, str, str+0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, str, str+1, S("abcdefghijklmnopqrst1"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, str, str+2, S("abcdefghijklmnopqrst12"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, str, str+4, S("abcdefghijklmnopqrst1234"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, str, str+5, S("abcdefghijklmnopqrst12345"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, str, str+0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, str, str+1, S("abcdefghijklmnopqrst1"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, str, str+5, S("abcdefghijklmnopqrst12345"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, str, str+9, S("abcdefghijklmnopqrst123456789"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, str, str+10, S("abcdefghijklmnopqrst1234567890"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, str, str+0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, str, str+1, S("abcdefghijklmnopqrst1"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, str, str+10, S("abcdefghijklmnopqrst1234567890"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, str, str+19, S("abcdefghijklmnopqrst1234567890123456789"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, str, str+20, S("abcdefghijklmnopqrst12345678901234567890"));
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test0<S>();
+ test1<S>();
+ test2<S>();
+ test3<S>();
+ test4<S>();
+ test5<S>();
+ test6<S>();
+ test7<S>();
+ test8<S>();
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test0<S>();
+ test1<S>();
+ test2<S>();
+ test3<S>();
+ test4<S>();
+ test5<S>();
+ test6<S>();
+ test7<S>();
+ test8<S>();
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_pointer.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_pointer.pass.cpp
new file mode 100644
index 000000000000..cb4ce61d0942
--- /dev/null
+++ b/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_pointer.pass.cpp
@@ -0,0 +1,285 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string<charT,traits,Allocator>&
+// replace(const_iterator i1, const_iterator i2, const charT* s);
+
+#include <stdio.h>
+
+#include <string>
+#include <algorithm>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s, typename S::size_type pos1, typename S::size_type n1, const typename S::value_type* str, S expected)
+{
+ typename S::size_type old_size = s.size();
+ typename S::const_iterator first = s.begin() + pos1;
+ typename S::const_iterator last = s.begin() + pos1 + n1;
+ typename S::size_type xlen = last - first;
+ s.replace(first, last, str);
+ assert(s.__invariants());
+ assert(s == expected);
+ typename S::size_type rlen = S::traits_type::length(str);
+ assert(s.size() == old_size - xlen + rlen);
+}
+
+template <class S>
+void test0()
+{
+ test(S(""), 0, 0, "", S(""));
+ test(S(""), 0, 0, "12345", S("12345"));
+ test(S(""), 0, 0, "1234567890", S("1234567890"));
+ test(S(""), 0, 0, "12345678901234567890", S("12345678901234567890"));
+ test(S("abcde"), 0, 0, "", S("abcde"));
+ test(S("abcde"), 0, 0, "12345", S("12345abcde"));
+ test(S("abcde"), 0, 0, "1234567890", S("1234567890abcde"));
+ test(S("abcde"), 0, 0, "12345678901234567890", S("12345678901234567890abcde"));
+ test(S("abcde"), 0, 1, "", S("bcde"));
+ test(S("abcde"), 0, 1, "12345", S("12345bcde"));
+ test(S("abcde"), 0, 1, "1234567890", S("1234567890bcde"));
+ test(S("abcde"), 0, 1, "12345678901234567890", S("12345678901234567890bcde"));
+ test(S("abcde"), 0, 2, "", S("cde"));
+ test(S("abcde"), 0, 2, "12345", S("12345cde"));
+ test(S("abcde"), 0, 2, "1234567890", S("1234567890cde"));
+ test(S("abcde"), 0, 2, "12345678901234567890", S("12345678901234567890cde"));
+ test(S("abcde"), 0, 4, "", S("e"));
+ test(S("abcde"), 0, 4, "12345", S("12345e"));
+ test(S("abcde"), 0, 4, "1234567890", S("1234567890e"));
+ test(S("abcde"), 0, 4, "12345678901234567890", S("12345678901234567890e"));
+ test(S("abcde"), 0, 5, "", S(""));
+ test(S("abcde"), 0, 5, "12345", S("12345"));
+ test(S("abcde"), 0, 5, "1234567890", S("1234567890"));
+ test(S("abcde"), 0, 5, "12345678901234567890", S("12345678901234567890"));
+ test(S("abcde"), 1, 0, "", S("abcde"));
+ test(S("abcde"), 1, 0, "12345", S("a12345bcde"));
+ test(S("abcde"), 1, 0, "1234567890", S("a1234567890bcde"));
+ test(S("abcde"), 1, 0, "12345678901234567890", S("a12345678901234567890bcde"));
+ test(S("abcde"), 1, 1, "", S("acde"));
+ test(S("abcde"), 1, 1, "12345", S("a12345cde"));
+ test(S("abcde"), 1, 1, "1234567890", S("a1234567890cde"));
+ test(S("abcde"), 1, 1, "12345678901234567890", S("a12345678901234567890cde"));
+ test(S("abcde"), 1, 2, "", S("ade"));
+ test(S("abcde"), 1, 2, "12345", S("a12345de"));
+ test(S("abcde"), 1, 2, "1234567890", S("a1234567890de"));
+ test(S("abcde"), 1, 2, "12345678901234567890", S("a12345678901234567890de"));
+ test(S("abcde"), 1, 3, "", S("ae"));
+ test(S("abcde"), 1, 3, "12345", S("a12345e"));
+ test(S("abcde"), 1, 3, "1234567890", S("a1234567890e"));
+ test(S("abcde"), 1, 3, "12345678901234567890", S("a12345678901234567890e"));
+ test(S("abcde"), 1, 4, "", S("a"));
+ test(S("abcde"), 1, 4, "12345", S("a12345"));
+ test(S("abcde"), 1, 4, "1234567890", S("a1234567890"));
+ test(S("abcde"), 1, 4, "12345678901234567890", S("a12345678901234567890"));
+ test(S("abcde"), 2, 0, "", S("abcde"));
+ test(S("abcde"), 2, 0, "12345", S("ab12345cde"));
+ test(S("abcde"), 2, 0, "1234567890", S("ab1234567890cde"));
+ test(S("abcde"), 2, 0, "12345678901234567890", S("ab12345678901234567890cde"));
+ test(S("abcde"), 2, 1, "", S("abde"));
+ test(S("abcde"), 2, 1, "12345", S("ab12345de"));
+ test(S("abcde"), 2, 1, "1234567890", S("ab1234567890de"));
+ test(S("abcde"), 2, 1, "12345678901234567890", S("ab12345678901234567890de"));
+ test(S("abcde"), 2, 2, "", S("abe"));
+ test(S("abcde"), 2, 2, "12345", S("ab12345e"));
+ test(S("abcde"), 2, 2, "1234567890", S("ab1234567890e"));
+ test(S("abcde"), 2, 2, "12345678901234567890", S("ab12345678901234567890e"));
+ test(S("abcde"), 2, 3, "", S("ab"));
+ test(S("abcde"), 2, 3, "12345", S("ab12345"));
+ test(S("abcde"), 2, 3, "1234567890", S("ab1234567890"));
+ test(S("abcde"), 2, 3, "12345678901234567890", S("ab12345678901234567890"));
+ test(S("abcde"), 4, 0, "", S("abcde"));
+ test(S("abcde"), 4, 0, "12345", S("abcd12345e"));
+ test(S("abcde"), 4, 0, "1234567890", S("abcd1234567890e"));
+ test(S("abcde"), 4, 0, "12345678901234567890", S("abcd12345678901234567890e"));
+ test(S("abcde"), 4, 1, "", S("abcd"));
+ test(S("abcde"), 4, 1, "12345", S("abcd12345"));
+ test(S("abcde"), 4, 1, "1234567890", S("abcd1234567890"));
+ test(S("abcde"), 4, 1, "12345678901234567890", S("abcd12345678901234567890"));
+ test(S("abcde"), 5, 0, "", S("abcde"));
+ test(S("abcde"), 5, 0, "12345", S("abcde12345"));
+ test(S("abcde"), 5, 0, "1234567890", S("abcde1234567890"));
+ test(S("abcde"), 5, 0, "12345678901234567890", S("abcde12345678901234567890"));
+ test(S("abcdefghij"), 0, 0, "", S("abcdefghij"));
+ test(S("abcdefghij"), 0, 0, "12345", S("12345abcdefghij"));
+ test(S("abcdefghij"), 0, 0, "1234567890", S("1234567890abcdefghij"));
+ test(S("abcdefghij"), 0, 0, "12345678901234567890", S("12345678901234567890abcdefghij"));
+ test(S("abcdefghij"), 0, 1, "", S("bcdefghij"));
+ test(S("abcdefghij"), 0, 1, "12345", S("12345bcdefghij"));
+ test(S("abcdefghij"), 0, 1, "1234567890", S("1234567890bcdefghij"));
+ test(S("abcdefghij"), 0, 1, "12345678901234567890", S("12345678901234567890bcdefghij"));
+ test(S("abcdefghij"), 0, 5, "", S("fghij"));
+ test(S("abcdefghij"), 0, 5, "12345", S("12345fghij"));
+ test(S("abcdefghij"), 0, 5, "1234567890", S("1234567890fghij"));
+ test(S("abcdefghij"), 0, 5, "12345678901234567890", S("12345678901234567890fghij"));
+ test(S("abcdefghij"), 0, 9, "", S("j"));
+ test(S("abcdefghij"), 0, 9, "12345", S("12345j"));
+ test(S("abcdefghij"), 0, 9, "1234567890", S("1234567890j"));
+ test(S("abcdefghij"), 0, 9, "12345678901234567890", S("12345678901234567890j"));
+ test(S("abcdefghij"), 0, 10, "", S(""));
+ test(S("abcdefghij"), 0, 10, "12345", S("12345"));
+ test(S("abcdefghij"), 0, 10, "1234567890", S("1234567890"));
+ test(S("abcdefghij"), 0, 10, "12345678901234567890", S("12345678901234567890"));
+ test(S("abcdefghij"), 1, 0, "", S("abcdefghij"));
+ test(S("abcdefghij"), 1, 0, "12345", S("a12345bcdefghij"));
+ test(S("abcdefghij"), 1, 0, "1234567890", S("a1234567890bcdefghij"));
+ test(S("abcdefghij"), 1, 0, "12345678901234567890", S("a12345678901234567890bcdefghij"));
+ test(S("abcdefghij"), 1, 1, "", S("acdefghij"));
+ test(S("abcdefghij"), 1, 1, "12345", S("a12345cdefghij"));
+ test(S("abcdefghij"), 1, 1, "1234567890", S("a1234567890cdefghij"));
+ test(S("abcdefghij"), 1, 1, "12345678901234567890", S("a12345678901234567890cdefghij"));
+}
+
+template <class S>
+void test1()
+{
+ test(S("abcdefghij"), 1, 4, "", S("afghij"));
+ test(S("abcdefghij"), 1, 4, "12345", S("a12345fghij"));
+ test(S("abcdefghij"), 1, 4, "1234567890", S("a1234567890fghij"));
+ test(S("abcdefghij"), 1, 4, "12345678901234567890", S("a12345678901234567890fghij"));
+ test(S("abcdefghij"), 1, 8, "", S("aj"));
+ test(S("abcdefghij"), 1, 8, "12345", S("a12345j"));
+ test(S("abcdefghij"), 1, 8, "1234567890", S("a1234567890j"));
+ test(S("abcdefghij"), 1, 8, "12345678901234567890", S("a12345678901234567890j"));
+ test(S("abcdefghij"), 1, 9, "", S("a"));
+ test(S("abcdefghij"), 1, 9, "12345", S("a12345"));
+ test(S("abcdefghij"), 1, 9, "1234567890", S("a1234567890"));
+ test(S("abcdefghij"), 1, 9, "12345678901234567890", S("a12345678901234567890"));
+ test(S("abcdefghij"), 5, 0, "", S("abcdefghij"));
+ test(S("abcdefghij"), 5, 0, "12345", S("abcde12345fghij"));
+ test(S("abcdefghij"), 5, 0, "1234567890", S("abcde1234567890fghij"));
+ test(S("abcdefghij"), 5, 0, "12345678901234567890", S("abcde12345678901234567890fghij"));
+ test(S("abcdefghij"), 5, 1, "", S("abcdeghij"));
+ test(S("abcdefghij"), 5, 1, "12345", S("abcde12345ghij"));
+ test(S("abcdefghij"), 5, 1, "1234567890", S("abcde1234567890ghij"));
+ test(S("abcdefghij"), 5, 1, "12345678901234567890", S("abcde12345678901234567890ghij"));
+ test(S("abcdefghij"), 5, 2, "", S("abcdehij"));
+ test(S("abcdefghij"), 5, 2, "12345", S("abcde12345hij"));
+ test(S("abcdefghij"), 5, 2, "1234567890", S("abcde1234567890hij"));
+ test(S("abcdefghij"), 5, 2, "12345678901234567890", S("abcde12345678901234567890hij"));
+ test(S("abcdefghij"), 5, 4, "", S("abcdej"));
+ test(S("abcdefghij"), 5, 4, "12345", S("abcde12345j"));
+ test(S("abcdefghij"), 5, 4, "1234567890", S("abcde1234567890j"));
+ test(S("abcdefghij"), 5, 4, "12345678901234567890", S("abcde12345678901234567890j"));
+ test(S("abcdefghij"), 5, 5, "", S("abcde"));
+ test(S("abcdefghij"), 5, 5, "12345", S("abcde12345"));
+ test(S("abcdefghij"), 5, 5, "1234567890", S("abcde1234567890"));
+ test(S("abcdefghij"), 5, 5, "12345678901234567890", S("abcde12345678901234567890"));
+ test(S("abcdefghij"), 9, 0, "", S("abcdefghij"));
+ test(S("abcdefghij"), 9, 0, "12345", S("abcdefghi12345j"));
+ test(S("abcdefghij"), 9, 0, "1234567890", S("abcdefghi1234567890j"));
+ test(S("abcdefghij"), 9, 0, "12345678901234567890", S("abcdefghi12345678901234567890j"));
+ test(S("abcdefghij"), 9, 1, "", S("abcdefghi"));
+ test(S("abcdefghij"), 9, 1, "12345", S("abcdefghi12345"));
+ test(S("abcdefghij"), 9, 1, "1234567890", S("abcdefghi1234567890"));
+ test(S("abcdefghij"), 9, 1, "12345678901234567890", S("abcdefghi12345678901234567890"));
+ test(S("abcdefghij"), 10, 0, "", S("abcdefghij"));
+ test(S("abcdefghij"), 10, 0, "12345", S("abcdefghij12345"));
+ test(S("abcdefghij"), 10, 0, "1234567890", S("abcdefghij1234567890"));
+ test(S("abcdefghij"), 10, 0, "12345678901234567890", S("abcdefghij12345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, "", S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, "12345", S("12345abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, "1234567890", S("1234567890abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, "12345678901234567890", S("12345678901234567890abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, "", S("bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, "12345", S("12345bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, "1234567890", S("1234567890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, "12345678901234567890", S("12345678901234567890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, "", S("klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, "12345", S("12345klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, "1234567890", S("1234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, "12345678901234567890", S("12345678901234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, "", S("t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, "12345", S("12345t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, "1234567890", S("1234567890t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, "12345678901234567890", S("12345678901234567890t"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, "", S(""));
+ test(S("abcdefghijklmnopqrst"), 0, 20, "12345", S("12345"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, "1234567890", S("1234567890"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, "12345678901234567890", S("12345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, "", S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, "12345", S("a12345bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, "1234567890", S("a1234567890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, "12345678901234567890", S("a12345678901234567890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, "", S("acdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, "12345", S("a12345cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, "1234567890", S("a1234567890cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, "12345678901234567890", S("a12345678901234567890cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, "", S("aklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, "12345", S("a12345klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, "1234567890", S("a1234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, "12345678901234567890", S("a12345678901234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, "", S("at"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, "12345", S("a12345t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, "1234567890", S("a1234567890t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, "12345678901234567890", S("a12345678901234567890t"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, "", S("a"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, "12345", S("a12345"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, "1234567890", S("a1234567890"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, "12345678901234567890", S("a12345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, "", S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, "12345", S("abcdefghij12345klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, "1234567890", S("abcdefghij1234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, "12345678901234567890", S("abcdefghij12345678901234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, "", S("abcdefghijlmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, "12345", S("abcdefghij12345lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, "1234567890", S("abcdefghij1234567890lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, "12345678901234567890", S("abcdefghij12345678901234567890lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, "", S("abcdefghijpqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, "12345", S("abcdefghij12345pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, "1234567890", S("abcdefghij1234567890pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, "12345678901234567890", S("abcdefghij12345678901234567890pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, "", S("abcdefghijt"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, "12345", S("abcdefghij12345t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, "1234567890", S("abcdefghij1234567890t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, "12345678901234567890", S("abcdefghij12345678901234567890t"));
+}
+
+template <class S>
+void test2()
+{
+ test(S("abcdefghijklmnopqrst"), 10, 10, "", S("abcdefghij"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, "12345", S("abcdefghij12345"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, "1234567890", S("abcdefghij1234567890"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, "12345678901234567890", S("abcdefghij12345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, "", S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, "12345", S("abcdefghijklmnopqrs12345t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, "1234567890", S("abcdefghijklmnopqrs1234567890t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, "12345678901234567890", S("abcdefghijklmnopqrs12345678901234567890t"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, "", S("abcdefghijklmnopqrs"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, "12345", S("abcdefghijklmnopqrs12345"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, "1234567890", S("abcdefghijklmnopqrs1234567890"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, "12345678901234567890", S("abcdefghijklmnopqrs12345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, "", S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, "12345", S("abcdefghijklmnopqrst12345"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, "1234567890", S("abcdefghijklmnopqrst1234567890"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, "12345678901234567890", S("abcdefghijklmnopqrst12345678901234567890"));
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test0<S>();
+ test1<S>();
+ test2<S>();
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test0<S>();
+ test1<S>();
+ test2<S>();
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_pointer_size.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_pointer_size.pass.cpp
new file mode 100644
index 000000000000..b1d6ab1ba579
--- /dev/null
+++ b/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_pointer_size.pass.cpp
@@ -0,0 +1,976 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string<charT,traits,Allocator>&
+// replace(const_iterator i1, const_iterator i2, const charT* s, size_type n);
+
+#include <stdio.h>
+
+#include <string>
+#include <algorithm>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s, typename S::size_type pos1, typename S::size_type n1, const typename S::value_type* str,
+ typename S::size_type n2, S expected)
+{
+ typename S::size_type old_size = s.size();
+ typename S::const_iterator first = s.begin() + pos1;
+ typename S::const_iterator last = s.begin() + pos1 + n1;
+ typename S::size_type xlen = last - first;
+ s.replace(first, last, str, n2);
+ assert(s.__invariants());
+ assert(s == expected);
+ typename S::size_type rlen = n2;
+ assert(s.size() == old_size - xlen + rlen);
+}
+
+template <class S>
+void test0()
+{
+ test(S(""), 0, 0, "", 0, S(""));
+ test(S(""), 0, 0, "12345", 0, S(""));
+ test(S(""), 0, 0, "12345", 1, S("1"));
+ test(S(""), 0, 0, "12345", 2, S("12"));
+ test(S(""), 0, 0, "12345", 4, S("1234"));
+ test(S(""), 0, 0, "12345", 5, S("12345"));
+ test(S(""), 0, 0, "1234567890", 0, S(""));
+ test(S(""), 0, 0, "1234567890", 1, S("1"));
+ test(S(""), 0, 0, "1234567890", 5, S("12345"));
+ test(S(""), 0, 0, "1234567890", 9, S("123456789"));
+ test(S(""), 0, 0, "1234567890", 10, S("1234567890"));
+ test(S(""), 0, 0, "12345678901234567890", 0, S(""));
+ test(S(""), 0, 0, "12345678901234567890", 1, S("1"));
+ test(S(""), 0, 0, "12345678901234567890", 10, S("1234567890"));
+ test(S(""), 0, 0, "12345678901234567890", 19, S("1234567890123456789"));
+ test(S(""), 0, 0, "12345678901234567890", 20, S("12345678901234567890"));
+ test(S("abcde"), 0, 0, "", 0, S("abcde"));
+ test(S("abcde"), 0, 0, "12345", 0, S("abcde"));
+ test(S("abcde"), 0, 0, "12345", 1, S("1abcde"));
+ test(S("abcde"), 0, 0, "12345", 2, S("12abcde"));
+ test(S("abcde"), 0, 0, "12345", 4, S("1234abcde"));
+ test(S("abcde"), 0, 0, "12345", 5, S("12345abcde"));
+ test(S("abcde"), 0, 0, "1234567890", 0, S("abcde"));
+ test(S("abcde"), 0, 0, "1234567890", 1, S("1abcde"));
+ test(S("abcde"), 0, 0, "1234567890", 5, S("12345abcde"));
+ test(S("abcde"), 0, 0, "1234567890", 9, S("123456789abcde"));
+ test(S("abcde"), 0, 0, "1234567890", 10, S("1234567890abcde"));
+ test(S("abcde"), 0, 0, "12345678901234567890", 0, S("abcde"));
+ test(S("abcde"), 0, 0, "12345678901234567890", 1, S("1abcde"));
+ test(S("abcde"), 0, 0, "12345678901234567890", 10, S("1234567890abcde"));
+ test(S("abcde"), 0, 0, "12345678901234567890", 19, S("1234567890123456789abcde"));
+ test(S("abcde"), 0, 0, "12345678901234567890", 20, S("12345678901234567890abcde"));
+ test(S("abcde"), 0, 1, "", 0, S("bcde"));
+ test(S("abcde"), 0, 1, "12345", 0, S("bcde"));
+ test(S("abcde"), 0, 1, "12345", 1, S("1bcde"));
+ test(S("abcde"), 0, 1, "12345", 2, S("12bcde"));
+ test(S("abcde"), 0, 1, "12345", 4, S("1234bcde"));
+ test(S("abcde"), 0, 1, "12345", 5, S("12345bcde"));
+ test(S("abcde"), 0, 1, "1234567890", 0, S("bcde"));
+ test(S("abcde"), 0, 1, "1234567890", 1, S("1bcde"));
+ test(S("abcde"), 0, 1, "1234567890", 5, S("12345bcde"));
+ test(S("abcde"), 0, 1, "1234567890", 9, S("123456789bcde"));
+ test(S("abcde"), 0, 1, "1234567890", 10, S("1234567890bcde"));
+ test(S("abcde"), 0, 1, "12345678901234567890", 0, S("bcde"));
+ test(S("abcde"), 0, 1, "12345678901234567890", 1, S("1bcde"));
+ test(S("abcde"), 0, 1, "12345678901234567890", 10, S("1234567890bcde"));
+ test(S("abcde"), 0, 1, "12345678901234567890", 19, S("1234567890123456789bcde"));
+ test(S("abcde"), 0, 1, "12345678901234567890", 20, S("12345678901234567890bcde"));
+ test(S("abcde"), 0, 2, "", 0, S("cde"));
+ test(S("abcde"), 0, 2, "12345", 0, S("cde"));
+ test(S("abcde"), 0, 2, "12345", 1, S("1cde"));
+ test(S("abcde"), 0, 2, "12345", 2, S("12cde"));
+ test(S("abcde"), 0, 2, "12345", 4, S("1234cde"));
+ test(S("abcde"), 0, 2, "12345", 5, S("12345cde"));
+ test(S("abcde"), 0, 2, "1234567890", 0, S("cde"));
+ test(S("abcde"), 0, 2, "1234567890", 1, S("1cde"));
+ test(S("abcde"), 0, 2, "1234567890", 5, S("12345cde"));
+ test(S("abcde"), 0, 2, "1234567890", 9, S("123456789cde"));
+ test(S("abcde"), 0, 2, "1234567890", 10, S("1234567890cde"));
+ test(S("abcde"), 0, 2, "12345678901234567890", 0, S("cde"));
+ test(S("abcde"), 0, 2, "12345678901234567890", 1, S("1cde"));
+ test(S("abcde"), 0, 2, "12345678901234567890", 10, S("1234567890cde"));
+ test(S("abcde"), 0, 2, "12345678901234567890", 19, S("1234567890123456789cde"));
+ test(S("abcde"), 0, 2, "12345678901234567890", 20, S("12345678901234567890cde"));
+ test(S("abcde"), 0, 4, "", 0, S("e"));
+ test(S("abcde"), 0, 4, "12345", 0, S("e"));
+ test(S("abcde"), 0, 4, "12345", 1, S("1e"));
+ test(S("abcde"), 0, 4, "12345", 2, S("12e"));
+ test(S("abcde"), 0, 4, "12345", 4, S("1234e"));
+ test(S("abcde"), 0, 4, "12345", 5, S("12345e"));
+ test(S("abcde"), 0, 4, "1234567890", 0, S("e"));
+ test(S("abcde"), 0, 4, "1234567890", 1, S("1e"));
+ test(S("abcde"), 0, 4, "1234567890", 5, S("12345e"));
+ test(S("abcde"), 0, 4, "1234567890", 9, S("123456789e"));
+ test(S("abcde"), 0, 4, "1234567890", 10, S("1234567890e"));
+ test(S("abcde"), 0, 4, "12345678901234567890", 0, S("e"));
+ test(S("abcde"), 0, 4, "12345678901234567890", 1, S("1e"));
+ test(S("abcde"), 0, 4, "12345678901234567890", 10, S("1234567890e"));
+ test(S("abcde"), 0, 4, "12345678901234567890", 19, S("1234567890123456789e"));
+ test(S("abcde"), 0, 4, "12345678901234567890", 20, S("12345678901234567890e"));
+ test(S("abcde"), 0, 5, "", 0, S(""));
+ test(S("abcde"), 0, 5, "12345", 0, S(""));
+ test(S("abcde"), 0, 5, "12345", 1, S("1"));
+ test(S("abcde"), 0, 5, "12345", 2, S("12"));
+ test(S("abcde"), 0, 5, "12345", 4, S("1234"));
+ test(S("abcde"), 0, 5, "12345", 5, S("12345"));
+ test(S("abcde"), 0, 5, "1234567890", 0, S(""));
+ test(S("abcde"), 0, 5, "1234567890", 1, S("1"));
+ test(S("abcde"), 0, 5, "1234567890", 5, S("12345"));
+ test(S("abcde"), 0, 5, "1234567890", 9, S("123456789"));
+ test(S("abcde"), 0, 5, "1234567890", 10, S("1234567890"));
+ test(S("abcde"), 0, 5, "12345678901234567890", 0, S(""));
+ test(S("abcde"), 0, 5, "12345678901234567890", 1, S("1"));
+ test(S("abcde"), 0, 5, "12345678901234567890", 10, S("1234567890"));
+ test(S("abcde"), 0, 5, "12345678901234567890", 19, S("1234567890123456789"));
+ test(S("abcde"), 0, 5, "12345678901234567890", 20, S("12345678901234567890"));
+ test(S("abcde"), 1, 0, "", 0, S("abcde"));
+ test(S("abcde"), 1, 0, "12345", 0, S("abcde"));
+ test(S("abcde"), 1, 0, "12345", 1, S("a1bcde"));
+ test(S("abcde"), 1, 0, "12345", 2, S("a12bcde"));
+}
+
+template <class S>
+void test1()
+{
+ test(S("abcde"), 1, 0, "12345", 4, S("a1234bcde"));
+ test(S("abcde"), 1, 0, "12345", 5, S("a12345bcde"));
+ test(S("abcde"), 1, 0, "1234567890", 0, S("abcde"));
+ test(S("abcde"), 1, 0, "1234567890", 1, S("a1bcde"));
+ test(S("abcde"), 1, 0, "1234567890", 5, S("a12345bcde"));
+ test(S("abcde"), 1, 0, "1234567890", 9, S("a123456789bcde"));
+ test(S("abcde"), 1, 0, "1234567890", 10, S("a1234567890bcde"));
+ test(S("abcde"), 1, 0, "12345678901234567890", 0, S("abcde"));
+ test(S("abcde"), 1, 0, "12345678901234567890", 1, S("a1bcde"));
+ test(S("abcde"), 1, 0, "12345678901234567890", 10, S("a1234567890bcde"));
+ test(S("abcde"), 1, 0, "12345678901234567890", 19, S("a1234567890123456789bcde"));
+ test(S("abcde"), 1, 0, "12345678901234567890", 20, S("a12345678901234567890bcde"));
+ test(S("abcde"), 1, 1, "", 0, S("acde"));
+ test(S("abcde"), 1, 1, "12345", 0, S("acde"));
+ test(S("abcde"), 1, 1, "12345", 1, S("a1cde"));
+ test(S("abcde"), 1, 1, "12345", 2, S("a12cde"));
+ test(S("abcde"), 1, 1, "12345", 4, S("a1234cde"));
+ test(S("abcde"), 1, 1, "12345", 5, S("a12345cde"));
+ test(S("abcde"), 1, 1, "1234567890", 0, S("acde"));
+ test(S("abcde"), 1, 1, "1234567890", 1, S("a1cde"));
+ test(S("abcde"), 1, 1, "1234567890", 5, S("a12345cde"));
+ test(S("abcde"), 1, 1, "1234567890", 9, S("a123456789cde"));
+ test(S("abcde"), 1, 1, "1234567890", 10, S("a1234567890cde"));
+ test(S("abcde"), 1, 1, "12345678901234567890", 0, S("acde"));
+ test(S("abcde"), 1, 1, "12345678901234567890", 1, S("a1cde"));
+ test(S("abcde"), 1, 1, "12345678901234567890", 10, S("a1234567890cde"));
+ test(S("abcde"), 1, 1, "12345678901234567890", 19, S("a1234567890123456789cde"));
+ test(S("abcde"), 1, 1, "12345678901234567890", 20, S("a12345678901234567890cde"));
+ test(S("abcde"), 1, 2, "", 0, S("ade"));
+ test(S("abcde"), 1, 2, "12345", 0, S("ade"));
+ test(S("abcde"), 1, 2, "12345", 1, S("a1de"));
+ test(S("abcde"), 1, 2, "12345", 2, S("a12de"));
+ test(S("abcde"), 1, 2, "12345", 4, S("a1234de"));
+ test(S("abcde"), 1, 2, "12345", 5, S("a12345de"));
+ test(S("abcde"), 1, 2, "1234567890", 0, S("ade"));
+ test(S("abcde"), 1, 2, "1234567890", 1, S("a1de"));
+ test(S("abcde"), 1, 2, "1234567890", 5, S("a12345de"));
+ test(S("abcde"), 1, 2, "1234567890", 9, S("a123456789de"));
+ test(S("abcde"), 1, 2, "1234567890", 10, S("a1234567890de"));
+ test(S("abcde"), 1, 2, "12345678901234567890", 0, S("ade"));
+ test(S("abcde"), 1, 2, "12345678901234567890", 1, S("a1de"));
+ test(S("abcde"), 1, 2, "12345678901234567890", 10, S("a1234567890de"));
+ test(S("abcde"), 1, 2, "12345678901234567890", 19, S("a1234567890123456789de"));
+ test(S("abcde"), 1, 2, "12345678901234567890", 20, S("a12345678901234567890de"));
+ test(S("abcde"), 1, 3, "", 0, S("ae"));
+ test(S("abcde"), 1, 3, "12345", 0, S("ae"));
+ test(S("abcde"), 1, 3, "12345", 1, S("a1e"));
+ test(S("abcde"), 1, 3, "12345", 2, S("a12e"));
+ test(S("abcde"), 1, 3, "12345", 4, S("a1234e"));
+ test(S("abcde"), 1, 3, "12345", 5, S("a12345e"));
+ test(S("abcde"), 1, 3, "1234567890", 0, S("ae"));
+ test(S("abcde"), 1, 3, "1234567890", 1, S("a1e"));
+ test(S("abcde"), 1, 3, "1234567890", 5, S("a12345e"));
+ test(S("abcde"), 1, 3, "1234567890", 9, S("a123456789e"));
+ test(S("abcde"), 1, 3, "1234567890", 10, S("a1234567890e"));
+ test(S("abcde"), 1, 3, "12345678901234567890", 0, S("ae"));
+ test(S("abcde"), 1, 3, "12345678901234567890", 1, S("a1e"));
+ test(S("abcde"), 1, 3, "12345678901234567890", 10, S("a1234567890e"));
+ test(S("abcde"), 1, 3, "12345678901234567890", 19, S("a1234567890123456789e"));
+ test(S("abcde"), 1, 3, "12345678901234567890", 20, S("a12345678901234567890e"));
+ test(S("abcde"), 1, 4, "", 0, S("a"));
+ test(S("abcde"), 1, 4, "12345", 0, S("a"));
+ test(S("abcde"), 1, 4, "12345", 1, S("a1"));
+ test(S("abcde"), 1, 4, "12345", 2, S("a12"));
+ test(S("abcde"), 1, 4, "12345", 4, S("a1234"));
+ test(S("abcde"), 1, 4, "12345", 5, S("a12345"));
+ test(S("abcde"), 1, 4, "1234567890", 0, S("a"));
+ test(S("abcde"), 1, 4, "1234567890", 1, S("a1"));
+ test(S("abcde"), 1, 4, "1234567890", 5, S("a12345"));
+ test(S("abcde"), 1, 4, "1234567890", 9, S("a123456789"));
+ test(S("abcde"), 1, 4, "1234567890", 10, S("a1234567890"));
+ test(S("abcde"), 1, 4, "12345678901234567890", 0, S("a"));
+ test(S("abcde"), 1, 4, "12345678901234567890", 1, S("a1"));
+ test(S("abcde"), 1, 4, "12345678901234567890", 10, S("a1234567890"));
+ test(S("abcde"), 1, 4, "12345678901234567890", 19, S("a1234567890123456789"));
+ test(S("abcde"), 1, 4, "12345678901234567890", 20, S("a12345678901234567890"));
+ test(S("abcde"), 2, 0, "", 0, S("abcde"));
+ test(S("abcde"), 2, 0, "12345", 0, S("abcde"));
+ test(S("abcde"), 2, 0, "12345", 1, S("ab1cde"));
+ test(S("abcde"), 2, 0, "12345", 2, S("ab12cde"));
+ test(S("abcde"), 2, 0, "12345", 4, S("ab1234cde"));
+ test(S("abcde"), 2, 0, "12345", 5, S("ab12345cde"));
+ test(S("abcde"), 2, 0, "1234567890", 0, S("abcde"));
+ test(S("abcde"), 2, 0, "1234567890", 1, S("ab1cde"));
+ test(S("abcde"), 2, 0, "1234567890", 5, S("ab12345cde"));
+ test(S("abcde"), 2, 0, "1234567890", 9, S("ab123456789cde"));
+ test(S("abcde"), 2, 0, "1234567890", 10, S("ab1234567890cde"));
+ test(S("abcde"), 2, 0, "12345678901234567890", 0, S("abcde"));
+ test(S("abcde"), 2, 0, "12345678901234567890", 1, S("ab1cde"));
+ test(S("abcde"), 2, 0, "12345678901234567890", 10, S("ab1234567890cde"));
+ test(S("abcde"), 2, 0, "12345678901234567890", 19, S("ab1234567890123456789cde"));
+ test(S("abcde"), 2, 0, "12345678901234567890", 20, S("ab12345678901234567890cde"));
+ test(S("abcde"), 2, 1, "", 0, S("abde"));
+ test(S("abcde"), 2, 1, "12345", 0, S("abde"));
+ test(S("abcde"), 2, 1, "12345", 1, S("ab1de"));
+ test(S("abcde"), 2, 1, "12345", 2, S("ab12de"));
+ test(S("abcde"), 2, 1, "12345", 4, S("ab1234de"));
+ test(S("abcde"), 2, 1, "12345", 5, S("ab12345de"));
+ test(S("abcde"), 2, 1, "1234567890", 0, S("abde"));
+ test(S("abcde"), 2, 1, "1234567890", 1, S("ab1de"));
+}
+
+template <class S>
+void test2()
+{
+ test(S("abcde"), 2, 1, "1234567890", 5, S("ab12345de"));
+ test(S("abcde"), 2, 1, "1234567890", 9, S("ab123456789de"));
+ test(S("abcde"), 2, 1, "1234567890", 10, S("ab1234567890de"));
+ test(S("abcde"), 2, 1, "12345678901234567890", 0, S("abde"));
+ test(S("abcde"), 2, 1, "12345678901234567890", 1, S("ab1de"));
+ test(S("abcde"), 2, 1, "12345678901234567890", 10, S("ab1234567890de"));
+ test(S("abcde"), 2, 1, "12345678901234567890", 19, S("ab1234567890123456789de"));
+ test(S("abcde"), 2, 1, "12345678901234567890", 20, S("ab12345678901234567890de"));
+ test(S("abcde"), 2, 2, "", 0, S("abe"));
+ test(S("abcde"), 2, 2, "12345", 0, S("abe"));
+ test(S("abcde"), 2, 2, "12345", 1, S("ab1e"));
+ test(S("abcde"), 2, 2, "12345", 2, S("ab12e"));
+ test(S("abcde"), 2, 2, "12345", 4, S("ab1234e"));
+ test(S("abcde"), 2, 2, "12345", 5, S("ab12345e"));
+ test(S("abcde"), 2, 2, "1234567890", 0, S("abe"));
+ test(S("abcde"), 2, 2, "1234567890", 1, S("ab1e"));
+ test(S("abcde"), 2, 2, "1234567890", 5, S("ab12345e"));
+ test(S("abcde"), 2, 2, "1234567890", 9, S("ab123456789e"));
+ test(S("abcde"), 2, 2, "1234567890", 10, S("ab1234567890e"));
+ test(S("abcde"), 2, 2, "12345678901234567890", 0, S("abe"));
+ test(S("abcde"), 2, 2, "12345678901234567890", 1, S("ab1e"));
+ test(S("abcde"), 2, 2, "12345678901234567890", 10, S("ab1234567890e"));
+ test(S("abcde"), 2, 2, "12345678901234567890", 19, S("ab1234567890123456789e"));
+ test(S("abcde"), 2, 2, "12345678901234567890", 20, S("ab12345678901234567890e"));
+ test(S("abcde"), 2, 3, "", 0, S("ab"));
+ test(S("abcde"), 2, 3, "12345", 0, S("ab"));
+ test(S("abcde"), 2, 3, "12345", 1, S("ab1"));
+ test(S("abcde"), 2, 3, "12345", 2, S("ab12"));
+ test(S("abcde"), 2, 3, "12345", 4, S("ab1234"));
+ test(S("abcde"), 2, 3, "12345", 5, S("ab12345"));
+ test(S("abcde"), 2, 3, "1234567890", 0, S("ab"));
+ test(S("abcde"), 2, 3, "1234567890", 1, S("ab1"));
+ test(S("abcde"), 2, 3, "1234567890", 5, S("ab12345"));
+ test(S("abcde"), 2, 3, "1234567890", 9, S("ab123456789"));
+ test(S("abcde"), 2, 3, "1234567890", 10, S("ab1234567890"));
+ test(S("abcde"), 2, 3, "12345678901234567890", 0, S("ab"));
+ test(S("abcde"), 2, 3, "12345678901234567890", 1, S("ab1"));
+ test(S("abcde"), 2, 3, "12345678901234567890", 10, S("ab1234567890"));
+ test(S("abcde"), 2, 3, "12345678901234567890", 19, S("ab1234567890123456789"));
+ test(S("abcde"), 2, 3, "12345678901234567890", 20, S("ab12345678901234567890"));
+ test(S("abcde"), 4, 0, "", 0, S("abcde"));
+ test(S("abcde"), 4, 0, "12345", 0, S("abcde"));
+ test(S("abcde"), 4, 0, "12345", 1, S("abcd1e"));
+ test(S("abcde"), 4, 0, "12345", 2, S("abcd12e"));
+ test(S("abcde"), 4, 0, "12345", 4, S("abcd1234e"));
+ test(S("abcde"), 4, 0, "12345", 5, S("abcd12345e"));
+ test(S("abcde"), 4, 0, "1234567890", 0, S("abcde"));
+ test(S("abcde"), 4, 0, "1234567890", 1, S("abcd1e"));
+ test(S("abcde"), 4, 0, "1234567890", 5, S("abcd12345e"));
+ test(S("abcde"), 4, 0, "1234567890", 9, S("abcd123456789e"));
+ test(S("abcde"), 4, 0, "1234567890", 10, S("abcd1234567890e"));
+ test(S("abcde"), 4, 0, "12345678901234567890", 0, S("abcde"));
+ test(S("abcde"), 4, 0, "12345678901234567890", 1, S("abcd1e"));
+ test(S("abcde"), 4, 0, "12345678901234567890", 10, S("abcd1234567890e"));
+ test(S("abcde"), 4, 0, "12345678901234567890", 19, S("abcd1234567890123456789e"));
+ test(S("abcde"), 4, 0, "12345678901234567890", 20, S("abcd12345678901234567890e"));
+ test(S("abcde"), 4, 1, "", 0, S("abcd"));
+ test(S("abcde"), 4, 1, "12345", 0, S("abcd"));
+ test(S("abcde"), 4, 1, "12345", 1, S("abcd1"));
+ test(S("abcde"), 4, 1, "12345", 2, S("abcd12"));
+ test(S("abcde"), 4, 1, "12345", 4, S("abcd1234"));
+ test(S("abcde"), 4, 1, "12345", 5, S("abcd12345"));
+ test(S("abcde"), 4, 1, "1234567890", 0, S("abcd"));
+ test(S("abcde"), 4, 1, "1234567890", 1, S("abcd1"));
+ test(S("abcde"), 4, 1, "1234567890", 5, S("abcd12345"));
+ test(S("abcde"), 4, 1, "1234567890", 9, S("abcd123456789"));
+ test(S("abcde"), 4, 1, "1234567890", 10, S("abcd1234567890"));
+ test(S("abcde"), 4, 1, "12345678901234567890", 0, S("abcd"));
+ test(S("abcde"), 4, 1, "12345678901234567890", 1, S("abcd1"));
+ test(S("abcde"), 4, 1, "12345678901234567890", 10, S("abcd1234567890"));
+ test(S("abcde"), 4, 1, "12345678901234567890", 19, S("abcd1234567890123456789"));
+ test(S("abcde"), 4, 1, "12345678901234567890", 20, S("abcd12345678901234567890"));
+ test(S("abcde"), 5, 0, "", 0, S("abcde"));
+ test(S("abcde"), 5, 0, "12345", 0, S("abcde"));
+ test(S("abcde"), 5, 0, "12345", 1, S("abcde1"));
+ test(S("abcde"), 5, 0, "12345", 2, S("abcde12"));
+ test(S("abcde"), 5, 0, "12345", 4, S("abcde1234"));
+ test(S("abcde"), 5, 0, "12345", 5, S("abcde12345"));
+ test(S("abcde"), 5, 0, "1234567890", 0, S("abcde"));
+ test(S("abcde"), 5, 0, "1234567890", 1, S("abcde1"));
+ test(S("abcde"), 5, 0, "1234567890", 5, S("abcde12345"));
+ test(S("abcde"), 5, 0, "1234567890", 9, S("abcde123456789"));
+ test(S("abcde"), 5, 0, "1234567890", 10, S("abcde1234567890"));
+ test(S("abcde"), 5, 0, "12345678901234567890", 0, S("abcde"));
+ test(S("abcde"), 5, 0, "12345678901234567890", 1, S("abcde1"));
+ test(S("abcde"), 5, 0, "12345678901234567890", 10, S("abcde1234567890"));
+ test(S("abcde"), 5, 0, "12345678901234567890", 19, S("abcde1234567890123456789"));
+ test(S("abcde"), 5, 0, "12345678901234567890", 20, S("abcde12345678901234567890"));
+ test(S("abcdefghij"), 0, 0, "", 0, S("abcdefghij"));
+ test(S("abcdefghij"), 0, 0, "12345", 0, S("abcdefghij"));
+ test(S("abcdefghij"), 0, 0, "12345", 1, S("1abcdefghij"));
+ test(S("abcdefghij"), 0, 0, "12345", 2, S("12abcdefghij"));
+ test(S("abcdefghij"), 0, 0, "12345", 4, S("1234abcdefghij"));
+ test(S("abcdefghij"), 0, 0, "12345", 5, S("12345abcdefghij"));
+ test(S("abcdefghij"), 0, 0, "1234567890", 0, S("abcdefghij"));
+ test(S("abcdefghij"), 0, 0, "1234567890", 1, S("1abcdefghij"));
+ test(S("abcdefghij"), 0, 0, "1234567890", 5, S("12345abcdefghij"));
+ test(S("abcdefghij"), 0, 0, "1234567890", 9, S("123456789abcdefghij"));
+ test(S("abcdefghij"), 0, 0, "1234567890", 10, S("1234567890abcdefghij"));
+ test(S("abcdefghij"), 0, 0, "12345678901234567890", 0, S("abcdefghij"));
+}
+
+template <class S>
+void test3()
+{
+ test(S("abcdefghij"), 0, 0, "12345678901234567890", 1, S("1abcdefghij"));
+ test(S("abcdefghij"), 0, 0, "12345678901234567890", 10, S("1234567890abcdefghij"));
+ test(S("abcdefghij"), 0, 0, "12345678901234567890", 19, S("1234567890123456789abcdefghij"));
+ test(S("abcdefghij"), 0, 0, "12345678901234567890", 20, S("12345678901234567890abcdefghij"));
+ test(S("abcdefghij"), 0, 1, "", 0, S("bcdefghij"));
+ test(S("abcdefghij"), 0, 1, "12345", 0, S("bcdefghij"));
+ test(S("abcdefghij"), 0, 1, "12345", 1, S("1bcdefghij"));
+ test(S("abcdefghij"), 0, 1, "12345", 2, S("12bcdefghij"));
+ test(S("abcdefghij"), 0, 1, "12345", 4, S("1234bcdefghij"));
+ test(S("abcdefghij"), 0, 1, "12345", 5, S("12345bcdefghij"));
+ test(S("abcdefghij"), 0, 1, "1234567890", 0, S("bcdefghij"));
+ test(S("abcdefghij"), 0, 1, "1234567890", 1, S("1bcdefghij"));
+ test(S("abcdefghij"), 0, 1, "1234567890", 5, S("12345bcdefghij"));
+ test(S("abcdefghij"), 0, 1, "1234567890", 9, S("123456789bcdefghij"));
+ test(S("abcdefghij"), 0, 1, "1234567890", 10, S("1234567890bcdefghij"));
+ test(S("abcdefghij"), 0, 1, "12345678901234567890", 0, S("bcdefghij"));
+ test(S("abcdefghij"), 0, 1, "12345678901234567890", 1, S("1bcdefghij"));
+ test(S("abcdefghij"), 0, 1, "12345678901234567890", 10, S("1234567890bcdefghij"));
+ test(S("abcdefghij"), 0, 1, "12345678901234567890", 19, S("1234567890123456789bcdefghij"));
+ test(S("abcdefghij"), 0, 1, "12345678901234567890", 20, S("12345678901234567890bcdefghij"));
+ test(S("abcdefghij"), 0, 5, "", 0, S("fghij"));
+ test(S("abcdefghij"), 0, 5, "12345", 0, S("fghij"));
+ test(S("abcdefghij"), 0, 5, "12345", 1, S("1fghij"));
+ test(S("abcdefghij"), 0, 5, "12345", 2, S("12fghij"));
+ test(S("abcdefghij"), 0, 5, "12345", 4, S("1234fghij"));
+ test(S("abcdefghij"), 0, 5, "12345", 5, S("12345fghij"));
+ test(S("abcdefghij"), 0, 5, "1234567890", 0, S("fghij"));
+ test(S("abcdefghij"), 0, 5, "1234567890", 1, S("1fghij"));
+ test(S("abcdefghij"), 0, 5, "1234567890", 5, S("12345fghij"));
+ test(S("abcdefghij"), 0, 5, "1234567890", 9, S("123456789fghij"));
+ test(S("abcdefghij"), 0, 5, "1234567890", 10, S("1234567890fghij"));
+ test(S("abcdefghij"), 0, 5, "12345678901234567890", 0, S("fghij"));
+ test(S("abcdefghij"), 0, 5, "12345678901234567890", 1, S("1fghij"));
+ test(S("abcdefghij"), 0, 5, "12345678901234567890", 10, S("1234567890fghij"));
+ test(S("abcdefghij"), 0, 5, "12345678901234567890", 19, S("1234567890123456789fghij"));
+ test(S("abcdefghij"), 0, 5, "12345678901234567890", 20, S("12345678901234567890fghij"));
+ test(S("abcdefghij"), 0, 9, "", 0, S("j"));
+ test(S("abcdefghij"), 0, 9, "12345", 0, S("j"));
+ test(S("abcdefghij"), 0, 9, "12345", 1, S("1j"));
+ test(S("abcdefghij"), 0, 9, "12345", 2, S("12j"));
+ test(S("abcdefghij"), 0, 9, "12345", 4, S("1234j"));
+ test(S("abcdefghij"), 0, 9, "12345", 5, S("12345j"));
+ test(S("abcdefghij"), 0, 9, "1234567890", 0, S("j"));
+ test(S("abcdefghij"), 0, 9, "1234567890", 1, S("1j"));
+ test(S("abcdefghij"), 0, 9, "1234567890", 5, S("12345j"));
+ test(S("abcdefghij"), 0, 9, "1234567890", 9, S("123456789j"));
+ test(S("abcdefghij"), 0, 9, "1234567890", 10, S("1234567890j"));
+ test(S("abcdefghij"), 0, 9, "12345678901234567890", 0, S("j"));
+ test(S("abcdefghij"), 0, 9, "12345678901234567890", 1, S("1j"));
+ test(S("abcdefghij"), 0, 9, "12345678901234567890", 10, S("1234567890j"));
+ test(S("abcdefghij"), 0, 9, "12345678901234567890", 19, S("1234567890123456789j"));
+ test(S("abcdefghij"), 0, 9, "12345678901234567890", 20, S("12345678901234567890j"));
+ test(S("abcdefghij"), 0, 10, "", 0, S(""));
+ test(S("abcdefghij"), 0, 10, "12345", 0, S(""));
+ test(S("abcdefghij"), 0, 10, "12345", 1, S("1"));
+ test(S("abcdefghij"), 0, 10, "12345", 2, S("12"));
+ test(S("abcdefghij"), 0, 10, "12345", 4, S("1234"));
+ test(S("abcdefghij"), 0, 10, "12345", 5, S("12345"));
+ test(S("abcdefghij"), 0, 10, "1234567890", 0, S(""));
+ test(S("abcdefghij"), 0, 10, "1234567890", 1, S("1"));
+ test(S("abcdefghij"), 0, 10, "1234567890", 5, S("12345"));
+ test(S("abcdefghij"), 0, 10, "1234567890", 9, S("123456789"));
+ test(S("abcdefghij"), 0, 10, "1234567890", 10, S("1234567890"));
+ test(S("abcdefghij"), 0, 10, "12345678901234567890", 0, S(""));
+ test(S("abcdefghij"), 0, 10, "12345678901234567890", 1, S("1"));
+ test(S("abcdefghij"), 0, 10, "12345678901234567890", 10, S("1234567890"));
+ test(S("abcdefghij"), 0, 10, "12345678901234567890", 19, S("1234567890123456789"));
+ test(S("abcdefghij"), 0, 10, "12345678901234567890", 20, S("12345678901234567890"));
+ test(S("abcdefghij"), 1, 0, "", 0, S("abcdefghij"));
+ test(S("abcdefghij"), 1, 0, "12345", 0, S("abcdefghij"));
+ test(S("abcdefghij"), 1, 0, "12345", 1, S("a1bcdefghij"));
+ test(S("abcdefghij"), 1, 0, "12345", 2, S("a12bcdefghij"));
+ test(S("abcdefghij"), 1, 0, "12345", 4, S("a1234bcdefghij"));
+ test(S("abcdefghij"), 1, 0, "12345", 5, S("a12345bcdefghij"));
+ test(S("abcdefghij"), 1, 0, "1234567890", 0, S("abcdefghij"));
+ test(S("abcdefghij"), 1, 0, "1234567890", 1, S("a1bcdefghij"));
+ test(S("abcdefghij"), 1, 0, "1234567890", 5, S("a12345bcdefghij"));
+ test(S("abcdefghij"), 1, 0, "1234567890", 9, S("a123456789bcdefghij"));
+ test(S("abcdefghij"), 1, 0, "1234567890", 10, S("a1234567890bcdefghij"));
+ test(S("abcdefghij"), 1, 0, "12345678901234567890", 0, S("abcdefghij"));
+ test(S("abcdefghij"), 1, 0, "12345678901234567890", 1, S("a1bcdefghij"));
+ test(S("abcdefghij"), 1, 0, "12345678901234567890", 10, S("a1234567890bcdefghij"));
+ test(S("abcdefghij"), 1, 0, "12345678901234567890", 19, S("a1234567890123456789bcdefghij"));
+ test(S("abcdefghij"), 1, 0, "12345678901234567890", 20, S("a12345678901234567890bcdefghij"));
+ test(S("abcdefghij"), 1, 1, "", 0, S("acdefghij"));
+ test(S("abcdefghij"), 1, 1, "12345", 0, S("acdefghij"));
+ test(S("abcdefghij"), 1, 1, "12345", 1, S("a1cdefghij"));
+ test(S("abcdefghij"), 1, 1, "12345", 2, S("a12cdefghij"));
+ test(S("abcdefghij"), 1, 1, "12345", 4, S("a1234cdefghij"));
+ test(S("abcdefghij"), 1, 1, "12345", 5, S("a12345cdefghij"));
+ test(S("abcdefghij"), 1, 1, "1234567890", 0, S("acdefghij"));
+ test(S("abcdefghij"), 1, 1, "1234567890", 1, S("a1cdefghij"));
+ test(S("abcdefghij"), 1, 1, "1234567890", 5, S("a12345cdefghij"));
+ test(S("abcdefghij"), 1, 1, "1234567890", 9, S("a123456789cdefghij"));
+ test(S("abcdefghij"), 1, 1, "1234567890", 10, S("a1234567890cdefghij"));
+ test(S("abcdefghij"), 1, 1, "12345678901234567890", 0, S("acdefghij"));
+ test(S("abcdefghij"), 1, 1, "12345678901234567890", 1, S("a1cdefghij"));
+ test(S("abcdefghij"), 1, 1, "12345678901234567890", 10, S("a1234567890cdefghij"));
+ test(S("abcdefghij"), 1, 1, "12345678901234567890", 19, S("a1234567890123456789cdefghij"));
+ test(S("abcdefghij"), 1, 1, "12345678901234567890", 20, S("a12345678901234567890cdefghij"));
+}
+
+template <class S>
+void test4()
+{
+ test(S("abcdefghij"), 1, 4, "", 0, S("afghij"));
+ test(S("abcdefghij"), 1, 4, "12345", 0, S("afghij"));
+ test(S("abcdefghij"), 1, 4, "12345", 1, S("a1fghij"));
+ test(S("abcdefghij"), 1, 4, "12345", 2, S("a12fghij"));
+ test(S("abcdefghij"), 1, 4, "12345", 4, S("a1234fghij"));
+ test(S("abcdefghij"), 1, 4, "12345", 5, S("a12345fghij"));
+ test(S("abcdefghij"), 1, 4, "1234567890", 0, S("afghij"));
+ test(S("abcdefghij"), 1, 4, "1234567890", 1, S("a1fghij"));
+ test(S("abcdefghij"), 1, 4, "1234567890", 5, S("a12345fghij"));
+ test(S("abcdefghij"), 1, 4, "1234567890", 9, S("a123456789fghij"));
+ test(S("abcdefghij"), 1, 4, "1234567890", 10, S("a1234567890fghij"));
+ test(S("abcdefghij"), 1, 4, "12345678901234567890", 0, S("afghij"));
+ test(S("abcdefghij"), 1, 4, "12345678901234567890", 1, S("a1fghij"));
+ test(S("abcdefghij"), 1, 4, "12345678901234567890", 10, S("a1234567890fghij"));
+ test(S("abcdefghij"), 1, 4, "12345678901234567890", 19, S("a1234567890123456789fghij"));
+ test(S("abcdefghij"), 1, 4, "12345678901234567890", 20, S("a12345678901234567890fghij"));
+ test(S("abcdefghij"), 1, 8, "", 0, S("aj"));
+ test(S("abcdefghij"), 1, 8, "12345", 0, S("aj"));
+ test(S("abcdefghij"), 1, 8, "12345", 1, S("a1j"));
+ test(S("abcdefghij"), 1, 8, "12345", 2, S("a12j"));
+ test(S("abcdefghij"), 1, 8, "12345", 4, S("a1234j"));
+ test(S("abcdefghij"), 1, 8, "12345", 5, S("a12345j"));
+ test(S("abcdefghij"), 1, 8, "1234567890", 0, S("aj"));
+ test(S("abcdefghij"), 1, 8, "1234567890", 1, S("a1j"));
+ test(S("abcdefghij"), 1, 8, "1234567890", 5, S("a12345j"));
+ test(S("abcdefghij"), 1, 8, "1234567890", 9, S("a123456789j"));
+ test(S("abcdefghij"), 1, 8, "1234567890", 10, S("a1234567890j"));
+ test(S("abcdefghij"), 1, 8, "12345678901234567890", 0, S("aj"));
+ test(S("abcdefghij"), 1, 8, "12345678901234567890", 1, S("a1j"));
+ test(S("abcdefghij"), 1, 8, "12345678901234567890", 10, S("a1234567890j"));
+ test(S("abcdefghij"), 1, 8, "12345678901234567890", 19, S("a1234567890123456789j"));
+ test(S("abcdefghij"), 1, 8, "12345678901234567890", 20, S("a12345678901234567890j"));
+ test(S("abcdefghij"), 1, 9, "", 0, S("a"));
+ test(S("abcdefghij"), 1, 9, "12345", 0, S("a"));
+ test(S("abcdefghij"), 1, 9, "12345", 1, S("a1"));
+ test(S("abcdefghij"), 1, 9, "12345", 2, S("a12"));
+ test(S("abcdefghij"), 1, 9, "12345", 4, S("a1234"));
+ test(S("abcdefghij"), 1, 9, "12345", 5, S("a12345"));
+ test(S("abcdefghij"), 1, 9, "1234567890", 0, S("a"));
+ test(S("abcdefghij"), 1, 9, "1234567890", 1, S("a1"));
+ test(S("abcdefghij"), 1, 9, "1234567890", 5, S("a12345"));
+ test(S("abcdefghij"), 1, 9, "1234567890", 9, S("a123456789"));
+ test(S("abcdefghij"), 1, 9, "1234567890", 10, S("a1234567890"));
+ test(S("abcdefghij"), 1, 9, "12345678901234567890", 0, S("a"));
+ test(S("abcdefghij"), 1, 9, "12345678901234567890", 1, S("a1"));
+ test(S("abcdefghij"), 1, 9, "12345678901234567890", 10, S("a1234567890"));
+ test(S("abcdefghij"), 1, 9, "12345678901234567890", 19, S("a1234567890123456789"));
+ test(S("abcdefghij"), 1, 9, "12345678901234567890", 20, S("a12345678901234567890"));
+ test(S("abcdefghij"), 5, 0, "", 0, S("abcdefghij"));
+ test(S("abcdefghij"), 5, 0, "12345", 0, S("abcdefghij"));
+ test(S("abcdefghij"), 5, 0, "12345", 1, S("abcde1fghij"));
+ test(S("abcdefghij"), 5, 0, "12345", 2, S("abcde12fghij"));
+ test(S("abcdefghij"), 5, 0, "12345", 4, S("abcde1234fghij"));
+ test(S("abcdefghij"), 5, 0, "12345", 5, S("abcde12345fghij"));
+ test(S("abcdefghij"), 5, 0, "1234567890", 0, S("abcdefghij"));
+ test(S("abcdefghij"), 5, 0, "1234567890", 1, S("abcde1fghij"));
+ test(S("abcdefghij"), 5, 0, "1234567890", 5, S("abcde12345fghij"));
+ test(S("abcdefghij"), 5, 0, "1234567890", 9, S("abcde123456789fghij"));
+ test(S("abcdefghij"), 5, 0, "1234567890", 10, S("abcde1234567890fghij"));
+ test(S("abcdefghij"), 5, 0, "12345678901234567890", 0, S("abcdefghij"));
+ test(S("abcdefghij"), 5, 0, "12345678901234567890", 1, S("abcde1fghij"));
+ test(S("abcdefghij"), 5, 0, "12345678901234567890", 10, S("abcde1234567890fghij"));
+ test(S("abcdefghij"), 5, 0, "12345678901234567890", 19, S("abcde1234567890123456789fghij"));
+ test(S("abcdefghij"), 5, 0, "12345678901234567890", 20, S("abcde12345678901234567890fghij"));
+ test(S("abcdefghij"), 5, 1, "", 0, S("abcdeghij"));
+ test(S("abcdefghij"), 5, 1, "12345", 0, S("abcdeghij"));
+ test(S("abcdefghij"), 5, 1, "12345", 1, S("abcde1ghij"));
+ test(S("abcdefghij"), 5, 1, "12345", 2, S("abcde12ghij"));
+ test(S("abcdefghij"), 5, 1, "12345", 4, S("abcde1234ghij"));
+ test(S("abcdefghij"), 5, 1, "12345", 5, S("abcde12345ghij"));
+ test(S("abcdefghij"), 5, 1, "1234567890", 0, S("abcdeghij"));
+ test(S("abcdefghij"), 5, 1, "1234567890", 1, S("abcde1ghij"));
+ test(S("abcdefghij"), 5, 1, "1234567890", 5, S("abcde12345ghij"));
+ test(S("abcdefghij"), 5, 1, "1234567890", 9, S("abcde123456789ghij"));
+ test(S("abcdefghij"), 5, 1, "1234567890", 10, S("abcde1234567890ghij"));
+ test(S("abcdefghij"), 5, 1, "12345678901234567890", 0, S("abcdeghij"));
+ test(S("abcdefghij"), 5, 1, "12345678901234567890", 1, S("abcde1ghij"));
+ test(S("abcdefghij"), 5, 1, "12345678901234567890", 10, S("abcde1234567890ghij"));
+ test(S("abcdefghij"), 5, 1, "12345678901234567890", 19, S("abcde1234567890123456789ghij"));
+ test(S("abcdefghij"), 5, 1, "12345678901234567890", 20, S("abcde12345678901234567890ghij"));
+ test(S("abcdefghij"), 5, 2, "", 0, S("abcdehij"));
+ test(S("abcdefghij"), 5, 2, "12345", 0, S("abcdehij"));
+ test(S("abcdefghij"), 5, 2, "12345", 1, S("abcde1hij"));
+ test(S("abcdefghij"), 5, 2, "12345", 2, S("abcde12hij"));
+ test(S("abcdefghij"), 5, 2, "12345", 4, S("abcde1234hij"));
+ test(S("abcdefghij"), 5, 2, "12345", 5, S("abcde12345hij"));
+ test(S("abcdefghij"), 5, 2, "1234567890", 0, S("abcdehij"));
+ test(S("abcdefghij"), 5, 2, "1234567890", 1, S("abcde1hij"));
+ test(S("abcdefghij"), 5, 2, "1234567890", 5, S("abcde12345hij"));
+ test(S("abcdefghij"), 5, 2, "1234567890", 9, S("abcde123456789hij"));
+ test(S("abcdefghij"), 5, 2, "1234567890", 10, S("abcde1234567890hij"));
+ test(S("abcdefghij"), 5, 2, "12345678901234567890", 0, S("abcdehij"));
+ test(S("abcdefghij"), 5, 2, "12345678901234567890", 1, S("abcde1hij"));
+ test(S("abcdefghij"), 5, 2, "12345678901234567890", 10, S("abcde1234567890hij"));
+ test(S("abcdefghij"), 5, 2, "12345678901234567890", 19, S("abcde1234567890123456789hij"));
+ test(S("abcdefghij"), 5, 2, "12345678901234567890", 20, S("abcde12345678901234567890hij"));
+ test(S("abcdefghij"), 5, 4, "", 0, S("abcdej"));
+ test(S("abcdefghij"), 5, 4, "12345", 0, S("abcdej"));
+ test(S("abcdefghij"), 5, 4, "12345", 1, S("abcde1j"));
+ test(S("abcdefghij"), 5, 4, "12345", 2, S("abcde12j"));
+}
+
+template <class S>
+void test5()
+{
+ test(S("abcdefghij"), 5, 4, "12345", 4, S("abcde1234j"));
+ test(S("abcdefghij"), 5, 4, "12345", 5, S("abcde12345j"));
+ test(S("abcdefghij"), 5, 4, "1234567890", 0, S("abcdej"));
+ test(S("abcdefghij"), 5, 4, "1234567890", 1, S("abcde1j"));
+ test(S("abcdefghij"), 5, 4, "1234567890", 5, S("abcde12345j"));
+ test(S("abcdefghij"), 5, 4, "1234567890", 9, S("abcde123456789j"));
+ test(S("abcdefghij"), 5, 4, "1234567890", 10, S("abcde1234567890j"));
+ test(S("abcdefghij"), 5, 4, "12345678901234567890", 0, S("abcdej"));
+ test(S("abcdefghij"), 5, 4, "12345678901234567890", 1, S("abcde1j"));
+ test(S("abcdefghij"), 5, 4, "12345678901234567890", 10, S("abcde1234567890j"));
+ test(S("abcdefghij"), 5, 4, "12345678901234567890", 19, S("abcde1234567890123456789j"));
+ test(S("abcdefghij"), 5, 4, "12345678901234567890", 20, S("abcde12345678901234567890j"));
+ test(S("abcdefghij"), 5, 5, "", 0, S("abcde"));
+ test(S("abcdefghij"), 5, 5, "12345", 0, S("abcde"));
+ test(S("abcdefghij"), 5, 5, "12345", 1, S("abcde1"));
+ test(S("abcdefghij"), 5, 5, "12345", 2, S("abcde12"));
+ test(S("abcdefghij"), 5, 5, "12345", 4, S("abcde1234"));
+ test(S("abcdefghij"), 5, 5, "12345", 5, S("abcde12345"));
+ test(S("abcdefghij"), 5, 5, "1234567890", 0, S("abcde"));
+ test(S("abcdefghij"), 5, 5, "1234567890", 1, S("abcde1"));
+ test(S("abcdefghij"), 5, 5, "1234567890", 5, S("abcde12345"));
+ test(S("abcdefghij"), 5, 5, "1234567890", 9, S("abcde123456789"));
+ test(S("abcdefghij"), 5, 5, "1234567890", 10, S("abcde1234567890"));
+ test(S("abcdefghij"), 5, 5, "12345678901234567890", 0, S("abcde"));
+ test(S("abcdefghij"), 5, 5, "12345678901234567890", 1, S("abcde1"));
+ test(S("abcdefghij"), 5, 5, "12345678901234567890", 10, S("abcde1234567890"));
+ test(S("abcdefghij"), 5, 5, "12345678901234567890", 19, S("abcde1234567890123456789"));
+ test(S("abcdefghij"), 5, 5, "12345678901234567890", 20, S("abcde12345678901234567890"));
+ test(S("abcdefghij"), 9, 0, "", 0, S("abcdefghij"));
+ test(S("abcdefghij"), 9, 0, "12345", 0, S("abcdefghij"));
+ test(S("abcdefghij"), 9, 0, "12345", 1, S("abcdefghi1j"));
+ test(S("abcdefghij"), 9, 0, "12345", 2, S("abcdefghi12j"));
+ test(S("abcdefghij"), 9, 0, "12345", 4, S("abcdefghi1234j"));
+ test(S("abcdefghij"), 9, 0, "12345", 5, S("abcdefghi12345j"));
+ test(S("abcdefghij"), 9, 0, "1234567890", 0, S("abcdefghij"));
+ test(S("abcdefghij"), 9, 0, "1234567890", 1, S("abcdefghi1j"));
+ test(S("abcdefghij"), 9, 0, "1234567890", 5, S("abcdefghi12345j"));
+ test(S("abcdefghij"), 9, 0, "1234567890", 9, S("abcdefghi123456789j"));
+ test(S("abcdefghij"), 9, 0, "1234567890", 10, S("abcdefghi1234567890j"));
+ test(S("abcdefghij"), 9, 0, "12345678901234567890", 0, S("abcdefghij"));
+ test(S("abcdefghij"), 9, 0, "12345678901234567890", 1, S("abcdefghi1j"));
+ test(S("abcdefghij"), 9, 0, "12345678901234567890", 10, S("abcdefghi1234567890j"));
+ test(S("abcdefghij"), 9, 0, "12345678901234567890", 19, S("abcdefghi1234567890123456789j"));
+ test(S("abcdefghij"), 9, 0, "12345678901234567890", 20, S("abcdefghi12345678901234567890j"));
+ test(S("abcdefghij"), 9, 1, "", 0, S("abcdefghi"));
+ test(S("abcdefghij"), 9, 1, "12345", 0, S("abcdefghi"));
+ test(S("abcdefghij"), 9, 1, "12345", 1, S("abcdefghi1"));
+ test(S("abcdefghij"), 9, 1, "12345", 2, S("abcdefghi12"));
+ test(S("abcdefghij"), 9, 1, "12345", 4, S("abcdefghi1234"));
+ test(S("abcdefghij"), 9, 1, "12345", 5, S("abcdefghi12345"));
+ test(S("abcdefghij"), 9, 1, "1234567890", 0, S("abcdefghi"));
+ test(S("abcdefghij"), 9, 1, "1234567890", 1, S("abcdefghi1"));
+ test(S("abcdefghij"), 9, 1, "1234567890", 5, S("abcdefghi12345"));
+ test(S("abcdefghij"), 9, 1, "1234567890", 9, S("abcdefghi123456789"));
+ test(S("abcdefghij"), 9, 1, "1234567890", 10, S("abcdefghi1234567890"));
+ test(S("abcdefghij"), 9, 1, "12345678901234567890", 0, S("abcdefghi"));
+ test(S("abcdefghij"), 9, 1, "12345678901234567890", 1, S("abcdefghi1"));
+ test(S("abcdefghij"), 9, 1, "12345678901234567890", 10, S("abcdefghi1234567890"));
+ test(S("abcdefghij"), 9, 1, "12345678901234567890", 19, S("abcdefghi1234567890123456789"));
+ test(S("abcdefghij"), 9, 1, "12345678901234567890", 20, S("abcdefghi12345678901234567890"));
+ test(S("abcdefghij"), 10, 0, "", 0, S("abcdefghij"));
+ test(S("abcdefghij"), 10, 0, "12345", 0, S("abcdefghij"));
+ test(S("abcdefghij"), 10, 0, "12345", 1, S("abcdefghij1"));
+ test(S("abcdefghij"), 10, 0, "12345", 2, S("abcdefghij12"));
+ test(S("abcdefghij"), 10, 0, "12345", 4, S("abcdefghij1234"));
+ test(S("abcdefghij"), 10, 0, "12345", 5, S("abcdefghij12345"));
+ test(S("abcdefghij"), 10, 0, "1234567890", 0, S("abcdefghij"));
+ test(S("abcdefghij"), 10, 0, "1234567890", 1, S("abcdefghij1"));
+ test(S("abcdefghij"), 10, 0, "1234567890", 5, S("abcdefghij12345"));
+ test(S("abcdefghij"), 10, 0, "1234567890", 9, S("abcdefghij123456789"));
+ test(S("abcdefghij"), 10, 0, "1234567890", 10, S("abcdefghij1234567890"));
+ test(S("abcdefghij"), 10, 0, "12345678901234567890", 0, S("abcdefghij"));
+ test(S("abcdefghij"), 10, 0, "12345678901234567890", 1, S("abcdefghij1"));
+ test(S("abcdefghij"), 10, 0, "12345678901234567890", 10, S("abcdefghij1234567890"));
+ test(S("abcdefghij"), 10, 0, "12345678901234567890", 19, S("abcdefghij1234567890123456789"));
+ test(S("abcdefghij"), 10, 0, "12345678901234567890", 20, S("abcdefghij12345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, "", 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, "12345", 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, "12345", 1, S("1abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, "12345", 2, S("12abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, "12345", 4, S("1234abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, "12345", 5, S("12345abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, "1234567890", 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, "1234567890", 1, S("1abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, "1234567890", 5, S("12345abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, "1234567890", 9, S("123456789abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, "1234567890", 10, S("1234567890abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, "12345678901234567890", 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, "12345678901234567890", 1, S("1abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, "12345678901234567890", 10, S("1234567890abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, "12345678901234567890", 19, S("1234567890123456789abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, "12345678901234567890", 20, S("12345678901234567890abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, "", 0, S("bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, "12345", 0, S("bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, "12345", 1, S("1bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, "12345", 2, S("12bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, "12345", 4, S("1234bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, "12345", 5, S("12345bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, "1234567890", 0, S("bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, "1234567890", 1, S("1bcdefghijklmnopqrst"));
+}
+
+template <class S>
+void test6()
+{
+ test(S("abcdefghijklmnopqrst"), 0, 1, "1234567890", 5, S("12345bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, "1234567890", 9, S("123456789bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, "1234567890", 10, S("1234567890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, "12345678901234567890", 0, S("bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, "12345678901234567890", 1, S("1bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, "12345678901234567890", 10, S("1234567890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, "12345678901234567890", 19, S("1234567890123456789bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, "12345678901234567890", 20, S("12345678901234567890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, "", 0, S("klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, "12345", 0, S("klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, "12345", 1, S("1klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, "12345", 2, S("12klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, "12345", 4, S("1234klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, "12345", 5, S("12345klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, "1234567890", 0, S("klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, "1234567890", 1, S("1klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, "1234567890", 5, S("12345klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, "1234567890", 9, S("123456789klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, "1234567890", 10, S("1234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, "12345678901234567890", 0, S("klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, "12345678901234567890", 1, S("1klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, "12345678901234567890", 10, S("1234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, "12345678901234567890", 19, S("1234567890123456789klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, "12345678901234567890", 20, S("12345678901234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, "", 0, S("t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, "12345", 0, S("t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, "12345", 1, S("1t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, "12345", 2, S("12t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, "12345", 4, S("1234t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, "12345", 5, S("12345t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, "1234567890", 0, S("t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, "1234567890", 1, S("1t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, "1234567890", 5, S("12345t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, "1234567890", 9, S("123456789t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, "1234567890", 10, S("1234567890t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, "12345678901234567890", 0, S("t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, "12345678901234567890", 1, S("1t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, "12345678901234567890", 10, S("1234567890t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, "12345678901234567890", 19, S("1234567890123456789t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, "12345678901234567890", 20, S("12345678901234567890t"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, "", 0, S(""));
+ test(S("abcdefghijklmnopqrst"), 0, 20, "12345", 0, S(""));
+ test(S("abcdefghijklmnopqrst"), 0, 20, "12345", 1, S("1"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, "12345", 2, S("12"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, "12345", 4, S("1234"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, "12345", 5, S("12345"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, "1234567890", 0, S(""));
+ test(S("abcdefghijklmnopqrst"), 0, 20, "1234567890", 1, S("1"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, "1234567890", 5, S("12345"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, "1234567890", 9, S("123456789"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, "1234567890", 10, S("1234567890"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, "12345678901234567890", 0, S(""));
+ test(S("abcdefghijklmnopqrst"), 0, 20, "12345678901234567890", 1, S("1"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, "12345678901234567890", 10, S("1234567890"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, "12345678901234567890", 19, S("1234567890123456789"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, "12345678901234567890", 20, S("12345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, "", 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, "12345", 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, "12345", 1, S("a1bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, "12345", 2, S("a12bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, "12345", 4, S("a1234bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, "12345", 5, S("a12345bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, "1234567890", 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, "1234567890", 1, S("a1bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, "1234567890", 5, S("a12345bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, "1234567890", 9, S("a123456789bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, "1234567890", 10, S("a1234567890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, "12345678901234567890", 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, "12345678901234567890", 1, S("a1bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, "12345678901234567890", 10, S("a1234567890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, "12345678901234567890", 19, S("a1234567890123456789bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, "12345678901234567890", 20, S("a12345678901234567890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, "", 0, S("acdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, "12345", 0, S("acdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, "12345", 1, S("a1cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, "12345", 2, S("a12cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, "12345", 4, S("a1234cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, "12345", 5, S("a12345cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, "1234567890", 0, S("acdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, "1234567890", 1, S("a1cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, "1234567890", 5, S("a12345cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, "1234567890", 9, S("a123456789cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, "1234567890", 10, S("a1234567890cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, "12345678901234567890", 0, S("acdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, "12345678901234567890", 1, S("a1cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, "12345678901234567890", 10, S("a1234567890cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, "12345678901234567890", 19, S("a1234567890123456789cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, "12345678901234567890", 20, S("a12345678901234567890cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, "", 0, S("aklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, "12345", 0, S("aklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, "12345", 1, S("a1klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, "12345", 2, S("a12klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, "12345", 4, S("a1234klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, "12345", 5, S("a12345klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, "1234567890", 0, S("aklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, "1234567890", 1, S("a1klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, "1234567890", 5, S("a12345klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, "1234567890", 9, S("a123456789klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, "1234567890", 10, S("a1234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, "12345678901234567890", 0, S("aklmnopqrst"));
+}
+
+template <class S>
+void test7()
+{
+ test(S("abcdefghijklmnopqrst"), 1, 9, "12345678901234567890", 1, S("a1klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, "12345678901234567890", 10, S("a1234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, "12345678901234567890", 19, S("a1234567890123456789klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, "12345678901234567890", 20, S("a12345678901234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, "", 0, S("at"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, "12345", 0, S("at"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, "12345", 1, S("a1t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, "12345", 2, S("a12t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, "12345", 4, S("a1234t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, "12345", 5, S("a12345t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, "1234567890", 0, S("at"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, "1234567890", 1, S("a1t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, "1234567890", 5, S("a12345t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, "1234567890", 9, S("a123456789t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, "1234567890", 10, S("a1234567890t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, "12345678901234567890", 0, S("at"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, "12345678901234567890", 1, S("a1t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, "12345678901234567890", 10, S("a1234567890t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, "12345678901234567890", 19, S("a1234567890123456789t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, "12345678901234567890", 20, S("a12345678901234567890t"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, "", 0, S("a"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, "12345", 0, S("a"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, "12345", 1, S("a1"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, "12345", 2, S("a12"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, "12345", 4, S("a1234"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, "12345", 5, S("a12345"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, "1234567890", 0, S("a"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, "1234567890", 1, S("a1"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, "1234567890", 5, S("a12345"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, "1234567890", 9, S("a123456789"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, "1234567890", 10, S("a1234567890"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, "12345678901234567890", 0, S("a"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, "12345678901234567890", 1, S("a1"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, "12345678901234567890", 10, S("a1234567890"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, "12345678901234567890", 19, S("a1234567890123456789"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, "12345678901234567890", 20, S("a12345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, "", 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, "12345", 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, "12345", 1, S("abcdefghij1klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, "12345", 2, S("abcdefghij12klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, "12345", 4, S("abcdefghij1234klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, "12345", 5, S("abcdefghij12345klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, "1234567890", 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, "1234567890", 1, S("abcdefghij1klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, "1234567890", 5, S("abcdefghij12345klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, "1234567890", 9, S("abcdefghij123456789klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, "1234567890", 10, S("abcdefghij1234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, "12345678901234567890", 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, "12345678901234567890", 1, S("abcdefghij1klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, "12345678901234567890", 10, S("abcdefghij1234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, "12345678901234567890", 19, S("abcdefghij1234567890123456789klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, "12345678901234567890", 20, S("abcdefghij12345678901234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, "", 0, S("abcdefghijlmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, "12345", 0, S("abcdefghijlmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, "12345", 1, S("abcdefghij1lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, "12345", 2, S("abcdefghij12lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, "12345", 4, S("abcdefghij1234lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, "12345", 5, S("abcdefghij12345lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, "1234567890", 0, S("abcdefghijlmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, "1234567890", 1, S("abcdefghij1lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, "1234567890", 5, S("abcdefghij12345lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, "1234567890", 9, S("abcdefghij123456789lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, "1234567890", 10, S("abcdefghij1234567890lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, "12345678901234567890", 0, S("abcdefghijlmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, "12345678901234567890", 1, S("abcdefghij1lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, "12345678901234567890", 10, S("abcdefghij1234567890lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, "12345678901234567890", 19, S("abcdefghij1234567890123456789lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, "12345678901234567890", 20, S("abcdefghij12345678901234567890lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, "", 0, S("abcdefghijpqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, "12345", 0, S("abcdefghijpqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, "12345", 1, S("abcdefghij1pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, "12345", 2, S("abcdefghij12pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, "12345", 4, S("abcdefghij1234pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, "12345", 5, S("abcdefghij12345pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, "1234567890", 0, S("abcdefghijpqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, "1234567890", 1, S("abcdefghij1pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, "1234567890", 5, S("abcdefghij12345pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, "1234567890", 9, S("abcdefghij123456789pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, "1234567890", 10, S("abcdefghij1234567890pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, "12345678901234567890", 0, S("abcdefghijpqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, "12345678901234567890", 1, S("abcdefghij1pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, "12345678901234567890", 10, S("abcdefghij1234567890pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, "12345678901234567890", 19, S("abcdefghij1234567890123456789pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, "12345678901234567890", 20, S("abcdefghij12345678901234567890pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, "", 0, S("abcdefghijt"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, "12345", 0, S("abcdefghijt"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, "12345", 1, S("abcdefghij1t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, "12345", 2, S("abcdefghij12t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, "12345", 4, S("abcdefghij1234t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, "12345", 5, S("abcdefghij12345t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, "1234567890", 0, S("abcdefghijt"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, "1234567890", 1, S("abcdefghij1t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, "1234567890", 5, S("abcdefghij12345t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, "1234567890", 9, S("abcdefghij123456789t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, "1234567890", 10, S("abcdefghij1234567890t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, "12345678901234567890", 0, S("abcdefghijt"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, "12345678901234567890", 1, S("abcdefghij1t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, "12345678901234567890", 10, S("abcdefghij1234567890t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, "12345678901234567890", 19, S("abcdefghij1234567890123456789t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, "12345678901234567890", 20, S("abcdefghij12345678901234567890t"));
+}
+
+template <class S>
+void test8()
+{
+ test(S("abcdefghijklmnopqrst"), 10, 10, "", 0, S("abcdefghij"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, "12345", 0, S("abcdefghij"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, "12345", 1, S("abcdefghij1"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, "12345", 2, S("abcdefghij12"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, "12345", 4, S("abcdefghij1234"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, "12345", 5, S("abcdefghij12345"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, "1234567890", 0, S("abcdefghij"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, "1234567890", 1, S("abcdefghij1"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, "1234567890", 5, S("abcdefghij12345"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, "1234567890", 9, S("abcdefghij123456789"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, "1234567890", 10, S("abcdefghij1234567890"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, "12345678901234567890", 0, S("abcdefghij"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, "12345678901234567890", 1, S("abcdefghij1"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, "12345678901234567890", 10, S("abcdefghij1234567890"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, "12345678901234567890", 19, S("abcdefghij1234567890123456789"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, "12345678901234567890", 20, S("abcdefghij12345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, "", 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, "12345", 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, "12345", 1, S("abcdefghijklmnopqrs1t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, "12345", 2, S("abcdefghijklmnopqrs12t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, "12345", 4, S("abcdefghijklmnopqrs1234t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, "12345", 5, S("abcdefghijklmnopqrs12345t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, "1234567890", 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, "1234567890", 1, S("abcdefghijklmnopqrs1t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, "1234567890", 5, S("abcdefghijklmnopqrs12345t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, "1234567890", 9, S("abcdefghijklmnopqrs123456789t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, "1234567890", 10, S("abcdefghijklmnopqrs1234567890t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, "12345678901234567890", 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, "12345678901234567890", 1, S("abcdefghijklmnopqrs1t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, "12345678901234567890", 10, S("abcdefghijklmnopqrs1234567890t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, "12345678901234567890", 19, S("abcdefghijklmnopqrs1234567890123456789t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, "12345678901234567890", 20, S("abcdefghijklmnopqrs12345678901234567890t"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, "", 0, S("abcdefghijklmnopqrs"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, "12345", 0, S("abcdefghijklmnopqrs"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, "12345", 1, S("abcdefghijklmnopqrs1"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, "12345", 2, S("abcdefghijklmnopqrs12"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, "12345", 4, S("abcdefghijklmnopqrs1234"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, "12345", 5, S("abcdefghijklmnopqrs12345"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, "1234567890", 0, S("abcdefghijklmnopqrs"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, "1234567890", 1, S("abcdefghijklmnopqrs1"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, "1234567890", 5, S("abcdefghijklmnopqrs12345"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, "1234567890", 9, S("abcdefghijklmnopqrs123456789"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, "1234567890", 10, S("abcdefghijklmnopqrs1234567890"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, "12345678901234567890", 0, S("abcdefghijklmnopqrs"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, "12345678901234567890", 1, S("abcdefghijklmnopqrs1"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, "12345678901234567890", 10, S("abcdefghijklmnopqrs1234567890"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, "12345678901234567890", 19, S("abcdefghijklmnopqrs1234567890123456789"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, "12345678901234567890", 20, S("abcdefghijklmnopqrs12345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, "", 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, "12345", 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, "12345", 1, S("abcdefghijklmnopqrst1"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, "12345", 2, S("abcdefghijklmnopqrst12"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, "12345", 4, S("abcdefghijklmnopqrst1234"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, "12345", 5, S("abcdefghijklmnopqrst12345"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, "1234567890", 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, "1234567890", 1, S("abcdefghijklmnopqrst1"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, "1234567890", 5, S("abcdefghijklmnopqrst12345"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, "1234567890", 9, S("abcdefghijklmnopqrst123456789"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, "1234567890", 10, S("abcdefghijklmnopqrst1234567890"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, "12345678901234567890", 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, "12345678901234567890", 1, S("abcdefghijklmnopqrst1"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, "12345678901234567890", 10, S("abcdefghijklmnopqrst1234567890"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, "12345678901234567890", 19, S("abcdefghijklmnopqrst1234567890123456789"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, "12345678901234567890", 20, S("abcdefghijklmnopqrst12345678901234567890"));
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test0<S>();
+ test1<S>();
+ test2<S>();
+ test3<S>();
+ test4<S>();
+ test5<S>();
+ test6<S>();
+ test7<S>();
+ test8<S>();
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test0<S>();
+ test1<S>();
+ test2<S>();
+ test3<S>();
+ test4<S>();
+ test5<S>();
+ test6<S>();
+ test7<S>();
+ test8<S>();
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_size_char.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_size_char.pass.cpp
new file mode 100644
index 000000000000..b0e2234a7e53
--- /dev/null
+++ b/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_size_char.pass.cpp
@@ -0,0 +1,286 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string<charT,traits,Allocator>&
+// replace(const_iterator i1, const_iterator i2, size_type n, charT c);
+
+#include <stdio.h>
+
+#include <string>
+#include <algorithm>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s, typename S::size_type pos1, typename S::size_type n1, typename S::size_type n2,
+ typename S::value_type c, S expected)
+{
+ typename S::size_type old_size = s.size();
+ typename S::const_iterator first = s.begin() + pos1;
+ typename S::const_iterator last = s.begin() + pos1 + n1;
+ typename S::size_type xlen = last - first;
+ s.replace(first, last, n2, c);
+ assert(s.__invariants());
+ assert(s == expected);
+ typename S::size_type rlen = n2;
+ assert(s.size() == old_size - xlen + rlen);
+}
+
+template <class S>
+void test0()
+{
+ test(S(""), 0, 0, 0, '3', S(""));
+ test(S(""), 0, 0, 5, '3', S("33333"));
+ test(S(""), 0, 0, 10, '3', S("3333333333"));
+ test(S(""), 0, 0, 20, '3', S("33333333333333333333"));
+ test(S("abcde"), 0, 0, 0, '3', S("abcde"));
+ test(S("abcde"), 0, 0, 5, '3', S("33333abcde"));
+ test(S("abcde"), 0, 0, 10, '3', S("3333333333abcde"));
+ test(S("abcde"), 0, 0, 20, '3', S("33333333333333333333abcde"));
+ test(S("abcde"), 0, 1, 0, '3', S("bcde"));
+ test(S("abcde"), 0, 1, 5, '3', S("33333bcde"));
+ test(S("abcde"), 0, 1, 10, '3', S("3333333333bcde"));
+ test(S("abcde"), 0, 1, 20, '3', S("33333333333333333333bcde"));
+ test(S("abcde"), 0, 2, 0, '3', S("cde"));
+ test(S("abcde"), 0, 2, 5, '3', S("33333cde"));
+ test(S("abcde"), 0, 2, 10, '3', S("3333333333cde"));
+ test(S("abcde"), 0, 2, 20, '3', S("33333333333333333333cde"));
+ test(S("abcde"), 0, 4, 0, '3', S("e"));
+ test(S("abcde"), 0, 4, 5, '3', S("33333e"));
+ test(S("abcde"), 0, 4, 10, '3', S("3333333333e"));
+ test(S("abcde"), 0, 4, 20, '3', S("33333333333333333333e"));
+ test(S("abcde"), 0, 5, 0, '3', S(""));
+ test(S("abcde"), 0, 5, 5, '3', S("33333"));
+ test(S("abcde"), 0, 5, 10, '3', S("3333333333"));
+ test(S("abcde"), 0, 5, 20, '3', S("33333333333333333333"));
+ test(S("abcde"), 1, 0, 0, '3', S("abcde"));
+ test(S("abcde"), 1, 0, 5, '3', S("a33333bcde"));
+ test(S("abcde"), 1, 0, 10, '3', S("a3333333333bcde"));
+ test(S("abcde"), 1, 0, 20, '3', S("a33333333333333333333bcde"));
+ test(S("abcde"), 1, 1, 0, '3', S("acde"));
+ test(S("abcde"), 1, 1, 5, '3', S("a33333cde"));
+ test(S("abcde"), 1, 1, 10, '3', S("a3333333333cde"));
+ test(S("abcde"), 1, 1, 20, '3', S("a33333333333333333333cde"));
+ test(S("abcde"), 1, 2, 0, '3', S("ade"));
+ test(S("abcde"), 1, 2, 5, '3', S("a33333de"));
+ test(S("abcde"), 1, 2, 10, '3', S("a3333333333de"));
+ test(S("abcde"), 1, 2, 20, '3', S("a33333333333333333333de"));
+ test(S("abcde"), 1, 3, 0, '3', S("ae"));
+ test(S("abcde"), 1, 3, 5, '3', S("a33333e"));
+ test(S("abcde"), 1, 3, 10, '3', S("a3333333333e"));
+ test(S("abcde"), 1, 3, 20, '3', S("a33333333333333333333e"));
+ test(S("abcde"), 1, 4, 0, '3', S("a"));
+ test(S("abcde"), 1, 4, 5, '3', S("a33333"));
+ test(S("abcde"), 1, 4, 10, '3', S("a3333333333"));
+ test(S("abcde"), 1, 4, 20, '3', S("a33333333333333333333"));
+ test(S("abcde"), 2, 0, 0, '3', S("abcde"));
+ test(S("abcde"), 2, 0, 5, '3', S("ab33333cde"));
+ test(S("abcde"), 2, 0, 10, '3', S("ab3333333333cde"));
+ test(S("abcde"), 2, 0, 20, '3', S("ab33333333333333333333cde"));
+ test(S("abcde"), 2, 1, 0, '3', S("abde"));
+ test(S("abcde"), 2, 1, 5, '3', S("ab33333de"));
+ test(S("abcde"), 2, 1, 10, '3', S("ab3333333333de"));
+ test(S("abcde"), 2, 1, 20, '3', S("ab33333333333333333333de"));
+ test(S("abcde"), 2, 2, 0, '3', S("abe"));
+ test(S("abcde"), 2, 2, 5, '3', S("ab33333e"));
+ test(S("abcde"), 2, 2, 10, '3', S("ab3333333333e"));
+ test(S("abcde"), 2, 2, 20, '3', S("ab33333333333333333333e"));
+ test(S("abcde"), 2, 3, 0, '3', S("ab"));
+ test(S("abcde"), 2, 3, 5, '3', S("ab33333"));
+ test(S("abcde"), 2, 3, 10, '3', S("ab3333333333"));
+ test(S("abcde"), 2, 3, 20, '3', S("ab33333333333333333333"));
+ test(S("abcde"), 4, 0, 0, '3', S("abcde"));
+ test(S("abcde"), 4, 0, 5, '3', S("abcd33333e"));
+ test(S("abcde"), 4, 0, 10, '3', S("abcd3333333333e"));
+ test(S("abcde"), 4, 0, 20, '3', S("abcd33333333333333333333e"));
+ test(S("abcde"), 4, 1, 0, '3', S("abcd"));
+ test(S("abcde"), 4, 1, 5, '3', S("abcd33333"));
+ test(S("abcde"), 4, 1, 10, '3', S("abcd3333333333"));
+ test(S("abcde"), 4, 1, 20, '3', S("abcd33333333333333333333"));
+ test(S("abcde"), 5, 0, 0, '3', S("abcde"));
+ test(S("abcde"), 5, 0, 5, '3', S("abcde33333"));
+ test(S("abcde"), 5, 0, 10, '3', S("abcde3333333333"));
+ test(S("abcde"), 5, 0, 20, '3', S("abcde33333333333333333333"));
+ test(S("abcdefghij"), 0, 0, 0, '3', S("abcdefghij"));
+ test(S("abcdefghij"), 0, 0, 5, '3', S("33333abcdefghij"));
+ test(S("abcdefghij"), 0, 0, 10, '3', S("3333333333abcdefghij"));
+ test(S("abcdefghij"), 0, 0, 20, '3', S("33333333333333333333abcdefghij"));
+ test(S("abcdefghij"), 0, 1, 0, '3', S("bcdefghij"));
+ test(S("abcdefghij"), 0, 1, 5, '3', S("33333bcdefghij"));
+ test(S("abcdefghij"), 0, 1, 10, '3', S("3333333333bcdefghij"));
+ test(S("abcdefghij"), 0, 1, 20, '3', S("33333333333333333333bcdefghij"));
+ test(S("abcdefghij"), 0, 5, 0, '3', S("fghij"));
+ test(S("abcdefghij"), 0, 5, 5, '3', S("33333fghij"));
+ test(S("abcdefghij"), 0, 5, 10, '3', S("3333333333fghij"));
+ test(S("abcdefghij"), 0, 5, 20, '3', S("33333333333333333333fghij"));
+ test(S("abcdefghij"), 0, 9, 0, '3', S("j"));
+ test(S("abcdefghij"), 0, 9, 5, '3', S("33333j"));
+ test(S("abcdefghij"), 0, 9, 10, '3', S("3333333333j"));
+ test(S("abcdefghij"), 0, 9, 20, '3', S("33333333333333333333j"));
+ test(S("abcdefghij"), 0, 10, 0, '3', S(""));
+ test(S("abcdefghij"), 0, 10, 5, '3', S("33333"));
+ test(S("abcdefghij"), 0, 10, 10, '3', S("3333333333"));
+ test(S("abcdefghij"), 0, 10, 20, '3', S("33333333333333333333"));
+ test(S("abcdefghij"), 1, 0, 0, '3', S("abcdefghij"));
+ test(S("abcdefghij"), 1, 0, 5, '3', S("a33333bcdefghij"));
+ test(S("abcdefghij"), 1, 0, 10, '3', S("a3333333333bcdefghij"));
+ test(S("abcdefghij"), 1, 0, 20, '3', S("a33333333333333333333bcdefghij"));
+ test(S("abcdefghij"), 1, 1, 0, '3', S("acdefghij"));
+ test(S("abcdefghij"), 1, 1, 5, '3', S("a33333cdefghij"));
+ test(S("abcdefghij"), 1, 1, 10, '3', S("a3333333333cdefghij"));
+ test(S("abcdefghij"), 1, 1, 20, '3', S("a33333333333333333333cdefghij"));
+}
+
+template <class S>
+void test1()
+{
+ test(S("abcdefghij"), 1, 4, 0, '3', S("afghij"));
+ test(S("abcdefghij"), 1, 4, 5, '3', S("a33333fghij"));
+ test(S("abcdefghij"), 1, 4, 10, '3', S("a3333333333fghij"));
+ test(S("abcdefghij"), 1, 4, 20, '3', S("a33333333333333333333fghij"));
+ test(S("abcdefghij"), 1, 8, 0, '3', S("aj"));
+ test(S("abcdefghij"), 1, 8, 5, '3', S("a33333j"));
+ test(S("abcdefghij"), 1, 8, 10, '3', S("a3333333333j"));
+ test(S("abcdefghij"), 1, 8, 20, '3', S("a33333333333333333333j"));
+ test(S("abcdefghij"), 1, 9, 0, '3', S("a"));
+ test(S("abcdefghij"), 1, 9, 5, '3', S("a33333"));
+ test(S("abcdefghij"), 1, 9, 10, '3', S("a3333333333"));
+ test(S("abcdefghij"), 1, 9, 20, '3', S("a33333333333333333333"));
+ test(S("abcdefghij"), 5, 0, 0, '3', S("abcdefghij"));
+ test(S("abcdefghij"), 5, 0, 5, '3', S("abcde33333fghij"));
+ test(S("abcdefghij"), 5, 0, 10, '3', S("abcde3333333333fghij"));
+ test(S("abcdefghij"), 5, 0, 20, '3', S("abcde33333333333333333333fghij"));
+ test(S("abcdefghij"), 5, 1, 0, '3', S("abcdeghij"));
+ test(S("abcdefghij"), 5, 1, 5, '3', S("abcde33333ghij"));
+ test(S("abcdefghij"), 5, 1, 10, '3', S("abcde3333333333ghij"));
+ test(S("abcdefghij"), 5, 1, 20, '3', S("abcde33333333333333333333ghij"));
+ test(S("abcdefghij"), 5, 2, 0, '3', S("abcdehij"));
+ test(S("abcdefghij"), 5, 2, 5, '3', S("abcde33333hij"));
+ test(S("abcdefghij"), 5, 2, 10, '3', S("abcde3333333333hij"));
+ test(S("abcdefghij"), 5, 2, 20, '3', S("abcde33333333333333333333hij"));
+ test(S("abcdefghij"), 5, 4, 0, '3', S("abcdej"));
+ test(S("abcdefghij"), 5, 4, 5, '3', S("abcde33333j"));
+ test(S("abcdefghij"), 5, 4, 10, '3', S("abcde3333333333j"));
+ test(S("abcdefghij"), 5, 4, 20, '3', S("abcde33333333333333333333j"));
+ test(S("abcdefghij"), 5, 5, 0, '3', S("abcde"));
+ test(S("abcdefghij"), 5, 5, 5, '3', S("abcde33333"));
+ test(S("abcdefghij"), 5, 5, 10, '3', S("abcde3333333333"));
+ test(S("abcdefghij"), 5, 5, 20, '3', S("abcde33333333333333333333"));
+ test(S("abcdefghij"), 9, 0, 0, '3', S("abcdefghij"));
+ test(S("abcdefghij"), 9, 0, 5, '3', S("abcdefghi33333j"));
+ test(S("abcdefghij"), 9, 0, 10, '3', S("abcdefghi3333333333j"));
+ test(S("abcdefghij"), 9, 0, 20, '3', S("abcdefghi33333333333333333333j"));
+ test(S("abcdefghij"), 9, 1, 0, '3', S("abcdefghi"));
+ test(S("abcdefghij"), 9, 1, 5, '3', S("abcdefghi33333"));
+ test(S("abcdefghij"), 9, 1, 10, '3', S("abcdefghi3333333333"));
+ test(S("abcdefghij"), 9, 1, 20, '3', S("abcdefghi33333333333333333333"));
+ test(S("abcdefghij"), 10, 0, 0, '3', S("abcdefghij"));
+ test(S("abcdefghij"), 10, 0, 5, '3', S("abcdefghij33333"));
+ test(S("abcdefghij"), 10, 0, 10, '3', S("abcdefghij3333333333"));
+ test(S("abcdefghij"), 10, 0, 20, '3', S("abcdefghij33333333333333333333"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, 0, '3', S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, 5, '3', S("33333abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, 10, '3', S("3333333333abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, 20, '3', S("33333333333333333333abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, 0, '3', S("bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, 5, '3', S("33333bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, 10, '3', S("3333333333bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, 20, '3', S("33333333333333333333bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, 0, '3', S("klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, 5, '3', S("33333klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, 10, '3', S("3333333333klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, 20, '3', S("33333333333333333333klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, 0, '3', S("t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, 5, '3', S("33333t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, 10, '3', S("3333333333t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, 20, '3', S("33333333333333333333t"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, 0, '3', S(""));
+ test(S("abcdefghijklmnopqrst"), 0, 20, 5, '3', S("33333"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, 10, '3', S("3333333333"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, 20, '3', S("33333333333333333333"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, 0, '3', S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, 5, '3', S("a33333bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, 10, '3', S("a3333333333bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, 20, '3', S("a33333333333333333333bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, 0, '3', S("acdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, 5, '3', S("a33333cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, 10, '3', S("a3333333333cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, 20, '3', S("a33333333333333333333cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, 0, '3', S("aklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, 5, '3', S("a33333klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, 10, '3', S("a3333333333klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, 20, '3', S("a33333333333333333333klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, 0, '3', S("at"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, 5, '3', S("a33333t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, 10, '3', S("a3333333333t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, 20, '3', S("a33333333333333333333t"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, 0, '3', S("a"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, 5, '3', S("a33333"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, 10, '3', S("a3333333333"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, 20, '3', S("a33333333333333333333"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, 0, '3', S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, 5, '3', S("abcdefghij33333klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, 10, '3', S("abcdefghij3333333333klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, 20, '3', S("abcdefghij33333333333333333333klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, 0, '3', S("abcdefghijlmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, 5, '3', S("abcdefghij33333lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, 10, '3', S("abcdefghij3333333333lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, 20, '3', S("abcdefghij33333333333333333333lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, 0, '3', S("abcdefghijpqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, 5, '3', S("abcdefghij33333pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, 10, '3', S("abcdefghij3333333333pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, 20, '3', S("abcdefghij33333333333333333333pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, 0, '3', S("abcdefghijt"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, 5, '3', S("abcdefghij33333t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, 10, '3', S("abcdefghij3333333333t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, 20, '3', S("abcdefghij33333333333333333333t"));
+}
+
+template <class S>
+void test2()
+{
+ test(S("abcdefghijklmnopqrst"), 10, 10, 0, '3', S("abcdefghij"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, 5, '3', S("abcdefghij33333"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, 10, '3', S("abcdefghij3333333333"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, 20, '3', S("abcdefghij33333333333333333333"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, 0, '3', S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, 5, '3', S("abcdefghijklmnopqrs33333t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, 10, '3', S("abcdefghijklmnopqrs3333333333t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, 20, '3', S("abcdefghijklmnopqrs33333333333333333333t"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, 0, '3', S("abcdefghijklmnopqrs"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, 5, '3', S("abcdefghijklmnopqrs33333"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, 10, '3', S("abcdefghijklmnopqrs3333333333"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, 20, '3', S("abcdefghijklmnopqrs33333333333333333333"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, 0, '3', S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, 5, '3', S("abcdefghijklmnopqrst33333"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, 10, '3', S("abcdefghijklmnopqrst3333333333"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, 20, '3', S("abcdefghijklmnopqrst33333333333333333333"));
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test0<S>();
+ test1<S>();
+ test2<S>();
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test0<S>();
+ test1<S>();
+ test2<S>();
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_string.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_string.pass.cpp
new file mode 100644
index 000000000000..0f95492fdb1a
--- /dev/null
+++ b/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_string.pass.cpp
@@ -0,0 +1,285 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string<charT,traits,Allocator>&
+// replace(const_iterator i1, const_iterator i2, const basic_string& str);
+
+#include <stdio.h>
+
+#include <string>
+#include <algorithm>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s, typename S::size_type pos1, typename S::size_type n1, S str, S expected)
+{
+ typename S::size_type old_size = s.size();
+ typename S::const_iterator first = s.begin() + pos1;
+ typename S::const_iterator last = s.begin() + pos1 + n1;
+ typename S::size_type xlen = last - first;
+ s.replace(first, last, str);
+ assert(s.__invariants());
+ assert(s == expected);
+ typename S::size_type rlen = str.size();
+ assert(s.size() == old_size - xlen + rlen);
+}
+
+template <class S>
+void test0()
+{
+ test(S(""), 0, 0, S(""), S(""));
+ test(S(""), 0, 0, S("12345"), S("12345"));
+ test(S(""), 0, 0, S("1234567890"), S("1234567890"));
+ test(S(""), 0, 0, S("12345678901234567890"), S("12345678901234567890"));
+ test(S("abcde"), 0, 0, S(""), S("abcde"));
+ test(S("abcde"), 0, 0, S("12345"), S("12345abcde"));
+ test(S("abcde"), 0, 0, S("1234567890"), S("1234567890abcde"));
+ test(S("abcde"), 0, 0, S("12345678901234567890"), S("12345678901234567890abcde"));
+ test(S("abcde"), 0, 1, S(""), S("bcde"));
+ test(S("abcde"), 0, 1, S("12345"), S("12345bcde"));
+ test(S("abcde"), 0, 1, S("1234567890"), S("1234567890bcde"));
+ test(S("abcde"), 0, 1, S("12345678901234567890"), S("12345678901234567890bcde"));
+ test(S("abcde"), 0, 2, S(""), S("cde"));
+ test(S("abcde"), 0, 2, S("12345"), S("12345cde"));
+ test(S("abcde"), 0, 2, S("1234567890"), S("1234567890cde"));
+ test(S("abcde"), 0, 2, S("12345678901234567890"), S("12345678901234567890cde"));
+ test(S("abcde"), 0, 4, S(""), S("e"));
+ test(S("abcde"), 0, 4, S("12345"), S("12345e"));
+ test(S("abcde"), 0, 4, S("1234567890"), S("1234567890e"));
+ test(S("abcde"), 0, 4, S("12345678901234567890"), S("12345678901234567890e"));
+ test(S("abcde"), 0, 5, S(""), S(""));
+ test(S("abcde"), 0, 5, S("12345"), S("12345"));
+ test(S("abcde"), 0, 5, S("1234567890"), S("1234567890"));
+ test(S("abcde"), 0, 5, S("12345678901234567890"), S("12345678901234567890"));
+ test(S("abcde"), 1, 0, S(""), S("abcde"));
+ test(S("abcde"), 1, 0, S("12345"), S("a12345bcde"));
+ test(S("abcde"), 1, 0, S("1234567890"), S("a1234567890bcde"));
+ test(S("abcde"), 1, 0, S("12345678901234567890"), S("a12345678901234567890bcde"));
+ test(S("abcde"), 1, 1, S(""), S("acde"));
+ test(S("abcde"), 1, 1, S("12345"), S("a12345cde"));
+ test(S("abcde"), 1, 1, S("1234567890"), S("a1234567890cde"));
+ test(S("abcde"), 1, 1, S("12345678901234567890"), S("a12345678901234567890cde"));
+ test(S("abcde"), 1, 2, S(""), S("ade"));
+ test(S("abcde"), 1, 2, S("12345"), S("a12345de"));
+ test(S("abcde"), 1, 2, S("1234567890"), S("a1234567890de"));
+ test(S("abcde"), 1, 2, S("12345678901234567890"), S("a12345678901234567890de"));
+ test(S("abcde"), 1, 3, S(""), S("ae"));
+ test(S("abcde"), 1, 3, S("12345"), S("a12345e"));
+ test(S("abcde"), 1, 3, S("1234567890"), S("a1234567890e"));
+ test(S("abcde"), 1, 3, S("12345678901234567890"), S("a12345678901234567890e"));
+ test(S("abcde"), 1, 4, S(""), S("a"));
+ test(S("abcde"), 1, 4, S("12345"), S("a12345"));
+ test(S("abcde"), 1, 4, S("1234567890"), S("a1234567890"));
+ test(S("abcde"), 1, 4, S("12345678901234567890"), S("a12345678901234567890"));
+ test(S("abcde"), 2, 0, S(""), S("abcde"));
+ test(S("abcde"), 2, 0, S("12345"), S("ab12345cde"));
+ test(S("abcde"), 2, 0, S("1234567890"), S("ab1234567890cde"));
+ test(S("abcde"), 2, 0, S("12345678901234567890"), S("ab12345678901234567890cde"));
+ test(S("abcde"), 2, 1, S(""), S("abde"));
+ test(S("abcde"), 2, 1, S("12345"), S("ab12345de"));
+ test(S("abcde"), 2, 1, S("1234567890"), S("ab1234567890de"));
+ test(S("abcde"), 2, 1, S("12345678901234567890"), S("ab12345678901234567890de"));
+ test(S("abcde"), 2, 2, S(""), S("abe"));
+ test(S("abcde"), 2, 2, S("12345"), S("ab12345e"));
+ test(S("abcde"), 2, 2, S("1234567890"), S("ab1234567890e"));
+ test(S("abcde"), 2, 2, S("12345678901234567890"), S("ab12345678901234567890e"));
+ test(S("abcde"), 2, 3, S(""), S("ab"));
+ test(S("abcde"), 2, 3, S("12345"), S("ab12345"));
+ test(S("abcde"), 2, 3, S("1234567890"), S("ab1234567890"));
+ test(S("abcde"), 2, 3, S("12345678901234567890"), S("ab12345678901234567890"));
+ test(S("abcde"), 4, 0, S(""), S("abcde"));
+ test(S("abcde"), 4, 0, S("12345"), S("abcd12345e"));
+ test(S("abcde"), 4, 0, S("1234567890"), S("abcd1234567890e"));
+ test(S("abcde"), 4, 0, S("12345678901234567890"), S("abcd12345678901234567890e"));
+ test(S("abcde"), 4, 1, S(""), S("abcd"));
+ test(S("abcde"), 4, 1, S("12345"), S("abcd12345"));
+ test(S("abcde"), 4, 1, S("1234567890"), S("abcd1234567890"));
+ test(S("abcde"), 4, 1, S("12345678901234567890"), S("abcd12345678901234567890"));
+ test(S("abcde"), 5, 0, S(""), S("abcde"));
+ test(S("abcde"), 5, 0, S("12345"), S("abcde12345"));
+ test(S("abcde"), 5, 0, S("1234567890"), S("abcde1234567890"));
+ test(S("abcde"), 5, 0, S("12345678901234567890"), S("abcde12345678901234567890"));
+ test(S("abcdefghij"), 0, 0, S(""), S("abcdefghij"));
+ test(S("abcdefghij"), 0, 0, S("12345"), S("12345abcdefghij"));
+ test(S("abcdefghij"), 0, 0, S("1234567890"), S("1234567890abcdefghij"));
+ test(S("abcdefghij"), 0, 0, S("12345678901234567890"), S("12345678901234567890abcdefghij"));
+ test(S("abcdefghij"), 0, 1, S(""), S("bcdefghij"));
+ test(S("abcdefghij"), 0, 1, S("12345"), S("12345bcdefghij"));
+ test(S("abcdefghij"), 0, 1, S("1234567890"), S("1234567890bcdefghij"));
+ test(S("abcdefghij"), 0, 1, S("12345678901234567890"), S("12345678901234567890bcdefghij"));
+ test(S("abcdefghij"), 0, 5, S(""), S("fghij"));
+ test(S("abcdefghij"), 0, 5, S("12345"), S("12345fghij"));
+ test(S("abcdefghij"), 0, 5, S("1234567890"), S("1234567890fghij"));
+ test(S("abcdefghij"), 0, 5, S("12345678901234567890"), S("12345678901234567890fghij"));
+ test(S("abcdefghij"), 0, 9, S(""), S("j"));
+ test(S("abcdefghij"), 0, 9, S("12345"), S("12345j"));
+ test(S("abcdefghij"), 0, 9, S("1234567890"), S("1234567890j"));
+ test(S("abcdefghij"), 0, 9, S("12345678901234567890"), S("12345678901234567890j"));
+ test(S("abcdefghij"), 0, 10, S(""), S(""));
+ test(S("abcdefghij"), 0, 10, S("12345"), S("12345"));
+ test(S("abcdefghij"), 0, 10, S("1234567890"), S("1234567890"));
+ test(S("abcdefghij"), 0, 10, S("12345678901234567890"), S("12345678901234567890"));
+ test(S("abcdefghij"), 1, 0, S(""), S("abcdefghij"));
+ test(S("abcdefghij"), 1, 0, S("12345"), S("a12345bcdefghij"));
+ test(S("abcdefghij"), 1, 0, S("1234567890"), S("a1234567890bcdefghij"));
+ test(S("abcdefghij"), 1, 0, S("12345678901234567890"), S("a12345678901234567890bcdefghij"));
+ test(S("abcdefghij"), 1, 1, S(""), S("acdefghij"));
+ test(S("abcdefghij"), 1, 1, S("12345"), S("a12345cdefghij"));
+ test(S("abcdefghij"), 1, 1, S("1234567890"), S("a1234567890cdefghij"));
+ test(S("abcdefghij"), 1, 1, S("12345678901234567890"), S("a12345678901234567890cdefghij"));
+}
+
+template <class S>
+void test1()
+{
+ test(S("abcdefghij"), 1, 4, S(""), S("afghij"));
+ test(S("abcdefghij"), 1, 4, S("12345"), S("a12345fghij"));
+ test(S("abcdefghij"), 1, 4, S("1234567890"), S("a1234567890fghij"));
+ test(S("abcdefghij"), 1, 4, S("12345678901234567890"), S("a12345678901234567890fghij"));
+ test(S("abcdefghij"), 1, 8, S(""), S("aj"));
+ test(S("abcdefghij"), 1, 8, S("12345"), S("a12345j"));
+ test(S("abcdefghij"), 1, 8, S("1234567890"), S("a1234567890j"));
+ test(S("abcdefghij"), 1, 8, S("12345678901234567890"), S("a12345678901234567890j"));
+ test(S("abcdefghij"), 1, 9, S(""), S("a"));
+ test(S("abcdefghij"), 1, 9, S("12345"), S("a12345"));
+ test(S("abcdefghij"), 1, 9, S("1234567890"), S("a1234567890"));
+ test(S("abcdefghij"), 1, 9, S("12345678901234567890"), S("a12345678901234567890"));
+ test(S("abcdefghij"), 5, 0, S(""), S("abcdefghij"));
+ test(S("abcdefghij"), 5, 0, S("12345"), S("abcde12345fghij"));
+ test(S("abcdefghij"), 5, 0, S("1234567890"), S("abcde1234567890fghij"));
+ test(S("abcdefghij"), 5, 0, S("12345678901234567890"), S("abcde12345678901234567890fghij"));
+ test(S("abcdefghij"), 5, 1, S(""), S("abcdeghij"));
+ test(S("abcdefghij"), 5, 1, S("12345"), S("abcde12345ghij"));
+ test(S("abcdefghij"), 5, 1, S("1234567890"), S("abcde1234567890ghij"));
+ test(S("abcdefghij"), 5, 1, S("12345678901234567890"), S("abcde12345678901234567890ghij"));
+ test(S("abcdefghij"), 5, 2, S(""), S("abcdehij"));
+ test(S("abcdefghij"), 5, 2, S("12345"), S("abcde12345hij"));
+ test(S("abcdefghij"), 5, 2, S("1234567890"), S("abcde1234567890hij"));
+ test(S("abcdefghij"), 5, 2, S("12345678901234567890"), S("abcde12345678901234567890hij"));
+ test(S("abcdefghij"), 5, 4, S(""), S("abcdej"));
+ test(S("abcdefghij"), 5, 4, S("12345"), S("abcde12345j"));
+ test(S("abcdefghij"), 5, 4, S("1234567890"), S("abcde1234567890j"));
+ test(S("abcdefghij"), 5, 4, S("12345678901234567890"), S("abcde12345678901234567890j"));
+ test(S("abcdefghij"), 5, 5, S(""), S("abcde"));
+ test(S("abcdefghij"), 5, 5, S("12345"), S("abcde12345"));
+ test(S("abcdefghij"), 5, 5, S("1234567890"), S("abcde1234567890"));
+ test(S("abcdefghij"), 5, 5, S("12345678901234567890"), S("abcde12345678901234567890"));
+ test(S("abcdefghij"), 9, 0, S(""), S("abcdefghij"));
+ test(S("abcdefghij"), 9, 0, S("12345"), S("abcdefghi12345j"));
+ test(S("abcdefghij"), 9, 0, S("1234567890"), S("abcdefghi1234567890j"));
+ test(S("abcdefghij"), 9, 0, S("12345678901234567890"), S("abcdefghi12345678901234567890j"));
+ test(S("abcdefghij"), 9, 1, S(""), S("abcdefghi"));
+ test(S("abcdefghij"), 9, 1, S("12345"), S("abcdefghi12345"));
+ test(S("abcdefghij"), 9, 1, S("1234567890"), S("abcdefghi1234567890"));
+ test(S("abcdefghij"), 9, 1, S("12345678901234567890"), S("abcdefghi12345678901234567890"));
+ test(S("abcdefghij"), 10, 0, S(""), S("abcdefghij"));
+ test(S("abcdefghij"), 10, 0, S("12345"), S("abcdefghij12345"));
+ test(S("abcdefghij"), 10, 0, S("1234567890"), S("abcdefghij1234567890"));
+ test(S("abcdefghij"), 10, 0, S("12345678901234567890"), S("abcdefghij12345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, S(""), S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), S("12345abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), S("1234567890abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), S("12345678901234567890abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S(""), S("bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), S("12345bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), S("1234567890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), S("12345678901234567890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S(""), S("klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), S("12345klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), S("1234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), S("12345678901234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S(""), S("t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), S("12345t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), S("1234567890t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), S("12345678901234567890t"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S(""), S(""));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), S("12345"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), S("1234567890"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), S("12345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S(""), S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), S("a12345bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), S("a1234567890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), S("a12345678901234567890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S(""), S("acdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), S("a12345cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), S("a1234567890cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), S("a12345678901234567890cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S(""), S("aklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), S("a12345klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), S("a1234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), S("a12345678901234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S(""), S("at"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), S("a12345t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), S("a1234567890t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), S("a12345678901234567890t"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S(""), S("a"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), S("a12345"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), S("a1234567890"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), S("a12345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S(""), S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), S("abcdefghij12345klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), S("abcdefghij1234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), S("abcdefghij12345678901234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S(""), S("abcdefghijlmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), S("abcdefghij12345lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), S("abcdefghij1234567890lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), S("abcdefghij12345678901234567890lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S(""), S("abcdefghijpqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), S("abcdefghij12345pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), S("abcdefghij1234567890pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), S("abcdefghij12345678901234567890pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S(""), S("abcdefghijt"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), S("abcdefghij12345t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), S("abcdefghij1234567890t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), S("abcdefghij12345678901234567890t"));
+}
+
+template <class S>
+void test2()
+{
+ test(S("abcdefghijklmnopqrst"), 10, 10, S(""), S("abcdefghij"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), S("abcdefghij12345"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), S("abcdefghij1234567890"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), S("abcdefghij12345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S(""), S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), S("abcdefghijklmnopqrs12345t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), S("abcdefghijklmnopqrs1234567890t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), S("abcdefghijklmnopqrs12345678901234567890t"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S(""), S("abcdefghijklmnopqrs"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), S("abcdefghijklmnopqrs12345"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), S("abcdefghijklmnopqrs1234567890"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), S("abcdefghijklmnopqrs12345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S(""), S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), S("abcdefghijklmnopqrst12345"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test0<S>();
+ test1<S>();
+ test2<S>();
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test0<S>();
+ test1<S>();
+ test2<S>();
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.modifiers/string_replace/size_size_pointer.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_replace/size_size_pointer.pass.cpp
new file mode 100644
index 000000000000..914081bbc456
--- /dev/null
+++ b/test/std/strings/basic.string/string.modifiers/string_replace/size_size_pointer.pass.cpp
@@ -0,0 +1,375 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string<charT,traits,Allocator>&
+// replace(size_type pos, size_type n1, const charT* s);
+
+#include <stdio.h>
+
+#include <string>
+#include <stdexcept>
+#include <algorithm>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s, typename S::size_type pos, typename S::size_type n1,
+ const typename S::value_type* str, S expected)
+{
+ typename S::size_type old_size = s.size();
+ S s0 = s;
+ try
+ {
+ s.replace(pos, n1, str);
+ assert(s.__invariants());
+ assert(pos <= old_size);
+ assert(s == expected);
+ typename S::size_type xlen = std::min(n1, old_size - pos);
+ typename S::size_type rlen = S::traits_type::length(str);
+ assert(s.size() == old_size - xlen + rlen);
+ }
+ catch (std::out_of_range&)
+ {
+ assert(pos > old_size);
+ assert(s == s0);
+ }
+}
+
+template <class S>
+void test0()
+{
+ test(S(""), 0, 0, "", S(""));
+ test(S(""), 0, 0, "12345", S("12345"));
+ test(S(""), 0, 0, "1234567890", S("1234567890"));
+ test(S(""), 0, 0, "12345678901234567890", S("12345678901234567890"));
+ test(S(""), 0, 1, "", S(""));
+ test(S(""), 0, 1, "12345", S("12345"));
+ test(S(""), 0, 1, "1234567890", S("1234567890"));
+ test(S(""), 0, 1, "12345678901234567890", S("12345678901234567890"));
+ test(S(""), 1, 0, "", S("can't happen"));
+ test(S(""), 1, 0, "12345", S("can't happen"));
+ test(S(""), 1, 0, "1234567890", S("can't happen"));
+ test(S(""), 1, 0, "12345678901234567890", S("can't happen"));
+ test(S("abcde"), 0, 0, "", S("abcde"));
+ test(S("abcde"), 0, 0, "12345", S("12345abcde"));
+ test(S("abcde"), 0, 0, "1234567890", S("1234567890abcde"));
+ test(S("abcde"), 0, 0, "12345678901234567890", S("12345678901234567890abcde"));
+ test(S("abcde"), 0, 1, "", S("bcde"));
+ test(S("abcde"), 0, 1, "12345", S("12345bcde"));
+ test(S("abcde"), 0, 1, "1234567890", S("1234567890bcde"));
+ test(S("abcde"), 0, 1, "12345678901234567890", S("12345678901234567890bcde"));
+ test(S("abcde"), 0, 2, "", S("cde"));
+ test(S("abcde"), 0, 2, "12345", S("12345cde"));
+ test(S("abcde"), 0, 2, "1234567890", S("1234567890cde"));
+ test(S("abcde"), 0, 2, "12345678901234567890", S("12345678901234567890cde"));
+ test(S("abcde"), 0, 4, "", S("e"));
+ test(S("abcde"), 0, 4, "12345", S("12345e"));
+ test(S("abcde"), 0, 4, "1234567890", S("1234567890e"));
+ test(S("abcde"), 0, 4, "12345678901234567890", S("12345678901234567890e"));
+ test(S("abcde"), 0, 5, "", S(""));
+ test(S("abcde"), 0, 5, "12345", S("12345"));
+ test(S("abcde"), 0, 5, "1234567890", S("1234567890"));
+ test(S("abcde"), 0, 5, "12345678901234567890", S("12345678901234567890"));
+ test(S("abcde"), 0, 6, "", S(""));
+ test(S("abcde"), 0, 6, "12345", S("12345"));
+ test(S("abcde"), 0, 6, "1234567890", S("1234567890"));
+ test(S("abcde"), 0, 6, "12345678901234567890", S("12345678901234567890"));
+ test(S("abcde"), 1, 0, "", S("abcde"));
+ test(S("abcde"), 1, 0, "12345", S("a12345bcde"));
+ test(S("abcde"), 1, 0, "1234567890", S("a1234567890bcde"));
+ test(S("abcde"), 1, 0, "12345678901234567890", S("a12345678901234567890bcde"));
+ test(S("abcde"), 1, 1, "", S("acde"));
+ test(S("abcde"), 1, 1, "12345", S("a12345cde"));
+ test(S("abcde"), 1, 1, "1234567890", S("a1234567890cde"));
+ test(S("abcde"), 1, 1, "12345678901234567890", S("a12345678901234567890cde"));
+ test(S("abcde"), 1, 2, "", S("ade"));
+ test(S("abcde"), 1, 2, "12345", S("a12345de"));
+ test(S("abcde"), 1, 2, "1234567890", S("a1234567890de"));
+ test(S("abcde"), 1, 2, "12345678901234567890", S("a12345678901234567890de"));
+ test(S("abcde"), 1, 3, "", S("ae"));
+ test(S("abcde"), 1, 3, "12345", S("a12345e"));
+ test(S("abcde"), 1, 3, "1234567890", S("a1234567890e"));
+ test(S("abcde"), 1, 3, "12345678901234567890", S("a12345678901234567890e"));
+ test(S("abcde"), 1, 4, "", S("a"));
+ test(S("abcde"), 1, 4, "12345", S("a12345"));
+ test(S("abcde"), 1, 4, "1234567890", S("a1234567890"));
+ test(S("abcde"), 1, 4, "12345678901234567890", S("a12345678901234567890"));
+ test(S("abcde"), 1, 5, "", S("a"));
+ test(S("abcde"), 1, 5, "12345", S("a12345"));
+ test(S("abcde"), 1, 5, "1234567890", S("a1234567890"));
+ test(S("abcde"), 1, 5, "12345678901234567890", S("a12345678901234567890"));
+ test(S("abcde"), 2, 0, "", S("abcde"));
+ test(S("abcde"), 2, 0, "12345", S("ab12345cde"));
+ test(S("abcde"), 2, 0, "1234567890", S("ab1234567890cde"));
+ test(S("abcde"), 2, 0, "12345678901234567890", S("ab12345678901234567890cde"));
+ test(S("abcde"), 2, 1, "", S("abde"));
+ test(S("abcde"), 2, 1, "12345", S("ab12345de"));
+ test(S("abcde"), 2, 1, "1234567890", S("ab1234567890de"));
+ test(S("abcde"), 2, 1, "12345678901234567890", S("ab12345678901234567890de"));
+ test(S("abcde"), 2, 2, "", S("abe"));
+ test(S("abcde"), 2, 2, "12345", S("ab12345e"));
+ test(S("abcde"), 2, 2, "1234567890", S("ab1234567890e"));
+ test(S("abcde"), 2, 2, "12345678901234567890", S("ab12345678901234567890e"));
+ test(S("abcde"), 2, 3, "", S("ab"));
+ test(S("abcde"), 2, 3, "12345", S("ab12345"));
+ test(S("abcde"), 2, 3, "1234567890", S("ab1234567890"));
+ test(S("abcde"), 2, 3, "12345678901234567890", S("ab12345678901234567890"));
+ test(S("abcde"), 2, 4, "", S("ab"));
+ test(S("abcde"), 2, 4, "12345", S("ab12345"));
+ test(S("abcde"), 2, 4, "1234567890", S("ab1234567890"));
+ test(S("abcde"), 2, 4, "12345678901234567890", S("ab12345678901234567890"));
+ test(S("abcde"), 4, 0, "", S("abcde"));
+ test(S("abcde"), 4, 0, "12345", S("abcd12345e"));
+ test(S("abcde"), 4, 0, "1234567890", S("abcd1234567890e"));
+ test(S("abcde"), 4, 0, "12345678901234567890", S("abcd12345678901234567890e"));
+ test(S("abcde"), 4, 1, "", S("abcd"));
+ test(S("abcde"), 4, 1, "12345", S("abcd12345"));
+ test(S("abcde"), 4, 1, "1234567890", S("abcd1234567890"));
+ test(S("abcde"), 4, 1, "12345678901234567890", S("abcd12345678901234567890"));
+ test(S("abcde"), 4, 2, "", S("abcd"));
+ test(S("abcde"), 4, 2, "12345", S("abcd12345"));
+ test(S("abcde"), 4, 2, "1234567890", S("abcd1234567890"));
+ test(S("abcde"), 4, 2, "12345678901234567890", S("abcd12345678901234567890"));
+ test(S("abcde"), 5, 0, "", S("abcde"));
+ test(S("abcde"), 5, 0, "12345", S("abcde12345"));
+ test(S("abcde"), 5, 0, "1234567890", S("abcde1234567890"));
+ test(S("abcde"), 5, 0, "12345678901234567890", S("abcde12345678901234567890"));
+ test(S("abcde"), 5, 1, "", S("abcde"));
+ test(S("abcde"), 5, 1, "12345", S("abcde12345"));
+ test(S("abcde"), 5, 1, "1234567890", S("abcde1234567890"));
+ test(S("abcde"), 5, 1, "12345678901234567890", S("abcde12345678901234567890"));
+}
+
+template <class S>
+void test1()
+{
+ test(S("abcde"), 6, 0, "", S("can't happen"));
+ test(S("abcde"), 6, 0, "12345", S("can't happen"));
+ test(S("abcde"), 6, 0, "1234567890", S("can't happen"));
+ test(S("abcde"), 6, 0, "12345678901234567890", S("can't happen"));
+ test(S("abcdefghij"), 0, 0, "", S("abcdefghij"));
+ test(S("abcdefghij"), 0, 0, "12345", S("12345abcdefghij"));
+ test(S("abcdefghij"), 0, 0, "1234567890", S("1234567890abcdefghij"));
+ test(S("abcdefghij"), 0, 0, "12345678901234567890", S("12345678901234567890abcdefghij"));
+ test(S("abcdefghij"), 0, 1, "", S("bcdefghij"));
+ test(S("abcdefghij"), 0, 1, "12345", S("12345bcdefghij"));
+ test(S("abcdefghij"), 0, 1, "1234567890", S("1234567890bcdefghij"));
+ test(S("abcdefghij"), 0, 1, "12345678901234567890", S("12345678901234567890bcdefghij"));
+ test(S("abcdefghij"), 0, 5, "", S("fghij"));
+ test(S("abcdefghij"), 0, 5, "12345", S("12345fghij"));
+ test(S("abcdefghij"), 0, 5, "1234567890", S("1234567890fghij"));
+ test(S("abcdefghij"), 0, 5, "12345678901234567890", S("12345678901234567890fghij"));
+ test(S("abcdefghij"), 0, 9, "", S("j"));
+ test(S("abcdefghij"), 0, 9, "12345", S("12345j"));
+ test(S("abcdefghij"), 0, 9, "1234567890", S("1234567890j"));
+ test(S("abcdefghij"), 0, 9, "12345678901234567890", S("12345678901234567890j"));
+ test(S("abcdefghij"), 0, 10, "", S(""));
+ test(S("abcdefghij"), 0, 10, "12345", S("12345"));
+ test(S("abcdefghij"), 0, 10, "1234567890", S("1234567890"));
+ test(S("abcdefghij"), 0, 10, "12345678901234567890", S("12345678901234567890"));
+ test(S("abcdefghij"), 0, 11, "", S(""));
+ test(S("abcdefghij"), 0, 11, "12345", S("12345"));
+ test(S("abcdefghij"), 0, 11, "1234567890", S("1234567890"));
+ test(S("abcdefghij"), 0, 11, "12345678901234567890", S("12345678901234567890"));
+ test(S("abcdefghij"), 1, 0, "", S("abcdefghij"));
+ test(S("abcdefghij"), 1, 0, "12345", S("a12345bcdefghij"));
+ test(S("abcdefghij"), 1, 0, "1234567890", S("a1234567890bcdefghij"));
+ test(S("abcdefghij"), 1, 0, "12345678901234567890", S("a12345678901234567890bcdefghij"));
+ test(S("abcdefghij"), 1, 1, "", S("acdefghij"));
+ test(S("abcdefghij"), 1, 1, "12345", S("a12345cdefghij"));
+ test(S("abcdefghij"), 1, 1, "1234567890", S("a1234567890cdefghij"));
+ test(S("abcdefghij"), 1, 1, "12345678901234567890", S("a12345678901234567890cdefghij"));
+ test(S("abcdefghij"), 1, 4, "", S("afghij"));
+ test(S("abcdefghij"), 1, 4, "12345", S("a12345fghij"));
+ test(S("abcdefghij"), 1, 4, "1234567890", S("a1234567890fghij"));
+ test(S("abcdefghij"), 1, 4, "12345678901234567890", S("a12345678901234567890fghij"));
+ test(S("abcdefghij"), 1, 8, "", S("aj"));
+ test(S("abcdefghij"), 1, 8, "12345", S("a12345j"));
+ test(S("abcdefghij"), 1, 8, "1234567890", S("a1234567890j"));
+ test(S("abcdefghij"), 1, 8, "12345678901234567890", S("a12345678901234567890j"));
+ test(S("abcdefghij"), 1, 9, "", S("a"));
+ test(S("abcdefghij"), 1, 9, "12345", S("a12345"));
+ test(S("abcdefghij"), 1, 9, "1234567890", S("a1234567890"));
+ test(S("abcdefghij"), 1, 9, "12345678901234567890", S("a12345678901234567890"));
+ test(S("abcdefghij"), 1, 10, "", S("a"));
+ test(S("abcdefghij"), 1, 10, "12345", S("a12345"));
+ test(S("abcdefghij"), 1, 10, "1234567890", S("a1234567890"));
+ test(S("abcdefghij"), 1, 10, "12345678901234567890", S("a12345678901234567890"));
+ test(S("abcdefghij"), 5, 0, "", S("abcdefghij"));
+ test(S("abcdefghij"), 5, 0, "12345", S("abcde12345fghij"));
+ test(S("abcdefghij"), 5, 0, "1234567890", S("abcde1234567890fghij"));
+ test(S("abcdefghij"), 5, 0, "12345678901234567890", S("abcde12345678901234567890fghij"));
+ test(S("abcdefghij"), 5, 1, "", S("abcdeghij"));
+ test(S("abcdefghij"), 5, 1, "12345", S("abcde12345ghij"));
+ test(S("abcdefghij"), 5, 1, "1234567890", S("abcde1234567890ghij"));
+ test(S("abcdefghij"), 5, 1, "12345678901234567890", S("abcde12345678901234567890ghij"));
+ test(S("abcdefghij"), 5, 2, "", S("abcdehij"));
+ test(S("abcdefghij"), 5, 2, "12345", S("abcde12345hij"));
+ test(S("abcdefghij"), 5, 2, "1234567890", S("abcde1234567890hij"));
+ test(S("abcdefghij"), 5, 2, "12345678901234567890", S("abcde12345678901234567890hij"));
+ test(S("abcdefghij"), 5, 4, "", S("abcdej"));
+ test(S("abcdefghij"), 5, 4, "12345", S("abcde12345j"));
+ test(S("abcdefghij"), 5, 4, "1234567890", S("abcde1234567890j"));
+ test(S("abcdefghij"), 5, 4, "12345678901234567890", S("abcde12345678901234567890j"));
+ test(S("abcdefghij"), 5, 5, "", S("abcde"));
+ test(S("abcdefghij"), 5, 5, "12345", S("abcde12345"));
+ test(S("abcdefghij"), 5, 5, "1234567890", S("abcde1234567890"));
+ test(S("abcdefghij"), 5, 5, "12345678901234567890", S("abcde12345678901234567890"));
+ test(S("abcdefghij"), 5, 6, "", S("abcde"));
+ test(S("abcdefghij"), 5, 6, "12345", S("abcde12345"));
+ test(S("abcdefghij"), 5, 6, "1234567890", S("abcde1234567890"));
+ test(S("abcdefghij"), 5, 6, "12345678901234567890", S("abcde12345678901234567890"));
+ test(S("abcdefghij"), 9, 0, "", S("abcdefghij"));
+ test(S("abcdefghij"), 9, 0, "12345", S("abcdefghi12345j"));
+ test(S("abcdefghij"), 9, 0, "1234567890", S("abcdefghi1234567890j"));
+ test(S("abcdefghij"), 9, 0, "12345678901234567890", S("abcdefghi12345678901234567890j"));
+ test(S("abcdefghij"), 9, 1, "", S("abcdefghi"));
+ test(S("abcdefghij"), 9, 1, "12345", S("abcdefghi12345"));
+ test(S("abcdefghij"), 9, 1, "1234567890", S("abcdefghi1234567890"));
+ test(S("abcdefghij"), 9, 1, "12345678901234567890", S("abcdefghi12345678901234567890"));
+ test(S("abcdefghij"), 9, 2, "", S("abcdefghi"));
+ test(S("abcdefghij"), 9, 2, "12345", S("abcdefghi12345"));
+ test(S("abcdefghij"), 9, 2, "1234567890", S("abcdefghi1234567890"));
+ test(S("abcdefghij"), 9, 2, "12345678901234567890", S("abcdefghi12345678901234567890"));
+ test(S("abcdefghij"), 10, 0, "", S("abcdefghij"));
+ test(S("abcdefghij"), 10, 0, "12345", S("abcdefghij12345"));
+ test(S("abcdefghij"), 10, 0, "1234567890", S("abcdefghij1234567890"));
+ test(S("abcdefghij"), 10, 0, "12345678901234567890", S("abcdefghij12345678901234567890"));
+ test(S("abcdefghij"), 10, 1, "", S("abcdefghij"));
+ test(S("abcdefghij"), 10, 1, "12345", S("abcdefghij12345"));
+ test(S("abcdefghij"), 10, 1, "1234567890", S("abcdefghij1234567890"));
+ test(S("abcdefghij"), 10, 1, "12345678901234567890", S("abcdefghij12345678901234567890"));
+ test(S("abcdefghij"), 11, 0, "", S("can't happen"));
+ test(S("abcdefghij"), 11, 0, "12345", S("can't happen"));
+ test(S("abcdefghij"), 11, 0, "1234567890", S("can't happen"));
+ test(S("abcdefghij"), 11, 0, "12345678901234567890", S("can't happen"));
+}
+
+template <class S>
+void test2()
+{
+ test(S("abcdefghijklmnopqrst"), 0, 0, "", S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, "12345", S("12345abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, "1234567890", S("1234567890abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, "12345678901234567890", S("12345678901234567890abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, "", S("bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, "12345", S("12345bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, "1234567890", S("1234567890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, "12345678901234567890", S("12345678901234567890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, "", S("klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, "12345", S("12345klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, "1234567890", S("1234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, "12345678901234567890", S("12345678901234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, "", S("t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, "12345", S("12345t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, "1234567890", S("1234567890t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, "12345678901234567890", S("12345678901234567890t"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, "", S(""));
+ test(S("abcdefghijklmnopqrst"), 0, 20, "12345", S("12345"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, "1234567890", S("1234567890"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, "12345678901234567890", S("12345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 0, 21, "", S(""));
+ test(S("abcdefghijklmnopqrst"), 0, 21, "12345", S("12345"));
+ test(S("abcdefghijklmnopqrst"), 0, 21, "1234567890", S("1234567890"));
+ test(S("abcdefghijklmnopqrst"), 0, 21, "12345678901234567890", S("12345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, "", S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, "12345", S("a12345bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, "1234567890", S("a1234567890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, "12345678901234567890", S("a12345678901234567890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, "", S("acdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, "12345", S("a12345cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, "1234567890", S("a1234567890cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, "12345678901234567890", S("a12345678901234567890cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, "", S("aklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, "12345", S("a12345klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, "1234567890", S("a1234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, "12345678901234567890", S("a12345678901234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, "", S("at"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, "12345", S("a12345t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, "1234567890", S("a1234567890t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, "12345678901234567890", S("a12345678901234567890t"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, "", S("a"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, "12345", S("a12345"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, "1234567890", S("a1234567890"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, "12345678901234567890", S("a12345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, "", S("a"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, "12345", S("a12345"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, "1234567890", S("a1234567890"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, "12345678901234567890", S("a12345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, "", S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, "12345", S("abcdefghij12345klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, "1234567890", S("abcdefghij1234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, "12345678901234567890", S("abcdefghij12345678901234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, "", S("abcdefghijlmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, "12345", S("abcdefghij12345lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, "1234567890", S("abcdefghij1234567890lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, "12345678901234567890", S("abcdefghij12345678901234567890lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, "", S("abcdefghijpqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, "12345", S("abcdefghij12345pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, "1234567890", S("abcdefghij1234567890pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, "12345678901234567890", S("abcdefghij12345678901234567890pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, "", S("abcdefghijt"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, "12345", S("abcdefghij12345t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, "1234567890", S("abcdefghij1234567890t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, "12345678901234567890", S("abcdefghij12345678901234567890t"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, "", S("abcdefghij"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, "12345", S("abcdefghij12345"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, "1234567890", S("abcdefghij1234567890"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, "12345678901234567890", S("abcdefghij12345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, "", S("abcdefghij"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, "12345", S("abcdefghij12345"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, "1234567890", S("abcdefghij1234567890"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, "12345678901234567890", S("abcdefghij12345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, "", S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, "12345", S("abcdefghijklmnopqrs12345t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, "1234567890", S("abcdefghijklmnopqrs1234567890t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, "12345678901234567890", S("abcdefghijklmnopqrs12345678901234567890t"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, "", S("abcdefghijklmnopqrs"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, "12345", S("abcdefghijklmnopqrs12345"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, "1234567890", S("abcdefghijklmnopqrs1234567890"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, "12345678901234567890", S("abcdefghijklmnopqrs12345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, "", S("abcdefghijklmnopqrs"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, "12345", S("abcdefghijklmnopqrs12345"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, "1234567890", S("abcdefghijklmnopqrs1234567890"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, "12345678901234567890", S("abcdefghijklmnopqrs12345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, "", S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, "12345", S("abcdefghijklmnopqrst12345"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, "1234567890", S("abcdefghijklmnopqrst1234567890"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, "12345678901234567890", S("abcdefghijklmnopqrst12345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, "", S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, "12345", S("abcdefghijklmnopqrst12345"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, "1234567890", S("abcdefghijklmnopqrst1234567890"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, "12345678901234567890", S("abcdefghijklmnopqrst12345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, "", S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, "12345", S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, "1234567890", S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, "12345678901234567890", S("can't happen"));
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test0<S>();
+ test1<S>();
+ test2<S>();
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test0<S>();
+ test1<S>();
+ test2<S>();
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.modifiers/string_replace/size_size_pointer_size.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_replace/size_size_pointer_size.pass.cpp
new file mode 100644
index 000000000000..d98704287327
--- /dev/null
+++ b/test/std/strings/basic.string/string.modifiers/string_replace/size_size_pointer_size.pass.cpp
@@ -0,0 +1,1327 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string<charT,traits,Allocator>&
+// replace(size_type pos, size_type n1, const charT* s, size_type n2);
+
+#include <stdio.h>
+
+#include <string>
+#include <stdexcept>
+#include <algorithm>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s, typename S::size_type pos, typename S::size_type n1,
+ const typename S::value_type* str, typename S::size_type n2,
+ S expected)
+{
+ typename S::size_type old_size = s.size();
+ S s0 = s;
+ try
+ {
+ s.replace(pos, n1, str, n2);
+ assert(s.__invariants());
+ assert(pos <= old_size);
+ assert(s == expected);
+ typename S::size_type xlen = std::min(n1, old_size - pos);
+ typename S::size_type rlen = n2;
+ assert(s.size() == old_size - xlen + rlen);
+ }
+ catch (std::out_of_range&)
+ {
+ assert(pos > old_size);
+ assert(s == s0);
+ }
+}
+
+template <class S>
+void test0()
+{
+ test(S(""), 0, 0, "", 0, S(""));
+ test(S(""), 0, 0, "12345", 0, S(""));
+ test(S(""), 0, 0, "12345", 1, S("1"));
+ test(S(""), 0, 0, "12345", 2, S("12"));
+ test(S(""), 0, 0, "12345", 4, S("1234"));
+ test(S(""), 0, 0, "12345", 5, S("12345"));
+ test(S(""), 0, 0, "1234567890", 0, S(""));
+ test(S(""), 0, 0, "1234567890", 1, S("1"));
+ test(S(""), 0, 0, "1234567890", 5, S("12345"));
+ test(S(""), 0, 0, "1234567890", 9, S("123456789"));
+ test(S(""), 0, 0, "1234567890", 10, S("1234567890"));
+ test(S(""), 0, 0, "12345678901234567890", 0, S(""));
+ test(S(""), 0, 0, "12345678901234567890", 1, S("1"));
+ test(S(""), 0, 0, "12345678901234567890", 10, S("1234567890"));
+ test(S(""), 0, 0, "12345678901234567890", 19, S("1234567890123456789"));
+ test(S(""), 0, 0, "12345678901234567890", 20, S("12345678901234567890"));
+ test(S(""), 0, 1, "", 0, S(""));
+ test(S(""), 0, 1, "12345", 0, S(""));
+ test(S(""), 0, 1, "12345", 1, S("1"));
+ test(S(""), 0, 1, "12345", 2, S("12"));
+ test(S(""), 0, 1, "12345", 4, S("1234"));
+ test(S(""), 0, 1, "12345", 5, S("12345"));
+ test(S(""), 0, 1, "1234567890", 0, S(""));
+ test(S(""), 0, 1, "1234567890", 1, S("1"));
+ test(S(""), 0, 1, "1234567890", 5, S("12345"));
+ test(S(""), 0, 1, "1234567890", 9, S("123456789"));
+ test(S(""), 0, 1, "1234567890", 10, S("1234567890"));
+ test(S(""), 0, 1, "12345678901234567890", 0, S(""));
+ test(S(""), 0, 1, "12345678901234567890", 1, S("1"));
+ test(S(""), 0, 1, "12345678901234567890", 10, S("1234567890"));
+ test(S(""), 0, 1, "12345678901234567890", 19, S("1234567890123456789"));
+ test(S(""), 0, 1, "12345678901234567890", 20, S("12345678901234567890"));
+ test(S(""), 1, 0, "", 0, S("can't happen"));
+ test(S(""), 1, 0, "12345", 0, S("can't happen"));
+ test(S(""), 1, 0, "12345", 1, S("can't happen"));
+ test(S(""), 1, 0, "12345", 2, S("can't happen"));
+ test(S(""), 1, 0, "12345", 4, S("can't happen"));
+ test(S(""), 1, 0, "12345", 5, S("can't happen"));
+ test(S(""), 1, 0, "1234567890", 0, S("can't happen"));
+ test(S(""), 1, 0, "1234567890", 1, S("can't happen"));
+ test(S(""), 1, 0, "1234567890", 5, S("can't happen"));
+ test(S(""), 1, 0, "1234567890", 9, S("can't happen"));
+ test(S(""), 1, 0, "1234567890", 10, S("can't happen"));
+ test(S(""), 1, 0, "12345678901234567890", 0, S("can't happen"));
+ test(S(""), 1, 0, "12345678901234567890", 1, S("can't happen"));
+ test(S(""), 1, 0, "12345678901234567890", 10, S("can't happen"));
+ test(S(""), 1, 0, "12345678901234567890", 19, S("can't happen"));
+ test(S(""), 1, 0, "12345678901234567890", 20, S("can't happen"));
+ test(S("abcde"), 0, 0, "", 0, S("abcde"));
+ test(S("abcde"), 0, 0, "12345", 0, S("abcde"));
+ test(S("abcde"), 0, 0, "12345", 1, S("1abcde"));
+ test(S("abcde"), 0, 0, "12345", 2, S("12abcde"));
+ test(S("abcde"), 0, 0, "12345", 4, S("1234abcde"));
+ test(S("abcde"), 0, 0, "12345", 5, S("12345abcde"));
+ test(S("abcde"), 0, 0, "1234567890", 0, S("abcde"));
+ test(S("abcde"), 0, 0, "1234567890", 1, S("1abcde"));
+ test(S("abcde"), 0, 0, "1234567890", 5, S("12345abcde"));
+ test(S("abcde"), 0, 0, "1234567890", 9, S("123456789abcde"));
+ test(S("abcde"), 0, 0, "1234567890", 10, S("1234567890abcde"));
+ test(S("abcde"), 0, 0, "12345678901234567890", 0, S("abcde"));
+ test(S("abcde"), 0, 0, "12345678901234567890", 1, S("1abcde"));
+ test(S("abcde"), 0, 0, "12345678901234567890", 10, S("1234567890abcde"));
+ test(S("abcde"), 0, 0, "12345678901234567890", 19, S("1234567890123456789abcde"));
+ test(S("abcde"), 0, 0, "12345678901234567890", 20, S("12345678901234567890abcde"));
+ test(S("abcde"), 0, 1, "", 0, S("bcde"));
+ test(S("abcde"), 0, 1, "12345", 0, S("bcde"));
+ test(S("abcde"), 0, 1, "12345", 1, S("1bcde"));
+ test(S("abcde"), 0, 1, "12345", 2, S("12bcde"));
+ test(S("abcde"), 0, 1, "12345", 4, S("1234bcde"));
+ test(S("abcde"), 0, 1, "12345", 5, S("12345bcde"));
+ test(S("abcde"), 0, 1, "1234567890", 0, S("bcde"));
+ test(S("abcde"), 0, 1, "1234567890", 1, S("1bcde"));
+ test(S("abcde"), 0, 1, "1234567890", 5, S("12345bcde"));
+ test(S("abcde"), 0, 1, "1234567890", 9, S("123456789bcde"));
+ test(S("abcde"), 0, 1, "1234567890", 10, S("1234567890bcde"));
+ test(S("abcde"), 0, 1, "12345678901234567890", 0, S("bcde"));
+ test(S("abcde"), 0, 1, "12345678901234567890", 1, S("1bcde"));
+ test(S("abcde"), 0, 1, "12345678901234567890", 10, S("1234567890bcde"));
+ test(S("abcde"), 0, 1, "12345678901234567890", 19, S("1234567890123456789bcde"));
+ test(S("abcde"), 0, 1, "12345678901234567890", 20, S("12345678901234567890bcde"));
+ test(S("abcde"), 0, 2, "", 0, S("cde"));
+ test(S("abcde"), 0, 2, "12345", 0, S("cde"));
+ test(S("abcde"), 0, 2, "12345", 1, S("1cde"));
+ test(S("abcde"), 0, 2, "12345", 2, S("12cde"));
+ test(S("abcde"), 0, 2, "12345", 4, S("1234cde"));
+ test(S("abcde"), 0, 2, "12345", 5, S("12345cde"));
+ test(S("abcde"), 0, 2, "1234567890", 0, S("cde"));
+ test(S("abcde"), 0, 2, "1234567890", 1, S("1cde"));
+ test(S("abcde"), 0, 2, "1234567890", 5, S("12345cde"));
+ test(S("abcde"), 0, 2, "1234567890", 9, S("123456789cde"));
+ test(S("abcde"), 0, 2, "1234567890", 10, S("1234567890cde"));
+ test(S("abcde"), 0, 2, "12345678901234567890", 0, S("cde"));
+ test(S("abcde"), 0, 2, "12345678901234567890", 1, S("1cde"));
+ test(S("abcde"), 0, 2, "12345678901234567890", 10, S("1234567890cde"));
+ test(S("abcde"), 0, 2, "12345678901234567890", 19, S("1234567890123456789cde"));
+ test(S("abcde"), 0, 2, "12345678901234567890", 20, S("12345678901234567890cde"));
+ test(S("abcde"), 0, 4, "", 0, S("e"));
+ test(S("abcde"), 0, 4, "12345", 0, S("e"));
+ test(S("abcde"), 0, 4, "12345", 1, S("1e"));
+ test(S("abcde"), 0, 4, "12345", 2, S("12e"));
+}
+
+template <class S>
+void test1()
+{
+ test(S("abcde"), 0, 4, "12345", 4, S("1234e"));
+ test(S("abcde"), 0, 4, "12345", 5, S("12345e"));
+ test(S("abcde"), 0, 4, "1234567890", 0, S("e"));
+ test(S("abcde"), 0, 4, "1234567890", 1, S("1e"));
+ test(S("abcde"), 0, 4, "1234567890", 5, S("12345e"));
+ test(S("abcde"), 0, 4, "1234567890", 9, S("123456789e"));
+ test(S("abcde"), 0, 4, "1234567890", 10, S("1234567890e"));
+ test(S("abcde"), 0, 4, "12345678901234567890", 0, S("e"));
+ test(S("abcde"), 0, 4, "12345678901234567890", 1, S("1e"));
+ test(S("abcde"), 0, 4, "12345678901234567890", 10, S("1234567890e"));
+ test(S("abcde"), 0, 4, "12345678901234567890", 19, S("1234567890123456789e"));
+ test(S("abcde"), 0, 4, "12345678901234567890", 20, S("12345678901234567890e"));
+ test(S("abcde"), 0, 5, "", 0, S(""));
+ test(S("abcde"), 0, 5, "12345", 0, S(""));
+ test(S("abcde"), 0, 5, "12345", 1, S("1"));
+ test(S("abcde"), 0, 5, "12345", 2, S("12"));
+ test(S("abcde"), 0, 5, "12345", 4, S("1234"));
+ test(S("abcde"), 0, 5, "12345", 5, S("12345"));
+ test(S("abcde"), 0, 5, "1234567890", 0, S(""));
+ test(S("abcde"), 0, 5, "1234567890", 1, S("1"));
+ test(S("abcde"), 0, 5, "1234567890", 5, S("12345"));
+ test(S("abcde"), 0, 5, "1234567890", 9, S("123456789"));
+ test(S("abcde"), 0, 5, "1234567890", 10, S("1234567890"));
+ test(S("abcde"), 0, 5, "12345678901234567890", 0, S(""));
+ test(S("abcde"), 0, 5, "12345678901234567890", 1, S("1"));
+ test(S("abcde"), 0, 5, "12345678901234567890", 10, S("1234567890"));
+ test(S("abcde"), 0, 5, "12345678901234567890", 19, S("1234567890123456789"));
+ test(S("abcde"), 0, 5, "12345678901234567890", 20, S("12345678901234567890"));
+ test(S("abcde"), 0, 6, "", 0, S(""));
+ test(S("abcde"), 0, 6, "12345", 0, S(""));
+ test(S("abcde"), 0, 6, "12345", 1, S("1"));
+ test(S("abcde"), 0, 6, "12345", 2, S("12"));
+ test(S("abcde"), 0, 6, "12345", 4, S("1234"));
+ test(S("abcde"), 0, 6, "12345", 5, S("12345"));
+ test(S("abcde"), 0, 6, "1234567890", 0, S(""));
+ test(S("abcde"), 0, 6, "1234567890", 1, S("1"));
+ test(S("abcde"), 0, 6, "1234567890", 5, S("12345"));
+ test(S("abcde"), 0, 6, "1234567890", 9, S("123456789"));
+ test(S("abcde"), 0, 6, "1234567890", 10, S("1234567890"));
+ test(S("abcde"), 0, 6, "12345678901234567890", 0, S(""));
+ test(S("abcde"), 0, 6, "12345678901234567890", 1, S("1"));
+ test(S("abcde"), 0, 6, "12345678901234567890", 10, S("1234567890"));
+ test(S("abcde"), 0, 6, "12345678901234567890", 19, S("1234567890123456789"));
+ test(S("abcde"), 0, 6, "12345678901234567890", 20, S("12345678901234567890"));
+ test(S("abcde"), 1, 0, "", 0, S("abcde"));
+ test(S("abcde"), 1, 0, "12345", 0, S("abcde"));
+ test(S("abcde"), 1, 0, "12345", 1, S("a1bcde"));
+ test(S("abcde"), 1, 0, "12345", 2, S("a12bcde"));
+ test(S("abcde"), 1, 0, "12345", 4, S("a1234bcde"));
+ test(S("abcde"), 1, 0, "12345", 5, S("a12345bcde"));
+ test(S("abcde"), 1, 0, "1234567890", 0, S("abcde"));
+ test(S("abcde"), 1, 0, "1234567890", 1, S("a1bcde"));
+ test(S("abcde"), 1, 0, "1234567890", 5, S("a12345bcde"));
+ test(S("abcde"), 1, 0, "1234567890", 9, S("a123456789bcde"));
+ test(S("abcde"), 1, 0, "1234567890", 10, S("a1234567890bcde"));
+ test(S("abcde"), 1, 0, "12345678901234567890", 0, S("abcde"));
+ test(S("abcde"), 1, 0, "12345678901234567890", 1, S("a1bcde"));
+ test(S("abcde"), 1, 0, "12345678901234567890", 10, S("a1234567890bcde"));
+ test(S("abcde"), 1, 0, "12345678901234567890", 19, S("a1234567890123456789bcde"));
+ test(S("abcde"), 1, 0, "12345678901234567890", 20, S("a12345678901234567890bcde"));
+ test(S("abcde"), 1, 1, "", 0, S("acde"));
+ test(S("abcde"), 1, 1, "12345", 0, S("acde"));
+ test(S("abcde"), 1, 1, "12345", 1, S("a1cde"));
+ test(S("abcde"), 1, 1, "12345", 2, S("a12cde"));
+ test(S("abcde"), 1, 1, "12345", 4, S("a1234cde"));
+ test(S("abcde"), 1, 1, "12345", 5, S("a12345cde"));
+ test(S("abcde"), 1, 1, "1234567890", 0, S("acde"));
+ test(S("abcde"), 1, 1, "1234567890", 1, S("a1cde"));
+ test(S("abcde"), 1, 1, "1234567890", 5, S("a12345cde"));
+ test(S("abcde"), 1, 1, "1234567890", 9, S("a123456789cde"));
+ test(S("abcde"), 1, 1, "1234567890", 10, S("a1234567890cde"));
+ test(S("abcde"), 1, 1, "12345678901234567890", 0, S("acde"));
+ test(S("abcde"), 1, 1, "12345678901234567890", 1, S("a1cde"));
+ test(S("abcde"), 1, 1, "12345678901234567890", 10, S("a1234567890cde"));
+ test(S("abcde"), 1, 1, "12345678901234567890", 19, S("a1234567890123456789cde"));
+ test(S("abcde"), 1, 1, "12345678901234567890", 20, S("a12345678901234567890cde"));
+ test(S("abcde"), 1, 2, "", 0, S("ade"));
+ test(S("abcde"), 1, 2, "12345", 0, S("ade"));
+ test(S("abcde"), 1, 2, "12345", 1, S("a1de"));
+ test(S("abcde"), 1, 2, "12345", 2, S("a12de"));
+ test(S("abcde"), 1, 2, "12345", 4, S("a1234de"));
+ test(S("abcde"), 1, 2, "12345", 5, S("a12345de"));
+ test(S("abcde"), 1, 2, "1234567890", 0, S("ade"));
+ test(S("abcde"), 1, 2, "1234567890", 1, S("a1de"));
+ test(S("abcde"), 1, 2, "1234567890", 5, S("a12345de"));
+ test(S("abcde"), 1, 2, "1234567890", 9, S("a123456789de"));
+ test(S("abcde"), 1, 2, "1234567890", 10, S("a1234567890de"));
+ test(S("abcde"), 1, 2, "12345678901234567890", 0, S("ade"));
+ test(S("abcde"), 1, 2, "12345678901234567890", 1, S("a1de"));
+ test(S("abcde"), 1, 2, "12345678901234567890", 10, S("a1234567890de"));
+ test(S("abcde"), 1, 2, "12345678901234567890", 19, S("a1234567890123456789de"));
+ test(S("abcde"), 1, 2, "12345678901234567890", 20, S("a12345678901234567890de"));
+ test(S("abcde"), 1, 3, "", 0, S("ae"));
+ test(S("abcde"), 1, 3, "12345", 0, S("ae"));
+ test(S("abcde"), 1, 3, "12345", 1, S("a1e"));
+ test(S("abcde"), 1, 3, "12345", 2, S("a12e"));
+ test(S("abcde"), 1, 3, "12345", 4, S("a1234e"));
+ test(S("abcde"), 1, 3, "12345", 5, S("a12345e"));
+ test(S("abcde"), 1, 3, "1234567890", 0, S("ae"));
+ test(S("abcde"), 1, 3, "1234567890", 1, S("a1e"));
+}
+
+template <class S>
+void test2()
+{
+ test(S("abcde"), 1, 3, "1234567890", 5, S("a12345e"));
+ test(S("abcde"), 1, 3, "1234567890", 9, S("a123456789e"));
+ test(S("abcde"), 1, 3, "1234567890", 10, S("a1234567890e"));
+ test(S("abcde"), 1, 3, "12345678901234567890", 0, S("ae"));
+ test(S("abcde"), 1, 3, "12345678901234567890", 1, S("a1e"));
+ test(S("abcde"), 1, 3, "12345678901234567890", 10, S("a1234567890e"));
+ test(S("abcde"), 1, 3, "12345678901234567890", 19, S("a1234567890123456789e"));
+ test(S("abcde"), 1, 3, "12345678901234567890", 20, S("a12345678901234567890e"));
+ test(S("abcde"), 1, 4, "", 0, S("a"));
+ test(S("abcde"), 1, 4, "12345", 0, S("a"));
+ test(S("abcde"), 1, 4, "12345", 1, S("a1"));
+ test(S("abcde"), 1, 4, "12345", 2, S("a12"));
+ test(S("abcde"), 1, 4, "12345", 4, S("a1234"));
+ test(S("abcde"), 1, 4, "12345", 5, S("a12345"));
+ test(S("abcde"), 1, 4, "1234567890", 0, S("a"));
+ test(S("abcde"), 1, 4, "1234567890", 1, S("a1"));
+ test(S("abcde"), 1, 4, "1234567890", 5, S("a12345"));
+ test(S("abcde"), 1, 4, "1234567890", 9, S("a123456789"));
+ test(S("abcde"), 1, 4, "1234567890", 10, S("a1234567890"));
+ test(S("abcde"), 1, 4, "12345678901234567890", 0, S("a"));
+ test(S("abcde"), 1, 4, "12345678901234567890", 1, S("a1"));
+ test(S("abcde"), 1, 4, "12345678901234567890", 10, S("a1234567890"));
+ test(S("abcde"), 1, 4, "12345678901234567890", 19, S("a1234567890123456789"));
+ test(S("abcde"), 1, 4, "12345678901234567890", 20, S("a12345678901234567890"));
+ test(S("abcde"), 1, 5, "", 0, S("a"));
+ test(S("abcde"), 1, 5, "12345", 0, S("a"));
+ test(S("abcde"), 1, 5, "12345", 1, S("a1"));
+ test(S("abcde"), 1, 5, "12345", 2, S("a12"));
+ test(S("abcde"), 1, 5, "12345", 4, S("a1234"));
+ test(S("abcde"), 1, 5, "12345", 5, S("a12345"));
+ test(S("abcde"), 1, 5, "1234567890", 0, S("a"));
+ test(S("abcde"), 1, 5, "1234567890", 1, S("a1"));
+ test(S("abcde"), 1, 5, "1234567890", 5, S("a12345"));
+ test(S("abcde"), 1, 5, "1234567890", 9, S("a123456789"));
+ test(S("abcde"), 1, 5, "1234567890", 10, S("a1234567890"));
+ test(S("abcde"), 1, 5, "12345678901234567890", 0, S("a"));
+ test(S("abcde"), 1, 5, "12345678901234567890", 1, S("a1"));
+ test(S("abcde"), 1, 5, "12345678901234567890", 10, S("a1234567890"));
+ test(S("abcde"), 1, 5, "12345678901234567890", 19, S("a1234567890123456789"));
+ test(S("abcde"), 1, 5, "12345678901234567890", 20, S("a12345678901234567890"));
+ test(S("abcde"), 2, 0, "", 0, S("abcde"));
+ test(S("abcde"), 2, 0, "12345", 0, S("abcde"));
+ test(S("abcde"), 2, 0, "12345", 1, S("ab1cde"));
+ test(S("abcde"), 2, 0, "12345", 2, S("ab12cde"));
+ test(S("abcde"), 2, 0, "12345", 4, S("ab1234cde"));
+ test(S("abcde"), 2, 0, "12345", 5, S("ab12345cde"));
+ test(S("abcde"), 2, 0, "1234567890", 0, S("abcde"));
+ test(S("abcde"), 2, 0, "1234567890", 1, S("ab1cde"));
+ test(S("abcde"), 2, 0, "1234567890", 5, S("ab12345cde"));
+ test(S("abcde"), 2, 0, "1234567890", 9, S("ab123456789cde"));
+ test(S("abcde"), 2, 0, "1234567890", 10, S("ab1234567890cde"));
+ test(S("abcde"), 2, 0, "12345678901234567890", 0, S("abcde"));
+ test(S("abcde"), 2, 0, "12345678901234567890", 1, S("ab1cde"));
+ test(S("abcde"), 2, 0, "12345678901234567890", 10, S("ab1234567890cde"));
+ test(S("abcde"), 2, 0, "12345678901234567890", 19, S("ab1234567890123456789cde"));
+ test(S("abcde"), 2, 0, "12345678901234567890", 20, S("ab12345678901234567890cde"));
+ test(S("abcde"), 2, 1, "", 0, S("abde"));
+ test(S("abcde"), 2, 1, "12345", 0, S("abde"));
+ test(S("abcde"), 2, 1, "12345", 1, S("ab1de"));
+ test(S("abcde"), 2, 1, "12345", 2, S("ab12de"));
+ test(S("abcde"), 2, 1, "12345", 4, S("ab1234de"));
+ test(S("abcde"), 2, 1, "12345", 5, S("ab12345de"));
+ test(S("abcde"), 2, 1, "1234567890", 0, S("abde"));
+ test(S("abcde"), 2, 1, "1234567890", 1, S("ab1de"));
+ test(S("abcde"), 2, 1, "1234567890", 5, S("ab12345de"));
+ test(S("abcde"), 2, 1, "1234567890", 9, S("ab123456789de"));
+ test(S("abcde"), 2, 1, "1234567890", 10, S("ab1234567890de"));
+ test(S("abcde"), 2, 1, "12345678901234567890", 0, S("abde"));
+ test(S("abcde"), 2, 1, "12345678901234567890", 1, S("ab1de"));
+ test(S("abcde"), 2, 1, "12345678901234567890", 10, S("ab1234567890de"));
+ test(S("abcde"), 2, 1, "12345678901234567890", 19, S("ab1234567890123456789de"));
+ test(S("abcde"), 2, 1, "12345678901234567890", 20, S("ab12345678901234567890de"));
+ test(S("abcde"), 2, 2, "", 0, S("abe"));
+ test(S("abcde"), 2, 2, "12345", 0, S("abe"));
+ test(S("abcde"), 2, 2, "12345", 1, S("ab1e"));
+ test(S("abcde"), 2, 2, "12345", 2, S("ab12e"));
+ test(S("abcde"), 2, 2, "12345", 4, S("ab1234e"));
+ test(S("abcde"), 2, 2, "12345", 5, S("ab12345e"));
+ test(S("abcde"), 2, 2, "1234567890", 0, S("abe"));
+ test(S("abcde"), 2, 2, "1234567890", 1, S("ab1e"));
+ test(S("abcde"), 2, 2, "1234567890", 5, S("ab12345e"));
+ test(S("abcde"), 2, 2, "1234567890", 9, S("ab123456789e"));
+ test(S("abcde"), 2, 2, "1234567890", 10, S("ab1234567890e"));
+ test(S("abcde"), 2, 2, "12345678901234567890", 0, S("abe"));
+ test(S("abcde"), 2, 2, "12345678901234567890", 1, S("ab1e"));
+ test(S("abcde"), 2, 2, "12345678901234567890", 10, S("ab1234567890e"));
+ test(S("abcde"), 2, 2, "12345678901234567890", 19, S("ab1234567890123456789e"));
+ test(S("abcde"), 2, 2, "12345678901234567890", 20, S("ab12345678901234567890e"));
+ test(S("abcde"), 2, 3, "", 0, S("ab"));
+ test(S("abcde"), 2, 3, "12345", 0, S("ab"));
+ test(S("abcde"), 2, 3, "12345", 1, S("ab1"));
+ test(S("abcde"), 2, 3, "12345", 2, S("ab12"));
+ test(S("abcde"), 2, 3, "12345", 4, S("ab1234"));
+ test(S("abcde"), 2, 3, "12345", 5, S("ab12345"));
+ test(S("abcde"), 2, 3, "1234567890", 0, S("ab"));
+ test(S("abcde"), 2, 3, "1234567890", 1, S("ab1"));
+ test(S("abcde"), 2, 3, "1234567890", 5, S("ab12345"));
+ test(S("abcde"), 2, 3, "1234567890", 9, S("ab123456789"));
+ test(S("abcde"), 2, 3, "1234567890", 10, S("ab1234567890"));
+ test(S("abcde"), 2, 3, "12345678901234567890", 0, S("ab"));
+}
+
+template <class S>
+void test3()
+{
+ test(S("abcde"), 2, 3, "12345678901234567890", 1, S("ab1"));
+ test(S("abcde"), 2, 3, "12345678901234567890", 10, S("ab1234567890"));
+ test(S("abcde"), 2, 3, "12345678901234567890", 19, S("ab1234567890123456789"));
+ test(S("abcde"), 2, 3, "12345678901234567890", 20, S("ab12345678901234567890"));
+ test(S("abcde"), 2, 4, "", 0, S("ab"));
+ test(S("abcde"), 2, 4, "12345", 0, S("ab"));
+ test(S("abcde"), 2, 4, "12345", 1, S("ab1"));
+ test(S("abcde"), 2, 4, "12345", 2, S("ab12"));
+ test(S("abcde"), 2, 4, "12345", 4, S("ab1234"));
+ test(S("abcde"), 2, 4, "12345", 5, S("ab12345"));
+ test(S("abcde"), 2, 4, "1234567890", 0, S("ab"));
+ test(S("abcde"), 2, 4, "1234567890", 1, S("ab1"));
+ test(S("abcde"), 2, 4, "1234567890", 5, S("ab12345"));
+ test(S("abcde"), 2, 4, "1234567890", 9, S("ab123456789"));
+ test(S("abcde"), 2, 4, "1234567890", 10, S("ab1234567890"));
+ test(S("abcde"), 2, 4, "12345678901234567890", 0, S("ab"));
+ test(S("abcde"), 2, 4, "12345678901234567890", 1, S("ab1"));
+ test(S("abcde"), 2, 4, "12345678901234567890", 10, S("ab1234567890"));
+ test(S("abcde"), 2, 4, "12345678901234567890", 19, S("ab1234567890123456789"));
+ test(S("abcde"), 2, 4, "12345678901234567890", 20, S("ab12345678901234567890"));
+ test(S("abcde"), 4, 0, "", 0, S("abcde"));
+ test(S("abcde"), 4, 0, "12345", 0, S("abcde"));
+ test(S("abcde"), 4, 0, "12345", 1, S("abcd1e"));
+ test(S("abcde"), 4, 0, "12345", 2, S("abcd12e"));
+ test(S("abcde"), 4, 0, "12345", 4, S("abcd1234e"));
+ test(S("abcde"), 4, 0, "12345", 5, S("abcd12345e"));
+ test(S("abcde"), 4, 0, "1234567890", 0, S("abcde"));
+ test(S("abcde"), 4, 0, "1234567890", 1, S("abcd1e"));
+ test(S("abcde"), 4, 0, "1234567890", 5, S("abcd12345e"));
+ test(S("abcde"), 4, 0, "1234567890", 9, S("abcd123456789e"));
+ test(S("abcde"), 4, 0, "1234567890", 10, S("abcd1234567890e"));
+ test(S("abcde"), 4, 0, "12345678901234567890", 0, S("abcde"));
+ test(S("abcde"), 4, 0, "12345678901234567890", 1, S("abcd1e"));
+ test(S("abcde"), 4, 0, "12345678901234567890", 10, S("abcd1234567890e"));
+ test(S("abcde"), 4, 0, "12345678901234567890", 19, S("abcd1234567890123456789e"));
+ test(S("abcde"), 4, 0, "12345678901234567890", 20, S("abcd12345678901234567890e"));
+ test(S("abcde"), 4, 1, "", 0, S("abcd"));
+ test(S("abcde"), 4, 1, "12345", 0, S("abcd"));
+ test(S("abcde"), 4, 1, "12345", 1, S("abcd1"));
+ test(S("abcde"), 4, 1, "12345", 2, S("abcd12"));
+ test(S("abcde"), 4, 1, "12345", 4, S("abcd1234"));
+ test(S("abcde"), 4, 1, "12345", 5, S("abcd12345"));
+ test(S("abcde"), 4, 1, "1234567890", 0, S("abcd"));
+ test(S("abcde"), 4, 1, "1234567890", 1, S("abcd1"));
+ test(S("abcde"), 4, 1, "1234567890", 5, S("abcd12345"));
+ test(S("abcde"), 4, 1, "1234567890", 9, S("abcd123456789"));
+ test(S("abcde"), 4, 1, "1234567890", 10, S("abcd1234567890"));
+ test(S("abcde"), 4, 1, "12345678901234567890", 0, S("abcd"));
+ test(S("abcde"), 4, 1, "12345678901234567890", 1, S("abcd1"));
+ test(S("abcde"), 4, 1, "12345678901234567890", 10, S("abcd1234567890"));
+ test(S("abcde"), 4, 1, "12345678901234567890", 19, S("abcd1234567890123456789"));
+ test(S("abcde"), 4, 1, "12345678901234567890", 20, S("abcd12345678901234567890"));
+ test(S("abcde"), 4, 2, "", 0, S("abcd"));
+ test(S("abcde"), 4, 2, "12345", 0, S("abcd"));
+ test(S("abcde"), 4, 2, "12345", 1, S("abcd1"));
+ test(S("abcde"), 4, 2, "12345", 2, S("abcd12"));
+ test(S("abcde"), 4, 2, "12345", 4, S("abcd1234"));
+ test(S("abcde"), 4, 2, "12345", 5, S("abcd12345"));
+ test(S("abcde"), 4, 2, "1234567890", 0, S("abcd"));
+ test(S("abcde"), 4, 2, "1234567890", 1, S("abcd1"));
+ test(S("abcde"), 4, 2, "1234567890", 5, S("abcd12345"));
+ test(S("abcde"), 4, 2, "1234567890", 9, S("abcd123456789"));
+ test(S("abcde"), 4, 2, "1234567890", 10, S("abcd1234567890"));
+ test(S("abcde"), 4, 2, "12345678901234567890", 0, S("abcd"));
+ test(S("abcde"), 4, 2, "12345678901234567890", 1, S("abcd1"));
+ test(S("abcde"), 4, 2, "12345678901234567890", 10, S("abcd1234567890"));
+ test(S("abcde"), 4, 2, "12345678901234567890", 19, S("abcd1234567890123456789"));
+ test(S("abcde"), 4, 2, "12345678901234567890", 20, S("abcd12345678901234567890"));
+ test(S("abcde"), 5, 0, "", 0, S("abcde"));
+ test(S("abcde"), 5, 0, "12345", 0, S("abcde"));
+ test(S("abcde"), 5, 0, "12345", 1, S("abcde1"));
+ test(S("abcde"), 5, 0, "12345", 2, S("abcde12"));
+ test(S("abcde"), 5, 0, "12345", 4, S("abcde1234"));
+ test(S("abcde"), 5, 0, "12345", 5, S("abcde12345"));
+ test(S("abcde"), 5, 0, "1234567890", 0, S("abcde"));
+ test(S("abcde"), 5, 0, "1234567890", 1, S("abcde1"));
+ test(S("abcde"), 5, 0, "1234567890", 5, S("abcde12345"));
+ test(S("abcde"), 5, 0, "1234567890", 9, S("abcde123456789"));
+ test(S("abcde"), 5, 0, "1234567890", 10, S("abcde1234567890"));
+ test(S("abcde"), 5, 0, "12345678901234567890", 0, S("abcde"));
+ test(S("abcde"), 5, 0, "12345678901234567890", 1, S("abcde1"));
+ test(S("abcde"), 5, 0, "12345678901234567890", 10, S("abcde1234567890"));
+ test(S("abcde"), 5, 0, "12345678901234567890", 19, S("abcde1234567890123456789"));
+ test(S("abcde"), 5, 0, "12345678901234567890", 20, S("abcde12345678901234567890"));
+ test(S("abcde"), 5, 1, "", 0, S("abcde"));
+ test(S("abcde"), 5, 1, "12345", 0, S("abcde"));
+ test(S("abcde"), 5, 1, "12345", 1, S("abcde1"));
+ test(S("abcde"), 5, 1, "12345", 2, S("abcde12"));
+ test(S("abcde"), 5, 1, "12345", 4, S("abcde1234"));
+ test(S("abcde"), 5, 1, "12345", 5, S("abcde12345"));
+ test(S("abcde"), 5, 1, "1234567890", 0, S("abcde"));
+ test(S("abcde"), 5, 1, "1234567890", 1, S("abcde1"));
+ test(S("abcde"), 5, 1, "1234567890", 5, S("abcde12345"));
+ test(S("abcde"), 5, 1, "1234567890", 9, S("abcde123456789"));
+ test(S("abcde"), 5, 1, "1234567890", 10, S("abcde1234567890"));
+ test(S("abcde"), 5, 1, "12345678901234567890", 0, S("abcde"));
+ test(S("abcde"), 5, 1, "12345678901234567890", 1, S("abcde1"));
+ test(S("abcde"), 5, 1, "12345678901234567890", 10, S("abcde1234567890"));
+ test(S("abcde"), 5, 1, "12345678901234567890", 19, S("abcde1234567890123456789"));
+ test(S("abcde"), 5, 1, "12345678901234567890", 20, S("abcde12345678901234567890"));
+}
+
+template <class S>
+void test4()
+{
+ test(S("abcde"), 6, 0, "", 0, S("can't happen"));
+ test(S("abcde"), 6, 0, "12345", 0, S("can't happen"));
+ test(S("abcde"), 6, 0, "12345", 1, S("can't happen"));
+ test(S("abcde"), 6, 0, "12345", 2, S("can't happen"));
+ test(S("abcde"), 6, 0, "12345", 4, S("can't happen"));
+ test(S("abcde"), 6, 0, "12345", 5, S("can't happen"));
+ test(S("abcde"), 6, 0, "1234567890", 0, S("can't happen"));
+ test(S("abcde"), 6, 0, "1234567890", 1, S("can't happen"));
+ test(S("abcde"), 6, 0, "1234567890", 5, S("can't happen"));
+ test(S("abcde"), 6, 0, "1234567890", 9, S("can't happen"));
+ test(S("abcde"), 6, 0, "1234567890", 10, S("can't happen"));
+ test(S("abcde"), 6, 0, "12345678901234567890", 0, S("can't happen"));
+ test(S("abcde"), 6, 0, "12345678901234567890", 1, S("can't happen"));
+ test(S("abcde"), 6, 0, "12345678901234567890", 10, S("can't happen"));
+ test(S("abcde"), 6, 0, "12345678901234567890", 19, S("can't happen"));
+ test(S("abcde"), 6, 0, "12345678901234567890", 20, S("can't happen"));
+ test(S("abcdefghij"), 0, 0, "", 0, S("abcdefghij"));
+ test(S("abcdefghij"), 0, 0, "12345", 0, S("abcdefghij"));
+ test(S("abcdefghij"), 0, 0, "12345", 1, S("1abcdefghij"));
+ test(S("abcdefghij"), 0, 0, "12345", 2, S("12abcdefghij"));
+ test(S("abcdefghij"), 0, 0, "12345", 4, S("1234abcdefghij"));
+ test(S("abcdefghij"), 0, 0, "12345", 5, S("12345abcdefghij"));
+ test(S("abcdefghij"), 0, 0, "1234567890", 0, S("abcdefghij"));
+ test(S("abcdefghij"), 0, 0, "1234567890", 1, S("1abcdefghij"));
+ test(S("abcdefghij"), 0, 0, "1234567890", 5, S("12345abcdefghij"));
+ test(S("abcdefghij"), 0, 0, "1234567890", 9, S("123456789abcdefghij"));
+ test(S("abcdefghij"), 0, 0, "1234567890", 10, S("1234567890abcdefghij"));
+ test(S("abcdefghij"), 0, 0, "12345678901234567890", 0, S("abcdefghij"));
+ test(S("abcdefghij"), 0, 0, "12345678901234567890", 1, S("1abcdefghij"));
+ test(S("abcdefghij"), 0, 0, "12345678901234567890", 10, S("1234567890abcdefghij"));
+ test(S("abcdefghij"), 0, 0, "12345678901234567890", 19, S("1234567890123456789abcdefghij"));
+ test(S("abcdefghij"), 0, 0, "12345678901234567890", 20, S("12345678901234567890abcdefghij"));
+ test(S("abcdefghij"), 0, 1, "", 0, S("bcdefghij"));
+ test(S("abcdefghij"), 0, 1, "12345", 0, S("bcdefghij"));
+ test(S("abcdefghij"), 0, 1, "12345", 1, S("1bcdefghij"));
+ test(S("abcdefghij"), 0, 1, "12345", 2, S("12bcdefghij"));
+ test(S("abcdefghij"), 0, 1, "12345", 4, S("1234bcdefghij"));
+ test(S("abcdefghij"), 0, 1, "12345", 5, S("12345bcdefghij"));
+ test(S("abcdefghij"), 0, 1, "1234567890", 0, S("bcdefghij"));
+ test(S("abcdefghij"), 0, 1, "1234567890", 1, S("1bcdefghij"));
+ test(S("abcdefghij"), 0, 1, "1234567890", 5, S("12345bcdefghij"));
+ test(S("abcdefghij"), 0, 1, "1234567890", 9, S("123456789bcdefghij"));
+ test(S("abcdefghij"), 0, 1, "1234567890", 10, S("1234567890bcdefghij"));
+ test(S("abcdefghij"), 0, 1, "12345678901234567890", 0, S("bcdefghij"));
+ test(S("abcdefghij"), 0, 1, "12345678901234567890", 1, S("1bcdefghij"));
+ test(S("abcdefghij"), 0, 1, "12345678901234567890", 10, S("1234567890bcdefghij"));
+ test(S("abcdefghij"), 0, 1, "12345678901234567890", 19, S("1234567890123456789bcdefghij"));
+ test(S("abcdefghij"), 0, 1, "12345678901234567890", 20, S("12345678901234567890bcdefghij"));
+ test(S("abcdefghij"), 0, 5, "", 0, S("fghij"));
+ test(S("abcdefghij"), 0, 5, "12345", 0, S("fghij"));
+ test(S("abcdefghij"), 0, 5, "12345", 1, S("1fghij"));
+ test(S("abcdefghij"), 0, 5, "12345", 2, S("12fghij"));
+ test(S("abcdefghij"), 0, 5, "12345", 4, S("1234fghij"));
+ test(S("abcdefghij"), 0, 5, "12345", 5, S("12345fghij"));
+ test(S("abcdefghij"), 0, 5, "1234567890", 0, S("fghij"));
+ test(S("abcdefghij"), 0, 5, "1234567890", 1, S("1fghij"));
+ test(S("abcdefghij"), 0, 5, "1234567890", 5, S("12345fghij"));
+ test(S("abcdefghij"), 0, 5, "1234567890", 9, S("123456789fghij"));
+ test(S("abcdefghij"), 0, 5, "1234567890", 10, S("1234567890fghij"));
+ test(S("abcdefghij"), 0, 5, "12345678901234567890", 0, S("fghij"));
+ test(S("abcdefghij"), 0, 5, "12345678901234567890", 1, S("1fghij"));
+ test(S("abcdefghij"), 0, 5, "12345678901234567890", 10, S("1234567890fghij"));
+ test(S("abcdefghij"), 0, 5, "12345678901234567890", 19, S("1234567890123456789fghij"));
+ test(S("abcdefghij"), 0, 5, "12345678901234567890", 20, S("12345678901234567890fghij"));
+ test(S("abcdefghij"), 0, 9, "", 0, S("j"));
+ test(S("abcdefghij"), 0, 9, "12345", 0, S("j"));
+ test(S("abcdefghij"), 0, 9, "12345", 1, S("1j"));
+ test(S("abcdefghij"), 0, 9, "12345", 2, S("12j"));
+ test(S("abcdefghij"), 0, 9, "12345", 4, S("1234j"));
+ test(S("abcdefghij"), 0, 9, "12345", 5, S("12345j"));
+ test(S("abcdefghij"), 0, 9, "1234567890", 0, S("j"));
+ test(S("abcdefghij"), 0, 9, "1234567890", 1, S("1j"));
+ test(S("abcdefghij"), 0, 9, "1234567890", 5, S("12345j"));
+ test(S("abcdefghij"), 0, 9, "1234567890", 9, S("123456789j"));
+ test(S("abcdefghij"), 0, 9, "1234567890", 10, S("1234567890j"));
+ test(S("abcdefghij"), 0, 9, "12345678901234567890", 0, S("j"));
+ test(S("abcdefghij"), 0, 9, "12345678901234567890", 1, S("1j"));
+ test(S("abcdefghij"), 0, 9, "12345678901234567890", 10, S("1234567890j"));
+ test(S("abcdefghij"), 0, 9, "12345678901234567890", 19, S("1234567890123456789j"));
+ test(S("abcdefghij"), 0, 9, "12345678901234567890", 20, S("12345678901234567890j"));
+ test(S("abcdefghij"), 0, 10, "", 0, S(""));
+ test(S("abcdefghij"), 0, 10, "12345", 0, S(""));
+ test(S("abcdefghij"), 0, 10, "12345", 1, S("1"));
+ test(S("abcdefghij"), 0, 10, "12345", 2, S("12"));
+ test(S("abcdefghij"), 0, 10, "12345", 4, S("1234"));
+ test(S("abcdefghij"), 0, 10, "12345", 5, S("12345"));
+ test(S("abcdefghij"), 0, 10, "1234567890", 0, S(""));
+ test(S("abcdefghij"), 0, 10, "1234567890", 1, S("1"));
+ test(S("abcdefghij"), 0, 10, "1234567890", 5, S("12345"));
+ test(S("abcdefghij"), 0, 10, "1234567890", 9, S("123456789"));
+ test(S("abcdefghij"), 0, 10, "1234567890", 10, S("1234567890"));
+ test(S("abcdefghij"), 0, 10, "12345678901234567890", 0, S(""));
+ test(S("abcdefghij"), 0, 10, "12345678901234567890", 1, S("1"));
+ test(S("abcdefghij"), 0, 10, "12345678901234567890", 10, S("1234567890"));
+ test(S("abcdefghij"), 0, 10, "12345678901234567890", 19, S("1234567890123456789"));
+ test(S("abcdefghij"), 0, 10, "12345678901234567890", 20, S("12345678901234567890"));
+ test(S("abcdefghij"), 0, 11, "", 0, S(""));
+ test(S("abcdefghij"), 0, 11, "12345", 0, S(""));
+ test(S("abcdefghij"), 0, 11, "12345", 1, S("1"));
+ test(S("abcdefghij"), 0, 11, "12345", 2, S("12"));
+}
+
+template <class S>
+void test5()
+{
+ test(S("abcdefghij"), 0, 11, "12345", 4, S("1234"));
+ test(S("abcdefghij"), 0, 11, "12345", 5, S("12345"));
+ test(S("abcdefghij"), 0, 11, "1234567890", 0, S(""));
+ test(S("abcdefghij"), 0, 11, "1234567890", 1, S("1"));
+ test(S("abcdefghij"), 0, 11, "1234567890", 5, S("12345"));
+ test(S("abcdefghij"), 0, 11, "1234567890", 9, S("123456789"));
+ test(S("abcdefghij"), 0, 11, "1234567890", 10, S("1234567890"));
+ test(S("abcdefghij"), 0, 11, "12345678901234567890", 0, S(""));
+ test(S("abcdefghij"), 0, 11, "12345678901234567890", 1, S("1"));
+ test(S("abcdefghij"), 0, 11, "12345678901234567890", 10, S("1234567890"));
+ test(S("abcdefghij"), 0, 11, "12345678901234567890", 19, S("1234567890123456789"));
+ test(S("abcdefghij"), 0, 11, "12345678901234567890", 20, S("12345678901234567890"));
+ test(S("abcdefghij"), 1, 0, "", 0, S("abcdefghij"));
+ test(S("abcdefghij"), 1, 0, "12345", 0, S("abcdefghij"));
+ test(S("abcdefghij"), 1, 0, "12345", 1, S("a1bcdefghij"));
+ test(S("abcdefghij"), 1, 0, "12345", 2, S("a12bcdefghij"));
+ test(S("abcdefghij"), 1, 0, "12345", 4, S("a1234bcdefghij"));
+ test(S("abcdefghij"), 1, 0, "12345", 5, S("a12345bcdefghij"));
+ test(S("abcdefghij"), 1, 0, "1234567890", 0, S("abcdefghij"));
+ test(S("abcdefghij"), 1, 0, "1234567890", 1, S("a1bcdefghij"));
+ test(S("abcdefghij"), 1, 0, "1234567890", 5, S("a12345bcdefghij"));
+ test(S("abcdefghij"), 1, 0, "1234567890", 9, S("a123456789bcdefghij"));
+ test(S("abcdefghij"), 1, 0, "1234567890", 10, S("a1234567890bcdefghij"));
+ test(S("abcdefghij"), 1, 0, "12345678901234567890", 0, S("abcdefghij"));
+ test(S("abcdefghij"), 1, 0, "12345678901234567890", 1, S("a1bcdefghij"));
+ test(S("abcdefghij"), 1, 0, "12345678901234567890", 10, S("a1234567890bcdefghij"));
+ test(S("abcdefghij"), 1, 0, "12345678901234567890", 19, S("a1234567890123456789bcdefghij"));
+ test(S("abcdefghij"), 1, 0, "12345678901234567890", 20, S("a12345678901234567890bcdefghij"));
+ test(S("abcdefghij"), 1, 1, "", 0, S("acdefghij"));
+ test(S("abcdefghij"), 1, 1, "12345", 0, S("acdefghij"));
+ test(S("abcdefghij"), 1, 1, "12345", 1, S("a1cdefghij"));
+ test(S("abcdefghij"), 1, 1, "12345", 2, S("a12cdefghij"));
+ test(S("abcdefghij"), 1, 1, "12345", 4, S("a1234cdefghij"));
+ test(S("abcdefghij"), 1, 1, "12345", 5, S("a12345cdefghij"));
+ test(S("abcdefghij"), 1, 1, "1234567890", 0, S("acdefghij"));
+ test(S("abcdefghij"), 1, 1, "1234567890", 1, S("a1cdefghij"));
+ test(S("abcdefghij"), 1, 1, "1234567890", 5, S("a12345cdefghij"));
+ test(S("abcdefghij"), 1, 1, "1234567890", 9, S("a123456789cdefghij"));
+ test(S("abcdefghij"), 1, 1, "1234567890", 10, S("a1234567890cdefghij"));
+ test(S("abcdefghij"), 1, 1, "12345678901234567890", 0, S("acdefghij"));
+ test(S("abcdefghij"), 1, 1, "12345678901234567890", 1, S("a1cdefghij"));
+ test(S("abcdefghij"), 1, 1, "12345678901234567890", 10, S("a1234567890cdefghij"));
+ test(S("abcdefghij"), 1, 1, "12345678901234567890", 19, S("a1234567890123456789cdefghij"));
+ test(S("abcdefghij"), 1, 1, "12345678901234567890", 20, S("a12345678901234567890cdefghij"));
+ test(S("abcdefghij"), 1, 4, "", 0, S("afghij"));
+ test(S("abcdefghij"), 1, 4, "12345", 0, S("afghij"));
+ test(S("abcdefghij"), 1, 4, "12345", 1, S("a1fghij"));
+ test(S("abcdefghij"), 1, 4, "12345", 2, S("a12fghij"));
+ test(S("abcdefghij"), 1, 4, "12345", 4, S("a1234fghij"));
+ test(S("abcdefghij"), 1, 4, "12345", 5, S("a12345fghij"));
+ test(S("abcdefghij"), 1, 4, "1234567890", 0, S("afghij"));
+ test(S("abcdefghij"), 1, 4, "1234567890", 1, S("a1fghij"));
+ test(S("abcdefghij"), 1, 4, "1234567890", 5, S("a12345fghij"));
+ test(S("abcdefghij"), 1, 4, "1234567890", 9, S("a123456789fghij"));
+ test(S("abcdefghij"), 1, 4, "1234567890", 10, S("a1234567890fghij"));
+ test(S("abcdefghij"), 1, 4, "12345678901234567890", 0, S("afghij"));
+ test(S("abcdefghij"), 1, 4, "12345678901234567890", 1, S("a1fghij"));
+ test(S("abcdefghij"), 1, 4, "12345678901234567890", 10, S("a1234567890fghij"));
+ test(S("abcdefghij"), 1, 4, "12345678901234567890", 19, S("a1234567890123456789fghij"));
+ test(S("abcdefghij"), 1, 4, "12345678901234567890", 20, S("a12345678901234567890fghij"));
+ test(S("abcdefghij"), 1, 8, "", 0, S("aj"));
+ test(S("abcdefghij"), 1, 8, "12345", 0, S("aj"));
+ test(S("abcdefghij"), 1, 8, "12345", 1, S("a1j"));
+ test(S("abcdefghij"), 1, 8, "12345", 2, S("a12j"));
+ test(S("abcdefghij"), 1, 8, "12345", 4, S("a1234j"));
+ test(S("abcdefghij"), 1, 8, "12345", 5, S("a12345j"));
+ test(S("abcdefghij"), 1, 8, "1234567890", 0, S("aj"));
+ test(S("abcdefghij"), 1, 8, "1234567890", 1, S("a1j"));
+ test(S("abcdefghij"), 1, 8, "1234567890", 5, S("a12345j"));
+ test(S("abcdefghij"), 1, 8, "1234567890", 9, S("a123456789j"));
+ test(S("abcdefghij"), 1, 8, "1234567890", 10, S("a1234567890j"));
+ test(S("abcdefghij"), 1, 8, "12345678901234567890", 0, S("aj"));
+ test(S("abcdefghij"), 1, 8, "12345678901234567890", 1, S("a1j"));
+ test(S("abcdefghij"), 1, 8, "12345678901234567890", 10, S("a1234567890j"));
+ test(S("abcdefghij"), 1, 8, "12345678901234567890", 19, S("a1234567890123456789j"));
+ test(S("abcdefghij"), 1, 8, "12345678901234567890", 20, S("a12345678901234567890j"));
+ test(S("abcdefghij"), 1, 9, "", 0, S("a"));
+ test(S("abcdefghij"), 1, 9, "12345", 0, S("a"));
+ test(S("abcdefghij"), 1, 9, "12345", 1, S("a1"));
+ test(S("abcdefghij"), 1, 9, "12345", 2, S("a12"));
+ test(S("abcdefghij"), 1, 9, "12345", 4, S("a1234"));
+ test(S("abcdefghij"), 1, 9, "12345", 5, S("a12345"));
+ test(S("abcdefghij"), 1, 9, "1234567890", 0, S("a"));
+ test(S("abcdefghij"), 1, 9, "1234567890", 1, S("a1"));
+ test(S("abcdefghij"), 1, 9, "1234567890", 5, S("a12345"));
+ test(S("abcdefghij"), 1, 9, "1234567890", 9, S("a123456789"));
+ test(S("abcdefghij"), 1, 9, "1234567890", 10, S("a1234567890"));
+ test(S("abcdefghij"), 1, 9, "12345678901234567890", 0, S("a"));
+ test(S("abcdefghij"), 1, 9, "12345678901234567890", 1, S("a1"));
+ test(S("abcdefghij"), 1, 9, "12345678901234567890", 10, S("a1234567890"));
+ test(S("abcdefghij"), 1, 9, "12345678901234567890", 19, S("a1234567890123456789"));
+ test(S("abcdefghij"), 1, 9, "12345678901234567890", 20, S("a12345678901234567890"));
+ test(S("abcdefghij"), 1, 10, "", 0, S("a"));
+ test(S("abcdefghij"), 1, 10, "12345", 0, S("a"));
+ test(S("abcdefghij"), 1, 10, "12345", 1, S("a1"));
+ test(S("abcdefghij"), 1, 10, "12345", 2, S("a12"));
+ test(S("abcdefghij"), 1, 10, "12345", 4, S("a1234"));
+ test(S("abcdefghij"), 1, 10, "12345", 5, S("a12345"));
+ test(S("abcdefghij"), 1, 10, "1234567890", 0, S("a"));
+ test(S("abcdefghij"), 1, 10, "1234567890", 1, S("a1"));
+}
+
+template <class S>
+void test6()
+{
+ test(S("abcdefghij"), 1, 10, "1234567890", 5, S("a12345"));
+ test(S("abcdefghij"), 1, 10, "1234567890", 9, S("a123456789"));
+ test(S("abcdefghij"), 1, 10, "1234567890", 10, S("a1234567890"));
+ test(S("abcdefghij"), 1, 10, "12345678901234567890", 0, S("a"));
+ test(S("abcdefghij"), 1, 10, "12345678901234567890", 1, S("a1"));
+ test(S("abcdefghij"), 1, 10, "12345678901234567890", 10, S("a1234567890"));
+ test(S("abcdefghij"), 1, 10, "12345678901234567890", 19, S("a1234567890123456789"));
+ test(S("abcdefghij"), 1, 10, "12345678901234567890", 20, S("a12345678901234567890"));
+ test(S("abcdefghij"), 5, 0, "", 0, S("abcdefghij"));
+ test(S("abcdefghij"), 5, 0, "12345", 0, S("abcdefghij"));
+ test(S("abcdefghij"), 5, 0, "12345", 1, S("abcde1fghij"));
+ test(S("abcdefghij"), 5, 0, "12345", 2, S("abcde12fghij"));
+ test(S("abcdefghij"), 5, 0, "12345", 4, S("abcde1234fghij"));
+ test(S("abcdefghij"), 5, 0, "12345", 5, S("abcde12345fghij"));
+ test(S("abcdefghij"), 5, 0, "1234567890", 0, S("abcdefghij"));
+ test(S("abcdefghij"), 5, 0, "1234567890", 1, S("abcde1fghij"));
+ test(S("abcdefghij"), 5, 0, "1234567890", 5, S("abcde12345fghij"));
+ test(S("abcdefghij"), 5, 0, "1234567890", 9, S("abcde123456789fghij"));
+ test(S("abcdefghij"), 5, 0, "1234567890", 10, S("abcde1234567890fghij"));
+ test(S("abcdefghij"), 5, 0, "12345678901234567890", 0, S("abcdefghij"));
+ test(S("abcdefghij"), 5, 0, "12345678901234567890", 1, S("abcde1fghij"));
+ test(S("abcdefghij"), 5, 0, "12345678901234567890", 10, S("abcde1234567890fghij"));
+ test(S("abcdefghij"), 5, 0, "12345678901234567890", 19, S("abcde1234567890123456789fghij"));
+ test(S("abcdefghij"), 5, 0, "12345678901234567890", 20, S("abcde12345678901234567890fghij"));
+ test(S("abcdefghij"), 5, 1, "", 0, S("abcdeghij"));
+ test(S("abcdefghij"), 5, 1, "12345", 0, S("abcdeghij"));
+ test(S("abcdefghij"), 5, 1, "12345", 1, S("abcde1ghij"));
+ test(S("abcdefghij"), 5, 1, "12345", 2, S("abcde12ghij"));
+ test(S("abcdefghij"), 5, 1, "12345", 4, S("abcde1234ghij"));
+ test(S("abcdefghij"), 5, 1, "12345", 5, S("abcde12345ghij"));
+ test(S("abcdefghij"), 5, 1, "1234567890", 0, S("abcdeghij"));
+ test(S("abcdefghij"), 5, 1, "1234567890", 1, S("abcde1ghij"));
+ test(S("abcdefghij"), 5, 1, "1234567890", 5, S("abcde12345ghij"));
+ test(S("abcdefghij"), 5, 1, "1234567890", 9, S("abcde123456789ghij"));
+ test(S("abcdefghij"), 5, 1, "1234567890", 10, S("abcde1234567890ghij"));
+ test(S("abcdefghij"), 5, 1, "12345678901234567890", 0, S("abcdeghij"));
+ test(S("abcdefghij"), 5, 1, "12345678901234567890", 1, S("abcde1ghij"));
+ test(S("abcdefghij"), 5, 1, "12345678901234567890", 10, S("abcde1234567890ghij"));
+ test(S("abcdefghij"), 5, 1, "12345678901234567890", 19, S("abcde1234567890123456789ghij"));
+ test(S("abcdefghij"), 5, 1, "12345678901234567890", 20, S("abcde12345678901234567890ghij"));
+ test(S("abcdefghij"), 5, 2, "", 0, S("abcdehij"));
+ test(S("abcdefghij"), 5, 2, "12345", 0, S("abcdehij"));
+ test(S("abcdefghij"), 5, 2, "12345", 1, S("abcde1hij"));
+ test(S("abcdefghij"), 5, 2, "12345", 2, S("abcde12hij"));
+ test(S("abcdefghij"), 5, 2, "12345", 4, S("abcde1234hij"));
+ test(S("abcdefghij"), 5, 2, "12345", 5, S("abcde12345hij"));
+ test(S("abcdefghij"), 5, 2, "1234567890", 0, S("abcdehij"));
+ test(S("abcdefghij"), 5, 2, "1234567890", 1, S("abcde1hij"));
+ test(S("abcdefghij"), 5, 2, "1234567890", 5, S("abcde12345hij"));
+ test(S("abcdefghij"), 5, 2, "1234567890", 9, S("abcde123456789hij"));
+ test(S("abcdefghij"), 5, 2, "1234567890", 10, S("abcde1234567890hij"));
+ test(S("abcdefghij"), 5, 2, "12345678901234567890", 0, S("abcdehij"));
+ test(S("abcdefghij"), 5, 2, "12345678901234567890", 1, S("abcde1hij"));
+ test(S("abcdefghij"), 5, 2, "12345678901234567890", 10, S("abcde1234567890hij"));
+ test(S("abcdefghij"), 5, 2, "12345678901234567890", 19, S("abcde1234567890123456789hij"));
+ test(S("abcdefghij"), 5, 2, "12345678901234567890", 20, S("abcde12345678901234567890hij"));
+ test(S("abcdefghij"), 5, 4, "", 0, S("abcdej"));
+ test(S("abcdefghij"), 5, 4, "12345", 0, S("abcdej"));
+ test(S("abcdefghij"), 5, 4, "12345", 1, S("abcde1j"));
+ test(S("abcdefghij"), 5, 4, "12345", 2, S("abcde12j"));
+ test(S("abcdefghij"), 5, 4, "12345", 4, S("abcde1234j"));
+ test(S("abcdefghij"), 5, 4, "12345", 5, S("abcde12345j"));
+ test(S("abcdefghij"), 5, 4, "1234567890", 0, S("abcdej"));
+ test(S("abcdefghij"), 5, 4, "1234567890", 1, S("abcde1j"));
+ test(S("abcdefghij"), 5, 4, "1234567890", 5, S("abcde12345j"));
+ test(S("abcdefghij"), 5, 4, "1234567890", 9, S("abcde123456789j"));
+ test(S("abcdefghij"), 5, 4, "1234567890", 10, S("abcde1234567890j"));
+ test(S("abcdefghij"), 5, 4, "12345678901234567890", 0, S("abcdej"));
+ test(S("abcdefghij"), 5, 4, "12345678901234567890", 1, S("abcde1j"));
+ test(S("abcdefghij"), 5, 4, "12345678901234567890", 10, S("abcde1234567890j"));
+ test(S("abcdefghij"), 5, 4, "12345678901234567890", 19, S("abcde1234567890123456789j"));
+ test(S("abcdefghij"), 5, 4, "12345678901234567890", 20, S("abcde12345678901234567890j"));
+ test(S("abcdefghij"), 5, 5, "", 0, S("abcde"));
+ test(S("abcdefghij"), 5, 5, "12345", 0, S("abcde"));
+ test(S("abcdefghij"), 5, 5, "12345", 1, S("abcde1"));
+ test(S("abcdefghij"), 5, 5, "12345", 2, S("abcde12"));
+ test(S("abcdefghij"), 5, 5, "12345", 4, S("abcde1234"));
+ test(S("abcdefghij"), 5, 5, "12345", 5, S("abcde12345"));
+ test(S("abcdefghij"), 5, 5, "1234567890", 0, S("abcde"));
+ test(S("abcdefghij"), 5, 5, "1234567890", 1, S("abcde1"));
+ test(S("abcdefghij"), 5, 5, "1234567890", 5, S("abcde12345"));
+ test(S("abcdefghij"), 5, 5, "1234567890", 9, S("abcde123456789"));
+ test(S("abcdefghij"), 5, 5, "1234567890", 10, S("abcde1234567890"));
+ test(S("abcdefghij"), 5, 5, "12345678901234567890", 0, S("abcde"));
+ test(S("abcdefghij"), 5, 5, "12345678901234567890", 1, S("abcde1"));
+ test(S("abcdefghij"), 5, 5, "12345678901234567890", 10, S("abcde1234567890"));
+ test(S("abcdefghij"), 5, 5, "12345678901234567890", 19, S("abcde1234567890123456789"));
+ test(S("abcdefghij"), 5, 5, "12345678901234567890", 20, S("abcde12345678901234567890"));
+ test(S("abcdefghij"), 5, 6, "", 0, S("abcde"));
+ test(S("abcdefghij"), 5, 6, "12345", 0, S("abcde"));
+ test(S("abcdefghij"), 5, 6, "12345", 1, S("abcde1"));
+ test(S("abcdefghij"), 5, 6, "12345", 2, S("abcde12"));
+ test(S("abcdefghij"), 5, 6, "12345", 4, S("abcde1234"));
+ test(S("abcdefghij"), 5, 6, "12345", 5, S("abcde12345"));
+ test(S("abcdefghij"), 5, 6, "1234567890", 0, S("abcde"));
+ test(S("abcdefghij"), 5, 6, "1234567890", 1, S("abcde1"));
+ test(S("abcdefghij"), 5, 6, "1234567890", 5, S("abcde12345"));
+ test(S("abcdefghij"), 5, 6, "1234567890", 9, S("abcde123456789"));
+ test(S("abcdefghij"), 5, 6, "1234567890", 10, S("abcde1234567890"));
+ test(S("abcdefghij"), 5, 6, "12345678901234567890", 0, S("abcde"));
+}
+
+template <class S>
+void test7()
+{
+ test(S("abcdefghij"), 5, 6, "12345678901234567890", 1, S("abcde1"));
+ test(S("abcdefghij"), 5, 6, "12345678901234567890", 10, S("abcde1234567890"));
+ test(S("abcdefghij"), 5, 6, "12345678901234567890", 19, S("abcde1234567890123456789"));
+ test(S("abcdefghij"), 5, 6, "12345678901234567890", 20, S("abcde12345678901234567890"));
+ test(S("abcdefghij"), 9, 0, "", 0, S("abcdefghij"));
+ test(S("abcdefghij"), 9, 0, "12345", 0, S("abcdefghij"));
+ test(S("abcdefghij"), 9, 0, "12345", 1, S("abcdefghi1j"));
+ test(S("abcdefghij"), 9, 0, "12345", 2, S("abcdefghi12j"));
+ test(S("abcdefghij"), 9, 0, "12345", 4, S("abcdefghi1234j"));
+ test(S("abcdefghij"), 9, 0, "12345", 5, S("abcdefghi12345j"));
+ test(S("abcdefghij"), 9, 0, "1234567890", 0, S("abcdefghij"));
+ test(S("abcdefghij"), 9, 0, "1234567890", 1, S("abcdefghi1j"));
+ test(S("abcdefghij"), 9, 0, "1234567890", 5, S("abcdefghi12345j"));
+ test(S("abcdefghij"), 9, 0, "1234567890", 9, S("abcdefghi123456789j"));
+ test(S("abcdefghij"), 9, 0, "1234567890", 10, S("abcdefghi1234567890j"));
+ test(S("abcdefghij"), 9, 0, "12345678901234567890", 0, S("abcdefghij"));
+ test(S("abcdefghij"), 9, 0, "12345678901234567890", 1, S("abcdefghi1j"));
+ test(S("abcdefghij"), 9, 0, "12345678901234567890", 10, S("abcdefghi1234567890j"));
+ test(S("abcdefghij"), 9, 0, "12345678901234567890", 19, S("abcdefghi1234567890123456789j"));
+ test(S("abcdefghij"), 9, 0, "12345678901234567890", 20, S("abcdefghi12345678901234567890j"));
+ test(S("abcdefghij"), 9, 1, "", 0, S("abcdefghi"));
+ test(S("abcdefghij"), 9, 1, "12345", 0, S("abcdefghi"));
+ test(S("abcdefghij"), 9, 1, "12345", 1, S("abcdefghi1"));
+ test(S("abcdefghij"), 9, 1, "12345", 2, S("abcdefghi12"));
+ test(S("abcdefghij"), 9, 1, "12345", 4, S("abcdefghi1234"));
+ test(S("abcdefghij"), 9, 1, "12345", 5, S("abcdefghi12345"));
+ test(S("abcdefghij"), 9, 1, "1234567890", 0, S("abcdefghi"));
+ test(S("abcdefghij"), 9, 1, "1234567890", 1, S("abcdefghi1"));
+ test(S("abcdefghij"), 9, 1, "1234567890", 5, S("abcdefghi12345"));
+ test(S("abcdefghij"), 9, 1, "1234567890", 9, S("abcdefghi123456789"));
+ test(S("abcdefghij"), 9, 1, "1234567890", 10, S("abcdefghi1234567890"));
+ test(S("abcdefghij"), 9, 1, "12345678901234567890", 0, S("abcdefghi"));
+ test(S("abcdefghij"), 9, 1, "12345678901234567890", 1, S("abcdefghi1"));
+ test(S("abcdefghij"), 9, 1, "12345678901234567890", 10, S("abcdefghi1234567890"));
+ test(S("abcdefghij"), 9, 1, "12345678901234567890", 19, S("abcdefghi1234567890123456789"));
+ test(S("abcdefghij"), 9, 1, "12345678901234567890", 20, S("abcdefghi12345678901234567890"));
+ test(S("abcdefghij"), 9, 2, "", 0, S("abcdefghi"));
+ test(S("abcdefghij"), 9, 2, "12345", 0, S("abcdefghi"));
+ test(S("abcdefghij"), 9, 2, "12345", 1, S("abcdefghi1"));
+ test(S("abcdefghij"), 9, 2, "12345", 2, S("abcdefghi12"));
+ test(S("abcdefghij"), 9, 2, "12345", 4, S("abcdefghi1234"));
+ test(S("abcdefghij"), 9, 2, "12345", 5, S("abcdefghi12345"));
+ test(S("abcdefghij"), 9, 2, "1234567890", 0, S("abcdefghi"));
+ test(S("abcdefghij"), 9, 2, "1234567890", 1, S("abcdefghi1"));
+ test(S("abcdefghij"), 9, 2, "1234567890", 5, S("abcdefghi12345"));
+ test(S("abcdefghij"), 9, 2, "1234567890", 9, S("abcdefghi123456789"));
+ test(S("abcdefghij"), 9, 2, "1234567890", 10, S("abcdefghi1234567890"));
+ test(S("abcdefghij"), 9, 2, "12345678901234567890", 0, S("abcdefghi"));
+ test(S("abcdefghij"), 9, 2, "12345678901234567890", 1, S("abcdefghi1"));
+ test(S("abcdefghij"), 9, 2, "12345678901234567890", 10, S("abcdefghi1234567890"));
+ test(S("abcdefghij"), 9, 2, "12345678901234567890", 19, S("abcdefghi1234567890123456789"));
+ test(S("abcdefghij"), 9, 2, "12345678901234567890", 20, S("abcdefghi12345678901234567890"));
+ test(S("abcdefghij"), 10, 0, "", 0, S("abcdefghij"));
+ test(S("abcdefghij"), 10, 0, "12345", 0, S("abcdefghij"));
+ test(S("abcdefghij"), 10, 0, "12345", 1, S("abcdefghij1"));
+ test(S("abcdefghij"), 10, 0, "12345", 2, S("abcdefghij12"));
+ test(S("abcdefghij"), 10, 0, "12345", 4, S("abcdefghij1234"));
+ test(S("abcdefghij"), 10, 0, "12345", 5, S("abcdefghij12345"));
+ test(S("abcdefghij"), 10, 0, "1234567890", 0, S("abcdefghij"));
+ test(S("abcdefghij"), 10, 0, "1234567890", 1, S("abcdefghij1"));
+ test(S("abcdefghij"), 10, 0, "1234567890", 5, S("abcdefghij12345"));
+ test(S("abcdefghij"), 10, 0, "1234567890", 9, S("abcdefghij123456789"));
+ test(S("abcdefghij"), 10, 0, "1234567890", 10, S("abcdefghij1234567890"));
+ test(S("abcdefghij"), 10, 0, "12345678901234567890", 0, S("abcdefghij"));
+ test(S("abcdefghij"), 10, 0, "12345678901234567890", 1, S("abcdefghij1"));
+ test(S("abcdefghij"), 10, 0, "12345678901234567890", 10, S("abcdefghij1234567890"));
+ test(S("abcdefghij"), 10, 0, "12345678901234567890", 19, S("abcdefghij1234567890123456789"));
+ test(S("abcdefghij"), 10, 0, "12345678901234567890", 20, S("abcdefghij12345678901234567890"));
+ test(S("abcdefghij"), 10, 1, "", 0, S("abcdefghij"));
+ test(S("abcdefghij"), 10, 1, "12345", 0, S("abcdefghij"));
+ test(S("abcdefghij"), 10, 1, "12345", 1, S("abcdefghij1"));
+ test(S("abcdefghij"), 10, 1, "12345", 2, S("abcdefghij12"));
+ test(S("abcdefghij"), 10, 1, "12345", 4, S("abcdefghij1234"));
+ test(S("abcdefghij"), 10, 1, "12345", 5, S("abcdefghij12345"));
+ test(S("abcdefghij"), 10, 1, "1234567890", 0, S("abcdefghij"));
+ test(S("abcdefghij"), 10, 1, "1234567890", 1, S("abcdefghij1"));
+ test(S("abcdefghij"), 10, 1, "1234567890", 5, S("abcdefghij12345"));
+ test(S("abcdefghij"), 10, 1, "1234567890", 9, S("abcdefghij123456789"));
+ test(S("abcdefghij"), 10, 1, "1234567890", 10, S("abcdefghij1234567890"));
+ test(S("abcdefghij"), 10, 1, "12345678901234567890", 0, S("abcdefghij"));
+ test(S("abcdefghij"), 10, 1, "12345678901234567890", 1, S("abcdefghij1"));
+ test(S("abcdefghij"), 10, 1, "12345678901234567890", 10, S("abcdefghij1234567890"));
+ test(S("abcdefghij"), 10, 1, "12345678901234567890", 19, S("abcdefghij1234567890123456789"));
+ test(S("abcdefghij"), 10, 1, "12345678901234567890", 20, S("abcdefghij12345678901234567890"));
+ test(S("abcdefghij"), 11, 0, "", 0, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, "12345", 0, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, "12345", 1, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, "12345", 2, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, "12345", 4, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, "12345", 5, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, "1234567890", 0, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, "1234567890", 1, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, "1234567890", 5, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, "1234567890", 9, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, "1234567890", 10, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, "12345678901234567890", 0, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, "12345678901234567890", 1, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, "12345678901234567890", 10, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, "12345678901234567890", 19, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, "12345678901234567890", 20, S("can't happen"));
+}
+
+template <class S>
+void test8()
+{
+ test(S("abcdefghijklmnopqrst"), 0, 0, "", 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, "12345", 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, "12345", 1, S("1abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, "12345", 2, S("12abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, "12345", 4, S("1234abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, "12345", 5, S("12345abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, "1234567890", 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, "1234567890", 1, S("1abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, "1234567890", 5, S("12345abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, "1234567890", 9, S("123456789abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, "1234567890", 10, S("1234567890abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, "12345678901234567890", 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, "12345678901234567890", 1, S("1abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, "12345678901234567890", 10, S("1234567890abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, "12345678901234567890", 19, S("1234567890123456789abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, "12345678901234567890", 20, S("12345678901234567890abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, "", 0, S("bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, "12345", 0, S("bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, "12345", 1, S("1bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, "12345", 2, S("12bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, "12345", 4, S("1234bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, "12345", 5, S("12345bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, "1234567890", 0, S("bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, "1234567890", 1, S("1bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, "1234567890", 5, S("12345bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, "1234567890", 9, S("123456789bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, "1234567890", 10, S("1234567890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, "12345678901234567890", 0, S("bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, "12345678901234567890", 1, S("1bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, "12345678901234567890", 10, S("1234567890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, "12345678901234567890", 19, S("1234567890123456789bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, "12345678901234567890", 20, S("12345678901234567890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, "", 0, S("klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, "12345", 0, S("klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, "12345", 1, S("1klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, "12345", 2, S("12klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, "12345", 4, S("1234klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, "12345", 5, S("12345klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, "1234567890", 0, S("klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, "1234567890", 1, S("1klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, "1234567890", 5, S("12345klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, "1234567890", 9, S("123456789klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, "1234567890", 10, S("1234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, "12345678901234567890", 0, S("klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, "12345678901234567890", 1, S("1klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, "12345678901234567890", 10, S("1234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, "12345678901234567890", 19, S("1234567890123456789klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, "12345678901234567890", 20, S("12345678901234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, "", 0, S("t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, "12345", 0, S("t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, "12345", 1, S("1t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, "12345", 2, S("12t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, "12345", 4, S("1234t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, "12345", 5, S("12345t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, "1234567890", 0, S("t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, "1234567890", 1, S("1t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, "1234567890", 5, S("12345t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, "1234567890", 9, S("123456789t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, "1234567890", 10, S("1234567890t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, "12345678901234567890", 0, S("t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, "12345678901234567890", 1, S("1t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, "12345678901234567890", 10, S("1234567890t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, "12345678901234567890", 19, S("1234567890123456789t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, "12345678901234567890", 20, S("12345678901234567890t"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, "", 0, S(""));
+ test(S("abcdefghijklmnopqrst"), 0, 20, "12345", 0, S(""));
+ test(S("abcdefghijklmnopqrst"), 0, 20, "12345", 1, S("1"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, "12345", 2, S("12"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, "12345", 4, S("1234"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, "12345", 5, S("12345"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, "1234567890", 0, S(""));
+ test(S("abcdefghijklmnopqrst"), 0, 20, "1234567890", 1, S("1"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, "1234567890", 5, S("12345"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, "1234567890", 9, S("123456789"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, "1234567890", 10, S("1234567890"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, "12345678901234567890", 0, S(""));
+ test(S("abcdefghijklmnopqrst"), 0, 20, "12345678901234567890", 1, S("1"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, "12345678901234567890", 10, S("1234567890"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, "12345678901234567890", 19, S("1234567890123456789"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, "12345678901234567890", 20, S("12345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 0, 21, "", 0, S(""));
+ test(S("abcdefghijklmnopqrst"), 0, 21, "12345", 0, S(""));
+ test(S("abcdefghijklmnopqrst"), 0, 21, "12345", 1, S("1"));
+ test(S("abcdefghijklmnopqrst"), 0, 21, "12345", 2, S("12"));
+ test(S("abcdefghijklmnopqrst"), 0, 21, "12345", 4, S("1234"));
+ test(S("abcdefghijklmnopqrst"), 0, 21, "12345", 5, S("12345"));
+ test(S("abcdefghijklmnopqrst"), 0, 21, "1234567890", 0, S(""));
+ test(S("abcdefghijklmnopqrst"), 0, 21, "1234567890", 1, S("1"));
+ test(S("abcdefghijklmnopqrst"), 0, 21, "1234567890", 5, S("12345"));
+ test(S("abcdefghijklmnopqrst"), 0, 21, "1234567890", 9, S("123456789"));
+ test(S("abcdefghijklmnopqrst"), 0, 21, "1234567890", 10, S("1234567890"));
+ test(S("abcdefghijklmnopqrst"), 0, 21, "12345678901234567890", 0, S(""));
+ test(S("abcdefghijklmnopqrst"), 0, 21, "12345678901234567890", 1, S("1"));
+ test(S("abcdefghijklmnopqrst"), 0, 21, "12345678901234567890", 10, S("1234567890"));
+ test(S("abcdefghijklmnopqrst"), 0, 21, "12345678901234567890", 19, S("1234567890123456789"));
+ test(S("abcdefghijklmnopqrst"), 0, 21, "12345678901234567890", 20, S("12345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, "", 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, "12345", 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, "12345", 1, S("a1bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, "12345", 2, S("a12bcdefghijklmnopqrst"));
+}
+
+template <class S>
+void test9()
+{
+ test(S("abcdefghijklmnopqrst"), 1, 0, "12345", 4, S("a1234bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, "12345", 5, S("a12345bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, "1234567890", 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, "1234567890", 1, S("a1bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, "1234567890", 5, S("a12345bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, "1234567890", 9, S("a123456789bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, "1234567890", 10, S("a1234567890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, "12345678901234567890", 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, "12345678901234567890", 1, S("a1bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, "12345678901234567890", 10, S("a1234567890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, "12345678901234567890", 19, S("a1234567890123456789bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, "12345678901234567890", 20, S("a12345678901234567890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, "", 0, S("acdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, "12345", 0, S("acdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, "12345", 1, S("a1cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, "12345", 2, S("a12cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, "12345", 4, S("a1234cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, "12345", 5, S("a12345cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, "1234567890", 0, S("acdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, "1234567890", 1, S("a1cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, "1234567890", 5, S("a12345cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, "1234567890", 9, S("a123456789cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, "1234567890", 10, S("a1234567890cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, "12345678901234567890", 0, S("acdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, "12345678901234567890", 1, S("a1cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, "12345678901234567890", 10, S("a1234567890cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, "12345678901234567890", 19, S("a1234567890123456789cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, "12345678901234567890", 20, S("a12345678901234567890cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, "", 0, S("aklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, "12345", 0, S("aklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, "12345", 1, S("a1klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, "12345", 2, S("a12klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, "12345", 4, S("a1234klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, "12345", 5, S("a12345klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, "1234567890", 0, S("aklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, "1234567890", 1, S("a1klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, "1234567890", 5, S("a12345klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, "1234567890", 9, S("a123456789klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, "1234567890", 10, S("a1234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, "12345678901234567890", 0, S("aklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, "12345678901234567890", 1, S("a1klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, "12345678901234567890", 10, S("a1234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, "12345678901234567890", 19, S("a1234567890123456789klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, "12345678901234567890", 20, S("a12345678901234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, "", 0, S("at"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, "12345", 0, S("at"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, "12345", 1, S("a1t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, "12345", 2, S("a12t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, "12345", 4, S("a1234t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, "12345", 5, S("a12345t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, "1234567890", 0, S("at"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, "1234567890", 1, S("a1t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, "1234567890", 5, S("a12345t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, "1234567890", 9, S("a123456789t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, "1234567890", 10, S("a1234567890t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, "12345678901234567890", 0, S("at"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, "12345678901234567890", 1, S("a1t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, "12345678901234567890", 10, S("a1234567890t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, "12345678901234567890", 19, S("a1234567890123456789t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, "12345678901234567890", 20, S("a12345678901234567890t"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, "", 0, S("a"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, "12345", 0, S("a"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, "12345", 1, S("a1"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, "12345", 2, S("a12"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, "12345", 4, S("a1234"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, "12345", 5, S("a12345"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, "1234567890", 0, S("a"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, "1234567890", 1, S("a1"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, "1234567890", 5, S("a12345"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, "1234567890", 9, S("a123456789"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, "1234567890", 10, S("a1234567890"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, "12345678901234567890", 0, S("a"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, "12345678901234567890", 1, S("a1"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, "12345678901234567890", 10, S("a1234567890"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, "12345678901234567890", 19, S("a1234567890123456789"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, "12345678901234567890", 20, S("a12345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, "", 0, S("a"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, "12345", 0, S("a"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, "12345", 1, S("a1"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, "12345", 2, S("a12"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, "12345", 4, S("a1234"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, "12345", 5, S("a12345"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, "1234567890", 0, S("a"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, "1234567890", 1, S("a1"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, "1234567890", 5, S("a12345"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, "1234567890", 9, S("a123456789"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, "1234567890", 10, S("a1234567890"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, "12345678901234567890", 0, S("a"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, "12345678901234567890", 1, S("a1"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, "12345678901234567890", 10, S("a1234567890"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, "12345678901234567890", 19, S("a1234567890123456789"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, "12345678901234567890", 20, S("a12345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, "", 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, "12345", 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, "12345", 1, S("abcdefghij1klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, "12345", 2, S("abcdefghij12klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, "12345", 4, S("abcdefghij1234klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, "12345", 5, S("abcdefghij12345klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, "1234567890", 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, "1234567890", 1, S("abcdefghij1klmnopqrst"));
+}
+
+template <class S>
+void test10()
+{
+ test(S("abcdefghijklmnopqrst"), 10, 0, "1234567890", 5, S("abcdefghij12345klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, "1234567890", 9, S("abcdefghij123456789klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, "1234567890", 10, S("abcdefghij1234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, "12345678901234567890", 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, "12345678901234567890", 1, S("abcdefghij1klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, "12345678901234567890", 10, S("abcdefghij1234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, "12345678901234567890", 19, S("abcdefghij1234567890123456789klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, "12345678901234567890", 20, S("abcdefghij12345678901234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, "", 0, S("abcdefghijlmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, "12345", 0, S("abcdefghijlmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, "12345", 1, S("abcdefghij1lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, "12345", 2, S("abcdefghij12lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, "12345", 4, S("abcdefghij1234lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, "12345", 5, S("abcdefghij12345lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, "1234567890", 0, S("abcdefghijlmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, "1234567890", 1, S("abcdefghij1lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, "1234567890", 5, S("abcdefghij12345lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, "1234567890", 9, S("abcdefghij123456789lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, "1234567890", 10, S("abcdefghij1234567890lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, "12345678901234567890", 0, S("abcdefghijlmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, "12345678901234567890", 1, S("abcdefghij1lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, "12345678901234567890", 10, S("abcdefghij1234567890lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, "12345678901234567890", 19, S("abcdefghij1234567890123456789lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, "12345678901234567890", 20, S("abcdefghij12345678901234567890lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, "", 0, S("abcdefghijpqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, "12345", 0, S("abcdefghijpqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, "12345", 1, S("abcdefghij1pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, "12345", 2, S("abcdefghij12pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, "12345", 4, S("abcdefghij1234pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, "12345", 5, S("abcdefghij12345pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, "1234567890", 0, S("abcdefghijpqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, "1234567890", 1, S("abcdefghij1pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, "1234567890", 5, S("abcdefghij12345pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, "1234567890", 9, S("abcdefghij123456789pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, "1234567890", 10, S("abcdefghij1234567890pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, "12345678901234567890", 0, S("abcdefghijpqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, "12345678901234567890", 1, S("abcdefghij1pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, "12345678901234567890", 10, S("abcdefghij1234567890pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, "12345678901234567890", 19, S("abcdefghij1234567890123456789pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, "12345678901234567890", 20, S("abcdefghij12345678901234567890pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, "", 0, S("abcdefghijt"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, "12345", 0, S("abcdefghijt"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, "12345", 1, S("abcdefghij1t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, "12345", 2, S("abcdefghij12t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, "12345", 4, S("abcdefghij1234t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, "12345", 5, S("abcdefghij12345t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, "1234567890", 0, S("abcdefghijt"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, "1234567890", 1, S("abcdefghij1t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, "1234567890", 5, S("abcdefghij12345t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, "1234567890", 9, S("abcdefghij123456789t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, "1234567890", 10, S("abcdefghij1234567890t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, "12345678901234567890", 0, S("abcdefghijt"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, "12345678901234567890", 1, S("abcdefghij1t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, "12345678901234567890", 10, S("abcdefghij1234567890t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, "12345678901234567890", 19, S("abcdefghij1234567890123456789t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, "12345678901234567890", 20, S("abcdefghij12345678901234567890t"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, "", 0, S("abcdefghij"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, "12345", 0, S("abcdefghij"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, "12345", 1, S("abcdefghij1"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, "12345", 2, S("abcdefghij12"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, "12345", 4, S("abcdefghij1234"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, "12345", 5, S("abcdefghij12345"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, "1234567890", 0, S("abcdefghij"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, "1234567890", 1, S("abcdefghij1"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, "1234567890", 5, S("abcdefghij12345"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, "1234567890", 9, S("abcdefghij123456789"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, "1234567890", 10, S("abcdefghij1234567890"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, "12345678901234567890", 0, S("abcdefghij"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, "12345678901234567890", 1, S("abcdefghij1"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, "12345678901234567890", 10, S("abcdefghij1234567890"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, "12345678901234567890", 19, S("abcdefghij1234567890123456789"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, "12345678901234567890", 20, S("abcdefghij12345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, "", 0, S("abcdefghij"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, "12345", 0, S("abcdefghij"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, "12345", 1, S("abcdefghij1"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, "12345", 2, S("abcdefghij12"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, "12345", 4, S("abcdefghij1234"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, "12345", 5, S("abcdefghij12345"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, "1234567890", 0, S("abcdefghij"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, "1234567890", 1, S("abcdefghij1"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, "1234567890", 5, S("abcdefghij12345"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, "1234567890", 9, S("abcdefghij123456789"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, "1234567890", 10, S("abcdefghij1234567890"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, "12345678901234567890", 0, S("abcdefghij"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, "12345678901234567890", 1, S("abcdefghij1"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, "12345678901234567890", 10, S("abcdefghij1234567890"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, "12345678901234567890", 19, S("abcdefghij1234567890123456789"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, "12345678901234567890", 20, S("abcdefghij12345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, "", 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, "12345", 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, "12345", 1, S("abcdefghijklmnopqrs1t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, "12345", 2, S("abcdefghijklmnopqrs12t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, "12345", 4, S("abcdefghijklmnopqrs1234t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, "12345", 5, S("abcdefghijklmnopqrs12345t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, "1234567890", 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, "1234567890", 1, S("abcdefghijklmnopqrs1t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, "1234567890", 5, S("abcdefghijklmnopqrs12345t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, "1234567890", 9, S("abcdefghijklmnopqrs123456789t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, "1234567890", 10, S("abcdefghijklmnopqrs1234567890t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, "12345678901234567890", 0, S("abcdefghijklmnopqrst"));
+}
+
+template <class S>
+void test11()
+{
+ test(S("abcdefghijklmnopqrst"), 19, 0, "12345678901234567890", 1, S("abcdefghijklmnopqrs1t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, "12345678901234567890", 10, S("abcdefghijklmnopqrs1234567890t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, "12345678901234567890", 19, S("abcdefghijklmnopqrs1234567890123456789t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, "12345678901234567890", 20, S("abcdefghijklmnopqrs12345678901234567890t"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, "", 0, S("abcdefghijklmnopqrs"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, "12345", 0, S("abcdefghijklmnopqrs"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, "12345", 1, S("abcdefghijklmnopqrs1"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, "12345", 2, S("abcdefghijklmnopqrs12"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, "12345", 4, S("abcdefghijklmnopqrs1234"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, "12345", 5, S("abcdefghijklmnopqrs12345"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, "1234567890", 0, S("abcdefghijklmnopqrs"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, "1234567890", 1, S("abcdefghijklmnopqrs1"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, "1234567890", 5, S("abcdefghijklmnopqrs12345"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, "1234567890", 9, S("abcdefghijklmnopqrs123456789"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, "1234567890", 10, S("abcdefghijklmnopqrs1234567890"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, "12345678901234567890", 0, S("abcdefghijklmnopqrs"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, "12345678901234567890", 1, S("abcdefghijklmnopqrs1"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, "12345678901234567890", 10, S("abcdefghijklmnopqrs1234567890"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, "12345678901234567890", 19, S("abcdefghijklmnopqrs1234567890123456789"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, "12345678901234567890", 20, S("abcdefghijklmnopqrs12345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, "", 0, S("abcdefghijklmnopqrs"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, "12345", 0, S("abcdefghijklmnopqrs"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, "12345", 1, S("abcdefghijklmnopqrs1"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, "12345", 2, S("abcdefghijklmnopqrs12"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, "12345", 4, S("abcdefghijklmnopqrs1234"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, "12345", 5, S("abcdefghijklmnopqrs12345"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, "1234567890", 0, S("abcdefghijklmnopqrs"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, "1234567890", 1, S("abcdefghijklmnopqrs1"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, "1234567890", 5, S("abcdefghijklmnopqrs12345"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, "1234567890", 9, S("abcdefghijklmnopqrs123456789"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, "1234567890", 10, S("abcdefghijklmnopqrs1234567890"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, "12345678901234567890", 0, S("abcdefghijklmnopqrs"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, "12345678901234567890", 1, S("abcdefghijklmnopqrs1"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, "12345678901234567890", 10, S("abcdefghijklmnopqrs1234567890"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, "12345678901234567890", 19, S("abcdefghijklmnopqrs1234567890123456789"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, "12345678901234567890", 20, S("abcdefghijklmnopqrs12345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, "", 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, "12345", 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, "12345", 1, S("abcdefghijklmnopqrst1"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, "12345", 2, S("abcdefghijklmnopqrst12"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, "12345", 4, S("abcdefghijklmnopqrst1234"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, "12345", 5, S("abcdefghijklmnopqrst12345"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, "1234567890", 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, "1234567890", 1, S("abcdefghijklmnopqrst1"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, "1234567890", 5, S("abcdefghijklmnopqrst12345"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, "1234567890", 9, S("abcdefghijklmnopqrst123456789"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, "1234567890", 10, S("abcdefghijklmnopqrst1234567890"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, "12345678901234567890", 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, "12345678901234567890", 1, S("abcdefghijklmnopqrst1"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, "12345678901234567890", 10, S("abcdefghijklmnopqrst1234567890"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, "12345678901234567890", 19, S("abcdefghijklmnopqrst1234567890123456789"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, "12345678901234567890", 20, S("abcdefghijklmnopqrst12345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, "", 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, "12345", 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, "12345", 1, S("abcdefghijklmnopqrst1"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, "12345", 2, S("abcdefghijklmnopqrst12"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, "12345", 4, S("abcdefghijklmnopqrst1234"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, "12345", 5, S("abcdefghijklmnopqrst12345"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, "1234567890", 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, "1234567890", 1, S("abcdefghijklmnopqrst1"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, "1234567890", 5, S("abcdefghijklmnopqrst12345"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, "1234567890", 9, S("abcdefghijklmnopqrst123456789"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, "1234567890", 10, S("abcdefghijklmnopqrst1234567890"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, "12345678901234567890", 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, "12345678901234567890", 1, S("abcdefghijklmnopqrst1"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, "12345678901234567890", 10, S("abcdefghijklmnopqrst1234567890"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, "12345678901234567890", 19, S("abcdefghijklmnopqrst1234567890123456789"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, "12345678901234567890", 20, S("abcdefghijklmnopqrst12345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, "", 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, "12345", 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, "12345", 1, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, "12345", 2, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, "12345", 4, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, "12345", 5, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, "1234567890", 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, "1234567890", 1, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, "1234567890", 5, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, "1234567890", 9, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, "1234567890", 10, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, "12345678901234567890", 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, "12345678901234567890", 1, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, "12345678901234567890", 10, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, "12345678901234567890", 19, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, "12345678901234567890", 20, S("can't happen"));
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test0<S>();
+ test1<S>();
+ test2<S>();
+ test3<S>();
+ test4<S>();
+ test5<S>();
+ test6<S>();
+ test7<S>();
+ test8<S>();
+ test9<S>();
+ test10<S>();
+ test11<S>();
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test0<S>();
+ test1<S>();
+ test2<S>();
+ test3<S>();
+ test4<S>();
+ test5<S>();
+ test6<S>();
+ test7<S>();
+ test8<S>();
+ test9<S>();
+ test10<S>();
+ test11<S>();
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.modifiers/string_replace/size_size_size_char.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_replace/size_size_size_char.pass.cpp
new file mode 100644
index 000000000000..33f57fd3b86c
--- /dev/null
+++ b/test/std/strings/basic.string/string.modifiers/string_replace/size_size_size_char.pass.cpp
@@ -0,0 +1,374 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string<charT,traits,Allocator>&
+// replace(size_type pos, size_type n1, size_type n2, charT c);
+
+#include <string>
+#include <stdexcept>
+#include <algorithm>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s, typename S::size_type pos, typename S::size_type n1,
+ typename S::size_type n2, typename S::value_type c,
+ S expected)
+{
+ typename S::size_type old_size = s.size();
+ S s0 = s;
+ try
+ {
+ s.replace(pos, n1, n2, c);
+ assert(s.__invariants());
+ assert(pos <= old_size);
+ assert(s == expected);
+ typename S::size_type xlen = std::min(n1, old_size - pos);
+ typename S::size_type rlen = n2;
+ assert(s.size() == old_size - xlen + rlen);
+ }
+ catch (std::out_of_range&)
+ {
+ assert(pos > old_size);
+ assert(s == s0);
+ }
+}
+
+template <class S>
+void test0()
+{
+ test(S(""), 0, 0, 0, '2', S(""));
+ test(S(""), 0, 0, 5, '2', S("22222"));
+ test(S(""), 0, 0, 10, '2', S("2222222222"));
+ test(S(""), 0, 0, 20, '2', S("22222222222222222222"));
+ test(S(""), 0, 1, 0, '2', S(""));
+ test(S(""), 0, 1, 5, '2', S("22222"));
+ test(S(""), 0, 1, 10, '2', S("2222222222"));
+ test(S(""), 0, 1, 20, '2', S("22222222222222222222"));
+ test(S(""), 1, 0, 0, '2', S("can't happen"));
+ test(S(""), 1, 0, 5, '2', S("can't happen"));
+ test(S(""), 1, 0, 10, '2', S("can't happen"));
+ test(S(""), 1, 0, 20, '2', S("can't happen"));
+ test(S("abcde"), 0, 0, 0, '2', S("abcde"));
+ test(S("abcde"), 0, 0, 5, '2', S("22222abcde"));
+ test(S("abcde"), 0, 0, 10, '2', S("2222222222abcde"));
+ test(S("abcde"), 0, 0, 20, '2', S("22222222222222222222abcde"));
+ test(S("abcde"), 0, 1, 0, '2', S("bcde"));
+ test(S("abcde"), 0, 1, 5, '2', S("22222bcde"));
+ test(S("abcde"), 0, 1, 10, '2', S("2222222222bcde"));
+ test(S("abcde"), 0, 1, 20, '2', S("22222222222222222222bcde"));
+ test(S("abcde"), 0, 2, 0, '2', S("cde"));
+ test(S("abcde"), 0, 2, 5, '2', S("22222cde"));
+ test(S("abcde"), 0, 2, 10, '2', S("2222222222cde"));
+ test(S("abcde"), 0, 2, 20, '2', S("22222222222222222222cde"));
+ test(S("abcde"), 0, 4, 0, '2', S("e"));
+ test(S("abcde"), 0, 4, 5, '2', S("22222e"));
+ test(S("abcde"), 0, 4, 10, '2', S("2222222222e"));
+ test(S("abcde"), 0, 4, 20, '2', S("22222222222222222222e"));
+ test(S("abcde"), 0, 5, 0, '2', S(""));
+ test(S("abcde"), 0, 5, 5, '2', S("22222"));
+ test(S("abcde"), 0, 5, 10, '2', S("2222222222"));
+ test(S("abcde"), 0, 5, 20, '2', S("22222222222222222222"));
+ test(S("abcde"), 0, 6, 0, '2', S(""));
+ test(S("abcde"), 0, 6, 5, '2', S("22222"));
+ test(S("abcde"), 0, 6, 10, '2', S("2222222222"));
+ test(S("abcde"), 0, 6, 20, '2', S("22222222222222222222"));
+ test(S("abcde"), 1, 0, 0, '2', S("abcde"));
+ test(S("abcde"), 1, 0, 5, '2', S("a22222bcde"));
+ test(S("abcde"), 1, 0, 10, '2', S("a2222222222bcde"));
+ test(S("abcde"), 1, 0, 20, '2', S("a22222222222222222222bcde"));
+ test(S("abcde"), 1, 1, 0, '2', S("acde"));
+ test(S("abcde"), 1, 1, 5, '2', S("a22222cde"));
+ test(S("abcde"), 1, 1, 10, '2', S("a2222222222cde"));
+ test(S("abcde"), 1, 1, 20, '2', S("a22222222222222222222cde"));
+ test(S("abcde"), 1, 2, 0, '2', S("ade"));
+ test(S("abcde"), 1, 2, 5, '2', S("a22222de"));
+ test(S("abcde"), 1, 2, 10, '2', S("a2222222222de"));
+ test(S("abcde"), 1, 2, 20, '2', S("a22222222222222222222de"));
+ test(S("abcde"), 1, 3, 0, '2', S("ae"));
+ test(S("abcde"), 1, 3, 5, '2', S("a22222e"));
+ test(S("abcde"), 1, 3, 10, '2', S("a2222222222e"));
+ test(S("abcde"), 1, 3, 20, '2', S("a22222222222222222222e"));
+ test(S("abcde"), 1, 4, 0, '2', S("a"));
+ test(S("abcde"), 1, 4, 5, '2', S("a22222"));
+ test(S("abcde"), 1, 4, 10, '2', S("a2222222222"));
+ test(S("abcde"), 1, 4, 20, '2', S("a22222222222222222222"));
+ test(S("abcde"), 1, 5, 0, '2', S("a"));
+ test(S("abcde"), 1, 5, 5, '2', S("a22222"));
+ test(S("abcde"), 1, 5, 10, '2', S("a2222222222"));
+ test(S("abcde"), 1, 5, 20, '2', S("a22222222222222222222"));
+ test(S("abcde"), 2, 0, 0, '2', S("abcde"));
+ test(S("abcde"), 2, 0, 5, '2', S("ab22222cde"));
+ test(S("abcde"), 2, 0, 10, '2', S("ab2222222222cde"));
+ test(S("abcde"), 2, 0, 20, '2', S("ab22222222222222222222cde"));
+ test(S("abcde"), 2, 1, 0, '2', S("abde"));
+ test(S("abcde"), 2, 1, 5, '2', S("ab22222de"));
+ test(S("abcde"), 2, 1, 10, '2', S("ab2222222222de"));
+ test(S("abcde"), 2, 1, 20, '2', S("ab22222222222222222222de"));
+ test(S("abcde"), 2, 2, 0, '2', S("abe"));
+ test(S("abcde"), 2, 2, 5, '2', S("ab22222e"));
+ test(S("abcde"), 2, 2, 10, '2', S("ab2222222222e"));
+ test(S("abcde"), 2, 2, 20, '2', S("ab22222222222222222222e"));
+ test(S("abcde"), 2, 3, 0, '2', S("ab"));
+ test(S("abcde"), 2, 3, 5, '2', S("ab22222"));
+ test(S("abcde"), 2, 3, 10, '2', S("ab2222222222"));
+ test(S("abcde"), 2, 3, 20, '2', S("ab22222222222222222222"));
+ test(S("abcde"), 2, 4, 0, '2', S("ab"));
+ test(S("abcde"), 2, 4, 5, '2', S("ab22222"));
+ test(S("abcde"), 2, 4, 10, '2', S("ab2222222222"));
+ test(S("abcde"), 2, 4, 20, '2', S("ab22222222222222222222"));
+ test(S("abcde"), 4, 0, 0, '2', S("abcde"));
+ test(S("abcde"), 4, 0, 5, '2', S("abcd22222e"));
+ test(S("abcde"), 4, 0, 10, '2', S("abcd2222222222e"));
+ test(S("abcde"), 4, 0, 20, '2', S("abcd22222222222222222222e"));
+ test(S("abcde"), 4, 1, 0, '2', S("abcd"));
+ test(S("abcde"), 4, 1, 5, '2', S("abcd22222"));
+ test(S("abcde"), 4, 1, 10, '2', S("abcd2222222222"));
+ test(S("abcde"), 4, 1, 20, '2', S("abcd22222222222222222222"));
+ test(S("abcde"), 4, 2, 0, '2', S("abcd"));
+ test(S("abcde"), 4, 2, 5, '2', S("abcd22222"));
+ test(S("abcde"), 4, 2, 10, '2', S("abcd2222222222"));
+ test(S("abcde"), 4, 2, 20, '2', S("abcd22222222222222222222"));
+ test(S("abcde"), 5, 0, 0, '2', S("abcde"));
+ test(S("abcde"), 5, 0, 5, '2', S("abcde22222"));
+ test(S("abcde"), 5, 0, 10, '2', S("abcde2222222222"));
+ test(S("abcde"), 5, 0, 20, '2', S("abcde22222222222222222222"));
+ test(S("abcde"), 5, 1, 0, '2', S("abcde"));
+ test(S("abcde"), 5, 1, 5, '2', S("abcde22222"));
+ test(S("abcde"), 5, 1, 10, '2', S("abcde2222222222"));
+ test(S("abcde"), 5, 1, 20, '2', S("abcde22222222222222222222"));
+}
+
+template <class S>
+void test1()
+{
+ test(S("abcde"), 6, 0, 0, '2', S("can't happen"));
+ test(S("abcde"), 6, 0, 5, '2', S("can't happen"));
+ test(S("abcde"), 6, 0, 10, '2', S("can't happen"));
+ test(S("abcde"), 6, 0, 20, '2', S("can't happen"));
+ test(S("abcdefghij"), 0, 0, 0, '2', S("abcdefghij"));
+ test(S("abcdefghij"), 0, 0, 5, '2', S("22222abcdefghij"));
+ test(S("abcdefghij"), 0, 0, 10, '2', S("2222222222abcdefghij"));
+ test(S("abcdefghij"), 0, 0, 20, '2', S("22222222222222222222abcdefghij"));
+ test(S("abcdefghij"), 0, 1, 0, '2', S("bcdefghij"));
+ test(S("abcdefghij"), 0, 1, 5, '2', S("22222bcdefghij"));
+ test(S("abcdefghij"), 0, 1, 10, '2', S("2222222222bcdefghij"));
+ test(S("abcdefghij"), 0, 1, 20, '2', S("22222222222222222222bcdefghij"));
+ test(S("abcdefghij"), 0, 5, 0, '2', S("fghij"));
+ test(S("abcdefghij"), 0, 5, 5, '2', S("22222fghij"));
+ test(S("abcdefghij"), 0, 5, 10, '2', S("2222222222fghij"));
+ test(S("abcdefghij"), 0, 5, 20, '2', S("22222222222222222222fghij"));
+ test(S("abcdefghij"), 0, 9, 0, '2', S("j"));
+ test(S("abcdefghij"), 0, 9, 5, '2', S("22222j"));
+ test(S("abcdefghij"), 0, 9, 10, '2', S("2222222222j"));
+ test(S("abcdefghij"), 0, 9, 20, '2', S("22222222222222222222j"));
+ test(S("abcdefghij"), 0, 10, 0, '2', S(""));
+ test(S("abcdefghij"), 0, 10, 5, '2', S("22222"));
+ test(S("abcdefghij"), 0, 10, 10, '2', S("2222222222"));
+ test(S("abcdefghij"), 0, 10, 20, '2', S("22222222222222222222"));
+ test(S("abcdefghij"), 0, 11, 0, '2', S(""));
+ test(S("abcdefghij"), 0, 11, 5, '2', S("22222"));
+ test(S("abcdefghij"), 0, 11, 10, '2', S("2222222222"));
+ test(S("abcdefghij"), 0, 11, 20, '2', S("22222222222222222222"));
+ test(S("abcdefghij"), 1, 0, 0, '2', S("abcdefghij"));
+ test(S("abcdefghij"), 1, 0, 5, '2', S("a22222bcdefghij"));
+ test(S("abcdefghij"), 1, 0, 10, '2', S("a2222222222bcdefghij"));
+ test(S("abcdefghij"), 1, 0, 20, '2', S("a22222222222222222222bcdefghij"));
+ test(S("abcdefghij"), 1, 1, 0, '2', S("acdefghij"));
+ test(S("abcdefghij"), 1, 1, 5, '2', S("a22222cdefghij"));
+ test(S("abcdefghij"), 1, 1, 10, '2', S("a2222222222cdefghij"));
+ test(S("abcdefghij"), 1, 1, 20, '2', S("a22222222222222222222cdefghij"));
+ test(S("abcdefghij"), 1, 4, 0, '2', S("afghij"));
+ test(S("abcdefghij"), 1, 4, 5, '2', S("a22222fghij"));
+ test(S("abcdefghij"), 1, 4, 10, '2', S("a2222222222fghij"));
+ test(S("abcdefghij"), 1, 4, 20, '2', S("a22222222222222222222fghij"));
+ test(S("abcdefghij"), 1, 8, 0, '2', S("aj"));
+ test(S("abcdefghij"), 1, 8, 5, '2', S("a22222j"));
+ test(S("abcdefghij"), 1, 8, 10, '2', S("a2222222222j"));
+ test(S("abcdefghij"), 1, 8, 20, '2', S("a22222222222222222222j"));
+ test(S("abcdefghij"), 1, 9, 0, '2', S("a"));
+ test(S("abcdefghij"), 1, 9, 5, '2', S("a22222"));
+ test(S("abcdefghij"), 1, 9, 10, '2', S("a2222222222"));
+ test(S("abcdefghij"), 1, 9, 20, '2', S("a22222222222222222222"));
+ test(S("abcdefghij"), 1, 10, 0, '2', S("a"));
+ test(S("abcdefghij"), 1, 10, 5, '2', S("a22222"));
+ test(S("abcdefghij"), 1, 10, 10, '2', S("a2222222222"));
+ test(S("abcdefghij"), 1, 10, 20, '2', S("a22222222222222222222"));
+ test(S("abcdefghij"), 5, 0, 0, '2', S("abcdefghij"));
+ test(S("abcdefghij"), 5, 0, 5, '2', S("abcde22222fghij"));
+ test(S("abcdefghij"), 5, 0, 10, '2', S("abcde2222222222fghij"));
+ test(S("abcdefghij"), 5, 0, 20, '2', S("abcde22222222222222222222fghij"));
+ test(S("abcdefghij"), 5, 1, 0, '2', S("abcdeghij"));
+ test(S("abcdefghij"), 5, 1, 5, '2', S("abcde22222ghij"));
+ test(S("abcdefghij"), 5, 1, 10, '2', S("abcde2222222222ghij"));
+ test(S("abcdefghij"), 5, 1, 20, '2', S("abcde22222222222222222222ghij"));
+ test(S("abcdefghij"), 5, 2, 0, '2', S("abcdehij"));
+ test(S("abcdefghij"), 5, 2, 5, '2', S("abcde22222hij"));
+ test(S("abcdefghij"), 5, 2, 10, '2', S("abcde2222222222hij"));
+ test(S("abcdefghij"), 5, 2, 20, '2', S("abcde22222222222222222222hij"));
+ test(S("abcdefghij"), 5, 4, 0, '2', S("abcdej"));
+ test(S("abcdefghij"), 5, 4, 5, '2', S("abcde22222j"));
+ test(S("abcdefghij"), 5, 4, 10, '2', S("abcde2222222222j"));
+ test(S("abcdefghij"), 5, 4, 20, '2', S("abcde22222222222222222222j"));
+ test(S("abcdefghij"), 5, 5, 0, '2', S("abcde"));
+ test(S("abcdefghij"), 5, 5, 5, '2', S("abcde22222"));
+ test(S("abcdefghij"), 5, 5, 10, '2', S("abcde2222222222"));
+ test(S("abcdefghij"), 5, 5, 20, '2', S("abcde22222222222222222222"));
+ test(S("abcdefghij"), 5, 6, 0, '2', S("abcde"));
+ test(S("abcdefghij"), 5, 6, 5, '2', S("abcde22222"));
+ test(S("abcdefghij"), 5, 6, 10, '2', S("abcde2222222222"));
+ test(S("abcdefghij"), 5, 6, 20, '2', S("abcde22222222222222222222"));
+ test(S("abcdefghij"), 9, 0, 0, '2', S("abcdefghij"));
+ test(S("abcdefghij"), 9, 0, 5, '2', S("abcdefghi22222j"));
+ test(S("abcdefghij"), 9, 0, 10, '2', S("abcdefghi2222222222j"));
+ test(S("abcdefghij"), 9, 0, 20, '2', S("abcdefghi22222222222222222222j"));
+ test(S("abcdefghij"), 9, 1, 0, '2', S("abcdefghi"));
+ test(S("abcdefghij"), 9, 1, 5, '2', S("abcdefghi22222"));
+ test(S("abcdefghij"), 9, 1, 10, '2', S("abcdefghi2222222222"));
+ test(S("abcdefghij"), 9, 1, 20, '2', S("abcdefghi22222222222222222222"));
+ test(S("abcdefghij"), 9, 2, 0, '2', S("abcdefghi"));
+ test(S("abcdefghij"), 9, 2, 5, '2', S("abcdefghi22222"));
+ test(S("abcdefghij"), 9, 2, 10, '2', S("abcdefghi2222222222"));
+ test(S("abcdefghij"), 9, 2, 20, '2', S("abcdefghi22222222222222222222"));
+ test(S("abcdefghij"), 10, 0, 0, '2', S("abcdefghij"));
+ test(S("abcdefghij"), 10, 0, 5, '2', S("abcdefghij22222"));
+ test(S("abcdefghij"), 10, 0, 10, '2', S("abcdefghij2222222222"));
+ test(S("abcdefghij"), 10, 0, 20, '2', S("abcdefghij22222222222222222222"));
+ test(S("abcdefghij"), 10, 1, 0, '2', S("abcdefghij"));
+ test(S("abcdefghij"), 10, 1, 5, '2', S("abcdefghij22222"));
+ test(S("abcdefghij"), 10, 1, 10, '2', S("abcdefghij2222222222"));
+ test(S("abcdefghij"), 10, 1, 20, '2', S("abcdefghij22222222222222222222"));
+ test(S("abcdefghij"), 11, 0, 0, '2', S("can't happen"));
+ test(S("abcdefghij"), 11, 0, 5, '2', S("can't happen"));
+ test(S("abcdefghij"), 11, 0, 10, '2', S("can't happen"));
+ test(S("abcdefghij"), 11, 0, 20, '2', S("can't happen"));
+}
+
+template <class S>
+void test2()
+{
+ test(S("abcdefghijklmnopqrst"), 0, 0, 0, '2', S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, 5, '2', S("22222abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, 10, '2', S("2222222222abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, 20, '2', S("22222222222222222222abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, 0, '2', S("bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, 5, '2', S("22222bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, 10, '2', S("2222222222bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, 20, '2', S("22222222222222222222bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, 0, '2', S("klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, 5, '2', S("22222klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, 10, '2', S("2222222222klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, 20, '2', S("22222222222222222222klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, 0, '2', S("t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, 5, '2', S("22222t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, 10, '2', S("2222222222t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, 20, '2', S("22222222222222222222t"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, 0, '2', S(""));
+ test(S("abcdefghijklmnopqrst"), 0, 20, 5, '2', S("22222"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, 10, '2', S("2222222222"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, 20, '2', S("22222222222222222222"));
+ test(S("abcdefghijklmnopqrst"), 0, 21, 0, '2', S(""));
+ test(S("abcdefghijklmnopqrst"), 0, 21, 5, '2', S("22222"));
+ test(S("abcdefghijklmnopqrst"), 0, 21, 10, '2', S("2222222222"));
+ test(S("abcdefghijklmnopqrst"), 0, 21, 20, '2', S("22222222222222222222"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, 0, '2', S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, 5, '2', S("a22222bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, 10, '2', S("a2222222222bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, 20, '2', S("a22222222222222222222bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, 0, '2', S("acdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, 5, '2', S("a22222cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, 10, '2', S("a2222222222cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, 20, '2', S("a22222222222222222222cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, 0, '2', S("aklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, 5, '2', S("a22222klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, 10, '2', S("a2222222222klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, 20, '2', S("a22222222222222222222klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, 0, '2', S("at"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, 5, '2', S("a22222t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, 10, '2', S("a2222222222t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, 20, '2', S("a22222222222222222222t"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, 0, '2', S("a"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, 5, '2', S("a22222"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, 10, '2', S("a2222222222"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, 20, '2', S("a22222222222222222222"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, 0, '2', S("a"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, 5, '2', S("a22222"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, 10, '2', S("a2222222222"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, 20, '2', S("a22222222222222222222"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, 0, '2', S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, 5, '2', S("abcdefghij22222klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, 10, '2', S("abcdefghij2222222222klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, 20, '2', S("abcdefghij22222222222222222222klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, 0, '2', S("abcdefghijlmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, 5, '2', S("abcdefghij22222lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, 10, '2', S("abcdefghij2222222222lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, 20, '2', S("abcdefghij22222222222222222222lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, 0, '2', S("abcdefghijpqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, 5, '2', S("abcdefghij22222pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, 10, '2', S("abcdefghij2222222222pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, 20, '2', S("abcdefghij22222222222222222222pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, 0, '2', S("abcdefghijt"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, 5, '2', S("abcdefghij22222t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, 10, '2', S("abcdefghij2222222222t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, 20, '2', S("abcdefghij22222222222222222222t"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, 0, '2', S("abcdefghij"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, 5, '2', S("abcdefghij22222"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, 10, '2', S("abcdefghij2222222222"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, 20, '2', S("abcdefghij22222222222222222222"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, 0, '2', S("abcdefghij"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, 5, '2', S("abcdefghij22222"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, 10, '2', S("abcdefghij2222222222"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, 20, '2', S("abcdefghij22222222222222222222"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, 0, '2', S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, 5, '2', S("abcdefghijklmnopqrs22222t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, 10, '2', S("abcdefghijklmnopqrs2222222222t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, 20, '2', S("abcdefghijklmnopqrs22222222222222222222t"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, 0, '2', S("abcdefghijklmnopqrs"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, 5, '2', S("abcdefghijklmnopqrs22222"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, 10, '2', S("abcdefghijklmnopqrs2222222222"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, 20, '2', S("abcdefghijklmnopqrs22222222222222222222"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, 0, '2', S("abcdefghijklmnopqrs"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, 5, '2', S("abcdefghijklmnopqrs22222"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, 10, '2', S("abcdefghijklmnopqrs2222222222"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, 20, '2', S("abcdefghijklmnopqrs22222222222222222222"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, 0, '2', S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, 5, '2', S("abcdefghijklmnopqrst22222"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, 10, '2', S("abcdefghijklmnopqrst2222222222"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, 20, '2', S("abcdefghijklmnopqrst22222222222222222222"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, 0, '2', S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, 5, '2', S("abcdefghijklmnopqrst22222"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, 10, '2', S("abcdefghijklmnopqrst2222222222"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, 20, '2', S("abcdefghijklmnopqrst22222222222222222222"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, 0, '2', S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, 5, '2', S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, 10, '2', S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, 20, '2', S("can't happen"));
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test0<S>();
+ test1<S>();
+ test2<S>();
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test0<S>();
+ test1<S>();
+ test2<S>();
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.modifiers/string_replace/size_size_string.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_replace/size_size_string.pass.cpp
new file mode 100644
index 000000000000..c130780dc9d1
--- /dev/null
+++ b/test/std/strings/basic.string/string.modifiers/string_replace/size_size_string.pass.cpp
@@ -0,0 +1,372 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string<charT,traits,Allocator>&
+// replace(size_type pos1, size_type n1, const basic_string<charT,traits,Allocator>& str);
+
+#include <string>
+#include <stdexcept>
+#include <algorithm>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s, typename S::size_type pos1, typename S::size_type n1, S str, S expected)
+{
+ typename S::size_type old_size = s.size();
+ S s0 = s;
+ try
+ {
+ s.replace(pos1, n1, str);
+ assert(s.__invariants());
+ assert(pos1 <= old_size);
+ assert(s == expected);
+ typename S::size_type xlen = std::min(n1, old_size - pos1);
+ typename S::size_type rlen = str.size();
+ assert(s.size() == old_size - xlen + rlen);
+ }
+ catch (std::out_of_range&)
+ {
+ assert(pos1 > old_size);
+ assert(s == s0);
+ }
+}
+
+template <class S>
+void test0()
+{
+ test(S(""), 0, 0, S(""), S(""));
+ test(S(""), 0, 0, S("12345"), S("12345"));
+ test(S(""), 0, 0, S("1234567890"), S("1234567890"));
+ test(S(""), 0, 0, S("12345678901234567890"), S("12345678901234567890"));
+ test(S(""), 0, 1, S(""), S(""));
+ test(S(""), 0, 1, S("12345"), S("12345"));
+ test(S(""), 0, 1, S("1234567890"), S("1234567890"));
+ test(S(""), 0, 1, S("12345678901234567890"), S("12345678901234567890"));
+ test(S(""), 1, 0, S(""), S("can't happen"));
+ test(S(""), 1, 0, S("12345"), S("can't happen"));
+ test(S(""), 1, 0, S("1234567890"), S("can't happen"));
+ test(S(""), 1, 0, S("12345678901234567890"), S("can't happen"));
+ test(S("abcde"), 0, 0, S(""), S("abcde"));
+ test(S("abcde"), 0, 0, S("12345"), S("12345abcde"));
+ test(S("abcde"), 0, 0, S("1234567890"), S("1234567890abcde"));
+ test(S("abcde"), 0, 0, S("12345678901234567890"), S("12345678901234567890abcde"));
+ test(S("abcde"), 0, 1, S(""), S("bcde"));
+ test(S("abcde"), 0, 1, S("12345"), S("12345bcde"));
+ test(S("abcde"), 0, 1, S("1234567890"), S("1234567890bcde"));
+ test(S("abcde"), 0, 1, S("12345678901234567890"), S("12345678901234567890bcde"));
+ test(S("abcde"), 0, 2, S(""), S("cde"));
+ test(S("abcde"), 0, 2, S("12345"), S("12345cde"));
+ test(S("abcde"), 0, 2, S("1234567890"), S("1234567890cde"));
+ test(S("abcde"), 0, 2, S("12345678901234567890"), S("12345678901234567890cde"));
+ test(S("abcde"), 0, 4, S(""), S("e"));
+ test(S("abcde"), 0, 4, S("12345"), S("12345e"));
+ test(S("abcde"), 0, 4, S("1234567890"), S("1234567890e"));
+ test(S("abcde"), 0, 4, S("12345678901234567890"), S("12345678901234567890e"));
+ test(S("abcde"), 0, 5, S(""), S(""));
+ test(S("abcde"), 0, 5, S("12345"), S("12345"));
+ test(S("abcde"), 0, 5, S("1234567890"), S("1234567890"));
+ test(S("abcde"), 0, 5, S("12345678901234567890"), S("12345678901234567890"));
+ test(S("abcde"), 0, 6, S(""), S(""));
+ test(S("abcde"), 0, 6, S("12345"), S("12345"));
+ test(S("abcde"), 0, 6, S("1234567890"), S("1234567890"));
+ test(S("abcde"), 0, 6, S("12345678901234567890"), S("12345678901234567890"));
+ test(S("abcde"), 1, 0, S(""), S("abcde"));
+ test(S("abcde"), 1, 0, S("12345"), S("a12345bcde"));
+ test(S("abcde"), 1, 0, S("1234567890"), S("a1234567890bcde"));
+ test(S("abcde"), 1, 0, S("12345678901234567890"), S("a12345678901234567890bcde"));
+ test(S("abcde"), 1, 1, S(""), S("acde"));
+ test(S("abcde"), 1, 1, S("12345"), S("a12345cde"));
+ test(S("abcde"), 1, 1, S("1234567890"), S("a1234567890cde"));
+ test(S("abcde"), 1, 1, S("12345678901234567890"), S("a12345678901234567890cde"));
+ test(S("abcde"), 1, 2, S(""), S("ade"));
+ test(S("abcde"), 1, 2, S("12345"), S("a12345de"));
+ test(S("abcde"), 1, 2, S("1234567890"), S("a1234567890de"));
+ test(S("abcde"), 1, 2, S("12345678901234567890"), S("a12345678901234567890de"));
+ test(S("abcde"), 1, 3, S(""), S("ae"));
+ test(S("abcde"), 1, 3, S("12345"), S("a12345e"));
+ test(S("abcde"), 1, 3, S("1234567890"), S("a1234567890e"));
+ test(S("abcde"), 1, 3, S("12345678901234567890"), S("a12345678901234567890e"));
+ test(S("abcde"), 1, 4, S(""), S("a"));
+ test(S("abcde"), 1, 4, S("12345"), S("a12345"));
+ test(S("abcde"), 1, 4, S("1234567890"), S("a1234567890"));
+ test(S("abcde"), 1, 4, S("12345678901234567890"), S("a12345678901234567890"));
+ test(S("abcde"), 1, 5, S(""), S("a"));
+ test(S("abcde"), 1, 5, S("12345"), S("a12345"));
+ test(S("abcde"), 1, 5, S("1234567890"), S("a1234567890"));
+ test(S("abcde"), 1, 5, S("12345678901234567890"), S("a12345678901234567890"));
+ test(S("abcde"), 2, 0, S(""), S("abcde"));
+ test(S("abcde"), 2, 0, S("12345"), S("ab12345cde"));
+ test(S("abcde"), 2, 0, S("1234567890"), S("ab1234567890cde"));
+ test(S("abcde"), 2, 0, S("12345678901234567890"), S("ab12345678901234567890cde"));
+ test(S("abcde"), 2, 1, S(""), S("abde"));
+ test(S("abcde"), 2, 1, S("12345"), S("ab12345de"));
+ test(S("abcde"), 2, 1, S("1234567890"), S("ab1234567890de"));
+ test(S("abcde"), 2, 1, S("12345678901234567890"), S("ab12345678901234567890de"));
+ test(S("abcde"), 2, 2, S(""), S("abe"));
+ test(S("abcde"), 2, 2, S("12345"), S("ab12345e"));
+ test(S("abcde"), 2, 2, S("1234567890"), S("ab1234567890e"));
+ test(S("abcde"), 2, 2, S("12345678901234567890"), S("ab12345678901234567890e"));
+ test(S("abcde"), 2, 3, S(""), S("ab"));
+ test(S("abcde"), 2, 3, S("12345"), S("ab12345"));
+ test(S("abcde"), 2, 3, S("1234567890"), S("ab1234567890"));
+ test(S("abcde"), 2, 3, S("12345678901234567890"), S("ab12345678901234567890"));
+ test(S("abcde"), 2, 4, S(""), S("ab"));
+ test(S("abcde"), 2, 4, S("12345"), S("ab12345"));
+ test(S("abcde"), 2, 4, S("1234567890"), S("ab1234567890"));
+ test(S("abcde"), 2, 4, S("12345678901234567890"), S("ab12345678901234567890"));
+ test(S("abcde"), 4, 0, S(""), S("abcde"));
+ test(S("abcde"), 4, 0, S("12345"), S("abcd12345e"));
+ test(S("abcde"), 4, 0, S("1234567890"), S("abcd1234567890e"));
+ test(S("abcde"), 4, 0, S("12345678901234567890"), S("abcd12345678901234567890e"));
+ test(S("abcde"), 4, 1, S(""), S("abcd"));
+ test(S("abcde"), 4, 1, S("12345"), S("abcd12345"));
+ test(S("abcde"), 4, 1, S("1234567890"), S("abcd1234567890"));
+ test(S("abcde"), 4, 1, S("12345678901234567890"), S("abcd12345678901234567890"));
+ test(S("abcde"), 4, 2, S(""), S("abcd"));
+ test(S("abcde"), 4, 2, S("12345"), S("abcd12345"));
+ test(S("abcde"), 4, 2, S("1234567890"), S("abcd1234567890"));
+ test(S("abcde"), 4, 2, S("12345678901234567890"), S("abcd12345678901234567890"));
+ test(S("abcde"), 5, 0, S(""), S("abcde"));
+ test(S("abcde"), 5, 0, S("12345"), S("abcde12345"));
+ test(S("abcde"), 5, 0, S("1234567890"), S("abcde1234567890"));
+ test(S("abcde"), 5, 0, S("12345678901234567890"), S("abcde12345678901234567890"));
+ test(S("abcde"), 5, 1, S(""), S("abcde"));
+ test(S("abcde"), 5, 1, S("12345"), S("abcde12345"));
+ test(S("abcde"), 5, 1, S("1234567890"), S("abcde1234567890"));
+ test(S("abcde"), 5, 1, S("12345678901234567890"), S("abcde12345678901234567890"));
+}
+
+template <class S>
+void test1()
+{
+ test(S("abcde"), 6, 0, S(""), S("can't happen"));
+ test(S("abcde"), 6, 0, S("12345"), S("can't happen"));
+ test(S("abcde"), 6, 0, S("1234567890"), S("can't happen"));
+ test(S("abcde"), 6, 0, S("12345678901234567890"), S("can't happen"));
+ test(S("abcdefghij"), 0, 0, S(""), S("abcdefghij"));
+ test(S("abcdefghij"), 0, 0, S("12345"), S("12345abcdefghij"));
+ test(S("abcdefghij"), 0, 0, S("1234567890"), S("1234567890abcdefghij"));
+ test(S("abcdefghij"), 0, 0, S("12345678901234567890"), S("12345678901234567890abcdefghij"));
+ test(S("abcdefghij"), 0, 1, S(""), S("bcdefghij"));
+ test(S("abcdefghij"), 0, 1, S("12345"), S("12345bcdefghij"));
+ test(S("abcdefghij"), 0, 1, S("1234567890"), S("1234567890bcdefghij"));
+ test(S("abcdefghij"), 0, 1, S("12345678901234567890"), S("12345678901234567890bcdefghij"));
+ test(S("abcdefghij"), 0, 5, S(""), S("fghij"));
+ test(S("abcdefghij"), 0, 5, S("12345"), S("12345fghij"));
+ test(S("abcdefghij"), 0, 5, S("1234567890"), S("1234567890fghij"));
+ test(S("abcdefghij"), 0, 5, S("12345678901234567890"), S("12345678901234567890fghij"));
+ test(S("abcdefghij"), 0, 9, S(""), S("j"));
+ test(S("abcdefghij"), 0, 9, S("12345"), S("12345j"));
+ test(S("abcdefghij"), 0, 9, S("1234567890"), S("1234567890j"));
+ test(S("abcdefghij"), 0, 9, S("12345678901234567890"), S("12345678901234567890j"));
+ test(S("abcdefghij"), 0, 10, S(""), S(""));
+ test(S("abcdefghij"), 0, 10, S("12345"), S("12345"));
+ test(S("abcdefghij"), 0, 10, S("1234567890"), S("1234567890"));
+ test(S("abcdefghij"), 0, 10, S("12345678901234567890"), S("12345678901234567890"));
+ test(S("abcdefghij"), 0, 11, S(""), S(""));
+ test(S("abcdefghij"), 0, 11, S("12345"), S("12345"));
+ test(S("abcdefghij"), 0, 11, S("1234567890"), S("1234567890"));
+ test(S("abcdefghij"), 0, 11, S("12345678901234567890"), S("12345678901234567890"));
+ test(S("abcdefghij"), 1, 0, S(""), S("abcdefghij"));
+ test(S("abcdefghij"), 1, 0, S("12345"), S("a12345bcdefghij"));
+ test(S("abcdefghij"), 1, 0, S("1234567890"), S("a1234567890bcdefghij"));
+ test(S("abcdefghij"), 1, 0, S("12345678901234567890"), S("a12345678901234567890bcdefghij"));
+ test(S("abcdefghij"), 1, 1, S(""), S("acdefghij"));
+ test(S("abcdefghij"), 1, 1, S("12345"), S("a12345cdefghij"));
+ test(S("abcdefghij"), 1, 1, S("1234567890"), S("a1234567890cdefghij"));
+ test(S("abcdefghij"), 1, 1, S("12345678901234567890"), S("a12345678901234567890cdefghij"));
+ test(S("abcdefghij"), 1, 4, S(""), S("afghij"));
+ test(S("abcdefghij"), 1, 4, S("12345"), S("a12345fghij"));
+ test(S("abcdefghij"), 1, 4, S("1234567890"), S("a1234567890fghij"));
+ test(S("abcdefghij"), 1, 4, S("12345678901234567890"), S("a12345678901234567890fghij"));
+ test(S("abcdefghij"), 1, 8, S(""), S("aj"));
+ test(S("abcdefghij"), 1, 8, S("12345"), S("a12345j"));
+ test(S("abcdefghij"), 1, 8, S("1234567890"), S("a1234567890j"));
+ test(S("abcdefghij"), 1, 8, S("12345678901234567890"), S("a12345678901234567890j"));
+ test(S("abcdefghij"), 1, 9, S(""), S("a"));
+ test(S("abcdefghij"), 1, 9, S("12345"), S("a12345"));
+ test(S("abcdefghij"), 1, 9, S("1234567890"), S("a1234567890"));
+ test(S("abcdefghij"), 1, 9, S("12345678901234567890"), S("a12345678901234567890"));
+ test(S("abcdefghij"), 1, 10, S(""), S("a"));
+ test(S("abcdefghij"), 1, 10, S("12345"), S("a12345"));
+ test(S("abcdefghij"), 1, 10, S("1234567890"), S("a1234567890"));
+ test(S("abcdefghij"), 1, 10, S("12345678901234567890"), S("a12345678901234567890"));
+ test(S("abcdefghij"), 5, 0, S(""), S("abcdefghij"));
+ test(S("abcdefghij"), 5, 0, S("12345"), S("abcde12345fghij"));
+ test(S("abcdefghij"), 5, 0, S("1234567890"), S("abcde1234567890fghij"));
+ test(S("abcdefghij"), 5, 0, S("12345678901234567890"), S("abcde12345678901234567890fghij"));
+ test(S("abcdefghij"), 5, 1, S(""), S("abcdeghij"));
+ test(S("abcdefghij"), 5, 1, S("12345"), S("abcde12345ghij"));
+ test(S("abcdefghij"), 5, 1, S("1234567890"), S("abcde1234567890ghij"));
+ test(S("abcdefghij"), 5, 1, S("12345678901234567890"), S("abcde12345678901234567890ghij"));
+ test(S("abcdefghij"), 5, 2, S(""), S("abcdehij"));
+ test(S("abcdefghij"), 5, 2, S("12345"), S("abcde12345hij"));
+ test(S("abcdefghij"), 5, 2, S("1234567890"), S("abcde1234567890hij"));
+ test(S("abcdefghij"), 5, 2, S("12345678901234567890"), S("abcde12345678901234567890hij"));
+ test(S("abcdefghij"), 5, 4, S(""), S("abcdej"));
+ test(S("abcdefghij"), 5, 4, S("12345"), S("abcde12345j"));
+ test(S("abcdefghij"), 5, 4, S("1234567890"), S("abcde1234567890j"));
+ test(S("abcdefghij"), 5, 4, S("12345678901234567890"), S("abcde12345678901234567890j"));
+ test(S("abcdefghij"), 5, 5, S(""), S("abcde"));
+ test(S("abcdefghij"), 5, 5, S("12345"), S("abcde12345"));
+ test(S("abcdefghij"), 5, 5, S("1234567890"), S("abcde1234567890"));
+ test(S("abcdefghij"), 5, 5, S("12345678901234567890"), S("abcde12345678901234567890"));
+ test(S("abcdefghij"), 5, 6, S(""), S("abcde"));
+ test(S("abcdefghij"), 5, 6, S("12345"), S("abcde12345"));
+ test(S("abcdefghij"), 5, 6, S("1234567890"), S("abcde1234567890"));
+ test(S("abcdefghij"), 5, 6, S("12345678901234567890"), S("abcde12345678901234567890"));
+ test(S("abcdefghij"), 9, 0, S(""), S("abcdefghij"));
+ test(S("abcdefghij"), 9, 0, S("12345"), S("abcdefghi12345j"));
+ test(S("abcdefghij"), 9, 0, S("1234567890"), S("abcdefghi1234567890j"));
+ test(S("abcdefghij"), 9, 0, S("12345678901234567890"), S("abcdefghi12345678901234567890j"));
+ test(S("abcdefghij"), 9, 1, S(""), S("abcdefghi"));
+ test(S("abcdefghij"), 9, 1, S("12345"), S("abcdefghi12345"));
+ test(S("abcdefghij"), 9, 1, S("1234567890"), S("abcdefghi1234567890"));
+ test(S("abcdefghij"), 9, 1, S("12345678901234567890"), S("abcdefghi12345678901234567890"));
+ test(S("abcdefghij"), 9, 2, S(""), S("abcdefghi"));
+ test(S("abcdefghij"), 9, 2, S("12345"), S("abcdefghi12345"));
+ test(S("abcdefghij"), 9, 2, S("1234567890"), S("abcdefghi1234567890"));
+ test(S("abcdefghij"), 9, 2, S("12345678901234567890"), S("abcdefghi12345678901234567890"));
+ test(S("abcdefghij"), 10, 0, S(""), S("abcdefghij"));
+ test(S("abcdefghij"), 10, 0, S("12345"), S("abcdefghij12345"));
+ test(S("abcdefghij"), 10, 0, S("1234567890"), S("abcdefghij1234567890"));
+ test(S("abcdefghij"), 10, 0, S("12345678901234567890"), S("abcdefghij12345678901234567890"));
+ test(S("abcdefghij"), 10, 1, S(""), S("abcdefghij"));
+ test(S("abcdefghij"), 10, 1, S("12345"), S("abcdefghij12345"));
+ test(S("abcdefghij"), 10, 1, S("1234567890"), S("abcdefghij1234567890"));
+ test(S("abcdefghij"), 10, 1, S("12345678901234567890"), S("abcdefghij12345678901234567890"));
+ test(S("abcdefghij"), 11, 0, S(""), S("can't happen"));
+ test(S("abcdefghij"), 11, 0, S("12345"), S("can't happen"));
+ test(S("abcdefghij"), 11, 0, S("1234567890"), S("can't happen"));
+ test(S("abcdefghij"), 11, 0, S("12345678901234567890"), S("can't happen"));
+}
+
+template <class S>
+void test2()
+{
+ test(S("abcdefghijklmnopqrst"), 0, 0, S(""), S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), S("12345abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), S("1234567890abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), S("12345678901234567890abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S(""), S("bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), S("12345bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), S("1234567890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), S("12345678901234567890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S(""), S("klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), S("12345klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), S("1234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), S("12345678901234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S(""), S("t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), S("12345t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), S("1234567890t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), S("12345678901234567890t"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S(""), S(""));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), S("12345"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), S("1234567890"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), S("12345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 0, 21, S(""), S(""));
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), S("12345"));
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), S("1234567890"));
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), S("12345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S(""), S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), S("a12345bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), S("a1234567890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), S("a12345678901234567890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S(""), S("acdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), S("a12345cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), S("a1234567890cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), S("a12345678901234567890cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S(""), S("aklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), S("a12345klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), S("a1234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), S("a12345678901234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S(""), S("at"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), S("a12345t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), S("a1234567890t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), S("a12345678901234567890t"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S(""), S("a"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), S("a12345"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), S("a1234567890"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), S("a12345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, S(""), S("a"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), S("a12345"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), S("a1234567890"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), S("a12345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S(""), S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), S("abcdefghij12345klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), S("abcdefghij1234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), S("abcdefghij12345678901234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S(""), S("abcdefghijlmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), S("abcdefghij12345lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), S("abcdefghij1234567890lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), S("abcdefghij12345678901234567890lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S(""), S("abcdefghijpqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), S("abcdefghij12345pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), S("abcdefghij1234567890pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), S("abcdefghij12345678901234567890pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S(""), S("abcdefghijt"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), S("abcdefghij12345t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), S("abcdefghij1234567890t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), S("abcdefghij12345678901234567890t"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, S(""), S("abcdefghij"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), S("abcdefghij12345"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), S("abcdefghij1234567890"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), S("abcdefghij12345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, S(""), S("abcdefghij"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), S("abcdefghij12345"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), S("abcdefghij1234567890"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), S("abcdefghij12345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S(""), S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), S("abcdefghijklmnopqrs12345t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), S("abcdefghijklmnopqrs1234567890t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), S("abcdefghijklmnopqrs12345678901234567890t"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S(""), S("abcdefghijklmnopqrs"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), S("abcdefghijklmnopqrs12345"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), S("abcdefghijklmnopqrs1234567890"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), S("abcdefghijklmnopqrs12345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, S(""), S("abcdefghijklmnopqrs"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), S("abcdefghijklmnopqrs12345"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), S("abcdefghijklmnopqrs1234567890"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), S("abcdefghijklmnopqrs12345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S(""), S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), S("abcdefghijklmnopqrst12345"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, S(""), S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), S("abcdefghijklmnopqrst12345"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, S(""), S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), S("can't happen"));
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test0<S>();
+ test1<S>();
+ test2<S>();
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test0<S>();
+ test1<S>();
+ test2<S>();
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.modifiers/string_replace/size_size_string_size_size.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_replace/size_size_string_size_size.pass.cpp
new file mode 100644
index 000000000000..ef0de8975eda
--- /dev/null
+++ b/test/std/strings/basic.string/string.modifiers/string_replace/size_size_string_size_size.pass.cpp
@@ -0,0 +1,5966 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string<charT,traits,Allocator>&
+// replace(size_type pos1, size_type n1, const basic_string<charT,traits,Allocator>& str,
+// size_type pos2, size_type n2=npos);
+// the "=npos" was added in C++14
+
+#include <string>
+#include <stdexcept>
+#include <algorithm>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s, typename S::size_type pos1, typename S::size_type n1,
+ S str, typename S::size_type pos2, typename S::size_type n2,
+ S expected)
+{
+ typename S::size_type old_size = s.size();
+ S s0 = s;
+ try
+ {
+ s.replace(pos1, n1, str, pos2, n2);
+ assert(s.__invariants());
+ assert(pos1 <= old_size && pos2 <= str.size());
+ assert(s == expected);
+ typename S::size_type xlen = std::min(n1, old_size - pos1);
+ typename S::size_type rlen = std::min(n2, str.size() - pos2);
+ assert(s.size() == old_size - xlen + rlen);
+ }
+ catch (std::out_of_range&)
+ {
+ assert(pos1 > old_size || pos2 > str.size());
+ assert(s == s0);
+ }
+}
+
+template <class S>
+void
+test_npos(S s, typename S::size_type pos1, typename S::size_type n1,
+ S str, typename S::size_type pos2,
+ S expected)
+{
+ typename S::size_type old_size = s.size();
+ S s0 = s;
+ try
+ {
+ s.replace(pos1, n1, str, pos2);
+ assert(s.__invariants());
+ assert(pos1 <= old_size && pos2 <= str.size());
+ assert(s == expected);
+ typename S::size_type xlen = std::min(n1, old_size - pos1);
+ typename S::size_type rlen = std::min(S::npos, str.size() - pos2);
+ assert(s.size() == old_size - xlen + rlen);
+ }
+ catch (std::out_of_range&)
+ {
+ assert(pos1 > old_size || pos2 > str.size());
+ assert(s == s0);
+ }
+}
+
+
+template <class S>
+void test0()
+{
+ test(S(""), 0, 0, S(""), 0, 0, S(""));
+ test(S(""), 0, 0, S(""), 0, 1, S(""));
+ test(S(""), 0, 0, S(""), 1, 0, S("can't happen"));
+ test(S(""), 0, 0, S("12345"), 0, 0, S(""));
+ test(S(""), 0, 0, S("12345"), 0, 1, S("1"));
+ test(S(""), 0, 0, S("12345"), 0, 2, S("12"));
+ test(S(""), 0, 0, S("12345"), 0, 4, S("1234"));
+ test(S(""), 0, 0, S("12345"), 0, 5, S("12345"));
+ test(S(""), 0, 0, S("12345"), 0, 6, S("12345"));
+ test(S(""), 0, 0, S("12345"), 1, 0, S(""));
+ test(S(""), 0, 0, S("12345"), 1, 1, S("2"));
+ test(S(""), 0, 0, S("12345"), 1, 2, S("23"));
+ test(S(""), 0, 0, S("12345"), 1, 3, S("234"));
+ test(S(""), 0, 0, S("12345"), 1, 4, S("2345"));
+ test(S(""), 0, 0, S("12345"), 1, 5, S("2345"));
+ test(S(""), 0, 0, S("12345"), 2, 0, S(""));
+ test(S(""), 0, 0, S("12345"), 2, 1, S("3"));
+ test(S(""), 0, 0, S("12345"), 2, 2, S("34"));
+ test(S(""), 0, 0, S("12345"), 2, 3, S("345"));
+ test(S(""), 0, 0, S("12345"), 2, 4, S("345"));
+ test(S(""), 0, 0, S("12345"), 4, 0, S(""));
+ test(S(""), 0, 0, S("12345"), 4, 1, S("5"));
+ test(S(""), 0, 0, S("12345"), 4, 2, S("5"));
+ test(S(""), 0, 0, S("12345"), 5, 0, S(""));
+ test(S(""), 0, 0, S("12345"), 5, 1, S(""));
+ test(S(""), 0, 0, S("12345"), 6, 0, S("can't happen"));
+ test(S(""), 0, 0, S("1234567890"), 0, 0, S(""));
+ test(S(""), 0, 0, S("1234567890"), 0, 1, S("1"));
+ test(S(""), 0, 0, S("1234567890"), 0, 5, S("12345"));
+ test(S(""), 0, 0, S("1234567890"), 0, 9, S("123456789"));
+ test(S(""), 0, 0, S("1234567890"), 0, 10, S("1234567890"));
+ test(S(""), 0, 0, S("1234567890"), 0, 11, S("1234567890"));
+ test(S(""), 0, 0, S("1234567890"), 1, 0, S(""));
+ test(S(""), 0, 0, S("1234567890"), 1, 1, S("2"));
+ test(S(""), 0, 0, S("1234567890"), 1, 4, S("2345"));
+ test(S(""), 0, 0, S("1234567890"), 1, 8, S("23456789"));
+ test(S(""), 0, 0, S("1234567890"), 1, 9, S("234567890"));
+ test(S(""), 0, 0, S("1234567890"), 1, 10, S("234567890"));
+ test(S(""), 0, 0, S("1234567890"), 5, 0, S(""));
+ test(S(""), 0, 0, S("1234567890"), 5, 1, S("6"));
+ test(S(""), 0, 0, S("1234567890"), 5, 2, S("67"));
+ test(S(""), 0, 0, S("1234567890"), 5, 4, S("6789"));
+ test(S(""), 0, 0, S("1234567890"), 5, 5, S("67890"));
+ test(S(""), 0, 0, S("1234567890"), 5, 6, S("67890"));
+ test(S(""), 0, 0, S("1234567890"), 9, 0, S(""));
+ test(S(""), 0, 0, S("1234567890"), 9, 1, S("0"));
+ test(S(""), 0, 0, S("1234567890"), 9, 2, S("0"));
+ test(S(""), 0, 0, S("1234567890"), 10, 0, S(""));
+ test(S(""), 0, 0, S("1234567890"), 10, 1, S(""));
+ test(S(""), 0, 0, S("1234567890"), 11, 0, S("can't happen"));
+ test(S(""), 0, 0, S("12345678901234567890"), 0, 0, S(""));
+ test(S(""), 0, 0, S("12345678901234567890"), 0, 1, S("1"));
+ test(S(""), 0, 0, S("12345678901234567890"), 0, 10, S("1234567890"));
+ test(S(""), 0, 0, S("12345678901234567890"), 0, 19, S("1234567890123456789"));
+ test(S(""), 0, 0, S("12345678901234567890"), 0, 20, S("12345678901234567890"));
+ test(S(""), 0, 0, S("12345678901234567890"), 0, 21, S("12345678901234567890"));
+ test(S(""), 0, 0, S("12345678901234567890"), 1, 0, S(""));
+ test(S(""), 0, 0, S("12345678901234567890"), 1, 1, S("2"));
+ test(S(""), 0, 0, S("12345678901234567890"), 1, 9, S("234567890"));
+ test(S(""), 0, 0, S("12345678901234567890"), 1, 18, S("234567890123456789"));
+ test(S(""), 0, 0, S("12345678901234567890"), 1, 19, S("2345678901234567890"));
+ test(S(""), 0, 0, S("12345678901234567890"), 1, 20, S("2345678901234567890"));
+ test(S(""), 0, 0, S("12345678901234567890"), 10, 0, S(""));
+ test(S(""), 0, 0, S("12345678901234567890"), 10, 1, S("1"));
+ test(S(""), 0, 0, S("12345678901234567890"), 10, 5, S("12345"));
+ test(S(""), 0, 0, S("12345678901234567890"), 10, 9, S("123456789"));
+ test(S(""), 0, 0, S("12345678901234567890"), 10, 10, S("1234567890"));
+ test(S(""), 0, 0, S("12345678901234567890"), 10, 11, S("1234567890"));
+ test(S(""), 0, 0, S("12345678901234567890"), 19, 0, S(""));
+ test(S(""), 0, 0, S("12345678901234567890"), 19, 1, S("0"));
+ test(S(""), 0, 0, S("12345678901234567890"), 19, 2, S("0"));
+ test(S(""), 0, 0, S("12345678901234567890"), 20, 0, S(""));
+ test(S(""), 0, 0, S("12345678901234567890"), 20, 1, S(""));
+ test(S(""), 0, 0, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S(""), 0, 1, S(""), 0, 0, S(""));
+ test(S(""), 0, 1, S(""), 0, 1, S(""));
+ test(S(""), 0, 1, S(""), 1, 0, S("can't happen"));
+ test(S(""), 0, 1, S("12345"), 0, 0, S(""));
+ test(S(""), 0, 1, S("12345"), 0, 1, S("1"));
+ test(S(""), 0, 1, S("12345"), 0, 2, S("12"));
+ test(S(""), 0, 1, S("12345"), 0, 4, S("1234"));
+ test(S(""), 0, 1, S("12345"), 0, 5, S("12345"));
+ test(S(""), 0, 1, S("12345"), 0, 6, S("12345"));
+ test(S(""), 0, 1, S("12345"), 1, 0, S(""));
+ test(S(""), 0, 1, S("12345"), 1, 1, S("2"));
+ test(S(""), 0, 1, S("12345"), 1, 2, S("23"));
+ test(S(""), 0, 1, S("12345"), 1, 3, S("234"));
+ test(S(""), 0, 1, S("12345"), 1, 4, S("2345"));
+ test(S(""), 0, 1, S("12345"), 1, 5, S("2345"));
+ test(S(""), 0, 1, S("12345"), 2, 0, S(""));
+ test(S(""), 0, 1, S("12345"), 2, 1, S("3"));
+ test(S(""), 0, 1, S("12345"), 2, 2, S("34"));
+ test(S(""), 0, 1, S("12345"), 2, 3, S("345"));
+ test(S(""), 0, 1, S("12345"), 2, 4, S("345"));
+ test(S(""), 0, 1, S("12345"), 4, 0, S(""));
+ test(S(""), 0, 1, S("12345"), 4, 1, S("5"));
+ test(S(""), 0, 1, S("12345"), 4, 2, S("5"));
+ test(S(""), 0, 1, S("12345"), 5, 0, S(""));
+ test(S(""), 0, 1, S("12345"), 5, 1, S(""));
+ test(S(""), 0, 1, S("12345"), 6, 0, S("can't happen"));
+}
+
+template <class S>
+void test1()
+{
+ test(S(""), 0, 1, S("1234567890"), 0, 0, S(""));
+ test(S(""), 0, 1, S("1234567890"), 0, 1, S("1"));
+ test(S(""), 0, 1, S("1234567890"), 0, 5, S("12345"));
+ test(S(""), 0, 1, S("1234567890"), 0, 9, S("123456789"));
+ test(S(""), 0, 1, S("1234567890"), 0, 10, S("1234567890"));
+ test(S(""), 0, 1, S("1234567890"), 0, 11, S("1234567890"));
+ test(S(""), 0, 1, S("1234567890"), 1, 0, S(""));
+ test(S(""), 0, 1, S("1234567890"), 1, 1, S("2"));
+ test(S(""), 0, 1, S("1234567890"), 1, 4, S("2345"));
+ test(S(""), 0, 1, S("1234567890"), 1, 8, S("23456789"));
+ test(S(""), 0, 1, S("1234567890"), 1, 9, S("234567890"));
+ test(S(""), 0, 1, S("1234567890"), 1, 10, S("234567890"));
+ test(S(""), 0, 1, S("1234567890"), 5, 0, S(""));
+ test(S(""), 0, 1, S("1234567890"), 5, 1, S("6"));
+ test(S(""), 0, 1, S("1234567890"), 5, 2, S("67"));
+ test(S(""), 0, 1, S("1234567890"), 5, 4, S("6789"));
+ test(S(""), 0, 1, S("1234567890"), 5, 5, S("67890"));
+ test(S(""), 0, 1, S("1234567890"), 5, 6, S("67890"));
+ test(S(""), 0, 1, S("1234567890"), 9, 0, S(""));
+ test(S(""), 0, 1, S("1234567890"), 9, 1, S("0"));
+ test(S(""), 0, 1, S("1234567890"), 9, 2, S("0"));
+ test(S(""), 0, 1, S("1234567890"), 10, 0, S(""));
+ test(S(""), 0, 1, S("1234567890"), 10, 1, S(""));
+ test(S(""), 0, 1, S("1234567890"), 11, 0, S("can't happen"));
+ test(S(""), 0, 1, S("12345678901234567890"), 0, 0, S(""));
+ test(S(""), 0, 1, S("12345678901234567890"), 0, 1, S("1"));
+ test(S(""), 0, 1, S("12345678901234567890"), 0, 10, S("1234567890"));
+ test(S(""), 0, 1, S("12345678901234567890"), 0, 19, S("1234567890123456789"));
+ test(S(""), 0, 1, S("12345678901234567890"), 0, 20, S("12345678901234567890"));
+ test(S(""), 0, 1, S("12345678901234567890"), 0, 21, S("12345678901234567890"));
+ test(S(""), 0, 1, S("12345678901234567890"), 1, 0, S(""));
+ test(S(""), 0, 1, S("12345678901234567890"), 1, 1, S("2"));
+ test(S(""), 0, 1, S("12345678901234567890"), 1, 9, S("234567890"));
+ test(S(""), 0, 1, S("12345678901234567890"), 1, 18, S("234567890123456789"));
+ test(S(""), 0, 1, S("12345678901234567890"), 1, 19, S("2345678901234567890"));
+ test(S(""), 0, 1, S("12345678901234567890"), 1, 20, S("2345678901234567890"));
+ test(S(""), 0, 1, S("12345678901234567890"), 10, 0, S(""));
+ test(S(""), 0, 1, S("12345678901234567890"), 10, 1, S("1"));
+ test(S(""), 0, 1, S("12345678901234567890"), 10, 5, S("12345"));
+ test(S(""), 0, 1, S("12345678901234567890"), 10, 9, S("123456789"));
+ test(S(""), 0, 1, S("12345678901234567890"), 10, 10, S("1234567890"));
+ test(S(""), 0, 1, S("12345678901234567890"), 10, 11, S("1234567890"));
+ test(S(""), 0, 1, S("12345678901234567890"), 19, 0, S(""));
+ test(S(""), 0, 1, S("12345678901234567890"), 19, 1, S("0"));
+ test(S(""), 0, 1, S("12345678901234567890"), 19, 2, S("0"));
+ test(S(""), 0, 1, S("12345678901234567890"), 20, 0, S(""));
+ test(S(""), 0, 1, S("12345678901234567890"), 20, 1, S(""));
+ test(S(""), 0, 1, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S(""), 1, 0, S(""), 0, 0, S("can't happen"));
+ test(S(""), 1, 0, S(""), 0, 1, S("can't happen"));
+ test(S(""), 1, 0, S(""), 1, 0, S("can't happen"));
+ test(S(""), 1, 0, S("12345"), 0, 0, S("can't happen"));
+ test(S(""), 1, 0, S("12345"), 0, 1, S("can't happen"));
+ test(S(""), 1, 0, S("12345"), 0, 2, S("can't happen"));
+ test(S(""), 1, 0, S("12345"), 0, 4, S("can't happen"));
+ test(S(""), 1, 0, S("12345"), 0, 5, S("can't happen"));
+ test(S(""), 1, 0, S("12345"), 0, 6, S("can't happen"));
+ test(S(""), 1, 0, S("12345"), 1, 0, S("can't happen"));
+ test(S(""), 1, 0, S("12345"), 1, 1, S("can't happen"));
+ test(S(""), 1, 0, S("12345"), 1, 2, S("can't happen"));
+ test(S(""), 1, 0, S("12345"), 1, 3, S("can't happen"));
+ test(S(""), 1, 0, S("12345"), 1, 4, S("can't happen"));
+ test(S(""), 1, 0, S("12345"), 1, 5, S("can't happen"));
+ test(S(""), 1, 0, S("12345"), 2, 0, S("can't happen"));
+ test(S(""), 1, 0, S("12345"), 2, 1, S("can't happen"));
+ test(S(""), 1, 0, S("12345"), 2, 2, S("can't happen"));
+ test(S(""), 1, 0, S("12345"), 2, 3, S("can't happen"));
+ test(S(""), 1, 0, S("12345"), 2, 4, S("can't happen"));
+ test(S(""), 1, 0, S("12345"), 4, 0, S("can't happen"));
+ test(S(""), 1, 0, S("12345"), 4, 1, S("can't happen"));
+ test(S(""), 1, 0, S("12345"), 4, 2, S("can't happen"));
+ test(S(""), 1, 0, S("12345"), 5, 0, S("can't happen"));
+ test(S(""), 1, 0, S("12345"), 5, 1, S("can't happen"));
+ test(S(""), 1, 0, S("12345"), 6, 0, S("can't happen"));
+ test(S(""), 1, 0, S("1234567890"), 0, 0, S("can't happen"));
+ test(S(""), 1, 0, S("1234567890"), 0, 1, S("can't happen"));
+ test(S(""), 1, 0, S("1234567890"), 0, 5, S("can't happen"));
+ test(S(""), 1, 0, S("1234567890"), 0, 9, S("can't happen"));
+ test(S(""), 1, 0, S("1234567890"), 0, 10, S("can't happen"));
+ test(S(""), 1, 0, S("1234567890"), 0, 11, S("can't happen"));
+ test(S(""), 1, 0, S("1234567890"), 1, 0, S("can't happen"));
+ test(S(""), 1, 0, S("1234567890"), 1, 1, S("can't happen"));
+ test(S(""), 1, 0, S("1234567890"), 1, 4, S("can't happen"));
+ test(S(""), 1, 0, S("1234567890"), 1, 8, S("can't happen"));
+ test(S(""), 1, 0, S("1234567890"), 1, 9, S("can't happen"));
+ test(S(""), 1, 0, S("1234567890"), 1, 10, S("can't happen"));
+ test(S(""), 1, 0, S("1234567890"), 5, 0, S("can't happen"));
+ test(S(""), 1, 0, S("1234567890"), 5, 1, S("can't happen"));
+ test(S(""), 1, 0, S("1234567890"), 5, 2, S("can't happen"));
+ test(S(""), 1, 0, S("1234567890"), 5, 4, S("can't happen"));
+ test(S(""), 1, 0, S("1234567890"), 5, 5, S("can't happen"));
+ test(S(""), 1, 0, S("1234567890"), 5, 6, S("can't happen"));
+ test(S(""), 1, 0, S("1234567890"), 9, 0, S("can't happen"));
+ test(S(""), 1, 0, S("1234567890"), 9, 1, S("can't happen"));
+ test(S(""), 1, 0, S("1234567890"), 9, 2, S("can't happen"));
+ test(S(""), 1, 0, S("1234567890"), 10, 0, S("can't happen"));
+ test(S(""), 1, 0, S("1234567890"), 10, 1, S("can't happen"));
+ test(S(""), 1, 0, S("1234567890"), 11, 0, S("can't happen"));
+ test(S(""), 1, 0, S("12345678901234567890"), 0, 0, S("can't happen"));
+ test(S(""), 1, 0, S("12345678901234567890"), 0, 1, S("can't happen"));
+}
+
+template <class S>
+void test2()
+{
+ test(S(""), 1, 0, S("12345678901234567890"), 0, 10, S("can't happen"));
+ test(S(""), 1, 0, S("12345678901234567890"), 0, 19, S("can't happen"));
+ test(S(""), 1, 0, S("12345678901234567890"), 0, 20, S("can't happen"));
+ test(S(""), 1, 0, S("12345678901234567890"), 0, 21, S("can't happen"));
+ test(S(""), 1, 0, S("12345678901234567890"), 1, 0, S("can't happen"));
+ test(S(""), 1, 0, S("12345678901234567890"), 1, 1, S("can't happen"));
+ test(S(""), 1, 0, S("12345678901234567890"), 1, 9, S("can't happen"));
+ test(S(""), 1, 0, S("12345678901234567890"), 1, 18, S("can't happen"));
+ test(S(""), 1, 0, S("12345678901234567890"), 1, 19, S("can't happen"));
+ test(S(""), 1, 0, S("12345678901234567890"), 1, 20, S("can't happen"));
+ test(S(""), 1, 0, S("12345678901234567890"), 10, 0, S("can't happen"));
+ test(S(""), 1, 0, S("12345678901234567890"), 10, 1, S("can't happen"));
+ test(S(""), 1, 0, S("12345678901234567890"), 10, 5, S("can't happen"));
+ test(S(""), 1, 0, S("12345678901234567890"), 10, 9, S("can't happen"));
+ test(S(""), 1, 0, S("12345678901234567890"), 10, 10, S("can't happen"));
+ test(S(""), 1, 0, S("12345678901234567890"), 10, 11, S("can't happen"));
+ test(S(""), 1, 0, S("12345678901234567890"), 19, 0, S("can't happen"));
+ test(S(""), 1, 0, S("12345678901234567890"), 19, 1, S("can't happen"));
+ test(S(""), 1, 0, S("12345678901234567890"), 19, 2, S("can't happen"));
+ test(S(""), 1, 0, S("12345678901234567890"), 20, 0, S("can't happen"));
+ test(S(""), 1, 0, S("12345678901234567890"), 20, 1, S("can't happen"));
+ test(S(""), 1, 0, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcde"), 0, 0, S(""), 0, 0, S("abcde"));
+ test(S("abcde"), 0, 0, S(""), 0, 1, S("abcde"));
+ test(S("abcde"), 0, 0, S(""), 1, 0, S("can't happen"));
+ test(S("abcde"), 0, 0, S("12345"), 0, 0, S("abcde"));
+ test(S("abcde"), 0, 0, S("12345"), 0, 1, S("1abcde"));
+ test(S("abcde"), 0, 0, S("12345"), 0, 2, S("12abcde"));
+ test(S("abcde"), 0, 0, S("12345"), 0, 4, S("1234abcde"));
+ test(S("abcde"), 0, 0, S("12345"), 0, 5, S("12345abcde"));
+ test(S("abcde"), 0, 0, S("12345"), 0, 6, S("12345abcde"));
+ test(S("abcde"), 0, 0, S("12345"), 1, 0, S("abcde"));
+ test(S("abcde"), 0, 0, S("12345"), 1, 1, S("2abcde"));
+ test(S("abcde"), 0, 0, S("12345"), 1, 2, S("23abcde"));
+ test(S("abcde"), 0, 0, S("12345"), 1, 3, S("234abcde"));
+ test(S("abcde"), 0, 0, S("12345"), 1, 4, S("2345abcde"));
+ test(S("abcde"), 0, 0, S("12345"), 1, 5, S("2345abcde"));
+ test(S("abcde"), 0, 0, S("12345"), 2, 0, S("abcde"));
+ test(S("abcde"), 0, 0, S("12345"), 2, 1, S("3abcde"));
+ test(S("abcde"), 0, 0, S("12345"), 2, 2, S("34abcde"));
+ test(S("abcde"), 0, 0, S("12345"), 2, 3, S("345abcde"));
+ test(S("abcde"), 0, 0, S("12345"), 2, 4, S("345abcde"));
+ test(S("abcde"), 0, 0, S("12345"), 4, 0, S("abcde"));
+ test(S("abcde"), 0, 0, S("12345"), 4, 1, S("5abcde"));
+ test(S("abcde"), 0, 0, S("12345"), 4, 2, S("5abcde"));
+ test(S("abcde"), 0, 0, S("12345"), 5, 0, S("abcde"));
+ test(S("abcde"), 0, 0, S("12345"), 5, 1, S("abcde"));
+ test(S("abcde"), 0, 0, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcde"), 0, 0, S("1234567890"), 0, 0, S("abcde"));
+ test(S("abcde"), 0, 0, S("1234567890"), 0, 1, S("1abcde"));
+ test(S("abcde"), 0, 0, S("1234567890"), 0, 5, S("12345abcde"));
+ test(S("abcde"), 0, 0, S("1234567890"), 0, 9, S("123456789abcde"));
+ test(S("abcde"), 0, 0, S("1234567890"), 0, 10, S("1234567890abcde"));
+ test(S("abcde"), 0, 0, S("1234567890"), 0, 11, S("1234567890abcde"));
+ test(S("abcde"), 0, 0, S("1234567890"), 1, 0, S("abcde"));
+ test(S("abcde"), 0, 0, S("1234567890"), 1, 1, S("2abcde"));
+ test(S("abcde"), 0, 0, S("1234567890"), 1, 4, S("2345abcde"));
+ test(S("abcde"), 0, 0, S("1234567890"), 1, 8, S("23456789abcde"));
+ test(S("abcde"), 0, 0, S("1234567890"), 1, 9, S("234567890abcde"));
+ test(S("abcde"), 0, 0, S("1234567890"), 1, 10, S("234567890abcde"));
+ test(S("abcde"), 0, 0, S("1234567890"), 5, 0, S("abcde"));
+ test(S("abcde"), 0, 0, S("1234567890"), 5, 1, S("6abcde"));
+ test(S("abcde"), 0, 0, S("1234567890"), 5, 2, S("67abcde"));
+ test(S("abcde"), 0, 0, S("1234567890"), 5, 4, S("6789abcde"));
+ test(S("abcde"), 0, 0, S("1234567890"), 5, 5, S("67890abcde"));
+ test(S("abcde"), 0, 0, S("1234567890"), 5, 6, S("67890abcde"));
+ test(S("abcde"), 0, 0, S("1234567890"), 9, 0, S("abcde"));
+ test(S("abcde"), 0, 0, S("1234567890"), 9, 1, S("0abcde"));
+ test(S("abcde"), 0, 0, S("1234567890"), 9, 2, S("0abcde"));
+ test(S("abcde"), 0, 0, S("1234567890"), 10, 0, S("abcde"));
+ test(S("abcde"), 0, 0, S("1234567890"), 10, 1, S("abcde"));
+ test(S("abcde"), 0, 0, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcde"), 0, 0, S("12345678901234567890"), 0, 0, S("abcde"));
+ test(S("abcde"), 0, 0, S("12345678901234567890"), 0, 1, S("1abcde"));
+ test(S("abcde"), 0, 0, S("12345678901234567890"), 0, 10, S("1234567890abcde"));
+ test(S("abcde"), 0, 0, S("12345678901234567890"), 0, 19, S("1234567890123456789abcde"));
+ test(S("abcde"), 0, 0, S("12345678901234567890"), 0, 20, S("12345678901234567890abcde"));
+ test(S("abcde"), 0, 0, S("12345678901234567890"), 0, 21, S("12345678901234567890abcde"));
+ test(S("abcde"), 0, 0, S("12345678901234567890"), 1, 0, S("abcde"));
+ test(S("abcde"), 0, 0, S("12345678901234567890"), 1, 1, S("2abcde"));
+ test(S("abcde"), 0, 0, S("12345678901234567890"), 1, 9, S("234567890abcde"));
+ test(S("abcde"), 0, 0, S("12345678901234567890"), 1, 18, S("234567890123456789abcde"));
+ test(S("abcde"), 0, 0, S("12345678901234567890"), 1, 19, S("2345678901234567890abcde"));
+ test(S("abcde"), 0, 0, S("12345678901234567890"), 1, 20, S("2345678901234567890abcde"));
+ test(S("abcde"), 0, 0, S("12345678901234567890"), 10, 0, S("abcde"));
+ test(S("abcde"), 0, 0, S("12345678901234567890"), 10, 1, S("1abcde"));
+ test(S("abcde"), 0, 0, S("12345678901234567890"), 10, 5, S("12345abcde"));
+ test(S("abcde"), 0, 0, S("12345678901234567890"), 10, 9, S("123456789abcde"));
+ test(S("abcde"), 0, 0, S("12345678901234567890"), 10, 10, S("1234567890abcde"));
+ test(S("abcde"), 0, 0, S("12345678901234567890"), 10, 11, S("1234567890abcde"));
+ test(S("abcde"), 0, 0, S("12345678901234567890"), 19, 0, S("abcde"));
+ test(S("abcde"), 0, 0, S("12345678901234567890"), 19, 1, S("0abcde"));
+ test(S("abcde"), 0, 0, S("12345678901234567890"), 19, 2, S("0abcde"));
+ test(S("abcde"), 0, 0, S("12345678901234567890"), 20, 0, S("abcde"));
+ test(S("abcde"), 0, 0, S("12345678901234567890"), 20, 1, S("abcde"));
+ test(S("abcde"), 0, 0, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcde"), 0, 1, S(""), 0, 0, S("bcde"));
+ test(S("abcde"), 0, 1, S(""), 0, 1, S("bcde"));
+ test(S("abcde"), 0, 1, S(""), 1, 0, S("can't happen"));
+ test(S("abcde"), 0, 1, S("12345"), 0, 0, S("bcde"));
+}
+
+template <class S>
+void test3()
+{
+ test(S("abcde"), 0, 1, S("12345"), 0, 1, S("1bcde"));
+ test(S("abcde"), 0, 1, S("12345"), 0, 2, S("12bcde"));
+ test(S("abcde"), 0, 1, S("12345"), 0, 4, S("1234bcde"));
+ test(S("abcde"), 0, 1, S("12345"), 0, 5, S("12345bcde"));
+ test(S("abcde"), 0, 1, S("12345"), 0, 6, S("12345bcde"));
+ test(S("abcde"), 0, 1, S("12345"), 1, 0, S("bcde"));
+ test(S("abcde"), 0, 1, S("12345"), 1, 1, S("2bcde"));
+ test(S("abcde"), 0, 1, S("12345"), 1, 2, S("23bcde"));
+ test(S("abcde"), 0, 1, S("12345"), 1, 3, S("234bcde"));
+ test(S("abcde"), 0, 1, S("12345"), 1, 4, S("2345bcde"));
+ test(S("abcde"), 0, 1, S("12345"), 1, 5, S("2345bcde"));
+ test(S("abcde"), 0, 1, S("12345"), 2, 0, S("bcde"));
+ test(S("abcde"), 0, 1, S("12345"), 2, 1, S("3bcde"));
+ test(S("abcde"), 0, 1, S("12345"), 2, 2, S("34bcde"));
+ test(S("abcde"), 0, 1, S("12345"), 2, 3, S("345bcde"));
+ test(S("abcde"), 0, 1, S("12345"), 2, 4, S("345bcde"));
+ test(S("abcde"), 0, 1, S("12345"), 4, 0, S("bcde"));
+ test(S("abcde"), 0, 1, S("12345"), 4, 1, S("5bcde"));
+ test(S("abcde"), 0, 1, S("12345"), 4, 2, S("5bcde"));
+ test(S("abcde"), 0, 1, S("12345"), 5, 0, S("bcde"));
+ test(S("abcde"), 0, 1, S("12345"), 5, 1, S("bcde"));
+ test(S("abcde"), 0, 1, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcde"), 0, 1, S("1234567890"), 0, 0, S("bcde"));
+ test(S("abcde"), 0, 1, S("1234567890"), 0, 1, S("1bcde"));
+ test(S("abcde"), 0, 1, S("1234567890"), 0, 5, S("12345bcde"));
+ test(S("abcde"), 0, 1, S("1234567890"), 0, 9, S("123456789bcde"));
+ test(S("abcde"), 0, 1, S("1234567890"), 0, 10, S("1234567890bcde"));
+ test(S("abcde"), 0, 1, S("1234567890"), 0, 11, S("1234567890bcde"));
+ test(S("abcde"), 0, 1, S("1234567890"), 1, 0, S("bcde"));
+ test(S("abcde"), 0, 1, S("1234567890"), 1, 1, S("2bcde"));
+ test(S("abcde"), 0, 1, S("1234567890"), 1, 4, S("2345bcde"));
+ test(S("abcde"), 0, 1, S("1234567890"), 1, 8, S("23456789bcde"));
+ test(S("abcde"), 0, 1, S("1234567890"), 1, 9, S("234567890bcde"));
+ test(S("abcde"), 0, 1, S("1234567890"), 1, 10, S("234567890bcde"));
+ test(S("abcde"), 0, 1, S("1234567890"), 5, 0, S("bcde"));
+ test(S("abcde"), 0, 1, S("1234567890"), 5, 1, S("6bcde"));
+ test(S("abcde"), 0, 1, S("1234567890"), 5, 2, S("67bcde"));
+ test(S("abcde"), 0, 1, S("1234567890"), 5, 4, S("6789bcde"));
+ test(S("abcde"), 0, 1, S("1234567890"), 5, 5, S("67890bcde"));
+ test(S("abcde"), 0, 1, S("1234567890"), 5, 6, S("67890bcde"));
+ test(S("abcde"), 0, 1, S("1234567890"), 9, 0, S("bcde"));
+ test(S("abcde"), 0, 1, S("1234567890"), 9, 1, S("0bcde"));
+ test(S("abcde"), 0, 1, S("1234567890"), 9, 2, S("0bcde"));
+ test(S("abcde"), 0, 1, S("1234567890"), 10, 0, S("bcde"));
+ test(S("abcde"), 0, 1, S("1234567890"), 10, 1, S("bcde"));
+ test(S("abcde"), 0, 1, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcde"), 0, 1, S("12345678901234567890"), 0, 0, S("bcde"));
+ test(S("abcde"), 0, 1, S("12345678901234567890"), 0, 1, S("1bcde"));
+ test(S("abcde"), 0, 1, S("12345678901234567890"), 0, 10, S("1234567890bcde"));
+ test(S("abcde"), 0, 1, S("12345678901234567890"), 0, 19, S("1234567890123456789bcde"));
+ test(S("abcde"), 0, 1, S("12345678901234567890"), 0, 20, S("12345678901234567890bcde"));
+ test(S("abcde"), 0, 1, S("12345678901234567890"), 0, 21, S("12345678901234567890bcde"));
+ test(S("abcde"), 0, 1, S("12345678901234567890"), 1, 0, S("bcde"));
+ test(S("abcde"), 0, 1, S("12345678901234567890"), 1, 1, S("2bcde"));
+ test(S("abcde"), 0, 1, S("12345678901234567890"), 1, 9, S("234567890bcde"));
+ test(S("abcde"), 0, 1, S("12345678901234567890"), 1, 18, S("234567890123456789bcde"));
+ test(S("abcde"), 0, 1, S("12345678901234567890"), 1, 19, S("2345678901234567890bcde"));
+ test(S("abcde"), 0, 1, S("12345678901234567890"), 1, 20, S("2345678901234567890bcde"));
+ test(S("abcde"), 0, 1, S("12345678901234567890"), 10, 0, S("bcde"));
+ test(S("abcde"), 0, 1, S("12345678901234567890"), 10, 1, S("1bcde"));
+ test(S("abcde"), 0, 1, S("12345678901234567890"), 10, 5, S("12345bcde"));
+ test(S("abcde"), 0, 1, S("12345678901234567890"), 10, 9, S("123456789bcde"));
+ test(S("abcde"), 0, 1, S("12345678901234567890"), 10, 10, S("1234567890bcde"));
+ test(S("abcde"), 0, 1, S("12345678901234567890"), 10, 11, S("1234567890bcde"));
+ test(S("abcde"), 0, 1, S("12345678901234567890"), 19, 0, S("bcde"));
+ test(S("abcde"), 0, 1, S("12345678901234567890"), 19, 1, S("0bcde"));
+ test(S("abcde"), 0, 1, S("12345678901234567890"), 19, 2, S("0bcde"));
+ test(S("abcde"), 0, 1, S("12345678901234567890"), 20, 0, S("bcde"));
+ test(S("abcde"), 0, 1, S("12345678901234567890"), 20, 1, S("bcde"));
+ test(S("abcde"), 0, 1, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcde"), 0, 2, S(""), 0, 0, S("cde"));
+ test(S("abcde"), 0, 2, S(""), 0, 1, S("cde"));
+ test(S("abcde"), 0, 2, S(""), 1, 0, S("can't happen"));
+ test(S("abcde"), 0, 2, S("12345"), 0, 0, S("cde"));
+ test(S("abcde"), 0, 2, S("12345"), 0, 1, S("1cde"));
+ test(S("abcde"), 0, 2, S("12345"), 0, 2, S("12cde"));
+ test(S("abcde"), 0, 2, S("12345"), 0, 4, S("1234cde"));
+ test(S("abcde"), 0, 2, S("12345"), 0, 5, S("12345cde"));
+ test(S("abcde"), 0, 2, S("12345"), 0, 6, S("12345cde"));
+ test(S("abcde"), 0, 2, S("12345"), 1, 0, S("cde"));
+ test(S("abcde"), 0, 2, S("12345"), 1, 1, S("2cde"));
+ test(S("abcde"), 0, 2, S("12345"), 1, 2, S("23cde"));
+ test(S("abcde"), 0, 2, S("12345"), 1, 3, S("234cde"));
+ test(S("abcde"), 0, 2, S("12345"), 1, 4, S("2345cde"));
+ test(S("abcde"), 0, 2, S("12345"), 1, 5, S("2345cde"));
+ test(S("abcde"), 0, 2, S("12345"), 2, 0, S("cde"));
+ test(S("abcde"), 0, 2, S("12345"), 2, 1, S("3cde"));
+ test(S("abcde"), 0, 2, S("12345"), 2, 2, S("34cde"));
+ test(S("abcde"), 0, 2, S("12345"), 2, 3, S("345cde"));
+ test(S("abcde"), 0, 2, S("12345"), 2, 4, S("345cde"));
+ test(S("abcde"), 0, 2, S("12345"), 4, 0, S("cde"));
+ test(S("abcde"), 0, 2, S("12345"), 4, 1, S("5cde"));
+ test(S("abcde"), 0, 2, S("12345"), 4, 2, S("5cde"));
+ test(S("abcde"), 0, 2, S("12345"), 5, 0, S("cde"));
+ test(S("abcde"), 0, 2, S("12345"), 5, 1, S("cde"));
+ test(S("abcde"), 0, 2, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcde"), 0, 2, S("1234567890"), 0, 0, S("cde"));
+ test(S("abcde"), 0, 2, S("1234567890"), 0, 1, S("1cde"));
+ test(S("abcde"), 0, 2, S("1234567890"), 0, 5, S("12345cde"));
+ test(S("abcde"), 0, 2, S("1234567890"), 0, 9, S("123456789cde"));
+}
+
+template <class S>
+void test4()
+{
+ test(S("abcde"), 0, 2, S("1234567890"), 0, 10, S("1234567890cde"));
+ test(S("abcde"), 0, 2, S("1234567890"), 0, 11, S("1234567890cde"));
+ test(S("abcde"), 0, 2, S("1234567890"), 1, 0, S("cde"));
+ test(S("abcde"), 0, 2, S("1234567890"), 1, 1, S("2cde"));
+ test(S("abcde"), 0, 2, S("1234567890"), 1, 4, S("2345cde"));
+ test(S("abcde"), 0, 2, S("1234567890"), 1, 8, S("23456789cde"));
+ test(S("abcde"), 0, 2, S("1234567890"), 1, 9, S("234567890cde"));
+ test(S("abcde"), 0, 2, S("1234567890"), 1, 10, S("234567890cde"));
+ test(S("abcde"), 0, 2, S("1234567890"), 5, 0, S("cde"));
+ test(S("abcde"), 0, 2, S("1234567890"), 5, 1, S("6cde"));
+ test(S("abcde"), 0, 2, S("1234567890"), 5, 2, S("67cde"));
+ test(S("abcde"), 0, 2, S("1234567890"), 5, 4, S("6789cde"));
+ test(S("abcde"), 0, 2, S("1234567890"), 5, 5, S("67890cde"));
+ test(S("abcde"), 0, 2, S("1234567890"), 5, 6, S("67890cde"));
+ test(S("abcde"), 0, 2, S("1234567890"), 9, 0, S("cde"));
+ test(S("abcde"), 0, 2, S("1234567890"), 9, 1, S("0cde"));
+ test(S("abcde"), 0, 2, S("1234567890"), 9, 2, S("0cde"));
+ test(S("abcde"), 0, 2, S("1234567890"), 10, 0, S("cde"));
+ test(S("abcde"), 0, 2, S("1234567890"), 10, 1, S("cde"));
+ test(S("abcde"), 0, 2, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcde"), 0, 2, S("12345678901234567890"), 0, 0, S("cde"));
+ test(S("abcde"), 0, 2, S("12345678901234567890"), 0, 1, S("1cde"));
+ test(S("abcde"), 0, 2, S("12345678901234567890"), 0, 10, S("1234567890cde"));
+ test(S("abcde"), 0, 2, S("12345678901234567890"), 0, 19, S("1234567890123456789cde"));
+ test(S("abcde"), 0, 2, S("12345678901234567890"), 0, 20, S("12345678901234567890cde"));
+ test(S("abcde"), 0, 2, S("12345678901234567890"), 0, 21, S("12345678901234567890cde"));
+ test(S("abcde"), 0, 2, S("12345678901234567890"), 1, 0, S("cde"));
+ test(S("abcde"), 0, 2, S("12345678901234567890"), 1, 1, S("2cde"));
+ test(S("abcde"), 0, 2, S("12345678901234567890"), 1, 9, S("234567890cde"));
+ test(S("abcde"), 0, 2, S("12345678901234567890"), 1, 18, S("234567890123456789cde"));
+ test(S("abcde"), 0, 2, S("12345678901234567890"), 1, 19, S("2345678901234567890cde"));
+ test(S("abcde"), 0, 2, S("12345678901234567890"), 1, 20, S("2345678901234567890cde"));
+ test(S("abcde"), 0, 2, S("12345678901234567890"), 10, 0, S("cde"));
+ test(S("abcde"), 0, 2, S("12345678901234567890"), 10, 1, S("1cde"));
+ test(S("abcde"), 0, 2, S("12345678901234567890"), 10, 5, S("12345cde"));
+ test(S("abcde"), 0, 2, S("12345678901234567890"), 10, 9, S("123456789cde"));
+ test(S("abcde"), 0, 2, S("12345678901234567890"), 10, 10, S("1234567890cde"));
+ test(S("abcde"), 0, 2, S("12345678901234567890"), 10, 11, S("1234567890cde"));
+ test(S("abcde"), 0, 2, S("12345678901234567890"), 19, 0, S("cde"));
+ test(S("abcde"), 0, 2, S("12345678901234567890"), 19, 1, S("0cde"));
+ test(S("abcde"), 0, 2, S("12345678901234567890"), 19, 2, S("0cde"));
+ test(S("abcde"), 0, 2, S("12345678901234567890"), 20, 0, S("cde"));
+ test(S("abcde"), 0, 2, S("12345678901234567890"), 20, 1, S("cde"));
+ test(S("abcde"), 0, 2, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcde"), 0, 4, S(""), 0, 0, S("e"));
+ test(S("abcde"), 0, 4, S(""), 0, 1, S("e"));
+ test(S("abcde"), 0, 4, S(""), 1, 0, S("can't happen"));
+ test(S("abcde"), 0, 4, S("12345"), 0, 0, S("e"));
+ test(S("abcde"), 0, 4, S("12345"), 0, 1, S("1e"));
+ test(S("abcde"), 0, 4, S("12345"), 0, 2, S("12e"));
+ test(S("abcde"), 0, 4, S("12345"), 0, 4, S("1234e"));
+ test(S("abcde"), 0, 4, S("12345"), 0, 5, S("12345e"));
+ test(S("abcde"), 0, 4, S("12345"), 0, 6, S("12345e"));
+ test(S("abcde"), 0, 4, S("12345"), 1, 0, S("e"));
+ test(S("abcde"), 0, 4, S("12345"), 1, 1, S("2e"));
+ test(S("abcde"), 0, 4, S("12345"), 1, 2, S("23e"));
+ test(S("abcde"), 0, 4, S("12345"), 1, 3, S("234e"));
+ test(S("abcde"), 0, 4, S("12345"), 1, 4, S("2345e"));
+ test(S("abcde"), 0, 4, S("12345"), 1, 5, S("2345e"));
+ test(S("abcde"), 0, 4, S("12345"), 2, 0, S("e"));
+ test(S("abcde"), 0, 4, S("12345"), 2, 1, S("3e"));
+ test(S("abcde"), 0, 4, S("12345"), 2, 2, S("34e"));
+ test(S("abcde"), 0, 4, S("12345"), 2, 3, S("345e"));
+ test(S("abcde"), 0, 4, S("12345"), 2, 4, S("345e"));
+ test(S("abcde"), 0, 4, S("12345"), 4, 0, S("e"));
+ test(S("abcde"), 0, 4, S("12345"), 4, 1, S("5e"));
+ test(S("abcde"), 0, 4, S("12345"), 4, 2, S("5e"));
+ test(S("abcde"), 0, 4, S("12345"), 5, 0, S("e"));
+ test(S("abcde"), 0, 4, S("12345"), 5, 1, S("e"));
+ test(S("abcde"), 0, 4, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcde"), 0, 4, S("1234567890"), 0, 0, S("e"));
+ test(S("abcde"), 0, 4, S("1234567890"), 0, 1, S("1e"));
+ test(S("abcde"), 0, 4, S("1234567890"), 0, 5, S("12345e"));
+ test(S("abcde"), 0, 4, S("1234567890"), 0, 9, S("123456789e"));
+ test(S("abcde"), 0, 4, S("1234567890"), 0, 10, S("1234567890e"));
+ test(S("abcde"), 0, 4, S("1234567890"), 0, 11, S("1234567890e"));
+ test(S("abcde"), 0, 4, S("1234567890"), 1, 0, S("e"));
+ test(S("abcde"), 0, 4, S("1234567890"), 1, 1, S("2e"));
+ test(S("abcde"), 0, 4, S("1234567890"), 1, 4, S("2345e"));
+ test(S("abcde"), 0, 4, S("1234567890"), 1, 8, S("23456789e"));
+ test(S("abcde"), 0, 4, S("1234567890"), 1, 9, S("234567890e"));
+ test(S("abcde"), 0, 4, S("1234567890"), 1, 10, S("234567890e"));
+ test(S("abcde"), 0, 4, S("1234567890"), 5, 0, S("e"));
+ test(S("abcde"), 0, 4, S("1234567890"), 5, 1, S("6e"));
+ test(S("abcde"), 0, 4, S("1234567890"), 5, 2, S("67e"));
+ test(S("abcde"), 0, 4, S("1234567890"), 5, 4, S("6789e"));
+ test(S("abcde"), 0, 4, S("1234567890"), 5, 5, S("67890e"));
+ test(S("abcde"), 0, 4, S("1234567890"), 5, 6, S("67890e"));
+ test(S("abcde"), 0, 4, S("1234567890"), 9, 0, S("e"));
+ test(S("abcde"), 0, 4, S("1234567890"), 9, 1, S("0e"));
+ test(S("abcde"), 0, 4, S("1234567890"), 9, 2, S("0e"));
+ test(S("abcde"), 0, 4, S("1234567890"), 10, 0, S("e"));
+ test(S("abcde"), 0, 4, S("1234567890"), 10, 1, S("e"));
+ test(S("abcde"), 0, 4, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcde"), 0, 4, S("12345678901234567890"), 0, 0, S("e"));
+ test(S("abcde"), 0, 4, S("12345678901234567890"), 0, 1, S("1e"));
+ test(S("abcde"), 0, 4, S("12345678901234567890"), 0, 10, S("1234567890e"));
+ test(S("abcde"), 0, 4, S("12345678901234567890"), 0, 19, S("1234567890123456789e"));
+ test(S("abcde"), 0, 4, S("12345678901234567890"), 0, 20, S("12345678901234567890e"));
+ test(S("abcde"), 0, 4, S("12345678901234567890"), 0, 21, S("12345678901234567890e"));
+}
+
+template <class S>
+void test5()
+{
+ test(S("abcde"), 0, 4, S("12345678901234567890"), 1, 0, S("e"));
+ test(S("abcde"), 0, 4, S("12345678901234567890"), 1, 1, S("2e"));
+ test(S("abcde"), 0, 4, S("12345678901234567890"), 1, 9, S("234567890e"));
+ test(S("abcde"), 0, 4, S("12345678901234567890"), 1, 18, S("234567890123456789e"));
+ test(S("abcde"), 0, 4, S("12345678901234567890"), 1, 19, S("2345678901234567890e"));
+ test(S("abcde"), 0, 4, S("12345678901234567890"), 1, 20, S("2345678901234567890e"));
+ test(S("abcde"), 0, 4, S("12345678901234567890"), 10, 0, S("e"));
+ test(S("abcde"), 0, 4, S("12345678901234567890"), 10, 1, S("1e"));
+ test(S("abcde"), 0, 4, S("12345678901234567890"), 10, 5, S("12345e"));
+ test(S("abcde"), 0, 4, S("12345678901234567890"), 10, 9, S("123456789e"));
+ test(S("abcde"), 0, 4, S("12345678901234567890"), 10, 10, S("1234567890e"));
+ test(S("abcde"), 0, 4, S("12345678901234567890"), 10, 11, S("1234567890e"));
+ test(S("abcde"), 0, 4, S("12345678901234567890"), 19, 0, S("e"));
+ test(S("abcde"), 0, 4, S("12345678901234567890"), 19, 1, S("0e"));
+ test(S("abcde"), 0, 4, S("12345678901234567890"), 19, 2, S("0e"));
+ test(S("abcde"), 0, 4, S("12345678901234567890"), 20, 0, S("e"));
+ test(S("abcde"), 0, 4, S("12345678901234567890"), 20, 1, S("e"));
+ test(S("abcde"), 0, 4, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcde"), 0, 5, S(""), 0, 0, S(""));
+ test(S("abcde"), 0, 5, S(""), 0, 1, S(""));
+ test(S("abcde"), 0, 5, S(""), 1, 0, S("can't happen"));
+ test(S("abcde"), 0, 5, S("12345"), 0, 0, S(""));
+ test(S("abcde"), 0, 5, S("12345"), 0, 1, S("1"));
+ test(S("abcde"), 0, 5, S("12345"), 0, 2, S("12"));
+ test(S("abcde"), 0, 5, S("12345"), 0, 4, S("1234"));
+ test(S("abcde"), 0, 5, S("12345"), 0, 5, S("12345"));
+ test(S("abcde"), 0, 5, S("12345"), 0, 6, S("12345"));
+ test(S("abcde"), 0, 5, S("12345"), 1, 0, S(""));
+ test(S("abcde"), 0, 5, S("12345"), 1, 1, S("2"));
+ test(S("abcde"), 0, 5, S("12345"), 1, 2, S("23"));
+ test(S("abcde"), 0, 5, S("12345"), 1, 3, S("234"));
+ test(S("abcde"), 0, 5, S("12345"), 1, 4, S("2345"));
+ test(S("abcde"), 0, 5, S("12345"), 1, 5, S("2345"));
+ test(S("abcde"), 0, 5, S("12345"), 2, 0, S(""));
+ test(S("abcde"), 0, 5, S("12345"), 2, 1, S("3"));
+ test(S("abcde"), 0, 5, S("12345"), 2, 2, S("34"));
+ test(S("abcde"), 0, 5, S("12345"), 2, 3, S("345"));
+ test(S("abcde"), 0, 5, S("12345"), 2, 4, S("345"));
+ test(S("abcde"), 0, 5, S("12345"), 4, 0, S(""));
+ test(S("abcde"), 0, 5, S("12345"), 4, 1, S("5"));
+ test(S("abcde"), 0, 5, S("12345"), 4, 2, S("5"));
+ test(S("abcde"), 0, 5, S("12345"), 5, 0, S(""));
+ test(S("abcde"), 0, 5, S("12345"), 5, 1, S(""));
+ test(S("abcde"), 0, 5, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcde"), 0, 5, S("1234567890"), 0, 0, S(""));
+ test(S("abcde"), 0, 5, S("1234567890"), 0, 1, S("1"));
+ test(S("abcde"), 0, 5, S("1234567890"), 0, 5, S("12345"));
+ test(S("abcde"), 0, 5, S("1234567890"), 0, 9, S("123456789"));
+ test(S("abcde"), 0, 5, S("1234567890"), 0, 10, S("1234567890"));
+ test(S("abcde"), 0, 5, S("1234567890"), 0, 11, S("1234567890"));
+ test(S("abcde"), 0, 5, S("1234567890"), 1, 0, S(""));
+ test(S("abcde"), 0, 5, S("1234567890"), 1, 1, S("2"));
+ test(S("abcde"), 0, 5, S("1234567890"), 1, 4, S("2345"));
+ test(S("abcde"), 0, 5, S("1234567890"), 1, 8, S("23456789"));
+ test(S("abcde"), 0, 5, S("1234567890"), 1, 9, S("234567890"));
+ test(S("abcde"), 0, 5, S("1234567890"), 1, 10, S("234567890"));
+ test(S("abcde"), 0, 5, S("1234567890"), 5, 0, S(""));
+ test(S("abcde"), 0, 5, S("1234567890"), 5, 1, S("6"));
+ test(S("abcde"), 0, 5, S("1234567890"), 5, 2, S("67"));
+ test(S("abcde"), 0, 5, S("1234567890"), 5, 4, S("6789"));
+ test(S("abcde"), 0, 5, S("1234567890"), 5, 5, S("67890"));
+ test(S("abcde"), 0, 5, S("1234567890"), 5, 6, S("67890"));
+ test(S("abcde"), 0, 5, S("1234567890"), 9, 0, S(""));
+ test(S("abcde"), 0, 5, S("1234567890"), 9, 1, S("0"));
+ test(S("abcde"), 0, 5, S("1234567890"), 9, 2, S("0"));
+ test(S("abcde"), 0, 5, S("1234567890"), 10, 0, S(""));
+ test(S("abcde"), 0, 5, S("1234567890"), 10, 1, S(""));
+ test(S("abcde"), 0, 5, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcde"), 0, 5, S("12345678901234567890"), 0, 0, S(""));
+ test(S("abcde"), 0, 5, S("12345678901234567890"), 0, 1, S("1"));
+ test(S("abcde"), 0, 5, S("12345678901234567890"), 0, 10, S("1234567890"));
+ test(S("abcde"), 0, 5, S("12345678901234567890"), 0, 19, S("1234567890123456789"));
+ test(S("abcde"), 0, 5, S("12345678901234567890"), 0, 20, S("12345678901234567890"));
+ test(S("abcde"), 0, 5, S("12345678901234567890"), 0, 21, S("12345678901234567890"));
+ test(S("abcde"), 0, 5, S("12345678901234567890"), 1, 0, S(""));
+ test(S("abcde"), 0, 5, S("12345678901234567890"), 1, 1, S("2"));
+ test(S("abcde"), 0, 5, S("12345678901234567890"), 1, 9, S("234567890"));
+ test(S("abcde"), 0, 5, S("12345678901234567890"), 1, 18, S("234567890123456789"));
+ test(S("abcde"), 0, 5, S("12345678901234567890"), 1, 19, S("2345678901234567890"));
+ test(S("abcde"), 0, 5, S("12345678901234567890"), 1, 20, S("2345678901234567890"));
+ test(S("abcde"), 0, 5, S("12345678901234567890"), 10, 0, S(""));
+ test(S("abcde"), 0, 5, S("12345678901234567890"), 10, 1, S("1"));
+ test(S("abcde"), 0, 5, S("12345678901234567890"), 10, 5, S("12345"));
+ test(S("abcde"), 0, 5, S("12345678901234567890"), 10, 9, S("123456789"));
+ test(S("abcde"), 0, 5, S("12345678901234567890"), 10, 10, S("1234567890"));
+ test(S("abcde"), 0, 5, S("12345678901234567890"), 10, 11, S("1234567890"));
+ test(S("abcde"), 0, 5, S("12345678901234567890"), 19, 0, S(""));
+ test(S("abcde"), 0, 5, S("12345678901234567890"), 19, 1, S("0"));
+ test(S("abcde"), 0, 5, S("12345678901234567890"), 19, 2, S("0"));
+ test(S("abcde"), 0, 5, S("12345678901234567890"), 20, 0, S(""));
+ test(S("abcde"), 0, 5, S("12345678901234567890"), 20, 1, S(""));
+ test(S("abcde"), 0, 5, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcde"), 0, 6, S(""), 0, 0, S(""));
+ test(S("abcde"), 0, 6, S(""), 0, 1, S(""));
+ test(S("abcde"), 0, 6, S(""), 1, 0, S("can't happen"));
+ test(S("abcde"), 0, 6, S("12345"), 0, 0, S(""));
+ test(S("abcde"), 0, 6, S("12345"), 0, 1, S("1"));
+ test(S("abcde"), 0, 6, S("12345"), 0, 2, S("12"));
+ test(S("abcde"), 0, 6, S("12345"), 0, 4, S("1234"));
+ test(S("abcde"), 0, 6, S("12345"), 0, 5, S("12345"));
+}
+
+template <class S>
+void test6()
+{
+ test(S("abcde"), 0, 6, S("12345"), 0, 6, S("12345"));
+ test(S("abcde"), 0, 6, S("12345"), 1, 0, S(""));
+ test(S("abcde"), 0, 6, S("12345"), 1, 1, S("2"));
+ test(S("abcde"), 0, 6, S("12345"), 1, 2, S("23"));
+ test(S("abcde"), 0, 6, S("12345"), 1, 3, S("234"));
+ test(S("abcde"), 0, 6, S("12345"), 1, 4, S("2345"));
+ test(S("abcde"), 0, 6, S("12345"), 1, 5, S("2345"));
+ test(S("abcde"), 0, 6, S("12345"), 2, 0, S(""));
+ test(S("abcde"), 0, 6, S("12345"), 2, 1, S("3"));
+ test(S("abcde"), 0, 6, S("12345"), 2, 2, S("34"));
+ test(S("abcde"), 0, 6, S("12345"), 2, 3, S("345"));
+ test(S("abcde"), 0, 6, S("12345"), 2, 4, S("345"));
+ test(S("abcde"), 0, 6, S("12345"), 4, 0, S(""));
+ test(S("abcde"), 0, 6, S("12345"), 4, 1, S("5"));
+ test(S("abcde"), 0, 6, S("12345"), 4, 2, S("5"));
+ test(S("abcde"), 0, 6, S("12345"), 5, 0, S(""));
+ test(S("abcde"), 0, 6, S("12345"), 5, 1, S(""));
+ test(S("abcde"), 0, 6, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcde"), 0, 6, S("1234567890"), 0, 0, S(""));
+ test(S("abcde"), 0, 6, S("1234567890"), 0, 1, S("1"));
+ test(S("abcde"), 0, 6, S("1234567890"), 0, 5, S("12345"));
+ test(S("abcde"), 0, 6, S("1234567890"), 0, 9, S("123456789"));
+ test(S("abcde"), 0, 6, S("1234567890"), 0, 10, S("1234567890"));
+ test(S("abcde"), 0, 6, S("1234567890"), 0, 11, S("1234567890"));
+ test(S("abcde"), 0, 6, S("1234567890"), 1, 0, S(""));
+ test(S("abcde"), 0, 6, S("1234567890"), 1, 1, S("2"));
+ test(S("abcde"), 0, 6, S("1234567890"), 1, 4, S("2345"));
+ test(S("abcde"), 0, 6, S("1234567890"), 1, 8, S("23456789"));
+ test(S("abcde"), 0, 6, S("1234567890"), 1, 9, S("234567890"));
+ test(S("abcde"), 0, 6, S("1234567890"), 1, 10, S("234567890"));
+ test(S("abcde"), 0, 6, S("1234567890"), 5, 0, S(""));
+ test(S("abcde"), 0, 6, S("1234567890"), 5, 1, S("6"));
+ test(S("abcde"), 0, 6, S("1234567890"), 5, 2, S("67"));
+ test(S("abcde"), 0, 6, S("1234567890"), 5, 4, S("6789"));
+ test(S("abcde"), 0, 6, S("1234567890"), 5, 5, S("67890"));
+ test(S("abcde"), 0, 6, S("1234567890"), 5, 6, S("67890"));
+ test(S("abcde"), 0, 6, S("1234567890"), 9, 0, S(""));
+ test(S("abcde"), 0, 6, S("1234567890"), 9, 1, S("0"));
+ test(S("abcde"), 0, 6, S("1234567890"), 9, 2, S("0"));
+ test(S("abcde"), 0, 6, S("1234567890"), 10, 0, S(""));
+ test(S("abcde"), 0, 6, S("1234567890"), 10, 1, S(""));
+ test(S("abcde"), 0, 6, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcde"), 0, 6, S("12345678901234567890"), 0, 0, S(""));
+ test(S("abcde"), 0, 6, S("12345678901234567890"), 0, 1, S("1"));
+ test(S("abcde"), 0, 6, S("12345678901234567890"), 0, 10, S("1234567890"));
+ test(S("abcde"), 0, 6, S("12345678901234567890"), 0, 19, S("1234567890123456789"));
+ test(S("abcde"), 0, 6, S("12345678901234567890"), 0, 20, S("12345678901234567890"));
+ test(S("abcde"), 0, 6, S("12345678901234567890"), 0, 21, S("12345678901234567890"));
+ test(S("abcde"), 0, 6, S("12345678901234567890"), 1, 0, S(""));
+ test(S("abcde"), 0, 6, S("12345678901234567890"), 1, 1, S("2"));
+ test(S("abcde"), 0, 6, S("12345678901234567890"), 1, 9, S("234567890"));
+ test(S("abcde"), 0, 6, S("12345678901234567890"), 1, 18, S("234567890123456789"));
+ test(S("abcde"), 0, 6, S("12345678901234567890"), 1, 19, S("2345678901234567890"));
+ test(S("abcde"), 0, 6, S("12345678901234567890"), 1, 20, S("2345678901234567890"));
+ test(S("abcde"), 0, 6, S("12345678901234567890"), 10, 0, S(""));
+ test(S("abcde"), 0, 6, S("12345678901234567890"), 10, 1, S("1"));
+ test(S("abcde"), 0, 6, S("12345678901234567890"), 10, 5, S("12345"));
+ test(S("abcde"), 0, 6, S("12345678901234567890"), 10, 9, S("123456789"));
+ test(S("abcde"), 0, 6, S("12345678901234567890"), 10, 10, S("1234567890"));
+ test(S("abcde"), 0, 6, S("12345678901234567890"), 10, 11, S("1234567890"));
+ test(S("abcde"), 0, 6, S("12345678901234567890"), 19, 0, S(""));
+ test(S("abcde"), 0, 6, S("12345678901234567890"), 19, 1, S("0"));
+ test(S("abcde"), 0, 6, S("12345678901234567890"), 19, 2, S("0"));
+ test(S("abcde"), 0, 6, S("12345678901234567890"), 20, 0, S(""));
+ test(S("abcde"), 0, 6, S("12345678901234567890"), 20, 1, S(""));
+ test(S("abcde"), 0, 6, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcde"), 1, 0, S(""), 0, 0, S("abcde"));
+ test(S("abcde"), 1, 0, S(""), 0, 1, S("abcde"));
+ test(S("abcde"), 1, 0, S(""), 1, 0, S("can't happen"));
+ test(S("abcde"), 1, 0, S("12345"), 0, 0, S("abcde"));
+ test(S("abcde"), 1, 0, S("12345"), 0, 1, S("a1bcde"));
+ test(S("abcde"), 1, 0, S("12345"), 0, 2, S("a12bcde"));
+ test(S("abcde"), 1, 0, S("12345"), 0, 4, S("a1234bcde"));
+ test(S("abcde"), 1, 0, S("12345"), 0, 5, S("a12345bcde"));
+ test(S("abcde"), 1, 0, S("12345"), 0, 6, S("a12345bcde"));
+ test(S("abcde"), 1, 0, S("12345"), 1, 0, S("abcde"));
+ test(S("abcde"), 1, 0, S("12345"), 1, 1, S("a2bcde"));
+ test(S("abcde"), 1, 0, S("12345"), 1, 2, S("a23bcde"));
+ test(S("abcde"), 1, 0, S("12345"), 1, 3, S("a234bcde"));
+ test(S("abcde"), 1, 0, S("12345"), 1, 4, S("a2345bcde"));
+ test(S("abcde"), 1, 0, S("12345"), 1, 5, S("a2345bcde"));
+ test(S("abcde"), 1, 0, S("12345"), 2, 0, S("abcde"));
+ test(S("abcde"), 1, 0, S("12345"), 2, 1, S("a3bcde"));
+ test(S("abcde"), 1, 0, S("12345"), 2, 2, S("a34bcde"));
+ test(S("abcde"), 1, 0, S("12345"), 2, 3, S("a345bcde"));
+ test(S("abcde"), 1, 0, S("12345"), 2, 4, S("a345bcde"));
+ test(S("abcde"), 1, 0, S("12345"), 4, 0, S("abcde"));
+ test(S("abcde"), 1, 0, S("12345"), 4, 1, S("a5bcde"));
+ test(S("abcde"), 1, 0, S("12345"), 4, 2, S("a5bcde"));
+ test(S("abcde"), 1, 0, S("12345"), 5, 0, S("abcde"));
+ test(S("abcde"), 1, 0, S("12345"), 5, 1, S("abcde"));
+ test(S("abcde"), 1, 0, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcde"), 1, 0, S("1234567890"), 0, 0, S("abcde"));
+ test(S("abcde"), 1, 0, S("1234567890"), 0, 1, S("a1bcde"));
+ test(S("abcde"), 1, 0, S("1234567890"), 0, 5, S("a12345bcde"));
+ test(S("abcde"), 1, 0, S("1234567890"), 0, 9, S("a123456789bcde"));
+ test(S("abcde"), 1, 0, S("1234567890"), 0, 10, S("a1234567890bcde"));
+ test(S("abcde"), 1, 0, S("1234567890"), 0, 11, S("a1234567890bcde"));
+ test(S("abcde"), 1, 0, S("1234567890"), 1, 0, S("abcde"));
+ test(S("abcde"), 1, 0, S("1234567890"), 1, 1, S("a2bcde"));
+}
+
+template <class S>
+void test7()
+{
+ test(S("abcde"), 1, 0, S("1234567890"), 1, 4, S("a2345bcde"));
+ test(S("abcde"), 1, 0, S("1234567890"), 1, 8, S("a23456789bcde"));
+ test(S("abcde"), 1, 0, S("1234567890"), 1, 9, S("a234567890bcde"));
+ test(S("abcde"), 1, 0, S("1234567890"), 1, 10, S("a234567890bcde"));
+ test(S("abcde"), 1, 0, S("1234567890"), 5, 0, S("abcde"));
+ test(S("abcde"), 1, 0, S("1234567890"), 5, 1, S("a6bcde"));
+ test(S("abcde"), 1, 0, S("1234567890"), 5, 2, S("a67bcde"));
+ test(S("abcde"), 1, 0, S("1234567890"), 5, 4, S("a6789bcde"));
+ test(S("abcde"), 1, 0, S("1234567890"), 5, 5, S("a67890bcde"));
+ test(S("abcde"), 1, 0, S("1234567890"), 5, 6, S("a67890bcde"));
+ test(S("abcde"), 1, 0, S("1234567890"), 9, 0, S("abcde"));
+ test(S("abcde"), 1, 0, S("1234567890"), 9, 1, S("a0bcde"));
+ test(S("abcde"), 1, 0, S("1234567890"), 9, 2, S("a0bcde"));
+ test(S("abcde"), 1, 0, S("1234567890"), 10, 0, S("abcde"));
+ test(S("abcde"), 1, 0, S("1234567890"), 10, 1, S("abcde"));
+ test(S("abcde"), 1, 0, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcde"), 1, 0, S("12345678901234567890"), 0, 0, S("abcde"));
+ test(S("abcde"), 1, 0, S("12345678901234567890"), 0, 1, S("a1bcde"));
+ test(S("abcde"), 1, 0, S("12345678901234567890"), 0, 10, S("a1234567890bcde"));
+ test(S("abcde"), 1, 0, S("12345678901234567890"), 0, 19, S("a1234567890123456789bcde"));
+ test(S("abcde"), 1, 0, S("12345678901234567890"), 0, 20, S("a12345678901234567890bcde"));
+ test(S("abcde"), 1, 0, S("12345678901234567890"), 0, 21, S("a12345678901234567890bcde"));
+ test(S("abcde"), 1, 0, S("12345678901234567890"), 1, 0, S("abcde"));
+ test(S("abcde"), 1, 0, S("12345678901234567890"), 1, 1, S("a2bcde"));
+ test(S("abcde"), 1, 0, S("12345678901234567890"), 1, 9, S("a234567890bcde"));
+ test(S("abcde"), 1, 0, S("12345678901234567890"), 1, 18, S("a234567890123456789bcde"));
+ test(S("abcde"), 1, 0, S("12345678901234567890"), 1, 19, S("a2345678901234567890bcde"));
+ test(S("abcde"), 1, 0, S("12345678901234567890"), 1, 20, S("a2345678901234567890bcde"));
+ test(S("abcde"), 1, 0, S("12345678901234567890"), 10, 0, S("abcde"));
+ test(S("abcde"), 1, 0, S("12345678901234567890"), 10, 1, S("a1bcde"));
+ test(S("abcde"), 1, 0, S("12345678901234567890"), 10, 5, S("a12345bcde"));
+ test(S("abcde"), 1, 0, S("12345678901234567890"), 10, 9, S("a123456789bcde"));
+ test(S("abcde"), 1, 0, S("12345678901234567890"), 10, 10, S("a1234567890bcde"));
+ test(S("abcde"), 1, 0, S("12345678901234567890"), 10, 11, S("a1234567890bcde"));
+ test(S("abcde"), 1, 0, S("12345678901234567890"), 19, 0, S("abcde"));
+ test(S("abcde"), 1, 0, S("12345678901234567890"), 19, 1, S("a0bcde"));
+ test(S("abcde"), 1, 0, S("12345678901234567890"), 19, 2, S("a0bcde"));
+ test(S("abcde"), 1, 0, S("12345678901234567890"), 20, 0, S("abcde"));
+ test(S("abcde"), 1, 0, S("12345678901234567890"), 20, 1, S("abcde"));
+ test(S("abcde"), 1, 0, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcde"), 1, 1, S(""), 0, 0, S("acde"));
+ test(S("abcde"), 1, 1, S(""), 0, 1, S("acde"));
+ test(S("abcde"), 1, 1, S(""), 1, 0, S("can't happen"));
+ test(S("abcde"), 1, 1, S("12345"), 0, 0, S("acde"));
+ test(S("abcde"), 1, 1, S("12345"), 0, 1, S("a1cde"));
+ test(S("abcde"), 1, 1, S("12345"), 0, 2, S("a12cde"));
+ test(S("abcde"), 1, 1, S("12345"), 0, 4, S("a1234cde"));
+ test(S("abcde"), 1, 1, S("12345"), 0, 5, S("a12345cde"));
+ test(S("abcde"), 1, 1, S("12345"), 0, 6, S("a12345cde"));
+ test(S("abcde"), 1, 1, S("12345"), 1, 0, S("acde"));
+ test(S("abcde"), 1, 1, S("12345"), 1, 1, S("a2cde"));
+ test(S("abcde"), 1, 1, S("12345"), 1, 2, S("a23cde"));
+ test(S("abcde"), 1, 1, S("12345"), 1, 3, S("a234cde"));
+ test(S("abcde"), 1, 1, S("12345"), 1, 4, S("a2345cde"));
+ test(S("abcde"), 1, 1, S("12345"), 1, 5, S("a2345cde"));
+ test(S("abcde"), 1, 1, S("12345"), 2, 0, S("acde"));
+ test(S("abcde"), 1, 1, S("12345"), 2, 1, S("a3cde"));
+ test(S("abcde"), 1, 1, S("12345"), 2, 2, S("a34cde"));
+ test(S("abcde"), 1, 1, S("12345"), 2, 3, S("a345cde"));
+ test(S("abcde"), 1, 1, S("12345"), 2, 4, S("a345cde"));
+ test(S("abcde"), 1, 1, S("12345"), 4, 0, S("acde"));
+ test(S("abcde"), 1, 1, S("12345"), 4, 1, S("a5cde"));
+ test(S("abcde"), 1, 1, S("12345"), 4, 2, S("a5cde"));
+ test(S("abcde"), 1, 1, S("12345"), 5, 0, S("acde"));
+ test(S("abcde"), 1, 1, S("12345"), 5, 1, S("acde"));
+ test(S("abcde"), 1, 1, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcde"), 1, 1, S("1234567890"), 0, 0, S("acde"));
+ test(S("abcde"), 1, 1, S("1234567890"), 0, 1, S("a1cde"));
+ test(S("abcde"), 1, 1, S("1234567890"), 0, 5, S("a12345cde"));
+ test(S("abcde"), 1, 1, S("1234567890"), 0, 9, S("a123456789cde"));
+ test(S("abcde"), 1, 1, S("1234567890"), 0, 10, S("a1234567890cde"));
+ test(S("abcde"), 1, 1, S("1234567890"), 0, 11, S("a1234567890cde"));
+ test(S("abcde"), 1, 1, S("1234567890"), 1, 0, S("acde"));
+ test(S("abcde"), 1, 1, S("1234567890"), 1, 1, S("a2cde"));
+ test(S("abcde"), 1, 1, S("1234567890"), 1, 4, S("a2345cde"));
+ test(S("abcde"), 1, 1, S("1234567890"), 1, 8, S("a23456789cde"));
+ test(S("abcde"), 1, 1, S("1234567890"), 1, 9, S("a234567890cde"));
+ test(S("abcde"), 1, 1, S("1234567890"), 1, 10, S("a234567890cde"));
+ test(S("abcde"), 1, 1, S("1234567890"), 5, 0, S("acde"));
+ test(S("abcde"), 1, 1, S("1234567890"), 5, 1, S("a6cde"));
+ test(S("abcde"), 1, 1, S("1234567890"), 5, 2, S("a67cde"));
+ test(S("abcde"), 1, 1, S("1234567890"), 5, 4, S("a6789cde"));
+ test(S("abcde"), 1, 1, S("1234567890"), 5, 5, S("a67890cde"));
+ test(S("abcde"), 1, 1, S("1234567890"), 5, 6, S("a67890cde"));
+ test(S("abcde"), 1, 1, S("1234567890"), 9, 0, S("acde"));
+ test(S("abcde"), 1, 1, S("1234567890"), 9, 1, S("a0cde"));
+ test(S("abcde"), 1, 1, S("1234567890"), 9, 2, S("a0cde"));
+ test(S("abcde"), 1, 1, S("1234567890"), 10, 0, S("acde"));
+ test(S("abcde"), 1, 1, S("1234567890"), 10, 1, S("acde"));
+ test(S("abcde"), 1, 1, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcde"), 1, 1, S("12345678901234567890"), 0, 0, S("acde"));
+ test(S("abcde"), 1, 1, S("12345678901234567890"), 0, 1, S("a1cde"));
+ test(S("abcde"), 1, 1, S("12345678901234567890"), 0, 10, S("a1234567890cde"));
+ test(S("abcde"), 1, 1, S("12345678901234567890"), 0, 19, S("a1234567890123456789cde"));
+ test(S("abcde"), 1, 1, S("12345678901234567890"), 0, 20, S("a12345678901234567890cde"));
+ test(S("abcde"), 1, 1, S("12345678901234567890"), 0, 21, S("a12345678901234567890cde"));
+ test(S("abcde"), 1, 1, S("12345678901234567890"), 1, 0, S("acde"));
+ test(S("abcde"), 1, 1, S("12345678901234567890"), 1, 1, S("a2cde"));
+ test(S("abcde"), 1, 1, S("12345678901234567890"), 1, 9, S("a234567890cde"));
+ test(S("abcde"), 1, 1, S("12345678901234567890"), 1, 18, S("a234567890123456789cde"));
+}
+
+template <class S>
+void test8()
+{
+ test(S("abcde"), 1, 1, S("12345678901234567890"), 1, 19, S("a2345678901234567890cde"));
+ test(S("abcde"), 1, 1, S("12345678901234567890"), 1, 20, S("a2345678901234567890cde"));
+ test(S("abcde"), 1, 1, S("12345678901234567890"), 10, 0, S("acde"));
+ test(S("abcde"), 1, 1, S("12345678901234567890"), 10, 1, S("a1cde"));
+ test(S("abcde"), 1, 1, S("12345678901234567890"), 10, 5, S("a12345cde"));
+ test(S("abcde"), 1, 1, S("12345678901234567890"), 10, 9, S("a123456789cde"));
+ test(S("abcde"), 1, 1, S("12345678901234567890"), 10, 10, S("a1234567890cde"));
+ test(S("abcde"), 1, 1, S("12345678901234567890"), 10, 11, S("a1234567890cde"));
+ test(S("abcde"), 1, 1, S("12345678901234567890"), 19, 0, S("acde"));
+ test(S("abcde"), 1, 1, S("12345678901234567890"), 19, 1, S("a0cde"));
+ test(S("abcde"), 1, 1, S("12345678901234567890"), 19, 2, S("a0cde"));
+ test(S("abcde"), 1, 1, S("12345678901234567890"), 20, 0, S("acde"));
+ test(S("abcde"), 1, 1, S("12345678901234567890"), 20, 1, S("acde"));
+ test(S("abcde"), 1, 1, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcde"), 1, 2, S(""), 0, 0, S("ade"));
+ test(S("abcde"), 1, 2, S(""), 0, 1, S("ade"));
+ test(S("abcde"), 1, 2, S(""), 1, 0, S("can't happen"));
+ test(S("abcde"), 1, 2, S("12345"), 0, 0, S("ade"));
+ test(S("abcde"), 1, 2, S("12345"), 0, 1, S("a1de"));
+ test(S("abcde"), 1, 2, S("12345"), 0, 2, S("a12de"));
+ test(S("abcde"), 1, 2, S("12345"), 0, 4, S("a1234de"));
+ test(S("abcde"), 1, 2, S("12345"), 0, 5, S("a12345de"));
+ test(S("abcde"), 1, 2, S("12345"), 0, 6, S("a12345de"));
+ test(S("abcde"), 1, 2, S("12345"), 1, 0, S("ade"));
+ test(S("abcde"), 1, 2, S("12345"), 1, 1, S("a2de"));
+ test(S("abcde"), 1, 2, S("12345"), 1, 2, S("a23de"));
+ test(S("abcde"), 1, 2, S("12345"), 1, 3, S("a234de"));
+ test(S("abcde"), 1, 2, S("12345"), 1, 4, S("a2345de"));
+ test(S("abcde"), 1, 2, S("12345"), 1, 5, S("a2345de"));
+ test(S("abcde"), 1, 2, S("12345"), 2, 0, S("ade"));
+ test(S("abcde"), 1, 2, S("12345"), 2, 1, S("a3de"));
+ test(S("abcde"), 1, 2, S("12345"), 2, 2, S("a34de"));
+ test(S("abcde"), 1, 2, S("12345"), 2, 3, S("a345de"));
+ test(S("abcde"), 1, 2, S("12345"), 2, 4, S("a345de"));
+ test(S("abcde"), 1, 2, S("12345"), 4, 0, S("ade"));
+ test(S("abcde"), 1, 2, S("12345"), 4, 1, S("a5de"));
+ test(S("abcde"), 1, 2, S("12345"), 4, 2, S("a5de"));
+ test(S("abcde"), 1, 2, S("12345"), 5, 0, S("ade"));
+ test(S("abcde"), 1, 2, S("12345"), 5, 1, S("ade"));
+ test(S("abcde"), 1, 2, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcde"), 1, 2, S("1234567890"), 0, 0, S("ade"));
+ test(S("abcde"), 1, 2, S("1234567890"), 0, 1, S("a1de"));
+ test(S("abcde"), 1, 2, S("1234567890"), 0, 5, S("a12345de"));
+ test(S("abcde"), 1, 2, S("1234567890"), 0, 9, S("a123456789de"));
+ test(S("abcde"), 1, 2, S("1234567890"), 0, 10, S("a1234567890de"));
+ test(S("abcde"), 1, 2, S("1234567890"), 0, 11, S("a1234567890de"));
+ test(S("abcde"), 1, 2, S("1234567890"), 1, 0, S("ade"));
+ test(S("abcde"), 1, 2, S("1234567890"), 1, 1, S("a2de"));
+ test(S("abcde"), 1, 2, S("1234567890"), 1, 4, S("a2345de"));
+ test(S("abcde"), 1, 2, S("1234567890"), 1, 8, S("a23456789de"));
+ test(S("abcde"), 1, 2, S("1234567890"), 1, 9, S("a234567890de"));
+ test(S("abcde"), 1, 2, S("1234567890"), 1, 10, S("a234567890de"));
+ test(S("abcde"), 1, 2, S("1234567890"), 5, 0, S("ade"));
+ test(S("abcde"), 1, 2, S("1234567890"), 5, 1, S("a6de"));
+ test(S("abcde"), 1, 2, S("1234567890"), 5, 2, S("a67de"));
+ test(S("abcde"), 1, 2, S("1234567890"), 5, 4, S("a6789de"));
+ test(S("abcde"), 1, 2, S("1234567890"), 5, 5, S("a67890de"));
+ test(S("abcde"), 1, 2, S("1234567890"), 5, 6, S("a67890de"));
+ test(S("abcde"), 1, 2, S("1234567890"), 9, 0, S("ade"));
+ test(S("abcde"), 1, 2, S("1234567890"), 9, 1, S("a0de"));
+ test(S("abcde"), 1, 2, S("1234567890"), 9, 2, S("a0de"));
+ test(S("abcde"), 1, 2, S("1234567890"), 10, 0, S("ade"));
+ test(S("abcde"), 1, 2, S("1234567890"), 10, 1, S("ade"));
+ test(S("abcde"), 1, 2, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcde"), 1, 2, S("12345678901234567890"), 0, 0, S("ade"));
+ test(S("abcde"), 1, 2, S("12345678901234567890"), 0, 1, S("a1de"));
+ test(S("abcde"), 1, 2, S("12345678901234567890"), 0, 10, S("a1234567890de"));
+ test(S("abcde"), 1, 2, S("12345678901234567890"), 0, 19, S("a1234567890123456789de"));
+ test(S("abcde"), 1, 2, S("12345678901234567890"), 0, 20, S("a12345678901234567890de"));
+ test(S("abcde"), 1, 2, S("12345678901234567890"), 0, 21, S("a12345678901234567890de"));
+ test(S("abcde"), 1, 2, S("12345678901234567890"), 1, 0, S("ade"));
+ test(S("abcde"), 1, 2, S("12345678901234567890"), 1, 1, S("a2de"));
+ test(S("abcde"), 1, 2, S("12345678901234567890"), 1, 9, S("a234567890de"));
+ test(S("abcde"), 1, 2, S("12345678901234567890"), 1, 18, S("a234567890123456789de"));
+ test(S("abcde"), 1, 2, S("12345678901234567890"), 1, 19, S("a2345678901234567890de"));
+ test(S("abcde"), 1, 2, S("12345678901234567890"), 1, 20, S("a2345678901234567890de"));
+ test(S("abcde"), 1, 2, S("12345678901234567890"), 10, 0, S("ade"));
+ test(S("abcde"), 1, 2, S("12345678901234567890"), 10, 1, S("a1de"));
+ test(S("abcde"), 1, 2, S("12345678901234567890"), 10, 5, S("a12345de"));
+ test(S("abcde"), 1, 2, S("12345678901234567890"), 10, 9, S("a123456789de"));
+ test(S("abcde"), 1, 2, S("12345678901234567890"), 10, 10, S("a1234567890de"));
+ test(S("abcde"), 1, 2, S("12345678901234567890"), 10, 11, S("a1234567890de"));
+ test(S("abcde"), 1, 2, S("12345678901234567890"), 19, 0, S("ade"));
+ test(S("abcde"), 1, 2, S("12345678901234567890"), 19, 1, S("a0de"));
+ test(S("abcde"), 1, 2, S("12345678901234567890"), 19, 2, S("a0de"));
+ test(S("abcde"), 1, 2, S("12345678901234567890"), 20, 0, S("ade"));
+ test(S("abcde"), 1, 2, S("12345678901234567890"), 20, 1, S("ade"));
+ test(S("abcde"), 1, 2, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcde"), 1, 3, S(""), 0, 0, S("ae"));
+ test(S("abcde"), 1, 3, S(""), 0, 1, S("ae"));
+ test(S("abcde"), 1, 3, S(""), 1, 0, S("can't happen"));
+ test(S("abcde"), 1, 3, S("12345"), 0, 0, S("ae"));
+ test(S("abcde"), 1, 3, S("12345"), 0, 1, S("a1e"));
+ test(S("abcde"), 1, 3, S("12345"), 0, 2, S("a12e"));
+ test(S("abcde"), 1, 3, S("12345"), 0, 4, S("a1234e"));
+ test(S("abcde"), 1, 3, S("12345"), 0, 5, S("a12345e"));
+ test(S("abcde"), 1, 3, S("12345"), 0, 6, S("a12345e"));
+ test(S("abcde"), 1, 3, S("12345"), 1, 0, S("ae"));
+ test(S("abcde"), 1, 3, S("12345"), 1, 1, S("a2e"));
+ test(S("abcde"), 1, 3, S("12345"), 1, 2, S("a23e"));
+}
+
+template <class S>
+void test9()
+{
+ test(S("abcde"), 1, 3, S("12345"), 1, 3, S("a234e"));
+ test(S("abcde"), 1, 3, S("12345"), 1, 4, S("a2345e"));
+ test(S("abcde"), 1, 3, S("12345"), 1, 5, S("a2345e"));
+ test(S("abcde"), 1, 3, S("12345"), 2, 0, S("ae"));
+ test(S("abcde"), 1, 3, S("12345"), 2, 1, S("a3e"));
+ test(S("abcde"), 1, 3, S("12345"), 2, 2, S("a34e"));
+ test(S("abcde"), 1, 3, S("12345"), 2, 3, S("a345e"));
+ test(S("abcde"), 1, 3, S("12345"), 2, 4, S("a345e"));
+ test(S("abcde"), 1, 3, S("12345"), 4, 0, S("ae"));
+ test(S("abcde"), 1, 3, S("12345"), 4, 1, S("a5e"));
+ test(S("abcde"), 1, 3, S("12345"), 4, 2, S("a5e"));
+ test(S("abcde"), 1, 3, S("12345"), 5, 0, S("ae"));
+ test(S("abcde"), 1, 3, S("12345"), 5, 1, S("ae"));
+ test(S("abcde"), 1, 3, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcde"), 1, 3, S("1234567890"), 0, 0, S("ae"));
+ test(S("abcde"), 1, 3, S("1234567890"), 0, 1, S("a1e"));
+ test(S("abcde"), 1, 3, S("1234567890"), 0, 5, S("a12345e"));
+ test(S("abcde"), 1, 3, S("1234567890"), 0, 9, S("a123456789e"));
+ test(S("abcde"), 1, 3, S("1234567890"), 0, 10, S("a1234567890e"));
+ test(S("abcde"), 1, 3, S("1234567890"), 0, 11, S("a1234567890e"));
+ test(S("abcde"), 1, 3, S("1234567890"), 1, 0, S("ae"));
+ test(S("abcde"), 1, 3, S("1234567890"), 1, 1, S("a2e"));
+ test(S("abcde"), 1, 3, S("1234567890"), 1, 4, S("a2345e"));
+ test(S("abcde"), 1, 3, S("1234567890"), 1, 8, S("a23456789e"));
+ test(S("abcde"), 1, 3, S("1234567890"), 1, 9, S("a234567890e"));
+ test(S("abcde"), 1, 3, S("1234567890"), 1, 10, S("a234567890e"));
+ test(S("abcde"), 1, 3, S("1234567890"), 5, 0, S("ae"));
+ test(S("abcde"), 1, 3, S("1234567890"), 5, 1, S("a6e"));
+ test(S("abcde"), 1, 3, S("1234567890"), 5, 2, S("a67e"));
+ test(S("abcde"), 1, 3, S("1234567890"), 5, 4, S("a6789e"));
+ test(S("abcde"), 1, 3, S("1234567890"), 5, 5, S("a67890e"));
+ test(S("abcde"), 1, 3, S("1234567890"), 5, 6, S("a67890e"));
+ test(S("abcde"), 1, 3, S("1234567890"), 9, 0, S("ae"));
+ test(S("abcde"), 1, 3, S("1234567890"), 9, 1, S("a0e"));
+ test(S("abcde"), 1, 3, S("1234567890"), 9, 2, S("a0e"));
+ test(S("abcde"), 1, 3, S("1234567890"), 10, 0, S("ae"));
+ test(S("abcde"), 1, 3, S("1234567890"), 10, 1, S("ae"));
+ test(S("abcde"), 1, 3, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcde"), 1, 3, S("12345678901234567890"), 0, 0, S("ae"));
+ test(S("abcde"), 1, 3, S("12345678901234567890"), 0, 1, S("a1e"));
+ test(S("abcde"), 1, 3, S("12345678901234567890"), 0, 10, S("a1234567890e"));
+ test(S("abcde"), 1, 3, S("12345678901234567890"), 0, 19, S("a1234567890123456789e"));
+ test(S("abcde"), 1, 3, S("12345678901234567890"), 0, 20, S("a12345678901234567890e"));
+ test(S("abcde"), 1, 3, S("12345678901234567890"), 0, 21, S("a12345678901234567890e"));
+ test(S("abcde"), 1, 3, S("12345678901234567890"), 1, 0, S("ae"));
+ test(S("abcde"), 1, 3, S("12345678901234567890"), 1, 1, S("a2e"));
+ test(S("abcde"), 1, 3, S("12345678901234567890"), 1, 9, S("a234567890e"));
+ test(S("abcde"), 1, 3, S("12345678901234567890"), 1, 18, S("a234567890123456789e"));
+ test(S("abcde"), 1, 3, S("12345678901234567890"), 1, 19, S("a2345678901234567890e"));
+ test(S("abcde"), 1, 3, S("12345678901234567890"), 1, 20, S("a2345678901234567890e"));
+ test(S("abcde"), 1, 3, S("12345678901234567890"), 10, 0, S("ae"));
+ test(S("abcde"), 1, 3, S("12345678901234567890"), 10, 1, S("a1e"));
+ test(S("abcde"), 1, 3, S("12345678901234567890"), 10, 5, S("a12345e"));
+ test(S("abcde"), 1, 3, S("12345678901234567890"), 10, 9, S("a123456789e"));
+ test(S("abcde"), 1, 3, S("12345678901234567890"), 10, 10, S("a1234567890e"));
+ test(S("abcde"), 1, 3, S("12345678901234567890"), 10, 11, S("a1234567890e"));
+ test(S("abcde"), 1, 3, S("12345678901234567890"), 19, 0, S("ae"));
+ test(S("abcde"), 1, 3, S("12345678901234567890"), 19, 1, S("a0e"));
+ test(S("abcde"), 1, 3, S("12345678901234567890"), 19, 2, S("a0e"));
+ test(S("abcde"), 1, 3, S("12345678901234567890"), 20, 0, S("ae"));
+ test(S("abcde"), 1, 3, S("12345678901234567890"), 20, 1, S("ae"));
+ test(S("abcde"), 1, 3, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcde"), 1, 4, S(""), 0, 0, S("a"));
+ test(S("abcde"), 1, 4, S(""), 0, 1, S("a"));
+ test(S("abcde"), 1, 4, S(""), 1, 0, S("can't happen"));
+ test(S("abcde"), 1, 4, S("12345"), 0, 0, S("a"));
+ test(S("abcde"), 1, 4, S("12345"), 0, 1, S("a1"));
+ test(S("abcde"), 1, 4, S("12345"), 0, 2, S("a12"));
+ test(S("abcde"), 1, 4, S("12345"), 0, 4, S("a1234"));
+ test(S("abcde"), 1, 4, S("12345"), 0, 5, S("a12345"));
+ test(S("abcde"), 1, 4, S("12345"), 0, 6, S("a12345"));
+ test(S("abcde"), 1, 4, S("12345"), 1, 0, S("a"));
+ test(S("abcde"), 1, 4, S("12345"), 1, 1, S("a2"));
+ test(S("abcde"), 1, 4, S("12345"), 1, 2, S("a23"));
+ test(S("abcde"), 1, 4, S("12345"), 1, 3, S("a234"));
+ test(S("abcde"), 1, 4, S("12345"), 1, 4, S("a2345"));
+ test(S("abcde"), 1, 4, S("12345"), 1, 5, S("a2345"));
+ test(S("abcde"), 1, 4, S("12345"), 2, 0, S("a"));
+ test(S("abcde"), 1, 4, S("12345"), 2, 1, S("a3"));
+ test(S("abcde"), 1, 4, S("12345"), 2, 2, S("a34"));
+ test(S("abcde"), 1, 4, S("12345"), 2, 3, S("a345"));
+ test(S("abcde"), 1, 4, S("12345"), 2, 4, S("a345"));
+ test(S("abcde"), 1, 4, S("12345"), 4, 0, S("a"));
+ test(S("abcde"), 1, 4, S("12345"), 4, 1, S("a5"));
+ test(S("abcde"), 1, 4, S("12345"), 4, 2, S("a5"));
+ test(S("abcde"), 1, 4, S("12345"), 5, 0, S("a"));
+ test(S("abcde"), 1, 4, S("12345"), 5, 1, S("a"));
+ test(S("abcde"), 1, 4, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcde"), 1, 4, S("1234567890"), 0, 0, S("a"));
+ test(S("abcde"), 1, 4, S("1234567890"), 0, 1, S("a1"));
+ test(S("abcde"), 1, 4, S("1234567890"), 0, 5, S("a12345"));
+ test(S("abcde"), 1, 4, S("1234567890"), 0, 9, S("a123456789"));
+ test(S("abcde"), 1, 4, S("1234567890"), 0, 10, S("a1234567890"));
+ test(S("abcde"), 1, 4, S("1234567890"), 0, 11, S("a1234567890"));
+ test(S("abcde"), 1, 4, S("1234567890"), 1, 0, S("a"));
+ test(S("abcde"), 1, 4, S("1234567890"), 1, 1, S("a2"));
+ test(S("abcde"), 1, 4, S("1234567890"), 1, 4, S("a2345"));
+ test(S("abcde"), 1, 4, S("1234567890"), 1, 8, S("a23456789"));
+ test(S("abcde"), 1, 4, S("1234567890"), 1, 9, S("a234567890"));
+ test(S("abcde"), 1, 4, S("1234567890"), 1, 10, S("a234567890"));
+}
+
+template <class S>
+void test10()
+{
+ test(S("abcde"), 1, 4, S("1234567890"), 5, 0, S("a"));
+ test(S("abcde"), 1, 4, S("1234567890"), 5, 1, S("a6"));
+ test(S("abcde"), 1, 4, S("1234567890"), 5, 2, S("a67"));
+ test(S("abcde"), 1, 4, S("1234567890"), 5, 4, S("a6789"));
+ test(S("abcde"), 1, 4, S("1234567890"), 5, 5, S("a67890"));
+ test(S("abcde"), 1, 4, S("1234567890"), 5, 6, S("a67890"));
+ test(S("abcde"), 1, 4, S("1234567890"), 9, 0, S("a"));
+ test(S("abcde"), 1, 4, S("1234567890"), 9, 1, S("a0"));
+ test(S("abcde"), 1, 4, S("1234567890"), 9, 2, S("a0"));
+ test(S("abcde"), 1, 4, S("1234567890"), 10, 0, S("a"));
+ test(S("abcde"), 1, 4, S("1234567890"), 10, 1, S("a"));
+ test(S("abcde"), 1, 4, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcde"), 1, 4, S("12345678901234567890"), 0, 0, S("a"));
+ test(S("abcde"), 1, 4, S("12345678901234567890"), 0, 1, S("a1"));
+ test(S("abcde"), 1, 4, S("12345678901234567890"), 0, 10, S("a1234567890"));
+ test(S("abcde"), 1, 4, S("12345678901234567890"), 0, 19, S("a1234567890123456789"));
+ test(S("abcde"), 1, 4, S("12345678901234567890"), 0, 20, S("a12345678901234567890"));
+ test(S("abcde"), 1, 4, S("12345678901234567890"), 0, 21, S("a12345678901234567890"));
+ test(S("abcde"), 1, 4, S("12345678901234567890"), 1, 0, S("a"));
+ test(S("abcde"), 1, 4, S("12345678901234567890"), 1, 1, S("a2"));
+ test(S("abcde"), 1, 4, S("12345678901234567890"), 1, 9, S("a234567890"));
+ test(S("abcde"), 1, 4, S("12345678901234567890"), 1, 18, S("a234567890123456789"));
+ test(S("abcde"), 1, 4, S("12345678901234567890"), 1, 19, S("a2345678901234567890"));
+ test(S("abcde"), 1, 4, S("12345678901234567890"), 1, 20, S("a2345678901234567890"));
+ test(S("abcde"), 1, 4, S("12345678901234567890"), 10, 0, S("a"));
+ test(S("abcde"), 1, 4, S("12345678901234567890"), 10, 1, S("a1"));
+ test(S("abcde"), 1, 4, S("12345678901234567890"), 10, 5, S("a12345"));
+ test(S("abcde"), 1, 4, S("12345678901234567890"), 10, 9, S("a123456789"));
+ test(S("abcde"), 1, 4, S("12345678901234567890"), 10, 10, S("a1234567890"));
+ test(S("abcde"), 1, 4, S("12345678901234567890"), 10, 11, S("a1234567890"));
+ test(S("abcde"), 1, 4, S("12345678901234567890"), 19, 0, S("a"));
+ test(S("abcde"), 1, 4, S("12345678901234567890"), 19, 1, S("a0"));
+ test(S("abcde"), 1, 4, S("12345678901234567890"), 19, 2, S("a0"));
+ test(S("abcde"), 1, 4, S("12345678901234567890"), 20, 0, S("a"));
+ test(S("abcde"), 1, 4, S("12345678901234567890"), 20, 1, S("a"));
+ test(S("abcde"), 1, 4, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcde"), 1, 5, S(""), 0, 0, S("a"));
+ test(S("abcde"), 1, 5, S(""), 0, 1, S("a"));
+ test(S("abcde"), 1, 5, S(""), 1, 0, S("can't happen"));
+ test(S("abcde"), 1, 5, S("12345"), 0, 0, S("a"));
+ test(S("abcde"), 1, 5, S("12345"), 0, 1, S("a1"));
+ test(S("abcde"), 1, 5, S("12345"), 0, 2, S("a12"));
+ test(S("abcde"), 1, 5, S("12345"), 0, 4, S("a1234"));
+ test(S("abcde"), 1, 5, S("12345"), 0, 5, S("a12345"));
+ test(S("abcde"), 1, 5, S("12345"), 0, 6, S("a12345"));
+ test(S("abcde"), 1, 5, S("12345"), 1, 0, S("a"));
+ test(S("abcde"), 1, 5, S("12345"), 1, 1, S("a2"));
+ test(S("abcde"), 1, 5, S("12345"), 1, 2, S("a23"));
+ test(S("abcde"), 1, 5, S("12345"), 1, 3, S("a234"));
+ test(S("abcde"), 1, 5, S("12345"), 1, 4, S("a2345"));
+ test(S("abcde"), 1, 5, S("12345"), 1, 5, S("a2345"));
+ test(S("abcde"), 1, 5, S("12345"), 2, 0, S("a"));
+ test(S("abcde"), 1, 5, S("12345"), 2, 1, S("a3"));
+ test(S("abcde"), 1, 5, S("12345"), 2, 2, S("a34"));
+ test(S("abcde"), 1, 5, S("12345"), 2, 3, S("a345"));
+ test(S("abcde"), 1, 5, S("12345"), 2, 4, S("a345"));
+ test(S("abcde"), 1, 5, S("12345"), 4, 0, S("a"));
+ test(S("abcde"), 1, 5, S("12345"), 4, 1, S("a5"));
+ test(S("abcde"), 1, 5, S("12345"), 4, 2, S("a5"));
+ test(S("abcde"), 1, 5, S("12345"), 5, 0, S("a"));
+ test(S("abcde"), 1, 5, S("12345"), 5, 1, S("a"));
+ test(S("abcde"), 1, 5, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcde"), 1, 5, S("1234567890"), 0, 0, S("a"));
+ test(S("abcde"), 1, 5, S("1234567890"), 0, 1, S("a1"));
+ test(S("abcde"), 1, 5, S("1234567890"), 0, 5, S("a12345"));
+ test(S("abcde"), 1, 5, S("1234567890"), 0, 9, S("a123456789"));
+ test(S("abcde"), 1, 5, S("1234567890"), 0, 10, S("a1234567890"));
+ test(S("abcde"), 1, 5, S("1234567890"), 0, 11, S("a1234567890"));
+ test(S("abcde"), 1, 5, S("1234567890"), 1, 0, S("a"));
+ test(S("abcde"), 1, 5, S("1234567890"), 1, 1, S("a2"));
+ test(S("abcde"), 1, 5, S("1234567890"), 1, 4, S("a2345"));
+ test(S("abcde"), 1, 5, S("1234567890"), 1, 8, S("a23456789"));
+ test(S("abcde"), 1, 5, S("1234567890"), 1, 9, S("a234567890"));
+ test(S("abcde"), 1, 5, S("1234567890"), 1, 10, S("a234567890"));
+ test(S("abcde"), 1, 5, S("1234567890"), 5, 0, S("a"));
+ test(S("abcde"), 1, 5, S("1234567890"), 5, 1, S("a6"));
+ test(S("abcde"), 1, 5, S("1234567890"), 5, 2, S("a67"));
+ test(S("abcde"), 1, 5, S("1234567890"), 5, 4, S("a6789"));
+ test(S("abcde"), 1, 5, S("1234567890"), 5, 5, S("a67890"));
+ test(S("abcde"), 1, 5, S("1234567890"), 5, 6, S("a67890"));
+ test(S("abcde"), 1, 5, S("1234567890"), 9, 0, S("a"));
+ test(S("abcde"), 1, 5, S("1234567890"), 9, 1, S("a0"));
+ test(S("abcde"), 1, 5, S("1234567890"), 9, 2, S("a0"));
+ test(S("abcde"), 1, 5, S("1234567890"), 10, 0, S("a"));
+ test(S("abcde"), 1, 5, S("1234567890"), 10, 1, S("a"));
+ test(S("abcde"), 1, 5, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcde"), 1, 5, S("12345678901234567890"), 0, 0, S("a"));
+ test(S("abcde"), 1, 5, S("12345678901234567890"), 0, 1, S("a1"));
+ test(S("abcde"), 1, 5, S("12345678901234567890"), 0, 10, S("a1234567890"));
+ test(S("abcde"), 1, 5, S("12345678901234567890"), 0, 19, S("a1234567890123456789"));
+ test(S("abcde"), 1, 5, S("12345678901234567890"), 0, 20, S("a12345678901234567890"));
+ test(S("abcde"), 1, 5, S("12345678901234567890"), 0, 21, S("a12345678901234567890"));
+ test(S("abcde"), 1, 5, S("12345678901234567890"), 1, 0, S("a"));
+ test(S("abcde"), 1, 5, S("12345678901234567890"), 1, 1, S("a2"));
+ test(S("abcde"), 1, 5, S("12345678901234567890"), 1, 9, S("a234567890"));
+ test(S("abcde"), 1, 5, S("12345678901234567890"), 1, 18, S("a234567890123456789"));
+ test(S("abcde"), 1, 5, S("12345678901234567890"), 1, 19, S("a2345678901234567890"));
+ test(S("abcde"), 1, 5, S("12345678901234567890"), 1, 20, S("a2345678901234567890"));
+ test(S("abcde"), 1, 5, S("12345678901234567890"), 10, 0, S("a"));
+ test(S("abcde"), 1, 5, S("12345678901234567890"), 10, 1, S("a1"));
+}
+
+template <class S>
+void test11()
+{
+ test(S("abcde"), 1, 5, S("12345678901234567890"), 10, 5, S("a12345"));
+ test(S("abcde"), 1, 5, S("12345678901234567890"), 10, 9, S("a123456789"));
+ test(S("abcde"), 1, 5, S("12345678901234567890"), 10, 10, S("a1234567890"));
+ test(S("abcde"), 1, 5, S("12345678901234567890"), 10, 11, S("a1234567890"));
+ test(S("abcde"), 1, 5, S("12345678901234567890"), 19, 0, S("a"));
+ test(S("abcde"), 1, 5, S("12345678901234567890"), 19, 1, S("a0"));
+ test(S("abcde"), 1, 5, S("12345678901234567890"), 19, 2, S("a0"));
+ test(S("abcde"), 1, 5, S("12345678901234567890"), 20, 0, S("a"));
+ test(S("abcde"), 1, 5, S("12345678901234567890"), 20, 1, S("a"));
+ test(S("abcde"), 1, 5, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcde"), 2, 0, S(""), 0, 0, S("abcde"));
+ test(S("abcde"), 2, 0, S(""), 0, 1, S("abcde"));
+ test(S("abcde"), 2, 0, S(""), 1, 0, S("can't happen"));
+ test(S("abcde"), 2, 0, S("12345"), 0, 0, S("abcde"));
+ test(S("abcde"), 2, 0, S("12345"), 0, 1, S("ab1cde"));
+ test(S("abcde"), 2, 0, S("12345"), 0, 2, S("ab12cde"));
+ test(S("abcde"), 2, 0, S("12345"), 0, 4, S("ab1234cde"));
+ test(S("abcde"), 2, 0, S("12345"), 0, 5, S("ab12345cde"));
+ test(S("abcde"), 2, 0, S("12345"), 0, 6, S("ab12345cde"));
+ test(S("abcde"), 2, 0, S("12345"), 1, 0, S("abcde"));
+ test(S("abcde"), 2, 0, S("12345"), 1, 1, S("ab2cde"));
+ test(S("abcde"), 2, 0, S("12345"), 1, 2, S("ab23cde"));
+ test(S("abcde"), 2, 0, S("12345"), 1, 3, S("ab234cde"));
+ test(S("abcde"), 2, 0, S("12345"), 1, 4, S("ab2345cde"));
+ test(S("abcde"), 2, 0, S("12345"), 1, 5, S("ab2345cde"));
+ test(S("abcde"), 2, 0, S("12345"), 2, 0, S("abcde"));
+ test(S("abcde"), 2, 0, S("12345"), 2, 1, S("ab3cde"));
+ test(S("abcde"), 2, 0, S("12345"), 2, 2, S("ab34cde"));
+ test(S("abcde"), 2, 0, S("12345"), 2, 3, S("ab345cde"));
+ test(S("abcde"), 2, 0, S("12345"), 2, 4, S("ab345cde"));
+ test(S("abcde"), 2, 0, S("12345"), 4, 0, S("abcde"));
+ test(S("abcde"), 2, 0, S("12345"), 4, 1, S("ab5cde"));
+ test(S("abcde"), 2, 0, S("12345"), 4, 2, S("ab5cde"));
+ test(S("abcde"), 2, 0, S("12345"), 5, 0, S("abcde"));
+ test(S("abcde"), 2, 0, S("12345"), 5, 1, S("abcde"));
+ test(S("abcde"), 2, 0, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcde"), 2, 0, S("1234567890"), 0, 0, S("abcde"));
+ test(S("abcde"), 2, 0, S("1234567890"), 0, 1, S("ab1cde"));
+ test(S("abcde"), 2, 0, S("1234567890"), 0, 5, S("ab12345cde"));
+ test(S("abcde"), 2, 0, S("1234567890"), 0, 9, S("ab123456789cde"));
+ test(S("abcde"), 2, 0, S("1234567890"), 0, 10, S("ab1234567890cde"));
+ test(S("abcde"), 2, 0, S("1234567890"), 0, 11, S("ab1234567890cde"));
+ test(S("abcde"), 2, 0, S("1234567890"), 1, 0, S("abcde"));
+ test(S("abcde"), 2, 0, S("1234567890"), 1, 1, S("ab2cde"));
+ test(S("abcde"), 2, 0, S("1234567890"), 1, 4, S("ab2345cde"));
+ test(S("abcde"), 2, 0, S("1234567890"), 1, 8, S("ab23456789cde"));
+ test(S("abcde"), 2, 0, S("1234567890"), 1, 9, S("ab234567890cde"));
+ test(S("abcde"), 2, 0, S("1234567890"), 1, 10, S("ab234567890cde"));
+ test(S("abcde"), 2, 0, S("1234567890"), 5, 0, S("abcde"));
+ test(S("abcde"), 2, 0, S("1234567890"), 5, 1, S("ab6cde"));
+ test(S("abcde"), 2, 0, S("1234567890"), 5, 2, S("ab67cde"));
+ test(S("abcde"), 2, 0, S("1234567890"), 5, 4, S("ab6789cde"));
+ test(S("abcde"), 2, 0, S("1234567890"), 5, 5, S("ab67890cde"));
+ test(S("abcde"), 2, 0, S("1234567890"), 5, 6, S("ab67890cde"));
+ test(S("abcde"), 2, 0, S("1234567890"), 9, 0, S("abcde"));
+ test(S("abcde"), 2, 0, S("1234567890"), 9, 1, S("ab0cde"));
+ test(S("abcde"), 2, 0, S("1234567890"), 9, 2, S("ab0cde"));
+ test(S("abcde"), 2, 0, S("1234567890"), 10, 0, S("abcde"));
+ test(S("abcde"), 2, 0, S("1234567890"), 10, 1, S("abcde"));
+ test(S("abcde"), 2, 0, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcde"), 2, 0, S("12345678901234567890"), 0, 0, S("abcde"));
+ test(S("abcde"), 2, 0, S("12345678901234567890"), 0, 1, S("ab1cde"));
+ test(S("abcde"), 2, 0, S("12345678901234567890"), 0, 10, S("ab1234567890cde"));
+ test(S("abcde"), 2, 0, S("12345678901234567890"), 0, 19, S("ab1234567890123456789cde"));
+ test(S("abcde"), 2, 0, S("12345678901234567890"), 0, 20, S("ab12345678901234567890cde"));
+ test(S("abcde"), 2, 0, S("12345678901234567890"), 0, 21, S("ab12345678901234567890cde"));
+ test(S("abcde"), 2, 0, S("12345678901234567890"), 1, 0, S("abcde"));
+ test(S("abcde"), 2, 0, S("12345678901234567890"), 1, 1, S("ab2cde"));
+ test(S("abcde"), 2, 0, S("12345678901234567890"), 1, 9, S("ab234567890cde"));
+ test(S("abcde"), 2, 0, S("12345678901234567890"), 1, 18, S("ab234567890123456789cde"));
+ test(S("abcde"), 2, 0, S("12345678901234567890"), 1, 19, S("ab2345678901234567890cde"));
+ test(S("abcde"), 2, 0, S("12345678901234567890"), 1, 20, S("ab2345678901234567890cde"));
+ test(S("abcde"), 2, 0, S("12345678901234567890"), 10, 0, S("abcde"));
+ test(S("abcde"), 2, 0, S("12345678901234567890"), 10, 1, S("ab1cde"));
+ test(S("abcde"), 2, 0, S("12345678901234567890"), 10, 5, S("ab12345cde"));
+ test(S("abcde"), 2, 0, S("12345678901234567890"), 10, 9, S("ab123456789cde"));
+ test(S("abcde"), 2, 0, S("12345678901234567890"), 10, 10, S("ab1234567890cde"));
+ test(S("abcde"), 2, 0, S("12345678901234567890"), 10, 11, S("ab1234567890cde"));
+ test(S("abcde"), 2, 0, S("12345678901234567890"), 19, 0, S("abcde"));
+ test(S("abcde"), 2, 0, S("12345678901234567890"), 19, 1, S("ab0cde"));
+ test(S("abcde"), 2, 0, S("12345678901234567890"), 19, 2, S("ab0cde"));
+ test(S("abcde"), 2, 0, S("12345678901234567890"), 20, 0, S("abcde"));
+ test(S("abcde"), 2, 0, S("12345678901234567890"), 20, 1, S("abcde"));
+ test(S("abcde"), 2, 0, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcde"), 2, 1, S(""), 0, 0, S("abde"));
+ test(S("abcde"), 2, 1, S(""), 0, 1, S("abde"));
+ test(S("abcde"), 2, 1, S(""), 1, 0, S("can't happen"));
+ test(S("abcde"), 2, 1, S("12345"), 0, 0, S("abde"));
+ test(S("abcde"), 2, 1, S("12345"), 0, 1, S("ab1de"));
+ test(S("abcde"), 2, 1, S("12345"), 0, 2, S("ab12de"));
+ test(S("abcde"), 2, 1, S("12345"), 0, 4, S("ab1234de"));
+ test(S("abcde"), 2, 1, S("12345"), 0, 5, S("ab12345de"));
+ test(S("abcde"), 2, 1, S("12345"), 0, 6, S("ab12345de"));
+ test(S("abcde"), 2, 1, S("12345"), 1, 0, S("abde"));
+ test(S("abcde"), 2, 1, S("12345"), 1, 1, S("ab2de"));
+ test(S("abcde"), 2, 1, S("12345"), 1, 2, S("ab23de"));
+ test(S("abcde"), 2, 1, S("12345"), 1, 3, S("ab234de"));
+ test(S("abcde"), 2, 1, S("12345"), 1, 4, S("ab2345de"));
+ test(S("abcde"), 2, 1, S("12345"), 1, 5, S("ab2345de"));
+ test(S("abcde"), 2, 1, S("12345"), 2, 0, S("abde"));
+}
+
+template <class S>
+void test12()
+{
+ test(S("abcde"), 2, 1, S("12345"), 2, 1, S("ab3de"));
+ test(S("abcde"), 2, 1, S("12345"), 2, 2, S("ab34de"));
+ test(S("abcde"), 2, 1, S("12345"), 2, 3, S("ab345de"));
+ test(S("abcde"), 2, 1, S("12345"), 2, 4, S("ab345de"));
+ test(S("abcde"), 2, 1, S("12345"), 4, 0, S("abde"));
+ test(S("abcde"), 2, 1, S("12345"), 4, 1, S("ab5de"));
+ test(S("abcde"), 2, 1, S("12345"), 4, 2, S("ab5de"));
+ test(S("abcde"), 2, 1, S("12345"), 5, 0, S("abde"));
+ test(S("abcde"), 2, 1, S("12345"), 5, 1, S("abde"));
+ test(S("abcde"), 2, 1, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcde"), 2, 1, S("1234567890"), 0, 0, S("abde"));
+ test(S("abcde"), 2, 1, S("1234567890"), 0, 1, S("ab1de"));
+ test(S("abcde"), 2, 1, S("1234567890"), 0, 5, S("ab12345de"));
+ test(S("abcde"), 2, 1, S("1234567890"), 0, 9, S("ab123456789de"));
+ test(S("abcde"), 2, 1, S("1234567890"), 0, 10, S("ab1234567890de"));
+ test(S("abcde"), 2, 1, S("1234567890"), 0, 11, S("ab1234567890de"));
+ test(S("abcde"), 2, 1, S("1234567890"), 1, 0, S("abde"));
+ test(S("abcde"), 2, 1, S("1234567890"), 1, 1, S("ab2de"));
+ test(S("abcde"), 2, 1, S("1234567890"), 1, 4, S("ab2345de"));
+ test(S("abcde"), 2, 1, S("1234567890"), 1, 8, S("ab23456789de"));
+ test(S("abcde"), 2, 1, S("1234567890"), 1, 9, S("ab234567890de"));
+ test(S("abcde"), 2, 1, S("1234567890"), 1, 10, S("ab234567890de"));
+ test(S("abcde"), 2, 1, S("1234567890"), 5, 0, S("abde"));
+ test(S("abcde"), 2, 1, S("1234567890"), 5, 1, S("ab6de"));
+ test(S("abcde"), 2, 1, S("1234567890"), 5, 2, S("ab67de"));
+ test(S("abcde"), 2, 1, S("1234567890"), 5, 4, S("ab6789de"));
+ test(S("abcde"), 2, 1, S("1234567890"), 5, 5, S("ab67890de"));
+ test(S("abcde"), 2, 1, S("1234567890"), 5, 6, S("ab67890de"));
+ test(S("abcde"), 2, 1, S("1234567890"), 9, 0, S("abde"));
+ test(S("abcde"), 2, 1, S("1234567890"), 9, 1, S("ab0de"));
+ test(S("abcde"), 2, 1, S("1234567890"), 9, 2, S("ab0de"));
+ test(S("abcde"), 2, 1, S("1234567890"), 10, 0, S("abde"));
+ test(S("abcde"), 2, 1, S("1234567890"), 10, 1, S("abde"));
+ test(S("abcde"), 2, 1, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcde"), 2, 1, S("12345678901234567890"), 0, 0, S("abde"));
+ test(S("abcde"), 2, 1, S("12345678901234567890"), 0, 1, S("ab1de"));
+ test(S("abcde"), 2, 1, S("12345678901234567890"), 0, 10, S("ab1234567890de"));
+ test(S("abcde"), 2, 1, S("12345678901234567890"), 0, 19, S("ab1234567890123456789de"));
+ test(S("abcde"), 2, 1, S("12345678901234567890"), 0, 20, S("ab12345678901234567890de"));
+ test(S("abcde"), 2, 1, S("12345678901234567890"), 0, 21, S("ab12345678901234567890de"));
+ test(S("abcde"), 2, 1, S("12345678901234567890"), 1, 0, S("abde"));
+ test(S("abcde"), 2, 1, S("12345678901234567890"), 1, 1, S("ab2de"));
+ test(S("abcde"), 2, 1, S("12345678901234567890"), 1, 9, S("ab234567890de"));
+ test(S("abcde"), 2, 1, S("12345678901234567890"), 1, 18, S("ab234567890123456789de"));
+ test(S("abcde"), 2, 1, S("12345678901234567890"), 1, 19, S("ab2345678901234567890de"));
+ test(S("abcde"), 2, 1, S("12345678901234567890"), 1, 20, S("ab2345678901234567890de"));
+ test(S("abcde"), 2, 1, S("12345678901234567890"), 10, 0, S("abde"));
+ test(S("abcde"), 2, 1, S("12345678901234567890"), 10, 1, S("ab1de"));
+ test(S("abcde"), 2, 1, S("12345678901234567890"), 10, 5, S("ab12345de"));
+ test(S("abcde"), 2, 1, S("12345678901234567890"), 10, 9, S("ab123456789de"));
+ test(S("abcde"), 2, 1, S("12345678901234567890"), 10, 10, S("ab1234567890de"));
+ test(S("abcde"), 2, 1, S("12345678901234567890"), 10, 11, S("ab1234567890de"));
+ test(S("abcde"), 2, 1, S("12345678901234567890"), 19, 0, S("abde"));
+ test(S("abcde"), 2, 1, S("12345678901234567890"), 19, 1, S("ab0de"));
+ test(S("abcde"), 2, 1, S("12345678901234567890"), 19, 2, S("ab0de"));
+ test(S("abcde"), 2, 1, S("12345678901234567890"), 20, 0, S("abde"));
+ test(S("abcde"), 2, 1, S("12345678901234567890"), 20, 1, S("abde"));
+ test(S("abcde"), 2, 1, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcde"), 2, 2, S(""), 0, 0, S("abe"));
+ test(S("abcde"), 2, 2, S(""), 0, 1, S("abe"));
+ test(S("abcde"), 2, 2, S(""), 1, 0, S("can't happen"));
+ test(S("abcde"), 2, 2, S("12345"), 0, 0, S("abe"));
+ test(S("abcde"), 2, 2, S("12345"), 0, 1, S("ab1e"));
+ test(S("abcde"), 2, 2, S("12345"), 0, 2, S("ab12e"));
+ test(S("abcde"), 2, 2, S("12345"), 0, 4, S("ab1234e"));
+ test(S("abcde"), 2, 2, S("12345"), 0, 5, S("ab12345e"));
+ test(S("abcde"), 2, 2, S("12345"), 0, 6, S("ab12345e"));
+ test(S("abcde"), 2, 2, S("12345"), 1, 0, S("abe"));
+ test(S("abcde"), 2, 2, S("12345"), 1, 1, S("ab2e"));
+ test(S("abcde"), 2, 2, S("12345"), 1, 2, S("ab23e"));
+ test(S("abcde"), 2, 2, S("12345"), 1, 3, S("ab234e"));
+ test(S("abcde"), 2, 2, S("12345"), 1, 4, S("ab2345e"));
+ test(S("abcde"), 2, 2, S("12345"), 1, 5, S("ab2345e"));
+ test(S("abcde"), 2, 2, S("12345"), 2, 0, S("abe"));
+ test(S("abcde"), 2, 2, S("12345"), 2, 1, S("ab3e"));
+ test(S("abcde"), 2, 2, S("12345"), 2, 2, S("ab34e"));
+ test(S("abcde"), 2, 2, S("12345"), 2, 3, S("ab345e"));
+ test(S("abcde"), 2, 2, S("12345"), 2, 4, S("ab345e"));
+ test(S("abcde"), 2, 2, S("12345"), 4, 0, S("abe"));
+ test(S("abcde"), 2, 2, S("12345"), 4, 1, S("ab5e"));
+ test(S("abcde"), 2, 2, S("12345"), 4, 2, S("ab5e"));
+ test(S("abcde"), 2, 2, S("12345"), 5, 0, S("abe"));
+ test(S("abcde"), 2, 2, S("12345"), 5, 1, S("abe"));
+ test(S("abcde"), 2, 2, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcde"), 2, 2, S("1234567890"), 0, 0, S("abe"));
+ test(S("abcde"), 2, 2, S("1234567890"), 0, 1, S("ab1e"));
+ test(S("abcde"), 2, 2, S("1234567890"), 0, 5, S("ab12345e"));
+ test(S("abcde"), 2, 2, S("1234567890"), 0, 9, S("ab123456789e"));
+ test(S("abcde"), 2, 2, S("1234567890"), 0, 10, S("ab1234567890e"));
+ test(S("abcde"), 2, 2, S("1234567890"), 0, 11, S("ab1234567890e"));
+ test(S("abcde"), 2, 2, S("1234567890"), 1, 0, S("abe"));
+ test(S("abcde"), 2, 2, S("1234567890"), 1, 1, S("ab2e"));
+ test(S("abcde"), 2, 2, S("1234567890"), 1, 4, S("ab2345e"));
+ test(S("abcde"), 2, 2, S("1234567890"), 1, 8, S("ab23456789e"));
+ test(S("abcde"), 2, 2, S("1234567890"), 1, 9, S("ab234567890e"));
+ test(S("abcde"), 2, 2, S("1234567890"), 1, 10, S("ab234567890e"));
+ test(S("abcde"), 2, 2, S("1234567890"), 5, 0, S("abe"));
+ test(S("abcde"), 2, 2, S("1234567890"), 5, 1, S("ab6e"));
+ test(S("abcde"), 2, 2, S("1234567890"), 5, 2, S("ab67e"));
+ test(S("abcde"), 2, 2, S("1234567890"), 5, 4, S("ab6789e"));
+}
+
+template <class S>
+void test13()
+{
+ test(S("abcde"), 2, 2, S("1234567890"), 5, 5, S("ab67890e"));
+ test(S("abcde"), 2, 2, S("1234567890"), 5, 6, S("ab67890e"));
+ test(S("abcde"), 2, 2, S("1234567890"), 9, 0, S("abe"));
+ test(S("abcde"), 2, 2, S("1234567890"), 9, 1, S("ab0e"));
+ test(S("abcde"), 2, 2, S("1234567890"), 9, 2, S("ab0e"));
+ test(S("abcde"), 2, 2, S("1234567890"), 10, 0, S("abe"));
+ test(S("abcde"), 2, 2, S("1234567890"), 10, 1, S("abe"));
+ test(S("abcde"), 2, 2, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcde"), 2, 2, S("12345678901234567890"), 0, 0, S("abe"));
+ test(S("abcde"), 2, 2, S("12345678901234567890"), 0, 1, S("ab1e"));
+ test(S("abcde"), 2, 2, S("12345678901234567890"), 0, 10, S("ab1234567890e"));
+ test(S("abcde"), 2, 2, S("12345678901234567890"), 0, 19, S("ab1234567890123456789e"));
+ test(S("abcde"), 2, 2, S("12345678901234567890"), 0, 20, S("ab12345678901234567890e"));
+ test(S("abcde"), 2, 2, S("12345678901234567890"), 0, 21, S("ab12345678901234567890e"));
+ test(S("abcde"), 2, 2, S("12345678901234567890"), 1, 0, S("abe"));
+ test(S("abcde"), 2, 2, S("12345678901234567890"), 1, 1, S("ab2e"));
+ test(S("abcde"), 2, 2, S("12345678901234567890"), 1, 9, S("ab234567890e"));
+ test(S("abcde"), 2, 2, S("12345678901234567890"), 1, 18, S("ab234567890123456789e"));
+ test(S("abcde"), 2, 2, S("12345678901234567890"), 1, 19, S("ab2345678901234567890e"));
+ test(S("abcde"), 2, 2, S("12345678901234567890"), 1, 20, S("ab2345678901234567890e"));
+ test(S("abcde"), 2, 2, S("12345678901234567890"), 10, 0, S("abe"));
+ test(S("abcde"), 2, 2, S("12345678901234567890"), 10, 1, S("ab1e"));
+ test(S("abcde"), 2, 2, S("12345678901234567890"), 10, 5, S("ab12345e"));
+ test(S("abcde"), 2, 2, S("12345678901234567890"), 10, 9, S("ab123456789e"));
+ test(S("abcde"), 2, 2, S("12345678901234567890"), 10, 10, S("ab1234567890e"));
+ test(S("abcde"), 2, 2, S("12345678901234567890"), 10, 11, S("ab1234567890e"));
+ test(S("abcde"), 2, 2, S("12345678901234567890"), 19, 0, S("abe"));
+ test(S("abcde"), 2, 2, S("12345678901234567890"), 19, 1, S("ab0e"));
+ test(S("abcde"), 2, 2, S("12345678901234567890"), 19, 2, S("ab0e"));
+ test(S("abcde"), 2, 2, S("12345678901234567890"), 20, 0, S("abe"));
+ test(S("abcde"), 2, 2, S("12345678901234567890"), 20, 1, S("abe"));
+ test(S("abcde"), 2, 2, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcde"), 2, 3, S(""), 0, 0, S("ab"));
+ test(S("abcde"), 2, 3, S(""), 0, 1, S("ab"));
+ test(S("abcde"), 2, 3, S(""), 1, 0, S("can't happen"));
+ test(S("abcde"), 2, 3, S("12345"), 0, 0, S("ab"));
+ test(S("abcde"), 2, 3, S("12345"), 0, 1, S("ab1"));
+ test(S("abcde"), 2, 3, S("12345"), 0, 2, S("ab12"));
+ test(S("abcde"), 2, 3, S("12345"), 0, 4, S("ab1234"));
+ test(S("abcde"), 2, 3, S("12345"), 0, 5, S("ab12345"));
+ test(S("abcde"), 2, 3, S("12345"), 0, 6, S("ab12345"));
+ test(S("abcde"), 2, 3, S("12345"), 1, 0, S("ab"));
+ test(S("abcde"), 2, 3, S("12345"), 1, 1, S("ab2"));
+ test(S("abcde"), 2, 3, S("12345"), 1, 2, S("ab23"));
+ test(S("abcde"), 2, 3, S("12345"), 1, 3, S("ab234"));
+ test(S("abcde"), 2, 3, S("12345"), 1, 4, S("ab2345"));
+ test(S("abcde"), 2, 3, S("12345"), 1, 5, S("ab2345"));
+ test(S("abcde"), 2, 3, S("12345"), 2, 0, S("ab"));
+ test(S("abcde"), 2, 3, S("12345"), 2, 1, S("ab3"));
+ test(S("abcde"), 2, 3, S("12345"), 2, 2, S("ab34"));
+ test(S("abcde"), 2, 3, S("12345"), 2, 3, S("ab345"));
+ test(S("abcde"), 2, 3, S("12345"), 2, 4, S("ab345"));
+ test(S("abcde"), 2, 3, S("12345"), 4, 0, S("ab"));
+ test(S("abcde"), 2, 3, S("12345"), 4, 1, S("ab5"));
+ test(S("abcde"), 2, 3, S("12345"), 4, 2, S("ab5"));
+ test(S("abcde"), 2, 3, S("12345"), 5, 0, S("ab"));
+ test(S("abcde"), 2, 3, S("12345"), 5, 1, S("ab"));
+ test(S("abcde"), 2, 3, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcde"), 2, 3, S("1234567890"), 0, 0, S("ab"));
+ test(S("abcde"), 2, 3, S("1234567890"), 0, 1, S("ab1"));
+ test(S("abcde"), 2, 3, S("1234567890"), 0, 5, S("ab12345"));
+ test(S("abcde"), 2, 3, S("1234567890"), 0, 9, S("ab123456789"));
+ test(S("abcde"), 2, 3, S("1234567890"), 0, 10, S("ab1234567890"));
+ test(S("abcde"), 2, 3, S("1234567890"), 0, 11, S("ab1234567890"));
+ test(S("abcde"), 2, 3, S("1234567890"), 1, 0, S("ab"));
+ test(S("abcde"), 2, 3, S("1234567890"), 1, 1, S("ab2"));
+ test(S("abcde"), 2, 3, S("1234567890"), 1, 4, S("ab2345"));
+ test(S("abcde"), 2, 3, S("1234567890"), 1, 8, S("ab23456789"));
+ test(S("abcde"), 2, 3, S("1234567890"), 1, 9, S("ab234567890"));
+ test(S("abcde"), 2, 3, S("1234567890"), 1, 10, S("ab234567890"));
+ test(S("abcde"), 2, 3, S("1234567890"), 5, 0, S("ab"));
+ test(S("abcde"), 2, 3, S("1234567890"), 5, 1, S("ab6"));
+ test(S("abcde"), 2, 3, S("1234567890"), 5, 2, S("ab67"));
+ test(S("abcde"), 2, 3, S("1234567890"), 5, 4, S("ab6789"));
+ test(S("abcde"), 2, 3, S("1234567890"), 5, 5, S("ab67890"));
+ test(S("abcde"), 2, 3, S("1234567890"), 5, 6, S("ab67890"));
+ test(S("abcde"), 2, 3, S("1234567890"), 9, 0, S("ab"));
+ test(S("abcde"), 2, 3, S("1234567890"), 9, 1, S("ab0"));
+ test(S("abcde"), 2, 3, S("1234567890"), 9, 2, S("ab0"));
+ test(S("abcde"), 2, 3, S("1234567890"), 10, 0, S("ab"));
+ test(S("abcde"), 2, 3, S("1234567890"), 10, 1, S("ab"));
+ test(S("abcde"), 2, 3, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcde"), 2, 3, S("12345678901234567890"), 0, 0, S("ab"));
+ test(S("abcde"), 2, 3, S("12345678901234567890"), 0, 1, S("ab1"));
+ test(S("abcde"), 2, 3, S("12345678901234567890"), 0, 10, S("ab1234567890"));
+ test(S("abcde"), 2, 3, S("12345678901234567890"), 0, 19, S("ab1234567890123456789"));
+ test(S("abcde"), 2, 3, S("12345678901234567890"), 0, 20, S("ab12345678901234567890"));
+ test(S("abcde"), 2, 3, S("12345678901234567890"), 0, 21, S("ab12345678901234567890"));
+ test(S("abcde"), 2, 3, S("12345678901234567890"), 1, 0, S("ab"));
+ test(S("abcde"), 2, 3, S("12345678901234567890"), 1, 1, S("ab2"));
+ test(S("abcde"), 2, 3, S("12345678901234567890"), 1, 9, S("ab234567890"));
+ test(S("abcde"), 2, 3, S("12345678901234567890"), 1, 18, S("ab234567890123456789"));
+ test(S("abcde"), 2, 3, S("12345678901234567890"), 1, 19, S("ab2345678901234567890"));
+ test(S("abcde"), 2, 3, S("12345678901234567890"), 1, 20, S("ab2345678901234567890"));
+ test(S("abcde"), 2, 3, S("12345678901234567890"), 10, 0, S("ab"));
+ test(S("abcde"), 2, 3, S("12345678901234567890"), 10, 1, S("ab1"));
+ test(S("abcde"), 2, 3, S("12345678901234567890"), 10, 5, S("ab12345"));
+ test(S("abcde"), 2, 3, S("12345678901234567890"), 10, 9, S("ab123456789"));
+ test(S("abcde"), 2, 3, S("12345678901234567890"), 10, 10, S("ab1234567890"));
+ test(S("abcde"), 2, 3, S("12345678901234567890"), 10, 11, S("ab1234567890"));
+}
+
+template <class S>
+void test14()
+{
+ test(S("abcde"), 2, 3, S("12345678901234567890"), 19, 0, S("ab"));
+ test(S("abcde"), 2, 3, S("12345678901234567890"), 19, 1, S("ab0"));
+ test(S("abcde"), 2, 3, S("12345678901234567890"), 19, 2, S("ab0"));
+ test(S("abcde"), 2, 3, S("12345678901234567890"), 20, 0, S("ab"));
+ test(S("abcde"), 2, 3, S("12345678901234567890"), 20, 1, S("ab"));
+ test(S("abcde"), 2, 3, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcde"), 2, 4, S(""), 0, 0, S("ab"));
+ test(S("abcde"), 2, 4, S(""), 0, 1, S("ab"));
+ test(S("abcde"), 2, 4, S(""), 1, 0, S("can't happen"));
+ test(S("abcde"), 2, 4, S("12345"), 0, 0, S("ab"));
+ test(S("abcde"), 2, 4, S("12345"), 0, 1, S("ab1"));
+ test(S("abcde"), 2, 4, S("12345"), 0, 2, S("ab12"));
+ test(S("abcde"), 2, 4, S("12345"), 0, 4, S("ab1234"));
+ test(S("abcde"), 2, 4, S("12345"), 0, 5, S("ab12345"));
+ test(S("abcde"), 2, 4, S("12345"), 0, 6, S("ab12345"));
+ test(S("abcde"), 2, 4, S("12345"), 1, 0, S("ab"));
+ test(S("abcde"), 2, 4, S("12345"), 1, 1, S("ab2"));
+ test(S("abcde"), 2, 4, S("12345"), 1, 2, S("ab23"));
+ test(S("abcde"), 2, 4, S("12345"), 1, 3, S("ab234"));
+ test(S("abcde"), 2, 4, S("12345"), 1, 4, S("ab2345"));
+ test(S("abcde"), 2, 4, S("12345"), 1, 5, S("ab2345"));
+ test(S("abcde"), 2, 4, S("12345"), 2, 0, S("ab"));
+ test(S("abcde"), 2, 4, S("12345"), 2, 1, S("ab3"));
+ test(S("abcde"), 2, 4, S("12345"), 2, 2, S("ab34"));
+ test(S("abcde"), 2, 4, S("12345"), 2, 3, S("ab345"));
+ test(S("abcde"), 2, 4, S("12345"), 2, 4, S("ab345"));
+ test(S("abcde"), 2, 4, S("12345"), 4, 0, S("ab"));
+ test(S("abcde"), 2, 4, S("12345"), 4, 1, S("ab5"));
+ test(S("abcde"), 2, 4, S("12345"), 4, 2, S("ab5"));
+ test(S("abcde"), 2, 4, S("12345"), 5, 0, S("ab"));
+ test(S("abcde"), 2, 4, S("12345"), 5, 1, S("ab"));
+ test(S("abcde"), 2, 4, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcde"), 2, 4, S("1234567890"), 0, 0, S("ab"));
+ test(S("abcde"), 2, 4, S("1234567890"), 0, 1, S("ab1"));
+ test(S("abcde"), 2, 4, S("1234567890"), 0, 5, S("ab12345"));
+ test(S("abcde"), 2, 4, S("1234567890"), 0, 9, S("ab123456789"));
+ test(S("abcde"), 2, 4, S("1234567890"), 0, 10, S("ab1234567890"));
+ test(S("abcde"), 2, 4, S("1234567890"), 0, 11, S("ab1234567890"));
+ test(S("abcde"), 2, 4, S("1234567890"), 1, 0, S("ab"));
+ test(S("abcde"), 2, 4, S("1234567890"), 1, 1, S("ab2"));
+ test(S("abcde"), 2, 4, S("1234567890"), 1, 4, S("ab2345"));
+ test(S("abcde"), 2, 4, S("1234567890"), 1, 8, S("ab23456789"));
+ test(S("abcde"), 2, 4, S("1234567890"), 1, 9, S("ab234567890"));
+ test(S("abcde"), 2, 4, S("1234567890"), 1, 10, S("ab234567890"));
+ test(S("abcde"), 2, 4, S("1234567890"), 5, 0, S("ab"));
+ test(S("abcde"), 2, 4, S("1234567890"), 5, 1, S("ab6"));
+ test(S("abcde"), 2, 4, S("1234567890"), 5, 2, S("ab67"));
+ test(S("abcde"), 2, 4, S("1234567890"), 5, 4, S("ab6789"));
+ test(S("abcde"), 2, 4, S("1234567890"), 5, 5, S("ab67890"));
+ test(S("abcde"), 2, 4, S("1234567890"), 5, 6, S("ab67890"));
+ test(S("abcde"), 2, 4, S("1234567890"), 9, 0, S("ab"));
+ test(S("abcde"), 2, 4, S("1234567890"), 9, 1, S("ab0"));
+ test(S("abcde"), 2, 4, S("1234567890"), 9, 2, S("ab0"));
+ test(S("abcde"), 2, 4, S("1234567890"), 10, 0, S("ab"));
+ test(S("abcde"), 2, 4, S("1234567890"), 10, 1, S("ab"));
+ test(S("abcde"), 2, 4, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcde"), 2, 4, S("12345678901234567890"), 0, 0, S("ab"));
+ test(S("abcde"), 2, 4, S("12345678901234567890"), 0, 1, S("ab1"));
+ test(S("abcde"), 2, 4, S("12345678901234567890"), 0, 10, S("ab1234567890"));
+ test(S("abcde"), 2, 4, S("12345678901234567890"), 0, 19, S("ab1234567890123456789"));
+ test(S("abcde"), 2, 4, S("12345678901234567890"), 0, 20, S("ab12345678901234567890"));
+ test(S("abcde"), 2, 4, S("12345678901234567890"), 0, 21, S("ab12345678901234567890"));
+ test(S("abcde"), 2, 4, S("12345678901234567890"), 1, 0, S("ab"));
+ test(S("abcde"), 2, 4, S("12345678901234567890"), 1, 1, S("ab2"));
+ test(S("abcde"), 2, 4, S("12345678901234567890"), 1, 9, S("ab234567890"));
+ test(S("abcde"), 2, 4, S("12345678901234567890"), 1, 18, S("ab234567890123456789"));
+ test(S("abcde"), 2, 4, S("12345678901234567890"), 1, 19, S("ab2345678901234567890"));
+ test(S("abcde"), 2, 4, S("12345678901234567890"), 1, 20, S("ab2345678901234567890"));
+ test(S("abcde"), 2, 4, S("12345678901234567890"), 10, 0, S("ab"));
+ test(S("abcde"), 2, 4, S("12345678901234567890"), 10, 1, S("ab1"));
+ test(S("abcde"), 2, 4, S("12345678901234567890"), 10, 5, S("ab12345"));
+ test(S("abcde"), 2, 4, S("12345678901234567890"), 10, 9, S("ab123456789"));
+ test(S("abcde"), 2, 4, S("12345678901234567890"), 10, 10, S("ab1234567890"));
+ test(S("abcde"), 2, 4, S("12345678901234567890"), 10, 11, S("ab1234567890"));
+ test(S("abcde"), 2, 4, S("12345678901234567890"), 19, 0, S("ab"));
+ test(S("abcde"), 2, 4, S("12345678901234567890"), 19, 1, S("ab0"));
+ test(S("abcde"), 2, 4, S("12345678901234567890"), 19, 2, S("ab0"));
+ test(S("abcde"), 2, 4, S("12345678901234567890"), 20, 0, S("ab"));
+ test(S("abcde"), 2, 4, S("12345678901234567890"), 20, 1, S("ab"));
+ test(S("abcde"), 2, 4, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcde"), 4, 0, S(""), 0, 0, S("abcde"));
+ test(S("abcde"), 4, 0, S(""), 0, 1, S("abcde"));
+ test(S("abcde"), 4, 0, S(""), 1, 0, S("can't happen"));
+ test(S("abcde"), 4, 0, S("12345"), 0, 0, S("abcde"));
+ test(S("abcde"), 4, 0, S("12345"), 0, 1, S("abcd1e"));
+ test(S("abcde"), 4, 0, S("12345"), 0, 2, S("abcd12e"));
+ test(S("abcde"), 4, 0, S("12345"), 0, 4, S("abcd1234e"));
+ test(S("abcde"), 4, 0, S("12345"), 0, 5, S("abcd12345e"));
+ test(S("abcde"), 4, 0, S("12345"), 0, 6, S("abcd12345e"));
+ test(S("abcde"), 4, 0, S("12345"), 1, 0, S("abcde"));
+ test(S("abcde"), 4, 0, S("12345"), 1, 1, S("abcd2e"));
+ test(S("abcde"), 4, 0, S("12345"), 1, 2, S("abcd23e"));
+ test(S("abcde"), 4, 0, S("12345"), 1, 3, S("abcd234e"));
+ test(S("abcde"), 4, 0, S("12345"), 1, 4, S("abcd2345e"));
+ test(S("abcde"), 4, 0, S("12345"), 1, 5, S("abcd2345e"));
+ test(S("abcde"), 4, 0, S("12345"), 2, 0, S("abcde"));
+ test(S("abcde"), 4, 0, S("12345"), 2, 1, S("abcd3e"));
+ test(S("abcde"), 4, 0, S("12345"), 2, 2, S("abcd34e"));
+ test(S("abcde"), 4, 0, S("12345"), 2, 3, S("abcd345e"));
+ test(S("abcde"), 4, 0, S("12345"), 2, 4, S("abcd345e"));
+}
+
+template <class S>
+void test15()
+{
+ test(S("abcde"), 4, 0, S("12345"), 4, 0, S("abcde"));
+ test(S("abcde"), 4, 0, S("12345"), 4, 1, S("abcd5e"));
+ test(S("abcde"), 4, 0, S("12345"), 4, 2, S("abcd5e"));
+ test(S("abcde"), 4, 0, S("12345"), 5, 0, S("abcde"));
+ test(S("abcde"), 4, 0, S("12345"), 5, 1, S("abcde"));
+ test(S("abcde"), 4, 0, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcde"), 4, 0, S("1234567890"), 0, 0, S("abcde"));
+ test(S("abcde"), 4, 0, S("1234567890"), 0, 1, S("abcd1e"));
+ test(S("abcde"), 4, 0, S("1234567890"), 0, 5, S("abcd12345e"));
+ test(S("abcde"), 4, 0, S("1234567890"), 0, 9, S("abcd123456789e"));
+ test(S("abcde"), 4, 0, S("1234567890"), 0, 10, S("abcd1234567890e"));
+ test(S("abcde"), 4, 0, S("1234567890"), 0, 11, S("abcd1234567890e"));
+ test(S("abcde"), 4, 0, S("1234567890"), 1, 0, S("abcde"));
+ test(S("abcde"), 4, 0, S("1234567890"), 1, 1, S("abcd2e"));
+ test(S("abcde"), 4, 0, S("1234567890"), 1, 4, S("abcd2345e"));
+ test(S("abcde"), 4, 0, S("1234567890"), 1, 8, S("abcd23456789e"));
+ test(S("abcde"), 4, 0, S("1234567890"), 1, 9, S("abcd234567890e"));
+ test(S("abcde"), 4, 0, S("1234567890"), 1, 10, S("abcd234567890e"));
+ test(S("abcde"), 4, 0, S("1234567890"), 5, 0, S("abcde"));
+ test(S("abcde"), 4, 0, S("1234567890"), 5, 1, S("abcd6e"));
+ test(S("abcde"), 4, 0, S("1234567890"), 5, 2, S("abcd67e"));
+ test(S("abcde"), 4, 0, S("1234567890"), 5, 4, S("abcd6789e"));
+ test(S("abcde"), 4, 0, S("1234567890"), 5, 5, S("abcd67890e"));
+ test(S("abcde"), 4, 0, S("1234567890"), 5, 6, S("abcd67890e"));
+ test(S("abcde"), 4, 0, S("1234567890"), 9, 0, S("abcde"));
+ test(S("abcde"), 4, 0, S("1234567890"), 9, 1, S("abcd0e"));
+ test(S("abcde"), 4, 0, S("1234567890"), 9, 2, S("abcd0e"));
+ test(S("abcde"), 4, 0, S("1234567890"), 10, 0, S("abcde"));
+ test(S("abcde"), 4, 0, S("1234567890"), 10, 1, S("abcde"));
+ test(S("abcde"), 4, 0, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcde"), 4, 0, S("12345678901234567890"), 0, 0, S("abcde"));
+ test(S("abcde"), 4, 0, S("12345678901234567890"), 0, 1, S("abcd1e"));
+ test(S("abcde"), 4, 0, S("12345678901234567890"), 0, 10, S("abcd1234567890e"));
+ test(S("abcde"), 4, 0, S("12345678901234567890"), 0, 19, S("abcd1234567890123456789e"));
+ test(S("abcde"), 4, 0, S("12345678901234567890"), 0, 20, S("abcd12345678901234567890e"));
+ test(S("abcde"), 4, 0, S("12345678901234567890"), 0, 21, S("abcd12345678901234567890e"));
+ test(S("abcde"), 4, 0, S("12345678901234567890"), 1, 0, S("abcde"));
+ test(S("abcde"), 4, 0, S("12345678901234567890"), 1, 1, S("abcd2e"));
+ test(S("abcde"), 4, 0, S("12345678901234567890"), 1, 9, S("abcd234567890e"));
+ test(S("abcde"), 4, 0, S("12345678901234567890"), 1, 18, S("abcd234567890123456789e"));
+ test(S("abcde"), 4, 0, S("12345678901234567890"), 1, 19, S("abcd2345678901234567890e"));
+ test(S("abcde"), 4, 0, S("12345678901234567890"), 1, 20, S("abcd2345678901234567890e"));
+ test(S("abcde"), 4, 0, S("12345678901234567890"), 10, 0, S("abcde"));
+ test(S("abcde"), 4, 0, S("12345678901234567890"), 10, 1, S("abcd1e"));
+ test(S("abcde"), 4, 0, S("12345678901234567890"), 10, 5, S("abcd12345e"));
+ test(S("abcde"), 4, 0, S("12345678901234567890"), 10, 9, S("abcd123456789e"));
+ test(S("abcde"), 4, 0, S("12345678901234567890"), 10, 10, S("abcd1234567890e"));
+ test(S("abcde"), 4, 0, S("12345678901234567890"), 10, 11, S("abcd1234567890e"));
+ test(S("abcde"), 4, 0, S("12345678901234567890"), 19, 0, S("abcde"));
+ test(S("abcde"), 4, 0, S("12345678901234567890"), 19, 1, S("abcd0e"));
+ test(S("abcde"), 4, 0, S("12345678901234567890"), 19, 2, S("abcd0e"));
+ test(S("abcde"), 4, 0, S("12345678901234567890"), 20, 0, S("abcde"));
+ test(S("abcde"), 4, 0, S("12345678901234567890"), 20, 1, S("abcde"));
+ test(S("abcde"), 4, 0, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcde"), 4, 1, S(""), 0, 0, S("abcd"));
+ test(S("abcde"), 4, 1, S(""), 0, 1, S("abcd"));
+ test(S("abcde"), 4, 1, S(""), 1, 0, S("can't happen"));
+ test(S("abcde"), 4, 1, S("12345"), 0, 0, S("abcd"));
+ test(S("abcde"), 4, 1, S("12345"), 0, 1, S("abcd1"));
+ test(S("abcde"), 4, 1, S("12345"), 0, 2, S("abcd12"));
+ test(S("abcde"), 4, 1, S("12345"), 0, 4, S("abcd1234"));
+ test(S("abcde"), 4, 1, S("12345"), 0, 5, S("abcd12345"));
+ test(S("abcde"), 4, 1, S("12345"), 0, 6, S("abcd12345"));
+ test(S("abcde"), 4, 1, S("12345"), 1, 0, S("abcd"));
+ test(S("abcde"), 4, 1, S("12345"), 1, 1, S("abcd2"));
+ test(S("abcde"), 4, 1, S("12345"), 1, 2, S("abcd23"));
+ test(S("abcde"), 4, 1, S("12345"), 1, 3, S("abcd234"));
+ test(S("abcde"), 4, 1, S("12345"), 1, 4, S("abcd2345"));
+ test(S("abcde"), 4, 1, S("12345"), 1, 5, S("abcd2345"));
+ test(S("abcde"), 4, 1, S("12345"), 2, 0, S("abcd"));
+ test(S("abcde"), 4, 1, S("12345"), 2, 1, S("abcd3"));
+ test(S("abcde"), 4, 1, S("12345"), 2, 2, S("abcd34"));
+ test(S("abcde"), 4, 1, S("12345"), 2, 3, S("abcd345"));
+ test(S("abcde"), 4, 1, S("12345"), 2, 4, S("abcd345"));
+ test(S("abcde"), 4, 1, S("12345"), 4, 0, S("abcd"));
+ test(S("abcde"), 4, 1, S("12345"), 4, 1, S("abcd5"));
+ test(S("abcde"), 4, 1, S("12345"), 4, 2, S("abcd5"));
+ test(S("abcde"), 4, 1, S("12345"), 5, 0, S("abcd"));
+ test(S("abcde"), 4, 1, S("12345"), 5, 1, S("abcd"));
+ test(S("abcde"), 4, 1, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcde"), 4, 1, S("1234567890"), 0, 0, S("abcd"));
+ test(S("abcde"), 4, 1, S("1234567890"), 0, 1, S("abcd1"));
+ test(S("abcde"), 4, 1, S("1234567890"), 0, 5, S("abcd12345"));
+ test(S("abcde"), 4, 1, S("1234567890"), 0, 9, S("abcd123456789"));
+ test(S("abcde"), 4, 1, S("1234567890"), 0, 10, S("abcd1234567890"));
+ test(S("abcde"), 4, 1, S("1234567890"), 0, 11, S("abcd1234567890"));
+ test(S("abcde"), 4, 1, S("1234567890"), 1, 0, S("abcd"));
+ test(S("abcde"), 4, 1, S("1234567890"), 1, 1, S("abcd2"));
+ test(S("abcde"), 4, 1, S("1234567890"), 1, 4, S("abcd2345"));
+ test(S("abcde"), 4, 1, S("1234567890"), 1, 8, S("abcd23456789"));
+ test(S("abcde"), 4, 1, S("1234567890"), 1, 9, S("abcd234567890"));
+ test(S("abcde"), 4, 1, S("1234567890"), 1, 10, S("abcd234567890"));
+ test(S("abcde"), 4, 1, S("1234567890"), 5, 0, S("abcd"));
+ test(S("abcde"), 4, 1, S("1234567890"), 5, 1, S("abcd6"));
+ test(S("abcde"), 4, 1, S("1234567890"), 5, 2, S("abcd67"));
+ test(S("abcde"), 4, 1, S("1234567890"), 5, 4, S("abcd6789"));
+ test(S("abcde"), 4, 1, S("1234567890"), 5, 5, S("abcd67890"));
+ test(S("abcde"), 4, 1, S("1234567890"), 5, 6, S("abcd67890"));
+ test(S("abcde"), 4, 1, S("1234567890"), 9, 0, S("abcd"));
+ test(S("abcde"), 4, 1, S("1234567890"), 9, 1, S("abcd0"));
+}
+
+template <class S>
+void test16()
+{
+ test(S("abcde"), 4, 1, S("1234567890"), 9, 2, S("abcd0"));
+ test(S("abcde"), 4, 1, S("1234567890"), 10, 0, S("abcd"));
+ test(S("abcde"), 4, 1, S("1234567890"), 10, 1, S("abcd"));
+ test(S("abcde"), 4, 1, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcde"), 4, 1, S("12345678901234567890"), 0, 0, S("abcd"));
+ test(S("abcde"), 4, 1, S("12345678901234567890"), 0, 1, S("abcd1"));
+ test(S("abcde"), 4, 1, S("12345678901234567890"), 0, 10, S("abcd1234567890"));
+ test(S("abcde"), 4, 1, S("12345678901234567890"), 0, 19, S("abcd1234567890123456789"));
+ test(S("abcde"), 4, 1, S("12345678901234567890"), 0, 20, S("abcd12345678901234567890"));
+ test(S("abcde"), 4, 1, S("12345678901234567890"), 0, 21, S("abcd12345678901234567890"));
+ test(S("abcde"), 4, 1, S("12345678901234567890"), 1, 0, S("abcd"));
+ test(S("abcde"), 4, 1, S("12345678901234567890"), 1, 1, S("abcd2"));
+ test(S("abcde"), 4, 1, S("12345678901234567890"), 1, 9, S("abcd234567890"));
+ test(S("abcde"), 4, 1, S("12345678901234567890"), 1, 18, S("abcd234567890123456789"));
+ test(S("abcde"), 4, 1, S("12345678901234567890"), 1, 19, S("abcd2345678901234567890"));
+ test(S("abcde"), 4, 1, S("12345678901234567890"), 1, 20, S("abcd2345678901234567890"));
+ test(S("abcde"), 4, 1, S("12345678901234567890"), 10, 0, S("abcd"));
+ test(S("abcde"), 4, 1, S("12345678901234567890"), 10, 1, S("abcd1"));
+ test(S("abcde"), 4, 1, S("12345678901234567890"), 10, 5, S("abcd12345"));
+ test(S("abcde"), 4, 1, S("12345678901234567890"), 10, 9, S("abcd123456789"));
+ test(S("abcde"), 4, 1, S("12345678901234567890"), 10, 10, S("abcd1234567890"));
+ test(S("abcde"), 4, 1, S("12345678901234567890"), 10, 11, S("abcd1234567890"));
+ test(S("abcde"), 4, 1, S("12345678901234567890"), 19, 0, S("abcd"));
+ test(S("abcde"), 4, 1, S("12345678901234567890"), 19, 1, S("abcd0"));
+ test(S("abcde"), 4, 1, S("12345678901234567890"), 19, 2, S("abcd0"));
+ test(S("abcde"), 4, 1, S("12345678901234567890"), 20, 0, S("abcd"));
+ test(S("abcde"), 4, 1, S("12345678901234567890"), 20, 1, S("abcd"));
+ test(S("abcde"), 4, 1, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcde"), 4, 2, S(""), 0, 0, S("abcd"));
+ test(S("abcde"), 4, 2, S(""), 0, 1, S("abcd"));
+ test(S("abcde"), 4, 2, S(""), 1, 0, S("can't happen"));
+ test(S("abcde"), 4, 2, S("12345"), 0, 0, S("abcd"));
+ test(S("abcde"), 4, 2, S("12345"), 0, 1, S("abcd1"));
+ test(S("abcde"), 4, 2, S("12345"), 0, 2, S("abcd12"));
+ test(S("abcde"), 4, 2, S("12345"), 0, 4, S("abcd1234"));
+ test(S("abcde"), 4, 2, S("12345"), 0, 5, S("abcd12345"));
+ test(S("abcde"), 4, 2, S("12345"), 0, 6, S("abcd12345"));
+ test(S("abcde"), 4, 2, S("12345"), 1, 0, S("abcd"));
+ test(S("abcde"), 4, 2, S("12345"), 1, 1, S("abcd2"));
+ test(S("abcde"), 4, 2, S("12345"), 1, 2, S("abcd23"));
+ test(S("abcde"), 4, 2, S("12345"), 1, 3, S("abcd234"));
+ test(S("abcde"), 4, 2, S("12345"), 1, 4, S("abcd2345"));
+ test(S("abcde"), 4, 2, S("12345"), 1, 5, S("abcd2345"));
+ test(S("abcde"), 4, 2, S("12345"), 2, 0, S("abcd"));
+ test(S("abcde"), 4, 2, S("12345"), 2, 1, S("abcd3"));
+ test(S("abcde"), 4, 2, S("12345"), 2, 2, S("abcd34"));
+ test(S("abcde"), 4, 2, S("12345"), 2, 3, S("abcd345"));
+ test(S("abcde"), 4, 2, S("12345"), 2, 4, S("abcd345"));
+ test(S("abcde"), 4, 2, S("12345"), 4, 0, S("abcd"));
+ test(S("abcde"), 4, 2, S("12345"), 4, 1, S("abcd5"));
+ test(S("abcde"), 4, 2, S("12345"), 4, 2, S("abcd5"));
+ test(S("abcde"), 4, 2, S("12345"), 5, 0, S("abcd"));
+ test(S("abcde"), 4, 2, S("12345"), 5, 1, S("abcd"));
+ test(S("abcde"), 4, 2, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcde"), 4, 2, S("1234567890"), 0, 0, S("abcd"));
+ test(S("abcde"), 4, 2, S("1234567890"), 0, 1, S("abcd1"));
+ test(S("abcde"), 4, 2, S("1234567890"), 0, 5, S("abcd12345"));
+ test(S("abcde"), 4, 2, S("1234567890"), 0, 9, S("abcd123456789"));
+ test(S("abcde"), 4, 2, S("1234567890"), 0, 10, S("abcd1234567890"));
+ test(S("abcde"), 4, 2, S("1234567890"), 0, 11, S("abcd1234567890"));
+ test(S("abcde"), 4, 2, S("1234567890"), 1, 0, S("abcd"));
+ test(S("abcde"), 4, 2, S("1234567890"), 1, 1, S("abcd2"));
+ test(S("abcde"), 4, 2, S("1234567890"), 1, 4, S("abcd2345"));
+ test(S("abcde"), 4, 2, S("1234567890"), 1, 8, S("abcd23456789"));
+ test(S("abcde"), 4, 2, S("1234567890"), 1, 9, S("abcd234567890"));
+ test(S("abcde"), 4, 2, S("1234567890"), 1, 10, S("abcd234567890"));
+ test(S("abcde"), 4, 2, S("1234567890"), 5, 0, S("abcd"));
+ test(S("abcde"), 4, 2, S("1234567890"), 5, 1, S("abcd6"));
+ test(S("abcde"), 4, 2, S("1234567890"), 5, 2, S("abcd67"));
+ test(S("abcde"), 4, 2, S("1234567890"), 5, 4, S("abcd6789"));
+ test(S("abcde"), 4, 2, S("1234567890"), 5, 5, S("abcd67890"));
+ test(S("abcde"), 4, 2, S("1234567890"), 5, 6, S("abcd67890"));
+ test(S("abcde"), 4, 2, S("1234567890"), 9, 0, S("abcd"));
+ test(S("abcde"), 4, 2, S("1234567890"), 9, 1, S("abcd0"));
+ test(S("abcde"), 4, 2, S("1234567890"), 9, 2, S("abcd0"));
+ test(S("abcde"), 4, 2, S("1234567890"), 10, 0, S("abcd"));
+ test(S("abcde"), 4, 2, S("1234567890"), 10, 1, S("abcd"));
+ test(S("abcde"), 4, 2, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcde"), 4, 2, S("12345678901234567890"), 0, 0, S("abcd"));
+ test(S("abcde"), 4, 2, S("12345678901234567890"), 0, 1, S("abcd1"));
+ test(S("abcde"), 4, 2, S("12345678901234567890"), 0, 10, S("abcd1234567890"));
+ test(S("abcde"), 4, 2, S("12345678901234567890"), 0, 19, S("abcd1234567890123456789"));
+ test(S("abcde"), 4, 2, S("12345678901234567890"), 0, 20, S("abcd12345678901234567890"));
+ test(S("abcde"), 4, 2, S("12345678901234567890"), 0, 21, S("abcd12345678901234567890"));
+ test(S("abcde"), 4, 2, S("12345678901234567890"), 1, 0, S("abcd"));
+ test(S("abcde"), 4, 2, S("12345678901234567890"), 1, 1, S("abcd2"));
+ test(S("abcde"), 4, 2, S("12345678901234567890"), 1, 9, S("abcd234567890"));
+ test(S("abcde"), 4, 2, S("12345678901234567890"), 1, 18, S("abcd234567890123456789"));
+ test(S("abcde"), 4, 2, S("12345678901234567890"), 1, 19, S("abcd2345678901234567890"));
+ test(S("abcde"), 4, 2, S("12345678901234567890"), 1, 20, S("abcd2345678901234567890"));
+ test(S("abcde"), 4, 2, S("12345678901234567890"), 10, 0, S("abcd"));
+ test(S("abcde"), 4, 2, S("12345678901234567890"), 10, 1, S("abcd1"));
+ test(S("abcde"), 4, 2, S("12345678901234567890"), 10, 5, S("abcd12345"));
+ test(S("abcde"), 4, 2, S("12345678901234567890"), 10, 9, S("abcd123456789"));
+ test(S("abcde"), 4, 2, S("12345678901234567890"), 10, 10, S("abcd1234567890"));
+ test(S("abcde"), 4, 2, S("12345678901234567890"), 10, 11, S("abcd1234567890"));
+ test(S("abcde"), 4, 2, S("12345678901234567890"), 19, 0, S("abcd"));
+ test(S("abcde"), 4, 2, S("12345678901234567890"), 19, 1, S("abcd0"));
+ test(S("abcde"), 4, 2, S("12345678901234567890"), 19, 2, S("abcd0"));
+ test(S("abcde"), 4, 2, S("12345678901234567890"), 20, 0, S("abcd"));
+}
+
+template <class S>
+void test17()
+{
+ test(S("abcde"), 4, 2, S("12345678901234567890"), 20, 1, S("abcd"));
+ test(S("abcde"), 4, 2, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcde"), 5, 0, S(""), 0, 0, S("abcde"));
+ test(S("abcde"), 5, 0, S(""), 0, 1, S("abcde"));
+ test(S("abcde"), 5, 0, S(""), 1, 0, S("can't happen"));
+ test(S("abcde"), 5, 0, S("12345"), 0, 0, S("abcde"));
+ test(S("abcde"), 5, 0, S("12345"), 0, 1, S("abcde1"));
+ test(S("abcde"), 5, 0, S("12345"), 0, 2, S("abcde12"));
+ test(S("abcde"), 5, 0, S("12345"), 0, 4, S("abcde1234"));
+ test(S("abcde"), 5, 0, S("12345"), 0, 5, S("abcde12345"));
+ test(S("abcde"), 5, 0, S("12345"), 0, 6, S("abcde12345"));
+ test(S("abcde"), 5, 0, S("12345"), 1, 0, S("abcde"));
+ test(S("abcde"), 5, 0, S("12345"), 1, 1, S("abcde2"));
+ test(S("abcde"), 5, 0, S("12345"), 1, 2, S("abcde23"));
+ test(S("abcde"), 5, 0, S("12345"), 1, 3, S("abcde234"));
+ test(S("abcde"), 5, 0, S("12345"), 1, 4, S("abcde2345"));
+ test(S("abcde"), 5, 0, S("12345"), 1, 5, S("abcde2345"));
+ test(S("abcde"), 5, 0, S("12345"), 2, 0, S("abcde"));
+ test(S("abcde"), 5, 0, S("12345"), 2, 1, S("abcde3"));
+ test(S("abcde"), 5, 0, S("12345"), 2, 2, S("abcde34"));
+ test(S("abcde"), 5, 0, S("12345"), 2, 3, S("abcde345"));
+ test(S("abcde"), 5, 0, S("12345"), 2, 4, S("abcde345"));
+ test(S("abcde"), 5, 0, S("12345"), 4, 0, S("abcde"));
+ test(S("abcde"), 5, 0, S("12345"), 4, 1, S("abcde5"));
+ test(S("abcde"), 5, 0, S("12345"), 4, 2, S("abcde5"));
+ test(S("abcde"), 5, 0, S("12345"), 5, 0, S("abcde"));
+ test(S("abcde"), 5, 0, S("12345"), 5, 1, S("abcde"));
+ test(S("abcde"), 5, 0, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcde"), 5, 0, S("1234567890"), 0, 0, S("abcde"));
+ test(S("abcde"), 5, 0, S("1234567890"), 0, 1, S("abcde1"));
+ test(S("abcde"), 5, 0, S("1234567890"), 0, 5, S("abcde12345"));
+ test(S("abcde"), 5, 0, S("1234567890"), 0, 9, S("abcde123456789"));
+ test(S("abcde"), 5, 0, S("1234567890"), 0, 10, S("abcde1234567890"));
+ test(S("abcde"), 5, 0, S("1234567890"), 0, 11, S("abcde1234567890"));
+ test(S("abcde"), 5, 0, S("1234567890"), 1, 0, S("abcde"));
+ test(S("abcde"), 5, 0, S("1234567890"), 1, 1, S("abcde2"));
+ test(S("abcde"), 5, 0, S("1234567890"), 1, 4, S("abcde2345"));
+ test(S("abcde"), 5, 0, S("1234567890"), 1, 8, S("abcde23456789"));
+ test(S("abcde"), 5, 0, S("1234567890"), 1, 9, S("abcde234567890"));
+ test(S("abcde"), 5, 0, S("1234567890"), 1, 10, S("abcde234567890"));
+ test(S("abcde"), 5, 0, S("1234567890"), 5, 0, S("abcde"));
+ test(S("abcde"), 5, 0, S("1234567890"), 5, 1, S("abcde6"));
+ test(S("abcde"), 5, 0, S("1234567890"), 5, 2, S("abcde67"));
+ test(S("abcde"), 5, 0, S("1234567890"), 5, 4, S("abcde6789"));
+ test(S("abcde"), 5, 0, S("1234567890"), 5, 5, S("abcde67890"));
+ test(S("abcde"), 5, 0, S("1234567890"), 5, 6, S("abcde67890"));
+ test(S("abcde"), 5, 0, S("1234567890"), 9, 0, S("abcde"));
+ test(S("abcde"), 5, 0, S("1234567890"), 9, 1, S("abcde0"));
+ test(S("abcde"), 5, 0, S("1234567890"), 9, 2, S("abcde0"));
+ test(S("abcde"), 5, 0, S("1234567890"), 10, 0, S("abcde"));
+ test(S("abcde"), 5, 0, S("1234567890"), 10, 1, S("abcde"));
+ test(S("abcde"), 5, 0, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcde"), 5, 0, S("12345678901234567890"), 0, 0, S("abcde"));
+ test(S("abcde"), 5, 0, S("12345678901234567890"), 0, 1, S("abcde1"));
+ test(S("abcde"), 5, 0, S("12345678901234567890"), 0, 10, S("abcde1234567890"));
+ test(S("abcde"), 5, 0, S("12345678901234567890"), 0, 19, S("abcde1234567890123456789"));
+ test(S("abcde"), 5, 0, S("12345678901234567890"), 0, 20, S("abcde12345678901234567890"));
+ test(S("abcde"), 5, 0, S("12345678901234567890"), 0, 21, S("abcde12345678901234567890"));
+ test(S("abcde"), 5, 0, S("12345678901234567890"), 1, 0, S("abcde"));
+ test(S("abcde"), 5, 0, S("12345678901234567890"), 1, 1, S("abcde2"));
+ test(S("abcde"), 5, 0, S("12345678901234567890"), 1, 9, S("abcde234567890"));
+ test(S("abcde"), 5, 0, S("12345678901234567890"), 1, 18, S("abcde234567890123456789"));
+ test(S("abcde"), 5, 0, S("12345678901234567890"), 1, 19, S("abcde2345678901234567890"));
+ test(S("abcde"), 5, 0, S("12345678901234567890"), 1, 20, S("abcde2345678901234567890"));
+ test(S("abcde"), 5, 0, S("12345678901234567890"), 10, 0, S("abcde"));
+ test(S("abcde"), 5, 0, S("12345678901234567890"), 10, 1, S("abcde1"));
+ test(S("abcde"), 5, 0, S("12345678901234567890"), 10, 5, S("abcde12345"));
+ test(S("abcde"), 5, 0, S("12345678901234567890"), 10, 9, S("abcde123456789"));
+ test(S("abcde"), 5, 0, S("12345678901234567890"), 10, 10, S("abcde1234567890"));
+ test(S("abcde"), 5, 0, S("12345678901234567890"), 10, 11, S("abcde1234567890"));
+ test(S("abcde"), 5, 0, S("12345678901234567890"), 19, 0, S("abcde"));
+ test(S("abcde"), 5, 0, S("12345678901234567890"), 19, 1, S("abcde0"));
+ test(S("abcde"), 5, 0, S("12345678901234567890"), 19, 2, S("abcde0"));
+ test(S("abcde"), 5, 0, S("12345678901234567890"), 20, 0, S("abcde"));
+ test(S("abcde"), 5, 0, S("12345678901234567890"), 20, 1, S("abcde"));
+ test(S("abcde"), 5, 0, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcde"), 5, 1, S(""), 0, 0, S("abcde"));
+ test(S("abcde"), 5, 1, S(""), 0, 1, S("abcde"));
+ test(S("abcde"), 5, 1, S(""), 1, 0, S("can't happen"));
+ test(S("abcde"), 5, 1, S("12345"), 0, 0, S("abcde"));
+ test(S("abcde"), 5, 1, S("12345"), 0, 1, S("abcde1"));
+ test(S("abcde"), 5, 1, S("12345"), 0, 2, S("abcde12"));
+ test(S("abcde"), 5, 1, S("12345"), 0, 4, S("abcde1234"));
+ test(S("abcde"), 5, 1, S("12345"), 0, 5, S("abcde12345"));
+ test(S("abcde"), 5, 1, S("12345"), 0, 6, S("abcde12345"));
+ test(S("abcde"), 5, 1, S("12345"), 1, 0, S("abcde"));
+ test(S("abcde"), 5, 1, S("12345"), 1, 1, S("abcde2"));
+ test(S("abcde"), 5, 1, S("12345"), 1, 2, S("abcde23"));
+ test(S("abcde"), 5, 1, S("12345"), 1, 3, S("abcde234"));
+ test(S("abcde"), 5, 1, S("12345"), 1, 4, S("abcde2345"));
+ test(S("abcde"), 5, 1, S("12345"), 1, 5, S("abcde2345"));
+ test(S("abcde"), 5, 1, S("12345"), 2, 0, S("abcde"));
+ test(S("abcde"), 5, 1, S("12345"), 2, 1, S("abcde3"));
+ test(S("abcde"), 5, 1, S("12345"), 2, 2, S("abcde34"));
+ test(S("abcde"), 5, 1, S("12345"), 2, 3, S("abcde345"));
+ test(S("abcde"), 5, 1, S("12345"), 2, 4, S("abcde345"));
+ test(S("abcde"), 5, 1, S("12345"), 4, 0, S("abcde"));
+ test(S("abcde"), 5, 1, S("12345"), 4, 1, S("abcde5"));
+ test(S("abcde"), 5, 1, S("12345"), 4, 2, S("abcde5"));
+ test(S("abcde"), 5, 1, S("12345"), 5, 0, S("abcde"));
+}
+
+template <class S>
+void test18()
+{
+ test(S("abcde"), 5, 1, S("12345"), 5, 1, S("abcde"));
+ test(S("abcde"), 5, 1, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcde"), 5, 1, S("1234567890"), 0, 0, S("abcde"));
+ test(S("abcde"), 5, 1, S("1234567890"), 0, 1, S("abcde1"));
+ test(S("abcde"), 5, 1, S("1234567890"), 0, 5, S("abcde12345"));
+ test(S("abcde"), 5, 1, S("1234567890"), 0, 9, S("abcde123456789"));
+ test(S("abcde"), 5, 1, S("1234567890"), 0, 10, S("abcde1234567890"));
+ test(S("abcde"), 5, 1, S("1234567890"), 0, 11, S("abcde1234567890"));
+ test(S("abcde"), 5, 1, S("1234567890"), 1, 0, S("abcde"));
+ test(S("abcde"), 5, 1, S("1234567890"), 1, 1, S("abcde2"));
+ test(S("abcde"), 5, 1, S("1234567890"), 1, 4, S("abcde2345"));
+ test(S("abcde"), 5, 1, S("1234567890"), 1, 8, S("abcde23456789"));
+ test(S("abcde"), 5, 1, S("1234567890"), 1, 9, S("abcde234567890"));
+ test(S("abcde"), 5, 1, S("1234567890"), 1, 10, S("abcde234567890"));
+ test(S("abcde"), 5, 1, S("1234567890"), 5, 0, S("abcde"));
+ test(S("abcde"), 5, 1, S("1234567890"), 5, 1, S("abcde6"));
+ test(S("abcde"), 5, 1, S("1234567890"), 5, 2, S("abcde67"));
+ test(S("abcde"), 5, 1, S("1234567890"), 5, 4, S("abcde6789"));
+ test(S("abcde"), 5, 1, S("1234567890"), 5, 5, S("abcde67890"));
+ test(S("abcde"), 5, 1, S("1234567890"), 5, 6, S("abcde67890"));
+ test(S("abcde"), 5, 1, S("1234567890"), 9, 0, S("abcde"));
+ test(S("abcde"), 5, 1, S("1234567890"), 9, 1, S("abcde0"));
+ test(S("abcde"), 5, 1, S("1234567890"), 9, 2, S("abcde0"));
+ test(S("abcde"), 5, 1, S("1234567890"), 10, 0, S("abcde"));
+ test(S("abcde"), 5, 1, S("1234567890"), 10, 1, S("abcde"));
+ test(S("abcde"), 5, 1, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcde"), 5, 1, S("12345678901234567890"), 0, 0, S("abcde"));
+ test(S("abcde"), 5, 1, S("12345678901234567890"), 0, 1, S("abcde1"));
+ test(S("abcde"), 5, 1, S("12345678901234567890"), 0, 10, S("abcde1234567890"));
+ test(S("abcde"), 5, 1, S("12345678901234567890"), 0, 19, S("abcde1234567890123456789"));
+ test(S("abcde"), 5, 1, S("12345678901234567890"), 0, 20, S("abcde12345678901234567890"));
+ test(S("abcde"), 5, 1, S("12345678901234567890"), 0, 21, S("abcde12345678901234567890"));
+ test(S("abcde"), 5, 1, S("12345678901234567890"), 1, 0, S("abcde"));
+ test(S("abcde"), 5, 1, S("12345678901234567890"), 1, 1, S("abcde2"));
+ test(S("abcde"), 5, 1, S("12345678901234567890"), 1, 9, S("abcde234567890"));
+ test(S("abcde"), 5, 1, S("12345678901234567890"), 1, 18, S("abcde234567890123456789"));
+ test(S("abcde"), 5, 1, S("12345678901234567890"), 1, 19, S("abcde2345678901234567890"));
+ test(S("abcde"), 5, 1, S("12345678901234567890"), 1, 20, S("abcde2345678901234567890"));
+ test(S("abcde"), 5, 1, S("12345678901234567890"), 10, 0, S("abcde"));
+ test(S("abcde"), 5, 1, S("12345678901234567890"), 10, 1, S("abcde1"));
+ test(S("abcde"), 5, 1, S("12345678901234567890"), 10, 5, S("abcde12345"));
+ test(S("abcde"), 5, 1, S("12345678901234567890"), 10, 9, S("abcde123456789"));
+ test(S("abcde"), 5, 1, S("12345678901234567890"), 10, 10, S("abcde1234567890"));
+ test(S("abcde"), 5, 1, S("12345678901234567890"), 10, 11, S("abcde1234567890"));
+ test(S("abcde"), 5, 1, S("12345678901234567890"), 19, 0, S("abcde"));
+ test(S("abcde"), 5, 1, S("12345678901234567890"), 19, 1, S("abcde0"));
+ test(S("abcde"), 5, 1, S("12345678901234567890"), 19, 2, S("abcde0"));
+ test(S("abcde"), 5, 1, S("12345678901234567890"), 20, 0, S("abcde"));
+ test(S("abcde"), 5, 1, S("12345678901234567890"), 20, 1, S("abcde"));
+ test(S("abcde"), 5, 1, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcde"), 6, 0, S(""), 0, 0, S("can't happen"));
+ test(S("abcde"), 6, 0, S(""), 0, 1, S("can't happen"));
+ test(S("abcde"), 6, 0, S(""), 1, 0, S("can't happen"));
+ test(S("abcde"), 6, 0, S("12345"), 0, 0, S("can't happen"));
+ test(S("abcde"), 6, 0, S("12345"), 0, 1, S("can't happen"));
+ test(S("abcde"), 6, 0, S("12345"), 0, 2, S("can't happen"));
+ test(S("abcde"), 6, 0, S("12345"), 0, 4, S("can't happen"));
+ test(S("abcde"), 6, 0, S("12345"), 0, 5, S("can't happen"));
+ test(S("abcde"), 6, 0, S("12345"), 0, 6, S("can't happen"));
+ test(S("abcde"), 6, 0, S("12345"), 1, 0, S("can't happen"));
+ test(S("abcde"), 6, 0, S("12345"), 1, 1, S("can't happen"));
+ test(S("abcde"), 6, 0, S("12345"), 1, 2, S("can't happen"));
+ test(S("abcde"), 6, 0, S("12345"), 1, 3, S("can't happen"));
+ test(S("abcde"), 6, 0, S("12345"), 1, 4, S("can't happen"));
+ test(S("abcde"), 6, 0, S("12345"), 1, 5, S("can't happen"));
+ test(S("abcde"), 6, 0, S("12345"), 2, 0, S("can't happen"));
+ test(S("abcde"), 6, 0, S("12345"), 2, 1, S("can't happen"));
+ test(S("abcde"), 6, 0, S("12345"), 2, 2, S("can't happen"));
+ test(S("abcde"), 6, 0, S("12345"), 2, 3, S("can't happen"));
+ test(S("abcde"), 6, 0, S("12345"), 2, 4, S("can't happen"));
+ test(S("abcde"), 6, 0, S("12345"), 4, 0, S("can't happen"));
+ test(S("abcde"), 6, 0, S("12345"), 4, 1, S("can't happen"));
+ test(S("abcde"), 6, 0, S("12345"), 4, 2, S("can't happen"));
+ test(S("abcde"), 6, 0, S("12345"), 5, 0, S("can't happen"));
+ test(S("abcde"), 6, 0, S("12345"), 5, 1, S("can't happen"));
+ test(S("abcde"), 6, 0, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcde"), 6, 0, S("1234567890"), 0, 0, S("can't happen"));
+ test(S("abcde"), 6, 0, S("1234567890"), 0, 1, S("can't happen"));
+ test(S("abcde"), 6, 0, S("1234567890"), 0, 5, S("can't happen"));
+ test(S("abcde"), 6, 0, S("1234567890"), 0, 9, S("can't happen"));
+ test(S("abcde"), 6, 0, S("1234567890"), 0, 10, S("can't happen"));
+ test(S("abcde"), 6, 0, S("1234567890"), 0, 11, S("can't happen"));
+ test(S("abcde"), 6, 0, S("1234567890"), 1, 0, S("can't happen"));
+ test(S("abcde"), 6, 0, S("1234567890"), 1, 1, S("can't happen"));
+ test(S("abcde"), 6, 0, S("1234567890"), 1, 4, S("can't happen"));
+ test(S("abcde"), 6, 0, S("1234567890"), 1, 8, S("can't happen"));
+ test(S("abcde"), 6, 0, S("1234567890"), 1, 9, S("can't happen"));
+ test(S("abcde"), 6, 0, S("1234567890"), 1, 10, S("can't happen"));
+ test(S("abcde"), 6, 0, S("1234567890"), 5, 0, S("can't happen"));
+ test(S("abcde"), 6, 0, S("1234567890"), 5, 1, S("can't happen"));
+ test(S("abcde"), 6, 0, S("1234567890"), 5, 2, S("can't happen"));
+ test(S("abcde"), 6, 0, S("1234567890"), 5, 4, S("can't happen"));
+ test(S("abcde"), 6, 0, S("1234567890"), 5, 5, S("can't happen"));
+ test(S("abcde"), 6, 0, S("1234567890"), 5, 6, S("can't happen"));
+ test(S("abcde"), 6, 0, S("1234567890"), 9, 0, S("can't happen"));
+ test(S("abcde"), 6, 0, S("1234567890"), 9, 1, S("can't happen"));
+ test(S("abcde"), 6, 0, S("1234567890"), 9, 2, S("can't happen"));
+ test(S("abcde"), 6, 0, S("1234567890"), 10, 0, S("can't happen"));
+ test(S("abcde"), 6, 0, S("1234567890"), 10, 1, S("can't happen"));
+ test(S("abcde"), 6, 0, S("1234567890"), 11, 0, S("can't happen"));
+}
+
+template <class S>
+void test19()
+{
+ test(S("abcde"), 6, 0, S("12345678901234567890"), 0, 0, S("can't happen"));
+ test(S("abcde"), 6, 0, S("12345678901234567890"), 0, 1, S("can't happen"));
+ test(S("abcde"), 6, 0, S("12345678901234567890"), 0, 10, S("can't happen"));
+ test(S("abcde"), 6, 0, S("12345678901234567890"), 0, 19, S("can't happen"));
+ test(S("abcde"), 6, 0, S("12345678901234567890"), 0, 20, S("can't happen"));
+ test(S("abcde"), 6, 0, S("12345678901234567890"), 0, 21, S("can't happen"));
+ test(S("abcde"), 6, 0, S("12345678901234567890"), 1, 0, S("can't happen"));
+ test(S("abcde"), 6, 0, S("12345678901234567890"), 1, 1, S("can't happen"));
+ test(S("abcde"), 6, 0, S("12345678901234567890"), 1, 9, S("can't happen"));
+ test(S("abcde"), 6, 0, S("12345678901234567890"), 1, 18, S("can't happen"));
+ test(S("abcde"), 6, 0, S("12345678901234567890"), 1, 19, S("can't happen"));
+ test(S("abcde"), 6, 0, S("12345678901234567890"), 1, 20, S("can't happen"));
+ test(S("abcde"), 6, 0, S("12345678901234567890"), 10, 0, S("can't happen"));
+ test(S("abcde"), 6, 0, S("12345678901234567890"), 10, 1, S("can't happen"));
+ test(S("abcde"), 6, 0, S("12345678901234567890"), 10, 5, S("can't happen"));
+ test(S("abcde"), 6, 0, S("12345678901234567890"), 10, 9, S("can't happen"));
+ test(S("abcde"), 6, 0, S("12345678901234567890"), 10, 10, S("can't happen"));
+ test(S("abcde"), 6, 0, S("12345678901234567890"), 10, 11, S("can't happen"));
+ test(S("abcde"), 6, 0, S("12345678901234567890"), 19, 0, S("can't happen"));
+ test(S("abcde"), 6, 0, S("12345678901234567890"), 19, 1, S("can't happen"));
+ test(S("abcde"), 6, 0, S("12345678901234567890"), 19, 2, S("can't happen"));
+ test(S("abcde"), 6, 0, S("12345678901234567890"), 20, 0, S("can't happen"));
+ test(S("abcde"), 6, 0, S("12345678901234567890"), 20, 1, S("can't happen"));
+ test(S("abcde"), 6, 0, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcdefghij"), 0, 0, S(""), 0, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 0, 0, S(""), 0, 1, S("abcdefghij"));
+ test(S("abcdefghij"), 0, 0, S(""), 1, 0, S("can't happen"));
+ test(S("abcdefghij"), 0, 0, S("12345"), 0, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 0, 0, S("12345"), 0, 1, S("1abcdefghij"));
+ test(S("abcdefghij"), 0, 0, S("12345"), 0, 2, S("12abcdefghij"));
+ test(S("abcdefghij"), 0, 0, S("12345"), 0, 4, S("1234abcdefghij"));
+ test(S("abcdefghij"), 0, 0, S("12345"), 0, 5, S("12345abcdefghij"));
+ test(S("abcdefghij"), 0, 0, S("12345"), 0, 6, S("12345abcdefghij"));
+ test(S("abcdefghij"), 0, 0, S("12345"), 1, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 0, 0, S("12345"), 1, 1, S("2abcdefghij"));
+ test(S("abcdefghij"), 0, 0, S("12345"), 1, 2, S("23abcdefghij"));
+ test(S("abcdefghij"), 0, 0, S("12345"), 1, 3, S("234abcdefghij"));
+ test(S("abcdefghij"), 0, 0, S("12345"), 1, 4, S("2345abcdefghij"));
+ test(S("abcdefghij"), 0, 0, S("12345"), 1, 5, S("2345abcdefghij"));
+ test(S("abcdefghij"), 0, 0, S("12345"), 2, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 0, 0, S("12345"), 2, 1, S("3abcdefghij"));
+ test(S("abcdefghij"), 0, 0, S("12345"), 2, 2, S("34abcdefghij"));
+ test(S("abcdefghij"), 0, 0, S("12345"), 2, 3, S("345abcdefghij"));
+ test(S("abcdefghij"), 0, 0, S("12345"), 2, 4, S("345abcdefghij"));
+ test(S("abcdefghij"), 0, 0, S("12345"), 4, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 0, 0, S("12345"), 4, 1, S("5abcdefghij"));
+ test(S("abcdefghij"), 0, 0, S("12345"), 4, 2, S("5abcdefghij"));
+ test(S("abcdefghij"), 0, 0, S("12345"), 5, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 0, 0, S("12345"), 5, 1, S("abcdefghij"));
+ test(S("abcdefghij"), 0, 0, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcdefghij"), 0, 0, S("1234567890"), 0, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 0, 0, S("1234567890"), 0, 1, S("1abcdefghij"));
+ test(S("abcdefghij"), 0, 0, S("1234567890"), 0, 5, S("12345abcdefghij"));
+ test(S("abcdefghij"), 0, 0, S("1234567890"), 0, 9, S("123456789abcdefghij"));
+ test(S("abcdefghij"), 0, 0, S("1234567890"), 0, 10, S("1234567890abcdefghij"));
+ test(S("abcdefghij"), 0, 0, S("1234567890"), 0, 11, S("1234567890abcdefghij"));
+ test(S("abcdefghij"), 0, 0, S("1234567890"), 1, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 0, 0, S("1234567890"), 1, 1, S("2abcdefghij"));
+ test(S("abcdefghij"), 0, 0, S("1234567890"), 1, 4, S("2345abcdefghij"));
+ test(S("abcdefghij"), 0, 0, S("1234567890"), 1, 8, S("23456789abcdefghij"));
+ test(S("abcdefghij"), 0, 0, S("1234567890"), 1, 9, S("234567890abcdefghij"));
+ test(S("abcdefghij"), 0, 0, S("1234567890"), 1, 10, S("234567890abcdefghij"));
+ test(S("abcdefghij"), 0, 0, S("1234567890"), 5, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 0, 0, S("1234567890"), 5, 1, S("6abcdefghij"));
+ test(S("abcdefghij"), 0, 0, S("1234567890"), 5, 2, S("67abcdefghij"));
+ test(S("abcdefghij"), 0, 0, S("1234567890"), 5, 4, S("6789abcdefghij"));
+ test(S("abcdefghij"), 0, 0, S("1234567890"), 5, 5, S("67890abcdefghij"));
+ test(S("abcdefghij"), 0, 0, S("1234567890"), 5, 6, S("67890abcdefghij"));
+ test(S("abcdefghij"), 0, 0, S("1234567890"), 9, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 0, 0, S("1234567890"), 9, 1, S("0abcdefghij"));
+ test(S("abcdefghij"), 0, 0, S("1234567890"), 9, 2, S("0abcdefghij"));
+ test(S("abcdefghij"), 0, 0, S("1234567890"), 10, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 0, 0, S("1234567890"), 10, 1, S("abcdefghij"));
+ test(S("abcdefghij"), 0, 0, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 0, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 0, 1, S("1abcdefghij"));
+ test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 0, 10, S("1234567890abcdefghij"));
+ test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 0, 19, S("1234567890123456789abcdefghij"));
+ test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 0, 20, S("12345678901234567890abcdefghij"));
+ test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 0, 21, S("12345678901234567890abcdefghij"));
+ test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 1, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 1, 1, S("2abcdefghij"));
+ test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 1, 9, S("234567890abcdefghij"));
+ test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 1, 18, S("234567890123456789abcdefghij"));
+ test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 1, 19, S("2345678901234567890abcdefghij"));
+ test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 1, 20, S("2345678901234567890abcdefghij"));
+ test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 10, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 10, 1, S("1abcdefghij"));
+ test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 10, 5, S("12345abcdefghij"));
+ test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 10, 9, S("123456789abcdefghij"));
+ test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 10, 10, S("1234567890abcdefghij"));
+ test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 10, 11, S("1234567890abcdefghij"));
+ test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 19, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 19, 1, S("0abcdefghij"));
+ test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 19, 2, S("0abcdefghij"));
+ test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 20, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 20, 1, S("abcdefghij"));
+ test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcdefghij"), 0, 1, S(""), 0, 0, S("bcdefghij"));
+ test(S("abcdefghij"), 0, 1, S(""), 0, 1, S("bcdefghij"));
+}
+
+template <class S>
+void test20()
+{
+ test(S("abcdefghij"), 0, 1, S(""), 1, 0, S("can't happen"));
+ test(S("abcdefghij"), 0, 1, S("12345"), 0, 0, S("bcdefghij"));
+ test(S("abcdefghij"), 0, 1, S("12345"), 0, 1, S("1bcdefghij"));
+ test(S("abcdefghij"), 0, 1, S("12345"), 0, 2, S("12bcdefghij"));
+ test(S("abcdefghij"), 0, 1, S("12345"), 0, 4, S("1234bcdefghij"));
+ test(S("abcdefghij"), 0, 1, S("12345"), 0, 5, S("12345bcdefghij"));
+ test(S("abcdefghij"), 0, 1, S("12345"), 0, 6, S("12345bcdefghij"));
+ test(S("abcdefghij"), 0, 1, S("12345"), 1, 0, S("bcdefghij"));
+ test(S("abcdefghij"), 0, 1, S("12345"), 1, 1, S("2bcdefghij"));
+ test(S("abcdefghij"), 0, 1, S("12345"), 1, 2, S("23bcdefghij"));
+ test(S("abcdefghij"), 0, 1, S("12345"), 1, 3, S("234bcdefghij"));
+ test(S("abcdefghij"), 0, 1, S("12345"), 1, 4, S("2345bcdefghij"));
+ test(S("abcdefghij"), 0, 1, S("12345"), 1, 5, S("2345bcdefghij"));
+ test(S("abcdefghij"), 0, 1, S("12345"), 2, 0, S("bcdefghij"));
+ test(S("abcdefghij"), 0, 1, S("12345"), 2, 1, S("3bcdefghij"));
+ test(S("abcdefghij"), 0, 1, S("12345"), 2, 2, S("34bcdefghij"));
+ test(S("abcdefghij"), 0, 1, S("12345"), 2, 3, S("345bcdefghij"));
+ test(S("abcdefghij"), 0, 1, S("12345"), 2, 4, S("345bcdefghij"));
+ test(S("abcdefghij"), 0, 1, S("12345"), 4, 0, S("bcdefghij"));
+ test(S("abcdefghij"), 0, 1, S("12345"), 4, 1, S("5bcdefghij"));
+ test(S("abcdefghij"), 0, 1, S("12345"), 4, 2, S("5bcdefghij"));
+ test(S("abcdefghij"), 0, 1, S("12345"), 5, 0, S("bcdefghij"));
+ test(S("abcdefghij"), 0, 1, S("12345"), 5, 1, S("bcdefghij"));
+ test(S("abcdefghij"), 0, 1, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcdefghij"), 0, 1, S("1234567890"), 0, 0, S("bcdefghij"));
+ test(S("abcdefghij"), 0, 1, S("1234567890"), 0, 1, S("1bcdefghij"));
+ test(S("abcdefghij"), 0, 1, S("1234567890"), 0, 5, S("12345bcdefghij"));
+ test(S("abcdefghij"), 0, 1, S("1234567890"), 0, 9, S("123456789bcdefghij"));
+ test(S("abcdefghij"), 0, 1, S("1234567890"), 0, 10, S("1234567890bcdefghij"));
+ test(S("abcdefghij"), 0, 1, S("1234567890"), 0, 11, S("1234567890bcdefghij"));
+ test(S("abcdefghij"), 0, 1, S("1234567890"), 1, 0, S("bcdefghij"));
+ test(S("abcdefghij"), 0, 1, S("1234567890"), 1, 1, S("2bcdefghij"));
+ test(S("abcdefghij"), 0, 1, S("1234567890"), 1, 4, S("2345bcdefghij"));
+ test(S("abcdefghij"), 0, 1, S("1234567890"), 1, 8, S("23456789bcdefghij"));
+ test(S("abcdefghij"), 0, 1, S("1234567890"), 1, 9, S("234567890bcdefghij"));
+ test(S("abcdefghij"), 0, 1, S("1234567890"), 1, 10, S("234567890bcdefghij"));
+ test(S("abcdefghij"), 0, 1, S("1234567890"), 5, 0, S("bcdefghij"));
+ test(S("abcdefghij"), 0, 1, S("1234567890"), 5, 1, S("6bcdefghij"));
+ test(S("abcdefghij"), 0, 1, S("1234567890"), 5, 2, S("67bcdefghij"));
+ test(S("abcdefghij"), 0, 1, S("1234567890"), 5, 4, S("6789bcdefghij"));
+ test(S("abcdefghij"), 0, 1, S("1234567890"), 5, 5, S("67890bcdefghij"));
+ test(S("abcdefghij"), 0, 1, S("1234567890"), 5, 6, S("67890bcdefghij"));
+ test(S("abcdefghij"), 0, 1, S("1234567890"), 9, 0, S("bcdefghij"));
+ test(S("abcdefghij"), 0, 1, S("1234567890"), 9, 1, S("0bcdefghij"));
+ test(S("abcdefghij"), 0, 1, S("1234567890"), 9, 2, S("0bcdefghij"));
+ test(S("abcdefghij"), 0, 1, S("1234567890"), 10, 0, S("bcdefghij"));
+ test(S("abcdefghij"), 0, 1, S("1234567890"), 10, 1, S("bcdefghij"));
+ test(S("abcdefghij"), 0, 1, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 0, 0, S("bcdefghij"));
+ test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 0, 1, S("1bcdefghij"));
+ test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 0, 10, S("1234567890bcdefghij"));
+ test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 0, 19, S("1234567890123456789bcdefghij"));
+ test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 0, 20, S("12345678901234567890bcdefghij"));
+ test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 0, 21, S("12345678901234567890bcdefghij"));
+ test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 1, 0, S("bcdefghij"));
+ test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 1, 1, S("2bcdefghij"));
+ test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 1, 9, S("234567890bcdefghij"));
+ test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 1, 18, S("234567890123456789bcdefghij"));
+ test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 1, 19, S("2345678901234567890bcdefghij"));
+ test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 1, 20, S("2345678901234567890bcdefghij"));
+ test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 10, 0, S("bcdefghij"));
+ test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 10, 1, S("1bcdefghij"));
+ test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 10, 5, S("12345bcdefghij"));
+ test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 10, 9, S("123456789bcdefghij"));
+ test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 10, 10, S("1234567890bcdefghij"));
+ test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 10, 11, S("1234567890bcdefghij"));
+ test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 19, 0, S("bcdefghij"));
+ test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 19, 1, S("0bcdefghij"));
+ test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 19, 2, S("0bcdefghij"));
+ test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 20, 0, S("bcdefghij"));
+ test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 20, 1, S("bcdefghij"));
+ test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcdefghij"), 0, 5, S(""), 0, 0, S("fghij"));
+ test(S("abcdefghij"), 0, 5, S(""), 0, 1, S("fghij"));
+ test(S("abcdefghij"), 0, 5, S(""), 1, 0, S("can't happen"));
+ test(S("abcdefghij"), 0, 5, S("12345"), 0, 0, S("fghij"));
+ test(S("abcdefghij"), 0, 5, S("12345"), 0, 1, S("1fghij"));
+ test(S("abcdefghij"), 0, 5, S("12345"), 0, 2, S("12fghij"));
+ test(S("abcdefghij"), 0, 5, S("12345"), 0, 4, S("1234fghij"));
+ test(S("abcdefghij"), 0, 5, S("12345"), 0, 5, S("12345fghij"));
+ test(S("abcdefghij"), 0, 5, S("12345"), 0, 6, S("12345fghij"));
+ test(S("abcdefghij"), 0, 5, S("12345"), 1, 0, S("fghij"));
+ test(S("abcdefghij"), 0, 5, S("12345"), 1, 1, S("2fghij"));
+ test(S("abcdefghij"), 0, 5, S("12345"), 1, 2, S("23fghij"));
+ test(S("abcdefghij"), 0, 5, S("12345"), 1, 3, S("234fghij"));
+ test(S("abcdefghij"), 0, 5, S("12345"), 1, 4, S("2345fghij"));
+ test(S("abcdefghij"), 0, 5, S("12345"), 1, 5, S("2345fghij"));
+ test(S("abcdefghij"), 0, 5, S("12345"), 2, 0, S("fghij"));
+ test(S("abcdefghij"), 0, 5, S("12345"), 2, 1, S("3fghij"));
+ test(S("abcdefghij"), 0, 5, S("12345"), 2, 2, S("34fghij"));
+ test(S("abcdefghij"), 0, 5, S("12345"), 2, 3, S("345fghij"));
+ test(S("abcdefghij"), 0, 5, S("12345"), 2, 4, S("345fghij"));
+ test(S("abcdefghij"), 0, 5, S("12345"), 4, 0, S("fghij"));
+ test(S("abcdefghij"), 0, 5, S("12345"), 4, 1, S("5fghij"));
+ test(S("abcdefghij"), 0, 5, S("12345"), 4, 2, S("5fghij"));
+ test(S("abcdefghij"), 0, 5, S("12345"), 5, 0, S("fghij"));
+ test(S("abcdefghij"), 0, 5, S("12345"), 5, 1, S("fghij"));
+ test(S("abcdefghij"), 0, 5, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcdefghij"), 0, 5, S("1234567890"), 0, 0, S("fghij"));
+ test(S("abcdefghij"), 0, 5, S("1234567890"), 0, 1, S("1fghij"));
+}
+
+template <class S>
+void test21()
+{
+ test(S("abcdefghij"), 0, 5, S("1234567890"), 0, 5, S("12345fghij"));
+ test(S("abcdefghij"), 0, 5, S("1234567890"), 0, 9, S("123456789fghij"));
+ test(S("abcdefghij"), 0, 5, S("1234567890"), 0, 10, S("1234567890fghij"));
+ test(S("abcdefghij"), 0, 5, S("1234567890"), 0, 11, S("1234567890fghij"));
+ test(S("abcdefghij"), 0, 5, S("1234567890"), 1, 0, S("fghij"));
+ test(S("abcdefghij"), 0, 5, S("1234567890"), 1, 1, S("2fghij"));
+ test(S("abcdefghij"), 0, 5, S("1234567890"), 1, 4, S("2345fghij"));
+ test(S("abcdefghij"), 0, 5, S("1234567890"), 1, 8, S("23456789fghij"));
+ test(S("abcdefghij"), 0, 5, S("1234567890"), 1, 9, S("234567890fghij"));
+ test(S("abcdefghij"), 0, 5, S("1234567890"), 1, 10, S("234567890fghij"));
+ test(S("abcdefghij"), 0, 5, S("1234567890"), 5, 0, S("fghij"));
+ test(S("abcdefghij"), 0, 5, S("1234567890"), 5, 1, S("6fghij"));
+ test(S("abcdefghij"), 0, 5, S("1234567890"), 5, 2, S("67fghij"));
+ test(S("abcdefghij"), 0, 5, S("1234567890"), 5, 4, S("6789fghij"));
+ test(S("abcdefghij"), 0, 5, S("1234567890"), 5, 5, S("67890fghij"));
+ test(S("abcdefghij"), 0, 5, S("1234567890"), 5, 6, S("67890fghij"));
+ test(S("abcdefghij"), 0, 5, S("1234567890"), 9, 0, S("fghij"));
+ test(S("abcdefghij"), 0, 5, S("1234567890"), 9, 1, S("0fghij"));
+ test(S("abcdefghij"), 0, 5, S("1234567890"), 9, 2, S("0fghij"));
+ test(S("abcdefghij"), 0, 5, S("1234567890"), 10, 0, S("fghij"));
+ test(S("abcdefghij"), 0, 5, S("1234567890"), 10, 1, S("fghij"));
+ test(S("abcdefghij"), 0, 5, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 0, 0, S("fghij"));
+ test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 0, 1, S("1fghij"));
+ test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 0, 10, S("1234567890fghij"));
+ test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 0, 19, S("1234567890123456789fghij"));
+ test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 0, 20, S("12345678901234567890fghij"));
+ test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 0, 21, S("12345678901234567890fghij"));
+ test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 1, 0, S("fghij"));
+ test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 1, 1, S("2fghij"));
+ test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 1, 9, S("234567890fghij"));
+ test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 1, 18, S("234567890123456789fghij"));
+ test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 1, 19, S("2345678901234567890fghij"));
+ test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 1, 20, S("2345678901234567890fghij"));
+ test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 10, 0, S("fghij"));
+ test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 10, 1, S("1fghij"));
+ test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 10, 5, S("12345fghij"));
+ test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 10, 9, S("123456789fghij"));
+ test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 10, 10, S("1234567890fghij"));
+ test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 10, 11, S("1234567890fghij"));
+ test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 19, 0, S("fghij"));
+ test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 19, 1, S("0fghij"));
+ test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 19, 2, S("0fghij"));
+ test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 20, 0, S("fghij"));
+ test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 20, 1, S("fghij"));
+ test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcdefghij"), 0, 9, S(""), 0, 0, S("j"));
+ test(S("abcdefghij"), 0, 9, S(""), 0, 1, S("j"));
+ test(S("abcdefghij"), 0, 9, S(""), 1, 0, S("can't happen"));
+ test(S("abcdefghij"), 0, 9, S("12345"), 0, 0, S("j"));
+ test(S("abcdefghij"), 0, 9, S("12345"), 0, 1, S("1j"));
+ test(S("abcdefghij"), 0, 9, S("12345"), 0, 2, S("12j"));
+ test(S("abcdefghij"), 0, 9, S("12345"), 0, 4, S("1234j"));
+ test(S("abcdefghij"), 0, 9, S("12345"), 0, 5, S("12345j"));
+ test(S("abcdefghij"), 0, 9, S("12345"), 0, 6, S("12345j"));
+ test(S("abcdefghij"), 0, 9, S("12345"), 1, 0, S("j"));
+ test(S("abcdefghij"), 0, 9, S("12345"), 1, 1, S("2j"));
+ test(S("abcdefghij"), 0, 9, S("12345"), 1, 2, S("23j"));
+ test(S("abcdefghij"), 0, 9, S("12345"), 1, 3, S("234j"));
+ test(S("abcdefghij"), 0, 9, S("12345"), 1, 4, S("2345j"));
+ test(S("abcdefghij"), 0, 9, S("12345"), 1, 5, S("2345j"));
+ test(S("abcdefghij"), 0, 9, S("12345"), 2, 0, S("j"));
+ test(S("abcdefghij"), 0, 9, S("12345"), 2, 1, S("3j"));
+ test(S("abcdefghij"), 0, 9, S("12345"), 2, 2, S("34j"));
+ test(S("abcdefghij"), 0, 9, S("12345"), 2, 3, S("345j"));
+ test(S("abcdefghij"), 0, 9, S("12345"), 2, 4, S("345j"));
+ test(S("abcdefghij"), 0, 9, S("12345"), 4, 0, S("j"));
+ test(S("abcdefghij"), 0, 9, S("12345"), 4, 1, S("5j"));
+ test(S("abcdefghij"), 0, 9, S("12345"), 4, 2, S("5j"));
+ test(S("abcdefghij"), 0, 9, S("12345"), 5, 0, S("j"));
+ test(S("abcdefghij"), 0, 9, S("12345"), 5, 1, S("j"));
+ test(S("abcdefghij"), 0, 9, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcdefghij"), 0, 9, S("1234567890"), 0, 0, S("j"));
+ test(S("abcdefghij"), 0, 9, S("1234567890"), 0, 1, S("1j"));
+ test(S("abcdefghij"), 0, 9, S("1234567890"), 0, 5, S("12345j"));
+ test(S("abcdefghij"), 0, 9, S("1234567890"), 0, 9, S("123456789j"));
+ test(S("abcdefghij"), 0, 9, S("1234567890"), 0, 10, S("1234567890j"));
+ test(S("abcdefghij"), 0, 9, S("1234567890"), 0, 11, S("1234567890j"));
+ test(S("abcdefghij"), 0, 9, S("1234567890"), 1, 0, S("j"));
+ test(S("abcdefghij"), 0, 9, S("1234567890"), 1, 1, S("2j"));
+ test(S("abcdefghij"), 0, 9, S("1234567890"), 1, 4, S("2345j"));
+ test(S("abcdefghij"), 0, 9, S("1234567890"), 1, 8, S("23456789j"));
+ test(S("abcdefghij"), 0, 9, S("1234567890"), 1, 9, S("234567890j"));
+ test(S("abcdefghij"), 0, 9, S("1234567890"), 1, 10, S("234567890j"));
+ test(S("abcdefghij"), 0, 9, S("1234567890"), 5, 0, S("j"));
+ test(S("abcdefghij"), 0, 9, S("1234567890"), 5, 1, S("6j"));
+ test(S("abcdefghij"), 0, 9, S("1234567890"), 5, 2, S("67j"));
+ test(S("abcdefghij"), 0, 9, S("1234567890"), 5, 4, S("6789j"));
+ test(S("abcdefghij"), 0, 9, S("1234567890"), 5, 5, S("67890j"));
+ test(S("abcdefghij"), 0, 9, S("1234567890"), 5, 6, S("67890j"));
+ test(S("abcdefghij"), 0, 9, S("1234567890"), 9, 0, S("j"));
+ test(S("abcdefghij"), 0, 9, S("1234567890"), 9, 1, S("0j"));
+ test(S("abcdefghij"), 0, 9, S("1234567890"), 9, 2, S("0j"));
+ test(S("abcdefghij"), 0, 9, S("1234567890"), 10, 0, S("j"));
+ test(S("abcdefghij"), 0, 9, S("1234567890"), 10, 1, S("j"));
+ test(S("abcdefghij"), 0, 9, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 0, 0, S("j"));
+ test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 0, 1, S("1j"));
+ test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 0, 10, S("1234567890j"));
+ test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 0, 19, S("1234567890123456789j"));
+}
+
+template <class S>
+void test22()
+{
+ test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 0, 20, S("12345678901234567890j"));
+ test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 0, 21, S("12345678901234567890j"));
+ test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 1, 0, S("j"));
+ test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 1, 1, S("2j"));
+ test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 1, 9, S("234567890j"));
+ test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 1, 18, S("234567890123456789j"));
+ test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 1, 19, S("2345678901234567890j"));
+ test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 1, 20, S("2345678901234567890j"));
+ test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 10, 0, S("j"));
+ test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 10, 1, S("1j"));
+ test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 10, 5, S("12345j"));
+ test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 10, 9, S("123456789j"));
+ test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 10, 10, S("1234567890j"));
+ test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 10, 11, S("1234567890j"));
+ test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 19, 0, S("j"));
+ test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 19, 1, S("0j"));
+ test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 19, 2, S("0j"));
+ test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 20, 0, S("j"));
+ test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 20, 1, S("j"));
+ test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcdefghij"), 0, 10, S(""), 0, 0, S(""));
+ test(S("abcdefghij"), 0, 10, S(""), 0, 1, S(""));
+ test(S("abcdefghij"), 0, 10, S(""), 1, 0, S("can't happen"));
+ test(S("abcdefghij"), 0, 10, S("12345"), 0, 0, S(""));
+ test(S("abcdefghij"), 0, 10, S("12345"), 0, 1, S("1"));
+ test(S("abcdefghij"), 0, 10, S("12345"), 0, 2, S("12"));
+ test(S("abcdefghij"), 0, 10, S("12345"), 0, 4, S("1234"));
+ test(S("abcdefghij"), 0, 10, S("12345"), 0, 5, S("12345"));
+ test(S("abcdefghij"), 0, 10, S("12345"), 0, 6, S("12345"));
+ test(S("abcdefghij"), 0, 10, S("12345"), 1, 0, S(""));
+ test(S("abcdefghij"), 0, 10, S("12345"), 1, 1, S("2"));
+ test(S("abcdefghij"), 0, 10, S("12345"), 1, 2, S("23"));
+ test(S("abcdefghij"), 0, 10, S("12345"), 1, 3, S("234"));
+ test(S("abcdefghij"), 0, 10, S("12345"), 1, 4, S("2345"));
+ test(S("abcdefghij"), 0, 10, S("12345"), 1, 5, S("2345"));
+ test(S("abcdefghij"), 0, 10, S("12345"), 2, 0, S(""));
+ test(S("abcdefghij"), 0, 10, S("12345"), 2, 1, S("3"));
+ test(S("abcdefghij"), 0, 10, S("12345"), 2, 2, S("34"));
+ test(S("abcdefghij"), 0, 10, S("12345"), 2, 3, S("345"));
+ test(S("abcdefghij"), 0, 10, S("12345"), 2, 4, S("345"));
+ test(S("abcdefghij"), 0, 10, S("12345"), 4, 0, S(""));
+ test(S("abcdefghij"), 0, 10, S("12345"), 4, 1, S("5"));
+ test(S("abcdefghij"), 0, 10, S("12345"), 4, 2, S("5"));
+ test(S("abcdefghij"), 0, 10, S("12345"), 5, 0, S(""));
+ test(S("abcdefghij"), 0, 10, S("12345"), 5, 1, S(""));
+ test(S("abcdefghij"), 0, 10, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcdefghij"), 0, 10, S("1234567890"), 0, 0, S(""));
+ test(S("abcdefghij"), 0, 10, S("1234567890"), 0, 1, S("1"));
+ test(S("abcdefghij"), 0, 10, S("1234567890"), 0, 5, S("12345"));
+ test(S("abcdefghij"), 0, 10, S("1234567890"), 0, 9, S("123456789"));
+ test(S("abcdefghij"), 0, 10, S("1234567890"), 0, 10, S("1234567890"));
+ test(S("abcdefghij"), 0, 10, S("1234567890"), 0, 11, S("1234567890"));
+ test(S("abcdefghij"), 0, 10, S("1234567890"), 1, 0, S(""));
+ test(S("abcdefghij"), 0, 10, S("1234567890"), 1, 1, S("2"));
+ test(S("abcdefghij"), 0, 10, S("1234567890"), 1, 4, S("2345"));
+ test(S("abcdefghij"), 0, 10, S("1234567890"), 1, 8, S("23456789"));
+ test(S("abcdefghij"), 0, 10, S("1234567890"), 1, 9, S("234567890"));
+ test(S("abcdefghij"), 0, 10, S("1234567890"), 1, 10, S("234567890"));
+ test(S("abcdefghij"), 0, 10, S("1234567890"), 5, 0, S(""));
+ test(S("abcdefghij"), 0, 10, S("1234567890"), 5, 1, S("6"));
+ test(S("abcdefghij"), 0, 10, S("1234567890"), 5, 2, S("67"));
+ test(S("abcdefghij"), 0, 10, S("1234567890"), 5, 4, S("6789"));
+ test(S("abcdefghij"), 0, 10, S("1234567890"), 5, 5, S("67890"));
+ test(S("abcdefghij"), 0, 10, S("1234567890"), 5, 6, S("67890"));
+ test(S("abcdefghij"), 0, 10, S("1234567890"), 9, 0, S(""));
+ test(S("abcdefghij"), 0, 10, S("1234567890"), 9, 1, S("0"));
+ test(S("abcdefghij"), 0, 10, S("1234567890"), 9, 2, S("0"));
+ test(S("abcdefghij"), 0, 10, S("1234567890"), 10, 0, S(""));
+ test(S("abcdefghij"), 0, 10, S("1234567890"), 10, 1, S(""));
+ test(S("abcdefghij"), 0, 10, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 0, 0, S(""));
+ test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 0, 1, S("1"));
+ test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 0, 10, S("1234567890"));
+ test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 0, 19, S("1234567890123456789"));
+ test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 0, 20, S("12345678901234567890"));
+ test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 0, 21, S("12345678901234567890"));
+ test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 1, 0, S(""));
+ test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 1, 1, S("2"));
+ test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 1, 9, S("234567890"));
+ test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 1, 18, S("234567890123456789"));
+ test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 1, 19, S("2345678901234567890"));
+ test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 1, 20, S("2345678901234567890"));
+ test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 10, 0, S(""));
+ test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 10, 1, S("1"));
+ test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 10, 5, S("12345"));
+ test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 10, 9, S("123456789"));
+ test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 10, 10, S("1234567890"));
+ test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 10, 11, S("1234567890"));
+ test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 19, 0, S(""));
+ test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 19, 1, S("0"));
+ test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 19, 2, S("0"));
+ test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 20, 0, S(""));
+ test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 20, 1, S(""));
+ test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcdefghij"), 0, 11, S(""), 0, 0, S(""));
+ test(S("abcdefghij"), 0, 11, S(""), 0, 1, S(""));
+ test(S("abcdefghij"), 0, 11, S(""), 1, 0, S("can't happen"));
+ test(S("abcdefghij"), 0, 11, S("12345"), 0, 0, S(""));
+ test(S("abcdefghij"), 0, 11, S("12345"), 0, 1, S("1"));
+ test(S("abcdefghij"), 0, 11, S("12345"), 0, 2, S("12"));
+}
+
+template <class S>
+void test23()
+{
+ test(S("abcdefghij"), 0, 11, S("12345"), 0, 4, S("1234"));
+ test(S("abcdefghij"), 0, 11, S("12345"), 0, 5, S("12345"));
+ test(S("abcdefghij"), 0, 11, S("12345"), 0, 6, S("12345"));
+ test(S("abcdefghij"), 0, 11, S("12345"), 1, 0, S(""));
+ test(S("abcdefghij"), 0, 11, S("12345"), 1, 1, S("2"));
+ test(S("abcdefghij"), 0, 11, S("12345"), 1, 2, S("23"));
+ test(S("abcdefghij"), 0, 11, S("12345"), 1, 3, S("234"));
+ test(S("abcdefghij"), 0, 11, S("12345"), 1, 4, S("2345"));
+ test(S("abcdefghij"), 0, 11, S("12345"), 1, 5, S("2345"));
+ test(S("abcdefghij"), 0, 11, S("12345"), 2, 0, S(""));
+ test(S("abcdefghij"), 0, 11, S("12345"), 2, 1, S("3"));
+ test(S("abcdefghij"), 0, 11, S("12345"), 2, 2, S("34"));
+ test(S("abcdefghij"), 0, 11, S("12345"), 2, 3, S("345"));
+ test(S("abcdefghij"), 0, 11, S("12345"), 2, 4, S("345"));
+ test(S("abcdefghij"), 0, 11, S("12345"), 4, 0, S(""));
+ test(S("abcdefghij"), 0, 11, S("12345"), 4, 1, S("5"));
+ test(S("abcdefghij"), 0, 11, S("12345"), 4, 2, S("5"));
+ test(S("abcdefghij"), 0, 11, S("12345"), 5, 0, S(""));
+ test(S("abcdefghij"), 0, 11, S("12345"), 5, 1, S(""));
+ test(S("abcdefghij"), 0, 11, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcdefghij"), 0, 11, S("1234567890"), 0, 0, S(""));
+ test(S("abcdefghij"), 0, 11, S("1234567890"), 0, 1, S("1"));
+ test(S("abcdefghij"), 0, 11, S("1234567890"), 0, 5, S("12345"));
+ test(S("abcdefghij"), 0, 11, S("1234567890"), 0, 9, S("123456789"));
+ test(S("abcdefghij"), 0, 11, S("1234567890"), 0, 10, S("1234567890"));
+ test(S("abcdefghij"), 0, 11, S("1234567890"), 0, 11, S("1234567890"));
+ test(S("abcdefghij"), 0, 11, S("1234567890"), 1, 0, S(""));
+ test(S("abcdefghij"), 0, 11, S("1234567890"), 1, 1, S("2"));
+ test(S("abcdefghij"), 0, 11, S("1234567890"), 1, 4, S("2345"));
+ test(S("abcdefghij"), 0, 11, S("1234567890"), 1, 8, S("23456789"));
+ test(S("abcdefghij"), 0, 11, S("1234567890"), 1, 9, S("234567890"));
+ test(S("abcdefghij"), 0, 11, S("1234567890"), 1, 10, S("234567890"));
+ test(S("abcdefghij"), 0, 11, S("1234567890"), 5, 0, S(""));
+ test(S("abcdefghij"), 0, 11, S("1234567890"), 5, 1, S("6"));
+ test(S("abcdefghij"), 0, 11, S("1234567890"), 5, 2, S("67"));
+ test(S("abcdefghij"), 0, 11, S("1234567890"), 5, 4, S("6789"));
+ test(S("abcdefghij"), 0, 11, S("1234567890"), 5, 5, S("67890"));
+ test(S("abcdefghij"), 0, 11, S("1234567890"), 5, 6, S("67890"));
+ test(S("abcdefghij"), 0, 11, S("1234567890"), 9, 0, S(""));
+ test(S("abcdefghij"), 0, 11, S("1234567890"), 9, 1, S("0"));
+ test(S("abcdefghij"), 0, 11, S("1234567890"), 9, 2, S("0"));
+ test(S("abcdefghij"), 0, 11, S("1234567890"), 10, 0, S(""));
+ test(S("abcdefghij"), 0, 11, S("1234567890"), 10, 1, S(""));
+ test(S("abcdefghij"), 0, 11, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 0, 0, S(""));
+ test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 0, 1, S("1"));
+ test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 0, 10, S("1234567890"));
+ test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 0, 19, S("1234567890123456789"));
+ test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 0, 20, S("12345678901234567890"));
+ test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 0, 21, S("12345678901234567890"));
+ test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 1, 0, S(""));
+ test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 1, 1, S("2"));
+ test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 1, 9, S("234567890"));
+ test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 1, 18, S("234567890123456789"));
+ test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 1, 19, S("2345678901234567890"));
+ test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 1, 20, S("2345678901234567890"));
+ test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 10, 0, S(""));
+ test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 10, 1, S("1"));
+ test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 10, 5, S("12345"));
+ test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 10, 9, S("123456789"));
+ test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 10, 10, S("1234567890"));
+ test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 10, 11, S("1234567890"));
+ test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 19, 0, S(""));
+ test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 19, 1, S("0"));
+ test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 19, 2, S("0"));
+ test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 20, 0, S(""));
+ test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 20, 1, S(""));
+ test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcdefghij"), 1, 0, S(""), 0, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 1, 0, S(""), 0, 1, S("abcdefghij"));
+ test(S("abcdefghij"), 1, 0, S(""), 1, 0, S("can't happen"));
+ test(S("abcdefghij"), 1, 0, S("12345"), 0, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 1, 0, S("12345"), 0, 1, S("a1bcdefghij"));
+ test(S("abcdefghij"), 1, 0, S("12345"), 0, 2, S("a12bcdefghij"));
+ test(S("abcdefghij"), 1, 0, S("12345"), 0, 4, S("a1234bcdefghij"));
+ test(S("abcdefghij"), 1, 0, S("12345"), 0, 5, S("a12345bcdefghij"));
+ test(S("abcdefghij"), 1, 0, S("12345"), 0, 6, S("a12345bcdefghij"));
+ test(S("abcdefghij"), 1, 0, S("12345"), 1, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 1, 0, S("12345"), 1, 1, S("a2bcdefghij"));
+ test(S("abcdefghij"), 1, 0, S("12345"), 1, 2, S("a23bcdefghij"));
+ test(S("abcdefghij"), 1, 0, S("12345"), 1, 3, S("a234bcdefghij"));
+ test(S("abcdefghij"), 1, 0, S("12345"), 1, 4, S("a2345bcdefghij"));
+ test(S("abcdefghij"), 1, 0, S("12345"), 1, 5, S("a2345bcdefghij"));
+ test(S("abcdefghij"), 1, 0, S("12345"), 2, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 1, 0, S("12345"), 2, 1, S("a3bcdefghij"));
+ test(S("abcdefghij"), 1, 0, S("12345"), 2, 2, S("a34bcdefghij"));
+ test(S("abcdefghij"), 1, 0, S("12345"), 2, 3, S("a345bcdefghij"));
+ test(S("abcdefghij"), 1, 0, S("12345"), 2, 4, S("a345bcdefghij"));
+ test(S("abcdefghij"), 1, 0, S("12345"), 4, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 1, 0, S("12345"), 4, 1, S("a5bcdefghij"));
+ test(S("abcdefghij"), 1, 0, S("12345"), 4, 2, S("a5bcdefghij"));
+ test(S("abcdefghij"), 1, 0, S("12345"), 5, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 1, 0, S("12345"), 5, 1, S("abcdefghij"));
+ test(S("abcdefghij"), 1, 0, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcdefghij"), 1, 0, S("1234567890"), 0, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 1, 0, S("1234567890"), 0, 1, S("a1bcdefghij"));
+ test(S("abcdefghij"), 1, 0, S("1234567890"), 0, 5, S("a12345bcdefghij"));
+ test(S("abcdefghij"), 1, 0, S("1234567890"), 0, 9, S("a123456789bcdefghij"));
+ test(S("abcdefghij"), 1, 0, S("1234567890"), 0, 10, S("a1234567890bcdefghij"));
+ test(S("abcdefghij"), 1, 0, S("1234567890"), 0, 11, S("a1234567890bcdefghij"));
+}
+
+template <class S>
+void test24()
+{
+ test(S("abcdefghij"), 1, 0, S("1234567890"), 1, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 1, 0, S("1234567890"), 1, 1, S("a2bcdefghij"));
+ test(S("abcdefghij"), 1, 0, S("1234567890"), 1, 4, S("a2345bcdefghij"));
+ test(S("abcdefghij"), 1, 0, S("1234567890"), 1, 8, S("a23456789bcdefghij"));
+ test(S("abcdefghij"), 1, 0, S("1234567890"), 1, 9, S("a234567890bcdefghij"));
+ test(S("abcdefghij"), 1, 0, S("1234567890"), 1, 10, S("a234567890bcdefghij"));
+ test(S("abcdefghij"), 1, 0, S("1234567890"), 5, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 1, 0, S("1234567890"), 5, 1, S("a6bcdefghij"));
+ test(S("abcdefghij"), 1, 0, S("1234567890"), 5, 2, S("a67bcdefghij"));
+ test(S("abcdefghij"), 1, 0, S("1234567890"), 5, 4, S("a6789bcdefghij"));
+ test(S("abcdefghij"), 1, 0, S("1234567890"), 5, 5, S("a67890bcdefghij"));
+ test(S("abcdefghij"), 1, 0, S("1234567890"), 5, 6, S("a67890bcdefghij"));
+ test(S("abcdefghij"), 1, 0, S("1234567890"), 9, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 1, 0, S("1234567890"), 9, 1, S("a0bcdefghij"));
+ test(S("abcdefghij"), 1, 0, S("1234567890"), 9, 2, S("a0bcdefghij"));
+ test(S("abcdefghij"), 1, 0, S("1234567890"), 10, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 1, 0, S("1234567890"), 10, 1, S("abcdefghij"));
+ test(S("abcdefghij"), 1, 0, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 0, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 0, 1, S("a1bcdefghij"));
+ test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 0, 10, S("a1234567890bcdefghij"));
+ test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 0, 19, S("a1234567890123456789bcdefghij"));
+ test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 0, 20, S("a12345678901234567890bcdefghij"));
+ test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 0, 21, S("a12345678901234567890bcdefghij"));
+ test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 1, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 1, 1, S("a2bcdefghij"));
+ test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 1, 9, S("a234567890bcdefghij"));
+ test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 1, 18, S("a234567890123456789bcdefghij"));
+ test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 1, 19, S("a2345678901234567890bcdefghij"));
+ test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 1, 20, S("a2345678901234567890bcdefghij"));
+ test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 10, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 10, 1, S("a1bcdefghij"));
+ test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 10, 5, S("a12345bcdefghij"));
+ test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 10, 9, S("a123456789bcdefghij"));
+ test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 10, 10, S("a1234567890bcdefghij"));
+ test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 10, 11, S("a1234567890bcdefghij"));
+ test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 19, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 19, 1, S("a0bcdefghij"));
+ test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 19, 2, S("a0bcdefghij"));
+ test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 20, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 20, 1, S("abcdefghij"));
+ test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcdefghij"), 1, 1, S(""), 0, 0, S("acdefghij"));
+ test(S("abcdefghij"), 1, 1, S(""), 0, 1, S("acdefghij"));
+ test(S("abcdefghij"), 1, 1, S(""), 1, 0, S("can't happen"));
+ test(S("abcdefghij"), 1, 1, S("12345"), 0, 0, S("acdefghij"));
+ test(S("abcdefghij"), 1, 1, S("12345"), 0, 1, S("a1cdefghij"));
+ test(S("abcdefghij"), 1, 1, S("12345"), 0, 2, S("a12cdefghij"));
+ test(S("abcdefghij"), 1, 1, S("12345"), 0, 4, S("a1234cdefghij"));
+ test(S("abcdefghij"), 1, 1, S("12345"), 0, 5, S("a12345cdefghij"));
+ test(S("abcdefghij"), 1, 1, S("12345"), 0, 6, S("a12345cdefghij"));
+ test(S("abcdefghij"), 1, 1, S("12345"), 1, 0, S("acdefghij"));
+ test(S("abcdefghij"), 1, 1, S("12345"), 1, 1, S("a2cdefghij"));
+ test(S("abcdefghij"), 1, 1, S("12345"), 1, 2, S("a23cdefghij"));
+ test(S("abcdefghij"), 1, 1, S("12345"), 1, 3, S("a234cdefghij"));
+ test(S("abcdefghij"), 1, 1, S("12345"), 1, 4, S("a2345cdefghij"));
+ test(S("abcdefghij"), 1, 1, S("12345"), 1, 5, S("a2345cdefghij"));
+ test(S("abcdefghij"), 1, 1, S("12345"), 2, 0, S("acdefghij"));
+ test(S("abcdefghij"), 1, 1, S("12345"), 2, 1, S("a3cdefghij"));
+ test(S("abcdefghij"), 1, 1, S("12345"), 2, 2, S("a34cdefghij"));
+ test(S("abcdefghij"), 1, 1, S("12345"), 2, 3, S("a345cdefghij"));
+ test(S("abcdefghij"), 1, 1, S("12345"), 2, 4, S("a345cdefghij"));
+ test(S("abcdefghij"), 1, 1, S("12345"), 4, 0, S("acdefghij"));
+ test(S("abcdefghij"), 1, 1, S("12345"), 4, 1, S("a5cdefghij"));
+ test(S("abcdefghij"), 1, 1, S("12345"), 4, 2, S("a5cdefghij"));
+ test(S("abcdefghij"), 1, 1, S("12345"), 5, 0, S("acdefghij"));
+ test(S("abcdefghij"), 1, 1, S("12345"), 5, 1, S("acdefghij"));
+ test(S("abcdefghij"), 1, 1, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcdefghij"), 1, 1, S("1234567890"), 0, 0, S("acdefghij"));
+ test(S("abcdefghij"), 1, 1, S("1234567890"), 0, 1, S("a1cdefghij"));
+ test(S("abcdefghij"), 1, 1, S("1234567890"), 0, 5, S("a12345cdefghij"));
+ test(S("abcdefghij"), 1, 1, S("1234567890"), 0, 9, S("a123456789cdefghij"));
+ test(S("abcdefghij"), 1, 1, S("1234567890"), 0, 10, S("a1234567890cdefghij"));
+ test(S("abcdefghij"), 1, 1, S("1234567890"), 0, 11, S("a1234567890cdefghij"));
+ test(S("abcdefghij"), 1, 1, S("1234567890"), 1, 0, S("acdefghij"));
+ test(S("abcdefghij"), 1, 1, S("1234567890"), 1, 1, S("a2cdefghij"));
+ test(S("abcdefghij"), 1, 1, S("1234567890"), 1, 4, S("a2345cdefghij"));
+ test(S("abcdefghij"), 1, 1, S("1234567890"), 1, 8, S("a23456789cdefghij"));
+ test(S("abcdefghij"), 1, 1, S("1234567890"), 1, 9, S("a234567890cdefghij"));
+ test(S("abcdefghij"), 1, 1, S("1234567890"), 1, 10, S("a234567890cdefghij"));
+ test(S("abcdefghij"), 1, 1, S("1234567890"), 5, 0, S("acdefghij"));
+ test(S("abcdefghij"), 1, 1, S("1234567890"), 5, 1, S("a6cdefghij"));
+ test(S("abcdefghij"), 1, 1, S("1234567890"), 5, 2, S("a67cdefghij"));
+ test(S("abcdefghij"), 1, 1, S("1234567890"), 5, 4, S("a6789cdefghij"));
+ test(S("abcdefghij"), 1, 1, S("1234567890"), 5, 5, S("a67890cdefghij"));
+ test(S("abcdefghij"), 1, 1, S("1234567890"), 5, 6, S("a67890cdefghij"));
+ test(S("abcdefghij"), 1, 1, S("1234567890"), 9, 0, S("acdefghij"));
+ test(S("abcdefghij"), 1, 1, S("1234567890"), 9, 1, S("a0cdefghij"));
+ test(S("abcdefghij"), 1, 1, S("1234567890"), 9, 2, S("a0cdefghij"));
+ test(S("abcdefghij"), 1, 1, S("1234567890"), 10, 0, S("acdefghij"));
+ test(S("abcdefghij"), 1, 1, S("1234567890"), 10, 1, S("acdefghij"));
+ test(S("abcdefghij"), 1, 1, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 0, 0, S("acdefghij"));
+ test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 0, 1, S("a1cdefghij"));
+ test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 0, 10, S("a1234567890cdefghij"));
+ test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 0, 19, S("a1234567890123456789cdefghij"));
+ test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 0, 20, S("a12345678901234567890cdefghij"));
+ test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 0, 21, S("a12345678901234567890cdefghij"));
+ test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 1, 0, S("acdefghij"));
+ test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 1, 1, S("a2cdefghij"));
+}
+
+template <class S>
+void test25()
+{
+ test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 1, 9, S("a234567890cdefghij"));
+ test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 1, 18, S("a234567890123456789cdefghij"));
+ test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 1, 19, S("a2345678901234567890cdefghij"));
+ test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 1, 20, S("a2345678901234567890cdefghij"));
+ test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 10, 0, S("acdefghij"));
+ test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 10, 1, S("a1cdefghij"));
+ test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 10, 5, S("a12345cdefghij"));
+ test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 10, 9, S("a123456789cdefghij"));
+ test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 10, 10, S("a1234567890cdefghij"));
+ test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 10, 11, S("a1234567890cdefghij"));
+ test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 19, 0, S("acdefghij"));
+ test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 19, 1, S("a0cdefghij"));
+ test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 19, 2, S("a0cdefghij"));
+ test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 20, 0, S("acdefghij"));
+ test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 20, 1, S("acdefghij"));
+ test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcdefghij"), 1, 4, S(""), 0, 0, S("afghij"));
+ test(S("abcdefghij"), 1, 4, S(""), 0, 1, S("afghij"));
+ test(S("abcdefghij"), 1, 4, S(""), 1, 0, S("can't happen"));
+ test(S("abcdefghij"), 1, 4, S("12345"), 0, 0, S("afghij"));
+ test(S("abcdefghij"), 1, 4, S("12345"), 0, 1, S("a1fghij"));
+ test(S("abcdefghij"), 1, 4, S("12345"), 0, 2, S("a12fghij"));
+ test(S("abcdefghij"), 1, 4, S("12345"), 0, 4, S("a1234fghij"));
+ test(S("abcdefghij"), 1, 4, S("12345"), 0, 5, S("a12345fghij"));
+ test(S("abcdefghij"), 1, 4, S("12345"), 0, 6, S("a12345fghij"));
+ test(S("abcdefghij"), 1, 4, S("12345"), 1, 0, S("afghij"));
+ test(S("abcdefghij"), 1, 4, S("12345"), 1, 1, S("a2fghij"));
+ test(S("abcdefghij"), 1, 4, S("12345"), 1, 2, S("a23fghij"));
+ test(S("abcdefghij"), 1, 4, S("12345"), 1, 3, S("a234fghij"));
+ test(S("abcdefghij"), 1, 4, S("12345"), 1, 4, S("a2345fghij"));
+ test(S("abcdefghij"), 1, 4, S("12345"), 1, 5, S("a2345fghij"));
+ test(S("abcdefghij"), 1, 4, S("12345"), 2, 0, S("afghij"));
+ test(S("abcdefghij"), 1, 4, S("12345"), 2, 1, S("a3fghij"));
+ test(S("abcdefghij"), 1, 4, S("12345"), 2, 2, S("a34fghij"));
+ test(S("abcdefghij"), 1, 4, S("12345"), 2, 3, S("a345fghij"));
+ test(S("abcdefghij"), 1, 4, S("12345"), 2, 4, S("a345fghij"));
+ test(S("abcdefghij"), 1, 4, S("12345"), 4, 0, S("afghij"));
+ test(S("abcdefghij"), 1, 4, S("12345"), 4, 1, S("a5fghij"));
+ test(S("abcdefghij"), 1, 4, S("12345"), 4, 2, S("a5fghij"));
+ test(S("abcdefghij"), 1, 4, S("12345"), 5, 0, S("afghij"));
+ test(S("abcdefghij"), 1, 4, S("12345"), 5, 1, S("afghij"));
+ test(S("abcdefghij"), 1, 4, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcdefghij"), 1, 4, S("1234567890"), 0, 0, S("afghij"));
+ test(S("abcdefghij"), 1, 4, S("1234567890"), 0, 1, S("a1fghij"));
+ test(S("abcdefghij"), 1, 4, S("1234567890"), 0, 5, S("a12345fghij"));
+ test(S("abcdefghij"), 1, 4, S("1234567890"), 0, 9, S("a123456789fghij"));
+ test(S("abcdefghij"), 1, 4, S("1234567890"), 0, 10, S("a1234567890fghij"));
+ test(S("abcdefghij"), 1, 4, S("1234567890"), 0, 11, S("a1234567890fghij"));
+ test(S("abcdefghij"), 1, 4, S("1234567890"), 1, 0, S("afghij"));
+ test(S("abcdefghij"), 1, 4, S("1234567890"), 1, 1, S("a2fghij"));
+ test(S("abcdefghij"), 1, 4, S("1234567890"), 1, 4, S("a2345fghij"));
+ test(S("abcdefghij"), 1, 4, S("1234567890"), 1, 8, S("a23456789fghij"));
+ test(S("abcdefghij"), 1, 4, S("1234567890"), 1, 9, S("a234567890fghij"));
+ test(S("abcdefghij"), 1, 4, S("1234567890"), 1, 10, S("a234567890fghij"));
+ test(S("abcdefghij"), 1, 4, S("1234567890"), 5, 0, S("afghij"));
+ test(S("abcdefghij"), 1, 4, S("1234567890"), 5, 1, S("a6fghij"));
+ test(S("abcdefghij"), 1, 4, S("1234567890"), 5, 2, S("a67fghij"));
+ test(S("abcdefghij"), 1, 4, S("1234567890"), 5, 4, S("a6789fghij"));
+ test(S("abcdefghij"), 1, 4, S("1234567890"), 5, 5, S("a67890fghij"));
+ test(S("abcdefghij"), 1, 4, S("1234567890"), 5, 6, S("a67890fghij"));
+ test(S("abcdefghij"), 1, 4, S("1234567890"), 9, 0, S("afghij"));
+ test(S("abcdefghij"), 1, 4, S("1234567890"), 9, 1, S("a0fghij"));
+ test(S("abcdefghij"), 1, 4, S("1234567890"), 9, 2, S("a0fghij"));
+ test(S("abcdefghij"), 1, 4, S("1234567890"), 10, 0, S("afghij"));
+ test(S("abcdefghij"), 1, 4, S("1234567890"), 10, 1, S("afghij"));
+ test(S("abcdefghij"), 1, 4, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 0, 0, S("afghij"));
+ test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 0, 1, S("a1fghij"));
+ test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 0, 10, S("a1234567890fghij"));
+ test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 0, 19, S("a1234567890123456789fghij"));
+ test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 0, 20, S("a12345678901234567890fghij"));
+ test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 0, 21, S("a12345678901234567890fghij"));
+ test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 1, 0, S("afghij"));
+ test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 1, 1, S("a2fghij"));
+ test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 1, 9, S("a234567890fghij"));
+ test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 1, 18, S("a234567890123456789fghij"));
+ test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 1, 19, S("a2345678901234567890fghij"));
+ test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 1, 20, S("a2345678901234567890fghij"));
+ test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 10, 0, S("afghij"));
+ test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 10, 1, S("a1fghij"));
+ test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 10, 5, S("a12345fghij"));
+ test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 10, 9, S("a123456789fghij"));
+ test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 10, 10, S("a1234567890fghij"));
+ test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 10, 11, S("a1234567890fghij"));
+ test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 19, 0, S("afghij"));
+ test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 19, 1, S("a0fghij"));
+ test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 19, 2, S("a0fghij"));
+ test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 20, 0, S("afghij"));
+ test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 20, 1, S("afghij"));
+ test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcdefghij"), 1, 8, S(""), 0, 0, S("aj"));
+ test(S("abcdefghij"), 1, 8, S(""), 0, 1, S("aj"));
+ test(S("abcdefghij"), 1, 8, S(""), 1, 0, S("can't happen"));
+ test(S("abcdefghij"), 1, 8, S("12345"), 0, 0, S("aj"));
+ test(S("abcdefghij"), 1, 8, S("12345"), 0, 1, S("a1j"));
+ test(S("abcdefghij"), 1, 8, S("12345"), 0, 2, S("a12j"));
+ test(S("abcdefghij"), 1, 8, S("12345"), 0, 4, S("a1234j"));
+ test(S("abcdefghij"), 1, 8, S("12345"), 0, 5, S("a12345j"));
+ test(S("abcdefghij"), 1, 8, S("12345"), 0, 6, S("a12345j"));
+ test(S("abcdefghij"), 1, 8, S("12345"), 1, 0, S("aj"));
+}
+
+template <class S>
+void test26()
+{
+ test(S("abcdefghij"), 1, 8, S("12345"), 1, 1, S("a2j"));
+ test(S("abcdefghij"), 1, 8, S("12345"), 1, 2, S("a23j"));
+ test(S("abcdefghij"), 1, 8, S("12345"), 1, 3, S("a234j"));
+ test(S("abcdefghij"), 1, 8, S("12345"), 1, 4, S("a2345j"));
+ test(S("abcdefghij"), 1, 8, S("12345"), 1, 5, S("a2345j"));
+ test(S("abcdefghij"), 1, 8, S("12345"), 2, 0, S("aj"));
+ test(S("abcdefghij"), 1, 8, S("12345"), 2, 1, S("a3j"));
+ test(S("abcdefghij"), 1, 8, S("12345"), 2, 2, S("a34j"));
+ test(S("abcdefghij"), 1, 8, S("12345"), 2, 3, S("a345j"));
+ test(S("abcdefghij"), 1, 8, S("12345"), 2, 4, S("a345j"));
+ test(S("abcdefghij"), 1, 8, S("12345"), 4, 0, S("aj"));
+ test(S("abcdefghij"), 1, 8, S("12345"), 4, 1, S("a5j"));
+ test(S("abcdefghij"), 1, 8, S("12345"), 4, 2, S("a5j"));
+ test(S("abcdefghij"), 1, 8, S("12345"), 5, 0, S("aj"));
+ test(S("abcdefghij"), 1, 8, S("12345"), 5, 1, S("aj"));
+ test(S("abcdefghij"), 1, 8, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcdefghij"), 1, 8, S("1234567890"), 0, 0, S("aj"));
+ test(S("abcdefghij"), 1, 8, S("1234567890"), 0, 1, S("a1j"));
+ test(S("abcdefghij"), 1, 8, S("1234567890"), 0, 5, S("a12345j"));
+ test(S("abcdefghij"), 1, 8, S("1234567890"), 0, 9, S("a123456789j"));
+ test(S("abcdefghij"), 1, 8, S("1234567890"), 0, 10, S("a1234567890j"));
+ test(S("abcdefghij"), 1, 8, S("1234567890"), 0, 11, S("a1234567890j"));
+ test(S("abcdefghij"), 1, 8, S("1234567890"), 1, 0, S("aj"));
+ test(S("abcdefghij"), 1, 8, S("1234567890"), 1, 1, S("a2j"));
+ test(S("abcdefghij"), 1, 8, S("1234567890"), 1, 4, S("a2345j"));
+ test(S("abcdefghij"), 1, 8, S("1234567890"), 1, 8, S("a23456789j"));
+ test(S("abcdefghij"), 1, 8, S("1234567890"), 1, 9, S("a234567890j"));
+ test(S("abcdefghij"), 1, 8, S("1234567890"), 1, 10, S("a234567890j"));
+ test(S("abcdefghij"), 1, 8, S("1234567890"), 5, 0, S("aj"));
+ test(S("abcdefghij"), 1, 8, S("1234567890"), 5, 1, S("a6j"));
+ test(S("abcdefghij"), 1, 8, S("1234567890"), 5, 2, S("a67j"));
+ test(S("abcdefghij"), 1, 8, S("1234567890"), 5, 4, S("a6789j"));
+ test(S("abcdefghij"), 1, 8, S("1234567890"), 5, 5, S("a67890j"));
+ test(S("abcdefghij"), 1, 8, S("1234567890"), 5, 6, S("a67890j"));
+ test(S("abcdefghij"), 1, 8, S("1234567890"), 9, 0, S("aj"));
+ test(S("abcdefghij"), 1, 8, S("1234567890"), 9, 1, S("a0j"));
+ test(S("abcdefghij"), 1, 8, S("1234567890"), 9, 2, S("a0j"));
+ test(S("abcdefghij"), 1, 8, S("1234567890"), 10, 0, S("aj"));
+ test(S("abcdefghij"), 1, 8, S("1234567890"), 10, 1, S("aj"));
+ test(S("abcdefghij"), 1, 8, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 0, 0, S("aj"));
+ test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 0, 1, S("a1j"));
+ test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 0, 10, S("a1234567890j"));
+ test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 0, 19, S("a1234567890123456789j"));
+ test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 0, 20, S("a12345678901234567890j"));
+ test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 0, 21, S("a12345678901234567890j"));
+ test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 1, 0, S("aj"));
+ test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 1, 1, S("a2j"));
+ test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 1, 9, S("a234567890j"));
+ test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 1, 18, S("a234567890123456789j"));
+ test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 1, 19, S("a2345678901234567890j"));
+ test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 1, 20, S("a2345678901234567890j"));
+ test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 10, 0, S("aj"));
+ test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 10, 1, S("a1j"));
+ test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 10, 5, S("a12345j"));
+ test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 10, 9, S("a123456789j"));
+ test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 10, 10, S("a1234567890j"));
+ test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 10, 11, S("a1234567890j"));
+ test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 19, 0, S("aj"));
+ test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 19, 1, S("a0j"));
+ test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 19, 2, S("a0j"));
+ test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 20, 0, S("aj"));
+ test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 20, 1, S("aj"));
+ test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcdefghij"), 1, 9, S(""), 0, 0, S("a"));
+ test(S("abcdefghij"), 1, 9, S(""), 0, 1, S("a"));
+ test(S("abcdefghij"), 1, 9, S(""), 1, 0, S("can't happen"));
+ test(S("abcdefghij"), 1, 9, S("12345"), 0, 0, S("a"));
+ test(S("abcdefghij"), 1, 9, S("12345"), 0, 1, S("a1"));
+ test(S("abcdefghij"), 1, 9, S("12345"), 0, 2, S("a12"));
+ test(S("abcdefghij"), 1, 9, S("12345"), 0, 4, S("a1234"));
+ test(S("abcdefghij"), 1, 9, S("12345"), 0, 5, S("a12345"));
+ test(S("abcdefghij"), 1, 9, S("12345"), 0, 6, S("a12345"));
+ test(S("abcdefghij"), 1, 9, S("12345"), 1, 0, S("a"));
+ test(S("abcdefghij"), 1, 9, S("12345"), 1, 1, S("a2"));
+ test(S("abcdefghij"), 1, 9, S("12345"), 1, 2, S("a23"));
+ test(S("abcdefghij"), 1, 9, S("12345"), 1, 3, S("a234"));
+ test(S("abcdefghij"), 1, 9, S("12345"), 1, 4, S("a2345"));
+ test(S("abcdefghij"), 1, 9, S("12345"), 1, 5, S("a2345"));
+ test(S("abcdefghij"), 1, 9, S("12345"), 2, 0, S("a"));
+ test(S("abcdefghij"), 1, 9, S("12345"), 2, 1, S("a3"));
+ test(S("abcdefghij"), 1, 9, S("12345"), 2, 2, S("a34"));
+ test(S("abcdefghij"), 1, 9, S("12345"), 2, 3, S("a345"));
+ test(S("abcdefghij"), 1, 9, S("12345"), 2, 4, S("a345"));
+ test(S("abcdefghij"), 1, 9, S("12345"), 4, 0, S("a"));
+ test(S("abcdefghij"), 1, 9, S("12345"), 4, 1, S("a5"));
+ test(S("abcdefghij"), 1, 9, S("12345"), 4, 2, S("a5"));
+ test(S("abcdefghij"), 1, 9, S("12345"), 5, 0, S("a"));
+ test(S("abcdefghij"), 1, 9, S("12345"), 5, 1, S("a"));
+ test(S("abcdefghij"), 1, 9, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcdefghij"), 1, 9, S("1234567890"), 0, 0, S("a"));
+ test(S("abcdefghij"), 1, 9, S("1234567890"), 0, 1, S("a1"));
+ test(S("abcdefghij"), 1, 9, S("1234567890"), 0, 5, S("a12345"));
+ test(S("abcdefghij"), 1, 9, S("1234567890"), 0, 9, S("a123456789"));
+ test(S("abcdefghij"), 1, 9, S("1234567890"), 0, 10, S("a1234567890"));
+ test(S("abcdefghij"), 1, 9, S("1234567890"), 0, 11, S("a1234567890"));
+ test(S("abcdefghij"), 1, 9, S("1234567890"), 1, 0, S("a"));
+ test(S("abcdefghij"), 1, 9, S("1234567890"), 1, 1, S("a2"));
+ test(S("abcdefghij"), 1, 9, S("1234567890"), 1, 4, S("a2345"));
+ test(S("abcdefghij"), 1, 9, S("1234567890"), 1, 8, S("a23456789"));
+}
+
+template <class S>
+void test27()
+{
+ test(S("abcdefghij"), 1, 9, S("1234567890"), 1, 9, S("a234567890"));
+ test(S("abcdefghij"), 1, 9, S("1234567890"), 1, 10, S("a234567890"));
+ test(S("abcdefghij"), 1, 9, S("1234567890"), 5, 0, S("a"));
+ test(S("abcdefghij"), 1, 9, S("1234567890"), 5, 1, S("a6"));
+ test(S("abcdefghij"), 1, 9, S("1234567890"), 5, 2, S("a67"));
+ test(S("abcdefghij"), 1, 9, S("1234567890"), 5, 4, S("a6789"));
+ test(S("abcdefghij"), 1, 9, S("1234567890"), 5, 5, S("a67890"));
+ test(S("abcdefghij"), 1, 9, S("1234567890"), 5, 6, S("a67890"));
+ test(S("abcdefghij"), 1, 9, S("1234567890"), 9, 0, S("a"));
+ test(S("abcdefghij"), 1, 9, S("1234567890"), 9, 1, S("a0"));
+ test(S("abcdefghij"), 1, 9, S("1234567890"), 9, 2, S("a0"));
+ test(S("abcdefghij"), 1, 9, S("1234567890"), 10, 0, S("a"));
+ test(S("abcdefghij"), 1, 9, S("1234567890"), 10, 1, S("a"));
+ test(S("abcdefghij"), 1, 9, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 0, 0, S("a"));
+ test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 0, 1, S("a1"));
+ test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 0, 10, S("a1234567890"));
+ test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 0, 19, S("a1234567890123456789"));
+ test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 0, 20, S("a12345678901234567890"));
+ test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 0, 21, S("a12345678901234567890"));
+ test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 1, 0, S("a"));
+ test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 1, 1, S("a2"));
+ test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 1, 9, S("a234567890"));
+ test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 1, 18, S("a234567890123456789"));
+ test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 1, 19, S("a2345678901234567890"));
+ test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 1, 20, S("a2345678901234567890"));
+ test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 10, 0, S("a"));
+ test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 10, 1, S("a1"));
+ test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 10, 5, S("a12345"));
+ test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 10, 9, S("a123456789"));
+ test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 10, 10, S("a1234567890"));
+ test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 10, 11, S("a1234567890"));
+ test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 19, 0, S("a"));
+ test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 19, 1, S("a0"));
+ test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 19, 2, S("a0"));
+ test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 20, 0, S("a"));
+ test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 20, 1, S("a"));
+ test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcdefghij"), 1, 10, S(""), 0, 0, S("a"));
+ test(S("abcdefghij"), 1, 10, S(""), 0, 1, S("a"));
+ test(S("abcdefghij"), 1, 10, S(""), 1, 0, S("can't happen"));
+ test(S("abcdefghij"), 1, 10, S("12345"), 0, 0, S("a"));
+ test(S("abcdefghij"), 1, 10, S("12345"), 0, 1, S("a1"));
+ test(S("abcdefghij"), 1, 10, S("12345"), 0, 2, S("a12"));
+ test(S("abcdefghij"), 1, 10, S("12345"), 0, 4, S("a1234"));
+ test(S("abcdefghij"), 1, 10, S("12345"), 0, 5, S("a12345"));
+ test(S("abcdefghij"), 1, 10, S("12345"), 0, 6, S("a12345"));
+ test(S("abcdefghij"), 1, 10, S("12345"), 1, 0, S("a"));
+ test(S("abcdefghij"), 1, 10, S("12345"), 1, 1, S("a2"));
+ test(S("abcdefghij"), 1, 10, S("12345"), 1, 2, S("a23"));
+ test(S("abcdefghij"), 1, 10, S("12345"), 1, 3, S("a234"));
+ test(S("abcdefghij"), 1, 10, S("12345"), 1, 4, S("a2345"));
+ test(S("abcdefghij"), 1, 10, S("12345"), 1, 5, S("a2345"));
+ test(S("abcdefghij"), 1, 10, S("12345"), 2, 0, S("a"));
+ test(S("abcdefghij"), 1, 10, S("12345"), 2, 1, S("a3"));
+ test(S("abcdefghij"), 1, 10, S("12345"), 2, 2, S("a34"));
+ test(S("abcdefghij"), 1, 10, S("12345"), 2, 3, S("a345"));
+ test(S("abcdefghij"), 1, 10, S("12345"), 2, 4, S("a345"));
+ test(S("abcdefghij"), 1, 10, S("12345"), 4, 0, S("a"));
+ test(S("abcdefghij"), 1, 10, S("12345"), 4, 1, S("a5"));
+ test(S("abcdefghij"), 1, 10, S("12345"), 4, 2, S("a5"));
+ test(S("abcdefghij"), 1, 10, S("12345"), 5, 0, S("a"));
+ test(S("abcdefghij"), 1, 10, S("12345"), 5, 1, S("a"));
+ test(S("abcdefghij"), 1, 10, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcdefghij"), 1, 10, S("1234567890"), 0, 0, S("a"));
+ test(S("abcdefghij"), 1, 10, S("1234567890"), 0, 1, S("a1"));
+ test(S("abcdefghij"), 1, 10, S("1234567890"), 0, 5, S("a12345"));
+ test(S("abcdefghij"), 1, 10, S("1234567890"), 0, 9, S("a123456789"));
+ test(S("abcdefghij"), 1, 10, S("1234567890"), 0, 10, S("a1234567890"));
+ test(S("abcdefghij"), 1, 10, S("1234567890"), 0, 11, S("a1234567890"));
+ test(S("abcdefghij"), 1, 10, S("1234567890"), 1, 0, S("a"));
+ test(S("abcdefghij"), 1, 10, S("1234567890"), 1, 1, S("a2"));
+ test(S("abcdefghij"), 1, 10, S("1234567890"), 1, 4, S("a2345"));
+ test(S("abcdefghij"), 1, 10, S("1234567890"), 1, 8, S("a23456789"));
+ test(S("abcdefghij"), 1, 10, S("1234567890"), 1, 9, S("a234567890"));
+ test(S("abcdefghij"), 1, 10, S("1234567890"), 1, 10, S("a234567890"));
+ test(S("abcdefghij"), 1, 10, S("1234567890"), 5, 0, S("a"));
+ test(S("abcdefghij"), 1, 10, S("1234567890"), 5, 1, S("a6"));
+ test(S("abcdefghij"), 1, 10, S("1234567890"), 5, 2, S("a67"));
+ test(S("abcdefghij"), 1, 10, S("1234567890"), 5, 4, S("a6789"));
+ test(S("abcdefghij"), 1, 10, S("1234567890"), 5, 5, S("a67890"));
+ test(S("abcdefghij"), 1, 10, S("1234567890"), 5, 6, S("a67890"));
+ test(S("abcdefghij"), 1, 10, S("1234567890"), 9, 0, S("a"));
+ test(S("abcdefghij"), 1, 10, S("1234567890"), 9, 1, S("a0"));
+ test(S("abcdefghij"), 1, 10, S("1234567890"), 9, 2, S("a0"));
+ test(S("abcdefghij"), 1, 10, S("1234567890"), 10, 0, S("a"));
+ test(S("abcdefghij"), 1, 10, S("1234567890"), 10, 1, S("a"));
+ test(S("abcdefghij"), 1, 10, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 0, 0, S("a"));
+ test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 0, 1, S("a1"));
+ test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 0, 10, S("a1234567890"));
+ test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 0, 19, S("a1234567890123456789"));
+ test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 0, 20, S("a12345678901234567890"));
+ test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 0, 21, S("a12345678901234567890"));
+ test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 1, 0, S("a"));
+ test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 1, 1, S("a2"));
+ test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 1, 9, S("a234567890"));
+ test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 1, 18, S("a234567890123456789"));
+ test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 1, 19, S("a2345678901234567890"));
+ test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 1, 20, S("a2345678901234567890"));
+}
+
+template <class S>
+void test28()
+{
+ test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 10, 0, S("a"));
+ test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 10, 1, S("a1"));
+ test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 10, 5, S("a12345"));
+ test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 10, 9, S("a123456789"));
+ test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 10, 10, S("a1234567890"));
+ test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 10, 11, S("a1234567890"));
+ test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 19, 0, S("a"));
+ test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 19, 1, S("a0"));
+ test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 19, 2, S("a0"));
+ test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 20, 0, S("a"));
+ test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 20, 1, S("a"));
+ test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcdefghij"), 5, 0, S(""), 0, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 5, 0, S(""), 0, 1, S("abcdefghij"));
+ test(S("abcdefghij"), 5, 0, S(""), 1, 0, S("can't happen"));
+ test(S("abcdefghij"), 5, 0, S("12345"), 0, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 5, 0, S("12345"), 0, 1, S("abcde1fghij"));
+ test(S("abcdefghij"), 5, 0, S("12345"), 0, 2, S("abcde12fghij"));
+ test(S("abcdefghij"), 5, 0, S("12345"), 0, 4, S("abcde1234fghij"));
+ test(S("abcdefghij"), 5, 0, S("12345"), 0, 5, S("abcde12345fghij"));
+ test(S("abcdefghij"), 5, 0, S("12345"), 0, 6, S("abcde12345fghij"));
+ test(S("abcdefghij"), 5, 0, S("12345"), 1, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 5, 0, S("12345"), 1, 1, S("abcde2fghij"));
+ test(S("abcdefghij"), 5, 0, S("12345"), 1, 2, S("abcde23fghij"));
+ test(S("abcdefghij"), 5, 0, S("12345"), 1, 3, S("abcde234fghij"));
+ test(S("abcdefghij"), 5, 0, S("12345"), 1, 4, S("abcde2345fghij"));
+ test(S("abcdefghij"), 5, 0, S("12345"), 1, 5, S("abcde2345fghij"));
+ test(S("abcdefghij"), 5, 0, S("12345"), 2, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 5, 0, S("12345"), 2, 1, S("abcde3fghij"));
+ test(S("abcdefghij"), 5, 0, S("12345"), 2, 2, S("abcde34fghij"));
+ test(S("abcdefghij"), 5, 0, S("12345"), 2, 3, S("abcde345fghij"));
+ test(S("abcdefghij"), 5, 0, S("12345"), 2, 4, S("abcde345fghij"));
+ test(S("abcdefghij"), 5, 0, S("12345"), 4, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 5, 0, S("12345"), 4, 1, S("abcde5fghij"));
+ test(S("abcdefghij"), 5, 0, S("12345"), 4, 2, S("abcde5fghij"));
+ test(S("abcdefghij"), 5, 0, S("12345"), 5, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 5, 0, S("12345"), 5, 1, S("abcdefghij"));
+ test(S("abcdefghij"), 5, 0, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcdefghij"), 5, 0, S("1234567890"), 0, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 5, 0, S("1234567890"), 0, 1, S("abcde1fghij"));
+ test(S("abcdefghij"), 5, 0, S("1234567890"), 0, 5, S("abcde12345fghij"));
+ test(S("abcdefghij"), 5, 0, S("1234567890"), 0, 9, S("abcde123456789fghij"));
+ test(S("abcdefghij"), 5, 0, S("1234567890"), 0, 10, S("abcde1234567890fghij"));
+ test(S("abcdefghij"), 5, 0, S("1234567890"), 0, 11, S("abcde1234567890fghij"));
+ test(S("abcdefghij"), 5, 0, S("1234567890"), 1, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 5, 0, S("1234567890"), 1, 1, S("abcde2fghij"));
+ test(S("abcdefghij"), 5, 0, S("1234567890"), 1, 4, S("abcde2345fghij"));
+ test(S("abcdefghij"), 5, 0, S("1234567890"), 1, 8, S("abcde23456789fghij"));
+ test(S("abcdefghij"), 5, 0, S("1234567890"), 1, 9, S("abcde234567890fghij"));
+ test(S("abcdefghij"), 5, 0, S("1234567890"), 1, 10, S("abcde234567890fghij"));
+ test(S("abcdefghij"), 5, 0, S("1234567890"), 5, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 5, 0, S("1234567890"), 5, 1, S("abcde6fghij"));
+ test(S("abcdefghij"), 5, 0, S("1234567890"), 5, 2, S("abcde67fghij"));
+ test(S("abcdefghij"), 5, 0, S("1234567890"), 5, 4, S("abcde6789fghij"));
+ test(S("abcdefghij"), 5, 0, S("1234567890"), 5, 5, S("abcde67890fghij"));
+ test(S("abcdefghij"), 5, 0, S("1234567890"), 5, 6, S("abcde67890fghij"));
+ test(S("abcdefghij"), 5, 0, S("1234567890"), 9, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 5, 0, S("1234567890"), 9, 1, S("abcde0fghij"));
+ test(S("abcdefghij"), 5, 0, S("1234567890"), 9, 2, S("abcde0fghij"));
+ test(S("abcdefghij"), 5, 0, S("1234567890"), 10, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 5, 0, S("1234567890"), 10, 1, S("abcdefghij"));
+ test(S("abcdefghij"), 5, 0, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 0, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 0, 1, S("abcde1fghij"));
+ test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 0, 10, S("abcde1234567890fghij"));
+ test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 0, 19, S("abcde1234567890123456789fghij"));
+ test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 0, 20, S("abcde12345678901234567890fghij"));
+ test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 0, 21, S("abcde12345678901234567890fghij"));
+ test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 1, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 1, 1, S("abcde2fghij"));
+ test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 1, 9, S("abcde234567890fghij"));
+ test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 1, 18, S("abcde234567890123456789fghij"));
+ test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 1, 19, S("abcde2345678901234567890fghij"));
+ test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 1, 20, S("abcde2345678901234567890fghij"));
+ test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 10, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 10, 1, S("abcde1fghij"));
+ test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 10, 5, S("abcde12345fghij"));
+ test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 10, 9, S("abcde123456789fghij"));
+ test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 10, 10, S("abcde1234567890fghij"));
+ test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 10, 11, S("abcde1234567890fghij"));
+ test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 19, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 19, 1, S("abcde0fghij"));
+ test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 19, 2, S("abcde0fghij"));
+ test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 20, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 20, 1, S("abcdefghij"));
+ test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcdefghij"), 5, 1, S(""), 0, 0, S("abcdeghij"));
+ test(S("abcdefghij"), 5, 1, S(""), 0, 1, S("abcdeghij"));
+ test(S("abcdefghij"), 5, 1, S(""), 1, 0, S("can't happen"));
+ test(S("abcdefghij"), 5, 1, S("12345"), 0, 0, S("abcdeghij"));
+ test(S("abcdefghij"), 5, 1, S("12345"), 0, 1, S("abcde1ghij"));
+ test(S("abcdefghij"), 5, 1, S("12345"), 0, 2, S("abcde12ghij"));
+ test(S("abcdefghij"), 5, 1, S("12345"), 0, 4, S("abcde1234ghij"));
+ test(S("abcdefghij"), 5, 1, S("12345"), 0, 5, S("abcde12345ghij"));
+ test(S("abcdefghij"), 5, 1, S("12345"), 0, 6, S("abcde12345ghij"));
+ test(S("abcdefghij"), 5, 1, S("12345"), 1, 0, S("abcdeghij"));
+ test(S("abcdefghij"), 5, 1, S("12345"), 1, 1, S("abcde2ghij"));
+ test(S("abcdefghij"), 5, 1, S("12345"), 1, 2, S("abcde23ghij"));
+ test(S("abcdefghij"), 5, 1, S("12345"), 1, 3, S("abcde234ghij"));
+ test(S("abcdefghij"), 5, 1, S("12345"), 1, 4, S("abcde2345ghij"));
+}
+
+template <class S>
+void test29()
+{
+ test(S("abcdefghij"), 5, 1, S("12345"), 1, 5, S("abcde2345ghij"));
+ test(S("abcdefghij"), 5, 1, S("12345"), 2, 0, S("abcdeghij"));
+ test(S("abcdefghij"), 5, 1, S("12345"), 2, 1, S("abcde3ghij"));
+ test(S("abcdefghij"), 5, 1, S("12345"), 2, 2, S("abcde34ghij"));
+ test(S("abcdefghij"), 5, 1, S("12345"), 2, 3, S("abcde345ghij"));
+ test(S("abcdefghij"), 5, 1, S("12345"), 2, 4, S("abcde345ghij"));
+ test(S("abcdefghij"), 5, 1, S("12345"), 4, 0, S("abcdeghij"));
+ test(S("abcdefghij"), 5, 1, S("12345"), 4, 1, S("abcde5ghij"));
+ test(S("abcdefghij"), 5, 1, S("12345"), 4, 2, S("abcde5ghij"));
+ test(S("abcdefghij"), 5, 1, S("12345"), 5, 0, S("abcdeghij"));
+ test(S("abcdefghij"), 5, 1, S("12345"), 5, 1, S("abcdeghij"));
+ test(S("abcdefghij"), 5, 1, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcdefghij"), 5, 1, S("1234567890"), 0, 0, S("abcdeghij"));
+ test(S("abcdefghij"), 5, 1, S("1234567890"), 0, 1, S("abcde1ghij"));
+ test(S("abcdefghij"), 5, 1, S("1234567890"), 0, 5, S("abcde12345ghij"));
+ test(S("abcdefghij"), 5, 1, S("1234567890"), 0, 9, S("abcde123456789ghij"));
+ test(S("abcdefghij"), 5, 1, S("1234567890"), 0, 10, S("abcde1234567890ghij"));
+ test(S("abcdefghij"), 5, 1, S("1234567890"), 0, 11, S("abcde1234567890ghij"));
+ test(S("abcdefghij"), 5, 1, S("1234567890"), 1, 0, S("abcdeghij"));
+ test(S("abcdefghij"), 5, 1, S("1234567890"), 1, 1, S("abcde2ghij"));
+ test(S("abcdefghij"), 5, 1, S("1234567890"), 1, 4, S("abcde2345ghij"));
+ test(S("abcdefghij"), 5, 1, S("1234567890"), 1, 8, S("abcde23456789ghij"));
+ test(S("abcdefghij"), 5, 1, S("1234567890"), 1, 9, S("abcde234567890ghij"));
+ test(S("abcdefghij"), 5, 1, S("1234567890"), 1, 10, S("abcde234567890ghij"));
+ test(S("abcdefghij"), 5, 1, S("1234567890"), 5, 0, S("abcdeghij"));
+ test(S("abcdefghij"), 5, 1, S("1234567890"), 5, 1, S("abcde6ghij"));
+ test(S("abcdefghij"), 5, 1, S("1234567890"), 5, 2, S("abcde67ghij"));
+ test(S("abcdefghij"), 5, 1, S("1234567890"), 5, 4, S("abcde6789ghij"));
+ test(S("abcdefghij"), 5, 1, S("1234567890"), 5, 5, S("abcde67890ghij"));
+ test(S("abcdefghij"), 5, 1, S("1234567890"), 5, 6, S("abcde67890ghij"));
+ test(S("abcdefghij"), 5, 1, S("1234567890"), 9, 0, S("abcdeghij"));
+ test(S("abcdefghij"), 5, 1, S("1234567890"), 9, 1, S("abcde0ghij"));
+ test(S("abcdefghij"), 5, 1, S("1234567890"), 9, 2, S("abcde0ghij"));
+ test(S("abcdefghij"), 5, 1, S("1234567890"), 10, 0, S("abcdeghij"));
+ test(S("abcdefghij"), 5, 1, S("1234567890"), 10, 1, S("abcdeghij"));
+ test(S("abcdefghij"), 5, 1, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 0, 0, S("abcdeghij"));
+ test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 0, 1, S("abcde1ghij"));
+ test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 0, 10, S("abcde1234567890ghij"));
+ test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 0, 19, S("abcde1234567890123456789ghij"));
+ test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 0, 20, S("abcde12345678901234567890ghij"));
+ test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 0, 21, S("abcde12345678901234567890ghij"));
+ test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 1, 0, S("abcdeghij"));
+ test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 1, 1, S("abcde2ghij"));
+ test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 1, 9, S("abcde234567890ghij"));
+ test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 1, 18, S("abcde234567890123456789ghij"));
+ test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 1, 19, S("abcde2345678901234567890ghij"));
+ test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 1, 20, S("abcde2345678901234567890ghij"));
+ test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 10, 0, S("abcdeghij"));
+ test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 10, 1, S("abcde1ghij"));
+ test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 10, 5, S("abcde12345ghij"));
+ test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 10, 9, S("abcde123456789ghij"));
+ test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 10, 10, S("abcde1234567890ghij"));
+ test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 10, 11, S("abcde1234567890ghij"));
+ test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 19, 0, S("abcdeghij"));
+ test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 19, 1, S("abcde0ghij"));
+ test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 19, 2, S("abcde0ghij"));
+ test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 20, 0, S("abcdeghij"));
+ test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 20, 1, S("abcdeghij"));
+ test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcdefghij"), 5, 2, S(""), 0, 0, S("abcdehij"));
+ test(S("abcdefghij"), 5, 2, S(""), 0, 1, S("abcdehij"));
+ test(S("abcdefghij"), 5, 2, S(""), 1, 0, S("can't happen"));
+ test(S("abcdefghij"), 5, 2, S("12345"), 0, 0, S("abcdehij"));
+ test(S("abcdefghij"), 5, 2, S("12345"), 0, 1, S("abcde1hij"));
+ test(S("abcdefghij"), 5, 2, S("12345"), 0, 2, S("abcde12hij"));
+ test(S("abcdefghij"), 5, 2, S("12345"), 0, 4, S("abcde1234hij"));
+ test(S("abcdefghij"), 5, 2, S("12345"), 0, 5, S("abcde12345hij"));
+ test(S("abcdefghij"), 5, 2, S("12345"), 0, 6, S("abcde12345hij"));
+ test(S("abcdefghij"), 5, 2, S("12345"), 1, 0, S("abcdehij"));
+ test(S("abcdefghij"), 5, 2, S("12345"), 1, 1, S("abcde2hij"));
+ test(S("abcdefghij"), 5, 2, S("12345"), 1, 2, S("abcde23hij"));
+ test(S("abcdefghij"), 5, 2, S("12345"), 1, 3, S("abcde234hij"));
+ test(S("abcdefghij"), 5, 2, S("12345"), 1, 4, S("abcde2345hij"));
+ test(S("abcdefghij"), 5, 2, S("12345"), 1, 5, S("abcde2345hij"));
+ test(S("abcdefghij"), 5, 2, S("12345"), 2, 0, S("abcdehij"));
+ test(S("abcdefghij"), 5, 2, S("12345"), 2, 1, S("abcde3hij"));
+ test(S("abcdefghij"), 5, 2, S("12345"), 2, 2, S("abcde34hij"));
+ test(S("abcdefghij"), 5, 2, S("12345"), 2, 3, S("abcde345hij"));
+ test(S("abcdefghij"), 5, 2, S("12345"), 2, 4, S("abcde345hij"));
+ test(S("abcdefghij"), 5, 2, S("12345"), 4, 0, S("abcdehij"));
+ test(S("abcdefghij"), 5, 2, S("12345"), 4, 1, S("abcde5hij"));
+ test(S("abcdefghij"), 5, 2, S("12345"), 4, 2, S("abcde5hij"));
+ test(S("abcdefghij"), 5, 2, S("12345"), 5, 0, S("abcdehij"));
+ test(S("abcdefghij"), 5, 2, S("12345"), 5, 1, S("abcdehij"));
+ test(S("abcdefghij"), 5, 2, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcdefghij"), 5, 2, S("1234567890"), 0, 0, S("abcdehij"));
+ test(S("abcdefghij"), 5, 2, S("1234567890"), 0, 1, S("abcde1hij"));
+ test(S("abcdefghij"), 5, 2, S("1234567890"), 0, 5, S("abcde12345hij"));
+ test(S("abcdefghij"), 5, 2, S("1234567890"), 0, 9, S("abcde123456789hij"));
+ test(S("abcdefghij"), 5, 2, S("1234567890"), 0, 10, S("abcde1234567890hij"));
+ test(S("abcdefghij"), 5, 2, S("1234567890"), 0, 11, S("abcde1234567890hij"));
+ test(S("abcdefghij"), 5, 2, S("1234567890"), 1, 0, S("abcdehij"));
+ test(S("abcdefghij"), 5, 2, S("1234567890"), 1, 1, S("abcde2hij"));
+ test(S("abcdefghij"), 5, 2, S("1234567890"), 1, 4, S("abcde2345hij"));
+ test(S("abcdefghij"), 5, 2, S("1234567890"), 1, 8, S("abcde23456789hij"));
+ test(S("abcdefghij"), 5, 2, S("1234567890"), 1, 9, S("abcde234567890hij"));
+ test(S("abcdefghij"), 5, 2, S("1234567890"), 1, 10, S("abcde234567890hij"));
+ test(S("abcdefghij"), 5, 2, S("1234567890"), 5, 0, S("abcdehij"));
+ test(S("abcdefghij"), 5, 2, S("1234567890"), 5, 1, S("abcde6hij"));
+}
+
+template <class S>
+void test30()
+{
+ test(S("abcdefghij"), 5, 2, S("1234567890"), 5, 2, S("abcde67hij"));
+ test(S("abcdefghij"), 5, 2, S("1234567890"), 5, 4, S("abcde6789hij"));
+ test(S("abcdefghij"), 5, 2, S("1234567890"), 5, 5, S("abcde67890hij"));
+ test(S("abcdefghij"), 5, 2, S("1234567890"), 5, 6, S("abcde67890hij"));
+ test(S("abcdefghij"), 5, 2, S("1234567890"), 9, 0, S("abcdehij"));
+ test(S("abcdefghij"), 5, 2, S("1234567890"), 9, 1, S("abcde0hij"));
+ test(S("abcdefghij"), 5, 2, S("1234567890"), 9, 2, S("abcde0hij"));
+ test(S("abcdefghij"), 5, 2, S("1234567890"), 10, 0, S("abcdehij"));
+ test(S("abcdefghij"), 5, 2, S("1234567890"), 10, 1, S("abcdehij"));
+ test(S("abcdefghij"), 5, 2, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 0, 0, S("abcdehij"));
+ test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 0, 1, S("abcde1hij"));
+ test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 0, 10, S("abcde1234567890hij"));
+ test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 0, 19, S("abcde1234567890123456789hij"));
+ test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 0, 20, S("abcde12345678901234567890hij"));
+ test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 0, 21, S("abcde12345678901234567890hij"));
+ test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 1, 0, S("abcdehij"));
+ test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 1, 1, S("abcde2hij"));
+ test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 1, 9, S("abcde234567890hij"));
+ test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 1, 18, S("abcde234567890123456789hij"));
+ test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 1, 19, S("abcde2345678901234567890hij"));
+ test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 1, 20, S("abcde2345678901234567890hij"));
+ test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 10, 0, S("abcdehij"));
+ test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 10, 1, S("abcde1hij"));
+ test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 10, 5, S("abcde12345hij"));
+ test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 10, 9, S("abcde123456789hij"));
+ test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 10, 10, S("abcde1234567890hij"));
+ test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 10, 11, S("abcde1234567890hij"));
+ test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 19, 0, S("abcdehij"));
+ test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 19, 1, S("abcde0hij"));
+ test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 19, 2, S("abcde0hij"));
+ test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 20, 0, S("abcdehij"));
+ test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 20, 1, S("abcdehij"));
+ test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcdefghij"), 5, 4, S(""), 0, 0, S("abcdej"));
+ test(S("abcdefghij"), 5, 4, S(""), 0, 1, S("abcdej"));
+ test(S("abcdefghij"), 5, 4, S(""), 1, 0, S("can't happen"));
+ test(S("abcdefghij"), 5, 4, S("12345"), 0, 0, S("abcdej"));
+ test(S("abcdefghij"), 5, 4, S("12345"), 0, 1, S("abcde1j"));
+ test(S("abcdefghij"), 5, 4, S("12345"), 0, 2, S("abcde12j"));
+ test(S("abcdefghij"), 5, 4, S("12345"), 0, 4, S("abcde1234j"));
+ test(S("abcdefghij"), 5, 4, S("12345"), 0, 5, S("abcde12345j"));
+ test(S("abcdefghij"), 5, 4, S("12345"), 0, 6, S("abcde12345j"));
+ test(S("abcdefghij"), 5, 4, S("12345"), 1, 0, S("abcdej"));
+ test(S("abcdefghij"), 5, 4, S("12345"), 1, 1, S("abcde2j"));
+ test(S("abcdefghij"), 5, 4, S("12345"), 1, 2, S("abcde23j"));
+ test(S("abcdefghij"), 5, 4, S("12345"), 1, 3, S("abcde234j"));
+ test(S("abcdefghij"), 5, 4, S("12345"), 1, 4, S("abcde2345j"));
+ test(S("abcdefghij"), 5, 4, S("12345"), 1, 5, S("abcde2345j"));
+ test(S("abcdefghij"), 5, 4, S("12345"), 2, 0, S("abcdej"));
+ test(S("abcdefghij"), 5, 4, S("12345"), 2, 1, S("abcde3j"));
+ test(S("abcdefghij"), 5, 4, S("12345"), 2, 2, S("abcde34j"));
+ test(S("abcdefghij"), 5, 4, S("12345"), 2, 3, S("abcde345j"));
+ test(S("abcdefghij"), 5, 4, S("12345"), 2, 4, S("abcde345j"));
+ test(S("abcdefghij"), 5, 4, S("12345"), 4, 0, S("abcdej"));
+ test(S("abcdefghij"), 5, 4, S("12345"), 4, 1, S("abcde5j"));
+ test(S("abcdefghij"), 5, 4, S("12345"), 4, 2, S("abcde5j"));
+ test(S("abcdefghij"), 5, 4, S("12345"), 5, 0, S("abcdej"));
+ test(S("abcdefghij"), 5, 4, S("12345"), 5, 1, S("abcdej"));
+ test(S("abcdefghij"), 5, 4, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcdefghij"), 5, 4, S("1234567890"), 0, 0, S("abcdej"));
+ test(S("abcdefghij"), 5, 4, S("1234567890"), 0, 1, S("abcde1j"));
+ test(S("abcdefghij"), 5, 4, S("1234567890"), 0, 5, S("abcde12345j"));
+ test(S("abcdefghij"), 5, 4, S("1234567890"), 0, 9, S("abcde123456789j"));
+ test(S("abcdefghij"), 5, 4, S("1234567890"), 0, 10, S("abcde1234567890j"));
+ test(S("abcdefghij"), 5, 4, S("1234567890"), 0, 11, S("abcde1234567890j"));
+ test(S("abcdefghij"), 5, 4, S("1234567890"), 1, 0, S("abcdej"));
+ test(S("abcdefghij"), 5, 4, S("1234567890"), 1, 1, S("abcde2j"));
+ test(S("abcdefghij"), 5, 4, S("1234567890"), 1, 4, S("abcde2345j"));
+ test(S("abcdefghij"), 5, 4, S("1234567890"), 1, 8, S("abcde23456789j"));
+ test(S("abcdefghij"), 5, 4, S("1234567890"), 1, 9, S("abcde234567890j"));
+ test(S("abcdefghij"), 5, 4, S("1234567890"), 1, 10, S("abcde234567890j"));
+ test(S("abcdefghij"), 5, 4, S("1234567890"), 5, 0, S("abcdej"));
+ test(S("abcdefghij"), 5, 4, S("1234567890"), 5, 1, S("abcde6j"));
+ test(S("abcdefghij"), 5, 4, S("1234567890"), 5, 2, S("abcde67j"));
+ test(S("abcdefghij"), 5, 4, S("1234567890"), 5, 4, S("abcde6789j"));
+ test(S("abcdefghij"), 5, 4, S("1234567890"), 5, 5, S("abcde67890j"));
+ test(S("abcdefghij"), 5, 4, S("1234567890"), 5, 6, S("abcde67890j"));
+ test(S("abcdefghij"), 5, 4, S("1234567890"), 9, 0, S("abcdej"));
+ test(S("abcdefghij"), 5, 4, S("1234567890"), 9, 1, S("abcde0j"));
+ test(S("abcdefghij"), 5, 4, S("1234567890"), 9, 2, S("abcde0j"));
+ test(S("abcdefghij"), 5, 4, S("1234567890"), 10, 0, S("abcdej"));
+ test(S("abcdefghij"), 5, 4, S("1234567890"), 10, 1, S("abcdej"));
+ test(S("abcdefghij"), 5, 4, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 0, 0, S("abcdej"));
+ test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 0, 1, S("abcde1j"));
+ test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 0, 10, S("abcde1234567890j"));
+ test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 0, 19, S("abcde1234567890123456789j"));
+ test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 0, 20, S("abcde12345678901234567890j"));
+ test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 0, 21, S("abcde12345678901234567890j"));
+ test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 1, 0, S("abcdej"));
+ test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 1, 1, S("abcde2j"));
+ test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 1, 9, S("abcde234567890j"));
+ test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 1, 18, S("abcde234567890123456789j"));
+ test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 1, 19, S("abcde2345678901234567890j"));
+ test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 1, 20, S("abcde2345678901234567890j"));
+ test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 10, 0, S("abcdej"));
+ test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 10, 1, S("abcde1j"));
+ test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 10, 5, S("abcde12345j"));
+ test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 10, 9, S("abcde123456789j"));
+}
+
+template <class S>
+void test31()
+{
+ test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 10, 10, S("abcde1234567890j"));
+ test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 10, 11, S("abcde1234567890j"));
+ test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 19, 0, S("abcdej"));
+ test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 19, 1, S("abcde0j"));
+ test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 19, 2, S("abcde0j"));
+ test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 20, 0, S("abcdej"));
+ test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 20, 1, S("abcdej"));
+ test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcdefghij"), 5, 5, S(""), 0, 0, S("abcde"));
+ test(S("abcdefghij"), 5, 5, S(""), 0, 1, S("abcde"));
+ test(S("abcdefghij"), 5, 5, S(""), 1, 0, S("can't happen"));
+ test(S("abcdefghij"), 5, 5, S("12345"), 0, 0, S("abcde"));
+ test(S("abcdefghij"), 5, 5, S("12345"), 0, 1, S("abcde1"));
+ test(S("abcdefghij"), 5, 5, S("12345"), 0, 2, S("abcde12"));
+ test(S("abcdefghij"), 5, 5, S("12345"), 0, 4, S("abcde1234"));
+ test(S("abcdefghij"), 5, 5, S("12345"), 0, 5, S("abcde12345"));
+ test(S("abcdefghij"), 5, 5, S("12345"), 0, 6, S("abcde12345"));
+ test(S("abcdefghij"), 5, 5, S("12345"), 1, 0, S("abcde"));
+ test(S("abcdefghij"), 5, 5, S("12345"), 1, 1, S("abcde2"));
+ test(S("abcdefghij"), 5, 5, S("12345"), 1, 2, S("abcde23"));
+ test(S("abcdefghij"), 5, 5, S("12345"), 1, 3, S("abcde234"));
+ test(S("abcdefghij"), 5, 5, S("12345"), 1, 4, S("abcde2345"));
+ test(S("abcdefghij"), 5, 5, S("12345"), 1, 5, S("abcde2345"));
+ test(S("abcdefghij"), 5, 5, S("12345"), 2, 0, S("abcde"));
+ test(S("abcdefghij"), 5, 5, S("12345"), 2, 1, S("abcde3"));
+ test(S("abcdefghij"), 5, 5, S("12345"), 2, 2, S("abcde34"));
+ test(S("abcdefghij"), 5, 5, S("12345"), 2, 3, S("abcde345"));
+ test(S("abcdefghij"), 5, 5, S("12345"), 2, 4, S("abcde345"));
+ test(S("abcdefghij"), 5, 5, S("12345"), 4, 0, S("abcde"));
+ test(S("abcdefghij"), 5, 5, S("12345"), 4, 1, S("abcde5"));
+ test(S("abcdefghij"), 5, 5, S("12345"), 4, 2, S("abcde5"));
+ test(S("abcdefghij"), 5, 5, S("12345"), 5, 0, S("abcde"));
+ test(S("abcdefghij"), 5, 5, S("12345"), 5, 1, S("abcde"));
+ test(S("abcdefghij"), 5, 5, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcdefghij"), 5, 5, S("1234567890"), 0, 0, S("abcde"));
+ test(S("abcdefghij"), 5, 5, S("1234567890"), 0, 1, S("abcde1"));
+ test(S("abcdefghij"), 5, 5, S("1234567890"), 0, 5, S("abcde12345"));
+ test(S("abcdefghij"), 5, 5, S("1234567890"), 0, 9, S("abcde123456789"));
+ test(S("abcdefghij"), 5, 5, S("1234567890"), 0, 10, S("abcde1234567890"));
+ test(S("abcdefghij"), 5, 5, S("1234567890"), 0, 11, S("abcde1234567890"));
+ test(S("abcdefghij"), 5, 5, S("1234567890"), 1, 0, S("abcde"));
+ test(S("abcdefghij"), 5, 5, S("1234567890"), 1, 1, S("abcde2"));
+ test(S("abcdefghij"), 5, 5, S("1234567890"), 1, 4, S("abcde2345"));
+ test(S("abcdefghij"), 5, 5, S("1234567890"), 1, 8, S("abcde23456789"));
+ test(S("abcdefghij"), 5, 5, S("1234567890"), 1, 9, S("abcde234567890"));
+ test(S("abcdefghij"), 5, 5, S("1234567890"), 1, 10, S("abcde234567890"));
+ test(S("abcdefghij"), 5, 5, S("1234567890"), 5, 0, S("abcde"));
+ test(S("abcdefghij"), 5, 5, S("1234567890"), 5, 1, S("abcde6"));
+ test(S("abcdefghij"), 5, 5, S("1234567890"), 5, 2, S("abcde67"));
+ test(S("abcdefghij"), 5, 5, S("1234567890"), 5, 4, S("abcde6789"));
+ test(S("abcdefghij"), 5, 5, S("1234567890"), 5, 5, S("abcde67890"));
+ test(S("abcdefghij"), 5, 5, S("1234567890"), 5, 6, S("abcde67890"));
+ test(S("abcdefghij"), 5, 5, S("1234567890"), 9, 0, S("abcde"));
+ test(S("abcdefghij"), 5, 5, S("1234567890"), 9, 1, S("abcde0"));
+ test(S("abcdefghij"), 5, 5, S("1234567890"), 9, 2, S("abcde0"));
+ test(S("abcdefghij"), 5, 5, S("1234567890"), 10, 0, S("abcde"));
+ test(S("abcdefghij"), 5, 5, S("1234567890"), 10, 1, S("abcde"));
+ test(S("abcdefghij"), 5, 5, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 0, 0, S("abcde"));
+ test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 0, 1, S("abcde1"));
+ test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 0, 10, S("abcde1234567890"));
+ test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 0, 19, S("abcde1234567890123456789"));
+ test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 0, 20, S("abcde12345678901234567890"));
+ test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 0, 21, S("abcde12345678901234567890"));
+ test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 1, 0, S("abcde"));
+ test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 1, 1, S("abcde2"));
+ test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 1, 9, S("abcde234567890"));
+ test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 1, 18, S("abcde234567890123456789"));
+ test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 1, 19, S("abcde2345678901234567890"));
+ test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 1, 20, S("abcde2345678901234567890"));
+ test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 10, 0, S("abcde"));
+ test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 10, 1, S("abcde1"));
+ test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 10, 5, S("abcde12345"));
+ test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 10, 9, S("abcde123456789"));
+ test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 10, 10, S("abcde1234567890"));
+ test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 10, 11, S("abcde1234567890"));
+ test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 19, 0, S("abcde"));
+ test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 19, 1, S("abcde0"));
+ test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 19, 2, S("abcde0"));
+ test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 20, 0, S("abcde"));
+ test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 20, 1, S("abcde"));
+ test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcdefghij"), 5, 6, S(""), 0, 0, S("abcde"));
+ test(S("abcdefghij"), 5, 6, S(""), 0, 1, S("abcde"));
+ test(S("abcdefghij"), 5, 6, S(""), 1, 0, S("can't happen"));
+ test(S("abcdefghij"), 5, 6, S("12345"), 0, 0, S("abcde"));
+ test(S("abcdefghij"), 5, 6, S("12345"), 0, 1, S("abcde1"));
+ test(S("abcdefghij"), 5, 6, S("12345"), 0, 2, S("abcde12"));
+ test(S("abcdefghij"), 5, 6, S("12345"), 0, 4, S("abcde1234"));
+ test(S("abcdefghij"), 5, 6, S("12345"), 0, 5, S("abcde12345"));
+ test(S("abcdefghij"), 5, 6, S("12345"), 0, 6, S("abcde12345"));
+ test(S("abcdefghij"), 5, 6, S("12345"), 1, 0, S("abcde"));
+ test(S("abcdefghij"), 5, 6, S("12345"), 1, 1, S("abcde2"));
+ test(S("abcdefghij"), 5, 6, S("12345"), 1, 2, S("abcde23"));
+ test(S("abcdefghij"), 5, 6, S("12345"), 1, 3, S("abcde234"));
+ test(S("abcdefghij"), 5, 6, S("12345"), 1, 4, S("abcde2345"));
+ test(S("abcdefghij"), 5, 6, S("12345"), 1, 5, S("abcde2345"));
+ test(S("abcdefghij"), 5, 6, S("12345"), 2, 0, S("abcde"));
+ test(S("abcdefghij"), 5, 6, S("12345"), 2, 1, S("abcde3"));
+ test(S("abcdefghij"), 5, 6, S("12345"), 2, 2, S("abcde34"));
+}
+
+template <class S>
+void test32()
+{
+ test(S("abcdefghij"), 5, 6, S("12345"), 2, 3, S("abcde345"));
+ test(S("abcdefghij"), 5, 6, S("12345"), 2, 4, S("abcde345"));
+ test(S("abcdefghij"), 5, 6, S("12345"), 4, 0, S("abcde"));
+ test(S("abcdefghij"), 5, 6, S("12345"), 4, 1, S("abcde5"));
+ test(S("abcdefghij"), 5, 6, S("12345"), 4, 2, S("abcde5"));
+ test(S("abcdefghij"), 5, 6, S("12345"), 5, 0, S("abcde"));
+ test(S("abcdefghij"), 5, 6, S("12345"), 5, 1, S("abcde"));
+ test(S("abcdefghij"), 5, 6, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcdefghij"), 5, 6, S("1234567890"), 0, 0, S("abcde"));
+ test(S("abcdefghij"), 5, 6, S("1234567890"), 0, 1, S("abcde1"));
+ test(S("abcdefghij"), 5, 6, S("1234567890"), 0, 5, S("abcde12345"));
+ test(S("abcdefghij"), 5, 6, S("1234567890"), 0, 9, S("abcde123456789"));
+ test(S("abcdefghij"), 5, 6, S("1234567890"), 0, 10, S("abcde1234567890"));
+ test(S("abcdefghij"), 5, 6, S("1234567890"), 0, 11, S("abcde1234567890"));
+ test(S("abcdefghij"), 5, 6, S("1234567890"), 1, 0, S("abcde"));
+ test(S("abcdefghij"), 5, 6, S("1234567890"), 1, 1, S("abcde2"));
+ test(S("abcdefghij"), 5, 6, S("1234567890"), 1, 4, S("abcde2345"));
+ test(S("abcdefghij"), 5, 6, S("1234567890"), 1, 8, S("abcde23456789"));
+ test(S("abcdefghij"), 5, 6, S("1234567890"), 1, 9, S("abcde234567890"));
+ test(S("abcdefghij"), 5, 6, S("1234567890"), 1, 10, S("abcde234567890"));
+ test(S("abcdefghij"), 5, 6, S("1234567890"), 5, 0, S("abcde"));
+ test(S("abcdefghij"), 5, 6, S("1234567890"), 5, 1, S("abcde6"));
+ test(S("abcdefghij"), 5, 6, S("1234567890"), 5, 2, S("abcde67"));
+ test(S("abcdefghij"), 5, 6, S("1234567890"), 5, 4, S("abcde6789"));
+ test(S("abcdefghij"), 5, 6, S("1234567890"), 5, 5, S("abcde67890"));
+ test(S("abcdefghij"), 5, 6, S("1234567890"), 5, 6, S("abcde67890"));
+ test(S("abcdefghij"), 5, 6, S("1234567890"), 9, 0, S("abcde"));
+ test(S("abcdefghij"), 5, 6, S("1234567890"), 9, 1, S("abcde0"));
+ test(S("abcdefghij"), 5, 6, S("1234567890"), 9, 2, S("abcde0"));
+ test(S("abcdefghij"), 5, 6, S("1234567890"), 10, 0, S("abcde"));
+ test(S("abcdefghij"), 5, 6, S("1234567890"), 10, 1, S("abcde"));
+ test(S("abcdefghij"), 5, 6, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 0, 0, S("abcde"));
+ test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 0, 1, S("abcde1"));
+ test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 0, 10, S("abcde1234567890"));
+ test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 0, 19, S("abcde1234567890123456789"));
+ test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 0, 20, S("abcde12345678901234567890"));
+ test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 0, 21, S("abcde12345678901234567890"));
+ test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 1, 0, S("abcde"));
+ test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 1, 1, S("abcde2"));
+ test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 1, 9, S("abcde234567890"));
+ test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 1, 18, S("abcde234567890123456789"));
+ test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 1, 19, S("abcde2345678901234567890"));
+ test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 1, 20, S("abcde2345678901234567890"));
+ test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 10, 0, S("abcde"));
+ test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 10, 1, S("abcde1"));
+ test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 10, 5, S("abcde12345"));
+ test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 10, 9, S("abcde123456789"));
+ test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 10, 10, S("abcde1234567890"));
+ test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 10, 11, S("abcde1234567890"));
+ test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 19, 0, S("abcde"));
+ test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 19, 1, S("abcde0"));
+ test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 19, 2, S("abcde0"));
+ test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 20, 0, S("abcde"));
+ test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 20, 1, S("abcde"));
+ test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcdefghij"), 9, 0, S(""), 0, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 9, 0, S(""), 0, 1, S("abcdefghij"));
+ test(S("abcdefghij"), 9, 0, S(""), 1, 0, S("can't happen"));
+ test(S("abcdefghij"), 9, 0, S("12345"), 0, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 9, 0, S("12345"), 0, 1, S("abcdefghi1j"));
+ test(S("abcdefghij"), 9, 0, S("12345"), 0, 2, S("abcdefghi12j"));
+ test(S("abcdefghij"), 9, 0, S("12345"), 0, 4, S("abcdefghi1234j"));
+ test(S("abcdefghij"), 9, 0, S("12345"), 0, 5, S("abcdefghi12345j"));
+ test(S("abcdefghij"), 9, 0, S("12345"), 0, 6, S("abcdefghi12345j"));
+ test(S("abcdefghij"), 9, 0, S("12345"), 1, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 9, 0, S("12345"), 1, 1, S("abcdefghi2j"));
+ test(S("abcdefghij"), 9, 0, S("12345"), 1, 2, S("abcdefghi23j"));
+ test(S("abcdefghij"), 9, 0, S("12345"), 1, 3, S("abcdefghi234j"));
+ test(S("abcdefghij"), 9, 0, S("12345"), 1, 4, S("abcdefghi2345j"));
+ test(S("abcdefghij"), 9, 0, S("12345"), 1, 5, S("abcdefghi2345j"));
+ test(S("abcdefghij"), 9, 0, S("12345"), 2, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 9, 0, S("12345"), 2, 1, S("abcdefghi3j"));
+ test(S("abcdefghij"), 9, 0, S("12345"), 2, 2, S("abcdefghi34j"));
+ test(S("abcdefghij"), 9, 0, S("12345"), 2, 3, S("abcdefghi345j"));
+ test(S("abcdefghij"), 9, 0, S("12345"), 2, 4, S("abcdefghi345j"));
+ test(S("abcdefghij"), 9, 0, S("12345"), 4, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 9, 0, S("12345"), 4, 1, S("abcdefghi5j"));
+ test(S("abcdefghij"), 9, 0, S("12345"), 4, 2, S("abcdefghi5j"));
+ test(S("abcdefghij"), 9, 0, S("12345"), 5, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 9, 0, S("12345"), 5, 1, S("abcdefghij"));
+ test(S("abcdefghij"), 9, 0, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcdefghij"), 9, 0, S("1234567890"), 0, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 9, 0, S("1234567890"), 0, 1, S("abcdefghi1j"));
+ test(S("abcdefghij"), 9, 0, S("1234567890"), 0, 5, S("abcdefghi12345j"));
+ test(S("abcdefghij"), 9, 0, S("1234567890"), 0, 9, S("abcdefghi123456789j"));
+ test(S("abcdefghij"), 9, 0, S("1234567890"), 0, 10, S("abcdefghi1234567890j"));
+ test(S("abcdefghij"), 9, 0, S("1234567890"), 0, 11, S("abcdefghi1234567890j"));
+ test(S("abcdefghij"), 9, 0, S("1234567890"), 1, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 9, 0, S("1234567890"), 1, 1, S("abcdefghi2j"));
+ test(S("abcdefghij"), 9, 0, S("1234567890"), 1, 4, S("abcdefghi2345j"));
+ test(S("abcdefghij"), 9, 0, S("1234567890"), 1, 8, S("abcdefghi23456789j"));
+ test(S("abcdefghij"), 9, 0, S("1234567890"), 1, 9, S("abcdefghi234567890j"));
+ test(S("abcdefghij"), 9, 0, S("1234567890"), 1, 10, S("abcdefghi234567890j"));
+ test(S("abcdefghij"), 9, 0, S("1234567890"), 5, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 9, 0, S("1234567890"), 5, 1, S("abcdefghi6j"));
+ test(S("abcdefghij"), 9, 0, S("1234567890"), 5, 2, S("abcdefghi67j"));
+ test(S("abcdefghij"), 9, 0, S("1234567890"), 5, 4, S("abcdefghi6789j"));
+ test(S("abcdefghij"), 9, 0, S("1234567890"), 5, 5, S("abcdefghi67890j"));
+ test(S("abcdefghij"), 9, 0, S("1234567890"), 5, 6, S("abcdefghi67890j"));
+}
+
+template <class S>
+void test33()
+{
+ test(S("abcdefghij"), 9, 0, S("1234567890"), 9, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 9, 0, S("1234567890"), 9, 1, S("abcdefghi0j"));
+ test(S("abcdefghij"), 9, 0, S("1234567890"), 9, 2, S("abcdefghi0j"));
+ test(S("abcdefghij"), 9, 0, S("1234567890"), 10, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 9, 0, S("1234567890"), 10, 1, S("abcdefghij"));
+ test(S("abcdefghij"), 9, 0, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 0, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 0, 1, S("abcdefghi1j"));
+ test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 0, 10, S("abcdefghi1234567890j"));
+ test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 0, 19, S("abcdefghi1234567890123456789j"));
+ test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 0, 20, S("abcdefghi12345678901234567890j"));
+ test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 0, 21, S("abcdefghi12345678901234567890j"));
+ test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 1, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 1, 1, S("abcdefghi2j"));
+ test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 1, 9, S("abcdefghi234567890j"));
+ test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 1, 18, S("abcdefghi234567890123456789j"));
+ test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 1, 19, S("abcdefghi2345678901234567890j"));
+ test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 1, 20, S("abcdefghi2345678901234567890j"));
+ test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 10, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 10, 1, S("abcdefghi1j"));
+ test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 10, 5, S("abcdefghi12345j"));
+ test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 10, 9, S("abcdefghi123456789j"));
+ test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 10, 10, S("abcdefghi1234567890j"));
+ test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 10, 11, S("abcdefghi1234567890j"));
+ test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 19, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 19, 1, S("abcdefghi0j"));
+ test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 19, 2, S("abcdefghi0j"));
+ test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 20, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 20, 1, S("abcdefghij"));
+ test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcdefghij"), 9, 1, S(""), 0, 0, S("abcdefghi"));
+ test(S("abcdefghij"), 9, 1, S(""), 0, 1, S("abcdefghi"));
+ test(S("abcdefghij"), 9, 1, S(""), 1, 0, S("can't happen"));
+ test(S("abcdefghij"), 9, 1, S("12345"), 0, 0, S("abcdefghi"));
+ test(S("abcdefghij"), 9, 1, S("12345"), 0, 1, S("abcdefghi1"));
+ test(S("abcdefghij"), 9, 1, S("12345"), 0, 2, S("abcdefghi12"));
+ test(S("abcdefghij"), 9, 1, S("12345"), 0, 4, S("abcdefghi1234"));
+ test(S("abcdefghij"), 9, 1, S("12345"), 0, 5, S("abcdefghi12345"));
+ test(S("abcdefghij"), 9, 1, S("12345"), 0, 6, S("abcdefghi12345"));
+ test(S("abcdefghij"), 9, 1, S("12345"), 1, 0, S("abcdefghi"));
+ test(S("abcdefghij"), 9, 1, S("12345"), 1, 1, S("abcdefghi2"));
+ test(S("abcdefghij"), 9, 1, S("12345"), 1, 2, S("abcdefghi23"));
+ test(S("abcdefghij"), 9, 1, S("12345"), 1, 3, S("abcdefghi234"));
+ test(S("abcdefghij"), 9, 1, S("12345"), 1, 4, S("abcdefghi2345"));
+ test(S("abcdefghij"), 9, 1, S("12345"), 1, 5, S("abcdefghi2345"));
+ test(S("abcdefghij"), 9, 1, S("12345"), 2, 0, S("abcdefghi"));
+ test(S("abcdefghij"), 9, 1, S("12345"), 2, 1, S("abcdefghi3"));
+ test(S("abcdefghij"), 9, 1, S("12345"), 2, 2, S("abcdefghi34"));
+ test(S("abcdefghij"), 9, 1, S("12345"), 2, 3, S("abcdefghi345"));
+ test(S("abcdefghij"), 9, 1, S("12345"), 2, 4, S("abcdefghi345"));
+ test(S("abcdefghij"), 9, 1, S("12345"), 4, 0, S("abcdefghi"));
+ test(S("abcdefghij"), 9, 1, S("12345"), 4, 1, S("abcdefghi5"));
+ test(S("abcdefghij"), 9, 1, S("12345"), 4, 2, S("abcdefghi5"));
+ test(S("abcdefghij"), 9, 1, S("12345"), 5, 0, S("abcdefghi"));
+ test(S("abcdefghij"), 9, 1, S("12345"), 5, 1, S("abcdefghi"));
+ test(S("abcdefghij"), 9, 1, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcdefghij"), 9, 1, S("1234567890"), 0, 0, S("abcdefghi"));
+ test(S("abcdefghij"), 9, 1, S("1234567890"), 0, 1, S("abcdefghi1"));
+ test(S("abcdefghij"), 9, 1, S("1234567890"), 0, 5, S("abcdefghi12345"));
+ test(S("abcdefghij"), 9, 1, S("1234567890"), 0, 9, S("abcdefghi123456789"));
+ test(S("abcdefghij"), 9, 1, S("1234567890"), 0, 10, S("abcdefghi1234567890"));
+ test(S("abcdefghij"), 9, 1, S("1234567890"), 0, 11, S("abcdefghi1234567890"));
+ test(S("abcdefghij"), 9, 1, S("1234567890"), 1, 0, S("abcdefghi"));
+ test(S("abcdefghij"), 9, 1, S("1234567890"), 1, 1, S("abcdefghi2"));
+ test(S("abcdefghij"), 9, 1, S("1234567890"), 1, 4, S("abcdefghi2345"));
+ test(S("abcdefghij"), 9, 1, S("1234567890"), 1, 8, S("abcdefghi23456789"));
+ test(S("abcdefghij"), 9, 1, S("1234567890"), 1, 9, S("abcdefghi234567890"));
+ test(S("abcdefghij"), 9, 1, S("1234567890"), 1, 10, S("abcdefghi234567890"));
+ test(S("abcdefghij"), 9, 1, S("1234567890"), 5, 0, S("abcdefghi"));
+ test(S("abcdefghij"), 9, 1, S("1234567890"), 5, 1, S("abcdefghi6"));
+ test(S("abcdefghij"), 9, 1, S("1234567890"), 5, 2, S("abcdefghi67"));
+ test(S("abcdefghij"), 9, 1, S("1234567890"), 5, 4, S("abcdefghi6789"));
+ test(S("abcdefghij"), 9, 1, S("1234567890"), 5, 5, S("abcdefghi67890"));
+ test(S("abcdefghij"), 9, 1, S("1234567890"), 5, 6, S("abcdefghi67890"));
+ test(S("abcdefghij"), 9, 1, S("1234567890"), 9, 0, S("abcdefghi"));
+ test(S("abcdefghij"), 9, 1, S("1234567890"), 9, 1, S("abcdefghi0"));
+ test(S("abcdefghij"), 9, 1, S("1234567890"), 9, 2, S("abcdefghi0"));
+ test(S("abcdefghij"), 9, 1, S("1234567890"), 10, 0, S("abcdefghi"));
+ test(S("abcdefghij"), 9, 1, S("1234567890"), 10, 1, S("abcdefghi"));
+ test(S("abcdefghij"), 9, 1, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 0, 0, S("abcdefghi"));
+ test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 0, 1, S("abcdefghi1"));
+ test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 0, 10, S("abcdefghi1234567890"));
+ test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 0, 19, S("abcdefghi1234567890123456789"));
+ test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 0, 20, S("abcdefghi12345678901234567890"));
+ test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 0, 21, S("abcdefghi12345678901234567890"));
+ test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 1, 0, S("abcdefghi"));
+ test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 1, 1, S("abcdefghi2"));
+ test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 1, 9, S("abcdefghi234567890"));
+ test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 1, 18, S("abcdefghi234567890123456789"));
+ test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 1, 19, S("abcdefghi2345678901234567890"));
+ test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 1, 20, S("abcdefghi2345678901234567890"));
+ test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 10, 0, S("abcdefghi"));
+ test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 10, 1, S("abcdefghi1"));
+ test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 10, 5, S("abcdefghi12345"));
+ test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 10, 9, S("abcdefghi123456789"));
+ test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 10, 10, S("abcdefghi1234567890"));
+ test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 10, 11, S("abcdefghi1234567890"));
+ test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 19, 0, S("abcdefghi"));
+ test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 19, 1, S("abcdefghi0"));
+}
+
+template <class S>
+void test34()
+{
+ test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 19, 2, S("abcdefghi0"));
+ test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 20, 0, S("abcdefghi"));
+ test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 20, 1, S("abcdefghi"));
+ test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcdefghij"), 9, 2, S(""), 0, 0, S("abcdefghi"));
+ test(S("abcdefghij"), 9, 2, S(""), 0, 1, S("abcdefghi"));
+ test(S("abcdefghij"), 9, 2, S(""), 1, 0, S("can't happen"));
+ test(S("abcdefghij"), 9, 2, S("12345"), 0, 0, S("abcdefghi"));
+ test(S("abcdefghij"), 9, 2, S("12345"), 0, 1, S("abcdefghi1"));
+ test(S("abcdefghij"), 9, 2, S("12345"), 0, 2, S("abcdefghi12"));
+ test(S("abcdefghij"), 9, 2, S("12345"), 0, 4, S("abcdefghi1234"));
+ test(S("abcdefghij"), 9, 2, S("12345"), 0, 5, S("abcdefghi12345"));
+ test(S("abcdefghij"), 9, 2, S("12345"), 0, 6, S("abcdefghi12345"));
+ test(S("abcdefghij"), 9, 2, S("12345"), 1, 0, S("abcdefghi"));
+ test(S("abcdefghij"), 9, 2, S("12345"), 1, 1, S("abcdefghi2"));
+ test(S("abcdefghij"), 9, 2, S("12345"), 1, 2, S("abcdefghi23"));
+ test(S("abcdefghij"), 9, 2, S("12345"), 1, 3, S("abcdefghi234"));
+ test(S("abcdefghij"), 9, 2, S("12345"), 1, 4, S("abcdefghi2345"));
+ test(S("abcdefghij"), 9, 2, S("12345"), 1, 5, S("abcdefghi2345"));
+ test(S("abcdefghij"), 9, 2, S("12345"), 2, 0, S("abcdefghi"));
+ test(S("abcdefghij"), 9, 2, S("12345"), 2, 1, S("abcdefghi3"));
+ test(S("abcdefghij"), 9, 2, S("12345"), 2, 2, S("abcdefghi34"));
+ test(S("abcdefghij"), 9, 2, S("12345"), 2, 3, S("abcdefghi345"));
+ test(S("abcdefghij"), 9, 2, S("12345"), 2, 4, S("abcdefghi345"));
+ test(S("abcdefghij"), 9, 2, S("12345"), 4, 0, S("abcdefghi"));
+ test(S("abcdefghij"), 9, 2, S("12345"), 4, 1, S("abcdefghi5"));
+ test(S("abcdefghij"), 9, 2, S("12345"), 4, 2, S("abcdefghi5"));
+ test(S("abcdefghij"), 9, 2, S("12345"), 5, 0, S("abcdefghi"));
+ test(S("abcdefghij"), 9, 2, S("12345"), 5, 1, S("abcdefghi"));
+ test(S("abcdefghij"), 9, 2, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcdefghij"), 9, 2, S("1234567890"), 0, 0, S("abcdefghi"));
+ test(S("abcdefghij"), 9, 2, S("1234567890"), 0, 1, S("abcdefghi1"));
+ test(S("abcdefghij"), 9, 2, S("1234567890"), 0, 5, S("abcdefghi12345"));
+ test(S("abcdefghij"), 9, 2, S("1234567890"), 0, 9, S("abcdefghi123456789"));
+ test(S("abcdefghij"), 9, 2, S("1234567890"), 0, 10, S("abcdefghi1234567890"));
+ test(S("abcdefghij"), 9, 2, S("1234567890"), 0, 11, S("abcdefghi1234567890"));
+ test(S("abcdefghij"), 9, 2, S("1234567890"), 1, 0, S("abcdefghi"));
+ test(S("abcdefghij"), 9, 2, S("1234567890"), 1, 1, S("abcdefghi2"));
+ test(S("abcdefghij"), 9, 2, S("1234567890"), 1, 4, S("abcdefghi2345"));
+ test(S("abcdefghij"), 9, 2, S("1234567890"), 1, 8, S("abcdefghi23456789"));
+ test(S("abcdefghij"), 9, 2, S("1234567890"), 1, 9, S("abcdefghi234567890"));
+ test(S("abcdefghij"), 9, 2, S("1234567890"), 1, 10, S("abcdefghi234567890"));
+ test(S("abcdefghij"), 9, 2, S("1234567890"), 5, 0, S("abcdefghi"));
+ test(S("abcdefghij"), 9, 2, S("1234567890"), 5, 1, S("abcdefghi6"));
+ test(S("abcdefghij"), 9, 2, S("1234567890"), 5, 2, S("abcdefghi67"));
+ test(S("abcdefghij"), 9, 2, S("1234567890"), 5, 4, S("abcdefghi6789"));
+ test(S("abcdefghij"), 9, 2, S("1234567890"), 5, 5, S("abcdefghi67890"));
+ test(S("abcdefghij"), 9, 2, S("1234567890"), 5, 6, S("abcdefghi67890"));
+ test(S("abcdefghij"), 9, 2, S("1234567890"), 9, 0, S("abcdefghi"));
+ test(S("abcdefghij"), 9, 2, S("1234567890"), 9, 1, S("abcdefghi0"));
+ test(S("abcdefghij"), 9, 2, S("1234567890"), 9, 2, S("abcdefghi0"));
+ test(S("abcdefghij"), 9, 2, S("1234567890"), 10, 0, S("abcdefghi"));
+ test(S("abcdefghij"), 9, 2, S("1234567890"), 10, 1, S("abcdefghi"));
+ test(S("abcdefghij"), 9, 2, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 0, 0, S("abcdefghi"));
+ test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 0, 1, S("abcdefghi1"));
+ test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 0, 10, S("abcdefghi1234567890"));
+ test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 0, 19, S("abcdefghi1234567890123456789"));
+ test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 0, 20, S("abcdefghi12345678901234567890"));
+ test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 0, 21, S("abcdefghi12345678901234567890"));
+ test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 1, 0, S("abcdefghi"));
+ test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 1, 1, S("abcdefghi2"));
+ test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 1, 9, S("abcdefghi234567890"));
+ test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 1, 18, S("abcdefghi234567890123456789"));
+ test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 1, 19, S("abcdefghi2345678901234567890"));
+ test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 1, 20, S("abcdefghi2345678901234567890"));
+ test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 10, 0, S("abcdefghi"));
+ test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 10, 1, S("abcdefghi1"));
+ test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 10, 5, S("abcdefghi12345"));
+ test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 10, 9, S("abcdefghi123456789"));
+ test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 10, 10, S("abcdefghi1234567890"));
+ test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 10, 11, S("abcdefghi1234567890"));
+ test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 19, 0, S("abcdefghi"));
+ test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 19, 1, S("abcdefghi0"));
+ test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 19, 2, S("abcdefghi0"));
+ test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 20, 0, S("abcdefghi"));
+ test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 20, 1, S("abcdefghi"));
+ test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcdefghij"), 10, 0, S(""), 0, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 10, 0, S(""), 0, 1, S("abcdefghij"));
+ test(S("abcdefghij"), 10, 0, S(""), 1, 0, S("can't happen"));
+ test(S("abcdefghij"), 10, 0, S("12345"), 0, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 10, 0, S("12345"), 0, 1, S("abcdefghij1"));
+ test(S("abcdefghij"), 10, 0, S("12345"), 0, 2, S("abcdefghij12"));
+ test(S("abcdefghij"), 10, 0, S("12345"), 0, 4, S("abcdefghij1234"));
+ test(S("abcdefghij"), 10, 0, S("12345"), 0, 5, S("abcdefghij12345"));
+ test(S("abcdefghij"), 10, 0, S("12345"), 0, 6, S("abcdefghij12345"));
+ test(S("abcdefghij"), 10, 0, S("12345"), 1, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 10, 0, S("12345"), 1, 1, S("abcdefghij2"));
+ test(S("abcdefghij"), 10, 0, S("12345"), 1, 2, S("abcdefghij23"));
+ test(S("abcdefghij"), 10, 0, S("12345"), 1, 3, S("abcdefghij234"));
+ test(S("abcdefghij"), 10, 0, S("12345"), 1, 4, S("abcdefghij2345"));
+ test(S("abcdefghij"), 10, 0, S("12345"), 1, 5, S("abcdefghij2345"));
+ test(S("abcdefghij"), 10, 0, S("12345"), 2, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 10, 0, S("12345"), 2, 1, S("abcdefghij3"));
+ test(S("abcdefghij"), 10, 0, S("12345"), 2, 2, S("abcdefghij34"));
+ test(S("abcdefghij"), 10, 0, S("12345"), 2, 3, S("abcdefghij345"));
+ test(S("abcdefghij"), 10, 0, S("12345"), 2, 4, S("abcdefghij345"));
+ test(S("abcdefghij"), 10, 0, S("12345"), 4, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 10, 0, S("12345"), 4, 1, S("abcdefghij5"));
+}
+
+template <class S>
+void test35()
+{
+ test(S("abcdefghij"), 10, 0, S("12345"), 4, 2, S("abcdefghij5"));
+ test(S("abcdefghij"), 10, 0, S("12345"), 5, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 10, 0, S("12345"), 5, 1, S("abcdefghij"));
+ test(S("abcdefghij"), 10, 0, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcdefghij"), 10, 0, S("1234567890"), 0, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 10, 0, S("1234567890"), 0, 1, S("abcdefghij1"));
+ test(S("abcdefghij"), 10, 0, S("1234567890"), 0, 5, S("abcdefghij12345"));
+ test(S("abcdefghij"), 10, 0, S("1234567890"), 0, 9, S("abcdefghij123456789"));
+ test(S("abcdefghij"), 10, 0, S("1234567890"), 0, 10, S("abcdefghij1234567890"));
+ test(S("abcdefghij"), 10, 0, S("1234567890"), 0, 11, S("abcdefghij1234567890"));
+ test(S("abcdefghij"), 10, 0, S("1234567890"), 1, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 10, 0, S("1234567890"), 1, 1, S("abcdefghij2"));
+ test(S("abcdefghij"), 10, 0, S("1234567890"), 1, 4, S("abcdefghij2345"));
+ test(S("abcdefghij"), 10, 0, S("1234567890"), 1, 8, S("abcdefghij23456789"));
+ test(S("abcdefghij"), 10, 0, S("1234567890"), 1, 9, S("abcdefghij234567890"));
+ test(S("abcdefghij"), 10, 0, S("1234567890"), 1, 10, S("abcdefghij234567890"));
+ test(S("abcdefghij"), 10, 0, S("1234567890"), 5, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 10, 0, S("1234567890"), 5, 1, S("abcdefghij6"));
+ test(S("abcdefghij"), 10, 0, S("1234567890"), 5, 2, S("abcdefghij67"));
+ test(S("abcdefghij"), 10, 0, S("1234567890"), 5, 4, S("abcdefghij6789"));
+ test(S("abcdefghij"), 10, 0, S("1234567890"), 5, 5, S("abcdefghij67890"));
+ test(S("abcdefghij"), 10, 0, S("1234567890"), 5, 6, S("abcdefghij67890"));
+ test(S("abcdefghij"), 10, 0, S("1234567890"), 9, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 10, 0, S("1234567890"), 9, 1, S("abcdefghij0"));
+ test(S("abcdefghij"), 10, 0, S("1234567890"), 9, 2, S("abcdefghij0"));
+ test(S("abcdefghij"), 10, 0, S("1234567890"), 10, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 10, 0, S("1234567890"), 10, 1, S("abcdefghij"));
+ test(S("abcdefghij"), 10, 0, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 0, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 0, 1, S("abcdefghij1"));
+ test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 0, 10, S("abcdefghij1234567890"));
+ test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 0, 19, S("abcdefghij1234567890123456789"));
+ test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 0, 20, S("abcdefghij12345678901234567890"));
+ test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 0, 21, S("abcdefghij12345678901234567890"));
+ test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 1, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 1, 1, S("abcdefghij2"));
+ test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 1, 9, S("abcdefghij234567890"));
+ test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 1, 18, S("abcdefghij234567890123456789"));
+ test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 1, 19, S("abcdefghij2345678901234567890"));
+ test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 1, 20, S("abcdefghij2345678901234567890"));
+ test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 10, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 10, 1, S("abcdefghij1"));
+ test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 10, 5, S("abcdefghij12345"));
+ test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 10, 9, S("abcdefghij123456789"));
+ test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 10, 10, S("abcdefghij1234567890"));
+ test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 10, 11, S("abcdefghij1234567890"));
+ test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 19, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 19, 1, S("abcdefghij0"));
+ test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 19, 2, S("abcdefghij0"));
+ test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 20, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 20, 1, S("abcdefghij"));
+ test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcdefghij"), 10, 1, S(""), 0, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 10, 1, S(""), 0, 1, S("abcdefghij"));
+ test(S("abcdefghij"), 10, 1, S(""), 1, 0, S("can't happen"));
+ test(S("abcdefghij"), 10, 1, S("12345"), 0, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 10, 1, S("12345"), 0, 1, S("abcdefghij1"));
+ test(S("abcdefghij"), 10, 1, S("12345"), 0, 2, S("abcdefghij12"));
+ test(S("abcdefghij"), 10, 1, S("12345"), 0, 4, S("abcdefghij1234"));
+ test(S("abcdefghij"), 10, 1, S("12345"), 0, 5, S("abcdefghij12345"));
+ test(S("abcdefghij"), 10, 1, S("12345"), 0, 6, S("abcdefghij12345"));
+ test(S("abcdefghij"), 10, 1, S("12345"), 1, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 10, 1, S("12345"), 1, 1, S("abcdefghij2"));
+ test(S("abcdefghij"), 10, 1, S("12345"), 1, 2, S("abcdefghij23"));
+ test(S("abcdefghij"), 10, 1, S("12345"), 1, 3, S("abcdefghij234"));
+ test(S("abcdefghij"), 10, 1, S("12345"), 1, 4, S("abcdefghij2345"));
+ test(S("abcdefghij"), 10, 1, S("12345"), 1, 5, S("abcdefghij2345"));
+ test(S("abcdefghij"), 10, 1, S("12345"), 2, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 10, 1, S("12345"), 2, 1, S("abcdefghij3"));
+ test(S("abcdefghij"), 10, 1, S("12345"), 2, 2, S("abcdefghij34"));
+ test(S("abcdefghij"), 10, 1, S("12345"), 2, 3, S("abcdefghij345"));
+ test(S("abcdefghij"), 10, 1, S("12345"), 2, 4, S("abcdefghij345"));
+ test(S("abcdefghij"), 10, 1, S("12345"), 4, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 10, 1, S("12345"), 4, 1, S("abcdefghij5"));
+ test(S("abcdefghij"), 10, 1, S("12345"), 4, 2, S("abcdefghij5"));
+ test(S("abcdefghij"), 10, 1, S("12345"), 5, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 10, 1, S("12345"), 5, 1, S("abcdefghij"));
+ test(S("abcdefghij"), 10, 1, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcdefghij"), 10, 1, S("1234567890"), 0, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 10, 1, S("1234567890"), 0, 1, S("abcdefghij1"));
+ test(S("abcdefghij"), 10, 1, S("1234567890"), 0, 5, S("abcdefghij12345"));
+ test(S("abcdefghij"), 10, 1, S("1234567890"), 0, 9, S("abcdefghij123456789"));
+ test(S("abcdefghij"), 10, 1, S("1234567890"), 0, 10, S("abcdefghij1234567890"));
+ test(S("abcdefghij"), 10, 1, S("1234567890"), 0, 11, S("abcdefghij1234567890"));
+ test(S("abcdefghij"), 10, 1, S("1234567890"), 1, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 10, 1, S("1234567890"), 1, 1, S("abcdefghij2"));
+ test(S("abcdefghij"), 10, 1, S("1234567890"), 1, 4, S("abcdefghij2345"));
+ test(S("abcdefghij"), 10, 1, S("1234567890"), 1, 8, S("abcdefghij23456789"));
+ test(S("abcdefghij"), 10, 1, S("1234567890"), 1, 9, S("abcdefghij234567890"));
+ test(S("abcdefghij"), 10, 1, S("1234567890"), 1, 10, S("abcdefghij234567890"));
+ test(S("abcdefghij"), 10, 1, S("1234567890"), 5, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 10, 1, S("1234567890"), 5, 1, S("abcdefghij6"));
+ test(S("abcdefghij"), 10, 1, S("1234567890"), 5, 2, S("abcdefghij67"));
+ test(S("abcdefghij"), 10, 1, S("1234567890"), 5, 4, S("abcdefghij6789"));
+ test(S("abcdefghij"), 10, 1, S("1234567890"), 5, 5, S("abcdefghij67890"));
+ test(S("abcdefghij"), 10, 1, S("1234567890"), 5, 6, S("abcdefghij67890"));
+ test(S("abcdefghij"), 10, 1, S("1234567890"), 9, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 10, 1, S("1234567890"), 9, 1, S("abcdefghij0"));
+ test(S("abcdefghij"), 10, 1, S("1234567890"), 9, 2, S("abcdefghij0"));
+ test(S("abcdefghij"), 10, 1, S("1234567890"), 10, 0, S("abcdefghij"));
+}
+
+template <class S>
+void test36()
+{
+ test(S("abcdefghij"), 10, 1, S("1234567890"), 10, 1, S("abcdefghij"));
+ test(S("abcdefghij"), 10, 1, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 0, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 0, 1, S("abcdefghij1"));
+ test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 0, 10, S("abcdefghij1234567890"));
+ test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 0, 19, S("abcdefghij1234567890123456789"));
+ test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 0, 20, S("abcdefghij12345678901234567890"));
+ test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 0, 21, S("abcdefghij12345678901234567890"));
+ test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 1, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 1, 1, S("abcdefghij2"));
+ test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 1, 9, S("abcdefghij234567890"));
+ test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 1, 18, S("abcdefghij234567890123456789"));
+ test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 1, 19, S("abcdefghij2345678901234567890"));
+ test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 1, 20, S("abcdefghij2345678901234567890"));
+ test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 10, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 10, 1, S("abcdefghij1"));
+ test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 10, 5, S("abcdefghij12345"));
+ test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 10, 9, S("abcdefghij123456789"));
+ test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 10, 10, S("abcdefghij1234567890"));
+ test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 10, 11, S("abcdefghij1234567890"));
+ test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 19, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 19, 1, S("abcdefghij0"));
+ test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 19, 2, S("abcdefghij0"));
+ test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 20, 0, S("abcdefghij"));
+ test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 20, 1, S("abcdefghij"));
+ test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, S(""), 0, 0, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, S(""), 0, 1, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, S(""), 1, 0, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, S("12345"), 0, 0, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, S("12345"), 0, 1, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, S("12345"), 0, 2, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, S("12345"), 0, 4, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, S("12345"), 0, 5, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, S("12345"), 0, 6, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, S("12345"), 1, 0, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, S("12345"), 1, 1, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, S("12345"), 1, 2, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, S("12345"), 1, 3, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, S("12345"), 1, 4, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, S("12345"), 1, 5, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, S("12345"), 2, 0, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, S("12345"), 2, 1, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, S("12345"), 2, 2, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, S("12345"), 2, 3, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, S("12345"), 2, 4, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, S("12345"), 4, 0, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, S("12345"), 4, 1, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, S("12345"), 4, 2, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, S("12345"), 5, 0, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, S("12345"), 5, 1, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, S("1234567890"), 0, 0, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, S("1234567890"), 0, 1, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, S("1234567890"), 0, 5, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, S("1234567890"), 0, 9, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, S("1234567890"), 0, 10, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, S("1234567890"), 0, 11, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, S("1234567890"), 1, 0, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, S("1234567890"), 1, 1, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, S("1234567890"), 1, 4, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, S("1234567890"), 1, 8, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, S("1234567890"), 1, 9, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, S("1234567890"), 1, 10, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, S("1234567890"), 5, 0, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, S("1234567890"), 5, 1, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, S("1234567890"), 5, 2, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, S("1234567890"), 5, 4, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, S("1234567890"), 5, 5, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, S("1234567890"), 5, 6, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, S("1234567890"), 9, 0, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, S("1234567890"), 9, 1, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, S("1234567890"), 9, 2, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, S("1234567890"), 10, 0, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, S("1234567890"), 10, 1, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 0, 0, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 0, 1, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 0, 10, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 0, 19, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 0, 20, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 0, 21, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 1, 0, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 1, 1, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 1, 9, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 1, 18, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 1, 19, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 1, 20, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 10, 0, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 10, 1, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 10, 5, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 10, 9, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 10, 10, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 10, 11, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 19, 0, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 19, 1, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 19, 2, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 20, 0, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 20, 1, S("can't happen"));
+ test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 21, 0, S("can't happen"));
+}
+
+template <class S>
+void test37()
+{
+ test(S("abcdefghijklmnopqrst"), 0, 0, S(""), 0, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, S(""), 0, 1, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, S(""), 1, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 0, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 0, 1, S("1abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 0, 2, S("12abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 0, 4, S("1234abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 0, 5, S("12345abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 0, 6, S("12345abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 1, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 1, 1, S("2abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 1, 2, S("23abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 1, 3, S("234abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 1, 4, S("2345abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 1, 5, S("2345abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 2, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 2, 1, S("3abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 2, 2, S("34abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 2, 3, S("345abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 2, 4, S("345abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 4, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 4, 1, S("5abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 4, 2, S("5abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 5, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 5, 1, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 0, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 0, 1, S("1abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 0, 5, S("12345abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 0, 9, S("123456789abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 0, 10, S("1234567890abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 0, 11, S("1234567890abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 1, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 1, 1, S("2abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 1, 4, S("2345abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 1, 8, S("23456789abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 1, 9, S("234567890abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 1, 10, S("234567890abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 5, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 5, 1, S("6abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 5, 2, S("67abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 5, 4, S("6789abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 5, 5, S("67890abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 5, 6, S("67890abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 9, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 9, 1, S("0abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 9, 2, S("0abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 10, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 10, 1, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 0, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 0, 1, S("1abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 0, 10, S("1234567890abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 0, 19, S("1234567890123456789abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 0, 20, S("12345678901234567890abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 0, 21, S("12345678901234567890abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 1, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 1, 1, S("2abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 1, 9, S("234567890abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 1, 18, S("234567890123456789abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 1, 19, S("2345678901234567890abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 1, 20, S("2345678901234567890abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 10, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 10, 1, S("1abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 10, 5, S("12345abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 10, 9, S("123456789abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 10, 10, S("1234567890abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 10, 11, S("1234567890abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 19, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 19, 1, S("0abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 19, 2, S("0abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 20, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 20, 1, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S(""), 0, 0, S("bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S(""), 0, 1, S("bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S(""), 1, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 0, 0, S("bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 0, 1, S("1bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 0, 2, S("12bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 0, 4, S("1234bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 0, 5, S("12345bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 0, 6, S("12345bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 1, 0, S("bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 1, 1, S("2bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 1, 2, S("23bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 1, 3, S("234bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 1, 4, S("2345bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 1, 5, S("2345bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 2, 0, S("bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 2, 1, S("3bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 2, 2, S("34bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 2, 3, S("345bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 2, 4, S("345bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 4, 0, S("bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 4, 1, S("5bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 4, 2, S("5bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 5, 0, S("bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 5, 1, S("bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 6, 0, S("can't happen"));
+}
+
+template <class S>
+void test38()
+{
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 0, 0, S("bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 0, 1, S("1bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 0, 5, S("12345bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 0, 9, S("123456789bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 0, 10, S("1234567890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 0, 11, S("1234567890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 1, 0, S("bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 1, 1, S("2bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 1, 4, S("2345bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 1, 8, S("23456789bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 1, 9, S("234567890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 1, 10, S("234567890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 5, 0, S("bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 5, 1, S("6bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 5, 2, S("67bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 5, 4, S("6789bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 5, 5, S("67890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 5, 6, S("67890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 9, 0, S("bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 9, 1, S("0bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 9, 2, S("0bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 10, 0, S("bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 10, 1, S("bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 0, 0, S("bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 0, 1, S("1bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 0, 10, S("1234567890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 0, 19, S("1234567890123456789bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 0, 20, S("12345678901234567890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 0, 21, S("12345678901234567890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 1, 0, S("bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 1, 1, S("2bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 1, 9, S("234567890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 1, 18, S("234567890123456789bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 1, 19, S("2345678901234567890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 1, 20, S("2345678901234567890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 10, 0, S("bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 10, 1, S("1bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 10, 5, S("12345bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 10, 9, S("123456789bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 10, 10, S("1234567890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 10, 11, S("1234567890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 19, 0, S("bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 19, 1, S("0bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 19, 2, S("0bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 20, 0, S("bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 20, 1, S("bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S(""), 0, 0, S("klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S(""), 0, 1, S("klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S(""), 1, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 0, 0, S("klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 0, 1, S("1klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 0, 2, S("12klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 0, 4, S("1234klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 0, 5, S("12345klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 0, 6, S("12345klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 1, 0, S("klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 1, 1, S("2klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 1, 2, S("23klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 1, 3, S("234klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 1, 4, S("2345klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 1, 5, S("2345klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 2, 0, S("klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 2, 1, S("3klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 2, 2, S("34klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 2, 3, S("345klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 2, 4, S("345klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 4, 0, S("klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 4, 1, S("5klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 4, 2, S("5klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 5, 0, S("klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 5, 1, S("klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 0, 0, S("klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 0, 1, S("1klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 0, 5, S("12345klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 0, 9, S("123456789klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 0, 10, S("1234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 0, 11, S("1234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 1, 0, S("klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 1, 1, S("2klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 1, 4, S("2345klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 1, 8, S("23456789klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 1, 9, S("234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 1, 10, S("234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 5, 0, S("klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 5, 1, S("6klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 5, 2, S("67klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 5, 4, S("6789klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 5, 5, S("67890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 5, 6, S("67890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 9, 0, S("klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 9, 1, S("0klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 9, 2, S("0klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 10, 0, S("klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 10, 1, S("klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 0, 0, S("klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 0, 1, S("1klmnopqrst"));
+}
+
+template <class S>
+void test39()
+{
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 0, 10, S("1234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 0, 19, S("1234567890123456789klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 0, 20, S("12345678901234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 0, 21, S("12345678901234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 1, 0, S("klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 1, 1, S("2klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 1, 9, S("234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 1, 18, S("234567890123456789klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 1, 19, S("2345678901234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 1, 20, S("2345678901234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 10, 0, S("klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 10, 1, S("1klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 10, 5, S("12345klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 10, 9, S("123456789klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 10, 10, S("1234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 10, 11, S("1234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 19, 0, S("klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 19, 1, S("0klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 19, 2, S("0klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 20, 0, S("klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 20, 1, S("klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S(""), 0, 0, S("t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S(""), 0, 1, S("t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S(""), 1, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 0, 0, S("t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 0, 1, S("1t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 0, 2, S("12t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 0, 4, S("1234t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 0, 5, S("12345t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 0, 6, S("12345t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 1, 0, S("t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 1, 1, S("2t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 1, 2, S("23t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 1, 3, S("234t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 1, 4, S("2345t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 1, 5, S("2345t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 2, 0, S("t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 2, 1, S("3t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 2, 2, S("34t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 2, 3, S("345t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 2, 4, S("345t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 4, 0, S("t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 4, 1, S("5t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 4, 2, S("5t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 5, 0, S("t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 5, 1, S("t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 0, 0, S("t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 0, 1, S("1t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 0, 5, S("12345t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 0, 9, S("123456789t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 0, 10, S("1234567890t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 0, 11, S("1234567890t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 1, 0, S("t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 1, 1, S("2t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 1, 4, S("2345t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 1, 8, S("23456789t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 1, 9, S("234567890t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 1, 10, S("234567890t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 5, 0, S("t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 5, 1, S("6t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 5, 2, S("67t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 5, 4, S("6789t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 5, 5, S("67890t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 5, 6, S("67890t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 9, 0, S("t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 9, 1, S("0t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 9, 2, S("0t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 10, 0, S("t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 10, 1, S("t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 0, 0, S("t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 0, 1, S("1t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 0, 10, S("1234567890t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 0, 19, S("1234567890123456789t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 0, 20, S("12345678901234567890t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 0, 21, S("12345678901234567890t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 1, 0, S("t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 1, 1, S("2t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 1, 9, S("234567890t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 1, 18, S("234567890123456789t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 1, 19, S("2345678901234567890t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 1, 20, S("2345678901234567890t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 10, 0, S("t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 10, 1, S("1t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 10, 5, S("12345t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 10, 9, S("123456789t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 10, 10, S("1234567890t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 10, 11, S("1234567890t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 19, 0, S("t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 19, 1, S("0t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 19, 2, S("0t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 20, 0, S("t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 20, 1, S("t"));
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S(""), 0, 0, S(""));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S(""), 0, 1, S(""));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S(""), 1, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 0, 0, S(""));
+}
+
+template <class S>
+void test40()
+{
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 0, 1, S("1"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 0, 2, S("12"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 0, 4, S("1234"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 0, 5, S("12345"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 0, 6, S("12345"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 1, 0, S(""));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 1, 1, S("2"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 1, 2, S("23"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 1, 3, S("234"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 1, 4, S("2345"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 1, 5, S("2345"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 2, 0, S(""));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 2, 1, S("3"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 2, 2, S("34"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 2, 3, S("345"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 2, 4, S("345"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 4, 0, S(""));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 4, 1, S("5"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 4, 2, S("5"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 5, 0, S(""));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 5, 1, S(""));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 0, 0, S(""));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 0, 1, S("1"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 0, 5, S("12345"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 0, 9, S("123456789"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 0, 10, S("1234567890"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 0, 11, S("1234567890"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 1, 0, S(""));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 1, 1, S("2"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 1, 4, S("2345"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 1, 8, S("23456789"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 1, 9, S("234567890"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 1, 10, S("234567890"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 5, 0, S(""));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 5, 1, S("6"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 5, 2, S("67"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 5, 4, S("6789"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 5, 5, S("67890"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 5, 6, S("67890"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 9, 0, S(""));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 9, 1, S("0"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 9, 2, S("0"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 10, 0, S(""));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 10, 1, S(""));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 0, 0, S(""));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 0, 1, S("1"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 0, 10, S("1234567890"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 0, 19, S("1234567890123456789"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 0, 20, S("12345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 0, 21, S("12345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 1, 0, S(""));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 1, 1, S("2"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 1, 9, S("234567890"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 1, 18, S("234567890123456789"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 1, 19, S("2345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 1, 20, S("2345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 10, 0, S(""));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 10, 1, S("1"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 10, 5, S("12345"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 10, 9, S("123456789"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 10, 10, S("1234567890"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 10, 11, S("1234567890"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 19, 0, S(""));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 19, 1, S("0"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 19, 2, S("0"));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 20, 0, S(""));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 20, 1, S(""));
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 0, 21, S(""), 0, 0, S(""));
+ test(S("abcdefghijklmnopqrst"), 0, 21, S(""), 0, 1, S(""));
+ test(S("abcdefghijklmnopqrst"), 0, 21, S(""), 1, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 0, 0, S(""));
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 0, 1, S("1"));
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 0, 2, S("12"));
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 0, 4, S("1234"));
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 0, 5, S("12345"));
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 0, 6, S("12345"));
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 1, 0, S(""));
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 1, 1, S("2"));
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 1, 2, S("23"));
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 1, 3, S("234"));
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 1, 4, S("2345"));
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 1, 5, S("2345"));
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 2, 0, S(""));
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 2, 1, S("3"));
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 2, 2, S("34"));
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 2, 3, S("345"));
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 2, 4, S("345"));
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 4, 0, S(""));
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 4, 1, S("5"));
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 4, 2, S("5"));
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 5, 0, S(""));
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 5, 1, S(""));
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 0, 0, S(""));
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 0, 1, S("1"));
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 0, 5, S("12345"));
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 0, 9, S("123456789"));
+}
+
+template <class S>
+void test41()
+{
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 0, 10, S("1234567890"));
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 0, 11, S("1234567890"));
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 1, 0, S(""));
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 1, 1, S("2"));
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 1, 4, S("2345"));
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 1, 8, S("23456789"));
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 1, 9, S("234567890"));
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 1, 10, S("234567890"));
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 5, 0, S(""));
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 5, 1, S("6"));
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 5, 2, S("67"));
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 5, 4, S("6789"));
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 5, 5, S("67890"));
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 5, 6, S("67890"));
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 9, 0, S(""));
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 9, 1, S("0"));
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 9, 2, S("0"));
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 10, 0, S(""));
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 10, 1, S(""));
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 0, 0, S(""));
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 0, 1, S("1"));
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 0, 10, S("1234567890"));
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 0, 19, S("1234567890123456789"));
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 0, 20, S("12345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 0, 21, S("12345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 1, 0, S(""));
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 1, 1, S("2"));
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 1, 9, S("234567890"));
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 1, 18, S("234567890123456789"));
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 1, 19, S("2345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 1, 20, S("2345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 10, 0, S(""));
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 10, 1, S("1"));
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 10, 5, S("12345"));
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 10, 9, S("123456789"));
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 10, 10, S("1234567890"));
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 10, 11, S("1234567890"));
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 19, 0, S(""));
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 19, 1, S("0"));
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 19, 2, S("0"));
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 20, 0, S(""));
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 20, 1, S(""));
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S(""), 0, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S(""), 0, 1, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S(""), 1, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 0, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 0, 1, S("a1bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 0, 2, S("a12bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 0, 4, S("a1234bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 0, 5, S("a12345bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 0, 6, S("a12345bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 1, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 1, 1, S("a2bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 1, 2, S("a23bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 1, 3, S("a234bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 1, 4, S("a2345bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 1, 5, S("a2345bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 2, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 2, 1, S("a3bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 2, 2, S("a34bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 2, 3, S("a345bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 2, 4, S("a345bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 4, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 4, 1, S("a5bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 4, 2, S("a5bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 5, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 5, 1, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 0, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 0, 1, S("a1bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 0, 5, S("a12345bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 0, 9, S("a123456789bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 0, 10, S("a1234567890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 0, 11, S("a1234567890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 1, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 1, 1, S("a2bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 1, 4, S("a2345bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 1, 8, S("a23456789bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 1, 9, S("a234567890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 1, 10, S("a234567890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 5, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 5, 1, S("a6bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 5, 2, S("a67bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 5, 4, S("a6789bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 5, 5, S("a67890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 5, 6, S("a67890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 9, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 9, 1, S("a0bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 9, 2, S("a0bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 10, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 10, 1, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 0, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 0, 1, S("a1bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 0, 10, S("a1234567890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 0, 19, S("a1234567890123456789bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 0, 20, S("a12345678901234567890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 0, 21, S("a12345678901234567890bcdefghijklmnopqrst"));
+}
+
+template <class S>
+void test42()
+{
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 1, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 1, 1, S("a2bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 1, 9, S("a234567890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 1, 18, S("a234567890123456789bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 1, 19, S("a2345678901234567890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 1, 20, S("a2345678901234567890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 10, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 10, 1, S("a1bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 10, 5, S("a12345bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 10, 9, S("a123456789bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 10, 10, S("a1234567890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 10, 11, S("a1234567890bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 19, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 19, 1, S("a0bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 19, 2, S("a0bcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 20, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 20, 1, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S(""), 0, 0, S("acdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S(""), 0, 1, S("acdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S(""), 1, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 0, 0, S("acdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 0, 1, S("a1cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 0, 2, S("a12cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 0, 4, S("a1234cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 0, 5, S("a12345cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 0, 6, S("a12345cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 1, 0, S("acdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 1, 1, S("a2cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 1, 2, S("a23cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 1, 3, S("a234cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 1, 4, S("a2345cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 1, 5, S("a2345cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 2, 0, S("acdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 2, 1, S("a3cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 2, 2, S("a34cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 2, 3, S("a345cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 2, 4, S("a345cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 4, 0, S("acdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 4, 1, S("a5cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 4, 2, S("a5cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 5, 0, S("acdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 5, 1, S("acdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 0, 0, S("acdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 0, 1, S("a1cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 0, 5, S("a12345cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 0, 9, S("a123456789cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 0, 10, S("a1234567890cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 0, 11, S("a1234567890cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 1, 0, S("acdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 1, 1, S("a2cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 1, 4, S("a2345cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 1, 8, S("a23456789cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 1, 9, S("a234567890cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 1, 10, S("a234567890cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 5, 0, S("acdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 5, 1, S("a6cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 5, 2, S("a67cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 5, 4, S("a6789cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 5, 5, S("a67890cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 5, 6, S("a67890cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 9, 0, S("acdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 9, 1, S("a0cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 9, 2, S("a0cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 10, 0, S("acdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 10, 1, S("acdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 0, 0, S("acdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 0, 1, S("a1cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 0, 10, S("a1234567890cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 0, 19, S("a1234567890123456789cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 0, 20, S("a12345678901234567890cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 0, 21, S("a12345678901234567890cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 1, 0, S("acdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 1, 1, S("a2cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 1, 9, S("a234567890cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 1, 18, S("a234567890123456789cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 1, 19, S("a2345678901234567890cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 1, 20, S("a2345678901234567890cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 10, 0, S("acdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 10, 1, S("a1cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 10, 5, S("a12345cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 10, 9, S("a123456789cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 10, 10, S("a1234567890cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 10, 11, S("a1234567890cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 19, 0, S("acdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 19, 1, S("a0cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 19, 2, S("a0cdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 20, 0, S("acdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 20, 1, S("acdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S(""), 0, 0, S("aklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S(""), 0, 1, S("aklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S(""), 1, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 0, 0, S("aklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 0, 1, S("a1klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 0, 2, S("a12klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 0, 4, S("a1234klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 0, 5, S("a12345klmnopqrst"));
+}
+
+template <class S>
+void test43()
+{
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 0, 6, S("a12345klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 1, 0, S("aklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 1, 1, S("a2klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 1, 2, S("a23klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 1, 3, S("a234klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 1, 4, S("a2345klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 1, 5, S("a2345klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 2, 0, S("aklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 2, 1, S("a3klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 2, 2, S("a34klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 2, 3, S("a345klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 2, 4, S("a345klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 4, 0, S("aklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 4, 1, S("a5klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 4, 2, S("a5klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 5, 0, S("aklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 5, 1, S("aklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 0, 0, S("aklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 0, 1, S("a1klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 0, 5, S("a12345klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 0, 9, S("a123456789klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 0, 10, S("a1234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 0, 11, S("a1234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 1, 0, S("aklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 1, 1, S("a2klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 1, 4, S("a2345klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 1, 8, S("a23456789klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 1, 9, S("a234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 1, 10, S("a234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 5, 0, S("aklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 5, 1, S("a6klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 5, 2, S("a67klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 5, 4, S("a6789klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 5, 5, S("a67890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 5, 6, S("a67890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 9, 0, S("aklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 9, 1, S("a0klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 9, 2, S("a0klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 10, 0, S("aklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 10, 1, S("aklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 0, 0, S("aklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 0, 1, S("a1klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 0, 10, S("a1234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 0, 19, S("a1234567890123456789klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 0, 20, S("a12345678901234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 0, 21, S("a12345678901234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 1, 0, S("aklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 1, 1, S("a2klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 1, 9, S("a234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 1, 18, S("a234567890123456789klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 1, 19, S("a2345678901234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 1, 20, S("a2345678901234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 10, 0, S("aklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 10, 1, S("a1klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 10, 5, S("a12345klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 10, 9, S("a123456789klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 10, 10, S("a1234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 10, 11, S("a1234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 19, 0, S("aklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 19, 1, S("a0klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 19, 2, S("a0klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 20, 0, S("aklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 20, 1, S("aklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S(""), 0, 0, S("at"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S(""), 0, 1, S("at"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S(""), 1, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 0, 0, S("at"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 0, 1, S("a1t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 0, 2, S("a12t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 0, 4, S("a1234t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 0, 5, S("a12345t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 0, 6, S("a12345t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 1, 0, S("at"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 1, 1, S("a2t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 1, 2, S("a23t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 1, 3, S("a234t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 1, 4, S("a2345t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 1, 5, S("a2345t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 2, 0, S("at"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 2, 1, S("a3t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 2, 2, S("a34t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 2, 3, S("a345t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 2, 4, S("a345t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 4, 0, S("at"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 4, 1, S("a5t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 4, 2, S("a5t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 5, 0, S("at"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 5, 1, S("at"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 0, 0, S("at"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 0, 1, S("a1t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 0, 5, S("a12345t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 0, 9, S("a123456789t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 0, 10, S("a1234567890t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 0, 11, S("a1234567890t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 1, 0, S("at"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 1, 1, S("a2t"));
+}
+
+template <class S>
+void test44()
+{
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 1, 4, S("a2345t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 1, 8, S("a23456789t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 1, 9, S("a234567890t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 1, 10, S("a234567890t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 5, 0, S("at"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 5, 1, S("a6t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 5, 2, S("a67t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 5, 4, S("a6789t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 5, 5, S("a67890t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 5, 6, S("a67890t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 9, 0, S("at"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 9, 1, S("a0t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 9, 2, S("a0t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 10, 0, S("at"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 10, 1, S("at"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 0, 0, S("at"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 0, 1, S("a1t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 0, 10, S("a1234567890t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 0, 19, S("a1234567890123456789t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 0, 20, S("a12345678901234567890t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 0, 21, S("a12345678901234567890t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 1, 0, S("at"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 1, 1, S("a2t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 1, 9, S("a234567890t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 1, 18, S("a234567890123456789t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 1, 19, S("a2345678901234567890t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 1, 20, S("a2345678901234567890t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 10, 0, S("at"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 10, 1, S("a1t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 10, 5, S("a12345t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 10, 9, S("a123456789t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 10, 10, S("a1234567890t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 10, 11, S("a1234567890t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 19, 0, S("at"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 19, 1, S("a0t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 19, 2, S("a0t"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 20, 0, S("at"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 20, 1, S("at"));
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S(""), 0, 0, S("a"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S(""), 0, 1, S("a"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S(""), 1, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 0, 0, S("a"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 0, 1, S("a1"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 0, 2, S("a12"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 0, 4, S("a1234"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 0, 5, S("a12345"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 0, 6, S("a12345"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 1, 0, S("a"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 1, 1, S("a2"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 1, 2, S("a23"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 1, 3, S("a234"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 1, 4, S("a2345"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 1, 5, S("a2345"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 2, 0, S("a"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 2, 1, S("a3"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 2, 2, S("a34"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 2, 3, S("a345"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 2, 4, S("a345"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 4, 0, S("a"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 4, 1, S("a5"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 4, 2, S("a5"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 5, 0, S("a"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 5, 1, S("a"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 0, 0, S("a"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 0, 1, S("a1"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 0, 5, S("a12345"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 0, 9, S("a123456789"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 0, 10, S("a1234567890"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 0, 11, S("a1234567890"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 1, 0, S("a"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 1, 1, S("a2"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 1, 4, S("a2345"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 1, 8, S("a23456789"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 1, 9, S("a234567890"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 1, 10, S("a234567890"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 5, 0, S("a"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 5, 1, S("a6"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 5, 2, S("a67"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 5, 4, S("a6789"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 5, 5, S("a67890"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 5, 6, S("a67890"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 9, 0, S("a"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 9, 1, S("a0"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 9, 2, S("a0"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 10, 0, S("a"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 10, 1, S("a"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 0, 0, S("a"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 0, 1, S("a1"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 0, 10, S("a1234567890"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 0, 19, S("a1234567890123456789"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 0, 20, S("a12345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 0, 21, S("a12345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 1, 0, S("a"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 1, 1, S("a2"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 1, 9, S("a234567890"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 1, 18, S("a234567890123456789"));
+}
+
+template <class S>
+void test45()
+{
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 1, 19, S("a2345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 1, 20, S("a2345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 10, 0, S("a"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 10, 1, S("a1"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 10, 5, S("a12345"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 10, 9, S("a123456789"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 10, 10, S("a1234567890"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 10, 11, S("a1234567890"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 19, 0, S("a"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 19, 1, S("a0"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 19, 2, S("a0"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 20, 0, S("a"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 20, 1, S("a"));
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, S(""), 0, 0, S("a"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, S(""), 0, 1, S("a"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, S(""), 1, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 0, 0, S("a"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 0, 1, S("a1"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 0, 2, S("a12"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 0, 4, S("a1234"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 0, 5, S("a12345"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 0, 6, S("a12345"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 1, 0, S("a"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 1, 1, S("a2"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 1, 2, S("a23"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 1, 3, S("a234"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 1, 4, S("a2345"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 1, 5, S("a2345"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 2, 0, S("a"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 2, 1, S("a3"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 2, 2, S("a34"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 2, 3, S("a345"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 2, 4, S("a345"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 4, 0, S("a"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 4, 1, S("a5"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 4, 2, S("a5"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 5, 0, S("a"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 5, 1, S("a"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 0, 0, S("a"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 0, 1, S("a1"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 0, 5, S("a12345"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 0, 9, S("a123456789"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 0, 10, S("a1234567890"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 0, 11, S("a1234567890"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 1, 0, S("a"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 1, 1, S("a2"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 1, 4, S("a2345"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 1, 8, S("a23456789"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 1, 9, S("a234567890"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 1, 10, S("a234567890"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 5, 0, S("a"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 5, 1, S("a6"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 5, 2, S("a67"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 5, 4, S("a6789"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 5, 5, S("a67890"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 5, 6, S("a67890"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 9, 0, S("a"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 9, 1, S("a0"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 9, 2, S("a0"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 10, 0, S("a"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 10, 1, S("a"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 0, 0, S("a"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 0, 1, S("a1"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 0, 10, S("a1234567890"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 0, 19, S("a1234567890123456789"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 0, 20, S("a12345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 0, 21, S("a12345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 1, 0, S("a"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 1, 1, S("a2"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 1, 9, S("a234567890"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 1, 18, S("a234567890123456789"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 1, 19, S("a2345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 1, 20, S("a2345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 10, 0, S("a"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 10, 1, S("a1"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 10, 5, S("a12345"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 10, 9, S("a123456789"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 10, 10, S("a1234567890"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 10, 11, S("a1234567890"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 19, 0, S("a"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 19, 1, S("a0"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 19, 2, S("a0"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 20, 0, S("a"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 20, 1, S("a"));
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S(""), 0, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S(""), 0, 1, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S(""), 1, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 0, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 0, 1, S("abcdefghij1klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 0, 2, S("abcdefghij12klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 0, 4, S("abcdefghij1234klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 0, 5, S("abcdefghij12345klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 0, 6, S("abcdefghij12345klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 1, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 1, 1, S("abcdefghij2klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 1, 2, S("abcdefghij23klmnopqrst"));
+}
+
+template <class S>
+void test46()
+{
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 1, 3, S("abcdefghij234klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 1, 4, S("abcdefghij2345klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 1, 5, S("abcdefghij2345klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 2, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 2, 1, S("abcdefghij3klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 2, 2, S("abcdefghij34klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 2, 3, S("abcdefghij345klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 2, 4, S("abcdefghij345klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 4, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 4, 1, S("abcdefghij5klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 4, 2, S("abcdefghij5klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 5, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 5, 1, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 0, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 0, 1, S("abcdefghij1klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 0, 5, S("abcdefghij12345klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 0, 9, S("abcdefghij123456789klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 0, 10, S("abcdefghij1234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 0, 11, S("abcdefghij1234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 1, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 1, 1, S("abcdefghij2klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 1, 4, S("abcdefghij2345klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 1, 8, S("abcdefghij23456789klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 1, 9, S("abcdefghij234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 1, 10, S("abcdefghij234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 5, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 5, 1, S("abcdefghij6klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 5, 2, S("abcdefghij67klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 5, 4, S("abcdefghij6789klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 5, 5, S("abcdefghij67890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 5, 6, S("abcdefghij67890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 9, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 9, 1, S("abcdefghij0klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 9, 2, S("abcdefghij0klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 10, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 10, 1, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 0, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 0, 1, S("abcdefghij1klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 0, 10, S("abcdefghij1234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 0, 19, S("abcdefghij1234567890123456789klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 0, 20, S("abcdefghij12345678901234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 0, 21, S("abcdefghij12345678901234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 1, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 1, 1, S("abcdefghij2klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 1, 9, S("abcdefghij234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 1, 18, S("abcdefghij234567890123456789klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 1, 19, S("abcdefghij2345678901234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 1, 20, S("abcdefghij2345678901234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 10, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 10, 1, S("abcdefghij1klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 10, 5, S("abcdefghij12345klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 10, 9, S("abcdefghij123456789klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 10, 10, S("abcdefghij1234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 10, 11, S("abcdefghij1234567890klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 19, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 19, 1, S("abcdefghij0klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 19, 2, S("abcdefghij0klmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 20, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 20, 1, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S(""), 0, 0, S("abcdefghijlmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S(""), 0, 1, S("abcdefghijlmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S(""), 1, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 0, 0, S("abcdefghijlmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 0, 1, S("abcdefghij1lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 0, 2, S("abcdefghij12lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 0, 4, S("abcdefghij1234lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 0, 5, S("abcdefghij12345lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 0, 6, S("abcdefghij12345lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 1, 0, S("abcdefghijlmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 1, 1, S("abcdefghij2lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 1, 2, S("abcdefghij23lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 1, 3, S("abcdefghij234lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 1, 4, S("abcdefghij2345lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 1, 5, S("abcdefghij2345lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 2, 0, S("abcdefghijlmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 2, 1, S("abcdefghij3lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 2, 2, S("abcdefghij34lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 2, 3, S("abcdefghij345lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 2, 4, S("abcdefghij345lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 4, 0, S("abcdefghijlmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 4, 1, S("abcdefghij5lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 4, 2, S("abcdefghij5lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 5, 0, S("abcdefghijlmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 5, 1, S("abcdefghijlmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 0, 0, S("abcdefghijlmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 0, 1, S("abcdefghij1lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 0, 5, S("abcdefghij12345lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 0, 9, S("abcdefghij123456789lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 0, 10, S("abcdefghij1234567890lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 0, 11, S("abcdefghij1234567890lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 1, 0, S("abcdefghijlmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 1, 1, S("abcdefghij2lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 1, 4, S("abcdefghij2345lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 1, 8, S("abcdefghij23456789lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 1, 9, S("abcdefghij234567890lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 1, 10, S("abcdefghij234567890lmnopqrst"));
+}
+
+template <class S>
+void test47()
+{
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 5, 0, S("abcdefghijlmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 5, 1, S("abcdefghij6lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 5, 2, S("abcdefghij67lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 5, 4, S("abcdefghij6789lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 5, 5, S("abcdefghij67890lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 5, 6, S("abcdefghij67890lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 9, 0, S("abcdefghijlmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 9, 1, S("abcdefghij0lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 9, 2, S("abcdefghij0lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 10, 0, S("abcdefghijlmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 10, 1, S("abcdefghijlmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 0, 0, S("abcdefghijlmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 0, 1, S("abcdefghij1lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 0, 10, S("abcdefghij1234567890lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 0, 19, S("abcdefghij1234567890123456789lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 0, 20, S("abcdefghij12345678901234567890lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 0, 21, S("abcdefghij12345678901234567890lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 1, 0, S("abcdefghijlmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 1, 1, S("abcdefghij2lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 1, 9, S("abcdefghij234567890lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 1, 18, S("abcdefghij234567890123456789lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 1, 19, S("abcdefghij2345678901234567890lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 1, 20, S("abcdefghij2345678901234567890lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 10, 0, S("abcdefghijlmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 10, 1, S("abcdefghij1lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 10, 5, S("abcdefghij12345lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 10, 9, S("abcdefghij123456789lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 10, 10, S("abcdefghij1234567890lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 10, 11, S("abcdefghij1234567890lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 19, 0, S("abcdefghijlmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 19, 1, S("abcdefghij0lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 19, 2, S("abcdefghij0lmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 20, 0, S("abcdefghijlmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 20, 1, S("abcdefghijlmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S(""), 0, 0, S("abcdefghijpqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S(""), 0, 1, S("abcdefghijpqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S(""), 1, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 0, 0, S("abcdefghijpqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 0, 1, S("abcdefghij1pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 0, 2, S("abcdefghij12pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 0, 4, S("abcdefghij1234pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 0, 5, S("abcdefghij12345pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 0, 6, S("abcdefghij12345pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 1, 0, S("abcdefghijpqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 1, 1, S("abcdefghij2pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 1, 2, S("abcdefghij23pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 1, 3, S("abcdefghij234pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 1, 4, S("abcdefghij2345pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 1, 5, S("abcdefghij2345pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 2, 0, S("abcdefghijpqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 2, 1, S("abcdefghij3pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 2, 2, S("abcdefghij34pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 2, 3, S("abcdefghij345pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 2, 4, S("abcdefghij345pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 4, 0, S("abcdefghijpqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 4, 1, S("abcdefghij5pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 4, 2, S("abcdefghij5pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 5, 0, S("abcdefghijpqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 5, 1, S("abcdefghijpqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 0, 0, S("abcdefghijpqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 0, 1, S("abcdefghij1pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 0, 5, S("abcdefghij12345pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 0, 9, S("abcdefghij123456789pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 0, 10, S("abcdefghij1234567890pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 0, 11, S("abcdefghij1234567890pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 1, 0, S("abcdefghijpqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 1, 1, S("abcdefghij2pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 1, 4, S("abcdefghij2345pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 1, 8, S("abcdefghij23456789pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 1, 9, S("abcdefghij234567890pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 1, 10, S("abcdefghij234567890pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 5, 0, S("abcdefghijpqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 5, 1, S("abcdefghij6pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 5, 2, S("abcdefghij67pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 5, 4, S("abcdefghij6789pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 5, 5, S("abcdefghij67890pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 5, 6, S("abcdefghij67890pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 9, 0, S("abcdefghijpqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 9, 1, S("abcdefghij0pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 9, 2, S("abcdefghij0pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 10, 0, S("abcdefghijpqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 10, 1, S("abcdefghijpqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 0, 0, S("abcdefghijpqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 0, 1, S("abcdefghij1pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 0, 10, S("abcdefghij1234567890pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 0, 19, S("abcdefghij1234567890123456789pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 0, 20, S("abcdefghij12345678901234567890pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 0, 21, S("abcdefghij12345678901234567890pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 1, 0, S("abcdefghijpqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 1, 1, S("abcdefghij2pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 1, 9, S("abcdefghij234567890pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 1, 18, S("abcdefghij234567890123456789pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 1, 19, S("abcdefghij2345678901234567890pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 1, 20, S("abcdefghij2345678901234567890pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 10, 0, S("abcdefghijpqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 10, 1, S("abcdefghij1pqrst"));
+}
+
+template <class S>
+void test48()
+{
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 10, 5, S("abcdefghij12345pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 10, 9, S("abcdefghij123456789pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 10, 10, S("abcdefghij1234567890pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 10, 11, S("abcdefghij1234567890pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 19, 0, S("abcdefghijpqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 19, 1, S("abcdefghij0pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 19, 2, S("abcdefghij0pqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 20, 0, S("abcdefghijpqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 20, 1, S("abcdefghijpqrst"));
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S(""), 0, 0, S("abcdefghijt"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S(""), 0, 1, S("abcdefghijt"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S(""), 1, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 0, 0, S("abcdefghijt"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 0, 1, S("abcdefghij1t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 0, 2, S("abcdefghij12t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 0, 4, S("abcdefghij1234t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 0, 5, S("abcdefghij12345t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 0, 6, S("abcdefghij12345t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 1, 0, S("abcdefghijt"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 1, 1, S("abcdefghij2t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 1, 2, S("abcdefghij23t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 1, 3, S("abcdefghij234t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 1, 4, S("abcdefghij2345t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 1, 5, S("abcdefghij2345t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 2, 0, S("abcdefghijt"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 2, 1, S("abcdefghij3t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 2, 2, S("abcdefghij34t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 2, 3, S("abcdefghij345t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 2, 4, S("abcdefghij345t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 4, 0, S("abcdefghijt"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 4, 1, S("abcdefghij5t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 4, 2, S("abcdefghij5t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 5, 0, S("abcdefghijt"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 5, 1, S("abcdefghijt"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 0, 0, S("abcdefghijt"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 0, 1, S("abcdefghij1t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 0, 5, S("abcdefghij12345t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 0, 9, S("abcdefghij123456789t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 0, 10, S("abcdefghij1234567890t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 0, 11, S("abcdefghij1234567890t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 1, 0, S("abcdefghijt"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 1, 1, S("abcdefghij2t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 1, 4, S("abcdefghij2345t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 1, 8, S("abcdefghij23456789t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 1, 9, S("abcdefghij234567890t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 1, 10, S("abcdefghij234567890t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 5, 0, S("abcdefghijt"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 5, 1, S("abcdefghij6t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 5, 2, S("abcdefghij67t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 5, 4, S("abcdefghij6789t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 5, 5, S("abcdefghij67890t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 5, 6, S("abcdefghij67890t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 9, 0, S("abcdefghijt"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 9, 1, S("abcdefghij0t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 9, 2, S("abcdefghij0t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 10, 0, S("abcdefghijt"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 10, 1, S("abcdefghijt"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 0, 0, S("abcdefghijt"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 0, 1, S("abcdefghij1t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 0, 10, S("abcdefghij1234567890t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 0, 19, S("abcdefghij1234567890123456789t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 0, 20, S("abcdefghij12345678901234567890t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 0, 21, S("abcdefghij12345678901234567890t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 1, 0, S("abcdefghijt"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 1, 1, S("abcdefghij2t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 1, 9, S("abcdefghij234567890t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 1, 18, S("abcdefghij234567890123456789t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 1, 19, S("abcdefghij2345678901234567890t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 1, 20, S("abcdefghij2345678901234567890t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 10, 0, S("abcdefghijt"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 10, 1, S("abcdefghij1t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 10, 5, S("abcdefghij12345t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 10, 9, S("abcdefghij123456789t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 10, 10, S("abcdefghij1234567890t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 10, 11, S("abcdefghij1234567890t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 19, 0, S("abcdefghijt"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 19, 1, S("abcdefghij0t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 19, 2, S("abcdefghij0t"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 20, 0, S("abcdefghijt"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 20, 1, S("abcdefghijt"));
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, S(""), 0, 0, S("abcdefghij"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, S(""), 0, 1, S("abcdefghij"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, S(""), 1, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 0, 0, S("abcdefghij"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 0, 1, S("abcdefghij1"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 0, 2, S("abcdefghij12"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 0, 4, S("abcdefghij1234"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 0, 5, S("abcdefghij12345"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 0, 6, S("abcdefghij12345"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 1, 0, S("abcdefghij"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 1, 1, S("abcdefghij2"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 1, 2, S("abcdefghij23"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 1, 3, S("abcdefghij234"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 1, 4, S("abcdefghij2345"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 1, 5, S("abcdefghij2345"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 2, 0, S("abcdefghij"));
+}
+
+template <class S>
+void test49()
+{
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 2, 1, S("abcdefghij3"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 2, 2, S("abcdefghij34"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 2, 3, S("abcdefghij345"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 2, 4, S("abcdefghij345"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 4, 0, S("abcdefghij"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 4, 1, S("abcdefghij5"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 4, 2, S("abcdefghij5"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 5, 0, S("abcdefghij"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 5, 1, S("abcdefghij"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 0, 0, S("abcdefghij"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 0, 1, S("abcdefghij1"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 0, 5, S("abcdefghij12345"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 0, 9, S("abcdefghij123456789"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 0, 10, S("abcdefghij1234567890"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 0, 11, S("abcdefghij1234567890"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 1, 0, S("abcdefghij"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 1, 1, S("abcdefghij2"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 1, 4, S("abcdefghij2345"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 1, 8, S("abcdefghij23456789"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 1, 9, S("abcdefghij234567890"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 1, 10, S("abcdefghij234567890"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 5, 0, S("abcdefghij"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 5, 1, S("abcdefghij6"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 5, 2, S("abcdefghij67"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 5, 4, S("abcdefghij6789"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 5, 5, S("abcdefghij67890"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 5, 6, S("abcdefghij67890"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 9, 0, S("abcdefghij"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 9, 1, S("abcdefghij0"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 9, 2, S("abcdefghij0"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 10, 0, S("abcdefghij"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 10, 1, S("abcdefghij"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 0, 0, S("abcdefghij"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 0, 1, S("abcdefghij1"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 0, 10, S("abcdefghij1234567890"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 0, 19, S("abcdefghij1234567890123456789"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 0, 20, S("abcdefghij12345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 0, 21, S("abcdefghij12345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 1, 0, S("abcdefghij"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 1, 1, S("abcdefghij2"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 1, 9, S("abcdefghij234567890"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 1, 18, S("abcdefghij234567890123456789"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 1, 19, S("abcdefghij2345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 1, 20, S("abcdefghij2345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 10, 0, S("abcdefghij"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 10, 1, S("abcdefghij1"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 10, 5, S("abcdefghij12345"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 10, 9, S("abcdefghij123456789"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 10, 10, S("abcdefghij1234567890"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 10, 11, S("abcdefghij1234567890"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 19, 0, S("abcdefghij"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 19, 1, S("abcdefghij0"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 19, 2, S("abcdefghij0"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 20, 0, S("abcdefghij"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 20, 1, S("abcdefghij"));
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, S(""), 0, 0, S("abcdefghij"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, S(""), 0, 1, S("abcdefghij"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, S(""), 1, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 0, 0, S("abcdefghij"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 0, 1, S("abcdefghij1"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 0, 2, S("abcdefghij12"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 0, 4, S("abcdefghij1234"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 0, 5, S("abcdefghij12345"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 0, 6, S("abcdefghij12345"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 1, 0, S("abcdefghij"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 1, 1, S("abcdefghij2"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 1, 2, S("abcdefghij23"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 1, 3, S("abcdefghij234"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 1, 4, S("abcdefghij2345"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 1, 5, S("abcdefghij2345"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 2, 0, S("abcdefghij"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 2, 1, S("abcdefghij3"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 2, 2, S("abcdefghij34"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 2, 3, S("abcdefghij345"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 2, 4, S("abcdefghij345"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 4, 0, S("abcdefghij"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 4, 1, S("abcdefghij5"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 4, 2, S("abcdefghij5"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 5, 0, S("abcdefghij"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 5, 1, S("abcdefghij"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 0, 0, S("abcdefghij"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 0, 1, S("abcdefghij1"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 0, 5, S("abcdefghij12345"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 0, 9, S("abcdefghij123456789"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 0, 10, S("abcdefghij1234567890"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 0, 11, S("abcdefghij1234567890"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 1, 0, S("abcdefghij"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 1, 1, S("abcdefghij2"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 1, 4, S("abcdefghij2345"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 1, 8, S("abcdefghij23456789"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 1, 9, S("abcdefghij234567890"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 1, 10, S("abcdefghij234567890"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 5, 0, S("abcdefghij"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 5, 1, S("abcdefghij6"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 5, 2, S("abcdefghij67"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 5, 4, S("abcdefghij6789"));
+}
+
+template <class S>
+void test50()
+{
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 5, 5, S("abcdefghij67890"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 5, 6, S("abcdefghij67890"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 9, 0, S("abcdefghij"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 9, 1, S("abcdefghij0"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 9, 2, S("abcdefghij0"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 10, 0, S("abcdefghij"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 10, 1, S("abcdefghij"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 0, 0, S("abcdefghij"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 0, 1, S("abcdefghij1"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 0, 10, S("abcdefghij1234567890"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 0, 19, S("abcdefghij1234567890123456789"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 0, 20, S("abcdefghij12345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 0, 21, S("abcdefghij12345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 1, 0, S("abcdefghij"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 1, 1, S("abcdefghij2"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 1, 9, S("abcdefghij234567890"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 1, 18, S("abcdefghij234567890123456789"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 1, 19, S("abcdefghij2345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 1, 20, S("abcdefghij2345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 10, 0, S("abcdefghij"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 10, 1, S("abcdefghij1"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 10, 5, S("abcdefghij12345"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 10, 9, S("abcdefghij123456789"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 10, 10, S("abcdefghij1234567890"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 10, 11, S("abcdefghij1234567890"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 19, 0, S("abcdefghij"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 19, 1, S("abcdefghij0"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 19, 2, S("abcdefghij0"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 20, 0, S("abcdefghij"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 20, 1, S("abcdefghij"));
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S(""), 0, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S(""), 0, 1, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S(""), 1, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 0, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 0, 1, S("abcdefghijklmnopqrs1t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 0, 2, S("abcdefghijklmnopqrs12t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 0, 4, S("abcdefghijklmnopqrs1234t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 0, 5, S("abcdefghijklmnopqrs12345t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 0, 6, S("abcdefghijklmnopqrs12345t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 1, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 1, 1, S("abcdefghijklmnopqrs2t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 1, 2, S("abcdefghijklmnopqrs23t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 1, 3, S("abcdefghijklmnopqrs234t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 1, 4, S("abcdefghijklmnopqrs2345t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 1, 5, S("abcdefghijklmnopqrs2345t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 2, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 2, 1, S("abcdefghijklmnopqrs3t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 2, 2, S("abcdefghijklmnopqrs34t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 2, 3, S("abcdefghijklmnopqrs345t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 2, 4, S("abcdefghijklmnopqrs345t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 4, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 4, 1, S("abcdefghijklmnopqrs5t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 4, 2, S("abcdefghijklmnopqrs5t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 5, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 5, 1, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 0, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 0, 1, S("abcdefghijklmnopqrs1t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 0, 5, S("abcdefghijklmnopqrs12345t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 0, 9, S("abcdefghijklmnopqrs123456789t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 0, 10, S("abcdefghijklmnopqrs1234567890t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 0, 11, S("abcdefghijklmnopqrs1234567890t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 1, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 1, 1, S("abcdefghijklmnopqrs2t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 1, 4, S("abcdefghijklmnopqrs2345t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 1, 8, S("abcdefghijklmnopqrs23456789t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 1, 9, S("abcdefghijklmnopqrs234567890t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 1, 10, S("abcdefghijklmnopqrs234567890t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 5, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 5, 1, S("abcdefghijklmnopqrs6t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 5, 2, S("abcdefghijklmnopqrs67t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 5, 4, S("abcdefghijklmnopqrs6789t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 5, 5, S("abcdefghijklmnopqrs67890t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 5, 6, S("abcdefghijklmnopqrs67890t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 9, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 9, 1, S("abcdefghijklmnopqrs0t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 9, 2, S("abcdefghijklmnopqrs0t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 10, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 10, 1, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 0, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 0, 1, S("abcdefghijklmnopqrs1t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 0, 10, S("abcdefghijklmnopqrs1234567890t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 0, 19, S("abcdefghijklmnopqrs1234567890123456789t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 0, 20, S("abcdefghijklmnopqrs12345678901234567890t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 0, 21, S("abcdefghijklmnopqrs12345678901234567890t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 1, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 1, 1, S("abcdefghijklmnopqrs2t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 1, 9, S("abcdefghijklmnopqrs234567890t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 1, 18, S("abcdefghijklmnopqrs234567890123456789t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 1, 19, S("abcdefghijklmnopqrs2345678901234567890t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 1, 20, S("abcdefghijklmnopqrs2345678901234567890t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 10, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 10, 1, S("abcdefghijklmnopqrs1t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 10, 5, S("abcdefghijklmnopqrs12345t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 10, 9, S("abcdefghijklmnopqrs123456789t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 10, 10, S("abcdefghijklmnopqrs1234567890t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 10, 11, S("abcdefghijklmnopqrs1234567890t"));
+}
+
+template <class S>
+void test51()
+{
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 19, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 19, 1, S("abcdefghijklmnopqrs0t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 19, 2, S("abcdefghijklmnopqrs0t"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 20, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 20, 1, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S(""), 0, 0, S("abcdefghijklmnopqrs"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S(""), 0, 1, S("abcdefghijklmnopqrs"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S(""), 1, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 0, 0, S("abcdefghijklmnopqrs"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 0, 1, S("abcdefghijklmnopqrs1"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 0, 2, S("abcdefghijklmnopqrs12"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 0, 4, S("abcdefghijklmnopqrs1234"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 0, 5, S("abcdefghijklmnopqrs12345"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 0, 6, S("abcdefghijklmnopqrs12345"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 1, 0, S("abcdefghijklmnopqrs"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 1, 1, S("abcdefghijklmnopqrs2"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 1, 2, S("abcdefghijklmnopqrs23"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 1, 3, S("abcdefghijklmnopqrs234"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 1, 4, S("abcdefghijklmnopqrs2345"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 1, 5, S("abcdefghijklmnopqrs2345"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 2, 0, S("abcdefghijklmnopqrs"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 2, 1, S("abcdefghijklmnopqrs3"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 2, 2, S("abcdefghijklmnopqrs34"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 2, 3, S("abcdefghijklmnopqrs345"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 2, 4, S("abcdefghijklmnopqrs345"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 4, 0, S("abcdefghijklmnopqrs"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 4, 1, S("abcdefghijklmnopqrs5"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 4, 2, S("abcdefghijklmnopqrs5"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 5, 0, S("abcdefghijklmnopqrs"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 5, 1, S("abcdefghijklmnopqrs"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 0, 0, S("abcdefghijklmnopqrs"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 0, 1, S("abcdefghijklmnopqrs1"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 0, 5, S("abcdefghijklmnopqrs12345"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 0, 9, S("abcdefghijklmnopqrs123456789"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 0, 10, S("abcdefghijklmnopqrs1234567890"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 0, 11, S("abcdefghijklmnopqrs1234567890"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 1, 0, S("abcdefghijklmnopqrs"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 1, 1, S("abcdefghijklmnopqrs2"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 1, 4, S("abcdefghijklmnopqrs2345"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 1, 8, S("abcdefghijklmnopqrs23456789"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 1, 9, S("abcdefghijklmnopqrs234567890"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 1, 10, S("abcdefghijklmnopqrs234567890"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 5, 0, S("abcdefghijklmnopqrs"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 5, 1, S("abcdefghijklmnopqrs6"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 5, 2, S("abcdefghijklmnopqrs67"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 5, 4, S("abcdefghijklmnopqrs6789"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 5, 5, S("abcdefghijklmnopqrs67890"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 5, 6, S("abcdefghijklmnopqrs67890"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 9, 0, S("abcdefghijklmnopqrs"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 9, 1, S("abcdefghijklmnopqrs0"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 9, 2, S("abcdefghijklmnopqrs0"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 10, 0, S("abcdefghijklmnopqrs"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 10, 1, S("abcdefghijklmnopqrs"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 0, 0, S("abcdefghijklmnopqrs"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 0, 1, S("abcdefghijklmnopqrs1"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 0, 10, S("abcdefghijklmnopqrs1234567890"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 0, 19, S("abcdefghijklmnopqrs1234567890123456789"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 0, 20, S("abcdefghijklmnopqrs12345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 0, 21, S("abcdefghijklmnopqrs12345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 1, 0, S("abcdefghijklmnopqrs"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 1, 1, S("abcdefghijklmnopqrs2"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 1, 9, S("abcdefghijklmnopqrs234567890"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 1, 18, S("abcdefghijklmnopqrs234567890123456789"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 1, 19, S("abcdefghijklmnopqrs2345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 1, 20, S("abcdefghijklmnopqrs2345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 10, 0, S("abcdefghijklmnopqrs"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 10, 1, S("abcdefghijklmnopqrs1"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 10, 5, S("abcdefghijklmnopqrs12345"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 10, 9, S("abcdefghijklmnopqrs123456789"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 10, 10, S("abcdefghijklmnopqrs1234567890"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 10, 11, S("abcdefghijklmnopqrs1234567890"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 19, 0, S("abcdefghijklmnopqrs"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 19, 1, S("abcdefghijklmnopqrs0"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 19, 2, S("abcdefghijklmnopqrs0"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 20, 0, S("abcdefghijklmnopqrs"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 20, 1, S("abcdefghijklmnopqrs"));
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, S(""), 0, 0, S("abcdefghijklmnopqrs"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, S(""), 0, 1, S("abcdefghijklmnopqrs"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, S(""), 1, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 0, 0, S("abcdefghijklmnopqrs"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 0, 1, S("abcdefghijklmnopqrs1"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 0, 2, S("abcdefghijklmnopqrs12"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 0, 4, S("abcdefghijklmnopqrs1234"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 0, 5, S("abcdefghijklmnopqrs12345"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 0, 6, S("abcdefghijklmnopqrs12345"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 1, 0, S("abcdefghijklmnopqrs"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 1, 1, S("abcdefghijklmnopqrs2"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 1, 2, S("abcdefghijklmnopqrs23"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 1, 3, S("abcdefghijklmnopqrs234"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 1, 4, S("abcdefghijklmnopqrs2345"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 1, 5, S("abcdefghijklmnopqrs2345"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 2, 0, S("abcdefghijklmnopqrs"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 2, 1, S("abcdefghijklmnopqrs3"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 2, 2, S("abcdefghijklmnopqrs34"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 2, 3, S("abcdefghijklmnopqrs345"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 2, 4, S("abcdefghijklmnopqrs345"));
+}
+
+template <class S>
+void test52()
+{
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 4, 0, S("abcdefghijklmnopqrs"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 4, 1, S("abcdefghijklmnopqrs5"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 4, 2, S("abcdefghijklmnopqrs5"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 5, 0, S("abcdefghijklmnopqrs"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 5, 1, S("abcdefghijklmnopqrs"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 0, 0, S("abcdefghijklmnopqrs"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 0, 1, S("abcdefghijklmnopqrs1"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 0, 5, S("abcdefghijklmnopqrs12345"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 0, 9, S("abcdefghijklmnopqrs123456789"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 0, 10, S("abcdefghijklmnopqrs1234567890"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 0, 11, S("abcdefghijklmnopqrs1234567890"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 1, 0, S("abcdefghijklmnopqrs"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 1, 1, S("abcdefghijklmnopqrs2"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 1, 4, S("abcdefghijklmnopqrs2345"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 1, 8, S("abcdefghijklmnopqrs23456789"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 1, 9, S("abcdefghijklmnopqrs234567890"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 1, 10, S("abcdefghijklmnopqrs234567890"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 5, 0, S("abcdefghijklmnopqrs"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 5, 1, S("abcdefghijklmnopqrs6"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 5, 2, S("abcdefghijklmnopqrs67"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 5, 4, S("abcdefghijklmnopqrs6789"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 5, 5, S("abcdefghijklmnopqrs67890"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 5, 6, S("abcdefghijklmnopqrs67890"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 9, 0, S("abcdefghijklmnopqrs"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 9, 1, S("abcdefghijklmnopqrs0"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 9, 2, S("abcdefghijklmnopqrs0"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 10, 0, S("abcdefghijklmnopqrs"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 10, 1, S("abcdefghijklmnopqrs"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 0, 0, S("abcdefghijklmnopqrs"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 0, 1, S("abcdefghijklmnopqrs1"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 0, 10, S("abcdefghijklmnopqrs1234567890"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 0, 19, S("abcdefghijklmnopqrs1234567890123456789"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 0, 20, S("abcdefghijklmnopqrs12345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 0, 21, S("abcdefghijklmnopqrs12345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 1, 0, S("abcdefghijklmnopqrs"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 1, 1, S("abcdefghijklmnopqrs2"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 1, 9, S("abcdefghijklmnopqrs234567890"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 1, 18, S("abcdefghijklmnopqrs234567890123456789"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 1, 19, S("abcdefghijklmnopqrs2345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 1, 20, S("abcdefghijklmnopqrs2345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 10, 0, S("abcdefghijklmnopqrs"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 10, 1, S("abcdefghijklmnopqrs1"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 10, 5, S("abcdefghijklmnopqrs12345"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 10, 9, S("abcdefghijklmnopqrs123456789"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 10, 10, S("abcdefghijklmnopqrs1234567890"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 10, 11, S("abcdefghijklmnopqrs1234567890"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 19, 0, S("abcdefghijklmnopqrs"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 19, 1, S("abcdefghijklmnopqrs0"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 19, 2, S("abcdefghijklmnopqrs0"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 20, 0, S("abcdefghijklmnopqrs"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 20, 1, S("abcdefghijklmnopqrs"));
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S(""), 0, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S(""), 0, 1, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S(""), 1, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 0, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 0, 1, S("abcdefghijklmnopqrst1"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 0, 2, S("abcdefghijklmnopqrst12"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 0, 4, S("abcdefghijklmnopqrst1234"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 0, 5, S("abcdefghijklmnopqrst12345"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 0, 6, S("abcdefghijklmnopqrst12345"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 1, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 1, 1, S("abcdefghijklmnopqrst2"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 1, 2, S("abcdefghijklmnopqrst23"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 1, 3, S("abcdefghijklmnopqrst234"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 1, 4, S("abcdefghijklmnopqrst2345"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 1, 5, S("abcdefghijklmnopqrst2345"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 2, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 2, 1, S("abcdefghijklmnopqrst3"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 2, 2, S("abcdefghijklmnopqrst34"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 2, 3, S("abcdefghijklmnopqrst345"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 2, 4, S("abcdefghijklmnopqrst345"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 4, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 4, 1, S("abcdefghijklmnopqrst5"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 4, 2, S("abcdefghijklmnopqrst5"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 5, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 5, 1, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 0, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 0, 1, S("abcdefghijklmnopqrst1"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 0, 5, S("abcdefghijklmnopqrst12345"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 0, 9, S("abcdefghijklmnopqrst123456789"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 0, 10, S("abcdefghijklmnopqrst1234567890"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 0, 11, S("abcdefghijklmnopqrst1234567890"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 1, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 1, 1, S("abcdefghijklmnopqrst2"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 1, 4, S("abcdefghijklmnopqrst2345"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 1, 8, S("abcdefghijklmnopqrst23456789"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 1, 9, S("abcdefghijklmnopqrst234567890"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 1, 10, S("abcdefghijklmnopqrst234567890"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 5, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 5, 1, S("abcdefghijklmnopqrst6"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 5, 2, S("abcdefghijklmnopqrst67"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 5, 4, S("abcdefghijklmnopqrst6789"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 5, 5, S("abcdefghijklmnopqrst67890"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 5, 6, S("abcdefghijklmnopqrst67890"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 9, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 9, 1, S("abcdefghijklmnopqrst0"));
+}
+
+template <class S>
+void test53()
+{
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 9, 2, S("abcdefghijklmnopqrst0"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 10, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 10, 1, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 0, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 0, 1, S("abcdefghijklmnopqrst1"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 0, 10, S("abcdefghijklmnopqrst1234567890"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 0, 19, S("abcdefghijklmnopqrst1234567890123456789"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 0, 20, S("abcdefghijklmnopqrst12345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 0, 21, S("abcdefghijklmnopqrst12345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 1, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 1, 1, S("abcdefghijklmnopqrst2"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 1, 9, S("abcdefghijklmnopqrst234567890"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 1, 18, S("abcdefghijklmnopqrst234567890123456789"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 1, 19, S("abcdefghijklmnopqrst2345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 1, 20, S("abcdefghijklmnopqrst2345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 10, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 10, 1, S("abcdefghijklmnopqrst1"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 10, 5, S("abcdefghijklmnopqrst12345"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 10, 9, S("abcdefghijklmnopqrst123456789"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 10, 10, S("abcdefghijklmnopqrst1234567890"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 10, 11, S("abcdefghijklmnopqrst1234567890"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 19, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 19, 1, S("abcdefghijklmnopqrst0"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 19, 2, S("abcdefghijklmnopqrst0"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 20, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 20, 1, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, S(""), 0, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, S(""), 0, 1, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, S(""), 1, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 0, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 0, 1, S("abcdefghijklmnopqrst1"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 0, 2, S("abcdefghijklmnopqrst12"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 0, 4, S("abcdefghijklmnopqrst1234"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 0, 5, S("abcdefghijklmnopqrst12345"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 0, 6, S("abcdefghijklmnopqrst12345"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 1, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 1, 1, S("abcdefghijklmnopqrst2"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 1, 2, S("abcdefghijklmnopqrst23"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 1, 3, S("abcdefghijklmnopqrst234"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 1, 4, S("abcdefghijklmnopqrst2345"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 1, 5, S("abcdefghijklmnopqrst2345"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 2, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 2, 1, S("abcdefghijklmnopqrst3"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 2, 2, S("abcdefghijklmnopqrst34"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 2, 3, S("abcdefghijklmnopqrst345"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 2, 4, S("abcdefghijklmnopqrst345"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 4, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 4, 1, S("abcdefghijklmnopqrst5"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 4, 2, S("abcdefghijklmnopqrst5"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 5, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 5, 1, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 0, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 0, 1, S("abcdefghijklmnopqrst1"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 0, 5, S("abcdefghijklmnopqrst12345"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 0, 9, S("abcdefghijklmnopqrst123456789"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 0, 10, S("abcdefghijklmnopqrst1234567890"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 0, 11, S("abcdefghijklmnopqrst1234567890"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 1, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 1, 1, S("abcdefghijklmnopqrst2"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 1, 4, S("abcdefghijklmnopqrst2345"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 1, 8, S("abcdefghijklmnopqrst23456789"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 1, 9, S("abcdefghijklmnopqrst234567890"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 1, 10, S("abcdefghijklmnopqrst234567890"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 5, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 5, 1, S("abcdefghijklmnopqrst6"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 5, 2, S("abcdefghijklmnopqrst67"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 5, 4, S("abcdefghijklmnopqrst6789"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 5, 5, S("abcdefghijklmnopqrst67890"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 5, 6, S("abcdefghijklmnopqrst67890"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 9, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 9, 1, S("abcdefghijklmnopqrst0"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 9, 2, S("abcdefghijklmnopqrst0"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 10, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 10, 1, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 0, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 0, 1, S("abcdefghijklmnopqrst1"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 0, 10, S("abcdefghijklmnopqrst1234567890"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 0, 19, S("abcdefghijklmnopqrst1234567890123456789"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 0, 20, S("abcdefghijklmnopqrst12345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 0, 21, S("abcdefghijklmnopqrst12345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 1, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 1, 1, S("abcdefghijklmnopqrst2"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 1, 9, S("abcdefghijklmnopqrst234567890"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 1, 18, S("abcdefghijklmnopqrst234567890123456789"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 1, 19, S("abcdefghijklmnopqrst2345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 1, 20, S("abcdefghijklmnopqrst2345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 10, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 10, 1, S("abcdefghijklmnopqrst1"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 10, 5, S("abcdefghijklmnopqrst12345"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 10, 9, S("abcdefghijklmnopqrst123456789"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 10, 10, S("abcdefghijklmnopqrst1234567890"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 10, 11, S("abcdefghijklmnopqrst1234567890"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 19, 0, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 19, 1, S("abcdefghijklmnopqrst0"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 19, 2, S("abcdefghijklmnopqrst0"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 20, 0, S("abcdefghijklmnopqrst"));
+}
+
+template <class S>
+void test54()
+{
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 20, 1, S("abcdefghijklmnopqrst"));
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 21, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, S(""), 0, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, S(""), 0, 1, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, S(""), 1, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 0, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 0, 1, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 0, 2, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 0, 4, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 0, 5, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 0, 6, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 1, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 1, 1, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 1, 2, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 1, 3, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 1, 4, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 1, 5, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 2, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 2, 1, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 2, 2, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 2, 3, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 2, 4, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 4, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 4, 1, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 4, 2, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 5, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 5, 1, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 6, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 0, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 0, 1, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 0, 5, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 0, 9, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 0, 10, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 0, 11, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 1, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 1, 1, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 1, 4, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 1, 8, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 1, 9, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 1, 10, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 5, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 5, 1, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 5, 2, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 5, 4, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 5, 5, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 5, 6, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 9, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 9, 1, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 9, 2, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 10, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 10, 1, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 11, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 0, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 0, 1, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 0, 10, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 0, 19, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 0, 20, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 0, 21, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 1, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 1, 1, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 1, 9, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 1, 18, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 1, 19, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 1, 20, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 10, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 10, 1, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 10, 5, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 10, 9, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 10, 10, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 10, 11, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 19, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 19, 1, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 19, 2, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 20, 0, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 20, 1, S("can't happen"));
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 21, 0, S("can't happen"));
+}
+
+template <class S>
+void test55()
+{
+ test_npos(S("abcdefghij"), 9, 1, S("12345678901234567890"), 10, S("abcdefghi1234567890"));
+ test_npos(S("abcdefghij"), 9, 1, S("12345678901234567890"), 19, S("abcdefghi0"));
+ test_npos(S("abcdefghij"), 9, 1, S("12345678901234567890"), 20, S("abcdefghi"));
+ test_npos(S("abcdefghij"), 9, 1, S("12345678901234567890"), 20, S("abcdefghi"));
+ test_npos(S("abcdefghij"), 9, 1, S("12345678901234567890"), 21, S("can't happen"));
+ test_npos(S("abcdefghij"), 9, 2, S(""), 0, S("abcdefghi"));
+ test_npos(S("abcdefghij"), 9, 2, S(""), 1, S("can't happen"));
+ test_npos(S("abcdefghij"), 9, 2, S("12345"), 0, S("abcdefghi12345"));
+ test_npos(S("abcdefghij"), 9, 2, S("12345"), 1, S("abcdefghi2345"));
+ test_npos(S("abcdefghij"), 9, 2, S("12345"), 2, S("abcdefghi345"));
+ test_npos(S("abcdefghij"), 9, 2, S("12345"), 4, S("abcdefghi5"));
+ test_npos(S("abcdefghij"), 9, 2, S("12345"), 5, S("abcdefghi"));
+ test_npos(S("abcdefghij"), 9, 2, S("12345"), 6, S("can't happen"));
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test0<S>();
+ test1<S>();
+ test2<S>();
+ test3<S>();
+ test4<S>();
+ test5<S>();
+ test6<S>();
+ test7<S>();
+ test8<S>();
+ test9<S>();
+ test10<S>();
+ test11<S>();
+ test12<S>();
+ test13<S>();
+ test14<S>();
+ test15<S>();
+ test16<S>();
+ test17<S>();
+ test18<S>();
+ test19<S>();
+ test20<S>();
+ test21<S>();
+ test22<S>();
+ test23<S>();
+ test24<S>();
+ test25<S>();
+ test26<S>();
+ test27<S>();
+ test28<S>();
+ test29<S>();
+ test30<S>();
+ test31<S>();
+ test32<S>();
+ test33<S>();
+ test34<S>();
+ test35<S>();
+ test36<S>();
+ test37<S>();
+ test38<S>();
+ test39<S>();
+ test40<S>();
+ test41<S>();
+ test42<S>();
+ test43<S>();
+ test44<S>();
+ test45<S>();
+ test46<S>();
+ test47<S>();
+ test48<S>();
+ test49<S>();
+ test50<S>();
+ test51<S>();
+ test52<S>();
+ test53<S>();
+ test54<S>();
+ test55<S>();
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test0<S>();
+ test1<S>();
+ test2<S>();
+ test3<S>();
+ test4<S>();
+ test5<S>();
+ test6<S>();
+ test7<S>();
+ test8<S>();
+ test9<S>();
+ test10<S>();
+ test11<S>();
+ test12<S>();
+ test13<S>();
+ test14<S>();
+ test15<S>();
+ test16<S>();
+ test17<S>();
+ test18<S>();
+ test19<S>();
+ test20<S>();
+ test21<S>();
+ test22<S>();
+ test23<S>();
+ test24<S>();
+ test25<S>();
+ test26<S>();
+ test27<S>();
+ test28<S>();
+ test29<S>();
+ test30<S>();
+ test31<S>();
+ test32<S>();
+ test33<S>();
+ test34<S>();
+ test35<S>();
+ test36<S>();
+ test37<S>();
+ test38<S>();
+ test39<S>();
+ test40<S>();
+ test41<S>();
+ test42<S>();
+ test43<S>();
+ test44<S>();
+ test45<S>();
+ test46<S>();
+ test47<S>();
+ test48<S>();
+ test49<S>();
+ test50<S>();
+ test51<S>();
+ test52<S>();
+ test53<S>();
+ test54<S>();
+ test55<S>();
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.modifiers/string_swap/swap.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_swap/swap.pass.cpp
new file mode 100644
index 000000000000..4973bda4ddf0
--- /dev/null
+++ b/test/std/strings/basic.string/string.modifiers/string_swap/swap.pass.cpp
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// void swap(basic_string& s);
+
+#include <string>
+#include <stdexcept>
+#include <algorithm>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s1, S s2)
+{
+ S s1_ = s1;
+ S s2_ = s2;
+ s1.swap(s2);
+ assert(s1.__invariants());
+ assert(s2.__invariants());
+ assert(s1 == s2_);
+ assert(s2 == s1_);
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test(S(""), S(""));
+ test(S(""), S("12345"));
+ test(S(""), S("1234567890"));
+ test(S(""), S("12345678901234567890"));
+ test(S("abcde"), S(""));
+ test(S("abcde"), S("12345"));
+ test(S("abcde"), S("1234567890"));
+ test(S("abcde"), S("12345678901234567890"));
+ test(S("abcdefghij"), S(""));
+ test(S("abcdefghij"), S("12345"));
+ test(S("abcdefghij"), S("1234567890"));
+ test(S("abcdefghij"), S("12345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), S(""));
+ test(S("abcdefghijklmnopqrst"), S("12345"));
+ test(S("abcdefghijklmnopqrst"), S("1234567890"));
+ test(S("abcdefghijklmnopqrst"), S("12345678901234567890"));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S(""), S(""));
+ test(S(""), S("12345"));
+ test(S(""), S("1234567890"));
+ test(S(""), S("12345678901234567890"));
+ test(S("abcde"), S(""));
+ test(S("abcde"), S("12345"));
+ test(S("abcde"), S("1234567890"));
+ test(S("abcde"), S("12345678901234567890"));
+ test(S("abcdefghij"), S(""));
+ test(S("abcdefghij"), S("12345"));
+ test(S("abcdefghij"), S("1234567890"));
+ test(S("abcdefghij"), S("12345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), S(""));
+ test(S("abcdefghijklmnopqrst"), S("12345"));
+ test(S("abcdefghijklmnopqrst"), S("1234567890"));
+ test(S("abcdefghijklmnopqrst"), S("12345678901234567890"));
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.nonmembers/nothing_to_do.pass.cpp b/test/std/strings/basic.string/string.nonmembers/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/strings/basic.string/string.nonmembers/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/strings/basic.string/string.nonmembers/string.io/get_line.pass.cpp b/test/std/strings/basic.string/string.nonmembers/string.io/get_line.pass.cpp
new file mode 100644
index 000000000000..4a912eaec6fa
--- /dev/null
+++ b/test/std/strings/basic.string/string.nonmembers/string.io/get_line.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+// basic_istream<charT,traits>&
+// getline(basic_istream<charT,traits>& is,
+// basic_string<charT,traits,Allocator>& str);
+
+#include <string>
+#include <sstream>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::istringstream in(" abc\n def\n ghij");
+ std::string s("initial text");
+ getline(in, s);
+ assert(in.good());
+ assert(s == " abc");
+ getline(in, s);
+ assert(in.good());
+ assert(s == " def");
+ getline(in, s);
+ assert(in.eof());
+ assert(s == " ghij");
+ }
+ {
+ std::wistringstream in(L" abc\n def\n ghij");
+ std::wstring s(L"initial text");
+ getline(in, s);
+ assert(in.good());
+ assert(s == L" abc");
+ getline(in, s);
+ assert(in.good());
+ assert(s == L" def");
+ getline(in, s);
+ assert(in.eof());
+ assert(s == L" ghij");
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ std::istringstream in(" abc\n def\n ghij");
+ S s("initial text");
+ getline(in, s);
+ assert(in.good());
+ assert(s == " abc");
+ getline(in, s);
+ assert(in.good());
+ assert(s == " def");
+ getline(in, s);
+ assert(in.eof());
+ assert(s == " ghij");
+ }
+ {
+ typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, min_allocator<wchar_t>> S;
+ std::wistringstream in(L" abc\n def\n ghij");
+ S s(L"initial text");
+ getline(in, s);
+ assert(in.good());
+ assert(s == L" abc");
+ getline(in, s);
+ assert(in.good());
+ assert(s == L" def");
+ getline(in, s);
+ assert(in.eof());
+ assert(s == L" ghij");
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.nonmembers/string.io/get_line_delim.pass.cpp b/test/std/strings/basic.string/string.nonmembers/string.io/get_line_delim.pass.cpp
new file mode 100644
index 000000000000..6596f2fffa79
--- /dev/null
+++ b/test/std/strings/basic.string/string.nonmembers/string.io/get_line_delim.pass.cpp
@@ -0,0 +1,93 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+// basic_istream<charT,traits>&
+// getline(basic_istream<charT,traits>& is,
+// basic_string<charT,traits,Allocator>& str, charT delim);
+
+#include <string>
+#include <sstream>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::istringstream in(" abc* def** ghij");
+ std::string s("initial text");
+ getline(in, s, '*');
+ assert(in.good());
+ assert(s == " abc");
+ getline(in, s, '*');
+ assert(in.good());
+ assert(s == " def");
+ getline(in, s, '*');
+ assert(in.good());
+ assert(s == "");
+ getline(in, s, '*');
+ assert(in.eof());
+ assert(s == " ghij");
+ }
+ {
+ std::wistringstream in(L" abc* def** ghij");
+ std::wstring s(L"initial text");
+ getline(in, s, L'*');
+ assert(in.good());
+ assert(s == L" abc");
+ getline(in, s, L'*');
+ assert(in.good());
+ assert(s == L" def");
+ getline(in, s, L'*');
+ assert(in.good());
+ assert(s == L"");
+ getline(in, s, L'*');
+ assert(in.eof());
+ assert(s == L" ghij");
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ std::istringstream in(" abc* def** ghij");
+ S s("initial text");
+ getline(in, s, '*');
+ assert(in.good());
+ assert(s == " abc");
+ getline(in, s, '*');
+ assert(in.good());
+ assert(s == " def");
+ getline(in, s, '*');
+ assert(in.good());
+ assert(s == "");
+ getline(in, s, '*');
+ assert(in.eof());
+ assert(s == " ghij");
+ }
+ {
+ typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, min_allocator<wchar_t>> S;
+ std::wistringstream in(L" abc* def** ghij");
+ S s(L"initial text");
+ getline(in, s, L'*');
+ assert(in.good());
+ assert(s == L" abc");
+ getline(in, s, L'*');
+ assert(in.good());
+ assert(s == L" def");
+ getline(in, s, L'*');
+ assert(in.good());
+ assert(s == L"");
+ getline(in, s, L'*');
+ assert(in.eof());
+ assert(s == L" ghij");
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.nonmembers/string.io/get_line_delim_rv.pass.cpp b/test/std/strings/basic.string/string.nonmembers/string.io/get_line_delim_rv.pass.cpp
new file mode 100644
index 000000000000..84f52bb2e50f
--- /dev/null
+++ b/test/std/strings/basic.string/string.nonmembers/string.io/get_line_delim_rv.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+// basic_istream<charT,traits>&
+// getline(basic_istream<charT,traits>&& is,
+// basic_string<charT,traits,Allocator>& str, charT delim);
+
+#include <string>
+#include <sstream>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::string s("initial text");
+ getline(std::istringstream(" abc* def* ghij"), s, '*');
+ assert(s == " abc");
+ }
+ {
+ std::wstring s(L"initial text");
+ getline(std::wistringstream(L" abc* def* ghij"), s, L'*');
+ assert(s == L" abc");
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ S s("initial text");
+ getline(std::istringstream(" abc* def* ghij"), s, '*');
+ assert(s == " abc");
+ }
+ {
+ typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, min_allocator<wchar_t>> S;
+ S s(L"initial text");
+ getline(std::wistringstream(L" abc* def* ghij"), s, L'*');
+ assert(s == L" abc");
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/strings/basic.string/string.nonmembers/string.io/get_line_rv.pass.cpp b/test/std/strings/basic.string/string.nonmembers/string.io/get_line_rv.pass.cpp
new file mode 100644
index 000000000000..a3c9911abe9b
--- /dev/null
+++ b/test/std/strings/basic.string/string.nonmembers/string.io/get_line_rv.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+// basic_istream<charT,traits>&
+// getline(basic_istream<charT,traits>&& is,
+// basic_string<charT,traits,Allocator>& str);
+
+#include <string>
+#include <sstream>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::string s("initial text");
+ getline(std::istringstream(" abc\n def\n ghij"), s);
+ assert(s == " abc");
+ }
+ {
+ std::wstring s(L"initial text");
+ getline(std::wistringstream(L" abc\n def\n ghij"), s);
+ assert(s == L" abc");
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ S s("initial text");
+ getline(std::istringstream(" abc\n def\n ghij"), s);
+ assert(s == " abc");
+ }
+ {
+ typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, min_allocator<wchar_t>> S;
+ S s(L"initial text");
+ getline(std::wistringstream(L" abc\n def\n ghij"), s);
+ assert(s == L" abc");
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/strings/basic.string/string.nonmembers/string.io/stream_extract.pass.cpp b/test/std/strings/basic.string/string.nonmembers/string.io/stream_extract.pass.cpp
new file mode 100644
index 000000000000..af806bc04570
--- /dev/null
+++ b/test/std/strings/basic.string/string.nonmembers/string.io/stream_extract.pass.cpp
@@ -0,0 +1,117 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+// basic_istream<charT,traits>&
+// operator>>(basic_istream<charT,traits>& is,
+// basic_string<charT,traits,Allocator>& str);
+
+#include <string>
+#include <sstream>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::istringstream in("a bc defghij");
+ std::string s("initial text");
+ in >> s;
+ assert(in.good());
+ assert(s == "a");
+ assert(in.peek() == ' ');
+ in >> s;
+ assert(in.good());
+ assert(s == "bc");
+ assert(in.peek() == ' ');
+ in.width(3);
+ in >> s;
+ assert(in.good());
+ assert(s == "def");
+ assert(in.peek() == 'g');
+ in >> s;
+ assert(in.eof());
+ assert(s == "ghij");
+ in >> s;
+ assert(in.fail());
+ }
+ {
+ std::wistringstream in(L"a bc defghij");
+ std::wstring s(L"initial text");
+ in >> s;
+ assert(in.good());
+ assert(s == L"a");
+ assert(in.peek() == L' ');
+ in >> s;
+ assert(in.good());
+ assert(s == L"bc");
+ assert(in.peek() == L' ');
+ in.width(3);
+ in >> s;
+ assert(in.good());
+ assert(s == L"def");
+ assert(in.peek() == L'g');
+ in >> s;
+ assert(in.eof());
+ assert(s == L"ghij");
+ in >> s;
+ assert(in.fail());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ std::istringstream in("a bc defghij");
+ S s("initial text");
+ in >> s;
+ assert(in.good());
+ assert(s == "a");
+ assert(in.peek() == ' ');
+ in >> s;
+ assert(in.good());
+ assert(s == "bc");
+ assert(in.peek() == ' ');
+ in.width(3);
+ in >> s;
+ assert(in.good());
+ assert(s == "def");
+ assert(in.peek() == 'g');
+ in >> s;
+ assert(in.eof());
+ assert(s == "ghij");
+ in >> s;
+ assert(in.fail());
+ }
+ {
+ typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, min_allocator<wchar_t>> S;
+ std::wistringstream in(L"a bc defghij");
+ S s(L"initial text");
+ in >> s;
+ assert(in.good());
+ assert(s == L"a");
+ assert(in.peek() == L' ');
+ in >> s;
+ assert(in.good());
+ assert(s == L"bc");
+ assert(in.peek() == L' ');
+ in.width(3);
+ in >> s;
+ assert(in.good());
+ assert(s == L"def");
+ assert(in.peek() == L'g');
+ in >> s;
+ assert(in.eof());
+ assert(s == L"ghij");
+ in >> s;
+ assert(in.fail());
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.nonmembers/string.io/stream_insert.pass.cpp b/test/std/strings/basic.string/string.nonmembers/string.io/stream_insert.pass.cpp
new file mode 100644
index 000000000000..102e8ea08159
--- /dev/null
+++ b/test/std/strings/basic.string/string.nonmembers/string.io/stream_insert.pass.cpp
@@ -0,0 +1,91 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+// basic_ostream<charT, traits>&
+// operator<<(basic_ostream<charT, traits>& os,
+// const basic_string<charT,traits,Allocator>& str);
+
+#include <string>
+#include <sstream>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::ostringstream out;
+ std::string s("some text");
+ out << s;
+ assert(out.good());
+ assert(s == out.str());
+ }
+ {
+ std::ostringstream out;
+ std::string s("some text");
+ out.width(12);
+ out << s;
+ assert(out.good());
+ assert(" " + s == out.str());
+ }
+ {
+ std::wostringstream out;
+ std::wstring s(L"some text");
+ out << s;
+ assert(out.good());
+ assert(s == out.str());
+ }
+ {
+ std::wostringstream out;
+ std::wstring s(L"some text");
+ out.width(12);
+ out << s;
+ assert(out.good());
+ assert(L" " + s == out.str());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ std::basic_ostringstream<S::value_type, S::traits_type, S::allocator_type> out;
+ S s("some text");
+ out << s;
+ assert(out.good());
+ assert(s == out.str());
+ }
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ std::basic_ostringstream<S::value_type, S::traits_type, S::allocator_type> out;
+ S s("some text");
+ out.width(12);
+ out << s;
+ assert(out.good());
+ assert(" " + s == out.str());
+ }
+ {
+ typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, min_allocator<wchar_t>> S;
+ std::basic_ostringstream<S::value_type, S::traits_type, S::allocator_type> out;
+ S s(L"some text");
+ out << s;
+ assert(out.good());
+ assert(s == out.str());
+ }
+ {
+ typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, min_allocator<wchar_t>> S;
+ std::basic_ostringstream<S::value_type, S::traits_type, S::allocator_type> out;
+ S s(L"some text");
+ out.width(12);
+ out << s;
+ assert(out.good());
+ assert(L" " + s == out.str());
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.nonmembers/string.special/swap.pass.cpp b/test/std/strings/basic.string/string.nonmembers/string.special/swap.pass.cpp
new file mode 100644
index 000000000000..cee538800dd0
--- /dev/null
+++ b/test/std/strings/basic.string/string.nonmembers/string.special/swap.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+// void swap(basic_string<charT,traits,Allocator>& lhs,
+// basic_string<charT,traits,Allocator>& rhs);
+
+#include <string>
+#include <stdexcept>
+#include <algorithm>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s1, S s2)
+{
+ S s1_ = s1;
+ S s2_ = s2;
+ swap(s1, s2);
+ assert(s1.__invariants());
+ assert(s2.__invariants());
+ assert(s1 == s2_);
+ assert(s2 == s1_);
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test(S(""), S(""));
+ test(S(""), S("12345"));
+ test(S(""), S("1234567890"));
+ test(S(""), S("12345678901234567890"));
+ test(S("abcde"), S(""));
+ test(S("abcde"), S("12345"));
+ test(S("abcde"), S("1234567890"));
+ test(S("abcde"), S("12345678901234567890"));
+ test(S("abcdefghij"), S(""));
+ test(S("abcdefghij"), S("12345"));
+ test(S("abcdefghij"), S("1234567890"));
+ test(S("abcdefghij"), S("12345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), S(""));
+ test(S("abcdefghijklmnopqrst"), S("12345"));
+ test(S("abcdefghijklmnopqrst"), S("1234567890"));
+ test(S("abcdefghijklmnopqrst"), S("12345678901234567890"));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S(""), S(""));
+ test(S(""), S("12345"));
+ test(S(""), S("1234567890"));
+ test(S(""), S("12345678901234567890"));
+ test(S("abcde"), S(""));
+ test(S("abcde"), S("12345"));
+ test(S("abcde"), S("1234567890"));
+ test(S("abcde"), S("12345678901234567890"));
+ test(S("abcdefghij"), S(""));
+ test(S("abcdefghij"), S("12345"));
+ test(S("abcdefghij"), S("1234567890"));
+ test(S("abcdefghij"), S("12345678901234567890"));
+ test(S("abcdefghijklmnopqrst"), S(""));
+ test(S("abcdefghijklmnopqrst"), S("12345"));
+ test(S("abcdefghijklmnopqrst"), S("1234567890"));
+ test(S("abcdefghijklmnopqrst"), S("12345678901234567890"));
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.nonmembers/string.special/swap_noexcept.pass.cpp b/test/std/strings/basic.string/string.nonmembers/string.special/swap_noexcept.pass.cpp
new file mode 100644
index 000000000000..cfe03655a8a1
--- /dev/null
+++ b/test/std/strings/basic.string/string.nonmembers/string.special/swap_noexcept.pass.cpp
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// void swap(basic_string& c)
+// noexcept(!allocator_type::propagate_on_container_swap::value ||
+// __is_nothrow_swappable<allocator_type>::value);
+//
+// In C++17, the standard says that swap shall have:
+// noexcept(allocator_traits<Allocator>::propagate_on_container_swap::value ||
+// allocator_traits<Allocator>::is_always_equal::value);
+
+// This tests a conforming extension
+
+#include <string>
+#include <cassert>
+
+#include "test_allocator.h"
+
+template <class T>
+struct some_alloc
+{
+ typedef T value_type;
+
+ some_alloc() {}
+ some_alloc(const some_alloc&);
+ void deallocate(void*, unsigned) {}
+
+ typedef std::true_type propagate_on_container_swap;
+};
+
+template <class T>
+struct some_alloc2
+{
+ typedef T value_type;
+
+ some_alloc2() {}
+ some_alloc2(const some_alloc2&);
+ void deallocate(void*, unsigned) {}
+
+ typedef std::false_type propagate_on_container_swap;
+ typedef std::true_type is_always_equal;
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::string C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::basic_string<char, std::char_traits<char>, test_allocator<char>> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::basic_string<char, std::char_traits<char>, some_alloc<char>> C;
+ C c1, c2;
+#if TEST_STD_VER >= 14
+ // In c++14, if POCS is set, swapping the allocator is required not to throw
+ static_assert( noexcept(swap(c1, c2)), "");
+#else
+ static_assert(!noexcept(swap(c1, c2)), "");
+#endif
+ }
+#if TEST_STD_VER >= 14
+ {
+ typedef std::basic_string<char, std::char_traits<char>, some_alloc2<char>> C;
+ C c1, c2;
+ // if the allocators are always equal, then the swap can be noexcept
+ static_assert( noexcept(swap(c1, c2)), "");
+ }
+#endif
+
+#endif
+}
diff --git a/test/std/strings/basic.string/string.nonmembers/string_op!=/pointer_string.pass.cpp b/test/std/strings/basic.string/string.nonmembers/string_op!=/pointer_string.pass.cpp
new file mode 100644
index 000000000000..cc08982a5ca3
--- /dev/null
+++ b/test/std/strings/basic.string/string.nonmembers/string_op!=/pointer_string.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+// bool operator!=(const charT* lhs, const basic_string<charT,traits,Allocator>& rhs);
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const typename S::value_type* lhs, const S& rhs, bool x)
+{
+ assert((lhs != rhs) == x);
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test("", S(""), false);
+ test("", S("abcde"), true);
+ test("", S("abcdefghij"), true);
+ test("", S("abcdefghijklmnopqrst"), true);
+ test("abcde", S(""), true);
+ test("abcde", S("abcde"), false);
+ test("abcde", S("abcdefghij"), true);
+ test("abcde", S("abcdefghijklmnopqrst"), true);
+ test("abcdefghij", S(""), true);
+ test("abcdefghij", S("abcde"), true);
+ test("abcdefghij", S("abcdefghij"), false);
+ test("abcdefghij", S("abcdefghijklmnopqrst"), true);
+ test("abcdefghijklmnopqrst", S(""), true);
+ test("abcdefghijklmnopqrst", S("abcde"), true);
+ test("abcdefghijklmnopqrst", S("abcdefghij"), true);
+ test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test("", S(""), false);
+ test("", S("abcde"), true);
+ test("", S("abcdefghij"), true);
+ test("", S("abcdefghijklmnopqrst"), true);
+ test("abcde", S(""), true);
+ test("abcde", S("abcde"), false);
+ test("abcde", S("abcdefghij"), true);
+ test("abcde", S("abcdefghijklmnopqrst"), true);
+ test("abcdefghij", S(""), true);
+ test("abcdefghij", S("abcde"), true);
+ test("abcdefghij", S("abcdefghij"), false);
+ test("abcdefghij", S("abcdefghijklmnopqrst"), true);
+ test("abcdefghijklmnopqrst", S(""), true);
+ test("abcdefghijklmnopqrst", S("abcde"), true);
+ test("abcdefghijklmnopqrst", S("abcdefghij"), true);
+ test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), false);
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.nonmembers/string_op!=/string_pointer.pass.cpp b/test/std/strings/basic.string/string.nonmembers/string_op!=/string_pointer.pass.cpp
new file mode 100644
index 000000000000..b496d70dc2f0
--- /dev/null
+++ b/test/std/strings/basic.string/string.nonmembers/string_op!=/string_pointer.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+// bool operator!=(const basic_string<charT,traits,Allocator>& lhs, const charT* rhs);
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& lhs, const typename S::value_type* rhs, bool x)
+{
+ assert((lhs != rhs) == x);
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test(S(""), "", false);
+ test(S(""), "abcde", true);
+ test(S(""), "abcdefghij", true);
+ test(S(""), "abcdefghijklmnopqrst", true);
+ test(S("abcde"), "", true);
+ test(S("abcde"), "abcde", false);
+ test(S("abcde"), "abcdefghij", true);
+ test(S("abcde"), "abcdefghijklmnopqrst", true);
+ test(S("abcdefghij"), "", true);
+ test(S("abcdefghij"), "abcde", true);
+ test(S("abcdefghij"), "abcdefghij", false);
+ test(S("abcdefghij"), "abcdefghijklmnopqrst", true);
+ test(S("abcdefghijklmnopqrst"), "", true);
+ test(S("abcdefghijklmnopqrst"), "abcde", true);
+ test(S("abcdefghijklmnopqrst"), "abcdefghij", true);
+ test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S(""), "", false);
+ test(S(""), "abcde", true);
+ test(S(""), "abcdefghij", true);
+ test(S(""), "abcdefghijklmnopqrst", true);
+ test(S("abcde"), "", true);
+ test(S("abcde"), "abcde", false);
+ test(S("abcde"), "abcdefghij", true);
+ test(S("abcde"), "abcdefghijklmnopqrst", true);
+ test(S("abcdefghij"), "", true);
+ test(S("abcdefghij"), "abcde", true);
+ test(S("abcdefghij"), "abcdefghij", false);
+ test(S("abcdefghij"), "abcdefghijklmnopqrst", true);
+ test(S("abcdefghijklmnopqrst"), "", true);
+ test(S("abcdefghijklmnopqrst"), "abcde", true);
+ test(S("abcdefghijklmnopqrst"), "abcdefghij", true);
+ test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", false);
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.nonmembers/string_op!=/string_string.pass.cpp b/test/std/strings/basic.string/string.nonmembers/string_op!=/string_string.pass.cpp
new file mode 100644
index 000000000000..069b305111d4
--- /dev/null
+++ b/test/std/strings/basic.string/string.nonmembers/string_op!=/string_string.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+// bool operator!=(const basic_string<charT,traits,Allocator>& lhs,
+// const basic_string<charT,traits,Allocator>& rhs);
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& lhs, const S& rhs, bool x)
+{
+ assert((lhs != rhs) == x);
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test(S(""), S(""), false);
+ test(S(""), S("abcde"), true);
+ test(S(""), S("abcdefghij"), true);
+ test(S(""), S("abcdefghijklmnopqrst"), true);
+ test(S("abcde"), S(""), true);
+ test(S("abcde"), S("abcde"), false);
+ test(S("abcde"), S("abcdefghij"), true);
+ test(S("abcde"), S("abcdefghijklmnopqrst"), true);
+ test(S("abcdefghij"), S(""), true);
+ test(S("abcdefghij"), S("abcde"), true);
+ test(S("abcdefghij"), S("abcdefghij"), false);
+ test(S("abcdefghij"), S("abcdefghijklmnopqrst"), true);
+ test(S("abcdefghijklmnopqrst"), S(""), true);
+ test(S("abcdefghijklmnopqrst"), S("abcde"), true);
+ test(S("abcdefghijklmnopqrst"), S("abcdefghij"), true);
+ test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S(""), S(""), false);
+ test(S(""), S("abcde"), true);
+ test(S(""), S("abcdefghij"), true);
+ test(S(""), S("abcdefghijklmnopqrst"), true);
+ test(S("abcde"), S(""), true);
+ test(S("abcde"), S("abcde"), false);
+ test(S("abcde"), S("abcdefghij"), true);
+ test(S("abcde"), S("abcdefghijklmnopqrst"), true);
+ test(S("abcdefghij"), S(""), true);
+ test(S("abcdefghij"), S("abcde"), true);
+ test(S("abcdefghij"), S("abcdefghij"), false);
+ test(S("abcdefghij"), S("abcdefghijklmnopqrst"), true);
+ test(S("abcdefghijklmnopqrst"), S(""), true);
+ test(S("abcdefghijklmnopqrst"), S("abcde"), true);
+ test(S("abcdefghijklmnopqrst"), S("abcdefghij"), true);
+ test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), false);
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.nonmembers/string_op+/char_string.pass.cpp b/test/std/strings/basic.string/string.nonmembers/string_op+/char_string.pass.cpp
new file mode 100644
index 000000000000..23a89c6fc8fb
--- /dev/null
+++ b/test/std/strings/basic.string/string.nonmembers/string_op+/char_string.pass.cpp
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+// basic_string<charT,traits,Allocator>
+// operator+(charT lhs, const basic_string<charT,traits,Allocator>& rhs);
+
+// template<class charT, class traits, class Allocator>
+// basic_string<charT,traits,Allocator>&&
+// operator+(charT lhs, basic_string<charT,traits,Allocator>&& rhs);
+
+#include <string>
+#include <utility>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test0(typename S::value_type lhs, const S& rhs, const S& x)
+{
+ assert(lhs + rhs == x);
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class S>
+void
+test1(typename S::value_type lhs, S&& rhs, const S& x)
+{
+ assert(lhs + move(rhs) == x);
+}
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+ {
+ typedef std::string S;
+ test0('a', S(""), S("a"));
+ test0('a', S("12345"), S("a12345"));
+ test0('a', S("1234567890"), S("a1234567890"));
+ test0('a', S("12345678901234567890"), S("a12345678901234567890"));
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+ test1('a', S(""), S("a"));
+ test1('a', S("12345"), S("a12345"));
+ test1('a', S("1234567890"), S("a1234567890"));
+ test1('a', S("12345678901234567890"), S("a12345678901234567890"));
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test0('a', S(""), S("a"));
+ test0('a', S("12345"), S("a12345"));
+ test0('a', S("1234567890"), S("a1234567890"));
+ test0('a', S("12345678901234567890"), S("a12345678901234567890"));
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+ test1('a', S(""), S("a"));
+ test1('a', S("12345"), S("a12345"));
+ test1('a', S("1234567890"), S("a1234567890"));
+ test1('a', S("12345678901234567890"), S("a12345678901234567890"));
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.nonmembers/string_op+/pointer_string.pass.cpp b/test/std/strings/basic.string/string.nonmembers/string_op+/pointer_string.pass.cpp
new file mode 100644
index 000000000000..665e86f2c239
--- /dev/null
+++ b/test/std/strings/basic.string/string.nonmembers/string_op+/pointer_string.pass.cpp
@@ -0,0 +1,128 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+// basic_string<charT,traits,Allocator>
+// operator+(const charT* lhs, const basic_string<charT,traits,Allocator>& rhs);
+
+// template<class charT, class traits, class Allocator>
+// basic_string<charT,traits,Allocator>&&
+// operator+(const charT* lhs, basic_string<charT,traits,Allocator>&& rhs);
+
+#include <string>
+#include <utility>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test0(const typename S::value_type* lhs, const S& rhs, const S& x)
+{
+ assert(lhs + rhs == x);
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class S>
+void
+test1(const typename S::value_type* lhs, S&& rhs, const S& x)
+{
+ assert(lhs + move(rhs) == x);
+}
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+ {
+ typedef std::string S;
+ test0("", S(""), S(""));
+ test0("", S("12345"), S("12345"));
+ test0("", S("1234567890"), S("1234567890"));
+ test0("", S("12345678901234567890"), S("12345678901234567890"));
+ test0("abcde", S(""), S("abcde"));
+ test0("abcde", S("12345"), S("abcde12345"));
+ test0("abcde", S("1234567890"), S("abcde1234567890"));
+ test0("abcde", S("12345678901234567890"), S("abcde12345678901234567890"));
+ test0("abcdefghij", S(""), S("abcdefghij"));
+ test0("abcdefghij", S("12345"), S("abcdefghij12345"));
+ test0("abcdefghij", S("1234567890"), S("abcdefghij1234567890"));
+ test0("abcdefghij", S("12345678901234567890"), S("abcdefghij12345678901234567890"));
+ test0("abcdefghijklmnopqrst", S(""), S("abcdefghijklmnopqrst"));
+ test0("abcdefghijklmnopqrst", S("12345"), S("abcdefghijklmnopqrst12345"));
+ test0("abcdefghijklmnopqrst", S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
+ test0("abcdefghijklmnopqrst", S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+ test1("", S(""), S(""));
+ test1("", S("12345"), S("12345"));
+ test1("", S("1234567890"), S("1234567890"));
+ test1("", S("12345678901234567890"), S("12345678901234567890"));
+ test1("abcde", S(""), S("abcde"));
+ test1("abcde", S("12345"), S("abcde12345"));
+ test1("abcde", S("1234567890"), S("abcde1234567890"));
+ test1("abcde", S("12345678901234567890"), S("abcde12345678901234567890"));
+ test1("abcdefghij", S(""), S("abcdefghij"));
+ test1("abcdefghij", S("12345"), S("abcdefghij12345"));
+ test1("abcdefghij", S("1234567890"), S("abcdefghij1234567890"));
+ test1("abcdefghij", S("12345678901234567890"), S("abcdefghij12345678901234567890"));
+ test1("abcdefghijklmnopqrst", S(""), S("abcdefghijklmnopqrst"));
+ test1("abcdefghijklmnopqrst", S("12345"), S("abcdefghijklmnopqrst12345"));
+ test1("abcdefghijklmnopqrst", S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
+ test1("abcdefghijklmnopqrst", S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test0("", S(""), S(""));
+ test0("", S("12345"), S("12345"));
+ test0("", S("1234567890"), S("1234567890"));
+ test0("", S("12345678901234567890"), S("12345678901234567890"));
+ test0("abcde", S(""), S("abcde"));
+ test0("abcde", S("12345"), S("abcde12345"));
+ test0("abcde", S("1234567890"), S("abcde1234567890"));
+ test0("abcde", S("12345678901234567890"), S("abcde12345678901234567890"));
+ test0("abcdefghij", S(""), S("abcdefghij"));
+ test0("abcdefghij", S("12345"), S("abcdefghij12345"));
+ test0("abcdefghij", S("1234567890"), S("abcdefghij1234567890"));
+ test0("abcdefghij", S("12345678901234567890"), S("abcdefghij12345678901234567890"));
+ test0("abcdefghijklmnopqrst", S(""), S("abcdefghijklmnopqrst"));
+ test0("abcdefghijklmnopqrst", S("12345"), S("abcdefghijklmnopqrst12345"));
+ test0("abcdefghijklmnopqrst", S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
+ test0("abcdefghijklmnopqrst", S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+ test1("", S(""), S(""));
+ test1("", S("12345"), S("12345"));
+ test1("", S("1234567890"), S("1234567890"));
+ test1("", S("12345678901234567890"), S("12345678901234567890"));
+ test1("abcde", S(""), S("abcde"));
+ test1("abcde", S("12345"), S("abcde12345"));
+ test1("abcde", S("1234567890"), S("abcde1234567890"));
+ test1("abcde", S("12345678901234567890"), S("abcde12345678901234567890"));
+ test1("abcdefghij", S(""), S("abcdefghij"));
+ test1("abcdefghij", S("12345"), S("abcdefghij12345"));
+ test1("abcdefghij", S("1234567890"), S("abcdefghij1234567890"));
+ test1("abcdefghij", S("12345678901234567890"), S("abcdefghij12345678901234567890"));
+ test1("abcdefghijklmnopqrst", S(""), S("abcdefghijklmnopqrst"));
+ test1("abcdefghijklmnopqrst", S("12345"), S("abcdefghijklmnopqrst12345"));
+ test1("abcdefghijklmnopqrst", S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
+ test1("abcdefghijklmnopqrst", S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.nonmembers/string_op+/string_char.pass.cpp b/test/std/strings/basic.string/string.nonmembers/string_op+/string_char.pass.cpp
new file mode 100644
index 000000000000..12903fe8118e
--- /dev/null
+++ b/test/std/strings/basic.string/string.nonmembers/string_op+/string_char.pass.cpp
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+// basic_string<charT,traits,Allocator>
+// operator+(const basic_string<charT,traits,Allocator>& lhs, charT rhs);
+
+// template<class charT, class traits, class Allocator>
+// basic_string<charT,traits,Allocator>&&
+// operator+(basic_string<charT,traits,Allocator>&& lhs, charT rhs);
+
+#include <string>
+#include <utility>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test0(const S& lhs, typename S::value_type rhs, const S& x)
+{
+ assert(lhs + rhs == x);
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class S>
+void
+test1(S&& lhs, typename S::value_type rhs, const S& x)
+{
+ assert(move(lhs) + rhs == x);
+}
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+ {
+ typedef std::string S;
+ test0(S(""), '1', S("1"));
+ test0(S("abcde"), '1', S("abcde1"));
+ test0(S("abcdefghij"), '1', S("abcdefghij1"));
+ test0(S("abcdefghijklmnopqrst"), '1', S("abcdefghijklmnopqrst1"));
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+ test1(S(""), '1', S("1"));
+ test1(S("abcde"), '1', S("abcde1"));
+ test1(S("abcdefghij"), '1', S("abcdefghij1"));
+ test1(S("abcdefghijklmnopqrst"), '1', S("abcdefghijklmnopqrst1"));
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test0(S(""), '1', S("1"));
+ test0(S("abcde"), '1', S("abcde1"));
+ test0(S("abcdefghij"), '1', S("abcdefghij1"));
+ test0(S("abcdefghijklmnopqrst"), '1', S("abcdefghijklmnopqrst1"));
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+ test1(S(""), '1', S("1"));
+ test1(S("abcde"), '1', S("abcde1"));
+ test1(S("abcdefghij"), '1', S("abcdefghij1"));
+ test1(S("abcdefghijklmnopqrst"), '1', S("abcdefghijklmnopqrst1"));
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.nonmembers/string_op+/string_pointer.pass.cpp b/test/std/strings/basic.string/string.nonmembers/string_op+/string_pointer.pass.cpp
new file mode 100644
index 000000000000..63a7b769b787
--- /dev/null
+++ b/test/std/strings/basic.string/string.nonmembers/string_op+/string_pointer.pass.cpp
@@ -0,0 +1,128 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+// basic_string<charT,traits,Allocator>
+// operator+(const basic_string<charT,traits,Allocator>& lhs, const charT* rhs);
+
+// template<class charT, class traits, class Allocator>
+// basic_string<charT,traits,Allocator>&&
+// operator+(basic_string<charT,traits,Allocator>&& lhs, const charT* rhs);
+
+#include <string>
+#include <utility>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test0(const S& lhs, const typename S::value_type* rhs, const S& x)
+{
+ assert(lhs + rhs == x);
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class S>
+void
+test1(S&& lhs, const typename S::value_type* rhs, const S& x)
+{
+ assert(move(lhs) + rhs == x);
+}
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+ {
+ typedef std::string S;
+ test0(S(""), "", S(""));
+ test0(S(""), "12345", S("12345"));
+ test0(S(""), "1234567890", S("1234567890"));
+ test0(S(""), "12345678901234567890", S("12345678901234567890"));
+ test0(S("abcde"), "", S("abcde"));
+ test0(S("abcde"), "12345", S("abcde12345"));
+ test0(S("abcde"), "1234567890", S("abcde1234567890"));
+ test0(S("abcde"), "12345678901234567890", S("abcde12345678901234567890"));
+ test0(S("abcdefghij"), "", S("abcdefghij"));
+ test0(S("abcdefghij"), "12345", S("abcdefghij12345"));
+ test0(S("abcdefghij"), "1234567890", S("abcdefghij1234567890"));
+ test0(S("abcdefghij"), "12345678901234567890", S("abcdefghij12345678901234567890"));
+ test0(S("abcdefghijklmnopqrst"), "", S("abcdefghijklmnopqrst"));
+ test0(S("abcdefghijklmnopqrst"), "12345", S("abcdefghijklmnopqrst12345"));
+ test0(S("abcdefghijklmnopqrst"), "1234567890", S("abcdefghijklmnopqrst1234567890"));
+ test0(S("abcdefghijklmnopqrst"), "12345678901234567890", S("abcdefghijklmnopqrst12345678901234567890"));
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+ test1(S(""), "", S(""));
+ test1(S(""), "12345", S("12345"));
+ test1(S(""), "1234567890", S("1234567890"));
+ test1(S(""), "12345678901234567890", S("12345678901234567890"));
+ test1(S("abcde"), "", S("abcde"));
+ test1(S("abcde"), "12345", S("abcde12345"));
+ test1(S("abcde"), "1234567890", S("abcde1234567890"));
+ test1(S("abcde"), "12345678901234567890", S("abcde12345678901234567890"));
+ test1(S("abcdefghij"), "", S("abcdefghij"));
+ test1(S("abcdefghij"), "12345", S("abcdefghij12345"));
+ test1(S("abcdefghij"), "1234567890", S("abcdefghij1234567890"));
+ test1(S("abcdefghij"), "12345678901234567890", S("abcdefghij12345678901234567890"));
+ test1(S("abcdefghijklmnopqrst"), "", S("abcdefghijklmnopqrst"));
+ test1(S("abcdefghijklmnopqrst"), "12345", S("abcdefghijklmnopqrst12345"));
+ test1(S("abcdefghijklmnopqrst"), "1234567890", S("abcdefghijklmnopqrst1234567890"));
+ test1(S("abcdefghijklmnopqrst"), "12345678901234567890", S("abcdefghijklmnopqrst12345678901234567890"));
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test0(S(""), "", S(""));
+ test0(S(""), "12345", S("12345"));
+ test0(S(""), "1234567890", S("1234567890"));
+ test0(S(""), "12345678901234567890", S("12345678901234567890"));
+ test0(S("abcde"), "", S("abcde"));
+ test0(S("abcde"), "12345", S("abcde12345"));
+ test0(S("abcde"), "1234567890", S("abcde1234567890"));
+ test0(S("abcde"), "12345678901234567890", S("abcde12345678901234567890"));
+ test0(S("abcdefghij"), "", S("abcdefghij"));
+ test0(S("abcdefghij"), "12345", S("abcdefghij12345"));
+ test0(S("abcdefghij"), "1234567890", S("abcdefghij1234567890"));
+ test0(S("abcdefghij"), "12345678901234567890", S("abcdefghij12345678901234567890"));
+ test0(S("abcdefghijklmnopqrst"), "", S("abcdefghijklmnopqrst"));
+ test0(S("abcdefghijklmnopqrst"), "12345", S("abcdefghijklmnopqrst12345"));
+ test0(S("abcdefghijklmnopqrst"), "1234567890", S("abcdefghijklmnopqrst1234567890"));
+ test0(S("abcdefghijklmnopqrst"), "12345678901234567890", S("abcdefghijklmnopqrst12345678901234567890"));
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+ test1(S(""), "", S(""));
+ test1(S(""), "12345", S("12345"));
+ test1(S(""), "1234567890", S("1234567890"));
+ test1(S(""), "12345678901234567890", S("12345678901234567890"));
+ test1(S("abcde"), "", S("abcde"));
+ test1(S("abcde"), "12345", S("abcde12345"));
+ test1(S("abcde"), "1234567890", S("abcde1234567890"));
+ test1(S("abcde"), "12345678901234567890", S("abcde12345678901234567890"));
+ test1(S("abcdefghij"), "", S("abcdefghij"));
+ test1(S("abcdefghij"), "12345", S("abcdefghij12345"));
+ test1(S("abcdefghij"), "1234567890", S("abcdefghij1234567890"));
+ test1(S("abcdefghij"), "12345678901234567890", S("abcdefghij12345678901234567890"));
+ test1(S("abcdefghijklmnopqrst"), "", S("abcdefghijklmnopqrst"));
+ test1(S("abcdefghijklmnopqrst"), "12345", S("abcdefghijklmnopqrst12345"));
+ test1(S("abcdefghijklmnopqrst"), "1234567890", S("abcdefghijklmnopqrst1234567890"));
+ test1(S("abcdefghijklmnopqrst"), "12345678901234567890", S("abcdefghijklmnopqrst12345678901234567890"));
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.nonmembers/string_op+/string_string.pass.cpp b/test/std/strings/basic.string/string.nonmembers/string_op+/string_string.pass.cpp
new file mode 100644
index 000000000000..318b648d6eb0
--- /dev/null
+++ b/test/std/strings/basic.string/string.nonmembers/string_op+/string_string.pass.cpp
@@ -0,0 +1,222 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+// basic_string<charT,traits,Allocator>
+// operator+(const basic_string<charT,traits,Allocator>& lhs,
+// const basic_string<charT,traits,Allocator>& rhs);
+
+// template<class charT, class traits, class Allocator>
+// basic_string<charT,traits,Allocator>&&
+// operator+(const basic_string<charT,traits,Allocator>&& lhs,
+// const basic_string<charT,traits,Allocator>& rhs);
+
+// template<class charT, class traits, class Allocator>
+// basic_string<charT,traits,Allocator>&&
+// operator+(const basic_string<charT,traits,Allocator>& lhs,
+// const basic_string<charT,traits,Allocator>&& rhs);
+
+// template<class charT, class traits, class Allocator>
+// basic_string<charT,traits,Allocator>&&
+// operator+(const basic_string<charT,traits,Allocator>&& lhs,
+// const basic_string<charT,traits,Allocator>&& rhs);
+
+#include <string>
+#include <utility>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test0(const S& lhs, const S& rhs, const S& x)
+{
+ assert(lhs + rhs == x);
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class S>
+void
+test1(S&& lhs, const S& rhs, const S& x)
+{
+ assert(move(lhs) + rhs == x);
+}
+
+template <class S>
+void
+test2(const S& lhs, S&& rhs, const S& x)
+{
+ assert(lhs + move(rhs) == x);
+}
+
+template <class S>
+void
+test3(S&& lhs, S&& rhs, const S& x)
+{
+ assert(move(lhs) + move(rhs) == x);
+}
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+ {
+ typedef std::string S;
+ test0(S(""), S(""), S(""));
+ test0(S(""), S("12345"), S("12345"));
+ test0(S(""), S("1234567890"), S("1234567890"));
+ test0(S(""), S("12345678901234567890"), S("12345678901234567890"));
+ test0(S("abcde"), S(""), S("abcde"));
+ test0(S("abcde"), S("12345"), S("abcde12345"));
+ test0(S("abcde"), S("1234567890"), S("abcde1234567890"));
+ test0(S("abcde"), S("12345678901234567890"), S("abcde12345678901234567890"));
+ test0(S("abcdefghij"), S(""), S("abcdefghij"));
+ test0(S("abcdefghij"), S("12345"), S("abcdefghij12345"));
+ test0(S("abcdefghij"), S("1234567890"), S("abcdefghij1234567890"));
+ test0(S("abcdefghij"), S("12345678901234567890"), S("abcdefghij12345678901234567890"));
+ test0(S("abcdefghijklmnopqrst"), S(""), S("abcdefghijklmnopqrst"));
+ test0(S("abcdefghijklmnopqrst"), S("12345"), S("abcdefghijklmnopqrst12345"));
+ test0(S("abcdefghijklmnopqrst"), S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
+ test0(S("abcdefghijklmnopqrst"), S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+ test1(S(""), S(""), S(""));
+ test1(S(""), S("12345"), S("12345"));
+ test1(S(""), S("1234567890"), S("1234567890"));
+ test1(S(""), S("12345678901234567890"), S("12345678901234567890"));
+ test1(S("abcde"), S(""), S("abcde"));
+ test1(S("abcde"), S("12345"), S("abcde12345"));
+ test1(S("abcde"), S("1234567890"), S("abcde1234567890"));
+ test1(S("abcde"), S("12345678901234567890"), S("abcde12345678901234567890"));
+ test1(S("abcdefghij"), S(""), S("abcdefghij"));
+ test1(S("abcdefghij"), S("12345"), S("abcdefghij12345"));
+ test1(S("abcdefghij"), S("1234567890"), S("abcdefghij1234567890"));
+ test1(S("abcdefghij"), S("12345678901234567890"), S("abcdefghij12345678901234567890"));
+ test1(S("abcdefghijklmnopqrst"), S(""), S("abcdefghijklmnopqrst"));
+ test1(S("abcdefghijklmnopqrst"), S("12345"), S("abcdefghijklmnopqrst12345"));
+ test1(S("abcdefghijklmnopqrst"), S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
+ test1(S("abcdefghijklmnopqrst"), S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
+
+ test2(S(""), S(""), S(""));
+ test2(S(""), S("12345"), S("12345"));
+ test2(S(""), S("1234567890"), S("1234567890"));
+ test2(S(""), S("12345678901234567890"), S("12345678901234567890"));
+ test2(S("abcde"), S(""), S("abcde"));
+ test2(S("abcde"), S("12345"), S("abcde12345"));
+ test2(S("abcde"), S("1234567890"), S("abcde1234567890"));
+ test2(S("abcde"), S("12345678901234567890"), S("abcde12345678901234567890"));
+ test2(S("abcdefghij"), S(""), S("abcdefghij"));
+ test2(S("abcdefghij"), S("12345"), S("abcdefghij12345"));
+ test2(S("abcdefghij"), S("1234567890"), S("abcdefghij1234567890"));
+ test2(S("abcdefghij"), S("12345678901234567890"), S("abcdefghij12345678901234567890"));
+ test2(S("abcdefghijklmnopqrst"), S(""), S("abcdefghijklmnopqrst"));
+ test2(S("abcdefghijklmnopqrst"), S("12345"), S("abcdefghijklmnopqrst12345"));
+ test2(S("abcdefghijklmnopqrst"), S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
+ test2(S("abcdefghijklmnopqrst"), S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
+
+ test3(S(""), S(""), S(""));
+ test3(S(""), S("12345"), S("12345"));
+ test3(S(""), S("1234567890"), S("1234567890"));
+ test3(S(""), S("12345678901234567890"), S("12345678901234567890"));
+ test3(S("abcde"), S(""), S("abcde"));
+ test3(S("abcde"), S("12345"), S("abcde12345"));
+ test3(S("abcde"), S("1234567890"), S("abcde1234567890"));
+ test3(S("abcde"), S("12345678901234567890"), S("abcde12345678901234567890"));
+ test3(S("abcdefghij"), S(""), S("abcdefghij"));
+ test3(S("abcdefghij"), S("12345"), S("abcdefghij12345"));
+ test3(S("abcdefghij"), S("1234567890"), S("abcdefghij1234567890"));
+ test3(S("abcdefghij"), S("12345678901234567890"), S("abcdefghij12345678901234567890"));
+ test3(S("abcdefghijklmnopqrst"), S(""), S("abcdefghijklmnopqrst"));
+ test3(S("abcdefghijklmnopqrst"), S("12345"), S("abcdefghijklmnopqrst12345"));
+ test3(S("abcdefghijklmnopqrst"), S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
+ test3(S("abcdefghijklmnopqrst"), S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test0(S(""), S(""), S(""));
+ test0(S(""), S("12345"), S("12345"));
+ test0(S(""), S("1234567890"), S("1234567890"));
+ test0(S(""), S("12345678901234567890"), S("12345678901234567890"));
+ test0(S("abcde"), S(""), S("abcde"));
+ test0(S("abcde"), S("12345"), S("abcde12345"));
+ test0(S("abcde"), S("1234567890"), S("abcde1234567890"));
+ test0(S("abcde"), S("12345678901234567890"), S("abcde12345678901234567890"));
+ test0(S("abcdefghij"), S(""), S("abcdefghij"));
+ test0(S("abcdefghij"), S("12345"), S("abcdefghij12345"));
+ test0(S("abcdefghij"), S("1234567890"), S("abcdefghij1234567890"));
+ test0(S("abcdefghij"), S("12345678901234567890"), S("abcdefghij12345678901234567890"));
+ test0(S("abcdefghijklmnopqrst"), S(""), S("abcdefghijklmnopqrst"));
+ test0(S("abcdefghijklmnopqrst"), S("12345"), S("abcdefghijklmnopqrst12345"));
+ test0(S("abcdefghijklmnopqrst"), S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
+ test0(S("abcdefghijklmnopqrst"), S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+ test1(S(""), S(""), S(""));
+ test1(S(""), S("12345"), S("12345"));
+ test1(S(""), S("1234567890"), S("1234567890"));
+ test1(S(""), S("12345678901234567890"), S("12345678901234567890"));
+ test1(S("abcde"), S(""), S("abcde"));
+ test1(S("abcde"), S("12345"), S("abcde12345"));
+ test1(S("abcde"), S("1234567890"), S("abcde1234567890"));
+ test1(S("abcde"), S("12345678901234567890"), S("abcde12345678901234567890"));
+ test1(S("abcdefghij"), S(""), S("abcdefghij"));
+ test1(S("abcdefghij"), S("12345"), S("abcdefghij12345"));
+ test1(S("abcdefghij"), S("1234567890"), S("abcdefghij1234567890"));
+ test1(S("abcdefghij"), S("12345678901234567890"), S("abcdefghij12345678901234567890"));
+ test1(S("abcdefghijklmnopqrst"), S(""), S("abcdefghijklmnopqrst"));
+ test1(S("abcdefghijklmnopqrst"), S("12345"), S("abcdefghijklmnopqrst12345"));
+ test1(S("abcdefghijklmnopqrst"), S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
+ test1(S("abcdefghijklmnopqrst"), S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
+
+ test2(S(""), S(""), S(""));
+ test2(S(""), S("12345"), S("12345"));
+ test2(S(""), S("1234567890"), S("1234567890"));
+ test2(S(""), S("12345678901234567890"), S("12345678901234567890"));
+ test2(S("abcde"), S(""), S("abcde"));
+ test2(S("abcde"), S("12345"), S("abcde12345"));
+ test2(S("abcde"), S("1234567890"), S("abcde1234567890"));
+ test2(S("abcde"), S("12345678901234567890"), S("abcde12345678901234567890"));
+ test2(S("abcdefghij"), S(""), S("abcdefghij"));
+ test2(S("abcdefghij"), S("12345"), S("abcdefghij12345"));
+ test2(S("abcdefghij"), S("1234567890"), S("abcdefghij1234567890"));
+ test2(S("abcdefghij"), S("12345678901234567890"), S("abcdefghij12345678901234567890"));
+ test2(S("abcdefghijklmnopqrst"), S(""), S("abcdefghijklmnopqrst"));
+ test2(S("abcdefghijklmnopqrst"), S("12345"), S("abcdefghijklmnopqrst12345"));
+ test2(S("abcdefghijklmnopqrst"), S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
+ test2(S("abcdefghijklmnopqrst"), S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
+
+ test3(S(""), S(""), S(""));
+ test3(S(""), S("12345"), S("12345"));
+ test3(S(""), S("1234567890"), S("1234567890"));
+ test3(S(""), S("12345678901234567890"), S("12345678901234567890"));
+ test3(S("abcde"), S(""), S("abcde"));
+ test3(S("abcde"), S("12345"), S("abcde12345"));
+ test3(S("abcde"), S("1234567890"), S("abcde1234567890"));
+ test3(S("abcde"), S("12345678901234567890"), S("abcde12345678901234567890"));
+ test3(S("abcdefghij"), S(""), S("abcdefghij"));
+ test3(S("abcdefghij"), S("12345"), S("abcdefghij12345"));
+ test3(S("abcdefghij"), S("1234567890"), S("abcdefghij1234567890"));
+ test3(S("abcdefghij"), S("12345678901234567890"), S("abcdefghij12345678901234567890"));
+ test3(S("abcdefghijklmnopqrst"), S(""), S("abcdefghijklmnopqrst"));
+ test3(S("abcdefghijklmnopqrst"), S("12345"), S("abcdefghijklmnopqrst12345"));
+ test3(S("abcdefghijklmnopqrst"), S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
+ test3(S("abcdefghijklmnopqrst"), S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.nonmembers/string_operator==/pointer_string.pass.cpp b/test/std/strings/basic.string/string.nonmembers/string_operator==/pointer_string.pass.cpp
new file mode 100644
index 000000000000..19a5bdd977e4
--- /dev/null
+++ b/test/std/strings/basic.string/string.nonmembers/string_operator==/pointer_string.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+// bool operator==(const charT* lhs, const basic_string<charT,traits,Allocator>& rhs);
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const typename S::value_type* lhs, const S& rhs, bool x)
+{
+ assert((lhs == rhs) == x);
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test("", S(""), true);
+ test("", S("abcde"), false);
+ test("", S("abcdefghij"), false);
+ test("", S("abcdefghijklmnopqrst"), false);
+ test("abcde", S(""), false);
+ test("abcde", S("abcde"), true);
+ test("abcde", S("abcdefghij"), false);
+ test("abcde", S("abcdefghijklmnopqrst"), false);
+ test("abcdefghij", S(""), false);
+ test("abcdefghij", S("abcde"), false);
+ test("abcdefghij", S("abcdefghij"), true);
+ test("abcdefghij", S("abcdefghijklmnopqrst"), false);
+ test("abcdefghijklmnopqrst", S(""), false);
+ test("abcdefghijklmnopqrst", S("abcde"), false);
+ test("abcdefghijklmnopqrst", S("abcdefghij"), false);
+ test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), true);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test("", S(""), true);
+ test("", S("abcde"), false);
+ test("", S("abcdefghij"), false);
+ test("", S("abcdefghijklmnopqrst"), false);
+ test("abcde", S(""), false);
+ test("abcde", S("abcde"), true);
+ test("abcde", S("abcdefghij"), false);
+ test("abcde", S("abcdefghijklmnopqrst"), false);
+ test("abcdefghij", S(""), false);
+ test("abcdefghij", S("abcde"), false);
+ test("abcdefghij", S("abcdefghij"), true);
+ test("abcdefghij", S("abcdefghijklmnopqrst"), false);
+ test("abcdefghijklmnopqrst", S(""), false);
+ test("abcdefghijklmnopqrst", S("abcde"), false);
+ test("abcdefghijklmnopqrst", S("abcdefghij"), false);
+ test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), true);
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.nonmembers/string_operator==/string_pointer.pass.cpp b/test/std/strings/basic.string/string.nonmembers/string_operator==/string_pointer.pass.cpp
new file mode 100644
index 000000000000..22006bb1be68
--- /dev/null
+++ b/test/std/strings/basic.string/string.nonmembers/string_operator==/string_pointer.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+// bool operator==(const basic_string<charT,traits,Allocator>& lhs, const charT* rhs);
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& lhs, const typename S::value_type* rhs, bool x)
+{
+ assert((lhs == rhs) == x);
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test(S(""), "", true);
+ test(S(""), "abcde", false);
+ test(S(""), "abcdefghij", false);
+ test(S(""), "abcdefghijklmnopqrst", false);
+ test(S("abcde"), "", false);
+ test(S("abcde"), "abcde", true);
+ test(S("abcde"), "abcdefghij", false);
+ test(S("abcde"), "abcdefghijklmnopqrst", false);
+ test(S("abcdefghij"), "", false);
+ test(S("abcdefghij"), "abcde", false);
+ test(S("abcdefghij"), "abcdefghij", true);
+ test(S("abcdefghij"), "abcdefghijklmnopqrst", false);
+ test(S("abcdefghijklmnopqrst"), "", false);
+ test(S("abcdefghijklmnopqrst"), "abcde", false);
+ test(S("abcdefghijklmnopqrst"), "abcdefghij", false);
+ test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", true);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S(""), "", true);
+ test(S(""), "abcde", false);
+ test(S(""), "abcdefghij", false);
+ test(S(""), "abcdefghijklmnopqrst", false);
+ test(S("abcde"), "", false);
+ test(S("abcde"), "abcde", true);
+ test(S("abcde"), "abcdefghij", false);
+ test(S("abcde"), "abcdefghijklmnopqrst", false);
+ test(S("abcdefghij"), "", false);
+ test(S("abcdefghij"), "abcde", false);
+ test(S("abcdefghij"), "abcdefghij", true);
+ test(S("abcdefghij"), "abcdefghijklmnopqrst", false);
+ test(S("abcdefghijklmnopqrst"), "", false);
+ test(S("abcdefghijklmnopqrst"), "abcde", false);
+ test(S("abcdefghijklmnopqrst"), "abcdefghij", false);
+ test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", true);
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.nonmembers/string_operator==/string_string.pass.cpp b/test/std/strings/basic.string/string.nonmembers/string_operator==/string_string.pass.cpp
new file mode 100644
index 000000000000..0bff70a977a6
--- /dev/null
+++ b/test/std/strings/basic.string/string.nonmembers/string_operator==/string_string.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+// bool operator==(const basic_string<charT,traits,Allocator>& lhs,
+// const basic_string<charT,traits,Allocator>& rhs);
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& lhs, const S& rhs, bool x)
+{
+ assert((lhs == rhs) == x);
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test(S(""), S(""), true);
+ test(S(""), S("abcde"), false);
+ test(S(""), S("abcdefghij"), false);
+ test(S(""), S("abcdefghijklmnopqrst"), false);
+ test(S("abcde"), S(""), false);
+ test(S("abcde"), S("abcde"), true);
+ test(S("abcde"), S("abcdefghij"), false);
+ test(S("abcde"), S("abcdefghijklmnopqrst"), false);
+ test(S("abcdefghij"), S(""), false);
+ test(S("abcdefghij"), S("abcde"), false);
+ test(S("abcdefghij"), S("abcdefghij"), true);
+ test(S("abcdefghij"), S("abcdefghijklmnopqrst"), false);
+ test(S("abcdefghijklmnopqrst"), S(""), false);
+ test(S("abcdefghijklmnopqrst"), S("abcde"), false);
+ test(S("abcdefghijklmnopqrst"), S("abcdefghij"), false);
+ test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), true);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S(""), S(""), true);
+ test(S(""), S("abcde"), false);
+ test(S(""), S("abcdefghij"), false);
+ test(S(""), S("abcdefghijklmnopqrst"), false);
+ test(S("abcde"), S(""), false);
+ test(S("abcde"), S("abcde"), true);
+ test(S("abcde"), S("abcdefghij"), false);
+ test(S("abcde"), S("abcdefghijklmnopqrst"), false);
+ test(S("abcdefghij"), S(""), false);
+ test(S("abcdefghij"), S("abcde"), false);
+ test(S("abcdefghij"), S("abcdefghij"), true);
+ test(S("abcdefghij"), S("abcdefghijklmnopqrst"), false);
+ test(S("abcdefghijklmnopqrst"), S(""), false);
+ test(S("abcdefghijklmnopqrst"), S("abcde"), false);
+ test(S("abcdefghijklmnopqrst"), S("abcdefghij"), false);
+ test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), true);
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.nonmembers/string_opgt/pointer_string.pass.cpp b/test/std/strings/basic.string/string.nonmembers/string_opgt/pointer_string.pass.cpp
new file mode 100644
index 000000000000..f9fa204b9eea
--- /dev/null
+++ b/test/std/strings/basic.string/string.nonmembers/string_opgt/pointer_string.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+// bool operator>(const charT* lhs, const basic_string<charT,traits,Allocator>& rhs);
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const typename S::value_type* lhs, const S& rhs, bool x)
+{
+ assert((lhs > rhs) == x);
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test("", S(""), false);
+ test("", S("abcde"), false);
+ test("", S("abcdefghij"), false);
+ test("", S("abcdefghijklmnopqrst"), false);
+ test("abcde", S(""), true);
+ test("abcde", S("abcde"), false);
+ test("abcde", S("abcdefghij"), false);
+ test("abcde", S("abcdefghijklmnopqrst"), false);
+ test("abcdefghij", S(""), true);
+ test("abcdefghij", S("abcde"), true);
+ test("abcdefghij", S("abcdefghij"), false);
+ test("abcdefghij", S("abcdefghijklmnopqrst"), false);
+ test("abcdefghijklmnopqrst", S(""), true);
+ test("abcdefghijklmnopqrst", S("abcde"), true);
+ test("abcdefghijklmnopqrst", S("abcdefghij"), true);
+ test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test("", S(""), false);
+ test("", S("abcde"), false);
+ test("", S("abcdefghij"), false);
+ test("", S("abcdefghijklmnopqrst"), false);
+ test("abcde", S(""), true);
+ test("abcde", S("abcde"), false);
+ test("abcde", S("abcdefghij"), false);
+ test("abcde", S("abcdefghijklmnopqrst"), false);
+ test("abcdefghij", S(""), true);
+ test("abcdefghij", S("abcde"), true);
+ test("abcdefghij", S("abcdefghij"), false);
+ test("abcdefghij", S("abcdefghijklmnopqrst"), false);
+ test("abcdefghijklmnopqrst", S(""), true);
+ test("abcdefghijklmnopqrst", S("abcde"), true);
+ test("abcdefghijklmnopqrst", S("abcdefghij"), true);
+ test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), false);
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.nonmembers/string_opgt/string_pointer.pass.cpp b/test/std/strings/basic.string/string.nonmembers/string_opgt/string_pointer.pass.cpp
new file mode 100644
index 000000000000..daa6f40ae3c0
--- /dev/null
+++ b/test/std/strings/basic.string/string.nonmembers/string_opgt/string_pointer.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+// bool operator>(const basic_string<charT,traits,Allocator>& lhs, const charT* rhs);
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& lhs, const typename S::value_type* rhs, bool x)
+{
+ assert((lhs > rhs) == x);
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test(S(""), "", false);
+ test(S(""), "abcde", false);
+ test(S(""), "abcdefghij", false);
+ test(S(""), "abcdefghijklmnopqrst", false);
+ test(S("abcde"), "", true);
+ test(S("abcde"), "abcde", false);
+ test(S("abcde"), "abcdefghij", false);
+ test(S("abcde"), "abcdefghijklmnopqrst", false);
+ test(S("abcdefghij"), "", true);
+ test(S("abcdefghij"), "abcde", true);
+ test(S("abcdefghij"), "abcdefghij", false);
+ test(S("abcdefghij"), "abcdefghijklmnopqrst", false);
+ test(S("abcdefghijklmnopqrst"), "", true);
+ test(S("abcdefghijklmnopqrst"), "abcde", true);
+ test(S("abcdefghijklmnopqrst"), "abcdefghij", true);
+ test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S(""), "", false);
+ test(S(""), "abcde", false);
+ test(S(""), "abcdefghij", false);
+ test(S(""), "abcdefghijklmnopqrst", false);
+ test(S("abcde"), "", true);
+ test(S("abcde"), "abcde", false);
+ test(S("abcde"), "abcdefghij", false);
+ test(S("abcde"), "abcdefghijklmnopqrst", false);
+ test(S("abcdefghij"), "", true);
+ test(S("abcdefghij"), "abcde", true);
+ test(S("abcdefghij"), "abcdefghij", false);
+ test(S("abcdefghij"), "abcdefghijklmnopqrst", false);
+ test(S("abcdefghijklmnopqrst"), "", true);
+ test(S("abcdefghijklmnopqrst"), "abcde", true);
+ test(S("abcdefghijklmnopqrst"), "abcdefghij", true);
+ test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", false);
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.nonmembers/string_opgt/string_string.pass.cpp b/test/std/strings/basic.string/string.nonmembers/string_opgt/string_string.pass.cpp
new file mode 100644
index 000000000000..95073bf7644c
--- /dev/null
+++ b/test/std/strings/basic.string/string.nonmembers/string_opgt/string_string.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+// bool operator>(const basic_string<charT,traits,Allocator>& lhs,
+// const basic_string<charT,traits,Allocator>& rhs);
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& lhs, const S& rhs, bool x)
+{
+ assert((lhs > rhs) == x);
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test(S(""), S(""), false);
+ test(S(""), S("abcde"), false);
+ test(S(""), S("abcdefghij"), false);
+ test(S(""), S("abcdefghijklmnopqrst"), false);
+ test(S("abcde"), S(""), true);
+ test(S("abcde"), S("abcde"), false);
+ test(S("abcde"), S("abcdefghij"), false);
+ test(S("abcde"), S("abcdefghijklmnopqrst"), false);
+ test(S("abcdefghij"), S(""), true);
+ test(S("abcdefghij"), S("abcde"), true);
+ test(S("abcdefghij"), S("abcdefghij"), false);
+ test(S("abcdefghij"), S("abcdefghijklmnopqrst"), false);
+ test(S("abcdefghijklmnopqrst"), S(""), true);
+ test(S("abcdefghijklmnopqrst"), S("abcde"), true);
+ test(S("abcdefghijklmnopqrst"), S("abcdefghij"), true);
+ test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S(""), S(""), false);
+ test(S(""), S("abcde"), false);
+ test(S(""), S("abcdefghij"), false);
+ test(S(""), S("abcdefghijklmnopqrst"), false);
+ test(S("abcde"), S(""), true);
+ test(S("abcde"), S("abcde"), false);
+ test(S("abcde"), S("abcdefghij"), false);
+ test(S("abcde"), S("abcdefghijklmnopqrst"), false);
+ test(S("abcdefghij"), S(""), true);
+ test(S("abcdefghij"), S("abcde"), true);
+ test(S("abcdefghij"), S("abcdefghij"), false);
+ test(S("abcdefghij"), S("abcdefghijklmnopqrst"), false);
+ test(S("abcdefghijklmnopqrst"), S(""), true);
+ test(S("abcdefghijklmnopqrst"), S("abcde"), true);
+ test(S("abcdefghijklmnopqrst"), S("abcdefghij"), true);
+ test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), false);
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.nonmembers/string_opgt=/pointer_string.pass.cpp b/test/std/strings/basic.string/string.nonmembers/string_opgt=/pointer_string.pass.cpp
new file mode 100644
index 000000000000..eab117a843fa
--- /dev/null
+++ b/test/std/strings/basic.string/string.nonmembers/string_opgt=/pointer_string.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+// bool operator>=(const charT* lhs, const basic_string<charT,traits,Allocator>& rhs);
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const typename S::value_type* lhs, const S& rhs, bool x)
+{
+ assert((lhs >= rhs) == x);
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test("", S(""), true);
+ test("", S("abcde"), false);
+ test("", S("abcdefghij"), false);
+ test("", S("abcdefghijklmnopqrst"), false);
+ test("abcde", S(""), true);
+ test("abcde", S("abcde"), true);
+ test("abcde", S("abcdefghij"), false);
+ test("abcde", S("abcdefghijklmnopqrst"), false);
+ test("abcdefghij", S(""), true);
+ test("abcdefghij", S("abcde"), true);
+ test("abcdefghij", S("abcdefghij"), true);
+ test("abcdefghij", S("abcdefghijklmnopqrst"), false);
+ test("abcdefghijklmnopqrst", S(""), true);
+ test("abcdefghijklmnopqrst", S("abcde"), true);
+ test("abcdefghijklmnopqrst", S("abcdefghij"), true);
+ test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), true);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test("", S(""), true);
+ test("", S("abcde"), false);
+ test("", S("abcdefghij"), false);
+ test("", S("abcdefghijklmnopqrst"), false);
+ test("abcde", S(""), true);
+ test("abcde", S("abcde"), true);
+ test("abcde", S("abcdefghij"), false);
+ test("abcde", S("abcdefghijklmnopqrst"), false);
+ test("abcdefghij", S(""), true);
+ test("abcdefghij", S("abcde"), true);
+ test("abcdefghij", S("abcdefghij"), true);
+ test("abcdefghij", S("abcdefghijklmnopqrst"), false);
+ test("abcdefghijklmnopqrst", S(""), true);
+ test("abcdefghijklmnopqrst", S("abcde"), true);
+ test("abcdefghijklmnopqrst", S("abcdefghij"), true);
+ test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), true);
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.nonmembers/string_opgt=/string_pointer.pass.cpp b/test/std/strings/basic.string/string.nonmembers/string_opgt=/string_pointer.pass.cpp
new file mode 100644
index 000000000000..56b3b35b3d94
--- /dev/null
+++ b/test/std/strings/basic.string/string.nonmembers/string_opgt=/string_pointer.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+// bool operator>=(const basic_string<charT,traits,Allocator>& lhs, const charT* rhs);
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& lhs, const typename S::value_type* rhs, bool x)
+{
+ assert((lhs >= rhs) == x);
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test(S(""), "", true);
+ test(S(""), "abcde", false);
+ test(S(""), "abcdefghij", false);
+ test(S(""), "abcdefghijklmnopqrst", false);
+ test(S("abcde"), "", true);
+ test(S("abcde"), "abcde", true);
+ test(S("abcde"), "abcdefghij", false);
+ test(S("abcde"), "abcdefghijklmnopqrst", false);
+ test(S("abcdefghij"), "", true);
+ test(S("abcdefghij"), "abcde", true);
+ test(S("abcdefghij"), "abcdefghij", true);
+ test(S("abcdefghij"), "abcdefghijklmnopqrst", false);
+ test(S("abcdefghijklmnopqrst"), "", true);
+ test(S("abcdefghijklmnopqrst"), "abcde", true);
+ test(S("abcdefghijklmnopqrst"), "abcdefghij", true);
+ test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", true);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S(""), "", true);
+ test(S(""), "abcde", false);
+ test(S(""), "abcdefghij", false);
+ test(S(""), "abcdefghijklmnopqrst", false);
+ test(S("abcde"), "", true);
+ test(S("abcde"), "abcde", true);
+ test(S("abcde"), "abcdefghij", false);
+ test(S("abcde"), "abcdefghijklmnopqrst", false);
+ test(S("abcdefghij"), "", true);
+ test(S("abcdefghij"), "abcde", true);
+ test(S("abcdefghij"), "abcdefghij", true);
+ test(S("abcdefghij"), "abcdefghijklmnopqrst", false);
+ test(S("abcdefghijklmnopqrst"), "", true);
+ test(S("abcdefghijklmnopqrst"), "abcde", true);
+ test(S("abcdefghijklmnopqrst"), "abcdefghij", true);
+ test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", true);
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.nonmembers/string_opgt=/string_string.pass.cpp b/test/std/strings/basic.string/string.nonmembers/string_opgt=/string_string.pass.cpp
new file mode 100644
index 000000000000..c02b202c49e6
--- /dev/null
+++ b/test/std/strings/basic.string/string.nonmembers/string_opgt=/string_string.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+// bool operator>=(const basic_string<charT,traits,Allocator>& lhs,
+// const basic_string<charT,traits,Allocator>& rhs);
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& lhs, const S& rhs, bool x)
+{
+ assert((lhs >= rhs) == x);
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test(S(""), S(""), true);
+ test(S(""), S("abcde"), false);
+ test(S(""), S("abcdefghij"), false);
+ test(S(""), S("abcdefghijklmnopqrst"), false);
+ test(S("abcde"), S(""), true);
+ test(S("abcde"), S("abcde"), true);
+ test(S("abcde"), S("abcdefghij"), false);
+ test(S("abcde"), S("abcdefghijklmnopqrst"), false);
+ test(S("abcdefghij"), S(""), true);
+ test(S("abcdefghij"), S("abcde"), true);
+ test(S("abcdefghij"), S("abcdefghij"), true);
+ test(S("abcdefghij"), S("abcdefghijklmnopqrst"), false);
+ test(S("abcdefghijklmnopqrst"), S(""), true);
+ test(S("abcdefghijklmnopqrst"), S("abcde"), true);
+ test(S("abcdefghijklmnopqrst"), S("abcdefghij"), true);
+ test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), true);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S(""), S(""), true);
+ test(S(""), S("abcde"), false);
+ test(S(""), S("abcdefghij"), false);
+ test(S(""), S("abcdefghijklmnopqrst"), false);
+ test(S("abcde"), S(""), true);
+ test(S("abcde"), S("abcde"), true);
+ test(S("abcde"), S("abcdefghij"), false);
+ test(S("abcde"), S("abcdefghijklmnopqrst"), false);
+ test(S("abcdefghij"), S(""), true);
+ test(S("abcdefghij"), S("abcde"), true);
+ test(S("abcdefghij"), S("abcdefghij"), true);
+ test(S("abcdefghij"), S("abcdefghijklmnopqrst"), false);
+ test(S("abcdefghijklmnopqrst"), S(""), true);
+ test(S("abcdefghijklmnopqrst"), S("abcde"), true);
+ test(S("abcdefghijklmnopqrst"), S("abcdefghij"), true);
+ test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), true);
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.nonmembers/string_oplt/pointer_string.pass.cpp b/test/std/strings/basic.string/string.nonmembers/string_oplt/pointer_string.pass.cpp
new file mode 100644
index 000000000000..86f6a2db119a
--- /dev/null
+++ b/test/std/strings/basic.string/string.nonmembers/string_oplt/pointer_string.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+// bool operator<(const charT* lhs, const basic_string<charT,traits,Allocator>& rhs);
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const typename S::value_type* lhs, const S& rhs, bool x)
+{
+ assert((lhs < rhs) == x);
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test("", S(""), false);
+ test("", S("abcde"), true);
+ test("", S("abcdefghij"), true);
+ test("", S("abcdefghijklmnopqrst"), true);
+ test("abcde", S(""), false);
+ test("abcde", S("abcde"), false);
+ test("abcde", S("abcdefghij"), true);
+ test("abcde", S("abcdefghijklmnopqrst"), true);
+ test("abcdefghij", S(""), false);
+ test("abcdefghij", S("abcde"), false);
+ test("abcdefghij", S("abcdefghij"), false);
+ test("abcdefghij", S("abcdefghijklmnopqrst"), true);
+ test("abcdefghijklmnopqrst", S(""), false);
+ test("abcdefghijklmnopqrst", S("abcde"), false);
+ test("abcdefghijklmnopqrst", S("abcdefghij"), false);
+ test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test("", S(""), false);
+ test("", S("abcde"), true);
+ test("", S("abcdefghij"), true);
+ test("", S("abcdefghijklmnopqrst"), true);
+ test("abcde", S(""), false);
+ test("abcde", S("abcde"), false);
+ test("abcde", S("abcdefghij"), true);
+ test("abcde", S("abcdefghijklmnopqrst"), true);
+ test("abcdefghij", S(""), false);
+ test("abcdefghij", S("abcde"), false);
+ test("abcdefghij", S("abcdefghij"), false);
+ test("abcdefghij", S("abcdefghijklmnopqrst"), true);
+ test("abcdefghijklmnopqrst", S(""), false);
+ test("abcdefghijklmnopqrst", S("abcde"), false);
+ test("abcdefghijklmnopqrst", S("abcdefghij"), false);
+ test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), false);
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.nonmembers/string_oplt/string_pointer.pass.cpp b/test/std/strings/basic.string/string.nonmembers/string_oplt/string_pointer.pass.cpp
new file mode 100644
index 000000000000..b935da5426fd
--- /dev/null
+++ b/test/std/strings/basic.string/string.nonmembers/string_oplt/string_pointer.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+// bool operator<(const basic_string<charT,traits,Allocator>& lhs, const charT* rhs);
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& lhs, const typename S::value_type* rhs, bool x)
+{
+ assert((lhs < rhs) == x);
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test(S(""), "", false);
+ test(S(""), "abcde", true);
+ test(S(""), "abcdefghij", true);
+ test(S(""), "abcdefghijklmnopqrst", true);
+ test(S("abcde"), "", false);
+ test(S("abcde"), "abcde", false);
+ test(S("abcde"), "abcdefghij", true);
+ test(S("abcde"), "abcdefghijklmnopqrst", true);
+ test(S("abcdefghij"), "", false);
+ test(S("abcdefghij"), "abcde", false);
+ test(S("abcdefghij"), "abcdefghij", false);
+ test(S("abcdefghij"), "abcdefghijklmnopqrst", true);
+ test(S("abcdefghijklmnopqrst"), "", false);
+ test(S("abcdefghijklmnopqrst"), "abcde", false);
+ test(S("abcdefghijklmnopqrst"), "abcdefghij", false);
+ test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S(""), "", false);
+ test(S(""), "abcde", true);
+ test(S(""), "abcdefghij", true);
+ test(S(""), "abcdefghijklmnopqrst", true);
+ test(S("abcde"), "", false);
+ test(S("abcde"), "abcde", false);
+ test(S("abcde"), "abcdefghij", true);
+ test(S("abcde"), "abcdefghijklmnopqrst", true);
+ test(S("abcdefghij"), "", false);
+ test(S("abcdefghij"), "abcde", false);
+ test(S("abcdefghij"), "abcdefghij", false);
+ test(S("abcdefghij"), "abcdefghijklmnopqrst", true);
+ test(S("abcdefghijklmnopqrst"), "", false);
+ test(S("abcdefghijklmnopqrst"), "abcde", false);
+ test(S("abcdefghijklmnopqrst"), "abcdefghij", false);
+ test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", false);
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.nonmembers/string_oplt/string_string.pass.cpp b/test/std/strings/basic.string/string.nonmembers/string_oplt/string_string.pass.cpp
new file mode 100644
index 000000000000..487e2056f2ca
--- /dev/null
+++ b/test/std/strings/basic.string/string.nonmembers/string_oplt/string_string.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+// bool operator<(const basic_string<charT,traits,Allocator>& lhs,
+// const basic_string<charT,traits,Allocator>& rhs);
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& lhs, const S& rhs, bool x)
+{
+ assert((lhs < rhs) == x);
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test(S(""), S(""), false);
+ test(S(""), S("abcde"), true);
+ test(S(""), S("abcdefghij"), true);
+ test(S(""), S("abcdefghijklmnopqrst"), true);
+ test(S("abcde"), S(""), false);
+ test(S("abcde"), S("abcde"), false);
+ test(S("abcde"), S("abcdefghij"), true);
+ test(S("abcde"), S("abcdefghijklmnopqrst"), true);
+ test(S("abcdefghij"), S(""), false);
+ test(S("abcdefghij"), S("abcde"), false);
+ test(S("abcdefghij"), S("abcdefghij"), false);
+ test(S("abcdefghij"), S("abcdefghijklmnopqrst"), true);
+ test(S("abcdefghijklmnopqrst"), S(""), false);
+ test(S("abcdefghijklmnopqrst"), S("abcde"), false);
+ test(S("abcdefghijklmnopqrst"), S("abcdefghij"), false);
+ test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S(""), S(""), false);
+ test(S(""), S("abcde"), true);
+ test(S(""), S("abcdefghij"), true);
+ test(S(""), S("abcdefghijklmnopqrst"), true);
+ test(S("abcde"), S(""), false);
+ test(S("abcde"), S("abcde"), false);
+ test(S("abcde"), S("abcdefghij"), true);
+ test(S("abcde"), S("abcdefghijklmnopqrst"), true);
+ test(S("abcdefghij"), S(""), false);
+ test(S("abcdefghij"), S("abcde"), false);
+ test(S("abcdefghij"), S("abcdefghij"), false);
+ test(S("abcdefghij"), S("abcdefghijklmnopqrst"), true);
+ test(S("abcdefghijklmnopqrst"), S(""), false);
+ test(S("abcdefghijklmnopqrst"), S("abcde"), false);
+ test(S("abcdefghijklmnopqrst"), S("abcdefghij"), false);
+ test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), false);
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.nonmembers/string_oplt=/pointer_string.pass.cpp b/test/std/strings/basic.string/string.nonmembers/string_oplt=/pointer_string.pass.cpp
new file mode 100644
index 000000000000..21959405194d
--- /dev/null
+++ b/test/std/strings/basic.string/string.nonmembers/string_oplt=/pointer_string.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+// bool operator<=(const charT* lhs, const basic_string<charT,traits,Allocator>& rhs);
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const typename S::value_type* lhs, const S& rhs, bool x)
+{
+ assert((lhs <= rhs) == x);
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test("", S(""), true);
+ test("", S("abcde"), true);
+ test("", S("abcdefghij"), true);
+ test("", S("abcdefghijklmnopqrst"), true);
+ test("abcde", S(""), false);
+ test("abcde", S("abcde"), true);
+ test("abcde", S("abcdefghij"), true);
+ test("abcde", S("abcdefghijklmnopqrst"), true);
+ test("abcdefghij", S(""), false);
+ test("abcdefghij", S("abcde"), false);
+ test("abcdefghij", S("abcdefghij"), true);
+ test("abcdefghij", S("abcdefghijklmnopqrst"), true);
+ test("abcdefghijklmnopqrst", S(""), false);
+ test("abcdefghijklmnopqrst", S("abcde"), false);
+ test("abcdefghijklmnopqrst", S("abcdefghij"), false);
+ test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), true);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test("", S(""), true);
+ test("", S("abcde"), true);
+ test("", S("abcdefghij"), true);
+ test("", S("abcdefghijklmnopqrst"), true);
+ test("abcde", S(""), false);
+ test("abcde", S("abcde"), true);
+ test("abcde", S("abcdefghij"), true);
+ test("abcde", S("abcdefghijklmnopqrst"), true);
+ test("abcdefghij", S(""), false);
+ test("abcdefghij", S("abcde"), false);
+ test("abcdefghij", S("abcdefghij"), true);
+ test("abcdefghij", S("abcdefghijklmnopqrst"), true);
+ test("abcdefghijklmnopqrst", S(""), false);
+ test("abcdefghijklmnopqrst", S("abcde"), false);
+ test("abcdefghijklmnopqrst", S("abcdefghij"), false);
+ test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), true);
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.nonmembers/string_oplt=/string_pointer.pass.cpp b/test/std/strings/basic.string/string.nonmembers/string_oplt=/string_pointer.pass.cpp
new file mode 100644
index 000000000000..bb1bce8d4043
--- /dev/null
+++ b/test/std/strings/basic.string/string.nonmembers/string_oplt=/string_pointer.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+// bool operator<=(const basic_string<charT,traits,Allocator>& lhs, const charT* rhs);
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& lhs, const typename S::value_type* rhs, bool x)
+{
+ assert((lhs <= rhs) == x);
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test(S(""), "", true);
+ test(S(""), "abcde", true);
+ test(S(""), "abcdefghij", true);
+ test(S(""), "abcdefghijklmnopqrst", true);
+ test(S("abcde"), "", false);
+ test(S("abcde"), "abcde", true);
+ test(S("abcde"), "abcdefghij", true);
+ test(S("abcde"), "abcdefghijklmnopqrst", true);
+ test(S("abcdefghij"), "", false);
+ test(S("abcdefghij"), "abcde", false);
+ test(S("abcdefghij"), "abcdefghij", true);
+ test(S("abcdefghij"), "abcdefghijklmnopqrst", true);
+ test(S("abcdefghijklmnopqrst"), "", false);
+ test(S("abcdefghijklmnopqrst"), "abcde", false);
+ test(S("abcdefghijklmnopqrst"), "abcdefghij", false);
+ test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", true);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S(""), "", true);
+ test(S(""), "abcde", true);
+ test(S(""), "abcdefghij", true);
+ test(S(""), "abcdefghijklmnopqrst", true);
+ test(S("abcde"), "", false);
+ test(S("abcde"), "abcde", true);
+ test(S("abcde"), "abcdefghij", true);
+ test(S("abcde"), "abcdefghijklmnopqrst", true);
+ test(S("abcdefghij"), "", false);
+ test(S("abcdefghij"), "abcde", false);
+ test(S("abcdefghij"), "abcdefghij", true);
+ test(S("abcdefghij"), "abcdefghijklmnopqrst", true);
+ test(S("abcdefghijklmnopqrst"), "", false);
+ test(S("abcdefghijklmnopqrst"), "abcde", false);
+ test(S("abcdefghijklmnopqrst"), "abcdefghij", false);
+ test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", true);
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.nonmembers/string_oplt=/string_string.pass.cpp b/test/std/strings/basic.string/string.nonmembers/string_oplt=/string_string.pass.cpp
new file mode 100644
index 000000000000..2b975f160d5d
--- /dev/null
+++ b/test/std/strings/basic.string/string.nonmembers/string_oplt=/string_string.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+// bool operator<=(const basic_string<charT,traits,Allocator>& lhs,
+// const basic_string<charT,traits,Allocator>& rhs);
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& lhs, const S& rhs, bool x)
+{
+ assert((lhs <= rhs) == x);
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test(S(""), S(""), true);
+ test(S(""), S("abcde"), true);
+ test(S(""), S("abcdefghij"), true);
+ test(S(""), S("abcdefghijklmnopqrst"), true);
+ test(S("abcde"), S(""), false);
+ test(S("abcde"), S("abcde"), true);
+ test(S("abcde"), S("abcdefghij"), true);
+ test(S("abcde"), S("abcdefghijklmnopqrst"), true);
+ test(S("abcdefghij"), S(""), false);
+ test(S("abcdefghij"), S("abcde"), false);
+ test(S("abcdefghij"), S("abcdefghij"), true);
+ test(S("abcdefghij"), S("abcdefghijklmnopqrst"), true);
+ test(S("abcdefghijklmnopqrst"), S(""), false);
+ test(S("abcdefghijklmnopqrst"), S("abcde"), false);
+ test(S("abcdefghijklmnopqrst"), S("abcdefghij"), false);
+ test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), true);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S(""), S(""), true);
+ test(S(""), S("abcde"), true);
+ test(S(""), S("abcdefghij"), true);
+ test(S(""), S("abcdefghijklmnopqrst"), true);
+ test(S("abcde"), S(""), false);
+ test(S("abcde"), S("abcde"), true);
+ test(S("abcde"), S("abcdefghij"), true);
+ test(S("abcde"), S("abcdefghijklmnopqrst"), true);
+ test(S("abcdefghij"), S(""), false);
+ test(S("abcdefghij"), S("abcde"), false);
+ test(S("abcdefghij"), S("abcdefghij"), true);
+ test(S("abcdefghij"), S("abcdefghijklmnopqrst"), true);
+ test(S("abcdefghijklmnopqrst"), S(""), false);
+ test(S("abcdefghijklmnopqrst"), S("abcde"), false);
+ test(S("abcdefghijklmnopqrst"), S("abcdefghij"), false);
+ test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), true);
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.ops/nothing_to_do.pass.cpp b/test/std/strings/basic.string/string.ops/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/strings/basic.string/string.ops/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/strings/basic.string/string.ops/string.accessors/c_str.pass.cpp b/test/std/strings/basic.string/string.ops/string.accessors/c_str.pass.cpp
new file mode 100644
index 000000000000..3bdb800bf736
--- /dev/null
+++ b/test/std/strings/basic.string/string.ops/string.accessors/c_str.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// const charT* c_str() const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& s)
+{
+ typedef typename S::traits_type T;
+ const typename S::value_type* str = s.c_str();
+ if (s.size() > 0)
+ {
+ assert(T::compare(str, &s[0], s.size()) == 0);
+ assert(T::eq(str[s.size()], typename S::value_type()));
+ }
+ else
+ assert(T::eq(str[0], typename S::value_type()));
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test(S(""));
+ test(S("abcde"));
+ test(S("abcdefghij"));
+ test(S("abcdefghijklmnopqrst"));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S(""));
+ test(S("abcde"));
+ test(S("abcdefghij"));
+ test(S("abcdefghijklmnopqrst"));
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.ops/string.accessors/data.pass.cpp b/test/std/strings/basic.string/string.ops/string.accessors/data.pass.cpp
new file mode 100644
index 000000000000..917248fa6916
--- /dev/null
+++ b/test/std/strings/basic.string/string.ops/string.accessors/data.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// const charT* data() const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& s)
+{
+ typedef typename S::traits_type T;
+ const typename S::value_type* str = s.data();
+ if (s.size() > 0)
+ {
+ assert(T::compare(str, &s[0], s.size()) == 0);
+ assert(T::eq(str[s.size()], typename S::value_type()));
+ }
+ else
+ assert(T::eq(str[0], typename S::value_type()));
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test(S(""));
+ test(S("abcde"));
+ test(S("abcdefghij"));
+ test(S("abcdefghijklmnopqrst"));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S(""));
+ test(S("abcde"));
+ test(S("abcdefghij"));
+ test(S("abcdefghijklmnopqrst"));
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.ops/string.accessors/get_allocator.pass.cpp b/test/std/strings/basic.string/string.ops/string.accessors/get_allocator.pass.cpp
new file mode 100644
index 000000000000..6ba040d2635d
--- /dev/null
+++ b/test/std/strings/basic.string/string.ops/string.accessors/get_allocator.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// allocator_type get_allocator() const;
+
+#include <string>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& s, const typename S::allocator_type& a)
+{
+ assert(s.get_allocator() == a);
+}
+
+int main()
+{
+ {
+ typedef test_allocator<char> A;
+ typedef std::basic_string<char, std::char_traits<char>, A> S;
+ test(S(""), A());
+ test(S("abcde", A(1)), A(1));
+ test(S("abcdefghij", A(2)), A(2));
+ test(S("abcdefghijklmnopqrst", A(3)), A(3));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef min_allocator<char> A;
+ typedef std::basic_string<char, std::char_traits<char>, A> S;
+ test(S(""), A());
+ test(S("abcde", A()), A());
+ test(S("abcdefghij", A()), A());
+ test(S("abcdefghijklmnopqrst", A()), A());
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.ops/string_compare/pointer.pass.cpp b/test/std/strings/basic.string/string.ops/string_compare/pointer.pass.cpp
new file mode 100644
index 000000000000..dda7428992a1
--- /dev/null
+++ b/test/std/strings/basic.string/string.ops/string_compare/pointer.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// int compare(const charT *s) const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int sign(int x)
+{
+ if (x == 0)
+ return 0;
+ if (x < 0)
+ return -1;
+ return 1;
+}
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, int x)
+{
+ assert(sign(s.compare(str)) == sign(x));
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test(S(""), "", 0);
+ test(S(""), "abcde", -5);
+ test(S(""), "abcdefghij", -10);
+ test(S(""), "abcdefghijklmnopqrst", -20);
+ test(S("abcde"), "", 5);
+ test(S("abcde"), "abcde", 0);
+ test(S("abcde"), "abcdefghij", -5);
+ test(S("abcde"), "abcdefghijklmnopqrst", -15);
+ test(S("abcdefghij"), "", 10);
+ test(S("abcdefghij"), "abcde", 5);
+ test(S("abcdefghij"), "abcdefghij", 0);
+ test(S("abcdefghij"), "abcdefghijklmnopqrst", -10);
+ test(S("abcdefghijklmnopqrst"), "", 20);
+ test(S("abcdefghijklmnopqrst"), "abcde", 15);
+ test(S("abcdefghijklmnopqrst"), "abcdefghij", 10);
+ test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S(""), "", 0);
+ test(S(""), "abcde", -5);
+ test(S(""), "abcdefghij", -10);
+ test(S(""), "abcdefghijklmnopqrst", -20);
+ test(S("abcde"), "", 5);
+ test(S("abcde"), "abcde", 0);
+ test(S("abcde"), "abcdefghij", -5);
+ test(S("abcde"), "abcdefghijklmnopqrst", -15);
+ test(S("abcdefghij"), "", 10);
+ test(S("abcdefghij"), "abcde", 5);
+ test(S("abcdefghij"), "abcdefghij", 0);
+ test(S("abcdefghij"), "abcdefghijklmnopqrst", -10);
+ test(S("abcdefghijklmnopqrst"), "", 20);
+ test(S("abcdefghijklmnopqrst"), "abcde", 15);
+ test(S("abcdefghijklmnopqrst"), "abcdefghij", 10);
+ test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", 0);
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.ops/string_compare/size_size_pointer.pass.cpp b/test/std/strings/basic.string/string.ops/string_compare/size_size_pointer.pass.cpp
new file mode 100644
index 000000000000..9ed58a3e9bbc
--- /dev/null
+++ b/test/std/strings/basic.string/string.ops/string_compare/size_size_pointer.pass.cpp
@@ -0,0 +1,372 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// int compare(size_type pos, size_type n1, const charT *s) const;
+
+#include <string>
+#include <stdexcept>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int sign(int x)
+{
+ if (x == 0)
+ return 0;
+ if (x < 0)
+ return -1;
+ return 1;
+}
+
+template <class S>
+void
+test(const S& s, typename S::size_type pos1, typename S::size_type n1,
+ const typename S::value_type* str, int x)
+{
+ try
+ {
+ assert(sign(s.compare(pos1, n1, str)) == sign(x));
+ assert(pos1 <= s.size());
+ }
+ catch (std::out_of_range&)
+ {
+ assert(pos1 > s.size());
+ }
+}
+
+template <class S>
+void test0()
+{
+ test(S(""), 0, 0, "", 0);
+ test(S(""), 0, 0, "abcde", -5);
+ test(S(""), 0, 0, "abcdefghij", -10);
+ test(S(""), 0, 0, "abcdefghijklmnopqrst", -20);
+ test(S(""), 0, 1, "", 0);
+ test(S(""), 0, 1, "abcde", -5);
+ test(S(""), 0, 1, "abcdefghij", -10);
+ test(S(""), 0, 1, "abcdefghijklmnopqrst", -20);
+ test(S(""), 1, 0, "", 0);
+ test(S(""), 1, 0, "abcde", 0);
+ test(S(""), 1, 0, "abcdefghij", 0);
+ test(S(""), 1, 0, "abcdefghijklmnopqrst", 0);
+ test(S("abcde"), 0, 0, "", 0);
+ test(S("abcde"), 0, 0, "abcde", -5);
+ test(S("abcde"), 0, 0, "abcdefghij", -10);
+ test(S("abcde"), 0, 0, "abcdefghijklmnopqrst", -20);
+ test(S("abcde"), 0, 1, "", 1);
+ test(S("abcde"), 0, 1, "abcde", -4);
+ test(S("abcde"), 0, 1, "abcdefghij", -9);
+ test(S("abcde"), 0, 1, "abcdefghijklmnopqrst", -19);
+ test(S("abcde"), 0, 2, "", 2);
+ test(S("abcde"), 0, 2, "abcde", -3);
+ test(S("abcde"), 0, 2, "abcdefghij", -8);
+ test(S("abcde"), 0, 2, "abcdefghijklmnopqrst", -18);
+ test(S("abcde"), 0, 4, "", 4);
+ test(S("abcde"), 0, 4, "abcde", -1);
+ test(S("abcde"), 0, 4, "abcdefghij", -6);
+ test(S("abcde"), 0, 4, "abcdefghijklmnopqrst", -16);
+ test(S("abcde"), 0, 5, "", 5);
+ test(S("abcde"), 0, 5, "abcde", 0);
+ test(S("abcde"), 0, 5, "abcdefghij", -5);
+ test(S("abcde"), 0, 5, "abcdefghijklmnopqrst", -15);
+ test(S("abcde"), 0, 6, "", 5);
+ test(S("abcde"), 0, 6, "abcde", 0);
+ test(S("abcde"), 0, 6, "abcdefghij", -5);
+ test(S("abcde"), 0, 6, "abcdefghijklmnopqrst", -15);
+ test(S("abcde"), 1, 0, "", 0);
+ test(S("abcde"), 1, 0, "abcde", -5);
+ test(S("abcde"), 1, 0, "abcdefghij", -10);
+ test(S("abcde"), 1, 0, "abcdefghijklmnopqrst", -20);
+ test(S("abcde"), 1, 1, "", 1);
+ test(S("abcde"), 1, 1, "abcde", 1);
+ test(S("abcde"), 1, 1, "abcdefghij", 1);
+ test(S("abcde"), 1, 1, "abcdefghijklmnopqrst", 1);
+ test(S("abcde"), 1, 2, "", 2);
+ test(S("abcde"), 1, 2, "abcde", 1);
+ test(S("abcde"), 1, 2, "abcdefghij", 1);
+ test(S("abcde"), 1, 2, "abcdefghijklmnopqrst", 1);
+ test(S("abcde"), 1, 3, "", 3);
+ test(S("abcde"), 1, 3, "abcde", 1);
+ test(S("abcde"), 1, 3, "abcdefghij", 1);
+ test(S("abcde"), 1, 3, "abcdefghijklmnopqrst", 1);
+ test(S("abcde"), 1, 4, "", 4);
+ test(S("abcde"), 1, 4, "abcde", 1);
+ test(S("abcde"), 1, 4, "abcdefghij", 1);
+ test(S("abcde"), 1, 4, "abcdefghijklmnopqrst", 1);
+ test(S("abcde"), 1, 5, "", 4);
+ test(S("abcde"), 1, 5, "abcde", 1);
+ test(S("abcde"), 1, 5, "abcdefghij", 1);
+ test(S("abcde"), 1, 5, "abcdefghijklmnopqrst", 1);
+ test(S("abcde"), 2, 0, "", 0);
+ test(S("abcde"), 2, 0, "abcde", -5);
+ test(S("abcde"), 2, 0, "abcdefghij", -10);
+ test(S("abcde"), 2, 0, "abcdefghijklmnopqrst", -20);
+ test(S("abcde"), 2, 1, "", 1);
+ test(S("abcde"), 2, 1, "abcde", 2);
+ test(S("abcde"), 2, 1, "abcdefghij", 2);
+ test(S("abcde"), 2, 1, "abcdefghijklmnopqrst", 2);
+ test(S("abcde"), 2, 2, "", 2);
+ test(S("abcde"), 2, 2, "abcde", 2);
+ test(S("abcde"), 2, 2, "abcdefghij", 2);
+ test(S("abcde"), 2, 2, "abcdefghijklmnopqrst", 2);
+ test(S("abcde"), 2, 3, "", 3);
+ test(S("abcde"), 2, 3, "abcde", 2);
+ test(S("abcde"), 2, 3, "abcdefghij", 2);
+ test(S("abcde"), 2, 3, "abcdefghijklmnopqrst", 2);
+ test(S("abcde"), 2, 4, "", 3);
+ test(S("abcde"), 2, 4, "abcde", 2);
+ test(S("abcde"), 2, 4, "abcdefghij", 2);
+ test(S("abcde"), 2, 4, "abcdefghijklmnopqrst", 2);
+ test(S("abcde"), 4, 0, "", 0);
+ test(S("abcde"), 4, 0, "abcde", -5);
+ test(S("abcde"), 4, 0, "abcdefghij", -10);
+ test(S("abcde"), 4, 0, "abcdefghijklmnopqrst", -20);
+ test(S("abcde"), 4, 1, "", 1);
+ test(S("abcde"), 4, 1, "abcde", 4);
+ test(S("abcde"), 4, 1, "abcdefghij", 4);
+ test(S("abcde"), 4, 1, "abcdefghijklmnopqrst", 4);
+ test(S("abcde"), 4, 2, "", 1);
+ test(S("abcde"), 4, 2, "abcde", 4);
+ test(S("abcde"), 4, 2, "abcdefghij", 4);
+ test(S("abcde"), 4, 2, "abcdefghijklmnopqrst", 4);
+ test(S("abcde"), 5, 0, "", 0);
+ test(S("abcde"), 5, 0, "abcde", -5);
+ test(S("abcde"), 5, 0, "abcdefghij", -10);
+ test(S("abcde"), 5, 0, "abcdefghijklmnopqrst", -20);
+ test(S("abcde"), 5, 1, "", 0);
+ test(S("abcde"), 5, 1, "abcde", -5);
+ test(S("abcde"), 5, 1, "abcdefghij", -10);
+ test(S("abcde"), 5, 1, "abcdefghijklmnopqrst", -20);
+}
+
+template <class S>
+void test1()
+{
+ test(S("abcde"), 6, 0, "", 0);
+ test(S("abcde"), 6, 0, "abcde", 0);
+ test(S("abcde"), 6, 0, "abcdefghij", 0);
+ test(S("abcde"), 6, 0, "abcdefghijklmnopqrst", 0);
+ test(S("abcdefghij"), 0, 0, "", 0);
+ test(S("abcdefghij"), 0, 0, "abcde", -5);
+ test(S("abcdefghij"), 0, 0, "abcdefghij", -10);
+ test(S("abcdefghij"), 0, 0, "abcdefghijklmnopqrst", -20);
+ test(S("abcdefghij"), 0, 1, "", 1);
+ test(S("abcdefghij"), 0, 1, "abcde", -4);
+ test(S("abcdefghij"), 0, 1, "abcdefghij", -9);
+ test(S("abcdefghij"), 0, 1, "abcdefghijklmnopqrst", -19);
+ test(S("abcdefghij"), 0, 5, "", 5);
+ test(S("abcdefghij"), 0, 5, "abcde", 0);
+ test(S("abcdefghij"), 0, 5, "abcdefghij", -5);
+ test(S("abcdefghij"), 0, 5, "abcdefghijklmnopqrst", -15);
+ test(S("abcdefghij"), 0, 9, "", 9);
+ test(S("abcdefghij"), 0, 9, "abcde", 4);
+ test(S("abcdefghij"), 0, 9, "abcdefghij", -1);
+ test(S("abcdefghij"), 0, 9, "abcdefghijklmnopqrst", -11);
+ test(S("abcdefghij"), 0, 10, "", 10);
+ test(S("abcdefghij"), 0, 10, "abcde", 5);
+ test(S("abcdefghij"), 0, 10, "abcdefghij", 0);
+ test(S("abcdefghij"), 0, 10, "abcdefghijklmnopqrst", -10);
+ test(S("abcdefghij"), 0, 11, "", 10);
+ test(S("abcdefghij"), 0, 11, "abcde", 5);
+ test(S("abcdefghij"), 0, 11, "abcdefghij", 0);
+ test(S("abcdefghij"), 0, 11, "abcdefghijklmnopqrst", -10);
+ test(S("abcdefghij"), 1, 0, "", 0);
+ test(S("abcdefghij"), 1, 0, "abcde", -5);
+ test(S("abcdefghij"), 1, 0, "abcdefghij", -10);
+ test(S("abcdefghij"), 1, 0, "abcdefghijklmnopqrst", -20);
+ test(S("abcdefghij"), 1, 1, "", 1);
+ test(S("abcdefghij"), 1, 1, "abcde", 1);
+ test(S("abcdefghij"), 1, 1, "abcdefghij", 1);
+ test(S("abcdefghij"), 1, 1, "abcdefghijklmnopqrst", 1);
+ test(S("abcdefghij"), 1, 4, "", 4);
+ test(S("abcdefghij"), 1, 4, "abcde", 1);
+ test(S("abcdefghij"), 1, 4, "abcdefghij", 1);
+ test(S("abcdefghij"), 1, 4, "abcdefghijklmnopqrst", 1);
+ test(S("abcdefghij"), 1, 8, "", 8);
+ test(S("abcdefghij"), 1, 8, "abcde", 1);
+ test(S("abcdefghij"), 1, 8, "abcdefghij", 1);
+ test(S("abcdefghij"), 1, 8, "abcdefghijklmnopqrst", 1);
+ test(S("abcdefghij"), 1, 9, "", 9);
+ test(S("abcdefghij"), 1, 9, "abcde", 1);
+ test(S("abcdefghij"), 1, 9, "abcdefghij", 1);
+ test(S("abcdefghij"), 1, 9, "abcdefghijklmnopqrst", 1);
+ test(S("abcdefghij"), 1, 10, "", 9);
+ test(S("abcdefghij"), 1, 10, "abcde", 1);
+ test(S("abcdefghij"), 1, 10, "abcdefghij", 1);
+ test(S("abcdefghij"), 1, 10, "abcdefghijklmnopqrst", 1);
+ test(S("abcdefghij"), 5, 0, "", 0);
+ test(S("abcdefghij"), 5, 0, "abcde", -5);
+ test(S("abcdefghij"), 5, 0, "abcdefghij", -10);
+ test(S("abcdefghij"), 5, 0, "abcdefghijklmnopqrst", -20);
+ test(S("abcdefghij"), 5, 1, "", 1);
+ test(S("abcdefghij"), 5, 1, "abcde", 5);
+ test(S("abcdefghij"), 5, 1, "abcdefghij", 5);
+ test(S("abcdefghij"), 5, 1, "abcdefghijklmnopqrst", 5);
+ test(S("abcdefghij"), 5, 2, "", 2);
+ test(S("abcdefghij"), 5, 2, "abcde", 5);
+ test(S("abcdefghij"), 5, 2, "abcdefghij", 5);
+ test(S("abcdefghij"), 5, 2, "abcdefghijklmnopqrst", 5);
+ test(S("abcdefghij"), 5, 4, "", 4);
+ test(S("abcdefghij"), 5, 4, "abcde", 5);
+ test(S("abcdefghij"), 5, 4, "abcdefghij", 5);
+ test(S("abcdefghij"), 5, 4, "abcdefghijklmnopqrst", 5);
+ test(S("abcdefghij"), 5, 5, "", 5);
+ test(S("abcdefghij"), 5, 5, "abcde", 5);
+ test(S("abcdefghij"), 5, 5, "abcdefghij", 5);
+ test(S("abcdefghij"), 5, 5, "abcdefghijklmnopqrst", 5);
+ test(S("abcdefghij"), 5, 6, "", 5);
+ test(S("abcdefghij"), 5, 6, "abcde", 5);
+ test(S("abcdefghij"), 5, 6, "abcdefghij", 5);
+ test(S("abcdefghij"), 5, 6, "abcdefghijklmnopqrst", 5);
+ test(S("abcdefghij"), 9, 0, "", 0);
+ test(S("abcdefghij"), 9, 0, "abcde", -5);
+ test(S("abcdefghij"), 9, 0, "abcdefghij", -10);
+ test(S("abcdefghij"), 9, 0, "abcdefghijklmnopqrst", -20);
+ test(S("abcdefghij"), 9, 1, "", 1);
+ test(S("abcdefghij"), 9, 1, "abcde", 9);
+ test(S("abcdefghij"), 9, 1, "abcdefghij", 9);
+ test(S("abcdefghij"), 9, 1, "abcdefghijklmnopqrst", 9);
+ test(S("abcdefghij"), 9, 2, "", 1);
+ test(S("abcdefghij"), 9, 2, "abcde", 9);
+ test(S("abcdefghij"), 9, 2, "abcdefghij", 9);
+ test(S("abcdefghij"), 9, 2, "abcdefghijklmnopqrst", 9);
+ test(S("abcdefghij"), 10, 0, "", 0);
+ test(S("abcdefghij"), 10, 0, "abcde", -5);
+ test(S("abcdefghij"), 10, 0, "abcdefghij", -10);
+ test(S("abcdefghij"), 10, 0, "abcdefghijklmnopqrst", -20);
+ test(S("abcdefghij"), 10, 1, "", 0);
+ test(S("abcdefghij"), 10, 1, "abcde", -5);
+ test(S("abcdefghij"), 10, 1, "abcdefghij", -10);
+ test(S("abcdefghij"), 10, 1, "abcdefghijklmnopqrst", -20);
+ test(S("abcdefghij"), 11, 0, "", 0);
+ test(S("abcdefghij"), 11, 0, "abcde", 0);
+ test(S("abcdefghij"), 11, 0, "abcdefghij", 0);
+ test(S("abcdefghij"), 11, 0, "abcdefghijklmnopqrst", 0);
+}
+
+template <class S>
+void test2()
+{
+ test(S("abcdefghijklmnopqrst"), 0, 0, "", 0);
+ test(S("abcdefghijklmnopqrst"), 0, 0, "abcde", -5);
+ test(S("abcdefghijklmnopqrst"), 0, 0, "abcdefghij", -10);
+ test(S("abcdefghijklmnopqrst"), 0, 0, "abcdefghijklmnopqrst", -20);
+ test(S("abcdefghijklmnopqrst"), 0, 1, "", 1);
+ test(S("abcdefghijklmnopqrst"), 0, 1, "abcde", -4);
+ test(S("abcdefghijklmnopqrst"), 0, 1, "abcdefghij", -9);
+ test(S("abcdefghijklmnopqrst"), 0, 1, "abcdefghijklmnopqrst", -19);
+ test(S("abcdefghijklmnopqrst"), 0, 10, "", 10);
+ test(S("abcdefghijklmnopqrst"), 0, 10, "abcde", 5);
+ test(S("abcdefghijklmnopqrst"), 0, 10, "abcdefghij", 0);
+ test(S("abcdefghijklmnopqrst"), 0, 10, "abcdefghijklmnopqrst", -10);
+ test(S("abcdefghijklmnopqrst"), 0, 19, "", 19);
+ test(S("abcdefghijklmnopqrst"), 0, 19, "abcde", 14);
+ test(S("abcdefghijklmnopqrst"), 0, 19, "abcdefghij", 9);
+ test(S("abcdefghijklmnopqrst"), 0, 19, "abcdefghijklmnopqrst", -1);
+ test(S("abcdefghijklmnopqrst"), 0, 20, "", 20);
+ test(S("abcdefghijklmnopqrst"), 0, 20, "abcde", 15);
+ test(S("abcdefghijklmnopqrst"), 0, 20, "abcdefghij", 10);
+ test(S("abcdefghijklmnopqrst"), 0, 20, "abcdefghijklmnopqrst", 0);
+ test(S("abcdefghijklmnopqrst"), 0, 21, "", 20);
+ test(S("abcdefghijklmnopqrst"), 0, 21, "abcde", 15);
+ test(S("abcdefghijklmnopqrst"), 0, 21, "abcdefghij", 10);
+ test(S("abcdefghijklmnopqrst"), 0, 21, "abcdefghijklmnopqrst", 0);
+ test(S("abcdefghijklmnopqrst"), 1, 0, "", 0);
+ test(S("abcdefghijklmnopqrst"), 1, 0, "abcde", -5);
+ test(S("abcdefghijklmnopqrst"), 1, 0, "abcdefghij", -10);
+ test(S("abcdefghijklmnopqrst"), 1, 0, "abcdefghijklmnopqrst", -20);
+ test(S("abcdefghijklmnopqrst"), 1, 1, "", 1);
+ test(S("abcdefghijklmnopqrst"), 1, 1, "abcde", 1);
+ test(S("abcdefghijklmnopqrst"), 1, 1, "abcdefghij", 1);
+ test(S("abcdefghijklmnopqrst"), 1, 1, "abcdefghijklmnopqrst", 1);
+ test(S("abcdefghijklmnopqrst"), 1, 9, "", 9);
+ test(S("abcdefghijklmnopqrst"), 1, 9, "abcde", 1);
+ test(S("abcdefghijklmnopqrst"), 1, 9, "abcdefghij", 1);
+ test(S("abcdefghijklmnopqrst"), 1, 9, "abcdefghijklmnopqrst", 1);
+ test(S("abcdefghijklmnopqrst"), 1, 18, "", 18);
+ test(S("abcdefghijklmnopqrst"), 1, 18, "abcde", 1);
+ test(S("abcdefghijklmnopqrst"), 1, 18, "abcdefghij", 1);
+ test(S("abcdefghijklmnopqrst"), 1, 18, "abcdefghijklmnopqrst", 1);
+ test(S("abcdefghijklmnopqrst"), 1, 19, "", 19);
+ test(S("abcdefghijklmnopqrst"), 1, 19, "abcde", 1);
+ test(S("abcdefghijklmnopqrst"), 1, 19, "abcdefghij", 1);
+ test(S("abcdefghijklmnopqrst"), 1, 19, "abcdefghijklmnopqrst", 1);
+ test(S("abcdefghijklmnopqrst"), 1, 20, "", 19);
+ test(S("abcdefghijklmnopqrst"), 1, 20, "abcde", 1);
+ test(S("abcdefghijklmnopqrst"), 1, 20, "abcdefghij", 1);
+ test(S("abcdefghijklmnopqrst"), 1, 20, "abcdefghijklmnopqrst", 1);
+ test(S("abcdefghijklmnopqrst"), 10, 0, "", 0);
+ test(S("abcdefghijklmnopqrst"), 10, 0, "abcde", -5);
+ test(S("abcdefghijklmnopqrst"), 10, 0, "abcdefghij", -10);
+ test(S("abcdefghijklmnopqrst"), 10, 0, "abcdefghijklmnopqrst", -20);
+ test(S("abcdefghijklmnopqrst"), 10, 1, "", 1);
+ test(S("abcdefghijklmnopqrst"), 10, 1, "abcde", 10);
+ test(S("abcdefghijklmnopqrst"), 10, 1, "abcdefghij", 10);
+ test(S("abcdefghijklmnopqrst"), 10, 1, "abcdefghijklmnopqrst", 10);
+ test(S("abcdefghijklmnopqrst"), 10, 5, "", 5);
+ test(S("abcdefghijklmnopqrst"), 10, 5, "abcde", 10);
+ test(S("abcdefghijklmnopqrst"), 10, 5, "abcdefghij", 10);
+ test(S("abcdefghijklmnopqrst"), 10, 5, "abcdefghijklmnopqrst", 10);
+ test(S("abcdefghijklmnopqrst"), 10, 9, "", 9);
+ test(S("abcdefghijklmnopqrst"), 10, 9, "abcde", 10);
+ test(S("abcdefghijklmnopqrst"), 10, 9, "abcdefghij", 10);
+ test(S("abcdefghijklmnopqrst"), 10, 9, "abcdefghijklmnopqrst", 10);
+ test(S("abcdefghijklmnopqrst"), 10, 10, "", 10);
+ test(S("abcdefghijklmnopqrst"), 10, 10, "abcde", 10);
+ test(S("abcdefghijklmnopqrst"), 10, 10, "abcdefghij", 10);
+ test(S("abcdefghijklmnopqrst"), 10, 10, "abcdefghijklmnopqrst", 10);
+ test(S("abcdefghijklmnopqrst"), 10, 11, "", 10);
+ test(S("abcdefghijklmnopqrst"), 10, 11, "abcde", 10);
+ test(S("abcdefghijklmnopqrst"), 10, 11, "abcdefghij", 10);
+ test(S("abcdefghijklmnopqrst"), 10, 11, "abcdefghijklmnopqrst", 10);
+ test(S("abcdefghijklmnopqrst"), 19, 0, "", 0);
+ test(S("abcdefghijklmnopqrst"), 19, 0, "abcde", -5);
+ test(S("abcdefghijklmnopqrst"), 19, 0, "abcdefghij", -10);
+ test(S("abcdefghijklmnopqrst"), 19, 0, "abcdefghijklmnopqrst", -20);
+ test(S("abcdefghijklmnopqrst"), 19, 1, "", 1);
+ test(S("abcdefghijklmnopqrst"), 19, 1, "abcde", 19);
+ test(S("abcdefghijklmnopqrst"), 19, 1, "abcdefghij", 19);
+ test(S("abcdefghijklmnopqrst"), 19, 1, "abcdefghijklmnopqrst", 19);
+ test(S("abcdefghijklmnopqrst"), 19, 2, "", 1);
+ test(S("abcdefghijklmnopqrst"), 19, 2, "abcde", 19);
+ test(S("abcdefghijklmnopqrst"), 19, 2, "abcdefghij", 19);
+ test(S("abcdefghijklmnopqrst"), 19, 2, "abcdefghijklmnopqrst", 19);
+ test(S("abcdefghijklmnopqrst"), 20, 0, "", 0);
+ test(S("abcdefghijklmnopqrst"), 20, 0, "abcde", -5);
+ test(S("abcdefghijklmnopqrst"), 20, 0, "abcdefghij", -10);
+ test(S("abcdefghijklmnopqrst"), 20, 0, "abcdefghijklmnopqrst", -20);
+ test(S("abcdefghijklmnopqrst"), 20, 1, "", 0);
+ test(S("abcdefghijklmnopqrst"), 20, 1, "abcde", -5);
+ test(S("abcdefghijklmnopqrst"), 20, 1, "abcdefghij", -10);
+ test(S("abcdefghijklmnopqrst"), 20, 1, "abcdefghijklmnopqrst", -20);
+ test(S("abcdefghijklmnopqrst"), 21, 0, "", 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, "abcde", 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, "abcdefghij", 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, "abcdefghijklmnopqrst", 0);
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test0<S>();
+ test1<S>();
+ test2<S>();
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test0<S>();
+ test1<S>();
+ test2<S>();
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.ops/string_compare/size_size_pointer_size.pass.cpp b/test/std/strings/basic.string/string.ops/string_compare/size_size_pointer_size.pass.cpp
new file mode 100644
index 000000000000..ee804d9cc6e5
--- /dev/null
+++ b/test/std/strings/basic.string/string.ops/string_compare/size_size_pointer_size.pass.cpp
@@ -0,0 +1,1323 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// int compare(size_type pos, size_type n1, const charT *s, size_type n2) const;
+
+#include <string>
+#include <stdexcept>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int sign(int x)
+{
+ if (x == 0)
+ return 0;
+ if (x < 0)
+ return -1;
+ return 1;
+}
+
+template <class S>
+void
+test(const S& s, typename S::size_type pos, typename S::size_type n1,
+ const typename S::value_type* str, typename S::size_type n2, int x)
+{
+ try
+ {
+ assert(sign(s.compare(pos, n1, str, n2)) == sign(x));
+ assert(pos <= s.size());
+ }
+ catch (std::out_of_range&)
+ {
+ assert(pos > s.size());
+ }
+}
+
+template <class S>
+void test0()
+{
+ test(S(""), 0, 0, "", 0, 0);
+ test(S(""), 0, 0, "abcde", 0, 0);
+ test(S(""), 0, 0, "abcde", 1, -1);
+ test(S(""), 0, 0, "abcde", 2, -2);
+ test(S(""), 0, 0, "abcde", 4, -4);
+ test(S(""), 0, 0, "abcde", 5, -5);
+ test(S(""), 0, 0, "abcdefghij", 0, 0);
+ test(S(""), 0, 0, "abcdefghij", 1, -1);
+ test(S(""), 0, 0, "abcdefghij", 5, -5);
+ test(S(""), 0, 0, "abcdefghij", 9, -9);
+ test(S(""), 0, 0, "abcdefghij", 10, -10);
+ test(S(""), 0, 0, "abcdefghijklmnopqrst", 0, 0);
+ test(S(""), 0, 0, "abcdefghijklmnopqrst", 1, -1);
+ test(S(""), 0, 0, "abcdefghijklmnopqrst", 10, -10);
+ test(S(""), 0, 0, "abcdefghijklmnopqrst", 19, -19);
+ test(S(""), 0, 0, "abcdefghijklmnopqrst", 20, -20);
+ test(S(""), 0, 1, "", 0, 0);
+ test(S(""), 0, 1, "abcde", 0, 0);
+ test(S(""), 0, 1, "abcde", 1, -1);
+ test(S(""), 0, 1, "abcde", 2, -2);
+ test(S(""), 0, 1, "abcde", 4, -4);
+ test(S(""), 0, 1, "abcde", 5, -5);
+ test(S(""), 0, 1, "abcdefghij", 0, 0);
+ test(S(""), 0, 1, "abcdefghij", 1, -1);
+ test(S(""), 0, 1, "abcdefghij", 5, -5);
+ test(S(""), 0, 1, "abcdefghij", 9, -9);
+ test(S(""), 0, 1, "abcdefghij", 10, -10);
+ test(S(""), 0, 1, "abcdefghijklmnopqrst", 0, 0);
+ test(S(""), 0, 1, "abcdefghijklmnopqrst", 1, -1);
+ test(S(""), 0, 1, "abcdefghijklmnopqrst", 10, -10);
+ test(S(""), 0, 1, "abcdefghijklmnopqrst", 19, -19);
+ test(S(""), 0, 1, "abcdefghijklmnopqrst", 20, -20);
+ test(S(""), 1, 0, "", 0, 0);
+ test(S(""), 1, 0, "abcde", 0, 0);
+ test(S(""), 1, 0, "abcde", 1, 0);
+ test(S(""), 1, 0, "abcde", 2, 0);
+ test(S(""), 1, 0, "abcde", 4, 0);
+ test(S(""), 1, 0, "abcde", 5, 0);
+ test(S(""), 1, 0, "abcdefghij", 0, 0);
+ test(S(""), 1, 0, "abcdefghij", 1, 0);
+ test(S(""), 1, 0, "abcdefghij", 5, 0);
+ test(S(""), 1, 0, "abcdefghij", 9, 0);
+ test(S(""), 1, 0, "abcdefghij", 10, 0);
+ test(S(""), 1, 0, "abcdefghijklmnopqrst", 0, 0);
+ test(S(""), 1, 0, "abcdefghijklmnopqrst", 1, 0);
+ test(S(""), 1, 0, "abcdefghijklmnopqrst", 10, 0);
+ test(S(""), 1, 0, "abcdefghijklmnopqrst", 19, 0);
+ test(S(""), 1, 0, "abcdefghijklmnopqrst", 20, 0);
+ test(S("abcde"), 0, 0, "", 0, 0);
+ test(S("abcde"), 0, 0, "abcde", 0, 0);
+ test(S("abcde"), 0, 0, "abcde", 1, -1);
+ test(S("abcde"), 0, 0, "abcde", 2, -2);
+ test(S("abcde"), 0, 0, "abcde", 4, -4);
+ test(S("abcde"), 0, 0, "abcde", 5, -5);
+ test(S("abcde"), 0, 0, "abcdefghij", 0, 0);
+ test(S("abcde"), 0, 0, "abcdefghij", 1, -1);
+ test(S("abcde"), 0, 0, "abcdefghij", 5, -5);
+ test(S("abcde"), 0, 0, "abcdefghij", 9, -9);
+ test(S("abcde"), 0, 0, "abcdefghij", 10, -10);
+ test(S("abcde"), 0, 0, "abcdefghijklmnopqrst", 0, 0);
+ test(S("abcde"), 0, 0, "abcdefghijklmnopqrst", 1, -1);
+ test(S("abcde"), 0, 0, "abcdefghijklmnopqrst", 10, -10);
+ test(S("abcde"), 0, 0, "abcdefghijklmnopqrst", 19, -19);
+ test(S("abcde"), 0, 0, "abcdefghijklmnopqrst", 20, -20);
+ test(S("abcde"), 0, 1, "", 0, 1);
+ test(S("abcde"), 0, 1, "abcde", 0, 1);
+ test(S("abcde"), 0, 1, "abcde", 1, 0);
+ test(S("abcde"), 0, 1, "abcde", 2, -1);
+ test(S("abcde"), 0, 1, "abcde", 4, -3);
+ test(S("abcde"), 0, 1, "abcde", 5, -4);
+ test(S("abcde"), 0, 1, "abcdefghij", 0, 1);
+ test(S("abcde"), 0, 1, "abcdefghij", 1, 0);
+ test(S("abcde"), 0, 1, "abcdefghij", 5, -4);
+ test(S("abcde"), 0, 1, "abcdefghij", 9, -8);
+ test(S("abcde"), 0, 1, "abcdefghij", 10, -9);
+ test(S("abcde"), 0, 1, "abcdefghijklmnopqrst", 0, 1);
+ test(S("abcde"), 0, 1, "abcdefghijklmnopqrst", 1, 0);
+ test(S("abcde"), 0, 1, "abcdefghijklmnopqrst", 10, -9);
+ test(S("abcde"), 0, 1, "abcdefghijklmnopqrst", 19, -18);
+ test(S("abcde"), 0, 1, "abcdefghijklmnopqrst", 20, -19);
+ test(S("abcde"), 0, 2, "", 0, 2);
+ test(S("abcde"), 0, 2, "abcde", 0, 2);
+ test(S("abcde"), 0, 2, "abcde", 1, 1);
+ test(S("abcde"), 0, 2, "abcde", 2, 0);
+ test(S("abcde"), 0, 2, "abcde", 4, -2);
+ test(S("abcde"), 0, 2, "abcde", 5, -3);
+ test(S("abcde"), 0, 2, "abcdefghij", 0, 2);
+ test(S("abcde"), 0, 2, "abcdefghij", 1, 1);
+ test(S("abcde"), 0, 2, "abcdefghij", 5, -3);
+ test(S("abcde"), 0, 2, "abcdefghij", 9, -7);
+ test(S("abcde"), 0, 2, "abcdefghij", 10, -8);
+ test(S("abcde"), 0, 2, "abcdefghijklmnopqrst", 0, 2);
+ test(S("abcde"), 0, 2, "abcdefghijklmnopqrst", 1, 1);
+ test(S("abcde"), 0, 2, "abcdefghijklmnopqrst", 10, -8);
+ test(S("abcde"), 0, 2, "abcdefghijklmnopqrst", 19, -17);
+ test(S("abcde"), 0, 2, "abcdefghijklmnopqrst", 20, -18);
+ test(S("abcde"), 0, 4, "", 0, 4);
+ test(S("abcde"), 0, 4, "abcde", 0, 4);
+ test(S("abcde"), 0, 4, "abcde", 1, 3);
+ test(S("abcde"), 0, 4, "abcde", 2, 2);
+}
+
+template <class S>
+void test1()
+{
+ test(S("abcde"), 0, 4, "abcde", 4, 0);
+ test(S("abcde"), 0, 4, "abcde", 5, -1);
+ test(S("abcde"), 0, 4, "abcdefghij", 0, 4);
+ test(S("abcde"), 0, 4, "abcdefghij", 1, 3);
+ test(S("abcde"), 0, 4, "abcdefghij", 5, -1);
+ test(S("abcde"), 0, 4, "abcdefghij", 9, -5);
+ test(S("abcde"), 0, 4, "abcdefghij", 10, -6);
+ test(S("abcde"), 0, 4, "abcdefghijklmnopqrst", 0, 4);
+ test(S("abcde"), 0, 4, "abcdefghijklmnopqrst", 1, 3);
+ test(S("abcde"), 0, 4, "abcdefghijklmnopqrst", 10, -6);
+ test(S("abcde"), 0, 4, "abcdefghijklmnopqrst", 19, -15);
+ test(S("abcde"), 0, 4, "abcdefghijklmnopqrst", 20, -16);
+ test(S("abcde"), 0, 5, "", 0, 5);
+ test(S("abcde"), 0, 5, "abcde", 0, 5);
+ test(S("abcde"), 0, 5, "abcde", 1, 4);
+ test(S("abcde"), 0, 5, "abcde", 2, 3);
+ test(S("abcde"), 0, 5, "abcde", 4, 1);
+ test(S("abcde"), 0, 5, "abcde", 5, 0);
+ test(S("abcde"), 0, 5, "abcdefghij", 0, 5);
+ test(S("abcde"), 0, 5, "abcdefghij", 1, 4);
+ test(S("abcde"), 0, 5, "abcdefghij", 5, 0);
+ test(S("abcde"), 0, 5, "abcdefghij", 9, -4);
+ test(S("abcde"), 0, 5, "abcdefghij", 10, -5);
+ test(S("abcde"), 0, 5, "abcdefghijklmnopqrst", 0, 5);
+ test(S("abcde"), 0, 5, "abcdefghijklmnopqrst", 1, 4);
+ test(S("abcde"), 0, 5, "abcdefghijklmnopqrst", 10, -5);
+ test(S("abcde"), 0, 5, "abcdefghijklmnopqrst", 19, -14);
+ test(S("abcde"), 0, 5, "abcdefghijklmnopqrst", 20, -15);
+ test(S("abcde"), 0, 6, "", 0, 5);
+ test(S("abcde"), 0, 6, "abcde", 0, 5);
+ test(S("abcde"), 0, 6, "abcde", 1, 4);
+ test(S("abcde"), 0, 6, "abcde", 2, 3);
+ test(S("abcde"), 0, 6, "abcde", 4, 1);
+ test(S("abcde"), 0, 6, "abcde", 5, 0);
+ test(S("abcde"), 0, 6, "abcdefghij", 0, 5);
+ test(S("abcde"), 0, 6, "abcdefghij", 1, 4);
+ test(S("abcde"), 0, 6, "abcdefghij", 5, 0);
+ test(S("abcde"), 0, 6, "abcdefghij", 9, -4);
+ test(S("abcde"), 0, 6, "abcdefghij", 10, -5);
+ test(S("abcde"), 0, 6, "abcdefghijklmnopqrst", 0, 5);
+ test(S("abcde"), 0, 6, "abcdefghijklmnopqrst", 1, 4);
+ test(S("abcde"), 0, 6, "abcdefghijklmnopqrst", 10, -5);
+ test(S("abcde"), 0, 6, "abcdefghijklmnopqrst", 19, -14);
+ test(S("abcde"), 0, 6, "abcdefghijklmnopqrst", 20, -15);
+ test(S("abcde"), 1, 0, "", 0, 0);
+ test(S("abcde"), 1, 0, "abcde", 0, 0);
+ test(S("abcde"), 1, 0, "abcde", 1, -1);
+ test(S("abcde"), 1, 0, "abcde", 2, -2);
+ test(S("abcde"), 1, 0, "abcde", 4, -4);
+ test(S("abcde"), 1, 0, "abcde", 5, -5);
+ test(S("abcde"), 1, 0, "abcdefghij", 0, 0);
+ test(S("abcde"), 1, 0, "abcdefghij", 1, -1);
+ test(S("abcde"), 1, 0, "abcdefghij", 5, -5);
+ test(S("abcde"), 1, 0, "abcdefghij", 9, -9);
+ test(S("abcde"), 1, 0, "abcdefghij", 10, -10);
+ test(S("abcde"), 1, 0, "abcdefghijklmnopqrst", 0, 0);
+ test(S("abcde"), 1, 0, "abcdefghijklmnopqrst", 1, -1);
+ test(S("abcde"), 1, 0, "abcdefghijklmnopqrst", 10, -10);
+ test(S("abcde"), 1, 0, "abcdefghijklmnopqrst", 19, -19);
+ test(S("abcde"), 1, 0, "abcdefghijklmnopqrst", 20, -20);
+ test(S("abcde"), 1, 1, "", 0, 1);
+ test(S("abcde"), 1, 1, "abcde", 0, 1);
+ test(S("abcde"), 1, 1, "abcde", 1, 1);
+ test(S("abcde"), 1, 1, "abcde", 2, 1);
+ test(S("abcde"), 1, 1, "abcde", 4, 1);
+ test(S("abcde"), 1, 1, "abcde", 5, 1);
+ test(S("abcde"), 1, 1, "abcdefghij", 0, 1);
+ test(S("abcde"), 1, 1, "abcdefghij", 1, 1);
+ test(S("abcde"), 1, 1, "abcdefghij", 5, 1);
+ test(S("abcde"), 1, 1, "abcdefghij", 9, 1);
+ test(S("abcde"), 1, 1, "abcdefghij", 10, 1);
+ test(S("abcde"), 1, 1, "abcdefghijklmnopqrst", 0, 1);
+ test(S("abcde"), 1, 1, "abcdefghijklmnopqrst", 1, 1);
+ test(S("abcde"), 1, 1, "abcdefghijklmnopqrst", 10, 1);
+ test(S("abcde"), 1, 1, "abcdefghijklmnopqrst", 19, 1);
+ test(S("abcde"), 1, 1, "abcdefghijklmnopqrst", 20, 1);
+ test(S("abcde"), 1, 2, "", 0, 2);
+ test(S("abcde"), 1, 2, "abcde", 0, 2);
+ test(S("abcde"), 1, 2, "abcde", 1, 1);
+ test(S("abcde"), 1, 2, "abcde", 2, 1);
+ test(S("abcde"), 1, 2, "abcde", 4, 1);
+ test(S("abcde"), 1, 2, "abcde", 5, 1);
+ test(S("abcde"), 1, 2, "abcdefghij", 0, 2);
+ test(S("abcde"), 1, 2, "abcdefghij", 1, 1);
+ test(S("abcde"), 1, 2, "abcdefghij", 5, 1);
+ test(S("abcde"), 1, 2, "abcdefghij", 9, 1);
+ test(S("abcde"), 1, 2, "abcdefghij", 10, 1);
+ test(S("abcde"), 1, 2, "abcdefghijklmnopqrst", 0, 2);
+ test(S("abcde"), 1, 2, "abcdefghijklmnopqrst", 1, 1);
+ test(S("abcde"), 1, 2, "abcdefghijklmnopqrst", 10, 1);
+ test(S("abcde"), 1, 2, "abcdefghijklmnopqrst", 19, 1);
+ test(S("abcde"), 1, 2, "abcdefghijklmnopqrst", 20, 1);
+ test(S("abcde"), 1, 3, "", 0, 3);
+ test(S("abcde"), 1, 3, "abcde", 0, 3);
+ test(S("abcde"), 1, 3, "abcde", 1, 1);
+ test(S("abcde"), 1, 3, "abcde", 2, 1);
+ test(S("abcde"), 1, 3, "abcde", 4, 1);
+ test(S("abcde"), 1, 3, "abcde", 5, 1);
+ test(S("abcde"), 1, 3, "abcdefghij", 0, 3);
+ test(S("abcde"), 1, 3, "abcdefghij", 1, 1);
+}
+
+template <class S>
+void test2()
+{
+ test(S("abcde"), 1, 3, "abcdefghij", 5, 1);
+ test(S("abcde"), 1, 3, "abcdefghij", 9, 1);
+ test(S("abcde"), 1, 3, "abcdefghij", 10, 1);
+ test(S("abcde"), 1, 3, "abcdefghijklmnopqrst", 0, 3);
+ test(S("abcde"), 1, 3, "abcdefghijklmnopqrst", 1, 1);
+ test(S("abcde"), 1, 3, "abcdefghijklmnopqrst", 10, 1);
+ test(S("abcde"), 1, 3, "abcdefghijklmnopqrst", 19, 1);
+ test(S("abcde"), 1, 3, "abcdefghijklmnopqrst", 20, 1);
+ test(S("abcde"), 1, 4, "", 0, 4);
+ test(S("abcde"), 1, 4, "abcde", 0, 4);
+ test(S("abcde"), 1, 4, "abcde", 1, 1);
+ test(S("abcde"), 1, 4, "abcde", 2, 1);
+ test(S("abcde"), 1, 4, "abcde", 4, 1);
+ test(S("abcde"), 1, 4, "abcde", 5, 1);
+ test(S("abcde"), 1, 4, "abcdefghij", 0, 4);
+ test(S("abcde"), 1, 4, "abcdefghij", 1, 1);
+ test(S("abcde"), 1, 4, "abcdefghij", 5, 1);
+ test(S("abcde"), 1, 4, "abcdefghij", 9, 1);
+ test(S("abcde"), 1, 4, "abcdefghij", 10, 1);
+ test(S("abcde"), 1, 4, "abcdefghijklmnopqrst", 0, 4);
+ test(S("abcde"), 1, 4, "abcdefghijklmnopqrst", 1, 1);
+ test(S("abcde"), 1, 4, "abcdefghijklmnopqrst", 10, 1);
+ test(S("abcde"), 1, 4, "abcdefghijklmnopqrst", 19, 1);
+ test(S("abcde"), 1, 4, "abcdefghijklmnopqrst", 20, 1);
+ test(S("abcde"), 1, 5, "", 0, 4);
+ test(S("abcde"), 1, 5, "abcde", 0, 4);
+ test(S("abcde"), 1, 5, "abcde", 1, 1);
+ test(S("abcde"), 1, 5, "abcde", 2, 1);
+ test(S("abcde"), 1, 5, "abcde", 4, 1);
+ test(S("abcde"), 1, 5, "abcde", 5, 1);
+ test(S("abcde"), 1, 5, "abcdefghij", 0, 4);
+ test(S("abcde"), 1, 5, "abcdefghij", 1, 1);
+ test(S("abcde"), 1, 5, "abcdefghij", 5, 1);
+ test(S("abcde"), 1, 5, "abcdefghij", 9, 1);
+ test(S("abcde"), 1, 5, "abcdefghij", 10, 1);
+ test(S("abcde"), 1, 5, "abcdefghijklmnopqrst", 0, 4);
+ test(S("abcde"), 1, 5, "abcdefghijklmnopqrst", 1, 1);
+ test(S("abcde"), 1, 5, "abcdefghijklmnopqrst", 10, 1);
+ test(S("abcde"), 1, 5, "abcdefghijklmnopqrst", 19, 1);
+ test(S("abcde"), 1, 5, "abcdefghijklmnopqrst", 20, 1);
+ test(S("abcde"), 2, 0, "", 0, 0);
+ test(S("abcde"), 2, 0, "abcde", 0, 0);
+ test(S("abcde"), 2, 0, "abcde", 1, -1);
+ test(S("abcde"), 2, 0, "abcde", 2, -2);
+ test(S("abcde"), 2, 0, "abcde", 4, -4);
+ test(S("abcde"), 2, 0, "abcde", 5, -5);
+ test(S("abcde"), 2, 0, "abcdefghij", 0, 0);
+ test(S("abcde"), 2, 0, "abcdefghij", 1, -1);
+ test(S("abcde"), 2, 0, "abcdefghij", 5, -5);
+ test(S("abcde"), 2, 0, "abcdefghij", 9, -9);
+ test(S("abcde"), 2, 0, "abcdefghij", 10, -10);
+ test(S("abcde"), 2, 0, "abcdefghijklmnopqrst", 0, 0);
+ test(S("abcde"), 2, 0, "abcdefghijklmnopqrst", 1, -1);
+ test(S("abcde"), 2, 0, "abcdefghijklmnopqrst", 10, -10);
+ test(S("abcde"), 2, 0, "abcdefghijklmnopqrst", 19, -19);
+ test(S("abcde"), 2, 0, "abcdefghijklmnopqrst", 20, -20);
+ test(S("abcde"), 2, 1, "", 0, 1);
+ test(S("abcde"), 2, 1, "abcde", 0, 1);
+ test(S("abcde"), 2, 1, "abcde", 1, 2);
+ test(S("abcde"), 2, 1, "abcde", 2, 2);
+ test(S("abcde"), 2, 1, "abcde", 4, 2);
+ test(S("abcde"), 2, 1, "abcde", 5, 2);
+ test(S("abcde"), 2, 1, "abcdefghij", 0, 1);
+ test(S("abcde"), 2, 1, "abcdefghij", 1, 2);
+ test(S("abcde"), 2, 1, "abcdefghij", 5, 2);
+ test(S("abcde"), 2, 1, "abcdefghij", 9, 2);
+ test(S("abcde"), 2, 1, "abcdefghij", 10, 2);
+ test(S("abcde"), 2, 1, "abcdefghijklmnopqrst", 0, 1);
+ test(S("abcde"), 2, 1, "abcdefghijklmnopqrst", 1, 2);
+ test(S("abcde"), 2, 1, "abcdefghijklmnopqrst", 10, 2);
+ test(S("abcde"), 2, 1, "abcdefghijklmnopqrst", 19, 2);
+ test(S("abcde"), 2, 1, "abcdefghijklmnopqrst", 20, 2);
+ test(S("abcde"), 2, 2, "", 0, 2);
+ test(S("abcde"), 2, 2, "abcde", 0, 2);
+ test(S("abcde"), 2, 2, "abcde", 1, 2);
+ test(S("abcde"), 2, 2, "abcde", 2, 2);
+ test(S("abcde"), 2, 2, "abcde", 4, 2);
+ test(S("abcde"), 2, 2, "abcde", 5, 2);
+ test(S("abcde"), 2, 2, "abcdefghij", 0, 2);
+ test(S("abcde"), 2, 2, "abcdefghij", 1, 2);
+ test(S("abcde"), 2, 2, "abcdefghij", 5, 2);
+ test(S("abcde"), 2, 2, "abcdefghij", 9, 2);
+ test(S("abcde"), 2, 2, "abcdefghij", 10, 2);
+ test(S("abcde"), 2, 2, "abcdefghijklmnopqrst", 0, 2);
+ test(S("abcde"), 2, 2, "abcdefghijklmnopqrst", 1, 2);
+ test(S("abcde"), 2, 2, "abcdefghijklmnopqrst", 10, 2);
+ test(S("abcde"), 2, 2, "abcdefghijklmnopqrst", 19, 2);
+ test(S("abcde"), 2, 2, "abcdefghijklmnopqrst", 20, 2);
+ test(S("abcde"), 2, 3, "", 0, 3);
+ test(S("abcde"), 2, 3, "abcde", 0, 3);
+ test(S("abcde"), 2, 3, "abcde", 1, 2);
+ test(S("abcde"), 2, 3, "abcde", 2, 2);
+ test(S("abcde"), 2, 3, "abcde", 4, 2);
+ test(S("abcde"), 2, 3, "abcde", 5, 2);
+ test(S("abcde"), 2, 3, "abcdefghij", 0, 3);
+ test(S("abcde"), 2, 3, "abcdefghij", 1, 2);
+ test(S("abcde"), 2, 3, "abcdefghij", 5, 2);
+ test(S("abcde"), 2, 3, "abcdefghij", 9, 2);
+ test(S("abcde"), 2, 3, "abcdefghij", 10, 2);
+ test(S("abcde"), 2, 3, "abcdefghijklmnopqrst", 0, 3);
+}
+
+template <class S>
+void test3()
+{
+ test(S("abcde"), 2, 3, "abcdefghijklmnopqrst", 1, 2);
+ test(S("abcde"), 2, 3, "abcdefghijklmnopqrst", 10, 2);
+ test(S("abcde"), 2, 3, "abcdefghijklmnopqrst", 19, 2);
+ test(S("abcde"), 2, 3, "abcdefghijklmnopqrst", 20, 2);
+ test(S("abcde"), 2, 4, "", 0, 3);
+ test(S("abcde"), 2, 4, "abcde", 0, 3);
+ test(S("abcde"), 2, 4, "abcde", 1, 2);
+ test(S("abcde"), 2, 4, "abcde", 2, 2);
+ test(S("abcde"), 2, 4, "abcde", 4, 2);
+ test(S("abcde"), 2, 4, "abcde", 5, 2);
+ test(S("abcde"), 2, 4, "abcdefghij", 0, 3);
+ test(S("abcde"), 2, 4, "abcdefghij", 1, 2);
+ test(S("abcde"), 2, 4, "abcdefghij", 5, 2);
+ test(S("abcde"), 2, 4, "abcdefghij", 9, 2);
+ test(S("abcde"), 2, 4, "abcdefghij", 10, 2);
+ test(S("abcde"), 2, 4, "abcdefghijklmnopqrst", 0, 3);
+ test(S("abcde"), 2, 4, "abcdefghijklmnopqrst", 1, 2);
+ test(S("abcde"), 2, 4, "abcdefghijklmnopqrst", 10, 2);
+ test(S("abcde"), 2, 4, "abcdefghijklmnopqrst", 19, 2);
+ test(S("abcde"), 2, 4, "abcdefghijklmnopqrst", 20, 2);
+ test(S("abcde"), 4, 0, "", 0, 0);
+ test(S("abcde"), 4, 0, "abcde", 0, 0);
+ test(S("abcde"), 4, 0, "abcde", 1, -1);
+ test(S("abcde"), 4, 0, "abcde", 2, -2);
+ test(S("abcde"), 4, 0, "abcde", 4, -4);
+ test(S("abcde"), 4, 0, "abcde", 5, -5);
+ test(S("abcde"), 4, 0, "abcdefghij", 0, 0);
+ test(S("abcde"), 4, 0, "abcdefghij", 1, -1);
+ test(S("abcde"), 4, 0, "abcdefghij", 5, -5);
+ test(S("abcde"), 4, 0, "abcdefghij", 9, -9);
+ test(S("abcde"), 4, 0, "abcdefghij", 10, -10);
+ test(S("abcde"), 4, 0, "abcdefghijklmnopqrst", 0, 0);
+ test(S("abcde"), 4, 0, "abcdefghijklmnopqrst", 1, -1);
+ test(S("abcde"), 4, 0, "abcdefghijklmnopqrst", 10, -10);
+ test(S("abcde"), 4, 0, "abcdefghijklmnopqrst", 19, -19);
+ test(S("abcde"), 4, 0, "abcdefghijklmnopqrst", 20, -20);
+ test(S("abcde"), 4, 1, "", 0, 1);
+ test(S("abcde"), 4, 1, "abcde", 0, 1);
+ test(S("abcde"), 4, 1, "abcde", 1, 4);
+ test(S("abcde"), 4, 1, "abcde", 2, 4);
+ test(S("abcde"), 4, 1, "abcde", 4, 4);
+ test(S("abcde"), 4, 1, "abcde", 5, 4);
+ test(S("abcde"), 4, 1, "abcdefghij", 0, 1);
+ test(S("abcde"), 4, 1, "abcdefghij", 1, 4);
+ test(S("abcde"), 4, 1, "abcdefghij", 5, 4);
+ test(S("abcde"), 4, 1, "abcdefghij", 9, 4);
+ test(S("abcde"), 4, 1, "abcdefghij", 10, 4);
+ test(S("abcde"), 4, 1, "abcdefghijklmnopqrst", 0, 1);
+ test(S("abcde"), 4, 1, "abcdefghijklmnopqrst", 1, 4);
+ test(S("abcde"), 4, 1, "abcdefghijklmnopqrst", 10, 4);
+ test(S("abcde"), 4, 1, "abcdefghijklmnopqrst", 19, 4);
+ test(S("abcde"), 4, 1, "abcdefghijklmnopqrst", 20, 4);
+ test(S("abcde"), 4, 2, "", 0, 1);
+ test(S("abcde"), 4, 2, "abcde", 0, 1);
+ test(S("abcde"), 4, 2, "abcde", 1, 4);
+ test(S("abcde"), 4, 2, "abcde", 2, 4);
+ test(S("abcde"), 4, 2, "abcde", 4, 4);
+ test(S("abcde"), 4, 2, "abcde", 5, 4);
+ test(S("abcde"), 4, 2, "abcdefghij", 0, 1);
+ test(S("abcde"), 4, 2, "abcdefghij", 1, 4);
+ test(S("abcde"), 4, 2, "abcdefghij", 5, 4);
+ test(S("abcde"), 4, 2, "abcdefghij", 9, 4);
+ test(S("abcde"), 4, 2, "abcdefghij", 10, 4);
+ test(S("abcde"), 4, 2, "abcdefghijklmnopqrst", 0, 1);
+ test(S("abcde"), 4, 2, "abcdefghijklmnopqrst", 1, 4);
+ test(S("abcde"), 4, 2, "abcdefghijklmnopqrst", 10, 4);
+ test(S("abcde"), 4, 2, "abcdefghijklmnopqrst", 19, 4);
+ test(S("abcde"), 4, 2, "abcdefghijklmnopqrst", 20, 4);
+ test(S("abcde"), 5, 0, "", 0, 0);
+ test(S("abcde"), 5, 0, "abcde", 0, 0);
+ test(S("abcde"), 5, 0, "abcde", 1, -1);
+ test(S("abcde"), 5, 0, "abcde", 2, -2);
+ test(S("abcde"), 5, 0, "abcde", 4, -4);
+ test(S("abcde"), 5, 0, "abcde", 5, -5);
+ test(S("abcde"), 5, 0, "abcdefghij", 0, 0);
+ test(S("abcde"), 5, 0, "abcdefghij", 1, -1);
+ test(S("abcde"), 5, 0, "abcdefghij", 5, -5);
+ test(S("abcde"), 5, 0, "abcdefghij", 9, -9);
+ test(S("abcde"), 5, 0, "abcdefghij", 10, -10);
+ test(S("abcde"), 5, 0, "abcdefghijklmnopqrst", 0, 0);
+ test(S("abcde"), 5, 0, "abcdefghijklmnopqrst", 1, -1);
+ test(S("abcde"), 5, 0, "abcdefghijklmnopqrst", 10, -10);
+ test(S("abcde"), 5, 0, "abcdefghijklmnopqrst", 19, -19);
+ test(S("abcde"), 5, 0, "abcdefghijklmnopqrst", 20, -20);
+ test(S("abcde"), 5, 1, "", 0, 0);
+ test(S("abcde"), 5, 1, "abcde", 0, 0);
+ test(S("abcde"), 5, 1, "abcde", 1, -1);
+ test(S("abcde"), 5, 1, "abcde", 2, -2);
+ test(S("abcde"), 5, 1, "abcde", 4, -4);
+ test(S("abcde"), 5, 1, "abcde", 5, -5);
+ test(S("abcde"), 5, 1, "abcdefghij", 0, 0);
+ test(S("abcde"), 5, 1, "abcdefghij", 1, -1);
+ test(S("abcde"), 5, 1, "abcdefghij", 5, -5);
+ test(S("abcde"), 5, 1, "abcdefghij", 9, -9);
+ test(S("abcde"), 5, 1, "abcdefghij", 10, -10);
+ test(S("abcde"), 5, 1, "abcdefghijklmnopqrst", 0, 0);
+ test(S("abcde"), 5, 1, "abcdefghijklmnopqrst", 1, -1);
+ test(S("abcde"), 5, 1, "abcdefghijklmnopqrst", 10, -10);
+ test(S("abcde"), 5, 1, "abcdefghijklmnopqrst", 19, -19);
+ test(S("abcde"), 5, 1, "abcdefghijklmnopqrst", 20, -20);
+}
+
+template <class S>
+void test4()
+{
+ test(S("abcde"), 6, 0, "", 0, 0);
+ test(S("abcde"), 6, 0, "abcde", 0, 0);
+ test(S("abcde"), 6, 0, "abcde", 1, 0);
+ test(S("abcde"), 6, 0, "abcde", 2, 0);
+ test(S("abcde"), 6, 0, "abcde", 4, 0);
+ test(S("abcde"), 6, 0, "abcde", 5, 0);
+ test(S("abcde"), 6, 0, "abcdefghij", 0, 0);
+ test(S("abcde"), 6, 0, "abcdefghij", 1, 0);
+ test(S("abcde"), 6, 0, "abcdefghij", 5, 0);
+ test(S("abcde"), 6, 0, "abcdefghij", 9, 0);
+ test(S("abcde"), 6, 0, "abcdefghij", 10, 0);
+ test(S("abcde"), 6, 0, "abcdefghijklmnopqrst", 0, 0);
+ test(S("abcde"), 6, 0, "abcdefghijklmnopqrst", 1, 0);
+ test(S("abcde"), 6, 0, "abcdefghijklmnopqrst", 10, 0);
+ test(S("abcde"), 6, 0, "abcdefghijklmnopqrst", 19, 0);
+ test(S("abcde"), 6, 0, "abcdefghijklmnopqrst", 20, 0);
+ test(S("abcdefghij"), 0, 0, "", 0, 0);
+ test(S("abcdefghij"), 0, 0, "abcde", 0, 0);
+ test(S("abcdefghij"), 0, 0, "abcde", 1, -1);
+ test(S("abcdefghij"), 0, 0, "abcde", 2, -2);
+ test(S("abcdefghij"), 0, 0, "abcde", 4, -4);
+ test(S("abcdefghij"), 0, 0, "abcde", 5, -5);
+ test(S("abcdefghij"), 0, 0, "abcdefghij", 0, 0);
+ test(S("abcdefghij"), 0, 0, "abcdefghij", 1, -1);
+ test(S("abcdefghij"), 0, 0, "abcdefghij", 5, -5);
+ test(S("abcdefghij"), 0, 0, "abcdefghij", 9, -9);
+ test(S("abcdefghij"), 0, 0, "abcdefghij", 10, -10);
+ test(S("abcdefghij"), 0, 0, "abcdefghijklmnopqrst", 0, 0);
+ test(S("abcdefghij"), 0, 0, "abcdefghijklmnopqrst", 1, -1);
+ test(S("abcdefghij"), 0, 0, "abcdefghijklmnopqrst", 10, -10);
+ test(S("abcdefghij"), 0, 0, "abcdefghijklmnopqrst", 19, -19);
+ test(S("abcdefghij"), 0, 0, "abcdefghijklmnopqrst", 20, -20);
+ test(S("abcdefghij"), 0, 1, "", 0, 1);
+ test(S("abcdefghij"), 0, 1, "abcde", 0, 1);
+ test(S("abcdefghij"), 0, 1, "abcde", 1, 0);
+ test(S("abcdefghij"), 0, 1, "abcde", 2, -1);
+ test(S("abcdefghij"), 0, 1, "abcde", 4, -3);
+ test(S("abcdefghij"), 0, 1, "abcde", 5, -4);
+ test(S("abcdefghij"), 0, 1, "abcdefghij", 0, 1);
+ test(S("abcdefghij"), 0, 1, "abcdefghij", 1, 0);
+ test(S("abcdefghij"), 0, 1, "abcdefghij", 5, -4);
+ test(S("abcdefghij"), 0, 1, "abcdefghij", 9, -8);
+ test(S("abcdefghij"), 0, 1, "abcdefghij", 10, -9);
+ test(S("abcdefghij"), 0, 1, "abcdefghijklmnopqrst", 0, 1);
+ test(S("abcdefghij"), 0, 1, "abcdefghijklmnopqrst", 1, 0);
+ test(S("abcdefghij"), 0, 1, "abcdefghijklmnopqrst", 10, -9);
+ test(S("abcdefghij"), 0, 1, "abcdefghijklmnopqrst", 19, -18);
+ test(S("abcdefghij"), 0, 1, "abcdefghijklmnopqrst", 20, -19);
+ test(S("abcdefghij"), 0, 5, "", 0, 5);
+ test(S("abcdefghij"), 0, 5, "abcde", 0, 5);
+ test(S("abcdefghij"), 0, 5, "abcde", 1, 4);
+ test(S("abcdefghij"), 0, 5, "abcde", 2, 3);
+ test(S("abcdefghij"), 0, 5, "abcde", 4, 1);
+ test(S("abcdefghij"), 0, 5, "abcde", 5, 0);
+ test(S("abcdefghij"), 0, 5, "abcdefghij", 0, 5);
+ test(S("abcdefghij"), 0, 5, "abcdefghij", 1, 4);
+ test(S("abcdefghij"), 0, 5, "abcdefghij", 5, 0);
+ test(S("abcdefghij"), 0, 5, "abcdefghij", 9, -4);
+ test(S("abcdefghij"), 0, 5, "abcdefghij", 10, -5);
+ test(S("abcdefghij"), 0, 5, "abcdefghijklmnopqrst", 0, 5);
+ test(S("abcdefghij"), 0, 5, "abcdefghijklmnopqrst", 1, 4);
+ test(S("abcdefghij"), 0, 5, "abcdefghijklmnopqrst", 10, -5);
+ test(S("abcdefghij"), 0, 5, "abcdefghijklmnopqrst", 19, -14);
+ test(S("abcdefghij"), 0, 5, "abcdefghijklmnopqrst", 20, -15);
+ test(S("abcdefghij"), 0, 9, "", 0, 9);
+ test(S("abcdefghij"), 0, 9, "abcde", 0, 9);
+ test(S("abcdefghij"), 0, 9, "abcde", 1, 8);
+ test(S("abcdefghij"), 0, 9, "abcde", 2, 7);
+ test(S("abcdefghij"), 0, 9, "abcde", 4, 5);
+ test(S("abcdefghij"), 0, 9, "abcde", 5, 4);
+ test(S("abcdefghij"), 0, 9, "abcdefghij", 0, 9);
+ test(S("abcdefghij"), 0, 9, "abcdefghij", 1, 8);
+ test(S("abcdefghij"), 0, 9, "abcdefghij", 5, 4);
+ test(S("abcdefghij"), 0, 9, "abcdefghij", 9, 0);
+ test(S("abcdefghij"), 0, 9, "abcdefghij", 10, -1);
+ test(S("abcdefghij"), 0, 9, "abcdefghijklmnopqrst", 0, 9);
+ test(S("abcdefghij"), 0, 9, "abcdefghijklmnopqrst", 1, 8);
+ test(S("abcdefghij"), 0, 9, "abcdefghijklmnopqrst", 10, -1);
+ test(S("abcdefghij"), 0, 9, "abcdefghijklmnopqrst", 19, -10);
+ test(S("abcdefghij"), 0, 9, "abcdefghijklmnopqrst", 20, -11);
+ test(S("abcdefghij"), 0, 10, "", 0, 10);
+ test(S("abcdefghij"), 0, 10, "abcde", 0, 10);
+ test(S("abcdefghij"), 0, 10, "abcde", 1, 9);
+ test(S("abcdefghij"), 0, 10, "abcde", 2, 8);
+ test(S("abcdefghij"), 0, 10, "abcde", 4, 6);
+ test(S("abcdefghij"), 0, 10, "abcde", 5, 5);
+ test(S("abcdefghij"), 0, 10, "abcdefghij", 0, 10);
+ test(S("abcdefghij"), 0, 10, "abcdefghij", 1, 9);
+ test(S("abcdefghij"), 0, 10, "abcdefghij", 5, 5);
+ test(S("abcdefghij"), 0, 10, "abcdefghij", 9, 1);
+ test(S("abcdefghij"), 0, 10, "abcdefghij", 10, 0);
+ test(S("abcdefghij"), 0, 10, "abcdefghijklmnopqrst", 0, 10);
+ test(S("abcdefghij"), 0, 10, "abcdefghijklmnopqrst", 1, 9);
+ test(S("abcdefghij"), 0, 10, "abcdefghijklmnopqrst", 10, 0);
+ test(S("abcdefghij"), 0, 10, "abcdefghijklmnopqrst", 19, -9);
+ test(S("abcdefghij"), 0, 10, "abcdefghijklmnopqrst", 20, -10);
+ test(S("abcdefghij"), 0, 11, "", 0, 10);
+ test(S("abcdefghij"), 0, 11, "abcde", 0, 10);
+ test(S("abcdefghij"), 0, 11, "abcde", 1, 9);
+ test(S("abcdefghij"), 0, 11, "abcde", 2, 8);
+}
+
+template <class S>
+void test5()
+{
+ test(S("abcdefghij"), 0, 11, "abcde", 4, 6);
+ test(S("abcdefghij"), 0, 11, "abcde", 5, 5);
+ test(S("abcdefghij"), 0, 11, "abcdefghij", 0, 10);
+ test(S("abcdefghij"), 0, 11, "abcdefghij", 1, 9);
+ test(S("abcdefghij"), 0, 11, "abcdefghij", 5, 5);
+ test(S("abcdefghij"), 0, 11, "abcdefghij", 9, 1);
+ test(S("abcdefghij"), 0, 11, "abcdefghij", 10, 0);
+ test(S("abcdefghij"), 0, 11, "abcdefghijklmnopqrst", 0, 10);
+ test(S("abcdefghij"), 0, 11, "abcdefghijklmnopqrst", 1, 9);
+ test(S("abcdefghij"), 0, 11, "abcdefghijklmnopqrst", 10, 0);
+ test(S("abcdefghij"), 0, 11, "abcdefghijklmnopqrst", 19, -9);
+ test(S("abcdefghij"), 0, 11, "abcdefghijklmnopqrst", 20, -10);
+ test(S("abcdefghij"), 1, 0, "", 0, 0);
+ test(S("abcdefghij"), 1, 0, "abcde", 0, 0);
+ test(S("abcdefghij"), 1, 0, "abcde", 1, -1);
+ test(S("abcdefghij"), 1, 0, "abcde", 2, -2);
+ test(S("abcdefghij"), 1, 0, "abcde", 4, -4);
+ test(S("abcdefghij"), 1, 0, "abcde", 5, -5);
+ test(S("abcdefghij"), 1, 0, "abcdefghij", 0, 0);
+ test(S("abcdefghij"), 1, 0, "abcdefghij", 1, -1);
+ test(S("abcdefghij"), 1, 0, "abcdefghij", 5, -5);
+ test(S("abcdefghij"), 1, 0, "abcdefghij", 9, -9);
+ test(S("abcdefghij"), 1, 0, "abcdefghij", 10, -10);
+ test(S("abcdefghij"), 1, 0, "abcdefghijklmnopqrst", 0, 0);
+ test(S("abcdefghij"), 1, 0, "abcdefghijklmnopqrst", 1, -1);
+ test(S("abcdefghij"), 1, 0, "abcdefghijklmnopqrst", 10, -10);
+ test(S("abcdefghij"), 1, 0, "abcdefghijklmnopqrst", 19, -19);
+ test(S("abcdefghij"), 1, 0, "abcdefghijklmnopqrst", 20, -20);
+ test(S("abcdefghij"), 1, 1, "", 0, 1);
+ test(S("abcdefghij"), 1, 1, "abcde", 0, 1);
+ test(S("abcdefghij"), 1, 1, "abcde", 1, 1);
+ test(S("abcdefghij"), 1, 1, "abcde", 2, 1);
+ test(S("abcdefghij"), 1, 1, "abcde", 4, 1);
+ test(S("abcdefghij"), 1, 1, "abcde", 5, 1);
+ test(S("abcdefghij"), 1, 1, "abcdefghij", 0, 1);
+ test(S("abcdefghij"), 1, 1, "abcdefghij", 1, 1);
+ test(S("abcdefghij"), 1, 1, "abcdefghij", 5, 1);
+ test(S("abcdefghij"), 1, 1, "abcdefghij", 9, 1);
+ test(S("abcdefghij"), 1, 1, "abcdefghij", 10, 1);
+ test(S("abcdefghij"), 1, 1, "abcdefghijklmnopqrst", 0, 1);
+ test(S("abcdefghij"), 1, 1, "abcdefghijklmnopqrst", 1, 1);
+ test(S("abcdefghij"), 1, 1, "abcdefghijklmnopqrst", 10, 1);
+ test(S("abcdefghij"), 1, 1, "abcdefghijklmnopqrst", 19, 1);
+ test(S("abcdefghij"), 1, 1, "abcdefghijklmnopqrst", 20, 1);
+ test(S("abcdefghij"), 1, 4, "", 0, 4);
+ test(S("abcdefghij"), 1, 4, "abcde", 0, 4);
+ test(S("abcdefghij"), 1, 4, "abcde", 1, 1);
+ test(S("abcdefghij"), 1, 4, "abcde", 2, 1);
+ test(S("abcdefghij"), 1, 4, "abcde", 4, 1);
+ test(S("abcdefghij"), 1, 4, "abcde", 5, 1);
+ test(S("abcdefghij"), 1, 4, "abcdefghij", 0, 4);
+ test(S("abcdefghij"), 1, 4, "abcdefghij", 1, 1);
+ test(S("abcdefghij"), 1, 4, "abcdefghij", 5, 1);
+ test(S("abcdefghij"), 1, 4, "abcdefghij", 9, 1);
+ test(S("abcdefghij"), 1, 4, "abcdefghij", 10, 1);
+ test(S("abcdefghij"), 1, 4, "abcdefghijklmnopqrst", 0, 4);
+ test(S("abcdefghij"), 1, 4, "abcdefghijklmnopqrst", 1, 1);
+ test(S("abcdefghij"), 1, 4, "abcdefghijklmnopqrst", 10, 1);
+ test(S("abcdefghij"), 1, 4, "abcdefghijklmnopqrst", 19, 1);
+ test(S("abcdefghij"), 1, 4, "abcdefghijklmnopqrst", 20, 1);
+ test(S("abcdefghij"), 1, 8, "", 0, 8);
+ test(S("abcdefghij"), 1, 8, "abcde", 0, 8);
+ test(S("abcdefghij"), 1, 8, "abcde", 1, 1);
+ test(S("abcdefghij"), 1, 8, "abcde", 2, 1);
+ test(S("abcdefghij"), 1, 8, "abcde", 4, 1);
+ test(S("abcdefghij"), 1, 8, "abcde", 5, 1);
+ test(S("abcdefghij"), 1, 8, "abcdefghij", 0, 8);
+ test(S("abcdefghij"), 1, 8, "abcdefghij", 1, 1);
+ test(S("abcdefghij"), 1, 8, "abcdefghij", 5, 1);
+ test(S("abcdefghij"), 1, 8, "abcdefghij", 9, 1);
+ test(S("abcdefghij"), 1, 8, "abcdefghij", 10, 1);
+ test(S("abcdefghij"), 1, 8, "abcdefghijklmnopqrst", 0, 8);
+ test(S("abcdefghij"), 1, 8, "abcdefghijklmnopqrst", 1, 1);
+ test(S("abcdefghij"), 1, 8, "abcdefghijklmnopqrst", 10, 1);
+ test(S("abcdefghij"), 1, 8, "abcdefghijklmnopqrst", 19, 1);
+ test(S("abcdefghij"), 1, 8, "abcdefghijklmnopqrst", 20, 1);
+ test(S("abcdefghij"), 1, 9, "", 0, 9);
+ test(S("abcdefghij"), 1, 9, "abcde", 0, 9);
+ test(S("abcdefghij"), 1, 9, "abcde", 1, 1);
+ test(S("abcdefghij"), 1, 9, "abcde", 2, 1);
+ test(S("abcdefghij"), 1, 9, "abcde", 4, 1);
+ test(S("abcdefghij"), 1, 9, "abcde", 5, 1);
+ test(S("abcdefghij"), 1, 9, "abcdefghij", 0, 9);
+ test(S("abcdefghij"), 1, 9, "abcdefghij", 1, 1);
+ test(S("abcdefghij"), 1, 9, "abcdefghij", 5, 1);
+ test(S("abcdefghij"), 1, 9, "abcdefghij", 9, 1);
+ test(S("abcdefghij"), 1, 9, "abcdefghij", 10, 1);
+ test(S("abcdefghij"), 1, 9, "abcdefghijklmnopqrst", 0, 9);
+ test(S("abcdefghij"), 1, 9, "abcdefghijklmnopqrst", 1, 1);
+ test(S("abcdefghij"), 1, 9, "abcdefghijklmnopqrst", 10, 1);
+ test(S("abcdefghij"), 1, 9, "abcdefghijklmnopqrst", 19, 1);
+ test(S("abcdefghij"), 1, 9, "abcdefghijklmnopqrst", 20, 1);
+ test(S("abcdefghij"), 1, 10, "", 0, 9);
+ test(S("abcdefghij"), 1, 10, "abcde", 0, 9);
+ test(S("abcdefghij"), 1, 10, "abcde", 1, 1);
+ test(S("abcdefghij"), 1, 10, "abcde", 2, 1);
+ test(S("abcdefghij"), 1, 10, "abcde", 4, 1);
+ test(S("abcdefghij"), 1, 10, "abcde", 5, 1);
+ test(S("abcdefghij"), 1, 10, "abcdefghij", 0, 9);
+ test(S("abcdefghij"), 1, 10, "abcdefghij", 1, 1);
+}
+
+template <class S>
+void test6()
+{
+ test(S("abcdefghij"), 1, 10, "abcdefghij", 5, 1);
+ test(S("abcdefghij"), 1, 10, "abcdefghij", 9, 1);
+ test(S("abcdefghij"), 1, 10, "abcdefghij", 10, 1);
+ test(S("abcdefghij"), 1, 10, "abcdefghijklmnopqrst", 0, 9);
+ test(S("abcdefghij"), 1, 10, "abcdefghijklmnopqrst", 1, 1);
+ test(S("abcdefghij"), 1, 10, "abcdefghijklmnopqrst", 10, 1);
+ test(S("abcdefghij"), 1, 10, "abcdefghijklmnopqrst", 19, 1);
+ test(S("abcdefghij"), 1, 10, "abcdefghijklmnopqrst", 20, 1);
+ test(S("abcdefghij"), 5, 0, "", 0, 0);
+ test(S("abcdefghij"), 5, 0, "abcde", 0, 0);
+ test(S("abcdefghij"), 5, 0, "abcde", 1, -1);
+ test(S("abcdefghij"), 5, 0, "abcde", 2, -2);
+ test(S("abcdefghij"), 5, 0, "abcde", 4, -4);
+ test(S("abcdefghij"), 5, 0, "abcde", 5, -5);
+ test(S("abcdefghij"), 5, 0, "abcdefghij", 0, 0);
+ test(S("abcdefghij"), 5, 0, "abcdefghij", 1, -1);
+ test(S("abcdefghij"), 5, 0, "abcdefghij", 5, -5);
+ test(S("abcdefghij"), 5, 0, "abcdefghij", 9, -9);
+ test(S("abcdefghij"), 5, 0, "abcdefghij", 10, -10);
+ test(S("abcdefghij"), 5, 0, "abcdefghijklmnopqrst", 0, 0);
+ test(S("abcdefghij"), 5, 0, "abcdefghijklmnopqrst", 1, -1);
+ test(S("abcdefghij"), 5, 0, "abcdefghijklmnopqrst", 10, -10);
+ test(S("abcdefghij"), 5, 0, "abcdefghijklmnopqrst", 19, -19);
+ test(S("abcdefghij"), 5, 0, "abcdefghijklmnopqrst", 20, -20);
+ test(S("abcdefghij"), 5, 1, "", 0, 1);
+ test(S("abcdefghij"), 5, 1, "abcde", 0, 1);
+ test(S("abcdefghij"), 5, 1, "abcde", 1, 5);
+ test(S("abcdefghij"), 5, 1, "abcde", 2, 5);
+ test(S("abcdefghij"), 5, 1, "abcde", 4, 5);
+ test(S("abcdefghij"), 5, 1, "abcde", 5, 5);
+ test(S("abcdefghij"), 5, 1, "abcdefghij", 0, 1);
+ test(S("abcdefghij"), 5, 1, "abcdefghij", 1, 5);
+ test(S("abcdefghij"), 5, 1, "abcdefghij", 5, 5);
+ test(S("abcdefghij"), 5, 1, "abcdefghij", 9, 5);
+ test(S("abcdefghij"), 5, 1, "abcdefghij", 10, 5);
+ test(S("abcdefghij"), 5, 1, "abcdefghijklmnopqrst", 0, 1);
+ test(S("abcdefghij"), 5, 1, "abcdefghijklmnopqrst", 1, 5);
+ test(S("abcdefghij"), 5, 1, "abcdefghijklmnopqrst", 10, 5);
+ test(S("abcdefghij"), 5, 1, "abcdefghijklmnopqrst", 19, 5);
+ test(S("abcdefghij"), 5, 1, "abcdefghijklmnopqrst", 20, 5);
+ test(S("abcdefghij"), 5, 2, "", 0, 2);
+ test(S("abcdefghij"), 5, 2, "abcde", 0, 2);
+ test(S("abcdefghij"), 5, 2, "abcde", 1, 5);
+ test(S("abcdefghij"), 5, 2, "abcde", 2, 5);
+ test(S("abcdefghij"), 5, 2, "abcde", 4, 5);
+ test(S("abcdefghij"), 5, 2, "abcde", 5, 5);
+ test(S("abcdefghij"), 5, 2, "abcdefghij", 0, 2);
+ test(S("abcdefghij"), 5, 2, "abcdefghij", 1, 5);
+ test(S("abcdefghij"), 5, 2, "abcdefghij", 5, 5);
+ test(S("abcdefghij"), 5, 2, "abcdefghij", 9, 5);
+ test(S("abcdefghij"), 5, 2, "abcdefghij", 10, 5);
+ test(S("abcdefghij"), 5, 2, "abcdefghijklmnopqrst", 0, 2);
+ test(S("abcdefghij"), 5, 2, "abcdefghijklmnopqrst", 1, 5);
+ test(S("abcdefghij"), 5, 2, "abcdefghijklmnopqrst", 10, 5);
+ test(S("abcdefghij"), 5, 2, "abcdefghijklmnopqrst", 19, 5);
+ test(S("abcdefghij"), 5, 2, "abcdefghijklmnopqrst", 20, 5);
+ test(S("abcdefghij"), 5, 4, "", 0, 4);
+ test(S("abcdefghij"), 5, 4, "abcde", 0, 4);
+ test(S("abcdefghij"), 5, 4, "abcde", 1, 5);
+ test(S("abcdefghij"), 5, 4, "abcde", 2, 5);
+ test(S("abcdefghij"), 5, 4, "abcde", 4, 5);
+ test(S("abcdefghij"), 5, 4, "abcde", 5, 5);
+ test(S("abcdefghij"), 5, 4, "abcdefghij", 0, 4);
+ test(S("abcdefghij"), 5, 4, "abcdefghij", 1, 5);
+ test(S("abcdefghij"), 5, 4, "abcdefghij", 5, 5);
+ test(S("abcdefghij"), 5, 4, "abcdefghij", 9, 5);
+ test(S("abcdefghij"), 5, 4, "abcdefghij", 10, 5);
+ test(S("abcdefghij"), 5, 4, "abcdefghijklmnopqrst", 0, 4);
+ test(S("abcdefghij"), 5, 4, "abcdefghijklmnopqrst", 1, 5);
+ test(S("abcdefghij"), 5, 4, "abcdefghijklmnopqrst", 10, 5);
+ test(S("abcdefghij"), 5, 4, "abcdefghijklmnopqrst", 19, 5);
+ test(S("abcdefghij"), 5, 4, "abcdefghijklmnopqrst", 20, 5);
+ test(S("abcdefghij"), 5, 5, "", 0, 5);
+ test(S("abcdefghij"), 5, 5, "abcde", 0, 5);
+ test(S("abcdefghij"), 5, 5, "abcde", 1, 5);
+ test(S("abcdefghij"), 5, 5, "abcde", 2, 5);
+ test(S("abcdefghij"), 5, 5, "abcde", 4, 5);
+ test(S("abcdefghij"), 5, 5, "abcde", 5, 5);
+ test(S("abcdefghij"), 5, 5, "abcdefghij", 0, 5);
+ test(S("abcdefghij"), 5, 5, "abcdefghij", 1, 5);
+ test(S("abcdefghij"), 5, 5, "abcdefghij", 5, 5);
+ test(S("abcdefghij"), 5, 5, "abcdefghij", 9, 5);
+ test(S("abcdefghij"), 5, 5, "abcdefghij", 10, 5);
+ test(S("abcdefghij"), 5, 5, "abcdefghijklmnopqrst", 0, 5);
+ test(S("abcdefghij"), 5, 5, "abcdefghijklmnopqrst", 1, 5);
+ test(S("abcdefghij"), 5, 5, "abcdefghijklmnopqrst", 10, 5);
+ test(S("abcdefghij"), 5, 5, "abcdefghijklmnopqrst", 19, 5);
+ test(S("abcdefghij"), 5, 5, "abcdefghijklmnopqrst", 20, 5);
+ test(S("abcdefghij"), 5, 6, "", 0, 5);
+ test(S("abcdefghij"), 5, 6, "abcde", 0, 5);
+ test(S("abcdefghij"), 5, 6, "abcde", 1, 5);
+ test(S("abcdefghij"), 5, 6, "abcde", 2, 5);
+ test(S("abcdefghij"), 5, 6, "abcde", 4, 5);
+ test(S("abcdefghij"), 5, 6, "abcde", 5, 5);
+ test(S("abcdefghij"), 5, 6, "abcdefghij", 0, 5);
+ test(S("abcdefghij"), 5, 6, "abcdefghij", 1, 5);
+ test(S("abcdefghij"), 5, 6, "abcdefghij", 5, 5);
+ test(S("abcdefghij"), 5, 6, "abcdefghij", 9, 5);
+ test(S("abcdefghij"), 5, 6, "abcdefghij", 10, 5);
+ test(S("abcdefghij"), 5, 6, "abcdefghijklmnopqrst", 0, 5);
+}
+
+template <class S>
+void test7()
+{
+ test(S("abcdefghij"), 5, 6, "abcdefghijklmnopqrst", 1, 5);
+ test(S("abcdefghij"), 5, 6, "abcdefghijklmnopqrst", 10, 5);
+ test(S("abcdefghij"), 5, 6, "abcdefghijklmnopqrst", 19, 5);
+ test(S("abcdefghij"), 5, 6, "abcdefghijklmnopqrst", 20, 5);
+ test(S("abcdefghij"), 9, 0, "", 0, 0);
+ test(S("abcdefghij"), 9, 0, "abcde", 0, 0);
+ test(S("abcdefghij"), 9, 0, "abcde", 1, -1);
+ test(S("abcdefghij"), 9, 0, "abcde", 2, -2);
+ test(S("abcdefghij"), 9, 0, "abcde", 4, -4);
+ test(S("abcdefghij"), 9, 0, "abcde", 5, -5);
+ test(S("abcdefghij"), 9, 0, "abcdefghij", 0, 0);
+ test(S("abcdefghij"), 9, 0, "abcdefghij", 1, -1);
+ test(S("abcdefghij"), 9, 0, "abcdefghij", 5, -5);
+ test(S("abcdefghij"), 9, 0, "abcdefghij", 9, -9);
+ test(S("abcdefghij"), 9, 0, "abcdefghij", 10, -10);
+ test(S("abcdefghij"), 9, 0, "abcdefghijklmnopqrst", 0, 0);
+ test(S("abcdefghij"), 9, 0, "abcdefghijklmnopqrst", 1, -1);
+ test(S("abcdefghij"), 9, 0, "abcdefghijklmnopqrst", 10, -10);
+ test(S("abcdefghij"), 9, 0, "abcdefghijklmnopqrst", 19, -19);
+ test(S("abcdefghij"), 9, 0, "abcdefghijklmnopqrst", 20, -20);
+ test(S("abcdefghij"), 9, 1, "", 0, 1);
+ test(S("abcdefghij"), 9, 1, "abcde", 0, 1);
+ test(S("abcdefghij"), 9, 1, "abcde", 1, 9);
+ test(S("abcdefghij"), 9, 1, "abcde", 2, 9);
+ test(S("abcdefghij"), 9, 1, "abcde", 4, 9);
+ test(S("abcdefghij"), 9, 1, "abcde", 5, 9);
+ test(S("abcdefghij"), 9, 1, "abcdefghij", 0, 1);
+ test(S("abcdefghij"), 9, 1, "abcdefghij", 1, 9);
+ test(S("abcdefghij"), 9, 1, "abcdefghij", 5, 9);
+ test(S("abcdefghij"), 9, 1, "abcdefghij", 9, 9);
+ test(S("abcdefghij"), 9, 1, "abcdefghij", 10, 9);
+ test(S("abcdefghij"), 9, 1, "abcdefghijklmnopqrst", 0, 1);
+ test(S("abcdefghij"), 9, 1, "abcdefghijklmnopqrst", 1, 9);
+ test(S("abcdefghij"), 9, 1, "abcdefghijklmnopqrst", 10, 9);
+ test(S("abcdefghij"), 9, 1, "abcdefghijklmnopqrst", 19, 9);
+ test(S("abcdefghij"), 9, 1, "abcdefghijklmnopqrst", 20, 9);
+ test(S("abcdefghij"), 9, 2, "", 0, 1);
+ test(S("abcdefghij"), 9, 2, "abcde", 0, 1);
+ test(S("abcdefghij"), 9, 2, "abcde", 1, 9);
+ test(S("abcdefghij"), 9, 2, "abcde", 2, 9);
+ test(S("abcdefghij"), 9, 2, "abcde", 4, 9);
+ test(S("abcdefghij"), 9, 2, "abcde", 5, 9);
+ test(S("abcdefghij"), 9, 2, "abcdefghij", 0, 1);
+ test(S("abcdefghij"), 9, 2, "abcdefghij", 1, 9);
+ test(S("abcdefghij"), 9, 2, "abcdefghij", 5, 9);
+ test(S("abcdefghij"), 9, 2, "abcdefghij", 9, 9);
+ test(S("abcdefghij"), 9, 2, "abcdefghij", 10, 9);
+ test(S("abcdefghij"), 9, 2, "abcdefghijklmnopqrst", 0, 1);
+ test(S("abcdefghij"), 9, 2, "abcdefghijklmnopqrst", 1, 9);
+ test(S("abcdefghij"), 9, 2, "abcdefghijklmnopqrst", 10, 9);
+ test(S("abcdefghij"), 9, 2, "abcdefghijklmnopqrst", 19, 9);
+ test(S("abcdefghij"), 9, 2, "abcdefghijklmnopqrst", 20, 9);
+ test(S("abcdefghij"), 10, 0, "", 0, 0);
+ test(S("abcdefghij"), 10, 0, "abcde", 0, 0);
+ test(S("abcdefghij"), 10, 0, "abcde", 1, -1);
+ test(S("abcdefghij"), 10, 0, "abcde", 2, -2);
+ test(S("abcdefghij"), 10, 0, "abcde", 4, -4);
+ test(S("abcdefghij"), 10, 0, "abcde", 5, -5);
+ test(S("abcdefghij"), 10, 0, "abcdefghij", 0, 0);
+ test(S("abcdefghij"), 10, 0, "abcdefghij", 1, -1);
+ test(S("abcdefghij"), 10, 0, "abcdefghij", 5, -5);
+ test(S("abcdefghij"), 10, 0, "abcdefghij", 9, -9);
+ test(S("abcdefghij"), 10, 0, "abcdefghij", 10, -10);
+ test(S("abcdefghij"), 10, 0, "abcdefghijklmnopqrst", 0, 0);
+ test(S("abcdefghij"), 10, 0, "abcdefghijklmnopqrst", 1, -1);
+ test(S("abcdefghij"), 10, 0, "abcdefghijklmnopqrst", 10, -10);
+ test(S("abcdefghij"), 10, 0, "abcdefghijklmnopqrst", 19, -19);
+ test(S("abcdefghij"), 10, 0, "abcdefghijklmnopqrst", 20, -20);
+ test(S("abcdefghij"), 10, 1, "", 0, 0);
+ test(S("abcdefghij"), 10, 1, "abcde", 0, 0);
+ test(S("abcdefghij"), 10, 1, "abcde", 1, -1);
+ test(S("abcdefghij"), 10, 1, "abcde", 2, -2);
+ test(S("abcdefghij"), 10, 1, "abcde", 4, -4);
+ test(S("abcdefghij"), 10, 1, "abcde", 5, -5);
+ test(S("abcdefghij"), 10, 1, "abcdefghij", 0, 0);
+ test(S("abcdefghij"), 10, 1, "abcdefghij", 1, -1);
+ test(S("abcdefghij"), 10, 1, "abcdefghij", 5, -5);
+ test(S("abcdefghij"), 10, 1, "abcdefghij", 9, -9);
+ test(S("abcdefghij"), 10, 1, "abcdefghij", 10, -10);
+ test(S("abcdefghij"), 10, 1, "abcdefghijklmnopqrst", 0, 0);
+ test(S("abcdefghij"), 10, 1, "abcdefghijklmnopqrst", 1, -1);
+ test(S("abcdefghij"), 10, 1, "abcdefghijklmnopqrst", 10, -10);
+ test(S("abcdefghij"), 10, 1, "abcdefghijklmnopqrst", 19, -19);
+ test(S("abcdefghij"), 10, 1, "abcdefghijklmnopqrst", 20, -20);
+ test(S("abcdefghij"), 11, 0, "", 0, 0);
+ test(S("abcdefghij"), 11, 0, "abcde", 0, 0);
+ test(S("abcdefghij"), 11, 0, "abcde", 1, 0);
+ test(S("abcdefghij"), 11, 0, "abcde", 2, 0);
+ test(S("abcdefghij"), 11, 0, "abcde", 4, 0);
+ test(S("abcdefghij"), 11, 0, "abcde", 5, 0);
+ test(S("abcdefghij"), 11, 0, "abcdefghij", 0, 0);
+ test(S("abcdefghij"), 11, 0, "abcdefghij", 1, 0);
+ test(S("abcdefghij"), 11, 0, "abcdefghij", 5, 0);
+ test(S("abcdefghij"), 11, 0, "abcdefghij", 9, 0);
+ test(S("abcdefghij"), 11, 0, "abcdefghij", 10, 0);
+ test(S("abcdefghij"), 11, 0, "abcdefghijklmnopqrst", 0, 0);
+ test(S("abcdefghij"), 11, 0, "abcdefghijklmnopqrst", 1, 0);
+ test(S("abcdefghij"), 11, 0, "abcdefghijklmnopqrst", 10, 0);
+ test(S("abcdefghij"), 11, 0, "abcdefghijklmnopqrst", 19, 0);
+ test(S("abcdefghij"), 11, 0, "abcdefghijklmnopqrst", 20, 0);
+}
+
+template <class S>
+void test8()
+{
+ test(S("abcdefghijklmnopqrst"), 0, 0, "", 0, 0);
+ test(S("abcdefghijklmnopqrst"), 0, 0, "abcde", 0, 0);
+ test(S("abcdefghijklmnopqrst"), 0, 0, "abcde", 1, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 0, "abcde", 2, -2);
+ test(S("abcdefghijklmnopqrst"), 0, 0, "abcde", 4, -4);
+ test(S("abcdefghijklmnopqrst"), 0, 0, "abcde", 5, -5);
+ test(S("abcdefghijklmnopqrst"), 0, 0, "abcdefghij", 0, 0);
+ test(S("abcdefghijklmnopqrst"), 0, 0, "abcdefghij", 1, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 0, "abcdefghij", 5, -5);
+ test(S("abcdefghijklmnopqrst"), 0, 0, "abcdefghij", 9, -9);
+ test(S("abcdefghijklmnopqrst"), 0, 0, "abcdefghij", 10, -10);
+ test(S("abcdefghijklmnopqrst"), 0, 0, "abcdefghijklmnopqrst", 0, 0);
+ test(S("abcdefghijklmnopqrst"), 0, 0, "abcdefghijklmnopqrst", 1, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 0, "abcdefghijklmnopqrst", 10, -10);
+ test(S("abcdefghijklmnopqrst"), 0, 0, "abcdefghijklmnopqrst", 19, -19);
+ test(S("abcdefghijklmnopqrst"), 0, 0, "abcdefghijklmnopqrst", 20, -20);
+ test(S("abcdefghijklmnopqrst"), 0, 1, "", 0, 1);
+ test(S("abcdefghijklmnopqrst"), 0, 1, "abcde", 0, 1);
+ test(S("abcdefghijklmnopqrst"), 0, 1, "abcde", 1, 0);
+ test(S("abcdefghijklmnopqrst"), 0, 1, "abcde", 2, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 1, "abcde", 4, -3);
+ test(S("abcdefghijklmnopqrst"), 0, 1, "abcde", 5, -4);
+ test(S("abcdefghijklmnopqrst"), 0, 1, "abcdefghij", 0, 1);
+ test(S("abcdefghijklmnopqrst"), 0, 1, "abcdefghij", 1, 0);
+ test(S("abcdefghijklmnopqrst"), 0, 1, "abcdefghij", 5, -4);
+ test(S("abcdefghijklmnopqrst"), 0, 1, "abcdefghij", 9, -8);
+ test(S("abcdefghijklmnopqrst"), 0, 1, "abcdefghij", 10, -9);
+ test(S("abcdefghijklmnopqrst"), 0, 1, "abcdefghijklmnopqrst", 0, 1);
+ test(S("abcdefghijklmnopqrst"), 0, 1, "abcdefghijklmnopqrst", 1, 0);
+ test(S("abcdefghijklmnopqrst"), 0, 1, "abcdefghijklmnopqrst", 10, -9);
+ test(S("abcdefghijklmnopqrst"), 0, 1, "abcdefghijklmnopqrst", 19, -18);
+ test(S("abcdefghijklmnopqrst"), 0, 1, "abcdefghijklmnopqrst", 20, -19);
+ test(S("abcdefghijklmnopqrst"), 0, 10, "", 0, 10);
+ test(S("abcdefghijklmnopqrst"), 0, 10, "abcde", 0, 10);
+ test(S("abcdefghijklmnopqrst"), 0, 10, "abcde", 1, 9);
+ test(S("abcdefghijklmnopqrst"), 0, 10, "abcde", 2, 8);
+ test(S("abcdefghijklmnopqrst"), 0, 10, "abcde", 4, 6);
+ test(S("abcdefghijklmnopqrst"), 0, 10, "abcde", 5, 5);
+ test(S("abcdefghijklmnopqrst"), 0, 10, "abcdefghij", 0, 10);
+ test(S("abcdefghijklmnopqrst"), 0, 10, "abcdefghij", 1, 9);
+ test(S("abcdefghijklmnopqrst"), 0, 10, "abcdefghij", 5, 5);
+ test(S("abcdefghijklmnopqrst"), 0, 10, "abcdefghij", 9, 1);
+ test(S("abcdefghijklmnopqrst"), 0, 10, "abcdefghij", 10, 0);
+ test(S("abcdefghijklmnopqrst"), 0, 10, "abcdefghijklmnopqrst", 0, 10);
+ test(S("abcdefghijklmnopqrst"), 0, 10, "abcdefghijklmnopqrst", 1, 9);
+ test(S("abcdefghijklmnopqrst"), 0, 10, "abcdefghijklmnopqrst", 10, 0);
+ test(S("abcdefghijklmnopqrst"), 0, 10, "abcdefghijklmnopqrst", 19, -9);
+ test(S("abcdefghijklmnopqrst"), 0, 10, "abcdefghijklmnopqrst", 20, -10);
+ test(S("abcdefghijklmnopqrst"), 0, 19, "", 0, 19);
+ test(S("abcdefghijklmnopqrst"), 0, 19, "abcde", 0, 19);
+ test(S("abcdefghijklmnopqrst"), 0, 19, "abcde", 1, 18);
+ test(S("abcdefghijklmnopqrst"), 0, 19, "abcde", 2, 17);
+ test(S("abcdefghijklmnopqrst"), 0, 19, "abcde", 4, 15);
+ test(S("abcdefghijklmnopqrst"), 0, 19, "abcde", 5, 14);
+ test(S("abcdefghijklmnopqrst"), 0, 19, "abcdefghij", 0, 19);
+ test(S("abcdefghijklmnopqrst"), 0, 19, "abcdefghij", 1, 18);
+ test(S("abcdefghijklmnopqrst"), 0, 19, "abcdefghij", 5, 14);
+ test(S("abcdefghijklmnopqrst"), 0, 19, "abcdefghij", 9, 10);
+ test(S("abcdefghijklmnopqrst"), 0, 19, "abcdefghij", 10, 9);
+ test(S("abcdefghijklmnopqrst"), 0, 19, "abcdefghijklmnopqrst", 0, 19);
+ test(S("abcdefghijklmnopqrst"), 0, 19, "abcdefghijklmnopqrst", 1, 18);
+ test(S("abcdefghijklmnopqrst"), 0, 19, "abcdefghijklmnopqrst", 10, 9);
+ test(S("abcdefghijklmnopqrst"), 0, 19, "abcdefghijklmnopqrst", 19, 0);
+ test(S("abcdefghijklmnopqrst"), 0, 19, "abcdefghijklmnopqrst", 20, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 20, "", 0, 20);
+ test(S("abcdefghijklmnopqrst"), 0, 20, "abcde", 0, 20);
+ test(S("abcdefghijklmnopqrst"), 0, 20, "abcde", 1, 19);
+ test(S("abcdefghijklmnopqrst"), 0, 20, "abcde", 2, 18);
+ test(S("abcdefghijklmnopqrst"), 0, 20, "abcde", 4, 16);
+ test(S("abcdefghijklmnopqrst"), 0, 20, "abcde", 5, 15);
+ test(S("abcdefghijklmnopqrst"), 0, 20, "abcdefghij", 0, 20);
+ test(S("abcdefghijklmnopqrst"), 0, 20, "abcdefghij", 1, 19);
+ test(S("abcdefghijklmnopqrst"), 0, 20, "abcdefghij", 5, 15);
+ test(S("abcdefghijklmnopqrst"), 0, 20, "abcdefghij", 9, 11);
+ test(S("abcdefghijklmnopqrst"), 0, 20, "abcdefghij", 10, 10);
+ test(S("abcdefghijklmnopqrst"), 0, 20, "abcdefghijklmnopqrst", 0, 20);
+ test(S("abcdefghijklmnopqrst"), 0, 20, "abcdefghijklmnopqrst", 1, 19);
+ test(S("abcdefghijklmnopqrst"), 0, 20, "abcdefghijklmnopqrst", 10, 10);
+ test(S("abcdefghijklmnopqrst"), 0, 20, "abcdefghijklmnopqrst", 19, 1);
+ test(S("abcdefghijklmnopqrst"), 0, 20, "abcdefghijklmnopqrst", 20, 0);
+ test(S("abcdefghijklmnopqrst"), 0, 21, "", 0, 20);
+ test(S("abcdefghijklmnopqrst"), 0, 21, "abcde", 0, 20);
+ test(S("abcdefghijklmnopqrst"), 0, 21, "abcde", 1, 19);
+ test(S("abcdefghijklmnopqrst"), 0, 21, "abcde", 2, 18);
+ test(S("abcdefghijklmnopqrst"), 0, 21, "abcde", 4, 16);
+ test(S("abcdefghijklmnopqrst"), 0, 21, "abcde", 5, 15);
+ test(S("abcdefghijklmnopqrst"), 0, 21, "abcdefghij", 0, 20);
+ test(S("abcdefghijklmnopqrst"), 0, 21, "abcdefghij", 1, 19);
+ test(S("abcdefghijklmnopqrst"), 0, 21, "abcdefghij", 5, 15);
+ test(S("abcdefghijklmnopqrst"), 0, 21, "abcdefghij", 9, 11);
+ test(S("abcdefghijklmnopqrst"), 0, 21, "abcdefghij", 10, 10);
+ test(S("abcdefghijklmnopqrst"), 0, 21, "abcdefghijklmnopqrst", 0, 20);
+ test(S("abcdefghijklmnopqrst"), 0, 21, "abcdefghijklmnopqrst", 1, 19);
+ test(S("abcdefghijklmnopqrst"), 0, 21, "abcdefghijklmnopqrst", 10, 10);
+ test(S("abcdefghijklmnopqrst"), 0, 21, "abcdefghijklmnopqrst", 19, 1);
+ test(S("abcdefghijklmnopqrst"), 0, 21, "abcdefghijklmnopqrst", 20, 0);
+ test(S("abcdefghijklmnopqrst"), 1, 0, "", 0, 0);
+ test(S("abcdefghijklmnopqrst"), 1, 0, "abcde", 0, 0);
+ test(S("abcdefghijklmnopqrst"), 1, 0, "abcde", 1, -1);
+ test(S("abcdefghijklmnopqrst"), 1, 0, "abcde", 2, -2);
+}
+
+template <class S>
+void test9()
+{
+ test(S("abcdefghijklmnopqrst"), 1, 0, "abcde", 4, -4);
+ test(S("abcdefghijklmnopqrst"), 1, 0, "abcde", 5, -5);
+ test(S("abcdefghijklmnopqrst"), 1, 0, "abcdefghij", 0, 0);
+ test(S("abcdefghijklmnopqrst"), 1, 0, "abcdefghij", 1, -1);
+ test(S("abcdefghijklmnopqrst"), 1, 0, "abcdefghij", 5, -5);
+ test(S("abcdefghijklmnopqrst"), 1, 0, "abcdefghij", 9, -9);
+ test(S("abcdefghijklmnopqrst"), 1, 0, "abcdefghij", 10, -10);
+ test(S("abcdefghijklmnopqrst"), 1, 0, "abcdefghijklmnopqrst", 0, 0);
+ test(S("abcdefghijklmnopqrst"), 1, 0, "abcdefghijklmnopqrst", 1, -1);
+ test(S("abcdefghijklmnopqrst"), 1, 0, "abcdefghijklmnopqrst", 10, -10);
+ test(S("abcdefghijklmnopqrst"), 1, 0, "abcdefghijklmnopqrst", 19, -19);
+ test(S("abcdefghijklmnopqrst"), 1, 0, "abcdefghijklmnopqrst", 20, -20);
+ test(S("abcdefghijklmnopqrst"), 1, 1, "", 0, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 1, "abcde", 0, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 1, "abcde", 1, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 1, "abcde", 2, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 1, "abcde", 4, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 1, "abcde", 5, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 1, "abcdefghij", 0, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 1, "abcdefghij", 1, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 1, "abcdefghij", 5, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 1, "abcdefghij", 9, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 1, "abcdefghij", 10, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 1, "abcdefghijklmnopqrst", 0, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 1, "abcdefghijklmnopqrst", 1, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 1, "abcdefghijklmnopqrst", 10, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 1, "abcdefghijklmnopqrst", 19, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 1, "abcdefghijklmnopqrst", 20, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 9, "", 0, 9);
+ test(S("abcdefghijklmnopqrst"), 1, 9, "abcde", 0, 9);
+ test(S("abcdefghijklmnopqrst"), 1, 9, "abcde", 1, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 9, "abcde", 2, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 9, "abcde", 4, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 9, "abcde", 5, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 9, "abcdefghij", 0, 9);
+ test(S("abcdefghijklmnopqrst"), 1, 9, "abcdefghij", 1, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 9, "abcdefghij", 5, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 9, "abcdefghij", 9, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 9, "abcdefghij", 10, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 9, "abcdefghijklmnopqrst", 0, 9);
+ test(S("abcdefghijklmnopqrst"), 1, 9, "abcdefghijklmnopqrst", 1, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 9, "abcdefghijklmnopqrst", 10, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 9, "abcdefghijklmnopqrst", 19, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 9, "abcdefghijklmnopqrst", 20, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 18, "", 0, 18);
+ test(S("abcdefghijklmnopqrst"), 1, 18, "abcde", 0, 18);
+ test(S("abcdefghijklmnopqrst"), 1, 18, "abcde", 1, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 18, "abcde", 2, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 18, "abcde", 4, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 18, "abcde", 5, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 18, "abcdefghij", 0, 18);
+ test(S("abcdefghijklmnopqrst"), 1, 18, "abcdefghij", 1, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 18, "abcdefghij", 5, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 18, "abcdefghij", 9, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 18, "abcdefghij", 10, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 18, "abcdefghijklmnopqrst", 0, 18);
+ test(S("abcdefghijklmnopqrst"), 1, 18, "abcdefghijklmnopqrst", 1, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 18, "abcdefghijklmnopqrst", 10, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 18, "abcdefghijklmnopqrst", 19, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 18, "abcdefghijklmnopqrst", 20, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 19, "", 0, 19);
+ test(S("abcdefghijklmnopqrst"), 1, 19, "abcde", 0, 19);
+ test(S("abcdefghijklmnopqrst"), 1, 19, "abcde", 1, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 19, "abcde", 2, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 19, "abcde", 4, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 19, "abcde", 5, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 19, "abcdefghij", 0, 19);
+ test(S("abcdefghijklmnopqrst"), 1, 19, "abcdefghij", 1, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 19, "abcdefghij", 5, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 19, "abcdefghij", 9, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 19, "abcdefghij", 10, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 19, "abcdefghijklmnopqrst", 0, 19);
+ test(S("abcdefghijklmnopqrst"), 1, 19, "abcdefghijklmnopqrst", 1, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 19, "abcdefghijklmnopqrst", 10, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 19, "abcdefghijklmnopqrst", 19, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 19, "abcdefghijklmnopqrst", 20, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 20, "", 0, 19);
+ test(S("abcdefghijklmnopqrst"), 1, 20, "abcde", 0, 19);
+ test(S("abcdefghijklmnopqrst"), 1, 20, "abcde", 1, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 20, "abcde", 2, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 20, "abcde", 4, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 20, "abcde", 5, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 20, "abcdefghij", 0, 19);
+ test(S("abcdefghijklmnopqrst"), 1, 20, "abcdefghij", 1, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 20, "abcdefghij", 5, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 20, "abcdefghij", 9, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 20, "abcdefghij", 10, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 20, "abcdefghijklmnopqrst", 0, 19);
+ test(S("abcdefghijklmnopqrst"), 1, 20, "abcdefghijklmnopqrst", 1, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 20, "abcdefghijklmnopqrst", 10, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 20, "abcdefghijklmnopqrst", 19, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 20, "abcdefghijklmnopqrst", 20, 1);
+ test(S("abcdefghijklmnopqrst"), 10, 0, "", 0, 0);
+ test(S("abcdefghijklmnopqrst"), 10, 0, "abcde", 0, 0);
+ test(S("abcdefghijklmnopqrst"), 10, 0, "abcde", 1, -1);
+ test(S("abcdefghijklmnopqrst"), 10, 0, "abcde", 2, -2);
+ test(S("abcdefghijklmnopqrst"), 10, 0, "abcde", 4, -4);
+ test(S("abcdefghijklmnopqrst"), 10, 0, "abcde", 5, -5);
+ test(S("abcdefghijklmnopqrst"), 10, 0, "abcdefghij", 0, 0);
+ test(S("abcdefghijklmnopqrst"), 10, 0, "abcdefghij", 1, -1);
+}
+
+template <class S>
+void test10()
+{
+ test(S("abcdefghijklmnopqrst"), 10, 0, "abcdefghij", 5, -5);
+ test(S("abcdefghijklmnopqrst"), 10, 0, "abcdefghij", 9, -9);
+ test(S("abcdefghijklmnopqrst"), 10, 0, "abcdefghij", 10, -10);
+ test(S("abcdefghijklmnopqrst"), 10, 0, "abcdefghijklmnopqrst", 0, 0);
+ test(S("abcdefghijklmnopqrst"), 10, 0, "abcdefghijklmnopqrst", 1, -1);
+ test(S("abcdefghijklmnopqrst"), 10, 0, "abcdefghijklmnopqrst", 10, -10);
+ test(S("abcdefghijklmnopqrst"), 10, 0, "abcdefghijklmnopqrst", 19, -19);
+ test(S("abcdefghijklmnopqrst"), 10, 0, "abcdefghijklmnopqrst", 20, -20);
+ test(S("abcdefghijklmnopqrst"), 10, 1, "", 0, 1);
+ test(S("abcdefghijklmnopqrst"), 10, 1, "abcde", 0, 1);
+ test(S("abcdefghijklmnopqrst"), 10, 1, "abcde", 1, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 1, "abcde", 2, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 1, "abcde", 4, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 1, "abcde", 5, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 1, "abcdefghij", 0, 1);
+ test(S("abcdefghijklmnopqrst"), 10, 1, "abcdefghij", 1, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 1, "abcdefghij", 5, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 1, "abcdefghij", 9, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 1, "abcdefghij", 10, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 1, "abcdefghijklmnopqrst", 0, 1);
+ test(S("abcdefghijklmnopqrst"), 10, 1, "abcdefghijklmnopqrst", 1, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 1, "abcdefghijklmnopqrst", 10, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 1, "abcdefghijklmnopqrst", 19, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 1, "abcdefghijklmnopqrst", 20, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 5, "", 0, 5);
+ test(S("abcdefghijklmnopqrst"), 10, 5, "abcde", 0, 5);
+ test(S("abcdefghijklmnopqrst"), 10, 5, "abcde", 1, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 5, "abcde", 2, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 5, "abcde", 4, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 5, "abcde", 5, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 5, "abcdefghij", 0, 5);
+ test(S("abcdefghijklmnopqrst"), 10, 5, "abcdefghij", 1, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 5, "abcdefghij", 5, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 5, "abcdefghij", 9, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 5, "abcdefghij", 10, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 5, "abcdefghijklmnopqrst", 0, 5);
+ test(S("abcdefghijklmnopqrst"), 10, 5, "abcdefghijklmnopqrst", 1, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 5, "abcdefghijklmnopqrst", 10, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 5, "abcdefghijklmnopqrst", 19, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 5, "abcdefghijklmnopqrst", 20, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 9, "", 0, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 9, "abcde", 0, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 9, "abcde", 1, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 9, "abcde", 2, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 9, "abcde", 4, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 9, "abcde", 5, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 9, "abcdefghij", 0, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 9, "abcdefghij", 1, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 9, "abcdefghij", 5, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 9, "abcdefghij", 9, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 9, "abcdefghij", 10, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 9, "abcdefghijklmnopqrst", 0, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 9, "abcdefghijklmnopqrst", 1, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 9, "abcdefghijklmnopqrst", 10, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 9, "abcdefghijklmnopqrst", 19, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 9, "abcdefghijklmnopqrst", 20, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 10, "", 0, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 10, "abcde", 0, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 10, "abcde", 1, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 10, "abcde", 2, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 10, "abcde", 4, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 10, "abcde", 5, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 10, "abcdefghij", 0, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 10, "abcdefghij", 1, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 10, "abcdefghij", 5, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 10, "abcdefghij", 9, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 10, "abcdefghij", 10, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 10, "abcdefghijklmnopqrst", 0, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 10, "abcdefghijklmnopqrst", 1, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 10, "abcdefghijklmnopqrst", 10, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 10, "abcdefghijklmnopqrst", 19, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 10, "abcdefghijklmnopqrst", 20, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 11, "", 0, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 11, "abcde", 0, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 11, "abcde", 1, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 11, "abcde", 2, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 11, "abcde", 4, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 11, "abcde", 5, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 11, "abcdefghij", 0, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 11, "abcdefghij", 1, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 11, "abcdefghij", 5, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 11, "abcdefghij", 9, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 11, "abcdefghij", 10, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 11, "abcdefghijklmnopqrst", 0, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 11, "abcdefghijklmnopqrst", 1, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 11, "abcdefghijklmnopqrst", 10, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 11, "abcdefghijklmnopqrst", 19, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 11, "abcdefghijklmnopqrst", 20, 10);
+ test(S("abcdefghijklmnopqrst"), 19, 0, "", 0, 0);
+ test(S("abcdefghijklmnopqrst"), 19, 0, "abcde", 0, 0);
+ test(S("abcdefghijklmnopqrst"), 19, 0, "abcde", 1, -1);
+ test(S("abcdefghijklmnopqrst"), 19, 0, "abcde", 2, -2);
+ test(S("abcdefghijklmnopqrst"), 19, 0, "abcde", 4, -4);
+ test(S("abcdefghijklmnopqrst"), 19, 0, "abcde", 5, -5);
+ test(S("abcdefghijklmnopqrst"), 19, 0, "abcdefghij", 0, 0);
+ test(S("abcdefghijklmnopqrst"), 19, 0, "abcdefghij", 1, -1);
+ test(S("abcdefghijklmnopqrst"), 19, 0, "abcdefghij", 5, -5);
+ test(S("abcdefghijklmnopqrst"), 19, 0, "abcdefghij", 9, -9);
+ test(S("abcdefghijklmnopqrst"), 19, 0, "abcdefghij", 10, -10);
+ test(S("abcdefghijklmnopqrst"), 19, 0, "abcdefghijklmnopqrst", 0, 0);
+}
+
+template <class S>
+void test11()
+{
+ test(S("abcdefghijklmnopqrst"), 19, 0, "abcdefghijklmnopqrst", 1, -1);
+ test(S("abcdefghijklmnopqrst"), 19, 0, "abcdefghijklmnopqrst", 10, -10);
+ test(S("abcdefghijklmnopqrst"), 19, 0, "abcdefghijklmnopqrst", 19, -19);
+ test(S("abcdefghijklmnopqrst"), 19, 0, "abcdefghijklmnopqrst", 20, -20);
+ test(S("abcdefghijklmnopqrst"), 19, 1, "", 0, 1);
+ test(S("abcdefghijklmnopqrst"), 19, 1, "abcde", 0, 1);
+ test(S("abcdefghijklmnopqrst"), 19, 1, "abcde", 1, 19);
+ test(S("abcdefghijklmnopqrst"), 19, 1, "abcde", 2, 19);
+ test(S("abcdefghijklmnopqrst"), 19, 1, "abcde", 4, 19);
+ test(S("abcdefghijklmnopqrst"), 19, 1, "abcde", 5, 19);
+ test(S("abcdefghijklmnopqrst"), 19, 1, "abcdefghij", 0, 1);
+ test(S("abcdefghijklmnopqrst"), 19, 1, "abcdefghij", 1, 19);
+ test(S("abcdefghijklmnopqrst"), 19, 1, "abcdefghij", 5, 19);
+ test(S("abcdefghijklmnopqrst"), 19, 1, "abcdefghij", 9, 19);
+ test(S("abcdefghijklmnopqrst"), 19, 1, "abcdefghij", 10, 19);
+ test(S("abcdefghijklmnopqrst"), 19, 1, "abcdefghijklmnopqrst", 0, 1);
+ test(S("abcdefghijklmnopqrst"), 19, 1, "abcdefghijklmnopqrst", 1, 19);
+ test(S("abcdefghijklmnopqrst"), 19, 1, "abcdefghijklmnopqrst", 10, 19);
+ test(S("abcdefghijklmnopqrst"), 19, 1, "abcdefghijklmnopqrst", 19, 19);
+ test(S("abcdefghijklmnopqrst"), 19, 1, "abcdefghijklmnopqrst", 20, 19);
+ test(S("abcdefghijklmnopqrst"), 19, 2, "", 0, 1);
+ test(S("abcdefghijklmnopqrst"), 19, 2, "abcde", 0, 1);
+ test(S("abcdefghijklmnopqrst"), 19, 2, "abcde", 1, 19);
+ test(S("abcdefghijklmnopqrst"), 19, 2, "abcde", 2, 19);
+ test(S("abcdefghijklmnopqrst"), 19, 2, "abcde", 4, 19);
+ test(S("abcdefghijklmnopqrst"), 19, 2, "abcde", 5, 19);
+ test(S("abcdefghijklmnopqrst"), 19, 2, "abcdefghij", 0, 1);
+ test(S("abcdefghijklmnopqrst"), 19, 2, "abcdefghij", 1, 19);
+ test(S("abcdefghijklmnopqrst"), 19, 2, "abcdefghij", 5, 19);
+ test(S("abcdefghijklmnopqrst"), 19, 2, "abcdefghij", 9, 19);
+ test(S("abcdefghijklmnopqrst"), 19, 2, "abcdefghij", 10, 19);
+ test(S("abcdefghijklmnopqrst"), 19, 2, "abcdefghijklmnopqrst", 0, 1);
+ test(S("abcdefghijklmnopqrst"), 19, 2, "abcdefghijklmnopqrst", 1, 19);
+ test(S("abcdefghijklmnopqrst"), 19, 2, "abcdefghijklmnopqrst", 10, 19);
+ test(S("abcdefghijklmnopqrst"), 19, 2, "abcdefghijklmnopqrst", 19, 19);
+ test(S("abcdefghijklmnopqrst"), 19, 2, "abcdefghijklmnopqrst", 20, 19);
+ test(S("abcdefghijklmnopqrst"), 20, 0, "", 0, 0);
+ test(S("abcdefghijklmnopqrst"), 20, 0, "abcde", 0, 0);
+ test(S("abcdefghijklmnopqrst"), 20, 0, "abcde", 1, -1);
+ test(S("abcdefghijklmnopqrst"), 20, 0, "abcde", 2, -2);
+ test(S("abcdefghijklmnopqrst"), 20, 0, "abcde", 4, -4);
+ test(S("abcdefghijklmnopqrst"), 20, 0, "abcde", 5, -5);
+ test(S("abcdefghijklmnopqrst"), 20, 0, "abcdefghij", 0, 0);
+ test(S("abcdefghijklmnopqrst"), 20, 0, "abcdefghij", 1, -1);
+ test(S("abcdefghijklmnopqrst"), 20, 0, "abcdefghij", 5, -5);
+ test(S("abcdefghijklmnopqrst"), 20, 0, "abcdefghij", 9, -9);
+ test(S("abcdefghijklmnopqrst"), 20, 0, "abcdefghij", 10, -10);
+ test(S("abcdefghijklmnopqrst"), 20, 0, "abcdefghijklmnopqrst", 0, 0);
+ test(S("abcdefghijklmnopqrst"), 20, 0, "abcdefghijklmnopqrst", 1, -1);
+ test(S("abcdefghijklmnopqrst"), 20, 0, "abcdefghijklmnopqrst", 10, -10);
+ test(S("abcdefghijklmnopqrst"), 20, 0, "abcdefghijklmnopqrst", 19, -19);
+ test(S("abcdefghijklmnopqrst"), 20, 0, "abcdefghijklmnopqrst", 20, -20);
+ test(S("abcdefghijklmnopqrst"), 20, 1, "", 0, 0);
+ test(S("abcdefghijklmnopqrst"), 20, 1, "abcde", 0, 0);
+ test(S("abcdefghijklmnopqrst"), 20, 1, "abcde", 1, -1);
+ test(S("abcdefghijklmnopqrst"), 20, 1, "abcde", 2, -2);
+ test(S("abcdefghijklmnopqrst"), 20, 1, "abcde", 4, -4);
+ test(S("abcdefghijklmnopqrst"), 20, 1, "abcde", 5, -5);
+ test(S("abcdefghijklmnopqrst"), 20, 1, "abcdefghij", 0, 0);
+ test(S("abcdefghijklmnopqrst"), 20, 1, "abcdefghij", 1, -1);
+ test(S("abcdefghijklmnopqrst"), 20, 1, "abcdefghij", 5, -5);
+ test(S("abcdefghijklmnopqrst"), 20, 1, "abcdefghij", 9, -9);
+ test(S("abcdefghijklmnopqrst"), 20, 1, "abcdefghij", 10, -10);
+ test(S("abcdefghijklmnopqrst"), 20, 1, "abcdefghijklmnopqrst", 0, 0);
+ test(S("abcdefghijklmnopqrst"), 20, 1, "abcdefghijklmnopqrst", 1, -1);
+ test(S("abcdefghijklmnopqrst"), 20, 1, "abcdefghijklmnopqrst", 10, -10);
+ test(S("abcdefghijklmnopqrst"), 20, 1, "abcdefghijklmnopqrst", 19, -19);
+ test(S("abcdefghijklmnopqrst"), 20, 1, "abcdefghijklmnopqrst", 20, -20);
+ test(S("abcdefghijklmnopqrst"), 21, 0, "", 0, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, "abcde", 0, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, "abcde", 1, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, "abcde", 2, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, "abcde", 4, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, "abcde", 5, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, "abcdefghij", 0, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, "abcdefghij", 1, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, "abcdefghij", 5, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, "abcdefghij", 9, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, "abcdefghij", 10, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, "abcdefghijklmnopqrst", 0, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, "abcdefghijklmnopqrst", 1, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, "abcdefghijklmnopqrst", 10, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, "abcdefghijklmnopqrst", 19, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, "abcdefghijklmnopqrst", 20, 0);
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test0<S>();
+ test1<S>();
+ test2<S>();
+ test3<S>();
+ test4<S>();
+ test5<S>();
+ test6<S>();
+ test7<S>();
+ test8<S>();
+ test9<S>();
+ test10<S>();
+ test11<S>();
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test0<S>();
+ test1<S>();
+ test2<S>();
+ test3<S>();
+ test4<S>();
+ test5<S>();
+ test6<S>();
+ test7<S>();
+ test8<S>();
+ test9<S>();
+ test10<S>();
+ test11<S>();
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.ops/string_compare/size_size_string.pass.cpp b/test/std/strings/basic.string/string.ops/string_compare/size_size_string.pass.cpp
new file mode 100644
index 000000000000..3deb617e8d84
--- /dev/null
+++ b/test/std/strings/basic.string/string.ops/string_compare/size_size_string.pass.cpp
@@ -0,0 +1,372 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// int compare(size_type pos1, size_type n1, const basic_string& str) const;
+
+#include <string>
+#include <stdexcept>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int sign(int x)
+{
+ if (x == 0)
+ return 0;
+ if (x < 0)
+ return -1;
+ return 1;
+}
+
+template <class S>
+void
+test(const S& s, typename S::size_type pos1, typename S::size_type n1,
+ const S& str, int x)
+{
+ try
+ {
+ assert(sign(s.compare(pos1, n1, str)) == sign(x));
+ assert(pos1 <= s.size());
+ }
+ catch (std::out_of_range&)
+ {
+ assert(pos1 > s.size());
+ }
+}
+
+template <class S>
+void test0()
+{
+ test(S(""), 0, 0, S(""), 0);
+ test(S(""), 0, 0, S("abcde"), -5);
+ test(S(""), 0, 0, S("abcdefghij"), -10);
+ test(S(""), 0, 0, S("abcdefghijklmnopqrst"), -20);
+ test(S(""), 0, 1, S(""), 0);
+ test(S(""), 0, 1, S("abcde"), -5);
+ test(S(""), 0, 1, S("abcdefghij"), -10);
+ test(S(""), 0, 1, S("abcdefghijklmnopqrst"), -20);
+ test(S(""), 1, 0, S(""), 0);
+ test(S(""), 1, 0, S("abcde"), 0);
+ test(S(""), 1, 0, S("abcdefghij"), 0);
+ test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 0);
+ test(S("abcde"), 0, 0, S(""), 0);
+ test(S("abcde"), 0, 0, S("abcde"), -5);
+ test(S("abcde"), 0, 0, S("abcdefghij"), -10);
+ test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), -20);
+ test(S("abcde"), 0, 1, S(""), 1);
+ test(S("abcde"), 0, 1, S("abcde"), -4);
+ test(S("abcde"), 0, 1, S("abcdefghij"), -9);
+ test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), -19);
+ test(S("abcde"), 0, 2, S(""), 2);
+ test(S("abcde"), 0, 2, S("abcde"), -3);
+ test(S("abcde"), 0, 2, S("abcdefghij"), -8);
+ test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), -18);
+ test(S("abcde"), 0, 4, S(""), 4);
+ test(S("abcde"), 0, 4, S("abcde"), -1);
+ test(S("abcde"), 0, 4, S("abcdefghij"), -6);
+ test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), -16);
+ test(S("abcde"), 0, 5, S(""), 5);
+ test(S("abcde"), 0, 5, S("abcde"), 0);
+ test(S("abcde"), 0, 5, S("abcdefghij"), -5);
+ test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), -15);
+ test(S("abcde"), 0, 6, S(""), 5);
+ test(S("abcde"), 0, 6, S("abcde"), 0);
+ test(S("abcde"), 0, 6, S("abcdefghij"), -5);
+ test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), -15);
+ test(S("abcde"), 1, 0, S(""), 0);
+ test(S("abcde"), 1, 0, S("abcde"), -5);
+ test(S("abcde"), 1, 0, S("abcdefghij"), -10);
+ test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), -20);
+ test(S("abcde"), 1, 1, S(""), 1);
+ test(S("abcde"), 1, 1, S("abcde"), 1);
+ test(S("abcde"), 1, 1, S("abcdefghij"), 1);
+ test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 1);
+ test(S("abcde"), 1, 2, S(""), 2);
+ test(S("abcde"), 1, 2, S("abcde"), 1);
+ test(S("abcde"), 1, 2, S("abcdefghij"), 1);
+ test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 1);
+ test(S("abcde"), 1, 3, S(""), 3);
+ test(S("abcde"), 1, 3, S("abcde"), 1);
+ test(S("abcde"), 1, 3, S("abcdefghij"), 1);
+ test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 1);
+ test(S("abcde"), 1, 4, S(""), 4);
+ test(S("abcde"), 1, 4, S("abcde"), 1);
+ test(S("abcde"), 1, 4, S("abcdefghij"), 1);
+ test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 1);
+ test(S("abcde"), 1, 5, S(""), 4);
+ test(S("abcde"), 1, 5, S("abcde"), 1);
+ test(S("abcde"), 1, 5, S("abcdefghij"), 1);
+ test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 1);
+ test(S("abcde"), 2, 0, S(""), 0);
+ test(S("abcde"), 2, 0, S("abcde"), -5);
+ test(S("abcde"), 2, 0, S("abcdefghij"), -10);
+ test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), -20);
+ test(S("abcde"), 2, 1, S(""), 1);
+ test(S("abcde"), 2, 1, S("abcde"), 2);
+ test(S("abcde"), 2, 1, S("abcdefghij"), 2);
+ test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 2);
+ test(S("abcde"), 2, 2, S(""), 2);
+ test(S("abcde"), 2, 2, S("abcde"), 2);
+ test(S("abcde"), 2, 2, S("abcdefghij"), 2);
+ test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 2);
+ test(S("abcde"), 2, 3, S(""), 3);
+ test(S("abcde"), 2, 3, S("abcde"), 2);
+ test(S("abcde"), 2, 3, S("abcdefghij"), 2);
+ test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 2);
+ test(S("abcde"), 2, 4, S(""), 3);
+ test(S("abcde"), 2, 4, S("abcde"), 2);
+ test(S("abcde"), 2, 4, S("abcdefghij"), 2);
+ test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 2);
+ test(S("abcde"), 4, 0, S(""), 0);
+ test(S("abcde"), 4, 0, S("abcde"), -5);
+ test(S("abcde"), 4, 0, S("abcdefghij"), -10);
+ test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), -20);
+ test(S("abcde"), 4, 1, S(""), 1);
+ test(S("abcde"), 4, 1, S("abcde"), 4);
+ test(S("abcde"), 4, 1, S("abcdefghij"), 4);
+ test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 4);
+ test(S("abcde"), 4, 2, S(""), 1);
+ test(S("abcde"), 4, 2, S("abcde"), 4);
+ test(S("abcde"), 4, 2, S("abcdefghij"), 4);
+ test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 4);
+ test(S("abcde"), 5, 0, S(""), 0);
+ test(S("abcde"), 5, 0, S("abcde"), -5);
+ test(S("abcde"), 5, 0, S("abcdefghij"), -10);
+ test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), -20);
+ test(S("abcde"), 5, 1, S(""), 0);
+ test(S("abcde"), 5, 1, S("abcde"), -5);
+ test(S("abcde"), 5, 1, S("abcdefghij"), -10);
+ test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), -20);
+}
+
+template <class S>
+void test1()
+{
+ test(S("abcde"), 6, 0, S(""), 0);
+ test(S("abcde"), 6, 0, S("abcde"), 0);
+ test(S("abcde"), 6, 0, S("abcdefghij"), 0);
+ test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 0);
+ test(S("abcdefghij"), 0, 0, S(""), 0);
+ test(S("abcdefghij"), 0, 0, S("abcde"), -5);
+ test(S("abcdefghij"), 0, 0, S("abcdefghij"), -10);
+ test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), -20);
+ test(S("abcdefghij"), 0, 1, S(""), 1);
+ test(S("abcdefghij"), 0, 1, S("abcde"), -4);
+ test(S("abcdefghij"), 0, 1, S("abcdefghij"), -9);
+ test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), -19);
+ test(S("abcdefghij"), 0, 5, S(""), 5);
+ test(S("abcdefghij"), 0, 5, S("abcde"), 0);
+ test(S("abcdefghij"), 0, 5, S("abcdefghij"), -5);
+ test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), -15);
+ test(S("abcdefghij"), 0, 9, S(""), 9);
+ test(S("abcdefghij"), 0, 9, S("abcde"), 4);
+ test(S("abcdefghij"), 0, 9, S("abcdefghij"), -1);
+ test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), -11);
+ test(S("abcdefghij"), 0, 10, S(""), 10);
+ test(S("abcdefghij"), 0, 10, S("abcde"), 5);
+ test(S("abcdefghij"), 0, 10, S("abcdefghij"), 0);
+ test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), -10);
+ test(S("abcdefghij"), 0, 11, S(""), 10);
+ test(S("abcdefghij"), 0, 11, S("abcde"), 5);
+ test(S("abcdefghij"), 0, 11, S("abcdefghij"), 0);
+ test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), -10);
+ test(S("abcdefghij"), 1, 0, S(""), 0);
+ test(S("abcdefghij"), 1, 0, S("abcde"), -5);
+ test(S("abcdefghij"), 1, 0, S("abcdefghij"), -10);
+ test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), -20);
+ test(S("abcdefghij"), 1, 1, S(""), 1);
+ test(S("abcdefghij"), 1, 1, S("abcde"), 1);
+ test(S("abcdefghij"), 1, 1, S("abcdefghij"), 1);
+ test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 1);
+ test(S("abcdefghij"), 1, 4, S(""), 4);
+ test(S("abcdefghij"), 1, 4, S("abcde"), 1);
+ test(S("abcdefghij"), 1, 4, S("abcdefghij"), 1);
+ test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 1);
+ test(S("abcdefghij"), 1, 8, S(""), 8);
+ test(S("abcdefghij"), 1, 8, S("abcde"), 1);
+ test(S("abcdefghij"), 1, 8, S("abcdefghij"), 1);
+ test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 1);
+ test(S("abcdefghij"), 1, 9, S(""), 9);
+ test(S("abcdefghij"), 1, 9, S("abcde"), 1);
+ test(S("abcdefghij"), 1, 9, S("abcdefghij"), 1);
+ test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 1);
+ test(S("abcdefghij"), 1, 10, S(""), 9);
+ test(S("abcdefghij"), 1, 10, S("abcde"), 1);
+ test(S("abcdefghij"), 1, 10, S("abcdefghij"), 1);
+ test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 1);
+ test(S("abcdefghij"), 5, 0, S(""), 0);
+ test(S("abcdefghij"), 5, 0, S("abcde"), -5);
+ test(S("abcdefghij"), 5, 0, S("abcdefghij"), -10);
+ test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), -20);
+ test(S("abcdefghij"), 5, 1, S(""), 1);
+ test(S("abcdefghij"), 5, 1, S("abcde"), 5);
+ test(S("abcdefghij"), 5, 1, S("abcdefghij"), 5);
+ test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 5);
+ test(S("abcdefghij"), 5, 2, S(""), 2);
+ test(S("abcdefghij"), 5, 2, S("abcde"), 5);
+ test(S("abcdefghij"), 5, 2, S("abcdefghij"), 5);
+ test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 5);
+ test(S("abcdefghij"), 5, 4, S(""), 4);
+ test(S("abcdefghij"), 5, 4, S("abcde"), 5);
+ test(S("abcdefghij"), 5, 4, S("abcdefghij"), 5);
+ test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 5);
+ test(S("abcdefghij"), 5, 5, S(""), 5);
+ test(S("abcdefghij"), 5, 5, S("abcde"), 5);
+ test(S("abcdefghij"), 5, 5, S("abcdefghij"), 5);
+ test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 5);
+ test(S("abcdefghij"), 5, 6, S(""), 5);
+ test(S("abcdefghij"), 5, 6, S("abcde"), 5);
+ test(S("abcdefghij"), 5, 6, S("abcdefghij"), 5);
+ test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 5);
+ test(S("abcdefghij"), 9, 0, S(""), 0);
+ test(S("abcdefghij"), 9, 0, S("abcde"), -5);
+ test(S("abcdefghij"), 9, 0, S("abcdefghij"), -10);
+ test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), -20);
+ test(S("abcdefghij"), 9, 1, S(""), 1);
+ test(S("abcdefghij"), 9, 1, S("abcde"), 9);
+ test(S("abcdefghij"), 9, 1, S("abcdefghij"), 9);
+ test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 9);
+ test(S("abcdefghij"), 9, 2, S(""), 1);
+ test(S("abcdefghij"), 9, 2, S("abcde"), 9);
+ test(S("abcdefghij"), 9, 2, S("abcdefghij"), 9);
+ test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 9);
+ test(S("abcdefghij"), 10, 0, S(""), 0);
+ test(S("abcdefghij"), 10, 0, S("abcde"), -5);
+ test(S("abcdefghij"), 10, 0, S("abcdefghij"), -10);
+ test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), -20);
+ test(S("abcdefghij"), 10, 1, S(""), 0);
+ test(S("abcdefghij"), 10, 1, S("abcde"), -5);
+ test(S("abcdefghij"), 10, 1, S("abcdefghij"), -10);
+ test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), -20);
+ test(S("abcdefghij"), 11, 0, S(""), 0);
+ test(S("abcdefghij"), 11, 0, S("abcde"), 0);
+ test(S("abcdefghij"), 11, 0, S("abcdefghij"), 0);
+ test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 0);
+}
+
+template <class S>
+void test2()
+{
+ test(S("abcdefghijklmnopqrst"), 0, 0, S(""), 0);
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), -5);
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), -10);
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), -20);
+ test(S("abcdefghijklmnopqrst"), 0, 1, S(""), 1);
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), -4);
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), -9);
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), -19);
+ test(S("abcdefghijklmnopqrst"), 0, 10, S(""), 10);
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 5);
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 0);
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), -10);
+ test(S("abcdefghijklmnopqrst"), 0, 19, S(""), 19);
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 14);
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 9);
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), -1);
+ test(S("abcdefghijklmnopqrst"), 0, 20, S(""), 20);
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 15);
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 10);
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 0);
+ test(S("abcdefghijklmnopqrst"), 0, 21, S(""), 20);
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 15);
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 10);
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 0);
+ test(S("abcdefghijklmnopqrst"), 1, 0, S(""), 0);
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), -5);
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), -10);
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), -20);
+ test(S("abcdefghijklmnopqrst"), 1, 1, S(""), 1);
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 1);
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 1);
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 1);
+ test(S("abcdefghijklmnopqrst"), 1, 9, S(""), 9);
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 1);
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 1);
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 1);
+ test(S("abcdefghijklmnopqrst"), 1, 18, S(""), 18);
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 1);
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 1);
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 1);
+ test(S("abcdefghijklmnopqrst"), 1, 19, S(""), 19);
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 1);
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 1);
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 1);
+ test(S("abcdefghijklmnopqrst"), 1, 20, S(""), 19);
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 1);
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 1);
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 1);
+ test(S("abcdefghijklmnopqrst"), 10, 0, S(""), 0);
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), -5);
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), -10);
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), -20);
+ test(S("abcdefghijklmnopqrst"), 10, 1, S(""), 1);
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 10);
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 10);
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 10);
+ test(S("abcdefghijklmnopqrst"), 10, 5, S(""), 5);
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 10);
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 10);
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 10);
+ test(S("abcdefghijklmnopqrst"), 10, 9, S(""), 9);
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 10);
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 10);
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 10);
+ test(S("abcdefghijklmnopqrst"), 10, 10, S(""), 10);
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 10);
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 10);
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 10);
+ test(S("abcdefghijklmnopqrst"), 10, 11, S(""), 10);
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 10);
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 10);
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 10);
+ test(S("abcdefghijklmnopqrst"), 19, 0, S(""), 0);
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), -5);
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), -10);
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), -20);
+ test(S("abcdefghijklmnopqrst"), 19, 1, S(""), 1);
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 19);
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 19);
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 19);
+ test(S("abcdefghijklmnopqrst"), 19, 2, S(""), 1);
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 19);
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 19);
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 19);
+ test(S("abcdefghijklmnopqrst"), 20, 0, S(""), 0);
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), -5);
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), -10);
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), -20);
+ test(S("abcdefghijklmnopqrst"), 20, 1, S(""), 0);
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), -5);
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), -10);
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), -20);
+ test(S("abcdefghijklmnopqrst"), 21, 0, S(""), 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 0);
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test0<S>();
+ test1<S>();
+ test2<S>();
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test0<S>();
+ test1<S>();
+ test2<S>();
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.ops/string_compare/size_size_string_size_size.pass.cpp b/test/std/strings/basic.string/string.ops/string_compare/size_size_string_size_size.pass.cpp
new file mode 100644
index 000000000000..122e6e9c487a
--- /dev/null
+++ b/test/std/strings/basic.string/string.ops/string_compare/size_size_string_size_size.pass.cpp
@@ -0,0 +1,5948 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// int compare(size_type pos1, size_type n1, const basic_string& str,
+// size_type pos2, size_type n2=npos) const;
+// the "=npos" was added in C++14
+
+#include <string>
+#include <stdexcept>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int sign(int x)
+{
+ if (x == 0)
+ return 0;
+ if (x < 0)
+ return -1;
+ return 1;
+}
+
+template <class S>
+void
+test(const S& s, typename S::size_type pos1, typename S::size_type n1,
+ const S& str, typename S::size_type pos2, typename S::size_type n2, int x)
+{
+ try
+ {
+ assert(sign(s.compare(pos1, n1, str, pos2, n2)) == sign(x));
+ assert(pos1 <= s.size());
+ assert(pos2 <= str.size());
+ }
+ catch (std::out_of_range&)
+ {
+ assert(pos1 > s.size() || pos2 > str.size());
+ }
+}
+
+template <class S>
+void
+test_npos(const S& s, typename S::size_type pos1, typename S::size_type n1,
+ const S& str, typename S::size_type pos2, int x)
+{
+ try
+ {
+ assert(sign(s.compare(pos1, n1, str, pos2)) == sign(x));
+ assert(pos1 <= s.size());
+ assert(pos2 <= str.size());
+ }
+ catch (std::out_of_range&)
+ {
+ assert(pos1 > s.size() || pos2 > str.size());
+ }
+}
+
+template <class S>
+void test0()
+{
+ test(S(""), 0, 0, S(""), 0, 0, 0);
+ test(S(""), 0, 0, S(""), 0, 1, 0);
+ test(S(""), 0, 0, S(""), 1, 0, 0);
+ test(S(""), 0, 0, S("abcde"), 0, 0, 0);
+ test(S(""), 0, 0, S("abcde"), 0, 1, -1);
+ test(S(""), 0, 0, S("abcde"), 0, 2, -2);
+ test(S(""), 0, 0, S("abcde"), 0, 4, -4);
+ test(S(""), 0, 0, S("abcde"), 0, 5, -5);
+ test(S(""), 0, 0, S("abcde"), 0, 6, -5);
+ test(S(""), 0, 0, S("abcde"), 1, 0, 0);
+ test(S(""), 0, 0, S("abcde"), 1, 1, -1);
+ test(S(""), 0, 0, S("abcde"), 1, 2, -2);
+ test(S(""), 0, 0, S("abcde"), 1, 3, -3);
+ test(S(""), 0, 0, S("abcde"), 1, 4, -4);
+ test(S(""), 0, 0, S("abcde"), 1, 5, -4);
+ test(S(""), 0, 0, S("abcde"), 2, 0, 0);
+ test(S(""), 0, 0, S("abcde"), 2, 1, -1);
+ test(S(""), 0, 0, S("abcde"), 2, 2, -2);
+ test(S(""), 0, 0, S("abcde"), 2, 3, -3);
+ test(S(""), 0, 0, S("abcde"), 2, 4, -3);
+ test(S(""), 0, 0, S("abcde"), 4, 0, 0);
+ test(S(""), 0, 0, S("abcde"), 4, 1, -1);
+ test(S(""), 0, 0, S("abcde"), 4, 2, -1);
+ test(S(""), 0, 0, S("abcde"), 5, 0, 0);
+ test(S(""), 0, 0, S("abcde"), 5, 1, 0);
+ test(S(""), 0, 0, S("abcde"), 6, 0, 0);
+ test(S(""), 0, 0, S("abcdefghij"), 0, 0, 0);
+ test(S(""), 0, 0, S("abcdefghij"), 0, 1, -1);
+ test(S(""), 0, 0, S("abcdefghij"), 0, 5, -5);
+ test(S(""), 0, 0, S("abcdefghij"), 0, 9, -9);
+ test(S(""), 0, 0, S("abcdefghij"), 0, 10, -10);
+ test(S(""), 0, 0, S("abcdefghij"), 0, 11, -10);
+ test(S(""), 0, 0, S("abcdefghij"), 1, 0, 0);
+ test(S(""), 0, 0, S("abcdefghij"), 1, 1, -1);
+ test(S(""), 0, 0, S("abcdefghij"), 1, 4, -4);
+ test(S(""), 0, 0, S("abcdefghij"), 1, 8, -8);
+ test(S(""), 0, 0, S("abcdefghij"), 1, 9, -9);
+ test(S(""), 0, 0, S("abcdefghij"), 1, 10, -9);
+ test(S(""), 0, 0, S("abcdefghij"), 5, 0, 0);
+ test(S(""), 0, 0, S("abcdefghij"), 5, 1, -1);
+ test(S(""), 0, 0, S("abcdefghij"), 5, 2, -2);
+ test(S(""), 0, 0, S("abcdefghij"), 5, 4, -4);
+ test(S(""), 0, 0, S("abcdefghij"), 5, 5, -5);
+ test(S(""), 0, 0, S("abcdefghij"), 5, 6, -5);
+ test(S(""), 0, 0, S("abcdefghij"), 9, 0, 0);
+ test(S(""), 0, 0, S("abcdefghij"), 9, 1, -1);
+ test(S(""), 0, 0, S("abcdefghij"), 9, 2, -1);
+ test(S(""), 0, 0, S("abcdefghij"), 10, 0, 0);
+ test(S(""), 0, 0, S("abcdefghij"), 10, 1, 0);
+ test(S(""), 0, 0, S("abcdefghij"), 11, 0, 0);
+ test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 0, 0, 0);
+ test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 0, 1, -1);
+ test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 0, 10, -10);
+ test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 0, 19, -19);
+ test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 0, 20, -20);
+ test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 0, 21, -20);
+ test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 1, 0, 0);
+ test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 1, 1, -1);
+ test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 1, 9, -9);
+ test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 1, 18, -18);
+ test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 1, 19, -19);
+ test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 1, 20, -19);
+ test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 10, 0, 0);
+ test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 10, 1, -1);
+ test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 10, 5, -5);
+ test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 10, 9, -9);
+ test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 10, 10, -10);
+ test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 10, 11, -10);
+ test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 19, 0, 0);
+ test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 19, 1, -1);
+ test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 19, 2, -1);
+ test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 20, 0, 0);
+ test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 20, 1, 0);
+ test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 21, 0, 0);
+ test(S(""), 0, 1, S(""), 0, 0, 0);
+ test(S(""), 0, 1, S(""), 0, 1, 0);
+ test(S(""), 0, 1, S(""), 1, 0, 0);
+ test(S(""), 0, 1, S("abcde"), 0, 0, 0);
+ test(S(""), 0, 1, S("abcde"), 0, 1, -1);
+ test(S(""), 0, 1, S("abcde"), 0, 2, -2);
+ test(S(""), 0, 1, S("abcde"), 0, 4, -4);
+ test(S(""), 0, 1, S("abcde"), 0, 5, -5);
+ test(S(""), 0, 1, S("abcde"), 0, 6, -5);
+ test(S(""), 0, 1, S("abcde"), 1, 0, 0);
+ test(S(""), 0, 1, S("abcde"), 1, 1, -1);
+ test(S(""), 0, 1, S("abcde"), 1, 2, -2);
+ test(S(""), 0, 1, S("abcde"), 1, 3, -3);
+ test(S(""), 0, 1, S("abcde"), 1, 4, -4);
+ test(S(""), 0, 1, S("abcde"), 1, 5, -4);
+ test(S(""), 0, 1, S("abcde"), 2, 0, 0);
+ test(S(""), 0, 1, S("abcde"), 2, 1, -1);
+ test(S(""), 0, 1, S("abcde"), 2, 2, -2);
+ test(S(""), 0, 1, S("abcde"), 2, 3, -3);
+ test(S(""), 0, 1, S("abcde"), 2, 4, -3);
+ test(S(""), 0, 1, S("abcde"), 4, 0, 0);
+ test(S(""), 0, 1, S("abcde"), 4, 1, -1);
+ test(S(""), 0, 1, S("abcde"), 4, 2, -1);
+ test(S(""), 0, 1, S("abcde"), 5, 0, 0);
+ test(S(""), 0, 1, S("abcde"), 5, 1, 0);
+ test(S(""), 0, 1, S("abcde"), 6, 0, 0);
+}
+
+template <class S>
+void test1()
+{
+ test(S(""), 0, 1, S("abcdefghij"), 0, 0, 0);
+ test(S(""), 0, 1, S("abcdefghij"), 0, 1, -1);
+ test(S(""), 0, 1, S("abcdefghij"), 0, 5, -5);
+ test(S(""), 0, 1, S("abcdefghij"), 0, 9, -9);
+ test(S(""), 0, 1, S("abcdefghij"), 0, 10, -10);
+ test(S(""), 0, 1, S("abcdefghij"), 0, 11, -10);
+ test(S(""), 0, 1, S("abcdefghij"), 1, 0, 0);
+ test(S(""), 0, 1, S("abcdefghij"), 1, 1, -1);
+ test(S(""), 0, 1, S("abcdefghij"), 1, 4, -4);
+ test(S(""), 0, 1, S("abcdefghij"), 1, 8, -8);
+ test(S(""), 0, 1, S("abcdefghij"), 1, 9, -9);
+ test(S(""), 0, 1, S("abcdefghij"), 1, 10, -9);
+ test(S(""), 0, 1, S("abcdefghij"), 5, 0, 0);
+ test(S(""), 0, 1, S("abcdefghij"), 5, 1, -1);
+ test(S(""), 0, 1, S("abcdefghij"), 5, 2, -2);
+ test(S(""), 0, 1, S("abcdefghij"), 5, 4, -4);
+ test(S(""), 0, 1, S("abcdefghij"), 5, 5, -5);
+ test(S(""), 0, 1, S("abcdefghij"), 5, 6, -5);
+ test(S(""), 0, 1, S("abcdefghij"), 9, 0, 0);
+ test(S(""), 0, 1, S("abcdefghij"), 9, 1, -1);
+ test(S(""), 0, 1, S("abcdefghij"), 9, 2, -1);
+ test(S(""), 0, 1, S("abcdefghij"), 10, 0, 0);
+ test(S(""), 0, 1, S("abcdefghij"), 10, 1, 0);
+ test(S(""), 0, 1, S("abcdefghij"), 11, 0, 0);
+ test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 0, 0, 0);
+ test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 0, 1, -1);
+ test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 0, 10, -10);
+ test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 0, 19, -19);
+ test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 0, 20, -20);
+ test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 0, 21, -20);
+ test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 1, 0, 0);
+ test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 1, 1, -1);
+ test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 1, 9, -9);
+ test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 1, 18, -18);
+ test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 1, 19, -19);
+ test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 1, 20, -19);
+ test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 10, 0, 0);
+ test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 10, 1, -1);
+ test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 10, 5, -5);
+ test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 10, 9, -9);
+ test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 10, 10, -10);
+ test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 10, 11, -10);
+ test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 19, 0, 0);
+ test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 19, 1, -1);
+ test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 19, 2, -1);
+ test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 20, 0, 0);
+ test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 20, 1, 0);
+ test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 21, 0, 0);
+ test(S(""), 1, 0, S(""), 0, 0, 0);
+ test(S(""), 1, 0, S(""), 0, 1, 0);
+ test(S(""), 1, 0, S(""), 1, 0, 0);
+ test(S(""), 1, 0, S("abcde"), 0, 0, 0);
+ test(S(""), 1, 0, S("abcde"), 0, 1, 0);
+ test(S(""), 1, 0, S("abcde"), 0, 2, 0);
+ test(S(""), 1, 0, S("abcde"), 0, 4, 0);
+ test(S(""), 1, 0, S("abcde"), 0, 5, 0);
+ test(S(""), 1, 0, S("abcde"), 0, 6, 0);
+ test(S(""), 1, 0, S("abcde"), 1, 0, 0);
+ test(S(""), 1, 0, S("abcde"), 1, 1, 0);
+ test(S(""), 1, 0, S("abcde"), 1, 2, 0);
+ test(S(""), 1, 0, S("abcde"), 1, 3, 0);
+ test(S(""), 1, 0, S("abcde"), 1, 4, 0);
+ test(S(""), 1, 0, S("abcde"), 1, 5, 0);
+ test(S(""), 1, 0, S("abcde"), 2, 0, 0);
+ test(S(""), 1, 0, S("abcde"), 2, 1, 0);
+ test(S(""), 1, 0, S("abcde"), 2, 2, 0);
+ test(S(""), 1, 0, S("abcde"), 2, 3, 0);
+ test(S(""), 1, 0, S("abcde"), 2, 4, 0);
+ test(S(""), 1, 0, S("abcde"), 4, 0, 0);
+ test(S(""), 1, 0, S("abcde"), 4, 1, 0);
+ test(S(""), 1, 0, S("abcde"), 4, 2, 0);
+ test(S(""), 1, 0, S("abcde"), 5, 0, 0);
+ test(S(""), 1, 0, S("abcde"), 5, 1, 0);
+ test(S(""), 1, 0, S("abcde"), 6, 0, 0);
+ test(S(""), 1, 0, S("abcdefghij"), 0, 0, 0);
+ test(S(""), 1, 0, S("abcdefghij"), 0, 1, 0);
+ test(S(""), 1, 0, S("abcdefghij"), 0, 5, 0);
+ test(S(""), 1, 0, S("abcdefghij"), 0, 9, 0);
+ test(S(""), 1, 0, S("abcdefghij"), 0, 10, 0);
+ test(S(""), 1, 0, S("abcdefghij"), 0, 11, 0);
+ test(S(""), 1, 0, S("abcdefghij"), 1, 0, 0);
+ test(S(""), 1, 0, S("abcdefghij"), 1, 1, 0);
+ test(S(""), 1, 0, S("abcdefghij"), 1, 4, 0);
+ test(S(""), 1, 0, S("abcdefghij"), 1, 8, 0);
+ test(S(""), 1, 0, S("abcdefghij"), 1, 9, 0);
+ test(S(""), 1, 0, S("abcdefghij"), 1, 10, 0);
+ test(S(""), 1, 0, S("abcdefghij"), 5, 0, 0);
+ test(S(""), 1, 0, S("abcdefghij"), 5, 1, 0);
+ test(S(""), 1, 0, S("abcdefghij"), 5, 2, 0);
+ test(S(""), 1, 0, S("abcdefghij"), 5, 4, 0);
+ test(S(""), 1, 0, S("abcdefghij"), 5, 5, 0);
+ test(S(""), 1, 0, S("abcdefghij"), 5, 6, 0);
+ test(S(""), 1, 0, S("abcdefghij"), 9, 0, 0);
+ test(S(""), 1, 0, S("abcdefghij"), 9, 1, 0);
+ test(S(""), 1, 0, S("abcdefghij"), 9, 2, 0);
+ test(S(""), 1, 0, S("abcdefghij"), 10, 0, 0);
+ test(S(""), 1, 0, S("abcdefghij"), 10, 1, 0);
+ test(S(""), 1, 0, S("abcdefghij"), 11, 0, 0);
+ test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 0, 0, 0);
+ test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 0, 1, 0);
+}
+
+template <class S>
+void test2()
+{
+ test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 0, 10, 0);
+ test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 0, 19, 0);
+ test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 0, 20, 0);
+ test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 0, 21, 0);
+ test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 1, 0, 0);
+ test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 1, 1, 0);
+ test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 1, 9, 0);
+ test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 1, 18, 0);
+ test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 1, 19, 0);
+ test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 1, 20, 0);
+ test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 10, 0, 0);
+ test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 10, 1, 0);
+ test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 10, 5, 0);
+ test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 10, 9, 0);
+ test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 10, 10, 0);
+ test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 10, 11, 0);
+ test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 19, 0, 0);
+ test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 19, 1, 0);
+ test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 19, 2, 0);
+ test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 20, 0, 0);
+ test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 20, 1, 0);
+ test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 21, 0, 0);
+ test(S("abcde"), 0, 0, S(""), 0, 0, 0);
+ test(S("abcde"), 0, 0, S(""), 0, 1, 0);
+ test(S("abcde"), 0, 0, S(""), 1, 0, 0);
+ test(S("abcde"), 0, 0, S("abcde"), 0, 0, 0);
+ test(S("abcde"), 0, 0, S("abcde"), 0, 1, -1);
+ test(S("abcde"), 0, 0, S("abcde"), 0, 2, -2);
+ test(S("abcde"), 0, 0, S("abcde"), 0, 4, -4);
+ test(S("abcde"), 0, 0, S("abcde"), 0, 5, -5);
+ test(S("abcde"), 0, 0, S("abcde"), 0, 6, -5);
+ test(S("abcde"), 0, 0, S("abcde"), 1, 0, 0);
+ test(S("abcde"), 0, 0, S("abcde"), 1, 1, -1);
+ test(S("abcde"), 0, 0, S("abcde"), 1, 2, -2);
+ test(S("abcde"), 0, 0, S("abcde"), 1, 3, -3);
+ test(S("abcde"), 0, 0, S("abcde"), 1, 4, -4);
+ test(S("abcde"), 0, 0, S("abcde"), 1, 5, -4);
+ test(S("abcde"), 0, 0, S("abcde"), 2, 0, 0);
+ test(S("abcde"), 0, 0, S("abcde"), 2, 1, -1);
+ test(S("abcde"), 0, 0, S("abcde"), 2, 2, -2);
+ test(S("abcde"), 0, 0, S("abcde"), 2, 3, -3);
+ test(S("abcde"), 0, 0, S("abcde"), 2, 4, -3);
+ test(S("abcde"), 0, 0, S("abcde"), 4, 0, 0);
+ test(S("abcde"), 0, 0, S("abcde"), 4, 1, -1);
+ test(S("abcde"), 0, 0, S("abcde"), 4, 2, -1);
+ test(S("abcde"), 0, 0, S("abcde"), 5, 0, 0);
+ test(S("abcde"), 0, 0, S("abcde"), 5, 1, 0);
+ test(S("abcde"), 0, 0, S("abcde"), 6, 0, 0);
+ test(S("abcde"), 0, 0, S("abcdefghij"), 0, 0, 0);
+ test(S("abcde"), 0, 0, S("abcdefghij"), 0, 1, -1);
+ test(S("abcde"), 0, 0, S("abcdefghij"), 0, 5, -5);
+ test(S("abcde"), 0, 0, S("abcdefghij"), 0, 9, -9);
+ test(S("abcde"), 0, 0, S("abcdefghij"), 0, 10, -10);
+ test(S("abcde"), 0, 0, S("abcdefghij"), 0, 11, -10);
+ test(S("abcde"), 0, 0, S("abcdefghij"), 1, 0, 0);
+ test(S("abcde"), 0, 0, S("abcdefghij"), 1, 1, -1);
+ test(S("abcde"), 0, 0, S("abcdefghij"), 1, 4, -4);
+ test(S("abcde"), 0, 0, S("abcdefghij"), 1, 8, -8);
+ test(S("abcde"), 0, 0, S("abcdefghij"), 1, 9, -9);
+ test(S("abcde"), 0, 0, S("abcdefghij"), 1, 10, -9);
+ test(S("abcde"), 0, 0, S("abcdefghij"), 5, 0, 0);
+ test(S("abcde"), 0, 0, S("abcdefghij"), 5, 1, -1);
+ test(S("abcde"), 0, 0, S("abcdefghij"), 5, 2, -2);
+ test(S("abcde"), 0, 0, S("abcdefghij"), 5, 4, -4);
+ test(S("abcde"), 0, 0, S("abcdefghij"), 5, 5, -5);
+ test(S("abcde"), 0, 0, S("abcdefghij"), 5, 6, -5);
+ test(S("abcde"), 0, 0, S("abcdefghij"), 9, 0, 0);
+ test(S("abcde"), 0, 0, S("abcdefghij"), 9, 1, -1);
+ test(S("abcde"), 0, 0, S("abcdefghij"), 9, 2, -1);
+ test(S("abcde"), 0, 0, S("abcdefghij"), 10, 0, 0);
+ test(S("abcde"), 0, 0, S("abcdefghij"), 10, 1, 0);
+ test(S("abcde"), 0, 0, S("abcdefghij"), 11, 0, 0);
+ test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 0, 0, 0);
+ test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 0, 1, -1);
+ test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 0, 10, -10);
+ test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 0, 19, -19);
+ test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 0, 20, -20);
+ test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 0, 21, -20);
+ test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 1, 0, 0);
+ test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 1, 1, -1);
+ test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 1, 9, -9);
+ test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 1, 18, -18);
+ test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 1, 19, -19);
+ test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 1, 20, -19);
+ test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 10, 0, 0);
+ test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 10, 1, -1);
+ test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 10, 5, -5);
+ test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 10, 9, -9);
+ test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 10, 10, -10);
+ test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 10, 11, -10);
+ test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 19, 0, 0);
+ test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 19, 1, -1);
+ test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 19, 2, -1);
+ test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 20, 0, 0);
+ test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 20, 1, 0);
+ test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 21, 0, 0);
+ test(S("abcde"), 0, 1, S(""), 0, 0, 1);
+ test(S("abcde"), 0, 1, S(""), 0, 1, 1);
+ test(S("abcde"), 0, 1, S(""), 1, 0, 0);
+ test(S("abcde"), 0, 1, S("abcde"), 0, 0, 1);
+}
+
+template <class S>
+void test3()
+{
+ test(S("abcde"), 0, 1, S("abcde"), 0, 1, 0);
+ test(S("abcde"), 0, 1, S("abcde"), 0, 2, -1);
+ test(S("abcde"), 0, 1, S("abcde"), 0, 4, -3);
+ test(S("abcde"), 0, 1, S("abcde"), 0, 5, -4);
+ test(S("abcde"), 0, 1, S("abcde"), 0, 6, -4);
+ test(S("abcde"), 0, 1, S("abcde"), 1, 0, 1);
+ test(S("abcde"), 0, 1, S("abcde"), 1, 1, -1);
+ test(S("abcde"), 0, 1, S("abcde"), 1, 2, -1);
+ test(S("abcde"), 0, 1, S("abcde"), 1, 3, -1);
+ test(S("abcde"), 0, 1, S("abcde"), 1, 4, -1);
+ test(S("abcde"), 0, 1, S("abcde"), 1, 5, -1);
+ test(S("abcde"), 0, 1, S("abcde"), 2, 0, 1);
+ test(S("abcde"), 0, 1, S("abcde"), 2, 1, -2);
+ test(S("abcde"), 0, 1, S("abcde"), 2, 2, -2);
+ test(S("abcde"), 0, 1, S("abcde"), 2, 3, -2);
+ test(S("abcde"), 0, 1, S("abcde"), 2, 4, -2);
+ test(S("abcde"), 0, 1, S("abcde"), 4, 0, 1);
+ test(S("abcde"), 0, 1, S("abcde"), 4, 1, -4);
+ test(S("abcde"), 0, 1, S("abcde"), 4, 2, -4);
+ test(S("abcde"), 0, 1, S("abcde"), 5, 0, 1);
+ test(S("abcde"), 0, 1, S("abcde"), 5, 1, 1);
+ test(S("abcde"), 0, 1, S("abcde"), 6, 0, 0);
+ test(S("abcde"), 0, 1, S("abcdefghij"), 0, 0, 1);
+ test(S("abcde"), 0, 1, S("abcdefghij"), 0, 1, 0);
+ test(S("abcde"), 0, 1, S("abcdefghij"), 0, 5, -4);
+ test(S("abcde"), 0, 1, S("abcdefghij"), 0, 9, -8);
+ test(S("abcde"), 0, 1, S("abcdefghij"), 0, 10, -9);
+ test(S("abcde"), 0, 1, S("abcdefghij"), 0, 11, -9);
+ test(S("abcde"), 0, 1, S("abcdefghij"), 1, 0, 1);
+ test(S("abcde"), 0, 1, S("abcdefghij"), 1, 1, -1);
+ test(S("abcde"), 0, 1, S("abcdefghij"), 1, 4, -1);
+ test(S("abcde"), 0, 1, S("abcdefghij"), 1, 8, -1);
+ test(S("abcde"), 0, 1, S("abcdefghij"), 1, 9, -1);
+ test(S("abcde"), 0, 1, S("abcdefghij"), 1, 10, -1);
+ test(S("abcde"), 0, 1, S("abcdefghij"), 5, 0, 1);
+ test(S("abcde"), 0, 1, S("abcdefghij"), 5, 1, -5);
+ test(S("abcde"), 0, 1, S("abcdefghij"), 5, 2, -5);
+ test(S("abcde"), 0, 1, S("abcdefghij"), 5, 4, -5);
+ test(S("abcde"), 0, 1, S("abcdefghij"), 5, 5, -5);
+ test(S("abcde"), 0, 1, S("abcdefghij"), 5, 6, -5);
+ test(S("abcde"), 0, 1, S("abcdefghij"), 9, 0, 1);
+ test(S("abcde"), 0, 1, S("abcdefghij"), 9, 1, -9);
+ test(S("abcde"), 0, 1, S("abcdefghij"), 9, 2, -9);
+ test(S("abcde"), 0, 1, S("abcdefghij"), 10, 0, 1);
+ test(S("abcde"), 0, 1, S("abcdefghij"), 10, 1, 1);
+ test(S("abcde"), 0, 1, S("abcdefghij"), 11, 0, 0);
+ test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 0, 0, 1);
+ test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 0, 1, 0);
+ test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 0, 10, -9);
+ test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 0, 19, -18);
+ test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 0, 20, -19);
+ test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 0, 21, -19);
+ test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 1, 0, 1);
+ test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 1, 1, -1);
+ test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 1, 9, -1);
+ test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 1, 18, -1);
+ test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 1, 19, -1);
+ test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 1, 20, -1);
+ test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 10, 0, 1);
+ test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 10, 1, -10);
+ test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 10, 5, -10);
+ test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 10, 9, -10);
+ test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 10, 10, -10);
+ test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 10, 11, -10);
+ test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 19, 0, 1);
+ test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 19, 1, -19);
+ test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 19, 2, -19);
+ test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 20, 0, 1);
+ test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 20, 1, 1);
+ test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 21, 0, 0);
+ test(S("abcde"), 0, 2, S(""), 0, 0, 2);
+ test(S("abcde"), 0, 2, S(""), 0, 1, 2);
+ test(S("abcde"), 0, 2, S(""), 1, 0, 0);
+ test(S("abcde"), 0, 2, S("abcde"), 0, 0, 2);
+ test(S("abcde"), 0, 2, S("abcde"), 0, 1, 1);
+ test(S("abcde"), 0, 2, S("abcde"), 0, 2, 0);
+ test(S("abcde"), 0, 2, S("abcde"), 0, 4, -2);
+ test(S("abcde"), 0, 2, S("abcde"), 0, 5, -3);
+ test(S("abcde"), 0, 2, S("abcde"), 0, 6, -3);
+ test(S("abcde"), 0, 2, S("abcde"), 1, 0, 2);
+ test(S("abcde"), 0, 2, S("abcde"), 1, 1, -1);
+ test(S("abcde"), 0, 2, S("abcde"), 1, 2, -1);
+ test(S("abcde"), 0, 2, S("abcde"), 1, 3, -1);
+ test(S("abcde"), 0, 2, S("abcde"), 1, 4, -1);
+ test(S("abcde"), 0, 2, S("abcde"), 1, 5, -1);
+ test(S("abcde"), 0, 2, S("abcde"), 2, 0, 2);
+ test(S("abcde"), 0, 2, S("abcde"), 2, 1, -2);
+ test(S("abcde"), 0, 2, S("abcde"), 2, 2, -2);
+ test(S("abcde"), 0, 2, S("abcde"), 2, 3, -2);
+ test(S("abcde"), 0, 2, S("abcde"), 2, 4, -2);
+ test(S("abcde"), 0, 2, S("abcde"), 4, 0, 2);
+ test(S("abcde"), 0, 2, S("abcde"), 4, 1, -4);
+ test(S("abcde"), 0, 2, S("abcde"), 4, 2, -4);
+ test(S("abcde"), 0, 2, S("abcde"), 5, 0, 2);
+ test(S("abcde"), 0, 2, S("abcde"), 5, 1, 2);
+ test(S("abcde"), 0, 2, S("abcde"), 6, 0, 0);
+ test(S("abcde"), 0, 2, S("abcdefghij"), 0, 0, 2);
+ test(S("abcde"), 0, 2, S("abcdefghij"), 0, 1, 1);
+ test(S("abcde"), 0, 2, S("abcdefghij"), 0, 5, -3);
+ test(S("abcde"), 0, 2, S("abcdefghij"), 0, 9, -7);
+}
+
+template <class S>
+void test4()
+{
+ test(S("abcde"), 0, 2, S("abcdefghij"), 0, 10, -8);
+ test(S("abcde"), 0, 2, S("abcdefghij"), 0, 11, -8);
+ test(S("abcde"), 0, 2, S("abcdefghij"), 1, 0, 2);
+ test(S("abcde"), 0, 2, S("abcdefghij"), 1, 1, -1);
+ test(S("abcde"), 0, 2, S("abcdefghij"), 1, 4, -1);
+ test(S("abcde"), 0, 2, S("abcdefghij"), 1, 8, -1);
+ test(S("abcde"), 0, 2, S("abcdefghij"), 1, 9, -1);
+ test(S("abcde"), 0, 2, S("abcdefghij"), 1, 10, -1);
+ test(S("abcde"), 0, 2, S("abcdefghij"), 5, 0, 2);
+ test(S("abcde"), 0, 2, S("abcdefghij"), 5, 1, -5);
+ test(S("abcde"), 0, 2, S("abcdefghij"), 5, 2, -5);
+ test(S("abcde"), 0, 2, S("abcdefghij"), 5, 4, -5);
+ test(S("abcde"), 0, 2, S("abcdefghij"), 5, 5, -5);
+ test(S("abcde"), 0, 2, S("abcdefghij"), 5, 6, -5);
+ test(S("abcde"), 0, 2, S("abcdefghij"), 9, 0, 2);
+ test(S("abcde"), 0, 2, S("abcdefghij"), 9, 1, -9);
+ test(S("abcde"), 0, 2, S("abcdefghij"), 9, 2, -9);
+ test(S("abcde"), 0, 2, S("abcdefghij"), 10, 0, 2);
+ test(S("abcde"), 0, 2, S("abcdefghij"), 10, 1, 2);
+ test(S("abcde"), 0, 2, S("abcdefghij"), 11, 0, 0);
+ test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 0, 0, 2);
+ test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 0, 1, 1);
+ test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 0, 10, -8);
+ test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 0, 19, -17);
+ test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 0, 20, -18);
+ test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 0, 21, -18);
+ test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 1, 0, 2);
+ test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 1, 1, -1);
+ test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 1, 9, -1);
+ test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 1, 18, -1);
+ test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 1, 19, -1);
+ test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 1, 20, -1);
+ test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 10, 0, 2);
+ test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 10, 1, -10);
+ test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 10, 5, -10);
+ test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 10, 9, -10);
+ test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 10, 10, -10);
+ test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 10, 11, -10);
+ test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 19, 0, 2);
+ test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 19, 1, -19);
+ test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 19, 2, -19);
+ test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 20, 0, 2);
+ test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 20, 1, 2);
+ test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 21, 0, 0);
+ test(S("abcde"), 0, 4, S(""), 0, 0, 4);
+ test(S("abcde"), 0, 4, S(""), 0, 1, 4);
+ test(S("abcde"), 0, 4, S(""), 1, 0, 0);
+ test(S("abcde"), 0, 4, S("abcde"), 0, 0, 4);
+ test(S("abcde"), 0, 4, S("abcde"), 0, 1, 3);
+ test(S("abcde"), 0, 4, S("abcde"), 0, 2, 2);
+ test(S("abcde"), 0, 4, S("abcde"), 0, 4, 0);
+ test(S("abcde"), 0, 4, S("abcde"), 0, 5, -1);
+ test(S("abcde"), 0, 4, S("abcde"), 0, 6, -1);
+ test(S("abcde"), 0, 4, S("abcde"), 1, 0, 4);
+ test(S("abcde"), 0, 4, S("abcde"), 1, 1, -1);
+ test(S("abcde"), 0, 4, S("abcde"), 1, 2, -1);
+ test(S("abcde"), 0, 4, S("abcde"), 1, 3, -1);
+ test(S("abcde"), 0, 4, S("abcde"), 1, 4, -1);
+ test(S("abcde"), 0, 4, S("abcde"), 1, 5, -1);
+ test(S("abcde"), 0, 4, S("abcde"), 2, 0, 4);
+ test(S("abcde"), 0, 4, S("abcde"), 2, 1, -2);
+ test(S("abcde"), 0, 4, S("abcde"), 2, 2, -2);
+ test(S("abcde"), 0, 4, S("abcde"), 2, 3, -2);
+ test(S("abcde"), 0, 4, S("abcde"), 2, 4, -2);
+ test(S("abcde"), 0, 4, S("abcde"), 4, 0, 4);
+ test(S("abcde"), 0, 4, S("abcde"), 4, 1, -4);
+ test(S("abcde"), 0, 4, S("abcde"), 4, 2, -4);
+ test(S("abcde"), 0, 4, S("abcde"), 5, 0, 4);
+ test(S("abcde"), 0, 4, S("abcde"), 5, 1, 4);
+ test(S("abcde"), 0, 4, S("abcde"), 6, 0, 0);
+ test(S("abcde"), 0, 4, S("abcdefghij"), 0, 0, 4);
+ test(S("abcde"), 0, 4, S("abcdefghij"), 0, 1, 3);
+ test(S("abcde"), 0, 4, S("abcdefghij"), 0, 5, -1);
+ test(S("abcde"), 0, 4, S("abcdefghij"), 0, 9, -5);
+ test(S("abcde"), 0, 4, S("abcdefghij"), 0, 10, -6);
+ test(S("abcde"), 0, 4, S("abcdefghij"), 0, 11, -6);
+ test(S("abcde"), 0, 4, S("abcdefghij"), 1, 0, 4);
+ test(S("abcde"), 0, 4, S("abcdefghij"), 1, 1, -1);
+ test(S("abcde"), 0, 4, S("abcdefghij"), 1, 4, -1);
+ test(S("abcde"), 0, 4, S("abcdefghij"), 1, 8, -1);
+ test(S("abcde"), 0, 4, S("abcdefghij"), 1, 9, -1);
+ test(S("abcde"), 0, 4, S("abcdefghij"), 1, 10, -1);
+ test(S("abcde"), 0, 4, S("abcdefghij"), 5, 0, 4);
+ test(S("abcde"), 0, 4, S("abcdefghij"), 5, 1, -5);
+ test(S("abcde"), 0, 4, S("abcdefghij"), 5, 2, -5);
+ test(S("abcde"), 0, 4, S("abcdefghij"), 5, 4, -5);
+ test(S("abcde"), 0, 4, S("abcdefghij"), 5, 5, -5);
+ test(S("abcde"), 0, 4, S("abcdefghij"), 5, 6, -5);
+ test(S("abcde"), 0, 4, S("abcdefghij"), 9, 0, 4);
+ test(S("abcde"), 0, 4, S("abcdefghij"), 9, 1, -9);
+ test(S("abcde"), 0, 4, S("abcdefghij"), 9, 2, -9);
+ test(S("abcde"), 0, 4, S("abcdefghij"), 10, 0, 4);
+ test(S("abcde"), 0, 4, S("abcdefghij"), 10, 1, 4);
+ test(S("abcde"), 0, 4, S("abcdefghij"), 11, 0, 0);
+ test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 0, 0, 4);
+ test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 0, 1, 3);
+ test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 0, 10, -6);
+ test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 0, 19, -15);
+ test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 0, 20, -16);
+ test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 0, 21, -16);
+}
+
+template <class S>
+void test5()
+{
+ test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 1, 0, 4);
+ test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 1, 1, -1);
+ test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 1, 9, -1);
+ test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 1, 18, -1);
+ test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 1, 19, -1);
+ test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 1, 20, -1);
+ test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 10, 0, 4);
+ test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 10, 1, -10);
+ test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 10, 5, -10);
+ test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 10, 9, -10);
+ test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 10, 10, -10);
+ test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 10, 11, -10);
+ test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 19, 0, 4);
+ test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 19, 1, -19);
+ test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 19, 2, -19);
+ test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 20, 0, 4);
+ test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 20, 1, 4);
+ test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 21, 0, 0);
+ test(S("abcde"), 0, 5, S(""), 0, 0, 5);
+ test(S("abcde"), 0, 5, S(""), 0, 1, 5);
+ test(S("abcde"), 0, 5, S(""), 1, 0, 0);
+ test(S("abcde"), 0, 5, S("abcde"), 0, 0, 5);
+ test(S("abcde"), 0, 5, S("abcde"), 0, 1, 4);
+ test(S("abcde"), 0, 5, S("abcde"), 0, 2, 3);
+ test(S("abcde"), 0, 5, S("abcde"), 0, 4, 1);
+ test(S("abcde"), 0, 5, S("abcde"), 0, 5, 0);
+ test(S("abcde"), 0, 5, S("abcde"), 0, 6, 0);
+ test(S("abcde"), 0, 5, S("abcde"), 1, 0, 5);
+ test(S("abcde"), 0, 5, S("abcde"), 1, 1, -1);
+ test(S("abcde"), 0, 5, S("abcde"), 1, 2, -1);
+ test(S("abcde"), 0, 5, S("abcde"), 1, 3, -1);
+ test(S("abcde"), 0, 5, S("abcde"), 1, 4, -1);
+ test(S("abcde"), 0, 5, S("abcde"), 1, 5, -1);
+ test(S("abcde"), 0, 5, S("abcde"), 2, 0, 5);
+ test(S("abcde"), 0, 5, S("abcde"), 2, 1, -2);
+ test(S("abcde"), 0, 5, S("abcde"), 2, 2, -2);
+ test(S("abcde"), 0, 5, S("abcde"), 2, 3, -2);
+ test(S("abcde"), 0, 5, S("abcde"), 2, 4, -2);
+ test(S("abcde"), 0, 5, S("abcde"), 4, 0, 5);
+ test(S("abcde"), 0, 5, S("abcde"), 4, 1, -4);
+ test(S("abcde"), 0, 5, S("abcde"), 4, 2, -4);
+ test(S("abcde"), 0, 5, S("abcde"), 5, 0, 5);
+ test(S("abcde"), 0, 5, S("abcde"), 5, 1, 5);
+ test(S("abcde"), 0, 5, S("abcde"), 6, 0, 0);
+ test(S("abcde"), 0, 5, S("abcdefghij"), 0, 0, 5);
+ test(S("abcde"), 0, 5, S("abcdefghij"), 0, 1, 4);
+ test(S("abcde"), 0, 5, S("abcdefghij"), 0, 5, 0);
+ test(S("abcde"), 0, 5, S("abcdefghij"), 0, 9, -4);
+ test(S("abcde"), 0, 5, S("abcdefghij"), 0, 10, -5);
+ test(S("abcde"), 0, 5, S("abcdefghij"), 0, 11, -5);
+ test(S("abcde"), 0, 5, S("abcdefghij"), 1, 0, 5);
+ test(S("abcde"), 0, 5, S("abcdefghij"), 1, 1, -1);
+ test(S("abcde"), 0, 5, S("abcdefghij"), 1, 4, -1);
+ test(S("abcde"), 0, 5, S("abcdefghij"), 1, 8, -1);
+ test(S("abcde"), 0, 5, S("abcdefghij"), 1, 9, -1);
+ test(S("abcde"), 0, 5, S("abcdefghij"), 1, 10, -1);
+ test(S("abcde"), 0, 5, S("abcdefghij"), 5, 0, 5);
+ test(S("abcde"), 0, 5, S("abcdefghij"), 5, 1, -5);
+ test(S("abcde"), 0, 5, S("abcdefghij"), 5, 2, -5);
+ test(S("abcde"), 0, 5, S("abcdefghij"), 5, 4, -5);
+ test(S("abcde"), 0, 5, S("abcdefghij"), 5, 5, -5);
+ test(S("abcde"), 0, 5, S("abcdefghij"), 5, 6, -5);
+ test(S("abcde"), 0, 5, S("abcdefghij"), 9, 0, 5);
+ test(S("abcde"), 0, 5, S("abcdefghij"), 9, 1, -9);
+ test(S("abcde"), 0, 5, S("abcdefghij"), 9, 2, -9);
+ test(S("abcde"), 0, 5, S("abcdefghij"), 10, 0, 5);
+ test(S("abcde"), 0, 5, S("abcdefghij"), 10, 1, 5);
+ test(S("abcde"), 0, 5, S("abcdefghij"), 11, 0, 0);
+ test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 0, 0, 5);
+ test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 0, 1, 4);
+ test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 0, 10, -5);
+ test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 0, 19, -14);
+ test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 0, 20, -15);
+ test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 0, 21, -15);
+ test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 1, 0, 5);
+ test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 1, 1, -1);
+ test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 1, 9, -1);
+ test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 1, 18, -1);
+ test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 1, 19, -1);
+ test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 1, 20, -1);
+ test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 10, 0, 5);
+ test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 10, 1, -10);
+ test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 10, 5, -10);
+ test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 10, 9, -10);
+ test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 10, 10, -10);
+ test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 10, 11, -10);
+ test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 19, 0, 5);
+ test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 19, 1, -19);
+ test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 19, 2, -19);
+ test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 20, 0, 5);
+ test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 20, 1, 5);
+ test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 21, 0, 0);
+ test(S("abcde"), 0, 6, S(""), 0, 0, 5);
+ test(S("abcde"), 0, 6, S(""), 0, 1, 5);
+ test(S("abcde"), 0, 6, S(""), 1, 0, 0);
+ test(S("abcde"), 0, 6, S("abcde"), 0, 0, 5);
+ test(S("abcde"), 0, 6, S("abcde"), 0, 1, 4);
+ test(S("abcde"), 0, 6, S("abcde"), 0, 2, 3);
+ test(S("abcde"), 0, 6, S("abcde"), 0, 4, 1);
+ test(S("abcde"), 0, 6, S("abcde"), 0, 5, 0);
+}
+
+template <class S>
+void test6()
+{
+ test(S("abcde"), 0, 6, S("abcde"), 0, 6, 0);
+ test(S("abcde"), 0, 6, S("abcde"), 1, 0, 5);
+ test(S("abcde"), 0, 6, S("abcde"), 1, 1, -1);
+ test(S("abcde"), 0, 6, S("abcde"), 1, 2, -1);
+ test(S("abcde"), 0, 6, S("abcde"), 1, 3, -1);
+ test(S("abcde"), 0, 6, S("abcde"), 1, 4, -1);
+ test(S("abcde"), 0, 6, S("abcde"), 1, 5, -1);
+ test(S("abcde"), 0, 6, S("abcde"), 2, 0, 5);
+ test(S("abcde"), 0, 6, S("abcde"), 2, 1, -2);
+ test(S("abcde"), 0, 6, S("abcde"), 2, 2, -2);
+ test(S("abcde"), 0, 6, S("abcde"), 2, 3, -2);
+ test(S("abcde"), 0, 6, S("abcde"), 2, 4, -2);
+ test(S("abcde"), 0, 6, S("abcde"), 4, 0, 5);
+ test(S("abcde"), 0, 6, S("abcde"), 4, 1, -4);
+ test(S("abcde"), 0, 6, S("abcde"), 4, 2, -4);
+ test(S("abcde"), 0, 6, S("abcde"), 5, 0, 5);
+ test(S("abcde"), 0, 6, S("abcde"), 5, 1, 5);
+ test(S("abcde"), 0, 6, S("abcde"), 6, 0, 0);
+ test(S("abcde"), 0, 6, S("abcdefghij"), 0, 0, 5);
+ test(S("abcde"), 0, 6, S("abcdefghij"), 0, 1, 4);
+ test(S("abcde"), 0, 6, S("abcdefghij"), 0, 5, 0);
+ test(S("abcde"), 0, 6, S("abcdefghij"), 0, 9, -4);
+ test(S("abcde"), 0, 6, S("abcdefghij"), 0, 10, -5);
+ test(S("abcde"), 0, 6, S("abcdefghij"), 0, 11, -5);
+ test(S("abcde"), 0, 6, S("abcdefghij"), 1, 0, 5);
+ test(S("abcde"), 0, 6, S("abcdefghij"), 1, 1, -1);
+ test(S("abcde"), 0, 6, S("abcdefghij"), 1, 4, -1);
+ test(S("abcde"), 0, 6, S("abcdefghij"), 1, 8, -1);
+ test(S("abcde"), 0, 6, S("abcdefghij"), 1, 9, -1);
+ test(S("abcde"), 0, 6, S("abcdefghij"), 1, 10, -1);
+ test(S("abcde"), 0, 6, S("abcdefghij"), 5, 0, 5);
+ test(S("abcde"), 0, 6, S("abcdefghij"), 5, 1, -5);
+ test(S("abcde"), 0, 6, S("abcdefghij"), 5, 2, -5);
+ test(S("abcde"), 0, 6, S("abcdefghij"), 5, 4, -5);
+ test(S("abcde"), 0, 6, S("abcdefghij"), 5, 5, -5);
+ test(S("abcde"), 0, 6, S("abcdefghij"), 5, 6, -5);
+ test(S("abcde"), 0, 6, S("abcdefghij"), 9, 0, 5);
+ test(S("abcde"), 0, 6, S("abcdefghij"), 9, 1, -9);
+ test(S("abcde"), 0, 6, S("abcdefghij"), 9, 2, -9);
+ test(S("abcde"), 0, 6, S("abcdefghij"), 10, 0, 5);
+ test(S("abcde"), 0, 6, S("abcdefghij"), 10, 1, 5);
+ test(S("abcde"), 0, 6, S("abcdefghij"), 11, 0, 0);
+ test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 0, 0, 5);
+ test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 0, 1, 4);
+ test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 0, 10, -5);
+ test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 0, 19, -14);
+ test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 0, 20, -15);
+ test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 0, 21, -15);
+ test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 1, 0, 5);
+ test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 1, 1, -1);
+ test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 1, 9, -1);
+ test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 1, 18, -1);
+ test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 1, 19, -1);
+ test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 1, 20, -1);
+ test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 10, 0, 5);
+ test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 10, 1, -10);
+ test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 10, 5, -10);
+ test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 10, 9, -10);
+ test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 10, 10, -10);
+ test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 10, 11, -10);
+ test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 19, 0, 5);
+ test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 19, 1, -19);
+ test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 19, 2, -19);
+ test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 20, 0, 5);
+ test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 20, 1, 5);
+ test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 21, 0, 0);
+ test(S("abcde"), 1, 0, S(""), 0, 0, 0);
+ test(S("abcde"), 1, 0, S(""), 0, 1, 0);
+ test(S("abcde"), 1, 0, S(""), 1, 0, 0);
+ test(S("abcde"), 1, 0, S("abcde"), 0, 0, 0);
+ test(S("abcde"), 1, 0, S("abcde"), 0, 1, -1);
+ test(S("abcde"), 1, 0, S("abcde"), 0, 2, -2);
+ test(S("abcde"), 1, 0, S("abcde"), 0, 4, -4);
+ test(S("abcde"), 1, 0, S("abcde"), 0, 5, -5);
+ test(S("abcde"), 1, 0, S("abcde"), 0, 6, -5);
+ test(S("abcde"), 1, 0, S("abcde"), 1, 0, 0);
+ test(S("abcde"), 1, 0, S("abcde"), 1, 1, -1);
+ test(S("abcde"), 1, 0, S("abcde"), 1, 2, -2);
+ test(S("abcde"), 1, 0, S("abcde"), 1, 3, -3);
+ test(S("abcde"), 1, 0, S("abcde"), 1, 4, -4);
+ test(S("abcde"), 1, 0, S("abcde"), 1, 5, -4);
+ test(S("abcde"), 1, 0, S("abcde"), 2, 0, 0);
+ test(S("abcde"), 1, 0, S("abcde"), 2, 1, -1);
+ test(S("abcde"), 1, 0, S("abcde"), 2, 2, -2);
+ test(S("abcde"), 1, 0, S("abcde"), 2, 3, -3);
+ test(S("abcde"), 1, 0, S("abcde"), 2, 4, -3);
+ test(S("abcde"), 1, 0, S("abcde"), 4, 0, 0);
+ test(S("abcde"), 1, 0, S("abcde"), 4, 1, -1);
+ test(S("abcde"), 1, 0, S("abcde"), 4, 2, -1);
+ test(S("abcde"), 1, 0, S("abcde"), 5, 0, 0);
+ test(S("abcde"), 1, 0, S("abcde"), 5, 1, 0);
+ test(S("abcde"), 1, 0, S("abcde"), 6, 0, 0);
+ test(S("abcde"), 1, 0, S("abcdefghij"), 0, 0, 0);
+ test(S("abcde"), 1, 0, S("abcdefghij"), 0, 1, -1);
+ test(S("abcde"), 1, 0, S("abcdefghij"), 0, 5, -5);
+ test(S("abcde"), 1, 0, S("abcdefghij"), 0, 9, -9);
+ test(S("abcde"), 1, 0, S("abcdefghij"), 0, 10, -10);
+ test(S("abcde"), 1, 0, S("abcdefghij"), 0, 11, -10);
+ test(S("abcde"), 1, 0, S("abcdefghij"), 1, 0, 0);
+ test(S("abcde"), 1, 0, S("abcdefghij"), 1, 1, -1);
+}
+
+template <class S>
+void test7()
+{
+ test(S("abcde"), 1, 0, S("abcdefghij"), 1, 4, -4);
+ test(S("abcde"), 1, 0, S("abcdefghij"), 1, 8, -8);
+ test(S("abcde"), 1, 0, S("abcdefghij"), 1, 9, -9);
+ test(S("abcde"), 1, 0, S("abcdefghij"), 1, 10, -9);
+ test(S("abcde"), 1, 0, S("abcdefghij"), 5, 0, 0);
+ test(S("abcde"), 1, 0, S("abcdefghij"), 5, 1, -1);
+ test(S("abcde"), 1, 0, S("abcdefghij"), 5, 2, -2);
+ test(S("abcde"), 1, 0, S("abcdefghij"), 5, 4, -4);
+ test(S("abcde"), 1, 0, S("abcdefghij"), 5, 5, -5);
+ test(S("abcde"), 1, 0, S("abcdefghij"), 5, 6, -5);
+ test(S("abcde"), 1, 0, S("abcdefghij"), 9, 0, 0);
+ test(S("abcde"), 1, 0, S("abcdefghij"), 9, 1, -1);
+ test(S("abcde"), 1, 0, S("abcdefghij"), 9, 2, -1);
+ test(S("abcde"), 1, 0, S("abcdefghij"), 10, 0, 0);
+ test(S("abcde"), 1, 0, S("abcdefghij"), 10, 1, 0);
+ test(S("abcde"), 1, 0, S("abcdefghij"), 11, 0, 0);
+ test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 0, 0, 0);
+ test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 0, 1, -1);
+ test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 0, 10, -10);
+ test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 0, 19, -19);
+ test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 0, 20, -20);
+ test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 0, 21, -20);
+ test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 1, 0, 0);
+ test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 1, 1, -1);
+ test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 1, 9, -9);
+ test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 1, 18, -18);
+ test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 1, 19, -19);
+ test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 1, 20, -19);
+ test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 10, 0, 0);
+ test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 10, 1, -1);
+ test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 10, 5, -5);
+ test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 10, 9, -9);
+ test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 10, 10, -10);
+ test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 10, 11, -10);
+ test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 19, 0, 0);
+ test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 19, 1, -1);
+ test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 19, 2, -1);
+ test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 20, 0, 0);
+ test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 20, 1, 0);
+ test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 21, 0, 0);
+ test(S("abcde"), 1, 1, S(""), 0, 0, 1);
+ test(S("abcde"), 1, 1, S(""), 0, 1, 1);
+ test(S("abcde"), 1, 1, S(""), 1, 0, 0);
+ test(S("abcde"), 1, 1, S("abcde"), 0, 0, 1);
+ test(S("abcde"), 1, 1, S("abcde"), 0, 1, 1);
+ test(S("abcde"), 1, 1, S("abcde"), 0, 2, 1);
+ test(S("abcde"), 1, 1, S("abcde"), 0, 4, 1);
+ test(S("abcde"), 1, 1, S("abcde"), 0, 5, 1);
+ test(S("abcde"), 1, 1, S("abcde"), 0, 6, 1);
+ test(S("abcde"), 1, 1, S("abcde"), 1, 0, 1);
+ test(S("abcde"), 1, 1, S("abcde"), 1, 1, 0);
+ test(S("abcde"), 1, 1, S("abcde"), 1, 2, -1);
+ test(S("abcde"), 1, 1, S("abcde"), 1, 3, -2);
+ test(S("abcde"), 1, 1, S("abcde"), 1, 4, -3);
+ test(S("abcde"), 1, 1, S("abcde"), 1, 5, -3);
+ test(S("abcde"), 1, 1, S("abcde"), 2, 0, 1);
+ test(S("abcde"), 1, 1, S("abcde"), 2, 1, -1);
+ test(S("abcde"), 1, 1, S("abcde"), 2, 2, -1);
+ test(S("abcde"), 1, 1, S("abcde"), 2, 3, -1);
+ test(S("abcde"), 1, 1, S("abcde"), 2, 4, -1);
+ test(S("abcde"), 1, 1, S("abcde"), 4, 0, 1);
+ test(S("abcde"), 1, 1, S("abcde"), 4, 1, -3);
+ test(S("abcde"), 1, 1, S("abcde"), 4, 2, -3);
+ test(S("abcde"), 1, 1, S("abcde"), 5, 0, 1);
+ test(S("abcde"), 1, 1, S("abcde"), 5, 1, 1);
+ test(S("abcde"), 1, 1, S("abcde"), 6, 0, 0);
+ test(S("abcde"), 1, 1, S("abcdefghij"), 0, 0, 1);
+ test(S("abcde"), 1, 1, S("abcdefghij"), 0, 1, 1);
+ test(S("abcde"), 1, 1, S("abcdefghij"), 0, 5, 1);
+ test(S("abcde"), 1, 1, S("abcdefghij"), 0, 9, 1);
+ test(S("abcde"), 1, 1, S("abcdefghij"), 0, 10, 1);
+ test(S("abcde"), 1, 1, S("abcdefghij"), 0, 11, 1);
+ test(S("abcde"), 1, 1, S("abcdefghij"), 1, 0, 1);
+ test(S("abcde"), 1, 1, S("abcdefghij"), 1, 1, 0);
+ test(S("abcde"), 1, 1, S("abcdefghij"), 1, 4, -3);
+ test(S("abcde"), 1, 1, S("abcdefghij"), 1, 8, -7);
+ test(S("abcde"), 1, 1, S("abcdefghij"), 1, 9, -8);
+ test(S("abcde"), 1, 1, S("abcdefghij"), 1, 10, -8);
+ test(S("abcde"), 1, 1, S("abcdefghij"), 5, 0, 1);
+ test(S("abcde"), 1, 1, S("abcdefghij"), 5, 1, -4);
+ test(S("abcde"), 1, 1, S("abcdefghij"), 5, 2, -4);
+ test(S("abcde"), 1, 1, S("abcdefghij"), 5, 4, -4);
+ test(S("abcde"), 1, 1, S("abcdefghij"), 5, 5, -4);
+ test(S("abcde"), 1, 1, S("abcdefghij"), 5, 6, -4);
+ test(S("abcde"), 1, 1, S("abcdefghij"), 9, 0, 1);
+ test(S("abcde"), 1, 1, S("abcdefghij"), 9, 1, -8);
+ test(S("abcde"), 1, 1, S("abcdefghij"), 9, 2, -8);
+ test(S("abcde"), 1, 1, S("abcdefghij"), 10, 0, 1);
+ test(S("abcde"), 1, 1, S("abcdefghij"), 10, 1, 1);
+ test(S("abcde"), 1, 1, S("abcdefghij"), 11, 0, 0);
+ test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 0, 0, 1);
+ test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 0, 1, 1);
+ test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 0, 10, 1);
+ test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 0, 19, 1);
+ test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 0, 20, 1);
+ test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 0, 21, 1);
+ test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 1, 0, 1);
+ test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 1, 1, 0);
+ test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 1, 9, -8);
+ test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 1, 18, -17);
+}
+
+template <class S>
+void test8()
+{
+ test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 1, 19, -18);
+ test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 1, 20, -18);
+ test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 10, 0, 1);
+ test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 10, 1, -9);
+ test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 10, 5, -9);
+ test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 10, 9, -9);
+ test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 10, 10, -9);
+ test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 10, 11, -9);
+ test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 19, 0, 1);
+ test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 19, 1, -18);
+ test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 19, 2, -18);
+ test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 20, 0, 1);
+ test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 20, 1, 1);
+ test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 21, 0, 0);
+ test(S("abcde"), 1, 2, S(""), 0, 0, 2);
+ test(S("abcde"), 1, 2, S(""), 0, 1, 2);
+ test(S("abcde"), 1, 2, S(""), 1, 0, 0);
+ test(S("abcde"), 1, 2, S("abcde"), 0, 0, 2);
+ test(S("abcde"), 1, 2, S("abcde"), 0, 1, 1);
+ test(S("abcde"), 1, 2, S("abcde"), 0, 2, 1);
+ test(S("abcde"), 1, 2, S("abcde"), 0, 4, 1);
+ test(S("abcde"), 1, 2, S("abcde"), 0, 5, 1);
+ test(S("abcde"), 1, 2, S("abcde"), 0, 6, 1);
+ test(S("abcde"), 1, 2, S("abcde"), 1, 0, 2);
+ test(S("abcde"), 1, 2, S("abcde"), 1, 1, 1);
+ test(S("abcde"), 1, 2, S("abcde"), 1, 2, 0);
+ test(S("abcde"), 1, 2, S("abcde"), 1, 3, -1);
+ test(S("abcde"), 1, 2, S("abcde"), 1, 4, -2);
+ test(S("abcde"), 1, 2, S("abcde"), 1, 5, -2);
+ test(S("abcde"), 1, 2, S("abcde"), 2, 0, 2);
+ test(S("abcde"), 1, 2, S("abcde"), 2, 1, -1);
+ test(S("abcde"), 1, 2, S("abcde"), 2, 2, -1);
+ test(S("abcde"), 1, 2, S("abcde"), 2, 3, -1);
+ test(S("abcde"), 1, 2, S("abcde"), 2, 4, -1);
+ test(S("abcde"), 1, 2, S("abcde"), 4, 0, 2);
+ test(S("abcde"), 1, 2, S("abcde"), 4, 1, -3);
+ test(S("abcde"), 1, 2, S("abcde"), 4, 2, -3);
+ test(S("abcde"), 1, 2, S("abcde"), 5, 0, 2);
+ test(S("abcde"), 1, 2, S("abcde"), 5, 1, 2);
+ test(S("abcde"), 1, 2, S("abcde"), 6, 0, 0);
+ test(S("abcde"), 1, 2, S("abcdefghij"), 0, 0, 2);
+ test(S("abcde"), 1, 2, S("abcdefghij"), 0, 1, 1);
+ test(S("abcde"), 1, 2, S("abcdefghij"), 0, 5, 1);
+ test(S("abcde"), 1, 2, S("abcdefghij"), 0, 9, 1);
+ test(S("abcde"), 1, 2, S("abcdefghij"), 0, 10, 1);
+ test(S("abcde"), 1, 2, S("abcdefghij"), 0, 11, 1);
+ test(S("abcde"), 1, 2, S("abcdefghij"), 1, 0, 2);
+ test(S("abcde"), 1, 2, S("abcdefghij"), 1, 1, 1);
+ test(S("abcde"), 1, 2, S("abcdefghij"), 1, 4, -2);
+ test(S("abcde"), 1, 2, S("abcdefghij"), 1, 8, -6);
+ test(S("abcde"), 1, 2, S("abcdefghij"), 1, 9, -7);
+ test(S("abcde"), 1, 2, S("abcdefghij"), 1, 10, -7);
+ test(S("abcde"), 1, 2, S("abcdefghij"), 5, 0, 2);
+ test(S("abcde"), 1, 2, S("abcdefghij"), 5, 1, -4);
+ test(S("abcde"), 1, 2, S("abcdefghij"), 5, 2, -4);
+ test(S("abcde"), 1, 2, S("abcdefghij"), 5, 4, -4);
+ test(S("abcde"), 1, 2, S("abcdefghij"), 5, 5, -4);
+ test(S("abcde"), 1, 2, S("abcdefghij"), 5, 6, -4);
+ test(S("abcde"), 1, 2, S("abcdefghij"), 9, 0, 2);
+ test(S("abcde"), 1, 2, S("abcdefghij"), 9, 1, -8);
+ test(S("abcde"), 1, 2, S("abcdefghij"), 9, 2, -8);
+ test(S("abcde"), 1, 2, S("abcdefghij"), 10, 0, 2);
+ test(S("abcde"), 1, 2, S("abcdefghij"), 10, 1, 2);
+ test(S("abcde"), 1, 2, S("abcdefghij"), 11, 0, 0);
+ test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 0, 0, 2);
+ test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 0, 1, 1);
+ test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 0, 10, 1);
+ test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 0, 19, 1);
+ test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 0, 20, 1);
+ test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 0, 21, 1);
+ test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 1, 0, 2);
+ test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 1, 1, 1);
+ test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 1, 9, -7);
+ test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 1, 18, -16);
+ test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 1, 19, -17);
+ test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 1, 20, -17);
+ test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 10, 0, 2);
+ test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 10, 1, -9);
+ test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 10, 5, -9);
+ test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 10, 9, -9);
+ test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 10, 10, -9);
+ test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 10, 11, -9);
+ test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 19, 0, 2);
+ test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 19, 1, -18);
+ test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 19, 2, -18);
+ test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 20, 0, 2);
+ test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 20, 1, 2);
+ test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 21, 0, 0);
+ test(S("abcde"), 1, 3, S(""), 0, 0, 3);
+ test(S("abcde"), 1, 3, S(""), 0, 1, 3);
+ test(S("abcde"), 1, 3, S(""), 1, 0, 0);
+ test(S("abcde"), 1, 3, S("abcde"), 0, 0, 3);
+ test(S("abcde"), 1, 3, S("abcde"), 0, 1, 1);
+ test(S("abcde"), 1, 3, S("abcde"), 0, 2, 1);
+ test(S("abcde"), 1, 3, S("abcde"), 0, 4, 1);
+ test(S("abcde"), 1, 3, S("abcde"), 0, 5, 1);
+ test(S("abcde"), 1, 3, S("abcde"), 0, 6, 1);
+ test(S("abcde"), 1, 3, S("abcde"), 1, 0, 3);
+ test(S("abcde"), 1, 3, S("abcde"), 1, 1, 2);
+ test(S("abcde"), 1, 3, S("abcde"), 1, 2, 1);
+}
+
+template <class S>
+void test9()
+{
+ test(S("abcde"), 1, 3, S("abcde"), 1, 3, 0);
+ test(S("abcde"), 1, 3, S("abcde"), 1, 4, -1);
+ test(S("abcde"), 1, 3, S("abcde"), 1, 5, -1);
+ test(S("abcde"), 1, 3, S("abcde"), 2, 0, 3);
+ test(S("abcde"), 1, 3, S("abcde"), 2, 1, -1);
+ test(S("abcde"), 1, 3, S("abcde"), 2, 2, -1);
+ test(S("abcde"), 1, 3, S("abcde"), 2, 3, -1);
+ test(S("abcde"), 1, 3, S("abcde"), 2, 4, -1);
+ test(S("abcde"), 1, 3, S("abcde"), 4, 0, 3);
+ test(S("abcde"), 1, 3, S("abcde"), 4, 1, -3);
+ test(S("abcde"), 1, 3, S("abcde"), 4, 2, -3);
+ test(S("abcde"), 1, 3, S("abcde"), 5, 0, 3);
+ test(S("abcde"), 1, 3, S("abcde"), 5, 1, 3);
+ test(S("abcde"), 1, 3, S("abcde"), 6, 0, 0);
+ test(S("abcde"), 1, 3, S("abcdefghij"), 0, 0, 3);
+ test(S("abcde"), 1, 3, S("abcdefghij"), 0, 1, 1);
+ test(S("abcde"), 1, 3, S("abcdefghij"), 0, 5, 1);
+ test(S("abcde"), 1, 3, S("abcdefghij"), 0, 9, 1);
+ test(S("abcde"), 1, 3, S("abcdefghij"), 0, 10, 1);
+ test(S("abcde"), 1, 3, S("abcdefghij"), 0, 11, 1);
+ test(S("abcde"), 1, 3, S("abcdefghij"), 1, 0, 3);
+ test(S("abcde"), 1, 3, S("abcdefghij"), 1, 1, 2);
+ test(S("abcde"), 1, 3, S("abcdefghij"), 1, 4, -1);
+ test(S("abcde"), 1, 3, S("abcdefghij"), 1, 8, -5);
+ test(S("abcde"), 1, 3, S("abcdefghij"), 1, 9, -6);
+ test(S("abcde"), 1, 3, S("abcdefghij"), 1, 10, -6);
+ test(S("abcde"), 1, 3, S("abcdefghij"), 5, 0, 3);
+ test(S("abcde"), 1, 3, S("abcdefghij"), 5, 1, -4);
+ test(S("abcde"), 1, 3, S("abcdefghij"), 5, 2, -4);
+ test(S("abcde"), 1, 3, S("abcdefghij"), 5, 4, -4);
+ test(S("abcde"), 1, 3, S("abcdefghij"), 5, 5, -4);
+ test(S("abcde"), 1, 3, S("abcdefghij"), 5, 6, -4);
+ test(S("abcde"), 1, 3, S("abcdefghij"), 9, 0, 3);
+ test(S("abcde"), 1, 3, S("abcdefghij"), 9, 1, -8);
+ test(S("abcde"), 1, 3, S("abcdefghij"), 9, 2, -8);
+ test(S("abcde"), 1, 3, S("abcdefghij"), 10, 0, 3);
+ test(S("abcde"), 1, 3, S("abcdefghij"), 10, 1, 3);
+ test(S("abcde"), 1, 3, S("abcdefghij"), 11, 0, 0);
+ test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 0, 0, 3);
+ test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 0, 1, 1);
+ test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 0, 10, 1);
+ test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 0, 19, 1);
+ test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 0, 20, 1);
+ test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 0, 21, 1);
+ test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 1, 0, 3);
+ test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 1, 1, 2);
+ test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 1, 9, -6);
+ test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 1, 18, -15);
+ test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 1, 19, -16);
+ test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 1, 20, -16);
+ test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 10, 0, 3);
+ test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 10, 1, -9);
+ test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 10, 5, -9);
+ test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 10, 9, -9);
+ test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 10, 10, -9);
+ test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 10, 11, -9);
+ test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 19, 0, 3);
+ test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 19, 1, -18);
+ test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 19, 2, -18);
+ test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 20, 0, 3);
+ test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 20, 1, 3);
+ test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 21, 0, 0);
+ test(S("abcde"), 1, 4, S(""), 0, 0, 4);
+ test(S("abcde"), 1, 4, S(""), 0, 1, 4);
+ test(S("abcde"), 1, 4, S(""), 1, 0, 0);
+ test(S("abcde"), 1, 4, S("abcde"), 0, 0, 4);
+ test(S("abcde"), 1, 4, S("abcde"), 0, 1, 1);
+ test(S("abcde"), 1, 4, S("abcde"), 0, 2, 1);
+ test(S("abcde"), 1, 4, S("abcde"), 0, 4, 1);
+ test(S("abcde"), 1, 4, S("abcde"), 0, 5, 1);
+ test(S("abcde"), 1, 4, S("abcde"), 0, 6, 1);
+ test(S("abcde"), 1, 4, S("abcde"), 1, 0, 4);
+ test(S("abcde"), 1, 4, S("abcde"), 1, 1, 3);
+ test(S("abcde"), 1, 4, S("abcde"), 1, 2, 2);
+ test(S("abcde"), 1, 4, S("abcde"), 1, 3, 1);
+ test(S("abcde"), 1, 4, S("abcde"), 1, 4, 0);
+ test(S("abcde"), 1, 4, S("abcde"), 1, 5, 0);
+ test(S("abcde"), 1, 4, S("abcde"), 2, 0, 4);
+ test(S("abcde"), 1, 4, S("abcde"), 2, 1, -1);
+ test(S("abcde"), 1, 4, S("abcde"), 2, 2, -1);
+ test(S("abcde"), 1, 4, S("abcde"), 2, 3, -1);
+ test(S("abcde"), 1, 4, S("abcde"), 2, 4, -1);
+ test(S("abcde"), 1, 4, S("abcde"), 4, 0, 4);
+ test(S("abcde"), 1, 4, S("abcde"), 4, 1, -3);
+ test(S("abcde"), 1, 4, S("abcde"), 4, 2, -3);
+ test(S("abcde"), 1, 4, S("abcde"), 5, 0, 4);
+ test(S("abcde"), 1, 4, S("abcde"), 5, 1, 4);
+ test(S("abcde"), 1, 4, S("abcde"), 6, 0, 0);
+ test(S("abcde"), 1, 4, S("abcdefghij"), 0, 0, 4);
+ test(S("abcde"), 1, 4, S("abcdefghij"), 0, 1, 1);
+ test(S("abcde"), 1, 4, S("abcdefghij"), 0, 5, 1);
+ test(S("abcde"), 1, 4, S("abcdefghij"), 0, 9, 1);
+ test(S("abcde"), 1, 4, S("abcdefghij"), 0, 10, 1);
+ test(S("abcde"), 1, 4, S("abcdefghij"), 0, 11, 1);
+ test(S("abcde"), 1, 4, S("abcdefghij"), 1, 0, 4);
+ test(S("abcde"), 1, 4, S("abcdefghij"), 1, 1, 3);
+ test(S("abcde"), 1, 4, S("abcdefghij"), 1, 4, 0);
+ test(S("abcde"), 1, 4, S("abcdefghij"), 1, 8, -4);
+ test(S("abcde"), 1, 4, S("abcdefghij"), 1, 9, -5);
+ test(S("abcde"), 1, 4, S("abcdefghij"), 1, 10, -5);
+}
+
+template <class S>
+void test10()
+{
+ test(S("abcde"), 1, 4, S("abcdefghij"), 5, 0, 4);
+ test(S("abcde"), 1, 4, S("abcdefghij"), 5, 1, -4);
+ test(S("abcde"), 1, 4, S("abcdefghij"), 5, 2, -4);
+ test(S("abcde"), 1, 4, S("abcdefghij"), 5, 4, -4);
+ test(S("abcde"), 1, 4, S("abcdefghij"), 5, 5, -4);
+ test(S("abcde"), 1, 4, S("abcdefghij"), 5, 6, -4);
+ test(S("abcde"), 1, 4, S("abcdefghij"), 9, 0, 4);
+ test(S("abcde"), 1, 4, S("abcdefghij"), 9, 1, -8);
+ test(S("abcde"), 1, 4, S("abcdefghij"), 9, 2, -8);
+ test(S("abcde"), 1, 4, S("abcdefghij"), 10, 0, 4);
+ test(S("abcde"), 1, 4, S("abcdefghij"), 10, 1, 4);
+ test(S("abcde"), 1, 4, S("abcdefghij"), 11, 0, 0);
+ test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 0, 0, 4);
+ test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 0, 1, 1);
+ test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 0, 10, 1);
+ test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 0, 19, 1);
+ test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 0, 20, 1);
+ test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 0, 21, 1);
+ test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 1, 0, 4);
+ test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 1, 1, 3);
+ test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 1, 9, -5);
+ test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 1, 18, -14);
+ test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 1, 19, -15);
+ test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 1, 20, -15);
+ test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 10, 0, 4);
+ test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 10, 1, -9);
+ test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 10, 5, -9);
+ test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 10, 9, -9);
+ test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 10, 10, -9);
+ test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 10, 11, -9);
+ test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 19, 0, 4);
+ test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 19, 1, -18);
+ test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 19, 2, -18);
+ test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 20, 0, 4);
+ test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 20, 1, 4);
+ test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 21, 0, 0);
+ test(S("abcde"), 1, 5, S(""), 0, 0, 4);
+ test(S("abcde"), 1, 5, S(""), 0, 1, 4);
+ test(S("abcde"), 1, 5, S(""), 1, 0, 0);
+ test(S("abcde"), 1, 5, S("abcde"), 0, 0, 4);
+ test(S("abcde"), 1, 5, S("abcde"), 0, 1, 1);
+ test(S("abcde"), 1, 5, S("abcde"), 0, 2, 1);
+ test(S("abcde"), 1, 5, S("abcde"), 0, 4, 1);
+ test(S("abcde"), 1, 5, S("abcde"), 0, 5, 1);
+ test(S("abcde"), 1, 5, S("abcde"), 0, 6, 1);
+ test(S("abcde"), 1, 5, S("abcde"), 1, 0, 4);
+ test(S("abcde"), 1, 5, S("abcde"), 1, 1, 3);
+ test(S("abcde"), 1, 5, S("abcde"), 1, 2, 2);
+ test(S("abcde"), 1, 5, S("abcde"), 1, 3, 1);
+ test(S("abcde"), 1, 5, S("abcde"), 1, 4, 0);
+ test(S("abcde"), 1, 5, S("abcde"), 1, 5, 0);
+ test(S("abcde"), 1, 5, S("abcde"), 2, 0, 4);
+ test(S("abcde"), 1, 5, S("abcde"), 2, 1, -1);
+ test(S("abcde"), 1, 5, S("abcde"), 2, 2, -1);
+ test(S("abcde"), 1, 5, S("abcde"), 2, 3, -1);
+ test(S("abcde"), 1, 5, S("abcde"), 2, 4, -1);
+ test(S("abcde"), 1, 5, S("abcde"), 4, 0, 4);
+ test(S("abcde"), 1, 5, S("abcde"), 4, 1, -3);
+ test(S("abcde"), 1, 5, S("abcde"), 4, 2, -3);
+ test(S("abcde"), 1, 5, S("abcde"), 5, 0, 4);
+ test(S("abcde"), 1, 5, S("abcde"), 5, 1, 4);
+ test(S("abcde"), 1, 5, S("abcde"), 6, 0, 0);
+ test(S("abcde"), 1, 5, S("abcdefghij"), 0, 0, 4);
+ test(S("abcde"), 1, 5, S("abcdefghij"), 0, 1, 1);
+ test(S("abcde"), 1, 5, S("abcdefghij"), 0, 5, 1);
+ test(S("abcde"), 1, 5, S("abcdefghij"), 0, 9, 1);
+ test(S("abcde"), 1, 5, S("abcdefghij"), 0, 10, 1);
+ test(S("abcde"), 1, 5, S("abcdefghij"), 0, 11, 1);
+ test(S("abcde"), 1, 5, S("abcdefghij"), 1, 0, 4);
+ test(S("abcde"), 1, 5, S("abcdefghij"), 1, 1, 3);
+ test(S("abcde"), 1, 5, S("abcdefghij"), 1, 4, 0);
+ test(S("abcde"), 1, 5, S("abcdefghij"), 1, 8, -4);
+ test(S("abcde"), 1, 5, S("abcdefghij"), 1, 9, -5);
+ test(S("abcde"), 1, 5, S("abcdefghij"), 1, 10, -5);
+ test(S("abcde"), 1, 5, S("abcdefghij"), 5, 0, 4);
+ test(S("abcde"), 1, 5, S("abcdefghij"), 5, 1, -4);
+ test(S("abcde"), 1, 5, S("abcdefghij"), 5, 2, -4);
+ test(S("abcde"), 1, 5, S("abcdefghij"), 5, 4, -4);
+ test(S("abcde"), 1, 5, S("abcdefghij"), 5, 5, -4);
+ test(S("abcde"), 1, 5, S("abcdefghij"), 5, 6, -4);
+ test(S("abcde"), 1, 5, S("abcdefghij"), 9, 0, 4);
+ test(S("abcde"), 1, 5, S("abcdefghij"), 9, 1, -8);
+ test(S("abcde"), 1, 5, S("abcdefghij"), 9, 2, -8);
+ test(S("abcde"), 1, 5, S("abcdefghij"), 10, 0, 4);
+ test(S("abcde"), 1, 5, S("abcdefghij"), 10, 1, 4);
+ test(S("abcde"), 1, 5, S("abcdefghij"), 11, 0, 0);
+ test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 0, 0, 4);
+ test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 0, 1, 1);
+ test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 0, 10, 1);
+ test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 0, 19, 1);
+ test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 0, 20, 1);
+ test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 0, 21, 1);
+ test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 1, 0, 4);
+ test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 1, 1, 3);
+ test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 1, 9, -5);
+ test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 1, 18, -14);
+ test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 1, 19, -15);
+ test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 1, 20, -15);
+ test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 10, 0, 4);
+ test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 10, 1, -9);
+}
+
+template <class S>
+void test11()
+{
+ test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 10, 5, -9);
+ test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 10, 9, -9);
+ test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 10, 10, -9);
+ test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 10, 11, -9);
+ test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 19, 0, 4);
+ test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 19, 1, -18);
+ test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 19, 2, -18);
+ test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 20, 0, 4);
+ test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 20, 1, 4);
+ test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 21, 0, 0);
+ test(S("abcde"), 2, 0, S(""), 0, 0, 0);
+ test(S("abcde"), 2, 0, S(""), 0, 1, 0);
+ test(S("abcde"), 2, 0, S(""), 1, 0, 0);
+ test(S("abcde"), 2, 0, S("abcde"), 0, 0, 0);
+ test(S("abcde"), 2, 0, S("abcde"), 0, 1, -1);
+ test(S("abcde"), 2, 0, S("abcde"), 0, 2, -2);
+ test(S("abcde"), 2, 0, S("abcde"), 0, 4, -4);
+ test(S("abcde"), 2, 0, S("abcde"), 0, 5, -5);
+ test(S("abcde"), 2, 0, S("abcde"), 0, 6, -5);
+ test(S("abcde"), 2, 0, S("abcde"), 1, 0, 0);
+ test(S("abcde"), 2, 0, S("abcde"), 1, 1, -1);
+ test(S("abcde"), 2, 0, S("abcde"), 1, 2, -2);
+ test(S("abcde"), 2, 0, S("abcde"), 1, 3, -3);
+ test(S("abcde"), 2, 0, S("abcde"), 1, 4, -4);
+ test(S("abcde"), 2, 0, S("abcde"), 1, 5, -4);
+ test(S("abcde"), 2, 0, S("abcde"), 2, 0, 0);
+ test(S("abcde"), 2, 0, S("abcde"), 2, 1, -1);
+ test(S("abcde"), 2, 0, S("abcde"), 2, 2, -2);
+ test(S("abcde"), 2, 0, S("abcde"), 2, 3, -3);
+ test(S("abcde"), 2, 0, S("abcde"), 2, 4, -3);
+ test(S("abcde"), 2, 0, S("abcde"), 4, 0, 0);
+ test(S("abcde"), 2, 0, S("abcde"), 4, 1, -1);
+ test(S("abcde"), 2, 0, S("abcde"), 4, 2, -1);
+ test(S("abcde"), 2, 0, S("abcde"), 5, 0, 0);
+ test(S("abcde"), 2, 0, S("abcde"), 5, 1, 0);
+ test(S("abcde"), 2, 0, S("abcde"), 6, 0, 0);
+ test(S("abcde"), 2, 0, S("abcdefghij"), 0, 0, 0);
+ test(S("abcde"), 2, 0, S("abcdefghij"), 0, 1, -1);
+ test(S("abcde"), 2, 0, S("abcdefghij"), 0, 5, -5);
+ test(S("abcde"), 2, 0, S("abcdefghij"), 0, 9, -9);
+ test(S("abcde"), 2, 0, S("abcdefghij"), 0, 10, -10);
+ test(S("abcde"), 2, 0, S("abcdefghij"), 0, 11, -10);
+ test(S("abcde"), 2, 0, S("abcdefghij"), 1, 0, 0);
+ test(S("abcde"), 2, 0, S("abcdefghij"), 1, 1, -1);
+ test(S("abcde"), 2, 0, S("abcdefghij"), 1, 4, -4);
+ test(S("abcde"), 2, 0, S("abcdefghij"), 1, 8, -8);
+ test(S("abcde"), 2, 0, S("abcdefghij"), 1, 9, -9);
+ test(S("abcde"), 2, 0, S("abcdefghij"), 1, 10, -9);
+ test(S("abcde"), 2, 0, S("abcdefghij"), 5, 0, 0);
+ test(S("abcde"), 2, 0, S("abcdefghij"), 5, 1, -1);
+ test(S("abcde"), 2, 0, S("abcdefghij"), 5, 2, -2);
+ test(S("abcde"), 2, 0, S("abcdefghij"), 5, 4, -4);
+ test(S("abcde"), 2, 0, S("abcdefghij"), 5, 5, -5);
+ test(S("abcde"), 2, 0, S("abcdefghij"), 5, 6, -5);
+ test(S("abcde"), 2, 0, S("abcdefghij"), 9, 0, 0);
+ test(S("abcde"), 2, 0, S("abcdefghij"), 9, 1, -1);
+ test(S("abcde"), 2, 0, S("abcdefghij"), 9, 2, -1);
+ test(S("abcde"), 2, 0, S("abcdefghij"), 10, 0, 0);
+ test(S("abcde"), 2, 0, S("abcdefghij"), 10, 1, 0);
+ test(S("abcde"), 2, 0, S("abcdefghij"), 11, 0, 0);
+ test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 0, 0, 0);
+ test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 0, 1, -1);
+ test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 0, 10, -10);
+ test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 0, 19, -19);
+ test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 0, 20, -20);
+ test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 0, 21, -20);
+ test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 1, 0, 0);
+ test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 1, 1, -1);
+ test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 1, 9, -9);
+ test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 1, 18, -18);
+ test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 1, 19, -19);
+ test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 1, 20, -19);
+ test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 10, 0, 0);
+ test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 10, 1, -1);
+ test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 10, 5, -5);
+ test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 10, 9, -9);
+ test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 10, 10, -10);
+ test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 10, 11, -10);
+ test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 19, 0, 0);
+ test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 19, 1, -1);
+ test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 19, 2, -1);
+ test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 20, 0, 0);
+ test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 20, 1, 0);
+ test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 21, 0, 0);
+ test(S("abcde"), 2, 1, S(""), 0, 0, 1);
+ test(S("abcde"), 2, 1, S(""), 0, 1, 1);
+ test(S("abcde"), 2, 1, S(""), 1, 0, 0);
+ test(S("abcde"), 2, 1, S("abcde"), 0, 0, 1);
+ test(S("abcde"), 2, 1, S("abcde"), 0, 1, 2);
+ test(S("abcde"), 2, 1, S("abcde"), 0, 2, 2);
+ test(S("abcde"), 2, 1, S("abcde"), 0, 4, 2);
+ test(S("abcde"), 2, 1, S("abcde"), 0, 5, 2);
+ test(S("abcde"), 2, 1, S("abcde"), 0, 6, 2);
+ test(S("abcde"), 2, 1, S("abcde"), 1, 0, 1);
+ test(S("abcde"), 2, 1, S("abcde"), 1, 1, 1);
+ test(S("abcde"), 2, 1, S("abcde"), 1, 2, 1);
+ test(S("abcde"), 2, 1, S("abcde"), 1, 3, 1);
+ test(S("abcde"), 2, 1, S("abcde"), 1, 4, 1);
+ test(S("abcde"), 2, 1, S("abcde"), 1, 5, 1);
+ test(S("abcde"), 2, 1, S("abcde"), 2, 0, 1);
+}
+
+template <class S>
+void test12()
+{
+ test(S("abcde"), 2, 1, S("abcde"), 2, 1, 0);
+ test(S("abcde"), 2, 1, S("abcde"), 2, 2, -1);
+ test(S("abcde"), 2, 1, S("abcde"), 2, 3, -2);
+ test(S("abcde"), 2, 1, S("abcde"), 2, 4, -2);
+ test(S("abcde"), 2, 1, S("abcde"), 4, 0, 1);
+ test(S("abcde"), 2, 1, S("abcde"), 4, 1, -2);
+ test(S("abcde"), 2, 1, S("abcde"), 4, 2, -2);
+ test(S("abcde"), 2, 1, S("abcde"), 5, 0, 1);
+ test(S("abcde"), 2, 1, S("abcde"), 5, 1, 1);
+ test(S("abcde"), 2, 1, S("abcde"), 6, 0, 0);
+ test(S("abcde"), 2, 1, S("abcdefghij"), 0, 0, 1);
+ test(S("abcde"), 2, 1, S("abcdefghij"), 0, 1, 2);
+ test(S("abcde"), 2, 1, S("abcdefghij"), 0, 5, 2);
+ test(S("abcde"), 2, 1, S("abcdefghij"), 0, 9, 2);
+ test(S("abcde"), 2, 1, S("abcdefghij"), 0, 10, 2);
+ test(S("abcde"), 2, 1, S("abcdefghij"), 0, 11, 2);
+ test(S("abcde"), 2, 1, S("abcdefghij"), 1, 0, 1);
+ test(S("abcde"), 2, 1, S("abcdefghij"), 1, 1, 1);
+ test(S("abcde"), 2, 1, S("abcdefghij"), 1, 4, 1);
+ test(S("abcde"), 2, 1, S("abcdefghij"), 1, 8, 1);
+ test(S("abcde"), 2, 1, S("abcdefghij"), 1, 9, 1);
+ test(S("abcde"), 2, 1, S("abcdefghij"), 1, 10, 1);
+ test(S("abcde"), 2, 1, S("abcdefghij"), 5, 0, 1);
+ test(S("abcde"), 2, 1, S("abcdefghij"), 5, 1, -3);
+ test(S("abcde"), 2, 1, S("abcdefghij"), 5, 2, -3);
+ test(S("abcde"), 2, 1, S("abcdefghij"), 5, 4, -3);
+ test(S("abcde"), 2, 1, S("abcdefghij"), 5, 5, -3);
+ test(S("abcde"), 2, 1, S("abcdefghij"), 5, 6, -3);
+ test(S("abcde"), 2, 1, S("abcdefghij"), 9, 0, 1);
+ test(S("abcde"), 2, 1, S("abcdefghij"), 9, 1, -7);
+ test(S("abcde"), 2, 1, S("abcdefghij"), 9, 2, -7);
+ test(S("abcde"), 2, 1, S("abcdefghij"), 10, 0, 1);
+ test(S("abcde"), 2, 1, S("abcdefghij"), 10, 1, 1);
+ test(S("abcde"), 2, 1, S("abcdefghij"), 11, 0, 0);
+ test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 0, 0, 1);
+ test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 0, 1, 2);
+ test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 0, 10, 2);
+ test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 0, 19, 2);
+ test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 0, 20, 2);
+ test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 0, 21, 2);
+ test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 1, 0, 1);
+ test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 1, 1, 1);
+ test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 1, 9, 1);
+ test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 1, 18, 1);
+ test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 1, 19, 1);
+ test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 1, 20, 1);
+ test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 10, 0, 1);
+ test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 10, 1, -8);
+ test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 10, 5, -8);
+ test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 10, 9, -8);
+ test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 10, 10, -8);
+ test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 10, 11, -8);
+ test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 19, 0, 1);
+ test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 19, 1, -17);
+ test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 19, 2, -17);
+ test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 20, 0, 1);
+ test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 20, 1, 1);
+ test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 21, 0, 0);
+ test(S("abcde"), 2, 2, S(""), 0, 0, 2);
+ test(S("abcde"), 2, 2, S(""), 0, 1, 2);
+ test(S("abcde"), 2, 2, S(""), 1, 0, 0);
+ test(S("abcde"), 2, 2, S("abcde"), 0, 0, 2);
+ test(S("abcde"), 2, 2, S("abcde"), 0, 1, 2);
+ test(S("abcde"), 2, 2, S("abcde"), 0, 2, 2);
+ test(S("abcde"), 2, 2, S("abcde"), 0, 4, 2);
+ test(S("abcde"), 2, 2, S("abcde"), 0, 5, 2);
+ test(S("abcde"), 2, 2, S("abcde"), 0, 6, 2);
+ test(S("abcde"), 2, 2, S("abcde"), 1, 0, 2);
+ test(S("abcde"), 2, 2, S("abcde"), 1, 1, 1);
+ test(S("abcde"), 2, 2, S("abcde"), 1, 2, 1);
+ test(S("abcde"), 2, 2, S("abcde"), 1, 3, 1);
+ test(S("abcde"), 2, 2, S("abcde"), 1, 4, 1);
+ test(S("abcde"), 2, 2, S("abcde"), 1, 5, 1);
+ test(S("abcde"), 2, 2, S("abcde"), 2, 0, 2);
+ test(S("abcde"), 2, 2, S("abcde"), 2, 1, 1);
+ test(S("abcde"), 2, 2, S("abcde"), 2, 2, 0);
+ test(S("abcde"), 2, 2, S("abcde"), 2, 3, -1);
+ test(S("abcde"), 2, 2, S("abcde"), 2, 4, -1);
+ test(S("abcde"), 2, 2, S("abcde"), 4, 0, 2);
+ test(S("abcde"), 2, 2, S("abcde"), 4, 1, -2);
+ test(S("abcde"), 2, 2, S("abcde"), 4, 2, -2);
+ test(S("abcde"), 2, 2, S("abcde"), 5, 0, 2);
+ test(S("abcde"), 2, 2, S("abcde"), 5, 1, 2);
+ test(S("abcde"), 2, 2, S("abcde"), 6, 0, 0);
+ test(S("abcde"), 2, 2, S("abcdefghij"), 0, 0, 2);
+ test(S("abcde"), 2, 2, S("abcdefghij"), 0, 1, 2);
+ test(S("abcde"), 2, 2, S("abcdefghij"), 0, 5, 2);
+ test(S("abcde"), 2, 2, S("abcdefghij"), 0, 9, 2);
+ test(S("abcde"), 2, 2, S("abcdefghij"), 0, 10, 2);
+ test(S("abcde"), 2, 2, S("abcdefghij"), 0, 11, 2);
+ test(S("abcde"), 2, 2, S("abcdefghij"), 1, 0, 2);
+ test(S("abcde"), 2, 2, S("abcdefghij"), 1, 1, 1);
+ test(S("abcde"), 2, 2, S("abcdefghij"), 1, 4, 1);
+ test(S("abcde"), 2, 2, S("abcdefghij"), 1, 8, 1);
+ test(S("abcde"), 2, 2, S("abcdefghij"), 1, 9, 1);
+ test(S("abcde"), 2, 2, S("abcdefghij"), 1, 10, 1);
+ test(S("abcde"), 2, 2, S("abcdefghij"), 5, 0, 2);
+ test(S("abcde"), 2, 2, S("abcdefghij"), 5, 1, -3);
+ test(S("abcde"), 2, 2, S("abcdefghij"), 5, 2, -3);
+ test(S("abcde"), 2, 2, S("abcdefghij"), 5, 4, -3);
+}
+
+template <class S>
+void test13()
+{
+ test(S("abcde"), 2, 2, S("abcdefghij"), 5, 5, -3);
+ test(S("abcde"), 2, 2, S("abcdefghij"), 5, 6, -3);
+ test(S("abcde"), 2, 2, S("abcdefghij"), 9, 0, 2);
+ test(S("abcde"), 2, 2, S("abcdefghij"), 9, 1, -7);
+ test(S("abcde"), 2, 2, S("abcdefghij"), 9, 2, -7);
+ test(S("abcde"), 2, 2, S("abcdefghij"), 10, 0, 2);
+ test(S("abcde"), 2, 2, S("abcdefghij"), 10, 1, 2);
+ test(S("abcde"), 2, 2, S("abcdefghij"), 11, 0, 0);
+ test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 0, 0, 2);
+ test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 0, 1, 2);
+ test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 0, 10, 2);
+ test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 0, 19, 2);
+ test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 0, 20, 2);
+ test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 0, 21, 2);
+ test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 1, 0, 2);
+ test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 1, 1, 1);
+ test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 1, 9, 1);
+ test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 1, 18, 1);
+ test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 1, 19, 1);
+ test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 1, 20, 1);
+ test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 10, 0, 2);
+ test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 10, 1, -8);
+ test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 10, 5, -8);
+ test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 10, 9, -8);
+ test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 10, 10, -8);
+ test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 10, 11, -8);
+ test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 19, 0, 2);
+ test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 19, 1, -17);
+ test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 19, 2, -17);
+ test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 20, 0, 2);
+ test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 20, 1, 2);
+ test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 21, 0, 0);
+ test(S("abcde"), 2, 3, S(""), 0, 0, 3);
+ test(S("abcde"), 2, 3, S(""), 0, 1, 3);
+ test(S("abcde"), 2, 3, S(""), 1, 0, 0);
+ test(S("abcde"), 2, 3, S("abcde"), 0, 0, 3);
+ test(S("abcde"), 2, 3, S("abcde"), 0, 1, 2);
+ test(S("abcde"), 2, 3, S("abcde"), 0, 2, 2);
+ test(S("abcde"), 2, 3, S("abcde"), 0, 4, 2);
+ test(S("abcde"), 2, 3, S("abcde"), 0, 5, 2);
+ test(S("abcde"), 2, 3, S("abcde"), 0, 6, 2);
+ test(S("abcde"), 2, 3, S("abcde"), 1, 0, 3);
+ test(S("abcde"), 2, 3, S("abcde"), 1, 1, 1);
+ test(S("abcde"), 2, 3, S("abcde"), 1, 2, 1);
+ test(S("abcde"), 2, 3, S("abcde"), 1, 3, 1);
+ test(S("abcde"), 2, 3, S("abcde"), 1, 4, 1);
+ test(S("abcde"), 2, 3, S("abcde"), 1, 5, 1);
+ test(S("abcde"), 2, 3, S("abcde"), 2, 0, 3);
+ test(S("abcde"), 2, 3, S("abcde"), 2, 1, 2);
+ test(S("abcde"), 2, 3, S("abcde"), 2, 2, 1);
+ test(S("abcde"), 2, 3, S("abcde"), 2, 3, 0);
+ test(S("abcde"), 2, 3, S("abcde"), 2, 4, 0);
+ test(S("abcde"), 2, 3, S("abcde"), 4, 0, 3);
+ test(S("abcde"), 2, 3, S("abcde"), 4, 1, -2);
+ test(S("abcde"), 2, 3, S("abcde"), 4, 2, -2);
+ test(S("abcde"), 2, 3, S("abcde"), 5, 0, 3);
+ test(S("abcde"), 2, 3, S("abcde"), 5, 1, 3);
+ test(S("abcde"), 2, 3, S("abcde"), 6, 0, 0);
+ test(S("abcde"), 2, 3, S("abcdefghij"), 0, 0, 3);
+ test(S("abcde"), 2, 3, S("abcdefghij"), 0, 1, 2);
+ test(S("abcde"), 2, 3, S("abcdefghij"), 0, 5, 2);
+ test(S("abcde"), 2, 3, S("abcdefghij"), 0, 9, 2);
+ test(S("abcde"), 2, 3, S("abcdefghij"), 0, 10, 2);
+ test(S("abcde"), 2, 3, S("abcdefghij"), 0, 11, 2);
+ test(S("abcde"), 2, 3, S("abcdefghij"), 1, 0, 3);
+ test(S("abcde"), 2, 3, S("abcdefghij"), 1, 1, 1);
+ test(S("abcde"), 2, 3, S("abcdefghij"), 1, 4, 1);
+ test(S("abcde"), 2, 3, S("abcdefghij"), 1, 8, 1);
+ test(S("abcde"), 2, 3, S("abcdefghij"), 1, 9, 1);
+ test(S("abcde"), 2, 3, S("abcdefghij"), 1, 10, 1);
+ test(S("abcde"), 2, 3, S("abcdefghij"), 5, 0, 3);
+ test(S("abcde"), 2, 3, S("abcdefghij"), 5, 1, -3);
+ test(S("abcde"), 2, 3, S("abcdefghij"), 5, 2, -3);
+ test(S("abcde"), 2, 3, S("abcdefghij"), 5, 4, -3);
+ test(S("abcde"), 2, 3, S("abcdefghij"), 5, 5, -3);
+ test(S("abcde"), 2, 3, S("abcdefghij"), 5, 6, -3);
+ test(S("abcde"), 2, 3, S("abcdefghij"), 9, 0, 3);
+ test(S("abcde"), 2, 3, S("abcdefghij"), 9, 1, -7);
+ test(S("abcde"), 2, 3, S("abcdefghij"), 9, 2, -7);
+ test(S("abcde"), 2, 3, S("abcdefghij"), 10, 0, 3);
+ test(S("abcde"), 2, 3, S("abcdefghij"), 10, 1, 3);
+ test(S("abcde"), 2, 3, S("abcdefghij"), 11, 0, 0);
+ test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 0, 0, 3);
+ test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 0, 1, 2);
+ test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 0, 10, 2);
+ test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 0, 19, 2);
+ test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 0, 20, 2);
+ test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 0, 21, 2);
+ test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 1, 0, 3);
+ test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 1, 1, 1);
+ test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 1, 9, 1);
+ test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 1, 18, 1);
+ test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 1, 19, 1);
+ test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 1, 20, 1);
+ test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 10, 0, 3);
+ test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 10, 1, -8);
+ test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 10, 5, -8);
+ test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 10, 9, -8);
+ test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 10, 10, -8);
+ test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 10, 11, -8);
+}
+
+template <class S>
+void test14()
+{
+ test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 19, 0, 3);
+ test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 19, 1, -17);
+ test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 19, 2, -17);
+ test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 20, 0, 3);
+ test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 20, 1, 3);
+ test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 21, 0, 0);
+ test(S("abcde"), 2, 4, S(""), 0, 0, 3);
+ test(S("abcde"), 2, 4, S(""), 0, 1, 3);
+ test(S("abcde"), 2, 4, S(""), 1, 0, 0);
+ test(S("abcde"), 2, 4, S("abcde"), 0, 0, 3);
+ test(S("abcde"), 2, 4, S("abcde"), 0, 1, 2);
+ test(S("abcde"), 2, 4, S("abcde"), 0, 2, 2);
+ test(S("abcde"), 2, 4, S("abcde"), 0, 4, 2);
+ test(S("abcde"), 2, 4, S("abcde"), 0, 5, 2);
+ test(S("abcde"), 2, 4, S("abcde"), 0, 6, 2);
+ test(S("abcde"), 2, 4, S("abcde"), 1, 0, 3);
+ test(S("abcde"), 2, 4, S("abcde"), 1, 1, 1);
+ test(S("abcde"), 2, 4, S("abcde"), 1, 2, 1);
+ test(S("abcde"), 2, 4, S("abcde"), 1, 3, 1);
+ test(S("abcde"), 2, 4, S("abcde"), 1, 4, 1);
+ test(S("abcde"), 2, 4, S("abcde"), 1, 5, 1);
+ test(S("abcde"), 2, 4, S("abcde"), 2, 0, 3);
+ test(S("abcde"), 2, 4, S("abcde"), 2, 1, 2);
+ test(S("abcde"), 2, 4, S("abcde"), 2, 2, 1);
+ test(S("abcde"), 2, 4, S("abcde"), 2, 3, 0);
+ test(S("abcde"), 2, 4, S("abcde"), 2, 4, 0);
+ test(S("abcde"), 2, 4, S("abcde"), 4, 0, 3);
+ test(S("abcde"), 2, 4, S("abcde"), 4, 1, -2);
+ test(S("abcde"), 2, 4, S("abcde"), 4, 2, -2);
+ test(S("abcde"), 2, 4, S("abcde"), 5, 0, 3);
+ test(S("abcde"), 2, 4, S("abcde"), 5, 1, 3);
+ test(S("abcde"), 2, 4, S("abcde"), 6, 0, 0);
+ test(S("abcde"), 2, 4, S("abcdefghij"), 0, 0, 3);
+ test(S("abcde"), 2, 4, S("abcdefghij"), 0, 1, 2);
+ test(S("abcde"), 2, 4, S("abcdefghij"), 0, 5, 2);
+ test(S("abcde"), 2, 4, S("abcdefghij"), 0, 9, 2);
+ test(S("abcde"), 2, 4, S("abcdefghij"), 0, 10, 2);
+ test(S("abcde"), 2, 4, S("abcdefghij"), 0, 11, 2);
+ test(S("abcde"), 2, 4, S("abcdefghij"), 1, 0, 3);
+ test(S("abcde"), 2, 4, S("abcdefghij"), 1, 1, 1);
+ test(S("abcde"), 2, 4, S("abcdefghij"), 1, 4, 1);
+ test(S("abcde"), 2, 4, S("abcdefghij"), 1, 8, 1);
+ test(S("abcde"), 2, 4, S("abcdefghij"), 1, 9, 1);
+ test(S("abcde"), 2, 4, S("abcdefghij"), 1, 10, 1);
+ test(S("abcde"), 2, 4, S("abcdefghij"), 5, 0, 3);
+ test(S("abcde"), 2, 4, S("abcdefghij"), 5, 1, -3);
+ test(S("abcde"), 2, 4, S("abcdefghij"), 5, 2, -3);
+ test(S("abcde"), 2, 4, S("abcdefghij"), 5, 4, -3);
+ test(S("abcde"), 2, 4, S("abcdefghij"), 5, 5, -3);
+ test(S("abcde"), 2, 4, S("abcdefghij"), 5, 6, -3);
+ test(S("abcde"), 2, 4, S("abcdefghij"), 9, 0, 3);
+ test(S("abcde"), 2, 4, S("abcdefghij"), 9, 1, -7);
+ test(S("abcde"), 2, 4, S("abcdefghij"), 9, 2, -7);
+ test(S("abcde"), 2, 4, S("abcdefghij"), 10, 0, 3);
+ test(S("abcde"), 2, 4, S("abcdefghij"), 10, 1, 3);
+ test(S("abcde"), 2, 4, S("abcdefghij"), 11, 0, 0);
+ test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 0, 0, 3);
+ test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 0, 1, 2);
+ test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 0, 10, 2);
+ test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 0, 19, 2);
+ test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 0, 20, 2);
+ test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 0, 21, 2);
+ test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 1, 0, 3);
+ test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 1, 1, 1);
+ test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 1, 9, 1);
+ test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 1, 18, 1);
+ test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 1, 19, 1);
+ test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 1, 20, 1);
+ test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 10, 0, 3);
+ test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 10, 1, -8);
+ test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 10, 5, -8);
+ test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 10, 9, -8);
+ test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 10, 10, -8);
+ test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 10, 11, -8);
+ test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 19, 0, 3);
+ test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 19, 1, -17);
+ test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 19, 2, -17);
+ test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 20, 0, 3);
+ test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 20, 1, 3);
+ test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 21, 0, 0);
+ test(S("abcde"), 4, 0, S(""), 0, 0, 0);
+ test(S("abcde"), 4, 0, S(""), 0, 1, 0);
+ test(S("abcde"), 4, 0, S(""), 1, 0, 0);
+ test(S("abcde"), 4, 0, S("abcde"), 0, 0, 0);
+ test(S("abcde"), 4, 0, S("abcde"), 0, 1, -1);
+ test(S("abcde"), 4, 0, S("abcde"), 0, 2, -2);
+ test(S("abcde"), 4, 0, S("abcde"), 0, 4, -4);
+ test(S("abcde"), 4, 0, S("abcde"), 0, 5, -5);
+ test(S("abcde"), 4, 0, S("abcde"), 0, 6, -5);
+ test(S("abcde"), 4, 0, S("abcde"), 1, 0, 0);
+ test(S("abcde"), 4, 0, S("abcde"), 1, 1, -1);
+ test(S("abcde"), 4, 0, S("abcde"), 1, 2, -2);
+ test(S("abcde"), 4, 0, S("abcde"), 1, 3, -3);
+ test(S("abcde"), 4, 0, S("abcde"), 1, 4, -4);
+ test(S("abcde"), 4, 0, S("abcde"), 1, 5, -4);
+ test(S("abcde"), 4, 0, S("abcde"), 2, 0, 0);
+ test(S("abcde"), 4, 0, S("abcde"), 2, 1, -1);
+ test(S("abcde"), 4, 0, S("abcde"), 2, 2, -2);
+ test(S("abcde"), 4, 0, S("abcde"), 2, 3, -3);
+ test(S("abcde"), 4, 0, S("abcde"), 2, 4, -3);
+}
+
+template <class S>
+void test15()
+{
+ test(S("abcde"), 4, 0, S("abcde"), 4, 0, 0);
+ test(S("abcde"), 4, 0, S("abcde"), 4, 1, -1);
+ test(S("abcde"), 4, 0, S("abcde"), 4, 2, -1);
+ test(S("abcde"), 4, 0, S("abcde"), 5, 0, 0);
+ test(S("abcde"), 4, 0, S("abcde"), 5, 1, 0);
+ test(S("abcde"), 4, 0, S("abcde"), 6, 0, 0);
+ test(S("abcde"), 4, 0, S("abcdefghij"), 0, 0, 0);
+ test(S("abcde"), 4, 0, S("abcdefghij"), 0, 1, -1);
+ test(S("abcde"), 4, 0, S("abcdefghij"), 0, 5, -5);
+ test(S("abcde"), 4, 0, S("abcdefghij"), 0, 9, -9);
+ test(S("abcde"), 4, 0, S("abcdefghij"), 0, 10, -10);
+ test(S("abcde"), 4, 0, S("abcdefghij"), 0, 11, -10);
+ test(S("abcde"), 4, 0, S("abcdefghij"), 1, 0, 0);
+ test(S("abcde"), 4, 0, S("abcdefghij"), 1, 1, -1);
+ test(S("abcde"), 4, 0, S("abcdefghij"), 1, 4, -4);
+ test(S("abcde"), 4, 0, S("abcdefghij"), 1, 8, -8);
+ test(S("abcde"), 4, 0, S("abcdefghij"), 1, 9, -9);
+ test(S("abcde"), 4, 0, S("abcdefghij"), 1, 10, -9);
+ test(S("abcde"), 4, 0, S("abcdefghij"), 5, 0, 0);
+ test(S("abcde"), 4, 0, S("abcdefghij"), 5, 1, -1);
+ test(S("abcde"), 4, 0, S("abcdefghij"), 5, 2, -2);
+ test(S("abcde"), 4, 0, S("abcdefghij"), 5, 4, -4);
+ test(S("abcde"), 4, 0, S("abcdefghij"), 5, 5, -5);
+ test(S("abcde"), 4, 0, S("abcdefghij"), 5, 6, -5);
+ test(S("abcde"), 4, 0, S("abcdefghij"), 9, 0, 0);
+ test(S("abcde"), 4, 0, S("abcdefghij"), 9, 1, -1);
+ test(S("abcde"), 4, 0, S("abcdefghij"), 9, 2, -1);
+ test(S("abcde"), 4, 0, S("abcdefghij"), 10, 0, 0);
+ test(S("abcde"), 4, 0, S("abcdefghij"), 10, 1, 0);
+ test(S("abcde"), 4, 0, S("abcdefghij"), 11, 0, 0);
+ test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 0, 0, 0);
+ test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 0, 1, -1);
+ test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 0, 10, -10);
+ test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 0, 19, -19);
+ test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 0, 20, -20);
+ test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 0, 21, -20);
+ test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 1, 0, 0);
+ test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 1, 1, -1);
+ test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 1, 9, -9);
+ test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 1, 18, -18);
+ test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 1, 19, -19);
+ test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 1, 20, -19);
+ test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 10, 0, 0);
+ test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 10, 1, -1);
+ test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 10, 5, -5);
+ test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 10, 9, -9);
+ test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 10, 10, -10);
+ test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 10, 11, -10);
+ test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 19, 0, 0);
+ test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 19, 1, -1);
+ test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 19, 2, -1);
+ test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 20, 0, 0);
+ test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 20, 1, 0);
+ test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 21, 0, 0);
+ test(S("abcde"), 4, 1, S(""), 0, 0, 1);
+ test(S("abcde"), 4, 1, S(""), 0, 1, 1);
+ test(S("abcde"), 4, 1, S(""), 1, 0, 0);
+ test(S("abcde"), 4, 1, S("abcde"), 0, 0, 1);
+ test(S("abcde"), 4, 1, S("abcde"), 0, 1, 4);
+ test(S("abcde"), 4, 1, S("abcde"), 0, 2, 4);
+ test(S("abcde"), 4, 1, S("abcde"), 0, 4, 4);
+ test(S("abcde"), 4, 1, S("abcde"), 0, 5, 4);
+ test(S("abcde"), 4, 1, S("abcde"), 0, 6, 4);
+ test(S("abcde"), 4, 1, S("abcde"), 1, 0, 1);
+ test(S("abcde"), 4, 1, S("abcde"), 1, 1, 3);
+ test(S("abcde"), 4, 1, S("abcde"), 1, 2, 3);
+ test(S("abcde"), 4, 1, S("abcde"), 1, 3, 3);
+ test(S("abcde"), 4, 1, S("abcde"), 1, 4, 3);
+ test(S("abcde"), 4, 1, S("abcde"), 1, 5, 3);
+ test(S("abcde"), 4, 1, S("abcde"), 2, 0, 1);
+ test(S("abcde"), 4, 1, S("abcde"), 2, 1, 2);
+ test(S("abcde"), 4, 1, S("abcde"), 2, 2, 2);
+ test(S("abcde"), 4, 1, S("abcde"), 2, 3, 2);
+ test(S("abcde"), 4, 1, S("abcde"), 2, 4, 2);
+ test(S("abcde"), 4, 1, S("abcde"), 4, 0, 1);
+ test(S("abcde"), 4, 1, S("abcde"), 4, 1, 0);
+ test(S("abcde"), 4, 1, S("abcde"), 4, 2, 0);
+ test(S("abcde"), 4, 1, S("abcde"), 5, 0, 1);
+ test(S("abcde"), 4, 1, S("abcde"), 5, 1, 1);
+ test(S("abcde"), 4, 1, S("abcde"), 6, 0, 0);
+ test(S("abcde"), 4, 1, S("abcdefghij"), 0, 0, 1);
+ test(S("abcde"), 4, 1, S("abcdefghij"), 0, 1, 4);
+ test(S("abcde"), 4, 1, S("abcdefghij"), 0, 5, 4);
+ test(S("abcde"), 4, 1, S("abcdefghij"), 0, 9, 4);
+ test(S("abcde"), 4, 1, S("abcdefghij"), 0, 10, 4);
+ test(S("abcde"), 4, 1, S("abcdefghij"), 0, 11, 4);
+ test(S("abcde"), 4, 1, S("abcdefghij"), 1, 0, 1);
+ test(S("abcde"), 4, 1, S("abcdefghij"), 1, 1, 3);
+ test(S("abcde"), 4, 1, S("abcdefghij"), 1, 4, 3);
+ test(S("abcde"), 4, 1, S("abcdefghij"), 1, 8, 3);
+ test(S("abcde"), 4, 1, S("abcdefghij"), 1, 9, 3);
+ test(S("abcde"), 4, 1, S("abcdefghij"), 1, 10, 3);
+ test(S("abcde"), 4, 1, S("abcdefghij"), 5, 0, 1);
+ test(S("abcde"), 4, 1, S("abcdefghij"), 5, 1, -1);
+ test(S("abcde"), 4, 1, S("abcdefghij"), 5, 2, -1);
+ test(S("abcde"), 4, 1, S("abcdefghij"), 5, 4, -1);
+ test(S("abcde"), 4, 1, S("abcdefghij"), 5, 5, -1);
+ test(S("abcde"), 4, 1, S("abcdefghij"), 5, 6, -1);
+ test(S("abcde"), 4, 1, S("abcdefghij"), 9, 0, 1);
+ test(S("abcde"), 4, 1, S("abcdefghij"), 9, 1, -5);
+}
+
+template <class S>
+void test16()
+{
+ test(S("abcde"), 4, 1, S("abcdefghij"), 9, 2, -5);
+ test(S("abcde"), 4, 1, S("abcdefghij"), 10, 0, 1);
+ test(S("abcde"), 4, 1, S("abcdefghij"), 10, 1, 1);
+ test(S("abcde"), 4, 1, S("abcdefghij"), 11, 0, 0);
+ test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 0, 0, 1);
+ test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 0, 1, 4);
+ test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 0, 10, 4);
+ test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 0, 19, 4);
+ test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 0, 20, 4);
+ test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 0, 21, 4);
+ test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 1, 0, 1);
+ test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 1, 1, 3);
+ test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 1, 9, 3);
+ test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 1, 18, 3);
+ test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 1, 19, 3);
+ test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 1, 20, 3);
+ test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 10, 0, 1);
+ test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 10, 1, -6);
+ test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 10, 5, -6);
+ test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 10, 9, -6);
+ test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 10, 10, -6);
+ test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 10, 11, -6);
+ test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 19, 0, 1);
+ test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 19, 1, -15);
+ test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 19, 2, -15);
+ test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 20, 0, 1);
+ test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 20, 1, 1);
+ test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 21, 0, 0);
+ test(S("abcde"), 4, 2, S(""), 0, 0, 1);
+ test(S("abcde"), 4, 2, S(""), 0, 1, 1);
+ test(S("abcde"), 4, 2, S(""), 1, 0, 0);
+ test(S("abcde"), 4, 2, S("abcde"), 0, 0, 1);
+ test(S("abcde"), 4, 2, S("abcde"), 0, 1, 4);
+ test(S("abcde"), 4, 2, S("abcde"), 0, 2, 4);
+ test(S("abcde"), 4, 2, S("abcde"), 0, 4, 4);
+ test(S("abcde"), 4, 2, S("abcde"), 0, 5, 4);
+ test(S("abcde"), 4, 2, S("abcde"), 0, 6, 4);
+ test(S("abcde"), 4, 2, S("abcde"), 1, 0, 1);
+ test(S("abcde"), 4, 2, S("abcde"), 1, 1, 3);
+ test(S("abcde"), 4, 2, S("abcde"), 1, 2, 3);
+ test(S("abcde"), 4, 2, S("abcde"), 1, 3, 3);
+ test(S("abcde"), 4, 2, S("abcde"), 1, 4, 3);
+ test(S("abcde"), 4, 2, S("abcde"), 1, 5, 3);
+ test(S("abcde"), 4, 2, S("abcde"), 2, 0, 1);
+ test(S("abcde"), 4, 2, S("abcde"), 2, 1, 2);
+ test(S("abcde"), 4, 2, S("abcde"), 2, 2, 2);
+ test(S("abcde"), 4, 2, S("abcde"), 2, 3, 2);
+ test(S("abcde"), 4, 2, S("abcde"), 2, 4, 2);
+ test(S("abcde"), 4, 2, S("abcde"), 4, 0, 1);
+ test(S("abcde"), 4, 2, S("abcde"), 4, 1, 0);
+ test(S("abcde"), 4, 2, S("abcde"), 4, 2, 0);
+ test(S("abcde"), 4, 2, S("abcde"), 5, 0, 1);
+ test(S("abcde"), 4, 2, S("abcde"), 5, 1, 1);
+ test(S("abcde"), 4, 2, S("abcde"), 6, 0, 0);
+ test(S("abcde"), 4, 2, S("abcdefghij"), 0, 0, 1);
+ test(S("abcde"), 4, 2, S("abcdefghij"), 0, 1, 4);
+ test(S("abcde"), 4, 2, S("abcdefghij"), 0, 5, 4);
+ test(S("abcde"), 4, 2, S("abcdefghij"), 0, 9, 4);
+ test(S("abcde"), 4, 2, S("abcdefghij"), 0, 10, 4);
+ test(S("abcde"), 4, 2, S("abcdefghij"), 0, 11, 4);
+ test(S("abcde"), 4, 2, S("abcdefghij"), 1, 0, 1);
+ test(S("abcde"), 4, 2, S("abcdefghij"), 1, 1, 3);
+ test(S("abcde"), 4, 2, S("abcdefghij"), 1, 4, 3);
+ test(S("abcde"), 4, 2, S("abcdefghij"), 1, 8, 3);
+ test(S("abcde"), 4, 2, S("abcdefghij"), 1, 9, 3);
+ test(S("abcde"), 4, 2, S("abcdefghij"), 1, 10, 3);
+ test(S("abcde"), 4, 2, S("abcdefghij"), 5, 0, 1);
+ test(S("abcde"), 4, 2, S("abcdefghij"), 5, 1, -1);
+ test(S("abcde"), 4, 2, S("abcdefghij"), 5, 2, -1);
+ test(S("abcde"), 4, 2, S("abcdefghij"), 5, 4, -1);
+ test(S("abcde"), 4, 2, S("abcdefghij"), 5, 5, -1);
+ test(S("abcde"), 4, 2, S("abcdefghij"), 5, 6, -1);
+ test(S("abcde"), 4, 2, S("abcdefghij"), 9, 0, 1);
+ test(S("abcde"), 4, 2, S("abcdefghij"), 9, 1, -5);
+ test(S("abcde"), 4, 2, S("abcdefghij"), 9, 2, -5);
+ test(S("abcde"), 4, 2, S("abcdefghij"), 10, 0, 1);
+ test(S("abcde"), 4, 2, S("abcdefghij"), 10, 1, 1);
+ test(S("abcde"), 4, 2, S("abcdefghij"), 11, 0, 0);
+ test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 0, 0, 1);
+ test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 0, 1, 4);
+ test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 0, 10, 4);
+ test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 0, 19, 4);
+ test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 0, 20, 4);
+ test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 0, 21, 4);
+ test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 1, 0, 1);
+ test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 1, 1, 3);
+ test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 1, 9, 3);
+ test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 1, 18, 3);
+ test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 1, 19, 3);
+ test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 1, 20, 3);
+ test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 10, 0, 1);
+ test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 10, 1, -6);
+ test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 10, 5, -6);
+ test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 10, 9, -6);
+ test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 10, 10, -6);
+ test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 10, 11, -6);
+ test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 19, 0, 1);
+ test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 19, 1, -15);
+ test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 19, 2, -15);
+ test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 20, 0, 1);
+}
+
+template <class S>
+void test17()
+{
+ test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 20, 1, 1);
+ test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 21, 0, 0);
+ test(S("abcde"), 5, 0, S(""), 0, 0, 0);
+ test(S("abcde"), 5, 0, S(""), 0, 1, 0);
+ test(S("abcde"), 5, 0, S(""), 1, 0, 0);
+ test(S("abcde"), 5, 0, S("abcde"), 0, 0, 0);
+ test(S("abcde"), 5, 0, S("abcde"), 0, 1, -1);
+ test(S("abcde"), 5, 0, S("abcde"), 0, 2, -2);
+ test(S("abcde"), 5, 0, S("abcde"), 0, 4, -4);
+ test(S("abcde"), 5, 0, S("abcde"), 0, 5, -5);
+ test(S("abcde"), 5, 0, S("abcde"), 0, 6, -5);
+ test(S("abcde"), 5, 0, S("abcde"), 1, 0, 0);
+ test(S("abcde"), 5, 0, S("abcde"), 1, 1, -1);
+ test(S("abcde"), 5, 0, S("abcde"), 1, 2, -2);
+ test(S("abcde"), 5, 0, S("abcde"), 1, 3, -3);
+ test(S("abcde"), 5, 0, S("abcde"), 1, 4, -4);
+ test(S("abcde"), 5, 0, S("abcde"), 1, 5, -4);
+ test(S("abcde"), 5, 0, S("abcde"), 2, 0, 0);
+ test(S("abcde"), 5, 0, S("abcde"), 2, 1, -1);
+ test(S("abcde"), 5, 0, S("abcde"), 2, 2, -2);
+ test(S("abcde"), 5, 0, S("abcde"), 2, 3, -3);
+ test(S("abcde"), 5, 0, S("abcde"), 2, 4, -3);
+ test(S("abcde"), 5, 0, S("abcde"), 4, 0, 0);
+ test(S("abcde"), 5, 0, S("abcde"), 4, 1, -1);
+ test(S("abcde"), 5, 0, S("abcde"), 4, 2, -1);
+ test(S("abcde"), 5, 0, S("abcde"), 5, 0, 0);
+ test(S("abcde"), 5, 0, S("abcde"), 5, 1, 0);
+ test(S("abcde"), 5, 0, S("abcde"), 6, 0, 0);
+ test(S("abcde"), 5, 0, S("abcdefghij"), 0, 0, 0);
+ test(S("abcde"), 5, 0, S("abcdefghij"), 0, 1, -1);
+ test(S("abcde"), 5, 0, S("abcdefghij"), 0, 5, -5);
+ test(S("abcde"), 5, 0, S("abcdefghij"), 0, 9, -9);
+ test(S("abcde"), 5, 0, S("abcdefghij"), 0, 10, -10);
+ test(S("abcde"), 5, 0, S("abcdefghij"), 0, 11, -10);
+ test(S("abcde"), 5, 0, S("abcdefghij"), 1, 0, 0);
+ test(S("abcde"), 5, 0, S("abcdefghij"), 1, 1, -1);
+ test(S("abcde"), 5, 0, S("abcdefghij"), 1, 4, -4);
+ test(S("abcde"), 5, 0, S("abcdefghij"), 1, 8, -8);
+ test(S("abcde"), 5, 0, S("abcdefghij"), 1, 9, -9);
+ test(S("abcde"), 5, 0, S("abcdefghij"), 1, 10, -9);
+ test(S("abcde"), 5, 0, S("abcdefghij"), 5, 0, 0);
+ test(S("abcde"), 5, 0, S("abcdefghij"), 5, 1, -1);
+ test(S("abcde"), 5, 0, S("abcdefghij"), 5, 2, -2);
+ test(S("abcde"), 5, 0, S("abcdefghij"), 5, 4, -4);
+ test(S("abcde"), 5, 0, S("abcdefghij"), 5, 5, -5);
+ test(S("abcde"), 5, 0, S("abcdefghij"), 5, 6, -5);
+ test(S("abcde"), 5, 0, S("abcdefghij"), 9, 0, 0);
+ test(S("abcde"), 5, 0, S("abcdefghij"), 9, 1, -1);
+ test(S("abcde"), 5, 0, S("abcdefghij"), 9, 2, -1);
+ test(S("abcde"), 5, 0, S("abcdefghij"), 10, 0, 0);
+ test(S("abcde"), 5, 0, S("abcdefghij"), 10, 1, 0);
+ test(S("abcde"), 5, 0, S("abcdefghij"), 11, 0, 0);
+ test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 0, 0, 0);
+ test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 0, 1, -1);
+ test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 0, 10, -10);
+ test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 0, 19, -19);
+ test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 0, 20, -20);
+ test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 0, 21, -20);
+ test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 1, 0, 0);
+ test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 1, 1, -1);
+ test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 1, 9, -9);
+ test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 1, 18, -18);
+ test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 1, 19, -19);
+ test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 1, 20, -19);
+ test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 10, 0, 0);
+ test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 10, 1, -1);
+ test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 10, 5, -5);
+ test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 10, 9, -9);
+ test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 10, 10, -10);
+ test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 10, 11, -10);
+ test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 19, 0, 0);
+ test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 19, 1, -1);
+ test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 19, 2, -1);
+ test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 20, 0, 0);
+ test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 20, 1, 0);
+ test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 21, 0, 0);
+ test(S("abcde"), 5, 1, S(""), 0, 0, 0);
+ test(S("abcde"), 5, 1, S(""), 0, 1, 0);
+ test(S("abcde"), 5, 1, S(""), 1, 0, 0);
+ test(S("abcde"), 5, 1, S("abcde"), 0, 0, 0);
+ test(S("abcde"), 5, 1, S("abcde"), 0, 1, -1);
+ test(S("abcde"), 5, 1, S("abcde"), 0, 2, -2);
+ test(S("abcde"), 5, 1, S("abcde"), 0, 4, -4);
+ test(S("abcde"), 5, 1, S("abcde"), 0, 5, -5);
+ test(S("abcde"), 5, 1, S("abcde"), 0, 6, -5);
+ test(S("abcde"), 5, 1, S("abcde"), 1, 0, 0);
+ test(S("abcde"), 5, 1, S("abcde"), 1, 1, -1);
+ test(S("abcde"), 5, 1, S("abcde"), 1, 2, -2);
+ test(S("abcde"), 5, 1, S("abcde"), 1, 3, -3);
+ test(S("abcde"), 5, 1, S("abcde"), 1, 4, -4);
+ test(S("abcde"), 5, 1, S("abcde"), 1, 5, -4);
+ test(S("abcde"), 5, 1, S("abcde"), 2, 0, 0);
+ test(S("abcde"), 5, 1, S("abcde"), 2, 1, -1);
+ test(S("abcde"), 5, 1, S("abcde"), 2, 2, -2);
+ test(S("abcde"), 5, 1, S("abcde"), 2, 3, -3);
+ test(S("abcde"), 5, 1, S("abcde"), 2, 4, -3);
+ test(S("abcde"), 5, 1, S("abcde"), 4, 0, 0);
+ test(S("abcde"), 5, 1, S("abcde"), 4, 1, -1);
+ test(S("abcde"), 5, 1, S("abcde"), 4, 2, -1);
+ test(S("abcde"), 5, 1, S("abcde"), 5, 0, 0);
+}
+
+template <class S>
+void test18()
+{
+ test(S("abcde"), 5, 1, S("abcde"), 5, 1, 0);
+ test(S("abcde"), 5, 1, S("abcde"), 6, 0, 0);
+ test(S("abcde"), 5, 1, S("abcdefghij"), 0, 0, 0);
+ test(S("abcde"), 5, 1, S("abcdefghij"), 0, 1, -1);
+ test(S("abcde"), 5, 1, S("abcdefghij"), 0, 5, -5);
+ test(S("abcde"), 5, 1, S("abcdefghij"), 0, 9, -9);
+ test(S("abcde"), 5, 1, S("abcdefghij"), 0, 10, -10);
+ test(S("abcde"), 5, 1, S("abcdefghij"), 0, 11, -10);
+ test(S("abcde"), 5, 1, S("abcdefghij"), 1, 0, 0);
+ test(S("abcde"), 5, 1, S("abcdefghij"), 1, 1, -1);
+ test(S("abcde"), 5, 1, S("abcdefghij"), 1, 4, -4);
+ test(S("abcde"), 5, 1, S("abcdefghij"), 1, 8, -8);
+ test(S("abcde"), 5, 1, S("abcdefghij"), 1, 9, -9);
+ test(S("abcde"), 5, 1, S("abcdefghij"), 1, 10, -9);
+ test(S("abcde"), 5, 1, S("abcdefghij"), 5, 0, 0);
+ test(S("abcde"), 5, 1, S("abcdefghij"), 5, 1, -1);
+ test(S("abcde"), 5, 1, S("abcdefghij"), 5, 2, -2);
+ test(S("abcde"), 5, 1, S("abcdefghij"), 5, 4, -4);
+ test(S("abcde"), 5, 1, S("abcdefghij"), 5, 5, -5);
+ test(S("abcde"), 5, 1, S("abcdefghij"), 5, 6, -5);
+ test(S("abcde"), 5, 1, S("abcdefghij"), 9, 0, 0);
+ test(S("abcde"), 5, 1, S("abcdefghij"), 9, 1, -1);
+ test(S("abcde"), 5, 1, S("abcdefghij"), 9, 2, -1);
+ test(S("abcde"), 5, 1, S("abcdefghij"), 10, 0, 0);
+ test(S("abcde"), 5, 1, S("abcdefghij"), 10, 1, 0);
+ test(S("abcde"), 5, 1, S("abcdefghij"), 11, 0, 0);
+ test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 0, 0, 0);
+ test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 0, 1, -1);
+ test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 0, 10, -10);
+ test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 0, 19, -19);
+ test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 0, 20, -20);
+ test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 0, 21, -20);
+ test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 1, 0, 0);
+ test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 1, 1, -1);
+ test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 1, 9, -9);
+ test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 1, 18, -18);
+ test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 1, 19, -19);
+ test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 1, 20, -19);
+ test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 10, 0, 0);
+ test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 10, 1, -1);
+ test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 10, 5, -5);
+ test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 10, 9, -9);
+ test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 10, 10, -10);
+ test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 10, 11, -10);
+ test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 19, 0, 0);
+ test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 19, 1, -1);
+ test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 19, 2, -1);
+ test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 20, 0, 0);
+ test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 20, 1, 0);
+ test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 21, 0, 0);
+ test(S("abcde"), 6, 0, S(""), 0, 0, 0);
+ test(S("abcde"), 6, 0, S(""), 0, 1, 0);
+ test(S("abcde"), 6, 0, S(""), 1, 0, 0);
+ test(S("abcde"), 6, 0, S("abcde"), 0, 0, 0);
+ test(S("abcde"), 6, 0, S("abcde"), 0, 1, 0);
+ test(S("abcde"), 6, 0, S("abcde"), 0, 2, 0);
+ test(S("abcde"), 6, 0, S("abcde"), 0, 4, 0);
+ test(S("abcde"), 6, 0, S("abcde"), 0, 5, 0);
+ test(S("abcde"), 6, 0, S("abcde"), 0, 6, 0);
+ test(S("abcde"), 6, 0, S("abcde"), 1, 0, 0);
+ test(S("abcde"), 6, 0, S("abcde"), 1, 1, 0);
+ test(S("abcde"), 6, 0, S("abcde"), 1, 2, 0);
+ test(S("abcde"), 6, 0, S("abcde"), 1, 3, 0);
+ test(S("abcde"), 6, 0, S("abcde"), 1, 4, 0);
+ test(S("abcde"), 6, 0, S("abcde"), 1, 5, 0);
+ test(S("abcde"), 6, 0, S("abcde"), 2, 0, 0);
+ test(S("abcde"), 6, 0, S("abcde"), 2, 1, 0);
+ test(S("abcde"), 6, 0, S("abcde"), 2, 2, 0);
+ test(S("abcde"), 6, 0, S("abcde"), 2, 3, 0);
+ test(S("abcde"), 6, 0, S("abcde"), 2, 4, 0);
+ test(S("abcde"), 6, 0, S("abcde"), 4, 0, 0);
+ test(S("abcde"), 6, 0, S("abcde"), 4, 1, 0);
+ test(S("abcde"), 6, 0, S("abcde"), 4, 2, 0);
+ test(S("abcde"), 6, 0, S("abcde"), 5, 0, 0);
+ test(S("abcde"), 6, 0, S("abcde"), 5, 1, 0);
+ test(S("abcde"), 6, 0, S("abcde"), 6, 0, 0);
+ test(S("abcde"), 6, 0, S("abcdefghij"), 0, 0, 0);
+ test(S("abcde"), 6, 0, S("abcdefghij"), 0, 1, 0);
+ test(S("abcde"), 6, 0, S("abcdefghij"), 0, 5, 0);
+ test(S("abcde"), 6, 0, S("abcdefghij"), 0, 9, 0);
+ test(S("abcde"), 6, 0, S("abcdefghij"), 0, 10, 0);
+ test(S("abcde"), 6, 0, S("abcdefghij"), 0, 11, 0);
+ test(S("abcde"), 6, 0, S("abcdefghij"), 1, 0, 0);
+ test(S("abcde"), 6, 0, S("abcdefghij"), 1, 1, 0);
+ test(S("abcde"), 6, 0, S("abcdefghij"), 1, 4, 0);
+ test(S("abcde"), 6, 0, S("abcdefghij"), 1, 8, 0);
+ test(S("abcde"), 6, 0, S("abcdefghij"), 1, 9, 0);
+ test(S("abcde"), 6, 0, S("abcdefghij"), 1, 10, 0);
+ test(S("abcde"), 6, 0, S("abcdefghij"), 5, 0, 0);
+ test(S("abcde"), 6, 0, S("abcdefghij"), 5, 1, 0);
+ test(S("abcde"), 6, 0, S("abcdefghij"), 5, 2, 0);
+ test(S("abcde"), 6, 0, S("abcdefghij"), 5, 4, 0);
+ test(S("abcde"), 6, 0, S("abcdefghij"), 5, 5, 0);
+ test(S("abcde"), 6, 0, S("abcdefghij"), 5, 6, 0);
+ test(S("abcde"), 6, 0, S("abcdefghij"), 9, 0, 0);
+ test(S("abcde"), 6, 0, S("abcdefghij"), 9, 1, 0);
+ test(S("abcde"), 6, 0, S("abcdefghij"), 9, 2, 0);
+ test(S("abcde"), 6, 0, S("abcdefghij"), 10, 0, 0);
+ test(S("abcde"), 6, 0, S("abcdefghij"), 10, 1, 0);
+ test(S("abcde"), 6, 0, S("abcdefghij"), 11, 0, 0);
+}
+
+template <class S>
+void test19()
+{
+ test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 0, 0, 0);
+ test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 0, 1, 0);
+ test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 0, 10, 0);
+ test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 0, 19, 0);
+ test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 0, 20, 0);
+ test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 0, 21, 0);
+ test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 1, 0, 0);
+ test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 1, 1, 0);
+ test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 1, 9, 0);
+ test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 1, 18, 0);
+ test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 1, 19, 0);
+ test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 1, 20, 0);
+ test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 10, 0, 0);
+ test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 10, 1, 0);
+ test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 10, 5, 0);
+ test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 10, 9, 0);
+ test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 10, 10, 0);
+ test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 10, 11, 0);
+ test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 19, 0, 0);
+ test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 19, 1, 0);
+ test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 19, 2, 0);
+ test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 20, 0, 0);
+ test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 20, 1, 0);
+ test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 21, 0, 0);
+ test(S("abcdefghij"), 0, 0, S(""), 0, 0, 0);
+ test(S("abcdefghij"), 0, 0, S(""), 0, 1, 0);
+ test(S("abcdefghij"), 0, 0, S(""), 1, 0, 0);
+ test(S("abcdefghij"), 0, 0, S("abcde"), 0, 0, 0);
+ test(S("abcdefghij"), 0, 0, S("abcde"), 0, 1, -1);
+ test(S("abcdefghij"), 0, 0, S("abcde"), 0, 2, -2);
+ test(S("abcdefghij"), 0, 0, S("abcde"), 0, 4, -4);
+ test(S("abcdefghij"), 0, 0, S("abcde"), 0, 5, -5);
+ test(S("abcdefghij"), 0, 0, S("abcde"), 0, 6, -5);
+ test(S("abcdefghij"), 0, 0, S("abcde"), 1, 0, 0);
+ test(S("abcdefghij"), 0, 0, S("abcde"), 1, 1, -1);
+ test(S("abcdefghij"), 0, 0, S("abcde"), 1, 2, -2);
+ test(S("abcdefghij"), 0, 0, S("abcde"), 1, 3, -3);
+ test(S("abcdefghij"), 0, 0, S("abcde"), 1, 4, -4);
+ test(S("abcdefghij"), 0, 0, S("abcde"), 1, 5, -4);
+ test(S("abcdefghij"), 0, 0, S("abcde"), 2, 0, 0);
+ test(S("abcdefghij"), 0, 0, S("abcde"), 2, 1, -1);
+ test(S("abcdefghij"), 0, 0, S("abcde"), 2, 2, -2);
+ test(S("abcdefghij"), 0, 0, S("abcde"), 2, 3, -3);
+ test(S("abcdefghij"), 0, 0, S("abcde"), 2, 4, -3);
+ test(S("abcdefghij"), 0, 0, S("abcde"), 4, 0, 0);
+ test(S("abcdefghij"), 0, 0, S("abcde"), 4, 1, -1);
+ test(S("abcdefghij"), 0, 0, S("abcde"), 4, 2, -1);
+ test(S("abcdefghij"), 0, 0, S("abcde"), 5, 0, 0);
+ test(S("abcdefghij"), 0, 0, S("abcde"), 5, 1, 0);
+ test(S("abcdefghij"), 0, 0, S("abcde"), 6, 0, 0);
+ test(S("abcdefghij"), 0, 0, S("abcdefghij"), 0, 0, 0);
+ test(S("abcdefghij"), 0, 0, S("abcdefghij"), 0, 1, -1);
+ test(S("abcdefghij"), 0, 0, S("abcdefghij"), 0, 5, -5);
+ test(S("abcdefghij"), 0, 0, S("abcdefghij"), 0, 9, -9);
+ test(S("abcdefghij"), 0, 0, S("abcdefghij"), 0, 10, -10);
+ test(S("abcdefghij"), 0, 0, S("abcdefghij"), 0, 11, -10);
+ test(S("abcdefghij"), 0, 0, S("abcdefghij"), 1, 0, 0);
+ test(S("abcdefghij"), 0, 0, S("abcdefghij"), 1, 1, -1);
+ test(S("abcdefghij"), 0, 0, S("abcdefghij"), 1, 4, -4);
+ test(S("abcdefghij"), 0, 0, S("abcdefghij"), 1, 8, -8);
+ test(S("abcdefghij"), 0, 0, S("abcdefghij"), 1, 9, -9);
+ test(S("abcdefghij"), 0, 0, S("abcdefghij"), 1, 10, -9);
+ test(S("abcdefghij"), 0, 0, S("abcdefghij"), 5, 0, 0);
+ test(S("abcdefghij"), 0, 0, S("abcdefghij"), 5, 1, -1);
+ test(S("abcdefghij"), 0, 0, S("abcdefghij"), 5, 2, -2);
+ test(S("abcdefghij"), 0, 0, S("abcdefghij"), 5, 4, -4);
+ test(S("abcdefghij"), 0, 0, S("abcdefghij"), 5, 5, -5);
+ test(S("abcdefghij"), 0, 0, S("abcdefghij"), 5, 6, -5);
+ test(S("abcdefghij"), 0, 0, S("abcdefghij"), 9, 0, 0);
+ test(S("abcdefghij"), 0, 0, S("abcdefghij"), 9, 1, -1);
+ test(S("abcdefghij"), 0, 0, S("abcdefghij"), 9, 2, -1);
+ test(S("abcdefghij"), 0, 0, S("abcdefghij"), 10, 0, 0);
+ test(S("abcdefghij"), 0, 0, S("abcdefghij"), 10, 1, 0);
+ test(S("abcdefghij"), 0, 0, S("abcdefghij"), 11, 0, 0);
+ test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 0, 0, 0);
+ test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 0, 1, -1);
+ test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 0, 10, -10);
+ test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 0, 19, -19);
+ test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 0, 20, -20);
+ test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 0, 21, -20);
+ test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 1, 0, 0);
+ test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 1, 1, -1);
+ test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 1, 9, -9);
+ test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 1, 18, -18);
+ test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 1, 19, -19);
+ test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 1, 20, -19);
+ test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 10, 0, 0);
+ test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 10, 1, -1);
+ test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 10, 5, -5);
+ test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 10, 9, -9);
+ test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 10, 10, -10);
+ test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 10, 11, -10);
+ test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 19, 0, 0);
+ test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 19, 1, -1);
+ test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 19, 2, -1);
+ test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 20, 0, 0);
+ test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 20, 1, 0);
+ test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 21, 0, 0);
+ test(S("abcdefghij"), 0, 1, S(""), 0, 0, 1);
+ test(S("abcdefghij"), 0, 1, S(""), 0, 1, 1);
+}
+
+template <class S>
+void test20()
+{
+ test(S("abcdefghij"), 0, 1, S(""), 1, 0, 0);
+ test(S("abcdefghij"), 0, 1, S("abcde"), 0, 0, 1);
+ test(S("abcdefghij"), 0, 1, S("abcde"), 0, 1, 0);
+ test(S("abcdefghij"), 0, 1, S("abcde"), 0, 2, -1);
+ test(S("abcdefghij"), 0, 1, S("abcde"), 0, 4, -3);
+ test(S("abcdefghij"), 0, 1, S("abcde"), 0, 5, -4);
+ test(S("abcdefghij"), 0, 1, S("abcde"), 0, 6, -4);
+ test(S("abcdefghij"), 0, 1, S("abcde"), 1, 0, 1);
+ test(S("abcdefghij"), 0, 1, S("abcde"), 1, 1, -1);
+ test(S("abcdefghij"), 0, 1, S("abcde"), 1, 2, -1);
+ test(S("abcdefghij"), 0, 1, S("abcde"), 1, 3, -1);
+ test(S("abcdefghij"), 0, 1, S("abcde"), 1, 4, -1);
+ test(S("abcdefghij"), 0, 1, S("abcde"), 1, 5, -1);
+ test(S("abcdefghij"), 0, 1, S("abcde"), 2, 0, 1);
+ test(S("abcdefghij"), 0, 1, S("abcde"), 2, 1, -2);
+ test(S("abcdefghij"), 0, 1, S("abcde"), 2, 2, -2);
+ test(S("abcdefghij"), 0, 1, S("abcde"), 2, 3, -2);
+ test(S("abcdefghij"), 0, 1, S("abcde"), 2, 4, -2);
+ test(S("abcdefghij"), 0, 1, S("abcde"), 4, 0, 1);
+ test(S("abcdefghij"), 0, 1, S("abcde"), 4, 1, -4);
+ test(S("abcdefghij"), 0, 1, S("abcde"), 4, 2, -4);
+ test(S("abcdefghij"), 0, 1, S("abcde"), 5, 0, 1);
+ test(S("abcdefghij"), 0, 1, S("abcde"), 5, 1, 1);
+ test(S("abcdefghij"), 0, 1, S("abcde"), 6, 0, 0);
+ test(S("abcdefghij"), 0, 1, S("abcdefghij"), 0, 0, 1);
+ test(S("abcdefghij"), 0, 1, S("abcdefghij"), 0, 1, 0);
+ test(S("abcdefghij"), 0, 1, S("abcdefghij"), 0, 5, -4);
+ test(S("abcdefghij"), 0, 1, S("abcdefghij"), 0, 9, -8);
+ test(S("abcdefghij"), 0, 1, S("abcdefghij"), 0, 10, -9);
+ test(S("abcdefghij"), 0, 1, S("abcdefghij"), 0, 11, -9);
+ test(S("abcdefghij"), 0, 1, S("abcdefghij"), 1, 0, 1);
+ test(S("abcdefghij"), 0, 1, S("abcdefghij"), 1, 1, -1);
+ test(S("abcdefghij"), 0, 1, S("abcdefghij"), 1, 4, -1);
+ test(S("abcdefghij"), 0, 1, S("abcdefghij"), 1, 8, -1);
+ test(S("abcdefghij"), 0, 1, S("abcdefghij"), 1, 9, -1);
+ test(S("abcdefghij"), 0, 1, S("abcdefghij"), 1, 10, -1);
+ test(S("abcdefghij"), 0, 1, S("abcdefghij"), 5, 0, 1);
+ test(S("abcdefghij"), 0, 1, S("abcdefghij"), 5, 1, -5);
+ test(S("abcdefghij"), 0, 1, S("abcdefghij"), 5, 2, -5);
+ test(S("abcdefghij"), 0, 1, S("abcdefghij"), 5, 4, -5);
+ test(S("abcdefghij"), 0, 1, S("abcdefghij"), 5, 5, -5);
+ test(S("abcdefghij"), 0, 1, S("abcdefghij"), 5, 6, -5);
+ test(S("abcdefghij"), 0, 1, S("abcdefghij"), 9, 0, 1);
+ test(S("abcdefghij"), 0, 1, S("abcdefghij"), 9, 1, -9);
+ test(S("abcdefghij"), 0, 1, S("abcdefghij"), 9, 2, -9);
+ test(S("abcdefghij"), 0, 1, S("abcdefghij"), 10, 0, 1);
+ test(S("abcdefghij"), 0, 1, S("abcdefghij"), 10, 1, 1);
+ test(S("abcdefghij"), 0, 1, S("abcdefghij"), 11, 0, 0);
+ test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 0, 0, 1);
+ test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 0, 1, 0);
+ test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 0, 10, -9);
+ test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 0, 19, -18);
+ test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 0, 20, -19);
+ test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 0, 21, -19);
+ test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 1, 0, 1);
+ test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 1, 1, -1);
+ test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 1, 9, -1);
+ test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 1, 18, -1);
+ test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 1, 19, -1);
+ test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 1, 20, -1);
+ test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 10, 0, 1);
+ test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 10, 1, -10);
+ test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 10, 5, -10);
+ test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 10, 9, -10);
+ test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 10, 10, -10);
+ test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 10, 11, -10);
+ test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 19, 0, 1);
+ test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 19, 1, -19);
+ test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 19, 2, -19);
+ test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 20, 0, 1);
+ test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 20, 1, 1);
+ test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 21, 0, 0);
+ test(S("abcdefghij"), 0, 5, S(""), 0, 0, 5);
+ test(S("abcdefghij"), 0, 5, S(""), 0, 1, 5);
+ test(S("abcdefghij"), 0, 5, S(""), 1, 0, 0);
+ test(S("abcdefghij"), 0, 5, S("abcde"), 0, 0, 5);
+ test(S("abcdefghij"), 0, 5, S("abcde"), 0, 1, 4);
+ test(S("abcdefghij"), 0, 5, S("abcde"), 0, 2, 3);
+ test(S("abcdefghij"), 0, 5, S("abcde"), 0, 4, 1);
+ test(S("abcdefghij"), 0, 5, S("abcde"), 0, 5, 0);
+ test(S("abcdefghij"), 0, 5, S("abcde"), 0, 6, 0);
+ test(S("abcdefghij"), 0, 5, S("abcde"), 1, 0, 5);
+ test(S("abcdefghij"), 0, 5, S("abcde"), 1, 1, -1);
+ test(S("abcdefghij"), 0, 5, S("abcde"), 1, 2, -1);
+ test(S("abcdefghij"), 0, 5, S("abcde"), 1, 3, -1);
+ test(S("abcdefghij"), 0, 5, S("abcde"), 1, 4, -1);
+ test(S("abcdefghij"), 0, 5, S("abcde"), 1, 5, -1);
+ test(S("abcdefghij"), 0, 5, S("abcde"), 2, 0, 5);
+ test(S("abcdefghij"), 0, 5, S("abcde"), 2, 1, -2);
+ test(S("abcdefghij"), 0, 5, S("abcde"), 2, 2, -2);
+ test(S("abcdefghij"), 0, 5, S("abcde"), 2, 3, -2);
+ test(S("abcdefghij"), 0, 5, S("abcde"), 2, 4, -2);
+ test(S("abcdefghij"), 0, 5, S("abcde"), 4, 0, 5);
+ test(S("abcdefghij"), 0, 5, S("abcde"), 4, 1, -4);
+ test(S("abcdefghij"), 0, 5, S("abcde"), 4, 2, -4);
+ test(S("abcdefghij"), 0, 5, S("abcde"), 5, 0, 5);
+ test(S("abcdefghij"), 0, 5, S("abcde"), 5, 1, 5);
+ test(S("abcdefghij"), 0, 5, S("abcde"), 6, 0, 0);
+ test(S("abcdefghij"), 0, 5, S("abcdefghij"), 0, 0, 5);
+ test(S("abcdefghij"), 0, 5, S("abcdefghij"), 0, 1, 4);
+}
+
+template <class S>
+void test21()
+{
+ test(S("abcdefghij"), 0, 5, S("abcdefghij"), 0, 5, 0);
+ test(S("abcdefghij"), 0, 5, S("abcdefghij"), 0, 9, -4);
+ test(S("abcdefghij"), 0, 5, S("abcdefghij"), 0, 10, -5);
+ test(S("abcdefghij"), 0, 5, S("abcdefghij"), 0, 11, -5);
+ test(S("abcdefghij"), 0, 5, S("abcdefghij"), 1, 0, 5);
+ test(S("abcdefghij"), 0, 5, S("abcdefghij"), 1, 1, -1);
+ test(S("abcdefghij"), 0, 5, S("abcdefghij"), 1, 4, -1);
+ test(S("abcdefghij"), 0, 5, S("abcdefghij"), 1, 8, -1);
+ test(S("abcdefghij"), 0, 5, S("abcdefghij"), 1, 9, -1);
+ test(S("abcdefghij"), 0, 5, S("abcdefghij"), 1, 10, -1);
+ test(S("abcdefghij"), 0, 5, S("abcdefghij"), 5, 0, 5);
+ test(S("abcdefghij"), 0, 5, S("abcdefghij"), 5, 1, -5);
+ test(S("abcdefghij"), 0, 5, S("abcdefghij"), 5, 2, -5);
+ test(S("abcdefghij"), 0, 5, S("abcdefghij"), 5, 4, -5);
+ test(S("abcdefghij"), 0, 5, S("abcdefghij"), 5, 5, -5);
+ test(S("abcdefghij"), 0, 5, S("abcdefghij"), 5, 6, -5);
+ test(S("abcdefghij"), 0, 5, S("abcdefghij"), 9, 0, 5);
+ test(S("abcdefghij"), 0, 5, S("abcdefghij"), 9, 1, -9);
+ test(S("abcdefghij"), 0, 5, S("abcdefghij"), 9, 2, -9);
+ test(S("abcdefghij"), 0, 5, S("abcdefghij"), 10, 0, 5);
+ test(S("abcdefghij"), 0, 5, S("abcdefghij"), 10, 1, 5);
+ test(S("abcdefghij"), 0, 5, S("abcdefghij"), 11, 0, 0);
+ test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 0, 0, 5);
+ test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 0, 1, 4);
+ test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 0, 10, -5);
+ test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 0, 19, -14);
+ test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 0, 20, -15);
+ test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 0, 21, -15);
+ test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 1, 0, 5);
+ test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 1, 1, -1);
+ test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 1, 9, -1);
+ test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 1, 18, -1);
+ test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 1, 19, -1);
+ test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 1, 20, -1);
+ test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 10, 0, 5);
+ test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 10, 1, -10);
+ test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 10, 5, -10);
+ test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 10, 9, -10);
+ test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 10, 10, -10);
+ test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 10, 11, -10);
+ test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 19, 0, 5);
+ test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 19, 1, -19);
+ test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 19, 2, -19);
+ test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 20, 0, 5);
+ test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 20, 1, 5);
+ test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 21, 0, 0);
+ test(S("abcdefghij"), 0, 9, S(""), 0, 0, 9);
+ test(S("abcdefghij"), 0, 9, S(""), 0, 1, 9);
+ test(S("abcdefghij"), 0, 9, S(""), 1, 0, 0);
+ test(S("abcdefghij"), 0, 9, S("abcde"), 0, 0, 9);
+ test(S("abcdefghij"), 0, 9, S("abcde"), 0, 1, 8);
+ test(S("abcdefghij"), 0, 9, S("abcde"), 0, 2, 7);
+ test(S("abcdefghij"), 0, 9, S("abcde"), 0, 4, 5);
+ test(S("abcdefghij"), 0, 9, S("abcde"), 0, 5, 4);
+ test(S("abcdefghij"), 0, 9, S("abcde"), 0, 6, 4);
+ test(S("abcdefghij"), 0, 9, S("abcde"), 1, 0, 9);
+ test(S("abcdefghij"), 0, 9, S("abcde"), 1, 1, -1);
+ test(S("abcdefghij"), 0, 9, S("abcde"), 1, 2, -1);
+ test(S("abcdefghij"), 0, 9, S("abcde"), 1, 3, -1);
+ test(S("abcdefghij"), 0, 9, S("abcde"), 1, 4, -1);
+ test(S("abcdefghij"), 0, 9, S("abcde"), 1, 5, -1);
+ test(S("abcdefghij"), 0, 9, S("abcde"), 2, 0, 9);
+ test(S("abcdefghij"), 0, 9, S("abcde"), 2, 1, -2);
+ test(S("abcdefghij"), 0, 9, S("abcde"), 2, 2, -2);
+ test(S("abcdefghij"), 0, 9, S("abcde"), 2, 3, -2);
+ test(S("abcdefghij"), 0, 9, S("abcde"), 2, 4, -2);
+ test(S("abcdefghij"), 0, 9, S("abcde"), 4, 0, 9);
+ test(S("abcdefghij"), 0, 9, S("abcde"), 4, 1, -4);
+ test(S("abcdefghij"), 0, 9, S("abcde"), 4, 2, -4);
+ test(S("abcdefghij"), 0, 9, S("abcde"), 5, 0, 9);
+ test(S("abcdefghij"), 0, 9, S("abcde"), 5, 1, 9);
+ test(S("abcdefghij"), 0, 9, S("abcde"), 6, 0, 0);
+ test(S("abcdefghij"), 0, 9, S("abcdefghij"), 0, 0, 9);
+ test(S("abcdefghij"), 0, 9, S("abcdefghij"), 0, 1, 8);
+ test(S("abcdefghij"), 0, 9, S("abcdefghij"), 0, 5, 4);
+ test(S("abcdefghij"), 0, 9, S("abcdefghij"), 0, 9, 0);
+ test(S("abcdefghij"), 0, 9, S("abcdefghij"), 0, 10, -1);
+ test(S("abcdefghij"), 0, 9, S("abcdefghij"), 0, 11, -1);
+ test(S("abcdefghij"), 0, 9, S("abcdefghij"), 1, 0, 9);
+ test(S("abcdefghij"), 0, 9, S("abcdefghij"), 1, 1, -1);
+ test(S("abcdefghij"), 0, 9, S("abcdefghij"), 1, 4, -1);
+ test(S("abcdefghij"), 0, 9, S("abcdefghij"), 1, 8, -1);
+ test(S("abcdefghij"), 0, 9, S("abcdefghij"), 1, 9, -1);
+ test(S("abcdefghij"), 0, 9, S("abcdefghij"), 1, 10, -1);
+ test(S("abcdefghij"), 0, 9, S("abcdefghij"), 5, 0, 9);
+ test(S("abcdefghij"), 0, 9, S("abcdefghij"), 5, 1, -5);
+ test(S("abcdefghij"), 0, 9, S("abcdefghij"), 5, 2, -5);
+ test(S("abcdefghij"), 0, 9, S("abcdefghij"), 5, 4, -5);
+ test(S("abcdefghij"), 0, 9, S("abcdefghij"), 5, 5, -5);
+ test(S("abcdefghij"), 0, 9, S("abcdefghij"), 5, 6, -5);
+ test(S("abcdefghij"), 0, 9, S("abcdefghij"), 9, 0, 9);
+ test(S("abcdefghij"), 0, 9, S("abcdefghij"), 9, 1, -9);
+ test(S("abcdefghij"), 0, 9, S("abcdefghij"), 9, 2, -9);
+ test(S("abcdefghij"), 0, 9, S("abcdefghij"), 10, 0, 9);
+ test(S("abcdefghij"), 0, 9, S("abcdefghij"), 10, 1, 9);
+ test(S("abcdefghij"), 0, 9, S("abcdefghij"), 11, 0, 0);
+ test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 0, 0, 9);
+ test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 0, 1, 8);
+ test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 0, 10, -1);
+ test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 0, 19, -10);
+}
+
+template <class S>
+void test22()
+{
+ test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 0, 20, -11);
+ test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 0, 21, -11);
+ test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 1, 0, 9);
+ test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 1, 1, -1);
+ test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 1, 9, -1);
+ test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 1, 18, -1);
+ test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 1, 19, -1);
+ test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 1, 20, -1);
+ test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 10, 0, 9);
+ test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 10, 1, -10);
+ test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 10, 5, -10);
+ test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 10, 9, -10);
+ test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 10, 10, -10);
+ test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 10, 11, -10);
+ test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 19, 0, 9);
+ test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 19, 1, -19);
+ test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 19, 2, -19);
+ test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 20, 0, 9);
+ test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 20, 1, 9);
+ test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 21, 0, 0);
+ test(S("abcdefghij"), 0, 10, S(""), 0, 0, 10);
+ test(S("abcdefghij"), 0, 10, S(""), 0, 1, 10);
+ test(S("abcdefghij"), 0, 10, S(""), 1, 0, 0);
+ test(S("abcdefghij"), 0, 10, S("abcde"), 0, 0, 10);
+ test(S("abcdefghij"), 0, 10, S("abcde"), 0, 1, 9);
+ test(S("abcdefghij"), 0, 10, S("abcde"), 0, 2, 8);
+ test(S("abcdefghij"), 0, 10, S("abcde"), 0, 4, 6);
+ test(S("abcdefghij"), 0, 10, S("abcde"), 0, 5, 5);
+ test(S("abcdefghij"), 0, 10, S("abcde"), 0, 6, 5);
+ test(S("abcdefghij"), 0, 10, S("abcde"), 1, 0, 10);
+ test(S("abcdefghij"), 0, 10, S("abcde"), 1, 1, -1);
+ test(S("abcdefghij"), 0, 10, S("abcde"), 1, 2, -1);
+ test(S("abcdefghij"), 0, 10, S("abcde"), 1, 3, -1);
+ test(S("abcdefghij"), 0, 10, S("abcde"), 1, 4, -1);
+ test(S("abcdefghij"), 0, 10, S("abcde"), 1, 5, -1);
+ test(S("abcdefghij"), 0, 10, S("abcde"), 2, 0, 10);
+ test(S("abcdefghij"), 0, 10, S("abcde"), 2, 1, -2);
+ test(S("abcdefghij"), 0, 10, S("abcde"), 2, 2, -2);
+ test(S("abcdefghij"), 0, 10, S("abcde"), 2, 3, -2);
+ test(S("abcdefghij"), 0, 10, S("abcde"), 2, 4, -2);
+ test(S("abcdefghij"), 0, 10, S("abcde"), 4, 0, 10);
+ test(S("abcdefghij"), 0, 10, S("abcde"), 4, 1, -4);
+ test(S("abcdefghij"), 0, 10, S("abcde"), 4, 2, -4);
+ test(S("abcdefghij"), 0, 10, S("abcde"), 5, 0, 10);
+ test(S("abcdefghij"), 0, 10, S("abcde"), 5, 1, 10);
+ test(S("abcdefghij"), 0, 10, S("abcde"), 6, 0, 0);
+ test(S("abcdefghij"), 0, 10, S("abcdefghij"), 0, 0, 10);
+ test(S("abcdefghij"), 0, 10, S("abcdefghij"), 0, 1, 9);
+ test(S("abcdefghij"), 0, 10, S("abcdefghij"), 0, 5, 5);
+ test(S("abcdefghij"), 0, 10, S("abcdefghij"), 0, 9, 1);
+ test(S("abcdefghij"), 0, 10, S("abcdefghij"), 0, 10, 0);
+ test(S("abcdefghij"), 0, 10, S("abcdefghij"), 0, 11, 0);
+ test(S("abcdefghij"), 0, 10, S("abcdefghij"), 1, 0, 10);
+ test(S("abcdefghij"), 0, 10, S("abcdefghij"), 1, 1, -1);
+ test(S("abcdefghij"), 0, 10, S("abcdefghij"), 1, 4, -1);
+ test(S("abcdefghij"), 0, 10, S("abcdefghij"), 1, 8, -1);
+ test(S("abcdefghij"), 0, 10, S("abcdefghij"), 1, 9, -1);
+ test(S("abcdefghij"), 0, 10, S("abcdefghij"), 1, 10, -1);
+ test(S("abcdefghij"), 0, 10, S("abcdefghij"), 5, 0, 10);
+ test(S("abcdefghij"), 0, 10, S("abcdefghij"), 5, 1, -5);
+ test(S("abcdefghij"), 0, 10, S("abcdefghij"), 5, 2, -5);
+ test(S("abcdefghij"), 0, 10, S("abcdefghij"), 5, 4, -5);
+ test(S("abcdefghij"), 0, 10, S("abcdefghij"), 5, 5, -5);
+ test(S("abcdefghij"), 0, 10, S("abcdefghij"), 5, 6, -5);
+ test(S("abcdefghij"), 0, 10, S("abcdefghij"), 9, 0, 10);
+ test(S("abcdefghij"), 0, 10, S("abcdefghij"), 9, 1, -9);
+ test(S("abcdefghij"), 0, 10, S("abcdefghij"), 9, 2, -9);
+ test(S("abcdefghij"), 0, 10, S("abcdefghij"), 10, 0, 10);
+ test(S("abcdefghij"), 0, 10, S("abcdefghij"), 10, 1, 10);
+ test(S("abcdefghij"), 0, 10, S("abcdefghij"), 11, 0, 0);
+ test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 0, 0, 10);
+ test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 0, 1, 9);
+ test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 0, 10, 0);
+ test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 0, 19, -9);
+ test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 0, 20, -10);
+ test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 0, 21, -10);
+ test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 1, 0, 10);
+ test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 1, 1, -1);
+ test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 1, 9, -1);
+ test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 1, 18, -1);
+ test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 1, 19, -1);
+ test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 1, 20, -1);
+ test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 10, 0, 10);
+ test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 10, 1, -10);
+ test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 10, 5, -10);
+ test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 10, 9, -10);
+ test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 10, 10, -10);
+ test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 10, 11, -10);
+ test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 19, 0, 10);
+ test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 19, 1, -19);
+ test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 19, 2, -19);
+ test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 20, 0, 10);
+ test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 20, 1, 10);
+ test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 21, 0, 0);
+ test(S("abcdefghij"), 0, 11, S(""), 0, 0, 10);
+ test(S("abcdefghij"), 0, 11, S(""), 0, 1, 10);
+ test(S("abcdefghij"), 0, 11, S(""), 1, 0, 0);
+ test(S("abcdefghij"), 0, 11, S("abcde"), 0, 0, 10);
+ test(S("abcdefghij"), 0, 11, S("abcde"), 0, 1, 9);
+ test(S("abcdefghij"), 0, 11, S("abcde"), 0, 2, 8);
+}
+
+template <class S>
+void test23()
+{
+ test(S("abcdefghij"), 0, 11, S("abcde"), 0, 4, 6);
+ test(S("abcdefghij"), 0, 11, S("abcde"), 0, 5, 5);
+ test(S("abcdefghij"), 0, 11, S("abcde"), 0, 6, 5);
+ test(S("abcdefghij"), 0, 11, S("abcde"), 1, 0, 10);
+ test(S("abcdefghij"), 0, 11, S("abcde"), 1, 1, -1);
+ test(S("abcdefghij"), 0, 11, S("abcde"), 1, 2, -1);
+ test(S("abcdefghij"), 0, 11, S("abcde"), 1, 3, -1);
+ test(S("abcdefghij"), 0, 11, S("abcde"), 1, 4, -1);
+ test(S("abcdefghij"), 0, 11, S("abcde"), 1, 5, -1);
+ test(S("abcdefghij"), 0, 11, S("abcde"), 2, 0, 10);
+ test(S("abcdefghij"), 0, 11, S("abcde"), 2, 1, -2);
+ test(S("abcdefghij"), 0, 11, S("abcde"), 2, 2, -2);
+ test(S("abcdefghij"), 0, 11, S("abcde"), 2, 3, -2);
+ test(S("abcdefghij"), 0, 11, S("abcde"), 2, 4, -2);
+ test(S("abcdefghij"), 0, 11, S("abcde"), 4, 0, 10);
+ test(S("abcdefghij"), 0, 11, S("abcde"), 4, 1, -4);
+ test(S("abcdefghij"), 0, 11, S("abcde"), 4, 2, -4);
+ test(S("abcdefghij"), 0, 11, S("abcde"), 5, 0, 10);
+ test(S("abcdefghij"), 0, 11, S("abcde"), 5, 1, 10);
+ test(S("abcdefghij"), 0, 11, S("abcde"), 6, 0, 0);
+ test(S("abcdefghij"), 0, 11, S("abcdefghij"), 0, 0, 10);
+ test(S("abcdefghij"), 0, 11, S("abcdefghij"), 0, 1, 9);
+ test(S("abcdefghij"), 0, 11, S("abcdefghij"), 0, 5, 5);
+ test(S("abcdefghij"), 0, 11, S("abcdefghij"), 0, 9, 1);
+ test(S("abcdefghij"), 0, 11, S("abcdefghij"), 0, 10, 0);
+ test(S("abcdefghij"), 0, 11, S("abcdefghij"), 0, 11, 0);
+ test(S("abcdefghij"), 0, 11, S("abcdefghij"), 1, 0, 10);
+ test(S("abcdefghij"), 0, 11, S("abcdefghij"), 1, 1, -1);
+ test(S("abcdefghij"), 0, 11, S("abcdefghij"), 1, 4, -1);
+ test(S("abcdefghij"), 0, 11, S("abcdefghij"), 1, 8, -1);
+ test(S("abcdefghij"), 0, 11, S("abcdefghij"), 1, 9, -1);
+ test(S("abcdefghij"), 0, 11, S("abcdefghij"), 1, 10, -1);
+ test(S("abcdefghij"), 0, 11, S("abcdefghij"), 5, 0, 10);
+ test(S("abcdefghij"), 0, 11, S("abcdefghij"), 5, 1, -5);
+ test(S("abcdefghij"), 0, 11, S("abcdefghij"), 5, 2, -5);
+ test(S("abcdefghij"), 0, 11, S("abcdefghij"), 5, 4, -5);
+ test(S("abcdefghij"), 0, 11, S("abcdefghij"), 5, 5, -5);
+ test(S("abcdefghij"), 0, 11, S("abcdefghij"), 5, 6, -5);
+ test(S("abcdefghij"), 0, 11, S("abcdefghij"), 9, 0, 10);
+ test(S("abcdefghij"), 0, 11, S("abcdefghij"), 9, 1, -9);
+ test(S("abcdefghij"), 0, 11, S("abcdefghij"), 9, 2, -9);
+ test(S("abcdefghij"), 0, 11, S("abcdefghij"), 10, 0, 10);
+ test(S("abcdefghij"), 0, 11, S("abcdefghij"), 10, 1, 10);
+ test(S("abcdefghij"), 0, 11, S("abcdefghij"), 11, 0, 0);
+ test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 0, 0, 10);
+ test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 0, 1, 9);
+ test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 0, 10, 0);
+ test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 0, 19, -9);
+ test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 0, 20, -10);
+ test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 0, 21, -10);
+ test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 1, 0, 10);
+ test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 1, 1, -1);
+ test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 1, 9, -1);
+ test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 1, 18, -1);
+ test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 1, 19, -1);
+ test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 1, 20, -1);
+ test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 10, 0, 10);
+ test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 10, 1, -10);
+ test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 10, 5, -10);
+ test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 10, 9, -10);
+ test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 10, 10, -10);
+ test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 10, 11, -10);
+ test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 19, 0, 10);
+ test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 19, 1, -19);
+ test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 19, 2, -19);
+ test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 20, 0, 10);
+ test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 20, 1, 10);
+ test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 21, 0, 0);
+ test(S("abcdefghij"), 1, 0, S(""), 0, 0, 0);
+ test(S("abcdefghij"), 1, 0, S(""), 0, 1, 0);
+ test(S("abcdefghij"), 1, 0, S(""), 1, 0, 0);
+ test(S("abcdefghij"), 1, 0, S("abcde"), 0, 0, 0);
+ test(S("abcdefghij"), 1, 0, S("abcde"), 0, 1, -1);
+ test(S("abcdefghij"), 1, 0, S("abcde"), 0, 2, -2);
+ test(S("abcdefghij"), 1, 0, S("abcde"), 0, 4, -4);
+ test(S("abcdefghij"), 1, 0, S("abcde"), 0, 5, -5);
+ test(S("abcdefghij"), 1, 0, S("abcde"), 0, 6, -5);
+ test(S("abcdefghij"), 1, 0, S("abcde"), 1, 0, 0);
+ test(S("abcdefghij"), 1, 0, S("abcde"), 1, 1, -1);
+ test(S("abcdefghij"), 1, 0, S("abcde"), 1, 2, -2);
+ test(S("abcdefghij"), 1, 0, S("abcde"), 1, 3, -3);
+ test(S("abcdefghij"), 1, 0, S("abcde"), 1, 4, -4);
+ test(S("abcdefghij"), 1, 0, S("abcde"), 1, 5, -4);
+ test(S("abcdefghij"), 1, 0, S("abcde"), 2, 0, 0);
+ test(S("abcdefghij"), 1, 0, S("abcde"), 2, 1, -1);
+ test(S("abcdefghij"), 1, 0, S("abcde"), 2, 2, -2);
+ test(S("abcdefghij"), 1, 0, S("abcde"), 2, 3, -3);
+ test(S("abcdefghij"), 1, 0, S("abcde"), 2, 4, -3);
+ test(S("abcdefghij"), 1, 0, S("abcde"), 4, 0, 0);
+ test(S("abcdefghij"), 1, 0, S("abcde"), 4, 1, -1);
+ test(S("abcdefghij"), 1, 0, S("abcde"), 4, 2, -1);
+ test(S("abcdefghij"), 1, 0, S("abcde"), 5, 0, 0);
+ test(S("abcdefghij"), 1, 0, S("abcde"), 5, 1, 0);
+ test(S("abcdefghij"), 1, 0, S("abcde"), 6, 0, 0);
+ test(S("abcdefghij"), 1, 0, S("abcdefghij"), 0, 0, 0);
+ test(S("abcdefghij"), 1, 0, S("abcdefghij"), 0, 1, -1);
+ test(S("abcdefghij"), 1, 0, S("abcdefghij"), 0, 5, -5);
+ test(S("abcdefghij"), 1, 0, S("abcdefghij"), 0, 9, -9);
+ test(S("abcdefghij"), 1, 0, S("abcdefghij"), 0, 10, -10);
+ test(S("abcdefghij"), 1, 0, S("abcdefghij"), 0, 11, -10);
+}
+
+template <class S>
+void test24()
+{
+ test(S("abcdefghij"), 1, 0, S("abcdefghij"), 1, 0, 0);
+ test(S("abcdefghij"), 1, 0, S("abcdefghij"), 1, 1, -1);
+ test(S("abcdefghij"), 1, 0, S("abcdefghij"), 1, 4, -4);
+ test(S("abcdefghij"), 1, 0, S("abcdefghij"), 1, 8, -8);
+ test(S("abcdefghij"), 1, 0, S("abcdefghij"), 1, 9, -9);
+ test(S("abcdefghij"), 1, 0, S("abcdefghij"), 1, 10, -9);
+ test(S("abcdefghij"), 1, 0, S("abcdefghij"), 5, 0, 0);
+ test(S("abcdefghij"), 1, 0, S("abcdefghij"), 5, 1, -1);
+ test(S("abcdefghij"), 1, 0, S("abcdefghij"), 5, 2, -2);
+ test(S("abcdefghij"), 1, 0, S("abcdefghij"), 5, 4, -4);
+ test(S("abcdefghij"), 1, 0, S("abcdefghij"), 5, 5, -5);
+ test(S("abcdefghij"), 1, 0, S("abcdefghij"), 5, 6, -5);
+ test(S("abcdefghij"), 1, 0, S("abcdefghij"), 9, 0, 0);
+ test(S("abcdefghij"), 1, 0, S("abcdefghij"), 9, 1, -1);
+ test(S("abcdefghij"), 1, 0, S("abcdefghij"), 9, 2, -1);
+ test(S("abcdefghij"), 1, 0, S("abcdefghij"), 10, 0, 0);
+ test(S("abcdefghij"), 1, 0, S("abcdefghij"), 10, 1, 0);
+ test(S("abcdefghij"), 1, 0, S("abcdefghij"), 11, 0, 0);
+ test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 0, 0, 0);
+ test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 0, 1, -1);
+ test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 0, 10, -10);
+ test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 0, 19, -19);
+ test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 0, 20, -20);
+ test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 0, 21, -20);
+ test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 1, 0, 0);
+ test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 1, 1, -1);
+ test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 1, 9, -9);
+ test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 1, 18, -18);
+ test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 1, 19, -19);
+ test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 1, 20, -19);
+ test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 10, 0, 0);
+ test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 10, 1, -1);
+ test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 10, 5, -5);
+ test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 10, 9, -9);
+ test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 10, 10, -10);
+ test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 10, 11, -10);
+ test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 19, 0, 0);
+ test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 19, 1, -1);
+ test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 19, 2, -1);
+ test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 20, 0, 0);
+ test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 20, 1, 0);
+ test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 21, 0, 0);
+ test(S("abcdefghij"), 1, 1, S(""), 0, 0, 1);
+ test(S("abcdefghij"), 1, 1, S(""), 0, 1, 1);
+ test(S("abcdefghij"), 1, 1, S(""), 1, 0, 0);
+ test(S("abcdefghij"), 1, 1, S("abcde"), 0, 0, 1);
+ test(S("abcdefghij"), 1, 1, S("abcde"), 0, 1, 1);
+ test(S("abcdefghij"), 1, 1, S("abcde"), 0, 2, 1);
+ test(S("abcdefghij"), 1, 1, S("abcde"), 0, 4, 1);
+ test(S("abcdefghij"), 1, 1, S("abcde"), 0, 5, 1);
+ test(S("abcdefghij"), 1, 1, S("abcde"), 0, 6, 1);
+ test(S("abcdefghij"), 1, 1, S("abcde"), 1, 0, 1);
+ test(S("abcdefghij"), 1, 1, S("abcde"), 1, 1, 0);
+ test(S("abcdefghij"), 1, 1, S("abcde"), 1, 2, -1);
+ test(S("abcdefghij"), 1, 1, S("abcde"), 1, 3, -2);
+ test(S("abcdefghij"), 1, 1, S("abcde"), 1, 4, -3);
+ test(S("abcdefghij"), 1, 1, S("abcde"), 1, 5, -3);
+ test(S("abcdefghij"), 1, 1, S("abcde"), 2, 0, 1);
+ test(S("abcdefghij"), 1, 1, S("abcde"), 2, 1, -1);
+ test(S("abcdefghij"), 1, 1, S("abcde"), 2, 2, -1);
+ test(S("abcdefghij"), 1, 1, S("abcde"), 2, 3, -1);
+ test(S("abcdefghij"), 1, 1, S("abcde"), 2, 4, -1);
+ test(S("abcdefghij"), 1, 1, S("abcde"), 4, 0, 1);
+ test(S("abcdefghij"), 1, 1, S("abcde"), 4, 1, -3);
+ test(S("abcdefghij"), 1, 1, S("abcde"), 4, 2, -3);
+ test(S("abcdefghij"), 1, 1, S("abcde"), 5, 0, 1);
+ test(S("abcdefghij"), 1, 1, S("abcde"), 5, 1, 1);
+ test(S("abcdefghij"), 1, 1, S("abcde"), 6, 0, 0);
+ test(S("abcdefghij"), 1, 1, S("abcdefghij"), 0, 0, 1);
+ test(S("abcdefghij"), 1, 1, S("abcdefghij"), 0, 1, 1);
+ test(S("abcdefghij"), 1, 1, S("abcdefghij"), 0, 5, 1);
+ test(S("abcdefghij"), 1, 1, S("abcdefghij"), 0, 9, 1);
+ test(S("abcdefghij"), 1, 1, S("abcdefghij"), 0, 10, 1);
+ test(S("abcdefghij"), 1, 1, S("abcdefghij"), 0, 11, 1);
+ test(S("abcdefghij"), 1, 1, S("abcdefghij"), 1, 0, 1);
+ test(S("abcdefghij"), 1, 1, S("abcdefghij"), 1, 1, 0);
+ test(S("abcdefghij"), 1, 1, S("abcdefghij"), 1, 4, -3);
+ test(S("abcdefghij"), 1, 1, S("abcdefghij"), 1, 8, -7);
+ test(S("abcdefghij"), 1, 1, S("abcdefghij"), 1, 9, -8);
+ test(S("abcdefghij"), 1, 1, S("abcdefghij"), 1, 10, -8);
+ test(S("abcdefghij"), 1, 1, S("abcdefghij"), 5, 0, 1);
+ test(S("abcdefghij"), 1, 1, S("abcdefghij"), 5, 1, -4);
+ test(S("abcdefghij"), 1, 1, S("abcdefghij"), 5, 2, -4);
+ test(S("abcdefghij"), 1, 1, S("abcdefghij"), 5, 4, -4);
+ test(S("abcdefghij"), 1, 1, S("abcdefghij"), 5, 5, -4);
+ test(S("abcdefghij"), 1, 1, S("abcdefghij"), 5, 6, -4);
+ test(S("abcdefghij"), 1, 1, S("abcdefghij"), 9, 0, 1);
+ test(S("abcdefghij"), 1, 1, S("abcdefghij"), 9, 1, -8);
+ test(S("abcdefghij"), 1, 1, S("abcdefghij"), 9, 2, -8);
+ test(S("abcdefghij"), 1, 1, S("abcdefghij"), 10, 0, 1);
+ test(S("abcdefghij"), 1, 1, S("abcdefghij"), 10, 1, 1);
+ test(S("abcdefghij"), 1, 1, S("abcdefghij"), 11, 0, 0);
+ test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 0, 0, 1);
+ test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 0, 1, 1);
+ test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 0, 10, 1);
+ test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 0, 19, 1);
+ test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 0, 20, 1);
+ test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 0, 21, 1);
+ test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 1, 0, 1);
+ test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 1, 1, 0);
+}
+
+template <class S>
+void test25()
+{
+ test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 1, 9, -8);
+ test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 1, 18, -17);
+ test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 1, 19, -18);
+ test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 1, 20, -18);
+ test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 10, 0, 1);
+ test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 10, 1, -9);
+ test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 10, 5, -9);
+ test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 10, 9, -9);
+ test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 10, 10, -9);
+ test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 10, 11, -9);
+ test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 19, 0, 1);
+ test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 19, 1, -18);
+ test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 19, 2, -18);
+ test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 20, 0, 1);
+ test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 20, 1, 1);
+ test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 21, 0, 0);
+ test(S("abcdefghij"), 1, 4, S(""), 0, 0, 4);
+ test(S("abcdefghij"), 1, 4, S(""), 0, 1, 4);
+ test(S("abcdefghij"), 1, 4, S(""), 1, 0, 0);
+ test(S("abcdefghij"), 1, 4, S("abcde"), 0, 0, 4);
+ test(S("abcdefghij"), 1, 4, S("abcde"), 0, 1, 1);
+ test(S("abcdefghij"), 1, 4, S("abcde"), 0, 2, 1);
+ test(S("abcdefghij"), 1, 4, S("abcde"), 0, 4, 1);
+ test(S("abcdefghij"), 1, 4, S("abcde"), 0, 5, 1);
+ test(S("abcdefghij"), 1, 4, S("abcde"), 0, 6, 1);
+ test(S("abcdefghij"), 1, 4, S("abcde"), 1, 0, 4);
+ test(S("abcdefghij"), 1, 4, S("abcde"), 1, 1, 3);
+ test(S("abcdefghij"), 1, 4, S("abcde"), 1, 2, 2);
+ test(S("abcdefghij"), 1, 4, S("abcde"), 1, 3, 1);
+ test(S("abcdefghij"), 1, 4, S("abcde"), 1, 4, 0);
+ test(S("abcdefghij"), 1, 4, S("abcde"), 1, 5, 0);
+ test(S("abcdefghij"), 1, 4, S("abcde"), 2, 0, 4);
+ test(S("abcdefghij"), 1, 4, S("abcde"), 2, 1, -1);
+ test(S("abcdefghij"), 1, 4, S("abcde"), 2, 2, -1);
+ test(S("abcdefghij"), 1, 4, S("abcde"), 2, 3, -1);
+ test(S("abcdefghij"), 1, 4, S("abcde"), 2, 4, -1);
+ test(S("abcdefghij"), 1, 4, S("abcde"), 4, 0, 4);
+ test(S("abcdefghij"), 1, 4, S("abcde"), 4, 1, -3);
+ test(S("abcdefghij"), 1, 4, S("abcde"), 4, 2, -3);
+ test(S("abcdefghij"), 1, 4, S("abcde"), 5, 0, 4);
+ test(S("abcdefghij"), 1, 4, S("abcde"), 5, 1, 4);
+ test(S("abcdefghij"), 1, 4, S("abcde"), 6, 0, 0);
+ test(S("abcdefghij"), 1, 4, S("abcdefghij"), 0, 0, 4);
+ test(S("abcdefghij"), 1, 4, S("abcdefghij"), 0, 1, 1);
+ test(S("abcdefghij"), 1, 4, S("abcdefghij"), 0, 5, 1);
+ test(S("abcdefghij"), 1, 4, S("abcdefghij"), 0, 9, 1);
+ test(S("abcdefghij"), 1, 4, S("abcdefghij"), 0, 10, 1);
+ test(S("abcdefghij"), 1, 4, S("abcdefghij"), 0, 11, 1);
+ test(S("abcdefghij"), 1, 4, S("abcdefghij"), 1, 0, 4);
+ test(S("abcdefghij"), 1, 4, S("abcdefghij"), 1, 1, 3);
+ test(S("abcdefghij"), 1, 4, S("abcdefghij"), 1, 4, 0);
+ test(S("abcdefghij"), 1, 4, S("abcdefghij"), 1, 8, -4);
+ test(S("abcdefghij"), 1, 4, S("abcdefghij"), 1, 9, -5);
+ test(S("abcdefghij"), 1, 4, S("abcdefghij"), 1, 10, -5);
+ test(S("abcdefghij"), 1, 4, S("abcdefghij"), 5, 0, 4);
+ test(S("abcdefghij"), 1, 4, S("abcdefghij"), 5, 1, -4);
+ test(S("abcdefghij"), 1, 4, S("abcdefghij"), 5, 2, -4);
+ test(S("abcdefghij"), 1, 4, S("abcdefghij"), 5, 4, -4);
+ test(S("abcdefghij"), 1, 4, S("abcdefghij"), 5, 5, -4);
+ test(S("abcdefghij"), 1, 4, S("abcdefghij"), 5, 6, -4);
+ test(S("abcdefghij"), 1, 4, S("abcdefghij"), 9, 0, 4);
+ test(S("abcdefghij"), 1, 4, S("abcdefghij"), 9, 1, -8);
+ test(S("abcdefghij"), 1, 4, S("abcdefghij"), 9, 2, -8);
+ test(S("abcdefghij"), 1, 4, S("abcdefghij"), 10, 0, 4);
+ test(S("abcdefghij"), 1, 4, S("abcdefghij"), 10, 1, 4);
+ test(S("abcdefghij"), 1, 4, S("abcdefghij"), 11, 0, 0);
+ test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 0, 0, 4);
+ test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 0, 1, 1);
+ test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 0, 10, 1);
+ test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 0, 19, 1);
+ test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 0, 20, 1);
+ test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 0, 21, 1);
+ test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 1, 0, 4);
+ test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 1, 1, 3);
+ test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 1, 9, -5);
+ test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 1, 18, -14);
+ test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 1, 19, -15);
+ test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 1, 20, -15);
+ test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 10, 0, 4);
+ test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 10, 1, -9);
+ test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 10, 5, -9);
+ test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 10, 9, -9);
+ test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 10, 10, -9);
+ test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 10, 11, -9);
+ test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 19, 0, 4);
+ test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 19, 1, -18);
+ test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 19, 2, -18);
+ test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 20, 0, 4);
+ test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 20, 1, 4);
+ test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 21, 0, 0);
+ test(S("abcdefghij"), 1, 8, S(""), 0, 0, 8);
+ test(S("abcdefghij"), 1, 8, S(""), 0, 1, 8);
+ test(S("abcdefghij"), 1, 8, S(""), 1, 0, 0);
+ test(S("abcdefghij"), 1, 8, S("abcde"), 0, 0, 8);
+ test(S("abcdefghij"), 1, 8, S("abcde"), 0, 1, 1);
+ test(S("abcdefghij"), 1, 8, S("abcde"), 0, 2, 1);
+ test(S("abcdefghij"), 1, 8, S("abcde"), 0, 4, 1);
+ test(S("abcdefghij"), 1, 8, S("abcde"), 0, 5, 1);
+ test(S("abcdefghij"), 1, 8, S("abcde"), 0, 6, 1);
+ test(S("abcdefghij"), 1, 8, S("abcde"), 1, 0, 8);
+}
+
+template <class S>
+void test26()
+{
+ test(S("abcdefghij"), 1, 8, S("abcde"), 1, 1, 7);
+ test(S("abcdefghij"), 1, 8, S("abcde"), 1, 2, 6);
+ test(S("abcdefghij"), 1, 8, S("abcde"), 1, 3, 5);
+ test(S("abcdefghij"), 1, 8, S("abcde"), 1, 4, 4);
+ test(S("abcdefghij"), 1, 8, S("abcde"), 1, 5, 4);
+ test(S("abcdefghij"), 1, 8, S("abcde"), 2, 0, 8);
+ test(S("abcdefghij"), 1, 8, S("abcde"), 2, 1, -1);
+ test(S("abcdefghij"), 1, 8, S("abcde"), 2, 2, -1);
+ test(S("abcdefghij"), 1, 8, S("abcde"), 2, 3, -1);
+ test(S("abcdefghij"), 1, 8, S("abcde"), 2, 4, -1);
+ test(S("abcdefghij"), 1, 8, S("abcde"), 4, 0, 8);
+ test(S("abcdefghij"), 1, 8, S("abcde"), 4, 1, -3);
+ test(S("abcdefghij"), 1, 8, S("abcde"), 4, 2, -3);
+ test(S("abcdefghij"), 1, 8, S("abcde"), 5, 0, 8);
+ test(S("abcdefghij"), 1, 8, S("abcde"), 5, 1, 8);
+ test(S("abcdefghij"), 1, 8, S("abcde"), 6, 0, 0);
+ test(S("abcdefghij"), 1, 8, S("abcdefghij"), 0, 0, 8);
+ test(S("abcdefghij"), 1, 8, S("abcdefghij"), 0, 1, 1);
+ test(S("abcdefghij"), 1, 8, S("abcdefghij"), 0, 5, 1);
+ test(S("abcdefghij"), 1, 8, S("abcdefghij"), 0, 9, 1);
+ test(S("abcdefghij"), 1, 8, S("abcdefghij"), 0, 10, 1);
+ test(S("abcdefghij"), 1, 8, S("abcdefghij"), 0, 11, 1);
+ test(S("abcdefghij"), 1, 8, S("abcdefghij"), 1, 0, 8);
+ test(S("abcdefghij"), 1, 8, S("abcdefghij"), 1, 1, 7);
+ test(S("abcdefghij"), 1, 8, S("abcdefghij"), 1, 4, 4);
+ test(S("abcdefghij"), 1, 8, S("abcdefghij"), 1, 8, 0);
+ test(S("abcdefghij"), 1, 8, S("abcdefghij"), 1, 9, -1);
+ test(S("abcdefghij"), 1, 8, S("abcdefghij"), 1, 10, -1);
+ test(S("abcdefghij"), 1, 8, S("abcdefghij"), 5, 0, 8);
+ test(S("abcdefghij"), 1, 8, S("abcdefghij"), 5, 1, -4);
+ test(S("abcdefghij"), 1, 8, S("abcdefghij"), 5, 2, -4);
+ test(S("abcdefghij"), 1, 8, S("abcdefghij"), 5, 4, -4);
+ test(S("abcdefghij"), 1, 8, S("abcdefghij"), 5, 5, -4);
+ test(S("abcdefghij"), 1, 8, S("abcdefghij"), 5, 6, -4);
+ test(S("abcdefghij"), 1, 8, S("abcdefghij"), 9, 0, 8);
+ test(S("abcdefghij"), 1, 8, S("abcdefghij"), 9, 1, -8);
+ test(S("abcdefghij"), 1, 8, S("abcdefghij"), 9, 2, -8);
+ test(S("abcdefghij"), 1, 8, S("abcdefghij"), 10, 0, 8);
+ test(S("abcdefghij"), 1, 8, S("abcdefghij"), 10, 1, 8);
+ test(S("abcdefghij"), 1, 8, S("abcdefghij"), 11, 0, 0);
+ test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 0, 0, 8);
+ test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 0, 1, 1);
+ test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 0, 10, 1);
+ test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 0, 19, 1);
+ test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 0, 20, 1);
+ test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 0, 21, 1);
+ test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 1, 0, 8);
+ test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 1, 1, 7);
+ test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 1, 9, -1);
+ test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 1, 18, -10);
+ test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 1, 19, -11);
+ test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 1, 20, -11);
+ test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 10, 0, 8);
+ test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 10, 1, -9);
+ test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 10, 5, -9);
+ test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 10, 9, -9);
+ test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 10, 10, -9);
+ test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 10, 11, -9);
+ test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 19, 0, 8);
+ test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 19, 1, -18);
+ test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 19, 2, -18);
+ test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 20, 0, 8);
+ test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 20, 1, 8);
+ test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 21, 0, 0);
+ test(S("abcdefghij"), 1, 9, S(""), 0, 0, 9);
+ test(S("abcdefghij"), 1, 9, S(""), 0, 1, 9);
+ test(S("abcdefghij"), 1, 9, S(""), 1, 0, 0);
+ test(S("abcdefghij"), 1, 9, S("abcde"), 0, 0, 9);
+ test(S("abcdefghij"), 1, 9, S("abcde"), 0, 1, 1);
+ test(S("abcdefghij"), 1, 9, S("abcde"), 0, 2, 1);
+ test(S("abcdefghij"), 1, 9, S("abcde"), 0, 4, 1);
+ test(S("abcdefghij"), 1, 9, S("abcde"), 0, 5, 1);
+ test(S("abcdefghij"), 1, 9, S("abcde"), 0, 6, 1);
+ test(S("abcdefghij"), 1, 9, S("abcde"), 1, 0, 9);
+ test(S("abcdefghij"), 1, 9, S("abcde"), 1, 1, 8);
+ test(S("abcdefghij"), 1, 9, S("abcde"), 1, 2, 7);
+ test(S("abcdefghij"), 1, 9, S("abcde"), 1, 3, 6);
+ test(S("abcdefghij"), 1, 9, S("abcde"), 1, 4, 5);
+ test(S("abcdefghij"), 1, 9, S("abcde"), 1, 5, 5);
+ test(S("abcdefghij"), 1, 9, S("abcde"), 2, 0, 9);
+ test(S("abcdefghij"), 1, 9, S("abcde"), 2, 1, -1);
+ test(S("abcdefghij"), 1, 9, S("abcde"), 2, 2, -1);
+ test(S("abcdefghij"), 1, 9, S("abcde"), 2, 3, -1);
+ test(S("abcdefghij"), 1, 9, S("abcde"), 2, 4, -1);
+ test(S("abcdefghij"), 1, 9, S("abcde"), 4, 0, 9);
+ test(S("abcdefghij"), 1, 9, S("abcde"), 4, 1, -3);
+ test(S("abcdefghij"), 1, 9, S("abcde"), 4, 2, -3);
+ test(S("abcdefghij"), 1, 9, S("abcde"), 5, 0, 9);
+ test(S("abcdefghij"), 1, 9, S("abcde"), 5, 1, 9);
+ test(S("abcdefghij"), 1, 9, S("abcde"), 6, 0, 0);
+ test(S("abcdefghij"), 1, 9, S("abcdefghij"), 0, 0, 9);
+ test(S("abcdefghij"), 1, 9, S("abcdefghij"), 0, 1, 1);
+ test(S("abcdefghij"), 1, 9, S("abcdefghij"), 0, 5, 1);
+ test(S("abcdefghij"), 1, 9, S("abcdefghij"), 0, 9, 1);
+ test(S("abcdefghij"), 1, 9, S("abcdefghij"), 0, 10, 1);
+ test(S("abcdefghij"), 1, 9, S("abcdefghij"), 0, 11, 1);
+ test(S("abcdefghij"), 1, 9, S("abcdefghij"), 1, 0, 9);
+ test(S("abcdefghij"), 1, 9, S("abcdefghij"), 1, 1, 8);
+ test(S("abcdefghij"), 1, 9, S("abcdefghij"), 1, 4, 5);
+ test(S("abcdefghij"), 1, 9, S("abcdefghij"), 1, 8, 1);
+}
+
+template <class S>
+void test27()
+{
+ test(S("abcdefghij"), 1, 9, S("abcdefghij"), 1, 9, 0);
+ test(S("abcdefghij"), 1, 9, S("abcdefghij"), 1, 10, 0);
+ test(S("abcdefghij"), 1, 9, S("abcdefghij"), 5, 0, 9);
+ test(S("abcdefghij"), 1, 9, S("abcdefghij"), 5, 1, -4);
+ test(S("abcdefghij"), 1, 9, S("abcdefghij"), 5, 2, -4);
+ test(S("abcdefghij"), 1, 9, S("abcdefghij"), 5, 4, -4);
+ test(S("abcdefghij"), 1, 9, S("abcdefghij"), 5, 5, -4);
+ test(S("abcdefghij"), 1, 9, S("abcdefghij"), 5, 6, -4);
+ test(S("abcdefghij"), 1, 9, S("abcdefghij"), 9, 0, 9);
+ test(S("abcdefghij"), 1, 9, S("abcdefghij"), 9, 1, -8);
+ test(S("abcdefghij"), 1, 9, S("abcdefghij"), 9, 2, -8);
+ test(S("abcdefghij"), 1, 9, S("abcdefghij"), 10, 0, 9);
+ test(S("abcdefghij"), 1, 9, S("abcdefghij"), 10, 1, 9);
+ test(S("abcdefghij"), 1, 9, S("abcdefghij"), 11, 0, 0);
+ test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 0, 0, 9);
+ test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 0, 1, 1);
+ test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 0, 10, 1);
+ test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 0, 19, 1);
+ test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 0, 20, 1);
+ test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 0, 21, 1);
+ test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 1, 0, 9);
+ test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 1, 1, 8);
+ test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 1, 9, 0);
+ test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 1, 18, -9);
+ test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 1, 19, -10);
+ test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 1, 20, -10);
+ test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 10, 0, 9);
+ test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 10, 1, -9);
+ test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 10, 5, -9);
+ test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 10, 9, -9);
+ test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 10, 10, -9);
+ test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 10, 11, -9);
+ test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 19, 0, 9);
+ test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 19, 1, -18);
+ test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 19, 2, -18);
+ test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 20, 0, 9);
+ test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 20, 1, 9);
+ test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 21, 0, 0);
+ test(S("abcdefghij"), 1, 10, S(""), 0, 0, 9);
+ test(S("abcdefghij"), 1, 10, S(""), 0, 1, 9);
+ test(S("abcdefghij"), 1, 10, S(""), 1, 0, 0);
+ test(S("abcdefghij"), 1, 10, S("abcde"), 0, 0, 9);
+ test(S("abcdefghij"), 1, 10, S("abcde"), 0, 1, 1);
+ test(S("abcdefghij"), 1, 10, S("abcde"), 0, 2, 1);
+ test(S("abcdefghij"), 1, 10, S("abcde"), 0, 4, 1);
+ test(S("abcdefghij"), 1, 10, S("abcde"), 0, 5, 1);
+ test(S("abcdefghij"), 1, 10, S("abcde"), 0, 6, 1);
+ test(S("abcdefghij"), 1, 10, S("abcde"), 1, 0, 9);
+ test(S("abcdefghij"), 1, 10, S("abcde"), 1, 1, 8);
+ test(S("abcdefghij"), 1, 10, S("abcde"), 1, 2, 7);
+ test(S("abcdefghij"), 1, 10, S("abcde"), 1, 3, 6);
+ test(S("abcdefghij"), 1, 10, S("abcde"), 1, 4, 5);
+ test(S("abcdefghij"), 1, 10, S("abcde"), 1, 5, 5);
+ test(S("abcdefghij"), 1, 10, S("abcde"), 2, 0, 9);
+ test(S("abcdefghij"), 1, 10, S("abcde"), 2, 1, -1);
+ test(S("abcdefghij"), 1, 10, S("abcde"), 2, 2, -1);
+ test(S("abcdefghij"), 1, 10, S("abcde"), 2, 3, -1);
+ test(S("abcdefghij"), 1, 10, S("abcde"), 2, 4, -1);
+ test(S("abcdefghij"), 1, 10, S("abcde"), 4, 0, 9);
+ test(S("abcdefghij"), 1, 10, S("abcde"), 4, 1, -3);
+ test(S("abcdefghij"), 1, 10, S("abcde"), 4, 2, -3);
+ test(S("abcdefghij"), 1, 10, S("abcde"), 5, 0, 9);
+ test(S("abcdefghij"), 1, 10, S("abcde"), 5, 1, 9);
+ test(S("abcdefghij"), 1, 10, S("abcde"), 6, 0, 0);
+ test(S("abcdefghij"), 1, 10, S("abcdefghij"), 0, 0, 9);
+ test(S("abcdefghij"), 1, 10, S("abcdefghij"), 0, 1, 1);
+ test(S("abcdefghij"), 1, 10, S("abcdefghij"), 0, 5, 1);
+ test(S("abcdefghij"), 1, 10, S("abcdefghij"), 0, 9, 1);
+ test(S("abcdefghij"), 1, 10, S("abcdefghij"), 0, 10, 1);
+ test(S("abcdefghij"), 1, 10, S("abcdefghij"), 0, 11, 1);
+ test(S("abcdefghij"), 1, 10, S("abcdefghij"), 1, 0, 9);
+ test(S("abcdefghij"), 1, 10, S("abcdefghij"), 1, 1, 8);
+ test(S("abcdefghij"), 1, 10, S("abcdefghij"), 1, 4, 5);
+ test(S("abcdefghij"), 1, 10, S("abcdefghij"), 1, 8, 1);
+ test(S("abcdefghij"), 1, 10, S("abcdefghij"), 1, 9, 0);
+ test(S("abcdefghij"), 1, 10, S("abcdefghij"), 1, 10, 0);
+ test(S("abcdefghij"), 1, 10, S("abcdefghij"), 5, 0, 9);
+ test(S("abcdefghij"), 1, 10, S("abcdefghij"), 5, 1, -4);
+ test(S("abcdefghij"), 1, 10, S("abcdefghij"), 5, 2, -4);
+ test(S("abcdefghij"), 1, 10, S("abcdefghij"), 5, 4, -4);
+ test(S("abcdefghij"), 1, 10, S("abcdefghij"), 5, 5, -4);
+ test(S("abcdefghij"), 1, 10, S("abcdefghij"), 5, 6, -4);
+ test(S("abcdefghij"), 1, 10, S("abcdefghij"), 9, 0, 9);
+ test(S("abcdefghij"), 1, 10, S("abcdefghij"), 9, 1, -8);
+ test(S("abcdefghij"), 1, 10, S("abcdefghij"), 9, 2, -8);
+ test(S("abcdefghij"), 1, 10, S("abcdefghij"), 10, 0, 9);
+ test(S("abcdefghij"), 1, 10, S("abcdefghij"), 10, 1, 9);
+ test(S("abcdefghij"), 1, 10, S("abcdefghij"), 11, 0, 0);
+ test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 0, 0, 9);
+ test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 0, 1, 1);
+ test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 0, 10, 1);
+ test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 0, 19, 1);
+ test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 0, 20, 1);
+ test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 0, 21, 1);
+ test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 1, 0, 9);
+ test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 1, 1, 8);
+ test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 1, 9, 0);
+ test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 1, 18, -9);
+ test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 1, 19, -10);
+ test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 1, 20, -10);
+}
+
+template <class S>
+void test28()
+{
+ test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 10, 0, 9);
+ test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 10, 1, -9);
+ test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 10, 5, -9);
+ test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 10, 9, -9);
+ test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 10, 10, -9);
+ test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 10, 11, -9);
+ test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 19, 0, 9);
+ test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 19, 1, -18);
+ test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 19, 2, -18);
+ test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 20, 0, 9);
+ test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 20, 1, 9);
+ test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 21, 0, 0);
+ test(S("abcdefghij"), 5, 0, S(""), 0, 0, 0);
+ test(S("abcdefghij"), 5, 0, S(""), 0, 1, 0);
+ test(S("abcdefghij"), 5, 0, S(""), 1, 0, 0);
+ test(S("abcdefghij"), 5, 0, S("abcde"), 0, 0, 0);
+ test(S("abcdefghij"), 5, 0, S("abcde"), 0, 1, -1);
+ test(S("abcdefghij"), 5, 0, S("abcde"), 0, 2, -2);
+ test(S("abcdefghij"), 5, 0, S("abcde"), 0, 4, -4);
+ test(S("abcdefghij"), 5, 0, S("abcde"), 0, 5, -5);
+ test(S("abcdefghij"), 5, 0, S("abcde"), 0, 6, -5);
+ test(S("abcdefghij"), 5, 0, S("abcde"), 1, 0, 0);
+ test(S("abcdefghij"), 5, 0, S("abcde"), 1, 1, -1);
+ test(S("abcdefghij"), 5, 0, S("abcde"), 1, 2, -2);
+ test(S("abcdefghij"), 5, 0, S("abcde"), 1, 3, -3);
+ test(S("abcdefghij"), 5, 0, S("abcde"), 1, 4, -4);
+ test(S("abcdefghij"), 5, 0, S("abcde"), 1, 5, -4);
+ test(S("abcdefghij"), 5, 0, S("abcde"), 2, 0, 0);
+ test(S("abcdefghij"), 5, 0, S("abcde"), 2, 1, -1);
+ test(S("abcdefghij"), 5, 0, S("abcde"), 2, 2, -2);
+ test(S("abcdefghij"), 5, 0, S("abcde"), 2, 3, -3);
+ test(S("abcdefghij"), 5, 0, S("abcde"), 2, 4, -3);
+ test(S("abcdefghij"), 5, 0, S("abcde"), 4, 0, 0);
+ test(S("abcdefghij"), 5, 0, S("abcde"), 4, 1, -1);
+ test(S("abcdefghij"), 5, 0, S("abcde"), 4, 2, -1);
+ test(S("abcdefghij"), 5, 0, S("abcde"), 5, 0, 0);
+ test(S("abcdefghij"), 5, 0, S("abcde"), 5, 1, 0);
+ test(S("abcdefghij"), 5, 0, S("abcde"), 6, 0, 0);
+ test(S("abcdefghij"), 5, 0, S("abcdefghij"), 0, 0, 0);
+ test(S("abcdefghij"), 5, 0, S("abcdefghij"), 0, 1, -1);
+ test(S("abcdefghij"), 5, 0, S("abcdefghij"), 0, 5, -5);
+ test(S("abcdefghij"), 5, 0, S("abcdefghij"), 0, 9, -9);
+ test(S("abcdefghij"), 5, 0, S("abcdefghij"), 0, 10, -10);
+ test(S("abcdefghij"), 5, 0, S("abcdefghij"), 0, 11, -10);
+ test(S("abcdefghij"), 5, 0, S("abcdefghij"), 1, 0, 0);
+ test(S("abcdefghij"), 5, 0, S("abcdefghij"), 1, 1, -1);
+ test(S("abcdefghij"), 5, 0, S("abcdefghij"), 1, 4, -4);
+ test(S("abcdefghij"), 5, 0, S("abcdefghij"), 1, 8, -8);
+ test(S("abcdefghij"), 5, 0, S("abcdefghij"), 1, 9, -9);
+ test(S("abcdefghij"), 5, 0, S("abcdefghij"), 1, 10, -9);
+ test(S("abcdefghij"), 5, 0, S("abcdefghij"), 5, 0, 0);
+ test(S("abcdefghij"), 5, 0, S("abcdefghij"), 5, 1, -1);
+ test(S("abcdefghij"), 5, 0, S("abcdefghij"), 5, 2, -2);
+ test(S("abcdefghij"), 5, 0, S("abcdefghij"), 5, 4, -4);
+ test(S("abcdefghij"), 5, 0, S("abcdefghij"), 5, 5, -5);
+ test(S("abcdefghij"), 5, 0, S("abcdefghij"), 5, 6, -5);
+ test(S("abcdefghij"), 5, 0, S("abcdefghij"), 9, 0, 0);
+ test(S("abcdefghij"), 5, 0, S("abcdefghij"), 9, 1, -1);
+ test(S("abcdefghij"), 5, 0, S("abcdefghij"), 9, 2, -1);
+ test(S("abcdefghij"), 5, 0, S("abcdefghij"), 10, 0, 0);
+ test(S("abcdefghij"), 5, 0, S("abcdefghij"), 10, 1, 0);
+ test(S("abcdefghij"), 5, 0, S("abcdefghij"), 11, 0, 0);
+ test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 0, 0, 0);
+ test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 0, 1, -1);
+ test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 0, 10, -10);
+ test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 0, 19, -19);
+ test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 0, 20, -20);
+ test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 0, 21, -20);
+ test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 1, 0, 0);
+ test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 1, 1, -1);
+ test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 1, 9, -9);
+ test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 1, 18, -18);
+ test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 1, 19, -19);
+ test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 1, 20, -19);
+ test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 10, 0, 0);
+ test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 10, 1, -1);
+ test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 10, 5, -5);
+ test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 10, 9, -9);
+ test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 10, 10, -10);
+ test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 10, 11, -10);
+ test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 19, 0, 0);
+ test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 19, 1, -1);
+ test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 19, 2, -1);
+ test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 20, 0, 0);
+ test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 20, 1, 0);
+ test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 21, 0, 0);
+ test(S("abcdefghij"), 5, 1, S(""), 0, 0, 1);
+ test(S("abcdefghij"), 5, 1, S(""), 0, 1, 1);
+ test(S("abcdefghij"), 5, 1, S(""), 1, 0, 0);
+ test(S("abcdefghij"), 5, 1, S("abcde"), 0, 0, 1);
+ test(S("abcdefghij"), 5, 1, S("abcde"), 0, 1, 5);
+ test(S("abcdefghij"), 5, 1, S("abcde"), 0, 2, 5);
+ test(S("abcdefghij"), 5, 1, S("abcde"), 0, 4, 5);
+ test(S("abcdefghij"), 5, 1, S("abcde"), 0, 5, 5);
+ test(S("abcdefghij"), 5, 1, S("abcde"), 0, 6, 5);
+ test(S("abcdefghij"), 5, 1, S("abcde"), 1, 0, 1);
+ test(S("abcdefghij"), 5, 1, S("abcde"), 1, 1, 4);
+ test(S("abcdefghij"), 5, 1, S("abcde"), 1, 2, 4);
+ test(S("abcdefghij"), 5, 1, S("abcde"), 1, 3, 4);
+ test(S("abcdefghij"), 5, 1, S("abcde"), 1, 4, 4);
+}
+
+template <class S>
+void test29()
+{
+ test(S("abcdefghij"), 5, 1, S("abcde"), 1, 5, 4);
+ test(S("abcdefghij"), 5, 1, S("abcde"), 2, 0, 1);
+ test(S("abcdefghij"), 5, 1, S("abcde"), 2, 1, 3);
+ test(S("abcdefghij"), 5, 1, S("abcde"), 2, 2, 3);
+ test(S("abcdefghij"), 5, 1, S("abcde"), 2, 3, 3);
+ test(S("abcdefghij"), 5, 1, S("abcde"), 2, 4, 3);
+ test(S("abcdefghij"), 5, 1, S("abcde"), 4, 0, 1);
+ test(S("abcdefghij"), 5, 1, S("abcde"), 4, 1, 1);
+ test(S("abcdefghij"), 5, 1, S("abcde"), 4, 2, 1);
+ test(S("abcdefghij"), 5, 1, S("abcde"), 5, 0, 1);
+ test(S("abcdefghij"), 5, 1, S("abcde"), 5, 1, 1);
+ test(S("abcdefghij"), 5, 1, S("abcde"), 6, 0, 0);
+ test(S("abcdefghij"), 5, 1, S("abcdefghij"), 0, 0, 1);
+ test(S("abcdefghij"), 5, 1, S("abcdefghij"), 0, 1, 5);
+ test(S("abcdefghij"), 5, 1, S("abcdefghij"), 0, 5, 5);
+ test(S("abcdefghij"), 5, 1, S("abcdefghij"), 0, 9, 5);
+ test(S("abcdefghij"), 5, 1, S("abcdefghij"), 0, 10, 5);
+ test(S("abcdefghij"), 5, 1, S("abcdefghij"), 0, 11, 5);
+ test(S("abcdefghij"), 5, 1, S("abcdefghij"), 1, 0, 1);
+ test(S("abcdefghij"), 5, 1, S("abcdefghij"), 1, 1, 4);
+ test(S("abcdefghij"), 5, 1, S("abcdefghij"), 1, 4, 4);
+ test(S("abcdefghij"), 5, 1, S("abcdefghij"), 1, 8, 4);
+ test(S("abcdefghij"), 5, 1, S("abcdefghij"), 1, 9, 4);
+ test(S("abcdefghij"), 5, 1, S("abcdefghij"), 1, 10, 4);
+ test(S("abcdefghij"), 5, 1, S("abcdefghij"), 5, 0, 1);
+ test(S("abcdefghij"), 5, 1, S("abcdefghij"), 5, 1, 0);
+ test(S("abcdefghij"), 5, 1, S("abcdefghij"), 5, 2, -1);
+ test(S("abcdefghij"), 5, 1, S("abcdefghij"), 5, 4, -3);
+ test(S("abcdefghij"), 5, 1, S("abcdefghij"), 5, 5, -4);
+ test(S("abcdefghij"), 5, 1, S("abcdefghij"), 5, 6, -4);
+ test(S("abcdefghij"), 5, 1, S("abcdefghij"), 9, 0, 1);
+ test(S("abcdefghij"), 5, 1, S("abcdefghij"), 9, 1, -4);
+ test(S("abcdefghij"), 5, 1, S("abcdefghij"), 9, 2, -4);
+ test(S("abcdefghij"), 5, 1, S("abcdefghij"), 10, 0, 1);
+ test(S("abcdefghij"), 5, 1, S("abcdefghij"), 10, 1, 1);
+ test(S("abcdefghij"), 5, 1, S("abcdefghij"), 11, 0, 0);
+ test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 0, 0, 1);
+ test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 0, 1, 5);
+ test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 0, 10, 5);
+ test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 0, 19, 5);
+ test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 0, 20, 5);
+ test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 0, 21, 5);
+ test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 1, 0, 1);
+ test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 1, 1, 4);
+ test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 1, 9, 4);
+ test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 1, 18, 4);
+ test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 1, 19, 4);
+ test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 1, 20, 4);
+ test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 10, 0, 1);
+ test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 10, 1, -5);
+ test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 10, 5, -5);
+ test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 10, 9, -5);
+ test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 10, 10, -5);
+ test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 10, 11, -5);
+ test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 19, 0, 1);
+ test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 19, 1, -14);
+ test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 19, 2, -14);
+ test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 20, 0, 1);
+ test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 20, 1, 1);
+ test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 21, 0, 0);
+ test(S("abcdefghij"), 5, 2, S(""), 0, 0, 2);
+ test(S("abcdefghij"), 5, 2, S(""), 0, 1, 2);
+ test(S("abcdefghij"), 5, 2, S(""), 1, 0, 0);
+ test(S("abcdefghij"), 5, 2, S("abcde"), 0, 0, 2);
+ test(S("abcdefghij"), 5, 2, S("abcde"), 0, 1, 5);
+ test(S("abcdefghij"), 5, 2, S("abcde"), 0, 2, 5);
+ test(S("abcdefghij"), 5, 2, S("abcde"), 0, 4, 5);
+ test(S("abcdefghij"), 5, 2, S("abcde"), 0, 5, 5);
+ test(S("abcdefghij"), 5, 2, S("abcde"), 0, 6, 5);
+ test(S("abcdefghij"), 5, 2, S("abcde"), 1, 0, 2);
+ test(S("abcdefghij"), 5, 2, S("abcde"), 1, 1, 4);
+ test(S("abcdefghij"), 5, 2, S("abcde"), 1, 2, 4);
+ test(S("abcdefghij"), 5, 2, S("abcde"), 1, 3, 4);
+ test(S("abcdefghij"), 5, 2, S("abcde"), 1, 4, 4);
+ test(S("abcdefghij"), 5, 2, S("abcde"), 1, 5, 4);
+ test(S("abcdefghij"), 5, 2, S("abcde"), 2, 0, 2);
+ test(S("abcdefghij"), 5, 2, S("abcde"), 2, 1, 3);
+ test(S("abcdefghij"), 5, 2, S("abcde"), 2, 2, 3);
+ test(S("abcdefghij"), 5, 2, S("abcde"), 2, 3, 3);
+ test(S("abcdefghij"), 5, 2, S("abcde"), 2, 4, 3);
+ test(S("abcdefghij"), 5, 2, S("abcde"), 4, 0, 2);
+ test(S("abcdefghij"), 5, 2, S("abcde"), 4, 1, 1);
+ test(S("abcdefghij"), 5, 2, S("abcde"), 4, 2, 1);
+ test(S("abcdefghij"), 5, 2, S("abcde"), 5, 0, 2);
+ test(S("abcdefghij"), 5, 2, S("abcde"), 5, 1, 2);
+ test(S("abcdefghij"), 5, 2, S("abcde"), 6, 0, 0);
+ test(S("abcdefghij"), 5, 2, S("abcdefghij"), 0, 0, 2);
+ test(S("abcdefghij"), 5, 2, S("abcdefghij"), 0, 1, 5);
+ test(S("abcdefghij"), 5, 2, S("abcdefghij"), 0, 5, 5);
+ test(S("abcdefghij"), 5, 2, S("abcdefghij"), 0, 9, 5);
+ test(S("abcdefghij"), 5, 2, S("abcdefghij"), 0, 10, 5);
+ test(S("abcdefghij"), 5, 2, S("abcdefghij"), 0, 11, 5);
+ test(S("abcdefghij"), 5, 2, S("abcdefghij"), 1, 0, 2);
+ test(S("abcdefghij"), 5, 2, S("abcdefghij"), 1, 1, 4);
+ test(S("abcdefghij"), 5, 2, S("abcdefghij"), 1, 4, 4);
+ test(S("abcdefghij"), 5, 2, S("abcdefghij"), 1, 8, 4);
+ test(S("abcdefghij"), 5, 2, S("abcdefghij"), 1, 9, 4);
+ test(S("abcdefghij"), 5, 2, S("abcdefghij"), 1, 10, 4);
+ test(S("abcdefghij"), 5, 2, S("abcdefghij"), 5, 0, 2);
+ test(S("abcdefghij"), 5, 2, S("abcdefghij"), 5, 1, 1);
+}
+
+template <class S>
+void test30()
+{
+ test(S("abcdefghij"), 5, 2, S("abcdefghij"), 5, 2, 0);
+ test(S("abcdefghij"), 5, 2, S("abcdefghij"), 5, 4, -2);
+ test(S("abcdefghij"), 5, 2, S("abcdefghij"), 5, 5, -3);
+ test(S("abcdefghij"), 5, 2, S("abcdefghij"), 5, 6, -3);
+ test(S("abcdefghij"), 5, 2, S("abcdefghij"), 9, 0, 2);
+ test(S("abcdefghij"), 5, 2, S("abcdefghij"), 9, 1, -4);
+ test(S("abcdefghij"), 5, 2, S("abcdefghij"), 9, 2, -4);
+ test(S("abcdefghij"), 5, 2, S("abcdefghij"), 10, 0, 2);
+ test(S("abcdefghij"), 5, 2, S("abcdefghij"), 10, 1, 2);
+ test(S("abcdefghij"), 5, 2, S("abcdefghij"), 11, 0, 0);
+ test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 0, 0, 2);
+ test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 0, 1, 5);
+ test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 0, 10, 5);
+ test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 0, 19, 5);
+ test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 0, 20, 5);
+ test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 0, 21, 5);
+ test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 1, 0, 2);
+ test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 1, 1, 4);
+ test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 1, 9, 4);
+ test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 1, 18, 4);
+ test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 1, 19, 4);
+ test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 1, 20, 4);
+ test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 10, 0, 2);
+ test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 10, 1, -5);
+ test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 10, 5, -5);
+ test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 10, 9, -5);
+ test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 10, 10, -5);
+ test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 10, 11, -5);
+ test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 19, 0, 2);
+ test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 19, 1, -14);
+ test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 19, 2, -14);
+ test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 20, 0, 2);
+ test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 20, 1, 2);
+ test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 21, 0, 0);
+ test(S("abcdefghij"), 5, 4, S(""), 0, 0, 4);
+ test(S("abcdefghij"), 5, 4, S(""), 0, 1, 4);
+ test(S("abcdefghij"), 5, 4, S(""), 1, 0, 0);
+ test(S("abcdefghij"), 5, 4, S("abcde"), 0, 0, 4);
+ test(S("abcdefghij"), 5, 4, S("abcde"), 0, 1, 5);
+ test(S("abcdefghij"), 5, 4, S("abcde"), 0, 2, 5);
+ test(S("abcdefghij"), 5, 4, S("abcde"), 0, 4, 5);
+ test(S("abcdefghij"), 5, 4, S("abcde"), 0, 5, 5);
+ test(S("abcdefghij"), 5, 4, S("abcde"), 0, 6, 5);
+ test(S("abcdefghij"), 5, 4, S("abcde"), 1, 0, 4);
+ test(S("abcdefghij"), 5, 4, S("abcde"), 1, 1, 4);
+ test(S("abcdefghij"), 5, 4, S("abcde"), 1, 2, 4);
+ test(S("abcdefghij"), 5, 4, S("abcde"), 1, 3, 4);
+ test(S("abcdefghij"), 5, 4, S("abcde"), 1, 4, 4);
+ test(S("abcdefghij"), 5, 4, S("abcde"), 1, 5, 4);
+ test(S("abcdefghij"), 5, 4, S("abcde"), 2, 0, 4);
+ test(S("abcdefghij"), 5, 4, S("abcde"), 2, 1, 3);
+ test(S("abcdefghij"), 5, 4, S("abcde"), 2, 2, 3);
+ test(S("abcdefghij"), 5, 4, S("abcde"), 2, 3, 3);
+ test(S("abcdefghij"), 5, 4, S("abcde"), 2, 4, 3);
+ test(S("abcdefghij"), 5, 4, S("abcde"), 4, 0, 4);
+ test(S("abcdefghij"), 5, 4, S("abcde"), 4, 1, 1);
+ test(S("abcdefghij"), 5, 4, S("abcde"), 4, 2, 1);
+ test(S("abcdefghij"), 5, 4, S("abcde"), 5, 0, 4);
+ test(S("abcdefghij"), 5, 4, S("abcde"), 5, 1, 4);
+ test(S("abcdefghij"), 5, 4, S("abcde"), 6, 0, 0);
+ test(S("abcdefghij"), 5, 4, S("abcdefghij"), 0, 0, 4);
+ test(S("abcdefghij"), 5, 4, S("abcdefghij"), 0, 1, 5);
+ test(S("abcdefghij"), 5, 4, S("abcdefghij"), 0, 5, 5);
+ test(S("abcdefghij"), 5, 4, S("abcdefghij"), 0, 9, 5);
+ test(S("abcdefghij"), 5, 4, S("abcdefghij"), 0, 10, 5);
+ test(S("abcdefghij"), 5, 4, S("abcdefghij"), 0, 11, 5);
+ test(S("abcdefghij"), 5, 4, S("abcdefghij"), 1, 0, 4);
+ test(S("abcdefghij"), 5, 4, S("abcdefghij"), 1, 1, 4);
+ test(S("abcdefghij"), 5, 4, S("abcdefghij"), 1, 4, 4);
+ test(S("abcdefghij"), 5, 4, S("abcdefghij"), 1, 8, 4);
+ test(S("abcdefghij"), 5, 4, S("abcdefghij"), 1, 9, 4);
+ test(S("abcdefghij"), 5, 4, S("abcdefghij"), 1, 10, 4);
+ test(S("abcdefghij"), 5, 4, S("abcdefghij"), 5, 0, 4);
+ test(S("abcdefghij"), 5, 4, S("abcdefghij"), 5, 1, 3);
+ test(S("abcdefghij"), 5, 4, S("abcdefghij"), 5, 2, 2);
+ test(S("abcdefghij"), 5, 4, S("abcdefghij"), 5, 4, 0);
+ test(S("abcdefghij"), 5, 4, S("abcdefghij"), 5, 5, -1);
+ test(S("abcdefghij"), 5, 4, S("abcdefghij"), 5, 6, -1);
+ test(S("abcdefghij"), 5, 4, S("abcdefghij"), 9, 0, 4);
+ test(S("abcdefghij"), 5, 4, S("abcdefghij"), 9, 1, -4);
+ test(S("abcdefghij"), 5, 4, S("abcdefghij"), 9, 2, -4);
+ test(S("abcdefghij"), 5, 4, S("abcdefghij"), 10, 0, 4);
+ test(S("abcdefghij"), 5, 4, S("abcdefghij"), 10, 1, 4);
+ test(S("abcdefghij"), 5, 4, S("abcdefghij"), 11, 0, 0);
+ test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 0, 0, 4);
+ test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 0, 1, 5);
+ test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 0, 10, 5);
+ test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 0, 19, 5);
+ test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 0, 20, 5);
+ test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 0, 21, 5);
+ test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 1, 0, 4);
+ test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 1, 1, 4);
+ test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 1, 9, 4);
+ test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 1, 18, 4);
+ test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 1, 19, 4);
+ test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 1, 20, 4);
+ test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 10, 0, 4);
+ test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 10, 1, -5);
+ test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 10, 5, -5);
+ test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 10, 9, -5);
+}
+
+template <class S>
+void test31()
+{
+ test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 10, 10, -5);
+ test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 10, 11, -5);
+ test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 19, 0, 4);
+ test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 19, 1, -14);
+ test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 19, 2, -14);
+ test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 20, 0, 4);
+ test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 20, 1, 4);
+ test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 21, 0, 0);
+ test(S("abcdefghij"), 5, 5, S(""), 0, 0, 5);
+ test(S("abcdefghij"), 5, 5, S(""), 0, 1, 5);
+ test(S("abcdefghij"), 5, 5, S(""), 1, 0, 0);
+ test(S("abcdefghij"), 5, 5, S("abcde"), 0, 0, 5);
+ test(S("abcdefghij"), 5, 5, S("abcde"), 0, 1, 5);
+ test(S("abcdefghij"), 5, 5, S("abcde"), 0, 2, 5);
+ test(S("abcdefghij"), 5, 5, S("abcde"), 0, 4, 5);
+ test(S("abcdefghij"), 5, 5, S("abcde"), 0, 5, 5);
+ test(S("abcdefghij"), 5, 5, S("abcde"), 0, 6, 5);
+ test(S("abcdefghij"), 5, 5, S("abcde"), 1, 0, 5);
+ test(S("abcdefghij"), 5, 5, S("abcde"), 1, 1, 4);
+ test(S("abcdefghij"), 5, 5, S("abcde"), 1, 2, 4);
+ test(S("abcdefghij"), 5, 5, S("abcde"), 1, 3, 4);
+ test(S("abcdefghij"), 5, 5, S("abcde"), 1, 4, 4);
+ test(S("abcdefghij"), 5, 5, S("abcde"), 1, 5, 4);
+ test(S("abcdefghij"), 5, 5, S("abcde"), 2, 0, 5);
+ test(S("abcdefghij"), 5, 5, S("abcde"), 2, 1, 3);
+ test(S("abcdefghij"), 5, 5, S("abcde"), 2, 2, 3);
+ test(S("abcdefghij"), 5, 5, S("abcde"), 2, 3, 3);
+ test(S("abcdefghij"), 5, 5, S("abcde"), 2, 4, 3);
+ test(S("abcdefghij"), 5, 5, S("abcde"), 4, 0, 5);
+ test(S("abcdefghij"), 5, 5, S("abcde"), 4, 1, 1);
+ test(S("abcdefghij"), 5, 5, S("abcde"), 4, 2, 1);
+ test(S("abcdefghij"), 5, 5, S("abcde"), 5, 0, 5);
+ test(S("abcdefghij"), 5, 5, S("abcde"), 5, 1, 5);
+ test(S("abcdefghij"), 5, 5, S("abcde"), 6, 0, 0);
+ test(S("abcdefghij"), 5, 5, S("abcdefghij"), 0, 0, 5);
+ test(S("abcdefghij"), 5, 5, S("abcdefghij"), 0, 1, 5);
+ test(S("abcdefghij"), 5, 5, S("abcdefghij"), 0, 5, 5);
+ test(S("abcdefghij"), 5, 5, S("abcdefghij"), 0, 9, 5);
+ test(S("abcdefghij"), 5, 5, S("abcdefghij"), 0, 10, 5);
+ test(S("abcdefghij"), 5, 5, S("abcdefghij"), 0, 11, 5);
+ test(S("abcdefghij"), 5, 5, S("abcdefghij"), 1, 0, 5);
+ test(S("abcdefghij"), 5, 5, S("abcdefghij"), 1, 1, 4);
+ test(S("abcdefghij"), 5, 5, S("abcdefghij"), 1, 4, 4);
+ test(S("abcdefghij"), 5, 5, S("abcdefghij"), 1, 8, 4);
+ test(S("abcdefghij"), 5, 5, S("abcdefghij"), 1, 9, 4);
+ test(S("abcdefghij"), 5, 5, S("abcdefghij"), 1, 10, 4);
+ test(S("abcdefghij"), 5, 5, S("abcdefghij"), 5, 0, 5);
+ test(S("abcdefghij"), 5, 5, S("abcdefghij"), 5, 1, 4);
+ test(S("abcdefghij"), 5, 5, S("abcdefghij"), 5, 2, 3);
+ test(S("abcdefghij"), 5, 5, S("abcdefghij"), 5, 4, 1);
+ test(S("abcdefghij"), 5, 5, S("abcdefghij"), 5, 5, 0);
+ test(S("abcdefghij"), 5, 5, S("abcdefghij"), 5, 6, 0);
+ test(S("abcdefghij"), 5, 5, S("abcdefghij"), 9, 0, 5);
+ test(S("abcdefghij"), 5, 5, S("abcdefghij"), 9, 1, -4);
+ test(S("abcdefghij"), 5, 5, S("abcdefghij"), 9, 2, -4);
+ test(S("abcdefghij"), 5, 5, S("abcdefghij"), 10, 0, 5);
+ test(S("abcdefghij"), 5, 5, S("abcdefghij"), 10, 1, 5);
+ test(S("abcdefghij"), 5, 5, S("abcdefghij"), 11, 0, 0);
+ test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 0, 0, 5);
+ test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 0, 1, 5);
+ test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 0, 10, 5);
+ test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 0, 19, 5);
+ test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 0, 20, 5);
+ test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 0, 21, 5);
+ test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 1, 0, 5);
+ test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 1, 1, 4);
+ test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 1, 9, 4);
+ test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 1, 18, 4);
+ test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 1, 19, 4);
+ test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 1, 20, 4);
+ test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 10, 0, 5);
+ test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 10, 1, -5);
+ test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 10, 5, -5);
+ test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 10, 9, -5);
+ test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 10, 10, -5);
+ test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 10, 11, -5);
+ test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 19, 0, 5);
+ test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 19, 1, -14);
+ test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 19, 2, -14);
+ test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 20, 0, 5);
+ test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 20, 1, 5);
+ test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 21, 0, 0);
+ test(S("abcdefghij"), 5, 6, S(""), 0, 0, 5);
+ test(S("abcdefghij"), 5, 6, S(""), 0, 1, 5);
+ test(S("abcdefghij"), 5, 6, S(""), 1, 0, 0);
+ test(S("abcdefghij"), 5, 6, S("abcde"), 0, 0, 5);
+ test(S("abcdefghij"), 5, 6, S("abcde"), 0, 1, 5);
+ test(S("abcdefghij"), 5, 6, S("abcde"), 0, 2, 5);
+ test(S("abcdefghij"), 5, 6, S("abcde"), 0, 4, 5);
+ test(S("abcdefghij"), 5, 6, S("abcde"), 0, 5, 5);
+ test(S("abcdefghij"), 5, 6, S("abcde"), 0, 6, 5);
+ test(S("abcdefghij"), 5, 6, S("abcde"), 1, 0, 5);
+ test(S("abcdefghij"), 5, 6, S("abcde"), 1, 1, 4);
+ test(S("abcdefghij"), 5, 6, S("abcde"), 1, 2, 4);
+ test(S("abcdefghij"), 5, 6, S("abcde"), 1, 3, 4);
+ test(S("abcdefghij"), 5, 6, S("abcde"), 1, 4, 4);
+ test(S("abcdefghij"), 5, 6, S("abcde"), 1, 5, 4);
+ test(S("abcdefghij"), 5, 6, S("abcde"), 2, 0, 5);
+ test(S("abcdefghij"), 5, 6, S("abcde"), 2, 1, 3);
+ test(S("abcdefghij"), 5, 6, S("abcde"), 2, 2, 3);
+}
+
+template <class S>
+void test32()
+{
+ test(S("abcdefghij"), 5, 6, S("abcde"), 2, 3, 3);
+ test(S("abcdefghij"), 5, 6, S("abcde"), 2, 4, 3);
+ test(S("abcdefghij"), 5, 6, S("abcde"), 4, 0, 5);
+ test(S("abcdefghij"), 5, 6, S("abcde"), 4, 1, 1);
+ test(S("abcdefghij"), 5, 6, S("abcde"), 4, 2, 1);
+ test(S("abcdefghij"), 5, 6, S("abcde"), 5, 0, 5);
+ test(S("abcdefghij"), 5, 6, S("abcde"), 5, 1, 5);
+ test(S("abcdefghij"), 5, 6, S("abcde"), 6, 0, 0);
+ test(S("abcdefghij"), 5, 6, S("abcdefghij"), 0, 0, 5);
+ test(S("abcdefghij"), 5, 6, S("abcdefghij"), 0, 1, 5);
+ test(S("abcdefghij"), 5, 6, S("abcdefghij"), 0, 5, 5);
+ test(S("abcdefghij"), 5, 6, S("abcdefghij"), 0, 9, 5);
+ test(S("abcdefghij"), 5, 6, S("abcdefghij"), 0, 10, 5);
+ test(S("abcdefghij"), 5, 6, S("abcdefghij"), 0, 11, 5);
+ test(S("abcdefghij"), 5, 6, S("abcdefghij"), 1, 0, 5);
+ test(S("abcdefghij"), 5, 6, S("abcdefghij"), 1, 1, 4);
+ test(S("abcdefghij"), 5, 6, S("abcdefghij"), 1, 4, 4);
+ test(S("abcdefghij"), 5, 6, S("abcdefghij"), 1, 8, 4);
+ test(S("abcdefghij"), 5, 6, S("abcdefghij"), 1, 9, 4);
+ test(S("abcdefghij"), 5, 6, S("abcdefghij"), 1, 10, 4);
+ test(S("abcdefghij"), 5, 6, S("abcdefghij"), 5, 0, 5);
+ test(S("abcdefghij"), 5, 6, S("abcdefghij"), 5, 1, 4);
+ test(S("abcdefghij"), 5, 6, S("abcdefghij"), 5, 2, 3);
+ test(S("abcdefghij"), 5, 6, S("abcdefghij"), 5, 4, 1);
+ test(S("abcdefghij"), 5, 6, S("abcdefghij"), 5, 5, 0);
+ test(S("abcdefghij"), 5, 6, S("abcdefghij"), 5, 6, 0);
+ test(S("abcdefghij"), 5, 6, S("abcdefghij"), 9, 0, 5);
+ test(S("abcdefghij"), 5, 6, S("abcdefghij"), 9, 1, -4);
+ test(S("abcdefghij"), 5, 6, S("abcdefghij"), 9, 2, -4);
+ test(S("abcdefghij"), 5, 6, S("abcdefghij"), 10, 0, 5);
+ test(S("abcdefghij"), 5, 6, S("abcdefghij"), 10, 1, 5);
+ test(S("abcdefghij"), 5, 6, S("abcdefghij"), 11, 0, 0);
+ test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 0, 0, 5);
+ test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 0, 1, 5);
+ test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 0, 10, 5);
+ test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 0, 19, 5);
+ test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 0, 20, 5);
+ test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 0, 21, 5);
+ test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 1, 0, 5);
+ test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 1, 1, 4);
+ test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 1, 9, 4);
+ test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 1, 18, 4);
+ test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 1, 19, 4);
+ test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 1, 20, 4);
+ test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 10, 0, 5);
+ test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 10, 1, -5);
+ test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 10, 5, -5);
+ test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 10, 9, -5);
+ test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 10, 10, -5);
+ test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 10, 11, -5);
+ test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 19, 0, 5);
+ test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 19, 1, -14);
+ test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 19, 2, -14);
+ test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 20, 0, 5);
+ test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 20, 1, 5);
+ test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 21, 0, 0);
+ test(S("abcdefghij"), 9, 0, S(""), 0, 0, 0);
+ test(S("abcdefghij"), 9, 0, S(""), 0, 1, 0);
+ test(S("abcdefghij"), 9, 0, S(""), 1, 0, 0);
+ test(S("abcdefghij"), 9, 0, S("abcde"), 0, 0, 0);
+ test(S("abcdefghij"), 9, 0, S("abcde"), 0, 1, -1);
+ test(S("abcdefghij"), 9, 0, S("abcde"), 0, 2, -2);
+ test(S("abcdefghij"), 9, 0, S("abcde"), 0, 4, -4);
+ test(S("abcdefghij"), 9, 0, S("abcde"), 0, 5, -5);
+ test(S("abcdefghij"), 9, 0, S("abcde"), 0, 6, -5);
+ test(S("abcdefghij"), 9, 0, S("abcde"), 1, 0, 0);
+ test(S("abcdefghij"), 9, 0, S("abcde"), 1, 1, -1);
+ test(S("abcdefghij"), 9, 0, S("abcde"), 1, 2, -2);
+ test(S("abcdefghij"), 9, 0, S("abcde"), 1, 3, -3);
+ test(S("abcdefghij"), 9, 0, S("abcde"), 1, 4, -4);
+ test(S("abcdefghij"), 9, 0, S("abcde"), 1, 5, -4);
+ test(S("abcdefghij"), 9, 0, S("abcde"), 2, 0, 0);
+ test(S("abcdefghij"), 9, 0, S("abcde"), 2, 1, -1);
+ test(S("abcdefghij"), 9, 0, S("abcde"), 2, 2, -2);
+ test(S("abcdefghij"), 9, 0, S("abcde"), 2, 3, -3);
+ test(S("abcdefghij"), 9, 0, S("abcde"), 2, 4, -3);
+ test(S("abcdefghij"), 9, 0, S("abcde"), 4, 0, 0);
+ test(S("abcdefghij"), 9, 0, S("abcde"), 4, 1, -1);
+ test(S("abcdefghij"), 9, 0, S("abcde"), 4, 2, -1);
+ test(S("abcdefghij"), 9, 0, S("abcde"), 5, 0, 0);
+ test(S("abcdefghij"), 9, 0, S("abcde"), 5, 1, 0);
+ test(S("abcdefghij"), 9, 0, S("abcde"), 6, 0, 0);
+ test(S("abcdefghij"), 9, 0, S("abcdefghij"), 0, 0, 0);
+ test(S("abcdefghij"), 9, 0, S("abcdefghij"), 0, 1, -1);
+ test(S("abcdefghij"), 9, 0, S("abcdefghij"), 0, 5, -5);
+ test(S("abcdefghij"), 9, 0, S("abcdefghij"), 0, 9, -9);
+ test(S("abcdefghij"), 9, 0, S("abcdefghij"), 0, 10, -10);
+ test(S("abcdefghij"), 9, 0, S("abcdefghij"), 0, 11, -10);
+ test(S("abcdefghij"), 9, 0, S("abcdefghij"), 1, 0, 0);
+ test(S("abcdefghij"), 9, 0, S("abcdefghij"), 1, 1, -1);
+ test(S("abcdefghij"), 9, 0, S("abcdefghij"), 1, 4, -4);
+ test(S("abcdefghij"), 9, 0, S("abcdefghij"), 1, 8, -8);
+ test(S("abcdefghij"), 9, 0, S("abcdefghij"), 1, 9, -9);
+ test(S("abcdefghij"), 9, 0, S("abcdefghij"), 1, 10, -9);
+ test(S("abcdefghij"), 9, 0, S("abcdefghij"), 5, 0, 0);
+ test(S("abcdefghij"), 9, 0, S("abcdefghij"), 5, 1, -1);
+ test(S("abcdefghij"), 9, 0, S("abcdefghij"), 5, 2, -2);
+ test(S("abcdefghij"), 9, 0, S("abcdefghij"), 5, 4, -4);
+ test(S("abcdefghij"), 9, 0, S("abcdefghij"), 5, 5, -5);
+ test(S("abcdefghij"), 9, 0, S("abcdefghij"), 5, 6, -5);
+}
+
+template <class S>
+void test33()
+{
+ test(S("abcdefghij"), 9, 0, S("abcdefghij"), 9, 0, 0);
+ test(S("abcdefghij"), 9, 0, S("abcdefghij"), 9, 1, -1);
+ test(S("abcdefghij"), 9, 0, S("abcdefghij"), 9, 2, -1);
+ test(S("abcdefghij"), 9, 0, S("abcdefghij"), 10, 0, 0);
+ test(S("abcdefghij"), 9, 0, S("abcdefghij"), 10, 1, 0);
+ test(S("abcdefghij"), 9, 0, S("abcdefghij"), 11, 0, 0);
+ test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 0, 0, 0);
+ test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 0, 1, -1);
+ test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 0, 10, -10);
+ test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 0, 19, -19);
+ test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 0, 20, -20);
+ test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 0, 21, -20);
+ test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 1, 0, 0);
+ test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 1, 1, -1);
+ test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 1, 9, -9);
+ test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 1, 18, -18);
+ test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 1, 19, -19);
+ test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 1, 20, -19);
+ test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 10, 0, 0);
+ test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 10, 1, -1);
+ test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 10, 5, -5);
+ test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 10, 9, -9);
+ test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 10, 10, -10);
+ test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 10, 11, -10);
+ test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 19, 0, 0);
+ test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 19, 1, -1);
+ test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 19, 2, -1);
+ test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 20, 0, 0);
+ test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 20, 1, 0);
+ test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 21, 0, 0);
+ test(S("abcdefghij"), 9, 1, S(""), 0, 0, 1);
+ test(S("abcdefghij"), 9, 1, S(""), 0, 1, 1);
+ test(S("abcdefghij"), 9, 1, S(""), 1, 0, 0);
+ test(S("abcdefghij"), 9, 1, S("abcde"), 0, 0, 1);
+ test(S("abcdefghij"), 9, 1, S("abcde"), 0, 1, 9);
+ test(S("abcdefghij"), 9, 1, S("abcde"), 0, 2, 9);
+ test(S("abcdefghij"), 9, 1, S("abcde"), 0, 4, 9);
+ test(S("abcdefghij"), 9, 1, S("abcde"), 0, 5, 9);
+ test(S("abcdefghij"), 9, 1, S("abcde"), 0, 6, 9);
+ test(S("abcdefghij"), 9, 1, S("abcde"), 1, 0, 1);
+ test(S("abcdefghij"), 9, 1, S("abcde"), 1, 1, 8);
+ test(S("abcdefghij"), 9, 1, S("abcde"), 1, 2, 8);
+ test(S("abcdefghij"), 9, 1, S("abcde"), 1, 3, 8);
+ test(S("abcdefghij"), 9, 1, S("abcde"), 1, 4, 8);
+ test(S("abcdefghij"), 9, 1, S("abcde"), 1, 5, 8);
+ test(S("abcdefghij"), 9, 1, S("abcde"), 2, 0, 1);
+ test(S("abcdefghij"), 9, 1, S("abcde"), 2, 1, 7);
+ test(S("abcdefghij"), 9, 1, S("abcde"), 2, 2, 7);
+ test(S("abcdefghij"), 9, 1, S("abcde"), 2, 3, 7);
+ test(S("abcdefghij"), 9, 1, S("abcde"), 2, 4, 7);
+ test(S("abcdefghij"), 9, 1, S("abcde"), 4, 0, 1);
+ test(S("abcdefghij"), 9, 1, S("abcde"), 4, 1, 5);
+ test(S("abcdefghij"), 9, 1, S("abcde"), 4, 2, 5);
+ test(S("abcdefghij"), 9, 1, S("abcde"), 5, 0, 1);
+ test(S("abcdefghij"), 9, 1, S("abcde"), 5, 1, 1);
+ test(S("abcdefghij"), 9, 1, S("abcde"), 6, 0, 0);
+ test(S("abcdefghij"), 9, 1, S("abcdefghij"), 0, 0, 1);
+ test(S("abcdefghij"), 9, 1, S("abcdefghij"), 0, 1, 9);
+ test(S("abcdefghij"), 9, 1, S("abcdefghij"), 0, 5, 9);
+ test(S("abcdefghij"), 9, 1, S("abcdefghij"), 0, 9, 9);
+ test(S("abcdefghij"), 9, 1, S("abcdefghij"), 0, 10, 9);
+ test(S("abcdefghij"), 9, 1, S("abcdefghij"), 0, 11, 9);
+ test(S("abcdefghij"), 9, 1, S("abcdefghij"), 1, 0, 1);
+ test(S("abcdefghij"), 9, 1, S("abcdefghij"), 1, 1, 8);
+ test(S("abcdefghij"), 9, 1, S("abcdefghij"), 1, 4, 8);
+ test(S("abcdefghij"), 9, 1, S("abcdefghij"), 1, 8, 8);
+ test(S("abcdefghij"), 9, 1, S("abcdefghij"), 1, 9, 8);
+ test(S("abcdefghij"), 9, 1, S("abcdefghij"), 1, 10, 8);
+ test(S("abcdefghij"), 9, 1, S("abcdefghij"), 5, 0, 1);
+ test(S("abcdefghij"), 9, 1, S("abcdefghij"), 5, 1, 4);
+ test(S("abcdefghij"), 9, 1, S("abcdefghij"), 5, 2, 4);
+ test(S("abcdefghij"), 9, 1, S("abcdefghij"), 5, 4, 4);
+ test(S("abcdefghij"), 9, 1, S("abcdefghij"), 5, 5, 4);
+ test(S("abcdefghij"), 9, 1, S("abcdefghij"), 5, 6, 4);
+ test(S("abcdefghij"), 9, 1, S("abcdefghij"), 9, 0, 1);
+ test(S("abcdefghij"), 9, 1, S("abcdefghij"), 9, 1, 0);
+ test(S("abcdefghij"), 9, 1, S("abcdefghij"), 9, 2, 0);
+ test(S("abcdefghij"), 9, 1, S("abcdefghij"), 10, 0, 1);
+ test(S("abcdefghij"), 9, 1, S("abcdefghij"), 10, 1, 1);
+ test(S("abcdefghij"), 9, 1, S("abcdefghij"), 11, 0, 0);
+ test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 0, 0, 1);
+ test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 0, 1, 9);
+ test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 0, 10, 9);
+ test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 0, 19, 9);
+ test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 0, 20, 9);
+ test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 0, 21, 9);
+ test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 1, 0, 1);
+ test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 1, 1, 8);
+ test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 1, 9, 8);
+ test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 1, 18, 8);
+ test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 1, 19, 8);
+ test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 1, 20, 8);
+ test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 10, 0, 1);
+ test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 10, 1, -1);
+ test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 10, 5, -1);
+ test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 10, 9, -1);
+ test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 10, 10, -1);
+ test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 10, 11, -1);
+ test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 19, 0, 1);
+ test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 19, 1, -10);
+}
+
+template <class S>
+void test34()
+{
+ test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 19, 2, -10);
+ test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 20, 0, 1);
+ test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 20, 1, 1);
+ test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 21, 0, 0);
+ test(S("abcdefghij"), 9, 2, S(""), 0, 0, 1);
+ test(S("abcdefghij"), 9, 2, S(""), 0, 1, 1);
+ test(S("abcdefghij"), 9, 2, S(""), 1, 0, 0);
+ test(S("abcdefghij"), 9, 2, S("abcde"), 0, 0, 1);
+ test(S("abcdefghij"), 9, 2, S("abcde"), 0, 1, 9);
+ test(S("abcdefghij"), 9, 2, S("abcde"), 0, 2, 9);
+ test(S("abcdefghij"), 9, 2, S("abcde"), 0, 4, 9);
+ test(S("abcdefghij"), 9, 2, S("abcde"), 0, 5, 9);
+ test(S("abcdefghij"), 9, 2, S("abcde"), 0, 6, 9);
+ test(S("abcdefghij"), 9, 2, S("abcde"), 1, 0, 1);
+ test(S("abcdefghij"), 9, 2, S("abcde"), 1, 1, 8);
+ test(S("abcdefghij"), 9, 2, S("abcde"), 1, 2, 8);
+ test(S("abcdefghij"), 9, 2, S("abcde"), 1, 3, 8);
+ test(S("abcdefghij"), 9, 2, S("abcde"), 1, 4, 8);
+ test(S("abcdefghij"), 9, 2, S("abcde"), 1, 5, 8);
+ test(S("abcdefghij"), 9, 2, S("abcde"), 2, 0, 1);
+ test(S("abcdefghij"), 9, 2, S("abcde"), 2, 1, 7);
+ test(S("abcdefghij"), 9, 2, S("abcde"), 2, 2, 7);
+ test(S("abcdefghij"), 9, 2, S("abcde"), 2, 3, 7);
+ test(S("abcdefghij"), 9, 2, S("abcde"), 2, 4, 7);
+ test(S("abcdefghij"), 9, 2, S("abcde"), 4, 0, 1);
+ test(S("abcdefghij"), 9, 2, S("abcde"), 4, 1, 5);
+ test(S("abcdefghij"), 9, 2, S("abcde"), 4, 2, 5);
+ test(S("abcdefghij"), 9, 2, S("abcde"), 5, 0, 1);
+ test(S("abcdefghij"), 9, 2, S("abcde"), 5, 1, 1);
+ test(S("abcdefghij"), 9, 2, S("abcde"), 6, 0, 0);
+ test(S("abcdefghij"), 9, 2, S("abcdefghij"), 0, 0, 1);
+ test(S("abcdefghij"), 9, 2, S("abcdefghij"), 0, 1, 9);
+ test(S("abcdefghij"), 9, 2, S("abcdefghij"), 0, 5, 9);
+ test(S("abcdefghij"), 9, 2, S("abcdefghij"), 0, 9, 9);
+ test(S("abcdefghij"), 9, 2, S("abcdefghij"), 0, 10, 9);
+ test(S("abcdefghij"), 9, 2, S("abcdefghij"), 0, 11, 9);
+ test(S("abcdefghij"), 9, 2, S("abcdefghij"), 1, 0, 1);
+ test(S("abcdefghij"), 9, 2, S("abcdefghij"), 1, 1, 8);
+ test(S("abcdefghij"), 9, 2, S("abcdefghij"), 1, 4, 8);
+ test(S("abcdefghij"), 9, 2, S("abcdefghij"), 1, 8, 8);
+ test(S("abcdefghij"), 9, 2, S("abcdefghij"), 1, 9, 8);
+ test(S("abcdefghij"), 9, 2, S("abcdefghij"), 1, 10, 8);
+ test(S("abcdefghij"), 9, 2, S("abcdefghij"), 5, 0, 1);
+ test(S("abcdefghij"), 9, 2, S("abcdefghij"), 5, 1, 4);
+ test(S("abcdefghij"), 9, 2, S("abcdefghij"), 5, 2, 4);
+ test(S("abcdefghij"), 9, 2, S("abcdefghij"), 5, 4, 4);
+ test(S("abcdefghij"), 9, 2, S("abcdefghij"), 5, 5, 4);
+ test(S("abcdefghij"), 9, 2, S("abcdefghij"), 5, 6, 4);
+ test(S("abcdefghij"), 9, 2, S("abcdefghij"), 9, 0, 1);
+ test(S("abcdefghij"), 9, 2, S("abcdefghij"), 9, 1, 0);
+ test(S("abcdefghij"), 9, 2, S("abcdefghij"), 9, 2, 0);
+ test(S("abcdefghij"), 9, 2, S("abcdefghij"), 10, 0, 1);
+ test(S("abcdefghij"), 9, 2, S("abcdefghij"), 10, 1, 1);
+ test(S("abcdefghij"), 9, 2, S("abcdefghij"), 11, 0, 0);
+ test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 0, 0, 1);
+ test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 0, 1, 9);
+ test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 0, 10, 9);
+ test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 0, 19, 9);
+ test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 0, 20, 9);
+ test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 0, 21, 9);
+ test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 1, 0, 1);
+ test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 1, 1, 8);
+ test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 1, 9, 8);
+ test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 1, 18, 8);
+ test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 1, 19, 8);
+ test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 1, 20, 8);
+ test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 10, 0, 1);
+ test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 10, 1, -1);
+ test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 10, 5, -1);
+ test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 10, 9, -1);
+ test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 10, 10, -1);
+ test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 10, 11, -1);
+ test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 19, 0, 1);
+ test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 19, 1, -10);
+ test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 19, 2, -10);
+ test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 20, 0, 1);
+ test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 20, 1, 1);
+ test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 21, 0, 0);
+ test(S("abcdefghij"), 10, 0, S(""), 0, 0, 0);
+ test(S("abcdefghij"), 10, 0, S(""), 0, 1, 0);
+ test(S("abcdefghij"), 10, 0, S(""), 1, 0, 0);
+ test(S("abcdefghij"), 10, 0, S("abcde"), 0, 0, 0);
+ test(S("abcdefghij"), 10, 0, S("abcde"), 0, 1, -1);
+ test(S("abcdefghij"), 10, 0, S("abcde"), 0, 2, -2);
+ test(S("abcdefghij"), 10, 0, S("abcde"), 0, 4, -4);
+ test(S("abcdefghij"), 10, 0, S("abcde"), 0, 5, -5);
+ test(S("abcdefghij"), 10, 0, S("abcde"), 0, 6, -5);
+ test(S("abcdefghij"), 10, 0, S("abcde"), 1, 0, 0);
+ test(S("abcdefghij"), 10, 0, S("abcde"), 1, 1, -1);
+ test(S("abcdefghij"), 10, 0, S("abcde"), 1, 2, -2);
+ test(S("abcdefghij"), 10, 0, S("abcde"), 1, 3, -3);
+ test(S("abcdefghij"), 10, 0, S("abcde"), 1, 4, -4);
+ test(S("abcdefghij"), 10, 0, S("abcde"), 1, 5, -4);
+ test(S("abcdefghij"), 10, 0, S("abcde"), 2, 0, 0);
+ test(S("abcdefghij"), 10, 0, S("abcde"), 2, 1, -1);
+ test(S("abcdefghij"), 10, 0, S("abcde"), 2, 2, -2);
+ test(S("abcdefghij"), 10, 0, S("abcde"), 2, 3, -3);
+ test(S("abcdefghij"), 10, 0, S("abcde"), 2, 4, -3);
+ test(S("abcdefghij"), 10, 0, S("abcde"), 4, 0, 0);
+ test(S("abcdefghij"), 10, 0, S("abcde"), 4, 1, -1);
+}
+
+template <class S>
+void test35()
+{
+ test(S("abcdefghij"), 10, 0, S("abcde"), 4, 2, -1);
+ test(S("abcdefghij"), 10, 0, S("abcde"), 5, 0, 0);
+ test(S("abcdefghij"), 10, 0, S("abcde"), 5, 1, 0);
+ test(S("abcdefghij"), 10, 0, S("abcde"), 6, 0, 0);
+ test(S("abcdefghij"), 10, 0, S("abcdefghij"), 0, 0, 0);
+ test(S("abcdefghij"), 10, 0, S("abcdefghij"), 0, 1, -1);
+ test(S("abcdefghij"), 10, 0, S("abcdefghij"), 0, 5, -5);
+ test(S("abcdefghij"), 10, 0, S("abcdefghij"), 0, 9, -9);
+ test(S("abcdefghij"), 10, 0, S("abcdefghij"), 0, 10, -10);
+ test(S("abcdefghij"), 10, 0, S("abcdefghij"), 0, 11, -10);
+ test(S("abcdefghij"), 10, 0, S("abcdefghij"), 1, 0, 0);
+ test(S("abcdefghij"), 10, 0, S("abcdefghij"), 1, 1, -1);
+ test(S("abcdefghij"), 10, 0, S("abcdefghij"), 1, 4, -4);
+ test(S("abcdefghij"), 10, 0, S("abcdefghij"), 1, 8, -8);
+ test(S("abcdefghij"), 10, 0, S("abcdefghij"), 1, 9, -9);
+ test(S("abcdefghij"), 10, 0, S("abcdefghij"), 1, 10, -9);
+ test(S("abcdefghij"), 10, 0, S("abcdefghij"), 5, 0, 0);
+ test(S("abcdefghij"), 10, 0, S("abcdefghij"), 5, 1, -1);
+ test(S("abcdefghij"), 10, 0, S("abcdefghij"), 5, 2, -2);
+ test(S("abcdefghij"), 10, 0, S("abcdefghij"), 5, 4, -4);
+ test(S("abcdefghij"), 10, 0, S("abcdefghij"), 5, 5, -5);
+ test(S("abcdefghij"), 10, 0, S("abcdefghij"), 5, 6, -5);
+ test(S("abcdefghij"), 10, 0, S("abcdefghij"), 9, 0, 0);
+ test(S("abcdefghij"), 10, 0, S("abcdefghij"), 9, 1, -1);
+ test(S("abcdefghij"), 10, 0, S("abcdefghij"), 9, 2, -1);
+ test(S("abcdefghij"), 10, 0, S("abcdefghij"), 10, 0, 0);
+ test(S("abcdefghij"), 10, 0, S("abcdefghij"), 10, 1, 0);
+ test(S("abcdefghij"), 10, 0, S("abcdefghij"), 11, 0, 0);
+ test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 0, 0, 0);
+ test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 0, 1, -1);
+ test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 0, 10, -10);
+ test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 0, 19, -19);
+ test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 0, 20, -20);
+ test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 0, 21, -20);
+ test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 1, 0, 0);
+ test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 1, 1, -1);
+ test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 1, 9, -9);
+ test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 1, 18, -18);
+ test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 1, 19, -19);
+ test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 1, 20, -19);
+ test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 10, 0, 0);
+ test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 10, 1, -1);
+ test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 10, 5, -5);
+ test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 10, 9, -9);
+ test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 10, 10, -10);
+ test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 10, 11, -10);
+ test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 19, 0, 0);
+ test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 19, 1, -1);
+ test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 19, 2, -1);
+ test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 20, 0, 0);
+ test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 20, 1, 0);
+ test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 21, 0, 0);
+ test(S("abcdefghij"), 10, 1, S(""), 0, 0, 0);
+ test(S("abcdefghij"), 10, 1, S(""), 0, 1, 0);
+ test(S("abcdefghij"), 10, 1, S(""), 1, 0, 0);
+ test(S("abcdefghij"), 10, 1, S("abcde"), 0, 0, 0);
+ test(S("abcdefghij"), 10, 1, S("abcde"), 0, 1, -1);
+ test(S("abcdefghij"), 10, 1, S("abcde"), 0, 2, -2);
+ test(S("abcdefghij"), 10, 1, S("abcde"), 0, 4, -4);
+ test(S("abcdefghij"), 10, 1, S("abcde"), 0, 5, -5);
+ test(S("abcdefghij"), 10, 1, S("abcde"), 0, 6, -5);
+ test(S("abcdefghij"), 10, 1, S("abcde"), 1, 0, 0);
+ test(S("abcdefghij"), 10, 1, S("abcde"), 1, 1, -1);
+ test(S("abcdefghij"), 10, 1, S("abcde"), 1, 2, -2);
+ test(S("abcdefghij"), 10, 1, S("abcde"), 1, 3, -3);
+ test(S("abcdefghij"), 10, 1, S("abcde"), 1, 4, -4);
+ test(S("abcdefghij"), 10, 1, S("abcde"), 1, 5, -4);
+ test(S("abcdefghij"), 10, 1, S("abcde"), 2, 0, 0);
+ test(S("abcdefghij"), 10, 1, S("abcde"), 2, 1, -1);
+ test(S("abcdefghij"), 10, 1, S("abcde"), 2, 2, -2);
+ test(S("abcdefghij"), 10, 1, S("abcde"), 2, 3, -3);
+ test(S("abcdefghij"), 10, 1, S("abcde"), 2, 4, -3);
+ test(S("abcdefghij"), 10, 1, S("abcde"), 4, 0, 0);
+ test(S("abcdefghij"), 10, 1, S("abcde"), 4, 1, -1);
+ test(S("abcdefghij"), 10, 1, S("abcde"), 4, 2, -1);
+ test(S("abcdefghij"), 10, 1, S("abcde"), 5, 0, 0);
+ test(S("abcdefghij"), 10, 1, S("abcde"), 5, 1, 0);
+ test(S("abcdefghij"), 10, 1, S("abcde"), 6, 0, 0);
+ test(S("abcdefghij"), 10, 1, S("abcdefghij"), 0, 0, 0);
+ test(S("abcdefghij"), 10, 1, S("abcdefghij"), 0, 1, -1);
+ test(S("abcdefghij"), 10, 1, S("abcdefghij"), 0, 5, -5);
+ test(S("abcdefghij"), 10, 1, S("abcdefghij"), 0, 9, -9);
+ test(S("abcdefghij"), 10, 1, S("abcdefghij"), 0, 10, -10);
+ test(S("abcdefghij"), 10, 1, S("abcdefghij"), 0, 11, -10);
+ test(S("abcdefghij"), 10, 1, S("abcdefghij"), 1, 0, 0);
+ test(S("abcdefghij"), 10, 1, S("abcdefghij"), 1, 1, -1);
+ test(S("abcdefghij"), 10, 1, S("abcdefghij"), 1, 4, -4);
+ test(S("abcdefghij"), 10, 1, S("abcdefghij"), 1, 8, -8);
+ test(S("abcdefghij"), 10, 1, S("abcdefghij"), 1, 9, -9);
+ test(S("abcdefghij"), 10, 1, S("abcdefghij"), 1, 10, -9);
+ test(S("abcdefghij"), 10, 1, S("abcdefghij"), 5, 0, 0);
+ test(S("abcdefghij"), 10, 1, S("abcdefghij"), 5, 1, -1);
+ test(S("abcdefghij"), 10, 1, S("abcdefghij"), 5, 2, -2);
+ test(S("abcdefghij"), 10, 1, S("abcdefghij"), 5, 4, -4);
+ test(S("abcdefghij"), 10, 1, S("abcdefghij"), 5, 5, -5);
+ test(S("abcdefghij"), 10, 1, S("abcdefghij"), 5, 6, -5);
+ test(S("abcdefghij"), 10, 1, S("abcdefghij"), 9, 0, 0);
+ test(S("abcdefghij"), 10, 1, S("abcdefghij"), 9, 1, -1);
+ test(S("abcdefghij"), 10, 1, S("abcdefghij"), 9, 2, -1);
+ test(S("abcdefghij"), 10, 1, S("abcdefghij"), 10, 0, 0);
+}
+
+template <class S>
+void test36()
+{
+ test(S("abcdefghij"), 10, 1, S("abcdefghij"), 10, 1, 0);
+ test(S("abcdefghij"), 10, 1, S("abcdefghij"), 11, 0, 0);
+ test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 0, 0, 0);
+ test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 0, 1, -1);
+ test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 0, 10, -10);
+ test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 0, 19, -19);
+ test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 0, 20, -20);
+ test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 0, 21, -20);
+ test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 1, 0, 0);
+ test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 1, 1, -1);
+ test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 1, 9, -9);
+ test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 1, 18, -18);
+ test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 1, 19, -19);
+ test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 1, 20, -19);
+ test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 10, 0, 0);
+ test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 10, 1, -1);
+ test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 10, 5, -5);
+ test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 10, 9, -9);
+ test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 10, 10, -10);
+ test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 10, 11, -10);
+ test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 19, 0, 0);
+ test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 19, 1, -1);
+ test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 19, 2, -1);
+ test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 20, 0, 0);
+ test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 20, 1, 0);
+ test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 21, 0, 0);
+ test(S("abcdefghij"), 11, 0, S(""), 0, 0, 0);
+ test(S("abcdefghij"), 11, 0, S(""), 0, 1, 0);
+ test(S("abcdefghij"), 11, 0, S(""), 1, 0, 0);
+ test(S("abcdefghij"), 11, 0, S("abcde"), 0, 0, 0);
+ test(S("abcdefghij"), 11, 0, S("abcde"), 0, 1, 0);
+ test(S("abcdefghij"), 11, 0, S("abcde"), 0, 2, 0);
+ test(S("abcdefghij"), 11, 0, S("abcde"), 0, 4, 0);
+ test(S("abcdefghij"), 11, 0, S("abcde"), 0, 5, 0);
+ test(S("abcdefghij"), 11, 0, S("abcde"), 0, 6, 0);
+ test(S("abcdefghij"), 11, 0, S("abcde"), 1, 0, 0);
+ test(S("abcdefghij"), 11, 0, S("abcde"), 1, 1, 0);
+ test(S("abcdefghij"), 11, 0, S("abcde"), 1, 2, 0);
+ test(S("abcdefghij"), 11, 0, S("abcde"), 1, 3, 0);
+ test(S("abcdefghij"), 11, 0, S("abcde"), 1, 4, 0);
+ test(S("abcdefghij"), 11, 0, S("abcde"), 1, 5, 0);
+ test(S("abcdefghij"), 11, 0, S("abcde"), 2, 0, 0);
+ test(S("abcdefghij"), 11, 0, S("abcde"), 2, 1, 0);
+ test(S("abcdefghij"), 11, 0, S("abcde"), 2, 2, 0);
+ test(S("abcdefghij"), 11, 0, S("abcde"), 2, 3, 0);
+ test(S("abcdefghij"), 11, 0, S("abcde"), 2, 4, 0);
+ test(S("abcdefghij"), 11, 0, S("abcde"), 4, 0, 0);
+ test(S("abcdefghij"), 11, 0, S("abcde"), 4, 1, 0);
+ test(S("abcdefghij"), 11, 0, S("abcde"), 4, 2, 0);
+ test(S("abcdefghij"), 11, 0, S("abcde"), 5, 0, 0);
+ test(S("abcdefghij"), 11, 0, S("abcde"), 5, 1, 0);
+ test(S("abcdefghij"), 11, 0, S("abcde"), 6, 0, 0);
+ test(S("abcdefghij"), 11, 0, S("abcdefghij"), 0, 0, 0);
+ test(S("abcdefghij"), 11, 0, S("abcdefghij"), 0, 1, 0);
+ test(S("abcdefghij"), 11, 0, S("abcdefghij"), 0, 5, 0);
+ test(S("abcdefghij"), 11, 0, S("abcdefghij"), 0, 9, 0);
+ test(S("abcdefghij"), 11, 0, S("abcdefghij"), 0, 10, 0);
+ test(S("abcdefghij"), 11, 0, S("abcdefghij"), 0, 11, 0);
+ test(S("abcdefghij"), 11, 0, S("abcdefghij"), 1, 0, 0);
+ test(S("abcdefghij"), 11, 0, S("abcdefghij"), 1, 1, 0);
+ test(S("abcdefghij"), 11, 0, S("abcdefghij"), 1, 4, 0);
+ test(S("abcdefghij"), 11, 0, S("abcdefghij"), 1, 8, 0);
+ test(S("abcdefghij"), 11, 0, S("abcdefghij"), 1, 9, 0);
+ test(S("abcdefghij"), 11, 0, S("abcdefghij"), 1, 10, 0);
+ test(S("abcdefghij"), 11, 0, S("abcdefghij"), 5, 0, 0);
+ test(S("abcdefghij"), 11, 0, S("abcdefghij"), 5, 1, 0);
+ test(S("abcdefghij"), 11, 0, S("abcdefghij"), 5, 2, 0);
+ test(S("abcdefghij"), 11, 0, S("abcdefghij"), 5, 4, 0);
+ test(S("abcdefghij"), 11, 0, S("abcdefghij"), 5, 5, 0);
+ test(S("abcdefghij"), 11, 0, S("abcdefghij"), 5, 6, 0);
+ test(S("abcdefghij"), 11, 0, S("abcdefghij"), 9, 0, 0);
+ test(S("abcdefghij"), 11, 0, S("abcdefghij"), 9, 1, 0);
+ test(S("abcdefghij"), 11, 0, S("abcdefghij"), 9, 2, 0);
+ test(S("abcdefghij"), 11, 0, S("abcdefghij"), 10, 0, 0);
+ test(S("abcdefghij"), 11, 0, S("abcdefghij"), 10, 1, 0);
+ test(S("abcdefghij"), 11, 0, S("abcdefghij"), 11, 0, 0);
+ test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 0, 0, 0);
+ test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 0, 1, 0);
+ test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 0, 10, 0);
+ test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 0, 19, 0);
+ test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 0, 20, 0);
+ test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 0, 21, 0);
+ test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 1, 0, 0);
+ test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 1, 1, 0);
+ test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 1, 9, 0);
+ test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 1, 18, 0);
+ test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 1, 19, 0);
+ test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 1, 20, 0);
+ test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 10, 0, 0);
+ test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 10, 1, 0);
+ test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 10, 5, 0);
+ test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 10, 9, 0);
+ test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 10, 10, 0);
+ test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 10, 11, 0);
+ test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 19, 0, 0);
+ test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 19, 1, 0);
+ test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 19, 2, 0);
+ test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 20, 0, 0);
+ test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 20, 1, 0);
+ test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 21, 0, 0);
+}
+
+template <class S>
+void test37()
+{
+ test(S("abcdefghijklmnopqrst"), 0, 0, S(""), 0, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 0, 0, S(""), 0, 1, 0);
+ test(S("abcdefghijklmnopqrst"), 0, 0, S(""), 1, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 0, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 0, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 0, 2, -2);
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 0, 4, -4);
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 0, 5, -5);
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 0, 6, -5);
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 1, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 1, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 1, 2, -2);
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 1, 3, -3);
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 1, 4, -4);
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 1, 5, -4);
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 2, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 2, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 2, 2, -2);
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 2, 3, -3);
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 2, 4, -3);
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 4, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 4, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 4, 2, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 5, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 5, 1, 0);
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 6, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 0, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 0, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 0, 5, -5);
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 0, 9, -9);
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 0, 10, -10);
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 0, 11, -10);
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 1, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 1, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 1, 4, -4);
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 1, 8, -8);
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 1, 9, -9);
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 1, 10, -9);
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 5, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 5, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 5, 2, -2);
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 5, 4, -4);
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 5, 5, -5);
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 5, 6, -5);
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 9, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 9, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 9, 2, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 10, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 10, 1, 0);
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 11, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 0, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 0, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 0, 10, -10);
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 0, 19, -19);
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 0, 20, -20);
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 0, 21, -20);
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 1, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 1, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 1, 9, -9);
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 1, 18, -18);
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 1, 19, -19);
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 1, 20, -19);
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 10, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 10, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 10, 5, -5);
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 10, 9, -9);
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 10, 10, -10);
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 10, 11, -10);
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 19, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 19, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 19, 2, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 20, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 20, 1, 0);
+ test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 21, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 0, 1, S(""), 0, 0, 1);
+ test(S("abcdefghijklmnopqrst"), 0, 1, S(""), 0, 1, 1);
+ test(S("abcdefghijklmnopqrst"), 0, 1, S(""), 1, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 0, 0, 1);
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 0, 1, 0);
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 0, 2, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 0, 4, -3);
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 0, 5, -4);
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 0, 6, -4);
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 1, 0, 1);
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 1, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 1, 2, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 1, 3, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 1, 4, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 1, 5, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 2, 0, 1);
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 2, 1, -2);
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 2, 2, -2);
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 2, 3, -2);
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 2, 4, -2);
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 4, 0, 1);
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 4, 1, -4);
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 4, 2, -4);
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 5, 0, 1);
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 5, 1, 1);
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 6, 0, 0);
+}
+
+template <class S>
+void test38()
+{
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 0, 0, 1);
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 0, 1, 0);
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 0, 5, -4);
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 0, 9, -8);
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 0, 10, -9);
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 0, 11, -9);
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 1, 0, 1);
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 1, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 1, 4, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 1, 8, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 1, 9, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 1, 10, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 5, 0, 1);
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 5, 1, -5);
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 5, 2, -5);
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 5, 4, -5);
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 5, 5, -5);
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 5, 6, -5);
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 9, 0, 1);
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 9, 1, -9);
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 9, 2, -9);
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 10, 0, 1);
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 10, 1, 1);
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 11, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 0, 0, 1);
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 0, 1, 0);
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 0, 10, -9);
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 0, 19, -18);
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 0, 20, -19);
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 0, 21, -19);
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 1, 0, 1);
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 1, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 1, 9, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 1, 18, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 1, 19, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 1, 20, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 10, 0, 1);
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 10, 1, -10);
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 10, 5, -10);
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 10, 9, -10);
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 10, 10, -10);
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 10, 11, -10);
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 19, 0, 1);
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 19, 1, -19);
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 19, 2, -19);
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 20, 0, 1);
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 20, 1, 1);
+ test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 21, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 0, 10, S(""), 0, 0, 10);
+ test(S("abcdefghijklmnopqrst"), 0, 10, S(""), 0, 1, 10);
+ test(S("abcdefghijklmnopqrst"), 0, 10, S(""), 1, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 0, 0, 10);
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 0, 1, 9);
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 0, 2, 8);
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 0, 4, 6);
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 0, 5, 5);
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 0, 6, 5);
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 1, 0, 10);
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 1, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 1, 2, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 1, 3, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 1, 4, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 1, 5, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 2, 0, 10);
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 2, 1, -2);
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 2, 2, -2);
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 2, 3, -2);
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 2, 4, -2);
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 4, 0, 10);
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 4, 1, -4);
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 4, 2, -4);
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 5, 0, 10);
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 5, 1, 10);
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 6, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 0, 0, 10);
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 0, 1, 9);
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 0, 5, 5);
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 0, 9, 1);
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 0, 10, 0);
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 0, 11, 0);
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 1, 0, 10);
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 1, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 1, 4, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 1, 8, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 1, 9, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 1, 10, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 5, 0, 10);
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 5, 1, -5);
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 5, 2, -5);
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 5, 4, -5);
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 5, 5, -5);
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 5, 6, -5);
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 9, 0, 10);
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 9, 1, -9);
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 9, 2, -9);
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 10, 0, 10);
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 10, 1, 10);
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 11, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 0, 0, 10);
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 0, 1, 9);
+}
+
+template <class S>
+void test39()
+{
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 0, 10, 0);
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 0, 19, -9);
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 0, 20, -10);
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 0, 21, -10);
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 1, 0, 10);
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 1, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 1, 9, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 1, 18, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 1, 19, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 1, 20, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 10, 0, 10);
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 10, 1, -10);
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 10, 5, -10);
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 10, 9, -10);
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 10, 10, -10);
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 10, 11, -10);
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 19, 0, 10);
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 19, 1, -19);
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 19, 2, -19);
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 20, 0, 10);
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 20, 1, 10);
+ test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 21, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 0, 19, S(""), 0, 0, 19);
+ test(S("abcdefghijklmnopqrst"), 0, 19, S(""), 0, 1, 19);
+ test(S("abcdefghijklmnopqrst"), 0, 19, S(""), 1, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 0, 0, 19);
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 0, 1, 18);
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 0, 2, 17);
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 0, 4, 15);
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 0, 5, 14);
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 0, 6, 14);
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 1, 0, 19);
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 1, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 1, 2, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 1, 3, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 1, 4, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 1, 5, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 2, 0, 19);
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 2, 1, -2);
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 2, 2, -2);
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 2, 3, -2);
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 2, 4, -2);
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 4, 0, 19);
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 4, 1, -4);
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 4, 2, -4);
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 5, 0, 19);
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 5, 1, 19);
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 6, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 0, 0, 19);
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 0, 1, 18);
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 0, 5, 14);
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 0, 9, 10);
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 0, 10, 9);
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 0, 11, 9);
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 1, 0, 19);
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 1, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 1, 4, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 1, 8, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 1, 9, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 1, 10, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 5, 0, 19);
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 5, 1, -5);
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 5, 2, -5);
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 5, 4, -5);
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 5, 5, -5);
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 5, 6, -5);
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 9, 0, 19);
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 9, 1, -9);
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 9, 2, -9);
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 10, 0, 19);
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 10, 1, 19);
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 11, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 0, 0, 19);
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 0, 1, 18);
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 0, 10, 9);
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 0, 19, 0);
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 0, 20, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 0, 21, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 1, 0, 19);
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 1, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 1, 9, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 1, 18, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 1, 19, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 1, 20, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 10, 0, 19);
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 10, 1, -10);
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 10, 5, -10);
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 10, 9, -10);
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 10, 10, -10);
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 10, 11, -10);
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 19, 0, 19);
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 19, 1, -19);
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 19, 2, -19);
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 20, 0, 19);
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 20, 1, 19);
+ test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 21, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 0, 20, S(""), 0, 0, 20);
+ test(S("abcdefghijklmnopqrst"), 0, 20, S(""), 0, 1, 20);
+ test(S("abcdefghijklmnopqrst"), 0, 20, S(""), 1, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 0, 0, 20);
+}
+
+template <class S>
+void test40()
+{
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 0, 1, 19);
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 0, 2, 18);
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 0, 4, 16);
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 0, 5, 15);
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 0, 6, 15);
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 1, 0, 20);
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 1, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 1, 2, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 1, 3, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 1, 4, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 1, 5, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 2, 0, 20);
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 2, 1, -2);
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 2, 2, -2);
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 2, 3, -2);
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 2, 4, -2);
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 4, 0, 20);
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 4, 1, -4);
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 4, 2, -4);
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 5, 0, 20);
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 5, 1, 20);
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 6, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 0, 0, 20);
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 0, 1, 19);
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 0, 5, 15);
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 0, 9, 11);
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 0, 10, 10);
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 0, 11, 10);
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 1, 0, 20);
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 1, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 1, 4, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 1, 8, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 1, 9, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 1, 10, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 5, 0, 20);
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 5, 1, -5);
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 5, 2, -5);
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 5, 4, -5);
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 5, 5, -5);
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 5, 6, -5);
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 9, 0, 20);
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 9, 1, -9);
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 9, 2, -9);
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 10, 0, 20);
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 10, 1, 20);
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 11, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 0, 0, 20);
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 0, 1, 19);
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 0, 10, 10);
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 0, 19, 1);
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 0, 20, 0);
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 0, 21, 0);
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 1, 0, 20);
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 1, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 1, 9, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 1, 18, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 1, 19, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 1, 20, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 10, 0, 20);
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 10, 1, -10);
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 10, 5, -10);
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 10, 9, -10);
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 10, 10, -10);
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 10, 11, -10);
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 19, 0, 20);
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 19, 1, -19);
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 19, 2, -19);
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 20, 0, 20);
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 20, 1, 20);
+ test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 21, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 0, 21, S(""), 0, 0, 20);
+ test(S("abcdefghijklmnopqrst"), 0, 21, S(""), 0, 1, 20);
+ test(S("abcdefghijklmnopqrst"), 0, 21, S(""), 1, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 0, 0, 20);
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 0, 1, 19);
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 0, 2, 18);
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 0, 4, 16);
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 0, 5, 15);
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 0, 6, 15);
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 1, 0, 20);
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 1, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 1, 2, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 1, 3, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 1, 4, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 1, 5, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 2, 0, 20);
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 2, 1, -2);
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 2, 2, -2);
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 2, 3, -2);
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 2, 4, -2);
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 4, 0, 20);
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 4, 1, -4);
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 4, 2, -4);
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 5, 0, 20);
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 5, 1, 20);
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 6, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 0, 0, 20);
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 0, 1, 19);
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 0, 5, 15);
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 0, 9, 11);
+}
+
+template <class S>
+void test41()
+{
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 0, 10, 10);
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 0, 11, 10);
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 1, 0, 20);
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 1, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 1, 4, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 1, 8, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 1, 9, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 1, 10, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 5, 0, 20);
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 5, 1, -5);
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 5, 2, -5);
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 5, 4, -5);
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 5, 5, -5);
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 5, 6, -5);
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 9, 0, 20);
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 9, 1, -9);
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 9, 2, -9);
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 10, 0, 20);
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 10, 1, 20);
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 11, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 0, 0, 20);
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 0, 1, 19);
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 0, 10, 10);
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 0, 19, 1);
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 0, 20, 0);
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 0, 21, 0);
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 1, 0, 20);
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 1, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 1, 9, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 1, 18, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 1, 19, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 1, 20, -1);
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 10, 0, 20);
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 10, 1, -10);
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 10, 5, -10);
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 10, 9, -10);
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 10, 10, -10);
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 10, 11, -10);
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 19, 0, 20);
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 19, 1, -19);
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 19, 2, -19);
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 20, 0, 20);
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 20, 1, 20);
+ test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 21, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 1, 0, S(""), 0, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 1, 0, S(""), 0, 1, 0);
+ test(S("abcdefghijklmnopqrst"), 1, 0, S(""), 1, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 0, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 0, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 0, 2, -2);
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 0, 4, -4);
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 0, 5, -5);
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 0, 6, -5);
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 1, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 1, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 1, 2, -2);
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 1, 3, -3);
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 1, 4, -4);
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 1, 5, -4);
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 2, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 2, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 2, 2, -2);
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 2, 3, -3);
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 2, 4, -3);
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 4, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 4, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 4, 2, -1);
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 5, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 5, 1, 0);
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 6, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 0, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 0, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 0, 5, -5);
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 0, 9, -9);
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 0, 10, -10);
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 0, 11, -10);
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 1, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 1, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 1, 4, -4);
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 1, 8, -8);
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 1, 9, -9);
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 1, 10, -9);
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 5, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 5, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 5, 2, -2);
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 5, 4, -4);
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 5, 5, -5);
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 5, 6, -5);
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 9, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 9, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 9, 2, -1);
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 10, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 10, 1, 0);
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 11, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 0, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 0, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 0, 10, -10);
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 0, 19, -19);
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 0, 20, -20);
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 0, 21, -20);
+}
+
+template <class S>
+void test42()
+{
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 1, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 1, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 1, 9, -9);
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 1, 18, -18);
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 1, 19, -19);
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 1, 20, -19);
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 10, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 10, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 10, 5, -5);
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 10, 9, -9);
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 10, 10, -10);
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 10, 11, -10);
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 19, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 19, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 19, 2, -1);
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 20, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 20, 1, 0);
+ test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 21, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 1, 1, S(""), 0, 0, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 1, S(""), 0, 1, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 1, S(""), 1, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 0, 0, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 0, 1, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 0, 2, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 0, 4, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 0, 5, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 0, 6, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 1, 0, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 1, 1, 0);
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 1, 2, -1);
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 1, 3, -2);
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 1, 4, -3);
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 1, 5, -3);
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 2, 0, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 2, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 2, 2, -1);
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 2, 3, -1);
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 2, 4, -1);
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 4, 0, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 4, 1, -3);
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 4, 2, -3);
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 5, 0, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 5, 1, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 6, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 0, 0, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 0, 1, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 0, 5, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 0, 9, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 0, 10, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 0, 11, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 1, 0, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 1, 1, 0);
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 1, 4, -3);
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 1, 8, -7);
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 1, 9, -8);
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 1, 10, -8);
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 5, 0, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 5, 1, -4);
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 5, 2, -4);
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 5, 4, -4);
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 5, 5, -4);
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 5, 6, -4);
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 9, 0, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 9, 1, -8);
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 9, 2, -8);
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 10, 0, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 10, 1, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 11, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 0, 0, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 0, 1, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 0, 10, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 0, 19, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 0, 20, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 0, 21, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 1, 0, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 1, 1, 0);
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 1, 9, -8);
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 1, 18, -17);
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 1, 19, -18);
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 1, 20, -18);
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 10, 0, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 10, 1, -9);
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 10, 5, -9);
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 10, 9, -9);
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 10, 10, -9);
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 10, 11, -9);
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 19, 0, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 19, 1, -18);
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 19, 2, -18);
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 20, 0, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 20, 1, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 21, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 1, 9, S(""), 0, 0, 9);
+ test(S("abcdefghijklmnopqrst"), 1, 9, S(""), 0, 1, 9);
+ test(S("abcdefghijklmnopqrst"), 1, 9, S(""), 1, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 0, 0, 9);
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 0, 1, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 0, 2, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 0, 4, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 0, 5, 1);
+}
+
+template <class S>
+void test43()
+{
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 0, 6, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 1, 0, 9);
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 1, 1, 8);
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 1, 2, 7);
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 1, 3, 6);
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 1, 4, 5);
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 1, 5, 5);
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 2, 0, 9);
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 2, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 2, 2, -1);
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 2, 3, -1);
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 2, 4, -1);
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 4, 0, 9);
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 4, 1, -3);
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 4, 2, -3);
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 5, 0, 9);
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 5, 1, 9);
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 6, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 0, 0, 9);
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 0, 1, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 0, 5, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 0, 9, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 0, 10, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 0, 11, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 1, 0, 9);
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 1, 1, 8);
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 1, 4, 5);
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 1, 8, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 1, 9, 0);
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 1, 10, 0);
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 5, 0, 9);
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 5, 1, -4);
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 5, 2, -4);
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 5, 4, -4);
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 5, 5, -4);
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 5, 6, -4);
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 9, 0, 9);
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 9, 1, -8);
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 9, 2, -8);
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 10, 0, 9);
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 10, 1, 9);
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 11, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 0, 0, 9);
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 0, 1, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 0, 10, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 0, 19, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 0, 20, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 0, 21, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 1, 0, 9);
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 1, 1, 8);
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 1, 9, 0);
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 1, 18, -9);
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 1, 19, -10);
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 1, 20, -10);
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 10, 0, 9);
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 10, 1, -9);
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 10, 5, -9);
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 10, 9, -9);
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 10, 10, -9);
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 10, 11, -9);
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 19, 0, 9);
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 19, 1, -18);
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 19, 2, -18);
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 20, 0, 9);
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 20, 1, 9);
+ test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 21, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 1, 18, S(""), 0, 0, 18);
+ test(S("abcdefghijklmnopqrst"), 1, 18, S(""), 0, 1, 18);
+ test(S("abcdefghijklmnopqrst"), 1, 18, S(""), 1, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 0, 0, 18);
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 0, 1, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 0, 2, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 0, 4, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 0, 5, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 0, 6, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 1, 0, 18);
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 1, 1, 17);
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 1, 2, 16);
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 1, 3, 15);
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 1, 4, 14);
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 1, 5, 14);
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 2, 0, 18);
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 2, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 2, 2, -1);
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 2, 3, -1);
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 2, 4, -1);
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 4, 0, 18);
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 4, 1, -3);
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 4, 2, -3);
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 5, 0, 18);
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 5, 1, 18);
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 6, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 0, 0, 18);
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 0, 1, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 0, 5, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 0, 9, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 0, 10, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 0, 11, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 1, 0, 18);
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 1, 1, 17);
+}
+
+template <class S>
+void test44()
+{
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 1, 4, 14);
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 1, 8, 10);
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 1, 9, 9);
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 1, 10, 9);
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 5, 0, 18);
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 5, 1, -4);
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 5, 2, -4);
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 5, 4, -4);
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 5, 5, -4);
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 5, 6, -4);
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 9, 0, 18);
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 9, 1, -8);
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 9, 2, -8);
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 10, 0, 18);
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 10, 1, 18);
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 11, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 0, 0, 18);
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 0, 1, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 0, 10, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 0, 19, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 0, 20, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 0, 21, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 1, 0, 18);
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 1, 1, 17);
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 1, 9, 9);
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 1, 18, 0);
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 1, 19, -1);
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 1, 20, -1);
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 10, 0, 18);
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 10, 1, -9);
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 10, 5, -9);
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 10, 9, -9);
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 10, 10, -9);
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 10, 11, -9);
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 19, 0, 18);
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 19, 1, -18);
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 19, 2, -18);
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 20, 0, 18);
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 20, 1, 18);
+ test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 21, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 1, 19, S(""), 0, 0, 19);
+ test(S("abcdefghijklmnopqrst"), 1, 19, S(""), 0, 1, 19);
+ test(S("abcdefghijklmnopqrst"), 1, 19, S(""), 1, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 0, 0, 19);
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 0, 1, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 0, 2, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 0, 4, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 0, 5, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 0, 6, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 1, 0, 19);
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 1, 1, 18);
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 1, 2, 17);
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 1, 3, 16);
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 1, 4, 15);
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 1, 5, 15);
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 2, 0, 19);
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 2, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 2, 2, -1);
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 2, 3, -1);
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 2, 4, -1);
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 4, 0, 19);
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 4, 1, -3);
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 4, 2, -3);
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 5, 0, 19);
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 5, 1, 19);
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 6, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 0, 0, 19);
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 0, 1, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 0, 5, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 0, 9, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 0, 10, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 0, 11, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 1, 0, 19);
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 1, 1, 18);
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 1, 4, 15);
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 1, 8, 11);
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 1, 9, 10);
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 1, 10, 10);
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 5, 0, 19);
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 5, 1, -4);
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 5, 2, -4);
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 5, 4, -4);
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 5, 5, -4);
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 5, 6, -4);
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 9, 0, 19);
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 9, 1, -8);
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 9, 2, -8);
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 10, 0, 19);
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 10, 1, 19);
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 11, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 0, 0, 19);
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 0, 1, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 0, 10, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 0, 19, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 0, 20, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 0, 21, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 1, 0, 19);
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 1, 1, 18);
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 1, 9, 10);
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 1, 18, 1);
+}
+
+template <class S>
+void test45()
+{
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 1, 19, 0);
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 1, 20, 0);
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 10, 0, 19);
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 10, 1, -9);
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 10, 5, -9);
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 10, 9, -9);
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 10, 10, -9);
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 10, 11, -9);
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 19, 0, 19);
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 19, 1, -18);
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 19, 2, -18);
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 20, 0, 19);
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 20, 1, 19);
+ test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 21, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 1, 20, S(""), 0, 0, 19);
+ test(S("abcdefghijklmnopqrst"), 1, 20, S(""), 0, 1, 19);
+ test(S("abcdefghijklmnopqrst"), 1, 20, S(""), 1, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 0, 0, 19);
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 0, 1, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 0, 2, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 0, 4, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 0, 5, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 0, 6, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 1, 0, 19);
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 1, 1, 18);
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 1, 2, 17);
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 1, 3, 16);
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 1, 4, 15);
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 1, 5, 15);
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 2, 0, 19);
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 2, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 2, 2, -1);
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 2, 3, -1);
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 2, 4, -1);
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 4, 0, 19);
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 4, 1, -3);
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 4, 2, -3);
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 5, 0, 19);
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 5, 1, 19);
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 6, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 0, 0, 19);
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 0, 1, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 0, 5, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 0, 9, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 0, 10, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 0, 11, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 1, 0, 19);
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 1, 1, 18);
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 1, 4, 15);
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 1, 8, 11);
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 1, 9, 10);
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 1, 10, 10);
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 5, 0, 19);
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 5, 1, -4);
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 5, 2, -4);
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 5, 4, -4);
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 5, 5, -4);
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 5, 6, -4);
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 9, 0, 19);
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 9, 1, -8);
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 9, 2, -8);
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 10, 0, 19);
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 10, 1, 19);
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 11, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 0, 0, 19);
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 0, 1, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 0, 10, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 0, 19, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 0, 20, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 0, 21, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 1, 0, 19);
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 1, 1, 18);
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 1, 9, 10);
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 1, 18, 1);
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 1, 19, 0);
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 1, 20, 0);
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 10, 0, 19);
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 10, 1, -9);
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 10, 5, -9);
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 10, 9, -9);
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 10, 10, -9);
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 10, 11, -9);
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 19, 0, 19);
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 19, 1, -18);
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 19, 2, -18);
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 20, 0, 19);
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 20, 1, 19);
+ test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 21, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 10, 0, S(""), 0, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 10, 0, S(""), 0, 1, 0);
+ test(S("abcdefghijklmnopqrst"), 10, 0, S(""), 1, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 0, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 0, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 0, 2, -2);
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 0, 4, -4);
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 0, 5, -5);
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 0, 6, -5);
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 1, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 1, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 1, 2, -2);
+}
+
+template <class S>
+void test46()
+{
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 1, 3, -3);
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 1, 4, -4);
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 1, 5, -4);
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 2, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 2, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 2, 2, -2);
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 2, 3, -3);
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 2, 4, -3);
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 4, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 4, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 4, 2, -1);
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 5, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 5, 1, 0);
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 6, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 0, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 0, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 0, 5, -5);
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 0, 9, -9);
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 0, 10, -10);
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 0, 11, -10);
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 1, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 1, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 1, 4, -4);
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 1, 8, -8);
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 1, 9, -9);
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 1, 10, -9);
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 5, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 5, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 5, 2, -2);
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 5, 4, -4);
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 5, 5, -5);
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 5, 6, -5);
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 9, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 9, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 9, 2, -1);
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 10, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 10, 1, 0);
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 11, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 0, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 0, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 0, 10, -10);
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 0, 19, -19);
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 0, 20, -20);
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 0, 21, -20);
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 1, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 1, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 1, 9, -9);
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 1, 18, -18);
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 1, 19, -19);
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 1, 20, -19);
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 10, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 10, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 10, 5, -5);
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 10, 9, -9);
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 10, 10, -10);
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 10, 11, -10);
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 19, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 19, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 19, 2, -1);
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 20, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 20, 1, 0);
+ test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 21, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 10, 1, S(""), 0, 0, 1);
+ test(S("abcdefghijklmnopqrst"), 10, 1, S(""), 0, 1, 1);
+ test(S("abcdefghijklmnopqrst"), 10, 1, S(""), 1, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 0, 0, 1);
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 0, 1, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 0, 2, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 0, 4, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 0, 5, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 0, 6, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 1, 0, 1);
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 1, 1, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 1, 2, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 1, 3, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 1, 4, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 1, 5, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 2, 0, 1);
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 2, 1, 8);
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 2, 2, 8);
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 2, 3, 8);
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 2, 4, 8);
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 4, 0, 1);
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 4, 1, 6);
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 4, 2, 6);
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 5, 0, 1);
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 5, 1, 1);
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 6, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 0, 0, 1);
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 0, 1, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 0, 5, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 0, 9, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 0, 10, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 0, 11, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 1, 0, 1);
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 1, 1, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 1, 4, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 1, 8, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 1, 9, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 1, 10, 9);
+}
+
+template <class S>
+void test47()
+{
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 5, 0, 1);
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 5, 1, 5);
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 5, 2, 5);
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 5, 4, 5);
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 5, 5, 5);
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 5, 6, 5);
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 9, 0, 1);
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 9, 1, 1);
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 9, 2, 1);
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 10, 0, 1);
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 10, 1, 1);
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 11, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 0, 0, 1);
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 0, 1, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 0, 10, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 0, 19, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 0, 20, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 0, 21, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 1, 0, 1);
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 1, 1, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 1, 9, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 1, 18, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 1, 19, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 1, 20, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 10, 0, 1);
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 10, 1, 0);
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 10, 5, -4);
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 10, 9, -8);
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 10, 10, -9);
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 10, 11, -9);
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 19, 0, 1);
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 19, 1, -9);
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 19, 2, -9);
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 20, 0, 1);
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 20, 1, 1);
+ test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 21, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 10, 5, S(""), 0, 0, 5);
+ test(S("abcdefghijklmnopqrst"), 10, 5, S(""), 0, 1, 5);
+ test(S("abcdefghijklmnopqrst"), 10, 5, S(""), 1, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 0, 0, 5);
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 0, 1, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 0, 2, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 0, 4, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 0, 5, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 0, 6, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 1, 0, 5);
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 1, 1, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 1, 2, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 1, 3, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 1, 4, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 1, 5, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 2, 0, 5);
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 2, 1, 8);
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 2, 2, 8);
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 2, 3, 8);
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 2, 4, 8);
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 4, 0, 5);
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 4, 1, 6);
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 4, 2, 6);
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 5, 0, 5);
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 5, 1, 5);
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 6, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 0, 0, 5);
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 0, 1, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 0, 5, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 0, 9, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 0, 10, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 0, 11, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 1, 0, 5);
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 1, 1, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 1, 4, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 1, 8, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 1, 9, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 1, 10, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 5, 0, 5);
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 5, 1, 5);
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 5, 2, 5);
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 5, 4, 5);
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 5, 5, 5);
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 5, 6, 5);
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 9, 0, 5);
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 9, 1, 1);
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 9, 2, 1);
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 10, 0, 5);
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 10, 1, 5);
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 11, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 0, 0, 5);
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 0, 1, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 0, 10, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 0, 19, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 0, 20, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 0, 21, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 1, 0, 5);
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 1, 1, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 1, 9, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 1, 18, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 1, 19, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 1, 20, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 10, 0, 5);
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 10, 1, 4);
+}
+
+template <class S>
+void test48()
+{
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 10, 5, 0);
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 10, 9, -4);
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 10, 10, -5);
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 10, 11, -5);
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 19, 0, 5);
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 19, 1, -9);
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 19, 2, -9);
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 20, 0, 5);
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 20, 1, 5);
+ test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 21, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 10, 9, S(""), 0, 0, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 9, S(""), 0, 1, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 9, S(""), 1, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 0, 0, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 0, 1, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 0, 2, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 0, 4, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 0, 5, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 0, 6, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 1, 0, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 1, 1, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 1, 2, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 1, 3, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 1, 4, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 1, 5, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 2, 0, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 2, 1, 8);
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 2, 2, 8);
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 2, 3, 8);
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 2, 4, 8);
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 4, 0, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 4, 1, 6);
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 4, 2, 6);
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 5, 0, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 5, 1, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 6, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 0, 0, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 0, 1, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 0, 5, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 0, 9, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 0, 10, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 0, 11, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 1, 0, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 1, 1, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 1, 4, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 1, 8, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 1, 9, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 1, 10, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 5, 0, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 5, 1, 5);
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 5, 2, 5);
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 5, 4, 5);
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 5, 5, 5);
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 5, 6, 5);
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 9, 0, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 9, 1, 1);
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 9, 2, 1);
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 10, 0, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 10, 1, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 11, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 0, 0, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 0, 1, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 0, 10, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 0, 19, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 0, 20, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 0, 21, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 1, 0, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 1, 1, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 1, 9, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 1, 18, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 1, 19, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 1, 20, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 10, 0, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 10, 1, 8);
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 10, 5, 4);
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 10, 9, 0);
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 10, 10, -1);
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 10, 11, -1);
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 19, 0, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 19, 1, -9);
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 19, 2, -9);
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 20, 0, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 20, 1, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 21, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 10, 10, S(""), 0, 0, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 10, S(""), 0, 1, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 10, S(""), 1, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 0, 0, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 0, 1, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 0, 2, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 0, 4, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 0, 5, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 0, 6, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 1, 0, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 1, 1, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 1, 2, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 1, 3, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 1, 4, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 1, 5, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 2, 0, 10);
+}
+
+template <class S>
+void test49()
+{
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 2, 1, 8);
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 2, 2, 8);
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 2, 3, 8);
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 2, 4, 8);
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 4, 0, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 4, 1, 6);
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 4, 2, 6);
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 5, 0, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 5, 1, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 6, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 0, 0, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 0, 1, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 0, 5, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 0, 9, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 0, 10, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 0, 11, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 1, 0, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 1, 1, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 1, 4, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 1, 8, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 1, 9, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 1, 10, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 5, 0, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 5, 1, 5);
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 5, 2, 5);
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 5, 4, 5);
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 5, 5, 5);
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 5, 6, 5);
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 9, 0, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 9, 1, 1);
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 9, 2, 1);
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 10, 0, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 10, 1, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 11, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 0, 0, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 0, 1, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 0, 10, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 0, 19, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 0, 20, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 0, 21, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 1, 0, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 1, 1, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 1, 9, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 1, 18, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 1, 19, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 1, 20, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 10, 0, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 10, 1, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 10, 5, 5);
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 10, 9, 1);
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 10, 10, 0);
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 10, 11, 0);
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 19, 0, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 19, 1, -9);
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 19, 2, -9);
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 20, 0, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 20, 1, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 21, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 10, 11, S(""), 0, 0, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 11, S(""), 0, 1, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 11, S(""), 1, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 0, 0, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 0, 1, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 0, 2, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 0, 4, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 0, 5, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 0, 6, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 1, 0, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 1, 1, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 1, 2, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 1, 3, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 1, 4, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 1, 5, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 2, 0, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 2, 1, 8);
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 2, 2, 8);
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 2, 3, 8);
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 2, 4, 8);
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 4, 0, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 4, 1, 6);
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 4, 2, 6);
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 5, 0, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 5, 1, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 6, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 0, 0, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 0, 1, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 0, 5, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 0, 9, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 0, 10, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 0, 11, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 1, 0, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 1, 1, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 1, 4, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 1, 8, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 1, 9, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 1, 10, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 5, 0, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 5, 1, 5);
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 5, 2, 5);
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 5, 4, 5);
+}
+
+template <class S>
+void test50()
+{
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 5, 5, 5);
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 5, 6, 5);
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 9, 0, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 9, 1, 1);
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 9, 2, 1);
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 10, 0, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 10, 1, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 11, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 0, 0, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 0, 1, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 0, 10, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 0, 19, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 0, 20, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 0, 21, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 1, 0, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 1, 1, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 1, 9, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 1, 18, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 1, 19, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 1, 20, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 10, 0, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 10, 1, 9);
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 10, 5, 5);
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 10, 9, 1);
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 10, 10, 0);
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 10, 11, 0);
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 19, 0, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 19, 1, -9);
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 19, 2, -9);
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 20, 0, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 20, 1, 10);
+ test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 21, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 19, 0, S(""), 0, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 19, 0, S(""), 0, 1, 0);
+ test(S("abcdefghijklmnopqrst"), 19, 0, S(""), 1, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 0, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 0, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 0, 2, -2);
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 0, 4, -4);
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 0, 5, -5);
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 0, 6, -5);
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 1, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 1, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 1, 2, -2);
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 1, 3, -3);
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 1, 4, -4);
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 1, 5, -4);
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 2, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 2, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 2, 2, -2);
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 2, 3, -3);
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 2, 4, -3);
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 4, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 4, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 4, 2, -1);
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 5, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 5, 1, 0);
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 6, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 0, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 0, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 0, 5, -5);
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 0, 9, -9);
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 0, 10, -10);
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 0, 11, -10);
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 1, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 1, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 1, 4, -4);
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 1, 8, -8);
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 1, 9, -9);
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 1, 10, -9);
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 5, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 5, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 5, 2, -2);
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 5, 4, -4);
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 5, 5, -5);
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 5, 6, -5);
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 9, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 9, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 9, 2, -1);
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 10, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 10, 1, 0);
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 11, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 0, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 0, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 0, 10, -10);
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 0, 19, -19);
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 0, 20, -20);
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 0, 21, -20);
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 1, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 1, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 1, 9, -9);
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 1, 18, -18);
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 1, 19, -19);
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 1, 20, -19);
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 10, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 10, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 10, 5, -5);
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 10, 9, -9);
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 10, 10, -10);
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 10, 11, -10);
+}
+
+template <class S>
+void test51()
+{
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 19, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 19, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 19, 2, -1);
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 20, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 20, 1, 0);
+ test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 21, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 19, 1, S(""), 0, 0, 1);
+ test(S("abcdefghijklmnopqrst"), 19, 1, S(""), 0, 1, 1);
+ test(S("abcdefghijklmnopqrst"), 19, 1, S(""), 1, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 0, 0, 1);
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 0, 1, 19);
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 0, 2, 19);
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 0, 4, 19);
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 0, 5, 19);
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 0, 6, 19);
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 1, 0, 1);
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 1, 1, 18);
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 1, 2, 18);
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 1, 3, 18);
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 1, 4, 18);
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 1, 5, 18);
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 2, 0, 1);
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 2, 1, 17);
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 2, 2, 17);
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 2, 3, 17);
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 2, 4, 17);
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 4, 0, 1);
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 4, 1, 15);
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 4, 2, 15);
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 5, 0, 1);
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 5, 1, 1);
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 6, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 0, 0, 1);
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 0, 1, 19);
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 0, 5, 19);
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 0, 9, 19);
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 0, 10, 19);
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 0, 11, 19);
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 1, 0, 1);
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 1, 1, 18);
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 1, 4, 18);
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 1, 8, 18);
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 1, 9, 18);
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 1, 10, 18);
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 5, 0, 1);
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 5, 1, 14);
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 5, 2, 14);
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 5, 4, 14);
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 5, 5, 14);
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 5, 6, 14);
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 9, 0, 1);
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 9, 1, 10);
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 9, 2, 10);
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 10, 0, 1);
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 10, 1, 1);
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 11, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 0, 0, 1);
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 0, 1, 19);
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 0, 10, 19);
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 0, 19, 19);
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 0, 20, 19);
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 0, 21, 19);
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 1, 0, 1);
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 1, 1, 18);
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 1, 9, 18);
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 1, 18, 18);
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 1, 19, 18);
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 1, 20, 18);
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 10, 0, 1);
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 10, 1, 9);
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 10, 5, 9);
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 10, 9, 9);
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 10, 10, 9);
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 10, 11, 9);
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 19, 0, 1);
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 19, 1, 0);
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 19, 2, 0);
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 20, 0, 1);
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 20, 1, 1);
+ test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 21, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 19, 2, S(""), 0, 0, 1);
+ test(S("abcdefghijklmnopqrst"), 19, 2, S(""), 0, 1, 1);
+ test(S("abcdefghijklmnopqrst"), 19, 2, S(""), 1, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 0, 0, 1);
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 0, 1, 19);
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 0, 2, 19);
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 0, 4, 19);
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 0, 5, 19);
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 0, 6, 19);
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 1, 0, 1);
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 1, 1, 18);
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 1, 2, 18);
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 1, 3, 18);
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 1, 4, 18);
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 1, 5, 18);
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 2, 0, 1);
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 2, 1, 17);
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 2, 2, 17);
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 2, 3, 17);
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 2, 4, 17);
+}
+
+template <class S>
+void test52()
+{
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 4, 0, 1);
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 4, 1, 15);
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 4, 2, 15);
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 5, 0, 1);
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 5, 1, 1);
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 6, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 0, 0, 1);
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 0, 1, 19);
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 0, 5, 19);
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 0, 9, 19);
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 0, 10, 19);
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 0, 11, 19);
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 1, 0, 1);
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 1, 1, 18);
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 1, 4, 18);
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 1, 8, 18);
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 1, 9, 18);
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 1, 10, 18);
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 5, 0, 1);
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 5, 1, 14);
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 5, 2, 14);
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 5, 4, 14);
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 5, 5, 14);
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 5, 6, 14);
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 9, 0, 1);
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 9, 1, 10);
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 9, 2, 10);
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 10, 0, 1);
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 10, 1, 1);
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 11, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 0, 0, 1);
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 0, 1, 19);
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 0, 10, 19);
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 0, 19, 19);
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 0, 20, 19);
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 0, 21, 19);
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 1, 0, 1);
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 1, 1, 18);
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 1, 9, 18);
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 1, 18, 18);
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 1, 19, 18);
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 1, 20, 18);
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 10, 0, 1);
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 10, 1, 9);
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 10, 5, 9);
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 10, 9, 9);
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 10, 10, 9);
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 10, 11, 9);
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 19, 0, 1);
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 19, 1, 0);
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 19, 2, 0);
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 20, 0, 1);
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 20, 1, 1);
+ test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 21, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 20, 0, S(""), 0, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 20, 0, S(""), 0, 1, 0);
+ test(S("abcdefghijklmnopqrst"), 20, 0, S(""), 1, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 0, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 0, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 0, 2, -2);
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 0, 4, -4);
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 0, 5, -5);
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 0, 6, -5);
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 1, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 1, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 1, 2, -2);
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 1, 3, -3);
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 1, 4, -4);
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 1, 5, -4);
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 2, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 2, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 2, 2, -2);
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 2, 3, -3);
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 2, 4, -3);
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 4, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 4, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 4, 2, -1);
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 5, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 5, 1, 0);
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 6, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 0, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 0, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 0, 5, -5);
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 0, 9, -9);
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 0, 10, -10);
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 0, 11, -10);
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 1, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 1, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 1, 4, -4);
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 1, 8, -8);
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 1, 9, -9);
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 1, 10, -9);
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 5, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 5, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 5, 2, -2);
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 5, 4, -4);
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 5, 5, -5);
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 5, 6, -5);
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 9, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 9, 1, -1);
+}
+
+template <class S>
+void test53()
+{
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 9, 2, -1);
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 10, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 10, 1, 0);
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 11, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 0, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 0, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 0, 10, -10);
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 0, 19, -19);
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 0, 20, -20);
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 0, 21, -20);
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 1, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 1, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 1, 9, -9);
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 1, 18, -18);
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 1, 19, -19);
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 1, 20, -19);
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 10, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 10, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 10, 5, -5);
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 10, 9, -9);
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 10, 10, -10);
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 10, 11, -10);
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 19, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 19, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 19, 2, -1);
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 20, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 20, 1, 0);
+ test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 21, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 20, 1, S(""), 0, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 20, 1, S(""), 0, 1, 0);
+ test(S("abcdefghijklmnopqrst"), 20, 1, S(""), 1, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 0, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 0, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 0, 2, -2);
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 0, 4, -4);
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 0, 5, -5);
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 0, 6, -5);
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 1, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 1, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 1, 2, -2);
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 1, 3, -3);
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 1, 4, -4);
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 1, 5, -4);
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 2, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 2, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 2, 2, -2);
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 2, 3, -3);
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 2, 4, -3);
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 4, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 4, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 4, 2, -1);
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 5, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 5, 1, 0);
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 6, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 0, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 0, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 0, 5, -5);
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 0, 9, -9);
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 0, 10, -10);
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 0, 11, -10);
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 1, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 1, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 1, 4, -4);
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 1, 8, -8);
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 1, 9, -9);
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 1, 10, -9);
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 5, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 5, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 5, 2, -2);
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 5, 4, -4);
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 5, 5, -5);
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 5, 6, -5);
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 9, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 9, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 9, 2, -1);
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 10, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 10, 1, 0);
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 11, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 0, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 0, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 0, 10, -10);
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 0, 19, -19);
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 0, 20, -20);
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 0, 21, -20);
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 1, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 1, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 1, 9, -9);
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 1, 18, -18);
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 1, 19, -19);
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 1, 20, -19);
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 10, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 10, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 10, 5, -5);
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 10, 9, -9);
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 10, 10, -10);
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 10, 11, -10);
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 19, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 19, 1, -1);
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 19, 2, -1);
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 20, 0, 0);
+}
+
+template <class S>
+void test54()
+{
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 20, 1, 0);
+ test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 21, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, S(""), 0, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, S(""), 0, 1, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, S(""), 1, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 0, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 0, 1, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 0, 2, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 0, 4, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 0, 5, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 0, 6, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 1, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 1, 1, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 1, 2, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 1, 3, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 1, 4, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 1, 5, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 2, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 2, 1, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 2, 2, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 2, 3, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 2, 4, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 4, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 4, 1, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 4, 2, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 5, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 5, 1, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 6, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 0, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 0, 1, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 0, 5, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 0, 9, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 0, 10, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 0, 11, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 1, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 1, 1, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 1, 4, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 1, 8, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 1, 9, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 1, 10, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 5, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 5, 1, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 5, 2, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 5, 4, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 5, 5, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 5, 6, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 9, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 9, 1, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 9, 2, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 10, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 10, 1, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 11, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 0, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 0, 1, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 0, 10, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 0, 19, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 0, 20, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 0, 21, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 1, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 1, 1, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 1, 9, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 1, 18, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 1, 19, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 1, 20, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 10, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 10, 1, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 10, 5, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 10, 9, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 10, 10, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 10, 11, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 19, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 19, 1, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 19, 2, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 20, 0, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 20, 1, 0);
+ test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 21, 0, 0);
+}
+
+template<class S>
+void test55()
+{
+ test_npos(S(""), 0, 0, S(""), 0, 0);
+ test_npos(S(""), 0, 0, S("abcde"), 0, -5);
+ test_npos(S("abcde"), 0, 0, S("abcdefghij"), 0, -10);
+ test_npos(S("abcde"), 0, 0, S("abcdefghij"), 1, -9);
+ test_npos(S("abcde"), 0, 0, S("abcdefghij"), 5, -5);
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test0<S>();
+ test1<S>();
+ test2<S>();
+ test3<S>();
+ test4<S>();
+ test5<S>();
+ test6<S>();
+ test7<S>();
+ test8<S>();
+ test9<S>();
+ test10<S>();
+ test11<S>();
+ test12<S>();
+ test13<S>();
+ test14<S>();
+ test15<S>();
+ test16<S>();
+ test17<S>();
+ test18<S>();
+ test19<S>();
+ test20<S>();
+ test21<S>();
+ test22<S>();
+ test23<S>();
+ test24<S>();
+ test25<S>();
+ test26<S>();
+ test27<S>();
+ test28<S>();
+ test29<S>();
+ test30<S>();
+ test31<S>();
+ test32<S>();
+ test33<S>();
+ test34<S>();
+ test35<S>();
+ test36<S>();
+ test37<S>();
+ test38<S>();
+ test39<S>();
+ test40<S>();
+ test41<S>();
+ test42<S>();
+ test43<S>();
+ test44<S>();
+ test45<S>();
+ test46<S>();
+ test47<S>();
+ test48<S>();
+ test49<S>();
+ test50<S>();
+ test51<S>();
+ test52<S>();
+ test53<S>();
+ test54<S>();
+ test55<S>();
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test0<S>();
+ test1<S>();
+ test2<S>();
+ test3<S>();
+ test4<S>();
+ test5<S>();
+ test6<S>();
+ test7<S>();
+ test8<S>();
+ test9<S>();
+ test10<S>();
+ test11<S>();
+ test12<S>();
+ test13<S>();
+ test14<S>();
+ test15<S>();
+ test16<S>();
+ test17<S>();
+ test18<S>();
+ test19<S>();
+ test20<S>();
+ test21<S>();
+ test22<S>();
+ test23<S>();
+ test24<S>();
+ test25<S>();
+ test26<S>();
+ test27<S>();
+ test28<S>();
+ test29<S>();
+ test30<S>();
+ test31<S>();
+ test32<S>();
+ test33<S>();
+ test34<S>();
+ test35<S>();
+ test36<S>();
+ test37<S>();
+ test38<S>();
+ test39<S>();
+ test40<S>();
+ test41<S>();
+ test42<S>();
+ test43<S>();
+ test44<S>();
+ test45<S>();
+ test46<S>();
+ test47<S>();
+ test48<S>();
+ test49<S>();
+ test50<S>();
+ test51<S>();
+ test52<S>();
+ test53<S>();
+ test54<S>();
+ test55<S>();
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.ops/string_compare/string.pass.cpp b/test/std/strings/basic.string/string.ops/string_compare/string.pass.cpp
new file mode 100644
index 000000000000..7de95a8cda56
--- /dev/null
+++ b/test/std/strings/basic.string/string.ops/string_compare/string.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// int compare(const basic_string& str) const
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int sign(int x)
+{
+ if (x == 0)
+ return 0;
+ if (x < 0)
+ return -1;
+ return 1;
+}
+
+template <class S>
+void
+test(const S& s, const S& str, int x)
+{
+ assert(sign(s.compare(str)) == sign(x));
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test(S(""), S(""), 0);
+ test(S(""), S("abcde"), -5);
+ test(S(""), S("abcdefghij"), -10);
+ test(S(""), S("abcdefghijklmnopqrst"), -20);
+ test(S("abcde"), S(""), 5);
+ test(S("abcde"), S("abcde"), 0);
+ test(S("abcde"), S("abcdefghij"), -5);
+ test(S("abcde"), S("abcdefghijklmnopqrst"), -15);
+ test(S("abcdefghij"), S(""), 10);
+ test(S("abcdefghij"), S("abcde"), 5);
+ test(S("abcdefghij"), S("abcdefghij"), 0);
+ test(S("abcdefghij"), S("abcdefghijklmnopqrst"), -10);
+ test(S("abcdefghijklmnopqrst"), S(""), 20);
+ test(S("abcdefghijklmnopqrst"), S("abcde"), 15);
+ test(S("abcdefghijklmnopqrst"), S("abcdefghij"), 10);
+ test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S(""), S(""), 0);
+ test(S(""), S("abcde"), -5);
+ test(S(""), S("abcdefghij"), -10);
+ test(S(""), S("abcdefghijklmnopqrst"), -20);
+ test(S("abcde"), S(""), 5);
+ test(S("abcde"), S("abcde"), 0);
+ test(S("abcde"), S("abcdefghij"), -5);
+ test(S("abcde"), S("abcdefghijklmnopqrst"), -15);
+ test(S("abcdefghij"), S(""), 10);
+ test(S("abcdefghij"), S("abcde"), 5);
+ test(S("abcdefghij"), S("abcdefghij"), 0);
+ test(S("abcdefghij"), S("abcdefghijklmnopqrst"), -10);
+ test(S("abcdefghijklmnopqrst"), S(""), 20);
+ test(S("abcdefghijklmnopqrst"), S("abcde"), 15);
+ test(S("abcdefghijklmnopqrst"), S("abcdefghij"), 10);
+ test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), 0);
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.ops/string_find.first.not.of/char_size.pass.cpp b/test/std/strings/basic.string/string.ops/string_find.first.not.of/char_size.pass.cpp
new file mode 100644
index 000000000000..590173eddf41
--- /dev/null
+++ b/test/std/strings/basic.string/string.ops/string_find.first.not.of/char_size.pass.cpp
@@ -0,0 +1,102 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type find_first_not_of(charT c, size_type pos = 0) const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& s, typename S::value_type c, typename S::size_type pos,
+ typename S::size_type x)
+{
+ assert(s.find_first_not_of(c, pos) == x);
+ if (x != S::npos)
+ assert(pos <= x && x < s.size());
+}
+
+template <class S>
+void
+test(const S& s, typename S::value_type c, typename S::size_type x)
+{
+ assert(s.find_first_not_of(c) == x);
+ if (x != S::npos)
+ assert(x < s.size());
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test(S(""), 'q', 0, S::npos);
+ test(S(""), 'q', 1, S::npos);
+ test(S("kitcj"), 'q', 0, 0);
+ test(S("qkamf"), 'q', 1, 1);
+ test(S("nhmko"), 'q', 2, 2);
+ test(S("tpsaf"), 'q', 4, 4);
+ test(S("lahfb"), 'q', 5, S::npos);
+ test(S("irkhs"), 'q', 6, S::npos);
+ test(S("gmfhdaipsr"), 'q', 0, 0);
+ test(S("kantesmpgj"), 'q', 1, 1);
+ test(S("odaftiegpm"), 'q', 5, 5);
+ test(S("oknlrstdpi"), 'q', 9, 9);
+ test(S("eolhfgpjqk"), 'q', 10, S::npos);
+ test(S("pcdrofikas"), 'q', 11, S::npos);
+ test(S("nbatdlmekrgcfqsophij"), 'q', 0, 0);
+ test(S("bnrpehidofmqtcksjgla"), 'q', 1, 1);
+ test(S("jdmciepkaqgotsrfnhlb"), 'q', 10, 10);
+ test(S("jtdaefblsokrmhpgcnqi"), 'q', 19, 19);
+ test(S("hkbgspofltajcnedqmri"), 'q', 20, S::npos);
+ test(S("oselktgbcapndfjihrmq"), 'q', 21, S::npos);
+
+ test(S(""), 'q', S::npos);
+ test(S("q"), 'q', S::npos);
+ test(S("qqq"), 'q', S::npos);
+ test(S("csope"), 'q', 0);
+ test(S("gfsmthlkon"), 'q', 0);
+ test(S("laenfsbridchgotmkqpj"), 'q', 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S(""), 'q', 0, S::npos);
+ test(S(""), 'q', 1, S::npos);
+ test(S("kitcj"), 'q', 0, 0);
+ test(S("qkamf"), 'q', 1, 1);
+ test(S("nhmko"), 'q', 2, 2);
+ test(S("tpsaf"), 'q', 4, 4);
+ test(S("lahfb"), 'q', 5, S::npos);
+ test(S("irkhs"), 'q', 6, S::npos);
+ test(S("gmfhdaipsr"), 'q', 0, 0);
+ test(S("kantesmpgj"), 'q', 1, 1);
+ test(S("odaftiegpm"), 'q', 5, 5);
+ test(S("oknlrstdpi"), 'q', 9, 9);
+ test(S("eolhfgpjqk"), 'q', 10, S::npos);
+ test(S("pcdrofikas"), 'q', 11, S::npos);
+ test(S("nbatdlmekrgcfqsophij"), 'q', 0, 0);
+ test(S("bnrpehidofmqtcksjgla"), 'q', 1, 1);
+ test(S("jdmciepkaqgotsrfnhlb"), 'q', 10, 10);
+ test(S("jtdaefblsokrmhpgcnqi"), 'q', 19, 19);
+ test(S("hkbgspofltajcnedqmri"), 'q', 20, S::npos);
+ test(S("oselktgbcapndfjihrmq"), 'q', 21, S::npos);
+
+ test(S(""), 'q', S::npos);
+ test(S("q"), 'q', S::npos);
+ test(S("qqq"), 'q', S::npos);
+ test(S("csope"), 'q', 0);
+ test(S("gfsmthlkon"), 'q', 0);
+ test(S("laenfsbridchgotmkqpj"), 'q', 0);
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.ops/string_find.first.not.of/pointer_size.pass.cpp b/test/std/strings/basic.string/string.ops/string_find.first.not.of/pointer_size.pass.cpp
new file mode 100644
index 000000000000..53d3a95292c2
--- /dev/null
+++ b/test/std/strings/basic.string/string.ops/string_find.first.not.of/pointer_size.pass.cpp
@@ -0,0 +1,158 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type find_first_not_of(const charT* s, size_type pos = 0) const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type pos,
+ typename S::size_type x)
+{
+ assert(s.find_first_not_of(str, pos) == x);
+ if (x != S::npos)
+ assert(pos <= x && x < s.size());
+}
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type x)
+{
+ assert(s.find_first_not_of(str) == x);
+ if (x != S::npos)
+ assert(x < s.size());
+}
+
+template <class S>
+void test0()
+{
+ test(S(""), "", 0, S::npos);
+ test(S(""), "laenf", 0, S::npos);
+ test(S(""), "pqlnkmbdjo", 0, S::npos);
+ test(S(""), "qkamfogpnljdcshbreti", 0, S::npos);
+ test(S(""), "", 1, S::npos);
+ test(S(""), "bjaht", 1, S::npos);
+ test(S(""), "hjlcmgpket", 1, S::npos);
+ test(S(""), "htaobedqikfplcgjsmrn", 1, S::npos);
+ test(S("fodgq"), "", 0, 0);
+ test(S("qanej"), "dfkap", 0, 0);
+ test(S("clbao"), "ihqrfebgad", 0, 0);
+ test(S("mekdn"), "ngtjfcalbseiqrphmkdo", 0, S::npos);
+ test(S("srdfq"), "", 1, 1);
+ test(S("oemth"), "ikcrq", 1, 1);
+ test(S("cdaih"), "dmajblfhsg", 1, 3);
+ test(S("qohtk"), "oqftjhdmkgsblacenirp", 1, S::npos);
+ test(S("cshmd"), "", 2, 2);
+ test(S("lhcdo"), "oebqi", 2, 2);
+ test(S("qnsoh"), "kojhpmbsfe", 2, S::npos);
+ test(S("pkrof"), "acbsjqogpltdkhinfrem", 2, S::npos);
+ test(S("fmtsp"), "", 4, 4);
+ test(S("khbpm"), "aobjd", 4, 4);
+ test(S("pbsji"), "pcbahntsje", 4, 4);
+ test(S("mprdj"), "fhepcrntkoagbmldqijs", 4, S::npos);
+ test(S("eqmpa"), "", 5, S::npos);
+ test(S("omigs"), "kocgb", 5, S::npos);
+ test(S("onmje"), "fbslrjiqkm", 5, S::npos);
+ test(S("oqmrj"), "jeidpcmalhfnqbgtrsko", 5, S::npos);
+ test(S("schfa"), "", 6, S::npos);
+ test(S("igdsc"), "qngpd", 6, S::npos);
+ test(S("brqgo"), "rodhqklgmb", 6, S::npos);
+ test(S("tnrph"), "thdjgafrlbkoiqcspmne", 6, S::npos);
+ test(S("hcjitbfapl"), "", 0, 0);
+ test(S("daiprenocl"), "ashjd", 0, 2);
+ test(S("litpcfdghe"), "mgojkldsqh", 0, 1);
+ test(S("aidjksrolc"), "imqnaghkfrdtlopbjesc", 0, S::npos);
+ test(S("qpghtfbaji"), "", 1, 1);
+ test(S("gfshlcmdjr"), "nadkh", 1, 1);
+ test(S("nkodajteqp"), "ofdrqmkebl", 1, 4);
+ test(S("gbmetiprqd"), "bdfjqgatlksriohemnpc", 1, S::npos);
+ test(S("crnklpmegd"), "", 5, 5);
+ test(S("jsbtafedoc"), "prqgn", 5, 5);
+ test(S("qnmodrtkeb"), "pejafmnokr", 5, 6);
+ test(S("cpebqsfmnj"), "odnqkgijrhabfmcestlp", 5, S::npos);
+ test(S("lmofqdhpki"), "", 9, 9);
+ test(S("hnefkqimca"), "rtjpa", 9, S::npos);
+ test(S("drtasbgmfp"), "ktsrmnqagd", 9, 9);
+ test(S("lsaijeqhtr"), "rtdhgcisbnmoaqkfpjle", 9, S::npos);
+ test(S("elgofjmbrq"), "", 10, S::npos);
+ test(S("mjqdgalkpc"), "dplqa", 10, S::npos);
+ test(S("kthqnfcerm"), "dkacjoptns", 10, S::npos);
+ test(S("dfsjhanorc"), "hqfimtrgnbekpdcsjalo", 10, S::npos);
+ test(S("eqsgalomhb"), "", 11, S::npos);
+ test(S("akiteljmoh"), "lofbc", 11, S::npos);
+ test(S("hlbdfreqjo"), "astoegbfpn", 11, S::npos);
+ test(S("taqobhlerg"), "pdgreqomsncafklhtibj", 11, S::npos);
+ test(S("snafbdlghrjkpqtoceim"), "", 0, 0);
+ test(S("aemtbrgcklhndjisfpoq"), "lbtqd", 0, 0);
+ test(S("pnracgfkjdiholtbqsem"), "tboimldpjh", 0, 1);
+ test(S("dicfltehbsgrmojnpkaq"), "slcerthdaiqjfnobgkpm", 0, S::npos);
+ test(S("jlnkraeodhcspfgbqitm"), "", 1, 1);
+ test(S("lhosrngtmfjikbqpcade"), "aqibs", 1, 1);
+ test(S("rbtaqjhgkneisldpmfoc"), "gtfblmqinc", 1, 3);
+ test(S("gpifsqlrdkbonjtmheca"), "mkqpbtdalgniorhfescj", 1, S::npos);
+ test(S("hdpkobnsalmcfijregtq"), "", 10, 10);
+ test(S("jtlshdgqaiprkbcoenfm"), "pblas", 10, 11);
+ test(S("fkdrbqltsgmcoiphneaj"), "arosdhcfme", 10, 13);
+ test(S("crsplifgtqedjohnabmk"), "blkhjeogicatqfnpdmsr", 10, S::npos);
+ test(S("niptglfbosehkamrdqcj"), "", 19, 19);
+ test(S("copqdhstbingamjfkler"), "djkqc", 19, 19);
+ test(S("mrtaefilpdsgocnhqbjk"), "lgokshjtpb", 19, S::npos);
+ test(S("kojatdhlcmigpbfrqnes"), "bqjhtkfepimcnsgrlado", 19, S::npos);
+ test(S("eaintpchlqsbdgrkjofm"), "", 20, S::npos);
+ test(S("gjnhidfsepkrtaqbmclo"), "nocfa", 20, S::npos);
+ test(S("spocfaktqdbiejlhngmr"), "bgtajmiedc", 20, S::npos);
+ test(S("rphmlekgfscndtaobiqj"), "lsckfnqgdahejiopbtmr", 20, S::npos);
+ test(S("liatsqdoegkmfcnbhrpj"), "", 21, S::npos);
+ test(S("binjagtfldkrspcomqeh"), "gfsrt", 21, S::npos);
+ test(S("latkmisecnorjbfhqpdg"), "pfsocbhjtm", 21, S::npos);
+ test(S("lecfratdjkhnsmqpoigb"), "tpflmdnoicjgkberhqsa", 21, S::npos);
+}
+
+template <class S>
+void test1()
+{
+ test(S(""), "", S::npos);
+ test(S(""), "laenf", S::npos);
+ test(S(""), "pqlnkmbdjo", S::npos);
+ test(S(""), "qkamfogpnljdcshbreti", S::npos);
+ test(S("nhmko"), "", 0);
+ test(S("lahfb"), "irkhs", 0);
+ test(S("gmfhd"), "kantesmpgj", 2);
+ test(S("odaft"), "oknlrstdpiqmjbaghcfe", S::npos);
+ test(S("eolhfgpjqk"), "", 0);
+ test(S("nbatdlmekr"), "bnrpe", 2);
+ test(S("jdmciepkaq"), "jtdaefblso", 2);
+ test(S("hkbgspoflt"), "oselktgbcapndfjihrmq", S::npos);
+ test(S("gprdcokbnjhlsfmtieqa"), "", 0);
+ test(S("qjghlnftcaismkropdeb"), "bjaht", 0);
+ test(S("pnalfrdtkqcmojiesbhg"), "hjlcmgpket", 1);
+ test(S("pniotcfrhqsmgdkjbael"), "htaobedqikfplcgjsmrn", S::npos);
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test0<S>();
+ test1<S>();
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test0<S>();
+ test1<S>();
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.ops/string_find.first.not.of/pointer_size_size.pass.cpp b/test/std/strings/basic.string/string.ops/string_find.first.not.of/pointer_size_size.pass.cpp
new file mode 100644
index 000000000000..14ac4b2a153b
--- /dev/null
+++ b/test/std/strings/basic.string/string.ops/string_find.first.not.of/pointer_size_size.pass.cpp
@@ -0,0 +1,387 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type find_first_not_of(const charT* s, size_type pos, size_type n) const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type pos,
+ typename S::size_type n, typename S::size_type x)
+{
+ assert(s.find_first_not_of(str, pos, n) == x);
+ if (x != S::npos)
+ assert(pos <= x && x < s.size());
+}
+
+template <class S>
+void test0()
+{
+ test(S(""), "", 0, 0, S::npos);
+ test(S(""), "irkhs", 0, 0, S::npos);
+ test(S(""), "kante", 0, 1, S::npos);
+ test(S(""), "oknlr", 0, 2, S::npos);
+ test(S(""), "pcdro", 0, 4, S::npos);
+ test(S(""), "bnrpe", 0, 5, S::npos);
+ test(S(""), "jtdaefblso", 0, 0, S::npos);
+ test(S(""), "oselktgbca", 0, 1, S::npos);
+ test(S(""), "eqgaplhckj", 0, 5, S::npos);
+ test(S(""), "bjahtcmnlp", 0, 9, S::npos);
+ test(S(""), "hjlcmgpket", 0, 10, S::npos);
+ test(S(""), "htaobedqikfplcgjsmrn", 0, 0, S::npos);
+ test(S(""), "hpqiarojkcdlsgnmfetb", 0, 1, S::npos);
+ test(S(""), "dfkaprhjloqetcsimnbg", 0, 10, S::npos);
+ test(S(""), "ihqrfebgadntlpmjksoc", 0, 19, S::npos);
+ test(S(""), "ngtjfcalbseiqrphmkdo", 0, 20, S::npos);
+ test(S(""), "", 1, 0, S::npos);
+ test(S(""), "lbtqd", 1, 0, S::npos);
+ test(S(""), "tboim", 1, 1, S::npos);
+ test(S(""), "slcer", 1, 2, S::npos);
+ test(S(""), "cbjfs", 1, 4, S::npos);
+ test(S(""), "aqibs", 1, 5, S::npos);
+ test(S(""), "gtfblmqinc", 1, 0, S::npos);
+ test(S(""), "mkqpbtdalg", 1, 1, S::npos);
+ test(S(""), "kphatlimcd", 1, 5, S::npos);
+ test(S(""), "pblasqogic", 1, 9, S::npos);
+ test(S(""), "arosdhcfme", 1, 10, S::npos);
+ test(S(""), "blkhjeogicatqfnpdmsr", 1, 0, S::npos);
+ test(S(""), "bmhineprjcoadgstflqk", 1, 1, S::npos);
+ test(S(""), "djkqcmetslnghpbarfoi", 1, 10, S::npos);
+ test(S(""), "lgokshjtpbemarcdqnfi", 1, 19, S::npos);
+ test(S(""), "bqjhtkfepimcnsgrlado", 1, 20, S::npos);
+ test(S("eaint"), "", 0, 0, 0);
+ test(S("binja"), "gfsrt", 0, 0, 0);
+ test(S("latkm"), "pfsoc", 0, 1, 0);
+ test(S("lecfr"), "tpflm", 0, 2, 0);
+ test(S("eqkst"), "sgkec", 0, 4, 1);
+ test(S("cdafr"), "romds", 0, 5, 0);
+ test(S("prbhe"), "qhjistlgmr", 0, 0, 0);
+ test(S("lbisk"), "pedfirsglo", 0, 1, 0);
+ test(S("hrlpd"), "aqcoslgrmk", 0, 5, 0);
+ test(S("ehmja"), "dabckmepqj", 0, 9, 1);
+ test(S("mhqgd"), "pqscrjthli", 0, 10, 0);
+ test(S("tgklq"), "kfphdcsjqmobliagtren", 0, 0, 0);
+ test(S("bocjs"), "rokpefncljibsdhqtagm", 0, 1, 0);
+ test(S("grbsd"), "afionmkphlebtcjqsgrd", 0, 10, 0);
+ test(S("ofjqr"), "aenmqplidhkofrjbctsg", 0, 19, S::npos);
+ test(S("btlfi"), "osjmbtcadhiklegrpqnf", 0, 20, S::npos);
+ test(S("clrgb"), "", 1, 0, 1);
+ test(S("tjmek"), "osmia", 1, 0, 1);
+ test(S("bgstp"), "ckonl", 1, 1, 1);
+ test(S("hstrk"), "ilcaj", 1, 2, 1);
+ test(S("kmspj"), "lasiq", 1, 4, 1);
+ test(S("tjboh"), "kfqmr", 1, 5, 1);
+ test(S("ilbcj"), "klnitfaobg", 1, 0, 1);
+ test(S("jkngf"), "gjhmdlqikp", 1, 1, 1);
+ test(S("gfcql"), "skbgtahqej", 1, 5, 1);
+ test(S("dqtlg"), "bjsdgtlpkf", 1, 9, 1);
+ test(S("bthpg"), "bjgfmnlkio", 1, 10, 1);
+ test(S("dgsnq"), "lbhepotfsjdqigcnamkr", 1, 0, 1);
+ test(S("rmfhp"), "tebangckmpsrqdlfojhi", 1, 1, 1);
+ test(S("jfdam"), "joflqbdkhtegimscpanr", 1, 10, 3);
+ test(S("edapb"), "adpmcohetfbsrjinlqkg", 1, 19, S::npos);
+ test(S("brfsm"), "iacldqjpfnogbsrhmetk", 1, 20, S::npos);
+ test(S("ndrhl"), "", 2, 0, 2);
+ test(S("mrecp"), "otkgb", 2, 0, 2);
+ test(S("qlasf"), "cqsjl", 2, 1, 2);
+ test(S("smaqd"), "dpifl", 2, 2, 2);
+ test(S("hjeni"), "oapht", 2, 4, 2);
+ test(S("ocmfj"), "cifts", 2, 5, 2);
+ test(S("hmftq"), "nmsckbgalo", 2, 0, 2);
+ test(S("fklad"), "tpksqhamle", 2, 1, 2);
+ test(S("dirnm"), "tpdrchmkji", 2, 5, 3);
+ test(S("hrgdc"), "ijagfkblst", 2, 9, 3);
+ test(S("ifakg"), "kpocsignjb", 2, 10, 2);
+ test(S("ebrgd"), "pecqtkjsnbdrialgmohf", 2, 0, 2);
+ test(S("rcjml"), "aiortphfcmkjebgsndql", 2, 1, 2);
+ test(S("peqmt"), "sdbkeamglhipojqftrcn", 2, 10, 2);
+ test(S("frehn"), "ljqncehgmfktroapidbs", 2, 19, S::npos);
+ test(S("tqolf"), "rtcfodilamkbenjghqps", 2, 20, S::npos);
+ test(S("cjgao"), "", 4, 0, 4);
+ test(S("kjplq"), "mabns", 4, 0, 4);
+ test(S("herni"), "bdnrp", 4, 1, 4);
+ test(S("tadrb"), "scidp", 4, 2, 4);
+ test(S("pkfeo"), "agbjl", 4, 4, 4);
+ test(S("hoser"), "jfmpr", 4, 5, S::npos);
+ test(S("kgrsp"), "rbpefghsmj", 4, 0, 4);
+ test(S("pgejb"), "apsfntdoqc", 4, 1, 4);
+ test(S("thlnq"), "ndkjeisgcl", 4, 5, 4);
+ test(S("nbmit"), "rnfpqatdeo", 4, 9, S::npos);
+ test(S("jgmib"), "bntjlqrfik", 4, 10, S::npos);
+ test(S("ncrfj"), "kcrtmpolnaqejghsfdbi", 4, 0, 4);
+ test(S("ncsik"), "lobheanpkmqidsrtcfgj", 4, 1, 4);
+ test(S("sgbfh"), "athdkljcnreqbgpmisof", 4, 10, S::npos);
+ test(S("dktbn"), "qkdmjialrscpbhefgont", 4, 19, S::npos);
+ test(S("fthqm"), "dmasojntqleribkgfchp", 4, 20, S::npos);
+ test(S("klopi"), "", 5, 0, S::npos);
+ test(S("dajhn"), "psthd", 5, 0, S::npos);
+ test(S("jbgno"), "rpmjd", 5, 1, S::npos);
+ test(S("hkjae"), "dfsmk", 5, 2, S::npos);
+}
+
+template <class S>
+void test1()
+{
+ test(S("gbhqo"), "skqne", 5, 4, S::npos);
+ test(S("ktdor"), "kipnf", 5, 5, S::npos);
+ test(S("ldprn"), "hmrnqdgifl", 5, 0, S::npos);
+ test(S("egmjk"), "fsmjcdairn", 5, 1, S::npos);
+ test(S("armql"), "pcdgltbrfj", 5, 5, S::npos);
+ test(S("cdhjo"), "aekfctpirg", 5, 9, S::npos);
+ test(S("jcons"), "ledihrsgpf", 5, 10, S::npos);
+ test(S("cbrkp"), "mqcklahsbtirgopefndj", 5, 0, S::npos);
+ test(S("fhgna"), "kmlthaoqgecrnpdbjfis", 5, 1, S::npos);
+ test(S("ejfcd"), "sfhbamcdptojlkrenqgi", 5, 10, S::npos);
+ test(S("kqjhe"), "pbniofmcedrkhlstgaqj", 5, 19, S::npos);
+ test(S("pbdjl"), "mongjratcskbhqiepfdl", 5, 20, S::npos);
+ test(S("gajqn"), "", 6, 0, S::npos);
+ test(S("stedk"), "hrnat", 6, 0, S::npos);
+ test(S("tjkaf"), "gsqdt", 6, 1, S::npos);
+ test(S("dthpe"), "bspkd", 6, 2, S::npos);
+ test(S("klhde"), "ohcmb", 6, 4, S::npos);
+ test(S("bhlki"), "heatr", 6, 5, S::npos);
+ test(S("lqmoh"), "pmblckedfn", 6, 0, S::npos);
+ test(S("mtqin"), "aceqmsrbik", 6, 1, S::npos);
+ test(S("dpqbr"), "lmbtdehjrn", 6, 5, S::npos);
+ test(S("kdhmo"), "teqmcrlgib", 6, 9, S::npos);
+ test(S("jblqp"), "njolbmspac", 6, 10, S::npos);
+ test(S("qmjgl"), "pofnhidklamecrbqjgst", 6, 0, S::npos);
+ test(S("rothp"), "jbhckmtgrqnosafedpli", 6, 1, S::npos);
+ test(S("ghknq"), "dobntpmqklicsahgjerf", 6, 10, S::npos);
+ test(S("eopfi"), "tpdshainjkbfoemlrgcq", 6, 19, S::npos);
+ test(S("dsnmg"), "oldpfgeakrnitscbjmqh", 6, 20, S::npos);
+ test(S("jnkrfhotgl"), "", 0, 0, 0);
+ test(S("dltjfngbko"), "rqegt", 0, 0, 0);
+ test(S("bmjlpkiqde"), "dashm", 0, 1, 0);
+ test(S("skrflobnqm"), "jqirk", 0, 2, 0);
+ test(S("jkpldtshrm"), "rckeg", 0, 4, 0);
+ test(S("ghasdbnjqo"), "jscie", 0, 5, 0);
+ test(S("igrkhpbqjt"), "efsphndliq", 0, 0, 0);
+ test(S("ikthdgcamf"), "gdicosleja", 0, 1, 0);
+ test(S("pcofgeniam"), "qcpjibosfl", 0, 5, 2);
+ test(S("rlfjgesqhc"), "lrhmefnjcq", 0, 9, 4);
+ test(S("itphbqsker"), "dtablcrseo", 0, 10, 0);
+ test(S("skjafcirqm"), "apckjsftedbhgomrnilq", 0, 0, 0);
+ test(S("tcqomarsfd"), "pcbrgflehjtiadnsokqm", 0, 1, 0);
+ test(S("rocfeldqpk"), "nsiadegjklhobrmtqcpf", 0, 10, 0);
+ test(S("cfpegndlkt"), "cpmajdqnolikhgsbretf", 0, 19, 1);
+ test(S("fqbtnkeasj"), "jcflkntmgiqrphdosaeb", 0, 20, S::npos);
+ test(S("shbcqnmoar"), "", 1, 0, 1);
+ test(S("bdoshlmfin"), "ontrs", 1, 0, 1);
+ test(S("khfrebnsgq"), "pfkna", 1, 1, 1);
+ test(S("getcrsaoji"), "ekosa", 1, 2, 2);
+ test(S("fjiknedcpq"), "anqhk", 1, 4, 1);
+ test(S("tkejgnafrm"), "jekca", 1, 5, 4);
+ test(S("jnakolqrde"), "ikemsjgacf", 1, 0, 1);
+ test(S("lcjptsmgbe"), "arolgsjkhm", 1, 1, 1);
+ test(S("itfsmcjorl"), "oftkbldhre", 1, 5, 3);
+ test(S("omchkfrjea"), "gbkqdoeftl", 1, 9, 1);
+ test(S("cigfqkated"), "sqcflrgtim", 1, 10, 5);
+ test(S("tscenjikml"), "fmhbkislrjdpanogqcet", 1, 0, 1);
+ test(S("qcpaemsinf"), "rnioadktqlgpbcjsmhef", 1, 1, 1);
+ test(S("gltkojeipd"), "oakgtnldpsefihqmjcbr", 1, 10, 5);
+ test(S("qistfrgnmp"), "gbnaelosidmcjqktfhpr", 1, 19, 5);
+ test(S("bdnpfcqaem"), "akbripjhlosndcmqgfet", 1, 20, S::npos);
+ test(S("ectnhskflp"), "", 5, 0, 5);
+ test(S("fgtianblpq"), "pijag", 5, 0, 5);
+ test(S("mfeqklirnh"), "jrckd", 5, 1, 5);
+ test(S("astedncjhk"), "qcloh", 5, 2, 5);
+ test(S("fhlqgcajbr"), "thlmp", 5, 4, 5);
+ test(S("epfhocmdng"), "qidmo", 5, 5, 5);
+ test(S("apcnsibger"), "lnegpsjqrd", 5, 0, 5);
+ test(S("aqkocrbign"), "rjqdablmfs", 5, 1, 6);
+ test(S("ijsmdtqgce"), "enkgpbsjaq", 5, 5, 5);
+ test(S("clobgsrken"), "kdsgoaijfh", 5, 9, 6);
+ test(S("jbhcfposld"), "trfqgmckbe", 5, 10, 5);
+ test(S("oqnpblhide"), "igetsracjfkdnpoblhqm", 5, 0, 5);
+ test(S("lroeasctif"), "nqctfaogirshlekbdjpm", 5, 1, 5);
+ test(S("bpjlgmiedh"), "csehfgomljdqinbartkp", 5, 10, 6);
+ test(S("pamkeoidrj"), "qahoegcmplkfsjbdnitr", 5, 19, 8);
+ test(S("espogqbthk"), "dpteiajrqmsognhlfbkc", 5, 20, S::npos);
+ test(S("shoiedtcjb"), "", 9, 0, 9);
+ test(S("ebcinjgads"), "tqbnh", 9, 0, 9);
+ test(S("dqmregkcfl"), "akmle", 9, 1, 9);
+ test(S("ngcrieqajf"), "iqfkm", 9, 2, 9);
+ test(S("qosmilgnjb"), "tqjsr", 9, 4, 9);
+ test(S("ikabsjtdfl"), "jplqg", 9, 5, S::npos);
+ test(S("ersmicafdh"), "oilnrbcgtj", 9, 0, 9);
+ test(S("fdnplotmgh"), "morkglpesn", 9, 1, 9);
+ test(S("fdbicojerm"), "dmicerngat", 9, 5, S::npos);
+ test(S("mbtafndjcq"), "radgeskbtc", 9, 9, 9);
+ test(S("mlenkpfdtc"), "ljikprsmqo", 9, 10, 9);
+ test(S("ahlcifdqgs"), "trqihkcgsjamfdbolnpe", 9, 0, 9);
+ test(S("bgjemaltks"), "lqmthbsrekajgnofcipd", 9, 1, 9);
+ test(S("pdhslbqrfc"), "jtalmedribkgqsopcnfh", 9, 10, 9);
+ test(S("dirhtsnjkc"), "spqfoiclmtagejbndkrh", 9, 19, S::npos);
+ test(S("dlroktbcja"), "nmotklspigjrdhcfaebq", 9, 20, S::npos);
+ test(S("ncjpmaekbs"), "", 10, 0, S::npos);
+ test(S("hlbosgmrak"), "hpmsd", 10, 0, S::npos);
+ test(S("pqfhsgilen"), "qnpor", 10, 1, S::npos);
+ test(S("gqtjsbdckh"), "otdma", 10, 2, S::npos);
+ test(S("cfkqpjlegi"), "efhjg", 10, 4, S::npos);
+ test(S("beanrfodgj"), "odpte", 10, 5, S::npos);
+ test(S("adtkqpbjfi"), "bctdgfmolr", 10, 0, S::npos);
+ test(S("iomkfthagj"), "oaklidrbqg", 10, 1, S::npos);
+}
+
+template <class S>
+void test2()
+{
+ test(S("sdpcilonqj"), "dnjfsagktr", 10, 5, S::npos);
+ test(S("gtfbdkqeml"), "nejaktmiqg", 10, 9, S::npos);
+ test(S("bmeqgcdorj"), "pjqonlebsf", 10, 10, S::npos);
+ test(S("etqlcanmob"), "dshmnbtolcjepgaikfqr", 10, 0, S::npos);
+ test(S("roqmkbdtia"), "iogfhpabtjkqlrnemcds", 10, 1, S::npos);
+ test(S("kadsithljf"), "ngridfabjsecpqltkmoh", 10, 10, S::npos);
+ test(S("sgtkpbfdmh"), "athmknplcgofrqejsdib", 10, 19, S::npos);
+ test(S("qgmetnabkl"), "ldobhmqcafnjtkeisgrp", 10, 20, S::npos);
+ test(S("cqjohampgd"), "", 11, 0, S::npos);
+ test(S("hobitmpsan"), "aocjb", 11, 0, S::npos);
+ test(S("tjehkpsalm"), "jbrnk", 11, 1, S::npos);
+ test(S("ngfbojitcl"), "tqedg", 11, 2, S::npos);
+ test(S("rcfkdbhgjo"), "nqskp", 11, 4, S::npos);
+ test(S("qghptonrea"), "eaqkl", 11, 5, S::npos);
+ test(S("hnprfgqjdl"), "reaoicljqm", 11, 0, S::npos);
+ test(S("hlmgabenti"), "lsftgajqpm", 11, 1, S::npos);
+ test(S("ofcjanmrbs"), "rlpfogmits", 11, 5, S::npos);
+ test(S("jqedtkornm"), "shkncmiaqj", 11, 9, S::npos);
+ test(S("rfedlasjmg"), "fpnatrhqgs", 11, 10, S::npos);
+ test(S("talpqjsgkm"), "sjclemqhnpdbgikarfot", 11, 0, S::npos);
+ test(S("lrkcbtqpie"), "otcmedjikgsfnqbrhpla", 11, 1, S::npos);
+ test(S("cipogdskjf"), "bonsaefdqiprkhlgtjcm", 11, 10, S::npos);
+ test(S("nqedcojahi"), "egpscmahijlfnkrodqtb", 11, 19, S::npos);
+ test(S("hefnrkmctj"), "kmqbfepjthgilscrndoa", 11, 20, S::npos);
+ test(S("atqirnmekfjolhpdsgcb"), "", 0, 0, 0);
+ test(S("echfkmlpribjnqsaogtd"), "prboq", 0, 0, 0);
+ test(S("qnhiftdgcleajbpkrosm"), "fjcqh", 0, 1, 0);
+ test(S("chamfknorbedjitgslpq"), "fmosa", 0, 2, 0);
+ test(S("njhqpibfmtlkaecdrgso"), "qdbok", 0, 4, 0);
+ test(S("ebnghfsqkprmdcljoiat"), "amslg", 0, 5, 0);
+ test(S("letjomsgihfrpqbkancd"), "smpltjneqb", 0, 0, 0);
+ test(S("nblgoipcrqeaktshjdmf"), "flitskrnge", 0, 1, 0);
+ test(S("cehkbngtjoiflqapsmrd"), "pgqihmlbef", 0, 5, 0);
+ test(S("mignapfoklbhcqjetdrs"), "cfpdqjtgsb", 0, 9, 0);
+ test(S("ceatbhlsqjgpnokfrmdi"), "htpsiaflom", 0, 10, 0);
+ test(S("ocihkjgrdelpfnmastqb"), "kpjfiaceghsrdtlbnomq", 0, 0, 0);
+ test(S("noelgschdtbrjfmiqkap"), "qhtbomidljgafneksprc", 0, 1, 0);
+ test(S("dkclqfombepritjnghas"), "nhtjobkcefldimpsaqgr", 0, 10, 0);
+ test(S("miklnresdgbhqcojftap"), "prabcjfqnoeskilmtgdh", 0, 19, 11);
+ test(S("htbcigojaqmdkfrnlsep"), "dtrgmchilkasqoebfpjn", 0, 20, S::npos);
+ test(S("febhmqtjanokscdirpgl"), "", 1, 0, 1);
+ test(S("loakbsqjpcrdhftniegm"), "sqome", 1, 0, 1);
+ test(S("reagphsqflbitdcjmkno"), "smfte", 1, 1, 1);
+ test(S("jitlfrqemsdhkopncabg"), "ciboh", 1, 2, 2);
+ test(S("mhtaepscdnrjqgbkifol"), "haois", 1, 4, 2);
+ test(S("tocesrfmnglpbjihqadk"), "abfki", 1, 5, 1);
+ test(S("lpfmctjrhdagneskbqoi"), "frdkocntmq", 1, 0, 1);
+ test(S("lsmqaepkdhncirbtjfgo"), "oasbpedlnr", 1, 1, 1);
+ test(S("epoiqmtldrabnkjhcfsg"), "kltqmhgand", 1, 5, 1);
+ test(S("emgasrilpknqojhtbdcf"), "gdtfjchpmr", 1, 9, 3);
+ test(S("hnfiagdpcklrjetqbsom"), "ponmcqblet", 1, 10, 2);
+ test(S("nsdfebgajhmtricpoklq"), "sgphqdnofeiklatbcmjr", 1, 0, 1);
+ test(S("atjgfsdlpobmeiqhncrk"), "ljqprsmigtfoneadckbh", 1, 1, 1);
+ test(S("sitodfgnrejlahcbmqkp"), "ligeojhafnkmrcsqtbdp", 1, 10, 2);
+ test(S("fraghmbiceknltjpqosd"), "lsimqfnjarbopedkhcgt", 1, 19, 13);
+ test(S("pmafenlhqtdbkirjsogc"), "abedmfjlghniorcqptks", 1, 20, S::npos);
+ test(S("pihgmoeqtnakrjslcbfd"), "", 10, 0, 10);
+ test(S("gjdkeprctqblnhiafsom"), "hqtoa", 10, 0, 10);
+ test(S("mkpnblfdsahrcqijteog"), "cahif", 10, 1, 10);
+ test(S("gckarqnelodfjhmbptis"), "kehis", 10, 2, 10);
+ test(S("gqpskidtbclomahnrjfe"), "kdlmh", 10, 4, 11);
+ test(S("pkldjsqrfgitbhmaecno"), "paeql", 10, 5, 10);
+ test(S("aftsijrbeklnmcdqhgop"), "aghoqiefnb", 10, 0, 10);
+ test(S("mtlgdrhafjkbiepqnsoc"), "jrbqaikpdo", 10, 1, 10);
+ test(S("pqgirnaefthokdmbsclj"), "smjonaeqcl", 10, 5, 10);
+ test(S("kpdbgjmtherlsfcqoina"), "eqbdrkcfah", 10, 9, 11);
+ test(S("jrlbothiknqmdgcfasep"), "kapmsienhf", 10, 10, 10);
+ test(S("mjogldqferckabinptsh"), "jpqotrlenfcsbhkaimdg", 10, 0, 10);
+ test(S("apoklnefbhmgqcdrisjt"), "jlbmhnfgtcqprikeados", 10, 1, 10);
+ test(S("ifeopcnrjbhkdgatmqls"), "stgbhfmdaljnpqoicker", 10, 10, 11);
+ test(S("ckqhaiesmjdnrgolbtpf"), "oihcetflbjagdsrkmqpn", 10, 19, 11);
+ test(S("bnlgapfimcoterskqdjh"), "adtclebmnpjsrqfkigoh", 10, 20, S::npos);
+ test(S("kgdlrobpmjcthqsafeni"), "", 19, 0, 19);
+ test(S("dfkechomjapgnslbtqir"), "beafg", 19, 0, 19);
+ test(S("rloadknfbqtgmhcsipje"), "iclat", 19, 1, 19);
+ test(S("mgjhkolrnadqbpetcifs"), "rkhnf", 19, 2, 19);
+ test(S("cmlfakiojdrgtbsphqen"), "clshq", 19, 4, 19);
+ test(S("kghbfipeomsntdalrqjc"), "dtcoj", 19, 5, S::npos);
+ test(S("eldiqckrnmtasbghjfpo"), "rqosnjmfth", 19, 0, 19);
+ test(S("abqjcfedgotihlnspkrm"), "siatdfqglh", 19, 1, 19);
+ test(S("qfbadrtjsimkolcenhpg"), "mrlshtpgjq", 19, 5, 19);
+ test(S("abseghclkjqifmtodrnp"), "adlcskgqjt", 19, 9, 19);
+ test(S("ibmsnlrjefhtdokacqpg"), "drshcjknaf", 19, 10, 19);
+ test(S("mrkfciqjebaponsthldg"), "etsaqroinghpkjdlfcbm", 19, 0, 19);
+ test(S("mjkticdeoqshpalrfbgn"), "sgepdnkqliambtrocfhj", 19, 1, 19);
+ test(S("rqnoclbdejgiphtfsakm"), "nlmcjaqgbsortfdihkpe", 19, 10, S::npos);
+ test(S("plkqbhmtfaeodjcrsing"), "racfnpmosldibqkghjet", 19, 19, S::npos);
+ test(S("oegalhmstjrfickpbndq"), "fjhdsctkqeiolagrnmbp", 19, 20, S::npos);
+ test(S("rdtgjcaohpblniekmsfq"), "", 20, 0, S::npos);
+ test(S("ofkqbnjetrmsaidphglc"), "ejanp", 20, 0, S::npos);
+ test(S("grkpahljcftesdmonqib"), "odife", 20, 1, S::npos);
+ test(S("jimlgbhfqkteospardcn"), "okaqd", 20, 2, S::npos);
+ test(S("gftenihpmslrjkqadcob"), "lcdbi", 20, 4, S::npos);
+ test(S("bmhldogtckrfsanijepq"), "fsqbj", 20, 5, S::npos);
+ test(S("nfqkrpjdesabgtlcmoih"), "bigdomnplq", 20, 0, S::npos);
+ test(S("focalnrpiqmdkstehbjg"), "apiblotgcd", 20, 1, S::npos);
+ test(S("rhqdspkmebiflcotnjga"), "acfhdenops", 20, 5, S::npos);
+ test(S("rahdtmsckfboqlpniegj"), "jopdeamcrk", 20, 9, S::npos);
+ test(S("fbkeiopclstmdqranjhg"), "trqncbkgmh", 20, 10, S::npos);
+ test(S("lifhpdgmbconstjeqark"), "tomglrkencbsfjqpihda", 20, 0, S::npos);
+}
+
+template <class S>
+void test3()
+{
+ test(S("pboqganrhedjmltsicfk"), "gbkhdnpoietfcmrslajq", 20, 1, S::npos);
+ test(S("klchabsimetjnqgorfpd"), "rtfnmbsglkjaichoqedp", 20, 10, S::npos);
+ test(S("sirfgmjqhctndbklaepo"), "ohkmdpfqbsacrtjnlgei", 20, 19, S::npos);
+ test(S("rlbdsiceaonqjtfpghkm"), "dlbrteoisgphmkncajfq", 20, 20, S::npos);
+ test(S("ecgdanriptblhjfqskom"), "", 21, 0, S::npos);
+ test(S("fdmiarlpgcskbhoteqjn"), "sjrlo", 21, 0, S::npos);
+ test(S("rlbstjqopignecmfadkh"), "qjpor", 21, 1, S::npos);
+ test(S("grjpqmbshektdolcafni"), "odhfn", 21, 2, S::npos);
+ test(S("sakfcohtqnibprjmlged"), "qtfin", 21, 4, S::npos);
+ test(S("mjtdglasihqpocebrfkn"), "hpqfo", 21, 5, S::npos);
+ test(S("okaplfrntghqbmeicsdj"), "fabmertkos", 21, 0, S::npos);
+ test(S("sahngemrtcjidqbklfpo"), "brqtgkmaej", 21, 1, S::npos);
+ test(S("dlmsipcnekhbgoaftqjr"), "nfrdeihsgl", 21, 5, S::npos);
+ test(S("ahegrmqnoiklpfsdbcjt"), "hlfrosekpi", 21, 9, S::npos);
+ test(S("hdsjbnmlegtkqripacof"), "atgbkrjdsm", 21, 10, S::npos);
+ test(S("pcnedrfjihqbalkgtoms"), "blnrptjgqmaifsdkhoec", 21, 0, S::npos);
+ test(S("qjidealmtpskrbfhocng"), "ctpmdahebfqjgknloris", 21, 1, S::npos);
+ test(S("qeindtagmokpfhsclrbj"), "apnkeqthrmlbfodiscgj", 21, 10, S::npos);
+ test(S("kpfegbjhsrnodltqciam"), "jdgictpframeoqlsbknh", 21, 19, S::npos);
+ test(S("hnbrcplsjfgiktoedmaq"), "qprlsfojamgndekthibc", 21, 20, S::npos);
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test0<S>();
+ test1<S>();
+ test2<S>();
+ test3<S>();
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test0<S>();
+ test1<S>();
+ test2<S>();
+ test3<S>();
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.ops/string_find.first.not.of/string_size.pass.cpp b/test/std/strings/basic.string/string.ops/string_find.first.not.of/string_size.pass.cpp
new file mode 100644
index 000000000000..4fb072fa4744
--- /dev/null
+++ b/test/std/strings/basic.string/string.ops/string_find.first.not.of/string_size.pass.cpp
@@ -0,0 +1,157 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type find_first_not_of(const basic_string& str, size_type pos = 0) const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& s, const S& str, typename S::size_type pos, typename S::size_type x)
+{
+ assert(s.find_first_not_of(str, pos) == x);
+ if (x != S::npos)
+ assert(pos <= x && x < s.size());
+}
+
+template <class S>
+void
+test(const S& s, const S& str, typename S::size_type x)
+{
+ assert(s.find_first_not_of(str) == x);
+ if (x != S::npos)
+ assert(x < s.size());
+}
+
+template <class S>
+void test0()
+{
+ test(S(""), S(""), 0, S::npos);
+ test(S(""), S("laenf"), 0, S::npos);
+ test(S(""), S("pqlnkmbdjo"), 0, S::npos);
+ test(S(""), S("qkamfogpnljdcshbreti"), 0, S::npos);
+ test(S(""), S(""), 1, S::npos);
+ test(S(""), S("bjaht"), 1, S::npos);
+ test(S(""), S("hjlcmgpket"), 1, S::npos);
+ test(S(""), S("htaobedqikfplcgjsmrn"), 1, S::npos);
+ test(S("fodgq"), S(""), 0, 0);
+ test(S("qanej"), S("dfkap"), 0, 0);
+ test(S("clbao"), S("ihqrfebgad"), 0, 0);
+ test(S("mekdn"), S("ngtjfcalbseiqrphmkdo"), 0, S::npos);
+ test(S("srdfq"), S(""), 1, 1);
+ test(S("oemth"), S("ikcrq"), 1, 1);
+ test(S("cdaih"), S("dmajblfhsg"), 1, 3);
+ test(S("qohtk"), S("oqftjhdmkgsblacenirp"), 1, S::npos);
+ test(S("cshmd"), S(""), 2, 2);
+ test(S("lhcdo"), S("oebqi"), 2, 2);
+ test(S("qnsoh"), S("kojhpmbsfe"), 2, S::npos);
+ test(S("pkrof"), S("acbsjqogpltdkhinfrem"), 2, S::npos);
+ test(S("fmtsp"), S(""), 4, 4);
+ test(S("khbpm"), S("aobjd"), 4, 4);
+ test(S("pbsji"), S("pcbahntsje"), 4, 4);
+ test(S("mprdj"), S("fhepcrntkoagbmldqijs"), 4, S::npos);
+ test(S("eqmpa"), S(""), 5, S::npos);
+ test(S("omigs"), S("kocgb"), 5, S::npos);
+ test(S("onmje"), S("fbslrjiqkm"), 5, S::npos);
+ test(S("oqmrj"), S("jeidpcmalhfnqbgtrsko"), 5, S::npos);
+ test(S("schfa"), S(""), 6, S::npos);
+ test(S("igdsc"), S("qngpd"), 6, S::npos);
+ test(S("brqgo"), S("rodhqklgmb"), 6, S::npos);
+ test(S("tnrph"), S("thdjgafrlbkoiqcspmne"), 6, S::npos);
+ test(S("hcjitbfapl"), S(""), 0, 0);
+ test(S("daiprenocl"), S("ashjd"), 0, 2);
+ test(S("litpcfdghe"), S("mgojkldsqh"), 0, 1);
+ test(S("aidjksrolc"), S("imqnaghkfrdtlopbjesc"), 0, S::npos);
+ test(S("qpghtfbaji"), S(""), 1, 1);
+ test(S("gfshlcmdjr"), S("nadkh"), 1, 1);
+ test(S("nkodajteqp"), S("ofdrqmkebl"), 1, 4);
+ test(S("gbmetiprqd"), S("bdfjqgatlksriohemnpc"), 1, S::npos);
+ test(S("crnklpmegd"), S(""), 5, 5);
+ test(S("jsbtafedoc"), S("prqgn"), 5, 5);
+ test(S("qnmodrtkeb"), S("pejafmnokr"), 5, 6);
+ test(S("cpebqsfmnj"), S("odnqkgijrhabfmcestlp"), 5, S::npos);
+ test(S("lmofqdhpki"), S(""), 9, 9);
+ test(S("hnefkqimca"), S("rtjpa"), 9, S::npos);
+ test(S("drtasbgmfp"), S("ktsrmnqagd"), 9, 9);
+ test(S("lsaijeqhtr"), S("rtdhgcisbnmoaqkfpjle"), 9, S::npos);
+ test(S("elgofjmbrq"), S(""), 10, S::npos);
+ test(S("mjqdgalkpc"), S("dplqa"), 10, S::npos);
+ test(S("kthqnfcerm"), S("dkacjoptns"), 10, S::npos);
+ test(S("dfsjhanorc"), S("hqfimtrgnbekpdcsjalo"), 10, S::npos);
+ test(S("eqsgalomhb"), S(""), 11, S::npos);
+ test(S("akiteljmoh"), S("lofbc"), 11, S::npos);
+ test(S("hlbdfreqjo"), S("astoegbfpn"), 11, S::npos);
+ test(S("taqobhlerg"), S("pdgreqomsncafklhtibj"), 11, S::npos);
+ test(S("snafbdlghrjkpqtoceim"), S(""), 0, 0);
+ test(S("aemtbrgcklhndjisfpoq"), S("lbtqd"), 0, 0);
+ test(S("pnracgfkjdiholtbqsem"), S("tboimldpjh"), 0, 1);
+ test(S("dicfltehbsgrmojnpkaq"), S("slcerthdaiqjfnobgkpm"), 0, S::npos);
+ test(S("jlnkraeodhcspfgbqitm"), S(""), 1, 1);
+ test(S("lhosrngtmfjikbqpcade"), S("aqibs"), 1, 1);
+ test(S("rbtaqjhgkneisldpmfoc"), S("gtfblmqinc"), 1, 3);
+ test(S("gpifsqlrdkbonjtmheca"), S("mkqpbtdalgniorhfescj"), 1, S::npos);
+ test(S("hdpkobnsalmcfijregtq"), S(""), 10, 10);
+ test(S("jtlshdgqaiprkbcoenfm"), S("pblas"), 10, 11);
+ test(S("fkdrbqltsgmcoiphneaj"), S("arosdhcfme"), 10, 13);
+ test(S("crsplifgtqedjohnabmk"), S("blkhjeogicatqfnpdmsr"), 10, S::npos);
+ test(S("niptglfbosehkamrdqcj"), S(""), 19, 19);
+ test(S("copqdhstbingamjfkler"), S("djkqc"), 19, 19);
+ test(S("mrtaefilpdsgocnhqbjk"), S("lgokshjtpb"), 19, S::npos);
+ test(S("kojatdhlcmigpbfrqnes"), S("bqjhtkfepimcnsgrlado"), 19, S::npos);
+ test(S("eaintpchlqsbdgrkjofm"), S(""), 20, S::npos);
+ test(S("gjnhidfsepkrtaqbmclo"), S("nocfa"), 20, S::npos);
+ test(S("spocfaktqdbiejlhngmr"), S("bgtajmiedc"), 20, S::npos);
+ test(S("rphmlekgfscndtaobiqj"), S("lsckfnqgdahejiopbtmr"), 20, S::npos);
+ test(S("liatsqdoegkmfcnbhrpj"), S(""), 21, S::npos);
+ test(S("binjagtfldkrspcomqeh"), S("gfsrt"), 21, S::npos);
+ test(S("latkmisecnorjbfhqpdg"), S("pfsocbhjtm"), 21, S::npos);
+ test(S("lecfratdjkhnsmqpoigb"), S("tpflmdnoicjgkberhqsa"), 21, S::npos);
+}
+
+template <class S>
+void test1()
+{
+ test(S(""), S(""), S::npos);
+ test(S(""), S("laenf"), S::npos);
+ test(S(""), S("pqlnkmbdjo"), S::npos);
+ test(S(""), S("qkamfogpnljdcshbreti"), S::npos);
+ test(S("nhmko"), S(""), 0);
+ test(S("lahfb"), S("irkhs"), 0);
+ test(S("gmfhd"), S("kantesmpgj"), 2);
+ test(S("odaft"), S("oknlrstdpiqmjbaghcfe"), S::npos);
+ test(S("eolhfgpjqk"), S(""), 0);
+ test(S("nbatdlmekr"), S("bnrpe"), 2);
+ test(S("jdmciepkaq"), S("jtdaefblso"), 2);
+ test(S("hkbgspoflt"), S("oselktgbcapndfjihrmq"), S::npos);
+ test(S("gprdcokbnjhlsfmtieqa"), S(""), 0);
+ test(S("qjghlnftcaismkropdeb"), S("bjaht"), 0);
+ test(S("pnalfrdtkqcmojiesbhg"), S("hjlcmgpket"), 1);
+ test(S("pniotcfrhqsmgdkjbael"), S("htaobedqikfplcgjsmrn"), S::npos);
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test0<S>();
+ test1<S>();
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test0<S>();
+ test1<S>();
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.ops/string_find.first.of/char_size.pass.cpp b/test/std/strings/basic.string/string.ops/string_find.first.of/char_size.pass.cpp
new file mode 100644
index 000000000000..32d0e86f3d84
--- /dev/null
+++ b/test/std/strings/basic.string/string.ops/string_find.first.of/char_size.pass.cpp
@@ -0,0 +1,98 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type find_first_of(charT c, size_type pos = 0) const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& s, typename S::value_type c, typename S::size_type pos,
+ typename S::size_type x)
+{
+ assert(s.find_first_of(c, pos) == x);
+ if (x != S::npos)
+ assert(pos <= x && x < s.size());
+}
+
+template <class S>
+void
+test(const S& s, typename S::value_type c, typename S::size_type x)
+{
+ assert(s.find_first_of(c) == x);
+ if (x != S::npos)
+ assert(x < s.size());
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test(S(""), 'e', 0, S::npos);
+ test(S(""), 'e', 1, S::npos);
+ test(S("kitcj"), 'e', 0, S::npos);
+ test(S("qkamf"), 'e', 1, S::npos);
+ test(S("nhmko"), 'e', 2, S::npos);
+ test(S("tpsaf"), 'e', 4, S::npos);
+ test(S("lahfb"), 'e', 5, S::npos);
+ test(S("irkhs"), 'e', 6, S::npos);
+ test(S("gmfhdaipsr"), 'e', 0, S::npos);
+ test(S("kantesmpgj"), 'e', 1, 4);
+ test(S("odaftiegpm"), 'e', 5, 6);
+ test(S("oknlrstdpi"), 'e', 9, S::npos);
+ test(S("eolhfgpjqk"), 'e', 10, S::npos);
+ test(S("pcdrofikas"), 'e', 11, S::npos);
+ test(S("nbatdlmekrgcfqsophij"), 'e', 0, 7);
+ test(S("bnrpehidofmqtcksjgla"), 'e', 1, 4);
+ test(S("jdmciepkaqgotsrfnhlb"), 'e', 10, S::npos);
+ test(S("jtdaefblsokrmhpgcnqi"), 'e', 19, S::npos);
+ test(S("hkbgspofltajcnedqmri"), 'e', 20, S::npos);
+ test(S("oselktgbcapndfjihrmq"), 'e', 21, S::npos);
+
+ test(S(""), 'e', S::npos);
+ test(S("csope"), 'e', 4);
+ test(S("gfsmthlkon"), 'e', S::npos);
+ test(S("laenfsbridchgotmkqpj"), 'e', 2);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S(""), 'e', 0, S::npos);
+ test(S(""), 'e', 1, S::npos);
+ test(S("kitcj"), 'e', 0, S::npos);
+ test(S("qkamf"), 'e', 1, S::npos);
+ test(S("nhmko"), 'e', 2, S::npos);
+ test(S("tpsaf"), 'e', 4, S::npos);
+ test(S("lahfb"), 'e', 5, S::npos);
+ test(S("irkhs"), 'e', 6, S::npos);
+ test(S("gmfhdaipsr"), 'e', 0, S::npos);
+ test(S("kantesmpgj"), 'e', 1, 4);
+ test(S("odaftiegpm"), 'e', 5, 6);
+ test(S("oknlrstdpi"), 'e', 9, S::npos);
+ test(S("eolhfgpjqk"), 'e', 10, S::npos);
+ test(S("pcdrofikas"), 'e', 11, S::npos);
+ test(S("nbatdlmekrgcfqsophij"), 'e', 0, 7);
+ test(S("bnrpehidofmqtcksjgla"), 'e', 1, 4);
+ test(S("jdmciepkaqgotsrfnhlb"), 'e', 10, S::npos);
+ test(S("jtdaefblsokrmhpgcnqi"), 'e', 19, S::npos);
+ test(S("hkbgspofltajcnedqmri"), 'e', 20, S::npos);
+ test(S("oselktgbcapndfjihrmq"), 'e', 21, S::npos);
+
+ test(S(""), 'e', S::npos);
+ test(S("csope"), 'e', 4);
+ test(S("gfsmthlkon"), 'e', S::npos);
+ test(S("laenfsbridchgotmkqpj"), 'e', 2);
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.ops/string_find.first.of/pointer_size.pass.cpp b/test/std/strings/basic.string/string.ops/string_find.first.of/pointer_size.pass.cpp
new file mode 100644
index 000000000000..6dd176df0165
--- /dev/null
+++ b/test/std/strings/basic.string/string.ops/string_find.first.of/pointer_size.pass.cpp
@@ -0,0 +1,158 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type find_first_of(const charT* s, size_type pos = 0) const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type pos,
+ typename S::size_type x)
+{
+ assert(s.find_first_of(str, pos) == x);
+ if (x != S::npos)
+ assert(pos <= x && x < s.size());
+}
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type x)
+{
+ assert(s.find_first_of(str) == x);
+ if (x != S::npos)
+ assert(x < s.size());
+}
+
+template <class S>
+void test0()
+{
+ test(S(""), "", 0, S::npos);
+ test(S(""), "laenf", 0, S::npos);
+ test(S(""), "pqlnkmbdjo", 0, S::npos);
+ test(S(""), "qkamfogpnljdcshbreti", 0, S::npos);
+ test(S(""), "", 1, S::npos);
+ test(S(""), "bjaht", 1, S::npos);
+ test(S(""), "hjlcmgpket", 1, S::npos);
+ test(S(""), "htaobedqikfplcgjsmrn", 1, S::npos);
+ test(S("fodgq"), "", 0, S::npos);
+ test(S("qanej"), "dfkap", 0, 1);
+ test(S("clbao"), "ihqrfebgad", 0, 2);
+ test(S("mekdn"), "ngtjfcalbseiqrphmkdo", 0, 0);
+ test(S("srdfq"), "", 1, S::npos);
+ test(S("oemth"), "ikcrq", 1, S::npos);
+ test(S("cdaih"), "dmajblfhsg", 1, 1);
+ test(S("qohtk"), "oqftjhdmkgsblacenirp", 1, 1);
+ test(S("cshmd"), "", 2, S::npos);
+ test(S("lhcdo"), "oebqi", 2, 4);
+ test(S("qnsoh"), "kojhpmbsfe", 2, 2);
+ test(S("pkrof"), "acbsjqogpltdkhinfrem", 2, 2);
+ test(S("fmtsp"), "", 4, S::npos);
+ test(S("khbpm"), "aobjd", 4, S::npos);
+ test(S("pbsji"), "pcbahntsje", 4, S::npos);
+ test(S("mprdj"), "fhepcrntkoagbmldqijs", 4, 4);
+ test(S("eqmpa"), "", 5, S::npos);
+ test(S("omigs"), "kocgb", 5, S::npos);
+ test(S("onmje"), "fbslrjiqkm", 5, S::npos);
+ test(S("oqmrj"), "jeidpcmalhfnqbgtrsko", 5, S::npos);
+ test(S("schfa"), "", 6, S::npos);
+ test(S("igdsc"), "qngpd", 6, S::npos);
+ test(S("brqgo"), "rodhqklgmb", 6, S::npos);
+ test(S("tnrph"), "thdjgafrlbkoiqcspmne", 6, S::npos);
+ test(S("hcjitbfapl"), "", 0, S::npos);
+ test(S("daiprenocl"), "ashjd", 0, 0);
+ test(S("litpcfdghe"), "mgojkldsqh", 0, 0);
+ test(S("aidjksrolc"), "imqnaghkfrdtlopbjesc", 0, 0);
+ test(S("qpghtfbaji"), "", 1, S::npos);
+ test(S("gfshlcmdjr"), "nadkh", 1, 3);
+ test(S("nkodajteqp"), "ofdrqmkebl", 1, 1);
+ test(S("gbmetiprqd"), "bdfjqgatlksriohemnpc", 1, 1);
+ test(S("crnklpmegd"), "", 5, S::npos);
+ test(S("jsbtafedoc"), "prqgn", 5, S::npos);
+ test(S("qnmodrtkeb"), "pejafmnokr", 5, 5);
+ test(S("cpebqsfmnj"), "odnqkgijrhabfmcestlp", 5, 5);
+ test(S("lmofqdhpki"), "", 9, S::npos);
+ test(S("hnefkqimca"), "rtjpa", 9, 9);
+ test(S("drtasbgmfp"), "ktsrmnqagd", 9, S::npos);
+ test(S("lsaijeqhtr"), "rtdhgcisbnmoaqkfpjle", 9, 9);
+ test(S("elgofjmbrq"), "", 10, S::npos);
+ test(S("mjqdgalkpc"), "dplqa", 10, S::npos);
+ test(S("kthqnfcerm"), "dkacjoptns", 10, S::npos);
+ test(S("dfsjhanorc"), "hqfimtrgnbekpdcsjalo", 10, S::npos);
+ test(S("eqsgalomhb"), "", 11, S::npos);
+ test(S("akiteljmoh"), "lofbc", 11, S::npos);
+ test(S("hlbdfreqjo"), "astoegbfpn", 11, S::npos);
+ test(S("taqobhlerg"), "pdgreqomsncafklhtibj", 11, S::npos);
+ test(S("snafbdlghrjkpqtoceim"), "", 0, S::npos);
+ test(S("aemtbrgcklhndjisfpoq"), "lbtqd", 0, 3);
+ test(S("pnracgfkjdiholtbqsem"), "tboimldpjh", 0, 0);
+ test(S("dicfltehbsgrmojnpkaq"), "slcerthdaiqjfnobgkpm", 0, 0);
+ test(S("jlnkraeodhcspfgbqitm"), "", 1, S::npos);
+ test(S("lhosrngtmfjikbqpcade"), "aqibs", 1, 3);
+ test(S("rbtaqjhgkneisldpmfoc"), "gtfblmqinc", 1, 1);
+ test(S("gpifsqlrdkbonjtmheca"), "mkqpbtdalgniorhfescj", 1, 1);
+ test(S("hdpkobnsalmcfijregtq"), "", 10, S::npos);
+ test(S("jtlshdgqaiprkbcoenfm"), "pblas", 10, 10);
+ test(S("fkdrbqltsgmcoiphneaj"), "arosdhcfme", 10, 10);
+ test(S("crsplifgtqedjohnabmk"), "blkhjeogicatqfnpdmsr", 10, 10);
+ test(S("niptglfbosehkamrdqcj"), "", 19, S::npos);
+ test(S("copqdhstbingamjfkler"), "djkqc", 19, S::npos);
+ test(S("mrtaefilpdsgocnhqbjk"), "lgokshjtpb", 19, 19);
+ test(S("kojatdhlcmigpbfrqnes"), "bqjhtkfepimcnsgrlado", 19, 19);
+ test(S("eaintpchlqsbdgrkjofm"), "", 20, S::npos);
+ test(S("gjnhidfsepkrtaqbmclo"), "nocfa", 20, S::npos);
+ test(S("spocfaktqdbiejlhngmr"), "bgtajmiedc", 20, S::npos);
+ test(S("rphmlekgfscndtaobiqj"), "lsckfnqgdahejiopbtmr", 20, S::npos);
+ test(S("liatsqdoegkmfcnbhrpj"), "", 21, S::npos);
+ test(S("binjagtfldkrspcomqeh"), "gfsrt", 21, S::npos);
+ test(S("latkmisecnorjbfhqpdg"), "pfsocbhjtm", 21, S::npos);
+ test(S("lecfratdjkhnsmqpoigb"), "tpflmdnoicjgkberhqsa", 21, S::npos);
+}
+
+template <class S>
+void test1()
+{
+ test(S(""), "", S::npos);
+ test(S(""), "laenf", S::npos);
+ test(S(""), "pqlnkmbdjo", S::npos);
+ test(S(""), "qkamfogpnljdcshbreti", S::npos);
+ test(S("nhmko"), "", S::npos);
+ test(S("lahfb"), "irkhs", 2);
+ test(S("gmfhd"), "kantesmpgj", 0);
+ test(S("odaft"), "oknlrstdpiqmjbaghcfe", 0);
+ test(S("eolhfgpjqk"), "", S::npos);
+ test(S("nbatdlmekr"), "bnrpe", 0);
+ test(S("jdmciepkaq"), "jtdaefblso", 0);
+ test(S("hkbgspoflt"), "oselktgbcapndfjihrmq", 0);
+ test(S("gprdcokbnjhlsfmtieqa"), "", S::npos);
+ test(S("qjghlnftcaismkropdeb"), "bjaht", 1);
+ test(S("pnalfrdtkqcmojiesbhg"), "hjlcmgpket", 0);
+ test(S("pniotcfrhqsmgdkjbael"), "htaobedqikfplcgjsmrn", 0);
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test0<S>();
+ test1<S>();
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test0<S>();
+ test1<S>();
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.ops/string_find.first.of/pointer_size_size.pass.cpp b/test/std/strings/basic.string/string.ops/string_find.first.of/pointer_size_size.pass.cpp
new file mode 100644
index 000000000000..9e98a6ad20f7
--- /dev/null
+++ b/test/std/strings/basic.string/string.ops/string_find.first.of/pointer_size_size.pass.cpp
@@ -0,0 +1,387 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type find_first_of(const charT* s, size_type pos, size_type n) const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type pos,
+ typename S::size_type n, typename S::size_type x)
+{
+ assert(s.find_first_of(str, pos, n) == x);
+ if (x != S::npos)
+ assert(pos <= x && x < s.size());
+}
+
+template <class S>
+void test0()
+{
+ test(S(""), "", 0, 0, S::npos);
+ test(S(""), "irkhs", 0, 0, S::npos);
+ test(S(""), "kante", 0, 1, S::npos);
+ test(S(""), "oknlr", 0, 2, S::npos);
+ test(S(""), "pcdro", 0, 4, S::npos);
+ test(S(""), "bnrpe", 0, 5, S::npos);
+ test(S(""), "jtdaefblso", 0, 0, S::npos);
+ test(S(""), "oselktgbca", 0, 1, S::npos);
+ test(S(""), "eqgaplhckj", 0, 5, S::npos);
+ test(S(""), "bjahtcmnlp", 0, 9, S::npos);
+ test(S(""), "hjlcmgpket", 0, 10, S::npos);
+ test(S(""), "htaobedqikfplcgjsmrn", 0, 0, S::npos);
+ test(S(""), "hpqiarojkcdlsgnmfetb", 0, 1, S::npos);
+ test(S(""), "dfkaprhjloqetcsimnbg", 0, 10, S::npos);
+ test(S(""), "ihqrfebgadntlpmjksoc", 0, 19, S::npos);
+ test(S(""), "ngtjfcalbseiqrphmkdo", 0, 20, S::npos);
+ test(S(""), "", 1, 0, S::npos);
+ test(S(""), "lbtqd", 1, 0, S::npos);
+ test(S(""), "tboim", 1, 1, S::npos);
+ test(S(""), "slcer", 1, 2, S::npos);
+ test(S(""), "cbjfs", 1, 4, S::npos);
+ test(S(""), "aqibs", 1, 5, S::npos);
+ test(S(""), "gtfblmqinc", 1, 0, S::npos);
+ test(S(""), "mkqpbtdalg", 1, 1, S::npos);
+ test(S(""), "kphatlimcd", 1, 5, S::npos);
+ test(S(""), "pblasqogic", 1, 9, S::npos);
+ test(S(""), "arosdhcfme", 1, 10, S::npos);
+ test(S(""), "blkhjeogicatqfnpdmsr", 1, 0, S::npos);
+ test(S(""), "bmhineprjcoadgstflqk", 1, 1, S::npos);
+ test(S(""), "djkqcmetslnghpbarfoi", 1, 10, S::npos);
+ test(S(""), "lgokshjtpbemarcdqnfi", 1, 19, S::npos);
+ test(S(""), "bqjhtkfepimcnsgrlado", 1, 20, S::npos);
+ test(S("eaint"), "", 0, 0, S::npos);
+ test(S("binja"), "gfsrt", 0, 0, S::npos);
+ test(S("latkm"), "pfsoc", 0, 1, S::npos);
+ test(S("lecfr"), "tpflm", 0, 2, S::npos);
+ test(S("eqkst"), "sgkec", 0, 4, 0);
+ test(S("cdafr"), "romds", 0, 5, 1);
+ test(S("prbhe"), "qhjistlgmr", 0, 0, S::npos);
+ test(S("lbisk"), "pedfirsglo", 0, 1, S::npos);
+ test(S("hrlpd"), "aqcoslgrmk", 0, 5, S::npos);
+ test(S("ehmja"), "dabckmepqj", 0, 9, 0);
+ test(S("mhqgd"), "pqscrjthli", 0, 10, 1);
+ test(S("tgklq"), "kfphdcsjqmobliagtren", 0, 0, S::npos);
+ test(S("bocjs"), "rokpefncljibsdhqtagm", 0, 1, S::npos);
+ test(S("grbsd"), "afionmkphlebtcjqsgrd", 0, 10, S::npos);
+ test(S("ofjqr"), "aenmqplidhkofrjbctsg", 0, 19, 0);
+ test(S("btlfi"), "osjmbtcadhiklegrpqnf", 0, 20, 0);
+ test(S("clrgb"), "", 1, 0, S::npos);
+ test(S("tjmek"), "osmia", 1, 0, S::npos);
+ test(S("bgstp"), "ckonl", 1, 1, S::npos);
+ test(S("hstrk"), "ilcaj", 1, 2, S::npos);
+ test(S("kmspj"), "lasiq", 1, 4, 2);
+ test(S("tjboh"), "kfqmr", 1, 5, S::npos);
+ test(S("ilbcj"), "klnitfaobg", 1, 0, S::npos);
+ test(S("jkngf"), "gjhmdlqikp", 1, 1, 3);
+ test(S("gfcql"), "skbgtahqej", 1, 5, S::npos);
+ test(S("dqtlg"), "bjsdgtlpkf", 1, 9, 2);
+ test(S("bthpg"), "bjgfmnlkio", 1, 10, 4);
+ test(S("dgsnq"), "lbhepotfsjdqigcnamkr", 1, 0, S::npos);
+ test(S("rmfhp"), "tebangckmpsrqdlfojhi", 1, 1, S::npos);
+ test(S("jfdam"), "joflqbdkhtegimscpanr", 1, 10, 1);
+ test(S("edapb"), "adpmcohetfbsrjinlqkg", 1, 19, 1);
+ test(S("brfsm"), "iacldqjpfnogbsrhmetk", 1, 20, 1);
+ test(S("ndrhl"), "", 2, 0, S::npos);
+ test(S("mrecp"), "otkgb", 2, 0, S::npos);
+ test(S("qlasf"), "cqsjl", 2, 1, S::npos);
+ test(S("smaqd"), "dpifl", 2, 2, 4);
+ test(S("hjeni"), "oapht", 2, 4, S::npos);
+ test(S("ocmfj"), "cifts", 2, 5, 3);
+ test(S("hmftq"), "nmsckbgalo", 2, 0, S::npos);
+ test(S("fklad"), "tpksqhamle", 2, 1, S::npos);
+ test(S("dirnm"), "tpdrchmkji", 2, 5, 2);
+ test(S("hrgdc"), "ijagfkblst", 2, 9, 2);
+ test(S("ifakg"), "kpocsignjb", 2, 10, 3);
+ test(S("ebrgd"), "pecqtkjsnbdrialgmohf", 2, 0, S::npos);
+ test(S("rcjml"), "aiortphfcmkjebgsndql", 2, 1, S::npos);
+ test(S("peqmt"), "sdbkeamglhipojqftrcn", 2, 10, 3);
+ test(S("frehn"), "ljqncehgmfktroapidbs", 2, 19, 2);
+ test(S("tqolf"), "rtcfodilamkbenjghqps", 2, 20, 2);
+ test(S("cjgao"), "", 4, 0, S::npos);
+ test(S("kjplq"), "mabns", 4, 0, S::npos);
+ test(S("herni"), "bdnrp", 4, 1, S::npos);
+ test(S("tadrb"), "scidp", 4, 2, S::npos);
+ test(S("pkfeo"), "agbjl", 4, 4, S::npos);
+ test(S("hoser"), "jfmpr", 4, 5, 4);
+ test(S("kgrsp"), "rbpefghsmj", 4, 0, S::npos);
+ test(S("pgejb"), "apsfntdoqc", 4, 1, S::npos);
+ test(S("thlnq"), "ndkjeisgcl", 4, 5, S::npos);
+ test(S("nbmit"), "rnfpqatdeo", 4, 9, 4);
+ test(S("jgmib"), "bntjlqrfik", 4, 10, 4);
+ test(S("ncrfj"), "kcrtmpolnaqejghsfdbi", 4, 0, S::npos);
+ test(S("ncsik"), "lobheanpkmqidsrtcfgj", 4, 1, S::npos);
+ test(S("sgbfh"), "athdkljcnreqbgpmisof", 4, 10, 4);
+ test(S("dktbn"), "qkdmjialrscpbhefgont", 4, 19, 4);
+ test(S("fthqm"), "dmasojntqleribkgfchp", 4, 20, 4);
+ test(S("klopi"), "", 5, 0, S::npos);
+ test(S("dajhn"), "psthd", 5, 0, S::npos);
+ test(S("jbgno"), "rpmjd", 5, 1, S::npos);
+ test(S("hkjae"), "dfsmk", 5, 2, S::npos);
+}
+
+template <class S>
+void test1()
+{
+ test(S("gbhqo"), "skqne", 5, 4, S::npos);
+ test(S("ktdor"), "kipnf", 5, 5, S::npos);
+ test(S("ldprn"), "hmrnqdgifl", 5, 0, S::npos);
+ test(S("egmjk"), "fsmjcdairn", 5, 1, S::npos);
+ test(S("armql"), "pcdgltbrfj", 5, 5, S::npos);
+ test(S("cdhjo"), "aekfctpirg", 5, 9, S::npos);
+ test(S("jcons"), "ledihrsgpf", 5, 10, S::npos);
+ test(S("cbrkp"), "mqcklahsbtirgopefndj", 5, 0, S::npos);
+ test(S("fhgna"), "kmlthaoqgecrnpdbjfis", 5, 1, S::npos);
+ test(S("ejfcd"), "sfhbamcdptojlkrenqgi", 5, 10, S::npos);
+ test(S("kqjhe"), "pbniofmcedrkhlstgaqj", 5, 19, S::npos);
+ test(S("pbdjl"), "mongjratcskbhqiepfdl", 5, 20, S::npos);
+ test(S("gajqn"), "", 6, 0, S::npos);
+ test(S("stedk"), "hrnat", 6, 0, S::npos);
+ test(S("tjkaf"), "gsqdt", 6, 1, S::npos);
+ test(S("dthpe"), "bspkd", 6, 2, S::npos);
+ test(S("klhde"), "ohcmb", 6, 4, S::npos);
+ test(S("bhlki"), "heatr", 6, 5, S::npos);
+ test(S("lqmoh"), "pmblckedfn", 6, 0, S::npos);
+ test(S("mtqin"), "aceqmsrbik", 6, 1, S::npos);
+ test(S("dpqbr"), "lmbtdehjrn", 6, 5, S::npos);
+ test(S("kdhmo"), "teqmcrlgib", 6, 9, S::npos);
+ test(S("jblqp"), "njolbmspac", 6, 10, S::npos);
+ test(S("qmjgl"), "pofnhidklamecrbqjgst", 6, 0, S::npos);
+ test(S("rothp"), "jbhckmtgrqnosafedpli", 6, 1, S::npos);
+ test(S("ghknq"), "dobntpmqklicsahgjerf", 6, 10, S::npos);
+ test(S("eopfi"), "tpdshainjkbfoemlrgcq", 6, 19, S::npos);
+ test(S("dsnmg"), "oldpfgeakrnitscbjmqh", 6, 20, S::npos);
+ test(S("jnkrfhotgl"), "", 0, 0, S::npos);
+ test(S("dltjfngbko"), "rqegt", 0, 0, S::npos);
+ test(S("bmjlpkiqde"), "dashm", 0, 1, 8);
+ test(S("skrflobnqm"), "jqirk", 0, 2, 8);
+ test(S("jkpldtshrm"), "rckeg", 0, 4, 1);
+ test(S("ghasdbnjqo"), "jscie", 0, 5, 3);
+ test(S("igrkhpbqjt"), "efsphndliq", 0, 0, S::npos);
+ test(S("ikthdgcamf"), "gdicosleja", 0, 1, 5);
+ test(S("pcofgeniam"), "qcpjibosfl", 0, 5, 0);
+ test(S("rlfjgesqhc"), "lrhmefnjcq", 0, 9, 0);
+ test(S("itphbqsker"), "dtablcrseo", 0, 10, 1);
+ test(S("skjafcirqm"), "apckjsftedbhgomrnilq", 0, 0, S::npos);
+ test(S("tcqomarsfd"), "pcbrgflehjtiadnsokqm", 0, 1, S::npos);
+ test(S("rocfeldqpk"), "nsiadegjklhobrmtqcpf", 0, 10, 4);
+ test(S("cfpegndlkt"), "cpmajdqnolikhgsbretf", 0, 19, 0);
+ test(S("fqbtnkeasj"), "jcflkntmgiqrphdosaeb", 0, 20, 0);
+ test(S("shbcqnmoar"), "", 1, 0, S::npos);
+ test(S("bdoshlmfin"), "ontrs", 1, 0, S::npos);
+ test(S("khfrebnsgq"), "pfkna", 1, 1, S::npos);
+ test(S("getcrsaoji"), "ekosa", 1, 2, 1);
+ test(S("fjiknedcpq"), "anqhk", 1, 4, 4);
+ test(S("tkejgnafrm"), "jekca", 1, 5, 1);
+ test(S("jnakolqrde"), "ikemsjgacf", 1, 0, S::npos);
+ test(S("lcjptsmgbe"), "arolgsjkhm", 1, 1, S::npos);
+ test(S("itfsmcjorl"), "oftkbldhre", 1, 5, 1);
+ test(S("omchkfrjea"), "gbkqdoeftl", 1, 9, 4);
+ test(S("cigfqkated"), "sqcflrgtim", 1, 10, 1);
+ test(S("tscenjikml"), "fmhbkislrjdpanogqcet", 1, 0, S::npos);
+ test(S("qcpaemsinf"), "rnioadktqlgpbcjsmhef", 1, 1, S::npos);
+ test(S("gltkojeipd"), "oakgtnldpsefihqmjcbr", 1, 10, 1);
+ test(S("qistfrgnmp"), "gbnaelosidmcjqktfhpr", 1, 19, 1);
+ test(S("bdnpfcqaem"), "akbripjhlosndcmqgfet", 1, 20, 1);
+ test(S("ectnhskflp"), "", 5, 0, S::npos);
+ test(S("fgtianblpq"), "pijag", 5, 0, S::npos);
+ test(S("mfeqklirnh"), "jrckd", 5, 1, S::npos);
+ test(S("astedncjhk"), "qcloh", 5, 2, 6);
+ test(S("fhlqgcajbr"), "thlmp", 5, 4, S::npos);
+ test(S("epfhocmdng"), "qidmo", 5, 5, 6);
+ test(S("apcnsibger"), "lnegpsjqrd", 5, 0, S::npos);
+ test(S("aqkocrbign"), "rjqdablmfs", 5, 1, 5);
+ test(S("ijsmdtqgce"), "enkgpbsjaq", 5, 5, 7);
+ test(S("clobgsrken"), "kdsgoaijfh", 5, 9, 5);
+ test(S("jbhcfposld"), "trfqgmckbe", 5, 10, S::npos);
+ test(S("oqnpblhide"), "igetsracjfkdnpoblhqm", 5, 0, S::npos);
+ test(S("lroeasctif"), "nqctfaogirshlekbdjpm", 5, 1, S::npos);
+ test(S("bpjlgmiedh"), "csehfgomljdqinbartkp", 5, 10, 5);
+ test(S("pamkeoidrj"), "qahoegcmplkfsjbdnitr", 5, 19, 5);
+ test(S("espogqbthk"), "dpteiajrqmsognhlfbkc", 5, 20, 5);
+ test(S("shoiedtcjb"), "", 9, 0, S::npos);
+ test(S("ebcinjgads"), "tqbnh", 9, 0, S::npos);
+ test(S("dqmregkcfl"), "akmle", 9, 1, S::npos);
+ test(S("ngcrieqajf"), "iqfkm", 9, 2, S::npos);
+ test(S("qosmilgnjb"), "tqjsr", 9, 4, S::npos);
+ test(S("ikabsjtdfl"), "jplqg", 9, 5, 9);
+ test(S("ersmicafdh"), "oilnrbcgtj", 9, 0, S::npos);
+ test(S("fdnplotmgh"), "morkglpesn", 9, 1, S::npos);
+ test(S("fdbicojerm"), "dmicerngat", 9, 5, 9);
+ test(S("mbtafndjcq"), "radgeskbtc", 9, 9, S::npos);
+ test(S("mlenkpfdtc"), "ljikprsmqo", 9, 10, S::npos);
+ test(S("ahlcifdqgs"), "trqihkcgsjamfdbolnpe", 9, 0, S::npos);
+ test(S("bgjemaltks"), "lqmthbsrekajgnofcipd", 9, 1, S::npos);
+ test(S("pdhslbqrfc"), "jtalmedribkgqsopcnfh", 9, 10, S::npos);
+ test(S("dirhtsnjkc"), "spqfoiclmtagejbndkrh", 9, 19, 9);
+ test(S("dlroktbcja"), "nmotklspigjrdhcfaebq", 9, 20, 9);
+ test(S("ncjpmaekbs"), "", 10, 0, S::npos);
+ test(S("hlbosgmrak"), "hpmsd", 10, 0, S::npos);
+ test(S("pqfhsgilen"), "qnpor", 10, 1, S::npos);
+ test(S("gqtjsbdckh"), "otdma", 10, 2, S::npos);
+ test(S("cfkqpjlegi"), "efhjg", 10, 4, S::npos);
+ test(S("beanrfodgj"), "odpte", 10, 5, S::npos);
+ test(S("adtkqpbjfi"), "bctdgfmolr", 10, 0, S::npos);
+ test(S("iomkfthagj"), "oaklidrbqg", 10, 1, S::npos);
+}
+
+template <class S>
+void test2()
+{
+ test(S("sdpcilonqj"), "dnjfsagktr", 10, 5, S::npos);
+ test(S("gtfbdkqeml"), "nejaktmiqg", 10, 9, S::npos);
+ test(S("bmeqgcdorj"), "pjqonlebsf", 10, 10, S::npos);
+ test(S("etqlcanmob"), "dshmnbtolcjepgaikfqr", 10, 0, S::npos);
+ test(S("roqmkbdtia"), "iogfhpabtjkqlrnemcds", 10, 1, S::npos);
+ test(S("kadsithljf"), "ngridfabjsecpqltkmoh", 10, 10, S::npos);
+ test(S("sgtkpbfdmh"), "athmknplcgofrqejsdib", 10, 19, S::npos);
+ test(S("qgmetnabkl"), "ldobhmqcafnjtkeisgrp", 10, 20, S::npos);
+ test(S("cqjohampgd"), "", 11, 0, S::npos);
+ test(S("hobitmpsan"), "aocjb", 11, 0, S::npos);
+ test(S("tjehkpsalm"), "jbrnk", 11, 1, S::npos);
+ test(S("ngfbojitcl"), "tqedg", 11, 2, S::npos);
+ test(S("rcfkdbhgjo"), "nqskp", 11, 4, S::npos);
+ test(S("qghptonrea"), "eaqkl", 11, 5, S::npos);
+ test(S("hnprfgqjdl"), "reaoicljqm", 11, 0, S::npos);
+ test(S("hlmgabenti"), "lsftgajqpm", 11, 1, S::npos);
+ test(S("ofcjanmrbs"), "rlpfogmits", 11, 5, S::npos);
+ test(S("jqedtkornm"), "shkncmiaqj", 11, 9, S::npos);
+ test(S("rfedlasjmg"), "fpnatrhqgs", 11, 10, S::npos);
+ test(S("talpqjsgkm"), "sjclemqhnpdbgikarfot", 11, 0, S::npos);
+ test(S("lrkcbtqpie"), "otcmedjikgsfnqbrhpla", 11, 1, S::npos);
+ test(S("cipogdskjf"), "bonsaefdqiprkhlgtjcm", 11, 10, S::npos);
+ test(S("nqedcojahi"), "egpscmahijlfnkrodqtb", 11, 19, S::npos);
+ test(S("hefnrkmctj"), "kmqbfepjthgilscrndoa", 11, 20, S::npos);
+ test(S("atqirnmekfjolhpdsgcb"), "", 0, 0, S::npos);
+ test(S("echfkmlpribjnqsaogtd"), "prboq", 0, 0, S::npos);
+ test(S("qnhiftdgcleajbpkrosm"), "fjcqh", 0, 1, 4);
+ test(S("chamfknorbedjitgslpq"), "fmosa", 0, 2, 3);
+ test(S("njhqpibfmtlkaecdrgso"), "qdbok", 0, 4, 3);
+ test(S("ebnghfsqkprmdcljoiat"), "amslg", 0, 5, 3);
+ test(S("letjomsgihfrpqbkancd"), "smpltjneqb", 0, 0, S::npos);
+ test(S("nblgoipcrqeaktshjdmf"), "flitskrnge", 0, 1, 19);
+ test(S("cehkbngtjoiflqapsmrd"), "pgqihmlbef", 0, 5, 2);
+ test(S("mignapfoklbhcqjetdrs"), "cfpdqjtgsb", 0, 9, 2);
+ test(S("ceatbhlsqjgpnokfrmdi"), "htpsiaflom", 0, 10, 2);
+ test(S("ocihkjgrdelpfnmastqb"), "kpjfiaceghsrdtlbnomq", 0, 0, S::npos);
+ test(S("noelgschdtbrjfmiqkap"), "qhtbomidljgafneksprc", 0, 1, 16);
+ test(S("dkclqfombepritjnghas"), "nhtjobkcefldimpsaqgr", 0, 10, 1);
+ test(S("miklnresdgbhqcojftap"), "prabcjfqnoeskilmtgdh", 0, 19, 0);
+ test(S("htbcigojaqmdkfrnlsep"), "dtrgmchilkasqoebfpjn", 0, 20, 0);
+ test(S("febhmqtjanokscdirpgl"), "", 1, 0, S::npos);
+ test(S("loakbsqjpcrdhftniegm"), "sqome", 1, 0, S::npos);
+ test(S("reagphsqflbitdcjmkno"), "smfte", 1, 1, 6);
+ test(S("jitlfrqemsdhkopncabg"), "ciboh", 1, 2, 1);
+ test(S("mhtaepscdnrjqgbkifol"), "haois", 1, 4, 1);
+ test(S("tocesrfmnglpbjihqadk"), "abfki", 1, 5, 6);
+ test(S("lpfmctjrhdagneskbqoi"), "frdkocntmq", 1, 0, S::npos);
+ test(S("lsmqaepkdhncirbtjfgo"), "oasbpedlnr", 1, 1, 19);
+ test(S("epoiqmtldrabnkjhcfsg"), "kltqmhgand", 1, 5, 4);
+ test(S("emgasrilpknqojhtbdcf"), "gdtfjchpmr", 1, 9, 1);
+ test(S("hnfiagdpcklrjetqbsom"), "ponmcqblet", 1, 10, 1);
+ test(S("nsdfebgajhmtricpoklq"), "sgphqdnofeiklatbcmjr", 1, 0, S::npos);
+ test(S("atjgfsdlpobmeiqhncrk"), "ljqprsmigtfoneadckbh", 1, 1, 7);
+ test(S("sitodfgnrejlahcbmqkp"), "ligeojhafnkmrcsqtbdp", 1, 10, 1);
+ test(S("fraghmbiceknltjpqosd"), "lsimqfnjarbopedkhcgt", 1, 19, 1);
+ test(S("pmafenlhqtdbkirjsogc"), "abedmfjlghniorcqptks", 1, 20, 1);
+ test(S("pihgmoeqtnakrjslcbfd"), "", 10, 0, S::npos);
+ test(S("gjdkeprctqblnhiafsom"), "hqtoa", 10, 0, S::npos);
+ test(S("mkpnblfdsahrcqijteog"), "cahif", 10, 1, 12);
+ test(S("gckarqnelodfjhmbptis"), "kehis", 10, 2, S::npos);
+ test(S("gqpskidtbclomahnrjfe"), "kdlmh", 10, 4, 10);
+ test(S("pkldjsqrfgitbhmaecno"), "paeql", 10, 5, 15);
+ test(S("aftsijrbeklnmcdqhgop"), "aghoqiefnb", 10, 0, S::npos);
+ test(S("mtlgdrhafjkbiepqnsoc"), "jrbqaikpdo", 10, 1, S::npos);
+ test(S("pqgirnaefthokdmbsclj"), "smjonaeqcl", 10, 5, 11);
+ test(S("kpdbgjmtherlsfcqoina"), "eqbdrkcfah", 10, 9, 10);
+ test(S("jrlbothiknqmdgcfasep"), "kapmsienhf", 10, 10, 11);
+ test(S("mjogldqferckabinptsh"), "jpqotrlenfcsbhkaimdg", 10, 0, S::npos);
+ test(S("apoklnefbhmgqcdrisjt"), "jlbmhnfgtcqprikeados", 10, 1, 18);
+ test(S("ifeopcnrjbhkdgatmqls"), "stgbhfmdaljnpqoicker", 10, 10, 10);
+ test(S("ckqhaiesmjdnrgolbtpf"), "oihcetflbjagdsrkmqpn", 10, 19, 10);
+ test(S("bnlgapfimcoterskqdjh"), "adtclebmnpjsrqfkigoh", 10, 20, 10);
+ test(S("kgdlrobpmjcthqsafeni"), "", 19, 0, S::npos);
+ test(S("dfkechomjapgnslbtqir"), "beafg", 19, 0, S::npos);
+ test(S("rloadknfbqtgmhcsipje"), "iclat", 19, 1, S::npos);
+ test(S("mgjhkolrnadqbpetcifs"), "rkhnf", 19, 2, S::npos);
+ test(S("cmlfakiojdrgtbsphqen"), "clshq", 19, 4, S::npos);
+ test(S("kghbfipeomsntdalrqjc"), "dtcoj", 19, 5, 19);
+ test(S("eldiqckrnmtasbghjfpo"), "rqosnjmfth", 19, 0, S::npos);
+ test(S("abqjcfedgotihlnspkrm"), "siatdfqglh", 19, 1, S::npos);
+ test(S("qfbadrtjsimkolcenhpg"), "mrlshtpgjq", 19, 5, S::npos);
+ test(S("abseghclkjqifmtodrnp"), "adlcskgqjt", 19, 9, S::npos);
+ test(S("ibmsnlrjefhtdokacqpg"), "drshcjknaf", 19, 10, S::npos);
+ test(S("mrkfciqjebaponsthldg"), "etsaqroinghpkjdlfcbm", 19, 0, S::npos);
+ test(S("mjkticdeoqshpalrfbgn"), "sgepdnkqliambtrocfhj", 19, 1, S::npos);
+ test(S("rqnoclbdejgiphtfsakm"), "nlmcjaqgbsortfdihkpe", 19, 10, 19);
+ test(S("plkqbhmtfaeodjcrsing"), "racfnpmosldibqkghjet", 19, 19, 19);
+ test(S("oegalhmstjrfickpbndq"), "fjhdsctkqeiolagrnmbp", 19, 20, 19);
+ test(S("rdtgjcaohpblniekmsfq"), "", 20, 0, S::npos);
+ test(S("ofkqbnjetrmsaidphglc"), "ejanp", 20, 0, S::npos);
+ test(S("grkpahljcftesdmonqib"), "odife", 20, 1, S::npos);
+ test(S("jimlgbhfqkteospardcn"), "okaqd", 20, 2, S::npos);
+ test(S("gftenihpmslrjkqadcob"), "lcdbi", 20, 4, S::npos);
+ test(S("bmhldogtckrfsanijepq"), "fsqbj", 20, 5, S::npos);
+ test(S("nfqkrpjdesabgtlcmoih"), "bigdomnplq", 20, 0, S::npos);
+ test(S("focalnrpiqmdkstehbjg"), "apiblotgcd", 20, 1, S::npos);
+ test(S("rhqdspkmebiflcotnjga"), "acfhdenops", 20, 5, S::npos);
+ test(S("rahdtmsckfboqlpniegj"), "jopdeamcrk", 20, 9, S::npos);
+ test(S("fbkeiopclstmdqranjhg"), "trqncbkgmh", 20, 10, S::npos);
+ test(S("lifhpdgmbconstjeqark"), "tomglrkencbsfjqpihda", 20, 0, S::npos);
+}
+
+template <class S>
+void test3()
+{
+ test(S("pboqganrhedjmltsicfk"), "gbkhdnpoietfcmrslajq", 20, 1, S::npos);
+ test(S("klchabsimetjnqgorfpd"), "rtfnmbsglkjaichoqedp", 20, 10, S::npos);
+ test(S("sirfgmjqhctndbklaepo"), "ohkmdpfqbsacrtjnlgei", 20, 19, S::npos);
+ test(S("rlbdsiceaonqjtfpghkm"), "dlbrteoisgphmkncajfq", 20, 20, S::npos);
+ test(S("ecgdanriptblhjfqskom"), "", 21, 0, S::npos);
+ test(S("fdmiarlpgcskbhoteqjn"), "sjrlo", 21, 0, S::npos);
+ test(S("rlbstjqopignecmfadkh"), "qjpor", 21, 1, S::npos);
+ test(S("grjpqmbshektdolcafni"), "odhfn", 21, 2, S::npos);
+ test(S("sakfcohtqnibprjmlged"), "qtfin", 21, 4, S::npos);
+ test(S("mjtdglasihqpocebrfkn"), "hpqfo", 21, 5, S::npos);
+ test(S("okaplfrntghqbmeicsdj"), "fabmertkos", 21, 0, S::npos);
+ test(S("sahngemrtcjidqbklfpo"), "brqtgkmaej", 21, 1, S::npos);
+ test(S("dlmsipcnekhbgoaftqjr"), "nfrdeihsgl", 21, 5, S::npos);
+ test(S("ahegrmqnoiklpfsdbcjt"), "hlfrosekpi", 21, 9, S::npos);
+ test(S("hdsjbnmlegtkqripacof"), "atgbkrjdsm", 21, 10, S::npos);
+ test(S("pcnedrfjihqbalkgtoms"), "blnrptjgqmaifsdkhoec", 21, 0, S::npos);
+ test(S("qjidealmtpskrbfhocng"), "ctpmdahebfqjgknloris", 21, 1, S::npos);
+ test(S("qeindtagmokpfhsclrbj"), "apnkeqthrmlbfodiscgj", 21, 10, S::npos);
+ test(S("kpfegbjhsrnodltqciam"), "jdgictpframeoqlsbknh", 21, 19, S::npos);
+ test(S("hnbrcplsjfgiktoedmaq"), "qprlsfojamgndekthibc", 21, 20, S::npos);
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test0<S>();
+ test1<S>();
+ test2<S>();
+ test3<S>();
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test0<S>();
+ test1<S>();
+ test2<S>();
+ test3<S>();
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.ops/string_find.first.of/string_size.pass.cpp b/test/std/strings/basic.string/string.ops/string_find.first.of/string_size.pass.cpp
new file mode 100644
index 000000000000..e409edc25f48
--- /dev/null
+++ b/test/std/strings/basic.string/string.ops/string_find.first.of/string_size.pass.cpp
@@ -0,0 +1,157 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type find_first_of(const basic_string& str, size_type pos = 0) const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& s, const S& str, typename S::size_type pos, typename S::size_type x)
+{
+ assert(s.find_first_of(str, pos) == x);
+ if (x != S::npos)
+ assert(pos <= x && x < s.size());
+}
+
+template <class S>
+void
+test(const S& s, const S& str, typename S::size_type x)
+{
+ assert(s.find_first_of(str) == x);
+ if (x != S::npos)
+ assert(x < s.size());
+}
+
+template <class S>
+void test0()
+{
+ test(S(""), S(""), 0, S::npos);
+ test(S(""), S("laenf"), 0, S::npos);
+ test(S(""), S("pqlnkmbdjo"), 0, S::npos);
+ test(S(""), S("qkamfogpnljdcshbreti"), 0, S::npos);
+ test(S(""), S(""), 1, S::npos);
+ test(S(""), S("bjaht"), 1, S::npos);
+ test(S(""), S("hjlcmgpket"), 1, S::npos);
+ test(S(""), S("htaobedqikfplcgjsmrn"), 1, S::npos);
+ test(S("fodgq"), S(""), 0, S::npos);
+ test(S("qanej"), S("dfkap"), 0, 1);
+ test(S("clbao"), S("ihqrfebgad"), 0, 2);
+ test(S("mekdn"), S("ngtjfcalbseiqrphmkdo"), 0, 0);
+ test(S("srdfq"), S(""), 1, S::npos);
+ test(S("oemth"), S("ikcrq"), 1, S::npos);
+ test(S("cdaih"), S("dmajblfhsg"), 1, 1);
+ test(S("qohtk"), S("oqftjhdmkgsblacenirp"), 1, 1);
+ test(S("cshmd"), S(""), 2, S::npos);
+ test(S("lhcdo"), S("oebqi"), 2, 4);
+ test(S("qnsoh"), S("kojhpmbsfe"), 2, 2);
+ test(S("pkrof"), S("acbsjqogpltdkhinfrem"), 2, 2);
+ test(S("fmtsp"), S(""), 4, S::npos);
+ test(S("khbpm"), S("aobjd"), 4, S::npos);
+ test(S("pbsji"), S("pcbahntsje"), 4, S::npos);
+ test(S("mprdj"), S("fhepcrntkoagbmldqijs"), 4, 4);
+ test(S("eqmpa"), S(""), 5, S::npos);
+ test(S("omigs"), S("kocgb"), 5, S::npos);
+ test(S("onmje"), S("fbslrjiqkm"), 5, S::npos);
+ test(S("oqmrj"), S("jeidpcmalhfnqbgtrsko"), 5, S::npos);
+ test(S("schfa"), S(""), 6, S::npos);
+ test(S("igdsc"), S("qngpd"), 6, S::npos);
+ test(S("brqgo"), S("rodhqklgmb"), 6, S::npos);
+ test(S("tnrph"), S("thdjgafrlbkoiqcspmne"), 6, S::npos);
+ test(S("hcjitbfapl"), S(""), 0, S::npos);
+ test(S("daiprenocl"), S("ashjd"), 0, 0);
+ test(S("litpcfdghe"), S("mgojkldsqh"), 0, 0);
+ test(S("aidjksrolc"), S("imqnaghkfrdtlopbjesc"), 0, 0);
+ test(S("qpghtfbaji"), S(""), 1, S::npos);
+ test(S("gfshlcmdjr"), S("nadkh"), 1, 3);
+ test(S("nkodajteqp"), S("ofdrqmkebl"), 1, 1);
+ test(S("gbmetiprqd"), S("bdfjqgatlksriohemnpc"), 1, 1);
+ test(S("crnklpmegd"), S(""), 5, S::npos);
+ test(S("jsbtafedoc"), S("prqgn"), 5, S::npos);
+ test(S("qnmodrtkeb"), S("pejafmnokr"), 5, 5);
+ test(S("cpebqsfmnj"), S("odnqkgijrhabfmcestlp"), 5, 5);
+ test(S("lmofqdhpki"), S(""), 9, S::npos);
+ test(S("hnefkqimca"), S("rtjpa"), 9, 9);
+ test(S("drtasbgmfp"), S("ktsrmnqagd"), 9, S::npos);
+ test(S("lsaijeqhtr"), S("rtdhgcisbnmoaqkfpjle"), 9, 9);
+ test(S("elgofjmbrq"), S(""), 10, S::npos);
+ test(S("mjqdgalkpc"), S("dplqa"), 10, S::npos);
+ test(S("kthqnfcerm"), S("dkacjoptns"), 10, S::npos);
+ test(S("dfsjhanorc"), S("hqfimtrgnbekpdcsjalo"), 10, S::npos);
+ test(S("eqsgalomhb"), S(""), 11, S::npos);
+ test(S("akiteljmoh"), S("lofbc"), 11, S::npos);
+ test(S("hlbdfreqjo"), S("astoegbfpn"), 11, S::npos);
+ test(S("taqobhlerg"), S("pdgreqomsncafklhtibj"), 11, S::npos);
+ test(S("snafbdlghrjkpqtoceim"), S(""), 0, S::npos);
+ test(S("aemtbrgcklhndjisfpoq"), S("lbtqd"), 0, 3);
+ test(S("pnracgfkjdiholtbqsem"), S("tboimldpjh"), 0, 0);
+ test(S("dicfltehbsgrmojnpkaq"), S("slcerthdaiqjfnobgkpm"), 0, 0);
+ test(S("jlnkraeodhcspfgbqitm"), S(""), 1, S::npos);
+ test(S("lhosrngtmfjikbqpcade"), S("aqibs"), 1, 3);
+ test(S("rbtaqjhgkneisldpmfoc"), S("gtfblmqinc"), 1, 1);
+ test(S("gpifsqlrdkbonjtmheca"), S("mkqpbtdalgniorhfescj"), 1, 1);
+ test(S("hdpkobnsalmcfijregtq"), S(""), 10, S::npos);
+ test(S("jtlshdgqaiprkbcoenfm"), S("pblas"), 10, 10);
+ test(S("fkdrbqltsgmcoiphneaj"), S("arosdhcfme"), 10, 10);
+ test(S("crsplifgtqedjohnabmk"), S("blkhjeogicatqfnpdmsr"), 10, 10);
+ test(S("niptglfbosehkamrdqcj"), S(""), 19, S::npos);
+ test(S("copqdhstbingamjfkler"), S("djkqc"), 19, S::npos);
+ test(S("mrtaefilpdsgocnhqbjk"), S("lgokshjtpb"), 19, 19);
+ test(S("kojatdhlcmigpbfrqnes"), S("bqjhtkfepimcnsgrlado"), 19, 19);
+ test(S("eaintpchlqsbdgrkjofm"), S(""), 20, S::npos);
+ test(S("gjnhidfsepkrtaqbmclo"), S("nocfa"), 20, S::npos);
+ test(S("spocfaktqdbiejlhngmr"), S("bgtajmiedc"), 20, S::npos);
+ test(S("rphmlekgfscndtaobiqj"), S("lsckfnqgdahejiopbtmr"), 20, S::npos);
+ test(S("liatsqdoegkmfcnbhrpj"), S(""), 21, S::npos);
+ test(S("binjagtfldkrspcomqeh"), S("gfsrt"), 21, S::npos);
+ test(S("latkmisecnorjbfhqpdg"), S("pfsocbhjtm"), 21, S::npos);
+ test(S("lecfratdjkhnsmqpoigb"), S("tpflmdnoicjgkberhqsa"), 21, S::npos);
+}
+
+template <class S>
+void test1()
+{
+ test(S(""), S(""), S::npos);
+ test(S(""), S("laenf"), S::npos);
+ test(S(""), S("pqlnkmbdjo"), S::npos);
+ test(S(""), S("qkamfogpnljdcshbreti"), S::npos);
+ test(S("nhmko"), S(""), S::npos);
+ test(S("lahfb"), S("irkhs"), 2);
+ test(S("gmfhd"), S("kantesmpgj"), 0);
+ test(S("odaft"), S("oknlrstdpiqmjbaghcfe"), 0);
+ test(S("eolhfgpjqk"), S(""), S::npos);
+ test(S("nbatdlmekr"), S("bnrpe"), 0);
+ test(S("jdmciepkaq"), S("jtdaefblso"), 0);
+ test(S("hkbgspoflt"), S("oselktgbcapndfjihrmq"), 0);
+ test(S("gprdcokbnjhlsfmtieqa"), S(""), S::npos);
+ test(S("qjghlnftcaismkropdeb"), S("bjaht"), 1);
+ test(S("pnalfrdtkqcmojiesbhg"), S("hjlcmgpket"), 0);
+ test(S("pniotcfrhqsmgdkjbael"), S("htaobedqikfplcgjsmrn"), 0);
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test0<S>();
+ test1<S>();
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test0<S>();
+ test1<S>();
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.ops/string_find.last.not.of/char_size.pass.cpp b/test/std/strings/basic.string/string.ops/string_find.last.not.of/char_size.pass.cpp
new file mode 100644
index 000000000000..b130f9287ba3
--- /dev/null
+++ b/test/std/strings/basic.string/string.ops/string_find.last.not.of/char_size.pass.cpp
@@ -0,0 +1,98 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type find_last_not_of(charT c, size_type pos = npos) const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& s, typename S::value_type c, typename S::size_type pos,
+ typename S::size_type x)
+{
+ assert(s.find_last_not_of(c, pos) == x);
+ if (x != S::npos)
+ assert(x <= pos && x < s.size());
+}
+
+template <class S>
+void
+test(const S& s, typename S::value_type c, typename S::size_type x)
+{
+ assert(s.find_last_not_of(c) == x);
+ if (x != S::npos)
+ assert(x < s.size());
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test(S(""), 'i', 0, S::npos);
+ test(S(""), 'i', 1, S::npos);
+ test(S("kitcj"), 'i', 0, 0);
+ test(S("qkamf"), 'i', 1, 1);
+ test(S("nhmko"), 'i', 2, 2);
+ test(S("tpsaf"), 'i', 4, 4);
+ test(S("lahfb"), 'i', 5, 4);
+ test(S("irkhs"), 'i', 6, 4);
+ test(S("gmfhdaipsr"), 'i', 0, 0);
+ test(S("kantesmpgj"), 'i', 1, 1);
+ test(S("odaftiegpm"), 'i', 5, 4);
+ test(S("oknlrstdpi"), 'i', 9, 8);
+ test(S("eolhfgpjqk"), 'i', 10, 9);
+ test(S("pcdrofikas"), 'i', 11, 9);
+ test(S("nbatdlmekrgcfqsophij"), 'i', 0, 0);
+ test(S("bnrpehidofmqtcksjgla"), 'i', 1, 1);
+ test(S("jdmciepkaqgotsrfnhlb"), 'i', 10, 10);
+ test(S("jtdaefblsokrmhpgcnqi"), 'i', 19, 18);
+ test(S("hkbgspofltajcnedqmri"), 'i', 20, 18);
+ test(S("oselktgbcapndfjihrmq"), 'i', 21, 19);
+
+ test(S(""), 'i', S::npos);
+ test(S("csope"), 'i', 4);
+ test(S("gfsmthlkon"), 'i', 9);
+ test(S("laenfsbridchgotmkqpj"), 'i', 19);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S(""), 'i', 0, S::npos);
+ test(S(""), 'i', 1, S::npos);
+ test(S("kitcj"), 'i', 0, 0);
+ test(S("qkamf"), 'i', 1, 1);
+ test(S("nhmko"), 'i', 2, 2);
+ test(S("tpsaf"), 'i', 4, 4);
+ test(S("lahfb"), 'i', 5, 4);
+ test(S("irkhs"), 'i', 6, 4);
+ test(S("gmfhdaipsr"), 'i', 0, 0);
+ test(S("kantesmpgj"), 'i', 1, 1);
+ test(S("odaftiegpm"), 'i', 5, 4);
+ test(S("oknlrstdpi"), 'i', 9, 8);
+ test(S("eolhfgpjqk"), 'i', 10, 9);
+ test(S("pcdrofikas"), 'i', 11, 9);
+ test(S("nbatdlmekrgcfqsophij"), 'i', 0, 0);
+ test(S("bnrpehidofmqtcksjgla"), 'i', 1, 1);
+ test(S("jdmciepkaqgotsrfnhlb"), 'i', 10, 10);
+ test(S("jtdaefblsokrmhpgcnqi"), 'i', 19, 18);
+ test(S("hkbgspofltajcnedqmri"), 'i', 20, 18);
+ test(S("oselktgbcapndfjihrmq"), 'i', 21, 19);
+
+ test(S(""), 'i', S::npos);
+ test(S("csope"), 'i', 4);
+ test(S("gfsmthlkon"), 'i', 9);
+ test(S("laenfsbridchgotmkqpj"), 'i', 19);
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.ops/string_find.last.not.of/pointer_size.pass.cpp b/test/std/strings/basic.string/string.ops/string_find.last.not.of/pointer_size.pass.cpp
new file mode 100644
index 000000000000..3e6bd9d093ea
--- /dev/null
+++ b/test/std/strings/basic.string/string.ops/string_find.last.not.of/pointer_size.pass.cpp
@@ -0,0 +1,158 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type find_last_not_of(const charT* s, size_type pos = npos) const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type pos,
+ typename S::size_type x)
+{
+ assert(s.find_last_not_of(str, pos) == x);
+ if (x != S::npos)
+ assert(x <= pos && x < s.size());
+}
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type x)
+{
+ assert(s.find_last_not_of(str) == x);
+ if (x != S::npos)
+ assert(x < s.size());
+}
+
+template <class S>
+void test0()
+{
+ test(S(""), "", 0, S::npos);
+ test(S(""), "laenf", 0, S::npos);
+ test(S(""), "pqlnkmbdjo", 0, S::npos);
+ test(S(""), "qkamfogpnljdcshbreti", 0, S::npos);
+ test(S(""), "", 1, S::npos);
+ test(S(""), "bjaht", 1, S::npos);
+ test(S(""), "hjlcmgpket", 1, S::npos);
+ test(S(""), "htaobedqikfplcgjsmrn", 1, S::npos);
+ test(S("fodgq"), "", 0, 0);
+ test(S("qanej"), "dfkap", 0, 0);
+ test(S("clbao"), "ihqrfebgad", 0, 0);
+ test(S("mekdn"), "ngtjfcalbseiqrphmkdo", 0, S::npos);
+ test(S("srdfq"), "", 1, 1);
+ test(S("oemth"), "ikcrq", 1, 1);
+ test(S("cdaih"), "dmajblfhsg", 1, 0);
+ test(S("qohtk"), "oqftjhdmkgsblacenirp", 1, S::npos);
+ test(S("cshmd"), "", 2, 2);
+ test(S("lhcdo"), "oebqi", 2, 2);
+ test(S("qnsoh"), "kojhpmbsfe", 2, 1);
+ test(S("pkrof"), "acbsjqogpltdkhinfrem", 2, S::npos);
+ test(S("fmtsp"), "", 4, 4);
+ test(S("khbpm"), "aobjd", 4, 4);
+ test(S("pbsji"), "pcbahntsje", 4, 4);
+ test(S("mprdj"), "fhepcrntkoagbmldqijs", 4, S::npos);
+ test(S("eqmpa"), "", 5, 4);
+ test(S("omigs"), "kocgb", 5, 4);
+ test(S("onmje"), "fbslrjiqkm", 5, 4);
+ test(S("oqmrj"), "jeidpcmalhfnqbgtrsko", 5, S::npos);
+ test(S("schfa"), "", 6, 4);
+ test(S("igdsc"), "qngpd", 6, 4);
+ test(S("brqgo"), "rodhqklgmb", 6, S::npos);
+ test(S("tnrph"), "thdjgafrlbkoiqcspmne", 6, S::npos);
+ test(S("hcjitbfapl"), "", 0, 0);
+ test(S("daiprenocl"), "ashjd", 0, S::npos);
+ test(S("litpcfdghe"), "mgojkldsqh", 0, S::npos);
+ test(S("aidjksrolc"), "imqnaghkfrdtlopbjesc", 0, S::npos);
+ test(S("qpghtfbaji"), "", 1, 1);
+ test(S("gfshlcmdjr"), "nadkh", 1, 1);
+ test(S("nkodajteqp"), "ofdrqmkebl", 1, 0);
+ test(S("gbmetiprqd"), "bdfjqgatlksriohemnpc", 1, S::npos);
+ test(S("crnklpmegd"), "", 5, 5);
+ test(S("jsbtafedoc"), "prqgn", 5, 5);
+ test(S("qnmodrtkeb"), "pejafmnokr", 5, 4);
+ test(S("cpebqsfmnj"), "odnqkgijrhabfmcestlp", 5, S::npos);
+ test(S("lmofqdhpki"), "", 9, 9);
+ test(S("hnefkqimca"), "rtjpa", 9, 8);
+ test(S("drtasbgmfp"), "ktsrmnqagd", 9, 9);
+ test(S("lsaijeqhtr"), "rtdhgcisbnmoaqkfpjle", 9, S::npos);
+ test(S("elgofjmbrq"), "", 10, 9);
+ test(S("mjqdgalkpc"), "dplqa", 10, 9);
+ test(S("kthqnfcerm"), "dkacjoptns", 10, 9);
+ test(S("dfsjhanorc"), "hqfimtrgnbekpdcsjalo", 10, S::npos);
+ test(S("eqsgalomhb"), "", 11, 9);
+ test(S("akiteljmoh"), "lofbc", 11, 9);
+ test(S("hlbdfreqjo"), "astoegbfpn", 11, 8);
+ test(S("taqobhlerg"), "pdgreqomsncafklhtibj", 11, S::npos);
+ test(S("snafbdlghrjkpqtoceim"), "", 0, 0);
+ test(S("aemtbrgcklhndjisfpoq"), "lbtqd", 0, 0);
+ test(S("pnracgfkjdiholtbqsem"), "tboimldpjh", 0, S::npos);
+ test(S("dicfltehbsgrmojnpkaq"), "slcerthdaiqjfnobgkpm", 0, S::npos);
+ test(S("jlnkraeodhcspfgbqitm"), "", 1, 1);
+ test(S("lhosrngtmfjikbqpcade"), "aqibs", 1, 1);
+ test(S("rbtaqjhgkneisldpmfoc"), "gtfblmqinc", 1, 0);
+ test(S("gpifsqlrdkbonjtmheca"), "mkqpbtdalgniorhfescj", 1, S::npos);
+ test(S("hdpkobnsalmcfijregtq"), "", 10, 10);
+ test(S("jtlshdgqaiprkbcoenfm"), "pblas", 10, 9);
+ test(S("fkdrbqltsgmcoiphneaj"), "arosdhcfme", 10, 9);
+ test(S("crsplifgtqedjohnabmk"), "blkhjeogicatqfnpdmsr", 10, S::npos);
+ test(S("niptglfbosehkamrdqcj"), "", 19, 19);
+ test(S("copqdhstbingamjfkler"), "djkqc", 19, 19);
+ test(S("mrtaefilpdsgocnhqbjk"), "lgokshjtpb", 19, 16);
+ test(S("kojatdhlcmigpbfrqnes"), "bqjhtkfepimcnsgrlado", 19, S::npos);
+ test(S("eaintpchlqsbdgrkjofm"), "", 20, 19);
+ test(S("gjnhidfsepkrtaqbmclo"), "nocfa", 20, 18);
+ test(S("spocfaktqdbiejlhngmr"), "bgtajmiedc", 20, 19);
+ test(S("rphmlekgfscndtaobiqj"), "lsckfnqgdahejiopbtmr", 20, S::npos);
+ test(S("liatsqdoegkmfcnbhrpj"), "", 21, 19);
+ test(S("binjagtfldkrspcomqeh"), "gfsrt", 21, 19);
+ test(S("latkmisecnorjbfhqpdg"), "pfsocbhjtm", 21, 19);
+ test(S("lecfratdjkhnsmqpoigb"), "tpflmdnoicjgkberhqsa", 21, S::npos);
+}
+
+template <class S>
+void test1()
+{
+ test(S(""), "", S::npos);
+ test(S(""), "laenf", S::npos);
+ test(S(""), "pqlnkmbdjo", S::npos);
+ test(S(""), "qkamfogpnljdcshbreti", S::npos);
+ test(S("nhmko"), "", 4);
+ test(S("lahfb"), "irkhs", 4);
+ test(S("gmfhd"), "kantesmpgj", 4);
+ test(S("odaft"), "oknlrstdpiqmjbaghcfe", S::npos);
+ test(S("eolhfgpjqk"), "", 9);
+ test(S("nbatdlmekr"), "bnrpe", 8);
+ test(S("jdmciepkaq"), "jtdaefblso", 9);
+ test(S("hkbgspoflt"), "oselktgbcapndfjihrmq", S::npos);
+ test(S("gprdcokbnjhlsfmtieqa"), "", 19);
+ test(S("qjghlnftcaismkropdeb"), "bjaht", 18);
+ test(S("pnalfrdtkqcmojiesbhg"), "hjlcmgpket", 17);
+ test(S("pniotcfrhqsmgdkjbael"), "htaobedqikfplcgjsmrn", S::npos);
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test0<S>();
+ test1<S>();
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test0<S>();
+ test1<S>();
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.ops/string_find.last.not.of/pointer_size_size.pass.cpp b/test/std/strings/basic.string/string.ops/string_find.last.not.of/pointer_size_size.pass.cpp
new file mode 100644
index 000000000000..4db7762b2755
--- /dev/null
+++ b/test/std/strings/basic.string/string.ops/string_find.last.not.of/pointer_size_size.pass.cpp
@@ -0,0 +1,387 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type find_last_not_of(const charT* s, size_type pos, size_type n) const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type pos,
+ typename S::size_type n, typename S::size_type x)
+{
+ assert(s.find_last_not_of(str, pos, n) == x);
+ if (x != S::npos)
+ assert(x <= pos && x < s.size());
+}
+
+template <class S>
+void test0()
+{
+ test(S(""), "", 0, 0, S::npos);
+ test(S(""), "irkhs", 0, 0, S::npos);
+ test(S(""), "kante", 0, 1, S::npos);
+ test(S(""), "oknlr", 0, 2, S::npos);
+ test(S(""), "pcdro", 0, 4, S::npos);
+ test(S(""), "bnrpe", 0, 5, S::npos);
+ test(S(""), "jtdaefblso", 0, 0, S::npos);
+ test(S(""), "oselktgbca", 0, 1, S::npos);
+ test(S(""), "eqgaplhckj", 0, 5, S::npos);
+ test(S(""), "bjahtcmnlp", 0, 9, S::npos);
+ test(S(""), "hjlcmgpket", 0, 10, S::npos);
+ test(S(""), "htaobedqikfplcgjsmrn", 0, 0, S::npos);
+ test(S(""), "hpqiarojkcdlsgnmfetb", 0, 1, S::npos);
+ test(S(""), "dfkaprhjloqetcsimnbg", 0, 10, S::npos);
+ test(S(""), "ihqrfebgadntlpmjksoc", 0, 19, S::npos);
+ test(S(""), "ngtjfcalbseiqrphmkdo", 0, 20, S::npos);
+ test(S(""), "", 1, 0, S::npos);
+ test(S(""), "lbtqd", 1, 0, S::npos);
+ test(S(""), "tboim", 1, 1, S::npos);
+ test(S(""), "slcer", 1, 2, S::npos);
+ test(S(""), "cbjfs", 1, 4, S::npos);
+ test(S(""), "aqibs", 1, 5, S::npos);
+ test(S(""), "gtfblmqinc", 1, 0, S::npos);
+ test(S(""), "mkqpbtdalg", 1, 1, S::npos);
+ test(S(""), "kphatlimcd", 1, 5, S::npos);
+ test(S(""), "pblasqogic", 1, 9, S::npos);
+ test(S(""), "arosdhcfme", 1, 10, S::npos);
+ test(S(""), "blkhjeogicatqfnpdmsr", 1, 0, S::npos);
+ test(S(""), "bmhineprjcoadgstflqk", 1, 1, S::npos);
+ test(S(""), "djkqcmetslnghpbarfoi", 1, 10, S::npos);
+ test(S(""), "lgokshjtpbemarcdqnfi", 1, 19, S::npos);
+ test(S(""), "bqjhtkfepimcnsgrlado", 1, 20, S::npos);
+ test(S("eaint"), "", 0, 0, 0);
+ test(S("binja"), "gfsrt", 0, 0, 0);
+ test(S("latkm"), "pfsoc", 0, 1, 0);
+ test(S("lecfr"), "tpflm", 0, 2, 0);
+ test(S("eqkst"), "sgkec", 0, 4, S::npos);
+ test(S("cdafr"), "romds", 0, 5, 0);
+ test(S("prbhe"), "qhjistlgmr", 0, 0, 0);
+ test(S("lbisk"), "pedfirsglo", 0, 1, 0);
+ test(S("hrlpd"), "aqcoslgrmk", 0, 5, 0);
+ test(S("ehmja"), "dabckmepqj", 0, 9, S::npos);
+ test(S("mhqgd"), "pqscrjthli", 0, 10, 0);
+ test(S("tgklq"), "kfphdcsjqmobliagtren", 0, 0, 0);
+ test(S("bocjs"), "rokpefncljibsdhqtagm", 0, 1, 0);
+ test(S("grbsd"), "afionmkphlebtcjqsgrd", 0, 10, 0);
+ test(S("ofjqr"), "aenmqplidhkofrjbctsg", 0, 19, S::npos);
+ test(S("btlfi"), "osjmbtcadhiklegrpqnf", 0, 20, S::npos);
+ test(S("clrgb"), "", 1, 0, 1);
+ test(S("tjmek"), "osmia", 1, 0, 1);
+ test(S("bgstp"), "ckonl", 1, 1, 1);
+ test(S("hstrk"), "ilcaj", 1, 2, 1);
+ test(S("kmspj"), "lasiq", 1, 4, 1);
+ test(S("tjboh"), "kfqmr", 1, 5, 1);
+ test(S("ilbcj"), "klnitfaobg", 1, 0, 1);
+ test(S("jkngf"), "gjhmdlqikp", 1, 1, 1);
+ test(S("gfcql"), "skbgtahqej", 1, 5, 1);
+ test(S("dqtlg"), "bjsdgtlpkf", 1, 9, 1);
+ test(S("bthpg"), "bjgfmnlkio", 1, 10, 1);
+ test(S("dgsnq"), "lbhepotfsjdqigcnamkr", 1, 0, 1);
+ test(S("rmfhp"), "tebangckmpsrqdlfojhi", 1, 1, 1);
+ test(S("jfdam"), "joflqbdkhtegimscpanr", 1, 10, S::npos);
+ test(S("edapb"), "adpmcohetfbsrjinlqkg", 1, 19, S::npos);
+ test(S("brfsm"), "iacldqjpfnogbsrhmetk", 1, 20, S::npos);
+ test(S("ndrhl"), "", 2, 0, 2);
+ test(S("mrecp"), "otkgb", 2, 0, 2);
+ test(S("qlasf"), "cqsjl", 2, 1, 2);
+ test(S("smaqd"), "dpifl", 2, 2, 2);
+ test(S("hjeni"), "oapht", 2, 4, 2);
+ test(S("ocmfj"), "cifts", 2, 5, 2);
+ test(S("hmftq"), "nmsckbgalo", 2, 0, 2);
+ test(S("fklad"), "tpksqhamle", 2, 1, 2);
+ test(S("dirnm"), "tpdrchmkji", 2, 5, 1);
+ test(S("hrgdc"), "ijagfkblst", 2, 9, 1);
+ test(S("ifakg"), "kpocsignjb", 2, 10, 2);
+ test(S("ebrgd"), "pecqtkjsnbdrialgmohf", 2, 0, 2);
+ test(S("rcjml"), "aiortphfcmkjebgsndql", 2, 1, 2);
+ test(S("peqmt"), "sdbkeamglhipojqftrcn", 2, 10, 2);
+ test(S("frehn"), "ljqncehgmfktroapidbs", 2, 19, S::npos);
+ test(S("tqolf"), "rtcfodilamkbenjghqps", 2, 20, S::npos);
+ test(S("cjgao"), "", 4, 0, 4);
+ test(S("kjplq"), "mabns", 4, 0, 4);
+ test(S("herni"), "bdnrp", 4, 1, 4);
+ test(S("tadrb"), "scidp", 4, 2, 4);
+ test(S("pkfeo"), "agbjl", 4, 4, 4);
+ test(S("hoser"), "jfmpr", 4, 5, 3);
+ test(S("kgrsp"), "rbpefghsmj", 4, 0, 4);
+ test(S("pgejb"), "apsfntdoqc", 4, 1, 4);
+ test(S("thlnq"), "ndkjeisgcl", 4, 5, 4);
+ test(S("nbmit"), "rnfpqatdeo", 4, 9, 3);
+ test(S("jgmib"), "bntjlqrfik", 4, 10, 2);
+ test(S("ncrfj"), "kcrtmpolnaqejghsfdbi", 4, 0, 4);
+ test(S("ncsik"), "lobheanpkmqidsrtcfgj", 4, 1, 4);
+ test(S("sgbfh"), "athdkljcnreqbgpmisof", 4, 10, 3);
+ test(S("dktbn"), "qkdmjialrscpbhefgont", 4, 19, 2);
+ test(S("fthqm"), "dmasojntqleribkgfchp", 4, 20, S::npos);
+ test(S("klopi"), "", 5, 0, 4);
+ test(S("dajhn"), "psthd", 5, 0, 4);
+ test(S("jbgno"), "rpmjd", 5, 1, 4);
+ test(S("hkjae"), "dfsmk", 5, 2, 4);
+}
+
+template <class S>
+void test1()
+{
+ test(S("gbhqo"), "skqne", 5, 4, 4);
+ test(S("ktdor"), "kipnf", 5, 5, 4);
+ test(S("ldprn"), "hmrnqdgifl", 5, 0, 4);
+ test(S("egmjk"), "fsmjcdairn", 5, 1, 4);
+ test(S("armql"), "pcdgltbrfj", 5, 5, 3);
+ test(S("cdhjo"), "aekfctpirg", 5, 9, 4);
+ test(S("jcons"), "ledihrsgpf", 5, 10, 3);
+ test(S("cbrkp"), "mqcklahsbtirgopefndj", 5, 0, 4);
+ test(S("fhgna"), "kmlthaoqgecrnpdbjfis", 5, 1, 4);
+ test(S("ejfcd"), "sfhbamcdptojlkrenqgi", 5, 10, 1);
+ test(S("kqjhe"), "pbniofmcedrkhlstgaqj", 5, 19, 2);
+ test(S("pbdjl"), "mongjratcskbhqiepfdl", 5, 20, S::npos);
+ test(S("gajqn"), "", 6, 0, 4);
+ test(S("stedk"), "hrnat", 6, 0, 4);
+ test(S("tjkaf"), "gsqdt", 6, 1, 4);
+ test(S("dthpe"), "bspkd", 6, 2, 4);
+ test(S("klhde"), "ohcmb", 6, 4, 4);
+ test(S("bhlki"), "heatr", 6, 5, 4);
+ test(S("lqmoh"), "pmblckedfn", 6, 0, 4);
+ test(S("mtqin"), "aceqmsrbik", 6, 1, 4);
+ test(S("dpqbr"), "lmbtdehjrn", 6, 5, 4);
+ test(S("kdhmo"), "teqmcrlgib", 6, 9, 4);
+ test(S("jblqp"), "njolbmspac", 6, 10, 3);
+ test(S("qmjgl"), "pofnhidklamecrbqjgst", 6, 0, 4);
+ test(S("rothp"), "jbhckmtgrqnosafedpli", 6, 1, 4);
+ test(S("ghknq"), "dobntpmqklicsahgjerf", 6, 10, 1);
+ test(S("eopfi"), "tpdshainjkbfoemlrgcq", 6, 19, S::npos);
+ test(S("dsnmg"), "oldpfgeakrnitscbjmqh", 6, 20, S::npos);
+ test(S("jnkrfhotgl"), "", 0, 0, 0);
+ test(S("dltjfngbko"), "rqegt", 0, 0, 0);
+ test(S("bmjlpkiqde"), "dashm", 0, 1, 0);
+ test(S("skrflobnqm"), "jqirk", 0, 2, 0);
+ test(S("jkpldtshrm"), "rckeg", 0, 4, 0);
+ test(S("ghasdbnjqo"), "jscie", 0, 5, 0);
+ test(S("igrkhpbqjt"), "efsphndliq", 0, 0, 0);
+ test(S("ikthdgcamf"), "gdicosleja", 0, 1, 0);
+ test(S("pcofgeniam"), "qcpjibosfl", 0, 5, S::npos);
+ test(S("rlfjgesqhc"), "lrhmefnjcq", 0, 9, S::npos);
+ test(S("itphbqsker"), "dtablcrseo", 0, 10, 0);
+ test(S("skjafcirqm"), "apckjsftedbhgomrnilq", 0, 0, 0);
+ test(S("tcqomarsfd"), "pcbrgflehjtiadnsokqm", 0, 1, 0);
+ test(S("rocfeldqpk"), "nsiadegjklhobrmtqcpf", 0, 10, 0);
+ test(S("cfpegndlkt"), "cpmajdqnolikhgsbretf", 0, 19, S::npos);
+ test(S("fqbtnkeasj"), "jcflkntmgiqrphdosaeb", 0, 20, S::npos);
+ test(S("shbcqnmoar"), "", 1, 0, 1);
+ test(S("bdoshlmfin"), "ontrs", 1, 0, 1);
+ test(S("khfrebnsgq"), "pfkna", 1, 1, 1);
+ test(S("getcrsaoji"), "ekosa", 1, 2, 0);
+ test(S("fjiknedcpq"), "anqhk", 1, 4, 1);
+ test(S("tkejgnafrm"), "jekca", 1, 5, 0);
+ test(S("jnakolqrde"), "ikemsjgacf", 1, 0, 1);
+ test(S("lcjptsmgbe"), "arolgsjkhm", 1, 1, 1);
+ test(S("itfsmcjorl"), "oftkbldhre", 1, 5, 0);
+ test(S("omchkfrjea"), "gbkqdoeftl", 1, 9, 1);
+ test(S("cigfqkated"), "sqcflrgtim", 1, 10, S::npos);
+ test(S("tscenjikml"), "fmhbkislrjdpanogqcet", 1, 0, 1);
+ test(S("qcpaemsinf"), "rnioadktqlgpbcjsmhef", 1, 1, 1);
+ test(S("gltkojeipd"), "oakgtnldpsefihqmjcbr", 1, 10, S::npos);
+ test(S("qistfrgnmp"), "gbnaelosidmcjqktfhpr", 1, 19, S::npos);
+ test(S("bdnpfcqaem"), "akbripjhlosndcmqgfet", 1, 20, S::npos);
+ test(S("ectnhskflp"), "", 5, 0, 5);
+ test(S("fgtianblpq"), "pijag", 5, 0, 5);
+ test(S("mfeqklirnh"), "jrckd", 5, 1, 5);
+ test(S("astedncjhk"), "qcloh", 5, 2, 5);
+ test(S("fhlqgcajbr"), "thlmp", 5, 4, 5);
+ test(S("epfhocmdng"), "qidmo", 5, 5, 5);
+ test(S("apcnsibger"), "lnegpsjqrd", 5, 0, 5);
+ test(S("aqkocrbign"), "rjqdablmfs", 5, 1, 4);
+ test(S("ijsmdtqgce"), "enkgpbsjaq", 5, 5, 5);
+ test(S("clobgsrken"), "kdsgoaijfh", 5, 9, 3);
+ test(S("jbhcfposld"), "trfqgmckbe", 5, 10, 5);
+ test(S("oqnpblhide"), "igetsracjfkdnpoblhqm", 5, 0, 5);
+ test(S("lroeasctif"), "nqctfaogirshlekbdjpm", 5, 1, 5);
+ test(S("bpjlgmiedh"), "csehfgomljdqinbartkp", 5, 10, 1);
+ test(S("pamkeoidrj"), "qahoegcmplkfsjbdnitr", 5, 19, S::npos);
+ test(S("espogqbthk"), "dpteiajrqmsognhlfbkc", 5, 20, S::npos);
+ test(S("shoiedtcjb"), "", 9, 0, 9);
+ test(S("ebcinjgads"), "tqbnh", 9, 0, 9);
+ test(S("dqmregkcfl"), "akmle", 9, 1, 9);
+ test(S("ngcrieqajf"), "iqfkm", 9, 2, 9);
+ test(S("qosmilgnjb"), "tqjsr", 9, 4, 9);
+ test(S("ikabsjtdfl"), "jplqg", 9, 5, 8);
+ test(S("ersmicafdh"), "oilnrbcgtj", 9, 0, 9);
+ test(S("fdnplotmgh"), "morkglpesn", 9, 1, 9);
+ test(S("fdbicojerm"), "dmicerngat", 9, 5, 8);
+ test(S("mbtafndjcq"), "radgeskbtc", 9, 9, 9);
+ test(S("mlenkpfdtc"), "ljikprsmqo", 9, 10, 9);
+ test(S("ahlcifdqgs"), "trqihkcgsjamfdbolnpe", 9, 0, 9);
+ test(S("bgjemaltks"), "lqmthbsrekajgnofcipd", 9, 1, 9);
+ test(S("pdhslbqrfc"), "jtalmedribkgqsopcnfh", 9, 10, 9);
+ test(S("dirhtsnjkc"), "spqfoiclmtagejbndkrh", 9, 19, 3);
+ test(S("dlroktbcja"), "nmotklspigjrdhcfaebq", 9, 20, S::npos);
+ test(S("ncjpmaekbs"), "", 10, 0, 9);
+ test(S("hlbosgmrak"), "hpmsd", 10, 0, 9);
+ test(S("pqfhsgilen"), "qnpor", 10, 1, 9);
+ test(S("gqtjsbdckh"), "otdma", 10, 2, 9);
+ test(S("cfkqpjlegi"), "efhjg", 10, 4, 9);
+ test(S("beanrfodgj"), "odpte", 10, 5, 9);
+ test(S("adtkqpbjfi"), "bctdgfmolr", 10, 0, 9);
+ test(S("iomkfthagj"), "oaklidrbqg", 10, 1, 9);
+}
+
+template <class S>
+void test2()
+{
+ test(S("sdpcilonqj"), "dnjfsagktr", 10, 5, 8);
+ test(S("gtfbdkqeml"), "nejaktmiqg", 10, 9, 9);
+ test(S("bmeqgcdorj"), "pjqonlebsf", 10, 10, 8);
+ test(S("etqlcanmob"), "dshmnbtolcjepgaikfqr", 10, 0, 9);
+ test(S("roqmkbdtia"), "iogfhpabtjkqlrnemcds", 10, 1, 9);
+ test(S("kadsithljf"), "ngridfabjsecpqltkmoh", 10, 10, 7);
+ test(S("sgtkpbfdmh"), "athmknplcgofrqejsdib", 10, 19, 5);
+ test(S("qgmetnabkl"), "ldobhmqcafnjtkeisgrp", 10, 20, S::npos);
+ test(S("cqjohampgd"), "", 11, 0, 9);
+ test(S("hobitmpsan"), "aocjb", 11, 0, 9);
+ test(S("tjehkpsalm"), "jbrnk", 11, 1, 9);
+ test(S("ngfbojitcl"), "tqedg", 11, 2, 9);
+ test(S("rcfkdbhgjo"), "nqskp", 11, 4, 9);
+ test(S("qghptonrea"), "eaqkl", 11, 5, 7);
+ test(S("hnprfgqjdl"), "reaoicljqm", 11, 0, 9);
+ test(S("hlmgabenti"), "lsftgajqpm", 11, 1, 9);
+ test(S("ofcjanmrbs"), "rlpfogmits", 11, 5, 9);
+ test(S("jqedtkornm"), "shkncmiaqj", 11, 9, 7);
+ test(S("rfedlasjmg"), "fpnatrhqgs", 11, 10, 8);
+ test(S("talpqjsgkm"), "sjclemqhnpdbgikarfot", 11, 0, 9);
+ test(S("lrkcbtqpie"), "otcmedjikgsfnqbrhpla", 11, 1, 9);
+ test(S("cipogdskjf"), "bonsaefdqiprkhlgtjcm", 11, 10, 8);
+ test(S("nqedcojahi"), "egpscmahijlfnkrodqtb", 11, 19, S::npos);
+ test(S("hefnrkmctj"), "kmqbfepjthgilscrndoa", 11, 20, S::npos);
+ test(S("atqirnmekfjolhpdsgcb"), "", 0, 0, 0);
+ test(S("echfkmlpribjnqsaogtd"), "prboq", 0, 0, 0);
+ test(S("qnhiftdgcleajbpkrosm"), "fjcqh", 0, 1, 0);
+ test(S("chamfknorbedjitgslpq"), "fmosa", 0, 2, 0);
+ test(S("njhqpibfmtlkaecdrgso"), "qdbok", 0, 4, 0);
+ test(S("ebnghfsqkprmdcljoiat"), "amslg", 0, 5, 0);
+ test(S("letjomsgihfrpqbkancd"), "smpltjneqb", 0, 0, 0);
+ test(S("nblgoipcrqeaktshjdmf"), "flitskrnge", 0, 1, 0);
+ test(S("cehkbngtjoiflqapsmrd"), "pgqihmlbef", 0, 5, 0);
+ test(S("mignapfoklbhcqjetdrs"), "cfpdqjtgsb", 0, 9, 0);
+ test(S("ceatbhlsqjgpnokfrmdi"), "htpsiaflom", 0, 10, 0);
+ test(S("ocihkjgrdelpfnmastqb"), "kpjfiaceghsrdtlbnomq", 0, 0, 0);
+ test(S("noelgschdtbrjfmiqkap"), "qhtbomidljgafneksprc", 0, 1, 0);
+ test(S("dkclqfombepritjnghas"), "nhtjobkcefldimpsaqgr", 0, 10, 0);
+ test(S("miklnresdgbhqcojftap"), "prabcjfqnoeskilmtgdh", 0, 19, S::npos);
+ test(S("htbcigojaqmdkfrnlsep"), "dtrgmchilkasqoebfpjn", 0, 20, S::npos);
+ test(S("febhmqtjanokscdirpgl"), "", 1, 0, 1);
+ test(S("loakbsqjpcrdhftniegm"), "sqome", 1, 0, 1);
+ test(S("reagphsqflbitdcjmkno"), "smfte", 1, 1, 1);
+ test(S("jitlfrqemsdhkopncabg"), "ciboh", 1, 2, 0);
+ test(S("mhtaepscdnrjqgbkifol"), "haois", 1, 4, 0);
+ test(S("tocesrfmnglpbjihqadk"), "abfki", 1, 5, 1);
+ test(S("lpfmctjrhdagneskbqoi"), "frdkocntmq", 1, 0, 1);
+ test(S("lsmqaepkdhncirbtjfgo"), "oasbpedlnr", 1, 1, 1);
+ test(S("epoiqmtldrabnkjhcfsg"), "kltqmhgand", 1, 5, 1);
+ test(S("emgasrilpknqojhtbdcf"), "gdtfjchpmr", 1, 9, 0);
+ test(S("hnfiagdpcklrjetqbsom"), "ponmcqblet", 1, 10, 0);
+ test(S("nsdfebgajhmtricpoklq"), "sgphqdnofeiklatbcmjr", 1, 0, 1);
+ test(S("atjgfsdlpobmeiqhncrk"), "ljqprsmigtfoneadckbh", 1, 1, 1);
+ test(S("sitodfgnrejlahcbmqkp"), "ligeojhafnkmrcsqtbdp", 1, 10, 0);
+ test(S("fraghmbiceknltjpqosd"), "lsimqfnjarbopedkhcgt", 1, 19, S::npos);
+ test(S("pmafenlhqtdbkirjsogc"), "abedmfjlghniorcqptks", 1, 20, S::npos);
+ test(S("pihgmoeqtnakrjslcbfd"), "", 10, 0, 10);
+ test(S("gjdkeprctqblnhiafsom"), "hqtoa", 10, 0, 10);
+ test(S("mkpnblfdsahrcqijteog"), "cahif", 10, 1, 10);
+ test(S("gckarqnelodfjhmbptis"), "kehis", 10, 2, 10);
+ test(S("gqpskidtbclomahnrjfe"), "kdlmh", 10, 4, 9);
+ test(S("pkldjsqrfgitbhmaecno"), "paeql", 10, 5, 10);
+ test(S("aftsijrbeklnmcdqhgop"), "aghoqiefnb", 10, 0, 10);
+ test(S("mtlgdrhafjkbiepqnsoc"), "jrbqaikpdo", 10, 1, 10);
+ test(S("pqgirnaefthokdmbsclj"), "smjonaeqcl", 10, 5, 10);
+ test(S("kpdbgjmtherlsfcqoina"), "eqbdrkcfah", 10, 9, 8);
+ test(S("jrlbothiknqmdgcfasep"), "kapmsienhf", 10, 10, 10);
+ test(S("mjogldqferckabinptsh"), "jpqotrlenfcsbhkaimdg", 10, 0, 10);
+ test(S("apoklnefbhmgqcdrisjt"), "jlbmhnfgtcqprikeados", 10, 1, 10);
+ test(S("ifeopcnrjbhkdgatmqls"), "stgbhfmdaljnpqoicker", 10, 10, 8);
+ test(S("ckqhaiesmjdnrgolbtpf"), "oihcetflbjagdsrkmqpn", 10, 19, S::npos);
+ test(S("bnlgapfimcoterskqdjh"), "adtclebmnpjsrqfkigoh", 10, 20, S::npos);
+ test(S("kgdlrobpmjcthqsafeni"), "", 19, 0, 19);
+ test(S("dfkechomjapgnslbtqir"), "beafg", 19, 0, 19);
+ test(S("rloadknfbqtgmhcsipje"), "iclat", 19, 1, 19);
+ test(S("mgjhkolrnadqbpetcifs"), "rkhnf", 19, 2, 19);
+ test(S("cmlfakiojdrgtbsphqen"), "clshq", 19, 4, 19);
+ test(S("kghbfipeomsntdalrqjc"), "dtcoj", 19, 5, 17);
+ test(S("eldiqckrnmtasbghjfpo"), "rqosnjmfth", 19, 0, 19);
+ test(S("abqjcfedgotihlnspkrm"), "siatdfqglh", 19, 1, 19);
+ test(S("qfbadrtjsimkolcenhpg"), "mrlshtpgjq", 19, 5, 19);
+ test(S("abseghclkjqifmtodrnp"), "adlcskgqjt", 19, 9, 19);
+ test(S("ibmsnlrjefhtdokacqpg"), "drshcjknaf", 19, 10, 19);
+ test(S("mrkfciqjebaponsthldg"), "etsaqroinghpkjdlfcbm", 19, 0, 19);
+ test(S("mjkticdeoqshpalrfbgn"), "sgepdnkqliambtrocfhj", 19, 1, 19);
+ test(S("rqnoclbdejgiphtfsakm"), "nlmcjaqgbsortfdihkpe", 19, 10, 18);
+ test(S("plkqbhmtfaeodjcrsing"), "racfnpmosldibqkghjet", 19, 19, 7);
+ test(S("oegalhmstjrfickpbndq"), "fjhdsctkqeiolagrnmbp", 19, 20, S::npos);
+ test(S("rdtgjcaohpblniekmsfq"), "", 20, 0, 19);
+ test(S("ofkqbnjetrmsaidphglc"), "ejanp", 20, 0, 19);
+ test(S("grkpahljcftesdmonqib"), "odife", 20, 1, 19);
+ test(S("jimlgbhfqkteospardcn"), "okaqd", 20, 2, 19);
+ test(S("gftenihpmslrjkqadcob"), "lcdbi", 20, 4, 18);
+ test(S("bmhldogtckrfsanijepq"), "fsqbj", 20, 5, 18);
+ test(S("nfqkrpjdesabgtlcmoih"), "bigdomnplq", 20, 0, 19);
+ test(S("focalnrpiqmdkstehbjg"), "apiblotgcd", 20, 1, 19);
+ test(S("rhqdspkmebiflcotnjga"), "acfhdenops", 20, 5, 18);
+ test(S("rahdtmsckfboqlpniegj"), "jopdeamcrk", 20, 9, 18);
+ test(S("fbkeiopclstmdqranjhg"), "trqncbkgmh", 20, 10, 17);
+ test(S("lifhpdgmbconstjeqark"), "tomglrkencbsfjqpihda", 20, 0, 19);
+}
+
+template <class S>
+void test3()
+{
+ test(S("pboqganrhedjmltsicfk"), "gbkhdnpoietfcmrslajq", 20, 1, 19);
+ test(S("klchabsimetjnqgorfpd"), "rtfnmbsglkjaichoqedp", 20, 10, 19);
+ test(S("sirfgmjqhctndbklaepo"), "ohkmdpfqbsacrtjnlgei", 20, 19, 1);
+ test(S("rlbdsiceaonqjtfpghkm"), "dlbrteoisgphmkncajfq", 20, 20, S::npos);
+ test(S("ecgdanriptblhjfqskom"), "", 21, 0, 19);
+ test(S("fdmiarlpgcskbhoteqjn"), "sjrlo", 21, 0, 19);
+ test(S("rlbstjqopignecmfadkh"), "qjpor", 21, 1, 19);
+ test(S("grjpqmbshektdolcafni"), "odhfn", 21, 2, 19);
+ test(S("sakfcohtqnibprjmlged"), "qtfin", 21, 4, 19);
+ test(S("mjtdglasihqpocebrfkn"), "hpqfo", 21, 5, 19);
+ test(S("okaplfrntghqbmeicsdj"), "fabmertkos", 21, 0, 19);
+ test(S("sahngemrtcjidqbklfpo"), "brqtgkmaej", 21, 1, 19);
+ test(S("dlmsipcnekhbgoaftqjr"), "nfrdeihsgl", 21, 5, 18);
+ test(S("ahegrmqnoiklpfsdbcjt"), "hlfrosekpi", 21, 9, 19);
+ test(S("hdsjbnmlegtkqripacof"), "atgbkrjdsm", 21, 10, 19);
+ test(S("pcnedrfjihqbalkgtoms"), "blnrptjgqmaifsdkhoec", 21, 0, 19);
+ test(S("qjidealmtpskrbfhocng"), "ctpmdahebfqjgknloris", 21, 1, 19);
+ test(S("qeindtagmokpfhsclrbj"), "apnkeqthrmlbfodiscgj", 21, 10, 19);
+ test(S("kpfegbjhsrnodltqciam"), "jdgictpframeoqlsbknh", 21, 19, 7);
+ test(S("hnbrcplsjfgiktoedmaq"), "qprlsfojamgndekthibc", 21, 20, S::npos);
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test0<S>();
+ test1<S>();
+ test2<S>();
+ test3<S>();
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test0<S>();
+ test1<S>();
+ test2<S>();
+ test3<S>();
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.ops/string_find.last.not.of/string_size.pass.cpp b/test/std/strings/basic.string/string.ops/string_find.last.not.of/string_size.pass.cpp
new file mode 100644
index 000000000000..ba93adbe445e
--- /dev/null
+++ b/test/std/strings/basic.string/string.ops/string_find.last.not.of/string_size.pass.cpp
@@ -0,0 +1,157 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type find_last_not_of(const basic_string& str, size_type pos = npos) const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& s, const S& str, typename S::size_type pos, typename S::size_type x)
+{
+ assert(s.find_last_not_of(str, pos) == x);
+ if (x != S::npos)
+ assert(x <= pos && x < s.size());
+}
+
+template <class S>
+void
+test(const S& s, const S& str, typename S::size_type x)
+{
+ assert(s.find_last_not_of(str) == x);
+ if (x != S::npos)
+ assert(x < s.size());
+}
+
+template <class S>
+void test0()
+{
+ test(S(""), S(""), 0, S::npos);
+ test(S(""), S("laenf"), 0, S::npos);
+ test(S(""), S("pqlnkmbdjo"), 0, S::npos);
+ test(S(""), S("qkamfogpnljdcshbreti"), 0, S::npos);
+ test(S(""), S(""), 1, S::npos);
+ test(S(""), S("bjaht"), 1, S::npos);
+ test(S(""), S("hjlcmgpket"), 1, S::npos);
+ test(S(""), S("htaobedqikfplcgjsmrn"), 1, S::npos);
+ test(S("fodgq"), S(""), 0, 0);
+ test(S("qanej"), S("dfkap"), 0, 0);
+ test(S("clbao"), S("ihqrfebgad"), 0, 0);
+ test(S("mekdn"), S("ngtjfcalbseiqrphmkdo"), 0, S::npos);
+ test(S("srdfq"), S(""), 1, 1);
+ test(S("oemth"), S("ikcrq"), 1, 1);
+ test(S("cdaih"), S("dmajblfhsg"), 1, 0);
+ test(S("qohtk"), S("oqftjhdmkgsblacenirp"), 1, S::npos);
+ test(S("cshmd"), S(""), 2, 2);
+ test(S("lhcdo"), S("oebqi"), 2, 2);
+ test(S("qnsoh"), S("kojhpmbsfe"), 2, 1);
+ test(S("pkrof"), S("acbsjqogpltdkhinfrem"), 2, S::npos);
+ test(S("fmtsp"), S(""), 4, 4);
+ test(S("khbpm"), S("aobjd"), 4, 4);
+ test(S("pbsji"), S("pcbahntsje"), 4, 4);
+ test(S("mprdj"), S("fhepcrntkoagbmldqijs"), 4, S::npos);
+ test(S("eqmpa"), S(""), 5, 4);
+ test(S("omigs"), S("kocgb"), 5, 4);
+ test(S("onmje"), S("fbslrjiqkm"), 5, 4);
+ test(S("oqmrj"), S("jeidpcmalhfnqbgtrsko"), 5, S::npos);
+ test(S("schfa"), S(""), 6, 4);
+ test(S("igdsc"), S("qngpd"), 6, 4);
+ test(S("brqgo"), S("rodhqklgmb"), 6, S::npos);
+ test(S("tnrph"), S("thdjgafrlbkoiqcspmne"), 6, S::npos);
+ test(S("hcjitbfapl"), S(""), 0, 0);
+ test(S("daiprenocl"), S("ashjd"), 0, S::npos);
+ test(S("litpcfdghe"), S("mgojkldsqh"), 0, S::npos);
+ test(S("aidjksrolc"), S("imqnaghkfrdtlopbjesc"), 0, S::npos);
+ test(S("qpghtfbaji"), S(""), 1, 1);
+ test(S("gfshlcmdjr"), S("nadkh"), 1, 1);
+ test(S("nkodajteqp"), S("ofdrqmkebl"), 1, 0);
+ test(S("gbmetiprqd"), S("bdfjqgatlksriohemnpc"), 1, S::npos);
+ test(S("crnklpmegd"), S(""), 5, 5);
+ test(S("jsbtafedoc"), S("prqgn"), 5, 5);
+ test(S("qnmodrtkeb"), S("pejafmnokr"), 5, 4);
+ test(S("cpebqsfmnj"), S("odnqkgijrhabfmcestlp"), 5, S::npos);
+ test(S("lmofqdhpki"), S(""), 9, 9);
+ test(S("hnefkqimca"), S("rtjpa"), 9, 8);
+ test(S("drtasbgmfp"), S("ktsrmnqagd"), 9, 9);
+ test(S("lsaijeqhtr"), S("rtdhgcisbnmoaqkfpjle"), 9, S::npos);
+ test(S("elgofjmbrq"), S(""), 10, 9);
+ test(S("mjqdgalkpc"), S("dplqa"), 10, 9);
+ test(S("kthqnfcerm"), S("dkacjoptns"), 10, 9);
+ test(S("dfsjhanorc"), S("hqfimtrgnbekpdcsjalo"), 10, S::npos);
+ test(S("eqsgalomhb"), S(""), 11, 9);
+ test(S("akiteljmoh"), S("lofbc"), 11, 9);
+ test(S("hlbdfreqjo"), S("astoegbfpn"), 11, 8);
+ test(S("taqobhlerg"), S("pdgreqomsncafklhtibj"), 11, S::npos);
+ test(S("snafbdlghrjkpqtoceim"), S(""), 0, 0);
+ test(S("aemtbrgcklhndjisfpoq"), S("lbtqd"), 0, 0);
+ test(S("pnracgfkjdiholtbqsem"), S("tboimldpjh"), 0, S::npos);
+ test(S("dicfltehbsgrmojnpkaq"), S("slcerthdaiqjfnobgkpm"), 0, S::npos);
+ test(S("jlnkraeodhcspfgbqitm"), S(""), 1, 1);
+ test(S("lhosrngtmfjikbqpcade"), S("aqibs"), 1, 1);
+ test(S("rbtaqjhgkneisldpmfoc"), S("gtfblmqinc"), 1, 0);
+ test(S("gpifsqlrdkbonjtmheca"), S("mkqpbtdalgniorhfescj"), 1, S::npos);
+ test(S("hdpkobnsalmcfijregtq"), S(""), 10, 10);
+ test(S("jtlshdgqaiprkbcoenfm"), S("pblas"), 10, 9);
+ test(S("fkdrbqltsgmcoiphneaj"), S("arosdhcfme"), 10, 9);
+ test(S("crsplifgtqedjohnabmk"), S("blkhjeogicatqfnpdmsr"), 10, S::npos);
+ test(S("niptglfbosehkamrdqcj"), S(""), 19, 19);
+ test(S("copqdhstbingamjfkler"), S("djkqc"), 19, 19);
+ test(S("mrtaefilpdsgocnhqbjk"), S("lgokshjtpb"), 19, 16);
+ test(S("kojatdhlcmigpbfrqnes"), S("bqjhtkfepimcnsgrlado"), 19, S::npos);
+ test(S("eaintpchlqsbdgrkjofm"), S(""), 20, 19);
+ test(S("gjnhidfsepkrtaqbmclo"), S("nocfa"), 20, 18);
+ test(S("spocfaktqdbiejlhngmr"), S("bgtajmiedc"), 20, 19);
+ test(S("rphmlekgfscndtaobiqj"), S("lsckfnqgdahejiopbtmr"), 20, S::npos);
+ test(S("liatsqdoegkmfcnbhrpj"), S(""), 21, 19);
+ test(S("binjagtfldkrspcomqeh"), S("gfsrt"), 21, 19);
+ test(S("latkmisecnorjbfhqpdg"), S("pfsocbhjtm"), 21, 19);
+ test(S("lecfratdjkhnsmqpoigb"), S("tpflmdnoicjgkberhqsa"), 21, S::npos);
+}
+
+template <class S>
+void test1()
+{
+ test(S(""), S(""), S::npos);
+ test(S(""), S("laenf"), S::npos);
+ test(S(""), S("pqlnkmbdjo"), S::npos);
+ test(S(""), S("qkamfogpnljdcshbreti"), S::npos);
+ test(S("nhmko"), S(""), 4);
+ test(S("lahfb"), S("irkhs"), 4);
+ test(S("gmfhd"), S("kantesmpgj"), 4);
+ test(S("odaft"), S("oknlrstdpiqmjbaghcfe"), S::npos);
+ test(S("eolhfgpjqk"), S(""), 9);
+ test(S("nbatdlmekr"), S("bnrpe"), 8);
+ test(S("jdmciepkaq"), S("jtdaefblso"), 9);
+ test(S("hkbgspoflt"), S("oselktgbcapndfjihrmq"), S::npos);
+ test(S("gprdcokbnjhlsfmtieqa"), S(""), 19);
+ test(S("qjghlnftcaismkropdeb"), S("bjaht"), 18);
+ test(S("pnalfrdtkqcmojiesbhg"), S("hjlcmgpket"), 17);
+ test(S("pniotcfrhqsmgdkjbael"), S("htaobedqikfplcgjsmrn"), S::npos);
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test0<S>();
+ test1<S>();
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test0<S>();
+ test1<S>();
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.ops/string_find.last.of/char_size.pass.cpp b/test/std/strings/basic.string/string.ops/string_find.last.of/char_size.pass.cpp
new file mode 100644
index 000000000000..12765b71f28f
--- /dev/null
+++ b/test/std/strings/basic.string/string.ops/string_find.last.of/char_size.pass.cpp
@@ -0,0 +1,98 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type find_last_of(charT c, size_type pos = npos) const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& s, typename S::value_type c, typename S::size_type pos,
+ typename S::size_type x)
+{
+ assert(s.find_last_of(c, pos) == x);
+ if (x != S::npos)
+ assert(x <= pos && x < s.size());
+}
+
+template <class S>
+void
+test(const S& s, typename S::value_type c, typename S::size_type x)
+{
+ assert(s.find_last_of(c) == x);
+ if (x != S::npos)
+ assert(x < s.size());
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test(S(""), 'm', 0, S::npos);
+ test(S(""), 'm', 1, S::npos);
+ test(S("kitcj"), 'm', 0, S::npos);
+ test(S("qkamf"), 'm', 1, S::npos);
+ test(S("nhmko"), 'm', 2, 2);
+ test(S("tpsaf"), 'm', 4, S::npos);
+ test(S("lahfb"), 'm', 5, S::npos);
+ test(S("irkhs"), 'm', 6, S::npos);
+ test(S("gmfhdaipsr"), 'm', 0, S::npos);
+ test(S("kantesmpgj"), 'm', 1, S::npos);
+ test(S("odaftiegpm"), 'm', 5, S::npos);
+ test(S("oknlrstdpi"), 'm', 9, S::npos);
+ test(S("eolhfgpjqk"), 'm', 10, S::npos);
+ test(S("pcdrofikas"), 'm', 11, S::npos);
+ test(S("nbatdlmekrgcfqsophij"), 'm', 0, S::npos);
+ test(S("bnrpehidofmqtcksjgla"), 'm', 1, S::npos);
+ test(S("jdmciepkaqgotsrfnhlb"), 'm', 10, 2);
+ test(S("jtdaefblsokrmhpgcnqi"), 'm', 19, 12);
+ test(S("hkbgspofltajcnedqmri"), 'm', 20, 17);
+ test(S("oselktgbcapndfjihrmq"), 'm', 21, 18);
+
+ test(S(""), 'm', S::npos);
+ test(S("csope"), 'm', S::npos);
+ test(S("gfsmthlkon"), 'm', 3);
+ test(S("laenfsbridchgotmkqpj"), 'm', 15);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S(""), 'm', 0, S::npos);
+ test(S(""), 'm', 1, S::npos);
+ test(S("kitcj"), 'm', 0, S::npos);
+ test(S("qkamf"), 'm', 1, S::npos);
+ test(S("nhmko"), 'm', 2, 2);
+ test(S("tpsaf"), 'm', 4, S::npos);
+ test(S("lahfb"), 'm', 5, S::npos);
+ test(S("irkhs"), 'm', 6, S::npos);
+ test(S("gmfhdaipsr"), 'm', 0, S::npos);
+ test(S("kantesmpgj"), 'm', 1, S::npos);
+ test(S("odaftiegpm"), 'm', 5, S::npos);
+ test(S("oknlrstdpi"), 'm', 9, S::npos);
+ test(S("eolhfgpjqk"), 'm', 10, S::npos);
+ test(S("pcdrofikas"), 'm', 11, S::npos);
+ test(S("nbatdlmekrgcfqsophij"), 'm', 0, S::npos);
+ test(S("bnrpehidofmqtcksjgla"), 'm', 1, S::npos);
+ test(S("jdmciepkaqgotsrfnhlb"), 'm', 10, 2);
+ test(S("jtdaefblsokrmhpgcnqi"), 'm', 19, 12);
+ test(S("hkbgspofltajcnedqmri"), 'm', 20, 17);
+ test(S("oselktgbcapndfjihrmq"), 'm', 21, 18);
+
+ test(S(""), 'm', S::npos);
+ test(S("csope"), 'm', S::npos);
+ test(S("gfsmthlkon"), 'm', 3);
+ test(S("laenfsbridchgotmkqpj"), 'm', 15);
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.ops/string_find.last.of/pointer_size.pass.cpp b/test/std/strings/basic.string/string.ops/string_find.last.of/pointer_size.pass.cpp
new file mode 100644
index 000000000000..f1b447c43f4b
--- /dev/null
+++ b/test/std/strings/basic.string/string.ops/string_find.last.of/pointer_size.pass.cpp
@@ -0,0 +1,158 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type find_last_of(const charT* s, size_type pos = npos) const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type pos,
+ typename S::size_type x)
+{
+ assert(s.find_last_of(str, pos) == x);
+ if (x != S::npos)
+ assert(x <= pos && x < s.size());
+}
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type x)
+{
+ assert(s.find_last_of(str) == x);
+ if (x != S::npos)
+ assert(x < s.size());
+}
+
+template <class S>
+void test0()
+{
+ test(S(""), "", 0, S::npos);
+ test(S(""), "laenf", 0, S::npos);
+ test(S(""), "pqlnkmbdjo", 0, S::npos);
+ test(S(""), "qkamfogpnljdcshbreti", 0, S::npos);
+ test(S(""), "", 1, S::npos);
+ test(S(""), "bjaht", 1, S::npos);
+ test(S(""), "hjlcmgpket", 1, S::npos);
+ test(S(""), "htaobedqikfplcgjsmrn", 1, S::npos);
+ test(S("fodgq"), "", 0, S::npos);
+ test(S("qanej"), "dfkap", 0, S::npos);
+ test(S("clbao"), "ihqrfebgad", 0, S::npos);
+ test(S("mekdn"), "ngtjfcalbseiqrphmkdo", 0, 0);
+ test(S("srdfq"), "", 1, S::npos);
+ test(S("oemth"), "ikcrq", 1, S::npos);
+ test(S("cdaih"), "dmajblfhsg", 1, 1);
+ test(S("qohtk"), "oqftjhdmkgsblacenirp", 1, 1);
+ test(S("cshmd"), "", 2, S::npos);
+ test(S("lhcdo"), "oebqi", 2, S::npos);
+ test(S("qnsoh"), "kojhpmbsfe", 2, 2);
+ test(S("pkrof"), "acbsjqogpltdkhinfrem", 2, 2);
+ test(S("fmtsp"), "", 4, S::npos);
+ test(S("khbpm"), "aobjd", 4, 2);
+ test(S("pbsji"), "pcbahntsje", 4, 3);
+ test(S("mprdj"), "fhepcrntkoagbmldqijs", 4, 4);
+ test(S("eqmpa"), "", 5, S::npos);
+ test(S("omigs"), "kocgb", 5, 3);
+ test(S("onmje"), "fbslrjiqkm", 5, 3);
+ test(S("oqmrj"), "jeidpcmalhfnqbgtrsko", 5, 4);
+ test(S("schfa"), "", 6, S::npos);
+ test(S("igdsc"), "qngpd", 6, 2);
+ test(S("brqgo"), "rodhqklgmb", 6, 4);
+ test(S("tnrph"), "thdjgafrlbkoiqcspmne", 6, 4);
+ test(S("hcjitbfapl"), "", 0, S::npos);
+ test(S("daiprenocl"), "ashjd", 0, 0);
+ test(S("litpcfdghe"), "mgojkldsqh", 0, 0);
+ test(S("aidjksrolc"), "imqnaghkfrdtlopbjesc", 0, 0);
+ test(S("qpghtfbaji"), "", 1, S::npos);
+ test(S("gfshlcmdjr"), "nadkh", 1, S::npos);
+ test(S("nkodajteqp"), "ofdrqmkebl", 1, 1);
+ test(S("gbmetiprqd"), "bdfjqgatlksriohemnpc", 1, 1);
+ test(S("crnklpmegd"), "", 5, S::npos);
+ test(S("jsbtafedoc"), "prqgn", 5, S::npos);
+ test(S("qnmodrtkeb"), "pejafmnokr", 5, 5);
+ test(S("cpebqsfmnj"), "odnqkgijrhabfmcestlp", 5, 5);
+ test(S("lmofqdhpki"), "", 9, S::npos);
+ test(S("hnefkqimca"), "rtjpa", 9, 9);
+ test(S("drtasbgmfp"), "ktsrmnqagd", 9, 7);
+ test(S("lsaijeqhtr"), "rtdhgcisbnmoaqkfpjle", 9, 9);
+ test(S("elgofjmbrq"), "", 10, S::npos);
+ test(S("mjqdgalkpc"), "dplqa", 10, 8);
+ test(S("kthqnfcerm"), "dkacjoptns", 10, 6);
+ test(S("dfsjhanorc"), "hqfimtrgnbekpdcsjalo", 10, 9);
+ test(S("eqsgalomhb"), "", 11, S::npos);
+ test(S("akiteljmoh"), "lofbc", 11, 8);
+ test(S("hlbdfreqjo"), "astoegbfpn", 11, 9);
+ test(S("taqobhlerg"), "pdgreqomsncafklhtibj", 11, 9);
+ test(S("snafbdlghrjkpqtoceim"), "", 0, S::npos);
+ test(S("aemtbrgcklhndjisfpoq"), "lbtqd", 0, S::npos);
+ test(S("pnracgfkjdiholtbqsem"), "tboimldpjh", 0, 0);
+ test(S("dicfltehbsgrmojnpkaq"), "slcerthdaiqjfnobgkpm", 0, 0);
+ test(S("jlnkraeodhcspfgbqitm"), "", 1, S::npos);
+ test(S("lhosrngtmfjikbqpcade"), "aqibs", 1, S::npos);
+ test(S("rbtaqjhgkneisldpmfoc"), "gtfblmqinc", 1, 1);
+ test(S("gpifsqlrdkbonjtmheca"), "mkqpbtdalgniorhfescj", 1, 1);
+ test(S("hdpkobnsalmcfijregtq"), "", 10, S::npos);
+ test(S("jtlshdgqaiprkbcoenfm"), "pblas", 10, 10);
+ test(S("fkdrbqltsgmcoiphneaj"), "arosdhcfme", 10, 10);
+ test(S("crsplifgtqedjohnabmk"), "blkhjeogicatqfnpdmsr", 10, 10);
+ test(S("niptglfbosehkamrdqcj"), "", 19, S::npos);
+ test(S("copqdhstbingamjfkler"), "djkqc", 19, 16);
+ test(S("mrtaefilpdsgocnhqbjk"), "lgokshjtpb", 19, 19);
+ test(S("kojatdhlcmigpbfrqnes"), "bqjhtkfepimcnsgrlado", 19, 19);
+ test(S("eaintpchlqsbdgrkjofm"), "", 20, S::npos);
+ test(S("gjnhidfsepkrtaqbmclo"), "nocfa", 20, 19);
+ test(S("spocfaktqdbiejlhngmr"), "bgtajmiedc", 20, 18);
+ test(S("rphmlekgfscndtaobiqj"), "lsckfnqgdahejiopbtmr", 20, 19);
+ test(S("liatsqdoegkmfcnbhrpj"), "", 21, S::npos);
+ test(S("binjagtfldkrspcomqeh"), "gfsrt", 21, 12);
+ test(S("latkmisecnorjbfhqpdg"), "pfsocbhjtm", 21, 17);
+ test(S("lecfratdjkhnsmqpoigb"), "tpflmdnoicjgkberhqsa", 21, 19);
+}
+
+template <class S>
+void test1()
+{
+ test(S(""), "", S::npos);
+ test(S(""), "laenf", S::npos);
+ test(S(""), "pqlnkmbdjo", S::npos);
+ test(S(""), "qkamfogpnljdcshbreti", S::npos);
+ test(S("nhmko"), "", S::npos);
+ test(S("lahfb"), "irkhs", 2);
+ test(S("gmfhd"), "kantesmpgj", 1);
+ test(S("odaft"), "oknlrstdpiqmjbaghcfe", 4);
+ test(S("eolhfgpjqk"), "", S::npos);
+ test(S("nbatdlmekr"), "bnrpe", 9);
+ test(S("jdmciepkaq"), "jtdaefblso", 8);
+ test(S("hkbgspoflt"), "oselktgbcapndfjihrmq", 9);
+ test(S("gprdcokbnjhlsfmtieqa"), "", S::npos);
+ test(S("qjghlnftcaismkropdeb"), "bjaht", 19);
+ test(S("pnalfrdtkqcmojiesbhg"), "hjlcmgpket", 19);
+ test(S("pniotcfrhqsmgdkjbael"), "htaobedqikfplcgjsmrn", 19);
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test0<S>();
+ test1<S>();
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test0<S>();
+ test1<S>();
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.ops/string_find.last.of/pointer_size_size.pass.cpp b/test/std/strings/basic.string/string.ops/string_find.last.of/pointer_size_size.pass.cpp
new file mode 100644
index 000000000000..7f96e6351aa6
--- /dev/null
+++ b/test/std/strings/basic.string/string.ops/string_find.last.of/pointer_size_size.pass.cpp
@@ -0,0 +1,387 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type find_last_of(const charT* s, size_type pos, size_type n) const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type pos,
+ typename S::size_type n, typename S::size_type x)
+{
+ assert(s.find_last_of(str, pos, n) == x);
+ if (x != S::npos)
+ assert(x <= pos && x < s.size());
+}
+
+template <class S>
+void test0()
+{
+ test(S(""), "", 0, 0, S::npos);
+ test(S(""), "irkhs", 0, 0, S::npos);
+ test(S(""), "kante", 0, 1, S::npos);
+ test(S(""), "oknlr", 0, 2, S::npos);
+ test(S(""), "pcdro", 0, 4, S::npos);
+ test(S(""), "bnrpe", 0, 5, S::npos);
+ test(S(""), "jtdaefblso", 0, 0, S::npos);
+ test(S(""), "oselktgbca", 0, 1, S::npos);
+ test(S(""), "eqgaplhckj", 0, 5, S::npos);
+ test(S(""), "bjahtcmnlp", 0, 9, S::npos);
+ test(S(""), "hjlcmgpket", 0, 10, S::npos);
+ test(S(""), "htaobedqikfplcgjsmrn", 0, 0, S::npos);
+ test(S(""), "hpqiarojkcdlsgnmfetb", 0, 1, S::npos);
+ test(S(""), "dfkaprhjloqetcsimnbg", 0, 10, S::npos);
+ test(S(""), "ihqrfebgadntlpmjksoc", 0, 19, S::npos);
+ test(S(""), "ngtjfcalbseiqrphmkdo", 0, 20, S::npos);
+ test(S(""), "", 1, 0, S::npos);
+ test(S(""), "lbtqd", 1, 0, S::npos);
+ test(S(""), "tboim", 1, 1, S::npos);
+ test(S(""), "slcer", 1, 2, S::npos);
+ test(S(""), "cbjfs", 1, 4, S::npos);
+ test(S(""), "aqibs", 1, 5, S::npos);
+ test(S(""), "gtfblmqinc", 1, 0, S::npos);
+ test(S(""), "mkqpbtdalg", 1, 1, S::npos);
+ test(S(""), "kphatlimcd", 1, 5, S::npos);
+ test(S(""), "pblasqogic", 1, 9, S::npos);
+ test(S(""), "arosdhcfme", 1, 10, S::npos);
+ test(S(""), "blkhjeogicatqfnpdmsr", 1, 0, S::npos);
+ test(S(""), "bmhineprjcoadgstflqk", 1, 1, S::npos);
+ test(S(""), "djkqcmetslnghpbarfoi", 1, 10, S::npos);
+ test(S(""), "lgokshjtpbemarcdqnfi", 1, 19, S::npos);
+ test(S(""), "bqjhtkfepimcnsgrlado", 1, 20, S::npos);
+ test(S("eaint"), "", 0, 0, S::npos);
+ test(S("binja"), "gfsrt", 0, 0, S::npos);
+ test(S("latkm"), "pfsoc", 0, 1, S::npos);
+ test(S("lecfr"), "tpflm", 0, 2, S::npos);
+ test(S("eqkst"), "sgkec", 0, 4, 0);
+ test(S("cdafr"), "romds", 0, 5, S::npos);
+ test(S("prbhe"), "qhjistlgmr", 0, 0, S::npos);
+ test(S("lbisk"), "pedfirsglo", 0, 1, S::npos);
+ test(S("hrlpd"), "aqcoslgrmk", 0, 5, S::npos);
+ test(S("ehmja"), "dabckmepqj", 0, 9, 0);
+ test(S("mhqgd"), "pqscrjthli", 0, 10, S::npos);
+ test(S("tgklq"), "kfphdcsjqmobliagtren", 0, 0, S::npos);
+ test(S("bocjs"), "rokpefncljibsdhqtagm", 0, 1, S::npos);
+ test(S("grbsd"), "afionmkphlebtcjqsgrd", 0, 10, S::npos);
+ test(S("ofjqr"), "aenmqplidhkofrjbctsg", 0, 19, 0);
+ test(S("btlfi"), "osjmbtcadhiklegrpqnf", 0, 20, 0);
+ test(S("clrgb"), "", 1, 0, S::npos);
+ test(S("tjmek"), "osmia", 1, 0, S::npos);
+ test(S("bgstp"), "ckonl", 1, 1, S::npos);
+ test(S("hstrk"), "ilcaj", 1, 2, S::npos);
+ test(S("kmspj"), "lasiq", 1, 4, S::npos);
+ test(S("tjboh"), "kfqmr", 1, 5, S::npos);
+ test(S("ilbcj"), "klnitfaobg", 1, 0, S::npos);
+ test(S("jkngf"), "gjhmdlqikp", 1, 1, S::npos);
+ test(S("gfcql"), "skbgtahqej", 1, 5, 0);
+ test(S("dqtlg"), "bjsdgtlpkf", 1, 9, 0);
+ test(S("bthpg"), "bjgfmnlkio", 1, 10, 0);
+ test(S("dgsnq"), "lbhepotfsjdqigcnamkr", 1, 0, S::npos);
+ test(S("rmfhp"), "tebangckmpsrqdlfojhi", 1, 1, S::npos);
+ test(S("jfdam"), "joflqbdkhtegimscpanr", 1, 10, 1);
+ test(S("edapb"), "adpmcohetfbsrjinlqkg", 1, 19, 1);
+ test(S("brfsm"), "iacldqjpfnogbsrhmetk", 1, 20, 1);
+ test(S("ndrhl"), "", 2, 0, S::npos);
+ test(S("mrecp"), "otkgb", 2, 0, S::npos);
+ test(S("qlasf"), "cqsjl", 2, 1, S::npos);
+ test(S("smaqd"), "dpifl", 2, 2, S::npos);
+ test(S("hjeni"), "oapht", 2, 4, 0);
+ test(S("ocmfj"), "cifts", 2, 5, 1);
+ test(S("hmftq"), "nmsckbgalo", 2, 0, S::npos);
+ test(S("fklad"), "tpksqhamle", 2, 1, S::npos);
+ test(S("dirnm"), "tpdrchmkji", 2, 5, 2);
+ test(S("hrgdc"), "ijagfkblst", 2, 9, 2);
+ test(S("ifakg"), "kpocsignjb", 2, 10, 0);
+ test(S("ebrgd"), "pecqtkjsnbdrialgmohf", 2, 0, S::npos);
+ test(S("rcjml"), "aiortphfcmkjebgsndql", 2, 1, S::npos);
+ test(S("peqmt"), "sdbkeamglhipojqftrcn", 2, 10, 1);
+ test(S("frehn"), "ljqncehgmfktroapidbs", 2, 19, 2);
+ test(S("tqolf"), "rtcfodilamkbenjghqps", 2, 20, 2);
+ test(S("cjgao"), "", 4, 0, S::npos);
+ test(S("kjplq"), "mabns", 4, 0, S::npos);
+ test(S("herni"), "bdnrp", 4, 1, S::npos);
+ test(S("tadrb"), "scidp", 4, 2, S::npos);
+ test(S("pkfeo"), "agbjl", 4, 4, S::npos);
+ test(S("hoser"), "jfmpr", 4, 5, 4);
+ test(S("kgrsp"), "rbpefghsmj", 4, 0, S::npos);
+ test(S("pgejb"), "apsfntdoqc", 4, 1, S::npos);
+ test(S("thlnq"), "ndkjeisgcl", 4, 5, 3);
+ test(S("nbmit"), "rnfpqatdeo", 4, 9, 4);
+ test(S("jgmib"), "bntjlqrfik", 4, 10, 4);
+ test(S("ncrfj"), "kcrtmpolnaqejghsfdbi", 4, 0, S::npos);
+ test(S("ncsik"), "lobheanpkmqidsrtcfgj", 4, 1, S::npos);
+ test(S("sgbfh"), "athdkljcnreqbgpmisof", 4, 10, 4);
+ test(S("dktbn"), "qkdmjialrscpbhefgont", 4, 19, 4);
+ test(S("fthqm"), "dmasojntqleribkgfchp", 4, 20, 4);
+ test(S("klopi"), "", 5, 0, S::npos);
+ test(S("dajhn"), "psthd", 5, 0, S::npos);
+ test(S("jbgno"), "rpmjd", 5, 1, S::npos);
+ test(S("hkjae"), "dfsmk", 5, 2, S::npos);
+}
+
+template <class S>
+void test1()
+{
+ test(S("gbhqo"), "skqne", 5, 4, 3);
+ test(S("ktdor"), "kipnf", 5, 5, 0);
+ test(S("ldprn"), "hmrnqdgifl", 5, 0, S::npos);
+ test(S("egmjk"), "fsmjcdairn", 5, 1, S::npos);
+ test(S("armql"), "pcdgltbrfj", 5, 5, 4);
+ test(S("cdhjo"), "aekfctpirg", 5, 9, 0);
+ test(S("jcons"), "ledihrsgpf", 5, 10, 4);
+ test(S("cbrkp"), "mqcklahsbtirgopefndj", 5, 0, S::npos);
+ test(S("fhgna"), "kmlthaoqgecrnpdbjfis", 5, 1, S::npos);
+ test(S("ejfcd"), "sfhbamcdptojlkrenqgi", 5, 10, 4);
+ test(S("kqjhe"), "pbniofmcedrkhlstgaqj", 5, 19, 4);
+ test(S("pbdjl"), "mongjratcskbhqiepfdl", 5, 20, 4);
+ test(S("gajqn"), "", 6, 0, S::npos);
+ test(S("stedk"), "hrnat", 6, 0, S::npos);
+ test(S("tjkaf"), "gsqdt", 6, 1, S::npos);
+ test(S("dthpe"), "bspkd", 6, 2, S::npos);
+ test(S("klhde"), "ohcmb", 6, 4, 2);
+ test(S("bhlki"), "heatr", 6, 5, 1);
+ test(S("lqmoh"), "pmblckedfn", 6, 0, S::npos);
+ test(S("mtqin"), "aceqmsrbik", 6, 1, S::npos);
+ test(S("dpqbr"), "lmbtdehjrn", 6, 5, 3);
+ test(S("kdhmo"), "teqmcrlgib", 6, 9, 3);
+ test(S("jblqp"), "njolbmspac", 6, 10, 4);
+ test(S("qmjgl"), "pofnhidklamecrbqjgst", 6, 0, S::npos);
+ test(S("rothp"), "jbhckmtgrqnosafedpli", 6, 1, S::npos);
+ test(S("ghknq"), "dobntpmqklicsahgjerf", 6, 10, 4);
+ test(S("eopfi"), "tpdshainjkbfoemlrgcq", 6, 19, 4);
+ test(S("dsnmg"), "oldpfgeakrnitscbjmqh", 6, 20, 4);
+ test(S("jnkrfhotgl"), "", 0, 0, S::npos);
+ test(S("dltjfngbko"), "rqegt", 0, 0, S::npos);
+ test(S("bmjlpkiqde"), "dashm", 0, 1, S::npos);
+ test(S("skrflobnqm"), "jqirk", 0, 2, S::npos);
+ test(S("jkpldtshrm"), "rckeg", 0, 4, S::npos);
+ test(S("ghasdbnjqo"), "jscie", 0, 5, S::npos);
+ test(S("igrkhpbqjt"), "efsphndliq", 0, 0, S::npos);
+ test(S("ikthdgcamf"), "gdicosleja", 0, 1, S::npos);
+ test(S("pcofgeniam"), "qcpjibosfl", 0, 5, 0);
+ test(S("rlfjgesqhc"), "lrhmefnjcq", 0, 9, 0);
+ test(S("itphbqsker"), "dtablcrseo", 0, 10, S::npos);
+ test(S("skjafcirqm"), "apckjsftedbhgomrnilq", 0, 0, S::npos);
+ test(S("tcqomarsfd"), "pcbrgflehjtiadnsokqm", 0, 1, S::npos);
+ test(S("rocfeldqpk"), "nsiadegjklhobrmtqcpf", 0, 10, S::npos);
+ test(S("cfpegndlkt"), "cpmajdqnolikhgsbretf", 0, 19, 0);
+ test(S("fqbtnkeasj"), "jcflkntmgiqrphdosaeb", 0, 20, 0);
+ test(S("shbcqnmoar"), "", 1, 0, S::npos);
+ test(S("bdoshlmfin"), "ontrs", 1, 0, S::npos);
+ test(S("khfrebnsgq"), "pfkna", 1, 1, S::npos);
+ test(S("getcrsaoji"), "ekosa", 1, 2, 1);
+ test(S("fjiknedcpq"), "anqhk", 1, 4, S::npos);
+ test(S("tkejgnafrm"), "jekca", 1, 5, 1);
+ test(S("jnakolqrde"), "ikemsjgacf", 1, 0, S::npos);
+ test(S("lcjptsmgbe"), "arolgsjkhm", 1, 1, S::npos);
+ test(S("itfsmcjorl"), "oftkbldhre", 1, 5, 1);
+ test(S("omchkfrjea"), "gbkqdoeftl", 1, 9, 0);
+ test(S("cigfqkated"), "sqcflrgtim", 1, 10, 1);
+ test(S("tscenjikml"), "fmhbkislrjdpanogqcet", 1, 0, S::npos);
+ test(S("qcpaemsinf"), "rnioadktqlgpbcjsmhef", 1, 1, S::npos);
+ test(S("gltkojeipd"), "oakgtnldpsefihqmjcbr", 1, 10, 1);
+ test(S("qistfrgnmp"), "gbnaelosidmcjqktfhpr", 1, 19, 1);
+ test(S("bdnpfcqaem"), "akbripjhlosndcmqgfet", 1, 20, 1);
+ test(S("ectnhskflp"), "", 5, 0, S::npos);
+ test(S("fgtianblpq"), "pijag", 5, 0, S::npos);
+ test(S("mfeqklirnh"), "jrckd", 5, 1, S::npos);
+ test(S("astedncjhk"), "qcloh", 5, 2, S::npos);
+ test(S("fhlqgcajbr"), "thlmp", 5, 4, 2);
+ test(S("epfhocmdng"), "qidmo", 5, 5, 4);
+ test(S("apcnsibger"), "lnegpsjqrd", 5, 0, S::npos);
+ test(S("aqkocrbign"), "rjqdablmfs", 5, 1, 5);
+ test(S("ijsmdtqgce"), "enkgpbsjaq", 5, 5, S::npos);
+ test(S("clobgsrken"), "kdsgoaijfh", 5, 9, 5);
+ test(S("jbhcfposld"), "trfqgmckbe", 5, 10, 4);
+ test(S("oqnpblhide"), "igetsracjfkdnpoblhqm", 5, 0, S::npos);
+ test(S("lroeasctif"), "nqctfaogirshlekbdjpm", 5, 1, S::npos);
+ test(S("bpjlgmiedh"), "csehfgomljdqinbartkp", 5, 10, 5);
+ test(S("pamkeoidrj"), "qahoegcmplkfsjbdnitr", 5, 19, 5);
+ test(S("espogqbthk"), "dpteiajrqmsognhlfbkc", 5, 20, 5);
+ test(S("shoiedtcjb"), "", 9, 0, S::npos);
+ test(S("ebcinjgads"), "tqbnh", 9, 0, S::npos);
+ test(S("dqmregkcfl"), "akmle", 9, 1, S::npos);
+ test(S("ngcrieqajf"), "iqfkm", 9, 2, 6);
+ test(S("qosmilgnjb"), "tqjsr", 9, 4, 8);
+ test(S("ikabsjtdfl"), "jplqg", 9, 5, 9);
+ test(S("ersmicafdh"), "oilnrbcgtj", 9, 0, S::npos);
+ test(S("fdnplotmgh"), "morkglpesn", 9, 1, 7);
+ test(S("fdbicojerm"), "dmicerngat", 9, 5, 9);
+ test(S("mbtafndjcq"), "radgeskbtc", 9, 9, 6);
+ test(S("mlenkpfdtc"), "ljikprsmqo", 9, 10, 5);
+ test(S("ahlcifdqgs"), "trqihkcgsjamfdbolnpe", 9, 0, S::npos);
+ test(S("bgjemaltks"), "lqmthbsrekajgnofcipd", 9, 1, 6);
+ test(S("pdhslbqrfc"), "jtalmedribkgqsopcnfh", 9, 10, 7);
+ test(S("dirhtsnjkc"), "spqfoiclmtagejbndkrh", 9, 19, 9);
+ test(S("dlroktbcja"), "nmotklspigjrdhcfaebq", 9, 20, 9);
+ test(S("ncjpmaekbs"), "", 10, 0, S::npos);
+ test(S("hlbosgmrak"), "hpmsd", 10, 0, S::npos);
+ test(S("pqfhsgilen"), "qnpor", 10, 1, 1);
+ test(S("gqtjsbdckh"), "otdma", 10, 2, 2);
+ test(S("cfkqpjlegi"), "efhjg", 10, 4, 7);
+ test(S("beanrfodgj"), "odpte", 10, 5, 7);
+ test(S("adtkqpbjfi"), "bctdgfmolr", 10, 0, S::npos);
+ test(S("iomkfthagj"), "oaklidrbqg", 10, 1, 1);
+}
+
+template <class S>
+void test2()
+{
+ test(S("sdpcilonqj"), "dnjfsagktr", 10, 5, 9);
+ test(S("gtfbdkqeml"), "nejaktmiqg", 10, 9, 8);
+ test(S("bmeqgcdorj"), "pjqonlebsf", 10, 10, 9);
+ test(S("etqlcanmob"), "dshmnbtolcjepgaikfqr", 10, 0, S::npos);
+ test(S("roqmkbdtia"), "iogfhpabtjkqlrnemcds", 10, 1, 8);
+ test(S("kadsithljf"), "ngridfabjsecpqltkmoh", 10, 10, 9);
+ test(S("sgtkpbfdmh"), "athmknplcgofrqejsdib", 10, 19, 9);
+ test(S("qgmetnabkl"), "ldobhmqcafnjtkeisgrp", 10, 20, 9);
+ test(S("cqjohampgd"), "", 11, 0, S::npos);
+ test(S("hobitmpsan"), "aocjb", 11, 0, S::npos);
+ test(S("tjehkpsalm"), "jbrnk", 11, 1, 1);
+ test(S("ngfbojitcl"), "tqedg", 11, 2, 7);
+ test(S("rcfkdbhgjo"), "nqskp", 11, 4, 3);
+ test(S("qghptonrea"), "eaqkl", 11, 5, 9);
+ test(S("hnprfgqjdl"), "reaoicljqm", 11, 0, S::npos);
+ test(S("hlmgabenti"), "lsftgajqpm", 11, 1, 1);
+ test(S("ofcjanmrbs"), "rlpfogmits", 11, 5, 7);
+ test(S("jqedtkornm"), "shkncmiaqj", 11, 9, 9);
+ test(S("rfedlasjmg"), "fpnatrhqgs", 11, 10, 9);
+ test(S("talpqjsgkm"), "sjclemqhnpdbgikarfot", 11, 0, S::npos);
+ test(S("lrkcbtqpie"), "otcmedjikgsfnqbrhpla", 11, 1, S::npos);
+ test(S("cipogdskjf"), "bonsaefdqiprkhlgtjcm", 11, 10, 9);
+ test(S("nqedcojahi"), "egpscmahijlfnkrodqtb", 11, 19, 9);
+ test(S("hefnrkmctj"), "kmqbfepjthgilscrndoa", 11, 20, 9);
+ test(S("atqirnmekfjolhpdsgcb"), "", 0, 0, S::npos);
+ test(S("echfkmlpribjnqsaogtd"), "prboq", 0, 0, S::npos);
+ test(S("qnhiftdgcleajbpkrosm"), "fjcqh", 0, 1, S::npos);
+ test(S("chamfknorbedjitgslpq"), "fmosa", 0, 2, S::npos);
+ test(S("njhqpibfmtlkaecdrgso"), "qdbok", 0, 4, S::npos);
+ test(S("ebnghfsqkprmdcljoiat"), "amslg", 0, 5, S::npos);
+ test(S("letjomsgihfrpqbkancd"), "smpltjneqb", 0, 0, S::npos);
+ test(S("nblgoipcrqeaktshjdmf"), "flitskrnge", 0, 1, S::npos);
+ test(S("cehkbngtjoiflqapsmrd"), "pgqihmlbef", 0, 5, S::npos);
+ test(S("mignapfoklbhcqjetdrs"), "cfpdqjtgsb", 0, 9, S::npos);
+ test(S("ceatbhlsqjgpnokfrmdi"), "htpsiaflom", 0, 10, S::npos);
+ test(S("ocihkjgrdelpfnmastqb"), "kpjfiaceghsrdtlbnomq", 0, 0, S::npos);
+ test(S("noelgschdtbrjfmiqkap"), "qhtbomidljgafneksprc", 0, 1, S::npos);
+ test(S("dkclqfombepritjnghas"), "nhtjobkcefldimpsaqgr", 0, 10, S::npos);
+ test(S("miklnresdgbhqcojftap"), "prabcjfqnoeskilmtgdh", 0, 19, 0);
+ test(S("htbcigojaqmdkfrnlsep"), "dtrgmchilkasqoebfpjn", 0, 20, 0);
+ test(S("febhmqtjanokscdirpgl"), "", 1, 0, S::npos);
+ test(S("loakbsqjpcrdhftniegm"), "sqome", 1, 0, S::npos);
+ test(S("reagphsqflbitdcjmkno"), "smfte", 1, 1, S::npos);
+ test(S("jitlfrqemsdhkopncabg"), "ciboh", 1, 2, 1);
+ test(S("mhtaepscdnrjqgbkifol"), "haois", 1, 4, 1);
+ test(S("tocesrfmnglpbjihqadk"), "abfki", 1, 5, S::npos);
+ test(S("lpfmctjrhdagneskbqoi"), "frdkocntmq", 1, 0, S::npos);
+ test(S("lsmqaepkdhncirbtjfgo"), "oasbpedlnr", 1, 1, S::npos);
+ test(S("epoiqmtldrabnkjhcfsg"), "kltqmhgand", 1, 5, S::npos);
+ test(S("emgasrilpknqojhtbdcf"), "gdtfjchpmr", 1, 9, 1);
+ test(S("hnfiagdpcklrjetqbsom"), "ponmcqblet", 1, 10, 1);
+ test(S("nsdfebgajhmtricpoklq"), "sgphqdnofeiklatbcmjr", 1, 0, S::npos);
+ test(S("atjgfsdlpobmeiqhncrk"), "ljqprsmigtfoneadckbh", 1, 1, S::npos);
+ test(S("sitodfgnrejlahcbmqkp"), "ligeojhafnkmrcsqtbdp", 1, 10, 1);
+ test(S("fraghmbiceknltjpqosd"), "lsimqfnjarbopedkhcgt", 1, 19, 1);
+ test(S("pmafenlhqtdbkirjsogc"), "abedmfjlghniorcqptks", 1, 20, 1);
+ test(S("pihgmoeqtnakrjslcbfd"), "", 10, 0, S::npos);
+ test(S("gjdkeprctqblnhiafsom"), "hqtoa", 10, 0, S::npos);
+ test(S("mkpnblfdsahrcqijteog"), "cahif", 10, 1, S::npos);
+ test(S("gckarqnelodfjhmbptis"), "kehis", 10, 2, 7);
+ test(S("gqpskidtbclomahnrjfe"), "kdlmh", 10, 4, 10);
+ test(S("pkldjsqrfgitbhmaecno"), "paeql", 10, 5, 6);
+ test(S("aftsijrbeklnmcdqhgop"), "aghoqiefnb", 10, 0, S::npos);
+ test(S("mtlgdrhafjkbiepqnsoc"), "jrbqaikpdo", 10, 1, 9);
+ test(S("pqgirnaefthokdmbsclj"), "smjonaeqcl", 10, 5, 5);
+ test(S("kpdbgjmtherlsfcqoina"), "eqbdrkcfah", 10, 9, 10);
+ test(S("jrlbothiknqmdgcfasep"), "kapmsienhf", 10, 10, 9);
+ test(S("mjogldqferckabinptsh"), "jpqotrlenfcsbhkaimdg", 10, 0, S::npos);
+ test(S("apoklnefbhmgqcdrisjt"), "jlbmhnfgtcqprikeados", 10, 1, S::npos);
+ test(S("ifeopcnrjbhkdgatmqls"), "stgbhfmdaljnpqoicker", 10, 10, 10);
+ test(S("ckqhaiesmjdnrgolbtpf"), "oihcetflbjagdsrkmqpn", 10, 19, 10);
+ test(S("bnlgapfimcoterskqdjh"), "adtclebmnpjsrqfkigoh", 10, 20, 10);
+ test(S("kgdlrobpmjcthqsafeni"), "", 19, 0, S::npos);
+ test(S("dfkechomjapgnslbtqir"), "beafg", 19, 0, S::npos);
+ test(S("rloadknfbqtgmhcsipje"), "iclat", 19, 1, 16);
+ test(S("mgjhkolrnadqbpetcifs"), "rkhnf", 19, 2, 7);
+ test(S("cmlfakiojdrgtbsphqen"), "clshq", 19, 4, 16);
+ test(S("kghbfipeomsntdalrqjc"), "dtcoj", 19, 5, 19);
+ test(S("eldiqckrnmtasbghjfpo"), "rqosnjmfth", 19, 0, S::npos);
+ test(S("abqjcfedgotihlnspkrm"), "siatdfqglh", 19, 1, 15);
+ test(S("qfbadrtjsimkolcenhpg"), "mrlshtpgjq", 19, 5, 17);
+ test(S("abseghclkjqifmtodrnp"), "adlcskgqjt", 19, 9, 16);
+ test(S("ibmsnlrjefhtdokacqpg"), "drshcjknaf", 19, 10, 16);
+ test(S("mrkfciqjebaponsthldg"), "etsaqroinghpkjdlfcbm", 19, 0, S::npos);
+ test(S("mjkticdeoqshpalrfbgn"), "sgepdnkqliambtrocfhj", 19, 1, 10);
+ test(S("rqnoclbdejgiphtfsakm"), "nlmcjaqgbsortfdihkpe", 19, 10, 19);
+ test(S("plkqbhmtfaeodjcrsing"), "racfnpmosldibqkghjet", 19, 19, 19);
+ test(S("oegalhmstjrfickpbndq"), "fjhdsctkqeiolagrnmbp", 19, 20, 19);
+ test(S("rdtgjcaohpblniekmsfq"), "", 20, 0, S::npos);
+ test(S("ofkqbnjetrmsaidphglc"), "ejanp", 20, 0, S::npos);
+ test(S("grkpahljcftesdmonqib"), "odife", 20, 1, 15);
+ test(S("jimlgbhfqkteospardcn"), "okaqd", 20, 2, 12);
+ test(S("gftenihpmslrjkqadcob"), "lcdbi", 20, 4, 19);
+ test(S("bmhldogtckrfsanijepq"), "fsqbj", 20, 5, 19);
+ test(S("nfqkrpjdesabgtlcmoih"), "bigdomnplq", 20, 0, S::npos);
+ test(S("focalnrpiqmdkstehbjg"), "apiblotgcd", 20, 1, 3);
+ test(S("rhqdspkmebiflcotnjga"), "acfhdenops", 20, 5, 19);
+ test(S("rahdtmsckfboqlpniegj"), "jopdeamcrk", 20, 9, 19);
+ test(S("fbkeiopclstmdqranjhg"), "trqncbkgmh", 20, 10, 19);
+ test(S("lifhpdgmbconstjeqark"), "tomglrkencbsfjqpihda", 20, 0, S::npos);
+}
+
+template <class S>
+void test3()
+{
+ test(S("pboqganrhedjmltsicfk"), "gbkhdnpoietfcmrslajq", 20, 1, 4);
+ test(S("klchabsimetjnqgorfpd"), "rtfnmbsglkjaichoqedp", 20, 10, 17);
+ test(S("sirfgmjqhctndbklaepo"), "ohkmdpfqbsacrtjnlgei", 20, 19, 19);
+ test(S("rlbdsiceaonqjtfpghkm"), "dlbrteoisgphmkncajfq", 20, 20, 19);
+ test(S("ecgdanriptblhjfqskom"), "", 21, 0, S::npos);
+ test(S("fdmiarlpgcskbhoteqjn"), "sjrlo", 21, 0, S::npos);
+ test(S("rlbstjqopignecmfadkh"), "qjpor", 21, 1, 6);
+ test(S("grjpqmbshektdolcafni"), "odhfn", 21, 2, 13);
+ test(S("sakfcohtqnibprjmlged"), "qtfin", 21, 4, 10);
+ test(S("mjtdglasihqpocebrfkn"), "hpqfo", 21, 5, 17);
+ test(S("okaplfrntghqbmeicsdj"), "fabmertkos", 21, 0, S::npos);
+ test(S("sahngemrtcjidqbklfpo"), "brqtgkmaej", 21, 1, 14);
+ test(S("dlmsipcnekhbgoaftqjr"), "nfrdeihsgl", 21, 5, 19);
+ test(S("ahegrmqnoiklpfsdbcjt"), "hlfrosekpi", 21, 9, 14);
+ test(S("hdsjbnmlegtkqripacof"), "atgbkrjdsm", 21, 10, 16);
+ test(S("pcnedrfjihqbalkgtoms"), "blnrptjgqmaifsdkhoec", 21, 0, S::npos);
+ test(S("qjidealmtpskrbfhocng"), "ctpmdahebfqjgknloris", 21, 1, 17);
+ test(S("qeindtagmokpfhsclrbj"), "apnkeqthrmlbfodiscgj", 21, 10, 17);
+ test(S("kpfegbjhsrnodltqciam"), "jdgictpframeoqlsbknh", 21, 19, 19);
+ test(S("hnbrcplsjfgiktoedmaq"), "qprlsfojamgndekthibc", 21, 20, 19);
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test0<S>();
+ test1<S>();
+ test2<S>();
+ test3<S>();
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test0<S>();
+ test1<S>();
+ test2<S>();
+ test3<S>();
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.ops/string_find.last.of/string_size.pass.cpp b/test/std/strings/basic.string/string.ops/string_find.last.of/string_size.pass.cpp
new file mode 100644
index 000000000000..351c6727de2d
--- /dev/null
+++ b/test/std/strings/basic.string/string.ops/string_find.last.of/string_size.pass.cpp
@@ -0,0 +1,157 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type find_last_of(const basic_string& str, size_type pos = npos) const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& s, const S& str, typename S::size_type pos, typename S::size_type x)
+{
+ assert(s.find_last_of(str, pos) == x);
+ if (x != S::npos)
+ assert(x <= pos && x < s.size());
+}
+
+template <class S>
+void
+test(const S& s, const S& str, typename S::size_type x)
+{
+ assert(s.find_last_of(str) == x);
+ if (x != S::npos)
+ assert(x < s.size());
+}
+
+template <class S>
+void test0()
+{
+ test(S(""), S(""), 0, S::npos);
+ test(S(""), S("laenf"), 0, S::npos);
+ test(S(""), S("pqlnkmbdjo"), 0, S::npos);
+ test(S(""), S("qkamfogpnljdcshbreti"), 0, S::npos);
+ test(S(""), S(""), 1, S::npos);
+ test(S(""), S("bjaht"), 1, S::npos);
+ test(S(""), S("hjlcmgpket"), 1, S::npos);
+ test(S(""), S("htaobedqikfplcgjsmrn"), 1, S::npos);
+ test(S("fodgq"), S(""), 0, S::npos);
+ test(S("qanej"), S("dfkap"), 0, S::npos);
+ test(S("clbao"), S("ihqrfebgad"), 0, S::npos);
+ test(S("mekdn"), S("ngtjfcalbseiqrphmkdo"), 0, 0);
+ test(S("srdfq"), S(""), 1, S::npos);
+ test(S("oemth"), S("ikcrq"), 1, S::npos);
+ test(S("cdaih"), S("dmajblfhsg"), 1, 1);
+ test(S("qohtk"), S("oqftjhdmkgsblacenirp"), 1, 1);
+ test(S("cshmd"), S(""), 2, S::npos);
+ test(S("lhcdo"), S("oebqi"), 2, S::npos);
+ test(S("qnsoh"), S("kojhpmbsfe"), 2, 2);
+ test(S("pkrof"), S("acbsjqogpltdkhinfrem"), 2, 2);
+ test(S("fmtsp"), S(""), 4, S::npos);
+ test(S("khbpm"), S("aobjd"), 4, 2);
+ test(S("pbsji"), S("pcbahntsje"), 4, 3);
+ test(S("mprdj"), S("fhepcrntkoagbmldqijs"), 4, 4);
+ test(S("eqmpa"), S(""), 5, S::npos);
+ test(S("omigs"), S("kocgb"), 5, 3);
+ test(S("onmje"), S("fbslrjiqkm"), 5, 3);
+ test(S("oqmrj"), S("jeidpcmalhfnqbgtrsko"), 5, 4);
+ test(S("schfa"), S(""), 6, S::npos);
+ test(S("igdsc"), S("qngpd"), 6, 2);
+ test(S("brqgo"), S("rodhqklgmb"), 6, 4);
+ test(S("tnrph"), S("thdjgafrlbkoiqcspmne"), 6, 4);
+ test(S("hcjitbfapl"), S(""), 0, S::npos);
+ test(S("daiprenocl"), S("ashjd"), 0, 0);
+ test(S("litpcfdghe"), S("mgojkldsqh"), 0, 0);
+ test(S("aidjksrolc"), S("imqnaghkfrdtlopbjesc"), 0, 0);
+ test(S("qpghtfbaji"), S(""), 1, S::npos);
+ test(S("gfshlcmdjr"), S("nadkh"), 1, S::npos);
+ test(S("nkodajteqp"), S("ofdrqmkebl"), 1, 1);
+ test(S("gbmetiprqd"), S("bdfjqgatlksriohemnpc"), 1, 1);
+ test(S("crnklpmegd"), S(""), 5, S::npos);
+ test(S("jsbtafedoc"), S("prqgn"), 5, S::npos);
+ test(S("qnmodrtkeb"), S("pejafmnokr"), 5, 5);
+ test(S("cpebqsfmnj"), S("odnqkgijrhabfmcestlp"), 5, 5);
+ test(S("lmofqdhpki"), S(""), 9, S::npos);
+ test(S("hnefkqimca"), S("rtjpa"), 9, 9);
+ test(S("drtasbgmfp"), S("ktsrmnqagd"), 9, 7);
+ test(S("lsaijeqhtr"), S("rtdhgcisbnmoaqkfpjle"), 9, 9);
+ test(S("elgofjmbrq"), S(""), 10, S::npos);
+ test(S("mjqdgalkpc"), S("dplqa"), 10, 8);
+ test(S("kthqnfcerm"), S("dkacjoptns"), 10, 6);
+ test(S("dfsjhanorc"), S("hqfimtrgnbekpdcsjalo"), 10, 9);
+ test(S("eqsgalomhb"), S(""), 11, S::npos);
+ test(S("akiteljmoh"), S("lofbc"), 11, 8);
+ test(S("hlbdfreqjo"), S("astoegbfpn"), 11, 9);
+ test(S("taqobhlerg"), S("pdgreqomsncafklhtibj"), 11, 9);
+ test(S("snafbdlghrjkpqtoceim"), S(""), 0, S::npos);
+ test(S("aemtbrgcklhndjisfpoq"), S("lbtqd"), 0, S::npos);
+ test(S("pnracgfkjdiholtbqsem"), S("tboimldpjh"), 0, 0);
+ test(S("dicfltehbsgrmojnpkaq"), S("slcerthdaiqjfnobgkpm"), 0, 0);
+ test(S("jlnkraeodhcspfgbqitm"), S(""), 1, S::npos);
+ test(S("lhosrngtmfjikbqpcade"), S("aqibs"), 1, S::npos);
+ test(S("rbtaqjhgkneisldpmfoc"), S("gtfblmqinc"), 1, 1);
+ test(S("gpifsqlrdkbonjtmheca"), S("mkqpbtdalgniorhfescj"), 1, 1);
+ test(S("hdpkobnsalmcfijregtq"), S(""), 10, S::npos);
+ test(S("jtlshdgqaiprkbcoenfm"), S("pblas"), 10, 10);
+ test(S("fkdrbqltsgmcoiphneaj"), S("arosdhcfme"), 10, 10);
+ test(S("crsplifgtqedjohnabmk"), S("blkhjeogicatqfnpdmsr"), 10, 10);
+ test(S("niptglfbosehkamrdqcj"), S(""), 19, S::npos);
+ test(S("copqdhstbingamjfkler"), S("djkqc"), 19, 16);
+ test(S("mrtaefilpdsgocnhqbjk"), S("lgokshjtpb"), 19, 19);
+ test(S("kojatdhlcmigpbfrqnes"), S("bqjhtkfepimcnsgrlado"), 19, 19);
+ test(S("eaintpchlqsbdgrkjofm"), S(""), 20, S::npos);
+ test(S("gjnhidfsepkrtaqbmclo"), S("nocfa"), 20, 19);
+ test(S("spocfaktqdbiejlhngmr"), S("bgtajmiedc"), 20, 18);
+ test(S("rphmlekgfscndtaobiqj"), S("lsckfnqgdahejiopbtmr"), 20, 19);
+ test(S("liatsqdoegkmfcnbhrpj"), S(""), 21, S::npos);
+ test(S("binjagtfldkrspcomqeh"), S("gfsrt"), 21, 12);
+ test(S("latkmisecnorjbfhqpdg"), S("pfsocbhjtm"), 21, 17);
+ test(S("lecfratdjkhnsmqpoigb"), S("tpflmdnoicjgkberhqsa"), 21, 19);
+}
+
+template <class S>
+void test1()
+{
+ test(S(""), S(""), S::npos);
+ test(S(""), S("laenf"), S::npos);
+ test(S(""), S("pqlnkmbdjo"), S::npos);
+ test(S(""), S("qkamfogpnljdcshbreti"), S::npos);
+ test(S("nhmko"), S(""), S::npos);
+ test(S("lahfb"), S("irkhs"), 2);
+ test(S("gmfhd"), S("kantesmpgj"), 1);
+ test(S("odaft"), S("oknlrstdpiqmjbaghcfe"), 4);
+ test(S("eolhfgpjqk"), S(""), S::npos);
+ test(S("nbatdlmekr"), S("bnrpe"), 9);
+ test(S("jdmciepkaq"), S("jtdaefblso"), 8);
+ test(S("hkbgspoflt"), S("oselktgbcapndfjihrmq"), 9);
+ test(S("gprdcokbnjhlsfmtieqa"), S(""), S::npos);
+ test(S("qjghlnftcaismkropdeb"), S("bjaht"), 19);
+ test(S("pnalfrdtkqcmojiesbhg"), S("hjlcmgpket"), 19);
+ test(S("pniotcfrhqsmgdkjbael"), S("htaobedqikfplcgjsmrn"), 19);
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test0<S>();
+ test1<S>();
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test0<S>();
+ test1<S>();
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.ops/string_find/char_size.pass.cpp b/test/std/strings/basic.string/string.ops/string_find/char_size.pass.cpp
new file mode 100644
index 000000000000..24e58fc5f1ad
--- /dev/null
+++ b/test/std/strings/basic.string/string.ops/string_find/char_size.pass.cpp
@@ -0,0 +1,98 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type find(charT c, size_type pos = 0) const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& s, typename S::value_type c, typename S::size_type pos,
+ typename S::size_type x)
+{
+ assert(s.find(c, pos) == x);
+ if (x != S::npos)
+ assert(pos <= x && x + 1 <= s.size());
+}
+
+template <class S>
+void
+test(const S& s, typename S::value_type c, typename S::size_type x)
+{
+ assert(s.find(c) == x);
+ if (x != S::npos)
+ assert(0 <= x && x + 1 <= s.size());
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test(S(""), 'c', 0, S::npos);
+ test(S(""), 'c', 1, S::npos);
+ test(S("abcde"), 'c', 0, 2);
+ test(S("abcde"), 'c', 1, 2);
+ test(S("abcde"), 'c', 2, 2);
+ test(S("abcde"), 'c', 4, S::npos);
+ test(S("abcde"), 'c', 5, S::npos);
+ test(S("abcde"), 'c', 6, S::npos);
+ test(S("abcdeabcde"), 'c', 0, 2);
+ test(S("abcdeabcde"), 'c', 1, 2);
+ test(S("abcdeabcde"), 'c', 5, 7);
+ test(S("abcdeabcde"), 'c', 9, S::npos);
+ test(S("abcdeabcde"), 'c', 10, S::npos);
+ test(S("abcdeabcde"), 'c', 11, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), 'c', 0, 2);
+ test(S("abcdeabcdeabcdeabcde"), 'c', 1, 2);
+ test(S("abcdeabcdeabcdeabcde"), 'c', 10, 12);
+ test(S("abcdeabcdeabcdeabcde"), 'c', 19, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), 'c', 20, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), 'c', 21, S::npos);
+
+ test(S(""), 'c', S::npos);
+ test(S("abcde"), 'c', 2);
+ test(S("abcdeabcde"), 'c', 2);
+ test(S("abcdeabcdeabcdeabcde"), 'c', 2);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S(""), 'c', 0, S::npos);
+ test(S(""), 'c', 1, S::npos);
+ test(S("abcde"), 'c', 0, 2);
+ test(S("abcde"), 'c', 1, 2);
+ test(S("abcde"), 'c', 2, 2);
+ test(S("abcde"), 'c', 4, S::npos);
+ test(S("abcde"), 'c', 5, S::npos);
+ test(S("abcde"), 'c', 6, S::npos);
+ test(S("abcdeabcde"), 'c', 0, 2);
+ test(S("abcdeabcde"), 'c', 1, 2);
+ test(S("abcdeabcde"), 'c', 5, 7);
+ test(S("abcdeabcde"), 'c', 9, S::npos);
+ test(S("abcdeabcde"), 'c', 10, S::npos);
+ test(S("abcdeabcde"), 'c', 11, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), 'c', 0, 2);
+ test(S("abcdeabcdeabcdeabcde"), 'c', 1, 2);
+ test(S("abcdeabcdeabcdeabcde"), 'c', 10, 12);
+ test(S("abcdeabcdeabcdeabcde"), 'c', 19, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), 'c', 20, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), 'c', 21, S::npos);
+
+ test(S(""), 'c', S::npos);
+ test(S("abcde"), 'c', 2);
+ test(S("abcdeabcde"), 'c', 2);
+ test(S("abcdeabcdeabcdeabcde"), 'c', 2);
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.ops/string_find/pointer_size.pass.cpp b/test/std/strings/basic.string/string.ops/string_find/pointer_size.pass.cpp
new file mode 100644
index 000000000000..e00d7fd8a3dc
--- /dev/null
+++ b/test/std/strings/basic.string/string.ops/string_find/pointer_size.pass.cpp
@@ -0,0 +1,164 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type find(const charT* s, size_type pos = 0) const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type pos,
+ typename S::size_type x)
+{
+ assert(s.find(str, pos) == x);
+ if (x != S::npos)
+ {
+ typename S::size_type n = S::traits_type::length(str);
+ assert(pos <= x && x + n <= s.size());
+ }
+}
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type x)
+{
+ assert(s.find(str) == x);
+ if (x != S::npos)
+ {
+ typename S::size_type n = S::traits_type::length(str);
+ assert(0 <= x && x + n <= s.size());
+ }
+}
+
+template <class S>
+void test0()
+{
+ test(S(""), "", 0, 0);
+ test(S(""), "abcde", 0, S::npos);
+ test(S(""), "abcdeabcde", 0, S::npos);
+ test(S(""), "abcdeabcdeabcdeabcde", 0, S::npos);
+ test(S(""), "", 1, S::npos);
+ test(S(""), "abcde", 1, S::npos);
+ test(S(""), "abcdeabcde", 1, S::npos);
+ test(S(""), "abcdeabcdeabcdeabcde", 1, S::npos);
+ test(S("abcde"), "", 0, 0);
+ test(S("abcde"), "abcde", 0, 0);
+ test(S("abcde"), "abcdeabcde", 0, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 0, S::npos);
+ test(S("abcde"), "", 1, 1);
+ test(S("abcde"), "abcde", 1, S::npos);
+ test(S("abcde"), "abcdeabcde", 1, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 1, S::npos);
+ test(S("abcde"), "", 2, 2);
+ test(S("abcde"), "abcde", 2, S::npos);
+ test(S("abcde"), "abcdeabcde", 2, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 2, S::npos);
+ test(S("abcde"), "", 4, 4);
+ test(S("abcde"), "abcde", 4, S::npos);
+ test(S("abcde"), "abcdeabcde", 4, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 4, S::npos);
+ test(S("abcde"), "", 5, 5);
+ test(S("abcde"), "abcde", 5, S::npos);
+ test(S("abcde"), "abcdeabcde", 5, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 5, S::npos);
+ test(S("abcde"), "", 6, S::npos);
+ test(S("abcde"), "abcde", 6, S::npos);
+ test(S("abcde"), "abcdeabcde", 6, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 6, S::npos);
+ test(S("abcdeabcde"), "", 0, 0);
+ test(S("abcdeabcde"), "abcde", 0, 0);
+ test(S("abcdeabcde"), "abcdeabcde", 0, 0);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 0, S::npos);
+ test(S("abcdeabcde"), "", 1, 1);
+ test(S("abcdeabcde"), "abcde", 1, 5);
+ test(S("abcdeabcde"), "abcdeabcde", 1, S::npos);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 1, S::npos);
+ test(S("abcdeabcde"), "", 5, 5);
+ test(S("abcdeabcde"), "abcde", 5, 5);
+ test(S("abcdeabcde"), "abcdeabcde", 5, S::npos);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 5, S::npos);
+ test(S("abcdeabcde"), "", 9, 9);
+ test(S("abcdeabcde"), "abcde", 9, S::npos);
+ test(S("abcdeabcde"), "abcdeabcde", 9, S::npos);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 9, S::npos);
+ test(S("abcdeabcde"), "", 10, 10);
+ test(S("abcdeabcde"), "abcde", 10, S::npos);
+ test(S("abcdeabcde"), "abcdeabcde", 10, S::npos);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 10, S::npos);
+ test(S("abcdeabcde"), "", 11, S::npos);
+ test(S("abcdeabcde"), "abcde", 11, S::npos);
+ test(S("abcdeabcde"), "abcdeabcde", 11, S::npos);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 11, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "", 0, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 0, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 0, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0, 0);
+ test(S("abcdeabcdeabcdeabcde"), "", 1, 1);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 1, 5);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 1, 5);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 1, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "", 10, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 10, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 10, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 10, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "", 19, 19);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 19, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 19, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 19, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "", 20, 20);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 20, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 20, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 20, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "", 21, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 21, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 21, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 21, S::npos);
+}
+
+template <class S>
+void test1()
+{
+ test(S(""), "", 0);
+ test(S(""), "abcde", S::npos);
+ test(S(""), "abcdeabcde", S::npos);
+ test(S(""), "abcdeabcdeabcdeabcde", S::npos);
+ test(S("abcde"), "", 0);
+ test(S("abcde"), "abcde", 0);
+ test(S("abcde"), "abcdeabcde", S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", S::npos);
+ test(S("abcdeabcde"), "", 0);
+ test(S("abcdeabcde"), "abcde", 0);
+ test(S("abcdeabcde"), "abcdeabcde", 0);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "", 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0);
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test0<S>();
+ test1<S>();
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test0<S>();
+ test1<S>();
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.ops/string_find/pointer_size_size.pass.cpp b/test/std/strings/basic.string/string.ops/string_find/pointer_size_size.pass.cpp
new file mode 100644
index 000000000000..3006c466eed3
--- /dev/null
+++ b/test/std/strings/basic.string/string.ops/string_find/pointer_size_size.pass.cpp
@@ -0,0 +1,387 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type find(const charT* s, size_type pos, size_type n) const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type pos,
+ typename S::size_type n, typename S::size_type x)
+{
+ assert(s.find(str, pos, n) == x);
+ if (x != S::npos)
+ assert(pos <= x && x + n <= s.size());
+}
+
+template <class S>
+void test0()
+{
+ test(S(""), "", 0, 0, 0);
+ test(S(""), "abcde", 0, 0, 0);
+ test(S(""), "abcde", 0, 1, S::npos);
+ test(S(""), "abcde", 0, 2, S::npos);
+ test(S(""), "abcde", 0, 4, S::npos);
+ test(S(""), "abcde", 0, 5, S::npos);
+ test(S(""), "abcdeabcde", 0, 0, 0);
+ test(S(""), "abcdeabcde", 0, 1, S::npos);
+ test(S(""), "abcdeabcde", 0, 5, S::npos);
+ test(S(""), "abcdeabcde", 0, 9, S::npos);
+ test(S(""), "abcdeabcde", 0, 10, S::npos);
+ test(S(""), "abcdeabcdeabcdeabcde", 0, 0, 0);
+ test(S(""), "abcdeabcdeabcdeabcde", 0, 1, S::npos);
+ test(S(""), "abcdeabcdeabcdeabcde", 0, 10, S::npos);
+ test(S(""), "abcdeabcdeabcdeabcde", 0, 19, S::npos);
+ test(S(""), "abcdeabcdeabcdeabcde", 0, 20, S::npos);
+ test(S(""), "", 1, 0, S::npos);
+ test(S(""), "abcde", 1, 0, S::npos);
+ test(S(""), "abcde", 1, 1, S::npos);
+ test(S(""), "abcde", 1, 2, S::npos);
+ test(S(""), "abcde", 1, 4, S::npos);
+ test(S(""), "abcde", 1, 5, S::npos);
+ test(S(""), "abcdeabcde", 1, 0, S::npos);
+ test(S(""), "abcdeabcde", 1, 1, S::npos);
+ test(S(""), "abcdeabcde", 1, 5, S::npos);
+ test(S(""), "abcdeabcde", 1, 9, S::npos);
+ test(S(""), "abcdeabcde", 1, 10, S::npos);
+ test(S(""), "abcdeabcdeabcdeabcde", 1, 0, S::npos);
+ test(S(""), "abcdeabcdeabcdeabcde", 1, 1, S::npos);
+ test(S(""), "abcdeabcdeabcdeabcde", 1, 10, S::npos);
+ test(S(""), "abcdeabcdeabcdeabcde", 1, 19, S::npos);
+ test(S(""), "abcdeabcdeabcdeabcde", 1, 20, S::npos);
+ test(S("abcde"), "", 0, 0, 0);
+ test(S("abcde"), "abcde", 0, 0, 0);
+ test(S("abcde"), "abcde", 0, 1, 0);
+ test(S("abcde"), "abcde", 0, 2, 0);
+ test(S("abcde"), "abcde", 0, 4, 0);
+ test(S("abcde"), "abcde", 0, 5, 0);
+ test(S("abcde"), "abcdeabcde", 0, 0, 0);
+ test(S("abcde"), "abcdeabcde", 0, 1, 0);
+ test(S("abcde"), "abcdeabcde", 0, 5, 0);
+ test(S("abcde"), "abcdeabcde", 0, 9, S::npos);
+ test(S("abcde"), "abcdeabcde", 0, 10, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 0, 0, 0);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 0, 1, 0);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 0, 10, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 0, 19, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 0, 20, S::npos);
+ test(S("abcde"), "", 1, 0, 1);
+ test(S("abcde"), "abcde", 1, 0, 1);
+ test(S("abcde"), "abcde", 1, 1, S::npos);
+ test(S("abcde"), "abcde", 1, 2, S::npos);
+ test(S("abcde"), "abcde", 1, 4, S::npos);
+ test(S("abcde"), "abcde", 1, 5, S::npos);
+ test(S("abcde"), "abcdeabcde", 1, 0, 1);
+ test(S("abcde"), "abcdeabcde", 1, 1, S::npos);
+ test(S("abcde"), "abcdeabcde", 1, 5, S::npos);
+ test(S("abcde"), "abcdeabcde", 1, 9, S::npos);
+ test(S("abcde"), "abcdeabcde", 1, 10, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 1, 0, 1);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 1, 1, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 1, 10, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 1, 19, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 1, 20, S::npos);
+ test(S("abcde"), "", 2, 0, 2);
+ test(S("abcde"), "abcde", 2, 0, 2);
+ test(S("abcde"), "abcde", 2, 1, S::npos);
+ test(S("abcde"), "abcde", 2, 2, S::npos);
+ test(S("abcde"), "abcde", 2, 4, S::npos);
+ test(S("abcde"), "abcde", 2, 5, S::npos);
+ test(S("abcde"), "abcdeabcde", 2, 0, 2);
+ test(S("abcde"), "abcdeabcde", 2, 1, S::npos);
+ test(S("abcde"), "abcdeabcde", 2, 5, S::npos);
+ test(S("abcde"), "abcdeabcde", 2, 9, S::npos);
+ test(S("abcde"), "abcdeabcde", 2, 10, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 2, 0, 2);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 2, 1, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 2, 10, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 2, 19, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 2, 20, S::npos);
+ test(S("abcde"), "", 4, 0, 4);
+ test(S("abcde"), "abcde", 4, 0, 4);
+ test(S("abcde"), "abcde", 4, 1, S::npos);
+ test(S("abcde"), "abcde", 4, 2, S::npos);
+ test(S("abcde"), "abcde", 4, 4, S::npos);
+ test(S("abcde"), "abcde", 4, 5, S::npos);
+ test(S("abcde"), "abcdeabcde", 4, 0, 4);
+ test(S("abcde"), "abcdeabcde", 4, 1, S::npos);
+ test(S("abcde"), "abcdeabcde", 4, 5, S::npos);
+ test(S("abcde"), "abcdeabcde", 4, 9, S::npos);
+ test(S("abcde"), "abcdeabcde", 4, 10, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 4, 0, 4);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 4, 1, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 4, 10, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 4, 19, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 4, 20, S::npos);
+ test(S("abcde"), "", 5, 0, 5);
+ test(S("abcde"), "abcde", 5, 0, 5);
+ test(S("abcde"), "abcde", 5, 1, S::npos);
+ test(S("abcde"), "abcde", 5, 2, S::npos);
+}
+
+template <class S>
+void test1()
+{
+ test(S("abcde"), "abcde", 5, 4, S::npos);
+ test(S("abcde"), "abcde", 5, 5, S::npos);
+ test(S("abcde"), "abcdeabcde", 5, 0, 5);
+ test(S("abcde"), "abcdeabcde", 5, 1, S::npos);
+ test(S("abcde"), "abcdeabcde", 5, 5, S::npos);
+ test(S("abcde"), "abcdeabcde", 5, 9, S::npos);
+ test(S("abcde"), "abcdeabcde", 5, 10, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 5, 0, 5);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 5, 1, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 5, 10, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 5, 19, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 5, 20, S::npos);
+ test(S("abcde"), "", 6, 0, S::npos);
+ test(S("abcde"), "abcde", 6, 0, S::npos);
+ test(S("abcde"), "abcde", 6, 1, S::npos);
+ test(S("abcde"), "abcde", 6, 2, S::npos);
+ test(S("abcde"), "abcde", 6, 4, S::npos);
+ test(S("abcde"), "abcde", 6, 5, S::npos);
+ test(S("abcde"), "abcdeabcde", 6, 0, S::npos);
+ test(S("abcde"), "abcdeabcde", 6, 1, S::npos);
+ test(S("abcde"), "abcdeabcde", 6, 5, S::npos);
+ test(S("abcde"), "abcdeabcde", 6, 9, S::npos);
+ test(S("abcde"), "abcdeabcde", 6, 10, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 6, 0, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 6, 1, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 6, 10, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 6, 19, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 6, 20, S::npos);
+ test(S("abcdeabcde"), "", 0, 0, 0);
+ test(S("abcdeabcde"), "abcde", 0, 0, 0);
+ test(S("abcdeabcde"), "abcde", 0, 1, 0);
+ test(S("abcdeabcde"), "abcde", 0, 2, 0);
+ test(S("abcdeabcde"), "abcde", 0, 4, 0);
+ test(S("abcdeabcde"), "abcde", 0, 5, 0);
+ test(S("abcdeabcde"), "abcdeabcde", 0, 0, 0);
+ test(S("abcdeabcde"), "abcdeabcde", 0, 1, 0);
+ test(S("abcdeabcde"), "abcdeabcde", 0, 5, 0);
+ test(S("abcdeabcde"), "abcdeabcde", 0, 9, 0);
+ test(S("abcdeabcde"), "abcdeabcde", 0, 10, 0);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 0, 0, 0);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 0, 1, 0);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 0, 10, 0);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 0, 19, S::npos);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 0, 20, S::npos);
+ test(S("abcdeabcde"), "", 1, 0, 1);
+ test(S("abcdeabcde"), "abcde", 1, 0, 1);
+ test(S("abcdeabcde"), "abcde", 1, 1, 5);
+ test(S("abcdeabcde"), "abcde", 1, 2, 5);
+ test(S("abcdeabcde"), "abcde", 1, 4, 5);
+ test(S("abcdeabcde"), "abcde", 1, 5, 5);
+ test(S("abcdeabcde"), "abcdeabcde", 1, 0, 1);
+ test(S("abcdeabcde"), "abcdeabcde", 1, 1, 5);
+ test(S("abcdeabcde"), "abcdeabcde", 1, 5, 5);
+ test(S("abcdeabcde"), "abcdeabcde", 1, 9, S::npos);
+ test(S("abcdeabcde"), "abcdeabcde", 1, 10, S::npos);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 1, 0, 1);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 1, 1, 5);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 1, 10, S::npos);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 1, 19, S::npos);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 1, 20, S::npos);
+ test(S("abcdeabcde"), "", 5, 0, 5);
+ test(S("abcdeabcde"), "abcde", 5, 0, 5);
+ test(S("abcdeabcde"), "abcde", 5, 1, 5);
+ test(S("abcdeabcde"), "abcde", 5, 2, 5);
+ test(S("abcdeabcde"), "abcde", 5, 4, 5);
+ test(S("abcdeabcde"), "abcde", 5, 5, 5);
+ test(S("abcdeabcde"), "abcdeabcde", 5, 0, 5);
+ test(S("abcdeabcde"), "abcdeabcde", 5, 1, 5);
+ test(S("abcdeabcde"), "abcdeabcde", 5, 5, 5);
+ test(S("abcdeabcde"), "abcdeabcde", 5, 9, S::npos);
+ test(S("abcdeabcde"), "abcdeabcde", 5, 10, S::npos);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 5, 0, 5);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 5, 1, 5);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 5, 10, S::npos);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 5, 19, S::npos);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 5, 20, S::npos);
+ test(S("abcdeabcde"), "", 9, 0, 9);
+ test(S("abcdeabcde"), "abcde", 9, 0, 9);
+ test(S("abcdeabcde"), "abcde", 9, 1, S::npos);
+ test(S("abcdeabcde"), "abcde", 9, 2, S::npos);
+ test(S("abcdeabcde"), "abcde", 9, 4, S::npos);
+ test(S("abcdeabcde"), "abcde", 9, 5, S::npos);
+ test(S("abcdeabcde"), "abcdeabcde", 9, 0, 9);
+ test(S("abcdeabcde"), "abcdeabcde", 9, 1, S::npos);
+ test(S("abcdeabcde"), "abcdeabcde", 9, 5, S::npos);
+ test(S("abcdeabcde"), "abcdeabcde", 9, 9, S::npos);
+ test(S("abcdeabcde"), "abcdeabcde", 9, 10, S::npos);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 9, 0, 9);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 9, 1, S::npos);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 9, 10, S::npos);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 9, 19, S::npos);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 9, 20, S::npos);
+ test(S("abcdeabcde"), "", 10, 0, 10);
+ test(S("abcdeabcde"), "abcde", 10, 0, 10);
+ test(S("abcdeabcde"), "abcde", 10, 1, S::npos);
+ test(S("abcdeabcde"), "abcde", 10, 2, S::npos);
+ test(S("abcdeabcde"), "abcde", 10, 4, S::npos);
+ test(S("abcdeabcde"), "abcde", 10, 5, S::npos);
+ test(S("abcdeabcde"), "abcdeabcde", 10, 0, 10);
+ test(S("abcdeabcde"), "abcdeabcde", 10, 1, S::npos);
+}
+
+template <class S>
+void test2()
+{
+ test(S("abcdeabcde"), "abcdeabcde", 10, 5, S::npos);
+ test(S("abcdeabcde"), "abcdeabcde", 10, 9, S::npos);
+ test(S("abcdeabcde"), "abcdeabcde", 10, 10, S::npos);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 10, 0, 10);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 10, 1, S::npos);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 10, 10, S::npos);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 10, 19, S::npos);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 10, 20, S::npos);
+ test(S("abcdeabcde"), "", 11, 0, S::npos);
+ test(S("abcdeabcde"), "abcde", 11, 0, S::npos);
+ test(S("abcdeabcde"), "abcde", 11, 1, S::npos);
+ test(S("abcdeabcde"), "abcde", 11, 2, S::npos);
+ test(S("abcdeabcde"), "abcde", 11, 4, S::npos);
+ test(S("abcdeabcde"), "abcde", 11, 5, S::npos);
+ test(S("abcdeabcde"), "abcdeabcde", 11, 0, S::npos);
+ test(S("abcdeabcde"), "abcdeabcde", 11, 1, S::npos);
+ test(S("abcdeabcde"), "abcdeabcde", 11, 5, S::npos);
+ test(S("abcdeabcde"), "abcdeabcde", 11, 9, S::npos);
+ test(S("abcdeabcde"), "abcdeabcde", 11, 10, S::npos);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 11, 0, S::npos);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 11, 1, S::npos);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 11, 10, S::npos);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 11, 19, S::npos);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 11, 20, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "", 0, 0, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 0, 0, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 0, 1, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 0, 2, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 0, 4, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 0, 5, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 0, 0, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 0, 1, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 0, 5, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 0, 9, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 0, 10, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0, 0, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0, 1, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0, 10, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0, 19, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0, 20, 0);
+ test(S("abcdeabcdeabcdeabcde"), "", 1, 0, 1);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 1, 0, 1);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 1, 1, 5);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 1, 2, 5);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 1, 4, 5);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 1, 5, 5);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 1, 0, 1);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 1, 1, 5);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 1, 5, 5);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 1, 9, 5);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 1, 10, 5);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 1, 0, 1);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 1, 1, 5);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 1, 10, 5);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 1, 19, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 1, 20, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "", 10, 0, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 10, 0, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 10, 1, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 10, 2, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 10, 4, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 10, 5, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 10, 0, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 10, 1, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 10, 5, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 10, 9, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 10, 10, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 10, 0, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 10, 1, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 10, 10, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 10, 19, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 10, 20, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "", 19, 0, 19);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 19, 0, 19);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 19, 1, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 19, 2, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 19, 4, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 19, 5, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 19, 0, 19);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 19, 1, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 19, 5, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 19, 9, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 19, 10, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 19, 0, 19);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 19, 1, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 19, 10, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 19, 19, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 19, 20, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "", 20, 0, 20);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 20, 0, 20);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 20, 1, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 20, 2, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 20, 4, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 20, 5, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 20, 0, 20);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 20, 1, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 20, 5, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 20, 9, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 20, 10, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 20, 0, 20);
+}
+
+template <class S>
+void test3()
+{
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 20, 1, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 20, 10, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 20, 19, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 20, 20, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "", 21, 0, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 21, 0, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 21, 1, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 21, 2, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 21, 4, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 21, 5, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 21, 0, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 21, 1, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 21, 5, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 21, 9, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 21, 10, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 21, 0, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 21, 1, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 21, 10, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 21, 19, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 21, 20, S::npos);
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test0<S>();
+ test1<S>();
+ test2<S>();
+ test3<S>();
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test0<S>();
+ test1<S>();
+ test2<S>();
+ test3<S>();
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.ops/string_find/string_size.pass.cpp b/test/std/strings/basic.string/string.ops/string_find/string_size.pass.cpp
new file mode 100644
index 000000000000..a89df4e3ffa1
--- /dev/null
+++ b/test/std/strings/basic.string/string.ops/string_find/string_size.pass.cpp
@@ -0,0 +1,157 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type find(const basic_string& str, size_type pos = 0) const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& s, const S& str, typename S::size_type pos, typename S::size_type x)
+{
+ assert(s.find(str, pos) == x);
+ if (x != S::npos)
+ assert(pos <= x && x + str.size() <= s.size());
+}
+
+template <class S>
+void
+test(const S& s, const S& str, typename S::size_type x)
+{
+ assert(s.find(str) == x);
+ if (x != S::npos)
+ assert(0 <= x && x + str.size() <= s.size());
+}
+
+template <class S>
+void test0()
+{
+ test(S(""), S(""), 0, 0);
+ test(S(""), S("abcde"), 0, S::npos);
+ test(S(""), S("abcdeabcde"), 0, S::npos);
+ test(S(""), S("abcdeabcdeabcdeabcde"), 0, S::npos);
+ test(S(""), S(""), 1, S::npos);
+ test(S(""), S("abcde"), 1, S::npos);
+ test(S(""), S("abcdeabcde"), 1, S::npos);
+ test(S(""), S("abcdeabcdeabcdeabcde"), 1, S::npos);
+ test(S("abcde"), S(""), 0, 0);
+ test(S("abcde"), S("abcde"), 0, 0);
+ test(S("abcde"), S("abcdeabcde"), 0, S::npos);
+ test(S("abcde"), S("abcdeabcdeabcdeabcde"), 0, S::npos);
+ test(S("abcde"), S(""), 1, 1);
+ test(S("abcde"), S("abcde"), 1, S::npos);
+ test(S("abcde"), S("abcdeabcde"), 1, S::npos);
+ test(S("abcde"), S("abcdeabcdeabcdeabcde"), 1, S::npos);
+ test(S("abcde"), S(""), 2, 2);
+ test(S("abcde"), S("abcde"), 2, S::npos);
+ test(S("abcde"), S("abcdeabcde"), 2, S::npos);
+ test(S("abcde"), S("abcdeabcdeabcdeabcde"), 2, S::npos);
+ test(S("abcde"), S(""), 4, 4);
+ test(S("abcde"), S("abcde"), 4, S::npos);
+ test(S("abcde"), S("abcdeabcde"), 4, S::npos);
+ test(S("abcde"), S("abcdeabcdeabcdeabcde"), 4, S::npos);
+ test(S("abcde"), S(""), 5, 5);
+ test(S("abcde"), S("abcde"), 5, S::npos);
+ test(S("abcde"), S("abcdeabcde"), 5, S::npos);
+ test(S("abcde"), S("abcdeabcdeabcdeabcde"), 5, S::npos);
+ test(S("abcde"), S(""), 6, S::npos);
+ test(S("abcde"), S("abcde"), 6, S::npos);
+ test(S("abcde"), S("abcdeabcde"), 6, S::npos);
+ test(S("abcde"), S("abcdeabcdeabcdeabcde"), 6, S::npos);
+ test(S("abcdeabcde"), S(""), 0, 0);
+ test(S("abcdeabcde"), S("abcde"), 0, 0);
+ test(S("abcdeabcde"), S("abcdeabcde"), 0, 0);
+ test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), 0, S::npos);
+ test(S("abcdeabcde"), S(""), 1, 1);
+ test(S("abcdeabcde"), S("abcde"), 1, 5);
+ test(S("abcdeabcde"), S("abcdeabcde"), 1, S::npos);
+ test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), 1, S::npos);
+ test(S("abcdeabcde"), S(""), 5, 5);
+ test(S("abcdeabcde"), S("abcde"), 5, 5);
+ test(S("abcdeabcde"), S("abcdeabcde"), 5, S::npos);
+ test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), 5, S::npos);
+ test(S("abcdeabcde"), S(""), 9, 9);
+ test(S("abcdeabcde"), S("abcde"), 9, S::npos);
+ test(S("abcdeabcde"), S("abcdeabcde"), 9, S::npos);
+ test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), 9, S::npos);
+ test(S("abcdeabcde"), S(""), 10, 10);
+ test(S("abcdeabcde"), S("abcde"), 10, S::npos);
+ test(S("abcdeabcde"), S("abcdeabcde"), 10, S::npos);
+ test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), 10, S::npos);
+ test(S("abcdeabcde"), S(""), 11, S::npos);
+ test(S("abcdeabcde"), S("abcde"), 11, S::npos);
+ test(S("abcdeabcde"), S("abcdeabcde"), 11, S::npos);
+ test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), 11, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), S(""), 0, 0);
+ test(S("abcdeabcdeabcdeabcde"), S("abcde"), 0, 0);
+ test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 0, 0);
+ test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 0, 0);
+ test(S("abcdeabcdeabcdeabcde"), S(""), 1, 1);
+ test(S("abcdeabcdeabcdeabcde"), S("abcde"), 1, 5);
+ test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 1, 5);
+ test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 1, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), S(""), 10, 10);
+ test(S("abcdeabcdeabcdeabcde"), S("abcde"), 10, 10);
+ test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 10, 10);
+ test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 10, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), S(""), 19, 19);
+ test(S("abcdeabcdeabcdeabcde"), S("abcde"), 19, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 19, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 19, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), S(""), 20, 20);
+ test(S("abcdeabcdeabcdeabcde"), S("abcde"), 20, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 20, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 20, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), S(""), 21, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), S("abcde"), 21, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 21, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 21, S::npos);
+}
+
+template <class S>
+void test1()
+{
+ test(S(""), S(""), 0);
+ test(S(""), S("abcde"), S::npos);
+ test(S(""), S("abcdeabcde"), S::npos);
+ test(S(""), S("abcdeabcdeabcdeabcde"), S::npos);
+ test(S("abcde"), S(""), 0);
+ test(S("abcde"), S("abcde"), 0);
+ test(S("abcde"), S("abcdeabcde"), S::npos);
+ test(S("abcde"), S("abcdeabcdeabcdeabcde"), S::npos);
+ test(S("abcdeabcde"), S(""), 0);
+ test(S("abcdeabcde"), S("abcde"), 0);
+ test(S("abcdeabcde"), S("abcdeabcde"), 0);
+ test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), S::npos);
+ test(S("abcdeabcdeabcdeabcde"), S(""), 0);
+ test(S("abcdeabcdeabcdeabcde"), S("abcde"), 0);
+ test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 0);
+ test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 0);
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test0<S>();
+ test1<S>();
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test0<S>();
+ test1<S>();
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.ops/string_rfind/char_size.pass.cpp b/test/std/strings/basic.string/string.ops/string_rfind/char_size.pass.cpp
new file mode 100644
index 000000000000..cbc0c9b35367
--- /dev/null
+++ b/test/std/strings/basic.string/string.ops/string_rfind/char_size.pass.cpp
@@ -0,0 +1,98 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type rfind(charT c, size_type pos = npos) const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& s, typename S::value_type c, typename S::size_type pos,
+ typename S::size_type x)
+{
+ assert(s.rfind(c, pos) == x);
+ if (x != S::npos)
+ assert(x <= pos && x + 1 <= s.size());
+}
+
+template <class S>
+void
+test(const S& s, typename S::value_type c, typename S::size_type x)
+{
+ assert(s.rfind(c) == x);
+ if (x != S::npos)
+ assert(x + 1 <= s.size());
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test(S(""), 'b', 0, S::npos);
+ test(S(""), 'b', 1, S::npos);
+ test(S("abcde"), 'b', 0, S::npos);
+ test(S("abcde"), 'b', 1, 1);
+ test(S("abcde"), 'b', 2, 1);
+ test(S("abcde"), 'b', 4, 1);
+ test(S("abcde"), 'b', 5, 1);
+ test(S("abcde"), 'b', 6, 1);
+ test(S("abcdeabcde"), 'b', 0, S::npos);
+ test(S("abcdeabcde"), 'b', 1, 1);
+ test(S("abcdeabcde"), 'b', 5, 1);
+ test(S("abcdeabcde"), 'b', 9, 6);
+ test(S("abcdeabcde"), 'b', 10, 6);
+ test(S("abcdeabcde"), 'b', 11, 6);
+ test(S("abcdeabcdeabcdeabcde"), 'b', 0, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), 'b', 1, 1);
+ test(S("abcdeabcdeabcdeabcde"), 'b', 10, 6);
+ test(S("abcdeabcdeabcdeabcde"), 'b', 19, 16);
+ test(S("abcdeabcdeabcdeabcde"), 'b', 20, 16);
+ test(S("abcdeabcdeabcdeabcde"), 'b', 21, 16);
+
+ test(S(""), 'b', S::npos);
+ test(S("abcde"), 'b', 1);
+ test(S("abcdeabcde"), 'b', 6);
+ test(S("abcdeabcdeabcdeabcde"), 'b', 16);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S(""), 'b', 0, S::npos);
+ test(S(""), 'b', 1, S::npos);
+ test(S("abcde"), 'b', 0, S::npos);
+ test(S("abcde"), 'b', 1, 1);
+ test(S("abcde"), 'b', 2, 1);
+ test(S("abcde"), 'b', 4, 1);
+ test(S("abcde"), 'b', 5, 1);
+ test(S("abcde"), 'b', 6, 1);
+ test(S("abcdeabcde"), 'b', 0, S::npos);
+ test(S("abcdeabcde"), 'b', 1, 1);
+ test(S("abcdeabcde"), 'b', 5, 1);
+ test(S("abcdeabcde"), 'b', 9, 6);
+ test(S("abcdeabcde"), 'b', 10, 6);
+ test(S("abcdeabcde"), 'b', 11, 6);
+ test(S("abcdeabcdeabcdeabcde"), 'b', 0, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), 'b', 1, 1);
+ test(S("abcdeabcdeabcdeabcde"), 'b', 10, 6);
+ test(S("abcdeabcdeabcdeabcde"), 'b', 19, 16);
+ test(S("abcdeabcdeabcdeabcde"), 'b', 20, 16);
+ test(S("abcdeabcdeabcdeabcde"), 'b', 21, 16);
+
+ test(S(""), 'b', S::npos);
+ test(S("abcde"), 'b', 1);
+ test(S("abcdeabcde"), 'b', 6);
+ test(S("abcdeabcdeabcdeabcde"), 'b', 16);
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.ops/string_rfind/pointer_size.pass.cpp b/test/std/strings/basic.string/string.ops/string_rfind/pointer_size.pass.cpp
new file mode 100644
index 000000000000..450aebedd59c
--- /dev/null
+++ b/test/std/strings/basic.string/string.ops/string_rfind/pointer_size.pass.cpp
@@ -0,0 +1,165 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type rfind(const charT* s, size_type pos = npos) const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type pos,
+ typename S::size_type x)
+{
+ assert(s.rfind(str, pos) == x);
+ if (x != S::npos)
+ {
+ typename S::size_type n = S::traits_type::length(str);
+ assert(x <= pos && x + n <= s.size());
+ }
+}
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type x)
+{
+ assert(s.rfind(str) == x);
+ if (x != S::npos)
+ {
+ typename S::size_type pos = s.size();
+ typename S::size_type n = S::traits_type::length(str);
+ assert(x <= pos && x + n <= s.size());
+ }
+}
+
+template <class S>
+void test0()
+{
+ test(S(""), "", 0, 0);
+ test(S(""), "abcde", 0, S::npos);
+ test(S(""), "abcdeabcde", 0, S::npos);
+ test(S(""), "abcdeabcdeabcdeabcde", 0, S::npos);
+ test(S(""), "", 1, 0);
+ test(S(""), "abcde", 1, S::npos);
+ test(S(""), "abcdeabcde", 1, S::npos);
+ test(S(""), "abcdeabcdeabcdeabcde", 1, S::npos);
+ test(S("abcde"), "", 0, 0);
+ test(S("abcde"), "abcde", 0, 0);
+ test(S("abcde"), "abcdeabcde", 0, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 0, S::npos);
+ test(S("abcde"), "", 1, 1);
+ test(S("abcde"), "abcde", 1, 0);
+ test(S("abcde"), "abcdeabcde", 1, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 1, S::npos);
+ test(S("abcde"), "", 2, 2);
+ test(S("abcde"), "abcde", 2, 0);
+ test(S("abcde"), "abcdeabcde", 2, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 2, S::npos);
+ test(S("abcde"), "", 4, 4);
+ test(S("abcde"), "abcde", 4, 0);
+ test(S("abcde"), "abcdeabcde", 4, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 4, S::npos);
+ test(S("abcde"), "", 5, 5);
+ test(S("abcde"), "abcde", 5, 0);
+ test(S("abcde"), "abcdeabcde", 5, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 5, S::npos);
+ test(S("abcde"), "", 6, 5);
+ test(S("abcde"), "abcde", 6, 0);
+ test(S("abcde"), "abcdeabcde", 6, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 6, S::npos);
+ test(S("abcdeabcde"), "", 0, 0);
+ test(S("abcdeabcde"), "abcde", 0, 0);
+ test(S("abcdeabcde"), "abcdeabcde", 0, 0);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 0, S::npos);
+ test(S("abcdeabcde"), "", 1, 1);
+ test(S("abcdeabcde"), "abcde", 1, 0);
+ test(S("abcdeabcde"), "abcdeabcde", 1, 0);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 1, S::npos);
+ test(S("abcdeabcde"), "", 5, 5);
+ test(S("abcdeabcde"), "abcde", 5, 5);
+ test(S("abcdeabcde"), "abcdeabcde", 5, 0);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 5, S::npos);
+ test(S("abcdeabcde"), "", 9, 9);
+ test(S("abcdeabcde"), "abcde", 9, 5);
+ test(S("abcdeabcde"), "abcdeabcde", 9, 0);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 9, S::npos);
+ test(S("abcdeabcde"), "", 10, 10);
+ test(S("abcdeabcde"), "abcde", 10, 5);
+ test(S("abcdeabcde"), "abcdeabcde", 10, 0);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 10, S::npos);
+ test(S("abcdeabcde"), "", 11, 10);
+ test(S("abcdeabcde"), "abcde", 11, 5);
+ test(S("abcdeabcde"), "abcdeabcde", 11, 0);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 11, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "", 0, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 0, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 0, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0, 0);
+ test(S("abcdeabcdeabcdeabcde"), "", 1, 1);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 1, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 1, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 1, 0);
+ test(S("abcdeabcdeabcdeabcde"), "", 10, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 10, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 10, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 10, 0);
+ test(S("abcdeabcdeabcdeabcde"), "", 19, 19);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 19, 15);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 19, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 19, 0);
+ test(S("abcdeabcdeabcdeabcde"), "", 20, 20);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 20, 15);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 20, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 20, 0);
+ test(S("abcdeabcdeabcdeabcde"), "", 21, 20);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 21, 15);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 21, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 21, 0);
+}
+
+template <class S>
+void test1()
+{
+ test(S(""), "", 0);
+ test(S(""), "abcde", S::npos);
+ test(S(""), "abcdeabcde", S::npos);
+ test(S(""), "abcdeabcdeabcdeabcde", S::npos);
+ test(S("abcde"), "", 5);
+ test(S("abcde"), "abcde", 0);
+ test(S("abcde"), "abcdeabcde", S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", S::npos);
+ test(S("abcdeabcde"), "", 10);
+ test(S("abcdeabcde"), "abcde", 5);
+ test(S("abcdeabcde"), "abcdeabcde", 0);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "", 20);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 15);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0);
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test0<S>();
+ test1<S>();
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test0<S>();
+ test1<S>();
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.ops/string_rfind/pointer_size_size.pass.cpp b/test/std/strings/basic.string/string.ops/string_rfind/pointer_size_size.pass.cpp
new file mode 100644
index 000000000000..47baf40b265b
--- /dev/null
+++ b/test/std/strings/basic.string/string.ops/string_rfind/pointer_size_size.pass.cpp
@@ -0,0 +1,387 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type rfind(const charT* s, size_type pos, size_type n) const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type pos,
+ typename S::size_type n, typename S::size_type x)
+{
+ assert(s.rfind(str, pos, n) == x);
+ if (x != S::npos)
+ assert(x <= pos && x + n <= s.size());
+}
+
+template <class S>
+void test0()
+{
+ test(S(""), "", 0, 0, 0);
+ test(S(""), "abcde", 0, 0, 0);
+ test(S(""), "abcde", 0, 1, S::npos);
+ test(S(""), "abcde", 0, 2, S::npos);
+ test(S(""), "abcde", 0, 4, S::npos);
+ test(S(""), "abcde", 0, 5, S::npos);
+ test(S(""), "abcdeabcde", 0, 0, 0);
+ test(S(""), "abcdeabcde", 0, 1, S::npos);
+ test(S(""), "abcdeabcde", 0, 5, S::npos);
+ test(S(""), "abcdeabcde", 0, 9, S::npos);
+ test(S(""), "abcdeabcde", 0, 10, S::npos);
+ test(S(""), "abcdeabcdeabcdeabcde", 0, 0, 0);
+ test(S(""), "abcdeabcdeabcdeabcde", 0, 1, S::npos);
+ test(S(""), "abcdeabcdeabcdeabcde", 0, 10, S::npos);
+ test(S(""), "abcdeabcdeabcdeabcde", 0, 19, S::npos);
+ test(S(""), "abcdeabcdeabcdeabcde", 0, 20, S::npos);
+ test(S(""), "", 1, 0, 0);
+ test(S(""), "abcde", 1, 0, 0);
+ test(S(""), "abcde", 1, 1, S::npos);
+ test(S(""), "abcde", 1, 2, S::npos);
+ test(S(""), "abcde", 1, 4, S::npos);
+ test(S(""), "abcde", 1, 5, S::npos);
+ test(S(""), "abcdeabcde", 1, 0, 0);
+ test(S(""), "abcdeabcde", 1, 1, S::npos);
+ test(S(""), "abcdeabcde", 1, 5, S::npos);
+ test(S(""), "abcdeabcde", 1, 9, S::npos);
+ test(S(""), "abcdeabcde", 1, 10, S::npos);
+ test(S(""), "abcdeabcdeabcdeabcde", 1, 0, 0);
+ test(S(""), "abcdeabcdeabcdeabcde", 1, 1, S::npos);
+ test(S(""), "abcdeabcdeabcdeabcde", 1, 10, S::npos);
+ test(S(""), "abcdeabcdeabcdeabcde", 1, 19, S::npos);
+ test(S(""), "abcdeabcdeabcdeabcde", 1, 20, S::npos);
+ test(S("abcde"), "", 0, 0, 0);
+ test(S("abcde"), "abcde", 0, 0, 0);
+ test(S("abcde"), "abcde", 0, 1, 0);
+ test(S("abcde"), "abcde", 0, 2, 0);
+ test(S("abcde"), "abcde", 0, 4, 0);
+ test(S("abcde"), "abcde", 0, 5, 0);
+ test(S("abcde"), "abcdeabcde", 0, 0, 0);
+ test(S("abcde"), "abcdeabcde", 0, 1, 0);
+ test(S("abcde"), "abcdeabcde", 0, 5, 0);
+ test(S("abcde"), "abcdeabcde", 0, 9, S::npos);
+ test(S("abcde"), "abcdeabcde", 0, 10, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 0, 0, 0);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 0, 1, 0);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 0, 10, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 0, 19, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 0, 20, S::npos);
+ test(S("abcde"), "", 1, 0, 1);
+ test(S("abcde"), "abcde", 1, 0, 1);
+ test(S("abcde"), "abcde", 1, 1, 0);
+ test(S("abcde"), "abcde", 1, 2, 0);
+ test(S("abcde"), "abcde", 1, 4, 0);
+ test(S("abcde"), "abcde", 1, 5, 0);
+ test(S("abcde"), "abcdeabcde", 1, 0, 1);
+ test(S("abcde"), "abcdeabcde", 1, 1, 0);
+ test(S("abcde"), "abcdeabcde", 1, 5, 0);
+ test(S("abcde"), "abcdeabcde", 1, 9, S::npos);
+ test(S("abcde"), "abcdeabcde", 1, 10, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 1, 0, 1);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 1, 1, 0);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 1, 10, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 1, 19, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 1, 20, S::npos);
+ test(S("abcde"), "", 2, 0, 2);
+ test(S("abcde"), "abcde", 2, 0, 2);
+ test(S("abcde"), "abcde", 2, 1, 0);
+ test(S("abcde"), "abcde", 2, 2, 0);
+ test(S("abcde"), "abcde", 2, 4, 0);
+ test(S("abcde"), "abcde", 2, 5, 0);
+ test(S("abcde"), "abcdeabcde", 2, 0, 2);
+ test(S("abcde"), "abcdeabcde", 2, 1, 0);
+ test(S("abcde"), "abcdeabcde", 2, 5, 0);
+ test(S("abcde"), "abcdeabcde", 2, 9, S::npos);
+ test(S("abcde"), "abcdeabcde", 2, 10, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 2, 0, 2);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 2, 1, 0);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 2, 10, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 2, 19, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 2, 20, S::npos);
+ test(S("abcde"), "", 4, 0, 4);
+ test(S("abcde"), "abcde", 4, 0, 4);
+ test(S("abcde"), "abcde", 4, 1, 0);
+ test(S("abcde"), "abcde", 4, 2, 0);
+ test(S("abcde"), "abcde", 4, 4, 0);
+ test(S("abcde"), "abcde", 4, 5, 0);
+ test(S("abcde"), "abcdeabcde", 4, 0, 4);
+ test(S("abcde"), "abcdeabcde", 4, 1, 0);
+ test(S("abcde"), "abcdeabcde", 4, 5, 0);
+ test(S("abcde"), "abcdeabcde", 4, 9, S::npos);
+ test(S("abcde"), "abcdeabcde", 4, 10, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 4, 0, 4);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 4, 1, 0);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 4, 10, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 4, 19, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 4, 20, S::npos);
+ test(S("abcde"), "", 5, 0, 5);
+ test(S("abcde"), "abcde", 5, 0, 5);
+ test(S("abcde"), "abcde", 5, 1, 0);
+ test(S("abcde"), "abcde", 5, 2, 0);
+}
+
+template <class S>
+void test1()
+{
+ test(S("abcde"), "abcde", 5, 4, 0);
+ test(S("abcde"), "abcde", 5, 5, 0);
+ test(S("abcde"), "abcdeabcde", 5, 0, 5);
+ test(S("abcde"), "abcdeabcde", 5, 1, 0);
+ test(S("abcde"), "abcdeabcde", 5, 5, 0);
+ test(S("abcde"), "abcdeabcde", 5, 9, S::npos);
+ test(S("abcde"), "abcdeabcde", 5, 10, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 5, 0, 5);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 5, 1, 0);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 5, 10, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 5, 19, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 5, 20, S::npos);
+ test(S("abcde"), "", 6, 0, 5);
+ test(S("abcde"), "abcde", 6, 0, 5);
+ test(S("abcde"), "abcde", 6, 1, 0);
+ test(S("abcde"), "abcde", 6, 2, 0);
+ test(S("abcde"), "abcde", 6, 4, 0);
+ test(S("abcde"), "abcde", 6, 5, 0);
+ test(S("abcde"), "abcdeabcde", 6, 0, 5);
+ test(S("abcde"), "abcdeabcde", 6, 1, 0);
+ test(S("abcde"), "abcdeabcde", 6, 5, 0);
+ test(S("abcde"), "abcdeabcde", 6, 9, S::npos);
+ test(S("abcde"), "abcdeabcde", 6, 10, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 6, 0, 5);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 6, 1, 0);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 6, 10, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 6, 19, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 6, 20, S::npos);
+ test(S("abcdeabcde"), "", 0, 0, 0);
+ test(S("abcdeabcde"), "abcde", 0, 0, 0);
+ test(S("abcdeabcde"), "abcde", 0, 1, 0);
+ test(S("abcdeabcde"), "abcde", 0, 2, 0);
+ test(S("abcdeabcde"), "abcde", 0, 4, 0);
+ test(S("abcdeabcde"), "abcde", 0, 5, 0);
+ test(S("abcdeabcde"), "abcdeabcde", 0, 0, 0);
+ test(S("abcdeabcde"), "abcdeabcde", 0, 1, 0);
+ test(S("abcdeabcde"), "abcdeabcde", 0, 5, 0);
+ test(S("abcdeabcde"), "abcdeabcde", 0, 9, 0);
+ test(S("abcdeabcde"), "abcdeabcde", 0, 10, 0);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 0, 0, 0);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 0, 1, 0);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 0, 10, 0);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 0, 19, S::npos);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 0, 20, S::npos);
+ test(S("abcdeabcde"), "", 1, 0, 1);
+ test(S("abcdeabcde"), "abcde", 1, 0, 1);
+ test(S("abcdeabcde"), "abcde", 1, 1, 0);
+ test(S("abcdeabcde"), "abcde", 1, 2, 0);
+ test(S("abcdeabcde"), "abcde", 1, 4, 0);
+ test(S("abcdeabcde"), "abcde", 1, 5, 0);
+ test(S("abcdeabcde"), "abcdeabcde", 1, 0, 1);
+ test(S("abcdeabcde"), "abcdeabcde", 1, 1, 0);
+ test(S("abcdeabcde"), "abcdeabcde", 1, 5, 0);
+ test(S("abcdeabcde"), "abcdeabcde", 1, 9, 0);
+ test(S("abcdeabcde"), "abcdeabcde", 1, 10, 0);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 1, 0, 1);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 1, 1, 0);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 1, 10, 0);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 1, 19, S::npos);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 1, 20, S::npos);
+ test(S("abcdeabcde"), "", 5, 0, 5);
+ test(S("abcdeabcde"), "abcde", 5, 0, 5);
+ test(S("abcdeabcde"), "abcde", 5, 1, 5);
+ test(S("abcdeabcde"), "abcde", 5, 2, 5);
+ test(S("abcdeabcde"), "abcde", 5, 4, 5);
+ test(S("abcdeabcde"), "abcde", 5, 5, 5);
+ test(S("abcdeabcde"), "abcdeabcde", 5, 0, 5);
+ test(S("abcdeabcde"), "abcdeabcde", 5, 1, 5);
+ test(S("abcdeabcde"), "abcdeabcde", 5, 5, 5);
+ test(S("abcdeabcde"), "abcdeabcde", 5, 9, 0);
+ test(S("abcdeabcde"), "abcdeabcde", 5, 10, 0);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 5, 0, 5);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 5, 1, 5);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 5, 10, 0);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 5, 19, S::npos);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 5, 20, S::npos);
+ test(S("abcdeabcde"), "", 9, 0, 9);
+ test(S("abcdeabcde"), "abcde", 9, 0, 9);
+ test(S("abcdeabcde"), "abcde", 9, 1, 5);
+ test(S("abcdeabcde"), "abcde", 9, 2, 5);
+ test(S("abcdeabcde"), "abcde", 9, 4, 5);
+ test(S("abcdeabcde"), "abcde", 9, 5, 5);
+ test(S("abcdeabcde"), "abcdeabcde", 9, 0, 9);
+ test(S("abcdeabcde"), "abcdeabcde", 9, 1, 5);
+ test(S("abcdeabcde"), "abcdeabcde", 9, 5, 5);
+ test(S("abcdeabcde"), "abcdeabcde", 9, 9, 0);
+ test(S("abcdeabcde"), "abcdeabcde", 9, 10, 0);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 9, 0, 9);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 9, 1, 5);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 9, 10, 0);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 9, 19, S::npos);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 9, 20, S::npos);
+ test(S("abcdeabcde"), "", 10, 0, 10);
+ test(S("abcdeabcde"), "abcde", 10, 0, 10);
+ test(S("abcdeabcde"), "abcde", 10, 1, 5);
+ test(S("abcdeabcde"), "abcde", 10, 2, 5);
+ test(S("abcdeabcde"), "abcde", 10, 4, 5);
+ test(S("abcdeabcde"), "abcde", 10, 5, 5);
+ test(S("abcdeabcde"), "abcdeabcde", 10, 0, 10);
+ test(S("abcdeabcde"), "abcdeabcde", 10, 1, 5);
+}
+
+template <class S>
+void test2()
+{
+ test(S("abcdeabcde"), "abcdeabcde", 10, 5, 5);
+ test(S("abcdeabcde"), "abcdeabcde", 10, 9, 0);
+ test(S("abcdeabcde"), "abcdeabcde", 10, 10, 0);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 10, 0, 10);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 10, 1, 5);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 10, 10, 0);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 10, 19, S::npos);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 10, 20, S::npos);
+ test(S("abcdeabcde"), "", 11, 0, 10);
+ test(S("abcdeabcde"), "abcde", 11, 0, 10);
+ test(S("abcdeabcde"), "abcde", 11, 1, 5);
+ test(S("abcdeabcde"), "abcde", 11, 2, 5);
+ test(S("abcdeabcde"), "abcde", 11, 4, 5);
+ test(S("abcdeabcde"), "abcde", 11, 5, 5);
+ test(S("abcdeabcde"), "abcdeabcde", 11, 0, 10);
+ test(S("abcdeabcde"), "abcdeabcde", 11, 1, 5);
+ test(S("abcdeabcde"), "abcdeabcde", 11, 5, 5);
+ test(S("abcdeabcde"), "abcdeabcde", 11, 9, 0);
+ test(S("abcdeabcde"), "abcdeabcde", 11, 10, 0);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 11, 0, 10);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 11, 1, 5);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 11, 10, 0);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 11, 19, S::npos);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 11, 20, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "", 0, 0, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 0, 0, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 0, 1, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 0, 2, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 0, 4, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 0, 5, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 0, 0, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 0, 1, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 0, 5, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 0, 9, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 0, 10, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0, 0, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0, 1, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0, 10, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0, 19, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0, 20, 0);
+ test(S("abcdeabcdeabcdeabcde"), "", 1, 0, 1);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 1, 0, 1);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 1, 1, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 1, 2, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 1, 4, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 1, 5, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 1, 0, 1);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 1, 1, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 1, 5, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 1, 9, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 1, 10, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 1, 0, 1);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 1, 1, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 1, 10, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 1, 19, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 1, 20, 0);
+ test(S("abcdeabcdeabcdeabcde"), "", 10, 0, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 10, 0, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 10, 1, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 10, 2, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 10, 4, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 10, 5, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 10, 0, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 10, 1, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 10, 5, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 10, 9, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 10, 10, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 10, 0, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 10, 1, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 10, 10, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 10, 19, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 10, 20, 0);
+ test(S("abcdeabcdeabcdeabcde"), "", 19, 0, 19);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 19, 0, 19);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 19, 1, 15);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 19, 2, 15);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 19, 4, 15);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 19, 5, 15);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 19, 0, 19);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 19, 1, 15);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 19, 5, 15);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 19, 9, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 19, 10, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 19, 0, 19);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 19, 1, 15);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 19, 10, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 19, 19, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 19, 20, 0);
+ test(S("abcdeabcdeabcdeabcde"), "", 20, 0, 20);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 20, 0, 20);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 20, 1, 15);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 20, 2, 15);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 20, 4, 15);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 20, 5, 15);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 20, 0, 20);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 20, 1, 15);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 20, 5, 15);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 20, 9, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 20, 10, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 20, 0, 20);
+}
+
+template <class S>
+void test3()
+{
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 20, 1, 15);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 20, 10, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 20, 19, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 20, 20, 0);
+ test(S("abcdeabcdeabcdeabcde"), "", 21, 0, 20);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 21, 0, 20);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 21, 1, 15);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 21, 2, 15);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 21, 4, 15);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 21, 5, 15);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 21, 0, 20);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 21, 1, 15);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 21, 5, 15);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 21, 9, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 21, 10, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 21, 0, 20);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 21, 1, 15);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 21, 10, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 21, 19, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 21, 20, 0);
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test0<S>();
+ test1<S>();
+ test2<S>();
+ test3<S>();
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test0<S>();
+ test1<S>();
+ test2<S>();
+ test3<S>();
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.ops/string_rfind/string_size.pass.cpp b/test/std/strings/basic.string/string.ops/string_rfind/string_size.pass.cpp
new file mode 100644
index 000000000000..05e6e5174232
--- /dev/null
+++ b/test/std/strings/basic.string/string.ops/string_rfind/string_size.pass.cpp
@@ -0,0 +1,157 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type rfind(const basic_string& str, size_type pos = npos) const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& s, const S& str, typename S::size_type pos, typename S::size_type x)
+{
+ assert(s.rfind(str, pos) == x);
+ if (x != S::npos)
+ assert(x <= pos && x + str.size() <= s.size());
+}
+
+template <class S>
+void
+test(const S& s, const S& str, typename S::size_type x)
+{
+ assert(s.rfind(str) == x);
+ if (x != S::npos)
+ assert(0 <= x && x + str.size() <= s.size());
+}
+
+template <class S>
+void test0()
+{
+ test(S(""), S(""), 0, 0);
+ test(S(""), S("abcde"), 0, S::npos);
+ test(S(""), S("abcdeabcde"), 0, S::npos);
+ test(S(""), S("abcdeabcdeabcdeabcde"), 0, S::npos);
+ test(S(""), S(""), 1, 0);
+ test(S(""), S("abcde"), 1, S::npos);
+ test(S(""), S("abcdeabcde"), 1, S::npos);
+ test(S(""), S("abcdeabcdeabcdeabcde"), 1, S::npos);
+ test(S("abcde"), S(""), 0, 0);
+ test(S("abcde"), S("abcde"), 0, 0);
+ test(S("abcde"), S("abcdeabcde"), 0, S::npos);
+ test(S("abcde"), S("abcdeabcdeabcdeabcde"), 0, S::npos);
+ test(S("abcde"), S(""), 1, 1);
+ test(S("abcde"), S("abcde"), 1, 0);
+ test(S("abcde"), S("abcdeabcde"), 1, S::npos);
+ test(S("abcde"), S("abcdeabcdeabcdeabcde"), 1, S::npos);
+ test(S("abcde"), S(""), 2, 2);
+ test(S("abcde"), S("abcde"), 2, 0);
+ test(S("abcde"), S("abcdeabcde"), 2, S::npos);
+ test(S("abcde"), S("abcdeabcdeabcdeabcde"), 2, S::npos);
+ test(S("abcde"), S(""), 4, 4);
+ test(S("abcde"), S("abcde"), 4, 0);
+ test(S("abcde"), S("abcdeabcde"), 4, S::npos);
+ test(S("abcde"), S("abcdeabcdeabcdeabcde"), 4, S::npos);
+ test(S("abcde"), S(""), 5, 5);
+ test(S("abcde"), S("abcde"), 5, 0);
+ test(S("abcde"), S("abcdeabcde"), 5, S::npos);
+ test(S("abcde"), S("abcdeabcdeabcdeabcde"), 5, S::npos);
+ test(S("abcde"), S(""), 6, 5);
+ test(S("abcde"), S("abcde"), 6, 0);
+ test(S("abcde"), S("abcdeabcde"), 6, S::npos);
+ test(S("abcde"), S("abcdeabcdeabcdeabcde"), 6, S::npos);
+ test(S("abcdeabcde"), S(""), 0, 0);
+ test(S("abcdeabcde"), S("abcde"), 0, 0);
+ test(S("abcdeabcde"), S("abcdeabcde"), 0, 0);
+ test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), 0, S::npos);
+ test(S("abcdeabcde"), S(""), 1, 1);
+ test(S("abcdeabcde"), S("abcde"), 1, 0);
+ test(S("abcdeabcde"), S("abcdeabcde"), 1, 0);
+ test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), 1, S::npos);
+ test(S("abcdeabcde"), S(""), 5, 5);
+ test(S("abcdeabcde"), S("abcde"), 5, 5);
+ test(S("abcdeabcde"), S("abcdeabcde"), 5, 0);
+ test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), 5, S::npos);
+ test(S("abcdeabcde"), S(""), 9, 9);
+ test(S("abcdeabcde"), S("abcde"), 9, 5);
+ test(S("abcdeabcde"), S("abcdeabcde"), 9, 0);
+ test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), 9, S::npos);
+ test(S("abcdeabcde"), S(""), 10, 10);
+ test(S("abcdeabcde"), S("abcde"), 10, 5);
+ test(S("abcdeabcde"), S("abcdeabcde"), 10, 0);
+ test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), 10, S::npos);
+ test(S("abcdeabcde"), S(""), 11, 10);
+ test(S("abcdeabcde"), S("abcde"), 11, 5);
+ test(S("abcdeabcde"), S("abcdeabcde"), 11, 0);
+ test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), 11, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), S(""), 0, 0);
+ test(S("abcdeabcdeabcdeabcde"), S("abcde"), 0, 0);
+ test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 0, 0);
+ test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 0, 0);
+ test(S("abcdeabcdeabcdeabcde"), S(""), 1, 1);
+ test(S("abcdeabcdeabcdeabcde"), S("abcde"), 1, 0);
+ test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 1, 0);
+ test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 1, 0);
+ test(S("abcdeabcdeabcdeabcde"), S(""), 10, 10);
+ test(S("abcdeabcdeabcdeabcde"), S("abcde"), 10, 10);
+ test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 10, 10);
+ test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 10, 0);
+ test(S("abcdeabcdeabcdeabcde"), S(""), 19, 19);
+ test(S("abcdeabcdeabcdeabcde"), S("abcde"), 19, 15);
+ test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 19, 10);
+ test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 19, 0);
+ test(S("abcdeabcdeabcdeabcde"), S(""), 20, 20);
+ test(S("abcdeabcdeabcdeabcde"), S("abcde"), 20, 15);
+ test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 20, 10);
+ test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 20, 0);
+ test(S("abcdeabcdeabcdeabcde"), S(""), 21, 20);
+ test(S("abcdeabcdeabcdeabcde"), S("abcde"), 21, 15);
+ test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 21, 10);
+ test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 21, 0);
+}
+
+template <class S>
+void test1()
+{
+ test(S(""), S(""), 0);
+ test(S(""), S("abcde"), S::npos);
+ test(S(""), S("abcdeabcde"), S::npos);
+ test(S(""), S("abcdeabcdeabcdeabcde"), S::npos);
+ test(S("abcde"), S(""), 5);
+ test(S("abcde"), S("abcde"), 0);
+ test(S("abcde"), S("abcdeabcde"), S::npos);
+ test(S("abcde"), S("abcdeabcdeabcdeabcde"), S::npos);
+ test(S("abcdeabcde"), S(""), 10);
+ test(S("abcdeabcde"), S("abcde"), 5);
+ test(S("abcdeabcde"), S("abcdeabcde"), 0);
+ test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), S::npos);
+ test(S("abcdeabcdeabcdeabcde"), S(""), 20);
+ test(S("abcdeabcdeabcdeabcde"), S("abcde"), 15);
+ test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 10);
+ test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 0);
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test0<S>();
+ test1<S>();
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test0<S>();
+ test1<S>();
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.ops/string_substr/substr.pass.cpp b/test/std/strings/basic.string/string.ops/string_substr/substr.pass.cpp
new file mode 100644
index 000000000000..a73f70cd4b89
--- /dev/null
+++ b/test/std/strings/basic.string/string.ops/string_substr/substr.pass.cpp
@@ -0,0 +1,166 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string substr(size_type pos = 0, size_type n = npos) const;
+
+#include <string>
+#include <stdexcept>
+#include <algorithm>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& s, typename S::size_type pos, typename S::size_type n)
+{
+ try
+ {
+ S str = s.substr(pos, n);
+ assert(str.__invariants());
+ assert(pos <= s.size());
+ typename S::size_type rlen = std::min(n, s.size() - pos);
+ assert(str.size() == rlen);
+ assert(S::traits_type::compare(s.data()+pos, str.data(), rlen) == 0);
+ }
+ catch (std::out_of_range&)
+ {
+ assert(pos > s.size());
+ }
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test(S(""), 0, 0);
+ test(S(""), 1, 0);
+ test(S("pniot"), 0, 0);
+ test(S("htaob"), 0, 1);
+ test(S("fodgq"), 0, 2);
+ test(S("hpqia"), 0, 4);
+ test(S("qanej"), 0, 5);
+ test(S("dfkap"), 1, 0);
+ test(S("clbao"), 1, 1);
+ test(S("ihqrf"), 1, 2);
+ test(S("mekdn"), 1, 3);
+ test(S("ngtjf"), 1, 4);
+ test(S("srdfq"), 2, 0);
+ test(S("qkdrs"), 2, 1);
+ test(S("ikcrq"), 2, 2);
+ test(S("cdaih"), 2, 3);
+ test(S("dmajb"), 4, 0);
+ test(S("karth"), 4, 1);
+ test(S("lhcdo"), 5, 0);
+ test(S("acbsj"), 6, 0);
+ test(S("pbsjikaole"), 0, 0);
+ test(S("pcbahntsje"), 0, 1);
+ test(S("mprdjbeiak"), 0, 5);
+ test(S("fhepcrntko"), 0, 9);
+ test(S("eqmpaidtls"), 0, 10);
+ test(S("joidhalcmq"), 1, 0);
+ test(S("omigsphflj"), 1, 1);
+ test(S("kocgbphfji"), 1, 4);
+ test(S("onmjekafbi"), 1, 8);
+ test(S("fbslrjiqkm"), 1, 9);
+ test(S("oqmrjahnkg"), 5, 0);
+ test(S("jeidpcmalh"), 5, 1);
+ test(S("schfalibje"), 5, 2);
+ test(S("crliponbqe"), 5, 4);
+ test(S("igdscopqtm"), 5, 5);
+ test(S("qngpdkimlc"), 9, 0);
+ test(S("thdjgafrlb"), 9, 1);
+ test(S("hcjitbfapl"), 10, 0);
+ test(S("mgojkldsqh"), 11, 0);
+ test(S("gfshlcmdjreqipbontak"), 0, 0);
+ test(S("nadkhpfemgclosibtjrq"), 0, 1);
+ test(S("nkodajteqplrbifhmcgs"), 0, 10);
+ test(S("ofdrqmkeblthacpgijsn"), 0, 19);
+ test(S("gbmetiprqdoasckjfhln"), 0, 20);
+ test(S("bdfjqgatlksriohemnpc"), 1, 0);
+ test(S("crnklpmegdqfiashtojb"), 1, 1);
+ test(S("ejqcnahdrkfsmptilgbo"), 1, 9);
+ test(S("jsbtafedocnirgpmkhql"), 1, 18);
+ test(S("prqgnlbaejsmkhdctoif"), 1, 19);
+ test(S("qnmodrtkebhpasifgcjl"), 10, 0);
+ test(S("pejafmnokrqhtisbcdgl"), 10, 1);
+ test(S("cpebqsfmnjdolhkratgi"), 10, 5);
+ test(S("odnqkgijrhabfmcestlp"), 10, 9);
+ test(S("lmofqdhpkibagnrcjste"), 10, 10);
+ test(S("lgjqketopbfahrmnsicd"), 19, 0);
+ test(S("ktsrmnqagdecfhijpobl"), 19, 1);
+ test(S("lsaijeqhtrbgcdmpfkno"), 20, 0);
+ test(S("dplqartnfgejichmoskb"), 21, 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ test(S(""), 0, 0);
+ test(S(""), 1, 0);
+ test(S("pniot"), 0, 0);
+ test(S("htaob"), 0, 1);
+ test(S("fodgq"), 0, 2);
+ test(S("hpqia"), 0, 4);
+ test(S("qanej"), 0, 5);
+ test(S("dfkap"), 1, 0);
+ test(S("clbao"), 1, 1);
+ test(S("ihqrf"), 1, 2);
+ test(S("mekdn"), 1, 3);
+ test(S("ngtjf"), 1, 4);
+ test(S("srdfq"), 2, 0);
+ test(S("qkdrs"), 2, 1);
+ test(S("ikcrq"), 2, 2);
+ test(S("cdaih"), 2, 3);
+ test(S("dmajb"), 4, 0);
+ test(S("karth"), 4, 1);
+ test(S("lhcdo"), 5, 0);
+ test(S("acbsj"), 6, 0);
+ test(S("pbsjikaole"), 0, 0);
+ test(S("pcbahntsje"), 0, 1);
+ test(S("mprdjbeiak"), 0, 5);
+ test(S("fhepcrntko"), 0, 9);
+ test(S("eqmpaidtls"), 0, 10);
+ test(S("joidhalcmq"), 1, 0);
+ test(S("omigsphflj"), 1, 1);
+ test(S("kocgbphfji"), 1, 4);
+ test(S("onmjekafbi"), 1, 8);
+ test(S("fbslrjiqkm"), 1, 9);
+ test(S("oqmrjahnkg"), 5, 0);
+ test(S("jeidpcmalh"), 5, 1);
+ test(S("schfalibje"), 5, 2);
+ test(S("crliponbqe"), 5, 4);
+ test(S("igdscopqtm"), 5, 5);
+ test(S("qngpdkimlc"), 9, 0);
+ test(S("thdjgafrlb"), 9, 1);
+ test(S("hcjitbfapl"), 10, 0);
+ test(S("mgojkldsqh"), 11, 0);
+ test(S("gfshlcmdjreqipbontak"), 0, 0);
+ test(S("nadkhpfemgclosibtjrq"), 0, 1);
+ test(S("nkodajteqplrbifhmcgs"), 0, 10);
+ test(S("ofdrqmkeblthacpgijsn"), 0, 19);
+ test(S("gbmetiprqdoasckjfhln"), 0, 20);
+ test(S("bdfjqgatlksriohemnpc"), 1, 0);
+ test(S("crnklpmegdqfiashtojb"), 1, 1);
+ test(S("ejqcnahdrkfsmptilgbo"), 1, 9);
+ test(S("jsbtafedocnirgpmkhql"), 1, 18);
+ test(S("prqgnlbaejsmkhdctoif"), 1, 19);
+ test(S("qnmodrtkebhpasifgcjl"), 10, 0);
+ test(S("pejafmnokrqhtisbcdgl"), 10, 1);
+ test(S("cpebqsfmnjdolhkratgi"), 10, 5);
+ test(S("odnqkgijrhabfmcestlp"), 10, 9);
+ test(S("lmofqdhpkibagnrcjste"), 10, 10);
+ test(S("lgjqketopbfahrmnsicd"), 19, 0);
+ test(S("ktsrmnqagdecfhijpobl"), 19, 1);
+ test(S("lsaijeqhtrbgcdmpfkno"), 20, 0);
+ test(S("dplqartnfgejichmoskb"), 21, 0);
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/string.require/contiguous.pass.cpp b/test/std/strings/basic.string/string.require/contiguous.pass.cpp
new file mode 100644
index 000000000000..ca31ace0ef0b
--- /dev/null
+++ b/test/std/strings/basic.string/string.require/contiguous.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// An string is a contiguous container
+
+#include <string>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+
+template <class C>
+void test_contiguous ( const C &c )
+{
+ for ( size_t i = 0; i < c.size(); ++i )
+ assert ( *(c.begin() + i) == *(std::addressof(*c.begin()) + i));
+}
+
+int main()
+{
+ {
+ typedef std::string S;
+ test_contiguous(S());
+ test_contiguous(S("1"));
+ test_contiguous(S("1234567890123456789012345678901234567890123456789012345678901234567890"));
+ }
+
+ {
+ typedef test_allocator<char> A;
+ typedef std::basic_string<char, std::char_traits<char>, A> S;
+ test_contiguous(S(A(3)));
+ test_contiguous(S("1", A(5)));
+ test_contiguous(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef min_allocator<char> A;
+ typedef std::basic_string<char, std::char_traits<char>, A> S;
+ test_contiguous(S(A{}));
+ test_contiguous(S("1", A()));
+ test_contiguous(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()));
+ }
+#endif
+}
diff --git a/test/std/strings/basic.string/test_traits.h b/test/std/strings/basic.string/test_traits.h
new file mode 100644
index 000000000000..f635b1d75162
--- /dev/null
+++ b/test/std/strings/basic.string/test_traits.h
@@ -0,0 +1,19 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef TEST_TRAITS_H
+#define TEST_TRAITS_H
+
+template <class charT>
+struct test_traits
+{
+ typedef charT char_type;
+};
+
+#endif // TEST_TRAITS_H
diff --git a/test/std/strings/basic.string/types.pass.cpp b/test/std/strings/basic.string/types.pass.cpp
new file mode 100644
index 000000000000..dcb3bbc35ebf
--- /dev/null
+++ b/test/std/strings/basic.string/types.pass.cpp
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// Test nested types and default template args:
+
+// template<class charT, class traits = char_traits<charT>,
+// class Allocator = allocator<charT> >
+// {
+// public:
+// // types:
+// typedef traits traits_type;
+// typedef typename traits::char_type value_type;
+// typedef Allocator allocator_type;
+// typedef typename Allocator::size_type size_type;
+// typedef typename Allocator::difference_type difference_type;
+// typedef typename Allocator::reference reference;
+// typedef typename Allocator::const_reference const_reference;
+// typedef typename Allocator::pointer pointer;
+// typedef typename Allocator::const_pointer const_pointer;
+// typedef implementation-defined iterator; // See 23.1
+// typedef implementation-defined const_iterator; // See 23.1
+// typedef std::reverse_iterator<iterator> reverse_iterator;
+// typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
+// static const size_type npos = -1;
+// };
+
+#include <string>
+#include <iterator>
+#include <type_traits>
+
+#include "test_traits.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+template <class Traits, class Allocator>
+void
+test()
+{
+ typedef std::basic_string<typename Traits::char_type, Traits, Allocator> S;
+
+ static_assert((std::is_same<typename S::traits_type, Traits>::value), "");
+ static_assert((std::is_same<typename S::value_type, typename Traits::char_type>::value), "");
+ static_assert((std::is_same<typename S::value_type, typename Allocator::value_type>::value), "");
+ static_assert((std::is_same<typename S::allocator_type, Allocator>::value), "");
+ static_assert((std::is_same<typename S::size_type, typename std::allocator_traits<Allocator>::size_type>::value), "");
+ static_assert((std::is_same<typename S::difference_type, typename std::allocator_traits<Allocator>::difference_type>::value), "");
+ static_assert((std::is_same<typename S::reference, typename S::value_type&>::value), "");
+ static_assert((std::is_same<typename S::const_reference, const typename S::value_type&>::value), "");
+ static_assert((std::is_same<typename S::pointer, typename std::allocator_traits<Allocator>::pointer>::value), "");
+ static_assert((std::is_same<typename S::const_pointer, typename std::allocator_traits<Allocator>::const_pointer>::value), "");
+ static_assert((std::is_same<
+ typename std::iterator_traits<typename S::iterator>::iterator_category,
+ std::random_access_iterator_tag>::value), "");
+ static_assert((std::is_same<
+ typename std::iterator_traits<typename S::const_iterator>::iterator_category,
+ std::random_access_iterator_tag>::value), "");
+ static_assert((std::is_same<
+ typename S::reverse_iterator,
+ std::reverse_iterator<typename S::iterator> >::value), "");
+ static_assert((std::is_same<
+ typename S::const_reverse_iterator,
+ std::reverse_iterator<typename S::const_iterator> >::value), "");
+ static_assert(S::npos == -1, "");
+}
+
+int main()
+{
+ test<test_traits<char>, test_allocator<char> >();
+ test<std::char_traits<wchar_t>, std::allocator<wchar_t> >();
+ static_assert((std::is_same<std::basic_string<char>::traits_type,
+ std::char_traits<char> >::value), "");
+ static_assert((std::is_same<std::basic_string<char>::allocator_type,
+ std::allocator<char> >::value), "");
+#if __cplusplus >= 201103L
+ test<std::char_traits<char>, min_allocator<char> >();
+#endif
+}
diff --git a/test/std/strings/c.strings/cctype.pass.cpp b/test/std/strings/c.strings/cctype.pass.cpp
new file mode 100644
index 000000000000..867338fb09c2
--- /dev/null
+++ b/test/std/strings/c.strings/cctype.pass.cpp
@@ -0,0 +1,103 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <cctype>
+
+#include <cctype>
+#include <type_traits>
+#include <cassert>
+
+#ifdef isalnum
+#error isalnum defined
+#endif
+
+#ifdef isalpha
+#error isalpha defined
+#endif
+
+#ifdef isblank
+#error isblank defined
+#endif
+
+#ifdef iscntrl
+#error iscntrl defined
+#endif
+
+#ifdef isdigit
+#error isdigit defined
+#endif
+
+#ifdef isgraph
+#error isgraph defined
+#endif
+
+#ifdef islower
+#error islower defined
+#endif
+
+#ifdef isprint
+#error isprint defined
+#endif
+
+#ifdef ispunct
+#error ispunct defined
+#endif
+
+#ifdef isspace
+#error isspace defined
+#endif
+
+#ifdef isupper
+#error isupper defined
+#endif
+
+#ifdef isxdigit
+#error isxdigit defined
+#endif
+
+#ifdef tolower
+#error tolower defined
+#endif
+
+#ifdef toupper
+#error toupper defined
+#endif
+
+int main()
+{
+ static_assert((std::is_same<decltype(std::isalnum(0)), int>::value), "");
+ static_assert((std::is_same<decltype(std::isalpha(0)), int>::value), "");
+ static_assert((std::is_same<decltype(std::isblank(0)), int>::value), "");
+ static_assert((std::is_same<decltype(std::iscntrl(0)), int>::value), "");
+ static_assert((std::is_same<decltype(std::isdigit(0)), int>::value), "");
+ static_assert((std::is_same<decltype(std::isgraph(0)), int>::value), "");
+ static_assert((std::is_same<decltype(std::islower(0)), int>::value), "");
+ static_assert((std::is_same<decltype(std::isprint(0)), int>::value), "");
+ static_assert((std::is_same<decltype(std::ispunct(0)), int>::value), "");
+ static_assert((std::is_same<decltype(std::isspace(0)), int>::value), "");
+ static_assert((std::is_same<decltype(std::isupper(0)), int>::value), "");
+ static_assert((std::is_same<decltype(std::isxdigit(0)), int>::value), "");
+ static_assert((std::is_same<decltype(std::tolower(0)), int>::value), "");
+ static_assert((std::is_same<decltype(std::toupper(0)), int>::value), "");
+
+ assert(isalnum('a'));
+ assert(isalpha('a'));
+ assert(isblank(' '));
+ assert(!iscntrl(' '));
+ assert(!isdigit('a'));
+ assert(isgraph('a'));
+ assert(islower('a'));
+ assert(isprint('a'));
+ assert(!ispunct('a'));
+ assert(!isspace('a'));
+ assert(!isupper('a'));
+ assert(isxdigit('a'));
+ assert(tolower('A') == 'a');
+ assert(toupper('a') == 'A');
+}
diff --git a/test/std/strings/c.strings/cstring.pass.cpp b/test/std/strings/c.strings/cstring.pass.cpp
new file mode 100644
index 000000000000..20f4050cfbdb
--- /dev/null
+++ b/test/std/strings/c.strings/cstring.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <cstring>
+
+#include <cstring>
+#include <type_traits>
+
+#ifndef NULL
+#error NULL not defined
+#endif
+
+int main()
+{
+ std::size_t s = 0;
+ void* vp = 0;
+ const void* vpc = 0;
+ char* cp = 0;
+ const char* cpc = 0;
+ static_assert((std::is_same<decltype(std::memcpy(vp, vpc, s)), void*>::value), "");
+ static_assert((std::is_same<decltype(std::memmove(vp, vpc, s)), void*>::value), "");
+ static_assert((std::is_same<decltype(std::strcpy(cp, cpc)), char*>::value), "");
+ static_assert((std::is_same<decltype(std::strncpy(cp, cpc, s)), char*>::value), "");
+ static_assert((std::is_same<decltype(std::strcat(cp, cpc)), char*>::value), "");
+ static_assert((std::is_same<decltype(std::strncat(cp, cpc, s)), char*>::value), "");
+ static_assert((std::is_same<decltype(std::memcmp(vpc, vpc, s)), int>::value), "");
+ static_assert((std::is_same<decltype(std::strcmp(cpc, cpc)), int>::value), "");
+ static_assert((std::is_same<decltype(std::strncmp(cpc, cpc, s)), int>::value), "");
+ static_assert((std::is_same<decltype(std::strcoll(cpc, cpc)), int>::value), "");
+ static_assert((std::is_same<decltype(std::strxfrm(cp, cpc, s)), std::size_t>::value), "");
+// static_assert((std::is_same<decltype(std::memchr(vpc, 0, s)), const void*>::value), "");
+ static_assert((std::is_same<decltype(std::memchr(vp, 0, s)), void*>::value), "");
+// static_assert((std::is_same<decltype(std::strchr(cpc, 0)), const char*>::value), "");
+ static_assert((std::is_same<decltype(std::strchr(cp, 0)), char*>::value), "");
+ static_assert((std::is_same<decltype(std::strcspn(cpc, cpc)), std::size_t>::value), "");
+// static_assert((std::is_same<decltype(std::strpbrk(cpc, cpc)), const char*>::value), "");
+ static_assert((std::is_same<decltype(std::strpbrk(cp, cpc)), char*>::value), "");
+// static_assert((std::is_same<decltype(std::strrchr(cpc, 0)), const char*>::value), "");
+ static_assert((std::is_same<decltype(std::strrchr(cp, 0)), char*>::value), "");
+ static_assert((std::is_same<decltype(std::strspn(cpc, cpc)), std::size_t>::value), "");
+// static_assert((std::is_same<decltype(std::strstr(cpc, cpc)), const char*>::value), "");
+ static_assert((std::is_same<decltype(std::strstr(cp, cpc)), char*>::value), "");
+#ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
+ static_assert((std::is_same<decltype(std::strtok(cp, cpc)), char*>::value), "");
+#endif
+ static_assert((std::is_same<decltype(std::memset(vp, 0, s)), void*>::value), "");
+ static_assert((std::is_same<decltype(std::strerror(0)), char*>::value), "");
+ static_assert((std::is_same<decltype(std::strlen(cpc)), std::size_t>::value), "");
+}
diff --git a/test/std/strings/c.strings/cuchar.pass.cpp b/test/std/strings/c.strings/cuchar.pass.cpp
new file mode 100644
index 000000000000..022c656e8a27
--- /dev/null
+++ b/test/std/strings/c.strings/cuchar.pass.cpp
@@ -0,0 +1,18 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// XFAIL: *
+
+// <cuchar>
+
+#include <cuchar>
+
+int main()
+{
+}
diff --git a/test/std/strings/c.strings/cwchar.pass.cpp b/test/std/strings/c.strings/cwchar.pass.cpp
new file mode 100644
index 000000000000..c3d868fbc3b7
--- /dev/null
+++ b/test/std/strings/c.strings/cwchar.pass.cpp
@@ -0,0 +1,115 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <cwchar>
+
+#include <cwchar>
+#include <type_traits>
+
+#ifndef NULL
+#error NULL not defined
+#endif
+
+#ifndef WCHAR_MAX
+#error WCHAR_MAX not defined
+#endif
+
+#ifndef WCHAR_MIN
+#error WCHAR_MIN not defined
+#endif
+
+#ifndef WEOF
+#error WEOF not defined
+#endif
+
+int main()
+{
+ std::mbstate_t mb = {0};
+ std::size_t s = 0;
+ std::tm *tm = 0;
+ std::wint_t w = 0;
+ ::FILE* fp = 0;
+#ifdef __APPLE__
+ __darwin_va_list va;
+#else
+ __builtin_va_list va;
+#endif
+ char* ns = 0;
+ wchar_t* ws = 0;
+ static_assert((std::is_same<decltype(std::fwprintf(fp, L"")), int>::value), "");
+ static_assert((std::is_same<decltype(std::fwscanf(fp, L"")), int>::value), "");
+ static_assert((std::is_same<decltype(std::swprintf(ws, s, L"")), int>::value), "");
+ static_assert((std::is_same<decltype(std::swscanf(L"", L"")), int>::value), "");
+ static_assert((std::is_same<decltype(std::vfwprintf(fp, L"", va)), int>::value), "");
+ static_assert((std::is_same<decltype(std::vfwscanf(fp, L"", va)), int>::value), "");
+ static_assert((std::is_same<decltype(std::vswprintf(ws, s, L"", va)), int>::value), "");
+ static_assert((std::is_same<decltype(std::vswscanf(L"", L"", va)), int>::value), "");
+ static_assert((std::is_same<decltype(std::fgetwc(fp)), std::wint_t>::value), "");
+ static_assert((std::is_same<decltype(std::fgetws(ws, 0, fp)), wchar_t*>::value), "");
+ static_assert((std::is_same<decltype(std::fputwc(L' ', fp)), std::wint_t>::value), "");
+ static_assert((std::is_same<decltype(std::fputws(L"", fp)), int>::value), "");
+ static_assert((std::is_same<decltype(std::fwide(fp, 0)), int>::value), "");
+ static_assert((std::is_same<decltype(std::getwc(fp)), std::wint_t>::value), "");
+ static_assert((std::is_same<decltype(std::putwc(L' ', fp)), std::wint_t>::value), "");
+ static_assert((std::is_same<decltype(std::ungetwc(L' ', fp)), std::wint_t>::value), "");
+ static_assert((std::is_same<decltype(std::wcstod(L"", (wchar_t**)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::wcstof(L"", (wchar_t**)0)), float>::value), "");
+ static_assert((std::is_same<decltype(std::wcstold(L"", (wchar_t**)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::wcstol(L"", (wchar_t**)0, 0)), long>::value), "");
+ static_assert((std::is_same<decltype(std::wcstoll(L"", (wchar_t**)0, 0)), long long>::value), "");
+ static_assert((std::is_same<decltype(std::wcstoul(L"", (wchar_t**)0, 0)), unsigned long>::value), "");
+ static_assert((std::is_same<decltype(std::wcstoull(L"", (wchar_t**)0, 0)), unsigned long long>::value), "");
+ static_assert((std::is_same<decltype(std::wcscpy(ws, L"")), wchar_t*>::value), "");
+ static_assert((std::is_same<decltype(std::wcsncpy(ws, L"", s)), wchar_t*>::value), "");
+ static_assert((std::is_same<decltype(std::wcscat(ws, L"")), wchar_t*>::value), "");
+ static_assert((std::is_same<decltype(std::wcsncat(ws, L"", s)), wchar_t*>::value), "");
+ static_assert((std::is_same<decltype(std::wcscmp(L"", L"")), int>::value), "");
+ static_assert((std::is_same<decltype(std::wcscoll(L"", L"")), int>::value), "");
+ static_assert((std::is_same<decltype(std::wcsncmp(L"", L"", s)), int>::value), "");
+ static_assert((std::is_same<decltype(std::wcsxfrm(ws, L"", s)), std::size_t>::value), "");
+ static_assert((std::is_same<decltype(std::wcschr((const wchar_t*)0, L' ')), const wchar_t*>::value), "");
+ static_assert((std::is_same<decltype(std::wcschr((wchar_t*)0, L' ')), wchar_t*>::value), "");
+ static_assert((std::is_same<decltype(std::wcscspn(L"", L"")), std::size_t>::value), "");
+ static_assert((std::is_same<decltype(std::wcslen(L"")), std::size_t>::value), "");
+ static_assert((std::is_same<decltype(std::wcspbrk((const wchar_t*)0, L"")), const wchar_t*>::value), "");
+ static_assert((std::is_same<decltype(std::wcspbrk((wchar_t*)0, L"")), wchar_t*>::value), "");
+ static_assert((std::is_same<decltype(std::wcsrchr((const wchar_t*)0, L' ')), const wchar_t*>::value), "");
+ static_assert((std::is_same<decltype(std::wcsrchr((wchar_t*)0, L' ')), wchar_t*>::value), "");
+ static_assert((std::is_same<decltype(std::wcsspn(L"", L"")), std::size_t>::value), "");
+ static_assert((std::is_same<decltype(std::wcsstr((const wchar_t*)0, L"")), const wchar_t*>::value), "");
+ static_assert((std::is_same<decltype(std::wcsstr((wchar_t*)0, L"")), wchar_t*>::value), "");
+ static_assert((std::is_same<decltype(std::wcstok(ws, L"", (wchar_t**)0)), wchar_t*>::value), "");
+ static_assert((std::is_same<decltype(std::wmemchr((const wchar_t*)0, L' ', s)), const wchar_t*>::value), "");
+ static_assert((std::is_same<decltype(std::wmemchr((wchar_t*)0, L' ', s)), wchar_t*>::value), "");
+ static_assert((std::is_same<decltype(std::wmemcmp(L"", L"", s)), int>::value), "");
+ static_assert((std::is_same<decltype(std::wmemcpy(ws, L"", s)), wchar_t*>::value), "");
+ static_assert((std::is_same<decltype(std::wmemmove(ws, L"", s)), wchar_t*>::value), "");
+ static_assert((std::is_same<decltype(std::wmemset(ws, L' ', s)), wchar_t*>::value), "");
+ static_assert((std::is_same<decltype(std::wcsftime(ws, s, L"", tm)), std::size_t>::value), "");
+ static_assert((std::is_same<decltype(std::btowc(0)), wint_t>::value), "");
+ static_assert((std::is_same<decltype(std::wctob(w)), int>::value), "");
+ static_assert((std::is_same<decltype(std::mbsinit(&mb)), int>::value), "");
+ static_assert((std::is_same<decltype(std::mbrlen("", s, &mb)), std::size_t>::value), "");
+ static_assert((std::is_same<decltype(std::mbrtowc(ws, "", s, &mb)), std::size_t>::value), "");
+ static_assert((std::is_same<decltype(std::wcrtomb(ns, L' ', &mb)), std::size_t>::value), "");
+ static_assert((std::is_same<decltype(std::mbsrtowcs(ws, (const char**)0, s, &mb)), std::size_t>::value), "");
+ static_assert((std::is_same<decltype(std::wcsrtombs(ns, (const wchar_t**)0, s, &mb)), std::size_t>::value), "");
+
+#ifndef _LIBCPP_HAS_NO_STDIN
+ static_assert((std::is_same<decltype(std::getwchar()), std::wint_t>::value), "");
+ static_assert((std::is_same<decltype(std::vwscanf(L"", va)), int>::value), "");
+ static_assert((std::is_same<decltype(std::wscanf(L"")), int>::value), "");
+#endif
+
+#ifndef _LIBCPP_HAS_NO_STDOUT
+ static_assert((std::is_same<decltype(std::putwchar(L' ')), std::wint_t>::value), "");
+ static_assert((std::is_same<decltype(std::vwprintf(L"", va)), int>::value), "");
+ static_assert((std::is_same<decltype(std::wprintf(L"")), int>::value), "");
+#endif
+}
diff --git a/test/std/strings/c.strings/cwctype.pass.cpp b/test/std/strings/c.strings/cwctype.pass.cpp
new file mode 100644
index 000000000000..6d66415abdc1
--- /dev/null
+++ b/test/std/strings/c.strings/cwctype.pass.cpp
@@ -0,0 +1,114 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <cwctype>
+
+#include <cwctype>
+#include <type_traits>
+
+#ifndef WEOF
+#error WEOF not defined
+#endif
+
+#ifdef iswalnum
+#error iswalnum defined
+#endif
+
+#ifdef iswalpha
+#error iswalpha defined
+#endif
+
+#ifdef iswblank
+#error iswblank defined
+#endif
+
+#ifdef iswcntrl
+#error iswcntrl defined
+#endif
+
+#ifdef iswdigit
+#error iswdigit defined
+#endif
+
+#ifdef iswgraph
+#error iswgraph defined
+#endif
+
+#ifdef iswlower
+#error iswlower defined
+#endif
+
+#ifdef iswprint
+#error iswprint defined
+#endif
+
+#ifdef iswpunct
+#error iswpunct defined
+#endif
+
+#ifdef iswspace
+#error iswspace defined
+#endif
+
+#ifdef iswupper
+#error iswupper defined
+#endif
+
+#ifdef iswxdigit
+#error iswxdigit defined
+#endif
+
+#ifdef iswctype
+#error iswctype defined
+#endif
+
+#ifdef wctype
+#error wctype defined
+#endif
+
+#ifdef towlower
+#error towlower defined
+#endif
+
+#ifdef towupper
+#error towupper defined
+#endif
+
+#ifdef towctrans
+#error towctrans defined
+#endif
+
+#ifdef wctrans
+#error wctrans defined
+#endif
+
+int main()
+{
+ std::wint_t w = 0;
+ std::wctrans_t wctr = 0;
+ std::wctype_t wct = 0;
+ static_assert((std::is_same<decltype(std::iswalnum(w)), int>::value), "");
+ static_assert((std::is_same<decltype(std::iswalpha(w)), int>::value), "");
+ static_assert((std::is_same<decltype(std::iswblank(w)), int>::value), "");
+ static_assert((std::is_same<decltype(std::iswcntrl(w)), int>::value), "");
+ static_assert((std::is_same<decltype(std::iswdigit(w)), int>::value), "");
+ static_assert((std::is_same<decltype(std::iswgraph(w)), int>::value), "");
+ static_assert((std::is_same<decltype(std::iswlower(w)), int>::value), "");
+ static_assert((std::is_same<decltype(std::iswprint(w)), int>::value), "");
+ static_assert((std::is_same<decltype(std::iswpunct(w)), int>::value), "");
+ static_assert((std::is_same<decltype(std::iswspace(w)), int>::value), "");
+ static_assert((std::is_same<decltype(std::iswupper(w)), int>::value), "");
+ static_assert((std::is_same<decltype(std::iswxdigit(w)), int>::value), "");
+ static_assert((std::is_same<decltype(std::iswctype(w, wct)), int>::value), "");
+ static_assert((std::is_same<decltype(std::wctype("")), std::wctype_t>::value), "");
+ static_assert((std::is_same<decltype(std::towlower(w)), std::wint_t>::value), "");
+ static_assert((std::is_same<decltype(std::towupper(w)), std::wint_t>::value), "");
+ static_assert((std::is_same<decltype(std::towctrans(w, wctr)), std::wint_t>::value), "");
+ static_assert((std::is_same<decltype(std::wctrans("")), std::wctrans_t>::value), "");
+}
diff --git a/test/std/strings/c.strings/version_cctype.pass.cpp b/test/std/strings/c.strings/version_cctype.pass.cpp
new file mode 100644
index 000000000000..e0919d9d27b0
--- /dev/null
+++ b/test/std/strings/c.strings/version_cctype.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <cctype>
+
+#include <cctype>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/strings/c.strings/version_cstring.pass.cpp b/test/std/strings/c.strings/version_cstring.pass.cpp
new file mode 100644
index 000000000000..87e705aec4cc
--- /dev/null
+++ b/test/std/strings/c.strings/version_cstring.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <cstring>
+
+#include <cstring>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/strings/c.strings/version_cuchar.pass.cpp b/test/std/strings/c.strings/version_cuchar.pass.cpp
new file mode 100644
index 000000000000..dcfdcc37ac7e
--- /dev/null
+++ b/test/std/strings/c.strings/version_cuchar.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// XFAIL: *
+
+// <cuchar>
+
+#include <cuchar>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/strings/c.strings/version_cwchar.pass.cpp b/test/std/strings/c.strings/version_cwchar.pass.cpp
new file mode 100644
index 000000000000..72e9855c54e5
--- /dev/null
+++ b/test/std/strings/c.strings/version_cwchar.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <cwchar>
+
+#include <cwchar>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/strings/c.strings/version_cwctype.pass.cpp b/test/std/strings/c.strings/version_cwctype.pass.cpp
new file mode 100644
index 000000000000..461482abe765
--- /dev/null
+++ b/test/std/strings/c.strings/version_cwctype.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <cwctype>
+
+#include <cwctype>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/strings/char.traits/char.traits.require/nothing_to_do.pass.cpp b/test/std/strings/char.traits/char.traits.require/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/strings/char.traits/char.traits.require/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/assign2.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/assign2.pass.cpp
new file mode 100644
index 000000000000..2c3deaefd063
--- /dev/null
+++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/assign2.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char>
+
+// static void assign(char_type& c1, const char_type& c2);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+ char c = '\0';
+ std::char_traits<char>::assign(c, 'a');
+ assert(c == 'a');
+}
diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/assign3.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/assign3.pass.cpp
new file mode 100644
index 000000000000..a4a0e294c262
--- /dev/null
+++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/assign3.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char>
+
+// static char_type* assign(char_type* s, size_t n, char_type a);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+ char s1[] = {1, 2, 3};
+ char s2[3] = {0};
+ assert(std::char_traits<char>::assign(s2, 3, char(5)) == s2);
+ assert(s2[0] == char(5));
+ assert(s2[1] == char(5));
+ assert(s2[2] == char(5));
+ assert(std::char_traits<char>::assign(NULL, 0, char(5)) == NULL);
+}
diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/compare.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/compare.pass.cpp
new file mode 100644
index 000000000000..ba58684b8e2e
--- /dev/null
+++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/compare.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char>
+
+// static int compare(const char_type* s1, const char_type* s2, size_t n);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+ assert(std::char_traits<char>::compare("", "", 0) == 0);
+ assert(std::char_traits<char>::compare(NULL, NULL, 0) == 0);
+
+ assert(std::char_traits<char>::compare("1", "1", 1) == 0);
+ assert(std::char_traits<char>::compare("1", "2", 1) < 0);
+ assert(std::char_traits<char>::compare("2", "1", 1) > 0);
+
+ assert(std::char_traits<char>::compare("12", "12", 2) == 0);
+ assert(std::char_traits<char>::compare("12", "13", 2) < 0);
+ assert(std::char_traits<char>::compare("12", "22", 2) < 0);
+ assert(std::char_traits<char>::compare("13", "12", 2) > 0);
+ assert(std::char_traits<char>::compare("22", "12", 2) > 0);
+
+ assert(std::char_traits<char>::compare("123", "123", 3) == 0);
+ assert(std::char_traits<char>::compare("123", "223", 3) < 0);
+ assert(std::char_traits<char>::compare("123", "133", 3) < 0);
+ assert(std::char_traits<char>::compare("123", "124", 3) < 0);
+ assert(std::char_traits<char>::compare("223", "123", 3) > 0);
+ assert(std::char_traits<char>::compare("133", "123", 3) > 0);
+ assert(std::char_traits<char>::compare("124", "123", 3) > 0);
+}
diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/copy.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/copy.pass.cpp
new file mode 100644
index 000000000000..179df9e19dde
--- /dev/null
+++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/copy.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char>
+
+// static char_type* copy(char_type* s1, const char_type* s2, size_t n);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+ char s1[] = {1, 2, 3};
+ char s2[3] = {0};
+ assert(std::char_traits<char>::copy(s2, s1, 3) == s2);
+ assert(s2[0] == char(1));
+ assert(s2[1] == char(2));
+ assert(s2[2] == char(3));
+ assert(std::char_traits<char>::copy(NULL, s1, 0) == NULL);
+ assert(std::char_traits<char>::copy(s1, NULL, 0) == s1);
+}
diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/eof.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/eof.pass.cpp
new file mode 100644
index 000000000000..39fba6b1c068
--- /dev/null
+++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/eof.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char>
+
+// static constexpr int_type eof();
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+ assert(std::char_traits<char>::eof() == EOF);
+}
diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/eq.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/eq.pass.cpp
new file mode 100644
index 000000000000..f7f84e85924c
--- /dev/null
+++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/eq.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char>
+
+// static constexpr bool eq(char_type c1, char_type c2);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+ char c = '\0';
+ assert(std::char_traits<char>::eq('a', 'a'));
+ assert(!std::char_traits<char>::eq('a', 'A'));
+}
diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/eq_int_type.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/eq_int_type.pass.cpp
new file mode 100644
index 000000000000..bdaf431db4dc
--- /dev/null
+++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/eq_int_type.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char>
+
+// static constexpr bool eq_int_type(int_type c1, int_type c2);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+ assert( std::char_traits<char>::eq_int_type('a', 'a'));
+ assert(!std::char_traits<char>::eq_int_type('a', 'A'));
+ assert(!std::char_traits<char>::eq_int_type(std::char_traits<char>::eof(), 'A'));
+ assert( std::char_traits<char>::eq_int_type(std::char_traits<char>::eof(),
+ std::char_traits<char>::eof()));
+}
diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/find.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/find.pass.cpp
new file mode 100644
index 000000000000..a640af28d8ac
--- /dev/null
+++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/find.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char>
+
+// static const char_type* find(const char_type* s, size_t n, const char_type& a);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+ char s1[] = {1, 2, 3};
+ assert(std::char_traits<char>::find(s1, 3, char(1)) == s1);
+ assert(std::char_traits<char>::find(s1, 3, char(2)) == s1+1);
+ assert(std::char_traits<char>::find(s1, 3, char(3)) == s1+2);
+ assert(std::char_traits<char>::find(s1, 3, char(4)) == 0);
+ assert(std::char_traits<char>::find(s1, 3, char(0)) == 0);
+ assert(std::char_traits<char>::find(NULL, 0, char(0)) == 0);
+}
diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/length.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/length.pass.cpp
new file mode 100644
index 000000000000..56844ef46644
--- /dev/null
+++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/length.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char>
+
+// static size_t length(const char_type* s);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+ assert(std::char_traits<char>::length("") == 0);
+ assert(std::char_traits<char>::length("a") == 1);
+ assert(std::char_traits<char>::length("aa") == 2);
+ assert(std::char_traits<char>::length("aaa") == 3);
+ assert(std::char_traits<char>::length("aaaa") == 4);
+}
diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/lt.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/lt.pass.cpp
new file mode 100644
index 000000000000..3ff9c0f1ff92
--- /dev/null
+++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/lt.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char>
+
+// static constexpr bool lt(char_type c1, char_type c2);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+ char c = '\0';
+ assert(!std::char_traits<char>::lt('a', 'a'));
+ assert( std::char_traits<char>::lt('A', 'a'));
+ assert(!std::char_traits<char>::lt('A' + 127, 'a'));
+ assert(!std::char_traits<char>::lt('A' - 127, 'a'));
+ assert( std::char_traits<char>::lt('A', 'a' + 127));
+ assert( std::char_traits<char>::lt('A', 'a' - 127));
+}
diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/move.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/move.pass.cpp
new file mode 100644
index 000000000000..67f0216a28b1
--- /dev/null
+++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/move.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char>
+
+// static char_type* move(char_type* s1, const char_type* s2, size_t n);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+ char s1[] = {1, 2, 3};
+ assert(std::char_traits<char>::move(s1, s1+1, 2) == s1);
+ assert(s1[0] == char(2));
+ assert(s1[1] == char(3));
+ assert(s1[2] == char(3));
+ s1[2] = char(0);
+ assert(std::char_traits<char>::move(s1+1, s1, 2) == s1+1);
+ assert(s1[0] == char(2));
+ assert(s1[1] == char(2));
+ assert(s1[2] == char(3));
+ assert(std::char_traits<char>::move(NULL, s1, 0) == NULL);
+ assert(std::char_traits<char>::move(s1, NULL, 0) == s1);
+}
diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/not_eof.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/not_eof.pass.cpp
new file mode 100644
index 000000000000..69800969a7f3
--- /dev/null
+++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/not_eof.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char>
+
+// static constexpr int_type not_eof(int_type c);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+ assert(std::char_traits<char>::not_eof('a') == 'a');
+ assert(std::char_traits<char>::not_eof('A') == 'A');
+ assert(std::char_traits<char>::not_eof(0) == 0);
+ assert(std::char_traits<char>::not_eof(std::char_traits<char>::eof()) !=
+ std::char_traits<char>::eof());
+}
diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/to_char_type.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/to_char_type.pass.cpp
new file mode 100644
index 000000000000..498abfa25fc0
--- /dev/null
+++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/to_char_type.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char>
+
+// static constexpr char_type to_char_type(int_type c);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+ assert(std::char_traits<char>::to_char_type('a') == 'a');
+ assert(std::char_traits<char>::to_char_type('A') == 'A');
+ assert(std::char_traits<char>::to_char_type(0) == 0);
+}
diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/to_int_type.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/to_int_type.pass.cpp
new file mode 100644
index 000000000000..aa9594cfdc42
--- /dev/null
+++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/to_int_type.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char>
+
+// static constexpr int_type to_int_type(char_type c);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+ assert(std::char_traits<char>::to_int_type('a') == 'a');
+ assert(std::char_traits<char>::to_int_type('A') == 'A');
+ assert(std::char_traits<char>::to_int_type(0) == 0);
+}
diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/types.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/types.pass.cpp
new file mode 100644
index 000000000000..ff4a93af65f2
--- /dev/null
+++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/types.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char>
+
+// typedef char char_type;
+// typedef int int_type;
+// typedef streamoff off_type;
+// typedef streampos pos_type;
+// typedef mbstate_t state_type;
+
+#include <string>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_same<std::char_traits<char>::char_type, char>::value), "");
+ static_assert((std::is_same<std::char_traits<char>::int_type, int>::value), "");
+ static_assert((std::is_same<std::char_traits<char>::off_type, std::streamoff>::value), "");
+ static_assert((std::is_same<std::char_traits<char>::pos_type, std::streampos>::value), "");
+ static_assert((std::is_same<std::char_traits<char>::state_type, std::mbstate_t>::value), "");
+}
diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/assign2.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/assign2.pass.cpp
new file mode 100644
index 000000000000..af87052ff219
--- /dev/null
+++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/assign2.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char16_t>
+
+// static void assign(char_type& c1, const char_type& c2);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+#if __cplusplus >= 201103L
+ char16_t c = u'\0';
+ std::char_traits<char16_t>::assign(c, u'a');
+ assert(c == u'a');
+#endif
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+}
diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/assign3.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/assign3.pass.cpp
new file mode 100644
index 000000000000..fc1ba6e8670a
--- /dev/null
+++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/assign3.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char16_t>
+
+// static char_type* assign(char_type* s, size_t n, char_type a);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+ char16_t s1[] = {1, 2, 3};
+ char16_t s2[3] = {0};
+ assert(std::char_traits<char16_t>::assign(s2, 3, char16_t(5)) == s2);
+ assert(s2[0] == char16_t(5));
+ assert(s2[1] == char16_t(5));
+ assert(s2[2] == char16_t(5));
+ assert(std::char_traits<char16_t>::assign(NULL, 0, char16_t(5)) == NULL);
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+}
diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/compare.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/compare.pass.cpp
new file mode 100644
index 000000000000..b5039072dbfd
--- /dev/null
+++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/compare.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char16_t>
+
+// static int compare(const char_type* s1, const char_type* s2, size_t n);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+#if __cplusplus >= 201103L
+ assert(std::char_traits<char16_t>::compare(u"", u"", 0) == 0);
+ assert(std::char_traits<char16_t>::compare(NULL, NULL, 0) == 0);
+
+ assert(std::char_traits<char16_t>::compare(u"1", u"1", 1) == 0);
+ assert(std::char_traits<char16_t>::compare(u"1", u"2", 1) < 0);
+ assert(std::char_traits<char16_t>::compare(u"2", u"1", 1) > 0);
+
+ assert(std::char_traits<char16_t>::compare(u"12", u"12", 2) == 0);
+ assert(std::char_traits<char16_t>::compare(u"12", u"13", 2) < 0);
+ assert(std::char_traits<char16_t>::compare(u"12", u"22", 2) < 0);
+ assert(std::char_traits<char16_t>::compare(u"13", u"12", 2) > 0);
+ assert(std::char_traits<char16_t>::compare(u"22", u"12", 2) > 0);
+
+ assert(std::char_traits<char16_t>::compare(u"123", u"123", 3) == 0);
+ assert(std::char_traits<char16_t>::compare(u"123", u"223", 3) < 0);
+ assert(std::char_traits<char16_t>::compare(u"123", u"133", 3) < 0);
+ assert(std::char_traits<char16_t>::compare(u"123", u"124", 3) < 0);
+ assert(std::char_traits<char16_t>::compare(u"223", u"123", 3) > 0);
+ assert(std::char_traits<char16_t>::compare(u"133", u"123", 3) > 0);
+ assert(std::char_traits<char16_t>::compare(u"124", u"123", 3) > 0);
+#endif
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+}
diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/copy.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/copy.pass.cpp
new file mode 100644
index 000000000000..4f66d2c2cade
--- /dev/null
+++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/copy.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char16_t>
+
+// static char_type* copy(char_type* s1, const char_type* s2, size_t n);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+ char16_t s1[] = {1, 2, 3};
+ char16_t s2[3] = {0};
+ assert(std::char_traits<char16_t>::copy(s2, s1, 3) == s2);
+ assert(s2[0] == char16_t(1));
+ assert(s2[1] == char16_t(2));
+ assert(s2[2] == char16_t(3));
+ assert(std::char_traits<char16_t>::copy(NULL, s1, 0) == NULL);
+ assert(std::char_traits<char16_t>::copy(s1, NULL, 0) == s1);
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+}
diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/eof.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/eof.pass.cpp
new file mode 100644
index 000000000000..4e5a1834aeb5
--- /dev/null
+++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/eof.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char16_t>
+
+// static constexpr int_type eof();
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+ std::char_traits<char16_t>::int_type i = std::char_traits<char16_t>::eof();
+#endif
+}
diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/eq.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/eq.pass.cpp
new file mode 100644
index 000000000000..8216934658ce
--- /dev/null
+++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/eq.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char16_t>
+
+// static constexpr bool eq(char_type c1, char_type c2);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+#if __cplusplus >= 201103L
+ char16_t c = u'\0';
+ assert(std::char_traits<char16_t>::eq(u'a', u'a'));
+ assert(!std::char_traits<char16_t>::eq(u'a', u'A'));
+#endif
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+}
diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/eq_int_type.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/eq_int_type.pass.cpp
new file mode 100644
index 000000000000..a20aa7d47189
--- /dev/null
+++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/eq_int_type.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char16_t>
+
+// static constexpr bool eq_int_type(int_type c1, int_type c2);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+#if __cplusplus >= 201103L
+ assert( std::char_traits<char16_t>::eq_int_type(u'a', u'a'));
+ assert(!std::char_traits<char16_t>::eq_int_type(u'a', u'A'));
+ assert(!std::char_traits<char16_t>::eq_int_type(std::char_traits<char16_t>::eof(), u'A'));
+#endif
+ assert( std::char_traits<char16_t>::eq_int_type(std::char_traits<char16_t>::eof(),
+ std::char_traits<char16_t>::eof()));
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+}
diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/find.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/find.pass.cpp
new file mode 100644
index 000000000000..22db05b55a87
--- /dev/null
+++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/find.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char16_t>
+
+// static const char_type* find(const char_type* s, size_t n, const char_type& a);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+ char16_t s1[] = {1, 2, 3};
+ assert(std::char_traits<char16_t>::find(s1, 3, char16_t(1)) == s1);
+ assert(std::char_traits<char16_t>::find(s1, 3, char16_t(2)) == s1+1);
+ assert(std::char_traits<char16_t>::find(s1, 3, char16_t(3)) == s1+2);
+ assert(std::char_traits<char16_t>::find(s1, 3, char16_t(4)) == 0);
+ assert(std::char_traits<char16_t>::find(s1, 3, char16_t(0)) == 0);
+ assert(std::char_traits<char16_t>::find(NULL, 0, char16_t(0)) == 0);
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+}
diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/length.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/length.pass.cpp
new file mode 100644
index 000000000000..9f6acca83e36
--- /dev/null
+++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/length.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char16_t>
+
+// static size_t length(const char_type* s);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+#if __cplusplus >= 201103L
+ assert(std::char_traits<char16_t>::length(u"") == 0);
+ assert(std::char_traits<char16_t>::length(u"a") == 1);
+ assert(std::char_traits<char16_t>::length(u"aa") == 2);
+ assert(std::char_traits<char16_t>::length(u"aaa") == 3);
+ assert(std::char_traits<char16_t>::length(u"aaaa") == 4);
+#endif
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+}
diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/lt.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/lt.pass.cpp
new file mode 100644
index 000000000000..135ecc05e199
--- /dev/null
+++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/lt.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char16_t>
+
+// static constexpr bool lt(char_type c1, char_type c2);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+#if __cplusplus >= 201103L
+ char16_t c = u'\0';
+ assert(!std::char_traits<char16_t>::lt(u'a', u'a'));
+ assert( std::char_traits<char16_t>::lt(u'A', u'a'));
+#endif
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+}
diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/move.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/move.pass.cpp
new file mode 100644
index 000000000000..b2ae8040ec24
--- /dev/null
+++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/move.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char16_t>
+
+// static char_type* move(char_type* s1, const char_type* s2, size_t n);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+ char16_t s1[] = {1, 2, 3};
+ assert(std::char_traits<char16_t>::move(s1, s1+1, 2) == s1);
+ assert(s1[0] == char16_t(2));
+ assert(s1[1] == char16_t(3));
+ assert(s1[2] == char16_t(3));
+ s1[2] = char16_t(0);
+ assert(std::char_traits<char16_t>::move(s1+1, s1, 2) == s1+1);
+ assert(s1[0] == char16_t(2));
+ assert(s1[1] == char16_t(2));
+ assert(s1[2] == char16_t(3));
+ assert(std::char_traits<char16_t>::move(NULL, s1, 0) == NULL);
+ assert(std::char_traits<char16_t>::move(s1, NULL, 0) == s1);
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+}
diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/not_eof.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/not_eof.pass.cpp
new file mode 100644
index 000000000000..3c213e6e0a37
--- /dev/null
+++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/not_eof.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char16_t>
+
+// static constexpr int_type not_eof(int_type c);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+#if __cplusplus >= 201103L
+ assert(std::char_traits<char16_t>::not_eof(u'a') == u'a');
+ assert(std::char_traits<char16_t>::not_eof(u'A') == u'A');
+#endif
+ assert(std::char_traits<char16_t>::not_eof(0) == 0);
+ assert(std::char_traits<char16_t>::not_eof(std::char_traits<char16_t>::eof()) !=
+ std::char_traits<char16_t>::eof());
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+}
diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/to_char_type.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/to_char_type.pass.cpp
new file mode 100644
index 000000000000..ab47403dbe01
--- /dev/null
+++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/to_char_type.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char16_t>
+
+// static constexpr char_type to_char_type(int_type c);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+#if __cplusplus >= 201103L
+ assert(std::char_traits<char16_t>::to_char_type(u'a') == u'a');
+ assert(std::char_traits<char16_t>::to_char_type(u'A') == u'A');
+#endif
+ assert(std::char_traits<char16_t>::to_char_type(0) == 0);
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+}
diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/to_int_type.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/to_int_type.pass.cpp
new file mode 100644
index 000000000000..11eb8f525466
--- /dev/null
+++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/to_int_type.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char16_t>
+
+// static constexpr int_type to_int_type(char_type c);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+#if __cplusplus >= 201103L
+ assert(std::char_traits<char16_t>::to_int_type(u'a') == u'a');
+ assert(std::char_traits<char16_t>::to_int_type(u'A') == u'A');
+#endif
+ assert(std::char_traits<char16_t>::to_int_type(0) == 0);
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+}
diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/types.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/types.pass.cpp
new file mode 100644
index 000000000000..a40296b25b1d
--- /dev/null
+++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/types.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char16_t>
+
+// typedef char16_t char_type;
+// typedef uint_least16_t int_type;
+// typedef streamoff off_type;
+// typedef u16streampos pos_type;
+// typedef mbstate_t state_type;
+
+#include <string>
+#include <type_traits>
+#include <cstdint>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+ static_assert((std::is_same<std::char_traits<char16_t>::char_type, char16_t>::value), "");
+ static_assert((std::is_same<std::char_traits<char16_t>::int_type, std::uint_least16_t>::value), "");
+ static_assert((std::is_same<std::char_traits<char16_t>::off_type, std::streamoff>::value), "");
+ static_assert((std::is_same<std::char_traits<char16_t>::pos_type, std::u16streampos>::value), "");
+ static_assert((std::is_same<std::char_traits<char16_t>::state_type, std::mbstate_t>::value), "");
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+}
diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/assign2.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/assign2.pass.cpp
new file mode 100644
index 000000000000..35dcd9602d3c
--- /dev/null
+++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/assign2.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char32_t>
+
+// static void assign(char_type& c1, const char_type& c2);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+#if __cplusplus >= 201103L
+ char32_t c = U'\0';
+ std::char_traits<char32_t>::assign(c, U'a');
+ assert(c == U'a');
+#endif
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+}
diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/assign3.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/assign3.pass.cpp
new file mode 100644
index 000000000000..0c31ea7ae97e
--- /dev/null
+++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/assign3.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char32_t>
+
+// static char_type* assign(char_type* s, size_t n, char_type a);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+ char32_t s1[] = {1, 2, 3};
+ char32_t s2[3] = {0};
+ assert(std::char_traits<char32_t>::assign(s2, 3, char32_t(5)) == s2);
+ assert(s2[0] == char32_t(5));
+ assert(s2[1] == char32_t(5));
+ assert(s2[2] == char32_t(5));
+ assert(std::char_traits<char32_t>::assign(NULL, 0, char32_t(5)) == NULL);
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+}
diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/compare.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/compare.pass.cpp
new file mode 100644
index 000000000000..25f2099896a6
--- /dev/null
+++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/compare.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char32_t>
+
+// static int compare(const char_type* s1, const char_type* s2, size_t n);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+#if __cplusplus >= 201103L
+ assert(std::char_traits<char32_t>::compare(U"", U"", 0) == 0);
+ assert(std::char_traits<char32_t>::compare(NULL, NULL, 0) == 0);
+
+ assert(std::char_traits<char32_t>::compare(U"1", U"1", 1) == 0);
+ assert(std::char_traits<char32_t>::compare(U"1", U"2", 1) < 0);
+ assert(std::char_traits<char32_t>::compare(U"2", U"1", 1) > 0);
+
+ assert(std::char_traits<char32_t>::compare(U"12", U"12", 2) == 0);
+ assert(std::char_traits<char32_t>::compare(U"12", U"13", 2) < 0);
+ assert(std::char_traits<char32_t>::compare(U"12", U"22", 2) < 0);
+ assert(std::char_traits<char32_t>::compare(U"13", U"12", 2) > 0);
+ assert(std::char_traits<char32_t>::compare(U"22", U"12", 2) > 0);
+
+ assert(std::char_traits<char32_t>::compare(U"123", U"123", 3) == 0);
+ assert(std::char_traits<char32_t>::compare(U"123", U"223", 3) < 0);
+ assert(std::char_traits<char32_t>::compare(U"123", U"133", 3) < 0);
+ assert(std::char_traits<char32_t>::compare(U"123", U"124", 3) < 0);
+ assert(std::char_traits<char32_t>::compare(U"223", U"123", 3) > 0);
+ assert(std::char_traits<char32_t>::compare(U"133", U"123", 3) > 0);
+ assert(std::char_traits<char32_t>::compare(U"124", U"123", 3) > 0);
+#endif
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+}
diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/copy.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/copy.pass.cpp
new file mode 100644
index 000000000000..89c22250b306
--- /dev/null
+++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/copy.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char32_t>
+
+// static char_type* copy(char_type* s1, const char_type* s2, size_t n);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+ char32_t s1[] = {1, 2, 3};
+ char32_t s2[3] = {0};
+ assert(std::char_traits<char32_t>::copy(s2, s1, 3) == s2);
+ assert(s2[0] == char32_t(1));
+ assert(s2[1] == char32_t(2));
+ assert(s2[2] == char32_t(3));
+ assert(std::char_traits<char32_t>::copy(NULL, s1, 0) == NULL);
+ assert(std::char_traits<char32_t>::copy(s1, NULL, 0) == s1);
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+}
diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/eof.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/eof.pass.cpp
new file mode 100644
index 000000000000..8f804aa22e7a
--- /dev/null
+++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/eof.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char32_t>
+
+// static constexpr int_type eof();
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+ std::char_traits<char32_t>::int_type i = std::char_traits<char32_t>::eof();
+#endif
+}
diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/eq.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/eq.pass.cpp
new file mode 100644
index 000000000000..ffeff0cf45a4
--- /dev/null
+++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/eq.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char32_t>
+
+// static constexpr bool eq(char_type c1, char_type c2);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+#if __cplusplus >= 201103L
+ char32_t c = U'\0';
+ assert(std::char_traits<char32_t>::eq(U'a', U'a'));
+ assert(!std::char_traits<char32_t>::eq(U'a', U'A'));
+#endif
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+}
diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/eq_int_type.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/eq_int_type.pass.cpp
new file mode 100644
index 000000000000..eb5c69661014
--- /dev/null
+++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/eq_int_type.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char32_t>
+
+// static constexpr bool eq_int_type(int_type c1, int_type c2);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+#if __cplusplus >= 201103L
+ assert( std::char_traits<char32_t>::eq_int_type(U'a', U'a'));
+ assert(!std::char_traits<char32_t>::eq_int_type(U'a', U'A'));
+ assert(!std::char_traits<char32_t>::eq_int_type(std::char_traits<char32_t>::eof(), U'A'));
+#endif
+ assert( std::char_traits<char32_t>::eq_int_type(std::char_traits<char32_t>::eof(),
+ std::char_traits<char32_t>::eof()));
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+}
diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/find.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/find.pass.cpp
new file mode 100644
index 000000000000..d0b17999d3e1
--- /dev/null
+++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/find.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char32_t>
+
+// static const char_type* find(const char_type* s, size_t n, const char_type& a);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+ char32_t s1[] = {1, 2, 3};
+ assert(std::char_traits<char32_t>::find(s1, 3, char32_t(1)) == s1);
+ assert(std::char_traits<char32_t>::find(s1, 3, char32_t(2)) == s1+1);
+ assert(std::char_traits<char32_t>::find(s1, 3, char32_t(3)) == s1+2);
+ assert(std::char_traits<char32_t>::find(s1, 3, char32_t(4)) == 0);
+ assert(std::char_traits<char32_t>::find(s1, 3, char32_t(0)) == 0);
+ assert(std::char_traits<char32_t>::find(NULL, 0, char32_t(0)) == 0);
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+}
diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/length.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/length.pass.cpp
new file mode 100644
index 000000000000..d80ce051d1fa
--- /dev/null
+++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/length.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char32_t>
+
+// static size_t length(const char_type* s);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+#if __cplusplus >= 201103L
+ assert(std::char_traits<char32_t>::length(U"") == 0);
+ assert(std::char_traits<char32_t>::length(U"a") == 1);
+ assert(std::char_traits<char32_t>::length(U"aa") == 2);
+ assert(std::char_traits<char32_t>::length(U"aaa") == 3);
+ assert(std::char_traits<char32_t>::length(U"aaaa") == 4);
+#endif
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+}
diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/lt.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/lt.pass.cpp
new file mode 100644
index 000000000000..f667507f0457
--- /dev/null
+++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/lt.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char32_t>
+
+// static constexpr bool lt(char_type c1, char_type c2);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+#if __cplusplus >= 201103L
+ char32_t c = U'\0';
+ assert(!std::char_traits<char32_t>::lt(U'a', U'a'));
+ assert( std::char_traits<char32_t>::lt(U'A', U'a'));
+#endif
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+}
diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/move.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/move.pass.cpp
new file mode 100644
index 000000000000..8641525d92bd
--- /dev/null
+++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/move.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char32_t>
+
+// static char_type* move(char_type* s1, const char_type* s2, size_t n);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+ char32_t s1[] = {1, 2, 3};
+ assert(std::char_traits<char32_t>::move(s1, s1+1, 2) == s1);
+ assert(s1[0] == char32_t(2));
+ assert(s1[1] == char32_t(3));
+ assert(s1[2] == char32_t(3));
+ s1[2] = char32_t(0);
+ assert(std::char_traits<char32_t>::move(s1+1, s1, 2) == s1+1);
+ assert(s1[0] == char32_t(2));
+ assert(s1[1] == char32_t(2));
+ assert(s1[2] == char32_t(3));
+ assert(std::char_traits<char32_t>::move(NULL, s1, 0) == NULL);
+ assert(std::char_traits<char32_t>::move(s1, NULL, 0) == s1);
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+}
diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/not_eof.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/not_eof.pass.cpp
new file mode 100644
index 000000000000..d794417bfd7a
--- /dev/null
+++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/not_eof.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char32_t>
+
+// static constexpr int_type not_eof(int_type c);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+#if __cplusplus >= 201103L
+ assert(std::char_traits<char32_t>::not_eof(U'a') == U'a');
+ assert(std::char_traits<char32_t>::not_eof(U'A') == U'A');
+#endif
+ assert(std::char_traits<char32_t>::not_eof(0) == 0);
+ assert(std::char_traits<char32_t>::not_eof(std::char_traits<char32_t>::eof()) !=
+ std::char_traits<char32_t>::eof());
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+}
diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/to_char_type.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/to_char_type.pass.cpp
new file mode 100644
index 000000000000..1f67242b2aec
--- /dev/null
+++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/to_char_type.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char32_t>
+
+// static constexpr char_type to_char_type(int_type c);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+#if __cplusplus >= 201103L
+ assert(std::char_traits<char32_t>::to_char_type(U'a') == U'a');
+ assert(std::char_traits<char32_t>::to_char_type(U'A') == U'A');
+#endif
+ assert(std::char_traits<char32_t>::to_char_type(0) == 0);
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+}
diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/to_int_type.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/to_int_type.pass.cpp
new file mode 100644
index 000000000000..a378186bdd6f
--- /dev/null
+++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/to_int_type.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char32_t>
+
+// static constexpr int_type to_int_type(char_type c);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+#if __cplusplus >= 201103L
+ assert(std::char_traits<char32_t>::to_int_type(U'a') == U'a');
+ assert(std::char_traits<char32_t>::to_int_type(U'A') == U'A');
+#endif
+ assert(std::char_traits<char32_t>::to_int_type(0) == 0);
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+}
diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/types.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/types.pass.cpp
new file mode 100644
index 000000000000..3b48af14f963
--- /dev/null
+++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/types.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char32_t>
+
+// typedef char32_t char_type;
+// typedef uint_least32_t int_type;
+// typedef streamoff off_type;
+// typedef u32streampos pos_type;
+// typedef mbstate_t state_type;
+
+#include <string>
+#include <type_traits>
+#include <cstdint>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+ static_assert((std::is_same<std::char_traits<char32_t>::char_type, char32_t>::value), "");
+ static_assert((std::is_same<std::char_traits<char32_t>::int_type, std::uint_least32_t>::value), "");
+ static_assert((std::is_same<std::char_traits<char32_t>::off_type, std::streamoff>::value), "");
+ static_assert((std::is_same<std::char_traits<char32_t>::pos_type, std::u32streampos>::value), "");
+ static_assert((std::is_same<std::char_traits<char32_t>::state_type, std::mbstate_t>::value), "");
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+}
diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/assign2.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/assign2.pass.cpp
new file mode 100644
index 000000000000..7dcf08c2e76f
--- /dev/null
+++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/assign2.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<wchar_t>
+
+// static void assign(char_type& c1, const char_type& c2);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+ wchar_t c = L'\0';
+ std::char_traits<wchar_t>::assign(c, L'a');
+ assert(c == L'a');
+}
diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/assign3.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/assign3.pass.cpp
new file mode 100644
index 000000000000..2a00fe06e5a2
--- /dev/null
+++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/assign3.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<wchar_t>
+
+// static char_type* assign(char_type* s, size_t n, char_type a);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+ wchar_t s1[] = {1, 2, 3};
+ wchar_t s2[3] = {0};
+ assert(std::char_traits<wchar_t>::assign(s2, 3, wchar_t(5)) == s2);
+ assert(s2[0] == wchar_t(5));
+ assert(s2[1] == wchar_t(5));
+ assert(s2[2] == wchar_t(5));
+ assert(std::char_traits<wchar_t>::assign(NULL, 0, wchar_t(5)) == NULL);
+}
diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/compare.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/compare.pass.cpp
new file mode 100644
index 000000000000..124201bb82f3
--- /dev/null
+++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/compare.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<wchar_t>
+
+// static int compare(const char_type* s1, const char_type* s2, size_t n);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+ assert(std::char_traits<wchar_t>::compare(L"", L"", 0) == 0);
+ assert(std::char_traits<wchar_t>::compare(NULL, NULL, 0) == 0);
+
+ assert(std::char_traits<wchar_t>::compare(L"1", L"1", 1) == 0);
+ assert(std::char_traits<wchar_t>::compare(L"1", L"2", 1) < 0);
+ assert(std::char_traits<wchar_t>::compare(L"2", L"1", 1) > 0);
+
+ assert(std::char_traits<wchar_t>::compare(L"12", L"12", 2) == 0);
+ assert(std::char_traits<wchar_t>::compare(L"12", L"13", 2) < 0);
+ assert(std::char_traits<wchar_t>::compare(L"12", L"22", 2) < 0);
+ assert(std::char_traits<wchar_t>::compare(L"13", L"12", 2) > 0);
+ assert(std::char_traits<wchar_t>::compare(L"22", L"12", 2) > 0);
+
+ assert(std::char_traits<wchar_t>::compare(L"123", L"123", 3) == 0);
+ assert(std::char_traits<wchar_t>::compare(L"123", L"223", 3) < 0);
+ assert(std::char_traits<wchar_t>::compare(L"123", L"133", 3) < 0);
+ assert(std::char_traits<wchar_t>::compare(L"123", L"124", 3) < 0);
+ assert(std::char_traits<wchar_t>::compare(L"223", L"123", 3) > 0);
+ assert(std::char_traits<wchar_t>::compare(L"133", L"123", 3) > 0);
+ assert(std::char_traits<wchar_t>::compare(L"124", L"123", 3) > 0);
+}
diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/copy.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/copy.pass.cpp
new file mode 100644
index 000000000000..f6d254f4c7c5
--- /dev/null
+++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/copy.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<wchar_t>
+
+// static char_type* copy(char_type* s1, const char_type* s2, size_t n);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+ wchar_t s1[] = {1, 2, 3};
+ wchar_t s2[3] = {0};
+ assert(std::char_traits<wchar_t>::copy(s2, s1, 3) == s2);
+ assert(s2[0] == wchar_t(1));
+ assert(s2[1] == wchar_t(2));
+ assert(s2[2] == wchar_t(3));
+ assert(std::char_traits<wchar_t>::copy(NULL, s1, 0) == NULL);
+ assert(std::char_traits<wchar_t>::copy(s1, NULL, 0) == s1);
+}
diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/eof.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/eof.pass.cpp
new file mode 100644
index 000000000000..61499b5809f8
--- /dev/null
+++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/eof.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<wchar_t>
+
+// static constexpr int_type eof();
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+ assert(std::char_traits<wchar_t>::eof() == WEOF);
+}
diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/eq.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/eq.pass.cpp
new file mode 100644
index 000000000000..98d0926e3071
--- /dev/null
+++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/eq.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<wchar_t>
+
+// static constexpr bool eq(char_type c1, char_type c2);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+ wchar_t c = L'\0';
+ assert(std::char_traits<wchar_t>::eq(L'a', L'a'));
+ assert(!std::char_traits<wchar_t>::eq(L'a', L'A'));
+}
diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/eq_int_type.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/eq_int_type.pass.cpp
new file mode 100644
index 000000000000..6b523dbdda23
--- /dev/null
+++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/eq_int_type.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<wchar_t>
+
+// static constexpr bool eq_int_type(int_type c1, int_type c2);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+ assert( std::char_traits<wchar_t>::eq_int_type(L'a', L'a'));
+ assert(!std::char_traits<wchar_t>::eq_int_type(L'a', L'A'));
+ assert(!std::char_traits<wchar_t>::eq_int_type(std::char_traits<wchar_t>::eof(), L'A'));
+ assert( std::char_traits<wchar_t>::eq_int_type(std::char_traits<wchar_t>::eof(),
+ std::char_traits<wchar_t>::eof()));
+}
diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/find.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/find.pass.cpp
new file mode 100644
index 000000000000..ead3f32fcc72
--- /dev/null
+++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/find.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<wchar_t>
+
+// static const char_type* find(const char_type* s, size_t n, const char_type& a);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+ wchar_t s1[] = {1, 2, 3};
+ assert(std::char_traits<wchar_t>::find(s1, 3, wchar_t(1)) == s1);
+ assert(std::char_traits<wchar_t>::find(s1, 3, wchar_t(2)) == s1+1);
+ assert(std::char_traits<wchar_t>::find(s1, 3, wchar_t(3)) == s1+2);
+ assert(std::char_traits<wchar_t>::find(s1, 3, wchar_t(4)) == 0);
+ assert(std::char_traits<wchar_t>::find(s1, 3, wchar_t(0)) == 0);
+ assert(std::char_traits<wchar_t>::find(NULL, 0, wchar_t(0)) == 0);
+}
diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/length.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/length.pass.cpp
new file mode 100644
index 000000000000..691e968ed246
--- /dev/null
+++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/length.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<wchar_t>
+
+// static size_t length(const char_type* s);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+ assert(std::char_traits<wchar_t>::length(L"") == 0);
+ assert(std::char_traits<wchar_t>::length(L"a") == 1);
+ assert(std::char_traits<wchar_t>::length(L"aa") == 2);
+ assert(std::char_traits<wchar_t>::length(L"aaa") == 3);
+ assert(std::char_traits<wchar_t>::length(L"aaaa") == 4);
+}
diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/lt.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/lt.pass.cpp
new file mode 100644
index 000000000000..147a57914e09
--- /dev/null
+++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/lt.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<wchar_t>
+
+// static constexpr bool lt(char_type c1, char_type c2);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+ wchar_t c = L'\0';
+ assert(!std::char_traits<wchar_t>::lt(L'a', L'a'));
+ assert( std::char_traits<wchar_t>::lt(L'A', L'a'));
+}
diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/move.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/move.pass.cpp
new file mode 100644
index 000000000000..0d80446e7118
--- /dev/null
+++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/move.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<wchar_t>
+
+// static char_type* move(char_type* s1, const char_type* s2, size_t n);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+ wchar_t s1[] = {1, 2, 3};
+ assert(std::char_traits<wchar_t>::move(s1, s1+1, 2) == s1);
+ assert(s1[0] == wchar_t(2));
+ assert(s1[1] == wchar_t(3));
+ assert(s1[2] == wchar_t(3));
+ s1[2] = wchar_t(0);
+ assert(std::char_traits<wchar_t>::move(s1+1, s1, 2) == s1+1);
+ assert(s1[0] == wchar_t(2));
+ assert(s1[1] == wchar_t(2));
+ assert(s1[2] == wchar_t(3));
+ assert(std::char_traits<wchar_t>::move(NULL, s1, 0) == NULL);
+ assert(std::char_traits<wchar_t>::move(s1, NULL, 0) == s1);
+}
diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/not_eof.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/not_eof.pass.cpp
new file mode 100644
index 000000000000..ee44f313b58c
--- /dev/null
+++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/not_eof.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<wchar_t>
+
+// static constexpr int_type not_eof(int_type c);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+ assert(std::char_traits<wchar_t>::not_eof(L'a') == L'a');
+ assert(std::char_traits<wchar_t>::not_eof(L'A') == L'A');
+ assert(std::char_traits<wchar_t>::not_eof(0) == 0);
+ assert(std::char_traits<wchar_t>::not_eof(std::char_traits<wchar_t>::eof()) !=
+ std::char_traits<wchar_t>::eof());
+}
diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/to_char_type.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/to_char_type.pass.cpp
new file mode 100644
index 000000000000..9b4c04829a92
--- /dev/null
+++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/to_char_type.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<wchar_t>
+
+// static constexpr char_type to_char_type(int_type c);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+ assert(std::char_traits<wchar_t>::to_char_type(L'a') == L'a');
+ assert(std::char_traits<wchar_t>::to_char_type(L'A') == L'A');
+ assert(std::char_traits<wchar_t>::to_char_type(0) == 0);
+}
diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/to_int_type.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/to_int_type.pass.cpp
new file mode 100644
index 000000000000..488b03e0f014
--- /dev/null
+++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/to_int_type.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<wchar_t>
+
+// static constexpr int_type to_int_type(char_type c);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+ assert(std::char_traits<wchar_t>::to_int_type(L'a') == L'a');
+ assert(std::char_traits<wchar_t>::to_int_type(L'A') == L'A');
+ assert(std::char_traits<wchar_t>::to_int_type(0) == 0);
+}
diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/types.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/types.pass.cpp
new file mode 100644
index 000000000000..12598975c4fe
--- /dev/null
+++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/types.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<wchar_t>
+
+// typedef wchar_t char_type;
+// typedef int int_type;
+// typedef streamoff off_type;
+// typedef streampos pos_type;
+// typedef mbstate_t state_type;
+
+#include <string>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_same<std::char_traits<wchar_t>::char_type, wchar_t>::value), "");
+ static_assert((std::is_same<std::char_traits<wchar_t>::int_type, std::wint_t>::value), "");
+ static_assert((std::is_same<std::char_traits<wchar_t>::off_type, std::streamoff>::value), "");
+ static_assert((std::is_same<std::char_traits<wchar_t>::pos_type, std::wstreampos>::value), "");
+ static_assert((std::is_same<std::char_traits<wchar_t>::state_type, std::mbstate_t>::value), "");
+}
diff --git a/test/std/strings/char.traits/char.traits.specializations/nothing_to_do.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/strings/char.traits/char.traits.specializations/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/strings/char.traits/char.traits.typedefs/nothing_to_do.pass.cpp b/test/std/strings/char.traits/char.traits.typedefs/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/strings/char.traits/char.traits.typedefs/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/strings/char.traits/nothing_to_do.pass.cpp b/test/std/strings/char.traits/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/strings/char.traits/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/strings/string.classes/typedefs.pass.cpp b/test/std/strings/string.classes/typedefs.pass.cpp
new file mode 100644
index 000000000000..11ee6c8a1215
--- /dev/null
+++ b/test/std/strings/string.classes/typedefs.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// Test for the existence of:
+
+// basic_string typedef names
+// typedef basic_string<char> string;
+// typedef basic_string<char16_t> u16string;
+// typedef basic_string<char32_t> u32string;
+// typedef basic_string<wchar_t> wstring;
+
+#include <string>
+
+int main()
+{
+ typedef std::string test1;
+ typedef std::wstring test2;
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+ typedef std::u16string test3;
+ typedef std::u32string test4;
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+}
diff --git a/test/std/strings/string.conversions/stod.pass.cpp b/test/std/strings/string.conversions/stod.pass.cpp
new file mode 100644
index 000000000000..026d2301e071
--- /dev/null
+++ b/test/std/strings/string.conversions/stod.pass.cpp
@@ -0,0 +1,166 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// double stod(const string& str, size_t *idx = 0);
+// double stod(const wstring& str, size_t *idx = 0);
+
+#include <string>
+#include <cmath>
+#include <cassert>
+
+int main()
+{
+ assert(std::stod("0") == 0);
+ assert(std::stod(L"0") == 0);
+ assert(std::stod("-0") == 0);
+ assert(std::stod(L"-0") == 0);
+ assert(std::stod("-10") == -10);
+ assert(std::stod(L"-10.5") == -10.5);
+ assert(std::stod(" 10") == 10);
+ assert(std::stod(L" 10") == 10);
+ size_t idx = 0;
+ assert(std::stod("10g", &idx) == 10);
+ assert(idx == 2);
+ idx = 0;
+ assert(std::stod(L"10g", &idx) == 10);
+ assert(idx == 2);
+ try
+ {
+ assert(std::stod("1.e60", &idx) == 1.e60);
+ assert(idx == 5);
+ }
+ catch (const std::out_of_range&)
+ {
+ assert(false);
+ }
+ try
+ {
+ assert(std::stod(L"1.e60", &idx) == 1.e60);
+ assert(idx == 5);
+ }
+ catch (const std::out_of_range&)
+ {
+ assert(false);
+ }
+ idx = 0;
+ try
+ {
+ assert(std::stod("1.e360", &idx) == INFINITY);
+ assert(false);
+ }
+ catch (const std::out_of_range&)
+ {
+ assert(idx == 0);
+ }
+ try
+ {
+ assert(std::stod(L"1.e360", &idx) == INFINITY);
+ assert(false);
+ }
+ catch (const std::out_of_range&)
+ {
+ assert(idx == 0);
+ }
+ try
+ {
+ assert(std::stod("INF", &idx) == INFINITY);
+ assert(idx == 3);
+ }
+ catch (const std::out_of_range&)
+ {
+ assert(false);
+ }
+ idx = 0;
+ try
+ {
+ assert(std::stod(L"INF", &idx) == INFINITY);
+ assert(idx == 3);
+ }
+ catch (const std::out_of_range&)
+ {
+ assert(false);
+ }
+ idx = 0;
+ try
+ {
+ assert(std::isnan(std::stod("NAN", &idx)));
+ assert(idx == 3);
+ }
+ catch (const std::out_of_range&)
+ {
+ assert(false);
+ }
+ idx = 0;
+ try
+ {
+ assert(std::isnan(std::stod(L"NAN", &idx)));
+ assert(idx == 3);
+ }
+ catch (const std::out_of_range&)
+ {
+ assert(false);
+ }
+ idx = 0;
+ try
+ {
+ std::stod("", &idx);
+ assert(false);
+ }
+ catch (const std::invalid_argument&)
+ {
+ assert(idx == 0);
+ }
+ try
+ {
+ std::stod(L"", &idx);
+ assert(false);
+ }
+ catch (const std::invalid_argument&)
+ {
+ assert(idx == 0);
+ }
+ try
+ {
+ std::stod(" - 8", &idx);
+ assert(false);
+ }
+ catch (const std::invalid_argument&)
+ {
+ assert(idx == 0);
+ }
+ try
+ {
+ std::stod(L" - 8", &idx);
+ assert(false);
+ }
+ catch (const std::invalid_argument&)
+ {
+ assert(idx == 0);
+ }
+ try
+ {
+ std::stod("a1", &idx);
+ assert(false);
+ }
+ catch (const std::invalid_argument&)
+ {
+ assert(idx == 0);
+ }
+ try
+ {
+ std::stod(L"a1", &idx);
+ assert(false);
+ }
+ catch (const std::invalid_argument&)
+ {
+ assert(idx == 0);
+ }
+}
diff --git a/test/std/strings/string.conversions/stof.pass.cpp b/test/std/strings/string.conversions/stof.pass.cpp
new file mode 100644
index 000000000000..3e9b681ddeb1
--- /dev/null
+++ b/test/std/strings/string.conversions/stof.pass.cpp
@@ -0,0 +1,170 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11
+// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12
+
+// <string>
+
+// float stof(const string& str, size_t *idx = 0);
+// float stof(const wstring& str, size_t *idx = 0);
+
+#include <string>
+#include <cmath>
+#include <cassert>
+
+int main()
+{
+ assert(std::stof("0") == 0);
+ assert(std::stof(L"0") == 0);
+ assert(std::stof("-0") == 0);
+ assert(std::stof(L"-0") == 0);
+ assert(std::stof("-10") == -10);
+ assert(std::stof(L"-10.5") == -10.5);
+ assert(std::stof(" 10") == 10);
+ assert(std::stof(L" 10") == 10);
+ size_t idx = 0;
+ assert(std::stof("10g", &idx) == 10);
+ assert(idx == 2);
+ idx = 0;
+ assert(std::stof(L"10g", &idx) == 10);
+ assert(idx == 2);
+ idx = 0;
+ try
+ {
+ assert(std::stof("1.e60", &idx) == INFINITY);
+ assert(false);
+ }
+ catch (const std::out_of_range&)
+ {
+ assert(idx == 0);
+ }
+ try
+ {
+ assert(std::stof(L"1.e60", &idx) == INFINITY);
+ assert(false);
+ }
+ catch (const std::out_of_range&)
+ {
+ assert(idx == 0);
+ }
+ idx = 0;
+ try
+ {
+ assert(std::stof("1.e360", &idx) == INFINITY);
+ assert(false);
+ }
+ catch (const std::out_of_range&)
+ {
+ assert(idx == 0);
+ }
+ try
+ {
+ assert(std::stof(L"1.e360", &idx) == INFINITY);
+ assert(false);
+ }
+ catch (const std::out_of_range&)
+ {
+ assert(idx == 0);
+ }
+ try
+ {
+ assert(std::stof("INF", &idx) == INFINITY);
+ assert(idx == 3);
+ }
+ catch (const std::out_of_range&)
+ {
+ assert(false);
+ }
+ idx = 0;
+ try
+ {
+ assert(std::stof(L"INF", &idx) == INFINITY);
+ assert(idx == 3);
+ }
+ catch (const std::out_of_range&)
+ {
+ assert(false);
+ }
+ idx = 0;
+ try
+ {
+ assert(std::isnan(std::stof("NAN", &idx)));
+ assert(idx == 3);
+ }
+ catch (const std::out_of_range&)
+ {
+ assert(false);
+ }
+ idx = 0;
+ try
+ {
+ assert(std::isnan(std::stof(L"NAN", &idx)));
+ assert(idx == 3);
+ }
+ catch (const std::out_of_range&)
+ {
+ assert(false);
+ }
+ idx = 0;
+ try
+ {
+ std::stof("", &idx);
+ assert(false);
+ }
+ catch (const std::invalid_argument&)
+ {
+ assert(idx == 0);
+ }
+ try
+ {
+ std::stof(L"", &idx);
+ assert(false);
+ }
+ catch (const std::invalid_argument&)
+ {
+ assert(idx == 0);
+ }
+ try
+ {
+ std::stof(" - 8", &idx);
+ assert(false);
+ }
+ catch (const std::invalid_argument&)
+ {
+ assert(idx == 0);
+ }
+ try
+ {
+ std::stof(L" - 8", &idx);
+ assert(false);
+ }
+ catch (const std::invalid_argument&)
+ {
+ assert(idx == 0);
+ }
+ try
+ {
+ std::stof("a1", &idx);
+ assert(false);
+ }
+ catch (const std::invalid_argument&)
+ {
+ assert(idx == 0);
+ }
+ try
+ {
+ std::stof(L"a1", &idx);
+ assert(false);
+ }
+ catch (const std::invalid_argument&)
+ {
+ assert(idx == 0);
+ }
+}
diff --git a/test/std/strings/string.conversions/stoi.pass.cpp b/test/std/strings/string.conversions/stoi.pass.cpp
new file mode 100644
index 000000000000..c2fc2103579d
--- /dev/null
+++ b/test/std/strings/string.conversions/stoi.pass.cpp
@@ -0,0 +1,108 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// int stoi(const string& str, size_t *idx = 0, int base = 10);
+// int stoi(const wstring& str, size_t *idx = 0, int base = 10);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+ assert(std::stoi("0") == 0);
+ assert(std::stoi(L"0") == 0);
+ assert(std::stoi("-0") == 0);
+ assert(std::stoi(L"-0") == 0);
+ assert(std::stoi("-10") == -10);
+ assert(std::stoi(L"-10") == -10);
+ assert(std::stoi(" 10") == 10);
+ assert(std::stoi(L" 10") == 10);
+ size_t idx = 0;
+ assert(std::stoi("10g", &idx, 16) == 16);
+ assert(idx == 2);
+ idx = 0;
+ assert(std::stoi(L"10g", &idx, 16) == 16);
+ assert(idx == 2);
+ if (std::numeric_limits<long>::max() > std::numeric_limits<int>::max())
+ {
+ try
+ {
+ std::stoi("0x100000000", &idx, 16);
+ assert(false);
+ }
+ catch (const std::out_of_range&)
+ {
+ }
+ try
+ {
+ std::stoi(L"0x100000000", &idx, 16);
+ assert(false);
+ }
+ catch (const std::out_of_range&)
+ {
+ }
+ }
+ idx = 0;
+ try
+ {
+ std::stoi("", &idx);
+ assert(false);
+ }
+ catch (const std::invalid_argument&)
+ {
+ assert(idx == 0);
+ }
+ try
+ {
+ std::stoi(L"", &idx);
+ assert(false);
+ }
+ catch (const std::invalid_argument&)
+ {
+ assert(idx == 0);
+ }
+ try
+ {
+ std::stoi(" - 8", &idx);
+ assert(false);
+ }
+ catch (const std::invalid_argument&)
+ {
+ assert(idx == 0);
+ }
+ try
+ {
+ std::stoi(L" - 8", &idx);
+ assert(false);
+ }
+ catch (const std::invalid_argument&)
+ {
+ assert(idx == 0);
+ }
+ try
+ {
+ std::stoi("a1", &idx);
+ assert(false);
+ }
+ catch (const std::invalid_argument&)
+ {
+ assert(idx == 0);
+ }
+ try
+ {
+ std::stoi(L"a1", &idx);
+ assert(false);
+ }
+ catch (const std::invalid_argument&)
+ {
+ assert(idx == 0);
+ }
+}
diff --git a/test/std/strings/string.conversions/stol.pass.cpp b/test/std/strings/string.conversions/stol.pass.cpp
new file mode 100644
index 000000000000..dbbccc92799c
--- /dev/null
+++ b/test/std/strings/string.conversions/stol.pass.cpp
@@ -0,0 +1,111 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11
+// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12
+
+// <string>
+
+// long stol(const string& str, size_t *idx = 0, int base = 10);
+// long stol(const wstring& str, size_t *idx = 0, int base = 10);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+ assert(std::stol("0") == 0);
+ assert(std::stol(L"0") == 0);
+ assert(std::stol("-0") == 0);
+ assert(std::stol(L"-0") == 0);
+ assert(std::stol("-10") == -10);
+ assert(std::stol(L"-10") == -10);
+ assert(std::stol(" 10") == 10);
+ assert(std::stol(L" 10") == 10);
+ size_t idx = 0;
+ assert(std::stol("10g", &idx, 16) == 16);
+ assert(idx == 2);
+ idx = 0;
+ assert(std::stol(L"10g", &idx, 16) == 16);
+ assert(idx == 2);
+ idx = 0;
+ try
+ {
+ std::stol("", &idx);
+ assert(false);
+ }
+ catch (const std::invalid_argument&)
+ {
+ assert(idx == 0);
+ }
+ try
+ {
+ std::stol(L"", &idx);
+ assert(false);
+ }
+ catch (const std::invalid_argument&)
+ {
+ assert(idx == 0);
+ }
+ try
+ {
+ std::stol(" - 8", &idx);
+ assert(false);
+ }
+ catch (const std::invalid_argument&)
+ {
+ assert(idx == 0);
+ }
+ try
+ {
+ std::stol(L" - 8", &idx);
+ assert(false);
+ }
+ catch (const std::invalid_argument&)
+ {
+ assert(idx == 0);
+ }
+ try
+ {
+ std::stol("a1", &idx);
+ assert(false);
+ }
+ catch (const std::invalid_argument&)
+ {
+ assert(idx == 0);
+ }
+ try
+ {
+ std::stol(L"a1", &idx);
+ assert(false);
+ }
+ catch (const std::invalid_argument&)
+ {
+ assert(idx == 0);
+ }
+// LWG issue #2009
+ try
+ {
+ std::stol("9999999999999999999999999999999999999999999999999", &idx);
+ assert(false);
+ }
+ catch (const std::out_of_range&)
+ {
+ assert(idx == 0);
+ }
+ try
+ {
+ std::stol(L"9999999999999999999999999999999999999999999999999", &idx);
+ assert(false);
+ }
+ catch (const std::out_of_range&)
+ {
+ assert(idx == 0);
+ }
+}
diff --git a/test/std/strings/string.conversions/stold.pass.cpp b/test/std/strings/string.conversions/stold.pass.cpp
new file mode 100644
index 000000000000..93c59fe09a11
--- /dev/null
+++ b/test/std/strings/string.conversions/stold.pass.cpp
@@ -0,0 +1,168 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// long double stold(const string& str, size_t *idx = 0);
+// long double stold(const wstring& str, size_t *idx = 0);
+
+#include <iostream>
+
+#include <string>
+#include <cmath>
+#include <cassert>
+
+int main()
+{
+ assert(std::stold("0") == 0);
+ assert(std::stold(L"0") == 0);
+ assert(std::stold("-0") == 0);
+ assert(std::stold(L"-0") == 0);
+ assert(std::stold("-10") == -10);
+ assert(std::stold(L"-10.5") == -10.5);
+ assert(std::stold(" 10") == 10);
+ assert(std::stold(L" 10") == 10);
+ size_t idx = 0;
+ assert(std::stold("10g", &idx) == 10);
+ assert(idx == 2);
+ idx = 0;
+ assert(std::stold(L"10g", &idx) == 10);
+ assert(idx == 2);
+ try
+ {
+ assert(std::stold("1.e60", &idx) == 1.e60L);
+ assert(idx == 5);
+ }
+ catch (const std::out_of_range&)
+ {
+ assert(false);
+ }
+ try
+ {
+ assert(std::stold(L"1.e60", &idx) == 1.e60L);
+ assert(idx == 5);
+ }
+ catch (const std::out_of_range&)
+ {
+ assert(false);
+ }
+ idx = 0;
+ try
+ {
+ assert(std::stold("1.e6000", &idx) == INFINITY);
+ assert(false);
+ }
+ catch (const std::out_of_range&)
+ {
+ assert(idx == 0);
+ }
+ try
+ {
+ assert(std::stold(L"1.e6000", &idx) == INFINITY);
+ assert(false);
+ }
+ catch (const std::out_of_range&)
+ {
+ assert(idx == 0);
+ }
+ try
+ {
+ assert(std::stold("INF", &idx) == INFINITY);
+ assert(idx == 3);
+ }
+ catch (const std::out_of_range&)
+ {
+ assert(false);
+ }
+ idx = 0;
+ try
+ {
+ assert(std::stold(L"INF", &idx) == INFINITY);
+ assert(idx == 3);
+ }
+ catch (const std::out_of_range&)
+ {
+ assert(false);
+ }
+ idx = 0;
+ try
+ {
+ assert(std::isnan(std::stold("NAN", &idx)));
+ assert(idx == 3);
+ }
+ catch (const std::out_of_range&)
+ {
+ assert(false);
+ }
+ idx = 0;
+ try
+ {
+ assert(std::isnan(std::stold(L"NAN", &idx)));
+ assert(idx == 3);
+ }
+ catch (const std::out_of_range&)
+ {
+ assert(false);
+ }
+ idx = 0;
+ try
+ {
+ std::stold("", &idx);
+ assert(false);
+ }
+ catch (const std::invalid_argument&)
+ {
+ assert(idx == 0);
+ }
+ try
+ {
+ std::stold(L"", &idx);
+ assert(false);
+ }
+ catch (const std::invalid_argument&)
+ {
+ assert(idx == 0);
+ }
+ try
+ {
+ std::stold(" - 8", &idx);
+ assert(false);
+ }
+ catch (const std::invalid_argument&)
+ {
+ assert(idx == 0);
+ }
+ try
+ {
+ std::stold(L" - 8", &idx);
+ assert(false);
+ }
+ catch (const std::invalid_argument&)
+ {
+ assert(idx == 0);
+ }
+ try
+ {
+ std::stold("a1", &idx);
+ assert(false);
+ }
+ catch (const std::invalid_argument&)
+ {
+ assert(idx == 0);
+ }
+ try
+ {
+ std::stold(L"a1", &idx);
+ assert(false);
+ }
+ catch (const std::invalid_argument&)
+ {
+ assert(idx == 0);
+ }
+}
diff --git a/test/std/strings/string.conversions/stoll.pass.cpp b/test/std/strings/string.conversions/stoll.pass.cpp
new file mode 100644
index 000000000000..f68490ed13ae
--- /dev/null
+++ b/test/std/strings/string.conversions/stoll.pass.cpp
@@ -0,0 +1,110 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11
+// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12
+
+// <string>
+
+// long long stoll(const string& str, size_t *idx = 0, int base = 10);
+// long long stoll(const wstring& str, size_t *idx = 0, int base = 10);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+ assert(std::stoll("0") == 0);
+ assert(std::stoll(L"0") == 0);
+ assert(std::stoll("-0") == 0);
+ assert(std::stoll(L"-0") == 0);
+ assert(std::stoll("-10") == -10);
+ assert(std::stoll(L"-10") == -10);
+ assert(std::stoll(" 10") == 10);
+ assert(std::stoll(L" 10") == 10);
+ size_t idx = 0;
+ assert(std::stoll("10g", &idx, 16) == 16);
+ assert(idx == 2);
+ idx = 0;
+ assert(std::stoll(L"10g", &idx, 16) == 16);
+ assert(idx == 2);
+ idx = 0;
+ try
+ {
+ std::stoll("", &idx);
+ assert(false);
+ }
+ catch (const std::invalid_argument&)
+ {
+ assert(idx == 0);
+ }
+ try
+ {
+ std::stoll(L"", &idx);
+ assert(false);
+ }
+ catch (const std::invalid_argument&)
+ {
+ assert(idx == 0);
+ }
+ try
+ {
+ std::stoll(" - 8", &idx);
+ assert(false);
+ }
+ catch (const std::invalid_argument&)
+ {
+ assert(idx == 0);
+ }
+ try
+ {
+ std::stoll(L" - 8", &idx);
+ assert(false);
+ }
+ catch (const std::invalid_argument&)
+ {
+ assert(idx == 0);
+ }
+ try
+ {
+ std::stoll("a1", &idx);
+ assert(false);
+ }
+ catch (const std::invalid_argument&)
+ {
+ assert(idx == 0);
+ }
+ try
+ {
+ std::stoll(L"a1", &idx);
+ assert(false);
+ }
+ catch (const std::invalid_argument&)
+ {
+ assert(idx == 0);
+ }
+ try
+ {
+ std::stoll("99999999999999999999999999", &idx);
+ assert(false);
+ }
+ catch (const std::out_of_range&)
+ {
+ assert(idx == 0);
+ }
+ try
+ {
+ std::stoll(L"99999999999999999999999999", &idx);
+ assert(false);
+ }
+ catch (const std::out_of_range&)
+ {
+ assert(idx == 0);
+ }
+}
diff --git a/test/std/strings/string.conversions/stoul.pass.cpp b/test/std/strings/string.conversions/stoul.pass.cpp
new file mode 100644
index 000000000000..37d33c4a9091
--- /dev/null
+++ b/test/std/strings/string.conversions/stoul.pass.cpp
@@ -0,0 +1,109 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11
+// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12
+
+// <string>
+
+// unsigned long stoul(const string& str, size_t *idx = 0, int base = 10);
+// unsigned long stoul(const wstring& str, size_t *idx = 0, int base = 10);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+ assert(std::stoul("0") == 0);
+ assert(std::stoul(L"0") == 0);
+ assert(std::stoul("-0") == 0);
+ assert(std::stoul(L"-0") == 0);
+ assert(std::stoul(" 10") == 10);
+ assert(std::stoul(L" 10") == 10);
+ size_t idx = 0;
+ assert(std::stoul("10g", &idx, 16) == 16);
+ assert(idx == 2);
+ idx = 0;
+ assert(std::stoul(L"10g", &idx, 16) == 16);
+ assert(idx == 2);
+ idx = 0;
+ try
+ {
+ std::stoul("", &idx);
+ assert(false);
+ }
+ catch (const std::invalid_argument&)
+ {
+ assert(idx == 0);
+ }
+ try
+ {
+ std::stoul(L"", &idx);
+ assert(false);
+ }
+ catch (const std::invalid_argument&)
+ {
+ assert(idx == 0);
+ }
+ try
+ {
+ std::stoul(" - 8", &idx);
+ assert(false);
+ }
+ catch (const std::invalid_argument&)
+ {
+ assert(idx == 0);
+ }
+ try
+ {
+ std::stoul(L" - 8", &idx);
+ assert(false);
+ }
+ catch (const std::invalid_argument&)
+ {
+ assert(idx == 0);
+ }
+ try
+ {
+ std::stoul("a1", &idx);
+ assert(false);
+ }
+ catch (const std::invalid_argument&)
+ {
+ assert(idx == 0);
+ }
+ try
+ {
+ std::stoul(L"a1", &idx);
+ assert(false);
+ }
+ catch (const std::invalid_argument&)
+ {
+ assert(idx == 0);
+ }
+// LWG issue #2009
+ try
+ {
+ std::stoul("9999999999999999999999999999999999999999999999999", &idx);
+ assert(false);
+ }
+ catch (const std::out_of_range&)
+ {
+ assert(idx == 0);
+ }
+ try
+ {
+ std::stoul(L"9999999999999999999999999999999999999999999999999", &idx);
+ assert(false);
+ }
+ catch (const std::out_of_range&)
+ {
+ assert(idx == 0);
+ }
+}
diff --git a/test/std/strings/string.conversions/stoull.pass.cpp b/test/std/strings/string.conversions/stoull.pass.cpp
new file mode 100644
index 000000000000..c0667edb385e
--- /dev/null
+++ b/test/std/strings/string.conversions/stoull.pass.cpp
@@ -0,0 +1,110 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11
+// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12
+
+// <string>
+
+// unsigned long long stoull(const string& str, size_t *idx = 0, int base = 10);
+// unsigned long long stoull(const wstring& str, size_t *idx = 0, int base = 10);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+ assert(std::stoull("0") == 0);
+ assert(std::stoull(L"0") == 0);
+ assert(std::stoull("-0") == 0);
+ assert(std::stoull(L"-0") == 0);
+ assert(std::stoull(" 10") == 10);
+ assert(std::stoull(L" 10") == 10);
+ size_t idx = 0;
+ assert(std::stoull("10g", &idx, 16) == 16);
+ assert(idx == 2);
+ idx = 0;
+ assert(std::stoull(L"10g", &idx, 16) == 16);
+ assert(idx == 2);
+ idx = 0;
+ try
+ {
+ std::stoull("", &idx);
+ assert(false);
+ }
+ catch (const std::invalid_argument&)
+ {
+ assert(idx == 0);
+ }
+ idx = 0;
+ try
+ {
+ std::stoull(L"", &idx);
+ assert(false);
+ }
+ catch (const std::invalid_argument&)
+ {
+ assert(idx == 0);
+ }
+ try
+ {
+ std::stoull(" - 8", &idx);
+ assert(false);
+ }
+ catch (const std::invalid_argument&)
+ {
+ assert(idx == 0);
+ }
+ try
+ {
+ std::stoull(L" - 8", &idx);
+ assert(false);
+ }
+ catch (const std::invalid_argument&)
+ {
+ assert(idx == 0);
+ }
+ try
+ {
+ std::stoull("a1", &idx);
+ assert(false);
+ }
+ catch (const std::invalid_argument&)
+ {
+ assert(idx == 0);
+ }
+ try
+ {
+ std::stoull(L"a1", &idx);
+ assert(false);
+ }
+ catch (const std::invalid_argument&)
+ {
+ assert(idx == 0);
+ }
+// LWG issue #2009
+ try
+ {
+ std::stoull("9999999999999999999999999999999999999999999999999", &idx);
+ assert(false);
+ }
+ catch (const std::out_of_range&)
+ {
+ assert(idx == 0);
+ }
+ try
+ {
+ std::stoull(L"9999999999999999999999999999999999999999999999999", &idx);
+ assert(false);
+ }
+ catch (const std::out_of_range&)
+ {
+ assert(idx == 0);
+ }
+}
diff --git a/test/std/strings/string.conversions/to_string.pass.cpp b/test/std/strings/string.conversions/to_string.pass.cpp
new file mode 100644
index 000000000000..05e5e4b922a5
--- /dev/null
+++ b/test/std/strings/string.conversions/to_string.pass.cpp
@@ -0,0 +1,126 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// string to_string(int val);
+// string to_string(unsigned val);
+// string to_string(long val);
+// string to_string(unsigned long val);
+// string to_string(long long val);
+// string to_string(unsigned long long val);
+// string to_string(float val);
+// string to_string(double val);
+// string to_string(long double val);
+
+#include <string>
+#include <cassert>
+#include <sstream>
+
+template <class T>
+void
+test_signed()
+{
+ {
+ std::string s = std::to_string(T(0));
+ assert(s.size() == 1);
+ assert(s[s.size()] == 0);
+ assert(s == "0");
+ }
+ {
+ std::string s = std::to_string(T(12345));
+ assert(s.size() == 5);
+ assert(s[s.size()] == 0);
+ assert(s == "12345");
+ }
+ {
+ std::string s = std::to_string(T(-12345));
+ assert(s.size() == 6);
+ assert(s[s.size()] == 0);
+ assert(s == "-12345");
+ }
+ {
+ std::string s = std::to_string(std::numeric_limits<T>::max());
+ assert(s.size() == std::numeric_limits<T>::digits10 + 1);
+ std::istringstream is(s);
+ T t(0);
+ is >> t;
+ assert(t == std::numeric_limits<T>::max());
+ }
+ {
+ std::string s = std::to_string(std::numeric_limits<T>::min());
+ std::istringstream is(s);
+ T t(0);
+ is >> t;
+ assert(t == std::numeric_limits<T>::min());
+ }
+}
+
+template <class T>
+void
+test_unsigned()
+{
+ {
+ std::string s = std::to_string(T(0));
+ assert(s.size() == 1);
+ assert(s[s.size()] == 0);
+ assert(s == "0");
+ }
+ {
+ std::string s = std::to_string(T(12345));
+ assert(s.size() == 5);
+ assert(s[s.size()] == 0);
+ assert(s == "12345");
+ }
+ {
+ std::string s = std::to_string(std::numeric_limits<T>::max());
+ assert(s.size() == std::numeric_limits<T>::digits10 + 1);
+ std::istringstream is(s);
+ T t(0);
+ is >> t;
+ assert(t == std::numeric_limits<T>::max());
+ }
+}
+
+template <class T>
+void
+test_float()
+{
+ {
+ std::string s = std::to_string(T(0));
+ assert(s.size() == 8);
+ assert(s[s.size()] == 0);
+ assert(s == "0.000000");
+ }
+ {
+ std::string s = std::to_string(T(12345));
+ assert(s.size() == 12);
+ assert(s[s.size()] == 0);
+ assert(s == "12345.000000");
+ }
+ {
+ std::string s = std::to_string(T(-12345));
+ assert(s.size() == 13);
+ assert(s[s.size()] == 0);
+ assert(s == "-12345.000000");
+ }
+}
+
+int main()
+{
+ test_signed<int>();
+ test_signed<long>();
+ test_signed<long long>();
+ test_unsigned<unsigned>();
+ test_unsigned<unsigned long>();
+ test_unsigned<unsigned long long>();
+ test_float<float>();
+ test_float<double>();
+ test_float<long double>();
+}
diff --git a/test/std/strings/string.conversions/to_wstring.pass.cpp b/test/std/strings/string.conversions/to_wstring.pass.cpp
new file mode 100644
index 000000000000..281aa1a5e79b
--- /dev/null
+++ b/test/std/strings/string.conversions/to_wstring.pass.cpp
@@ -0,0 +1,126 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// wstring to_wstring(int val);
+// wstring to_wstring(unsigned val);
+// wstring to_wstring(long val);
+// wstring to_wstring(unsigned long val);
+// wstring to_wstring(long long val);
+// wstring to_wstring(unsigned long long val);
+// wstring to_wstring(float val);
+// wstring to_wstring(double val);
+// wstring to_wstring(long double val);
+
+#include <string>
+#include <cassert>
+#include <sstream>
+
+template <class T>
+void
+test_signed()
+{
+ {
+ std::wstring s = std::to_wstring(T(0));
+ assert(s.size() == 1);
+ assert(s[s.size()] == 0);
+ assert(s == L"0");
+ }
+ {
+ std::wstring s = std::to_wstring(T(12345));
+ assert(s.size() == 5);
+ assert(s[s.size()] == 0);
+ assert(s == L"12345");
+ }
+ {
+ std::wstring s = std::to_wstring(T(-12345));
+ assert(s.size() == 6);
+ assert(s[s.size()] == 0);
+ assert(s == L"-12345");
+ }
+ {
+ std::wstring s = std::to_wstring(std::numeric_limits<T>::max());
+ assert(s.size() == std::numeric_limits<T>::digits10 + 1);
+ std::wistringstream is(s);
+ T t(0);
+ is >> t;
+ assert(t == std::numeric_limits<T>::max());
+ }
+ {
+ std::wstring s = std::to_wstring(std::numeric_limits<T>::min());
+ std::wistringstream is(s);
+ T t(0);
+ is >> t;
+ assert(t == std::numeric_limits<T>::min());
+ }
+}
+
+template <class T>
+void
+test_unsigned()
+{
+ {
+ std::wstring s = std::to_wstring(T(0));
+ assert(s.size() == 1);
+ assert(s[s.size()] == 0);
+ assert(s == L"0");
+ }
+ {
+ std::wstring s = std::to_wstring(T(12345));
+ assert(s.size() == 5);
+ assert(s[s.size()] == 0);
+ assert(s == L"12345");
+ }
+ {
+ std::wstring s = std::to_wstring(std::numeric_limits<T>::max());
+ assert(s.size() == std::numeric_limits<T>::digits10 + 1);
+ std::wistringstream is(s);
+ T t(0);
+ is >> t;
+ assert(t == std::numeric_limits<T>::max());
+ }
+}
+
+template <class T>
+void
+test_float()
+{
+ {
+ std::wstring s = std::to_wstring(T(0));
+ assert(s.size() == 8);
+ assert(s[s.size()] == 0);
+ assert(s == L"0.000000");
+ }
+ {
+ std::wstring s = std::to_wstring(T(12345));
+ assert(s.size() == 12);
+ assert(s[s.size()] == 0);
+ assert(s == L"12345.000000");
+ }
+ {
+ std::wstring s = std::to_wstring(T(-12345));
+ assert(s.size() == 13);
+ assert(s[s.size()] == 0);
+ assert(s == L"-12345.000000");
+ }
+}
+
+int main()
+{
+ test_signed<int>();
+ test_signed<long>();
+ test_signed<long long>();
+ test_unsigned<unsigned>();
+ test_unsigned<unsigned long>();
+ test_unsigned<unsigned long long>();
+ test_float<float>();
+ test_float<double>();
+ test_float<long double>();
+}
diff --git a/test/std/strings/strings.general/nothing_to_do.pass.cpp b/test/std/strings/strings.general/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..9a59227abdd9
--- /dev/null
+++ b/test/std/strings/strings.general/nothing_to_do.pass.cpp
@@ -0,0 +1,13 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/strings/version.pass.cpp b/test/std/strings/version.pass.cpp
new file mode 100644
index 000000000000..0c79c1af2ce8
--- /dev/null
+++ b/test/std/strings/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+#include <string>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/thread/futures/futures.async/async.pass.cpp b/test/std/thread/futures/futures.async/async.pass.cpp
new file mode 100644
index 000000000000..c8a742566d8f
--- /dev/null
+++ b/test/std/thread/futures/futures.async/async.pass.cpp
@@ -0,0 +1,198 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <future>
+
+// template <class F, class... Args>
+// future<typename result_of<F(Args...)>::type>
+// async(F&& f, Args&&... args);
+
+// template <class F, class... Args>
+// future<typename result_of<F(Args...)>::type>
+// async(launch policy, F&& f, Args&&... args);
+
+#include <future>
+#include <memory>
+#include <cassert>
+
+typedef std::chrono::high_resolution_clock Clock;
+typedef std::chrono::milliseconds ms;
+
+int f0()
+{
+ std::this_thread::sleep_for(ms(200));
+ return 3;
+}
+
+int i = 0;
+
+int& f1()
+{
+ std::this_thread::sleep_for(ms(200));
+ return i;
+}
+
+void f2()
+{
+ std::this_thread::sleep_for(ms(200));
+}
+
+std::unique_ptr<int> f3(int i)
+{
+ std::this_thread::sleep_for(ms(200));
+ return std::unique_ptr<int>(new int(i));
+}
+
+std::unique_ptr<int> f4(std::unique_ptr<int>&& p)
+{
+ std::this_thread::sleep_for(ms(200));
+ return std::move(p);
+}
+
+void f5(int i)
+{
+ std::this_thread::sleep_for(ms(200));
+ throw i;
+}
+
+int main()
+{
+ {
+ std::future<int> f = std::async(f0);
+ std::this_thread::sleep_for(ms(300));
+ Clock::time_point t0 = Clock::now();
+ assert(f.get() == 3);
+ Clock::time_point t1 = Clock::now();
+ assert(t1-t0 < ms(100));
+ }
+ {
+ std::future<int> f = std::async(std::launch::async, f0);
+ std::this_thread::sleep_for(ms(300));
+ Clock::time_point t0 = Clock::now();
+ assert(f.get() == 3);
+ Clock::time_point t1 = Clock::now();
+ assert(t1-t0 < ms(100));
+ }
+ {
+ std::future<int> f = std::async(std::launch::any, f0);
+ std::this_thread::sleep_for(ms(300));
+ Clock::time_point t0 = Clock::now();
+ assert(f.get() == 3);
+ Clock::time_point t1 = Clock::now();
+ assert(t1-t0 < ms(100));
+ }
+ {
+ std::future<int> f = std::async(std::launch::deferred, f0);
+ std::this_thread::sleep_for(ms(300));
+ Clock::time_point t0 = Clock::now();
+ assert(f.get() == 3);
+ Clock::time_point t1 = Clock::now();
+ assert(t1-t0 > ms(100));
+ }
+
+ {
+ std::future<int&> f = std::async(f1);
+ std::this_thread::sleep_for(ms(300));
+ Clock::time_point t0 = Clock::now();
+ assert(&f.get() == &i);
+ Clock::time_point t1 = Clock::now();
+ assert(t1-t0 < ms(100));
+ }
+ {
+ std::future<int&> f = std::async(std::launch::async, f1);
+ std::this_thread::sleep_for(ms(300));
+ Clock::time_point t0 = Clock::now();
+ assert(&f.get() == &i);
+ Clock::time_point t1 = Clock::now();
+ assert(t1-t0 < ms(100));
+ }
+ {
+ std::future<int&> f = std::async(std::launch::any, f1);
+ std::this_thread::sleep_for(ms(300));
+ Clock::time_point t0 = Clock::now();
+ assert(&f.get() == &i);
+ Clock::time_point t1 = Clock::now();
+ assert(t1-t0 < ms(100));
+ }
+ {
+ std::future<int&> f = std::async(std::launch::deferred, f1);
+ std::this_thread::sleep_for(ms(300));
+ Clock::time_point t0 = Clock::now();
+ assert(&f.get() == &i);
+ Clock::time_point t1 = Clock::now();
+ assert(t1-t0 > ms(100));
+ }
+
+ {
+ std::future<void> f = std::async(f2);
+ std::this_thread::sleep_for(ms(300));
+ Clock::time_point t0 = Clock::now();
+ f.get();
+ Clock::time_point t1 = Clock::now();
+ assert(t1-t0 < ms(100));
+ }
+ {
+ std::future<void> f = std::async(std::launch::async, f2);
+ std::this_thread::sleep_for(ms(300));
+ Clock::time_point t0 = Clock::now();
+ f.get();
+ Clock::time_point t1 = Clock::now();
+ assert(t1-t0 < ms(100));
+ }
+ {
+ std::future<void> f = std::async(std::launch::any, f2);
+ std::this_thread::sleep_for(ms(300));
+ Clock::time_point t0 = Clock::now();
+ f.get();
+ Clock::time_point t1 = Clock::now();
+ assert(t1-t0 < ms(100));
+ }
+ {
+ std::future<void> f = std::async(std::launch::deferred, f2);
+ std::this_thread::sleep_for(ms(300));
+ Clock::time_point t0 = Clock::now();
+ f.get();
+ Clock::time_point t1 = Clock::now();
+ assert(t1-t0 > ms(100));
+ }
+
+ {
+ std::future<std::unique_ptr<int>> f = std::async(f3, 3);
+ std::this_thread::sleep_for(ms(300));
+ Clock::time_point t0 = Clock::now();
+ assert(*f.get() == 3);
+ Clock::time_point t1 = Clock::now();
+ assert(t1-t0 < ms(100));
+ }
+
+ {
+ std::future<std::unique_ptr<int>> f =
+ std::async(f4, std::unique_ptr<int>(new int(3)));
+ std::this_thread::sleep_for(ms(300));
+ Clock::time_point t0 = Clock::now();
+ assert(*f.get() == 3);
+ Clock::time_point t1 = Clock::now();
+ assert(t1-t0 < ms(100));
+ }
+
+ {
+ std::future<void> f = std::async(f5, 3);
+ std::this_thread::sleep_for(ms(300));
+ try { f.get(); assert (false); } catch ( int ex ) {}
+ }
+
+ {
+ std::future<void> f = std::async(std::launch::deferred, f5, 3);
+ std::this_thread::sleep_for(ms(300));
+ try { f.get(); assert (false); } catch ( int ex ) {}
+ }
+
+}
diff --git a/test/std/thread/futures/futures.async/async_race.pass.cpp b/test/std/thread/futures/futures.async/async_race.pass.cpp
new file mode 100644
index 000000000000..325a027132de
--- /dev/null
+++ b/test/std/thread/futures/futures.async/async_race.pass.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <future>
+
+// template <class F, class... Args>
+// future<typename result_of<F(Args...)>::type>
+// async(F&& f, Args&&... args);
+
+// template <class F, class... Args>
+// future<typename result_of<F(Args...)>::type>
+// async(launch policy, F&& f, Args&&... args);
+
+// This test is designed to cause and allow TSAN to detect the race condition
+// reported in PR23293. (http://llvm.org/PR23293).
+
+#include <future>
+#include <chrono>
+#include <thread>
+#include <memory>
+#include <cassert>
+
+int f_async() {
+ typedef std::chrono::milliseconds ms;
+ std::this_thread::sleep_for(ms(200));
+ return 42;
+}
+
+bool ran = false;
+
+int f_deferred() {
+ ran = true;
+ return 42;
+}
+
+void test_each() {
+ {
+ std::future<int> f = std::async(f_async);
+ int const result = f.get();
+ assert(result == 42);
+ }
+ {
+ std::future<int> f = std::async(std::launch::async, f_async);
+ int const result = f.get();
+ assert(result == 42);
+ }
+ {
+ ran = false;
+ std::future<int> f = std::async(std::launch::deferred, f_deferred);
+ assert(ran == false);
+ int const result = f.get();
+ assert(ran == true);
+ assert(result == 42);
+ }
+}
+
+int main() {
+ for (int i=0; i < 25; ++i) test_each();
+}
diff --git a/test/std/thread/futures/futures.errors/default_error_condition.pass.cpp b/test/std/thread/futures/futures.errors/default_error_condition.pass.cpp
new file mode 100644
index 000000000000..7f28b8a23b81
--- /dev/null
+++ b/test/std/thread/futures/futures.errors/default_error_condition.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <future>
+
+// const error_category& future_category();
+
+// virtual error_condition default_error_condition(int ev) const;
+
+#include <future>
+#include <cassert>
+
+int main()
+{
+ const std::error_category& e_cat = std::future_category();
+ std::error_condition e_cond = e_cat.default_error_condition(static_cast<int>(std::errc::not_a_directory));
+ assert(e_cond.category() == e_cat);
+ assert(e_cond.value() == static_cast<int>(std::errc::not_a_directory));
+}
diff --git a/test/std/thread/futures/futures.errors/equivalent_error_code_int.pass.cpp b/test/std/thread/futures/futures.errors/equivalent_error_code_int.pass.cpp
new file mode 100644
index 000000000000..cd0017657740
--- /dev/null
+++ b/test/std/thread/futures/futures.errors/equivalent_error_code_int.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <future>
+
+// const error_category& future_category();
+
+// virtual bool equivalent(const error_code& code, int condition) const;
+
+#include <future>
+#include <cassert>
+
+int main()
+{
+ const std::error_category& e_cat = std::future_category();
+ assert(e_cat.equivalent(std::error_code(5, e_cat), 5));
+ assert(!e_cat.equivalent(std::error_code(5, e_cat), 6));
+}
diff --git a/test/std/thread/futures/futures.errors/equivalent_int_error_condition.pass.cpp b/test/std/thread/futures/futures.errors/equivalent_int_error_condition.pass.cpp
new file mode 100644
index 000000000000..05ad1ec9c6f5
--- /dev/null
+++ b/test/std/thread/futures/futures.errors/equivalent_int_error_condition.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <future>
+
+// const error_category& future_category();
+
+// virtual bool equivalent(int code, const error_condition& condition) const;
+
+#include <future>
+#include <cassert>
+
+int main()
+{
+ const std::error_category& e_cat = std::future_category();
+ std::error_condition e_cond = e_cat.default_error_condition(5);
+ assert(e_cat.equivalent(5, e_cond));
+ assert(!e_cat.equivalent(6, e_cond));
+}
diff --git a/test/std/thread/futures/futures.errors/future_category.pass.cpp b/test/std/thread/futures/futures.errors/future_category.pass.cpp
new file mode 100644
index 000000000000..7f407a061d95
--- /dev/null
+++ b/test/std/thread/futures/futures.errors/future_category.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <future>
+
+// const error_category& future_category();
+
+#include <future>
+#include <cstring>
+#include <cassert>
+
+int main()
+{
+ const std::error_category& ec = std::future_category();
+ assert(std::strcmp(ec.name(), "future") == 0);
+}
diff --git a/test/std/thread/futures/futures.errors/make_error_code.pass.cpp b/test/std/thread/futures/futures.errors/make_error_code.pass.cpp
new file mode 100644
index 000000000000..3c14addf309f
--- /dev/null
+++ b/test/std/thread/futures/futures.errors/make_error_code.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <future>
+
+// class error_code
+
+// error_code make_error_code(future_errc e);
+
+#include <future>
+#include <cassert>
+
+int main()
+{
+ {
+ std::error_code ec = make_error_code(std::future_errc::broken_promise);
+ assert(ec.value() == static_cast<int>(std::future_errc::broken_promise));
+ assert(ec.category() == std::future_category());
+ }
+}
diff --git a/test/std/thread/futures/futures.errors/make_error_condition.pass.cpp b/test/std/thread/futures/futures.errors/make_error_condition.pass.cpp
new file mode 100644
index 000000000000..52972aa373f5
--- /dev/null
+++ b/test/std/thread/futures/futures.errors/make_error_condition.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <future>
+
+// class error_condition
+
+// error_condition make_error_condition(future_errc e);
+
+#include <future>
+#include <cassert>
+
+int main()
+{
+ {
+ const std::error_condition ec1 =
+ std::make_error_condition(std::future_errc::future_already_retrieved);
+ assert(ec1.value() ==
+ static_cast<int>(std::future_errc::future_already_retrieved));
+ assert(ec1.category() == std::future_category());
+ }
+}
diff --git a/test/std/thread/futures/futures.future_error/code.pass.cpp b/test/std/thread/futures/futures.future_error/code.pass.cpp
new file mode 100644
index 000000000000..e02af486fc39
--- /dev/null
+++ b/test/std/thread/futures/futures.future_error/code.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <future>
+
+// class future_error
+
+// const error_code& code() const throw();
+
+#include <future>
+#include <cassert>
+
+int main()
+{
+ {
+ std::error_code ec = std::make_error_code(std::future_errc::broken_promise);
+ std::future_error f(ec);
+ assert(f.code() == ec);
+ }
+ {
+ std::error_code ec = std::make_error_code(std::future_errc::future_already_retrieved);
+ std::future_error f(ec);
+ assert(f.code() == ec);
+ }
+ {
+ std::error_code ec = std::make_error_code(std::future_errc::promise_already_satisfied);
+ std::future_error f(ec);
+ assert(f.code() == ec);
+ }
+ {
+ std::error_code ec = std::make_error_code(std::future_errc::no_state);
+ std::future_error f(ec);
+ assert(f.code() == ec);
+ }
+}
diff --git a/test/std/thread/futures/futures.future_error/types.pass.cpp b/test/std/thread/futures/futures.future_error/types.pass.cpp
new file mode 100644
index 000000000000..e741dd06e4b9
--- /dev/null
+++ b/test/std/thread/futures/futures.future_error/types.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <future>
+
+// class future_error : public logic_error {...};
+
+#include <future>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_convertible<std::future_error*,
+ std::logic_error*>::value), "");
+}
diff --git a/test/std/thread/futures/futures.future_error/what.pass.cpp b/test/std/thread/futures/futures.future_error/what.pass.cpp
new file mode 100644
index 000000000000..52d2e944a684
--- /dev/null
+++ b/test/std/thread/futures/futures.future_error/what.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// LWG 2056 changed the values of future_errc, so if we're using new headers
+// with an old library we'll get incorrect messages.
+//
+// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11
+// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12
+// XFAIL: with_system_cxx_lib=x86_64-apple-darwin13
+
+// <future>
+
+// class future_error
+
+// const char* what() const throw();
+
+#include <future>
+#include <cstring>
+#include <cassert>
+
+int main()
+{
+ {
+ std::future_error f(std::make_error_code(std::future_errc::broken_promise));
+ assert(std::strcmp(f.what(), "The associated promise has been destructed prior "
+ "to the associated state becoming ready.") == 0);
+ }
+ {
+ std::future_error f(std::make_error_code(std::future_errc::future_already_retrieved));
+ assert(std::strcmp(f.what(), "The future has already been retrieved from "
+ "the promise or packaged_task.") == 0);
+ }
+ {
+ std::future_error f(std::make_error_code(std::future_errc::promise_already_satisfied));
+ assert(std::strcmp(f.what(), "The state of the promise has already been set.") == 0);
+ }
+ {
+ std::future_error f(std::make_error_code(std::future_errc::no_state));
+ assert(std::strcmp(f.what(), "Operation not permitted on an object without "
+ "an associated state.") == 0);
+ }
+}
diff --git a/test/std/thread/futures/futures.overview/future_errc.pass.cpp b/test/std/thread/futures/futures.overview/future_errc.pass.cpp
new file mode 100644
index 000000000000..1e6fcb76a0e7
--- /dev/null
+++ b/test/std/thread/futures/futures.overview/future_errc.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <future>
+
+// enum class future_errc
+// {
+// future_already_retrieved = 1,
+// promise_already_satisfied,
+// no_state
+// broken_promise,
+// };
+
+#include <future>
+
+int main()
+{
+ static_assert(static_cast<int>(std::future_errc::future_already_retrieved) == 1, "");
+ static_assert(static_cast<int>(std::future_errc::promise_already_satisfied) == 2, "");
+ static_assert(static_cast<int>(std::future_errc::no_state) == 3, "");
+ static_assert(static_cast<int>(std::future_errc::broken_promise) == 4, "");
+}
diff --git a/test/std/thread/futures/futures.overview/future_status.pass.cpp b/test/std/thread/futures/futures.overview/future_status.pass.cpp
new file mode 100644
index 000000000000..2c196aaac56d
--- /dev/null
+++ b/test/std/thread/futures/futures.overview/future_status.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <future>
+
+// enum class future_status
+// {
+// ready,
+// timeout,
+// deferred
+// };
+
+#include <future>
+
+int main()
+{
+ static_assert(static_cast<int>(std::future_status::ready) == 0, "");
+ static_assert(static_cast<int>(std::future_status::timeout) == 1, "");
+ static_assert(static_cast<int>(std::future_status::deferred) == 2, "");
+}
diff --git a/test/std/thread/futures/futures.overview/is_error_code_enum_future_errc.pass.cpp b/test/std/thread/futures/futures.overview/is_error_code_enum_future_errc.pass.cpp
new file mode 100644
index 000000000000..499de52598b6
--- /dev/null
+++ b/test/std/thread/futures/futures.overview/is_error_code_enum_future_errc.pass.cpp
@@ -0,0 +1,21 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <future>
+
+// template <> struct is_error_code_enum<future_errc> : public true_type {};
+
+#include <future>
+
+int main()
+{
+ static_assert(std::is_error_code_enum<std::future_errc>::value, "");
+}
diff --git a/test/std/thread/futures/futures.overview/launch.pass.cpp b/test/std/thread/futures/futures.overview/launch.pass.cpp
new file mode 100644
index 000000000000..da54f7ee6732
--- /dev/null
+++ b/test/std/thread/futures/futures.overview/launch.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <future>
+
+// enum class launch
+// {
+// async = 1,
+// deferred = 2,
+// any = async | deferred
+// };
+
+#include <future>
+#include <cassert>
+
+int main()
+{
+#ifdef _LIBCPP_HAS_NO_STRONG_ENUMS
+ static_assert(static_cast<int>(std::launch::any) ==
+ (static_cast<int>(std::launch::async) | static_cast<int>(std::launch::deferred)), "");
+#else
+ static_assert(std::launch::any == (std::launch::async | std::launch::deferred), "");
+ static_assert(std::launch(0) == (std::launch::async & std::launch::deferred), "");
+ static_assert(std::launch::any == (std::launch::async ^ std::launch::deferred), "");
+ static_assert(std::launch::deferred == ~std::launch::async, "");
+ std::launch x = std::launch::async;
+ x &= std::launch::deferred;
+ assert(x == std::launch(0));
+ x = std::launch::async;
+ x |= std::launch::deferred;
+ assert(x == std::launch::any);
+ x ^= std::launch::deferred;
+ assert(x == std::launch::async);
+#endif
+ static_assert(static_cast<int>(std::launch::async) == 1, "");
+ static_assert(static_cast<int>(std::launch::deferred) == 2, "");
+}
diff --git a/test/std/thread/futures/futures.promise/alloc_ctor.pass.cpp b/test/std/thread/futures/futures.promise/alloc_ctor.pass.cpp
new file mode 100644
index 000000000000..70a4e00b0d6a
--- /dev/null
+++ b/test/std/thread/futures/futures.promise/alloc_ctor.pass.cpp
@@ -0,0 +1,84 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <future>
+
+// class promise<R>
+
+// template <class Allocator>
+// promise(allocator_arg_t, const Allocator& a);
+
+#include <future>
+#include <cassert>
+
+#include "../test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ assert(test_alloc_base::count == 0);
+ {
+ std::promise<int> p(std::allocator_arg, test_allocator<int>());
+ assert(test_alloc_base::count == 1);
+ std::future<int> f = p.get_future();
+ assert(test_alloc_base::count == 1);
+ assert(f.valid());
+ }
+ assert(test_alloc_base::count == 0);
+ {
+ std::promise<int&> p(std::allocator_arg, test_allocator<int>());
+ assert(test_alloc_base::count == 1);
+ std::future<int&> f = p.get_future();
+ assert(test_alloc_base::count == 1);
+ assert(f.valid());
+ }
+ assert(test_alloc_base::count == 0);
+ {
+ std::promise<void> p(std::allocator_arg, test_allocator<void>());
+ assert(test_alloc_base::count == 1);
+ std::future<void> f = p.get_future();
+ assert(test_alloc_base::count == 1);
+ assert(f.valid());
+ }
+ assert(test_alloc_base::count == 0);
+ // Test with a minimal allocator
+ {
+ std::promise<int> p(std::allocator_arg, bare_allocator<void>());
+ std::future<int> f = p.get_future();
+ assert(f.valid());
+ }
+ {
+ std::promise<int&> p(std::allocator_arg, bare_allocator<void>());
+ std::future<int&> f = p.get_future();
+ assert(f.valid());
+ }
+ {
+ std::promise<void> p(std::allocator_arg, bare_allocator<void>());
+ std::future<void> f = p.get_future();
+ assert(f.valid());
+ }
+ // Test with a minimal allocator that returns class-type pointers
+ {
+ std::promise<int> p(std::allocator_arg, min_allocator<void>());
+ std::future<int> f = p.get_future();
+ assert(f.valid());
+ }
+ {
+ std::promise<int&> p(std::allocator_arg, min_allocator<void>());
+ std::future<int&> f = p.get_future();
+ assert(f.valid());
+ }
+ {
+ std::promise<void> p(std::allocator_arg, min_allocator<void>());
+ std::future<void> f = p.get_future();
+ assert(f.valid());
+ }
+}
diff --git a/test/std/thread/futures/futures.promise/copy_assign.fail.cpp b/test/std/thread/futures/futures.promise/copy_assign.fail.cpp
new file mode 100644
index 000000000000..c08278122225
--- /dev/null
+++ b/test/std/thread/futures/futures.promise/copy_assign.fail.cpp
@@ -0,0 +1,87 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+// class promise<R>
+
+// promise& operator=(const promise& rhs) = delete;
+
+#include <future>
+#include <cassert>
+
+#include "../test_allocator.h"
+
+int main()
+{
+ assert(test_alloc_base::count == 0);
+ {
+ std::promise<int> p0(std::allocator_arg, test_allocator<int>());
+ std::promise<int> p(std::allocator_arg, test_allocator<int>());
+ assert(test_alloc_base::count == 2);
+ p = p0;
+ assert(test_alloc_base::count == 1);
+ std::future<int> f = p.get_future();
+ assert(test_alloc_base::count == 1);
+ assert(f.valid());
+ try
+ {
+ f = p0.get_future();
+ assert(false);
+ }
+ catch (const std::future_error& e)
+ {
+ assert(e.code() == make_error_code(std::future_errc::no_state));
+ }
+ assert(test_alloc_base::count == 1);
+ }
+ assert(test_alloc_base::count == 0);
+ {
+ std::promise<int&> p0(std::allocator_arg, test_allocator<int>());
+ std::promise<int&> p(std::allocator_arg, test_allocator<int>());
+ assert(test_alloc_base::count == 2);
+ p = p0;
+ assert(test_alloc_base::count == 1);
+ std::future<int&> f = p.get_future();
+ assert(test_alloc_base::count == 1);
+ assert(f.valid());
+ try
+ {
+ f = p0.get_future();
+ assert(false);
+ }
+ catch (const std::future_error& e)
+ {
+ assert(e.code() == make_error_code(std::future_errc::no_state));
+ }
+ assert(test_alloc_base::count == 1);
+ }
+ assert(test_alloc_base::count == 0);
+ {
+ std::promise<void> p0(std::allocator_arg, test_allocator<void>());
+ std::promise<void> p(std::allocator_arg, test_allocator<void>());
+ assert(test_alloc_base::count == 2);
+ p = p0;
+ assert(test_alloc_base::count == 1);
+ std::future<void> f = p.get_future();
+ assert(test_alloc_base::count == 1);
+ assert(f.valid());
+ try
+ {
+ f = p0.get_future();
+ assert(false);
+ }
+ catch (const std::future_error& e)
+ {
+ assert(e.code() == make_error_code(std::future_errc::no_state));
+ }
+ assert(test_alloc_base::count == 1);
+ }
+ assert(test_alloc_base::count == 0);
+}
diff --git a/test/std/thread/futures/futures.promise/copy_ctor.fail.cpp b/test/std/thread/futures/futures.promise/copy_ctor.fail.cpp
new file mode 100644
index 000000000000..36a3555aed46
--- /dev/null
+++ b/test/std/thread/futures/futures.promise/copy_ctor.fail.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+// class promise<R>
+
+// promise(const promise&) = delete;
+
+#include <future>
+#include <cassert>
+
+#include "../test_allocator.h"
+
+int main()
+{
+ assert(test_alloc_base::count == 0);
+ {
+ std::promise<int> p0(std::allocator_arg, test_allocator<int>());
+ std::promise<int> p(p0);
+ assert(test_alloc_base::count == 1);
+ std::future<int> f = p.get_future();
+ assert(test_alloc_base::count == 1);
+ assert(f.valid());
+ try
+ {
+ f = p0.get_future();
+ assert(false);
+ }
+ catch (const std::future_error& e)
+ {
+ assert(e.code() == make_error_code(std::future_errc::no_state));
+ }
+ assert(test_alloc_base::count == 1);
+ }
+ assert(test_alloc_base::count == 0);
+ {
+ std::promise<int&> p0(std::allocator_arg, test_allocator<int>());
+ std::promise<int&> p(p0);
+ assert(test_alloc_base::count == 1);
+ std::future<int&> f = p.get_future();
+ assert(test_alloc_base::count == 1);
+ assert(f.valid());
+ try
+ {
+ f = p0.get_future();
+ assert(false);
+ }
+ catch (const std::future_error& e)
+ {
+ assert(e.code() == make_error_code(std::future_errc::no_state));
+ }
+ assert(test_alloc_base::count == 1);
+ }
+ assert(test_alloc_base::count == 0);
+ {
+ std::promise<void> p0(std::allocator_arg, test_allocator<void>());
+ std::promise<void> p(p0);
+ assert(test_alloc_base::count == 1);
+ std::future<void> f = p.get_future();
+ assert(test_alloc_base::count == 1);
+ assert(f.valid());
+ try
+ {
+ f = p0.get_future();
+ assert(false);
+ }
+ catch (const std::future_error& e)
+ {
+ assert(e.code() == make_error_code(std::future_errc::no_state));
+ }
+ assert(test_alloc_base::count == 1);
+ }
+ assert(test_alloc_base::count == 0);
+}
diff --git a/test/std/thread/futures/futures.promise/default.pass.cpp b/test/std/thread/futures/futures.promise/default.pass.cpp
new file mode 100644
index 000000000000..95c9657c633e
--- /dev/null
+++ b/test/std/thread/futures/futures.promise/default.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <future>
+
+// class promise<R>
+
+// promise();
+
+#include <future>
+#include <cassert>
+
+int main()
+{
+ {
+ std::promise<int> p;
+ std::future<int> f = p.get_future();
+ assert(f.valid());
+ }
+ {
+ std::promise<int&> p;
+ std::future<int&> f = p.get_future();
+ assert(f.valid());
+ }
+ {
+ std::promise<void> p;
+ std::future<void> f = p.get_future();
+ assert(f.valid());
+ }
+}
diff --git a/test/std/thread/futures/futures.promise/dtor.pass.cpp b/test/std/thread/futures/futures.promise/dtor.pass.cpp
new file mode 100644
index 000000000000..78912f12adb9
--- /dev/null
+++ b/test/std/thread/futures/futures.promise/dtor.pass.cpp
@@ -0,0 +1,116 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <future>
+
+// class promise<R>
+
+// ~promise();
+
+#include <future>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ std::future<T> f;
+ {
+ std::promise<T> p;
+ f = p.get_future();
+ p.set_value(3);
+ }
+ assert(f.get() == 3);
+ }
+ {
+ typedef int T;
+ std::future<T> f;
+ {
+ std::promise<T> p;
+ f = p.get_future();
+ }
+ try
+ {
+ T i = f.get();
+ assert(false);
+ }
+ catch (const std::future_error& e)
+ {
+ assert(e.code() == make_error_code(std::future_errc::broken_promise));
+ }
+ }
+
+ {
+ typedef int& T;
+ int i = 4;
+ std::future<T> f;
+ {
+ std::promise<T> p;
+ f = p.get_future();
+ p.set_value(i);
+ }
+ assert(&f.get() == &i);
+ }
+ {
+ typedef int& T;
+ std::future<T> f;
+ {
+ std::promise<T> p;
+ f = p.get_future();
+ }
+ try
+ {
+ T i = f.get();
+ assert(false);
+ }
+ catch (const std::future_error& e)
+ {
+ assert(e.code() == make_error_code(std::future_errc::broken_promise));
+ }
+ }
+
+ {
+ typedef void T;
+ std::future<T> f;
+ {
+ std::promise<T> p;
+ f = p.get_future();
+ p.set_value();
+ }
+ f.get();
+ assert(true);
+ }
+ {
+ typedef void T;
+ std::future<T> f;
+ {
+ std::promise<T> p;
+ f = p.get_future();
+ }
+ try
+ {
+ f.get();
+ assert(false);
+ }
+ catch (const std::future_error& e)
+ {
+ // LWG 2056 changed the values of future_errc, so if we're using new
+ // headers with an old library the error codes won't line up.
+ //
+ // Note that this particular check only applies to promise<void>
+ // since the other specializations happen to be implemented in the
+ // header rather than the library.
+ assert(
+ e.code() == make_error_code(std::future_errc::broken_promise) ||
+ e.code() == std::error_code(0, std::future_category()));
+ }
+ }
+}
diff --git a/test/std/thread/futures/futures.promise/get_future.pass.cpp b/test/std/thread/futures/futures.promise/get_future.pass.cpp
new file mode 100644
index 000000000000..a7d084ee7873
--- /dev/null
+++ b/test/std/thread/futures/futures.promise/get_future.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <future>
+
+// class promise<R>
+
+// future<R> get_future();
+
+#include <future>
+#include <cassert>
+
+int main()
+{
+ {
+ std::promise<double> p;
+ std::future<double> f = p.get_future();
+ p.set_value(105.5);
+ assert(f.get() == 105.5);
+ }
+ {
+ std::promise<double> p;
+ std::future<double> f = p.get_future();
+ try
+ {
+ f = p.get_future();
+ assert(false);
+ }
+ catch (const std::future_error& e)
+ {
+ assert(e.code() == make_error_code(std::future_errc::future_already_retrieved));
+ }
+ }
+ {
+ std::promise<double> p;
+ std::promise<double> p0 = std::move(p);
+ try
+ {
+ std::future<double> f = p.get_future();
+ assert(false);
+ }
+ catch (const std::future_error& e)
+ {
+ assert(e.code() == make_error_code(std::future_errc::no_state));
+ }
+ }
+}
diff --git a/test/std/thread/futures/futures.promise/move_assign.pass.cpp b/test/std/thread/futures/futures.promise/move_assign.pass.cpp
new file mode 100644
index 000000000000..c3097df74990
--- /dev/null
+++ b/test/std/thread/futures/futures.promise/move_assign.pass.cpp
@@ -0,0 +1,91 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <future>
+
+// class promise<R>
+
+// promise& operator=(promise&& rhs);
+
+#include <future>
+#include <cassert>
+
+#include "../test_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ assert(test_alloc_base::count == 0);
+ {
+ std::promise<int> p0(std::allocator_arg, test_allocator<int>());
+ std::promise<int> p(std::allocator_arg, test_allocator<int>());
+ assert(test_alloc_base::count == 2);
+ p = std::move(p0);
+ assert(test_alloc_base::count == 1);
+ std::future<int> f = p.get_future();
+ assert(test_alloc_base::count == 1);
+ assert(f.valid());
+ try
+ {
+ f = p0.get_future();
+ assert(false);
+ }
+ catch (const std::future_error& e)
+ {
+ assert(e.code() == make_error_code(std::future_errc::no_state));
+ }
+ assert(test_alloc_base::count == 1);
+ }
+ assert(test_alloc_base::count == 0);
+ {
+ std::promise<int&> p0(std::allocator_arg, test_allocator<int>());
+ std::promise<int&> p(std::allocator_arg, test_allocator<int>());
+ assert(test_alloc_base::count == 2);
+ p = std::move(p0);
+ assert(test_alloc_base::count == 1);
+ std::future<int&> f = p.get_future();
+ assert(test_alloc_base::count == 1);
+ assert(f.valid());
+ try
+ {
+ f = p0.get_future();
+ assert(false);
+ }
+ catch (const std::future_error& e)
+ {
+ assert(e.code() == make_error_code(std::future_errc::no_state));
+ }
+ assert(test_alloc_base::count == 1);
+ }
+ assert(test_alloc_base::count == 0);
+ {
+ std::promise<void> p0(std::allocator_arg, test_allocator<void>());
+ std::promise<void> p(std::allocator_arg, test_allocator<void>());
+ assert(test_alloc_base::count == 2);
+ p = std::move(p0);
+ assert(test_alloc_base::count == 1);
+ std::future<void> f = p.get_future();
+ assert(test_alloc_base::count == 1);
+ assert(f.valid());
+ try
+ {
+ f = p0.get_future();
+ assert(false);
+ }
+ catch (const std::future_error& e)
+ {
+ assert(e.code() == make_error_code(std::future_errc::no_state));
+ }
+ assert(test_alloc_base::count == 1);
+ }
+ assert(test_alloc_base::count == 0);
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/thread/futures/futures.promise/move_ctor.pass.cpp b/test/std/thread/futures/futures.promise/move_ctor.pass.cpp
new file mode 100644
index 000000000000..eeec4fb15b95
--- /dev/null
+++ b/test/std/thread/futures/futures.promise/move_ctor.pass.cpp
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <future>
+
+// class promise<R>
+
+// promise(promise&& rhs);
+
+#include <future>
+#include <cassert>
+
+#include "../test_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ assert(test_alloc_base::count == 0);
+ {
+ std::promise<int> p0(std::allocator_arg, test_allocator<int>());
+ std::promise<int> p(std::move(p0));
+ assert(test_alloc_base::count == 1);
+ std::future<int> f = p.get_future();
+ assert(test_alloc_base::count == 1);
+ assert(f.valid());
+ try
+ {
+ f = p0.get_future();
+ assert(false);
+ }
+ catch (const std::future_error& e)
+ {
+ assert(e.code() == make_error_code(std::future_errc::no_state));
+ }
+ assert(test_alloc_base::count == 1);
+ }
+ assert(test_alloc_base::count == 0);
+ {
+ std::promise<int&> p0(std::allocator_arg, test_allocator<int>());
+ std::promise<int&> p(std::move(p0));
+ assert(test_alloc_base::count == 1);
+ std::future<int&> f = p.get_future();
+ assert(test_alloc_base::count == 1);
+ assert(f.valid());
+ try
+ {
+ f = p0.get_future();
+ assert(false);
+ }
+ catch (const std::future_error& e)
+ {
+ assert(e.code() == make_error_code(std::future_errc::no_state));
+ }
+ assert(test_alloc_base::count == 1);
+ }
+ assert(test_alloc_base::count == 0);
+ {
+ std::promise<void> p0(std::allocator_arg, test_allocator<void>());
+ std::promise<void> p(std::move(p0));
+ assert(test_alloc_base::count == 1);
+ std::future<void> f = p.get_future();
+ assert(test_alloc_base::count == 1);
+ assert(f.valid());
+ try
+ {
+ f = p0.get_future();
+ assert(false);
+ }
+ catch (const std::future_error& e)
+ {
+ assert(e.code() == make_error_code(std::future_errc::no_state));
+ }
+ assert(test_alloc_base::count == 1);
+ }
+ assert(test_alloc_base::count == 0);
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/thread/futures/futures.promise/set_exception.pass.cpp b/test/std/thread/futures/futures.promise/set_exception.pass.cpp
new file mode 100644
index 000000000000..51c05eb803cb
--- /dev/null
+++ b/test/std/thread/futures/futures.promise/set_exception.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <future>
+
+// class promise<R>
+
+// void set_exception(exception_ptr p);
+
+#include <future>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ std::promise<T> p;
+ std::future<T> f = p.get_future();
+ p.set_exception(std::make_exception_ptr(3));
+ try
+ {
+ f.get();
+ assert(false);
+ }
+ catch (int i)
+ {
+ assert(i == 3);
+ }
+ try
+ {
+ p.set_exception(std::make_exception_ptr(3));
+ assert(false);
+ }
+ catch (const std::future_error& e)
+ {
+ assert(e.code() == make_error_code(std::future_errc::promise_already_satisfied));
+ }
+ }
+}
diff --git a/test/std/thread/futures/futures.promise/set_exception_at_thread_exit.pass.cpp b/test/std/thread/futures/futures.promise/set_exception_at_thread_exit.pass.cpp
new file mode 100644
index 000000000000..5e57692563d8
--- /dev/null
+++ b/test/std/thread/futures/futures.promise/set_exception_at_thread_exit.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <future>
+
+// class promise<R>
+
+// void promise::set_exception_at_thread_exit(exception_ptr p);
+
+#include <future>
+#include <cassert>
+
+void func(std::promise<int> p)
+{
+ const int i = 5;
+ p.set_exception_at_thread_exit(std::make_exception_ptr(3));
+}
+
+int main()
+{
+ {
+ typedef int T;
+ std::promise<T> p;
+ std::future<T> f = p.get_future();
+ std::thread(func, std::move(p)).detach();
+ try
+ {
+ f.get();
+ assert(false);
+ }
+ catch (int i)
+ {
+ assert(i == 3);
+ }
+ }
+}
diff --git a/test/std/thread/futures/futures.promise/set_lvalue.pass.cpp b/test/std/thread/futures/futures.promise/set_lvalue.pass.cpp
new file mode 100644
index 000000000000..cdc37775012c
--- /dev/null
+++ b/test/std/thread/futures/futures.promise/set_lvalue.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <future>
+
+// class promise<R>
+
+// void promise<R&>::set_value(R& r);
+
+#include <future>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int& T;
+ int i = 3;
+ std::promise<T> p;
+ std::future<T> f = p.get_future();
+ p.set_value(i);
+ int& j = f.get();
+ assert(j == 3);
+ ++i;
+ assert(j == 4);
+ try
+ {
+ p.set_value(i);
+ assert(false);
+ }
+ catch (const std::future_error& e)
+ {
+ assert(e.code() == make_error_code(std::future_errc::promise_already_satisfied));
+ }
+ }
+}
diff --git a/test/std/thread/futures/futures.promise/set_lvalue_at_thread_exit.pass.cpp b/test/std/thread/futures/futures.promise/set_lvalue_at_thread_exit.pass.cpp
new file mode 100644
index 000000000000..18f87c596a00
--- /dev/null
+++ b/test/std/thread/futures/futures.promise/set_lvalue_at_thread_exit.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <future>
+
+// class promise<R>
+
+// void promise<R&>::set_value_at_thread_exit(R& r);
+
+#include <future>
+#include <memory>
+#include <cassert>
+
+int i = 0;
+
+void func(std::promise<int&> p)
+{
+ p.set_value_at_thread_exit(i);
+ i = 4;
+}
+
+int main()
+{
+ {
+ std::promise<int&> p;
+ std::future<int&> f = p.get_future();
+ std::thread(func, std::move(p)).detach();
+ assert(f.get() == 4);
+ }
+}
diff --git a/test/std/thread/futures/futures.promise/set_rvalue.pass.cpp b/test/std/thread/futures/futures.promise/set_rvalue.pass.cpp
new file mode 100644
index 000000000000..dab4bf7e9c83
--- /dev/null
+++ b/test/std/thread/futures/futures.promise/set_rvalue.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <future>
+
+// class promise<R>
+
+// void promise::set_value(R&& r);
+
+#include <future>
+#include <memory>
+#include <cassert>
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+struct A
+{
+ A() {}
+ A(const A&) = delete;
+ A(A&&) {throw 9;}
+};
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::unique_ptr<int> T;
+ T i(new int(3));
+ std::promise<T> p;
+ std::future<T> f = p.get_future();
+ p.set_value(std::move(i));
+ assert(*f.get() == 3);
+ try
+ {
+ p.set_value(std::move(i));
+ assert(false);
+ }
+ catch (const std::future_error& e)
+ {
+ assert(e.code() == make_error_code(std::future_errc::promise_already_satisfied));
+ }
+ }
+ {
+ typedef A T;
+ T i;
+ std::promise<T> p;
+ std::future<T> f = p.get_future();
+ try
+ {
+ p.set_value(std::move(i));
+ assert(false);
+ }
+ catch (int j)
+ {
+ assert(j == 9);
+ }
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/thread/futures/futures.promise/set_rvalue_at_thread_exit.pass.cpp b/test/std/thread/futures/futures.promise/set_rvalue_at_thread_exit.pass.cpp
new file mode 100644
index 000000000000..8f3b76865e2a
--- /dev/null
+++ b/test/std/thread/futures/futures.promise/set_rvalue_at_thread_exit.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <future>
+
+// class promise<R>
+
+// void promise::set_value_at_thread_exit(R&& r);
+
+#include <future>
+#include <memory>
+#include <cassert>
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+void func(std::promise<std::unique_ptr<int>> p)
+{
+ p.set_value_at_thread_exit(std::unique_ptr<int>(new int(5)));
+}
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::promise<std::unique_ptr<int>> p;
+ std::future<std::unique_ptr<int>> f = p.get_future();
+ std::thread(func, std::move(p)).detach();
+ assert(*f.get() == 5);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/thread/futures/futures.promise/set_value_at_thread_exit_const.pass.cpp b/test/std/thread/futures/futures.promise/set_value_at_thread_exit_const.pass.cpp
new file mode 100644
index 000000000000..ec50cc310298
--- /dev/null
+++ b/test/std/thread/futures/futures.promise/set_value_at_thread_exit_const.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <future>
+
+// class promise<R>
+
+// void promise::set_value_at_thread_exit(const R& r);
+
+#include <future>
+#include <cassert>
+
+void func(std::promise<int> p)
+{
+ const int i = 5;
+ p.set_value_at_thread_exit(i);
+}
+
+int main()
+{
+ {
+ std::promise<int> p;
+ std::future<int> f = p.get_future();
+ std::thread(func, std::move(p)).detach();
+ assert(f.get() == 5);
+ }
+}
diff --git a/test/std/thread/futures/futures.promise/set_value_at_thread_exit_void.pass.cpp b/test/std/thread/futures/futures.promise/set_value_at_thread_exit_void.pass.cpp
new file mode 100644
index 000000000000..8c092084668d
--- /dev/null
+++ b/test/std/thread/futures/futures.promise/set_value_at_thread_exit_void.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <future>
+
+// class promise<R>
+
+// void promise<void>::set_value_at_thread_exit();
+
+#include <future>
+#include <memory>
+#include <cassert>
+
+int i = 0;
+
+void func(std::promise<void> p)
+{
+ p.set_value_at_thread_exit();
+ i = 1;
+}
+
+int main()
+{
+ {
+ std::promise<void> p;
+ std::future<void> f = p.get_future();
+ std::thread(func, std::move(p)).detach();
+ f.get();
+ assert(i == 1);
+ }
+}
diff --git a/test/std/thread/futures/futures.promise/set_value_const.pass.cpp b/test/std/thread/futures/futures.promise/set_value_const.pass.cpp
new file mode 100644
index 000000000000..6673f6307579
--- /dev/null
+++ b/test/std/thread/futures/futures.promise/set_value_const.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <future>
+
+// class promise<R>
+
+// void promise::set_value(const R& r);
+
+#include <future>
+#include <cassert>
+
+struct A
+{
+ A() {}
+ A(const A&) {throw 10;}
+};
+
+int main()
+{
+ {
+ typedef int T;
+ T i = 3;
+ std::promise<T> p;
+ std::future<T> f = p.get_future();
+ p.set_value(i);
+ ++i;
+ assert(f.get() == 3);
+ --i;
+ try
+ {
+ p.set_value(i);
+ assert(false);
+ }
+ catch (const std::future_error& e)
+ {
+ assert(e.code() == make_error_code(std::future_errc::promise_already_satisfied));
+ }
+ }
+ {
+ typedef A T;
+ T i;
+ std::promise<T> p;
+ std::future<T> f = p.get_future();
+ try
+ {
+ p.set_value(i);
+ assert(false);
+ }
+ catch (int j)
+ {
+ assert(j == 10);
+ }
+ }
+}
diff --git a/test/std/thread/futures/futures.promise/set_value_void.pass.cpp b/test/std/thread/futures/futures.promise/set_value_void.pass.cpp
new file mode 100644
index 000000000000..5012e0bfe5fd
--- /dev/null
+++ b/test/std/thread/futures/futures.promise/set_value_void.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <future>
+
+// class promise<R>
+
+// void promise<void>::set_value();
+
+#include <future>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef void T;
+ std::promise<T> p;
+ std::future<T> f = p.get_future();
+ p.set_value();
+ f.get();
+ try
+ {
+ p.set_value();
+ assert(false);
+ }
+ catch (const std::future_error& e)
+ {
+ assert(e.code() == make_error_code(std::future_errc::promise_already_satisfied));
+ }
+ }
+}
diff --git a/test/std/thread/futures/futures.promise/swap.pass.cpp b/test/std/thread/futures/futures.promise/swap.pass.cpp
new file mode 100644
index 000000000000..1ed3e646813c
--- /dev/null
+++ b/test/std/thread/futures/futures.promise/swap.pass.cpp
@@ -0,0 +1,84 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <future>
+
+// class promise<R>
+
+// void swap(promise& other);
+
+// template <class R> void swap(promise<R>& x, promise<R>& y);
+
+#include <future>
+#include <cassert>
+
+#include "../test_allocator.h"
+
+int main()
+{
+ assert(test_alloc_base::count == 0);
+ {
+ std::promise<int> p0(std::allocator_arg, test_allocator<int>());
+ std::promise<int> p(std::allocator_arg, test_allocator<int>());
+ assert(test_alloc_base::count == 2);
+ p.swap(p0);
+ assert(test_alloc_base::count == 2);
+ std::future<int> f = p.get_future();
+ assert(test_alloc_base::count == 2);
+ assert(f.valid());
+ f = p0.get_future();
+ assert(f.valid());
+ assert(test_alloc_base::count == 2);
+ }
+ assert(test_alloc_base::count == 0);
+ {
+ std::promise<int> p0(std::allocator_arg, test_allocator<int>());
+ std::promise<int> p(std::allocator_arg, test_allocator<int>());
+ assert(test_alloc_base::count == 2);
+ swap(p, p0);
+ assert(test_alloc_base::count == 2);
+ std::future<int> f = p.get_future();
+ assert(test_alloc_base::count == 2);
+ assert(f.valid());
+ f = p0.get_future();
+ assert(f.valid());
+ assert(test_alloc_base::count == 2);
+ }
+ assert(test_alloc_base::count == 0);
+ {
+ std::promise<int> p0(std::allocator_arg, test_allocator<int>());
+ std::promise<int> p;
+ assert(test_alloc_base::count == 1);
+ p.swap(p0);
+ assert(test_alloc_base::count == 1);
+ std::future<int> f = p.get_future();
+ assert(test_alloc_base::count == 1);
+ assert(f.valid());
+ f = p0.get_future();
+ assert(f.valid());
+ assert(test_alloc_base::count == 1);
+ }
+ assert(test_alloc_base::count == 0);
+ {
+ std::promise<int> p0(std::allocator_arg, test_allocator<int>());
+ std::promise<int> p;
+ assert(test_alloc_base::count == 1);
+ swap(p, p0);
+ assert(test_alloc_base::count == 1);
+ std::future<int> f = p.get_future();
+ assert(test_alloc_base::count == 1);
+ assert(f.valid());
+ f = p0.get_future();
+ assert(f.valid());
+ assert(test_alloc_base::count == 1);
+ }
+ assert(test_alloc_base::count == 0);
+}
diff --git a/test/std/thread/futures/futures.promise/uses_allocator.pass.cpp b/test/std/thread/futures/futures.promise/uses_allocator.pass.cpp
new file mode 100644
index 000000000000..458826e956e1
--- /dev/null
+++ b/test/std/thread/futures/futures.promise/uses_allocator.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <future>
+
+// class promise<R>
+
+// template <class R, class Alloc>
+// struct uses_allocator<promise<R>, Alloc>
+// : true_type { };
+
+#include <future>
+#include "../test_allocator.h"
+
+int main()
+{
+ static_assert((std::uses_allocator<std::promise<int>, test_allocator<int> >::value), "");
+ static_assert((std::uses_allocator<std::promise<int&>, test_allocator<int> >::value), "");
+ static_assert((std::uses_allocator<std::promise<void>, test_allocator<void> >::value), "");
+}
diff --git a/test/std/thread/futures/futures.shared_future/copy_assign.pass.cpp b/test/std/thread/futures/futures.shared_future/copy_assign.pass.cpp
new file mode 100644
index 000000000000..b23ba196ec30
--- /dev/null
+++ b/test/std/thread/futures/futures.shared_future/copy_assign.pass.cpp
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <future>
+
+// class shared_future<R>
+
+// shared_future& operator=(const shared_future& rhs);
+
+#include <future>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef int T;
+ std::promise<T> p;
+ std::shared_future<T> f0 = p.get_future();
+ std::shared_future<T> f;
+ f = f0;
+ assert(f0.valid());
+ assert(f.valid());
+ }
+ {
+ typedef int T;
+ std::shared_future<T> f0;
+ std::shared_future<T> f;
+ f = f0;
+ assert(!f0.valid());
+ assert(!f.valid());
+ }
+ {
+ typedef int& T;
+ std::promise<T> p;
+ std::shared_future<T> f0 = p.get_future();
+ std::shared_future<T> f;
+ f = f0;
+ assert(f0.valid());
+ assert(f.valid());
+ }
+ {
+ typedef int& T;
+ std::shared_future<T> f0;
+ std::shared_future<T> f;
+ f = f0;
+ assert(!f0.valid());
+ assert(!f.valid());
+ }
+ {
+ typedef void T;
+ std::promise<T> p;
+ std::shared_future<T> f0 = p.get_future();
+ std::shared_future<T> f;
+ f = f0;
+ assert(f0.valid());
+ assert(f.valid());
+ }
+ {
+ typedef void T;
+ std::shared_future<T> f0;
+ std::shared_future<T> f;
+ f = f0;
+ assert(!f0.valid());
+ assert(!f.valid());
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/thread/futures/futures.shared_future/copy_ctor.pass.cpp b/test/std/thread/futures/futures.shared_future/copy_ctor.pass.cpp
new file mode 100644
index 000000000000..425d1f9be96f
--- /dev/null
+++ b/test/std/thread/futures/futures.shared_future/copy_ctor.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <future>
+
+// class shared_future<R>
+
+// shared_future(const shared_future& rhs);
+
+#include <future>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ std::promise<T> p;
+ std::shared_future<T> f0 = p.get_future();
+ std::shared_future<T> f = f0;
+ assert(f0.valid());
+ assert(f.valid());
+ }
+ {
+ typedef int T;
+ std::shared_future<T> f0;
+ std::shared_future<T> f = f0;
+ assert(!f0.valid());
+ assert(!f.valid());
+ }
+ {
+ typedef int& T;
+ std::promise<T> p;
+ std::shared_future<T> f0 = p.get_future();
+ std::shared_future<T> f = f0;
+ assert(f0.valid());
+ assert(f.valid());
+ }
+ {
+ typedef int& T;
+ std::shared_future<T> f0;
+ std::shared_future<T> f = std::move(f0);
+ assert(!f0.valid());
+ assert(!f.valid());
+ }
+ {
+ typedef void T;
+ std::promise<T> p;
+ std::shared_future<T> f0 = p.get_future();
+ std::shared_future<T> f = f0;
+ assert(f0.valid());
+ assert(f.valid());
+ }
+ {
+ typedef void T;
+ std::shared_future<T> f0;
+ std::shared_future<T> f = f0;
+ assert(!f0.valid());
+ assert(!f.valid());
+ }
+}
diff --git a/test/std/thread/futures/futures.shared_future/ctor_future.pass.cpp b/test/std/thread/futures/futures.shared_future/ctor_future.pass.cpp
new file mode 100644
index 000000000000..3a78b80f0634
--- /dev/null
+++ b/test/std/thread/futures/futures.shared_future/ctor_future.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <future>
+
+// class shared_future<R>
+
+// shared_future(future<R>&& rhs);
+
+#include <future>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ std::promise<T> p;
+ std::future<T> f0 = p.get_future();
+ std::shared_future<T> f = std::move(f0);
+ assert(!f0.valid());
+ assert(f.valid());
+ }
+ {
+ typedef int T;
+ std::future<T> f0;
+ std::shared_future<T> f = std::move(f0);
+ assert(!f0.valid());
+ assert(!f.valid());
+ }
+ {
+ typedef int& T;
+ std::promise<T> p;
+ std::future<T> f0 = p.get_future();
+ std::shared_future<T> f = std::move(f0);
+ assert(!f0.valid());
+ assert(f.valid());
+ }
+ {
+ typedef int& T;
+ std::future<T> f0;
+ std::shared_future<T> f = std::move(f0);
+ assert(!f0.valid());
+ assert(!f.valid());
+ }
+ {
+ typedef void T;
+ std::promise<T> p;
+ std::future<T> f0 = p.get_future();
+ std::shared_future<T> f = std::move(f0);
+ assert(!f0.valid());
+ assert(f.valid());
+ }
+ {
+ typedef void T;
+ std::future<T> f0;
+ std::shared_future<T> f = std::move(f0);
+ assert(!f0.valid());
+ assert(!f.valid());
+ }
+}
diff --git a/test/std/thread/futures/futures.shared_future/default.pass.cpp b/test/std/thread/futures/futures.shared_future/default.pass.cpp
new file mode 100644
index 000000000000..92927f5f6933
--- /dev/null
+++ b/test/std/thread/futures/futures.shared_future/default.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <future>
+
+// class shared_future<R>
+
+// shared_future();
+
+#include <future>
+#include <cassert>
+
+int main()
+{
+ {
+ std::shared_future<int> f;
+ assert(!f.valid());
+ }
+ {
+ std::shared_future<int&> f;
+ assert(!f.valid());
+ }
+ {
+ std::shared_future<void> f;
+ assert(!f.valid());
+ }
+}
diff --git a/test/std/thread/futures/futures.shared_future/dtor.pass.cpp b/test/std/thread/futures/futures.shared_future/dtor.pass.cpp
new file mode 100644
index 000000000000..baa89cb12b1c
--- /dev/null
+++ b/test/std/thread/futures/futures.shared_future/dtor.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <future>
+
+// class shared_future<R>
+
+// ~shared_future();
+
+#include <future>
+#include <cassert>
+
+#include "../test_allocator.h"
+
+int main()
+{
+ assert(test_alloc_base::count == 0);
+ {
+ typedef int T;
+ std::shared_future<T> f;
+ {
+ std::promise<T> p(std::allocator_arg, test_allocator<T>());
+ assert(test_alloc_base::count == 1);
+ f = p.get_future();
+ assert(test_alloc_base::count == 1);
+ assert(f.valid());
+ }
+ assert(test_alloc_base::count == 1);
+ assert(f.valid());
+ }
+ assert(test_alloc_base::count == 0);
+ {
+ typedef int& T;
+ std::shared_future<T> f;
+ {
+ std::promise<T> p(std::allocator_arg, test_allocator<int>());
+ assert(test_alloc_base::count == 1);
+ f = p.get_future();
+ assert(test_alloc_base::count == 1);
+ assert(f.valid());
+ }
+ assert(test_alloc_base::count == 1);
+ assert(f.valid());
+ }
+ assert(test_alloc_base::count == 0);
+ {
+ typedef void T;
+ std::shared_future<T> f;
+ {
+ std::promise<T> p(std::allocator_arg, test_allocator<T>());
+ assert(test_alloc_base::count == 1);
+ f = p.get_future();
+ assert(test_alloc_base::count == 1);
+ assert(f.valid());
+ }
+ assert(test_alloc_base::count == 1);
+ assert(f.valid());
+ }
+ assert(test_alloc_base::count == 0);
+}
diff --git a/test/std/thread/futures/futures.shared_future/get.pass.cpp b/test/std/thread/futures/futures.shared_future/get.pass.cpp
new file mode 100644
index 000000000000..c5ee234b127f
--- /dev/null
+++ b/test/std/thread/futures/futures.shared_future/get.pass.cpp
@@ -0,0 +1,145 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <future>
+
+// class shared_future<R>
+
+// const R& shared_future::get();
+// R& shared_future<R&>::get();
+// void shared_future<void>::get();
+
+#include <future>
+#include <cassert>
+
+void func1(std::promise<int> p)
+{
+ std::this_thread::sleep_for(std::chrono::milliseconds(500));
+ p.set_value(3);
+}
+
+void func2(std::promise<int> p)
+{
+ std::this_thread::sleep_for(std::chrono::milliseconds(500));
+ p.set_exception(std::make_exception_ptr(3));
+}
+
+int j = 0;
+
+void func3(std::promise<int&> p)
+{
+ std::this_thread::sleep_for(std::chrono::milliseconds(500));
+ j = 5;
+ p.set_value(j);
+}
+
+void func4(std::promise<int&> p)
+{
+ std::this_thread::sleep_for(std::chrono::milliseconds(500));
+ p.set_exception(std::make_exception_ptr(3.5));
+}
+
+void func5(std::promise<void> p)
+{
+ std::this_thread::sleep_for(std::chrono::milliseconds(500));
+ p.set_value();
+}
+
+void func6(std::promise<void> p)
+{
+ std::this_thread::sleep_for(std::chrono::milliseconds(500));
+ p.set_exception(std::make_exception_ptr('c'));
+}
+
+int main()
+{
+ {
+ typedef int T;
+ {
+ std::promise<T> p;
+ std::shared_future<T> f = p.get_future();
+ std::thread(func1, std::move(p)).detach();
+ assert(f.valid());
+ assert(f.get() == 3);
+ assert(f.valid());
+ }
+ {
+ std::promise<T> p;
+ std::shared_future<T> f = p.get_future();
+ std::thread(func2, std::move(p)).detach();
+ try
+ {
+ assert(f.valid());
+ assert(f.get() == 3);
+ assert(false);
+ }
+ catch (int i)
+ {
+ assert(i == 3);
+ }
+ assert(f.valid());
+ }
+ }
+ {
+ typedef int& T;
+ {
+ std::promise<T> p;
+ std::shared_future<T> f = p.get_future();
+ std::thread(func3, std::move(p)).detach();
+ assert(f.valid());
+ assert(f.get() == 5);
+ assert(f.valid());
+ }
+ {
+ std::promise<T> p;
+ std::shared_future<T> f = p.get_future();
+ std::thread(func4, std::move(p)).detach();
+ try
+ {
+ assert(f.valid());
+ assert(f.get() == 3);
+ assert(false);
+ }
+ catch (double i)
+ {
+ assert(i == 3.5);
+ }
+ assert(f.valid());
+ }
+ }
+ {
+ typedef void T;
+ {
+ std::promise<T> p;
+ std::shared_future<T> f = p.get_future();
+ std::thread(func5, std::move(p)).detach();
+ assert(f.valid());
+ f.get();
+ assert(f.valid());
+ }
+ {
+ std::promise<T> p;
+ std::shared_future<T> f = p.get_future();
+ std::thread(func6, std::move(p)).detach();
+ try
+ {
+ assert(f.valid());
+ f.get();
+ assert(false);
+ }
+ catch (char i)
+ {
+ assert(i == 'c');
+ }
+ assert(f.valid());
+ }
+ }
+}
diff --git a/test/std/thread/futures/futures.shared_future/move_assign.pass.cpp b/test/std/thread/futures/futures.shared_future/move_assign.pass.cpp
new file mode 100644
index 000000000000..6b58f41c9085
--- /dev/null
+++ b/test/std/thread/futures/futures.shared_future/move_assign.pass.cpp
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <future>
+
+// class shared_future<R>
+
+// shared_future& operator=(shared_future&& rhs);
+
+#include <future>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef int T;
+ std::promise<T> p;
+ std::shared_future<T> f0 = p.get_future();
+ std::shared_future<T> f;
+ f = std::move(f0);
+ assert(!f0.valid());
+ assert(f.valid());
+ }
+ {
+ typedef int T;
+ std::shared_future<T> f0;
+ std::shared_future<T> f;
+ f = std::move(f0);
+ assert(!f0.valid());
+ assert(!f.valid());
+ }
+ {
+ typedef int& T;
+ std::promise<T> p;
+ std::shared_future<T> f0 = p.get_future();
+ std::shared_future<T> f;
+ f = std::move(f0);
+ assert(!f0.valid());
+ assert(f.valid());
+ }
+ {
+ typedef int& T;
+ std::shared_future<T> f0;
+ std::shared_future<T> f;
+ f = std::move(f0);
+ assert(!f0.valid());
+ assert(!f.valid());
+ }
+ {
+ typedef void T;
+ std::promise<T> p;
+ std::shared_future<T> f0 = p.get_future();
+ std::shared_future<T> f;
+ f = std::move(f0);
+ assert(!f0.valid());
+ assert(f.valid());
+ }
+ {
+ typedef void T;
+ std::shared_future<T> f0;
+ std::shared_future<T> f;
+ f = std::move(f0);
+ assert(!f0.valid());
+ assert(!f.valid());
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/thread/futures/futures.shared_future/move_ctor.pass.cpp b/test/std/thread/futures/futures.shared_future/move_ctor.pass.cpp
new file mode 100644
index 000000000000..32b8fd77c672
--- /dev/null
+++ b/test/std/thread/futures/futures.shared_future/move_ctor.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <future>
+
+// class shared_future<R>
+
+// shared_future(shared_future&& rhs);
+
+#include <future>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ std::promise<T> p;
+ std::shared_future<T> f0 = p.get_future();
+ std::shared_future<T> f = std::move(f0);
+ assert(!f0.valid());
+ assert(f.valid());
+ }
+ {
+ typedef int T;
+ std::shared_future<T> f0;
+ std::shared_future<T> f = std::move(f0);
+ assert(!f0.valid());
+ assert(!f.valid());
+ }
+ {
+ typedef int& T;
+ std::promise<T> p;
+ std::shared_future<T> f0 = p.get_future();
+ std::shared_future<T> f = std::move(f0);
+ assert(!f0.valid());
+ assert(f.valid());
+ }
+ {
+ typedef int& T;
+ std::shared_future<T> f0;
+ std::shared_future<T> f = std::move(f0);
+ assert(!f0.valid());
+ assert(!f.valid());
+ }
+ {
+ typedef void T;
+ std::promise<T> p;
+ std::shared_future<T> f0 = p.get_future();
+ std::shared_future<T> f = std::move(f0);
+ assert(!f0.valid());
+ assert(f.valid());
+ }
+ {
+ typedef void T;
+ std::shared_future<T> f0;
+ std::shared_future<T> f = std::move(f0);
+ assert(!f0.valid());
+ assert(!f.valid());
+ }
+}
diff --git a/test/std/thread/futures/futures.shared_future/wait.pass.cpp b/test/std/thread/futures/futures.shared_future/wait.pass.cpp
new file mode 100644
index 000000000000..4293fcab3564
--- /dev/null
+++ b/test/std/thread/futures/futures.shared_future/wait.pass.cpp
@@ -0,0 +1,88 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <future>
+
+// class shared_future<R>
+
+// void wait() const;
+
+#include <future>
+#include <cassert>
+
+void func1(std::promise<int> p)
+{
+ std::this_thread::sleep_for(std::chrono::milliseconds(500));
+ p.set_value(3);
+}
+
+int j = 0;
+
+void func3(std::promise<int&> p)
+{
+ std::this_thread::sleep_for(std::chrono::milliseconds(500));
+ j = 5;
+ p.set_value(j);
+}
+
+void func5(std::promise<void> p)
+{
+ std::this_thread::sleep_for(std::chrono::milliseconds(500));
+ p.set_value();
+}
+
+int main()
+{
+ typedef std::chrono::high_resolution_clock Clock;
+ typedef std::chrono::duration<double, std::milli> ms;
+ {
+ typedef int T;
+ std::promise<T> p;
+ std::shared_future<T> f = p.get_future();
+ std::thread(func1, std::move(p)).detach();
+ assert(f.valid());
+ f.wait();
+ assert(f.valid());
+ Clock::time_point t0 = Clock::now();
+ f.wait();
+ Clock::time_point t1 = Clock::now();
+ assert(f.valid());
+ assert(t1-t0 < ms(5));
+ }
+ {
+ typedef int& T;
+ std::promise<T> p;
+ std::shared_future<T> f = p.get_future();
+ std::thread(func3, std::move(p)).detach();
+ assert(f.valid());
+ f.wait();
+ assert(f.valid());
+ Clock::time_point t0 = Clock::now();
+ f.wait();
+ Clock::time_point t1 = Clock::now();
+ assert(f.valid());
+ assert(t1-t0 < ms(5));
+ }
+ {
+ typedef void T;
+ std::promise<T> p;
+ std::shared_future<T> f = p.get_future();
+ std::thread(func5, std::move(p)).detach();
+ assert(f.valid());
+ f.wait();
+ assert(f.valid());
+ Clock::time_point t0 = Clock::now();
+ f.wait();
+ Clock::time_point t1 = Clock::now();
+ assert(f.valid());
+ assert(t1-t0 < ms(5));
+ }
+}
diff --git a/test/std/thread/futures/futures.shared_future/wait_for.pass.cpp b/test/std/thread/futures/futures.shared_future/wait_for.pass.cpp
new file mode 100644
index 000000000000..e5a4754e38ad
--- /dev/null
+++ b/test/std/thread/futures/futures.shared_future/wait_for.pass.cpp
@@ -0,0 +1,97 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <future>
+
+// class shared_future<R>
+
+// template <class Rep, class Period>
+// future_status
+// wait_for(const chrono::duration<Rep, Period>& rel_time) const;
+
+#include <future>
+#include <cassert>
+
+typedef std::chrono::milliseconds ms;
+
+void func1(std::promise<int> p)
+{
+ std::this_thread::sleep_for(ms(500));
+ p.set_value(3);
+}
+
+int j = 0;
+
+void func3(std::promise<int&> p)
+{
+ std::this_thread::sleep_for(ms(500));
+ j = 5;
+ p.set_value(j);
+}
+
+void func5(std::promise<void> p)
+{
+ std::this_thread::sleep_for(ms(500));
+ p.set_value();
+}
+
+int main()
+{
+ typedef std::chrono::high_resolution_clock Clock;
+ {
+ typedef int T;
+ std::promise<T> p;
+ std::shared_future<T> f = p.get_future();
+ std::thread(func1, std::move(p)).detach();
+ assert(f.valid());
+ assert(f.wait_for(ms(300)) == std::future_status::timeout);
+ assert(f.valid());
+ assert(f.wait_for(ms(300)) == std::future_status::ready);
+ assert(f.valid());
+ Clock::time_point t0 = Clock::now();
+ f.wait();
+ Clock::time_point t1 = Clock::now();
+ assert(f.valid());
+ assert(t1-t0 < ms(5));
+ }
+ {
+ typedef int& T;
+ std::promise<T> p;
+ std::shared_future<T> f = p.get_future();
+ std::thread(func3, std::move(p)).detach();
+ assert(f.valid());
+ assert(f.wait_for(ms(300)) == std::future_status::timeout);
+ assert(f.valid());
+ assert(f.wait_for(ms(300)) == std::future_status::ready);
+ assert(f.valid());
+ Clock::time_point t0 = Clock::now();
+ f.wait();
+ Clock::time_point t1 = Clock::now();
+ assert(f.valid());
+ assert(t1-t0 < ms(5));
+ }
+ {
+ typedef void T;
+ std::promise<T> p;
+ std::shared_future<T> f = p.get_future();
+ std::thread(func5, std::move(p)).detach();
+ assert(f.valid());
+ assert(f.wait_for(ms(300)) == std::future_status::timeout);
+ assert(f.valid());
+ assert(f.wait_for(ms(300)) == std::future_status::ready);
+ assert(f.valid());
+ Clock::time_point t0 = Clock::now();
+ f.wait();
+ Clock::time_point t1 = Clock::now();
+ assert(f.valid());
+ assert(t1-t0 < ms(5));
+ }
+}
diff --git a/test/std/thread/futures/futures.shared_future/wait_until.pass.cpp b/test/std/thread/futures/futures.shared_future/wait_until.pass.cpp
new file mode 100644
index 000000000000..6a6aeba7759e
--- /dev/null
+++ b/test/std/thread/futures/futures.shared_future/wait_until.pass.cpp
@@ -0,0 +1,129 @@
+ //===----------------------------------------------------------------------===//
+ //
+ // The LLVM Compiler Infrastructure
+ //
+ // This file is dual licensed under the MIT and the University of Illinois Open
+ // Source Licenses. See LICENSE.TXT for details.
+ //
+ //===----------------------------------------------------------------------===//
+ //
+ // UNSUPPORTED: libcpp-has-no-threads
+
+ // <future>
+
+ // class shared_future<R>
+
+ // template <class Clock, class Duration>
+ // future_status
+ // wait_until(const chrono::time_point<Clock, Duration>& abs_time) const;
+
+ #include <future>
+ #include <atomic>
+ #include <cassert>
+
+ enum class WorkerThreadState { Uninitialized, AllowedToRun, Exiting };
+ typedef std::chrono::milliseconds ms;
+
+ std::atomic<WorkerThreadState> thread_state(WorkerThreadState::Uninitialized);
+
+ void set_worker_thread_state(WorkerThreadState state)
+ {
+ thread_state.store(state, std::memory_order_relaxed);
+ }
+
+ void wait_for_worker_thread_state(WorkerThreadState state)
+ {
+ while (thread_state.load(std::memory_order_relaxed) != state);
+ }
+
+ void func1(std::promise<int> p)
+ {
+ wait_for_worker_thread_state(WorkerThreadState::AllowedToRun);
+ p.set_value(3);
+ set_worker_thread_state(WorkerThreadState::Exiting);
+ }
+
+ int j = 0;
+
+ void func3(std::promise<int&> p)
+ {
+ wait_for_worker_thread_state(WorkerThreadState::AllowedToRun);
+ j = 5;
+ p.set_value(j);
+ set_worker_thread_state(WorkerThreadState::Exiting);
+ }
+
+ void func5(std::promise<void> p)
+ {
+ wait_for_worker_thread_state(WorkerThreadState::AllowedToRun);
+ p.set_value();
+ set_worker_thread_state(WorkerThreadState::Exiting);
+ }
+
+ int main()
+ {
+ typedef std::chrono::high_resolution_clock Clock;
+ {
+ typedef int T;
+ std::promise<T> p;
+ std::shared_future<T> f = p.get_future();
+ std::thread(func1, std::move(p)).detach();
+ assert(f.valid());
+ assert(f.wait_until(Clock::now() + ms(10)) == std::future_status::timeout);
+ assert(f.valid());
+
+ // allow the worker thread to produce the result and wait until the worker is done
+ set_worker_thread_state(WorkerThreadState::AllowedToRun);
+ wait_for_worker_thread_state(WorkerThreadState::Exiting);
+
+ assert(f.wait_until(Clock::now() + ms(10)) == std::future_status::ready);
+ assert(f.valid());
+ Clock::time_point t0 = Clock::now();
+ f.wait();
+ Clock::time_point t1 = Clock::now();
+ assert(f.valid());
+ assert(t1-t0 < ms(5));
+ }
+ {
+ typedef int& T;
+ std::promise<T> p;
+ std::shared_future<T> f = p.get_future();
+ std::thread(func3, std::move(p)).detach();
+ assert(f.valid());
+ assert(f.wait_until(Clock::now() + ms(10)) == std::future_status::timeout);
+ assert(f.valid());
+
+ // allow the worker thread to produce the result and wait until the worker is done
+ set_worker_thread_state(WorkerThreadState::AllowedToRun);
+ wait_for_worker_thread_state(WorkerThreadState::Exiting);
+
+ assert(f.wait_until(Clock::now() + ms(10)) == std::future_status::ready);
+ assert(f.valid());
+ Clock::time_point t0 = Clock::now();
+ f.wait();
+ Clock::time_point t1 = Clock::now();
+ assert(f.valid());
+ assert(t1-t0 < ms(5));
+ }
+ {
+ typedef void T;
+ std::promise<T> p;
+ std::shared_future<T> f = p.get_future();
+ std::thread(func5, std::move(p)).detach();
+ assert(f.valid());
+ assert(f.wait_until(Clock::now() + ms(10)) == std::future_status::timeout);
+ assert(f.valid());
+
+ // allow the worker thread to produce the result and wait until the worker is done
+ set_worker_thread_state(WorkerThreadState::AllowedToRun);
+ wait_for_worker_thread_state(WorkerThreadState::Exiting);
+
+ assert(f.wait_until(Clock::now() + ms(10)) == std::future_status::ready);
+ assert(f.valid());
+ Clock::time_point t0 = Clock::now();
+ f.wait();
+ Clock::time_point t1 = Clock::now();
+ assert(f.valid());
+ assert(t1-t0 < ms(5));
+ }
+ }
diff --git a/test/std/thread/futures/futures.state/nothing_to_do.pass.cpp b/test/std/thread/futures/futures.state/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..9a59227abdd9
--- /dev/null
+++ b/test/std/thread/futures/futures.state/nothing_to_do.pass.cpp
@@ -0,0 +1,13 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/thread/futures/futures.tas/futures.task.members/assign_copy.fail.cpp b/test/std/thread/futures/futures.tas/futures.task.members/assign_copy.fail.cpp
new file mode 100644
index 000000000000..70ea0ad31fed
--- /dev/null
+++ b/test/std/thread/futures/futures.tas/futures.task.members/assign_copy.fail.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+// class packaged_task<R(ArgTypes...)>
+
+// packaged_task& operator=(packaged_task&) = delete;
+
+#include <future>
+#include <cassert>
+
+class A
+{
+ long data_;
+
+public:
+ explicit A(long i) : data_(i) {}
+
+ long operator()(long i, long j) const {return data_ + i + j;}
+};
+
+int main()
+{
+ {
+ std::packaged_task<double(int, char)> p0(A(5));
+ std::packaged_task<double(int, char)> p;
+ p = p0;
+ assert(!p0.valid());
+ assert(p.valid());
+ std::future<double> f = p.get_future();
+ p(3, 'a');
+ assert(f.get() == 105.0);
+ }
+ {
+ std::packaged_task<double(int, char)> p0;
+ std::packaged_task<double(int, char)> p;
+ p = p0;
+ assert(!p0.valid());
+ assert(!p.valid());
+ }
+}
diff --git a/test/std/thread/futures/futures.tas/futures.task.members/assign_move.pass.cpp b/test/std/thread/futures/futures.tas/futures.task.members/assign_move.pass.cpp
new file mode 100644
index 000000000000..18786f4eb7a2
--- /dev/null
+++ b/test/std/thread/futures/futures.tas/futures.task.members/assign_move.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <future>
+
+// class packaged_task<R(ArgTypes...)>
+
+// packaged_task& operator=(packaged_task&& other);
+
+#include <future>
+#include <cassert>
+
+class A
+{
+ long data_;
+
+public:
+ explicit A(long i) : data_(i) {}
+
+ long operator()(long i, long j) const {return data_ + i + j;}
+};
+
+int main()
+{
+ {
+ std::packaged_task<double(int, char)> p0(A(5));
+ std::packaged_task<double(int, char)> p;
+ p = std::move(p0);
+ assert(!p0.valid());
+ assert(p.valid());
+ std::future<double> f = p.get_future();
+ p(3, 'a');
+ assert(f.get() == 105.0);
+ }
+ {
+ std::packaged_task<double(int, char)> p0;
+ std::packaged_task<double(int, char)> p;
+ p = std::move(p0);
+ assert(!p0.valid());
+ assert(!p.valid());
+ }
+}
diff --git a/test/std/thread/futures/futures.tas/futures.task.members/ctor1.fail.cpp b/test/std/thread/futures/futures.tas/futures.task.members/ctor1.fail.cpp
new file mode 100644
index 000000000000..45048b747f7a
--- /dev/null
+++ b/test/std/thread/futures/futures.tas/futures.task.members/ctor1.fail.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+// class packaged_task<R(ArgTypes...)>
+// template <class F>
+// packaged_task(F&& f);
+// These constructors shall not participate in overload resolution if
+// decay<F>::type is the same type as std::packaged_task<R(ArgTypes...)>.
+
+#include <future>
+#include <cassert>
+
+struct A {};
+typedef std::packaged_task<A(int, char)> PT;
+typedef volatile std::packaged_task<A(int, char)> VPT;
+
+
+int main()
+{
+ PT p { VPT{} };
+}
diff --git a/test/std/thread/futures/futures.tas/futures.task.members/ctor2.fail.cpp b/test/std/thread/futures/futures.tas/futures.task.members/ctor2.fail.cpp
new file mode 100644
index 000000000000..e4df4ec225e7
--- /dev/null
+++ b/test/std/thread/futures/futures.tas/futures.task.members/ctor2.fail.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+// class packaged_task<R(ArgTypes...)>
+// template <class F, class Allocator>
+// packaged_task(allocator_arg_t, const Allocator& a, F&& f);
+// These constructors shall not participate in overload resolution if
+// decay<F>::type is the same type as std::packaged_task<R(ArgTypes...)>.
+
+#include <future>
+#include <cassert>
+
+#include "../../test_allocator.h"
+
+struct A {};
+typedef std::packaged_task<A(int, char)> PT;
+typedef volatile std::packaged_task<A(int, char)> VPT;
+
+int main()
+{
+ PT p { std::allocator_arg_t{}, test_allocator<A>{}, VPT {}};
+}
diff --git a/test/std/thread/futures/futures.tas/futures.task.members/ctor_copy.fail.cpp b/test/std/thread/futures/futures.tas/futures.task.members/ctor_copy.fail.cpp
new file mode 100644
index 000000000000..9884c49a6dc7
--- /dev/null
+++ b/test/std/thread/futures/futures.tas/futures.task.members/ctor_copy.fail.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+// class packaged_task<R(ArgTypes...)>
+
+// packaged_task(packaged_task&) = delete;
+
+#include <future>
+#include <cassert>
+
+class A
+{
+ long data_;
+
+public:
+ explicit A(long i) : data_(i) {}
+
+ long operator()(long i, long j) const {return data_ + i + j;}
+};
+
+int main()
+{
+ {
+ std::packaged_task<double(int, char)> p0(A(5));
+ std::packaged_task<double(int, char)> p(p0);
+ assert(!p0.valid());
+ assert(p.valid());
+ std::future<double> f = p.get_future();
+ p(3, 'a');
+ assert(f.get() == 105.0);
+ }
+ {
+ std::packaged_task<double(int, char)> p0;
+ std::packaged_task<double(int, char)> p(p0);
+ assert(!p0.valid());
+ assert(!p.valid());
+ }
+}
diff --git a/test/std/thread/futures/futures.tas/futures.task.members/ctor_default.pass.cpp b/test/std/thread/futures/futures.tas/futures.task.members/ctor_default.pass.cpp
new file mode 100644
index 000000000000..76904962a778
--- /dev/null
+++ b/test/std/thread/futures/futures.tas/futures.task.members/ctor_default.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <future>
+
+// class packaged_task<R(ArgTypes...)>
+
+// packaged_task();
+
+#include <future>
+#include <cassert>
+
+struct A {};
+
+int main()
+{
+ std::packaged_task<A(int, char)> p;
+ assert(!p.valid());
+}
diff --git a/test/std/thread/futures/futures.tas/futures.task.members/ctor_func.pass.cpp b/test/std/thread/futures/futures.tas/futures.task.members/ctor_func.pass.cpp
new file mode 100644
index 000000000000..2eee2cbc2d50
--- /dev/null
+++ b/test/std/thread/futures/futures.tas/futures.task.members/ctor_func.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <future>
+
+// class packaged_task<R(ArgTypes...)>
+
+// template <class F>
+// explicit packaged_task(F&& f);
+
+#include <future>
+#include <cassert>
+
+class A
+{
+ long data_;
+
+public:
+ static int n_moves;
+ static int n_copies;
+
+ explicit A(long i) : data_(i) {}
+ A(A&& a) : data_(a.data_) {++n_moves; a.data_ = -1;}
+ A(const A& a) : data_(a.data_) {++n_copies;}
+
+ long operator()(long i, long j) const {return data_ + i + j;}
+};
+
+int A::n_moves = 0;
+int A::n_copies = 0;
+
+int func(int i) { return i; }
+
+int main()
+{
+ {
+ std::packaged_task<double(int, char)> p(A(5));
+ assert(p.valid());
+ std::future<double> f = p.get_future();
+ p(3, 'a');
+ assert(f.get() == 105.0);
+ assert(A::n_copies == 0);
+ assert(A::n_moves > 0);
+ }
+ A::n_copies = 0;
+ A::n_copies = 0;
+ {
+ A a(5);
+ std::packaged_task<double(int, char)> p(a);
+ assert(p.valid());
+ std::future<double> f = p.get_future();
+ p(3, 'a');
+ assert(f.get() == 105.0);
+ assert(A::n_copies > 0);
+ assert(A::n_moves > 0);
+ }
+ {
+ std::packaged_task<int(int)> p(&func);
+ assert(p.valid());
+ std::future<int> f = p.get_future();
+ p(4);
+ assert(f.get() == 4);
+ }
+ {
+ std::packaged_task<int(int)> p(func);
+ assert(p.valid());
+ std::future<int> f = p.get_future();
+ p(4);
+ assert(f.get() == 4);
+ }
+}
diff --git a/test/std/thread/futures/futures.tas/futures.task.members/ctor_func_alloc.pass.cpp b/test/std/thread/futures/futures.tas/futures.task.members/ctor_func_alloc.pass.cpp
new file mode 100644
index 000000000000..3aac2b26bfc1
--- /dev/null
+++ b/test/std/thread/futures/futures.tas/futures.task.members/ctor_func_alloc.pass.cpp
@@ -0,0 +1,124 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <future>
+
+// class packaged_task<R(ArgTypes...)>
+
+// template <class F, class Allocator>
+// explicit packaged_task(allocator_arg_t, const Allocator& a, F&& f);
+
+#include <future>
+#include <cassert>
+
+#include "../../test_allocator.h"
+#include "min_allocator.h"
+
+class A
+{
+ long data_;
+
+public:
+ static int n_moves;
+ static int n_copies;
+
+ explicit A(long i) : data_(i) {}
+ A(A&& a) : data_(a.data_) {++n_moves; a.data_ = -1;}
+ A(const A& a) : data_(a.data_) {++n_copies;}
+
+ long operator()(long i, long j) const {return data_ + i + j;}
+};
+
+int A::n_moves = 0;
+int A::n_copies = 0;
+
+int func(int i) { return i; }
+
+int main()
+{
+ {
+ std::packaged_task<double(int, char)> p(std::allocator_arg,
+ test_allocator<A>(), A(5));
+ assert(test_alloc_base::count > 0);
+ assert(p.valid());
+ std::future<double> f = p.get_future();
+ p(3, 'a');
+ assert(f.get() == 105.0);
+ assert(A::n_copies == 0);
+ assert(A::n_moves > 0);
+ }
+ assert(test_alloc_base::count == 0);
+ A::n_copies = 0;
+ A::n_moves = 0;
+ {
+ A a(5);
+ std::packaged_task<double(int, char)> p(std::allocator_arg,
+ test_allocator<A>(), a);
+ assert(test_alloc_base::count > 0);
+ assert(p.valid());
+ std::future<double> f = p.get_future();
+ p(3, 'a');
+ assert(f.get() == 105.0);
+ assert(A::n_copies > 0);
+ assert(A::n_moves > 0);
+ }
+ assert(test_alloc_base::count == 0);
+ A::n_copies = 0;
+ A::n_moves = 0;
+ {
+ A a(5);
+ std::packaged_task<int(int)> p(std::allocator_arg, test_allocator<A>(), &func);
+ assert(test_alloc_base::count > 0);
+ assert(p.valid());
+ std::future<int> f = p.get_future();
+ p(4);
+ assert(f.get() == 4);
+ }
+ assert(test_alloc_base::count == 0);
+ A::n_copies = 0;
+ A::n_moves = 0;
+ {
+ A a(5);
+ std::packaged_task<int(int)> p(std::allocator_arg, test_allocator<A>(), func);
+ assert(test_alloc_base::count > 0);
+ assert(p.valid());
+ std::future<int> f = p.get_future();
+ p(4);
+ assert(f.get() == 4);
+ }
+ assert(test_alloc_base::count == 0);
+ A::n_copies = 0;
+ A::n_moves = 0;
+ {
+ std::packaged_task<double(int, char)> p(std::allocator_arg,
+ bare_allocator<void>(), A(5));
+ assert(p.valid());
+ std::future<double> f = p.get_future();
+ p(3, 'a');
+ assert(f.get() == 105.0);
+ assert(A::n_copies == 0);
+ assert(A::n_moves > 0);
+ }
+ A::n_copies = 0;
+ A::n_moves = 0;
+ {
+ std::packaged_task<double(int, char)> p(std::allocator_arg,
+ min_allocator<void>(), A(5));
+ assert(p.valid());
+ std::future<double> f = p.get_future();
+ p(3, 'a');
+ assert(f.get() == 105.0);
+ assert(A::n_copies == 0);
+ assert(A::n_moves > 0);
+ }
+ A::n_copies = 0;
+ A::n_moves = 0;
+}
diff --git a/test/std/thread/futures/futures.tas/futures.task.members/ctor_move.pass.cpp b/test/std/thread/futures/futures.tas/futures.task.members/ctor_move.pass.cpp
new file mode 100644
index 000000000000..88f072281750
--- /dev/null
+++ b/test/std/thread/futures/futures.tas/futures.task.members/ctor_move.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <future>
+
+// class packaged_task<R(ArgTypes...)>
+
+// packaged_task(packaged_task&& other);
+
+#include <future>
+#include <cassert>
+
+class A
+{
+ long data_;
+
+public:
+ explicit A(long i) : data_(i) {}
+
+ long operator()(long i, long j) const {return data_ + i + j;}
+};
+
+int main()
+{
+ {
+ std::packaged_task<double(int, char)> p0(A(5));
+ std::packaged_task<double(int, char)> p = std::move(p0);
+ assert(!p0.valid());
+ assert(p.valid());
+ std::future<double> f = p.get_future();
+ p(3, 'a');
+ assert(f.get() == 105.0);
+ }
+ {
+ std::packaged_task<double(int, char)> p0;
+ std::packaged_task<double(int, char)> p = std::move(p0);
+ assert(!p0.valid());
+ assert(!p.valid());
+ }
+}
diff --git a/test/std/thread/futures/futures.tas/futures.task.members/dtor.pass.cpp b/test/std/thread/futures/futures.tas/futures.task.members/dtor.pass.cpp
new file mode 100644
index 000000000000..e24232d1b227
--- /dev/null
+++ b/test/std/thread/futures/futures.tas/futures.task.members/dtor.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <future>
+
+// class packaged_task<R(ArgTypes...)>
+
+// ~packaged_task();
+
+#include <future>
+#include <cassert>
+
+class A
+{
+ long data_;
+
+public:
+ explicit A(long i) : data_(i) {}
+
+ long operator()(long i, long j) const {return data_ + i + j;}
+};
+
+void func(std::packaged_task<double(int, char)> p)
+{
+}
+
+void func2(std::packaged_task<double(int, char)> p)
+{
+ p(3, 'a');
+}
+
+int main()
+{
+ {
+ std::packaged_task<double(int, char)> p(A(5));
+ std::future<double> f = p.get_future();
+ std::thread(func, std::move(p)).detach();
+ try
+ {
+ double i = f.get();
+ assert(false);
+ }
+ catch (const std::future_error& e)
+ {
+ assert(e.code() == make_error_code(std::future_errc::broken_promise));
+ }
+ }
+ {
+ std::packaged_task<double(int, char)> p(A(5));
+ std::future<double> f = p.get_future();
+ std::thread(func2, std::move(p)).detach();
+ assert(f.get() == 105.0);
+ }
+}
diff --git a/test/std/thread/futures/futures.tas/futures.task.members/get_future.pass.cpp b/test/std/thread/futures/futures.tas/futures.task.members/get_future.pass.cpp
new file mode 100644
index 000000000000..13b5db110668
--- /dev/null
+++ b/test/std/thread/futures/futures.tas/futures.task.members/get_future.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <future>
+
+// class packaged_task<R(ArgTypes...)>
+
+// future<R> get_future();
+
+#include <future>
+#include <cassert>
+
+class A
+{
+ long data_;
+
+public:
+ explicit A(long i) : data_(i) {}
+
+ long operator()(long i, long j) const {return data_ + i + j;}
+};
+
+int main()
+{
+ {
+ std::packaged_task<double(int, char)> p(A(5));
+ std::future<double> f = p.get_future();
+ p(3, 'a');
+ assert(f.get() == 105.0);
+ }
+ {
+ std::packaged_task<double(int, char)> p(A(5));
+ std::future<double> f = p.get_future();
+ try
+ {
+ f = p.get_future();
+ assert(false);
+ }
+ catch (const std::future_error& e)
+ {
+ assert(e.code() == make_error_code(std::future_errc::future_already_retrieved));
+ }
+ }
+ {
+ std::packaged_task<double(int, char)> p;
+ try
+ {
+ std::future<double> f = p.get_future();
+ assert(false);
+ }
+ catch (const std::future_error& e)
+ {
+ assert(e.code() == make_error_code(std::future_errc::no_state));
+ }
+ }
+}
diff --git a/test/std/thread/futures/futures.tas/futures.task.members/make_ready_at_thread_exit.pass.cpp b/test/std/thread/futures/futures.tas/futures.task.members/make_ready_at_thread_exit.pass.cpp
new file mode 100644
index 000000000000..61a6a4f87965
--- /dev/null
+++ b/test/std/thread/futures/futures.tas/futures.task.members/make_ready_at_thread_exit.pass.cpp
@@ -0,0 +1,106 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <future>
+
+// class packaged_task<R(ArgTypes...)>
+
+// void make_ready_at_thread_exit(ArgTypes... args);
+
+#include <future>
+#include <cassert>
+
+class A
+{
+ long data_;
+
+public:
+ explicit A(long i) : data_(i) {}
+
+ long operator()(long i, long j) const
+ {
+ if (j == 'z')
+ throw A(6);
+ return data_ + i + j;
+ }
+};
+
+void func0(std::packaged_task<double(int, char)> p)
+{
+ std::this_thread::sleep_for(std::chrono::milliseconds(500));
+ p.make_ready_at_thread_exit(3, 'a');
+}
+
+void func1(std::packaged_task<double(int, char)> p)
+{
+ std::this_thread::sleep_for(std::chrono::milliseconds(500));
+ p.make_ready_at_thread_exit(3, 'z');
+}
+
+void func2(std::packaged_task<double(int, char)> p)
+{
+ p.make_ready_at_thread_exit(3, 'a');
+ try
+ {
+ p.make_ready_at_thread_exit(3, 'c');
+ }
+ catch (const std::future_error& e)
+ {
+ assert(e.code() == make_error_code(std::future_errc::promise_already_satisfied));
+ }
+}
+
+void func3(std::packaged_task<double(int, char)> p)
+{
+ try
+ {
+ p.make_ready_at_thread_exit(3, 'a');
+ }
+ catch (const std::future_error& e)
+ {
+ assert(e.code() == make_error_code(std::future_errc::no_state));
+ }
+}
+
+int main()
+{
+ {
+ std::packaged_task<double(int, char)> p(A(5));
+ std::future<double> f = p.get_future();
+ std::thread(func0, std::move(p)).detach();
+ assert(f.get() == 105.0);
+ }
+ {
+ std::packaged_task<double(int, char)> p(A(5));
+ std::future<double> f = p.get_future();
+ std::thread(func1, std::move(p)).detach();
+ try
+ {
+ f.get();
+ assert(false);
+ }
+ catch (const A& e)
+ {
+ assert(e(3, 'a') == 106);
+ }
+ }
+ {
+ std::packaged_task<double(int, char)> p(A(5));
+ std::future<double> f = p.get_future();
+ std::thread(func2, std::move(p)).detach();
+ assert(f.get() == 105.0);
+ }
+ {
+ std::packaged_task<double(int, char)> p;
+ std::thread t(func3, std::move(p));
+ t.join();
+ }
+}
diff --git a/test/std/thread/futures/futures.tas/futures.task.members/operator.pass.cpp b/test/std/thread/futures/futures.tas/futures.task.members/operator.pass.cpp
new file mode 100644
index 000000000000..2a09353b1e63
--- /dev/null
+++ b/test/std/thread/futures/futures.tas/futures.task.members/operator.pass.cpp
@@ -0,0 +1,107 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <future>
+
+// class packaged_task<R(ArgTypes...)>
+
+// void operator()(ArgTypes... args);
+
+#include <future>
+#include <cassert>
+
+class A
+{
+ long data_;
+
+public:
+ explicit A(long i) : data_(i) {}
+
+ long operator()(long i, long j) const
+ {
+ if (j == 'z')
+ throw A(6);
+ return data_ + i + j;
+ }
+};
+
+void func0(std::packaged_task<double(int, char)> p)
+{
+ std::this_thread::sleep_for(std::chrono::milliseconds(500));
+ p(3, 'a');
+}
+
+void func1(std::packaged_task<double(int, char)> p)
+{
+ std::this_thread::sleep_for(std::chrono::milliseconds(500));
+ p(3, 'z');
+}
+
+void func2(std::packaged_task<double(int, char)> p)
+{
+ p(3, 'a');
+ try
+ {
+ p(3, 'c');
+ }
+ catch (const std::future_error& e)
+ {
+ assert(e.code() == make_error_code(std::future_errc::promise_already_satisfied));
+ }
+}
+
+void func3(std::packaged_task<double(int, char)> p)
+{
+ try
+ {
+ p(3, 'a');
+ }
+ catch (const std::future_error& e)
+ {
+ assert(e.code() == make_error_code(std::future_errc::no_state));
+ }
+}
+
+int main()
+{
+ {
+ std::packaged_task<double(int, char)> p(A(5));
+ std::future<double> f = p.get_future();
+ std::thread(func0, std::move(p)).detach();
+ assert(f.get() == 105.0);
+ }
+ {
+ std::packaged_task<double(int, char)> p(A(5));
+ std::future<double> f = p.get_future();
+ std::thread(func1, std::move(p)).detach();
+ try
+ {
+ f.get();
+ assert(false);
+ }
+ catch (const A& e)
+ {
+ assert(e(3, 'a') == 106);
+ }
+ }
+ {
+ std::packaged_task<double(int, char)> p(A(5));
+ std::future<double> f = p.get_future();
+ std::thread t(func2, std::move(p));
+ assert(f.get() == 105.0);
+ t.join();
+ }
+ {
+ std::packaged_task<double(int, char)> p;
+ std::thread t(func3, std::move(p));
+ t.join();
+ }
+}
diff --git a/test/std/thread/futures/futures.tas/futures.task.members/reset.pass.cpp b/test/std/thread/futures/futures.tas/futures.task.members/reset.pass.cpp
new file mode 100644
index 000000000000..9d38d9b409c0
--- /dev/null
+++ b/test/std/thread/futures/futures.tas/futures.task.members/reset.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <future>
+
+// class packaged_task<R(ArgTypes...)>
+
+// void reset();
+
+#include <future>
+#include <cassert>
+
+class A
+{
+ long data_;
+
+public:
+ explicit A(long i) : data_(i) {}
+
+ long operator()(long i, long j) const
+ {
+ if (j == 'z')
+ throw A(6);
+ return data_ + i + j;
+ }
+};
+
+int main()
+{
+ {
+ std::packaged_task<double(int, char)> p(A(5));
+ std::future<double> f = p.get_future();
+ p(3, 'a');
+ assert(f.get() == 105.0);
+ p.reset();
+ p(4, 'a');
+ f = p.get_future();
+ assert(f.get() == 106.0);
+ }
+ {
+ std::packaged_task<double(int, char)> p;
+ try
+ {
+ p.reset();
+ assert(false);
+ }
+ catch (const std::future_error& e)
+ {
+ assert(e.code() == make_error_code(std::future_errc::no_state));
+ }
+ }
+}
diff --git a/test/std/thread/futures/futures.tas/futures.task.members/swap.pass.cpp b/test/std/thread/futures/futures.tas/futures.task.members/swap.pass.cpp
new file mode 100644
index 000000000000..33763bef0d0f
--- /dev/null
+++ b/test/std/thread/futures/futures.tas/futures.task.members/swap.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <future>
+
+// class packaged_task<R(ArgTypes...)>
+
+// void swap(packaged_task& other);
+
+#include <future>
+#include <cassert>
+
+class A
+{
+ long data_;
+
+public:
+ explicit A(long i) : data_(i) {}
+
+ long operator()(long i, long j) const {return data_ + i + j;}
+};
+
+int main()
+{
+ {
+ std::packaged_task<double(int, char)> p0(A(5));
+ std::packaged_task<double(int, char)> p;
+ p.swap(p0);
+ assert(!p0.valid());
+ assert(p.valid());
+ std::future<double> f = p.get_future();
+ p(3, 'a');
+ assert(f.get() == 105.0);
+ }
+ {
+ std::packaged_task<double(int, char)> p0;
+ std::packaged_task<double(int, char)> p;
+ p.swap(p0);
+ assert(!p0.valid());
+ assert(!p.valid());
+ }
+}
diff --git a/test/std/thread/futures/futures.tas/futures.task.nonmembers/swap.pass.cpp b/test/std/thread/futures/futures.tas/futures.task.nonmembers/swap.pass.cpp
new file mode 100644
index 000000000000..668732b9b24a
--- /dev/null
+++ b/test/std/thread/futures/futures.tas/futures.task.nonmembers/swap.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <future>
+
+// class packaged_task<R(ArgTypes...)>
+
+// template <class R, class... ArgTypes>
+// void
+// swap(packaged_task<R(ArgTypes...)>& x, packaged_task<R(ArgTypes...)>& y);
+
+#include <future>
+#include <cassert>
+
+class A
+{
+ long data_;
+
+public:
+ explicit A(long i) : data_(i) {}
+
+ long operator()(long i, long j) const {return data_ + i + j;}
+};
+
+int main()
+{
+ {
+ std::packaged_task<double(int, char)> p0(A(5));
+ std::packaged_task<double(int, char)> p;
+ swap(p, p0);
+ assert(!p0.valid());
+ assert(p.valid());
+ std::future<double> f = p.get_future();
+ p(3, 'a');
+ assert(f.get() == 105.0);
+ }
+ {
+ std::packaged_task<double(int, char)> p0;
+ std::packaged_task<double(int, char)> p;
+ swap(p, p0);
+ assert(!p0.valid());
+ assert(!p.valid());
+ }
+}
diff --git a/test/std/thread/futures/futures.tas/futures.task.nonmembers/uses_allocator.pass.cpp b/test/std/thread/futures/futures.tas/futures.task.nonmembers/uses_allocator.pass.cpp
new file mode 100644
index 000000000000..986f71e29a46
--- /dev/null
+++ b/test/std/thread/futures/futures.tas/futures.task.nonmembers/uses_allocator.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <future>
+
+// class packaged_task<R(ArgTypes...)>
+
+// template <class Callable, class Alloc>
+// struct uses_allocator<packaged_task<Callable>, Alloc>
+// : true_type { };
+
+#include <future>
+#include "../../test_allocator.h"
+
+int main()
+{
+ static_assert((std::uses_allocator<std::packaged_task<double(int, char)>, test_allocator<int> >::value), "");
+}
diff --git a/test/std/thread/futures/futures.tas/types.pass.cpp b/test/std/thread/futures/futures.tas/types.pass.cpp
new file mode 100644
index 000000000000..dd1724ddbda5
--- /dev/null
+++ b/test/std/thread/futures/futures.tas/types.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <future>
+
+// template<class R, class... ArgTypes>
+// class packaged_task<R(ArgTypes...)>
+// {
+// public:
+// typedef R result_type;
+
+#include <future>
+#include <type_traits>
+
+struct A {};
+
+int main()
+{
+ static_assert((std::is_same<std::packaged_task<A(int, char)>::result_type, A>::value), "");
+}
diff --git a/test/std/thread/futures/futures.unique_future/copy_assign.fail.cpp b/test/std/thread/futures/futures.unique_future/copy_assign.fail.cpp
new file mode 100644
index 000000000000..ebdcbf98d996
--- /dev/null
+++ b/test/std/thread/futures/futures.unique_future/copy_assign.fail.cpp
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+// class future<R>
+
+// future& operator=(const future&) = delete;
+
+#include <future>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef int T;
+ std::promise<T> p;
+ std::future<T> f0 = p.get_future();
+ std::future<T> f;
+ f = f0;
+ assert(!f0.valid());
+ assert(f.valid());
+ }
+ {
+ typedef int T;
+ std::future<T> f0;
+ std::future<T> f;
+ f = f0;
+ assert(!f0.valid());
+ assert(!f.valid());
+ }
+ {
+ typedef int& T;
+ std::promise<T> p;
+ std::future<T> f0 = p.get_future();
+ std::future<T> f;
+ f = f0;
+ assert(!f0.valid());
+ assert(f.valid());
+ }
+ {
+ typedef int& T;
+ std::future<T> f0;
+ std::future<T> f;
+ f = f0;
+ assert(!f0.valid());
+ assert(!f.valid());
+ }
+ {
+ typedef void T;
+ std::promise<T> p;
+ std::future<T> f0 = p.get_future();
+ std::future<T> f;
+ f = f0;
+ assert(!f0.valid());
+ assert(f.valid());
+ }
+ {
+ typedef void T;
+ std::future<T> f0;
+ std::future<T> f;
+ f = f0;
+ assert(!f0.valid());
+ assert(!f.valid());
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/thread/futures/futures.unique_future/copy_ctor.fail.cpp b/test/std/thread/futures/futures.unique_future/copy_ctor.fail.cpp
new file mode 100644
index 000000000000..8d43294edc26
--- /dev/null
+++ b/test/std/thread/futures/futures.unique_future/copy_ctor.fail.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+// class future<R>
+
+// future(const future&) = delete;
+
+#include <future>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ std::promise<T> p;
+ std::future<T> f0 = p.get_future();
+ std::future<T> f = f0;
+ assert(!f0.valid());
+ assert(f.valid());
+ }
+ {
+ typedef int T;
+ std::future<T> f0;
+ std::future<T> f = f0;
+ assert(!f0.valid());
+ assert(!f.valid());
+ }
+ {
+ typedef int& T;
+ std::promise<T> p;
+ std::future<T> f0 = p.get_future();
+ std::future<T> f = f0;
+ assert(!f0.valid());
+ assert(f.valid());
+ }
+ {
+ typedef int& T;
+ std::future<T> f0;
+ std::future<T> f = std::move(f0);
+ assert(!f0.valid());
+ assert(!f.valid());
+ }
+ {
+ typedef void T;
+ std::promise<T> p;
+ std::future<T> f0 = p.get_future();
+ std::future<T> f = f0;
+ assert(!f0.valid());
+ assert(f.valid());
+ }
+ {
+ typedef void T;
+ std::future<T> f0;
+ std::future<T> f = f0;
+ assert(!f0.valid());
+ assert(!f.valid());
+ }
+}
diff --git a/test/std/thread/futures/futures.unique_future/default.pass.cpp b/test/std/thread/futures/futures.unique_future/default.pass.cpp
new file mode 100644
index 000000000000..84cb84650dcd
--- /dev/null
+++ b/test/std/thread/futures/futures.unique_future/default.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <future>
+
+// class future<R>
+
+// future();
+
+#include <future>
+#include <cassert>
+
+int main()
+{
+ {
+ std::future<int> f;
+ assert(!f.valid());
+ }
+ {
+ std::future<int&> f;
+ assert(!f.valid());
+ }
+ {
+ std::future<void> f;
+ assert(!f.valid());
+ }
+}
diff --git a/test/std/thread/futures/futures.unique_future/dtor.pass.cpp b/test/std/thread/futures/futures.unique_future/dtor.pass.cpp
new file mode 100644
index 000000000000..5e9697bb939b
--- /dev/null
+++ b/test/std/thread/futures/futures.unique_future/dtor.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <future>
+
+// class future<R>
+
+// ~future();
+
+#include <future>
+#include <cassert>
+
+#include "../test_allocator.h"
+
+int main()
+{
+ assert(test_alloc_base::count == 0);
+ {
+ typedef int T;
+ std::future<T> f;
+ {
+ std::promise<T> p(std::allocator_arg, test_allocator<T>());
+ assert(test_alloc_base::count == 1);
+ f = p.get_future();
+ assert(test_alloc_base::count == 1);
+ assert(f.valid());
+ }
+ assert(test_alloc_base::count == 1);
+ assert(f.valid());
+ }
+ assert(test_alloc_base::count == 0);
+ {
+ typedef int& T;
+ std::future<T> f;
+ {
+ std::promise<T> p(std::allocator_arg, test_allocator<int>());
+ assert(test_alloc_base::count == 1);
+ f = p.get_future();
+ assert(test_alloc_base::count == 1);
+ assert(f.valid());
+ }
+ assert(test_alloc_base::count == 1);
+ assert(f.valid());
+ }
+ assert(test_alloc_base::count == 0);
+ {
+ typedef void T;
+ std::future<T> f;
+ {
+ std::promise<T> p(std::allocator_arg, test_allocator<T>());
+ assert(test_alloc_base::count == 1);
+ f = p.get_future();
+ assert(test_alloc_base::count == 1);
+ assert(f.valid());
+ }
+ assert(test_alloc_base::count == 1);
+ assert(f.valid());
+ }
+ assert(test_alloc_base::count == 0);
+}
diff --git a/test/std/thread/futures/futures.unique_future/get.pass.cpp b/test/std/thread/futures/futures.unique_future/get.pass.cpp
new file mode 100644
index 000000000000..758e38a7dae9
--- /dev/null
+++ b/test/std/thread/futures/futures.unique_future/get.pass.cpp
@@ -0,0 +1,145 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <future>
+
+// class future<R>
+
+// R future::get();
+// R& future<R&>::get();
+// void future<void>::get();
+
+#include <future>
+#include <cassert>
+
+void func1(std::promise<int> p)
+{
+ std::this_thread::sleep_for(std::chrono::milliseconds(500));
+ p.set_value(3);
+}
+
+void func2(std::promise<int> p)
+{
+ std::this_thread::sleep_for(std::chrono::milliseconds(500));
+ p.set_exception(std::make_exception_ptr(3));
+}
+
+int j = 0;
+
+void func3(std::promise<int&> p)
+{
+ std::this_thread::sleep_for(std::chrono::milliseconds(500));
+ j = 5;
+ p.set_value(j);
+}
+
+void func4(std::promise<int&> p)
+{
+ std::this_thread::sleep_for(std::chrono::milliseconds(500));
+ p.set_exception(std::make_exception_ptr(3.5));
+}
+
+void func5(std::promise<void> p)
+{
+ std::this_thread::sleep_for(std::chrono::milliseconds(500));
+ p.set_value();
+}
+
+void func6(std::promise<void> p)
+{
+ std::this_thread::sleep_for(std::chrono::milliseconds(500));
+ p.set_exception(std::make_exception_ptr('c'));
+}
+
+int main()
+{
+ {
+ typedef int T;
+ {
+ std::promise<T> p;
+ std::future<T> f = p.get_future();
+ std::thread(func1, std::move(p)).detach();
+ assert(f.valid());
+ assert(f.get() == 3);
+ assert(!f.valid());
+ }
+ {
+ std::promise<T> p;
+ std::future<T> f = p.get_future();
+ std::thread(func2, std::move(p)).detach();
+ try
+ {
+ assert(f.valid());
+ assert(f.get() == 3);
+ assert(false);
+ }
+ catch (int i)
+ {
+ assert(i == 3);
+ }
+ assert(!f.valid());
+ }
+ }
+ {
+ typedef int& T;
+ {
+ std::promise<T> p;
+ std::future<T> f = p.get_future();
+ std::thread(func3, std::move(p)).detach();
+ assert(f.valid());
+ assert(f.get() == 5);
+ assert(!f.valid());
+ }
+ {
+ std::promise<T> p;
+ std::future<T> f = p.get_future();
+ std::thread(func4, std::move(p)).detach();
+ try
+ {
+ assert(f.valid());
+ assert(f.get() == 3);
+ assert(false);
+ }
+ catch (double i)
+ {
+ assert(i == 3.5);
+ }
+ assert(!f.valid());
+ }
+ }
+ {
+ typedef void T;
+ {
+ std::promise<T> p;
+ std::future<T> f = p.get_future();
+ std::thread(func5, std::move(p)).detach();
+ assert(f.valid());
+ f.get();
+ assert(!f.valid());
+ }
+ {
+ std::promise<T> p;
+ std::future<T> f = p.get_future();
+ std::thread(func6, std::move(p)).detach();
+ try
+ {
+ assert(f.valid());
+ f.get();
+ assert(false);
+ }
+ catch (char i)
+ {
+ assert(i == 'c');
+ }
+ assert(!f.valid());
+ }
+ }
+}
diff --git a/test/std/thread/futures/futures.unique_future/move_assign.pass.cpp b/test/std/thread/futures/futures.unique_future/move_assign.pass.cpp
new file mode 100644
index 000000000000..8d38b81f0cda
--- /dev/null
+++ b/test/std/thread/futures/futures.unique_future/move_assign.pass.cpp
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <future>
+
+// class future<R>
+
+// future& operator=(future&& rhs);
+
+#include <future>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef int T;
+ std::promise<T> p;
+ std::future<T> f0 = p.get_future();
+ std::future<T> f;
+ f = std::move(f0);
+ assert(!f0.valid());
+ assert(f.valid());
+ }
+ {
+ typedef int T;
+ std::future<T> f0;
+ std::future<T> f;
+ f = std::move(f0);
+ assert(!f0.valid());
+ assert(!f.valid());
+ }
+ {
+ typedef int& T;
+ std::promise<T> p;
+ std::future<T> f0 = p.get_future();
+ std::future<T> f;
+ f = std::move(f0);
+ assert(!f0.valid());
+ assert(f.valid());
+ }
+ {
+ typedef int& T;
+ std::future<T> f0;
+ std::future<T> f;
+ f = std::move(f0);
+ assert(!f0.valid());
+ assert(!f.valid());
+ }
+ {
+ typedef void T;
+ std::promise<T> p;
+ std::future<T> f0 = p.get_future();
+ std::future<T> f;
+ f = std::move(f0);
+ assert(!f0.valid());
+ assert(f.valid());
+ }
+ {
+ typedef void T;
+ std::future<T> f0;
+ std::future<T> f;
+ f = std::move(f0);
+ assert(!f0.valid());
+ assert(!f.valid());
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/thread/futures/futures.unique_future/move_ctor.pass.cpp b/test/std/thread/futures/futures.unique_future/move_ctor.pass.cpp
new file mode 100644
index 000000000000..e12c920886fa
--- /dev/null
+++ b/test/std/thread/futures/futures.unique_future/move_ctor.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <future>
+
+// class future<R>
+
+// future(future&& rhs);
+
+#include <future>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef int T;
+ std::promise<T> p;
+ std::future<T> f0 = p.get_future();
+ std::future<T> f = std::move(f0);
+ assert(!f0.valid());
+ assert(f.valid());
+ }
+ {
+ typedef int T;
+ std::future<T> f0;
+ std::future<T> f = std::move(f0);
+ assert(!f0.valid());
+ assert(!f.valid());
+ }
+ {
+ typedef int& T;
+ std::promise<T> p;
+ std::future<T> f0 = p.get_future();
+ std::future<T> f = std::move(f0);
+ assert(!f0.valid());
+ assert(f.valid());
+ }
+ {
+ typedef int& T;
+ std::future<T> f0;
+ std::future<T> f = std::move(f0);
+ assert(!f0.valid());
+ assert(!f.valid());
+ }
+ {
+ typedef void T;
+ std::promise<T> p;
+ std::future<T> f0 = p.get_future();
+ std::future<T> f = std::move(f0);
+ assert(!f0.valid());
+ assert(f.valid());
+ }
+ {
+ typedef void T;
+ std::future<T> f0;
+ std::future<T> f = std::move(f0);
+ assert(!f0.valid());
+ assert(!f.valid());
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/thread/futures/futures.unique_future/share.pass.cpp b/test/std/thread/futures/futures.unique_future/share.pass.cpp
new file mode 100644
index 000000000000..794b5ce38feb
--- /dev/null
+++ b/test/std/thread/futures/futures.unique_future/share.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <future>
+
+// class future<R>
+
+// shared_future<R> share() &&;
+
+#include <future>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ std::promise<T> p;
+ std::future<T> f0 = p.get_future();
+ std::shared_future<T> f = std::move(f0.share());
+ assert(!f0.valid());
+ assert(f.valid());
+ }
+ {
+ typedef int T;
+ std::future<T> f0;
+ std::shared_future<T> f = std::move(f0.share());
+ assert(!f0.valid());
+ assert(!f.valid());
+ }
+ {
+ typedef int& T;
+ std::promise<T> p;
+ std::future<T> f0 = p.get_future();
+ std::shared_future<T> f = std::move(f0.share());
+ assert(!f0.valid());
+ assert(f.valid());
+ }
+ {
+ typedef int& T;
+ std::future<T> f0;
+ std::shared_future<T> f = std::move(f0.share());
+ assert(!f0.valid());
+ assert(!f.valid());
+ }
+ {
+ typedef void T;
+ std::promise<T> p;
+ std::future<T> f0 = p.get_future();
+ std::shared_future<T> f = std::move(f0.share());
+ assert(!f0.valid());
+ assert(f.valid());
+ }
+ {
+ typedef void T;
+ std::future<T> f0;
+ std::shared_future<T> f = std::move(f0.share());
+ assert(!f0.valid());
+ assert(!f.valid());
+ }
+}
diff --git a/test/std/thread/futures/futures.unique_future/wait.pass.cpp b/test/std/thread/futures/futures.unique_future/wait.pass.cpp
new file mode 100644
index 000000000000..e10d37cf8064
--- /dev/null
+++ b/test/std/thread/futures/futures.unique_future/wait.pass.cpp
@@ -0,0 +1,88 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <future>
+
+// class future<R>
+
+// void wait() const;
+
+#include <future>
+#include <cassert>
+
+void func1(std::promise<int> p)
+{
+ std::this_thread::sleep_for(std::chrono::milliseconds(500));
+ p.set_value(3);
+}
+
+int j = 0;
+
+void func3(std::promise<int&> p)
+{
+ std::this_thread::sleep_for(std::chrono::milliseconds(500));
+ j = 5;
+ p.set_value(j);
+}
+
+void func5(std::promise<void> p)
+{
+ std::this_thread::sleep_for(std::chrono::milliseconds(500));
+ p.set_value();
+}
+
+int main()
+{
+ typedef std::chrono::high_resolution_clock Clock;
+ typedef std::chrono::duration<double, std::milli> ms;
+ {
+ typedef int T;
+ std::promise<T> p;
+ std::future<T> f = p.get_future();
+ std::thread(func1, std::move(p)).detach();
+ assert(f.valid());
+ f.wait();
+ assert(f.valid());
+ Clock::time_point t0 = Clock::now();
+ f.wait();
+ Clock::time_point t1 = Clock::now();
+ assert(f.valid());
+ assert(t1-t0 < ms(5));
+ }
+ {
+ typedef int& T;
+ std::promise<T> p;
+ std::future<T> f = p.get_future();
+ std::thread(func3, std::move(p)).detach();
+ assert(f.valid());
+ f.wait();
+ assert(f.valid());
+ Clock::time_point t0 = Clock::now();
+ f.wait();
+ Clock::time_point t1 = Clock::now();
+ assert(f.valid());
+ assert(t1-t0 < ms(5));
+ }
+ {
+ typedef void T;
+ std::promise<T> p;
+ std::future<T> f = p.get_future();
+ std::thread(func5, std::move(p)).detach();
+ assert(f.valid());
+ f.wait();
+ assert(f.valid());
+ Clock::time_point t0 = Clock::now();
+ f.wait();
+ Clock::time_point t1 = Clock::now();
+ assert(f.valid());
+ assert(t1-t0 < ms(5));
+ }
+}
diff --git a/test/std/thread/futures/futures.unique_future/wait_for.pass.cpp b/test/std/thread/futures/futures.unique_future/wait_for.pass.cpp
new file mode 100644
index 000000000000..0a381d9ca2f0
--- /dev/null
+++ b/test/std/thread/futures/futures.unique_future/wait_for.pass.cpp
@@ -0,0 +1,97 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <future>
+
+// class future<R>
+
+// template <class Rep, class Period>
+// future_status
+// wait_for(const chrono::duration<Rep, Period>& rel_time) const;
+
+#include <future>
+#include <cassert>
+
+typedef std::chrono::milliseconds ms;
+
+void func1(std::promise<int> p)
+{
+ std::this_thread::sleep_for(ms(500));
+ p.set_value(3);
+}
+
+int j = 0;
+
+void func3(std::promise<int&> p)
+{
+ std::this_thread::sleep_for(ms(500));
+ j = 5;
+ p.set_value(j);
+}
+
+void func5(std::promise<void> p)
+{
+ std::this_thread::sleep_for(ms(500));
+ p.set_value();
+}
+
+int main()
+{
+ typedef std::chrono::high_resolution_clock Clock;
+ {
+ typedef int T;
+ std::promise<T> p;
+ std::future<T> f = p.get_future();
+ std::thread(func1, std::move(p)).detach();
+ assert(f.valid());
+ assert(f.wait_for(ms(300)) == std::future_status::timeout);
+ assert(f.valid());
+ assert(f.wait_for(ms(300)) == std::future_status::ready);
+ assert(f.valid());
+ Clock::time_point t0 = Clock::now();
+ f.wait();
+ Clock::time_point t1 = Clock::now();
+ assert(f.valid());
+ assert(t1-t0 < ms(50));
+ }
+ {
+ typedef int& T;
+ std::promise<T> p;
+ std::future<T> f = p.get_future();
+ std::thread(func3, std::move(p)).detach();
+ assert(f.valid());
+ assert(f.wait_for(ms(300)) == std::future_status::timeout);
+ assert(f.valid());
+ assert(f.wait_for(ms(300)) == std::future_status::ready);
+ assert(f.valid());
+ Clock::time_point t0 = Clock::now();
+ f.wait();
+ Clock::time_point t1 = Clock::now();
+ assert(f.valid());
+ assert(t1-t0 < ms(50));
+ }
+ {
+ typedef void T;
+ std::promise<T> p;
+ std::future<T> f = p.get_future();
+ std::thread(func5, std::move(p)).detach();
+ assert(f.valid());
+ assert(f.wait_for(ms(300)) == std::future_status::timeout);
+ assert(f.valid());
+ assert(f.wait_for(ms(300)) == std::future_status::ready);
+ assert(f.valid());
+ Clock::time_point t0 = Clock::now();
+ f.wait();
+ Clock::time_point t1 = Clock::now();
+ assert(f.valid());
+ assert(t1-t0 < ms(50));
+ }
+}
diff --git a/test/std/thread/futures/futures.unique_future/wait_until.pass.cpp b/test/std/thread/futures/futures.unique_future/wait_until.pass.cpp
new file mode 100644
index 000000000000..d5865b9b9dcf
--- /dev/null
+++ b/test/std/thread/futures/futures.unique_future/wait_until.pass.cpp
@@ -0,0 +1,129 @@
+ //===----------------------------------------------------------------------===//
+ //
+ // The LLVM Compiler Infrastructure
+ //
+ // This file is dual licensed under the MIT and the University of Illinois Open
+ // Source Licenses. See LICENSE.TXT for details.
+ //
+ //===----------------------------------------------------------------------===//
+ //
+ // UNSUPPORTED: libcpp-has-no-threads
+
+ // <future>
+
+ // class future<R>
+
+ // template <class Clock, class Duration>
+ // future_status
+ // wait_until(const chrono::time_point<Clock, Duration>& abs_time) const;
+
+ #include <future>
+ #include <atomic>
+ #include <cassert>
+
+ enum class WorkerThreadState { Uninitialized, AllowedToRun, Exiting };
+ typedef std::chrono::milliseconds ms;
+
+ std::atomic<WorkerThreadState> thread_state(WorkerThreadState::Uninitialized);
+
+ void set_worker_thread_state(WorkerThreadState state)
+ {
+ thread_state.store(state, std::memory_order_relaxed);
+ }
+
+ void wait_for_worker_thread_state(WorkerThreadState state)
+ {
+ while (thread_state.load(std::memory_order_relaxed) != state);
+ }
+
+ void func1(std::promise<int> p)
+ {
+ wait_for_worker_thread_state(WorkerThreadState::AllowedToRun);
+ p.set_value(3);
+ set_worker_thread_state(WorkerThreadState::Exiting);
+ }
+
+ int j = 0;
+
+ void func3(std::promise<int&> p)
+ {
+ wait_for_worker_thread_state(WorkerThreadState::AllowedToRun);
+ j = 5;
+ p.set_value(j);
+ set_worker_thread_state(WorkerThreadState::Exiting);
+ }
+
+ void func5(std::promise<void> p)
+ {
+ wait_for_worker_thread_state(WorkerThreadState::AllowedToRun);
+ p.set_value();
+ set_worker_thread_state(WorkerThreadState::Exiting);
+ }
+
+ int main()
+ {
+ typedef std::chrono::high_resolution_clock Clock;
+ {
+ typedef int T;
+ std::promise<T> p;
+ std::future<T> f = p.get_future();
+ std::thread(func1, std::move(p)).detach();
+ assert(f.valid());
+ assert(f.wait_until(Clock::now() + ms(10)) == std::future_status::timeout);
+ assert(f.valid());
+
+ // allow the worker thread to produce the result and wait until the worker is done
+ set_worker_thread_state(WorkerThreadState::AllowedToRun);
+ wait_for_worker_thread_state(WorkerThreadState::Exiting);
+
+ assert(f.wait_until(Clock::now() + ms(10)) == std::future_status::ready);
+ assert(f.valid());
+ Clock::time_point t0 = Clock::now();
+ f.wait();
+ Clock::time_point t1 = Clock::now();
+ assert(f.valid());
+ assert(t1-t0 < ms(5));
+ }
+ {
+ typedef int& T;
+ std::promise<T> p;
+ std::future<T> f = p.get_future();
+ std::thread(func3, std::move(p)).detach();
+ assert(f.valid());
+ assert(f.wait_until(Clock::now() + ms(10)) == std::future_status::timeout);
+ assert(f.valid());
+
+ // allow the worker thread to produce the result and wait until the worker is done
+ set_worker_thread_state(WorkerThreadState::AllowedToRun);
+ wait_for_worker_thread_state(WorkerThreadState::Exiting);
+
+ assert(f.wait_until(Clock::now() + ms(10)) == std::future_status::ready);
+ assert(f.valid());
+ Clock::time_point t0 = Clock::now();
+ f.wait();
+ Clock::time_point t1 = Clock::now();
+ assert(f.valid());
+ assert(t1-t0 < ms(5));
+ }
+ {
+ typedef void T;
+ std::promise<T> p;
+ std::future<T> f = p.get_future();
+ std::thread(func5, std::move(p)).detach();
+ assert(f.valid());
+ assert(f.wait_until(Clock::now() + ms(10)) == std::future_status::timeout);
+ assert(f.valid());
+
+ // allow the worker thread to produce the result and wait until the worker is done
+ set_worker_thread_state(WorkerThreadState::AllowedToRun);
+ wait_for_worker_thread_state(WorkerThreadState::Exiting);
+
+ assert(f.wait_until(Clock::now() + ms(10)) == std::future_status::ready);
+ assert(f.valid());
+ Clock::time_point t0 = Clock::now();
+ f.wait();
+ Clock::time_point t1 = Clock::now();
+ assert(f.valid());
+ assert(t1-t0 < ms(5));
+ }
+ }
diff --git a/test/std/thread/futures/test_allocator.h b/test/std/thread/futures/test_allocator.h
new file mode 100644
index 000000000000..50072909fa4e
--- /dev/null
+++ b/test/std/thread/futures/test_allocator.h
@@ -0,0 +1,158 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef TEST_ALLOCATOR_H
+#define TEST_ALLOCATOR_H
+
+#include <cstddef>
+#include <type_traits>
+#include <utility>
+#include <cstdlib>
+#include <new>
+#include <climits>
+
+class test_alloc_base
+{
+public:
+ static int count;
+public:
+ static int throw_after;
+};
+
+int test_alloc_base::count = 0;
+int test_alloc_base::throw_after = INT_MAX;
+
+template <class T>
+class test_allocator
+ : public test_alloc_base
+{
+ int data_;
+
+ template <class U> friend class test_allocator;
+public:
+
+ typedef unsigned size_type;
+ typedef int difference_type;
+ typedef T value_type;
+ typedef value_type* pointer;
+ typedef const value_type* const_pointer;
+ typedef typename std::add_lvalue_reference<value_type>::type reference;
+ typedef typename std::add_lvalue_reference<const value_type>::type const_reference;
+
+ template <class U> struct rebind {typedef test_allocator<U> other;};
+
+ test_allocator() throw() : data_(-1) {}
+ explicit test_allocator(int i) throw() : data_(i) {}
+ test_allocator(const test_allocator& a) throw()
+ : data_(a.data_) {}
+ template <class U> test_allocator(const test_allocator<U>& a) throw()
+ : data_(a.data_) {}
+ ~test_allocator() throw() {data_ = 0;}
+ pointer address(reference x) const {return &x;}
+ const_pointer address(const_reference x) const {return &x;}
+ pointer allocate(size_type n, const void* = 0)
+ {
+ if (count >= throw_after) {
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ throw std::bad_alloc();
+#else
+ std::terminate();
+#endif
+ }
+ ++count;
+ return (pointer)std::malloc(n * sizeof(T));
+ }
+ void deallocate(pointer p, size_type n)
+ {--count; std::free(p);}
+ size_type max_size() const throw()
+ {return UINT_MAX / sizeof(T);}
+ void construct(pointer p, const T& val)
+ {::new(p) T(val);}
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ void construct(pointer p, T&& val)
+ {::new(p) T(std::move(val));}
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ void destroy(pointer p) {p->~T();}
+
+ friend bool operator==(const test_allocator& x, const test_allocator& y)
+ {return x.data_ == y.data_;}
+ friend bool operator!=(const test_allocator& x, const test_allocator& y)
+ {return !(x == y);}
+};
+
+template <>
+class test_allocator<void>
+ : public test_alloc_base
+{
+ int data_;
+
+ template <class U> friend class test_allocator;
+public:
+
+ typedef unsigned size_type;
+ typedef int difference_type;
+ typedef void value_type;
+ typedef value_type* pointer;
+ typedef const value_type* const_pointer;
+
+ template <class U> struct rebind {typedef test_allocator<U> other;};
+
+ test_allocator() throw() : data_(-1) {}
+ explicit test_allocator(int i) throw() : data_(i) {}
+ test_allocator(const test_allocator& a) throw()
+ : data_(a.data_) {}
+ template <class U> test_allocator(const test_allocator<U>& a) throw()
+ : data_(a.data_) {}
+ ~test_allocator() throw() {data_ = 0;}
+
+ friend bool operator==(const test_allocator& x, const test_allocator& y)
+ {return x.data_ == y.data_;}
+ friend bool operator!=(const test_allocator& x, const test_allocator& y)
+ {return !(x == y);}
+};
+
+template <class T>
+class other_allocator
+{
+ int data_;
+
+ template <class U> friend class other_allocator;
+
+public:
+ typedef T value_type;
+
+ other_allocator() : data_(-1) {}
+ explicit other_allocator(int i) : data_(i) {}
+ template <class U> other_allocator(const other_allocator<U>& a)
+ : data_(a.data_) {}
+ T* allocate(std::size_t n)
+ {return (T*)std::malloc(n * sizeof(T));}
+ void deallocate(T* p, std::size_t n)
+ {std::free(p);}
+
+ other_allocator select_on_container_copy_construction() const
+ {return other_allocator(-2);}
+
+ friend bool operator==(const other_allocator& x, const other_allocator& y)
+ {return x.data_ == y.data_;}
+ friend bool operator!=(const other_allocator& x, const other_allocator& y)
+ {return !(x == y);}
+
+ typedef std::true_type propagate_on_container_copy_assignment;
+ typedef std::true_type propagate_on_container_move_assignment;
+ typedef std::true_type propagate_on_container_swap;
+
+#ifdef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+ std::size_t max_size() const
+ {return UINT_MAX / sizeof(T);}
+#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE
+
+};
+
+#endif // TEST_ALLOCATOR_H
diff --git a/test/std/thread/futures/version.pass.cpp b/test/std/thread/futures/version.pass.cpp
new file mode 100644
index 000000000000..6730a1477db7
--- /dev/null
+++ b/test/std/thread/futures/version.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <future>
+
+#include <future>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/thread/macro.pass.cpp b/test/std/thread/macro.pass.cpp
new file mode 100644
index 000000000000..c1b1377d6cc3
--- /dev/null
+++ b/test/std/thread/macro.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <thread>
+
+// #define __STDCPP_THREADS__ __cplusplus
+
+#include <thread>
+
+int main()
+{
+#ifndef __STDCPP_THREADS__
+#error __STDCPP_THREADS__ is not defined
+#endif
+}
diff --git a/test/std/thread/thread.condition/cv_status.pass.cpp b/test/std/thread/thread.condition/cv_status.pass.cpp
new file mode 100644
index 000000000000..fe5fa05ad247
--- /dev/null
+++ b/test/std/thread/thread.condition/cv_status.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <condition_variable>
+
+// enum class cv_status { no_timeout, timeout };
+
+#include <condition_variable>
+#include <cassert>
+
+int main()
+{
+ assert(static_cast<int>(std::cv_status::no_timeout) == 0);
+ assert(static_cast<int>(std::cv_status::timeout) == 1);
+}
diff --git a/test/std/thread/thread.condition/notify_all_at_thread_exit.pass.cpp b/test/std/thread/thread.condition/notify_all_at_thread_exit.pass.cpp
new file mode 100644
index 000000000000..2b8772f92ed2
--- /dev/null
+++ b/test/std/thread/thread.condition/notify_all_at_thread_exit.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <condition_variable>
+
+// void
+// notify_all_at_thread_exit(condition_variable& cond, unique_lock<mutex> lk);
+
+#include <condition_variable>
+#include <mutex>
+#include <thread>
+#include <chrono>
+#include <cassert>
+
+std::condition_variable cv;
+std::mutex mut;
+
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::high_resolution_clock Clock;
+
+void func()
+{
+ std::unique_lock<std::mutex> lk(mut);
+ std::notify_all_at_thread_exit(cv, std::move(lk));
+ std::this_thread::sleep_for(ms(300));
+}
+
+int main()
+{
+ std::unique_lock<std::mutex> lk(mut);
+ std::thread(func).detach();
+ Clock::time_point t0 = Clock::now();
+ cv.wait(lk);
+ Clock::time_point t1 = Clock::now();
+ assert(t1-t0 > ms(250));
+}
diff --git a/test/std/thread/thread.condition/thread.condition.condvar/assign.fail.cpp b/test/std/thread/thread.condition/thread.condition.condvar/assign.fail.cpp
new file mode 100644
index 000000000000..e88550c5b8ad
--- /dev/null
+++ b/test/std/thread/thread.condition/thread.condition.condvar/assign.fail.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <condition_variable>
+
+// class condition_variable;
+
+// condition_variable& operator=(const condition_variable&) = delete;
+
+#include <condition_variable>
+#include <cassert>
+
+int main()
+{
+ std::condition_variable cv0;
+ std::condition_variable cv1;
+ cv1 = cv0;
+}
diff --git a/test/std/thread/thread.condition/thread.condition.condvar/copy.fail.cpp b/test/std/thread/thread.condition/thread.condition.condvar/copy.fail.cpp
new file mode 100644
index 000000000000..24d6ee0e71d2
--- /dev/null
+++ b/test/std/thread/thread.condition/thread.condition.condvar/copy.fail.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <condition_variable>
+
+// class condition_variable;
+
+// condition_variable(const condition_variable&) = delete;
+
+#include <condition_variable>
+#include <cassert>
+
+int main()
+{
+ std::condition_variable cv0;
+ std::condition_variable cv1(cv0);
+}
diff --git a/test/std/thread/thread.condition/thread.condition.condvar/default.pass.cpp b/test/std/thread/thread.condition/thread.condition.condvar/default.pass.cpp
new file mode 100644
index 000000000000..6f43564c3b3d
--- /dev/null
+++ b/test/std/thread/thread.condition/thread.condition.condvar/default.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <condition_variable>
+
+// class condition_variable;
+
+// condition_variable();
+
+#include <condition_variable>
+#include <cassert>
+
+int main()
+{
+ std::condition_variable cv;
+}
diff --git a/test/std/thread/thread.condition/thread.condition.condvar/destructor.pass.cpp b/test/std/thread/thread.condition/thread.condition.condvar/destructor.pass.cpp
new file mode 100644
index 000000000000..437ed965b191
--- /dev/null
+++ b/test/std/thread/thread.condition/thread.condition.condvar/destructor.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <condition_variable>
+
+// class condition_variable;
+
+// ~condition_variable();
+
+#include <condition_variable>
+#include <mutex>
+#include <thread>
+#include <cassert>
+
+std::condition_variable* cv;
+std::mutex m;
+typedef std::unique_lock<std::mutex> Lock;
+
+bool f_ready = false;
+bool g_ready = false;
+
+void f()
+{
+ Lock lk(m);
+ f_ready = true;
+ cv->notify_one();
+ delete cv;
+}
+
+void g()
+{
+ Lock lk(m);
+ g_ready = true;
+ cv->notify_one();
+ while (!f_ready)
+ cv->wait(lk);
+}
+
+int main()
+{
+ cv = new std::condition_variable;
+ std::thread th2(g);
+ Lock lk(m);
+ while (!g_ready)
+ cv->wait(lk);
+ lk.unlock();
+ std::thread th1(f);
+ th1.join();
+ th2.join();
+}
diff --git a/test/std/thread/thread.condition/thread.condition.condvar/native_handle.pass.cpp b/test/std/thread/thread.condition/thread.condition.condvar/native_handle.pass.cpp
new file mode 100644
index 000000000000..bf28e01a0e86
--- /dev/null
+++ b/test/std/thread/thread.condition/thread.condition.condvar/native_handle.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <condition_variable>
+
+// class condition_variable;
+
+// typedef pthread_cond_t* native_handle_type;
+// native_handle_type native_handle();
+
+#include <condition_variable>
+#include <cassert>
+
+int main()
+{
+ static_assert((std::is_same<std::condition_variable::native_handle_type,
+ pthread_cond_t*>::value), "");
+ std::condition_variable cv;
+ std::condition_variable::native_handle_type h = cv.native_handle();
+ assert(h != nullptr);
+}
diff --git a/test/std/thread/thread.condition/thread.condition.condvar/notify_all.pass.cpp b/test/std/thread/thread.condition/thread.condition.condvar/notify_all.pass.cpp
new file mode 100644
index 000000000000..fd80ee99c968
--- /dev/null
+++ b/test/std/thread/thread.condition/thread.condition.condvar/notify_all.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <condition_variable>
+
+// class condition_variable;
+
+// void notify_all();
+
+#include <condition_variable>
+#include <mutex>
+#include <thread>
+#include <cassert>
+
+std::condition_variable cv;
+std::mutex mut;
+
+int test0 = 0;
+int test1 = 0;
+int test2 = 0;
+
+void f1()
+{
+ std::unique_lock<std::mutex> lk(mut);
+ assert(test1 == 0);
+ while (test1 == 0)
+ cv.wait(lk);
+ assert(test1 == 1);
+ test1 = 2;
+}
+
+void f2()
+{
+ std::unique_lock<std::mutex> lk(mut);
+ assert(test2 == 0);
+ while (test2 == 0)
+ cv.wait(lk);
+ assert(test2 == 1);
+ test2 = 2;
+}
+
+int main()
+{
+ std::thread t1(f1);
+ std::thread t2(f2);
+ std::this_thread::sleep_for(std::chrono::milliseconds(100));
+ {
+ std::unique_lock<std::mutex>lk(mut);
+ test1 = 1;
+ test2 = 1;
+ }
+ cv.notify_all();
+ {
+ std::this_thread::sleep_for(std::chrono::milliseconds(100));
+ std::unique_lock<std::mutex>lk(mut);
+ }
+ t1.join();
+ t2.join();
+ assert(test1 == 2);
+ assert(test2 == 2);
+}
diff --git a/test/std/thread/thread.condition/thread.condition.condvar/notify_one.pass.cpp b/test/std/thread/thread.condition/thread.condition.condvar/notify_one.pass.cpp
new file mode 100644
index 000000000000..6236a13df80e
--- /dev/null
+++ b/test/std/thread/thread.condition/thread.condition.condvar/notify_one.pass.cpp
@@ -0,0 +1,94 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <condition_variable>
+
+// class condition_variable;
+
+// void notify_one();
+
+#include <condition_variable>
+#include <mutex>
+#include <thread>
+#include <cassert>
+
+std::condition_variable cv;
+std::mutex mut;
+
+int test0 = 0;
+int test1 = 0;
+int test2 = 0;
+
+void f1()
+{
+ std::unique_lock<std::mutex> lk(mut);
+ assert(test1 == 0);
+ while (test1 == 0)
+ cv.wait(lk);
+ assert(test1 == 1);
+ test1 = 2;
+}
+
+void f2()
+{
+ std::unique_lock<std::mutex> lk(mut);
+ assert(test2 == 0);
+ while (test2 == 0)
+ cv.wait(lk);
+ assert(test2 == 1);
+ test2 = 2;
+}
+
+int main()
+{
+ std::thread t1(f1);
+ std::thread t2(f2);
+ std::this_thread::sleep_for(std::chrono::milliseconds(100));
+ {
+ std::unique_lock<std::mutex>lk(mut);
+ test1 = 1;
+ test2 = 1;
+ }
+ cv.notify_one();
+ {
+ std::this_thread::sleep_for(std::chrono::milliseconds(100));
+ std::unique_lock<std::mutex>lk(mut);
+ }
+ if (test1 == 2)
+ {
+ t1.join();
+ test1 = 0;
+ }
+ else if (test2 == 2)
+ {
+ t2.join();
+ test2 = 0;
+ }
+ else
+ assert(false);
+ cv.notify_one();
+ {
+ std::this_thread::sleep_for(std::chrono::milliseconds(100));
+ std::unique_lock<std::mutex>lk(mut);
+ }
+ if (test1 == 2)
+ {
+ t1.join();
+ test1 = 0;
+ }
+ else if (test2 == 2)
+ {
+ t2.join();
+ test2 = 0;
+ }
+ else
+ assert(false);
+}
diff --git a/test/std/thread/thread.condition/thread.condition.condvar/wait.pass.cpp b/test/std/thread/thread.condition/thread.condition.condvar/wait.pass.cpp
new file mode 100644
index 000000000000..236eecc919ad
--- /dev/null
+++ b/test/std/thread/thread.condition/thread.condition.condvar/wait.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <condition_variable>
+
+// class condition_variable;
+
+// void wait(unique_lock<mutex>& lock);
+
+#include <condition_variable>
+#include <mutex>
+#include <thread>
+#include <cassert>
+
+std::condition_variable cv;
+std::mutex mut;
+
+int test1 = 0;
+int test2 = 0;
+
+void f()
+{
+ std::unique_lock<std::mutex> lk(mut);
+ assert(test2 == 0);
+ test1 = 1;
+ cv.notify_one();
+ while (test2 == 0)
+ cv.wait(lk);
+ assert(test2 != 0);
+}
+
+int main()
+{
+ std::unique_lock<std::mutex>lk(mut);
+ std::thread t(f);
+ assert(test1 == 0);
+ while (test1 == 0)
+ cv.wait(lk);
+ assert(test1 != 0);
+ test2 = 1;
+ lk.unlock();
+ cv.notify_one();
+ t.join();
+}
diff --git a/test/std/thread/thread.condition/thread.condition.condvar/wait_for.pass.cpp b/test/std/thread/thread.condition/thread.condition.condvar/wait_for.pass.cpp
new file mode 100644
index 000000000000..ca48eee19d27
--- /dev/null
+++ b/test/std/thread/thread.condition/thread.condition.condvar/wait_for.pass.cpp
@@ -0,0 +1,87 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <condition_variable>
+
+// class condition_variable;
+
+// template <class Rep, class Period>
+// cv_status
+// wait_for(unique_lock<mutex>& lock,
+// const chrono::duration<Rep, Period>& rel_time);
+
+#include <condition_variable>
+#include <mutex>
+#include <thread>
+#include <chrono>
+#include <cassert>
+
+std::condition_variable cv;
+std::mutex mut;
+
+int test1 = 0;
+int test2 = 0;
+
+int runs = 0;
+
+void f()
+{
+ typedef std::chrono::system_clock Clock;
+ typedef std::chrono::milliseconds milliseconds;
+ std::unique_lock<std::mutex> lk(mut);
+ assert(test2 == 0);
+ test1 = 1;
+ cv.notify_one();
+ Clock::time_point t0 = Clock::now();
+ while (test2 == 0 &&
+ cv.wait_for(lk, milliseconds(250)) == std::cv_status::no_timeout)
+ ;
+ Clock::time_point t1 = Clock::now();
+ if (runs == 0)
+ {
+ assert(t1 - t0 < milliseconds(250));
+ assert(test2 != 0);
+ }
+ else
+ {
+ assert(t1 - t0 - milliseconds(250) < milliseconds(50));
+ assert(test2 == 0);
+ }
+ ++runs;
+}
+
+int main()
+{
+ {
+ std::unique_lock<std::mutex>lk(mut);
+ std::thread t(f);
+ assert(test1 == 0);
+ while (test1 == 0)
+ cv.wait(lk);
+ assert(test1 != 0);
+ test2 = 1;
+ lk.unlock();
+ cv.notify_one();
+ t.join();
+ }
+ test1 = 0;
+ test2 = 0;
+ {
+ std::unique_lock<std::mutex>lk(mut);
+ std::thread t(f);
+ assert(test1 == 0);
+ while (test1 == 0)
+ cv.wait(lk);
+ assert(test1 != 0);
+ lk.unlock();
+ t.join();
+ }
+}
diff --git a/test/std/thread/thread.condition/thread.condition.condvar/wait_for_pred.pass.cpp b/test/std/thread/thread.condition/thread.condition.condvar/wait_for_pred.pass.cpp
new file mode 100644
index 000000000000..0ee40d161b7b
--- /dev/null
+++ b/test/std/thread/thread.condition/thread.condition.condvar/wait_for_pred.pass.cpp
@@ -0,0 +1,95 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <condition_variable>
+
+// class condition_variable;
+
+// template <class Rep, class Period, class Predicate>
+// bool
+// wait_for(unique_lock<mutex>& lock,
+// const chrono::duration<Rep, Period>& rel_time,
+// Predicate pred);
+
+#include <condition_variable>
+#include <mutex>
+#include <thread>
+#include <chrono>
+#include <cassert>
+
+class Pred
+{
+ int& i_;
+public:
+ explicit Pred(int& i) : i_(i) {}
+
+ bool operator()() {return i_ != 0;}
+};
+
+std::condition_variable cv;
+std::mutex mut;
+
+int test1 = 0;
+int test2 = 0;
+
+int runs = 0;
+
+void f()
+{
+ typedef std::chrono::system_clock Clock;
+ typedef std::chrono::milliseconds milliseconds;
+ std::unique_lock<std::mutex> lk(mut);
+ assert(test2 == 0);
+ test1 = 1;
+ cv.notify_one();
+ Clock::time_point t0 = Clock::now();
+ bool r = cv.wait_for(lk, milliseconds(250), Pred(test2));
+ Clock::time_point t1 = Clock::now();
+ if (runs == 0)
+ {
+ assert(t1 - t0 < milliseconds(250));
+ assert(test2 != 0);
+ }
+ else
+ {
+ assert(t1 - t0 - milliseconds(250) < milliseconds(50));
+ assert(test2 == 0);
+ }
+ ++runs;
+}
+
+int main()
+{
+ {
+ std::unique_lock<std::mutex>lk(mut);
+ std::thread t(f);
+ assert(test1 == 0);
+ while (test1 == 0)
+ cv.wait(lk);
+ assert(test1 != 0);
+ test2 = 1;
+ lk.unlock();
+ cv.notify_one();
+ t.join();
+ }
+ test1 = 0;
+ test2 = 0;
+ {
+ std::unique_lock<std::mutex>lk(mut);
+ std::thread t(f);
+ assert(test1 == 0);
+ while (test1 == 0)
+ cv.wait(lk);
+ assert(test1 != 0);
+ lk.unlock();
+ t.join();
+ }
+}
diff --git a/test/std/thread/thread.condition/thread.condition.condvar/wait_pred.pass.cpp b/test/std/thread/thread.condition/thread.condition.condvar/wait_pred.pass.cpp
new file mode 100644
index 000000000000..45e0b8124165
--- /dev/null
+++ b/test/std/thread/thread.condition/thread.condition.condvar/wait_pred.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <condition_variable>
+
+// class condition_variable;
+
+// template <class Predicate>
+// void wait(unique_lock<mutex>& lock, Predicate pred);
+
+#include <condition_variable>
+#include <mutex>
+#include <thread>
+#include <functional>
+#include <cassert>
+
+std::condition_variable cv;
+std::mutex mut;
+
+int test1 = 0;
+int test2 = 0;
+
+class Pred
+{
+ int& i_;
+public:
+ explicit Pred(int& i) : i_(i) {}
+
+ bool operator()() {return i_ != 0;}
+};
+
+void f()
+{
+ std::unique_lock<std::mutex> lk(mut);
+ assert(test2 == 0);
+ test1 = 1;
+ cv.notify_one();
+ cv.wait(lk, Pred(test2));
+ assert(test2 != 0);
+}
+
+int main()
+{
+ std::unique_lock<std::mutex>lk(mut);
+ std::thread t(f);
+ assert(test1 == 0);
+ while (test1 == 0)
+ cv.wait(lk);
+ assert(test1 != 0);
+ test2 = 1;
+ lk.unlock();
+ cv.notify_one();
+ t.join();
+}
diff --git a/test/std/thread/thread.condition/thread.condition.condvar/wait_until.pass.cpp b/test/std/thread/thread.condition/thread.condition.condvar/wait_until.pass.cpp
new file mode 100644
index 000000000000..d87a188e93d7
--- /dev/null
+++ b/test/std/thread/thread.condition/thread.condition.condvar/wait_until.pass.cpp
@@ -0,0 +1,102 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <condition_variable>
+
+// class condition_variable;
+
+// template <class Clock, class Duration>
+// cv_status
+// wait_until(unique_lock<mutex>& lock,
+// const chrono::time_point<Clock, Duration>& abs_time);
+
+#include <condition_variable>
+#include <mutex>
+#include <thread>
+#include <chrono>
+#include <cassert>
+
+struct Clock
+{
+ typedef std::chrono::milliseconds duration;
+ typedef duration::rep rep;
+ typedef duration::period period;
+ typedef std::chrono::time_point<Clock> time_point;
+ static const bool is_steady = true;
+
+ static time_point now()
+ {
+ using namespace std::chrono;
+ return time_point(duration_cast<duration>(
+ steady_clock::now().time_since_epoch()
+ ));
+ }
+};
+
+std::condition_variable cv;
+std::mutex mut;
+
+int test1 = 0;
+int test2 = 0;
+
+int runs = 0;
+
+void f()
+{
+ std::unique_lock<std::mutex> lk(mut);
+ assert(test2 == 0);
+ test1 = 1;
+ cv.notify_one();
+ Clock::time_point t0 = Clock::now();
+ Clock::time_point t = t0 + Clock::duration(250);
+ while (test2 == 0 && cv.wait_until(lk, t) == std::cv_status::no_timeout)
+ ;
+ Clock::time_point t1 = Clock::now();
+ if (runs == 0)
+ {
+ assert(t1 - t0 < Clock::duration(250));
+ assert(test2 != 0);
+ }
+ else
+ {
+ assert(t1 - t0 - Clock::duration(250) < Clock::duration(50));
+ assert(test2 == 0);
+ }
+ ++runs;
+}
+
+int main()
+{
+ {
+ std::unique_lock<std::mutex>lk(mut);
+ std::thread t(f);
+ assert(test1 == 0);
+ while (test1 == 0)
+ cv.wait(lk);
+ assert(test1 != 0);
+ test2 = 1;
+ lk.unlock();
+ cv.notify_one();
+ t.join();
+ }
+ test1 = 0;
+ test2 = 0;
+ {
+ std::unique_lock<std::mutex>lk(mut);
+ std::thread t(f);
+ assert(test1 == 0);
+ while (test1 == 0)
+ cv.wait(lk);
+ assert(test1 != 0);
+ lk.unlock();
+ t.join();
+ }
+}
diff --git a/test/std/thread/thread.condition/thread.condition.condvar/wait_until_pred.pass.cpp b/test/std/thread/thread.condition/thread.condition.condvar/wait_until_pred.pass.cpp
new file mode 100644
index 000000000000..90ffb1d0b29d
--- /dev/null
+++ b/test/std/thread/thread.condition/thread.condition.condvar/wait_until_pred.pass.cpp
@@ -0,0 +1,113 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <condition_variable>
+
+// class condition_variable;
+
+// template <class Clock, class Duration, class Predicate>
+// bool
+// wait_until(unique_lock<mutex>& lock,
+// const chrono::time_point<Clock, Duration>& abs_time,
+// Predicate pred);
+
+#include <condition_variable>
+#include <mutex>
+#include <thread>
+#include <chrono>
+#include <cassert>
+
+struct Clock
+{
+ typedef std::chrono::milliseconds duration;
+ typedef duration::rep rep;
+ typedef duration::period period;
+ typedef std::chrono::time_point<Clock> time_point;
+ static const bool is_steady = true;
+
+ static time_point now()
+ {
+ using namespace std::chrono;
+ return time_point(duration_cast<duration>(
+ steady_clock::now().time_since_epoch()
+ ));
+ }
+};
+
+class Pred
+{
+ int& i_;
+public:
+ explicit Pred(int& i) : i_(i) {}
+
+ bool operator()() {return i_ != 0;}
+};
+
+std::condition_variable cv;
+std::mutex mut;
+
+int test1 = 0;
+int test2 = 0;
+
+int runs = 0;
+
+void f()
+{
+ std::unique_lock<std::mutex> lk(mut);
+ assert(test2 == 0);
+ test1 = 1;
+ cv.notify_one();
+ Clock::time_point t0 = Clock::now();
+ Clock::time_point t = t0 + Clock::duration(250);
+ bool r = cv.wait_until(lk, t, Pred(test2));
+ Clock::time_point t1 = Clock::now();
+ if (runs == 0)
+ {
+ assert(t1 - t0 < Clock::duration(250));
+ assert(test2 != 0);
+ assert(r);
+ }
+ else
+ {
+ assert(t1 - t0 - Clock::duration(250) < Clock::duration(50));
+ assert(test2 == 0);
+ assert(!r);
+ }
+ ++runs;
+}
+
+int main()
+{
+ {
+ std::unique_lock<std::mutex>lk(mut);
+ std::thread t(f);
+ assert(test1 == 0);
+ while (test1 == 0)
+ cv.wait(lk);
+ assert(test1 != 0);
+ test2 = 1;
+ lk.unlock();
+ cv.notify_one();
+ t.join();
+ }
+ test1 = 0;
+ test2 = 0;
+ {
+ std::unique_lock<std::mutex>lk(mut);
+ std::thread t(f);
+ assert(test1 == 0);
+ while (test1 == 0)
+ cv.wait(lk);
+ assert(test1 != 0);
+ lk.unlock();
+ t.join();
+ }
+}
diff --git a/test/std/thread/thread.condition/thread.condition.condvarany/assign.fail.cpp b/test/std/thread/thread.condition/thread.condition.condvarany/assign.fail.cpp
new file mode 100644
index 000000000000..0b8d8e965e63
--- /dev/null
+++ b/test/std/thread/thread.condition/thread.condition.condvarany/assign.fail.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <condition_variable>
+
+// class condition_variable_any;
+
+// condition_variable_any& operator=(const condition_variable_any&) = delete;
+
+#include <condition_variable>
+#include <cassert>
+
+int main()
+{
+ std::condition_variable_any cv0;
+ std::condition_variable_any cv1;
+ cv1 = cv0;
+}
diff --git a/test/std/thread/thread.condition/thread.condition.condvarany/copy.fail.cpp b/test/std/thread/thread.condition/thread.condition.condvarany/copy.fail.cpp
new file mode 100644
index 000000000000..84902546d07d
--- /dev/null
+++ b/test/std/thread/thread.condition/thread.condition.condvarany/copy.fail.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <condition_variable>
+
+// class condition_variable_any;
+
+// condition_variable_any(const condition_variable_any&) = delete;
+
+#include <condition_variable>
+#include <cassert>
+
+int main()
+{
+ std::condition_variable_any cv0;
+ std::condition_variable_any cv1(cv0);
+}
diff --git a/test/std/thread/thread.condition/thread.condition.condvarany/default.pass.cpp b/test/std/thread/thread.condition/thread.condition.condvarany/default.pass.cpp
new file mode 100644
index 000000000000..210060a7461b
--- /dev/null
+++ b/test/std/thread/thread.condition/thread.condition.condvarany/default.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <condition_variable>
+
+// class condition_variable_any;
+
+// condition_variable_any();
+
+#include <condition_variable>
+#include <cassert>
+
+int main()
+{
+ std::condition_variable_any cv;
+}
diff --git a/test/std/thread/thread.condition/thread.condition.condvarany/destructor.pass.cpp b/test/std/thread/thread.condition/thread.condition.condvarany/destructor.pass.cpp
new file mode 100644
index 000000000000..6bdca7b010c2
--- /dev/null
+++ b/test/std/thread/thread.condition/thread.condition.condvarany/destructor.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <condition_variable>
+
+// class condition_variable_any;
+
+// ~condition_variable_any();
+
+#include <condition_variable>
+#include <mutex>
+#include <thread>
+#include <cassert>
+
+std::condition_variable_any* cv;
+std::mutex m;
+
+bool f_ready = false;
+bool g_ready = false;
+
+void f()
+{
+ m.lock();
+ f_ready = true;
+ cv->notify_one();
+ delete cv;
+ m.unlock();
+}
+
+void g()
+{
+ m.lock();
+ g_ready = true;
+ cv->notify_one();
+ while (!f_ready)
+ cv->wait(m);
+ m.unlock();
+}
+
+int main()
+{
+ cv = new std::condition_variable_any;
+ std::thread th2(g);
+ m.lock();
+ while (!g_ready)
+ cv->wait(m);
+ m.unlock();
+ std::thread th1(f);
+ th1.join();
+ th2.join();
+}
diff --git a/test/std/thread/thread.condition/thread.condition.condvarany/notify_all.pass.cpp b/test/std/thread/thread.condition/thread.condition.condvarany/notify_all.pass.cpp
new file mode 100644
index 000000000000..27ead95682a4
--- /dev/null
+++ b/test/std/thread/thread.condition/thread.condition.condvarany/notify_all.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <condition_variable>
+
+// class condition_variable_any;
+
+// void notify_all();
+
+#include <condition_variable>
+#include <mutex>
+#include <thread>
+#include <cassert>
+
+std::condition_variable_any cv;
+
+typedef std::timed_mutex L0;
+typedef std::unique_lock<L0> L1;
+
+L0 m0;
+
+int test0 = 0;
+int test1 = 0;
+int test2 = 0;
+
+void f1()
+{
+ L1 lk(m0);
+ assert(test1 == 0);
+ while (test1 == 0)
+ cv.wait(lk);
+ assert(test1 == 1);
+ test1 = 2;
+}
+
+void f2()
+{
+ L1 lk(m0);
+ assert(test2 == 0);
+ while (test2 == 0)
+ cv.wait(lk);
+ assert(test2 == 1);
+ test2 = 2;
+}
+
+int main()
+{
+ std::thread t1(f1);
+ std::thread t2(f2);
+ std::this_thread::sleep_for(std::chrono::milliseconds(100));
+ {
+ L1 lk(m0);
+ test1 = 1;
+ test2 = 1;
+ }
+ cv.notify_all();
+ {
+ std::this_thread::sleep_for(std::chrono::milliseconds(100));
+ L1 lk(m0);
+ }
+ t1.join();
+ t2.join();
+ assert(test1 == 2);
+ assert(test2 == 2);
+}
diff --git a/test/std/thread/thread.condition/thread.condition.condvarany/notify_one.pass.cpp b/test/std/thread/thread.condition/thread.condition.condvarany/notify_one.pass.cpp
new file mode 100644
index 000000000000..98f6c432c977
--- /dev/null
+++ b/test/std/thread/thread.condition/thread.condition.condvarany/notify_one.pass.cpp
@@ -0,0 +1,98 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <condition_variable>
+
+// class condition_variable_any;
+
+// void notify_one();
+
+#include <condition_variable>
+#include <mutex>
+#include <thread>
+#include <cassert>
+
+std::condition_variable_any cv;
+
+typedef std::timed_mutex L0;
+typedef std::unique_lock<L0> L1;
+
+L0 m0;
+
+int test0 = 0;
+int test1 = 0;
+int test2 = 0;
+
+void f1()
+{
+ L1 lk(m0);
+ assert(test1 == 0);
+ while (test1 == 0)
+ cv.wait(lk);
+ assert(test1 == 1);
+ test1 = 2;
+}
+
+void f2()
+{
+ L1 lk(m0);
+ assert(test2 == 0);
+ while (test2 == 0)
+ cv.wait(lk);
+ assert(test2 == 1);
+ test2 = 2;
+}
+
+int main()
+{
+ std::thread t1(f1);
+ std::thread t2(f2);
+ std::this_thread::sleep_for(std::chrono::milliseconds(100));
+ {
+ L1 lk(m0);
+ test1 = 1;
+ test2 = 1;
+ }
+ cv.notify_one();
+ {
+ std::this_thread::sleep_for(std::chrono::milliseconds(100));
+ L1 lk(m0);
+ }
+ if (test1 == 2)
+ {
+ t1.join();
+ test1 = 0;
+ }
+ else if (test2 == 2)
+ {
+ t2.join();
+ test2 = 0;
+ }
+ else
+ assert(false);
+ cv.notify_one();
+ {
+ std::this_thread::sleep_for(std::chrono::milliseconds(100));
+ L1 lk(m0);
+ }
+ if (test1 == 2)
+ {
+ t1.join();
+ test1 = 0;
+ }
+ else if (test2 == 2)
+ {
+ t2.join();
+ test2 = 0;
+ }
+ else
+ assert(false);
+}
diff --git a/test/std/thread/thread.condition/thread.condition.condvarany/wait.exception.pass.cpp b/test/std/thread/thread.condition/thread.condition.condvarany/wait.exception.pass.cpp
new file mode 100644
index 000000000000..522c61b02d17
--- /dev/null
+++ b/test/std/thread/thread.condition/thread.condition.condvarany/wait.exception.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+#include <thread>
+#include <condition_variable>
+#include <mutex>
+#include <chrono>
+#include <iostream>
+#include <cassert>
+
+void f1()
+{
+ std::exit(0);
+}
+
+struct Mutex
+{
+ unsigned state = 0;
+ Mutex() = default;
+ ~Mutex() = default;
+ Mutex(const Mutex&) = delete;
+ Mutex& operator=(const Mutex&) = delete;
+
+ void lock()
+ {
+ if (++state == 2)
+ throw 1; // this throw should end up calling terminate()
+ }
+
+ void unlock() {}
+};
+
+Mutex mut;
+std::condition_variable_any cv;
+
+void
+signal_me()
+{
+ std::this_thread::sleep_for(std::chrono::milliseconds(500));
+ cv.notify_one();
+}
+
+int
+main()
+{
+ std::set_terminate(f1);
+ try
+ {
+ std::thread(signal_me).detach();
+ mut.lock();
+ cv.wait(mut);
+ }
+ catch (...) {}
+ assert(false);
+}
diff --git a/test/std/thread/thread.condition/thread.condition.condvarany/wait.pass.cpp b/test/std/thread/thread.condition/thread.condition.condvarany/wait.pass.cpp
new file mode 100644
index 000000000000..f5c8926e34b3
--- /dev/null
+++ b/test/std/thread/thread.condition/thread.condition.condvarany/wait.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <condition_variable>
+
+// class condition_variable_any;
+
+// template <class Lock>
+// void wait(Lock& lock);
+
+#include <condition_variable>
+#include <mutex>
+#include <thread>
+#include <cassert>
+
+std::condition_variable_any cv;
+
+typedef std::timed_mutex L0;
+typedef std::unique_lock<L0> L1;
+
+L0 m0;
+
+int test1 = 0;
+int test2 = 0;
+
+void f()
+{
+ L1 lk(m0);
+ assert(test2 == 0);
+ test1 = 1;
+ cv.notify_one();
+ while (test2 == 0)
+ cv.wait(lk);
+ assert(test2 != 0);
+}
+
+int main()
+{
+ L1 lk(m0);
+ std::thread t(f);
+ assert(test1 == 0);
+ while (test1 == 0)
+ cv.wait(lk);
+ assert(test1 != 0);
+ test2 = 1;
+ lk.unlock();
+ cv.notify_one();
+ t.join();
+}
diff --git a/test/std/thread/thread.condition/thread.condition.condvarany/wait_for.exception.pass.cpp b/test/std/thread/thread.condition/thread.condition.condvarany/wait_for.exception.pass.cpp
new file mode 100644
index 000000000000..1906b5892506
--- /dev/null
+++ b/test/std/thread/thread.condition/thread.condition.condvarany/wait_for.exception.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+#include <thread>
+#include <condition_variable>
+#include <mutex>
+#include <chrono>
+#include <iostream>
+#include <cassert>
+
+void f1()
+{
+ std::exit(0);
+}
+
+struct Mutex
+{
+ unsigned state = 0;
+ Mutex() = default;
+ ~Mutex() = default;
+ Mutex(const Mutex&) = delete;
+ Mutex& operator=(const Mutex&) = delete;
+
+ void lock()
+ {
+ if (++state == 2)
+ throw 1; // this throw should end up calling terminate()
+ }
+
+ void unlock() {}
+};
+
+Mutex mut;
+std::condition_variable_any cv;
+
+void
+signal_me()
+{
+ std::this_thread::sleep_for(std::chrono::milliseconds(500));
+ cv.notify_one();
+}
+
+int
+main()
+{
+ std::set_terminate(f1);
+ try
+ {
+ std::thread(signal_me).detach();
+ mut.lock();
+ cv.wait_for(mut, std::chrono::milliseconds(250));
+ }
+ catch (...) {}
+ assert(false);
+}
diff --git a/test/std/thread/thread.condition/thread.condition.condvarany/wait_for.pass.cpp b/test/std/thread/thread.condition/thread.condition.condvarany/wait_for.pass.cpp
new file mode 100644
index 000000000000..a4b4ed991f29
--- /dev/null
+++ b/test/std/thread/thread.condition/thread.condition.condvarany/wait_for.pass.cpp
@@ -0,0 +1,90 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <condition_variable>
+
+// class condition_variable_any;
+
+// template <class Lock, class Rep, class Period>
+// cv_status
+// wait_for(Lock& lock, const chrono::duration<Rep, Period>& rel_time);
+
+#include <condition_variable>
+#include <mutex>
+#include <thread>
+#include <chrono>
+#include <cassert>
+
+std::condition_variable_any cv;
+
+typedef std::timed_mutex L0;
+typedef std::unique_lock<L0> L1;
+
+L0 m0;
+
+int test1 = 0;
+int test2 = 0;
+
+int runs = 0;
+
+void f()
+{
+ typedef std::chrono::system_clock Clock;
+ typedef std::chrono::milliseconds milliseconds;
+ L1 lk(m0);
+ assert(test2 == 0);
+ test1 = 1;
+ cv.notify_one();
+ Clock::time_point t0 = Clock::now();
+ while (test2 == 0 &&
+ cv.wait_for(lk, milliseconds(250)) == std::cv_status::no_timeout)
+ ;
+ Clock::time_point t1 = Clock::now();
+ if (runs == 0)
+ {
+ assert(t1 - t0 < milliseconds(250));
+ assert(test2 != 0);
+ }
+ else
+ {
+ assert(t1 - t0 - milliseconds(250) < milliseconds(50));
+ assert(test2 == 0);
+ }
+ ++runs;
+}
+
+int main()
+{
+ {
+ L1 lk(m0);
+ std::thread t(f);
+ assert(test1 == 0);
+ while (test1 == 0)
+ cv.wait(lk);
+ assert(test1 != 0);
+ test2 = 1;
+ lk.unlock();
+ cv.notify_one();
+ t.join();
+ }
+ test1 = 0;
+ test2 = 0;
+ {
+ L1 lk(m0);
+ std::thread t(f);
+ assert(test1 == 0);
+ while (test1 == 0)
+ cv.wait(lk);
+ assert(test1 != 0);
+ lk.unlock();
+ t.join();
+ }
+}
diff --git a/test/std/thread/thread.condition/thread.condition.condvarany/wait_for_pred.pass.cpp b/test/std/thread/thread.condition/thread.condition.condvarany/wait_for_pred.pass.cpp
new file mode 100644
index 000000000000..b2403079275d
--- /dev/null
+++ b/test/std/thread/thread.condition/thread.condition.condvarany/wait_for_pred.pass.cpp
@@ -0,0 +1,98 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <condition_variable>
+
+// class condition_variable_any;
+
+// template <class Lock, class Rep, class Period, class Predicate>
+// bool
+// wait_for(Lock& lock, const chrono::duration<Rep, Period>& rel_time,
+// Predicate pred);
+
+#include <condition_variable>
+#include <mutex>
+#include <thread>
+#include <chrono>
+#include <cassert>
+
+class Pred
+{
+ int& i_;
+public:
+ explicit Pred(int& i) : i_(i) {}
+
+ bool operator()() {return i_ != 0;}
+};
+
+std::condition_variable_any cv;
+
+typedef std::timed_mutex L0;
+typedef std::unique_lock<L0> L1;
+
+L0 m0;
+
+int test1 = 0;
+int test2 = 0;
+
+int runs = 0;
+
+void f()
+{
+ typedef std::chrono::system_clock Clock;
+ typedef std::chrono::milliseconds milliseconds;
+ L1 lk(m0);
+ assert(test2 == 0);
+ test1 = 1;
+ cv.notify_one();
+ Clock::time_point t0 = Clock::now();
+ bool r = cv.wait_for(lk, milliseconds(250), Pred(test2));
+ Clock::time_point t1 = Clock::now();
+ if (runs == 0)
+ {
+ assert(t1 - t0 < milliseconds(250));
+ assert(test2 != 0);
+ }
+ else
+ {
+ assert(t1 - t0 - milliseconds(250) < milliseconds(50));
+ assert(test2 == 0);
+ }
+ ++runs;
+}
+
+int main()
+{
+ {
+ L1 lk(m0);
+ std::thread t(f);
+ assert(test1 == 0);
+ while (test1 == 0)
+ cv.wait(lk);
+ assert(test1 != 0);
+ test2 = 1;
+ lk.unlock();
+ cv.notify_one();
+ t.join();
+ }
+ test1 = 0;
+ test2 = 0;
+ {
+ L1 lk(m0);
+ std::thread t(f);
+ assert(test1 == 0);
+ while (test1 == 0)
+ cv.wait(lk);
+ assert(test1 != 0);
+ lk.unlock();
+ t.join();
+ }
+}
diff --git a/test/std/thread/thread.condition/thread.condition.condvarany/wait_pred.pass.cpp b/test/std/thread/thread.condition/thread.condition.condvarany/wait_pred.pass.cpp
new file mode 100644
index 000000000000..921ad69f145e
--- /dev/null
+++ b/test/std/thread/thread.condition/thread.condition.condvarany/wait_pred.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <condition_variable>
+
+// class condition_variable_any;
+
+// template <class Lock, class Predicate>
+// void wait(Lock& lock, Predicate pred);
+
+#include <condition_variable>
+#include <mutex>
+#include <thread>
+#include <functional>
+#include <cassert>
+
+std::condition_variable_any cv;
+
+typedef std::timed_mutex L0;
+typedef std::unique_lock<L0> L1;
+
+L0 m0;
+
+int test1 = 0;
+int test2 = 0;
+
+class Pred
+{
+ int& i_;
+public:
+ explicit Pred(int& i) : i_(i) {}
+
+ bool operator()() {return i_ != 0;}
+};
+
+void f()
+{
+ L1 lk(m0);
+ assert(test2 == 0);
+ test1 = 1;
+ cv.notify_one();
+ cv.wait(lk, Pred(test2));
+ assert(test2 != 0);
+}
+
+int main()
+{
+ L1 lk(m0);
+ std::thread t(f);
+ assert(test1 == 0);
+ while (test1 == 0)
+ cv.wait(lk);
+ assert(test1 != 0);
+ test2 = 1;
+ lk.unlock();
+ cv.notify_one();
+ t.join();
+}
diff --git a/test/std/thread/thread.condition/thread.condition.condvarany/wait_until.pass.cpp b/test/std/thread/thread.condition/thread.condition.condvarany/wait_until.pass.cpp
new file mode 100644
index 000000000000..1994ebdfe609
--- /dev/null
+++ b/test/std/thread/thread.condition/thread.condition.condvarany/wait_until.pass.cpp
@@ -0,0 +1,105 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <condition_variable>
+
+// class condition_variable_any;
+
+// template <class Lock, class Clock, class Duration>
+// cv_status
+// wait_until(Lock& lock, const chrono::time_point<Clock, Duration>& abs_time);
+
+#include <condition_variable>
+#include <mutex>
+#include <thread>
+#include <chrono>
+#include <cassert>
+
+struct Clock
+{
+ typedef std::chrono::milliseconds duration;
+ typedef duration::rep rep;
+ typedef duration::period period;
+ typedef std::chrono::time_point<Clock> time_point;
+ static const bool is_steady = true;
+
+ static time_point now()
+ {
+ using namespace std::chrono;
+ return time_point(duration_cast<duration>(
+ steady_clock::now().time_since_epoch()
+ ));
+ }
+};
+
+std::condition_variable_any cv;
+
+typedef std::timed_mutex L0;
+typedef std::unique_lock<L0> L1;
+
+L0 m0;
+
+int test1 = 0;
+int test2 = 0;
+
+int runs = 0;
+
+void f()
+{
+ L1 lk(m0);
+ assert(test2 == 0);
+ test1 = 1;
+ cv.notify_one();
+ Clock::time_point t0 = Clock::now();
+ Clock::time_point t = t0 + Clock::duration(250);
+ while (test2 == 0 && cv.wait_until(lk, t) == std::cv_status::no_timeout)
+ ;
+ Clock::time_point t1 = Clock::now();
+ if (runs == 0)
+ {
+ assert(t1 - t0 < Clock::duration(250));
+ assert(test2 != 0);
+ }
+ else
+ {
+ assert(t1 - t0 - Clock::duration(250) < Clock::duration(50));
+ assert(test2 == 0);
+ }
+ ++runs;
+}
+
+int main()
+{
+ {
+ L1 lk(m0);
+ std::thread t(f);
+ assert(test1 == 0);
+ while (test1 == 0)
+ cv.wait(lk);
+ assert(test1 != 0);
+ test2 = 1;
+ lk.unlock();
+ cv.notify_one();
+ t.join();
+ }
+ test1 = 0;
+ test2 = 0;
+ {
+ L1 lk(m0);
+ std::thread t(f);
+ assert(test1 == 0);
+ while (test1 == 0)
+ cv.wait(lk);
+ assert(test1 != 0);
+ lk.unlock();
+ t.join();
+ }
+}
diff --git a/test/std/thread/thread.condition/thread.condition.condvarany/wait_until_pred.pass.cpp b/test/std/thread/thread.condition/thread.condition.condvarany/wait_until_pred.pass.cpp
new file mode 100644
index 000000000000..c0fea0355b9c
--- /dev/null
+++ b/test/std/thread/thread.condition/thread.condition.condvarany/wait_until_pred.pass.cpp
@@ -0,0 +1,117 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <condition_variable>
+
+// class condition_variable_any;
+
+// template <class Lock, class Duration, class Predicate>
+// bool
+// wait_until(Lock& lock,
+// const chrono::time_point<Clock, Duration>& abs_time,
+// Predicate pred);
+
+#include <condition_variable>
+#include <mutex>
+#include <thread>
+#include <chrono>
+#include <cassert>
+
+struct Clock
+{
+ typedef std::chrono::milliseconds duration;
+ typedef duration::rep rep;
+ typedef duration::period period;
+ typedef std::chrono::time_point<Clock> time_point;
+ static const bool is_steady = true;
+
+ static time_point now()
+ {
+ using namespace std::chrono;
+ return time_point(duration_cast<duration>(
+ steady_clock::now().time_since_epoch()
+ ));
+ }
+};
+
+class Pred
+{
+ int& i_;
+public:
+ explicit Pred(int& i) : i_(i) {}
+
+ bool operator()() {return i_ != 0;}
+};
+
+std::condition_variable_any cv;
+
+typedef std::timed_mutex L0;
+typedef std::unique_lock<L0> L1;
+
+L0 m0;
+
+int test1 = 0;
+int test2 = 0;
+
+int runs = 0;
+
+void f()
+{
+ L1 lk(m0);
+ assert(test2 == 0);
+ test1 = 1;
+ cv.notify_one();
+ Clock::time_point t0 = Clock::now();
+ Clock::time_point t = t0 + Clock::duration(250);
+ bool r = cv.wait_until(lk, t, Pred(test2));
+ Clock::time_point t1 = Clock::now();
+ if (runs == 0)
+ {
+ assert(t1 - t0 < Clock::duration(250));
+ assert(test2 != 0);
+ assert(r);
+ }
+ else
+ {
+ assert(t1 - t0 - Clock::duration(250) < Clock::duration(50));
+ assert(test2 == 0);
+ assert(!r);
+ }
+ ++runs;
+}
+
+int main()
+{
+ {
+ L1 lk(m0);
+ std::thread t(f);
+ assert(test1 == 0);
+ while (test1 == 0)
+ cv.wait(lk);
+ assert(test1 != 0);
+ test2 = 1;
+ lk.unlock();
+ cv.notify_one();
+ t.join();
+ }
+ test1 = 0;
+ test2 = 0;
+ {
+ L1 lk(m0);
+ std::thread t(f);
+ assert(test1 == 0);
+ while (test1 == 0)
+ cv.wait(lk);
+ assert(test1 != 0);
+ lk.unlock();
+ t.join();
+ }
+}
diff --git a/test/std/thread/thread.condition/version.pass.cpp b/test/std/thread/thread.condition/version.pass.cpp
new file mode 100644
index 000000000000..12a775e83398
--- /dev/null
+++ b/test/std/thread/thread.condition/version.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <condition_variable>
+
+#include <condition_variable>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/thread/thread.general/nothing_to_do.pass.cpp b/test/std/thread/thread.general/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/thread/thread.general/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/thread/thread.mutex/thread.lock.algorithm/lock.pass.cpp b/test/std/thread/thread.mutex/thread.lock.algorithm/lock.pass.cpp
new file mode 100644
index 000000000000..f67ca2169825
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.lock.algorithm/lock.pass.cpp
@@ -0,0 +1,507 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <mutex>
+
+// template <class L1, class L2, class... L3>
+// void lock(L1&, L2&, L3&...);
+
+#include <mutex>
+#include <cassert>
+
+class L0
+{
+ bool locked_;
+
+public:
+ L0() : locked_(false) {}
+
+ void lock()
+ {
+ locked_ = true;
+ }
+
+ bool try_lock()
+ {
+ locked_ = true;
+ return locked_;
+ }
+
+ void unlock() {locked_ = false;}
+
+ bool locked() const {return locked_;}
+};
+
+class L1
+{
+ bool locked_;
+
+public:
+ L1() : locked_(false) {}
+
+ void lock()
+ {
+ locked_ = true;
+ }
+
+ bool try_lock()
+ {
+ locked_ = false;
+ return locked_;
+ }
+
+ void unlock() {locked_ = false;}
+
+ bool locked() const {return locked_;}
+};
+
+class L2
+{
+ bool locked_;
+
+public:
+ L2() : locked_(false) {}
+
+ void lock()
+ {
+ throw 1;
+ }
+
+ bool try_lock()
+ {
+ throw 1;
+ return locked_;
+ }
+
+ void unlock() {locked_ = false;}
+
+ bool locked() const {return locked_;}
+};
+
+int main()
+{
+ {
+ L0 l0;
+ L0 l1;
+ std::lock(l0, l1);
+ assert(l0.locked());
+ assert(l1.locked());
+ }
+ {
+ L0 l0;
+ L1 l1;
+ std::lock(l0, l1);
+ assert(l0.locked());
+ assert(l1.locked());
+ }
+ {
+ L1 l0;
+ L0 l1;
+ std::lock(l0, l1);
+ assert(l0.locked());
+ assert(l1.locked());
+ }
+ {
+ L0 l0;
+ L2 l1;
+ try
+ {
+ std::lock(l0, l1);
+ assert(false);
+ }
+ catch (int)
+ {
+ assert(!l0.locked());
+ assert(!l1.locked());
+ }
+ }
+ {
+ L2 l0;
+ L0 l1;
+ try
+ {
+ std::lock(l0, l1);
+ assert(false);
+ }
+ catch (int)
+ {
+ assert(!l0.locked());
+ assert(!l1.locked());
+ }
+ }
+ {
+ L1 l0;
+ L2 l1;
+ try
+ {
+ std::lock(l0, l1);
+ assert(false);
+ }
+ catch (int)
+ {
+ assert(!l0.locked());
+ assert(!l1.locked());
+ }
+ }
+ {
+ L2 l0;
+ L1 l1;
+ try
+ {
+ std::lock(l0, l1);
+ assert(false);
+ }
+ catch (int)
+ {
+ assert(!l0.locked());
+ assert(!l1.locked());
+ }
+ }
+ {
+ L2 l0;
+ L2 l1;
+ try
+ {
+ std::lock(l0, l1);
+ assert(false);
+ }
+ catch (int)
+ {
+ assert(!l0.locked());
+ assert(!l1.locked());
+ }
+ }
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+ {
+ L0 l0;
+ L0 l1;
+ L0 l2;
+ std::lock(l0, l1, l2);
+ assert(l0.locked());
+ assert(l1.locked());
+ assert(l2.locked());
+ }
+ {
+ L2 l0;
+ L2 l1;
+ L2 l2;
+ try
+ {
+ std::lock(l0, l1, l2);
+ assert(false);
+ }
+ catch (int)
+ {
+ assert(!l0.locked());
+ assert(!l1.locked());
+ assert(!l2.locked());
+ }
+ }
+ {
+ L0 l0;
+ L0 l1;
+ L1 l2;
+ std::lock(l0, l1, l2);
+ assert(l0.locked());
+ assert(l1.locked());
+ assert(l2.locked());
+ }
+ {
+ L0 l0;
+ L1 l1;
+ L0 l2;
+ std::lock(l0, l1, l2);
+ assert(l0.locked());
+ assert(l1.locked());
+ assert(l2.locked());
+ }
+ {
+ L1 l0;
+ L0 l1;
+ L0 l2;
+ std::lock(l0, l1, l2);
+ assert(l0.locked());
+ assert(l1.locked());
+ assert(l2.locked());
+ }
+ {
+ L0 l0;
+ L0 l1;
+ L2 l2;
+ try
+ {
+ std::lock(l0, l1, l2);
+ assert(false);
+ }
+ catch (int)
+ {
+ assert(!l0.locked());
+ assert(!l1.locked());
+ assert(!l2.locked());
+ }
+ }
+ {
+ L0 l0;
+ L2 l1;
+ L0 l2;
+ try
+ {
+ std::lock(l0, l1, l2);
+ assert(false);
+ }
+ catch (int)
+ {
+ assert(!l0.locked());
+ assert(!l1.locked());
+ assert(!l2.locked());
+ }
+ }
+ {
+ L2 l0;
+ L0 l1;
+ L0 l2;
+ try
+ {
+ std::lock(l0, l1, l2);
+ assert(false);
+ }
+ catch (int)
+ {
+ assert(!l0.locked());
+ assert(!l1.locked());
+ assert(!l2.locked());
+ }
+ }
+ {
+ L2 l0;
+ L2 l1;
+ L0 l2;
+ try
+ {
+ std::lock(l0, l1, l2);
+ assert(false);
+ }
+ catch (int)
+ {
+ assert(!l0.locked());
+ assert(!l1.locked());
+ assert(!l2.locked());
+ }
+ }
+ {
+ L2 l0;
+ L0 l1;
+ L2 l2;
+ try
+ {
+ std::lock(l0, l1, l2);
+ assert(false);
+ }
+ catch (int)
+ {
+ assert(!l0.locked());
+ assert(!l1.locked());
+ assert(!l2.locked());
+ }
+ }
+ {
+ L0 l0;
+ L2 l1;
+ L2 l2;
+ try
+ {
+ std::lock(l0, l1, l2);
+ assert(false);
+ }
+ catch (int)
+ {
+ assert(!l0.locked());
+ assert(!l1.locked());
+ assert(!l2.locked());
+ }
+ }
+ {
+ L2 l0;
+ L2 l1;
+ L1 l2;
+ try
+ {
+ std::lock(l0, l1, l2);
+ assert(false);
+ }
+ catch (int)
+ {
+ assert(!l0.locked());
+ assert(!l1.locked());
+ assert(!l2.locked());
+ }
+ }
+ {
+ L2 l0;
+ L1 l1;
+ L2 l2;
+ try
+ {
+ std::lock(l0, l1, l2);
+ assert(false);
+ }
+ catch (int)
+ {
+ assert(!l0.locked());
+ assert(!l1.locked());
+ assert(!l2.locked());
+ }
+ }
+ {
+ L1 l0;
+ L2 l1;
+ L2 l2;
+ try
+ {
+ std::lock(l0, l1, l2);
+ assert(false);
+ }
+ catch (int)
+ {
+ assert(!l0.locked());
+ assert(!l1.locked());
+ assert(!l2.locked());
+ }
+ }
+ {
+ L0 l0;
+ L0 l1;
+ L0 l2;
+ L0 l3;
+ std::lock(l0, l1, l2, l3);
+ assert(l0.locked());
+ assert(l1.locked());
+ assert(l2.locked());
+ assert(l3.locked());
+ }
+ {
+ L0 l0;
+ L0 l1;
+ L0 l2;
+ L1 l3;
+ std::lock(l0, l1, l2, l3);
+ assert(l0.locked());
+ assert(l1.locked());
+ assert(l2.locked());
+ assert(l3.locked());
+ }
+ {
+ L0 l0;
+ L0 l1;
+ L1 l2;
+ L0 l3;
+ std::lock(l0, l1, l2, l3);
+ assert(l0.locked());
+ assert(l1.locked());
+ assert(l2.locked());
+ assert(l3.locked());
+ }
+ {
+ L0 l0;
+ L1 l1;
+ L0 l2;
+ L0 l3;
+ std::lock(l0, l1, l2, l3);
+ assert(l0.locked());
+ assert(l1.locked());
+ assert(l2.locked());
+ assert(l3.locked());
+ }
+ {
+ L1 l0;
+ L0 l1;
+ L0 l2;
+ L0 l3;
+ std::lock(l0, l1, l2, l3);
+ assert(l0.locked());
+ assert(l1.locked());
+ assert(l2.locked());
+ assert(l3.locked());
+ }
+ {
+ L0 l0;
+ L0 l1;
+ L0 l2;
+ L2 l3;
+ try
+ {
+ std::lock(l0, l1, l2, l3);
+ assert(false);
+ }
+ catch (int)
+ {
+ assert(!l0.locked());
+ assert(!l1.locked());
+ assert(!l2.locked());
+ assert(!l3.locked());
+ }
+ }
+ {
+ L0 l0;
+ L0 l1;
+ L2 l2;
+ L0 l3;
+ try
+ {
+ std::lock(l0, l1, l2, l3);
+ assert(false);
+ }
+ catch (int)
+ {
+ assert(!l0.locked());
+ assert(!l1.locked());
+ assert(!l2.locked());
+ assert(!l3.locked());
+ }
+ }
+ {
+ L0 l0;
+ L2 l1;
+ L0 l2;
+ L0 l3;
+ try
+ {
+ std::lock(l0, l1, l2, l3);
+ assert(false);
+ }
+ catch (int)
+ {
+ assert(!l0.locked());
+ assert(!l1.locked());
+ assert(!l2.locked());
+ assert(!l3.locked());
+ }
+ }
+ {
+ L2 l0;
+ L0 l1;
+ L0 l2;
+ L0 l3;
+ try
+ {
+ std::lock(l0, l1, l2, l3);
+ assert(false);
+ }
+ catch (int)
+ {
+ assert(!l0.locked());
+ assert(!l1.locked());
+ assert(!l2.locked());
+ assert(!l3.locked());
+ }
+ }
+#endif // _LIBCPP_HAS_NO_VARIADICS
+}
diff --git a/test/std/thread/thread.mutex/thread.lock.algorithm/try_lock.pass.cpp b/test/std/thread/thread.mutex/thread.lock.algorithm/try_lock.pass.cpp
new file mode 100644
index 000000000000..f0c54b71883f
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.lock.algorithm/try_lock.pass.cpp
@@ -0,0 +1,516 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <mutex>
+
+// template <class L1, class L2, class... L3>
+// int try_lock(L1&, L2&, L3&...);
+
+#include <mutex>
+#include <cassert>
+
+class L0
+{
+ bool locked_;
+
+public:
+ L0() : locked_(false) {}
+
+ bool try_lock()
+ {
+ locked_ = true;
+ return locked_;
+ }
+
+ void unlock() {locked_ = false;}
+
+ bool locked() const {return locked_;}
+};
+
+class L1
+{
+ bool locked_;
+
+public:
+ L1() : locked_(false) {}
+
+ bool try_lock()
+ {
+ locked_ = false;
+ return locked_;
+ }
+
+ void unlock() {locked_ = false;}
+
+ bool locked() const {return locked_;}
+};
+
+class L2
+{
+ bool locked_;
+
+public:
+ L2() : locked_(false) {}
+
+ bool try_lock()
+ {
+ throw 1;
+ return locked_;
+ }
+
+ void unlock() {locked_ = false;}
+
+ bool locked() const {return locked_;}
+};
+
+int main()
+{
+ {
+ L0 l0;
+ L0 l1;
+ assert(std::try_lock(l0, l1) == -1);
+ assert(l0.locked());
+ assert(l1.locked());
+ }
+ {
+ L0 l0;
+ L1 l1;
+ assert(std::try_lock(l0, l1) == 1);
+ assert(!l0.locked());
+ assert(!l1.locked());
+ }
+ {
+ L1 l0;
+ L0 l1;
+ assert(std::try_lock(l0, l1) == 0);
+ assert(!l0.locked());
+ assert(!l1.locked());
+ }
+ {
+ L0 l0;
+ L2 l1;
+ try
+ {
+ std::try_lock(l0, l1);
+ assert(false);
+ }
+ catch (int)
+ {
+ assert(!l0.locked());
+ assert(!l1.locked());
+ }
+ }
+ {
+ L2 l0;
+ L0 l1;
+ try
+ {
+ std::try_lock(l0, l1);
+ assert(false);
+ }
+ catch (int)
+ {
+ assert(!l0.locked());
+ assert(!l1.locked());
+ }
+ }
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+ {
+ L0 l0;
+ L0 l1;
+ L0 l2;
+ assert(std::try_lock(l0, l1, l2) == -1);
+ assert(l0.locked());
+ assert(l1.locked());
+ assert(l2.locked());
+ }
+ {
+ L1 l0;
+ L1 l1;
+ L1 l2;
+ assert(std::try_lock(l0, l1, l2) == 0);
+ assert(!l0.locked());
+ assert(!l1.locked());
+ assert(!l2.locked());
+ }
+ {
+ L2 l0;
+ L2 l1;
+ L2 l2;
+ try
+ {
+ std::try_lock(l0, l1, l2);
+ assert(false);
+ }
+ catch (int)
+ {
+ assert(!l0.locked());
+ assert(!l1.locked());
+ assert(!l2.locked());
+ }
+ }
+ {
+ L0 l0;
+ L1 l1;
+ L2 l2;
+ assert(std::try_lock(l0, l1, l2) == 1);
+ assert(!l0.locked());
+ assert(!l1.locked());
+ assert(!l2.locked());
+ }
+ {
+ L0 l0;
+ L0 l1;
+ L1 l2;
+ assert(std::try_lock(l0, l1, l2) == 2);
+ assert(!l0.locked());
+ assert(!l1.locked());
+ assert(!l2.locked());
+ }
+ {
+ L0 l0;
+ L1 l1;
+ L0 l2;
+ assert(std::try_lock(l0, l1, l2) == 1);
+ assert(!l0.locked());
+ assert(!l1.locked());
+ assert(!l2.locked());
+ }
+ {
+ L1 l0;
+ L0 l1;
+ L0 l2;
+ assert(std::try_lock(l0, l1, l2) == 0);
+ assert(!l0.locked());
+ assert(!l1.locked());
+ assert(!l2.locked());
+ }
+ {
+ L0 l0;
+ L0 l1;
+ L2 l2;
+ try
+ {
+ std::try_lock(l0, l1, l2);
+ assert(false);
+ }
+ catch (int)
+ {
+ assert(!l0.locked());
+ assert(!l1.locked());
+ assert(!l2.locked());
+ }
+ }
+ {
+ L0 l0;
+ L2 l1;
+ L0 l2;
+ try
+ {
+ std::try_lock(l0, l1, l2);
+ assert(false);
+ }
+ catch (int)
+ {
+ assert(!l0.locked());
+ assert(!l1.locked());
+ assert(!l2.locked());
+ }
+ }
+ {
+ L2 l0;
+ L0 l1;
+ L0 l2;
+ try
+ {
+ std::try_lock(l0, l1, l2);
+ assert(false);
+ }
+ catch (int)
+ {
+ assert(!l0.locked());
+ assert(!l1.locked());
+ assert(!l2.locked());
+ }
+ }
+ {
+ L1 l0;
+ L1 l1;
+ L0 l2;
+ assert(std::try_lock(l0, l1, l2) == 0);
+ assert(!l0.locked());
+ assert(!l1.locked());
+ assert(!l2.locked());
+ }
+ {
+ L1 l0;
+ L0 l1;
+ L1 l2;
+ assert(std::try_lock(l0, l1, l2) == 0);
+ assert(!l0.locked());
+ assert(!l1.locked());
+ assert(!l2.locked());
+ }
+ {
+ L0 l0;
+ L1 l1;
+ L1 l2;
+ assert(std::try_lock(l0, l1, l2) == 1);
+ assert(!l0.locked());
+ assert(!l1.locked());
+ assert(!l2.locked());
+ }
+ {
+ L1 l0;
+ L1 l1;
+ L2 l2;
+ assert(std::try_lock(l0, l1, l2) == 0);
+ assert(!l0.locked());
+ assert(!l1.locked());
+ assert(!l2.locked());
+ }
+ {
+ L1 l0;
+ L2 l1;
+ L1 l2;
+ assert(std::try_lock(l0, l1, l2) == 0);
+ assert(!l0.locked());
+ assert(!l1.locked());
+ assert(!l2.locked());
+ }
+ {
+ L2 l0;
+ L1 l1;
+ L1 l2;
+ try
+ {
+ std::try_lock(l0, l1, l2);
+ assert(false);
+ }
+ catch (int)
+ {
+ assert(!l0.locked());
+ assert(!l1.locked());
+ assert(!l2.locked());
+ }
+ }
+ {
+ L2 l0;
+ L2 l1;
+ L0 l2;
+ try
+ {
+ std::try_lock(l0, l1, l2);
+ assert(false);
+ }
+ catch (int)
+ {
+ assert(!l0.locked());
+ assert(!l1.locked());
+ assert(!l2.locked());
+ }
+ }
+ {
+ L2 l0;
+ L0 l1;
+ L2 l2;
+ try
+ {
+ std::try_lock(l0, l1, l2);
+ assert(false);
+ }
+ catch (int)
+ {
+ assert(!l0.locked());
+ assert(!l1.locked());
+ assert(!l2.locked());
+ }
+ }
+ {
+ L0 l0;
+ L2 l1;
+ L2 l2;
+ try
+ {
+ std::try_lock(l0, l1, l2);
+ assert(false);
+ }
+ catch (int)
+ {
+ assert(!l0.locked());
+ assert(!l1.locked());
+ assert(!l2.locked());
+ }
+ }
+ {
+ L2 l0;
+ L2 l1;
+ L1 l2;
+ try
+ {
+ std::try_lock(l0, l1, l2);
+ assert(false);
+ }
+ catch (int)
+ {
+ assert(!l0.locked());
+ assert(!l1.locked());
+ assert(!l2.locked());
+ }
+ }
+ {
+ L2 l0;
+ L1 l1;
+ L2 l2;
+ try
+ {
+ std::try_lock(l0, l1, l2);
+ assert(false);
+ }
+ catch (int)
+ {
+ assert(!l0.locked());
+ assert(!l1.locked());
+ assert(!l2.locked());
+ }
+ }
+ {
+ L1 l0;
+ L2 l1;
+ L2 l2;
+ assert(std::try_lock(l0, l1, l2) == 0);
+ assert(!l0.locked());
+ assert(!l1.locked());
+ assert(!l2.locked());
+ }
+ {
+ L0 l0;
+ L2 l1;
+ L1 l2;
+ try
+ {
+ std::try_lock(l0, l1, l2);
+ assert(false);
+ }
+ catch (int)
+ {
+ assert(!l0.locked());
+ assert(!l1.locked());
+ assert(!l2.locked());
+ }
+ }
+ {
+ L1 l0;
+ L0 l1;
+ L2 l2;
+ assert(std::try_lock(l0, l1, l2) == 0);
+ assert(!l0.locked());
+ assert(!l1.locked());
+ assert(!l2.locked());
+ }
+ {
+ L1 l0;
+ L2 l1;
+ L0 l2;
+ assert(std::try_lock(l0, l1, l2) == 0);
+ assert(!l0.locked());
+ assert(!l1.locked());
+ assert(!l2.locked());
+ }
+ {
+ L2 l0;
+ L0 l1;
+ L1 l2;
+ try
+ {
+ std::try_lock(l0, l1, l2);
+ assert(false);
+ }
+ catch (int)
+ {
+ assert(!l0.locked());
+ assert(!l1.locked());
+ assert(!l2.locked());
+ }
+ }
+ {
+ L2 l0;
+ L1 l1;
+ L0 l2;
+ try
+ {
+ std::try_lock(l0, l1, l2);
+ assert(false);
+ }
+ catch (int)
+ {
+ assert(!l0.locked());
+ assert(!l1.locked());
+ assert(!l2.locked());
+ }
+ }
+ {
+ L0 l0;
+ L0 l1;
+ L0 l2;
+ L0 l3;
+ assert(std::try_lock(l0, l1, l2, l3) == -1);
+ assert(l0.locked());
+ assert(l1.locked());
+ assert(l2.locked());
+ assert(l3.locked());
+ }
+ {
+ L1 l0;
+ L0 l1;
+ L0 l2;
+ L0 l3;
+ assert(std::try_lock(l0, l1, l2, l3) == 0);
+ assert(!l0.locked());
+ assert(!l1.locked());
+ assert(!l2.locked());
+ assert(!l3.locked());
+ }
+ {
+ L0 l0;
+ L1 l1;
+ L0 l2;
+ L0 l3;
+ assert(std::try_lock(l0, l1, l2, l3) == 1);
+ assert(!l0.locked());
+ assert(!l1.locked());
+ assert(!l2.locked());
+ assert(!l3.locked());
+ }
+ {
+ L0 l0;
+ L0 l1;
+ L1 l2;
+ L0 l3;
+ assert(std::try_lock(l0, l1, l2, l3) == 2);
+ assert(!l0.locked());
+ assert(!l1.locked());
+ assert(!l2.locked());
+ assert(!l3.locked());
+ }
+ {
+ L0 l0;
+ L0 l1;
+ L0 l2;
+ L1 l3;
+ assert(std::try_lock(l0, l1, l2, l3) == 3);
+ assert(!l0.locked());
+ assert(!l1.locked());
+ assert(!l2.locked());
+ assert(!l3.locked());
+ }
+#endif // _LIBCPP_HAS_NO_VARIADICS
+}
diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/adopt_lock.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/adopt_lock.pass.cpp
new file mode 100644
index 000000000000..83271009a67e
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/adopt_lock.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <mutex>
+
+// template <class Mutex> class lock_guard;
+
+// lock_guard(mutex_type& m, adopt_lock_t);
+
+#include <mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+std::mutex m;
+
+typedef std::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f()
+{
+ time_point t0 = Clock::now();
+ time_point t1;
+ {
+ m.lock();
+ std::lock_guard<std::mutex> lg(m, std::adopt_lock);
+ t1 = Clock::now();
+ }
+ ns d = t1 - t0 - ms(250);
+ assert(d < ms(50)); // within 50ms
+}
+
+int main()
+{
+ m.lock();
+ std::thread t(f);
+ std::this_thread::sleep_for(ms(250));
+ m.unlock();
+ t.join();
+}
diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/assign.fail.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/assign.fail.cpp
new file mode 100644
index 000000000000..53abb42c0e38
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/assign.fail.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// template <class Mutex> class lock_guard;
+
+// lock_guard& operator=(lock_guard const&) = delete;
+
+#include <mutex>
+
+int main()
+{
+ std::mutex m0;
+ std::mutex m1;
+ std::lock_guard<std::mutex> lg0(m0);
+ std::lock_guard<std::mutex> lg(m1);
+ lg = lg0;
+}
diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/copy.fail.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/copy.fail.cpp
new file mode 100644
index 000000000000..296ccdaee67a
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/copy.fail.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// template <class Mutex> class lock_guard;
+
+// lock_guard(lock_guard const&) = delete;
+
+#include <mutex>
+
+int main()
+{
+ std::mutex m;
+ std::lock_guard<std::mutex> lg0(m);
+ std::lock_guard<std::mutex> lg(lg0);
+}
diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/mutex.fail.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/mutex.fail.cpp
new file mode 100644
index 000000000000..246eb935c995
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/mutex.fail.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// template <class Mutex> class lock_guard;
+
+// explicit lock_guard(mutex_type& m);
+
+#include <mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+std::mutex m;
+
+typedef std::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f()
+{
+ time_point t0 = Clock::now();
+ time_point t1;
+ {
+ std::lock_guard<std::mutex> lg = m;
+ t1 = Clock::now();
+ }
+ ns d = t1 - t0 - ms(250);
+ assert(d < ns(2500000)); // within 2.5ms
+}
+
+int main()
+{
+ m.lock();
+ std::thread t(f);
+ std::this_thread::sleep_for(ms(250));
+ m.unlock();
+ t.join();
+}
diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/mutex.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/mutex.pass.cpp
new file mode 100644
index 000000000000..a15405fcd98b
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/mutex.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <mutex>
+
+// template <class Mutex> class lock_guard;
+
+// explicit lock_guard(mutex_type& m);
+
+#include <mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+std::mutex m;
+
+typedef std::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f()
+{
+ time_point t0 = Clock::now();
+ time_point t1;
+ {
+ std::lock_guard<std::mutex> lg(m);
+ t1 = Clock::now();
+ }
+ ns d = t1 - t0 - ms(250);
+ assert(d < ms(200)); // within 200ms
+}
+
+int main()
+{
+ m.lock();
+ std::thread t(f);
+ std::this_thread::sleep_for(ms(250));
+ m.unlock();
+ t.join();
+}
diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/types.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/types.pass.cpp
new file mode 100644
index 000000000000..5238ed67064f
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/types.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <mutex>
+
+// template <class Mutex>
+// class lock_guard
+// {
+// public:
+// typedef Mutex mutex_type;
+// ...
+// };
+
+#include <mutex>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_same<std::lock_guard<std::mutex>::mutex_type,
+ std::mutex>::value), "");
+}
diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/copy_assign.fail.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/copy_assign.fail.cpp
new file mode 100644
index 000000000000..446807f3f333
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/copy_assign.fail.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <shared_mutex>
+
+// template <class Mutex> class shared_lock;
+
+// shared_lock& operator=(shared_lock const&) = delete;
+
+#include <shared_mutex>
+
+#if _LIBCPP_STD_VER > 11
+
+std::shared_timed_mutex m0;
+std::shared_timed_mutex m1;
+
+#endif // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ std::shared_lock<std::shared_timed_mutex> lk0(m0);
+ std::shared_lock<std::shared_timed_mutex> lk1(m1);
+ lk1 = lk0;
+#else
+# error
+#endif // _LIBCPP_STD_VER > 11
+}
diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/copy_ctor.fail.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/copy_ctor.fail.cpp
new file mode 100644
index 000000000000..370c1fa4e336
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/copy_ctor.fail.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <shared_mutex>
+
+// template <class Mutex> class shared_lock;
+
+// shared_lock(shared_lock const&) = delete;
+
+#include <shared_mutex>
+
+#if _LIBCPP_STD_VER > 11
+std::shared_timed_mutex m;
+#endif // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ std::shared_lock<std::shared_timed_mutex> lk0(m);
+ std::shared_lock<std::shared_timed_mutex> lk = lk0;
+#else
+# error
+#endif // _LIBCPP_STD_VER > 11
+}
diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/default.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/default.pass.cpp
new file mode 100644
index 000000000000..2c1c665fdeda
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/default.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <shared_mutex>
+
+// template <class Mutex> class shared_lock;
+
+// shared_lock();
+
+#include <shared_mutex>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ std::shared_lock<std::shared_timed_mutex> ul;
+ assert(!ul.owns_lock());
+ assert(ul.mutex() == nullptr);
+#endif // _LIBCPP_STD_VER > 11
+}
diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/move_assign.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/move_assign.pass.cpp
new file mode 100644
index 000000000000..8676f2ca0472
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/move_assign.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <shared_mutex>
+
+// template <class Mutex> class shared_lock;
+
+// shared_lock& operator=(shared_lock&& u);
+
+#include <shared_mutex>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+std::shared_timed_mutex m0;
+std::shared_timed_mutex m1;
+
+#endif // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ std::shared_lock<std::shared_timed_mutex> lk0(m0);
+ std::shared_lock<std::shared_timed_mutex> lk1(m1);
+ lk1 = std::move(lk0);
+ assert(lk1.mutex() == &m0);
+ assert(lk1.owns_lock() == true);
+ assert(lk0.mutex() == nullptr);
+ assert(lk0.owns_lock() == false);
+#endif // _LIBCPP_STD_VER > 11
+}
diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/move_ctor.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/move_ctor.pass.cpp
new file mode 100644
index 000000000000..f59d2e826980
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/move_ctor.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <shared_mutex>
+
+// template <class Mutex> class shared_lock;
+
+// shared_lock(shared_lock&& u);
+
+#include <shared_mutex>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+std::shared_timed_mutex m;
+#endif // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ std::shared_lock<std::shared_timed_mutex> lk0(m);
+ std::shared_lock<std::shared_timed_mutex> lk = std::move(lk0);
+ assert(lk.mutex() == &m);
+ assert(lk.owns_lock() == true);
+ assert(lk0.mutex() == nullptr);
+ assert(lk0.owns_lock() == false);
+#endif // _LIBCPP_STD_VER > 11
+}
diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex.pass.cpp
new file mode 100644
index 000000000000..c8a0287314bf
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <shared_mutex>
+
+// template <class Mutex> class shared_lock;
+
+// explicit shared_lock(mutex_type& m);
+
+#include <shared_mutex>
+#include <thread>
+#include <vector>
+#include <cstdlib>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+std::shared_timed_mutex m;
+
+typedef std::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f()
+{
+ time_point t0 = Clock::now();
+ time_point t1;
+ {
+ std::shared_lock<std::shared_timed_mutex> ul(m);
+ t1 = Clock::now();
+ }
+ ns d = t1 - t0 - ms(250);
+ assert(d < ms(50)); // within 50ms
+}
+
+void g()
+{
+ time_point t0 = Clock::now();
+ time_point t1;
+ {
+ std::shared_lock<std::shared_timed_mutex> ul(m);
+ t1 = Clock::now();
+ }
+ ns d = t1 - t0;
+ assert(d < ms(50)); // within 50ms
+}
+
+#endif // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ m.lock();
+ std::vector<std::thread> v;
+ for (int i = 0; i < 5; ++i)
+ v.push_back(std::thread(f));
+ std::this_thread::sleep_for(ms(250));
+ m.unlock();
+ for (auto& t : v)
+ t.join();
+ m.lock_shared();
+ for (auto& t : v)
+ t = std::thread(g);
+ std::thread q(f);
+ std::this_thread::sleep_for(ms(250));
+ m.unlock_shared();
+ for (auto& t : v)
+ t.join();
+ q.join();
+#endif // _LIBCPP_STD_VER > 11
+}
diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_adopt_lock.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_adopt_lock.pass.cpp
new file mode 100644
index 000000000000..3b49b3029052
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_adopt_lock.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <shared_mutex>
+
+// template <class Mutex> class shared_lock;
+
+// shared_lock(mutex_type& m, adopt_lock_t);
+
+#include <shared_mutex>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ std::shared_timed_mutex m;
+ m.lock_shared();
+ std::shared_lock<std::shared_timed_mutex> lk(m, std::adopt_lock);
+ assert(lk.mutex() == &m);
+ assert(lk.owns_lock() == true);
+#endif // _LIBCPP_STD_VER > 11
+}
diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_defer_lock.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_defer_lock.pass.cpp
new file mode 100644
index 000000000000..bbc38fcadb10
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_defer_lock.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <shared_mutex>
+
+// template <class Mutex> class shared_lock;
+
+// shared_lock(mutex_type& m, defer_lock_t);
+
+#include <shared_mutex>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ std::shared_timed_mutex m;
+ std::shared_lock<std::shared_timed_mutex> lk(m, std::defer_lock);
+ assert(lk.mutex() == &m);
+ assert(lk.owns_lock() == false);
+#endif // _LIBCPP_STD_VER > 11
+}
diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_duration.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_duration.pass.cpp
new file mode 100644
index 000000000000..9816e57f692a
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_duration.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <shared_mutex>
+
+// class timed_mutex;
+
+// template <class Rep, class Period>
+// shared_lock(mutex_type& m, const chrono::duration<Rep, Period>& rel_time);
+
+#include <shared_mutex>
+#include <thread>
+#include <vector>
+#include <cstdlib>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+std::shared_timed_mutex m;
+
+typedef std::chrono::steady_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f1()
+{
+ time_point t0 = Clock::now();
+ std::shared_lock<std::shared_timed_mutex> lk(m, ms(300));
+ assert(lk.owns_lock() == true);
+ time_point t1 = Clock::now();
+ ns d = t1 - t0 - ms(250);
+ assert(d < ms(50)); // within 50ms
+}
+
+void f2()
+{
+ time_point t0 = Clock::now();
+ std::shared_lock<std::shared_timed_mutex> lk(m, ms(250));
+ assert(lk.owns_lock() == false);
+ time_point t1 = Clock::now();
+ ns d = t1 - t0 - ms(250);
+ assert(d < ms(50)); // within 50ms
+}
+
+#endif // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ {
+ m.lock();
+ std::vector<std::thread> v;
+ for (int i = 0; i < 5; ++i)
+ v.push_back(std::thread(f1));
+ std::this_thread::sleep_for(ms(250));
+ m.unlock();
+ for (auto& t : v)
+ t.join();
+ }
+ {
+ m.lock();
+ std::vector<std::thread> v;
+ for (int i = 0; i < 5; ++i)
+ v.push_back(std::thread(f2));
+ std::this_thread::sleep_for(ms(300));
+ m.unlock();
+ for (auto& t : v)
+ t.join();
+ }
+#endif // _LIBCPP_STD_VER > 11
+}
diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_time_point.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_time_point.pass.cpp
new file mode 100644
index 000000000000..5d188ab06737
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_time_point.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <shared_mutex>
+
+// class shared_timed_mutex;
+
+// template <class Clock, class Duration>
+// shared_lock(mutex_type& m, const chrono::time_point<Clock, Duration>& abs_time);
+
+#include <shared_mutex>
+#include <thread>
+#include <vector>
+#include <cstdlib>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+std::shared_timed_mutex m;
+
+typedef std::chrono::steady_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f1()
+{
+ time_point t0 = Clock::now();
+ std::shared_lock<std::shared_timed_mutex> lk(m, Clock::now() + ms(300));
+ assert(lk.owns_lock() == true);
+ time_point t1 = Clock::now();
+ ns d = t1 - t0 - ms(250);
+ assert(d < ns(50000000)); // within 50ms
+}
+
+void f2()
+{
+ time_point t0 = Clock::now();
+ std::shared_lock<std::shared_timed_mutex> lk(m, Clock::now() + ms(250));
+ assert(lk.owns_lock() == false);
+ time_point t1 = Clock::now();
+ ns d = t1 - t0 - ms(250);
+ assert(d < ms(50)); // within 50ms
+}
+
+#endif // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ {
+ m.lock();
+ std::vector<std::thread> v;
+ for (int i = 0; i < 5; ++i)
+ v.push_back(std::thread(f1));
+ std::this_thread::sleep_for(ms(250));
+ m.unlock();
+ for (auto& t : v)
+ t.join();
+ }
+ {
+ m.lock();
+ std::vector<std::thread> v;
+ for (int i = 0; i < 5; ++i)
+ v.push_back(std::thread(f2));
+ std::this_thread::sleep_for(ms(300));
+ m.unlock();
+ for (auto& t : v)
+ t.join();
+ }
+#endif // _LIBCPP_STD_VER > 11
+}
diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_try_to_lock.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_try_to_lock.pass.cpp
new file mode 100644
index 000000000000..f2d4e0deb73f
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_try_to_lock.pass.cpp
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <shared_mutex>
+
+// template <class Mutex> class shared_lock;
+
+// shared_lock(mutex_type& m, try_to_lock_t);
+
+#include <shared_mutex>
+#include <thread>
+#include <vector>
+#include <cstdlib>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+std::shared_timed_mutex m;
+
+typedef std::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f()
+{
+ time_point t0 = Clock::now();
+ {
+ std::shared_lock<std::shared_timed_mutex> lk(m, std::try_to_lock);
+ assert(lk.owns_lock() == false);
+ }
+ {
+ std::shared_lock<std::shared_timed_mutex> lk(m, std::try_to_lock);
+ assert(lk.owns_lock() == false);
+ }
+ {
+ std::shared_lock<std::shared_timed_mutex> lk(m, std::try_to_lock);
+ assert(lk.owns_lock() == false);
+ }
+ while (true)
+ {
+ std::shared_lock<std::shared_timed_mutex> lk(m, std::try_to_lock);
+ if (lk.owns_lock())
+ break;
+ }
+ time_point t1 = Clock::now();
+ ns d = t1 - t0 - ms(250);
+ assert(d < ms(200)); // within 200ms
+}
+
+#endif // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ m.lock();
+ std::vector<std::thread> v;
+ for (int i = 0; i < 5; ++i)
+ v.push_back(std::thread(f));
+ std::this_thread::sleep_for(ms(250));
+ m.unlock();
+ for (auto& t : v)
+ t.join();
+#endif // _LIBCPP_STD_VER > 11
+}
diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/lock.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/lock.pass.cpp
new file mode 100644
index 000000000000..f1500652badd
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/lock.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <shared_mutex>
+
+// template <class Mutex> class shared_lock;
+
+// void lock();
+
+#include <shared_mutex>
+#include <thread>
+#include <vector>
+#include <cstdlib>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+std::shared_timed_mutex m;
+
+typedef std::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f()
+{
+ std::shared_lock<std::shared_timed_mutex> lk(m, std::defer_lock);
+ time_point t0 = Clock::now();
+ lk.lock();
+ time_point t1 = Clock::now();
+ assert(lk.owns_lock() == true);
+ ns d = t1 - t0 - ms(250);
+ assert(d < ms(25)); // within 25ms
+ try
+ {
+ lk.lock();
+ assert(false);
+ }
+ catch (std::system_error& e)
+ {
+ assert(e.code().value() == EDEADLK);
+ }
+ lk.unlock();
+ lk.release();
+ try
+ {
+ lk.lock();
+ assert(false);
+ }
+ catch (std::system_error& e)
+ {
+ assert(e.code().value() == EPERM);
+ }
+}
+
+#endif // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ m.lock();
+ std::vector<std::thread> v;
+ for (int i = 0; i < 5; ++i)
+ v.push_back(std::thread(f));
+ std::this_thread::sleep_for(ms(250));
+ m.unlock();
+ for (auto& t : v)
+ t.join();
+#endif // _LIBCPP_STD_VER > 11
+}
diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock.pass.cpp
new file mode 100644
index 000000000000..82b1ff865053
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <shared_mutex>
+
+// template <class Mutex> class shared_lock;
+
+// bool try_lock();
+
+#include <shared_mutex>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+bool try_lock_called = false;
+
+struct mutex
+{
+ bool try_lock_shared()
+ {
+ try_lock_called = !try_lock_called;
+ return try_lock_called;
+ }
+ void unlock_shared() {}
+};
+
+mutex m;
+
+#endif // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ std::shared_lock<mutex> lk(m, std::defer_lock);
+ assert(lk.try_lock() == true);
+ assert(try_lock_called == true);
+ assert(lk.owns_lock() == true);
+ try
+ {
+ lk.try_lock();
+ assert(false);
+ }
+ catch (std::system_error& e)
+ {
+ assert(e.code().value() == EDEADLK);
+ }
+ lk.unlock();
+ assert(lk.try_lock() == false);
+ assert(try_lock_called == false);
+ assert(lk.owns_lock() == false);
+ lk.release();
+ try
+ {
+ lk.try_lock();
+ assert(false);
+ }
+ catch (std::system_error& e)
+ {
+ assert(e.code().value() == EPERM);
+ }
+#endif // _LIBCPP_STD_VER > 11
+}
diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock_for.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock_for.pass.cpp
new file mode 100644
index 000000000000..5867465a6626
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock_for.pass.cpp
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <shared_mutex>
+
+// template <class Mutex> class shared_lock;
+
+// template <class Rep, class Period>
+// bool try_lock_for(const chrono::duration<Rep, Period>& rel_time);
+
+#include <shared_mutex>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+bool try_lock_for_called = false;
+
+typedef std::chrono::milliseconds ms;
+
+struct mutex
+{
+ template <class Rep, class Period>
+ bool try_lock_shared_for(const std::chrono::duration<Rep, Period>& rel_time)
+ {
+ assert(rel_time == ms(5));
+ try_lock_for_called = !try_lock_for_called;
+ return try_lock_for_called;
+ }
+ void unlock_shared() {}
+};
+
+mutex m;
+
+#endif // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ std::shared_lock<mutex> lk(m, std::defer_lock);
+ assert(lk.try_lock_for(ms(5)) == true);
+ assert(try_lock_for_called == true);
+ assert(lk.owns_lock() == true);
+ try
+ {
+ lk.try_lock_for(ms(5));
+ assert(false);
+ }
+ catch (std::system_error& e)
+ {
+ assert(e.code().value() == EDEADLK);
+ }
+ lk.unlock();
+ assert(lk.try_lock_for(ms(5)) == false);
+ assert(try_lock_for_called == false);
+ assert(lk.owns_lock() == false);
+ lk.release();
+ try
+ {
+ lk.try_lock_for(ms(5));
+ assert(false);
+ }
+ catch (std::system_error& e)
+ {
+ assert(e.code().value() == EPERM);
+ }
+#endif // _LIBCPP_STD_VER > 11
+}
diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock_until.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock_until.pass.cpp
new file mode 100644
index 000000000000..9d38983be724
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock_until.pass.cpp
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <shared_mutex>
+
+// template <class Mutex> class shared_lock;
+
+// template <class Clock, class Duration>
+// bool try_lock_until(const chrono::time_point<Clock, Duration>& abs_time);
+
+#include <shared_mutex>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+bool try_lock_until_called = false;
+
+struct mutex
+{
+ template <class Clock, class Duration>
+ bool try_lock_shared_until(const std::chrono::time_point<Clock, Duration>& abs_time)
+ {
+ typedef std::chrono::milliseconds ms;
+ assert(Clock::now() - abs_time < ms(5));
+ try_lock_until_called = !try_lock_until_called;
+ return try_lock_until_called;
+ }
+ void unlock_shared() {}
+};
+
+mutex m;
+
+#endif // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ typedef std::chrono::steady_clock Clock;
+ std::shared_lock<mutex> lk(m, std::defer_lock);
+ assert(lk.try_lock_until(Clock::now()) == true);
+ assert(try_lock_until_called == true);
+ assert(lk.owns_lock() == true);
+ try
+ {
+ lk.try_lock_until(Clock::now());
+ assert(false);
+ }
+ catch (std::system_error& e)
+ {
+ assert(e.code().value() == EDEADLK);
+ }
+ lk.unlock();
+ assert(lk.try_lock_until(Clock::now()) == false);
+ assert(try_lock_until_called == false);
+ assert(lk.owns_lock() == false);
+ lk.release();
+ try
+ {
+ lk.try_lock_until(Clock::now());
+ assert(false);
+ }
+ catch (std::system_error& e)
+ {
+ assert(e.code().value() == EPERM);
+ }
+#endif // _LIBCPP_STD_VER > 11
+}
diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/unlock.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/unlock.pass.cpp
new file mode 100644
index 000000000000..eb08a45cde6e
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/unlock.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <shared_mutex>
+
+// template <class Mutex> class shared_lock;
+
+// void unlock();
+
+#include <shared_mutex>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+bool unlock_called = false;
+
+struct mutex
+{
+ void lock_shared() {}
+ void unlock_shared() {unlock_called = true;}
+};
+
+mutex m;
+
+#endif // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ std::shared_lock<mutex> lk(m);
+ lk.unlock();
+ assert(unlock_called == true);
+ assert(lk.owns_lock() == false);
+ try
+ {
+ lk.unlock();
+ assert(false);
+ }
+ catch (std::system_error& e)
+ {
+ assert(e.code().value() == EPERM);
+ }
+ lk.release();
+ try
+ {
+ lk.unlock();
+ assert(false);
+ }
+ catch (std::system_error& e)
+ {
+ assert(e.code().value() == EPERM);
+ }
+#endif // _LIBCPP_STD_VER > 11
+}
diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.mod/member_swap.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.mod/member_swap.pass.cpp
new file mode 100644
index 000000000000..8505763e44bc
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.mod/member_swap.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <shared_mutex>
+
+// template <class Mutex> class shared_lock;
+
+// void swap(shared_lock& u) noexcept;
+
+#include <shared_mutex>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+struct mutex
+{
+ void lock_shared() {}
+ void unlock_shared() {}
+};
+
+mutex m;
+
+#endif // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ std::shared_lock<mutex> lk1(m);
+ std::shared_lock<mutex> lk2;
+ lk1.swap(lk2);
+ assert(lk1.mutex() == nullptr);
+ assert(lk1.owns_lock() == false);
+ assert(lk2.mutex() == &m);
+ assert(lk2.owns_lock() == true);
+ static_assert(noexcept(lk1.swap(lk2)), "member swap must be noexcept");
+#endif // _LIBCPP_STD_VER > 11
+}
diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.mod/nonmember_swap.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.mod/nonmember_swap.pass.cpp
new file mode 100644
index 000000000000..057dbc4cd3b7
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.mod/nonmember_swap.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <shared_mutex>
+
+// template <class Mutex> class shared_lock;
+
+// template <class Mutex>
+// void swap(shared_lock<Mutex>& x, shared_lock<Mutex>& y) noexcept;
+
+#include <shared_mutex>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+struct mutex
+{
+ void lock_shared() {}
+ void unlock_shared() {}
+};
+
+mutex m;
+
+#endif // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ std::shared_lock<mutex> lk1(m);
+ std::shared_lock<mutex> lk2;
+ swap(lk1, lk2);
+ assert(lk1.mutex() == nullptr);
+ assert(lk1.owns_lock() == false);
+ assert(lk2.mutex() == &m);
+ assert(lk2.owns_lock() == true);
+ static_assert(noexcept(swap(lk1, lk2)), "non-member swap must be noexcept");
+#endif // _LIBCPP_STD_VER > 11
+}
diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.mod/release.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.mod/release.pass.cpp
new file mode 100644
index 000000000000..65ddca624725
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.mod/release.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <shared_mutex>
+
+// template <class Mutex> class shared_lock;
+
+// mutex_type* release() noexcept;
+
+#include <shared_mutex>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+struct mutex
+{
+ static int lock_count;
+ static int unlock_count;
+ void lock_shared() {++lock_count;}
+ void unlock_shared() {++unlock_count;}
+};
+
+int mutex::lock_count = 0;
+int mutex::unlock_count = 0;
+
+mutex m;
+
+#endif // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ std::shared_lock<mutex> lk(m);
+ assert(lk.mutex() == &m);
+ assert(lk.owns_lock() == true);
+ assert(mutex::lock_count == 1);
+ assert(mutex::unlock_count == 0);
+ assert(lk.release() == &m);
+ assert(lk.mutex() == nullptr);
+ assert(lk.owns_lock() == false);
+ assert(mutex::lock_count == 1);
+ assert(mutex::unlock_count == 0);
+ static_assert(noexcept(lk.release()), "release must be noexcept");
+#endif // _LIBCPP_STD_VER > 11
+}
diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.obs/mutex.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.obs/mutex.pass.cpp
new file mode 100644
index 000000000000..4eb75d8f050e
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.obs/mutex.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <shared_mutex>
+
+// template <class Mutex> class shared_lock;
+
+// mutex_type *mutex() const noexcept;
+
+#include <shared_mutex>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+std::shared_timed_mutex m;
+
+#endif // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ std::shared_lock<std::shared_timed_mutex> lk0;
+ assert(lk0.mutex() == nullptr);
+ std::shared_lock<std::shared_timed_mutex> lk1(m);
+ assert(lk1.mutex() == &m);
+ lk1.unlock();
+ assert(lk1.mutex() == &m);
+ static_assert(noexcept(lk0.mutex()), "mutex() must be noexcept");
+#endif // _LIBCPP_STD_VER > 11
+}
diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.obs/op_bool.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.obs/op_bool.pass.cpp
new file mode 100644
index 000000000000..d079d2d8b03a
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.obs/op_bool.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <shared_mutex>
+
+// template <class Mutex> class shared_lock;
+
+// explicit operator bool() const noexcept;
+
+#include <shared_mutex>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+std::shared_timed_mutex m;
+
+#endif // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ std::shared_lock<std::shared_timed_mutex> lk0;
+ assert(static_cast<bool>(lk0) == false);
+ std::shared_lock<std::shared_timed_mutex> lk1(m);
+ assert(static_cast<bool>(lk1) == true);
+ lk1.unlock();
+ assert(static_cast<bool>(lk1) == false);
+ static_assert(noexcept(static_cast<bool>(lk0)), "explicit operator bool() must be noexcept");
+#endif // _LIBCPP_STD_VER > 11
+}
diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.obs/owns_lock.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.obs/owns_lock.pass.cpp
new file mode 100644
index 000000000000..d64b0aa6a736
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.obs/owns_lock.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <shared_mutex>
+
+// template <class Mutex> class shared_lock;
+
+// bool owns_lock() const noexcept;
+
+#include <shared_mutex>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+std::shared_timed_mutex m;
+
+#endif // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ std::shared_lock<std::shared_timed_mutex> lk0;
+ assert(lk0.owns_lock() == false);
+ std::shared_lock<std::shared_timed_mutex> lk1(m);
+ assert(lk1.owns_lock() == true);
+ lk1.unlock();
+ assert(lk1.owns_lock() == false);
+ static_assert(noexcept(lk0.owns_lock()), "owns_lock must be noexcept");
+#endif // _LIBCPP_STD_VER > 11
+}
diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/types.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/types.pass.cpp
new file mode 100644
index 000000000000..c153b455f404
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/types.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <shared_mutex>
+
+// template <class Mutex>
+// class shared_lock
+// {
+// public:
+// typedef Mutex mutex_type;
+// ...
+// };
+
+#include <shared_mutex>
+#include <type_traits>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ static_assert((std::is_same<std::shared_lock<std::mutex>::mutex_type,
+ std::mutex>::value), "");
+#endif // _LIBCPP_STD_VER > 11
+}
diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/copy_assign.fail.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/copy_assign.fail.cpp
new file mode 100644
index 000000000000..4f477449d6a2
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/copy_assign.fail.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// template <class Mutex> class unique_lock;
+
+// unique_lock& operator=(unique_lock const&) = delete;
+
+#include <mutex>
+#include <cassert>
+
+std::mutex m0;
+std::mutex m1;
+
+int main()
+{
+ std::unique_lock<std::mutex> lk0(m0);
+ std::unique_lock<std::mutex> lk1(m1);
+ lk1 = lk0;
+ assert(lk1.mutex() == &m0);
+ assert(lk1.owns_lock() == true);
+ assert(lk0.mutex() == nullptr);
+ assert(lk0.owns_lock() == false);
+}
diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/copy_ctor.fail.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/copy_ctor.fail.cpp
new file mode 100644
index 000000000000..4888fe90d92c
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/copy_ctor.fail.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// template <class Mutex> class unique_lock;
+
+// unique_lock(unique_lock const&) = delete;
+
+#include <mutex>
+#include <cassert>
+
+std::mutex m;
+
+int main()
+{
+ std::unique_lock<std::mutex> lk0(m);
+ std::unique_lock<std::mutex> lk = lk0;
+ assert(lk.mutex() == &m);
+ assert(lk.owns_lock() == true);
+ assert(lk0.mutex() == nullptr);
+ assert(lk0.owns_lock() == false);
+}
diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/default.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/default.pass.cpp
new file mode 100644
index 000000000000..a49bc507171c
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/default.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <mutex>
+
+// template <class Mutex> class unique_lock;
+
+// unique_lock();
+
+#include <mutex>
+#include <cassert>
+
+int main()
+{
+ std::unique_lock<std::mutex> ul;
+ assert(!ul.owns_lock());
+ assert(ul.mutex() == nullptr);
+}
diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/move_assign.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/move_assign.pass.cpp
new file mode 100644
index 000000000000..4dff853088ac
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/move_assign.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <mutex>
+
+// template <class Mutex> class unique_lock;
+
+// unique_lock& operator=(unique_lock&& u);
+
+#include <mutex>
+#include <cassert>
+
+std::mutex m0;
+std::mutex m1;
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ std::unique_lock<std::mutex> lk0(m0);
+ std::unique_lock<std::mutex> lk1(m1);
+ lk1 = std::move(lk0);
+ assert(lk1.mutex() == &m0);
+ assert(lk1.owns_lock() == true);
+ assert(lk0.mutex() == nullptr);
+ assert(lk0.owns_lock() == false);
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/move_ctor.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/move_ctor.pass.cpp
new file mode 100644
index 000000000000..aa640ee6d746
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/move_ctor.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <mutex>
+
+// template <class Mutex> class unique_lock;
+
+// unique_lock(unique_lock&& u);
+
+#include <mutex>
+#include <cassert>
+
+std::mutex m;
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ std::unique_lock<std::mutex> lk0(m);
+ std::unique_lock<std::mutex> lk = std::move(lk0);
+ assert(lk.mutex() == &m);
+ assert(lk.owns_lock() == true);
+ assert(lk0.mutex() == nullptr);
+ assert(lk0.owns_lock() == false);
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex.pass.cpp
new file mode 100644
index 000000000000..1f7217a8300e
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <mutex>
+
+// template <class Mutex> class unique_lock;
+
+// explicit unique_lock(mutex_type& m);
+
+#include <mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+std::mutex m;
+
+typedef std::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f()
+{
+ time_point t0 = Clock::now();
+ time_point t1;
+ {
+ std::unique_lock<std::mutex> ul(m);
+ t1 = Clock::now();
+ }
+ ns d = t1 - t0 - ms(250);
+ assert(d < ms(50)); // within 50ms
+}
+
+int main()
+{
+ m.lock();
+ std::thread t(f);
+ std::this_thread::sleep_for(ms(250));
+ m.unlock();
+ t.join();
+}
diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_adopt_lock.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_adopt_lock.pass.cpp
new file mode 100644
index 000000000000..9c3a7b6505a4
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_adopt_lock.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <mutex>
+
+// template <class Mutex> class unique_lock;
+
+// unique_lock(mutex_type& m, adopt_lock_t);
+
+#include <mutex>
+#include <cassert>
+
+int main()
+{
+ std::mutex m;
+ m.lock();
+ std::unique_lock<std::mutex> lk(m, std::adopt_lock);
+ assert(lk.mutex() == &m);
+ assert(lk.owns_lock() == true);
+}
diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_defer_lock.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_defer_lock.pass.cpp
new file mode 100644
index 000000000000..bf622311f013
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_defer_lock.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <mutex>
+
+// template <class Mutex> class unique_lock;
+
+// unique_lock(mutex_type& m, defer_lock_t);
+
+#include <mutex>
+#include <cassert>
+
+int main()
+{
+ std::mutex m;
+ std::unique_lock<std::mutex> lk(m, std::defer_lock);
+ assert(lk.mutex() == &m);
+ assert(lk.owns_lock() == false);
+}
diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_duration.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_duration.pass.cpp
new file mode 100644
index 000000000000..33e400b0da80
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_duration.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <mutex>
+
+// class timed_mutex;
+
+// template <class Rep, class Period>
+// unique_lock(mutex_type& m, const chrono::duration<Rep, Period>& rel_time);
+
+#include <mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+std::timed_mutex m;
+
+typedef std::chrono::steady_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f1()
+{
+ time_point t0 = Clock::now();
+ std::unique_lock<std::timed_mutex> lk(m, ms(300));
+ assert(lk.owns_lock() == true);
+ time_point t1 = Clock::now();
+ ns d = t1 - t0 - ms(250);
+ assert(d < ms(50)); // within 50ms
+}
+
+void f2()
+{
+ time_point t0 = Clock::now();
+ std::unique_lock<std::timed_mutex> lk(m, ms(250));
+ assert(lk.owns_lock() == false);
+ time_point t1 = Clock::now();
+ ns d = t1 - t0 - ms(250);
+ assert(d < ms(50)); // within 50ms
+}
+
+int main()
+{
+ {
+ m.lock();
+ std::thread t(f1);
+ std::this_thread::sleep_for(ms(250));
+ m.unlock();
+ t.join();
+ }
+ {
+ m.lock();
+ std::thread t(f2);
+ std::this_thread::sleep_for(ms(300));
+ m.unlock();
+ t.join();
+ }
+}
diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_time_point.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_time_point.pass.cpp
new file mode 100644
index 000000000000..2ead67097730
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_time_point.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <mutex>
+
+// class timed_mutex;
+
+// template <class Clock, class Duration>
+// unique_lock(mutex_type& m, const chrono::time_point<Clock, Duration>& abs_time);
+
+#include <mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+std::timed_mutex m;
+
+typedef std::chrono::steady_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f1()
+{
+ time_point t0 = Clock::now();
+ std::unique_lock<std::timed_mutex> lk(m, Clock::now() + ms(300));
+ assert(lk.owns_lock() == true);
+ time_point t1 = Clock::now();
+ ns d = t1 - t0 - ms(250);
+ assert(d < ns(50000000)); // within 50ms
+}
+
+void f2()
+{
+ time_point t0 = Clock::now();
+ std::unique_lock<std::timed_mutex> lk(m, Clock::now() + ms(250));
+ assert(lk.owns_lock() == false);
+ time_point t1 = Clock::now();
+ ns d = t1 - t0 - ms(250);
+ assert(d < ms(50)); // within 50ms
+}
+
+int main()
+{
+ {
+ m.lock();
+ std::thread t(f1);
+ std::this_thread::sleep_for(ms(250));
+ m.unlock();
+ t.join();
+ }
+ {
+ m.lock();
+ std::thread t(f2);
+ std::this_thread::sleep_for(ms(300));
+ m.unlock();
+ t.join();
+ }
+}
diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_try_to_lock.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_try_to_lock.pass.cpp
new file mode 100644
index 000000000000..cea58c554a9b
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_try_to_lock.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <mutex>
+
+// template <class Mutex> class unique_lock;
+
+// unique_lock(mutex_type& m, try_to_lock_t);
+
+#include <mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+std::mutex m;
+
+typedef std::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f()
+{
+ time_point t0 = Clock::now();
+ {
+ std::unique_lock<std::mutex> lk(m, std::try_to_lock);
+ assert(lk.owns_lock() == false);
+ }
+ {
+ std::unique_lock<std::mutex> lk(m, std::try_to_lock);
+ assert(lk.owns_lock() == false);
+ }
+ {
+ std::unique_lock<std::mutex> lk(m, std::try_to_lock);
+ assert(lk.owns_lock() == false);
+ }
+ while (true)
+ {
+ std::unique_lock<std::mutex> lk(m, std::try_to_lock);
+ if (lk.owns_lock())
+ break;
+ }
+ time_point t1 = Clock::now();
+ ns d = t1 - t0 - ms(250);
+ assert(d < ms(200)); // within 200ms
+}
+
+int main()
+{
+ m.lock();
+ std::thread t(f);
+ std::this_thread::sleep_for(ms(250));
+ m.unlock();
+ t.join();
+}
diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/lock.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/lock.pass.cpp
new file mode 100644
index 000000000000..f5408df98199
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/lock.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <mutex>
+
+// template <class Mutex> class unique_lock;
+
+// void lock();
+
+#include <mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+std::mutex m;
+
+typedef std::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f()
+{
+ std::unique_lock<std::mutex> lk(m, std::defer_lock);
+ time_point t0 = Clock::now();
+ lk.lock();
+ time_point t1 = Clock::now();
+ assert(lk.owns_lock() == true);
+ ns d = t1 - t0 - ms(250);
+ assert(d < ms(25)); // within 25ms
+ try
+ {
+ lk.lock();
+ assert(false);
+ }
+ catch (std::system_error& e)
+ {
+ assert(e.code().value() == EDEADLK);
+ }
+ lk.unlock();
+ lk.release();
+ try
+ {
+ lk.lock();
+ assert(false);
+ }
+ catch (std::system_error& e)
+ {
+ assert(e.code().value() == EPERM);
+ }
+}
+
+int main()
+{
+ m.lock();
+ std::thread t(f);
+ std::this_thread::sleep_for(ms(250));
+ m.unlock();
+ t.join();
+}
diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock.pass.cpp
new file mode 100644
index 000000000000..bd88577f0a22
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <mutex>
+
+// template <class Mutex> class unique_lock;
+
+// bool try_lock();
+
+#include <mutex>
+#include <cassert>
+
+bool try_lock_called = false;
+
+struct mutex
+{
+ bool try_lock()
+ {
+ try_lock_called = !try_lock_called;
+ return try_lock_called;
+ }
+ void unlock() {}
+};
+
+mutex m;
+
+int main()
+{
+ std::unique_lock<mutex> lk(m, std::defer_lock);
+ assert(lk.try_lock() == true);
+ assert(try_lock_called == true);
+ assert(lk.owns_lock() == true);
+ try
+ {
+ lk.try_lock();
+ assert(false);
+ }
+ catch (std::system_error& e)
+ {
+ assert(e.code().value() == EDEADLK);
+ }
+ lk.unlock();
+ assert(lk.try_lock() == false);
+ assert(try_lock_called == false);
+ assert(lk.owns_lock() == false);
+ lk.release();
+ try
+ {
+ lk.try_lock();
+ assert(false);
+ }
+ catch (std::system_error& e)
+ {
+ assert(e.code().value() == EPERM);
+ }
+}
diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock_for.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock_for.pass.cpp
new file mode 100644
index 000000000000..558f079463a4
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock_for.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <mutex>
+
+// template <class Mutex> class unique_lock;
+
+// template <class Rep, class Period>
+// bool try_lock_for(const chrono::duration<Rep, Period>& rel_time);
+
+#include <mutex>
+#include <cassert>
+
+bool try_lock_for_called = false;
+
+typedef std::chrono::milliseconds ms;
+
+struct mutex
+{
+ template <class Rep, class Period>
+ bool try_lock_for(const std::chrono::duration<Rep, Period>& rel_time)
+ {
+ assert(rel_time == ms(5));
+ try_lock_for_called = !try_lock_for_called;
+ return try_lock_for_called;
+ }
+ void unlock() {}
+};
+
+mutex m;
+
+int main()
+{
+ std::unique_lock<mutex> lk(m, std::defer_lock);
+ assert(lk.try_lock_for(ms(5)) == true);
+ assert(try_lock_for_called == true);
+ assert(lk.owns_lock() == true);
+ try
+ {
+ lk.try_lock_for(ms(5));
+ assert(false);
+ }
+ catch (std::system_error& e)
+ {
+ assert(e.code().value() == EDEADLK);
+ }
+ lk.unlock();
+ assert(lk.try_lock_for(ms(5)) == false);
+ assert(try_lock_for_called == false);
+ assert(lk.owns_lock() == false);
+ lk.release();
+ try
+ {
+ lk.try_lock_for(ms(5));
+ assert(false);
+ }
+ catch (std::system_error& e)
+ {
+ assert(e.code().value() == EPERM);
+ }
+}
diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock_until.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock_until.pass.cpp
new file mode 100644
index 000000000000..24e4d109a097
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock_until.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <mutex>
+
+// template <class Mutex> class unique_lock;
+
+// template <class Clock, class Duration>
+// bool try_lock_until(const chrono::time_point<Clock, Duration>& abs_time);
+
+#include <mutex>
+#include <cassert>
+
+bool try_lock_until_called = false;
+
+struct mutex
+{
+ template <class Clock, class Duration>
+ bool try_lock_until(const std::chrono::time_point<Clock, Duration>& abs_time)
+ {
+ typedef std::chrono::milliseconds ms;
+ assert(Clock::now() - abs_time < ms(5));
+ try_lock_until_called = !try_lock_until_called;
+ return try_lock_until_called;
+ }
+ void unlock() {}
+};
+
+mutex m;
+
+int main()
+{
+ typedef std::chrono::steady_clock Clock;
+ std::unique_lock<mutex> lk(m, std::defer_lock);
+ assert(lk.try_lock_until(Clock::now()) == true);
+ assert(try_lock_until_called == true);
+ assert(lk.owns_lock() == true);
+ try
+ {
+ lk.try_lock_until(Clock::now());
+ assert(false);
+ }
+ catch (std::system_error& e)
+ {
+ assert(e.code().value() == EDEADLK);
+ }
+ lk.unlock();
+ assert(lk.try_lock_until(Clock::now()) == false);
+ assert(try_lock_until_called == false);
+ assert(lk.owns_lock() == false);
+ lk.release();
+ try
+ {
+ lk.try_lock_until(Clock::now());
+ assert(false);
+ }
+ catch (std::system_error& e)
+ {
+ assert(e.code().value() == EPERM);
+ }
+}
diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/unlock.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/unlock.pass.cpp
new file mode 100644
index 000000000000..bbabfc41df11
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/unlock.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <mutex>
+
+// template <class Mutex> class unique_lock;
+
+// void unlock();
+
+#include <mutex>
+#include <cassert>
+
+bool unlock_called = false;
+
+struct mutex
+{
+ void lock() {}
+ void unlock() {unlock_called = true;}
+};
+
+mutex m;
+
+int main()
+{
+ std::unique_lock<mutex> lk(m);
+ lk.unlock();
+ assert(unlock_called == true);
+ assert(lk.owns_lock() == false);
+ try
+ {
+ lk.unlock();
+ assert(false);
+ }
+ catch (std::system_error& e)
+ {
+ assert(e.code().value() == EPERM);
+ }
+ lk.release();
+ try
+ {
+ lk.unlock();
+ assert(false);
+ }
+ catch (std::system_error& e)
+ {
+ assert(e.code().value() == EPERM);
+ }
+}
diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.mod/member_swap.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.mod/member_swap.pass.cpp
new file mode 100644
index 000000000000..598d53a65c85
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.mod/member_swap.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <mutex>
+
+// template <class Mutex> class unique_lock;
+
+// void swap(unique_lock& u);
+
+#include <mutex>
+#include <cassert>
+
+struct mutex
+{
+ void lock() {}
+ void unlock() {}
+};
+
+mutex m;
+
+int main()
+{
+ std::unique_lock<mutex> lk1(m);
+ std::unique_lock<mutex> lk2;
+ lk1.swap(lk2);
+ assert(lk1.mutex() == nullptr);
+ assert(lk1.owns_lock() == false);
+ assert(lk2.mutex() == &m);
+ assert(lk2.owns_lock() == true);
+}
diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.mod/nonmember_swap.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.mod/nonmember_swap.pass.cpp
new file mode 100644
index 000000000000..3fc8c28f5071
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.mod/nonmember_swap.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <mutex>
+
+// template <class Mutex> class unique_lock;
+
+// template <class Mutex>
+// void swap(unique_lock<Mutex>& x, unique_lock<Mutex>& y);
+
+#include <mutex>
+#include <cassert>
+
+struct mutex
+{
+ void lock() {}
+ void unlock() {}
+};
+
+mutex m;
+
+int main()
+{
+ std::unique_lock<mutex> lk1(m);
+ std::unique_lock<mutex> lk2;
+ swap(lk1, lk2);
+ assert(lk1.mutex() == nullptr);
+ assert(lk1.owns_lock() == false);
+ assert(lk2.mutex() == &m);
+ assert(lk2.owns_lock() == true);
+}
diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.mod/release.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.mod/release.pass.cpp
new file mode 100644
index 000000000000..89c28e6be73c
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.mod/release.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <mutex>
+
+// template <class Mutex> class unique_lock;
+
+// mutex_type* release() noexcept;
+
+#include <mutex>
+#include <cassert>
+
+struct mutex
+{
+ static int lock_count;
+ static int unlock_count;
+ void lock() {++lock_count;}
+ void unlock() {++unlock_count;}
+};
+
+int mutex::lock_count = 0;
+int mutex::unlock_count = 0;
+
+mutex m;
+
+int main()
+{
+ std::unique_lock<mutex> lk(m);
+ assert(lk.mutex() == &m);
+ assert(lk.owns_lock() == true);
+ assert(mutex::lock_count == 1);
+ assert(mutex::unlock_count == 0);
+ assert(lk.release() == &m);
+ assert(lk.mutex() == nullptr);
+ assert(lk.owns_lock() == false);
+ assert(mutex::lock_count == 1);
+ assert(mutex::unlock_count == 0);
+}
diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.obs/mutex.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.obs/mutex.pass.cpp
new file mode 100644
index 000000000000..bc1e3e5eb774
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.obs/mutex.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <mutex>
+
+// template <class Mutex> class unique_lock;
+
+// mutex_type *mutex() const;
+
+#include <mutex>
+#include <cassert>
+
+std::mutex m;
+
+int main()
+{
+ std::unique_lock<std::mutex> lk0;
+ assert(lk0.mutex() == nullptr);
+ std::unique_lock<std::mutex> lk1(m);
+ assert(lk1.mutex() == &m);
+ lk1.unlock();
+ assert(lk1.mutex() == &m);
+}
diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.obs/op_bool.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.obs/op_bool.pass.cpp
new file mode 100644
index 000000000000..7004ac0092e1
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.obs/op_bool.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <mutex>
+
+// template <class Mutex> class unique_lock;
+
+// explicit operator bool() const;
+
+#include <mutex>
+#include <cassert>
+
+std::mutex m;
+
+int main()
+{
+ std::unique_lock<std::mutex> lk0;
+ assert(static_cast<bool>(lk0) == false);
+ std::unique_lock<std::mutex> lk1(m);
+ assert(static_cast<bool>(lk1) == true);
+ lk1.unlock();
+ assert(static_cast<bool>(lk1) == false);
+}
diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.obs/owns_lock.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.obs/owns_lock.pass.cpp
new file mode 100644
index 000000000000..f53af35ff284
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.obs/owns_lock.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <mutex>
+
+// template <class Mutex> class unique_lock;
+
+// bool owns_lock() const;
+
+#include <mutex>
+#include <cassert>
+
+std::mutex m;
+
+int main()
+{
+ std::unique_lock<std::mutex> lk0;
+ assert(lk0.owns_lock() == false);
+ std::unique_lock<std::mutex> lk1(m);
+ assert(lk1.owns_lock() == true);
+ lk1.unlock();
+ assert(lk1.owns_lock() == false);
+}
diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/types.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/types.pass.cpp
new file mode 100644
index 000000000000..f8bcb6d0d22f
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/types.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <mutex>
+
+// template <class Mutex>
+// class unique_lock
+// {
+// public:
+// typedef Mutex mutex_type;
+// ...
+// };
+
+#include <mutex>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_same<std::unique_lock<std::mutex>::mutex_type,
+ std::mutex>::value), "");
+}
diff --git a/test/std/thread/thread.mutex/thread.lock/types.pass.cpp b/test/std/thread/thread.mutex/thread.lock/types.pass.cpp
new file mode 100644
index 000000000000..64df0680b0b9
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.lock/types.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <mutex>
+
+// struct defer_lock_t {};
+// struct try_to_lock_t {};
+// struct adopt_lock_t {};
+//
+// constexpr defer_lock_t defer_lock{};
+// constexpr try_to_lock_t try_to_lock{};
+// constexpr adopt_lock_t adopt_lock{};
+
+#include <mutex>
+#include <type_traits>
+
+int main()
+{
+ typedef std::defer_lock_t T1;
+ typedef std::try_to_lock_t T2;
+ typedef std::adopt_lock_t T3;
+
+ T1 t1 = std::defer_lock;
+ T2 t2 = std::try_to_lock;
+ T3 t3 = std::adopt_lock;
+}
diff --git a/test/std/thread/thread.mutex/thread.mutex.requirements/nothing_to_do.pass.cpp b/test/std/thread/thread.mutex/thread.mutex.requirements/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.mutex.requirements/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.general/nothing_to_do.pass.cpp b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.general/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.general/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/nothing_to_do.pass.cpp b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/assign.fail.cpp b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/assign.fail.cpp
new file mode 100644
index 000000000000..7f6333af9e29
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/assign.fail.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// class mutex;
+
+// mutex& operator=(const mutex&) = delete;
+
+#include <mutex>
+
+int main()
+{
+ std::mutex m0;
+ std::mutex m1;
+ m1 = m0;
+}
diff --git a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/copy.fail.cpp b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/copy.fail.cpp
new file mode 100644
index 000000000000..7e1a07ac8c1a
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/copy.fail.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// class mutex;
+
+// mutex(const mutex&) = delete;
+
+#include <mutex>
+
+int main()
+{
+ std::mutex m0;
+ std::mutex m1(m0);
+}
diff --git a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/default.pass.cpp b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/default.pass.cpp
new file mode 100644
index 000000000000..4de42fbd0243
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/default.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <mutex>
+
+// class mutex;
+
+// mutex();
+
+#include <mutex>
+
+int main()
+{
+ std::mutex m;
+}
diff --git a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/lock.pass.cpp b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/lock.pass.cpp
new file mode 100644
index 000000000000..ba2d54d58663
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/lock.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <mutex>
+
+// class mutex;
+
+// void lock();
+
+#include <mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+#include <iostream>
+
+std::mutex m;
+
+typedef std::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f()
+{
+ time_point t0 = Clock::now();
+ m.lock();
+ time_point t1 = Clock::now();
+ m.unlock();
+ ns d = t1 - t0 - ms(250);
+ assert(d < ms(50)); // within 50ms
+}
+
+int main()
+{
+ m.lock();
+ std::thread t(f);
+ std::this_thread::sleep_for(ms(250));
+ m.unlock();
+ t.join();
+}
diff --git a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/native_handle.pass.cpp b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/native_handle.pass.cpp
new file mode 100644
index 000000000000..12c80f02c340
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/native_handle.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <mutex>
+
+// class mutex;
+
+// typedef pthread_mutex_t* native_handle_type;
+// native_handle_type native_handle();
+
+#include <mutex>
+#include <cassert>
+
+int main()
+{
+ std::mutex m;
+ pthread_mutex_t* h = m.native_handle();
+ assert(h);
+}
diff --git a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/try_lock.pass.cpp b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/try_lock.pass.cpp
new file mode 100644
index 000000000000..fe8f351d7db7
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/try_lock.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <mutex>
+
+// class mutex;
+
+// bool try_lock();
+
+#include <mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+std::mutex m;
+
+typedef std::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f()
+{
+ time_point t0 = Clock::now();
+ assert(!m.try_lock());
+ assert(!m.try_lock());
+ assert(!m.try_lock());
+ while(!m.try_lock())
+ ;
+ time_point t1 = Clock::now();
+ m.unlock();
+ ns d = t1 - t0 - ms(250);
+ assert(d < ms(200)); // within 200ms
+}
+
+int main()
+{
+ m.lock();
+ std::thread t(f);
+ std::this_thread::sleep_for(ms(250));
+ m.unlock();
+ t.join();
+}
diff --git a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/assign.fail.cpp b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/assign.fail.cpp
new file mode 100644
index 000000000000..61b56216e8fb
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/assign.fail.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// class recursive_mutex;
+
+// recursive_mutex& operator=(const recursive_mutex&) = delete;
+
+#include <mutex>
+
+int main()
+{
+ std::recursive_mutex m0;
+ std::recursive_mutex m1;
+ m1 = m0;
+}
diff --git a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/copy.fail.cpp b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/copy.fail.cpp
new file mode 100644
index 000000000000..0239c0475ac2
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/copy.fail.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// class recursive_mutex;
+
+// recursive_mutex(const recursive_mutex&) = delete;
+
+#include <mutex>
+
+int main()
+{
+ std::recursive_mutex m0;
+ std::recursive_mutex m1(m0);
+}
diff --git a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/default.pass.cpp b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/default.pass.cpp
new file mode 100644
index 000000000000..8c5d26675d3f
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/default.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <mutex>
+
+// class recursive_mutex;
+
+// recursive_mutex();
+
+#include <mutex>
+
+int main()
+{
+ std::recursive_mutex m;
+}
diff --git a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/lock.pass.cpp b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/lock.pass.cpp
new file mode 100644
index 000000000000..abebe906378c
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/lock.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <mutex>
+
+// class recursive_mutex;
+
+// void lock();
+
+#include <mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+#include <iostream>
+
+std::recursive_mutex m;
+
+typedef std::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f()
+{
+ time_point t0 = Clock::now();
+ m.lock();
+ time_point t1 = Clock::now();
+ m.lock();
+ m.unlock();
+ m.unlock();
+ ns d = t1 - t0 - ms(250);
+ assert(d < ms(200)); // within 200ms
+}
+
+int main()
+{
+ m.lock();
+ std::thread t(f);
+ std::this_thread::sleep_for(ms(250));
+ m.unlock();
+ t.join();
+}
diff --git a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/native_handle.pass.cpp b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/native_handle.pass.cpp
new file mode 100644
index 000000000000..10626bc4072e
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/native_handle.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <mutex>
+
+// class recursive_mutex;
+
+// typedef pthread_mutex_t* native_handle_type;
+// native_handle_type native_handle();
+
+#include <mutex>
+#include <cassert>
+
+int main()
+{
+ std::recursive_mutex m;
+ pthread_mutex_t* h = m.native_handle();
+ assert(h);
+}
diff --git a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/try_lock.pass.cpp b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/try_lock.pass.cpp
new file mode 100644
index 000000000000..ff546d4ad66d
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/try_lock.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <mutex>
+
+// class recursive_mutex;
+
+// bool try_lock();
+
+#include <mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+std::recursive_mutex m;
+
+typedef std::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f()
+{
+ time_point t0 = Clock::now();
+ assert(!m.try_lock());
+ assert(!m.try_lock());
+ assert(!m.try_lock());
+ while(!m.try_lock())
+ ;
+ time_point t1 = Clock::now();
+ assert(m.try_lock());
+ m.unlock();
+ m.unlock();
+ ns d = t1 - t0 - ms(250);
+ assert(d < ms(200)); // within 200ms
+}
+
+int main()
+{
+ m.lock();
+ std::thread t(f);
+ std::this_thread::sleep_for(ms(250));
+ m.unlock();
+ t.join();
+}
diff --git a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/nothing_to_do.pass.cpp b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/assign.fail.cpp b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/assign.fail.cpp
new file mode 100644
index 000000000000..7bcb2d61379a
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/assign.fail.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <shared_mutex>
+
+// class shared_mutex;
+
+// shared_mutex& operator=(const shared_mutex&) = delete;
+
+#include <shared_mutex>
+
+#include "test_macros.h"
+
+int main()
+{
+#if TEST_STD_VER > 14
+ std::shared_mutex m0;
+ std::shared_mutex m1;
+ m1 = m0;
+#else
+# error
+#endif
+}
diff --git a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/copy.fail.cpp b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/copy.fail.cpp
new file mode 100644
index 000000000000..af064aeee26c
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/copy.fail.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <shared_mutex>
+
+// class shared_mutex;
+
+// shared_mutex(const shared_mutex&) = delete;
+
+#include <shared_mutex>
+
+#include "test_macros.h"
+
+int main()
+{
+#if TEST_STD_VER > 14
+ std::shared_mutex m0;
+ std::shared_mutex m1(m0);
+#else
+# error
+#endif
+}
diff --git a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/default.pass.cpp b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/default.pass.cpp
new file mode 100644
index 000000000000..c61a93aa0c7f
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/default.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+// UNSUPPORTED: c++03, c++98, c++11, c++14
+
+// <shared_mutex>
+
+// class shared_mutex;
+
+// shared_mutex();
+
+#include <shared_mutex>
+
+int main()
+{
+ std::shared_mutex m;
+}
diff --git a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/lock.pass.cpp b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/lock.pass.cpp
new file mode 100644
index 000000000000..9bf7a79e3400
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/lock.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+// UNSUPPORTED: c++03, c++98, c++11, c++14
+
+// <shared_mutex>
+
+// class shared_mutex;
+
+// void lock();
+
+#include <shared_mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+
+std::shared_mutex m;
+
+typedef std::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f()
+{
+ time_point t0 = Clock::now();
+ m.lock();
+ time_point t1 = Clock::now();
+ m.unlock();
+ ns d = t1 - t0 - ms(250);
+ assert(d < ms(50)); // within 50ms
+}
+
+int main()
+{
+ m.lock();
+ std::thread t(f);
+ std::this_thread::sleep_for(ms(250));
+ m.unlock();
+ t.join();
+}
diff --git a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/lock_shared.pass.cpp b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/lock_shared.pass.cpp
new file mode 100644
index 000000000000..3ffa9e2d0065
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/lock_shared.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+// UNSUPPORTED: c++03, c++98, c++11, c++14
+
+// <shared_mutex>
+
+// class shared_mutex;
+
+// void lock_shared();
+
+#include <shared_mutex>
+#include <thread>
+#include <vector>
+#include <cstdlib>
+#include <cassert>
+
+std::shared_mutex m;
+
+typedef std::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f()
+{
+ time_point t0 = Clock::now();
+ m.lock_shared();
+ time_point t1 = Clock::now();
+ m.unlock_shared();
+ ns d = t1 - t0 - ms(250);
+ assert(d < ms(50)); // within 50ms
+}
+
+void g()
+{
+ time_point t0 = Clock::now();
+ m.lock_shared();
+ time_point t1 = Clock::now();
+ m.unlock_shared();
+ ns d = t1 - t0;
+ assert(d < ms(50)); // within 50ms
+}
+
+
+int main()
+{
+ m.lock();
+ std::vector<std::thread> v;
+ for (int i = 0; i < 5; ++i)
+ v.push_back(std::thread(f));
+ std::this_thread::sleep_for(ms(250));
+ m.unlock();
+ for (auto& t : v)
+ t.join();
+ m.lock_shared();
+ for (auto& t : v)
+ t = std::thread(g);
+ std::thread q(f);
+ std::this_thread::sleep_for(ms(250));
+ m.unlock_shared();
+ for (auto& t : v)
+ t.join();
+ q.join();
+}
diff --git a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/try_lock.pass.cpp b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/try_lock.pass.cpp
new file mode 100644
index 000000000000..6f3ca24a4558
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/try_lock.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+// UNSUPPORTED: c++03, c++98, c++11, c++14
+
+// <shared_mutex>
+
+// class shared_mutex;
+
+// bool try_lock();
+
+#include <shared_mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+std::shared_mutex m;
+
+typedef std::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f()
+{
+ time_point t0 = Clock::now();
+ assert(!m.try_lock());
+ assert(!m.try_lock());
+ assert(!m.try_lock());
+ while(!m.try_lock())
+ ;
+ time_point t1 = Clock::now();
+ m.unlock();
+ ns d = t1 - t0 - ms(250);
+ assert(d < ms(200)); // within 200ms
+}
+
+int main()
+{
+ m.lock();
+ std::thread t(f);
+ std::this_thread::sleep_for(ms(250));
+ m.unlock();
+ t.join();
+}
diff --git a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/try_lock_shared.pass.cpp b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/try_lock_shared.pass.cpp
new file mode 100644
index 000000000000..52007155ba5f
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/try_lock_shared.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+// UNSUPPORTED: c++03, c++98, c++11, c++14
+
+// <shared_mutex>
+
+// class shared_mutex;
+
+// bool try_lock_shared();
+
+#include <shared_mutex>
+#include <thread>
+#include <vector>
+#include <cstdlib>
+#include <cassert>
+
+std::shared_mutex m;
+
+typedef std::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f()
+{
+ time_point t0 = Clock::now();
+ assert(!m.try_lock_shared());
+ assert(!m.try_lock_shared());
+ assert(!m.try_lock_shared());
+ while(!m.try_lock_shared())
+ ;
+ time_point t1 = Clock::now();
+ m.unlock_shared();
+ ns d = t1 - t0 - ms(250);
+ assert(d < ms(200)); // within 200ms
+}
+
+
+int main()
+{
+ m.lock();
+ std::vector<std::thread> v;
+ for (int i = 0; i < 5; ++i)
+ v.push_back(std::thread(f));
+ std::this_thread::sleep_for(ms(250));
+ m.unlock();
+ for (auto& t : v)
+ t.join();
+}
diff --git a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/nothing_to_do.pass.cpp b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/assign.fail.cpp b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/assign.fail.cpp
new file mode 100644
index 000000000000..528aaca6d9e1
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/assign.fail.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <shared_mutex>
+
+// class shared_timed_mutex;
+
+// shared_timed_mutex& operator=(const shared_timed_mutex&) = delete;
+
+#include <shared_mutex>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ std::shared_timed_mutex m0;
+ std::shared_timed_mutex m1;
+ m1 = m0;
+#else
+# error
+#endif
+}
diff --git a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/copy.fail.cpp b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/copy.fail.cpp
new file mode 100644
index 000000000000..dbf01002e691
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/copy.fail.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <shared_mutex>
+
+// class shared_timed_mutex;
+
+// shared_timed_mutex(const shared_timed_mutex&) = delete;
+
+#include <shared_mutex>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ std::shared_timed_mutex m0;
+ std::shared_timed_mutex m1(m0);
+#else
+# error
+#endif
+}
diff --git a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/default.pass.cpp b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/default.pass.cpp
new file mode 100644
index 000000000000..45cd563f9407
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/default.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+// UNSUPPORTED: c++03, c++98, c++11
+
+// <shared_mutex>
+
+// class shared_timed_mutex;
+
+// shared_timed_mutex();
+
+#include <shared_mutex>
+
+int main()
+{
+ std::shared_timed_mutex m;
+}
diff --git a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/lock.pass.cpp b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/lock.pass.cpp
new file mode 100644
index 000000000000..62bb736837ea
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/lock.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+// UNSUPPORTED: c++03, c++98, c++11
+
+// <shared_mutex>
+
+// class shared_timed_mutex;
+
+// void lock();
+
+#include <shared_mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+std::shared_timed_mutex m;
+
+typedef std::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f()
+{
+ time_point t0 = Clock::now();
+ m.lock();
+ time_point t1 = Clock::now();
+ m.unlock();
+ ns d = t1 - t0 - ms(250);
+ assert(d < ms(50)); // within 50ms
+}
+
+int main()
+{
+ m.lock();
+ std::thread t(f);
+ std::this_thread::sleep_for(ms(250));
+ m.unlock();
+ t.join();
+}
diff --git a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/lock_shared.pass.cpp b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/lock_shared.pass.cpp
new file mode 100644
index 000000000000..8fc6299f1b8f
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/lock_shared.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+// UNSUPPORTED: c++03, c++98, c++11
+
+// <shared_mutex>
+
+// class shared_timed_mutex;
+
+// void lock_shared();
+
+#include <shared_mutex>
+#include <thread>
+#include <vector>
+#include <cstdlib>
+#include <cassert>
+
+std::shared_timed_mutex m;
+
+typedef std::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f()
+{
+ time_point t0 = Clock::now();
+ m.lock_shared();
+ time_point t1 = Clock::now();
+ m.unlock_shared();
+ ns d = t1 - t0 - ms(250);
+ assert(d < ms(50)); // within 50ms
+}
+
+void g()
+{
+ time_point t0 = Clock::now();
+ m.lock_shared();
+ time_point t1 = Clock::now();
+ m.unlock_shared();
+ ns d = t1 - t0;
+ assert(d < ms(50)); // within 50ms
+}
+
+
+int main()
+{
+ m.lock();
+ std::vector<std::thread> v;
+ for (int i = 0; i < 5; ++i)
+ v.push_back(std::thread(f));
+ std::this_thread::sleep_for(ms(250));
+ m.unlock();
+ for (auto& t : v)
+ t.join();
+ m.lock_shared();
+ for (auto& t : v)
+ t = std::thread(g);
+ std::thread q(f);
+ std::this_thread::sleep_for(ms(250));
+ m.unlock_shared();
+ for (auto& t : v)
+ t.join();
+ q.join();
+}
diff --git a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock.pass.cpp b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock.pass.cpp
new file mode 100644
index 000000000000..61900ba83342
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+// UNSUPPORTED: c++03, c++98, c++11
+
+// <shared_mutex>
+
+// class shared_timed_mutex;
+
+// bool try_lock();
+
+#include <shared_mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+std::shared_timed_mutex m;
+
+typedef std::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f()
+{
+ time_point t0 = Clock::now();
+ assert(!m.try_lock());
+ assert(!m.try_lock());
+ assert(!m.try_lock());
+ while(!m.try_lock())
+ ;
+ time_point t1 = Clock::now();
+ m.unlock();
+ ns d = t1 - t0 - ms(250);
+ assert(d < ms(200)); // within 200ms
+}
+
+int main()
+{
+ m.lock();
+ std::thread t(f);
+ std::this_thread::sleep_for(ms(250));
+ m.unlock();
+ t.join();
+}
diff --git a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_for.pass.cpp b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_for.pass.cpp
new file mode 100644
index 000000000000..ab20241895ba
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_for.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+// UNSUPPORTED: c++03, c++98, c++11
+
+// <shared_mutex>
+
+// class shared_timed_mutex;
+
+// template <class Rep, class Period>
+// bool try_lock_for(const chrono::duration<Rep, Period>& rel_time);
+
+#include <shared_mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+std::shared_timed_mutex m;
+
+typedef std::chrono::steady_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f1()
+{
+ time_point t0 = Clock::now();
+ assert(m.try_lock_for(ms(300)) == true);
+ time_point t1 = Clock::now();
+ m.unlock();
+ ns d = t1 - t0 - ms(250);
+ assert(d < ms(50)); // within 50ms
+}
+
+void f2()
+{
+ time_point t0 = Clock::now();
+ assert(m.try_lock_for(ms(250)) == false);
+ time_point t1 = Clock::now();
+ ns d = t1 - t0 - ms(250);
+ assert(d < ms(50)); // within 50ms
+}
+
+int main()
+{
+ {
+ m.lock();
+ std::thread t(f1);
+ std::this_thread::sleep_for(ms(250));
+ m.unlock();
+ t.join();
+ }
+ {
+ m.lock();
+ std::thread t(f2);
+ std::this_thread::sleep_for(ms(300));
+ m.unlock();
+ t.join();
+ }
+}
diff --git a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_shared.pass.cpp b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_shared.pass.cpp
new file mode 100644
index 000000000000..9c2d8c9c8e5c
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_shared.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+// UNSUPPORTED: c++03, c++98, c++11
+
+// <shared_mutex>
+
+// class shared_timed_mutex;
+
+// bool try_lock_shared();
+
+#include <shared_mutex>
+#include <thread>
+#include <vector>
+#include <cstdlib>
+#include <cassert>
+
+std::shared_timed_mutex m;
+
+typedef std::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f()
+{
+ time_point t0 = Clock::now();
+ assert(!m.try_lock_shared());
+ assert(!m.try_lock_shared());
+ assert(!m.try_lock_shared());
+ while(!m.try_lock_shared())
+ ;
+ time_point t1 = Clock::now();
+ m.unlock_shared();
+ ns d = t1 - t0 - ms(250);
+ assert(d < ms(200)); // within 200ms
+}
+
+int main()
+{
+ m.lock();
+ std::vector<std::thread> v;
+ for (int i = 0; i < 5; ++i)
+ v.push_back(std::thread(f));
+ std::this_thread::sleep_for(ms(250));
+ m.unlock();
+ for (auto& t : v)
+ t.join();
+}
diff --git a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_shared_for.pass.cpp b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_shared_for.pass.cpp
new file mode 100644
index 000000000000..35444112a5da
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_shared_for.pass.cpp
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+// UNSUPPORTED: c++03, c++98, c++11
+
+// <shared_mutex>
+
+// class shared_timed_mutex;
+
+// template <class Rep, class Period>
+// bool try_lock_shared_for(const chrono::duration<Rep, Period>& rel_time);
+
+#include <shared_mutex>
+#include <thread>
+#include <vector>
+#include <cstdlib>
+#include <cassert>
+
+std::shared_timed_mutex m;
+
+typedef std::chrono::steady_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f1()
+{
+ time_point t0 = Clock::now();
+ assert(m.try_lock_shared_for(ms(300)) == true);
+ time_point t1 = Clock::now();
+ m.unlock_shared();
+ ns d = t1 - t0 - ms(250);
+ assert(d < ms(50)); // within 50ms
+}
+
+void f2()
+{
+ time_point t0 = Clock::now();
+ assert(m.try_lock_shared_for(ms(250)) == false);
+ time_point t1 = Clock::now();
+ ns d = t1 - t0 - ms(250);
+ assert(d < ms(50)); // within 50ms
+}
+
+int main()
+{
+ {
+ m.lock();
+ std::vector<std::thread> v;
+ for (int i = 0; i < 5; ++i)
+ v.push_back(std::thread(f1));
+ std::this_thread::sleep_for(ms(250));
+ m.unlock();
+ for (auto& t : v)
+ t.join();
+ }
+ {
+ m.lock();
+ std::vector<std::thread> v;
+ for (int i = 0; i < 5; ++i)
+ v.push_back(std::thread(f2));
+ std::this_thread::sleep_for(ms(300));
+ m.unlock();
+ for (auto& t : v)
+ t.join();
+ }
+}
diff --git a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_shared_until.pass.cpp b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_shared_until.pass.cpp
new file mode 100644
index 000000000000..4e0f19de07ce
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_shared_until.pass.cpp
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+// UNSUPPORTED: c++03, c++98, c++11
+
+// <shared_mutex>
+
+// class shared_timed_mutex;
+
+// template <class Clock, class Duration>
+// bool try_lock_shared_until(const chrono::time_point<Clock, Duration>& abs_time);
+
+#include <shared_mutex>
+#include <thread>
+#include <vector>
+#include <cstdlib>
+#include <cassert>
+
+std::shared_timed_mutex m;
+
+typedef std::chrono::steady_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f1()
+{
+ time_point t0 = Clock::now();
+ assert(m.try_lock_shared_until(Clock::now() + ms(300)) == true);
+ time_point t1 = Clock::now();
+ m.unlock_shared();
+ ns d = t1 - t0 - ms(250);
+ assert(d < ms(50)); // within 50ms
+}
+
+void f2()
+{
+ time_point t0 = Clock::now();
+ assert(m.try_lock_shared_until(Clock::now() + ms(250)) == false);
+ time_point t1 = Clock::now();
+ ns d = t1 - t0 - ms(250);
+ assert(d < ms(50)); // within 50ms
+}
+
+int main()
+{
+ {
+ m.lock();
+ std::vector<std::thread> v;
+ for (int i = 0; i < 5; ++i)
+ v.push_back(std::thread(f1));
+ std::this_thread::sleep_for(ms(250));
+ m.unlock();
+ for (auto& t : v)
+ t.join();
+ }
+ {
+ m.lock();
+ std::vector<std::thread> v;
+ for (int i = 0; i < 5; ++i)
+ v.push_back(std::thread(f2));
+ std::this_thread::sleep_for(ms(300));
+ m.unlock();
+ for (auto& t : v)
+ t.join();
+ }
+}
diff --git a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_until.pass.cpp b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_until.pass.cpp
new file mode 100644
index 000000000000..aa90cf71502f
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_until.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+// UNSUPPORTED: c++03, c++98, c++11
+
+// <shared_mutex>
+
+// class shared_timed_mutex;
+
+// template <class Clock, class Duration>
+// bool try_lock_until(const chrono::time_point<Clock, Duration>& abs_time);
+
+#include <shared_mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+#include "test_macros.h"
+
+std::shared_timed_mutex m;
+
+typedef std::chrono::steady_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f1()
+{
+ time_point t0 = Clock::now();
+ assert(m.try_lock_until(Clock::now() + ms(300)) == true);
+ time_point t1 = Clock::now();
+ m.unlock();
+ ns d = t1 - t0 - ms(250);
+ assert(d < ms(50)); // within 50ms
+}
+
+void f2()
+{
+ time_point t0 = Clock::now();
+ assert(m.try_lock_until(Clock::now() + ms(250)) == false);
+ time_point t1 = Clock::now();
+ ns d = t1 - t0 - ms(250);
+ assert(d < ms(50)); // within 50ms
+}
+
+int main()
+{
+ {
+ m.lock();
+ std::thread t(f1);
+ std::this_thread::sleep_for(ms(250));
+ m.unlock();
+ t.join();
+ }
+ {
+ m.lock();
+ std::thread t(f2);
+ std::this_thread::sleep_for(ms(300));
+ m.unlock();
+ t.join();
+ }
+}
diff --git a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_until_deadlock_bug.pass.cpp b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_until_deadlock_bug.pass.cpp
new file mode 100644
index 000000000000..ed288099c979
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_until_deadlock_bug.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+// UNSUPPORTED: c++03, c++98, c++11
+
+// <shared_mutex>
+
+// class shared_timed_mutex;
+
+#include <shared_mutex>
+
+#include <atomic>
+#include <chrono>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+std::shared_timed_mutex m;
+
+const int total_readers = 2;
+std::atomic<int> readers_started(0);
+std::atomic<int> readers_finished(0);
+
+// Wait for the readers to start then try and acquire the write lock.
+void writer_one() {
+ while (readers_started != total_readers) {}
+ bool b = m.try_lock_for(std::chrono::milliseconds(500));
+ assert(b == false);
+}
+
+void blocked_reader() {
+ ++readers_started;
+ // Wait until writer_one is waiting for the write lock.
+ while (m.try_lock_shared()) {
+ m.unlock_shared();
+ }
+ // Attempt to get the read lock. writer_one should be blocking us because
+ // writer_one is blocked by main.
+ m.lock_shared();
+ ++readers_finished;
+ m.unlock_shared();
+}
+
+int main()
+{
+ typedef std::chrono::steady_clock Clock;
+
+ m.lock_shared();
+ std::thread t1(writer_one);
+ // create some readers
+ std::thread t2(blocked_reader);
+ std::thread t3(blocked_reader);
+ // Kill the test after 10 seconds if it hasn't completed.
+ auto end_point = Clock::now() + std::chrono::seconds(10);
+ while (readers_finished != total_readers && Clock::now() < end_point) {
+ std::this_thread::sleep_for(std::chrono::seconds(1));
+ }
+ assert(readers_finished == total_readers);
+ m.unlock_shared();
+ t1.join();
+ t2.join();
+ t3.join();
+}
diff --git a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/nothing_to_do.pass.cpp b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/assign.fail.cpp b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/assign.fail.cpp
new file mode 100644
index 000000000000..58006833ecac
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/assign.fail.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// class timed_mutex;
+
+// timed_mutex& operator=(const timed_mutex&) = delete;
+
+#include <mutex>
+
+int main()
+{
+ std::timed_mutex m0;
+ std::timed_mutex m1;
+ m1 = m0;
+}
diff --git a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/copy.fail.cpp b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/copy.fail.cpp
new file mode 100644
index 000000000000..61ba31d8648e
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/copy.fail.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// class timed_mutex;
+
+// timed_mutex(const timed_mutex&) = delete;
+
+#include <mutex>
+
+int main()
+{
+ std::timed_mutex m0;
+ std::timed_mutex m1(m0);
+}
diff --git a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/default.pass.cpp b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/default.pass.cpp
new file mode 100644
index 000000000000..33320a7e260a
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/default.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <mutex>
+
+// class timed_mutex;
+
+// timed_mutex();
+
+#include <mutex>
+
+int main()
+{
+ std::timed_mutex m;
+}
diff --git a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/lock.pass.cpp b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/lock.pass.cpp
new file mode 100644
index 000000000000..fe2dd825c207
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/lock.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <mutex>
+
+// class timed_mutex;
+
+// void lock();
+
+#include <mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+#include <iostream>
+
+std::timed_mutex m;
+
+typedef std::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f()
+{
+ time_point t0 = Clock::now();
+ m.lock();
+ time_point t1 = Clock::now();
+ m.unlock();
+ ns d = t1 - t0 - ms(250);
+ assert(d < ms(50)); // within 50ms
+}
+
+int main()
+{
+ m.lock();
+ std::thread t(f);
+ std::this_thread::sleep_for(ms(250));
+ m.unlock();
+ t.join();
+}
diff --git a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/try_lock.pass.cpp b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/try_lock.pass.cpp
new file mode 100644
index 000000000000..b32a2664551a
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/try_lock.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <mutex>
+
+// class timed_mutex;
+
+// bool try_lock();
+
+#include <mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+std::timed_mutex m;
+
+typedef std::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f()
+{
+ time_point t0 = Clock::now();
+ assert(!m.try_lock());
+ assert(!m.try_lock());
+ assert(!m.try_lock());
+ while(!m.try_lock())
+ ;
+ time_point t1 = Clock::now();
+ m.unlock();
+ ns d = t1 - t0 - ms(250);
+ assert(d < ms(200)); // within 200ms
+}
+
+int main()
+{
+ m.lock();
+ std::thread t(f);
+ std::this_thread::sleep_for(ms(250));
+ m.unlock();
+ t.join();
+}
diff --git a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/try_lock_for.pass.cpp b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/try_lock_for.pass.cpp
new file mode 100644
index 000000000000..46222a70c8d9
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/try_lock_for.pass.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <mutex>
+
+// class timed_mutex;
+
+// template <class Rep, class Period>
+// bool try_lock_for(const chrono::duration<Rep, Period>& rel_time);
+
+#include <mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+std::timed_mutex m;
+
+typedef std::chrono::steady_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f1()
+{
+ time_point t0 = Clock::now();
+ assert(m.try_lock_for(ms(300)) == true);
+ time_point t1 = Clock::now();
+ m.unlock();
+ ns d = t1 - t0 - ms(250);
+ assert(d < ms(50)); // within 50ms
+}
+
+void f2()
+{
+ time_point t0 = Clock::now();
+ assert(m.try_lock_for(ms(250)) == false);
+ time_point t1 = Clock::now();
+ ns d = t1 - t0 - ms(250);
+ assert(d < ms(50)); // within 50ms
+}
+
+int main()
+{
+ {
+ m.lock();
+ std::thread t(f1);
+ std::this_thread::sleep_for(ms(250));
+ m.unlock();
+ t.join();
+ }
+ {
+ m.lock();
+ std::thread t(f2);
+ std::this_thread::sleep_for(ms(300));
+ m.unlock();
+ t.join();
+ }
+}
diff --git a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/try_lock_until.pass.cpp b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/try_lock_until.pass.cpp
new file mode 100644
index 000000000000..6c9c442ab124
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/try_lock_until.pass.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <mutex>
+
+// class timed_mutex;
+
+// template <class Clock, class Duration>
+// bool try_lock_until(const chrono::time_point<Clock, Duration>& abs_time);
+
+#include <mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+std::timed_mutex m;
+
+typedef std::chrono::steady_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f1()
+{
+ time_point t0 = Clock::now();
+ assert(m.try_lock_until(Clock::now() + ms(300)) == true);
+ time_point t1 = Clock::now();
+ m.unlock();
+ ns d = t1 - t0 - ms(250);
+ assert(d < ms(50)); // within 50ms
+}
+
+void f2()
+{
+ time_point t0 = Clock::now();
+ assert(m.try_lock_until(Clock::now() + ms(250)) == false);
+ time_point t1 = Clock::now();
+ ns d = t1 - t0 - ms(250);
+ assert(d < ms(50)); // within 50ms
+}
+
+int main()
+{
+ {
+ m.lock();
+ std::thread t(f1);
+ std::this_thread::sleep_for(ms(250));
+ m.unlock();
+ t.join();
+ }
+ {
+ m.lock();
+ std::thread t(f2);
+ std::this_thread::sleep_for(ms(300));
+ m.unlock();
+ t.join();
+ }
+}
diff --git a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/assign.fail.cpp b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/assign.fail.cpp
new file mode 100644
index 000000000000..ae84be838d66
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/assign.fail.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// class recursive_timed_mutex;
+
+// recursive_timed_mutex& operator=(const recursive_timed_mutex&) = delete;
+
+#include <mutex>
+
+int main()
+{
+ std::recursive_timed_mutex m0;
+ std::recursive_timed_mutex m1;
+ m1 = m0;
+}
diff --git a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/copy.fail.cpp b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/copy.fail.cpp
new file mode 100644
index 000000000000..487d6a8c269c
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/copy.fail.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// class recursive_timed_mutex;
+
+// recursive_timed_mutex(const recursive_timed_mutex&) = delete;
+
+#include <mutex>
+
+int main()
+{
+ std::recursive_timed_mutex m0;
+ std::recursive_timed_mutex m1(m0);
+}
diff --git a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/default.pass.cpp b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/default.pass.cpp
new file mode 100644
index 000000000000..56e1874dc126
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/default.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <mutex>
+
+// class recursive_timed_mutex;
+
+// recursive_timed_mutex();
+
+#include <mutex>
+
+int main()
+{
+ std::recursive_timed_mutex m;
+}
diff --git a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/lock.pass.cpp b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/lock.pass.cpp
new file mode 100644
index 000000000000..91f747bc1ab0
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/lock.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <mutex>
+
+// class recursive_timed_mutex;
+
+// void lock();
+
+#include <mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+#include <iostream>
+
+std::recursive_timed_mutex m;
+
+typedef std::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f()
+{
+ time_point t0 = Clock::now();
+ m.lock();
+ time_point t1 = Clock::now();
+ m.lock();
+ m.unlock();
+ m.unlock();
+ ns d = t1 - t0 - ms(250);
+ assert(d < ms(50)); // within 50ms
+}
+
+int main()
+{
+ m.lock();
+ std::thread t(f);
+ std::this_thread::sleep_for(ms(250));
+ m.unlock();
+ t.join();
+}
diff --git a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/try_lock.pass.cpp b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/try_lock.pass.cpp
new file mode 100644
index 000000000000..63c3cfee38a3
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/try_lock.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <mutex>
+
+// class recursive_timed_mutex;
+
+// bool try_lock();
+
+#include <mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+std::recursive_timed_mutex m;
+
+typedef std::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f()
+{
+ time_point t0 = Clock::now();
+ assert(!m.try_lock());
+ assert(!m.try_lock());
+ assert(!m.try_lock());
+ while(!m.try_lock())
+ ;
+ time_point t1 = Clock::now();
+ assert(m.try_lock());
+ m.unlock();
+ m.unlock();
+ ns d = t1 - t0 - ms(250);
+ assert(d < ms(200)); // within 200ms
+}
+
+int main()
+{
+ m.lock();
+ std::thread t(f);
+ std::this_thread::sleep_for(ms(250));
+ m.unlock();
+ t.join();
+}
diff --git a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/try_lock_for.pass.cpp b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/try_lock_for.pass.cpp
new file mode 100644
index 000000000000..3c1d6ddc6f40
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/try_lock_for.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <mutex>
+
+// class recursive_timed_mutex;
+
+// template <class Rep, class Period>
+// bool try_lock_for(const chrono::duration<Rep, Period>& rel_time);
+
+#include <mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+std::recursive_timed_mutex m;
+
+typedef std::chrono::steady_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f1()
+{
+ time_point t0 = Clock::now();
+ assert(m.try_lock_for(ms(300)) == true);
+ time_point t1 = Clock::now();
+ assert(m.try_lock());
+ m.unlock();
+ m.unlock();
+ ns d = t1 - t0 - ms(250);
+ assert(d < ns(50000000)); // within 50ms
+}
+
+void f2()
+{
+ time_point t0 = Clock::now();
+ assert(m.try_lock_for(ms(250)) == false);
+ time_point t1 = Clock::now();
+ ns d = t1 - t0 - ms(250);
+ assert(d < ns(50000000)); // within 50ms
+}
+
+int main()
+{
+ {
+ m.lock();
+ std::thread t(f1);
+ std::this_thread::sleep_for(ms(250));
+ m.unlock();
+ t.join();
+ }
+ {
+ m.lock();
+ std::thread t(f2);
+ std::this_thread::sleep_for(ms(300));
+ m.unlock();
+ t.join();
+ }
+}
diff --git a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/try_lock_until.pass.cpp b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/try_lock_until.pass.cpp
new file mode 100644
index 000000000000..066eb7b3064c
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/try_lock_until.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <mutex>
+
+// class recursive_timed_mutex;
+
+// template <class Clock, class Duration>
+// bool try_lock_until(const chrono::time_point<Clock, Duration>& abs_time);
+
+#include <mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+std::recursive_timed_mutex m;
+
+typedef std::chrono::steady_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f1()
+{
+ time_point t0 = Clock::now();
+ assert(m.try_lock_until(Clock::now() + ms(300)) == true);
+ time_point t1 = Clock::now();
+ assert(m.try_lock());
+ m.unlock();
+ m.unlock();
+ ns d = t1 - t0 - ms(250);
+ assert(d < ms(50)); // within 50ms
+}
+
+void f2()
+{
+ time_point t0 = Clock::now();
+ assert(m.try_lock_until(Clock::now() + ms(250)) == false);
+ time_point t1 = Clock::now();
+ ns d = t1 - t0 - ms(250);
+ assert(d < ms(50)); // within 50ms
+}
+
+int main()
+{
+ {
+ m.lock();
+ std::thread t(f1);
+ std::this_thread::sleep_for(ms(250));
+ m.unlock();
+ t.join();
+ }
+ {
+ m.lock();
+ std::thread t(f2);
+ std::this_thread::sleep_for(ms(300));
+ m.unlock();
+ t.join();
+ }
+}
diff --git a/test/std/thread/thread.mutex/thread.once/nothing_to_do.pass.cpp b/test/std/thread/thread.mutex/thread.once/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.once/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/thread/thread.mutex/thread.once/thread.once.callonce/call_once.pass.cpp b/test/std/thread/thread.mutex/thread.once/thread.once.callonce/call_once.pass.cpp
new file mode 100644
index 000000000000..89b99348459b
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.once/thread.once.callonce/call_once.pass.cpp
@@ -0,0 +1,254 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <mutex>
+
+// struct once_flag;
+
+// template<class Callable, class ...Args>
+// void call_once(once_flag& flag, Callable&& func, Args&&... args);
+
+#include <mutex>
+#include <thread>
+#include <cassert>
+
+typedef std::chrono::milliseconds ms;
+
+std::once_flag flg0;
+
+int init0_called = 0;
+
+void init0()
+{
+ std::this_thread::sleep_for(ms(250));
+ ++init0_called;
+}
+
+void f0()
+{
+ std::call_once(flg0, init0);
+}
+
+std::once_flag flg3;
+
+int init3_called = 0;
+int init3_completed = 0;
+
+void init3()
+{
+ ++init3_called;
+ std::this_thread::sleep_for(ms(250));
+ if (init3_called == 1)
+ throw 1;
+ ++init3_completed;
+}
+
+void f3()
+{
+ try
+ {
+ std::call_once(flg3, init3);
+ }
+ catch (...)
+ {
+ }
+}
+
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+
+struct init1
+{
+ static int called;
+
+ void operator()(int i) {called += i;}
+};
+
+int init1::called = 0;
+
+std::once_flag flg1;
+
+void f1()
+{
+ std::call_once(flg1, init1(), 1);
+}
+
+struct init2
+{
+ static int called;
+
+ void operator()(int i, int j) const {called += i + j;}
+};
+
+int init2::called = 0;
+
+std::once_flag flg2;
+
+void f2()
+{
+ std::call_once(flg2, init2(), 2, 3);
+ std::call_once(flg2, init2(), 4, 5);
+}
+
+#endif // _LIBCPP_HAS_NO_VARIADICS
+
+std::once_flag flg41;
+std::once_flag flg42;
+
+int init41_called = 0;
+int init42_called = 0;
+
+void init42();
+
+void init41()
+{
+ std::this_thread::sleep_for(ms(250));
+ ++init41_called;
+}
+
+void init42()
+{
+ std::this_thread::sleep_for(ms(250));
+ ++init42_called;
+}
+
+void f41()
+{
+ std::call_once(flg41, init41);
+ std::call_once(flg42, init42);
+}
+
+void f42()
+{
+ std::call_once(flg42, init42);
+ std::call_once(flg41, init41);
+}
+
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+
+class MoveOnly
+{
+#if !defined(__clang__)
+ // GCC 4.8 complains about the following being private
+public:
+ MoveOnly(const MoveOnly&)
+ {
+ }
+#else
+ MoveOnly(const MoveOnly&);
+#endif
+public:
+ MoveOnly() {}
+ MoveOnly(MoveOnly&&) {}
+
+ void operator()(MoveOnly&&)
+ {
+ }
+};
+
+class NonCopyable
+{
+#if !defined(__clang__)
+ // GCC 4.8 complains about the following being private
+public:
+ NonCopyable(const NonCopyable&)
+ {
+ }
+#else
+ NonCopyable(const NonCopyable&);
+#endif
+public:
+ NonCopyable() {}
+
+ void operator()(int&) {}
+};
+
+#if __cplusplus >= 201103L
+// reference qualifiers on functions are a C++11 extension
+struct RefQual
+{
+ int lv_called, rv_called;
+
+ RefQual() : lv_called(0), rv_called(0) {}
+
+ void operator()() & { ++lv_called; }
+ void operator()() && { ++rv_called; }
+};
+#endif
+#endif
+
+int main()
+{
+ // check basic functionality
+ {
+ std::thread t0(f0);
+ std::thread t1(f0);
+ t0.join();
+ t1.join();
+ assert(init0_called == 1);
+ }
+ // check basic exception safety
+ {
+ std::thread t0(f3);
+ std::thread t1(f3);
+ t0.join();
+ t1.join();
+ assert(init3_called == 2);
+ assert(init3_completed == 1);
+ }
+ // check deadlock avoidance
+ {
+ std::thread t0(f41);
+ std::thread t1(f42);
+ t0.join();
+ t1.join();
+ assert(init41_called == 1);
+ assert(init42_called == 1);
+ }
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+ // check functors with 1 arg
+ {
+ std::thread t0(f1);
+ std::thread t1(f1);
+ t0.join();
+ t1.join();
+ assert(init1::called == 1);
+ }
+ // check functors with 2 args
+ {
+ std::thread t0(f2);
+ std::thread t1(f2);
+ t0.join();
+ t1.join();
+ assert(init2::called == 5);
+ }
+ {
+ std::once_flag f;
+ std::call_once(f, MoveOnly(), MoveOnly());
+ }
+ // check LWG2442: call_once() shouldn't DECAY_COPY()
+ {
+ std::once_flag f;
+ int i = 0;
+ std::call_once(f, NonCopyable(), i);
+ }
+#if __cplusplus >= 201103L
+// reference qualifiers on functions are a C++11 extension
+ {
+ std::once_flag f1, f2;
+ RefQual rq;
+ std::call_once(f1, rq);
+ assert(rq.lv_called == 1);
+ std::call_once(f2, std::move(rq));
+ assert(rq.rv_called == 1);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_VARIADICS
+}
diff --git a/test/std/thread/thread.mutex/thread.once/thread.once.onceflag/assign.fail.cpp b/test/std/thread/thread.mutex/thread.once/thread.once.onceflag/assign.fail.cpp
new file mode 100644
index 000000000000..c4714276432c
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.once/thread.once.onceflag/assign.fail.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// struct once_flag;
+
+// once_flag& operator=(const once_flag&) = delete;
+
+#include <mutex>
+
+int main()
+{
+ std::once_flag f;
+ std::once_flag f2;
+ f2 = f;
+}
diff --git a/test/std/thread/thread.mutex/thread.once/thread.once.onceflag/copy.fail.cpp b/test/std/thread/thread.mutex/thread.once/thread.once.onceflag/copy.fail.cpp
new file mode 100644
index 000000000000..450ba8361391
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.once/thread.once.onceflag/copy.fail.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// struct once_flag;
+
+// once_flag(const once_flag&) = delete;
+
+#include <mutex>
+
+int main()
+{
+ std::once_flag f;
+ std::once_flag f2(f);
+}
diff --git a/test/std/thread/thread.mutex/thread.once/thread.once.onceflag/default.pass.cpp b/test/std/thread/thread.mutex/thread.once/thread.once.onceflag/default.pass.cpp
new file mode 100644
index 000000000000..6995f0648335
--- /dev/null
+++ b/test/std/thread/thread.mutex/thread.once/thread.once.onceflag/default.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// struct once_flag;
+
+// constexpr once_flag() noexcept;
+
+#include <mutex>
+
+int main()
+{
+ {
+ std::once_flag f;
+ }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+ {
+ constexpr std::once_flag f;
+ }
+#endif
+}
diff --git a/test/std/thread/thread.mutex/version.pass.cpp b/test/std/thread/thread.mutex/version.pass.cpp
new file mode 100644
index 000000000000..81b52c79204b
--- /dev/null
+++ b/test/std/thread/thread.mutex/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+#include <mutex>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/thread/thread.req/nothing_to_do.pass.cpp b/test/std/thread/thread.req/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/thread/thread.req/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/thread/thread.req/thread.req.exception/nothing_to_do.pass.cpp b/test/std/thread/thread.req/thread.req.exception/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/thread/thread.req/thread.req.exception/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/thread/thread.req/thread.req.lockable/nothing_to_do.pass.cpp b/test/std/thread/thread.req/thread.req.lockable/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/thread/thread.req/thread.req.lockable/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/thread/thread.req/thread.req.lockable/thread.req.lockable.basic/nothing_to_do.pass.cpp b/test/std/thread/thread.req/thread.req.lockable/thread.req.lockable.basic/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/thread/thread.req/thread.req.lockable/thread.req.lockable.basic/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/thread/thread.req/thread.req.lockable/thread.req.lockable.general/nothing_to_do.pass.cpp b/test/std/thread/thread.req/thread.req.lockable/thread.req.lockable.general/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/thread/thread.req/thread.req.lockable/thread.req.lockable.general/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/thread/thread.req/thread.req.lockable/thread.req.lockable.req/nothing_to_do.pass.cpp b/test/std/thread/thread.req/thread.req.lockable/thread.req.lockable.req/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/thread/thread.req/thread.req.lockable/thread.req.lockable.req/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/thread/thread.req/thread.req.lockable/thread.req.lockable.timed/nothing_to_do.pass.cpp b/test/std/thread/thread.req/thread.req.lockable/thread.req.lockable.timed/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/thread/thread.req/thread.req.lockable/thread.req.lockable.timed/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/thread/thread.req/thread.req.native/nothing_to_do.pass.cpp b/test/std/thread/thread.req/thread.req.native/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/thread/thread.req/thread.req.native/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/thread/thread.req/thread.req.paramname/nothing_to_do.pass.cpp b/test/std/thread/thread.req/thread.req.paramname/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/thread/thread.req/thread.req.paramname/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/thread/thread.req/thread.req.timing/nothing_to_do.pass.cpp b/test/std/thread/thread.req/thread.req.timing/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/thread/thread.req/thread.req.timing/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/thread/thread.threads/thread.thread.class/thread.thread.algorithm/swap.pass.cpp b/test/std/thread/thread.threads/thread.thread.class/thread.thread.algorithm/swap.pass.cpp
new file mode 100644
index 000000000000..4d3a742dd168
--- /dev/null
+++ b/test/std/thread/thread.threads/thread.thread.class/thread.thread.algorithm/swap.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <thread>
+
+// class thread
+
+// void swap(thread& x, thread& y);
+
+#include <thread>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+class G
+{
+ int alive_;
+public:
+ static int n_alive;
+ static bool op_run;
+
+ G() : alive_(1) {++n_alive;}
+ G(const G& g) : alive_(g.alive_) {++n_alive;}
+ ~G() {alive_ = 0; --n_alive;}
+
+ void operator()()
+ {
+ assert(alive_ == 1);
+ assert(n_alive >= 1);
+ op_run = true;
+ }
+};
+
+int G::n_alive = 0;
+bool G::op_run = false;
+
+int main()
+{
+ {
+ G g;
+ std::thread t0(g);
+ std::thread::id id0 = t0.get_id();
+ std::thread t1;
+ std::thread::id id1 = t1.get_id();
+ swap(t0, t1);
+ assert(t0.get_id() == id1);
+ assert(t1.get_id() == id0);
+ t1.join();
+ }
+}
diff --git a/test/std/thread/thread.threads/thread.thread.class/thread.thread.assign/copy.fail.cpp b/test/std/thread/thread.threads/thread.thread.class/thread.thread.assign/copy.fail.cpp
new file mode 100644
index 000000000000..7373886f6173
--- /dev/null
+++ b/test/std/thread/thread.threads/thread.thread.class/thread.thread.assign/copy.fail.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <thread>
+
+// class thread
+
+// thread& operator=(thread&& t);
+
+#include <thread>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+class G
+{
+ int alive_;
+public:
+ static int n_alive;
+ static bool op_run;
+
+ G() : alive_(1) {++n_alive;}
+ G(const G& g) : alive_(g.alive_) {++n_alive;}
+ ~G() {alive_ = 0; --n_alive;}
+
+ void operator()()
+ {
+ assert(alive_ == 1);
+ assert(n_alive >= 1);
+ op_run = true;
+ }
+
+};
+
+int G::n_alive = 0;
+bool G::op_run = false;
+
+int main()
+{
+ {
+ std::thread t0(G());
+ std::thread t1;
+ t1 = t0;
+ }
+}
diff --git a/test/std/thread/thread.threads/thread.thread.class/thread.thread.assign/move.pass.cpp b/test/std/thread/thread.threads/thread.thread.class/thread.thread.assign/move.pass.cpp
new file mode 100644
index 000000000000..2db9430a698d
--- /dev/null
+++ b/test/std/thread/thread.threads/thread.thread.class/thread.thread.assign/move.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <thread>
+
+// class thread
+
+// thread& operator=(thread&& t);
+
+#include <thread>
+#include <cassert>
+
+class G
+{
+ int alive_;
+public:
+ static int n_alive;
+ static bool op_run;
+
+ G() : alive_(1) {++n_alive;}
+ G(const G& g) : alive_(g.alive_) {++n_alive;}
+ ~G() {alive_ = 0; --n_alive;}
+
+ void operator()(int i, double j)
+ {
+ assert(alive_ == 1);
+ assert(n_alive >= 1);
+ assert(i == 5);
+ assert(j == 5.5);
+ op_run = true;
+ }
+};
+
+int G::n_alive = 0;
+bool G::op_run = false;
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ assert(G::n_alive == 0);
+ assert(!G::op_run);
+ {
+ G g;
+ std::thread t0(g, 5, 5.5);
+ std::thread::id id = t0.get_id();
+ std::thread t1;
+ t1 = std::move(t0);
+ assert(t1.get_id() == id);
+ assert(t0.get_id() == std::thread::id());
+ t1.join();
+ }
+ assert(G::n_alive == 0);
+ assert(G::op_run);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/thread/thread.threads/thread.thread.class/thread.thread.assign/move2.pass.cpp b/test/std/thread/thread.threads/thread.thread.class/thread.thread.assign/move2.pass.cpp
new file mode 100644
index 000000000000..7198d226960a
--- /dev/null
+++ b/test/std/thread/thread.threads/thread.thread.class/thread.thread.assign/move2.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// NOTE: std::terminate is called so the destructors are not invoked and the
+// memory is not freed. This will cause ASAN to fail.
+// XFAIL: asan
+
+// NOTE: TSAN will report this test as leaking a thread.
+// XFAIL: tsan
+
+// <thread>
+
+// class thread
+
+// thread& operator=(thread&& t);
+
+#include <thread>
+#include <exception>
+#include <cstdlib>
+#include <cassert>
+
+class G
+{
+ int alive_;
+public:
+ static int n_alive;
+ static bool op_run;
+
+ G() : alive_(1) {++n_alive;}
+ G(const G& g) : alive_(g.alive_) {++n_alive;}
+ ~G() {alive_ = 0; --n_alive;}
+
+ void operator()()
+ {
+ assert(alive_ == 1);
+ assert(n_alive >= 1);
+ op_run = true;
+ }
+
+ void operator()(int i, double j)
+ {
+ assert(alive_ == 1);
+ assert(n_alive >= 1);
+ assert(i == 5);
+ assert(j == 5.5);
+ op_run = true;
+ }
+};
+
+int G::n_alive = 0;
+bool G::op_run = false;
+
+void f1()
+{
+ std::exit(0);
+}
+
+int main()
+{
+ std::set_terminate(f1);
+ {
+ G g;
+ std::thread t0(g, 5, 5.5);
+ std::thread::id id = t0.get_id();
+ std::thread t1;
+ t0 = std::move(t1);
+ assert(false);
+ }
+}
diff --git a/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp b/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp
new file mode 100644
index 000000000000..a8b4be16e631
--- /dev/null
+++ b/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp
@@ -0,0 +1,154 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <thread>
+
+// class thread
+
+// template <class F, class ...Args> thread(F&& f, Args&&... args);
+
+// UNSUPPORTED: sanitizer-new-delete
+
+#include <thread>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+unsigned throw_one = 0xFFFF;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+ if (throw_one == 0)
+ throw std::bad_alloc();
+ --throw_one;
+ return std::malloc(s);
+}
+
+void operator delete(void* p) throw()
+{
+ std::free(p);
+}
+
+bool f_run = false;
+
+void f()
+{
+ f_run = true;
+}
+
+class G
+{
+ int alive_;
+public:
+ static int n_alive;
+ static bool op_run;
+
+ G() : alive_(1) {++n_alive;}
+ G(const G& g) : alive_(g.alive_) {++n_alive;}
+ ~G() {alive_ = 0; --n_alive;}
+
+ void operator()()
+ {
+ assert(alive_ == 1);
+ assert(n_alive >= 1);
+ op_run = true;
+ }
+
+ void operator()(int i, double j)
+ {
+ assert(alive_ == 1);
+ assert(n_alive >= 1);
+ assert(i == 5);
+ assert(j == 5.5);
+ op_run = true;
+ }
+};
+
+int G::n_alive = 0;
+bool G::op_run = false;
+
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+
+class MoveOnly
+{
+ MoveOnly(const MoveOnly&);
+public:
+ MoveOnly() {}
+ MoveOnly(MoveOnly&&) {}
+
+ void operator()(MoveOnly&&)
+ {
+ }
+};
+
+#endif
+
+int main()
+{
+ {
+ std::thread t(f);
+ t.join();
+ assert(f_run == true);
+ }
+ f_run = false;
+ {
+ try
+ {
+ throw_one = 0;
+ std::thread t(f);
+ assert(false);
+ }
+ catch (...)
+ {
+ throw_one = 0xFFFF;
+ assert(!f_run);
+ }
+ }
+ {
+ assert(G::n_alive == 0);
+ assert(!G::op_run);
+ std::thread t((G()));
+ t.join();
+ assert(G::n_alive == 0);
+ assert(G::op_run);
+ }
+ G::op_run = false;
+ {
+ try
+ {
+ throw_one = 0;
+ assert(G::n_alive == 0);
+ assert(!G::op_run);
+ std::thread t((G()));
+ assert(false);
+ }
+ catch (...)
+ {
+ throw_one = 0xFFFF;
+ assert(G::n_alive == 0);
+ assert(!G::op_run);
+ }
+ }
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+ {
+ assert(G::n_alive == 0);
+ assert(!G::op_run);
+ std::thread t(G(), 5, 5.5);
+ t.join();
+ assert(G::n_alive == 0);
+ assert(G::op_run);
+ }
+ {
+ std::thread t = std::thread(MoveOnly(), MoveOnly());
+ t.join();
+ }
+#endif // _LIBCPP_HAS_NO_VARIADICS
+}
diff --git a/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/constr.fail.cpp b/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/constr.fail.cpp
new file mode 100644
index 000000000000..a331add96263
--- /dev/null
+++ b/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/constr.fail.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <thread>
+
+// class thread
+// template <class _Fp, class ..._Args,
+// explicit thread(_Fp&& __f, _Args&&... __args);
+// This constructor shall not participate in overload resolution
+// if decay<F>::type is the same type as std::thread.
+
+
+#include <thread>
+#include <cassert>
+
+int main()
+{
+ volatile std::thread t1;
+ std::thread t2 ( t1, 1, 2.0 );
+}
diff --git a/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/copy.fail.cpp b/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/copy.fail.cpp
new file mode 100644
index 000000000000..f66474c93b42
--- /dev/null
+++ b/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/copy.fail.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <thread>
+
+// class thread
+
+// thread(const thread&) = delete;
+
+#include <thread>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+class G
+{
+ int alive_;
+public:
+ static int n_alive;
+ static bool op_run;
+
+ G() : alive_(1) {++n_alive;}
+ G(const G& g) : alive_(g.alive_) {++n_alive;}
+ ~G() {alive_ = 0; --n_alive;}
+
+ void operator()()
+ {
+ assert(alive_ == 1);
+ assert(n_alive >= 1);
+ op_run = true;
+ }
+
+ void operator()(int i, double j)
+ {
+ assert(alive_ == 1);
+ assert(n_alive >= 1);
+ assert(i == 5);
+ assert(j == 5.5);
+ op_run = true;
+ }
+};
+
+int G::n_alive = 0;
+bool G::op_run = false;
+
+int main()
+{
+ {
+ assert(G::n_alive == 0);
+ assert(!G::op_run);
+ std::thread t0(G(), 5, 5.5);
+ std::thread::id id = t0.get_id();
+ std::thread t1 = t0;
+ assert(t1.get_id() == id);
+ assert(t0.get_id() == std::thread::id());
+ t1.join();
+ assert(G::n_alive == 0);
+ assert(G::op_run);
+ }
+}
diff --git a/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/default.pass.cpp b/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/default.pass.cpp
new file mode 100644
index 000000000000..64d5a935ba55
--- /dev/null
+++ b/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/default.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <thread>
+
+// class thread
+
+// thread();
+
+#include <thread>
+#include <cassert>
+
+int main()
+{
+ std::thread t;
+ assert(t.get_id() == std::thread::id());
+}
diff --git a/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/move.pass.cpp b/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/move.pass.cpp
new file mode 100644
index 000000000000..e88304ec8da9
--- /dev/null
+++ b/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/move.pass.cpp
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <thread>
+
+// class thread
+
+// thread(thread&& t);
+
+#include <thread>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+class G
+{
+ int alive_;
+public:
+ static int n_alive;
+ static bool op_run;
+
+ G() : alive_(1) {++n_alive;}
+ G(const G& g) : alive_(g.alive_) {++n_alive;}
+ ~G() {alive_ = 0; --n_alive;}
+
+ void operator()()
+ {
+ assert(alive_ == 1);
+ assert(n_alive >= 1);
+ op_run = true;
+ }
+
+ void operator()(int i, double j)
+ {
+ assert(alive_ == 1);
+ assert(n_alive >= 1);
+ assert(i == 5);
+ assert(j == 5.5);
+ op_run = true;
+ }
+};
+
+int G::n_alive = 0;
+bool G::op_run = false;
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ G g;
+ assert(G::n_alive == 1);
+ assert(!G::op_run);
+ std::thread t0(g, 5, 5.5);
+ std::thread::id id = t0.get_id();
+ std::thread t1 = std::move(t0);
+ assert(t1.get_id() == id);
+ assert(t0.get_id() == std::thread::id());
+ t1.join();
+ assert(G::n_alive == 1);
+ assert(G::op_run);
+ }
+ assert(G::n_alive == 0);
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/thread/thread.threads/thread.thread.class/thread.thread.destr/dtor.pass.cpp b/test/std/thread/thread.threads/thread.thread.class/thread.thread.destr/dtor.pass.cpp
new file mode 100644
index 000000000000..ddf96d095730
--- /dev/null
+++ b/test/std/thread/thread.threads/thread.thread.class/thread.thread.destr/dtor.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// NOTE: TSAN will report this test as leaking a thread.
+// XFAIL: tsan
+
+// <thread>
+
+// class thread
+
+// ~thread();
+
+#include <thread>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+class G
+{
+ int alive_;
+public:
+ static int n_alive;
+ static bool op_run;
+
+ G() : alive_(1) {++n_alive;}
+ G(const G& g) : alive_(g.alive_) {++n_alive;}
+ ~G() {alive_ = 0; --n_alive;}
+
+ void operator()()
+ {
+ assert(alive_ == 1);
+ assert(n_alive >= 1);
+ op_run = true;
+ }
+};
+
+int G::n_alive = 0;
+bool G::op_run = false;
+
+void f1()
+{
+ std::exit(0);
+}
+
+int main()
+{
+ std::set_terminate(f1);
+ {
+ assert(G::n_alive == 0);
+ assert(!G::op_run);
+ G g;
+ {
+ std::thread t(g);
+ std::this_thread::sleep_for(std::chrono::milliseconds(250));
+ }
+ }
+ assert(false);
+}
diff --git a/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/assign.pass.cpp b/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/assign.pass.cpp
new file mode 100644
index 000000000000..585f7ea98a03
--- /dev/null
+++ b/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/assign.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <thread>
+
+// class thread::id
+
+// id& operator=(const id&) = default;
+
+#include <thread>
+#include <cassert>
+
+int main()
+{
+ std::thread::id id0;
+ std::thread::id id1;
+ id1 = id0;
+ assert(id1 == id0);
+ id1 = std::this_thread::get_id();
+ assert(id1 != id0);
+}
diff --git a/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/copy.pass.cpp b/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/copy.pass.cpp
new file mode 100644
index 000000000000..e8c38016b288
--- /dev/null
+++ b/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/copy.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <thread>
+
+// class thread::id
+
+// id(const id&) = default;
+
+#include <thread>
+#include <cassert>
+
+int main()
+{
+ std::thread::id id0;
+ std::thread::id id1 = id0;
+ assert(id1 == id0);
+}
diff --git a/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/default.pass.cpp b/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/default.pass.cpp
new file mode 100644
index 000000000000..0037deb1dd65
--- /dev/null
+++ b/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/default.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <thread>
+
+// class thread::id
+
+// id();
+
+#include <thread>
+#include <cassert>
+
+int main()
+{
+ std::thread::id id;
+ assert(id == std::thread::id());
+}
diff --git a/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/eq.pass.cpp b/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/eq.pass.cpp
new file mode 100644
index 000000000000..6dd4c3ec4f57
--- /dev/null
+++ b/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/eq.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <thread>
+
+// class thread::id
+
+// bool operator==(thread::id x, thread::id y);
+// bool operator!=(thread::id x, thread::id y);
+
+#include <thread>
+#include <cassert>
+
+int main()
+{
+ std::thread::id id0;
+ std::thread::id id1;
+ id1 = id0;
+ assert( (id1 == id0));
+ assert(!(id1 != id0));
+ id1 = std::this_thread::get_id();
+ assert(!(id1 == id0));
+ assert( (id1 != id0));
+}
diff --git a/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/lt.pass.cpp b/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/lt.pass.cpp
new file mode 100644
index 000000000000..de52b1d00cdf
--- /dev/null
+++ b/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/lt.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <thread>
+
+// class thread::id
+
+// bool operator< (thread::id x, thread::id y);
+// bool operator<=(thread::id x, thread::id y);
+// bool operator> (thread::id x, thread::id y);
+// bool operator>=(thread::id x, thread::id y);
+
+#include <thread>
+#include <cassert>
+
+int main()
+{
+ std::thread::id id0;
+ std::thread::id id1;
+ std::thread::id id2 = std::this_thread::get_id();
+ assert(!(id0 < id1));
+ assert( (id0 <= id1));
+ assert(!(id0 > id1));
+ assert( (id0 >= id1));
+ assert(!(id0 == id2));
+ if (id0 < id2) {
+ assert( (id0 <= id2));
+ assert(!(id0 > id2));
+ assert(!(id0 >= id2));
+ } else {
+ assert(!(id0 <= id2));
+ assert( (id0 > id2));
+ assert( (id0 >= id2));
+ }
+}
diff --git a/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/stream.pass.cpp b/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/stream.pass.cpp
new file mode 100644
index 000000000000..126965fe3fc3
--- /dev/null
+++ b/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/stream.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <thread>
+
+// class thread::id
+
+// template<class charT, class traits>
+// basic_ostream<charT, traits>&
+// operator<<(basic_ostream<charT, traits>& out, thread::id id);
+
+#include <thread>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ std::thread::id id0 = std::this_thread::get_id();
+ std::ostringstream os;
+ os << id0;
+}
diff --git a/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/thread_id.pass.cpp b/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/thread_id.pass.cpp
new file mode 100644
index 000000000000..106c69e2e4a1
--- /dev/null
+++ b/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/thread_id.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <functional>
+
+// template <class T>
+// struct hash
+// : public unary_function<T, size_t>
+// {
+// size_t operator()(T val) const;
+// };
+
+// Not very portable
+
+#include <thread>
+#include <cassert>
+
+int main()
+{
+ std::thread::id id1;
+ std::thread::id id2 = std::this_thread::get_id();
+ typedef std::hash<std::thread::id> H;
+ static_assert((std::is_same<typename H::argument_type, std::thread::id>::value), "" );
+ static_assert((std::is_same<typename H::result_type, std::size_t>::value), "" );
+ H h;
+ assert(h(id1) != h(id2));
+}
diff --git a/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/detach.pass.cpp b/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/detach.pass.cpp
new file mode 100644
index 000000000000..f4a4d1f777f1
--- /dev/null
+++ b/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/detach.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <thread>
+
+// class thread
+
+// void detach();
+
+#include <thread>
+#include <atomic>
+#include <cassert>
+
+std::atomic_bool done = ATOMIC_VAR_INIT(false);
+
+class G
+{
+ int alive_;
+ bool done_;
+public:
+ static int n_alive;
+ static bool op_run;
+
+ G() : alive_(1), done_(false)
+ {
+ ++n_alive;
+ }
+
+ G(const G& g) : alive_(g.alive_), done_(false)
+ {
+ ++n_alive;
+ }
+ ~G()
+ {
+ alive_ = 0;
+ --n_alive;
+ if (done_) done = true;
+ }
+
+ void operator()()
+ {
+ assert(alive_ == 1);
+ assert(n_alive >= 1);
+ op_run = true;
+ done_ = true;
+ }
+};
+
+int G::n_alive = 0;
+bool G::op_run = false;
+
+int main()
+{
+ {
+ G g;
+ std::thread t0(g);
+ assert(t0.joinable());
+ t0.detach();
+ assert(!t0.joinable());
+ while (!done) {}
+ assert(G::op_run);
+ assert(G::n_alive == 1);
+ }
+ assert(G::n_alive == 0);
+}
diff --git a/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/get_id.pass.cpp b/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/get_id.pass.cpp
new file mode 100644
index 000000000000..5cca7b0b66b8
--- /dev/null
+++ b/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/get_id.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <thread>
+
+// class thread
+
+// id get_id() const;
+
+#include <thread>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+class G
+{
+ int alive_;
+public:
+ static int n_alive;
+ static bool op_run;
+
+ G() : alive_(1) {++n_alive;}
+ G(const G& g) : alive_(g.alive_) {++n_alive;}
+ ~G() {alive_ = 0; --n_alive;}
+
+ void operator()()
+ {
+ assert(alive_ == 1);
+ assert(n_alive >= 1);
+ op_run = true;
+ }
+};
+
+int G::n_alive = 0;
+bool G::op_run = false;
+
+int main()
+{
+ {
+ G g;
+ std::thread t0(g);
+ std::thread::id id0 = t0.get_id();
+ std::thread t1;
+ std::thread::id id1 = t1.get_id();
+ assert(t0.get_id() != id1);
+ assert(t1.get_id() == std::thread::id());
+ t0.join();
+ }
+}
diff --git a/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/join.pass.cpp b/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/join.pass.cpp
new file mode 100644
index 000000000000..0512e49dcb33
--- /dev/null
+++ b/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/join.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <thread>
+
+// class thread
+
+// void join();
+
+#include <thread>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+class G
+{
+ int alive_;
+public:
+ static int n_alive;
+ static bool op_run;
+
+ G() : alive_(1) {++n_alive;}
+ G(const G& g) : alive_(g.alive_) {++n_alive;}
+ ~G() {alive_ = 0; --n_alive;}
+
+ void operator()()
+ {
+ assert(alive_ == 1);
+ assert(n_alive >= 1);
+ op_run = true;
+ }
+};
+
+int G::n_alive = 0;
+bool G::op_run = false;
+
+int main()
+{
+ {
+ G g;
+ std::thread t0(g);
+ assert(t0.joinable());
+ t0.join();
+ assert(!t0.joinable());
+ }
+}
diff --git a/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/joinable.pass.cpp b/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/joinable.pass.cpp
new file mode 100644
index 000000000000..b97839c32184
--- /dev/null
+++ b/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/joinable.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <thread>
+
+// class thread
+
+// bool joinable() const;
+
+#include <thread>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+class G
+{
+ int alive_;
+public:
+ static int n_alive;
+ static bool op_run;
+
+ G() : alive_(1) {++n_alive;}
+ G(const G& g) : alive_(g.alive_) {++n_alive;}
+ ~G() {alive_ = 0; --n_alive;}
+
+ void operator()()
+ {
+ assert(alive_ == 1);
+ assert(n_alive >= 1);
+ op_run = true;
+ }
+};
+
+int G::n_alive = 0;
+bool G::op_run = false;
+
+int main()
+{
+ {
+ G g;
+ std::thread t0(g);
+ assert(t0.joinable());
+ t0.join();
+ assert(!t0.joinable());
+ }
+}
diff --git a/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/native_handle.pass.cpp b/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/native_handle.pass.cpp
new file mode 100644
index 000000000000..c8807a965c44
--- /dev/null
+++ b/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/native_handle.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <thread>
+
+// class thread
+
+// native_handle_type native_handle();
+
+#include <thread>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+class G
+{
+ int alive_;
+public:
+ static int n_alive;
+ static bool op_run;
+
+ G() : alive_(1) {++n_alive;}
+ G(const G& g) : alive_(g.alive_) {++n_alive;}
+ ~G() {alive_ = 0; --n_alive;}
+
+ void operator()()
+ {
+ assert(alive_ == 1);
+ assert(n_alive >= 1);
+ op_run = true;
+ }
+};
+
+int G::n_alive = 0;
+bool G::op_run = false;
+
+int main()
+{
+ {
+ G g;
+ std::thread t0(g);
+ pthread_t pid = t0.native_handle();
+ assert(pid != 0);
+ t0.join();
+ }
+}
diff --git a/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/swap.pass.cpp b/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/swap.pass.cpp
new file mode 100644
index 000000000000..49d4618e86ad
--- /dev/null
+++ b/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/swap.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <thread>
+
+// class thread
+
+// void swap(thread& t);
+
+#include <thread>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+class G
+{
+ int alive_;
+public:
+ static int n_alive;
+ static bool op_run;
+
+ G() : alive_(1) {++n_alive;}
+ G(const G& g) : alive_(g.alive_) {++n_alive;}
+ ~G() {alive_ = 0; --n_alive;}
+
+ void operator()()
+ {
+ assert(alive_ == 1);
+ assert(n_alive >= 1);
+ op_run = true;
+ }
+};
+
+int G::n_alive = 0;
+bool G::op_run = false;
+
+int main()
+{
+ {
+ G g;
+ std::thread t0(g);
+ std::thread::id id0 = t0.get_id();
+ std::thread t1;
+ std::thread::id id1 = t1.get_id();
+ t0.swap(t1);
+ assert(t0.get_id() == id1);
+ assert(t1.get_id() == id0);
+ t1.join();
+ }
+}
diff --git a/test/std/thread/thread.threads/thread.thread.class/thread.thread.static/hardware_concurrency.pass.cpp b/test/std/thread/thread.threads/thread.thread.class/thread.thread.static/hardware_concurrency.pass.cpp
new file mode 100644
index 000000000000..4d1ffad45937
--- /dev/null
+++ b/test/std/thread/thread.threads/thread.thread.class/thread.thread.static/hardware_concurrency.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <thread>
+
+// class thread
+
+// unsigned hardware_concurrency();
+
+#include <thread>
+#include <cassert>
+
+int main()
+{
+ assert(std::thread::hardware_concurrency() > 0);
+}
diff --git a/test/std/thread/thread.threads/thread.thread.class/types.pass.cpp b/test/std/thread/thread.threads/thread.thread.class/types.pass.cpp
new file mode 100644
index 000000000000..a5bf77031cca
--- /dev/null
+++ b/test/std/thread/thread.threads/thread.thread.class/types.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <thread>
+
+// class thread
+// {
+// public:
+// typedef pthread_t native_handle_type;
+// ...
+// };
+
+#include <thread>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_same<std::thread::native_handle_type, pthread_t>::value), "");
+}
diff --git a/test/std/thread/thread.threads/thread.thread.this/get_id.pass.cpp b/test/std/thread/thread.threads/thread.thread.this/get_id.pass.cpp
new file mode 100644
index 000000000000..3b4b7823a831
--- /dev/null
+++ b/test/std/thread/thread.threads/thread.thread.this/get_id.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <thread>
+
+// thread::id this_thread::get_id();
+
+#include <thread>
+#include <cassert>
+
+int main()
+{
+ std::thread::id id = std::this_thread::get_id();
+ assert(id != std::thread::id());
+}
diff --git a/test/std/thread/thread.threads/thread.thread.this/sleep_for.pass.cpp b/test/std/thread/thread.threads/thread.thread.this/sleep_for.pass.cpp
new file mode 100644
index 000000000000..27e1d2a1d42f
--- /dev/null
+++ b/test/std/thread/thread.threads/thread.thread.this/sleep_for.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <thread>
+
+// template <class Rep, class Period>
+// void sleep_for(const chrono::duration<Rep, Period>& rel_time);
+
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+#include <cstring>
+#include <signal.h>
+#include <sys/time.h>
+
+void sig_action(int) {}
+
+int main()
+{
+ int ec;
+ struct sigaction action;
+ action.sa_handler = &sig_action;
+ sigemptyset(&action.sa_mask);
+ action.sa_flags = 0;
+
+ ec = sigaction(SIGALRM, &action, nullptr);
+ assert(!ec);
+
+ struct itimerval it;
+ std::memset(&it, 0, sizeof(itimerval));
+ it.it_value.tv_sec = 0;
+ it.it_value.tv_usec = 250000;
+ // This will result in a SIGALRM getting fired resulting in the nanosleep
+ // inside sleep_for getting EINTR.
+ ec = setitimer(ITIMER_REAL, &it, nullptr);
+ assert(!ec);
+
+ typedef std::chrono::system_clock Clock;
+ typedef Clock::time_point time_point;
+ typedef Clock::duration duration;
+ std::chrono::milliseconds ms(500);
+ time_point t0 = Clock::now();
+ std::this_thread::sleep_for(ms);
+ time_point t1 = Clock::now();
+ std::chrono::nanoseconds ns = (t1 - t0) - ms;
+ std::chrono::nanoseconds err = 5 * ms / 100;
+ // The time slept is within 5% of 500ms
+ assert(std::abs(ns.count()) < err.count());
+}
diff --git a/test/std/thread/thread.threads/thread.thread.this/sleep_until.pass.cpp b/test/std/thread/thread.threads/thread.thread.this/sleep_until.pass.cpp
new file mode 100644
index 000000000000..9f3941b93adf
--- /dev/null
+++ b/test/std/thread/thread.threads/thread.thread.this/sleep_until.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <thread>
+
+// template <class Clock, class Duration>
+// void sleep_until(const chrono::time_point<Clock, Duration>& abs_time);
+
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+int main()
+{
+ typedef std::chrono::system_clock Clock;
+ typedef Clock::time_point time_point;
+ typedef Clock::duration duration;
+ std::chrono::milliseconds ms(500);
+ time_point t0 = Clock::now();
+ std::this_thread::sleep_until(t0 + ms);
+ time_point t1 = Clock::now();
+ std::chrono::nanoseconds ns = (t1 - t0) - ms;
+ std::chrono::nanoseconds err = 5 * ms / 100;
+ // The time slept is within 5% of 500ms
+ assert(std::abs(ns.count()) < err.count());
+}
diff --git a/test/std/thread/thread.threads/thread.thread.this/yield.pass.cpp b/test/std/thread/thread.threads/thread.thread.this/yield.pass.cpp
new file mode 100644
index 000000000000..daf5b0cf7abf
--- /dev/null
+++ b/test/std/thread/thread.threads/thread.thread.this/yield.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <thread>
+
+// void this_thread::yield();
+
+#include <thread>
+#include <cassert>
+
+int main()
+{
+ std::this_thread::yield();
+}
diff --git a/test/std/thread/thread.threads/version.pass.cpp b/test/std/thread/thread.threads/version.pass.cpp
new file mode 100644
index 000000000000..d16b0eb06842
--- /dev/null
+++ b/test/std/thread/thread.threads/version.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <thread>
+
+#include <thread>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/utilities/allocator.adaptor/allocator.adaptor.cnstr/allocs.pass.cpp b/test/std/utilities/allocator.adaptor/allocator.adaptor.cnstr/allocs.pass.cpp
new file mode 100644
index 000000000000..a5663a2e063e
--- /dev/null
+++ b/test/std/utilities/allocator.adaptor/allocator.adaptor.cnstr/allocs.pass.cpp
@@ -0,0 +1,112 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class OuterAlloc, class... InnerAllocs>
+// class scoped_allocator_adaptor
+
+// template <class OuterA2>
+// scoped_allocator_adaptor(OuterA2&& outerAlloc,
+// const InnerAllocs& ...innerAllocs);
+
+#include <scoped_allocator>
+#include <cassert>
+
+#include "allocators.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+ {
+ typedef std::scoped_allocator_adaptor<A1<int>> A;
+ A1<int> a3(3);
+ A a(a3);
+ assert(a.outer_allocator() == A1<int>(3));
+ assert(a.inner_allocator() == a);
+ assert(A1<int>::copy_called == true);
+ assert(A1<int>::move_called == false);
+ }
+ A1<int>::copy_called = false;
+ {
+ typedef std::scoped_allocator_adaptor<A1<int>> A;
+ A a(A1<int>(3));
+ assert(a.outer_allocator() == A1<int>(3));
+ assert(a.inner_allocator() == a);
+ assert(A1<int>::copy_called == false);
+ assert(A1<int>::move_called == true);
+ }
+ A1<int>::move_called = false;
+ {
+ typedef std::scoped_allocator_adaptor<A1<int>, A2<int>> A;
+ A1<int> a4(4);
+ A a(a4, A2<int>(5));
+ assert(A1<int>::copy_called == true);
+ assert(A1<int>::move_called == false);
+ assert(A2<int>::copy_called == true);
+ assert(A2<int>::move_called == false);
+ assert(a.outer_allocator() == A1<int>(4));
+ assert(a.inner_allocator() == std::scoped_allocator_adaptor<A2<int>>(A2<int>(5)));
+ }
+ A1<int>::copy_called = false;
+ A1<int>::move_called = false;
+ A2<int>::copy_called = false;
+ A2<int>::move_called = false;
+ {
+ typedef std::scoped_allocator_adaptor<A1<int>, A2<int>> A;
+ A a(A1<int>(4), A2<int>(5));
+ assert(A1<int>::copy_called == false);
+ assert(A1<int>::move_called == true);
+ assert(A2<int>::copy_called == true);
+ assert(A2<int>::move_called == false);
+ assert(a.outer_allocator() == A1<int>(4));
+ assert(a.inner_allocator() == std::scoped_allocator_adaptor<A2<int>>(A2<int>(5)));
+ }
+ A1<int>::copy_called = false;
+ A1<int>::move_called = false;
+ A2<int>::copy_called = false;
+ A2<int>::move_called = false;
+ A1<int>::move_called = false;
+ {
+ typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A;
+ A1<int> a4(4);
+ A a(a4, A2<int>(5), A3<int>(6));
+ assert(A1<int>::copy_called == true);
+ assert(A1<int>::move_called == false);
+ assert(A2<int>::copy_called == true);
+ assert(A2<int>::move_called == false);
+ assert(A3<int>::copy_called == true);
+ assert(A3<int>::move_called == false);
+ assert(a.outer_allocator() == A1<int>(4));
+ assert((a.inner_allocator() ==
+ std::scoped_allocator_adaptor<A2<int>, A3<int>>(A2<int>(5), A3<int>(6))));
+ }
+ A1<int>::copy_called = false;
+ A1<int>::move_called = false;
+ A2<int>::copy_called = false;
+ A2<int>::move_called = false;
+ A3<int>::copy_called = false;
+ A3<int>::move_called = false;
+ {
+ typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A;
+ A a(A1<int>(4), A2<int>(5), A3<int>(6));
+ assert(A1<int>::copy_called == false);
+ assert(A1<int>::move_called == true);
+ assert(A2<int>::copy_called == true);
+ assert(A2<int>::move_called == false);
+ assert(A3<int>::copy_called == true);
+ assert(A3<int>::move_called == false);
+ assert(a.outer_allocator() == A1<int>(4));
+ assert((a.inner_allocator() ==
+ std::scoped_allocator_adaptor<A2<int>, A3<int>>(A2<int>(5), A3<int>(6))));
+ }
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/utilities/allocator.adaptor/allocator.adaptor.cnstr/converting_copy.pass.cpp b/test/std/utilities/allocator.adaptor/allocator.adaptor.cnstr/converting_copy.pass.cpp
new file mode 100644
index 000000000000..9d40cf55a144
--- /dev/null
+++ b/test/std/utilities/allocator.adaptor/allocator.adaptor.cnstr/converting_copy.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class OuterAlloc, class... InnerAllocs>
+// class scoped_allocator_adaptor
+
+// template <class OuterA2>
+// scoped_allocator_adaptor(const scoped_allocator_adaptor<OuterA2,
+// InnerAllocs...>& other);
+
+#include <scoped_allocator>
+#include <cassert>
+
+#include "allocators.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+ {
+ typedef std::scoped_allocator_adaptor<A1<double>> B;
+ typedef std::scoped_allocator_adaptor<A1<int>> A;
+ B a1(A1<int>(3));
+ A1<int>::copy_called = false;
+ A1<int>::move_called = false;
+ A a2 = a1;
+ assert(A1<int>::copy_called == true);
+ assert(a2 == a1);
+ }
+ {
+ typedef std::scoped_allocator_adaptor<A1<double>, A2<int>> B;
+ typedef std::scoped_allocator_adaptor<A1<int>, A2<int>> A;
+ B a1(A1<int>(4), A2<int>(5));
+ A1<int>::copy_called = false;
+ A1<int>::move_called = false;
+ A2<int>::copy_called = false;
+ A2<int>::move_called = false;
+ A a2 = a1;
+ assert(A1<int>::copy_called == true);
+ assert(A2<int>::copy_called == true);
+ assert(a2 == a1);
+ }
+ {
+ typedef std::scoped_allocator_adaptor<A1<double>, A2<int>, A3<int>> B;
+ typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A;
+ B a1(A1<int>(4), A2<int>(5), A3<int>(6));
+ A1<int>::copy_called = false;
+ A1<int>::move_called = false;
+ A2<int>::copy_called = false;
+ A2<int>::move_called = false;
+ A3<int>::copy_called = false;
+ A3<int>::move_called = false;
+ A a2 = a1;
+ assert(A1<int>::copy_called == true);
+ assert(A2<int>::copy_called == true);
+ assert(A3<int>::copy_called == true);
+ assert(a2 == a1);
+ }
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/utilities/allocator.adaptor/allocator.adaptor.cnstr/converting_move.pass.cpp b/test/std/utilities/allocator.adaptor/allocator.adaptor.cnstr/converting_move.pass.cpp
new file mode 100644
index 000000000000..02e9dff7d7d3
--- /dev/null
+++ b/test/std/utilities/allocator.adaptor/allocator.adaptor.cnstr/converting_move.pass.cpp
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class OuterAlloc, class... InnerAllocs>
+// class scoped_allocator_adaptor
+
+// template <class OuterA2>
+// scoped_allocator_adaptor(scoped_allocator_adaptor<OuterA2,
+// InnerAllocs...>&& other);
+
+#include <scoped_allocator>
+#include <cassert>
+
+#include "allocators.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+ {
+ typedef std::scoped_allocator_adaptor<A1<double>> B;
+ typedef std::scoped_allocator_adaptor<A1<int>> A;
+ B a1(A1<int>(3));
+ A1<int>::copy_called = false;
+ A1<int>::move_called = false;
+ A a2 = std::move(a1);
+ assert(A1<int>::copy_called == false);
+ assert(A1<int>::move_called == true);
+ assert(a2 == a1);
+ }
+ {
+ typedef std::scoped_allocator_adaptor<A1<double>, A2<int>> B;
+ typedef std::scoped_allocator_adaptor<A1<int>, A2<int>> A;
+ B a1(A1<int>(4), A2<int>(5));
+ A1<int>::copy_called = false;
+ A1<int>::move_called = false;
+ A2<int>::copy_called = false;
+ A2<int>::move_called = false;
+ A a2 = std::move(a1);
+ assert(A1<int>::copy_called == false);
+ assert(A1<int>::move_called == true);
+ assert(A2<int>::copy_called == false);
+ assert(A2<int>::move_called == true);
+ assert(a2 == a1);
+ }
+ {
+ typedef std::scoped_allocator_adaptor<A1<double>, A2<int>, A3<int>> B;
+ typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A;
+ B a1(A1<int>(4), A2<int>(5), A3<int>(6));
+ A1<int>::copy_called = false;
+ A1<int>::move_called = false;
+ A2<int>::copy_called = false;
+ A2<int>::move_called = false;
+ A3<int>::copy_called = false;
+ A3<int>::move_called = false;
+ A a2 = std::move(a1);
+ assert(A1<int>::copy_called == false);
+ assert(A1<int>::move_called == true);
+ assert(A2<int>::copy_called == false);
+ assert(A2<int>::move_called == true);
+ assert(A3<int>::copy_called == false);
+ assert(A3<int>::move_called == true);
+ assert(a2 == a1);
+ }
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/utilities/allocator.adaptor/allocator.adaptor.cnstr/copy.pass.cpp b/test/std/utilities/allocator.adaptor/allocator.adaptor.cnstr/copy.pass.cpp
new file mode 100644
index 000000000000..21055325112f
--- /dev/null
+++ b/test/std/utilities/allocator.adaptor/allocator.adaptor.cnstr/copy.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class OuterAlloc, class... InnerAllocs>
+// class scoped_allocator_adaptor
+
+// scoped_allocator_adaptor(const scoped_allocator_adaptor& other);
+
+#include <scoped_allocator>
+#include <cassert>
+
+#include "allocators.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+ {
+ typedef std::scoped_allocator_adaptor<A1<int>> A;
+ A a1(A1<int>(3));
+ A1<int>::copy_called = false;
+ A1<int>::move_called = false;
+ A a2 = a1;
+ assert(A1<int>::copy_called == true);
+ assert(A1<int>::move_called == false);
+ assert(a2 == a1);
+ }
+ {
+ typedef std::scoped_allocator_adaptor<A1<int>, A2<int>> A;
+ A a1(A1<int>(4), A2<int>(5));
+ A1<int>::copy_called = false;
+ A1<int>::move_called = false;
+ A2<int>::copy_called = false;
+ A2<int>::move_called = false;
+ A a2 = a1;
+ assert(A1<int>::copy_called == true);
+ assert(A1<int>::move_called == false);
+ assert(A2<int>::copy_called == true);
+ assert(A2<int>::move_called == false);
+ assert(a2 == a1);
+ }
+ {
+ typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A;
+ A a1(A1<int>(4), A2<int>(5), A3<int>(6));
+ A1<int>::copy_called = false;
+ A1<int>::move_called = false;
+ A2<int>::copy_called = false;
+ A2<int>::move_called = false;
+ A3<int>::copy_called = false;
+ A3<int>::move_called = false;
+ A a2 = a1;
+ assert(A1<int>::copy_called == true);
+ assert(A1<int>::move_called == false);
+ assert(A2<int>::copy_called == true);
+ assert(A2<int>::move_called == false);
+ assert(A3<int>::copy_called == true);
+ assert(A3<int>::move_called == false);
+ assert(a2 == a1);
+ }
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/utilities/allocator.adaptor/allocator.adaptor.cnstr/default.pass.cpp b/test/std/utilities/allocator.adaptor/allocator.adaptor.cnstr/default.pass.cpp
new file mode 100644
index 000000000000..2a1d781eb9cd
--- /dev/null
+++ b/test/std/utilities/allocator.adaptor/allocator.adaptor.cnstr/default.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class OuterAlloc, class... InnerAllocs>
+// class scoped_allocator_adaptor
+
+// scoped_allocator_adaptor();
+
+#include <scoped_allocator>
+#include <cassert>
+
+#include "allocators.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+ {
+ typedef std::scoped_allocator_adaptor<A1<int>> A;
+ A a;
+ assert(a.outer_allocator() == A1<int>());
+ assert(a.inner_allocator() == a);
+ assert(A1<int>::copy_called == false);
+ assert(A1<int>::move_called == false);
+ }
+ {
+ typedef std::scoped_allocator_adaptor<A1<int>, A2<int>> A;
+ A a;
+ assert(a.outer_allocator() == A1<int>());
+ assert(a.inner_allocator() == std::scoped_allocator_adaptor<A2<int>>());
+ assert(A1<int>::copy_called == false);
+ assert(A1<int>::move_called == false);
+ assert(A2<int>::copy_called == false);
+ assert(A2<int>::move_called == false);
+ }
+ {
+ typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A;
+ A a;
+ assert(a.outer_allocator() == A1<int>());
+ assert((a.inner_allocator() == std::scoped_allocator_adaptor<A2<int>, A3<int>>()));
+ assert(A1<int>::copy_called == false);
+ assert(A1<int>::move_called == false);
+ assert(A2<int>::copy_called == false);
+ assert(A2<int>::move_called == false);
+ assert(A3<int>::copy_called == false);
+ assert(A3<int>::move_called == false);
+ }
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/utilities/allocator.adaptor/allocator.adaptor.members/allocate_size.pass.cpp b/test/std/utilities/allocator.adaptor/allocator.adaptor.members/allocate_size.pass.cpp
new file mode 100644
index 000000000000..727907e3ec76
--- /dev/null
+++ b/test/std/utilities/allocator.adaptor/allocator.adaptor.members/allocate_size.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class OuterAlloc, class... InnerAllocs>
+// class scoped_allocator_adaptor
+
+// pointer allocate(size_type n);
+
+#include <scoped_allocator>
+#include <cassert>
+
+#include "allocators.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+ {
+ typedef std::scoped_allocator_adaptor<A1<int>> A;
+ A a;
+ A1<int>::allocate_called = false;
+ assert(a.allocate(10) == (int*)10);
+ assert(A1<int>::allocate_called == true);
+ }
+ {
+ typedef std::scoped_allocator_adaptor<A1<int>, A2<int>> A;
+ A a;
+ A1<int>::allocate_called = false;
+ assert(a.allocate(10) == (int*)10);
+ assert(A1<int>::allocate_called == true);
+ }
+ {
+ typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A;
+ A a;
+ A1<int>::allocate_called = false;
+ assert(a.allocate(10) == (int*)10);
+ assert(A1<int>::allocate_called == true);
+ }
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/utilities/allocator.adaptor/allocator.adaptor.members/allocate_size_hint.pass.cpp b/test/std/utilities/allocator.adaptor/allocator.adaptor.members/allocate_size_hint.pass.cpp
new file mode 100644
index 000000000000..cae42de66905
--- /dev/null
+++ b/test/std/utilities/allocator.adaptor/allocator.adaptor.members/allocate_size_hint.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class OuterAlloc, class... InnerAllocs>
+// class scoped_allocator_adaptor
+
+// pointer allocate(size_type n, const_void_pointer hint);
+
+#include <scoped_allocator>
+#include <cassert>
+
+#include "allocators.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+ {
+ typedef std::scoped_allocator_adaptor<A1<int>> A;
+ A a;
+ A1<int>::allocate_called = false;
+ assert(a.allocate(10, (const void*)0) == (int*)10);
+ assert(A1<int>::allocate_called == true);
+ }
+ {
+ typedef std::scoped_allocator_adaptor<A1<int>, A2<int>> A;
+ A a;
+ A1<int>::allocate_called = false;
+ assert(a.allocate(10, (const void*)10) == (int*)10);
+ assert(A1<int>::allocate_called == true);
+ }
+ {
+ typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A;
+ A a;
+ A1<int>::allocate_called = false;
+ assert(a.allocate(10, (const void*)20) == (int*)10);
+ assert(A1<int>::allocate_called == true);
+ }
+
+ {
+ typedef std::scoped_allocator_adaptor<A2<int>> A;
+ A a;
+ A2<int>::allocate_called = false;
+ assert(a.allocate(10, (const void*)0) == (int*)0);
+ assert(A2<int>::allocate_called == true);
+ }
+ {
+ typedef std::scoped_allocator_adaptor<A2<int>, A2<int>> A;
+ A a;
+ A2<int>::allocate_called = false;
+ assert(a.allocate(10, (const void*)10) == (int*)10);
+ assert(A2<int>::allocate_called == true);
+ }
+ {
+ typedef std::scoped_allocator_adaptor<A2<int>, A2<int>, A3<int>> A;
+ A a;
+ A2<int>::allocate_called = false;
+ assert(a.allocate(10, (const void*)20) == (int*)20);
+ assert(A2<int>::allocate_called == true);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct.pass.cpp b/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct.pass.cpp
new file mode 100644
index 000000000000..f94b0e19ac90
--- /dev/null
+++ b/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct.pass.cpp
@@ -0,0 +1,193 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class OuterAlloc, class... InnerAllocs>
+// class scoped_allocator_adaptor
+
+// template <class T, class... Args> void construct(T* p, Args&&... args);
+
+#include <scoped_allocator>
+#include <cassert>
+#include <string>
+
+#include "allocators.h"
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+struct B
+{
+ static bool constructed;
+
+ typedef A1<B> allocator_type;
+
+ explicit B(std::allocator_arg_t, const allocator_type& a, int i)
+ {
+ assert(a.id() == 5);
+ assert(i == 6);
+ constructed = true;
+ }
+};
+
+bool B::constructed = false;
+
+struct C
+{
+ static bool constructed;
+
+ typedef std::scoped_allocator_adaptor<A2<C>> allocator_type;
+
+ explicit C(std::allocator_arg_t, const allocator_type& a, int i)
+ {
+ assert(a.id() == 7);
+ assert(i == 8);
+ constructed = true;
+ }
+};
+
+bool C::constructed = false;
+
+struct D
+{
+ static bool constructed;
+
+ typedef std::scoped_allocator_adaptor<A2<D>> allocator_type;
+
+ explicit D(int i, int j, const allocator_type& a)
+ {
+ assert(i == 1);
+ assert(j == 2);
+ assert(a.id() == 3);
+ constructed = true;
+ }
+};
+
+bool D::constructed = false;
+
+struct E
+{
+ static bool constructed;
+
+ typedef std::scoped_allocator_adaptor<A1<E>> allocator_type;
+
+ explicit E(int i, int j, const allocator_type& a)
+ {
+ assert(i == 1);
+ assert(j == 2);
+ assert(a.id() == 50);
+ constructed = true;
+ }
+};
+
+bool E::constructed = false;
+
+struct F
+{
+ static bool constructed;
+
+ typedef std::scoped_allocator_adaptor<A2<F>> allocator_type;
+
+ explicit F(int i, int j)
+ {
+ assert(i == 1);
+ assert(j == 2);
+ }
+
+ explicit F(int i, int j, const allocator_type& a)
+ {
+ assert(i == 1);
+ assert(j == 2);
+ assert(a.id() == 50);
+ constructed = true;
+ }
+};
+
+bool F::constructed = false;
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+ {
+ typedef std::scoped_allocator_adaptor<A1<std::string>> A;
+ A a;
+ char buf[100];
+ typedef std::string S;
+ S* s = (S*)buf;
+ a.construct(s, 4, 'c');
+ assert(*s == "cccc");
+ s->~S();
+ }
+
+ {
+ typedef std::scoped_allocator_adaptor<A1<B>> A;
+ A a(A1<B>(5));
+ char buf[100];
+ typedef B S;
+ S* s = (S*)buf;
+ a.construct(s, 6);
+ assert(S::constructed);
+ s->~S();
+ }
+
+ {
+ typedef std::scoped_allocator_adaptor<A1<int>, A2<C>> A;
+ A a(A1<int>(5), A2<C>(7));
+ char buf[100];
+ typedef C S;
+ S* s = (S*)buf;
+ a.construct(s, 8);
+ assert(S::constructed);
+ s->~S();
+ }
+
+ {
+ typedef std::scoped_allocator_adaptor<A1<int>, A2<D>> A;
+ A a(A1<int>(5), A2<D>(3));
+ char buf[100];
+ typedef D S;
+ S* s = (S*)buf;
+ a.construct(s, 1, 2);
+ assert(S::constructed);
+ s->~S();
+ }
+
+ {
+ typedef std::scoped_allocator_adaptor<A3<E>, A2<E>> K;
+ typedef std::scoped_allocator_adaptor<K, A1<E>> A;
+ A a(K(), A1<E>(50));
+ char buf[100];
+ typedef E S;
+ S* s = (S*)buf;
+ A3<E>::constructed = false;
+ a.construct(s, 1, 2);
+ assert(S::constructed);
+ assert(A3<E>::constructed);
+ s->~S();
+ }
+
+ {
+ typedef std::scoped_allocator_adaptor<A3<F>, A2<F>> K;
+ typedef std::scoped_allocator_adaptor<K, A1<F>> A;
+ A a(K(), A1<F>(50));
+ char buf[100];
+ typedef F S;
+ S* s = (S*)buf;
+ A3<F>::constructed = false;
+ a.construct(s, 1, 2);
+ assert(!S::constructed);
+ assert(A3<F>::constructed);
+ s->~S();
+ }
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/utilities/allocator.adaptor/allocator.adaptor.members/deallocate.pass.cpp b/test/std/utilities/allocator.adaptor/allocator.adaptor.members/deallocate.pass.cpp
new file mode 100644
index 000000000000..bf77f29f7145
--- /dev/null
+++ b/test/std/utilities/allocator.adaptor/allocator.adaptor.members/deallocate.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class OuterAlloc, class... InnerAllocs>
+// class scoped_allocator_adaptor
+
+// void deallocate(pointer p, size_type n);
+
+#include <scoped_allocator>
+#include <cassert>
+
+#include "allocators.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+ {
+ typedef std::scoped_allocator_adaptor<A1<int>> A;
+ A a;
+ a.deallocate((int*)10, 20);
+ assert((A1<int>::deallocate_called == std::pair<int*, std::size_t>((int*)10, 20)));
+ }
+ {
+ typedef std::scoped_allocator_adaptor<A1<int>, A2<int>> A;
+ A a;
+ a.deallocate((int*)10, 20);
+ assert((A1<int>::deallocate_called == std::pair<int*, std::size_t>((int*)10, 20)));
+ }
+ {
+ typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A;
+ A a;
+ a.deallocate((int*)10, 20);
+ assert((A1<int>::deallocate_called == std::pair<int*, std::size_t>((int*)10, 20)));
+ }
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/utilities/allocator.adaptor/allocator.adaptor.members/destroy.pass.cpp b/test/std/utilities/allocator.adaptor/allocator.adaptor.members/destroy.pass.cpp
new file mode 100644
index 000000000000..0ff3880f9fc1
--- /dev/null
+++ b/test/std/utilities/allocator.adaptor/allocator.adaptor.members/destroy.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class OuterAlloc, class... InnerAllocs>
+// class scoped_allocator_adaptor
+
+// template <class T> void destroy(T* p);
+
+#include <scoped_allocator>
+#include <cassert>
+#include <string>
+
+#include "allocators.h"
+
+struct B
+{
+ static bool constructed;
+
+ B() {constructed = true;}
+ ~B() {constructed = false;}
+};
+
+bool B::constructed = false;
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+ {
+ typedef std::scoped_allocator_adaptor<A1<B>> A;
+ A a;
+ char buf[100];
+ typedef B S;
+ S* s = (S*)buf;
+ assert(!S::constructed);
+ a.construct(s);
+ assert(S::constructed);
+ a.destroy(s);
+ assert(!S::constructed);
+ }
+
+ {
+ typedef std::scoped_allocator_adaptor<A3<B>, A1<B>> A;
+ A a;
+ char buf[100];
+ typedef B S;
+ S* s = (S*)buf;
+ assert(!S::constructed);
+ assert(!A3<S>::constructed);
+ assert(!A3<S>::destroy_called);
+ a.construct(s);
+ assert(S::constructed);
+ assert(A3<S>::constructed);
+ assert(!A3<S>::destroy_called);
+ a.destroy(s);
+ assert(!S::constructed);
+ assert(A3<S>::constructed);
+ assert(A3<S>::destroy_called);
+ }
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/utilities/allocator.adaptor/allocator.adaptor.members/inner_allocator.pass.cpp b/test/std/utilities/allocator.adaptor/allocator.adaptor.members/inner_allocator.pass.cpp
new file mode 100644
index 000000000000..0fb55b692cdb
--- /dev/null
+++ b/test/std/utilities/allocator.adaptor/allocator.adaptor.members/inner_allocator.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class OuterAlloc, class... InnerAllocs>
+// class scoped_allocator_adaptor
+
+// inner_allocator_type& inner_allocator();
+// const inner_allocator_type& inner_allocator() const;
+
+#include <scoped_allocator>
+#include <cassert>
+
+#include "allocators.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+ {
+ typedef std::scoped_allocator_adaptor<A1<int>> A;
+ A a(A1<int>(5));
+ assert(a.inner_allocator() == a);
+ }
+ {
+ typedef std::scoped_allocator_adaptor<A1<int>, A2<int>> A;
+ A a(A1<int>(5), A2<int>(6));
+ assert(a.inner_allocator() == std::scoped_allocator_adaptor<A2<int>>(A2<int>(6)));
+ }
+ {
+ typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A;
+ A a(A1<int>(5), A2<int>(6), A3<int>(8));
+ assert((a.inner_allocator() ==
+ std::scoped_allocator_adaptor<A2<int>, A3<int>>(A2<int>(6), A3<int>(8))));
+ }
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/utilities/allocator.adaptor/allocator.adaptor.members/max_size.pass.cpp b/test/std/utilities/allocator.adaptor/allocator.adaptor.members/max_size.pass.cpp
new file mode 100644
index 000000000000..a5275ee30253
--- /dev/null
+++ b/test/std/utilities/allocator.adaptor/allocator.adaptor.members/max_size.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class OuterAlloc, class... InnerAllocs>
+// class scoped_allocator_adaptor
+
+// size_type max_size() const;
+
+#include <scoped_allocator>
+#include <cassert>
+
+#include "allocators.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+ {
+ typedef std::scoped_allocator_adaptor<A1<int>> A;
+ const A a(A1<int>(100));
+ assert(a.max_size() == 100);
+ }
+ {
+ typedef std::scoped_allocator_adaptor<A1<int>, A2<int>> A;
+ const A a(A1<int>(20), A2<int>());
+ assert(a.max_size() == 20);
+ }
+ {
+ typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A;
+ const A a(A1<int>(200), A2<int>(), A3<int>());
+ assert(a.max_size() == 200);
+ }
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/utilities/allocator.adaptor/allocator.adaptor.members/outer_allocator.pass.cpp b/test/std/utilities/allocator.adaptor/allocator.adaptor.members/outer_allocator.pass.cpp
new file mode 100644
index 000000000000..2297612e6098
--- /dev/null
+++ b/test/std/utilities/allocator.adaptor/allocator.adaptor.members/outer_allocator.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class OuterAlloc, class... InnerAllocs>
+// class scoped_allocator_adaptor
+
+// outer_allocator_type& outer_allocator();
+// const outer_allocator_type& outer_allocator() const;
+
+#include <scoped_allocator>
+#include <cassert>
+
+#include "allocators.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+ {
+ typedef std::scoped_allocator_adaptor<A1<int>> A;
+ A a(A1<int>(5));
+ assert(a.outer_allocator() == A1<int>(5));
+ }
+ {
+ typedef std::scoped_allocator_adaptor<A1<int>, A2<int>> A;
+ A a(A1<int>(5), A2<int>(6));
+ assert(a.outer_allocator() == A1<int>(5));
+ }
+ {
+ typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A;
+ A a(A1<int>(5), A2<int>(6), A3<int>(8));
+ assert(a.outer_allocator() == A1<int>(5));
+ }
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/utilities/allocator.adaptor/allocator.adaptor.members/select_on_container_copy_construction.pass.cpp b/test/std/utilities/allocator.adaptor/allocator.adaptor.members/select_on_container_copy_construction.pass.cpp
new file mode 100644
index 000000000000..f9f0ffa2ad2a
--- /dev/null
+++ b/test/std/utilities/allocator.adaptor/allocator.adaptor.members/select_on_container_copy_construction.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class OuterAlloc, class... InnerAllocs>
+// class scoped_allocator_adaptor
+
+// scoped_allocator_adaptor select_on_container_copy_construction() const;
+
+#include <scoped_allocator>
+#include <cassert>
+
+#include "allocators.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+ {
+ typedef std::scoped_allocator_adaptor<A1<int>> A;
+ A a1(A1<int>(3));
+ assert(a1.outer_allocator().id() == 3);
+ A a2 = std::allocator_traits<A>::select_on_container_copy_construction(a1);
+ assert(a2.outer_allocator().id() == 3);
+ }
+
+ {
+ typedef std::scoped_allocator_adaptor<A3<int>> A;
+ A a1(A3<int>(3));
+ assert(a1.outer_allocator().id() == 3);
+ A a2 = std::allocator_traits<A>::select_on_container_copy_construction(a1);
+ assert(a2.outer_allocator().id() == -1);
+ }
+
+ {
+ typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A;
+ A a1(A1<int>(1), A2<int>(2), A3<int>(3));
+ assert(a1.outer_allocator().id() == 1);
+ assert(a1.inner_allocator().outer_allocator().id() == 2);
+ assert(a1.inner_allocator().inner_allocator().outer_allocator().id() == 3);
+ A a2 = std::allocator_traits<A>::select_on_container_copy_construction(a1);
+ assert(a2.outer_allocator().id() == 1);
+ assert(a2.inner_allocator().outer_allocator().id() == 2);
+ assert(a2.inner_allocator().inner_allocator().outer_allocator().id() == -1);
+ }
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/utilities/allocator.adaptor/allocator.adaptor.types/allocator_pointers.pass.cpp b/test/std/utilities/allocator.adaptor/allocator.adaptor.types/allocator_pointers.pass.cpp
new file mode 100644
index 000000000000..e165d9836db0
--- /dev/null
+++ b/test/std/utilities/allocator.adaptor/allocator.adaptor.types/allocator_pointers.pass.cpp
@@ -0,0 +1,117 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <scoped_allocator>
+#include <memory>
+#include <cassert>
+
+#if __cplusplus >= 201103L
+// #include <memory>
+//
+// template <class Alloc>
+// struct allocator_traits
+// {
+// typedef Alloc allocator_type;
+// typedef typename allocator_type::value_type
+// value_type;
+//
+// typedef Alloc::pointer | value_type* pointer;
+// typedef Alloc::const_pointer
+// | pointer_traits<pointer>::rebind<const value_type>
+// const_pointer;
+// typedef Alloc::void_pointer
+// | pointer_traits<pointer>::rebind<void>
+// void_pointer;
+// typedef Alloc::const_void_pointer
+// | pointer_traits<pointer>::rebind<const void>
+// const_void_pointer;
+
+template <typename Alloc>
+void test_pointer()
+{
+ typename std::allocator_traits<Alloc>::pointer vp;
+ typename std::allocator_traits<Alloc>::const_pointer cvp;
+
+ static_assert(std::is_same<bool, decltype( vp == vp)>::value, "");
+ static_assert(std::is_same<bool, decltype( vp != vp)>::value, "");
+ static_assert(std::is_same<bool, decltype( vp > vp)>::value, "");
+ static_assert(std::is_same<bool, decltype( vp >= vp)>::value, "");
+ static_assert(std::is_same<bool, decltype( vp < vp)>::value, "");
+ static_assert(std::is_same<bool, decltype( vp <= vp)>::value, "");
+
+ static_assert(std::is_same<bool, decltype( vp == cvp)>::value, "");
+ static_assert(std::is_same<bool, decltype(cvp == vp)>::value, "");
+ static_assert(std::is_same<bool, decltype( vp != cvp)>::value, "");
+ static_assert(std::is_same<bool, decltype(cvp != vp)>::value, "");
+ static_assert(std::is_same<bool, decltype( vp > cvp)>::value, "");
+ static_assert(std::is_same<bool, decltype(cvp > vp)>::value, "");
+ static_assert(std::is_same<bool, decltype( vp >= cvp)>::value, "");
+ static_assert(std::is_same<bool, decltype(cvp >= vp)>::value, "");
+ static_assert(std::is_same<bool, decltype( vp < cvp)>::value, "");
+ static_assert(std::is_same<bool, decltype(cvp < vp)>::value, "");
+ static_assert(std::is_same<bool, decltype( vp <= cvp)>::value, "");
+ static_assert(std::is_same<bool, decltype(cvp <= vp)>::value, "");
+
+ static_assert(std::is_same<bool, decltype(cvp == cvp)>::value, "");
+ static_assert(std::is_same<bool, decltype(cvp != cvp)>::value, "");
+ static_assert(std::is_same<bool, decltype(cvp > cvp)>::value, "");
+ static_assert(std::is_same<bool, decltype(cvp >= cvp)>::value, "");
+ static_assert(std::is_same<bool, decltype(cvp < cvp)>::value, "");
+ static_assert(std::is_same<bool, decltype(cvp <= cvp)>::value, "");
+}
+
+template <typename Alloc>
+void test_void_pointer()
+{
+ typename std::allocator_traits<Alloc>::void_pointer vp;
+ typename std::allocator_traits<Alloc>::const_void_pointer cvp;
+
+ static_assert(std::is_same<bool, decltype( vp == vp)>::value, "");
+ static_assert(std::is_same<bool, decltype( vp != vp)>::value, "");
+ static_assert(std::is_same<bool, decltype( vp > vp)>::value, "");
+ static_assert(std::is_same<bool, decltype( vp >= vp)>::value, "");
+ static_assert(std::is_same<bool, decltype( vp < vp)>::value, "");
+ static_assert(std::is_same<bool, decltype( vp <= vp)>::value, "");
+
+ static_assert(std::is_same<bool, decltype( vp == cvp)>::value, "");
+ static_assert(std::is_same<bool, decltype(cvp == vp)>::value, "");
+ static_assert(std::is_same<bool, decltype( vp != cvp)>::value, "");
+ static_assert(std::is_same<bool, decltype(cvp != vp)>::value, "");
+ static_assert(std::is_same<bool, decltype( vp > cvp)>::value, "");
+ static_assert(std::is_same<bool, decltype(cvp > vp)>::value, "");
+ static_assert(std::is_same<bool, decltype( vp >= cvp)>::value, "");
+ static_assert(std::is_same<bool, decltype(cvp >= vp)>::value, "");
+ static_assert(std::is_same<bool, decltype( vp < cvp)>::value, "");
+ static_assert(std::is_same<bool, decltype(cvp < vp)>::value, "");
+ static_assert(std::is_same<bool, decltype( vp <= cvp)>::value, "");
+ static_assert(std::is_same<bool, decltype(cvp <= vp)>::value, "");
+
+ static_assert(std::is_same<bool, decltype(cvp == cvp)>::value, "");
+ static_assert(std::is_same<bool, decltype(cvp != cvp)>::value, "");
+ static_assert(std::is_same<bool, decltype(cvp > cvp)>::value, "");
+ static_assert(std::is_same<bool, decltype(cvp >= cvp)>::value, "");
+ static_assert(std::is_same<bool, decltype(cvp < cvp)>::value, "");
+ static_assert(std::is_same<bool, decltype(cvp <= cvp)>::value, "");
+}
+
+struct Foo { int x; };
+
+int main()
+{
+ test_pointer<std::scoped_allocator_adaptor<std::allocator<char>>> ();
+ test_pointer<std::scoped_allocator_adaptor<std::allocator<int>>> ();
+ test_pointer<std::scoped_allocator_adaptor<std::allocator<Foo>>> ();
+
+ test_void_pointer<std::scoped_allocator_adaptor<std::allocator<char>>> ();
+ test_void_pointer<std::scoped_allocator_adaptor<std::allocator<int>>> ();
+ test_void_pointer<std::scoped_allocator_adaptor<std::allocator<Foo>>> ();
+}
+#else
+int main() {}
+#endif
diff --git a/test/std/utilities/allocator.adaptor/allocator.adaptor.types/inner_allocator_type.pass.cpp b/test/std/utilities/allocator.adaptor/allocator.adaptor.types/inner_allocator_type.pass.cpp
new file mode 100644
index 000000000000..4303b95166c7
--- /dev/null
+++ b/test/std/utilities/allocator.adaptor/allocator.adaptor.types/inner_allocator_type.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class OuterAlloc, class... InnerAllocs>
+// class scoped_allocator_adaptor
+
+// typedef see below inner_allocator_type;
+
+#include <scoped_allocator>
+#include <type_traits>
+
+#include "allocators.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+ static_assert((std::is_same<
+ std::scoped_allocator_adaptor<A1<int>>::inner_allocator_type,
+ std::scoped_allocator_adaptor<A1<int>>>::value), "");
+
+ static_assert((std::is_same<
+ std::scoped_allocator_adaptor<A1<int>, A2<int>>::inner_allocator_type,
+ std::scoped_allocator_adaptor<A2<int>>>::value), "");
+
+ static_assert((std::is_same<
+ std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>>::inner_allocator_type,
+ std::scoped_allocator_adaptor<A2<int>, A3<int>>>::value), "");
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/utilities/allocator.adaptor/allocator.adaptor.types/is_always_equal.pass.cpp b/test/std/utilities/allocator.adaptor/allocator.adaptor.types/is_always_equal.pass.cpp
new file mode 100644
index 000000000000..e19e731f6cf2
--- /dev/null
+++ b/test/std/utilities/allocator.adaptor/allocator.adaptor.types/is_always_equal.pass.cpp
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class OuterAlloc, class... InnerAllocs>
+// class scoped_allocator_adaptor
+
+// typedef see below is_always_equal;
+
+#include <scoped_allocator>
+#include <type_traits>
+
+#include "allocators.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+ // sanity checks
+ static_assert( (std::is_same<
+ std::allocator_traits<A1<int>>::is_always_equal, std::false_type>::value
+ ), "" );
+
+ static_assert( (std::is_same<
+ std::allocator_traits<min_allocator<int>>::is_always_equal, std::true_type>::value
+ ), "" );
+
+ // wrapping one allocator
+ static_assert(
+ (std::is_same<
+ std::scoped_allocator_adaptor<A1<int>>::is_always_equal,
+ std::allocator_traits<A1<int>>::is_always_equal
+ >::value), "");
+
+ // wrapping one allocator
+ static_assert(
+ (std::is_same<
+ std::scoped_allocator_adaptor<min_allocator<int>>::is_always_equal,
+ std::allocator_traits<min_allocator<int>>::is_always_equal
+ >::value), "");
+
+ // wrapping two allocators (check the values instead of the types)
+ static_assert((
+ std::scoped_allocator_adaptor<A1<int>, A2<int>>::is_always_equal::value ==
+ ( std::allocator_traits<A1<int>>::is_always_equal::value &&
+ std::allocator_traits<A2<int>>::is_always_equal::value)
+ ), "");
+
+ // wrapping two allocators (check the values instead of the types)
+ static_assert((
+ std::scoped_allocator_adaptor<A1<int>, min_allocator<int>>::is_always_equal::value ==
+ ( std::allocator_traits<A1<int>>::is_always_equal::value &&
+ std::allocator_traits<min_allocator<int>>::is_always_equal::value)
+ ), "");
+
+
+ // wrapping three allocators (check the values instead of the types)
+ static_assert((
+ std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>>::is_always_equal::value ==
+ ( std::allocator_traits<A1<int>>::is_always_equal::value &&
+ std::allocator_traits<A2<int>>::is_always_equal::value &&
+ std::allocator_traits<A3<int>>::is_always_equal::value)
+ ), "");
+
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/utilities/allocator.adaptor/allocator.adaptor.types/propagate_on_container_copy_assignment.pass.cpp b/test/std/utilities/allocator.adaptor/allocator.adaptor.types/propagate_on_container_copy_assignment.pass.cpp
new file mode 100644
index 000000000000..ceb941380dc7
--- /dev/null
+++ b/test/std/utilities/allocator.adaptor/allocator.adaptor.types/propagate_on_container_copy_assignment.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class OuterAlloc, class... InnerAllocs>
+// class scoped_allocator_adaptor
+
+// typedef see below propagate_on_container_copy_assignment;
+
+#include <scoped_allocator>
+#include <type_traits>
+
+#include "allocators.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+ static_assert((std::is_same<
+ std::scoped_allocator_adaptor<A1<int>>::propagate_on_container_copy_assignment,
+ std::false_type>::value), "");
+
+ static_assert((std::is_same<
+ std::scoped_allocator_adaptor<A1<int>, A2<int>>::propagate_on_container_copy_assignment,
+ std::false_type>::value), "");
+
+ static_assert((std::is_same<
+ std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>>::propagate_on_container_copy_assignment,
+ std::true_type>::value), "");
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/utilities/allocator.adaptor/allocator.adaptor.types/propagate_on_container_move_assignment.pass.cpp b/test/std/utilities/allocator.adaptor/allocator.adaptor.types/propagate_on_container_move_assignment.pass.cpp
new file mode 100644
index 000000000000..04da50706536
--- /dev/null
+++ b/test/std/utilities/allocator.adaptor/allocator.adaptor.types/propagate_on_container_move_assignment.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class OuterAlloc, class... InnerAllocs>
+// class scoped_allocator_adaptor
+
+// typedef see below propagate_on_container_move_assignment;
+
+#include <scoped_allocator>
+#include <type_traits>
+
+#include "allocators.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+ static_assert((std::is_same<
+ std::scoped_allocator_adaptor<A1<int>>::propagate_on_container_move_assignment,
+ std::false_type>::value), "");
+
+ static_assert((std::is_same<
+ std::scoped_allocator_adaptor<A1<int>, A2<int>>::propagate_on_container_move_assignment,
+ std::true_type>::value), "");
+
+ static_assert((std::is_same<
+ std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>>::propagate_on_container_move_assignment,
+ std::true_type>::value), "");
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/utilities/allocator.adaptor/allocator.adaptor.types/propagate_on_container_swap.pass.cpp b/test/std/utilities/allocator.adaptor/allocator.adaptor.types/propagate_on_container_swap.pass.cpp
new file mode 100644
index 000000000000..4a66bbd46749
--- /dev/null
+++ b/test/std/utilities/allocator.adaptor/allocator.adaptor.types/propagate_on_container_swap.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class OuterAlloc, class... InnerAllocs>
+// class scoped_allocator_adaptor
+
+// typedef see below propagate_on_container_swap;
+
+#include <scoped_allocator>
+#include <type_traits>
+
+#include "allocators.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+ static_assert((std::is_same<
+ std::scoped_allocator_adaptor<A1<int>>::propagate_on_container_swap,
+ std::false_type>::value), "");
+
+ static_assert((std::is_same<
+ std::scoped_allocator_adaptor<A1<int>, A2<int>>::propagate_on_container_swap,
+ std::false_type>::value), "");
+
+ static_assert((std::is_same<
+ std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>>::propagate_on_container_swap,
+ std::true_type>::value), "");
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/utilities/allocator.adaptor/scoped.adaptor.operators/eq.pass.cpp b/test/std/utilities/allocator.adaptor/scoped.adaptor.operators/eq.pass.cpp
new file mode 100644
index 000000000000..8d4cb6abe84a
--- /dev/null
+++ b/test/std/utilities/allocator.adaptor/scoped.adaptor.operators/eq.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class OuterAlloc, class... InnerAllocs>
+// class scoped_allocator_adaptor
+
+// template <class OuterA1, class OuterA2, class... InnerAllocs>
+// bool
+// operator==(const scoped_allocator_adaptor<OuterA1, InnerAllocs...>& a,
+// const scoped_allocator_adaptor<OuterA2, InnerAllocs...>& b);
+//
+// template <class OuterA1, class OuterA2, class... InnerAllocs>
+// bool
+// operator!=(const scoped_allocator_adaptor<OuterA1, InnerAllocs...>& a,
+// const scoped_allocator_adaptor<OuterA2, InnerAllocs...>& b);
+
+#include <scoped_allocator>
+#include <cassert>
+
+#include "allocators.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+ {
+ typedef std::scoped_allocator_adaptor<A1<int>> A;
+ A a1(A1<int>(3));
+ A a2 = a1;
+ assert(a2 == a1);
+ assert(!(a2 != a1));
+ }
+ {
+ typedef std::scoped_allocator_adaptor<A1<int>, A2<int>> A;
+ A a1(A1<int>(4), A2<int>(5));
+ A a2 = a1;
+ assert(a2 == a1);
+ assert(!(a2 != a1));
+ }
+ {
+ typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A;
+ A a1(A1<int>(4), A2<int>(5), A3<int>(6));
+ A a2 = a1;
+ assert(a2 == a1);
+ assert(!(a2 != a1));
+ }
+ {
+ typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A;
+ A a1(A1<int>(4), A2<int>(5), A3<int>(6));
+ A a2(A1<int>(4), A2<int>(5), A3<int>(5));
+ assert(a2 != a1);
+ assert(!(a2 == a1));
+ }
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/utilities/allocator.adaptor/types.pass.cpp b/test/std/utilities/allocator.adaptor/types.pass.cpp
new file mode 100644
index 000000000000..7beff48bbf46
--- /dev/null
+++ b/test/std/utilities/allocator.adaptor/types.pass.cpp
@@ -0,0 +1,102 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class OuterAlloc, class... InnerAllocs>
+// class scoped_allocator_adaptor
+// : public OuterAlloc
+// {
+// public:
+// typedef OuterAlloc outer_allocator_type;
+// typedef typename OuterTraits::size_type size_type;
+// typedef typename OuterTraits::difference_type difference_type;
+// typedef typename OuterTraits::pointer pointer;
+// typedef typename OuterTraits::const_pointer const_pointer;
+// typedef typename OuterTraits::void_pointer void_pointer;
+// typedef typename OuterTraits::const_void_pointer const_void_pointer;
+// };
+
+#include <scoped_allocator>
+#include <type_traits>
+
+#include "allocators.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+ static_assert((std::is_base_of<
+ A1<int>,
+ std::scoped_allocator_adaptor<A1<int>>
+ >::value), "");
+
+ static_assert((std::is_same<
+ std::scoped_allocator_adaptor<A1<int>>::outer_allocator_type,
+ A1<int>>::value), "");
+
+ static_assert((std::is_same<
+ std::scoped_allocator_adaptor<A1<int>>::size_type,
+ std::make_unsigned<std::ptrdiff_t>::type>::value), "");
+
+ static_assert((std::is_same<
+ std::scoped_allocator_adaptor<A1<int>>::difference_type,
+ std::ptrdiff_t>::value), "");
+
+ static_assert((std::is_same<
+ std::scoped_allocator_adaptor<A1<int>>::pointer,
+ int*>::value), "");
+
+ static_assert((std::is_same<
+ std::scoped_allocator_adaptor<A1<int>>::const_pointer,
+ const int*>::value), "");
+
+ static_assert((std::is_same<
+ std::scoped_allocator_adaptor<A1<int>>::void_pointer,
+ void*>::value), "");
+
+ static_assert((std::is_same<
+ std::scoped_allocator_adaptor<A1<int>>::const_void_pointer,
+ const void*>::value), "");
+
+ static_assert((std::is_base_of<
+ A2<int>,
+ std::scoped_allocator_adaptor<A2<int>, A1<int>>
+ >::value), "");
+
+ static_assert((std::is_same<
+ std::scoped_allocator_adaptor<A2<int>, A1<int>>::outer_allocator_type,
+ A2<int>>::value), "");
+
+ static_assert((std::is_same<
+ std::scoped_allocator_adaptor<A2<int>, A1<int>>::size_type,
+ unsigned>::value), "");
+
+ static_assert((std::is_same<
+ std::scoped_allocator_adaptor<A2<int>, A1<int>>::difference_type,
+ int>::value), "");
+
+ static_assert((std::is_same<
+ std::scoped_allocator_adaptor<A2<int>, A1<int>>::pointer,
+ int*>::value), "");
+
+ static_assert((std::is_same<
+ std::scoped_allocator_adaptor<A2<int>, A1<int>>::const_pointer,
+ const int*>::value), "");
+
+ static_assert((std::is_same<
+ std::scoped_allocator_adaptor<A2<int>, A1<int>>::void_pointer,
+ void*>::value), "");
+
+ static_assert((std::is_same<
+ std::scoped_allocator_adaptor<A2<int>, A1<int>>::const_void_pointer,
+ const void*>::value), "");
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/utilities/date.time/asctime.thread-unsafe.fail.cpp b/test/std/utilities/date.time/asctime.thread-unsafe.fail.cpp
new file mode 100644
index 000000000000..3a9749e21c52
--- /dev/null
+++ b/test/std/utilities/date.time/asctime.thread-unsafe.fail.cpp
@@ -0,0 +1,18 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: libcpp-has-no-thread-unsafe-c-functions
+
+#include <ctime>
+
+int main() {
+ // asctime is not thread-safe.
+ std::time_t t = 0;
+ std::asctime(&t);
+}
diff --git a/test/std/utilities/date.time/ctime.thread-unsafe.fail.cpp b/test/std/utilities/date.time/ctime.thread-unsafe.fail.cpp
new file mode 100644
index 000000000000..cd246c631527
--- /dev/null
+++ b/test/std/utilities/date.time/ctime.thread-unsafe.fail.cpp
@@ -0,0 +1,18 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: libcpp-has-no-thread-unsafe-c-functions
+
+#include <ctime>
+
+int main() {
+ // ctime is not thread-safe.
+ std::time_t t = 0;
+ std::ctime(&t);
+}
diff --git a/test/std/utilities/date.time/gmtime.thread-unsafe.fail.cpp b/test/std/utilities/date.time/gmtime.thread-unsafe.fail.cpp
new file mode 100644
index 000000000000..a6debcbd98d8
--- /dev/null
+++ b/test/std/utilities/date.time/gmtime.thread-unsafe.fail.cpp
@@ -0,0 +1,18 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: libcpp-has-no-thread-unsafe-c-functions
+
+#include <ctime>
+
+int main() {
+ // gmtime is not thread-safe.
+ std::time_t t = 0;
+ std::gmtime(&t);
+}
diff --git a/test/std/utilities/date.time/localtime.thread-unsafe.fail.cpp b/test/std/utilities/date.time/localtime.thread-unsafe.fail.cpp
new file mode 100644
index 000000000000..c9e55c8fd3a6
--- /dev/null
+++ b/test/std/utilities/date.time/localtime.thread-unsafe.fail.cpp
@@ -0,0 +1,18 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: libcpp-has-no-thread-unsafe-c-functions
+
+#include <ctime>
+
+int main() {
+ // localtime is not thread-safe.
+ std::time_t t = 0;
+ std::localtime(&t);
+}
diff --git a/test/std/utilities/date.time/tested_elsewhere.pass.cpp b/test/std/utilities/date.time/tested_elsewhere.pass.cpp
new file mode 100644
index 000000000000..419f415dee19
--- /dev/null
+++ b/test/std/utilities/date.time/tested_elsewhere.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <ctime>
+#include <type_traits>
+
+#ifndef NULL
+#error NULL not defined
+#endif
+
+#ifndef CLOCKS_PER_SEC
+#error CLOCKS_PER_SEC not defined
+#endif
+
+int main()
+{
+ std::clock_t c = 0;
+ ((void)c); // avoid unused warning
+ std::size_t s = 0;
+ std::time_t t = 0;
+ std::tm tm = {0};
+ char str[3];
+ static_assert((std::is_same<decltype(std::clock()), std::clock_t>::value), "");
+ static_assert((std::is_same<decltype(std::difftime(t,t)), double>::value), "");
+ static_assert((std::is_same<decltype(std::mktime(&tm)), std::time_t>::value), "");
+ static_assert((std::is_same<decltype(std::time(&t)), std::time_t>::value), "");
+ static_assert((std::is_same<decltype(std::asctime(&tm)), char*>::value), "");
+ static_assert((std::is_same<decltype(std::ctime(&t)), char*>::value), "");
+ static_assert((std::is_same<decltype(std::gmtime(&t)), std::tm*>::value), "");
+ static_assert((std::is_same<decltype(std::localtime(&t)), std::tm*>::value), "");
+ static_assert((std::is_same<decltype(std::strftime(str,s,"",&tm)), std::size_t>::value), "");
+}
diff --git a/test/std/utilities/function.objects/arithmetic.operations/divides.pass.cpp b/test/std/utilities/function.objects/arithmetic.operations/divides.pass.cpp
new file mode 100644
index 000000000000..490dc16b60e2
--- /dev/null
+++ b/test/std/utilities/function.objects/arithmetic.operations/divides.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// divides
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+ typedef std::divides<int> F;
+ const F f = F();
+ static_assert((std::is_same<int, F::first_argument_type>::value), "" );
+ static_assert((std::is_same<int, F::second_argument_type>::value), "" );
+ static_assert((std::is_same<int, F::result_type>::value), "" );
+ assert(f(36, 4) == 9);
+#if _LIBCPP_STD_VER > 11
+ typedef std::divides<> F2;
+ const F2 f2 = F2();
+ assert(f2(36, 4) == 9);
+ assert(f2(36.0, 4) == 9);
+ assert(f2(18, 4.0) == 4.5); // exact in binary
+
+ constexpr int foo = std::divides<int> () (3, 2);
+ static_assert ( foo == 1, "" );
+
+ constexpr int bar = std::divides<> () (3.0, 2);
+ static_assert ( bar == 1, "" );
+#endif
+}
diff --git a/test/std/utilities/function.objects/arithmetic.operations/minus.pass.cpp b/test/std/utilities/function.objects/arithmetic.operations/minus.pass.cpp
new file mode 100644
index 000000000000..9bda541f896a
--- /dev/null
+++ b/test/std/utilities/function.objects/arithmetic.operations/minus.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// minus
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+ typedef std::minus<int> F;
+ const F f = F();
+ static_assert((std::is_same<int, F::first_argument_type>::value), "" );
+ static_assert((std::is_same<int, F::second_argument_type>::value), "" );
+ static_assert((std::is_same<int, F::result_type>::value), "" );
+ assert(f(3, 2) == 1);
+#if _LIBCPP_STD_VER > 11
+ typedef std::minus<> F2;
+ const F2 f2 = F2();
+ assert(f2(3,2) == 1);
+ assert(f2(3.0, 2) == 1);
+ assert(f2(3, 2.5) == 0.5);
+
+ constexpr int foo = std::minus<int> () (3, 2);
+ static_assert ( foo == 1, "" );
+
+ constexpr int bar = std::minus<> () (3.0, 2);
+ static_assert ( bar == 1, "" );
+#endif
+}
diff --git a/test/std/utilities/function.objects/arithmetic.operations/modulus.pass.cpp b/test/std/utilities/function.objects/arithmetic.operations/modulus.pass.cpp
new file mode 100644
index 000000000000..ca5bba6d5b8e
--- /dev/null
+++ b/test/std/utilities/function.objects/arithmetic.operations/modulus.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// modulus
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+ typedef std::modulus<int> F;
+ const F f = F();
+ static_assert((std::is_same<int, F::first_argument_type>::value), "" );
+ static_assert((std::is_same<int, F::second_argument_type>::value), "" );
+ static_assert((std::is_same<int, F::result_type>::value), "" );
+ assert(f(36, 8) == 4);
+#if _LIBCPP_STD_VER > 11
+ typedef std::modulus<> F2;
+ const F2 f2 = F2();
+ assert(f2(36, 8) == 4);
+ assert(f2(36L, 8) == 4);
+ assert(f2(36, 8L) == 4);
+
+ constexpr int foo = std::modulus<int> () (3, 2);
+ static_assert ( foo == 1, "" );
+
+ constexpr int bar = std::modulus<> () (3L, 2);
+ static_assert ( bar == 1, "" );
+#endif
+}
diff --git a/test/std/utilities/function.objects/arithmetic.operations/multiplies.pass.cpp b/test/std/utilities/function.objects/arithmetic.operations/multiplies.pass.cpp
new file mode 100644
index 000000000000..f132c8d4bd9b
--- /dev/null
+++ b/test/std/utilities/function.objects/arithmetic.operations/multiplies.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// multiplies
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+ typedef std::multiplies<int> F;
+ const F f = F();
+ static_assert((std::is_same<int, F::first_argument_type>::value), "" );
+ static_assert((std::is_same<int, F::second_argument_type>::value), "" );
+ static_assert((std::is_same<int, F::result_type>::value), "" );
+ assert(f(3, 2) == 6);
+#if _LIBCPP_STD_VER > 11
+ typedef std::multiplies<> F2;
+ const F2 f2 = F2();
+ assert(f2(3,2) == 6);
+ assert(f2(3.0, 2) == 6);
+ assert(f2(3, 2.5) == 7.5); // exact in binary
+
+ constexpr int foo = std::multiplies<int> () (3, 2);
+ static_assert ( foo == 6, "" );
+
+ constexpr int bar = std::multiplies<> () (3.0, 2);
+ static_assert ( bar == 6, "" );
+#endif
+}
diff --git a/test/std/utilities/function.objects/arithmetic.operations/negate.pass.cpp b/test/std/utilities/function.objects/arithmetic.operations/negate.pass.cpp
new file mode 100644
index 000000000000..0adac659123b
--- /dev/null
+++ b/test/std/utilities/function.objects/arithmetic.operations/negate.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// negate
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+ typedef std::negate<int> F;
+ const F f = F();
+ static_assert((std::is_same<F::argument_type, int>::value), "" );
+ static_assert((std::is_same<F::result_type, int>::value), "" );
+ assert(f(36) == -36);
+#if _LIBCPP_STD_VER > 11
+ typedef std::negate<> F2;
+ const F2 f2 = F2();
+ assert(f2(36) == -36);
+ assert(f2(36L) == -36);
+ assert(f2(36.0) == -36);
+
+ constexpr int foo = std::negate<int> () (3);
+ static_assert ( foo == -3, "" );
+
+ constexpr int bar = std::negate<> () (3.0);
+ static_assert ( bar == -3, "" );
+#endif
+}
diff --git a/test/std/utilities/function.objects/arithmetic.operations/plus.pass.cpp b/test/std/utilities/function.objects/arithmetic.operations/plus.pass.cpp
new file mode 100644
index 000000000000..3c093fc093c3
--- /dev/null
+++ b/test/std/utilities/function.objects/arithmetic.operations/plus.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// plus
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+ typedef std::plus<int> F;
+ const F f = F();
+ static_assert((std::is_same<int, F::first_argument_type>::value), "" );
+ static_assert((std::is_same<int, F::second_argument_type>::value), "" );
+ static_assert((std::is_same<int, F::result_type>::value), "" );
+ assert(f(3, 2) == 5);
+#if _LIBCPP_STD_VER > 11
+ typedef std::plus<> F2;
+ const F2 f2 = F2();
+ assert(f2(3,2) == 5);
+ assert(f2(3.0, 2) == 5);
+ assert(f2(3, 2.5) == 5.5);
+
+ constexpr int foo = std::plus<int> () (3, 2);
+ static_assert ( foo == 5, "" );
+
+ constexpr int bar = std::plus<> () (3.0, 2);
+ static_assert ( bar == 5, "" );
+#endif
+}
diff --git a/test/std/utilities/function.objects/arithmetic.operations/transparent.pass.cpp b/test/std/utilities/function.objects/arithmetic.operations/transparent.pass.cpp
new file mode 100644
index 000000000000..72b4b4a0a1fe
--- /dev/null
+++ b/test/std/utilities/function.objects/arithmetic.operations/transparent.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <functional>
+#include <string>
+
+template <class _Tp>
+struct is_transparent
+{
+private:
+ struct __two {char __lx; char __lxx;};
+ template <class _Up> static __two __test(...);
+ template <class _Up> static char __test(typename _Up::is_transparent* = 0);
+public:
+ static const bool value = sizeof(__test<_Tp>(0)) == 1;
+};
+
+
+int main () {
+#if _LIBCPP_STD_VER > 11
+
+ static_assert ( !is_transparent<std::plus<int>>::value, "" );
+ static_assert ( !is_transparent<std::plus<std::string>>::value, "" );
+ static_assert ( is_transparent<std::plus<void>>::value, "" );
+ static_assert ( is_transparent<std::plus<>>::value, "" );
+
+ static_assert ( !is_transparent<std::minus<int>>::value, "" );
+ static_assert ( !is_transparent<std::minus<std::string>>::value, "" );
+ static_assert ( is_transparent<std::minus<void>>::value, "" );
+ static_assert ( is_transparent<std::minus<>>::value, "" );
+
+ static_assert ( !is_transparent<std::multiplies<int>>::value, "" );
+ static_assert ( !is_transparent<std::multiplies<std::string>>::value, "" );
+ static_assert ( is_transparent<std::multiplies<void>>::value, "" );
+ static_assert ( is_transparent<std::multiplies<>>::value, "" );
+
+ static_assert ( !is_transparent<std::divides<int>>::value, "" );
+ static_assert ( !is_transparent<std::divides<std::string>>::value, "" );
+ static_assert ( is_transparent<std::divides<void>>::value, "" );
+ static_assert ( is_transparent<std::divides<>>::value, "" );
+
+ static_assert ( !is_transparent<std::modulus<int>>::value, "" );
+ static_assert ( !is_transparent<std::modulus<std::string>>::value, "" );
+ static_assert ( is_transparent<std::modulus<void>>::value, "" );
+ static_assert ( is_transparent<std::modulus<>>::value, "" );
+
+ static_assert ( !is_transparent<std::negate<int>>::value, "" );
+ static_assert ( !is_transparent<std::negate<std::string>>::value, "" );
+ static_assert ( is_transparent<std::negate<void>>::value, "" );
+ static_assert ( is_transparent<std::negate<>>::value, "" );
+
+#endif
+
+ return 0;
+ }
diff --git a/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/copy.pass.cpp b/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/copy.pass.cpp
new file mode 100644
index 000000000000..6315598125c9
--- /dev/null
+++ b/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/copy.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template<CopyConstructible Fn, CopyConstructible... Types>
+// unspecified bind(Fn, Types...);
+// template<Returnable R, CopyConstructible Fn, CopyConstructible... Types>
+// unspecified bind(Fn, Types...);
+
+// http://llvm.org/bugs/show_bug.cgi?id=16385
+
+#include <functional>
+#include <cmath>
+#include <cassert>
+
+float _pow(float a, float b)
+{
+ return std::pow(a, b);
+}
+
+int main()
+{
+ std::function<float(float, float)> fnc = _pow;
+ auto task = std::bind(fnc, 2.f, 4.f);
+ auto task2(task);
+ assert(task() == 16);
+ assert(task2() == 16);
+}
diff --git a/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_function_object.pass.cpp b/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_function_object.pass.cpp
new file mode 100644
index 000000000000..33bf01855908
--- /dev/null
+++ b/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_function_object.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template<CopyConstructible Fn, CopyConstructible... Types>
+// unspecified bind(Fn, Types...);
+// template<Returnable R, CopyConstructible Fn, CopyConstructible... Types>
+// unspecified bind(Fn, Types...);
+
+// http://llvm.org/bugs/show_bug.cgi?id=22003
+
+#include <functional>
+
+struct DummyUnaryFunction
+{
+ template <typename S>
+ int operator()(S const & s) const { return 0; }
+};
+
+struct BadUnaryFunction
+{
+ template <typename S>
+ constexpr int operator()(S const & s) const
+ {
+ // Trigger a compile error if this function is instantiated.
+ // The constexpr is needed so that it is instantiated while checking
+ // __invoke_of<BadUnaryFunction &, ...>.
+ static_assert(!std::is_same<S, S>::value, "Shit");
+ return 0;
+ }
+};
+
+int main(int argc, char* argv[])
+{
+ // Check that BadUnaryFunction::operator()(S const &) is not
+ // instantiated when checking if BadUnaryFunction is a nested bind
+ // expression during b(0). See PR22003.
+ auto b = std::bind(DummyUnaryFunction(), BadUnaryFunction());
+ b(0);
+ auto b2 = std::bind<long>(DummyUnaryFunction(), BadUnaryFunction());
+ b2(0);
+}
diff --git a/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_int_0.pass.cpp b/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_int_0.pass.cpp
new file mode 100644
index 000000000000..ab4dd59534d5
--- /dev/null
+++ b/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_int_0.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template<CopyConstructible Fn, CopyConstructible... Types>
+// unspecified bind(Fn, Types...);
+// template<Returnable R, CopyConstructible Fn, CopyConstructible... Types>
+// unspecified bind(Fn, Types...);
+
+#include <functional>
+#include <cassert>
+
+template <class R, class F>
+void
+test(F f, R expected)
+{
+ assert(f() == expected);
+}
+
+template <class R, class F>
+void
+test_const(const F& f, R expected)
+{
+ assert(f() == expected);
+}
+
+int f() {return 1;}
+
+struct A_int_0
+{
+ int operator()() {return 4;}
+ int operator()() const {return 5;}
+};
+
+int main()
+{
+ test(std::bind(f), 1);
+ test(std::bind(&f), 1);
+ test(std::bind(A_int_0()), 4);
+ test_const(std::bind(A_int_0()), 5);
+
+ test(std::bind<int>(f), 1);
+ test(std::bind<int>(&f), 1);
+ test(std::bind<int>(A_int_0()), 4);
+ test_const(std::bind<int>(A_int_0()), 5);
+}
diff --git a/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_lvalue.pass.cpp b/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_lvalue.pass.cpp
new file mode 100644
index 000000000000..af5efe464d5d
--- /dev/null
+++ b/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_lvalue.pass.cpp
@@ -0,0 +1,287 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template<CopyConstructible Fn, CopyConstructible... Types>
+// unspecified bind(Fn, Types...);
+// template<Returnable R, CopyConstructible Fn, CopyConstructible... Types>
+// unspecified bind(Fn, Types...);
+
+#include <stdio.h>
+
+#include <functional>
+#include <cassert>
+
+int count = 0;
+
+// 1 arg, return void
+
+void f_void_1(int i)
+{
+ count += i;
+}
+
+struct A_void_1
+{
+ void operator()(int i)
+ {
+ count += i;
+ }
+
+ void mem1() {++count;}
+ void mem2() const {count += 2;}
+};
+
+void
+test_void_1()
+{
+ using namespace std::placeholders;
+ int save_count = count;
+ // function
+ {
+ int i = 2;
+ std::bind(f_void_1, _1)(i);
+ assert(count == save_count + 2);
+ save_count = count;
+ }
+ {
+ int i = 2;
+ std::bind(f_void_1, i)();
+ assert(count == save_count + 2);
+ save_count = count;
+ }
+ // function pointer
+ {
+ void (*fp)(int) = f_void_1;
+ int i = 3;
+ std::bind(fp, _1)(i);
+ assert(count == save_count+3);
+ save_count = count;
+ }
+ {
+ void (*fp)(int) = f_void_1;
+ int i = 3;
+ std::bind(fp, i)();
+ assert(count == save_count+3);
+ save_count = count;
+ }
+ // functor
+ {
+ A_void_1 a0;
+ int i = 4;
+ std::bind(a0, _1)(i);
+ assert(count == save_count+4);
+ save_count = count;
+ }
+ {
+ A_void_1 a0;
+ int i = 4;
+ std::bind(a0, i)();
+ assert(count == save_count+4);
+ save_count = count;
+ }
+ // member function pointer
+ {
+ void (A_void_1::*fp)() = &A_void_1::mem1;
+ A_void_1 a;
+ std::bind(fp, _1)(a);
+ assert(count == save_count+1);
+ save_count = count;
+ A_void_1* ap = &a;
+ std::bind(fp, _1)(ap);
+ assert(count == save_count+1);
+ save_count = count;
+ }
+ {
+ void (A_void_1::*fp)() = &A_void_1::mem1;
+ A_void_1 a;
+ std::bind(fp, a)();
+ assert(count == save_count+1);
+ save_count = count;
+ A_void_1* ap = &a;
+ std::bind(fp, ap)();
+ assert(count == save_count+1);
+ save_count = count;
+ }
+ // const member function pointer
+ {
+ void (A_void_1::*fp)() const = &A_void_1::mem2;
+ A_void_1 a;
+ std::bind(fp, _1)(a);
+ assert(count == save_count+2);
+ save_count = count;
+ A_void_1* ap = &a;
+ std::bind(fp, _1)(ap);
+ assert(count == save_count+2);
+ save_count = count;
+ }
+ {
+ void (A_void_1::*fp)() const = &A_void_1::mem2;
+ A_void_1 a;
+ std::bind(fp, a)();
+ assert(count == save_count+2);
+ save_count = count;
+ A_void_1* ap = &a;
+ std::bind(fp, ap)();
+ assert(count == save_count+2);
+ save_count = count;
+ }
+}
+
+// 1 arg, return int
+
+int f_int_1(int i)
+{
+ return i + 1;
+}
+
+struct A_int_1
+{
+ A_int_1() : data_(5) {}
+ int operator()(int i)
+ {
+ return i - 1;
+ }
+
+ int mem1() {return 3;}
+ int mem2() const {return 4;}
+ int data_;
+};
+
+void
+test_int_1()
+{
+ using namespace std::placeholders;
+ // function
+ {
+ int i = 2;
+ assert(std::bind(f_int_1, _1)(i) == 3);
+ assert(std::bind(f_int_1, i)() == 3);
+ }
+ // function pointer
+ {
+ int (*fp)(int) = f_int_1;
+ int i = 3;
+ assert(std::bind(fp, _1)(i) == 4);
+ assert(std::bind(fp, i)() == 4);
+ }
+ // functor
+ {
+ int i = 4;
+ assert(std::bind(A_int_1(), _1)(i) == 3);
+ assert(std::bind(A_int_1(), i)() == 3);
+ }
+ // member function pointer
+ {
+ A_int_1 a;
+ assert(std::bind(&A_int_1::mem1, _1)(a) == 3);
+ assert(std::bind(&A_int_1::mem1, a)() == 3);
+ A_int_1* ap = &a;
+ assert(std::bind(&A_int_1::mem1, _1)(ap) == 3);
+ assert(std::bind(&A_int_1::mem1, ap)() == 3);
+ }
+ // const member function pointer
+ {
+ A_int_1 a;
+ assert(std::bind(&A_int_1::mem2, _1)(A_int_1()) == 4);
+ assert(std::bind(&A_int_1::mem2, A_int_1())() == 4);
+ A_int_1* ap = &a;
+ assert(std::bind(&A_int_1::mem2, _1)(ap) == 4);
+ assert(std::bind(&A_int_1::mem2, ap)() == 4);
+ }
+ // member data pointer
+ {
+ A_int_1 a;
+ assert(std::bind(&A_int_1::data_, _1)(a) == 5);
+ assert(std::bind(&A_int_1::data_, a)() == 5);
+ A_int_1* ap = &a;
+ assert(std::bind(&A_int_1::data_, _1)(a) == 5);
+ std::bind(&A_int_1::data_, _1)(a) = 6;
+ assert(std::bind(&A_int_1::data_, _1)(a) == 6);
+ assert(std::bind(&A_int_1::data_, _1)(ap) == 6);
+ std::bind(&A_int_1::data_, _1)(ap) = 7;
+ assert(std::bind(&A_int_1::data_, _1)(ap) == 7);
+ }
+}
+
+// 2 arg, return void
+
+void f_void_2(int i, int j)
+{
+ count += i+j;
+}
+
+struct A_void_2
+{
+ void operator()(int i, int j)
+ {
+ count += i+j;
+ }
+
+ void mem1(int i) {count += i;}
+ void mem2(int i) const {count += i;}
+};
+
+void
+test_void_2()
+{
+ using namespace std::placeholders;
+ int save_count = count;
+ // function
+ {
+ int i = 2;
+ int j = 3;
+ std::bind(f_void_2, _1, _2)(i, j);
+ assert(count == save_count+5);
+ save_count = count;
+ std::bind(f_void_2, i, _1)(j);
+ assert(count == save_count+5);
+ save_count = count;
+ std::bind(f_void_2, i, j)();
+ assert(count == save_count+5);
+ save_count = count;
+ }
+ // member function pointer
+ {
+ int j = 3;
+ std::bind(&A_void_2::mem1, _1, _2)(A_void_2(), j);
+ assert(count == save_count+3);
+ save_count = count;
+ std::bind(&A_void_2::mem1, _2, _1)(j, A_void_2());
+ assert(count == save_count+3);
+ save_count = count;
+ }
+}
+
+struct TFENode
+{
+ bool foo(unsigned long long) const
+ {
+ return true;
+ }
+};
+
+void
+test3()
+{
+ using namespace std;
+ using namespace std::placeholders;
+ const auto f = bind(&TFENode::foo, _1, 0UL);
+ const TFENode n = TFENode{};
+ bool b = f(n);
+ assert(b);
+}
+
+int main()
+{
+ test_void_1();
+ test_int_1();
+ test_void_2();
+}
diff --git a/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_rvalue.pass.cpp b/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_rvalue.pass.cpp
new file mode 100644
index 000000000000..4913a510c36e
--- /dev/null
+++ b/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_rvalue.pass.cpp
@@ -0,0 +1,266 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template<CopyConstructible Fn, CopyConstructible... Types>
+// unspecified bind(Fn, Types...);
+// template<Returnable R, CopyConstructible Fn, CopyConstructible... Types>
+// unspecified bind(Fn, Types...);
+
+#include <stdio.h>
+
+#include <functional>
+#include <cassert>
+
+int count = 0;
+
+// 1 arg, return void
+
+void f_void_1(int i)
+{
+ count += i;
+}
+
+struct A_void_1
+{
+ void operator()(int i)
+ {
+ count += i;
+ }
+
+ void mem1() {++count;}
+ void mem2() const {count += 2;}
+};
+
+void
+test_void_1()
+{
+ using namespace std::placeholders;
+ int save_count = count;
+ // function
+ {
+ std::bind(f_void_1, _1)(2);
+ assert(count == save_count + 2);
+ save_count = count;
+ }
+ {
+ std::bind(f_void_1, 2)();
+ assert(count == save_count + 2);
+ save_count = count;
+ }
+ // function pointer
+ {
+ void (*fp)(int) = f_void_1;
+ std::bind(fp, _1)(3);
+ assert(count == save_count+3);
+ save_count = count;
+ }
+ {
+ void (*fp)(int) = f_void_1;
+ std::bind(fp, 3)();
+ assert(count == save_count+3);
+ save_count = count;
+ }
+ // functor
+ {
+ A_void_1 a0;
+ std::bind(a0, _1)(4);
+ assert(count == save_count+4);
+ save_count = count;
+ }
+ {
+ A_void_1 a0;
+ std::bind(a0, 4)();
+ assert(count == save_count+4);
+ save_count = count;
+ }
+ // member function pointer
+ {
+ void (A_void_1::*fp)() = &A_void_1::mem1;
+ std::bind(fp, _1)(A_void_1());
+ assert(count == save_count+1);
+ save_count = count;
+ A_void_1 a;
+ std::bind(fp, _1)(&a);
+ assert(count == save_count+1);
+ save_count = count;
+ }
+ {
+ void (A_void_1::*fp)() = &A_void_1::mem1;
+ std::bind(fp, A_void_1())();
+ assert(count == save_count+1);
+ save_count = count;
+ A_void_1 a;
+ std::bind(fp, &a)();
+ assert(count == save_count+1);
+ save_count = count;
+ }
+ // const member function pointer
+ {
+ void (A_void_1::*fp)() const = &A_void_1::mem2;
+ std::bind(fp, _1)(A_void_1());
+ assert(count == save_count+2);
+ save_count = count;
+ A_void_1 a;
+ std::bind(fp, _1)(&a);
+ assert(count == save_count+2);
+ save_count = count;
+ }
+ {
+ void (A_void_1::*fp)() const = &A_void_1::mem2;
+ std::bind(fp, A_void_1())();
+ assert(count == save_count+2);
+ save_count = count;
+ A_void_1 a;
+ std::bind(fp, &a)();
+ assert(count == save_count+2);
+ save_count = count;
+ }
+}
+
+// 1 arg, return int
+
+int f_int_1(int i)
+{
+ return i + 1;
+}
+
+struct A_int_1
+{
+ A_int_1() : data_(5) {}
+ int operator()(int i)
+ {
+ return i - 1;
+ }
+
+ int mem1() {return 3;}
+ int mem2() const {return 4;}
+ int data_;
+};
+
+void
+test_int_1()
+{
+ using namespace std::placeholders;
+ // function
+ {
+ assert(std::bind(f_int_1, _1)(2) == 3);
+ assert(std::bind(f_int_1, 2)() == 3);
+ }
+ // function pointer
+ {
+ int (*fp)(int) = f_int_1;
+ assert(std::bind(fp, _1)(3) == 4);
+ assert(std::bind(fp, 3)() == 4);
+ }
+ // functor
+ {
+ assert(std::bind(A_int_1(), _1)(4) == 3);
+ assert(std::bind(A_int_1(), 4)() == 3);
+ }
+ // member function pointer
+ {
+ assert(std::bind(&A_int_1::mem1, _1)(A_int_1()) == 3);
+ assert(std::bind(&A_int_1::mem1, A_int_1())() == 3);
+ A_int_1 a;
+ assert(std::bind(&A_int_1::mem1, _1)(&a) == 3);
+ assert(std::bind(&A_int_1::mem1, &a)() == 3);
+ }
+ // const member function pointer
+ {
+ assert(std::bind(&A_int_1::mem2, _1)(A_int_1()) == 4);
+ assert(std::bind(&A_int_1::mem2, A_int_1())() == 4);
+ A_int_1 a;
+ assert(std::bind(&A_int_1::mem2, _1)(&a) == 4);
+ assert(std::bind(&A_int_1::mem2, &a)() == 4);
+ }
+ // member data pointer
+ {
+ assert(std::bind(&A_int_1::data_, _1)(A_int_1()) == 5);
+ assert(std::bind(&A_int_1::data_, A_int_1())() == 5);
+ A_int_1 a;
+ assert(std::bind(&A_int_1::data_, _1)(a) == 5);
+ std::bind(&A_int_1::data_, _1)(a) = 6;
+ assert(std::bind(&A_int_1::data_, _1)(a) == 6);
+ assert(std::bind(&A_int_1::data_, _1)(&a) == 6);
+ std::bind(&A_int_1::data_, _1)(&a) = 7;
+ assert(std::bind(&A_int_1::data_, _1)(&a) == 7);
+ }
+}
+
+// 2 arg, return void
+
+void f_void_2(int i, int j)
+{
+ count += i+j;
+}
+
+struct A_void_2
+{
+ void operator()(int i, int j)
+ {
+ count += i+j;
+ }
+
+ void mem1(int i) {count += i;}
+ void mem2(int i) const {count += i;}
+};
+
+void
+test_void_2()
+{
+ using namespace std::placeholders;
+ int save_count = count;
+ // function
+ {
+ std::bind(f_void_2, _1, _2)(2, 3);
+ assert(count == save_count+5);
+ save_count = count;
+ std::bind(f_void_2, 2, _1)(3);
+ assert(count == save_count+5);
+ save_count = count;
+ std::bind(f_void_2, 2, 3)();
+ assert(count == save_count+5);
+ save_count = count;
+ }
+ // member function pointer
+ {
+ std::bind(&A_void_2::mem1, _1, _2)(A_void_2(), 3);
+ assert(count == save_count+3);
+ save_count = count;
+ std::bind(&A_void_2::mem1, _2, _1)(3, A_void_2());
+ assert(count == save_count+3);
+ save_count = count;
+ }
+}
+
+int f_nested(int i)
+{
+ return i+1;
+}
+
+int g_nested(int i)
+{
+ return i*10;
+}
+
+void test_nested()
+{
+ using namespace std::placeholders;
+ assert(std::bind(f_nested, std::bind(g_nested, _1))(3) == 31);
+}
+
+int main()
+{
+ test_void_1();
+ test_int_1();
+ test_void_2();
+ test_nested();
+}
diff --git a/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_void_0.pass.cpp b/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_void_0.pass.cpp
new file mode 100644
index 000000000000..b7874b77cf03
--- /dev/null
+++ b/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_void_0.pass.cpp
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template<CopyConstructible Fn, CopyConstructible... Types>
+// unspecified bind(Fn, Types...);
+// template<Returnable R, CopyConstructible Fn, CopyConstructible... Types>
+// unspecified bind(Fn, Types...);
+
+#include <functional>
+#include <cassert>
+
+int count = 0;
+
+template <class F>
+void
+test(F f)
+{
+ int save_count = count;
+ f();
+ assert(count == save_count + 1);
+}
+
+template <class F>
+void
+test_const(const F& f)
+{
+ int save_count = count;
+ f();
+ assert(count == save_count + 2);
+}
+
+void f() {++count;}
+
+int g() {++count; return 0;}
+
+struct A_void_0
+{
+ void operator()() {++count;}
+ void operator()() const {count += 2;}
+};
+
+struct A_int_0
+{
+ int operator()() {++count; return 4;}
+ int operator()() const {count += 2; return 5;}
+};
+
+int main()
+{
+ test(std::bind(f));
+ test(std::bind(&f));
+ test(std::bind(A_void_0()));
+ test_const(std::bind(A_void_0()));
+
+ test(std::bind<void>(f));
+ test(std::bind<void>(&f));
+ test(std::bind<void>(A_void_0()));
+ test_const(std::bind<void>(A_void_0()));
+
+ test(std::bind<void>(g));
+ test(std::bind<void>(&g));
+ test(std::bind<void>(A_int_0()));
+ test_const(std::bind<void>(A_int_0()));
+}
diff --git a/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/nested.pass.cpp b/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/nested.pass.cpp
new file mode 100644
index 000000000000..12720f7b550a
--- /dev/null
+++ b/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/nested.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template<CopyConstructible Fn, CopyConstructible... Types>
+// unspecified bind(Fn, Types...);
+// template<Returnable R, CopyConstructible Fn, CopyConstructible... Types>
+// unspecified bind(Fn, Types...);
+
+// http://llvm.org/bugs/show_bug.cgi?id=16343
+
+#include <cmath>
+#include <functional>
+#include <cassert>
+
+struct power
+{
+ template <typename T>
+ T
+ operator()(T a, T b)
+ {
+ return std::pow(a, b);
+ }
+};
+
+struct plus_one
+{
+ template <typename T>
+ T
+ operator()(T a)
+ {
+ return a + 1;
+ }
+};
+
+int
+main()
+{
+ using std::placeholders::_1;
+
+ auto g = std::bind(power(), 2, _1);
+ assert(g(5) == 32);
+ assert(std::bind(plus_one(), g)(5) == 33);
+}
diff --git a/test/std/utilities/function.objects/bind/func.bind/func.bind.isbind/is_bind_expression.pass.cpp b/test/std/utilities/function.objects/bind/func.bind/func.bind.isbind/is_bind_expression.pass.cpp
new file mode 100644
index 000000000000..7f8dd4a98d2b
--- /dev/null
+++ b/test/std/utilities/function.objects/bind/func.bind/func.bind.isbind/is_bind_expression.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template<class T> struct is_bind_expression
+
+#include <functional>
+
+template <bool Expected, class T>
+void
+test(const T&)
+{
+ static_assert(std::is_bind_expression<T>::value == Expected, "");
+}
+
+struct C {};
+
+int main()
+{
+ test<true>(std::bind(C()));
+ test<true>(std::bind(C(), std::placeholders::_2));
+ test<true>(std::bind<int>(C()));
+ test<false>(1);
+ test<false>(std::placeholders::_2);
+}
diff --git a/test/std/utilities/function.objects/bind/func.bind/func.bind.isbind/is_placeholder.pass.cpp b/test/std/utilities/function.objects/bind/func.bind/func.bind.isbind/is_placeholder.pass.cpp
new file mode 100644
index 000000000000..6a52bd1848e9
--- /dev/null
+++ b/test/std/utilities/function.objects/bind/func.bind/func.bind.isbind/is_placeholder.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// struct is_placeholder
+
+#include <functional>
+
+template <int Expected, class T>
+void
+test(const T&)
+{
+ static_assert(std::is_placeholder<T>::value == Expected, "");
+}
+
+struct C {};
+
+int main()
+{
+ test<1>(std::placeholders::_1);
+ test<2>(std::placeholders::_2);
+ test<3>(std::placeholders::_3);
+ test<4>(std::placeholders::_4);
+ test<5>(std::placeholders::_5);
+ test<6>(std::placeholders::_6);
+ test<7>(std::placeholders::_7);
+ test<8>(std::placeholders::_8);
+ test<9>(std::placeholders::_9);
+ test<10>(std::placeholders::_10);
+ test<0>(4);
+ test<0>(5.5);
+ test<0>('a');
+ test<0>(C());
+}
diff --git a/test/std/utilities/function.objects/bind/func.bind/func.bind.place/placeholders.pass.cpp b/test/std/utilities/function.objects/bind/func.bind/func.bind.place/placeholders.pass.cpp
new file mode 100644
index 000000000000..246186040c56
--- /dev/null
+++ b/test/std/utilities/function.objects/bind/func.bind/func.bind.place/placeholders.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// placeholders
+
+#include <functional>
+#include <type_traits>
+
+template <class T>
+void
+test(const T& t)
+{
+ // Test default constructible.
+ T t2;
+ ((void)t2);
+ // Test copy constructible.
+ T t3 = t;
+ ((void)t3);
+ static_assert(std::is_nothrow_copy_constructible<T>::value, "");
+ static_assert(std::is_nothrow_move_constructible<T>::value, "");
+}
+
+int main()
+{
+ test(std::placeholders::_1);
+ test(std::placeholders::_2);
+ test(std::placeholders::_3);
+ test(std::placeholders::_4);
+ test(std::placeholders::_5);
+ test(std::placeholders::_6);
+ test(std::placeholders::_7);
+ test(std::placeholders::_8);
+ test(std::placeholders::_9);
+ test(std::placeholders::_10);
+}
diff --git a/test/std/utilities/function.objects/bind/func.bind/nothing_to_do.pass.cpp b/test/std/utilities/function.objects/bind/func.bind/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/utilities/function.objects/bind/func.bind/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/utilities/function.objects/bind/nothing_to_do.pass.cpp b/test/std/utilities/function.objects/bind/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/utilities/function.objects/bind/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/utilities/function.objects/bitwise.operations/bit_and.pass.cpp b/test/std/utilities/function.objects/bitwise.operations/bit_and.pass.cpp
new file mode 100644
index 000000000000..c0135fad1982
--- /dev/null
+++ b/test/std/utilities/function.objects/bitwise.operations/bit_and.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// bit_and
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+ typedef std::bit_and<int> F;
+ const F f = F();
+ static_assert((std::is_same<int, F::first_argument_type>::value), "" );
+ static_assert((std::is_same<int, F::second_argument_type>::value), "" );
+ static_assert((std::is_same<int, F::result_type>::value), "" );
+ assert(f(0xEA95, 0xEA95) == 0xEA95);
+ assert(f(0xEA95, 0x58D3) == 0x4891);
+ assert(f(0x58D3, 0xEA95) == 0x4891);
+ assert(f(0x58D3, 0) == 0);
+ assert(f(0xFFFF, 0x58D3) == 0x58D3);
+#if _LIBCPP_STD_VER > 11
+ typedef std::bit_and<> F2;
+ const F2 f2 = F2();
+ assert(f2(0xEA95, 0xEA95) == 0xEA95);
+ assert(f2(0xEA95L, 0xEA95) == 0xEA95);
+ assert(f2(0xEA95, 0xEA95L) == 0xEA95);
+
+ assert(f2(0xEA95, 0x58D3) == 0x4891);
+ assert(f2(0xEA95L, 0x58D3) == 0x4891);
+ assert(f2(0xEA95, 0x58D3L) == 0x4891);
+
+ assert(f2(0x58D3, 0xEA95) == 0x4891);
+ assert(f2(0x58D3L, 0xEA95) == 0x4891);
+ assert(f2(0x58D3, 0xEA95L) == 0x4891);
+
+ assert(f2(0x58D3, 0) == 0);
+ assert(f2(0x58D3L, 0) == 0);
+ assert(f2(0x58D3, 0L) == 0);
+
+ assert(f2(0xFFFF, 0x58D3) == 0x58D3);
+ assert(f2(0xFFFFL, 0x58D3) == 0x58D3);
+ assert(f2(0xFFFF, 0x58D3L) == 0x58D3);
+
+ constexpr int foo = std::bit_and<int> () (0x58D3, 0xEA95);
+ static_assert ( foo == 0x4891, "" );
+
+ constexpr int bar = std::bit_and<> () (0x58D3L, 0xEA95);
+ static_assert ( bar == 0x4891, "" );
+#endif
+}
diff --git a/test/std/utilities/function.objects/bitwise.operations/bit_not.pass.cpp b/test/std/utilities/function.objects/bitwise.operations/bit_not.pass.cpp
new file mode 100644
index 000000000000..48800a366a81
--- /dev/null
+++ b/test/std/utilities/function.objects/bitwise.operations/bit_not.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// bit_not
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ typedef std::bit_not<int> F;
+ const F f = F();
+ static_assert((std::is_same<F::argument_type, int>::value), "" );
+ static_assert((std::is_same<F::result_type, int>::value), "" );
+ assert((f(0xEA95) & 0xFFFF ) == 0x156A);
+ assert((f(0x58D3) & 0xFFFF ) == 0xA72C);
+ assert((f(0) & 0xFFFF ) == 0xFFFF);
+ assert((f(0xFFFF) & 0xFFFF ) == 0);
+
+ typedef std::bit_not<> F2;
+ const F2 f2 = F2();
+ assert((f2(0xEA95) & 0xFFFF ) == 0x156A);
+ assert((f2(0xEA95L) & 0xFFFF ) == 0x156A);
+ assert((f2(0x58D3) & 0xFFFF ) == 0xA72C);
+ assert((f2(0x58D3L) & 0xFFFF ) == 0xA72C);
+ assert((f2(0) & 0xFFFF ) == 0xFFFF);
+ assert((f2(0L) & 0xFFFF ) == 0xFFFF);
+ assert((f2(0xFFFF) & 0xFFFF ) == 0);
+ assert((f2(0xFFFFL) & 0xFFFF ) == 0);
+
+ constexpr int foo = std::bit_not<int> () (0xEA95) & 0xFFFF;
+ static_assert ( foo == 0x156A, "" );
+
+ constexpr int bar = std::bit_not<> () (0xEA95) & 0xFFFF;
+ static_assert ( bar == 0x156A, "" );
+#endif
+}
diff --git a/test/std/utilities/function.objects/bitwise.operations/bit_or.pass.cpp b/test/std/utilities/function.objects/bitwise.operations/bit_or.pass.cpp
new file mode 100644
index 000000000000..cb33df3d84b7
--- /dev/null
+++ b/test/std/utilities/function.objects/bitwise.operations/bit_or.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// bit_or
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+ typedef std::bit_or<int> F;
+ const F f = F();
+ static_assert((std::is_same<int, F::first_argument_type>::value), "" );
+ static_assert((std::is_same<int, F::second_argument_type>::value), "" );
+ static_assert((std::is_same<int, F::result_type>::value), "" );
+ assert(f(0xEA95, 0xEA95) == 0xEA95);
+ assert(f(0xEA95, 0x58D3) == 0xFAD7);
+ assert(f(0x58D3, 0xEA95) == 0xFAD7);
+ assert(f(0x58D3, 0) == 0x58D3);
+ assert(f(0xFFFF, 0x58D3) == 0xFFFF);
+#if _LIBCPP_STD_VER > 11
+ typedef std::bit_or<> F2;
+ const F2 f2 = F2();
+ assert(f2(0xEA95, 0xEA95) == 0xEA95);
+ assert(f2(0xEA95L, 0xEA95) == 0xEA95);
+ assert(f2(0xEA95, 0xEA95L) == 0xEA95);
+
+ assert(f2(0xEA95, 0x58D3) == 0xFAD7);
+ assert(f2(0xEA95L, 0x58D3) == 0xFAD7);
+ assert(f2(0xEA95, 0x58D3L) == 0xFAD7);
+
+ assert(f2(0x58D3, 0xEA95) == 0xFAD7);
+ assert(f2(0x58D3L, 0xEA95) == 0xFAD7);
+ assert(f2(0x58D3, 0xEA95L) == 0xFAD7);
+
+ assert(f2(0x58D3, 0) == 0x58D3);
+ assert(f2(0x58D3L, 0) == 0x58D3);
+ assert(f2(0x58D3, 0L) == 0x58D3);
+
+ assert(f2(0xFFFF, 0x58D3) == 0xFFFF);
+ assert(f2(0xFFFFL, 0x58D3) == 0xFFFF);
+ assert(f2(0xFFFF, 0x58D3L) == 0xFFFF);
+
+ constexpr int foo = std::bit_or<int> () (0x58D3, 0xEA95);
+ static_assert ( foo == 0xFAD7, "" );
+
+ constexpr int bar = std::bit_or<> () (0x58D3L, 0xEA95);
+ static_assert ( bar == 0xFAD7, "" );
+#endif
+}
diff --git a/test/std/utilities/function.objects/bitwise.operations/bit_xor.pass.cpp b/test/std/utilities/function.objects/bitwise.operations/bit_xor.pass.cpp
new file mode 100644
index 000000000000..bbf2ce5baf1b
--- /dev/null
+++ b/test/std/utilities/function.objects/bitwise.operations/bit_xor.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// bit_xor
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::bit_xor<int> F;
+ const F f = F();
+ static_assert((std::is_same<int, F::first_argument_type>::value), "" );
+ static_assert((std::is_same<int, F::second_argument_type>::value), "" );
+ static_assert((std::is_same<int, F::result_type>::value), "" );
+ assert(f(0xEA95, 0xEA95) == 0);
+ assert(f(0xEA95, 0x58D3) == 0xB246);
+ assert(f(0x58D3, 0xEA95) == 0xB246);
+ assert(f(0x58D3, 0) == 0x58D3);
+ assert(f(0xFFFF, 0x58D3) == 0xA72C);
+ }
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::bit_xor<> F2;
+ const F2 f = F2();
+ assert(f(0xEA95, 0xEA95) == 0);
+ assert(f(0xEA95L, 0xEA95) == 0);
+ assert(f(0xEA95, 0xEA95L) == 0);
+
+ assert(f(0xEA95, 0x58D3) == 0xB246);
+ assert(f(0xEA95L, 0x58D3) == 0xB246);
+ assert(f(0xEA95, 0x58D3L) == 0xB246);
+
+ assert(f(0x58D3, 0xEA95) == 0xB246);
+ assert(f(0x58D3L, 0xEA95) == 0xB246);
+ assert(f(0x58D3, 0xEA95L) == 0xB246);
+
+ assert(f(0x58D3, 0) == 0x58D3);
+ assert(f(0x58D3L, 0) == 0x58D3);
+ assert(f(0x58D3, 0L) == 0x58D3);
+
+ assert(f(0xFFFF, 0x58D3) == 0xA72C);
+ assert(f(0xFFFFL, 0x58D3) == 0xA72C);
+ assert(f(0xFFFF, 0x58D3L) == 0xA72C);
+
+ constexpr int foo = std::bit_xor<int> () (0x58D3, 0xEA95);
+ static_assert ( foo == 0xB246, "" );
+
+ constexpr int bar = std::bit_xor<> () (0x58D3L, 0xEA95);
+ static_assert ( bar == 0xB246, "" );
+ }
+#endif
+}
diff --git a/test/std/utilities/function.objects/bitwise.operations/transparent.pass.cpp b/test/std/utilities/function.objects/bitwise.operations/transparent.pass.cpp
new file mode 100644
index 000000000000..9f8e15dd55fe
--- /dev/null
+++ b/test/std/utilities/function.objects/bitwise.operations/transparent.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <functional>
+#include <string>
+
+template <class _Tp>
+struct is_transparent
+{
+private:
+ struct __two {char __lx; char __lxx;};
+ template <class _Up> static __two __test(...);
+ template <class _Up> static char __test(typename _Up::is_transparent* = 0);
+public:
+ static const bool value = sizeof(__test<_Tp>(0)) == 1;
+};
+
+
+int main () {
+#if _LIBCPP_STD_VER > 11
+
+ static_assert ( !is_transparent<std::bit_and<int>>::value, "" );
+ static_assert ( !is_transparent<std::bit_and<std::string>>::value, "" );
+ static_assert ( is_transparent<std::bit_and<void>>::value, "" );
+ static_assert ( is_transparent<std::bit_and<>>::value, "" );
+
+ static_assert ( !is_transparent<std::bit_or<int>>::value, "" );
+ static_assert ( !is_transparent<std::bit_or<std::string>>::value, "" );
+ static_assert ( is_transparent<std::bit_or<void>>::value, "" );
+ static_assert ( is_transparent<std::bit_or<>>::value, "" );
+
+ static_assert ( !is_transparent<std::bit_xor<int>>::value, "" );
+ static_assert ( !is_transparent<std::bit_xor<std::string>>::value, "" );
+ static_assert ( is_transparent<std::bit_xor<void>>::value, "" );
+ static_assert ( is_transparent<std::bit_xor<>>::value, "" );
+
+ static_assert ( !is_transparent<std::bit_not<int>>::value, "" );
+ static_assert ( !is_transparent<std::bit_not<std::string>>::value, "" );
+ static_assert ( is_transparent<std::bit_not<void>>::value, "" );
+ static_assert ( is_transparent<std::bit_not<>>::value, "" );
+
+#endif
+
+ return 0;
+ }
diff --git a/test/std/utilities/function.objects/comparisons/equal_to.pass.cpp b/test/std/utilities/function.objects/comparisons/equal_to.pass.cpp
new file mode 100644
index 000000000000..60415ec75d60
--- /dev/null
+++ b/test/std/utilities/function.objects/comparisons/equal_to.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// equal_to
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+ typedef std::equal_to<int> F;
+ const F f = F();
+ static_assert((std::is_same<int, F::first_argument_type>::value), "" );
+ static_assert((std::is_same<int, F::second_argument_type>::value), "" );
+ static_assert((std::is_same<bool, F::result_type>::value), "" );
+ assert(f(36, 36));
+ assert(!f(36, 6));
+#if _LIBCPP_STD_VER > 11
+ typedef std::equal_to<> F2;
+ const F2 f2 = F2();
+ assert(f2(36, 36));
+ assert(!f2(36, 6));
+ assert(f2(36, 36.0));
+ assert(f2(36.0, 36L));
+
+ constexpr bool foo = std::equal_to<int> () (36, 36);
+ static_assert ( foo, "" );
+
+ constexpr bool bar = std::equal_to<> () (36.0, 36);
+ static_assert ( bar, "" );
+#endif
+}
diff --git a/test/std/utilities/function.objects/comparisons/greater.pass.cpp b/test/std/utilities/function.objects/comparisons/greater.pass.cpp
new file mode 100644
index 000000000000..164f09aa605c
--- /dev/null
+++ b/test/std/utilities/function.objects/comparisons/greater.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// greater
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+ typedef std::greater<int> F;
+ const F f = F();
+ static_assert((std::is_same<int, F::first_argument_type>::value), "" );
+ static_assert((std::is_same<int, F::second_argument_type>::value), "" );
+ static_assert((std::is_same<bool, F::result_type>::value), "" );
+ assert(!f(36, 36));
+ assert(f(36, 6));
+ assert(!f(6, 36));
+#if _LIBCPP_STD_VER > 11
+ typedef std::greater<> F2;
+ const F2 f2 = F2();
+ assert(!f2(36, 36));
+ assert(f2(36, 6));
+ assert(!f2(6, 36));
+ assert( f2(36, 6.0));
+ assert( f2(36.0, 6));
+ assert(!f2(6, 36.0));
+ assert(!f2(6.0, 36));
+
+ constexpr bool foo = std::greater<int> () (36, 36);
+ static_assert ( !foo, "" );
+
+ constexpr bool bar = std::greater<> () (36.0, 36);
+ static_assert ( !bar, "" );
+#endif
+}
diff --git a/test/std/utilities/function.objects/comparisons/greater_equal.pass.cpp b/test/std/utilities/function.objects/comparisons/greater_equal.pass.cpp
new file mode 100644
index 000000000000..e89c14e24625
--- /dev/null
+++ b/test/std/utilities/function.objects/comparisons/greater_equal.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// greater_equal
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+ typedef std::greater_equal<int> F;
+ const F f = F();
+ static_assert((std::is_same<int, F::first_argument_type>::value), "" );
+ static_assert((std::is_same<int, F::second_argument_type>::value), "" );
+ static_assert((std::is_same<bool, F::result_type>::value), "" );
+ assert(f(36, 36));
+ assert(f(36, 6));
+ assert(!f(6, 36));
+#if _LIBCPP_STD_VER > 11
+ typedef std::greater_equal<> F2;
+ const F2 f2 = F2();
+ assert(f2(36, 36));
+ assert(f2(36, 6));
+ assert(!f2(6, 36));
+ assert( f2(36, 6.0));
+ assert( f2(36.0, 6));
+ assert(!f2(6, 36.0));
+ assert(!f2(6.0, 36));
+
+ constexpr bool foo = std::greater_equal<int> () (36, 36);
+ static_assert ( foo, "" );
+
+ constexpr bool bar = std::greater_equal<> () (36.0, 36);
+ static_assert ( bar, "" );
+#endif
+}
diff --git a/test/std/utilities/function.objects/comparisons/less.pass.cpp b/test/std/utilities/function.objects/comparisons/less.pass.cpp
new file mode 100644
index 000000000000..74fe166a0cd9
--- /dev/null
+++ b/test/std/utilities/function.objects/comparisons/less.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// less
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+ typedef std::less<int> F;
+ const F f = F();
+ static_assert((std::is_same<int, F::first_argument_type>::value), "" );
+ static_assert((std::is_same<int, F::second_argument_type>::value), "" );
+ static_assert((std::is_same<bool, F::result_type>::value), "" );
+ assert(!f(36, 36));
+ assert(!f(36, 6));
+ assert(f(6, 36));
+#if _LIBCPP_STD_VER > 11
+ typedef std::less<> F2;
+ const F2 f2 = F2();
+ assert(!f2(36, 36));
+ assert(!f2(36, 6));
+ assert( f2(6, 36));
+ assert(!f2(36, 6.0));
+ assert(!f2(36.0, 6));
+ assert( f2(6, 36.0));
+ assert( f2(6.0, 36));
+
+ constexpr bool foo = std::less<int> () (36, 36);
+ static_assert ( !foo, "" );
+
+ constexpr bool bar = std::less<> () (36.0, 36);
+ static_assert ( !bar, "" );
+#endif
+}
diff --git a/test/std/utilities/function.objects/comparisons/less_equal.pass.cpp b/test/std/utilities/function.objects/comparisons/less_equal.pass.cpp
new file mode 100644
index 000000000000..e6ba1f7f8a21
--- /dev/null
+++ b/test/std/utilities/function.objects/comparisons/less_equal.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// less_equal
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+ typedef std::less_equal<int> F;
+ const F f = F();
+ static_assert((std::is_same<int, F::first_argument_type>::value), "" );
+ static_assert((std::is_same<int, F::second_argument_type>::value), "" );
+ static_assert((std::is_same<bool, F::result_type>::value), "" );
+ assert(f(36, 36));
+ assert(!f(36, 6));
+ assert(f(6, 36));
+#if _LIBCPP_STD_VER > 11
+ typedef std::less_equal<> F2;
+ const F2 f2 = F2();
+ assert( f2(36, 36));
+ assert(!f2(36, 6));
+ assert( f2(6, 36));
+ assert(!f2(36, 6.0));
+ assert(!f2(36.0, 6));
+ assert( f2(6, 36.0));
+ assert( f2(6.0, 36));
+
+ constexpr bool foo = std::less_equal<int> () (36, 36);
+ static_assert ( foo, "" );
+
+ constexpr bool bar = std::less_equal<> () (36.0, 36);
+ static_assert ( bar, "" );
+#endif
+}
diff --git a/test/std/utilities/function.objects/comparisons/not_equal_to.pass.cpp b/test/std/utilities/function.objects/comparisons/not_equal_to.pass.cpp
new file mode 100644
index 000000000000..3e710b3e0c70
--- /dev/null
+++ b/test/std/utilities/function.objects/comparisons/not_equal_to.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// not_equal_to
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+ typedef std::not_equal_to<int> F;
+ const F f = F();
+ static_assert((std::is_same<int, F::first_argument_type>::value), "" );
+ static_assert((std::is_same<int, F::second_argument_type>::value), "" );
+ static_assert((std::is_same<bool, F::result_type>::value), "" );
+ assert(!f(36, 36));
+ assert(f(36, 6));
+#if _LIBCPP_STD_VER > 11
+ typedef std::not_equal_to<> F2;
+ const F2 f2 = F2();
+ assert(!f2(36, 36));
+ assert( f2(36, 6));
+ assert( f2(36, 6.0));
+ assert( f2(36.0, 6));
+ assert(!f2(36.0, 36));
+ assert(!f2(36, 36.0));
+
+ constexpr bool foo = std::not_equal_to<int> () (36, 36);
+ static_assert ( !foo, "" );
+
+ constexpr bool bar = std::not_equal_to<> () (36.0, 36);
+ static_assert ( !bar, "" );
+#endif
+}
diff --git a/test/std/utilities/function.objects/comparisons/transparent.pass.cpp b/test/std/utilities/function.objects/comparisons/transparent.pass.cpp
new file mode 100644
index 000000000000..41ce4bcae65f
--- /dev/null
+++ b/test/std/utilities/function.objects/comparisons/transparent.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <functional>
+#include <string>
+
+template <class _Tp>
+struct is_transparent
+{
+private:
+ struct __two {char __lx; char __lxx;};
+ template <class _Up> static __two __test(...);
+ template <class _Up> static char __test(typename _Up::is_transparent* = 0);
+public:
+ static const bool value = sizeof(__test<_Tp>(0)) == 1;
+};
+
+
+int main () {
+#if _LIBCPP_STD_VER > 11
+
+ static_assert ( !is_transparent<std::less<int>>::value, "" );
+ static_assert ( !is_transparent<std::less<std::string>>::value, "" );
+ static_assert ( is_transparent<std::less<void>>::value, "" );
+ static_assert ( is_transparent<std::less<>>::value, "" );
+
+ static_assert ( !is_transparent<std::less_equal<int>>::value, "" );
+ static_assert ( !is_transparent<std::less_equal<std::string>>::value, "" );
+ static_assert ( is_transparent<std::less_equal<void>>::value, "" );
+ static_assert ( is_transparent<std::less_equal<>>::value, "" );
+
+ static_assert ( !is_transparent<std::equal_to<int>>::value, "" );
+ static_assert ( !is_transparent<std::equal_to<std::string>>::value, "" );
+ static_assert ( is_transparent<std::equal_to<void>>::value, "" );
+ static_assert ( is_transparent<std::equal_to<>>::value, "" );
+
+ static_assert ( !is_transparent<std::not_equal_to<int>>::value, "" );
+ static_assert ( !is_transparent<std::not_equal_to<std::string>>::value, "" );
+ static_assert ( is_transparent<std::not_equal_to<void>>::value, "" );
+ static_assert ( is_transparent<std::not_equal_to<>>::value, "" );
+
+ static_assert ( !is_transparent<std::greater<int>>::value, "" );
+ static_assert ( !is_transparent<std::greater<std::string>>::value, "" );
+ static_assert ( is_transparent<std::greater<void>>::value, "" );
+ static_assert ( is_transparent<std::greater<>>::value, "" );
+
+ static_assert ( !is_transparent<std::greater_equal<int>>::value, "" );
+ static_assert ( !is_transparent<std::greater_equal<std::string>>::value, "" );
+ static_assert ( is_transparent<std::greater_equal<void>>::value, "" );
+ static_assert ( is_transparent<std::greater_equal<>>::value, "" );
+
+#endif
+
+ return 0;
+ }
diff --git a/test/std/utilities/function.objects/func.def/nothing_to_do.pass.cpp b/test/std/utilities/function.objects/func.def/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/utilities/function.objects/func.def/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/utilities/function.objects/func.invoke/invoke.pass.cpp b/test/std/utilities/function.objects/func.invoke/invoke.pass.cpp
new file mode 100644
index 000000000000..4b9cc76f7e4f
--- /dev/null
+++ b/test/std/utilities/function.objects/func.invoke/invoke.pass.cpp
@@ -0,0 +1,268 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+// <functional>
+
+// template <class F, class ...Args>
+// result_of_t<F&&(Args&&...)> invoke(F&&, Args&&...);
+
+/// C++14 [func.def] 20.9.0
+/// (1) The following definitions apply to this Clause:
+/// (2) A call signature is the name of a return type followed by a parenthesized
+/// comma-separated list of zero or more argument types.
+/// (3) A callable type is a function object type (20.9) or a pointer to member.
+/// (4) A callable object is an object of a callable type.
+/// (5) A call wrapper type is a type that holds a callable object and supports
+/// a call operation that forwards to that object.
+/// (6) A call wrapper is an object of a call wrapper type.
+/// (7) A target object is the callable object held by a call wrapper.
+
+/// C++14 [func.require] 20.9.1
+///
+/// Define INVOKE (f, t1, t2, ..., tN) as follows:
+/// (1.1) - (t1.*f)(t2, ..., tN) when f is a pointer to a member function of a class T and t1 is an object of
+/// type T or a reference to an object of type T or a reference to an object of a type derived from T;
+/// (1.2) - ((*t1).*f)(t2, ..., tN) when f is a pointer to a member function of a class T and t1 is not one of
+/// the types described in the previous item;
+/// (1.3) - t1.*f when N == 1 and f is a pointer to member data of a class T and t1 is an object of type T or a
+/// reference to an object of type T or a reference to an object of a type derived from T;
+/// (1.4) - (*t1).*f when N == 1 and f is a pointer to member data of a class T and t1 is not one of the types
+/// described in the previous item;
+/// (1.5) - f(t1, t2, ..., tN) in all other cases.
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+struct NonCopyable {
+ NonCopyable() {}
+private:
+ NonCopyable(NonCopyable const&) = delete;
+ NonCopyable& operator=(NonCopyable const&) = delete;
+};
+
+struct TestClass {
+ explicit TestClass(int x) : data(x) {}
+
+ int& operator()(NonCopyable&&) & { return data; }
+ int const& operator()(NonCopyable&&) const & { return data; }
+ int volatile& operator()(NonCopyable&&) volatile & { return data; }
+ int const volatile& operator()(NonCopyable&&) const volatile & { return data; }
+
+ int&& operator()(NonCopyable&&) && { return std::move(data); }
+ int const&& operator()(NonCopyable&&) const && { return std::move(data); }
+ int volatile&& operator()(NonCopyable&&) volatile && { return std::move(data); }
+ int const volatile&& operator()(NonCopyable&&) const volatile && { return std::move(data); }
+
+ int data;
+private:
+ TestClass(TestClass const&) = delete;
+ TestClass& operator=(TestClass const&) = delete;
+};
+
+struct DerivedFromTestClass : public TestClass {
+ explicit DerivedFromTestClass(int x) : TestClass(x) {}
+};
+
+int& foo(NonCopyable&&) {
+ static int data = 42;
+ return data;
+}
+
+template <class Signature, class Expect, class Functor>
+void test_b12(Functor&& f) {
+ // Create the callable object.
+ typedef Signature TestClass::*ClassFunc;
+ ClassFunc func_ptr = &TestClass::operator();
+
+ // Create the dummy arg.
+ NonCopyable arg;
+
+ // Check that the deduced return type of invoke is what is expected.
+ typedef decltype(
+ std::invoke(func_ptr, std::forward<Functor>(f), std::move(arg))
+ ) DeducedReturnType;
+ static_assert((std::is_same<DeducedReturnType, Expect>::value), "");
+
+ // Check that result_of_t matches Expect.
+ typedef typename std::result_of<ClassFunc&&(Functor&&, NonCopyable&&)>::type
+ ResultOfReturnType;
+ static_assert((std::is_same<ResultOfReturnType, Expect>::value), "");
+
+ // Run invoke and check the return value.
+ DeducedReturnType ret =
+ std::invoke(func_ptr, std::forward<Functor>(f), std::move(arg));
+ assert(ret == 42);
+}
+
+template <class Expect, class Functor>
+void test_b34(Functor&& f) {
+ // Create the callable object.
+ typedef int TestClass::*ClassFunc;
+ ClassFunc func_ptr = &TestClass::data;
+
+ // Check that the deduced return type of invoke is what is expected.
+ typedef decltype(
+ std::invoke(func_ptr, std::forward<Functor>(f))
+ ) DeducedReturnType;
+ static_assert((std::is_same<DeducedReturnType, Expect>::value), "");
+
+ // Check that result_of_t matches Expect.
+ typedef typename std::result_of<ClassFunc&&(Functor&&)>::type
+ ResultOfReturnType;
+ static_assert((std::is_same<ResultOfReturnType, Expect>::value), "");
+
+ // Run invoke and check the return value.
+ DeducedReturnType ret =
+ std::invoke(func_ptr, std::forward<Functor>(f));
+ assert(ret == 42);
+}
+
+template <class Expect, class Functor>
+void test_b5(Functor&& f) {
+ NonCopyable arg;
+
+ // Check that the deduced return type of invoke is what is expected.
+ typedef decltype(
+ std::invoke(std::forward<Functor>(f), std::move(arg))
+ ) DeducedReturnType;
+ static_assert((std::is_same<DeducedReturnType, Expect>::value), "");
+
+ // Check that result_of_t matches Expect.
+ typedef typename std::result_of<Functor&&(NonCopyable&&)>::type
+ ResultOfReturnType;
+ static_assert((std::is_same<ResultOfReturnType, Expect>::value), "");
+
+ // Run invoke and check the return value.
+ DeducedReturnType ret = std::invoke(std::forward<Functor>(f), std::move(arg));
+ assert(ret == 42);
+}
+
+void bullet_one_two_tests() {
+ {
+ TestClass cl(42);
+ test_b12<int&(NonCopyable&&) &, int&>(cl);
+ test_b12<int const&(NonCopyable&&) const &, int const&>(cl);
+ test_b12<int volatile&(NonCopyable&&) volatile &, int volatile&>(cl);
+ test_b12<int const volatile&(NonCopyable&&) const volatile &, int const volatile&>(cl);
+
+ test_b12<int&&(NonCopyable&&) &&, int&&>(std::move(cl));
+ test_b12<int const&&(NonCopyable&&) const &&, int const&&>(std::move(cl));
+ test_b12<int volatile&&(NonCopyable&&) volatile &&, int volatile&&>(std::move(cl));
+ test_b12<int const volatile&&(NonCopyable&&) const volatile &&, int const volatile&&>(std::move(cl));
+ }
+ {
+ DerivedFromTestClass cl(42);
+ test_b12<int&(NonCopyable&&) &, int&>(cl);
+ test_b12<int const&(NonCopyable&&) const &, int const&>(cl);
+ test_b12<int volatile&(NonCopyable&&) volatile &, int volatile&>(cl);
+ test_b12<int const volatile&(NonCopyable&&) const volatile &, int const volatile&>(cl);
+
+ test_b12<int&&(NonCopyable&&) &&, int&&>(std::move(cl));
+ test_b12<int const&&(NonCopyable&&) const &&, int const&&>(std::move(cl));
+ test_b12<int volatile&&(NonCopyable&&) volatile &&, int volatile&&>(std::move(cl));
+ test_b12<int const volatile&&(NonCopyable&&) const volatile &&, int const volatile&&>(std::move(cl));
+ }
+ {
+ TestClass cl_obj(42);
+ TestClass *cl = &cl_obj;
+ test_b12<int&(NonCopyable&&) &, int&>(cl);
+ test_b12<int const&(NonCopyable&&) const &, int const&>(cl);
+ test_b12<int volatile&(NonCopyable&&) volatile &, int volatile&>(cl);
+ test_b12<int const volatile&(NonCopyable&&) const volatile &, int const volatile&>(cl);
+ }
+ {
+ DerivedFromTestClass cl_obj(42);
+ DerivedFromTestClass *cl = &cl_obj;
+ test_b12<int&(NonCopyable&&) &, int&>(cl);
+ test_b12<int const&(NonCopyable&&) const &, int const&>(cl);
+ test_b12<int volatile&(NonCopyable&&) volatile &, int volatile&>(cl);
+ test_b12<int const volatile&(NonCopyable&&) const volatile &, int const volatile&>(cl);
+ }
+}
+
+void bullet_three_four_tests() {
+ {
+ typedef TestClass Fn;
+ Fn cl(42);
+ test_b34<int&>(cl);
+ test_b34<int const&>(static_cast<Fn const&>(cl));
+ test_b34<int volatile&>(static_cast<Fn volatile&>(cl));
+ test_b34<int const volatile&>(static_cast<Fn const volatile &>(cl));
+
+ test_b34<int&&>(static_cast<Fn &&>(cl));
+ test_b34<int const&&>(static_cast<Fn const&&>(cl));
+ test_b34<int volatile&&>(static_cast<Fn volatile&&>(cl));
+ test_b34<int const volatile&&>(static_cast<Fn const volatile&&>(cl));
+ }
+ {
+ typedef DerivedFromTestClass Fn;
+ Fn cl(42);
+ test_b34<int&>(cl);
+ test_b34<int const&>(static_cast<Fn const&>(cl));
+ test_b34<int volatile&>(static_cast<Fn volatile&>(cl));
+ test_b34<int const volatile&>(static_cast<Fn const volatile &>(cl));
+
+ test_b34<int&&>(static_cast<Fn &&>(cl));
+ test_b34<int const&&>(static_cast<Fn const&&>(cl));
+ test_b34<int volatile&&>(static_cast<Fn volatile&&>(cl));
+ test_b34<int const volatile&&>(static_cast<Fn const volatile&&>(cl));
+ }
+ {
+ typedef TestClass Fn;
+ Fn cl_obj(42);
+ Fn* cl = &cl_obj;
+ test_b34<int&>(cl);
+ test_b34<int const&>(static_cast<Fn const*>(cl));
+ test_b34<int volatile&>(static_cast<Fn volatile*>(cl));
+ test_b34<int const volatile&>(static_cast<Fn const volatile *>(cl));
+ }
+ {
+ typedef DerivedFromTestClass Fn;
+ Fn cl_obj(42);
+ Fn* cl = &cl_obj;
+ test_b34<int&>(cl);
+ test_b34<int const&>(static_cast<Fn const*>(cl));
+ test_b34<int volatile&>(static_cast<Fn volatile*>(cl));
+ test_b34<int const volatile&>(static_cast<Fn const volatile *>(cl));
+ }
+}
+
+void bullet_five_tests() {
+ using FooType = int&(NonCopyable&&);
+ {
+ FooType& fn = foo;
+ test_b5<int &>(fn);
+ }
+ {
+ FooType* fn = foo;
+ test_b5<int &>(fn);
+ }
+ {
+ typedef TestClass Fn;
+ Fn cl(42);
+ test_b5<int&>(cl);
+ test_b5<int const&>(static_cast<Fn const&>(cl));
+ test_b5<int volatile&>(static_cast<Fn volatile&>(cl));
+ test_b5<int const volatile&>(static_cast<Fn const volatile &>(cl));
+
+ test_b5<int&&>(static_cast<Fn &&>(cl));
+ test_b5<int const&&>(static_cast<Fn const&&>(cl));
+ test_b5<int volatile&&>(static_cast<Fn volatile&&>(cl));
+ test_b5<int const volatile&&>(static_cast<Fn const volatile&&>(cl));
+ }
+}
+
+int main() {
+ bullet_one_two_tests();
+ bullet_three_four_tests();
+ bullet_five_tests();
+}
diff --git a/test/std/utilities/function.objects/func.memfn/member_data.fail.cpp b/test/std/utilities/function.objects/func.memfn/member_data.fail.cpp
new file mode 100644
index 000000000000..5e748c93b9e4
--- /dev/null
+++ b/test/std/utilities/function.objects/func.memfn/member_data.fail.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template<Returnable R, class T> unspecified mem_fn(R T::* pm);
+
+#include <functional>
+#include <cassert>
+
+struct A
+{
+ double data_;
+};
+
+template <class F>
+void
+test(F f)
+{
+ {
+ A a;
+ f(a) = 5;
+ assert(a.data_ == 5);
+ A* ap = &a;
+ f(ap) = 6;
+ assert(a.data_ == 6);
+ const A* cap = ap;
+ assert(f(cap) == f(ap));
+ f(cap) = 7;
+ }
+}
+
+int main()
+{
+ test(std::mem_fn(&A::data_));
+}
diff --git a/test/std/utilities/function.objects/func.memfn/member_data.pass.cpp b/test/std/utilities/function.objects/func.memfn/member_data.pass.cpp
new file mode 100644
index 000000000000..dff211c60573
--- /dev/null
+++ b/test/std/utilities/function.objects/func.memfn/member_data.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template<Returnable R, class T> unspecified mem_fn(R T::* pm);
+
+#include <functional>
+#include <cassert>
+
+struct A
+{
+ double data_;
+};
+
+template <class F>
+void
+test(F f)
+{
+ {
+ A a;
+ f(a) = 5;
+ assert(a.data_ == 5);
+ A* ap = &a;
+ f(ap) = 6;
+ assert(a.data_ == 6);
+ const A* cap = ap;
+ assert(f(cap) == f(ap));
+ const F& cf = f;
+ assert(cf(ap) == f(ap));
+ }
+}
+
+int main()
+{
+ test(std::mem_fn(&A::data_));
+}
diff --git a/test/std/utilities/function.objects/func.memfn/member_function.pass.cpp b/test/std/utilities/function.objects/func.memfn/member_function.pass.cpp
new file mode 100644
index 000000000000..4096bd814421
--- /dev/null
+++ b/test/std/utilities/function.objects/func.memfn/member_function.pass.cpp
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template<Returnable R, class T, CopyConstructible... Args>
+// unspecified mem_fn(R (T::* pm)(Args...));
+
+#include <functional>
+#include <cassert>
+
+struct A
+{
+ char test0() {return 'a';}
+ char test1(int) {return 'b';}
+ char test2(int, double) {return 'c';}
+};
+
+template <class F>
+void
+test0(F f)
+{
+ {
+ A a;
+ assert(f(a) == 'a');
+ A* ap = &a;
+ assert(f(ap) == 'a');
+ const F& cf = f;
+ assert(cf(ap) == 'a');
+ }
+}
+
+template <class F>
+void
+test1(F f)
+{
+ {
+ A a;
+ assert(f(a, 1) == 'b');
+ A* ap = &a;
+ assert(f(ap, 2) == 'b');
+ const F& cf = f;
+ assert(cf(ap, 2) == 'b');
+ }
+}
+
+template <class F>
+void
+test2(F f)
+{
+ {
+ A a;
+ assert(f(a, 1, 2) == 'c');
+ A* ap = &a;
+ assert(f(ap, 2, 3.5) == 'c');
+ const F& cf = f;
+ assert(cf(ap, 2, 3.5) == 'c');
+ }
+}
+
+int main()
+{
+ test0(std::mem_fn(&A::test0));
+ test1(std::mem_fn(&A::test1));
+ test2(std::mem_fn(&A::test2));
+}
diff --git a/test/std/utilities/function.objects/func.memfn/member_function_const.pass.cpp b/test/std/utilities/function.objects/func.memfn/member_function_const.pass.cpp
new file mode 100644
index 000000000000..be22443e9542
--- /dev/null
+++ b/test/std/utilities/function.objects/func.memfn/member_function_const.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template<Returnable R, class T, CopyConstructible... Args>
+// unspecified mem_fn(R (T::* pm)(Args...) const);
+
+#include <functional>
+#include <cassert>
+
+struct A
+{
+ char test0() const {return 'a';}
+ char test1(int) const {return 'b';}
+ char test2(int, double) const {return 'c';}
+};
+
+template <class F>
+void
+test0(F f)
+{
+ {
+ A a;
+ assert(f(a) == 'a');
+ A* ap = &a;
+ assert(f(ap) == 'a');
+ const A* cap = &a;
+ assert(f(cap) == 'a');
+ const F& cf = f;
+ assert(cf(ap) == 'a');
+ }
+}
+
+template <class F>
+void
+test1(F f)
+{
+ {
+ A a;
+ assert(f(a, 1) == 'b');
+ A* ap = &a;
+ assert(f(ap, 2) == 'b');
+ const A* cap = &a;
+ assert(f(cap, 2) == 'b');
+ const F& cf = f;
+ assert(cf(ap, 2) == 'b');
+ }
+}
+
+template <class F>
+void
+test2(F f)
+{
+ {
+ A a;
+ assert(f(a, 1, 2) == 'c');
+ A* ap = &a;
+ assert(f(ap, 2, 3.5) == 'c');
+ const A* cap = &a;
+ assert(f(cap, 2, 3.5) == 'c');
+ const F& cf = f;
+ assert(cf(ap, 2, 3.5) == 'c');
+ }
+}
+
+int main()
+{
+ test0(std::mem_fn(&A::test0));
+ test1(std::mem_fn(&A::test1));
+ test2(std::mem_fn(&A::test2));
+}
diff --git a/test/std/utilities/function.objects/func.memfn/member_function_const_volatile.pass.cpp b/test/std/utilities/function.objects/func.memfn/member_function_const_volatile.pass.cpp
new file mode 100644
index 000000000000..329ac16a86db
--- /dev/null
+++ b/test/std/utilities/function.objects/func.memfn/member_function_const_volatile.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template<Returnable R, class T, CopyConstructible... Args>
+// unspecified mem_fn(R (T::* pm)(Args...) const volatile);
+
+#include <functional>
+#include <cassert>
+
+struct A
+{
+ char test0() const volatile {return 'a';}
+ char test1(int) const volatile {return 'b';}
+ char test2(int, double) const volatile {return 'c';}
+};
+
+template <class F>
+void
+test0(F f)
+{
+ {
+ A a;
+ assert(f(a) == 'a');
+ A* ap = &a;
+ assert(f(ap) == 'a');
+ const volatile A* cap = &a;
+ assert(f(cap) == 'a');
+ const F& cf = f;
+ assert(cf(ap) == 'a');
+ }
+}
+
+template <class F>
+void
+test1(F f)
+{
+ {
+ A a;
+ assert(f(a, 1) == 'b');
+ A* ap = &a;
+ assert(f(ap, 2) == 'b');
+ const volatile A* cap = &a;
+ assert(f(cap, 2) == 'b');
+ const F& cf = f;
+ assert(cf(ap, 2) == 'b');
+ }
+}
+
+template <class F>
+void
+test2(F f)
+{
+ {
+ A a;
+ assert(f(a, 1, 2) == 'c');
+ A* ap = &a;
+ assert(f(ap, 2, 3.5) == 'c');
+ const volatile A* cap = &a;
+ assert(f(cap, 2, 3.5) == 'c');
+ const F& cf = f;
+ assert(cf(ap, 2, 3.5) == 'c');
+ }
+}
+
+int main()
+{
+ test0(std::mem_fn(&A::test0));
+ test1(std::mem_fn(&A::test1));
+ test2(std::mem_fn(&A::test2));
+}
diff --git a/test/std/utilities/function.objects/func.memfn/member_function_volatile.pass.cpp b/test/std/utilities/function.objects/func.memfn/member_function_volatile.pass.cpp
new file mode 100644
index 000000000000..743ded9944aa
--- /dev/null
+++ b/test/std/utilities/function.objects/func.memfn/member_function_volatile.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template<Returnable R, class T, CopyConstructible... Args>
+// unspecified mem_fn(R (T::* pm)(Args...) volatile);
+
+#include <functional>
+#include <cassert>
+
+struct A
+{
+ char test0() volatile {return 'a';}
+ char test1(int) volatile {return 'b';}
+ char test2(int, double) volatile {return 'c';}
+};
+
+template <class F>
+void
+test0(F f)
+{
+ {
+ A a;
+ assert(f(a) == 'a');
+ A* ap = &a;
+ assert(f(ap) == 'a');
+ volatile A* cap = &a;
+ assert(f(cap) == 'a');
+ const F& cf = f;
+ assert(cf(ap) == 'a');
+ }
+}
+
+template <class F>
+void
+test1(F f)
+{
+ {
+ A a;
+ assert(f(a, 1) == 'b');
+ A* ap = &a;
+ assert(f(ap, 2) == 'b');
+ volatile A* cap = &a;
+ assert(f(cap, 2) == 'b');
+ const F& cf = f;
+ assert(cf(ap, 2) == 'b');
+ }
+}
+
+template <class F>
+void
+test2(F f)
+{
+ {
+ A a;
+ assert(f(a, 1, 2) == 'c');
+ A* ap = &a;
+ assert(f(ap, 2, 3.5) == 'c');
+ volatile A* cap = &a;
+ assert(f(cap, 2, 3.5) == 'c');
+ const F& cf = f;
+ assert(cf(ap, 2, 3.5) == 'c');
+ }
+}
+
+int main()
+{
+ test0(std::mem_fn(&A::test0));
+ test1(std::mem_fn(&A::test1));
+ test2(std::mem_fn(&A::test2));
+}
diff --git a/test/std/utilities/function.objects/func.require/binary_function.pass.cpp b/test/std/utilities/function.objects/func.require/binary_function.pass.cpp
new file mode 100644
index 000000000000..fa7afb2e7b9c
--- /dev/null
+++ b/test/std/utilities/function.objects/func.require/binary_function.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// binary_function
+
+#include <functional>
+#include <type_traits>
+
+int main()
+{
+ typedef std::binary_function<int, short, bool> bf;
+ static_assert((std::is_same<bf::first_argument_type, int>::value), "");
+ static_assert((std::is_same<bf::second_argument_type, short>::value), "");
+ static_assert((std::is_same<bf::result_type, bool>::value), "");
+}
diff --git a/test/std/utilities/function.objects/func.require/invoke.pass.cpp b/test/std/utilities/function.objects/func.require/invoke.pass.cpp
new file mode 100644
index 000000000000..25681630a80c
--- /dev/null
+++ b/test/std/utilities/function.objects/func.require/invoke.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// [func.require]
+
+// INVOKE
+#if __cplusplus < 201103L
+int main () {} // no __invoke in C++03
+#else
+
+#include <type_traits>
+
+template <typename T, int N>
+struct Array
+{
+ typedef T type[N];
+};
+
+struct Type
+{
+ Array<char, 1>::type& f1();
+ Array<char, 2>::type& f2() const;
+
+ Array<char, 1>::type& g1() &;
+ Array<char, 2>::type& g2() const &;
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ Array<char, 3>::type& g3() &&;
+ Array<char, 4>::type& g4() const &&;
+#endif
+};
+
+int main()
+{
+ static_assert(sizeof(std::__invoke(&Type::f1, std::declval<Type >())) == 1, "");
+ static_assert(sizeof(std::__invoke(&Type::f2, std::declval<Type const >())) == 2, "");
+
+ static_assert(sizeof(std::__invoke(&Type::g1, std::declval<Type &>())) == 1, "");
+ static_assert(sizeof(std::__invoke(&Type::g2, std::declval<Type const &>())) == 2, "");
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ static_assert(sizeof(std::__invoke(&Type::g3, std::declval<Type &&>())) == 3, "");
+ static_assert(sizeof(std::__invoke(&Type::g4, std::declval<Type const&&>())) == 4, "");
+#endif
+}
+#endif
diff --git a/test/std/utilities/function.objects/func.require/unary_function.pass.cpp b/test/std/utilities/function.objects/func.require/unary_function.pass.cpp
new file mode 100644
index 000000000000..f14b2d3a2ce5
--- /dev/null
+++ b/test/std/utilities/function.objects/func.require/unary_function.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// unary_function
+
+#include <functional>
+#include <type_traits>
+
+int main()
+{
+ typedef std::unary_function<int, bool> uf;
+ static_assert((std::is_same<uf::argument_type, int>::value), "");
+ static_assert((std::is_same<uf::result_type, bool>::value), "");
+}
diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.badcall/bad_function_call.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.badcall/bad_function_call.pass.cpp
new file mode 100644
index 000000000000..357a3b48eae2
--- /dev/null
+++ b/test/std/utilities/function.objects/func.wrap/func.wrap.badcall/bad_function_call.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// Class bad_function_call
+
+// class bad_function_call
+// : public exception
+// {
+// public:
+// // 20.7.16.1.1, constructor:
+// bad_function_call();
+// };
+
+#include <functional>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_base_of<std::exception, std::bad_function_call>::value), "");
+}
diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.badcall/func.wrap.badcall.const/bad_function_call_ctor.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.badcall/func.wrap.badcall.const/bad_function_call_ctor.pass.cpp
new file mode 100644
index 000000000000..f5ab9487532f
--- /dev/null
+++ b/test/std/utilities/function.objects/func.wrap/func.wrap.badcall/func.wrap.badcall.const/bad_function_call_ctor.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// Class bad_function_call
+
+// bad_function_call();
+
+#include <functional>
+#include <type_traits>
+
+int main()
+{
+ std::bad_function_call ex;
+}
diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.alg/swap.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.alg/swap.pass.cpp
new file mode 100644
index 000000000000..58192c928d58
--- /dev/null
+++ b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.alg/swap.pass.cpp
@@ -0,0 +1,123 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// class function<R(ArgTypes...)>
+
+// template <MoveConstructible R, MoveConstructible ... ArgTypes>
+// void swap(function<R(ArgTypes...)>&, function<R(ArgTypes...)>&);
+
+
+#include <functional>
+#include <cstdlib>
+#include <cassert>
+
+#include "count_new.hpp"
+
+class A
+{
+ int data_[10];
+public:
+ static int count;
+
+ explicit A(int j)
+ {
+ ++count;
+ data_[0] = j;
+ }
+
+ A(const A& a)
+ {
+ ++count;
+ for (int i = 0; i < 10; ++i)
+ data_[i] = a.data_[i];
+ }
+
+ ~A() {--count;}
+
+ int operator()(int i) const
+ {
+ for (int j = 0; j < 10; ++j)
+ i += data_[j];
+ return i;
+ }
+
+ int id() const {return data_[0];}
+};
+
+int A::count = 0;
+
+int g(int) {return 0;}
+int h(int) {return 1;}
+
+int main()
+{
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ {
+ std::function<int(int)> f1 = A(1);
+ std::function<int(int)> f2 = A(2);
+ assert(A::count == 2);
+ assert(globalMemCounter.checkOutstandingNewEq(2));
+ assert(f1.target<A>()->id() == 1);
+ assert(f2.target<A>()->id() == 2);
+ swap(f1, f2);
+ assert(A::count == 2);
+ assert(globalMemCounter.checkOutstandingNewEq(2));
+ assert(f1.target<A>()->id() == 2);
+ assert(f2.target<A>()->id() == 1);
+ }
+ assert(A::count == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ {
+ std::function<int(int)> f1 = A(1);
+ std::function<int(int)> f2 = g;
+ assert(A::count == 1);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
+ assert(f1.target<A>()->id() == 1);
+ assert(*f2.target<int(*)(int)>() == g);
+ swap(f1, f2);
+ assert(A::count == 1);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
+ assert(*f1.target<int(*)(int)>() == g);
+ assert(f2.target<A>()->id() == 1);
+ }
+ assert(A::count == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ {
+ std::function<int(int)> f1 = g;
+ std::function<int(int)> f2 = A(1);
+ assert(A::count == 1);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
+ assert(*f1.target<int(*)(int)>() == g);
+ assert(f2.target<A>()->id() == 1);
+ swap(f1, f2);
+ assert(A::count == 1);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
+ assert(f1.target<A>()->id() == 1);
+ assert(*f2.target<int(*)(int)>() == g);
+ }
+ assert(A::count == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ {
+ std::function<int(int)> f1 = g;
+ std::function<int(int)> f2 = h;
+ assert(A::count == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ assert(*f1.target<int(*)(int)>() == g);
+ assert(*f2.target<int(*)(int)>() == h);
+ swap(f1, f2);
+ assert(A::count == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ assert(*f1.target<int(*)(int)>() == h);
+ assert(*f2.target<int(*)(int)>() == g);
+ }
+ assert(A::count == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+}
diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.cap/operator_bool.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.cap/operator_bool.pass.cpp
new file mode 100644
index 000000000000..829763f79d82
--- /dev/null
+++ b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.cap/operator_bool.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// class function<R(ArgTypes...)>
+
+// explicit operator bool() const
+
+#include <functional>
+#include <cassert>
+
+int g(int) {return 0;}
+
+int main()
+{
+ {
+ std::function<int(int)> f;
+ assert(!f);
+ f = g;
+ assert(f);
+ }
+}
diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F.pass.cpp
new file mode 100644
index 000000000000..cd86e4cbf8eb
--- /dev/null
+++ b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F.pass.cpp
@@ -0,0 +1,90 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// class function<R(ArgTypes...)>
+
+// function(nullptr_t);
+
+#include <functional>
+#include <cassert>
+
+#include "count_new.hpp"
+
+class A
+{
+ int data_[10];
+public:
+ static int count;
+
+ A()
+ {
+ ++count;
+ for (int i = 0; i < 10; ++i)
+ data_[i] = i;
+ }
+
+ A(const A&) {++count;}
+
+ ~A() {--count;}
+
+ int operator()(int i) const
+ {
+ for (int j = 0; j < 10; ++j)
+ i += data_[j];
+ return i;
+ }
+
+ int foo(int) const {return 1;}
+};
+
+int A::count = 0;
+
+int g(int) {return 0;}
+
+int main()
+{
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ {
+ std::function<int(int)> f = A();
+ assert(A::count == 1);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
+ assert(f.target<A>());
+ assert(f.target<int(*)(int)>() == 0);
+ }
+ assert(A::count == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ {
+ std::function<int(int)> f = g;
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ assert(f.target<int(*)(int)>());
+ assert(f.target<A>() == 0);
+ }
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ {
+ std::function<int(int)> f = (int (*)(int))0;
+ assert(!f);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ assert(f.target<int(*)(int)>() == 0);
+ assert(f.target<A>() == 0);
+ }
+ {
+ std::function<int(const A*, int)> f = &A::foo;
+ assert(f);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ assert(f.target<int (A::*)(int) const>() != 0);
+ }
+ {
+ std::function<void(int)> f(&g);
+ assert(f);
+ assert(f.target<int(*)(int)>() != 0);
+ f(1);
+ }
+}
diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_assign.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_assign.pass.cpp
new file mode 100644
index 000000000000..11716e7946b0
--- /dev/null
+++ b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_assign.pass.cpp
@@ -0,0 +1,98 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// class function<R(ArgTypes...)>
+
+// template<class F>
+// requires CopyConstructible<F> && Callable<F, ArgTypes..>
+// && Convertible<Callable<F, ArgTypes...>::result_type
+// operator=(F f);
+
+#include <functional>
+#include <cassert>
+
+#include "count_new.hpp"
+
+class A
+{
+ int data_[10];
+public:
+ static int count;
+
+ A()
+ {
+ ++count;
+ for (int i = 0; i < 10; ++i)
+ data_[i] = i;
+ }
+
+ A(const A&) {++count;}
+
+ ~A() {--count;}
+
+ int operator()(int i) const
+ {
+ for (int j = 0; j < 10; ++j)
+ i += data_[j];
+ return i;
+ }
+
+ int foo(int) const {return 1;}
+};
+
+int A::count = 0;
+
+int g(int) {return 0;}
+
+int main()
+{
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ {
+ std::function<int(int)> f;
+ f = A();
+ assert(A::count == 1);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
+ assert(f.target<A>());
+ assert(f.target<int(*)(int)>() == 0);
+ }
+ assert(A::count == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ {
+ std::function<int(int)> f;
+ f = g;
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ assert(f.target<int(*)(int)>());
+ assert(f.target<A>() == 0);
+ }
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ {
+ std::function<int(int)> f;
+ f = (int (*)(int))0;
+ assert(!f);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ assert(f.target<int(*)(int)>() == 0);
+ assert(f.target<A>() == 0);
+ }
+ {
+ std::function<int(const A*, int)> f;
+ f = &A::foo;
+ assert(f);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ assert(f.target<int (A::*)(int) const>() != 0);
+ }
+ {
+ std::function<void(int)> f;
+ f = &g;
+ assert(f);
+ assert(f.target<int(*)(int)>() != 0);
+ f(1);
+ }
+}
diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_incomplete.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_incomplete.pass.cpp
new file mode 100644
index 000000000000..c8f4178a26bd
--- /dev/null
+++ b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_incomplete.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// class function<R(ArgTypes...)>
+
+// template<class F> function(F);
+
+// Allow incomplete argument types in the __is_callable check
+
+#include <functional>
+
+struct X{
+ typedef std::function<void(X&)> callback_type;
+ virtual ~X() {}
+private:
+ callback_type _cb;
+};
+
+int main()
+{
+}
diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc.pass.cpp
new file mode 100644
index 000000000000..f97e34d3f2cb
--- /dev/null
+++ b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// class function<R(ArgTypes...)>
+
+// template<class A> function(allocator_arg_t, const A&);
+
+#include <functional>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::function<int(int)> f(std::allocator_arg, bare_allocator<int>());
+ assert(!f);
+ }
+}
diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_F.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_F.pass.cpp
new file mode 100644
index 000000000000..352ecfc602be
--- /dev/null
+++ b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_F.pass.cpp
@@ -0,0 +1,106 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// class function<R(ArgTypes...)>
+
+// template<class F, class A> function(allocator_arg_t, const A&, F);
+
+#include <functional>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "test_allocator.h"
+#include "count_new.hpp"
+#include "../function_types.h"
+
+class DummyClass {};
+
+template <class FuncType, class AllocType>
+void test_FunctionObject(AllocType& alloc)
+{
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ {
+ FunctionObject target;
+ assert(FunctionObject::count == 1);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ std::function<FuncType> f2(std::allocator_arg, alloc, target);
+ assert(FunctionObject::count == 2);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
+ assert(f2.template target<FunctionObject>());
+ assert(f2.template target<FuncType>() == 0);
+ assert(f2.template target<FuncType*>() == 0);
+ }
+ assert(FunctionObject::count == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+}
+
+
+template <class FuncType, class AllocType>
+void test_FreeFunction(AllocType& alloc)
+{
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ {
+ FuncType* target = &FreeFunction;
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ std::function<FuncType> f2(std::allocator_arg, alloc, target);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ assert(f2.template target<FuncType*>());
+ assert(*f2.template target<FuncType*>() == target);
+ assert(f2.template target<FuncType>() == 0);
+ assert(f2.template target<DummyClass>() == 0);
+ }
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+}
+
+template <class TargetType, class FuncType, class AllocType>
+void test_MemFunClass(AllocType& alloc)
+{
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ {
+ TargetType target = &MemFunClass::foo;
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ std::function<FuncType> f2(std::allocator_arg, alloc, target);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ assert(f2.template target<TargetType>());
+ assert(*f2.template target<TargetType>() == target);
+ assert(f2.template target<FuncType*>() == 0);
+ }
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+}
+
+template <class Alloc>
+void test_for_alloc(Alloc& alloc) {
+ test_FunctionObject<int()>(alloc);
+ test_FunctionObject<int(int)>(alloc);
+ test_FunctionObject<int(int, int)>(alloc);
+ test_FunctionObject<int(int, int, int)>(alloc);
+
+ test_FreeFunction<int()>(alloc);
+ test_FreeFunction<int(int)>(alloc);
+ test_FreeFunction<int(int, int)>(alloc);
+ test_FreeFunction<int(int, int, int)>(alloc);
+
+ test_MemFunClass<int(MemFunClass::*)() const, int(MemFunClass&)>(alloc);
+ test_MemFunClass<int(MemFunClass::*)(int) const, int(MemFunClass&, int)>(alloc);
+ test_MemFunClass<int(MemFunClass::*)(int, int) const, int(MemFunClass&, int, int)>(alloc);
+}
+
+int main()
+{
+ {
+ bare_allocator<DummyClass> bare_alloc;
+ test_for_alloc(bare_alloc);
+ }
+ {
+ non_default_test_allocator<DummyClass> non_default_alloc(42);
+ test_for_alloc(non_default_alloc);
+ }
+}
diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_function.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_function.pass.cpp
new file mode 100644
index 000000000000..371eb98de1a9
--- /dev/null
+++ b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_function.pass.cpp
@@ -0,0 +1,124 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// class function<R(ArgTypes...)>
+
+// template<class A> function(allocator_arg_t, const A&, const function&);
+
+
+#include <functional>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "test_allocator.h"
+#include "count_new.hpp"
+#include "../function_types.h"
+
+class DummyClass {};
+
+template <class FuncType, class AllocType>
+void test_FunctionObject(AllocType& alloc)
+{
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ {
+ // Construct function from FunctionObject.
+ std::function<FuncType> f = FunctionObject();
+ assert(FunctionObject::count == 1);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
+ assert(f.template target<FunctionObject>());
+ assert(f.template target<FuncType>() == 0);
+ assert(f.template target<FuncType*>() == 0);
+ // Copy function with allocator
+ std::function<FuncType> f2(std::allocator_arg, alloc, f);
+ assert(FunctionObject::count == 2);
+ assert(globalMemCounter.checkOutstandingNewEq(2));
+ assert(f2.template target<FunctionObject>());
+ assert(f2.template target<FuncType>() == 0);
+ assert(f2.template target<FuncType*>() == 0);
+ }
+ assert(FunctionObject::count == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+}
+
+template <class FuncType, class AllocType>
+void test_FreeFunction(AllocType& alloc)
+{
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ {
+ // Construct function from function pointer.
+ FuncType* target = &FreeFunction;
+ std::function<FuncType> f = target;
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ assert(f.template target<FuncType*>());
+ assert(*f.template target<FuncType*>() == target);
+ assert(f.template target<FuncType>() == 0);
+ // Copy function with allocator
+ std::function<FuncType> f2(std::allocator_arg, alloc, f);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ assert(f2.template target<FuncType*>());
+ assert(*f2.template target<FuncType*>() == target);
+ assert(f2.template target<FuncType>() == 0);
+ }
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+}
+
+template <class TargetType, class FuncType, class AllocType>
+void test_MemFunClass(AllocType& alloc)
+{
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ {
+ // Construct function from function pointer.
+ TargetType target = &MemFunClass::foo;
+ std::function<FuncType> f = target;
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ assert(f.template target<TargetType>());
+ assert(*f.template target<TargetType>() == target);
+ assert(f.template target<FuncType*>() == 0);
+ // Copy function with allocator
+ std::function<FuncType> f2(std::allocator_arg, alloc, f);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ assert(f2.template target<TargetType>());
+ assert(*f2.template target<TargetType>() == target);
+ assert(f2.template target<FuncType*>() == 0);
+ }
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+}
+
+template <class Alloc>
+void test_for_alloc(Alloc& alloc)
+{
+ // Large FunctionObject -- Allocation should occur
+ test_FunctionObject<int()>(alloc);
+ test_FunctionObject<int(int)>(alloc);
+ test_FunctionObject<int(int, int)>(alloc);
+ test_FunctionObject<int(int, int, int)>(alloc);
+ // Free function -- No allocation should occur
+ test_FreeFunction<int()>(alloc);
+ test_FreeFunction<int(int)>(alloc);
+ test_FreeFunction<int(int, int)>(alloc);
+ test_FreeFunction<int(int, int, int)>(alloc);
+ // Member function -- No allocation should occur.
+ test_MemFunClass<int(MemFunClass::*)() const, int(MemFunClass&)>(alloc);
+ test_MemFunClass<int(MemFunClass::*)(int) const, int(MemFunClass&, int)>(alloc);
+ test_MemFunClass<int(MemFunClass::*)(int, int) const, int(MemFunClass&, int, int)>(alloc);
+}
+
+int main()
+{
+ {
+ bare_allocator<DummyClass> alloc;
+ test_for_alloc(alloc);
+ }
+ {
+ non_default_test_allocator<DummyClass> alloc(42);
+ test_for_alloc(alloc);
+ }
+}
diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_nullptr.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_nullptr.pass.cpp
new file mode 100644
index 000000000000..2350f92f0f89
--- /dev/null
+++ b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_nullptr.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// class function<R(ArgTypes...)>
+
+// template<class A> function(allocator_arg_t, const A&, nullptr_t);
+
+#include <functional>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ std::function<int(int)> f(std::allocator_arg, bare_allocator<int>(), nullptr);
+ assert(!f);
+}
diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_rfunction.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_rfunction.pass.cpp
new file mode 100644
index 000000000000..aa6b743b5236
--- /dev/null
+++ b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_rfunction.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// class function<R(ArgTypes...)>
+
+// template<class A> function(allocator_arg_t, const A&, function&&);
+
+#include <functional>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "count_new.hpp"
+
+class A
+{
+ int data_[10];
+public:
+ static int count;
+
+ A()
+ {
+ ++count;
+ for (int i = 0; i < 10; ++i)
+ data_[i] = i;
+ }
+
+ A(const A&) {++count;}
+
+ ~A() {--count;}
+
+ int operator()(int i) const
+ {
+ for (int j = 0; j < 10; ++j)
+ i += data_[j];
+ return i;
+ }
+};
+
+int A::count = 0;
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ {
+ std::function<int(int)> f = A();
+ assert(A::count == 1);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
+ assert(f.target<A>());
+ assert(f.target<int(*)(int)>() == 0);
+ std::function<int(int)> f2(std::allocator_arg, bare_allocator<A>(), std::move(f));
+ assert(A::count == 1);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
+ assert(f2.target<A>());
+ assert(f2.target<int(*)(int)>() == 0);
+ assert(f.target<A>() == 0);
+ assert(f.target<int(*)(int)>() == 0);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy.pass.cpp
new file mode 100644
index 000000000000..f603da9dd131
--- /dev/null
+++ b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy.pass.cpp
@@ -0,0 +1,118 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// class function<R(ArgTypes...)>
+
+// function(const function& f);
+
+#include <functional>
+#include <cstdlib>
+#include <cassert>
+
+#include "count_new.hpp"
+
+class A
+{
+ int data_[10];
+public:
+ static int count;
+
+ A()
+ {
+ ++count;
+ for (int i = 0; i < 10; ++i)
+ data_[i] = i;
+ }
+
+ A(const A&) {++count;}
+
+ ~A() {--count;}
+
+ int operator()(int i) const
+ {
+ for (int j = 0; j < 10; ++j)
+ i += data_[j];
+ return i;
+ }
+};
+
+int A::count = 0;
+
+int g(int) {return 0;}
+
+int main()
+{
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ {
+ std::function<int(int)> f = A();
+ assert(A::count == 1);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
+ assert(f.target<A>());
+ assert(f.target<int(*)(int)>() == 0);
+ std::function<int(int)> f2 = f;
+ assert(A::count == 2);
+ assert(globalMemCounter.checkOutstandingNewEq(2));
+ assert(f2.target<A>());
+ assert(f2.target<int(*)(int)>() == 0);
+ }
+ assert(A::count == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ {
+ std::function<int(int)> f = g;
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ assert(f.target<int(*)(int)>());
+ assert(f.target<A>() == 0);
+ std::function<int(int)> f2 = f;
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ assert(f2.target<int(*)(int)>());
+ assert(f2.target<A>() == 0);
+ }
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ {
+ std::function<int(int)> f;
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ assert(f.target<int(*)(int)>() == 0);
+ assert(f.target<A>() == 0);
+ std::function<int(int)> f2 = f;
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ assert(f2.target<int(*)(int)>() == 0);
+ assert(f2.target<A>() == 0);
+ }
+ {
+ std::function<int(int)> f;
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ assert(f.target<int(*)(int)>() == 0);
+ assert(f.target<A>() == 0);
+ assert(!f);
+ std::function<long(int)> g = f;
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ assert(g.target<long(*)(int)>() == 0);
+ assert(g.target<A>() == 0);
+ assert(!g);
+ }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ {
+ std::function<int(int)> f = A();
+ assert(A::count == 1);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
+ assert(f.target<A>());
+ assert(f.target<int(*)(int)>() == 0);
+ std::function<int(int)> f2 = std::move(f);
+ assert(A::count == 1);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
+ assert(f2.target<A>());
+ assert(f2.target<int(*)(int)>() == 0);
+ assert(f.target<A>() == 0);
+ assert(f.target<int(*)(int)>() == 0);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy_assign.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy_assign.pass.cpp
new file mode 100644
index 000000000000..c91eaa2d5674
--- /dev/null
+++ b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy_assign.pass.cpp
@@ -0,0 +1,109 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// class function<R(ArgTypes...)>
+
+// function& operator=(const function& f);
+
+#include <functional>
+#include <cassert>
+
+#include "count_new.hpp"
+
+class A
+{
+ int data_[10];
+public:
+ static int count;
+
+ A()
+ {
+ ++count;
+ for (int i = 0; i < 10; ++i)
+ data_[i] = i;
+ }
+
+ A(const A&) {++count;}
+
+ ~A() {--count;}
+
+ int operator()(int i) const
+ {
+ for (int j = 0; j < 10; ++j)
+ i += data_[j];
+ return i;
+ }
+};
+
+int A::count = 0;
+
+int g(int) {return 0;}
+
+int main()
+{
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ {
+ std::function<int(int)> f = A();
+ assert(A::count == 1);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
+ assert(f.target<A>());
+ assert(f.target<int(*)(int)>() == 0);
+ std::function<int(int)> f2;
+ f2 = f;
+ assert(A::count == 2);
+ assert(globalMemCounter.checkOutstandingNewEq(2));
+ assert(f2.target<A>());
+ assert(f2.target<int(*)(int)>() == 0);
+ }
+ assert(A::count == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ {
+ std::function<int(int)> f = g;
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ assert(f.target<int(*)(int)>());
+ assert(f.target<A>() == 0);
+ std::function<int(int)> f2;
+ f2 = f;
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ assert(f2.target<int(*)(int)>());
+ assert(f2.target<A>() == 0);
+ }
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ {
+ std::function<int(int)> f;
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ assert(f.target<int(*)(int)>() == 0);
+ assert(f.target<A>() == 0);
+ std::function<int(int)> f2;
+ f2 = f;
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ assert(f2.target<int(*)(int)>() == 0);
+ assert(f2.target<A>() == 0);
+ }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ {
+ std::function<int(int)> f = A();
+ assert(A::count == 1);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
+ assert(f.target<A>());
+ assert(f.target<int(*)(int)>() == 0);
+ std::function<int(int)> f2;
+ f2 = std::move(f);
+ assert(A::count == 1);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
+ assert(f2.target<A>());
+ assert(f2.target<int(*)(int)>() == 0);
+ assert(f.target<A>() == 0);
+ assert(f.target<int(*)(int)>() == 0);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/default.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/default.pass.cpp
new file mode 100644
index 000000000000..83d61b6b2d89
--- /dev/null
+++ b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/default.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// class function<R(ArgTypes...)>
+
+// explicit function();
+
+#include <functional>
+#include <cassert>
+
+int main()
+{
+ std::function<int(int)> f;
+ assert(!f);
+}
diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/no-variadics.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/no-variadics.pass.cpp
new file mode 100644
index 000000000000..7099c45fab81
--- /dev/null
+++ b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/no-variadics.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// class function<R()>
+
+// template<class F> function(F);
+
+#define _LIBCPP_HAS_NO_VARIADICS
+#include <functional>
+#include <cassert>
+
+int main()
+{
+ std::function<void()> f(static_cast<void(*)()>(0));
+ assert(!f);
+}
diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/nullptr_t.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/nullptr_t.pass.cpp
new file mode 100644
index 000000000000..f0d6402d185e
--- /dev/null
+++ b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/nullptr_t.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// class function<R(ArgTypes...)>
+
+// function(nullptr_t);
+
+#include <functional>
+#include <cassert>
+
+int main()
+{
+ std::function<int(int)> f(nullptr);
+ assert(!f);
+}
diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/nullptr_t_assign.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/nullptr_t_assign.pass.cpp
new file mode 100644
index 000000000000..9b2482fb9d54
--- /dev/null
+++ b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/nullptr_t_assign.pass.cpp
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// class function<R(ArgTypes...)>
+
+// function& operator=(nullptr_t);
+
+#include <functional>
+#include <cassert>
+
+#include "count_new.hpp"
+
+class A
+{
+ int data_[10];
+public:
+ static int count;
+
+ A()
+ {
+ ++count;
+ for (int i = 0; i < 10; ++i)
+ data_[i] = i;
+ }
+
+ A(const A&) {++count;}
+
+ ~A() {--count;}
+
+ int operator()(int i) const
+ {
+ for (int j = 0; j < 10; ++j)
+ i += data_[j];
+ return i;
+ }
+};
+
+int A::count = 0;
+
+int g(int) {return 0;}
+
+int main()
+{
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ {
+ std::function<int(int)> f = A();
+ assert(A::count == 1);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
+ assert(f.target<A>());
+ f = nullptr;
+ assert(A::count == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ assert(f.target<A>() == 0);
+ }
+ {
+ std::function<int(int)> f = g;
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ assert(f.target<int(*)(int)>());
+ assert(f.target<A>() == 0);
+ f = nullptr;
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ assert(f.target<int(*)(int)>() == 0);
+ }
+}
diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke.fail.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke.fail.cpp
new file mode 100644
index 000000000000..6dcd2857452c
--- /dev/null
+++ b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke.fail.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// class function<R(ArgTypes...)>
+
+// R operator()(ArgTypes... args) const
+
+#include <functional>
+#include <cassert>
+
+// member data pointer: cv qualifiers should transfer from argument to return type
+
+struct A_int_1
+{
+ A_int_1() : data_(5) {}
+
+ int data_;
+};
+
+void
+test_int_1()
+{
+ // member data pointer
+ {
+ int A_int_1::*fp = &A_int_1::data_;
+ A_int_1 a;
+ std::function<int& (const A_int_1*)> r2(fp);
+ const A_int_1* ap = &a;
+ assert(r2(ap) == 6);
+ r2(ap) = 7;
+ assert(r2(ap) == 7);
+ }
+}
+
+int main()
+{
+ test_int_1();
+}
diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke.pass.cpp
new file mode 100644
index 000000000000..31b80c3323c1
--- /dev/null
+++ b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke.pass.cpp
@@ -0,0 +1,335 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// class function<R(ArgTypes...)>
+
+// R operator()(ArgTypes... args) const
+
+#include <functional>
+#include <cassert>
+
+int count = 0;
+
+// 1 arg, return void
+
+void f_void_1(int i)
+{
+ count += i;
+}
+
+struct A_void_1
+{
+ void operator()(int i)
+ {
+ count += i;
+ }
+
+ void mem1() {++count;}
+ void mem2() const {++count;}
+};
+
+void
+test_void_1()
+{
+ int save_count = count;
+ // function
+ {
+ std::function<void (int)> r1(f_void_1);
+ int i = 2;
+ r1(i);
+ assert(count == save_count+2);
+ save_count = count;
+ }
+ // function pointer
+ {
+ void (*fp)(int) = f_void_1;
+ std::function<void (int)> r1(fp);
+ int i = 3;
+ r1(i);
+ assert(count == save_count+3);
+ save_count = count;
+ }
+ // functor
+ {
+ A_void_1 a0;
+ std::function<void (int)> r1(a0);
+ int i = 4;
+ r1(i);
+ assert(count == save_count+4);
+ save_count = count;
+ }
+ // member function pointer
+ {
+ void (A_void_1::*fp)() = &A_void_1::mem1;
+ std::function<void (A_void_1)> r1(fp);
+ A_void_1 a;
+ r1(a);
+ assert(count == save_count+1);
+ save_count = count;
+ A_void_1* ap = &a;
+ std::function<void (A_void_1*)> r2 = fp;
+ r2(ap);
+ assert(count == save_count+1);
+ save_count = count;
+ }
+ // const member function pointer
+ {
+ void (A_void_1::*fp)() const = &A_void_1::mem2;
+ std::function<void (A_void_1)> r1(fp);
+ A_void_1 a;
+ r1(a);
+ assert(count == save_count+1);
+ save_count = count;
+ std::function<void (A_void_1*)> r2(fp);
+ A_void_1* ap = &a;
+ r2(ap);
+ assert(count == save_count+1);
+ save_count = count;
+ }
+}
+
+// 1 arg, return int
+
+int f_int_1(int i)
+{
+ return i + 1;
+}
+
+struct A_int_1
+{
+ A_int_1() : data_(5) {}
+ int operator()(int i)
+ {
+ return i - 1;
+ }
+
+ int mem1() {return 3;}
+ int mem2() const {return 4;}
+ int data_;
+};
+
+void
+test_int_1()
+{
+ // function
+ {
+ std::function<int (int)> r1(f_int_1);
+ int i = 2;
+ assert(r1(i) == 3);
+ }
+ // function pointer
+ {
+ int (*fp)(int) = f_int_1;
+ std::function<int (int)> r1(fp);
+ int i = 3;
+ assert(r1(i) == 4);
+ }
+ // functor
+ {
+ A_int_1 a0;
+ std::function<int (int)> r1(a0);
+ int i = 4;
+ assert(r1(i) == 3);
+ }
+ // member function pointer
+ {
+ int (A_int_1::*fp)() = &A_int_1::mem1;
+ std::function<int (A_int_1)> r1(fp);
+ A_int_1 a;
+ assert(r1(a) == 3);
+ std::function<int (A_int_1*)> r2(fp);
+ A_int_1* ap = &a;
+ assert(r2(ap) == 3);
+ }
+ // const member function pointer
+ {
+ int (A_int_1::*fp)() const = &A_int_1::mem2;
+ std::function<int (A_int_1)> r1(fp);
+ A_int_1 a;
+ assert(r1(a) == 4);
+ std::function<int (A_int_1*)> r2(fp);
+ A_int_1* ap = &a;
+ assert(r2(ap) == 4);
+ }
+ // member data pointer
+ {
+ int A_int_1::*fp = &A_int_1::data_;
+ std::function<int& (A_int_1&)> r1(fp);
+ A_int_1 a;
+ assert(r1(a) == 5);
+ r1(a) = 6;
+ assert(r1(a) == 6);
+ std::function<int& (A_int_1*)> r2(fp);
+ A_int_1* ap = &a;
+ assert(r2(ap) == 6);
+ r2(ap) = 7;
+ assert(r2(ap) == 7);
+ }
+}
+
+// 2 arg, return void
+
+void f_void_2(int i, int j)
+{
+ count += i+j;
+}
+
+struct A_void_2
+{
+ void operator()(int i, int j)
+ {
+ count += i+j;
+ }
+
+ void mem1(int i) {count += i;}
+ void mem2(int i) const {count += i;}
+};
+
+void
+test_void_2()
+{
+ int save_count = count;
+ // function
+ {
+ std::function<void (int, int)> r1(f_void_2);
+ int i = 2;
+ int j = 3;
+ r1(i, j);
+ assert(count == save_count+5);
+ save_count = count;
+ }
+ // function pointer
+ {
+ void (*fp)(int, int) = f_void_2;
+ std::function<void (int, int)> r1(fp);
+ int i = 3;
+ int j = 4;
+ r1(i, j);
+ assert(count == save_count+7);
+ save_count = count;
+ }
+ // functor
+ {
+ A_void_2 a0;
+ std::function<void (int, int)> r1(a0);
+ int i = 4;
+ int j = 5;
+ r1(i, j);
+ assert(count == save_count+9);
+ save_count = count;
+ }
+ // member function pointer
+ {
+ void (A_void_2::*fp)(int) = &A_void_2::mem1;
+ std::function<void (A_void_2, int)> r1(fp);
+ A_void_2 a;
+ int i = 3;
+ r1(a, i);
+ assert(count == save_count+3);
+ save_count = count;
+ std::function<void (A_void_2*, int)> r2(fp);
+ A_void_2* ap = &a;
+ r2(ap, i);
+ assert(count == save_count+3);
+ save_count = count;
+ }
+ // const member function pointer
+ {
+ void (A_void_2::*fp)(int) const = &A_void_2::mem2;
+ std::function<void (A_void_2, int)> r1(fp);
+ A_void_2 a;
+ int i = 4;
+ r1(a, i);
+ assert(count == save_count+4);
+ save_count = count;
+ std::function<void (A_void_2*, int)> r2(fp);
+ A_void_2* ap = &a;
+ r2(ap, i);
+ assert(count == save_count+4);
+ save_count = count;
+ }
+}
+
+// 2 arg, return int
+
+int f_int_2(int i, int j)
+{
+ return i+j;
+}
+
+struct A_int_2
+{
+ int operator()(int i, int j)
+ {
+ return i+j;
+ }
+
+ int mem1(int i) {return i+1;}
+ int mem2(int i) const {return i+2;}
+};
+
+void
+testint_2()
+{
+ // function
+ {
+ std::function<int (int, int)> r1(f_int_2);
+ int i = 2;
+ int j = 3;
+ assert(r1(i, j) == i+j);
+ }
+ // function pointer
+ {
+ int (*fp)(int, int) = f_int_2;
+ std::function<int (int, int)> r1(fp);
+ int i = 3;
+ int j = 4;
+ assert(r1(i, j) == i+j);
+ }
+ // functor
+ {
+ A_int_2 a0;
+ std::function<int (int, int)> r1(a0);
+ int i = 4;
+ int j = 5;
+ assert(r1(i, j) == i+j);
+ }
+ // member function pointer
+ {
+ int(A_int_2::*fp)(int) = &A_int_2::mem1;
+ std::function<int (A_int_2, int)> r1(fp);
+ A_int_2 a;
+ int i = 3;
+ assert(r1(a, i) == i+1);
+ std::function<int (A_int_2*, int)> r2(fp);
+ A_int_2* ap = &a;
+ assert(r2(ap, i) == i+1);
+ }
+ // const member function pointer
+ {
+ int (A_int_2::*fp)(int) const = &A_int_2::mem2;
+ std::function<int (A_int_2, int)> r1(fp);
+ A_int_2 a;
+ int i = 4;
+ assert(r1(a, i) == i+2);
+ std::function<int (A_int_2*, int)> r2(fp);
+ A_int_2* ap = &a;
+ assert(r2(ap, i) == i+2);
+ }
+}
+
+int main()
+{
+ test_void_1();
+ test_int_1();
+ test_void_2();
+ testint_2();
+}
diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke_int_0.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke_int_0.pass.cpp
new file mode 100644
index 000000000000..67b4ec22da8c
--- /dev/null
+++ b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke_int_0.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// class function<R(ArgTypes...)>
+
+// R operator()(ArgTypes... args) const
+
+#include <functional>
+#include <cassert>
+
+// 0 args, return int
+
+int count = 0;
+
+int f_int_0()
+{
+ return 3;
+}
+
+struct A_int_0
+{
+ int operator()() {return 4;}
+};
+
+void
+test_int_0()
+{
+ // function
+ {
+ std::function<int ()> r1(f_int_0);
+ assert(r1() == 3);
+ }
+ // function pointer
+ {
+ int (*fp)() = f_int_0;
+ std::function<int ()> r1(fp);
+ assert(r1() == 3);
+ }
+ // functor
+ {
+ A_int_0 a0;
+ std::function<int ()> r1(a0);
+ assert(r1() == 4);
+ }
+}
+
+int main()
+{
+ test_int_0();
+}
diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke_no_variadics.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke_no_variadics.pass.cpp
new file mode 100644
index 000000000000..c0a14fd96fcb
--- /dev/null
+++ b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke_no_variadics.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// class function<R()>
+
+// Test that we properly return both values and void for all non-variadic
+// overloads of function::operator()(...)
+
+#define _LIBCPP_HAS_NO_VARIADICS
+#include <functional>
+#include <cassert>
+
+int foo0() { return 42; }
+int foo1(int) { return 42; }
+int foo2(int, int) { return 42; }
+int foo3(int, int, int) { return 42; }
+
+int main()
+{
+ {
+ std::function<int()> f(&foo0);
+ assert(f() == 42);
+ }
+ {
+ std::function<int(int)> f(&foo1);
+ assert(f(1) == 42);
+ }
+ {
+ std::function<int(int, int)> f(&foo2);
+ assert(f(1, 1) == 42);
+ }
+ {
+ std::function<int(int, int, int)> f(&foo3);
+ assert(f(1, 1, 1) == 42);
+ }
+ {
+ std::function<void()> f(&foo0);
+ f();
+ }
+ {
+ std::function<void(int)> f(&foo1);
+ f(1);
+ }
+ {
+ std::function<void(int, int)> f(&foo2);
+ f(1, 1);
+ }
+ {
+ std::function<void(int, int, int)> f(&foo3);
+ f(1, 1, 1);
+ }
+}
diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke_void_0.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke_void_0.pass.cpp
new file mode 100644
index 000000000000..a820cb1b8f38
--- /dev/null
+++ b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke_void_0.pass.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// class function<R(ArgTypes...)>
+
+// R operator()(ArgTypes... args) const
+
+#include <functional>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+// 0 args, return void
+
+int count = 0;
+
+void f_void_0()
+{
+ ++count;
+}
+
+struct A_void_0
+{
+ void operator()() {++count;}
+};
+
+void
+test_void_0()
+{
+ int save_count = count;
+ // function
+ {
+ std::function<void ()> r1(f_void_0);
+ r1();
+ assert(count == save_count+1);
+ save_count = count;
+ }
+ // function pointer
+ {
+ void (*fp)() = f_void_0;
+ std::function<void ()> r1(fp);
+ r1();
+ assert(count == save_count+1);
+ save_count = count;
+ }
+ // functor
+ {
+ A_void_0 a0;
+ std::function<void ()> r1(a0);
+ r1();
+ assert(count == save_count+1);
+ save_count = count;
+ }
+}
+
+int main()
+{
+ test_void_0();
+}
diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.mod/assign_F_alloc.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.mod/assign_F_alloc.pass.cpp
new file mode 100644
index 000000000000..e9ecfa5539ce
--- /dev/null
+++ b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.mod/assign_F_alloc.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// class function<R(ArgTypes...)>
+
+// template<class F, class A> void assign(F&&, const A&);
+
+#include <functional>
+#include <cassert>
+
+#include "test_allocator.h"
+
+class A
+{
+ int data_[10];
+public:
+ static int count;
+
+ A()
+ {
+ ++count;
+ for (int i = 0; i < 10; ++i)
+ data_[i] = i;
+ }
+
+ A(const A&) {++count;}
+
+ ~A() {--count;}
+
+ int operator()(int i) const
+ {
+ for (int j = 0; j < 10; ++j)
+ i += data_[j];
+ return i;
+ }
+
+ int foo(int) const {return 1;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ std::function<int(int)> f;
+ f.assign(A(), test_allocator<A>());
+ assert(A::count == 1);
+ assert(f.target<A>());
+ assert(f.target<int(*)(int)>() == 0);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.mod/swap.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.mod/swap.pass.cpp
new file mode 100644
index 000000000000..f94e689b2a6b
--- /dev/null
+++ b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.mod/swap.pass.cpp
@@ -0,0 +1,120 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// class function<R(ArgTypes...)>
+
+// void swap(function& other);
+
+#include <functional>
+#include <cassert>
+
+#include "count_new.hpp"
+
+class A
+{
+ int data_[10];
+public:
+ static int count;
+
+ explicit A(int j)
+ {
+ ++count;
+ data_[0] = j;
+ }
+
+ A(const A& a)
+ {
+ ++count;
+ for (int i = 0; i < 10; ++i)
+ data_[i] = a.data_[i];
+ }
+
+ ~A() {--count;}
+
+ int operator()(int i) const
+ {
+ for (int j = 0; j < 10; ++j)
+ i += data_[j];
+ return i;
+ }
+
+ int id() const {return data_[0];}
+};
+
+int A::count = 0;
+
+int g(int) {return 0;}
+int h(int) {return 1;}
+
+int main()
+{
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ {
+ std::function<int(int)> f1 = A(1);
+ std::function<int(int)> f2 = A(2);
+ assert(A::count == 2);
+ assert(globalMemCounter.checkOutstandingNewEq(2));
+ assert(f1.target<A>()->id() == 1);
+ assert(f2.target<A>()->id() == 2);
+ f1.swap(f2);
+ assert(A::count == 2);
+ assert(globalMemCounter.checkOutstandingNewEq(2));
+ assert(f1.target<A>()->id() == 2);
+ assert(f2.target<A>()->id() == 1);
+ }
+ assert(A::count == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ {
+ std::function<int(int)> f1 = A(1);
+ std::function<int(int)> f2 = g;
+ assert(A::count == 1);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
+ assert(f1.target<A>()->id() == 1);
+ assert(*f2.target<int(*)(int)>() == g);
+ f1.swap(f2);
+ assert(A::count == 1);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
+ assert(*f1.target<int(*)(int)>() == g);
+ assert(f2.target<A>()->id() == 1);
+ }
+ assert(A::count == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ {
+ std::function<int(int)> f1 = g;
+ std::function<int(int)> f2 = A(1);
+ assert(A::count == 1);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
+ assert(*f1.target<int(*)(int)>() == g);
+ assert(f2.target<A>()->id() == 1);
+ f1.swap(f2);
+ assert(A::count == 1);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
+ assert(f1.target<A>()->id() == 1);
+ assert(*f2.target<int(*)(int)>() == g);
+ }
+ assert(A::count == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ {
+ std::function<int(int)> f1 = g;
+ std::function<int(int)> f2 = h;
+ assert(A::count == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ assert(*f1.target<int(*)(int)>() == g);
+ assert(*f2.target<int(*)(int)>() == h);
+ f1.swap(f2);
+ assert(A::count == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ assert(*f1.target<int(*)(int)>() == h);
+ assert(*f2.target<int(*)(int)>() == g);
+ }
+ assert(A::count == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+}
diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.nullptr/operator_==.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.nullptr/operator_==.pass.cpp
new file mode 100644
index 000000000000..5bca0968702c
--- /dev/null
+++ b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.nullptr/operator_==.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// class function<R(ArgTypes...)>
+
+// template <MoveConstructible R, MoveConstructible ... ArgTypes>
+// bool operator==(const function<R(ArgTypes...)>&, nullptr_t);
+//
+// template <MoveConstructible R, MoveConstructible ... ArgTypes>
+// bool operator==(nullptr_t, const function<R(ArgTypes...)>&);
+//
+// template <MoveConstructible R, MoveConstructible ... ArgTypes>
+// bool operator!=(const function<R(ArgTypes...)>&, nullptr_t);
+//
+// template <MoveConstructible R, MoveConstructible ... ArgTypes>
+// bool operator!=(nullptr_t, const function<R(ArgTypes...)>&);
+
+#include <functional>
+#include <cassert>
+
+int g(int) {return 0;}
+
+int main()
+{
+ {
+ std::function<int(int)> f;
+ assert(f == nullptr);
+ assert(nullptr == f);
+ f = g;
+ assert(f != nullptr);
+ assert(nullptr != f);
+ }
+}
diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.targ/target.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.targ/target.pass.cpp
new file mode 100644
index 000000000000..53476a274735
--- /dev/null
+++ b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.targ/target.pass.cpp
@@ -0,0 +1,89 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// class function<R(ArgTypes...)>
+
+// template<typename T>
+// requires Callable<T, ArgTypes...> && Convertible<Callable<T, ArgTypes...>::result_type, R>
+// T*
+// target();
+// template<typename T>
+// requires Callable<T, ArgTypes...> && Convertible<Callable<T, ArgTypes...>::result_type, R>
+// const T*
+// target() const;
+
+#include <functional>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+class A
+{
+ int data_[10];
+public:
+ static int count;
+
+ A()
+ {
+ ++count;
+ for (int i = 0; i < 10; ++i)
+ data_[i] = i;
+ }
+
+ A(const A&) {++count;}
+
+ ~A() {--count;}
+
+ int operator()(int i) const
+ {
+ for (int j = 0; j < 10; ++j)
+ i += data_[j];
+ return i;
+ }
+
+ int foo(int) const {return 1;}
+};
+
+int A::count = 0;
+
+int g(int) {return 0;}
+
+int main()
+{
+ {
+ std::function<int(int)> f = A();
+ assert(A::count == 1);
+ assert(f.target<A>());
+ assert(f.target<int(*)(int)>() == 0);
+ }
+ assert(A::count == 0);
+ {
+ std::function<int(int)> f = g;
+ assert(A::count == 0);
+ assert(f.target<int(*)(int)>());
+ assert(f.target<A>() == 0);
+ }
+ assert(A::count == 0);
+ {
+ const std::function<int(int)> f = A();
+ assert(A::count == 1);
+ assert(f.target<A>());
+ assert(f.target<int(*)(int)>() == 0);
+ }
+ assert(A::count == 0);
+ {
+ const std::function<int(int)> f = g;
+ assert(A::count == 0);
+ assert(f.target<int(*)(int)>());
+ assert(f.target<A>() == 0);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.targ/target_type.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.targ/target_type.pass.cpp
new file mode 100644
index 000000000000..7605e3bf666e
--- /dev/null
+++ b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.targ/target_type.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// class function<R(ArgTypes...)>
+
+// const std::type_info& target_type() const;
+
+#include <functional>
+#include <typeinfo>
+#include <cassert>
+
+class A
+{
+ int data_[10];
+public:
+ static int count;
+
+ A()
+ {
+ ++count;
+ for (int i = 0; i < 10; ++i)
+ data_[i] = i;
+ }
+
+ A(const A&) {++count;}
+
+ ~A() {--count;}
+
+ int operator()(int i) const
+ {
+ for (int j = 0; j < 10; ++j)
+ i += data_[j];
+ return i;
+ }
+
+ int foo(int) const {return 1;}
+};
+
+int A::count = 0;
+
+int g(int) {return 0;}
+
+int main()
+{
+ {
+ std::function<int(int)> f = A();
+ assert(f.target_type() == typeid(A));
+ }
+ {
+ std::function<int(int)> f;
+ assert(f.target_type() == typeid(void));
+ }
+}
diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/function_types.h b/test/std/utilities/function.objects/func.wrap/func.wrap.func/function_types.h
new file mode 100644
index 000000000000..55eb80f43ffe
--- /dev/null
+++ b/test/std/utilities/function.objects/func.wrap/func.wrap.func/function_types.h
@@ -0,0 +1,57 @@
+#ifndef FUNCTION_TYPES_H
+#define FUNCTION_TYPES_H
+
+
+class FunctionObject
+{
+ int data_[10]; // dummy variable to prevent small object optimization in
+ // std::function
+public:
+ static int count;
+
+ FunctionObject() {
+ ++count;
+ for (int i = 0; i < 10; ++i) data_[i] = i;
+ }
+
+ FunctionObject(const FunctionObject&) {++count;}
+ ~FunctionObject() {--count; ((void)data_); }
+
+ int operator()() const { return 42; }
+ int operator()(int i) const { return i; }
+ int operator()(int i, int) const { return i; }
+ int operator()(int i, int, int) const { return i; }
+};
+
+int FunctionObject::count = 0;
+
+class MemFunClass
+{
+ int data_[10]; // dummy variable to prevent small object optimization in
+ // std::function
+public:
+ static int count;
+
+ MemFunClass() {
+ ++count;
+ for (int i = 0; i < 10; ++i) data_[i] = 0;
+ }
+
+ MemFunClass(const MemFunClass&) {++count; ((void)data_); }
+
+ ~MemFunClass() {--count;}
+
+ int foo() const { return 42; }
+ int foo(int i) const { return i; }
+ int foo(int i, int) const { return i; }
+ int foo(int i, int, int) const { return i; }
+};
+
+int MemFunClass::count = 0;
+
+int FreeFunction() { return 42; }
+int FreeFunction(int i) {return i;}
+int FreeFunction(int i, int) { return i; }
+int FreeFunction(int i, int, int) { return i; }
+
+#endif // FUNCTION_TYPES_H
diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/types.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/types.pass.cpp
new file mode 100644
index 000000000000..eb4eac65cd2c
--- /dev/null
+++ b/test/std/utilities/function.objects/func.wrap/func.wrap.func/types.pass.cpp
@@ -0,0 +1,108 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template<Returnable R, CopyConstructible... ArgTypes>
+// class function<R(ArgTypes...)> {
+// public:
+// typedef R result_type;
+// typedef T1 argument_type; // iff sizeof...(ArgTypes) == 1 and
+// // the type in ArgTypes is T1
+// typedef T1 first_argument_type; // iff sizeof...(ArgTypes) == 2 and
+// // ArgTypes contains T1 and T2
+// typedef T2 second_argument_type; // iff sizeof...(ArgTypes) == 2 and
+// // ArgTypes contains T1 and T2
+// ...
+// };
+
+#include <functional>
+#include <type_traits>
+
+
+template <typename T>
+class has_argument_type
+{
+ typedef char yes;
+ typedef long no;
+
+ template <typename C> static yes check( typename C::argument_type * );
+ template <typename C> static no check(...);
+public:
+ enum { value = sizeof(check<T>(0)) == sizeof(yes) };
+};
+
+template <typename T>
+class has_first_argument_type
+{
+ typedef char yes;
+ typedef long no;
+
+ template <typename C> static yes check( typename C::first_argument_type * );
+ template <typename C> static no check(...);
+public:
+ enum { value = sizeof(check<T>(0)) == sizeof(yes) };
+};
+
+
+template <typename T>
+class has_second_argument_type
+{
+ typedef char yes;
+ typedef long no;
+
+ template <typename C> static yes check( typename C::second_argument_type *);
+ template <typename C> static no check(...);
+public:
+ enum { value = sizeof(check<T>(0)) == sizeof(yes) };
+};
+
+template <class F, class return_type>
+void test_nullary_function ()
+{
+ static_assert((std::is_same<typename F::result_type, return_type>::value), "" );
+ static_assert((!has_argument_type<F>::value), "" );
+ static_assert((!has_first_argument_type<F>::value), "" );
+ static_assert((!has_second_argument_type<F>::value), "" );
+}
+
+template <class F, class return_type, class arg_type>
+void test_unary_function ()
+{
+ static_assert((std::is_same<typename F::result_type, return_type>::value), "" );
+ static_assert((std::is_same<typename F::argument_type, arg_type>::value), "" );
+ static_assert((!has_first_argument_type<F>::value), "" );
+ static_assert((!has_second_argument_type<F>::value), "" );
+}
+
+template <class F, class return_type, class arg_type1, class arg_type2>
+void test_binary_function ()
+{
+ static_assert((std::is_same<typename F::result_type, return_type>::value), "" );
+ static_assert((std::is_same<typename F::first_argument_type, arg_type1>::value), "" );
+ static_assert((std::is_same<typename F::second_argument_type, arg_type2>::value), "" );
+ static_assert((!has_argument_type<F>::value), "" );
+}
+
+template <class F, class return_type>
+void test_other_function ()
+{
+ static_assert((std::is_same<typename F::result_type, return_type>::value), "" );
+ static_assert((!has_argument_type<F>::value), "" );
+ static_assert((!has_first_argument_type<F>::value), "" );
+ static_assert((!has_second_argument_type<F>::value), "" );
+}
+
+int main()
+{
+ test_nullary_function<std::function<int()>, int>();
+ test_unary_function <std::function<double(int)>, double, int>();
+ test_binary_function <std::function<double(int, char)>, double, int, char>();
+ test_other_function <std::function<double(int, char, double)>, double>();
+}
diff --git a/test/std/utilities/function.objects/func.wrap/nothing_to_do.pass.cpp b/test/std/utilities/function.objects/func.wrap/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/utilities/function.objects/func.wrap/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/utilities/function.objects/logical.operations/logical_and.pass.cpp b/test/std/utilities/function.objects/logical.operations/logical_and.pass.cpp
new file mode 100644
index 000000000000..72f9dc20144d
--- /dev/null
+++ b/test/std/utilities/function.objects/logical.operations/logical_and.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// logical_and
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+ typedef std::logical_and<int> F;
+ const F f = F();
+ static_assert((std::is_same<int, F::first_argument_type>::value), "" );
+ static_assert((std::is_same<int, F::second_argument_type>::value), "" );
+ static_assert((std::is_same<bool, F::result_type>::value), "" );
+ assert(f(36, 36));
+ assert(!f(36, 0));
+ assert(!f(0, 36));
+ assert(!f(0, 0));
+#if _LIBCPP_STD_VER > 11
+ typedef std::logical_and<> F2;
+ const F2 f2 = F2();
+ assert( f2(36, 36));
+ assert( f2(36, 36L));
+ assert( f2(36L, 36));
+ assert(!f2(36, 0));
+ assert(!f2(0, 36));
+ assert( f2(36, 36L));
+ assert(!f2(36, 0L));
+ assert(!f2(0, 36L));
+ assert( f2(36L, 36));
+ assert(!f2(36L, 0));
+ assert(!f2(0L, 36));
+
+ constexpr bool foo = std::logical_and<int> () (36, 36);
+ static_assert ( foo, "" );
+
+ constexpr bool bar = std::logical_and<> () (36.0, 36);
+ static_assert ( bar, "" );
+#endif
+}
diff --git a/test/std/utilities/function.objects/logical.operations/logical_not.pass.cpp b/test/std/utilities/function.objects/logical.operations/logical_not.pass.cpp
new file mode 100644
index 000000000000..8484625a727c
--- /dev/null
+++ b/test/std/utilities/function.objects/logical.operations/logical_not.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// logical_not
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+ typedef std::logical_not<int> F;
+ const F f = F();
+ static_assert((std::is_same<F::argument_type, int>::value), "" );
+ static_assert((std::is_same<F::result_type, bool>::value), "" );
+ assert(!f(36));
+ assert(f(0));
+#if _LIBCPP_STD_VER > 11
+ typedef std::logical_not<> F2;
+ const F2 f2 = F2();
+ assert(!f2(36));
+ assert( f2(0));
+ assert(!f2(36L));
+ assert( f2(0L));
+
+ constexpr bool foo = std::logical_not<int> () (36);
+ static_assert ( !foo, "" );
+
+ constexpr bool bar = std::logical_not<> () (36);
+ static_assert ( !bar, "" );
+#endif
+}
diff --git a/test/std/utilities/function.objects/logical.operations/logical_or.pass.cpp b/test/std/utilities/function.objects/logical.operations/logical_or.pass.cpp
new file mode 100644
index 000000000000..7280504403f4
--- /dev/null
+++ b/test/std/utilities/function.objects/logical.operations/logical_or.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// logical_or
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+ typedef std::logical_or<int> F;
+ const F f = F();
+ static_assert((std::is_same<int, F::first_argument_type>::value), "" );
+ static_assert((std::is_same<int, F::second_argument_type>::value), "" );
+ static_assert((std::is_same<bool, F::result_type>::value), "" );
+ assert(f(36, 36));
+ assert(f(36, 0));
+ assert(f(0, 36));
+ assert(!f(0, 0));
+#if _LIBCPP_STD_VER > 11
+ typedef std::logical_or<> F2;
+ const F2 f2 = F2();
+ assert( f2(36, 36));
+ assert( f2(36, 36L));
+ assert( f2(36L, 36));
+ assert( f2(36, 0));
+ assert( f2(0, 36));
+ assert( f2(36, 0L));
+ assert( f2(0, 36L));
+ assert(!f2(0, 0));
+ assert(!f2(0, 0L));
+ assert(!f2(0L, 0));
+
+ constexpr bool foo = std::logical_or<int> () (36, 36);
+ static_assert ( foo, "" );
+
+ constexpr bool bar = std::logical_or<> () (36.0, 36);
+ static_assert ( bar, "" );
+#endif
+}
diff --git a/test/std/utilities/function.objects/logical.operations/transparent.pass.cpp b/test/std/utilities/function.objects/logical.operations/transparent.pass.cpp
new file mode 100644
index 000000000000..6e3b7a2eee24
--- /dev/null
+++ b/test/std/utilities/function.objects/logical.operations/transparent.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <functional>
+#include <string>
+
+template <class _Tp>
+struct is_transparent
+{
+private:
+ struct __two {char __lx; char __lxx;};
+ template <class _Up> static __two __test(...);
+ template <class _Up> static char __test(typename _Up::is_transparent* = 0);
+public:
+ static const bool value = sizeof(__test<_Tp>(0)) == 1;
+};
+
+
+int main () {
+#if _LIBCPP_STD_VER > 11
+
+ static_assert ( !is_transparent<std::logical_and<int>>::value, "" );
+ static_assert ( !is_transparent<std::logical_and<std::string>>::value, "" );
+ static_assert ( is_transparent<std::logical_and<void>>::value, "" );
+ static_assert ( is_transparent<std::logical_and<>>::value, "" );
+
+ static_assert ( !is_transparent<std::logical_or<int>>::value, "" );
+ static_assert ( !is_transparent<std::logical_or<std::string>>::value, "" );
+ static_assert ( is_transparent<std::logical_or<void>>::value, "" );
+ static_assert ( is_transparent<std::logical_or<>>::value, "" );
+
+ static_assert ( !is_transparent<std::logical_not<int>>::value, "" );
+ static_assert ( !is_transparent<std::logical_not<std::string>>::value, "" );
+ static_assert ( is_transparent<std::logical_not<void>>::value, "" );
+ static_assert ( is_transparent<std::logical_not<>>::value, "" );
+
+#endif
+
+ return 0;
+ }
diff --git a/test/std/utilities/function.objects/negators/binary_negate.pass.cpp b/test/std/utilities/function.objects/negators/binary_negate.pass.cpp
new file mode 100644
index 000000000000..53ff5b47a3a0
--- /dev/null
+++ b/test/std/utilities/function.objects/negators/binary_negate.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// binary_negate
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+ typedef std::binary_negate<std::logical_and<int> > F;
+ const F f = F(std::logical_and<int>());
+ static_assert((std::is_same<int, F::first_argument_type>::value), "" );
+ static_assert((std::is_same<int, F::second_argument_type>::value), "" );
+ static_assert((std::is_same<bool, F::result_type>::value), "" );
+ assert(!f(36, 36));
+ assert( f(36, 0));
+ assert( f(0, 36));
+ assert( f(0, 0));
+}
diff --git a/test/std/utilities/function.objects/negators/not1.pass.cpp b/test/std/utilities/function.objects/negators/not1.pass.cpp
new file mode 100644
index 000000000000..f6ac7a49dc00
--- /dev/null
+++ b/test/std/utilities/function.objects/negators/not1.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// not1
+
+#include <functional>
+#include <cassert>
+
+int main()
+{
+ typedef std::logical_not<int> F;
+ assert(std::not1(F())(36));
+ assert(!std::not1(F())(0));
+}
diff --git a/test/std/utilities/function.objects/negators/not2.pass.cpp b/test/std/utilities/function.objects/negators/not2.pass.cpp
new file mode 100644
index 000000000000..7541753d568e
--- /dev/null
+++ b/test/std/utilities/function.objects/negators/not2.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// not2
+
+#include <functional>
+#include <cassert>
+
+int main()
+{
+ typedef std::logical_and<int> F;
+ assert(!std::not2(F())(36, 36));
+ assert( std::not2(F())(36, 0));
+ assert( std::not2(F())(0, 36));
+ assert( std::not2(F())(0, 0));
+}
diff --git a/test/std/utilities/function.objects/negators/unary_negate.pass.cpp b/test/std/utilities/function.objects/negators/unary_negate.pass.cpp
new file mode 100644
index 000000000000..e2498a3b52e2
--- /dev/null
+++ b/test/std/utilities/function.objects/negators/unary_negate.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// unary_negate
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+ typedef std::unary_negate<std::logical_not<int> > F;
+ const F f = F(std::logical_not<int>());
+ static_assert((std::is_same<F::argument_type, int>::value), "" );
+ static_assert((std::is_same<F::result_type, bool>::value), "" );
+ assert(f(36));
+ assert(!f(0));
+}
diff --git a/test/std/utilities/function.objects/refwrap/binary.pass.cpp b/test/std/utilities/function.objects/refwrap/binary.pass.cpp
new file mode 100644
index 000000000000..579e81fe69e6
--- /dev/null
+++ b/test/std/utilities/function.objects/refwrap/binary.pass.cpp
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// reference_wrapper
+
+// check for deriving from binary_function
+
+#include <functional>
+#include <type_traits>
+
+class functor1
+ : public std::unary_function<int, char>
+{
+};
+
+class functor2
+ : public std::binary_function<char, int, double>
+{
+};
+
+class functor3
+ : public std::unary_function<int, int>,
+ public std::binary_function<char, int, double>
+{
+public:
+ typedef float result_type;
+};
+
+class functor4
+ : public std::unary_function<int, int>,
+ public std::binary_function<char, int, double>
+{
+public:
+};
+
+struct C
+{
+ typedef int argument_type;
+ typedef int result_type;
+};
+
+int main()
+{
+ static_assert((!std::is_base_of<std::binary_function<int, char, int>,
+ std::reference_wrapper<functor1> >::value), "");
+ static_assert((std::is_base_of<std::binary_function<char, int, double>,
+ std::reference_wrapper<functor2> >::value), "");
+ static_assert((std::is_base_of<std::binary_function<char, int, double>,
+ std::reference_wrapper<functor3> >::value), "");
+ static_assert((std::is_base_of<std::binary_function<char, int, double>,
+ std::reference_wrapper<functor4> >::value), "");
+ static_assert((!std::is_base_of<std::binary_function<int, int, int>,
+ std::reference_wrapper<C> >::value), "");
+ static_assert((!std::is_base_of<std::binary_function<int, int, float>,
+ std::reference_wrapper<float ()> >::value), "");
+ static_assert((!std::is_base_of<std::binary_function<int, int, float>,
+ std::reference_wrapper<float (int)> >::value), "");
+ static_assert((std::is_base_of<std::binary_function<int, int, float>,
+ std::reference_wrapper<float (int, int)> >::value), "");
+ static_assert((!std::is_base_of<std::binary_function<int, int, float>,
+ std::reference_wrapper<float(*)()> >::value), "");
+ static_assert((!std::is_base_of<std::binary_function<int, int, float>,
+ std::reference_wrapper<float(*)(int)> >::value), "");
+ static_assert((std::is_base_of<std::binary_function<int, int, float>,
+ std::reference_wrapper<float(*)(int, int)> >::value), "");
+ static_assert((!std::is_base_of<std::binary_function<C*, int, float>,
+ std::reference_wrapper<float(C::*)()> >::value), "");
+ static_assert((std::is_base_of<std::binary_function<C*, int, float>,
+ std::reference_wrapper<float(C::*)(int)> >::value), "");
+ static_assert((std::is_base_of<std::binary_function<const volatile C*, int, float>,
+ std::reference_wrapper<float(C::*)(int) const volatile> >::value), "");
+}
diff --git a/test/std/utilities/function.objects/refwrap/refwrap.access/conversion.pass.cpp b/test/std/utilities/function.objects/refwrap/refwrap.access/conversion.pass.cpp
new file mode 100644
index 000000000000..df0b55a5d060
--- /dev/null
+++ b/test/std/utilities/function.objects/refwrap/refwrap.access/conversion.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// reference_wrapper
+
+// operator T& () const;
+
+#include <functional>
+#include <cassert>
+
+class functor1
+ : public std::unary_function<int, char>
+{
+};
+
+template <class T>
+void
+test(T& t)
+{
+ std::reference_wrapper<T> r(t);
+ T& r2 = r;
+ assert(&r2 == &t);
+}
+
+void f() {}
+
+int main()
+{
+ void (*fp)() = f;
+ test(fp);
+ test(f);
+ functor1 f1;
+ test(f1);
+ int i = 0;
+ test(i);
+ const int j = 0;
+ test(j);
+}
diff --git a/test/std/utilities/function.objects/refwrap/refwrap.assign/copy_assign.pass.cpp b/test/std/utilities/function.objects/refwrap/refwrap.assign/copy_assign.pass.cpp
new file mode 100644
index 000000000000..122716a23a8b
--- /dev/null
+++ b/test/std/utilities/function.objects/refwrap/refwrap.assign/copy_assign.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// reference_wrapper
+
+// reference_wrapper& operator=(const reference_wrapper<T>& x);
+
+#include <functional>
+#include <cassert>
+
+class functor1
+ : public std::unary_function<int, char>
+{
+};
+
+template <class T>
+void
+test(T& t)
+{
+ std::reference_wrapper<T> r(t);
+ T t2 = t;
+ std::reference_wrapper<T> r2(t2);
+ r2 = r;
+ assert(&r2.get() == &t);
+}
+
+void f() {}
+void g() {}
+
+void
+test_function()
+{
+ std::reference_wrapper<void ()> r(f);
+ std::reference_wrapper<void ()> r2(g);
+ r2 = r;
+ assert(&r2.get() == &f);
+}
+
+int main()
+{
+ void (*fp)() = f;
+ test(fp);
+ test_function();
+ functor1 f1;
+ test(f1);
+ int i = 0;
+ test(i);
+ const int j = 0;
+ test(j);
+}
diff --git a/test/std/utilities/function.objects/refwrap/refwrap.const/copy_ctor.pass.cpp b/test/std/utilities/function.objects/refwrap/refwrap.const/copy_ctor.pass.cpp
new file mode 100644
index 000000000000..721a442d4431
--- /dev/null
+++ b/test/std/utilities/function.objects/refwrap/refwrap.const/copy_ctor.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// reference_wrapper
+
+// reference_wrapper(const reference_wrapper<T>& x);
+
+#include <functional>
+#include <cassert>
+
+class functor1
+ : public std::unary_function<int, char>
+{
+};
+
+template <class T>
+void
+test(T& t)
+{
+ std::reference_wrapper<T> r(t);
+ std::reference_wrapper<T> r2 = r;
+ assert(&r2.get() == &t);
+}
+
+void f() {}
+
+int main()
+{
+ void (*fp)() = f;
+ test(fp);
+ test(f);
+ functor1 f1;
+ test(f1);
+ int i = 0;
+ test(i);
+ const int j = 0;
+ test(j);
+}
diff --git a/test/std/utilities/function.objects/refwrap/refwrap.const/type_ctor.fail.cpp b/test/std/utilities/function.objects/refwrap/refwrap.const/type_ctor.fail.cpp
new file mode 100644
index 000000000000..ba46946aae1b
--- /dev/null
+++ b/test/std/utilities/function.objects/refwrap/refwrap.const/type_ctor.fail.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// reference_wrapper
+
+// reference_wrapper(T&&) = delete;
+
+#include <functional>
+#include <cassert>
+
+int main()
+{
+ std::reference_wrapper<const int> r(3);
+}
diff --git a/test/std/utilities/function.objects/refwrap/refwrap.const/type_ctor.pass.cpp b/test/std/utilities/function.objects/refwrap/refwrap.const/type_ctor.pass.cpp
new file mode 100644
index 000000000000..564a3f77433c
--- /dev/null
+++ b/test/std/utilities/function.objects/refwrap/refwrap.const/type_ctor.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// reference_wrapper
+
+// reference_wrapper(T& t);
+
+#include <functional>
+#include <cassert>
+
+class functor1
+ : public std::unary_function<int, char>
+{
+};
+
+template <class T>
+void
+test(T& t)
+{
+ std::reference_wrapper<T> r(t);
+ assert(&r.get() == &t);
+}
+
+void f() {}
+
+int main()
+{
+ void (*fp)() = f;
+ test(fp);
+ test(f);
+ functor1 f1;
+ test(f1);
+ int i = 0;
+ test(i);
+ const int j = 0;
+ test(j);
+}
diff --git a/test/std/utilities/function.objects/refwrap/refwrap.helpers/cref_1.pass.cpp b/test/std/utilities/function.objects/refwrap/refwrap.helpers/cref_1.pass.cpp
new file mode 100644
index 000000000000..f2ffd44e26b7
--- /dev/null
+++ b/test/std/utilities/function.objects/refwrap/refwrap.helpers/cref_1.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// reference_wrapper
+
+// template <ObjectType T> reference_wrapper<const T> cref(const T& t);
+
+#include <functional>
+#include <cassert>
+
+int main()
+{
+ int i = 0;
+ std::reference_wrapper<const int> r = std::cref(i);
+ assert(&r.get() == &i);
+}
diff --git a/test/std/utilities/function.objects/refwrap/refwrap.helpers/cref_2.pass.cpp b/test/std/utilities/function.objects/refwrap/refwrap.helpers/cref_2.pass.cpp
new file mode 100644
index 000000000000..75875264479a
--- /dev/null
+++ b/test/std/utilities/function.objects/refwrap/refwrap.helpers/cref_2.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// reference_wrapper
+
+// template <ObjectType T> reference_wrapper<const T> cref(reference_wrapper<T> t);
+
+#include <functional>
+#include <cassert>
+
+int main()
+{
+ const int i = 0;
+ std::reference_wrapper<const int> r1 = std::cref(i);
+ std::reference_wrapper<const int> r2 = std::cref(r1);
+ assert(&r2.get() == &i);
+}
diff --git a/test/std/utilities/function.objects/refwrap/refwrap.helpers/ref_1.fail.cpp b/test/std/utilities/function.objects/refwrap/refwrap.helpers/ref_1.fail.cpp
new file mode 100644
index 000000000000..86a5696f48ca
--- /dev/null
+++ b/test/std/utilities/function.objects/refwrap/refwrap.helpers/ref_1.fail.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// reference_wrapper
+
+// template <ObjectType T> reference_wrapper<T> ref(T& t);
+
+// Don't allow binding to a temp
+
+#include <functional>
+
+struct A {};
+
+const A source() {return A();}
+
+int main()
+{
+ std::reference_wrapper<const A> r = std::ref(source());
+}
diff --git a/test/std/utilities/function.objects/refwrap/refwrap.helpers/ref_1.pass.cpp b/test/std/utilities/function.objects/refwrap/refwrap.helpers/ref_1.pass.cpp
new file mode 100644
index 000000000000..39aa4843a710
--- /dev/null
+++ b/test/std/utilities/function.objects/refwrap/refwrap.helpers/ref_1.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// reference_wrapper
+
+// template <ObjectType T> reference_wrapper<T> ref(T& t);
+
+#include <functional>
+#include <cassert>
+
+int main()
+{
+ int i = 0;
+ std::reference_wrapper<int> r = std::ref(i);
+ assert(&r.get() == &i);
+}
diff --git a/test/std/utilities/function.objects/refwrap/refwrap.helpers/ref_2.pass.cpp b/test/std/utilities/function.objects/refwrap/refwrap.helpers/ref_2.pass.cpp
new file mode 100644
index 000000000000..4033e676f018
--- /dev/null
+++ b/test/std/utilities/function.objects/refwrap/refwrap.helpers/ref_2.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// reference_wrapper
+
+// template <ObjectType T> reference_wrapper<T> ref(reference_wrapper<T>t);
+
+#include <functional>
+#include <cassert>
+
+#include "counting_predicates.hpp"
+
+bool is5 ( int i ) { return i == 5; }
+
+template <typename T>
+bool call_pred ( T pred ) { return pred(5); }
+
+int main()
+{
+ {
+ int i = 0;
+ std::reference_wrapper<int> r1 = std::ref(i);
+ std::reference_wrapper<int> r2 = std::ref(r1);
+ assert(&r2.get() == &i);
+ }
+ {
+ unary_counting_predicate<bool(*)(int), int> cp(is5);
+ assert(!cp(6));
+ assert(cp.count() == 1);
+ assert(call_pred(cp));
+ assert(cp.count() == 1);
+ assert(call_pred(std::ref(cp)));
+ assert(cp.count() == 2);
+ }
+}
diff --git a/test/std/utilities/function.objects/refwrap/refwrap.invoke/invoke.fail.cpp b/test/std/utilities/function.objects/refwrap/refwrap.invoke/invoke.fail.cpp
new file mode 100644
index 000000000000..551562721e3e
--- /dev/null
+++ b/test/std/utilities/function.objects/refwrap/refwrap.invoke/invoke.fail.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// reference_wrapper
+
+// template <class... ArgTypes>
+// requires Callable<T, ArgTypes&&...>
+// Callable<T, ArgTypes&&...>::result_type
+// operator()(ArgTypes&&... args) const;
+
+#include <functional>
+#include <cassert>
+
+// member data pointer: cv qualifiers should transfer from argument to return type
+
+struct A_int_1
+{
+ A_int_1() : data_(5) {}
+
+ int data_;
+};
+
+void
+test_int_1()
+{
+ // member data pointer
+ {
+ int A_int_1::*fp = &A_int_1::data_;
+ std::reference_wrapper<int A_int_1::*> r1(fp);
+ A_int_1 a;
+ assert(r1(a) == 5);
+ r1(a) = 6;
+ assert(r1(a) == 6);
+ const A_int_1* ap = &a;
+ assert(r1(ap) == 6);
+ r1(ap) = 7;
+ assert(r1(ap) == 7);
+ }
+}
+
+int main()
+{
+ test_int_1();
+}
diff --git a/test/std/utilities/function.objects/refwrap/refwrap.invoke/invoke.pass.cpp b/test/std/utilities/function.objects/refwrap/refwrap.invoke/invoke.pass.cpp
new file mode 100644
index 000000000000..a9edf00ee592
--- /dev/null
+++ b/test/std/utilities/function.objects/refwrap/refwrap.invoke/invoke.pass.cpp
@@ -0,0 +1,329 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// reference_wrapper
+
+// template <class... ArgTypes>
+// requires Callable<T, ArgTypes&&...>
+// Callable<T, ArgTypes&&...>::result_type
+// operator()(ArgTypes&&... args) const;
+
+#include <functional>
+#include <cassert>
+
+int count = 0;
+
+// 1 arg, return void
+
+void f_void_1(int i)
+{
+ count += i;
+}
+
+struct A_void_1
+{
+ void operator()(int i)
+ {
+ count += i;
+ }
+
+ void mem1() {++count;}
+ void mem2() const {++count;}
+};
+
+void
+test_void_1()
+{
+ int save_count = count;
+ // function
+ {
+ std::reference_wrapper<void (int)> r1(f_void_1);
+ int i = 2;
+ r1(i);
+ assert(count == save_count+2);
+ save_count = count;
+ }
+ // function pointer
+ {
+ void (*fp)(int) = f_void_1;
+ std::reference_wrapper<void (*)(int)> r1(fp);
+ int i = 3;
+ r1(i);
+ assert(count == save_count+3);
+ save_count = count;
+ }
+ // functor
+ {
+ A_void_1 a0;
+ std::reference_wrapper<A_void_1> r1(a0);
+ int i = 4;
+ r1(i);
+ assert(count == save_count+4);
+ save_count = count;
+ }
+ // member function pointer
+ {
+ void (A_void_1::*fp)() = &A_void_1::mem1;
+ std::reference_wrapper<void (A_void_1::*)()> r1(fp);
+ A_void_1 a;
+ r1(a);
+ assert(count == save_count+1);
+ save_count = count;
+ A_void_1* ap = &a;
+ r1(ap);
+ assert(count == save_count+1);
+ save_count = count;
+ }
+ // const member function pointer
+ {
+ void (A_void_1::*fp)() const = &A_void_1::mem2;
+ std::reference_wrapper<void (A_void_1::*)() const> r1(fp);
+ A_void_1 a;
+ r1(a);
+ assert(count == save_count+1);
+ save_count = count;
+ A_void_1* ap = &a;
+ r1(ap);
+ assert(count == save_count+1);
+ save_count = count;
+ }
+}
+
+// 1 arg, return int
+
+int f_int_1(int i)
+{
+ return i + 1;
+}
+
+struct A_int_1
+{
+ A_int_1() : data_(5) {}
+ int operator()(int i)
+ {
+ return i - 1;
+ }
+
+ int mem1() {return 3;}
+ int mem2() const {return 4;}
+ int data_;
+};
+
+void
+test_int_1()
+{
+ // function
+ {
+ std::reference_wrapper<int (int)> r1(f_int_1);
+ int i = 2;
+ assert(r1(i) == 3);
+ }
+ // function pointer
+ {
+ int (*fp)(int) = f_int_1;
+ std::reference_wrapper<int (*)(int)> r1(fp);
+ int i = 3;
+ assert(r1(i) == 4);
+ }
+ // functor
+ {
+ A_int_1 a0;
+ std::reference_wrapper<A_int_1> r1(a0);
+ int i = 4;
+ assert(r1(i) == 3);
+ }
+ // member function pointer
+ {
+ int (A_int_1::*fp)() = &A_int_1::mem1;
+ std::reference_wrapper<int (A_int_1::*)()> r1(fp);
+ A_int_1 a;
+ assert(r1(a) == 3);
+ A_int_1* ap = &a;
+ assert(r1(ap) == 3);
+ }
+ // const member function pointer
+ {
+ int (A_int_1::*fp)() const = &A_int_1::mem2;
+ std::reference_wrapper<int (A_int_1::*)() const> r1(fp);
+ A_int_1 a;
+ assert(r1(a) == 4);
+ A_int_1* ap = &a;
+ assert(r1(ap) == 4);
+ }
+ // member data pointer
+ {
+ int A_int_1::*fp = &A_int_1::data_;
+ std::reference_wrapper<int A_int_1::*> r1(fp);
+ A_int_1 a;
+ assert(r1(a) == 5);
+ r1(a) = 6;
+ assert(r1(a) == 6);
+ A_int_1* ap = &a;
+ assert(r1(ap) == 6);
+ r1(ap) = 7;
+ assert(r1(ap) == 7);
+ }
+}
+
+// 2 arg, return void
+
+void f_void_2(int i, int j)
+{
+ count += i+j;
+}
+
+struct A_void_2
+{
+ void operator()(int i, int j)
+ {
+ count += i+j;
+ }
+
+ void mem1(int i) {count += i;}
+ void mem2(int i) const {count += i;}
+};
+
+void
+test_void_2()
+{
+ int save_count = count;
+ // function
+ {
+ std::reference_wrapper<void (int, int)> r1(f_void_2);
+ int i = 2;
+ int j = 3;
+ r1(i, j);
+ assert(count == save_count+5);
+ save_count = count;
+ }
+ // function pointer
+ {
+ void (*fp)(int, int) = f_void_2;
+ std::reference_wrapper<void (*)(int, int)> r1(fp);
+ int i = 3;
+ int j = 4;
+ r1(i, j);
+ assert(count == save_count+7);
+ save_count = count;
+ }
+ // functor
+ {
+ A_void_2 a0;
+ std::reference_wrapper<A_void_2> r1(a0);
+ int i = 4;
+ int j = 5;
+ r1(i, j);
+ assert(count == save_count+9);
+ save_count = count;
+ }
+ // member function pointer
+ {
+ void (A_void_2::*fp)(int) = &A_void_2::mem1;
+ std::reference_wrapper<void (A_void_2::*)(int)> r1(fp);
+ A_void_2 a;
+ int i = 3;
+ r1(a, i);
+ assert(count == save_count+3);
+ save_count = count;
+ A_void_2* ap = &a;
+ r1(ap, i);
+ assert(count == save_count+3);
+ save_count = count;
+ }
+ // const member function pointer
+ {
+ void (A_void_2::*fp)(int) const = &A_void_2::mem2;
+ std::reference_wrapper<void (A_void_2::*)(int) const> r1(fp);
+ A_void_2 a;
+ int i = 4;
+ r1(a, i);
+ assert(count == save_count+4);
+ save_count = count;
+ A_void_2* ap = &a;
+ r1(ap, i);
+ assert(count == save_count+4);
+ save_count = count;
+ }
+}
+
+// 2 arg, return int
+
+int f_int_2(int i, int j)
+{
+ return i+j;
+}
+
+struct A_int_2
+{
+ int operator()(int i, int j)
+ {
+ return i+j;
+ }
+
+ int mem1(int i) {return i+1;}
+ int mem2(int i) const {return i+2;}
+};
+
+void
+testint_2()
+{
+ // function
+ {
+ std::reference_wrapper<int (int, int)> r1(f_int_2);
+ int i = 2;
+ int j = 3;
+ assert(r1(i, j) == i+j);
+ }
+ // function pointer
+ {
+ int (*fp)(int, int) = f_int_2;
+ std::reference_wrapper<int (*)(int, int)> r1(fp);
+ int i = 3;
+ int j = 4;
+ assert(r1(i, j) == i+j);
+ }
+ // functor
+ {
+ A_int_2 a0;
+ std::reference_wrapper<A_int_2> r1(a0);
+ int i = 4;
+ int j = 5;
+ assert(r1(i, j) == i+j);
+ }
+ // member function pointer
+ {
+ int(A_int_2::*fp)(int) = &A_int_2::mem1;
+ std::reference_wrapper<int (A_int_2::*)(int)> r1(fp);
+ A_int_2 a;
+ int i = 3;
+ assert(r1(a, i) == i+1);
+ A_int_2* ap = &a;
+ assert(r1(ap, i) == i+1);
+ }
+ // const member function pointer
+ {
+ int (A_int_2::*fp)(int) const = &A_int_2::mem2;
+ std::reference_wrapper<int (A_int_2::*)(int) const> r1(fp);
+ A_int_2 a;
+ int i = 4;
+ assert(r1(a, i) == i+2);
+ A_int_2* ap = &a;
+ assert(r1(ap, i) == i+2);
+ }
+}
+
+int main()
+{
+ test_void_1();
+ test_int_1();
+ test_void_2();
+ testint_2();
+}
diff --git a/test/std/utilities/function.objects/refwrap/refwrap.invoke/invoke_int_0.pass.cpp b/test/std/utilities/function.objects/refwrap/refwrap.invoke/invoke_int_0.pass.cpp
new file mode 100644
index 000000000000..61357a7fa394
--- /dev/null
+++ b/test/std/utilities/function.objects/refwrap/refwrap.invoke/invoke_int_0.pass.cpp
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// reference_wrapper
+
+// template <class... ArgTypes>
+// requires Callable<T, ArgTypes&&...>
+// Callable<T, ArgTypes&&...>::result_type
+// operator()(ArgTypes&&... args) const;
+
+#include <functional>
+#include <cassert>
+
+// 0 args, return int
+
+int count = 0;
+
+int f_int_0()
+{
+ return 3;
+}
+
+struct A_int_0
+{
+ int operator()() {return 4;}
+};
+
+void
+test_int_0()
+{
+ // function
+ {
+ std::reference_wrapper<int ()> r1(f_int_0);
+ assert(r1() == 3);
+ }
+ // function pointer
+ {
+ int (*fp)() = f_int_0;
+ std::reference_wrapper<int (*)()> r1(fp);
+ assert(r1() == 3);
+ }
+ // functor
+ {
+ A_int_0 a0;
+ std::reference_wrapper<A_int_0> r1(a0);
+ assert(r1() == 4);
+ }
+}
+
+// 1 arg, return void
+
+void f_void_1(int i)
+{
+ count += i;
+}
+
+struct A_void_1
+{
+ void operator()(int i)
+ {
+ count += i;
+ }
+};
+
+int main()
+{
+ test_int_0();
+}
diff --git a/test/std/utilities/function.objects/refwrap/refwrap.invoke/invoke_void_0.pass.cpp b/test/std/utilities/function.objects/refwrap/refwrap.invoke/invoke_void_0.pass.cpp
new file mode 100644
index 000000000000..8d700508cdc1
--- /dev/null
+++ b/test/std/utilities/function.objects/refwrap/refwrap.invoke/invoke_void_0.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// reference_wrapper
+
+// template <class... ArgTypes>
+// requires Callable<T, ArgTypes&&...>
+// Callable<T, ArgTypes&&...>::result_type
+// operator()(ArgTypes&&... args) const;
+
+#include <functional>
+#include <cassert>
+
+// 0 args, return void
+
+int count = 0;
+
+void f_void_0()
+{
+ ++count;
+}
+
+struct A_void_0
+{
+ void operator()() {++count;}
+};
+
+void
+test_void_0()
+{
+ int save_count = count;
+ // function
+ {
+ std::reference_wrapper<void ()> r1(f_void_0);
+ r1();
+ assert(count == save_count+1);
+ save_count = count;
+ }
+ // function pointer
+ {
+ void (*fp)() = f_void_0;
+ std::reference_wrapper<void (*)()> r1(fp);
+ r1();
+ assert(count == save_count+1);
+ save_count = count;
+ }
+ // functor
+ {
+ A_void_0 a0;
+ std::reference_wrapper<A_void_0> r1(a0);
+ r1();
+ assert(count == save_count+1);
+ save_count = count;
+ }
+}
+
+int main()
+{
+ test_void_0();
+}
diff --git a/test/std/utilities/function.objects/refwrap/type.pass.cpp b/test/std/utilities/function.objects/refwrap/type.pass.cpp
new file mode 100644
index 000000000000..68e406798145
--- /dev/null
+++ b/test/std/utilities/function.objects/refwrap/type.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// reference_wrapper
+
+// check for member typedef type
+
+#include <functional>
+#include <type_traits>
+
+class C {};
+
+int main()
+{
+ static_assert((std::is_same<std::reference_wrapper<C>::type,
+ C>::value), "");
+ static_assert((std::is_same<std::reference_wrapper<void ()>::type,
+ void ()>::value), "");
+ static_assert((std::is_same<std::reference_wrapper<int* (double*)>::type,
+ int* (double*)>::value), "");
+ static_assert((std::is_same<std::reference_wrapper<void(*)()>::type,
+ void(*)()>::value), "");
+ static_assert((std::is_same<std::reference_wrapper<int*(*)(double*)>::type,
+ int*(*)(double*)>::value), "");
+ static_assert((std::is_same<std::reference_wrapper<int*(C::*)(double*)>::type,
+ int*(C::*)(double*)>::value), "");
+ static_assert((std::is_same<std::reference_wrapper<int (C::*)(double*) const volatile>::type,
+ int (C::*)(double*) const volatile>::value), "");
+}
diff --git a/test/std/utilities/function.objects/refwrap/type_properties.pass.cpp b/test/std/utilities/function.objects/refwrap/type_properties.pass.cpp
new file mode 100644
index 000000000000..61e0bfa162d8
--- /dev/null
+++ b/test/std/utilities/function.objects/refwrap/type_properties.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// reference_wrapper
+
+// Test that reference wrapper meets the requirements of TriviallyCopyable,
+// CopyConstructible and CopyAssignable.
+
+#include <functional>
+#include <type_traits>
+#include <string>
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+class MoveOnly
+{
+ MoveOnly(const MoveOnly&);
+ MoveOnly& operator=(const MoveOnly&);
+
+ int data_;
+public:
+ MoveOnly(int data = 1) : data_(data) {}
+ MoveOnly(MoveOnly&& x)
+ : data_(x.data_) {x.data_ = 0;}
+ MoveOnly& operator=(MoveOnly&& x)
+ {data_ = x.data_; x.data_ = 0; return *this;}
+
+ int get() const {return data_;}
+};
+#endif
+
+
+template <class T>
+void test()
+{
+ typedef std::reference_wrapper<T> Wrap;
+ static_assert(std::is_copy_constructible<Wrap>::value, "");
+ static_assert(std::is_copy_assignable<Wrap>::value, "");
+ // Extension up for standardization: See N4151.
+ static_assert(std::is_trivially_copyable<Wrap>::value, "");
+}
+
+int main()
+{
+ test<int>();
+ test<double>();
+ test<std::string>();
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ test<MoveOnly>();
+#endif
+}
diff --git a/test/std/utilities/function.objects/refwrap/unary.pass.cpp b/test/std/utilities/function.objects/refwrap/unary.pass.cpp
new file mode 100644
index 000000000000..528a8f327d96
--- /dev/null
+++ b/test/std/utilities/function.objects/refwrap/unary.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// reference_wrapper
+
+// check for deriving from unary_function
+
+#include <functional>
+#include <type_traits>
+
+class functor1
+ : public std::unary_function<int, char>
+{
+};
+
+class functor2
+ : public std::binary_function<char, int, double>
+{
+};
+
+class functor3
+ : public std::unary_function<int, int>,
+ public std::binary_function<char, int, double>
+{
+public:
+ typedef float result_type;
+};
+
+class functor4
+ : public std::unary_function<int, int>,
+ public std::binary_function<char, int, double>
+{
+public:
+};
+
+struct C
+{
+ typedef int argument_type;
+ typedef int result_type;
+};
+
+int main()
+{
+ static_assert((std::is_base_of<std::unary_function<int, char>,
+ std::reference_wrapper<functor1> >::value), "");
+ static_assert((!std::is_base_of<std::unary_function<char, int>,
+ std::reference_wrapper<functor2> >::value), "");
+ static_assert((std::is_base_of<std::unary_function<int, int>,
+ std::reference_wrapper<functor3> >::value), "");
+ static_assert((std::is_base_of<std::unary_function<int, int>,
+ std::reference_wrapper<functor4> >::value), "");
+ static_assert((!std::is_base_of<std::unary_function<int, int>,
+ std::reference_wrapper<C> >::value), "");
+ static_assert((!std::is_base_of<std::unary_function<int, float>,
+ std::reference_wrapper<float(*)()> >::value), "");
+ static_assert((std::is_base_of<std::unary_function<int, float>,
+ std::reference_wrapper<float (int)> >::value), "");
+ static_assert((!std::is_base_of<std::unary_function<int, float>,
+ std::reference_wrapper<float (int, int)> >::value), "");
+ static_assert((std::is_base_of<std::unary_function<int, float>,
+ std::reference_wrapper<float(*)(int)> >::value), "");
+ static_assert((!std::is_base_of<std::unary_function<int, float>,
+ std::reference_wrapper<float(*)(int, int)> >::value), "");
+ static_assert((std::is_base_of<std::unary_function<C*, float>,
+ std::reference_wrapper<float(C::*)()> >::value), "");
+ static_assert((std::is_base_of<std::unary_function<const volatile C*, float>,
+ std::reference_wrapper<float(C::*)() const volatile> >::value), "");
+ static_assert((!std::is_base_of<std::unary_function<C*, float>,
+ std::reference_wrapper<float(C::*)(int)> >::value), "");
+}
diff --git a/test/std/utilities/function.objects/refwrap/weak_result.pass.cpp b/test/std/utilities/function.objects/refwrap/weak_result.pass.cpp
new file mode 100644
index 000000000000..609094dae406
--- /dev/null
+++ b/test/std/utilities/function.objects/refwrap/weak_result.pass.cpp
@@ -0,0 +1,82 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// reference_wrapper
+
+// has weak result type
+
+#include <functional>
+#include <type_traits>
+
+class functor1
+ : public std::unary_function<int, char>
+{
+};
+
+class functor2
+ : public std::binary_function<char, int, double>
+{
+};
+
+class functor3
+ : public std::unary_function<char, int>,
+ public std::binary_function<char, int, double>
+{
+public:
+ typedef float result_type;
+};
+
+class functor4
+ : public std::unary_function<char, int>,
+ public std::binary_function<char, int, double>
+{
+public:
+};
+
+class C {};
+
+template <class T>
+struct has_result_type
+{
+private:
+ struct two {char _; char __;};
+ template <class U> static two test(...);
+ template <class U> static char test(typename U::result_type* = 0);
+public:
+ static const bool value = sizeof(test<T>(0)) == 1;
+};
+
+int main()
+{
+ static_assert((std::is_same<std::reference_wrapper<functor1>::result_type,
+ char>::value), "");
+ static_assert((std::is_same<std::reference_wrapper<functor2>::result_type,
+ double>::value), "");
+ static_assert((std::is_same<std::reference_wrapper<functor3>::result_type,
+ float>::value), "");
+ static_assert((std::is_same<std::reference_wrapper<void()>::result_type,
+ void>::value), "");
+ static_assert((std::is_same<std::reference_wrapper<int*(double*)>::result_type,
+ int*>::value), "");
+ static_assert((std::is_same<std::reference_wrapper<void(*)()>::result_type,
+ void>::value), "");
+ static_assert((std::is_same<std::reference_wrapper<int*(*)(double*)>::result_type,
+ int*>::value), "");
+ static_assert((std::is_same<std::reference_wrapper<int*(C::*)(double*)>::result_type,
+ int*>::value), "");
+ static_assert((std::is_same<std::reference_wrapper<int (C::*)(double*) const volatile>::result_type,
+ int>::value), "");
+ static_assert((std::is_same<std::reference_wrapper<C()>::result_type,
+ C>::value), "");
+ static_assert(has_result_type<std::reference_wrapper<functor3> >::value, "");
+ static_assert(!has_result_type<std::reference_wrapper<functor4> >::value, "");
+ static_assert(!has_result_type<std::reference_wrapper<C> >::value, "");
+}
diff --git a/test/std/utilities/function.objects/unord.hash/enum.fail.cpp b/test/std/utilities/function.objects/unord.hash/enum.fail.cpp
new file mode 100644
index 000000000000..9e44bfb77817
--- /dev/null
+++ b/test/std/utilities/function.objects/unord.hash/enum.fail.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// Hashing a struct w/o a defined hash should fail.
+
+#include <functional>
+#include <cassert>
+#include <type_traits>
+
+struct X {};
+
+int main()
+{
+ X x;
+ size_t h = std::hash<X>{} ( x );
+}
diff --git a/test/std/utilities/function.objects/unord.hash/enum.pass.cpp b/test/std/utilities/function.objects/unord.hash/enum.pass.cpp
new file mode 100644
index 000000000000..bd92a4ac4d2e
--- /dev/null
+++ b/test/std/utilities/function.objects/unord.hash/enum.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// make sure that we can hash enumeration values
+// Not very portable
+
+#if __cplusplus >= 201402L
+
+#include <functional>
+#include <cassert>
+#include <type_traits>
+#include <limits>
+
+enum class Colors { red, orange, yellow, green, blue, indigo, violet };
+enum class Cardinals { zero, one, two, three, five=5 };
+enum class LongColors : short { red, orange, yellow, green, blue, indigo, violet };
+enum class ShortColors : long { red, orange, yellow, green, blue, indigo, violet };
+enum class EightBitColors : uint8_t { red, orange, yellow, green, blue, indigo, violet };
+
+enum Fruits { apple, pear, grape, mango, cantaloupe };
+
+template <class T>
+void
+test()
+{
+ typedef std::hash<T> H;
+ static_assert((std::is_same<typename H::argument_type, T>::value), "" );
+ static_assert((std::is_same<typename H::result_type, std::size_t>::value), "" );
+ typedef typename std::underlying_type<T>::type under_type;
+
+ H h1;
+ std::hash<under_type> h2;
+ for (int i = 0; i <= 5; ++i)
+ {
+ T t(static_cast<T> (i));
+ if (sizeof(T) <= sizeof(std::size_t))
+ assert(h1(t) == h2(static_cast<under_type>(i)));
+ }
+}
+
+int main()
+{
+ test<Cardinals>();
+
+ test<Colors>();
+ test<ShortColors>();
+ test<LongColors>();
+ test<EightBitColors>();
+
+ test<Fruits>();
+}
+#else
+int main () {}
+#endif
diff --git a/test/std/utilities/function.objects/unord.hash/floating.pass.cpp b/test/std/utilities/function.objects/unord.hash/floating.pass.cpp
new file mode 100644
index 000000000000..f1f198f23599
--- /dev/null
+++ b/test/std/utilities/function.objects/unord.hash/floating.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template <class T>
+// struct hash
+// : public unary_function<T, size_t>
+// {
+// size_t operator()(T val) const;
+// };
+
+// Not very portable
+
+#include <functional>
+#include <cassert>
+#include <type_traits>
+#include <limits>
+#include <cmath>
+
+template <class T>
+void
+test()
+{
+ typedef std::hash<T> H;
+ static_assert((std::is_same<typename H::argument_type, T>::value), "" );
+ static_assert((std::is_same<typename H::result_type, std::size_t>::value), "" );
+ H h;
+
+ std::size_t t0 = h(0.);
+ std::size_t tn0 = h(-0.);
+ std::size_t tp1 = h(0.1);
+ std::size_t t1 = h(1);
+ std::size_t tn1 = h(-1);
+ std::size_t pinf = h(INFINITY);
+ std::size_t ninf = h(-INFINITY);
+ assert(t0 == tn0);
+ assert(t0 != tp1);
+ assert(t0 != t1);
+ assert(t0 != tn1);
+ assert(t0 != pinf);
+ assert(t0 != ninf);
+
+ assert(tp1 != t1);
+ assert(tp1 != tn1);
+ assert(tp1 != pinf);
+ assert(tp1 != ninf);
+
+ assert(t1 != tn1);
+ assert(t1 != pinf);
+ assert(t1 != ninf);
+
+ assert(tn1 != pinf);
+ assert(tn1 != ninf);
+
+ assert(pinf != ninf);
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+}
diff --git a/test/std/utilities/function.objects/unord.hash/integral.pass.cpp b/test/std/utilities/function.objects/unord.hash/integral.pass.cpp
new file mode 100644
index 000000000000..7cd9f15e93d1
--- /dev/null
+++ b/test/std/utilities/function.objects/unord.hash/integral.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template <class T>
+// struct hash
+// : public unary_function<T, size_t>
+// {
+// size_t operator()(T val) const;
+// };
+
+// Not very portable
+
+#include <functional>
+#include <cassert>
+#include <type_traits>
+#include <limits>
+
+template <class T>
+void
+test()
+{
+ typedef std::hash<T> H;
+ static_assert((std::is_same<typename H::argument_type, T>::value), "" );
+ static_assert((std::is_same<typename H::result_type, std::size_t>::value), "" );
+ H h;
+
+ for (int i = 0; i <= 5; ++i)
+ {
+ T t(i);
+ if (sizeof(T) <= sizeof(std::size_t))
+ assert(h(t) == t);
+ }
+}
+
+int main()
+{
+ test<bool>();
+ test<char>();
+ test<signed char>();
+ test<unsigned char>();
+ test<char16_t>();
+ test<char32_t>();
+ test<wchar_t>();
+ test<short>();
+ test<unsigned short>();
+ test<int>();
+ test<unsigned int>();
+ test<long>();
+ test<unsigned long>();
+ test<long long>();
+ test<unsigned long long>();
+}
diff --git a/test/std/utilities/function.objects/unord.hash/pointer.pass.cpp b/test/std/utilities/function.objects/unord.hash/pointer.pass.cpp
new file mode 100644
index 000000000000..a48394495e2d
--- /dev/null
+++ b/test/std/utilities/function.objects/unord.hash/pointer.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template <class T>
+// struct hash
+// : public unary_function<T, size_t>
+// {
+// size_t operator()(T val) const;
+// };
+
+// Not very portable
+
+#include <functional>
+#include <cassert>
+#include <type_traits>
+#include <limits>
+
+template <class T>
+void
+test()
+{
+ typedef std::hash<T> H;
+ static_assert((std::is_same<typename H::argument_type, T>::value), "" );
+ static_assert((std::is_same<typename H::result_type, std::size_t>::value), "" );
+ H h;
+
+ typedef typename std::remove_pointer<T>::type type;
+ type i;
+ type j;
+ assert(h(&i) != h(&j));
+}
+
+int main()
+{
+ test<int*>();
+}
diff --git a/test/std/utilities/function.objects/version.pass.cpp b/test/std/utilities/function.objects/version.pass.cpp
new file mode 100644
index 000000000000..99d731a74543
--- /dev/null
+++ b/test/std/utilities/function.objects/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+#include <functional>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/utilities/intseq/intseq.general/integer_seq.pass.cpp b/test/std/utilities/intseq/intseq.general/integer_seq.pass.cpp
new file mode 100644
index 000000000000..8ca5a96a4fac
--- /dev/null
+++ b/test/std/utilities/intseq/intseq.general/integer_seq.pass.cpp
@@ -0,0 +1,86 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// class make_integer_sequence
+
+#include <tuple>
+#include <utility>
+#include <type_traits>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+template <typename AtContainer, typename T, T... I>
+auto extract ( const AtContainer &t, const std::integer_sequence<T, I...> idx )
+-> decltype ( std::make_tuple ( std::get<I>(t)... ))
+{ return std::make_tuple ( std::get<I>(t)... ); }
+
+#endif // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+
+// Make a couple of sequences
+ using int3 = std::make_integer_sequence<int, 3>; // generates int: 0,1,2
+ using size7 = std::make_integer_sequence<size_t, 7>; // generates size_t: 0,1,2,3,4,5,6
+ using size4 = std::make_index_sequence<4>; // generates size_t: 0,1,2,3
+ using size2 = std::index_sequence_for<int, size_t>; // generates size_t: 0,1
+ using intmix = std::integer_sequence<int, 9, 8, 7, 2>; // generates int: 9,8,7,2
+ using sizemix = std::index_sequence<1, 1, 2, 3, 5>; // generates size_t: 1,1,2,3,5
+
+// Make sure they're what we expect
+ static_assert ( std::is_same<int3::value_type, int>::value, "int3 type wrong" );
+ static_assert ( int3::size () == 3, "int3 size wrong" );
+
+ static_assert ( std::is_same<size7::value_type, size_t>::value, "size7 type wrong" );
+ static_assert ( size7::size () == 7, "size7 size wrong" );
+
+ static_assert ( std::is_same<size4::value_type, size_t>::value, "size4 type wrong" );
+ static_assert ( size4::size () == 4, "size4 size wrong" );
+
+ static_assert ( std::is_same<size2::value_type, size_t>::value, "size2 type wrong" );
+ static_assert ( size2::size () == 2, "size2 size wrong" );
+
+ static_assert ( std::is_same<intmix::value_type, int>::value, "intmix type wrong" );
+ static_assert ( intmix::size () == 4, "intmix size wrong" );
+
+ static_assert ( std::is_same<sizemix::value_type, size_t>::value, "sizemix type wrong" );
+ static_assert ( sizemix::size () == 5, "sizemix size wrong" );
+
+ auto tup = std::make_tuple ( 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 );
+
+// Use them
+ auto t3 = extract ( tup, int3() );
+ static_assert ( std::tuple_size<decltype(t3)>::value == int3::size (), "t3 size wrong");
+ assert ( t3 == std::make_tuple ( 10, 11, 12 ));
+
+ auto t7 = extract ( tup, size7 ());
+ static_assert ( std::tuple_size<decltype(t7)>::value == size7::size (), "t7 size wrong");
+ assert ( t7 == std::make_tuple ( 10, 11, 12, 13, 14, 15, 16 ));
+
+ auto t4 = extract ( tup, size4 ());
+ static_assert ( std::tuple_size<decltype(t4)>::value == size4::size (), "t4 size wrong");
+ assert ( t4 == std::make_tuple ( 10, 11, 12, 13 ));
+
+ auto t2 = extract ( tup, size2 ());
+ static_assert ( std::tuple_size<decltype(t2)>::value == size2::size (), "t2 size wrong");
+ assert ( t2 == std::make_tuple ( 10, 11 ));
+
+ auto tintmix = extract ( tup, intmix ());
+ static_assert ( std::tuple_size<decltype(tintmix)>::value == intmix::size (), "tintmix size wrong");
+ assert ( tintmix == std::make_tuple ( 19, 18, 17, 12 ));
+
+ auto tsizemix = extract ( tup, sizemix ());
+ static_assert ( std::tuple_size<decltype(tsizemix)>::value == sizemix::size (), "tsizemix size wrong");
+ assert ( tsizemix == std::make_tuple ( 11, 11, 12, 13, 15 ));
+#endif // _LIBCPP_STD_VER > 11
+}
diff --git a/test/std/utilities/intseq/intseq.intseq/integer_seq.fail.cpp b/test/std/utilities/intseq/intseq.intseq/integer_seq.fail.cpp
new file mode 100644
index 000000000000..4b2d1acb5e6b
--- /dev/null
+++ b/test/std/utilities/intseq/intseq.intseq/integer_seq.fail.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template<class T, T... I>
+// struct integer_sequence
+// {
+// typedef T type;
+//
+// static constexpr size_t size() noexcept;
+// };
+
+// This test is a conforming extension. The extension turns undefined behavior
+// into a compile-time error.
+
+#include <utility>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+
+// Should fail to compile, since float is not an integral type
+ using floatmix = std::integer_sequence<float>;
+ floatmix::value_type I;
+
+#else
+
+X
+
+#endif // _LIBCPP_STD_VER > 11
+}
diff --git a/test/std/utilities/intseq/intseq.intseq/integer_seq.pass.cpp b/test/std/utilities/intseq/intseq.intseq/integer_seq.pass.cpp
new file mode 100644
index 000000000000..a795e90c41e4
--- /dev/null
+++ b/test/std/utilities/intseq/intseq.intseq/integer_seq.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template<class T, T... I>
+// struct integer_sequence
+// {
+// typedef T type;
+//
+// static constexpr size_t size() noexcept;
+// };
+
+#include <utility>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+
+// Make a few of sequences
+ using int3 = std::integer_sequence<int, 3, 2, 1>;
+ using size1 = std::integer_sequence<size_t, 7>;
+ using ushort2 = std::integer_sequence<unsigned short, 4, 6>;
+ using bool0 = std::integer_sequence<bool>;
+
+// Make sure they're what we expect
+ static_assert ( std::is_same<int3::value_type, int>::value, "int3 type wrong" );
+ static_assert ( int3::size() == 3, "int3 size wrong" );
+
+ static_assert ( std::is_same<size1::value_type, size_t>::value, "size1 type wrong" );
+ static_assert ( size1::size() == 1, "size1 size wrong" );
+
+ static_assert ( std::is_same<ushort2::value_type, unsigned short>::value, "ushort2 type wrong" );
+ static_assert ( ushort2::size() == 2, "ushort2 size wrong" );
+
+ static_assert ( std::is_same<bool0::value_type, bool>::value, "bool0 type wrong" );
+ static_assert ( bool0::size() == 0, "bool0 size wrong" );
+
+#endif // _LIBCPP_STD_VER > 11
+}
diff --git a/test/std/utilities/intseq/intseq.make/make_integer_seq.fail.cpp b/test/std/utilities/intseq/intseq.make/make_integer_seq.fail.cpp
new file mode 100644
index 000000000000..2dd6c17b3dee
--- /dev/null
+++ b/test/std/utilities/intseq/intseq.make/make_integer_seq.fail.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template<class T, T N>
+// using make_integer_sequence = integer_sequence<T, 0, 1, ..., N-1>;
+
+#include <utility>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+
+ std::make_integer_sequence<int, -3>::value_type i;
+
+#else
+
+X
+
+#endif // _LIBCPP_STD_VER > 11
+}
diff --git a/test/std/utilities/intseq/intseq.make/make_integer_seq.pass.cpp b/test/std/utilities/intseq/intseq.make/make_integer_seq.pass.cpp
new file mode 100644
index 000000000000..7e82b94a7da0
--- /dev/null
+++ b/test/std/utilities/intseq/intseq.make/make_integer_seq.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template<class T, T N>
+// using make_integer_sequence = integer_sequence<T, 0, 1, ..., N-1>;
+
+#include <utility>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+
+ static_assert(std::is_same<std::make_integer_sequence<int, 0>, std::integer_sequence<int>>::value, "");
+ static_assert(std::is_same<std::make_integer_sequence<int, 1>, std::integer_sequence<int, 0>>::value, "");
+ static_assert(std::is_same<std::make_integer_sequence<int, 2>, std::integer_sequence<int, 0, 1>>::value, "");
+ static_assert(std::is_same<std::make_integer_sequence<int, 3>, std::integer_sequence<int, 0, 1, 2>>::value, "");
+
+ static_assert(std::is_same<std::make_integer_sequence<unsigned long long, 0>, std::integer_sequence<unsigned long long>>::value, "");
+ static_assert(std::is_same<std::make_integer_sequence<unsigned long long, 1>, std::integer_sequence<unsigned long long, 0>>::value, "");
+ static_assert(std::is_same<std::make_integer_sequence<unsigned long long, 2>, std::integer_sequence<unsigned long long, 0, 1>>::value, "");
+ static_assert(std::is_same<std::make_integer_sequence<unsigned long long, 3>, std::integer_sequence<unsigned long long, 0, 1, 2>>::value, "");
+
+#endif // _LIBCPP_STD_VER > 11
+}
diff --git a/test/std/utilities/intseq/nothing_to_do.pass.cpp b/test/std/utilities/intseq/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/utilities/intseq/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/utilities/memory/allocator.tag/allocator_arg.pass.cpp b/test/std/utilities/memory/allocator.tag/allocator_arg.pass.cpp
new file mode 100644
index 000000000000..636998aa0d72
--- /dev/null
+++ b/test/std/utilities/memory/allocator.tag/allocator_arg.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// struct allocator_arg_t { };
+// const allocator_arg_t allocator_arg = allocator_arg_t();
+
+#include <memory>
+
+void test(std::allocator_arg_t) {}
+
+int main()
+{
+ test(std::allocator_arg);
+}
diff --git a/test/std/utilities/memory/allocator.traits/allocator.traits.members/allocate.pass.cpp b/test/std/utilities/memory/allocator.traits/allocator.traits.members/allocate.pass.cpp
new file mode 100644
index 000000000000..490fdf5d332b
--- /dev/null
+++ b/test/std/utilities/memory/allocator.traits/allocator.traits.members/allocate.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Alloc>
+// struct allocator_traits
+// {
+// static pointer allocate(allocator_type& a, size_type n);
+// ...
+// };
+
+#include <memory>
+#include <cassert>
+
+template <class T>
+struct A
+{
+ typedef T value_type;
+
+ value_type* allocate(std::size_t n)
+ {
+ assert(n == 10);
+ return (value_type*)0xDEADBEEF;
+ }
+};
+
+int main()
+{
+ A<int> a;
+ assert(std::allocator_traits<A<int> >::allocate(a, 10) == (int*)0xDEADBEEF);
+}
diff --git a/test/std/utilities/memory/allocator.traits/allocator.traits.members/allocate_hint.pass.cpp b/test/std/utilities/memory/allocator.traits/allocator.traits.members/allocate_hint.pass.cpp
new file mode 100644
index 000000000000..079db3526ac7
--- /dev/null
+++ b/test/std/utilities/memory/allocator.traits/allocator.traits.members/allocate_hint.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Alloc>
+// struct allocator_traits
+// {
+// static pointer allocate(allocator_type& a, size_type n, const_void_pointer hint);
+// ...
+// };
+
+#include <memory>
+#include <cassert>
+
+template <class T>
+struct A
+{
+ typedef T value_type;
+
+ value_type* allocate(std::size_t n)
+ {
+ assert(n == 10);
+ return (value_type*)0xDEADBEEF;
+ }
+};
+
+template <class T>
+struct B
+{
+ typedef T value_type;
+
+ value_type* allocate(std::size_t n)
+ {
+ assert(n == 12);
+ return (value_type*)0xEEADBEEF;
+ }
+ value_type* allocate(std::size_t n, const void* p)
+ {
+ assert(n == 11);
+ assert(p == 0);
+ return (value_type*)0xFEADBEEF;
+ }
+};
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+ A<int> a;
+ assert(std::allocator_traits<A<int> >::allocate(a, 10, nullptr) == (int*)0xDEADBEEF);
+#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE
+ B<int> b;
+ assert(std::allocator_traits<B<int> >::allocate(b, 11, nullptr) == (int*)0xFEADBEEF);
+}
diff --git a/test/std/utilities/memory/allocator.traits/allocator.traits.members/construct.pass.cpp b/test/std/utilities/memory/allocator.traits/allocator.traits.members/construct.pass.cpp
new file mode 100644
index 000000000000..634019758e70
--- /dev/null
+++ b/test/std/utilities/memory/allocator.traits/allocator.traits.members/construct.pass.cpp
@@ -0,0 +1,143 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Alloc>
+// struct allocator_traits
+// {
+// template <class Ptr, class... Args>
+// static void construct(allocator_type& a, Ptr p, Args&&... args);
+// ...
+// };
+
+#include <memory>
+#include <new>
+#include <type_traits>
+#include <cassert>
+
+template <class T>
+struct A
+{
+ typedef T value_type;
+
+};
+
+int b_construct = 0;
+
+template <class T>
+struct B
+{
+ typedef T value_type;
+
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+ template <class U, class ...Args>
+ void construct(U* p, Args&& ...args)
+ {
+ ++b_construct;
+ ::new ((void*)p) U(std::forward<Args>(args)...);
+ }
+#endif // _LIBCPP_HAS_NO_VARIADICS
+};
+
+struct A0
+{
+ static int count;
+ A0() {++count;}
+};
+
+int A0::count = 0;
+
+struct A1
+{
+ static int count;
+ A1(char c)
+ {
+ assert(c == 'c');
+ ++count;
+ }
+};
+
+int A1::count = 0;
+
+struct A2
+{
+ static int count;
+ A2(char c, int i)
+ {
+ assert(c == 'd');
+ assert(i == 5);
+ ++count;
+ }
+};
+
+int A2::count = 0;
+
+int main()
+{
+ {
+ A0::count = 0;
+ A<int> a;
+ std::aligned_storage<sizeof(A0)>::type a0;
+ assert(A0::count == 0);
+ std::allocator_traits<A<int> >::construct(a, (A0*)&a0);
+ assert(A0::count == 1);
+ }
+ {
+ A1::count = 0;
+ A<int> a;
+ std::aligned_storage<sizeof(A1)>::type a1;
+ assert(A1::count == 0);
+ std::allocator_traits<A<int> >::construct(a, (A1*)&a1, 'c');
+ assert(A1::count == 1);
+ }
+ {
+ A2::count = 0;
+ A<int> a;
+ std::aligned_storage<sizeof(A2)>::type a2;
+ assert(A2::count == 0);
+ std::allocator_traits<A<int> >::construct(a, (A2*)&a2, 'd', 5);
+ assert(A2::count == 1);
+ }
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+ {
+ A0::count = 0;
+ b_construct = 0;
+ B<int> b;
+ std::aligned_storage<sizeof(A0)>::type a0;
+ assert(A0::count == 0);
+ assert(b_construct == 0);
+ std::allocator_traits<B<int> >::construct(b, (A0*)&a0);
+ assert(A0::count == 1);
+ assert(b_construct == 1);
+ }
+ {
+ A1::count = 0;
+ b_construct = 0;
+ B<int> b;
+ std::aligned_storage<sizeof(A1)>::type a1;
+ assert(A1::count == 0);
+ assert(b_construct == 0);
+ std::allocator_traits<B<int> >::construct(b, (A1*)&a1, 'c');
+ assert(A1::count == 1);
+ assert(b_construct == 1);
+ }
+ {
+ A2::count = 0;
+ b_construct = 0;
+ B<int> b;
+ std::aligned_storage<sizeof(A2)>::type a2;
+ assert(A2::count == 0);
+ assert(b_construct == 0);
+ std::allocator_traits<B<int> >::construct(b, (A2*)&a2, 'd', 5);
+ assert(A2::count == 1);
+ assert(b_construct == 1);
+ }
+#endif // _LIBCPP_HAS_NO_VARIADICS
+}
diff --git a/test/std/utilities/memory/allocator.traits/allocator.traits.members/deallocate.pass.cpp b/test/std/utilities/memory/allocator.traits/allocator.traits.members/deallocate.pass.cpp
new file mode 100644
index 000000000000..b137dc6d36c3
--- /dev/null
+++ b/test/std/utilities/memory/allocator.traits/allocator.traits.members/deallocate.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Alloc>
+// struct allocator_traits
+// {
+// static void deallocate(allocator_type& a, pointer p, size_type n);
+// ...
+// };
+
+#include <memory>
+#include <cassert>
+
+int called = 0;
+
+template <class T>
+struct A
+{
+ typedef T value_type;
+
+ void deallocate(value_type* p, std::size_t n)
+ {
+ assert(p == (value_type*)0xDEADBEEF);
+ assert(n == 10);
+ ++called;
+ }
+};
+
+int main()
+{
+ A<int> a;
+ std::allocator_traits<A<int> >::deallocate(a, (int*)0xDEADBEEF, 10);
+ assert(called == 1);
+}
diff --git a/test/std/utilities/memory/allocator.traits/allocator.traits.members/destroy.pass.cpp b/test/std/utilities/memory/allocator.traits/allocator.traits.members/destroy.pass.cpp
new file mode 100644
index 000000000000..54726c929efe
--- /dev/null
+++ b/test/std/utilities/memory/allocator.traits/allocator.traits.members/destroy.pass.cpp
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Alloc>
+// struct allocator_traits
+// {
+// template <class Ptr>
+// static void destroy(allocator_type& a, Ptr p);
+// ...
+// };
+
+#include <memory>
+#include <new>
+#include <type_traits>
+#include <cassert>
+
+template <class T>
+struct A
+{
+ typedef T value_type;
+
+};
+
+int b_destroy = 0;
+
+template <class T>
+struct B
+{
+ typedef T value_type;
+
+ template <class U>
+ void destroy(U* p)
+ {
+ ++b_destroy;
+ p->~U();
+ }
+};
+
+struct A0
+{
+ static int count;
+ ~A0() {++count;}
+};
+
+int A0::count = 0;
+
+int main()
+{
+ {
+ A0::count = 0;
+ A<int> a;
+ std::aligned_storage<sizeof(A0)>::type a0;
+ std::allocator_traits<A<int> >::construct(a, (A0*)&a0);
+ assert(A0::count == 0);
+ std::allocator_traits<A<int> >::destroy(a, (A0*)&a0);
+ assert(A0::count == 1);
+ }
+#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+ {
+ A0::count = 0;
+ b_destroy = 0;
+ B<int> b;
+ std::aligned_storage<sizeof(A0)>::type a0;
+ std::allocator_traits<B<int> >::construct(b, (A0*)&a0);
+ assert(A0::count == 0);
+ assert(b_destroy == 0);
+ std::allocator_traits<B<int> >::destroy(b, (A0*)&a0);
+ assert(A0::count == 1);
+ assert(b_destroy == 1);
+ }
+#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE
+}
diff --git a/test/std/utilities/memory/allocator.traits/allocator.traits.members/max_size.pass.cpp b/test/std/utilities/memory/allocator.traits/allocator.traits.members/max_size.pass.cpp
new file mode 100644
index 000000000000..1fa7291203ed
--- /dev/null
+++ b/test/std/utilities/memory/allocator.traits/allocator.traits.members/max_size.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Alloc>
+// struct allocator_traits
+// {
+// static size_type max_size(const allocator_type& a) noexcept;
+// ...
+// };
+
+#include <memory>
+#include <new>
+#include <type_traits>
+#include <cassert>
+
+template <class T>
+struct A
+{
+ typedef T value_type;
+
+};
+
+template <class T>
+struct B
+{
+ typedef T value_type;
+
+ size_t max_size() const
+ {
+ return 100;
+ }
+};
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+ {
+ A<int> a;
+ assert(std::allocator_traits<A<int> >::max_size(a) ==
+ std::numeric_limits<std::size_t>::max());
+ }
+ {
+ const A<int> a = {};
+ assert(std::allocator_traits<A<int> >::max_size(a) ==
+ std::numeric_limits<std::size_t>::max());
+ }
+#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE
+ {
+ B<int> b;
+ assert(std::allocator_traits<B<int> >::max_size(b) == 100);
+ }
+ {
+ const B<int> b = {};
+ assert(std::allocator_traits<B<int> >::max_size(b) == 100);
+ }
+#if __cplusplus >= 201103
+ {
+ std::allocator<int> a;
+ static_assert(noexcept(std::allocator_traits<std::allocator<int>>::max_size(a)) == true, "");
+ }
+#endif
+}
diff --git a/test/std/utilities/memory/allocator.traits/allocator.traits.members/select_on_container_copy_construction.pass.cpp b/test/std/utilities/memory/allocator.traits/allocator.traits.members/select_on_container_copy_construction.pass.cpp
new file mode 100644
index 000000000000..29fe2be126f3
--- /dev/null
+++ b/test/std/utilities/memory/allocator.traits/allocator.traits.members/select_on_container_copy_construction.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Alloc>
+// struct allocator_traits
+// {
+// static allocator_type
+// select_on_container_copy_construction(const allocator_type& a);
+// ...
+// };
+
+#include <memory>
+#include <new>
+#include <type_traits>
+#include <cassert>
+
+template <class T>
+struct A
+{
+ typedef T value_type;
+ int id;
+ explicit A(int i = 0) : id(i) {}
+
+};
+
+template <class T>
+struct B
+{
+ typedef T value_type;
+
+ int id;
+ explicit B(int i = 0) : id(i) {}
+
+ B select_on_container_copy_construction() const
+ {
+ return B(100);
+ }
+};
+
+int main()
+{
+ {
+ A<int> a;
+ assert(std::allocator_traits<A<int> >::select_on_container_copy_construction(a).id == 0);
+ }
+ {
+ const A<int> a(0);
+ assert(std::allocator_traits<A<int> >::select_on_container_copy_construction(a).id == 0);
+ }
+#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+ {
+ B<int> b;
+ assert(std::allocator_traits<B<int> >::select_on_container_copy_construction(b).id == 100);
+ }
+ {
+ const B<int> b(0);
+ assert(std::allocator_traits<B<int> >::select_on_container_copy_construction(b).id == 100);
+ }
+#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE
+}
diff --git a/test/std/utilities/memory/allocator.traits/allocator.traits.types/const_pointer.pass.cpp b/test/std/utilities/memory/allocator.traits/allocator.traits.types/const_pointer.pass.cpp
new file mode 100644
index 000000000000..20348d20c10c
--- /dev/null
+++ b/test/std/utilities/memory/allocator.traits/allocator.traits.types/const_pointer.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Alloc>
+// struct allocator_traits
+// {
+// typedef Alloc::const_pointer
+// | pointer_traits<pointer>::rebind<const value_type>
+// ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+template <class T>
+struct Ptr {};
+
+template <class T>
+struct A
+{
+ typedef T value_type;
+ typedef Ptr<T> pointer;
+};
+
+template <class T>
+struct B
+{
+ typedef T value_type;
+};
+
+template <class T>
+struct CPtr {};
+
+template <class T>
+struct C
+{
+ typedef T value_type;
+ typedef CPtr<T> pointer;
+ typedef CPtr<const T> const_pointer;
+};
+
+int main()
+{
+ static_assert((std::is_same<std::allocator_traits<A<char> >::const_pointer, Ptr<const char> >::value), "");
+ static_assert((std::is_same<std::allocator_traits<B<char> >::const_pointer, const char*>::value), "");
+ static_assert((std::is_same<std::allocator_traits<C<char> >::const_pointer, CPtr<const char> >::value), "");
+}
diff --git a/test/std/utilities/memory/allocator.traits/allocator.traits.types/const_void_pointer.pass.cpp b/test/std/utilities/memory/allocator.traits/allocator.traits.types/const_void_pointer.pass.cpp
new file mode 100644
index 000000000000..4b4045a51bae
--- /dev/null
+++ b/test/std/utilities/memory/allocator.traits/allocator.traits.types/const_void_pointer.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Alloc>
+// struct allocator_traits
+// {
+// typedef Alloc::const_void_pointer
+// | pointer_traits<pointer>::rebind<const void>
+// const_void_pointer;
+// ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+template <class T>
+struct Ptr {};
+
+template <class T>
+struct A
+{
+ typedef T value_type;
+ typedef Ptr<T> pointer;
+};
+
+template <class T>
+struct B
+{
+ typedef T value_type;
+};
+
+template <class T>
+struct CPtr {};
+
+template <class T>
+struct C
+{
+ typedef T value_type;
+ typedef CPtr<const void> const_void_pointer;
+};
+
+int main()
+{
+ static_assert((std::is_same<std::allocator_traits<A<char> >::const_void_pointer, Ptr<const void> >::value), "");
+ static_assert((std::is_same<std::allocator_traits<B<char> >::const_void_pointer, const void*>::value), "");
+ static_assert((std::is_same<std::allocator_traits<C<char> >::const_void_pointer, CPtr<const void> >::value), "");
+}
diff --git a/test/std/utilities/memory/allocator.traits/allocator.traits.types/difference_type.pass.cpp b/test/std/utilities/memory/allocator.traits/allocator.traits.types/difference_type.pass.cpp
new file mode 100644
index 000000000000..085c911b0703
--- /dev/null
+++ b/test/std/utilities/memory/allocator.traits/allocator.traits.types/difference_type.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Alloc>
+// struct allocator_traits
+// {
+// typedef Alloc::difference_type
+// | pointer_traits<pointer>::difference_type difference_type;
+// ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+template <class T>
+struct A
+{
+ typedef T value_type;
+ typedef short difference_type;
+};
+
+template <class T>
+struct B
+{
+ typedef T value_type;
+};
+
+template <class T>
+struct C
+{
+ typedef T value_type;
+ struct pointer {};
+ struct const_pointer {};
+ struct void_pointer {};
+ struct const_void_pointer {};
+};
+
+namespace std
+{
+
+template <>
+struct pointer_traits<C<char>::pointer>
+{
+ typedef signed char difference_type;
+};
+
+}
+
+int main()
+{
+ static_assert((std::is_same<std::allocator_traits<A<char> >::difference_type, short>::value), "");
+ static_assert((std::is_same<std::allocator_traits<B<char> >::difference_type, std::ptrdiff_t>::value), "");
+ static_assert((std::is_same<std::allocator_traits<C<char> >::difference_type, signed char>::value), "");
+}
diff --git a/test/std/utilities/memory/allocator.traits/allocator.traits.types/is_always_equal.pass.cpp b/test/std/utilities/memory/allocator.traits/allocator.traits.types/is_always_equal.pass.cpp
new file mode 100644
index 000000000000..31a0f171d33d
--- /dev/null
+++ b/test/std/utilities/memory/allocator.traits/allocator.traits.types/is_always_equal.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Alloc>
+// struct allocator_traits
+// {
+// typedef Alloc::is_always_equal
+// | is_empty is_always_equal;
+// ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+template <class T>
+struct A
+{
+ typedef T value_type;
+ typedef std::true_type is_always_equal;
+};
+
+template <class T>
+struct B
+{
+ typedef T value_type;
+};
+
+template <class T>
+struct C
+{
+ typedef T value_type;
+ int not_empty_; // some random member variable
+};
+
+int main()
+{
+ static_assert((std::is_same<std::allocator_traits<A<char> >::is_always_equal, std::true_type>::value), "");
+ static_assert((std::is_same<std::allocator_traits<B<char> >::is_always_equal, std::true_type>::value), "");
+ static_assert((std::is_same<std::allocator_traits<C<char> >::is_always_equal, std::false_type>::value), "");
+
+ static_assert((std::is_same<std::allocator_traits<A<const char> >::is_always_equal, std::true_type>::value), "");
+ static_assert((std::is_same<std::allocator_traits<B<const char> >::is_always_equal, std::true_type>::value), "");
+ static_assert((std::is_same<std::allocator_traits<C<const char> >::is_always_equal, std::false_type>::value), "");
+}
diff --git a/test/std/utilities/memory/allocator.traits/allocator.traits.types/pointer.pass.cpp b/test/std/utilities/memory/allocator.traits/allocator.traits.types/pointer.pass.cpp
new file mode 100644
index 000000000000..60ba09499342
--- /dev/null
+++ b/test/std/utilities/memory/allocator.traits/allocator.traits.types/pointer.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Alloc>
+// struct allocator_traits
+// {
+// typedef Alloc::pointer | value_type* pointer;
+// ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+template <class T>
+struct Ptr {};
+
+template <class T>
+struct A
+{
+ typedef T value_type;
+ typedef Ptr<T> pointer;
+};
+
+template <class T>
+struct B
+{
+ typedef T value_type;
+};
+
+int main()
+{
+ static_assert((std::is_same<std::allocator_traits<A<char> >::pointer, Ptr<char> >::value), "");
+ static_assert((std::is_same<std::allocator_traits<B<char> >::pointer, char*>::value), "");
+}
diff --git a/test/std/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_copy_assignment.pass.cpp b/test/std/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_copy_assignment.pass.cpp
new file mode 100644
index 000000000000..604e890efaae
--- /dev/null
+++ b/test/std/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_copy_assignment.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Alloc>
+// struct allocator_traits
+// {
+// typedef Alloc::propagate_on_container_copy_assignment
+// | false_type propagate_on_container_copy_assignment;
+// ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+template <class T>
+struct A
+{
+ typedef T value_type;
+ typedef std::true_type propagate_on_container_copy_assignment;
+};
+
+template <class T>
+struct B
+{
+ typedef T value_type;
+};
+
+int main()
+{
+ static_assert((std::is_same<std::allocator_traits<A<char> >::propagate_on_container_copy_assignment, std::true_type>::value), "");
+ static_assert((std::is_same<std::allocator_traits<B<char> >::propagate_on_container_copy_assignment, std::false_type>::value), "");
+}
diff --git a/test/std/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_move_assignment.pass.cpp b/test/std/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_move_assignment.pass.cpp
new file mode 100644
index 000000000000..1d2b18686d0f
--- /dev/null
+++ b/test/std/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_move_assignment.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Alloc>
+// struct allocator_traits
+// {
+// typedef Alloc::propagate_on_container_move_assignment
+// | false_type propagate_on_container_move_assignment;
+// ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+template <class T>
+struct A
+{
+ typedef T value_type;
+ typedef std::true_type propagate_on_container_move_assignment;
+};
+
+template <class T>
+struct B
+{
+ typedef T value_type;
+};
+
+int main()
+{
+ static_assert((std::is_same<std::allocator_traits<A<char> >::propagate_on_container_move_assignment, std::true_type>::value), "");
+ static_assert((std::is_same<std::allocator_traits<B<char> >::propagate_on_container_move_assignment, std::false_type>::value), "");
+}
diff --git a/test/std/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_swap.pass.cpp b/test/std/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_swap.pass.cpp
new file mode 100644
index 000000000000..6730d1ae261a
--- /dev/null
+++ b/test/std/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_swap.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Alloc>
+// struct allocator_traits
+// {
+// typedef Alloc::propagate_on_container_swap
+// | false_type propagate_on_container_swap;
+// ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+template <class T>
+struct A
+{
+ typedef T value_type;
+ typedef std::true_type propagate_on_container_swap;
+};
+
+template <class T>
+struct B
+{
+ typedef T value_type;
+};
+
+int main()
+{
+ static_assert((std::is_same<std::allocator_traits<A<char> >::propagate_on_container_swap, std::true_type>::value), "");
+ static_assert((std::is_same<std::allocator_traits<B<char> >::propagate_on_container_swap, std::false_type>::value), "");
+}
diff --git a/test/std/utilities/memory/allocator.traits/allocator.traits.types/rebind_alloc.pass.cpp b/test/std/utilities/memory/allocator.traits/allocator.traits.types/rebind_alloc.pass.cpp
new file mode 100644
index 000000000000..50611b99da9a
--- /dev/null
+++ b/test/std/utilities/memory/allocator.traits/allocator.traits.types/rebind_alloc.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Alloc>
+// struct allocator_traits
+// {
+// template <class T> using rebind_alloc = Alloc::rebind<U>::other | Alloc<T, Args...>;
+// ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+template <class T>
+struct ReboundA {};
+
+template <class T>
+struct A
+{
+ typedef T value_type;
+
+ template <class U> struct rebind {typedef ReboundA<U> other;};
+};
+
+template <class T, class U>
+struct ReboundB {};
+
+template <class T, class U>
+struct B
+{
+ typedef T value_type;
+
+ template <class V> struct rebind {typedef ReboundB<V, U> other;};
+};
+
+template <class T>
+struct C
+{
+ typedef T value_type;
+};
+
+template <class T, class U>
+struct D
+{
+ typedef T value_type;
+};
+
+template <class T>
+struct E
+{
+ typedef T value_type;
+
+ template <class U> struct rebind {typedef ReboundA<U> otter;};
+};
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+ static_assert((std::is_same<std::allocator_traits<A<char> >::rebind_alloc<double>, ReboundA<double> >::value), "");
+ static_assert((std::is_same<std::allocator_traits<B<int, char> >::rebind_alloc<double>, ReboundB<double, char> >::value), "");
+ static_assert((std::is_same<std::allocator_traits<C<char> >::rebind_alloc<double>, C<double> >::value), "");
+ static_assert((std::is_same<std::allocator_traits<D<int, char> >::rebind_alloc<double>, D<double, char> >::value), "");
+ static_assert((std::is_same<std::allocator_traits<E<char> >::rebind_alloc<double>, E<double> >::value), "");
+#else // _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+ static_assert((std::is_same<std::allocator_traits<A<char> >::rebind_alloc<double>::other, ReboundA<double> >::value), "");
+ static_assert((std::is_same<std::allocator_traits<B<int, char> >::rebind_alloc<double>::other, ReboundB<double, char> >::value), "");
+ static_assert((std::is_same<std::allocator_traits<C<char> >::rebind_alloc<double>::other, C<double> >::value), "");
+ static_assert((std::is_same<std::allocator_traits<D<int, char> >::rebind_alloc<double>::other, D<double, char> >::value), "");
+ static_assert((std::is_same<std::allocator_traits<E<char> >::rebind_alloc<double>::other, E<double> >::value), "");
+#endif // _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+}
diff --git a/test/std/utilities/memory/allocator.traits/allocator.traits.types/size_type.pass.cpp b/test/std/utilities/memory/allocator.traits/allocator.traits.types/size_type.pass.cpp
new file mode 100644
index 000000000000..e9c175fe86a5
--- /dev/null
+++ b/test/std/utilities/memory/allocator.traits/allocator.traits.types/size_type.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Alloc>
+// struct allocator_traits
+// {
+// typedef Alloc::size_type | size_t size_type;
+// ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+template <class T>
+struct A
+{
+ typedef T value_type;
+ typedef unsigned short size_type;
+};
+
+template <class T>
+struct B
+{
+ typedef T value_type;
+};
+
+template <class T>
+struct C
+{
+ typedef T value_type;
+ struct pointer {};
+ struct const_pointer {};
+ struct void_pointer {};
+ struct const_void_pointer {};
+};
+
+namespace std
+{
+
+template <>
+struct pointer_traits<C<char>::pointer>
+{
+ typedef signed char difference_type;
+};
+
+}
+
+int main()
+{
+ static_assert((std::is_same<std::allocator_traits<A<char> >::size_type, unsigned short>::value), "");
+ static_assert((std::is_same<std::allocator_traits<B<char> >::size_type,
+ std::make_unsigned<std::ptrdiff_t>::type>::value), "");
+ static_assert((std::is_same<std::allocator_traits<C<char> >::size_type,
+ unsigned char>::value), "");
+}
diff --git a/test/std/utilities/memory/allocator.traits/allocator.traits.types/void_pointer.pass.cpp b/test/std/utilities/memory/allocator.traits/allocator.traits.types/void_pointer.pass.cpp
new file mode 100644
index 000000000000..74cd3475f664
--- /dev/null
+++ b/test/std/utilities/memory/allocator.traits/allocator.traits.types/void_pointer.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Alloc>
+// struct allocator_traits
+// {
+// typedef Alloc::void_pointer
+// | pointer_traits<pointer>::rebind<void>
+// void_pointer;
+// ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+template <class T>
+struct Ptr {};
+
+template <class T>
+struct A
+{
+ typedef T value_type;
+ typedef Ptr<T> pointer;
+};
+
+template <class T>
+struct B
+{
+ typedef T value_type;
+};
+
+template <class T>
+struct CPtr {};
+
+template <class T>
+struct C
+{
+ typedef T value_type;
+ typedef CPtr<void> void_pointer;
+};
+
+int main()
+{
+ static_assert((std::is_same<std::allocator_traits<A<char> >::void_pointer, Ptr<void> >::value), "");
+ static_assert((std::is_same<std::allocator_traits<B<char> >::void_pointer, void*>::value), "");
+ static_assert((std::is_same<std::allocator_traits<C<char> >::void_pointer, CPtr<void> >::value), "");
+}
diff --git a/test/std/utilities/memory/allocator.traits/allocator_type.pass.cpp b/test/std/utilities/memory/allocator.traits/allocator_type.pass.cpp
new file mode 100644
index 000000000000..fe35ae487576
--- /dev/null
+++ b/test/std/utilities/memory/allocator.traits/allocator_type.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Alloc>
+// struct allocator_traits
+// {
+// typedef Alloc allocator_type;
+// ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+template <class T>
+struct A
+{
+ typedef T value_type;
+};
+
+int main()
+{
+ static_assert((std::is_same<std::allocator_traits<A<char> >::allocator_type, A<char> >::value), "");
+}
diff --git a/test/std/utilities/memory/allocator.traits/rebind_traits.pass.cpp b/test/std/utilities/memory/allocator.traits/rebind_traits.pass.cpp
new file mode 100644
index 000000000000..87da9a0a85da
--- /dev/null
+++ b/test/std/utilities/memory/allocator.traits/rebind_traits.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Alloc>
+// struct allocator_traits
+// {
+// template <class T> using rebind_traits = allocator_traits<rebind_alloc<T>>;
+// ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+template <class T>
+struct ReboundA {};
+
+template <class T>
+struct A
+{
+ typedef T value_type;
+
+ template <class U> struct rebind {typedef ReboundA<U> other;};
+};
+
+template <class T, class U>
+struct ReboundB {};
+
+template <class T, class U>
+struct B
+{
+ typedef T value_type;
+
+ template <class V> struct rebind {typedef ReboundB<V, U> other;};
+};
+
+template <class T>
+struct C
+{
+ typedef T value_type;
+};
+
+template <class T, class U>
+struct D
+{
+ typedef T value_type;
+};
+
+template <class T>
+struct E
+{
+ typedef T value_type;
+
+ template <class U> struct rebind {typedef ReboundA<U> otter;};
+};
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+ static_assert((std::is_same<std::allocator_traits<A<char> >::rebind_traits<double>, std::allocator_traits<ReboundA<double> > >::value), "");
+ static_assert((std::is_same<std::allocator_traits<B<int, char> >::rebind_traits<double>, std::allocator_traits<ReboundB<double, char> > >::value), "");
+ static_assert((std::is_same<std::allocator_traits<C<char> >::rebind_traits<double>, std::allocator_traits<C<double> > >::value), "");
+ static_assert((std::is_same<std::allocator_traits<D<int, char> >::rebind_traits<double>, std::allocator_traits<D<double, char> > >::value), "");
+ static_assert((std::is_same<std::allocator_traits<E<char> >::rebind_traits<double>, std::allocator_traits<E<double> > >::value), "");
+#else // _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+ static_assert((std::is_same<std::allocator_traits<A<char> >::rebind_traits<double>::other, std::allocator_traits<ReboundA<double> > >::value), "");
+ static_assert((std::is_same<std::allocator_traits<B<int, char> >::rebind_traits<double>::other, std::allocator_traits<ReboundB<double, char> > >::value), "");
+ static_assert((std::is_same<std::allocator_traits<C<char> >::rebind_traits<double>::other, std::allocator_traits<C<double> > >::value), "");
+ static_assert((std::is_same<std::allocator_traits<D<int, char> >::rebind_traits<double>::other, std::allocator_traits<D<double, char> > >::value), "");
+ static_assert((std::is_same<std::allocator_traits<E<char> >::rebind_traits<double>::other, std::allocator_traits<E<double> > >::value), "");
+#endif // _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+}
diff --git a/test/std/utilities/memory/allocator.traits/value_type.pass.cpp b/test/std/utilities/memory/allocator.traits/value_type.pass.cpp
new file mode 100644
index 000000000000..d0c3d2c09a1f
--- /dev/null
+++ b/test/std/utilities/memory/allocator.traits/value_type.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Alloc>
+// struct allocator_traits
+// {
+// typedef typename Alloc::value_type value_type;
+// ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+template <class T>
+struct A
+{
+ typedef T value_type;
+};
+
+int main()
+{
+ static_assert((std::is_same<std::allocator_traits<A<char> >::value_type, char>::value), "");
+}
diff --git a/test/std/utilities/memory/allocator.uses/allocator.uses.construction/tested_elsewhere.pass.cpp b/test/std/utilities/memory/allocator.uses/allocator.uses.construction/tested_elsewhere.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/utilities/memory/allocator.uses/allocator.uses.construction/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/utilities/memory/allocator.uses/allocator.uses.trait/uses_allocator.pass.cpp b/test/std/utilities/memory/allocator.uses/allocator.uses.trait/uses_allocator.pass.cpp
new file mode 100644
index 000000000000..0477d9912e6e
--- /dev/null
+++ b/test/std/utilities/memory/allocator.uses/allocator.uses.trait/uses_allocator.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class T, class Alloc> struct uses_allocator;
+
+#include <memory>
+#include <vector>
+
+struct A
+{
+};
+
+struct B
+{
+ typedef int allocator_type;
+};
+
+int main()
+{
+ static_assert((!std::uses_allocator<int, std::allocator<int> >::value), "");
+ static_assert(( std::uses_allocator<std::vector<int>, std::allocator<int> >::value), "");
+ static_assert((!std::uses_allocator<A, std::allocator<int> >::value), "");
+ static_assert((!std::uses_allocator<B, std::allocator<int> >::value), "");
+ static_assert(( std::uses_allocator<B, double>::value), "");
+}
diff --git a/test/std/utilities/memory/allocator.uses/nothing_to_do.pass.cpp b/test/std/utilities/memory/allocator.uses/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/utilities/memory/allocator.uses/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/utilities/memory/c.malloc/nothing_to_do.pass.cpp b/test/std/utilities/memory/c.malloc/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..a71806330062
--- /dev/null
+++ b/test/std/utilities/memory/c.malloc/nothing_to_do.pass.cpp
@@ -0,0 +1,14 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <cstdlib> and <cstring> are already tested elsewhere
+
+int main()
+{
+}
diff --git a/test/std/utilities/memory/default.allocator/allocator.globals/eq.pass.cpp b/test/std/utilities/memory/default.allocator/allocator.globals/eq.pass.cpp
new file mode 100644
index 000000000000..8ce49b90d489
--- /dev/null
+++ b/test/std/utilities/memory/default.allocator/allocator.globals/eq.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// allocator:
+
+// template <class T1, class T2>
+// bool
+// operator==(const allocator<T1>&, const allocator<T2>&) throw();
+//
+// template <class T1, class T2>
+// bool
+// operator!=(const allocator<T1>&, const allocator<T2>&) throw();
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+ std::allocator<int> a1;
+ std::allocator<int> a2;
+ assert(a1 == a2);
+ assert(!(a1 != a2));
+}
diff --git a/test/std/utilities/memory/default.allocator/allocator.members/address.pass.cpp b/test/std/utilities/memory/default.allocator/allocator.members/address.pass.cpp
new file mode 100644
index 000000000000..04534f24d502
--- /dev/null
+++ b/test/std/utilities/memory/default.allocator/allocator.members/address.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// allocator:
+// pointer address(reference x) const;
+// const_pointer address(const_reference x) const;
+
+#include <memory>
+#include <cassert>
+
+template <class T>
+void test_address()
+{
+ T* tp = new T();
+ const T* ctp = tp;
+ const std::allocator<T> a;
+ assert(a.address(*tp) == tp);
+ assert(a.address(*ctp) == tp);
+ delete tp;
+}
+
+struct A
+{
+ void operator&() const {}
+};
+
+int main()
+{
+ test_address<int>();
+ test_address<A>();
+}
diff --git a/test/std/utilities/memory/default.allocator/allocator.members/allocate.pass.cpp b/test/std/utilities/memory/default.allocator/allocator.members/allocate.pass.cpp
new file mode 100644
index 000000000000..253515e3db3c
--- /dev/null
+++ b/test/std/utilities/memory/default.allocator/allocator.members/allocate.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// allocator:
+// pointer allocate(size_type n, allocator<void>::const_pointer hint=0);
+
+#include <memory>
+#include <cassert>
+
+#include "count_new.hpp"
+
+int A_constructed = 0;
+
+struct A
+{
+ int data;
+ A() {++A_constructed;}
+ A(const A&) {++A_constructed;}
+ ~A() {--A_constructed;}
+};
+
+int main()
+{
+ std::allocator<A> a;
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ assert(A_constructed == 0);
+ globalMemCounter.last_new_size = 0;
+ A* ap = a.allocate(3);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
+ assert(globalMemCounter.checkLastNewSizeEq(3 * sizeof(int)));
+ assert(A_constructed == 0);
+ a.deallocate(ap, 3);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ assert(A_constructed == 0);
+
+ globalMemCounter.last_new_size = 0;
+ A* ap2 = a.allocate(3, (const void*)5);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
+ assert(globalMemCounter.checkLastNewSizeEq(3 * sizeof(int)));
+ assert(A_constructed == 0);
+ a.deallocate(ap2, 3);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ assert(A_constructed == 0);
+}
diff --git a/test/std/utilities/memory/default.allocator/allocator.members/construct.pass.cpp b/test/std/utilities/memory/default.allocator/allocator.members/construct.pass.cpp
new file mode 100644
index 000000000000..d0a870e60690
--- /dev/null
+++ b/test/std/utilities/memory/default.allocator/allocator.members/construct.pass.cpp
@@ -0,0 +1,142 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// allocator:
+// template <class... Args> void construct(pointer p, Args&&... args);
+
+#include <memory>
+#include <cassert>
+
+#include "count_new.hpp"
+
+int A_constructed = 0;
+
+struct A
+{
+ int data;
+ A() {++A_constructed;}
+
+ A(const A&) {++A_constructed;}
+
+ explicit A(int) {++A_constructed;}
+ A(int, int*) {++A_constructed;}
+
+ ~A() {--A_constructed;}
+};
+
+int move_only_constructed = 0;
+
+class move_only
+{
+ int data;
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ move_only(const move_only&);
+ move_only& operator=(const move_only&);
+#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ move_only(move_only&);
+ move_only& operator=(move_only&);
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+public:
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ move_only(move_only&&) {++move_only_constructed;}
+ move_only& operator=(move_only&&) {return *this;}
+#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ operator std::__rv<move_only> () {return std::__rv<move_only>(*this);}
+ move_only(std::__rv<move_only>) {++move_only_constructed;}
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+ move_only() {++move_only_constructed;}
+ ~move_only() {--move_only_constructed;}
+};
+
+int main()
+{
+ {
+ std::allocator<A> a;
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ assert(A_constructed == 0);
+
+ globalMemCounter.last_new_size = 0;
+ A* ap = a.allocate(3);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
+ assert(globalMemCounter.checkLastNewSizeEq(3 * sizeof(int)));
+ assert(A_constructed == 0);
+
+ a.construct(ap);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
+ assert(A_constructed == 1);
+
+ a.destroy(ap);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
+ assert(A_constructed == 0);
+
+ a.construct(ap, A());
+ assert(globalMemCounter.checkOutstandingNewEq(1));
+ assert(A_constructed == 1);
+
+ a.destroy(ap);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
+ assert(A_constructed == 0);
+
+ a.construct(ap, 5);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
+ assert(A_constructed == 1);
+
+ a.destroy(ap);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
+ assert(A_constructed == 0);
+
+ a.construct(ap, 5, (int*)0);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
+ assert(A_constructed == 1);
+
+ a.destroy(ap);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
+ assert(A_constructed == 0);
+
+ a.deallocate(ap, 3);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ assert(A_constructed == 0);
+ }
+ {
+ std::allocator<move_only> a;
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ assert(move_only_constructed == 0);
+
+ globalMemCounter.last_new_size = 0;
+ move_only* ap = a.allocate(3);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
+ assert(globalMemCounter.checkLastNewSizeEq(3 * sizeof(int)));
+ assert(move_only_constructed == 0);
+
+ a.construct(ap);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
+ assert(move_only_constructed == 1);
+
+ a.destroy(ap);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
+ assert(move_only_constructed == 0);
+
+ a.construct(ap, move_only());
+ assert(globalMemCounter.checkOutstandingNewEq(1));
+ assert(move_only_constructed == 1);
+
+ a.destroy(ap);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
+ assert(move_only_constructed == 0);
+
+ a.deallocate(ap, 3);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ assert(move_only_constructed == 0);
+ }
+}
diff --git a/test/std/utilities/memory/default.allocator/allocator.members/max_size.pass.cpp b/test/std/utilities/memory/default.allocator/allocator.members/max_size.pass.cpp
new file mode 100644
index 000000000000..6ec9339bc48f
--- /dev/null
+++ b/test/std/utilities/memory/default.allocator/allocator.members/max_size.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// allocator:
+// size_type max_size() const throw();
+
+#include <memory>
+#include <limits>
+#include <cstddef>
+#include <cassert>
+
+int new_called = 0;
+
+int main()
+{
+ const std::allocator<int> a;
+ std::size_t M = a.max_size() * sizeof(int);
+ assert(M > 0xFFFF && M <= std::numeric_limits<std::size_t>::max());
+}
diff --git a/test/std/utilities/memory/default.allocator/allocator_pointers.pass.cpp b/test/std/utilities/memory/default.allocator/allocator_pointers.pass.cpp
new file mode 100644
index 000000000000..5a8f7a28a042
--- /dev/null
+++ b/test/std/utilities/memory/default.allocator/allocator_pointers.pass.cpp
@@ -0,0 +1,116 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <memory>
+#include <cassert>
+
+#if __cplusplus >= 201103L
+// #include <memory>
+//
+// template <class Alloc>
+// struct allocator_traits
+// {
+// typedef Alloc allocator_type;
+// typedef typename allocator_type::value_type
+// value_type;
+//
+// typedef Alloc::pointer | value_type* pointer;
+// typedef Alloc::const_pointer
+// | pointer_traits<pointer>::rebind<const value_type>
+// const_pointer;
+// typedef Alloc::void_pointer
+// | pointer_traits<pointer>::rebind<void>
+// void_pointer;
+// typedef Alloc::const_void_pointer
+// | pointer_traits<pointer>::rebind<const void>
+// const_void_pointer;
+
+template <typename Alloc>
+void test_pointer()
+{
+ typename std::allocator_traits<Alloc>::pointer vp;
+ typename std::allocator_traits<Alloc>::const_pointer cvp;
+
+ static_assert(std::is_same<bool, decltype( vp == vp)>::value, "");
+ static_assert(std::is_same<bool, decltype( vp != vp)>::value, "");
+ static_assert(std::is_same<bool, decltype( vp > vp)>::value, "");
+ static_assert(std::is_same<bool, decltype( vp >= vp)>::value, "");
+ static_assert(std::is_same<bool, decltype( vp < vp)>::value, "");
+ static_assert(std::is_same<bool, decltype( vp <= vp)>::value, "");
+
+ static_assert(std::is_same<bool, decltype( vp == cvp)>::value, "");
+ static_assert(std::is_same<bool, decltype(cvp == vp)>::value, "");
+ static_assert(std::is_same<bool, decltype( vp != cvp)>::value, "");
+ static_assert(std::is_same<bool, decltype(cvp != vp)>::value, "");
+ static_assert(std::is_same<bool, decltype( vp > cvp)>::value, "");
+ static_assert(std::is_same<bool, decltype(cvp > vp)>::value, "");
+ static_assert(std::is_same<bool, decltype( vp >= cvp)>::value, "");
+ static_assert(std::is_same<bool, decltype(cvp >= vp)>::value, "");
+ static_assert(std::is_same<bool, decltype( vp < cvp)>::value, "");
+ static_assert(std::is_same<bool, decltype(cvp < vp)>::value, "");
+ static_assert(std::is_same<bool, decltype( vp <= cvp)>::value, "");
+ static_assert(std::is_same<bool, decltype(cvp <= vp)>::value, "");
+
+ static_assert(std::is_same<bool, decltype(cvp == cvp)>::value, "");
+ static_assert(std::is_same<bool, decltype(cvp != cvp)>::value, "");
+ static_assert(std::is_same<bool, decltype(cvp > cvp)>::value, "");
+ static_assert(std::is_same<bool, decltype(cvp >= cvp)>::value, "");
+ static_assert(std::is_same<bool, decltype(cvp < cvp)>::value, "");
+ static_assert(std::is_same<bool, decltype(cvp <= cvp)>::value, "");
+}
+
+template <typename Alloc>
+void test_void_pointer()
+{
+ typename std::allocator_traits<Alloc>::void_pointer vp;
+ typename std::allocator_traits<Alloc>::const_void_pointer cvp;
+
+ static_assert(std::is_same<bool, decltype( vp == vp)>::value, "");
+ static_assert(std::is_same<bool, decltype( vp != vp)>::value, "");
+ static_assert(std::is_same<bool, decltype( vp > vp)>::value, "");
+ static_assert(std::is_same<bool, decltype( vp >= vp)>::value, "");
+ static_assert(std::is_same<bool, decltype( vp < vp)>::value, "");
+ static_assert(std::is_same<bool, decltype( vp <= vp)>::value, "");
+
+ static_assert(std::is_same<bool, decltype( vp == cvp)>::value, "");
+ static_assert(std::is_same<bool, decltype(cvp == vp)>::value, "");
+ static_assert(std::is_same<bool, decltype( vp != cvp)>::value, "");
+ static_assert(std::is_same<bool, decltype(cvp != vp)>::value, "");
+ static_assert(std::is_same<bool, decltype( vp > cvp)>::value, "");
+ static_assert(std::is_same<bool, decltype(cvp > vp)>::value, "");
+ static_assert(std::is_same<bool, decltype( vp >= cvp)>::value, "");
+ static_assert(std::is_same<bool, decltype(cvp >= vp)>::value, "");
+ static_assert(std::is_same<bool, decltype( vp < cvp)>::value, "");
+ static_assert(std::is_same<bool, decltype(cvp < vp)>::value, "");
+ static_assert(std::is_same<bool, decltype( vp <= cvp)>::value, "");
+ static_assert(std::is_same<bool, decltype(cvp <= vp)>::value, "");
+
+ static_assert(std::is_same<bool, decltype(cvp == cvp)>::value, "");
+ static_assert(std::is_same<bool, decltype(cvp != cvp)>::value, "");
+ static_assert(std::is_same<bool, decltype(cvp > cvp)>::value, "");
+ static_assert(std::is_same<bool, decltype(cvp >= cvp)>::value, "");
+ static_assert(std::is_same<bool, decltype(cvp < cvp)>::value, "");
+ static_assert(std::is_same<bool, decltype(cvp <= cvp)>::value, "");
+}
+
+struct Foo { int x; };
+
+int main()
+{
+ test_pointer<std::allocator<char>> ();
+ test_pointer<std::allocator<int>> ();
+ test_pointer<std::allocator<Foo>> ();
+
+ test_void_pointer<std::allocator<char>> ();
+ test_void_pointer<std::allocator<int>> ();
+ test_void_pointer<std::allocator<Foo>> ();
+}
+#else
+int main() {}
+#endif
diff --git a/test/std/utilities/memory/default.allocator/allocator_types.pass.cpp b/test/std/utilities/memory/default.allocator/allocator_types.pass.cpp
new file mode 100644
index 000000000000..cba32103dcd4
--- /dev/null
+++ b/test/std/utilities/memory/default.allocator/allocator_types.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// check nested types:
+
+// template <class T>
+// class allocator
+// {
+// public:
+// typedef size_t size_type;
+// typedef ptrdiff_t difference_type;
+// typedef T* pointer;
+// typedef const T* const_pointer;
+// typedef typename add_lvalue_reference<T>::type reference;
+// typedef typename add_lvalue_reference<const T>::type const_reference;
+// typedef T value_type;
+// typedef true_type is_always_equal;
+//
+// template <class U> struct rebind {typedef allocator<U> other;};
+// ...
+// };
+
+#include <memory>
+#include <type_traits>
+#include <cstddef>
+
+int main()
+{
+ static_assert((std::is_same<std::allocator<char>::size_type, std::size_t>::value), "");
+ static_assert((std::is_same<std::allocator<char>::difference_type, std::ptrdiff_t>::value), "");
+ static_assert((std::is_same<std::allocator<char>::pointer, char*>::value), "");
+ static_assert((std::is_same<std::allocator<char>::const_pointer, const char*>::value), "");
+ static_assert((std::is_same<std::allocator<char>::value_type, char>::value), "");
+ static_assert((std::is_same<std::allocator<char>::reference, char&>::value), "");
+ static_assert((std::is_same<std::allocator<char>::const_reference, const char&>::value), "");
+ static_assert((std::is_same<std::allocator<char>::rebind<int>::other,
+ std::allocator<int> >::value), "");
+
+ static_assert((std::is_same<std::allocator< char>::is_always_equal, std::true_type>::value), "");
+ static_assert((std::is_same<std::allocator<const char>::is_always_equal, std::true_type>::value), "");
+
+ std::allocator<char> a;
+ std::allocator<char> a2 = a;
+ a2 = a;
+ std::allocator<int> a3 = a2;
+ ((void)a3);
+}
diff --git a/test/std/utilities/memory/default.allocator/allocator_void.pass.cpp b/test/std/utilities/memory/default.allocator/allocator_void.pass.cpp
new file mode 100644
index 000000000000..cc1dbebae033
--- /dev/null
+++ b/test/std/utilities/memory/default.allocator/allocator_void.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <>
+// class allocator<void>
+// {
+// public:
+// typedef void* pointer;
+// typedef const void* const_pointer;
+// typedef void value_type;
+//
+// template <class _Up> struct rebind {typedef allocator<_Up> other;};
+// };
+
+#include <memory>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_same<std::allocator<void>::pointer, void*>::value), "");
+ static_assert((std::is_same<std::allocator<void>::const_pointer, const void*>::value), "");
+ static_assert((std::is_same<std::allocator<void>::value_type, void>::value), "");
+ static_assert((std::is_same<std::allocator<void>::rebind<int>::other,
+ std::allocator<int> >::value), "");
+ std::allocator<void> a;
+ std::allocator<void> a2 = a;
+ a2 = a;
+}
diff --git a/test/std/utilities/memory/pointer.traits/difference_type.pass.cpp b/test/std/utilities/memory/pointer.traits/difference_type.pass.cpp
new file mode 100644
index 000000000000..483c32561e85
--- /dev/null
+++ b/test/std/utilities/memory/pointer.traits/difference_type.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class T>
+// struct pointer_traits<T*>
+// {
+// typedef ptrdiff_t difference_type;
+// ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_same<std::pointer_traits<double*>::difference_type, std::ptrdiff_t>::value), "");
+}
diff --git a/test/std/utilities/memory/pointer.traits/element_type.pass.cpp b/test/std/utilities/memory/pointer.traits/element_type.pass.cpp
new file mode 100644
index 000000000000..44694fcb013c
--- /dev/null
+++ b/test/std/utilities/memory/pointer.traits/element_type.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class T>
+// struct pointer_traits<T*>
+// {
+// typedef T element_type;
+// ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_same<std::pointer_traits<const short*>::element_type, const short>::value), "");
+}
diff --git a/test/std/utilities/memory/pointer.traits/pointer.pass.cpp b/test/std/utilities/memory/pointer.traits/pointer.pass.cpp
new file mode 100644
index 000000000000..66e90cfcb854
--- /dev/null
+++ b/test/std/utilities/memory/pointer.traits/pointer.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Ptr>
+// struct pointer_traits
+// {
+// typedef Ptr pointer;
+// ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+struct A
+{
+ typedef short element_type;
+ typedef char difference_type;
+};
+
+int main()
+{
+ static_assert((std::is_same<std::pointer_traits<A>::pointer, A>::value), "");
+ static_assert((std::is_same<std::pointer_traits<int*>::pointer, int*>::value), "");
+}
diff --git a/test/std/utilities/memory/pointer.traits/pointer.traits.functions/pointer_to.pass.cpp b/test/std/utilities/memory/pointer.traits/pointer.traits.functions/pointer_to.pass.cpp
new file mode 100644
index 000000000000..a8ad936c9366
--- /dev/null
+++ b/test/std/utilities/memory/pointer.traits/pointer.traits.functions/pointer_to.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Ptr>
+// struct pointer_traits
+// {
+// static pointer pointer_to(<details>);
+// ...
+// };
+
+#include <memory>
+#include <cassert>
+
+template <class T>
+struct A
+{
+private:
+ struct nat {};
+public:
+ typedef T element_type;
+ element_type* t_;
+
+ A(element_type* t) : t_(t) {}
+
+ static A pointer_to(typename std::conditional<std::is_void<element_type>::value,
+ nat, element_type>::type& et)
+ {return A(&et);}
+};
+
+int main()
+{
+ {
+ int i = 0;
+ A<int> a = std::pointer_traits<A<int> >::pointer_to(i);
+ assert(a.t_ == &i);
+ }
+ {
+ (std::pointer_traits<A<void> >::element_type)0;
+ }
+}
diff --git a/test/std/utilities/memory/pointer.traits/pointer.traits.types/difference_type.pass.cpp b/test/std/utilities/memory/pointer.traits/pointer.traits.types/difference_type.pass.cpp
new file mode 100644
index 000000000000..4efe61342420
--- /dev/null
+++ b/test/std/utilities/memory/pointer.traits/pointer.traits.types/difference_type.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Ptr>
+// struct pointer_traits
+// {
+// typedef <details> difference_type;
+// ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+struct A
+{
+ typedef short element_type;
+ typedef char difference_type;
+};
+
+struct B
+{
+ typedef short element_type;
+};
+
+template <class T>
+struct C {};
+
+template <class T>
+struct D
+{
+ typedef char difference_type;
+};
+
+int main()
+{
+ static_assert((std::is_same<std::pointer_traits<A>::difference_type, char>::value), "");
+ static_assert((std::is_same<std::pointer_traits<B>::difference_type, std::ptrdiff_t>::value), "");
+ static_assert((std::is_same<std::pointer_traits<C<double> >::difference_type, std::ptrdiff_t>::value), "");
+ static_assert((std::is_same<std::pointer_traits<D<int> >::difference_type, char>::value), "");
+}
diff --git a/test/std/utilities/memory/pointer.traits/pointer.traits.types/element_type.pass.cpp b/test/std/utilities/memory/pointer.traits/pointer.traits.types/element_type.pass.cpp
new file mode 100644
index 000000000000..0ee1e8c93a67
--- /dev/null
+++ b/test/std/utilities/memory/pointer.traits/pointer.traits.types/element_type.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Ptr>
+// struct pointer_traits
+// {
+// typedef <details> element_type;
+// ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+struct A
+{
+ typedef char element_type;
+};
+
+template <class T>
+struct B
+{
+ typedef char element_type;
+};
+
+template <class T>
+struct C
+{
+};
+
+template <class T, class U>
+struct D
+{
+};
+
+int main()
+{
+ static_assert((std::is_same<std::pointer_traits<A>::element_type, char>::value), "");
+ static_assert((std::is_same<std::pointer_traits<B<int> >::element_type, char>::value), "");
+ static_assert((std::is_same<std::pointer_traits<C<int> >::element_type, int>::value), "");
+ static_assert((std::is_same<std::pointer_traits<D<double, int> >::element_type, double>::value), "");
+}
diff --git a/test/std/utilities/memory/pointer.traits/pointer.traits.types/rebind.pass.cpp b/test/std/utilities/memory/pointer.traits/pointer.traits.types/rebind.pass.cpp
new file mode 100644
index 000000000000..4a1455c53ef6
--- /dev/null
+++ b/test/std/utilities/memory/pointer.traits/pointer.traits.types/rebind.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Ptr>
+// struct pointer_traits
+// {
+// template <class U> using rebind = <details>;
+// ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+template <class T>
+struct A
+{
+};
+
+template <class T> struct B1 {};
+
+template <class T>
+struct B
+{
+#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+ template <class U> using rebind = B1<U>;
+#else
+ template <class U> struct rebind {typedef B1<U> other;};
+#endif
+};
+
+template <class T, class U>
+struct C
+{
+};
+
+template <class T, class U> struct D1 {};
+
+template <class T, class U>
+struct D
+{
+#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+ template <class V> using rebind = D1<V, U>;
+#else
+ template <class V> struct rebind {typedef D1<V, U> other;};
+#endif
+};
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+ static_assert((std::is_same<std::pointer_traits<A<int*> >::rebind<double*>, A<double*> >::value), "");
+ static_assert((std::is_same<std::pointer_traits<B<int> >::rebind<double>, B1<double> >::value), "");
+ static_assert((std::is_same<std::pointer_traits<C<char, int> >::rebind<double>, C<double, int> >::value), "");
+ static_assert((std::is_same<std::pointer_traits<D<char, int> >::rebind<double>, D1<double, int> >::value), "");
+#else // _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+ static_assert((std::is_same<std::pointer_traits<A<int*> >::rebind<double*>::other, A<double*> >::value), "");
+ static_assert((std::is_same<std::pointer_traits<B<int> >::rebind<double>::other, B1<double> >::value), "");
+ static_assert((std::is_same<std::pointer_traits<C<char, int> >::rebind<double>::other, C<double, int> >::value), "");
+ static_assert((std::is_same<std::pointer_traits<D<char, int> >::rebind<double>::other, D1<double, int> >::value), "");
+#endif // _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+}
diff --git a/test/std/utilities/memory/pointer.traits/pointer_to.pass.cpp b/test/std/utilities/memory/pointer.traits/pointer_to.pass.cpp
new file mode 100644
index 000000000000..fc44d9d77a2f
--- /dev/null
+++ b/test/std/utilities/memory/pointer.traits/pointer_to.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class T>
+// struct pointer_traits<T*>
+// {
+// static pointer pointer_to(<details>);
+// ...
+// };
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+ {
+ int i = 0;
+ int* a = std::pointer_traits<int*>::pointer_to(i);
+ assert(a == &i);
+ }
+ {
+ (std::pointer_traits<void*>::element_type)0;
+ }
+}
diff --git a/test/std/utilities/memory/pointer.traits/rebind.pass.cpp b/test/std/utilities/memory/pointer.traits/rebind.pass.cpp
new file mode 100644
index 000000000000..8716c05f3335
--- /dev/null
+++ b/test/std/utilities/memory/pointer.traits/rebind.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class T>
+// struct pointer_traits<T*>
+// {
+// template <class U> using rebind = U*;
+// ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+ static_assert((std::is_same<std::pointer_traits<int*>::rebind<double>, double*>::value), "");
+#else
+ static_assert((std::is_same<std::pointer_traits<int*>::rebind<double>::other, double*>::value), "");
+#endif
+}
diff --git a/test/std/utilities/memory/ptr.align/align.pass.cpp b/test/std/utilities/memory/ptr.align/align.pass.cpp
new file mode 100644
index 000000000000..d77d13c906de
--- /dev/null
+++ b/test/std/utilities/memory/ptr.align/align.pass.cpp
@@ -0,0 +1,84 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// #include <memory>
+
+// void* align(size_t alignment, size_t size, void*& ptr, size_t& space);
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+ const unsigned N = 20;
+ char buf[N];
+ void* r;
+ void* p = &buf[0];
+ std::size_t s = N;
+ r = std::align(4, 10, p, s);
+ assert(p == &buf[0]);
+ assert(r == p);
+ assert(s == N);
+
+ p = &buf[1];
+ s = N;
+ r = std::align(4, 10, p, s);
+ assert(p == &buf[4]);
+ assert(r == p);
+ assert(s == N-3);
+
+ p = &buf[2];
+ s = N;
+ r = std::align(4, 10, p, s);
+ assert(p == &buf[4]);
+ assert(r == p);
+ assert(s == N-2);
+
+ p = &buf[3];
+ s = N;
+ r = std::align(4, 10, p, s);
+ assert(p == &buf[4]);
+ assert(r == p);
+ assert(s == N-1);
+
+ p = &buf[4];
+ s = N;
+ r = std::align(4, 10, p, s);
+ assert(p == &buf[4]);
+ assert(r == p);
+ assert(s == N);
+
+ p = &buf[0];
+ s = N;
+ r = std::align(4, N, p, s);
+ assert(p == &buf[0]);
+ assert(r == p);
+ assert(s == N);
+
+ p = &buf[1];
+ s = N-1;
+ r = std::align(4, N-4, p, s);
+ assert(p == &buf[4]);
+ assert(r == p);
+ assert(s == N-4);
+
+ p = &buf[1];
+ s = N-1;
+ r = std::align(4, N-3, p, s);
+ assert(p == &buf[1]);
+ assert(r == nullptr);
+ assert(s == N-1);
+
+ p = &buf[0];
+ s = N;
+ r = std::align(1, N+1, p, s);
+ assert(p == &buf[0]);
+ assert(r == nullptr);
+ assert(s == N);
+}
diff --git a/test/std/utilities/memory/specialized.algorithms/nothing_to_do.pass.cpp b/test/std/utilities/memory/specialized.algorithms/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/utilities/memory/specialized.algorithms/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/utilities/memory/specialized.algorithms/specialized.addressof/addressof.pass.cpp b/test/std/utilities/memory/specialized.algorithms/specialized.addressof/addressof.pass.cpp
new file mode 100644
index 000000000000..e07bec4d0a47
--- /dev/null
+++ b/test/std/utilities/memory/specialized.algorithms/specialized.addressof/addressof.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <ObjectType T> T* addressof(T& r);
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ void operator&() const {}
+};
+
+struct nothing {
+ operator char&()
+ {
+ static char c;
+ return c;
+ }
+};
+
+int main()
+{
+ {
+ int i;
+ double d;
+ assert(std::addressof(i) == &i);
+ assert(std::addressof(d) == &d);
+ A* tp = new A;
+ const A* ctp = tp;
+ assert(std::addressof(*tp) == tp);
+ assert(std::addressof(*ctp) == tp);
+ delete tp;
+ }
+ {
+ union
+ {
+ nothing n;
+ int i;
+ };
+ assert(std::addressof(n) == (void*)std::addressof(i));
+ }
+}
diff --git a/test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy.pass.cpp b/test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy.pass.cpp
new file mode 100644
index 000000000000..f431335db732
--- /dev/null
+++ b/test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy.pass.cpp
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class InputIterator, class ForwardIterator>
+// ForwardIterator
+// uninitialized_copy(InputIterator first, InputIterator last,
+// ForwardIterator result);
+
+#include <memory>
+#include <cassert>
+
+struct B
+{
+ static int count_;
+ int data_;
+ explicit B() : data_(1) {}
+ B(const B& b) {if (++count_ == 3) throw 1; data_ = b.data_;}
+ ~B() {data_ = 0;}
+};
+
+int B::count_ = 0;
+
+struct Nasty
+{
+ Nasty() : i_ ( counter_++ ) {}
+ Nasty * operator &() const { return NULL; }
+ int i_;
+ static int counter_;
+};
+
+int Nasty::counter_ = 0;
+
+int main()
+{
+ {
+ const int N = 5;
+ char pool[sizeof(B)*N] = {0};
+ B* bp = (B*)pool;
+ B b[N];
+ try
+ {
+ std::uninitialized_copy(b, b+N, bp);
+ assert(false);
+ }
+ catch (...)
+ {
+ for (int i = 0; i < N; ++i)
+ assert(bp[i].data_ == 0);
+ }
+ B::count_ = 0;
+ std::uninitialized_copy(b, b+2, bp);
+ for (int i = 0; i < 2; ++i)
+ assert(bp[i].data_ == 1);
+ }
+ {
+ const int N = 5;
+ char pool[sizeof(Nasty)*N] = {0};
+ Nasty * p = (Nasty *) pool;
+ Nasty arr[N];
+ std::uninitialized_copy(arr, arr+N, p);
+ for (int i = 0; i < N; ++i) {
+ assert(arr[i].i_ == i);
+ assert( p[i].i_ == i);
+ }
+ }
+
+}
diff --git a/test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy_n.pass.cpp b/test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy_n.pass.cpp
new file mode 100644
index 000000000000..3b2007b969c3
--- /dev/null
+++ b/test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy_n.pass.cpp
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class InputIterator, class Size, class ForwardIterator>
+// ForwardIterator
+// uninitialized_copy_n(InputIterator first, Size n,
+// ForwardIterator result);
+
+#include <memory>
+#include <cassert>
+
+struct B
+{
+ static int count_;
+ int data_;
+ explicit B() : data_(1) {}
+ B(const B& b) {if (++count_ == 3) throw 1; data_ = b.data_;}
+ ~B() {data_ = 0;}
+};
+
+int B::count_ = 0;
+
+struct Nasty
+{
+ Nasty() : i_ ( counter_++ ) {}
+ Nasty * operator &() const { return NULL; }
+ int i_;
+ static int counter_;
+};
+
+int Nasty::counter_ = 0;
+
+int main()
+{
+ {
+ const int N = 5;
+ char pool[sizeof(B)*N] = {0};
+ B* bp = (B*)pool;
+ B b[N];
+ try
+ {
+ std::uninitialized_copy_n(b, 5, bp);
+ assert(false);
+ }
+ catch (...)
+ {
+ for (int i = 0; i < N; ++i)
+ assert(bp[i].data_ == 0);
+ }
+ B::count_ = 0;
+ std::uninitialized_copy_n(b, 2, bp);
+ for (int i = 0; i < 2; ++i)
+ assert(bp[i].data_ == 1);
+ }
+ {
+ const int N = 5;
+ char pool[sizeof(Nasty)*N] = {0};
+ Nasty * p = (Nasty *) pool;
+ Nasty arr[N];
+ std::uninitialized_copy_n(arr, N, p);
+ for (int i = 0; i < N; ++i) {
+ assert(arr[i].i_ == i);
+ assert( p[i].i_ == i);
+ }
+ }
+}
diff --git a/test/std/utilities/memory/specialized.algorithms/uninitialized.fill.n/uninitialized_fill_n.pass.cpp b/test/std/utilities/memory/specialized.algorithms/uninitialized.fill.n/uninitialized_fill_n.pass.cpp
new file mode 100644
index 000000000000..d2b1dfa28868
--- /dev/null
+++ b/test/std/utilities/memory/specialized.algorithms/uninitialized.fill.n/uninitialized_fill_n.pass.cpp
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class ForwardIterator, class Size, class T>
+// ForwardIterator
+// uninitialized_fill_n(ForwardIterator first, Size n, const T& x);
+
+#include <memory>
+#include <cassert>
+
+struct B
+{
+ static int count_;
+ int data_;
+ explicit B() : data_(1) {}
+ B(const B& b) {if (++count_ == 3) throw 1; data_ = b.data_;}
+ ~B() {data_ = 0;}
+};
+
+int B::count_ = 0;
+
+struct Nasty
+{
+ Nasty() : i_ ( counter_++ ) {}
+ Nasty * operator &() const { return NULL; }
+ int i_;
+ static int counter_;
+};
+
+int Nasty::counter_ = 0;
+
+int main()
+{
+ {
+ const int N = 5;
+ char pool[sizeof(B)*N] = {0};
+ B* bp = (B*)pool;
+ try
+ {
+ std::uninitialized_fill_n(bp, 5, B());
+ assert(false);
+ }
+ catch (...)
+ {
+ for (int i = 0; i < N; ++i)
+ assert(bp[i].data_ == 0);
+ }
+ B::count_ = 0;
+ B* r = std::uninitialized_fill_n(bp, 2, B());
+ assert(r == bp + 2);
+ for (int i = 0; i < 2; ++i)
+ assert(bp[i].data_ == 1);
+ }
+ {
+ {
+ const int N = 5;
+ char pool[N*sizeof(Nasty)] = {0};
+ Nasty* bp = (Nasty*)pool;
+
+ Nasty::counter_ = 23;
+ std::uninitialized_fill_n(bp, N, Nasty());
+ for (int i = 0; i < N; ++i)
+ assert(bp[i].i_ == 23);
+ }
+
+ }
+}
diff --git a/test/std/utilities/memory/specialized.algorithms/uninitialized.fill/uninitialized_fill.pass.cpp b/test/std/utilities/memory/specialized.algorithms/uninitialized.fill/uninitialized_fill.pass.cpp
new file mode 100644
index 000000000000..47cabdfa478a
--- /dev/null
+++ b/test/std/utilities/memory/specialized.algorithms/uninitialized.fill/uninitialized_fill.pass.cpp
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class ForwardIterator, class T>
+// void
+// uninitialized_fill(ForwardIterator first, ForwardIterator last,
+// const T& x);
+
+#include <memory>
+#include <cassert>
+
+struct B
+{
+ static int count_;
+ int data_;
+ explicit B() : data_(1) {}
+ B(const B& b) {if (++count_ == 3) throw 1; data_ = b.data_;}
+ ~B() {data_ = 0;}
+};
+
+int B::count_ = 0;
+
+struct Nasty
+{
+ Nasty() : i_ ( counter_++ ) {}
+ Nasty * operator &() const { return NULL; }
+ int i_;
+ static int counter_;
+};
+
+int Nasty::counter_ = 0;
+
+int main()
+{
+ {
+ const int N = 5;
+ char pool[sizeof(B)*N] = {0};
+ B* bp = (B*)pool;
+ try
+ {
+ std::uninitialized_fill(bp, bp+N, B());
+ assert(false);
+ }
+ catch (...)
+ {
+ for (int i = 0; i < N; ++i)
+ assert(bp[i].data_ == 0);
+ }
+ B::count_ = 0;
+ std::uninitialized_fill(bp, bp+2, B());
+ for (int i = 0; i < 2; ++i)
+ assert(bp[i].data_ == 1);
+ }
+ {
+ const int N = 5;
+ char pool[N*sizeof(Nasty)] = {0};
+ Nasty* bp = (Nasty*)pool;
+
+ Nasty::counter_ = 23;
+ std::uninitialized_fill(bp, bp+N, Nasty());
+ for (int i = 0; i < N; ++i)
+ assert(bp[i].i_ == 23);
+ }
+}
diff --git a/test/std/utilities/memory/storage.iterator/raw_storag_iterator.base.pass.cpp b/test/std/utilities/memory/storage.iterator/raw_storag_iterator.base.pass.cpp
new file mode 100644
index 000000000000..27b620569b83
--- /dev/null
+++ b/test/std/utilities/memory/storage.iterator/raw_storag_iterator.base.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// raw_storage_iterator
+
+#include <memory>
+#include <type_traits>
+#include <cassert>
+
+int A_constructed = 0;
+
+struct A
+{
+ int data_;
+public:
+ explicit A(int i) : data_(i) {++A_constructed;}
+
+ A(const A& a) : data_(a.data_) {++A_constructed;}
+ ~A() {--A_constructed; data_ = 0;}
+
+ bool operator==(int i) const {return data_ == i;}
+};
+
+int main()
+{
+#if __cplusplus >= 201402L
+ typedef std::aligned_storage<3*sizeof(A), std::alignment_of<A>::value>::type
+ Storage;
+ Storage buffer;
+ std::raw_storage_iterator<A*, A> it((A*)&buffer);
+ assert(A_constructed == 0);
+ assert(it.base() == (A*)&buffer);
+ for (int i = 0; i < 3; ++i)
+ {
+ *it++ = A(i+1);
+ A* ap = (A*)&buffer + i;
+ assert(*ap == i+1);
+ assert(A_constructed == i+1);
+ assert(it.base() == ap + 1); // next place to write
+ }
+#endif
+}
diff --git a/test/std/utilities/memory/storage.iterator/raw_storag_iterator.pass.cpp b/test/std/utilities/memory/storage.iterator/raw_storag_iterator.pass.cpp
new file mode 100644
index 000000000000..f77d6c75e17a
--- /dev/null
+++ b/test/std/utilities/memory/storage.iterator/raw_storag_iterator.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// raw_storage_iterator
+
+#include <memory>
+#include <type_traits>
+#include <cassert>
+
+int A_constructed = 0;
+
+struct A
+{
+ int data_;
+public:
+ explicit A(int i) : data_(i) {++A_constructed;}
+
+ A(const A& a) : data_(a.data_) {++A_constructed;}
+ ~A() {--A_constructed; data_ = 0;}
+
+ bool operator==(int i) const {return data_ == i;}
+};
+
+int main()
+{
+ typedef std::aligned_storage<3*sizeof(A), std::alignment_of<A>::value>::type
+ Storage;
+ Storage buffer;
+ std::raw_storage_iterator<A*, A> it((A*)&buffer);
+ assert(A_constructed == 0);
+ for (int i = 0; i < 3; ++i)
+ {
+ *it++ = A(i+1);
+ A* ap = (A*)&buffer + i;
+ assert(*ap == i+1);
+ assert(A_constructed == i+1);
+ }
+}
diff --git a/test/std/utilities/memory/temporary.buffer/temporary_buffer.pass.cpp b/test/std/utilities/memory/temporary.buffer/temporary_buffer.pass.cpp
new file mode 100644
index 000000000000..c1575bda2bac
--- /dev/null
+++ b/test/std/utilities/memory/temporary.buffer/temporary_buffer.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class T>
+// pair<T*, ptrdiff_t>
+// get_temporary_buffer(ptrdiff_t n);
+//
+// template <class T>
+// void
+// return_temporary_buffer(T* p);
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+ std::pair<int*, std::ptrdiff_t> ip = std::get_temporary_buffer<int>(5);
+ assert(ip.first);
+ assert(ip.second == 5);
+ std::return_temporary_buffer(ip.first);
+}
diff --git a/test/std/utilities/memory/unique.ptr/deleter.h b/test/std/utilities/memory/unique.ptr/deleter.h
new file mode 100644
index 000000000000..fb26044d98ff
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/deleter.h
@@ -0,0 +1,182 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Example move-only deleter
+
+#ifndef DELETER_H
+#define DELETER_H
+
+#include <type_traits>
+#include <utility>
+#include <cassert>
+
+template <class T>
+class Deleter
+{
+ int state_;
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ Deleter(const Deleter&);
+ Deleter& operator=(const Deleter&);
+#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ Deleter(Deleter&);
+ Deleter& operator=(Deleter&);
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+public:
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ Deleter(Deleter&& r) : state_(r.state_) {r.state_ = 0;}
+ Deleter& operator=(Deleter&& r)
+ {
+ state_ = r.state_;
+ r.state_ = 0;
+ return *this;
+ }
+#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ operator std::__rv<Deleter>() {return std::__rv<Deleter>(*this);}
+ Deleter(std::__rv<Deleter> r) : state_(r->state_) {r->state_ = 0;}
+ Deleter& operator=(std::__rv<Deleter> r)
+ {
+ state_ = r->state_;
+ r->state_ = 0;
+ return *this;
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+ Deleter() : state_(0) {}
+ explicit Deleter(int s) : state_(s) {}
+ ~Deleter() {assert(state_ >= 0); state_ = -1;}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ template <class U>
+ Deleter(Deleter<U>&& d,
+ typename std::enable_if<!std::is_same<U, T>::value>::type* = 0)
+ : state_(d.state()) {d.set_state(0);}
+
+private:
+ template <class U>
+ Deleter(const Deleter<U>& d,
+ typename std::enable_if<!std::is_same<U, T>::value>::type* = 0);
+#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ template <class U>
+ Deleter(Deleter<U> d,
+ typename std::enable_if<!std::is_same<U, T>::value>::type* = 0)
+ : state_(d.state()) {}
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+public:
+ int state() const {return state_;}
+ void set_state(int i) {state_ = i;}
+
+ void operator()(T* p) {delete p;}
+};
+
+template <class T>
+class Deleter<T[]>
+{
+ int state_;
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ Deleter(const Deleter&);
+ Deleter& operator=(const Deleter&);
+#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ Deleter(Deleter&);
+ Deleter& operator=(Deleter&);
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+public:
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ Deleter(Deleter&& r) : state_(r.state_) {r.state_ = 0;}
+ Deleter& operator=(Deleter&& r)
+ {
+ state_ = r.state_;
+ r.state_ = 0;
+ return *this;
+ }
+#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ operator std::__rv<Deleter>() {return std::__rv<Deleter>(*this);}
+ Deleter(std::__rv<Deleter> r) : state_(r->state_) {r->state_ = 0;}
+ Deleter& operator=(std::__rv<Deleter> r)
+ {
+ state_ = r->state_;
+ r->state_ = 0;
+ return *this;
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+ Deleter() : state_(0) {}
+ explicit Deleter(int s) : state_(s) {}
+ ~Deleter() {assert(state_ >= 0); state_ = -1;}
+
+ int state() const {return state_;}
+ void set_state(int i) {state_ = i;}
+
+ void operator()(T* p) {delete [] p;}
+};
+
+template <class T>
+void
+swap(Deleter<T>& x, Deleter<T>& y)
+{
+ Deleter<T> t(std::move(x));
+ x = std::move(y);
+ y = std::move(t);
+}
+
+template <class T>
+class CDeleter
+{
+ int state_;
+
+public:
+
+ CDeleter() : state_(0) {}
+ explicit CDeleter(int s) : state_(s) {}
+ ~CDeleter() {assert(state_ >= 0); state_ = -1;}
+
+ template <class U>
+ CDeleter(const CDeleter<U>& d)
+ : state_(d.state()) {}
+
+ int state() const {return state_;}
+ void set_state(int i) {state_ = i;}
+
+ void operator()(T* p) {delete p;}
+};
+
+template <class T>
+class CDeleter<T[]>
+{
+ int state_;
+
+public:
+
+ CDeleter() : state_(0) {}
+ explicit CDeleter(int s) : state_(s) {}
+ ~CDeleter() {assert(state_ >= 0); state_ = -1;}
+
+ int state() const {return state_;}
+ void set_state(int i) {state_ = i;}
+
+ void operator()(T* p) {delete [] p;}
+};
+
+template <class T>
+void
+swap(CDeleter<T>& x, CDeleter<T>& y)
+{
+ CDeleter<T> t(std::move(x));
+ x = std::move(y);
+ y = std::move(t);
+}
+
+#endif // DELETER_H
diff --git a/test/std/utilities/memory/unique.ptr/nothing_to_do.pass.cpp b/test/std/utilities/memory/unique.ptr/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array.pass.cpp
new file mode 100644
index 000000000000..b2fb58f529f3
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <memory>
+#include <string>
+#include <cassert>
+
+// The only way to create an unique_ptr<T[]> is to default construct them.
+
+class foo {
+public:
+ foo () : val_(3) {}
+ int get () const { return val_; }
+private:
+ int val_;
+ };
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ {
+ auto p1 = std::make_unique<int[]>(5);
+ for ( int i = 0; i < 5; ++i )
+ assert ( p1[i] == 0 );
+ }
+
+ {
+ auto p2 = std::make_unique<std::string[]>(5);
+ for ( int i = 0; i < 5; ++i )
+ assert ( p2[i].size () == 0 );
+ }
+
+ {
+ auto p3 = std::make_unique<foo[]>(7);
+ for ( int i = 0; i < 7; ++i )
+ assert ( p3[i].get () == 3 );
+ }
+#endif // _LIBCPP_STD_VER > 11
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array1.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array1.fail.cpp
new file mode 100644
index 000000000000..00987919413b
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array1.fail.cpp
@@ -0,0 +1,17 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <memory>
+#include <string>
+#include <cassert>
+
+int main()
+{
+ auto up1 = std::make_unique<std::string[]>("error"); // doesn't compile - no bound
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array2.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array2.fail.cpp
new file mode 100644
index 000000000000..cc94e9ab3aaa
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array2.fail.cpp
@@ -0,0 +1,17 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <memory>
+#include <string>
+#include <cassert>
+
+int main()
+{
+ auto up2 = std::make_unique<int[]>(10, 20, 30, 40);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array3.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array3.fail.cpp
new file mode 100644
index 000000000000..cfdc2e1d886b
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array3.fail.cpp
@@ -0,0 +1,17 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <memory>
+#include <string>
+#include <cassert>
+
+int main()
+{
+ auto up3 = std::make_unique<int[5]>(); // this is deleted
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array4.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array4.fail.cpp
new file mode 100644
index 000000000000..26eb59bbfd71
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array4.fail.cpp
@@ -0,0 +1,17 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <memory>
+#include <string>
+#include <cassert>
+
+int main()
+{
+ auto up4 = std::make_unique<int[5]>(11, 22, 33, 44, 55); // deleted
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.single.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.single.pass.cpp
new file mode 100644
index 000000000000..7326ed226557
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.single.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <memory>
+#include <string>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ {
+ std::unique_ptr<int> p1 = std::make_unique<int>(1);
+ assert ( *p1 == 1 );
+ p1 = std::make_unique<int> ();
+ assert ( *p1 == 0 );
+ }
+
+ {
+ std::unique_ptr<std::string> p2 = std::make_unique<std::string> ( "Meow!" );
+ assert ( *p2 == "Meow!" );
+ p2 = std::make_unique<std::string> ();
+ assert ( *p2 == "" );
+ p2 = std::make_unique<std::string> ( 6, 'z' );
+ assert ( *p2 == "zzzzzz" );
+ }
+#endif // _LIBCPP_STD_VER > 11
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/nothing_to_do.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/convert_ctor.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/convert_ctor.pass.cpp
new file mode 100644
index 000000000000..9bf794caeda2
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/convert_ctor.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// default_delete
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ std::default_delete<B> d2;
+ std::default_delete<A> d1 = d2;
+ A* p = new B;
+ assert(A::count == 1);
+ assert(B::count == 1);
+ d1(p);
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/default.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/default.pass.cpp
new file mode 100644
index 000000000000..f686e9f01f11
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/default.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// default_delete
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ std::default_delete<A> d;
+ A* p = new A;
+ assert(A::count == 1);
+ d(p);
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/incomplete.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/incomplete.fail.cpp
new file mode 100644
index 000000000000..255e5cd39c69
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/incomplete.fail.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// default_delete
+
+// Test that default_delete's operator() requires a complete type
+
+#include <memory>
+#include <cassert>
+
+struct A;
+
+int main()
+{
+ std::default_delete<A> d;
+ A* p = 0;
+ d(p);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/void.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/void.fail.cpp
new file mode 100644
index 000000000000..5d1cf1ff4981
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/void.fail.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// default_delete
+
+// Test that default_delete's operator() requires a complete type
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+ std::default_delete<const void> d;
+ const void* p = 0;
+ d(p);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/convert_ctor.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/convert_ctor.fail.cpp
new file mode 100644
index 000000000000..41209d977b71
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/convert_ctor.fail.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// default_delete
+
+// Test that default_delete<T[]> does not have a working converting constructor
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+};
+
+struct B
+ : public A
+{
+};
+
+int main()
+{
+ std::default_delete<B[]> d2;
+ std::default_delete<A[]> d1 = d2;
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/default.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/default.pass.cpp
new file mode 100644
index 000000000000..7a409766412f
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/default.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// default_delete
+
+// Test that default_delete<T[]> has a working default constructor
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ std::default_delete<A[]> d;
+ A* p = new A[3];
+ assert(A::count == 3);
+ d(p);
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/incomplete.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/incomplete.fail.cpp
new file mode 100644
index 000000000000..528b10e9085d
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/incomplete.fail.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// default_delete
+
+// Test that default_delete<T[]>'s operator() requires a complete type
+
+#include <memory>
+#include <cassert>
+
+struct A;
+
+int main()
+{
+ std::default_delete<A[]> d;
+ A* p = 0;
+ d(p);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.general/nothing_to_do.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.general/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.general/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move01.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move01.fail.cpp
new file mode 100644
index 000000000000..17375ede00f5
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move01.fail.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move assignment
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+// Can't copy from lvalue
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ std::unique_ptr<A> s(new A);
+ std::unique_ptr<A> s2;
+ s2 = s;
+ }
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move01.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move01.pass.cpp
new file mode 100644
index 000000000000..286e6bc9a7b9
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move01.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move assignment
+
+// test move assignment. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+#include "../deleter.h"
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ std::unique_ptr<A[]> s1(new A[3]);
+ A* p = s1.get();
+ assert(A::count == 3);
+ std::unique_ptr<A[]> s2(new A[2]);
+ assert(A::count == 5);
+ s2 = std::move(s1);
+ assert(A::count == 3);
+ assert(s2.get() == p);
+ assert(s1.get() == 0);
+ }
+ assert(A::count == 0);
+ {
+ std::unique_ptr<A[], Deleter<A[]> > s1(new A[4], Deleter<A[]>(5));
+ A* p = s1.get();
+ assert(A::count == 4);
+ std::unique_ptr<A[], Deleter<A[]> > s2(new A[5]);
+ assert(A::count == 9);
+ s2 = std::move(s1);
+ assert(s2.get() == p);
+ assert(s1.get() == 0);
+ assert(A::count == 4);
+ assert(s2.get_deleter().state() == 5);
+ assert(s1.get_deleter().state() == 0);
+ }
+ assert(A::count == 0);
+ {
+ CDeleter<A[]> d1(5);
+ std::unique_ptr<A[], CDeleter<A[]>&> s1(new A[6], d1);
+ A* p = s1.get();
+ assert(A::count == 6);
+ CDeleter<A[]> d2(6);
+ std::unique_ptr<A[], CDeleter<A[]>&> s2(new A[3], d2);
+ assert(A::count == 9);
+ s2 = std::move(s1);
+ assert(A::count == 6);
+ assert(s2.get() == p);
+ assert(s1.get() == 0);
+ assert(d1.state() == 5);
+ assert(d2.state() == 5);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move02.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move02.fail.cpp
new file mode 100644
index 000000000000..6e13873c2fb3
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move02.fail.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move assignment
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+// Can't copy from const lvalue
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ const std::unique_ptr<A[]> s(new A[3]);
+ std::unique_ptr<A[]> s2;
+ s2 = s;
+ }
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move03.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move03.fail.cpp
new file mode 100644
index 000000000000..3712a2796392
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move03.fail.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move assignment
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+// Can't copy from lvalue
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+class Deleter
+{
+ int state_;
+
+public:
+
+ Deleter() : state_(5) {}
+
+ int state() const {return state_;}
+
+ void operator()(A* p) {delete p;}
+};
+
+int main()
+{
+ {
+ std::unique_ptr<A, Deleter> s(new A);
+ A* p = s.get();
+ std::unique_ptr<A, Deleter> s2;
+ s2 = s;
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move04.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move04.fail.cpp
new file mode 100644
index 000000000000..4e85e5b0fb90
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move04.fail.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move ctor
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+// test move ctor. Can't copy from const lvalue
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+class Deleter
+{
+ int state_;
+
+public:
+
+ Deleter() : state_(5) {}
+
+ int state() const {return state_;}
+
+ void operator()(A* p) {delete p;}
+};
+
+int main()
+{
+ {
+ const std::unique_ptr<A, Deleter> s(new A);
+ A* p = s.get();
+ std::unique_ptr<A, Deleter> s2;
+ s2 = s;
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert01.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert01.fail.cpp
new file mode 100644
index 000000000000..9461958a431d
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert01.fail.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+// Can't assign from lvalue
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ std::unique_ptr<B[]> s(new B);
+ A* p = s.get();
+ std::unique_ptr<A[]> s2;
+ s2 = s;
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert02.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert02.fail.cpp
new file mode 100644
index 000000000000..1737136f4d72
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert02.fail.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+// Can't assign from lvalue
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+#include "../deleter.h"
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ boost::unique_ptr<B[], Deleter<B> > s(new B);
+ A* p = s.get();
+ boost::unique_ptr<A[], Deleter<A> > s2;
+ s2 = s;
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ assert(s2.get_deleter().state() == 5);
+ assert(s.get_deleter().state() == 0);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert03.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert03.fail.cpp
new file mode 100644
index 000000000000..3c89bb12344e
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert03.fail.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+// Can't assign from lvalue
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+#include "../deleter.h"
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ Deleter<B> db(5);
+ boost::unique_ptr<B[], Deleter<B>&> s(new B, db);
+ A* p = s.get();
+ Deleter<A> da(6);
+ boost::unique_ptr<A[], Deleter<A>&> s2(new A, da);
+ s2 = s;
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ assert(s2.get_deleter().state() == 5);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert04.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert04.fail.cpp
new file mode 100644
index 000000000000..970beb5a150e
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert04.fail.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+// Can't assign from const lvalue
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ const boost::unique_ptr<B[]> s(new B);
+ A* p = s.get();
+ boost::unique_ptr<A[]> s2;
+ s2 = s;
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert05.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert05.fail.cpp
new file mode 100644
index 000000000000..786858dd4016
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert05.fail.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+// Can't assign from const lvalue
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+#include "../deleter.h"
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ const boost::unique_ptr<B[], Deleter<B> > s(new B);
+ A* p = s.get();
+ boost::unique_ptr<A[], Deleter<A> > s2;
+ s2 = s;
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ assert(s2.get_deleter().state() == 5);
+ assert(s.get_deleter().state() == 0);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert06.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert06.fail.cpp
new file mode 100644
index 000000000000..46d4c0985d71
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert06.fail.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+// Can't assign from const lvalue
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+#include "../deleter.h"
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ Deleter<B> db(5);
+ const boost::unique_ptr<B[], Deleter<B>&> s(new B, db);
+ A* p = s.get();
+ Deleter<A> da(6);
+ boost::unique_ptr<A[], Deleter<A>&> s2(new A, da);
+ s2 = s;
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ assert(s2.get_deleter().state() == 5);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert07.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert07.fail.cpp
new file mode 100644
index 000000000000..65ee2694156f
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert07.fail.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ boost::unique_ptr<B[]> s(new B);
+ A* p = s.get();
+ boost::unique_ptr<A[]> s2(new A);
+ assert(A::count == 2);
+ s2 = boost::move(s);
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert08.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert08.fail.cpp
new file mode 100644
index 000000000000..da08195ffdd3
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert08.fail.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+#include "../deleter.h"
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ boost::unique_ptr<B[], Deleter<B> > s(new B);
+ A* p = s.get();
+ boost::unique_ptr<A[], Deleter<A> > s2(new A);
+ assert(A::count == 2);
+ s2 = (boost::move(s));
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ assert(s2.get_deleter().state() == 5);
+ assert(s.get_deleter().state() == 0);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert09.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert09.fail.cpp
new file mode 100644
index 000000000000..aeec076cb86a
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert09.fail.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+// test converting move assignment with reference deleters
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+#include "../deleter.h"
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ Deleter<B> db(5);
+ boost::unique_ptr<B[], Deleter<B>&> s(new B, db);
+ A* p = s.get();
+ Deleter<A> da(6);
+ boost::unique_ptr<A[], Deleter<A>&> s2(new A, da);
+ s2 = boost::move(s);
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ assert(s2.get_deleter().state() == 5);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/null_asgn.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/null_asgn.pass.cpp
new file mode 100644
index 000000000000..e2d7956cda64
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/null_asgn.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move assignment
+
+#include <memory>
+#include <cassert>
+
+// test assignment from null
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ std::unique_ptr<A> s2(new A);
+ assert(A::count == 1);
+ s2 = 0;
+ assert(A::count == 0);
+ assert(s2.get() == 0);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/null_ctor.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/null_ctor.pass.cpp
new file mode 100644
index 000000000000..6d752b9951a5
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/null_ctor.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// The deleter is not called if get() == 0
+
+#include <memory>
+#include <cassert>
+
+class Deleter
+{
+ int state_;
+
+ Deleter(Deleter&);
+ Deleter& operator=(Deleter&);
+
+public:
+ Deleter() : state_(0) {}
+
+ int state() const {return state_;}
+
+ void operator()(void*) {++state_;}
+};
+
+int main()
+{
+ Deleter d;
+ assert(d.state() == 0);
+ {
+ std::unique_ptr<int[], Deleter&> p(0, d);
+ assert(p.get() == 0);
+ assert(&p.get_deleter() == &d);
+ }
+ assert(d.state() == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/nullptr_asgn.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/nullptr_asgn.pass.cpp
new file mode 100644
index 000000000000..30ecdded3cf7
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/nullptr_asgn.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move assignment
+
+#include <memory>
+#include <cassert>
+
+// test assignment from null
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ std::unique_ptr<A[]> s2(new A[3]);
+ assert(A::count == 3);
+ s2 = nullptr;
+ assert(A::count == 0);
+ assert(s2.get() == 0);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/pointer_type.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/pointer_type.pass.cpp
new file mode 100644
index 000000000000..e7ad6ad7ef33
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/pointer_type.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr<T[]>::pointer type
+
+#include <memory>
+#include <type_traits>
+
+struct Deleter
+{
+ struct pointer {};
+};
+
+int main()
+{
+ {
+ typedef std::unique_ptr<int[]> P;
+ static_assert((std::is_same<P::pointer, int*>::value), "");
+ }
+ {
+ typedef std::unique_ptr<int[], Deleter> P;
+ static_assert((std::is_same<P::pointer, Deleter::pointer>::value), "");
+ }
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.fail.cpp
new file mode 100644
index 000000000000..b6bcad9a91c6
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.fail.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr default ctor
+
+// default unique_ptr ctor should require default Deleter ctor
+
+
+#include <memory>
+
+class Deleter
+{
+ // expected-error@memory:* {{base class 'Deleter' has private default constructor}}
+ // expected-note@memory:* + {{in instantiation of member function}}
+ Deleter() {} // expected-note {{implicitly declared private here}}
+
+public:
+
+ Deleter(Deleter&) {}
+ Deleter& operator=(Deleter&) { return *this; }
+
+ void operator()(void*) const {}
+};
+
+int main()
+{
+ std::unique_ptr<int[], Deleter> p;
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.pass.cpp
new file mode 100644
index 000000000000..0cc54382b98d
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr default ctor
+
+// default unique_ptr ctor should only require default Deleter ctor
+
+#include <memory>
+#include <cassert>
+
+class Deleter
+{
+ int state_;
+
+ Deleter(Deleter&);
+ Deleter& operator=(Deleter&);
+
+public:
+ Deleter() : state_(5) {}
+
+ int state() const {return state_;}
+
+ void operator()(void*) {}
+};
+
+int main()
+{
+ {
+ std::unique_ptr<int[]> p;
+ assert(p.get() == 0);
+ }
+ {
+ std::unique_ptr<int[], Deleter> p;
+ assert(p.get() == 0);
+ assert(p.get_deleter().state() == 5);
+ }
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default02.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default02.fail.cpp
new file mode 100644
index 000000000000..82b84948f3f0
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default02.fail.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr default ctor
+
+// default unique_ptr ctor should require non-reference Deleter ctor
+
+#include <memory>
+
+class Deleter
+{
+public:
+
+ void operator()(void*) {}
+};
+
+int main()
+{
+ std::unique_ptr<int[], Deleter&> p;
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default02.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default02.pass.cpp
new file mode 100644
index 000000000000..3ded41c419c8
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default02.pass.cpp
@@ -0,0 +1,87 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test default unique_ptr<T[]> ctor
+
+// default unique_ptr<T[]> ctor shouldn't require complete type
+
+#include <memory>
+#include <cassert>
+
+struct A;
+
+class Deleter
+{
+ int state_;
+
+ Deleter(Deleter&);
+ Deleter& operator=(Deleter&);
+
+public:
+ Deleter() : state_(5) {}
+
+ int state() const {return state_;}
+
+ void operator()(A* p);
+};
+
+void check(int i);
+
+template <class D = std::default_delete<A> >
+struct B
+{
+ std::unique_ptr<A[], D> a_;
+ B();
+ ~B();
+
+ A* get() const {return a_.get();}
+ D& get_deleter() {return a_.get_deleter();}
+};
+
+int main()
+{
+ {
+ B<> s;
+ assert(s.get() == 0);
+ }
+ check(0);
+ {
+ B<Deleter> s;
+ assert(s.get() == 0);
+ assert(s.get_deleter().state() == 5);
+ }
+ check(0);
+}
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+void Deleter::operator()(A* p) {delete p;}
+
+void check(int i)
+{
+ assert(A::count == i);
+}
+
+template <class D>
+B<D>::B() {}
+
+template <class D>
+B<D>::~B() {}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default03.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default03.fail.cpp
new file mode 100644
index 000000000000..74d24fd488b6
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default03.fail.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr default ctor
+
+// default unique_ptr ctor should require non-pointer Deleter
+
+#include <memory>
+
+int main()
+{
+ std::unique_ptr<int[], void (*)(void*)> p;
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move01.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move01.fail.cpp
new file mode 100644
index 000000000000..bc49a0e5c31e
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move01.fail.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move ctor
+
+#include <memory>
+#include <cassert>
+
+// test move ctor. Can't copy from lvalue
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ std::unique_ptr<A[]> s(new A[3]);
+ A* p = s.get();
+ std::unique_ptr<A[]> s2 = s;
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move01.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move01.pass.cpp
new file mode 100644
index 000000000000..03747b4f89cf
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move01.pass.cpp
@@ -0,0 +1,86 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move ctor
+
+// test move ctor. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+#include "../../deleter.h"
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+class NCDeleter
+{
+ int state_;
+
+ NCDeleter(NCDeleter&);
+ NCDeleter& operator=(NCDeleter&);
+public:
+
+ NCDeleter() : state_(5) {}
+
+ int state() const {return state_;}
+ void set_state(int s) {state_ = s;}
+
+ void operator()(A* p) {delete [] p;}
+};
+
+int main()
+{
+ {
+ std::unique_ptr<A[]> s(new A[3]);
+ A* p = s.get();
+ std::unique_ptr<A[]> s2 = std::move(s);
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 3);
+ }
+ assert(A::count == 0);
+ {
+ std::unique_ptr<A[], Deleter<A[]> > s(new A[3], Deleter<A[]>(5));
+ A* p = s.get();
+ std::unique_ptr<A[], Deleter<A[]> > s2 = std::move(s);
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 3);
+ assert(s2.get_deleter().state() == 5);
+ assert(s.get_deleter().state() == 0);
+ }
+ assert(A::count == 0);
+ {
+ NCDeleter d;
+ std::unique_ptr<A[], NCDeleter&> s(new A[3], d);
+ A* p = s.get();
+ std::unique_ptr<A[], NCDeleter&> s2 = std::move(s);
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 3);
+ d.set_state(6);
+ assert(s2.get_deleter().state() == d.state());
+ assert(s.get_deleter().state() == d.state());
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move02.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move02.fail.cpp
new file mode 100644
index 000000000000..8e44c78bf1e9
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move02.fail.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move ctor
+
+// test move ctor. Can't copy from const lvalue
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ const std::unique_ptr<A[]> s(new A[3]);
+ A* p = s.get();
+ std::unique_ptr<A[]> s2 = s;
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move02.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move02.pass.cpp
new file mode 100644
index 000000000000..ef821a915e44
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move02.pass.cpp
@@ -0,0 +1,87 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move ctor
+
+// test move ctor. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+
+#include <memory>
+#include <cassert>
+
+#include "../../deleter.h"
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+class NCDeleter
+{
+ int state_;
+
+ NCDeleter(NCDeleter&);
+ NCDeleter& operator=(NCDeleter&);
+public:
+
+ NCDeleter() : state_(5) {}
+
+ int state() const {return state_;}
+ void set_state(int s) {state_ = s;}
+
+ void operator()(A* p) {delete [] p;}
+};
+
+std::unique_ptr<A[]>
+source1()
+{
+ return std::unique_ptr<A[]>(new A[3]);
+}
+
+void sink1(std::unique_ptr<A[]> p)
+{
+}
+
+std::unique_ptr<A[], Deleter<A[]> >
+source2()
+{
+ return std::unique_ptr<A[], Deleter<A[]> >(new A[3]);
+}
+
+void sink2(std::unique_ptr<A[], Deleter<A[]> > p)
+{
+}
+
+std::unique_ptr<A[], NCDeleter&>
+source3()
+{
+ static NCDeleter d;
+ return std::unique_ptr<A[], NCDeleter&>(new A[3], d);
+}
+
+void sink3(std::unique_ptr<A[], NCDeleter&> p)
+{
+}
+
+int main()
+{
+ sink1(source1());
+ sink2(source2());
+ sink3(source3());
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move03.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move03.fail.cpp
new file mode 100644
index 000000000000..c952cf2d4e13
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move03.fail.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move ctor
+
+// test move ctor. Can't copy from lvalue
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+class Deleter
+{
+ int state_;
+
+public:
+
+ Deleter() : state_(5) {}
+
+ int state() const {return state_;}
+
+ void operator()(A* p) {delete [] p;}
+};
+
+int main()
+{
+ {
+ std::unique_ptr<A[], Deleter> s(new A[3]);
+ A* p = s.get();
+ std::unique_ptr<A[], Deleter> s2 = s;
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move04.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move04.fail.cpp
new file mode 100644
index 000000000000..0d091ff346d1
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move04.fail.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move ctor
+
+// test move ctor. Can't copy from const lvalue
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+class Deleter
+{
+ int state_;
+
+public:
+
+ Deleter() : state_(5) {}
+
+ int state() const {return state_;}
+
+ void operator()(A* p) {delete [] p;}
+};
+
+int main()
+{
+ {
+ const std::unique_ptr<A[], Deleter> s(new A[3]);
+ A* p = s.get();
+ std::unique_ptr<A[], Deleter> s2 = s;
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert01.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert01.fail.cpp
new file mode 100644
index 000000000000..d175fbf93adc
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert01.fail.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+// test converting move ctor. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+// Explicit version
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ std::unique_ptr<B[]> s(new B);
+ A* p = s.get();
+ std::unique_ptr<A[]> s2(s);
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert02.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert02.fail.cpp
new file mode 100644
index 000000000000..1838511b4929
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert02.fail.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+// test converting move ctor. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+// Explicit version
+
+#include <memory>
+#include <cassert>
+
+#include "../../deleter.h"
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ std::unique_ptr<B[], Deleter<B[]> > s(new B);
+ A* p = s.get();
+ std::unique_ptr<A[], Deleter<A[]> > s2(s);
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ assert(s2.get_deleter().state() == 5);
+ assert(s.get_deleter().state() == 0);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert03.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert03.fail.cpp
new file mode 100644
index 000000000000..36ad75d8331a
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert03.fail.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+// test converting move ctor. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+// Explicit version
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+template <class T>
+class CDeleter
+{
+ int state_;
+
+ CDeleter(CDeleter&);
+ CDeleter& operator=(CDeleter&);
+public:
+
+ CDeleter() : state_(5) {}
+
+ int state() const {return state_;}
+ void set_state(int s) {state_ = s;}
+
+ void operator()(T* p) {delete p;}
+};
+
+int main()
+{
+ {
+ CDeleter<A> d;
+ std::unique_ptr<B[], CDeleter<A>&> s(new B, d);
+ A* p = s.get();
+ std::unique_ptr<A[], CDeleter<A>&> s2(s);
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ d.set_state(6);
+ assert(s2.get_deleter().state() == d.state());
+ assert(s.get_deleter().state() == d.state());
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert04.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert04.fail.cpp
new file mode 100644
index 000000000000..3a19bde92889
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert04.fail.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+// test converting move ctor. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+// implicit version
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ std::unique_ptr<B[]> s(new B);
+ A* p = s.get();
+ std::unique_ptr<A[]> s2 = s;
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert05.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert05.fail.cpp
new file mode 100644
index 000000000000..bda2a70a4ef3
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert05.fail.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+// test converting move ctor. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+// Implicit version
+
+#include <memory>
+#include <cassert>
+
+#include "../../deleter.h"
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ std::unique_ptr<B[], Deleter<B[]> > s(new B);
+ A* p = s.get();
+ std::unique_ptr<A[], Deleter<A[]> > s2 = s;
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ assert(s2.get_deleter().state() == 5);
+ assert(s.get_deleter().state() == 0);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert06.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert06.fail.cpp
new file mode 100644
index 000000000000..fba895137b05
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert06.fail.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+// test converting move ctor. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+// Explicit version
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+template <class T>
+class CDeleter
+{
+ int state_;
+
+ CDeleter(CDeleter&);
+ CDeleter& operator=(CDeleter&);
+public:
+
+ CDeleter() : state_(5) {}
+
+ int state() const {return state_;}
+ void set_state(int s) {state_ = s;}
+
+ void operator()(T* p) {delete p;}
+};
+
+int main()
+{
+ {
+ CDeleter<A> d;
+ std::unique_ptr<B[], CDeleter<A>&> s(new B, d);
+ A* p = s.get();
+ std::unique_ptr<A[], CDeleter<A>&> s2 = s;
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ d.set_state(6);
+ assert(s2.get_deleter().state() == d.state());
+ assert(s.get_deleter().state() == d.state());
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert07.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert07.fail.cpp
new file mode 100644
index 000000000000..24c646988f0a
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert07.fail.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+// test converting move ctor. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+// Explicit version
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ const std::unique_ptr<B[]> s(new B);
+ A* p = s.get();
+ std::unique_ptr<A[]> s2(s);
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert08.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert08.fail.cpp
new file mode 100644
index 000000000000..486d90825d9e
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert08.fail.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+// test converting move ctor. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+// Explicit version
+
+#include <memory>
+#include <cassert>
+
+#include "../../deleter.h"
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ const std::unique_ptr<B[], Deleter<B[]> > s(new B);
+ A* p = s.get();
+ std::unique_ptr<A[], Deleter<A[]> > s2(s);
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ assert(s2.get_deleter().state() == 5);
+ assert(s.get_deleter().state() == 0);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert09.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert09.fail.cpp
new file mode 100644
index 000000000000..e4cbef5c0560
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert09.fail.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+// test converting move ctor. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+// Explicit version
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+template <class T>
+class CDeleter
+{
+ int state_;
+
+ CDeleter(CDeleter&);
+ CDeleter& operator=(CDeleter&);
+public:
+
+ CDeleter() : state_(5) {}
+
+ int state() const {return state_;}
+ void set_state(int s) {state_ = s;}
+
+ void operator()(T* p) {delete p;}
+};
+
+int main()
+{
+ {
+ CDeleter<A> d;
+ const std::unique_ptr<B[], CDeleter<A>&> s(new B, d);
+ A* p = s.get();
+ std::unique_ptr<A[], CDeleter<A>&> s2(s);
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ d.set_state(6);
+ assert(s2.get_deleter().state() == d.state());
+ assert(s.get_deleter().state() == d.state());
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert10.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert10.fail.cpp
new file mode 100644
index 000000000000..73423d1b3751
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert10.fail.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+// test converting move ctor. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+// implicit version
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ const std::unique_ptr<B[]> s(new B);
+ A* p = s.get();
+ std::unique_ptr<A[]> s2 = s;
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert11.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert11.fail.cpp
new file mode 100644
index 000000000000..cfc097ba0b84
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert11.fail.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+// test converting move ctor. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+// Implicit version
+
+#include <memory>
+#include <cassert>
+
+#include "../../deleter.h"
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ const std::unique_ptr<B[], Deleter<B[]> > s(new B);
+ A* p = s.get();
+ std::unique_ptr<A[], Deleter<A[]> > s2 = s;
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ assert(s2.get_deleter().state() == 5);
+ assert(s.get_deleter().state() == 0);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert12.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert12.fail.cpp
new file mode 100644
index 000000000000..fdb088250b9f
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert12.fail.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+// test converting move ctor. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+// Explicit version
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+template <class T>
+class CDeleter
+{
+ int state_;
+
+ CDeleter(CDeleter&);
+ CDeleter& operator=(CDeleter&);
+public:
+
+ CDeleter() : state_(5) {}
+
+ int state() const {return state_;}
+ void set_state(int s) {state_ = s;}
+
+ void operator()(T* p) {delete p;}
+};
+
+int main()
+{
+ {
+ CDeleter<A> d;
+ const std::unique_ptr<B[], CDeleter<A>&> s(new B, d);
+ A* p = s.get();
+ std::unique_ptr<A[], CDeleter<A>&> s2 = s;
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ d.set_state(6);
+ assert(s2.get_deleter().state() == d.state());
+ assert(s.get_deleter().state() == d.state());
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert13.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert13.fail.cpp
new file mode 100644
index 000000000000..d9ef8e96fe8f
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert13.fail.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+// test converting move ctor. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+// Explicit version
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ std::unique_ptr<B[]> s(new B);
+ A* p = s.get();
+ std::unique_ptr<A[]> s2(std::move(s));
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert14.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert14.fail.cpp
new file mode 100644
index 000000000000..b4577a126c68
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert14.fail.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+// test converting move ctor. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+// Explicit version
+
+#include <memory>
+#include <cassert>
+
+#include "../../deleter.h"
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ std::unique_ptr<B[], Deleter<B[]> > s(new B);
+ A* p = s.get();
+ std::unique_ptr<A[], Deleter<A[]> > s2(std::move(s));
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ assert(s2.get_deleter().state() == 5);
+ assert(s.get_deleter().state() == 0);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert15.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert15.fail.cpp
new file mode 100644
index 000000000000..9325d07d0d0c
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert15.fail.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+// test converting move ctor. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+// Explicit version
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+template <class T>
+class CDeleter
+{
+ int state_;
+
+ CDeleter(CDeleter&);
+ CDeleter& operator=(CDeleter&);
+public:
+
+ CDeleter() : state_(5) {}
+
+ int state() const {return state_;}
+ void set_state(int s) {state_ = s;}
+
+ void operator()(T* p) {delete p;}
+};
+
+int main()
+{
+ {
+ CDeleter<A> d;
+ std::unique_ptr<B[], CDeleter<A>&> s(new B, d);
+ A* p = s.get();
+ std::unique_ptr<A[], CDeleter<A>&> s2(std::move(s));
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ d.set_state(6);
+ assert(s2.get_deleter().state() == d.state());
+ assert(s.get_deleter().state() == d.state());
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert16.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert16.fail.cpp
new file mode 100644
index 000000000000..b090e593ec62
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert16.fail.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+// test converting move ctor. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+// implicit version
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ std::unique_ptr<B[]> s(new B);
+ A* p = s.get();
+ std::unique_ptr<A[]> s2 = std::move(s);
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert17.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert17.fail.cpp
new file mode 100644
index 000000000000..b2af3c7a6938
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert17.fail.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+// test converting move ctor. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+// Implicit version
+
+#include <memory>
+#include <cassert>
+
+#include "../../deleter.h"
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ std::unique_ptr<B[], Deleter<B[]> > s(new B);
+ A* p = s.get();
+ std::unique_ptr<A[], Deleter<A[]> > s2 = std::move(s);
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ assert(s2.get_deleter().state() == 5);
+ assert(s.get_deleter().state() == 0);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert18.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert18.fail.cpp
new file mode 100644
index 000000000000..d1c0e8a781e6
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert18.fail.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+// test converting move ctor. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+// Explicit version
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+template <class T>
+class CDeleter
+{
+ int state_;
+
+ CDeleter(CDeleter&);
+ CDeleter& operator=(CDeleter&);
+public:
+
+ CDeleter() : state_(5) {}
+
+ int state() const {return state_;}
+ void set_state(int s) {state_ = s;}
+
+ void operator()(T* p) {delete p;}
+};
+
+int main()
+{
+ {
+ CDeleter<A> d;
+ std::unique_ptr<B[], CDeleter<A>&> s(new B, d);
+ A* p = s.get();
+ std::unique_ptr<A[], CDeleter<A>&> s2 = std::move(s);
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ d.set_state(6);
+ assert(s2.get_deleter().state() == d.state());
+ assert(s.get_deleter().state() == d.state());
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/nullptr.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/nullptr.pass.cpp
new file mode 100644
index 000000000000..9a8c17547bca
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/nullptr.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// unique_ptr(nullptr_t);
+
+#include <memory>
+#include <cassert>
+
+// default unique_ptr ctor should only require default Deleter ctor
+class Deleter
+{
+ int state_;
+
+ Deleter(Deleter&);
+ Deleter& operator=(Deleter&);
+
+public:
+ Deleter() : state_(5) {}
+
+ int state() const {return state_;}
+
+ void operator()(void*) {}
+};
+
+int main()
+{
+ {
+ std::unique_ptr<int[]> p(nullptr);
+ assert(p.get() == 0);
+ }
+ {
+ std::unique_ptr<int[], Deleter> p(nullptr);
+ assert(p.get() == 0);
+ assert(p.get_deleter().state() == 5);
+ }
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer01.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer01.fail.cpp
new file mode 100644
index 000000000000..4c3161150831
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer01.fail.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr<T[]>(pointer) ctor
+
+// unique_ptr<T[]>(pointer) ctor should require default Deleter ctor
+
+#include <memory>
+
+class Deleter
+{
+
+ Deleter() {}
+
+public:
+
+ Deleter(Deleter&) {}
+ Deleter& operator=(Deleter&) {}
+
+ void operator()(void*) const {}
+};
+
+int main()
+{
+ std::unique_ptr<int[], Deleter> p(new int);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer01.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer01.pass.cpp
new file mode 100644
index 000000000000..dab42f277411
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer01.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer) ctor
+
+// unique_ptr<T[]>(pointer) ctor should only require default Deleter ctor
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+class Deleter
+{
+ int state_;
+
+ Deleter(Deleter&);
+ Deleter& operator=(Deleter&);
+
+public:
+ Deleter() : state_(5) {}
+
+ int state() const {return state_;}
+
+ void operator()(A* p) {delete [] p;}
+};
+
+int main()
+{
+ {
+ A* p = new A[3];
+ assert(A::count == 3);
+ std::unique_ptr<A[]> s(p);
+ assert(s.get() == p);
+ }
+ assert(A::count == 0);
+ {
+ A* p = new A[3];
+ assert(A::count == 3);
+ std::unique_ptr<A[], Deleter> s(p);
+ assert(s.get() == p);
+ assert(s.get_deleter().state() == 5);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer02.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer02.fail.cpp
new file mode 100644
index 000000000000..af7f27f73fc5
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer02.fail.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr<T[]>(pointer) ctor
+
+#include <memory>
+
+// unique_ptr<T[]>(pointer) ctor should require non-reference Deleter ctor
+class Deleter
+{
+public:
+
+ void operator()(void*) {}
+};
+
+int main()
+{
+ std::unique_ptr<int[], Deleter&> p(new int);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer02.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer02.pass.cpp
new file mode 100644
index 000000000000..1afb1c32ce8c
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer02.pass.cpp
@@ -0,0 +1,95 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr<T[]>(pointer) ctor
+
+// unique_ptr<T[]>(pointer) ctor shouldn't require complete type
+
+#include <memory>
+#include <cassert>
+
+struct A;
+
+class Deleter
+{
+ int state_;
+
+ Deleter(Deleter&);
+ Deleter& operator=(Deleter&);
+
+public:
+ Deleter() : state_(5) {}
+
+ int state() const {return state_;}
+
+ void operator()(A* p);
+};
+
+void check(int i);
+
+template <class D = std::default_delete<A[]> >
+struct B
+{
+ std::unique_ptr<A[], D> a_;
+ explicit B(A*);
+ ~B();
+
+ A* get() const {return a_.get();}
+ D& get_deleter() {return a_.get_deleter();}
+};
+
+A* get();
+
+int main()
+{
+ {
+ A* p = get();
+ check(3);
+ B<> s(p);
+ assert(s.get() == p);
+ }
+ check(0);
+ {
+ A* p = get();
+ check(3);
+ B<Deleter> s(p);
+ assert(s.get() == p);
+ assert(s.get_deleter().state() == 5);
+ }
+ check(0);
+}
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+A* get() {return new A[3];}
+
+void Deleter::operator()(A* p) {delete [] p;}
+
+void check(int i)
+{
+ assert(A::count == i);
+}
+
+template <class D>
+B<D>::B(A* a) : a_(a) {}
+
+template <class D>
+B<D>::~B() {}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer03.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer03.fail.cpp
new file mode 100644
index 000000000000..31f7ce367e3d
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer03.fail.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr<T[]>(pointer) ctor
+
+// unique_ptr<T[]>(pointer) ctor should require non-pointer Deleter
+
+#include <memory>
+
+int main()
+{
+ std::unique_ptr<int[], void (*)(void*)> p(new int);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer04.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer04.fail.cpp
new file mode 100644
index 000000000000..591144f7aa58
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer04.fail.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer) ctor
+
+// unique_ptr(pointer) ctor should not work with derived pointers
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+class Deleter
+{
+ int state_;
+
+ Deleter(Deleter&);
+ Deleter& operator=(Deleter&);
+
+public:
+ Deleter() : state_(5) {}
+
+ int state() const {return state_;}
+
+ void operator()(A* p) {delete [] p;}
+};
+
+int main()
+{
+ {
+ B* p = new B[3];
+ std::unique_ptr<A[]> s(p);
+ }
+ {
+ B* p = new B[3];
+ std::unique_ptr<A[], Deleter> s(p);
+ }
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter01.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter01.pass.cpp
new file mode 100644
index 000000000000..2d62bccdce50
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter01.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer, deleter) ctor
+
+// unique_ptr(pointer, deleter()) only requires MoveConstructible deleter
+
+#include <memory>
+#include <cassert>
+
+#include "../../deleter.h"
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ A* p = new A[3];
+ assert(A::count == 3);
+ std::unique_ptr<A[], Deleter<A[]> > s(p, Deleter<A[]>());
+ assert(s.get() == p);
+ assert(s.get_deleter().state() == 0);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter02.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter02.pass.cpp
new file mode 100644
index 000000000000..914076b50f42
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter02.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer, deleter) ctor
+
+// unique_ptr(pointer, d) requires CopyConstructible deleter
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+class Deleter
+{
+ int state_;
+
+public:
+
+ Deleter() : state_(5) {}
+
+ int state() const {return state_;}
+ void set_state(int s) {state_ = s;}
+
+ void operator()(A* p) {delete [] p;}
+};
+
+int main()
+{
+ {
+ A* p = new A[3];
+ assert(A::count == 3);
+ Deleter d;
+ std::unique_ptr<A[], Deleter> s(p, d);
+ assert(s.get() == p);
+ assert(s.get_deleter().state() == 5);
+ d.set_state(6);
+ assert(s.get_deleter().state() == 5);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter03.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter03.pass.cpp
new file mode 100644
index 000000000000..a6f535f38f08
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter03.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer, deleter) ctor
+
+// unique_ptr<T[], D&>(pointer, d) does not requires CopyConstructible deleter
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+class Deleter
+{
+ int state_;
+
+ Deleter(const Deleter&);
+ Deleter& operator=(const Deleter&);
+public:
+
+ Deleter() : state_(5) {}
+
+ int state() const {return state_;}
+ void set_state(int s) {state_ = s;}
+
+ void operator()(A* p) {delete [] p;}
+};
+
+int main()
+{
+ {
+ A* p = new A[3];
+ assert(A::count == 3);
+ Deleter d;
+ std::unique_ptr<A[], Deleter&> s(p, d);
+ assert(s.get() == p);
+ assert(s.get_deleter().state() == 5);
+ d.set_state(6);
+ assert(s.get_deleter().state() == 6);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter04.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter04.fail.cpp
new file mode 100644
index 000000000000..b635d507b2ec
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter04.fail.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer, deleter) ctor
+
+// unique_ptr<T, const D&>(pointer, D()) should not compile
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+class Deleter
+{
+ int state_;
+
+public:
+
+ Deleter() : state_(5) {}
+
+ int state() const {return state_;}
+ void set_state(int s) {state_ = s;}
+
+ void operator()(A* p) const {delete [] p;}
+};
+
+int main()
+{
+ {
+ A* p = new A[3];
+ assert(A::count == 3);
+ std::unique_ptr<A[], const Deleter&> s(p, Deleter());
+ assert(s.get() == p);
+ assert(s.get_deleter().state() == 5);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter04.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter04.pass.cpp
new file mode 100644
index 000000000000..a4c917c1af76
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter04.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer, deleter) ctor
+
+// unique_ptr<T[], const D&>(pointer, d) does not requires CopyConstructible deleter
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+class Deleter
+{
+ int state_;
+
+ Deleter(const Deleter&);
+ Deleter& operator=(const Deleter&);
+public:
+
+ Deleter() : state_(5) {}
+
+ int state() const {return state_;}
+ void set_state(int s) {state_ = s;}
+
+ void operator()(A* p) const {delete [] p;}
+};
+
+int main()
+{
+ {
+ A* p = new A[3];
+ assert(A::count == 3);
+ Deleter d;
+ std::unique_ptr<A[], const Deleter&> s(p, d);
+ assert(s.get() == p);
+ assert(s.get_deleter().state() == 5);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter05.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter05.fail.cpp
new file mode 100644
index 000000000000..0e03a7da07fb
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter05.fail.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer, deleter) ctor
+
+// unique_ptr(pointer, deleter) should not work with derived pointers
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+class Deleter
+{
+ int state_;
+
+public:
+ Deleter() : state_(5) {}
+
+ int state() const {return state_;}
+
+ void operator()(A* p) {delete [] p;}
+};
+
+int main()
+{
+ B* p = new B[3];
+ std::unique_ptr<A[], Deleter> s(p, Deleter());
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/release.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/release.pass.cpp
new file mode 100644
index 000000000000..d79a4e396eed
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/release.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// test release
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+ std::unique_ptr<int[]> p(new int[3]);
+ int* i = p.get();
+ int* j = p.release();
+ assert(p.get() == 0);
+ assert(i == j);
+ delete [] j;
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/reset1.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/reset1.pass.cpp
new file mode 100644
index 000000000000..195d877bbb70
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/reset1.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// test reset
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ std::unique_ptr<A[]> p(new A[3]);
+ assert(A::count == 3);
+ A* i = p.get();
+ assert(i != nullptr);
+ p.reset();
+ assert(A::count == 0);
+ assert(p.get() == 0);
+ }
+ assert(A::count == 0);
+ {
+ std::unique_ptr<A[]> p(new A[4]);
+ assert(A::count == 4);
+ A* i = p.get();
+ assert(i != nullptr);
+ p.reset(new A[5]);
+ assert(A::count == 5);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/reset2.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/reset2.fail.cpp
new file mode 100644
index 000000000000..bca6cb2470ac
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/reset2.fail.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// test reset
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ std::unique_ptr<A[]> p(new A);
+ assert(A::count == 1);
+ assert(B::count == 0);
+ A* i = p.get();
+ p.reset(new B);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+ {
+ std::unique_ptr<A[]> p(new B);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ A* i = p.get();
+ p.reset(new B);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/swap.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/swap.pass.cpp
new file mode 100644
index 000000000000..e9754cc0f226
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/swap.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// test swap
+
+#include <memory>
+#include <cassert>
+
+#include "../../deleter.h"
+
+struct A
+{
+ int state_;
+ static int count;
+ A() : state_(0) {++count;}
+ explicit A(int i) : state_(i) {++count;}
+ A(const A& a) : state_(a.state_) {++count;}
+ A& operator=(const A& a) {state_ = a.state_; return *this;}
+ ~A() {--count;}
+
+ friend bool operator==(const A& x, const A& y)
+ {return x.state_ == y.state_;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ A* p1 = new A[3];
+ std::unique_ptr<A[], Deleter<A[]> > s1(p1, Deleter<A[]>(1));
+ A* p2 = new A[3];
+ std::unique_ptr<A[], Deleter<A[]> > s2(p2, Deleter<A[]>(2));
+ assert(s1.get() == p1);
+ assert(s1.get_deleter().state() == 1);
+ assert(s2.get() == p2);
+ assert(s2.get_deleter().state() == 2);
+ s1.swap(s2);
+ assert(s1.get() == p2);
+ assert(s1.get_deleter().state() == 2);
+ assert(s2.get() == p1);
+ assert(s2.get_deleter().state() == 1);
+ assert(A::count == 6);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/dereference.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/dereference.fail.cpp
new file mode 100644
index 000000000000..46ba1395bb85
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/dereference.fail.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// test op*()
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+ std::unique_ptr<int[]> p(new int(3));
+ assert(*p == 3);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/explicit_bool.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/explicit_bool.pass.cpp
new file mode 100644
index 000000000000..9ec9b9527e8a
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/explicit_bool.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// test op*()
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+ {
+ std::unique_ptr<int[]> p(new int [3]);
+ if (p)
+ ;
+ else
+ assert(false);
+ if (!p)
+ assert(false);
+ }
+ {
+ std::unique_ptr<int[]> p;
+ if (!p)
+ ;
+ else
+ assert(false);
+ if (p)
+ assert(false);
+ }
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/get.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/get.pass.cpp
new file mode 100644
index 000000000000..2ae0659adc26
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/get.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// test get
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+ int* p = new int[3];
+ std::unique_ptr<int[]> s(p);
+ assert(s.get() == p);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/get_deleter.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/get_deleter.pass.cpp
new file mode 100644
index 000000000000..4496740715a5
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/get_deleter.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// test get_deleter()
+
+#include <memory>
+#include <cassert>
+
+struct Deleter
+{
+ void operator()(void*) {}
+
+ int test() {return 5;}
+ int test() const {return 6;}
+};
+
+int main()
+{
+ {
+ std::unique_ptr<int[], Deleter> p;
+ assert(p.get_deleter().test() == 5);
+ }
+ {
+ const std::unique_ptr<int[], Deleter> p;
+ assert(p.get_deleter().test() == 6);
+ }
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/index.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/index.pass.cpp
new file mode 100644
index 000000000000..519eae688ec1
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/index.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// test op[](size_t)
+
+#include <memory>
+#include <cassert>
+
+class A
+{
+ int state_;
+ static int next_;
+public:
+ A() : state_(++next_) {}
+ int get() const {return state_;}
+
+ friend bool operator==(const A& x, int y)
+ {return x.state_ == y;}
+
+ A& operator=(int i) {state_ = i; return *this;}
+};
+
+int A::next_ = 0;
+
+int main()
+{
+ std::unique_ptr<A[]> p(new A[3]);
+ assert(p[0] == 1);
+ assert(p[1] == 2);
+ assert(p[2] == 3);
+ p[0] = 3;
+ p[1] = 2;
+ p[2] = 1;
+ assert(p[0] == 3);
+ assert(p[1] == 2);
+ assert(p[2] == 1);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/op_arrow.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/op_arrow.fail.cpp
new file mode 100644
index 000000000000..1c90ba76af39
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/op_arrow.fail.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// test op->()
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ int i_;
+
+ A() : i_(7) {}
+};
+
+int main()
+{
+ std::unique_ptr<A[]> p(new A);
+ assert(p->i_ == 7);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/pointer_type.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/pointer_type.pass.cpp
new file mode 100644
index 000000000000..8721062c6d02
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/pointer_type.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr::pointer type
+
+#include <memory>
+#include <type_traits>
+
+struct Deleter
+{
+ struct pointer {};
+};
+
+int main()
+{
+ {
+ typedef std::unique_ptr<int> P;
+ static_assert((std::is_same<P::pointer, int*>::value), "");
+ }
+ {
+ typedef std::unique_ptr<int, Deleter> P;
+ static_assert((std::is_same<P::pointer, Deleter::pointer>::value), "");
+ }
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move01.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move01.fail.cpp
new file mode 100644
index 000000000000..57724ae10a70
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move01.fail.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move assignment
+
+#include <memory>
+#include <cassert>
+
+// Can't copy from lvalue
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ std::unique_ptr<A> s(new A);
+ std::unique_ptr<A> s2;
+ s2 = s;
+ }
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move01.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move01.pass.cpp
new file mode 100644
index 000000000000..9535ed0295d4
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move01.pass.cpp
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move assignment
+
+// test move assignment. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+#include "../../deleter.h"
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ std::unique_ptr<A> s1(new A);
+ A* p = s1.get();
+ std::unique_ptr<A> s2(new A);
+ assert(A::count == 2);
+ s2 = std::move(s1);
+ assert(A::count == 1);
+ assert(s2.get() == p);
+ assert(s1.get() == 0);
+ }
+ assert(A::count == 0);
+ {
+ std::unique_ptr<A, Deleter<A> > s1(new A, Deleter<A>(5));
+ A* p = s1.get();
+ std::unique_ptr<A, Deleter<A> > s2(new A);
+ assert(A::count == 2);
+ s2 = std::move(s1);
+ assert(s2.get() == p);
+ assert(s1.get() == 0);
+ assert(A::count == 1);
+ assert(s2.get_deleter().state() == 5);
+ assert(s1.get_deleter().state() == 0);
+ }
+ assert(A::count == 0);
+ {
+ CDeleter<A> d1(5);
+ std::unique_ptr<A, CDeleter<A>&> s1(new A, d1);
+ A* p = s1.get();
+ CDeleter<A> d2(6);
+ std::unique_ptr<A, CDeleter<A>&> s2(new A, d2);
+ s2 = std::move(s1);
+ assert(s2.get() == p);
+ assert(s1.get() == 0);
+ assert(A::count == 1);
+ assert(d1.state() == 5);
+ assert(d2.state() == 5);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move02.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move02.fail.cpp
new file mode 100644
index 000000000000..5046fd8aae6b
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move02.fail.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move assignment
+
+#include <memory>
+#include <cassert>
+
+// Can't copy from const lvalue
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ const std::unique_ptr<A> s(new A);
+ std::unique_ptr<A> s2;
+ s2 = s;
+ }
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move03.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move03.fail.cpp
new file mode 100644
index 000000000000..aa4fdb8a96b1
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move03.fail.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move assignment
+
+#include <memory>
+#include <cassert>
+
+// Can't copy from lvalue
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+class Deleter
+{
+ int state_;
+
+public:
+
+ Deleter() : state_(5) {}
+
+ int state() const {return state_;}
+
+ void operator()(A* p) {delete p;}
+};
+
+int main()
+{
+ {
+ std::unique_ptr<A, Deleter> s(new A);
+ A* p = s.get();
+ std::unique_ptr<A, Deleter> s2;
+ s2 = s;
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move04.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move04.fail.cpp
new file mode 100644
index 000000000000..e0d7c891c80f
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move04.fail.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move ctor
+
+#include <memory>
+#include <cassert>
+
+// test move ctor. Can't copy from const lvalue
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+class Deleter
+{
+ int state_;
+
+public:
+
+ Deleter() : state_(5) {}
+
+ int state() const {return state_;}
+
+ void operator()(A* p) {delete p;}
+};
+
+int main()
+{
+ {
+ const std::unique_ptr<A, Deleter> s(new A);
+ A* p = s.get();
+ std::unique_ptr<A, Deleter> s2;
+ s2 = s;
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert01.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert01.fail.cpp
new file mode 100644
index 000000000000..3fd2cbc42bd6
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert01.fail.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+// Can't assign from lvalue
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ std::unique_ptr<B> s(new B);
+ A* p = s.get();
+ std::unique_ptr<A> s2;
+ s2 = s;
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert01.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert01.pass.cpp
new file mode 100644
index 000000000000..989f594e38b8
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert01.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ std::unique_ptr<B> s(new B);
+ A* p = s.get();
+ std::unique_ptr<A> s2(new A);
+ assert(A::count == 2);
+ s2 = std::move(s);
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert02.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert02.fail.cpp
new file mode 100644
index 000000000000..0f900603e239
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert02.fail.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+#include "../../deleter.h"
+
+// Can't assign from lvalue
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ std::unique_ptr<B, Deleter<B> > s(new B);
+ A* p = s.get();
+ std::unique_ptr<A, Deleter<A> > s2;
+ s2 = s;
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ assert(s2.get_deleter().state() == 5);
+ assert(s.get_deleter().state() == 0);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert02.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert02.pass.cpp
new file mode 100644
index 000000000000..a448c77a66a7
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert02.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+#include "../../deleter.h"
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ std::unique_ptr<B, Deleter<B> > s(new B, Deleter<B>(5));
+ A* p = s.get();
+ std::unique_ptr<A, Deleter<A> > s2(new A);
+ assert(A::count == 2);
+ s2 = std::move(s);
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ assert(s2.get_deleter().state() == 5);
+ assert(s.get_deleter().state() == 0);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert03.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert03.fail.cpp
new file mode 100644
index 000000000000..f35af9f453ff
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert03.fail.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+// Can't assign from lvalue
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+#include "../../deleter.h"
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ Deleter<B> db(5);
+ std::unique_ptr<B, Deleter<B>&> s(new B, db);
+ A* p = s.get();
+ Deleter<A> da(6);
+ std::unique_ptr<A, Deleter<A>&> s2(new A, da);
+ s2 = s;
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ assert(s2.get_deleter().state() == 5);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert03.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert03.pass.cpp
new file mode 100644
index 000000000000..9aea81a8b144
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert03.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+// test converting move assignment with reference deleters
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+#include "../../deleter.h"
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ CDeleter<B> db(5);
+ std::unique_ptr<B, CDeleter<B>&> s(new B, db);
+ A* p = s.get();
+ CDeleter<A> da(6);
+ std::unique_ptr<A, CDeleter<A>&> s2(new A, da);
+ s2 = std::move(s);
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ assert(s.get_deleter().state() == 5);
+ assert(s2.get_deleter().state() == 5);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert04.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert04.fail.cpp
new file mode 100644
index 000000000000..dba901b2ce17
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert04.fail.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+// Can't assign from const lvalue
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ const std::unique_ptr<B> s(new B);
+ A* p = s.get();
+ std::unique_ptr<A> s2;
+ s2 = s;
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert05.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert05.fail.cpp
new file mode 100644
index 000000000000..4694986c6773
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert05.fail.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+// Can't assign from const lvalue
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+#include "../../deleter.h"
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ const std::unique_ptr<B, Deleter<B> > s(new B);
+ A* p = s.get();
+ std::unique_ptr<A, Deleter<A> > s2;
+ s2 = s;
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ assert(s2.get_deleter().state() == 5);
+ assert(s.get_deleter().state() == 0);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert06.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert06.fail.cpp
new file mode 100644
index 000000000000..220677cd6fa7
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert06.fail.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+// Can't assign from const lvalue
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+#include "../../deleter.h"
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ Deleter<B> db(5);
+ const std::unique_ptr<B, Deleter<B>&> s(new B, db);
+ A* p = s.get();
+ Deleter<A> da(6);
+ std::unique_ptr<A, Deleter<A>&> s2(new A, da);
+ s2 = s;
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ assert(s2.get_deleter().state() == 5);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert13.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert13.fail.cpp
new file mode 100644
index 000000000000..56ab43c7de24
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert13.fail.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+// Do not convert from an array unique_ptr
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+struct A
+{
+};
+
+struct Deleter
+{
+ void operator()(void*) {}
+};
+
+int main()
+{
+ std::unique_ptr<A[], Deleter> s;
+ std::unique_ptr<A, Deleter> s2;
+ s2 = std::move(s);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/null.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/null.pass.cpp
new file mode 100644
index 000000000000..e2d7956cda64
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/null.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move assignment
+
+#include <memory>
+#include <cassert>
+
+// test assignment from null
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ std::unique_ptr<A> s2(new A);
+ assert(A::count == 1);
+ s2 = 0;
+ assert(A::count == 0);
+ assert(s2.get() == 0);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/nullptr.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/nullptr.pass.cpp
new file mode 100644
index 000000000000..fb1584951993
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/nullptr.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move assignment
+
+#include <memory>
+#include <cassert>
+
+// test assignment from null
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ std::unique_ptr<A> s2(new A);
+ assert(A::count == 1);
+ s2 = nullptr;
+ assert(A::count == 0);
+ assert(s2.get() == 0);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer.pass.cpp
new file mode 100644
index 000000000000..1ce1838afbb7
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer) ctor
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+// template <class U> explicit unique_ptr(auto_ptr<U>&);
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ B* p = new B;
+ std::auto_ptr<B> ap(p);
+ std::unique_ptr<A> up(std::move(ap));
+ assert(up.get() == p);
+ assert(ap.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+ {
+ B* p = new B;
+ std::auto_ptr<B> ap(p);
+ std::unique_ptr<A> up;
+ up = std::move(ap);
+ assert(up.get() == p);
+ assert(ap.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer01.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer01.fail.cpp
new file mode 100644
index 000000000000..1f317c782454
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer01.fail.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer) ctor
+
+#include <memory>
+#include <cassert>
+
+// template <class U> explicit unique_ptr(auto_ptr<U>&);
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+// : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ B* p = new B;
+ std::auto_ptr<B> ap(p);
+ std::unique_ptr<A> up(ap);
+ assert(up.get() == p);
+ assert(ap.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+ {
+ B* p = new B;
+ std::auto_ptr<B> ap(p);
+ std::unique_ptr<A> up;
+ up = ap;
+ assert(up.get() == p);
+ assert(ap.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer02.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer02.fail.cpp
new file mode 100644
index 000000000000..2dd5ea30049b
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer02.fail.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer) ctor
+
+#include <memory>
+#include <cassert>
+
+// template <class U> explicit unique_ptr(auto_ptr<U>&);
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+struct Deleter
+{
+ template <class T>
+ void operator()(T*) {}
+};
+
+int main()
+{
+ {
+ B* p = new B;
+ std::auto_ptr<B> ap(p);
+ std::unique_ptr<A, Deleter> up(ap);
+ assert(up.get() == p);
+ assert(ap.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default01.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default01.fail.cpp
new file mode 100644
index 000000000000..2ffe1be190e0
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default01.fail.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr default ctor
+
+#include <memory>
+
+// default unique_ptr ctor should require default Deleter ctor
+class Deleter
+{
+
+ Deleter() {}
+
+public:
+
+ Deleter(Deleter&) {}
+ Deleter& operator=(Deleter&) {}
+
+ void operator()(void*) const {}
+};
+
+int main()
+{
+ std::unique_ptr<int, Deleter> p;
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default01.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default01.pass.cpp
new file mode 100644
index 000000000000..e63db5cb7185
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default01.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr default ctor
+
+#include <memory>
+#include <cassert>
+
+// default unique_ptr ctor should only require default Deleter ctor
+class Deleter
+{
+ int state_;
+
+ Deleter(Deleter&);
+ Deleter& operator=(Deleter&);
+
+public:
+ Deleter() : state_(5) {}
+
+ int state() const {return state_;}
+
+ void operator()(void*) {}
+};
+
+int main()
+{
+ {
+ std::unique_ptr<int> p;
+ assert(p.get() == 0);
+ }
+ {
+ std::unique_ptr<int, Deleter> p;
+ assert(p.get() == 0);
+ assert(p.get_deleter().state() == 5);
+ }
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default02.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default02.fail.cpp
new file mode 100644
index 000000000000..690750143414
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default02.fail.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr default ctor
+
+#include <memory>
+
+// default unique_ptr ctor should require non-reference Deleter ctor
+class Deleter
+{
+public:
+
+ void operator()(void*) {}
+};
+
+int main()
+{
+ std::unique_ptr<int, Deleter&> p;
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default02.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default02.pass.cpp
new file mode 100644
index 000000000000..e9af7e285255
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default02.pass.cpp
@@ -0,0 +1,84 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test default unique_ptr ctor
+
+#include <memory>
+#include <cassert>
+
+// default unique_ptr ctor shouldn't require complete type
+
+struct A;
+
+class Deleter
+{
+ int state_;
+
+ Deleter(Deleter&);
+ Deleter& operator=(Deleter&);
+
+public:
+ Deleter() : state_(5) {}
+
+ int state() const {return state_;}
+
+ void operator()(A* p);
+};
+
+void check(int i);
+
+template <class D = std::default_delete<A> >
+struct B
+{
+ std::unique_ptr<A, D> a_;
+ B() {}
+ ~B();
+
+ A* get() const {return a_.get();}
+ D& get_deleter() {return a_.get_deleter();}
+};
+
+int main()
+{
+ {
+ B<> s;
+ assert(s.get() == 0);
+ }
+ check(0);
+ {
+ B<Deleter> s;
+ assert(s.get() == 0);
+ assert(s.get_deleter().state() == 5);
+ }
+ check(0);
+}
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+void Deleter::operator()(A* p) {delete p;}
+
+void check(int i)
+{
+ assert(A::count == i);
+}
+
+template <class D>
+B<D>::~B() {}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default03.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default03.fail.cpp
new file mode 100644
index 000000000000..78f6e73a1d55
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default03.fail.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr default ctor
+
+#include <memory>
+
+// default unique_ptr ctor should require non-pointer Deleter
+
+int main()
+{
+ std::unique_ptr<int, void (*)(void*)> p;
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move01.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move01.fail.cpp
new file mode 100644
index 000000000000..68ad589b1148
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move01.fail.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move ctor
+
+#include <memory>
+#include <cassert>
+
+// test move ctor. Can't copy from lvalue
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ std::unique_ptr<A> s(new A);
+ A* p = s.get();
+ std::unique_ptr<A> s2 = s;
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move01.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move01.pass.cpp
new file mode 100644
index 000000000000..dc16c3115376
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move01.pass.cpp
@@ -0,0 +1,142 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move ctor
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+// test move ctor. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+template <class T>
+class Deleter
+{
+ int state_;
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ Deleter(const Deleter&);
+ Deleter& operator=(const Deleter&);
+#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ Deleter(Deleter&);
+ Deleter& operator=(Deleter&);
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+public:
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ Deleter(Deleter&& r) : state_(r.state_) {r.state_ = 0;}
+ Deleter& operator=(Deleter&& r)
+ {
+ state_ = r.state_;
+ r.state_ = 0;
+ return *this;
+ }
+#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ operator std::__rv<Deleter>() {return std::__rv<Deleter>(*this);}
+ Deleter(std::__rv<Deleter> r) : state_(r->state_) {r->state_ = 0;}
+ Deleter& operator=(std::__rv<Deleter> r)
+ {
+ state_ = r->state_;
+ r->state_ = 0;
+ return *this;
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+ Deleter() : state_(5) {}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ template <class U>
+ Deleter(Deleter<U>&& d,
+ typename std::enable_if<!std::is_same<U, T>::value>::type* = 0)
+ : state_(d.state()) {d.set_state(0);}
+
+private:
+ template <class U>
+ Deleter(const Deleter<U>& d,
+ typename std::enable_if<!std::is_same<U, T>::value>::type* = 0);
+#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ template <class U>
+ Deleter(Deleter<U> d,
+ typename std::enable_if<!std::is_same<U, T>::value>::type* = 0)
+ : state_(d.state()) {}
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+public:
+ int state() const {return state_;}
+ void set_state(int i) {state_ = i;}
+
+ void operator()(T* p) {delete p;}
+};
+
+class CDeleter
+{
+ int state_;
+
+ CDeleter(CDeleter&);
+ CDeleter& operator=(CDeleter&);
+public:
+
+ CDeleter() : state_(5) {}
+
+ int state() const {return state_;}
+ void set_state(int s) {state_ = s;}
+
+ void operator()(A* p) {delete p;}
+};
+
+int main()
+{
+ {
+ std::unique_ptr<A> s(new A);
+ A* p = s.get();
+ std::unique_ptr<A> s2 = std::move(s);
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ }
+ assert(A::count == 0);
+ {
+ std::unique_ptr<A, Deleter<A> > s(new A);
+ A* p = s.get();
+ std::unique_ptr<A, Deleter<A> > s2 = std::move(s);
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(s2.get_deleter().state() == 5);
+ assert(s.get_deleter().state() == 0);
+ }
+ assert(A::count == 0);
+ {
+ CDeleter d;
+ std::unique_ptr<A, CDeleter&> s(new A, d);
+ A* p = s.get();
+ std::unique_ptr<A, CDeleter&> s2 = std::move(s);
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ d.set_state(6);
+ assert(s2.get_deleter().state() == d.state());
+ assert(s.get_deleter().state() == d.state());
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move02.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move02.fail.cpp
new file mode 100644
index 000000000000..897b889d6778
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move02.fail.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move ctor
+
+#include <memory>
+#include <cassert>
+
+// test move ctor. Can't copy from const lvalue
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ const std::unique_ptr<A> s(new A);
+ A* p = s.get();
+ std::unique_ptr<A> s2 = s;
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move02.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move02.pass.cpp
new file mode 100644
index 000000000000..4b997df95a0b
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move02.pass.cpp
@@ -0,0 +1,143 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move ctor
+
+#include <memory>
+#include <cassert>
+
+// test move ctor. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+template <class T>
+class Deleter
+{
+ int state_;
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ Deleter(const Deleter&);
+ Deleter& operator=(const Deleter&);
+#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ Deleter(Deleter&);
+ Deleter& operator=(Deleter&);
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+public:
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ Deleter(Deleter&& r) : state_(r.state_) {r.state_ = 0;}
+ Deleter& operator=(Deleter&& r)
+ {
+ state_ = r.state_;
+ r.state_ = 0;
+ return *this;
+ }
+#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ operator std::__rv<Deleter>() {return std::__rv<Deleter>(*this);}
+ Deleter(std::__rv<Deleter> r) : state_(r->state_) {r->state_ = 0;}
+ Deleter& operator=(std::__rv<Deleter> r)
+ {
+ state_ = r->state_;
+ r->state_ = 0;
+ return *this;
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+ Deleter() : state_(5) {}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ template <class U>
+ Deleter(Deleter<U>&& d,
+ typename std::enable_if<!std::is_same<U, T>::value>::type* = 0)
+ : state_(d.state()) {d.set_state(0);}
+
+private:
+ template <class U>
+ Deleter(const Deleter<U>& d,
+ typename std::enable_if<!std::is_same<U, T>::value>::type* = 0);
+#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ template <class U>
+ Deleter(Deleter<U> d,
+ typename std::enable_if<!std::is_same<U, T>::value>::type* = 0)
+ : state_(d.state()) {}
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+public:
+ int state() const {return state_;}
+ void set_state(int i) {state_ = i;}
+
+ void operator()(T* p) {delete p;}
+};
+
+class CDeleter
+{
+ int state_;
+
+ CDeleter(CDeleter&);
+ CDeleter& operator=(CDeleter&);
+public:
+
+ CDeleter() : state_(5) {}
+
+ int state() const {return state_;}
+ void set_state(int s) {state_ = s;}
+
+ void operator()(A* p) {delete p;}
+};
+
+std::unique_ptr<A>
+source1()
+{
+ return std::unique_ptr<A>(new A);
+}
+
+void sink1(std::unique_ptr<A> p)
+{
+}
+
+std::unique_ptr<A, Deleter<A> >
+source2()
+{
+ return std::unique_ptr<A, Deleter<A> >(new A);
+}
+
+void sink2(std::unique_ptr<A, Deleter<A> > p)
+{
+}
+
+std::unique_ptr<A, CDeleter&>
+source3()
+{
+ static CDeleter d;
+ return std::unique_ptr<A, CDeleter&>(new A, d);
+}
+
+void sink3(std::unique_ptr<A, CDeleter&> p)
+{
+}
+
+int main()
+{
+ sink1(source1());
+ sink2(source2());
+ sink3(source3());
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move03.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move03.fail.cpp
new file mode 100644
index 000000000000..7fb1a0a74811
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move03.fail.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move ctor
+
+#include <memory>
+#include <cassert>
+
+// test move ctor. Can't copy from lvalue
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+class Deleter
+{
+ int state_;
+
+public:
+
+ Deleter() : state_(5) {}
+
+ int state() const {return state_;}
+
+ void operator()(A* p) {delete p;}
+};
+
+int main()
+{
+ {
+ std::unique_ptr<A, Deleter> s(new A);
+ A* p = s.get();
+ std::unique_ptr<A, Deleter> s2 = s;
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move04.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move04.fail.cpp
new file mode 100644
index 000000000000..671e343fd7f5
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move04.fail.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move ctor
+
+#include <memory>
+#include <cassert>
+
+// test move ctor. Can't copy from const lvalue
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+class Deleter
+{
+ int state_;
+
+public:
+
+ Deleter() : state_(5) {}
+
+ int state() const {return state_;}
+
+ void operator()(A* p) {delete p;}
+};
+
+int main()
+{
+ {
+ const std::unique_ptr<A, Deleter> s(new A);
+ A* p = s.get();
+ std::unique_ptr<A, Deleter> s2 = s;
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert01.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert01.fail.cpp
new file mode 100644
index 000000000000..ed1fe8c2bdd4
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert01.fail.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+// Can't construct from lvalue
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ std::unique_ptr<B> s(new B);
+ A* p = s.get();
+ std::unique_ptr<A> s2(s);
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert01.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert01.pass.cpp
new file mode 100644
index 000000000000..b65cf564a925
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert01.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+// test converting move ctor. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+// Explicit version
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ std::unique_ptr<B> s(new B);
+ A* p = s.get();
+ std::unique_ptr<A> s2(std::move(s));
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert02.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert02.fail.cpp
new file mode 100644
index 000000000000..a1bf634b9995
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert02.fail.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+// test converting move ctor. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+// Explicit version
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+#include "../../deleter.h"
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ std::unique_ptr<B, Deleter<B> > s(new B);
+ A* p = s.get();
+ std::unique_ptr<A, Deleter<A> > s2(s);
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ assert(s2.get_deleter().state() == 5);
+ assert(s.get_deleter().state() == 0);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert02.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert02.pass.cpp
new file mode 100644
index 000000000000..829e7553acd9
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert02.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+#include "../../deleter.h"
+
+// test converting move ctor. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+// Explicit version
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ std::unique_ptr<B, Deleter<B> > s(new B, Deleter<B>(5));
+ A* p = s.get();
+ std::unique_ptr<A, Deleter<A> > s2(std::move(s));
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ assert(s2.get_deleter().state() == 5);
+ assert(s.get_deleter().state() == 0);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert03.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert03.fail.cpp
new file mode 100644
index 000000000000..7409199791b5
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert03.fail.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+// test converting move ctor. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+// Explicit version
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+template <class T>
+class CDeleter
+{
+ int state_;
+
+ CDeleter(CDeleter&);
+ CDeleter& operator=(CDeleter&);
+public:
+
+ CDeleter() : state_(5) {}
+
+ int state() const {return state_;}
+ void set_state(int s) {state_ = s;}
+
+ void operator()(T* p) {delete p;}
+};
+
+int main()
+{
+ {
+ CDeleter<A> d;
+ std::unique_ptr<B, CDeleter<A>&> s(new B, d);
+ A* p = s.get();
+ std::unique_ptr<A, CDeleter<A>&> s2(s);
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ d.set_state(6);
+ assert(s2.get_deleter().state() == d.state());
+ assert(s.get_deleter().state() == d.state());
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert03.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert03.pass.cpp
new file mode 100644
index 000000000000..792076a95245
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert03.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+// test converting move ctor. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+// Explicit version
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+template <class T>
+class CDeleter
+{
+ int state_;
+
+ CDeleter(CDeleter&);
+ CDeleter& operator=(CDeleter&);
+public:
+
+ CDeleter() : state_(5) {}
+
+ int state() const {return state_;}
+ void set_state(int s) {state_ = s;}
+
+ void operator()(T* p) {delete p;}
+};
+
+int main()
+{
+ {
+ CDeleter<A> d;
+ std::unique_ptr<B, CDeleter<A>&> s(new B, d);
+ A* p = s.get();
+ std::unique_ptr<A, CDeleter<A>&> s2(std::move(s));
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ d.set_state(6);
+ assert(s2.get_deleter().state() == d.state());
+ assert(s.get_deleter().state() == d.state());
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert04.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert04.fail.cpp
new file mode 100644
index 000000000000..981ea706eb29
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert04.fail.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+// test converting move ctor. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+// implicit version
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ std::unique_ptr<B> s(new B);
+ A* p = s.get();
+ std::unique_ptr<A> s2 = s;
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert04.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert04.pass.cpp
new file mode 100644
index 000000000000..12ab17fadcd3
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert04.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+// test converting move ctor. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+// implicit version
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ std::unique_ptr<B> s(new B);
+ A* p = s.get();
+ std::unique_ptr<A> s2 = std::move(s);
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert05.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert05.fail.cpp
new file mode 100644
index 000000000000..d055b80627f9
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert05.fail.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+#include "../../deleter.h"
+
+// test converting move ctor. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+// Implicit version
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ std::unique_ptr<B, Deleter<B> > s(new B);
+ std::unique_ptr<A, Deleter<A> > s2 = s;
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert05.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert05.pass.cpp
new file mode 100644
index 000000000000..8077b0dacb23
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert05.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+#include "../../deleter.h"
+
+// test converting move ctor. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+// Implicit version
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ std::unique_ptr<B, Deleter<B> > s(new B, Deleter<B>(5));
+ A* p = s.get();
+ std::unique_ptr<A, Deleter<A> > s2 = std::move(s);
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ assert(s2.get_deleter().state() == 5);
+ assert(s.get_deleter().state() == 0);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert06.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert06.fail.cpp
new file mode 100644
index 000000000000..5b9b12e0d60b
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert06.fail.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+// test converting move ctor. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+// Explicit version
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+template <class T>
+class CDeleter
+{
+ int state_;
+
+ CDeleter(CDeleter&);
+ CDeleter& operator=(CDeleter&);
+public:
+
+ CDeleter() : state_(5) {}
+
+ int state() const {return state_;}
+ void set_state(int s) {state_ = s;}
+
+ void operator()(T* p) {delete p;}
+};
+
+int main()
+{
+ {
+ CDeleter<A> d;
+ std::unique_ptr<B, CDeleter<A>&> s(new B, d);
+ A* p = s.get();
+ std::unique_ptr<A, CDeleter<A>&> s2 = s;
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ d.set_state(6);
+ assert(s2.get_deleter().state() == d.state());
+ assert(s.get_deleter().state() == d.state());
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert06.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert06.pass.cpp
new file mode 100644
index 000000000000..4115107b85f9
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert06.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+// test converting move ctor. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+// Explicit version
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+template <class T>
+class CDeleter
+{
+ int state_;
+
+ CDeleter(CDeleter&);
+ CDeleter& operator=(CDeleter&);
+public:
+
+ CDeleter() : state_(5) {}
+
+ int state() const {return state_;}
+ void set_state(int s) {state_ = s;}
+
+ void operator()(T* p) {delete p;}
+};
+
+int main()
+{
+ {
+ CDeleter<A> d;
+ std::unique_ptr<B, CDeleter<A>&> s(new B, d);
+ A* p = s.get();
+ std::unique_ptr<A, CDeleter<A>&> s2 = std::move(s);
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ d.set_state(6);
+ assert(s2.get_deleter().state() == d.state());
+ assert(s.get_deleter().state() == d.state());
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert07.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert07.fail.cpp
new file mode 100644
index 000000000000..bef022cfc143
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert07.fail.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+// test converting move ctor. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+// Explicit version
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ const std::unique_ptr<B> s(new B);
+ A* p = s.get();
+ std::unique_ptr<A> s2(s);
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert07.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert07.pass.cpp
new file mode 100644
index 000000000000..978cb0e9024b
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert07.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+#include "../../deleter.h"
+
+// test converting move ctor. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+// Implicit version
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ CDeleter<B> b(5);
+ std::unique_ptr<B, CDeleter<B>&> s(new B, b);
+ A* p = s.get();
+ std::unique_ptr<A, CDeleter<A> > s2 = std::move(s);
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ assert(s2.get_deleter().state() == 5);
+ assert(s.get_deleter().state() == 5);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert08.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert08.fail.cpp
new file mode 100644
index 000000000000..e14bba0763c5
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert08.fail.cpp
@@ -0,0 +1,118 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+// test converting move ctor. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+// Explicit version
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+template <class T>
+class Deleter
+{
+ int state_;
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ Deleter(const Deleter&);
+ Deleter& operator=(const Deleter&);
+#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ Deleter(Deleter&);
+ Deleter& operator=(Deleter&);
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+public:
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ Deleter(Deleter&& r) : state_(r.state_) {r.state_ = 0;}
+ Deleter& operator=(Deleter&& r)
+ {
+ state_ = r.state_;
+ r.state_ = 0;
+ return *this;
+ }
+#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ operator std::__rv<Deleter>() {return std::__rv<Deleter>(*this);}
+ Deleter(std::__rv<Deleter> r) : state_(r->state_) {r->state_ = 0;}
+ Deleter& operator=(std::__rv<Deleter> r)
+ {
+ state_ = r->state_;
+ r->state_ = 0;
+ return *this;
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+ Deleter() : state_(5) {}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ template <class U>
+ Deleter(Deleter<U>&& d,
+ typename std::enable_if<!std::is_same<U, T>::value>::type* = 0)
+ : state_(d.state()) {d.set_state(0);}
+
+private:
+ template <class U>
+ Deleter(const Deleter<U>& d,
+ typename std::enable_if<!std::is_same<U, T>::value>::type* = 0);
+#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ template <class U>
+ Deleter(Deleter<U> d,
+ typename std::enable_if<!std::is_same<U, T>::value>::type* = 0)
+ : state_(d.state()) {}
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+public:
+ int state() const {return state_;}
+ void set_state(int i) {state_ = i;}
+
+ void operator()(T* p) {delete p;}
+};
+
+int main()
+{
+ {
+ const std::unique_ptr<B, Deleter<B> > s(new B);
+ A* p = s.get();
+ std::unique_ptr<A, Deleter<A> > s2(s);
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ assert(s2.get_deleter().state() == 5);
+ assert(s.get_deleter().state() == 0);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert09.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert09.fail.cpp
new file mode 100644
index 000000000000..a475c17547c9
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert09.fail.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+// test converting move ctor. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+// Explicit version
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+template <class T>
+class CDeleter
+{
+ int state_;
+
+ CDeleter(CDeleter&);
+ CDeleter& operator=(CDeleter&);
+public:
+
+ CDeleter() : state_(5) {}
+
+ int state() const {return state_;}
+ void set_state(int s) {state_ = s;}
+
+ void operator()(T* p) {delete p;}
+};
+
+int main()
+{
+ {
+ CDeleter<A> d;
+ const std::unique_ptr<B, CDeleter<A>&> s(new B, d);
+ A* p = s.get();
+ std::unique_ptr<A, CDeleter<A>&> s2(s);
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ d.set_state(6);
+ assert(s2.get_deleter().state() == d.state());
+ assert(s.get_deleter().state() == d.state());
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert10.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert10.fail.cpp
new file mode 100644
index 000000000000..f0da5efb6917
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert10.fail.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+// test converting move ctor. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+// implicit version
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ const std::unique_ptr<B> s(new B);
+ A* p = s.get();
+ std::unique_ptr<A> s2 = s;
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert11.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert11.fail.cpp
new file mode 100644
index 000000000000..bcf94a978144
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert11.fail.cpp
@@ -0,0 +1,118 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+// test converting move ctor. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+// Implicit version
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+template <class T>
+class Deleter
+{
+ int state_;
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ Deleter(const Deleter&);
+ Deleter& operator=(const Deleter&);
+#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ Deleter(Deleter&);
+ Deleter& operator=(Deleter&);
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+public:
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ Deleter(Deleter&& r) : state_(r.state_) {r.state_ = 0;}
+ Deleter& operator=(Deleter&& r)
+ {
+ state_ = r.state_;
+ r.state_ = 0;
+ return *this;
+ }
+#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ operator std::__rv<Deleter>() {return std::__rv<Deleter>(*this);}
+ Deleter(std::__rv<Deleter> r) : state_(r->state_) {r->state_ = 0;}
+ Deleter& operator=(std::__rv<Deleter> r)
+ {
+ state_ = r->state_;
+ r->state_ = 0;
+ return *this;
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+ Deleter() : state_(5) {}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ template <class U>
+ Deleter(Deleter<U>&& d,
+ typename std::enable_if<!std::is_same<U, T>::value>::type* = 0)
+ : state_(d.state()) {d.set_state(0);}
+
+private:
+ template <class U>
+ Deleter(const Deleter<U>& d,
+ typename std::enable_if<!std::is_same<U, T>::value>::type* = 0);
+#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ template <class U>
+ Deleter(Deleter<U> d,
+ typename std::enable_if<!std::is_same<U, T>::value>::type* = 0)
+ : state_(d.state()) {}
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+public:
+ int state() const {return state_;}
+ void set_state(int i) {state_ = i;}
+
+ void operator()(T* p) {delete p;}
+};
+
+int main()
+{
+ {
+ const std::unique_ptr<B, Deleter<B> > s(new B);
+ A* p = s.get();
+ std::unique_ptr<A, Deleter<A> > s2 = s;
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ assert(s2.get_deleter().state() == 5);
+ assert(s.get_deleter().state() == 0);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert12.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert12.fail.cpp
new file mode 100644
index 000000000000..095bec65669b
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert12.fail.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+// test converting move ctor. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+// Explicit version
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+template <class T>
+class CDeleter
+{
+ int state_;
+
+ CDeleter(CDeleter&);
+ CDeleter& operator=(CDeleter&);
+public:
+
+ CDeleter() : state_(5) {}
+
+ int state() const {return state_;}
+ void set_state(int s) {state_ = s;}
+
+ void operator()(T* p) {delete p;}
+};
+
+int main()
+{
+ {
+ CDeleter<A> d;
+ const std::unique_ptr<B, CDeleter<A>&> s(new B, d);
+ A* p = s.get();
+ std::unique_ptr<A, CDeleter<A>&> s2 = s;
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ d.set_state(6);
+ assert(s2.get_deleter().state() == d.state());
+ assert(s.get_deleter().state() == d.state());
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert13.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert13.fail.cpp
new file mode 100644
index 000000000000..a4bd2cba1cef
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert13.fail.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+// Do not convert from an array unique_ptr
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+struct A
+{
+};
+
+struct Deleter
+{
+ void operator()(void*) {}
+};
+
+int main()
+{
+ std::unique_ptr<A[], Deleter> s;
+ std::unique_ptr<A, Deleter> s2(std::move(s));
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/nullptr.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/nullptr.pass.cpp
new file mode 100644
index 000000000000..67a48a3e7a12
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/nullptr.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// unique_ptr(nullptr_t);
+
+#include <memory>
+#include <cassert>
+
+// default unique_ptr ctor should only require default Deleter ctor
+class Deleter
+{
+ int state_;
+
+ Deleter(Deleter&);
+ Deleter& operator=(Deleter&);
+
+public:
+ Deleter() : state_(5) {}
+
+ int state() const {return state_;}
+
+ void operator()(void*) {}
+};
+
+int main()
+{
+ {
+ std::unique_ptr<int> p(nullptr);
+ assert(p.get() == 0);
+ }
+ {
+ std::unique_ptr<int, Deleter> p(nullptr);
+ assert(p.get() == 0);
+ assert(p.get_deleter().state() == 5);
+ }
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer01.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer01.fail.cpp
new file mode 100644
index 000000000000..1af04b2c0033
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer01.fail.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer) ctor
+
+#include <memory>
+
+// unique_ptr(pointer) ctor should require default Deleter ctor
+class Deleter
+{
+
+ Deleter() {}
+
+public:
+
+ Deleter(Deleter&) {}
+ Deleter& operator=(Deleter&) {}
+
+ void operator()(void*) const {}
+};
+
+int main()
+{
+ std::unique_ptr<int, Deleter> p(new int);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer01.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer01.pass.cpp
new file mode 100644
index 000000000000..e5fff774b790
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer01.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer) ctor
+
+#include <memory>
+#include <cassert>
+
+// unique_ptr(pointer) ctor should only require default Deleter ctor
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+class Deleter
+{
+ int state_;
+
+ Deleter(Deleter&);
+ Deleter& operator=(Deleter&);
+
+public:
+ Deleter() : state_(5) {}
+
+ int state() const {return state_;}
+
+ void operator()(A* p) {delete p;}
+};
+
+int main()
+{
+ {
+ A* p = new A;
+ assert(A::count == 1);
+ std::unique_ptr<A> s(p);
+ assert(s.get() == p);
+ }
+ assert(A::count == 0);
+ {
+ A* p = new A;
+ assert(A::count == 1);
+ std::unique_ptr<A, Deleter> s(p);
+ assert(s.get() == p);
+ assert(s.get_deleter().state() == 5);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer02.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer02.fail.cpp
new file mode 100644
index 000000000000..9b7dd8c70f28
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer02.fail.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer) ctor
+
+#include <memory>
+
+// unique_ptr(pointer) ctor should require non-reference Deleter ctor
+class Deleter
+{
+public:
+
+ void operator()(void*) {}
+};
+
+int main()
+{
+ std::unique_ptr<int, Deleter&> p(new int);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer02.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer02.pass.cpp
new file mode 100644
index 000000000000..a226e87d64a4
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer02.pass.cpp
@@ -0,0 +1,95 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer) ctor
+
+#include <memory>
+#include <cassert>
+
+// unique_ptr(pointer) ctor shouldn't require complete type
+
+struct A;
+
+class Deleter
+{
+ int state_;
+
+ Deleter(Deleter&);
+ Deleter& operator=(Deleter&);
+
+public:
+ Deleter() : state_(5) {}
+
+ int state() const {return state_;}
+
+ void operator()(A* p);
+};
+
+void check(int i);
+
+template <class D = std::default_delete<A> >
+struct B
+{
+ std::unique_ptr<A, D> a_;
+ explicit B(A*);
+ ~B();
+
+ A* get() const {return a_.get();}
+ D& get_deleter() {return a_.get_deleter();}
+};
+
+A* get();
+
+int main()
+{
+ {
+ A* p = get();
+ check(1);
+ B<> s(p);
+ assert(s.get() == p);
+ }
+ check(0);
+ {
+ A* p = get();
+ check(1);
+ B<Deleter> s(p);
+ assert(s.get() == p);
+ assert(s.get_deleter().state() == 5);
+ }
+ check(0);
+}
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+A* get() {return new A;}
+
+void Deleter::operator()(A* p) {delete p;}
+
+void check(int i)
+{
+ assert(A::count == i);
+}
+
+template <class D>
+B<D>::B(A* a) : a_(a) {}
+
+template <class D>
+B<D>::~B() {}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer03.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer03.fail.cpp
new file mode 100644
index 000000000000..a917d87eeede
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer03.fail.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer) ctor
+
+#include <memory>
+
+// unique_ptr(pointer) ctor should require non-pointer Deleter
+
+int main()
+{
+ std::unique_ptr<int, void (*)(void*)> p(new int);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer03.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer03.pass.cpp
new file mode 100644
index 000000000000..42fc09453914
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer03.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer) ctor
+
+#include <memory>
+#include <cassert>
+
+// unique_ptr(pointer) ctor should work with derived pointers
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+class Deleter
+{
+ int state_;
+
+ Deleter(Deleter&);
+ Deleter& operator=(Deleter&);
+
+public:
+ Deleter() : state_(5) {}
+
+ int state() const {return state_;}
+
+ void operator()(A* p) {delete p;}
+};
+
+int main()
+{
+ {
+ B* p = new B;
+ assert(A::count == 1);
+ assert(B::count == 1);
+ std::unique_ptr<A> s(p);
+ assert(s.get() == p);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+ {
+ B* p = new B;
+ assert(A::count == 1);
+ assert(B::count == 1);
+ std::unique_ptr<A, Deleter> s(p);
+ assert(s.get() == p);
+ assert(s.get_deleter().state() == 5);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter01.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter01.pass.cpp
new file mode 100644
index 000000000000..130f91d6216f
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter01.pass.cpp
@@ -0,0 +1,99 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer) ctor
+
+#include <memory>
+#include <cassert>
+
+// unique_ptr(pointer, deleter()) only requires MoveConstructible deleter
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+template <class T>
+class Deleter
+{
+ int state_;
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ Deleter(const Deleter&);
+ Deleter& operator=(const Deleter&);
+#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ Deleter(Deleter&);
+ Deleter& operator=(Deleter&);
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+public:
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ Deleter(Deleter&& r) : state_(r.state_) {r.state_ = 0;}
+ Deleter& operator=(Deleter&& r)
+ {
+ state_ = r.state_;
+ r.state_ = 0;
+ return *this;
+ }
+#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ operator std::__rv<Deleter>() {return std::__rv<Deleter>(*this);}
+ Deleter(std::__rv<Deleter> r) : state_(r->state_) {r->state_ = 0;}
+ Deleter& operator=(std::__rv<Deleter> r)
+ {
+ state_ = r->state_;
+ r->state_ = 0;
+ return *this;
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+ Deleter() : state_(5) {}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ template <class U>
+ Deleter(Deleter<U>&& d,
+ typename std::enable_if<!std::is_same<U, T>::value>::type* = 0)
+ : state_(d.state()) {d.set_state(0);}
+
+private:
+ template <class U>
+ Deleter(const Deleter<U>& d,
+ typename std::enable_if<!std::is_same<U, T>::value>::type* = 0);
+#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ template <class U>
+ Deleter(Deleter<U> d,
+ typename std::enable_if<!std::is_same<U, T>::value>::type* = 0)
+ : state_(d.state()) {}
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+public:
+ int state() const {return state_;}
+ void set_state(int i) {state_ = i;}
+
+ void operator()(T* p) {delete p;}
+};
+
+int main()
+{
+ {
+ A* p = new A;
+ assert(A::count == 1);
+ std::unique_ptr<A, Deleter<A> > s(p, Deleter<A>());
+ assert(s.get() == p);
+ assert(s.get_deleter().state() == 5);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter02.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter02.pass.cpp
new file mode 100644
index 000000000000..421bec55f99c
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter02.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer) ctor
+
+#include <memory>
+#include <cassert>
+
+// unique_ptr(pointer, d) requires CopyConstructible deleter
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+class Deleter
+{
+ int state_;
+
+public:
+
+ Deleter() : state_(5) {}
+
+ int state() const {return state_;}
+ void set_state(int s) {state_ = s;}
+
+ void operator()(A* p) {delete p;}
+};
+
+int main()
+{
+ {
+ A* p = new A;
+ assert(A::count == 1);
+ Deleter d;
+ std::unique_ptr<A, Deleter> s(p, d);
+ assert(s.get() == p);
+ assert(s.get_deleter().state() == 5);
+ d.set_state(6);
+ assert(s.get_deleter().state() == 5);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter03.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter03.pass.cpp
new file mode 100644
index 000000000000..bce79dbb1a97
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter03.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer) ctor
+
+#include <memory>
+#include <cassert>
+
+// unique_ptr<T, D&>(pointer, d) does not requires CopyConstructible deleter
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+class Deleter
+{
+ int state_;
+
+ Deleter(const Deleter&);
+ Deleter& operator=(const Deleter&);
+public:
+
+ Deleter() : state_(5) {}
+
+ int state() const {return state_;}
+ void set_state(int s) {state_ = s;}
+
+ void operator()(A* p) {delete p;}
+};
+
+int main()
+{
+ {
+ A* p = new A;
+ assert(A::count == 1);
+ Deleter d;
+ std::unique_ptr<A, Deleter&> s(p, d);
+ assert(s.get() == p);
+ assert(s.get_deleter().state() == 5);
+ d.set_state(6);
+ assert(s.get_deleter().state() == 6);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter04.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter04.fail.cpp
new file mode 100644
index 000000000000..7cacd1fda9f3
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter04.fail.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer) ctor
+
+#include <memory>
+#include <cassert>
+
+// unique_ptr<T, const D&>(pointer, D()) should not compile
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+class Deleter
+{
+ int state_;
+
+public:
+
+ Deleter() : state_(5) {}
+
+ int state() const {return state_;}
+ void set_state(int s) {state_ = s;}
+
+ void operator()(A* p) const {delete p;}
+};
+
+int main()
+{
+ {
+ A* p = new A;
+ assert(A::count == 1);
+ std::unique_ptr<A, const Deleter&> s(p, Deleter());
+ assert(s.get() == p);
+ assert(s.get_deleter().state() == 5);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter04.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter04.pass.cpp
new file mode 100644
index 000000000000..a7750fcb9f0f
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter04.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer) ctor
+
+#include <memory>
+#include <cassert>
+
+// unique_ptr<T, const D&>(pointer, d) does not requires CopyConstructible deleter
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+class Deleter
+{
+ int state_;
+
+ Deleter(const Deleter&);
+ Deleter& operator=(const Deleter&);
+public:
+
+ Deleter() : state_(5) {}
+
+ int state() const {return state_;}
+ void set_state(int s) {state_ = s;}
+
+ void operator()(A* p) const {delete p;}
+};
+
+int main()
+{
+ {
+ A* p = new A;
+ assert(A::count == 1);
+ Deleter d;
+ std::unique_ptr<A, const Deleter&> s(p, d);
+ assert(s.get() == p);
+ assert(s.get_deleter().state() == 5);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter05.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter05.pass.cpp
new file mode 100644
index 000000000000..1a83258e1e41
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter05.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer, deleter) ctor
+
+#include <memory>
+#include <cassert>
+
+// unique_ptr(pointer, deleter) should work with derived pointers
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+class Deleter
+{
+ int state_;
+
+public:
+ Deleter() : state_(5) {}
+
+ int state() const {return state_;}
+
+ void operator()(A* p) {delete p;}
+};
+
+int main()
+{
+ {
+ B* p = new B;
+ assert(A::count == 1);
+ assert(B::count == 1);
+ std::unique_ptr<A, Deleter> s(p, Deleter());
+ assert(s.get() == p);
+ assert(s.get_deleter().state() == 5);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter06.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter06.pass.cpp
new file mode 100644
index 000000000000..ed68052cd3bb
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter06.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer, deleter) ctor
+
+#include <memory>
+#include <cassert>
+
+// unique_ptr(pointer, deleter) should work with function pointers
+// unique_ptr<void> should work
+
+bool my_free_called = false;
+
+void my_free(void*)
+{
+ my_free_called = true;
+}
+
+int main()
+{
+ {
+ int i = 0;
+ std::unique_ptr<void, void (*)(void*)> s(&i, my_free);
+ assert(s.get() == &i);
+ assert(s.get_deleter() == my_free);
+ assert(!my_free_called);
+ }
+ assert(my_free_called);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.dtor/null.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.dtor/null.pass.cpp
new file mode 100644
index 000000000000..064f38c5f167
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.dtor/null.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// The deleter is not called if get() == 0
+
+#include <memory>
+#include <cassert>
+
+class Deleter
+{
+ int state_;
+
+ Deleter(Deleter&);
+ Deleter& operator=(Deleter&);
+
+public:
+ Deleter() : state_(0) {}
+
+ int state() const {return state_;}
+
+ void operator()(void*) {++state_;}
+};
+
+int main()
+{
+ Deleter d;
+ assert(d.state() == 0);
+ {
+ std::unique_ptr<int, Deleter&> p(0, d);
+ assert(p.get() == 0);
+ assert(&p.get_deleter() == &d);
+ }
+ assert(d.state() == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/release.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/release.pass.cpp
new file mode 100644
index 000000000000..dadd4ecbe590
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/release.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// test release
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+ std::unique_ptr<int> p(new int(3));
+ int* i = p.get();
+ int* j = p.release();
+ assert(p.get() == 0);
+ assert(i == j);
+ delete j;
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset1.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset1.pass.cpp
new file mode 100644
index 000000000000..2cf7f8b77568
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset1.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// test reset
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ std::unique_ptr<A> p(new A);
+ assert(A::count == 1);
+ A* i = p.get();
+ assert(i != nullptr);
+ p.reset();
+ assert(A::count == 0);
+ assert(p.get() == 0);
+ }
+ assert(A::count == 0);
+ {
+ std::unique_ptr<A> p(new A);
+ assert(A::count == 1);
+ A* i = p.get();
+ assert(i != nullptr);
+ p.reset(new A);
+ assert(A::count == 1);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset2.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset2.pass.cpp
new file mode 100644
index 000000000000..2de7787b267e
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset2.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// test reset
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ std::unique_ptr<A> p(new A);
+ assert(A::count == 1);
+ assert(B::count == 0);
+ A* i = p.get();
+ assert(i != nullptr);
+ p.reset(new B);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+ {
+ std::unique_ptr<A> p(new B);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ A* i = p.get();
+ assert(i != nullptr);
+ p.reset(new B);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset_self.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset_self.pass.cpp
new file mode 100644
index 000000000000..58b05efa25f6
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset_self.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// test reset against resetting self
+
+#include <memory>
+
+struct A
+{
+ std::unique_ptr<A> ptr_;
+
+ A() : ptr_(this) {}
+ void reset() {ptr_.reset();}
+};
+
+int main()
+{
+ (new A)->reset();
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/swap.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/swap.pass.cpp
new file mode 100644
index 000000000000..d0a03be80326
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/swap.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// test swap
+
+#include <memory>
+#include <cassert>
+
+#include "../../deleter.h"
+
+struct A
+{
+ int state_;
+ static int count;
+ explicit A(int i) : state_(i) {++count;}
+ A(const A& a) : state_(a.state_) {++count;}
+ A& operator=(const A& a) {state_ = a.state_; return *this;}
+ ~A() {--count;}
+
+ friend bool operator==(const A& x, const A& y)
+ {return x.state_ == y.state_;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ A* p1 = new A(1);
+ std::unique_ptr<A, Deleter<A> > s1(p1, Deleter<A>(1));
+ A* p2 = new A(2);
+ std::unique_ptr<A, Deleter<A> > s2(p2, Deleter<A>(2));
+ assert(s1.get() == p1);
+ assert(*s1 == A(1));
+ assert(s1.get_deleter().state() == 1);
+ assert(s2.get() == p2);
+ assert(*s2 == A(2));
+ assert(s2.get_deleter().state() == 2);
+ s1.swap(s2);
+ assert(s1.get() == p2);
+ assert(*s1 == A(2));
+ assert(s1.get_deleter().state() == 2);
+ assert(s2.get() == p1);
+ assert(*s2 == A(1));
+ assert(s2.get_deleter().state() == 1);
+ assert(A::count == 2);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/dereference.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/dereference.pass.cpp
new file mode 100644
index 000000000000..9d0cfcaaf353
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/dereference.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// test op*()
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+ std::unique_ptr<int> p(new int(3));
+ assert(*p == 3);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/explicit_bool.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/explicit_bool.pass.cpp
new file mode 100644
index 000000000000..d5c7445b0d86
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/explicit_bool.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// test op*()
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+ {
+ std::unique_ptr<int> p(new int(3));
+ if (p)
+ ;
+ else
+ assert(false);
+ if (!p)
+ assert(false);
+ }
+ {
+ std::unique_ptr<int> p;
+ if (!p)
+ ;
+ else
+ assert(false);
+ if (p)
+ assert(false);
+ }
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/get.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/get.pass.cpp
new file mode 100644
index 000000000000..24fa6beb4273
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/get.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// test get
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+ int* p = new int;
+ std::unique_ptr<int> s(p);
+ assert(s.get() == p);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/get_deleter.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/get_deleter.pass.cpp
new file mode 100644
index 000000000000..5ed8a22b14c4
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/get_deleter.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// test get_deleter()
+
+#include <memory>
+#include <cassert>
+
+struct Deleter
+{
+ void operator()(void*) {}
+
+ int test() {return 5;}
+ int test() const {return 6;}
+};
+
+int main()
+{
+ {
+ std::unique_ptr<int, Deleter> p;
+ assert(p.get_deleter().test() == 5);
+ }
+ {
+ const std::unique_ptr<int, Deleter> p;
+ assert(p.get_deleter().test() == 6);
+ }
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/index.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/index.fail.cpp
new file mode 100644
index 000000000000..21e829cbc444
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/index.fail.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// test op[](size_t)
+
+#include <memory>
+#include <cassert>
+
+class A
+{
+ int state_;
+ static int next_;
+public:
+ A() : state_(++next_) {}
+ int get() const {return state_;}
+
+ friend bool operator==(const A& x, int y)
+ {return x.state_ == y;}
+
+ A& operator=(int i) {state_ = i; return *this;}
+};
+
+int A::next_ = 0;
+
+int main()
+{
+ std::unique_ptr<A> p(new A[3]);
+ assert(p[0] == 1);
+ assert(p[1] == 2);
+ assert(p[2] == 3);
+ p[0] = 3;
+ p[1] = 2;
+ p[2] = 1;
+ assert(p[0] == 3);
+ assert(p[1] == 2);
+ assert(p[2] == 1);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/op_arrow.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/op_arrow.pass.cpp
new file mode 100644
index 000000000000..47de8f66ed2e
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/op_arrow.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// test op->()
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ int i_;
+
+ A() : i_(7) {}
+};
+
+int main()
+{
+ std::unique_ptr<A> p(new A);
+ assert(p->i_ == 7);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.special/cmp_nullptr.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.special/cmp_nullptr.pass.cpp
new file mode 100644
index 000000000000..22ae217a61d6
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.special/cmp_nullptr.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// template <class T, class D>
+// bool operator==(const unique_ptr<T, D>& x, nullptr_t) noexcept;
+// template <class T, class D>
+// bool operator==(nullptr_t, const unique_ptr<T, D>& y) noexcept;
+// template <class T, class D>
+// bool operator!=(const unique_ptr<T, D>& x, nullptr_t) noexcept;
+// template <class T, class D>
+// bool operator!=(nullptr_t, const unique_ptr<T, D>& y) noexcept;
+// template <class T, class D>
+// bool operator<(const unique_ptr<T, D>& x, nullptr_t) noexcept;
+// template <class T, class D>
+// bool operator<(nullptr_t, const unique_ptr<T, D>& y) noexcept;
+// template <class T, class D>
+// bool operator<=(const unique_ptr<T, D>& x, nullptr_t) noexcept;
+// template <class T, class D>
+// bool operator<=(nullptr_t, const unique_ptr<T, D>& y) noexcept;
+// template <class T, class D>
+// bool operator>(const unique_ptr<T, D>& x, nullptr_t) noexcept;
+// template <class T, class D>
+// bool operator>(nullptr_t, const unique_ptr<T, D>& y) noexcept;
+// template <class T, class D>
+// bool operator>=(const unique_ptr<T, D>& x, nullptr_t) noexcept;
+// template <class T, class D>
+// bool operator>=(nullptr_t, const unique_ptr<T, D>& y) noexcept;
+
+#include <memory>
+#include <cassert>
+
+void do_nothing(int*) {}
+
+int main()
+{
+ const std::unique_ptr<int> p1(new int(1));
+ assert(!(p1 == nullptr));
+ assert(!(nullptr == p1));
+ assert(!(p1 < nullptr));
+ assert( (nullptr < p1));
+ assert(!(p1 <= nullptr));
+ assert( (nullptr <= p1));
+ assert( (p1 > nullptr));
+ assert(!(nullptr > p1));
+ assert( (p1 >= nullptr));
+ assert(!(nullptr >= p1));
+
+ const std::unique_ptr<int> p2;
+ assert( (p2 == nullptr));
+ assert( (nullptr == p2));
+ assert(!(p2 < nullptr));
+ assert(!(nullptr < p2));
+ assert( (p2 <= nullptr));
+ assert( (nullptr <= p2));
+ assert(!(p2 > nullptr));
+ assert(!(nullptr > p2));
+ assert( (p2 >= nullptr));
+ assert( (nullptr >= p2));
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.special/eq.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.special/eq.pass.cpp
new file mode 100644
index 000000000000..37886548e721
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.special/eq.pass.cpp
@@ -0,0 +1,86 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// template <class T1, class D1, class T2, class D2>
+// bool
+// operator==(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
+
+// template <class T1, class D1, class T2, class D2>
+// bool
+// operator!=(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
+
+#include <memory>
+#include <cassert>
+
+#include "../deleter.h"
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ const std::unique_ptr<A, Deleter<A> > p1(new A);
+ const std::unique_ptr<A, Deleter<A> > p2(new A);
+ assert(!(p1 == p2));
+ assert(p1 != p2);
+ }
+ {
+ const std::unique_ptr<A, Deleter<A> > p1(new A);
+ const std::unique_ptr<B, Deleter<B> > p2(new B);
+ assert(!(p1 == p2));
+ assert(p1 != p2);
+ }
+ {
+ const std::unique_ptr<A[], Deleter<A[]> > p1(new A[3]);
+ const std::unique_ptr<A[], Deleter<A[]> > p2(new A[3]);
+ assert(!(p1 == p2));
+ assert(p1 != p2);
+ }
+ {
+ const std::unique_ptr<A[], Deleter<A[]> > p1(new A[3]);
+ const std::unique_ptr<B[], Deleter<B[]> > p2(new B[3]);
+ assert(!(p1 == p2));
+ assert(p1 != p2);
+ }
+ {
+ const std::unique_ptr<A, Deleter<A> > p1;
+ const std::unique_ptr<A, Deleter<A> > p2;
+ assert(p1 == p2);
+ assert(!(p1 != p2));
+ }
+ {
+ const std::unique_ptr<A, Deleter<A> > p1;
+ const std::unique_ptr<B, Deleter<B> > p2;
+ assert(p1 == p2);
+ assert(!(p1 != p2));
+ }
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.special/rel.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.special/rel.pass.cpp
new file mode 100644
index 000000000000..80653cf707c3
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.special/rel.pass.cpp
@@ -0,0 +1,100 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// template <class T1, class D1, class T2, class D2>
+// bool
+// operator< (const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
+
+// template <class T1, class D1, class T2, class D2>
+// bool
+// operator> (const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
+
+// template <class T1, class D1, class T2, class D2>
+// bool
+// operator<=(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
+
+// template <class T1, class D1, class T2, class D2>
+// bool
+// operator>=(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
+
+#include <memory>
+#include <cassert>
+
+#include "../deleter.h"
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ const std::unique_ptr<A, Deleter<A> > p1(new A);
+ const std::unique_ptr<A, Deleter<A> > p2(new A);
+ assert((p1 < p2) == !(p1 > p2));
+ assert((p1 < p2) == (p1 <= p2));
+ assert((p1 < p2) == !(p1 >= p2));
+ }
+ {
+ const std::unique_ptr<A, Deleter<A> > p1(new A);
+ const std::unique_ptr<B, Deleter<B> > p2(new B);
+ assert((p1 < p2) == !(p1 > p2));
+ assert((p1 < p2) == (p1 <= p2));
+ assert((p1 < p2) == !(p1 >= p2));
+ }
+ {
+ const std::unique_ptr<A[], Deleter<A[]> > p1(new A[3]);
+ const std::unique_ptr<A[], Deleter<A[]> > p2(new A[3]);
+ assert((p1 < p2) == !(p1 > p2));
+ assert((p1 < p2) == (p1 <= p2));
+ assert((p1 < p2) == !(p1 >= p2));
+ }
+ {
+ const std::unique_ptr<A[], Deleter<A[]> > p1(new A[3]);
+ const std::unique_ptr<B[], Deleter<B[]> > p2(new B[3]);
+ assert((p1 < p2) == !(p1 > p2));
+ assert((p1 < p2) == (p1 <= p2));
+ assert((p1 < p2) == !(p1 >= p2));
+ }
+ {
+ const std::unique_ptr<A, Deleter<A> > p1;
+ const std::unique_ptr<A, Deleter<A> > p2;
+ assert((p1 < p2) == (p1 > p2));
+ assert((p1 < p2) == !(p1 <= p2));
+ assert((p1 < p2) == !(p1 >= p2));
+ }
+ {
+ const std::unique_ptr<A, Deleter<A> > p1;
+ const std::unique_ptr<B, Deleter<B> > p2;
+ assert((p1 < p2) == (p1 > p2));
+ assert((p1 < p2) == !(p1 <= p2));
+ assert((p1 < p2) == !(p1 >= p2));
+ }
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.special/swap.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.special/swap.pass.cpp
new file mode 100644
index 000000000000..44b746fbcfd8
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.special/swap.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test swap
+
+#include <memory>
+#include <cassert>
+
+#include "../deleter.h"
+
+struct A
+{
+ int state_;
+ static int count;
+ A() : state_(0) {++count;}
+ explicit A(int i) : state_(i) {++count;}
+ A(const A& a) : state_(a.state_) {++count;}
+ A& operator=(const A& a) {state_ = a.state_; return *this;}
+ ~A() {--count;}
+
+ friend bool operator==(const A& x, const A& y)
+ {return x.state_ == y.state_;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ A* p1 = new A(1);
+ std::unique_ptr<A, Deleter<A> > s1(p1, Deleter<A>(1));
+ A* p2 = new A(2);
+ std::unique_ptr<A, Deleter<A> > s2(p2, Deleter<A>(2));
+ assert(s1.get() == p1);
+ assert(*s1 == A(1));
+ assert(s1.get_deleter().state() == 1);
+ assert(s2.get() == p2);
+ assert(*s2 == A(2));
+ assert(s2.get_deleter().state() == 2);
+ swap(s1, s2);
+ assert(s1.get() == p2);
+ assert(*s1 == A(2));
+ assert(s1.get_deleter().state() == 2);
+ assert(s2.get() == p1);
+ assert(*s2 == A(1));
+ assert(s2.get_deleter().state() == 1);
+ assert(A::count == 2);
+ }
+ assert(A::count == 0);
+ {
+ A* p1 = new A[3];
+ std::unique_ptr<A[], Deleter<A[]> > s1(p1, Deleter<A[]>(1));
+ A* p2 = new A[3];
+ std::unique_ptr<A[], Deleter<A[]> > s2(p2, Deleter<A[]>(2));
+ assert(s1.get() == p1);
+ assert(s1.get_deleter().state() == 1);
+ assert(s2.get() == p2);
+ assert(s2.get_deleter().state() == 2);
+ swap(s1, s2);
+ assert(s1.get() == p2);
+ assert(s1.get_deleter().state() == 2);
+ assert(s2.get() == p1);
+ assert(s2.get_deleter().state() == 1);
+ assert(A::count == 6);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/util.dynamic.safety/declare_no_pointers.pass.cpp b/test/std/utilities/memory/util.dynamic.safety/declare_no_pointers.pass.cpp
new file mode 100644
index 000000000000..bbf4be20f8fe
--- /dev/null
+++ b/test/std/utilities/memory/util.dynamic.safety/declare_no_pointers.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// void declare_no_pointers(char* p, size_t n);
+// void undeclare_no_pointers(char* p, size_t n);
+
+#include <memory>
+
+int main()
+{
+ char* p = new char[10];
+ std::declare_no_pointers(p, 10);
+ std::undeclare_no_pointers(p, 10);
+ delete [] p;
+}
diff --git a/test/std/utilities/memory/util.dynamic.safety/declare_reachable.pass.cpp b/test/std/utilities/memory/util.dynamic.safety/declare_reachable.pass.cpp
new file mode 100644
index 000000000000..3f0bcead9bef
--- /dev/null
+++ b/test/std/utilities/memory/util.dynamic.safety/declare_reachable.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// void declare_reachable(void* p);
+// template <class T> T* undeclare_reachable(T* p);
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+ int* p = new int;
+ std::declare_reachable(p);
+ assert(std::undeclare_reachable(p) == p);
+ delete p;
+}
diff --git a/test/std/utilities/memory/util.dynamic.safety/get_pointer_safety.pass.cpp b/test/std/utilities/memory/util.dynamic.safety/get_pointer_safety.pass.cpp
new file mode 100644
index 000000000000..1f27b45e8ab8
--- /dev/null
+++ b/test/std/utilities/memory/util.dynamic.safety/get_pointer_safety.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// pointer_safety get_pointer_safety();
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+ std::pointer_safety r = std::get_pointer_safety();
+ assert(r == std::pointer_safety::relaxed ||
+ r == std::pointer_safety::preferred ||
+ r == std::pointer_safety::strict);
+}
diff --git a/test/std/utilities/memory/util.smartptr/nothing_to_do.pass.cpp b/test/std/utilities/memory/util.smartptr/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.enab/enable_shared_from_this.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.enab/enable_shared_from_this.pass.cpp
new file mode 100644
index 000000000000..77af13fa90d1
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.enab/enable_shared_from_this.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// template<class T>
+// class enable_shared_from_this
+// {
+// protected:
+// enable_shared_from_this();
+// enable_shared_from_this(enable_shared_from_this const&);
+// enable_shared_from_this& operator=(enable_shared_from_this const&);
+// ~enable_shared_from_this();
+// public:
+// shared_ptr<T> shared_from_this();
+// shared_ptr<T const> shared_from_this() const;
+// };
+
+#include <memory>
+#include <cassert>
+
+struct T
+ : public std::enable_shared_from_this<T>
+{
+};
+
+struct Y : T {};
+
+struct Z : Y {};
+
+int main()
+{
+ { // https://llvm.org/bugs/show_bug.cgi?id=18843
+ std::shared_ptr<T const> t1(new T);
+ std::shared_ptr<T const> t2(std::make_shared<T>());
+ }
+ {
+ std::shared_ptr<Y> p(new Z);
+ std::shared_ptr<T> q = p->shared_from_this();
+ assert(p == q);
+ assert(!p.owner_before(q) && !q.owner_before(p)); // p and q share ownership
+ }
+ {
+ std::shared_ptr<Y> p = std::make_shared<Z>();
+ std::shared_ptr<T> q = p->shared_from_this();
+ assert(p == q);
+ assert(!p.owner_before(q) && !q.owner_before(p)); // p and q share ownership
+ }
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.hash/hash_shared_ptr.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.hash/hash_shared_ptr.pass.cpp
new file mode 100644
index 000000000000..990cb58722b1
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.hash/hash_shared_ptr.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class T>
+// struct hash<shared_ptr<T>>
+// {
+// typedef shared_ptr<T> argument_type;
+// typedef size_t result_type;
+// size_t operator()(const shared_ptr<T>& p) const;
+// };
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+ int* ptr = new int;
+ std::shared_ptr<int> p(ptr);
+ std::hash<std::shared_ptr<int> > f;
+ std::size_t h = f(p);
+ assert(h == std::hash<int*>()(ptr));
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.hash/hash_unique_ptr.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.hash/hash_unique_ptr.pass.cpp
new file mode 100644
index 000000000000..5cd4ab1f83d0
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.hash/hash_unique_ptr.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class T, class D>
+// struct hash<unique_ptr<T, D>>
+// {
+// typedef unique_ptr<T, D> argument_type;
+// typedef size_t result_type;
+// size_t operator()(const unique_ptr<T, D>& p) const;
+// };
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+ int* ptr = new int;
+ std::unique_ptr<int> p(ptr);
+ std::hash<std::unique_ptr<int> > f;
+ std::size_t h = f(p);
+ assert(h == std::hash<int*>()(ptr));
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_strong.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_strong.pass.cpp
new file mode 100644
index 000000000000..2d586e9c7fdd
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_strong.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+//
+// This test uses new symbols that were not defined in the libc++ shipped on
+// darwin11 and darwin12:
+// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11
+// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12
+
+// <memory>
+
+// shared_ptr
+
+// template <class T>
+// bool
+// atomic_compare_exchange_strong(shared_ptr<T>* p, shared_ptr<T>* v,
+// shared_ptr<T> w);
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+#if __has_feature(cxx_atomic)
+ {
+ std::shared_ptr<int> p(new int(4));
+ std::shared_ptr<int> v(new int(3));
+ std::shared_ptr<int> w(new int(2));
+ bool b = std::atomic_compare_exchange_strong(&p, &v, w);
+ assert(b == false);
+ assert(*p == 4);
+ assert(*v == 4);
+ assert(*w == 2);
+ }
+ {
+ std::shared_ptr<int> p(new int(4));
+ std::shared_ptr<int> v = p;
+ std::shared_ptr<int> w(new int(2));
+ bool b = std::atomic_compare_exchange_strong(&p, &v, w);
+ assert(b == true);
+ assert(*p == 2);
+ assert(*v == 4);
+ assert(*w == 2);
+ }
+#endif
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_strong_explicit.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_strong_explicit.pass.cpp
new file mode 100644
index 000000000000..34da04cc1810
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_strong_explicit.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+//
+// This test uses new symbols that were not defined in the libc++ shipped on
+// darwin11 and darwin12:
+// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11
+// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12
+
+// <memory>
+
+// shared_ptr
+
+// template <class T>
+// bool
+// atomic_compare_exchange_strong_explicit(shared_ptr<T>* p, shared_ptr<T>* v,
+// shared_ptr<T> w, memory_order success,
+// memory_order failure);
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+#if __has_feature(cxx_atomic)
+ {
+ std::shared_ptr<int> p(new int(4));
+ std::shared_ptr<int> v(new int(3));
+ std::shared_ptr<int> w(new int(2));
+ bool b = std::atomic_compare_exchange_strong_explicit(&p, &v, w,
+ std::memory_order_seq_cst,
+ std::memory_order_seq_cst);
+ assert(b == false);
+ assert(*p == 4);
+ assert(*v == 4);
+ assert(*w == 2);
+ }
+ {
+ std::shared_ptr<int> p(new int(4));
+ std::shared_ptr<int> v = p;
+ std::shared_ptr<int> w(new int(2));
+ bool b = std::atomic_compare_exchange_strong_explicit(&p, &v, w,
+ std::memory_order_seq_cst,
+ std::memory_order_seq_cst);
+ assert(b == true);
+ assert(*p == 2);
+ assert(*v == 4);
+ assert(*w == 2);
+ }
+#endif
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_weak.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_weak.pass.cpp
new file mode 100644
index 000000000000..50b96e551fd3
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_weak.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+//
+// This test uses new symbols that were not defined in the libc++ shipped on
+// darwin11 and darwin12:
+// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11
+// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12
+
+// <memory>
+
+// shared_ptr
+
+// template <class T>
+// bool
+// atomic_compare_exchange_weak(shared_ptr<T>* p, shared_ptr<T>* v,
+// shared_ptr<T> w);
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+#if __has_feature(cxx_atomic)
+ {
+ std::shared_ptr<int> p(new int(4));
+ std::shared_ptr<int> v(new int(3));
+ std::shared_ptr<int> w(new int(2));
+ bool b = std::atomic_compare_exchange_weak(&p, &v, w);
+ assert(b == false);
+ assert(*p == 4);
+ assert(*v == 4);
+ assert(*w == 2);
+ }
+ {
+ std::shared_ptr<int> p(new int(4));
+ std::shared_ptr<int> v = p;
+ std::shared_ptr<int> w(new int(2));
+ bool b = std::atomic_compare_exchange_weak(&p, &v, w);
+ assert(b == true);
+ assert(*p == 2);
+ assert(*v == 4);
+ assert(*w == 2);
+ }
+#endif
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_weak_explicit.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_weak_explicit.pass.cpp
new file mode 100644
index 000000000000..d304319d251d
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_weak_explicit.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+//
+// This test uses new symbols that were not defined in the libc++ shipped on
+// darwin11 and darwin12:
+// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11
+// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12
+
+// <memory>
+
+// shared_ptr
+
+// template <class T>
+// bool
+// atomic_compare_exchange_weak_explicit(shared_ptr<T>* p, shared_ptr<T>* v,
+// shared_ptr<T> w, memory_order success,
+// memory_order failure);
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+#if __has_feature(cxx_atomic)
+ {
+ std::shared_ptr<int> p(new int(4));
+ std::shared_ptr<int> v(new int(3));
+ std::shared_ptr<int> w(new int(2));
+ bool b = std::atomic_compare_exchange_weak_explicit(&p, &v, w,
+ std::memory_order_seq_cst,
+ std::memory_order_seq_cst);
+ assert(b == false);
+ assert(*p == 4);
+ assert(*v == 4);
+ assert(*w == 2);
+ }
+ {
+ std::shared_ptr<int> p(new int(4));
+ std::shared_ptr<int> v = p;
+ std::shared_ptr<int> w(new int(2));
+ bool b = std::atomic_compare_exchange_weak_explicit(&p, &v, w,
+ std::memory_order_seq_cst,
+ std::memory_order_seq_cst);
+ assert(b == true);
+ assert(*p == 2);
+ assert(*v == 4);
+ assert(*w == 2);
+ }
+#endif
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_exchange.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_exchange.pass.cpp
new file mode 100644
index 000000000000..3b44c8ba9b33
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_exchange.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+//
+// This test uses new symbols that were not defined in the libc++ shipped on
+// darwin11 and darwin12:
+// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11
+// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12
+
+// <memory>
+
+// shared_ptr
+
+// template <class T>
+// shared_ptr<T>
+// atomic_exchange(shared_ptr<T>* p, shared_ptr<T> r)
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+#if __has_feature(cxx_atomic)
+ {
+ std::shared_ptr<int> p(new int(4));
+ std::shared_ptr<int> r(new int(3));
+ r = std::atomic_exchange(&p, r);
+ assert(*p == 3);
+ assert(*r == 4);
+ }
+#endif
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_exchange_explicit.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_exchange_explicit.pass.cpp
new file mode 100644
index 000000000000..598a1b8da175
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_exchange_explicit.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+//
+// This test uses new symbols that were not defined in the libc++ shipped on
+// darwin11 and darwin12:
+// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11
+// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12
+
+// <memory>
+
+// shared_ptr
+
+// template <class T>
+// shared_ptr<T>
+// atomic_exchange_explicit(shared_ptr<T>* p, shared_ptr<T> r)
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+#if __has_feature(cxx_atomic)
+ {
+ std::shared_ptr<int> p(new int(4));
+ std::shared_ptr<int> r(new int(3));
+ r = std::atomic_exchange_explicit(&p, r, std::memory_order_seq_cst);
+ assert(*p == 3);
+ assert(*r == 4);
+ }
+#endif
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_is_lock_free.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_is_lock_free.pass.cpp
new file mode 100644
index 000000000000..e3ac84a4fa50
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_is_lock_free.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <memory>
+
+// shared_ptr
+
+// template<class T>
+// bool
+// atomic_is_lock_free(const shared_ptr<T>* p);
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+#if __has_feature(cxx_atomic)
+ {
+ const std::shared_ptr<int> p(new int(3));
+ assert(std::atomic_is_lock_free(&p) == false);
+ }
+#endif
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_load.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_load.pass.cpp
new file mode 100644
index 000000000000..d4a39c878ac7
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_load.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+//
+// This test uses new symbols that were not defined in the libc++ shipped on
+// darwin11 and darwin12:
+// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11
+// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12
+
+// <memory>
+
+// shared_ptr
+
+// template <class T>
+// shared_ptr<T>
+// atomic_load(const shared_ptr<T>* p)
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+#if __has_feature(cxx_atomic)
+ {
+ std::shared_ptr<int> p(new int(3));
+ std::shared_ptr<int> q = std::atomic_load(&p);
+ assert(*q == *p);
+ }
+#endif
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_load_explicit.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_load_explicit.pass.cpp
new file mode 100644
index 000000000000..af11dc8bc2c9
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_load_explicit.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+//
+// This test uses new symbols that were not defined in the libc++ shipped on
+// darwin11 and darwin12:
+// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11
+// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12
+
+// <memory>
+
+// shared_ptr
+
+// template <class T>
+// shared_ptr<T>
+// atomic_load_explicit(const shared_ptr<T>* p, memory_order mo)
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+#if __has_feature(cxx_atomic)
+ {
+ const std::shared_ptr<int> p(new int(3));
+ std::shared_ptr<int> q = std::atomic_load_explicit(&p, std::memory_order_relaxed);
+ assert(*q == *p);
+ }
+#endif
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_store.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_store.pass.cpp
new file mode 100644
index 000000000000..7a85a9934ef0
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_store.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+//
+// This test uses new symbols that were not defined in the libc++ shipped on
+// darwin11 and darwin12:
+// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11
+// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12
+
+// <memory>
+
+// shared_ptr
+
+// template <class T>
+// void
+// atomic_store(shared_ptr<T>* p, shared_ptr<T> r)
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+#if __has_feature(cxx_atomic)
+ {
+ std::shared_ptr<int> p;
+ std::shared_ptr<int> r(new int(3));
+ std::atomic_store(&p, r);
+ assert(*p == *r);
+ }
+#endif
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_store_explicit.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_store_explicit.pass.cpp
new file mode 100644
index 000000000000..c81266c55fa4
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_store_explicit.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+//
+// This test uses new symbols that were not defined in the libc++ shipped on
+// darwin11 and darwin12:
+// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11
+// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12
+
+// <memory>
+
+// shared_ptr
+
+// template <class T>
+// void
+// atomic_store_explicit(shared_ptr<T>* p, shared_ptr<T> r, memory_order mo)
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+#if __has_feature(cxx_atomic)
+ {
+ std::shared_ptr<int> p;
+ std::shared_ptr<int> r(new int(3));
+ std::atomic_store_explicit(&p, r, std::memory_order_seq_cst);
+ assert(*p == *r);
+ }
+#endif
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/test_deleter.h b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/test_deleter.h
new file mode 100644
index 000000000000..0263061b3a84
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/test_deleter.h
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// Example move-only deleter
+
+#ifndef DELETER_H
+#define DELETER_H
+
+#include <type_traits>
+#include <cassert>
+
+#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS
+#define DELETE_FUNCTION = delete
+#else
+#define DELETE_FUNCTION { assert(false); }
+#endif
+
+struct test_deleter_base
+{
+ static int count;
+ static int dealloc_count;
+};
+
+int test_deleter_base::count = 0;
+int test_deleter_base::dealloc_count = 0;
+
+template <class T>
+class test_deleter
+ : public test_deleter_base
+{
+ int state_;
+
+public:
+
+ test_deleter() : state_(0) {++count;}
+ explicit test_deleter(int s) : state_(s) {++count;}
+ test_deleter(const test_deleter& d)
+ : state_(d.state_) {++count;}
+ ~test_deleter() {assert(state_ >= 0); --count; state_ = -1;}
+
+ int state() const {return state_;}
+ void set_state(int i) {state_ = i;}
+
+ void operator()(T* p) {assert(state_ >= 0); ++dealloc_count; delete p;}
+
+ test_deleter* operator&() const DELETE_FUNCTION;
+};
+
+template <class T>
+void
+swap(test_deleter<T>& x, test_deleter<T>& y)
+{
+ test_deleter<T> t(std::move(x));
+ x = std::move(y);
+ y = std::move(t);
+}
+
+#endif // DELETER_H
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/types.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/types.pass.cpp
new file mode 100644
index 000000000000..8175312334f6
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/types.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template<class T> class shared_ptr
+// {
+// public:
+// typedef T element_type;
+// ...
+// };
+
+#include <memory>
+
+struct A; // purposefully incomplete
+
+int main()
+{
+ static_assert((std::is_same<std::shared_ptr<A>::element_type, A>::value), "");
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.getdeleter/get_deleter.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.getdeleter/get_deleter.pass.cpp
new file mode 100644
index 000000000000..a6c62496fd62
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.getdeleter/get_deleter.pass.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// template<class D, class T> D* get_deleter(const shared_ptr<T>& p);
+
+#include <memory>
+#include <cassert>
+#include "../test_deleter.h"
+
+struct A
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ {
+ A* ptr = new A;
+ std::shared_ptr<A> p(ptr, test_deleter<A>(3));
+ test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p);
+ assert(test_deleter<A>::count == 1);
+ assert(test_deleter<A>::dealloc_count == 0);
+ assert(d);
+ assert(d->state() == 3);
+ }
+ assert(A::count == 0);
+ assert(test_deleter<A>::count == 0);
+ assert(test_deleter<A>::dealloc_count == 1);
+ }
+ test_deleter<A>::dealloc_count = 0;
+ {
+ {
+ std::shared_ptr<A> p(nullptr, test_deleter<A>(3));
+ test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p);
+ assert(test_deleter<A>::count == 1);
+ assert(test_deleter<A>::dealloc_count == 0);
+ assert(d);
+ assert(d->state() == 3);
+ }
+ assert(A::count == 0);
+ assert(test_deleter<A>::count == 0);
+ assert(test_deleter<A>::dealloc_count == 1);
+ }
+ test_deleter<A>::dealloc_count = 0;
+ {
+ std::shared_ptr<A> p(nullptr, test_deleter<A>(3));
+ std::default_delete<A>* d = std::get_deleter<std::default_delete<A> >(p);
+ assert(d == 0);
+ }
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/auto_ptr_Y.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/auto_ptr_Y.pass.cpp
new file mode 100644
index 000000000000..21cdf4a13e47
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/auto_ptr_Y.pass.cpp
@@ -0,0 +1,113 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// template<class Y> shared_ptr& operator=(auto_ptr<Y>&& r);
+
+#include <memory>
+#include <type_traits>
+#include <cassert>
+
+struct B
+{
+ static int count;
+
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+struct A
+ : public B
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ std::auto_ptr<A> pA(new A);
+ A* ptrA = pA.get();
+ {
+ std::shared_ptr<B> pB(new B);
+ pB = std::move(pA);
+ assert(B::count == 1);
+ assert(A::count == 1);
+ assert(pB.use_count() == 1);
+ assert(pA.get() == 0);
+ assert(pB.get() == ptrA);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+ {
+ std::auto_ptr<A> pA;
+ A* ptrA = pA.get();
+ {
+ std::shared_ptr<B> pB(new B);
+ pB = std::move(pA);
+ assert(B::count == 0);
+ assert(A::count == 0);
+ assert(pB.use_count() == 1);
+ assert(pA.get() == 0);
+ assert(pB.get() == ptrA);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+ {
+ std::auto_ptr<A> pA(new A);
+ A* ptrA = pA.get();
+ {
+ std::shared_ptr<B> pB;
+ pB = std::move(pA);
+ assert(B::count == 1);
+ assert(A::count == 1);
+ assert(pB.use_count() == 1);
+ assert(pA.get() == 0);
+ assert(pB.get() == ptrA);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+ {
+ std::auto_ptr<A> pA;
+ A* ptrA = pA.get();
+ {
+ std::shared_ptr<B> pB;
+ pB = std::move(pA);
+ assert(B::count == 0);
+ assert(A::count == 0);
+ assert(pB.use_count() == 1);
+ assert(pA.get() == 0);
+ assert(pB.get() == ptrA);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr.pass.cpp
new file mode 100644
index 000000000000..5d27a8865f08
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr.pass.cpp
@@ -0,0 +1,121 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// shared_ptr& operator=(const shared_ptr& r);
+
+#include <memory>
+#include <type_traits>
+#include <cassert>
+
+struct B
+{
+ static int count;
+
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+struct A
+ : public B
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ const std::shared_ptr<A> pA(new A);
+ A* ptrA = pA.get();
+ {
+ std::shared_ptr<A> pB(new A);
+ pB = pA;
+ assert(B::count == 1);
+ assert(A::count == 1);
+ assert(pB.use_count() == 2);
+ assert(pA.use_count() == 2);
+ assert(pA.get() == pB.get());
+ assert(pB.get() == ptrA);
+ }
+ assert(pA.use_count() == 1);
+ assert(B::count == 1);
+ assert(A::count == 1);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+ {
+ const std::shared_ptr<A> pA;
+ A* ptrA = pA.get();
+ {
+ std::shared_ptr<A> pB(new A);
+ pB = pA;
+ assert(B::count == 0);
+ assert(A::count == 0);
+ assert(pB.use_count() == 0);
+ assert(pA.use_count() == 0);
+ assert(pA.get() == pB.get());
+ assert(pB.get() == ptrA);
+ }
+ assert(pA.use_count() == 0);
+ assert(B::count == 0);
+ assert(A::count == 0);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+ {
+ const std::shared_ptr<A> pA(new A);
+ A* ptrA = pA.get();
+ {
+ std::shared_ptr<A> pB;
+ pB = pA;
+ assert(B::count == 1);
+ assert(A::count == 1);
+ assert(pB.use_count() == 2);
+ assert(pA.use_count() == 2);
+ assert(pA.get() == pB.get());
+ assert(pB.get() == ptrA);
+ }
+ assert(pA.use_count() == 1);
+ assert(B::count == 1);
+ assert(A::count == 1);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+ {
+ const std::shared_ptr<A> pA;
+ A* ptrA = pA.get();
+ {
+ std::shared_ptr<A> pB;
+ pB = pA;
+ assert(B::count == 0);
+ assert(A::count == 0);
+ assert(pB.use_count() == 0);
+ assert(pA.use_count() == 0);
+ assert(pA.get() == pB.get());
+ assert(pB.get() == ptrA);
+ }
+ assert(pA.use_count() == 0);
+ assert(B::count == 0);
+ assert(A::count == 0);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr_Y.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr_Y.pass.cpp
new file mode 100644
index 000000000000..abd3d378eb71
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr_Y.pass.cpp
@@ -0,0 +1,121 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// template<class Y> shared_ptr& operator=(const shared_ptr<Y>& r);
+
+#include <memory>
+#include <type_traits>
+#include <cassert>
+
+struct B
+{
+ static int count;
+
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+struct A
+ : public B
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ const std::shared_ptr<A> pA(new A);
+ A* ptrA = pA.get();
+ {
+ std::shared_ptr<B> pB(new B);
+ pB = pA;
+ assert(B::count == 1);
+ assert(A::count == 1);
+ assert(pB.use_count() == 2);
+ assert(pA.use_count() == 2);
+ assert(pA.get() == pB.get());
+ assert(pB.get() == ptrA);
+ }
+ assert(pA.use_count() == 1);
+ assert(B::count == 1);
+ assert(A::count == 1);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+ {
+ const std::shared_ptr<A> pA;
+ A* ptrA = pA.get();
+ {
+ std::shared_ptr<B> pB(new B);
+ pB = pA;
+ assert(B::count == 0);
+ assert(A::count == 0);
+ assert(pB.use_count() == 0);
+ assert(pA.use_count() == 0);
+ assert(pA.get() == pB.get());
+ assert(pB.get() == ptrA);
+ }
+ assert(pA.use_count() == 0);
+ assert(B::count == 0);
+ assert(A::count == 0);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+ {
+ const std::shared_ptr<A> pA(new A);
+ A* ptrA = pA.get();
+ {
+ std::shared_ptr<B> pB;
+ pB = pA;
+ assert(B::count == 1);
+ assert(A::count == 1);
+ assert(pB.use_count() == 2);
+ assert(pA.use_count() == 2);
+ assert(pA.get() == pB.get());
+ assert(pB.get() == ptrA);
+ }
+ assert(pA.use_count() == 1);
+ assert(B::count == 1);
+ assert(A::count == 1);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+ {
+ const std::shared_ptr<A> pA;
+ A* ptrA = pA.get();
+ {
+ std::shared_ptr<B> pB;
+ pB = pA;
+ assert(B::count == 0);
+ assert(A::count == 0);
+ assert(pB.use_count() == 0);
+ assert(pA.use_count() == 0);
+ assert(pA.get() == pB.get());
+ assert(pB.get() == ptrA);
+ }
+ assert(pA.use_count() == 0);
+ assert(B::count == 0);
+ assert(A::count == 0);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr_Y_rv.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr_Y_rv.pass.cpp
new file mode 100644
index 000000000000..93956bcae663
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr_Y_rv.pass.cpp
@@ -0,0 +1,123 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// template<class Y> shared_ptr& operator=(shared_ptr<Y>&& r);
+
+#include <memory>
+#include <type_traits>
+#include <cassert>
+
+struct B
+{
+ static int count;
+
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+struct A
+ : public B
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::shared_ptr<A> pA(new A);
+ A* ptrA = pA.get();
+ {
+ std::shared_ptr<B> pB(new B);
+ pB = std::move(pA);
+ assert(B::count == 1);
+ assert(A::count == 1);
+ assert(pB.use_count() == 1);
+ assert(pA.use_count() == 0);
+ assert(pA.get() == 0);
+ assert(pB.get() == ptrA);
+ }
+ assert(pA.use_count() == 0);
+ assert(B::count == 0);
+ assert(A::count == 0);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+ {
+ std::shared_ptr<A> pA;
+ A* ptrA = pA.get();
+ {
+ std::shared_ptr<B> pB(new B);
+ pB = std::move(pA);
+ assert(B::count == 0);
+ assert(A::count == 0);
+ assert(pB.use_count() == 0);
+ assert(pA.use_count() == 0);
+ assert(pA.get() == 0);
+ assert(pB.get() == ptrA);
+ }
+ assert(pA.use_count() == 0);
+ assert(B::count == 0);
+ assert(A::count == 0);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+ {
+ std::shared_ptr<A> pA(new A);
+ A* ptrA = pA.get();
+ {
+ std::shared_ptr<B> pB;
+ pB = std::move(pA);
+ assert(B::count == 1);
+ assert(A::count == 1);
+ assert(pB.use_count() == 1);
+ assert(pA.use_count() == 0);
+ assert(pA.get() == 0);
+ assert(pB.get() == ptrA);
+ }
+ assert(pA.use_count() == 0);
+ assert(B::count == 0);
+ assert(A::count == 0);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+ {
+ std::shared_ptr<A> pA;
+ A* ptrA = pA.get();
+ {
+ std::shared_ptr<B> pB;
+ pB = std::move(pA);
+ assert(B::count == 0);
+ assert(A::count == 0);
+ assert(pB.use_count() == 0);
+ assert(pA.use_count() == 0);
+ assert(pA.get() == 0);
+ assert(pB.get() == ptrA);
+ }
+ assert(pA.use_count() == 0);
+ assert(B::count == 0);
+ assert(A::count == 0);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr_rv.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr_rv.pass.cpp
new file mode 100644
index 000000000000..4194890dda2d
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr_rv.pass.cpp
@@ -0,0 +1,123 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// shared_ptr& operator=(shared_ptr&& r);
+
+#include <memory>
+#include <type_traits>
+#include <cassert>
+
+struct B
+{
+ static int count;
+
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+struct A
+ : public B
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::shared_ptr<A> pA(new A);
+ A* ptrA = pA.get();
+ {
+ std::shared_ptr<A> pB(new A);
+ pB = std::move(pA);
+ assert(B::count == 1);
+ assert(A::count == 1);
+ assert(pB.use_count() == 1);
+ assert(pA.use_count() == 0);
+ assert(pA.get() == 0);
+ assert(pB.get() == ptrA);
+ }
+ assert(pA.use_count() == 0);
+ assert(B::count == 0);
+ assert(A::count == 0);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+ {
+ std::shared_ptr<A> pA;
+ A* ptrA = pA.get();
+ {
+ std::shared_ptr<A> pB(new A);
+ pB = std::move(pA);
+ assert(B::count == 0);
+ assert(A::count == 0);
+ assert(pB.use_count() == 0);
+ assert(pA.use_count() == 0);
+ assert(pA.get() == 0);
+ assert(pB.get() == ptrA);
+ }
+ assert(pA.use_count() == 0);
+ assert(B::count == 0);
+ assert(A::count == 0);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+ {
+ std::shared_ptr<A> pA(new A);
+ A* ptrA = pA.get();
+ {
+ std::shared_ptr<A> pB;
+ pB = std::move(pA);
+ assert(B::count == 1);
+ assert(A::count == 1);
+ assert(pB.use_count() == 1);
+ assert(pA.use_count() == 0);
+ assert(pA.get() == 0);
+ assert(pB.get() == ptrA);
+ }
+ assert(pA.use_count() == 0);
+ assert(B::count == 0);
+ assert(A::count == 0);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+ {
+ std::shared_ptr<A> pA;
+ A* ptrA = pA.get();
+ {
+ std::shared_ptr<A> pB;
+ pB = std::move(pA);
+ assert(B::count == 0);
+ assert(A::count == 0);
+ assert(pB.use_count() == 0);
+ assert(pA.use_count() == 0);
+ assert(pA.get() == 0);
+ assert(pB.get() == ptrA);
+ }
+ assert(pA.use_count() == 0);
+ assert(B::count == 0);
+ assert(A::count == 0);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+#endif // _LIBCXX_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/unique_ptr_Y.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/unique_ptr_Y.pass.cpp
new file mode 100644
index 000000000000..30e0fce21e04
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/unique_ptr_Y.pass.cpp
@@ -0,0 +1,113 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// template <class Y, class D> shared_ptr& operator=(unique_ptr<Y, D>&& r);
+
+#include <memory>
+#include <type_traits>
+#include <cassert>
+
+struct B
+{
+ static int count;
+
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+struct A
+ : public B
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ std::unique_ptr<A> pA(new A);
+ A* ptrA = pA.get();
+ {
+ std::shared_ptr<B> pB(new B);
+ pB = std::move(pA);
+ assert(B::count == 1);
+ assert(A::count == 1);
+ assert(pB.use_count() == 1);
+ assert(pA.get() == 0);
+ assert(pB.get() == ptrA);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+ {
+ std::unique_ptr<A> pA;
+ A* ptrA = pA.get();
+ {
+ std::shared_ptr<B> pB(new B);
+ pB = std::move(pA);
+ assert(B::count == 0);
+ assert(A::count == 0);
+// assert(pB.use_count() == 1); // no longer true due to LWG 2415
+ assert(pA.get() == 0);
+ assert(pB.get() == ptrA);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+ {
+ std::unique_ptr<A> pA(new A);
+ A* ptrA = pA.get();
+ {
+ std::shared_ptr<B> pB;
+ pB = std::move(pA);
+ assert(B::count == 1);
+ assert(A::count == 1);
+ assert(pB.use_count() == 1);
+ assert(pA.get() == 0);
+ assert(pB.get() == ptrA);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+ {
+ std::unique_ptr<A> pA;
+ A* ptrA = pA.get();
+ {
+ std::shared_ptr<B> pB;
+ pB = std::move(pA);
+ assert(B::count == 0);
+ assert(A::count == 0);
+// assert(pB.use_count() == 1); // no longer true due to LWG 2415
+ assert(pA.get() == 0);
+ assert(pB.get() == ptrA);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cast/const_pointer_cast.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cast/const_pointer_cast.pass.cpp
new file mode 100644
index 000000000000..7d771d03c71f
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cast/const_pointer_cast.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// template<class T, class U> shared_ptr<T> const_pointer_cast(const shared_ptr<U>& r);
+
+#include <memory>
+#include <type_traits>
+#include <cassert>
+
+struct B
+{
+ static int count;
+
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+struct A
+ : public B
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ const std::shared_ptr<const A> pA(new A);
+ std::shared_ptr<A> pB = std::const_pointer_cast<A>(pA);
+ assert(pB.get() == pA.get());
+ assert(!pB.owner_before(pA) && !pA.owner_before(pB));
+ }
+ {
+ const std::shared_ptr<const A> pA;
+ std::shared_ptr<A> pB = std::const_pointer_cast<A>(pA);
+ assert(pB.get() == pA.get());
+ assert(!pB.owner_before(pA) && !pA.owner_before(pB));
+ }
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cast/dynamic_pointer_cast.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cast/dynamic_pointer_cast.pass.cpp
new file mode 100644
index 000000000000..4f88a5c4351a
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cast/dynamic_pointer_cast.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// template<class T, class U> shared_ptr<T> dynamic_pointer_cast(const shared_ptr<U>& r);
+
+#include <memory>
+#include <type_traits>
+#include <cassert>
+
+struct B
+{
+ static int count;
+
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+struct A
+ : public B
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ const std::shared_ptr<B> pB(new A);
+ std::shared_ptr<A> pA = std::dynamic_pointer_cast<A>(pB);
+ assert(pA.get() == pB.get());
+ assert(!pB.owner_before(pA) && !pA.owner_before(pB));
+ }
+ {
+ const std::shared_ptr<B> pB(new B);
+ std::shared_ptr<A> pA = std::dynamic_pointer_cast<A>(pB);
+ assert(pA.get() == 0);
+ assert(pA.use_count() == 0);
+ }
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cast/static_pointer_cast.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cast/static_pointer_cast.pass.cpp
new file mode 100644
index 000000000000..98fa13801a8c
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cast/static_pointer_cast.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// template<class T, class U> shared_ptr<T> static_pointer_cast(const shared_ptr<U>& r);
+
+#include <memory>
+#include <type_traits>
+#include <cassert>
+
+struct B
+{
+ static int count;
+
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+struct A
+ : public B
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ const std::shared_ptr<A> pA(new A);
+ std::shared_ptr<B> pB = std::static_pointer_cast<B>(pA);
+ assert(pB.get() == pA.get());
+ assert(!pB.owner_before(pA) && !pA.owner_before(pB));
+ }
+ {
+ const std::shared_ptr<B> pA(new A);
+ std::shared_ptr<A> pB = std::static_pointer_cast<A>(pA);
+ assert(pB.get() == pA.get());
+ assert(!pB.owner_before(pA) && !pA.owner_before(pB));
+ }
+ {
+ const std::shared_ptr<A> pA;
+ std::shared_ptr<B> pB = std::static_pointer_cast<B>(pA);
+ assert(pB.get() == pA.get());
+ assert(!pB.owner_before(pA) && !pA.owner_before(pB));
+ }
+ {
+ const std::shared_ptr<B> pA;
+ std::shared_ptr<A> pB = std::static_pointer_cast<A>(pA);
+ assert(pB.get() == pA.get());
+ assert(!pB.owner_before(pA) && !pA.owner_before(pB));
+ }
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cmp/cmp_nullptr.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cmp/cmp_nullptr.pass.cpp
new file mode 100644
index 000000000000..f40cbc3d0324
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cmp/cmp_nullptr.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// template <class T>
+// bool operator==(const shared_ptr<T>& x, nullptr_t) noexcept;
+// template <class T>
+// bool operator==(nullptr_t, const shared_ptr<T>& y) noexcept;
+// template <class T>
+// bool operator!=(const shared_ptr<T>& x, nullptr_t) noexcept;
+// template <class T>
+// bool operator!=(nullptr_t, const shared_ptr<T>& y) noexcept;
+// template <class T>
+// bool operator<(const shared_ptr<T>& x, nullptr_t) noexcept;
+// template <class T>
+// bool operator<(nullptr_t, const shared_ptr<T>& y) noexcept;
+// template <class T>
+// bool operator<=(const shared_ptr<T>& x, nullptr_t) noexcept;
+// template <class T>
+// bool operator<=(nullptr_t, const shared_ptr<T>& y) noexcept;
+// template <class T>
+// bool operator>(const shared_ptr<T>& x, nullptr_t) noexcept;
+// template <class T>
+// bool operator>(nullptr_t, const shared_ptr<T>& y) noexcept;
+// template <class T>
+// bool operator>=(const shared_ptr<T>& x, nullptr_t) noexcept;
+// template <class T>
+// bool operator>=(nullptr_t, const shared_ptr<T>& y) noexcept;
+
+#include <memory>
+#include <cassert>
+
+void do_nothing(int*) {}
+
+int main()
+{
+ const std::shared_ptr<int> p1(new int(1));
+ assert(!(p1 == nullptr));
+ assert(!(nullptr == p1));
+ assert(!(p1 < nullptr));
+ assert( (nullptr < p1));
+ assert(!(p1 <= nullptr));
+ assert( (nullptr <= p1));
+ assert( (p1 > nullptr));
+ assert(!(nullptr > p1));
+ assert( (p1 >= nullptr));
+ assert(!(nullptr >= p1));
+
+ const std::shared_ptr<int> p2;
+ assert( (p2 == nullptr));
+ assert( (nullptr == p2));
+ assert(!(p2 < nullptr));
+ assert(!(nullptr < p2));
+ assert( (p2 <= nullptr));
+ assert( (nullptr <= p2));
+ assert(!(p2 > nullptr));
+ assert(!(nullptr > p2));
+ assert( (p2 >= nullptr));
+ assert( (nullptr >= p2));
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cmp/eq.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cmp/eq.pass.cpp
new file mode 100644
index 000000000000..c4cd1693f496
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cmp/eq.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// template<class T, class U> bool operator==(const shared_ptr<T>& a, const shared_ptr<U>& b);
+// template<class T, class U> bool operator!=(const shared_ptr<T>& a, const shared_ptr<U>& b);
+
+#include <memory>
+#include <cassert>
+
+void do_nothing(int*) {}
+
+int main()
+{
+ int* ptr1(new int);
+ int* ptr2(new int);
+ const std::shared_ptr<int> p1(ptr1);
+ const std::shared_ptr<int> p2(ptr2);
+ const std::shared_ptr<int> p3(ptr2, do_nothing);
+ assert(p1 != p2);
+ assert(p2 == p3);
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cmp/lt.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cmp/lt.pass.cpp
new file mode 100644
index 000000000000..5a90a9a325fa
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cmp/lt.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// template<class T, class U> bool operator<(const shared_ptr<T>& a, const shared_ptr<U>& b);
+
+#include <memory>
+#include <cassert>
+
+void do_nothing(int*) {}
+
+int main()
+{
+ int* ptr1(new int);
+ int* ptr2(new int);
+ const std::shared_ptr<int> p1(ptr1);
+ const std::shared_ptr<int> p2(ptr2);
+ const std::shared_ptr<int> p3(ptr2, do_nothing);
+ assert((p1 < p2) == (ptr1 < ptr2));
+ assert(!(p2 < p3) && !(p3 < p2));
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/auto_ptr.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/auto_ptr.pass.cpp
new file mode 100644
index 000000000000..b2e61faff5ed
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/auto_ptr.pass.cpp
@@ -0,0 +1,104 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template<class Y> explicit shared_ptr(auto_ptr<Y>&& r);
+
+// UNSUPPORTED: sanitizer-new-delete
+
+#include <memory>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+bool throw_next = false;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+ if (throw_next)
+ throw std::bad_alloc();
+ return std::malloc(s);
+}
+
+void operator delete(void* p) throw()
+{
+ std::free(p);
+}
+
+struct B
+{
+ static int count;
+
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+struct A
+ : public B
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ std::auto_ptr<A> ptr(new A);
+ A* raw_ptr = ptr.get();
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ std::shared_ptr<B> p(std::move(ptr));
+#else
+ std::shared_ptr<B> p(ptr);
+#endif
+ assert(A::count == 1);
+ assert(B::count == 1);
+ assert(p.use_count() == 1);
+ assert(p.get() == raw_ptr);
+ assert(ptr.get() == 0);
+ }
+ assert(A::count == 0);
+ {
+ std::auto_ptr<A> ptr(new A);
+ A* raw_ptr = ptr.get();
+ throw_next = true;
+ try
+ {
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ std::shared_ptr<B> p(std::move(ptr));
+#else
+ std::shared_ptr<B> p(ptr);
+#endif
+ assert(false);
+ }
+ catch (...)
+ {
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ assert(A::count == 1);
+ assert(B::count == 1);
+ assert(ptr.get() == raw_ptr);
+#else
+ // Without rvalue references, ptr got copied into
+ // the shared_ptr destructor and the copy was
+ // destroyed during unwinding.
+ assert(A::count == 0);
+ assert(B::count == 0);
+#endif
+ }
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/default.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/default.pass.cpp
new file mode 100644
index 000000000000..9af5d7ea8619
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/default.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr();
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+ std::shared_ptr<int> p;
+ assert(p.use_count() == 0);
+ assert(p.get() == 0);
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t.pass.cpp
new file mode 100644
index 000000000000..3a9b3a9ca1de
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr(nullptr_t)
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+ std::shared_ptr<int> p(nullptr);
+ assert(p.use_count() == 0);
+ assert(p.get() == 0);
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter.pass.cpp
new file mode 100644
index 000000000000..7d4dc38d4b9a
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// template<class D> shared_ptr(nullptr_t, D d);
+
+#include <memory>
+#include <cassert>
+#include "../test_deleter.h"
+
+struct A
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ std::shared_ptr<A> p(nullptr, test_deleter<A>(3));
+ assert(A::count == 0);
+ assert(p.use_count() == 1);
+ assert(p.get() == 0);
+ test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p);
+ assert(test_deleter<A>::count == 1);
+ assert(test_deleter<A>::dealloc_count == 0);
+ assert(d);
+ assert(d->state() == 3);
+ }
+ assert(A::count == 0);
+ assert(test_deleter<A>::count == 0);
+ assert(test_deleter<A>::dealloc_count == 1);
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator.pass.cpp
new file mode 100644
index 000000000000..b67f31ee45a8
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator.pass.cpp
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template<class D, class A> shared_ptr(nullptr_t, D d, A a);
+
+#include <memory>
+#include <cassert>
+#include "../test_deleter.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+struct A
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ std::shared_ptr<A> p(nullptr, test_deleter<A>(3), test_allocator<A>(5));
+ assert(A::count == 0);
+ assert(p.use_count() == 1);
+ assert(p.get() == 0);
+ test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p);
+ assert(test_deleter<A>::count == 1);
+ assert(test_deleter<A>::dealloc_count == 0);
+ assert(d);
+ assert(d->state() == 3);
+ assert(test_allocator<A>::count == 1);
+ assert(test_allocator<A>::alloc_count == 1);
+ }
+ assert(A::count == 0);
+ assert(test_deleter<A>::count == 0);
+ assert(test_deleter<A>::dealloc_count == 1);
+ assert(test_allocator<A>::count == 0);
+ assert(test_allocator<A>::alloc_count == 0);
+ test_deleter<A>::dealloc_count = 0;
+ // Test an allocator with a minimal interface
+ {
+ std::shared_ptr<A> p(nullptr, test_deleter<A>(1), bare_allocator<void>());
+ assert(A::count == 0);
+ assert(p.use_count() == 1);
+ assert(p.get() == 0);
+ test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p);
+ assert(test_deleter<A>::count ==1);
+ assert(test_deleter<A>::dealloc_count == 0);
+ assert(d);
+ assert(d->state() == 1);
+ }
+ assert(A::count == 0);
+ assert(test_deleter<A>::count == 0);
+ assert(test_deleter<A>::dealloc_count == 1);
+ test_deleter<A>::dealloc_count = 0;
+#if __cplusplus >= 201103L
+ // Test an allocator that returns class-type pointers
+ {
+ std::shared_ptr<A> p(nullptr, test_deleter<A>(1), min_allocator<void>());
+ assert(A::count == 0);
+ assert(p.use_count() == 1);
+ assert(p.get() == 0);
+ test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p);
+ assert(test_deleter<A>::count ==1);
+ assert(test_deleter<A>::dealloc_count == 0);
+ assert(d);
+ assert(d->state() == 1);
+ }
+ assert(A::count == 0);
+ assert(test_deleter<A>::count == 0);
+ assert(test_deleter<A>::dealloc_count == 1);
+#endif
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator_throw.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator_throw.pass.cpp
new file mode 100644
index 000000000000..ab2c73e0c5f1
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator_throw.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template<class D, class A> shared_ptr(nullptr_t, D d, A a);
+
+#include <memory>
+#include <cassert>
+#include "../test_deleter.h"
+#include "test_allocator.h"
+
+struct A
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ try
+ {
+ test_allocator<A>::throw_after = 0;
+ std::shared_ptr<A> p(nullptr, test_deleter<A>(3), test_allocator<A>(5));
+ assert(false);
+ }
+ catch (std::bad_alloc&)
+ {
+ assert(A::count == 0);
+ assert(test_deleter<A>::count == 0);
+ assert(test_deleter<A>::dealloc_count == 1);
+ assert(test_allocator<A>::count == 0);
+ assert(test_allocator<A>::alloc_count == 0);
+ }
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_throw.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_throw.pass.cpp
new file mode 100644
index 000000000000..97d3f69fb5c4
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_throw.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// template<class D> shared_ptr(nullptr_t, D d);
+
+// UNSUPPORTED: sanitizer-new-delete
+
+#include <memory>
+#include <cassert>
+#include <new>
+#include <cstdlib>
+#include "../test_deleter.h"
+
+struct A
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+bool throw_next = false;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+ if (throw_next)
+ throw std::bad_alloc();
+ return std::malloc(s);
+}
+
+void operator delete(void* p) throw()
+{
+ std::free(p);
+}
+
+int main()
+{
+ throw_next = true;
+ try
+ {
+ std::shared_ptr<A> p(nullptr, test_deleter<A>(3));
+ assert(false);
+ }
+ catch (std::bad_alloc&)
+ {
+ assert(A::count == 0);
+ assert(test_deleter<A>::count == 0);
+ assert(test_deleter<A>::dealloc_count == 1);
+ }
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer.pass.cpp
new file mode 100644
index 000000000000..c9cffa1fe25e
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template<class Y> explicit shared_ptr(Y* p);
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ A* ptr = new A;
+ std::shared_ptr<A> p(ptr);
+ assert(A::count == 1);
+ assert(p.use_count() == 1);
+ assert(p.get() == ptr);
+ }
+ assert(A::count == 0);
+ {
+ A* ptr = new A;
+ std::shared_ptr<void> p(ptr);
+ assert(A::count == 1);
+ assert(p.use_count() == 1);
+ assert(p.get() == ptr);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter.pass.cpp
new file mode 100644
index 000000000000..43eedee176c2
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// template<class Y, class D> shared_ptr(Y* p, D d);
+
+#include <memory>
+#include <cassert>
+#include "../test_deleter.h"
+
+struct A
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ A* ptr = new A;
+ std::shared_ptr<A> p(ptr, test_deleter<A>(3));
+ assert(A::count == 1);
+ assert(p.use_count() == 1);
+ assert(p.get() == ptr);
+ test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p);
+ assert(test_deleter<A>::count == 1);
+ assert(test_deleter<A>::dealloc_count == 0);
+ assert(d);
+ assert(d->state() == 3);
+ }
+ assert(A::count == 0);
+ assert(test_deleter<A>::count == 0);
+ assert(test_deleter<A>::dealloc_count == 1);
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator.pass.cpp
new file mode 100644
index 000000000000..1a9c09cdb78c
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator.pass.cpp
@@ -0,0 +1,89 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template<class Y, class D, class A> shared_ptr(Y* p, D d, A a);
+
+#include <memory>
+#include <cassert>
+#include "../test_deleter.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+struct A
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+
+int main()
+{
+ {
+ A* ptr = new A;
+ std::shared_ptr<A> p(ptr, test_deleter<A>(3), test_allocator<A>(5));
+ assert(A::count == 1);
+ assert(p.use_count() == 1);
+ assert(p.get() == ptr);
+ test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p);
+ assert(test_deleter<A>::count == 1);
+ assert(test_deleter<A>::dealloc_count == 0);
+ assert(d);
+ assert(d->state() == 3);
+ assert(test_allocator<A>::count == 1);
+ assert(test_allocator<A>::alloc_count == 1);
+ }
+ assert(A::count == 0);
+ assert(test_deleter<A>::count == 0);
+ assert(test_deleter<A>::dealloc_count == 1);
+ assert(test_allocator<A>::count == 0);
+ assert(test_allocator<A>::alloc_count == 0);
+ test_deleter<A>::dealloc_count = 0;
+ // Test an allocator with a minimal interface
+ {
+ A* ptr = new A;
+ std::shared_ptr<A> p(ptr, test_deleter<A>(3), bare_allocator<void>());
+ assert(A::count == 1);
+ assert(p.use_count() == 1);
+ assert(p.get() == ptr);
+ test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p);
+ assert(test_deleter<A>::count == 1);
+ assert(test_deleter<A>::dealloc_count == 0);
+ assert(d);
+ assert(d->state() == 3);
+ }
+ assert(A::count == 0);
+ assert(test_deleter<A>::count == 0);
+ assert(test_deleter<A>::dealloc_count == 1);
+ test_deleter<A>::dealloc_count = 0;
+#if __cplusplus >= 201103L
+ // Test an allocator that returns class-type pointers
+ {
+ A* ptr = new A;
+ std::shared_ptr<A> p(ptr, test_deleter<A>(3), min_allocator<void>());
+ assert(A::count == 1);
+ assert(p.use_count() == 1);
+ assert(p.get() == ptr);
+ test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p);
+ assert(test_deleter<A>::count == 1);
+ assert(test_deleter<A>::dealloc_count == 0);
+ assert(d);
+ assert(d->state() == 3);
+ }
+ assert(A::count == 0);
+ assert(test_deleter<A>::count == 0);
+ assert(test_deleter<A>::dealloc_count == 1);
+#endif
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator_throw.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator_throw.pass.cpp
new file mode 100644
index 000000000000..4220993a5fd1
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator_throw.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template<class Y, class D, class A> shared_ptr(Y* p, D d, A a);
+
+#include <memory>
+#include <cassert>
+#include "../test_deleter.h"
+#include "test_allocator.h"
+
+struct A
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ A* ptr = new A;
+ try
+ {
+ test_allocator<A>::throw_after = 0;
+ std::shared_ptr<A> p(ptr, test_deleter<A>(3), test_allocator<A>(5));
+ assert(false);
+ }
+ catch (std::bad_alloc&)
+ {
+ assert(A::count == 0);
+ assert(test_deleter<A>::count == 0);
+ assert(test_deleter<A>::dealloc_count == 1);
+ assert(test_allocator<A>::count == 0);
+ assert(test_allocator<A>::alloc_count == 0);
+ }
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_throw.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_throw.pass.cpp
new file mode 100644
index 000000000000..ead081645671
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_throw.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// template<class Y, class D> shared_ptr(Y* p, D d);
+
+// UNSUPPORTED: sanitizer-new-delete
+
+#include <memory>
+#include <cassert>
+#include <new>
+#include <cstdlib>
+#include "../test_deleter.h"
+
+struct A
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+bool throw_next = false;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+ if (throw_next)
+ throw std::bad_alloc();
+ return std::malloc(s);
+}
+
+void operator delete(void* p) throw()
+{
+ std::free(p);
+}
+
+int main()
+{
+ A* ptr = new A;
+ throw_next = true;
+ try
+ {
+ std::shared_ptr<A> p(ptr, test_deleter<A>(3));
+ assert(false);
+ }
+ catch (std::bad_alloc&)
+ {
+ assert(A::count == 0);
+ assert(test_deleter<A>::count == 0);
+ assert(test_deleter<A>::dealloc_count == 1);
+ }
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_throw.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_throw.pass.cpp
new file mode 100644
index 000000000000..041fe9a7853d
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_throw.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template<class Y> explicit shared_ptr(Y* p);
+
+// UNSUPPORTED: sanitizer-new-delete
+
+#include <memory>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+struct A
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+bool throw_next = false;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+ if (throw_next)
+ throw std::bad_alloc();
+ return std::malloc(s);
+}
+
+void operator delete(void* p) throw()
+{
+ std::free(p);
+}
+
+int main()
+{
+ {
+ A* ptr = new A;
+ throw_next = true;
+ assert(A::count == 1);
+ try
+ {
+ std::shared_ptr<A> p(ptr);
+ assert(false);
+ }
+ catch (std::bad_alloc&)
+ {
+ assert(A::count == 0);
+ }
+ }
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr.pass.cpp
new file mode 100644
index 000000000000..e1dcdfc8165f
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// shared_ptr(const shared_ptr& r);
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ std::shared_ptr<A> pA(new A);
+ assert(pA.use_count() == 1);
+ assert(A::count == 1);
+ {
+ std::shared_ptr<A> pA2(pA);
+ assert(A::count == 1);
+ assert(pA.use_count() == 2);
+ assert(pA2.use_count() == 2);
+ assert(pA2.get() == pA.get());
+ }
+ assert(pA.use_count() == 1);
+ assert(A::count == 1);
+ }
+ assert(A::count == 0);
+ {
+ std::shared_ptr<A> pA;
+ assert(pA.use_count() == 0);
+ assert(A::count == 0);
+ {
+ std::shared_ptr<A> pA2(pA);
+ assert(A::count == 0);
+ assert(pA.use_count() == 0);
+ assert(pA2.use_count() == 0);
+ assert(pA2.get() == pA.get());
+ }
+ assert(pA.use_count() == 0);
+ assert(A::count == 0);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_Y.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_Y.pass.cpp
new file mode 100644
index 000000000000..8b5ffdc1475b
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_Y.pass.cpp
@@ -0,0 +1,97 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// template<class Y> shared_ptr(const shared_ptr<Y>& r);
+
+#include <memory>
+#include <type_traits>
+#include <cassert>
+
+struct B
+{
+ static int count;
+
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+struct A
+ : public B
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct C
+{
+ static int count;
+
+ C() {++count;}
+ C(const C&) {++count;}
+ virtual ~C() {--count;}
+};
+
+int C::count = 0;
+
+int main()
+{
+ static_assert(( std::is_convertible<std::shared_ptr<A>, std::shared_ptr<B> >::value), "");
+ static_assert((!std::is_convertible<std::shared_ptr<B>, std::shared_ptr<A> >::value), "");
+ static_assert((!std::is_convertible<std::shared_ptr<A>, std::shared_ptr<C> >::value), "");
+ {
+ const std::shared_ptr<A> pA(new A);
+ assert(pA.use_count() == 1);
+ assert(B::count == 1);
+ assert(A::count == 1);
+ {
+ std::shared_ptr<B> pB(pA);
+ assert(B::count == 1);
+ assert(A::count == 1);
+ assert(pB.use_count() == 2);
+ assert(pA.use_count() == 2);
+ assert(pA.get() == pB.get());
+ }
+ assert(pA.use_count() == 1);
+ assert(B::count == 1);
+ assert(A::count == 1);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+ {
+ std::shared_ptr<A> pA;
+ assert(pA.use_count() == 0);
+ assert(B::count == 0);
+ assert(A::count == 0);
+ {
+ std::shared_ptr<B> pB(pA);
+ assert(B::count == 0);
+ assert(A::count == 0);
+ assert(pB.use_count() == 0);
+ assert(pA.use_count() == 0);
+ assert(pA.get() == pB.get());
+ }
+ assert(pA.use_count() == 0);
+ assert(B::count == 0);
+ assert(A::count == 0);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_Y_rv.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_Y_rv.pass.cpp
new file mode 100644
index 000000000000..f041d9451a6d
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_Y_rv.pass.cpp
@@ -0,0 +1,109 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// template<class Y> shared_ptr(shared_ptr<Y>&& r);
+
+#include <memory>
+#include <type_traits>
+#include <cassert>
+
+struct B
+{
+ static int count;
+
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+struct A
+ : public B
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct C
+{
+ static int count;
+
+ C() {++count;}
+ C(const C&) {++count;}
+ virtual ~C() {--count;}
+};
+
+int C::count = 0;
+
+int main()
+{
+ static_assert(( std::is_convertible<std::shared_ptr<A>, std::shared_ptr<B> >::value), "");
+ static_assert((!std::is_convertible<std::shared_ptr<B>, std::shared_ptr<A> >::value), "");
+ static_assert((!std::is_convertible<std::shared_ptr<A>, std::shared_ptr<C> >::value), "");
+ {
+ std::shared_ptr<A> pA(new A);
+ assert(pA.use_count() == 1);
+ assert(B::count == 1);
+ assert(A::count == 1);
+ {
+ B* p = pA.get();
+ std::shared_ptr<B> pB(std::move(pA));
+ assert(B::count == 1);
+ assert(A::count == 1);
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ assert(pB.use_count() == 1);
+ assert(pA.use_count() == 0);
+#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ assert(pB.use_count() == 2);
+ assert(pA.use_count() == 2);
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ assert(p == pB.get());
+ }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ assert(pA.use_count() == 0);
+ assert(B::count == 0);
+ assert(A::count == 0);
+#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ assert(pA.use_count() == 1);
+ assert(B::count == 1);
+ assert(A::count == 1);
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+ {
+ std::shared_ptr<A> pA;
+ assert(pA.use_count() == 0);
+ assert(B::count == 0);
+ assert(A::count == 0);
+ {
+ std::shared_ptr<B> pB(pA);
+ assert(B::count == 0);
+ assert(A::count == 0);
+ assert(pB.use_count() == 0);
+ assert(pA.use_count() == 0);
+ assert(pA.get() == pB.get());
+ }
+ assert(pA.use_count() == 0);
+ assert(B::count == 0);
+ assert(A::count == 0);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_pointer.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_pointer.pass.cpp
new file mode 100644
index 000000000000..fb5262f3b0ef
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_pointer.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// template<class Y> shared_ptr(const shared_ptr<Y>& r, T *p);
+
+#include <memory>
+#include <cassert>
+
+struct B
+{
+ static int count;
+
+ B() {++count;}
+ B(const B&) {++count;}
+ ~B() {--count;}
+};
+
+int B::count = 0;
+
+struct A
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ std::shared_ptr<A> pA(new A);
+ assert(pA.use_count() == 1);
+ {
+ B b;
+ std::shared_ptr<B> pB(pA, &b);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ assert(pA.use_count() == 2);
+ assert(pB.use_count() == 2);
+ assert(pB.get() == &b);
+ }
+ assert(pA.use_count() == 1);
+ assert(A::count == 1);
+ assert(B::count == 0);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_rv.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_rv.pass.cpp
new file mode 100644
index 000000000000..b89178e201cf
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_rv.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// shared_ptr(shared_ptr&& r);
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ std::shared_ptr<A> pA(new A);
+ assert(pA.use_count() == 1);
+ assert(A::count == 1);
+ {
+ A* p = pA.get();
+ std::shared_ptr<A> pA2(std::move(pA));
+ assert(A::count == 1);
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ assert(pA.use_count() == 0);
+ assert(pA2.use_count() == 1);
+#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ assert(pA.use_count() == 2);
+ assert(pA2.use_count() == 2);
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ assert(pA2.get() == p);
+ }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ assert(pA.use_count() == 0);
+ assert(A::count == 0);
+#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ assert(pA.use_count() == 1);
+ assert(A::count == 1);
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ }
+ assert(A::count == 0);
+ {
+ std::shared_ptr<A> pA;
+ assert(pA.use_count() == 0);
+ assert(A::count == 0);
+ {
+ std::shared_ptr<A> pA2(std::move(pA));
+ assert(A::count == 0);
+ assert(pA.use_count() == 0);
+ assert(pA2.use_count() == 0);
+ assert(pA2.get() == pA.get());
+ }
+ assert(pA.use_count() == 0);
+ assert(A::count == 0);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/unique_ptr.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/unique_ptr.pass.cpp
new file mode 100644
index 000000000000..5e09d9a7934c
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/unique_ptr.pass.cpp
@@ -0,0 +1,115 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Y, class D> explicit shared_ptr(unique_ptr<Y, D>&&r);
+
+// UNSUPPORTED: sanitizer-new-delete
+
+#include <memory>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+bool throw_next = false;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+ if (throw_next)
+ throw std::bad_alloc();
+ return std::malloc(s);
+}
+
+void operator delete(void* p) throw()
+{
+ std::free(p);
+}
+
+struct B
+{
+ static int count;
+
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+struct A
+ : public B
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+void fn ( const std::shared_ptr<int> &) {}
+void fn ( const std::shared_ptr<B> &) { assert (false); }
+
+template <typename T>
+void assert_deleter ( T * ) { assert(false); }
+
+int main()
+{
+ {
+ std::unique_ptr<A> ptr(new A);
+ A* raw_ptr = ptr.get();
+ std::shared_ptr<B> p(std::move(ptr));
+ assert(A::count == 1);
+ assert(B::count == 1);
+ assert(p.use_count() == 1);
+ assert(p.get() == raw_ptr);
+ assert(ptr.get() == 0);
+ }
+ assert(A::count == 0);
+ {
+ std::unique_ptr<A> ptr(new A);
+ A* raw_ptr = ptr.get();
+ throw_next = true;
+ try
+ {
+ std::shared_ptr<B> p(std::move(ptr));
+ assert(false);
+ }
+ catch (...)
+ {
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ assert(A::count == 1);
+ assert(B::count == 1);
+ assert(ptr.get() == raw_ptr);
+#else
+ assert(A::count == 0);
+ assert(B::count == 0);
+ assert(ptr.get() == 0);
+#endif
+ }
+ }
+ assert(A::count == 0);
+
+ // LWG 2399
+ {
+ throw_next = false;
+ fn(std::unique_ptr<int>(new int));
+ }
+
+#if __cplusplus >= 201402L
+ // LWG 2415
+ {
+ std::unique_ptr<int, void (*)(int*)> p(nullptr, assert_deleter<int>);
+ std::shared_ptr<int> p2(std::move(p)); // should not call deleter when going out of scope
+ }
+#endif
+
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/weak_ptr.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/weak_ptr.pass.cpp
new file mode 100644
index 000000000000..a9d8aff145a7
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/weak_ptr.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// template<class Y> explicit shared_ptr(const weak_ptr<Y>& r);
+
+#include <memory>
+#include <cassert>
+
+struct B
+{
+ static int count;
+
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+struct A
+ : public B
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ std::weak_ptr<A> wp;
+ try
+ {
+ std::shared_ptr<A> sp(wp);
+ assert(false);
+ }
+ catch (std::bad_weak_ptr&)
+ {
+ }
+ assert(A::count == 0);
+ }
+ {
+ std::shared_ptr<A> sp0(new A);
+ std::weak_ptr<A> wp(sp0);
+ std::shared_ptr<A> sp(wp);
+ assert(sp.use_count() == 2);
+ assert(sp.get() == sp0.get());
+ assert(A::count == 1);
+ }
+ assert(A::count == 0);
+ {
+ std::shared_ptr<A> sp0(new A);
+ std::weak_ptr<A> wp(sp0);
+ sp0.reset();
+ try
+ {
+ std::shared_ptr<A> sp(wp);
+ assert(false);
+ }
+ catch (std::bad_weak_ptr&)
+ {
+ }
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared.pass.cpp
new file mode 100644
index 000000000000..aa77dab51515
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// template<class T, class A, class... Args>
+// shared_ptr<T> allocate_shared(const A& a, Args&&... args);
+
+#include <memory>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int new_count = 0;
+
+struct A
+{
+ static int count;
+
+ A(int i, char c) : int_(i), char_(c) {++count;}
+ A(const A& a)
+ : int_(a.int_), char_(a.char_)
+ {++count;}
+ ~A() {--count;}
+
+ int get_int() const {return int_;}
+ char get_char() const {return char_;}
+private:
+ int int_;
+ char char_;
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ int i = 67;
+ char c = 'e';
+ std::shared_ptr<A> p = std::allocate_shared<A>(test_allocator<A>(54), i, c);
+ assert(test_allocator<A>::alloc_count == 1);
+ assert(A::count == 1);
+ assert(p->get_int() == 67);
+ assert(p->get_char() == 'e');
+ }
+ assert(A::count == 0);
+ assert(test_allocator<A>::alloc_count == 0);
+#if __cplusplus >= 201103L
+ {
+ int i = 67;
+ char c = 'e';
+ std::shared_ptr<A> p = std::allocate_shared<A>(min_allocator<void>(), i, c);
+ assert(A::count == 1);
+ assert(p->get_int() == 67);
+ assert(p->get_char() == 'e');
+ }
+ assert(A::count == 0);
+ {
+ int i = 68;
+ char c = 'f';
+ std::shared_ptr<A> p = std::allocate_shared<A>(bare_allocator<void>(), i, c);
+ assert(A::count == 1);
+ assert(p->get_int() == 68);
+ assert(p->get_char() == 'f');
+ }
+ assert(A::count == 0);
+#endif
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared_no_variadics.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared_no_variadics.pass.cpp
new file mode 100644
index 000000000000..8dcd50e49411
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared_no_variadics.pass.cpp
@@ -0,0 +1,118 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// template<class T, class A, class... Args>
+// shared_ptr<T> allocate_shared(const A& a, Args&&... args);
+
+#define _LIBCPP_HAS_NO_VARIADICS
+#include <memory>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+struct Zero
+{
+ static int count;
+ Zero() {++count;}
+ Zero(Zero const &) {++count;}
+ ~Zero() {--count;}
+};
+
+int Zero::count = 0;
+
+struct One
+{
+ static int count;
+ int value;
+ explicit One(int v) : value(v) {++count;}
+ One(One const & o) : value(o.value) {++count;}
+ ~One() {--count;}
+};
+
+int One::count = 0;
+
+
+struct Two
+{
+ static int count;
+ int value;
+ Two(int v, int) : value(v) {++count;}
+ Two(Two const & o) : value(o.value) {++count;}
+ ~Two() {--count;}
+};
+
+int Two::count = 0;
+
+struct Three
+{
+ static int count;
+ int value;
+ Three(int v, int, int) : value(v) {++count;}
+ Three(Three const & o) : value(o.value) {++count;}
+ ~Three() {--count;}
+};
+
+int Three::count = 0;
+
+template <class Alloc>
+void test()
+{
+ int const bad = -1;
+ {
+ std::shared_ptr<Zero> p = std::allocate_shared<Zero>(Alloc());
+ assert(Zero::count == 1);
+ }
+ assert(Zero::count == 0);
+ {
+ int const i = 42;
+ std::shared_ptr<One> p = std::allocate_shared<One>(Alloc(), i);
+ assert(One::count == 1);
+ assert(p->value == i);
+ }
+ assert(One::count == 0);
+ {
+ int const i = 42;
+ std::shared_ptr<Two> p = std::allocate_shared<Two>(Alloc(), i, bad);
+ assert(Two::count == 1);
+ assert(p->value == i);
+ }
+ assert(Two::count == 0);
+ {
+ int const i = 42;
+ std::shared_ptr<Three> p = std::allocate_shared<Three>(Alloc(), i, bad, bad);
+ assert(Three::count == 1);
+ assert(p->value == i);
+ }
+ assert(Three::count == 0);
+}
+
+int main()
+{
+ {
+ int i = 67;
+ int const bad = -1;
+ std::shared_ptr<Two> p = std::allocate_shared<Two>(test_allocator<Two>(54), i, bad);
+ assert(test_allocator<Two>::alloc_count == 1);
+ assert(Two::count == 1);
+ assert(p->value == 67);
+ }
+ assert(Two::count == 0);
+ assert(test_allocator<Two>::alloc_count == 0);
+
+ test<bare_allocator<void> >();
+#if __cplusplus >= 201103L
+ test<min_allocator<void> >();
+#endif
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.pass.cpp
new file mode 100644
index 000000000000..8cb972b0c1a1
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.pass.cpp
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// template<class T, class... Args> shared_ptr<T> make_shared(Args&&... args);
+
+#include <memory>
+#include <cassert>
+
+#include "count_new.hpp"
+
+struct A
+{
+ static int count;
+
+ A(int i, char c) : int_(i), char_(c) {++count;}
+ A(const A& a)
+ : int_(a.int_), char_(a.char_)
+ {++count;}
+ ~A() {--count;}
+
+ int get_int() const {return int_;}
+ char get_char() const {return char_;}
+private:
+ int int_;
+ char char_;
+};
+
+int A::count = 0;
+
+
+struct Foo
+{
+ Foo() = default;
+ virtual ~Foo() = default;
+};
+
+
+int main()
+{
+ int nc = globalMemCounter.outstanding_new;
+ {
+ int i = 67;
+ char c = 'e';
+ std::shared_ptr<A> p = std::make_shared<A>(i, c);
+ assert(globalMemCounter.checkOutstandingNewEq(nc+1));
+ assert(A::count == 1);
+ assert(p->get_int() == 67);
+ assert(p->get_char() == 'e');
+ }
+
+ { // https://llvm.org/bugs/show_bug.cgi?id=24137
+ std::shared_ptr<Foo> p1 = std::make_shared<Foo>();
+ assert(p1.get());
+ std::shared_ptr<const Foo> p2 = std::make_shared<const Foo>();
+ assert(p2.get());
+ }
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ nc = globalMemCounter.outstanding_new;
+ {
+ char c = 'e';
+ std::shared_ptr<A> p = std::make_shared<A>(67, c);
+ assert(globalMemCounter.checkOutstandingNewEq(nc+1));
+ assert(A::count == 1);
+ assert(p->get_int() == 67);
+ assert(p->get_char() == 'e');
+ }
+#endif
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.volatile.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.volatile.pass.cpp
new file mode 100644
index 000000000000..1045f9347b38
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.volatile.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// template<class T, class... Args> shared_ptr<T> make_shared(Args&&... args);
+
+#include <memory>
+#include <cassert>
+
+template <typename T>
+void test(const T &t0)
+{
+ {
+ T t1 = t0;
+ std::shared_ptr<T> p0 = std::make_shared<T>(t0);
+ std::shared_ptr<T> p1 = std::make_shared<T>(t1);
+ assert(*p0 == t0);
+ assert(*p1 == t1);
+ }
+
+ {
+ const T t1 = t0;
+ std::shared_ptr<const T> p0 = std::make_shared<const T>(t0);
+ std::shared_ptr<const T> p1 = std::make_shared<const T>(t1);
+ assert(*p0 == t0);
+ assert(*p1 == t1);
+ }
+
+ {
+ volatile T t1 = t0;
+ std::shared_ptr<volatile T> p0 = std::make_shared<volatile T>(t0);
+ std::shared_ptr<volatile T> p1 = std::make_shared<volatile T>(t1);
+ assert(*p0 == t0);
+ assert(*p1 == t1);
+ }
+
+ {
+ const volatile T t1 = t0;
+ std::shared_ptr<const volatile T> p0 = std::make_shared<const volatile T>(t0);
+ std::shared_ptr<const volatile T> p1 = std::make_shared<const volatile T>(t1);
+ assert(*p0 == t0);
+ assert(*p1 == t1);
+ }
+
+}
+
+int main()
+{
+ test<bool>(true);
+ test<int>(3);
+ test<double>(5.0);
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.dest/tested_elsewhere.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.dest/tested_elsewhere.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.dest/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.io/io.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.io/io.pass.cpp
new file mode 100644
index 000000000000..b627ac1ccbc9
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.io/io.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// template<class CharT, class Traits, class Y>
+// basic_ostream<CharT, Traits>&
+// operator<<(basic_ostream<CharT, Traits>& os, shared_ptr<Y> const& p);
+
+#include <memory>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ std::shared_ptr<int> p(new int(3));
+ std::ostringstream os;
+ assert(os.str().empty());
+ os << p;
+ assert(!os.str().empty());
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset.pass.cpp
new file mode 100644
index 000000000000..7bffc06993fa
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// void reset();
+
+#include <memory>
+#include <cassert>
+
+struct B
+{
+ static int count;
+
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+struct A
+ : public B
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ std::shared_ptr<B> p(new B);
+ p.reset();
+ assert(A::count == 0);
+ assert(B::count == 0);
+ assert(p.use_count() == 0);
+ assert(p.get() == 0);
+ }
+ assert(A::count == 0);
+ {
+ std::shared_ptr<B> p;
+ p.reset();
+ assert(A::count == 0);
+ assert(B::count == 0);
+ assert(p.use_count() == 0);
+ assert(p.get() == 0);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer.pass.cpp
new file mode 100644
index 000000000000..85a64d0f1b0b
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// template<class Y> void reset(Y* p);
+
+#include <memory>
+#include <cassert>
+
+struct B
+{
+ static int count;
+
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+struct A
+ : public B
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ std::shared_ptr<B> p(new B);
+ A* ptr = new A;
+ p.reset(ptr);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ assert(p.use_count() == 1);
+ assert(p.get() == ptr);
+ }
+ assert(A::count == 0);
+ {
+ std::shared_ptr<B> p;
+ A* ptr = new A;
+ p.reset(ptr);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ assert(p.use_count() == 1);
+ assert(p.get() == ptr);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer_deleter.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer_deleter.pass.cpp
new file mode 100644
index 000000000000..33965dfeb33c
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer_deleter.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// template<class Y, class D> void reset(Y* p, D d);
+
+#include <memory>
+#include <cassert>
+#include "../test_deleter.h"
+
+struct B
+{
+ static int count;
+
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+struct A
+ : public B
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ std::shared_ptr<B> p(new B);
+ A* ptr = new A;
+ p.reset(ptr, test_deleter<A>(3));
+ assert(A::count == 1);
+ assert(B::count == 1);
+ assert(p.use_count() == 1);
+ assert(p.get() == ptr);
+ test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p);
+ assert(test_deleter<A>::count == 1);
+ assert(test_deleter<A>::dealloc_count == 0);
+ assert(d);
+ assert(d->state() == 3);
+ }
+ assert(A::count == 0);
+ assert(test_deleter<A>::count == 0);
+ assert(test_deleter<A>::dealloc_count == 1);
+ {
+ std::shared_ptr<B> p;
+ A* ptr = new A;
+ p.reset(ptr, test_deleter<A>(3));
+ assert(A::count == 1);
+ assert(B::count == 1);
+ assert(p.use_count() == 1);
+ assert(p.get() == ptr);
+ test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p);
+ assert(test_deleter<A>::count == 1);
+ assert(test_deleter<A>::dealloc_count == 1);
+ assert(d);
+ assert(d->state() == 3);
+ }
+ assert(A::count == 0);
+ assert(test_deleter<A>::count == 0);
+ assert(test_deleter<A>::dealloc_count == 2);
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer_deleter_allocator.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer_deleter_allocator.pass.cpp
new file mode 100644
index 000000000000..09070e2c059b
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer_deleter_allocator.pass.cpp
@@ -0,0 +1,88 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// template<class Y, class D, class A> void reset(Y* p, D d, A a);
+
+#include <memory>
+#include <cassert>
+#include "../test_deleter.h"
+#include "test_allocator.h"
+
+struct B
+{
+ static int count;
+
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+struct A
+ : public B
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ std::shared_ptr<B> p(new B);
+ A* ptr = new A;
+ p.reset(ptr, test_deleter<A>(3), test_allocator<A>(4));
+ assert(A::count == 1);
+ assert(B::count == 1);
+ assert(p.use_count() == 1);
+ assert(p.get() == ptr);
+ test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p);
+ assert(test_deleter<A>::count == 1);
+ assert(test_deleter<A>::dealloc_count == 0);
+ assert(d);
+ assert(d->state() == 3);
+ assert(test_allocator<A>::count == 1);
+ assert(test_allocator<A>::alloc_count == 1);
+ }
+ assert(A::count == 0);
+ assert(test_deleter<A>::count == 0);
+ assert(test_deleter<A>::dealloc_count == 1);
+ assert(test_allocator<A>::count == 0);
+ assert(test_allocator<A>::alloc_count == 0);
+ {
+ std::shared_ptr<B> p;
+ A* ptr = new A;
+ p.reset(ptr, test_deleter<A>(3), test_allocator<A>(4));
+ assert(A::count == 1);
+ assert(B::count == 1);
+ assert(p.use_count() == 1);
+ assert(p.get() == ptr);
+ test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p);
+ assert(test_deleter<A>::count == 1);
+ assert(test_deleter<A>::dealloc_count == 1);
+ assert(d);
+ assert(d->state() == 3);
+ assert(test_allocator<A>::count == 1);
+ assert(test_allocator<A>::alloc_count == 1);
+ }
+ assert(A::count == 0);
+ assert(test_deleter<A>::count == 0);
+ assert(test_deleter<A>::dealloc_count == 2);
+ assert(test_allocator<A>::count == 0);
+ assert(test_allocator<A>::alloc_count == 0);
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/swap.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/swap.pass.cpp
new file mode 100644
index 000000000000..6d28a5043ca0
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/swap.pass.cpp
@@ -0,0 +1,104 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// void swap(shared_ptr& r);
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ A* ptr1 = new A;
+ A* ptr2 = new A;
+ std::shared_ptr<A> p1(ptr1);
+ {
+ std::shared_ptr<A> p2(ptr2);
+ p1.swap(p2);
+ assert(p1.use_count() == 1);
+ assert(p1.get() == ptr2);
+ assert(p2.use_count() == 1);
+ assert(p2.get() == ptr1);
+ assert(A::count == 2);
+ }
+ assert(p1.use_count() == 1);
+ assert(p1.get() == ptr2);
+ assert(A::count == 1);
+ }
+ assert(A::count == 0);
+ {
+ A* ptr1 = new A;
+ A* ptr2 = 0;
+ std::shared_ptr<A> p1(ptr1);
+ {
+ std::shared_ptr<A> p2;
+ p1.swap(p2);
+ assert(p1.use_count() == 0);
+ assert(p1.get() == ptr2);
+ assert(p2.use_count() == 1);
+ assert(p2.get() == ptr1);
+ assert(A::count == 1);
+ }
+ assert(p1.use_count() == 0);
+ assert(p1.get() == ptr2);
+ assert(A::count == 0);
+ }
+ assert(A::count == 0);
+ {
+ A* ptr1 = 0;
+ A* ptr2 = new A;
+ std::shared_ptr<A> p1;
+ {
+ std::shared_ptr<A> p2(ptr2);
+ p1.swap(p2);
+ assert(p1.use_count() == 1);
+ assert(p1.get() == ptr2);
+ assert(p2.use_count() == 0);
+ assert(p2.get() == ptr1);
+ assert(A::count == 1);
+ }
+ assert(p1.use_count() == 1);
+ assert(p1.get() == ptr2);
+ assert(A::count == 1);
+ }
+ assert(A::count == 0);
+ {
+ A* ptr1 = 0;
+ A* ptr2 = 0;
+ std::shared_ptr<A> p1;
+ {
+ std::shared_ptr<A> p2;
+ p1.swap(p2);
+ assert(p1.use_count() == 0);
+ assert(p1.get() == ptr2);
+ assert(p2.use_count() == 0);
+ assert(p2.get() == ptr1);
+ assert(A::count == 0);
+ }
+ assert(p1.use_count() == 0);
+ assert(p1.get() == ptr2);
+ assert(A::count == 0);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/arrow.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/arrow.pass.cpp
new file mode 100644
index 000000000000..00281687521f
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/arrow.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// T* operator->() const;
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+int main()
+{
+ const std::shared_ptr<std::pair<int, int> > p(new std::pair<int, int>(3, 4));
+ assert(p->first == 3);
+ assert(p->second == 4);
+ p->first = 5;
+ p->second = 6;
+ assert(p->first == 5);
+ assert(p->second == 6);
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/dereference.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/dereference.pass.cpp
new file mode 100644
index 000000000000..378cd0514ca2
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/dereference.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// T& operator*() const;
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+ const std::shared_ptr<int> p(new int(32));
+ assert(*p == 32);
+ *p = 3;
+ assert(*p == 3);
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/op_bool.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/op_bool.pass.cpp
new file mode 100644
index 000000000000..1b79d497005a
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/op_bool.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// explicit operator bool() const;
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+ {
+ const std::shared_ptr<int> p(new int(32));
+ assert(p);
+ }
+ {
+ const std::shared_ptr<int> p;
+ assert(!p);
+ }
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/owner_before_shared_ptr.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/owner_before_shared_ptr.pass.cpp
new file mode 100644
index 000000000000..3acd2f8c6f2d
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/owner_before_shared_ptr.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// template <class U> bool owner_before(shared_ptr<U> const& b) const;
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+ const std::shared_ptr<int> p1(new int);
+ const std::shared_ptr<int> p2 = p1;
+ const std::shared_ptr<int> p3(new int);
+ assert(!p1.owner_before(p2));
+ assert(!p2.owner_before(p1));
+ assert(p1.owner_before(p3) || p3.owner_before(p1));
+ assert(p3.owner_before(p1) == p3.owner_before(p2));
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/owner_before_weak_ptr.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/owner_before_weak_ptr.pass.cpp
new file mode 100644
index 000000000000..33447ba7da00
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/owner_before_weak_ptr.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// template <class U> bool owner_before(weak_ptr<U> const& b) const;
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+ const std::shared_ptr<int> p1(new int);
+ const std::shared_ptr<int> p2 = p1;
+ const std::shared_ptr<int> p3(new int);
+ const std::weak_ptr<int> w1(p1);
+ const std::weak_ptr<int> w2(p2);
+ const std::weak_ptr<int> w3(p3);
+ assert(!p1.owner_before(w2));
+ assert(!p2.owner_before(w1));
+ assert(p1.owner_before(w3) || p3.owner_before(w1));
+ assert(p3.owner_before(w1) == p3.owner_before(w2));
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/unique.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/unique.pass.cpp
new file mode 100644
index 000000000000..50ff692f9d42
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/unique.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// bool unique() const;
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+ const std::shared_ptr<int> p(new int(32));
+ assert(p.unique());
+ {
+ std::shared_ptr<int> p2 = p;
+ assert(!p.unique());
+ }
+ assert(p.unique());
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.spec/swap.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.spec/swap.pass.cpp
new file mode 100644
index 000000000000..b40e4705acfe
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.spec/swap.pass.cpp
@@ -0,0 +1,104 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// template<class T> void swap(shared_ptr<T>& a, shared_ptr<T>& b);
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ A* ptr1 = new A;
+ A* ptr2 = new A;
+ std::shared_ptr<A> p1(ptr1);
+ {
+ std::shared_ptr<A> p2(ptr2);
+ swap(p1, p2);
+ assert(p1.use_count() == 1);
+ assert(p1.get() == ptr2);
+ assert(p2.use_count() == 1);
+ assert(p2.get() == ptr1);
+ assert(A::count == 2);
+ }
+ assert(p1.use_count() == 1);
+ assert(p1.get() == ptr2);
+ assert(A::count == 1);
+ }
+ assert(A::count == 0);
+ {
+ A* ptr1 = new A;
+ A* ptr2 = 0;
+ std::shared_ptr<A> p1(ptr1);
+ {
+ std::shared_ptr<A> p2;
+ swap(p1, p2);
+ assert(p1.use_count() == 0);
+ assert(p1.get() == ptr2);
+ assert(p2.use_count() == 1);
+ assert(p2.get() == ptr1);
+ assert(A::count == 1);
+ }
+ assert(p1.use_count() == 0);
+ assert(p1.get() == ptr2);
+ assert(A::count == 0);
+ }
+ assert(A::count == 0);
+ {
+ A* ptr1 = 0;
+ A* ptr2 = new A;
+ std::shared_ptr<A> p1;
+ {
+ std::shared_ptr<A> p2(ptr2);
+ swap(p1, p2);
+ assert(p1.use_count() == 1);
+ assert(p1.get() == ptr2);
+ assert(p2.use_count() == 0);
+ assert(p2.get() == ptr1);
+ assert(A::count == 1);
+ }
+ assert(p1.use_count() == 1);
+ assert(p1.get() == ptr2);
+ assert(A::count == 1);
+ }
+ assert(A::count == 0);
+ {
+ A* ptr1 = 0;
+ A* ptr2 = 0;
+ std::shared_ptr<A> p1;
+ {
+ std::shared_ptr<A> p2;
+ swap(p1, p2);
+ assert(p1.use_count() == 0);
+ assert(p1.get() == ptr2);
+ assert(p2.use_count() == 0);
+ assert(p2.get() == ptr1);
+ assert(A::count == 0);
+ }
+ assert(p1.use_count() == 0);
+ assert(p1.get() == ptr2);
+ assert(A::count == 0);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.weak/types.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/types.pass.cpp
new file mode 100644
index 000000000000..45748d7db6fb
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/types.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template<class T> class weak_ptr
+// {
+// public:
+// typedef T element_type;
+// ...
+// };
+
+#include <memory>
+
+struct A; // purposefully incomplete
+
+int main()
+{
+ static_assert((std::is_same<std::weak_ptr<A>::element_type, A>::value), "");
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.ownerless/owner_less.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.ownerless/owner_less.pass.cpp
new file mode 100644
index 000000000000..d091ae99fc27
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.ownerless/owner_less.pass.cpp
@@ -0,0 +1,82 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class T> struct owner_less;
+//
+// template <class T>
+// struct owner_less<shared_ptr<T> >
+// : binary_function<shared_ptr<T>, shared_ptr<T>, bool>
+// {
+// typedef bool result_type;
+// bool operator()(shared_ptr<T> const&, shared_ptr<T> const&) const;
+// bool operator()(shared_ptr<T> const&, weak_ptr<T> const&) const;
+// bool operator()(weak_ptr<T> const&, shared_ptr<T> const&) const;
+// };
+//
+// template <class T>
+// struct owner_less<weak_ptr<T> >
+// : binary_function<weak_ptr<T>, weak_ptr<T>, bool>
+// {
+// typedef bool result_type;
+// bool operator()(weak_ptr<T> const&, weak_ptr<T> const&) const;
+// bool operator()(shared_ptr<T> const&, weak_ptr<T> const&) const;
+// bool operator()(weak_ptr<T> const&, shared_ptr<T> const&) const;
+// };
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+ const std::shared_ptr<int> p1(new int);
+ const std::shared_ptr<int> p2 = p1;
+ const std::shared_ptr<int> p3(new int);
+ const std::weak_ptr<int> w1(p1);
+ const std::weak_ptr<int> w2(p2);
+ const std::weak_ptr<int> w3(p3);
+
+ {
+ typedef std::owner_less<std::shared_ptr<int> > CS;
+ CS cs;
+
+ static_assert((std::is_same<std::shared_ptr<int>, CS::first_argument_type>::value), "" );
+ static_assert((std::is_same<std::shared_ptr<int>, CS::second_argument_type>::value), "" );
+ static_assert((std::is_same<bool, CS::result_type>::value), "" );
+
+ assert(!cs(p1, p2));
+ assert(!cs(p2, p1));
+ assert(cs(p1 ,p3) || cs(p3, p1));
+ assert(cs(p3, p1) == cs(p3, p2));
+
+ assert(!cs(p1, w2));
+ assert(!cs(p2, w1));
+ assert(cs(p1, w3) || cs(p3, w1));
+ assert(cs(p3, w1) == cs(p3, w2));
+ }
+ {
+ typedef std::owner_less<std::weak_ptr<int> > CS;
+ CS cs;
+
+ static_assert((std::is_same<std::weak_ptr<int>, CS::first_argument_type>::value), "" );
+ static_assert((std::is_same<std::weak_ptr<int>, CS::second_argument_type>::value), "" );
+ static_assert((std::is_same<bool, CS::result_type>::value), "" );
+
+ assert(!cs(w1, w2));
+ assert(!cs(w2, w1));
+ assert(cs(w1, w3) || cs(w3, w1));
+ assert(cs(w3, w1) == cs(w3, w2));
+
+ assert(!cs(w1, p2));
+ assert(!cs(w2, p1));
+ assert(cs(w1, p3) || cs(w3, p1));
+ assert(cs(w3, p1) == cs(w3, p2));
+ }
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.assign/shared_ptr_Y.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.assign/shared_ptr_Y.pass.cpp
new file mode 100644
index 000000000000..6b32079c71b4
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.assign/shared_ptr_Y.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// weak_ptr
+
+// template<class Y> weak_ptr& operator=(const shared_ptr<Y>& r);
+
+#include <memory>
+#include <type_traits>
+#include <cassert>
+
+struct B
+{
+ static int count;
+
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+struct A
+ : public B
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ const std::shared_ptr<A> pA(new A);
+ {
+ std::weak_ptr<B> pB;
+ pB = pA;
+ assert(B::count == 1);
+ assert(A::count == 1);
+ assert(pB.use_count() == 1);
+ assert(pA.use_count() == 1);
+ }
+ assert(pA.use_count() == 1);
+ assert(B::count == 1);
+ assert(A::count == 1);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.assign/weak_ptr.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.assign/weak_ptr.pass.cpp
new file mode 100644
index 000000000000..e5713f375215
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.assign/weak_ptr.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// weak_ptr
+
+// weak_ptr& operator=(const weak_ptr& r);
+
+#include <memory>
+#include <type_traits>
+#include <cassert>
+
+struct B
+{
+ static int count;
+
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+struct A
+ : public B
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ const std::shared_ptr<A> ps(new A);
+ const std::weak_ptr<A> pA(ps);
+ {
+ std::weak_ptr<A> pB;
+ pB = pA;
+ assert(B::count == 1);
+ assert(A::count == 1);
+ assert(pB.use_count() == 1);
+ assert(pA.use_count() == 1);
+ }
+ assert(pA.use_count() == 1);
+ assert(B::count == 1);
+ assert(A::count == 1);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+
+ {
+ const std::shared_ptr<A> ps(new A);
+ std::weak_ptr<A> pA(ps);
+ {
+ std::weak_ptr<A> pB;
+ pB = std::move(pA);
+ assert(B::count == 1);
+ assert(A::count == 1);
+ assert(pB.use_count() == 1);
+ }
+ assert(B::count == 1);
+ assert(A::count == 1);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.assign/weak_ptr_Y.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.assign/weak_ptr_Y.pass.cpp
new file mode 100644
index 000000000000..5a03d926f7d6
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.assign/weak_ptr_Y.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// weak_ptr
+
+// template<class Y> weak_ptr& operator=(const weak_ptr<Y>& r);
+
+#include <memory>
+#include <type_traits>
+#include <cassert>
+
+struct B
+{
+ static int count;
+
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+struct A
+ : public B
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ const std::shared_ptr<A> ps(new A);
+ const std::weak_ptr<A> pA(ps);
+ {
+ std::weak_ptr<B> pB;
+ pB = pA;
+ assert(B::count == 1);
+ assert(A::count == 1);
+ assert(pB.use_count() == 1);
+ assert(pA.use_count() == 1);
+ }
+ assert(pA.use_count() == 1);
+ assert(B::count == 1);
+ assert(A::count == 1);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+
+ {
+ const std::shared_ptr<A> ps(new A);
+ std::weak_ptr<A> pA(ps);
+ {
+ std::weak_ptr<B> pB;
+ pB = std::move(pA);
+ assert(B::count == 1);
+ assert(A::count == 1);
+ assert(pB.use_count() == 1);
+ }
+ assert(B::count == 1);
+ assert(A::count == 1);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/default.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/default.pass.cpp
new file mode 100644
index 000000000000..28358db6a446
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/default.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template<class T> class weak_ptr
+
+// weak_ptr();
+
+#include <memory>
+#include <cassert>
+
+struct A;
+
+int main()
+{
+ std::weak_ptr<A> p;
+ assert(p.use_count() == 0);
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/shared_ptr_Y.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/shared_ptr_Y.pass.cpp
new file mode 100644
index 000000000000..d70adb940eb2
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/shared_ptr_Y.pass.cpp
@@ -0,0 +1,95 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// weak_ptr
+
+// template<class Y> weak_ptr(const shared_ptr<Y>& r);
+
+#include <memory>
+#include <type_traits>
+#include <cassert>
+
+struct B
+{
+ static int count;
+
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+struct A
+ : public B
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct C
+{
+ static int count;
+
+ C() {++count;}
+ C(const C&) {++count;}
+ virtual ~C() {--count;}
+};
+
+int C::count = 0;
+
+int main()
+{
+ static_assert(( std::is_convertible<std::shared_ptr<A>, std::weak_ptr<B> >::value), "");
+ static_assert((!std::is_convertible<std::weak_ptr<B>, std::shared_ptr<A> >::value), "");
+ static_assert((!std::is_convertible<std::shared_ptr<A>, std::weak_ptr<C> >::value), "");
+ {
+ const std::shared_ptr<A> pA(new A);
+ assert(pA.use_count() == 1);
+ assert(B::count == 1);
+ assert(A::count == 1);
+ {
+ std::weak_ptr<B> pB(pA);
+ assert(B::count == 1);
+ assert(A::count == 1);
+ assert(pB.use_count() == 1);
+ assert(pA.use_count() == 1);
+ }
+ assert(pA.use_count() == 1);
+ assert(B::count == 1);
+ assert(A::count == 1);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+ {
+ std::shared_ptr<A> pA;
+ assert(pA.use_count() == 0);
+ assert(B::count == 0);
+ assert(A::count == 0);
+ {
+ std::weak_ptr<B> pB(pA);
+ assert(B::count == 0);
+ assert(A::count == 0);
+ assert(pB.use_count() == 0);
+ assert(pA.use_count() == 0);
+ }
+ assert(pA.use_count() == 0);
+ assert(B::count == 0);
+ assert(A::count == 0);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/weak_ptr.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/weak_ptr.pass.cpp
new file mode 100644
index 000000000000..75bf3df90aa3
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/weak_ptr.pass.cpp
@@ -0,0 +1,114 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// weak_ptr
+
+// weak_ptr(const weak_ptr& r);
+// weak_ptr(weak_ptr &&r)
+
+#include <memory>
+#include <type_traits>
+#include <cassert>
+
+struct B
+{
+ static int count;
+
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+struct A
+ : public B
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct C
+{
+ static int count;
+
+ C() {++count;}
+ C(const C&) {++count;}
+ virtual ~C() {--count;}
+};
+
+int C::count = 0;
+
+template <class T>
+std::weak_ptr<T> source (std::shared_ptr<T> p) { return std::weak_ptr<T>(p); }
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+template <class T>
+void sink (std::weak_ptr<T> &&) {}
+#endif
+
+int main()
+{
+ {
+ const std::shared_ptr<A> ps(new A);
+ const std::weak_ptr<A> pA(ps);
+ assert(pA.use_count() == 1);
+ assert(B::count == 1);
+ assert(A::count == 1);
+ {
+ std::weak_ptr<A> pB(pA);
+ assert(B::count == 1);
+ assert(A::count == 1);
+ assert(pB.use_count() == 1);
+ assert(pA.use_count() == 1);
+ }
+ assert(pA.use_count() == 1);
+ assert(B::count == 1);
+ assert(A::count == 1);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+ {
+ std::weak_ptr<A> pA;
+ assert(pA.use_count() == 0);
+ assert(B::count == 0);
+ assert(A::count == 0);
+ {
+ std::weak_ptr<A> pB(pA);
+ assert(B::count == 0);
+ assert(A::count == 0);
+ assert(pB.use_count() == 0);
+ assert(pA.use_count() == 0);
+ }
+ assert(pA.use_count() == 0);
+ assert(B::count == 0);
+ assert(A::count == 0);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::shared_ptr<A> ps(new A);
+ std::weak_ptr<A> pA = source(ps);
+ assert(pA.use_count() == 1);
+ assert(A::count == 1);
+ sink(std::move(pA)); // kill off the weak pointer
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+#endif
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/weak_ptr_Y.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/weak_ptr_Y.pass.cpp
new file mode 100644
index 000000000000..51a8fa5ae81f
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/weak_ptr_Y.pass.cpp
@@ -0,0 +1,108 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// weak_ptr
+
+// template<class Y> weak_ptr(const weak_ptr<Y>& r);
+// template<class Y> weak_ptr(weak_ptr<Y> &&r);
+
+#include <memory>
+#include <type_traits>
+#include <cassert>
+
+struct B
+{
+ static int count;
+
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+struct A
+ : public B
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct C
+{
+ static int count;
+
+ C() {++count;}
+ C(const C&) {++count;}
+ virtual ~C() {--count;}
+};
+
+int C::count = 0;
+
+template <class T>
+std::weak_ptr<T> source (std::shared_ptr<T> p) { return std::weak_ptr<T>(p); }
+
+int main()
+{
+ static_assert(( std::is_convertible<std::weak_ptr<A>, std::weak_ptr<B> >::value), "");
+ static_assert((!std::is_convertible<std::weak_ptr<B>, std::weak_ptr<A> >::value), "");
+ static_assert((!std::is_convertible<std::weak_ptr<A>, std::weak_ptr<C> >::value), "");
+ {
+ const std::weak_ptr<A> pA(std::shared_ptr<A>(new A));
+ assert(pA.use_count() == 0);
+ assert(B::count == 0);
+ assert(A::count == 0);
+ {
+ std::weak_ptr<B> pB(pA);
+ assert(B::count == 0);
+ assert(A::count == 0);
+ assert(pB.use_count() == 0);
+ assert(pA.use_count() == 0);
+ }
+ assert(pA.use_count() == 0);
+ assert(B::count == 0);
+ assert(A::count == 0);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+ {
+ std::weak_ptr<A> pA;
+ assert(pA.use_count() == 0);
+ assert(B::count == 0);
+ assert(A::count == 0);
+ {
+ std::weak_ptr<B> pB(pA);
+ assert(B::count == 0);
+ assert(A::count == 0);
+ assert(pB.use_count() == 0);
+ assert(pA.use_count() == 0);
+ }
+ assert(pA.use_count() == 0);
+ assert(B::count == 0);
+ assert(A::count == 0);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+
+ {
+ std::shared_ptr<A> ps(new A);
+ std::weak_ptr<A> pA = source(ps);
+ std::weak_ptr<B> pB(std::move(pA));
+ assert(pB.use_count() == 1);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.dest/tested_elsewhere.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.dest/tested_elsewhere.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.dest/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.mod/reset.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.mod/reset.pass.cpp
new file mode 100644
index 000000000000..fa496d4bda59
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.mod/reset.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// weak_ptr
+
+// void swap(weak_ptr& r);
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ std::shared_ptr<A> p1(new A);
+ std::weak_ptr<A> w1(p1);
+ assert(w1.use_count() == 1);
+ w1.reset();
+ assert(w1.use_count() == 0);
+ assert(p1.use_count() == 1);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.mod/swap.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.mod/swap.pass.cpp
new file mode 100644
index 000000000000..4001efb737e4
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.mod/swap.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// weak_ptr
+
+// void swap(weak_ptr& r);
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ A* ptr1 = new A;
+ A* ptr2 = new A;
+ std::shared_ptr<A> p1(ptr1);
+ std::weak_ptr<A> w1(p1);
+ {
+ std::shared_ptr<A> p2(ptr2);
+ std::weak_ptr<A> w2(p2);
+ w1.swap(w2);
+ assert(w1.use_count() == 1);
+ assert(w1.lock().get() == ptr2);
+ assert(w2.use_count() == 1);
+ assert(w2.lock().get() == ptr1);
+ assert(A::count == 2);
+ }
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/expired.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/expired.pass.cpp
new file mode 100644
index 000000000000..d61ac51afc62
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/expired.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// weak_ptr
+
+// bool expired() const;
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ std::weak_ptr<A> wp;
+ assert(wp.use_count() == 0);
+ assert(wp.expired() == (wp.use_count() == 0));
+ }
+ {
+ std::shared_ptr<A> sp0(new A);
+ std::weak_ptr<A> wp(sp0);
+ assert(wp.use_count() == 1);
+ assert(wp.expired() == (wp.use_count() == 0));
+ sp0.reset();
+ assert(wp.use_count() == 0);
+ assert(wp.expired() == (wp.use_count() == 0));
+ }
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/lock.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/lock.pass.cpp
new file mode 100644
index 000000000000..956884b5c5c4
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/lock.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// weak_ptr
+
+// shared_ptr<T> lock() const;
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ std::weak_ptr<A> wp;
+ std::shared_ptr<A> sp = wp.lock();
+ assert(sp.use_count() == 0);
+ assert(sp.get() == 0);
+ assert(A::count == 0);
+ }
+ {
+ std::shared_ptr<A> sp0(new A);
+ std::weak_ptr<A> wp(sp0);
+ std::shared_ptr<A> sp = wp.lock();
+ assert(sp.use_count() == 2);
+ assert(sp.get() == sp0.get());
+ assert(A::count == 1);
+ }
+ assert(A::count == 0);
+ {
+ std::shared_ptr<A> sp0(new A);
+ std::weak_ptr<A> wp(sp0);
+ sp0.reset();
+ std::shared_ptr<A> sp = wp.lock();
+ assert(sp.use_count() == 0);
+ assert(sp.get() == 0);
+ assert(A::count == 0);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/not_less_than.fail.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/not_less_than.fail.cpp
new file mode 100644
index 000000000000..ccffc2a66fb5
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/not_less_than.fail.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class T> class weak_ptr;
+//
+// not less than comparable
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+ const std::shared_ptr<int> p1(new int);
+ const std::shared_ptr<int> p2(new int);
+ const std::weak_ptr<int> w1(p1);
+ const std::weak_ptr<int> w2(p2);
+
+ bool b = w1 < w2;
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/owner_before_shared_ptr.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/owner_before_shared_ptr.pass.cpp
new file mode 100644
index 000000000000..4aa49cfe8a24
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/owner_before_shared_ptr.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// weak_ptr
+
+// template<class U> bool owner_before(const shared_ptr<U>& b);
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+ const std::shared_ptr<int> p1(new int);
+ const std::shared_ptr<int> p2 = p1;
+ const std::shared_ptr<int> p3(new int);
+ const std::weak_ptr<int> w1(p1);
+ const std::weak_ptr<int> w2(p2);
+ const std::weak_ptr<int> w3(p3);
+ assert(!w1.owner_before(p2));
+ assert(!w2.owner_before(p1));
+ assert(w1.owner_before(p3) || w3.owner_before(p1));
+ assert(w3.owner_before(p1) == w3.owner_before(p2));
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/owner_before_weak_ptr.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/owner_before_weak_ptr.pass.cpp
new file mode 100644
index 000000000000..9fe2b6e39035
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/owner_before_weak_ptr.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// weak_ptr
+
+// template<class U> bool owner_before(const weak_ptr<U>& b);
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+ const std::shared_ptr<int> p1(new int);
+ const std::shared_ptr<int> p2 = p1;
+ const std::shared_ptr<int> p3(new int);
+ const std::weak_ptr<int> w1(p1);
+ const std::weak_ptr<int> w2(p2);
+ const std::weak_ptr<int> w3(p3);
+ assert(!w1.owner_before(w2));
+ assert(!w2.owner_before(w1));
+ assert(w1.owner_before(w3) || w3.owner_before(w1));
+ assert(w3.owner_before(w1) == w3.owner_before(w2));
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.spec/swap.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.spec/swap.pass.cpp
new file mode 100644
index 000000000000..e13d5aeaf636
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.spec/swap.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// weak_ptr
+
+// template<class T> void swap(weak_ptr<T>& a, weak_ptr<T>& b)
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ A* ptr1 = new A;
+ A* ptr2 = new A;
+ std::shared_ptr<A> p1(ptr1);
+ std::weak_ptr<A> w1(p1);
+ {
+ std::shared_ptr<A> p2(ptr2);
+ std::weak_ptr<A> w2(p2);
+ swap(w1, w2);
+ assert(w1.use_count() == 1);
+ assert(w1.lock().get() == ptr2);
+ assert(w2.use_count() == 1);
+ assert(w2.lock().get() == ptr1);
+ assert(A::count == 2);
+ }
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.weakptr/bad_weak_ptr.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.weakptr/bad_weak_ptr.pass.cpp
new file mode 100644
index 000000000000..cb895cd2bbf3
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.weakptr/bad_weak_ptr.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// class bad_weak_ptr
+// : public std::exception
+// {
+// public:
+// bad_weak_ptr();
+// };
+
+#include <memory>
+#include <type_traits>
+#include <cassert>
+#include <cstring>
+
+int main()
+{
+ static_assert((std::is_base_of<std::exception, std::bad_weak_ptr>::value), "");
+ std::bad_weak_ptr e;
+ std::bad_weak_ptr e2 = e;
+ e2 = e;
+ assert(std::strcmp(e.what(), "bad_weak_ptr") == 0);
+}
diff --git a/test/std/utilities/memory/version.pass.cpp b/test/std/utilities/memory/version.pass.cpp
new file mode 100644
index 000000000000..790c08a3bd2d
--- /dev/null
+++ b/test/std/utilities/memory/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+#include <memory>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/utilities/meta/meta.hel/bool_constant.pass.cpp b/test/std/utilities/meta/meta.hel/bool_constant.pass.cpp
new file mode 100644
index 000000000000..71110ea3bfb0
--- /dev/null
+++ b/test/std/utilities/meta/meta.hel/bool_constant.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// bool_constant
+
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+#if __cplusplus > 201402L
+ typedef std::bool_constant<true> _t;
+ static_assert(_t::value, "");
+ static_assert((std::is_same<_t::value_type, bool>::value), "");
+ static_assert((std::is_same<_t::type, _t>::value), "");
+ static_assert((_t() == true), "");
+
+ typedef std::bool_constant<false> _f;
+ static_assert(!_f::value, "");
+ static_assert((std::is_same<_f::value_type, bool>::value), "");
+ static_assert((std::is_same<_f::type, _f>::value), "");
+ static_assert((_f() == false), "");
+#endif
+}
diff --git a/test/std/utilities/meta/meta.hel/integral_constant.pass.cpp b/test/std/utilities/meta/meta.hel/integral_constant.pass.cpp
new file mode 100644
index 000000000000..335305a28236
--- /dev/null
+++ b/test/std/utilities/meta/meta.hel/integral_constant.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// integral_constant
+
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+ typedef std::integral_constant<int, 5> _5;
+ static_assert(_5::value == 5, "");
+ static_assert((std::is_same<_5::value_type, int>::value), "");
+ static_assert((std::is_same<_5::type, _5>::value), "");
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+ static_assert((_5() == 5), "");
+#else
+ assert(_5() == 5);
+#endif
+
+#if _LIBCPP_STD_VER > 11
+ static_assert ( _5{}() == 5, "" );
+ static_assert ( std::true_type{}(), "" );
+#endif
+
+ static_assert(std::false_type::value == false, "");
+ static_assert((std::is_same<std::false_type::value_type, bool>::value), "");
+ static_assert((std::is_same<std::false_type::type, std::false_type>::value), "");
+
+ static_assert(std::true_type::value == true, "");
+ static_assert((std::is_same<std::true_type::value_type, bool>::value), "");
+ static_assert((std::is_same<std::true_type::type, std::true_type>::value), "");
+
+ std::false_type f1;
+ std::false_type f2 = f1;
+ assert(!f2);
+
+ std::true_type t1;
+ std::true_type t2 = t1;
+ assert(t2);
+}
diff --git a/test/std/utilities/meta/meta.rel/is_base_of.pass.cpp b/test/std/utilities/meta/meta.rel/is_base_of.pass.cpp
new file mode 100644
index 000000000000..0f90ae5c1cab
--- /dev/null
+++ b/test/std/utilities/meta/meta.rel/is_base_of.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_base_of
+
+#include <type_traits>
+
+template <class T, class U>
+void test_is_base_of()
+{
+ static_assert((std::is_base_of<T, U>::value), "");
+ static_assert((std::is_base_of<const T, U>::value), "");
+ static_assert((std::is_base_of<T, const U>::value), "");
+ static_assert((std::is_base_of<const T, const U>::value), "");
+}
+
+template <class T, class U>
+void test_is_not_base_of()
+{
+ static_assert((!std::is_base_of<T, U>::value), "");
+}
+
+struct B {};
+struct B1 : B {};
+struct B2 : B {};
+struct D : private B1, private B2 {};
+
+int main()
+{
+ test_is_base_of<B, D>();
+ test_is_base_of<B1, D>();
+ test_is_base_of<B2, D>();
+ test_is_base_of<B, B1>();
+ test_is_base_of<B, B2>();
+ test_is_base_of<B, B>();
+
+ test_is_not_base_of<D, B>();
+ test_is_not_base_of<B&, D&>();
+ test_is_not_base_of<B[3], D[3]>();
+ test_is_not_base_of<int, int>();
+}
diff --git a/test/std/utilities/meta/meta.rel/is_convertible.pass.cpp b/test/std/utilities/meta/meta.rel/is_convertible.pass.cpp
new file mode 100644
index 000000000000..429fb33037ff
--- /dev/null
+++ b/test/std/utilities/meta/meta.rel/is_convertible.pass.cpp
@@ -0,0 +1,195 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_convertible
+
+#include <type_traits>
+
+template <class T, class U>
+void test_is_convertible()
+{
+ static_assert((std::is_convertible<T, U>::value), "");
+ static_assert((std::is_convertible<const T, U>::value), "");
+ static_assert((std::is_convertible<T, const U>::value), "");
+ static_assert((std::is_convertible<const T, const U>::value), "");
+}
+
+template <class T, class U>
+void test_is_not_convertible()
+{
+ static_assert((!std::is_convertible<T, U>::value), "");
+ static_assert((!std::is_convertible<const T, U>::value), "");
+ static_assert((!std::is_convertible<T, const U>::value), "");
+ static_assert((!std::is_convertible<const T, const U>::value), "");
+}
+
+typedef void Function();
+typedef char Array[1];
+
+class NonCopyable {
+ NonCopyable(NonCopyable&);
+};
+
+int main()
+{
+ // void
+ test_is_convertible<void,void> ();
+ test_is_not_convertible<void,Function> ();
+ test_is_not_convertible<void,Function&> ();
+ test_is_not_convertible<void,Function*> ();
+ test_is_not_convertible<void,Array> ();
+ test_is_not_convertible<void,Array&> ();
+ test_is_not_convertible<void,char> ();
+ test_is_not_convertible<void,char&> ();
+ test_is_not_convertible<void,char*> ();
+
+ // Function
+ test_is_not_convertible<Function, void> ();
+ test_is_not_convertible<Function, Function> ();
+ test_is_convertible<Function, Function&> ();
+ test_is_convertible<Function, Function*> ();
+ test_is_not_convertible<Function, Array> ();
+ test_is_not_convertible<Function, Array&> ();
+ test_is_not_convertible<Function, char> ();
+ test_is_not_convertible<Function, char&> ();
+ test_is_not_convertible<Function, char*> ();
+
+ // Function&
+ test_is_not_convertible<Function&, void> ();
+ test_is_not_convertible<Function&, Function> ();
+ test_is_convertible<Function&, Function&> ();
+
+ test_is_convertible<Function&, Function*> ();
+ test_is_not_convertible<Function&, Array> ();
+ test_is_not_convertible<Function&, Array&> ();
+ test_is_not_convertible<Function&, char> ();
+ test_is_not_convertible<Function&, char&> ();
+ test_is_not_convertible<Function&, char*> ();
+
+ // Function*
+ test_is_not_convertible<Function*, void> ();
+ test_is_not_convertible<Function*, Function> ();
+ test_is_not_convertible<Function*, Function&> ();
+ test_is_convertible<Function*, Function*> ();
+
+ test_is_not_convertible<Function*, Array> ();
+ test_is_not_convertible<Function*, Array&> ();
+ test_is_not_convertible<Function*, char> ();
+ test_is_not_convertible<Function*, char&> ();
+ test_is_not_convertible<Function*, char*> ();
+
+ // Array
+ test_is_not_convertible<Array, void> ();
+ test_is_not_convertible<Array, Function> ();
+ test_is_not_convertible<Array, Function&> ();
+ test_is_not_convertible<Array, Function*> ();
+ test_is_not_convertible<Array, Array> ();
+
+ static_assert((!std::is_convertible<Array, Array&>::value), "");
+ static_assert(( std::is_convertible<Array, const Array&>::value), "");
+ static_assert((!std::is_convertible<const Array, Array&>::value), "");
+ static_assert(( std::is_convertible<const Array, const Array&>::value), "");
+
+ test_is_not_convertible<Array, char> ();
+ test_is_not_convertible<Array, char&> ();
+
+ static_assert(( std::is_convertible<Array, char*>::value), "");
+ static_assert(( std::is_convertible<Array, const char*>::value), "");
+ static_assert((!std::is_convertible<const Array, char*>::value), "");
+ static_assert(( std::is_convertible<const Array, const char*>::value), "");
+
+ // Array&
+ test_is_not_convertible<Array&, void> ();
+ test_is_not_convertible<Array&, Function> ();
+ test_is_not_convertible<Array&, Function&> ();
+ test_is_not_convertible<Array&, Function*> ();
+ test_is_not_convertible<Array&, Array> ();
+
+ static_assert(( std::is_convertible<Array&, Array&>::value), "");
+ static_assert(( std::is_convertible<Array&, const Array&>::value), "");
+ static_assert((!std::is_convertible<const Array&, Array&>::value), "");
+ static_assert(( std::is_convertible<const Array&, const Array&>::value), "");
+
+ test_is_not_convertible<Array&, char> ();
+ test_is_not_convertible<Array&, char&> ();
+
+ static_assert(( std::is_convertible<Array&, char*>::value), "");
+ static_assert(( std::is_convertible<Array&, const char*>::value), "");
+ static_assert((!std::is_convertible<const Array&, char*>::value), "");
+ static_assert(( std::is_convertible<const Array&, const char*>::value), "");
+
+ // char
+ test_is_not_convertible<char, void> ();
+ test_is_not_convertible<char, Function> ();
+ test_is_not_convertible<char, Function&> ();
+ test_is_not_convertible<char, Function*> ();
+ test_is_not_convertible<char, Array> ();
+ test_is_not_convertible<char, Array&> ();
+
+ test_is_convertible<char, char> ();
+
+ static_assert((!std::is_convertible<char, char&>::value), "");
+ static_assert(( std::is_convertible<char, const char&>::value), "");
+ static_assert((!std::is_convertible<const char, char&>::value), "");
+ static_assert(( std::is_convertible<const char, const char&>::value), "");
+
+ test_is_not_convertible<char, char*> ();
+
+ // char&
+ test_is_not_convertible<char&, void> ();
+ test_is_not_convertible<char&, Function> ();
+ test_is_not_convertible<char&, Function&> ();
+ test_is_not_convertible<char&, Function*> ();
+ test_is_not_convertible<char&, Array> ();
+ test_is_not_convertible<char&, Array&> ();
+
+ test_is_convertible<char&, char> ();
+
+ static_assert(( std::is_convertible<char&, char&>::value), "");
+ static_assert(( std::is_convertible<char&, const char&>::value), "");
+ static_assert((!std::is_convertible<const char&, char&>::value), "");
+ static_assert(( std::is_convertible<const char&, const char&>::value), "");
+
+ test_is_not_convertible<char&, char*> ();
+
+ // char*
+ test_is_not_convertible<char*, void> ();
+ test_is_not_convertible<char*, Function> ();
+ test_is_not_convertible<char*, Function&> ();
+ test_is_not_convertible<char*, Function*> ();
+ test_is_not_convertible<char*, Array> ();
+ test_is_not_convertible<char*, Array&> ();
+
+ test_is_not_convertible<char*, char> ();
+ test_is_not_convertible<char*, char&> ();
+
+ static_assert(( std::is_convertible<char*, char*>::value), "");
+ static_assert(( std::is_convertible<char*, const char*>::value), "");
+ static_assert((!std::is_convertible<const char*, char*>::value), "");
+ static_assert(( std::is_convertible<const char*, const char*>::value), "");
+
+ // NonCopyable
+ static_assert((std::is_convertible<NonCopyable&, NonCopyable&>::value), "");
+ static_assert((std::is_convertible<NonCopyable&, const NonCopyable&>::value), "");
+ static_assert((std::is_convertible<NonCopyable&, const volatile NonCopyable&>::value), "");
+ static_assert((std::is_convertible<NonCopyable&, volatile NonCopyable&>::value), "");
+ static_assert((std::is_convertible<const NonCopyable&, const NonCopyable&>::value), "");
+ static_assert((std::is_convertible<const NonCopyable&, const volatile NonCopyable&>::value), "");
+ static_assert((std::is_convertible<volatile NonCopyable&, const volatile NonCopyable&>::value), "");
+ static_assert((std::is_convertible<const volatile NonCopyable&, const volatile NonCopyable&>::value), "");
+ static_assert((!std::is_convertible<const NonCopyable&, NonCopyable&>::value), "");
+// This test requires Access control SFINAE which we only have in C++11 or when
+// we are using the compiler builtin for is_convertible.
+#if __cplusplus >= 201103L || !defined(_LIBCPP_USE_IS_CONVERTIBLE_FALLBACK)
+ test_is_not_convertible<NonCopyable&, NonCopyable>();
+#endif
+
+}
diff --git a/test/std/utilities/meta/meta.rel/is_convertible_fallback.pass.cpp b/test/std/utilities/meta/meta.rel/is_convertible_fallback.pass.cpp
new file mode 100644
index 000000000000..bd35ef63d08b
--- /dev/null
+++ b/test/std/utilities/meta/meta.rel/is_convertible_fallback.pass.cpp
@@ -0,0 +1,18 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_convertible
+
+// Test the fallback implementation.
+
+#define _LIBCPP_USE_IS_CONVERTIBLE_FALLBACK
+#include "is_convertible.pass.cpp"
+
diff --git a/test/std/utilities/meta/meta.rel/is_same.pass.cpp b/test/std/utilities/meta/meta.rel/is_same.pass.cpp
new file mode 100644
index 000000000000..7250d6ca7730
--- /dev/null
+++ b/test/std/utilities/meta/meta.rel/is_same.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_same
+
+#include <type_traits>
+
+template <class T, class U>
+void test_is_same()
+{
+ static_assert((std::is_same<T, U>::value), "");
+ static_assert((!std::is_same<const T, U>::value), "");
+ static_assert((!std::is_same<T, const U>::value), "");
+ static_assert((std::is_same<const T, const U>::value), "");
+}
+
+template <class T, class U>
+void test_is_same_ref()
+{
+ static_assert((std::is_same<T, U>::value), "");
+ static_assert((std::is_same<const T, U>::value), "");
+ static_assert((std::is_same<T, const U>::value), "");
+ static_assert((std::is_same<const T, const U>::value), "");
+}
+
+template <class T, class U>
+void test_is_not_same()
+{
+ static_assert((!std::is_same<T, U>::value), "");
+}
+
+class Class
+{
+public:
+ ~Class();
+};
+
+int main()
+{
+ test_is_same<int, int>();
+ test_is_same<void, void>();
+ test_is_same<Class, Class>();
+ test_is_same<int*, int*>();
+ test_is_same_ref<int&, int&>();
+
+ test_is_not_same<int, void>();
+ test_is_not_same<void, Class>();
+ test_is_not_same<Class, int*>();
+ test_is_not_same<int*, int&>();
+ test_is_not_same<int&, int>();
+}
diff --git a/test/std/utilities/meta/meta.rqmts/nothing_to_do.pass.cpp b/test/std/utilities/meta/meta.rqmts/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/utilities/meta/meta.rqmts/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/utilities/meta/meta.trans/meta.trans.arr/remove_all_extents.pass.cpp b/test/std/utilities/meta/meta.trans/meta.trans.arr/remove_all_extents.pass.cpp
new file mode 100644
index 000000000000..28bbedee1749
--- /dev/null
+++ b/test/std/utilities/meta/meta.trans/meta.trans.arr/remove_all_extents.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// remove_all_extents
+
+#include <type_traits>
+
+enum Enum {zero, one_};
+
+template <class T, class U>
+void test_remove_all_extents()
+{
+ static_assert((std::is_same<typename std::remove_all_extents<T>::type, U>::value), "");
+#if _LIBCPP_STD_VER > 11
+ static_assert((std::is_same<std::remove_all_extents_t<T>, U>::value), "");
+#endif
+}
+
+int main()
+{
+ test_remove_all_extents<int, int> ();
+ test_remove_all_extents<const Enum, const Enum> ();
+ test_remove_all_extents<int[], int> ();
+ test_remove_all_extents<const int[], const int> ();
+ test_remove_all_extents<int[3], int> ();
+ test_remove_all_extents<const int[3], const int> ();
+ test_remove_all_extents<int[][3], int> ();
+ test_remove_all_extents<const int[][3], const int> ();
+ test_remove_all_extents<int[2][3], int> ();
+ test_remove_all_extents<const int[2][3], const int> ();
+ test_remove_all_extents<int[1][2][3], int> ();
+ test_remove_all_extents<const int[1][2][3], const int> ();
+}
diff --git a/test/std/utilities/meta/meta.trans/meta.trans.arr/remove_extent.pass.cpp b/test/std/utilities/meta/meta.trans/meta.trans.arr/remove_extent.pass.cpp
new file mode 100644
index 000000000000..c688c26b9a5b
--- /dev/null
+++ b/test/std/utilities/meta/meta.trans/meta.trans.arr/remove_extent.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// remove_extent
+
+#include <type_traits>
+
+enum Enum {zero, one_};
+
+template <class T, class U>
+void test_remove_extent()
+{
+ static_assert((std::is_same<typename std::remove_extent<T>::type, U>::value), "");
+#if _LIBCPP_STD_VER > 11
+ static_assert((std::is_same<std::remove_extent_t<T>, U>::value), "");
+#endif
+}
+
+
+int main()
+{
+ test_remove_extent<int, int> ();
+ test_remove_extent<const Enum, const Enum> ();
+ test_remove_extent<int[], int> ();
+ test_remove_extent<const int[], const int> ();
+ test_remove_extent<int[3], int> ();
+ test_remove_extent<const int[3], const int> ();
+ test_remove_extent<int[][3], int[3]> ();
+ test_remove_extent<const int[][3], const int[3]> ();
+ test_remove_extent<int[2][3], int[3]> ();
+ test_remove_extent<const int[2][3], const int[3]> ();
+ test_remove_extent<int[1][2][3], int[2][3]> ();
+ test_remove_extent<const int[1][2][3], const int[2][3]> ();
+}
diff --git a/test/std/utilities/meta/meta.trans/meta.trans.cv/add_const.pass.cpp b/test/std/utilities/meta/meta.trans/meta.trans.cv/add_const.pass.cpp
new file mode 100644
index 000000000000..19b1fb4d01b3
--- /dev/null
+++ b/test/std/utilities/meta/meta.trans/meta.trans.cv/add_const.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// add_const
+
+#include <type_traits>
+
+template <class T, class U>
+void test_add_const_imp()
+{
+ static_assert((std::is_same<typename std::add_const<T>::type, const U>::value), "");
+#if _LIBCPP_STD_VER > 11
+ static_assert((std::is_same<std::add_const_t<T>, U>::value), "");
+#endif
+}
+
+template <class T>
+void test_add_const()
+{
+ test_add_const_imp<T, const T>();
+ test_add_const_imp<const T, const T>();
+ test_add_const_imp<volatile T, volatile const T>();
+ test_add_const_imp<const volatile T, const volatile T>();
+}
+
+int main()
+{
+ test_add_const<void>();
+ test_add_const<int>();
+ test_add_const<int[3]>();
+ test_add_const<int&>();
+ test_add_const<const int&>();
+ test_add_const<int*>();
+ test_add_const<const int*>();
+}
diff --git a/test/std/utilities/meta/meta.trans/meta.trans.cv/add_cv.pass.cpp b/test/std/utilities/meta/meta.trans/meta.trans.cv/add_cv.pass.cpp
new file mode 100644
index 000000000000..4905e518e12a
--- /dev/null
+++ b/test/std/utilities/meta/meta.trans/meta.trans.cv/add_cv.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// add_cv
+
+#include <type_traits>
+
+template <class T, class U>
+void test_add_cv_imp()
+{
+ static_assert((std::is_same<typename std::add_cv<T>::type, const volatile U>::value), "");
+#if _LIBCPP_STD_VER > 11
+ static_assert((std::is_same<std::add_cv_t<T>, U>::value), "");
+#endif
+}
+
+template <class T>
+void test_add_cv()
+{
+ test_add_cv_imp<T, const volatile T>();
+ test_add_cv_imp<const T, const volatile T>();
+ test_add_cv_imp<volatile T, volatile const T>();
+ test_add_cv_imp<const volatile T, const volatile T>();
+}
+
+int main()
+{
+ test_add_cv<void>();
+ test_add_cv<int>();
+ test_add_cv<int[3]>();
+ test_add_cv<int&>();
+ test_add_cv<const int&>();
+ test_add_cv<int*>();
+ test_add_cv<const int*>();
+}
diff --git a/test/std/utilities/meta/meta.trans/meta.trans.cv/add_volatile.pass.cpp b/test/std/utilities/meta/meta.trans/meta.trans.cv/add_volatile.pass.cpp
new file mode 100644
index 000000000000..7a12c44a2c6e
--- /dev/null
+++ b/test/std/utilities/meta/meta.trans/meta.trans.cv/add_volatile.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// add_volatile
+
+#include <type_traits>
+
+template <class T, class U>
+void test_add_volatile_imp()
+{
+ static_assert((std::is_same<typename std::add_volatile<T>::type, volatile U>::value), "");
+#if _LIBCPP_STD_VER > 11
+ static_assert((std::is_same<std::add_volatile_t<T>, U>::value), "");
+#endif
+}
+
+template <class T>
+void test_add_volatile()
+{
+ test_add_volatile_imp<T, volatile T>();
+ test_add_volatile_imp<const T, const volatile T>();
+ test_add_volatile_imp<volatile T, volatile T>();
+ test_add_volatile_imp<const volatile T, const volatile T>();
+}
+
+int main()
+{
+ test_add_volatile<void>();
+ test_add_volatile<int>();
+ test_add_volatile<int[3]>();
+ test_add_volatile<int&>();
+ test_add_volatile<const int&>();
+ test_add_volatile<int*>();
+ test_add_volatile<const int*>();
+}
diff --git a/test/std/utilities/meta/meta.trans/meta.trans.cv/remove_const.pass.cpp b/test/std/utilities/meta/meta.trans/meta.trans.cv/remove_const.pass.cpp
new file mode 100644
index 000000000000..cd2faf786d80
--- /dev/null
+++ b/test/std/utilities/meta/meta.trans/meta.trans.cv/remove_const.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// remove_const
+
+#include <type_traits>
+
+template <class T, class U>
+void test_remove_const_imp()
+{
+ static_assert((std::is_same<typename std::remove_const<T>::type, U>::value), "");
+#if _LIBCPP_STD_VER > 11
+ static_assert((std::is_same<std::remove_const_t<T>, U>::value), "");
+#endif
+}
+
+template <class T>
+void test_remove_const()
+{
+ test_remove_const_imp<T, T>();
+ test_remove_const_imp<const T, T>();
+ test_remove_const_imp<volatile T, volatile T>();
+ test_remove_const_imp<const volatile T, volatile T>();
+}
+
+int main()
+{
+ test_remove_const<void>();
+ test_remove_const<int>();
+ test_remove_const<int[3]>();
+ test_remove_const<int&>();
+ test_remove_const<const int&>();
+ test_remove_const<int*>();
+ test_remove_const<const int*>();
+}
diff --git a/test/std/utilities/meta/meta.trans/meta.trans.cv/remove_cv.pass.cpp b/test/std/utilities/meta/meta.trans/meta.trans.cv/remove_cv.pass.cpp
new file mode 100644
index 000000000000..3f6405c8280c
--- /dev/null
+++ b/test/std/utilities/meta/meta.trans/meta.trans.cv/remove_cv.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// remove_cv
+
+#include <type_traits>
+
+template <class T, class U>
+void test_remove_cv_imp()
+{
+ static_assert((std::is_same<typename std::remove_cv<T>::type, U>::value), "");
+#if _LIBCPP_STD_VER > 11
+ static_assert((std::is_same<std::remove_cv_t<T>, U>::value), "");
+#endif
+}
+
+template <class T>
+void test_remove_cv()
+{
+ test_remove_cv_imp<T, T>();
+ test_remove_cv_imp<const T, T>();
+ test_remove_cv_imp<volatile T, T>();
+ test_remove_cv_imp<const volatile T, T>();
+}
+
+int main()
+{
+ test_remove_cv<void>();
+ test_remove_cv<int>();
+ test_remove_cv<int[3]>();
+ test_remove_cv<int&>();
+ test_remove_cv<const int&>();
+ test_remove_cv<int*>();
+ test_remove_cv<const int*>();
+}
diff --git a/test/std/utilities/meta/meta.trans/meta.trans.cv/remove_volatile.pass.cpp b/test/std/utilities/meta/meta.trans/meta.trans.cv/remove_volatile.pass.cpp
new file mode 100644
index 000000000000..6258a9039b40
--- /dev/null
+++ b/test/std/utilities/meta/meta.trans/meta.trans.cv/remove_volatile.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// remove_volatile
+
+#include <type_traits>
+
+template <class T, class U>
+void test_remove_volatile_imp()
+{
+ static_assert((std::is_same<typename std::remove_volatile<T>::type, U>::value), "");
+#if _LIBCPP_STD_VER > 11
+ static_assert((std::is_same<std::remove_volatile_t<T>, U>::value), "");
+#endif
+}
+
+template <class T>
+void test_remove_volatile()
+{
+ test_remove_volatile_imp<T, T>();
+ test_remove_volatile_imp<const T, const T>();
+ test_remove_volatile_imp<volatile T, T>();
+ test_remove_volatile_imp<const volatile T, const T>();
+}
+
+int main()
+{
+ test_remove_volatile<void>();
+ test_remove_volatile<int>();
+ test_remove_volatile<int[3]>();
+ test_remove_volatile<int&>();
+ test_remove_volatile<const int&>();
+ test_remove_volatile<int*>();
+ test_remove_volatile<volatile int*>();
+}
diff --git a/test/std/utilities/meta/meta.trans/meta.trans.other/aligned_storage.pass.cpp b/test/std/utilities/meta/meta.trans/meta.trans.other/aligned_storage.pass.cpp
new file mode 100644
index 000000000000..c87e99c46e80
--- /dev/null
+++ b/test/std/utilities/meta/meta.trans/meta.trans.other/aligned_storage.pass.cpp
@@ -0,0 +1,194 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// aligned_storage
+
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::aligned_storage<10, 1 >::type T1;
+#if _LIBCPP_STD_VER > 11
+ static_assert(std::is_same<std::aligned_storage_t<10, 1>, T1>::value, "" );
+#endif
+ static_assert(std::alignment_of<T1>::value == 1, "");
+ static_assert(sizeof(T1) == 10, "");
+ }
+ {
+ typedef std::aligned_storage<10, 2 >::type T1;
+#if _LIBCPP_STD_VER > 11
+ static_assert(std::is_same<std::aligned_storage_t<10, 2>, T1>::value, "" );
+#endif
+ static_assert(std::alignment_of<T1>::value == 2, "");
+ static_assert(sizeof(T1) == 10, "");
+ }
+ {
+ typedef std::aligned_storage<10, 4 >::type T1;
+#if _LIBCPP_STD_VER > 11
+ static_assert(std::is_same<std::aligned_storage_t<10, 4>, T1>::value, "" );
+#endif
+ static_assert(std::alignment_of<T1>::value == 4, "");
+ static_assert(sizeof(T1) == 12, "");
+ }
+ {
+ typedef std::aligned_storage<10, 8 >::type T1;
+#if _LIBCPP_STD_VER > 11
+ static_assert(std::is_same<std::aligned_storage_t<10, 8>, T1>::value, "" );
+#endif
+ static_assert(std::alignment_of<T1>::value == 8, "");
+ static_assert(sizeof(T1) == 16, "");
+ }
+ {
+ typedef std::aligned_storage<10, 16 >::type T1;
+#if _LIBCPP_STD_VER > 11
+ static_assert(std::is_same<std::aligned_storage_t<10, 16>, T1>::value, "" );
+#endif
+ static_assert(std::alignment_of<T1>::value == 16, "");
+ static_assert(sizeof(T1) == 16, "");
+ }
+ {
+ typedef std::aligned_storage<10, 32 >::type T1;
+#if _LIBCPP_STD_VER > 11
+ static_assert(std::is_same<std::aligned_storage_t<10, 32>, T1>::value, "" );
+#endif
+ static_assert(std::alignment_of<T1>::value == 32, "");
+ static_assert(sizeof(T1) == 32, "");
+ }
+ {
+ typedef std::aligned_storage<20, 32 >::type T1;
+#if _LIBCPP_STD_VER > 11
+ static_assert(std::is_same<std::aligned_storage_t<20, 32>, T1>::value, "" );
+#endif
+ static_assert(std::alignment_of<T1>::value == 32, "");
+ static_assert(sizeof(T1) == 32, "");
+ }
+ {
+ typedef std::aligned_storage<40, 32 >::type T1;
+#if _LIBCPP_STD_VER > 11
+ static_assert(std::is_same<std::aligned_storage_t<40, 32>, T1>::value, "" );
+#endif
+ static_assert(std::alignment_of<T1>::value == 32, "");
+ static_assert(sizeof(T1) == 64, "");
+ }
+ {
+ typedef std::aligned_storage<12, 16 >::type T1;
+#if _LIBCPP_STD_VER > 11
+ static_assert(std::is_same<std::aligned_storage_t<12, 16>, T1>::value, "" );
+#endif
+ static_assert(std::alignment_of<T1>::value == 16, "");
+ static_assert(sizeof(T1) == 16, "");
+ }
+ {
+ typedef std::aligned_storage<1>::type T1;
+#if _LIBCPP_STD_VER > 11
+ static_assert(std::is_same<std::aligned_storage_t<1>, T1>::value, "" );
+#endif
+ static_assert(std::alignment_of<T1>::value == 1, "");
+ static_assert(sizeof(T1) == 1, "");
+ }
+ {
+ typedef std::aligned_storage<2>::type T1;
+#if _LIBCPP_STD_VER > 11
+ static_assert(std::is_same<std::aligned_storage_t<2>, T1>::value, "" );
+#endif
+ static_assert(std::alignment_of<T1>::value == 2, "");
+ static_assert(sizeof(T1) == 2, "");
+ }
+ {
+ typedef std::aligned_storage<3>::type T1;
+#if _LIBCPP_STD_VER > 11
+ static_assert(std::is_same<std::aligned_storage_t<3>, T1>::value, "" );
+#endif
+ static_assert(std::alignment_of<T1>::value == 2, "");
+ static_assert(sizeof(T1) == 4, "");
+ }
+ {
+ typedef std::aligned_storage<4>::type T1;
+#if _LIBCPP_STD_VER > 11
+ static_assert(std::is_same<std::aligned_storage_t<4>, T1>::value, "" );
+#endif
+ static_assert(std::alignment_of<T1>::value == 4, "");
+ static_assert(sizeof(T1) == 4, "");
+ }
+ {
+ typedef std::aligned_storage<5>::type T1;
+#if _LIBCPP_STD_VER > 11
+ static_assert(std::is_same<std::aligned_storage_t<5>, T1>::value, "" );
+#endif
+ static_assert(std::alignment_of<T1>::value == 4, "");
+ static_assert(sizeof(T1) == 8, "");
+ }
+ {
+ typedef std::aligned_storage<7>::type T1;
+#if _LIBCPP_STD_VER > 11
+ static_assert(std::is_same<std::aligned_storage_t<7>, T1>::value, "" );
+#endif
+ static_assert(std::alignment_of<T1>::value == 4, "");
+ static_assert(sizeof(T1) == 8, "");
+ }
+ {
+ typedef std::aligned_storage<8>::type T1;
+#if _LIBCPP_STD_VER > 11
+ static_assert(std::is_same<std::aligned_storage_t<8>, T1>::value, "" );
+#endif
+ static_assert(std::alignment_of<T1>::value == 8, "");
+ static_assert(sizeof(T1) == 8, "");
+ }
+ {
+ typedef std::aligned_storage<9>::type T1;
+#if _LIBCPP_STD_VER > 11
+ static_assert(std::is_same<std::aligned_storage_t<9>, T1>::value, "" );
+#endif
+ static_assert(std::alignment_of<T1>::value == 8, "");
+ static_assert(sizeof(T1) == 16, "");
+ }
+ {
+ typedef std::aligned_storage<15>::type T1;
+#if _LIBCPP_STD_VER > 11
+ static_assert(std::is_same<std::aligned_storage_t<15>, T1>::value, "" );
+#endif
+ static_assert(std::alignment_of<T1>::value == 8, "");
+ static_assert(sizeof(T1) == 16, "");
+ }
+ // Use alignof(std::max_align_t) below to find the max alignment instead of
+ // hardcoding it, because it's different on different platforms.
+ // (For example 8 on arm and 16 on x86.)
+#if __cplusplus < 201103L
+#define alignof __alignof__
+#endif
+ {
+ typedef std::aligned_storage<16>::type T1;
+#if _LIBCPP_STD_VER > 11
+ static_assert(std::is_same<std::aligned_storage_t<16>, T1>::value, "" );
+#endif
+ static_assert(std::alignment_of<T1>::value == alignof(std::max_align_t),
+ "");
+ static_assert(sizeof(T1) == 16, "");
+ }
+ {
+ typedef std::aligned_storage<17>::type T1;
+#if _LIBCPP_STD_VER > 11
+ static_assert(std::is_same<std::aligned_storage_t<17>, T1>::value, "" );
+#endif
+ static_assert(std::alignment_of<T1>::value == alignof(std::max_align_t),
+ "");
+ static_assert(sizeof(T1) == 16 + alignof(std::max_align_t), "");
+ }
+ {
+ typedef std::aligned_storage<10>::type T1;
+#if _LIBCPP_STD_VER > 11
+ static_assert(std::is_same<std::aligned_storage_t<10>, T1>::value, "" );
+#endif
+ static_assert(std::alignment_of<T1>::value == 8, "");
+ static_assert(sizeof(T1) == 16, "");
+ }
+}
diff --git a/test/std/utilities/meta/meta.trans/meta.trans.other/aligned_union.pass.cpp b/test/std/utilities/meta/meta.trans/meta.trans.other/aligned_union.pass.cpp
new file mode 100644
index 000000000000..ae849ca54558
--- /dev/null
+++ b/test/std/utilities/meta/meta.trans/meta.trans.other/aligned_union.pass.cpp
@@ -0,0 +1,92 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// aligned_union<size_t Len, class ...Types>
+
+#include <type_traits>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+ {
+ typedef std::aligned_union<10, char >::type T1;
+#if _LIBCPP_STD_VER > 11
+ static_assert(std::is_same<std::aligned_union_t<10, char>, T1>::value, "" );
+#endif
+ static_assert(std::alignment_of<T1>::value == 1, "");
+ static_assert(sizeof(T1) == 10, "");
+ }
+ {
+ typedef std::aligned_union<10, short >::type T1;
+#if _LIBCPP_STD_VER > 11
+ static_assert(std::is_same<std::aligned_union_t<10, short>, T1>::value, "" );
+#endif
+ static_assert(std::alignment_of<T1>::value == 2, "");
+ static_assert(sizeof(T1) == 10, "");
+ }
+ {
+ typedef std::aligned_union<10, int >::type T1;
+#if _LIBCPP_STD_VER > 11
+ static_assert(std::is_same<std::aligned_union_t<10, int>, T1>::value, "" );
+#endif
+ static_assert(std::alignment_of<T1>::value == 4, "");
+ static_assert(sizeof(T1) == 12, "");
+ }
+ {
+ typedef std::aligned_union<10, double >::type T1;
+#if _LIBCPP_STD_VER > 11
+ static_assert(std::is_same<std::aligned_union_t<10, double>, T1>::value, "" );
+#endif
+ static_assert(std::alignment_of<T1>::value == 8, "");
+ static_assert(sizeof(T1) == 16, "");
+ }
+ {
+ typedef std::aligned_union<10, short, char >::type T1;
+#if _LIBCPP_STD_VER > 11
+ static_assert(std::is_same<std::aligned_union_t<10, short, char>, T1>::value, "" );
+#endif
+ static_assert(std::alignment_of<T1>::value == 2, "");
+ static_assert(sizeof(T1) == 10, "");
+ }
+ {
+ typedef std::aligned_union<10, char, short >::type T1;
+#if _LIBCPP_STD_VER > 11
+ static_assert(std::is_same<std::aligned_union_t<10, char, short>, T1>::value, "" );
+#endif
+ static_assert(std::alignment_of<T1>::value == 2, "");
+ static_assert(sizeof(T1) == 10, "");
+ }
+ {
+ typedef std::aligned_union<2, int, char, short >::type T1;
+#if _LIBCPP_STD_VER > 11
+ static_assert(std::is_same<std::aligned_union_t<2, int, char, short>, T1>::value, "" );
+#endif
+ static_assert(std::alignment_of<T1>::value == 4, "");
+ static_assert(sizeof(T1) == 4, "");
+ }
+ {
+ typedef std::aligned_union<2, char, int, short >::type T1;
+#if _LIBCPP_STD_VER > 11
+ static_assert(std::is_same<std::aligned_union_t<2, char, int, short >, T1>::value, "" );
+#endif
+ static_assert(std::alignment_of<T1>::value == 4, "");
+ static_assert(sizeof(T1) == 4, "");
+ }
+ {
+ typedef std::aligned_union<2, char, short, int >::type T1;
+#if _LIBCPP_STD_VER > 11
+ static_assert(std::is_same<std::aligned_union_t<2, char, short, int >, T1>::value, "" );
+#endif
+ static_assert(std::alignment_of<T1>::value == 4, "");
+ static_assert(sizeof(T1) == 4, "");
+ }
+#endif
+}
diff --git a/test/std/utilities/meta/meta.trans/meta.trans.other/common_type.pass.cpp b/test/std/utilities/meta/meta.trans/meta.trans.other/common_type.pass.cpp
new file mode 100644
index 000000000000..91bf7e7654e0
--- /dev/null
+++ b/test/std/utilities/meta/meta.trans/meta.trans.other/common_type.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// common_type
+
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_same<std::common_type<int>::type, int>::value), "");
+ static_assert((std::is_same<std::common_type<char>::type, char>::value), "");
+#if _LIBCPP_STD_VER > 11
+ static_assert((std::is_same<std::common_type_t<int>, int>::value), "");
+ static_assert((std::is_same<std::common_type_t<char>, char>::value), "");
+#endif
+
+ static_assert((std::is_same<std::common_type< int>::type, int>::value), "");
+ static_assert((std::is_same<std::common_type<const int>::type, int>::value), "");
+ static_assert((std::is_same<std::common_type< volatile int>::type, int>::value), "");
+ static_assert((std::is_same<std::common_type<const volatile int>::type, int>::value), "");
+
+ static_assert((std::is_same<std::common_type<int, int>::type, int>::value), "");
+ static_assert((std::is_same<std::common_type<int, const int>::type, int>::value), "");
+
+ static_assert((std::is_same<std::common_type<long, const int>::type, long>::value), "");
+ static_assert((std::is_same<std::common_type<const long, int>::type, long>::value), "");
+ static_assert((std::is_same<std::common_type<long, volatile int>::type, long>::value), "");
+ static_assert((std::is_same<std::common_type<volatile long, int>::type, long>::value), "");
+ static_assert((std::is_same<std::common_type<const long, const int>::type, long>::value), "");
+
+ static_assert((std::is_same<std::common_type<double, char>::type, double>::value), "");
+ static_assert((std::is_same<std::common_type<short, char>::type, int>::value), "");
+#if _LIBCPP_STD_VER > 11
+ static_assert((std::is_same<std::common_type_t<double, char>, double>::value), "");
+ static_assert((std::is_same<std::common_type_t<short, char>, int>::value), "");
+#endif
+
+ static_assert((std::is_same<std::common_type<double, char, long long>::type, double>::value), "");
+ static_assert((std::is_same<std::common_type<unsigned, char, long long>::type, long long>::value), "");
+#if _LIBCPP_STD_VER > 11
+ static_assert((std::is_same<std::common_type_t<double, char, long long>, double>::value), "");
+ static_assert((std::is_same<std::common_type_t<unsigned, char, long long>, long long>::value), "");
+#endif
+}
diff --git a/test/std/utilities/meta/meta.trans/meta.trans.other/conditional.pass.cpp b/test/std/utilities/meta/meta.trans/meta.trans.other/conditional.pass.cpp
new file mode 100644
index 000000000000..ac11e3a4ce86
--- /dev/null
+++ b/test/std/utilities/meta/meta.trans/meta.trans.other/conditional.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// conditional
+
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_same<std::conditional<true, char, int>::type, char>::value), "");
+ static_assert((std::is_same<std::conditional<false, char, int>::type, int>::value), "");
+#if _LIBCPP_STD_VER > 11
+ static_assert((std::is_same<std::conditional_t<true, char, int>, char>::value), "");
+ static_assert((std::is_same<std::conditional_t<false, char, int>, int>::value), "");
+#endif
+}
diff --git a/test/std/utilities/meta/meta.trans/meta.trans.other/decay.pass.cpp b/test/std/utilities/meta/meta.trans/meta.trans.other/decay.pass.cpp
new file mode 100644
index 000000000000..bd8ae0e297bc
--- /dev/null
+++ b/test/std/utilities/meta/meta.trans/meta.trans.other/decay.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// decay
+
+#include <type_traits>
+
+template <class T, class U>
+void test_decay()
+{
+ static_assert((std::is_same<typename std::decay<T>::type, U>::value), "");
+#if _LIBCPP_STD_VER > 11
+ static_assert((std::is_same<std::decay_t<T>, U>::value), "");
+#endif
+}
+
+int main()
+{
+ test_decay<void, void>();
+ test_decay<int, int>();
+ test_decay<const volatile int, int>();
+ test_decay<int*, int*>();
+ test_decay<int[3], int*>();
+ test_decay<const int[3], const int*>();
+ test_decay<void(), void (*)()>();
+}
diff --git a/test/std/utilities/meta/meta.trans/meta.trans.other/enable_if.fail.cpp b/test/std/utilities/meta/meta.trans/meta.trans.other/enable_if.fail.cpp
new file mode 100644
index 000000000000..1ab07670fc26
--- /dev/null
+++ b/test/std/utilities/meta/meta.trans/meta.trans.other/enable_if.fail.cpp
@@ -0,0 +1,19 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// enable_if
+
+#include <type_traits>
+
+int main()
+{
+ typedef std::enable_if<false>::type A;
+}
diff --git a/test/std/utilities/meta/meta.trans/meta.trans.other/enable_if.pass.cpp b/test/std/utilities/meta/meta.trans/meta.trans.other/enable_if.pass.cpp
new file mode 100644
index 000000000000..eb72b0f393b3
--- /dev/null
+++ b/test/std/utilities/meta/meta.trans/meta.trans.other/enable_if.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// enable_if
+
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_same<std::enable_if<true>::type, void>::value), "");
+ static_assert((std::is_same<std::enable_if<true, int>::type, int>::value), "");
+#if _LIBCPP_STD_VER > 11
+ static_assert((std::is_same<std::enable_if_t<true>, void>::value), "");
+ static_assert((std::is_same<std::enable_if_t<true, int>, int>::value), "");
+#endif
+}
diff --git a/test/std/utilities/meta/meta.trans/meta.trans.other/enable_if2.fail.cpp b/test/std/utilities/meta/meta.trans/meta.trans.other/enable_if2.fail.cpp
new file mode 100644
index 000000000000..8ce894578c4f
--- /dev/null
+++ b/test/std/utilities/meta/meta.trans/meta.trans.other/enable_if2.fail.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// enable_if
+
+#include <type_traits>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ typedef std::enable_if_t<false> A;
+#else
+ static_assert ( false, "" );
+#endif
+}
diff --git a/test/std/utilities/meta/meta.trans/meta.trans.other/result_of.pass.cpp b/test/std/utilities/meta/meta.trans/meta.trans.other/result_of.pass.cpp
new file mode 100644
index 000000000000..5a925bb34b26
--- /dev/null
+++ b/test/std/utilities/meta/meta.trans/meta.trans.other/result_of.pass.cpp
@@ -0,0 +1,252 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// result_of<Fn(ArgTypes...)>
+
+#include <type_traits>
+#include <memory>
+#include "test_macros.h"
+
+struct S
+{
+ typedef short (*FreeFunc)(long);
+ operator FreeFunc() const;
+ double operator()(char, int&);
+ double const& operator()(char, int&) const;
+ double volatile& operator()(char, int&) volatile;
+ double const volatile& operator()(char, int&) const volatile;
+};
+
+template <class Tp>
+struct Voider {
+ typedef void type;
+};
+
+template <class T, class = void>
+struct HasType : std::false_type {};
+
+template <class T>
+struct HasType<T, typename Voider<typename T::type>::type> : std::true_type {};
+
+template <class T, class U>
+void test_result_of()
+{
+ static_assert((std::is_same<typename std::result_of<T>::type, U>::value), "");
+}
+
+template <class T>
+void test_no_result()
+{
+#if TEST_STD_VER >= 11
+ static_assert((!HasType<std::result_of<T> >::value), "");
+#endif
+}
+
+int main()
+{
+ { // functor object
+ test_result_of<S(int), short> ();
+ test_result_of<S&(unsigned char, int&), double> ();
+ test_result_of<S const&(unsigned char, int&), double const &> ();
+ test_result_of<S volatile&(unsigned char, int&), double volatile&> ();
+ test_result_of<S const volatile&(unsigned char, int&), double const volatile&> ();
+ }
+ { // pointer to function
+ typedef bool (&RF0)();
+ typedef bool* (&RF1)(int);
+ typedef bool& (&RF2)(int, int);
+ typedef bool const& (&RF3)(int, int, int);
+ typedef bool (*PF0)();
+ typedef bool* (*PF1)(int);
+ typedef bool& (*PF2)(int, int);
+ typedef bool const& (*PF3)(int, int, int);
+ typedef bool (*&PRF0)();
+ typedef bool* (*&PRF1)(int);
+ typedef bool& (*&PRF2)(int, int);
+ typedef bool const& (*&PRF3)(int, int, int);
+ test_result_of<RF0(), bool>();
+ test_result_of<RF1(int), bool*>();
+ test_result_of<RF2(int, long), bool&>();
+ test_result_of<RF3(int, long, int), bool const&>();
+ test_result_of<PF0(), bool>();
+ test_result_of<PF1(int), bool*>();
+ test_result_of<PF2(int, long), bool&>();
+ test_result_of<PF3(int, long, int), bool const&>();
+ test_result_of<PRF0(), bool>();
+ test_result_of<PRF1(int), bool*>();
+ test_result_of<PRF2(int, long), bool&>();
+ test_result_of<PRF3(int, long, int), bool const&>();
+ }
+ { // pointer to member function
+
+ typedef int (S::*PMS0)();
+ typedef int* (S::*PMS1)(long);
+ typedef int& (S::*PMS2)(long, int);
+ test_result_of<PMS0( S), int> ();
+ test_result_of<PMS0( S&), int> ();
+ test_result_of<PMS0( S*), int> ();
+ test_result_of<PMS0( S*&), int> ();
+ test_result_of<PMS0(std::unique_ptr<S>), int> ();
+ test_no_result<PMS0(const S&)>();
+ test_no_result<PMS0(volatile S&)>();
+ test_no_result<PMS0(const volatile S&)>();
+
+ test_result_of<PMS1( S, int), int*> ();
+ test_result_of<PMS1( S&, int), int*> ();
+ test_result_of<PMS1( S*, int), int*> ();
+ test_result_of<PMS1( S*&, int), int*> ();
+ test_result_of<PMS1(std::unique_ptr<S>, int), int*> ();
+ test_no_result<PMS1(const S&, int)>();
+ test_no_result<PMS1(volatile S&, int)>();
+ test_no_result<PMS1(const volatile S&, int)>();
+
+ test_result_of<PMS2( S, int, int), int&> ();
+ test_result_of<PMS2( S&, int, int), int&> ();
+ test_result_of<PMS2( S*, int, int), int&> ();
+ test_result_of<PMS2( S*&, int, int), int&> ();
+ test_result_of<PMS2(std::unique_ptr<S>, int, int), int&> ();
+ test_no_result<PMS2(const S&, int, int)>();
+ test_no_result<PMS2(volatile S&, int, int)>();
+ test_no_result<PMS2(const volatile S&, int, int)>();
+
+ typedef int (S::*PMS0C)() const;
+ typedef int* (S::*PMS1C)(long) const;
+ typedef int& (S::*PMS2C)(long, int) const;
+ test_result_of<PMS0C( S), int> ();
+ test_result_of<PMS0C( S&), int> ();
+ test_result_of<PMS0C(const S&), int> ();
+ test_result_of<PMS0C( S*), int> ();
+ test_result_of<PMS0C(const S*), int> ();
+ test_result_of<PMS0C( S*&), int> ();
+ test_result_of<PMS0C(const S*&), int> ();
+ test_result_of<PMS0C(std::unique_ptr<S>), int> ();
+ test_no_result<PMS0C(volatile S&)>();
+ test_no_result<PMS0C(const volatile S&)>();
+
+ test_result_of<PMS1C( S, int), int*> ();
+ test_result_of<PMS1C( S&, int), int*> ();
+ test_result_of<PMS1C(const S&, int), int*> ();
+ test_result_of<PMS1C( S*, int), int*> ();
+ test_result_of<PMS1C(const S*, int), int*> ();
+ test_result_of<PMS1C( S*&, int), int*> ();
+ test_result_of<PMS1C(const S*&, int), int*> ();
+ test_result_of<PMS1C(std::unique_ptr<S>, int), int*> ();
+ test_no_result<PMS1C(volatile S&, int)>();
+ test_no_result<PMS1C(const volatile S&, int)>();
+
+ test_result_of<PMS2C( S, int, int), int&> ();
+ test_result_of<PMS2C( S&, int, int), int&> ();
+ test_result_of<PMS2C(const S&, int, int), int&> ();
+ test_result_of<PMS2C( S*, int, int), int&> ();
+ test_result_of<PMS2C(const S*, int, int), int&> ();
+ test_result_of<PMS2C( S*&, int, int), int&> ();
+ test_result_of<PMS2C(const S*&, int, int), int&> ();
+ test_result_of<PMS2C(std::unique_ptr<S>, int, int), int&> ();
+ test_no_result<PMS2C(volatile S&, int, int)>();
+ test_no_result<PMS2C(const volatile S&, int, int)>();
+
+ typedef int (S::*PMS0V)() volatile;
+ typedef int* (S::*PMS1V)(long) volatile;
+ typedef int& (S::*PMS2V)(long, int) volatile;
+ test_result_of<PMS0V( S), int> ();
+ test_result_of<PMS0V( S&), int> ();
+ test_result_of<PMS0V(volatile S&), int> ();
+ test_result_of<PMS0V( S*), int> ();
+ test_result_of<PMS0V(volatile S*), int> ();
+ test_result_of<PMS0V( S*&), int> ();
+ test_result_of<PMS0V(volatile S*&), int> ();
+ test_result_of<PMS0V(std::unique_ptr<S>), int> ();
+ test_no_result<PMS0V(const S&)>();
+ test_no_result<PMS0V(const volatile S&)>();
+
+ test_result_of<PMS1V( S, int), int*> ();
+ test_result_of<PMS1V( S&, int), int*> ();
+ test_result_of<PMS1V(volatile S&, int), int*> ();
+ test_result_of<PMS1V( S*, int), int*> ();
+ test_result_of<PMS1V(volatile S*, int), int*> ();
+ test_result_of<PMS1V( S*&, int), int*> ();
+ test_result_of<PMS1V(volatile S*&, int), int*> ();
+ test_result_of<PMS1V(std::unique_ptr<S>, int), int*> ();
+ test_no_result<PMS1V(const S&, int)>();
+ test_no_result<PMS1V(const volatile S&, int)>();
+
+ test_result_of<PMS2V( S, int, int), int&> ();
+ test_result_of<PMS2V( S&, int, int), int&> ();
+ test_result_of<PMS2V(volatile S&, int, int), int&> ();
+ test_result_of<PMS2V( S*, int, int), int&> ();
+ test_result_of<PMS2V(volatile S*, int, int), int&> ();
+ test_result_of<PMS2V( S*&, int, int), int&> ();
+ test_result_of<PMS2V(volatile S*&, int, int), int&> ();
+ test_result_of<PMS2V(std::unique_ptr<S>, int, int), int&> ();
+ test_no_result<PMS2V(const S&, int, int)>();
+ test_no_result<PMS2V(const volatile S&, int, int)>();
+
+ typedef int (S::*PMS0CV)() const volatile;
+ typedef int* (S::*PMS1CV)(long) const volatile;
+ typedef int& (S::*PMS2CV)(long, int) const volatile;
+ test_result_of<PMS0CV( S), int> ();
+ test_result_of<PMS0CV( S&), int> ();
+ test_result_of<PMS0CV(const S&), int> ();
+ test_result_of<PMS0CV(volatile S&), int> ();
+ test_result_of<PMS0CV(const volatile S&), int> ();
+ test_result_of<PMS0CV( S*), int> ();
+ test_result_of<PMS0CV(const S*), int> ();
+ test_result_of<PMS0CV(volatile S*), int> ();
+ test_result_of<PMS0CV(const volatile S*), int> ();
+ test_result_of<PMS0CV( S*&), int> ();
+ test_result_of<PMS0CV(const S*&), int> ();
+ test_result_of<PMS0CV(volatile S*&), int> ();
+ test_result_of<PMS0CV(const volatile S*&), int> ();
+ test_result_of<PMS0CV(std::unique_ptr<S>), int> ();
+
+ test_result_of<PMS1CV( S, int), int*> ();
+ test_result_of<PMS1CV( S&, int), int*> ();
+ test_result_of<PMS1CV(const S&, int), int*> ();
+ test_result_of<PMS1CV(volatile S&, int), int*> ();
+ test_result_of<PMS1CV(const volatile S&, int), int*> ();
+ test_result_of<PMS1CV( S*, int), int*> ();
+ test_result_of<PMS1CV(const S*, int), int*> ();
+ test_result_of<PMS1CV(volatile S*, int), int*> ();
+ test_result_of<PMS1CV(const volatile S*, int), int*> ();
+ test_result_of<PMS1CV( S*&, int), int*> ();
+ test_result_of<PMS1CV(const S*&, int), int*> ();
+ test_result_of<PMS1CV(volatile S*&, int), int*> ();
+ test_result_of<PMS1CV(const volatile S*&, int), int*> ();
+ test_result_of<PMS1CV(std::unique_ptr<S>, int), int*> ();
+
+ test_result_of<PMS2CV( S, int, int), int&> ();
+ test_result_of<PMS2CV( S&, int, int), int&> ();
+ test_result_of<PMS2CV(const S&, int, int), int&> ();
+ test_result_of<PMS2CV(volatile S&, int, int), int&> ();
+ test_result_of<PMS2CV(const volatile S&, int, int), int&> ();
+ test_result_of<PMS2CV( S*, int, int), int&> ();
+ test_result_of<PMS2CV(const S*, int, int), int&> ();
+ test_result_of<PMS2CV(volatile S*, int, int), int&> ();
+ test_result_of<PMS2CV(const volatile S*, int, int), int&> ();
+ test_result_of<PMS2CV( S*&, int, int), int&> ();
+ test_result_of<PMS2CV(const S*&, int, int), int&> ();
+ test_result_of<PMS2CV(volatile S*&, int, int), int&> ();
+ test_result_of<PMS2CV(const volatile S*&, int, int), int&> ();
+ test_result_of<PMS2CV(std::unique_ptr<S>, int, int), int&> ();
+ }
+ { // pointer to member data
+ typedef char S::*PMD;
+ test_result_of<PMD(S&), char &>();
+ test_result_of<PMD(S*), char &>();
+ test_result_of<PMD(S* const), char &>();
+ test_result_of<PMD(const S&), const char&> ();
+ test_result_of<PMD(const S*), const char&> ();
+ test_result_of<PMD(volatile S&), volatile char&> ();
+ test_result_of<PMD(volatile S*), volatile char&> ();
+ test_result_of<PMD(const volatile S&), const volatile char&> ();
+ test_result_of<PMD(const volatile S*), const volatile char&> ();
+ }
+}
diff --git a/test/std/utilities/meta/meta.trans/meta.trans.other/result_of11.pass.cpp b/test/std/utilities/meta/meta.trans/meta.trans.other/result_of11.pass.cpp
new file mode 100644
index 000000000000..6996cddc08b9
--- /dev/null
+++ b/test/std/utilities/meta/meta.trans/meta.trans.other/result_of11.pass.cpp
@@ -0,0 +1,88 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: c++98, c++03
+//
+// <functional>
+//
+// result_of<Fn(ArgTypes...)>
+
+#include <type_traits>
+#include "test_macros.h"
+
+struct wat
+{
+ wat& operator*() { return *this; }
+ void foo();
+};
+
+struct F {};
+
+template <class T, class U>
+void test_result_of_imp()
+{
+ static_assert((std::is_same<typename std::result_of<T>::type, U>::value), "");
+#if TEST_STD_VER > 11
+ static_assert((std::is_same<std::result_of_t<T>, U>::value), "");
+#endif
+}
+
+int main()
+{
+ {
+ typedef char F::*PMD;
+ test_result_of_imp<PMD(F &), char &>();
+ test_result_of_imp<PMD(F const &), char const &>();
+ test_result_of_imp<PMD(F volatile &), char volatile &>();
+ test_result_of_imp<PMD(F const volatile &), char const volatile &>();
+
+ test_result_of_imp<PMD(F &&), char &&>();
+ test_result_of_imp<PMD(F const &&), char const &&>();
+ test_result_of_imp<PMD(F volatile &&), char volatile &&>();
+ test_result_of_imp<PMD(F const volatile &&), char const volatile &&>();
+
+ test_result_of_imp<PMD(F ), char &&>();
+ test_result_of_imp<PMD(F const ), char &&>();
+ test_result_of_imp<PMD(F volatile ), char &&>();
+ test_result_of_imp<PMD(F const volatile ), char &&>();
+ }
+ {
+ test_result_of_imp<int (F::* (F &)) () &, int> ();
+ test_result_of_imp<int (F::* (F &)) () const &, int> ();
+ test_result_of_imp<int (F::* (F &)) () volatile &, int> ();
+ test_result_of_imp<int (F::* (F &)) () const volatile &, int> ();
+ test_result_of_imp<int (F::* (F const &)) () const &, int> ();
+ test_result_of_imp<int (F::* (F const &)) () const volatile &, int> ();
+ test_result_of_imp<int (F::* (F volatile &)) () volatile &, int> ();
+ test_result_of_imp<int (F::* (F volatile &)) () const volatile &, int> ();
+ test_result_of_imp<int (F::* (F const volatile &)) () const volatile &, int> ();
+
+ test_result_of_imp<int (F::* (F &&)) () &&, int> ();
+ test_result_of_imp<int (F::* (F &&)) () const &&, int> ();
+ test_result_of_imp<int (F::* (F &&)) () volatile &&, int> ();
+ test_result_of_imp<int (F::* (F &&)) () const volatile &&, int> ();
+ test_result_of_imp<int (F::* (F const &&)) () const &&, int> ();
+ test_result_of_imp<int (F::* (F const &&)) () const volatile &&, int> ();
+ test_result_of_imp<int (F::* (F volatile &&)) () volatile &&, int> ();
+ test_result_of_imp<int (F::* (F volatile &&)) () const volatile &&, int> ();
+ test_result_of_imp<int (F::* (F const volatile &&)) () const volatile &&, int> ();
+
+ test_result_of_imp<int (F::* (F )) () &&, int> ();
+ test_result_of_imp<int (F::* (F )) () const &&, int> ();
+ test_result_of_imp<int (F::* (F )) () volatile &&, int> ();
+ test_result_of_imp<int (F::* (F )) () const volatile &&, int> ();
+ test_result_of_imp<int (F::* (F const )) () const &&, int> ();
+ test_result_of_imp<int (F::* (F const )) () const volatile &&, int> ();
+ test_result_of_imp<int (F::* (F volatile )) () volatile &&, int> ();
+ test_result_of_imp<int (F::* (F volatile )) () const volatile &&, int> ();
+ test_result_of_imp<int (F::* (F const volatile )) () const volatile &&, int> ();
+ }
+
+ test_result_of_imp<decltype(&wat::foo)(wat), void>();
+}
diff --git a/test/std/utilities/meta/meta.trans/meta.trans.other/underlying_type.pass.cpp b/test/std/utilities/meta/meta.trans/meta.trans.other/underlying_type.pass.cpp
new file mode 100644
index 000000000000..728062b70684
--- /dev/null
+++ b/test/std/utilities/meta/meta.trans/meta.trans.other/underlying_type.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// underlying_type
+
+#include <type_traits>
+#include <climits>
+
+enum E { V = INT_MIN };
+enum F { W = UINT_MAX };
+
+int main()
+{
+ static_assert((std::is_same<std::underlying_type<E>::type, int>::value),
+ "E has the wrong underlying type");
+ static_assert((std::is_same<std::underlying_type<F>::type, unsigned>::value),
+ "F has the wrong underlying type");
+
+#if _LIBCPP_STD_VER > 11
+ static_assert((std::is_same<std::underlying_type_t<E>, int>::value), "");
+ static_assert((std::is_same<std::underlying_type_t<F>, unsigned>::value), "");
+#endif
+
+#if __has_feature(cxx_strong_enums)
+ enum G : char { };
+
+ static_assert((std::is_same<std::underlying_type<G>::type, char>::value),
+ "G has the wrong underlying type");
+#if _LIBCPP_STD_VER > 11
+ static_assert((std::is_same<std::underlying_type_t<G>, char>::value), "");
+#endif
+#endif // __has_feature(cxx_strong_enums)
+}
diff --git a/test/std/utilities/meta/meta.trans/meta.trans.ptr/add_pointer.pass.cpp b/test/std/utilities/meta/meta.trans/meta.trans.ptr/add_pointer.pass.cpp
new file mode 100644
index 000000000000..76d0f12d03fb
--- /dev/null
+++ b/test/std/utilities/meta/meta.trans/meta.trans.ptr/add_pointer.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// add_pointer
+
+#include <type_traits>
+
+template <class T, class U>
+void test_add_pointer()
+{
+ static_assert((std::is_same<typename std::add_pointer<T>::type, U>::value), "");
+#if _LIBCPP_STD_VER > 11
+ static_assert((std::is_same<std::add_pointer_t<T>, U>::value), "");
+#endif
+}
+
+int main()
+{
+ test_add_pointer<void, void*>();
+ test_add_pointer<int, int*>();
+ test_add_pointer<int[3], int(*)[3]>();
+ test_add_pointer<int&, int*>();
+ test_add_pointer<const int&, const int*>();
+ test_add_pointer<int*, int**>();
+ test_add_pointer<const int*, const int**>();
+}
diff --git a/test/std/utilities/meta/meta.trans/meta.trans.ptr/remove_pointer.pass.cpp b/test/std/utilities/meta/meta.trans/meta.trans.ptr/remove_pointer.pass.cpp
new file mode 100644
index 000000000000..9cecd39049fc
--- /dev/null
+++ b/test/std/utilities/meta/meta.trans/meta.trans.ptr/remove_pointer.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// remove_pointer
+
+#include <type_traits>
+
+template <class T, class U>
+void test_remove_pointer()
+{
+ static_assert((std::is_same<typename std::remove_pointer<T>::type, U>::value), "");
+#if _LIBCPP_STD_VER > 11
+ static_assert((std::is_same<std::remove_pointer_t<T>, U>::value), "");
+#endif
+}
+
+int main()
+{
+ test_remove_pointer<void, void>();
+ test_remove_pointer<int, int>();
+ test_remove_pointer<int[3], int[3]>();
+ test_remove_pointer<int*, int>();
+ test_remove_pointer<const int*, const int>();
+ test_remove_pointer<int**, int*>();
+ test_remove_pointer<int** const, int*>();
+ test_remove_pointer<int*const * , int* const>();
+ test_remove_pointer<const int** , const int*>();
+
+ test_remove_pointer<int&, int&>();
+ test_remove_pointer<const int&, const int&>();
+ test_remove_pointer<int(&)[3], int(&)[3]>();
+ test_remove_pointer<int(*)[3], int[3]>();
+ test_remove_pointer<int*&, int*&>();
+ test_remove_pointer<const int*&, const int*&>();
+}
diff --git a/test/std/utilities/meta/meta.trans/meta.trans.ref/add_lvalue_ref.pass.cpp b/test/std/utilities/meta/meta.trans/meta.trans.ref/add_lvalue_ref.pass.cpp
new file mode 100644
index 000000000000..8150ce04e37f
--- /dev/null
+++ b/test/std/utilities/meta/meta.trans/meta.trans.ref/add_lvalue_ref.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// add_lvalue_reference
+
+#include <type_traits>
+
+template <class T, class U>
+void test_add_lvalue_reference()
+{
+ static_assert((std::is_same<typename std::add_lvalue_reference<T>::type, U>::value), "");
+#if _LIBCPP_STD_VER > 11
+ static_assert((std::is_same<std::add_lvalue_reference_t<T>, U>::value), "");
+#endif
+}
+
+int main()
+{
+ test_add_lvalue_reference<void, void>();
+ test_add_lvalue_reference<int, int&>();
+ test_add_lvalue_reference<int[3], int(&)[3]>();
+ test_add_lvalue_reference<int&, int&>();
+ test_add_lvalue_reference<const int&, const int&>();
+ test_add_lvalue_reference<int*, int*&>();
+ test_add_lvalue_reference<const int*, const int*&>();
+}
diff --git a/test/std/utilities/meta/meta.trans/meta.trans.ref/add_rvalue_ref.pass.cpp b/test/std/utilities/meta/meta.trans/meta.trans.ref/add_rvalue_ref.pass.cpp
new file mode 100644
index 000000000000..e8f08fdc398a
--- /dev/null
+++ b/test/std/utilities/meta/meta.trans/meta.trans.ref/add_rvalue_ref.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// add_rvalue_reference
+
+#include <type_traits>
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class T, class U>
+void test_add_rvalue_reference()
+{
+ static_assert((std::is_same<typename std::add_rvalue_reference<T>::type, U>::value), "");
+#if _LIBCPP_STD_VER > 11
+ static_assert((std::is_same<std::add_rvalue_reference_t<T>, U>::value), "");
+#endif
+}
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ test_add_rvalue_reference<void, void>();
+ test_add_rvalue_reference<int, int&&>();
+ test_add_rvalue_reference<int[3], int(&&)[3]>();
+ test_add_rvalue_reference<int&, int&>();
+ test_add_rvalue_reference<const int&, const int&>();
+ test_add_rvalue_reference<int*, int*&&>();
+ test_add_rvalue_reference<const int*, const int*&&>();
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/utilities/meta/meta.trans/meta.trans.ref/remove_ref.pass.cpp b/test/std/utilities/meta/meta.trans/meta.trans.ref/remove_ref.pass.cpp
new file mode 100644
index 000000000000..f9ebc37a5dd2
--- /dev/null
+++ b/test/std/utilities/meta/meta.trans/meta.trans.ref/remove_ref.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// remove_reference
+
+#include <type_traits>
+
+template <class T, class U>
+void test_remove_reference()
+{
+ static_assert((std::is_same<typename std::remove_reference<T>::type, U>::value), "");
+#if _LIBCPP_STD_VER > 11
+ static_assert((std::is_same<std::remove_reference_t<T>, U>::value), "");
+#endif
+}
+
+int main()
+{
+ test_remove_reference<void, void>();
+ test_remove_reference<int, int>();
+ test_remove_reference<int[3], int[3]>();
+ test_remove_reference<int*, int*>();
+ test_remove_reference<const int*, const int*>();
+
+ test_remove_reference<int&, int>();
+ test_remove_reference<const int&, const int>();
+ test_remove_reference<int(&)[3], int[3]>();
+ test_remove_reference<int*&, int*>();
+ test_remove_reference<const int*&, const int*>();
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ test_remove_reference<int&&, int>();
+ test_remove_reference<const int&&, const int>();
+ test_remove_reference<int(&&)[3], int[3]>();
+ test_remove_reference<int*&&, int*>();
+ test_remove_reference<const int*&&, const int*>();
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/utilities/meta/meta.trans/meta.trans.sign/make_signed.pass.cpp b/test/std/utilities/meta/meta.trans/meta.trans.sign/make_signed.pass.cpp
new file mode 100644
index 000000000000..eb8e31c76e10
--- /dev/null
+++ b/test/std/utilities/meta/meta.trans/meta.trans.sign/make_signed.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// make_signed
+
+#include <type_traits>
+
+enum Enum {zero, one_};
+
+enum BigEnum
+{
+ bigzero,
+ big = 0xFFFFFFFFFFFFFFFFULL
+};
+
+#if !defined(_LIBCPP_HAS_NO_INT128) && !defined(_LIBCPP_HAS_NO_STRONG_ENUMS)
+enum HugeEnum : __uint128_t
+{
+ hugezero
+};
+#endif
+
+template <class T, class U>
+void test_make_signed()
+{
+ static_assert((std::is_same<typename std::make_signed<T>::type, U>::value), "");
+#if _LIBCPP_STD_VER > 11
+ static_assert((std::is_same<std::make_signed_t<T>, U>::value), "");
+#endif
+}
+
+int main()
+{
+ test_make_signed< signed char, signed char >();
+ test_make_signed< unsigned char, signed char >();
+ test_make_signed< char, signed char >();
+ test_make_signed< short, signed short >();
+ test_make_signed< unsigned short, signed short >();
+ test_make_signed< int, signed int >();
+ test_make_signed< unsigned int, signed int >();
+ test_make_signed< long, signed long >();
+ test_make_signed< unsigned long, long >();
+ test_make_signed< long long, signed long long >();
+ test_make_signed< unsigned long long, signed long long >();
+ test_make_signed< wchar_t, std::conditional<sizeof(wchar_t) == 4, int, short>::type >();
+ test_make_signed< const wchar_t, std::conditional<sizeof(wchar_t) == 4, const int, const short>::type >();
+ test_make_signed< const Enum, std::conditional<sizeof(Enum) == sizeof(int), const int, const signed char>::type >();
+ test_make_signed< BigEnum, std::conditional<sizeof(long) == 4, long long, long>::type >();
+#ifndef _LIBCPP_HAS_NO_INT128
+ test_make_signed< __int128_t, __int128_t >();
+ test_make_signed< __uint128_t, __int128_t >();
+# ifndef _LIBCPP_HAS_NO_STRONG_ENUMS
+ test_make_signed< HugeEnum, __int128_t >();
+# endif
+#endif
+}
diff --git a/test/std/utilities/meta/meta.trans/meta.trans.sign/make_unsigned.pass.cpp b/test/std/utilities/meta/meta.trans/meta.trans.sign/make_unsigned.pass.cpp
new file mode 100644
index 000000000000..984440193fa6
--- /dev/null
+++ b/test/std/utilities/meta/meta.trans/meta.trans.sign/make_unsigned.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// make_unsigned
+
+#include <type_traits>
+
+enum Enum {zero, one_};
+
+enum BigEnum
+{
+ bigzero,
+ big = 0xFFFFFFFFFFFFFFFFULL
+};
+
+#if !defined(_LIBCPP_HAS_NO_INT128) && !defined(_LIBCPP_HAS_NO_STRONG_ENUMS)
+enum HugeEnum : __int128_t
+{
+ hugezero
+};
+#endif
+
+template <class T, class U>
+void test_make_unsigned()
+{
+ static_assert((std::is_same<typename std::make_unsigned<T>::type, U>::value), "");
+#if _LIBCPP_STD_VER > 11
+ static_assert((std::is_same<std::make_unsigned_t<T>, U>::value), "");
+#endif
+}
+
+int main()
+{
+ test_make_unsigned<signed char, unsigned char> ();
+ test_make_unsigned<unsigned char, unsigned char> ();
+ test_make_unsigned<char, unsigned char> ();
+ test_make_unsigned<short, unsigned short> ();
+ test_make_unsigned<unsigned short, unsigned short> ();
+ test_make_unsigned<int, unsigned int> ();
+ test_make_unsigned<unsigned int, unsigned int> ();
+ test_make_unsigned<long, unsigned long> ();
+ test_make_unsigned<unsigned long, unsigned long> ();
+ test_make_unsigned<long long, unsigned long long> ();
+ test_make_unsigned<unsigned long long, unsigned long long> ();
+ test_make_unsigned<wchar_t, std::conditional<sizeof(wchar_t) == 4, unsigned int, unsigned short>::type> ();
+ test_make_unsigned<const wchar_t, std::conditional<sizeof(wchar_t) == 4, const unsigned int, const unsigned short>::type> ();
+ test_make_unsigned<const Enum, std::conditional<sizeof(Enum) == sizeof(int), const unsigned int, const unsigned char>::type >();
+ test_make_unsigned<BigEnum,
+ std::conditional<sizeof(long) == 4, unsigned long long, unsigned long>::type> ();
+#ifndef _LIBCPP_HAS_NO_INT128
+ test_make_unsigned<__int128_t, __uint128_t>();
+ test_make_unsigned<__uint128_t, __uint128_t>();
+# ifndef _LIBCPP_HAS_NO_STRONG_ENUMS
+ test_make_unsigned<HugeEnum, __uint128_t>();
+# endif
+#endif
+}
diff --git a/test/std/utilities/meta/meta.trans/nothing_to_do.pass.cpp b/test/std/utilities/meta/meta.trans/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/utilities/meta/meta.trans/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/utilities/meta/meta.type.synop/nothing_to_do.pass.cpp b/test/std/utilities/meta/meta.type.synop/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/utilities/meta/meta.type.synop/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/utilities/meta/meta.unary.prop.query/alignment_of.pass.cpp b/test/std/utilities/meta/meta.unary.prop.query/alignment_of.pass.cpp
new file mode 100644
index 000000000000..6ea1cac789ef
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary.prop.query/alignment_of.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// alignment_of
+
+#include <type_traits>
+#include <cstdint>
+
+template <class T, unsigned A>
+void test_alignment_of()
+{
+ static_assert( std::alignment_of<T>::value == A, "");
+ static_assert( std::alignment_of<const T>::value == A, "");
+ static_assert( std::alignment_of<volatile T>::value == A, "");
+ static_assert( std::alignment_of<const volatile T>::value == A, "");
+}
+
+class Class
+{
+public:
+ ~Class();
+};
+
+int main()
+{
+ test_alignment_of<int&, 4>();
+ test_alignment_of<Class, 1>();
+ test_alignment_of<int*, sizeof(intptr_t)>();
+ test_alignment_of<const int*, sizeof(intptr_t)>();
+ test_alignment_of<char[3], 1>();
+ test_alignment_of<int, 4>();
+ test_alignment_of<double, 8>();
+#if (defined(__ppc__) && !defined(__ppc64__))
+ test_alignment_of<bool, 4>(); // 32-bit PPC has four byte bool
+#else
+ test_alignment_of<bool, 1>();
+#endif
+ test_alignment_of<unsigned, 4>();
+}
diff --git a/test/std/utilities/meta/meta.unary.prop.query/extent.pass.cpp b/test/std/utilities/meta/meta.unary.prop.query/extent.pass.cpp
new file mode 100644
index 000000000000..a99dc6948529
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary.prop.query/extent.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// extent
+
+#include <type_traits>
+
+template <class T, unsigned A>
+void test_extent()
+{
+ static_assert((std::extent<T>::value == A), "");
+ static_assert((std::extent<const T>::value == A), "");
+ static_assert((std::extent<volatile T>::value == A), "");
+ static_assert((std::extent<const volatile T>::value == A), "");
+}
+
+template <class T, unsigned A>
+void test_extent1()
+{
+ static_assert((std::extent<T, 1>::value == A), "");
+ static_assert((std::extent<const T, 1>::value == A), "");
+ static_assert((std::extent<volatile T, 1>::value == A), "");
+ static_assert((std::extent<const volatile T, 1>::value == A), "");
+}
+
+class Class
+{
+public:
+ ~Class();
+};
+
+int main()
+{
+ test_extent<void, 0>();
+ test_extent<int&, 0>();
+ test_extent<Class, 0>();
+ test_extent<int*, 0>();
+ test_extent<const int*, 0>();
+ test_extent<int, 0>();
+ test_extent<double, 0>();
+ test_extent<bool, 0>();
+ test_extent<unsigned, 0>();
+
+ test_extent<int[2], 2>();
+ test_extent<int[2][4], 2>();
+ test_extent<int[][4], 0>();
+
+ test_extent1<int, 0>();
+ test_extent1<int[2], 0>();
+ test_extent1<int[2][4], 4>();
+ test_extent1<int[][4], 4>();
+}
diff --git a/test/std/utilities/meta/meta.unary.prop.query/rank.pass.cpp b/test/std/utilities/meta/meta.unary.prop.query/rank.pass.cpp
new file mode 100644
index 000000000000..06f66a92c7c3
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary.prop.query/rank.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// rank
+
+#include <type_traits>
+
+template <class T, unsigned A>
+void test_rank()
+{
+ static_assert( std::rank<T>::value == A, "");
+ static_assert( std::rank<const T>::value == A, "");
+ static_assert( std::rank<volatile T>::value == A, "");
+ static_assert( std::rank<const volatile T>::value == A, "");
+}
+
+class Class
+{
+public:
+ ~Class();
+};
+
+int main()
+{
+ test_rank<void, 0>();
+ test_rank<int&, 0>();
+ test_rank<Class, 0>();
+ test_rank<int*, 0>();
+ test_rank<const int*, 0>();
+ test_rank<int, 0>();
+ test_rank<double, 0>();
+ test_rank<bool, 0>();
+ test_rank<unsigned, 0>();
+
+ test_rank<char[3], 1>();
+ test_rank<char[][3], 2>();
+ test_rank<char[][4][3], 3>();
+}
diff --git a/test/std/utilities/meta/meta.unary.prop.query/void_t.pass.cpp b/test/std/utilities/meta/meta.unary.prop.query/void_t.pass.cpp
new file mode 100644
index 000000000000..5deeeff110d4
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary.prop.query/void_t.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// void_t
+
+#include <type_traits>
+
+#if _LIBCPP_STD_VER <= 14
+int main () {}
+#else
+
+template <class T>
+void test1()
+{
+ static_assert( std::is_same<void, std::void_t<T>>::value, "");
+ static_assert( std::is_same<void, std::void_t<const T>>::value, "");
+ static_assert( std::is_same<void, std::void_t<volatile T>>::value, "");
+ static_assert( std::is_same<void, std::void_t<const volatile T>>::value, "");
+}
+
+template <class T, class U>
+void test2()
+{
+ static_assert( std::is_same<void, std::void_t<T, U>>::value, "");
+ static_assert( std::is_same<void, std::void_t<const T, U>>::value, "");
+ static_assert( std::is_same<void, std::void_t<volatile T, U>>::value, "");
+ static_assert( std::is_same<void, std::void_t<const volatile T, U>>::value, "");
+
+ static_assert( std::is_same<void, std::void_t<T, const U>>::value, "");
+ static_assert( std::is_same<void, std::void_t<const T, const U>>::value, "");
+ static_assert( std::is_same<void, std::void_t<volatile T, const U>>::value, "");
+ static_assert( std::is_same<void, std::void_t<const volatile T, const U>>::value, "");
+}
+
+class Class
+{
+public:
+ ~Class();
+};
+
+int main()
+{
+ static_assert( std::is_same<void, std::void_t<>>::value, "");
+
+ test1<void>();
+ test1<int>();
+ test1<double>();
+ test1<int&>();
+ test1<Class>();
+ test1<Class[]>();
+ test1<Class[5]>();
+
+ test2<void, int>();
+ test2<double, int>();
+ test2<int&, int>();
+ test2<Class&, bool>();
+ test2<void *, int&>();
+
+ static_assert( std::is_same<void, std::void_t<int, double const &, Class, volatile int[], void>>::value, "");
+}
+#endif
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.cat/array.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.cat/array.pass.cpp
new file mode 100644
index 000000000000..f4dd356383af
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.cat/array.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// array
+
+#include <type_traits>
+
+template <class T>
+void test_array_imp()
+{
+ static_assert(!std::is_void<T>::value, "");
+#if _LIBCPP_STD_VER > 11
+ static_assert(!std::is_null_pointer<T>::value, "");
+#endif
+ static_assert(!std::is_integral<T>::value, "");
+ static_assert(!std::is_floating_point<T>::value, "");
+ static_assert( std::is_array<T>::value, "");
+ static_assert(!std::is_pointer<T>::value, "");
+ static_assert(!std::is_lvalue_reference<T>::value, "");
+ static_assert(!std::is_rvalue_reference<T>::value, "");
+ static_assert(!std::is_member_object_pointer<T>::value, "");
+ static_assert(!std::is_member_function_pointer<T>::value, "");
+ static_assert(!std::is_enum<T>::value, "");
+ static_assert(!std::is_union<T>::value, "");
+ static_assert(!std::is_class<T>::value, "");
+ static_assert(!std::is_function<T>::value, "");
+}
+
+template <class T>
+void test_array()
+{
+ test_array_imp<T>();
+ test_array_imp<const T>();
+ test_array_imp<volatile T>();
+ test_array_imp<const volatile T>();
+}
+
+typedef char array[3];
+typedef const char const_array[3];
+typedef char incomplete_array[];
+
+int main()
+{
+ test_array<array>();
+ test_array<const_array>();
+ test_array<incomplete_array>();
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.cat/class.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.cat/class.pass.cpp
new file mode 100644
index 000000000000..ac5d6e592311
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.cat/class.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// class
+
+#include <type_traits>
+
+template <class T>
+void test_class_imp()
+{
+ static_assert(!std::is_void<T>::value, "");
+#if _LIBCPP_STD_VER > 11
+ static_assert(!std::is_null_pointer<T>::value, "");
+#endif
+ static_assert(!std::is_integral<T>::value, "");
+ static_assert(!std::is_floating_point<T>::value, "");
+ static_assert(!std::is_array<T>::value, "");
+ static_assert(!std::is_pointer<T>::value, "");
+ static_assert(!std::is_lvalue_reference<T>::value, "");
+ static_assert(!std::is_rvalue_reference<T>::value, "");
+ static_assert(!std::is_member_object_pointer<T>::value, "");
+ static_assert(!std::is_member_function_pointer<T>::value, "");
+ static_assert(!std::is_enum<T>::value, "");
+ static_assert(!std::is_union<T>::value, "");
+ static_assert( std::is_class<T>::value, "");
+ static_assert(!std::is_function<T>::value, "");
+}
+
+template <class T>
+void test_class()
+{
+ test_class_imp<T>();
+ test_class_imp<const T>();
+ test_class_imp<volatile T>();
+ test_class_imp<const volatile T>();
+}
+
+class Class
+{
+};
+
+int main()
+{
+ test_class<Class>();
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.cat/enum.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.cat/enum.pass.cpp
new file mode 100644
index 000000000000..7c9c78fcf2b9
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.cat/enum.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// enum
+
+#include <type_traits>
+
+template <class T>
+void test_enum_imp()
+{
+ static_assert(!std::is_void<T>::value, "");
+#if _LIBCPP_STD_VER > 11
+ static_assert(!std::is_null_pointer<T>::value, "");
+#endif
+ static_assert(!std::is_integral<T>::value, "");
+ static_assert(!std::is_floating_point<T>::value, "");
+ static_assert(!std::is_array<T>::value, "");
+ static_assert(!std::is_pointer<T>::value, "");
+ static_assert(!std::is_lvalue_reference<T>::value, "");
+ static_assert(!std::is_rvalue_reference<T>::value, "");
+ static_assert(!std::is_member_object_pointer<T>::value, "");
+ static_assert(!std::is_member_function_pointer<T>::value, "");
+ static_assert( std::is_enum<T>::value, "");
+ static_assert(!std::is_union<T>::value, "");
+ static_assert(!std::is_class<T>::value, "");
+ static_assert(!std::is_function<T>::value, "");
+}
+
+template <class T>
+void test_enum()
+{
+ test_enum_imp<T>();
+ test_enum_imp<const T>();
+ test_enum_imp<volatile T>();
+ test_enum_imp<const volatile T>();
+}
+
+enum Enum {zero, one};
+
+int main()
+{
+ test_enum<Enum>();
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.cat/floating_point.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.cat/floating_point.pass.cpp
new file mode 100644
index 000000000000..286644960315
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.cat/floating_point.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// floating_point
+
+#include <type_traits>
+
+template <class T>
+void test_floating_point_imp()
+{
+ static_assert(!std::is_void<T>::value, "");
+#if _LIBCPP_STD_VER > 11
+ static_assert(!std::is_null_pointer<T>::value, "");
+#endif
+ static_assert(!std::is_integral<T>::value, "");
+ static_assert( std::is_floating_point<T>::value, "");
+ static_assert(!std::is_array<T>::value, "");
+ static_assert(!std::is_pointer<T>::value, "");
+ static_assert(!std::is_lvalue_reference<T>::value, "");
+ static_assert(!std::is_rvalue_reference<T>::value, "");
+ static_assert(!std::is_member_object_pointer<T>::value, "");
+ static_assert(!std::is_member_function_pointer<T>::value, "");
+ static_assert(!std::is_enum<T>::value, "");
+ static_assert(!std::is_union<T>::value, "");
+ static_assert(!std::is_class<T>::value, "");
+ static_assert(!std::is_function<T>::value, "");
+}
+
+template <class T>
+void test_floating_point()
+{
+ test_floating_point_imp<T>();
+ test_floating_point_imp<const T>();
+ test_floating_point_imp<volatile T>();
+ test_floating_point_imp<const volatile T>();
+}
+
+int main()
+{
+ test_floating_point<float>();
+ test_floating_point<double>();
+ test_floating_point<long double>();
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.cat/function.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.cat/function.pass.cpp
new file mode 100644
index 000000000000..b1df4f2d3f4c
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.cat/function.pass.cpp
@@ -0,0 +1,88 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// function
+
+#include <type_traits>
+
+using namespace std;
+
+class Class {};
+
+enum Enum1 {};
+#if __cplusplus >= 201103L
+enum class Enum2 : int {};
+#else
+enum Enum2 {};
+#endif
+
+template <class T>
+void test()
+{
+ static_assert(!std::is_void<T>::value, "");
+#if _LIBCPP_STD_VER > 11
+ static_assert(!std::is_null_pointer<T>::value, "");
+#endif
+ static_assert(!std::is_integral<T>::value, "");
+ static_assert(!std::is_floating_point<T>::value, "");
+ static_assert(!std::is_array<T>::value, "");
+ static_assert(!std::is_pointer<T>::value, "");
+ static_assert(!std::is_lvalue_reference<T>::value, "");
+ static_assert(!std::is_rvalue_reference<T>::value, "");
+ static_assert(!std::is_member_object_pointer<T>::value, "");
+ static_assert(!std::is_member_function_pointer<T>::value, "");
+ static_assert(!std::is_enum<T>::value, "");
+ static_assert(!std::is_union<T>::value, "");
+ static_assert(!std::is_class<T>::value, "");
+ static_assert( std::is_function<T>::value, "");
+}
+
+// Since we can't actually add the const volatile and ref qualifiers once
+// later let's use a macro to do it.
+#define TEST_REGULAR(...) \
+ test<__VA_ARGS__>(); \
+ test<__VA_ARGS__ const>(); \
+ test<__VA_ARGS__ volatile>(); \
+ test<__VA_ARGS__ const volatile>()
+
+
+#define TEST_REF_QUALIFIED(...) \
+ test<__VA_ARGS__ &>(); \
+ test<__VA_ARGS__ const &>(); \
+ test<__VA_ARGS__ volatile &>(); \
+ test<__VA_ARGS__ const volatile &>(); \
+ test<__VA_ARGS__ &&>(); \
+ test<__VA_ARGS__ const &&>(); \
+ test<__VA_ARGS__ volatile &&>(); \
+ test<__VA_ARGS__ const volatile &&>()
+
+
+int main()
+{
+ TEST_REGULAR( void () );
+ TEST_REGULAR( void (int) );
+ TEST_REGULAR( int (double) );
+ TEST_REGULAR( int (double, char) );
+ TEST_REGULAR( void (...) );
+ TEST_REGULAR( void (int, ...) );
+ TEST_REGULAR( int (double, ...) );
+ TEST_REGULAR( int (double, char, ...) );
+#if __cplusplus >= 201103L
+ TEST_REF_QUALIFIED( void () );
+ TEST_REF_QUALIFIED( void (int) );
+ TEST_REF_QUALIFIED( int (double) );
+ TEST_REF_QUALIFIED( int (double, char) );
+ TEST_REF_QUALIFIED( void (...) );
+ TEST_REF_QUALIFIED( void (int, ...) );
+ TEST_REF_QUALIFIED( int (double, ...) );
+ TEST_REF_QUALIFIED( int (double, char, ...) );
+#endif
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.cat/integral.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.cat/integral.pass.cpp
new file mode 100644
index 000000000000..f68ed3ef7e57
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.cat/integral.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// integral
+
+#include <type_traits>
+
+template <class T>
+void test_integral_imp()
+{
+ static_assert(!std::is_void<T>::value, "");
+#if _LIBCPP_STD_VER > 11
+ static_assert(!std::is_null_pointer<T>::value, "");
+#endif
+ static_assert( std::is_integral<T>::value, "");
+ static_assert(!std::is_floating_point<T>::value, "");
+ static_assert(!std::is_array<T>::value, "");
+ static_assert(!std::is_pointer<T>::value, "");
+ static_assert(!std::is_lvalue_reference<T>::value, "");
+ static_assert(!std::is_rvalue_reference<T>::value, "");
+ static_assert(!std::is_member_object_pointer<T>::value, "");
+ static_assert(!std::is_member_function_pointer<T>::value, "");
+ static_assert(!std::is_enum<T>::value, "");
+ static_assert(!std::is_union<T>::value, "");
+ static_assert(!std::is_class<T>::value, "");
+ static_assert(!std::is_function<T>::value, "");
+}
+
+template <class T>
+void test_integral()
+{
+ test_integral_imp<T>();
+ test_integral_imp<const T>();
+ test_integral_imp<volatile T>();
+ test_integral_imp<const volatile T>();
+}
+
+int main()
+{
+ test_integral<bool>();
+ test_integral<char>();
+ test_integral<signed char>();
+ test_integral<unsigned char>();
+ test_integral<wchar_t>();
+ test_integral<short>();
+ test_integral<unsigned short>();
+ test_integral<int>();
+ test_integral<unsigned int>();
+ test_integral<long>();
+ test_integral<unsigned long>();
+ test_integral<long long>();
+ test_integral<unsigned long long>();
+#ifndef _LIBCPP_HAS_NO_INT128
+ test_integral<__int128_t>();
+ test_integral<__uint128_t>();
+#endif
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.cat/lvalue_ref.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.cat/lvalue_ref.pass.cpp
new file mode 100644
index 000000000000..3b6ccade7e74
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.cat/lvalue_ref.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// lvalue_ref
+
+#include <type_traits>
+
+template <class T>
+void test_lvalue_ref()
+{
+ static_assert(!std::is_void<T>::value, "");
+#if _LIBCPP_STD_VER > 11
+ static_assert(!std::is_null_pointer<T>::value, "");
+#endif
+ static_assert(!std::is_integral<T>::value, "");
+ static_assert(!std::is_floating_point<T>::value, "");
+ static_assert(!std::is_array<T>::value, "");
+ static_assert(!std::is_pointer<T>::value, "");
+ static_assert( std::is_lvalue_reference<T>::value, "");
+ static_assert(!std::is_rvalue_reference<T>::value, "");
+ static_assert(!std::is_member_object_pointer<T>::value, "");
+ static_assert(!std::is_member_function_pointer<T>::value, "");
+ static_assert(!std::is_enum<T>::value, "");
+ static_assert(!std::is_union<T>::value, "");
+ static_assert(!std::is_class<T>::value, "");
+ static_assert(!std::is_function<T>::value, "");
+}
+
+int main()
+{
+ test_lvalue_ref<int&>();
+ test_lvalue_ref<const int&>();
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.cat/member_function_pointer.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.cat/member_function_pointer.pass.cpp
new file mode 100644
index 000000000000..6f546efdf51e
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.cat/member_function_pointer.pass.cpp
@@ -0,0 +1,136 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// member_function_pointer
+
+#include <type_traits>
+#include "test_macros.h"
+
+template <class T>
+void test_member_function_pointer_imp()
+{
+ static_assert(!std::is_void<T>::value, "");
+#if TEST_STD_VER > 11
+ static_assert(!std::is_null_pointer<T>::value, "");
+#endif
+ static_assert(!std::is_integral<T>::value, "");
+ static_assert(!std::is_floating_point<T>::value, "");
+ static_assert(!std::is_array<T>::value, "");
+ static_assert(!std::is_pointer<T>::value, "");
+ static_assert(!std::is_lvalue_reference<T>::value, "");
+ static_assert(!std::is_rvalue_reference<T>::value, "");
+ static_assert(!std::is_member_object_pointer<T>::value, "");
+ static_assert( std::is_member_function_pointer<T>::value, "");
+ static_assert(!std::is_enum<T>::value, "");
+ static_assert(!std::is_union<T>::value, "");
+ static_assert(!std::is_class<T>::value, "");
+ static_assert(!std::is_function<T>::value, "");
+}
+
+template <class T>
+void test_member_function_pointer()
+{
+ test_member_function_pointer_imp<T>();
+ test_member_function_pointer_imp<const T>();
+ test_member_function_pointer_imp<volatile T>();
+ test_member_function_pointer_imp<const volatile T>();
+}
+
+class Class
+{
+};
+
+int main()
+{
+ test_member_function_pointer<void (Class::*)()>();
+ test_member_function_pointer<void (Class::*)(int)>();
+ test_member_function_pointer<void (Class::*)(int, char)>();
+
+ test_member_function_pointer<void (Class::*)() const>();
+ test_member_function_pointer<void (Class::*)(int) const>();
+ test_member_function_pointer<void (Class::*)(int, char) const>();
+
+ test_member_function_pointer<void (Class::*)() volatile>();
+ test_member_function_pointer<void (Class::*)(int) volatile>();
+ test_member_function_pointer<void (Class::*)(int, char) volatile>();
+
+ test_member_function_pointer<void (Class::*)(...)>();
+ test_member_function_pointer<void (Class::*)(int, ...)>();
+ test_member_function_pointer<void (Class::*)(int, char, ...)>();
+
+ test_member_function_pointer<void (Class::*)(...) const>();
+ test_member_function_pointer<void (Class::*)(int, ...) const>();
+ test_member_function_pointer<void (Class::*)(int, char, ...) const>();
+
+ test_member_function_pointer<void (Class::*)(...) volatile>();
+ test_member_function_pointer<void (Class::*)(int, ...) volatile>();
+ test_member_function_pointer<void (Class::*)(int, char, ...) volatile>();
+
+// reference qualifiers on functions are a C++11 extension
+#if TEST_STD_VER >= 11
+ test_member_function_pointer<void (Class::*)() &>();
+ test_member_function_pointer<void (Class::*)(int) &>();
+ test_member_function_pointer<void (Class::*)(int, char) &>();
+ test_member_function_pointer<void (Class::*)(...) &>();
+ test_member_function_pointer<void (Class::*)(int,...) &>();
+ test_member_function_pointer<void (Class::*)(int, char,...) &>();
+
+ test_member_function_pointer<void (Class::*)() const &>();
+ test_member_function_pointer<void (Class::*)(int) const &>();
+ test_member_function_pointer<void (Class::*)(int, char) const &>();
+ test_member_function_pointer<void (Class::*)(...) const &>();
+ test_member_function_pointer<void (Class::*)(int,...) const &>();
+ test_member_function_pointer<void (Class::*)(int, char,...) const &>();
+
+ test_member_function_pointer<void (Class::*)() volatile &>();
+ test_member_function_pointer<void (Class::*)(int) volatile &>();
+ test_member_function_pointer<void (Class::*)(int, char) volatile &>();
+ test_member_function_pointer<void (Class::*)(...) volatile &>();
+ test_member_function_pointer<void (Class::*)(int,...) volatile &>();
+ test_member_function_pointer<void (Class::*)(int, char,...) volatile &>();
+
+ test_member_function_pointer<void (Class::*)() const volatile &>();
+ test_member_function_pointer<void (Class::*)(int) const volatile &>();
+ test_member_function_pointer<void (Class::*)(int, char) const volatile &>();
+ test_member_function_pointer<void (Class::*)(...) const volatile &>();
+ test_member_function_pointer<void (Class::*)(int,...) const volatile &>();
+ test_member_function_pointer<void (Class::*)(int, char,...) const volatile &>();
+
+ // RValue qualifiers
+ test_member_function_pointer<void (Class::*)() &&>();
+ test_member_function_pointer<void (Class::*)(int) &&>();
+ test_member_function_pointer<void (Class::*)(int, char) &&>();
+ test_member_function_pointer<void (Class::*)(...) &&>();
+ test_member_function_pointer<void (Class::*)(int,...) &&>();
+ test_member_function_pointer<void (Class::*)(int, char,...) &&>();
+
+ test_member_function_pointer<void (Class::*)() const &&>();
+ test_member_function_pointer<void (Class::*)(int) const &&>();
+ test_member_function_pointer<void (Class::*)(int, char) const &&>();
+ test_member_function_pointer<void (Class::*)(...) const &&>();
+ test_member_function_pointer<void (Class::*)(int,...) const &&>();
+ test_member_function_pointer<void (Class::*)(int, char,...) const &&>();
+
+ test_member_function_pointer<void (Class::*)() volatile &&>();
+ test_member_function_pointer<void (Class::*)(int) volatile &&>();
+ test_member_function_pointer<void (Class::*)(int, char) volatile &&>();
+ test_member_function_pointer<void (Class::*)(...) volatile &&>();
+ test_member_function_pointer<void (Class::*)(int,...) volatile &&>();
+ test_member_function_pointer<void (Class::*)(int, char,...) volatile &&>();
+
+ test_member_function_pointer<void (Class::*)() const volatile &&>();
+ test_member_function_pointer<void (Class::*)(int) const volatile &&>();
+ test_member_function_pointer<void (Class::*)(int, char) const volatile &&>();
+ test_member_function_pointer<void (Class::*)(...) const volatile &&>();
+ test_member_function_pointer<void (Class::*)(int,...) const volatile &&>();
+ test_member_function_pointer<void (Class::*)(int, char,...) const volatile &&>();
+#endif
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.cat/member_function_pointer_no_variadics.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.cat/member_function_pointer_no_variadics.pass.cpp
new file mode 100644
index 000000000000..e13e58632a32
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.cat/member_function_pointer_no_variadics.pass.cpp
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// member_function_pointer
+
+#define _LIBCPP_HAS_NO_VARIADICS
+#include <type_traits>
+
+template <class T>
+void test_member_function_pointer_imp()
+{
+ static_assert(!std::is_void<T>::value, "");
+#if _LIBCPP_STD_VER > 11
+ static_assert(!std::is_null_pointer<T>::value, "");
+#endif
+ static_assert(!std::is_integral<T>::value, "");
+ static_assert(!std::is_floating_point<T>::value, "");
+ static_assert(!std::is_array<T>::value, "");
+ static_assert(!std::is_pointer<T>::value, "");
+ static_assert(!std::is_lvalue_reference<T>::value, "");
+ static_assert(!std::is_rvalue_reference<T>::value, "");
+ static_assert(!std::is_member_object_pointer<T>::value, "");
+ static_assert( std::is_member_function_pointer<T>::value, "");
+ static_assert(!std::is_enum<T>::value, "");
+ static_assert(!std::is_union<T>::value, "");
+ static_assert(!std::is_class<T>::value, "");
+ static_assert(!std::is_function<T>::value, "");
+}
+
+template <class T>
+void test_member_function_pointer()
+{
+ test_member_function_pointer_imp<T>();
+ test_member_function_pointer_imp<const T>();
+ test_member_function_pointer_imp<volatile T>();
+ test_member_function_pointer_imp<const volatile T>();
+}
+
+class Class
+{
+};
+
+int main()
+{
+ test_member_function_pointer<void (Class::*)()>();
+ test_member_function_pointer<void (Class::*)(int)>();
+ test_member_function_pointer<void (Class::*)(int, char)>();
+
+ test_member_function_pointer<void (Class::*)() const>();
+ test_member_function_pointer<void (Class::*)(int) const>();
+ test_member_function_pointer<void (Class::*)(int, char) const>();
+
+ test_member_function_pointer<void (Class::*)() volatile>();
+ test_member_function_pointer<void (Class::*)(int) volatile>();
+ test_member_function_pointer<void (Class::*)(int, char) volatile>();
+
+ test_member_function_pointer<void (Class::*)(...)>();
+ test_member_function_pointer<void (Class::*)(int, ...)>();
+ test_member_function_pointer<void (Class::*)(int, char, ...)>();
+
+ test_member_function_pointer<void (Class::*)(...) const>();
+ test_member_function_pointer<void (Class::*)(int, ...) const>();
+ test_member_function_pointer<void (Class::*)(int, char, ...) const>();
+
+ test_member_function_pointer<void (Class::*)(...) volatile>();
+ test_member_function_pointer<void (Class::*)(int, ...) volatile>();
+ test_member_function_pointer<void (Class::*)(int, char, ...) volatile>();
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.cat/member_object_pointer.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.cat/member_object_pointer.pass.cpp
new file mode 100644
index 000000000000..4e6699cc3e7c
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.cat/member_object_pointer.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// member_object_pointer
+
+#include <type_traits>
+
+template <class T>
+void test_member_object_pointer_imp()
+{
+ static_assert(!std::is_void<T>::value, "");
+#if _LIBCPP_STD_VER > 11
+ static_assert(!std::is_null_pointer<T>::value, "");
+#endif
+ static_assert(!std::is_integral<T>::value, "");
+ static_assert(!std::is_floating_point<T>::value, "");
+ static_assert(!std::is_array<T>::value, "");
+ static_assert(!std::is_pointer<T>::value, "");
+ static_assert(!std::is_lvalue_reference<T>::value, "");
+ static_assert(!std::is_rvalue_reference<T>::value, "");
+ static_assert( std::is_member_object_pointer<T>::value, "");
+ static_assert(!std::is_member_function_pointer<T>::value, "");
+ static_assert(!std::is_enum<T>::value, "");
+ static_assert(!std::is_union<T>::value, "");
+ static_assert(!std::is_class<T>::value, "");
+ static_assert(!std::is_function<T>::value, "");
+}
+
+template <class T>
+void test_member_object_pointer()
+{
+ test_member_object_pointer_imp<T>();
+ test_member_object_pointer_imp<const T>();
+ test_member_object_pointer_imp<volatile T>();
+ test_member_object_pointer_imp<const volatile T>();
+}
+
+class Class
+{
+};
+
+int main()
+{
+ test_member_object_pointer<int Class::*>();
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.cat/nullptr.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.cat/nullptr.pass.cpp
new file mode 100644
index 000000000000..691e3536167d
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.cat/nullptr.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// nullptr_t
+// is_null_pointer
+
+#include <type_traits>
+
+#if _LIBCPP_STD_VER > 11
+template <class T>
+void test_nullptr_imp()
+{
+ static_assert(!std::is_void<T>::value, "");
+ static_assert( std::is_null_pointer<T>::value, "");
+ static_assert(!std::is_integral<T>::value, "");
+ static_assert(!std::is_floating_point<T>::value, "");
+ static_assert(!std::is_array<T>::value, "");
+ static_assert(!std::is_pointer<T>::value, "");
+ static_assert(!std::is_lvalue_reference<T>::value, "");
+ static_assert(!std::is_rvalue_reference<T>::value, "");
+ static_assert(!std::is_member_object_pointer<T>::value, "");
+ static_assert(!std::is_member_function_pointer<T>::value, "");
+ static_assert(!std::is_enum<T>::value, "");
+ static_assert(!std::is_union<T>::value, "");
+ static_assert(!std::is_class<T>::value, "");
+ static_assert(!std::is_function<T>::value, "");
+}
+
+template <class T>
+void test_nullptr()
+{
+ test_nullptr_imp<T>();
+ test_nullptr_imp<const T>();
+ test_nullptr_imp<volatile T>();
+ test_nullptr_imp<const volatile T>();
+}
+
+int main()
+{
+ test_nullptr<std::nullptr_t>();
+}
+#else
+int main() {}
+#endif
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.cat/pointer.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.cat/pointer.pass.cpp
new file mode 100644
index 000000000000..7073c106b44b
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.cat/pointer.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// pointer
+
+#include <type_traits>
+
+template <class T>
+void test_pointer_imp()
+{
+ static_assert(!std::is_void<T>::value, "");
+#if _LIBCPP_STD_VER > 11
+ static_assert(!std::is_null_pointer<T>::value, "");
+#endif
+ static_assert(!std::is_integral<T>::value, "");
+ static_assert(!std::is_floating_point<T>::value, "");
+ static_assert(!std::is_array<T>::value, "");
+ static_assert( std::is_pointer<T>::value, "");
+ static_assert(!std::is_lvalue_reference<T>::value, "");
+ static_assert(!std::is_rvalue_reference<T>::value, "");
+ static_assert(!std::is_member_object_pointer<T>::value, "");
+ static_assert(!std::is_member_function_pointer<T>::value, "");
+ static_assert(!std::is_enum<T>::value, "");
+ static_assert(!std::is_union<T>::value, "");
+ static_assert(!std::is_class<T>::value, "");
+ static_assert(!std::is_function<T>::value, "");
+}
+
+template <class T>
+void test_pointer()
+{
+ test_pointer_imp<T>();
+ test_pointer_imp<const T>();
+ test_pointer_imp<volatile T>();
+ test_pointer_imp<const volatile T>();
+}
+
+int main()
+{
+ test_pointer<void*>();
+ test_pointer<int*>();
+ test_pointer<const int*>();
+ test_pointer<void (*)(int)>();
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.cat/rvalue_ref.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.cat/rvalue_ref.pass.cpp
new file mode 100644
index 000000000000..796442403634
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.cat/rvalue_ref.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// rvalue_ref
+
+#include <type_traits>
+
+template <class T>
+void test_rvalue_ref()
+{
+ static_assert(!std::is_void<T>::value, "");
+#if _LIBCPP_STD_VER > 11
+ static_assert(!std::is_null_pointer<T>::value, "");
+#endif
+ static_assert(!std::is_integral<T>::value, "");
+ static_assert(!std::is_floating_point<T>::value, "");
+ static_assert(!std::is_array<T>::value, "");
+ static_assert(!std::is_pointer<T>::value, "");
+ static_assert(!std::is_lvalue_reference<T>::value, "");
+ static_assert( std::is_rvalue_reference<T>::value, "");
+ static_assert(!std::is_member_object_pointer<T>::value, "");
+ static_assert(!std::is_member_function_pointer<T>::value, "");
+ static_assert(!std::is_enum<T>::value, "");
+ static_assert(!std::is_union<T>::value, "");
+ static_assert(!std::is_class<T>::value, "");
+ static_assert(!std::is_function<T>::value, "");
+}
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ test_rvalue_ref<int&&>();
+ test_rvalue_ref<const int&&>();
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.cat/union.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.cat/union.pass.cpp
new file mode 100644
index 000000000000..6cabb717c0c6
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.cat/union.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// union
+
+#include <type_traits>
+
+template <class T>
+void test_union_imp()
+{
+ static_assert(!std::is_void<T>::value, "");
+#if _LIBCPP_STD_VER > 11
+ static_assert(!std::is_null_pointer<T>::value, "");
+#endif
+ static_assert(!std::is_integral<T>::value, "");
+ static_assert(!std::is_floating_point<T>::value, "");
+ static_assert(!std::is_array<T>::value, "");
+ static_assert(!std::is_pointer<T>::value, "");
+ static_assert(!std::is_lvalue_reference<T>::value, "");
+ static_assert(!std::is_rvalue_reference<T>::value, "");
+ static_assert(!std::is_member_object_pointer<T>::value, "");
+ static_assert(!std::is_member_function_pointer<T>::value, "");
+ static_assert(!std::is_enum<T>::value, "");
+ static_assert( std::is_union<T>::value, "");
+ static_assert(!std::is_class<T>::value, "");
+ static_assert(!std::is_function<T>::value, "");
+}
+
+template <class T>
+void test_union()
+{
+ test_union_imp<T>();
+ test_union_imp<const T>();
+ test_union_imp<volatile T>();
+ test_union_imp<const volatile T>();
+}
+
+union Union
+{
+ int _;
+ double __;
+};
+
+int main()
+{
+ test_union<Union>();
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.cat/void.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.cat/void.pass.cpp
new file mode 100644
index 000000000000..f20bcf87ea15
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.cat/void.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// void
+
+#include <type_traits>
+
+template <class T>
+void test_void_imp()
+{
+ static_assert( std::is_void<T>::value, "");
+#if _LIBCPP_STD_VER > 11
+ static_assert(!std::is_null_pointer<T>::value, "");
+#endif
+ static_assert(!std::is_integral<T>::value, "");
+ static_assert(!std::is_floating_point<T>::value, "");
+ static_assert(!std::is_array<T>::value, "");
+ static_assert(!std::is_pointer<T>::value, "");
+ static_assert(!std::is_lvalue_reference<T>::value, "");
+ static_assert(!std::is_rvalue_reference<T>::value, "");
+ static_assert(!std::is_member_object_pointer<T>::value, "");
+ static_assert(!std::is_member_function_pointer<T>::value, "");
+ static_assert(!std::is_enum<T>::value, "");
+ static_assert(!std::is_union<T>::value, "");
+ static_assert(!std::is_class<T>::value, "");
+ static_assert(!std::is_function<T>::value, "");
+}
+
+template <class T>
+void test_void()
+{
+ test_void_imp<T>();
+ test_void_imp<const T>();
+ test_void_imp<volatile T>();
+ test_void_imp<const volatile T>();
+}
+
+int main()
+{
+ test_void<void>();
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.comp/array.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.comp/array.pass.cpp
new file mode 100644
index 000000000000..3476d5ceea2b
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.comp/array.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// array
+
+#include <type_traits>
+
+template <class T>
+void test_array_imp()
+{
+ static_assert(!std::is_reference<T>::value, "");
+ static_assert(!std::is_arithmetic<T>::value, "");
+ static_assert(!std::is_fundamental<T>::value, "");
+ static_assert( std::is_object<T>::value, "");
+ static_assert(!std::is_scalar<T>::value, "");
+ static_assert( std::is_compound<T>::value, "");
+ static_assert(!std::is_member_pointer<T>::value, "");
+}
+
+template <class T>
+void test_array()
+{
+ test_array_imp<T>();
+ test_array_imp<const T>();
+ test_array_imp<volatile T>();
+ test_array_imp<const volatile T>();
+}
+
+typedef char array[3];
+typedef const char const_array[3];
+typedef char incomplete_array[];
+
+int main()
+{
+ test_array<array>();
+ test_array<const_array>();
+ test_array<incomplete_array>();
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.comp/class.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.comp/class.pass.cpp
new file mode 100644
index 000000000000..49e41380ca27
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.comp/class.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// class
+
+#include <type_traits>
+
+template <class T>
+void test_class_imp()
+{
+ static_assert(!std::is_reference<T>::value, "");
+ static_assert(!std::is_arithmetic<T>::value, "");
+ static_assert(!std::is_fundamental<T>::value, "");
+ static_assert( std::is_object<T>::value, "");
+ static_assert(!std::is_scalar<T>::value, "");
+ static_assert( std::is_compound<T>::value, "");
+ static_assert(!std::is_member_pointer<T>::value, "");
+}
+
+template <class T>
+void test_class()
+{
+ test_class_imp<T>();
+ test_class_imp<const T>();
+ test_class_imp<volatile T>();
+ test_class_imp<const volatile T>();
+}
+
+class Class
+{
+};
+
+int main()
+{
+ test_class<Class>();
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.comp/enum.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.comp/enum.pass.cpp
new file mode 100644
index 000000000000..dc9e4874ab19
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.comp/enum.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// enum
+
+#include <type_traits>
+
+template <class T>
+void test_enum_imp()
+{
+ static_assert(!std::is_reference<T>::value, "");
+ static_assert(!std::is_arithmetic<T>::value, "");
+ static_assert(!std::is_fundamental<T>::value, "");
+ static_assert( std::is_object<T>::value, "");
+ static_assert( std::is_scalar<T>::value, "");
+ static_assert( std::is_compound<T>::value, "");
+ static_assert(!std::is_member_pointer<T>::value, "");
+}
+
+template <class T>
+void test_enum()
+{
+ test_enum_imp<T>();
+ test_enum_imp<const T>();
+ test_enum_imp<volatile T>();
+ test_enum_imp<const volatile T>();
+}
+
+enum Enum {zero, one};
+
+int main()
+{
+ test_enum<Enum>();
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.comp/floating_point.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.comp/floating_point.pass.cpp
new file mode 100644
index 000000000000..3560b456b004
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.comp/floating_point.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// floating_point
+
+#include <type_traits>
+
+template <class T>
+void test_floating_point_imp()
+{
+ static_assert(!std::is_reference<T>::value, "");
+ static_assert( std::is_arithmetic<T>::value, "");
+ static_assert( std::is_fundamental<T>::value, "");
+ static_assert( std::is_object<T>::value, "");
+ static_assert( std::is_scalar<T>::value, "");
+ static_assert(!std::is_compound<T>::value, "");
+ static_assert(!std::is_member_pointer<T>::value, "");
+}
+
+template <class T>
+void test_floating_point()
+{
+ test_floating_point_imp<T>();
+ test_floating_point_imp<const T>();
+ test_floating_point_imp<volatile T>();
+ test_floating_point_imp<const volatile T>();
+}
+
+int main()
+{
+ test_floating_point<float>();
+ test_floating_point<double>();
+ test_floating_point<long double>();
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.comp/function.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.comp/function.pass.cpp
new file mode 100644
index 000000000000..fc8a1e5a8b26
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.comp/function.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// function
+
+#include <type_traits>
+
+template <class T>
+void test_function_imp()
+{
+ static_assert(!std::is_reference<T>::value, "");
+ static_assert(!std::is_arithmetic<T>::value, "");
+ static_assert(!std::is_fundamental<T>::value, "");
+ static_assert(!std::is_object<T>::value, "");
+ static_assert(!std::is_scalar<T>::value, "");
+ static_assert( std::is_compound<T>::value, "");
+ static_assert(!std::is_member_pointer<T>::value, "");
+}
+
+template <class T>
+void test_function()
+{
+ test_function_imp<T>();
+ test_function_imp<const T>();
+ test_function_imp<volatile T>();
+ test_function_imp<const volatile T>();
+}
+
+int main()
+{
+ test_function<void ()>();
+ test_function<void (int)>();
+ test_function<int (double)>();
+ test_function<int (double, char)>();
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.comp/integral.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.comp/integral.pass.cpp
new file mode 100644
index 000000000000..0bc94583ab04
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.comp/integral.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// integral
+
+#include <type_traits>
+
+template <class T>
+void test_integral_imp()
+{
+ static_assert(!std::is_reference<T>::value, "");
+ static_assert( std::is_arithmetic<T>::value, "");
+ static_assert( std::is_fundamental<T>::value, "");
+ static_assert( std::is_object<T>::value, "");
+ static_assert( std::is_scalar<T>::value, "");
+ static_assert(!std::is_compound<T>::value, "");
+ static_assert(!std::is_member_pointer<T>::value, "");
+}
+
+template <class T>
+void test_integral()
+{
+ test_integral_imp<T>();
+ test_integral_imp<const T>();
+ test_integral_imp<volatile T>();
+ test_integral_imp<const volatile T>();
+}
+
+int main()
+{
+ test_integral<bool>();
+ test_integral<char>();
+ test_integral<signed char>();
+ test_integral<unsigned char>();
+ test_integral<wchar_t>();
+ test_integral<short>();
+ test_integral<unsigned short>();
+ test_integral<int>();
+ test_integral<unsigned int>();
+ test_integral<long>();
+ test_integral<unsigned long>();
+ test_integral<long long>();
+ test_integral<unsigned long long>();
+#ifndef _LIBCPP_HAS_NO_INT128
+ test_integral<__int128_t>();
+ test_integral<__uint128_t>();
+#endif
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.comp/lvalue_ref.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.comp/lvalue_ref.pass.cpp
new file mode 100644
index 000000000000..dd812832f6cf
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.comp/lvalue_ref.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// lvalue_ref
+
+#include <type_traits>
+
+template <class T>
+void test_lvalue_ref()
+{
+ static_assert( std::is_reference<T>::value, "");
+ static_assert(!std::is_arithmetic<T>::value, "");
+ static_assert(!std::is_fundamental<T>::value, "");
+ static_assert(!std::is_object<T>::value, "");
+ static_assert(!std::is_scalar<T>::value, "");
+ static_assert( std::is_compound<T>::value, "");
+ static_assert(!std::is_member_pointer<T>::value, "");
+}
+
+int main()
+{
+ test_lvalue_ref<int&>();
+ test_lvalue_ref<const int&>();
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.comp/member_function_pointer.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.comp/member_function_pointer.pass.cpp
new file mode 100644
index 000000000000..0df21173c691
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.comp/member_function_pointer.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// member_function_pointer
+
+#include <type_traits>
+
+template <class T>
+void test_member_function_pointer_imp()
+{
+ static_assert(!std::is_reference<T>::value, "");
+ static_assert(!std::is_arithmetic<T>::value, "");
+ static_assert(!std::is_fundamental<T>::value, "");
+ static_assert( std::is_object<T>::value, "");
+ static_assert( std::is_scalar<T>::value, "");
+ static_assert( std::is_compound<T>::value, "");
+ static_assert( std::is_member_pointer<T>::value, "");
+}
+
+template <class T>
+void test_member_function_pointer()
+{
+ test_member_function_pointer_imp<T>();
+ test_member_function_pointer_imp<const T>();
+ test_member_function_pointer_imp<volatile T>();
+ test_member_function_pointer_imp<const volatile T>();
+}
+
+class Class
+{
+};
+
+int main()
+{
+ test_member_function_pointer<void (Class::*)()>();
+ test_member_function_pointer<void (Class::*)(int)>();
+ test_member_function_pointer<void (Class::*)(int, char)>();
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.comp/member_object_pointer.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.comp/member_object_pointer.pass.cpp
new file mode 100644
index 000000000000..a0dea4a9c44f
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.comp/member_object_pointer.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// member_object_pointer
+
+#include <type_traits>
+
+template <class T>
+void test_member_object_pointer_imp()
+{
+ static_assert(!std::is_reference<T>::value, "");
+ static_assert(!std::is_arithmetic<T>::value, "");
+ static_assert(!std::is_fundamental<T>::value, "");
+ static_assert( std::is_object<T>::value, "");
+ static_assert( std::is_scalar<T>::value, "");
+ static_assert( std::is_compound<T>::value, "");
+ static_assert( std::is_member_pointer<T>::value, "");
+}
+
+template <class T>
+void test_member_object_pointer()
+{
+ test_member_object_pointer_imp<T>();
+ test_member_object_pointer_imp<const T>();
+ test_member_object_pointer_imp<volatile T>();
+ test_member_object_pointer_imp<const volatile T>();
+}
+
+class Class
+{
+};
+
+int main()
+{
+ test_member_object_pointer<int Class::*>();
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.comp/pointer.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.comp/pointer.pass.cpp
new file mode 100644
index 000000000000..de23da83637a
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.comp/pointer.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// pointer
+
+#include <type_traits>
+
+template <class T>
+void test_pointer_imp()
+{
+ static_assert(!std::is_reference<T>::value, "");
+ static_assert(!std::is_arithmetic<T>::value, "");
+ static_assert(!std::is_fundamental<T>::value, "");
+ static_assert( std::is_object<T>::value, "");
+ static_assert( std::is_scalar<T>::value, "");
+ static_assert( std::is_compound<T>::value, "");
+ static_assert(!std::is_member_pointer<T>::value, "");
+}
+
+template <class T>
+void test_pointer()
+{
+ test_pointer_imp<T>();
+ test_pointer_imp<const T>();
+ test_pointer_imp<volatile T>();
+ test_pointer_imp<const volatile T>();
+}
+
+int main()
+{
+ test_pointer<void*>();
+ test_pointer<int*>();
+ test_pointer<const int*>();
+ test_pointer<void (*)(int)>();
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.comp/rvalue_ref.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.comp/rvalue_ref.pass.cpp
new file mode 100644
index 000000000000..7563c2fd5850
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.comp/rvalue_ref.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// rvalue_ref
+
+#include <type_traits>
+
+template <class T>
+void test_rvalue_ref()
+{
+ static_assert( std::is_reference<T>::value, "");
+ static_assert(!std::is_arithmetic<T>::value, "");
+ static_assert(!std::is_fundamental<T>::value, "");
+ static_assert(!std::is_object<T>::value, "");
+ static_assert(!std::is_scalar<T>::value, "");
+ static_assert( std::is_compound<T>::value, "");
+ static_assert(!std::is_member_pointer<T>::value, "");
+}
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ test_rvalue_ref<int&&>();
+ test_rvalue_ref<const int&&>();
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.comp/union.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.comp/union.pass.cpp
new file mode 100644
index 000000000000..05db74c8aaf5
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.comp/union.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// union
+
+#include <type_traits>
+
+template <class T>
+void test_union_imp()
+{
+ static_assert(!std::is_reference<T>::value, "");
+ static_assert(!std::is_arithmetic<T>::value, "");
+ static_assert(!std::is_fundamental<T>::value, "");
+ static_assert( std::is_object<T>::value, "");
+ static_assert(!std::is_scalar<T>::value, "");
+ static_assert( std::is_compound<T>::value, "");
+ static_assert(!std::is_member_pointer<T>::value, "");
+}
+
+template <class T>
+void test_union()
+{
+ test_union_imp<T>();
+ test_union_imp<const T>();
+ test_union_imp<volatile T>();
+ test_union_imp<const volatile T>();
+}
+
+union Union
+{
+ int _;
+ double __;
+};
+
+int main()
+{
+ test_union<Union>();
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.comp/void.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.comp/void.pass.cpp
new file mode 100644
index 000000000000..59569fe086bf
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.comp/void.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// void
+
+#include <type_traits>
+
+template <class T>
+void test_void_imp()
+{
+ static_assert(!std::is_reference<T>::value, "");
+ static_assert(!std::is_arithmetic<T>::value, "");
+ static_assert( std::is_fundamental<T>::value, "");
+ static_assert(!std::is_object<T>::value, "");
+ static_assert(!std::is_scalar<T>::value, "");
+ static_assert(!std::is_compound<T>::value, "");
+ static_assert(!std::is_member_pointer<T>::value, "");
+}
+
+template <class T>
+void test_void()
+{
+ test_void_imp<T>();
+ test_void_imp<const T>();
+ test_void_imp<volatile T>();
+ test_void_imp<const volatile T>();
+}
+
+int main()
+{
+ test_void<void>();
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/__has_operator_addressof.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/__has_operator_addressof.pass.cpp
new file mode 100644
index 000000000000..1c715e04970c
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/__has_operator_addressof.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// extension
+
+// template <typename _Tp> struct __has_operator_addressof
+
+
+#include <type_traits>
+
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+
+struct A
+{
+};
+
+struct B
+{
+ constexpr B* operator&() const;
+};
+
+struct D;
+
+struct C
+{
+ template <class U>
+ D operator,(U&&);
+};
+
+struct E
+{
+ constexpr C operator&() const;
+};
+
+struct F {};
+constexpr F* operator&(F const &) { return nullptr; }
+
+struct G {};
+constexpr G* operator&(G &&) { return nullptr; }
+
+struct H {};
+constexpr H* operator&(H const &&) { return nullptr; }
+
+struct J
+{
+ constexpr J* operator&() const &&;
+};
+
+#endif // _LIBCPP_HAS_NO_CONSTEXPR
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+ static_assert(std::__has_operator_addressof<int>::value == false, "");
+ static_assert(std::__has_operator_addressof<A>::value == false, "");
+ static_assert(std::__has_operator_addressof<B>::value == true, "");
+ static_assert(std::__has_operator_addressof<E>::value == true, "");
+ static_assert(std::__has_operator_addressof<F>::value == true, "");
+ static_assert(std::__has_operator_addressof<G>::value == true, "");
+ static_assert(std::__has_operator_addressof<H>::value == true, "");
+ static_assert(std::__has_operator_addressof<J>::value == true, "");
+#endif // _LIBCPP_HAS_NO_CONSTEXPR
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/has_virtual_destructor.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/has_virtual_destructor.pass.cpp
new file mode 100644
index 000000000000..685d30de692f
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/has_virtual_destructor.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// has_virtual_destructor
+
+#include <type_traits>
+
+template <class T>
+void test_has_virtual_destructor()
+{
+ static_assert( std::has_virtual_destructor<T>::value, "");
+ static_assert( std::has_virtual_destructor<const T>::value, "");
+ static_assert( std::has_virtual_destructor<volatile T>::value, "");
+ static_assert( std::has_virtual_destructor<const volatile T>::value, "");
+}
+
+template <class T>
+void test_has_not_virtual_destructor()
+{
+ static_assert(!std::has_virtual_destructor<T>::value, "");
+ static_assert(!std::has_virtual_destructor<const T>::value, "");
+ static_assert(!std::has_virtual_destructor<volatile T>::value, "");
+ static_assert(!std::has_virtual_destructor<const volatile T>::value, "");
+}
+
+class Empty
+{
+};
+
+class NotEmpty
+{
+ virtual ~NotEmpty();
+};
+
+union Union {};
+
+struct bit_zero
+{
+ int : 0;
+};
+
+class Abstract
+{
+ virtual ~Abstract() = 0;
+};
+
+struct A
+{
+ ~A();
+};
+
+int main()
+{
+ test_has_not_virtual_destructor<void>();
+ test_has_not_virtual_destructor<A>();
+ test_has_not_virtual_destructor<int&>();
+ test_has_not_virtual_destructor<Union>();
+ test_has_not_virtual_destructor<Empty>();
+ test_has_not_virtual_destructor<int>();
+ test_has_not_virtual_destructor<double>();
+ test_has_not_virtual_destructor<int*>();
+ test_has_not_virtual_destructor<const int*>();
+ test_has_not_virtual_destructor<char[3]>();
+ test_has_not_virtual_destructor<char[]>();
+ test_has_not_virtual_destructor<bit_zero>();
+
+ test_has_virtual_destructor<Abstract>();
+ test_has_virtual_destructor<NotEmpty>();
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_abstract.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_abstract.pass.cpp
new file mode 100644
index 000000000000..f2a8c23246b1
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_abstract.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_abstract
+
+#include <type_traits>
+
+template <class T>
+void test_is_abstract()
+{
+ static_assert( std::is_abstract<T>::value, "");
+ static_assert( std::is_abstract<const T>::value, "");
+ static_assert( std::is_abstract<volatile T>::value, "");
+ static_assert( std::is_abstract<const volatile T>::value, "");
+}
+
+template <class T>
+void test_is_not_abstract()
+{
+ static_assert(!std::is_abstract<T>::value, "");
+ static_assert(!std::is_abstract<const T>::value, "");
+ static_assert(!std::is_abstract<volatile T>::value, "");
+ static_assert(!std::is_abstract<const volatile T>::value, "");
+}
+
+class Empty
+{
+};
+
+class NotEmpty
+{
+ virtual ~NotEmpty();
+};
+
+union Union {};
+
+struct bit_zero
+{
+ int : 0;
+};
+
+class Abstract
+{
+ virtual ~Abstract() = 0;
+};
+
+int main()
+{
+ test_is_not_abstract<void>();
+ test_is_not_abstract<int&>();
+ test_is_not_abstract<int>();
+ test_is_not_abstract<double>();
+ test_is_not_abstract<int*>();
+ test_is_not_abstract<const int*>();
+ test_is_not_abstract<char[3]>();
+ test_is_not_abstract<char[]>();
+ test_is_not_abstract<Union>();
+ test_is_not_abstract<Empty>();
+ test_is_not_abstract<bit_zero>();
+ test_is_not_abstract<NotEmpty>();
+
+ test_is_abstract<Abstract>();
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_assignable.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_assignable.pass.cpp
new file mode 100644
index 000000000000..d33019bcba9e
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_assignable.pass.cpp
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_assignable
+
+#include <type_traits>
+
+struct A
+{
+};
+
+struct B
+{
+ void operator=(A);
+};
+
+template <class T, class U>
+void test_is_assignable()
+{
+ static_assert(( std::is_assignable<T, U>::value), "");
+}
+
+template <class T, class U>
+void test_is_not_assignable()
+{
+ static_assert((!std::is_assignable<T, U>::value), "");
+}
+
+struct D;
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+struct C
+{
+ template <class U>
+ D operator,(U&&);
+};
+
+struct E
+{
+ C operator=(int);
+};
+#endif
+
+template <typename T>
+struct X { T t; };
+
+int main()
+{
+ test_is_assignable<int&, int&> ();
+ test_is_assignable<int&, int> ();
+ test_is_assignable<int&, double> ();
+ test_is_assignable<B, A> ();
+ test_is_assignable<void*&, void*> ();
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ test_is_assignable<E, int> ();
+
+ test_is_not_assignable<int, int&> ();
+ test_is_not_assignable<int, int> ();
+#endif
+ test_is_not_assignable<A, B> ();
+ test_is_not_assignable<void, const void> ();
+ test_is_not_assignable<const void, const void> ();
+ test_is_not_assignable<int(), int> ();
+
+// pointer to incomplete template type
+ test_is_assignable<X<D>*&, X<D>*> ();
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_const.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_const.pass.cpp
new file mode 100644
index 000000000000..72f2ff458921
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_const.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_const
+
+#include <type_traits>
+
+template <class T>
+void test_is_const()
+{
+ static_assert(!std::is_const<T>::value, "");
+ static_assert( std::is_const<const T>::value, "");
+ static_assert(!std::is_const<volatile T>::value, "");
+ static_assert( std::is_const<const volatile T>::value, "");
+}
+
+int main()
+{
+ test_is_const<void>();
+ test_is_const<int>();
+ test_is_const<double>();
+ test_is_const<int*>();
+ test_is_const<const int*>();
+ test_is_const<char[3]>();
+ test_is_const<char[]>();
+
+ static_assert(!std::is_const<int&>::value, "");
+ static_assert(!std::is_const<const int&>::value, "");
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp
new file mode 100644
index 000000000000..2b8f7efec602
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp
@@ -0,0 +1,86 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// template <class T, class... Args>
+// struct is_constructible;
+
+#include <type_traits>
+
+struct A
+{
+ explicit A(int);
+ A(int, double);
+#if __has_feature(cxx_access_control_sfinae)
+private:
+#endif
+ A(char);
+};
+
+class Abstract
+{
+ virtual void foo() = 0;
+};
+
+class AbstractDestructor
+{
+ virtual ~AbstractDestructor() = 0;
+};
+
+template <class T>
+void test_is_constructible()
+{
+ static_assert( (std::is_constructible<T>::value), "");
+}
+
+template <class T, class A0>
+void test_is_constructible()
+{
+ static_assert( (std::is_constructible<T, A0>::value), "");
+}
+
+template <class T, class A0, class A1>
+void test_is_constructible()
+{
+ static_assert( (std::is_constructible<T, A0, A1>::value), "");
+}
+
+template <class T>
+void test_is_not_constructible()
+{
+ static_assert((!std::is_constructible<T>::value), "");
+}
+
+template <class T, class A0>
+void test_is_not_constructible()
+{
+ static_assert((!std::is_constructible<T, A0>::value), "");
+}
+
+int main()
+{
+ test_is_constructible<int> ();
+ test_is_constructible<int, const int> ();
+ test_is_constructible<A, int> ();
+ test_is_constructible<A, int, double> ();
+ test_is_constructible<int&, int&> ();
+
+ test_is_not_constructible<A> ();
+#if __has_feature(cxx_access_control_sfinae)
+ test_is_not_constructible<A, char> ();
+#else
+ test_is_constructible<A, char> ();
+#endif
+ test_is_not_constructible<A, void> ();
+ test_is_not_constructible<void> ();
+ test_is_not_constructible<int&> ();
+ test_is_not_constructible<Abstract> ();
+ test_is_not_constructible<AbstractDestructor> ();
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_copy_assignable.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_copy_assignable.pass.cpp
new file mode 100644
index 000000000000..c43d59479fb2
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_copy_assignable.pass.cpp
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_copy_assignable
+
+#include <type_traits>
+
+template <class T>
+void test_is_copy_assignable()
+{
+ static_assert(( std::is_copy_assignable<T>::value), "");
+}
+
+template <class T>
+void test_is_not_copy_assignable()
+{
+ static_assert((!std::is_copy_assignable<T>::value), "");
+}
+
+class Empty
+{
+};
+
+class NotEmpty
+{
+public:
+ virtual ~NotEmpty();
+};
+
+union Union {};
+
+struct bit_zero
+{
+ int : 0;
+};
+
+struct A
+{
+ A();
+};
+
+class B
+{
+ B& operator=(const B&);
+};
+
+struct C
+{
+ void operator=(C&); // not const
+};
+
+int main()
+{
+ test_is_copy_assignable<int> ();
+ test_is_copy_assignable<int&> ();
+ test_is_copy_assignable<A> ();
+ test_is_copy_assignable<bit_zero> ();
+ test_is_copy_assignable<Union> ();
+ test_is_copy_assignable<NotEmpty> ();
+ test_is_copy_assignable<Empty> ();
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ test_is_not_copy_assignable<const int> ();
+ test_is_not_copy_assignable<int[]> ();
+ test_is_not_copy_assignable<int[3]> ();
+#endif
+#if __has_feature(cxx_access_control_sfinae)
+ test_is_not_copy_assignable<B> ();
+#endif
+ test_is_not_copy_assignable<void> ();
+ test_is_not_copy_assignable<C> ();
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_copy_constructible.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_copy_constructible.pass.cpp
new file mode 100644
index 000000000000..f878a50c3af5
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_copy_constructible.pass.cpp
@@ -0,0 +1,88 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_copy_constructible
+
+#include <type_traits>
+
+template <class T>
+void test_is_copy_constructible()
+{
+ static_assert( std::is_copy_constructible<T>::value, "");
+}
+
+template <class T>
+void test_is_not_copy_constructible()
+{
+ static_assert(!std::is_copy_constructible<T>::value, "");
+}
+
+class Empty
+{
+};
+
+class NotEmpty
+{
+public:
+ virtual ~NotEmpty();
+};
+
+union Union {};
+
+struct bit_zero
+{
+ int : 0;
+};
+
+class Abstract
+{
+public:
+ virtual ~Abstract() = 0;
+};
+
+struct A
+{
+ A(const A&);
+};
+
+class B
+{
+ B(const B&);
+};
+
+struct C
+{
+ C(C&); // not const
+ void operator=(C&); // not const
+};
+
+int main()
+{
+ test_is_copy_constructible<A>();
+ test_is_copy_constructible<int&>();
+ test_is_copy_constructible<Union>();
+ test_is_copy_constructible<Empty>();
+ test_is_copy_constructible<int>();
+ test_is_copy_constructible<double>();
+ test_is_copy_constructible<int*>();
+ test_is_copy_constructible<const int*>();
+ test_is_copy_constructible<NotEmpty>();
+ test_is_copy_constructible<bit_zero>();
+
+ test_is_not_copy_constructible<char[3]>();
+ test_is_not_copy_constructible<char[]>();
+ test_is_not_copy_constructible<void>();
+ test_is_not_copy_constructible<Abstract>();
+ test_is_not_copy_constructible<C>();
+#if __has_feature(cxx_access_control_sfinae)
+ test_is_not_copy_constructible<B>();
+#endif
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_default_constructible.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_default_constructible.pass.cpp
new file mode 100644
index 000000000000..c8d5c42fbf89
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_default_constructible.pass.cpp
@@ -0,0 +1,93 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_default_constructible
+
+#include <type_traits>
+
+template <class T>
+void test_is_default_constructible()
+{
+ static_assert( std::is_default_constructible<T>::value, "");
+ static_assert( std::is_default_constructible<const T>::value, "");
+ static_assert( std::is_default_constructible<volatile T>::value, "");
+ static_assert( std::is_default_constructible<const volatile T>::value, "");
+}
+
+template <class T>
+void test_is_not_default_constructible()
+{
+ static_assert(!std::is_default_constructible<T>::value, "");
+ static_assert(!std::is_default_constructible<const T>::value, "");
+ static_assert(!std::is_default_constructible<volatile T>::value, "");
+ static_assert(!std::is_default_constructible<const volatile T>::value, "");
+}
+
+class Empty
+{
+};
+
+class NoDefaultConstructor
+{
+ NoDefaultConstructor(int) {}
+};
+
+class NotEmpty
+{
+public:
+ virtual ~NotEmpty();
+};
+
+union Union {};
+
+struct bit_zero
+{
+ int : 0;
+};
+
+class Abstract
+{
+public:
+ virtual ~Abstract() = 0;
+};
+
+struct A
+{
+ A();
+};
+
+class B
+{
+ B();
+};
+
+int main()
+{
+ test_is_default_constructible<A>();
+ test_is_default_constructible<Union>();
+ test_is_default_constructible<Empty>();
+ test_is_default_constructible<int>();
+ test_is_default_constructible<double>();
+ test_is_default_constructible<int*>();
+ test_is_default_constructible<const int*>();
+ test_is_default_constructible<char[3]>();
+ test_is_default_constructible<NotEmpty>();
+ test_is_default_constructible<bit_zero>();
+
+ test_is_not_default_constructible<void>();
+ test_is_not_default_constructible<int&>();
+ test_is_not_default_constructible<char[]>();
+ test_is_not_default_constructible<Abstract>();
+ test_is_not_default_constructible<NoDefaultConstructor>();
+#if __has_feature(cxx_access_control_sfinae)
+ test_is_not_default_constructible<B>();
+#endif
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_destructible.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_destructible.pass.cpp
new file mode 100644
index 000000000000..807745ef66c1
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_destructible.pass.cpp
@@ -0,0 +1,121 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_destructible
+
+#include <type_traits>
+
+template <class T>
+void test_is_destructible()
+{
+ static_assert( std::is_destructible<T>::value, "");
+ static_assert( std::is_destructible<const T>::value, "");
+ static_assert( std::is_destructible<volatile T>::value, "");
+ static_assert( std::is_destructible<const volatile T>::value, "");
+}
+
+template <class T>
+void test_is_not_destructible()
+{
+ static_assert(!std::is_destructible<T>::value, "");
+ static_assert(!std::is_destructible<const T>::value, "");
+ static_assert(!std::is_destructible<volatile T>::value, "");
+ static_assert(!std::is_destructible<const volatile T>::value, "");
+}
+
+class Empty {};
+
+class NotEmpty
+{
+ virtual ~NotEmpty();
+};
+
+union Union {};
+
+struct bit_zero
+{
+ int : 0;
+};
+
+struct A
+{
+ ~A();
+};
+
+typedef void (Function) ();
+
+struct PublicAbstract { public: virtual void foo() = 0; };
+struct ProtectedAbstract { protected: virtual void foo() = 0; };
+struct PrivateAbstract { private: virtual void foo() = 0; };
+
+struct PublicDestructor { public: ~PublicDestructor() {}};
+struct ProtectedDestructor { protected: ~ProtectedDestructor() {}};
+struct PrivateDestructor { private: ~PrivateDestructor() {}};
+
+struct VirtualPublicDestructor { public: virtual ~VirtualPublicDestructor() {}};
+struct VirtualProtectedDestructor { protected: virtual ~VirtualProtectedDestructor() {}};
+struct VirtualPrivateDestructor { private: virtual ~VirtualPrivateDestructor() {}};
+
+struct PurePublicDestructor { public: virtual ~PurePublicDestructor() = 0; };
+struct PureProtectedDestructor { protected: virtual ~PureProtectedDestructor() = 0; };
+struct PurePrivateDestructor { private: virtual ~PurePrivateDestructor() = 0; };
+
+struct DeletedPublicDestructor { public: ~DeletedPublicDestructor() = delete; };
+struct DeletedProtectedDestructor { protected: ~DeletedProtectedDestructor() = delete; };
+struct DeletedPrivateDestructor { private: ~DeletedPrivateDestructor() = delete; };
+
+struct DeletedVirtualPublicDestructor { public: virtual ~DeletedVirtualPublicDestructor() = delete; };
+struct DeletedVirtualProtectedDestructor { protected: virtual ~DeletedVirtualProtectedDestructor() = delete; };
+struct DeletedVirtualPrivateDestructor { private: virtual ~DeletedVirtualPrivateDestructor() = delete; };
+
+
+int main()
+{
+ test_is_destructible<A>();
+ test_is_destructible<int&>();
+ test_is_destructible<Union>();
+ test_is_destructible<Empty>();
+ test_is_destructible<int>();
+ test_is_destructible<double>();
+ test_is_destructible<int*>();
+ test_is_destructible<const int*>();
+ test_is_destructible<char[3]>();
+ test_is_destructible<bit_zero>();
+ test_is_destructible<int[3]>();
+ test_is_destructible<ProtectedAbstract>();
+ test_is_destructible<PublicAbstract>();
+ test_is_destructible<PrivateAbstract>();
+ test_is_destructible<PublicDestructor>();
+ test_is_destructible<VirtualPublicDestructor>();
+ test_is_destructible<PurePublicDestructor>();
+
+ test_is_not_destructible<int[]>();
+ test_is_not_destructible<void>();
+
+ test_is_not_destructible<ProtectedDestructor>();
+ test_is_not_destructible<PrivateDestructor>();
+ test_is_not_destructible<VirtualProtectedDestructor>();
+ test_is_not_destructible<VirtualPrivateDestructor>();
+ test_is_not_destructible<PureProtectedDestructor>();
+ test_is_not_destructible<PurePrivateDestructor>();
+ test_is_not_destructible<DeletedPublicDestructor>();
+ test_is_not_destructible<DeletedProtectedDestructor>();
+ test_is_not_destructible<DeletedPrivateDestructor>();
+
+// test_is_not_destructible<DeletedVirtualPublicDestructor>(); // currently fails due to clang bug #20268
+ test_is_not_destructible<DeletedVirtualProtectedDestructor>();
+ test_is_not_destructible<DeletedVirtualPrivateDestructor>();
+
+#if __has_feature(cxx_access_control_sfinae)
+ test_is_not_destructible<NotEmpty>();
+#endif
+ test_is_not_destructible<Function>();
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_empty.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_empty.pass.cpp
new file mode 100644
index 000000000000..47af3c45cdea
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_empty.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_empty
+
+#include <type_traits>
+
+template <class T>
+void test_is_empty()
+{
+ static_assert( std::is_empty<T>::value, "");
+ static_assert( std::is_empty<const T>::value, "");
+ static_assert( std::is_empty<volatile T>::value, "");
+ static_assert( std::is_empty<const volatile T>::value, "");
+}
+
+template <class T>
+void test_is_not_empty()
+{
+ static_assert(!std::is_empty<T>::value, "");
+ static_assert(!std::is_empty<const T>::value, "");
+ static_assert(!std::is_empty<volatile T>::value, "");
+ static_assert(!std::is_empty<const volatile T>::value, "");
+}
+
+class Empty
+{
+};
+
+class NotEmpty
+{
+ virtual ~NotEmpty();
+};
+
+union Union {};
+
+struct bit_zero
+{
+ int : 0;
+};
+
+int main()
+{
+ test_is_not_empty<void>();
+ test_is_not_empty<int&>();
+ test_is_not_empty<int>();
+ test_is_not_empty<double>();
+ test_is_not_empty<int*>();
+ test_is_not_empty<const int*>();
+ test_is_not_empty<char[3]>();
+ test_is_not_empty<char[]>();
+ test_is_not_empty<Union>();
+ test_is_not_empty<NotEmpty>();
+
+ test_is_empty<Empty>();
+ test_is_empty<bit_zero>();
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_final.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_final.pass.cpp
new file mode 100644
index 000000000000..cf32196213e1
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_final.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_final
+
+#include <type_traits>
+
+#if _LIBCPP_STD_VER > 11
+
+struct P final { };
+union U1 { };
+union U2 final { };
+
+template <class T>
+void test_is_final()
+{
+ static_assert( std::is_final<T>::value, "");
+ static_assert( std::is_final<const T>::value, "");
+ static_assert( std::is_final<volatile T>::value, "");
+ static_assert( std::is_final<const volatile T>::value, "");
+}
+
+template <class T>
+void test_is_not_final()
+{
+ static_assert(!std::is_final<T>::value, "");
+ static_assert(!std::is_final<const T>::value, "");
+ static_assert(!std::is_final<volatile T>::value, "");
+ static_assert(!std::is_final<const volatile T>::value, "");
+}
+
+int main ()
+{
+ test_is_not_final<int>();
+ test_is_not_final<int*>();
+ test_is_final <P>();
+ test_is_not_final<P*>();
+ test_is_not_final<U1>();
+ test_is_not_final<U1*>();
+ test_is_final <U2>();
+ test_is_not_final<U2*>();
+}
+#else
+int main () {}
+#endif
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_literal_type.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_literal_type.pass.cpp
new file mode 100644
index 000000000000..ce781cd936b0
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_literal_type.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_literal_type
+
+#include <type_traits>
+
+template <class T>
+void test_is_literal_type()
+{
+ static_assert( std::is_literal_type<T>::value, "");
+}
+
+template <class T>
+void test_is_not_literal_type()
+{
+ static_assert(!std::is_literal_type<T>::value, "");
+}
+
+struct A
+{
+};
+
+struct B
+{
+ B();
+};
+
+int main()
+{
+ test_is_literal_type<int> ();
+ test_is_literal_type<const int> ();
+ test_is_literal_type<int&> ();
+ test_is_literal_type<volatile int&> ();
+ test_is_literal_type<A> ();
+
+ test_is_not_literal_type<B> ();
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_move_assignable.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_move_assignable.pass.cpp
new file mode 100644
index 000000000000..a89ee7d4e490
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_move_assignable.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_move_assignable
+
+#include <type_traits>
+
+template <class T>
+void test_is_move_assignable()
+{
+ static_assert( std::is_move_assignable<T>::value, "");
+}
+
+template <class T>
+void test_is_not_move_assignable()
+{
+ static_assert(!std::is_move_assignable<T>::value, "");
+}
+
+class Empty
+{
+};
+
+class NotEmpty
+{
+public:
+ virtual ~NotEmpty();
+};
+
+union Union {};
+
+struct bit_zero
+{
+ int : 0;
+};
+
+struct A
+{
+ A();
+};
+
+int main()
+{
+ test_is_move_assignable<int> ();
+ test_is_move_assignable<A> ();
+ test_is_move_assignable<bit_zero> ();
+ test_is_move_assignable<Union> ();
+ test_is_move_assignable<NotEmpty> ();
+ test_is_move_assignable<Empty> ();
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ test_is_not_move_assignable<const int> ();
+ test_is_not_move_assignable<int[]> ();
+ test_is_not_move_assignable<int[3]> ();
+#endif
+ test_is_not_move_assignable<void> ();
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_move_constructible.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_move_constructible.pass.cpp
new file mode 100644
index 000000000000..7409ebaa56c8
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_move_constructible.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_move_constructible
+
+#include <type_traits>
+
+template <class T>
+void test_is_move_constructible()
+{
+ static_assert( std::is_move_constructible<T>::value, "");
+}
+
+template <class T>
+void test_is_not_move_constructible()
+{
+ static_assert(!std::is_move_constructible<T>::value, "");
+}
+
+class Empty
+{
+};
+
+class NotEmpty
+{
+public:
+ virtual ~NotEmpty();
+};
+
+union Union {};
+
+struct bit_zero
+{
+ int : 0;
+};
+
+class Abstract
+{
+public:
+ virtual ~Abstract() = 0;
+};
+
+struct A
+{
+ A(const A&);
+};
+
+struct B
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ B(B&&);
+#endif
+};
+
+int main()
+{
+ test_is_not_move_constructible<char[3]>();
+ test_is_not_move_constructible<char[]>();
+ test_is_not_move_constructible<void>();
+ test_is_not_move_constructible<Abstract>();
+
+ test_is_move_constructible<A>();
+ test_is_move_constructible<int&>();
+ test_is_move_constructible<Union>();
+ test_is_move_constructible<Empty>();
+ test_is_move_constructible<int>();
+ test_is_move_constructible<double>();
+ test_is_move_constructible<int*>();
+ test_is_move_constructible<const int*>();
+ test_is_move_constructible<NotEmpty>();
+ test_is_move_constructible<bit_zero>();
+ test_is_move_constructible<B>();
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_assignable.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_assignable.pass.cpp
new file mode 100644
index 000000000000..8fff5f8b3de3
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_assignable.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_nothrow_assignable
+
+#include <type_traits>
+
+template <class T, class U>
+void test_is_nothrow_assignable()
+{
+ static_assert(( std::is_nothrow_assignable<T, U>::value), "");
+}
+
+template <class T, class U>
+void test_is_not_nothrow_assignable()
+{
+ static_assert((!std::is_nothrow_assignable<T, U>::value), "");
+}
+
+struct A
+{
+};
+
+struct B
+{
+ void operator=(A);
+};
+
+struct C
+{
+ void operator=(C&); // not const
+};
+
+int main()
+{
+ test_is_nothrow_assignable<int&, int&> ();
+ test_is_nothrow_assignable<int&, int> ();
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ test_is_nothrow_assignable<int&, double> ();
+#endif
+
+ test_is_not_nothrow_assignable<int, int&> ();
+ test_is_not_nothrow_assignable<int, int> ();
+ test_is_not_nothrow_assignable<B, A> ();
+ test_is_not_nothrow_assignable<A, B> ();
+ test_is_not_nothrow_assignable<C, C&> ();
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_constructible.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_constructible.pass.cpp
new file mode 100644
index 000000000000..fe0b5673bc44
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_constructible.pass.cpp
@@ -0,0 +1,103 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// template <class T, class... Args>
+// struct is_nothrow_constructible;
+
+#include <type_traits>
+
+template <class T>
+void test_is_nothrow_constructible()
+{
+ static_assert(( std::is_nothrow_constructible<T>::value), "");
+}
+
+template <class T, class A0>
+void test_is_nothrow_constructible()
+{
+ static_assert(( std::is_nothrow_constructible<T, A0>::value), "");
+}
+
+template <class T>
+void test_is_not_nothrow_constructible()
+{
+ static_assert((!std::is_nothrow_constructible<T>::value), "");
+}
+
+template <class T, class A0>
+void test_is_not_nothrow_constructible()
+{
+ static_assert((!std::is_nothrow_constructible<T, A0>::value), "");
+}
+
+template <class T, class A0, class A1>
+void test_is_not_nothrow_constructible()
+{
+ static_assert((!std::is_nothrow_constructible<T, A0, A1>::value), "");
+}
+
+class Empty
+{
+};
+
+class NotEmpty
+{
+ virtual ~NotEmpty();
+};
+
+union Union {};
+
+struct bit_zero
+{
+ int : 0;
+};
+
+class Abstract
+{
+ virtual ~Abstract() = 0;
+};
+
+struct A
+{
+ A(const A&);
+};
+
+struct C
+{
+ C(C&); // not const
+ void operator=(C&); // not const
+};
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+struct Tuple {
+ Tuple(Empty&&) noexcept {}
+};
+#endif
+
+int main()
+{
+ test_is_nothrow_constructible<int> ();
+ test_is_nothrow_constructible<int, const int&> ();
+ test_is_nothrow_constructible<Empty> ();
+ test_is_nothrow_constructible<Empty, const Empty&> ();
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ test_is_nothrow_constructible<Tuple &&, Empty> (); // See bug #19616.
+#endif
+
+ test_is_not_nothrow_constructible<A, int> ();
+ test_is_not_nothrow_constructible<A, int, double> ();
+ test_is_not_nothrow_constructible<A> ();
+ test_is_not_nothrow_constructible<C> ();
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ static_assert(!std::is_constructible<Tuple&, Empty>::value, "");
+ test_is_not_nothrow_constructible<Tuple &, Empty> (); // See bug #19616.
+#endif
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_copy_assignable.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_copy_assignable.pass.cpp
new file mode 100644
index 000000000000..d843803cf21d
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_copy_assignable.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_nothrow_copy_assignable
+
+#include <type_traits>
+
+template <class T>
+void test_has_nothrow_assign()
+{
+ static_assert( std::is_nothrow_copy_assignable<T>::value, "");
+}
+
+template <class T>
+void test_has_not_nothrow_assign()
+{
+ static_assert(!std::is_nothrow_copy_assignable<T>::value, "");
+}
+
+class Empty
+{
+};
+
+struct NotEmpty
+{
+ virtual ~NotEmpty();
+};
+
+union Union {};
+
+struct bit_zero
+{
+ int : 0;
+};
+
+struct A
+{
+ A& operator=(const A&);
+};
+
+int main()
+{
+ test_has_nothrow_assign<int&>();
+ test_has_nothrow_assign<Union>();
+ test_has_nothrow_assign<Empty>();
+ test_has_nothrow_assign<int>();
+ test_has_nothrow_assign<double>();
+ test_has_nothrow_assign<int*>();
+ test_has_nothrow_assign<const int*>();
+ test_has_nothrow_assign<NotEmpty>();
+ test_has_nothrow_assign<bit_zero>();
+
+ test_has_not_nothrow_assign<const int>();
+ test_has_not_nothrow_assign<void>();
+ test_has_not_nothrow_assign<A>();
+
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_copy_constructible.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_copy_constructible.pass.cpp
new file mode 100644
index 000000000000..99fce65dcc7e
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_copy_constructible.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_nothrow_copy_constructible
+
+#include <type_traits>
+
+template <class T>
+void test_is_nothrow_copy_constructible()
+{
+ static_assert( std::is_nothrow_copy_constructible<T>::value, "");
+ static_assert( std::is_nothrow_copy_constructible<const T>::value, "");
+}
+
+template <class T>
+void test_has_not_nothrow_copy_constructor()
+{
+ static_assert(!std::is_nothrow_copy_constructible<T>::value, "");
+ static_assert(!std::is_nothrow_copy_constructible<const T>::value, "");
+ static_assert(!std::is_nothrow_copy_constructible<volatile T>::value, "");
+ static_assert(!std::is_nothrow_copy_constructible<const volatile T>::value, "");
+}
+
+class Empty
+{
+};
+
+union Union {};
+
+struct bit_zero
+{
+ int : 0;
+};
+
+struct A
+{
+ A(const A&);
+};
+
+int main()
+{
+ test_has_not_nothrow_copy_constructor<void>();
+ test_has_not_nothrow_copy_constructor<A>();
+
+ test_is_nothrow_copy_constructible<int&>();
+ test_is_nothrow_copy_constructible<Union>();
+ test_is_nothrow_copy_constructible<Empty>();
+ test_is_nothrow_copy_constructible<int>();
+ test_is_nothrow_copy_constructible<double>();
+ test_is_nothrow_copy_constructible<int*>();
+ test_is_nothrow_copy_constructible<const int*>();
+ test_is_nothrow_copy_constructible<bit_zero>();
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_default_constructible.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_default_constructible.pass.cpp
new file mode 100644
index 000000000000..1550dff08bb5
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_default_constructible.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_nothrow_default_constructible
+
+#include <type_traits>
+
+template <class T>
+void test_is_nothrow_default_constructible()
+{
+ static_assert( std::is_nothrow_default_constructible<T>::value, "");
+ static_assert( std::is_nothrow_default_constructible<const T>::value, "");
+ static_assert( std::is_nothrow_default_constructible<volatile T>::value, "");
+ static_assert( std::is_nothrow_default_constructible<const volatile T>::value, "");
+}
+
+template <class T>
+void test_has_not_nothrow_default_constructor()
+{
+ static_assert(!std::is_nothrow_default_constructible<T>::value, "");
+ static_assert(!std::is_nothrow_default_constructible<const T>::value, "");
+ static_assert(!std::is_nothrow_default_constructible<volatile T>::value, "");
+ static_assert(!std::is_nothrow_default_constructible<const volatile T>::value, "");
+}
+
+class Empty
+{
+};
+
+union Union {};
+
+struct bit_zero
+{
+ int : 0;
+};
+
+struct A
+{
+ A();
+};
+
+int main()
+{
+ test_has_not_nothrow_default_constructor<void>();
+ test_has_not_nothrow_default_constructor<int&>();
+ test_has_not_nothrow_default_constructor<A>();
+
+ test_is_nothrow_default_constructible<Union>();
+ test_is_nothrow_default_constructible<Empty>();
+ test_is_nothrow_default_constructible<int>();
+ test_is_nothrow_default_constructible<double>();
+ test_is_nothrow_default_constructible<int*>();
+ test_is_nothrow_default_constructible<const int*>();
+ test_is_nothrow_default_constructible<char[3]>();
+ test_is_nothrow_default_constructible<bit_zero>();
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_destructible.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_destructible.pass.cpp
new file mode 100644
index 000000000000..8fd5bab5a019
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_destructible.pass.cpp
@@ -0,0 +1,91 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_nothrow_destructible
+
+#include <type_traits>
+
+template <class T>
+void test_is_nothrow_destructible()
+{
+ static_assert( std::is_nothrow_destructible<T>::value, "");
+ static_assert( std::is_nothrow_destructible<const T>::value, "");
+ static_assert( std::is_nothrow_destructible<volatile T>::value, "");
+ static_assert( std::is_nothrow_destructible<const volatile T>::value, "");
+}
+
+template <class T>
+void test_is_not_nothrow_destructible()
+{
+ static_assert(!std::is_nothrow_destructible<T>::value, "");
+ static_assert(!std::is_nothrow_destructible<const T>::value, "");
+ static_assert(!std::is_nothrow_destructible<volatile T>::value, "");
+ static_assert(!std::is_nothrow_destructible<const volatile T>::value, "");
+}
+
+class Empty
+{
+};
+
+class NotEmpty
+{
+ virtual ~NotEmpty();
+};
+
+union Union {};
+
+struct bit_zero
+{
+ int : 0;
+};
+
+class Abstract
+{
+ virtual void foo() = 0;
+};
+
+class AbstractDestructor
+{
+ virtual ~AbstractDestructor() = 0;
+};
+
+struct A
+{
+ ~A();
+};
+
+int main()
+{
+ test_is_not_nothrow_destructible<void>();
+ test_is_not_nothrow_destructible<AbstractDestructor>();
+ test_is_not_nothrow_destructible<NotEmpty>();
+ test_is_not_nothrow_destructible<char[]>();
+
+#if __has_feature(cxx_noexcept)
+ test_is_nothrow_destructible<A>();
+#endif
+ test_is_nothrow_destructible<int&>();
+#if __has_feature(cxx_unrestricted_unions)
+ test_is_nothrow_destructible<Union>();
+#endif
+#if __has_feature(cxx_access_control_sfinae)
+ test_is_nothrow_destructible<Empty>();
+#endif
+ test_is_nothrow_destructible<int>();
+ test_is_nothrow_destructible<double>();
+ test_is_nothrow_destructible<int*>();
+ test_is_nothrow_destructible<const int*>();
+ test_is_nothrow_destructible<char[3]>();
+ test_is_nothrow_destructible<Abstract>();
+#if __has_feature(cxx_noexcept)
+ test_is_nothrow_destructible<bit_zero>();
+#endif
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_move_assignable.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_move_assignable.pass.cpp
new file mode 100644
index 000000000000..fe51e438864f
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_move_assignable.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// has_nothrow_move_assign
+
+#include <type_traits>
+
+template <class T>
+void test_has_nothrow_assign()
+{
+ static_assert( std::is_nothrow_move_assignable<T>::value, "");
+}
+
+template <class T>
+void test_has_not_nothrow_assign()
+{
+ static_assert(!std::is_nothrow_move_assignable<T>::value, "");
+}
+
+class Empty
+{
+};
+
+struct NotEmpty
+{
+ virtual ~NotEmpty();
+};
+
+union Union {};
+
+struct bit_zero
+{
+ int : 0;
+};
+
+struct A
+{
+ A& operator=(const A&);
+};
+
+int main()
+{
+ test_has_nothrow_assign<int&>();
+ test_has_nothrow_assign<Union>();
+ test_has_nothrow_assign<Empty>();
+ test_has_nothrow_assign<int>();
+ test_has_nothrow_assign<double>();
+ test_has_nothrow_assign<int*>();
+ test_has_nothrow_assign<const int*>();
+ test_has_nothrow_assign<NotEmpty>();
+ test_has_nothrow_assign<bit_zero>();
+
+ test_has_not_nothrow_assign<void>();
+ test_has_not_nothrow_assign<A>();
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_move_constructible.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_move_constructible.pass.cpp
new file mode 100644
index 000000000000..f5a42afe0d50
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_move_constructible.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// has_nothrow_move_constructor
+
+#include <type_traits>
+
+template <class T>
+void test_is_nothrow_move_constructible()
+{
+ static_assert( std::is_nothrow_move_constructible<T>::value, "");
+ static_assert( std::is_nothrow_move_constructible<const T>::value, "");
+}
+
+template <class T>
+void test_has_not_nothrow_move_constructor()
+{
+ static_assert(!std::is_nothrow_move_constructible<T>::value, "");
+ static_assert(!std::is_nothrow_move_constructible<const T>::value, "");
+ static_assert(!std::is_nothrow_move_constructible<volatile T>::value, "");
+ static_assert(!std::is_nothrow_move_constructible<const volatile T>::value, "");
+}
+
+class Empty
+{
+};
+
+union Union {};
+
+struct bit_zero
+{
+ int : 0;
+};
+
+struct A
+{
+ A(const A&);
+};
+
+int main()
+{
+ test_has_not_nothrow_move_constructor<void>();
+ test_has_not_nothrow_move_constructor<A>();
+
+ test_is_nothrow_move_constructible<int&>();
+ test_is_nothrow_move_constructible<Union>();
+ test_is_nothrow_move_constructible<Empty>();
+ test_is_nothrow_move_constructible<int>();
+ test_is_nothrow_move_constructible<double>();
+ test_is_nothrow_move_constructible<int*>();
+ test_is_nothrow_move_constructible<const int*>();
+ test_is_nothrow_move_constructible<bit_zero>();
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_pod.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_pod.pass.cpp
new file mode 100644
index 000000000000..4ec1ae9949ef
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_pod.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_pod
+
+#include <type_traits>
+
+template <class T>
+void test_is_pod()
+{
+ static_assert( std::is_pod<T>::value, "");
+ static_assert( std::is_pod<const T>::value, "");
+ static_assert( std::is_pod<volatile T>::value, "");
+ static_assert( std::is_pod<const volatile T>::value, "");
+}
+
+template <class T>
+void test_is_not_pod()
+{
+ static_assert(!std::is_pod<T>::value, "");
+ static_assert(!std::is_pod<const T>::value, "");
+ static_assert(!std::is_pod<volatile T>::value, "");
+ static_assert(!std::is_pod<const volatile T>::value, "");
+}
+
+class Class
+{
+public:
+ ~Class();
+};
+
+int main()
+{
+ test_is_not_pod<void>();
+ test_is_not_pod<int&>();
+ test_is_not_pod<Class>();
+
+ test_is_pod<int>();
+ test_is_pod<double>();
+ test_is_pod<int*>();
+ test_is_pod<const int*>();
+ test_is_pod<char[3]>();
+ test_is_pod<char[]>();
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_polymorphic.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_polymorphic.pass.cpp
new file mode 100644
index 000000000000..6e82cddc5166
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_polymorphic.pass.cpp
@@ -0,0 +1,82 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_polymorphic
+
+#include <type_traits>
+
+template <class T>
+void test_is_polymorphic()
+{
+ static_assert( std::is_polymorphic<T>::value, "");
+ static_assert( std::is_polymorphic<const T>::value, "");
+ static_assert( std::is_polymorphic<volatile T>::value, "");
+ static_assert( std::is_polymorphic<const volatile T>::value, "");
+}
+
+template <class T>
+void test_is_not_polymorphic()
+{
+ static_assert(!std::is_polymorphic<T>::value, "");
+ static_assert(!std::is_polymorphic<const T>::value, "");
+ static_assert(!std::is_polymorphic<volatile T>::value, "");
+ static_assert(!std::is_polymorphic<const volatile T>::value, "");
+}
+
+class Empty
+{
+};
+
+class NotEmpty
+{
+ virtual ~NotEmpty();
+};
+
+union Union {};
+
+struct bit_zero
+{
+ int : 0;
+};
+
+class Abstract
+{
+ virtual ~Abstract() = 0;
+};
+
+#if __has_feature(cxx_attributes)
+class Final final {
+};
+#else
+class Final {
+};
+#endif
+
+int main()
+{
+ test_is_not_polymorphic<void>();
+ test_is_not_polymorphic<int&>();
+ test_is_not_polymorphic<int>();
+ test_is_not_polymorphic<double>();
+ test_is_not_polymorphic<int*>();
+ test_is_not_polymorphic<const int*>();
+ test_is_not_polymorphic<char[3]>();
+ test_is_not_polymorphic<char[]>();
+ test_is_not_polymorphic<Union>();
+ test_is_not_polymorphic<Empty>();
+ test_is_not_polymorphic<bit_zero>();
+ test_is_not_polymorphic<Final>();
+ test_is_not_polymorphic<NotEmpty&>();
+ test_is_not_polymorphic<Abstract&>();
+
+ test_is_polymorphic<NotEmpty>();
+ test_is_polymorphic<Abstract>();
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_signed.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_signed.pass.cpp
new file mode 100644
index 000000000000..479c2529f02a
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_signed.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_signed
+
+#include <type_traits>
+
+template <class T>
+void test_is_signed()
+{
+ static_assert( std::is_signed<T>::value, "");
+ static_assert( std::is_signed<const T>::value, "");
+ static_assert( std::is_signed<volatile T>::value, "");
+ static_assert( std::is_signed<const volatile T>::value, "");
+}
+
+template <class T>
+void test_is_not_signed()
+{
+ static_assert(!std::is_signed<T>::value, "");
+ static_assert(!std::is_signed<const T>::value, "");
+ static_assert(!std::is_signed<volatile T>::value, "");
+ static_assert(!std::is_signed<const volatile T>::value, "");
+}
+
+class Class
+{
+public:
+ ~Class();
+};
+
+int main()
+{
+ test_is_not_signed<void>();
+ test_is_not_signed<int&>();
+ test_is_not_signed<Class>();
+ test_is_not_signed<int*>();
+ test_is_not_signed<const int*>();
+ test_is_not_signed<char[3]>();
+ test_is_not_signed<char[]>();
+ test_is_not_signed<bool>();
+ test_is_not_signed<unsigned>();
+
+ test_is_signed<int>();
+ test_is_signed<double>();
+
+#ifndef _LIBCPP_HAS_NO_INT128
+ test_is_signed<__int128_t>();
+ test_is_not_signed<__uint128_t>();
+#endif
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_standard_layout.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_standard_layout.pass.cpp
new file mode 100644
index 000000000000..668c4cdc7dd6
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_standard_layout.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_standard_layout
+
+#include <type_traits>
+
+template <class T>
+void test_is_standard_layout()
+{
+ static_assert( std::is_standard_layout<T>::value, "");
+ static_assert( std::is_standard_layout<const T>::value, "");
+ static_assert( std::is_standard_layout<volatile T>::value, "");
+ static_assert( std::is_standard_layout<const volatile T>::value, "");
+}
+
+template <class T>
+void test_is_not_standard_layout()
+{
+ static_assert(!std::is_standard_layout<T>::value, "");
+ static_assert(!std::is_standard_layout<const T>::value, "");
+ static_assert(!std::is_standard_layout<volatile T>::value, "");
+ static_assert(!std::is_standard_layout<const volatile T>::value, "");
+}
+
+template <class T1, class T2>
+struct pair
+{
+ T1 first;
+ T2 second;
+};
+
+int main()
+{
+ test_is_standard_layout<int> ();
+ test_is_standard_layout<int[3]> ();
+ test_is_standard_layout<pair<int, double> > ();
+
+ test_is_not_standard_layout<int&> ();
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivial.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivial.pass.cpp
new file mode 100644
index 000000000000..af38699d881b
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivial.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_trivial
+
+#include <type_traits>
+
+template <class T>
+void test_is_trivial()
+{
+ static_assert( std::is_trivial<T>::value, "");
+ static_assert( std::is_trivial<const T>::value, "");
+ static_assert( std::is_trivial<volatile T>::value, "");
+ static_assert( std::is_trivial<const volatile T>::value, "");
+}
+
+template <class T>
+void test_is_not_trivial()
+{
+ static_assert(!std::is_trivial<T>::value, "");
+ static_assert(!std::is_trivial<const T>::value, "");
+ static_assert(!std::is_trivial<volatile T>::value, "");
+ static_assert(!std::is_trivial<const volatile T>::value, "");
+}
+
+struct A {};
+
+class B
+{
+public:
+ B();
+};
+
+int main()
+{
+ test_is_trivial<int> ();
+ test_is_trivial<A> ();
+
+ test_is_not_trivial<int&> ();
+ test_is_not_trivial<volatile int&> ();
+ test_is_not_trivial<B> ();
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_assignable.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_assignable.pass.cpp
new file mode 100644
index 000000000000..735d05fa6ee4
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_assignable.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_trivially_assignable
+
+#include <type_traits>
+
+template <class T, class U>
+void test_is_trivially_assignable()
+{
+ static_assert(( std::is_trivially_assignable<T, U>::value), "");
+}
+
+template <class T, class U>
+void test_is_not_trivially_assignable()
+{
+ static_assert((!std::is_trivially_assignable<T, U>::value), "");
+}
+
+struct A
+{
+};
+
+struct B
+{
+ void operator=(A);
+};
+
+struct C
+{
+ void operator=(C&); // not const
+};
+
+int main()
+{
+ test_is_trivially_assignable<int&, int&> ();
+ test_is_trivially_assignable<int&, int> ();
+ test_is_trivially_assignable<int&, double> ();
+
+ test_is_not_trivially_assignable<int, int&> ();
+ test_is_not_trivially_assignable<int, int> ();
+ test_is_not_trivially_assignable<B, A> ();
+ test_is_not_trivially_assignable<A, B> ();
+ test_is_not_trivially_assignable<C&, C&> ();
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_constructible.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_constructible.pass.cpp
new file mode 100644
index 000000000000..4171d4d32f5d
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_constructible.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// template <class T, class... Args>
+// struct is_trivially_constructible;
+
+#include <type_traits>
+
+template <class T>
+void test_is_trivially_constructible()
+{
+ static_assert(( std::is_trivially_constructible<T>::value), "");
+}
+
+template <class T, class A0>
+void test_is_trivially_constructible()
+{
+ static_assert(( std::is_trivially_constructible<T, A0>::value), "");
+}
+
+template <class T>
+void test_is_not_trivially_constructible()
+{
+ static_assert((!std::is_trivially_constructible<T>::value), "");
+}
+
+template <class T, class A0>
+void test_is_not_trivially_constructible()
+{
+ static_assert((!std::is_trivially_constructible<T, A0>::value), "");
+}
+
+template <class T, class A0, class A1>
+void test_is_not_trivially_constructible()
+{
+ static_assert((!std::is_trivially_constructible<T, A0, A1>::value), "");
+}
+
+struct A
+{
+ explicit A(int);
+ A(int, double);
+};
+
+int main()
+{
+ test_is_trivially_constructible<int> ();
+ test_is_trivially_constructible<int, const int&> ();
+
+ test_is_not_trivially_constructible<A, int> ();
+ test_is_not_trivially_constructible<A, int, double> ();
+ test_is_not_trivially_constructible<A> ();
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copy_assignable.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copy_assignable.pass.cpp
new file mode 100644
index 000000000000..7d72565e40ca
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copy_assignable.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_trivially_copy_assignable
+
+#include <type_traits>
+
+template <class T>
+void test_has_trivially_copy_assignable()
+{
+ static_assert( std::is_trivially_copy_assignable<T>::value, "");
+}
+
+template <class T>
+void test_has_not_trivially_copy_assignable()
+{
+ static_assert(!std::is_trivially_copy_assignable<T>::value, "");
+}
+
+class Empty
+{
+};
+
+class NotEmpty
+{
+ virtual ~NotEmpty();
+};
+
+union Union {};
+
+struct bit_zero
+{
+ int : 0;
+};
+
+class Abstract
+{
+ virtual ~Abstract() = 0;
+};
+
+struct A
+{
+ A& operator=(const A&);
+};
+
+int main()
+{
+ test_has_trivially_copy_assignable<int&>();
+ test_has_trivially_copy_assignable<Union>();
+ test_has_trivially_copy_assignable<Empty>();
+ test_has_trivially_copy_assignable<int>();
+ test_has_trivially_copy_assignable<double>();
+ test_has_trivially_copy_assignable<int*>();
+ test_has_trivially_copy_assignable<const int*>();
+ test_has_trivially_copy_assignable<bit_zero>();
+
+ test_has_not_trivially_copy_assignable<void>();
+ test_has_not_trivially_copy_assignable<A>();
+ test_has_not_trivially_copy_assignable<NotEmpty>();
+ test_has_not_trivially_copy_assignable<Abstract>();
+ test_has_not_trivially_copy_assignable<const Empty>();
+
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copy_constructible.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copy_constructible.pass.cpp
new file mode 100644
index 000000000000..6bd78ec9e7a1
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copy_constructible.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_trivially_copy_constructible
+
+#include <type_traits>
+
+template <class T>
+void test_is_trivially_copy_constructible()
+{
+ static_assert( std::is_trivially_copy_constructible<T>::value, "");
+ static_assert( std::is_trivially_copy_constructible<const T>::value, "");
+}
+
+template <class T>
+void test_has_not_trivial_copy_constructor()
+{
+ static_assert(!std::is_trivially_copy_constructible<T>::value, "");
+ static_assert(!std::is_trivially_copy_constructible<const T>::value, "");
+}
+
+class Empty
+{
+};
+
+class NotEmpty
+{
+public:
+ virtual ~NotEmpty();
+};
+
+union Union {};
+
+struct bit_zero
+{
+ int : 0;
+};
+
+class Abstract
+{
+public:
+ virtual ~Abstract() = 0;
+};
+
+struct A
+{
+ A(const A&);
+};
+
+int main()
+{
+ test_has_not_trivial_copy_constructor<void>();
+ test_has_not_trivial_copy_constructor<A>();
+ test_has_not_trivial_copy_constructor<Abstract>();
+ test_has_not_trivial_copy_constructor<NotEmpty>();
+
+ test_is_trivially_copy_constructible<int&>();
+ test_is_trivially_copy_constructible<Union>();
+ test_is_trivially_copy_constructible<Empty>();
+ test_is_trivially_copy_constructible<int>();
+ test_is_trivially_copy_constructible<double>();
+ test_is_trivially_copy_constructible<int*>();
+ test_is_trivially_copy_constructible<const int*>();
+ test_is_trivially_copy_constructible<bit_zero>();
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copyable.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copyable.pass.cpp
new file mode 100644
index 000000000000..d65882378fc4
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copyable.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_trivially_copyable
+
+#include <type_traits>
+#include <cassert>
+
+template <class T>
+void test_is_trivially_copyable()
+{
+ static_assert( std::is_trivially_copyable<T>::value, "");
+ static_assert( std::is_trivially_copyable<const T>::value, "");
+ static_assert(!std::is_trivially_copyable<volatile T>::value, "");
+ static_assert(!std::is_trivially_copyable<const volatile T>::value, "");
+}
+
+template <class T>
+void test_is_not_trivially_copyable()
+{
+ static_assert(!std::is_trivially_copyable<T>::value, "");
+ static_assert(!std::is_trivially_copyable<const T>::value, "");
+ static_assert(!std::is_trivially_copyable<volatile T>::value, "");
+ static_assert(!std::is_trivially_copyable<const volatile T>::value, "");
+}
+
+struct A
+{
+ int i_;
+};
+
+struct B
+{
+ int i_;
+ ~B() {assert(i_ == 0);}
+};
+
+class C
+{
+public:
+ C();
+};
+
+int main()
+{
+ test_is_trivially_copyable<int> ();
+ test_is_trivially_copyable<const int> ();
+ test_is_trivially_copyable<A> ();
+ test_is_trivially_copyable<const A> ();
+ test_is_trivially_copyable<C> ();
+
+ test_is_not_trivially_copyable<int&> ();
+ test_is_not_trivially_copyable<const A&> ();
+ test_is_not_trivially_copyable<B> ();
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_default_constructible.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_default_constructible.pass.cpp
new file mode 100644
index 000000000000..1f63401dacb7
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_default_constructible.pass.cpp
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_trivially_default_constructible
+
+#include <type_traits>
+
+template <class T>
+void test_is_trivially_default_constructible()
+{
+ static_assert( std::is_trivially_default_constructible<T>::value, "");
+ static_assert( std::is_trivially_default_constructible<const T>::value, "");
+ static_assert( std::is_trivially_default_constructible<volatile T>::value, "");
+ static_assert( std::is_trivially_default_constructible<const volatile T>::value, "");
+}
+
+template <class T>
+void test_has_not_trivial_default_constructor()
+{
+ static_assert(!std::is_trivially_default_constructible<T>::value, "");
+ static_assert(!std::is_trivially_default_constructible<const T>::value, "");
+ static_assert(!std::is_trivially_default_constructible<volatile T>::value, "");
+ static_assert(!std::is_trivially_default_constructible<const volatile T>::value, "");
+}
+
+class Empty
+{
+};
+
+class NotEmpty
+{
+ virtual ~NotEmpty();
+};
+
+union Union {};
+
+struct bit_zero
+{
+ int : 0;
+};
+
+class Abstract
+{
+ virtual ~Abstract() = 0;
+};
+
+struct A
+{
+ A();
+};
+
+int main()
+{
+ test_has_not_trivial_default_constructor<void>();
+ test_has_not_trivial_default_constructor<int&>();
+ test_has_not_trivial_default_constructor<A>();
+ test_has_not_trivial_default_constructor<Abstract>();
+ test_has_not_trivial_default_constructor<NotEmpty>();
+
+ test_is_trivially_default_constructible<Union>();
+ test_is_trivially_default_constructible<Empty>();
+ test_is_trivially_default_constructible<int>();
+ test_is_trivially_default_constructible<double>();
+ test_is_trivially_default_constructible<int*>();
+ test_is_trivially_default_constructible<const int*>();
+ test_is_trivially_default_constructible<char[3]>();
+ test_is_trivially_default_constructible<bit_zero>();
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_destructible.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_destructible.pass.cpp
new file mode 100644
index 000000000000..b18ace44bda1
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_destructible.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_trivially_destructible
+
+#include <type_traits>
+
+template <class T>
+void test_is_trivially_destructible()
+{
+ static_assert( std::is_trivially_destructible<T>::value, "");
+ static_assert( std::is_trivially_destructible<const T>::value, "");
+ static_assert( std::is_trivially_destructible<volatile T>::value, "");
+ static_assert( std::is_trivially_destructible<const volatile T>::value, "");
+}
+
+template <class T>
+void test_is_not_trivially_destructible()
+{
+ static_assert(!std::is_trivially_destructible<T>::value, "");
+ static_assert(!std::is_trivially_destructible<const T>::value, "");
+ static_assert(!std::is_trivially_destructible<volatile T>::value, "");
+ static_assert(!std::is_trivially_destructible<const volatile T>::value, "");
+}
+
+class Empty
+{
+};
+
+class NotEmpty
+{
+ virtual ~NotEmpty();
+};
+
+union Union {};
+
+struct bit_zero
+{
+ int : 0;
+};
+
+class Abstract
+{
+ virtual void foo() = 0;
+};
+
+class AbstractDestructor
+{
+ virtual ~AbstractDestructor() = 0;
+};
+
+struct A
+{
+ ~A();
+};
+
+int main()
+{
+ test_is_not_trivially_destructible<void>();
+ test_is_not_trivially_destructible<A>();
+ test_is_not_trivially_destructible<AbstractDestructor>();
+ test_is_not_trivially_destructible<NotEmpty>();
+ test_is_not_trivially_destructible<char[]>();
+
+ test_is_trivially_destructible<Abstract>();
+ test_is_trivially_destructible<int&>();
+ test_is_trivially_destructible<Union>();
+ test_is_trivially_destructible<Empty>();
+ test_is_trivially_destructible<int>();
+ test_is_trivially_destructible<double>();
+ test_is_trivially_destructible<int*>();
+ test_is_trivially_destructible<const int*>();
+ test_is_trivially_destructible<char[3]>();
+ test_is_trivially_destructible<bit_zero>();
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_move_assignable.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_move_assignable.pass.cpp
new file mode 100644
index 000000000000..c3fc7ac0a3df
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_move_assignable.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_trivially_move_assignable
+
+#include <type_traits>
+
+template <class T>
+void test_has_trivial_assign()
+{
+ static_assert( std::is_trivially_move_assignable<T>::value, "");
+}
+
+template <class T>
+void test_has_not_trivial_assign()
+{
+ static_assert(!std::is_trivially_move_assignable<T>::value, "");
+}
+
+class Empty
+{
+};
+
+class NotEmpty
+{
+ virtual ~NotEmpty();
+};
+
+union Union {};
+
+struct bit_zero
+{
+ int : 0;
+};
+
+class Abstract
+{
+ virtual ~Abstract() = 0;
+};
+
+struct A
+{
+ A& operator=(const A&);
+};
+
+int main()
+{
+ test_has_trivial_assign<int&>();
+ test_has_trivial_assign<Union>();
+ test_has_trivial_assign<Empty>();
+ test_has_trivial_assign<int>();
+ test_has_trivial_assign<double>();
+ test_has_trivial_assign<int*>();
+ test_has_trivial_assign<const int*>();
+ test_has_trivial_assign<bit_zero>();
+
+ test_has_not_trivial_assign<void>();
+ test_has_not_trivial_assign<A>();
+ test_has_not_trivial_assign<NotEmpty>();
+ test_has_not_trivial_assign<Abstract>();
+ test_has_not_trivial_assign<const Empty>();
+
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_move_constructible.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_move_constructible.pass.cpp
new file mode 100644
index 000000000000..54cb5e853a81
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_move_constructible.pass.cpp
@@ -0,0 +1,89 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_trivially_move_constructible
+
+#include <type_traits>
+
+template <class T>
+void test_is_trivially_move_constructible()
+{
+ static_assert( std::is_trivially_move_constructible<T>::value, "");
+}
+
+template <class T>
+void test_has_not_trivial_move_constructor()
+{
+ static_assert(!std::is_trivially_move_constructible<T>::value, "");
+}
+
+class Empty
+{
+};
+
+class NotEmpty
+{
+public:
+ virtual ~NotEmpty();
+};
+
+union Union {};
+
+struct bit_zero
+{
+ int : 0;
+};
+
+class Abstract
+{
+public:
+ virtual ~Abstract() = 0;
+};
+
+struct A
+{
+ A(const A&);
+};
+
+#if __has_feature(cxx_defaulted_functions)
+
+struct MoveOnly1
+{
+ MoveOnly1(MoveOnly1&&);
+};
+
+struct MoveOnly2
+{
+ MoveOnly2(MoveOnly2&&) = default;
+};
+
+#endif
+
+int main()
+{
+ test_has_not_trivial_move_constructor<void>();
+ test_has_not_trivial_move_constructor<A>();
+ test_has_not_trivial_move_constructor<Abstract>();
+ test_has_not_trivial_move_constructor<NotEmpty>();
+
+ test_is_trivially_move_constructible<Union>();
+ test_is_trivially_move_constructible<Empty>();
+ test_is_trivially_move_constructible<int>();
+ test_is_trivially_move_constructible<double>();
+ test_is_trivially_move_constructible<int*>();
+ test_is_trivially_move_constructible<const int*>();
+ test_is_trivially_move_constructible<bit_zero>();
+
+#if __has_feature(cxx_defaulted_functions)
+ static_assert(!std::is_trivially_move_constructible<MoveOnly1>::value, "");
+ static_assert( std::is_trivially_move_constructible<MoveOnly2>::value, "");
+#endif
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_unsigned.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_unsigned.pass.cpp
new file mode 100644
index 000000000000..dfdb15542610
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_unsigned.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_unsigned
+
+#include <type_traits>
+
+template <class T>
+void test_is_unsigned()
+{
+ static_assert( std::is_unsigned<T>::value, "");
+ static_assert( std::is_unsigned<const T>::value, "");
+ static_assert( std::is_unsigned<volatile T>::value, "");
+ static_assert( std::is_unsigned<const volatile T>::value, "");
+}
+
+template <class T>
+void test_is_not_unsigned()
+{
+ static_assert(!std::is_unsigned<T>::value, "");
+ static_assert(!std::is_unsigned<const T>::value, "");
+ static_assert(!std::is_unsigned<volatile T>::value, "");
+ static_assert(!std::is_unsigned<const volatile T>::value, "");
+}
+
+class Class
+{
+public:
+ ~Class();
+};
+
+int main()
+{
+ test_is_not_unsigned<void>();
+ test_is_not_unsigned<int&>();
+ test_is_not_unsigned<Class>();
+ test_is_not_unsigned<int*>();
+ test_is_not_unsigned<const int*>();
+ test_is_not_unsigned<char[3]>();
+ test_is_not_unsigned<char[]>();
+ test_is_not_unsigned<int>();
+ test_is_not_unsigned<double>();
+
+ test_is_unsigned<bool>();
+ test_is_unsigned<unsigned>();
+
+#ifndef _LIBCPP_HAS_NO_INT128
+ test_is_unsigned<__uint128_t>();
+ test_is_not_unsigned<__int128_t>();
+#endif
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_volatile.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_volatile.pass.cpp
new file mode 100644
index 000000000000..f6805bc1c4ff
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_volatile.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_volatile
+
+#include <type_traits>
+
+template <class T>
+void test_is_volatile()
+{
+ static_assert(!std::is_volatile<T>::value, "");
+ static_assert(!std::is_volatile<const T>::value, "");
+ static_assert( std::is_volatile<volatile T>::value, "");
+ static_assert( std::is_volatile<const volatile T>::value, "");
+}
+
+int main()
+{
+ test_is_volatile<void>();
+ test_is_volatile<int>();
+ test_is_volatile<double>();
+ test_is_volatile<int*>();
+ test_is_volatile<const int*>();
+ test_is_volatile<char[3]>();
+ test_is_volatile<char[]>();
+
+ static_assert(!std::is_volatile<int&>::value, "");
+ static_assert(!std::is_volatile<volatile int&>::value, "");
+}
diff --git a/test/std/utilities/meta/meta.unary/nothing_to_do.pass.cpp b/test/std/utilities/meta/meta.unary/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/utilities/meta/version.pass.cpp b/test/std/utilities/meta/version.pass.cpp
new file mode 100644
index 000000000000..3a1033bbb560
--- /dev/null
+++ b/test/std/utilities/meta/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <type_traits>
+
+#include <type_traits>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/utilities/nothing_to_do.pass.cpp b/test/std/utilities/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/utilities/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/utilities/ratio/ratio.arithmetic/ratio_add.fail.cpp b/test/std/utilities/ratio/ratio.arithmetic/ratio_add.fail.cpp
new file mode 100644
index 000000000000..e4ced3213293
--- /dev/null
+++ b/test/std/utilities/ratio/ratio.arithmetic/ratio_add.fail.cpp
@@ -0,0 +1,19 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test ratio_add
+
+#include <ratio>
+
+int main()
+{
+ typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1;
+ typedef std::ratio<1, 1> R2;
+ typedef std::ratio_add<R1, R2>::type R;
+}
diff --git a/test/std/utilities/ratio/ratio.arithmetic/ratio_add.pass.cpp b/test/std/utilities/ratio/ratio.arithmetic/ratio_add.pass.cpp
new file mode 100644
index 000000000000..a537f0215ca8
--- /dev/null
+++ b/test/std/utilities/ratio/ratio.arithmetic/ratio_add.pass.cpp
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test ratio_add
+
+#include <ratio>
+
+int main()
+{
+ {
+ typedef std::ratio<1, 1> R1;
+ typedef std::ratio<1, 1> R2;
+ typedef std::ratio_add<R1, R2>::type R;
+ static_assert(R::num == 2 && R::den == 1, "");
+ }
+ {
+ typedef std::ratio<1, 2> R1;
+ typedef std::ratio<1, 1> R2;
+ typedef std::ratio_add<R1, R2>::type R;
+ static_assert(R::num == 3 && R::den == 2, "");
+ }
+ {
+ typedef std::ratio<-1, 2> R1;
+ typedef std::ratio<1, 1> R2;
+ typedef std::ratio_add<R1, R2>::type R;
+ static_assert(R::num == 1 && R::den == 2, "");
+ }
+ {
+ typedef std::ratio<1, -2> R1;
+ typedef std::ratio<1, 1> R2;
+ typedef std::ratio_add<R1, R2>::type R;
+ static_assert(R::num == 1 && R::den == 2, "");
+ }
+ {
+ typedef std::ratio<1, 2> R1;
+ typedef std::ratio<-1, 1> R2;
+ typedef std::ratio_add<R1, R2>::type R;
+ static_assert(R::num == -1 && R::den == 2, "");
+ }
+ {
+ typedef std::ratio<1, 2> R1;
+ typedef std::ratio<1, -1> R2;
+ typedef std::ratio_add<R1, R2>::type R;
+ static_assert(R::num == -1 && R::den == 2, "");
+ }
+ {
+ typedef std::ratio<56987354, 467584654> R1;
+ typedef std::ratio<544668, 22145> R2;
+ typedef std::ratio_add<R1, R2>::type R;
+ static_assert(R::num == 127970191639601LL && R::den == 5177331081415LL, "");
+ }
+ {
+ typedef std::ratio<0> R1;
+ typedef std::ratio<0> R2;
+ typedef std::ratio_add<R1, R2>::type R;
+ static_assert(R::num == 0 && R::den == 1, "");
+ }
+ {
+ typedef std::ratio<1> R1;
+ typedef std::ratio<0> R2;
+ typedef std::ratio_add<R1, R2>::type R;
+ static_assert(R::num == 1 && R::den == 1, "");
+ }
+ {
+ typedef std::ratio<0> R1;
+ typedef std::ratio<1> R2;
+ typedef std::ratio_add<R1, R2>::type R;
+ static_assert(R::num == 1 && R::den == 1, "");
+ }
+}
diff --git a/test/std/utilities/ratio/ratio.arithmetic/ratio_divide.fail.cpp b/test/std/utilities/ratio/ratio.arithmetic/ratio_divide.fail.cpp
new file mode 100644
index 000000000000..bdbcda36fabc
--- /dev/null
+++ b/test/std/utilities/ratio/ratio.arithmetic/ratio_divide.fail.cpp
@@ -0,0 +1,19 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test ratio_divide
+
+#include <ratio>
+
+int main()
+{
+ typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1;
+ typedef std::ratio<1, 2> R2;
+ typedef std::ratio_divide<R1, R2>::type R;
+}
diff --git a/test/std/utilities/ratio/ratio.arithmetic/ratio_divide.pass.cpp b/test/std/utilities/ratio/ratio.arithmetic/ratio_divide.pass.cpp
new file mode 100644
index 000000000000..49b55e7a6ca8
--- /dev/null
+++ b/test/std/utilities/ratio/ratio.arithmetic/ratio_divide.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test ratio_divide
+
+#include <ratio>
+
+int main()
+{
+ {
+ typedef std::ratio<1, 1> R1;
+ typedef std::ratio<1, 1> R2;
+ typedef std::ratio_divide<R1, R2>::type R;
+ static_assert(R::num == 1 && R::den == 1, "");
+ }
+ {
+ typedef std::ratio<1, 2> R1;
+ typedef std::ratio<1, 1> R2;
+ typedef std::ratio_divide<R1, R2>::type R;
+ static_assert(R::num == 1 && R::den == 2, "");
+ }
+ {
+ typedef std::ratio<-1, 2> R1;
+ typedef std::ratio<1, 1> R2;
+ typedef std::ratio_divide<R1, R2>::type R;
+ static_assert(R::num == -1 && R::den == 2, "");
+ }
+ {
+ typedef std::ratio<1, -2> R1;
+ typedef std::ratio<1, 1> R2;
+ typedef std::ratio_divide<R1, R2>::type R;
+ static_assert(R::num == -1 && R::den == 2, "");
+ }
+ {
+ typedef std::ratio<1, 2> R1;
+ typedef std::ratio<-1, 1> R2;
+ typedef std::ratio_divide<R1, R2>::type R;
+ static_assert(R::num == -1 && R::den == 2, "");
+ }
+ {
+ typedef std::ratio<1, 2> R1;
+ typedef std::ratio<1, -1> R2;
+ typedef std::ratio_divide<R1, R2>::type R;
+ static_assert(R::num == -1 && R::den == 2, "");
+ }
+ {
+ typedef std::ratio<56987354, 467584654> R1;
+ typedef std::ratio<544668, 22145> R2;
+ typedef std::ratio_divide<R1, R2>::type R;
+ static_assert(R::num == 630992477165LL && R::den == 127339199162436LL, "");
+ }
+}
diff --git a/test/std/utilities/ratio/ratio.arithmetic/ratio_multiply.fail.cpp b/test/std/utilities/ratio/ratio.arithmetic/ratio_multiply.fail.cpp
new file mode 100644
index 000000000000..81acc14be14c
--- /dev/null
+++ b/test/std/utilities/ratio/ratio.arithmetic/ratio_multiply.fail.cpp
@@ -0,0 +1,19 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test ratio_multiply
+
+#include <ratio>
+
+int main()
+{
+ typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1;
+ typedef std::ratio<2, 1> R2;
+ typedef std::ratio_multiply<R1, R2>::type R;
+}
diff --git a/test/std/utilities/ratio/ratio.arithmetic/ratio_multiply.pass.cpp b/test/std/utilities/ratio/ratio.arithmetic/ratio_multiply.pass.cpp
new file mode 100644
index 000000000000..ccf15e07aed5
--- /dev/null
+++ b/test/std/utilities/ratio/ratio.arithmetic/ratio_multiply.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test ratio_multiply
+
+#include <ratio>
+
+int main()
+{
+ {
+ typedef std::ratio<1, 1> R1;
+ typedef std::ratio<1, 1> R2;
+ typedef std::ratio_multiply<R1, R2>::type R;
+ static_assert(R::num == 1 && R::den == 1, "");
+ }
+ {
+ typedef std::ratio<1, 2> R1;
+ typedef std::ratio<1, 1> R2;
+ typedef std::ratio_multiply<R1, R2>::type R;
+ static_assert(R::num == 1 && R::den == 2, "");
+ }
+ {
+ typedef std::ratio<-1, 2> R1;
+ typedef std::ratio<1, 1> R2;
+ typedef std::ratio_multiply<R1, R2>::type R;
+ static_assert(R::num == -1 && R::den == 2, "");
+ }
+ {
+ typedef std::ratio<1, -2> R1;
+ typedef std::ratio<1, 1> R2;
+ typedef std::ratio_multiply<R1, R2>::type R;
+ static_assert(R::num == -1 && R::den == 2, "");
+ }
+ {
+ typedef std::ratio<1, 2> R1;
+ typedef std::ratio<-1, 1> R2;
+ typedef std::ratio_multiply<R1, R2>::type R;
+ static_assert(R::num == -1 && R::den == 2, "");
+ }
+ {
+ typedef std::ratio<1, 2> R1;
+ typedef std::ratio<1, -1> R2;
+ typedef std::ratio_multiply<R1, R2>::type R;
+ static_assert(R::num == -1 && R::den == 2, "");
+ }
+ {
+ typedef std::ratio<56987354, 467584654> R1;
+ typedef std::ratio<544668, 22145> R2;
+ typedef std::ratio_multiply<R1, R2>::type R;
+ static_assert(R::num == 15519594064236LL && R::den == 5177331081415LL, "");
+ }
+}
diff --git a/test/std/utilities/ratio/ratio.arithmetic/ratio_subtract.fail.cpp b/test/std/utilities/ratio/ratio.arithmetic/ratio_subtract.fail.cpp
new file mode 100644
index 000000000000..b88314388333
--- /dev/null
+++ b/test/std/utilities/ratio/ratio.arithmetic/ratio_subtract.fail.cpp
@@ -0,0 +1,19 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test ratio_subtract
+
+#include <ratio>
+
+int main()
+{
+ typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R1;
+ typedef std::ratio<1, 1> R2;
+ typedef std::ratio_subtract<R1, R2>::type R;
+}
diff --git a/test/std/utilities/ratio/ratio.arithmetic/ratio_subtract.pass.cpp b/test/std/utilities/ratio/ratio.arithmetic/ratio_subtract.pass.cpp
new file mode 100644
index 000000000000..33efd90f5555
--- /dev/null
+++ b/test/std/utilities/ratio/ratio.arithmetic/ratio_subtract.pass.cpp
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test ratio_subtract
+
+#include <ratio>
+
+int main()
+{
+ {
+ typedef std::ratio<1, 1> R1;
+ typedef std::ratio<1, 1> R2;
+ typedef std::ratio_subtract<R1, R2>::type R;
+ static_assert(R::num == 0 && R::den == 1, "");
+ }
+ {
+ typedef std::ratio<1, 2> R1;
+ typedef std::ratio<1, 1> R2;
+ typedef std::ratio_subtract<R1, R2>::type R;
+ static_assert(R::num == -1 && R::den == 2, "");
+ }
+ {
+ typedef std::ratio<-1, 2> R1;
+ typedef std::ratio<1, 1> R2;
+ typedef std::ratio_subtract<R1, R2>::type R;
+ static_assert(R::num == -3 && R::den == 2, "");
+ }
+ {
+ typedef std::ratio<1, -2> R1;
+ typedef std::ratio<1, 1> R2;
+ typedef std::ratio_subtract<R1, R2>::type R;
+ static_assert(R::num == -3 && R::den == 2, "");
+ }
+ {
+ typedef std::ratio<1, 2> R1;
+ typedef std::ratio<-1, 1> R2;
+ typedef std::ratio_subtract<R1, R2>::type R;
+ static_assert(R::num == 3 && R::den == 2, "");
+ }
+ {
+ typedef std::ratio<1, 2> R1;
+ typedef std::ratio<1, -1> R2;
+ typedef std::ratio_subtract<R1, R2>::type R;
+ static_assert(R::num == 3 && R::den == 2, "");
+ }
+ {
+ typedef std::ratio<56987354, 467584654> R1;
+ typedef std::ratio<544668, 22145> R2;
+ typedef std::ratio_subtract<R1, R2>::type R;
+ static_assert(R::num == -126708206685271LL && R::den == 5177331081415LL, "");
+ }
+ {
+ typedef std::ratio<0> R1;
+ typedef std::ratio<0> R2;
+ typedef std::ratio_subtract<R1, R2>::type R;
+ static_assert(R::num == 0 && R::den == 1, "");
+ }
+ {
+ typedef std::ratio<1> R1;
+ typedef std::ratio<0> R2;
+ typedef std::ratio_subtract<R1, R2>::type R;
+ static_assert(R::num == 1 && R::den == 1, "");
+ }
+ {
+ typedef std::ratio<0> R1;
+ typedef std::ratio<1> R2;
+ typedef std::ratio_subtract<R1, R2>::type R;
+ static_assert(R::num == -1 && R::den == 1, "");
+ }
+}
diff --git a/test/std/utilities/ratio/ratio.comparison/ratio_equal.pass.cpp b/test/std/utilities/ratio/ratio.comparison/ratio_equal.pass.cpp
new file mode 100644
index 000000000000..78027f7e48b8
--- /dev/null
+++ b/test/std/utilities/ratio/ratio.comparison/ratio_equal.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test ratio_equal
+
+#include <ratio>
+
+int main()
+{
+ {
+ typedef std::ratio<1, 1> R1;
+ typedef std::ratio<1, 1> R2;
+ static_assert((std::ratio_equal<R1, R2>::value), "");
+ }
+ {
+ typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1;
+ typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R2;
+ static_assert((std::ratio_equal<R1, R2>::value), "");
+ }
+ {
+ typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R1;
+ typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R2;
+ static_assert((std::ratio_equal<R1, R2>::value), "");
+ }
+ {
+ typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R1;
+ typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R2;
+ static_assert((std::ratio_equal<R1, R2>::value), "");
+ }
+ {
+ typedef std::ratio<1, 1> R1;
+ typedef std::ratio<1, -1> R2;
+ static_assert((!std::ratio_equal<R1, R2>::value), "");
+ }
+ {
+ typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1;
+ typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R2;
+ static_assert((!std::ratio_equal<R1, R2>::value), "");
+ }
+ {
+ typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R1;
+ typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R2;
+ static_assert((!std::ratio_equal<R1, R2>::value), "");
+ }
+ {
+ typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R1;
+ typedef std::ratio<1, -0x7FFFFFFFFFFFFFFFLL> R2;
+ static_assert((!std::ratio_equal<R1, R2>::value), "");
+ }
+}
diff --git a/test/std/utilities/ratio/ratio.comparison/ratio_greater.pass.cpp b/test/std/utilities/ratio/ratio.comparison/ratio_greater.pass.cpp
new file mode 100644
index 000000000000..9182a9ec503c
--- /dev/null
+++ b/test/std/utilities/ratio/ratio.comparison/ratio_greater.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test ratio_greater
+
+#include <ratio>
+
+int main()
+{
+ {
+ typedef std::ratio<1, 1> R1;
+ typedef std::ratio<1, 1> R2;
+ static_assert((!std::ratio_greater<R1, R2>::value), "");
+ }
+ {
+ typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1;
+ typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R2;
+ static_assert((!std::ratio_greater<R1, R2>::value), "");
+ }
+ {
+ typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R1;
+ typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R2;
+ static_assert((!std::ratio_greater<R1, R2>::value), "");
+ }
+ {
+ typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R1;
+ typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R2;
+ static_assert((!std::ratio_greater<R1, R2>::value), "");
+ }
+ {
+ typedef std::ratio<1, 1> R1;
+ typedef std::ratio<1, -1> R2;
+ static_assert((std::ratio_greater<R1, R2>::value), "");
+ }
+ {
+ typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1;
+ typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R2;
+ static_assert((std::ratio_greater<R1, R2>::value), "");
+ }
+ {
+ typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R1;
+ typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R2;
+ static_assert((!std::ratio_greater<R1, R2>::value), "");
+ }
+ {
+ typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R1;
+ typedef std::ratio<1, -0x7FFFFFFFFFFFFFFFLL> R2;
+ static_assert((std::ratio_greater<R1, R2>::value), "");
+ }
+}
diff --git a/test/std/utilities/ratio/ratio.comparison/ratio_greater_equal.pass.cpp b/test/std/utilities/ratio/ratio.comparison/ratio_greater_equal.pass.cpp
new file mode 100644
index 000000000000..a1f5a185e621
--- /dev/null
+++ b/test/std/utilities/ratio/ratio.comparison/ratio_greater_equal.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test ratio_greater_equal
+
+#include <ratio>
+
+int main()
+{
+ {
+ typedef std::ratio<1, 1> R1;
+ typedef std::ratio<1, 1> R2;
+ static_assert((std::ratio_greater_equal<R1, R2>::value), "");
+ }
+ {
+ typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1;
+ typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R2;
+ static_assert((std::ratio_greater_equal<R1, R2>::value), "");
+ }
+ {
+ typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R1;
+ typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R2;
+ static_assert((std::ratio_greater_equal<R1, R2>::value), "");
+ }
+ {
+ typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R1;
+ typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R2;
+ static_assert((std::ratio_greater_equal<R1, R2>::value), "");
+ }
+ {
+ typedef std::ratio<1, 1> R1;
+ typedef std::ratio<1, -1> R2;
+ static_assert((std::ratio_greater_equal<R1, R2>::value), "");
+ }
+ {
+ typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1;
+ typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R2;
+ static_assert((std::ratio_greater_equal<R1, R2>::value), "");
+ }
+ {
+ typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R1;
+ typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R2;
+ static_assert((!std::ratio_greater_equal<R1, R2>::value), "");
+ }
+ {
+ typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R1;
+ typedef std::ratio<1, -0x7FFFFFFFFFFFFFFFLL> R2;
+ static_assert((std::ratio_greater_equal<R1, R2>::value), "");
+ }
+}
diff --git a/test/std/utilities/ratio/ratio.comparison/ratio_less.pass.cpp b/test/std/utilities/ratio/ratio.comparison/ratio_less.pass.cpp
new file mode 100644
index 000000000000..db53ab0ad448
--- /dev/null
+++ b/test/std/utilities/ratio/ratio.comparison/ratio_less.pass.cpp
@@ -0,0 +1,86 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test ratio_less
+
+#include <ratio>
+
+int main()
+{
+ {
+ typedef std::ratio<1, 1> R1;
+ typedef std::ratio<1, 1> R2;
+ static_assert((!std::ratio_less<R1, R2>::value), "");
+ }
+ {
+ typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1;
+ typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R2;
+ static_assert((!std::ratio_less<R1, R2>::value), "");
+ }
+ {
+ typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R1;
+ typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R2;
+ static_assert((!std::ratio_less<R1, R2>::value), "");
+ }
+ {
+ typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R1;
+ typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R2;
+ static_assert((!std::ratio_less<R1, R2>::value), "");
+ }
+ {
+ typedef std::ratio<1, 1> R1;
+ typedef std::ratio<1, -1> R2;
+ static_assert((!std::ratio_less<R1, R2>::value), "");
+ }
+ {
+ typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1;
+ typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R2;
+ static_assert((!std::ratio_less<R1, R2>::value), "");
+ }
+ {
+ typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R1;
+ typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R2;
+ static_assert((std::ratio_less<R1, R2>::value), "");
+ }
+ {
+ typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R1;
+ typedef std::ratio<1, -0x7FFFFFFFFFFFFFFFLL> R2;
+ static_assert((!std::ratio_less<R1, R2>::value), "");
+ }
+ {
+ typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 0x7FFFFFFFFFFFFFFELL> R1;
+ typedef std::ratio<0x7FFFFFFFFFFFFFFDLL, 0x7FFFFFFFFFFFFFFCLL> R2;
+ static_assert((std::ratio_less<R1, R2>::value), "");
+ }
+ {
+ typedef std::ratio<0x7FFFFFFFFFFFFFFDLL, 0x7FFFFFFFFFFFFFFCLL> R1;
+ typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 0x7FFFFFFFFFFFFFFELL> R2;
+ static_assert((!std::ratio_less<R1, R2>::value), "");
+ }
+ {
+ typedef std::ratio<-0x7FFFFFFFFFFFFFFDLL, 0x7FFFFFFFFFFFFFFCLL> R1;
+ typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 0x7FFFFFFFFFFFFFFELL> R2;
+ static_assert((std::ratio_less<R1, R2>::value), "");
+ }
+ {
+ typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 0x7FFFFFFFFFFFFFFELL> R1;
+ typedef std::ratio<0x7FFFFFFFFFFFFFFELL, 0x7FFFFFFFFFFFFFFDLL> R2;
+ static_assert((std::ratio_less<R1, R2>::value), "");
+ }
+ {
+ typedef std::ratio<641981, 1339063> R1;
+ typedef std::ratio<1291640, 2694141LL> R2;
+ static_assert((!std::ratio_less<R1, R2>::value), "");
+ }
+ {
+ typedef std::ratio<1291640, 2694141LL> R1;
+ typedef std::ratio<641981, 1339063> R2;
+ static_assert((std::ratio_less<R1, R2>::value), "");
+ }
+}
diff --git a/test/std/utilities/ratio/ratio.comparison/ratio_less_equal.pass.cpp b/test/std/utilities/ratio/ratio.comparison/ratio_less_equal.pass.cpp
new file mode 100644
index 000000000000..5b148f0e1435
--- /dev/null
+++ b/test/std/utilities/ratio/ratio.comparison/ratio_less_equal.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test ratio_less_equal
+
+#include <ratio>
+
+int main()
+{
+ {
+ typedef std::ratio<1, 1> R1;
+ typedef std::ratio<1, 1> R2;
+ static_assert((std::ratio_less_equal<R1, R2>::value), "");
+ }
+ {
+ typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1;
+ typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R2;
+ static_assert((std::ratio_less_equal<R1, R2>::value), "");
+ }
+ {
+ typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R1;
+ typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R2;
+ static_assert((std::ratio_less_equal<R1, R2>::value), "");
+ }
+ {
+ typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R1;
+ typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R2;
+ static_assert((std::ratio_less_equal<R1, R2>::value), "");
+ }
+ {
+ typedef std::ratio<1, 1> R1;
+ typedef std::ratio<1, -1> R2;
+ static_assert((!std::ratio_less_equal<R1, R2>::value), "");
+ }
+ {
+ typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1;
+ typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R2;
+ static_assert((!std::ratio_less_equal<R1, R2>::value), "");
+ }
+ {
+ typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R1;
+ typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R2;
+ static_assert((std::ratio_less_equal<R1, R2>::value), "");
+ }
+ {
+ typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R1;
+ typedef std::ratio<1, -0x7FFFFFFFFFFFFFFFLL> R2;
+ static_assert((!std::ratio_less_equal<R1, R2>::value), "");
+ }
+}
diff --git a/test/std/utilities/ratio/ratio.comparison/ratio_not_equal.pass.cpp b/test/std/utilities/ratio/ratio.comparison/ratio_not_equal.pass.cpp
new file mode 100644
index 000000000000..ebf930746585
--- /dev/null
+++ b/test/std/utilities/ratio/ratio.comparison/ratio_not_equal.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test ratio_not_equal
+
+#include <ratio>
+
+int main()
+{
+ {
+ typedef std::ratio<1, 1> R1;
+ typedef std::ratio<1, 1> R2;
+ static_assert((!std::ratio_not_equal<R1, R2>::value), "");
+ }
+ {
+ typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1;
+ typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R2;
+ static_assert((!std::ratio_not_equal<R1, R2>::value), "");
+ }
+ {
+ typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R1;
+ typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R2;
+ static_assert((!std::ratio_not_equal<R1, R2>::value), "");
+ }
+ {
+ typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R1;
+ typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R2;
+ static_assert((!std::ratio_not_equal<R1, R2>::value), "");
+ }
+ {
+ typedef std::ratio<1, 1> R1;
+ typedef std::ratio<1, -1> R2;
+ static_assert((std::ratio_not_equal<R1, R2>::value), "");
+ }
+ {
+ typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1;
+ typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R2;
+ static_assert((std::ratio_not_equal<R1, R2>::value), "");
+ }
+ {
+ typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R1;
+ typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R2;
+ static_assert((std::ratio_not_equal<R1, R2>::value), "");
+ }
+ {
+ typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R1;
+ typedef std::ratio<1, -0x7FFFFFFFFFFFFFFFLL> R2;
+ static_assert((std::ratio_not_equal<R1, R2>::value), "");
+ }
+}
diff --git a/test/std/utilities/ratio/ratio.ratio/ratio.pass.cpp b/test/std/utilities/ratio/ratio.ratio/ratio.pass.cpp
new file mode 100644
index 000000000000..a7326162f40a
--- /dev/null
+++ b/test/std/utilities/ratio/ratio.ratio/ratio.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test ratio: The static data members num and den shall have the common
+// divisor of the absolute values of N and D:
+
+#include <ratio>
+
+template <long long N, long long D, long long eN, long long eD>
+void test()
+{
+ static_assert((std::ratio<N, D>::num == eN), "");
+ static_assert((std::ratio<N, D>::den == eD), "");
+}
+
+int main()
+{
+ test<1, 1, 1, 1>();
+ test<1, 10, 1, 10>();
+ test<10, 10, 1, 1>();
+ test<10, 1, 10, 1>();
+ test<12, 4, 3, 1>();
+ test<12, -4, -3, 1>();
+ test<-12, 4, -3, 1>();
+ test<-12, -4, 3, 1>();
+ test<4, 12, 1, 3>();
+ test<4, -12, -1, 3>();
+ test<-4, 12, -1, 3>();
+ test<-4, -12, 1, 3>();
+ test<222, 333, 2, 3>();
+ test<222, -333, -2, 3>();
+ test<-222, 333, -2, 3>();
+ test<-222, -333, 2, 3>();
+ test<0x7FFFFFFFFFFFFFFFLL, 127, 72624976668147841LL, 1>();
+ test<-0x7FFFFFFFFFFFFFFFLL, 127, -72624976668147841LL, 1>();
+ test<0x7FFFFFFFFFFFFFFFLL, -127, -72624976668147841LL, 1>();
+ test<-0x7FFFFFFFFFFFFFFFLL, -127, 72624976668147841LL, 1>();
+}
diff --git a/test/std/utilities/ratio/ratio.ratio/ratio1.fail.cpp b/test/std/utilities/ratio/ratio.ratio/ratio1.fail.cpp
new file mode 100644
index 000000000000..e6dbf710b71a
--- /dev/null
+++ b/test/std/utilities/ratio/ratio.ratio/ratio1.fail.cpp
@@ -0,0 +1,18 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test ratio: The template argument D shall not be zero
+
+#include <ratio>
+#include <cstdint>
+
+int main()
+{
+ const std::intmax_t t1 = std::ratio<1, 0>::num;
+}
diff --git a/test/std/utilities/ratio/ratio.ratio/ratio2.fail.cpp b/test/std/utilities/ratio/ratio.ratio/ratio2.fail.cpp
new file mode 100644
index 000000000000..753e79af6d0d
--- /dev/null
+++ b/test/std/utilities/ratio/ratio.ratio/ratio2.fail.cpp
@@ -0,0 +1,19 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test ratio: the absolute values of the template arguments N and D
+// shall be representable by type intmax_t.
+
+#include <ratio>
+#include <cstdint>
+
+int main()
+{
+ const std::intmax_t t1 = std::ratio<0x8000000000000000ULL, 1>::num;
+}
diff --git a/test/std/utilities/ratio/ratio.ratio/ratio3.fail.cpp b/test/std/utilities/ratio/ratio.ratio/ratio3.fail.cpp
new file mode 100644
index 000000000000..f4b4ab950016
--- /dev/null
+++ b/test/std/utilities/ratio/ratio.ratio/ratio3.fail.cpp
@@ -0,0 +1,19 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test ratio: the absolute values of the template arguments N and D
+// shall be representable by type intmax_t.
+
+#include <ratio>
+#include <cstdint>
+
+int main()
+{
+ const std::intmax_t t1 = std::ratio<1, 0x8000000000000000ULL>::num;
+}
diff --git a/test/std/utilities/ratio/ratio.si/nothing_to_do.pass.cpp b/test/std/utilities/ratio/ratio.si/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/utilities/ratio/ratio.si/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/utilities/ratio/typedefs.pass.cpp b/test/std/utilities/ratio/typedefs.pass.cpp
new file mode 100644
index 000000000000..5ab4c740ddb6
--- /dev/null
+++ b/test/std/utilities/ratio/typedefs.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test ratio typedef's
+
+#include <ratio>
+
+int main()
+{
+ static_assert(std::atto::num == 1 && std::atto::den == 1000000000000000000ULL, "");
+ static_assert(std::femto::num == 1 && std::femto::den == 1000000000000000ULL, "");
+ static_assert(std::pico::num == 1 && std::pico::den == 1000000000000ULL, "");
+ static_assert(std::nano::num == 1 && std::nano::den == 1000000000ULL, "");
+ static_assert(std::micro::num == 1 && std::micro::den == 1000000ULL, "");
+ static_assert(std::milli::num == 1 && std::milli::den == 1000ULL, "");
+ static_assert(std::centi::num == 1 && std::centi::den == 100ULL, "");
+ static_assert(std::deci::num == 1 && std::deci::den == 10ULL, "");
+ static_assert(std::deca::num == 10ULL && std::deca::den == 1, "");
+ static_assert(std::hecto::num == 100ULL && std::hecto::den == 1, "");
+ static_assert(std::kilo::num == 1000ULL && std::kilo::den == 1, "");
+ static_assert(std::mega::num == 1000000ULL && std::mega::den == 1, "");
+ static_assert(std::giga::num == 1000000000ULL && std::giga::den == 1, "");
+ static_assert(std::tera::num == 1000000000000ULL && std::tera::den == 1, "");
+ static_assert(std::peta::num == 1000000000000000ULL && std::peta::den == 1, "");
+ static_assert(std::exa::num == 1000000000000000000ULL && std::exa::den == 1, "");
+}
diff --git a/test/std/utilities/ratio/version.pass.cpp b/test/std/utilities/ratio/version.pass.cpp
new file mode 100644
index 000000000000..26c455fb0a9a
--- /dev/null
+++ b/test/std/utilities/ratio/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ratio>
+
+#include <ratio>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/utilities/template.bitset/bitset.cons/char_ptr_ctor.pass.cpp b/test/std/utilities/template.bitset/bitset.cons/char_ptr_ctor.pass.cpp
new file mode 100644
index 000000000000..7fe78bad1cc6
--- /dev/null
+++ b/test/std/utilities/template.bitset/bitset.cons/char_ptr_ctor.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// template <class charT>
+// explicit bitset(const charT* str,
+// typename basic_string<charT>::size_type n = basic_string<charT>::npos,
+// charT zero = charT('0'), charT one = charT('1'));
+
+#include <bitset>
+#include <cassert>
+
+#pragma clang diagnostic ignored "-Wtautological-compare"
+
+template <std::size_t N>
+void test_char_pointer_ctor()
+{
+ {
+ try
+ {
+ std::bitset<N> v("xxx1010101010xxxx");
+ assert(false);
+ }
+ catch (std::invalid_argument&)
+ {
+ }
+ }
+
+ {
+ const char str[] ="1010101010";
+ std::bitset<N> v(str);
+ std::size_t M = std::min<std::size_t>(N, 10);
+ for (std::size_t i = 0; i < M; ++i)
+ assert(v[i] == (str[M - 1 - i] == '1'));
+ for (std::size_t i = 10; i < N; ++i)
+ assert(v[i] == false);
+ }
+}
+
+int main()
+{
+ test_char_pointer_ctor<0>();
+ test_char_pointer_ctor<1>();
+ test_char_pointer_ctor<31>();
+ test_char_pointer_ctor<32>();
+ test_char_pointer_ctor<33>();
+ test_char_pointer_ctor<63>();
+ test_char_pointer_ctor<64>();
+ test_char_pointer_ctor<65>();
+ test_char_pointer_ctor<1000>();
+}
diff --git a/test/std/utilities/template.bitset/bitset.cons/default.pass.cpp b/test/std/utilities/template.bitset/bitset.cons/default.pass.cpp
new file mode 100644
index 000000000000..bd5ca7e08b2a
--- /dev/null
+++ b/test/std/utilities/template.bitset/bitset.cons/default.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test default ctor
+
+#include <bitset>
+#include <cassert>
+
+#pragma clang diagnostic ignored "-Wtautological-compare"
+
+template <std::size_t N>
+void test_default_ctor()
+{
+ {
+ _LIBCPP_CONSTEXPR std::bitset<N> v1;
+ assert(v1.size() == N);
+ for (std::size_t i = 0; i < N; ++i)
+ assert(v1[i] == false);
+ }
+}
+
+int main()
+{
+ test_default_ctor<0>();
+ test_default_ctor<1>();
+ test_default_ctor<31>();
+ test_default_ctor<32>();
+ test_default_ctor<33>();
+ test_default_ctor<63>();
+ test_default_ctor<64>();
+ test_default_ctor<65>();
+ test_default_ctor<1000>();
+}
diff --git a/test/std/utilities/template.bitset/bitset.cons/string_ctor.pass.cpp b/test/std/utilities/template.bitset/bitset.cons/string_ctor.pass.cpp
new file mode 100644
index 000000000000..bcee50c4c63a
--- /dev/null
+++ b/test/std/utilities/template.bitset/bitset.cons/string_ctor.pass.cpp
@@ -0,0 +1,88 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test bitset(string, pos, n, zero, one);
+
+#include <bitset>
+#include <cassert>
+
+#pragma clang diagnostic ignored "-Wtautological-compare"
+
+template <std::size_t N>
+void test_string_ctor()
+{
+ {
+ try
+ {
+ std::string str("xxx1010101010xxxx");
+ std::bitset<N> v(str, str.size()+1, 10);
+ assert(false);
+ }
+ catch (std::out_of_range&)
+ {
+ }
+ }
+
+ {
+ try
+ {
+ std::string str("xxx1010101010xxxx");
+ std::bitset<N> v(str, 2, 10);
+ assert(false);
+ }
+ catch (std::invalid_argument&)
+ {
+ }
+ }
+
+ {
+ std::string str("xxx1010101010xxxx");
+ std::bitset<N> v(str, 3, 10);
+ std::size_t M = std::min<std::size_t>(N, 10);
+ for (std::size_t i = 0; i < M; ++i)
+ assert(v[i] == (str[3 + M - 1 - i] == '1'));
+ for (std::size_t i = 10; i < N; ++i)
+ assert(v[i] == false);
+ }
+
+ {
+ try
+ {
+ std::string str("xxxbababababaxxxx");
+ std::bitset<N> v(str, 2, 10, 'a', 'b');
+ assert(false);
+ }
+ catch (std::invalid_argument&)
+ {
+ }
+ }
+
+ {
+ std::string str("xxxbababababaxxxx");
+ std::bitset<N> v(str, 3, 10, 'a', 'b');
+ std::size_t M = std::min<std::size_t>(N, 10);
+ for (std::size_t i = 0; i < M; ++i)
+ assert(v[i] == (str[3 + M - 1 - i] == 'b'));
+ for (std::size_t i = 10; i < N; ++i)
+ assert(v[i] == false);
+ }
+}
+
+int main()
+{
+ test_string_ctor<0>();
+ test_string_ctor<1>();
+ test_string_ctor<31>();
+ test_string_ctor<32>();
+ test_string_ctor<33>();
+ test_string_ctor<63>();
+ test_string_ctor<64>();
+ test_string_ctor<65>();
+ test_string_ctor<1000>();
+}
diff --git a/test/std/utilities/template.bitset/bitset.cons/ull_ctor.pass.cpp b/test/std/utilities/template.bitset/bitset.cons/ull_ctor.pass.cpp
new file mode 100644
index 000000000000..023fedc25839
--- /dev/null
+++ b/test/std/utilities/template.bitset/bitset.cons/ull_ctor.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test bitset(unsigned long long val);
+
+#include <bitset>
+#include <cassert>
+
+#pragma clang diagnostic ignored "-Wtautological-compare"
+
+template <std::size_t N>
+void test_val_ctor()
+{
+ {
+ _LIBCPP_CONSTEXPR std::bitset<N> v(0xAAAAAAAAAAAAAAAAULL);
+ assert(v.size() == N);
+ unsigned M = std::min<std::size_t>(N, 64);
+ for (std::size_t i = 0; i < M; ++i)
+ assert(v[i] == (i & 1));
+ for (std::size_t i = M; i < N; ++i)
+ assert(v[i] == false);
+ }
+}
+
+int main()
+{
+ test_val_ctor<0>();
+ test_val_ctor<1>();
+ test_val_ctor<31>();
+ test_val_ctor<32>();
+ test_val_ctor<33>();
+ test_val_ctor<63>();
+ test_val_ctor<64>();
+ test_val_ctor<65>();
+ test_val_ctor<1000>();
+}
diff --git a/test/std/utilities/template.bitset/bitset.hash/bitset.pass.cpp b/test/std/utilities/template.bitset/bitset.hash/bitset.pass.cpp
new file mode 100644
index 000000000000..520f2e8757c2
--- /dev/null
+++ b/test/std/utilities/template.bitset/bitset.hash/bitset.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template <class T>
+// struct hash
+// : public unary_function<T, size_t>
+// {
+// size_t operator()(T val) const;
+// };
+
+// Not very portable
+
+#include <bitset>
+#include <cassert>
+#include <type_traits>
+
+template <std::size_t N>
+void
+test()
+{
+ typedef std::bitset<N> T;
+ typedef std::hash<T> H;
+ static_assert((std::is_same<typename H::argument_type, T>::value), "" );
+ static_assert((std::is_same<typename H::result_type, std::size_t>::value), "" );
+ H h;
+ T bs(static_cast<unsigned long long>(N));
+ assert(h(bs) == N);
+}
+
+int main()
+{
+ test<0>();
+ test<10>();
+ test<100>();
+ test<1000>();
+}
diff --git a/test/std/utilities/template.bitset/bitset.members/all.pass.cpp b/test/std/utilities/template.bitset/bitset.members/all.pass.cpp
new file mode 100644
index 000000000000..5387b733918f
--- /dev/null
+++ b/test/std/utilities/template.bitset/bitset.members/all.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test bool all() const;
+
+#include <bitset>
+#include <cassert>
+
+template <std::size_t N>
+void test_all()
+{
+ std::bitset<N> v;
+ v.reset();
+ assert(v.all() == (N == 0));
+ v.set();
+ assert(v.all() == true);
+ if (N > 1)
+ {
+ v[N/2] = false;
+ assert(v.all() == false);
+ }
+}
+
+int main()
+{
+ test_all<0>();
+ test_all<1>();
+ test_all<31>();
+ test_all<32>();
+ test_all<33>();
+ test_all<63>();
+ test_all<64>();
+ test_all<65>();
+ test_all<1000>();
+}
diff --git a/test/std/utilities/template.bitset/bitset.members/any.pass.cpp b/test/std/utilities/template.bitset/bitset.members/any.pass.cpp
new file mode 100644
index 000000000000..aa6384a49df1
--- /dev/null
+++ b/test/std/utilities/template.bitset/bitset.members/any.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test bool any() const;
+
+#include <bitset>
+#include <cassert>
+
+template <std::size_t N>
+void test_any()
+{
+ std::bitset<N> v;
+ v.reset();
+ assert(v.any() == false);
+ v.set();
+ assert(v.any() == (N != 0));
+ if (N > 1)
+ {
+ v[N/2] = false;
+ assert(v.any() == true);
+ v.reset();
+ v[N/2] = true;
+ assert(v.any() == true);
+ }
+}
+
+int main()
+{
+ test_any<0>();
+ test_any<1>();
+ test_any<31>();
+ test_any<32>();
+ test_any<33>();
+ test_any<63>();
+ test_any<64>();
+ test_any<65>();
+ test_any<1000>();
+}
diff --git a/test/std/utilities/template.bitset/bitset.members/count.pass.cpp b/test/std/utilities/template.bitset/bitset.members/count.pass.cpp
new file mode 100644
index 000000000000..fb9ce6422997
--- /dev/null
+++ b/test/std/utilities/template.bitset/bitset.members/count.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test size_t count() const;
+
+#include <bitset>
+#include <cstdlib>
+#include <cassert>
+
+#pragma clang diagnostic ignored "-Wtautological-compare"
+
+template <std::size_t N>
+std::bitset<N>
+make_bitset()
+{
+ std::bitset<N> v;
+ for (std::size_t i = 0; i < N; ++i)
+ v[i] = static_cast<bool>(std::rand() & 1);
+ return v;
+}
+
+template <std::size_t N>
+void test_count()
+{
+ const std::bitset<N> v = make_bitset<N>();
+ std::size_t c1 = v.count();
+ std::size_t c2 = 0;
+ for (std::size_t i = 0; i < N; ++i)
+ if (v[i])
+ ++c2;
+ assert(c1 == c2);
+}
+
+int main()
+{
+ test_count<0>();
+ test_count<1>();
+ test_count<31>();
+ test_count<32>();
+ test_count<33>();
+ test_count<63>();
+ test_count<64>();
+ test_count<65>();
+ test_count<1000>();
+}
diff --git a/test/std/utilities/template.bitset/bitset.members/flip_all.pass.cpp b/test/std/utilities/template.bitset/bitset.members/flip_all.pass.cpp
new file mode 100644
index 000000000000..6c4f5c699850
--- /dev/null
+++ b/test/std/utilities/template.bitset/bitset.members/flip_all.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test bitset<N>& flip();
+
+#include <bitset>
+#include <cstdlib>
+#include <cassert>
+
+#pragma clang diagnostic ignored "-Wtautological-compare"
+
+template <std::size_t N>
+std::bitset<N>
+make_bitset()
+{
+ std::bitset<N> v;
+ for (std::size_t i = 0; i < N; ++i)
+ v[i] = static_cast<bool>(std::rand() & 1);
+ return v;
+}
+
+template <std::size_t N>
+void test_flip_all()
+{
+ std::bitset<N> v1 = make_bitset<N>();
+ std::bitset<N> v2 = v1;
+ v2.flip();
+ for (std::size_t i = 0; i < N; ++i)
+ assert(v2[i] == ~v1[i]);
+}
+
+int main()
+{
+ test_flip_all<0>();
+ test_flip_all<1>();
+ test_flip_all<31>();
+ test_flip_all<32>();
+ test_flip_all<33>();
+ test_flip_all<63>();
+ test_flip_all<64>();
+ test_flip_all<65>();
+ test_flip_all<1000>();
+}
diff --git a/test/std/utilities/template.bitset/bitset.members/flip_one.pass.cpp b/test/std/utilities/template.bitset/bitset.members/flip_one.pass.cpp
new file mode 100644
index 000000000000..3e09b202097d
--- /dev/null
+++ b/test/std/utilities/template.bitset/bitset.members/flip_one.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test bitset<N>& flip(size_t pos);
+
+#include <bitset>
+#include <cstdlib>
+#include <cassert>
+
+#pragma clang diagnostic ignored "-Wtautological-compare"
+
+template <std::size_t N>
+std::bitset<N>
+make_bitset()
+{
+ std::bitset<N> v;
+ for (std::size_t i = 0; i < N; ++i)
+ v[i] = static_cast<bool>(std::rand() & 1);
+ return v;
+}
+
+template <std::size_t N>
+void test_flip_one()
+{
+ std::bitset<N> v = make_bitset<N>();
+ try
+ {
+ v.flip(50);
+ bool b = v[50];
+ if (50 >= v.size())
+ assert(false);
+ assert(v[50] == b);
+ v.flip(50);
+ assert(v[50] != b);
+ v.flip(50);
+ assert(v[50] == b);
+ }
+ catch (std::out_of_range&)
+ {
+ }
+}
+
+int main()
+{
+ test_flip_one<0>();
+ test_flip_one<1>();
+ test_flip_one<31>();
+ test_flip_one<32>();
+ test_flip_one<33>();
+ test_flip_one<63>();
+ test_flip_one<64>();
+ test_flip_one<65>();
+ test_flip_one<1000>();
+}
diff --git a/test/std/utilities/template.bitset/bitset.members/index.pass.cpp b/test/std/utilities/template.bitset/bitset.members/index.pass.cpp
new file mode 100644
index 000000000000..b96aaa51ab8f
--- /dev/null
+++ b/test/std/utilities/template.bitset/bitset.members/index.pass.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test bitset<N>::reference operator[](size_t pos);
+
+#include <bitset>
+#include <cstdlib>
+#include <cassert>
+
+#pragma clang diagnostic ignored "-Wtautological-compare"
+
+template <std::size_t N>
+std::bitset<N>
+make_bitset()
+{
+ std::bitset<N> v;
+ for (std::size_t i = 0; i < N; ++i)
+ v[i] = static_cast<bool>(std::rand() & 1);
+ return v;
+}
+
+template <std::size_t N>
+void test_index_const()
+{
+ std::bitset<N> v1 = make_bitset<N>();
+ if (N > 0)
+ {
+ assert(v1[N/2] == v1.test(N/2));
+ typename std::bitset<N>::reference r = v1[N/2];
+ assert(r == v1.test(N/2));
+ typename std::bitset<N>::reference r2 = v1[N/2];
+ r = r2;
+ assert(r == v1.test(N/2));
+ r = false;
+ assert(r == false);
+ assert(v1.test(N/2) == false);
+ r = true;
+ assert(r == true);
+ assert(v1.test(N/2) == true);
+ bool b = ~r;
+ assert(r == true);
+ assert(v1.test(N/2) == true);
+ assert(b == false);
+ r.flip();
+ assert(r == false);
+ assert(v1.test(N/2) == false);
+ }
+}
+
+int main()
+{
+ test_index_const<0>();
+ test_index_const<1>();
+ test_index_const<31>();
+ test_index_const<32>();
+ test_index_const<33>();
+ test_index_const<63>();
+ test_index_const<64>();
+ test_index_const<65>();
+ test_index_const<1000>();
+}
diff --git a/test/std/utilities/template.bitset/bitset.members/index_const.pass.cpp b/test/std/utilities/template.bitset/bitset.members/index_const.pass.cpp
new file mode 100644
index 000000000000..e3c28c693576
--- /dev/null
+++ b/test/std/utilities/template.bitset/bitset.members/index_const.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test constexpr bool operator[](size_t pos) const;
+
+#include <bitset>
+#include <cstdlib>
+#include <cassert>
+
+#pragma clang diagnostic ignored "-Wtautological-compare"
+
+template <std::size_t N>
+std::bitset<N>
+make_bitset()
+{
+ std::bitset<N> v;
+ for (std::size_t i = 0; i < N; ++i)
+ v[i] = static_cast<bool>(std::rand() & 1);
+ return v;
+}
+
+template <std::size_t N>
+void test_index_const()
+{
+ const std::bitset<N> v1 = make_bitset<N>();
+ if (N > 0)
+ {
+ assert(v1[N/2] == v1.test(N/2));
+ }
+}
+
+int main()
+{
+ test_index_const<0>();
+ test_index_const<1>();
+ test_index_const<31>();
+ test_index_const<32>();
+ test_index_const<33>();
+ test_index_const<63>();
+ test_index_const<64>();
+ test_index_const<65>();
+ test_index_const<1000>();
+}
diff --git a/test/std/utilities/template.bitset/bitset.members/left_shift.pass.cpp b/test/std/utilities/template.bitset/bitset.members/left_shift.pass.cpp
new file mode 100644
index 000000000000..7fe9fa72e924
--- /dev/null
+++ b/test/std/utilities/template.bitset/bitset.members/left_shift.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test bitset<N> operator<<(size_t pos) const;
+
+#include <bitset>
+#include <cstdlib>
+#include <cassert>
+
+#pragma clang diagnostic ignored "-Wtautological-compare"
+
+template <std::size_t N>
+std::bitset<N>
+make_bitset()
+{
+ std::bitset<N> v;
+ for (std::size_t i = 0; i < N; ++i)
+ v[i] = static_cast<bool>(std::rand() & 1);
+ return v;
+}
+
+template <std::size_t N>
+void test_left_shift()
+{
+ for (std::size_t s = 0; s <= N+1; ++s)
+ {
+ std::bitset<N> v1 = make_bitset<N>();
+ std::bitset<N> v2 = v1;
+ assert((v1 <<= s) == (v2 << s));
+ }
+}
+
+int main()
+{
+ test_left_shift<0>();
+ test_left_shift<1>();
+ test_left_shift<31>();
+ test_left_shift<32>();
+ test_left_shift<33>();
+ test_left_shift<63>();
+ test_left_shift<64>();
+ test_left_shift<65>();
+ test_left_shift<1000>();
+}
diff --git a/test/std/utilities/template.bitset/bitset.members/left_shift_eq.pass.cpp b/test/std/utilities/template.bitset/bitset.members/left_shift_eq.pass.cpp
new file mode 100644
index 000000000000..bed3e28ece81
--- /dev/null
+++ b/test/std/utilities/template.bitset/bitset.members/left_shift_eq.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test bitset<N>& operator<<=(size_t pos);
+
+#include <bitset>
+#include <cstdlib>
+#include <cassert>
+
+#pragma clang diagnostic ignored "-Wtautological-compare"
+
+template <std::size_t N>
+std::bitset<N>
+make_bitset()
+{
+ std::bitset<N> v;
+ for (std::size_t i = 0; i < N; ++i)
+ v[i] = static_cast<bool>(std::rand() & 1);
+ return v;
+}
+
+template <std::size_t N>
+void test_left_shift()
+{
+ for (std::size_t s = 0; s <= N+1; ++s)
+ {
+ std::bitset<N> v1 = make_bitset<N>();
+ std::bitset<N> v2 = v1;
+ v1 <<= s;
+ for (std::size_t i = 0; i < N; ++i)
+ if (i < s)
+ assert(v1[i] == 0);
+ else
+ assert(v1[i] == v2[i-s]);
+ }
+}
+
+int main()
+{
+ test_left_shift<0>();
+ test_left_shift<1>();
+ test_left_shift<31>();
+ test_left_shift<32>();
+ test_left_shift<33>();
+ test_left_shift<63>();
+ test_left_shift<64>();
+ test_left_shift<65>();
+ test_left_shift<1000>();
+}
diff --git a/test/std/utilities/template.bitset/bitset.members/none.pass.cpp b/test/std/utilities/template.bitset/bitset.members/none.pass.cpp
new file mode 100644
index 000000000000..b65c636f3c56
--- /dev/null
+++ b/test/std/utilities/template.bitset/bitset.members/none.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test bool none() const;
+
+#include <bitset>
+#include <cassert>
+
+template <std::size_t N>
+void test_none()
+{
+ std::bitset<N> v;
+ v.reset();
+ assert(v.none() == true);
+ v.set();
+ assert(v.none() == (N == 0));
+ if (N > 1)
+ {
+ v[N/2] = false;
+ assert(v.none() == false);
+ v.reset();
+ v[N/2] = true;
+ assert(v.none() == false);
+ }
+}
+
+int main()
+{
+ test_none<0>();
+ test_none<1>();
+ test_none<31>();
+ test_none<32>();
+ test_none<33>();
+ test_none<63>();
+ test_none<64>();
+ test_none<65>();
+ test_none<1000>();
+}
diff --git a/test/std/utilities/template.bitset/bitset.members/not_all.pass.cpp b/test/std/utilities/template.bitset/bitset.members/not_all.pass.cpp
new file mode 100644
index 000000000000..2f8f7111f5a1
--- /dev/null
+++ b/test/std/utilities/template.bitset/bitset.members/not_all.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test bitset<N> operator~() const;
+
+#include <bitset>
+#include <cstdlib>
+#include <cassert>
+
+#pragma clang diagnostic ignored "-Wtautological-compare"
+
+template <std::size_t N>
+std::bitset<N>
+make_bitset()
+{
+ std::bitset<N> v;
+ for (std::size_t i = 0; i < N; ++i)
+ v[i] = static_cast<bool>(std::rand() & 1);
+ return v;
+}
+
+template <std::size_t N>
+void test_not_all()
+{
+ std::bitset<N> v1 = make_bitset<N>();
+ std::bitset<N> v2 = ~v1;
+ for (std::size_t i = 0; i < N; ++i)
+ assert(v2[i] == ~v1[i]);
+}
+
+int main()
+{
+ test_not_all<0>();
+ test_not_all<1>();
+ test_not_all<31>();
+ test_not_all<32>();
+ test_not_all<33>();
+ test_not_all<63>();
+ test_not_all<64>();
+ test_not_all<65>();
+ test_not_all<1000>();
+}
diff --git a/test/std/utilities/template.bitset/bitset.members/op_and_eq.pass.cpp b/test/std/utilities/template.bitset/bitset.members/op_and_eq.pass.cpp
new file mode 100644
index 000000000000..b599ec398b30
--- /dev/null
+++ b/test/std/utilities/template.bitset/bitset.members/op_and_eq.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test bitset<N>& operator&=(const bitset<N>& rhs);
+
+#include <bitset>
+#include <cstdlib>
+#include <cassert>
+
+#pragma clang diagnostic ignored "-Wtautological-compare"
+
+template <std::size_t N>
+std::bitset<N>
+make_bitset()
+{
+ std::bitset<N> v;
+ for (std::size_t i = 0; i < N; ++i)
+ v[i] = static_cast<bool>(std::rand() & 1);
+ return v;
+}
+
+template <std::size_t N>
+void test_op_and_eq()
+{
+ std::bitset<N> v1 = make_bitset<N>();
+ std::bitset<N> v2 = make_bitset<N>();
+ std::bitset<N> v3 = v1;
+ v1 &= v2;
+ for (std::size_t i = 0; i < N; ++i)
+ assert(v1[i] == (v3[i] && v2[i]));
+}
+
+int main()
+{
+ test_op_and_eq<0>();
+ test_op_and_eq<1>();
+ test_op_and_eq<31>();
+ test_op_and_eq<32>();
+ test_op_and_eq<33>();
+ test_op_and_eq<63>();
+ test_op_and_eq<64>();
+ test_op_and_eq<65>();
+ test_op_and_eq<1000>();
+}
diff --git a/test/std/utilities/template.bitset/bitset.members/op_eq_eq.pass.cpp b/test/std/utilities/template.bitset/bitset.members/op_eq_eq.pass.cpp
new file mode 100644
index 000000000000..5f6cf3d0a30c
--- /dev/null
+++ b/test/std/utilities/template.bitset/bitset.members/op_eq_eq.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test:
+
+// bool operator==(const bitset<N>& rhs) const;
+// bool operator!=(const bitset<N>& rhs) const;
+
+#include <bitset>
+#include <cstdlib>
+#include <cassert>
+
+#pragma clang diagnostic ignored "-Wtautological-compare"
+
+template <std::size_t N>
+std::bitset<N>
+make_bitset()
+{
+ std::bitset<N> v;
+ for (std::size_t i = 0; i < N; ++i)
+ v[i] = static_cast<bool>(std::rand() & 1);
+ return v;
+}
+
+template <std::size_t N>
+void test_equality()
+{
+ const std::bitset<N> v1 = make_bitset<N>();
+ std::bitset<N> v2 = v1;
+ assert(v1 == v2);
+ if (N > 0)
+ {
+ v2[N/2].flip();
+ assert(v1 != v2);
+ }
+}
+
+int main()
+{
+ test_equality<0>();
+ test_equality<1>();
+ test_equality<31>();
+ test_equality<32>();
+ test_equality<33>();
+ test_equality<63>();
+ test_equality<64>();
+ test_equality<65>();
+ test_equality<1000>();
+}
diff --git a/test/std/utilities/template.bitset/bitset.members/op_or_eq.pass.cpp b/test/std/utilities/template.bitset/bitset.members/op_or_eq.pass.cpp
new file mode 100644
index 000000000000..6e63879890a6
--- /dev/null
+++ b/test/std/utilities/template.bitset/bitset.members/op_or_eq.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test bitset<N>& operator|=(const bitset<N>& rhs);
+
+#include <bitset>
+#include <cstdlib>
+#include <cassert>
+
+#pragma clang diagnostic ignored "-Wtautological-compare"
+
+template <std::size_t N>
+std::bitset<N>
+make_bitset()
+{
+ std::bitset<N> v;
+ for (std::size_t i = 0; i < N; ++i)
+ v[i] = static_cast<bool>(std::rand() & 1);
+ return v;
+}
+
+template <std::size_t N>
+void test_op_or_eq()
+{
+ std::bitset<N> v1 = make_bitset<N>();
+ std::bitset<N> v2 = make_bitset<N>();
+ std::bitset<N> v3 = v1;
+ v1 |= v2;
+ for (std::size_t i = 0; i < N; ++i)
+ assert(v1[i] == (v3[i] || v2[i]));
+}
+
+int main()
+{
+ test_op_or_eq<0>();
+ test_op_or_eq<1>();
+ test_op_or_eq<31>();
+ test_op_or_eq<32>();
+ test_op_or_eq<33>();
+ test_op_or_eq<63>();
+ test_op_or_eq<64>();
+ test_op_or_eq<65>();
+ test_op_or_eq<1000>();
+}
diff --git a/test/std/utilities/template.bitset/bitset.members/op_xor_eq.pass.cpp b/test/std/utilities/template.bitset/bitset.members/op_xor_eq.pass.cpp
new file mode 100644
index 000000000000..e68a641cadc6
--- /dev/null
+++ b/test/std/utilities/template.bitset/bitset.members/op_xor_eq.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test bitset<N>& operator^=(const bitset<N>& rhs);
+
+#include <bitset>
+#include <cstdlib>
+#include <cassert>
+
+#pragma clang diagnostic ignored "-Wtautological-compare"
+
+template <std::size_t N>
+std::bitset<N>
+make_bitset()
+{
+ std::bitset<N> v;
+ for (std::size_t i = 0; i < N; ++i)
+ v[i] = static_cast<bool>(std::rand() & 1);
+ return v;
+}
+
+template <std::size_t N>
+void test_op_xor_eq()
+{
+ std::bitset<N> v1 = make_bitset<N>();
+ std::bitset<N> v2 = make_bitset<N>();
+ std::bitset<N> v3 = v1;
+ v1 ^= v2;
+ for (std::size_t i = 0; i < N; ++i)
+ assert(v1[i] == (v3[i] != v2[i]));
+}
+
+int main()
+{
+ test_op_xor_eq<0>();
+ test_op_xor_eq<1>();
+ test_op_xor_eq<31>();
+ test_op_xor_eq<32>();
+ test_op_xor_eq<33>();
+ test_op_xor_eq<63>();
+ test_op_xor_eq<64>();
+ test_op_xor_eq<65>();
+ test_op_xor_eq<1000>();
+}
diff --git a/test/std/utilities/template.bitset/bitset.members/reset_all.pass.cpp b/test/std/utilities/template.bitset/bitset.members/reset_all.pass.cpp
new file mode 100644
index 000000000000..ee44d92c43b8
--- /dev/null
+++ b/test/std/utilities/template.bitset/bitset.members/reset_all.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test bitset<N>& reset();
+
+#include <bitset>
+#include <cassert>
+
+#pragma clang diagnostic ignored "-Wtautological-compare"
+
+template <std::size_t N>
+void test_reset_all()
+{
+ std::bitset<N> v;
+ v.set();
+ v.reset();
+ for (std::size_t i = 0; i < N; ++i)
+ assert(!v[i]);
+}
+
+int main()
+{
+ test_reset_all<0>();
+ test_reset_all<1>();
+ test_reset_all<31>();
+ test_reset_all<32>();
+ test_reset_all<33>();
+ test_reset_all<63>();
+ test_reset_all<64>();
+ test_reset_all<65>();
+ test_reset_all<1000>();
+}
diff --git a/test/std/utilities/template.bitset/bitset.members/reset_one.pass.cpp b/test/std/utilities/template.bitset/bitset.members/reset_one.pass.cpp
new file mode 100644
index 000000000000..ebaa9e7a8d72
--- /dev/null
+++ b/test/std/utilities/template.bitset/bitset.members/reset_one.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test bitset<N>& reset(size_t pos);
+
+#include <bitset>
+#include <cassert>
+
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wtautological-compare"
+
+template <std::size_t N>
+void test_reset_one()
+{
+ std::bitset<N> v;
+ try
+ {
+ v.set();
+ v.reset(50);
+ if (50 >= v.size())
+ assert(false);
+ for (unsigned i = 0; i < v.size(); ++i)
+ if (i == 50)
+ assert(!v[i]);
+ else
+ assert(v[i]);
+ }
+ catch (std::out_of_range&)
+ {
+ }
+}
+
+int main()
+{
+ test_reset_one<0>();
+ test_reset_one<1>();
+ test_reset_one<31>();
+ test_reset_one<32>();
+ test_reset_one<33>();
+ test_reset_one<63>();
+ test_reset_one<64>();
+ test_reset_one<65>();
+ test_reset_one<1000>();
+}
diff --git a/test/std/utilities/template.bitset/bitset.members/right_shift.pass.cpp b/test/std/utilities/template.bitset/bitset.members/right_shift.pass.cpp
new file mode 100644
index 000000000000..87fcc281fa26
--- /dev/null
+++ b/test/std/utilities/template.bitset/bitset.members/right_shift.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test bitset<N> operator>>(size_t pos) const;
+
+#include <bitset>
+#include <cstdlib>
+#include <cassert>
+
+#pragma clang diagnostic ignored "-Wtautological-compare"
+
+template <std::size_t N>
+std::bitset<N>
+make_bitset()
+{
+ std::bitset<N> v;
+ for (std::size_t i = 0; i < N; ++i)
+ v[i] = static_cast<bool>(std::rand() & 1);
+ return v;
+}
+
+template <std::size_t N>
+void test_right_shift()
+{
+ for (std::size_t s = 0; s <= N+1; ++s)
+ {
+ std::bitset<N> v1 = make_bitset<N>();
+ std::bitset<N> v2 = v1;
+ assert((v1 >>= s) == (v2 >> s));
+ }
+}
+
+int main()
+{
+ test_right_shift<0>();
+ test_right_shift<1>();
+ test_right_shift<31>();
+ test_right_shift<32>();
+ test_right_shift<33>();
+ test_right_shift<63>();
+ test_right_shift<64>();
+ test_right_shift<65>();
+ test_right_shift<1000>();
+}
diff --git a/test/std/utilities/template.bitset/bitset.members/right_shift_eq.pass.cpp b/test/std/utilities/template.bitset/bitset.members/right_shift_eq.pass.cpp
new file mode 100644
index 000000000000..1dd89c1844b9
--- /dev/null
+++ b/test/std/utilities/template.bitset/bitset.members/right_shift_eq.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test bitset<N>& operator<<=(size_t pos);
+
+#include <bitset>
+#include <cstdlib>
+#include <cassert>
+
+#pragma clang diagnostic ignored "-Wtautological-compare"
+
+template <std::size_t N>
+std::bitset<N>
+make_bitset()
+{
+ std::bitset<N> v;
+ for (std::size_t i = 0; i < N; ++i)
+ v[i] = static_cast<bool>(std::rand() & 1);
+ return v;
+}
+
+template <std::size_t N>
+void test_right_shift()
+{
+ for (std::size_t s = 0; s <= N+1; ++s)
+ {
+ std::bitset<N> v1 = make_bitset<N>();
+ std::bitset<N> v2 = v1;
+ v1 >>= s;
+ for (std::size_t i = 0; i < N; ++i)
+ if (i + s < N)
+ assert(v1[i] == v2[i + s]);
+ else
+ assert(v1[i] == 0);
+ }
+}
+
+int main()
+{
+ test_right_shift<0>();
+ test_right_shift<1>();
+ test_right_shift<31>();
+ test_right_shift<32>();
+ test_right_shift<33>();
+ test_right_shift<63>();
+ test_right_shift<64>();
+ test_right_shift<65>();
+ test_right_shift<1000>();
+}
diff --git a/test/std/utilities/template.bitset/bitset.members/set_all.pass.cpp b/test/std/utilities/template.bitset/bitset.members/set_all.pass.cpp
new file mode 100644
index 000000000000..56454a84f113
--- /dev/null
+++ b/test/std/utilities/template.bitset/bitset.members/set_all.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test bitset<N>& set();
+
+#include <bitset>
+#include <cassert>
+
+#pragma clang diagnostic ignored "-Wtautological-compare"
+
+template <std::size_t N>
+void test_set_all()
+{
+ std::bitset<N> v;
+ v.set();
+ for (std::size_t i = 0; i < N; ++i)
+ assert(v[i]);
+}
+
+int main()
+{
+ test_set_all<0>();
+ test_set_all<1>();
+ test_set_all<31>();
+ test_set_all<32>();
+ test_set_all<33>();
+ test_set_all<63>();
+ test_set_all<64>();
+ test_set_all<65>();
+ test_set_all<1000>();
+}
diff --git a/test/std/utilities/template.bitset/bitset.members/set_one.pass.cpp b/test/std/utilities/template.bitset/bitset.members/set_one.pass.cpp
new file mode 100644
index 000000000000..116eaf3f46e0
--- /dev/null
+++ b/test/std/utilities/template.bitset/bitset.members/set_one.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test bitset<N>& set(size_t pos, bool val = true);
+
+#include <bitset>
+#include <cassert>
+
+template <std::size_t N>
+void test_set_one()
+{
+ std::bitset<N> v;
+ try
+ {
+ v.set(50);
+ if (50 >= v.size())
+ assert(false);
+ assert(v[50]);
+ }
+ catch (std::out_of_range&)
+ {
+ }
+ try
+ {
+ v.set(50, false);
+ if (50 >= v.size())
+ assert(false);
+ assert(!v[50]);
+ }
+ catch (std::out_of_range&)
+ {
+ }
+}
+
+int main()
+{
+ test_set_one<0>();
+ test_set_one<1>();
+ test_set_one<31>();
+ test_set_one<32>();
+ test_set_one<33>();
+ test_set_one<63>();
+ test_set_one<64>();
+ test_set_one<65>();
+ test_set_one<1000>();
+}
diff --git a/test/std/utilities/template.bitset/bitset.members/size.pass.cpp b/test/std/utilities/template.bitset/bitset.members/size.pass.cpp
new file mode 100644
index 000000000000..822e0a048b5a
--- /dev/null
+++ b/test/std/utilities/template.bitset/bitset.members/size.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test size_t count() const;
+
+#include <bitset>
+#include <cassert>
+
+template <std::size_t N>
+void test_size()
+{
+ const std::bitset<N> v;
+ assert(v.size() == N);
+}
+
+int main()
+{
+ test_size<0>();
+ test_size<1>();
+ test_size<31>();
+ test_size<32>();
+ test_size<33>();
+ test_size<63>();
+ test_size<64>();
+ test_size<65>();
+ test_size<1000>();
+}
diff --git a/test/std/utilities/template.bitset/bitset.members/test.pass.cpp b/test/std/utilities/template.bitset/bitset.members/test.pass.cpp
new file mode 100644
index 000000000000..5102b46171a2
--- /dev/null
+++ b/test/std/utilities/template.bitset/bitset.members/test.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test constexpr bool test(size_t pos) const;
+
+#include <bitset>
+#include <cstdlib>
+#include <cassert>
+
+#pragma clang diagnostic ignored "-Wtautological-compare"
+
+template <std::size_t N>
+std::bitset<N>
+make_bitset()
+{
+ std::bitset<N> v;
+ for (std::size_t i = 0; i < N; ++i)
+ v[i] = static_cast<bool>(std::rand() & 1);
+ return v;
+}
+
+template <std::size_t N>
+void test_test()
+{
+ const std::bitset<N> v1 = make_bitset<N>();
+ try
+ {
+ bool b = v1.test(50);
+ if (50 >= v1.size())
+ assert(false);
+ assert(b == v1[50]);
+ }
+ catch (std::out_of_range&)
+ {
+ }
+}
+
+int main()
+{
+ test_test<0>();
+ test_test<1>();
+ test_test<31>();
+ test_test<32>();
+ test_test<33>();
+ test_test<63>();
+ test_test<64>();
+ test_test<65>();
+ test_test<1000>();
+}
diff --git a/test/std/utilities/template.bitset/bitset.members/to_string.pass.cpp b/test/std/utilities/template.bitset/bitset.members/to_string.pass.cpp
new file mode 100644
index 000000000000..b65794097470
--- /dev/null
+++ b/test/std/utilities/template.bitset/bitset.members/to_string.pass.cpp
@@ -0,0 +1,162 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test:
+
+// template <class charT, class traits, class Allocator>
+// basic_string<charT, traits, Allocator>
+// to_string(charT zero = charT('0'), charT one = charT('1')) const;
+//
+// template <class charT, class traits>
+// basic_string<charT, traits, allocator<charT> > to_string() const;
+//
+// template <class charT>
+// basic_string<charT, char_traits<charT>, allocator<charT> > to_string() const;
+//
+// basic_string<char, char_traits<char>, allocator<char> > to_string() const;
+
+#include <bitset>
+#include <string>
+#include <cstdlib>
+#include <cassert>
+
+#pragma clang diagnostic ignored "-Wtautological-compare"
+
+template <std::size_t N>
+std::bitset<N>
+make_bitset()
+{
+ std::bitset<N> v;
+ for (std::size_t i = 0; i < N; ++i)
+ v[i] = static_cast<bool>(std::rand() & 1);
+ return v;
+}
+
+template <std::size_t N>
+void test_to_string()
+{
+{
+ std::bitset<N> v = make_bitset<N>();
+ {
+ std::wstring s = v.template to_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >();
+ for (std::size_t i = 0; i < N; ++i)
+ if (v[i])
+ assert(s[N - 1 - i] == '1');
+ else
+ assert(s[N - 1 - i] == '0');
+ }
+ {
+ std::wstring s = v.template to_string<wchar_t, std::char_traits<wchar_t> >();
+ for (std::size_t i = 0; i < N; ++i)
+ if (v[i])
+ assert(s[N - 1 - i] == '1');
+ else
+ assert(s[N - 1 - i] == '0');
+ }
+ {
+ std::string s = v.template to_string<char>();
+ for (std::size_t i = 0; i < N; ++i)
+ if (v[i])
+ assert(s[N - 1 - i] == '1');
+ else
+ assert(s[N - 1 - i] == '0');
+ }
+ {
+ std::string s = v.to_string();
+ for (std::size_t i = 0; i < N; ++i)
+ if (v[i])
+ assert(s[N - 1 - i] == '1');
+ else
+ assert(s[N - 1 - i] == '0');
+ }
+}
+{
+ std::bitset<N> v = make_bitset<N>();
+ {
+ std::wstring s = v.template to_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >('0');
+ for (std::size_t i = 0; i < N; ++i)
+ if (v[i])
+ assert(s[N - 1 - i] == '1');
+ else
+ assert(s[N - 1 - i] == '0');
+ }
+ {
+ std::wstring s = v.template to_string<wchar_t, std::char_traits<wchar_t> >('0');
+ for (std::size_t i = 0; i < N; ++i)
+ if (v[i])
+ assert(s[N - 1 - i] == '1');
+ else
+ assert(s[N - 1 - i] == '0');
+ }
+ {
+ std::string s = v.template to_string<char>('0');
+ for (std::size_t i = 0; i < N; ++i)
+ if (v[i])
+ assert(s[N - 1 - i] == '1');
+ else
+ assert(s[N - 1 - i] == '0');
+ }
+ {
+ std::string s = v.to_string('0');
+ for (std::size_t i = 0; i < N; ++i)
+ if (v[i])
+ assert(s[N - 1 - i] == '1');
+ else
+ assert(s[N - 1 - i] == '0');
+ }
+}
+{
+ std::bitset<N> v = make_bitset<N>();
+ {
+ std::wstring s = v.template to_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >('0', '1');
+ for (std::size_t i = 0; i < N; ++i)
+ if (v[i])
+ assert(s[N - 1 - i] == '1');
+ else
+ assert(s[N - 1 - i] == '0');
+ }
+ {
+ std::wstring s = v.template to_string<wchar_t, std::char_traits<wchar_t> >('0', '1');
+ for (std::size_t i = 0; i < N; ++i)
+ if (v[i])
+ assert(s[N - 1 - i] == '1');
+ else
+ assert(s[N - 1 - i] == '0');
+ }
+ {
+ std::string s = v.template to_string<char>('0', '1');
+ for (std::size_t i = 0; i < N; ++i)
+ if (v[i])
+ assert(s[N - 1 - i] == '1');
+ else
+ assert(s[N - 1 - i] == '0');
+ }
+ {
+ std::string s = v.to_string('0', '1');
+ for (std::size_t i = 0; i < N; ++i)
+ if (v[i])
+ assert(s[N - 1 - i] == '1');
+ else
+ assert(s[N - 1 - i] == '0');
+ }
+}
+}
+
+int main()
+{
+ test_to_string<0>();
+ test_to_string<1>();
+ test_to_string<31>();
+ test_to_string<32>();
+ test_to_string<33>();
+ test_to_string<63>();
+ test_to_string<64>();
+ test_to_string<65>();
+ test_to_string<1000>();
+}
diff --git a/test/std/utilities/template.bitset/bitset.members/to_ullong.pass.cpp b/test/std/utilities/template.bitset/bitset.members/to_ullong.pass.cpp
new file mode 100644
index 000000000000..27d8480d10cf
--- /dev/null
+++ b/test/std/utilities/template.bitset/bitset.members/to_ullong.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test unsigned long long to_ullong() const;
+
+#include <bitset>
+#include <algorithm>
+#include <climits>
+#include <cassert>
+
+template <std::size_t N>
+void test_to_ullong()
+{
+ const std::size_t M = sizeof(unsigned long long) * CHAR_BIT < N ? sizeof(unsigned long long) * CHAR_BIT : N;
+ const std::size_t X = M == 0 ? sizeof(unsigned long long) * CHAR_BIT - 1 : sizeof(unsigned long long) * CHAR_BIT - M;
+ const unsigned long long max = M == 0 ? 0 : (unsigned long long)(-1) >> X;
+ unsigned long long tests[] = {0,
+ std::min<unsigned long long>(1, max),
+ std::min<unsigned long long>(2, max),
+ std::min<unsigned long long>(3, max),
+ std::min(max, max-3),
+ std::min(max, max-2),
+ std::min(max, max-1),
+ max};
+ for (std::size_t i = 0; i < sizeof(tests)/sizeof(tests[0]); ++i)
+ {
+ unsigned long long j = tests[i];
+ std::bitset<N> v(j);
+ assert(j == v.to_ullong());
+ }
+}
+
+int main()
+{
+ test_to_ullong<0>();
+ test_to_ullong<1>();
+ test_to_ullong<31>();
+ test_to_ullong<32>();
+ test_to_ullong<33>();
+ test_to_ullong<63>();
+ test_to_ullong<64>();
+ test_to_ullong<65>();
+ test_to_ullong<1000>();
+}
diff --git a/test/std/utilities/template.bitset/bitset.members/to_ulong.pass.cpp b/test/std/utilities/template.bitset/bitset.members/to_ulong.pass.cpp
new file mode 100644
index 000000000000..3ad1abade9f4
--- /dev/null
+++ b/test/std/utilities/template.bitset/bitset.members/to_ulong.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test unsigned long to_ulong() const;
+
+#include <bitset>
+#include <algorithm>
+#include <limits>
+#include <climits>
+#include <cassert>
+
+template <std::size_t N>
+void test_to_ulong()
+{
+ const std::size_t M = sizeof(unsigned long) * CHAR_BIT < N ? sizeof(unsigned long) * CHAR_BIT : N;
+ const std::size_t X = M == 0 ? sizeof(unsigned long) * CHAR_BIT - 1 : sizeof(unsigned long) * CHAR_BIT - M;
+ const std::size_t max = M == 0 ? 0 : std::size_t(std::numeric_limits<unsigned long>::max()) >> X;
+ std::size_t tests[] = {0,
+ std::min<std::size_t>(1, max),
+ std::min<std::size_t>(2, max),
+ std::min<std::size_t>(3, max),
+ std::min(max, max-3),
+ std::min(max, max-2),
+ std::min(max, max-1),
+ max};
+ for (std::size_t i = 0; i < sizeof(tests)/sizeof(tests[0]); ++i)
+ {
+ std::size_t j = tests[i];
+ std::bitset<N> v(j);
+ assert(j == v.to_ulong());
+ }
+}
+
+int main()
+{
+ test_to_ulong<0>();
+ test_to_ulong<1>();
+ test_to_ulong<31>();
+ test_to_ulong<32>();
+ test_to_ulong<33>();
+ test_to_ulong<63>();
+ test_to_ulong<64>();
+ test_to_ulong<65>();
+ test_to_ulong<1000>();
+}
diff --git a/test/std/utilities/template.bitset/bitset.operators/op_and.pass.cpp b/test/std/utilities/template.bitset/bitset.operators/op_and.pass.cpp
new file mode 100644
index 000000000000..751cee69102a
--- /dev/null
+++ b/test/std/utilities/template.bitset/bitset.operators/op_and.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test bitset<N> operator&(const bitset<N>& lhs, const bitset<N>& rhs);
+
+#include <bitset>
+#include <cstdlib>
+#include <cassert>
+
+#pragma clang diagnostic ignored "-Wtautological-compare"
+
+template <std::size_t N>
+std::bitset<N>
+make_bitset()
+{
+ std::bitset<N> v;
+ for (std::size_t i = 0; i < N; ++i)
+ v[i] = static_cast<bool>(std::rand() & 1);
+ return v;
+}
+
+template <std::size_t N>
+void test_op_and()
+{
+ std::bitset<N> v1 = make_bitset<N>();
+ std::bitset<N> v2 = make_bitset<N>();
+ std::bitset<N> v3 = v1;
+ assert((v1 & v2) == (v3 &= v2));;
+}
+
+int main()
+{
+ test_op_and<0>();
+ test_op_and<1>();
+ test_op_and<31>();
+ test_op_and<32>();
+ test_op_and<33>();
+ test_op_and<63>();
+ test_op_and<64>();
+ test_op_and<65>();
+ test_op_and<1000>();
+}
diff --git a/test/std/utilities/template.bitset/bitset.operators/op_not.pass.cpp b/test/std/utilities/template.bitset/bitset.operators/op_not.pass.cpp
new file mode 100644
index 000000000000..fda5e5cda8ee
--- /dev/null
+++ b/test/std/utilities/template.bitset/bitset.operators/op_not.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test bitset<N> operator^(const bitset<N>& lhs, const bitset<N>& rhs);
+
+#include <bitset>
+#include <cstdlib>
+#include <cassert>
+
+#pragma clang diagnostic ignored "-Wtautological-compare"
+
+template <std::size_t N>
+std::bitset<N>
+make_bitset()
+{
+ std::bitset<N> v;
+ for (std::size_t i = 0; i < N; ++i)
+ v[i] = static_cast<bool>(std::rand() & 1);
+ return v;
+}
+
+template <std::size_t N>
+void test_op_not()
+{
+ std::bitset<N> v1 = make_bitset<N>();
+ std::bitset<N> v2 = make_bitset<N>();
+ std::bitset<N> v3 = v1;
+ assert((v1 ^ v2) == (v3 ^= v2));;
+}
+
+int main()
+{
+ test_op_not<0>();
+ test_op_not<1>();
+ test_op_not<31>();
+ test_op_not<32>();
+ test_op_not<33>();
+ test_op_not<63>();
+ test_op_not<64>();
+ test_op_not<65>();
+ test_op_not<1000>();
+}
diff --git a/test/std/utilities/template.bitset/bitset.operators/op_or.pass.cpp b/test/std/utilities/template.bitset/bitset.operators/op_or.pass.cpp
new file mode 100644
index 000000000000..067f868215be
--- /dev/null
+++ b/test/std/utilities/template.bitset/bitset.operators/op_or.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test bitset<N> operator|(const bitset<N>& lhs, const bitset<N>& rhs);
+
+#include <bitset>
+#include <cstdlib>
+#include <cassert>
+
+#pragma clang diagnostic ignored "-Wtautological-compare"
+
+template <std::size_t N>
+std::bitset<N>
+make_bitset()
+{
+ std::bitset<N> v;
+ for (std::size_t i = 0; i < N; ++i)
+ v[i] = static_cast<bool>(std::rand() & 1);
+ return v;
+}
+
+template <std::size_t N>
+void test_op_or()
+{
+ std::bitset<N> v1 = make_bitset<N>();
+ std::bitset<N> v2 = make_bitset<N>();
+ std::bitset<N> v3 = v1;
+ assert((v1 | v2) == (v3 |= v2));;
+}
+
+int main()
+{
+ test_op_or<0>();
+ test_op_or<1>();
+ test_op_or<31>();
+ test_op_or<32>();
+ test_op_or<33>();
+ test_op_or<63>();
+ test_op_or<64>();
+ test_op_or<65>();
+ test_op_or<1000>();
+}
diff --git a/test/std/utilities/template.bitset/bitset.operators/stream_in.pass.cpp b/test/std/utilities/template.bitset/bitset.operators/stream_in.pass.cpp
new file mode 100644
index 000000000000..4c8afe3f96b0
--- /dev/null
+++ b/test/std/utilities/template.bitset/bitset.operators/stream_in.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test:
+
+// template <class charT, class traits, size_t N>
+// basic_ostream<charT, traits>&
+// operator<<(basic_ostream<charT, traits>& os, const bitset<N>& x);
+
+#include <bitset>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ std::istringstream in("01011010");
+ std::bitset<8> b;
+ in >> b;
+ assert(b.to_ulong() == 0x5A);
+}
diff --git a/test/std/utilities/template.bitset/bitset.operators/stream_out.pass.cpp b/test/std/utilities/template.bitset/bitset.operators/stream_out.pass.cpp
new file mode 100644
index 000000000000..05efe27fae85
--- /dev/null
+++ b/test/std/utilities/template.bitset/bitset.operators/stream_out.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test:
+
+// template <class charT, class traits, size_t N>
+// basic_istream<charT, traits>&
+// operator>>(basic_istream<charT, traits>& is, bitset<N>& x);
+
+#include <bitset>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ std::ostringstream os;
+ std::bitset<8> b(0x5A);
+ os << b;
+ assert(os.str() == "01011010");
+}
diff --git a/test/std/utilities/template.bitset/includes.pass.cpp b/test/std/utilities/template.bitset/includes.pass.cpp
new file mode 100644
index 000000000000..2e3c2812e441
--- /dev/null
+++ b/test/std/utilities/template.bitset/includes.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test that <bitset> includes <cstddef>, <string>, <stdexcept> and <iosfwd>
+
+#include <bitset>
+
+#ifndef _LIBCPP_CSTDDEF
+#error <cstddef> has not been included
+#endif
+
+#ifndef _LIBCPP_STRING
+#error <string> has not been included
+#endif
+
+#ifndef _LIBCPP_STDEXCEPT
+#error <stdexcept> has not been included
+#endif
+
+#ifndef _LIBCPP_IOSFWD
+#error <iosfwd> has not been included
+#endif
+
+int main()
+{
+}
diff --git a/test/std/utilities/template.bitset/version.pass.cpp b/test/std/utilities/template.bitset/version.pass.cpp
new file mode 100644
index 000000000000..5ae984c0092d
--- /dev/null
+++ b/test/std/utilities/template.bitset/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <bitset>
+
+#include <bitset>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/utilities/time/clock.h b/test/std/utilities/time/clock.h
new file mode 100644
index 000000000000..c72470c9cc8d
--- /dev/null
+++ b/test/std/utilities/time/clock.h
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef CLOCK_H
+#define CLOCK_H
+
+#include <chrono>
+
+class Clock
+{
+ typedef std::chrono::nanoseconds duration;
+ typedef duration::rep rep;
+ typedef duration::period period;
+ typedef std::chrono::time_point<Clock, duration> time_point;
+ static const bool is_steady = false;
+
+ static time_point now();
+};
+
+#endif // CLOCK_H
diff --git a/test/std/utilities/time/hours.pass.cpp b/test/std/utilities/time/hours.pass.cpp
new file mode 100644
index 000000000000..e4c39f7859e7
--- /dev/null
+++ b/test/std/utilities/time/hours.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// typedef duration<signed integral type of at least 23 bits, ratio<3600>> hours;
+
+#include <chrono>
+#include <type_traits>
+#include <limits>
+
+int main()
+{
+ typedef std::chrono::hours D;
+ typedef D::rep Rep;
+ typedef D::period Period;
+ static_assert(std::is_signed<Rep>::value, "");
+ static_assert(std::is_integral<Rep>::value, "");
+ static_assert(std::numeric_limits<Rep>::digits >= 22, "");
+ static_assert((std::is_same<Period, std::ratio<3600> >::value), "");
+}
diff --git a/test/std/utilities/time/microseconds.pass.cpp b/test/std/utilities/time/microseconds.pass.cpp
new file mode 100644
index 000000000000..1fe6b10da5ac
--- /dev/null
+++ b/test/std/utilities/time/microseconds.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// typedef duration<signed integral type of at least 55 bits, micro> microseconds;
+
+#include <chrono>
+#include <type_traits>
+#include <limits>
+
+int main()
+{
+ typedef std::chrono::microseconds D;
+ typedef D::rep Rep;
+ typedef D::period Period;
+ static_assert(std::is_signed<Rep>::value, "");
+ static_assert(std::is_integral<Rep>::value, "");
+ static_assert(std::numeric_limits<Rep>::digits >= 54, "");
+ static_assert((std::is_same<Period, std::micro>::value), "");
+}
diff --git a/test/std/utilities/time/milliseconds.pass.cpp b/test/std/utilities/time/milliseconds.pass.cpp
new file mode 100644
index 000000000000..75df301f7a65
--- /dev/null
+++ b/test/std/utilities/time/milliseconds.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// typedef duration<signed integral type of at least 45 bits, milli> milliseconds;
+
+#include <chrono>
+#include <type_traits>
+#include <limits>
+
+int main()
+{
+ typedef std::chrono::milliseconds D;
+ typedef D::rep Rep;
+ typedef D::period Period;
+ static_assert(std::is_signed<Rep>::value, "");
+ static_assert(std::is_integral<Rep>::value, "");
+ static_assert(std::numeric_limits<Rep>::digits >= 44, "");
+ static_assert((std::is_same<Period, std::milli>::value), "");
+}
diff --git a/test/std/utilities/time/minutes.pass.cpp b/test/std/utilities/time/minutes.pass.cpp
new file mode 100644
index 000000000000..14214861c073
--- /dev/null
+++ b/test/std/utilities/time/minutes.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// typedef duration<signed integral type of at least 29 bits, ratio< 60>> minutes;
+
+#include <chrono>
+#include <type_traits>
+#include <limits>
+
+int main()
+{
+ typedef std::chrono::minutes D;
+ typedef D::rep Rep;
+ typedef D::period Period;
+ static_assert(std::is_signed<Rep>::value, "");
+ static_assert(std::is_integral<Rep>::value, "");
+ static_assert(std::numeric_limits<Rep>::digits >= 28, "");
+ static_assert((std::is_same<Period, std::ratio<60> >::value), "");
+}
diff --git a/test/std/utilities/time/nanoseconds.pass.cpp b/test/std/utilities/time/nanoseconds.pass.cpp
new file mode 100644
index 000000000000..d422803f4523
--- /dev/null
+++ b/test/std/utilities/time/nanoseconds.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// typedef duration<signed integral type of at least 64 bits, nano> nanoseconds;
+
+#include <chrono>
+#include <type_traits>
+#include <limits>
+
+int main()
+{
+ typedef std::chrono::nanoseconds D;
+ typedef D::rep Rep;
+ typedef D::period Period;
+ static_assert(std::is_signed<Rep>::value, "");
+ static_assert(std::is_integral<Rep>::value, "");
+ static_assert(std::numeric_limits<Rep>::digits >= 63, "");
+ static_assert((std::is_same<Period, std::nano>::value), "");
+}
diff --git a/test/std/utilities/time/rep.h b/test/std/utilities/time/rep.h
new file mode 100644
index 000000000000..2ec3514ab567
--- /dev/null
+++ b/test/std/utilities/time/rep.h
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef REP_H
+#define REP_H
+
+class Rep
+{
+ int data_;
+public:
+ _LIBCPP_CONSTEXPR Rep() : data_(-1) {}
+ explicit _LIBCPP_CONSTEXPR Rep(int i) : data_(i) {}
+
+ bool _LIBCPP_CONSTEXPR operator==(int i) const {return data_ == i;}
+ bool _LIBCPP_CONSTEXPR operator==(const Rep& r) const {return data_ == r.data_;}
+
+ Rep& operator*=(Rep x) {data_ *= x.data_; return *this;}
+ Rep& operator/=(Rep x) {data_ /= x.data_; return *this;}
+};
+
+#endif // REP_H
diff --git a/test/std/utilities/time/seconds.pass.cpp b/test/std/utilities/time/seconds.pass.cpp
new file mode 100644
index 000000000000..231d59695a0a
--- /dev/null
+++ b/test/std/utilities/time/seconds.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// typedef duration<signed integral type of at least 35 bits > seconds;
+
+#include <chrono>
+#include <type_traits>
+#include <limits>
+
+int main()
+{
+ typedef std::chrono::seconds D;
+ typedef D::rep Rep;
+ typedef D::period Period;
+ static_assert(std::is_signed<Rep>::value, "");
+ static_assert(std::is_integral<Rep>::value, "");
+ static_assert(std::numeric_limits<Rep>::digits >= 34, "");
+ static_assert((std::is_same<Period, std::ratio<1> >::value), "");
+}
diff --git a/test/std/utilities/time/time.clock.req/nothing_to_do.pass.cpp b/test/std/utilities/time/time.clock.req/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/utilities/time/time.clock.req/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/utilities/time/time.clock/nothing_to_do.pass.cpp b/test/std/utilities/time/time.clock/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/utilities/time/time.clock/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/utilities/time/time.clock/time.clock.hires/consistency.pass.cpp b/test/std/utilities/time/time.clock/time.clock.hires/consistency.pass.cpp
new file mode 100644
index 000000000000..2e3acbc52b11
--- /dev/null
+++ b/test/std/utilities/time/time.clock/time.clock.hires/consistency.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This test uses new symbols that were not defined in the libc++ shipped on
+// darwin11 and darwin12:
+// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11
+// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12
+
+// <chrono>
+
+// high_resolution_clock
+
+// check clock invariants
+
+#include <chrono>
+
+template <class _Tp>
+void test(const _Tp &) {}
+
+int main()
+{
+ typedef std::chrono::high_resolution_clock C;
+ static_assert((std::is_same<C::rep, C::duration::rep>::value), "");
+ static_assert((std::is_same<C::period, C::duration::period>::value), "");
+ static_assert((std::is_same<C::duration, C::time_point::duration>::value), "");
+ static_assert(C::is_steady || !C::is_steady, "");
+ test(std::chrono::high_resolution_clock::is_steady);
+}
diff --git a/test/std/utilities/time/time.clock/time.clock.hires/now.pass.cpp b/test/std/utilities/time/time.clock/time.clock.hires/now.pass.cpp
new file mode 100644
index 000000000000..ab67cd838f93
--- /dev/null
+++ b/test/std/utilities/time/time.clock/time.clock.hires/now.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// high_resolution_clock
+
+// static time_point now();
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+ typedef std::chrono::high_resolution_clock C;
+ C::time_point t1 = C::now();
+ assert(t1.time_since_epoch().count() != 0);
+ assert(C::time_point::min() < t1);
+ assert(C::time_point::max() > t1);
+}
diff --git a/test/std/utilities/time/time.clock/time.clock.steady/consistency.pass.cpp b/test/std/utilities/time/time.clock/time.clock.steady/consistency.pass.cpp
new file mode 100644
index 000000000000..0e0b83b2f244
--- /dev/null
+++ b/test/std/utilities/time/time.clock/time.clock.steady/consistency.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This test uses new symbols that were not defined in the libc++ shipped on
+// darwin11 and darwin12:
+// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11
+// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12
+// UNSUPPORTED: libcpp-has-no-monotonic-clock
+
+// <chrono>
+
+// steady_clock
+
+// check clock invariants
+
+#include <chrono>
+
+template <class _Tp>
+void test(const _Tp &) {}
+
+int main()
+{
+ typedef std::chrono::steady_clock C;
+ static_assert((std::is_same<C::rep, C::duration::rep>::value), "");
+ static_assert((std::is_same<C::period, C::duration::period>::value), "");
+ static_assert((std::is_same<C::duration, C::time_point::duration>::value), "");
+ static_assert(C::is_steady, "");
+ test(std::chrono::steady_clock::is_steady);
+}
diff --git a/test/std/utilities/time/time.clock/time.clock.steady/now.pass.cpp b/test/std/utilities/time/time.clock/time.clock.steady/now.pass.cpp
new file mode 100644
index 000000000000..4b86d9e8cbc4
--- /dev/null
+++ b/test/std/utilities/time/time.clock/time.clock.steady/now.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-monotonic-clock
+
+// <chrono>
+
+// steady_clock
+
+// static time_point now();
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+ typedef std::chrono::steady_clock C;
+ C::time_point t1 = C::now();
+ C::time_point t2 = C::now();
+ assert(t2 >= t1);
+}
diff --git a/test/std/utilities/time/time.clock/time.clock.system/consistency.pass.cpp b/test/std/utilities/time/time.clock/time.clock.system/consistency.pass.cpp
new file mode 100644
index 000000000000..e277d4e67dc7
--- /dev/null
+++ b/test/std/utilities/time/time.clock/time.clock.system/consistency.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This test uses new symbols that were not defined in the libc++ shipped on
+// darwin11 and darwin12:
+// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11
+// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12
+
+// <chrono>
+
+// system_clock
+
+// check clock invariants
+
+#include <chrono>
+
+template <class _Tp>
+void test(const _Tp &) {}
+
+int main()
+{
+ typedef std::chrono::system_clock C;
+ static_assert((std::is_same<C::rep, C::duration::rep>::value), "");
+ static_assert((std::is_same<C::period, C::duration::period>::value), "");
+ static_assert((std::is_same<C::duration, C::time_point::duration>::value), "");
+ static_assert((std::is_same<C::time_point::clock, C>::value), "");
+ static_assert((C::is_steady || !C::is_steady), "");
+ test(std::chrono::system_clock::is_steady);
+}
diff --git a/test/std/utilities/time/time.clock/time.clock.system/from_time_t.pass.cpp b/test/std/utilities/time/time.clock/time.clock.system/from_time_t.pass.cpp
new file mode 100644
index 000000000000..f4a454f57801
--- /dev/null
+++ b/test/std/utilities/time/time.clock/time.clock.system/from_time_t.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// system_clock
+
+// static time_point from_time_t(time_t t);
+
+#include <chrono>
+#include <ctime>
+
+int main()
+{
+ typedef std::chrono::system_clock C;
+ C::time_point t1 = C::from_time_t(C::to_time_t(C::now()));
+ ((void)t1);
+}
diff --git a/test/std/utilities/time/time.clock/time.clock.system/now.pass.cpp b/test/std/utilities/time/time.clock/time.clock.system/now.pass.cpp
new file mode 100644
index 000000000000..ebc0db80b648
--- /dev/null
+++ b/test/std/utilities/time/time.clock/time.clock.system/now.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// system_clock
+
+// static time_point now();
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+ typedef std::chrono::system_clock C;
+ C::time_point t1 = C::now();
+ assert(t1.time_since_epoch().count() != 0);
+ assert(C::time_point::min() < t1);
+ assert(C::time_point::max() > t1);
+}
diff --git a/test/std/utilities/time/time.clock/time.clock.system/rep_signed.pass.cpp b/test/std/utilities/time/time.clock/time.clock.system/rep_signed.pass.cpp
new file mode 100644
index 000000000000..b6a440e16dd4
--- /dev/null
+++ b/test/std/utilities/time/time.clock/time.clock.system/rep_signed.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// system_clock
+
+// rep should be signed
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+ assert(std::chrono::system_clock::duration::min() <
+ std::chrono::system_clock::duration::zero());
+}
diff --git a/test/std/utilities/time/time.clock/time.clock.system/to_time_t.pass.cpp b/test/std/utilities/time/time.clock/time.clock.system/to_time_t.pass.cpp
new file mode 100644
index 000000000000..c4028063bc53
--- /dev/null
+++ b/test/std/utilities/time/time.clock/time.clock.system/to_time_t.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// system_clock
+
+// time_t to_time_t(const time_point& t);
+
+#include <chrono>
+#include <ctime>
+
+int main()
+{
+ typedef std::chrono::system_clock C;
+ std::time_t t1 = C::to_time_t(C::now());
+ ((void)t1);
+}
diff --git a/test/std/utilities/time/time.duration/default_ratio.pass.cpp b/test/std/utilities/time/time.duration/default_ratio.pass.cpp
new file mode 100644
index 000000000000..a34e27832bdc
--- /dev/null
+++ b/test/std/utilities/time/time.duration/default_ratio.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// Test default template arg:
+
+// template <class Rep, class Period = ratio<1>>
+// class duration;
+
+#include <chrono>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_same<std::chrono::duration<int, std::ratio<1> >,
+ std::chrono::duration<int> >::value), "");
+}
diff --git a/test/std/utilities/time/time.duration/duration.fail.cpp b/test/std/utilities/time/time.duration/duration.fail.cpp
new file mode 100644
index 000000000000..053616b79b43
--- /dev/null
+++ b/test/std/utilities/time/time.duration/duration.fail.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// If a program instantiates duration with a duration type for the template
+// argument Rep a diagnostic is required.
+
+#include <chrono>
+
+int main()
+{
+ typedef std::chrono::duration<std::chrono::milliseconds> D;
+ D d;
+}
diff --git a/test/std/utilities/time/time.duration/positive_num.fail.cpp b/test/std/utilities/time/time.duration/positive_num.fail.cpp
new file mode 100644
index 000000000000..e9096fd3fcb7
--- /dev/null
+++ b/test/std/utilities/time/time.duration/positive_num.fail.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// Period::num shall be positive, diagnostic required.
+
+#include <chrono>
+
+int main()
+{
+ typedef std::chrono::duration<int, std::ratio<5, -1> > D;
+ D d;
+}
diff --git a/test/std/utilities/time/time.duration/ratio.fail.cpp b/test/std/utilities/time/time.duration/ratio.fail.cpp
new file mode 100644
index 000000000000..4ce0aaad003e
--- /dev/null
+++ b/test/std/utilities/time/time.duration/ratio.fail.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// Period shall be a specialization of ratio, diagnostic required.
+
+#include <chrono>
+
+template <int N, int D = 1>
+class Ratio
+{
+public:
+ static const int num = N;
+ static const int den = D;
+};
+
+int main()
+{
+ typedef std::chrono::duration<int, Ratio<1> > D;
+ D d;
+}
diff --git a/test/std/utilities/time/time.duration/time.duration.arithmetic/op_++.pass.cpp b/test/std/utilities/time/time.duration/time.duration.arithmetic/op_++.pass.cpp
new file mode 100644
index 000000000000..8a8f4b1c0d9b
--- /dev/null
+++ b/test/std/utilities/time/time.duration/time.duration.arithmetic/op_++.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// duration& operator++();
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+ std::chrono::hours h(3);
+ std::chrono::hours& href = ++h;
+ assert(&href == &h);
+ assert(h.count() == 4);
+}
diff --git a/test/std/utilities/time/time.duration/time.duration.arithmetic/op_++int.pass.cpp b/test/std/utilities/time/time.duration/time.duration.arithmetic/op_++int.pass.cpp
new file mode 100644
index 000000000000..cf5028281007
--- /dev/null
+++ b/test/std/utilities/time/time.duration/time.duration.arithmetic/op_++int.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// duration operator++(int);
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+ std::chrono::hours h(3);
+ std::chrono::hours h2 = h++;
+ assert(h.count() == 4);
+ assert(h2.count() == 3);
+}
diff --git a/test/std/utilities/time/time.duration/time.duration.arithmetic/op_+.pass.cpp b/test/std/utilities/time/time.duration/time.duration.arithmetic/op_+.pass.cpp
new file mode 100644
index 000000000000..c0f10147ee89
--- /dev/null
+++ b/test/std/utilities/time/time.duration/time.duration.arithmetic/op_+.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// duration operator+() const;
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+ {
+ const std::chrono::minutes m(3);
+ std::chrono::minutes m2 = +m;
+ assert(m.count() == m2.count());
+ }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+ {
+ constexpr std::chrono::minutes m(3);
+ constexpr std::chrono::minutes m2 = +m;
+ static_assert(m.count() == m2.count(), "");
+ }
+#endif
+}
diff --git a/test/std/utilities/time/time.duration/time.duration.arithmetic/op_+=.pass.cpp b/test/std/utilities/time/time.duration/time.duration.arithmetic/op_+=.pass.cpp
new file mode 100644
index 000000000000..8d8cf4539c16
--- /dev/null
+++ b/test/std/utilities/time/time.duration/time.duration.arithmetic/op_+=.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// duration& operator+=(const duration& d);
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+ std::chrono::seconds s(3);
+ s += std::chrono::seconds(2);
+ assert(s.count() == 5);
+ s += std::chrono::minutes(2);
+ assert(s.count() == 125);
+}
diff --git a/test/std/utilities/time/time.duration/time.duration.arithmetic/op_--.pass.cpp b/test/std/utilities/time/time.duration/time.duration.arithmetic/op_--.pass.cpp
new file mode 100644
index 000000000000..0aadfbcd5991
--- /dev/null
+++ b/test/std/utilities/time/time.duration/time.duration.arithmetic/op_--.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// duration& operator--();
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+ std::chrono::hours h(3);
+ std::chrono::hours& href = --h;
+ assert(&href == &h);
+ assert(h.count() == 2);
+}
diff --git a/test/std/utilities/time/time.duration/time.duration.arithmetic/op_--int.pass.cpp b/test/std/utilities/time/time.duration/time.duration.arithmetic/op_--int.pass.cpp
new file mode 100644
index 000000000000..7fc6a1df603f
--- /dev/null
+++ b/test/std/utilities/time/time.duration/time.duration.arithmetic/op_--int.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// duration operator--(int);
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+ std::chrono::hours h(3);
+ std::chrono::hours h2 = h--;
+ assert(h.count() == 2);
+ assert(h2.count() == 3);
+}
diff --git a/test/std/utilities/time/time.duration/time.duration.arithmetic/op_-.pass.cpp b/test/std/utilities/time/time.duration/time.duration.arithmetic/op_-.pass.cpp
new file mode 100644
index 000000000000..00da6f69ca53
--- /dev/null
+++ b/test/std/utilities/time/time.duration/time.duration.arithmetic/op_-.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// duration operator-() const;
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+ {
+ const std::chrono::minutes m(3);
+ std::chrono::minutes m2 = -m;
+ assert(m2.count() == -m.count());
+ }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+ {
+ constexpr std::chrono::minutes m(3);
+ constexpr std::chrono::minutes m2 = -m;
+ static_assert(m2.count() == -m.count(), "");
+ }
+#endif
+}
diff --git a/test/std/utilities/time/time.duration/time.duration.arithmetic/op_-=.pass.cpp b/test/std/utilities/time/time.duration/time.duration.arithmetic/op_-=.pass.cpp
new file mode 100644
index 000000000000..a0a7aed202b1
--- /dev/null
+++ b/test/std/utilities/time/time.duration/time.duration.arithmetic/op_-=.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// duration& operator-=(const duration& d);
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+ std::chrono::seconds s(3);
+ s -= std::chrono::seconds(2);
+ assert(s.count() == 1);
+ s -= std::chrono::minutes(2);
+ assert(s.count() == -119);
+}
diff --git a/test/std/utilities/time/time.duration/time.duration.arithmetic/op_divide=.pass.cpp b/test/std/utilities/time/time.duration/time.duration.arithmetic/op_divide=.pass.cpp
new file mode 100644
index 000000000000..09786bcd8cf8
--- /dev/null
+++ b/test/std/utilities/time/time.duration/time.duration.arithmetic/op_divide=.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// duration& operator/=(const rep& rhs);
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+ std::chrono::nanoseconds ns(15);
+ ns /= 5;
+ assert(ns.count() == 3);
+}
diff --git a/test/std/utilities/time/time.duration/time.duration.arithmetic/op_mod=duration.pass.cpp b/test/std/utilities/time/time.duration/time.duration.arithmetic/op_mod=duration.pass.cpp
new file mode 100644
index 000000000000..8a4a2b472324
--- /dev/null
+++ b/test/std/utilities/time/time.duration/time.duration.arithmetic/op_mod=duration.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// duration& operator%=(const duration& rhs)
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+ std::chrono::microseconds us(11);
+ std::chrono::microseconds us2(3);
+ us %= us2;
+ assert(us.count() == 2);
+ us %= std::chrono::milliseconds(3);
+ assert(us.count() == 2);
+}
diff --git a/test/std/utilities/time/time.duration/time.duration.arithmetic/op_mod=rep.pass.cpp b/test/std/utilities/time/time.duration/time.duration.arithmetic/op_mod=rep.pass.cpp
new file mode 100644
index 000000000000..8758e17ba6af
--- /dev/null
+++ b/test/std/utilities/time/time.duration/time.duration.arithmetic/op_mod=rep.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// duration& operator%=(const rep& rhs)
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+ std::chrono::microseconds us(11);
+ us %= 3;
+ assert(us.count() == 2);
+}
diff --git a/test/std/utilities/time/time.duration/time.duration.arithmetic/op_times=.pass.cpp b/test/std/utilities/time/time.duration/time.duration.arithmetic/op_times=.pass.cpp
new file mode 100644
index 000000000000..b97534a3615a
--- /dev/null
+++ b/test/std/utilities/time/time.duration/time.duration.arithmetic/op_times=.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// duration& operator*=(const rep& rhs);
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+ std::chrono::nanoseconds ns(3);
+ ns *= 5;
+ assert(ns.count() == 15);
+}
diff --git a/test/std/utilities/time/time.duration/time.duration.cast/duration_cast.pass.cpp b/test/std/utilities/time/time.duration/time.duration.cast/duration_cast.pass.cpp
new file mode 100644
index 000000000000..1c87fcd909ef
--- /dev/null
+++ b/test/std/utilities/time/time.duration/time.duration.cast/duration_cast.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// template <class ToDuration, class Rep, class Period>
+// constexpr
+// ToDuration
+// duration_cast(const duration<Rep, Period>& d);
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+template <class ToDuration, class FromDuration>
+void
+test(const FromDuration& f, const ToDuration& d)
+{
+ {
+ typedef decltype(std::chrono::duration_cast<ToDuration>(f)) R;
+ static_assert((std::is_same<R, ToDuration>::value), "");
+ assert(std::chrono::duration_cast<ToDuration>(f) == d);
+ }
+}
+
+int main()
+{
+ test(std::chrono::milliseconds(7265000), std::chrono::hours(2));
+ test(std::chrono::milliseconds(7265000), std::chrono::minutes(121));
+ test(std::chrono::milliseconds(7265000), std::chrono::seconds(7265));
+ test(std::chrono::milliseconds(7265000), std::chrono::milliseconds(7265000));
+ test(std::chrono::milliseconds(7265000), std::chrono::microseconds(7265000000LL));
+ test(std::chrono::milliseconds(7265000), std::chrono::nanoseconds(7265000000000LL));
+ test(std::chrono::milliseconds(7265000),
+ std::chrono::duration<double, std::ratio<3600> >(7265./3600));
+ test(std::chrono::duration<int, std::ratio<2, 3> >(9),
+ std::chrono::duration<int, std::ratio<3, 5> >(10));
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+ {
+ constexpr std::chrono::hours h = std::chrono::duration_cast<std::chrono::hours>(std::chrono::milliseconds(7265000));
+ static_assert(h.count() == 2, "");
+ }
+#endif
+}
diff --git a/test/std/utilities/time/time.duration/time.duration.cast/toduration.fail.cpp b/test/std/utilities/time/time.duration/time.duration.cast/toduration.fail.cpp
new file mode 100644
index 000000000000..13dd8f44c364
--- /dev/null
+++ b/test/std/utilities/time/time.duration/time.duration.cast/toduration.fail.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// template <class ToDuration, class Rep, class Period>
+// ToDuration
+// duration_cast(const duration<Rep, Period>& d);
+
+// ToDuration shall be an instantiation of duration.
+
+#include <chrono>
+
+int main()
+{
+ std::chrono::duration_cast<int>(std::chrono::milliseconds(3));
+}
diff --git a/test/std/utilities/time/time.duration/time.duration.comparisons/op_equal.pass.cpp b/test/std/utilities/time/time.duration/time.duration.comparisons/op_equal.pass.cpp
new file mode 100644
index 000000000000..2d0dd94d4cf6
--- /dev/null
+++ b/test/std/utilities/time/time.duration/time.duration.comparisons/op_equal.pass.cpp
@@ -0,0 +1,115 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// template <class Rep1, class Period1, class Rep2, class Period2>
+// constexpr
+// bool
+// operator==(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
+
+// template <class Rep1, class Period1, class Rep2, class Period2>
+// constexpr
+// bool
+// operator!=(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+ {
+ std::chrono::seconds s1(3);
+ std::chrono::seconds s2(3);
+ assert(s1 == s2);
+ assert(!(s1 != s2));
+ }
+ {
+ std::chrono::seconds s1(3);
+ std::chrono::seconds s2(4);
+ assert(!(s1 == s2));
+ assert(s1 != s2);
+ }
+ {
+ std::chrono::milliseconds s1(3);
+ std::chrono::microseconds s2(3000);
+ assert(s1 == s2);
+ assert(!(s1 != s2));
+ }
+ {
+ std::chrono::milliseconds s1(3);
+ std::chrono::microseconds s2(4000);
+ assert(!(s1 == s2));
+ assert(s1 != s2);
+ }
+ {
+ std::chrono::duration<int, std::ratio<2, 3> > s1(9);
+ std::chrono::duration<int, std::ratio<3, 5> > s2(10);
+ assert(s1 == s2);
+ assert(!(s1 != s2));
+ }
+ {
+ std::chrono::duration<int, std::ratio<2, 3> > s1(10);
+ std::chrono::duration<int, std::ratio<3, 5> > s2(9);
+ assert(!(s1 == s2));
+ assert(s1 != s2);
+ }
+ {
+ std::chrono::duration<int, std::ratio<2, 3> > s1(9);
+ std::chrono::duration<double, std::ratio<3, 5> > s2(10);
+ assert(s1 == s2);
+ assert(!(s1 != s2));
+ }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+ {
+ constexpr std::chrono::seconds s1(3);
+ constexpr std::chrono::seconds s2(3);
+ static_assert(s1 == s2, "");
+ static_assert(!(s1 != s2), "");
+ }
+ {
+ constexpr std::chrono::seconds s1(3);
+ constexpr std::chrono::seconds s2(4);
+ static_assert(!(s1 == s2), "");
+ static_assert(s1 != s2, "");
+ }
+ {
+ constexpr std::chrono::milliseconds s1(3);
+ constexpr std::chrono::microseconds s2(3000);
+ static_assert(s1 == s2, "");
+ static_assert(!(s1 != s2), "");
+ }
+ {
+ constexpr std::chrono::milliseconds s1(3);
+ constexpr std::chrono::microseconds s2(4000);
+ static_assert(!(s1 == s2), "");
+ static_assert(s1 != s2, "");
+ }
+ {
+ constexpr std::chrono::duration<int, std::ratio<2, 3> > s1(9);
+ constexpr std::chrono::duration<int, std::ratio<3, 5> > s2(10);
+ static_assert(s1 == s2, "");
+ static_assert(!(s1 != s2), "");
+ }
+ {
+ constexpr std::chrono::duration<int, std::ratio<2, 3> > s1(10);
+ constexpr std::chrono::duration<int, std::ratio<3, 5> > s2(9);
+ static_assert(!(s1 == s2), "");
+ static_assert(s1 != s2, "");
+ }
+ {
+ constexpr std::chrono::duration<int, std::ratio<2, 3> > s1(9);
+ constexpr std::chrono::duration<double, std::ratio<3, 5> > s2(10);
+ static_assert(s1 == s2, "");
+ static_assert(!(s1 != s2), "");
+ }
+#endif
+}
diff --git a/test/std/utilities/time/time.duration/time.duration.comparisons/op_less.pass.cpp b/test/std/utilities/time/time.duration/time.duration.comparisons/op_less.pass.cpp
new file mode 100644
index 000000000000..9d875579f326
--- /dev/null
+++ b/test/std/utilities/time/time.duration/time.duration.comparisons/op_less.pass.cpp
@@ -0,0 +1,153 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// template <class Rep1, class Period1, class Rep2, class Period2>
+// constexpr
+// bool
+// operator< (const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
+
+// template <class Rep1, class Period1, class Rep2, class Period2>
+// constexpr
+// bool
+// operator> (const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
+
+// template <class Rep1, class Period1, class Rep2, class Period2>
+// constexpr
+// bool
+// operator<=(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
+
+// template <class Rep1, class Period1, class Rep2, class Period2>
+// constexpr
+// bool
+// operator>=(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+ {
+ std::chrono::seconds s1(3);
+ std::chrono::seconds s2(3);
+ assert(!(s1 < s2));
+ assert(!(s1 > s2));
+ assert( (s1 <= s2));
+ assert( (s1 >= s2));
+ }
+ {
+ std::chrono::seconds s1(3);
+ std::chrono::seconds s2(4);
+ assert( (s1 < s2));
+ assert(!(s1 > s2));
+ assert( (s1 <= s2));
+ assert(!(s1 >= s2));
+ }
+ {
+ std::chrono::milliseconds s1(3);
+ std::chrono::microseconds s2(3000);
+ assert(!(s1 < s2));
+ assert(!(s1 > s2));
+ assert( (s1 <= s2));
+ assert( (s1 >= s2));
+ }
+ {
+ std::chrono::milliseconds s1(3);
+ std::chrono::microseconds s2(4000);
+ assert( (s1 < s2));
+ assert(!(s1 > s2));
+ assert( (s1 <= s2));
+ assert(!(s1 >= s2));
+ }
+ {
+ std::chrono::duration<int, std::ratio<2, 3> > s1(9);
+ std::chrono::duration<int, std::ratio<3, 5> > s2(10);
+ assert(!(s1 < s2));
+ assert(!(s1 > s2));
+ assert( (s1 <= s2));
+ assert( (s1 >= s2));
+ }
+ {
+ std::chrono::duration<int, std::ratio<2, 3> > s1(10);
+ std::chrono::duration<int, std::ratio<3, 5> > s2(9);
+ assert(!(s1 < s2));
+ assert( (s1 > s2));
+ assert(!(s1 <= s2));
+ assert( (s1 >= s2));
+ }
+ {
+ std::chrono::duration<int, std::ratio<2, 3> > s1(9);
+ std::chrono::duration<double, std::ratio<3, 5> > s2(10);
+ assert(!(s1 < s2));
+ assert(!(s1 > s2));
+ assert( (s1 <= s2));
+ assert( (s1 >= s2));
+ }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+ {
+ constexpr std::chrono::seconds s1(3);
+ constexpr std::chrono::seconds s2(3);
+ static_assert(!(s1 < s2), "");
+ static_assert(!(s1 > s2), "");
+ static_assert( (s1 <= s2), "");
+ static_assert( (s1 >= s2), "");
+ }
+ {
+ constexpr std::chrono::seconds s1(3);
+ constexpr std::chrono::seconds s2(4);
+ static_assert( (s1 < s2), "");
+ static_assert(!(s1 > s2), "");
+ static_assert( (s1 <= s2), "");
+ static_assert(!(s1 >= s2), "");
+ }
+ {
+ constexpr std::chrono::milliseconds s1(3);
+ constexpr std::chrono::microseconds s2(3000);
+ static_assert(!(s1 < s2), "");
+ static_assert(!(s1 > s2), "");
+ static_assert( (s1 <= s2), "");
+ static_assert( (s1 >= s2), "");
+ }
+ {
+ constexpr std::chrono::milliseconds s1(3);
+ constexpr std::chrono::microseconds s2(4000);
+ static_assert( (s1 < s2), "");
+ static_assert(!(s1 > s2), "");
+ static_assert( (s1 <= s2), "");
+ static_assert(!(s1 >= s2), "");
+ }
+ {
+ constexpr std::chrono::duration<int, std::ratio<2, 3> > s1(9);
+ constexpr std::chrono::duration<int, std::ratio<3, 5> > s2(10);
+ static_assert(!(s1 < s2), "");
+ static_assert(!(s1 > s2), "");
+ static_assert( (s1 <= s2), "");
+ static_assert( (s1 >= s2), "");
+ }
+ {
+ constexpr std::chrono::duration<int, std::ratio<2, 3> > s1(10);
+ constexpr std::chrono::duration<int, std::ratio<3, 5> > s2(9);
+ static_assert(!(s1 < s2), "");
+ static_assert( (s1 > s2), "");
+ static_assert(!(s1 <= s2), "");
+ static_assert( (s1 >= s2), "");
+ }
+ {
+ constexpr std::chrono::duration<int, std::ratio<2, 3> > s1(9);
+ constexpr std::chrono::duration<double, std::ratio<3, 5> > s2(10);
+ static_assert(!(s1 < s2), "");
+ static_assert(!(s1 > s2), "");
+ static_assert( (s1 <= s2), "");
+ static_assert( (s1 >= s2), "");
+ }
+#endif
+}
diff --git a/test/std/utilities/time/time.duration/time.duration.cons/convert_exact.pass.cpp b/test/std/utilities/time/time.duration/time.duration.cons/convert_exact.pass.cpp
new file mode 100644
index 000000000000..152227d82a82
--- /dev/null
+++ b/test/std/utilities/time/time.duration/time.duration.cons/convert_exact.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// template <class Rep2, class Period2>
+// duration(const duration<Rep2, Period2>& d);
+
+// exact conversions allowed for integral reps
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+ {
+ std::chrono::milliseconds ms(1);
+ std::chrono::microseconds us = ms;
+ assert(us.count() == 1000);
+ }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+ {
+ constexpr std::chrono::milliseconds ms(1);
+ constexpr std::chrono::microseconds us = ms;
+ static_assert(us.count() == 1000, "");
+ }
+#endif
+}
diff --git a/test/std/utilities/time/time.duration/time.duration.cons/convert_float_to_int.fail.cpp b/test/std/utilities/time/time.duration/time.duration.cons/convert_float_to_int.fail.cpp
new file mode 100644
index 000000000000..04c082578289
--- /dev/null
+++ b/test/std/utilities/time/time.duration/time.duration.cons/convert_float_to_int.fail.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// template <class Rep2, class Period2>
+// duration(const duration<Rep2, Period2>& d);
+
+// conversions from floating point to integral durations disallowed
+
+#include <chrono>
+
+int main()
+{
+ std::chrono::duration<double> d;
+ std::chrono::duration<int> i = d;
+}
diff --git a/test/std/utilities/time/time.duration/time.duration.cons/convert_inexact.fail.cpp b/test/std/utilities/time/time.duration/time.duration.cons/convert_inexact.fail.cpp
new file mode 100644
index 000000000000..e82e25e8f694
--- /dev/null
+++ b/test/std/utilities/time/time.duration/time.duration.cons/convert_inexact.fail.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// template <class Rep2, class Period2>
+// duration(const duration<Rep2, Period2>& d);
+
+// inexact conversions disallowed for integral reps
+
+#include <chrono>
+
+int main()
+{
+ std::chrono::microseconds us(1);
+ std::chrono::milliseconds ms = us;
+}
diff --git a/test/std/utilities/time/time.duration/time.duration.cons/convert_inexact.pass.cpp b/test/std/utilities/time/time.duration/time.duration.cons/convert_inexact.pass.cpp
new file mode 100644
index 000000000000..519b2b141c29
--- /dev/null
+++ b/test/std/utilities/time/time.duration/time.duration.cons/convert_inexact.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// template <class Rep2, class Period2>
+// duration(const duration<Rep2, Period2>& d);
+
+// inexact conversions allowed for floating point reps
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+ {
+ std::chrono::duration<double, std::micro> us(1);
+ std::chrono::duration<double, std::milli> ms = us;
+ assert(ms.count() == 1./1000);
+ }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+ {
+ constexpr std::chrono::duration<double, std::micro> us(1);
+ constexpr std::chrono::duration<double, std::milli> ms = us;
+ static_assert(ms.count() == 1./1000, "");
+ }
+#endif
+}
diff --git a/test/std/utilities/time/time.duration/time.duration.cons/convert_int_to_float.pass.cpp b/test/std/utilities/time/time.duration/time.duration.cons/convert_int_to_float.pass.cpp
new file mode 100644
index 000000000000..59fefe2e002d
--- /dev/null
+++ b/test/std/utilities/time/time.duration/time.duration.cons/convert_int_to_float.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// template <class Rep2, class Period2>
+// duration(const duration<Rep2, Period2>& d);
+
+// conversions from integral to floating point durations allowed
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+ {
+ std::chrono::duration<int> i(3);
+ std::chrono::duration<double, std::milli> d = i;
+ assert(d.count() == 3000);
+ }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+ {
+ constexpr std::chrono::duration<int> i(3);
+ constexpr std::chrono::duration<double, std::milli> d = i;
+ static_assert(d.count() == 3000, "");
+ }
+#endif
+}
diff --git a/test/std/utilities/time/time.duration/time.duration.cons/convert_overflow.pass.cpp b/test/std/utilities/time/time.duration/time.duration.cons/convert_overflow.pass.cpp
new file mode 100644
index 000000000000..74b65d6b9cc7
--- /dev/null
+++ b/test/std/utilities/time/time.duration/time.duration.cons/convert_overflow.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// template <class Rep2, class Period2>
+// duration(const duration<Rep2, Period2>& d);
+
+// overflow should SFINAE instead of error out, LWG 2094
+
+#include <chrono>
+#include <cassert>
+
+bool called = false;
+
+void f(std::chrono::milliseconds);
+void f(std::chrono::seconds)
+{
+ called = true;
+}
+
+int main()
+{
+ {
+ std::chrono::duration<int, std::exa> r(1);
+ f(r);
+ assert(called);
+ }
+}
diff --git a/test/std/utilities/time/time.duration/time.duration.cons/default.pass.cpp b/test/std/utilities/time/time.duration/time.duration.cons/default.pass.cpp
new file mode 100644
index 000000000000..c52990961c25
--- /dev/null
+++ b/test/std/utilities/time/time.duration/time.duration.cons/default.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// duration() = default;
+
+// Rep must be default initialized, not initialized with 0
+
+#include <chrono>
+#include <cassert>
+
+#include "../../rep.h"
+
+template <class D>
+void
+test()
+{
+ D d;
+ assert(d.count() == typename D::rep());
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+ constexpr D d2 = D();
+ static_assert(d2.count() == typename D::rep(), "");
+#endif
+}
+
+int main()
+{
+ test<std::chrono::duration<Rep> >();
+}
diff --git a/test/std/utilities/time/time.duration/time.duration.cons/rep.pass.cpp b/test/std/utilities/time/time.duration/time.duration.cons/rep.pass.cpp
new file mode 100644
index 000000000000..20f81619bd12
--- /dev/null
+++ b/test/std/utilities/time/time.duration/time.duration.cons/rep.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// template <class Rep2>
+// explicit duration(const Rep2& r);
+
+#include <chrono>
+#include <cassert>
+
+#include "../../rep.h"
+
+template <class D, class R>
+void
+test(R r)
+{
+ D d(r);
+ assert(d.count() == r);
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+ constexpr D d2(R(2));
+ static_assert(d2.count() == 2, "");
+#endif
+}
+
+int main()
+{
+ test<std::chrono::duration<int> >(5);
+ test<std::chrono::duration<int, std::ratio<3, 2> > >(5);
+ test<std::chrono::duration<Rep, std::ratio<3, 2> > >(Rep(3));
+ test<std::chrono::duration<double, std::ratio<2, 3> > >(5.5);
+}
diff --git a/test/std/utilities/time/time.duration/time.duration.cons/rep01.fail.cpp b/test/std/utilities/time/time.duration/time.duration.cons/rep01.fail.cpp
new file mode 100644
index 000000000000..9f071ca1afc0
--- /dev/null
+++ b/test/std/utilities/time/time.duration/time.duration.cons/rep01.fail.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// template <class Rep2>
+// explicit duration(const Rep2& r);
+
+// test for explicit
+
+#include <chrono>
+
+#include "../../rep.h"
+
+int main()
+{
+ std::chrono::duration<int> d = 1;
+}
diff --git a/test/std/utilities/time/time.duration/time.duration.cons/rep02.fail.cpp b/test/std/utilities/time/time.duration/time.duration.cons/rep02.fail.cpp
new file mode 100644
index 000000000000..37f32e77686a
--- /dev/null
+++ b/test/std/utilities/time/time.duration/time.duration.cons/rep02.fail.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// template <class Rep2>
+// explicit duration(const Rep2& r);
+
+// Rep2 shall be implicitly convertible to rep
+
+#include <chrono>
+
+#include "../../rep.h"
+
+int main()
+{
+ std::chrono::duration<Rep> d(1);
+}
diff --git a/test/std/utilities/time/time.duration/time.duration.cons/rep02.pass.cpp b/test/std/utilities/time/time.duration/time.duration.cons/rep02.pass.cpp
new file mode 100644
index 000000000000..b3ba9f7081e4
--- /dev/null
+++ b/test/std/utilities/time/time.duration/time.duration.cons/rep02.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// template <class Rep2>
+// explicit duration(const Rep2& r);
+
+// construct double with int
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+ std::chrono::duration<double> d(5);
+ assert(d.count() == 5);
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+ constexpr std::chrono::duration<double> d2(5);
+ static_assert(d2.count() == 5, "");
+#endif
+}
diff --git a/test/std/utilities/time/time.duration/time.duration.cons/rep03.fail.cpp b/test/std/utilities/time/time.duration/time.duration.cons/rep03.fail.cpp
new file mode 100644
index 000000000000..4ace54b231ff
--- /dev/null
+++ b/test/std/utilities/time/time.duration/time.duration.cons/rep03.fail.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// template <class Rep2>
+// explicit duration(const Rep2& r);
+
+// treat_as_floating_point<Rep2>::value shall be false
+
+#include <chrono>
+
+int main()
+{
+ std::chrono::duration<int> d(1.);
+}
diff --git a/test/std/utilities/time/time.duration/time.duration.literals/literals.pass.cpp b/test/std/utilities/time/time.duration/time.duration.literals/literals.pass.cpp
new file mode 100644
index 000000000000..48324ae83651
--- /dev/null
+++ b/test/std/utilities/time/time.duration/time.duration.literals/literals.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ using namespace std::literals::chrono_literals;
+
+// Make sure the types are right
+ static_assert ( std::is_same<decltype( 3h ), std::chrono::hours>::value, "" );
+ static_assert ( std::is_same<decltype( 3min ), std::chrono::minutes>::value, "" );
+ static_assert ( std::is_same<decltype( 3s ), std::chrono::seconds>::value, "" );
+ static_assert ( std::is_same<decltype( 3ms ), std::chrono::milliseconds>::value, "" );
+ static_assert ( std::is_same<decltype( 3us ), std::chrono::microseconds>::value, "" );
+ static_assert ( std::is_same<decltype( 3ns ), std::chrono::nanoseconds>::value, "" );
+
+ std::chrono::hours h = 4h;
+ assert ( h == std::chrono::hours(4));
+ auto h2 = 4.0h;
+ assert ( h == h2 );
+
+ std::chrono::minutes min = 36min;
+ assert ( min == std::chrono::minutes(36));
+ auto min2 = 36.0min;
+ assert ( min == min2 );
+
+ std::chrono::seconds s = 24s;
+ assert ( s == std::chrono::seconds(24));
+ auto s2 = 24.0s;
+ assert ( s == s2 );
+
+ std::chrono::milliseconds ms = 247ms;
+ assert ( ms == std::chrono::milliseconds(247));
+ auto ms2 = 247.0ms;
+ assert ( ms == ms2 );
+
+ std::chrono::microseconds us = 867us;
+ assert ( us == std::chrono::microseconds(867));
+ auto us2 = 867.0us;
+ assert ( us == us2 );
+
+ std::chrono::nanoseconds ns = 645ns;
+ assert ( ns == std::chrono::nanoseconds(645));
+ auto ns2 = 645.ns;
+ assert ( ns == ns2 );
+#endif
+}
diff --git a/test/std/utilities/time/time.duration/time.duration.literals/literals1.fail.cpp b/test/std/utilities/time/time.duration/time.duration.literals/literals1.fail.cpp
new file mode 100644
index 000000000000..46aaa30e51e4
--- /dev/null
+++ b/test/std/utilities/time/time.duration/time.duration.literals/literals1.fail.cpp
@@ -0,0 +1,21 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ std::chrono::hours h = 4h; // should fail w/conversion operator not found
+#else
+#error
+#endif
+}
+
diff --git a/test/std/utilities/time/time.duration/time.duration.literals/literals1.pass.cpp b/test/std/utilities/time/time.duration/time.duration.literals/literals1.pass.cpp
new file mode 100644
index 000000000000..574f9bcce874
--- /dev/null
+++ b/test/std/utilities/time/time.duration/time.duration.literals/literals1.pass.cpp
@@ -0,0 +1,48 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ using namespace std::chrono;
+
+ hours h = 4h;
+ assert ( h == hours(4));
+ auto h2 = 4.0h;
+ assert ( h == h2 );
+
+ minutes min = 36min;
+ assert ( min == minutes(36));
+ auto min2 = 36.0min;
+ assert ( min == min2 );
+
+ seconds s = 24s;
+ assert ( s == seconds(24));
+ auto s2 = 24.0s;
+ assert ( s == s2 );
+
+ milliseconds ms = 247ms;
+ assert ( ms == milliseconds(247));
+ auto ms2 = 247.0ms;
+ assert ( ms == ms2 );
+
+ microseconds us = 867us;
+ assert ( us == microseconds(867));
+ auto us2 = 867.0us;
+ assert ( us == us2 );
+
+ nanoseconds ns = 645ns;
+ assert ( ns == nanoseconds(645));
+ auto ns2 = 645.ns;
+ assert ( ns == ns2 );
+#endif
+}
diff --git a/test/std/utilities/time/time.duration/time.duration.literals/literals2.fail.cpp b/test/std/utilities/time/time.duration/time.duration.literals/literals2.fail.cpp
new file mode 100644
index 000000000000..17358e589f4f
--- /dev/null
+++ b/test/std/utilities/time/time.duration/time.duration.literals/literals2.fail.cpp
@@ -0,0 +1,22 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ using std::chrono::hours;
+
+ hours foo = 4h; // should fail w/conversion operator not found
+#else
+#error
+#endif
+}
diff --git a/test/std/utilities/time/time.duration/time.duration.literals/literals2.pass.cpp b/test/std/utilities/time/time.duration/time.duration.literals/literals2.pass.cpp
new file mode 100644
index 000000000000..e37bc6e67961
--- /dev/null
+++ b/test/std/utilities/time/time.duration/time.duration.literals/literals2.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ using namespace std::literals;
+
+ std::chrono::hours h = 4h;
+ assert ( h == std::chrono::hours(4));
+ auto h2 = 4.0h;
+ assert ( h == h2 );
+
+ std::chrono::minutes min = 36min;
+ assert ( min == std::chrono::minutes(36));
+ auto min2 = 36.0min;
+ assert ( min == min2 );
+
+ std::chrono::seconds s = 24s;
+ assert ( s == std::chrono::seconds(24));
+ auto s2 = 24.0s;
+ assert ( s == s2 );
+
+ std::chrono::milliseconds ms = 247ms;
+ assert ( ms == std::chrono::milliseconds(247));
+ auto ms2 = 247.0ms;
+ assert ( ms == ms2 );
+
+ std::chrono::microseconds us = 867us;
+ assert ( us == std::chrono::microseconds(867));
+ auto us2 = 867.0us;
+ assert ( us == us2 );
+
+ std::chrono::nanoseconds ns = 645ns;
+ assert ( ns == std::chrono::nanoseconds(645));
+ auto ns2 = 645.ns;
+ assert ( ns == ns2 );
+#endif
+}
diff --git a/test/std/utilities/time/time.duration/time.duration.nonmember/op_+.pass.cpp b/test/std/utilities/time/time.duration/time.duration.nonmember/op_+.pass.cpp
new file mode 100644
index 000000000000..6585351cb4c8
--- /dev/null
+++ b/test/std/utilities/time/time.duration/time.duration.nonmember/op_+.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// template <class Rep1, class Period1, class Rep2, class Period2>
+// typename common_type<duration<Rep1, Period1>, duration<Rep2, Period2>>::type
+// operator+(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+ {
+ std::chrono::seconds s1(3);
+ std::chrono::seconds s2(5);
+ std::chrono::seconds r = s1 + s2;
+ assert(r.count() == 8);
+ }
+ {
+ std::chrono::seconds s1(3);
+ std::chrono::microseconds s2(5);
+ std::chrono::microseconds r = s1 + s2;
+ assert(r.count() == 3000005);
+ }
+ {
+ std::chrono::duration<int, std::ratio<2, 3> > s1(3);
+ std::chrono::duration<int, std::ratio<3, 5> > s2(5);
+ std::chrono::duration<int, std::ratio<1, 15> > r = s1 + s2;
+ assert(r.count() == 75);
+ }
+ {
+ std::chrono::duration<int, std::ratio<2, 3> > s1(3);
+ std::chrono::duration<double, std::ratio<3, 5> > s2(5);
+ std::chrono::duration<double, std::ratio<1, 15> > r = s1 + s2;
+ assert(r.count() == 75);
+ }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+ {
+ constexpr std::chrono::seconds s1(3);
+ constexpr std::chrono::seconds s2(5);
+ constexpr std::chrono::seconds r = s1 + s2;
+ static_assert(r.count() == 8, "");
+ }
+ {
+ constexpr std::chrono::seconds s1(3);
+ constexpr std::chrono::microseconds s2(5);
+ constexpr std::chrono::microseconds r = s1 + s2;
+ static_assert(r.count() == 3000005, "");
+ }
+ {
+ constexpr std::chrono::duration<int, std::ratio<2, 3> > s1(3);
+ constexpr std::chrono::duration<int, std::ratio<3, 5> > s2(5);
+ constexpr std::chrono::duration<int, std::ratio<1, 15> > r = s1 + s2;
+ static_assert(r.count() == 75, "");
+ }
+ {
+ constexpr std::chrono::duration<int, std::ratio<2, 3> > s1(3);
+ constexpr std::chrono::duration<double, std::ratio<3, 5> > s2(5);
+ constexpr std::chrono::duration<double, std::ratio<1, 15> > r = s1 + s2;
+ static_assert(r.count() == 75, "");
+ }
+#endif
+}
diff --git a/test/std/utilities/time/time.duration/time.duration.nonmember/op_-.pass.cpp b/test/std/utilities/time/time.duration/time.duration.nonmember/op_-.pass.cpp
new file mode 100644
index 000000000000..fac58b9716d3
--- /dev/null
+++ b/test/std/utilities/time/time.duration/time.duration.nonmember/op_-.pass.cpp
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// template <class Rep1, class Period1, class Rep2, class Period2>
+// constexpr
+// typename common_type<duration<Rep1, Period1>, duration<Rep2, Period2>>::type
+// operator-(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+ {
+ std::chrono::seconds s1(3);
+ std::chrono::seconds s2(5);
+ std::chrono::seconds r = s1 - s2;
+ assert(r.count() == -2);
+ }
+ {
+ std::chrono::seconds s1(3);
+ std::chrono::microseconds s2(5);
+ std::chrono::microseconds r = s1 - s2;
+ assert(r.count() == 2999995);
+ }
+ {
+ std::chrono::duration<int, std::ratio<2, 3> > s1(3);
+ std::chrono::duration<int, std::ratio<3, 5> > s2(5);
+ std::chrono::duration<int, std::ratio<1, 15> > r = s1 - s2;
+ assert(r.count() == -15);
+ }
+ {
+ std::chrono::duration<int, std::ratio<2, 3> > s1(3);
+ std::chrono::duration<double, std::ratio<3, 5> > s2(5);
+ std::chrono::duration<double, std::ratio<1, 15> > r = s1 - s2;
+ assert(r.count() == -15);
+ }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+ {
+ constexpr std::chrono::seconds s1(3);
+ constexpr std::chrono::seconds s2(5);
+ constexpr std::chrono::seconds r = s1 - s2;
+ static_assert(r.count() == -2, "");
+ }
+ {
+ constexpr std::chrono::seconds s1(3);
+ constexpr std::chrono::microseconds s2(5);
+ constexpr std::chrono::microseconds r = s1 - s2;
+ static_assert(r.count() == 2999995, "");
+ }
+ {
+ constexpr std::chrono::duration<int, std::ratio<2, 3> > s1(3);
+ constexpr std::chrono::duration<int, std::ratio<3, 5> > s2(5);
+ constexpr std::chrono::duration<int, std::ratio<1, 15> > r = s1 - s2;
+ static_assert(r.count() == -15, "");
+ }
+ {
+ constexpr std::chrono::duration<int, std::ratio<2, 3> > s1(3);
+ constexpr std::chrono::duration<double, std::ratio<3, 5> > s2(5);
+ constexpr std::chrono::duration<double, std::ratio<1, 15> > r = s1 - s2;
+ static_assert(r.count() == -15, "");
+ }
+#endif
+}
diff --git a/test/std/utilities/time/time.duration/time.duration.nonmember/op_divide_duration.pass.cpp b/test/std/utilities/time/time.duration/time.duration.nonmember/op_divide_duration.pass.cpp
new file mode 100644
index 000000000000..6b24676f100c
--- /dev/null
+++ b/test/std/utilities/time/time.duration/time.duration.nonmember/op_divide_duration.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// template <class Rep1, class Period1, class Rep2, class Period2>
+// constexpr
+// typename common_type<Rep1, Rep2>::type
+// operator/(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+ {
+ std::chrono::nanoseconds ns1(15);
+ std::chrono::nanoseconds ns2(5);
+ assert(ns1 / ns2 == 3);
+ }
+ {
+ std::chrono::microseconds us1(15);
+ std::chrono::nanoseconds ns2(5);
+ assert(us1 / ns2 == 3000);
+ }
+ {
+ std::chrono::duration<int, std::ratio<2, 3> > s1(30);
+ std::chrono::duration<int, std::ratio<3, 5> > s2(5);
+ assert(s1 / s2 == 6);
+ }
+ {
+ std::chrono::duration<int, std::ratio<2, 3> > s1(30);
+ std::chrono::duration<double, std::ratio<3, 5> > s2(5);
+ assert(s1 / s2 == 20./3);
+ }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+ {
+ constexpr std::chrono::nanoseconds ns1(15);
+ constexpr std::chrono::nanoseconds ns2(5);
+ static_assert(ns1 / ns2 == 3, "");
+ }
+ {
+ constexpr std::chrono::microseconds us1(15);
+ constexpr std::chrono::nanoseconds ns2(5);
+ static_assert(us1 / ns2 == 3000, "");
+ }
+ {
+ constexpr std::chrono::duration<int, std::ratio<2, 3> > s1(30);
+ constexpr std::chrono::duration<int, std::ratio<3, 5> > s2(5);
+ static_assert(s1 / s2 == 6, "");
+ }
+ {
+ constexpr std::chrono::duration<int, std::ratio<2, 3> > s1(30);
+ constexpr std::chrono::duration<double, std::ratio<3, 5> > s2(5);
+ static_assert(s1 / s2 == 20./3, "");
+ }
+#endif
+}
diff --git a/test/std/utilities/time/time.duration/time.duration.nonmember/op_divide_rep.fail.cpp b/test/std/utilities/time/time.duration/time.duration.nonmember/op_divide_rep.fail.cpp
new file mode 100644
index 000000000000..db725773fd47
--- /dev/null
+++ b/test/std/utilities/time/time.duration/time.duration.nonmember/op_divide_rep.fail.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// template <class Rep1, class Period, class Rep2>
+// duration<typename common_type<Rep1, Rep2>::type, Period>
+// operator/(const duration<Rep1, Period>& d, const Rep2& s);
+
+#include <chrono>
+
+#include "../../rep.h"
+
+int main()
+{
+ std::chrono::duration<Rep> d(Rep(15));
+ d = d / 5;
+}
diff --git a/test/std/utilities/time/time.duration/time.duration.nonmember/op_divide_rep.pass.cpp b/test/std/utilities/time/time.duration/time.duration.nonmember/op_divide_rep.pass.cpp
new file mode 100644
index 000000000000..3036cde5bf67
--- /dev/null
+++ b/test/std/utilities/time/time.duration/time.duration.nonmember/op_divide_rep.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// template <class Rep1, class Period, class Rep2>
+// constexpr
+// duration<typename common_type<Rep1, Rep2>::type, Period>
+// operator/(const duration<Rep1, Period>& d, const Rep2& s);
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+ {
+ std::chrono::nanoseconds ns(15);
+ ns = ns / 5;
+ assert(ns.count() == 3);
+ }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+ {
+ constexpr std::chrono::nanoseconds ns(15);
+ constexpr std::chrono::nanoseconds ns2 = ns / 5;
+ static_assert(ns2.count() == 3, "");
+ }
+#endif
+}
diff --git a/test/std/utilities/time/time.duration/time.duration.nonmember/op_mod_duration.pass.cpp b/test/std/utilities/time/time.duration/time.duration.nonmember/op_mod_duration.pass.cpp
new file mode 100644
index 000000000000..e69f3205d14f
--- /dev/null
+++ b/test/std/utilities/time/time.duration/time.duration.nonmember/op_mod_duration.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// template <class Rep1, class Period1, class Rep2, class Period2>
+// constexpr
+// typename common_type<duration<Rep1, Period1>, duration<Rep2, Period2>>::type
+// operator%(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+ {
+ std::chrono::nanoseconds ns1(15);
+ std::chrono::nanoseconds ns2(6);
+ std::chrono::nanoseconds r = ns1 % ns2;
+ assert(r.count() == 3);
+ }
+ {
+ std::chrono::microseconds us1(15);
+ std::chrono::nanoseconds ns2(28);
+ std::chrono::nanoseconds r = us1 % ns2;
+ assert(r.count() == 20);
+ }
+ {
+ std::chrono::duration<int, std::ratio<3, 5> > s1(6);
+ std::chrono::duration<int, std::ratio<2, 3> > s2(3);
+ std::chrono::duration<int, std::ratio<1, 15> > r = s1 % s2;
+ assert(r.count() == 24);
+ }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+ {
+ constexpr std::chrono::nanoseconds ns1(15);
+ constexpr std::chrono::nanoseconds ns2(6);
+ constexpr std::chrono::nanoseconds r = ns1 % ns2;
+ static_assert(r.count() == 3, "");
+ }
+ {
+ constexpr std::chrono::microseconds us1(15);
+ constexpr std::chrono::nanoseconds ns2(28);
+ constexpr std::chrono::nanoseconds r = us1 % ns2;
+ static_assert(r.count() == 20, "");
+ }
+ {
+ constexpr std::chrono::duration<int, std::ratio<3, 5> > s1(6);
+ constexpr std::chrono::duration<int, std::ratio<2, 3> > s2(3);
+ constexpr std::chrono::duration<int, std::ratio<1, 15> > r = s1 % s2;
+ static_assert(r.count() == 24, "");
+ }
+#endif
+}
diff --git a/test/std/utilities/time/time.duration/time.duration.nonmember/op_mod_rep.fail.cpp b/test/std/utilities/time/time.duration/time.duration.nonmember/op_mod_rep.fail.cpp
new file mode 100644
index 000000000000..16e511d44f66
--- /dev/null
+++ b/test/std/utilities/time/time.duration/time.duration.nonmember/op_mod_rep.fail.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// template <class Rep1, class Period, class Rep2>
+// duration<typename common_type<Rep1, Rep2>::type, Period>
+// operator%(const duration<Rep1, Period>& d, const Rep2& s)
+
+#include <chrono>
+
+#include "../../rep.h"
+
+int main()
+{
+ std::chrono::duration<Rep> d(Rep(15));
+ d = d % 5;
+}
diff --git a/test/std/utilities/time/time.duration/time.duration.nonmember/op_mod_rep.pass.cpp b/test/std/utilities/time/time.duration/time.duration.nonmember/op_mod_rep.pass.cpp
new file mode 100644
index 000000000000..1acbe34ea5eb
--- /dev/null
+++ b/test/std/utilities/time/time.duration/time.duration.nonmember/op_mod_rep.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// template <class Rep1, class Period, class Rep2>
+// constexpr
+// duration<typename common_type<Rep1, Rep2>::type, Period>
+// operator%(const duration<Rep1, Period>& d, const Rep2& s)
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+ {
+ std::chrono::nanoseconds ns(15);
+ ns = ns % 6;
+ assert(ns.count() == 3);
+ }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+ {
+ constexpr std::chrono::nanoseconds ns(15);
+ constexpr std::chrono::nanoseconds ns2 = ns % 6;
+ static_assert(ns2.count() == 3, "");
+ }
+#endif
+}
diff --git a/test/std/utilities/time/time.duration/time.duration.nonmember/op_times_rep.pass.cpp b/test/std/utilities/time/time.duration/time.duration.nonmember/op_times_rep.pass.cpp
new file mode 100644
index 000000000000..190e74b1dc32
--- /dev/null
+++ b/test/std/utilities/time/time.duration/time.duration.nonmember/op_times_rep.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// template <class Rep1, class Period, class Rep2>
+// constexpr
+// duration<typename common_type<Rep1, Rep2>::type, Period>
+// operator*(const duration<Rep1, Period>& d, const Rep2& s);
+
+// template <class Rep1, class Period, class Rep2>
+// constexpr
+// duration<typename common_type<Rep1, Rep2>::type, Period>
+// operator*(const Rep1& s, const duration<Rep2, Period>& d);
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+ {
+ std::chrono::nanoseconds ns(3);
+ ns = ns * 5;
+ assert(ns.count() == 15);
+ ns = 6 * ns;
+ assert(ns.count() == 90);
+ }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+ {
+ constexpr std::chrono::nanoseconds ns(3);
+ constexpr std::chrono::nanoseconds ns2 = ns * 5;
+ static_assert(ns2.count() == 15, "");
+ constexpr std::chrono::nanoseconds ns3 = 6 * ns;
+ static_assert(ns3.count() == 18, "");
+ }
+#endif
+}
diff --git a/test/std/utilities/time/time.duration/time.duration.nonmember/op_times_rep1.fail.cpp b/test/std/utilities/time/time.duration/time.duration.nonmember/op_times_rep1.fail.cpp
new file mode 100644
index 000000000000..d8160500f916
--- /dev/null
+++ b/test/std/utilities/time/time.duration/time.duration.nonmember/op_times_rep1.fail.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// template <class Rep1, class Period, class Rep2>
+// duration<typename common_type<Rep1, Rep2>::type, Period>
+// operator*(const duration<Rep1, Period>& d, const Rep2& s);
+
+// template <class Rep1, class Period, class Rep2>
+// duration<typename common_type<Rep1, Rep2>::type, Period>
+// operator*(const Rep1& s, const duration<Rep2, Period>& d);
+
+#include <chrono>
+
+#include "../../rep.h"
+
+int main()
+{
+ std::chrono::duration<Rep> d;
+ d = d * 5;
+}
diff --git a/test/std/utilities/time/time.duration/time.duration.nonmember/op_times_rep2.fail.cpp b/test/std/utilities/time/time.duration/time.duration.nonmember/op_times_rep2.fail.cpp
new file mode 100644
index 000000000000..e224ba942109
--- /dev/null
+++ b/test/std/utilities/time/time.duration/time.duration.nonmember/op_times_rep2.fail.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// template <class Rep1, class Period, class Rep2>
+// duration<typename common_type<Rep1, Rep2>::type, Period>
+// operator*(const duration<Rep1, Period>& d, const Rep2& s);
+
+// template <class Rep1, class Period, class Rep2>
+// duration<typename common_type<Rep1, Rep2>::type, Period>
+// operator*(const Rep1& s, const duration<Rep2, Period>& d);
+
+#include <chrono>
+
+#include "../../rep.h"
+
+int main()
+{
+ std::chrono::duration<Rep> d;
+ d = 5 * d;
+}
diff --git a/test/std/utilities/time/time.duration/time.duration.observer/tested_elsewhere.pass.cpp b/test/std/utilities/time/time.duration/time.duration.observer/tested_elsewhere.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/utilities/time/time.duration/time.duration.observer/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/utilities/time/time.duration/time.duration.special/max.pass.cpp b/test/std/utilities/time/time.duration/time.duration.special/max.pass.cpp
new file mode 100644
index 000000000000..405461e88ae9
--- /dev/null
+++ b/test/std/utilities/time/time.duration/time.duration.special/max.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// static constexpr duration max();
+
+#include <chrono>
+#include <limits>
+#include <cassert>
+
+#include "../../rep.h"
+
+template <class D>
+void test()
+{
+ {
+ typedef typename D::rep Rep;
+ Rep max_rep = std::chrono::duration_values<Rep>::max();
+ assert(D::max().count() == max_rep);
+ }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+ {
+ typedef typename D::rep Rep;
+ constexpr Rep max_rep = std::chrono::duration_values<Rep>::max();
+ static_assert(D::max().count() == max_rep, "");
+ }
+#endif
+}
+
+int main()
+{
+ test<std::chrono::duration<int> >();
+ test<std::chrono::duration<Rep> >();
+}
diff --git a/test/std/utilities/time/time.duration/time.duration.special/min.pass.cpp b/test/std/utilities/time/time.duration/time.duration.special/min.pass.cpp
new file mode 100644
index 000000000000..44cd64eff3d3
--- /dev/null
+++ b/test/std/utilities/time/time.duration/time.duration.special/min.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// static constexpr duration min();
+
+#include <chrono>
+#include <limits>
+#include <cassert>
+
+#include "../../rep.h"
+
+template <class D>
+void test()
+{
+ {
+ typedef typename D::rep Rep;
+ Rep min_rep = std::chrono::duration_values<Rep>::min();
+ assert(D::min().count() == min_rep);
+ }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+ {
+ typedef typename D::rep Rep;
+ constexpr Rep min_rep = std::chrono::duration_values<Rep>::min();
+ static_assert(D::min().count() == min_rep, "");
+ }
+#endif
+}
+
+int main()
+{
+ test<std::chrono::duration<int> >();
+ test<std::chrono::duration<Rep> >();
+}
diff --git a/test/std/utilities/time/time.duration/time.duration.special/zero.pass.cpp b/test/std/utilities/time/time.duration/time.duration.special/zero.pass.cpp
new file mode 100644
index 000000000000..18350fe2ff47
--- /dev/null
+++ b/test/std/utilities/time/time.duration/time.duration.special/zero.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// static constexpr duration zero();
+
+#include <chrono>
+#include <cassert>
+
+#include "../../rep.h"
+
+template <class D>
+void test()
+{
+ {
+ typedef typename D::rep Rep;
+ Rep zero_rep = std::chrono::duration_values<Rep>::zero();
+ assert(D::zero().count() == zero_rep);
+ }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+ {
+ typedef typename D::rep Rep;
+ constexpr Rep zero_rep = std::chrono::duration_values<Rep>::zero();
+ static_assert(D::zero().count() == zero_rep, "");
+ }
+#endif
+}
+
+int main()
+{
+ test<std::chrono::duration<int> >();
+ test<std::chrono::duration<Rep> >();
+}
diff --git a/test/std/utilities/time/time.duration/types.pass.cpp b/test/std/utilities/time/time.duration/types.pass.cpp
new file mode 100644
index 000000000000..8eaffe77651c
--- /dev/null
+++ b/test/std/utilities/time/time.duration/types.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// Test nested types
+
+// typedef Rep rep;
+// typedef Period period;
+
+#include <chrono>
+#include <type_traits>
+
+int main()
+{
+ typedef std::chrono::duration<long, std::ratio<3, 2> > D;
+ static_assert((std::is_same<D::rep, long>::value), "");
+ static_assert((std::is_same<D::period, std::ratio<3, 2> >::value), "");
+}
diff --git a/test/std/utilities/time/time.point/default_duration.pass.cpp b/test/std/utilities/time/time.point/default_duration.pass.cpp
new file mode 100644
index 000000000000..dfdf225ed472
--- /dev/null
+++ b/test/std/utilities/time/time.point/default_duration.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// time_point
+
+// Test default template arg:
+
+// template <class Clock, class Duration = typename Clock::duration>
+// class time_point;
+
+#include <chrono>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_same<std::chrono::system_clock::duration,
+ std::chrono::time_point<std::chrono::system_clock>::duration>::value), "");
+}
diff --git a/test/std/utilities/time/time.point/duration.fail.cpp b/test/std/utilities/time/time.point/duration.fail.cpp
new file mode 100644
index 000000000000..ee48bcb392ec
--- /dev/null
+++ b/test/std/utilities/time/time.point/duration.fail.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// time_point
+
+// Duration shall be an instance of duration.
+
+#include <chrono>
+
+int main()
+{
+ typedef std::chrono::time_point<std::chrono::system_clock, int> T;
+ T t;
+}
diff --git a/test/std/utilities/time/time.point/time.point.arithmetic/op_+=.pass.cpp b/test/std/utilities/time/time.point/time.point.arithmetic/op_+=.pass.cpp
new file mode 100644
index 000000000000..ffe855ce9031
--- /dev/null
+++ b/test/std/utilities/time/time.point/time.point.arithmetic/op_+=.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// time_point
+
+// time_point& operator+=(const duration& d);
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+ typedef std::chrono::system_clock Clock;
+ typedef std::chrono::milliseconds Duration;
+ std::chrono::time_point<Clock, Duration> t(Duration(3));
+ t += Duration(2);
+ assert(t.time_since_epoch() == Duration(5));
+}
diff --git a/test/std/utilities/time/time.point/time.point.arithmetic/op_-=.pass.cpp b/test/std/utilities/time/time.point/time.point.arithmetic/op_-=.pass.cpp
new file mode 100644
index 000000000000..acad1cfecb44
--- /dev/null
+++ b/test/std/utilities/time/time.point/time.point.arithmetic/op_-=.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// time_point
+
+// time_point& operator-=(const duration& d);
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+ typedef std::chrono::system_clock Clock;
+ typedef std::chrono::milliseconds Duration;
+ std::chrono::time_point<Clock, Duration> t(Duration(3));
+ t -= Duration(2);
+ assert(t.time_since_epoch() == Duration(1));
+}
diff --git a/test/std/utilities/time/time.point/time.point.cast/time_point_cast.pass.cpp b/test/std/utilities/time/time.point/time.point.cast/time_point_cast.pass.cpp
new file mode 100644
index 000000000000..7d7e82ac5e23
--- /dev/null
+++ b/test/std/utilities/time/time.point/time.point.cast/time_point_cast.pass.cpp
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// time_point
+
+// template <class ToDuration, class Clock, class Duration>
+// time_point<Clock, ToDuration>
+// time_point_cast(const time_point<Clock, Duration>& t);
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+template <class FromDuration, class ToDuration>
+void
+test(const FromDuration& df, const ToDuration& d)
+{
+ typedef std::chrono::system_clock Clock;
+ typedef std::chrono::time_point<Clock, FromDuration> FromTimePoint;
+ typedef std::chrono::time_point<Clock, ToDuration> ToTimePoint;
+ {
+ FromTimePoint f(df);
+ ToTimePoint t(d);
+ typedef decltype(std::chrono::time_point_cast<ToDuration>(f)) R;
+ static_assert((std::is_same<R, ToTimePoint>::value), "");
+ assert(std::chrono::time_point_cast<ToDuration>(f) == t);
+ }
+}
+
+#if _LIBCPP_STD_VER > 11
+
+template<class FromDuration, long long From, class ToDuration, long long To>
+void test_constexpr ()
+{
+ typedef std::chrono::system_clock Clock;
+ typedef std::chrono::time_point<Clock, FromDuration> FromTimePoint;
+ typedef std::chrono::time_point<Clock, ToDuration> ToTimePoint;
+ {
+ constexpr FromTimePoint f{FromDuration{From}};
+ constexpr ToTimePoint t{ToDuration{To}};
+ static_assert(std::chrono::time_point_cast<ToDuration>(f) == t, "");
+ }
+
+}
+
+#endif
+
+int main()
+{
+ test(std::chrono::milliseconds(7265000), std::chrono::hours(2));
+ test(std::chrono::milliseconds(7265000), std::chrono::minutes(121));
+ test(std::chrono::milliseconds(7265000), std::chrono::seconds(7265));
+ test(std::chrono::milliseconds(7265000), std::chrono::milliseconds(7265000));
+ test(std::chrono::milliseconds(7265000), std::chrono::microseconds(7265000000LL));
+ test(std::chrono::milliseconds(7265000), std::chrono::nanoseconds(7265000000000LL));
+ test(std::chrono::milliseconds(7265000),
+ std::chrono::duration<double, std::ratio<3600> >(7265./3600));
+ test(std::chrono::duration<int, std::ratio<2, 3> >(9),
+ std::chrono::duration<int, std::ratio<3, 5> >(10));
+#if _LIBCPP_STD_VER > 11
+ {
+ test_constexpr<std::chrono::milliseconds, 7265000, std::chrono::hours, 2> ();
+ test_constexpr<std::chrono::milliseconds, 7265000, std::chrono::minutes,121> ();
+ test_constexpr<std::chrono::milliseconds, 7265000, std::chrono::seconds,7265> ();
+ test_constexpr<std::chrono::milliseconds, 7265000, std::chrono::milliseconds,7265000> ();
+ test_constexpr<std::chrono::milliseconds, 7265000, std::chrono::microseconds,7265000000LL> ();
+ test_constexpr<std::chrono::milliseconds, 7265000, std::chrono::nanoseconds,7265000000000LL> ();
+ typedef std::chrono::duration<int, std::ratio<3, 5>> T1;
+ test_constexpr<std::chrono::duration<int, std::ratio<2, 3>>, 9, T1, 10> ();
+ }
+#endif
+}
diff --git a/test/std/utilities/time/time.point/time.point.cast/toduration.fail.cpp b/test/std/utilities/time/time.point/time.point.cast/toduration.fail.cpp
new file mode 100644
index 000000000000..de1e5bb3e273
--- /dev/null
+++ b/test/std/utilities/time/time.point/time.point.cast/toduration.fail.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// time_point
+
+// template <class ToDuration, class Clock, class Duration>
+// time_point<Clock, ToDuration>
+// time_point_cast(const time_point<Clock, Duration>& t);
+
+// ToDuration shall be an instantiation of duration.
+
+#include <chrono>
+
+int main()
+{
+ typedef std::chrono::system_clock Clock;
+ typedef std::chrono::time_point<Clock, std::chrono::milliseconds> FromTimePoint;
+ typedef std::chrono::time_point<Clock, std::chrono::minutes> ToTimePoint;
+ std::chrono::time_point_cast<ToTimePoint>(FromTimePoint(std::chrono::milliseconds(3)));
+}
diff --git a/test/std/utilities/time/time.point/time.point.comparisons/op_equal.fail.cpp b/test/std/utilities/time/time.point/time.point.comparisons/op_equal.fail.cpp
new file mode 100644
index 000000000000..f5ff11958ba2
--- /dev/null
+++ b/test/std/utilities/time/time.point/time.point.comparisons/op_equal.fail.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// time_point
+
+// template <class Clock, class Duration1, class Duration2>
+// bool
+// operator==(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
+
+// template <class Clock, class Duration1, class Duration2>
+// bool
+// operator!=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
+
+// time_points with different clocks should not compare
+
+#include <chrono>
+
+#include "../../clock.h"
+
+int main()
+{
+ typedef std::chrono::system_clock Clock1;
+ typedef Clock Clock2;
+ typedef std::chrono::milliseconds Duration1;
+ typedef std::chrono::microseconds Duration2;
+ typedef std::chrono::time_point<Clock1, Duration1> T1;
+ typedef std::chrono::time_point<Clock2, Duration2> T2;
+
+ T1 t1(Duration1(3));
+ T2 t2(Duration2(3000));
+ t1 == t2;
+}
diff --git a/test/std/utilities/time/time.point/time.point.comparisons/op_equal.pass.cpp b/test/std/utilities/time/time.point/time.point.comparisons/op_equal.pass.cpp
new file mode 100644
index 000000000000..fbd3a1386d35
--- /dev/null
+++ b/test/std/utilities/time/time.point/time.point.comparisons/op_equal.pass.cpp
@@ -0,0 +1,84 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// time_point
+
+// template <class Clock, class Duration1, class Duration2>
+// bool
+// operator==(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
+
+// template <class Clock, class Duration1, class Duration2>
+// bool
+// operator!=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+ typedef std::chrono::system_clock Clock;
+ typedef std::chrono::milliseconds Duration1;
+ typedef std::chrono::microseconds Duration2;
+ typedef std::chrono::time_point<Clock, Duration1> T1;
+ typedef std::chrono::time_point<Clock, Duration2> T2;
+
+ {
+ T1 t1(Duration1(3));
+ T1 t2(Duration1(3));
+ assert( (t1 == t2));
+ assert(!(t1 != t2));
+ }
+ {
+ T1 t1(Duration1(3));
+ T1 t2(Duration1(4));
+ assert(!(t1 == t2));
+ assert( (t1 != t2));
+ }
+ {
+ T1 t1(Duration1(3));
+ T2 t2(Duration2(3000));
+ assert( (t1 == t2));
+ assert(!(t1 != t2));
+ }
+ {
+ T1 t1(Duration1(3));
+ T2 t2(Duration2(3001));
+ assert(!(t1 == t2));
+ assert( (t1 != t2));
+ }
+
+#if _LIBCPP_STD_VER > 11
+ {
+ constexpr T1 t1(Duration1(3));
+ constexpr T1 t2(Duration1(3));
+ static_assert( (t1 == t2), "");
+ static_assert(!(t1 != t2), "");
+ }
+ {
+ constexpr T1 t1(Duration1(3));
+ constexpr T1 t2(Duration1(4));
+ static_assert(!(t1 == t2), "");
+ static_assert( (t1 != t2), "");
+ }
+ {
+ constexpr T1 t1(Duration1(3));
+ constexpr T2 t2(Duration2(3000));
+ static_assert( (t1 == t2), "");
+ static_assert(!(t1 != t2), "");
+ }
+ {
+ constexpr T1 t1(Duration1(3));
+ constexpr T2 t2(Duration2(3001));
+ static_assert(!(t1 == t2), "");
+ static_assert( (t1 != t2), "");
+ }
+#endif
+}
diff --git a/test/std/utilities/time/time.point/time.point.comparisons/op_less.fail.cpp b/test/std/utilities/time/time.point/time.point.comparisons/op_less.fail.cpp
new file mode 100644
index 000000000000..f9745cbf9de7
--- /dev/null
+++ b/test/std/utilities/time/time.point/time.point.comparisons/op_less.fail.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// time_point
+
+// template <class Clock, class Duration1, class Duration2>
+// bool
+// operator< (const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
+
+// template <class Clock, class Duration1, class Duration2>
+// bool
+// operator> (const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
+
+// template <class Clock, class Duration1, class Duration2>
+// bool
+// operator<=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
+
+// template <class Clock, class Duration1, class Duration2>
+// bool
+// operator>=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
+
+// time_points with different clocks should not compare
+
+#include <chrono>
+
+#include "../../clock.h"
+
+int main()
+{
+ typedef std::chrono::system_clock Clock1;
+ typedef Clock Clock2;
+ typedef std::chrono::milliseconds Duration1;
+ typedef std::chrono::microseconds Duration2;
+ typedef std::chrono::time_point<Clock1, Duration1> T1;
+ typedef std::chrono::time_point<Clock2, Duration2> T2;
+
+ T1 t1(Duration1(3));
+ T2 t2(Duration2(3000));
+ t1 < t2;
+}
diff --git a/test/std/utilities/time/time.point/time.point.comparisons/op_less.pass.cpp b/test/std/utilities/time/time.point/time.point.comparisons/op_less.pass.cpp
new file mode 100644
index 000000000000..9d94400ed3d1
--- /dev/null
+++ b/test/std/utilities/time/time.point/time.point.comparisons/op_less.pass.cpp
@@ -0,0 +1,108 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// time_point
+
+// template <class Clock, class Duration1, class Duration2>
+// bool
+// operator< (const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
+
+// template <class Clock, class Duration1, class Duration2>
+// bool
+// operator> (const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
+
+// template <class Clock, class Duration1, class Duration2>
+// bool
+// operator<=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
+
+// template <class Clock, class Duration1, class Duration2>
+// bool
+// operator>=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+ typedef std::chrono::system_clock Clock;
+ typedef std::chrono::milliseconds Duration1;
+ typedef std::chrono::microseconds Duration2;
+ typedef std::chrono::time_point<Clock, Duration1> T1;
+ typedef std::chrono::time_point<Clock, Duration2> T2;
+
+ {
+ T1 t1(Duration1(3));
+ T1 t2(Duration1(3));
+ assert(!(t1 < t2));
+ assert(!(t1 > t2));
+ assert( (t1 <= t2));
+ assert( (t1 >= t2));
+ }
+ {
+ T1 t1(Duration1(3));
+ T1 t2(Duration1(4));
+ assert( (t1 < t2));
+ assert(!(t1 > t2));
+ assert( (t1 <= t2));
+ assert(!(t1 >= t2));
+ }
+ {
+ T1 t1(Duration1(3));
+ T2 t2(Duration2(3000));
+ assert(!(t1 < t2));
+ assert(!(t1 > t2));
+ assert( (t1 <= t2));
+ assert( (t1 >= t2));
+ }
+ {
+ T1 t1(Duration1(3));
+ T2 t2(Duration2(3001));
+ assert( (t1 < t2));
+ assert(!(t1 > t2));
+ assert( (t1 <= t2));
+ assert(!(t1 >= t2));
+ }
+
+#if _LIBCPP_STD_VER > 11
+ {
+ constexpr T1 t1(Duration1(3));
+ constexpr T1 t2(Duration1(3));
+ static_assert(!(t1 < t2), "");
+ static_assert(!(t1 > t2), "");
+ static_assert( (t1 <= t2), "");
+ static_assert( (t1 >= t2), "");
+ }
+ {
+ constexpr T1 t1(Duration1(3));
+ constexpr T1 t2(Duration1(4));
+ static_assert( (t1 < t2), "");
+ static_assert(!(t1 > t2), "");
+ static_assert( (t1 <= t2), "");
+ static_assert(!(t1 >= t2), "");
+ }
+ {
+ constexpr T1 t1(Duration1(3));
+ constexpr T2 t2(Duration2(3000));
+ static_assert(!(t1 < t2), "");
+ static_assert(!(t1 > t2), "");
+ static_assert( (t1 <= t2), "");
+ static_assert( (t1 >= t2), "");
+ }
+ {
+ constexpr T1 t1(Duration1(3));
+ constexpr T2 t2(Duration2(3001));
+ static_assert( (t1 < t2), "");
+ static_assert(!(t1 > t2), "");
+ static_assert( (t1 <= t2), "");
+ static_assert(!(t1 >= t2), "");
+ }
+#endif
+}
diff --git a/test/std/utilities/time/time.point/time.point.cons/convert.fail.cpp b/test/std/utilities/time/time.point/time.point.cons/convert.fail.cpp
new file mode 100644
index 000000000000..565aa6c4f52f
--- /dev/null
+++ b/test/std/utilities/time/time.point/time.point.cons/convert.fail.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// time_point
+
+// template <class Duration2>
+// time_point(const time_point<clock, Duration2>& t);
+
+// Duration2 shall be implicitly convertible to duration.
+
+#include <chrono>
+
+int main()
+{
+ typedef std::chrono::system_clock Clock;
+ typedef std::chrono::milliseconds Duration1;
+ typedef std::chrono::microseconds Duration2;
+ {
+ std::chrono::time_point<Clock, Duration2> t2(Duration2(3));
+ std::chrono::time_point<Clock, Duration1> t1 = t2;
+ }
+}
diff --git a/test/std/utilities/time/time.point/time.point.cons/convert.pass.cpp b/test/std/utilities/time/time.point/time.point.cons/convert.pass.cpp
new file mode 100644
index 000000000000..6cd7dcb7d2f4
--- /dev/null
+++ b/test/std/utilities/time/time.point/time.point.cons/convert.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// time_point
+
+// template <class Duration2>
+// time_point(const time_point<clock, Duration2>& t);
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+ typedef std::chrono::system_clock Clock;
+ typedef std::chrono::microseconds Duration1;
+ typedef std::chrono::milliseconds Duration2;
+ {
+ std::chrono::time_point<Clock, Duration2> t2(Duration2(3));
+ std::chrono::time_point<Clock, Duration1> t1 = t2;
+ assert(t1.time_since_epoch() == Duration1(3000));
+ }
+#if _LIBCPP_STD_VER > 11
+ {
+ constexpr std::chrono::time_point<Clock, Duration2> t2(Duration2(3));
+ constexpr std::chrono::time_point<Clock, Duration1> t1 = t2;
+ static_assert(t1.time_since_epoch() == Duration1(3000), "");
+ }
+#endif
+}
diff --git a/test/std/utilities/time/time.point/time.point.cons/default.pass.cpp b/test/std/utilities/time/time.point/time.point.cons/default.pass.cpp
new file mode 100644
index 000000000000..01f0bc169933
--- /dev/null
+++ b/test/std/utilities/time/time.point/time.point.cons/default.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// time_point
+
+// time_point();
+
+#include <chrono>
+#include <cassert>
+
+#include "../../rep.h"
+
+int main()
+{
+ typedef std::chrono::system_clock Clock;
+ typedef std::chrono::duration<Rep, std::milli> Duration;
+ {
+ std::chrono::time_point<Clock, Duration> t;
+ assert(t.time_since_epoch() == Duration::zero());
+ }
+#if _LIBCPP_STD_VER > 11
+ {
+ constexpr std::chrono::time_point<Clock, Duration> t;
+ static_assert(t.time_since_epoch() == Duration::zero(), "");
+ }
+#endif
+}
diff --git a/test/std/utilities/time/time.point/time.point.cons/duration.fail.cpp b/test/std/utilities/time/time.point/time.point.cons/duration.fail.cpp
new file mode 100644
index 000000000000..810007ed9425
--- /dev/null
+++ b/test/std/utilities/time/time.point/time.point.cons/duration.fail.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// time_point
+
+// explicit time_point(const duration& d);
+
+// test for explicit
+
+#include <chrono>
+
+int main()
+{
+ typedef std::chrono::system_clock Clock;
+ typedef std::chrono::milliseconds Duration;
+ std::chrono::time_point<Clock, Duration> t = Duration(3);
+}
diff --git a/test/std/utilities/time/time.point/time.point.cons/duration.pass.cpp b/test/std/utilities/time/time.point/time.point.cons/duration.pass.cpp
new file mode 100644
index 000000000000..9d53d86dea3b
--- /dev/null
+++ b/test/std/utilities/time/time.point/time.point.cons/duration.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// time_point
+
+// explicit time_point(const duration& d);
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+ typedef std::chrono::system_clock Clock;
+ typedef std::chrono::milliseconds Duration;
+ {
+ std::chrono::time_point<Clock, Duration> t(Duration(3));
+ assert(t.time_since_epoch() == Duration(3));
+ }
+ {
+ std::chrono::time_point<Clock, Duration> t(std::chrono::seconds(3));
+ assert(t.time_since_epoch() == Duration(3000));
+ }
+#if _LIBCPP_STD_VER > 11
+ {
+ constexpr std::chrono::time_point<Clock, Duration> t(Duration(3));
+ static_assert(t.time_since_epoch() == Duration(3), "");
+ }
+ {
+ constexpr std::chrono::time_point<Clock, Duration> t(std::chrono::seconds(3));
+ static_assert(t.time_since_epoch() == Duration(3000), "");
+ }
+#endif
+}
diff --git a/test/std/utilities/time/time.point/time.point.nonmember/op_+.pass.cpp b/test/std/utilities/time/time.point/time.point.nonmember/op_+.pass.cpp
new file mode 100644
index 000000000000..7a8fa6dcf14f
--- /dev/null
+++ b/test/std/utilities/time/time.point/time.point.nonmember/op_+.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// time_point
+
+// template <class Clock, class Duration1, class Rep2, class Period2>
+// time_point<Clock, typename common_type<Duration1, duration<Rep2, Period2>>::type>
+// operator+(const time_point<Clock, Duration1>& lhs, const duration<Rep2, Period2>& rhs);
+
+// template <class Rep1, class Period1, class Clock, class Duration2>
+// time_point<Clock, typename common_type<duration<Rep1, Period1>, Duration2>::type>
+// operator+(const duration<Rep1, Period1>& lhs, const time_point<Clock, Duration2>& rhs);
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+ typedef std::chrono::system_clock Clock;
+ typedef std::chrono::milliseconds Duration1;
+ typedef std::chrono::microseconds Duration2;
+ {
+ std::chrono::time_point<Clock, Duration1> t1(Duration1(3));
+ std::chrono::time_point<Clock, Duration2> t2 = t1 + Duration2(5);
+ assert(t2.time_since_epoch() == Duration2(3005));
+ t2 = Duration2(6) + t1;
+ assert(t2.time_since_epoch() == Duration2(3006));
+ }
+#if _LIBCPP_STD_VER > 11
+ {
+ constexpr std::chrono::time_point<Clock, Duration1> t1(Duration1(3));
+ constexpr std::chrono::time_point<Clock, Duration2> t2 = t1 + Duration2(5);
+ static_assert(t2.time_since_epoch() == Duration2(3005), "");
+ constexpr std::chrono::time_point<Clock, Duration2> t3 = Duration2(6) + t1;
+ static_assert(t3.time_since_epoch() == Duration2(3006), "");
+ }
+#endif
+}
diff --git a/test/std/utilities/time/time.point/time.point.nonmember/op_-duration.pass.cpp b/test/std/utilities/time/time.point/time.point.nonmember/op_-duration.pass.cpp
new file mode 100644
index 000000000000..342d27b5aebd
--- /dev/null
+++ b/test/std/utilities/time/time.point/time.point.nonmember/op_-duration.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// time_point
+
+// template <class Clock, class Duration1, class Rep2, class Period2>
+// time_point<Clock, typename common_type<Duration1, duration<Rep2, Period2>>::type>
+// operator-(const time_point<Clock, Duration1>& lhs, const duration<Rep2, Period2>& rhs);
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+ typedef std::chrono::system_clock Clock;
+ typedef std::chrono::milliseconds Duration1;
+ typedef std::chrono::microseconds Duration2;
+ {
+ std::chrono::time_point<Clock, Duration1> t1(Duration1(3));
+ std::chrono::time_point<Clock, Duration2> t2 = t1 - Duration2(5);
+ assert(t2.time_since_epoch() == Duration2(2995));
+ }
+#if _LIBCPP_STD_VER > 11
+ {
+ constexpr std::chrono::time_point<Clock, Duration1> t1(Duration1(3));
+ constexpr std::chrono::time_point<Clock, Duration2> t2 = t1 - Duration2(5);
+ static_assert(t2.time_since_epoch() == Duration2(2995), "");
+ }
+#endif
+}
diff --git a/test/std/utilities/time/time.point/time.point.nonmember/op_-time_point.pass.cpp b/test/std/utilities/time/time.point/time.point.nonmember/op_-time_point.pass.cpp
new file mode 100644
index 000000000000..5267f07e1b86
--- /dev/null
+++ b/test/std/utilities/time/time.point/time.point.nonmember/op_-time_point.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// time_point
+
+// template <class Clock, class Duration1, class Duration2>
+// typename common_type<Duration1, Duration2>::type
+// operator-(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+ typedef std::chrono::system_clock Clock;
+ typedef std::chrono::milliseconds Duration1;
+ typedef std::chrono::microseconds Duration2;
+ {
+ std::chrono::time_point<Clock, Duration1> t1(Duration1(3));
+ std::chrono::time_point<Clock, Duration2> t2(Duration2(5));
+ assert((t1 - t2) == Duration2(2995));
+ }
+#if _LIBCPP_STD_VER > 11
+ {
+ constexpr std::chrono::time_point<Clock, Duration1> t1(Duration1(3));
+ constexpr std::chrono::time_point<Clock, Duration2> t2(Duration2(5));
+ static_assert((t1 - t2) == Duration2(2995), "");
+ }
+#endif
+}
diff --git a/test/std/utilities/time/time.point/time.point.observer/tested_elsewhere.pass.cpp b/test/std/utilities/time/time.point/time.point.observer/tested_elsewhere.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/utilities/time/time.point/time.point.observer/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/utilities/time/time.point/time.point.special/max.pass.cpp b/test/std/utilities/time/time.point/time.point.special/max.pass.cpp
new file mode 100644
index 000000000000..6bba6fc82787
--- /dev/null
+++ b/test/std/utilities/time/time.point/time.point.special/max.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// time_point
+
+// static constexpr time_point max();
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+ typedef std::chrono::system_clock Clock;
+ typedef std::chrono::milliseconds Duration;
+ typedef std::chrono::time_point<Clock, Duration> TP;
+ assert(TP::max() == TP(Duration::max()));
+}
diff --git a/test/std/utilities/time/time.point/time.point.special/min.pass.cpp b/test/std/utilities/time/time.point/time.point.special/min.pass.cpp
new file mode 100644
index 000000000000..b1d955c252aa
--- /dev/null
+++ b/test/std/utilities/time/time.point/time.point.special/min.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// time_point
+
+// static constexpr time_point min();
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+ typedef std::chrono::system_clock Clock;
+ typedef std::chrono::milliseconds Duration;
+ typedef std::chrono::time_point<Clock, Duration> TP;
+ assert(TP::min() == TP(Duration::min()));
+}
diff --git a/test/std/utilities/time/time.traits/nothing_to_do.pass.cpp b/test/std/utilities/time/time.traits/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/utilities/time/time.traits/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/utilities/time/time.traits/time.traits.duration_values/max.pass.cpp b/test/std/utilities/time/time.traits/time.traits.duration_values/max.pass.cpp
new file mode 100644
index 000000000000..89dc1dcc1a59
--- /dev/null
+++ b/test/std/utilities/time/time.traits/time.traits.duration_values/max.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration_values::max
+
+#include <chrono>
+#include <limits>
+#include <cassert>
+
+#include "../../rep.h"
+
+int main()
+{
+ assert(std::chrono::duration_values<int>::max() ==
+ std::numeric_limits<int>::max());
+ assert(std::chrono::duration_values<double>::max() ==
+ std::numeric_limits<double>::max());
+ assert(std::chrono::duration_values<Rep>::max() ==
+ std::numeric_limits<Rep>::max());
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+ static_assert(std::chrono::duration_values<int>::max() ==
+ std::numeric_limits<int>::max(), "");
+ static_assert(std::chrono::duration_values<double>::max() ==
+ std::numeric_limits<double>::max(), "");
+ static_assert(std::chrono::duration_values<Rep>::max() ==
+ std::numeric_limits<Rep>::max(), "");
+#endif
+}
diff --git a/test/std/utilities/time/time.traits/time.traits.duration_values/min.pass.cpp b/test/std/utilities/time/time.traits/time.traits.duration_values/min.pass.cpp
new file mode 100644
index 000000000000..69812bba006a
--- /dev/null
+++ b/test/std/utilities/time/time.traits/time.traits.duration_values/min.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration_values::min
+
+#include <chrono>
+#include <limits>
+#include <cassert>
+
+#include "../../rep.h"
+
+int main()
+{
+ assert(std::chrono::duration_values<int>::min() ==
+ std::numeric_limits<int>::lowest());
+ assert(std::chrono::duration_values<double>::min() ==
+ std::numeric_limits<double>::lowest());
+ assert(std::chrono::duration_values<Rep>::min() ==
+ std::numeric_limits<Rep>::lowest());
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+ static_assert(std::chrono::duration_values<int>::min() ==
+ std::numeric_limits<int>::lowest(), "");
+ static_assert(std::chrono::duration_values<double>::min() ==
+ std::numeric_limits<double>::lowest(), "");
+ static_assert(std::chrono::duration_values<Rep>::min() ==
+ std::numeric_limits<Rep>::lowest(), "");
+#endif
+}
diff --git a/test/std/utilities/time/time.traits/time.traits.duration_values/zero.pass.cpp b/test/std/utilities/time/time.traits/time.traits.duration_values/zero.pass.cpp
new file mode 100644
index 000000000000..234b4bc31c9d
--- /dev/null
+++ b/test/std/utilities/time/time.traits/time.traits.duration_values/zero.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration_values::zero
+
+#include <chrono>
+#include <cassert>
+
+#include "../../rep.h"
+
+int main()
+{
+ assert(std::chrono::duration_values<int>::zero() == 0);
+ assert(std::chrono::duration_values<Rep>::zero() == 0);
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+ static_assert(std::chrono::duration_values<int>::zero() == 0, "");
+ static_assert(std::chrono::duration_values<Rep>::zero() == 0, "");
+#endif
+}
diff --git a/test/std/utilities/time/time.traits/time.traits.is_fp/treat_as_floating_point.pass.cpp b/test/std/utilities/time/time.traits/time.traits.is_fp/treat_as_floating_point.pass.cpp
new file mode 100644
index 000000000000..c32350faa83b
--- /dev/null
+++ b/test/std/utilities/time/time.traits/time.traits.is_fp/treat_as_floating_point.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// treat_as_floating_point
+
+#include <chrono>
+#include <type_traits>
+
+template <class T>
+void
+test()
+{
+ static_assert((std::is_base_of<std::is_floating_point<T>,
+ std::chrono::treat_as_floating_point<T> >::value), "");
+}
+
+struct A {};
+
+int main()
+{
+ test<int>();
+ test<unsigned>();
+ test<char>();
+ test<bool>();
+ test<float>();
+ test<double>();
+ test<long double>();
+ test<A>();
+}
diff --git a/test/std/utilities/time/time.traits/time.traits.specializations/duration.pass.cpp b/test/std/utilities/time/time.traits/time.traits.specializations/duration.pass.cpp
new file mode 100644
index 000000000000..f942844b60a6
--- /dev/null
+++ b/test/std/utilities/time/time.traits/time.traits.specializations/duration.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// template <class Rep1, class Period1, class Rep2, class Period2>
+// struct common_type<chrono::duration<Rep1, Period1>, chrono::duration<Rep2, Period2>>
+// {
+// typedef chrono::duration<typename common_type<Rep1, Rep2>::type, see below }> type;
+// };
+
+#include <chrono>
+
+template <class D1, class D2, class De>
+void
+test()
+{
+ typedef typename std::common_type<D1, D2>::type Dc;
+ static_assert((std::is_same<Dc, De>::value), "");
+}
+
+int main()
+{
+ test<std::chrono::duration<int, std::ratio<1, 100> >,
+ std::chrono::duration<long, std::ratio<1, 1000> >,
+ std::chrono::duration<long, std::ratio<1, 1000> > >();
+ test<std::chrono::duration<long, std::ratio<1, 100> >,
+ std::chrono::duration<int, std::ratio<1, 1000> >,
+ std::chrono::duration<long, std::ratio<1, 1000> > >();
+ test<std::chrono::duration<char, std::ratio<1, 30> >,
+ std::chrono::duration<short, std::ratio<1, 1000> >,
+ std::chrono::duration<int, std::ratio<1, 3000> > >();
+ test<std::chrono::duration<double, std::ratio<21, 1> >,
+ std::chrono::duration<short, std::ratio<15, 1> >,
+ std::chrono::duration<double, std::ratio<3, 1> > >();
+}
diff --git a/test/std/utilities/time/time.traits/time.traits.specializations/time_point.pass.cpp b/test/std/utilities/time/time.traits/time.traits.specializations/time_point.pass.cpp
new file mode 100644
index 000000000000..a0786b49924c
--- /dev/null
+++ b/test/std/utilities/time/time.traits/time.traits.specializations/time_point.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// template <class Clock, class Duration1, class Duration2>
+// struct common_type<chrono::time_point<Clock, Duration1>, chrono::time_point<Clock, Duration2>>
+// {
+// typedef chrono::time_point<Clock, typename common_type<Duration1, Duration2>::type> type;
+// };
+
+#include <chrono>
+
+template <class D1, class D2, class De>
+void
+test()
+{
+ typedef std::chrono::system_clock C;
+ typedef std::chrono::time_point<C, D1> T1;
+ typedef std::chrono::time_point<C, D2> T2;
+ typedef std::chrono::time_point<C, De> Te;
+ typedef typename std::common_type<T1, T2>::type Tc;
+ static_assert((std::is_same<Tc, Te>::value), "");
+}
+
+int main()
+{
+ test<std::chrono::duration<int, std::ratio<1, 100> >,
+ std::chrono::duration<long, std::ratio<1, 1000> >,
+ std::chrono::duration<long, std::ratio<1, 1000> > >();
+ test<std::chrono::duration<long, std::ratio<1, 100> >,
+ std::chrono::duration<int, std::ratio<1, 1000> >,
+ std::chrono::duration<long, std::ratio<1, 1000> > >();
+ test<std::chrono::duration<char, std::ratio<1, 30> >,
+ std::chrono::duration<short, std::ratio<1, 1000> >,
+ std::chrono::duration<int, std::ratio<1, 3000> > >();
+ test<std::chrono::duration<double, std::ratio<21, 1> >,
+ std::chrono::duration<short, std::ratio<15, 1> >,
+ std::chrono::duration<double, std::ratio<3, 1> > >();
+}
diff --git a/test/std/utilities/time/version.pass.cpp b/test/std/utilities/time/version.pass.cpp
new file mode 100644
index 000000000000..bfa3f6d6797d
--- /dev/null
+++ b/test/std/utilities/time/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+#include <chrono>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/utilities/tuple/tuple.general/tuple.smartptr.pass.cpp b/test/std/utilities/tuple/tuple.general/tuple.smartptr.pass.cpp
new file mode 100644
index 000000000000..1d8be420d837
--- /dev/null
+++ b/test/std/utilities/tuple/tuple.general/tuple.smartptr.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+
+// UNSUPPORTED: c++98, c++03
+
+// Tuples of smart pointers; based on bug #18350
+// auto_ptr doesn't have a copy constructor that takes a const &, but tuple does.
+
+#include <tuple>
+#include <memory>
+
+int main () {
+ {
+ std::tuple<std::unique_ptr<char>> up;
+ std::tuple<std::shared_ptr<char>> sp;
+ std::tuple<std::weak_ptr <char>> wp;
+// std::tuple<std::auto_ptr <char>> ap;
+ }
+ {
+ std::tuple<std::unique_ptr<char[]>> up;
+ std::tuple<std::shared_ptr<char[]>> sp;
+ std::tuple<std::weak_ptr <char[]>> wp;
+// std::tuple<std::auto_ptr <char[]>> ap;
+ }
+ {
+ std::tuple<std::unique_ptr<char[5]>> up;
+ std::tuple<std::shared_ptr<char[5]>> sp;
+ std::tuple<std::weak_ptr <char[5]>> wp;
+// std::tuple<std::auto_ptr <char[5]>> ap;
+ }
+} \ No newline at end of file
diff --git a/test/std/utilities/tuple/tuple.tuple/TupleFunction.pass.cpp b/test/std/utilities/tuple/tuple.tuple/TupleFunction.pass.cpp
new file mode 100644
index 000000000000..df5fdff511e3
--- /dev/null
+++ b/test/std/utilities/tuple/tuple.tuple/TupleFunction.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// This is for bugs 18853 and 19118
+
+#if __cplusplus >= 201103L
+
+#include <tuple>
+#include <functional>
+
+struct X
+{
+ X() {}
+
+ template <class T>
+ X(T);
+
+ void operator()() {}
+};
+
+int
+main()
+{
+ X x;
+ std::function<void()> f(x);
+}
+#else
+int main () {}
+#endif
diff --git a/test/std/utilities/tuple/tuple.tuple/alloc_first.h b/test/std/utilities/tuple/tuple.tuple/alloc_first.h
new file mode 100644
index 000000000000..237a2897e87a
--- /dev/null
+++ b/test/std/utilities/tuple/tuple.tuple/alloc_first.h
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef ALLOC_FIRST_H
+#define ALLOC_FIRST_H
+
+#include <cassert>
+
+#include "allocators.h"
+
+struct alloc_first
+{
+ static bool allocator_constructed;
+
+ typedef A1<int> allocator_type;
+
+ int data_;
+
+ alloc_first() : data_(0) {}
+ alloc_first(int d) : data_(d) {}
+ alloc_first(std::allocator_arg_t, const A1<int>& a)
+ : data_(0)
+ {
+ assert(a.id() == 5);
+ allocator_constructed = true;
+ }
+
+ alloc_first(std::allocator_arg_t, const A1<int>& a, int d)
+ : data_(d)
+ {
+ assert(a.id() == 5);
+ allocator_constructed = true;
+ }
+
+ alloc_first(std::allocator_arg_t, const A1<int>& a, const alloc_first& d)
+ : data_(d.data_)
+ {
+ assert(a.id() == 5);
+ allocator_constructed = true;
+ }
+
+ ~alloc_first() {data_ = -1;}
+
+ friend bool operator==(const alloc_first& x, const alloc_first& y)
+ {return x.data_ == y.data_;}
+ friend bool operator< (const alloc_first& x, const alloc_first& y)
+ {return x.data_ < y.data_;}
+};
+
+bool alloc_first::allocator_constructed = false;
+
+#endif // ALLOC_FIRST_H
diff --git a/test/std/utilities/tuple/tuple.tuple/alloc_last.h b/test/std/utilities/tuple/tuple.tuple/alloc_last.h
new file mode 100644
index 000000000000..71a9b9e97acc
--- /dev/null
+++ b/test/std/utilities/tuple/tuple.tuple/alloc_last.h
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef ALLOC_LAST_H
+#define ALLOC_LAST_H
+
+#include <cassert>
+
+#include "allocators.h"
+
+struct alloc_last
+{
+ static bool allocator_constructed;
+
+ typedef A1<int> allocator_type;
+
+ int data_;
+
+ alloc_last() : data_(0) {}
+ alloc_last(int d) : data_(d) {}
+ alloc_last(const A1<int>& a)
+ : data_(0)
+ {
+ assert(a.id() == 5);
+ allocator_constructed = true;
+ }
+
+ alloc_last(int d, const A1<int>& a)
+ : data_(d)
+ {
+ assert(a.id() == 5);
+ allocator_constructed = true;
+ }
+
+ alloc_last(const alloc_last& d, const A1<int>& a)
+ : data_(d.data_)
+ {
+ assert(a.id() == 5);
+ allocator_constructed = true;
+ }
+
+ ~alloc_last() {data_ = -1;}
+
+ friend bool operator==(const alloc_last& x, const alloc_last& y)
+ {return x.data_ == y.data_;}
+ friend bool operator< (const alloc_last& x, const alloc_last& y)
+ {return x.data_ < y.data_;}
+};
+
+bool alloc_last::allocator_constructed = false;
+
+#endif // ALLOC_LAST_H
diff --git a/test/std/utilities/tuple/tuple.tuple/empty_member.pass.cpp b/test/std/utilities/tuple/tuple.tuple/empty_member.pass.cpp
new file mode 100644
index 000000000000..1e7243b5f501
--- /dev/null
+++ b/test/std/utilities/tuple/tuple.tuple/empty_member.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// UNSUPPORTED: c++98, c++03
+
+// This is not a portable test
+
+#include <tuple>
+
+struct A {};
+
+struct B {};
+
+int main()
+{
+ {
+ typedef std::tuple<int, A> T;
+ static_assert((sizeof(T) == sizeof(int)), "");
+ }
+ {
+ typedef std::tuple<A, int> T;
+ static_assert((sizeof(T) == sizeof(int)), "");
+ }
+ {
+ typedef std::tuple<A, int, B> T;
+ static_assert((sizeof(T) == sizeof(int)), "");
+ }
+ {
+ typedef std::tuple<A, B, int> T;
+ static_assert((sizeof(T) == sizeof(int)), "");
+ }
+ {
+ typedef std::tuple<int, A, B> T;
+ static_assert((sizeof(T) == sizeof(int)), "");
+ }
+}
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.assign/const_pair.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.assign/const_pair.pass.cpp
new file mode 100644
index 000000000000..a3d14487b47d
--- /dev/null
+++ b/test/std/utilities/tuple/tuple.tuple/tuple.assign/const_pair.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class U1, class U2>
+// tuple& operator=(const pair<U1, U2>& u);
+
+// UNSUPPORTED: c++98, c++03
+
+#include <tuple>
+#include <utility>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::pair<double, char> T0;
+ typedef std::tuple<int, short> T1;
+ T0 t0(2.5, 'a');
+ T1 t1;
+ t1 = t0;
+ assert(std::get<0>(t1) == 2);
+ assert(std::get<1>(t1) == short('a'));
+ }
+}
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_copy.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_copy.pass.cpp
new file mode 100644
index 000000000000..2dde6b5521f2
--- /dev/null
+++ b/test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_copy.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class... UTypes>
+// tuple& operator=(const tuple<UTypes...>& u);
+
+// UNSUPPORTED: c++98, c++03
+
+#include <tuple>
+#include <string>
+#include <cassert>
+
+struct B
+{
+ int id_;
+
+ explicit B(int i = 0) : id_(i) {}
+};
+
+struct D
+ : B
+{
+ explicit D(int i = 0) : B(i) {}
+};
+
+int main()
+{
+ {
+ typedef std::tuple<double> T0;
+ typedef std::tuple<int> T1;
+ T0 t0(2.5);
+ T1 t1;
+ t1 = t0;
+ assert(std::get<0>(t1) == 2);
+ }
+ {
+ typedef std::tuple<double, char> T0;
+ typedef std::tuple<int, int> T1;
+ T0 t0(2.5, 'a');
+ T1 t1;
+ t1 = t0;
+ assert(std::get<0>(t1) == 2);
+ assert(std::get<1>(t1) == int('a'));
+ }
+ {
+ typedef std::tuple<double, char, D> T0;
+ typedef std::tuple<int, int, B> T1;
+ T0 t0(2.5, 'a', D(3));
+ T1 t1;
+ t1 = t0;
+ assert(std::get<0>(t1) == 2);
+ assert(std::get<1>(t1) == int('a'));
+ assert(std::get<2>(t1).id_ == 3);
+ }
+ {
+ D d(3);
+ D d2(2);
+ typedef std::tuple<double, char, D&> T0;
+ typedef std::tuple<int, int, B&> T1;
+ T0 t0(2.5, 'a', d2);
+ T1 t1(1.5, 'b', d);
+ t1 = t0;
+ assert(std::get<0>(t1) == 2);
+ assert(std::get<1>(t1) == int('a'));
+ assert(std::get<2>(t1).id_ == 2);
+ }
+}
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_move.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_move.pass.cpp
new file mode 100644
index 000000000000..11bfdd0c94a9
--- /dev/null
+++ b/test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_move.pass.cpp
@@ -0,0 +1,91 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class... UTypes>
+// tuple& operator=(tuple<UTypes...>&& u);
+
+// UNSUPPORTED: c++98, c++03
+
+#include <tuple>
+#include <string>
+#include <memory>
+#include <utility>
+#include <cassert>
+
+struct B
+{
+ int id_;
+
+ explicit B(int i= 0) : id_(i) {}
+
+ virtual ~B() {}
+};
+
+struct D
+ : B
+{
+ explicit D(int i) : B(i) {}
+};
+
+int main()
+{
+ {
+ typedef std::tuple<double> T0;
+ typedef std::tuple<int> T1;
+ T0 t0(2.5);
+ T1 t1;
+ t1 = std::move(t0);
+ assert(std::get<0>(t1) == 2);
+ }
+ {
+ typedef std::tuple<double, char> T0;
+ typedef std::tuple<int, int> T1;
+ T0 t0(2.5, 'a');
+ T1 t1;
+ t1 = std::move(t0);
+ assert(std::get<0>(t1) == 2);
+ assert(std::get<1>(t1) == int('a'));
+ }
+ {
+ typedef std::tuple<double, char, D> T0;
+ typedef std::tuple<int, int, B> T1;
+ T0 t0(2.5, 'a', D(3));
+ T1 t1;
+ t1 = std::move(t0);
+ assert(std::get<0>(t1) == 2);
+ assert(std::get<1>(t1) == int('a'));
+ assert(std::get<2>(t1).id_ == 3);
+ }
+ {
+ D d(3);
+ D d2(2);
+ typedef std::tuple<double, char, D&> T0;
+ typedef std::tuple<int, int, B&> T1;
+ T0 t0(2.5, 'a', d2);
+ T1 t1(1.5, 'b', d);
+ t1 = std::move(t0);
+ assert(std::get<0>(t1) == 2);
+ assert(std::get<1>(t1) == int('a'));
+ assert(std::get<2>(t1).id_ == 2);
+ }
+ {
+ typedef std::tuple<double, char, std::unique_ptr<D>> T0;
+ typedef std::tuple<int, int, std::unique_ptr<B>> T1;
+ T0 t0(2.5, 'a', std::unique_ptr<D>(new D(3)));
+ T1 t1;
+ t1 = std::move(t0);
+ assert(std::get<0>(t1) == 2);
+ assert(std::get<1>(t1) == int('a'));
+ assert(std::get<2>(t1)->id_ == 3);
+ }
+}
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.assign/copy.fail.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.assign/copy.fail.cpp
new file mode 100644
index 000000000000..5911391d6cd2
--- /dev/null
+++ b/test/std/utilities/tuple/tuple.tuple/tuple.assign/copy.fail.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// tuple& operator=(const tuple& u);
+
+// UNSUPPORTED: c++98, c++03
+
+#include <tuple>
+#include <cassert>
+
+#include "MoveOnly.h"
+
+int main()
+{
+ {
+ typedef std::tuple<MoveOnly> T;
+ T t0(MoveOnly(2));
+ T t;
+ t = t0;
+ }
+}
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.assign/copy.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.assign/copy.pass.cpp
new file mode 100644
index 000000000000..d5d020779726
--- /dev/null
+++ b/test/std/utilities/tuple/tuple.tuple/tuple.assign/copy.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// tuple& operator=(const tuple& u);
+
+// UNSUPPORTED: c++98, c++03
+
+#include <tuple>
+#include <string>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::tuple<> T;
+ T t0;
+ T t;
+ t = t0;
+ }
+ {
+ typedef std::tuple<int> T;
+ T t0(2);
+ T t;
+ t = t0;
+ assert(std::get<0>(t) == 2);
+ }
+ {
+ typedef std::tuple<int, char> T;
+ T t0(2, 'a');
+ T t;
+ t = t0;
+ assert(std::get<0>(t) == 2);
+ assert(std::get<1>(t) == 'a');
+ }
+ {
+ typedef std::tuple<int, char, std::string> T;
+ const T t0(2, 'a', "some text");
+ T t;
+ t = t0;
+ assert(std::get<0>(t) == 2);
+ assert(std::get<1>(t) == 'a');
+ assert(std::get<2>(t) == "some text");
+ }
+}
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.assign/move.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.assign/move.pass.cpp
new file mode 100644
index 000000000000..fc5e41ad569d
--- /dev/null
+++ b/test/std/utilities/tuple/tuple.tuple/tuple.assign/move.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// tuple& operator=(tuple&& u);
+
+// UNSUPPORTED: c++98, c++03
+
+#include <tuple>
+#include <utility>
+#include <cassert>
+
+#include "MoveOnly.h"
+
+int main()
+{
+ {
+ typedef std::tuple<> T;
+ T t0;
+ T t;
+ t = std::move(t0);
+ }
+ {
+ typedef std::tuple<MoveOnly> T;
+ T t0(MoveOnly(0));
+ T t;
+ t = std::move(t0);
+ assert(std::get<0>(t) == 0);
+ }
+ {
+ typedef std::tuple<MoveOnly, MoveOnly> T;
+ T t0(MoveOnly(0), MoveOnly(1));
+ T t;
+ t = std::move(t0);
+ assert(std::get<0>(t) == 0);
+ assert(std::get<1>(t) == 1);
+ }
+ {
+ typedef std::tuple<MoveOnly, MoveOnly, MoveOnly> T;
+ T t0(MoveOnly(0), MoveOnly(1), MoveOnly(2));
+ T t;
+ t = std::move(t0);
+ assert(std::get<0>(t) == 0);
+ assert(std::get<1>(t) == 1);
+ assert(std::get<2>(t) == 2);
+ }
+}
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.assign/move_pair.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.assign/move_pair.pass.cpp
new file mode 100644
index 000000000000..812e6329bb3e
--- /dev/null
+++ b/test/std/utilities/tuple/tuple.tuple/tuple.assign/move_pair.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class U1, class U2>
+// tuple& operator=(pair<U1, U2>&& u);
+
+// UNSUPPORTED: c++98, c++03
+
+#include <tuple>
+#include <utility>
+#include <memory>
+#include <cassert>
+
+struct B
+{
+ int id_;
+
+ explicit B(int i = 0) : id_(i) {}
+
+ virtual ~B() {}
+};
+
+struct D
+ : B
+{
+ explicit D(int i) : B(i) {}
+};
+
+int main()
+{
+ {
+ typedef std::pair<double, std::unique_ptr<D>> T0;
+ typedef std::tuple<int, std::unique_ptr<B>> T1;
+ T0 t0(2.5, std::unique_ptr<D>(new D(3)));
+ T1 t1;
+ t1 = std::move(t0);
+ assert(std::get<0>(t1) == 2);
+ assert(std::get<1>(t1)->id_ == 3);
+ }
+}
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.assign/tuple_array_template_depth.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.assign/tuple_array_template_depth.pass.cpp
new file mode 100644
index 000000000000..08d1304f9942
--- /dev/null
+++ b/test/std/utilities/tuple/tuple.tuple/tuple.assign/tuple_array_template_depth.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class Tuple, __tuple_assignable<Tuple, tuple> >
+// tuple & operator=(Tuple &&);
+
+// This test checks that we do not evaluate __make_tuple_types
+// on the array when it doesn't match the size of the tuple.
+
+#include <array>
+#include <tuple>
+
+// Use 1256 to try and blow the template instantiation depth for all compilers.
+typedef std::array<char, 1256> array_t;
+typedef std::tuple<array_t> tuple_t;
+
+int main()
+{
+ array_t arr;
+ tuple_t tup;
+ tup = arr;
+}
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/UTypes.fail.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/UTypes.fail.cpp
new file mode 100644
index 000000000000..b9497bea5677
--- /dev/null
+++ b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/UTypes.fail.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class... UTypes>
+// explicit tuple(UTypes&&... u);
+
+// UNSUPPORTED: c++98, c++03
+
+/*
+ This is testing an extension whereby only Types having an explicit conversion
+ from UTypes are bound by the explicit tuple constructor.
+*/
+
+#include <tuple>
+#include <cassert>
+
+class MoveOnly
+{
+ MoveOnly(const MoveOnly&);
+ MoveOnly& operator=(const MoveOnly&);
+
+ int data_;
+public:
+ explicit MoveOnly(int data = 1) : data_(data) {}
+ MoveOnly(MoveOnly&& x)
+ : data_(x.data_) {x.data_ = 0;}
+ MoveOnly& operator=(MoveOnly&& x)
+ {data_ = x.data_; x.data_ = 0; return *this;}
+
+ int get() const {return data_;}
+
+ bool operator==(const MoveOnly& x) const {return data_ == x.data_;}
+ bool operator< (const MoveOnly& x) const {return data_ < x.data_;}
+};
+
+int main()
+{
+ {
+ std::tuple<MoveOnly> t = 1;
+ }
+}
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/UTypes.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/UTypes.pass.cpp
new file mode 100644
index 000000000000..817cc8f10990
--- /dev/null
+++ b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/UTypes.pass.cpp
@@ -0,0 +1,146 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class... UTypes>
+// explicit tuple(UTypes&&... u);
+
+// UNSUPPORTED: c++98, c++03
+
+#include <tuple>
+#include <cassert>
+#include <type_traits>
+
+#include "MoveOnly.h"
+
+#if _LIBCPP_STD_VER > 11
+
+struct Empty {};
+struct A
+{
+ int id_;
+ explicit constexpr A(int i) : id_(i) {}
+};
+
+#endif
+
+struct NoDefault { NoDefault() = delete; };
+
+// Make sure the _Up... constructor SFINAEs out when the types that
+// are not explicitly initialized are not all default constructible.
+// Otherwise, std::is_constructible would return true but instantiating
+// the constructor would fail.
+void test_default_constructible_extension_sfinae()
+{
+ {
+ typedef std::tuple<MoveOnly, NoDefault> Tuple;
+
+ static_assert(!std::is_constructible<
+ Tuple,
+ MoveOnly
+ >::value, "");
+
+ static_assert(std::is_constructible<
+ Tuple,
+ MoveOnly, NoDefault
+ >::value, "");
+ }
+ {
+ typedef std::tuple<MoveOnly, MoveOnly, NoDefault> Tuple;
+
+ static_assert(!std::is_constructible<
+ Tuple,
+ MoveOnly, MoveOnly
+ >::value, "");
+
+ static_assert(std::is_constructible<
+ Tuple,
+ MoveOnly, MoveOnly, NoDefault
+ >::value, "");
+ }
+ {
+ // Same idea as above but with a nested tuple type.
+ typedef std::tuple<MoveOnly, NoDefault> Tuple;
+ typedef std::tuple<MoveOnly, Tuple, MoveOnly, MoveOnly> NestedTuple;
+
+ static_assert(!std::is_constructible<
+ NestedTuple,
+ MoveOnly, MoveOnly, MoveOnly, MoveOnly
+ >::value, "");
+
+ static_assert(std::is_constructible<
+ NestedTuple,
+ MoveOnly, Tuple, MoveOnly, MoveOnly
+ >::value, "");
+ }
+ {
+ typedef std::tuple<MoveOnly, int> Tuple;
+ typedef std::tuple<MoveOnly, Tuple, MoveOnly, MoveOnly> NestedTuple;
+
+ static_assert(std::is_constructible<
+ NestedTuple,
+ MoveOnly, MoveOnly, MoveOnly, MoveOnly
+ >::value, "");
+
+ static_assert(std::is_constructible<
+ NestedTuple,
+ MoveOnly, Tuple, MoveOnly, MoveOnly
+ >::value, "");
+ }
+}
+
+int main()
+{
+ {
+ std::tuple<MoveOnly> t(MoveOnly(0));
+ assert(std::get<0>(t) == 0);
+ }
+ {
+ std::tuple<MoveOnly, MoveOnly> t(MoveOnly(0), MoveOnly(1));
+ assert(std::get<0>(t) == 0);
+ assert(std::get<1>(t) == 1);
+ }
+ {
+ std::tuple<MoveOnly, MoveOnly, MoveOnly> t(MoveOnly(0),
+ MoveOnly(1),
+ MoveOnly(2));
+ assert(std::get<0>(t) == 0);
+ assert(std::get<1>(t) == 1);
+ assert(std::get<2>(t) == 2);
+ }
+ // extensions
+ {
+ std::tuple<MoveOnly, MoveOnly, MoveOnly> t(MoveOnly(0),
+ MoveOnly(1));
+ assert(std::get<0>(t) == 0);
+ assert(std::get<1>(t) == 1);
+ assert(std::get<2>(t) == MoveOnly());
+ }
+ {
+ std::tuple<MoveOnly, MoveOnly, MoveOnly> t(MoveOnly(0));
+ assert(std::get<0>(t) == 0);
+ assert(std::get<1>(t) == MoveOnly());
+ assert(std::get<2>(t) == MoveOnly());
+ }
+#if _LIBCPP_STD_VER > 11
+ {
+ constexpr std::tuple<Empty> t0{Empty()};
+ }
+ {
+ constexpr std::tuple<A, A> t(3, 2);
+ static_assert(std::get<0>(t).id_ == 3, "");
+ }
+#endif
+ // Check that SFINAE is properly applied with the default reduced arity
+ // constructor extensions.
+ test_default_constructible_extension_sfinae();
+}
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc.pass.cpp
new file mode 100644
index 000000000000..39776822cbda
--- /dev/null
+++ b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class Alloc>
+// tuple(allocator_arg_t, const Alloc& a);
+
+// UNSUPPORTED: c++98, c++03
+
+#include <tuple>
+#include <cassert>
+
+#include "DefaultOnly.h"
+#include "allocators.h"
+#include "../alloc_first.h"
+#include "../alloc_last.h"
+
+int main()
+{
+ {
+ std::tuple<> t(std::allocator_arg, A1<int>());
+ }
+ {
+ std::tuple<int> t(std::allocator_arg, A1<int>());
+ assert(std::get<0>(t) == 0);
+ }
+ {
+ std::tuple<DefaultOnly> t(std::allocator_arg, A1<int>());
+ assert(std::get<0>(t) == DefaultOnly());
+ }
+ {
+ assert(!alloc_first::allocator_constructed);
+ std::tuple<alloc_first> t(std::allocator_arg, A1<int>(5));
+ assert(alloc_first::allocator_constructed);
+ assert(std::get<0>(t) == alloc_first());
+ }
+ {
+ assert(!alloc_last::allocator_constructed);
+ std::tuple<alloc_last> t(std::allocator_arg, A1<int>(5));
+ assert(alloc_last::allocator_constructed);
+ assert(std::get<0>(t) == alloc_last());
+ }
+ {
+ alloc_first::allocator_constructed = false;
+ std::tuple<DefaultOnly, alloc_first> t(std::allocator_arg, A1<int>(5));
+ assert(std::get<0>(t) == DefaultOnly());
+ assert(alloc_first::allocator_constructed);
+ assert(std::get<1>(t) == alloc_first());
+ }
+ {
+ alloc_first::allocator_constructed = false;
+ alloc_last::allocator_constructed = false;
+ std::tuple<DefaultOnly, alloc_first, alloc_last> t(std::allocator_arg,
+ A1<int>(5));
+ assert(std::get<0>(t) == DefaultOnly());
+ assert(alloc_first::allocator_constructed);
+ assert(std::get<1>(t) == alloc_first());
+ assert(alloc_last::allocator_constructed);
+ assert(std::get<2>(t) == alloc_last());
+ }
+ {
+ alloc_first::allocator_constructed = false;
+ alloc_last::allocator_constructed = false;
+ std::tuple<DefaultOnly, alloc_first, alloc_last> t(std::allocator_arg,
+ A2<int>(5));
+ assert(std::get<0>(t) == DefaultOnly());
+ assert(!alloc_first::allocator_constructed);
+ assert(std::get<1>(t) == alloc_first());
+ assert(!alloc_last::allocator_constructed);
+ assert(std::get<2>(t) == alloc_last());
+ }
+}
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_UTypes.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_UTypes.pass.cpp
new file mode 100644
index 000000000000..3929965cd273
--- /dev/null
+++ b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_UTypes.pass.cpp
@@ -0,0 +1,141 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class Alloc, class... UTypes>
+// tuple(allocator_arg_t, const Alloc& a, UTypes&&...);
+
+// UNSUPPORTED: c++98, c++03
+
+#include <tuple>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "allocators.h"
+#include "../alloc_first.h"
+#include "../alloc_last.h"
+
+struct NoDefault { NoDefault() = delete; };
+
+// Make sure the _Up... constructor SFINAEs out when the types that
+// are not explicitly initialized are not all default constructible.
+// Otherwise, std::is_constructible would return true but instantiating
+// the constructor would fail.
+void test_default_constructible_extension_sfinae()
+{
+ {
+ typedef std::tuple<MoveOnly, NoDefault> Tuple;
+
+ static_assert(!std::is_constructible<
+ Tuple,
+ std::allocator_arg_t, A1<int>, MoveOnly
+ >::value, "");
+
+ static_assert(std::is_constructible<
+ Tuple,
+ std::allocator_arg_t, A1<int>, MoveOnly, NoDefault
+ >::value, "");
+ }
+ {
+ typedef std::tuple<MoveOnly, MoveOnly, NoDefault> Tuple;
+
+ static_assert(!std::is_constructible<
+ Tuple,
+ std::allocator_arg_t, A1<int>, MoveOnly, MoveOnly
+ >::value, "");
+
+ static_assert(std::is_constructible<
+ Tuple,
+ std::allocator_arg_t, A1<int>, MoveOnly, MoveOnly, NoDefault
+ >::value, "");
+ }
+ {
+ // Same idea as above but with a nested tuple
+ typedef std::tuple<MoveOnly, NoDefault> Tuple;
+ typedef std::tuple<MoveOnly, Tuple, MoveOnly, MoveOnly> NestedTuple;
+
+ static_assert(!std::is_constructible<
+ NestedTuple,
+ std::allocator_arg_t, A1<int>, MoveOnly, MoveOnly, MoveOnly, MoveOnly
+ >::value, "");
+
+ static_assert(std::is_constructible<
+ NestedTuple,
+ std::allocator_arg_t, A1<int>, MoveOnly, Tuple, MoveOnly, MoveOnly
+ >::value, "");
+ }
+ {
+ typedef std::tuple<MoveOnly, int> Tuple;
+ typedef std::tuple<MoveOnly, Tuple, MoveOnly, MoveOnly> NestedTuple;
+
+ static_assert(std::is_constructible<
+ NestedTuple,
+ std::allocator_arg_t, A1<int>, MoveOnly, MoveOnly, MoveOnly, MoveOnly
+ >::value, "");
+
+ static_assert(std::is_constructible<
+ NestedTuple,
+ std::allocator_arg_t, A1<int>, MoveOnly, Tuple, MoveOnly, MoveOnly
+ >::value, "");
+ }
+}
+
+int main()
+{
+ {
+ std::tuple<MoveOnly> t(std::allocator_arg, A1<int>(), MoveOnly(0));
+ assert(std::get<0>(t) == 0);
+ }
+ {
+ std::tuple<MoveOnly, MoveOnly> t(std::allocator_arg, A1<int>(),
+ MoveOnly(0), MoveOnly(1));
+ assert(std::get<0>(t) == 0);
+ assert(std::get<1>(t) == 1);
+ }
+ {
+ std::tuple<MoveOnly, MoveOnly, MoveOnly> t(std::allocator_arg, A1<int>(),
+ MoveOnly(0),
+ 1, 2);
+ assert(std::get<0>(t) == 0);
+ assert(std::get<1>(t) == 1);
+ assert(std::get<2>(t) == 2);
+ }
+ {
+ alloc_first::allocator_constructed = false;
+ alloc_last::allocator_constructed = false;
+ std::tuple<int, alloc_first, alloc_last> t(std::allocator_arg,
+ A1<int>(5), 1, 2, 3);
+ assert(std::get<0>(t) == 1);
+ assert(alloc_first::allocator_constructed);
+ assert(std::get<1>(t) == alloc_first(2));
+ assert(alloc_last::allocator_constructed);
+ assert(std::get<2>(t) == alloc_last(3));
+ }
+ // extensions
+ {
+ std::tuple<MoveOnly, MoveOnly, MoveOnly> t(std::allocator_arg, A1<int>(),
+ 0, 1);
+ assert(std::get<0>(t) == 0);
+ assert(std::get<1>(t) == 1);
+ assert(std::get<2>(t) == MoveOnly());
+ }
+ {
+ std::tuple<MoveOnly, MoveOnly, MoveOnly> t(std::allocator_arg, A1<int>(),
+ 0);
+ assert(std::get<0>(t) == 0);
+ assert(std::get<1>(t) == MoveOnly());
+ assert(std::get<2>(t) == MoveOnly());
+ }
+ // Check that SFINAE is properly applied with the default reduced arity
+ // constructor extensions.
+ test_default_constructible_extension_sfinae();
+}
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_const_Types.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_const_Types.pass.cpp
new file mode 100644
index 000000000000..0f68926376f2
--- /dev/null
+++ b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_const_Types.pass.cpp
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class Alloc>
+// tuple(allocator_arg_t, const Alloc& a, const Types&...);
+
+// UNSUPPORTED: c++98, c++03
+
+#include <tuple>
+#include <cassert>
+
+#include "allocators.h"
+#include "../alloc_first.h"
+#include "../alloc_last.h"
+
+int main()
+{
+ {
+ std::tuple<int> t(std::allocator_arg, A1<int>(), 3);
+ assert(std::get<0>(t) == 3);
+ }
+ {
+ assert(!alloc_first::allocator_constructed);
+ std::tuple<alloc_first> t(std::allocator_arg, A1<int>(5), alloc_first(3));
+ assert(alloc_first::allocator_constructed);
+ assert(std::get<0>(t) == alloc_first(3));
+ }
+ {
+ assert(!alloc_last::allocator_constructed);
+ std::tuple<alloc_last> t(std::allocator_arg, A1<int>(5), alloc_last(3));
+ assert(alloc_last::allocator_constructed);
+ assert(std::get<0>(t) == alloc_last(3));
+ }
+ {
+ alloc_first::allocator_constructed = false;
+ std::tuple<int, alloc_first> t(std::allocator_arg, A1<int>(5),
+ 10, alloc_first(15));
+ assert(std::get<0>(t) == 10);
+ assert(alloc_first::allocator_constructed);
+ assert(std::get<1>(t) == alloc_first(15));
+ }
+ {
+ alloc_first::allocator_constructed = false;
+ alloc_last::allocator_constructed = false;
+ std::tuple<int, alloc_first, alloc_last> t(std::allocator_arg,
+ A1<int>(5), 1, alloc_first(2),
+ alloc_last(3));
+ assert(std::get<0>(t) == 1);
+ assert(alloc_first::allocator_constructed);
+ assert(std::get<1>(t) == alloc_first(2));
+ assert(alloc_last::allocator_constructed);
+ assert(std::get<2>(t) == alloc_last(3));
+ }
+ {
+ alloc_first::allocator_constructed = false;
+ alloc_last::allocator_constructed = false;
+ std::tuple<int, alloc_first, alloc_last> t(std::allocator_arg,
+ A2<int>(5), 1, alloc_first(2),
+ alloc_last(3));
+ assert(std::get<0>(t) == 1);
+ assert(!alloc_first::allocator_constructed);
+ assert(std::get<1>(t) == alloc_first(2));
+ assert(!alloc_last::allocator_constructed);
+ assert(std::get<2>(t) == alloc_last(3));
+ }
+}
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_const_pair.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_const_pair.pass.cpp
new file mode 100644
index 000000000000..c5941618180d
--- /dev/null
+++ b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_const_pair.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class Alloc, class U1, class U2>
+// tuple(allocator_arg_t, const Alloc& a, const pair<U1, U2>&);
+
+// UNSUPPORTED: c++98, c++03
+
+#include <tuple>
+#include <utility>
+#include <cassert>
+
+#include "allocators.h"
+#include "../alloc_first.h"
+#include "../alloc_last.h"
+
+int main()
+{
+ {
+ typedef std::pair<double, int> T0;
+ typedef std::tuple<int, double> T1;
+ T0 t0(2, 3);
+ T1 t1(std::allocator_arg, A1<int>(5), t0);
+ assert(std::get<0>(t1) == 2);
+ assert(std::get<1>(t1) == 3);
+ }
+ {
+ typedef std::pair<int, int> T0;
+ typedef std::tuple<alloc_first, double> T1;
+ T0 t0(2, 3);
+ alloc_first::allocator_constructed = false;
+ T1 t1(std::allocator_arg, A1<int>(5), t0);
+ assert(alloc_first::allocator_constructed);
+ assert(std::get<0>(t1) == 2);
+ assert(std::get<1>(t1) == 3);
+ }
+ {
+ typedef std::pair<int, int> T0;
+ typedef std::tuple<alloc_first, alloc_last> T1;
+ T0 t0(2, 3);
+ alloc_first::allocator_constructed = false;
+ alloc_last::allocator_constructed = false;
+ T1 t1(std::allocator_arg, A1<int>(5), t0);
+ assert(alloc_first::allocator_constructed);
+ assert(alloc_last::allocator_constructed);
+ assert(std::get<0>(t1) == 2);
+ assert(std::get<1>(t1) == 3);
+ }
+}
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_convert_copy.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_convert_copy.pass.cpp
new file mode 100644
index 000000000000..8acfde7a98eb
--- /dev/null
+++ b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_convert_copy.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class Alloc, class... UTypes>
+// tuple(allocator_arg_t, const Alloc& a, const tuple<UTypes...>&);
+
+// UNSUPPORTED: c++98, c++03
+
+#include <tuple>
+#include <cassert>
+
+#include "allocators.h"
+#include "../alloc_first.h"
+#include "../alloc_last.h"
+
+int main()
+{
+ {
+ typedef std::tuple<double> T0;
+ typedef std::tuple<int> T1;
+ T0 t0(2.5);
+ T1 t1(std::allocator_arg, A1<int>(), t0);
+ assert(std::get<0>(t1) == 2);
+ }
+ {
+ typedef std::tuple<int> T0;
+ typedef std::tuple<alloc_first> T1;
+ T0 t0(2);
+ alloc_first::allocator_constructed = false;
+ T1 t1(std::allocator_arg, A1<int>(5), t0);
+ assert(alloc_first::allocator_constructed);
+ assert(std::get<0>(t1) == 2);
+ }
+ {
+ typedef std::tuple<int, int> T0;
+ typedef std::tuple<alloc_first, alloc_last> T1;
+ T0 t0(2, 3);
+ alloc_first::allocator_constructed = false;
+ alloc_last::allocator_constructed = false;
+ T1 t1(std::allocator_arg, A1<int>(5), t0);
+ assert(alloc_first::allocator_constructed);
+ assert(alloc_last::allocator_constructed);
+ assert(std::get<0>(t1) == 2);
+ assert(std::get<1>(t1) == 3);
+ }
+ {
+ typedef std::tuple<double, int, int> T0;
+ typedef std::tuple<int, alloc_first, alloc_last> T1;
+ T0 t0(1.5, 2, 3);
+ alloc_first::allocator_constructed = false;
+ alloc_last::allocator_constructed = false;
+ T1 t1(std::allocator_arg, A1<int>(5), t0);
+ assert(alloc_first::allocator_constructed);
+ assert(alloc_last::allocator_constructed);
+ assert(std::get<0>(t1) == 1);
+ assert(std::get<1>(t1) == 2);
+ assert(std::get<2>(t1) == 3);
+ }
+}
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_convert_move.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_convert_move.pass.cpp
new file mode 100644
index 000000000000..c862d3b64d56
--- /dev/null
+++ b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_convert_move.pass.cpp
@@ -0,0 +1,84 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class Alloc, class... UTypes>
+// tuple(allocator_arg_t, const Alloc& a, tuple<UTypes...>&&);
+
+// UNSUPPORTED: c++98, c++03
+
+#include <tuple>
+#include <string>
+#include <memory>
+#include <cassert>
+
+#include "allocators.h"
+#include "../alloc_first.h"
+#include "../alloc_last.h"
+
+struct B
+{
+ int id_;
+
+ explicit B(int i) : id_(i) {}
+
+ virtual ~B() {}
+};
+
+struct D
+ : B
+{
+ explicit D(int i) : B(i) {}
+};
+
+int main()
+{
+ {
+ typedef std::tuple<int> T0;
+ typedef std::tuple<alloc_first> T1;
+ T0 t0(2);
+ alloc_first::allocator_constructed = false;
+ T1 t1(std::allocator_arg, A1<int>(5), std::move(t0));
+ assert(alloc_first::allocator_constructed);
+ assert(std::get<0>(t1) == 2);
+ }
+ {
+ typedef std::tuple<std::unique_ptr<D>> T0;
+ typedef std::tuple<std::unique_ptr<B>> T1;
+ T0 t0(std::unique_ptr<D>(new D(3)));
+ T1 t1(std::allocator_arg, A1<int>(5), std::move(t0));
+ assert(std::get<0>(t1)->id_ == 3);
+ }
+ {
+ typedef std::tuple<int, std::unique_ptr<D>> T0;
+ typedef std::tuple<alloc_first, std::unique_ptr<B>> T1;
+ T0 t0(2, std::unique_ptr<D>(new D(3)));
+ alloc_first::allocator_constructed = false;
+ T1 t1(std::allocator_arg, A1<int>(5), std::move(t0));
+ assert(alloc_first::allocator_constructed);
+ assert(std::get<0>(t1) == 2);
+ assert(std::get<1>(t1)->id_ == 3);
+ }
+ {
+ typedef std::tuple<int, int, std::unique_ptr<D>> T0;
+ typedef std::tuple<alloc_last, alloc_first, std::unique_ptr<B>> T1;
+ T0 t0(1, 2, std::unique_ptr<D>(new D(3)));
+ alloc_first::allocator_constructed = false;
+ alloc_last::allocator_constructed = false;
+ T1 t1(std::allocator_arg, A1<int>(5), std::move(t0));
+ assert(alloc_first::allocator_constructed);
+ assert(alloc_last::allocator_constructed);
+ assert(std::get<0>(t1) == 1);
+ assert(std::get<1>(t1) == 2);
+ assert(std::get<2>(t1)->id_ == 3);
+ }
+}
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_copy.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_copy.pass.cpp
new file mode 100644
index 000000000000..14e127e59ba9
--- /dev/null
+++ b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_copy.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class Alloc>
+// tuple(allocator_arg_t, const Alloc& a, const tuple&);
+
+// UNSUPPORTED: c++98, c++03
+
+#include <tuple>
+#include <cassert>
+
+#include "allocators.h"
+#include "../alloc_first.h"
+#include "../alloc_last.h"
+
+int main()
+{
+ {
+ typedef std::tuple<> T;
+ T t0;
+ T t(std::allocator_arg, A1<int>(), t0);
+ }
+ {
+ typedef std::tuple<int> T;
+ T t0(2);
+ T t(std::allocator_arg, A1<int>(), t0);
+ assert(std::get<0>(t) == 2);
+ }
+ {
+ typedef std::tuple<alloc_first> T;
+ T t0(2);
+ alloc_first::allocator_constructed = false;
+ T t(std::allocator_arg, A1<int>(5), t0);
+ assert(alloc_first::allocator_constructed);
+ assert(std::get<0>(t) == 2);
+ }
+ {
+ typedef std::tuple<alloc_last> T;
+ T t0(2);
+ alloc_last::allocator_constructed = false;
+ T t(std::allocator_arg, A1<int>(5), t0);
+ assert(alloc_last::allocator_constructed);
+ assert(std::get<0>(t) == 2);
+ }
+ {
+ typedef std::tuple<alloc_first, alloc_last> T;
+ T t0(2, 3);
+ alloc_first::allocator_constructed = false;
+ alloc_last::allocator_constructed = false;
+ T t(std::allocator_arg, A1<int>(5), t0);
+ assert(alloc_first::allocator_constructed);
+ assert(alloc_last::allocator_constructed);
+ assert(std::get<0>(t) == 2);
+ assert(std::get<1>(t) == 3);
+ }
+ {
+ typedef std::tuple<int, alloc_first, alloc_last> T;
+ T t0(1, 2, 3);
+ alloc_first::allocator_constructed = false;
+ alloc_last::allocator_constructed = false;
+ T t(std::allocator_arg, A1<int>(5), t0);
+ assert(alloc_first::allocator_constructed);
+ assert(alloc_last::allocator_constructed);
+ assert(std::get<0>(t) == 1);
+ assert(std::get<1>(t) == 2);
+ assert(std::get<2>(t) == 3);
+ }
+}
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_move.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_move.pass.cpp
new file mode 100644
index 000000000000..54d3f7ee0c07
--- /dev/null
+++ b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_move.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class Alloc>
+// tuple(allocator_arg_t, const Alloc& a, tuple&&);
+
+// UNSUPPORTED: c++98, c++03
+
+#include <tuple>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "allocators.h"
+#include "../alloc_first.h"
+#include "../alloc_last.h"
+
+int main()
+{
+ {
+ typedef std::tuple<> T;
+ T t0;
+ T t(std::allocator_arg, A1<int>(), std::move(t0));
+ }
+ {
+ typedef std::tuple<MoveOnly> T;
+ T t0(MoveOnly(0));
+ T t(std::allocator_arg, A1<int>(), std::move(t0));
+ assert(std::get<0>(t) == 0);
+ }
+ {
+ typedef std::tuple<alloc_first> T;
+ T t0(1);
+ alloc_first::allocator_constructed = false;
+ T t(std::allocator_arg, A1<int>(5), std::move(t0));
+ assert(alloc_first::allocator_constructed);
+ assert(std::get<0>(t) == 1);
+ }
+ {
+ typedef std::tuple<alloc_last> T;
+ T t0(1);
+ alloc_last::allocator_constructed = false;
+ T t(std::allocator_arg, A1<int>(5), std::move(t0));
+ assert(alloc_last::allocator_constructed);
+ assert(std::get<0>(t) == 1);
+ }
+ {
+ typedef std::tuple<MoveOnly, alloc_first> T;
+ T t0(0 ,1);
+ alloc_first::allocator_constructed = false;
+ T t(std::allocator_arg, A1<int>(5), std::move(t0));
+ assert(alloc_first::allocator_constructed);
+ assert(std::get<0>(t) == 0);
+ assert(std::get<1>(t) == 1);
+ }
+ {
+ typedef std::tuple<MoveOnly, alloc_first, alloc_last> T;
+ T t0(1, 2, 3);
+ alloc_first::allocator_constructed = false;
+ alloc_last::allocator_constructed = false;
+ T t(std::allocator_arg, A1<int>(5), std::move(t0));
+ assert(alloc_first::allocator_constructed);
+ assert(alloc_last::allocator_constructed);
+ assert(std::get<0>(t) == 1);
+ assert(std::get<1>(t) == 2);
+ assert(std::get<2>(t) == 3);
+ }
+}
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_move_pair.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_move_pair.pass.cpp
new file mode 100644
index 000000000000..03e9ab2f6026
--- /dev/null
+++ b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_move_pair.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class Alloc, class U1, class U2>
+// tuple(allocator_arg_t, const Alloc& a, pair<U1, U2>&&);
+
+// UNSUPPORTED: c++98, c++03
+
+#include <tuple>
+#include <utility>
+#include <memory>
+#include <cassert>
+
+#include "allocators.h"
+#include "../alloc_first.h"
+#include "../alloc_last.h"
+
+struct B
+{
+ int id_;
+
+ explicit B(int i) : id_(i) {}
+
+ virtual ~B() {}
+};
+
+struct D
+ : B
+{
+ explicit D(int i) : B(i) {}
+};
+
+int main()
+{
+ {
+ typedef std::pair<int, std::unique_ptr<D>> T0;
+ typedef std::tuple<alloc_first, std::unique_ptr<B>> T1;
+ T0 t0(2, std::unique_ptr<D>(new D(3)));
+ alloc_first::allocator_constructed = false;
+ T1 t1(std::allocator_arg, A1<int>(5), std::move(t0));
+ assert(alloc_first::allocator_constructed);
+ assert(std::get<0>(t1) == 2);
+ assert(std::get<1>(t1)->id_ == 3);
+ }
+}
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/const_Types.fail.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/const_Types.fail.cpp
new file mode 100644
index 000000000000..00e2af265b36
--- /dev/null
+++ b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/const_Types.fail.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// explicit tuple(const T&...);
+
+// UNSUPPORTED: c++98, c++03
+
+#include <tuple>
+#include <string>
+#include <cassert>
+
+int main()
+{
+ {
+ std::tuple<int*> t = 0;
+ }
+}
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/const_Types.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/const_Types.pass.cpp
new file mode 100644
index 000000000000..bbadf8de1600
--- /dev/null
+++ b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/const_Types.pass.cpp
@@ -0,0 +1,132 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// explicit tuple(const T&...);
+
+// UNSUPPORTED: c++98, c++03
+
+#include <tuple>
+#include <string>
+#include <cassert>
+
+
+template <class ...>
+struct never {
+ enum { value = 0 };
+};
+
+struct NoValueCtor
+{
+ NoValueCtor() : id(++count) {}
+ NoValueCtor(NoValueCtor const & other) : id(other.id) { ++count; }
+
+ // The constexpr is required to make is_constructible instantiate this template.
+ // The explicit is needed to test-around a similar bug with is_convertible.
+ template <class T>
+ constexpr explicit NoValueCtor(T)
+ { static_assert(never<T>::value, "This should not be instantiated"); }
+
+ static int count;
+ int id;
+};
+
+int NoValueCtor::count = 0;
+
+
+struct NoValueCtorEmpty
+{
+ NoValueCtorEmpty() {}
+ NoValueCtorEmpty(NoValueCtorEmpty const &) {}
+
+ template <class T>
+ constexpr explicit NoValueCtorEmpty(T)
+ { static_assert(never<T>::value, "This should not be instantiated"); }
+};
+
+int main()
+{
+ {
+ std::tuple<int> t(2);
+ assert(std::get<0>(t) == 2);
+ }
+#if _LIBCPP_STD_VER > 11
+ {
+ constexpr std::tuple<int> t(2);
+ static_assert(std::get<0>(t) == 2, "");
+ }
+ {
+ constexpr std::tuple<int> t;
+ static_assert(std::get<0>(t) == 0, "");
+ }
+#endif
+ {
+ std::tuple<int, char*> t(2, 0);
+ assert(std::get<0>(t) == 2);
+ assert(std::get<1>(t) == nullptr);
+ }
+#if _LIBCPP_STD_VER > 11
+ {
+ constexpr std::tuple<int, char*> t(2, nullptr);
+ static_assert(std::get<0>(t) == 2, "");
+ static_assert(std::get<1>(t) == nullptr, "");
+ }
+#endif
+ {
+ std::tuple<int, char*> t(2, nullptr);
+ assert(std::get<0>(t) == 2);
+ assert(std::get<1>(t) == nullptr);
+ }
+ {
+ std::tuple<int, char*, std::string> t(2, nullptr, "text");
+ assert(std::get<0>(t) == 2);
+ assert(std::get<1>(t) == nullptr);
+ assert(std::get<2>(t) == "text");
+ }
+ // __tuple_leaf<T> uses is_constructible<T, U> to disable its explicit converting
+ // constructor overload __tuple_leaf(U &&). Evaluating is_constructible can cause a compile error.
+ // This overload is evaluated when __tuple_leafs copy or move ctor is called.
+ // This checks that is_constructible is not evaluated when U == __tuple_leaf.
+ {
+ std::tuple<int, NoValueCtor, int, int> t(1, NoValueCtor(), 2, 3);
+ assert(std::get<0>(t) == 1);
+ assert(std::get<1>(t).id == 1);
+ assert(std::get<2>(t) == 2);
+ assert(std::get<3>(t) == 3);
+ }
+ {
+ std::tuple<int, NoValueCtorEmpty, int, int> t(1, NoValueCtorEmpty(), 2, 3);
+ assert(std::get<0>(t) == 1);
+ assert(std::get<2>(t) == 2);
+ assert(std::get<3>(t) == 3);
+ }
+ // extensions
+ {
+ std::tuple<int, char*, std::string> t(2);
+ assert(std::get<0>(t) == 2);
+ assert(std::get<1>(t) == nullptr);
+ assert(std::get<2>(t) == "");
+ }
+ {
+ std::tuple<int, char*, std::string> t(2, nullptr);
+ assert(std::get<0>(t) == 2);
+ assert(std::get<1>(t) == nullptr);
+ assert(std::get<2>(t) == "");
+ }
+ {
+ std::tuple<int, char*, std::string, double> t(2, nullptr, "text");
+ assert(std::get<0>(t) == 2);
+ assert(std::get<1>(t) == nullptr);
+ assert(std::get<2>(t) == "text");
+ assert(std::get<3>(t) == 0.0);
+ }
+}
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/const_Types2.fail.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/const_Types2.fail.cpp
new file mode 100644
index 000000000000..68b3fbd0dd9e
--- /dev/null
+++ b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/const_Types2.fail.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// explicit tuple(const T&...);
+
+// UNSUPPORTED: c++98, c++03
+
+#include <tuple>
+#include <string>
+#include <cassert>
+
+int main()
+{
+ {
+ std::tuple<int, char*, std::string, double&> t(2, nullptr, "text");
+ }
+}
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/const_pair.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/const_pair.pass.cpp
new file mode 100644
index 000000000000..740b6589e511
--- /dev/null
+++ b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/const_pair.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class U1, class U2> tuple(const pair<U1, U2>& u);
+
+// UNSUPPORTED: c++98, c++03
+
+#include <tuple>
+#include <utility>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::pair<double, char> T0;
+ typedef std::tuple<int, short> T1;
+ T0 t0(2.5, 'a');
+ T1 t1 = t0;
+ assert(std::get<0>(t1) == 2);
+ assert(std::get<1>(t1) == short('a'));
+ }
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::pair<double, char> P0;
+ typedef std::tuple<int, short> T1;
+ constexpr P0 p0(2.5, 'a');
+ constexpr T1 t1 = p0;
+ static_assert(std::get<0>(t1) != std::get<0>(p0), "");
+ static_assert(std::get<1>(t1) == std::get<1>(p0), "");
+ static_assert(std::get<0>(t1) == 2, "");
+ static_assert(std::get<1>(t1) == short('a'), "");
+ }
+#endif
+}
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/convert_copy.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/convert_copy.pass.cpp
new file mode 100644
index 000000000000..5ad4f9227f48
--- /dev/null
+++ b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/convert_copy.pass.cpp
@@ -0,0 +1,118 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class... UTypes> tuple(const tuple<UTypes...>& u);
+
+// UNSUPPORTED: c++98, c++03
+
+#include <tuple>
+#include <utility>
+#include <string>
+#include <cassert>
+
+struct B
+{
+ int id_;
+
+ explicit B(int i) : id_(i) {}
+};
+
+struct D
+ : B
+{
+ explicit D(int i) : B(i) {}
+};
+
+#if _LIBCPP_STD_VER > 11
+
+struct A
+{
+ int id_;
+
+ constexpr A(int i) : id_(i) {}
+ friend constexpr bool operator==(const A& x, const A& y) {return x.id_ == y.id_;}
+};
+
+struct C
+{
+ int id_;
+
+ constexpr explicit C(int i) : id_(i) {}
+ friend constexpr bool operator==(const C& x, const C& y) {return x.id_ == y.id_;}
+};
+
+#endif
+
+int main()
+{
+ {
+ typedef std::tuple<double> T0;
+ typedef std::tuple<int> T1;
+ T0 t0(2.5);
+ T1 t1 = t0;
+ assert(std::get<0>(t1) == 2);
+ }
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::tuple<double> T0;
+ typedef std::tuple<A> T1;
+ constexpr T0 t0(2.5);
+ constexpr T1 t1 = t0;
+ static_assert(std::get<0>(t1) == 2, "");
+ }
+ {
+ typedef std::tuple<int> T0;
+ typedef std::tuple<C> T1;
+ constexpr T0 t0(2);
+ constexpr T1 t1{t0};
+ static_assert(std::get<0>(t1) == C(2), "");
+ }
+#endif
+ {
+ typedef std::tuple<double, char> T0;
+ typedef std::tuple<int, int> T1;
+ T0 t0(2.5, 'a');
+ T1 t1 = t0;
+ assert(std::get<0>(t1) == 2);
+ assert(std::get<1>(t1) == int('a'));
+ }
+ {
+ typedef std::tuple<double, char, D> T0;
+ typedef std::tuple<int, int, B> T1;
+ T0 t0(2.5, 'a', D(3));
+ T1 t1 = t0;
+ assert(std::get<0>(t1) == 2);
+ assert(std::get<1>(t1) == int('a'));
+ assert(std::get<2>(t1).id_ == 3);
+ }
+ {
+ D d(3);
+ typedef std::tuple<double, char, D&> T0;
+ typedef std::tuple<int, int, B&> T1;
+ T0 t0(2.5, 'a', d);
+ T1 t1 = t0;
+ d.id_ = 2;
+ assert(std::get<0>(t1) == 2);
+ assert(std::get<1>(t1) == int('a'));
+ assert(std::get<2>(t1).id_ == 2);
+ }
+ {
+ typedef std::tuple<double, char, int> T0;
+ typedef std::tuple<int, int, B> T1;
+ T0 t0(2.5, 'a', 3);
+ T1 t1(t0);
+ assert(std::get<0>(t1) == 2);
+ assert(std::get<1>(t1) == int('a'));
+ assert(std::get<2>(t1).id_ == 3);
+ }
+}
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/convert_move.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/convert_move.pass.cpp
new file mode 100644
index 000000000000..3a6abd3a95af
--- /dev/null
+++ b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/convert_move.pass.cpp
@@ -0,0 +1,84 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class... UTypes> tuple(tuple<UTypes...>&& u);
+
+// UNSUPPORTED: c++98, c++03
+
+#include <tuple>
+#include <string>
+#include <memory>
+#include <cassert>
+
+struct B
+{
+ int id_;
+
+ explicit B(int i) : id_(i) {}
+
+ virtual ~B() {}
+};
+
+struct D
+ : B
+{
+ explicit D(int i) : B(i) {}
+};
+
+int main()
+{
+ {
+ typedef std::tuple<double> T0;
+ typedef std::tuple<int> T1;
+ T0 t0(2.5);
+ T1 t1 = std::move(t0);
+ assert(std::get<0>(t1) == 2);
+ }
+ {
+ typedef std::tuple<double, char> T0;
+ typedef std::tuple<int, int> T1;
+ T0 t0(2.5, 'a');
+ T1 t1 = std::move(t0);
+ assert(std::get<0>(t1) == 2);
+ assert(std::get<1>(t1) == int('a'));
+ }
+ {
+ typedef std::tuple<double, char, D> T0;
+ typedef std::tuple<int, int, B> T1;
+ T0 t0(2.5, 'a', D(3));
+ T1 t1 = std::move(t0);
+ assert(std::get<0>(t1) == 2);
+ assert(std::get<1>(t1) == int('a'));
+ assert(std::get<2>(t1).id_ == 3);
+ }
+ {
+ D d(3);
+ typedef std::tuple<double, char, D&> T0;
+ typedef std::tuple<int, int, B&> T1;
+ T0 t0(2.5, 'a', d);
+ T1 t1 = std::move(t0);
+ d.id_ = 2;
+ assert(std::get<0>(t1) == 2);
+ assert(std::get<1>(t1) == int('a'));
+ assert(std::get<2>(t1).id_ == 2);
+ }
+ {
+ typedef std::tuple<double, char, std::unique_ptr<D>> T0;
+ typedef std::tuple<int, int, std::unique_ptr<B>> T1;
+ T0 t0(2.5, 'a', std::unique_ptr<D>(new D(3)));
+ T1 t1 = std::move(t0);
+ assert(std::get<0>(t1) == 2);
+ assert(std::get<1>(t1) == int('a'));
+ assert(std::get<2>(t1)->id_ == 3);
+ }
+}
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/copy.fail.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/copy.fail.cpp
new file mode 100644
index 000000000000..1937f49efa76
--- /dev/null
+++ b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/copy.fail.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// tuple(const tuple& u) = default;
+
+// UNSUPPORTED: c++98, c++03
+
+#include <tuple>
+#include <cassert>
+
+#include "MoveOnly.h"
+
+int main()
+{
+ {
+ typedef std::tuple<MoveOnly> T;
+ T t0(MoveOnly(2));
+ T t = t0;
+ }
+}
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/copy.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/copy.pass.cpp
new file mode 100644
index 000000000000..783c9d1f06a8
--- /dev/null
+++ b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/copy.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// tuple(const tuple& u) = default;
+
+// UNSUPPORTED: c++98, c++03
+
+#include <tuple>
+#include <string>
+#include <cassert>
+
+struct Empty {};
+
+int main()
+{
+ {
+ typedef std::tuple<> T;
+ T t0;
+ T t = t0;
+ ((void)t); // Prevent unused warning
+ }
+ {
+ typedef std::tuple<int> T;
+ T t0(2);
+ T t = t0;
+ assert(std::get<0>(t) == 2);
+ }
+ {
+ typedef std::tuple<int, char> T;
+ T t0(2, 'a');
+ T t = t0;
+ assert(std::get<0>(t) == 2);
+ assert(std::get<1>(t) == 'a');
+ }
+ {
+ typedef std::tuple<int, char, std::string> T;
+ const T t0(2, 'a', "some text");
+ T t = t0;
+ assert(std::get<0>(t) == 2);
+ assert(std::get<1>(t) == 'a');
+ assert(std::get<2>(t) == "some text");
+ }
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::tuple<int> T;
+ constexpr T t0(2);
+ constexpr T t = t0;
+ static_assert(std::get<0>(t) == 2, "");
+ }
+ {
+ typedef std::tuple<Empty> T;
+ constexpr T t0;
+ constexpr T t = t0;
+ constexpr Empty e = std::get<0>(t);
+ ((void)e); // Prevent unused warning
+ }
+#endif
+}
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/default.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/default.pass.cpp
new file mode 100644
index 000000000000..d282c9c68a42
--- /dev/null
+++ b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/default.pass.cpp
@@ -0,0 +1,110 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// constexpr tuple();
+
+// UNSUPPORTED: c++98, c++03
+
+#include <tuple>
+#include <string>
+#include <cassert>
+#include <type_traits>
+
+#include "DefaultOnly.h"
+
+struct NoDefault {
+ NoDefault() = delete;
+ explicit NoDefault(int) { }
+};
+
+struct NoExceptDefault {
+ NoExceptDefault() noexcept = default;
+};
+
+struct ThrowingDefault {
+ ThrowingDefault() { }
+};
+
+struct IllFormedDefault {
+ IllFormedDefault(int x) : value(x) {}
+ template <bool Pred = false>
+ constexpr IllFormedDefault() {
+ static_assert(Pred,
+ "The default constructor should not be instantiated");
+ }
+ int value;
+};
+
+int main()
+{
+ {
+ std::tuple<> t;
+ }
+ {
+ std::tuple<int> t;
+ assert(std::get<0>(t) == 0);
+ }
+ {
+ std::tuple<int, char*> t;
+ assert(std::get<0>(t) == 0);
+ assert(std::get<1>(t) == nullptr);
+ }
+ {
+ std::tuple<int, char*, std::string> t;
+ assert(std::get<0>(t) == 0);
+ assert(std::get<1>(t) == nullptr);
+ assert(std::get<2>(t) == "");
+ }
+ {
+ std::tuple<int, char*, std::string, DefaultOnly> t;
+ assert(std::get<0>(t) == 0);
+ assert(std::get<1>(t) == nullptr);
+ assert(std::get<2>(t) == "");
+ assert(std::get<3>(t) == DefaultOnly());
+ }
+ {
+ // See bug #21157.
+ static_assert(!std::is_default_constructible<std::tuple<NoDefault>>(), "");
+ static_assert(!std::is_default_constructible<std::tuple<DefaultOnly, NoDefault>>(), "");
+ static_assert(!std::is_default_constructible<std::tuple<NoDefault, DefaultOnly, NoDefault>>(), "");
+ }
+ {
+ static_assert(noexcept(std::tuple<NoExceptDefault>()), "");
+ static_assert(noexcept(std::tuple<NoExceptDefault, NoExceptDefault>()), "");
+
+ static_assert(!noexcept(std::tuple<ThrowingDefault, NoExceptDefault>()), "");
+ static_assert(!noexcept(std::tuple<NoExceptDefault, ThrowingDefault>()), "");
+ static_assert(!noexcept(std::tuple<ThrowingDefault, ThrowingDefault>()), "");
+ }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+ {
+ constexpr std::tuple<> t;
+ }
+ {
+ constexpr std::tuple<int> t;
+ assert(std::get<0>(t) == 0);
+ }
+ {
+ constexpr std::tuple<int, char*> t;
+ assert(std::get<0>(t) == 0);
+ assert(std::get<1>(t) == nullptr);
+ }
+ {
+ // Check that the SFINAE on the default constructor is not evaluted when
+ // it isn't needed. If the default constructor is evaluted then this test
+ // should fail to compile.
+ IllFormedDefault v(0);
+ std::tuple<IllFormedDefault> t(v);
+ }
+#endif
+}
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/move.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/move.pass.cpp
new file mode 100644
index 000000000000..0cda96846f71
--- /dev/null
+++ b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/move.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// tuple(tuple&& u);
+
+// UNSUPPORTED: c++98, c++03
+
+#include <tuple>
+#include <utility>
+#include <cassert>
+
+#include "MoveOnly.h"
+
+struct ConstructsWithTupleLeaf
+{
+ ConstructsWithTupleLeaf() {}
+
+ ConstructsWithTupleLeaf(ConstructsWithTupleLeaf const &) { assert(false); }
+ ConstructsWithTupleLeaf(ConstructsWithTupleLeaf &&) {}
+
+ template <class T>
+ ConstructsWithTupleLeaf(T t)
+ { assert(false); }
+};
+
+int main()
+{
+ {
+ typedef std::tuple<> T;
+ T t0;
+ T t = std::move(t0);
+ ((void)t); // Prevent unused warning
+ }
+ {
+ typedef std::tuple<MoveOnly> T;
+ T t0(MoveOnly(0));
+ T t = std::move(t0);
+ assert(std::get<0>(t) == 0);
+ }
+ {
+ typedef std::tuple<MoveOnly, MoveOnly> T;
+ T t0(MoveOnly(0), MoveOnly(1));
+ T t = std::move(t0);
+ assert(std::get<0>(t) == 0);
+ assert(std::get<1>(t) == 1);
+ }
+ {
+ typedef std::tuple<MoveOnly, MoveOnly, MoveOnly> T;
+ T t0(MoveOnly(0), MoveOnly(1), MoveOnly(2));
+ T t = std::move(t0);
+ assert(std::get<0>(t) == 0);
+ assert(std::get<1>(t) == 1);
+ assert(std::get<2>(t) == 2);
+ }
+ // A bug in tuple caused __tuple_leaf to use its explicit converting constructor
+ // as its move constructor. This tests that ConstructsWithTupleLeaf is not called
+ // (w/ __tuple_leaf)
+ {
+ typedef std::tuple<ConstructsWithTupleLeaf> d_t;
+ d_t d((ConstructsWithTupleLeaf()));
+ d_t d2(static_cast<d_t &&>(d));
+ }
+}
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/move_pair.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/move_pair.pass.cpp
new file mode 100644
index 000000000000..2dfbaff6cc1a
--- /dev/null
+++ b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/move_pair.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class U1, class U2> tuple(pair<U1, U2>&& u);
+
+// UNSUPPORTED: c++98, c++03
+
+#include <tuple>
+#include <utility>
+#include <memory>
+#include <cassert>
+
+struct B
+{
+ int id_;
+
+ explicit B(int i) : id_(i) {}
+
+ virtual ~B() {}
+};
+
+struct D
+ : B
+{
+ explicit D(int i) : B(i) {}
+};
+
+int main()
+{
+ {
+ typedef std::pair<double, std::unique_ptr<D>> T0;
+ typedef std::tuple<int, std::unique_ptr<B>> T1;
+ T0 t0(2.5, std::unique_ptr<D>(new D(3)));
+ T1 t1 = std::move(t0);
+ assert(std::get<0>(t1) == 2);
+ assert(std::get<1>(t1)->id_ == 3);
+ }
+}
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/tuple_array_template_depth.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/tuple_array_template_depth.pass.cpp
new file mode 100644
index 000000000000..c069a0ba20ea
--- /dev/null
+++ b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/tuple_array_template_depth.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class Tuple, __tuple_convertible<Tuple, tuple> >
+// tuple(Tuple &&);
+//
+// template <class Tuple, __tuple_constructible<Tuple, tuple> >
+// tuple(Tuple &&);
+
+// This test checks that we do not evaluate __make_tuple_types
+// on the array.
+
+#include <array>
+#include <tuple>
+
+// Use 1256 to try and blow the template instantiation depth for all compilers.
+typedef std::array<char, 1256> array_t;
+typedef std::tuple<array_t> tuple_t;
+
+int main()
+{
+ array_t arr;
+ tuple_t tup(arr);
+}
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.creation/forward_as_tuple.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.creation/forward_as_tuple.pass.cpp
new file mode 100644
index 000000000000..0e556b1b6c8e
--- /dev/null
+++ b/test/std/utilities/tuple/tuple.tuple/tuple.creation/forward_as_tuple.pass.cpp
@@ -0,0 +1,86 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template<class... Types>
+// tuple<Types&&...> forward_as_tuple(Types&&... t);
+
+// UNSUPPORTED: c++98, c++03
+
+#include <tuple>
+#include <type_traits>
+#include <cassert>
+
+template <class Tuple>
+void
+test0(const Tuple& t)
+{
+ static_assert(std::tuple_size<Tuple>::value == 0, "");
+}
+
+template <class Tuple>
+void
+test1a(const Tuple& t)
+{
+ static_assert(std::tuple_size<Tuple>::value == 1, "");
+ static_assert(std::is_same<typename std::tuple_element<0, Tuple>::type, int&&>::value, "");
+ assert(std::get<0>(t) == 1);
+}
+
+template <class Tuple>
+void
+test1b(const Tuple& t)
+{
+ static_assert(std::tuple_size<Tuple>::value == 1, "");
+ static_assert(std::is_same<typename std::tuple_element<0, Tuple>::type, int&>::value, "");
+ assert(std::get<0>(t) == 2);
+}
+
+template <class Tuple>
+void
+test2a(const Tuple& t)
+{
+ static_assert(std::tuple_size<Tuple>::value == 2, "");
+ static_assert(std::is_same<typename std::tuple_element<0, Tuple>::type, double&>::value, "");
+ static_assert(std::is_same<typename std::tuple_element<1, Tuple>::type, char&>::value, "");
+ assert(std::get<0>(t) == 2.5);
+ assert(std::get<1>(t) == 'a');
+}
+
+#if _LIBCPP_STD_VER > 11
+template <class Tuple>
+constexpr int
+test3(const Tuple& t)
+{
+ return std::tuple_size<Tuple>::value;
+}
+#endif
+
+int main()
+{
+ {
+ test0(std::forward_as_tuple());
+ }
+ {
+ test1a(std::forward_as_tuple(1));
+ }
+ {
+ int i = 2;
+ test1b(std::forward_as_tuple(i));
+ }
+ {
+ double i = 2.5;
+ char c = 'a';
+ test2a(std::forward_as_tuple(i, c));
+#if _LIBCPP_STD_VER > 11
+ static_assert ( test3 (std::forward_as_tuple(i, c)) == 2, "" );
+#endif
+ }
+}
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.creation/make_tuple.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.creation/make_tuple.pass.cpp
new file mode 100644
index 000000000000..2ee96dc7ebf4
--- /dev/null
+++ b/test/std/utilities/tuple/tuple.tuple/tuple.creation/make_tuple.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template<class... Types>
+// tuple<VTypes...> make_tuple(Types&&... t);
+
+// UNSUPPORTED: c++98, c++03
+
+#include <tuple>
+#include <functional>
+#include <cassert>
+
+int main()
+{
+ {
+ int i = 0;
+ float j = 0;
+ std::tuple<int, int&, float&> t = std::make_tuple(1, std::ref(i),
+ std::ref(j));
+ assert(std::get<0>(t) == 1);
+ assert(std::get<1>(t) == 0);
+ assert(std::get<2>(t) == 0);
+ i = 2;
+ j = 3.5;
+ assert(std::get<0>(t) == 1);
+ assert(std::get<1>(t) == 2);
+ assert(std::get<2>(t) == 3.5);
+ std::get<1>(t) = 0;
+ std::get<2>(t) = 0;
+ assert(i == 0);
+ assert(j == 0);
+ }
+#if _LIBCPP_STD_VER > 11
+ {
+ constexpr auto t1 = std::make_tuple(0, 1, 3.14);
+ constexpr int i1 = std::get<1>(t1);
+ constexpr double d1 = std::get<2>(t1);
+ static_assert (i1 == 1, "" );
+ static_assert (d1 == 3.14, "" );
+ }
+#endif
+}
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.creation/tie.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.creation/tie.pass.cpp
new file mode 100644
index 000000000000..52ecd249402f
--- /dev/null
+++ b/test/std/utilities/tuple/tuple.tuple/tuple.creation/tie.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template<class... Types>
+// tuple<Types&...> tie(Types&... t);
+
+// UNSUPPORTED: c++98, c++03
+
+#include <tuple>
+#include <string>
+#include <cassert>
+
+int main()
+{
+ {
+ int i = 0;
+ std::string s;
+ std::tie(i, std::ignore, s) = std::make_tuple(42, 3.14, "C++");
+ assert(i == 42);
+ assert(s == "C++");
+ }
+#if _LIBCPP_STD_VER > 11
+ {
+ static constexpr int i = 42;
+ static constexpr double f = 1.1;
+ constexpr std::tuple<const int &, const double &> t = std::tie(i, f);
+ static_assert ( std::get<0>(t) == 42, "" );
+ static_assert ( std::get<1>(t) == 1.1, "" );
+ }
+#endif
+}
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.creation/tuple_cat.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.creation/tuple_cat.pass.cpp
new file mode 100644
index 000000000000..770edcaca5e1
--- /dev/null
+++ b/test/std/utilities/tuple/tuple.tuple/tuple.creation/tuple_cat.pass.cpp
@@ -0,0 +1,241 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class... Tuples> tuple<CTypes...> tuple_cat(Tuples&&... tpls);
+
+// UNSUPPORTED: c++98, c++03
+
+#include <tuple>
+#include <utility>
+#include <array>
+#include <string>
+#include <cassert>
+
+#include "MoveOnly.h"
+
+int main()
+{
+ {
+ std::tuple<> t = std::tuple_cat();
+ ((void)t); // Prevent unused warning
+ }
+ {
+ std::tuple<> t1;
+ std::tuple<> t2 = std::tuple_cat(t1);
+ ((void)t2); // Prevent unused warning
+ }
+ {
+ std::tuple<> t = std::tuple_cat(std::tuple<>());
+ ((void)t); // Prevent unused warning
+ }
+ {
+ std::tuple<> t = std::tuple_cat(std::array<int, 0>());
+ ((void)t); // Prevent unused warning
+ }
+ {
+ std::tuple<int> t1(1);
+ std::tuple<int> t = std::tuple_cat(t1);
+ assert(std::get<0>(t) == 1);
+ }
+
+#if _LIBCPP_STD_VER > 11
+ {
+ constexpr std::tuple<> t = std::tuple_cat();
+ ((void)t); // Prevent unused warning
+ }
+ {
+ constexpr std::tuple<> t1;
+ constexpr std::tuple<> t2 = std::tuple_cat(t1);
+ ((void)t2); // Prevent unused warning
+ }
+ {
+ constexpr std::tuple<> t = std::tuple_cat(std::tuple<>());
+ ((void)t); // Prevent unused warning
+ }
+ {
+ constexpr std::tuple<> t = std::tuple_cat(std::array<int, 0>());
+ ((void)t); // Prevent unused warning
+ }
+ {
+ constexpr std::tuple<int> t1(1);
+ constexpr std::tuple<int> t = std::tuple_cat(t1);
+ static_assert(std::get<0>(t) == 1, "");
+ }
+ {
+ constexpr std::tuple<int> t1(1);
+ constexpr std::tuple<int, int> t = std::tuple_cat(t1, t1);
+ static_assert(std::get<0>(t) == 1, "");
+ static_assert(std::get<1>(t) == 1, "");
+ }
+#endif
+ {
+ std::tuple<int, MoveOnly> t =
+ std::tuple_cat(std::tuple<int, MoveOnly>(1, 2));
+ assert(std::get<0>(t) == 1);
+ assert(std::get<1>(t) == 2);
+ }
+ {
+ std::tuple<int, int, int> t = std::tuple_cat(std::array<int, 3>());
+ assert(std::get<0>(t) == 0);
+ assert(std::get<1>(t) == 0);
+ assert(std::get<2>(t) == 0);
+ }
+ {
+ std::tuple<int, MoveOnly> t = std::tuple_cat(std::pair<int, MoveOnly>(2, 1));
+ assert(std::get<0>(t) == 2);
+ assert(std::get<1>(t) == 1);
+ }
+
+ {
+ std::tuple<> t1;
+ std::tuple<> t2;
+ std::tuple<> t3 = std::tuple_cat(t1, t2);
+ ((void)t3); // Prevent unused warning
+ }
+ {
+ std::tuple<> t1;
+ std::tuple<int> t2(2);
+ std::tuple<int> t3 = std::tuple_cat(t1, t2);
+ assert(std::get<0>(t3) == 2);
+ }
+ {
+ std::tuple<> t1;
+ std::tuple<int> t2(2);
+ std::tuple<int> t3 = std::tuple_cat(t2, t1);
+ assert(std::get<0>(t3) == 2);
+ }
+ {
+ std::tuple<int*> t1;
+ std::tuple<int> t2(2);
+ std::tuple<int*, int> t3 = std::tuple_cat(t1, t2);
+ assert(std::get<0>(t3) == nullptr);
+ assert(std::get<1>(t3) == 2);
+ }
+ {
+ std::tuple<int*> t1;
+ std::tuple<int> t2(2);
+ std::tuple<int, int*> t3 = std::tuple_cat(t2, t1);
+ assert(std::get<0>(t3) == 2);
+ assert(std::get<1>(t3) == nullptr);
+ }
+ {
+ std::tuple<int*> t1;
+ std::tuple<int, double> t2(2, 3.5);
+ std::tuple<int*, int, double> t3 = std::tuple_cat(t1, t2);
+ assert(std::get<0>(t3) == nullptr);
+ assert(std::get<1>(t3) == 2);
+ assert(std::get<2>(t3) == 3.5);
+ }
+ {
+ std::tuple<int*> t1;
+ std::tuple<int, double> t2(2, 3.5);
+ std::tuple<int, double, int*> t3 = std::tuple_cat(t2, t1);
+ assert(std::get<0>(t3) == 2);
+ assert(std::get<1>(t3) == 3.5);
+ assert(std::get<2>(t3) == nullptr);
+ }
+ {
+ std::tuple<int*, MoveOnly> t1(nullptr, 1);
+ std::tuple<int, double> t2(2, 3.5);
+ std::tuple<int*, MoveOnly, int, double> t3 =
+ std::tuple_cat(std::move(t1), t2);
+ assert(std::get<0>(t3) == nullptr);
+ assert(std::get<1>(t3) == 1);
+ assert(std::get<2>(t3) == 2);
+ assert(std::get<3>(t3) == 3.5);
+ }
+ {
+ std::tuple<int*, MoveOnly> t1(nullptr, 1);
+ std::tuple<int, double> t2(2, 3.5);
+ std::tuple<int, double, int*, MoveOnly> t3 =
+ std::tuple_cat(t2, std::move(t1));
+ assert(std::get<0>(t3) == 2);
+ assert(std::get<1>(t3) == 3.5);
+ assert(std::get<2>(t3) == nullptr);
+ assert(std::get<3>(t3) == 1);
+ }
+ {
+ std::tuple<MoveOnly, MoveOnly> t1(1, 2);
+ std::tuple<int*, MoveOnly> t2(nullptr, 4);
+ std::tuple<MoveOnly, MoveOnly, int*, MoveOnly> t3 =
+ std::tuple_cat(std::move(t1), std::move(t2));
+ assert(std::get<0>(t3) == 1);
+ assert(std::get<1>(t3) == 2);
+ assert(std::get<2>(t3) == nullptr);
+ assert(std::get<3>(t3) == 4);
+ }
+
+ {
+ std::tuple<MoveOnly, MoveOnly> t1(1, 2);
+ std::tuple<int*, MoveOnly> t2(nullptr, 4);
+ std::tuple<MoveOnly, MoveOnly, int*, MoveOnly> t3 =
+ std::tuple_cat(std::tuple<>(),
+ std::move(t1),
+ std::move(t2));
+ assert(std::get<0>(t3) == 1);
+ assert(std::get<1>(t3) == 2);
+ assert(std::get<2>(t3) == nullptr);
+ assert(std::get<3>(t3) == 4);
+ }
+ {
+ std::tuple<MoveOnly, MoveOnly> t1(1, 2);
+ std::tuple<int*, MoveOnly> t2(nullptr, 4);
+ std::tuple<MoveOnly, MoveOnly, int*, MoveOnly> t3 =
+ std::tuple_cat(std::move(t1),
+ std::tuple<>(),
+ std::move(t2));
+ assert(std::get<0>(t3) == 1);
+ assert(std::get<1>(t3) == 2);
+ assert(std::get<2>(t3) == nullptr);
+ assert(std::get<3>(t3) == 4);
+ }
+ {
+ std::tuple<MoveOnly, MoveOnly> t1(1, 2);
+ std::tuple<int*, MoveOnly> t2(nullptr, 4);
+ std::tuple<MoveOnly, MoveOnly, int*, MoveOnly> t3 =
+ std::tuple_cat(std::move(t1),
+ std::move(t2),
+ std::tuple<>());
+ assert(std::get<0>(t3) == 1);
+ assert(std::get<1>(t3) == 2);
+ assert(std::get<2>(t3) == nullptr);
+ assert(std::get<3>(t3) == 4);
+ }
+ {
+ std::tuple<MoveOnly, MoveOnly> t1(1, 2);
+ std::tuple<int*, MoveOnly> t2(nullptr, 4);
+ std::tuple<MoveOnly, MoveOnly, int*, MoveOnly, int> t3 =
+ std::tuple_cat(std::move(t1),
+ std::move(t2),
+ std::tuple<int>(5));
+ assert(std::get<0>(t3) == 1);
+ assert(std::get<1>(t3) == 2);
+ assert(std::get<2>(t3) == nullptr);
+ assert(std::get<3>(t3) == 4);
+ assert(std::get<4>(t3) == 5);
+ }
+ {
+ // See bug #19616.
+ auto t1 = std::tuple_cat(
+ std::make_tuple(std::make_tuple(1)),
+ std::make_tuple()
+ );
+ assert(t1 == std::make_tuple(std::make_tuple(1)));
+
+ auto t2 = std::tuple_cat(
+ std::make_tuple(std::make_tuple(1)),
+ std::make_tuple(std::make_tuple(2))
+ );
+ assert(t2 == std::make_tuple(std::make_tuple(1), std::make_tuple(2)));
+ }
+}
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.elem/get_const.fail.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.elem/get_const.fail.cpp
new file mode 100644
index 000000000000..490283e7abdd
--- /dev/null
+++ b/test/std/utilities/tuple/tuple.tuple/tuple.elem/get_const.fail.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <size_t I, class... Types>
+// typename tuple_element<I, tuple<Types...> >::type const&
+// get(const tuple<Types...>& t);
+
+// UNSUPPORTED: c++98, c++03
+
+#include <tuple>
+#include <string>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::tuple<double&, std::string, int> T;
+ double d = 1.5;
+ const T t(d, "high", 5);
+ assert(std::get<0>(t) == 1.5);
+ assert(std::get<1>(t) == "high");
+ assert(std::get<2>(t) == 5);
+ std::get<0>(t) = 2.5;
+ assert(std::get<0>(t) == 2.5);
+ assert(std::get<1>(t) == "high");
+ assert(std::get<2>(t) == 5);
+ assert(d == 2.5);
+
+ std::get<1>(t) = "four";
+ }
+}
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.elem/get_const.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.elem/get_const.pass.cpp
new file mode 100644
index 000000000000..e21768cb6f5f
--- /dev/null
+++ b/test/std/utilities/tuple/tuple.tuple/tuple.elem/get_const.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <size_t I, class... Types>
+// typename tuple_element<I, tuple<Types...> >::type const&
+// get(const tuple<Types...>& t);
+
+// UNSUPPORTED: c++98, c++03
+
+#include <tuple>
+#include <string>
+#include <cassert>
+
+struct Empty {};
+
+int main()
+{
+ {
+ typedef std::tuple<int> T;
+ const T t(3);
+ assert(std::get<0>(t) == 3);
+ }
+ {
+ typedef std::tuple<std::string, int> T;
+ const T t("high", 5);
+ assert(std::get<0>(t) == "high");
+ assert(std::get<1>(t) == 5);
+ }
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::tuple<double, int> T;
+ constexpr T t(2.718, 5);
+ static_assert(std::get<0>(t) == 2.718, "");
+ static_assert(std::get<1>(t) == 5, "");
+ }
+ {
+ typedef std::tuple<Empty> T;
+ constexpr T t{Empty()};
+ constexpr Empty e = std::get<0>(t);
+ ((void)e); // Prevent unused warning
+ }
+#endif
+ {
+ typedef std::tuple<double&, std::string, int> T;
+ double d = 1.5;
+ const T t(d, "high", 5);
+ assert(std::get<0>(t) == 1.5);
+ assert(std::get<1>(t) == "high");
+ assert(std::get<2>(t) == 5);
+ std::get<0>(t) = 2.5;
+ assert(std::get<0>(t) == 2.5);
+ assert(std::get<1>(t) == "high");
+ assert(std::get<2>(t) == 5);
+ assert(d == 2.5);
+ }
+}
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.elem/get_non_const.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.elem/get_non_const.pass.cpp
new file mode 100644
index 000000000000..1c2b17ad8832
--- /dev/null
+++ b/test/std/utilities/tuple/tuple.tuple/tuple.elem/get_non_const.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <size_t I, class... Types>
+// typename tuple_element<I, tuple<Types...> >::type&
+// get(tuple<Types...>& t);
+
+// UNSUPPORTED: c++98, c++03
+
+#include <tuple>
+#include <string>
+#include <cassert>
+
+#if __cplusplus > 201103L
+
+struct Empty {};
+
+struct S {
+ std::tuple<int, Empty> a;
+ int k;
+ Empty e;
+ constexpr S() : a{1,Empty{}}, k(std::get<0>(a)), e(std::get<1>(a)) {}
+ };
+
+constexpr std::tuple<int, int> getP () { return { 3, 4 }; }
+#endif
+
+int main()
+{
+ {
+ typedef std::tuple<int> T;
+ T t(3);
+ assert(std::get<0>(t) == 3);
+ std::get<0>(t) = 2;
+ assert(std::get<0>(t) == 2);
+ }
+ {
+ typedef std::tuple<std::string, int> T;
+ T t("high", 5);
+ assert(std::get<0>(t) == "high");
+ assert(std::get<1>(t) == 5);
+ std::get<0>(t) = "four";
+ std::get<1>(t) = 4;
+ assert(std::get<0>(t) == "four");
+ assert(std::get<1>(t) == 4);
+ }
+ {
+ typedef std::tuple<double&, std::string, int> T;
+ double d = 1.5;
+ T t(d, "high", 5);
+ assert(std::get<0>(t) == 1.5);
+ assert(std::get<1>(t) == "high");
+ assert(std::get<2>(t) == 5);
+ std::get<0>(t) = 2.5;
+ std::get<1>(t) = "four";
+ std::get<2>(t) = 4;
+ assert(std::get<0>(t) == 2.5);
+ assert(std::get<1>(t) == "four");
+ assert(std::get<2>(t) == 4);
+ assert(d == 2.5);
+ }
+#if _LIBCPP_STD_VER > 11
+ { // get on an rvalue tuple
+ static_assert ( std::get<0> ( std::make_tuple ( 0.0f, 1, 2.0, 3L )) == 0, "" );
+ static_assert ( std::get<1> ( std::make_tuple ( 0.0f, 1, 2.0, 3L )) == 1, "" );
+ static_assert ( std::get<2> ( std::make_tuple ( 0.0f, 1, 2.0, 3L )) == 2, "" );
+ static_assert ( std::get<3> ( std::make_tuple ( 0.0f, 1, 2.0, 3L )) == 3, "" );
+ static_assert(S().k == 1, "");
+ static_assert(std::get<1>(getP()) == 4, "");
+ }
+#endif
+
+}
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.elem/get_rv.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.elem/get_rv.pass.cpp
new file mode 100644
index 000000000000..6c456d430826
--- /dev/null
+++ b/test/std/utilities/tuple/tuple.tuple/tuple.elem/get_rv.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <size_t I, class... Types>
+// typename tuple_element<I, tuple<Types...> >::type&&
+// get(tuple<Types...>&& t);
+
+// UNSUPPORTED: c++98, c++03
+
+#include <tuple>
+#include <utility>
+#include <memory>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::tuple<std::unique_ptr<int> > T;
+ T t(std::unique_ptr<int>(new int(3)));
+ std::unique_ptr<int> p = std::get<0>(std::move(t));
+ assert(*p == 3);
+ }
+}
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type.pass.cpp
new file mode 100644
index 000000000000..aa020dab47c7
--- /dev/null
+++ b/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11
+
+#include <tuple>
+#include <string>
+#include <complex>
+
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ typedef std::complex<float> cf;
+ {
+ auto t1 = std::tuple<int, std::string, cf> { 42, "Hi", { 1,2 }};
+ assert ( std::get<int>(t1) == 42 ); // find at the beginning
+ assert ( std::get<std::string>(t1) == "Hi" ); // find in the middle
+ assert ( std::get<cf>(t1).real() == 1 ); // find at the end
+ assert ( std::get<cf>(t1).imag() == 2 );
+ }
+
+ {
+ auto t2 = std::tuple<int, std::string, int, cf> { 42, "Hi", 23, { 1,2 }};
+// get<int> would fail!
+ assert ( std::get<std::string>(t2) == "Hi" );
+ assert (( std::get<cf>(t2) == cf{ 1,2 } ));
+ }
+
+ {
+ constexpr std::tuple<int, const int, double, double> p5 { 1, 2, 3.4, 5.6 };
+ static_assert ( std::get<int>(p5) == 1, "" );
+ static_assert ( std::get<const int>(p5) == 2, "" );
+ }
+
+ {
+ const std::tuple<int, const int, double, double> p5 { 1, 2, 3.4, 5.6 };
+ const int &i1 = std::get<int>(p5);
+ const int &i2 = std::get<const int>(p5);
+ assert ( i1 == 1 );
+ assert ( i2 == 2 );
+ }
+
+ {
+ typedef std::unique_ptr<int> upint;
+ std::tuple<upint> t(upint(new int(4)));
+ upint p = std::get<upint>(std::move(t)); // get rvalue
+ assert(*p == 4);
+ assert(std::get<0>(t) == nullptr); // has been moved from
+ }
+
+#endif
+}
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type1.fail.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type1.fail.cpp
new file mode 100644
index 000000000000..85c32ca6d495
--- /dev/null
+++ b/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type1.fail.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11
+
+#include <tuple>
+#include <string>
+#include <complex>
+
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ typedef std::complex<float> cf;
+ auto t1 = std::make_tuple<int, std::string> ( 42, "Hi" );
+ assert (( std::get<cf>(t1) == cf {1,2} )); // no such type
+#else
+#error
+#endif
+}
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type2.fail.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type2.fail.cpp
new file mode 100644
index 000000000000..0a8d5829d02b
--- /dev/null
+++ b/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type2.fail.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11
+
+#include <tuple>
+#include <string>
+#include <complex>
+
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ typedef std::complex<float> cf;
+ auto t1 = std::make_tuple<int, int, std::string, cf> ( 42, 21, "Hi", { 1,2 } );
+ assert ( std::get<int>(t1) == 42 ); // two ints here
+#else
+#error
+#endif
+}
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type3.fail.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type3.fail.cpp
new file mode 100644
index 000000000000..0a4550f387dc
--- /dev/null
+++ b/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type3.fail.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11
+
+#include <tuple>
+#include <string>
+#include <complex>
+
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ typedef std::complex<float> cf;
+ auto t1 = std::make_tuple<double, int, std::string, cf, int> ( 42, 21, "Hi", { 1,2 } );
+ assert ( std::get<int>(t1) == 42 ); // two ints here (one at the end)
+#else
+#error
+#endif
+}
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type4.fail.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type4.fail.cpp
new file mode 100644
index 000000000000..ffc715fe9a5b
--- /dev/null
+++ b/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type4.fail.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11
+
+#include <tuple>
+#include <string>
+#include <memory>
+
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ typedef std::unique_ptr<int> upint;
+ std::tuple<upint> t(upint(new int(4)));
+ upint p = std::get<upint>(t);
+#else
+#error
+#endif
+}
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple.include.array.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple.include.array.pass.cpp
new file mode 100644
index 000000000000..d8a72c617cb5
--- /dev/null
+++ b/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple.include.array.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <size_t I, class... Types>
+// class tuple_element<I, tuple<Types...> >
+// {
+// public:
+// typedef Ti type;
+// };
+//
+// LWG #2212 says that tuple_size and tuple_element must be
+// available after including <utility>
+
+#include <array>
+#include <type_traits>
+
+template <class T, std::size_t N, class U, size_t idx>
+void test()
+{
+ static_assert((std::is_base_of<std::integral_constant<std::size_t, N>,
+ std::tuple_size<T> >::value), "");
+ static_assert((std::is_base_of<std::integral_constant<std::size_t, N>,
+ std::tuple_size<const T> >::value), "");
+ static_assert((std::is_base_of<std::integral_constant<std::size_t, N>,
+ std::tuple_size<volatile T> >::value), "");
+ static_assert((std::is_base_of<std::integral_constant<std::size_t, N>,
+ std::tuple_size<const volatile T> >::value), "");
+ static_assert((std::is_same<typename std::tuple_element<idx, T>::type, U>::value), "");
+ static_assert((std::is_same<typename std::tuple_element<idx, const T>::type, const U>::value), "");
+ static_assert((std::is_same<typename std::tuple_element<idx, volatile T>::type, volatile U>::value), "");
+ static_assert((std::is_same<typename std::tuple_element<idx, const volatile T>::type, const volatile U>::value), "");
+}
+
+int main()
+{
+ test<std::array<int, 5>, 5, int, 0>();
+ test<std::array<int, 5>, 5, int, 1>();
+ test<std::array<const char *, 4>, 4, const char *, 3>();
+ test<std::array<volatile int, 4>, 4, volatile int, 3>();
+ test<std::array<char *, 3>, 3, char *, 1>();
+ test<std::array<char *, 3>, 3, char *, 2>();
+}
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple.include.utility.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple.include.utility.pass.cpp
new file mode 100644
index 000000000000..8c8357d95d99
--- /dev/null
+++ b/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple.include.utility.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class... Types>
+// class tuple_size<tuple<Types...>>
+// : public integral_constant<size_t, sizeof...(Types)> { };
+//
+// LWG #2212 says that tuple_size and tuple_element must be
+// available after including <utility>
+
+#include <utility>
+#include <type_traits>
+
+template <class T, std::size_t N, class U, size_t idx>
+void test()
+{
+ static_assert((std::is_base_of<std::integral_constant<std::size_t, N>,
+ std::tuple_size<T> >::value), "");
+ static_assert((std::is_base_of<std::integral_constant<std::size_t, N>,
+ std::tuple_size<const T> >::value), "");
+ static_assert((std::is_base_of<std::integral_constant<std::size_t, N>,
+ std::tuple_size<volatile T> >::value), "");
+ static_assert((std::is_base_of<std::integral_constant<std::size_t, N>,
+ std::tuple_size<const volatile T> >::value), "");
+ static_assert((std::is_same<typename std::tuple_element<idx, T>::type, U>::value), "");
+ static_assert((std::is_same<typename std::tuple_element<idx, const T>::type, const U>::value), "");
+ static_assert((std::is_same<typename std::tuple_element<idx, volatile T>::type, volatile U>::value), "");
+ static_assert((std::is_same<typename std::tuple_element<idx, const volatile T>::type, const volatile U>::value), "");
+}
+
+int main()
+{
+ test<std::pair<int, int>, 2, int, 0>();
+ test<std::pair<int, int>, 2, int, 1>();
+ test<std::pair<const int, int>, 2, int, 1>();
+ test<std::pair<int, volatile int>, 2, volatile int, 1>();
+ test<std::pair<char *, int>, 2, char *, 0>();
+ test<std::pair<char *, int>, 2, int, 1>();
+}
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_element.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_element.pass.cpp
new file mode 100644
index 000000000000..42e4fab88ffa
--- /dev/null
+++ b/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_element.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <size_t I, class... Types>
+// class tuple_element<I, tuple<Types...> >
+// {
+// public:
+// typedef Ti type;
+// };
+
+// UNSUPPORTED: c++98, c++03
+
+#include <tuple>
+#include <type_traits>
+
+template <class T, std::size_t N, class U>
+void test()
+{
+ static_assert((std::is_same<typename std::tuple_element<N, T>::type, U>::value), "");
+ static_assert((std::is_same<typename std::tuple_element<N, const T>::type, const U>::value), "");
+ static_assert((std::is_same<typename std::tuple_element<N, volatile T>::type, volatile U>::value), "");
+ static_assert((std::is_same<typename std::tuple_element<N, const volatile T>::type, const volatile U>::value), "");
+#if _LIBCPP_STD_VER > 11
+ static_assert((std::is_same<typename std::tuple_element_t<N, T>, U>::value), "");
+ static_assert((std::is_same<typename std::tuple_element_t<N, const T>, const U>::value), "");
+ static_assert((std::is_same<typename std::tuple_element_t<N, volatile T>, volatile U>::value), "");
+ static_assert((std::is_same<typename std::tuple_element_t<N, const volatile T>, const volatile U>::value), "");
+#endif
+}
+
+int main()
+{
+ test<std::tuple<int>, 0, int>();
+ test<std::tuple<char, int>, 0, char>();
+ test<std::tuple<char, int>, 1, int>();
+ test<std::tuple<int*, char, int>, 0, int*>();
+ test<std::tuple<int*, char, int>, 1, char>();
+ test<std::tuple<int*, char, int>, 2, int>();
+}
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size.pass.cpp
new file mode 100644
index 000000000000..49b4215a1956
--- /dev/null
+++ b/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class... Types>
+// class tuple_size<tuple<Types...>>
+// : public integral_constant<size_t, sizeof...(Types)> { };
+
+// UNSUPPORTED: c++98, c++03
+
+#include <tuple>
+#include <type_traits>
+
+template <class T, std::size_t N>
+void test()
+{
+ static_assert((std::is_base_of<std::integral_constant<std::size_t, N>,
+ std::tuple_size<T> >::value), "");
+ static_assert((std::is_base_of<std::integral_constant<std::size_t, N>,
+ std::tuple_size<const T> >::value), "");
+ static_assert((std::is_base_of<std::integral_constant<std::size_t, N>,
+ std::tuple_size<volatile T> >::value), "");
+ static_assert((std::is_base_of<std::integral_constant<std::size_t, N>,
+ std::tuple_size<const volatile T> >::value), "");
+}
+
+int main()
+{
+ test<std::tuple<>, 0>();
+ test<std::tuple<int>, 1>();
+ test<std::tuple<char, int>, 2>();
+ test<std::tuple<char, char*, int>, 3>();
+}
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.rel/eq.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.rel/eq.pass.cpp
new file mode 100644
index 000000000000..0d25edc4547b
--- /dev/null
+++ b/test/std/utilities/tuple/tuple.tuple/tuple.rel/eq.pass.cpp
@@ -0,0 +1,156 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template<class... TTypes, class... UTypes>
+// bool
+// operator==(const tuple<TTypes...>& t, const tuple<UTypes...>& u);
+
+// UNSUPPORTED: c++98, c++03
+
+#include <tuple>
+#include <string>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::tuple<> T1;
+ typedef std::tuple<> T2;
+ const T1 t1;
+ const T2 t2;
+ assert(t1 == t2);
+ assert(!(t1 != t2));
+ }
+ {
+ typedef std::tuple<int> T1;
+ typedef std::tuple<double> T2;
+ const T1 t1(1);
+ const T2 t2(1.1);
+ assert(!(t1 == t2));
+ assert(t1 != t2);
+ }
+ {
+ typedef std::tuple<int> T1;
+ typedef std::tuple<double> T2;
+ const T1 t1(1);
+ const T2 t2(1);
+ assert(t1 == t2);
+ assert(!(t1 != t2));
+ }
+ {
+ typedef std::tuple<int, double> T1;
+ typedef std::tuple<double, char> T2;
+ const T1 t1(1, 2);
+ const T2 t2(1, char(2));
+ assert(t1 == t2);
+ assert(!(t1 != t2));
+ }
+ {
+ typedef std::tuple<int, double> T1;
+ typedef std::tuple<double, char> T2;
+ const T1 t1(1, 2);
+ const T2 t2(1, char(3));
+ assert(!(t1 == t2));
+ assert(t1 != t2);
+ }
+ {
+ typedef std::tuple<int, double> T1;
+ typedef std::tuple<double, char> T2;
+ const T1 t1(1, 2);
+ const T2 t2(1.1, char(2));
+ assert(!(t1 == t2));
+ assert(t1 != t2);
+ }
+ {
+ typedef std::tuple<int, double> T1;
+ typedef std::tuple<double, char> T2;
+ const T1 t1(1, 2);
+ const T2 t2(1.1, char(3));
+ assert(!(t1 == t2));
+ assert(t1 != t2);
+ }
+ {
+ typedef std::tuple<char, int, double> T1;
+ typedef std::tuple<double, char, int> T2;
+ const T1 t1(1, 2, 3);
+ const T2 t2(1, 2, 3);
+ assert(t1 == t2);
+ assert(!(t1 != t2));
+ }
+ {
+ typedef std::tuple<char, int, double> T1;
+ typedef std::tuple<double, char, int> T2;
+ const T1 t1(1, 2, 3);
+ const T2 t2(1.1, 2, 3);
+ assert(!(t1 == t2));
+ assert(t1 != t2);
+ }
+ {
+ typedef std::tuple<char, int, double> T1;
+ typedef std::tuple<double, char, int> T2;
+ const T1 t1(1, 2, 3);
+ const T2 t2(1, 3, 3);
+ assert(!(t1 == t2));
+ assert(t1 != t2);
+ }
+ {
+ typedef std::tuple<char, int, double> T1;
+ typedef std::tuple<double, char, int> T2;
+ const T1 t1(1, 2, 3);
+ const T2 t2(1, 2, 4);
+ assert(!(t1 == t2));
+ assert(t1 != t2);
+ }
+ {
+ typedef std::tuple<char, int, double> T1;
+ typedef std::tuple<double, char, int> T2;
+ const T1 t1(1, 2, 3);
+ const T2 t2(1, 3, 2);
+ assert(!(t1 == t2));
+ assert(t1 != t2);
+ }
+ {
+ typedef std::tuple<char, int, double> T1;
+ typedef std::tuple<double, char, int> T2;
+ const T1 t1(1, 2, 3);
+ const T2 t2(1.1, 2, 2);
+ assert(!(t1 == t2));
+ assert(t1 != t2);
+ }
+ {
+ typedef std::tuple<char, int, double> T1;
+ typedef std::tuple<double, char, int> T2;
+ const T1 t1(1, 2, 3);
+ const T2 t2(1.1, 3, 3);
+ assert(!(t1 == t2));
+ assert(t1 != t2);
+ }
+ {
+ typedef std::tuple<char, int, double> T1;
+ typedef std::tuple<double, char, int> T2;
+ const T1 t1(1, 2, 3);
+ const T2 t2(1.1, 3, 2);
+ assert(!(t1 == t2));
+ assert(t1 != t2);
+ }
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::tuple<char, int, double> T1;
+ typedef std::tuple<double, char, int> T2;
+ constexpr T1 t1(1, 2, 3);
+ constexpr T2 t2(1.1, 3, 2);
+ static_assert(!(t1 == t2), "");
+ static_assert(t1 != t2, "");
+ }
+#endif
+}
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.rel/lt.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.rel/lt.pass.cpp
new file mode 100644
index 000000000000..eac84a9c35f6
--- /dev/null
+++ b/test/std/utilities/tuple/tuple.tuple/tuple.rel/lt.pass.cpp
@@ -0,0 +1,210 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template<class... TTypes, class... UTypes>
+// bool
+// operator<(const tuple<TTypes...>& t, const tuple<UTypes...>& u);
+//
+// template<class... TTypes, class... UTypes>
+// bool
+// operator>(const tuple<TTypes...>& t, const tuple<UTypes...>& u);
+//
+// template<class... TTypes, class... UTypes>
+// bool
+// operator<=(const tuple<TTypes...>& t, const tuple<UTypes...>& u);
+//
+// template<class... TTypes, class... UTypes>
+// bool
+// operator>=(const tuple<TTypes...>& t, const tuple<UTypes...>& u);
+
+// UNSUPPORTED: c++98, c++03
+
+#include <tuple>
+#include <string>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::tuple<> T1;
+ typedef std::tuple<> T2;
+ const T1 t1;
+ const T2 t2;
+ assert(!(t1 < t2));
+ assert( (t1 <= t2));
+ assert(!(t1 > t2));
+ assert( (t1 >= t2));
+ }
+ {
+ typedef std::tuple<char> T1;
+ typedef std::tuple<double> T2;
+ const T1 t1(1);
+ const T2 t2(1);
+ assert(!(t1 < t2));
+ assert( (t1 <= t2));
+ assert(!(t1 > t2));
+ assert( (t1 >= t2));
+ }
+ {
+ typedef std::tuple<char> T1;
+ typedef std::tuple<double> T2;
+ const T1 t1(1);
+ const T2 t2(0.9);
+ assert(!(t1 < t2));
+ assert(!(t1 <= t2));
+ assert( (t1 > t2));
+ assert( (t1 >= t2));
+ }
+ {
+ typedef std::tuple<char> T1;
+ typedef std::tuple<double> T2;
+ const T1 t1(1);
+ const T2 t2(1.1);
+ assert( (t1 < t2));
+ assert( (t1 <= t2));
+ assert(!(t1 > t2));
+ assert(!(t1 >= t2));
+ }
+ {
+ typedef std::tuple<char, int> T1;
+ typedef std::tuple<double, char> T2;
+ const T1 t1(1, 2);
+ const T2 t2(1, 2);
+ assert(!(t1 < t2));
+ assert( (t1 <= t2));
+ assert(!(t1 > t2));
+ assert( (t1 >= t2));
+ }
+ {
+ typedef std::tuple<char, int> T1;
+ typedef std::tuple<double, char> T2;
+ const T1 t1(1, 2);
+ const T2 t2(0.9, 2);
+ assert(!(t1 < t2));
+ assert(!(t1 <= t2));
+ assert( (t1 > t2));
+ assert( (t1 >= t2));
+ }
+ {
+ typedef std::tuple<char, int> T1;
+ typedef std::tuple<double, char> T2;
+ const T1 t1(1, 2);
+ const T2 t2(1.1, 2);
+ assert( (t1 < t2));
+ assert( (t1 <= t2));
+ assert(!(t1 > t2));
+ assert(!(t1 >= t2));
+ }
+ {
+ typedef std::tuple<char, int> T1;
+ typedef std::tuple<double, char> T2;
+ const T1 t1(1, 2);
+ const T2 t2(1, 1);
+ assert(!(t1 < t2));
+ assert(!(t1 <= t2));
+ assert( (t1 > t2));
+ assert( (t1 >= t2));
+ }
+ {
+ typedef std::tuple<char, int> T1;
+ typedef std::tuple<double, char> T2;
+ const T1 t1(1, 2);
+ const T2 t2(1, 3);
+ assert( (t1 < t2));
+ assert( (t1 <= t2));
+ assert(!(t1 > t2));
+ assert(!(t1 >= t2));
+ }
+ {
+ typedef std::tuple<char, int, double> T1;
+ typedef std::tuple<double, char, int> T2;
+ const T1 t1(1, 2, 3);
+ const T2 t2(1, 2, 3);
+ assert(!(t1 < t2));
+ assert( (t1 <= t2));
+ assert(!(t1 > t2));
+ assert( (t1 >= t2));
+ }
+ {
+ typedef std::tuple<char, int, double> T1;
+ typedef std::tuple<double, char, int> T2;
+ const T1 t1(1, 2, 3);
+ const T2 t2(0.9, 2, 3);
+ assert(!(t1 < t2));
+ assert(!(t1 <= t2));
+ assert( (t1 > t2));
+ assert( (t1 >= t2));
+ }
+ {
+ typedef std::tuple<char, int, double> T1;
+ typedef std::tuple<double, char, int> T2;
+ const T1 t1(1, 2, 3);
+ const T2 t2(1.1, 2, 3);
+ assert( (t1 < t2));
+ assert( (t1 <= t2));
+ assert(!(t1 > t2));
+ assert(!(t1 >= t2));
+ }
+ {
+ typedef std::tuple<char, int, double> T1;
+ typedef std::tuple<double, char, int> T2;
+ const T1 t1(1, 2, 3);
+ const T2 t2(1, 1, 3);
+ assert(!(t1 < t2));
+ assert(!(t1 <= t2));
+ assert( (t1 > t2));
+ assert( (t1 >= t2));
+ }
+ {
+ typedef std::tuple<char, int, double> T1;
+ typedef std::tuple<double, char, int> T2;
+ const T1 t1(1, 2, 3);
+ const T2 t2(1, 3, 3);
+ assert( (t1 < t2));
+ assert( (t1 <= t2));
+ assert(!(t1 > t2));
+ assert(!(t1 >= t2));
+ }
+ {
+ typedef std::tuple<char, int, double> T1;
+ typedef std::tuple<double, char, int> T2;
+ const T1 t1(1, 2, 3);
+ const T2 t2(1, 2, 2);
+ assert(!(t1 < t2));
+ assert(!(t1 <= t2));
+ assert( (t1 > t2));
+ assert( (t1 >= t2));
+ }
+ {
+ typedef std::tuple<char, int, double> T1;
+ typedef std::tuple<double, char, int> T2;
+ const T1 t1(1, 2, 3);
+ const T2 t2(1, 2, 4);
+ assert( (t1 < t2));
+ assert( (t1 <= t2));
+ assert(!(t1 > t2));
+ assert(!(t1 >= t2));
+ }
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::tuple<char, int, double> T1;
+ typedef std::tuple<double, char, int> T2;
+ constexpr T1 t1(1, 2, 3);
+ constexpr T2 t2(1, 2, 4);
+ static_assert( (t1 < t2), "");
+ static_assert( (t1 <= t2), "");
+ static_assert(!(t1 > t2), "");
+ static_assert(!(t1 >= t2), "");
+ }
+#endif
+}
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.special/non_member_swap.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.special/non_member_swap.pass.cpp
new file mode 100644
index 000000000000..dcae606129fa
--- /dev/null
+++ b/test/std/utilities/tuple/tuple.tuple/tuple.special/non_member_swap.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class... Types>
+// void swap(tuple<Types...>& x, tuple<Types...>& y);
+
+// UNSUPPORTED: c++98, c++03
+
+#include <tuple>
+#include <cassert>
+
+#include "MoveOnly.h"
+
+int main()
+{
+ {
+ typedef std::tuple<> T;
+ T t0;
+ T t1;
+ swap(t0, t1);
+ }
+ {
+ typedef std::tuple<MoveOnly> T;
+ T t0(MoveOnly(0));
+ T t1(MoveOnly(1));
+ swap(t0, t1);
+ assert(std::get<0>(t0) == 1);
+ assert(std::get<0>(t1) == 0);
+ }
+ {
+ typedef std::tuple<MoveOnly, MoveOnly> T;
+ T t0(MoveOnly(0), MoveOnly(1));
+ T t1(MoveOnly(2), MoveOnly(3));
+ swap(t0, t1);
+ assert(std::get<0>(t0) == 2);
+ assert(std::get<1>(t0) == 3);
+ assert(std::get<0>(t1) == 0);
+ assert(std::get<1>(t1) == 1);
+ }
+ {
+ typedef std::tuple<MoveOnly, MoveOnly, MoveOnly> T;
+ T t0(MoveOnly(0), MoveOnly(1), MoveOnly(2));
+ T t1(MoveOnly(3), MoveOnly(4), MoveOnly(5));
+ swap(t0, t1);
+ assert(std::get<0>(t0) == 3);
+ assert(std::get<1>(t0) == 4);
+ assert(std::get<2>(t0) == 5);
+ assert(std::get<0>(t1) == 0);
+ assert(std::get<1>(t1) == 1);
+ assert(std::get<2>(t1) == 2);
+ }
+}
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.swap/member_swap.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.swap/member_swap.pass.cpp
new file mode 100644
index 000000000000..6749f592aa30
--- /dev/null
+++ b/test/std/utilities/tuple/tuple.tuple/tuple.swap/member_swap.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// void swap(tuple& rhs);
+
+// UNSUPPORTED: c++98, c++03
+
+#include <tuple>
+#include <cassert>
+
+#include "MoveOnly.h"
+
+int main()
+{
+ {
+ typedef std::tuple<> T;
+ T t0;
+ T t1;
+ t0.swap(t1);
+ }
+ {
+ typedef std::tuple<MoveOnly> T;
+ T t0(MoveOnly(0));
+ T t1(MoveOnly(1));
+ t0.swap(t1);
+ assert(std::get<0>(t0) == 1);
+ assert(std::get<0>(t1) == 0);
+ }
+ {
+ typedef std::tuple<MoveOnly, MoveOnly> T;
+ T t0(MoveOnly(0), MoveOnly(1));
+ T t1(MoveOnly(2), MoveOnly(3));
+ t0.swap(t1);
+ assert(std::get<0>(t0) == 2);
+ assert(std::get<1>(t0) == 3);
+ assert(std::get<0>(t1) == 0);
+ assert(std::get<1>(t1) == 1);
+ }
+ {
+ typedef std::tuple<MoveOnly, MoveOnly, MoveOnly> T;
+ T t0(MoveOnly(0), MoveOnly(1), MoveOnly(2));
+ T t1(MoveOnly(3), MoveOnly(4), MoveOnly(5));
+ t0.swap(t1);
+ assert(std::get<0>(t0) == 3);
+ assert(std::get<1>(t0) == 4);
+ assert(std::get<2>(t0) == 5);
+ assert(std::get<0>(t1) == 0);
+ assert(std::get<1>(t1) == 1);
+ assert(std::get<2>(t1) == 2);
+ }
+}
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.traits/uses_allocator.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.traits/uses_allocator.pass.cpp
new file mode 100644
index 000000000000..ddaf52fead31
--- /dev/null
+++ b/test/std/utilities/tuple/tuple.tuple/tuple.traits/uses_allocator.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class... Types, class Alloc>
+// struct uses_allocator<tuple<Types...>, Alloc> : true_type { };
+
+// UNSUPPORTED: c++98, c++03
+
+#include <tuple>
+#include <type_traits>
+
+struct A {};
+
+int main()
+{
+ {
+ typedef std::tuple<> T;
+ static_assert((std::is_base_of<std::true_type,
+ std::uses_allocator<T, A>>::value), "");
+ }
+ {
+ typedef std::tuple<int> T;
+ static_assert((std::is_base_of<std::true_type,
+ std::uses_allocator<T, A>>::value), "");
+ }
+ {
+ typedef std::tuple<char, int> T;
+ static_assert((std::is_base_of<std::true_type,
+ std::uses_allocator<T, A>>::value), "");
+ }
+ {
+ typedef std::tuple<double&, char, int> T;
+ static_assert((std::is_base_of<std::true_type,
+ std::uses_allocator<T, A>>::value), "");
+ }
+}
diff --git a/test/std/utilities/tuple/version.pass.cpp b/test/std/utilities/tuple/version.pass.cpp
new file mode 100644
index 000000000000..2fdbb5d2784a
--- /dev/null
+++ b/test/std/utilities/tuple/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+#include <tuple>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/utilities/type.index/type.index.hash/hash.pass.cpp b/test/std/utilities/type.index/type.index.hash/hash.pass.cpp
new file mode 100644
index 000000000000..c5ffacfa37e9
--- /dev/null
+++ b/test/std/utilities/type.index/type.index.hash/hash.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <typeindex>
+
+// class type_index
+
+// template <>
+// struct hash<type_index>
+// : public unary_function<type_index, size_t>
+// {
+// size_t operator()(type_index index) const;
+// };
+
+#include <typeindex>
+#include <cassert>
+
+int main()
+{
+ typedef std::hash<std::type_index> H;
+ static_assert((std::is_same<typename H::argument_type, std::type_index>::value), "" );
+ static_assert((std::is_same<typename H::result_type, std::size_t>::value), "" );
+
+ std::type_index t1 = typeid(int);
+ assert(std::hash<std::type_index>()(t1) == t1.hash_code());
+}
diff --git a/test/std/utilities/type.index/type.index.members/ctor.pass.cpp b/test/std/utilities/type.index/type.index.members/ctor.pass.cpp
new file mode 100644
index 000000000000..e5183eb87a77
--- /dev/null
+++ b/test/std/utilities/type.index/type.index.members/ctor.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <typeindex>
+
+// class type_index
+
+// type_index(const type_info& rhs);
+
+#include <typeinfo>
+#include <typeindex>
+#include <cassert>
+
+int main()
+{
+ std::type_info const & info = typeid(int);
+ std::type_index t1(info);
+ assert(t1.name() == info.name());
+}
diff --git a/test/std/utilities/type.index/type.index.members/eq.pass.cpp b/test/std/utilities/type.index/type.index.members/eq.pass.cpp
new file mode 100644
index 000000000000..b6bbd1d23723
--- /dev/null
+++ b/test/std/utilities/type.index/type.index.members/eq.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <typeindex>
+
+// class type_index
+
+// bool operator==(const type_index& rhs) const;
+// bool operator!=(const type_index& rhs) const;
+
+#include <typeindex>
+#include <cassert>
+
+int main()
+{
+ std::type_index t1 = typeid(int);
+ std::type_index t2 = typeid(int);
+ std::type_index t3 = typeid(long);
+ assert(t1 == t2);
+ assert(t1 != t3);
+}
diff --git a/test/std/utilities/type.index/type.index.members/hash_code.pass.cpp b/test/std/utilities/type.index/type.index.members/hash_code.pass.cpp
new file mode 100644
index 000000000000..b4f316830065
--- /dev/null
+++ b/test/std/utilities/type.index/type.index.members/hash_code.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <typeindex>
+
+// class type_index
+
+// size_t hash_code() const;
+
+#include <typeindex>
+#include <cassert>
+
+int main()
+{
+ const std::type_info& ti = typeid(int);
+ std::type_index t1 = typeid(int);
+ assert(t1.hash_code() == ti.hash_code());
+}
diff --git a/test/std/utilities/type.index/type.index.members/lt.pass.cpp b/test/std/utilities/type.index/type.index.members/lt.pass.cpp
new file mode 100644
index 000000000000..c099d1c56378
--- /dev/null
+++ b/test/std/utilities/type.index/type.index.members/lt.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <typeindex>
+
+// class type_index
+
+// bool operator< (const type_index& rhs) const;
+// bool operator<=(const type_index& rhs) const;
+// bool operator> (const type_index& rhs) const;
+// bool operator>=(const type_index& rhs) const;
+
+#include <typeindex>
+#include <cassert>
+
+int main()
+{
+ std::type_index t1 = typeid(int);
+ std::type_index t2 = typeid(int);
+ std::type_index t3 = typeid(long);
+ assert(!(t1 < t2));
+ assert( (t1 <= t2));
+ assert(!(t1 > t2));
+ assert( (t1 >= t2));
+ if (t1 < t3)
+ {
+ assert( (t1 < t3));
+ assert( (t1 <= t3));
+ assert(!(t1 > t3));
+ assert(!(t1 >= t3));
+ }
+ else
+ {
+ assert(!(t1 < t3));
+ assert(!(t1 <= t3));
+ assert( (t1 > t3));
+ assert( (t1 >= t3));
+ }
+}
diff --git a/test/std/utilities/type.index/type.index.members/name.pass.cpp b/test/std/utilities/type.index/type.index.members/name.pass.cpp
new file mode 100644
index 000000000000..44ee2151915b
--- /dev/null
+++ b/test/std/utilities/type.index/type.index.members/name.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <typeindex>
+
+// class type_index
+
+// const char* name() const;
+
+#include <typeindex>
+#include <string>
+#include <cassert>
+
+int main()
+{
+ const std::type_info& ti = typeid(int);
+ std::type_index t1 = typeid(int);
+ assert(std::string(t1.name()) == ti.name());
+}
diff --git a/test/std/utilities/type.index/type.index.overview/copy_assign.pass.cpp b/test/std/utilities/type.index/type.index.overview/copy_assign.pass.cpp
new file mode 100644
index 000000000000..234e26b495f9
--- /dev/null
+++ b/test/std/utilities/type.index/type.index.overview/copy_assign.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <typeindex>
+
+// class type_index
+
+// type_index& operator=(const type_index& ti);
+
+#include <typeindex>
+#include <cassert>
+
+int main()
+{
+ std::type_index t1(typeid(int));
+ std::type_index t2(typeid(double));
+ assert(t2 != t1);
+ t2 = t1;
+ assert(t2 == t1);
+}
diff --git a/test/std/utilities/type.index/type.index.overview/copy_ctor.pass.cpp b/test/std/utilities/type.index/type.index.overview/copy_ctor.pass.cpp
new file mode 100644
index 000000000000..499c4b63b06f
--- /dev/null
+++ b/test/std/utilities/type.index/type.index.overview/copy_ctor.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <typeindex>
+
+// class type_index
+
+// type_index(const type_index& ti);
+
+#include <typeindex>
+#include <cassert>
+
+int main()
+{
+ std::type_index t1(typeid(int));
+ std::type_index t2 = t1;
+ assert(t2 == t1);
+}
diff --git a/test/std/utilities/type.index/type.index.synopsis/hash_type_index.pass.cpp b/test/std/utilities/type.index/type.index.synopsis/hash_type_index.pass.cpp
new file mode 100644
index 000000000000..6d353f1d3057
--- /dev/null
+++ b/test/std/utilities/type.index/type.index.synopsis/hash_type_index.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <typeindex>
+
+// struct hash<type_index>
+// : public unary_function<type_index, size_t>
+// {
+// size_t operator()(type_index index) const;
+// };
+
+#include <typeindex>
+#include <type_traits>
+
+int main()
+{
+ typedef std::hash<std::type_index> H;
+ static_assert((std::is_same<typename H::argument_type, std::type_index>::value), "" );
+ static_assert((std::is_same<typename H::result_type, std::size_t>::value), "" );
+}
diff --git a/test/std/utilities/type.index/version.pass.cpp b/test/std/utilities/type.index/version.pass.cpp
new file mode 100644
index 000000000000..26f462042fd3
--- /dev/null
+++ b/test/std/utilities/type.index/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <typeindex>
+
+#include <typeindex>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/std/utilities/utilities.general/nothing_to_do.pass.cpp b/test/std/utilities/utilities.general/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/utilities/utilities.general/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/utilities/utility.requirements/allocator.requirements/nothing_to_do.pass.cpp b/test/std/utilities/utility.requirements/allocator.requirements/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/utilities/utility.requirements/allocator.requirements/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/utilities/utility.requirements/hash.requirements/nothing_to_do.pass.cpp b/test/std/utilities/utility.requirements/hash.requirements/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/utilities/utility.requirements/hash.requirements/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/utilities/utility.requirements/nothing_to_do.pass.cpp b/test/std/utilities/utility.requirements/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/utilities/utility.requirements/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/utilities/utility.requirements/nullablepointer.requirements/nothing_to_do.pass.cpp b/test/std/utilities/utility.requirements/nullablepointer.requirements/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/utilities/utility.requirements/nullablepointer.requirements/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/utilities/utility.requirements/swappable.requirements/nothing_to_do.pass.cpp b/test/std/utilities/utility.requirements/swappable.requirements/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/utilities/utility.requirements/swappable.requirements/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/utilities/utility.requirements/utility.arg.requirements/nothing_to_do.pass.cpp b/test/std/utilities/utility.requirements/utility.arg.requirements/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/utilities/utility.requirements/utility.arg.requirements/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/utilities/utility/declval/declval.pass.cpp b/test/std/utilities/utility/declval/declval.pass.cpp
new file mode 100644
index 000000000000..81f4df8e8b2b
--- /dev/null
+++ b/test/std/utilities/utility/declval/declval.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template <class T> typename add_rvalue_reference<T>::type declval() noexcept;
+
+#include <utility>
+#include <type_traits>
+
+class A
+{
+ A(const A&);
+ A& operator=(const A&);
+};
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ static_assert((std::is_same<decltype(std::declval<A>()), A&&>::value), "");
+#else
+ static_assert((std::is_same<decltype(std::declval<A>()), A>::value), "");
+#endif
+}
diff --git a/test/std/utilities/utility/exchange/exchange.pass.cpp b/test/std/utilities/utility/exchange/exchange.pass.cpp
new file mode 100644
index 000000000000..620b4149d1d0
--- /dev/null
+++ b/test/std/utilities/utility/exchange/exchange.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// utilities
+
+// exchange
+
+#include <utility>
+#include <cassert>
+#include <string>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ {
+ int v = 12;
+ assert ( std::exchange ( v, 23 ) == 12 );
+ assert ( v == 23 );
+ assert ( std::exchange ( v, 67.2 ) == 23 );
+ assert ( v == 67 );
+
+ assert ((std::exchange<int, float> ( v, {} )) == 67 );
+ assert ( v == 0 );
+
+ }
+
+ {
+ bool b = false;
+ assert ( !std::exchange ( b, true ));
+ assert ( b );
+ }
+
+ {
+ const std::string s1 ( "Hi Mom!" );
+ const std::string s2 ( "Yo Dad!" );
+ std::string s3 = s1; // Mom
+ assert ( std::exchange ( s3, s2 ) == s1 );
+ assert ( s3 == s2 );
+ assert ( std::exchange ( s3, "Hi Mom!" ) == s2 );
+ assert ( s3 == s1 );
+
+ s3 = s2; // Dad
+ assert ( std::exchange ( s3, {} ) == s2 );
+ assert ( s3.size () == 0 );
+
+ s3 = s2; // Dad
+ assert ( std::exchange ( s3, "" ) == s2 );
+ assert ( s3.size () == 0 );
+ }
+
+#endif
+}
diff --git a/test/std/utilities/utility/forward/forward.pass.cpp b/test/std/utilities/utility/forward/forward.pass.cpp
new file mode 100644
index 000000000000..357b36fafa96
--- /dev/null
+++ b/test/std/utilities/utility/forward/forward.pass.cpp
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test forward
+
+#include <utility>
+#include <cassert>
+
+struct A
+{
+};
+
+A source() {return A();}
+const A csource() {return A();}
+
+typedef char one;
+struct two {one _[2];};
+struct four {one _[4];};
+struct eight {one _[8];};
+
+one test(A&);
+two test(const A&);
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+four test(A&&);
+eight test(const A&&);
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+ A a;
+ const A ca = A();
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ static_assert(sizeof(test(std::forward<A&>(a))) == 1, "");
+ static_assert(sizeof(test(std::forward<A>(a))) == 4, "");
+ static_assert(sizeof(test(std::forward<A>(source()))) == 4, "");
+
+ static_assert(sizeof(test(std::forward<const A&>(a))) == 2, "");
+// static_assert(sizeof(test(std::forward<const A&>(source()))) == 2, "");
+ static_assert(sizeof(test(std::forward<const A>(a))) == 8, "");
+ static_assert(sizeof(test(std::forward<const A>(source()))) == 8, "");
+
+ static_assert(sizeof(test(std::forward<const A&>(ca))) == 2, "");
+// static_assert(sizeof(test(std::forward<const A&>(csource()))) == 2, "");
+ static_assert(sizeof(test(std::forward<const A>(ca))) == 8, "");
+ static_assert(sizeof(test(std::forward<const A>(csource()))) == 8, "");
+
+#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+ static_assert(sizeof(test(std::forward<A&>(a))) == 1, "");
+ static_assert(sizeof(test(std::forward<A>(a))) == 1, "");
+// static_assert(sizeof(test(std::forward<A>(source()))) == 2, "");
+
+ static_assert(sizeof(test(std::forward<const A&>(a))) == 2, "");
+ static_assert(sizeof(test(std::forward<const A&>(source()))) == 2, "");
+ static_assert(sizeof(test(std::forward<const A>(a))) == 2, "");
+ static_assert(sizeof(test(std::forward<const A>(source()))) == 2, "");
+
+ static_assert(sizeof(test(std::forward<const A&>(ca))) == 2, "");
+ static_assert(sizeof(test(std::forward<const A&>(csource()))) == 2, "");
+ static_assert(sizeof(test(std::forward<const A>(ca))) == 2, "");
+ static_assert(sizeof(test(std::forward<const A>(csource()))) == 2, "");
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+#if _LIBCPP_STD_VER > 11
+ constexpr int i1 = std::move(23);
+ static_assert(i1 == 23, "" );
+ constexpr int i2 = std::forward<int>(42);
+ static_assert(i2 == 42, "" );
+#endif
+}
diff --git a/test/std/utilities/utility/forward/forward1.fail.cpp b/test/std/utilities/utility/forward/forward1.fail.cpp
new file mode 100644
index 000000000000..43884d54bf86
--- /dev/null
+++ b/test/std/utilities/utility/forward/forward1.fail.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test forward
+
+#include <utility>
+
+struct A
+{
+};
+
+A source() {return A();}
+const A csource() {return A();}
+
+int main()
+{
+ std::forward<A&>(source()); // error
+}
diff --git a/test/std/utilities/utility/forward/forward2.fail.cpp b/test/std/utilities/utility/forward/forward2.fail.cpp
new file mode 100644
index 000000000000..9ff07233fee8
--- /dev/null
+++ b/test/std/utilities/utility/forward/forward2.fail.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test forward
+
+#include <utility>
+
+struct A
+{
+};
+
+A source() {return A();}
+const A csource() {return A();}
+
+int main()
+{
+ const A ca = A();
+ std::forward<A&>(ca); // error
+}
diff --git a/test/std/utilities/utility/forward/forward3.fail.cpp b/test/std/utilities/utility/forward/forward3.fail.cpp
new file mode 100644
index 000000000000..7e1e9b38fdc2
--- /dev/null
+++ b/test/std/utilities/utility/forward/forward3.fail.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test forward
+
+#include <utility>
+
+struct A
+{
+};
+
+A source() {return A();}
+const A csource() {return A();}
+
+int main()
+{
+ std::forward<A&>(csource()); // error
+}
diff --git a/test/std/utilities/utility/forward/forward4.fail.cpp b/test/std/utilities/utility/forward/forward4.fail.cpp
new file mode 100644
index 000000000000..276506f811b5
--- /dev/null
+++ b/test/std/utilities/utility/forward/forward4.fail.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test forward
+
+#include <utility>
+
+struct A
+{
+};
+
+A source() {return A();}
+const A csource() {return A();}
+
+int main()
+{
+ const A ca = A();
+ std::forward<A>(ca); // error
+}
diff --git a/test/std/utilities/utility/forward/forward5.fail.cpp b/test/std/utilities/utility/forward/forward5.fail.cpp
new file mode 100644
index 000000000000..86c2b5651b90
--- /dev/null
+++ b/test/std/utilities/utility/forward/forward5.fail.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test forward
+
+#include <utility>
+
+struct A
+{
+};
+
+A source() {return A();}
+const A csource() {return A();}
+
+int main()
+{
+ const A ca = A();
+ std::forward<A>(csource()); // error
+}
diff --git a/test/std/utilities/utility/forward/forward6.fail.cpp b/test/std/utilities/utility/forward/forward6.fail.cpp
new file mode 100644
index 000000000000..1f4b37d946ca
--- /dev/null
+++ b/test/std/utilities/utility/forward/forward6.fail.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test forward
+
+#include <utility>
+
+struct A
+{
+};
+
+int main()
+{
+ A a;
+ std::forward(a); // error
+}
diff --git a/test/std/utilities/utility/forward/move_copy.pass.cpp b/test/std/utilities/utility/forward/move_copy.pass.cpp
new file mode 100644
index 000000000000..fa15553f669f
--- /dev/null
+++ b/test/std/utilities/utility/forward/move_copy.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test move
+
+// UNSUPPORTED: c++98, c++03
+
+#include <utility>
+#include <cassert>
+
+int copy_ctor = 0;
+int move_ctor = 0;
+
+class A
+{
+public:
+
+ A(const A&) {++copy_ctor;}
+ A& operator=(const A&);
+
+ A(A&&) {++move_ctor;}
+ A& operator=(A&&);
+
+ A() {}
+};
+
+A source() {return A();}
+const A csource() {return A();}
+
+void test(A) {}
+
+int main()
+{
+ A a;
+ const A ca = A();
+
+ assert(copy_ctor == 0);
+ assert(move_ctor == 0);
+
+ A a2 = a;
+ assert(copy_ctor == 1);
+ assert(move_ctor == 0);
+
+ A a3 = std::move(a);
+ assert(copy_ctor == 1);
+ assert(move_ctor == 1);
+
+ A a4 = ca;
+ assert(copy_ctor == 2);
+ assert(move_ctor == 1);
+
+ A a5 = std::move(ca);
+ assert(copy_ctor == 3);
+ assert(move_ctor == 1);
+}
diff --git a/test/std/utilities/utility/forward/move_if_noexcept.pass.cpp b/test/std/utilities/utility/forward/move_if_noexcept.pass.cpp
new file mode 100644
index 000000000000..c8375e9d7238
--- /dev/null
+++ b/test/std/utilities/utility/forward/move_if_noexcept.pass.cpp
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template <class T>
+// typename conditional
+// <
+// !is_nothrow_move_constructible<T>::value && is_copy_constructible<T>::value,
+// const T&,
+// T&&
+// >::type
+// move_if_noexcept(T& x);
+
+#include <utility>
+
+#include "test_macros.h"
+
+class A
+{
+ A(const A&);
+ A& operator=(const A&);
+public:
+
+ A() {}
+#if TEST_STD_VER >= 11
+ A(A&&) {}
+#endif
+};
+
+struct legacy
+{
+ legacy() {}
+ legacy(const legacy&);
+};
+
+int main()
+{
+ int i = 0;
+ const int ci = 0;
+
+ legacy l;
+ A a;
+ const A ca;
+
+#if TEST_STD_VER >= 11
+ static_assert((std::is_same<decltype(std::move_if_noexcept(i)), int&&>::value), "");
+ static_assert((std::is_same<decltype(std::move_if_noexcept(ci)), const int&&>::value), "");
+ static_assert((std::is_same<decltype(std::move_if_noexcept(a)), A&&>::value), "");
+ static_assert((std::is_same<decltype(std::move_if_noexcept(ca)), const A&&>::value), "");
+ static_assert((std::is_same<decltype(std::move_if_noexcept(l)), const legacy&>::value), "");
+#else // C++ < 11
+ // libc++ defines decltype to be __typeof__ in C++03. __typeof__ does not
+ // deduce the reference qualifiers.
+ static_assert((std::is_same<decltype(std::move_if_noexcept(i)), const int>::value), "");
+ static_assert((std::is_same<decltype(std::move_if_noexcept(ci)), const int>::value), "");
+ static_assert((std::is_same<decltype(std::move_if_noexcept(a)), const A>::value), "");
+ static_assert((std::is_same<decltype(std::move_if_noexcept(ca)), const A>::value), "");
+ static_assert((std::is_same<decltype(std::move_if_noexcept(l)), const legacy>::value), "");
+#endif
+
+#if TEST_STD_VER > 11
+ constexpr int i1 = 23;
+ constexpr int i2 = std::move_if_noexcept(i1);
+ static_assert(i2 == 23, "" );
+#endif
+
+}
diff --git a/test/std/utilities/utility/forward/move_only.pass.cpp b/test/std/utilities/utility/forward/move_only.pass.cpp
new file mode 100644
index 000000000000..520bf5e5b6a1
--- /dev/null
+++ b/test/std/utilities/utility/forward/move_only.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test move
+
+// UNSUPPORTED: c++98, c++03
+
+#include <utility>
+#include <cassert>
+
+class move_only
+{
+ move_only(const move_only&);
+ move_only& operator=(const move_only&);
+public:
+ move_only(move_only&&) {}
+ move_only& operator=(move_only&&) {return *this;}
+
+ move_only() {}
+};
+
+move_only source() {return move_only();}
+const move_only csource() {return move_only();}
+
+void test(move_only) {}
+
+int main()
+{
+ move_only mo;
+
+ test(std::move(mo));
+ test(source());
+}
diff --git a/test/std/utilities/utility/forward/move_only1.fail.cpp b/test/std/utilities/utility/forward/move_only1.fail.cpp
new file mode 100644
index 000000000000..5e7623a1bd19
--- /dev/null
+++ b/test/std/utilities/utility/forward/move_only1.fail.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test move
+
+#include <utility>
+#include <cassert>
+
+#include <typeinfo>
+#include <stdio.h>
+
+class move_only
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ move_only(const move_only&);
+ move_only& operator=(const move_only&);
+#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ move_only(move_only&);
+ move_only& operator=(move_only&);
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+public:
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ move_only(move_only&&) {}
+ move_only& operator=(move_only&&) {}
+#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ operator std::__rv<move_only> () {return std::__rv<move_only>(*this);}
+ move_only(std::__rv<move_only>) {}
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+ move_only() {}
+};
+
+move_only source() {return move_only();}
+const move_only csource() {return move_only();}
+
+void test(move_only) {}
+
+int main()
+{
+ move_only a;
+ const move_only ca = move_only();
+
+ test(a);
+}
diff --git a/test/std/utilities/utility/forward/move_only2.fail.cpp b/test/std/utilities/utility/forward/move_only2.fail.cpp
new file mode 100644
index 000000000000..2043f3d4bde7
--- /dev/null
+++ b/test/std/utilities/utility/forward/move_only2.fail.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test move
+
+#include <utility>
+#include <cassert>
+
+#include <typeinfo>
+#include <stdio.h>
+
+class move_only
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ move_only(const move_only&);
+ move_only& operator=(const move_only&);
+#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ move_only(move_only&);
+ move_only& operator=(move_only&);
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+public:
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ move_only(move_only&&) {}
+ move_only& operator=(move_only&&) {}
+#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ operator std::__rv<move_only> () {return std::__rv<move_only>(*this);}
+ move_only(std::__rv<move_only>) {}
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+ move_only() {}
+};
+
+move_only source() {return move_only();}
+const move_only csource() {return move_only();}
+
+void test(move_only) {}
+
+int main()
+{
+ move_only a;
+ const move_only ca = move_only();
+
+ test(ca);
+}
diff --git a/test/std/utilities/utility/forward/move_only3.fail.cpp b/test/std/utilities/utility/forward/move_only3.fail.cpp
new file mode 100644
index 000000000000..84c83ae48f8a
--- /dev/null
+++ b/test/std/utilities/utility/forward/move_only3.fail.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test move
+
+#include <utility>
+#include <cassert>
+
+class move_only
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ move_only(const move_only&);
+ move_only& operator=(const move_only&);
+#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ move_only(move_only&);
+ move_only& operator=(move_only&);
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+public:
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ move_only(move_only&&) {}
+ move_only& operator=(move_only&&) {}
+#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ operator std::__rv<move_only> () {return std::__rv<move_only>(*this);}
+ move_only(std::__rv<move_only>) {}
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+ move_only() {}
+};
+
+move_only source() {return move_only();}
+const move_only csource() {return move_only();}
+
+void test(move_only) {}
+
+int main()
+{
+ move_only a;
+ const move_only ca = move_only();
+
+ test(std::move(ca));
+}
diff --git a/test/std/utilities/utility/forward/move_only4.fail.cpp b/test/std/utilities/utility/forward/move_only4.fail.cpp
new file mode 100644
index 000000000000..5eeca89abe36
--- /dev/null
+++ b/test/std/utilities/utility/forward/move_only4.fail.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test move
+
+#include <utility>
+#include <cassert>
+
+#include <typeinfo>
+#include <stdio.h>
+
+class move_only
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ move_only(const move_only&);
+ move_only& operator=(const move_only&);
+#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ move_only(move_only&);
+ move_only& operator=(move_only&);
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+public:
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ move_only(move_only&&) {}
+ move_only& operator=(move_only&&) {}
+#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ operator std::__rv<move_only> () {return std::__rv<move_only>(*this);}
+ move_only(std::__rv<move_only>) {}
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+ move_only() {}
+};
+
+move_only source() {return move_only();}
+const move_only csource() {return move_only();}
+
+void test(move_only) {}
+
+int main()
+{
+ move_only a;
+ const move_only ca = move_only();
+
+ test(csource());
+}
diff --git a/test/std/utilities/utility/operators/rel_ops.pass.cpp b/test/std/utilities/utility/operators/rel_ops.pass.cpp
new file mode 100644
index 000000000000..26e766592f2b
--- /dev/null
+++ b/test/std/utilities/utility/operators/rel_ops.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test rel_ops
+
+#include <utility>
+#include <cassert>
+
+struct A
+{
+ int data_;
+
+ explicit A(int data = -1) : data_(data) {}
+};
+
+inline
+bool
+operator == (const A& x, const A& y)
+{
+ return x.data_ == y.data_;
+}
+
+inline
+bool
+operator < (const A& x, const A& y)
+{
+ return x.data_ < y.data_;
+}
+
+int main()
+{
+ using namespace std::rel_ops;
+ A a1(1);
+ A a2(2);
+ assert(a1 == a1);
+ assert(a1 != a2);
+ assert(a1 < a2);
+ assert(a2 > a1);
+ assert(a1 <= a1);
+ assert(a1 <= a2);
+ assert(a2 >= a2);
+ assert(a2 >= a1);
+}
diff --git a/test/std/utilities/utility/pairs/nothing_to_do.pass.cpp b/test/std/utilities/utility/pairs/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/utilities/utility/pairs/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/utilities/utility/pairs/pair.astuple/get_const.fail.cpp b/test/std/utilities/utility/pairs/pair.astuple/get_const.fail.cpp
new file mode 100644
index 000000000000..dbe1c2668665
--- /dev/null
+++ b/test/std/utilities/utility/pairs/pair.astuple/get_const.fail.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template <class T1, class T2> struct pair
+
+// template<size_t I, class T1, class T2>
+// const typename tuple_element<I, std::pair<T1, T2> >::type&
+// get(const pair<T1, T2>&);
+
+#include <utility>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::pair<int, short> P;
+ const P p(3, 4);
+ assert(std::get<0>(p) == 3);
+ assert(std::get<1>(p) == 4);
+ std::get<0>(p) = 5;
+ }
+}
diff --git a/test/std/utilities/utility/pairs/pair.astuple/get_const.pass.cpp b/test/std/utilities/utility/pairs/pair.astuple/get_const.pass.cpp
new file mode 100644
index 000000000000..fcda3664d9b6
--- /dev/null
+++ b/test/std/utilities/utility/pairs/pair.astuple/get_const.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template <class T1, class T2> struct pair
+
+// template<size_t I, class T1, class T2>
+// const typename tuple_element<I, std::pair<T1, T2> >::type&
+// get(const pair<T1, T2>&);
+
+#include <utility>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::pair<int, short> P;
+ const P p(3, 4);
+ assert(std::get<0>(p) == 3);
+ assert(std::get<1>(p) == 4);
+ }
+
+#if __cplusplus > 201103L
+ {
+ typedef std::pair<int, short> P;
+ constexpr P p1(3, 4);
+ static_assert(std::get<0>(p1) == 3, "");
+ static_assert(std::get<1>(p1) == 4, "");
+ }
+#endif
+}
diff --git a/test/std/utilities/utility/pairs/pair.astuple/get_non_const.pass.cpp b/test/std/utilities/utility/pairs/pair.astuple/get_non_const.pass.cpp
new file mode 100644
index 000000000000..6d61c47ffbf0
--- /dev/null
+++ b/test/std/utilities/utility/pairs/pair.astuple/get_non_const.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template <class T1, class T2> struct pair
+
+// template<size_t I, class T1, class T2>
+// typename tuple_element<I, std::pair<T1, T2> >::type&
+// get(pair<T1, T2>&);
+
+#include <utility>
+#include <cassert>
+
+#if __cplusplus > 201103L
+struct S {
+ std::pair<int, int> a;
+ int k;
+ constexpr S() : a{1,2}, k(std::get<0>(a)) {}
+ };
+
+constexpr std::pair<int, int> getP () { return { 3, 4 }; }
+#endif
+
+int main()
+{
+ {
+ typedef std::pair<int, short> P;
+ P p(3, 4);
+ assert(std::get<0>(p) == 3);
+ assert(std::get<1>(p) == 4);
+ std::get<0>(p) = 5;
+ std::get<1>(p) = 6;
+ assert(std::get<0>(p) == 5);
+ assert(std::get<1>(p) == 6);
+ }
+
+#if __cplusplus > 201103L
+ {
+ static_assert(S().k == 1, "");
+ static_assert(std::get<1>(getP()) == 4, "");
+ }
+#endif
+
+}
diff --git a/test/std/utilities/utility/pairs/pair.astuple/get_rv.pass.cpp b/test/std/utilities/utility/pairs/pair.astuple/get_rv.pass.cpp
new file mode 100644
index 000000000000..aa5ca530913c
--- /dev/null
+++ b/test/std/utilities/utility/pairs/pair.astuple/get_rv.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template <class T1, class T2> struct pair
+
+// template<size_t I, class T1, class T2>
+// typename tuple_element<I, std::pair<T1, T2> >::type&&
+// get(pair<T1, T2>&&);
+
+#include <utility>
+#include <memory>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::pair<std::unique_ptr<int>, short> P;
+ P p(std::unique_ptr<int>(new int(3)), 4);
+ std::unique_ptr<int> ptr = std::get<0>(std::move(p));
+ assert(*ptr == 3);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/utilities/utility/pairs/pair.astuple/pairs.by.type.pass.cpp b/test/std/utilities/utility/pairs/pair.astuple/pairs.by.type.pass.cpp
new file mode 100644
index 000000000000..176d58330d16
--- /dev/null
+++ b/test/std/utilities/utility/pairs/pair.astuple/pairs.by.type.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <utility>
+#include <string>
+#include <complex>
+
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ typedef std::complex<float> cf;
+ {
+ auto t1 = std::make_pair<int, cf> ( 42, { 1,2 } );
+ assert ( std::get<int>(t1) == 42 );
+ assert ( std::get<cf>(t1).real() == 1 );
+ assert ( std::get<cf>(t1).imag() == 2 );
+ }
+
+ {
+ const std::pair<int, const int> p1 { 1, 2 };
+ const int &i1 = std::get<int>(p1);
+ const int &i2 = std::get<const int>(p1);
+ assert ( i1 == 1 );
+ assert ( i2 == 2 );
+ }
+
+ {
+ typedef std::unique_ptr<int> upint;
+ std::pair<upint, int> t(upint(new int(4)), 42);
+ upint p = std::get<0>(std::move(t)); // get rvalue
+ assert(*p == 4);
+ assert(std::get<0>(t) == nullptr); // has been moved from
+ }
+
+#endif
+}
diff --git a/test/std/utilities/utility/pairs/pair.astuple/pairs.by.type1.fail.cpp b/test/std/utilities/utility/pairs/pair.astuple/pairs.by.type1.fail.cpp
new file mode 100644
index 000000000000..27194effe5c3
--- /dev/null
+++ b/test/std/utilities/utility/pairs/pair.astuple/pairs.by.type1.fail.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <utility>
+#include <complex>
+
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ typedef std::complex<float> cf;
+ auto t1 = std::make_pair<int, double> ( 42, 3.4 );
+ assert (( std::get<cf>(t1) == cf {1,2} )); // no such type
+#else
+#error
+#endif
+}
diff --git a/test/std/utilities/utility/pairs/pair.astuple/pairs.by.type2.fail.cpp b/test/std/utilities/utility/pairs/pair.astuple/pairs.by.type2.fail.cpp
new file mode 100644
index 000000000000..f9e3942d7e77
--- /dev/null
+++ b/test/std/utilities/utility/pairs/pair.astuple/pairs.by.type2.fail.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <utility>
+#include <complex>
+
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ typedef std::complex<float> cf;
+ auto t1 = std::make_pair<int, int> ( 42, 43 );
+ assert ( std::get<int>(t1) == 42 ); // two ints
+#else
+#error
+#endif
+}
diff --git a/test/std/utilities/utility/pairs/pair.astuple/pairs.by.type3.fail.cpp b/test/std/utilities/utility/pairs/pair.astuple/pairs.by.type3.fail.cpp
new file mode 100644
index 000000000000..484347345747
--- /dev/null
+++ b/test/std/utilities/utility/pairs/pair.astuple/pairs.by.type3.fail.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <utility>
+#include <complex>
+
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ typedef std::unique_ptr<int> upint;
+ std::pair<upint, int> t(upint(new int(4)), 23);
+ upint p = std::get<upint>(t);
+#else
+#error
+#endif
+}
diff --git a/test/std/utilities/utility/pairs/pair.astuple/tuple_element.pass.cpp b/test/std/utilities/utility/pairs/pair.astuple/tuple_element.pass.cpp
new file mode 100644
index 000000000000..5ac838b37429
--- /dev/null
+++ b/test/std/utilities/utility/pairs/pair.astuple/tuple_element.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template <class T1, class T2> struct pair
+
+// tuple_element<I, pair<T1, T2> >::type
+
+#include <utility>
+
+template <class T1, class T2>
+void test()
+{
+ {
+ typedef T1 Exp1;
+ typedef T2 Exp2;
+ typedef std::pair<T1, T2> P;
+ static_assert((std::is_same<typename std::tuple_element<0, P>::type, Exp1>::value), "");
+ static_assert((std::is_same<typename std::tuple_element<1, P>::type, Exp2>::value), "");
+ }
+ {
+ typedef T1 const Exp1;
+ typedef T2 const Exp2;
+ typedef std::pair<T1, T2> const P;
+ static_assert((std::is_same<typename std::tuple_element<0, P>::type, Exp1>::value), "");
+ static_assert((std::is_same<typename std::tuple_element<1, P>::type, Exp2>::value), "");
+ }
+ {
+ typedef T1 volatile Exp1;
+ typedef T2 volatile Exp2;
+ typedef std::pair<T1, T2> volatile P;
+ static_assert((std::is_same<typename std::tuple_element<0, P>::type, Exp1>::value), "");
+ static_assert((std::is_same<typename std::tuple_element<1, P>::type, Exp2>::value), "");
+ }
+ {
+ typedef T1 const volatile Exp1;
+ typedef T2 const volatile Exp2;
+ typedef std::pair<T1, T2> const volatile P;
+ static_assert((std::is_same<typename std::tuple_element<0, P>::type, Exp1>::value), "");
+ static_assert((std::is_same<typename std::tuple_element<1, P>::type, Exp2>::value), "");
+ }
+}
+
+int main()
+{
+ test<int, short>();
+ test<int*, char>();
+}
diff --git a/test/std/utilities/utility/pairs/pair.astuple/tuple_size.pass.cpp b/test/std/utilities/utility/pairs/pair.astuple/tuple_size.pass.cpp
new file mode 100644
index 000000000000..3756e963fa35
--- /dev/null
+++ b/test/std/utilities/utility/pairs/pair.astuple/tuple_size.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template <class T1, class T2> struct pair
+
+// tuple_size<pair<T1, T2> >::value
+
+#include <utility>
+
+int main()
+{
+ {
+ typedef std::pair<int, short> P1;
+ static_assert((std::tuple_size<P1>::value == 2), "");
+ }
+ {
+ typedef std::pair<int, short> const P1;
+ static_assert((std::tuple_size<P1>::value == 2), "");
+ }
+ {
+ typedef std::pair<int, short> volatile P1;
+ static_assert((std::tuple_size<P1>::value == 2), "");
+ }
+ {
+ typedef std::pair<int, short> const volatile P1;
+ static_assert((std::tuple_size<P1>::value == 2), "");
+ }
+}
diff --git a/test/std/utilities/utility/pairs/pair.piecewise/piecewise_construct.pass.cpp b/test/std/utilities/utility/pairs/pair.piecewise/piecewise_construct.pass.cpp
new file mode 100644
index 000000000000..90476bcde28c
--- /dev/null
+++ b/test/std/utilities/utility/pairs/pair.piecewise/piecewise_construct.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template <class T1, class T2> struct pair
+
+// struct piecewise_construct_t { };
+// constexpr piecewise_construct_t piecewise_construct = piecewise_construct_t();
+
+#include <utility>
+#include <tuple>
+#include <cassert>
+
+class A
+{
+ int i_;
+ char c_;
+public:
+ A(int i, char c) : i_(i), c_(c) {}
+ int get_i() const {return i_;}
+ char get_c() const {return c_;}
+};
+
+class B
+{
+ double d_;
+ unsigned u1_;
+ unsigned u2_;
+public:
+ B(double d, unsigned u1, unsigned u2) : d_(d), u1_(u1), u2_(u2) {}
+ double get_d() const {return d_;}
+ unsigned get_u1() const {return u1_;}
+ unsigned get_u2() const {return u2_;}
+};
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+ std::pair<A, B> p(std::piecewise_construct,
+ std::make_tuple(4, 'a'),
+ std::make_tuple(3.5, 6u, 2u));
+ assert(p.first.get_i() == 4);
+ assert(p.first.get_c() == 'a');
+ assert(p.second.get_d() == 3.5);
+ assert(p.second.get_u1() == 6u);
+ assert(p.second.get_u2() == 2u);
+#endif
+}
diff --git a/test/std/utilities/utility/pairs/pairs.general/nothing_to_do.pass.cpp b/test/std/utilities/utility/pairs/pairs.general/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..b58f5c55b643
--- /dev/null
+++ b/test/std/utilities/utility/pairs/pairs.general/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/utilities/utility/pairs/pairs.pair/U_V.pass.cpp b/test/std/utilities/utility/pairs/pairs.pair/U_V.pass.cpp
new file mode 100644
index 000000000000..8c7dee2499dd
--- /dev/null
+++ b/test/std/utilities/utility/pairs/pairs.pair/U_V.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template <class T1, class T2> struct pair
+
+// template<class U, class V> pair(U&& x, V&& y);
+
+#include <utility>
+#include <memory>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::pair<std::unique_ptr<int>, short*> P;
+ P p(std::unique_ptr<int>(new int(3)), nullptr);
+ assert(*p.first == 3);
+ assert(p.second == nullptr);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/utilities/utility/pairs/pairs.pair/assign_const_pair_U_V.pass.cpp b/test/std/utilities/utility/pairs/pairs.pair/assign_const_pair_U_V.pass.cpp
new file mode 100644
index 000000000000..fdef5961437a
--- /dev/null
+++ b/test/std/utilities/utility/pairs/pairs.pair/assign_const_pair_U_V.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template <class T1, class T2> struct pair
+
+// template<class U, class V> pair& operator=(const pair<U, V>& p);
+
+#include <utility>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::pair<int, short> P1;
+ typedef std::pair<double, long> P2;
+ P1 p1(3, 4);
+ P2 p2;
+ p2 = p1;
+ assert(p2.first == 3);
+ assert(p2.second == 4);
+ }
+}
diff --git a/test/std/utilities/utility/pairs/pairs.pair/assign_rv_pair.pass.cpp b/test/std/utilities/utility/pairs/pairs.pair/assign_rv_pair.pass.cpp
new file mode 100644
index 000000000000..a753ee520dfa
--- /dev/null
+++ b/test/std/utilities/utility/pairs/pairs.pair/assign_rv_pair.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template <class T1, class T2> struct pair
+
+// pair& operator=(pair&& p);
+
+#include <utility>
+#include <memory>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::pair<std::unique_ptr<int>, short> P;
+ P p1(std::unique_ptr<int>(new int(3)), 4);
+ P p2;
+ p2 = std::move(p1);
+ assert(*p2.first == 3);
+ assert(p2.second == 4);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/utilities/utility/pairs/pairs.pair/assign_rv_pair_U_V.pass.cpp b/test/std/utilities/utility/pairs/pairs.pair/assign_rv_pair_U_V.pass.cpp
new file mode 100644
index 000000000000..a200390f4882
--- /dev/null
+++ b/test/std/utilities/utility/pairs/pairs.pair/assign_rv_pair_U_V.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template <class T1, class T2> struct pair
+
+// template<class U, class V> pair& operator=(pair<U, V>&& p);
+
+#include <utility>
+#include <memory>
+#include <cassert>
+
+struct Base
+{
+ virtual ~Base() {}
+};
+
+struct Derived
+ : public Base
+{
+};
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::pair<std::unique_ptr<Derived>, short> P1;
+ typedef std::pair<std::unique_ptr<Base>, long> P2;
+ P1 p1(std::unique_ptr<Derived>(), 4);
+ P2 p2;
+ p2 = std::move(p1);
+ assert(p2.first == nullptr);
+ assert(p2.second == 4);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/utilities/utility/pairs/pairs.pair/const_first_const_second.pass.cpp b/test/std/utilities/utility/pairs/pairs.pair/const_first_const_second.pass.cpp
new file mode 100644
index 000000000000..2041b39c2dc9
--- /dev/null
+++ b/test/std/utilities/utility/pairs/pairs.pair/const_first_const_second.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template <class T1, class T2> struct pair
+
+// pair(const T1& x, const T2& y);
+
+#include <utility>
+#include <cassert>
+
+class A
+{
+ int data_;
+public:
+ A(int data) : data_(data) {}
+
+ bool operator==(const A& a) const {return data_ == a.data_;}
+};
+
+#if _LIBCPP_STD_VER > 11
+class AC
+{
+ int data_;
+public:
+ constexpr AC(int data) : data_(data) {}
+
+ constexpr bool operator==(const AC& a) const {return data_ == a.data_;}
+};
+#endif
+
+int main()
+{
+ {
+ typedef std::pair<float, short*> P;
+ P p(3.5f, 0);
+ assert(p.first == 3.5f);
+ assert(p.second == nullptr);
+ }
+ {
+ typedef std::pair<A, int> P;
+ P p(1, 2);
+ assert(p.first == A(1));
+ assert(p.second == 2);
+ }
+
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::pair<float, short*> P;
+ constexpr P p(3.5f, 0);
+ static_assert(p.first == 3.5f, "");
+ static_assert(p.second == nullptr, "");
+ }
+ {
+ typedef std::pair<AC, int> P;
+ constexpr P p(1, 2);
+ static_assert(p.first == AC(1), "");
+ static_assert(p.second == 2, "");
+ }
+#endif
+}
diff --git a/test/std/utilities/utility/pairs/pairs.pair/const_pair_U_V.pass.cpp b/test/std/utilities/utility/pairs/pairs.pair/const_pair_U_V.pass.cpp
new file mode 100644
index 000000000000..286cce47f050
--- /dev/null
+++ b/test/std/utilities/utility/pairs/pairs.pair/const_pair_U_V.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template <class T1, class T2> struct pair
+
+// template <class U, class V> pair(const pair<U, V>& p);
+
+#include <utility>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::pair<int, short> P1;
+ typedef std::pair<double, long> P2;
+ P1 p1(3, 4);
+ P2 p2 = p1;
+ assert(p2.first == 3);
+ assert(p2.second == 4);
+ }
+
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::pair<int, short> P1;
+ typedef std::pair<double, long> P2;
+ constexpr P1 p1(3, 4);
+ constexpr P2 p2 = p1;
+ static_assert(p2.first == 3, "");
+ static_assert(p2.second == 4, "");
+ }
+#endif
+}
diff --git a/test/std/utilities/utility/pairs/pairs.pair/copy_ctor.pass.cpp b/test/std/utilities/utility/pairs/pairs.pair/copy_ctor.pass.cpp
new file mode 100644
index 000000000000..4b54f717045a
--- /dev/null
+++ b/test/std/utilities/utility/pairs/pairs.pair/copy_ctor.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template <class T1, class T2> struct pair
+
+// pair(const pair&) = default;
+
+#include <utility>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::pair<int, short> P1;
+ P1 p1(3, 4);
+ P1 p2 = p1;
+ assert(p2.first == 3);
+ assert(p2.second == 4);
+ }
+
+ static_assert((std::is_trivially_copy_constructible<std::pair<int, int> >::value), "");
+
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::pair<int, short> P1;
+ constexpr P1 p1(3, 4);
+ constexpr P1 p2 = p1;
+ static_assert(p2.first == 3, "");
+ static_assert(p2.second == 4, "");
+ }
+#endif
+}
diff --git a/test/std/utilities/utility/pairs/pairs.pair/default.pass.cpp b/test/std/utilities/utility/pairs/pairs.pair/default.pass.cpp
new file mode 100644
index 000000000000..bb6661f7966c
--- /dev/null
+++ b/test/std/utilities/utility/pairs/pairs.pair/default.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template <class T1, class T2> struct pair
+
+// constexpr pair();
+
+#include <utility>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::pair<float, short*> P;
+ P p;
+ assert(p.first == 0.0f);
+ assert(p.second == nullptr);
+ }
+
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::pair<float, short*> P;
+ constexpr P p;
+ static_assert(p.first == 0.0f, "");
+ static_assert(p.second == nullptr, "");
+ }
+#endif
+}
diff --git a/test/std/utilities/utility/pairs/pairs.pair/piecewise.pass.cpp b/test/std/utilities/utility/pairs/pairs.pair/piecewise.pass.cpp
new file mode 100644
index 000000000000..42a2666dd04b
--- /dev/null
+++ b/test/std/utilities/utility/pairs/pairs.pair/piecewise.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template <class T1, class T2> struct pair
+
+// template <class... Args1, class... Args2>
+// pair(piecewise_construct_t, tuple<Args1...> first_args,
+// tuple<Args2...> second_args);
+
+#include <utility>
+#include <tuple>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+ {
+ typedef std::pair<int, int*> P1;
+ typedef std::pair<int*, int> P2;
+ typedef std::pair<P1, P2> P3;
+ P3 p3(std::piecewise_construct, std::tuple<int, int*>(3, nullptr),
+ std::tuple<int*, int>(nullptr, 4));
+ assert(p3.first == P1(3, nullptr));
+ assert(p3.second == P2(nullptr, 4));
+ }
+#endif // _LIBCPP_HAS_NO_VARIADICS
+}
diff --git a/test/std/utilities/utility/pairs/pairs.pair/rv_pair_U_V.pass.cpp b/test/std/utilities/utility/pairs/pairs.pair/rv_pair_U_V.pass.cpp
new file mode 100644
index 000000000000..5fb6c98979b5
--- /dev/null
+++ b/test/std/utilities/utility/pairs/pairs.pair/rv_pair_U_V.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template <class T1, class T2> struct pair
+
+// template <class U, class V> pair(pair<U, V>&& p);
+
+#include <utility>
+#include <memory>
+#include <cassert>
+
+struct Base
+{
+ virtual ~Base() {}
+};
+
+struct Derived
+ : public Base
+{
+};
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::pair<std::unique_ptr<Derived>, short> P1;
+ typedef std::pair<std::unique_ptr<Base>, long> P2;
+ P1 p1(std::unique_ptr<Derived>(), 4);
+ P2 p2 = std::move(p1);
+ assert(p2.first == nullptr);
+ assert(p2.second == 4);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/utilities/utility/pairs/pairs.pair/swap.pass.cpp b/test/std/utilities/utility/pairs/pairs.pair/swap.pass.cpp
new file mode 100644
index 000000000000..a912df00d7bb
--- /dev/null
+++ b/test/std/utilities/utility/pairs/pairs.pair/swap.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template <class T1, class T2> struct pair
+
+// void swap(pair& p);
+
+#include <utility>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::pair<int, short> P1;
+ P1 p1(3, 4);
+ P1 p2(5, 6);
+ p1.swap(p2);
+ assert(p1.first == 5);
+ assert(p1.second == 6);
+ assert(p2.first == 3);
+ assert(p2.second == 4);
+ }
+}
diff --git a/test/std/utilities/utility/pairs/pairs.pair/types.pass.cpp b/test/std/utilities/utility/pairs/pairs.pair/types.pass.cpp
new file mode 100644
index 000000000000..c16bd71ffcb2
--- /dev/null
+++ b/test/std/utilities/utility/pairs/pairs.pair/types.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template <class T1, class T2>
+// struct pair
+// {
+// typedef T1 first_type;
+// typedef T2 second_type;
+
+#include <utility>
+#include <type_traits>
+
+int main()
+{
+ typedef std::pair<float, short*> P;
+ static_assert((std::is_same<P::first_type, float>::value), "");
+ static_assert((std::is_same<P::second_type, short*>::value), "");
+}
diff --git a/test/std/utilities/utility/pairs/pairs.spec/comparison.pass.cpp b/test/std/utilities/utility/pairs/pairs.spec/comparison.pass.cpp
new file mode 100644
index 000000000000..9ba8532ab29e
--- /dev/null
+++ b/test/std/utilities/utility/pairs/pairs.spec/comparison.pass.cpp
@@ -0,0 +1,95 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template <class T1, class T2> struct pair
+
+// template <class T1, class T2> bool operator==(const pair<T1,T2>&, const pair<T1,T2>&);
+// template <class T1, class T2> bool operator!=(const pair<T1,T2>&, const pair<T1,T2>&);
+// template <class T1, class T2> bool operator< (const pair<T1,T2>&, const pair<T1,T2>&);
+// template <class T1, class T2> bool operator> (const pair<T1,T2>&, const pair<T1,T2>&);
+// template <class T1, class T2> bool operator>=(const pair<T1,T2>&, const pair<T1,T2>&);
+// template <class T1, class T2> bool operator<=(const pair<T1,T2>&, const pair<T1,T2>&);
+
+#include <utility>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::pair<int, short> P;
+ P p1(3, 4);
+ P p2(3, 4);
+ assert( (p1 == p2));
+ assert(!(p1 != p2));
+ assert(!(p1 < p2));
+ assert( (p1 <= p2));
+ assert(!(p1 > p2));
+ assert( (p1 >= p2));
+ }
+ {
+ typedef std::pair<int, short> P;
+ P p1(2, 4);
+ P p2(3, 4);
+ assert(!(p1 == p2));
+ assert( (p1 != p2));
+ assert( (p1 < p2));
+ assert( (p1 <= p2));
+ assert(!(p1 > p2));
+ assert(!(p1 >= p2));
+ }
+ {
+ typedef std::pair<int, short> P;
+ P p1(3, 2);
+ P p2(3, 4);
+ assert(!(p1 == p2));
+ assert( (p1 != p2));
+ assert( (p1 < p2));
+ assert( (p1 <= p2));
+ assert(!(p1 > p2));
+ assert(!(p1 >= p2));
+ }
+ {
+ typedef std::pair<int, short> P;
+ P p1(3, 4);
+ P p2(2, 4);
+ assert(!(p1 == p2));
+ assert( (p1 != p2));
+ assert(!(p1 < p2));
+ assert(!(p1 <= p2));
+ assert( (p1 > p2));
+ assert( (p1 >= p2));
+ }
+ {
+ typedef std::pair<int, short> P;
+ P p1(3, 4);
+ P p2(3, 2);
+ assert(!(p1 == p2));
+ assert( (p1 != p2));
+ assert(!(p1 < p2));
+ assert(!(p1 <= p2));
+ assert( (p1 > p2));
+ assert( (p1 >= p2));
+ }
+
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::pair<int, short> P;
+ constexpr P p1(3, 4);
+ constexpr P p2(3, 2);
+ static_assert(!(p1 == p2), "");
+ static_assert( (p1 != p2), "");
+ static_assert(!(p1 < p2), "");
+ static_assert(!(p1 <= p2), "");
+ static_assert( (p1 > p2), "");
+ static_assert( (p1 >= p2), "");
+ }
+#endif
+}
diff --git a/test/std/utilities/utility/pairs/pairs.spec/make_pair.pass.cpp b/test/std/utilities/utility/pairs/pairs.spec/make_pair.pass.cpp
new file mode 100644
index 000000000000..48e09735abb0
--- /dev/null
+++ b/test/std/utilities/utility/pairs/pairs.spec/make_pair.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template <class T1, class T2> pair<V1, V2> make_pair(T1&&, T2&&);
+
+#include <utility>
+#include <memory>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::pair<int, short> P1;
+ P1 p1 = std::make_pair(3, 4);
+ assert(p1.first == 3);
+ assert(p1.second == 4);
+ }
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::pair<std::unique_ptr<int>, short> P1;
+ P1 p1 = std::make_pair(std::unique_ptr<int>(new int(3)), 4);
+ assert(*p1.first == 3);
+ assert(p1.second == 4);
+ }
+ {
+ typedef std::pair<std::unique_ptr<int>, short> P1;
+ P1 p1 = std::make_pair(nullptr, 4);
+ assert(p1.first == nullptr);
+ assert(p1.second == 4);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::pair<int, short> P1;
+ constexpr P1 p1 = std::make_pair(3, 4);
+ static_assert(p1.first == 3, "");
+ static_assert(p1.second == 4, "");
+ }
+#endif
+
+}
diff --git a/test/std/utilities/utility/pairs/pairs.spec/non_member_swap.pass.cpp b/test/std/utilities/utility/pairs/pairs.spec/non_member_swap.pass.cpp
new file mode 100644
index 000000000000..d9d8f27b5225
--- /dev/null
+++ b/test/std/utilities/utility/pairs/pairs.spec/non_member_swap.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template <class T1, class T2> struct pair
+
+// template <class T1, class T2> void swap(pair<T1, T2>& x, pair<T1, T2>& y);
+
+#include <utility>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::pair<int, short> P1;
+ P1 p1(3, 4);
+ P1 p2(5, 6);
+ swap(p1, p2);
+ assert(p1.first == 5);
+ assert(p1.second == 6);
+ assert(p2.first == 3);
+ assert(p2.second == 4);
+ }
+}
diff --git a/test/std/utilities/utility/utility.swap/swap.pass.cpp b/test/std/utilities/utility/utility.swap/swap.pass.cpp
new file mode 100644
index 000000000000..8606611f6603
--- /dev/null
+++ b/test/std/utilities/utility/utility.swap/swap.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template<class T>
+// requires MoveAssignable<T> && MoveConstructible<T>
+// void
+// swap(T& a, T& b);
+
+#include <utility>
+#include <cassert>
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#include <memory>
+#endif
+
+void
+test()
+{
+ int i = 1;
+ int j = 2;
+ std::swap(i, j);
+ assert(i == 2);
+ assert(j == 1);
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+void
+test1()
+{
+ std::unique_ptr<int> i(new int(1));
+ std::unique_ptr<int> j(new int(2));
+ std::swap(i, j);
+ assert(*i == 2);
+ assert(*j == 1);
+}
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+ test();
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ test1();
+#endif
+}
diff --git a/test/std/utilities/utility/utility.swap/swap_array.pass.cpp b/test/std/utilities/utility/utility.swap/swap_array.pass.cpp
new file mode 100644
index 000000000000..b1209c3c3651
--- /dev/null
+++ b/test/std/utilities/utility/utility.swap/swap_array.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template<ValueType T, size_t N>
+// requires Swappable<T>
+// void
+// swap(T (&a)[N], T (&b)[N]);
+
+#include <utility>
+#include <cassert>
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#include <memory>
+#endif
+
+void
+test()
+{
+ int i[3] = {1, 2, 3};
+ int j[3] = {4, 5, 6};
+ std::swap(i, j);
+ assert(i[0] == 4);
+ assert(i[1] == 5);
+ assert(i[2] == 6);
+ assert(j[0] == 1);
+ assert(j[1] == 2);
+ assert(j[2] == 3);
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+void
+test1()
+{
+ std::unique_ptr<int> i[3];
+ for (int k = 0; k < 3; ++k)
+ i[k].reset(new int(k+1));
+ std::unique_ptr<int> j[3];
+ for (int k = 0; k < 3; ++k)
+ j[k].reset(new int(k+4));
+ std::swap(i, j);
+ assert(*i[0] == 4);
+ assert(*i[1] == 5);
+ assert(*i[2] == 6);
+ assert(*j[0] == 1);
+ assert(*j[1] == 2);
+ assert(*j[2] == 3);
+}
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+ test();
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ test1();
+#endif
+}
diff --git a/test/std/utilities/utility/version.pass.cpp b/test/std/utilities/utility/version.pass.cpp
new file mode 100644
index 000000000000..77d145d94457
--- /dev/null
+++ b/test/std/utilities/utility/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+#include <utility>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/support/Counter.h b/test/support/Counter.h
new file mode 100644
index 000000000000..2bc3642f5059
--- /dev/null
+++ b/test/support/Counter.h
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef COUNTER_H
+#define COUNTER_H
+
+#include <functional> // for std::hash
+
+struct Counter_base { static int gConstructed; };
+
+template <typename T>
+class Counter : public Counter_base
+{
+public:
+ Counter() : data_() { ++gConstructed; }
+ Counter(const T &data) : data_(data) { ++gConstructed; }
+ Counter(const Counter& rhs) : data_(rhs.data_) { ++gConstructed; }
+ Counter& operator=(const Counter& rhs) { ++gConstructed; data_ = rhs.data_; return *this; }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ Counter(Counter&& rhs) : data_(std::move(rhs.data_)) { ++gConstructed; }
+ Counter& operator=(Counter&& rhs) { ++gConstructed; data_ = std::move(rhs.data_); return *this; }
+#endif
+ ~Counter() { --gConstructed; }
+
+ const T& get() const {return data_;}
+
+ bool operator==(const Counter& x) const {return data_ == x.data_;}
+ bool operator< (const Counter& x) const {return data_ < x.data_;}
+
+private:
+ T data_;
+};
+
+int Counter_base::gConstructed = 0;
+
+namespace std {
+
+template <class T>
+struct hash<Counter<T> >
+ : public std::unary_function<Counter<T>, std::size_t>
+{
+ std::size_t operator()(const Counter<T>& x) const {return std::hash<T>(x.get());}
+};
+}
+
+#endif
diff --git a/test/support/DefaultOnly.h b/test/support/DefaultOnly.h
new file mode 100644
index 000000000000..a3d4303f8158
--- /dev/null
+++ b/test/support/DefaultOnly.h
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef DEFAULTONLY_H
+#define DEFAULTONLY_H
+
+#include <cassert>
+
+class DefaultOnly
+{
+ int data_;
+
+ DefaultOnly(const DefaultOnly&);
+ DefaultOnly& operator=(const DefaultOnly&);
+public:
+ static int count;
+
+ DefaultOnly() : data_(-1) {++count;}
+ ~DefaultOnly() {data_ = 0; --count;}
+
+ friend bool operator==(const DefaultOnly& x, const DefaultOnly& y)
+ {return x.data_ == y.data_;}
+ friend bool operator< (const DefaultOnly& x, const DefaultOnly& y)
+ {return x.data_ < y.data_;}
+};
+
+int DefaultOnly::count = 0;
+
+#endif // DEFAULTONLY_H
diff --git a/test/support/MoveOnly.h b/test/support/MoveOnly.h
new file mode 100644
index 000000000000..e4d9f6495602
--- /dev/null
+++ b/test/support/MoveOnly.h
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef MOVEONLY_H
+#define MOVEONLY_H
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+#include <cstddef>
+#include <functional>
+
+class MoveOnly
+{
+ MoveOnly(const MoveOnly&);
+ MoveOnly& operator=(const MoveOnly&);
+
+ int data_;
+public:
+ MoveOnly(int data = 1) : data_(data) {}
+ MoveOnly(MoveOnly&& x)
+ : data_(x.data_) {x.data_ = 0;}
+ MoveOnly& operator=(MoveOnly&& x)
+ {data_ = x.data_; x.data_ = 0; return *this;}
+
+ int get() const {return data_;}
+
+ bool operator==(const MoveOnly& x) const {return data_ == x.data_;}
+ bool operator< (const MoveOnly& x) const {return data_ < x.data_;}
+};
+
+namespace std {
+
+template <>
+struct hash<MoveOnly>
+ : public std::unary_function<MoveOnly, std::size_t>
+{
+ std::size_t operator()(const MoveOnly& x) const {return x.get();}
+};
+
+}
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+#endif // MOVEONLY_H
diff --git a/test/support/allocators.h b/test/support/allocators.h
new file mode 100644
index 000000000000..b7aba12e21fd
--- /dev/null
+++ b/test/support/allocators.h
@@ -0,0 +1,185 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef ALLOCATORS_H
+#define ALLOCATORS_H
+
+#include <type_traits>
+#include <utility>
+
+#include "test_macros.h"
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class T>
+class A1
+{
+ int id_;
+public:
+ explicit A1(int id = 0) TEST_NOEXCEPT : id_(id) {}
+
+ typedef T value_type;
+
+ int id() const {return id_;}
+
+ static bool copy_called;
+ static bool move_called;
+ static bool allocate_called;
+ static std::pair<T*, std::size_t> deallocate_called;
+
+ A1(const A1& a) TEST_NOEXCEPT : id_(a.id()) {copy_called = true;}
+ A1(A1&& a) TEST_NOEXCEPT : id_(a.id()) {move_called = true;}
+
+ template <class U>
+ A1(const A1<U>& a) TEST_NOEXCEPT : id_(a.id()) {copy_called = true;}
+ template <class U>
+ A1(A1<U>&& a) TEST_NOEXCEPT : id_(a.id()) {move_called = true;}
+
+ T* allocate(std::size_t n)
+ {
+ allocate_called = true;
+ return (T*)n;
+ }
+
+ void deallocate(T* p, std::size_t n)
+ {
+ deallocate_called = std::pair<T*, std::size_t>(p, n);
+ }
+
+ std::size_t max_size() const {return id_;}
+};
+
+template <class T> bool A1<T>::copy_called = false;
+template <class T> bool A1<T>::move_called = false;
+template <class T> bool A1<T>::allocate_called = false;
+template <class T> std::pair<T*, std::size_t> A1<T>::deallocate_called;
+
+template <class T, class U>
+inline
+bool operator==(const A1<T>& x, const A1<U>& y)
+{
+ return x.id() == y.id();
+}
+
+template <class T, class U>
+inline
+bool operator!=(const A1<T>& x, const A1<U>& y)
+{
+ return !(x == y);
+}
+
+template <class T>
+class A2
+{
+ int id_;
+public:
+ explicit A2(int id = 0) TEST_NOEXCEPT : id_(id) {}
+
+ typedef T value_type;
+
+ typedef unsigned size_type;
+ typedef int difference_type;
+
+ typedef std::true_type propagate_on_container_move_assignment;
+
+ int id() const {return id_;}
+
+ static bool copy_called;
+ static bool move_called;
+ static bool allocate_called;
+
+ A2(const A2& a) TEST_NOEXCEPT : id_(a.id()) {copy_called = true;}
+ A2(A2&& a) TEST_NOEXCEPT : id_(a.id()) {move_called = true;}
+
+ T* allocate(std::size_t n, const void* hint)
+ {
+ allocate_called = true;
+ return (T*)hint;
+ }
+};
+
+template <class T> bool A2<T>::copy_called = false;
+template <class T> bool A2<T>::move_called = false;
+template <class T> bool A2<T>::allocate_called = false;
+
+template <class T, class U>
+inline
+bool operator==(const A2<T>& x, const A2<U>& y)
+{
+ return x.id() == y.id();
+}
+
+template <class T, class U>
+inline
+bool operator!=(const A2<T>& x, const A2<U>& y)
+{
+ return !(x == y);
+}
+
+template <class T>
+class A3
+{
+ int id_;
+public:
+ explicit A3(int id = 0) TEST_NOEXCEPT : id_(id) {}
+
+ typedef T value_type;
+
+ typedef std::true_type propagate_on_container_copy_assignment;
+ typedef std::true_type propagate_on_container_swap;
+
+ int id() const {return id_;}
+
+ static bool copy_called;
+ static bool move_called;
+ static bool constructed;
+ static bool destroy_called;
+
+ A3(const A3& a) TEST_NOEXCEPT : id_(a.id()) {copy_called = true;}
+ A3(A3&& a) TEST_NOEXCEPT: id_(a.id()) {move_called = true;}
+
+ template <class U, class ...Args>
+ void construct(U* p, Args&& ...args)
+ {
+ ::new (p) U(std::forward<Args>(args)...);
+ constructed = true;
+ }
+
+ template <class U>
+ void destroy(U* p)
+ {
+ p->~U();
+ destroy_called = true;
+ }
+
+ A3 select_on_container_copy_construction() const {return A3(-1);}
+};
+
+template <class T> bool A3<T>::copy_called = false;
+template <class T> bool A3<T>::move_called = false;
+template <class T> bool A3<T>::constructed = false;
+template <class T> bool A3<T>::destroy_called = false;
+
+template <class T, class U>
+inline
+bool operator==(const A3<T>& x, const A3<U>& y)
+{
+ return x.id() == y.id();
+}
+
+template <class T, class U>
+inline
+bool operator!=(const A3<T>& x, const A3<U>& y)
+{
+ return !(x == y);
+}
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+#endif // ALLOCATORS_H
diff --git a/test/support/asan_testing.h b/test/support/asan_testing.h
new file mode 100644
index 000000000000..45ad04b1bb2c
--- /dev/null
+++ b/test/support/asan_testing.h
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef ASAN_TESTING_H
+#define ASAN_TESTING_H
+
+#include <__config>
+
+#ifndef _LIBCPP_HAS_NO_ASAN
+extern "C" int __sanitizer_verify_contiguous_container
+ ( const void *beg, const void *mid, const void *end );
+
+template <typename T, typename Alloc>
+bool is_contiguous_container_asan_correct ( const std::vector<T, Alloc> &c )
+{
+ if ( std::is_same<Alloc, std::allocator<T> >::value && c.data() != NULL)
+ return __sanitizer_verify_contiguous_container (
+ c.data(), c.data() + c.size(), c.data() + c.capacity()) != 0;
+ return true;
+}
+
+#else
+template <typename T, typename Alloc>
+bool is_contiguous_container_asan_correct ( const std::vector<T, Alloc> &c )
+{
+ return true;
+}
+#endif
+
+
+#endif // ASAN_TESTING_H
diff --git a/test/support/cmpxchg_loop.h b/test/support/cmpxchg_loop.h
new file mode 100644
index 000000000000..c39e3fb12f67
--- /dev/null
+++ b/test/support/cmpxchg_loop.h
@@ -0,0 +1,51 @@
+#include <atomic>
+
+template <class A, class T>
+bool cmpxchg_weak_loop(A& atomic, T& expected, T desired) {
+ for (int i = 0; i < 10; i++) {
+ if (atomic.compare_exchange_weak(expected, desired) == true) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+template <class A, class T>
+bool cmpxchg_weak_loop(A& atomic, T& expected, T desired,
+ std::memory_order success,
+ std::memory_order failure) {
+ for (int i = 0; i < 10; i++) {
+ if (atomic.compare_exchange_weak(expected, desired, success,
+ failure) == true) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+template <class A, class T>
+bool c_cmpxchg_weak_loop(A* atomic, T* expected, T desired) {
+ for (int i = 0; i < 10; i++) {
+ if (std::atomic_compare_exchange_weak(atomic, expected, desired) == true) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+template <class A, class T>
+bool c_cmpxchg_weak_loop(A* atomic, T* expected, T desired,
+ std::memory_order success,
+ std::memory_order failure) {
+ for (int i = 0; i < 10; i++) {
+ if (std::atomic_compare_exchange_weak_explicit(atomic, expected, desired,
+ success, failure) == true) {
+ return true;
+ }
+ }
+
+ return false;
+}
diff --git a/test/support/constexpr_char_traits.hpp b/test/support/constexpr_char_traits.hpp
new file mode 100644
index 000000000000..b069c90076a2
--- /dev/null
+++ b/test/support/constexpr_char_traits.hpp
@@ -0,0 +1,138 @@
+// -*- C++ -*-
+//===-------_------------ constexpr_char_traits ---------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _CONSTEXPR_CHAR_TRAITS
+#define _CONSTEXPR_CHAR_TRAITS
+
+#include <__config>
+#include <string>
+
+
+template <class _CharT>
+struct constexpr_char_traits
+{
+ typedef _CharT char_type;
+ typedef int int_type;
+ typedef std::streamoff off_type;
+ typedef std::streampos pos_type;
+ typedef std::mbstate_t state_type;
+
+ static _LIBCPP_CONSTEXPR_AFTER_CXX11 void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT
+ {__c1 = __c2;}
+
+ static _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT
+ {return __c1 == __c2;}
+
+ static _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT
+ {return __c1 < __c2;}
+
+ static _LIBCPP_CONSTEXPR_AFTER_CXX11 int compare(const char_type* __s1, const char_type* __s2, size_t __n);
+ static _LIBCPP_CONSTEXPR_AFTER_CXX11 size_t length(const char_type* __s);
+ static _LIBCPP_CONSTEXPR_AFTER_CXX11 const char_type* find(const char_type* __s, size_t __n, const char_type& __a);
+ static _LIBCPP_CONSTEXPR_AFTER_CXX11 char_type* move(char_type* __s1, const char_type* __s2, size_t __n);
+ static _LIBCPP_CONSTEXPR_AFTER_CXX11 char_type* copy(char_type* __s1, const char_type* __s2, size_t __n);
+ static _LIBCPP_CONSTEXPR_AFTER_CXX11 char_type* assign(char_type* __s, size_t __n, char_type __a);
+
+ static _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT
+ {return eq_int_type(__c, eof()) ? ~eof() : __c;}
+
+ static _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT
+ {return char_type(__c);}
+
+ static _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT
+ {return int_type(__c);}
+
+ static _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT
+ {return __c1 == __c2;}
+
+ static _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT
+ {return int_type(EOF);}
+};
+
+
+template <class _CharT>
+_LIBCPP_CONSTEXPR_AFTER_CXX11 int
+constexpr_char_traits<_CharT>::compare(const char_type* __s1, const char_type* __s2, size_t __n)
+{
+ for (; __n; --__n, ++__s1, ++__s2)
+ {
+ if (lt(*__s1, *__s2))
+ return -1;
+ if (lt(*__s2, *__s1))
+ return 1;
+ }
+ return 0;
+}
+
+template <class _CharT>
+_LIBCPP_CONSTEXPR_AFTER_CXX11 size_t
+constexpr_char_traits<_CharT>::length(const char_type* __s)
+{
+ size_t __len = 0;
+ for (; !eq(*__s, char_type(0)); ++__s)
+ ++__len;
+ return __len;
+}
+
+template <class _CharT>
+_LIBCPP_CONSTEXPR_AFTER_CXX11 const _CharT*
+constexpr_char_traits<_CharT>::find(const char_type* __s, size_t __n, const char_type& __a)
+{
+ for (; __n; --__n)
+ {
+ if (eq(*__s, __a))
+ return __s;
+ ++__s;
+ }
+ return 0;
+}
+
+template <class _CharT>
+_LIBCPP_CONSTEXPR_AFTER_CXX11 _CharT*
+constexpr_char_traits<_CharT>::move(char_type* __s1, const char_type* __s2, size_t __n)
+{
+ char_type* __r = __s1;
+ if (__s1 < __s2)
+ {
+ for (; __n; --__n, ++__s1, ++__s2)
+ assign(*__s1, *__s2);
+ }
+ else if (__s2 < __s1)
+ {
+ __s1 += __n;
+ __s2 += __n;
+ for (; __n; --__n)
+ assign(*--__s1, *--__s2);
+ }
+ return __r;
+}
+
+template <class _CharT>
+_LIBCPP_CONSTEXPR_AFTER_CXX11 _CharT*
+constexpr_char_traits<_CharT>::copy(char_type* __s1, const char_type* __s2, size_t __n)
+{
+ _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range");
+ char_type* __r = __s1;
+ for (; __n; --__n, ++__s1, ++__s2)
+ assign(*__s1, *__s2);
+ return __r;
+}
+
+template <class _CharT>
+_LIBCPP_CONSTEXPR_AFTER_CXX11 _CharT*
+constexpr_char_traits<_CharT>::assign(char_type* __s, size_t __n, char_type __a)
+{
+ char_type* __r = __s;
+ for (; __n; --__n, ++__s)
+ assign(*__s, __a);
+ return __r;
+}
+
+#endif // _CONSTEXPR_CHAR_TRAITS
diff --git a/test/support/count_new.hpp b/test/support/count_new.hpp
new file mode 100644
index 000000000000..ddaf036f7d16
--- /dev/null
+++ b/test/support/count_new.hpp
@@ -0,0 +1,206 @@
+#ifndef COUNT_NEW_HPP
+#define COUNT_NEW_HPP
+
+# include <cstdlib>
+# include <cassert>
+# include <new>
+
+#ifndef __has_feature
+# define __has_feature(x) 0
+#endif
+
+#if __has_feature(address_sanitizer) \
+ || __has_feature(memory_sanitizer) \
+ || __has_feature(thread_sanitizer)
+#define DISABLE_NEW_COUNT
+#endif
+
+class MemCounter
+{
+public:
+ // Make MemCounter super hard to accidentally construct or copy.
+ class MemCounterCtorArg_ {};
+ explicit MemCounter(MemCounterCtorArg_) { reset(); }
+
+private:
+ MemCounter(MemCounter const &);
+ MemCounter & operator=(MemCounter const &);
+
+public:
+ // All checks return true when disable_checking is enabled.
+ static const bool disable_checking;
+
+ int outstanding_new;
+ int new_called;
+ int delete_called;
+ int last_new_size;
+
+ int outstanding_array_new;
+ int new_array_called;
+ int delete_array_called;
+ int last_new_array_size;
+
+public:
+ void newCalled(std::size_t s)
+ {
+ assert(s);
+ ++new_called;
+ ++outstanding_new;
+ last_new_size = s;
+ }
+
+ void deleteCalled(void * p)
+ {
+ assert(p);
+ --outstanding_new;
+ ++delete_called;
+ }
+
+ void newArrayCalled(std::size_t s)
+ {
+ assert(s);
+ ++outstanding_array_new;
+ ++new_array_called;
+ last_new_array_size = s;
+ }
+
+ void deleteArrayCalled(void * p)
+ {
+ assert(p);
+ --outstanding_array_new;
+ ++delete_array_called;
+ }
+
+ void reset()
+ {
+ outstanding_new = 0;
+ new_called = 0;
+ delete_called = 0;
+ last_new_size = 0;
+
+ outstanding_array_new = 0;
+ new_array_called = 0;
+ delete_array_called = 0;
+ last_new_array_size = 0;
+ }
+
+public:
+ bool checkOutstandingNewEq(int n) const
+ {
+ return disable_checking || n == outstanding_new;
+ }
+
+ bool checkOutstandingNewNotEq(int n) const
+ {
+ return disable_checking || n != outstanding_new;
+ }
+
+ bool checkNewCalledEq(int n) const
+ {
+ return disable_checking || n == new_called;
+ }
+
+ bool checkNewCalledNotEq(int n) const
+ {
+ return disable_checking || n != new_called;
+ }
+
+ bool checkDeleteCalledEq(int n) const
+ {
+ return disable_checking || n == delete_called;
+ }
+
+ bool checkDeleteCalledNotEq(int n) const
+ {
+ return disable_checking || n != delete_called;
+ }
+
+ bool checkLastNewSizeEq(int n) const
+ {
+ return disable_checking || n == last_new_size;
+ }
+
+ bool checkLastNewSizeNotEq(int n) const
+ {
+ return disable_checking || n != last_new_size;
+ }
+
+ bool checkOutstandingArrayNewEq(int n) const
+ {
+ return disable_checking || n == outstanding_array_new;
+ }
+
+ bool checkOutstandingArrayNewNotEq(int n) const
+ {
+ return disable_checking || n != outstanding_array_new;
+ }
+
+ bool checkNewArrayCalledEq(int n) const
+ {
+ return disable_checking || n == new_array_called;
+ }
+
+ bool checkNewArrayCalledNotEq(int n) const
+ {
+ return disable_checking || n != new_array_called;
+ }
+
+ bool checkDeleteArrayCalledEq(int n) const
+ {
+ return disable_checking || n == delete_array_called;
+ }
+
+ bool checkDeleteArrayCalledNotEq(int n) const
+ {
+ return disable_checking || n != delete_array_called;
+ }
+
+ bool checkLastNewArraySizeEq(int n) const
+ {
+ return disable_checking || n == last_new_array_size;
+ }
+
+ bool checkLastNewArraySizeNotEq(int n) const
+ {
+ return disable_checking || n != last_new_array_size;
+ }
+};
+
+#ifdef DISABLE_NEW_COUNT
+ const bool MemCounter::disable_checking = true;
+#else
+ const bool MemCounter::disable_checking = false;
+#endif
+
+MemCounter globalMemCounter((MemCounter::MemCounterCtorArg_()));
+
+#ifndef DISABLE_NEW_COUNT
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+ globalMemCounter.newCalled(s);
+ return std::malloc(s);
+}
+
+void operator delete(void* p) throw()
+{
+ globalMemCounter.deleteCalled(p);
+ std::free(p);
+}
+
+
+void* operator new[](std::size_t s) throw(std::bad_alloc)
+{
+ globalMemCounter.newArrayCalled(s);
+ return operator new(s);
+}
+
+
+void operator delete[](void* p) throw()
+{
+ globalMemCounter.deleteArrayCalled(p);
+ operator delete(p);
+}
+
+#endif // DISABLE_NEW_COUNT
+
+#endif /* COUNT_NEW_HPP */
diff --git a/test/support/counting_predicates.hpp b/test/support/counting_predicates.hpp
new file mode 100644
index 000000000000..aab6a9785772
--- /dev/null
+++ b/test/support/counting_predicates.hpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef __COUNTING_PREDICATES_H
+#define __COUNTING_PREDICATES_H
+
+
+template <typename Predicate, typename Arg>
+struct unary_counting_predicate : public std::unary_function<Arg, bool> {
+public:
+ unary_counting_predicate(Predicate p) : p_(p), count_(0) {}
+ ~unary_counting_predicate() {}
+
+ bool operator () (const Arg &a) const { ++count_; return p_(a); }
+ size_t count() const { return count_; }
+ void reset() { count_ = 0; }
+
+private:
+ Predicate p_;
+ mutable size_t count_;
+ };
+
+
+template <typename Predicate, typename Arg1, typename Arg2=Arg1>
+struct binary_counting_predicate : public std::binary_function<Arg1, Arg2, bool> {
+public:
+
+ binary_counting_predicate ( Predicate p ) : p_(p), count_(0) {}
+ ~binary_counting_predicate() {}
+
+ bool operator () (const Arg1 &a1, const Arg2 &a2) const { ++count_; return p_(a1, a2); }
+ size_t count() const { return count_; }
+ void reset() { count_ = 0; }
+
+private:
+ Predicate p_;
+ mutable size_t count_;
+ };
+
+#endif // __COUNTING_PREDICATES_H
diff --git a/test/support/hexfloat.h b/test/support/hexfloat.h
new file mode 100644
index 000000000000..7ef093714fed
--- /dev/null
+++ b/test/support/hexfloat.h
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// Define a hexfloat literal emulator since we can't depend on being able to
+// for hexfloat literals
+
+// 0x10.F5p-10 == hexfloat<double>(0x10, 0xF5, -10)
+
+#ifndef HEXFLOAT_H
+#define HEXFLOAT_H
+
+#include <algorithm>
+#include <cmath>
+#include <climits>
+
+template <class T>
+class hexfloat
+{
+ T value_;
+public:
+ hexfloat(long long m1, unsigned long long m0, int exp)
+ {
+ const std::size_t n = sizeof(unsigned long long) * CHAR_BIT;
+ int s = m1 < 0 ? -1 : 1;
+ value_ = std::ldexp(m1 + s * std::ldexp(T(m0), -static_cast<int>(n -
+ std::__clz(m0)/4*4)), exp);
+ }
+
+ operator T() const {return value_;}
+};
+
+#endif
diff --git a/test/support/is_transparent.h b/test/support/is_transparent.h
new file mode 100644
index 000000000000..58255248abc9
--- /dev/null
+++ b/test/support/is_transparent.h
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef TRANSPARENT_H
+#define TRANSPARENT_H
+
+// testing transparent
+#if _LIBCPP_STD_VER > 11
+
+struct transparent_less
+{
+ template <class T, class U>
+ constexpr auto operator()(T&& t, U&& u) const
+ noexcept(noexcept(std::forward<T>(t) < std::forward<U>(u)))
+ -> decltype (std::forward<T>(t) < std::forward<U>(u))
+ { return std::forward<T>(t) < std::forward<U>(u); }
+ typedef void is_transparent; // correct
+};
+
+struct transparent_less_no_type
+{
+ template <class T, class U>
+ constexpr auto operator()(T&& t, U&& u) const
+ noexcept(noexcept(std::forward<T>(t) < std::forward<U>(u)))
+ -> decltype (std::forward<T>(t) < std::forward<U>(u))
+ { return std::forward<T>(t) < std::forward<U>(u); }
+private:
+// typedef void is_transparent; // error - should exist
+};
+
+struct transparent_less_private
+{
+ template <class T, class U>
+ constexpr auto operator()(T&& t, U&& u) const
+ noexcept(noexcept(std::forward<T>(t) < std::forward<U>(u)))
+ -> decltype (std::forward<T>(t) < std::forward<U>(u))
+ { return std::forward<T>(t) < std::forward<U>(u); }
+private:
+ typedef void is_transparent; // error - should be accessible
+};
+
+struct transparent_less_not_a_type
+{
+ template <class T, class U>
+ constexpr auto operator()(T&& t, U&& u) const
+ noexcept(noexcept(std::forward<T>(t) < std::forward<U>(u)))
+ -> decltype (std::forward<T>(t) < std::forward<U>(u))
+ { return std::forward<T>(t) < std::forward<U>(u); }
+
+ int is_transparent; // error - should be a type
+};
+
+struct C2Int { // comparable to int
+ C2Int() : i_(0) {}
+ C2Int(int i): i_(i) {}
+ int get () const { return i_; }
+private:
+ int i_;
+ };
+
+bool operator <(int rhs, const C2Int& lhs) { return rhs < lhs.get(); }
+bool operator <(const C2Int& rhs, const C2Int& lhs) { return rhs.get() < lhs.get(); }
+bool operator <(const C2Int& rhs, int lhs) { return rhs.get() < lhs; }
+
+#endif
+
+#endif // TRANSPARENT_H
diff --git a/test/support/min_allocator.h b/test/support/min_allocator.h
new file mode 100644
index 000000000000..5e3ae5d2a136
--- /dev/null
+++ b/test/support/min_allocator.h
@@ -0,0 +1,291 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef MIN_ALLOCATOR_H
+#define MIN_ALLOCATOR_H
+
+#include <cstddef>
+
+#include "test_macros.h"
+
+template <class T>
+class bare_allocator
+{
+public:
+ typedef T value_type;
+
+ bare_allocator() TEST_NOEXCEPT {}
+
+ template <class U>
+ bare_allocator(bare_allocator<U>) TEST_NOEXCEPT {}
+
+ T* allocate(std::size_t n)
+ {
+ return static_cast<T*>(::operator new(n*sizeof(T)));
+ }
+
+ void deallocate(T* p, std::size_t)
+ {
+ return ::operator delete(static_cast<void*>(p));
+ }
+
+ friend bool operator==(bare_allocator, bare_allocator) {return true;}
+ friend bool operator!=(bare_allocator x, bare_allocator y) {return !(x == y);}
+};
+
+
+#if __cplusplus >= 201103L
+
+#include <memory>
+
+template <class T> class min_pointer;
+template <class T> class min_pointer<const T>;
+template <> class min_pointer<void>;
+template <> class min_pointer<const void>;
+template <class T> class min_allocator;
+
+template <>
+class min_pointer<const void>
+{
+ const void* ptr_;
+public:
+ min_pointer() TEST_NOEXCEPT = default;
+ min_pointer(std::nullptr_t) TEST_NOEXCEPT : ptr_(nullptr) {}
+ template <class T>
+ min_pointer(min_pointer<T> p) TEST_NOEXCEPT : ptr_(p.ptr_) {}
+
+ explicit operator bool() const {return ptr_ != nullptr;}
+
+ friend bool operator==(min_pointer x, min_pointer y) {return x.ptr_ == y.ptr_;}
+ friend bool operator!=(min_pointer x, min_pointer y) {return !(x == y);}
+ template <class U> friend class min_pointer;
+};
+
+template <>
+class min_pointer<void>
+{
+ void* ptr_;
+public:
+ min_pointer() TEST_NOEXCEPT = default;
+ min_pointer(std::nullptr_t) TEST_NOEXCEPT : ptr_(nullptr) {}
+ template <class T,
+ class = typename std::enable_if
+ <
+ !std::is_const<T>::value
+ >::type
+ >
+ min_pointer(min_pointer<T> p) TEST_NOEXCEPT : ptr_(p.ptr_) {}
+
+ explicit operator bool() const {return ptr_ != nullptr;}
+
+ friend bool operator==(min_pointer x, min_pointer y) {return x.ptr_ == y.ptr_;}
+ friend bool operator!=(min_pointer x, min_pointer y) {return !(x == y);}
+ template <class U> friend class min_pointer;
+};
+
+template <class T>
+class min_pointer
+{
+ T* ptr_;
+
+ explicit min_pointer(T* p) TEST_NOEXCEPT : ptr_(p) {}
+public:
+ min_pointer() TEST_NOEXCEPT = default;
+ min_pointer(std::nullptr_t) TEST_NOEXCEPT : ptr_(nullptr) {}
+ explicit min_pointer(min_pointer<void> p) TEST_NOEXCEPT : ptr_(static_cast<T*>(p.ptr_)) {}
+
+ explicit operator bool() const {return ptr_ != nullptr;}
+
+ typedef std::ptrdiff_t difference_type;
+ typedef T& reference;
+ typedef T* pointer;
+ typedef T value_type;
+ typedef std::random_access_iterator_tag iterator_category;
+
+ reference operator*() const {return *ptr_;}
+ pointer operator->() const {return ptr_;}
+
+ min_pointer& operator++() {++ptr_; return *this;}
+ min_pointer operator++(int) {min_pointer tmp(*this); ++ptr_; return tmp;}
+
+ min_pointer& operator--() {--ptr_; return *this;}
+ min_pointer operator--(int) {min_pointer tmp(*this); --ptr_; return tmp;}
+
+ min_pointer& operator+=(difference_type n) {ptr_ += n; return *this;}
+ min_pointer& operator-=(difference_type n) {ptr_ -= n; return *this;}
+
+ min_pointer operator+(difference_type n) const
+ {
+ min_pointer tmp(*this);
+ tmp += n;
+ return tmp;
+ }
+
+ friend min_pointer operator+(difference_type n, min_pointer x)
+ {
+ return x + n;
+ }
+
+ min_pointer operator-(difference_type n) const
+ {
+ min_pointer tmp(*this);
+ tmp -= n;
+ return tmp;
+ }
+
+ friend difference_type operator-(min_pointer x, min_pointer y)
+ {
+ return x.ptr_ - y.ptr_;
+ }
+
+ reference operator[](difference_type n) const {return ptr_[n];}
+
+ friend bool operator< (min_pointer x, min_pointer y) {return x.ptr_ < y.ptr_;}
+ friend bool operator> (min_pointer x, min_pointer y) {return y < x;}
+ friend bool operator<=(min_pointer x, min_pointer y) {return !(y < x);}
+ friend bool operator>=(min_pointer x, min_pointer y) {return !(x < y);}
+
+ static min_pointer pointer_to(T& t) {return min_pointer(std::addressof(t));}
+
+ friend bool operator==(min_pointer x, min_pointer y) {return x.ptr_ == y.ptr_;}
+ friend bool operator!=(min_pointer x, min_pointer y) {return !(x == y);}
+ template <class U> friend class min_pointer;
+ template <class U> friend class min_allocator;
+};
+
+template <class T>
+class min_pointer<const T>
+{
+ const T* ptr_;
+
+ explicit min_pointer(const T* p) : ptr_(p) {}
+public:
+ min_pointer() TEST_NOEXCEPT = default;
+ min_pointer(std::nullptr_t) : ptr_(nullptr) {}
+ min_pointer(min_pointer<T> p) : ptr_(p.ptr_) {}
+ explicit min_pointer(min_pointer<const void> p) : ptr_(static_cast<const T*>(p.ptr_)) {}
+
+ explicit operator bool() const {return ptr_ != nullptr;}
+
+ typedef std::ptrdiff_t difference_type;
+ typedef const T& reference;
+ typedef const T* pointer;
+ typedef const T value_type;
+ typedef std::random_access_iterator_tag iterator_category;
+
+ reference operator*() const {return *ptr_;}
+ pointer operator->() const {return ptr_;}
+
+ min_pointer& operator++() {++ptr_; return *this;}
+ min_pointer operator++(int) {min_pointer tmp(*this); ++ptr_; return tmp;}
+
+ min_pointer& operator--() {--ptr_; return *this;}
+ min_pointer operator--(int) {min_pointer tmp(*this); --ptr_; return tmp;}
+
+ min_pointer& operator+=(difference_type n) {ptr_ += n; return *this;}
+ min_pointer& operator-=(difference_type n) {ptr_ -= n; return *this;}
+
+ min_pointer operator+(difference_type n) const
+ {
+ min_pointer tmp(*this);
+ tmp += n;
+ return tmp;
+ }
+
+ friend min_pointer operator+(difference_type n, min_pointer x)
+ {
+ return x + n;
+ }
+
+ min_pointer operator-(difference_type n) const
+ {
+ min_pointer tmp(*this);
+ tmp -= n;
+ return tmp;
+ }
+
+ friend difference_type operator-(min_pointer x, min_pointer y)
+ {
+ return x.ptr_ - y.ptr_;
+ }
+
+ reference operator[](difference_type n) const {return ptr_[n];}
+
+ friend bool operator< (min_pointer x, min_pointer y) {return x.ptr_ < y.ptr_;}
+ friend bool operator> (min_pointer x, min_pointer y) {return y < x;}
+ friend bool operator<=(min_pointer x, min_pointer y) {return !(y < x);}
+ friend bool operator>=(min_pointer x, min_pointer y) {return !(x < y);}
+
+ static min_pointer pointer_to(const T& t) {return min_pointer(std::addressof(t));}
+
+ friend bool operator==(min_pointer x, min_pointer y) {return x.ptr_ == y.ptr_;}
+ friend bool operator!=(min_pointer x, min_pointer y) {return !(x == y);}
+ template <class U> friend class min_pointer;
+};
+
+template <class T>
+inline
+bool
+operator==(min_pointer<T> x, std::nullptr_t)
+{
+ return !static_cast<bool>(x);
+}
+
+template <class T>
+inline
+bool
+operator==(std::nullptr_t, min_pointer<T> x)
+{
+ return !static_cast<bool>(x);
+}
+
+template <class T>
+inline
+bool
+operator!=(min_pointer<T> x, std::nullptr_t)
+{
+ return static_cast<bool>(x);
+}
+
+template <class T>
+inline
+bool
+operator!=(std::nullptr_t, min_pointer<T> x)
+{
+ return static_cast<bool>(x);
+}
+
+template <class T>
+class min_allocator
+{
+public:
+ typedef T value_type;
+ typedef min_pointer<T> pointer;
+
+ min_allocator() = default;
+ template <class U>
+ min_allocator(min_allocator<U>) {}
+
+ pointer allocate(std::ptrdiff_t n)
+ {
+ return pointer(static_cast<T*>(::operator new(n*sizeof(T))));
+ }
+
+ void deallocate(pointer p, std::ptrdiff_t)
+ {
+ return ::operator delete(p.ptr_);
+ }
+
+ friend bool operator==(min_allocator, min_allocator) {return true;}
+ friend bool operator!=(min_allocator x, min_allocator y) {return !(x == y);}
+};
+
+#endif // __cplusplus >= 201103L
+
+#endif // MIN_ALLOCATOR_H
diff --git a/test/support/nasty_containers.hpp b/test/support/nasty_containers.hpp
new file mode 100644
index 000000000000..5a2e19505424
--- /dev/null
+++ b/test/support/nasty_containers.hpp
@@ -0,0 +1,282 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef NASTY_VECTOR_H
+#define NASTY_VECTOR_H
+
+#include <vector>
+#include <list>
+
+template <class T>
+class nasty_vector
+{
+public:
+ typedef typename std::vector<T> nested_container;
+ typedef typename nested_container::value_type value_type;
+ typedef typename nested_container::reference reference;
+ typedef typename nested_container::const_reference const_reference;
+ typedef typename nested_container::iterator iterator;
+ typedef typename nested_container::const_iterator const_iterator;
+
+ typedef typename nested_container::size_type size_type;
+ typedef typename nested_container::difference_type difference_type;
+ typedef typename nested_container::pointer pointer;
+ typedef typename nested_container::const_pointer const_pointer;
+
+ typedef typename nested_container::reverse_iterator reverse_iterator;
+ typedef typename nested_container::const_reverse_iterator const_reverse_iterator;
+
+ nasty_vector() : v_() {}
+ explicit nasty_vector(size_type n) : v_(n) {}
+ nasty_vector(size_type n, const value_type& value) : v_(n, value) {}
+ template <class InputIterator> nasty_vector(InputIterator first, InputIterator last) : v_(first, last) {}
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ nasty_vector(std::initializer_list<value_type> il) : v_(il) {}
+#endif
+ ~nasty_vector() {}
+
+ template <class InputIterator>
+ void assign(InputIterator first, InputIterator last) { v_.assign(first, last); }
+ void assign(size_type n, const value_type& u) { v_.assign(n, u); }
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ void assign(std::initializer_list<value_type> il) { v_.assign(il); }
+#endif
+
+ iterator begin() _NOEXCEPT { return v_.begin(); }
+ const_iterator begin() const _NOEXCEPT { return v_.begin(); }
+ iterator end() _NOEXCEPT { return v_.end(); }
+ const_iterator end() const _NOEXCEPT { return v_.end(); }
+
+ reverse_iterator rbegin() _NOEXCEPT { return v_.rbegin(); }
+ const_reverse_iterator rbegin() const _NOEXCEPT { return v_.rbegin(); }
+ reverse_iterator rend() _NOEXCEPT { return v_.rend(); }
+ const_reverse_iterator rend() const _NOEXCEPT { return v_.rend(); }
+
+ const_iterator cbegin() const _NOEXCEPT { return v_.cbegin(); }
+ const_iterator cend() const _NOEXCEPT { return v_.cend(); }
+ const_reverse_iterator crbegin() const _NOEXCEPT { return v_.crbegin(); }
+ const_reverse_iterator crend() const _NOEXCEPT { return v_.crend(); }
+
+ size_type size() const _NOEXCEPT { return v_.size(); }
+ size_type max_size() const _NOEXCEPT { return v_.max_size(); }
+ size_type capacity() const _NOEXCEPT { return v_.capacity(); }
+ bool empty() const _NOEXCEPT { return v_.empty(); }
+ void reserve(size_type n) { v_.reserve(n); };
+ void shrink_to_fit() _NOEXCEPT { v_.shrink_to_fit(); }
+
+ reference operator[](size_type n) { return v_[n]; }
+ const_reference operator[](size_type n) const { return v_[n]; }
+ reference at(size_type n) { return v_.at(n); }
+ const_reference at(size_type n) const { return v_.at(n); }
+
+ reference front() { return v_.front(); }
+ const_reference front() const { return v_.front(); }
+ reference back() { return v_.back(); }
+ const_reference back() const { return v_.back(); }
+
+ value_type* data() _NOEXCEPT { return v_.data(); }
+ const value_type* data() const _NOEXCEPT { return v_.data(); }
+
+ void push_back(const value_type& x) { v_.push_back(x); }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ void push_back(value_type&& x) { v_.push_back(std::forward<value_type&&>(x)); }
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+ template <class... Args>
+ void emplace_back(Args&&... args) { v_.emplace_back(std::forward<Args>(args)...); }
+#endif
+#endif
+ void pop_back() { v_.pop_back(); }
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+ template <class... Args> iterator emplace(const_iterator pos, Args&&... args)
+ { return v_.emplace(pos, std::forward<Args>(args)...); }
+#endif
+#endif
+
+ iterator insert(const_iterator pos, const value_type& x) { return v_.insert(pos, x); }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ iterator insert(const_iterator pos, value_type&& x) { return v_.insert(pos, std::forward<value_type>(x)); }
+#endif
+ iterator insert(const_iterator pos, size_type n, const value_type& x) { return v_.insert(pos, n, x); }
+ template <class InputIterator>
+ iterator insert(const_iterator pos, InputIterator first, InputIterator last)
+ { return v_.insert(pos, first, last); }
+
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ iterator insert(const_iterator pos, std::initializer_list<value_type> il) { return v_.insert(pos, il); }
+#endif
+
+ iterator erase(const_iterator pos) { return v_.erase(pos); }
+ iterator erase(const_iterator first, const_iterator last) { return v_.erase(first, last); }
+
+ void clear() _NOEXCEPT { v_.clear(); }
+
+ void resize(size_type sz) { v_.resize(sz); }
+ void resize(size_type sz, const value_type& c) { v_.resize(sz, c); }
+
+ void swap(nasty_vector &nv) _NOEXCEPT_(std::__is_nothrow_swappable<nested_container>::value)
+ { v_.swap(nv.v_); }
+
+ nasty_vector *operator &() { return nullptr; } // nasty
+ const nasty_vector *operator &() const { return nullptr; } // nasty
+
+ nested_container v_;
+};
+
+template <class T>
+bool operator==(const nasty_vector<T>& x, const nasty_vector<T>& y) { return x.v_ == y.v_; }
+
+template <class T>
+class nasty_list
+{
+public:
+
+ typedef typename std::list<T> nested_container;
+ typedef typename nested_container::value_type value_type;
+ typedef typename nested_container::reference reference;
+ typedef typename nested_container::const_reference const_reference;
+ typedef typename nested_container::iterator iterator;
+ typedef typename nested_container::const_iterator const_iterator;
+
+ typedef typename nested_container::size_type size_type;
+ typedef typename nested_container::difference_type difference_type;
+ typedef typename nested_container::pointer pointer;
+ typedef typename nested_container::const_pointer const_pointer;
+
+ typedef typename nested_container::reverse_iterator reverse_iterator;
+ typedef typename nested_container::const_reverse_iterator const_reverse_iterator;
+
+ nasty_list() : l_() {}
+ explicit nasty_list(size_type n) : l_(n) {}
+ nasty_list(size_type n, const value_type& value) : l_(n,value) {}
+ template <class Iter>
+ nasty_list(Iter first, Iter last) : l_(first, last) {}
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ nasty_list(std::initializer_list<value_type> il) : l_(il) {}
+#endif
+
+ ~nasty_list() {}
+
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ nasty_list& operator=(std::initializer_list<value_type> il) { l_ = il; return *this; }
+#endif
+ template <class Iter>
+ void assign(Iter first, Iter last) { l_.assign(first, last); }
+ void assign(size_type n, const value_type& t) { l_.assign(n, t); }
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ void assign(std::initializer_list<value_type> il) { l_.assign(il); }
+#endif
+
+
+ iterator begin() _NOEXCEPT { return l_.begin(); }
+ const_iterator begin() const _NOEXCEPT { return l_.begin(); }
+ iterator end() _NOEXCEPT { return l_.end(); }
+ const_iterator end() const _NOEXCEPT { return l_.end(); }
+
+ reverse_iterator rbegin() _NOEXCEPT { return l_.rbegin(); }
+ const_reverse_iterator rbegin() const _NOEXCEPT { return l_.rbegin(); }
+ reverse_iterator rend() _NOEXCEPT { return l_.rend(); }
+ const_reverse_iterator rend() const _NOEXCEPT { return l_.rend(); }
+
+ const_iterator cbegin() const _NOEXCEPT { return l_.cbegin(); }
+ const_iterator cend() const _NOEXCEPT { return l_.cend(); }
+ const_reverse_iterator crbegin() const _NOEXCEPT { return l_.crbegin(); }
+ const_reverse_iterator crend() const _NOEXCEPT { return l_.crend(); }
+
+ reference front() { return l_.front(); }
+ const_reference front() const { return l_.front(); }
+ reference back() { return l_.back(); }
+ const_reference back() const { return l_.back(); }
+
+ size_type size() const _NOEXCEPT { return l_.size(); }
+ size_type max_size() const _NOEXCEPT { return l_.max_size(); }
+ bool empty() const _NOEXCEPT { return l_.empty(); }
+
+ void push_front(const value_type& x) { l_.push_front(x); }
+ void push_back(const value_type& x) { l_.push_back(x); }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ void push_back(value_type&& x) { l_.push_back(std::forward<value_type&&>(x)); }
+ void push_front(value_type&& x) { l_.push_back(std::forward<value_type&&>(x)); }
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+ template <class... Args>
+ void emplace_back(Args&&... args) { l_.emplace_back(std::forward<Args>(args)...); }
+ template <class... Args>
+ void emplace_front(Args&&... args) { l_.emplace_front(std::forward<Args>(args)...); }
+#endif
+#endif
+ void pop_front() { l_.pop_front(); }
+ void pop_back() { l_.pop_back(); }
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+ template <class... Args> iterator emplace(const_iterator pos, Args&&... args)
+ { return l_.emplace(pos, std::forward<Args>(args)...); }
+#endif
+#endif
+
+ iterator insert(const_iterator pos, const value_type& x) { return l_.insert(pos, x); }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ iterator insert(const_iterator pos, value_type&& x) { return l_.insert(pos, std::forward<value_type>(x)); }
+#endif
+ iterator insert(const_iterator pos, size_type n, const value_type& x) { return l_.insert(pos, n, x); }
+ template <class InputIterator>
+ iterator insert(const_iterator pos, InputIterator first, InputIterator last)
+ { return l_.insert(pos, first, last); }
+
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ iterator insert(const_iterator pos, std::initializer_list<value_type> il) { return l_.insert(pos, il); }
+#endif
+
+ iterator erase(const_iterator pos) { return l_.erase(pos); }
+ iterator erase(const_iterator pos, const_iterator last) { return l_.erase(pos, last); }
+
+ void resize(size_type sz) { l_.resize(); }
+ void resize(size_type sz, const value_type& c) { l_.resize(c); }
+
+ void swap(nasty_list &nl) _NOEXCEPT_(std::__is_nothrow_swappable<nested_container>::value)
+ { l_.swap(nl.l_); }
+
+ void clear() _NOEXCEPT { l_.clear(); }
+
+// void splice(const_iterator position, list& x);
+// void splice(const_iterator position, list&& x);
+// void splice(const_iterator position, list& x, const_iterator i);
+// void splice(const_iterator position, list&& x, const_iterator i);
+// void splice(const_iterator position, list& x, const_iterator first,
+// const_iterator last);
+// void splice(const_iterator position, list&& x, const_iterator first,
+// const_iterator last);
+//
+// void remove(const value_type& value);
+// template <class Pred> void remove_if(Pred pred);
+// void unique();
+// template <class BinaryPredicate>
+// void unique(BinaryPredicate binary_pred);
+// void merge(list& x);
+// void merge(list&& x);
+// template <class Compare>
+// void merge(list& x, Compare comp);
+// template <class Compare>
+// void merge(list&& x, Compare comp);
+// void sort();
+// template <class Compare>
+// void sort(Compare comp);
+// void reverse() noexcept;
+
+ nasty_list *operator &() { return nullptr; } // nasty
+ const nasty_list *operator &() const { return nullptr; } // nasty
+
+ nested_container l_;
+};
+
+template <class T>
+bool operator==(const nasty_list<T>& x, const nasty_list<T>& y) { return x.l_ == y.l_; }
+
+#endif
diff --git a/test/support/nasty_macros.hpp b/test/support/nasty_macros.hpp
new file mode 100644
index 000000000000..2738e47eac9f
--- /dev/null
+++ b/test/support/nasty_macros.hpp
@@ -0,0 +1,32 @@
+#ifndef SUPPORT_NASTY_MACROS_HPP
+#define SUPPORT_NASTY_MACROS_HPP
+
+#define NASTY_MACRO This should not be expanded!!!
+#define _A NASTY_MACRO
+#define _B NASTY_MACRO
+#define _C NASTY_MACRO
+#define _D NASTY_MACRO
+#define _E NASTY_MACRO
+#define _F NASTY_MACRO
+#define _G NASTY_MACRO
+#define _H NASTY_MACRO
+#define _I NASTY_MACRO
+#define _J NASTY_MACRO
+#define _K NASTY_MACRO
+#define _L NASTY_MACRO
+#define _M NASTY_MACRO
+#define _N NASTY_MACRO
+#define _O NASTY_MACRO
+#define _P NASTY_MACRO
+#define _Q NASTY_MACRO
+#define _R NASTY_MACRO
+#define _S NASTY_MACRO
+#define _T NASTY_MACRO
+#define _U NASTY_MACRO
+#define _V NASTY_MACRO
+#define _W NASTY_MACRO
+#define _X NASTY_MACRO
+#define _Y NASTY_MACRO
+#define _Z NASTY_MACRO
+
+#endif // SUPPORT_NASTY_MACROS_HPP
diff --git a/test/support/nothing_to_do.pass.cpp b/test/support/nothing_to_do.pass.cpp
new file mode 100644
index 000000000000..9125fe194f46
--- /dev/null
+++ b/test/support/nothing_to_do.pass.cpp
@@ -0,0 +1,14 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
+
diff --git a/test/support/platform_support.h b/test/support/platform_support.h
new file mode 100644
index 000000000000..233e721ff515
--- /dev/null
+++ b/test/support/platform_support.h
@@ -0,0 +1,98 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// Define a bunch of macros that can be used in the tests instead of
+// implementation defined assumptions:
+// - locale names
+// - floating point number string output
+
+#ifndef PLATFORM_SUPPORT_H
+#define PLATFORM_SUPPORT_H
+
+#include <__config>
+
+// locale names
+#ifdef _WIN32
+// WARNING: Windows does not support UTF-8 codepages.
+// Locales are "converted" using http://docs.moodle.org/dev/Table_of_locales
+#define LOCALE_en_US_UTF_8 "English_United States.1252"
+#define LOCALE_cs_CZ_ISO8859_2 "Czech_Czech Republic.1250"
+#define LOCALE_fr_FR_UTF_8 "French_France.1252"
+#define LOCALE_fr_CA_ISO8859_1 "French_Canada.1252"
+#define LOCALE_ru_RU_UTF_8 "Russian_Russia.1251"
+#define LOCALE_zh_CN_UTF_8 "Chinese_China.936"
+#elif defined(__CloudABI__)
+// Timezones are integrated into locales through LC_TIMEZONE_MASK on
+// CloudABI. LC_ALL_MASK can only be used if a timezone has also been
+// provided. UTC should be all right.
+#define LOCALE_en_US_UTF_8 "en_US.UTF-8@UTC"
+#define LOCALE_fr_FR_UTF_8 "fr_FR.UTF-8@UTC"
+#define LOCALE_fr_CA_ISO8859_1 "fr_CA.ISO-8859-1@UTC"
+#define LOCALE_cs_CZ_ISO8859_2 "cs_CZ.ISO-8859-2@UTC"
+#define LOCALE_ru_RU_UTF_8 "ru_RU.UTF-8@UTC"
+#define LOCALE_zh_CN_UTF_8 "zh_CN.UTF-8@UTC"
+#else
+#define LOCALE_en_US_UTF_8 "en_US.UTF-8"
+#define LOCALE_fr_FR_UTF_8 "fr_FR.UTF-8"
+#ifdef __linux__
+#define LOCALE_fr_CA_ISO8859_1 "fr_CA.ISO-8859-1"
+#define LOCALE_cs_CZ_ISO8859_2 "cs_CZ.ISO-8859-2"
+#else
+#define LOCALE_fr_CA_ISO8859_1 "fr_CA.ISO8859-1"
+#define LOCALE_cs_CZ_ISO8859_2 "cs_CZ.ISO8859-2"
+#endif
+#define LOCALE_ru_RU_UTF_8 "ru_RU.UTF-8"
+#define LOCALE_zh_CN_UTF_8 "zh_CN.UTF-8"
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string>
+#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
+#include <io.h> // _mktemp
+#else
+#include <unistd.h> // close
+#endif
+
+#if defined(_NEWLIB_VERSION) && defined(__STRICT_ANSI__)
+// Newlib provies this, but in the header it's under __STRICT_ANSI__
+extern "C" {
+ int mkstemp(char*);
+}
+#endif
+
+#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
+inline
+std::string
+get_temp_file_name()
+{
+#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
+ char Path[MAX_PATH+1];
+ char FN[MAX_PATH+1];
+ do { } while (0 == GetTempPath(MAX_PATH+1, Path));
+ do { } while (0 == GetTempFileName(Path, "libcxx", 0, FN));
+ return FN;
+#else
+ std::string Name;
+ int FD = -1;
+ do {
+ Name = "libcxx.XXXXXX";
+ FD = mkstemp(&Name[0]);
+ if (FD == -1 && errno == EINVAL) {
+ perror("mkstemp");
+ abort();
+ }
+ } while (FD == -1);
+ close(FD);
+ return Name;
+#endif
+}
+#endif // _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
+
+#endif // PLATFORM_SUPPORT_H
diff --git a/test/support/private_constructor.hpp b/test/support/private_constructor.hpp
new file mode 100644
index 000000000000..a9fcf6897233
--- /dev/null
+++ b/test/support/private_constructor.hpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef __PRIVATE_CONSTRUCTOR__H
+#define __PRIVATE_CONSTRUCTOR__H
+
+#include <iostream>
+
+struct PrivateConstructor {
+
+ PrivateConstructor static make ( int v ) { return PrivateConstructor(v); }
+ int get () const { return val; }
+private:
+ PrivateConstructor ( int v ) : val(v) {}
+ int val;
+ };
+
+bool operator < ( const PrivateConstructor &lhs, const PrivateConstructor &rhs ) { return lhs.get() < rhs.get(); }
+
+bool operator < ( const PrivateConstructor &lhs, int rhs ) { return lhs.get() < rhs; }
+bool operator < ( int lhs, const PrivateConstructor &rhs ) { return lhs < rhs.get(); }
+
+std::ostream & operator << ( std::ostream &os, const PrivateConstructor &foo ) { return os << foo.get (); }
+
+#endif
diff --git a/test/support/test_allocator.h b/test/support/test_allocator.h
new file mode 100644
index 000000000000..47ef1d556784
--- /dev/null
+++ b/test/support/test_allocator.h
@@ -0,0 +1,226 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef TEST_ALLOCATOR_H
+#define TEST_ALLOCATOR_H
+
+#include <cstddef>
+#include <type_traits>
+#include <cstdlib>
+#include <new>
+#include <climits>
+#include <cassert>
+
+#include "test_macros.h"
+
+class test_alloc_base
+{
+protected:
+ static int time_to_throw;
+public:
+ static int throw_after;
+ static int count;
+ static int alloc_count;
+};
+
+int test_alloc_base::count = 0;
+int test_alloc_base::time_to_throw = 0;
+int test_alloc_base::alloc_count = 0;
+int test_alloc_base::throw_after = INT_MAX;
+
+template <class T>
+class test_allocator
+ : public test_alloc_base
+{
+ int data_;
+
+ template <class U> friend class test_allocator;
+public:
+
+ typedef unsigned size_type;
+ typedef int difference_type;
+ typedef T value_type;
+ typedef value_type* pointer;
+ typedef const value_type* const_pointer;
+ typedef typename std::add_lvalue_reference<value_type>::type reference;
+ typedef typename std::add_lvalue_reference<const value_type>::type const_reference;
+
+ template <class U> struct rebind {typedef test_allocator<U> other;};
+
+ test_allocator() throw() : data_(0) {++count;}
+ explicit test_allocator(int i) throw() : data_(i) {++count;}
+ test_allocator(const test_allocator& a) throw()
+ : data_(a.data_) {++count;}
+ template <class U> test_allocator(const test_allocator<U>& a) throw()
+ : data_(a.data_) {++count;}
+ ~test_allocator() throw() {assert(data_ >= 0); --count; data_ = -1;}
+ pointer address(reference x) const {return &x;}
+ const_pointer address(const_reference x) const {return &x;}
+ pointer allocate(size_type n, const void* = 0)
+ {
+ assert(data_ >= 0);
+ if (time_to_throw >= throw_after) {
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ throw std::bad_alloc();
+#else
+ std::terminate();
+#endif
+ }
+ ++time_to_throw;
+ ++alloc_count;
+ return (pointer)::operator new(n * sizeof(T));
+ }
+ void deallocate(pointer p, size_type n)
+ {assert(data_ >= 0); --alloc_count; ::operator delete((void*)p);}
+ size_type max_size() const throw()
+ {return UINT_MAX / sizeof(T);}
+ void construct(pointer p, const T& val)
+ {::new(p) T(val);}
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ void construct(pointer p, T&& val)
+ {::new(p) T(std::move(val));}
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ void destroy(pointer p) {p->~T();}
+
+ friend bool operator==(const test_allocator& x, const test_allocator& y)
+ {return x.data_ == y.data_;}
+ friend bool operator!=(const test_allocator& x, const test_allocator& y)
+ {return !(x == y);}
+};
+
+template <class T>
+class non_default_test_allocator
+ : public test_alloc_base
+{
+ int data_;
+
+ template <class U> friend class non_default_test_allocator;
+public:
+
+ typedef unsigned size_type;
+ typedef int difference_type;
+ typedef T value_type;
+ typedef value_type* pointer;
+ typedef const value_type* const_pointer;
+ typedef typename std::add_lvalue_reference<value_type>::type reference;
+ typedef typename std::add_lvalue_reference<const value_type>::type const_reference;
+
+ template <class U> struct rebind {typedef non_default_test_allocator<U> other;};
+
+// non_default_test_allocator() throw() : data_(0) {++count;}
+ explicit non_default_test_allocator(int i) throw() : data_(i) {++count;}
+ non_default_test_allocator(const non_default_test_allocator& a) throw()
+ : data_(a.data_) {++count;}
+ template <class U> non_default_test_allocator(const non_default_test_allocator<U>& a) throw()
+ : data_(a.data_) {++count;}
+ ~non_default_test_allocator() throw() {assert(data_ >= 0); --count; data_ = -1;}
+ pointer address(reference x) const {return &x;}
+ const_pointer address(const_reference x) const {return &x;}
+ pointer allocate(size_type n, const void* = 0)
+ {
+ assert(data_ >= 0);
+ if (time_to_throw >= throw_after) {
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ throw std::bad_alloc();
+#else
+ std::terminate();
+#endif
+ }
+ ++time_to_throw;
+ ++alloc_count;
+ return (pointer)::operator new (n * sizeof(T));
+ }
+ void deallocate(pointer p, size_type n)
+ {assert(data_ >= 0); --alloc_count; ::operator delete((void*)p); }
+ size_type max_size() const throw()
+ {return UINT_MAX / sizeof(T);}
+ void construct(pointer p, const T& val)
+ {::new(p) T(val);}
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ void construct(pointer p, T&& val)
+ {::new(p) T(std::move(val));}
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ void destroy(pointer p) {p->~T();}
+
+ friend bool operator==(const non_default_test_allocator& x, const non_default_test_allocator& y)
+ {return x.data_ == y.data_;}
+ friend bool operator!=(const non_default_test_allocator& x, const non_default_test_allocator& y)
+ {return !(x == y);}
+};
+
+template <>
+class test_allocator<void>
+ : public test_alloc_base
+{
+ int data_;
+
+ template <class U> friend class test_allocator;
+public:
+
+ typedef unsigned size_type;
+ typedef int difference_type;
+ typedef void value_type;
+ typedef value_type* pointer;
+ typedef const value_type* const_pointer;
+
+ template <class U> struct rebind {typedef test_allocator<U> other;};
+
+ test_allocator() throw() : data_(-1) {}
+ explicit test_allocator(int i) throw() : data_(i) {}
+ test_allocator(const test_allocator& a) throw()
+ : data_(a.data_) {}
+ template <class U> test_allocator(const test_allocator<U>& a) throw()
+ : data_(a.data_) {}
+ ~test_allocator() throw() {data_ = 0;}
+
+ friend bool operator==(const test_allocator& x, const test_allocator& y)
+ {return x.data_ == y.data_;}
+ friend bool operator!=(const test_allocator& x, const test_allocator& y)
+ {return !(x == y);}
+};
+
+template <class T>
+class other_allocator
+{
+ int data_;
+
+ template <class U> friend class other_allocator;
+
+public:
+ typedef T value_type;
+
+ other_allocator() : data_(-1) {}
+ explicit other_allocator(int i) : data_(i) {}
+ template <class U> other_allocator(const other_allocator<U>& a)
+ : data_(a.data_) {}
+ T* allocate(std::size_t n)
+ {return (T*)::operator new(n * sizeof(T));}
+ void deallocate(T* p, std::size_t n)
+ {::operator delete((void*)p);}
+
+ other_allocator select_on_container_copy_construction() const
+ {return other_allocator(-2);}
+
+ friend bool operator==(const other_allocator& x, const other_allocator& y)
+ {return x.data_ == y.data_;}
+ friend bool operator!=(const other_allocator& x, const other_allocator& y)
+ {return !(x == y);}
+
+ typedef std::true_type propagate_on_container_copy_assignment;
+ typedef std::true_type propagate_on_container_move_assignment;
+ typedef std::true_type propagate_on_container_swap;
+
+#ifdef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+ std::size_t max_size() const
+ {return UINT_MAX / sizeof(T);}
+#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE
+
+};
+
+#endif // TEST_ALLOCATOR_H
diff --git a/test/support/test_iterators.h b/test/support/test_iterators.h
new file mode 100644
index 000000000000..e09fd834d215
--- /dev/null
+++ b/test/support/test_iterators.h
@@ -0,0 +1,329 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef ITERATORS_H
+#define ITERATORS_H
+
+#include <iterator>
+#include <cassert>
+
+#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS
+#define DELETE_FUNCTION = delete
+#else
+#define DELETE_FUNCTION
+#endif
+
+template <class It>
+class output_iterator
+{
+ It it_;
+
+ template <class U> friend class output_iterator;
+public:
+ typedef std::output_iterator_tag iterator_category;
+ typedef void value_type;
+ typedef typename std::iterator_traits<It>::difference_type difference_type;
+ typedef It pointer;
+ typedef typename std::iterator_traits<It>::reference reference;
+
+ It base() const {return it_;}
+
+ output_iterator () {}
+ explicit output_iterator(It it) : it_(it) {}
+ template <class U>
+ output_iterator(const output_iterator<U>& u) :it_(u.it_) {}
+
+ reference operator*() const {return *it_;}
+
+ output_iterator& operator++() {++it_; return *this;}
+ output_iterator operator++(int)
+ {output_iterator tmp(*this); ++(*this); return tmp;}
+
+ template <class T>
+ void operator,(T const &) DELETE_FUNCTION;
+};
+
+template <class It>
+class input_iterator
+{
+ It it_;
+
+ template <class U> friend class input_iterator;
+public:
+ typedef std::input_iterator_tag iterator_category;
+ typedef typename std::iterator_traits<It>::value_type value_type;
+ typedef typename std::iterator_traits<It>::difference_type difference_type;
+ typedef It pointer;
+ typedef typename std::iterator_traits<It>::reference reference;
+
+ It base() const {return it_;}
+
+ input_iterator() : it_() {}
+ explicit input_iterator(It it) : it_(it) {}
+ template <class U>
+ input_iterator(const input_iterator<U>& u) :it_(u.it_) {}
+
+ reference operator*() const {return *it_;}
+ pointer operator->() const {return it_;}
+
+ input_iterator& operator++() {++it_; return *this;}
+ input_iterator operator++(int)
+ {input_iterator tmp(*this); ++(*this); return tmp;}
+
+ friend bool operator==(const input_iterator& x, const input_iterator& y)
+ {return x.it_ == y.it_;}
+ friend bool operator!=(const input_iterator& x, const input_iterator& y)
+ {return !(x == y);}
+
+ template <class T>
+ void operator,(T const &) DELETE_FUNCTION;
+};
+
+template <class T, class U>
+inline
+bool
+operator==(const input_iterator<T>& x, const input_iterator<U>& y)
+{
+ return x.base() == y.base();
+}
+
+template <class T, class U>
+inline
+bool
+operator!=(const input_iterator<T>& x, const input_iterator<U>& y)
+{
+ return !(x == y);
+}
+
+template <class It>
+class forward_iterator
+{
+ It it_;
+
+ template <class U> friend class forward_iterator;
+public:
+ typedef std::forward_iterator_tag iterator_category;
+ typedef typename std::iterator_traits<It>::value_type value_type;
+ typedef typename std::iterator_traits<It>::difference_type difference_type;
+ typedef It pointer;
+ typedef typename std::iterator_traits<It>::reference reference;
+
+ It base() const {return it_;}
+
+ forward_iterator() : it_() {}
+ explicit forward_iterator(It it) : it_(it) {}
+ template <class U>
+ forward_iterator(const forward_iterator<U>& u) :it_(u.it_) {}
+
+ reference operator*() const {return *it_;}
+ pointer operator->() const {return it_;}
+
+ forward_iterator& operator++() {++it_; return *this;}
+ forward_iterator operator++(int)
+ {forward_iterator tmp(*this); ++(*this); return tmp;}
+
+ friend bool operator==(const forward_iterator& x, const forward_iterator& y)
+ {return x.it_ == y.it_;}
+ friend bool operator!=(const forward_iterator& x, const forward_iterator& y)
+ {return !(x == y);}
+
+ template <class T>
+ void operator,(T const &) DELETE_FUNCTION;
+};
+
+template <class T, class U>
+inline
+bool
+operator==(const forward_iterator<T>& x, const forward_iterator<U>& y)
+{
+ return x.base() == y.base();
+}
+
+template <class T, class U>
+inline
+bool
+operator!=(const forward_iterator<T>& x, const forward_iterator<U>& y)
+{
+ return !(x == y);
+}
+
+template <class It>
+class bidirectional_iterator
+{
+ It it_;
+
+ template <class U> friend class bidirectional_iterator;
+public:
+ typedef std::bidirectional_iterator_tag iterator_category;
+ typedef typename std::iterator_traits<It>::value_type value_type;
+ typedef typename std::iterator_traits<It>::difference_type difference_type;
+ typedef It pointer;
+ typedef typename std::iterator_traits<It>::reference reference;
+
+ It base() const {return it_;}
+
+ bidirectional_iterator() : it_() {}
+ explicit bidirectional_iterator(It it) : it_(it) {}
+ template <class U>
+ bidirectional_iterator(const bidirectional_iterator<U>& u) :it_(u.it_) {}
+
+ reference operator*() const {return *it_;}
+ pointer operator->() const {return it_;}
+
+ bidirectional_iterator& operator++() {++it_; return *this;}
+ bidirectional_iterator operator++(int)
+ {bidirectional_iterator tmp(*this); ++(*this); return tmp;}
+
+ bidirectional_iterator& operator--() {--it_; return *this;}
+ bidirectional_iterator operator--(int)
+ {bidirectional_iterator tmp(*this); --(*this); return tmp;}
+
+ template <class T>
+ void operator,(T const &) DELETE_FUNCTION;
+};
+
+template <class T, class U>
+inline
+bool
+operator==(const bidirectional_iterator<T>& x, const bidirectional_iterator<U>& y)
+{
+ return x.base() == y.base();
+}
+
+template <class T, class U>
+inline
+bool
+operator!=(const bidirectional_iterator<T>& x, const bidirectional_iterator<U>& y)
+{
+ return !(x == y);
+}
+
+template <class It>
+class random_access_iterator
+{
+ It it_;
+
+ template <class U> friend class random_access_iterator;
+public:
+ typedef std::random_access_iterator_tag iterator_category;
+ typedef typename std::iterator_traits<It>::value_type value_type;
+ typedef typename std::iterator_traits<It>::difference_type difference_type;
+ typedef It pointer;
+ typedef typename std::iterator_traits<It>::reference reference;
+
+ It base() const {return it_;}
+
+ random_access_iterator() : it_() {}
+ explicit random_access_iterator(It it) : it_(it) {}
+ template <class U>
+ random_access_iterator(const random_access_iterator<U>& u) :it_(u.it_) {}
+
+ reference operator*() const {return *it_;}
+ pointer operator->() const {return it_;}
+
+ random_access_iterator& operator++() {++it_; return *this;}
+ random_access_iterator operator++(int)
+ {random_access_iterator tmp(*this); ++(*this); return tmp;}
+
+ random_access_iterator& operator--() {--it_; return *this;}
+ random_access_iterator operator--(int)
+ {random_access_iterator tmp(*this); --(*this); return tmp;}
+
+ random_access_iterator& operator+=(difference_type n) {it_ += n; return *this;}
+ random_access_iterator operator+(difference_type n) const
+ {random_access_iterator tmp(*this); tmp += n; return tmp;}
+ friend random_access_iterator operator+(difference_type n, random_access_iterator x)
+ {x += n; return x;}
+ random_access_iterator& operator-=(difference_type n) {return *this += -n;}
+ random_access_iterator operator-(difference_type n) const
+ {random_access_iterator tmp(*this); tmp -= n; return tmp;}
+
+ reference operator[](difference_type n) const {return it_[n];}
+
+ template <class T>
+ void operator,(T const &) DELETE_FUNCTION;
+};
+
+template <class T, class U>
+inline
+bool
+operator==(const random_access_iterator<T>& x, const random_access_iterator<U>& y)
+{
+ return x.base() == y.base();
+}
+
+template <class T, class U>
+inline
+bool
+operator!=(const random_access_iterator<T>& x, const random_access_iterator<U>& y)
+{
+ return !(x == y);
+}
+
+template <class T, class U>
+inline
+bool
+operator<(const random_access_iterator<T>& x, const random_access_iterator<U>& y)
+{
+ return x.base() < y.base();
+}
+
+template <class T, class U>
+inline
+bool
+operator<=(const random_access_iterator<T>& x, const random_access_iterator<U>& y)
+{
+ return !(y < x);
+}
+
+template <class T, class U>
+inline
+bool
+operator>(const random_access_iterator<T>& x, const random_access_iterator<U>& y)
+{
+ return y < x;
+}
+
+template <class T, class U>
+inline
+bool
+operator>=(const random_access_iterator<T>& x, const random_access_iterator<U>& y)
+{
+ return !(x < y);
+}
+
+template <class T, class U>
+inline
+typename std::iterator_traits<T>::difference_type
+operator-(const random_access_iterator<T>& x, const random_access_iterator<U>& y)
+{
+ return x.base() - y.base();
+}
+
+template <class Iter>
+inline Iter base(output_iterator<Iter> i) { return i.base(); }
+
+template <class Iter>
+inline Iter base(input_iterator<Iter> i) { return i.base(); }
+
+template <class Iter>
+inline Iter base(forward_iterator<Iter> i) { return i.base(); }
+
+template <class Iter>
+inline Iter base(bidirectional_iterator<Iter> i) { return i.base(); }
+
+template <class Iter>
+inline Iter base(random_access_iterator<Iter> i) { return i.base(); }
+
+template <class Iter> // everything else
+inline Iter base(Iter i) { return i; }
+
+#undef DELETE_FUNCTION
+
+#endif // ITERATORS_H
diff --git a/test/support/test_macros.h b/test/support/test_macros.h
new file mode 100644
index 000000000000..a08ca87be935
--- /dev/null
+++ b/test/support/test_macros.h
@@ -0,0 +1,83 @@
+// -*- C++ -*-
+//===---------------------------- test_macros.h ---------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef SUPPORT_TEST_MACROS_HPP
+#define SUPPORT_TEST_MACROS_HPP
+
+#define TEST_CONCAT1(X, Y) X##Y
+#define TEST_CONCAT(X, Y) TEST_CONCAT1(X, Y)
+
+#ifdef __has_extension
+#define TEST_HAS_EXTENSION(X) __has_extension(X)
+#else
+#define TEST_HAS_EXTENSION(X) 0
+#endif
+
+/* Make a nice name for the standard version */
+#if __cplusplus <= 199711L
+# define TEST_STD_VER 3
+#elif __cplusplus <= 201103L
+# define TEST_STD_VER 11
+#elif __cplusplus <= 201402L
+# define TEST_STD_VER 14
+#else
+# define TEST_STD_VER 99 // greater than current standard
+#endif
+
+/* Features that were introduced in C++11 */
+#if TEST_STD_VER >= 11
+#define TEST_HAS_RVALUE_REFERENCES
+#define TEST_HAS_VARIADIC_TEMPLATES
+#define TEST_HAS_INITIALIZER_LISTS
+#define TEST_HAS_BASIC_CONSTEXPR
+#endif
+
+/* Features that were introduced in C++14 */
+#if TEST_STD_VER >= 14
+#define TEST_HAS_EXTENDED_CONSTEXPR
+#define TEST_HAS_VARIABLE_TEMPLATES
+#endif
+
+/* Features that were introduced after C++14 */
+#if TEST_STD_VER > 14
+#endif
+
+#if TEST_HAS_EXTENSION(cxx_decltype) || TEST_STD_VER >= 11
+#define TEST_DECLTYPE(T) decltype(T)
+#else
+#define TEST_DECLTYPE(T) __typeof__(T)
+#endif
+
+#if TEST_STD_VER >= 11
+#define TEST_NOEXCEPT noexcept
+#else
+#define TEST_NOEXCEPT
+#endif
+
+#if TEST_HAS_EXTENSION(cxx_static_assert) || TEST_STD_VER >= 11
+# define TEST_STATIC_ASSERT(Expr, Msg) static_assert(Expr, Msg)
+#else
+# define TEST_STATIC_ASSERT(Expr, Msg) \
+ typedef ::test_detail::static_assert_check<sizeof( \
+ ::test_detail::static_assert_incomplete_test<(Expr)>)> \
+ TEST_CONCAT(test_assert, __LINE__)
+#
+#endif
+
+namespace test_detail {
+
+template <bool> struct static_assert_incomplete_test;
+template <> struct static_assert_incomplete_test<true> {};
+template <unsigned> struct static_assert_check {};
+
+} // end namespace test_detail
+
+
+#endif // SUPPORT_TEST_MACROS_HPP
diff --git a/test/support/tracked_value.h b/test/support/tracked_value.h
new file mode 100644
index 000000000000..b0869b23bdcb
--- /dev/null
+++ b/test/support/tracked_value.h
@@ -0,0 +1,50 @@
+#ifndef SUPPORT_TRACKED_VALUE_H
+#define SUPPORT_TRACKED_VALUE_H
+
+#include <cassert>
+
+struct TrackedValue {
+ enum State { CONSTRUCTED, MOVED_FROM, DESTROYED };
+ State state;
+
+ TrackedValue() : state(State::CONSTRUCTED) {}
+
+ TrackedValue(TrackedValue const& t) : state(State::CONSTRUCTED) {
+ assert(t.state != State::MOVED_FROM && "copying a moved-from object");
+ assert(t.state != State::DESTROYED && "copying a destroyed object");
+ }
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ TrackedValue(TrackedValue&& t) : state(State::CONSTRUCTED) {
+ assert(t.state != State::MOVED_FROM && "double moving from an object");
+ assert(t.state != State::DESTROYED && "moving from a destroyed object");
+ t.state = State::MOVED_FROM;
+ }
+#endif
+
+ TrackedValue& operator=(TrackedValue const& t) {
+ assert(state != State::DESTROYED && "copy assigning into destroyed object");
+ assert(t.state != State::MOVED_FROM && "copying a moved-from object");
+ assert(t.state != State::DESTROYED && "copying a destroyed object");
+ state = t.state;
+ return *this;
+ }
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ TrackedValue& operator=(TrackedValue&& t) {
+ assert(state != State::DESTROYED && "move assigning into destroyed object");
+ assert(t.state != State::MOVED_FROM && "double moving from an object");
+ assert(t.state != State::DESTROYED && "moving from a destroyed object");
+ state = t.state;
+ t.state = State::MOVED_FROM;
+ return *this;
+ }
+#endif
+
+ ~TrackedValue() {
+ assert(state != State::DESTROYED && "double-destroying an object");
+ state = State::DESTROYED;
+ }
+};
+
+#endif // SUPPORT_TRACKED_VALUE_H
diff --git a/test/support/user_defined_integral.hpp b/test/support/user_defined_integral.hpp
new file mode 100644
index 000000000000..3b0f7a19fcf4
--- /dev/null
+++ b/test/support/user_defined_integral.hpp
@@ -0,0 +1,44 @@
+#ifndef SUPPORT_USER_DEFINED_INTEGRAL_HPP
+#define SUPPORT_USER_DEFINED_INTEGRAL_HPP
+
+template <class T>
+struct UserDefinedIntegral
+{
+ UserDefinedIntegral() : value(0) {}
+ UserDefinedIntegral(T v) : value(v) {}
+ operator T() const { return value; }
+ T value;
+};
+
+// Poison the arithmetic and comparison operations
+template <class T, class U>
+void operator+(UserDefinedIntegral<T>, UserDefinedIntegral<U>);
+
+template <class T, class U>
+void operator-(UserDefinedIntegral<T>, UserDefinedIntegral<U>);
+
+template <class T, class U>
+void operator*(UserDefinedIntegral<T>, UserDefinedIntegral<U>);
+
+template <class T, class U>
+void operator/(UserDefinedIntegral<T>, UserDefinedIntegral<U>);
+
+template <class T, class U>
+void operator==(UserDefinedIntegral<T>, UserDefinedIntegral<U>);
+
+template <class T, class U>
+void operator!=(UserDefinedIntegral<T>, UserDefinedIntegral<U>);
+
+template <class T, class U>
+void operator<(UserDefinedIntegral<T>, UserDefinedIntegral<U>);
+
+template <class T, class U>
+void operator>(UserDefinedIntegral<T>, UserDefinedIntegral<U>);
+
+template <class T, class U>
+void operator<=(UserDefinedIntegral<T>, UserDefinedIntegral<U>);
+
+template <class T, class U>
+void operator>=(UserDefinedIntegral<T>, UserDefinedIntegral<U>);
+
+#endif // SUPPORT_USER_DEFINED_INTEGRAL_HPP
diff --git a/test/testit b/test/testit
new file mode 100755
index 000000000000..821292efb5a3
--- /dev/null
+++ b/test/testit
@@ -0,0 +1,180 @@
+#!/bin/sh
+# //===--------------------------- testit ---------------------------------===//
+# //
+# // The LLVM Compiler Infrastructure
+# //
+# // This file is distributed under the University of Illinois Open Source
+# // License. See LICENSE.TXT for details.
+# //
+# //===--------------------------------------------------------------------===//
+
+currentpath=`pwd`
+origpath=$currentpath
+currentdir=`basename $currentpath`
+while [ $currentdir != "test" ]; do
+ if [ $currentdir = "/" ]
+ then
+ echo "current directory must be in or under \"test\"."
+ exit 1
+ fi
+ cd ..
+ currentpath=`pwd`
+ currentdir=`basename $currentpath`
+done
+
+cd ..
+LIBCXX_ROOT=`pwd`
+cd $origpath
+
+if [ -z "$CC" ]
+then
+ if which xcrun >/dev/null
+ then
+ CC="xcrun clang++"
+ else
+ CC=clang++
+ fi
+fi
+
+if [ -z "$CXX_LANG" ]
+then
+ CXX_LANG=c++11
+fi
+if [ -z "$OPTIONS" ]
+then
+ OPTIONS="-std=${CXX_LANG} -stdlib=libc++"
+fi
+OPTIONS="$OPTIONS -I$LIBCXX_ROOT/test/support"
+
+if [ -z "$HEADER_INCLUDE" ]
+then
+ HEADER_INCLUDE="-I$LIBCXX_ROOT/include"
+fi
+
+if [ -z "$SOURCE_LIB" ]
+then
+ SOURCE_LIB="-L$LIBCXX_ROOT/lib"
+fi
+
+case $TRIPLE in
+ *-*-mingw* | *-*-cygwin* | *-*-win*)
+ TEST_EXE=test.exe
+ ;;
+ *)
+ TEST_EXE=a.out
+ ;;
+esac
+
+case $(uname -s) in
+ NetBSD)
+ THREAD_FLAGS=-lpthread
+ ;;
+esac
+
+FAIL=0
+PASS=0
+UNIMPLEMENTED=0
+IMPLEMENTED_FAIL=0
+IMPLEMENTED_PASS=0
+
+afunc() {
+ fail=0
+ pass=0
+ if (ls ${TEST_PREFIX}*fail.cpp > /dev/null 2>&1)
+ then
+ for FILE in $(ls ${TEST_PREFIX}*fail.cpp); do
+ if $CC $OPTIONS $HEADER_INCLUDE $SOURCE_LIB $FILE $LIBS -o ./$TEST_EXE > /dev/null 2>&1
+ then
+ rm ./$TEST_EXE
+ echo "$FILE should not compile"
+ fail=$(($fail+1))
+ else
+ pass=$(($pass+1))
+ fi
+ done
+ fi
+
+ if (ls ${TEST_PREFIX}*pass.cpp > /dev/null 2>&1)
+ then
+ for FILE in $(ls ${TEST_PREFIX}*pass.cpp); do
+ if [ "$VERBOSE" ]
+ then
+ echo "Running test: " $FILE
+ fi
+ if $CC $OPTIONS $HEADER_INCLUDE $SOURCE_LIB $FILE $LIBS $(test $1 = no || echo $THREAD_FLAGS) -o ./$TEST_EXE
+ then
+ if ./$TEST_EXE
+ then
+ rm ./$TEST_EXE
+ pass=$(($pass+1))
+ else
+ echo "`pwd`/$FILE failed at run time"
+ echo "Compile line was:" $CC $OPTIONS $HEADER_INCLUDE $SOURCE_LIB $FILE $LIBS $(test $1 = no || echo $THREAD_FLAGS)
+ fail=$(($fail+1))
+ rm ./$TEST_EXE
+ fi
+ else
+ echo "`pwd`/$FILE failed to compile"
+ echo "Compile line was:" $CC $OPTIONS $HEADER_INCLUDE $SOURCE_LIB $FILE $LIBS $(test $1 = no || echo $THREAD_FLAGS)
+ fail=$(($fail+1))
+ fi
+ done
+ fi
+
+ if [ $fail -gt 0 ]
+ then
+ echo "failed $fail tests in `pwd`"
+ IMPLEMENTED_FAIL=$(($IMPLEMENTED_FAIL+1))
+ fi
+ if [ $pass -gt 0 ]
+ then
+ echo "passed $pass tests in `pwd`"
+ if [ $fail -eq 0 ]
+ then
+ IMPLEMENTED_PASS=$((IMPLEMENTED_PASS+1))
+ fi
+ fi
+ if [ $fail -eq 0 -a $pass -eq 0 ]
+ then
+ echo "not implemented: `pwd`"
+ UNIMPLEMENTED=$(($UNIMPLEMENTED+1))
+ fi
+
+ FAIL=$(($FAIL+$fail))
+ PASS=$(($PASS+$pass))
+
+ for FILE in *
+ do
+ if [ -d "$FILE" ];
+ then
+ cd $FILE
+ if [ $FILE = thread -o $1 = yes ]; then
+ afunc yes
+ else
+ afunc no
+ fi
+ cd ..
+ fi
+ done
+}
+
+afunc no
+
+echo "****************************************************"
+echo "Results for `pwd`:"
+echo "using `$CC --version`"
+echo "with $OPTIONS $HEADER_INCLUDE $SOURCE_LIB"
+echo "----------------------------------------------------"
+echo "sections without tests : $UNIMPLEMENTED"
+echo "sections with failures : $IMPLEMENTED_FAIL"
+echo "sections without failures: $IMPLEMENTED_PASS"
+echo " + ----"
+echo "total number of sections : $(($UNIMPLEMENTED+$IMPLEMENTED_FAIL+$IMPLEMENTED_PASS))"
+echo "----------------------------------------------------"
+echo "number of tests failed : $FAIL"
+echo "number of tests passed : $PASS"
+echo " + ----"
+echo "total number of tests : $(($FAIL+$PASS))"
+echo "****************************************************"
+
+exit $FAIL